ltmain.sh revision 300346ae
1300346aeSmrg#! /bin/sh
2300346aeSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
3300346aeSmrg##               by inline-source v2014-01-03.01
4d656433aSmrg
5300346aeSmrg# libtool (GNU libtool) 2.4.6
6300346aeSmrg# Provide generalized library-building support services.
7d656433aSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8d656433aSmrg
9300346aeSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc.
10d656433aSmrg# This is free software; see the source for copying conditions.  There is NO
11d656433aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12d656433aSmrg
13d656433aSmrg# GNU Libtool is free software; you can redistribute it and/or modify
14126a8a12Smrg# it under the terms of the GNU General Public License as published by
15126a8a12Smrg# the Free Software Foundation; either version 2 of the License, or
16126a8a12Smrg# (at your option) any later version.
17126a8a12Smrg#
18d656433aSmrg# As a special exception to the GNU General Public License,
19d656433aSmrg# if you distribute this file as part of a program or library that
20d656433aSmrg# is built using GNU Libtool, you may include this file under the
21d656433aSmrg# same distribution terms that you use for the rest of that program.
22d656433aSmrg#
23d656433aSmrg# GNU Libtool is distributed in the hope that it will be useful, but
24126a8a12Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
25126a8a12Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26126a8a12Smrg# General Public License for more details.
27126a8a12Smrg#
28126a8a12Smrg# You should have received a copy of the GNU General Public License
29300346aeSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
30d656433aSmrg
31d656433aSmrg
32555991fdSmrgPROGRAM=libtool
33d656433aSmrgPACKAGE=libtool
34300346aeSmrgVERSION="2.4.6 Debian-2.4.6-2"
35300346aeSmrgpackage_revision=2.4.6
36d656433aSmrg
37300346aeSmrg
38300346aeSmrg## ------ ##
39300346aeSmrg## Usage. ##
40300346aeSmrg## ------ ##
41300346aeSmrg
42300346aeSmrg# Run './libtool --help' for help with using this script from the
43300346aeSmrg# command line.
44300346aeSmrg
45300346aeSmrg
46300346aeSmrg## ------------------------------- ##
47300346aeSmrg## User overridable command paths. ##
48300346aeSmrg## ------------------------------- ##
49300346aeSmrg
50300346aeSmrg# After configure completes, it has a better idea of some of the
51300346aeSmrg# shell tools we need than the defaults used by the functions shared
52300346aeSmrg# with bootstrap, so set those here where they can still be over-
53300346aeSmrg# ridden by the user, but otherwise take precedence.
54300346aeSmrg
55300346aeSmrg: ${AUTOCONF="autoconf"}
56300346aeSmrg: ${AUTOMAKE="automake"}
57300346aeSmrg
58300346aeSmrg
59300346aeSmrg## -------------------------- ##
60300346aeSmrg## Source external libraries. ##
61300346aeSmrg## -------------------------- ##
62300346aeSmrg
63300346aeSmrg# Much of our low-level functionality needs to be sourced from external
64300346aeSmrg# libraries, which are installed to $pkgauxdir.
65300346aeSmrg
66300346aeSmrg# Set a version string for this script.
67300346aeSmrgscriptversion=2015-01-20.17; # UTC
68300346aeSmrg
69300346aeSmrg# General shell script boiler plate, and helper functions.
70300346aeSmrg# Written by Gary V. Vaughan, 2004
71300346aeSmrg
72300346aeSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc.
73300346aeSmrg# This is free software; see the source for copying conditions.  There is NO
74300346aeSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
75300346aeSmrg
76300346aeSmrg# This program is free software; you can redistribute it and/or modify
77300346aeSmrg# it under the terms of the GNU General Public License as published by
78300346aeSmrg# the Free Software Foundation; either version 3 of the License, or
79300346aeSmrg# (at your option) any later version.
80300346aeSmrg
81300346aeSmrg# As a special exception to the GNU General Public License, if you distribute
82300346aeSmrg# this file as part of a program or library that is built using GNU Libtool,
83300346aeSmrg# you may include this file under the same distribution terms that you use
84300346aeSmrg# for the rest of that program.
85300346aeSmrg
86300346aeSmrg# This program is distributed in the hope that it will be useful,
87300346aeSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
88300346aeSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
89300346aeSmrg# General Public License for more details.
90300346aeSmrg
91300346aeSmrg# You should have received a copy of the GNU General Public License
92300346aeSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>.
93300346aeSmrg
94300346aeSmrg# Please report bugs or propose patches to gary@gnu.org.
95300346aeSmrg
96300346aeSmrg
97300346aeSmrg## ------ ##
98300346aeSmrg## Usage. ##
99300346aeSmrg## ------ ##
100300346aeSmrg
101300346aeSmrg# Evaluate this file near the top of your script to gain access to
102300346aeSmrg# the functions and variables defined here:
103300346aeSmrg#
104300346aeSmrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
105300346aeSmrg#
106300346aeSmrg# If you need to override any of the default environment variable
107300346aeSmrg# settings, do that before evaluating this file.
108300346aeSmrg
109300346aeSmrg
110300346aeSmrg## -------------------- ##
111300346aeSmrg## Shell normalisation. ##
112300346aeSmrg## -------------------- ##
113300346aeSmrg
114300346aeSmrg# Some shells need a little help to be as Bourne compatible as possible.
115300346aeSmrg# Before doing anything else, make sure all that help has been provided!
116300346aeSmrg
117300346aeSmrgDUALCASE=1; export DUALCASE # for MKS sh
118300346aeSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
119d656433aSmrg  emulate sh
120d656433aSmrg  NULLCMD=:
121300346aeSmrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
122d656433aSmrg  # is contrary to our usage.  Disable this feature.
123d656433aSmrg  alias -g '${1+"$@"}'='"$@"'
124d656433aSmrg  setopt NO_GLOB_SUBST
125d656433aSmrgelse
126300346aeSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
127d656433aSmrgfi
128555991fdSmrg
129300346aeSmrg# NLS nuisances: We save the old values in case they are required later.
130300346aeSmrg_G_user_locale=
131300346aeSmrg_G_safe_locale=
132300346aeSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
133d656433aSmrgdo
134300346aeSmrg  eval "if test set = \"\${$_G_var+set}\"; then
135300346aeSmrg          save_$_G_var=\$$_G_var
136300346aeSmrg          $_G_var=C
137300346aeSmrg	  export $_G_var
138300346aeSmrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
139300346aeSmrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
140d656433aSmrg	fi"
141d656433aSmrgdone
142d656433aSmrg
143300346aeSmrg# CDPATH.
144300346aeSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
145d656433aSmrg
146300346aeSmrg# Make sure IFS has a sensible default
147300346aeSmrgsp=' '
148300346aeSmrgnl='
149300346aeSmrg'
150300346aeSmrgIFS="$sp	$nl"
151300346aeSmrg
152300346aeSmrg# There are apparently some retarded systems that use ';' as a PATH separator!
153300346aeSmrgif test "${PATH_SEPARATOR+set}" != set; then
154300346aeSmrg  PATH_SEPARATOR=:
155300346aeSmrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
156300346aeSmrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
157300346aeSmrg      PATH_SEPARATOR=';'
158300346aeSmrg  }
159300346aeSmrgfi
160d656433aSmrg
161d656433aSmrg
162d656433aSmrg
163300346aeSmrg## ------------------------- ##
164300346aeSmrg## Locate command utilities. ##
165300346aeSmrg## ------------------------- ##
166300346aeSmrg
167300346aeSmrg
168300346aeSmrg# func_executable_p FILE
169300346aeSmrg# ----------------------
170300346aeSmrg# Check that FILE is an executable regular file.
171300346aeSmrgfunc_executable_p ()
172300346aeSmrg{
173300346aeSmrg    test -f "$1" && test -x "$1"
174300346aeSmrg}
175300346aeSmrg
176300346aeSmrg
177300346aeSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
178300346aeSmrg# --------------------------------------------
179300346aeSmrg# Search for either a program that responds to --version with output
180300346aeSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
181300346aeSmrg# trying all the directories in PATH with each of the elements of
182300346aeSmrg# PROGS_LIST.
183300346aeSmrg#
184300346aeSmrg# CHECK_FUNC should accept the path to a candidate program, and
185300346aeSmrg# set $func_check_prog_result if it truncates its output less than
186300346aeSmrg# $_G_path_prog_max characters.
187300346aeSmrgfunc_path_progs ()
188300346aeSmrg{
189300346aeSmrg    _G_progs_list=$1
190300346aeSmrg    _G_check_func=$2
191300346aeSmrg    _G_PATH=${3-"$PATH"}
192300346aeSmrg
193300346aeSmrg    _G_path_prog_max=0
194300346aeSmrg    _G_path_prog_found=false
195300346aeSmrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
196300346aeSmrg    for _G_dir in $_G_PATH; do
197300346aeSmrg      IFS=$_G_save_IFS
198300346aeSmrg      test -z "$_G_dir" && _G_dir=.
199300346aeSmrg      for _G_prog_name in $_G_progs_list; do
200300346aeSmrg        for _exeext in '' .EXE; do
201300346aeSmrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
202300346aeSmrg          func_executable_p "$_G_path_prog" || continue
203300346aeSmrg          case `"$_G_path_prog" --version 2>&1` in
204300346aeSmrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
205300346aeSmrg            *)     $_G_check_func $_G_path_prog
206300346aeSmrg		   func_path_progs_result=$func_check_prog_result
207300346aeSmrg		   ;;
208300346aeSmrg          esac
209300346aeSmrg          $_G_path_prog_found && break 3
210300346aeSmrg        done
211300346aeSmrg      done
212300346aeSmrg    done
213300346aeSmrg    IFS=$_G_save_IFS
214300346aeSmrg    test -z "$func_path_progs_result" && {
215300346aeSmrg      echo "no acceptable sed could be found in \$PATH" >&2
216300346aeSmrg      exit 1
217300346aeSmrg    }
218300346aeSmrg}
219300346aeSmrg
220300346aeSmrg
221300346aeSmrg# We want to be able to use the functions in this file before configure
222300346aeSmrg# has figured out where the best binaries are kept, which means we have
223300346aeSmrg# to search for them ourselves - except when the results are already set
224300346aeSmrg# where we skip the searches.
225300346aeSmrg
226300346aeSmrg# Unless the user overrides by setting SED, search the path for either GNU
227300346aeSmrg# sed, or the sed that truncates its output the least.
228300346aeSmrgtest -z "$SED" && {
229300346aeSmrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
230300346aeSmrg  for _G_i in 1 2 3 4 5 6 7; do
231300346aeSmrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
232300346aeSmrg  done
233300346aeSmrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
234300346aeSmrg  _G_sed_script=
235300346aeSmrg
236300346aeSmrg  func_check_prog_sed ()
237300346aeSmrg  {
238300346aeSmrg    _G_path_prog=$1
239300346aeSmrg
240300346aeSmrg    _G_count=0
241300346aeSmrg    printf 0123456789 >conftest.in
242300346aeSmrg    while :
243300346aeSmrg    do
244300346aeSmrg      cat conftest.in conftest.in >conftest.tmp
245300346aeSmrg      mv conftest.tmp conftest.in
246300346aeSmrg      cp conftest.in conftest.nl
247300346aeSmrg      echo '' >> conftest.nl
248300346aeSmrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
249300346aeSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
250300346aeSmrg      _G_count=`expr $_G_count + 1`
251300346aeSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
252300346aeSmrg        # Best one so far, save it but keep looking for a better one
253300346aeSmrg        func_check_prog_result=$_G_path_prog
254300346aeSmrg        _G_path_prog_max=$_G_count
255300346aeSmrg      fi
256300346aeSmrg      # 10*(2^10) chars as input seems more than enough
257300346aeSmrg      test 10 -lt "$_G_count" && break
258300346aeSmrg    done
259300346aeSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
260300346aeSmrg  }
261300346aeSmrg
262300346aeSmrg  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
263300346aeSmrg  rm -f conftest.sed
264300346aeSmrg  SED=$func_path_progs_result
265300346aeSmrg}
266300346aeSmrg
267300346aeSmrg
268300346aeSmrg# Unless the user overrides by setting GREP, search the path for either GNU
269300346aeSmrg# grep, or the grep that truncates its output the least.
270300346aeSmrgtest -z "$GREP" && {
271300346aeSmrg  func_check_prog_grep ()
272300346aeSmrg  {
273300346aeSmrg    _G_path_prog=$1
274300346aeSmrg
275300346aeSmrg    _G_count=0
276300346aeSmrg    _G_path_prog_max=0
277300346aeSmrg    printf 0123456789 >conftest.in
278300346aeSmrg    while :
279300346aeSmrg    do
280300346aeSmrg      cat conftest.in conftest.in >conftest.tmp
281300346aeSmrg      mv conftest.tmp conftest.in
282300346aeSmrg      cp conftest.in conftest.nl
283300346aeSmrg      echo 'GREP' >> conftest.nl
284300346aeSmrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
285300346aeSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
286300346aeSmrg      _G_count=`expr $_G_count + 1`
287300346aeSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
288300346aeSmrg        # Best one so far, save it but keep looking for a better one
289300346aeSmrg        func_check_prog_result=$_G_path_prog
290300346aeSmrg        _G_path_prog_max=$_G_count
291300346aeSmrg      fi
292300346aeSmrg      # 10*(2^10) chars as input seems more than enough
293300346aeSmrg      test 10 -lt "$_G_count" && break
294300346aeSmrg    done
295300346aeSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
296300346aeSmrg  }
297300346aeSmrg
298300346aeSmrg  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
299300346aeSmrg  GREP=$func_path_progs_result
300300346aeSmrg}
301300346aeSmrg
302300346aeSmrg
303300346aeSmrg## ------------------------------- ##
304300346aeSmrg## User overridable command paths. ##
305300346aeSmrg## ------------------------------- ##
306300346aeSmrg
307300346aeSmrg# All uppercase variable names are used for environment variables.  These
308300346aeSmrg# variables can be overridden by the user before calling a script that
309300346aeSmrg# uses them if a suitable command of that name is not already available
310300346aeSmrg# in the command search PATH.
311d656433aSmrg
312d656433aSmrg: ${CP="cp -f"}
313300346aeSmrg: ${ECHO="printf %s\n"}
314300346aeSmrg: ${EGREP="$GREP -E"}
315300346aeSmrg: ${FGREP="$GREP -F"}
316300346aeSmrg: ${LN_S="ln -s"}
317d656433aSmrg: ${MAKE="make"}
318d656433aSmrg: ${MKDIR="mkdir"}
319d656433aSmrg: ${MV="mv -f"}
320d656433aSmrg: ${RM="rm -f"}
321d656433aSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
322d656433aSmrg
323d656433aSmrg
324300346aeSmrg## -------------------- ##
325300346aeSmrg## Useful sed snippets. ##
326300346aeSmrg## -------------------- ##
3273c15da26Smrg
328300346aeSmrgsed_dirname='s|/[^/]*$||'
329300346aeSmrgsed_basename='s|^.*/||'
3303c15da26Smrg
331300346aeSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
332300346aeSmrg# metacharacters that are still active within double-quoted strings.
333300346aeSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
3343c15da26Smrg
335300346aeSmrg# Same as above, but do not quote variable references.
336300346aeSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
3373c15da26Smrg
338300346aeSmrg# Sed substitution that turns a string into a regex matching for the
339300346aeSmrg# string literally.
340300346aeSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
3413c15da26Smrg
342300346aeSmrg# Sed substitution that converts a w32 file name or path
343300346aeSmrg# that contains forward slashes, into one that contains
344300346aeSmrg# (escaped) backslashes.  A very naive implementation.
345300346aeSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
346300346aeSmrg
347300346aeSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
348300346aeSmrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
349300346aeSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from
350300346aeSmrg# expansion.  Since each input '\' is now two '\'s, look for any number
351300346aeSmrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
352300346aeSmrg_G_bs='\\'
353300346aeSmrg_G_bs2='\\\\'
354300346aeSmrg_G_bs4='\\\\\\\\'
355300346aeSmrg_G_dollar='\$'
356300346aeSmrgsed_double_backslash="\
357300346aeSmrg  s/$_G_bs4/&\\
358300346aeSmrg/g
359300346aeSmrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
360300346aeSmrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
361300346aeSmrg  s/\n//g"
3623c15da26Smrg
363d656433aSmrg
364300346aeSmrg## ----------------- ##
365300346aeSmrg## Global variables. ##
366300346aeSmrg## ----------------- ##
367126a8a12Smrg
368300346aeSmrg# Except for the global variables explicitly listed below, the following
369300346aeSmrg# functions in the '^func_' namespace, and the '^require_' namespace
370300346aeSmrg# variables initialised in the 'Resource management' section, sourcing
371300346aeSmrg# this file will not pollute your global namespace with anything
372300346aeSmrg# else. There's no portable way to scope variables in Bourne shell
373300346aeSmrg# though, so actually running these functions will sometimes place
374300346aeSmrg# results into a variable named after the function, and often use
375300346aeSmrg# temporary variables in the '^_G_' namespace. If you are careful to
376300346aeSmrg# avoid using those namespaces casually in your sourcing script, things
377300346aeSmrg# should continue to work as you expect. And, of course, you can freely
378300346aeSmrg# overwrite any of the functions or variables defined here before
379300346aeSmrg# calling anything to customize them.
380555991fdSmrg
381300346aeSmrgEXIT_SUCCESS=0
382300346aeSmrgEXIT_FAILURE=1
383300346aeSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
384300346aeSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
385555991fdSmrg
386300346aeSmrg# Allow overriding, eg assuming that you follow the convention of
387300346aeSmrg# putting '$debug_cmd' at the start of all your functions, you can get
388300346aeSmrg# bash to show function call trace with:
389300346aeSmrg#
390300346aeSmrg#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
391300346aeSmrgdebug_cmd=${debug_cmd-":"}
392300346aeSmrgexit_cmd=:
393555991fdSmrg
394300346aeSmrg# By convention, finish your script with:
395300346aeSmrg#
396300346aeSmrg#    exit $exit_status
397300346aeSmrg#
398300346aeSmrg# so that you can set exit_status to non-zero if you want to indicate
399300346aeSmrg# something went wrong during execution without actually bailing out at
400300346aeSmrg# the point of failure.
401300346aeSmrgexit_status=$EXIT_SUCCESS
402555991fdSmrg
403300346aeSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
404300346aeSmrg# is ksh but when the shell is invoked as "sh" and the current value of
405300346aeSmrg# the _XPG environment variable is not equal to 1 (one), the special
406300346aeSmrg# positional parameter $0, within a function call, is the name of the
407300346aeSmrg# function.
408300346aeSmrgprogpath=$0
409126a8a12Smrg
410300346aeSmrg# The name of this program.
411300346aeSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
412126a8a12Smrg
413300346aeSmrg# Make sure we have an absolute progpath for reexecution:
414d656433aSmrgcase $progpath in
415d656433aSmrg  [\\/]*|[A-Za-z]:\\*) ;;
416d656433aSmrg  *[\\/]*)
417300346aeSmrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
418d656433aSmrg     progdir=`cd "$progdir" && pwd`
419300346aeSmrg     progpath=$progdir/$progname
420d656433aSmrg     ;;
421d656433aSmrg  *)
422300346aeSmrg     _G_IFS=$IFS
4230a6b08f8Smrg     IFS=${PATH_SEPARATOR-:}
424d656433aSmrg     for progdir in $PATH; do
425300346aeSmrg       IFS=$_G_IFS
426d656433aSmrg       test -x "$progdir/$progname" && break
427d656433aSmrg     done
428300346aeSmrg     IFS=$_G_IFS
429d656433aSmrg     test -n "$progdir" || progdir=`pwd`
430300346aeSmrg     progpath=$progdir/$progname
431d656433aSmrg     ;;
432d656433aSmrgesac
433126a8a12Smrg
434d656433aSmrg
435300346aeSmrg## ----------------- ##
436300346aeSmrg## Standard options. ##
437300346aeSmrg## ----------------- ##
4383c15da26Smrg
439300346aeSmrg# The following options affect the operation of the functions defined
440300346aeSmrg# below, and should be set appropriately depending on run-time para-
441300346aeSmrg# meters passed on the command line.
442d656433aSmrg
443d656433aSmrgopt_dry_run=false
444d656433aSmrgopt_quiet=false
445d656433aSmrgopt_verbose=false
446d656433aSmrg
447300346aeSmrg# Categories 'all' and 'none' are always available.  Append any others
448300346aeSmrg# you will pass as the first argument to func_warning from your own
449300346aeSmrg# code.
450300346aeSmrgwarning_categories=
451126a8a12Smrg
452300346aeSmrg# By default, display warnings according to 'opt_warning_types'.  Set
453300346aeSmrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
454300346aeSmrg# treat the next displayed warning as a fatal error.
455300346aeSmrgwarning_func=func_warn_and_continue
456126a8a12Smrg
457300346aeSmrg# Set to 'all' to display all warnings, 'none' to suppress all
458300346aeSmrg# warnings, or a space delimited list of some subset of
459300346aeSmrg# 'warning_categories' to display only the listed warnings.
460300346aeSmrgopt_warning_types=all
461126a8a12Smrg
462555991fdSmrg
463300346aeSmrg## -------------------- ##
464300346aeSmrg## Resource management. ##
465300346aeSmrg## -------------------- ##
466126a8a12Smrg
467300346aeSmrg# This section contains definitions for functions that each ensure a
468300346aeSmrg# particular resource (a file, or a non-empty configuration variable for
469300346aeSmrg# example) is available, and if appropriate to extract default values
470300346aeSmrg# from pertinent package files. Call them using their associated
471300346aeSmrg# 'require_*' variable to ensure that they are executed, at most, once.
472300346aeSmrg#
473300346aeSmrg# It's entirely deliberate that calling these functions can set
474300346aeSmrg# variables that don't obey the namespace limitations obeyed by the rest
475300346aeSmrg# of this file, in order that that they be as useful as possible to
476300346aeSmrg# callers.
477126a8a12Smrg
478126a8a12Smrg
479300346aeSmrg# require_term_colors
480300346aeSmrg# -------------------
481300346aeSmrg# Allow display of bold text on terminals that support it.
482300346aeSmrgrequire_term_colors=func_require_term_colors
483300346aeSmrgfunc_require_term_colors ()
484d656433aSmrg{
485300346aeSmrg    $debug_cmd
486300346aeSmrg
487300346aeSmrg    test -t 1 && {
488300346aeSmrg      # COLORTERM and USE_ANSI_COLORS environment variables take
489300346aeSmrg      # precedence, because most terminfo databases neglect to describe
490300346aeSmrg      # whether color sequences are supported.
491300346aeSmrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
492300346aeSmrg
493300346aeSmrg      if test 1 = "$USE_ANSI_COLORS"; then
494300346aeSmrg        # Standard ANSI escape sequences
495300346aeSmrg        tc_reset='[0m'
496300346aeSmrg        tc_bold='[1m';   tc_standout='[7m'
497300346aeSmrg        tc_red='[31m';   tc_green='[32m'
498300346aeSmrg        tc_blue='[34m';  tc_cyan='[36m'
499300346aeSmrg      else
500300346aeSmrg        # Otherwise trust the terminfo database after all.
501300346aeSmrg        test -n "`tput sgr0 2>/dev/null`" && {
502300346aeSmrg          tc_reset=`tput sgr0`
503300346aeSmrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
504300346aeSmrg          tc_standout=$tc_bold
505300346aeSmrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
506300346aeSmrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
507300346aeSmrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
508300346aeSmrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
509300346aeSmrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
510300346aeSmrg        }
511300346aeSmrg      fi
512300346aeSmrg    }
513126a8a12Smrg
514300346aeSmrg    require_term_colors=:
515d656433aSmrg}
516126a8a12Smrg
517126a8a12Smrg
518300346aeSmrg## ----------------- ##
519300346aeSmrg## Function library. ##
520300346aeSmrg## ----------------- ##
521300346aeSmrg
522300346aeSmrg# This section contains a variety of useful functions to call in your
523300346aeSmrg# scripts. Take note of the portable wrappers for features provided by
524300346aeSmrg# some modern shells, which will fall back to slower equivalents on
525300346aeSmrg# less featureful shells.
526300346aeSmrg
527300346aeSmrg
528300346aeSmrg# func_append VAR VALUE
529300346aeSmrg# ---------------------
530300346aeSmrg# Append VALUE onto the existing contents of VAR.
531300346aeSmrg
532300346aeSmrg  # We should try to minimise forks, especially on Windows where they are
533300346aeSmrg  # unreasonably slow, so skip the feature probes when bash or zsh are
534300346aeSmrg  # being used:
535300346aeSmrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
536300346aeSmrg    : ${_G_HAVE_ARITH_OP="yes"}
537300346aeSmrg    : ${_G_HAVE_XSI_OPS="yes"}
538300346aeSmrg    # The += operator was introduced in bash 3.1
539300346aeSmrg    case $BASH_VERSION in
540300346aeSmrg      [12].* | 3.0 | 3.0*) ;;
541300346aeSmrg      *)
542300346aeSmrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
543300346aeSmrg        ;;
544300346aeSmrg    esac
545300346aeSmrg  fi
546300346aeSmrg
547300346aeSmrg  # _G_HAVE_PLUSEQ_OP
548300346aeSmrg  # Can be empty, in which case the shell is probed, "yes" if += is
549300346aeSmrg  # useable or anything else if it does not work.
550300346aeSmrg  test -z "$_G_HAVE_PLUSEQ_OP" \
551300346aeSmrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
552300346aeSmrg    && _G_HAVE_PLUSEQ_OP=yes
553300346aeSmrg
554300346aeSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"
555300346aeSmrgthen
556300346aeSmrg  # This is an XSI compatible shell, allowing a faster implementation...
557300346aeSmrg  eval 'func_append ()
558300346aeSmrg  {
559300346aeSmrg    $debug_cmd
560300346aeSmrg
561300346aeSmrg    eval "$1+=\$2"
562300346aeSmrg  }'
563300346aeSmrgelse
564300346aeSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
565300346aeSmrg  func_append ()
566300346aeSmrg  {
567300346aeSmrg    $debug_cmd
568300346aeSmrg
569300346aeSmrg    eval "$1=\$$1\$2"
570300346aeSmrg  }
571300346aeSmrgfi
572300346aeSmrg
573300346aeSmrg
574300346aeSmrg# func_append_quoted VAR VALUE
575300346aeSmrg# ----------------------------
576300346aeSmrg# Quote VALUE and append to the end of shell variable VAR, separated
577300346aeSmrg# by a space.
578300346aeSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
579300346aeSmrg  eval 'func_append_quoted ()
580300346aeSmrg  {
581300346aeSmrg    $debug_cmd
582300346aeSmrg
583300346aeSmrg    func_quote_for_eval "$2"
584300346aeSmrg    eval "$1+=\\ \$func_quote_for_eval_result"
585300346aeSmrg  }'
586300346aeSmrgelse
587300346aeSmrg  func_append_quoted ()
588300346aeSmrg  {
589300346aeSmrg    $debug_cmd
590300346aeSmrg
591300346aeSmrg    func_quote_for_eval "$2"
592300346aeSmrg    eval "$1=\$$1\\ \$func_quote_for_eval_result"
593300346aeSmrg  }
594300346aeSmrgfi
595300346aeSmrg
596300346aeSmrg
597300346aeSmrg# func_append_uniq VAR VALUE
598300346aeSmrg# --------------------------
599300346aeSmrg# Append unique VALUE onto the existing contents of VAR, assuming
600300346aeSmrg# entries are delimited by the first character of VALUE.  For example:
601300346aeSmrg#
602300346aeSmrg#   func_append_uniq options " --another-option option-argument"
603300346aeSmrg#
604300346aeSmrg# will only append to $options if " --another-option option-argument "
605300346aeSmrg# is not already present somewhere in $options already (note spaces at
606300346aeSmrg# each end implied by leading space in second argument).
607300346aeSmrgfunc_append_uniq ()
608300346aeSmrg{
609300346aeSmrg    $debug_cmd
610300346aeSmrg
611300346aeSmrg    eval _G_current_value='`$ECHO $'$1'`'
612300346aeSmrg    _G_delim=`expr "$2" : '\(.\)'`
613300346aeSmrg
614300346aeSmrg    case $_G_delim$_G_current_value$_G_delim in
615300346aeSmrg      *"$2$_G_delim"*) ;;
616300346aeSmrg      *) func_append "$@" ;;
617300346aeSmrg    esac
618300346aeSmrg}
619300346aeSmrg
620300346aeSmrg
621300346aeSmrg# func_arith TERM...
622300346aeSmrg# ------------------
623300346aeSmrg# Set func_arith_result to the result of evaluating TERMs.
624300346aeSmrg  test -z "$_G_HAVE_ARITH_OP" \
625300346aeSmrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
626300346aeSmrg    && _G_HAVE_ARITH_OP=yes
627300346aeSmrg
628300346aeSmrgif test yes = "$_G_HAVE_ARITH_OP"; then
629300346aeSmrg  eval 'func_arith ()
630300346aeSmrg  {
631300346aeSmrg    $debug_cmd
632300346aeSmrg
633300346aeSmrg    func_arith_result=$(( $* ))
634300346aeSmrg  }'
635300346aeSmrgelse
636300346aeSmrg  func_arith ()
637300346aeSmrg  {
638300346aeSmrg    $debug_cmd
639300346aeSmrg
640300346aeSmrg    func_arith_result=`expr "$@"`
641300346aeSmrg  }
642300346aeSmrgfi
643300346aeSmrg
644300346aeSmrg
645300346aeSmrg# func_basename FILE
646300346aeSmrg# ------------------
647300346aeSmrg# Set func_basename_result to FILE with everything up to and including
648300346aeSmrg# the last / stripped.
649300346aeSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
650300346aeSmrg  # If this shell supports suffix pattern removal, then use it to avoid
651300346aeSmrg  # forking. Hide the definitions single quotes in case the shell chokes
652300346aeSmrg  # on unsupported syntax...
653300346aeSmrg  _b='func_basename_result=${1##*/}'
654300346aeSmrg  _d='case $1 in
655300346aeSmrg        */*) func_dirname_result=${1%/*}$2 ;;
656300346aeSmrg        *  ) func_dirname_result=$3        ;;
657300346aeSmrg      esac'
658300346aeSmrg
659300346aeSmrgelse
660300346aeSmrg  # ...otherwise fall back to using sed.
661300346aeSmrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
662300346aeSmrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
663300346aeSmrg      if test "X$func_dirname_result" = "X$1"; then
664300346aeSmrg        func_dirname_result=$3
665300346aeSmrg      else
666300346aeSmrg        func_append func_dirname_result "$2"
667300346aeSmrg      fi'
668300346aeSmrgfi
669300346aeSmrg
670300346aeSmrgeval 'func_basename ()
671300346aeSmrg{
672300346aeSmrg    $debug_cmd
673300346aeSmrg
674300346aeSmrg    '"$_b"'
675300346aeSmrg}'
676300346aeSmrg
677300346aeSmrg
678300346aeSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
679300346aeSmrg# -------------------------------------------
680300346aeSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
681300346aeSmrg# otherwise set result to NONDIR_REPLACEMENT.
682300346aeSmrgeval 'func_dirname ()
683300346aeSmrg{
684300346aeSmrg    $debug_cmd
685300346aeSmrg
686300346aeSmrg    '"$_d"'
687300346aeSmrg}'
688300346aeSmrg
689300346aeSmrg
690300346aeSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
691300346aeSmrg# --------------------------------------------------------
692300346aeSmrg# Perform func_basename and func_dirname in a single function
693300346aeSmrg# call:
694300346aeSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
695300346aeSmrg#             add APPEND to the result, otherwise set result
696300346aeSmrg#             to NONDIR_REPLACEMENT.
697300346aeSmrg#             value returned in "$func_dirname_result"
698300346aeSmrg#   basename: Compute filename of FILE.
699300346aeSmrg#             value retuned in "$func_basename_result"
700300346aeSmrg# For efficiency, we do not delegate to the functions above but instead
701300346aeSmrg# duplicate the functionality here.
702300346aeSmrgeval 'func_dirname_and_basename ()
703300346aeSmrg{
704300346aeSmrg    $debug_cmd
705300346aeSmrg
706300346aeSmrg    '"$_b"'
707300346aeSmrg    '"$_d"'
708300346aeSmrg}'
709300346aeSmrg
710300346aeSmrg
711300346aeSmrg# func_echo ARG...
712300346aeSmrg# ----------------
713300346aeSmrg# Echo program name prefixed message.
714300346aeSmrgfunc_echo ()
715300346aeSmrg{
716300346aeSmrg    $debug_cmd
717300346aeSmrg
718300346aeSmrg    _G_message=$*
719300346aeSmrg
720300346aeSmrg    func_echo_IFS=$IFS
721300346aeSmrg    IFS=$nl
722300346aeSmrg    for _G_line in $_G_message; do
723300346aeSmrg      IFS=$func_echo_IFS
724300346aeSmrg      $ECHO "$progname: $_G_line"
725300346aeSmrg    done
726300346aeSmrg    IFS=$func_echo_IFS
727300346aeSmrg}
728300346aeSmrg
729300346aeSmrg
730300346aeSmrg# func_echo_all ARG...
731300346aeSmrg# --------------------
732300346aeSmrg# Invoke $ECHO with all args, space-separated.
733300346aeSmrgfunc_echo_all ()
734300346aeSmrg{
735300346aeSmrg    $ECHO "$*"
736300346aeSmrg}
737300346aeSmrg
738300346aeSmrg
739300346aeSmrg# func_echo_infix_1 INFIX ARG...
740300346aeSmrg# ------------------------------
741300346aeSmrg# Echo program name, followed by INFIX on the first line, with any
742300346aeSmrg# additional lines not showing INFIX.
743300346aeSmrgfunc_echo_infix_1 ()
744300346aeSmrg{
745300346aeSmrg    $debug_cmd
746300346aeSmrg
747300346aeSmrg    $require_term_colors
748300346aeSmrg
749300346aeSmrg    _G_infix=$1; shift
750300346aeSmrg    _G_indent=$_G_infix
751300346aeSmrg    _G_prefix="$progname: $_G_infix: "
752300346aeSmrg    _G_message=$*
753300346aeSmrg
754300346aeSmrg    # Strip color escape sequences before counting printable length
755300346aeSmrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
756300346aeSmrg    do
757300346aeSmrg      test -n "$_G_tc" && {
758300346aeSmrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
759300346aeSmrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
760300346aeSmrg      }
761300346aeSmrg    done
762300346aeSmrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
763300346aeSmrg
764300346aeSmrg    func_echo_infix_1_IFS=$IFS
765300346aeSmrg    IFS=$nl
766300346aeSmrg    for _G_line in $_G_message; do
767300346aeSmrg      IFS=$func_echo_infix_1_IFS
768300346aeSmrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
769300346aeSmrg      _G_prefix=$_G_indent
770300346aeSmrg    done
771300346aeSmrg    IFS=$func_echo_infix_1_IFS
772300346aeSmrg}
773300346aeSmrg
774300346aeSmrg
775300346aeSmrg# func_error ARG...
776300346aeSmrg# -----------------
777300346aeSmrg# Echo program name prefixed message to standard error.
778300346aeSmrgfunc_error ()
779300346aeSmrg{
780300346aeSmrg    $debug_cmd
781300346aeSmrg
782300346aeSmrg    $require_term_colors
783300346aeSmrg
784300346aeSmrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
785300346aeSmrg}
786300346aeSmrg
787300346aeSmrg
788300346aeSmrg# func_fatal_error ARG...
789300346aeSmrg# -----------------------
790300346aeSmrg# Echo program name prefixed message to standard error, and exit.
791300346aeSmrgfunc_fatal_error ()
792300346aeSmrg{
793300346aeSmrg    $debug_cmd
794300346aeSmrg
795300346aeSmrg    func_error "$*"
796300346aeSmrg    exit $EXIT_FAILURE
797300346aeSmrg}
798300346aeSmrg
799300346aeSmrg
800300346aeSmrg# func_grep EXPRESSION FILENAME
801300346aeSmrg# -----------------------------
802d656433aSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
803d656433aSmrgfunc_grep ()
804d656433aSmrg{
805300346aeSmrg    $debug_cmd
806300346aeSmrg
807d656433aSmrg    $GREP "$1" "$2" >/dev/null 2>&1
808d656433aSmrg}
809d656433aSmrg
810d656433aSmrg
811300346aeSmrg# func_len STRING
812300346aeSmrg# ---------------
813300346aeSmrg# Set func_len_result to the length of STRING. STRING may not
814300346aeSmrg# start with a hyphen.
815300346aeSmrg  test -z "$_G_HAVE_XSI_OPS" \
816300346aeSmrg    && (eval 'x=a/b/c;
817300346aeSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
818300346aeSmrg    && _G_HAVE_XSI_OPS=yes
819300346aeSmrg
820300346aeSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
821300346aeSmrg  eval 'func_len ()
822300346aeSmrg  {
823300346aeSmrg    $debug_cmd
824300346aeSmrg
825300346aeSmrg    func_len_result=${#1}
826300346aeSmrg  }'
827300346aeSmrgelse
828300346aeSmrg  func_len ()
829300346aeSmrg  {
830300346aeSmrg    $debug_cmd
831300346aeSmrg
832300346aeSmrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
833300346aeSmrg  }
834300346aeSmrgfi
835300346aeSmrg
836300346aeSmrg
837300346aeSmrg# func_mkdir_p DIRECTORY-PATH
838300346aeSmrg# ---------------------------
839d656433aSmrg# Make sure the entire path to DIRECTORY-PATH is available.
840d656433aSmrgfunc_mkdir_p ()
841d656433aSmrg{
842300346aeSmrg    $debug_cmd
843300346aeSmrg
844300346aeSmrg    _G_directory_path=$1
845300346aeSmrg    _G_dir_list=
846d656433aSmrg
847300346aeSmrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
848d656433aSmrg
849300346aeSmrg      # Protect directory names starting with '-'
850300346aeSmrg      case $_G_directory_path in
851300346aeSmrg        -*) _G_directory_path=./$_G_directory_path ;;
852d656433aSmrg      esac
853d656433aSmrg
854d656433aSmrg      # While some portion of DIR does not yet exist...
855300346aeSmrg      while test ! -d "$_G_directory_path"; do
856d656433aSmrg        # ...make a list in topmost first order.  Use a colon delimited
857d656433aSmrg	# list incase some portion of path contains whitespace.
858300346aeSmrg        _G_dir_list=$_G_directory_path:$_G_dir_list
859d656433aSmrg
860d656433aSmrg        # If the last portion added has no slash in it, the list is done
861300346aeSmrg        case $_G_directory_path in */*) ;; *) break ;; esac
862d656433aSmrg
863d656433aSmrg        # ...otherwise throw away the child directory and loop
864300346aeSmrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
865d656433aSmrg      done
866300346aeSmrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
867d656433aSmrg
868300346aeSmrg      func_mkdir_p_IFS=$IFS; IFS=:
869300346aeSmrg      for _G_dir in $_G_dir_list; do
870300346aeSmrg	IFS=$func_mkdir_p_IFS
871300346aeSmrg        # mkdir can fail with a 'File exist' error if two processes
872d656433aSmrg        # try to create one of the directories concurrently.  Don't
873d656433aSmrg        # stop in that case!
874300346aeSmrg        $MKDIR "$_G_dir" 2>/dev/null || :
875d656433aSmrg      done
876300346aeSmrg      IFS=$func_mkdir_p_IFS
877d656433aSmrg
878d656433aSmrg      # Bail out if we (or some other process) failed to create a directory.
879300346aeSmrg      test -d "$_G_directory_path" || \
880300346aeSmrg        func_fatal_error "Failed to create '$1'"
881d656433aSmrg    fi
882d656433aSmrg}
883126a8a12Smrg
884126a8a12Smrg
885300346aeSmrg# func_mktempdir [BASENAME]
886300346aeSmrg# -------------------------
887126a8a12Smrg# Make a temporary directory that won't clash with other running
888126a8a12Smrg# libtool processes, and avoids race conditions if possible.  If
889300346aeSmrg# given, BASENAME is the basename for that directory.
890126a8a12Smrgfunc_mktempdir ()
891126a8a12Smrg{
892300346aeSmrg    $debug_cmd
893300346aeSmrg
894300346aeSmrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
895126a8a12Smrg
896300346aeSmrg    if test : = "$opt_dry_run"; then
897126a8a12Smrg      # Return a directory name, but don't create it in dry-run mode
898300346aeSmrg      _G_tmpdir=$_G_template-$$
899126a8a12Smrg    else
900126a8a12Smrg
901126a8a12Smrg      # If mktemp works, use that first and foremost
902300346aeSmrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
903126a8a12Smrg
904300346aeSmrg      if test ! -d "$_G_tmpdir"; then
905d656433aSmrg        # Failing that, at least try and use $RANDOM to avoid a race
906300346aeSmrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
907126a8a12Smrg
908300346aeSmrg        func_mktempdir_umask=`umask`
909d656433aSmrg        umask 0077
910300346aeSmrg        $MKDIR "$_G_tmpdir"
911300346aeSmrg        umask $func_mktempdir_umask
912126a8a12Smrg      fi
913126a8a12Smrg
914126a8a12Smrg      # If we're not in dry-run mode, bomb out on failure
915300346aeSmrg      test -d "$_G_tmpdir" || \
916300346aeSmrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
917126a8a12Smrg    fi
918126a8a12Smrg
919300346aeSmrg    $ECHO "$_G_tmpdir"
920126a8a12Smrg}
921126a8a12Smrg
922126a8a12Smrg
923300346aeSmrg# func_normal_abspath PATH
924300346aeSmrg# ------------------------
925300346aeSmrg# Remove doubled-up and trailing slashes, "." path components,
926300346aeSmrg# and cancel out any ".." path components in PATH after making
927300346aeSmrg# it an absolute path.
928300346aeSmrgfunc_normal_abspath ()
929126a8a12Smrg{
930300346aeSmrg    $debug_cmd
931d656433aSmrg
932300346aeSmrg    # These SED scripts presuppose an absolute path with a trailing slash.
933300346aeSmrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
934300346aeSmrg    _G_pathcdr='s|^/[^/]*||'
935300346aeSmrg    _G_removedotparts=':dotsl
936300346aeSmrg		s|/\./|/|g
937300346aeSmrg		t dotsl
938300346aeSmrg		s|/\.$|/|'
939300346aeSmrg    _G_collapseslashes='s|/\{1,\}|/|g'
940300346aeSmrg    _G_finalslash='s|/*$|/|'
941300346aeSmrg
942300346aeSmrg    # Start from root dir and reassemble the path.
943300346aeSmrg    func_normal_abspath_result=
944300346aeSmrg    func_normal_abspath_tpath=$1
945300346aeSmrg    func_normal_abspath_altnamespace=
946300346aeSmrg    case $func_normal_abspath_tpath in
947300346aeSmrg      "")
948300346aeSmrg        # Empty path, that just means $cwd.
949300346aeSmrg        func_stripname '' '/' "`pwd`"
950300346aeSmrg        func_normal_abspath_result=$func_stripname_result
951300346aeSmrg        return
952300346aeSmrg        ;;
953300346aeSmrg      # The next three entries are used to spot a run of precisely
954300346aeSmrg      # two leading slashes without using negated character classes;
955300346aeSmrg      # we take advantage of case's first-match behaviour.
956300346aeSmrg      ///*)
957300346aeSmrg        # Unusual form of absolute path, do nothing.
958300346aeSmrg        ;;
959300346aeSmrg      //*)
960300346aeSmrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
961300346aeSmrg        # and for example Cygwin uses it to access remote file shares
962300346aeSmrg        # over CIFS/SMB, so we conserve a leading double slash if found.
963300346aeSmrg        func_normal_abspath_altnamespace=/
964300346aeSmrg        ;;
965300346aeSmrg      /*)
966300346aeSmrg        # Absolute path, do nothing.
967d656433aSmrg        ;;
968d656433aSmrg      *)
969300346aeSmrg        # Relative path, prepend $cwd.
970300346aeSmrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
971300346aeSmrg        ;;
972126a8a12Smrg    esac
973300346aeSmrg
974300346aeSmrg    # Cancel out all the simple stuff to save iterations.  We also want
975300346aeSmrg    # the path to end with a slash for ease of parsing, so make sure
976300346aeSmrg    # there is one (and only one) here.
977300346aeSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
978300346aeSmrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
979300346aeSmrg    while :; do
980300346aeSmrg      # Processed it all yet?
981300346aeSmrg      if test / = "$func_normal_abspath_tpath"; then
982300346aeSmrg        # If we ascended to the root using ".." the result may be empty now.
983300346aeSmrg        if test -z "$func_normal_abspath_result"; then
984300346aeSmrg          func_normal_abspath_result=/
985300346aeSmrg        fi
986300346aeSmrg        break
987300346aeSmrg      fi
988300346aeSmrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
989300346aeSmrg          -e "$_G_pathcar"`
990300346aeSmrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
991300346aeSmrg          -e "$_G_pathcdr"`
992300346aeSmrg      # Figure out what to do with it
993300346aeSmrg      case $func_normal_abspath_tcomponent in
994300346aeSmrg        "")
995300346aeSmrg          # Trailing empty path component, ignore it.
996300346aeSmrg          ;;
997300346aeSmrg        ..)
998300346aeSmrg          # Parent dir; strip last assembled component from result.
999300346aeSmrg          func_dirname "$func_normal_abspath_result"
1000300346aeSmrg          func_normal_abspath_result=$func_dirname_result
1001300346aeSmrg          ;;
1002300346aeSmrg        *)
1003300346aeSmrg          # Actual path component, append it.
1004300346aeSmrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1005300346aeSmrg          ;;
1006300346aeSmrg      esac
1007300346aeSmrg    done
1008300346aeSmrg    # Restore leading double-slash if one was found on entry.
1009300346aeSmrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1010300346aeSmrg}
1011300346aeSmrg
1012300346aeSmrg
1013300346aeSmrg# func_notquiet ARG...
1014300346aeSmrg# --------------------
1015300346aeSmrg# Echo program name prefixed message only when not in quiet mode.
1016300346aeSmrgfunc_notquiet ()
1017300346aeSmrg{
1018300346aeSmrg    $debug_cmd
1019300346aeSmrg
1020300346aeSmrg    $opt_quiet || func_echo ${1+"$@"}
1021300346aeSmrg
1022300346aeSmrg    # A bug in bash halts the script if the last line of a function
1023300346aeSmrg    # fails when set -e is in force, so we need another command to
1024300346aeSmrg    # work around that:
1025300346aeSmrg    :
1026300346aeSmrg}
1027300346aeSmrg
1028300346aeSmrg
1029300346aeSmrg# func_relative_path SRCDIR DSTDIR
1030300346aeSmrg# --------------------------------
1031300346aeSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1032300346aeSmrgfunc_relative_path ()
1033300346aeSmrg{
1034300346aeSmrg    $debug_cmd
1035300346aeSmrg
1036300346aeSmrg    func_relative_path_result=
1037300346aeSmrg    func_normal_abspath "$1"
1038300346aeSmrg    func_relative_path_tlibdir=$func_normal_abspath_result
1039300346aeSmrg    func_normal_abspath "$2"
1040300346aeSmrg    func_relative_path_tbindir=$func_normal_abspath_result
1041300346aeSmrg
1042300346aeSmrg    # Ascend the tree starting from libdir
1043300346aeSmrg    while :; do
1044300346aeSmrg      # check if we have found a prefix of bindir
1045300346aeSmrg      case $func_relative_path_tbindir in
1046300346aeSmrg        $func_relative_path_tlibdir)
1047300346aeSmrg          # found an exact match
1048300346aeSmrg          func_relative_path_tcancelled=
1049300346aeSmrg          break
1050300346aeSmrg          ;;
1051300346aeSmrg        $func_relative_path_tlibdir*)
1052300346aeSmrg          # found a matching prefix
1053300346aeSmrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1054300346aeSmrg          func_relative_path_tcancelled=$func_stripname_result
1055300346aeSmrg          if test -z "$func_relative_path_result"; then
1056300346aeSmrg            func_relative_path_result=.
1057300346aeSmrg          fi
1058300346aeSmrg          break
1059300346aeSmrg          ;;
1060300346aeSmrg        *)
1061300346aeSmrg          func_dirname $func_relative_path_tlibdir
1062300346aeSmrg          func_relative_path_tlibdir=$func_dirname_result
1063300346aeSmrg          if test -z "$func_relative_path_tlibdir"; then
1064300346aeSmrg            # Have to descend all the way to the root!
1065300346aeSmrg            func_relative_path_result=../$func_relative_path_result
1066300346aeSmrg            func_relative_path_tcancelled=$func_relative_path_tbindir
1067300346aeSmrg            break
1068300346aeSmrg          fi
1069300346aeSmrg          func_relative_path_result=../$func_relative_path_result
1070300346aeSmrg          ;;
1071300346aeSmrg      esac
1072300346aeSmrg    done
1073300346aeSmrg
1074300346aeSmrg    # Now calculate path; take care to avoid doubling-up slashes.
1075300346aeSmrg    func_stripname '' '/' "$func_relative_path_result"
1076300346aeSmrg    func_relative_path_result=$func_stripname_result
1077300346aeSmrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
1078300346aeSmrg    if test -n "$func_stripname_result"; then
1079300346aeSmrg      func_append func_relative_path_result "/$func_stripname_result"
1080300346aeSmrg    fi
1081300346aeSmrg
1082300346aeSmrg    # Normalisation. If bindir is libdir, return '.' else relative path.
1083300346aeSmrg    if test -n "$func_relative_path_result"; then
1084300346aeSmrg      func_stripname './' '' "$func_relative_path_result"
1085300346aeSmrg      func_relative_path_result=$func_stripname_result
1086300346aeSmrg    fi
1087300346aeSmrg
1088300346aeSmrg    test -n "$func_relative_path_result" || func_relative_path_result=.
1089300346aeSmrg
1090300346aeSmrg    :
1091126a8a12Smrg}
1092126a8a12Smrg
1093126a8a12Smrg
1094300346aeSmrg# func_quote_for_eval ARG...
1095300346aeSmrg# --------------------------
1096300346aeSmrg# Aesthetically quote ARGs to be evaled later.
1097300346aeSmrg# This function returns two values:
1098300346aeSmrg#   i) func_quote_for_eval_result
1099300346aeSmrg#      double-quoted, suitable for a subsequent eval
1100300346aeSmrg#  ii) func_quote_for_eval_unquoted_result
1101300346aeSmrg#      has all characters that are still active within double
1102300346aeSmrg#      quotes backslashified.
1103300346aeSmrgfunc_quote_for_eval ()
1104300346aeSmrg{
1105300346aeSmrg    $debug_cmd
1106300346aeSmrg
1107300346aeSmrg    func_quote_for_eval_unquoted_result=
1108300346aeSmrg    func_quote_for_eval_result=
1109300346aeSmrg    while test 0 -lt $#; do
1110300346aeSmrg      case $1 in
1111300346aeSmrg        *[\\\`\"\$]*)
1112300346aeSmrg	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
1113300346aeSmrg        *)
1114300346aeSmrg          _G_unquoted_arg=$1 ;;
1115300346aeSmrg      esac
1116300346aeSmrg      if test -n "$func_quote_for_eval_unquoted_result"; then
1117300346aeSmrg	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1118300346aeSmrg      else
1119300346aeSmrg        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1120300346aeSmrg      fi
1121300346aeSmrg
1122300346aeSmrg      case $_G_unquoted_arg in
1123300346aeSmrg        # Double-quote args containing shell metacharacters to delay
1124300346aeSmrg        # word splitting, command substitution and variable expansion
1125300346aeSmrg        # for a subsequent eval.
1126300346aeSmrg        # Many Bourne shells cannot handle close brackets correctly
1127300346aeSmrg        # in scan sets, so we specify it separately.
1128300346aeSmrg        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1129300346aeSmrg          _G_quoted_arg=\"$_G_unquoted_arg\"
1130300346aeSmrg          ;;
1131300346aeSmrg        *)
1132300346aeSmrg          _G_quoted_arg=$_G_unquoted_arg
1133300346aeSmrg	  ;;
1134300346aeSmrg      esac
1135300346aeSmrg
1136300346aeSmrg      if test -n "$func_quote_for_eval_result"; then
1137300346aeSmrg	func_append func_quote_for_eval_result " $_G_quoted_arg"
1138300346aeSmrg      else
1139300346aeSmrg        func_append func_quote_for_eval_result "$_G_quoted_arg"
1140300346aeSmrg      fi
1141300346aeSmrg      shift
1142300346aeSmrg    done
1143300346aeSmrg}
1144300346aeSmrg
1145300346aeSmrg
1146300346aeSmrg# func_quote_for_expand ARG
1147300346aeSmrg# -------------------------
1148d656433aSmrg# Aesthetically quote ARG to be evaled later; same as above,
1149d656433aSmrg# but do not quote variable references.
1150d656433aSmrgfunc_quote_for_expand ()
1151126a8a12Smrg{
1152300346aeSmrg    $debug_cmd
1153300346aeSmrg
1154d656433aSmrg    case $1 in
1155d656433aSmrg      *[\\\`\"]*)
1156300346aeSmrg	_G_arg=`$ECHO "$1" | $SED \
1157300346aeSmrg	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
1158126a8a12Smrg      *)
1159300346aeSmrg        _G_arg=$1 ;;
1160d656433aSmrg    esac
1161d656433aSmrg
1162300346aeSmrg    case $_G_arg in
1163d656433aSmrg      # Double-quote args containing shell metacharacters to delay
1164d656433aSmrg      # word splitting and command substitution for a subsequent eval.
1165d656433aSmrg      # Many Bourne shells cannot handle close brackets correctly
1166d656433aSmrg      # in scan sets, so we specify it separately.
1167d656433aSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1168300346aeSmrg        _G_arg=\"$_G_arg\"
1169d656433aSmrg        ;;
1170d656433aSmrg    esac
1171d656433aSmrg
1172300346aeSmrg    func_quote_for_expand_result=$_G_arg
1173300346aeSmrg}
1174300346aeSmrg
1175300346aeSmrg
1176300346aeSmrg# func_stripname PREFIX SUFFIX NAME
1177300346aeSmrg# ---------------------------------
1178300346aeSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1179300346aeSmrg# PREFIX and SUFFIX must not contain globbing or regex special
1180300346aeSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
1181300346aeSmrg# dot (in which case that matches only a dot).
1182300346aeSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
1183300346aeSmrg  eval 'func_stripname ()
1184300346aeSmrg  {
1185300346aeSmrg    $debug_cmd
1186300346aeSmrg
1187300346aeSmrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1188300346aeSmrg    # positional parameters, so assign one to ordinary variable first.
1189300346aeSmrg    func_stripname_result=$3
1190300346aeSmrg    func_stripname_result=${func_stripname_result#"$1"}
1191300346aeSmrg    func_stripname_result=${func_stripname_result%"$2"}
1192300346aeSmrg  }'
1193300346aeSmrgelse
1194300346aeSmrg  func_stripname ()
1195300346aeSmrg  {
1196300346aeSmrg    $debug_cmd
1197300346aeSmrg
1198300346aeSmrg    case $2 in
1199300346aeSmrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1200300346aeSmrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1201300346aeSmrg    esac
1202300346aeSmrg  }
1203300346aeSmrgfi
1204300346aeSmrg
1205300346aeSmrg
1206300346aeSmrg# func_show_eval CMD [FAIL_EXP]
1207300346aeSmrg# -----------------------------
1208300346aeSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1209300346aeSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1210300346aeSmrg# is given, then evaluate it.
1211300346aeSmrgfunc_show_eval ()
1212300346aeSmrg{
1213300346aeSmrg    $debug_cmd
1214300346aeSmrg
1215300346aeSmrg    _G_cmd=$1
1216300346aeSmrg    _G_fail_exp=${2-':'}
1217300346aeSmrg
1218300346aeSmrg    func_quote_for_expand "$_G_cmd"
1219300346aeSmrg    eval "func_notquiet $func_quote_for_expand_result"
1220300346aeSmrg
1221300346aeSmrg    $opt_dry_run || {
1222300346aeSmrg      eval "$_G_cmd"
1223300346aeSmrg      _G_status=$?
1224300346aeSmrg      if test 0 -ne "$_G_status"; then
1225300346aeSmrg	eval "(exit $_G_status); $_G_fail_exp"
1226300346aeSmrg      fi
1227300346aeSmrg    }
1228300346aeSmrg}
1229300346aeSmrg
1230300346aeSmrg
1231300346aeSmrg# func_show_eval_locale CMD [FAIL_EXP]
1232300346aeSmrg# ------------------------------------
1233300346aeSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1234300346aeSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1235300346aeSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
1236300346aeSmrgfunc_show_eval_locale ()
1237300346aeSmrg{
1238300346aeSmrg    $debug_cmd
1239300346aeSmrg
1240300346aeSmrg    _G_cmd=$1
1241300346aeSmrg    _G_fail_exp=${2-':'}
1242300346aeSmrg
1243300346aeSmrg    $opt_quiet || {
1244300346aeSmrg      func_quote_for_expand "$_G_cmd"
1245300346aeSmrg      eval "func_echo $func_quote_for_expand_result"
1246300346aeSmrg    }
1247300346aeSmrg
1248300346aeSmrg    $opt_dry_run || {
1249300346aeSmrg      eval "$_G_user_locale
1250300346aeSmrg	    $_G_cmd"
1251300346aeSmrg      _G_status=$?
1252300346aeSmrg      eval "$_G_safe_locale"
1253300346aeSmrg      if test 0 -ne "$_G_status"; then
1254300346aeSmrg	eval "(exit $_G_status); $_G_fail_exp"
1255300346aeSmrg      fi
1256300346aeSmrg    }
1257300346aeSmrg}
1258300346aeSmrg
1259300346aeSmrg
1260300346aeSmrg# func_tr_sh
1261300346aeSmrg# ----------
1262300346aeSmrg# Turn $1 into a string suitable for a shell variable name.
1263300346aeSmrg# Result is stored in $func_tr_sh_result.  All characters
1264300346aeSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1265300346aeSmrg# if $1 begins with a digit, a '_' is prepended as well.
1266300346aeSmrgfunc_tr_sh ()
1267300346aeSmrg{
1268300346aeSmrg    $debug_cmd
1269300346aeSmrg
1270300346aeSmrg    case $1 in
1271300346aeSmrg    [0-9]* | *[!a-zA-Z0-9_]*)
1272300346aeSmrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1273300346aeSmrg      ;;
1274300346aeSmrg    * )
1275300346aeSmrg      func_tr_sh_result=$1
1276300346aeSmrg      ;;
1277300346aeSmrg    esac
1278300346aeSmrg}
1279300346aeSmrg
1280300346aeSmrg
1281300346aeSmrg# func_verbose ARG...
1282300346aeSmrg# -------------------
1283300346aeSmrg# Echo program name prefixed message in verbose mode only.
1284300346aeSmrgfunc_verbose ()
1285300346aeSmrg{
1286300346aeSmrg    $debug_cmd
1287300346aeSmrg
1288300346aeSmrg    $opt_verbose && func_echo "$*"
1289300346aeSmrg
1290300346aeSmrg    :
1291300346aeSmrg}
1292300346aeSmrg
1293300346aeSmrg
1294300346aeSmrg# func_warn_and_continue ARG...
1295300346aeSmrg# -----------------------------
1296300346aeSmrg# Echo program name prefixed warning message to standard error.
1297300346aeSmrgfunc_warn_and_continue ()
1298300346aeSmrg{
1299300346aeSmrg    $debug_cmd
1300300346aeSmrg
1301300346aeSmrg    $require_term_colors
1302300346aeSmrg
1303300346aeSmrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1304300346aeSmrg}
1305300346aeSmrg
1306300346aeSmrg
1307300346aeSmrg# func_warning CATEGORY ARG...
1308300346aeSmrg# ----------------------------
1309300346aeSmrg# Echo program name prefixed warning message to standard error. Warning
1310300346aeSmrg# messages can be filtered according to CATEGORY, where this function
1311300346aeSmrg# elides messages where CATEGORY is not listed in the global variable
1312300346aeSmrg# 'opt_warning_types'.
1313300346aeSmrgfunc_warning ()
1314300346aeSmrg{
1315300346aeSmrg    $debug_cmd
1316300346aeSmrg
1317300346aeSmrg    # CATEGORY must be in the warning_categories list!
1318300346aeSmrg    case " $warning_categories " in
1319300346aeSmrg      *" $1 "*) ;;
1320300346aeSmrg      *) func_internal_error "invalid warning category '$1'" ;;
1321300346aeSmrg    esac
1322300346aeSmrg
1323300346aeSmrg    _G_category=$1
1324300346aeSmrg    shift
1325300346aeSmrg
1326300346aeSmrg    case " $opt_warning_types " in
1327300346aeSmrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
1328300346aeSmrg    esac
1329126a8a12Smrg}
1330126a8a12Smrg
1331126a8a12Smrg
1332300346aeSmrg# func_sort_ver VER1 VER2
1333300346aeSmrg# -----------------------
1334300346aeSmrg# 'sort -V' is not generally available.
1335300346aeSmrg# Note this deviates from the version comparison in automake
1336300346aeSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1337300346aeSmrg# but this should suffice as we won't be specifying old
1338300346aeSmrg# version formats or redundant trailing .0 in bootstrap.conf.
1339300346aeSmrg# If we did want full compatibility then we should probably
1340300346aeSmrg# use m4_version_compare from autoconf.
1341300346aeSmrgfunc_sort_ver ()
1342300346aeSmrg{
1343300346aeSmrg    $debug_cmd
1344300346aeSmrg
1345300346aeSmrg    printf '%s\n%s\n' "$1" "$2" \
1346300346aeSmrg      | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
1347300346aeSmrg}
1348300346aeSmrg
1349300346aeSmrg# func_lt_ver PREV CURR
1350300346aeSmrg# ---------------------
1351300346aeSmrg# Return true if PREV and CURR are in the correct order according to
1352300346aeSmrg# func_sort_ver, otherwise false.  Use it like this:
1353300346aeSmrg#
1354300346aeSmrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1355300346aeSmrgfunc_lt_ver ()
1356300346aeSmrg{
1357300346aeSmrg    $debug_cmd
1358300346aeSmrg
1359300346aeSmrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1360300346aeSmrg}
1361300346aeSmrg
1362300346aeSmrg
1363300346aeSmrg# Local variables:
1364300346aeSmrg# mode: shell-script
1365300346aeSmrg# sh-indentation: 2
1366300346aeSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1367300346aeSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1368300346aeSmrg# time-stamp-time-zone: "UTC"
1369300346aeSmrg# End:
1370300346aeSmrg#! /bin/sh
1371300346aeSmrg
1372300346aeSmrg# Set a version string for this script.
1373300346aeSmrgscriptversion=2014-01-07.03; # UTC
1374300346aeSmrg
1375300346aeSmrg# A portable, pluggable option parser for Bourne shell.
1376300346aeSmrg# Written by Gary V. Vaughan, 2010
1377300346aeSmrg
1378300346aeSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc.
1379300346aeSmrg# This is free software; see the source for copying conditions.  There is NO
1380300346aeSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1381300346aeSmrg
1382300346aeSmrg# This program is free software: you can redistribute it and/or modify
1383300346aeSmrg# it under the terms of the GNU General Public License as published by
1384300346aeSmrg# the Free Software Foundation, either version 3 of the License, or
1385300346aeSmrg# (at your option) any later version.
1386300346aeSmrg
1387300346aeSmrg# This program is distributed in the hope that it will be useful,
1388300346aeSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1389300346aeSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1390300346aeSmrg# GNU General Public License for more details.
1391300346aeSmrg
1392300346aeSmrg# You should have received a copy of the GNU General Public License
1393300346aeSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
1394300346aeSmrg
1395300346aeSmrg# Please report bugs or propose patches to gary@gnu.org.
1396300346aeSmrg
1397300346aeSmrg
1398300346aeSmrg## ------ ##
1399300346aeSmrg## Usage. ##
1400300346aeSmrg## ------ ##
1401300346aeSmrg
1402300346aeSmrg# This file is a library for parsing options in your shell scripts along
1403300346aeSmrg# with assorted other useful supporting features that you can make use
1404300346aeSmrg# of too.
1405300346aeSmrg#
1406300346aeSmrg# For the simplest scripts you might need only:
1407300346aeSmrg#
1408300346aeSmrg#   #!/bin/sh
1409300346aeSmrg#   . relative/path/to/funclib.sh
1410300346aeSmrg#   . relative/path/to/options-parser
1411300346aeSmrg#   scriptversion=1.0
1412300346aeSmrg#   func_options ${1+"$@"}
1413300346aeSmrg#   eval set dummy "$func_options_result"; shift
1414300346aeSmrg#   ...rest of your script...
1415300346aeSmrg#
1416300346aeSmrg# In order for the '--version' option to work, you will need to have a
1417300346aeSmrg# suitably formatted comment like the one at the top of this file
1418300346aeSmrg# starting with '# Written by ' and ending with '# warranty; '.
1419300346aeSmrg#
1420300346aeSmrg# For '-h' and '--help' to work, you will also need a one line
1421300346aeSmrg# description of your script's purpose in a comment directly above the
1422300346aeSmrg# '# Written by ' line, like the one at the top of this file.
1423300346aeSmrg#
1424300346aeSmrg# The default options also support '--debug', which will turn on shell
1425300346aeSmrg# execution tracing (see the comment above debug_cmd below for another
1426300346aeSmrg# use), and '--verbose' and the func_verbose function to allow your script
1427300346aeSmrg# to display verbose messages only when your user has specified
1428300346aeSmrg# '--verbose'.
1429300346aeSmrg#
1430300346aeSmrg# After sourcing this file, you can plug processing for additional
1431300346aeSmrg# options by amending the variables from the 'Configuration' section
1432300346aeSmrg# below, and following the instructions in the 'Option parsing'
1433300346aeSmrg# section further down.
1434300346aeSmrg
1435300346aeSmrg## -------------- ##
1436300346aeSmrg## Configuration. ##
1437300346aeSmrg## -------------- ##
1438300346aeSmrg
1439300346aeSmrg# You should override these variables in your script after sourcing this
1440300346aeSmrg# file so that they reflect the customisations you have added to the
1441300346aeSmrg# option parser.
1442300346aeSmrg
1443300346aeSmrg# The usage line for option parsing errors and the start of '-h' and
1444300346aeSmrg# '--help' output messages. You can embed shell variables for delayed
1445300346aeSmrg# expansion at the time the message is displayed, but you will need to
1446300346aeSmrg# quote other shell meta-characters carefully to prevent them being
1447300346aeSmrg# expanded when the contents are evaled.
1448300346aeSmrgusage='$progpath [OPTION]...'
1449300346aeSmrg
1450300346aeSmrg# Short help message in response to '-h' and '--help'.  Add to this or
1451300346aeSmrg# override it after sourcing this library to reflect the full set of
1452300346aeSmrg# options your script accepts.
1453300346aeSmrgusage_message="\
1454300346aeSmrg       --debug        enable verbose shell tracing
1455300346aeSmrg   -W, --warnings=CATEGORY
1456300346aeSmrg                      report the warnings falling in CATEGORY [all]
1457300346aeSmrg   -v, --verbose      verbosely report processing
1458300346aeSmrg       --version      print version information and exit
1459300346aeSmrg   -h, --help         print short or long help message and exit
1460300346aeSmrg"
1461300346aeSmrg
1462300346aeSmrg# Additional text appended to 'usage_message' in response to '--help'.
1463300346aeSmrglong_help_message="
1464300346aeSmrgWarning categories include:
1465300346aeSmrg       'all'          show all warnings
1466300346aeSmrg       'none'         turn off all the warnings
1467300346aeSmrg       'error'        warnings are treated as fatal errors"
1468300346aeSmrg
1469300346aeSmrg# Help message printed before fatal option parsing errors.
1470300346aeSmrgfatal_help="Try '\$progname --help' for more information."
1471300346aeSmrg
1472300346aeSmrg
1473300346aeSmrg
1474300346aeSmrg## ------------------------- ##
1475300346aeSmrg## Hook function management. ##
1476300346aeSmrg## ------------------------- ##
1477300346aeSmrg
1478300346aeSmrg# This section contains functions for adding, removing, and running hooks
1479300346aeSmrg# to the main code.  A hook is just a named list of of function, that can
1480300346aeSmrg# be run in order later on.
1481300346aeSmrg
1482300346aeSmrg# func_hookable FUNC_NAME
1483300346aeSmrg# -----------------------
1484300346aeSmrg# Declare that FUNC_NAME will run hooks added with
1485300346aeSmrg# 'func_add_hook FUNC_NAME ...'.
1486300346aeSmrgfunc_hookable ()
1487300346aeSmrg{
1488300346aeSmrg    $debug_cmd
1489300346aeSmrg
1490300346aeSmrg    func_append hookable_fns " $1"
1491300346aeSmrg}
1492300346aeSmrg
1493300346aeSmrg
1494300346aeSmrg# func_add_hook FUNC_NAME HOOK_FUNC
1495300346aeSmrg# ---------------------------------
1496300346aeSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
1497300346aeSmrg# first have been declared "hookable" by a call to 'func_hookable'.
1498300346aeSmrgfunc_add_hook ()
1499300346aeSmrg{
1500300346aeSmrg    $debug_cmd
1501300346aeSmrg
1502300346aeSmrg    case " $hookable_fns " in
1503300346aeSmrg      *" $1 "*) ;;
1504300346aeSmrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
1505300346aeSmrg    esac
1506300346aeSmrg
1507300346aeSmrg    eval func_append ${1}_hooks '" $2"'
1508300346aeSmrg}
1509300346aeSmrg
1510300346aeSmrg
1511300346aeSmrg# func_remove_hook FUNC_NAME HOOK_FUNC
1512300346aeSmrg# ------------------------------------
1513300346aeSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
1514300346aeSmrgfunc_remove_hook ()
1515300346aeSmrg{
1516300346aeSmrg    $debug_cmd
1517300346aeSmrg
1518300346aeSmrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1519300346aeSmrg}
1520300346aeSmrg
1521300346aeSmrg
1522300346aeSmrg# func_run_hooks FUNC_NAME [ARG]...
1523300346aeSmrg# ---------------------------------
1524300346aeSmrg# Run all hook functions registered to FUNC_NAME.
1525300346aeSmrg# It is assumed that the list of hook functions contains nothing more
1526300346aeSmrg# than a whitespace-delimited list of legal shell function names, and
1527300346aeSmrg# no effort is wasted trying to catch shell meta-characters or preserve
1528300346aeSmrg# whitespace.
1529300346aeSmrgfunc_run_hooks ()
1530300346aeSmrg{
1531300346aeSmrg    $debug_cmd
1532300346aeSmrg
1533300346aeSmrg    case " $hookable_fns " in
1534300346aeSmrg      *" $1 "*) ;;
1535300346aeSmrg      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
1536300346aeSmrg    esac
1537300346aeSmrg
1538300346aeSmrg    eval _G_hook_fns=\$$1_hooks; shift
1539300346aeSmrg
1540300346aeSmrg    for _G_hook in $_G_hook_fns; do
1541300346aeSmrg      eval $_G_hook '"$@"'
1542300346aeSmrg
1543300346aeSmrg      # store returned options list back into positional
1544300346aeSmrg      # parameters for next 'cmd' execution.
1545300346aeSmrg      eval _G_hook_result=\$${_G_hook}_result
1546300346aeSmrg      eval set dummy "$_G_hook_result"; shift
1547300346aeSmrg    done
1548300346aeSmrg
1549300346aeSmrg    func_quote_for_eval ${1+"$@"}
1550300346aeSmrg    func_run_hooks_result=$func_quote_for_eval_result
1551300346aeSmrg}
1552300346aeSmrg
1553300346aeSmrg
1554300346aeSmrg
1555300346aeSmrg## --------------- ##
1556300346aeSmrg## Option parsing. ##
1557300346aeSmrg## --------------- ##
1558300346aeSmrg
1559300346aeSmrg# In order to add your own option parsing hooks, you must accept the
1560300346aeSmrg# full positional parameter list in your hook function, remove any
1561300346aeSmrg# options that you action, and then pass back the remaining unprocessed
1562300346aeSmrg# options in '<hooked_function_name>_result', escaped suitably for
1563300346aeSmrg# 'eval'.  Like this:
1564300346aeSmrg#
1565300346aeSmrg#    my_options_prep ()
1566300346aeSmrg#    {
1567300346aeSmrg#        $debug_cmd
1568300346aeSmrg#
1569300346aeSmrg#        # Extend the existing usage message.
1570300346aeSmrg#        usage_message=$usage_message'
1571300346aeSmrg#      -s, --silent       don'\''t print informational messages
1572300346aeSmrg#    '
1573300346aeSmrg#
1574300346aeSmrg#        func_quote_for_eval ${1+"$@"}
1575300346aeSmrg#        my_options_prep_result=$func_quote_for_eval_result
1576300346aeSmrg#    }
1577300346aeSmrg#    func_add_hook func_options_prep my_options_prep
1578300346aeSmrg#
1579300346aeSmrg#
1580300346aeSmrg#    my_silent_option ()
1581300346aeSmrg#    {
1582300346aeSmrg#        $debug_cmd
1583300346aeSmrg#
1584300346aeSmrg#        # Note that for efficiency, we parse as many options as we can
1585300346aeSmrg#        # recognise in a loop before passing the remainder back to the
1586300346aeSmrg#        # caller on the first unrecognised argument we encounter.
1587300346aeSmrg#        while test $# -gt 0; do
1588300346aeSmrg#          opt=$1; shift
1589300346aeSmrg#          case $opt in
1590300346aeSmrg#            --silent|-s) opt_silent=: ;;
1591300346aeSmrg#            # Separate non-argument short options:
1592300346aeSmrg#            -s*)         func_split_short_opt "$_G_opt"
1593300346aeSmrg#                         set dummy "$func_split_short_opt_name" \
1594300346aeSmrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
1595300346aeSmrg#                         shift
1596300346aeSmrg#                         ;;
1597300346aeSmrg#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
1598300346aeSmrg#          esac
1599300346aeSmrg#        done
1600300346aeSmrg#
1601300346aeSmrg#        func_quote_for_eval ${1+"$@"}
1602300346aeSmrg#        my_silent_option_result=$func_quote_for_eval_result
1603300346aeSmrg#    }
1604300346aeSmrg#    func_add_hook func_parse_options my_silent_option
1605300346aeSmrg#
1606300346aeSmrg#
1607300346aeSmrg#    my_option_validation ()
1608300346aeSmrg#    {
1609300346aeSmrg#        $debug_cmd
1610300346aeSmrg#
1611300346aeSmrg#        $opt_silent && $opt_verbose && func_fatal_help "\
1612300346aeSmrg#    '--silent' and '--verbose' options are mutually exclusive."
1613300346aeSmrg#
1614300346aeSmrg#        func_quote_for_eval ${1+"$@"}
1615300346aeSmrg#        my_option_validation_result=$func_quote_for_eval_result
1616300346aeSmrg#    }
1617300346aeSmrg#    func_add_hook func_validate_options my_option_validation
1618300346aeSmrg#
1619300346aeSmrg# You'll alse need to manually amend $usage_message to reflect the extra
1620300346aeSmrg# options you parse.  It's preferable to append if you can, so that
1621300346aeSmrg# multiple option parsing hooks can be added safely.
1622300346aeSmrg
1623300346aeSmrg
1624300346aeSmrg# func_options [ARG]...
1625300346aeSmrg# ---------------------
1626300346aeSmrg# All the functions called inside func_options are hookable. See the
1627300346aeSmrg# individual implementations for details.
1628300346aeSmrgfunc_hookable func_options
1629300346aeSmrgfunc_options ()
1630126a8a12Smrg{
1631300346aeSmrg    $debug_cmd
1632126a8a12Smrg
1633300346aeSmrg    func_options_prep ${1+"$@"}
1634300346aeSmrg    eval func_parse_options \
1635300346aeSmrg        ${func_options_prep_result+"$func_options_prep_result"}
1636300346aeSmrg    eval func_validate_options \
1637300346aeSmrg        ${func_parse_options_result+"$func_parse_options_result"}
1638d656433aSmrg
1639300346aeSmrg    eval func_run_hooks func_options \
1640300346aeSmrg        ${func_validate_options_result+"$func_validate_options_result"}
1641300346aeSmrg
1642300346aeSmrg    # save modified positional parameters for caller
1643300346aeSmrg    func_options_result=$func_run_hooks_result
1644126a8a12Smrg}
1645126a8a12Smrg
1646d656433aSmrg
1647300346aeSmrg# func_options_prep [ARG]...
1648300346aeSmrg# --------------------------
1649300346aeSmrg# All initialisations required before starting the option parse loop.
1650300346aeSmrg# Note that when calling hook functions, we pass through the list of
1651300346aeSmrg# positional parameters.  If a hook function modifies that list, and
1652300346aeSmrg# needs to propogate that back to rest of this script, then the complete
1653300346aeSmrg# modified list must be put in 'func_run_hooks_result' before
1654300346aeSmrg# returning.
1655300346aeSmrgfunc_hookable func_options_prep
1656300346aeSmrgfunc_options_prep ()
1657126a8a12Smrg{
1658300346aeSmrg    $debug_cmd
1659126a8a12Smrg
1660300346aeSmrg    # Option defaults:
1661300346aeSmrg    opt_verbose=false
1662300346aeSmrg    opt_warning_types=
1663d656433aSmrg
1664300346aeSmrg    func_run_hooks func_options_prep ${1+"$@"}
1665300346aeSmrg
1666300346aeSmrg    # save modified positional parameters for caller
1667300346aeSmrg    func_options_prep_result=$func_run_hooks_result
1668126a8a12Smrg}
1669126a8a12Smrg
1670300346aeSmrg
1671300346aeSmrg# func_parse_options [ARG]...
1672300346aeSmrg# ---------------------------
1673300346aeSmrg# The main option parsing loop.
1674300346aeSmrgfunc_hookable func_parse_options
1675300346aeSmrgfunc_parse_options ()
16763c15da26Smrg{
1677300346aeSmrg    $debug_cmd
1678300346aeSmrg
1679300346aeSmrg    func_parse_options_result=
1680300346aeSmrg
1681300346aeSmrg    # this just eases exit handling
1682300346aeSmrg    while test $# -gt 0; do
1683300346aeSmrg      # Defer to hook functions for initial option parsing, so they
1684300346aeSmrg      # get priority in the event of reusing an option name.
1685300346aeSmrg      func_run_hooks func_parse_options ${1+"$@"}
1686300346aeSmrg
1687300346aeSmrg      # Adjust func_parse_options positional parameters to match
1688300346aeSmrg      eval set dummy "$func_run_hooks_result"; shift
1689300346aeSmrg
1690300346aeSmrg      # Break out of the loop if we already parsed every option.
1691300346aeSmrg      test $# -gt 0 || break
1692300346aeSmrg
1693300346aeSmrg      _G_opt=$1
1694300346aeSmrg      shift
1695300346aeSmrg      case $_G_opt in
1696300346aeSmrg        --debug|-x)   debug_cmd='set -x'
1697300346aeSmrg                      func_echo "enabling shell trace mode"
1698300346aeSmrg                      $debug_cmd
1699300346aeSmrg                      ;;
1700300346aeSmrg
1701300346aeSmrg        --no-warnings|--no-warning|--no-warn)
1702300346aeSmrg                      set dummy --warnings none ${1+"$@"}
1703300346aeSmrg                      shift
1704300346aeSmrg		      ;;
1705300346aeSmrg
1706300346aeSmrg        --warnings|--warning|-W)
1707300346aeSmrg                      test $# = 0 && func_missing_arg $_G_opt && break
1708300346aeSmrg                      case " $warning_categories $1" in
1709300346aeSmrg                        *" $1 "*)
1710300346aeSmrg                          # trailing space prevents matching last $1 above
1711300346aeSmrg                          func_append_uniq opt_warning_types " $1"
1712300346aeSmrg                          ;;
1713300346aeSmrg                        *all)
1714300346aeSmrg                          opt_warning_types=$warning_categories
1715300346aeSmrg                          ;;
1716300346aeSmrg                        *none)
1717300346aeSmrg                          opt_warning_types=none
1718300346aeSmrg                          warning_func=:
1719300346aeSmrg                          ;;
1720300346aeSmrg                        *error)
1721300346aeSmrg                          opt_warning_types=$warning_categories
1722300346aeSmrg                          warning_func=func_fatal_error
1723300346aeSmrg                          ;;
1724300346aeSmrg                        *)
1725300346aeSmrg                          func_fatal_error \
1726300346aeSmrg                             "unsupported warning category: '$1'"
1727300346aeSmrg                          ;;
1728300346aeSmrg                      esac
1729300346aeSmrg                      shift
1730300346aeSmrg                      ;;
1731300346aeSmrg
1732300346aeSmrg        --verbose|-v) opt_verbose=: ;;
1733300346aeSmrg        --version)    func_version ;;
1734300346aeSmrg        -\?|-h)       func_usage ;;
1735300346aeSmrg        --help)       func_help ;;
1736300346aeSmrg
1737300346aeSmrg	# Separate optargs to long options (plugins may need this):
1738300346aeSmrg	--*=*)        func_split_equals "$_G_opt"
1739300346aeSmrg	              set dummy "$func_split_equals_lhs" \
1740300346aeSmrg                          "$func_split_equals_rhs" ${1+"$@"}
1741300346aeSmrg                      shift
1742300346aeSmrg                      ;;
1743300346aeSmrg
1744300346aeSmrg       # Separate optargs to short options:
1745300346aeSmrg        -W*)
1746300346aeSmrg                      func_split_short_opt "$_G_opt"
1747300346aeSmrg                      set dummy "$func_split_short_opt_name" \
1748300346aeSmrg                          "$func_split_short_opt_arg" ${1+"$@"}
1749300346aeSmrg                      shift
1750300346aeSmrg                      ;;
1751300346aeSmrg
1752300346aeSmrg        # Separate non-argument short options:
1753300346aeSmrg        -\?*|-h*|-v*|-x*)
1754300346aeSmrg                      func_split_short_opt "$_G_opt"
1755300346aeSmrg                      set dummy "$func_split_short_opt_name" \
1756300346aeSmrg                          "-$func_split_short_opt_arg" ${1+"$@"}
1757300346aeSmrg                      shift
1758300346aeSmrg                      ;;
1759300346aeSmrg
1760300346aeSmrg        --)           break ;;
1761300346aeSmrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
1762300346aeSmrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1763300346aeSmrg      esac
1764300346aeSmrg    done
1765300346aeSmrg
1766300346aeSmrg    # save modified positional parameters for caller
1767300346aeSmrg    func_quote_for_eval ${1+"$@"}
1768300346aeSmrg    func_parse_options_result=$func_quote_for_eval_result
17693c15da26Smrg}
17703c15da26Smrg
1771126a8a12Smrg
1772300346aeSmrg# func_validate_options [ARG]...
1773300346aeSmrg# ------------------------------
1774300346aeSmrg# Perform any sanity checks on option settings and/or unconsumed
1775300346aeSmrg# arguments.
1776300346aeSmrgfunc_hookable func_validate_options
1777300346aeSmrgfunc_validate_options ()
1778d656433aSmrg{
1779300346aeSmrg    $debug_cmd
17803c15da26Smrg
1781300346aeSmrg    # Display all warnings if -W was not given.
1782300346aeSmrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1783300346aeSmrg
1784300346aeSmrg    func_run_hooks func_validate_options ${1+"$@"}
1785300346aeSmrg
1786300346aeSmrg    # Bail if the options were screwed!
1787300346aeSmrg    $exit_cmd $EXIT_FAILURE
1788300346aeSmrg
1789300346aeSmrg    # save modified positional parameters for caller
1790300346aeSmrg    func_validate_options_result=$func_run_hooks_result
1791d656433aSmrg}
1792d656433aSmrg
1793300346aeSmrg
1794300346aeSmrg
1795300346aeSmrg## ----------------- ##
1796300346aeSmrg## Helper functions. ##
1797300346aeSmrg## ----------------- ##
1798300346aeSmrg
1799300346aeSmrg# This section contains the helper functions used by the rest of the
1800300346aeSmrg# hookable option parser framework in ascii-betical order.
1801300346aeSmrg
1802300346aeSmrg
1803300346aeSmrg# func_fatal_help ARG...
1804300346aeSmrg# ----------------------
1805300346aeSmrg# Echo program name prefixed message to standard error, followed by
1806300346aeSmrg# a help hint, and exit.
1807300346aeSmrgfunc_fatal_help ()
1808d656433aSmrg{
1809300346aeSmrg    $debug_cmd
18103c15da26Smrg
1811300346aeSmrg    eval \$ECHO \""Usage: $usage"\"
1812300346aeSmrg    eval \$ECHO \""$fatal_help"\"
1813300346aeSmrg    func_error ${1+"$@"}
1814300346aeSmrg    exit $EXIT_FAILURE
1815d656433aSmrg}
1816d656433aSmrg
1817300346aeSmrg
1818300346aeSmrg# func_help
1819300346aeSmrg# ---------
1820300346aeSmrg# Echo long help message to standard output and exit.
1821d656433aSmrgfunc_help ()
1822d656433aSmrg{
1823300346aeSmrg    $debug_cmd
1824300346aeSmrg
1825300346aeSmrg    func_usage_message
1826300346aeSmrg    $ECHO "$long_help_message"
1827300346aeSmrg    exit 0
1828d656433aSmrg}
1829d656433aSmrg
1830300346aeSmrg
1831300346aeSmrg# func_missing_arg ARGNAME
1832300346aeSmrg# ------------------------
1833d656433aSmrg# Echo program name prefixed message to standard error and set global
1834d656433aSmrg# exit_cmd.
1835d656433aSmrgfunc_missing_arg ()
1836d656433aSmrg{
1837300346aeSmrg    $debug_cmd
18383c15da26Smrg
1839300346aeSmrg    func_error "Missing argument for '$1'."
1840d656433aSmrg    exit_cmd=exit
1841d656433aSmrg}
1842d656433aSmrg
1843d656433aSmrg
1844300346aeSmrg# func_split_equals STRING
1845300346aeSmrg# ------------------------
1846300346aeSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
1847300346aeSmrg# splitting STRING at the '=' sign.
1848300346aeSmrgtest -z "$_G_HAVE_XSI_OPS" \
1849300346aeSmrg    && (eval 'x=a/b/c;
1850300346aeSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1851300346aeSmrg    && _G_HAVE_XSI_OPS=yes
1852300346aeSmrg
1853300346aeSmrgif test yes = "$_G_HAVE_XSI_OPS"
1854300346aeSmrgthen
1855300346aeSmrg  # This is an XSI compatible shell, allowing a faster implementation...
1856300346aeSmrg  eval 'func_split_equals ()
1857300346aeSmrg  {
1858300346aeSmrg      $debug_cmd
1859300346aeSmrg
1860300346aeSmrg      func_split_equals_lhs=${1%%=*}
1861300346aeSmrg      func_split_equals_rhs=${1#*=}
1862300346aeSmrg      test "x$func_split_equals_lhs" = "x$1" \
1863300346aeSmrg        && func_split_equals_rhs=
1864300346aeSmrg  }'
1865300346aeSmrgelse
1866300346aeSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
1867300346aeSmrg  func_split_equals ()
1868300346aeSmrg  {
1869300346aeSmrg      $debug_cmd
1870300346aeSmrg
1871300346aeSmrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
1872300346aeSmrg      func_split_equals_rhs=
1873300346aeSmrg      test "x$func_split_equals_lhs" = "x$1" \
1874300346aeSmrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
1875300346aeSmrg  }
1876300346aeSmrgfi #func_split_equals
1877300346aeSmrg
1878300346aeSmrg
1879300346aeSmrg# func_split_short_opt SHORTOPT
1880300346aeSmrg# -----------------------------
18813c15da26Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
18823c15da26Smrg# variables after splitting SHORTOPT after the 2nd character.
1883300346aeSmrgif test yes = "$_G_HAVE_XSI_OPS"
1884300346aeSmrgthen
1885300346aeSmrg  # This is an XSI compatible shell, allowing a faster implementation...
1886300346aeSmrg  eval 'func_split_short_opt ()
1887300346aeSmrg  {
1888300346aeSmrg      $debug_cmd
1889300346aeSmrg
1890300346aeSmrg      func_split_short_opt_arg=${1#??}
1891300346aeSmrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1892300346aeSmrg  }'
1893300346aeSmrgelse
1894300346aeSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
1895300346aeSmrg  func_split_short_opt ()
1896300346aeSmrg  {
1897300346aeSmrg      $debug_cmd
1898300346aeSmrg
1899300346aeSmrg      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
1900300346aeSmrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
1901300346aeSmrg  }
1902300346aeSmrgfi #func_split_short_opt
1903300346aeSmrg
1904300346aeSmrg
1905300346aeSmrg# func_usage
1906300346aeSmrg# ----------
1907300346aeSmrg# Echo short help message to standard output and exit.
1908300346aeSmrgfunc_usage ()
19093c15da26Smrg{
1910300346aeSmrg    $debug_cmd
19113c15da26Smrg
1912300346aeSmrg    func_usage_message
1913300346aeSmrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
1914300346aeSmrg    exit 0
1915300346aeSmrg}
19163c15da26Smrg
19173c15da26Smrg
1918300346aeSmrg# func_usage_message
1919300346aeSmrg# ------------------
1920300346aeSmrg# Echo short help message to standard output.
1921300346aeSmrgfunc_usage_message ()
19223c15da26Smrg{
1923300346aeSmrg    $debug_cmd
19243c15da26Smrg
1925300346aeSmrg    eval \$ECHO \""Usage: $usage"\"
1926300346aeSmrg    echo
1927300346aeSmrg    $SED -n 's|^# ||
1928300346aeSmrg        /^Written by/{
1929300346aeSmrg          x;p;x
1930300346aeSmrg        }
1931300346aeSmrg	h
1932300346aeSmrg	/^Written by/q' < "$progpath"
1933300346aeSmrg    echo
1934300346aeSmrg    eval \$ECHO \""$usage_message"\"
1935300346aeSmrg}
19363c15da26Smrg
1937d656433aSmrg
1938300346aeSmrg# func_version
1939300346aeSmrg# ------------
1940300346aeSmrg# Echo version message to standard output and exit.
1941300346aeSmrgfunc_version ()
1942300346aeSmrg{
1943300346aeSmrg    $debug_cmd
1944d656433aSmrg
1945300346aeSmrg    printf '%s\n' "$progname $scriptversion"
1946300346aeSmrg    $SED -n '
1947300346aeSmrg        /(C)/!b go
1948300346aeSmrg        :more
1949300346aeSmrg        /\./!{
1950300346aeSmrg          N
1951300346aeSmrg          s|\n# | |
1952300346aeSmrg          b more
1953300346aeSmrg        }
1954300346aeSmrg        :go
1955300346aeSmrg        /^# Written by /,/# warranty; / {
1956300346aeSmrg          s|^# ||
1957300346aeSmrg          s|^# *$||
1958300346aeSmrg          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
1959300346aeSmrg          p
1960300346aeSmrg        }
1961300346aeSmrg        /^# Written by / {
1962300346aeSmrg          s|^# ||
1963300346aeSmrg          p
1964300346aeSmrg        }
1965300346aeSmrg        /^warranty; /q' < "$progpath"
1966d656433aSmrg
1967300346aeSmrg    exit $?
1968300346aeSmrg}
1969d656433aSmrg
1970126a8a12Smrg
1971300346aeSmrg# Local variables:
1972300346aeSmrg# mode: shell-script
1973300346aeSmrg# sh-indentation: 2
1974300346aeSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1975300346aeSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1976300346aeSmrg# time-stamp-time-zone: "UTC"
1977300346aeSmrg# End:
1978126a8a12Smrg
1979300346aeSmrg# Set a version string.
1980300346aeSmrgscriptversion='(GNU libtool) 2.4.6'
1981126a8a12Smrg
1982126a8a12Smrg
1983300346aeSmrg# func_echo ARG...
1984300346aeSmrg# ----------------
1985300346aeSmrg# Libtool also displays the current mode in messages, so override
1986300346aeSmrg# funclib.sh func_echo with this custom definition.
1987300346aeSmrgfunc_echo ()
19883c15da26Smrg{
1989300346aeSmrg    $debug_cmd
19903c15da26Smrg
1991300346aeSmrg    _G_message=$*
1992300346aeSmrg
1993300346aeSmrg    func_echo_IFS=$IFS
1994300346aeSmrg    IFS=$nl
1995300346aeSmrg    for _G_line in $_G_message; do
1996300346aeSmrg      IFS=$func_echo_IFS
1997300346aeSmrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
1998300346aeSmrg    done
1999300346aeSmrg    IFS=$func_echo_IFS
2000300346aeSmrg}
20013c15da26Smrg
20023c15da26Smrg
2003300346aeSmrg# func_warning ARG...
2004300346aeSmrg# -------------------
2005300346aeSmrg# Libtool warnings are not categorized, so override funclib.sh
2006300346aeSmrg# func_warning with this simpler definition.
2007300346aeSmrgfunc_warning ()
20083c15da26Smrg{
2009300346aeSmrg    $debug_cmd
2010300346aeSmrg
2011300346aeSmrg    $warning_func ${1+"$@"}
2012300346aeSmrg}
2013300346aeSmrg
20143c15da26Smrg
2015300346aeSmrg## ---------------- ##
2016300346aeSmrg## Options parsing. ##
2017300346aeSmrg## ---------------- ##
2018300346aeSmrg
2019300346aeSmrg# Hook in the functions to make sure our own options are parsed during
2020300346aeSmrg# the option parsing loop.
2021300346aeSmrg
2022300346aeSmrgusage='$progpath [OPTION]... [MODE-ARG]...'
2023300346aeSmrg
2024300346aeSmrg# Short help message in response to '-h'.
2025300346aeSmrgusage_message="Options:
2026300346aeSmrg       --config             show all configuration variables
2027300346aeSmrg       --debug              enable verbose shell tracing
2028300346aeSmrg   -n, --dry-run            display commands without modifying any files
2029300346aeSmrg       --features           display basic configuration information and exit
2030300346aeSmrg       --mode=MODE          use operation mode MODE
2031300346aeSmrg       --no-warnings        equivalent to '-Wnone'
2032300346aeSmrg       --preserve-dup-deps  don't remove duplicate dependency libraries
2033300346aeSmrg       --quiet, --silent    don't print informational messages
2034300346aeSmrg       --tag=TAG            use configuration variables from tag TAG
2035300346aeSmrg   -v, --verbose            print more informational messages than default
2036300346aeSmrg       --version            print version information
2037300346aeSmrg   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
2038300346aeSmrg   -h, --help, --help-all   print short, long, or detailed help message
2039300346aeSmrg"
20403c15da26Smrg
2041300346aeSmrg# Additional text appended to 'usage_message' in response to '--help'.
2042300346aeSmrgfunc_help ()
20433c15da26Smrg{
2044300346aeSmrg    $debug_cmd
2045300346aeSmrg
2046300346aeSmrg    func_usage_message
2047300346aeSmrg    $ECHO "$long_help_message
2048300346aeSmrg
2049300346aeSmrgMODE must be one of the following:
2050300346aeSmrg
2051300346aeSmrg       clean           remove files from the build directory
2052300346aeSmrg       compile         compile a source file into a libtool object
2053300346aeSmrg       execute         automatically set library path, then run a program
2054300346aeSmrg       finish          complete the installation of libtool libraries
2055300346aeSmrg       install         install libraries or executables
2056300346aeSmrg       link            create a library or an executable
2057300346aeSmrg       uninstall       remove libraries from an installed directory
2058300346aeSmrg
2059300346aeSmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
2060300346aeSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2061300346aeSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
2062300346aeSmrg
2063300346aeSmrgWhen reporting a bug, please describe a test case to reproduce it and
2064300346aeSmrginclude the following information:
2065300346aeSmrg
2066300346aeSmrg       host-triplet:   $host
2067300346aeSmrg       shell:          $SHELL
2068300346aeSmrg       compiler:       $LTCC
2069300346aeSmrg       compiler flags: $LTCFLAGS
2070300346aeSmrg       linker:         $LD (gnu? $with_gnu_ld)
2071300346aeSmrg       version:        $progname $scriptversion Debian-2.4.6-2
2072300346aeSmrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2073300346aeSmrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2074300346aeSmrg
2075300346aeSmrgReport bugs to <bug-libtool@gnu.org>.
2076300346aeSmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>.
2077300346aeSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
2078300346aeSmrg    exit 0
2079300346aeSmrg}
20803c15da26Smrg
20813c15da26Smrg
2082300346aeSmrg# func_lo2o OBJECT-NAME
2083300346aeSmrg# ---------------------
2084300346aeSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2085300346aeSmrg# object suffix.
20863c15da26Smrg
2087300346aeSmrglo2o=s/\\.lo\$/.$objext/
2088300346aeSmrgo2lo=s/\\.$objext\$/.lo/
20893c15da26Smrg
2090300346aeSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
2091300346aeSmrg  eval 'func_lo2o ()
2092300346aeSmrg  {
2093300346aeSmrg    case $1 in
2094300346aeSmrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
2095300346aeSmrg      *   ) func_lo2o_result=$1               ;;
2096300346aeSmrg    esac
2097300346aeSmrg  }'
2098300346aeSmrg
2099300346aeSmrg  # func_xform LIBOBJ-OR-SOURCE
2100300346aeSmrg  # ---------------------------
2101300346aeSmrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2102300346aeSmrg  # suffix to a '.lo' libtool-object suffix.
2103300346aeSmrg  eval 'func_xform ()
2104300346aeSmrg  {
2105300346aeSmrg    func_xform_result=${1%.*}.lo
2106300346aeSmrg  }'
2107300346aeSmrgelse
2108300346aeSmrg  # ...otherwise fall back to using sed.
2109300346aeSmrg  func_lo2o ()
2110300346aeSmrg  {
2111300346aeSmrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2112300346aeSmrg  }
2113300346aeSmrg
2114300346aeSmrg  func_xform ()
2115300346aeSmrg  {
2116300346aeSmrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2117300346aeSmrg  }
2118300346aeSmrgfi
21193c15da26Smrg
21203c15da26Smrg
2121300346aeSmrg# func_fatal_configuration ARG...
2122300346aeSmrg# -------------------------------
2123d656433aSmrg# Echo program name prefixed message to standard error, followed by
2124d656433aSmrg# a configuration failure hint, and exit.
2125d656433aSmrgfunc_fatal_configuration ()
2126d656433aSmrg{
2127300346aeSmrg    func__fatal_error ${1+"$@"} \
2128300346aeSmrg      "See the $PACKAGE documentation for more information." \
2129300346aeSmrg      "Fatal configuration error."
2130d656433aSmrg}
2131d656433aSmrg
2132d656433aSmrg
2133d656433aSmrg# func_config
2134300346aeSmrg# -----------
2135d656433aSmrg# Display the configuration for all the tags in this script.
2136d656433aSmrgfunc_config ()
2137d656433aSmrg{
2138d656433aSmrg    re_begincf='^# ### BEGIN LIBTOOL'
2139d656433aSmrg    re_endcf='^# ### END LIBTOOL'
2140d656433aSmrg
2141d656433aSmrg    # Default configuration.
2142d656433aSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
2143126a8a12Smrg
2144126a8a12Smrg    # Now print the configurations for the tags.
2145126a8a12Smrg    for tagname in $taglist; do
2146d656433aSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2147126a8a12Smrg    done
2148126a8a12Smrg
2149d656433aSmrg    exit $?
2150d656433aSmrg}
2151126a8a12Smrg
2152300346aeSmrg
2153d656433aSmrg# func_features
2154300346aeSmrg# -------------
2155d656433aSmrg# Display the features supported by this script.
2156d656433aSmrgfunc_features ()
2157d656433aSmrg{
2158555991fdSmrg    echo "host: $host"
2159300346aeSmrg    if test yes = "$build_libtool_libs"; then
2160555991fdSmrg      echo "enable shared libraries"
2161126a8a12Smrg    else
2162555991fdSmrg      echo "disable shared libraries"
2163126a8a12Smrg    fi
2164300346aeSmrg    if test yes = "$build_old_libs"; then
2165555991fdSmrg      echo "enable static libraries"
2166126a8a12Smrg    else
2167555991fdSmrg      echo "disable static libraries"
2168126a8a12Smrg    fi
2169d656433aSmrg
2170126a8a12Smrg    exit $?
2171d656433aSmrg}
2172126a8a12Smrg
2173300346aeSmrg
2174300346aeSmrg# func_enable_tag TAGNAME
2175300346aeSmrg# -----------------------
2176d656433aSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
2177d656433aSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
2178d656433aSmrg# variable here.
2179d656433aSmrgfunc_enable_tag ()
2180d656433aSmrg{
2181300346aeSmrg    # Global variable:
2182300346aeSmrg    tagname=$1
2183126a8a12Smrg
2184300346aeSmrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
2185300346aeSmrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
2186300346aeSmrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
2187126a8a12Smrg
2188300346aeSmrg    # Validate tagname.
2189300346aeSmrg    case $tagname in
2190300346aeSmrg      *[!-_A-Za-z0-9,/]*)
2191300346aeSmrg        func_fatal_error "invalid tag name: $tagname"
2192300346aeSmrg        ;;
2193300346aeSmrg    esac
2194126a8a12Smrg
2195300346aeSmrg    # Don't test for the "default" C tag, as we know it's
2196300346aeSmrg    # there but not specially marked.
2197300346aeSmrg    case $tagname in
2198300346aeSmrg        CC) ;;
2199d656433aSmrg    *)
2200300346aeSmrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
2201300346aeSmrg	  taglist="$taglist $tagname"
2202300346aeSmrg
2203300346aeSmrg	  # Evaluate the configuration.  Be careful to quote the path
2204300346aeSmrg	  # and the sed script, to avoid splitting on whitespace, but
2205300346aeSmrg	  # also don't use non-portable quotes within backquotes within
2206300346aeSmrg	  # quotes we have to do it in 2 steps:
2207300346aeSmrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
2208300346aeSmrg	  eval "$extractedcf"
2209300346aeSmrg        else
2210300346aeSmrg	  func_error "ignoring unknown tag $tagname"
2211300346aeSmrg        fi
2212300346aeSmrg        ;;
2213300346aeSmrg    esac
2214d656433aSmrg}
2215d656433aSmrg
2216300346aeSmrg
22173c15da26Smrg# func_check_version_match
2218300346aeSmrg# ------------------------
22193c15da26Smrg# Ensure that we are using m4 macros, and libtool script from the same
22203c15da26Smrg# release of libtool.
22213c15da26Smrgfunc_check_version_match ()
2222d656433aSmrg{
2223300346aeSmrg    if test "$package_revision" != "$macro_revision"; then
2224300346aeSmrg      if test "$VERSION" != "$macro_version"; then
2225300346aeSmrg        if test -z "$macro_version"; then
2226300346aeSmrg          cat >&2 <<_LT_EOF
22273c15da26Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
22283c15da26Smrg$progname: definition of this LT_INIT comes from an older release.
22293c15da26Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
22303c15da26Smrg$progname: and run autoconf again.
22313c15da26Smrg_LT_EOF
2232300346aeSmrg        else
2233300346aeSmrg          cat >&2 <<_LT_EOF
22343c15da26Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
22353c15da26Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
22363c15da26Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
22373c15da26Smrg$progname: and run autoconf again.
22383c15da26Smrg_LT_EOF
2239300346aeSmrg        fi
2240300346aeSmrg      else
2241300346aeSmrg        cat >&2 <<_LT_EOF
22423c15da26Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
22433c15da26Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
22443c15da26Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
22453c15da26Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
22463c15da26Smrg_LT_EOF
2247300346aeSmrg      fi
2248126a8a12Smrg
2249300346aeSmrg      exit $EXIT_MISMATCH
2250300346aeSmrg    fi
22513c15da26Smrg}
22523c15da26Smrg
22533c15da26Smrg
2254300346aeSmrg# libtool_options_prep [ARG]...
2255300346aeSmrg# -----------------------------
2256300346aeSmrg# Preparation for options parsed by libtool.
2257300346aeSmrglibtool_options_prep ()
2258300346aeSmrg{
2259300346aeSmrg    $debug_mode
2260126a8a12Smrg
2261300346aeSmrg    # Option defaults:
2262300346aeSmrg    opt_config=false
2263300346aeSmrg    opt_dlopen=
2264300346aeSmrg    opt_dry_run=false
2265300346aeSmrg    opt_help=false
2266300346aeSmrg    opt_mode=
2267300346aeSmrg    opt_preserve_dup_deps=false
2268300346aeSmrg    opt_quiet=false
22693c15da26Smrg
2270300346aeSmrg    nonopt=
2271300346aeSmrg    preserve_args=
22723c15da26Smrg
2273300346aeSmrg    # Shorthand for --mode=foo, only valid as the first argument
2274300346aeSmrg    case $1 in
2275300346aeSmrg    clean|clea|cle|cl)
2276300346aeSmrg      shift; set dummy --mode clean ${1+"$@"}; shift
2277300346aeSmrg      ;;
2278300346aeSmrg    compile|compil|compi|comp|com|co|c)
2279300346aeSmrg      shift; set dummy --mode compile ${1+"$@"}; shift
2280300346aeSmrg      ;;
2281300346aeSmrg    execute|execut|execu|exec|exe|ex|e)
2282300346aeSmrg      shift; set dummy --mode execute ${1+"$@"}; shift
2283300346aeSmrg      ;;
2284300346aeSmrg    finish|finis|fini|fin|fi|f)
2285300346aeSmrg      shift; set dummy --mode finish ${1+"$@"}; shift
2286300346aeSmrg      ;;
2287300346aeSmrg    install|instal|insta|inst|ins|in|i)
2288300346aeSmrg      shift; set dummy --mode install ${1+"$@"}; shift
2289300346aeSmrg      ;;
2290300346aeSmrg    link|lin|li|l)
2291300346aeSmrg      shift; set dummy --mode link ${1+"$@"}; shift
2292300346aeSmrg      ;;
2293300346aeSmrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
2294300346aeSmrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
2295300346aeSmrg      ;;
2296300346aeSmrg    esac
2297300346aeSmrg
2298300346aeSmrg    # Pass back the list of options.
2299300346aeSmrg    func_quote_for_eval ${1+"$@"}
2300300346aeSmrg    libtool_options_prep_result=$func_quote_for_eval_result
2301300346aeSmrg}
2302300346aeSmrgfunc_add_hook func_options_prep libtool_options_prep
23033c15da26Smrg
23043c15da26Smrg
2305300346aeSmrg# libtool_parse_options [ARG]...
2306300346aeSmrg# ---------------------------------
2307300346aeSmrg# Provide handling for libtool specific options.
2308300346aeSmrglibtool_parse_options ()
23093c15da26Smrg{
2310300346aeSmrg    $debug_cmd
2311d656433aSmrg
2312300346aeSmrg    # Perform our own loop to consume as many options as possible in
2313300346aeSmrg    # each iteration.
2314300346aeSmrg    while test $# -gt 0; do
2315300346aeSmrg      _G_opt=$1
2316300346aeSmrg      shift
2317300346aeSmrg      case $_G_opt in
2318300346aeSmrg        --dry-run|--dryrun|-n)
2319300346aeSmrg                        opt_dry_run=:
2320300346aeSmrg                        ;;
2321300346aeSmrg
2322300346aeSmrg        --config)       func_config ;;
2323300346aeSmrg
2324300346aeSmrg        --dlopen|-dlopen)
2325300346aeSmrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
2326300346aeSmrg}$1"
2327300346aeSmrg                        shift
2328300346aeSmrg                        ;;
2329300346aeSmrg
2330300346aeSmrg        --preserve-dup-deps)
2331300346aeSmrg                        opt_preserve_dup_deps=: ;;
2332300346aeSmrg
2333300346aeSmrg        --features)     func_features ;;
2334300346aeSmrg
2335300346aeSmrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
2336300346aeSmrg
2337300346aeSmrg        --help)         opt_help=: ;;
2338300346aeSmrg
2339300346aeSmrg        --help-all)     opt_help=': help-all' ;;
2340300346aeSmrg
2341300346aeSmrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
2342300346aeSmrg                        opt_mode=$1
2343300346aeSmrg                        case $1 in
2344300346aeSmrg                          # Valid mode arguments:
2345300346aeSmrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
2346300346aeSmrg
2347300346aeSmrg                          # Catch anything else as an error
2348300346aeSmrg                          *) func_error "invalid argument for $_G_opt"
2349300346aeSmrg                             exit_cmd=exit
2350300346aeSmrg                             break
2351300346aeSmrg                             ;;
2352300346aeSmrg                        esac
2353300346aeSmrg                        shift
2354300346aeSmrg                        ;;
2355300346aeSmrg
2356300346aeSmrg        --no-silent|--no-quiet)
2357300346aeSmrg                        opt_quiet=false
2358300346aeSmrg                        func_append preserve_args " $_G_opt"
2359300346aeSmrg                        ;;
2360300346aeSmrg
2361300346aeSmrg        --no-warnings|--no-warning|--no-warn)
2362300346aeSmrg                        opt_warning=false
2363300346aeSmrg                        func_append preserve_args " $_G_opt"
2364300346aeSmrg                        ;;
2365300346aeSmrg
2366300346aeSmrg        --no-verbose)
2367300346aeSmrg                        opt_verbose=false
2368300346aeSmrg                        func_append preserve_args " $_G_opt"
2369300346aeSmrg                        ;;
2370300346aeSmrg
2371300346aeSmrg        --silent|--quiet)
2372300346aeSmrg                        opt_quiet=:
2373300346aeSmrg                        opt_verbose=false
2374300346aeSmrg                        func_append preserve_args " $_G_opt"
2375300346aeSmrg                        ;;
2376300346aeSmrg
2377300346aeSmrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
2378300346aeSmrg                        opt_tag=$1
2379300346aeSmrg                        func_append preserve_args " $_G_opt $1"
2380300346aeSmrg                        func_enable_tag "$1"
2381300346aeSmrg                        shift
2382300346aeSmrg                        ;;
2383300346aeSmrg
2384300346aeSmrg        --verbose|-v)   opt_quiet=false
2385300346aeSmrg                        opt_verbose=:
2386300346aeSmrg                        func_append preserve_args " $_G_opt"
2387300346aeSmrg                        ;;
2388300346aeSmrg
2389300346aeSmrg	# An option not handled by this hook function:
2390300346aeSmrg        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
2391300346aeSmrg      esac
2392300346aeSmrg    done
23933c15da26Smrg
23943c15da26Smrg
2395300346aeSmrg    # save modified positional parameters for caller
2396300346aeSmrg    func_quote_for_eval ${1+"$@"}
2397300346aeSmrg    libtool_parse_options_result=$func_quote_for_eval_result
2398300346aeSmrg}
2399300346aeSmrgfunc_add_hook func_parse_options libtool_parse_options
2400d656433aSmrg
2401126a8a12Smrg
2402d656433aSmrg
2403300346aeSmrg# libtool_validate_options [ARG]...
2404300346aeSmrg# ---------------------------------
2405300346aeSmrg# Perform any sanity checks on option settings and/or unconsumed
2406300346aeSmrg# arguments.
2407300346aeSmrglibtool_validate_options ()
2408300346aeSmrg{
2409300346aeSmrg    # save first non-option argument
2410300346aeSmrg    if test 0 -lt $#; then
2411300346aeSmrg      nonopt=$1
2412300346aeSmrg      shift
2413d656433aSmrg    fi
2414d656433aSmrg
2415300346aeSmrg    # preserve --debug
2416300346aeSmrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
2417d656433aSmrg
2418300346aeSmrg    case $host in
2419300346aeSmrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
2420300346aeSmrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
2421300346aeSmrg      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
2422300346aeSmrg        # don't eliminate duplications in $postdeps and $predeps
2423300346aeSmrg        opt_duplicate_compiler_generated_deps=:
2424300346aeSmrg        ;;
2425300346aeSmrg      *)
2426300346aeSmrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
2427300346aeSmrg        ;;
2428300346aeSmrg    esac
2429d656433aSmrg
2430300346aeSmrg    $opt_help || {
2431300346aeSmrg      # Sanity checks first:
2432300346aeSmrg      func_check_version_match
2433d656433aSmrg
2434300346aeSmrg      test yes != "$build_libtool_libs" \
2435300346aeSmrg        && test yes != "$build_old_libs" \
2436300346aeSmrg        && func_fatal_configuration "not configured to build any kind of library"
2437d656433aSmrg
2438300346aeSmrg      # Darwin sucks
2439300346aeSmrg      eval std_shrext=\"$shrext_cmds\"
2440300346aeSmrg
2441300346aeSmrg      # Only execute mode is allowed to have -dlopen flags.
2442300346aeSmrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
2443300346aeSmrg        func_error "unrecognized option '-dlopen'"
2444300346aeSmrg        $ECHO "$help" 1>&2
2445300346aeSmrg        exit $EXIT_FAILURE
2446300346aeSmrg      fi
2447300346aeSmrg
2448300346aeSmrg      # Change the help message to a mode-specific one.
2449300346aeSmrg      generic_help=$help
2450300346aeSmrg      help="Try '$progname --help --mode=$opt_mode' for more information."
2451300346aeSmrg    }
2452300346aeSmrg
2453300346aeSmrg    # Pass back the unparsed argument list
2454300346aeSmrg    func_quote_for_eval ${1+"$@"}
2455300346aeSmrg    libtool_validate_options_result=$func_quote_for_eval_result
24563c15da26Smrg}
2457300346aeSmrgfunc_add_hook func_validate_options libtool_validate_options
2458300346aeSmrg
2459d656433aSmrg
2460300346aeSmrg# Process options as early as possible so that --help and --version
2461300346aeSmrg# can return quickly.
2462300346aeSmrgfunc_options ${1+"$@"}
2463300346aeSmrgeval set dummy "$func_options_result"; shift
2464126a8a12Smrg
2465126a8a12Smrg
2466126a8a12Smrg
24673c15da26Smrg## ----------- ##
24683c15da26Smrg##    Main.    ##
24693c15da26Smrg## ----------- ##
2470126a8a12Smrg
2471300346aeSmrgmagic='%%%MAGIC variable%%%'
2472300346aeSmrgmagic_exe='%%%MAGIC EXE variable%%%'
2473300346aeSmrg
2474300346aeSmrg# Global variables.
2475300346aeSmrgextracted_archives=
2476300346aeSmrgextracted_serial=0
2477300346aeSmrg
2478300346aeSmrg# If this variable is set in any of the actions, the command in it
2479300346aeSmrg# will be execed at the end.  This prevents here-documents from being
2480300346aeSmrg# left over by shells.
2481300346aeSmrgexec_cmd=
2482300346aeSmrg
2483300346aeSmrg
2484300346aeSmrg# A function that is used when there is no print builtin or printf.
2485300346aeSmrgfunc_fallback_echo ()
2486300346aeSmrg{
2487300346aeSmrg  eval 'cat <<_LTECHO_EOF
2488300346aeSmrg$1
2489300346aeSmrg_LTECHO_EOF'
2490300346aeSmrg}
2491300346aeSmrg
2492300346aeSmrg# func_generated_by_libtool
2493300346aeSmrg# True iff stdin has been generated by Libtool. This function is only
2494300346aeSmrg# a basic sanity check; it will hardly flush out determined imposters.
2495300346aeSmrgfunc_generated_by_libtool_p ()
2496300346aeSmrg{
2497300346aeSmrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
2498300346aeSmrg}
2499300346aeSmrg
2500d656433aSmrg# func_lalib_p file
2501300346aeSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
2502d656433aSmrg# This function is only a basic sanity check; it will hardly flush out
2503d656433aSmrg# determined imposters.
2504d656433aSmrgfunc_lalib_p ()
2505d656433aSmrg{
2506d656433aSmrg    test -f "$1" &&
2507300346aeSmrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
2508d656433aSmrg}
2509126a8a12Smrg
2510d656433aSmrg# func_lalib_unsafe_p file
2511300346aeSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
2512d656433aSmrg# This function implements the same check as func_lalib_p without
2513d656433aSmrg# resorting to external programs.  To this end, it redirects stdin and
2514d656433aSmrg# closes it afterwards, without saving the original file descriptor.
2515d656433aSmrg# As a safety measure, use it only where a negative result would be
2516300346aeSmrg# fatal anyway.  Works if 'file' does not exist.
2517d656433aSmrgfunc_lalib_unsafe_p ()
2518d656433aSmrg{
2519d656433aSmrg    lalib_p=no
2520d656433aSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
2521d656433aSmrg	for lalib_p_l in 1 2 3 4
2522d656433aSmrg	do
2523d656433aSmrg	    read lalib_p_line
2524300346aeSmrg	    case $lalib_p_line in
2525d656433aSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
2526d656433aSmrg	    esac
2527d656433aSmrg	done
2528d656433aSmrg	exec 0<&5 5<&-
2529d656433aSmrg    fi
2530300346aeSmrg    test yes = "$lalib_p"
2531d656433aSmrg}
2532126a8a12Smrg
2533d656433aSmrg# func_ltwrapper_script_p file
2534d656433aSmrg# True iff FILE is a libtool wrapper script
2535d656433aSmrg# This function is only a basic sanity check; it will hardly flush out
2536d656433aSmrg# determined imposters.
2537d656433aSmrgfunc_ltwrapper_script_p ()
2538d656433aSmrg{
2539300346aeSmrg    test -f "$1" &&
2540300346aeSmrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
2541d656433aSmrg}
2542126a8a12Smrg
2543d656433aSmrg# func_ltwrapper_executable_p file
2544d656433aSmrg# True iff FILE is a libtool wrapper executable
2545d656433aSmrg# This function is only a basic sanity check; it will hardly flush out
2546d656433aSmrg# determined imposters.
2547d656433aSmrgfunc_ltwrapper_executable_p ()
2548d656433aSmrg{
2549d656433aSmrg    func_ltwrapper_exec_suffix=
2550d656433aSmrg    case $1 in
2551d656433aSmrg    *.exe) ;;
2552d656433aSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
2553d656433aSmrg    esac
2554d656433aSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
2555d656433aSmrg}
2556126a8a12Smrg
2557d656433aSmrg# func_ltwrapper_scriptname file
2558d656433aSmrg# Assumes file is an ltwrapper_executable
2559d656433aSmrg# uses $file to determine the appropriate filename for a
2560d656433aSmrg# temporary ltwrapper_script.
2561d656433aSmrgfunc_ltwrapper_scriptname ()
2562d656433aSmrg{
25633c15da26Smrg    func_dirname_and_basename "$1" "" "."
25643c15da26Smrg    func_stripname '' '.exe' "$func_basename_result"
2565300346aeSmrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
2566d656433aSmrg}
2567126a8a12Smrg
2568d656433aSmrg# func_ltwrapper_p file
2569d656433aSmrg# True iff FILE is a libtool wrapper script or wrapper executable
2570d656433aSmrg# This function is only a basic sanity check; it will hardly flush out
2571d656433aSmrg# determined imposters.
2572d656433aSmrgfunc_ltwrapper_p ()
2573d656433aSmrg{
2574d656433aSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
2575d656433aSmrg}
2576126a8a12Smrg
2577126a8a12Smrg
2578d656433aSmrg# func_execute_cmds commands fail_cmd
2579d656433aSmrg# Execute tilde-delimited COMMANDS.
2580d656433aSmrg# If FAIL_CMD is given, eval that upon failure.
2581d656433aSmrg# FAIL_CMD may read-access the current command in variable CMD!
2582d656433aSmrgfunc_execute_cmds ()
2583d656433aSmrg{
2584300346aeSmrg    $debug_cmd
2585300346aeSmrg
2586d656433aSmrg    save_ifs=$IFS; IFS='~'
2587d656433aSmrg    for cmd in $1; do
2588300346aeSmrg      IFS=$sp$nl
2589d656433aSmrg      eval cmd=\"$cmd\"
2590300346aeSmrg      IFS=$save_ifs
2591d656433aSmrg      func_show_eval "$cmd" "${2-:}"
2592d656433aSmrg    done
2593d656433aSmrg    IFS=$save_ifs
2594d656433aSmrg}
2595d656433aSmrg
2596d656433aSmrg
2597d656433aSmrg# func_source file
2598d656433aSmrg# Source FILE, adding directory component if necessary.
2599d656433aSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
2600d656433aSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
2601d656433aSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
2602300346aeSmrg# 'FILE.' does not work on cygwin managed mounts.
2603d656433aSmrgfunc_source ()
2604d656433aSmrg{
2605300346aeSmrg    $debug_cmd
2606300346aeSmrg
2607d656433aSmrg    case $1 in
2608d656433aSmrg    */* | *\\*)	. "$1" ;;
2609d656433aSmrg    *)		. "./$1" ;;
2610d656433aSmrg    esac
2611d656433aSmrg}
2612d656433aSmrg
2613d656433aSmrg
26143c15da26Smrg# func_resolve_sysroot PATH
26153c15da26Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
26163c15da26Smrg# func_resolve_sysroot_result
26173c15da26Smrgfunc_resolve_sysroot ()
26183c15da26Smrg{
26193c15da26Smrg  func_resolve_sysroot_result=$1
26203c15da26Smrg  case $func_resolve_sysroot_result in
26213c15da26Smrg  =*)
26223c15da26Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
26233c15da26Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
26243c15da26Smrg    ;;
26253c15da26Smrg  esac
26263c15da26Smrg}
26273c15da26Smrg
26283c15da26Smrg# func_replace_sysroot PATH
26293c15da26Smrg# If PATH begins with the sysroot, replace it with = and
26303c15da26Smrg# store the result into func_replace_sysroot_result.
26313c15da26Smrgfunc_replace_sysroot ()
26323c15da26Smrg{
2633300346aeSmrg  case $lt_sysroot:$1 in
26343c15da26Smrg  ?*:"$lt_sysroot"*)
26353c15da26Smrg    func_stripname "$lt_sysroot" '' "$1"
2636300346aeSmrg    func_replace_sysroot_result='='$func_stripname_result
26373c15da26Smrg    ;;
26383c15da26Smrg  *)
26393c15da26Smrg    # Including no sysroot.
26403c15da26Smrg    func_replace_sysroot_result=$1
26413c15da26Smrg    ;;
26423c15da26Smrg  esac
26433c15da26Smrg}
26443c15da26Smrg
2645d656433aSmrg# func_infer_tag arg
2646d656433aSmrg# Infer tagged configuration to use if any are available and
2647d656433aSmrg# if one wasn't chosen via the "--tag" command line option.
2648d656433aSmrg# Only attempt this if the compiler in the base compile
2649d656433aSmrg# command doesn't match the default compiler.
2650d656433aSmrg# arg is usually of the form 'gcc ...'
2651d656433aSmrgfunc_infer_tag ()
2652d656433aSmrg{
2653300346aeSmrg    $debug_cmd
2654300346aeSmrg
2655d656433aSmrg    if test -n "$available_tags" && test -z "$tagname"; then
2656d656433aSmrg      CC_quoted=
2657d656433aSmrg      for arg in $CC; do
26583c15da26Smrg	func_append_quoted CC_quoted "$arg"
2659d656433aSmrg      done
2660555991fdSmrg      CC_expanded=`func_echo_all $CC`
2661555991fdSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
2662d656433aSmrg      case $@ in
2663d656433aSmrg      # Blanks in the command may have been stripped by the calling shell,
2664d656433aSmrg      # but not from the CC environment variable when configure was run.
2665555991fdSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2666555991fdSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
2667d656433aSmrg      # Blanks at the start of $base_compile will cause this to fail
2668d656433aSmrg      # if we don't check for them as well.
2669d656433aSmrg      *)
2670d656433aSmrg	for z in $available_tags; do
2671d656433aSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2672d656433aSmrg	    # Evaluate the configuration.
2673300346aeSmrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2674d656433aSmrg	    CC_quoted=
2675d656433aSmrg	    for arg in $CC; do
2676d656433aSmrg	      # Double-quote args containing other shell metacharacters.
26773c15da26Smrg	      func_append_quoted CC_quoted "$arg"
2678d656433aSmrg	    done
2679555991fdSmrg	    CC_expanded=`func_echo_all $CC`
2680555991fdSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
2681d656433aSmrg	    case "$@ " in
2682555991fdSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2683555991fdSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
2684d656433aSmrg	      # The compiler in the base compile command matches
2685d656433aSmrg	      # the one in the tagged configuration.
2686d656433aSmrg	      # Assume this is the tagged configuration we want.
2687d656433aSmrg	      tagname=$z
2688d656433aSmrg	      break
2689126a8a12Smrg	      ;;
2690126a8a12Smrg	    esac
2691d656433aSmrg	  fi
2692d656433aSmrg	done
2693d656433aSmrg	# If $tagname still isn't set, then no tagged configuration
2694d656433aSmrg	# was found and let the user know that the "--tag" command
2695d656433aSmrg	# line option must be used.
2696d656433aSmrg	if test -z "$tagname"; then
2697d656433aSmrg	  func_echo "unable to infer tagged configuration"
2698300346aeSmrg	  func_fatal_error "specify a tag with '--tag'"
2699d656433aSmrg#	else
2700d656433aSmrg#	  func_verbose "using $tagname tagged configuration"
2701d656433aSmrg	fi
2702d656433aSmrg	;;
2703d656433aSmrg      esac
2704d656433aSmrg    fi
2705d656433aSmrg}
2706d656433aSmrg
2707d656433aSmrg
2708d656433aSmrg
27093c15da26Smrg# func_write_libtool_object output_name pic_name nonpic_name
27103c15da26Smrg# Create a libtool object file (analogous to a ".la" file),
27113c15da26Smrg# but don't create it if we're doing a dry run.
27123c15da26Smrgfunc_write_libtool_object ()
27133c15da26Smrg{
2714300346aeSmrg    write_libobj=$1
2715300346aeSmrg    if test yes = "$build_libtool_libs"; then
2716300346aeSmrg      write_lobj=\'$2\'
27173c15da26Smrg    else
27183c15da26Smrg      write_lobj=none
27193c15da26Smrg    fi
27203c15da26Smrg
2721300346aeSmrg    if test yes = "$build_old_libs"; then
2722300346aeSmrg      write_oldobj=\'$3\'
27233c15da26Smrg    else
27243c15da26Smrg      write_oldobj=none
27253c15da26Smrg    fi
27263c15da26Smrg
27273c15da26Smrg    $opt_dry_run || {
27283c15da26Smrg      cat >${write_libobj}T <<EOF
27293c15da26Smrg# $write_libobj - a libtool object file
2730300346aeSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
27313c15da26Smrg#
27323c15da26Smrg# Please DO NOT delete this file!
27333c15da26Smrg# It is necessary for linking the library.
27343c15da26Smrg
27353c15da26Smrg# Name of the PIC object.
27363c15da26Smrgpic_object=$write_lobj
27373c15da26Smrg
27383c15da26Smrg# Name of the non-PIC object
27393c15da26Smrgnon_pic_object=$write_oldobj
27403c15da26Smrg
27413c15da26SmrgEOF
2742300346aeSmrg      $MV "${write_libobj}T" "$write_libobj"
27433c15da26Smrg    }
27443c15da26Smrg}
27453c15da26Smrg
27463c15da26Smrg
27473c15da26Smrg##################################################
27483c15da26Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
27493c15da26Smrg##################################################
27503c15da26Smrg
27513c15da26Smrg# func_convert_core_file_wine_to_w32 ARG
27523c15da26Smrg# Helper function used by file name conversion functions when $build is *nix,
27533c15da26Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
27543c15da26Smrg# correctly configured wine environment available, with the winepath program
27553c15da26Smrg# in $build's $PATH.
27563c15da26Smrg#
27573c15da26Smrg# ARG is the $build file name to be converted to w32 format.
27583c15da26Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
27593c15da26Smrg# be empty on error (or when ARG is empty)
27603c15da26Smrgfunc_convert_core_file_wine_to_w32 ()
27613c15da26Smrg{
2762300346aeSmrg  $debug_cmd
2763300346aeSmrg
2764300346aeSmrg  func_convert_core_file_wine_to_w32_result=$1
27653c15da26Smrg  if test -n "$1"; then
27663c15da26Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
27673c15da26Smrg    # are forced to check the contents of stdout. On the other hand, if the
27683c15da26Smrg    # command is not found, the shell will set an exit code of 127 and print
27693c15da26Smrg    # *an error message* to stdout. So we must check for both error code of
27703c15da26Smrg    # zero AND non-empty stdout, which explains the odd construction:
27713c15da26Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
2772300346aeSmrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
27733c15da26Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
2774300346aeSmrg        $SED -e "$sed_naive_backslashify"`
27753c15da26Smrg    else
27763c15da26Smrg      func_convert_core_file_wine_to_w32_result=
27773c15da26Smrg    fi
27783c15da26Smrg  fi
27793c15da26Smrg}
27803c15da26Smrg# end: func_convert_core_file_wine_to_w32
27813c15da26Smrg
27823c15da26Smrg
27833c15da26Smrg# func_convert_core_path_wine_to_w32 ARG
27843c15da26Smrg# Helper function used by path conversion functions when $build is *nix, and
27853c15da26Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
27863c15da26Smrg# configured wine environment available, with the winepath program in $build's
27873c15da26Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
27883c15da26Smrg#
27893c15da26Smrg# ARG is path to be converted from $build format to win32.
27903c15da26Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
27913c15da26Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
27923c15da26Smrg# are convertible, then the result may be empty.
27933c15da26Smrgfunc_convert_core_path_wine_to_w32 ()
27943c15da26Smrg{
2795300346aeSmrg  $debug_cmd
2796300346aeSmrg
27973c15da26Smrg  # unfortunately, winepath doesn't convert paths, only file names
2798300346aeSmrg  func_convert_core_path_wine_to_w32_result=
27993c15da26Smrg  if test -n "$1"; then
28003c15da26Smrg    oldIFS=$IFS
28013c15da26Smrg    IFS=:
28023c15da26Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
28033c15da26Smrg      IFS=$oldIFS
28043c15da26Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
2805300346aeSmrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
28063c15da26Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
2807300346aeSmrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
28083c15da26Smrg        else
28093c15da26Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
28103c15da26Smrg        fi
28113c15da26Smrg      fi
28123c15da26Smrg    done
28133c15da26Smrg    IFS=$oldIFS
28143c15da26Smrg  fi
28153c15da26Smrg}
28163c15da26Smrg# end: func_convert_core_path_wine_to_w32
28173c15da26Smrg
28183c15da26Smrg
28193c15da26Smrg# func_cygpath ARGS...
28203c15da26Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
28213c15da26Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
28223c15da26Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
28233c15da26Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
28243c15da26Smrg# file name or path is assumed to be in w32 format, as previously converted
28253c15da26Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
28263c15da26Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
28273c15da26Smrg# Cygwin format). Returns an empty string on error.
28283c15da26Smrg#
28293c15da26Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
28303c15da26Smrg# be converted.
28313c15da26Smrg#
28323c15da26Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
28333c15da26Smrg# environment variable; do not put it in $PATH.
28343c15da26Smrgfunc_cygpath ()
28353c15da26Smrg{
2836300346aeSmrg  $debug_cmd
2837300346aeSmrg
28383c15da26Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
28393c15da26Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
28403c15da26Smrg    if test "$?" -ne 0; then
28413c15da26Smrg      # on failure, ensure result is empty
28423c15da26Smrg      func_cygpath_result=
28433c15da26Smrg    fi
28443c15da26Smrg  else
28453c15da26Smrg    func_cygpath_result=
2846300346aeSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
28473c15da26Smrg  fi
28483c15da26Smrg}
28493c15da26Smrg#end: func_cygpath
28503c15da26Smrg
28513c15da26Smrg
28523c15da26Smrg# func_convert_core_msys_to_w32 ARG
28533c15da26Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
28543c15da26Smrg# result in func_convert_core_msys_to_w32_result.
28553c15da26Smrgfunc_convert_core_msys_to_w32 ()
28563c15da26Smrg{
2857300346aeSmrg  $debug_cmd
2858300346aeSmrg
28593c15da26Smrg  # awkward: cmd appends spaces to result
28603c15da26Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
2861300346aeSmrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
28623c15da26Smrg}
28633c15da26Smrg#end: func_convert_core_msys_to_w32
28643c15da26Smrg
28653c15da26Smrg
28663c15da26Smrg# func_convert_file_check ARG1 ARG2
28673c15da26Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
28683c15da26Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
28693c15da26Smrg# func_to_host_file_result to ARG1).
28703c15da26Smrgfunc_convert_file_check ()
28713c15da26Smrg{
2872300346aeSmrg  $debug_cmd
2873300346aeSmrg
2874300346aeSmrg  if test -z "$2" && test -n "$1"; then
28753c15da26Smrg    func_error "Could not determine host file name corresponding to"
2876300346aeSmrg    func_error "  '$1'"
28773c15da26Smrg    func_error "Continuing, but uninstalled executables may not work."
28783c15da26Smrg    # Fallback:
2879300346aeSmrg    func_to_host_file_result=$1
28803c15da26Smrg  fi
28813c15da26Smrg}
28823c15da26Smrg# end func_convert_file_check
28833c15da26Smrg
28843c15da26Smrg
28853c15da26Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
28863c15da26Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
28873c15da26Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
28883c15da26Smrg# func_to_host_file_result to a simplistic fallback value (see below).
28893c15da26Smrgfunc_convert_path_check ()
28903c15da26Smrg{
2891300346aeSmrg  $debug_cmd
2892300346aeSmrg
28933c15da26Smrg  if test -z "$4" && test -n "$3"; then
28943c15da26Smrg    func_error "Could not determine the host path corresponding to"
2895300346aeSmrg    func_error "  '$3'"
28963c15da26Smrg    func_error "Continuing, but uninstalled executables may not work."
28973c15da26Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
28983c15da26Smrg    # should not be "improved".  See libtool.info.
28993c15da26Smrg    if test "x$1" != "x$2"; then
29003c15da26Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
29013c15da26Smrg      func_to_host_path_result=`echo "$3" |
29023c15da26Smrg        $SED -e "$lt_replace_pathsep_chars"`
29033c15da26Smrg    else
2904300346aeSmrg      func_to_host_path_result=$3
29053c15da26Smrg    fi
29063c15da26Smrg  fi
29073c15da26Smrg}
29083c15da26Smrg# end func_convert_path_check
29093c15da26Smrg
29103c15da26Smrg
29113c15da26Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
29123c15da26Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
29133c15da26Smrg# and appending REPL if ORIG matches BACKPAT.
29143c15da26Smrgfunc_convert_path_front_back_pathsep ()
29153c15da26Smrg{
2916300346aeSmrg  $debug_cmd
2917300346aeSmrg
29183c15da26Smrg  case $4 in
2919300346aeSmrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
29203c15da26Smrg    ;;
29213c15da26Smrg  esac
29223c15da26Smrg  case $4 in
29233c15da26Smrg  $2 ) func_append func_to_host_path_result "$3"
29243c15da26Smrg    ;;
29253c15da26Smrg  esac
29263c15da26Smrg}
29273c15da26Smrg# end func_convert_path_front_back_pathsep
29283c15da26Smrg
29293c15da26Smrg
29303c15da26Smrg##################################################
29313c15da26Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
29323c15da26Smrg##################################################
2933300346aeSmrg# invoked via '$to_host_file_cmd ARG'
29343c15da26Smrg#
29353c15da26Smrg# In each case, ARG is the path to be converted from $build to $host format.
29363c15da26Smrg# Result will be available in $func_to_host_file_result.
29373c15da26Smrg
29383c15da26Smrg
29393c15da26Smrg# func_to_host_file ARG
29403c15da26Smrg# Converts the file name ARG from $build format to $host format. Return result
29413c15da26Smrg# in func_to_host_file_result.
29423c15da26Smrgfunc_to_host_file ()
29433c15da26Smrg{
2944300346aeSmrg  $debug_cmd
2945300346aeSmrg
29463c15da26Smrg  $to_host_file_cmd "$1"
29473c15da26Smrg}
29483c15da26Smrg# end func_to_host_file
29493c15da26Smrg
29503c15da26Smrg
29513c15da26Smrg# func_to_tool_file ARG LAZY
29523c15da26Smrg# converts the file name ARG from $build format to toolchain format. Return
29533c15da26Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
29543c15da26Smrg# in (the comma separated) LAZY, no conversion takes place.
29553c15da26Smrgfunc_to_tool_file ()
29563c15da26Smrg{
2957300346aeSmrg  $debug_cmd
2958300346aeSmrg
29593c15da26Smrg  case ,$2, in
29603c15da26Smrg    *,"$to_tool_file_cmd",*)
29613c15da26Smrg      func_to_tool_file_result=$1
29623c15da26Smrg      ;;
29633c15da26Smrg    *)
29643c15da26Smrg      $to_tool_file_cmd "$1"
29653c15da26Smrg      func_to_tool_file_result=$func_to_host_file_result
29663c15da26Smrg      ;;
29673c15da26Smrg  esac
29683c15da26Smrg}
29693c15da26Smrg# end func_to_tool_file
29703c15da26Smrg
29713c15da26Smrg
29723c15da26Smrg# func_convert_file_noop ARG
29733c15da26Smrg# Copy ARG to func_to_host_file_result.
29743c15da26Smrgfunc_convert_file_noop ()
29753c15da26Smrg{
2976300346aeSmrg  func_to_host_file_result=$1
29773c15da26Smrg}
29783c15da26Smrg# end func_convert_file_noop
29793c15da26Smrg
29803c15da26Smrg
29813c15da26Smrg# func_convert_file_msys_to_w32 ARG
29823c15da26Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
29833c15da26Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
29843c15da26Smrg# func_to_host_file_result.
29853c15da26Smrgfunc_convert_file_msys_to_w32 ()
29863c15da26Smrg{
2987300346aeSmrg  $debug_cmd
2988300346aeSmrg
2989300346aeSmrg  func_to_host_file_result=$1
29903c15da26Smrg  if test -n "$1"; then
29913c15da26Smrg    func_convert_core_msys_to_w32 "$1"
2992300346aeSmrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
29933c15da26Smrg  fi
29943c15da26Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
29953c15da26Smrg}
29963c15da26Smrg# end func_convert_file_msys_to_w32
29973c15da26Smrg
29983c15da26Smrg
29993c15da26Smrg# func_convert_file_cygwin_to_w32 ARG
30003c15da26Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
30013c15da26Smrg# func_to_host_file_result.
30023c15da26Smrgfunc_convert_file_cygwin_to_w32 ()
30033c15da26Smrg{
3004300346aeSmrg  $debug_cmd
3005300346aeSmrg
3006300346aeSmrg  func_to_host_file_result=$1
30073c15da26Smrg  if test -n "$1"; then
30083c15da26Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
30093c15da26Smrg    # LT_CYGPATH in this case.
30103c15da26Smrg    func_to_host_file_result=`cygpath -m "$1"`
30113c15da26Smrg  fi
30123c15da26Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
30133c15da26Smrg}
30143c15da26Smrg# end func_convert_file_cygwin_to_w32
30153c15da26Smrg
30163c15da26Smrg
30173c15da26Smrg# func_convert_file_nix_to_w32 ARG
30183c15da26Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
30193c15da26Smrg# and a working winepath. Returns result in func_to_host_file_result.
30203c15da26Smrgfunc_convert_file_nix_to_w32 ()
30213c15da26Smrg{
3022300346aeSmrg  $debug_cmd
3023300346aeSmrg
3024300346aeSmrg  func_to_host_file_result=$1
30253c15da26Smrg  if test -n "$1"; then
30263c15da26Smrg    func_convert_core_file_wine_to_w32 "$1"
3027300346aeSmrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
30283c15da26Smrg  fi
30293c15da26Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
30303c15da26Smrg}
30313c15da26Smrg# end func_convert_file_nix_to_w32
30323c15da26Smrg
30333c15da26Smrg
30343c15da26Smrg# func_convert_file_msys_to_cygwin ARG
30353c15da26Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
30363c15da26Smrg# Returns result in func_to_host_file_result.
30373c15da26Smrgfunc_convert_file_msys_to_cygwin ()
30383c15da26Smrg{
3039300346aeSmrg  $debug_cmd
3040300346aeSmrg
3041300346aeSmrg  func_to_host_file_result=$1
30423c15da26Smrg  if test -n "$1"; then
30433c15da26Smrg    func_convert_core_msys_to_w32 "$1"
30443c15da26Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
3045300346aeSmrg    func_to_host_file_result=$func_cygpath_result
30463c15da26Smrg  fi
30473c15da26Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
30483c15da26Smrg}
30493c15da26Smrg# end func_convert_file_msys_to_cygwin
30503c15da26Smrg
30513c15da26Smrg
30523c15da26Smrg# func_convert_file_nix_to_cygwin ARG
30533c15da26Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
30543c15da26Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
30553c15da26Smrg# in func_to_host_file_result.
30563c15da26Smrgfunc_convert_file_nix_to_cygwin ()
30573c15da26Smrg{
3058300346aeSmrg  $debug_cmd
3059300346aeSmrg
3060300346aeSmrg  func_to_host_file_result=$1
30613c15da26Smrg  if test -n "$1"; then
30623c15da26Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
30633c15da26Smrg    func_convert_core_file_wine_to_w32 "$1"
30643c15da26Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
3065300346aeSmrg    func_to_host_file_result=$func_cygpath_result
30663c15da26Smrg  fi
30673c15da26Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
30683c15da26Smrg}
30693c15da26Smrg# end func_convert_file_nix_to_cygwin
30703c15da26Smrg
30713c15da26Smrg
30723c15da26Smrg#############################################
30733c15da26Smrg# $build to $host PATH CONVERSION FUNCTIONS #
30743c15da26Smrg#############################################
3075300346aeSmrg# invoked via '$to_host_path_cmd ARG'
30763c15da26Smrg#
30773c15da26Smrg# In each case, ARG is the path to be converted from $build to $host format.
30783c15da26Smrg# The result will be available in $func_to_host_path_result.
30793c15da26Smrg#
30803c15da26Smrg# Path separators are also converted from $build format to $host format.  If
30813c15da26Smrg# ARG begins or ends with a path separator character, it is preserved (but
30823c15da26Smrg# converted to $host format) on output.
30833c15da26Smrg#
30843c15da26Smrg# All path conversion functions are named using the following convention:
30853c15da26Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
30863c15da26Smrg#   path conversion function         : func_convert_path_X_to_Y ()
30873c15da26Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
30883c15da26Smrg# same.  If conversion functions are added for new $build/$host combinations,
30893c15da26Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
30903c15da26Smrg# will break.
30913c15da26Smrg
30923c15da26Smrg
30933c15da26Smrg# func_init_to_host_path_cmd
30943c15da26Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
30953c15da26Smrg# appropriate value, based on the value of $to_host_file_cmd.
30963c15da26Smrgto_host_path_cmd=
30973c15da26Smrgfunc_init_to_host_path_cmd ()
30983c15da26Smrg{
3099300346aeSmrg  $debug_cmd
3100300346aeSmrg
31013c15da26Smrg  if test -z "$to_host_path_cmd"; then
31023c15da26Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
3103300346aeSmrg    to_host_path_cmd=func_convert_path_$func_stripname_result
31043c15da26Smrg  fi
31053c15da26Smrg}
31063c15da26Smrg
31073c15da26Smrg
31083c15da26Smrg# func_to_host_path ARG
31093c15da26Smrg# Converts the path ARG from $build format to $host format. Return result
31103c15da26Smrg# in func_to_host_path_result.
31113c15da26Smrgfunc_to_host_path ()
31123c15da26Smrg{
3113300346aeSmrg  $debug_cmd
3114300346aeSmrg
31153c15da26Smrg  func_init_to_host_path_cmd
31163c15da26Smrg  $to_host_path_cmd "$1"
31173c15da26Smrg}
31183c15da26Smrg# end func_to_host_path
31193c15da26Smrg
31203c15da26Smrg
31213c15da26Smrg# func_convert_path_noop ARG
31223c15da26Smrg# Copy ARG to func_to_host_path_result.
31233c15da26Smrgfunc_convert_path_noop ()
31243c15da26Smrg{
3125300346aeSmrg  func_to_host_path_result=$1
31263c15da26Smrg}
31273c15da26Smrg# end func_convert_path_noop
31283c15da26Smrg
31293c15da26Smrg
31303c15da26Smrg# func_convert_path_msys_to_w32 ARG
31313c15da26Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
31323c15da26Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
31333c15da26Smrg# func_to_host_path_result.
31343c15da26Smrgfunc_convert_path_msys_to_w32 ()
3135d656433aSmrg{
3136300346aeSmrg  $debug_cmd
3137300346aeSmrg
3138300346aeSmrg  func_to_host_path_result=$1
31393c15da26Smrg  if test -n "$1"; then
31403c15da26Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
31413c15da26Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
31423c15da26Smrg    # and winepath ignores them completely.
31433c15da26Smrg    func_stripname : : "$1"
31443c15da26Smrg    func_to_host_path_tmp1=$func_stripname_result
31453c15da26Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3146300346aeSmrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
31473c15da26Smrg    func_convert_path_check : ";" \
31483c15da26Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
31493c15da26Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
31503c15da26Smrg  fi
31513c15da26Smrg}
31523c15da26Smrg# end func_convert_path_msys_to_w32
3153d656433aSmrg
3154d656433aSmrg
31553c15da26Smrg# func_convert_path_cygwin_to_w32 ARG
31563c15da26Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
31573c15da26Smrg# func_to_host_file_result.
31583c15da26Smrgfunc_convert_path_cygwin_to_w32 ()
31593c15da26Smrg{
3160300346aeSmrg  $debug_cmd
3161300346aeSmrg
3162300346aeSmrg  func_to_host_path_result=$1
31633c15da26Smrg  if test -n "$1"; then
31643c15da26Smrg    # See func_convert_path_msys_to_w32:
31653c15da26Smrg    func_stripname : : "$1"
31663c15da26Smrg    func_to_host_path_tmp1=$func_stripname_result
31673c15da26Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
31683c15da26Smrg    func_convert_path_check : ";" \
31693c15da26Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
31703c15da26Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
31713c15da26Smrg  fi
31723c15da26Smrg}
31733c15da26Smrg# end func_convert_path_cygwin_to_w32
3174d656433aSmrg
3175d656433aSmrg
31763c15da26Smrg# func_convert_path_nix_to_w32 ARG
31773c15da26Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
31783c15da26Smrg# a working winepath.  Returns result in func_to_host_file_result.
31793c15da26Smrgfunc_convert_path_nix_to_w32 ()
31803c15da26Smrg{
3181300346aeSmrg  $debug_cmd
3182300346aeSmrg
3183300346aeSmrg  func_to_host_path_result=$1
31843c15da26Smrg  if test -n "$1"; then
31853c15da26Smrg    # See func_convert_path_msys_to_w32:
31863c15da26Smrg    func_stripname : : "$1"
31873c15da26Smrg    func_to_host_path_tmp1=$func_stripname_result
31883c15da26Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3189300346aeSmrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
31903c15da26Smrg    func_convert_path_check : ";" \
31913c15da26Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
31923c15da26Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
31933c15da26Smrg  fi
31943c15da26Smrg}
31953c15da26Smrg# end func_convert_path_nix_to_w32
3196d656433aSmrg
31973c15da26Smrg
31983c15da26Smrg# func_convert_path_msys_to_cygwin ARG
31993c15da26Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
32003c15da26Smrg# Returns result in func_to_host_file_result.
32013c15da26Smrgfunc_convert_path_msys_to_cygwin ()
32023c15da26Smrg{
3203300346aeSmrg  $debug_cmd
3204300346aeSmrg
3205300346aeSmrg  func_to_host_path_result=$1
32063c15da26Smrg  if test -n "$1"; then
32073c15da26Smrg    # See func_convert_path_msys_to_w32:
32083c15da26Smrg    func_stripname : : "$1"
32093c15da26Smrg    func_to_host_path_tmp1=$func_stripname_result
32103c15da26Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
32113c15da26Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
3212300346aeSmrg    func_to_host_path_result=$func_cygpath_result
32133c15da26Smrg    func_convert_path_check : : \
32143c15da26Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
32153c15da26Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
32163c15da26Smrg  fi
32173c15da26Smrg}
32183c15da26Smrg# end func_convert_path_msys_to_cygwin
32193c15da26Smrg
32203c15da26Smrg
32213c15da26Smrg# func_convert_path_nix_to_cygwin ARG
32223c15da26Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
32233c15da26Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
32243c15da26Smrg# func_to_host_file_result.
32253c15da26Smrgfunc_convert_path_nix_to_cygwin ()
32263c15da26Smrg{
3227300346aeSmrg  $debug_cmd
3228300346aeSmrg
3229300346aeSmrg  func_to_host_path_result=$1
32303c15da26Smrg  if test -n "$1"; then
32313c15da26Smrg    # Remove leading and trailing path separator characters from
32323c15da26Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
32333c15da26Smrg    # into '.;' and ';.', and winepath ignores them completely.
32343c15da26Smrg    func_stripname : : "$1"
32353c15da26Smrg    func_to_host_path_tmp1=$func_stripname_result
32363c15da26Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
32373c15da26Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
3238300346aeSmrg    func_to_host_path_result=$func_cygpath_result
32393c15da26Smrg    func_convert_path_check : : \
32403c15da26Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
32413c15da26Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
32423c15da26Smrg  fi
3243d656433aSmrg}
32443c15da26Smrg# end func_convert_path_nix_to_cygwin
32453c15da26Smrg
3246d656433aSmrg
3247300346aeSmrg# func_dll_def_p FILE
3248300346aeSmrg# True iff FILE is a Windows DLL '.def' file.
3249300346aeSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
3250300346aeSmrgfunc_dll_def_p ()
3251300346aeSmrg{
3252300346aeSmrg  $debug_cmd
3253300346aeSmrg
3254300346aeSmrg  func_dll_def_p_tmp=`$SED -n \
3255300346aeSmrg    -e 's/^[	 ]*//' \
3256300346aeSmrg    -e '/^\(;.*\)*$/d' \
3257300346aeSmrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
3258300346aeSmrg    -e q \
3259300346aeSmrg    "$1"`
3260300346aeSmrg  test DEF = "$func_dll_def_p_tmp"
3261300346aeSmrg}
3262300346aeSmrg
3263300346aeSmrg
3264d656433aSmrg# func_mode_compile arg...
3265d656433aSmrgfunc_mode_compile ()
3266d656433aSmrg{
3267300346aeSmrg    $debug_cmd
3268300346aeSmrg
3269d656433aSmrg    # Get the compilation command and the source file.
3270d656433aSmrg    base_compile=
3271300346aeSmrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
3272d656433aSmrg    suppress_opt=yes
3273d656433aSmrg    suppress_output=
3274d656433aSmrg    arg_mode=normal
3275d656433aSmrg    libobj=
3276d656433aSmrg    later=
3277d656433aSmrg    pie_flag=
3278d656433aSmrg
3279d656433aSmrg    for arg
3280d656433aSmrg    do
3281d656433aSmrg      case $arg_mode in
3282d656433aSmrg      arg  )
3283d656433aSmrg	# do not "continue".  Instead, add this to base_compile
3284300346aeSmrg	lastarg=$arg
3285d656433aSmrg	arg_mode=normal
3286d656433aSmrg	;;
3287d656433aSmrg
3288d656433aSmrg      target )
3289300346aeSmrg	libobj=$arg
3290d656433aSmrg	arg_mode=normal
3291d656433aSmrg	continue
3292d656433aSmrg	;;
3293d656433aSmrg
3294d656433aSmrg      normal )
3295d656433aSmrg	# Accept any command-line options.
3296d656433aSmrg	case $arg in
3297d656433aSmrg	-o)
3298d656433aSmrg	  test -n "$libobj" && \
3299300346aeSmrg	    func_fatal_error "you cannot specify '-o' more than once"
3300d656433aSmrg	  arg_mode=target
3301d656433aSmrg	  continue
3302d656433aSmrg	  ;;
3303d656433aSmrg
3304d656433aSmrg	-pie | -fpie | -fPIE)
33053c15da26Smrg          func_append pie_flag " $arg"
3306d656433aSmrg	  continue
3307d656433aSmrg	  ;;
3308d656433aSmrg
3309d656433aSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
33103c15da26Smrg	  func_append later " $arg"
3311d656433aSmrg	  continue
3312d656433aSmrg	  ;;
3313d656433aSmrg
3314d656433aSmrg	-no-suppress)
3315d656433aSmrg	  suppress_opt=no
3316d656433aSmrg	  continue
3317d656433aSmrg	  ;;
3318d656433aSmrg
3319d656433aSmrg	-Xcompiler)
3320d656433aSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
3321d656433aSmrg	  continue      #  The current "srcfile" will either be retained or
3322d656433aSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
3323d656433aSmrg
3324d656433aSmrg	-Wc,*)
3325d656433aSmrg	  func_stripname '-Wc,' '' "$arg"
3326d656433aSmrg	  args=$func_stripname_result
3327d656433aSmrg	  lastarg=
3328300346aeSmrg	  save_ifs=$IFS; IFS=,
3329d656433aSmrg	  for arg in $args; do
3330300346aeSmrg	    IFS=$save_ifs
33313c15da26Smrg	    func_append_quoted lastarg "$arg"
3332126a8a12Smrg	  done
3333300346aeSmrg	  IFS=$save_ifs
3334d656433aSmrg	  func_stripname ' ' '' "$lastarg"
3335d656433aSmrg	  lastarg=$func_stripname_result
3336126a8a12Smrg
3337126a8a12Smrg	  # Add the arguments to base_compile.
33383c15da26Smrg	  func_append base_compile " $lastarg"
3339126a8a12Smrg	  continue
3340126a8a12Smrg	  ;;
3341126a8a12Smrg
3342d656433aSmrg	*)
3343126a8a12Smrg	  # Accept the current argument as the source file.
3344126a8a12Smrg	  # The previous "srcfile" becomes the current argument.
3345126a8a12Smrg	  #
3346300346aeSmrg	  lastarg=$srcfile
3347300346aeSmrg	  srcfile=$arg
3348126a8a12Smrg	  ;;
3349126a8a12Smrg	esac  #  case $arg
3350126a8a12Smrg	;;
3351126a8a12Smrg      esac    #  case $arg_mode
3352126a8a12Smrg
3353126a8a12Smrg      # Aesthetically quote the previous argument.
33543c15da26Smrg      func_append_quoted base_compile "$lastarg"
3355126a8a12Smrg    done # for arg
3356126a8a12Smrg
3357126a8a12Smrg    case $arg_mode in
3358126a8a12Smrg    arg)
3359d656433aSmrg      func_fatal_error "you must specify an argument for -Xcompile"
3360126a8a12Smrg      ;;
3361126a8a12Smrg    target)
3362300346aeSmrg      func_fatal_error "you must specify a target with '-o'"
3363126a8a12Smrg      ;;
3364126a8a12Smrg    *)
3365126a8a12Smrg      # Get the name of the library object.
3366d656433aSmrg      test -z "$libobj" && {
3367d656433aSmrg	func_basename "$srcfile"
3368300346aeSmrg	libobj=$func_basename_result
3369d656433aSmrg      }
3370126a8a12Smrg      ;;
3371126a8a12Smrg    esac
3372126a8a12Smrg
3373126a8a12Smrg    # Recognize several different file suffixes.
3374126a8a12Smrg    # If the user specifies -o file.o, it is replaced with file.lo
3375126a8a12Smrg    case $libobj in
3376d656433aSmrg    *.[cCFSifmso] | \
3377d656433aSmrg    *.ada | *.adb | *.ads | *.asm | \
3378d656433aSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
33790a6b08f8Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
3380d656433aSmrg      func_xform "$libobj"
3381d656433aSmrg      libobj=$func_xform_result
3382d656433aSmrg      ;;
3383126a8a12Smrg    esac
3384126a8a12Smrg
3385126a8a12Smrg    case $libobj in
3386d656433aSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3387126a8a12Smrg    *)
3388300346aeSmrg      func_fatal_error "cannot determine name of library object from '$libobj'"
3389126a8a12Smrg      ;;
3390126a8a12Smrg    esac
3391126a8a12Smrg
3392126a8a12Smrg    func_infer_tag $base_compile
3393126a8a12Smrg
3394126a8a12Smrg    for arg in $later; do
3395126a8a12Smrg      case $arg in
3396d656433aSmrg      -shared)
3397300346aeSmrg	test yes = "$build_libtool_libs" \
3398300346aeSmrg	  || func_fatal_configuration "cannot build a shared library"
3399d656433aSmrg	build_old_libs=no
3400d656433aSmrg	continue
3401d656433aSmrg	;;
3402d656433aSmrg
3403126a8a12Smrg      -static)
3404d656433aSmrg	build_libtool_libs=no
3405126a8a12Smrg	build_old_libs=yes
3406126a8a12Smrg	continue
3407126a8a12Smrg	;;
3408126a8a12Smrg
3409126a8a12Smrg      -prefer-pic)
3410126a8a12Smrg	pic_mode=yes
3411126a8a12Smrg	continue
3412126a8a12Smrg	;;
3413126a8a12Smrg
3414126a8a12Smrg      -prefer-non-pic)
3415126a8a12Smrg	pic_mode=no
3416126a8a12Smrg	continue
3417126a8a12Smrg	;;
3418126a8a12Smrg      esac
3419126a8a12Smrg    done
3420126a8a12Smrg
3421d656433aSmrg    func_quote_for_eval "$libobj"
3422d656433aSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
3423d656433aSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
3424300346aeSmrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
3425d656433aSmrg    func_dirname_and_basename "$obj" "/" ""
3426300346aeSmrg    objname=$func_basename_result
3427300346aeSmrg    xdir=$func_dirname_result
3428300346aeSmrg    lobj=$xdir$objdir/$objname
3429126a8a12Smrg
3430d656433aSmrg    test -z "$base_compile" && \
3431d656433aSmrg      func_fatal_help "you must specify a compilation command"
3432126a8a12Smrg
3433126a8a12Smrg    # Delete any leftover library objects.
3434300346aeSmrg    if test yes = "$build_old_libs"; then
3435126a8a12Smrg      removelist="$obj $lobj $libobj ${libobj}T"
3436126a8a12Smrg    else
3437126a8a12Smrg      removelist="$lobj $libobj ${libobj}T"
3438126a8a12Smrg    fi
3439126a8a12Smrg
3440126a8a12Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
3441126a8a12Smrg    case $host_os in
3442d656433aSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
3443126a8a12Smrg      pic_mode=default
3444126a8a12Smrg      ;;
3445126a8a12Smrg    esac
3446300346aeSmrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3447126a8a12Smrg      # non-PIC code in shared libraries is not supported
3448126a8a12Smrg      pic_mode=default
3449126a8a12Smrg    fi
3450126a8a12Smrg
3451126a8a12Smrg    # Calculate the filename of the output object if compiler does
3452126a8a12Smrg    # not support -o with -c
3453300346aeSmrg    if test no = "$compiler_c_o"; then
3454300346aeSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
3455300346aeSmrg      lockfile=$output_obj.lock
3456126a8a12Smrg    else
3457126a8a12Smrg      output_obj=
3458126a8a12Smrg      need_locks=no
3459126a8a12Smrg      lockfile=
3460126a8a12Smrg    fi
3461126a8a12Smrg
3462126a8a12Smrg    # Lock this critical section if it is needed
3463126a8a12Smrg    # We use this script file to make the link, it avoids creating a new file
3464300346aeSmrg    if test yes = "$need_locks"; then
3465d656433aSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3466d656433aSmrg	func_echo "Waiting for $lockfile to be removed"
3467126a8a12Smrg	sleep 2
3468126a8a12Smrg      done
3469300346aeSmrg    elif test warn = "$need_locks"; then
3470126a8a12Smrg      if test -f "$lockfile"; then
3471d656433aSmrg	$ECHO "\
3472126a8a12Smrg*** ERROR, $lockfile exists and contains:
3473126a8a12Smrg`cat $lockfile 2>/dev/null`
3474126a8a12Smrg
3475126a8a12SmrgThis indicates that another process is trying to use the same
3476126a8a12Smrgtemporary object file, and libtool could not work around it because
3477300346aeSmrgyour compiler does not support '-c' and '-o' together.  If you
3478126a8a12Smrgrepeat this compilation, it may succeed, by chance, but you had better
3479126a8a12Smrgavoid parallel builds (make -j) in this platform, or get a better
3480126a8a12Smrgcompiler."
3481126a8a12Smrg
3482d656433aSmrg	$opt_dry_run || $RM $removelist
3483126a8a12Smrg	exit $EXIT_FAILURE
3484126a8a12Smrg      fi
34853c15da26Smrg      func_append removelist " $output_obj"
3486d656433aSmrg      $ECHO "$srcfile" > "$lockfile"
3487126a8a12Smrg    fi
3488126a8a12Smrg
3489d656433aSmrg    $opt_dry_run || $RM $removelist
34903c15da26Smrg    func_append removelist " $lockfile"
3491d656433aSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
3492d656433aSmrg
34933c15da26Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
34943c15da26Smrg    srcfile=$func_to_tool_file_result
3495d656433aSmrg    func_quote_for_eval "$srcfile"
3496d656433aSmrg    qsrcfile=$func_quote_for_eval_result
3497126a8a12Smrg
3498126a8a12Smrg    # Only build a PIC object if we are building libtool libraries.
3499300346aeSmrg    if test yes = "$build_libtool_libs"; then
3500126a8a12Smrg      # Without this assignment, base_compile gets emptied.
3501126a8a12Smrg      fbsd_hideous_sh_bug=$base_compile
3502126a8a12Smrg
3503300346aeSmrg      if test no != "$pic_mode"; then
3504126a8a12Smrg	command="$base_compile $qsrcfile $pic_flag"
3505126a8a12Smrg      else
3506126a8a12Smrg	# Don't build PIC code
3507126a8a12Smrg	command="$base_compile $qsrcfile"
3508126a8a12Smrg      fi
3509126a8a12Smrg
3510d656433aSmrg      func_mkdir_p "$xdir$objdir"
3511126a8a12Smrg
3512126a8a12Smrg      if test -z "$output_obj"; then
3513126a8a12Smrg	# Place PIC objects in $objdir
35143c15da26Smrg	func_append command " -o $lobj"
3515126a8a12Smrg      fi
3516126a8a12Smrg
3517d656433aSmrg      func_show_eval_locale "$command"	\
3518d656433aSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3519126a8a12Smrg
3520300346aeSmrg      if test warn = "$need_locks" &&
3521126a8a12Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3522d656433aSmrg	$ECHO "\
3523126a8a12Smrg*** ERROR, $lockfile contains:
3524126a8a12Smrg`cat $lockfile 2>/dev/null`
3525126a8a12Smrg
3526126a8a12Smrgbut it should contain:
3527126a8a12Smrg$srcfile
3528126a8a12Smrg
3529126a8a12SmrgThis indicates that another process is trying to use the same
3530126a8a12Smrgtemporary object file, and libtool could not work around it because
3531300346aeSmrgyour compiler does not support '-c' and '-o' together.  If you
3532126a8a12Smrgrepeat this compilation, it may succeed, by chance, but you had better
3533126a8a12Smrgavoid parallel builds (make -j) in this platform, or get a better
3534126a8a12Smrgcompiler."
3535126a8a12Smrg
3536d656433aSmrg	$opt_dry_run || $RM $removelist
3537126a8a12Smrg	exit $EXIT_FAILURE
3538126a8a12Smrg      fi
3539126a8a12Smrg
3540126a8a12Smrg      # Just move the object if needed, then go on to compile the next one
3541126a8a12Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
3542d656433aSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
3543d656433aSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3544126a8a12Smrg      fi
3545126a8a12Smrg
3546126a8a12Smrg      # Allow error messages only from the first compilation.
3547300346aeSmrg      if test yes = "$suppress_opt"; then
3548d656433aSmrg	suppress_output=' >/dev/null 2>&1'
3549126a8a12Smrg      fi
3550126a8a12Smrg    fi
3551126a8a12Smrg
3552126a8a12Smrg    # Only build a position-dependent object if we build old libraries.
3553300346aeSmrg    if test yes = "$build_old_libs"; then
3554300346aeSmrg      if test yes != "$pic_mode"; then
3555126a8a12Smrg	# Don't build PIC code
3556d656433aSmrg	command="$base_compile $qsrcfile$pie_flag"
3557126a8a12Smrg      else
3558126a8a12Smrg	command="$base_compile $qsrcfile $pic_flag"
3559126a8a12Smrg      fi
3560300346aeSmrg      if test yes = "$compiler_c_o"; then
35613c15da26Smrg	func_append command " -o $obj"
3562126a8a12Smrg      fi
3563126a8a12Smrg
3564126a8a12Smrg      # Suppress compiler output if we already did a PIC compilation.
35653c15da26Smrg      func_append command "$suppress_output"
3566d656433aSmrg      func_show_eval_locale "$command" \
3567d656433aSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3568126a8a12Smrg
3569300346aeSmrg      if test warn = "$need_locks" &&
3570126a8a12Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3571d656433aSmrg	$ECHO "\
3572126a8a12Smrg*** ERROR, $lockfile contains:
3573126a8a12Smrg`cat $lockfile 2>/dev/null`
3574126a8a12Smrg
3575126a8a12Smrgbut it should contain:
3576126a8a12Smrg$srcfile
3577126a8a12Smrg
3578126a8a12SmrgThis indicates that another process is trying to use the same
3579126a8a12Smrgtemporary object file, and libtool could not work around it because
3580300346aeSmrgyour compiler does not support '-c' and '-o' together.  If you
3581126a8a12Smrgrepeat this compilation, it may succeed, by chance, but you had better
3582126a8a12Smrgavoid parallel builds (make -j) in this platform, or get a better
3583126a8a12Smrgcompiler."
3584126a8a12Smrg
3585d656433aSmrg	$opt_dry_run || $RM $removelist
3586126a8a12Smrg	exit $EXIT_FAILURE
3587126a8a12Smrg      fi
3588126a8a12Smrg
3589126a8a12Smrg      # Just move the object if needed
3590126a8a12Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
3591d656433aSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
3592d656433aSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3593126a8a12Smrg      fi
3594126a8a12Smrg    fi
3595126a8a12Smrg
3596d656433aSmrg    $opt_dry_run || {
3597d656433aSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3598126a8a12Smrg
3599d656433aSmrg      # Unlock the critical section if it was locked
3600300346aeSmrg      if test no != "$need_locks"; then
3601d656433aSmrg	removelist=$lockfile
3602d656433aSmrg        $RM "$lockfile"
3603d656433aSmrg      fi
3604d656433aSmrg    }
3605126a8a12Smrg
3606126a8a12Smrg    exit $EXIT_SUCCESS
3607d656433aSmrg}
3608126a8a12Smrg
3609d656433aSmrg$opt_help || {
3610300346aeSmrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
3611d656433aSmrg}
3612126a8a12Smrg
3613d656433aSmrgfunc_mode_help ()
3614d656433aSmrg{
3615d656433aSmrg    # We need to display help for each of the modes.
36163c15da26Smrg    case $opt_mode in
3617d656433aSmrg      "")
3618d656433aSmrg        # Generic help is extracted from the usage comments
3619d656433aSmrg        # at the start of this file.
3620d656433aSmrg        func_help
3621d656433aSmrg        ;;
3622126a8a12Smrg
3623d656433aSmrg      clean)
3624d656433aSmrg        $ECHO \
3625d656433aSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3626126a8a12Smrg
3627d656433aSmrgRemove files from the build directory.
3628126a8a12Smrg
3629d656433aSmrgRM is the name of the program to use to delete files associated with each FILE
3630300346aeSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
3631d656433aSmrgto RM.
3632126a8a12Smrg
3633d656433aSmrgIf FILE is a libtool library, object or program, all the files associated
3634d656433aSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
3635d656433aSmrg        ;;
3636126a8a12Smrg
3637d656433aSmrg      compile)
3638d656433aSmrg      $ECHO \
3639d656433aSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3640126a8a12Smrg
3641d656433aSmrgCompile a source file into a libtool library object.
3642126a8a12Smrg
3643d656433aSmrgThis mode accepts the following additional options:
3644126a8a12Smrg
3645d656433aSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
3646d656433aSmrg  -no-suppress      do not suppress compiler output for multiple passes
3647555991fdSmrg  -prefer-pic       try to build PIC objects only
3648555991fdSmrg  -prefer-non-pic   try to build non-PIC objects only
3649300346aeSmrg  -shared           do not build a '.o' file suitable for static linking
3650300346aeSmrg  -static           only build a '.o' file suitable for static linking
3651555991fdSmrg  -Wc,FLAG          pass FLAG directly to the compiler
3652126a8a12Smrg
3653300346aeSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
3654d656433aSmrgfrom the given SOURCEFILE.
3655126a8a12Smrg
3656d656433aSmrgThe output file name is determined by removing the directory component from
3657300346aeSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
3658300346aeSmrglibrary object suffix, '.lo'."
3659d656433aSmrg        ;;
3660126a8a12Smrg
3661d656433aSmrg      execute)
3662d656433aSmrg        $ECHO \
3663d656433aSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3664126a8a12Smrg
3665d656433aSmrgAutomatically set library path, then run a program.
3666126a8a12Smrg
3667d656433aSmrgThis mode accepts the following additional options:
3668126a8a12Smrg
3669d656433aSmrg  -dlopen FILE      add the directory containing FILE to the library path
3670126a8a12Smrg
3671300346aeSmrgThis mode sets the library path environment variable according to '-dlopen'
3672d656433aSmrgflags.
3673126a8a12Smrg
3674d656433aSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
3675d656433aSmrginto their corresponding uninstalled binary, and any of their required library
3676d656433aSmrgdirectories are added to the library path.
3677126a8a12Smrg
3678d656433aSmrgThen, COMMAND is executed, with ARGS as arguments."
3679d656433aSmrg        ;;
3680126a8a12Smrg
3681d656433aSmrg      finish)
3682d656433aSmrg        $ECHO \
3683d656433aSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3684126a8a12Smrg
3685d656433aSmrgComplete the installation of libtool libraries.
3686126a8a12Smrg
3687d656433aSmrgEach LIBDIR is a directory that contains libtool libraries.
3688126a8a12Smrg
3689d656433aSmrgThe commands that this mode executes may require superuser privileges.  Use
3690300346aeSmrgthe '--dry-run' option if you just want to see what would be executed."
3691d656433aSmrg        ;;
3692126a8a12Smrg
3693d656433aSmrg      install)
3694d656433aSmrg        $ECHO \
3695d656433aSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3696126a8a12Smrg
3697d656433aSmrgInstall executables or libraries.
3698126a8a12Smrg
3699d656433aSmrgINSTALL-COMMAND is the installation command.  The first component should be
3700300346aeSmrgeither the 'install' or 'cp' program.
3701126a8a12Smrg
3702d656433aSmrgThe following components of INSTALL-COMMAND are treated specially:
3703126a8a12Smrg
3704555991fdSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
3705126a8a12Smrg
3706d656433aSmrgThe rest of the components are interpreted as arguments to that command (only
3707d656433aSmrgBSD-compatible install options are recognized)."
3708d656433aSmrg        ;;
3709126a8a12Smrg
3710d656433aSmrg      link)
3711d656433aSmrg        $ECHO \
3712d656433aSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3713126a8a12Smrg
3714d656433aSmrgLink object files or libraries together to form another library, or to
3715d656433aSmrgcreate an executable program.
3716126a8a12Smrg
3717d656433aSmrgLINK-COMMAND is a command using the C compiler that you would use to create
3718d656433aSmrga program from several object files.
3719126a8a12Smrg
3720d656433aSmrgThe following components of LINK-COMMAND are treated specially:
3721126a8a12Smrg
3722d656433aSmrg  -all-static       do not do any dynamic linking at all
3723d656433aSmrg  -avoid-version    do not add a version suffix if possible
3724555991fdSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
3725555991fdSmrg                    libraries must be found in the PATH setting at runtime)
3726300346aeSmrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
3727d656433aSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
3728d656433aSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3729d656433aSmrg  -export-symbols SYMFILE
3730d656433aSmrg                    try to export only the symbols listed in SYMFILE
3731d656433aSmrg  -export-symbols-regex REGEX
3732d656433aSmrg                    try to export only the symbols matching REGEX
3733d656433aSmrg  -LLIBDIR          search LIBDIR for required installed libraries
3734d656433aSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
3735d656433aSmrg  -module           build a library that can dlopened
3736d656433aSmrg  -no-fast-install  disable the fast-install mode
3737d656433aSmrg  -no-install       link a not-installable executable
3738d656433aSmrg  -no-undefined     declare that a library does not refer to external symbols
3739d656433aSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
3740300346aeSmrg  -objectlist FILE  use a list of object files found in FILE to specify objects
3741300346aeSmrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
3742d656433aSmrg  -precious-files-regex REGEX
3743d656433aSmrg                    don't remove output files matching REGEX
3744d656433aSmrg  -release RELEASE  specify package release information
3745d656433aSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
3746d656433aSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
3747d656433aSmrg  -shared           only do dynamic linking of libtool libraries
3748d656433aSmrg  -shrext SUFFIX    override the standard shared library file extension
3749d656433aSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
3750d656433aSmrg  -static-libtool-libs
3751d656433aSmrg                    do not do any dynamic linking of libtool libraries
3752d656433aSmrg  -version-info CURRENT[:REVISION[:AGE]]
3753d656433aSmrg                    specify library version info [each variable defaults to 0]
3754d656433aSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
3755555991fdSmrg  -Wc,FLAG
3756555991fdSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
3757555991fdSmrg  -Wl,FLAG
3758555991fdSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
3759555991fdSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
3760126a8a12Smrg
3761300346aeSmrgAll other options (arguments beginning with '-') are ignored.
3762126a8a12Smrg
3763300346aeSmrgEvery other argument is treated as a filename.  Files ending in '.la' are
3764d656433aSmrgtreated as uninstalled libtool libraries, other files are standard or library
3765d656433aSmrgobject files.
3766126a8a12Smrg
3767300346aeSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
3768300346aeSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is
3769d656433aSmrgrequired, except when creating a convenience library.
3770126a8a12Smrg
3771300346aeSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
3772300346aeSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
3773126a8a12Smrg
3774300346aeSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
3775d656433aSmrgis created, otherwise an executable program is created."
3776126a8a12Smrg        ;;
3777126a8a12Smrg
3778d656433aSmrg      uninstall)
3779d656433aSmrg        $ECHO \
3780d656433aSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3781126a8a12Smrg
3782d656433aSmrgRemove libraries from an installation directory.
3783126a8a12Smrg
3784d656433aSmrgRM is the name of the program to use to delete files associated with each FILE
3785300346aeSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
3786d656433aSmrgto RM.
3787126a8a12Smrg
3788d656433aSmrgIf FILE is a libtool library, all the files associated with it are deleted.
3789d656433aSmrgOtherwise, only FILE itself is deleted using RM."
3790d656433aSmrg        ;;
3791126a8a12Smrg
3792d656433aSmrg      *)
3793300346aeSmrg        func_fatal_help "invalid operation mode '$opt_mode'"
3794d656433aSmrg        ;;
3795d656433aSmrg    esac
3796126a8a12Smrg
3797555991fdSmrg    echo
3798300346aeSmrg    $ECHO "Try '$progname --help' for more information about other modes."
3799d656433aSmrg}
3800126a8a12Smrg
3801555991fdSmrg# Now that we've collected a possible --mode arg, show help if necessary
3802555991fdSmrgif $opt_help; then
3803300346aeSmrg  if test : = "$opt_help"; then
3804555991fdSmrg    func_mode_help
3805555991fdSmrg  else
3806555991fdSmrg    {
3807555991fdSmrg      func_help noexit
38083c15da26Smrg      for opt_mode in compile link execute install finish uninstall clean; do
3809555991fdSmrg	func_mode_help
3810555991fdSmrg      done
3811300346aeSmrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
3812555991fdSmrg    {
3813555991fdSmrg      func_help noexit
38143c15da26Smrg      for opt_mode in compile link execute install finish uninstall clean; do
3815555991fdSmrg	echo
3816555991fdSmrg	func_mode_help
3817555991fdSmrg      done
3818555991fdSmrg    } |
3819300346aeSmrg    $SED '1d
3820555991fdSmrg      /^When reporting/,/^Report/{
3821555991fdSmrg	H
3822555991fdSmrg	d
3823555991fdSmrg      }
3824555991fdSmrg      $x
3825555991fdSmrg      /information about other modes/d
3826555991fdSmrg      /more detailed .*MODE/d
3827555991fdSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3828555991fdSmrg  fi
3829555991fdSmrg  exit $?
3830555991fdSmrgfi
3831126a8a12Smrg
3832126a8a12Smrg
3833d656433aSmrg# func_mode_execute arg...
3834d656433aSmrgfunc_mode_execute ()
3835d656433aSmrg{
3836300346aeSmrg    $debug_cmd
3837300346aeSmrg
3838d656433aSmrg    # The first argument is the command name.
3839300346aeSmrg    cmd=$nonopt
3840d656433aSmrg    test -z "$cmd" && \
3841d656433aSmrg      func_fatal_help "you must specify a COMMAND"
3842126a8a12Smrg
3843d656433aSmrg    # Handle -dlopen flags immediately.
38443c15da26Smrg    for file in $opt_dlopen; do
3845d656433aSmrg      test -f "$file" \
3846300346aeSmrg	|| func_fatal_help "'$file' is not a file"
3847126a8a12Smrg
3848d656433aSmrg      dir=
3849d656433aSmrg      case $file in
3850d656433aSmrg      *.la)
38513c15da26Smrg	func_resolve_sysroot "$file"
38523c15da26Smrg	file=$func_resolve_sysroot_result
38533c15da26Smrg
3854d656433aSmrg	# Check to see that this really is a libtool archive.
3855d656433aSmrg	func_lalib_unsafe_p "$file" \
3856300346aeSmrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
3857126a8a12Smrg
3858d656433aSmrg	# Read the libtool library.
3859d656433aSmrg	dlname=
3860d656433aSmrg	library_names=
3861d656433aSmrg	func_source "$file"
3862126a8a12Smrg
3863d656433aSmrg	# Skip this library if it cannot be dlopened.
3864d656433aSmrg	if test -z "$dlname"; then
3865d656433aSmrg	  # Warn if it was a shared library.
3866d656433aSmrg	  test -n "$library_names" && \
3867300346aeSmrg	    func_warning "'$file' was not linked with '-export-dynamic'"
3868d656433aSmrg	  continue
3869d656433aSmrg	fi
3870126a8a12Smrg
3871d656433aSmrg	func_dirname "$file" "" "."
3872300346aeSmrg	dir=$func_dirname_result
3873126a8a12Smrg
3874d656433aSmrg	if test -f "$dir/$objdir/$dlname"; then
38753c15da26Smrg	  func_append dir "/$objdir"
3876d656433aSmrg	else
3877d656433aSmrg	  if test ! -f "$dir/$dlname"; then
3878300346aeSmrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
3879d656433aSmrg	  fi
3880d656433aSmrg	fi
3881126a8a12Smrg	;;
3882126a8a12Smrg
3883d656433aSmrg      *.lo)
3884d656433aSmrg	# Just add the directory containing the .lo file.
3885d656433aSmrg	func_dirname "$file" "" "."
3886300346aeSmrg	dir=$func_dirname_result
3887126a8a12Smrg	;;
3888126a8a12Smrg
3889d656433aSmrg      *)
3890300346aeSmrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
3891126a8a12Smrg	continue
3892126a8a12Smrg	;;
3893d656433aSmrg      esac
3894126a8a12Smrg
3895d656433aSmrg      # Get the absolute pathname.
3896d656433aSmrg      absdir=`cd "$dir" && pwd`
3897300346aeSmrg      test -n "$absdir" && dir=$absdir
3898126a8a12Smrg
3899d656433aSmrg      # Now add the directory to shlibpath_var.
3900d656433aSmrg      if eval "test -z \"\$$shlibpath_var\""; then
3901d656433aSmrg	eval "$shlibpath_var=\"\$dir\""
3902d656433aSmrg      else
3903d656433aSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
3904d656433aSmrg      fi
3905d656433aSmrg    done
3906126a8a12Smrg
3907d656433aSmrg    # This variable tells wrapper scripts just to set shlibpath_var
3908d656433aSmrg    # rather than running their programs.
3909300346aeSmrg    libtool_execute_magic=$magic
3910126a8a12Smrg
3911d656433aSmrg    # Check if any of the arguments is a wrapper script.
3912d656433aSmrg    args=
3913d656433aSmrg    for file
3914d656433aSmrg    do
3915d656433aSmrg      case $file in
3916555991fdSmrg      -* | *.la | *.lo ) ;;
3917d656433aSmrg      *)
3918d656433aSmrg	# Do a test to see if this is really a libtool program.
3919d656433aSmrg	if func_ltwrapper_script_p "$file"; then
3920d656433aSmrg	  func_source "$file"
3921d656433aSmrg	  # Transform arg to wrapped name.
3922300346aeSmrg	  file=$progdir/$program
3923d656433aSmrg	elif func_ltwrapper_executable_p "$file"; then
3924d656433aSmrg	  func_ltwrapper_scriptname "$file"
3925d656433aSmrg	  func_source "$func_ltwrapper_scriptname_result"
3926d656433aSmrg	  # Transform arg to wrapped name.
3927300346aeSmrg	  file=$progdir/$program
3928d656433aSmrg	fi
3929d656433aSmrg	;;
3930d656433aSmrg      esac
3931d656433aSmrg      # Quote arguments (to preserve shell metacharacters).
39323c15da26Smrg      func_append_quoted args "$file"
3933d656433aSmrg    done
3934126a8a12Smrg
3935300346aeSmrg    if $opt_dry_run; then
3936300346aeSmrg      # Display what would be done.
3937300346aeSmrg      if test -n "$shlibpath_var"; then
3938300346aeSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
3939300346aeSmrg	echo "export $shlibpath_var"
3940300346aeSmrg      fi
3941300346aeSmrg      $ECHO "$cmd$args"
3942300346aeSmrg      exit $EXIT_SUCCESS
3943300346aeSmrg    else
3944d656433aSmrg      if test -n "$shlibpath_var"; then
3945d656433aSmrg	# Export the shlibpath_var.
3946d656433aSmrg	eval "export $shlibpath_var"
3947d656433aSmrg      fi
3948126a8a12Smrg
3949d656433aSmrg      # Restore saved environment variables
3950d656433aSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
3951d656433aSmrg      do
3952d656433aSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
3953d656433aSmrg                $lt_var=\$save_$lt_var; export $lt_var
3954d656433aSmrg	      else
3955d656433aSmrg		$lt_unset $lt_var
3956d656433aSmrg	      fi"
3957d656433aSmrg      done
3958126a8a12Smrg
3959d656433aSmrg      # Now prepare to actually exec the command.
3960300346aeSmrg      exec_cmd=\$cmd$args
3961d656433aSmrg    fi
3962d656433aSmrg}
3963126a8a12Smrg
3964300346aeSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
3965126a8a12Smrg
3966126a8a12Smrg
3967d656433aSmrg# func_mode_finish arg...
3968d656433aSmrgfunc_mode_finish ()
3969d656433aSmrg{
3970300346aeSmrg    $debug_cmd
3971300346aeSmrg
39723c15da26Smrg    libs=
39733c15da26Smrg    libdirs=
3974d656433aSmrg    admincmds=
3975126a8a12Smrg
39763c15da26Smrg    for opt in "$nonopt" ${1+"$@"}
39773c15da26Smrg    do
39783c15da26Smrg      if test -d "$opt"; then
39793c15da26Smrg	func_append libdirs " $opt"
39803c15da26Smrg
39813c15da26Smrg      elif test -f "$opt"; then
39823c15da26Smrg	if func_lalib_unsafe_p "$opt"; then
39833c15da26Smrg	  func_append libs " $opt"
39843c15da26Smrg	else
3985300346aeSmrg	  func_warning "'$opt' is not a valid libtool archive"
39863c15da26Smrg	fi
39873c15da26Smrg
39883c15da26Smrg      else
3989300346aeSmrg	func_fatal_error "invalid argument '$opt'"
39903c15da26Smrg      fi
39913c15da26Smrg    done
39923c15da26Smrg
39933c15da26Smrg    if test -n "$libs"; then
39943c15da26Smrg      if test -n "$lt_sysroot"; then
39953c15da26Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
39963c15da26Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
39973c15da26Smrg      else
39983c15da26Smrg        sysroot_cmd=
39993c15da26Smrg      fi
40003c15da26Smrg
40013c15da26Smrg      # Remove sysroot references
40023c15da26Smrg      if $opt_dry_run; then
40033c15da26Smrg        for lib in $libs; do
4004300346aeSmrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
40053c15da26Smrg        done
40063c15da26Smrg      else
40073c15da26Smrg        tmpdir=`func_mktempdir`
40083c15da26Smrg        for lib in $libs; do
4009300346aeSmrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
40103c15da26Smrg	    > $tmpdir/tmp-la
40113c15da26Smrg	  mv -f $tmpdir/tmp-la $lib
40123c15da26Smrg	done
40133c15da26Smrg        ${RM}r "$tmpdir"
40143c15da26Smrg      fi
40153c15da26Smrg    fi
4016126a8a12Smrg
40173c15da26Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4018d656433aSmrg      for libdir in $libdirs; do
4019d656433aSmrg	if test -n "$finish_cmds"; then
4020d656433aSmrg	  # Do each command in the finish commands.
4021d656433aSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
4022d656433aSmrg'"$cmd"'"'
4023d656433aSmrg	fi
4024d656433aSmrg	if test -n "$finish_eval"; then
4025d656433aSmrg	  # Do the single finish_eval.
4026d656433aSmrg	  eval cmds=\"$finish_eval\"
40273c15da26Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
4028d656433aSmrg       $cmds"
4029d656433aSmrg	fi
4030d656433aSmrg      done
4031d656433aSmrg    fi
4032126a8a12Smrg
4033d656433aSmrg    # Exit here if they wanted silent mode.
4034300346aeSmrg    $opt_quiet && exit $EXIT_SUCCESS
4035126a8a12Smrg
40363c15da26Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
40373c15da26Smrg      echo "----------------------------------------------------------------------"
40383c15da26Smrg      echo "Libraries have been installed in:"
40393c15da26Smrg      for libdir in $libdirs; do
40403c15da26Smrg	$ECHO "   $libdir"
40413c15da26Smrg      done
40423c15da26Smrg      echo
40433c15da26Smrg      echo "If you ever happen to want to link against installed libraries"
40443c15da26Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
4045300346aeSmrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
40463c15da26Smrg      echo "flag during linking and do at least one of the following:"
40473c15da26Smrg      if test -n "$shlibpath_var"; then
4048300346aeSmrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
40493c15da26Smrg	echo "     during execution"
40503c15da26Smrg      fi
40513c15da26Smrg      if test -n "$runpath_var"; then
4052300346aeSmrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
40533c15da26Smrg	echo "     during linking"
40543c15da26Smrg      fi
40553c15da26Smrg      if test -n "$hardcode_libdir_flag_spec"; then
40563c15da26Smrg	libdir=LIBDIR
40573c15da26Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
4058126a8a12Smrg
4059300346aeSmrg	$ECHO "   - use the '$flag' linker flag"
40603c15da26Smrg      fi
40613c15da26Smrg      if test -n "$admincmds"; then
40623c15da26Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
40633c15da26Smrg      fi
40643c15da26Smrg      if test -f /etc/ld.so.conf; then
4065300346aeSmrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
40663c15da26Smrg      fi
40673c15da26Smrg      echo
4068126a8a12Smrg
40693c15da26Smrg      echo "See any operating system documentation about shared libraries for"
40703c15da26Smrg      case $host in
40713c15da26Smrg	solaris2.[6789]|solaris2.1[0-9])
40723c15da26Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
40733c15da26Smrg	  echo "pages."
40743c15da26Smrg	  ;;
40753c15da26Smrg	*)
40763c15da26Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
40773c15da26Smrg	  ;;
40783c15da26Smrg      esac
40793c15da26Smrg      echo "----------------------------------------------------------------------"
40803c15da26Smrg    fi
4081d656433aSmrg    exit $EXIT_SUCCESS
4082d656433aSmrg}
4083126a8a12Smrg
4084300346aeSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
4085126a8a12Smrg
4086126a8a12Smrg
4087d656433aSmrg# func_mode_install arg...
4088d656433aSmrgfunc_mode_install ()
4089d656433aSmrg{
4090300346aeSmrg    $debug_cmd
4091300346aeSmrg
4092d656433aSmrg    # There may be an optional sh(1) argument at the beginning of
4093d656433aSmrg    # install_prog (especially on Windows NT).
4094300346aeSmrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
4095d656433aSmrg       # Allow the use of GNU shtool's install command.
4096300346aeSmrg       case $nonopt in *shtool*) :;; *) false;; esac
4097300346aeSmrg    then
4098d656433aSmrg      # Aesthetically quote it.
4099d656433aSmrg      func_quote_for_eval "$nonopt"
4100d656433aSmrg      install_prog="$func_quote_for_eval_result "
4101d656433aSmrg      arg=$1
4102d656433aSmrg      shift
4103d656433aSmrg    else
4104d656433aSmrg      install_prog=
4105d656433aSmrg      arg=$nonopt
4106d656433aSmrg    fi
4107126a8a12Smrg
4108d656433aSmrg    # The real first argument should be the name of the installation program.
4109d656433aSmrg    # Aesthetically quote it.
4110d656433aSmrg    func_quote_for_eval "$arg"
41113c15da26Smrg    func_append install_prog "$func_quote_for_eval_result"
4112555991fdSmrg    install_shared_prog=$install_prog
4113555991fdSmrg    case " $install_prog " in
4114555991fdSmrg      *[\\\ /]cp\ *) install_cp=: ;;
4115555991fdSmrg      *) install_cp=false ;;
4116555991fdSmrg    esac
4117d656433aSmrg
4118d656433aSmrg    # We need to accept at least all the BSD install flags.
4119d656433aSmrg    dest=
4120d656433aSmrg    files=
4121d656433aSmrg    opts=
4122d656433aSmrg    prev=
4123d656433aSmrg    install_type=
4124300346aeSmrg    isdir=false
4125d656433aSmrg    stripme=
4126555991fdSmrg    no_mode=:
4127d656433aSmrg    for arg
4128d656433aSmrg    do
4129555991fdSmrg      arg2=
4130d656433aSmrg      if test -n "$dest"; then
41313c15da26Smrg	func_append files " $dest"
4132d656433aSmrg	dest=$arg
4133d656433aSmrg	continue
4134126a8a12Smrg      fi
4135126a8a12Smrg
4136d656433aSmrg      case $arg in
4137300346aeSmrg      -d) isdir=: ;;
4138d656433aSmrg      -f)
4139555991fdSmrg	if $install_cp; then :; else
4140555991fdSmrg	  prev=$arg
4141555991fdSmrg	fi
4142d656433aSmrg	;;
4143d656433aSmrg      -g | -m | -o)
4144d656433aSmrg	prev=$arg
4145d656433aSmrg	;;
4146d656433aSmrg      -s)
4147d656433aSmrg	stripme=" -s"
4148d656433aSmrg	continue
4149d656433aSmrg	;;
4150d656433aSmrg      -*)
4151d656433aSmrg	;;
4152d656433aSmrg      *)
4153d656433aSmrg	# If the previous option needed an argument, then skip it.
4154d656433aSmrg	if test -n "$prev"; then
4155300346aeSmrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
4156555991fdSmrg	    arg2=$install_override_mode
4157555991fdSmrg	    no_mode=false
4158555991fdSmrg	  fi
4159d656433aSmrg	  prev=
4160d656433aSmrg	else
4161d656433aSmrg	  dest=$arg
4162d656433aSmrg	  continue
4163d656433aSmrg	fi
4164d656433aSmrg	;;
4165d656433aSmrg      esac
4166126a8a12Smrg
4167d656433aSmrg      # Aesthetically quote the argument.
4168d656433aSmrg      func_quote_for_eval "$arg"
41693c15da26Smrg      func_append install_prog " $func_quote_for_eval_result"
4170555991fdSmrg      if test -n "$arg2"; then
4171555991fdSmrg	func_quote_for_eval "$arg2"
4172555991fdSmrg      fi
41733c15da26Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
4174d656433aSmrg    done
4175126a8a12Smrg
4176d656433aSmrg    test -z "$install_prog" && \
4177d656433aSmrg      func_fatal_help "you must specify an install program"
4178126a8a12Smrg
4179d656433aSmrg    test -n "$prev" && \
4180300346aeSmrg      func_fatal_help "the '$prev' option requires an argument"
4181126a8a12Smrg
4182555991fdSmrg    if test -n "$install_override_mode" && $no_mode; then
4183555991fdSmrg      if $install_cp; then :; else
4184555991fdSmrg	func_quote_for_eval "$install_override_mode"
41853c15da26Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
4186555991fdSmrg      fi
4187555991fdSmrg    fi
4188555991fdSmrg
4189d656433aSmrg    if test -z "$files"; then
4190d656433aSmrg      if test -z "$dest"; then
4191d656433aSmrg	func_fatal_help "no file or destination specified"
4192d656433aSmrg      else
4193d656433aSmrg	func_fatal_help "you must specify a destination"
4194126a8a12Smrg      fi
4195126a8a12Smrg    fi
4196126a8a12Smrg
4197d656433aSmrg    # Strip any trailing slash from the destination.
4198d656433aSmrg    func_stripname '' '/' "$dest"
4199d656433aSmrg    dest=$func_stripname_result
4200126a8a12Smrg
4201d656433aSmrg    # Check to see that the destination is a directory.
4202300346aeSmrg    test -d "$dest" && isdir=:
4203300346aeSmrg    if $isdir; then
4204300346aeSmrg      destdir=$dest
4205d656433aSmrg      destname=
4206d656433aSmrg    else
4207d656433aSmrg      func_dirname_and_basename "$dest" "" "."
4208300346aeSmrg      destdir=$func_dirname_result
4209300346aeSmrg      destname=$func_basename_result
4210d656433aSmrg
4211d656433aSmrg      # Not a directory, so check to see that there is only one file specified.
4212d656433aSmrg      set dummy $files; shift
4213d656433aSmrg      test "$#" -gt 1 && \
4214300346aeSmrg	func_fatal_help "'$dest' is not a directory"
4215d656433aSmrg    fi
4216d656433aSmrg    case $destdir in
4217d656433aSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
4218126a8a12Smrg    *)
4219d656433aSmrg      for file in $files; do
4220d656433aSmrg	case $file in
4221d656433aSmrg	*.lo) ;;
4222d656433aSmrg	*)
4223300346aeSmrg	  func_fatal_help "'$destdir' must be an absolute directory name"
4224d656433aSmrg	  ;;
4225d656433aSmrg	esac
4226d656433aSmrg      done
4227126a8a12Smrg      ;;
4228126a8a12Smrg    esac
4229126a8a12Smrg
4230d656433aSmrg    # This variable tells wrapper scripts just to set variables rather
4231d656433aSmrg    # than running their programs.
4232300346aeSmrg    libtool_install_magic=$magic
4233126a8a12Smrg
4234d656433aSmrg    staticlibs=
4235d656433aSmrg    future_libdirs=
4236d656433aSmrg    current_libdirs=
4237d656433aSmrg    for file in $files; do
4238126a8a12Smrg
4239d656433aSmrg      # Do each installation.
4240d656433aSmrg      case $file in
4241d656433aSmrg      *.$libext)
4242d656433aSmrg	# Do the static libraries later.
42433c15da26Smrg	func_append staticlibs " $file"
4244d656433aSmrg	;;
4245d656433aSmrg
4246d656433aSmrg      *.la)
42473c15da26Smrg	func_resolve_sysroot "$file"
42483c15da26Smrg	file=$func_resolve_sysroot_result
42493c15da26Smrg
4250d656433aSmrg	# Check to see that this really is a libtool archive.
4251d656433aSmrg	func_lalib_unsafe_p "$file" \
4252300346aeSmrg	  || func_fatal_help "'$file' is not a valid libtool archive"
4253d656433aSmrg
4254d656433aSmrg	library_names=
4255d656433aSmrg	old_library=
4256d656433aSmrg	relink_command=
4257d656433aSmrg	func_source "$file"
4258d656433aSmrg
4259d656433aSmrg	# Add the libdir to current_libdirs if it is the destination.
4260d656433aSmrg	if test "X$destdir" = "X$libdir"; then
4261d656433aSmrg	  case "$current_libdirs " in
4262d656433aSmrg	  *" $libdir "*) ;;
42633c15da26Smrg	  *) func_append current_libdirs " $libdir" ;;
4264126a8a12Smrg	  esac
4265d656433aSmrg	else
4266d656433aSmrg	  # Note the libdir as a future libdir.
4267d656433aSmrg	  case "$future_libdirs " in
4268d656433aSmrg	  *" $libdir "*) ;;
42693c15da26Smrg	  *) func_append future_libdirs " $libdir" ;;
4270d656433aSmrg	  esac
4271d656433aSmrg	fi
4272126a8a12Smrg
4273d656433aSmrg	func_dirname "$file" "/" ""
4274300346aeSmrg	dir=$func_dirname_result
42753c15da26Smrg	func_append dir "$objdir"
4276d656433aSmrg
4277d656433aSmrg	if test -n "$relink_command"; then
4278d656433aSmrg	  # Determine the prefix the user has applied to our future dir.
4279555991fdSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
4280d656433aSmrg
4281d656433aSmrg	  # Don't allow the user to place us outside of our expected
4282d656433aSmrg	  # location b/c this prevents finding dependent libraries that
4283d656433aSmrg	  # are installed to the same prefix.
4284d656433aSmrg	  # At present, this check doesn't affect windows .dll's that
4285d656433aSmrg	  # are installed into $libdir/../bin (currently, that works fine)
4286d656433aSmrg	  # but it's something to keep an eye on.
4287d656433aSmrg	  test "$inst_prefix_dir" = "$destdir" && \
4288300346aeSmrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
4289d656433aSmrg
4290d656433aSmrg	  if test -n "$inst_prefix_dir"; then
4291d656433aSmrg	    # Stick the inst_prefix_dir data into the link command.
4292555991fdSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
4293d656433aSmrg	  else
4294555991fdSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
4295d656433aSmrg	  fi
4296d656433aSmrg
4297300346aeSmrg	  func_warning "relinking '$file'"
4298d656433aSmrg	  func_show_eval "$relink_command" \
4299300346aeSmrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
4300d656433aSmrg	fi
4301d656433aSmrg
4302d656433aSmrg	# See the names of the shared library.
4303d656433aSmrg	set dummy $library_names; shift
4304d656433aSmrg	if test -n "$1"; then
4305300346aeSmrg	  realname=$1
4306d656433aSmrg	  shift
4307d656433aSmrg
4308300346aeSmrg	  srcname=$realname
4309300346aeSmrg	  test -n "$relink_command" && srcname=${realname}T
4310d656433aSmrg
4311d656433aSmrg	  # Install the shared library and build the symlinks.
4312555991fdSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
4313d656433aSmrg	      'exit $?'
4314300346aeSmrg	  tstripme=$stripme
4315d656433aSmrg	  case $host_os in
4316d656433aSmrg	  cygwin* | mingw* | pw32* | cegcc*)
4317d656433aSmrg	    case $realname in
4318d656433aSmrg	    *.dll.a)
4319300346aeSmrg	      tstripme=
4320300346aeSmrg	      ;;
4321300346aeSmrg	    esac
4322300346aeSmrg	    ;;
4323300346aeSmrg	  os2*)
4324300346aeSmrg	    case $realname in
4325300346aeSmrg	    *_dll.a)
4326300346aeSmrg	      tstripme=
4327d656433aSmrg	      ;;
4328d656433aSmrg	    esac
4329126a8a12Smrg	    ;;
4330126a8a12Smrg	  esac
4331d656433aSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
4332d656433aSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
4333126a8a12Smrg	  fi
4334d656433aSmrg
4335d656433aSmrg	  if test "$#" -gt 0; then
4336d656433aSmrg	    # Delete the old symlinks, and create new ones.
4337300346aeSmrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
4338d656433aSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
4339d656433aSmrg	    # so we also need to try rm && ln -s.
4340d656433aSmrg	    for linkname
4341d656433aSmrg	    do
4342d656433aSmrg	      test "$linkname" != "$realname" \
4343d656433aSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4344126a8a12Smrg	    done
4345126a8a12Smrg	  fi
4346126a8a12Smrg
4347d656433aSmrg	  # Do each command in the postinstall commands.
4348300346aeSmrg	  lib=$destdir/$realname
4349d656433aSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
4350126a8a12Smrg	fi
4351126a8a12Smrg
4352d656433aSmrg	# Install the pseudo-library for information purposes.
4353d656433aSmrg	func_basename "$file"
4354300346aeSmrg	name=$func_basename_result
4355300346aeSmrg	instname=$dir/${name}i
4356d656433aSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4357126a8a12Smrg
4358d656433aSmrg	# Maybe install the static library, too.
43593c15da26Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
4360d656433aSmrg	;;
4361126a8a12Smrg
4362d656433aSmrg      *.lo)
4363d656433aSmrg	# Install (i.e. copy) a libtool object.
4364126a8a12Smrg
4365d656433aSmrg	# Figure out destination file name, if it wasn't already specified.
4366d656433aSmrg	if test -n "$destname"; then
4367300346aeSmrg	  destfile=$destdir/$destname
4368d656433aSmrg	else
4369d656433aSmrg	  func_basename "$file"
4370300346aeSmrg	  destfile=$func_basename_result
4371300346aeSmrg	  destfile=$destdir/$destfile
4372d656433aSmrg	fi
4373d656433aSmrg
4374d656433aSmrg	# Deduce the name of the destination old-style object file.
4375d656433aSmrg	case $destfile in
4376d656433aSmrg	*.lo)
4377d656433aSmrg	  func_lo2o "$destfile"
4378d656433aSmrg	  staticdest=$func_lo2o_result
4379d656433aSmrg	  ;;
4380d656433aSmrg	*.$objext)
4381300346aeSmrg	  staticdest=$destfile
4382d656433aSmrg	  destfile=
4383d656433aSmrg	  ;;
4384d656433aSmrg	*)
4385300346aeSmrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
4386d656433aSmrg	  ;;
4387126a8a12Smrg	esac
4388126a8a12Smrg
4389d656433aSmrg	# Install the libtool object if requested.
4390d656433aSmrg	test -n "$destfile" && \
4391d656433aSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
4392d656433aSmrg
4393d656433aSmrg	# Install the old object if enabled.
4394300346aeSmrg	if test yes = "$build_old_libs"; then
4395d656433aSmrg	  # Deduce the name of the old-style object file.
4396d656433aSmrg	  func_lo2o "$file"
4397d656433aSmrg	  staticobj=$func_lo2o_result
4398d656433aSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4399126a8a12Smrg	fi
4400d656433aSmrg	exit $EXIT_SUCCESS
4401d656433aSmrg	;;
4402126a8a12Smrg
4403d656433aSmrg      *)
4404d656433aSmrg	# Figure out destination file name, if it wasn't already specified.
4405d656433aSmrg	if test -n "$destname"; then
4406300346aeSmrg	  destfile=$destdir/$destname
4407d656433aSmrg	else
4408d656433aSmrg	  func_basename "$file"
4409300346aeSmrg	  destfile=$func_basename_result
4410300346aeSmrg	  destfile=$destdir/$destfile
4411d656433aSmrg	fi
4412d656433aSmrg
4413d656433aSmrg	# If the file is missing, and there is a .exe on the end, strip it
4414d656433aSmrg	# because it is most likely a libtool script we actually want to
4415d656433aSmrg	# install
4416300346aeSmrg	stripped_ext=
4417d656433aSmrg	case $file in
4418d656433aSmrg	  *.exe)
4419d656433aSmrg	    if test ! -f "$file"; then
4420d656433aSmrg	      func_stripname '' '.exe' "$file"
4421d656433aSmrg	      file=$func_stripname_result
4422300346aeSmrg	      stripped_ext=.exe
4423126a8a12Smrg	    fi
4424d656433aSmrg	    ;;
4425d656433aSmrg	esac
4426126a8a12Smrg
4427d656433aSmrg	# Do a test to see if this is really a libtool program.
4428d656433aSmrg	case $host in
4429d656433aSmrg	*cygwin* | *mingw*)
4430d656433aSmrg	    if func_ltwrapper_executable_p "$file"; then
4431d656433aSmrg	      func_ltwrapper_scriptname "$file"
4432d656433aSmrg	      wrapper=$func_ltwrapper_scriptname_result
4433d656433aSmrg	    else
4434d656433aSmrg	      func_stripname '' '.exe' "$file"
4435d656433aSmrg	      wrapper=$func_stripname_result
4436d656433aSmrg	    fi
4437d656433aSmrg	    ;;
4438d656433aSmrg	*)
4439d656433aSmrg	    wrapper=$file
4440d656433aSmrg	    ;;
4441d656433aSmrg	esac
4442d656433aSmrg	if func_ltwrapper_script_p "$wrapper"; then
4443d656433aSmrg	  notinst_deplibs=
4444d656433aSmrg	  relink_command=
4445126a8a12Smrg
4446d656433aSmrg	  func_source "$wrapper"
4447126a8a12Smrg
4448d656433aSmrg	  # Check the variables that should have been set.
4449d656433aSmrg	  test -z "$generated_by_libtool_version" && \
4450300346aeSmrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
4451d656433aSmrg
4452300346aeSmrg	  finalize=:
4453d656433aSmrg	  for lib in $notinst_deplibs; do
4454d656433aSmrg	    # Check to see that each library is installed.
4455d656433aSmrg	    libdir=
4456d656433aSmrg	    if test -f "$lib"; then
4457d656433aSmrg	      func_source "$lib"
4458d656433aSmrg	    fi
4459300346aeSmrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
4460d656433aSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
4461300346aeSmrg	      func_warning "'$lib' has not been installed in '$libdir'"
4462300346aeSmrg	      finalize=false
4463d656433aSmrg	    fi
4464d656433aSmrg	  done
4465d656433aSmrg
4466d656433aSmrg	  relink_command=
4467d656433aSmrg	  func_source "$wrapper"
4468d656433aSmrg
4469d656433aSmrg	  outputname=
4470300346aeSmrg	  if test no = "$fast_install" && test -n "$relink_command"; then
4471d656433aSmrg	    $opt_dry_run || {
4472300346aeSmrg	      if $finalize; then
4473d656433aSmrg	        tmpdir=`func_mktempdir`
4474d656433aSmrg		func_basename "$file$stripped_ext"
4475300346aeSmrg		file=$func_basename_result
4476300346aeSmrg	        outputname=$tmpdir/$file
4477d656433aSmrg	        # Replace the output file specification.
4478555991fdSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
4479d656433aSmrg
4480300346aeSmrg	        $opt_quiet || {
4481d656433aSmrg	          func_quote_for_expand "$relink_command"
4482d656433aSmrg		  eval "func_echo $func_quote_for_expand_result"
4483d656433aSmrg	        }
4484d656433aSmrg	        if eval "$relink_command"; then :
4485d656433aSmrg	          else
4486300346aeSmrg		  func_error "error: relink '$file' with the above command before installing it"
4487d656433aSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
4488d656433aSmrg		  continue
4489d656433aSmrg	        fi
4490300346aeSmrg	        file=$outputname
4491d656433aSmrg	      else
4492300346aeSmrg	        func_warning "cannot relink '$file'"
4493d656433aSmrg	      fi
4494d656433aSmrg	    }
4495126a8a12Smrg	  else
4496d656433aSmrg	    # Install the binary that we compiled earlier.
4497555991fdSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4498126a8a12Smrg	  fi
4499d656433aSmrg	fi
4500126a8a12Smrg
4501d656433aSmrg	# remove .exe since cygwin /usr/bin/install will append another
4502d656433aSmrg	# one anyway
4503d656433aSmrg	case $install_prog,$host in
4504d656433aSmrg	*/usr/bin/install*,*cygwin*)
4505d656433aSmrg	  case $file:$destfile in
4506d656433aSmrg	  *.exe:*.exe)
4507d656433aSmrg	    # this is ok
4508d656433aSmrg	    ;;
4509d656433aSmrg	  *.exe:*)
4510d656433aSmrg	    destfile=$destfile.exe
4511d656433aSmrg	    ;;
4512d656433aSmrg	  *:*.exe)
4513d656433aSmrg	    func_stripname '' '.exe' "$destfile"
4514d656433aSmrg	    destfile=$func_stripname_result
4515d656433aSmrg	    ;;
4516d656433aSmrg	  esac
4517126a8a12Smrg	  ;;
4518126a8a12Smrg	esac
4519d656433aSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
4520d656433aSmrg	$opt_dry_run || if test -n "$outputname"; then
4521d656433aSmrg	  ${RM}r "$tmpdir"
4522d656433aSmrg	fi
4523d656433aSmrg	;;
4524d656433aSmrg      esac
4525d656433aSmrg    done
4526126a8a12Smrg
4527d656433aSmrg    for file in $staticlibs; do
4528d656433aSmrg      func_basename "$file"
4529300346aeSmrg      name=$func_basename_result
4530126a8a12Smrg
4531d656433aSmrg      # Set up the ranlib parameters.
4532300346aeSmrg      oldlib=$destdir/$name
45330a6b08f8Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
45340a6b08f8Smrg      tool_oldlib=$func_to_tool_file_result
4535126a8a12Smrg
4536d656433aSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
4537126a8a12Smrg
4538d656433aSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
45390a6b08f8Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
4540d656433aSmrg      fi
4541126a8a12Smrg
4542d656433aSmrg      # Do each command in the postinstall commands.
4543d656433aSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
4544d656433aSmrg    done
4545126a8a12Smrg
4546d656433aSmrg    test -n "$future_libdirs" && \
4547300346aeSmrg      func_warning "remember to run '$progname --finish$future_libdirs'"
4548126a8a12Smrg
4549d656433aSmrg    if test -n "$current_libdirs"; then
4550d656433aSmrg      # Maybe just do a dry run.
4551d656433aSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
4552300346aeSmrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
4553d656433aSmrg    else
4554d656433aSmrg      exit $EXIT_SUCCESS
4555d656433aSmrg    fi
4556d656433aSmrg}
4557126a8a12Smrg
4558300346aeSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
4559126a8a12Smrg
4560126a8a12Smrg
4561d656433aSmrg# func_generate_dlsyms outputname originator pic_p
4562d656433aSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
4563d656433aSmrg# a dlpreopen symbol table.
4564d656433aSmrgfunc_generate_dlsyms ()
4565d656433aSmrg{
4566300346aeSmrg    $debug_cmd
4567300346aeSmrg
4568300346aeSmrg    my_outputname=$1
4569300346aeSmrg    my_originator=$2
4570300346aeSmrg    my_pic_p=${3-false}
4571300346aeSmrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
4572d656433aSmrg    my_dlsyms=
4573d656433aSmrg
4574300346aeSmrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
4575d656433aSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
4576300346aeSmrg	my_dlsyms=${my_outputname}S.c
4577d656433aSmrg      else
4578d656433aSmrg	func_error "not configured to extract global symbols from dlpreopened files"
4579d656433aSmrg      fi
4580d656433aSmrg    fi
4581126a8a12Smrg
4582d656433aSmrg    if test -n "$my_dlsyms"; then
4583d656433aSmrg      case $my_dlsyms in
4584d656433aSmrg      "") ;;
4585d656433aSmrg      *.c)
4586d656433aSmrg	# Discover the nlist of each of the dlfiles.
4587300346aeSmrg	nlist=$output_objdir/$my_outputname.nm
4588d656433aSmrg
4589d656433aSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
4590d656433aSmrg
4591d656433aSmrg	# Parse the name list into a source file.
4592d656433aSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
4593d656433aSmrg
4594d656433aSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
4595300346aeSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
4596300346aeSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
4597d656433aSmrg
4598d656433aSmrg#ifdef __cplusplus
4599d656433aSmrgextern \"C\" {
4600d656433aSmrg#endif
4601d656433aSmrg
4602300346aeSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4603555991fdSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4604555991fdSmrg#endif
4605555991fdSmrg
46063c15da26Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
4607300346aeSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
4608300346aeSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
46093c15da26Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
46103c15da26Smrg# define LT_DLSYM_CONST
4611300346aeSmrg#elif defined __osf__
46123c15da26Smrg/* This system does not cope well with relocations in const data.  */
46133c15da26Smrg# define LT_DLSYM_CONST
46143c15da26Smrg#else
46153c15da26Smrg# define LT_DLSYM_CONST const
46163c15da26Smrg#endif
46173c15da26Smrg
4618300346aeSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
4619300346aeSmrg
4620d656433aSmrg/* External symbol declarations for the compiler. */\
4621d656433aSmrg"
4622d656433aSmrg
4623300346aeSmrg	if test yes = "$dlself"; then
4624300346aeSmrg	  func_verbose "generating symbol list for '$output'"
4625d656433aSmrg
4626d656433aSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
4627d656433aSmrg
4628d656433aSmrg	  # Add our own program objects to the symbol list.
4629555991fdSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
4630d656433aSmrg	  for progfile in $progfiles; do
46313c15da26Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
4632300346aeSmrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
46333c15da26Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
4634d656433aSmrg	  done
4635d656433aSmrg
4636d656433aSmrg	  if test -n "$exclude_expsyms"; then
4637d656433aSmrg	    $opt_dry_run || {
4638d656433aSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4639d656433aSmrg	      eval '$MV "$nlist"T "$nlist"'
4640d656433aSmrg	    }
4641126a8a12Smrg	  fi
4642126a8a12Smrg
4643d656433aSmrg	  if test -n "$export_symbols_regex"; then
4644d656433aSmrg	    $opt_dry_run || {
4645d656433aSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4646d656433aSmrg	      eval '$MV "$nlist"T "$nlist"'
4647d656433aSmrg	    }
4648126a8a12Smrg	  fi
4649d656433aSmrg
4650d656433aSmrg	  # Prepare the list of exported symbols
4651d656433aSmrg	  if test -z "$export_symbols"; then
4652300346aeSmrg	    export_symbols=$output_objdir/$outputname.exp
4653d656433aSmrg	    $opt_dry_run || {
4654d656433aSmrg	      $RM $export_symbols
4655300346aeSmrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4656d656433aSmrg	      case $host in
4657d656433aSmrg	      *cygwin* | *mingw* | *cegcc* )
4658d656433aSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4659d656433aSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4660d656433aSmrg	        ;;
4661126a8a12Smrg	      esac
4662d656433aSmrg	    }
4663d656433aSmrg	  else
4664d656433aSmrg	    $opt_dry_run || {
4665300346aeSmrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4666d656433aSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4667d656433aSmrg	      eval '$MV "$nlist"T "$nlist"'
4668d656433aSmrg	      case $host in
4669555991fdSmrg	        *cygwin* | *mingw* | *cegcc* )
4670d656433aSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4671d656433aSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4672d656433aSmrg	          ;;
4673126a8a12Smrg	      esac
4674d656433aSmrg	    }
4675126a8a12Smrg	  fi
4676d656433aSmrg	fi
4677126a8a12Smrg
4678d656433aSmrg	for dlprefile in $dlprefiles; do
4679300346aeSmrg	  func_verbose "extracting global C symbols from '$dlprefile'"
4680d656433aSmrg	  func_basename "$dlprefile"
4681300346aeSmrg	  name=$func_basename_result
46823c15da26Smrg          case $host in
46833c15da26Smrg	    *cygwin* | *mingw* | *cegcc* )
46843c15da26Smrg	      # if an import library, we need to obtain dlname
46853c15da26Smrg	      if func_win32_import_lib_p "$dlprefile"; then
46863c15da26Smrg	        func_tr_sh "$dlprefile"
46873c15da26Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
4688300346aeSmrg	        dlprefile_dlbasename=
46893c15da26Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
46903c15da26Smrg	          # Use subshell, to avoid clobbering current variable values
46913c15da26Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
4692300346aeSmrg	          if test -n "$dlprefile_dlname"; then
46933c15da26Smrg	            func_basename "$dlprefile_dlname"
4694300346aeSmrg	            dlprefile_dlbasename=$func_basename_result
46953c15da26Smrg	          else
46963c15da26Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
46973c15da26Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
46983c15da26Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
46993c15da26Smrg	          fi
47003c15da26Smrg	        fi
47013c15da26Smrg	        $opt_dry_run || {
4702300346aeSmrg	          if test -n "$dlprefile_dlbasename"; then
47033c15da26Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
47043c15da26Smrg	          else
47053c15da26Smrg	            func_warning "Could not compute DLL name from $name"
47063c15da26Smrg	            eval '$ECHO ": $name " >> "$nlist"'
47073c15da26Smrg	          fi
47083c15da26Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
47093c15da26Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
47103c15da26Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
47113c15da26Smrg	        }
47123c15da26Smrg	      else # not an import lib
47133c15da26Smrg	        $opt_dry_run || {
47143c15da26Smrg	          eval '$ECHO ": $name " >> "$nlist"'
47153c15da26Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
47163c15da26Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
47173c15da26Smrg	        }
47183c15da26Smrg	      fi
47193c15da26Smrg	    ;;
47203c15da26Smrg	    *)
47213c15da26Smrg	      $opt_dry_run || {
47223c15da26Smrg	        eval '$ECHO ": $name " >> "$nlist"'
47233c15da26Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
47243c15da26Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
47253c15da26Smrg	      }
47263c15da26Smrg	    ;;
47273c15da26Smrg          esac
4728d656433aSmrg	done
4729126a8a12Smrg
4730d656433aSmrg	$opt_dry_run || {
4731d656433aSmrg	  # Make sure we have at least an empty file.
4732d656433aSmrg	  test -f "$nlist" || : > "$nlist"
4733126a8a12Smrg
4734d656433aSmrg	  if test -n "$exclude_expsyms"; then
4735d656433aSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4736d656433aSmrg	    $MV "$nlist"T "$nlist"
4737126a8a12Smrg	  fi
4738126a8a12Smrg
4739d656433aSmrg	  # Try sorting and uniquifying the output.
4740d656433aSmrg	  if $GREP -v "^: " < "$nlist" |
4741d656433aSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
4742d656433aSmrg		sort -k 3
4743126a8a12Smrg	      else
4744d656433aSmrg		sort +2
4745d656433aSmrg	      fi |
4746d656433aSmrg	      uniq > "$nlist"S; then
4747d656433aSmrg	    :
4748126a8a12Smrg	  else
4749d656433aSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
4750126a8a12Smrg	  fi
4751126a8a12Smrg
4752d656433aSmrg	  if test -f "$nlist"S; then
4753d656433aSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
4754126a8a12Smrg	  else
4755555991fdSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
4756126a8a12Smrg	  fi
4757126a8a12Smrg
4758300346aeSmrg	  func_show_eval '$RM "${nlist}I"'
4759300346aeSmrg	  if test -n "$global_symbol_to_import"; then
4760300346aeSmrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
4761300346aeSmrg	  fi
4762300346aeSmrg
4763555991fdSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
4764126a8a12Smrg
4765d656433aSmrg/* The mapping between symbol names and symbols.  */
4766d656433aSmrgtypedef struct {
4767d656433aSmrg  const char *name;
4768d656433aSmrg  void *address;
4769d656433aSmrg} lt_dlsymlist;
47703c15da26Smrgextern LT_DLSYM_CONST lt_dlsymlist
4771300346aeSmrglt_${my_prefix}_LTX_preloaded_symbols[];\
4772300346aeSmrg"
4773300346aeSmrg
4774300346aeSmrg	  if test -s "$nlist"I; then
4775300346aeSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
4776300346aeSmrgstatic void lt_syminit(void)
4777300346aeSmrg{
4778300346aeSmrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
4779300346aeSmrg  for (; symbol->name; ++symbol)
4780300346aeSmrg    {"
4781300346aeSmrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
4782300346aeSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
4783300346aeSmrg    }
4784300346aeSmrg}"
4785300346aeSmrg	  fi
4786300346aeSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
47873c15da26SmrgLT_DLSYM_CONST lt_dlsymlist
4788d656433aSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
4789300346aeSmrg{ {\"$my_originator\", (void *) 0},"
4790300346aeSmrg
4791300346aeSmrg	  if test -s "$nlist"I; then
4792300346aeSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
4793300346aeSmrg  {\"@INIT@\", (void *) &lt_syminit},"
4794300346aeSmrg	  fi
4795d656433aSmrg
4796d656433aSmrg	  case $need_lib_prefix in
4797d656433aSmrg	  no)
4798d656433aSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
4799d656433aSmrg	    ;;
4800d656433aSmrg	  *)
4801d656433aSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
4802d656433aSmrg	    ;;
4803d656433aSmrg	  esac
4804555991fdSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
4805d656433aSmrg  {0, (void *) 0}
4806d656433aSmrg};
4807d656433aSmrg
4808d656433aSmrg/* This works around a problem in FreeBSD linker */
4809d656433aSmrg#ifdef FREEBSD_WORKAROUND
4810d656433aSmrgstatic const void *lt_preloaded_setup() {
4811d656433aSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
4812d656433aSmrg}
4813d656433aSmrg#endif
4814d656433aSmrg
4815d656433aSmrg#ifdef __cplusplus
4816d656433aSmrg}
4817d656433aSmrg#endif\
4818d656433aSmrg"
4819d656433aSmrg	} # !$opt_dry_run
4820d656433aSmrg
4821d656433aSmrg	pic_flag_for_symtable=
4822d656433aSmrg	case "$compile_command " in
4823d656433aSmrg	*" -static "*) ;;
4824d656433aSmrg	*)
4825d656433aSmrg	  case $host in
4826d656433aSmrg	  # compiling the symbol table file with pic_flag works around
4827d656433aSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
4828d656433aSmrg	  # linked before any other PIC object.  But we must not use
4829d656433aSmrg	  # pic_flag when linking with -static.  The problem exists in
4830d656433aSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
48310a6b08f8Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4832d656433aSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
4833d656433aSmrg	  *-*-hpux*)
4834d656433aSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
4835d656433aSmrg	  *)
4836300346aeSmrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
4837d656433aSmrg	    ;;
4838d656433aSmrg	  esac
4839d656433aSmrg	  ;;
4840d656433aSmrg	esac
4841d656433aSmrg	symtab_cflags=
4842d656433aSmrg	for arg in $LTCFLAGS; do
4843d656433aSmrg	  case $arg in
4844d656433aSmrg	  -pie | -fpie | -fPIE) ;;
48453c15da26Smrg	  *) func_append symtab_cflags " $arg" ;;
4846d656433aSmrg	  esac
4847d656433aSmrg	done
4848126a8a12Smrg
4849d656433aSmrg	# Now compile the dynamic symbol file.
4850d656433aSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
4851126a8a12Smrg
4852d656433aSmrg	# Clean up the generated files.
4853300346aeSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
4854d656433aSmrg
4855d656433aSmrg	# Transform the symbol file into the correct name.
4856300346aeSmrg	symfileobj=$output_objdir/${my_outputname}S.$objext
4857d656433aSmrg	case $host in
4858d656433aSmrg	*cygwin* | *mingw* | *cegcc* )
4859d656433aSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
4860555991fdSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4861555991fdSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4862d656433aSmrg	  else
4863555991fdSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4864555991fdSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4865d656433aSmrg	  fi
4866d656433aSmrg	  ;;
4867d656433aSmrg	*)
4868555991fdSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4869555991fdSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4870126a8a12Smrg	  ;;
4871126a8a12Smrg	esac
4872d656433aSmrg	;;
4873d656433aSmrg      *)
4874300346aeSmrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
4875d656433aSmrg	;;
4876d656433aSmrg      esac
4877d656433aSmrg    else
4878d656433aSmrg      # We keep going just in case the user didn't refer to
4879d656433aSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
4880d656433aSmrg      # really was required.
4881d656433aSmrg
4882d656433aSmrg      # Nullify the symbol file.
4883555991fdSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4884555991fdSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
4885126a8a12Smrg    fi
4886d656433aSmrg}
4887126a8a12Smrg
4888300346aeSmrg# func_cygming_gnu_implib_p ARG
4889300346aeSmrg# This predicate returns with zero status (TRUE) if
4890300346aeSmrg# ARG is a GNU/binutils-style import library. Returns
4891300346aeSmrg# with nonzero status (FALSE) otherwise.
4892300346aeSmrgfunc_cygming_gnu_implib_p ()
4893300346aeSmrg{
4894300346aeSmrg  $debug_cmd
4895300346aeSmrg
4896300346aeSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
4897300346aeSmrg  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)$'`
4898300346aeSmrg  test -n "$func_cygming_gnu_implib_tmp"
4899300346aeSmrg}
4900300346aeSmrg
4901300346aeSmrg# func_cygming_ms_implib_p ARG
4902300346aeSmrg# This predicate returns with zero status (TRUE) if
4903300346aeSmrg# ARG is an MS-style import library. Returns
4904300346aeSmrg# with nonzero status (FALSE) otherwise.
4905300346aeSmrgfunc_cygming_ms_implib_p ()
4906300346aeSmrg{
4907300346aeSmrg  $debug_cmd
4908300346aeSmrg
4909300346aeSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
4910300346aeSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
4911300346aeSmrg  test -n "$func_cygming_ms_implib_tmp"
4912300346aeSmrg}
4913300346aeSmrg
4914d656433aSmrg# func_win32_libid arg
4915d656433aSmrg# return the library type of file 'arg'
4916d656433aSmrg#
4917d656433aSmrg# Need a lot of goo to handle *both* DLLs and import libs
4918d656433aSmrg# Has to be a shell function in order to 'eat' the argument
4919d656433aSmrg# that is supplied when $file_magic_command is called.
4920555991fdSmrg# Despite the name, also deal with 64 bit binaries.
4921d656433aSmrgfunc_win32_libid ()
4922d656433aSmrg{
4923300346aeSmrg  $debug_cmd
4924300346aeSmrg
4925300346aeSmrg  win32_libid_type=unknown
4926d656433aSmrg  win32_fileres=`file -L $1 2>/dev/null`
4927d656433aSmrg  case $win32_fileres in
4928d656433aSmrg  *ar\ archive\ import\ library*) # definitely import
4929d656433aSmrg    win32_libid_type="x86 archive import"
4930d656433aSmrg    ;;
4931d656433aSmrg  *ar\ archive*) # could be an import, or static
4932555991fdSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
4933d656433aSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
4934555991fdSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
4935300346aeSmrg      case $nm_interface in
4936300346aeSmrg      "MS dumpbin")
4937300346aeSmrg	if func_cygming_ms_implib_p "$1" ||
4938300346aeSmrg	   func_cygming_gnu_implib_p "$1"
4939300346aeSmrg	then
4940300346aeSmrg	  win32_nmres=import
4941300346aeSmrg	else
4942300346aeSmrg	  win32_nmres=
4943300346aeSmrg	fi
4944300346aeSmrg	;;
4945300346aeSmrg      *)
4946300346aeSmrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
4947300346aeSmrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
4948300346aeSmrg	  $SED -n -e '
4949d656433aSmrg	    1,100{
4950d656433aSmrg		/ I /{
4951300346aeSmrg		    s|.*|import|
4952d656433aSmrg		    p
4953d656433aSmrg		    q
4954d656433aSmrg		}
4955d656433aSmrg	    }'`
4956300346aeSmrg	;;
4957300346aeSmrg      esac
4958d656433aSmrg      case $win32_nmres in
4959d656433aSmrg      import*)  win32_libid_type="x86 archive import";;
4960d656433aSmrg      *)        win32_libid_type="x86 archive static";;
4961d656433aSmrg      esac
4962d656433aSmrg    fi
4963d656433aSmrg    ;;
4964d656433aSmrg  *DLL*)
4965d656433aSmrg    win32_libid_type="x86 DLL"
4966d656433aSmrg    ;;
4967d656433aSmrg  *executable*) # but shell scripts are "executable" too...
4968d656433aSmrg    case $win32_fileres in
4969d656433aSmrg    *MS\ Windows\ PE\ Intel*)
4970d656433aSmrg      win32_libid_type="x86 DLL"
4971d656433aSmrg      ;;
4972d656433aSmrg    esac
4973d656433aSmrg    ;;
4974d656433aSmrg  esac
4975d656433aSmrg  $ECHO "$win32_libid_type"
4976d656433aSmrg}
4977126a8a12Smrg
49783c15da26Smrg# func_cygming_dll_for_implib ARG
49793c15da26Smrg#
49803c15da26Smrg# Platform-specific function to extract the
49813c15da26Smrg# name of the DLL associated with the specified
49823c15da26Smrg# import library ARG.
49833c15da26Smrg# Invoked by eval'ing the libtool variable
49843c15da26Smrg#    $sharedlib_from_linklib_cmd
49853c15da26Smrg# Result is available in the variable
49863c15da26Smrg#    $sharedlib_from_linklib_result
49873c15da26Smrgfunc_cygming_dll_for_implib ()
49883c15da26Smrg{
4989300346aeSmrg  $debug_cmd
4990300346aeSmrg
49913c15da26Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
49923c15da26Smrg}
49933c15da26Smrg
49943c15da26Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
49953c15da26Smrg#
49963c15da26Smrg# The is the core of a fallback implementation of a
49973c15da26Smrg# platform-specific function to extract the name of the
49983c15da26Smrg# DLL associated with the specified import library LIBNAME.
49993c15da26Smrg#
50003c15da26Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
50013c15da26Smrg# on the platform and compiler that created the implib.
50023c15da26Smrg#
50033c15da26Smrg# Echos the name of the DLL associated with the
50043c15da26Smrg# specified import library.
50053c15da26Smrgfunc_cygming_dll_for_implib_fallback_core ()
50063c15da26Smrg{
5007300346aeSmrg  $debug_cmd
5008300346aeSmrg
50093c15da26Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
50103c15da26Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
50113c15da26Smrg    $SED '/^Contents of section '"$match_literal"':/{
50123c15da26Smrg      # Place marker at beginning of archive member dllname section
50133c15da26Smrg      s/.*/====MARK====/
50143c15da26Smrg      p
50153c15da26Smrg      d
50163c15da26Smrg    }
50173c15da26Smrg    # These lines can sometimes be longer than 43 characters, but
50183c15da26Smrg    # are always uninteresting
50193c15da26Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
50203c15da26Smrg    /^In archive [^:]*:/d
50213c15da26Smrg    # Ensure marker is printed
50223c15da26Smrg    /^====MARK====/p
50233c15da26Smrg    # Remove all lines with less than 43 characters
50243c15da26Smrg    /^.\{43\}/!d
50253c15da26Smrg    # From remaining lines, remove first 43 characters
50263c15da26Smrg    s/^.\{43\}//' |
50273c15da26Smrg    $SED -n '
50283c15da26Smrg      # Join marker and all lines until next marker into a single line
50293c15da26Smrg      /^====MARK====/ b para
50303c15da26Smrg      H
50313c15da26Smrg      $ b para
50323c15da26Smrg      b
50333c15da26Smrg      :para
50343c15da26Smrg      x
50353c15da26Smrg      s/\n//g
50363c15da26Smrg      # Remove the marker
50373c15da26Smrg      s/^====MARK====//
50383c15da26Smrg      # Remove trailing dots and whitespace
50393c15da26Smrg      s/[\. \t]*$//
50403c15da26Smrg      # Print
50413c15da26Smrg      /./p' |
50423c15da26Smrg    # we now have a list, one entry per line, of the stringified
50433c15da26Smrg    # contents of the appropriate section of all members of the
5044300346aeSmrg    # archive that possess that section. Heuristic: eliminate
5045300346aeSmrg    # all those that have a first or second character that is
50463c15da26Smrg    # a '.' (that is, objdump's representation of an unprintable
50473c15da26Smrg    # character.) This should work for all archives with less than
50483c15da26Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
50493c15da26Smrg    # begins with a literal '.' or a single character followed by
50503c15da26Smrg    # a '.'.
50513c15da26Smrg    #
50523c15da26Smrg    # Of those that remain, print the first one.
50533c15da26Smrg    $SED -e '/^\./d;/^.\./d;q'
50543c15da26Smrg}
50553c15da26Smrg
50563c15da26Smrg# func_cygming_dll_for_implib_fallback ARG
50573c15da26Smrg# Platform-specific function to extract the
50583c15da26Smrg# name of the DLL associated with the specified
50593c15da26Smrg# import library ARG.
50603c15da26Smrg#
50613c15da26Smrg# This fallback implementation is for use when $DLLTOOL
50623c15da26Smrg# does not support the --identify-strict option.
50633c15da26Smrg# Invoked by eval'ing the libtool variable
50643c15da26Smrg#    $sharedlib_from_linklib_cmd
50653c15da26Smrg# Result is available in the variable
50663c15da26Smrg#    $sharedlib_from_linklib_result
50673c15da26Smrgfunc_cygming_dll_for_implib_fallback ()
50683c15da26Smrg{
5069300346aeSmrg  $debug_cmd
5070300346aeSmrg
5071300346aeSmrg  if func_cygming_gnu_implib_p "$1"; then
50723c15da26Smrg    # binutils import library
50733c15da26Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
5074300346aeSmrg  elif func_cygming_ms_implib_p "$1"; then
50753c15da26Smrg    # ms-generated import library
50763c15da26Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
50773c15da26Smrg  else
50783c15da26Smrg    # unknown
5079300346aeSmrg    sharedlib_from_linklib_result=
50803c15da26Smrg  fi
50813c15da26Smrg}
5082126a8a12Smrg
5083126a8a12Smrg
5084d656433aSmrg# func_extract_an_archive dir oldlib
5085d656433aSmrgfunc_extract_an_archive ()
5086d656433aSmrg{
5087300346aeSmrg    $debug_cmd
5088300346aeSmrg
5089300346aeSmrg    f_ex_an_ar_dir=$1; shift
5090300346aeSmrg    f_ex_an_ar_oldlib=$1
5091300346aeSmrg    if test yes = "$lock_old_archive_extraction"; then
5092555991fdSmrg      lockfile=$f_ex_an_ar_oldlib.lock
5093555991fdSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5094555991fdSmrg	func_echo "Waiting for $lockfile to be removed"
5095555991fdSmrg	sleep 2
5096555991fdSmrg      done
5097555991fdSmrg    fi
5098555991fdSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5099555991fdSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
5100300346aeSmrg    if test yes = "$lock_old_archive_extraction"; then
5101555991fdSmrg      $opt_dry_run || rm -f "$lockfile"
5102555991fdSmrg    fi
5103d656433aSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
5104d656433aSmrg     :
5105d656433aSmrg    else
5106d656433aSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
5107d656433aSmrg    fi
5108d656433aSmrg}
5109126a8a12Smrg
5110126a8a12Smrg
5111d656433aSmrg# func_extract_archives gentop oldlib ...
5112d656433aSmrgfunc_extract_archives ()
5113d656433aSmrg{
5114300346aeSmrg    $debug_cmd
5115300346aeSmrg
5116300346aeSmrg    my_gentop=$1; shift
5117d656433aSmrg    my_oldlibs=${1+"$@"}
5118300346aeSmrg    my_oldobjs=
5119300346aeSmrg    my_xlib=
5120300346aeSmrg    my_xabs=
5121300346aeSmrg    my_xdir=
5122126a8a12Smrg
5123d656433aSmrg    for my_xlib in $my_oldlibs; do
5124d656433aSmrg      # Extract the objects.
5125d656433aSmrg      case $my_xlib in
5126300346aeSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
5127d656433aSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
5128d656433aSmrg      esac
5129d656433aSmrg      func_basename "$my_xlib"
5130300346aeSmrg      my_xlib=$func_basename_result
5131d656433aSmrg      my_xlib_u=$my_xlib
5132d656433aSmrg      while :; do
5133d656433aSmrg        case " $extracted_archives " in
5134d656433aSmrg	*" $my_xlib_u "*)
5135d656433aSmrg	  func_arith $extracted_serial + 1
5136d656433aSmrg	  extracted_serial=$func_arith_result
5137d656433aSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
5138d656433aSmrg	*) break ;;
5139d656433aSmrg	esac
5140d656433aSmrg      done
5141d656433aSmrg      extracted_archives="$extracted_archives $my_xlib_u"
5142300346aeSmrg      my_xdir=$my_gentop/$my_xlib_u
5143126a8a12Smrg
5144d656433aSmrg      func_mkdir_p "$my_xdir"
5145126a8a12Smrg
5146d656433aSmrg      case $host in
5147d656433aSmrg      *-darwin*)
5148d656433aSmrg	func_verbose "Extracting $my_xabs"
5149d656433aSmrg	# Do not bother doing anything if just a dry run
5150d656433aSmrg	$opt_dry_run || {
5151d656433aSmrg	  darwin_orig_dir=`pwd`
5152d656433aSmrg	  cd $my_xdir || exit $?
5153d656433aSmrg	  darwin_archive=$my_xabs
5154d656433aSmrg	  darwin_curdir=`pwd`
5155300346aeSmrg	  func_basename "$darwin_archive"
5156300346aeSmrg	  darwin_base_archive=$func_basename_result
5157d656433aSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
5158d656433aSmrg	  if test -n "$darwin_arches"; then
5159d656433aSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
5160d656433aSmrg	    darwin_arch=
5161d656433aSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
5162300346aeSmrg	    for darwin_arch in  $darwin_arches; do
5163300346aeSmrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
5164300346aeSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
5165300346aeSmrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
5166300346aeSmrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
5167d656433aSmrg	      cd "$darwin_curdir"
5168300346aeSmrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
5169d656433aSmrg	    done # $darwin_arches
5170d656433aSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
5171300346aeSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
5172d656433aSmrg	    darwin_file=
5173d656433aSmrg	    darwin_files=
5174d656433aSmrg	    for darwin_file in $darwin_filelist; do
5175555991fdSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
5176d656433aSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
5177d656433aSmrg	    done # $darwin_filelist
5178d656433aSmrg	    $RM -rf unfat-$$
5179d656433aSmrg	    cd "$darwin_orig_dir"
5180d656433aSmrg	  else
5181d656433aSmrg	    cd $darwin_orig_dir
5182d656433aSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
5183d656433aSmrg	  fi # $darwin_arches
5184d656433aSmrg	} # !$opt_dry_run
5185d656433aSmrg	;;
5186d656433aSmrg      *)
5187d656433aSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
5188d656433aSmrg	;;
5189126a8a12Smrg      esac
5190555991fdSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
5191d656433aSmrg    done
5192126a8a12Smrg
5193300346aeSmrg    func_extract_archives_result=$my_oldobjs
5194d656433aSmrg}
5195126a8a12Smrg
5196126a8a12Smrg
5197555991fdSmrg# func_emit_wrapper [arg=no]
5198d656433aSmrg#
5199555991fdSmrg# Emit a libtool wrapper script on stdout.
5200555991fdSmrg# Don't directly open a file because we may want to
5201555991fdSmrg# incorporate the script contents within a cygwin/mingw
5202555991fdSmrg# wrapper executable.  Must ONLY be called from within
5203555991fdSmrg# func_mode_link because it depends on a number of variables
5204555991fdSmrg# set therein.
5205555991fdSmrg#
5206555991fdSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5207555991fdSmrg# variable will take.  If 'yes', then the emitted script
5208300346aeSmrg# will assume that the directory where it is stored is
5209555991fdSmrg# the $objdir directory.  This is a cygwin/mingw-specific
5210555991fdSmrg# behavior.
5211555991fdSmrgfunc_emit_wrapper ()
5212d656433aSmrg{
5213555991fdSmrg	func_emit_wrapper_arg1=${1-no}
5214126a8a12Smrg
5215d656433aSmrg	$ECHO "\
5216d656433aSmrg#! $SHELL
5217126a8a12Smrg
5218d656433aSmrg# $output - temporary wrapper script for $objdir/$outputname
5219300346aeSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5220d656433aSmrg#
5221d656433aSmrg# The $output program cannot be directly executed until all the libtool
5222d656433aSmrg# libraries that it depends on are installed.
5223d656433aSmrg#
5224d656433aSmrg# This wrapper script should never be moved out of the build directory.
5225d656433aSmrg# If it is, it will not operate correctly.
5226126a8a12Smrg
5227d656433aSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
5228d656433aSmrg# metacharacters that are still active within double-quoted strings.
5229d656433aSmrgsed_quote_subst='$sed_quote_subst'
5230126a8a12Smrg
5231d656433aSmrg# Be Bourne compatible
5232d656433aSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5233d656433aSmrg  emulate sh
5234d656433aSmrg  NULLCMD=:
5235d656433aSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5236d656433aSmrg  # is contrary to our usage.  Disable this feature.
5237d656433aSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
5238d656433aSmrg  setopt NO_GLOB_SUBST
5239d656433aSmrgelse
5240d656433aSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5241d656433aSmrgfi
5242d656433aSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
5243d656433aSmrgDUALCASE=1; export DUALCASE # for MKS sh
5244126a8a12Smrg
5245d656433aSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
5246d656433aSmrg# if CDPATH is set.
5247d656433aSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5248126a8a12Smrg
5249d656433aSmrgrelink_command=\"$relink_command\"
5250126a8a12Smrg
5251d656433aSmrg# This environment variable determines our operation mode.
5252d656433aSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
5253d656433aSmrg  # install mode needs the following variables:
5254d656433aSmrg  generated_by_libtool_version='$macro_version'
5255d656433aSmrg  notinst_deplibs='$notinst_deplibs'
5256d656433aSmrgelse
5257d656433aSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
5258d656433aSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5259555991fdSmrg    file=\"\$0\""
5260555991fdSmrg
5261555991fdSmrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
5262555991fdSmrg    $ECHO "\
5263555991fdSmrg
5264555991fdSmrg# A function that is used when there is no print builtin or printf.
5265555991fdSmrgfunc_fallback_echo ()
5266555991fdSmrg{
5267555991fdSmrg  eval 'cat <<_LTECHO_EOF
5268555991fdSmrg\$1
5269555991fdSmrg_LTECHO_EOF'
5270555991fdSmrg}
5271555991fdSmrg    ECHO=\"$qECHO\"
5272555991fdSmrg  fi
5273555991fdSmrg
5274555991fdSmrg# Very basic option parsing. These options are (a) specific to
5275555991fdSmrg# the libtool wrapper, (b) are identical between the wrapper
5276300346aeSmrg# /script/ and the wrapper /executable/ that is used only on
5277555991fdSmrg# windows platforms, and (c) all begin with the string "--lt-"
5278300346aeSmrg# (application programs are unlikely to have options that match
5279555991fdSmrg# this pattern).
5280555991fdSmrg#
5281555991fdSmrg# There are only two supported options: --lt-debug and
5282555991fdSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
5283555991fdSmrg#
5284555991fdSmrg# The first argument to this parsing function should be the
5285555991fdSmrg# script's $0 value, followed by "$@".
5286555991fdSmrglt_option_debug=
5287555991fdSmrgfunc_parse_lt_options ()
5288555991fdSmrg{
5289555991fdSmrg  lt_script_arg0=\$0
5290555991fdSmrg  shift
5291555991fdSmrg  for lt_opt
5292555991fdSmrg  do
5293555991fdSmrg    case \"\$lt_opt\" in
5294555991fdSmrg    --lt-debug) lt_option_debug=1 ;;
5295555991fdSmrg    --lt-dump-script)
5296555991fdSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5297555991fdSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5298555991fdSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5299555991fdSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
5300555991fdSmrg        exit 0
5301555991fdSmrg      ;;
5302555991fdSmrg    --lt-*)
5303555991fdSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5304555991fdSmrg        exit 1
5305555991fdSmrg      ;;
5306555991fdSmrg    esac
5307555991fdSmrg  done
5308555991fdSmrg
5309555991fdSmrg  # Print the debug banner immediately:
5310555991fdSmrg  if test -n \"\$lt_option_debug\"; then
5311300346aeSmrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5312555991fdSmrg  fi
5313555991fdSmrg}
5314555991fdSmrg
5315555991fdSmrg# Used when --lt-debug. Prints its arguments to stdout
5316555991fdSmrg# (redirection is the responsibility of the caller)
5317555991fdSmrgfunc_lt_dump_args ()
5318555991fdSmrg{
5319555991fdSmrg  lt_dump_args_N=1;
5320555991fdSmrg  for lt_arg
5321555991fdSmrg  do
5322300346aeSmrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5323555991fdSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5324555991fdSmrg  done
5325555991fdSmrg}
5326555991fdSmrg
5327555991fdSmrg# Core function for launching the target application
5328555991fdSmrgfunc_exec_program_core ()
5329555991fdSmrg{
5330d656433aSmrg"
5331555991fdSmrg  case $host in
5332555991fdSmrg  # Backslashes separate directories on plain windows
5333555991fdSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
5334555991fdSmrg    $ECHO "\
5335555991fdSmrg      if test -n \"\$lt_option_debug\"; then
5336300346aeSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5337555991fdSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5338555991fdSmrg      fi
5339555991fdSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5340555991fdSmrg"
5341555991fdSmrg    ;;
5342555991fdSmrg
5343555991fdSmrg  *)
5344555991fdSmrg    $ECHO "\
5345555991fdSmrg      if test -n \"\$lt_option_debug\"; then
5346300346aeSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5347555991fdSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5348555991fdSmrg      fi
5349555991fdSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5350555991fdSmrg"
5351555991fdSmrg    ;;
5352555991fdSmrg  esac
5353555991fdSmrg  $ECHO "\
5354555991fdSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5355555991fdSmrg      exit 1
5356555991fdSmrg}
5357555991fdSmrg
5358555991fdSmrg# A function to encapsulate launching the target application
5359555991fdSmrg# Strips options in the --lt-* namespace from \$@ and
5360555991fdSmrg# launches target application with the remaining arguments.
5361555991fdSmrgfunc_exec_program ()
5362555991fdSmrg{
53630a6b08f8Smrg  case \" \$* \" in
53640a6b08f8Smrg  *\\ --lt-*)
53650a6b08f8Smrg    for lt_wr_arg
53660a6b08f8Smrg    do
53670a6b08f8Smrg      case \$lt_wr_arg in
53680a6b08f8Smrg      --lt-*) ;;
53690a6b08f8Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
53700a6b08f8Smrg      esac
53710a6b08f8Smrg      shift
53720a6b08f8Smrg    done ;;
53730a6b08f8Smrg  esac
5374555991fdSmrg  func_exec_program_core \${1+\"\$@\"}
5375555991fdSmrg}
5376555991fdSmrg
5377555991fdSmrg  # Parse options
5378555991fdSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5379126a8a12Smrg
5380d656433aSmrg  # Find the directory that this script lives in.
5381555991fdSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
5382d656433aSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5383126a8a12Smrg
5384d656433aSmrg  # Follow symbolic links until we get to the real thisdir.
5385555991fdSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
5386d656433aSmrg  while test -n \"\$file\"; do
5387555991fdSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5388126a8a12Smrg
5389d656433aSmrg    # If there was a directory component, then change thisdir.
5390d656433aSmrg    if test \"x\$destdir\" != \"x\$file\"; then
5391d656433aSmrg      case \"\$destdir\" in
5392d656433aSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5393d656433aSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5394d656433aSmrg      esac
5395d656433aSmrg    fi
5396126a8a12Smrg
5397555991fdSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5398555991fdSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
5399d656433aSmrg  done
5400126a8a12Smrg
5401d656433aSmrg  # Usually 'no', except on cygwin/mingw when embedded into
5402d656433aSmrg  # the cwrapper.
5403555991fdSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
5404d656433aSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
5405d656433aSmrg    # special case for '.'
5406d656433aSmrg    if test \"\$thisdir\" = \".\"; then
5407d656433aSmrg      thisdir=\`pwd\`
5408d656433aSmrg    fi
5409d656433aSmrg    # remove .libs from thisdir
5410d656433aSmrg    case \"\$thisdir\" in
5411555991fdSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
5412d656433aSmrg    $objdir )   thisdir=. ;;
5413d656433aSmrg    esac
5414d656433aSmrg  fi
5415126a8a12Smrg
5416d656433aSmrg  # Try to get the absolute directory name.
5417d656433aSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
5418d656433aSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5419d656433aSmrg"
5420126a8a12Smrg
5421300346aeSmrg	if test yes = "$fast_install"; then
5422d656433aSmrg	  $ECHO "\
5423d656433aSmrg  program=lt-'$outputname'$exeext
5424d656433aSmrg  progdir=\"\$thisdir/$objdir\"
5425126a8a12Smrg
5426d656433aSmrg  if test ! -f \"\$progdir/\$program\" ||
5427300346aeSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
5428d656433aSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5429126a8a12Smrg
5430d656433aSmrg    file=\"\$\$-\$program\"
5431126a8a12Smrg
5432d656433aSmrg    if test ! -d \"\$progdir\"; then
5433d656433aSmrg      $MKDIR \"\$progdir\"
5434d656433aSmrg    else
5435d656433aSmrg      $RM \"\$progdir/\$file\"
5436d656433aSmrg    fi"
5437126a8a12Smrg
5438d656433aSmrg	  $ECHO "\
5439126a8a12Smrg
5440d656433aSmrg    # relink executable if necessary
5441d656433aSmrg    if test -n \"\$relink_command\"; then
5442d656433aSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5443d656433aSmrg      else
5444300346aeSmrg	\$ECHO \"\$relink_command_output\" >&2
5445d656433aSmrg	$RM \"\$progdir/\$file\"
5446d656433aSmrg	exit 1
5447d656433aSmrg      fi
5448d656433aSmrg    fi
5449126a8a12Smrg
5450d656433aSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5451d656433aSmrg    { $RM \"\$progdir/\$program\";
5452d656433aSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5453d656433aSmrg    $RM \"\$progdir/\$file\"
5454d656433aSmrg  fi"
5455d656433aSmrg	else
5456d656433aSmrg	  $ECHO "\
5457d656433aSmrg  program='$outputname'
5458d656433aSmrg  progdir=\"\$thisdir/$objdir\"
5459d656433aSmrg"
5460d656433aSmrg	fi
5461126a8a12Smrg
5462d656433aSmrg	$ECHO "\
5463126a8a12Smrg
5464d656433aSmrg  if test -f \"\$progdir/\$program\"; then"
5465126a8a12Smrg
54663c15da26Smrg	# fixup the dll searchpath if we need to.
54673c15da26Smrg	#
54683c15da26Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
54693c15da26Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
54703c15da26Smrg	# libraries must come first.
54713c15da26Smrg	if test -n "$dllsearchpath"; then
54723c15da26Smrg	  $ECHO "\
54733c15da26Smrg    # Add the dll search path components to the executable PATH
54743c15da26Smrg    PATH=$dllsearchpath:\$PATH
54753c15da26Smrg"
54763c15da26Smrg	fi
54773c15da26Smrg
5478d656433aSmrg	# Export our shlibpath_var if we have one.
5479300346aeSmrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5480d656433aSmrg	  $ECHO "\
5481d656433aSmrg    # Add our own library path to $shlibpath_var
5482d656433aSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5483126a8a12Smrg
5484d656433aSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
5485d656433aSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
5486555991fdSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5487126a8a12Smrg
5488d656433aSmrg    export $shlibpath_var
5489d656433aSmrg"
5490126a8a12Smrg	fi
5491126a8a12Smrg
5492d656433aSmrg	$ECHO "\
5493d656433aSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5494d656433aSmrg      # Run the actual program with our arguments.
5495555991fdSmrg      func_exec_program \${1+\"\$@\"}
5496d656433aSmrg    fi
5497d656433aSmrg  else
5498d656433aSmrg    # The program doesn't exist.
5499300346aeSmrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
5500d656433aSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5501555991fdSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
5502d656433aSmrg    exit 1
5503d656433aSmrg  fi
5504d656433aSmrgfi\
5505d656433aSmrg"
5506d656433aSmrg}
5507126a8a12Smrg
5508126a8a12Smrg
5509d656433aSmrg# func_emit_cwrapperexe_src
5510d656433aSmrg# emit the source code for a wrapper executable on stdout
5511d656433aSmrg# Must ONLY be called from within func_mode_link because
5512d656433aSmrg# it depends on a number of variable set therein.
5513d656433aSmrgfunc_emit_cwrapperexe_src ()
5514d656433aSmrg{
5515d656433aSmrg	cat <<EOF
5516126a8a12Smrg
5517d656433aSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5518300346aeSmrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5519126a8a12Smrg
5520d656433aSmrg   The $output program cannot be directly executed until all the libtool
5521d656433aSmrg   libraries that it depends on are installed.
5522126a8a12Smrg
5523d656433aSmrg   This wrapper executable should never be moved out of the build directory.
5524d656433aSmrg   If it is, it will not operate correctly.
5525d656433aSmrg*/
5526d656433aSmrgEOF
5527d656433aSmrg	    cat <<"EOF"
5528555991fdSmrg#ifdef _MSC_VER
5529555991fdSmrg# define _CRT_SECURE_NO_DEPRECATE 1
5530555991fdSmrg#endif
5531d656433aSmrg#include <stdio.h>
5532d656433aSmrg#include <stdlib.h>
5533d656433aSmrg#ifdef _MSC_VER
5534d656433aSmrg# include <direct.h>
5535d656433aSmrg# include <process.h>
5536d656433aSmrg# include <io.h>
5537d656433aSmrg#else
5538d656433aSmrg# include <unistd.h>
5539d656433aSmrg# include <stdint.h>
5540d656433aSmrg# ifdef __CYGWIN__
5541d656433aSmrg#  include <io.h>
5542d656433aSmrg# endif
5543d656433aSmrg#endif
5544d656433aSmrg#include <malloc.h>
5545d656433aSmrg#include <stdarg.h>
5546d656433aSmrg#include <assert.h>
5547d656433aSmrg#include <string.h>
5548d656433aSmrg#include <ctype.h>
5549d656433aSmrg#include <errno.h>
5550d656433aSmrg#include <fcntl.h>
5551d656433aSmrg#include <sys/stat.h>
5552d656433aSmrg
5553300346aeSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5554300346aeSmrg
5555555991fdSmrg/* declarations of non-ANSI functions */
5556300346aeSmrg#if defined __MINGW32__
5557555991fdSmrg# ifdef __STRICT_ANSI__
5558555991fdSmrgint _putenv (const char *);
5559555991fdSmrg# endif
5560300346aeSmrg#elif defined __CYGWIN__
5561555991fdSmrg# ifdef __STRICT_ANSI__
5562555991fdSmrgchar *realpath (const char *, char *);
5563555991fdSmrgint putenv (char *);
5564555991fdSmrgint setenv (const char *, const char *, int);
5565555991fdSmrg# endif
5566300346aeSmrg/* #elif defined other_platform || defined ... */
5567555991fdSmrg#endif
5568555991fdSmrg
5569555991fdSmrg/* portability defines, excluding path handling macros */
5570300346aeSmrg#if defined _MSC_VER
5571555991fdSmrg# define setmode _setmode
5572555991fdSmrg# define stat    _stat
5573555991fdSmrg# define chmod   _chmod
5574555991fdSmrg# define getcwd  _getcwd
5575555991fdSmrg# define putenv  _putenv
5576555991fdSmrg# define S_IXUSR _S_IEXEC
5577300346aeSmrg#elif defined __MINGW32__
5578555991fdSmrg# define setmode _setmode
5579555991fdSmrg# define stat    _stat
5580555991fdSmrg# define chmod   _chmod
5581555991fdSmrg# define getcwd  _getcwd
5582555991fdSmrg# define putenv  _putenv
5583300346aeSmrg#elif defined __CYGWIN__
5584555991fdSmrg# define HAVE_SETENV
5585555991fdSmrg# define FOPEN_WB "wb"
5586300346aeSmrg/* #elif defined other platforms ... */
5587555991fdSmrg#endif
5588555991fdSmrg
5589300346aeSmrg#if defined PATH_MAX
5590d656433aSmrg# define LT_PATHMAX PATH_MAX
5591300346aeSmrg#elif defined MAXPATHLEN
5592d656433aSmrg# define LT_PATHMAX MAXPATHLEN
5593d656433aSmrg#else
5594d656433aSmrg# define LT_PATHMAX 1024
5595d656433aSmrg#endif
5596d656433aSmrg
5597d656433aSmrg#ifndef S_IXOTH
5598d656433aSmrg# define S_IXOTH 0
5599d656433aSmrg#endif
5600d656433aSmrg#ifndef S_IXGRP
5601d656433aSmrg# define S_IXGRP 0
5602d656433aSmrg#endif
5603d656433aSmrg
5604555991fdSmrg/* path handling portability macros */
5605d656433aSmrg#ifndef DIR_SEPARATOR
5606d656433aSmrg# define DIR_SEPARATOR '/'
5607d656433aSmrg# define PATH_SEPARATOR ':'
5608d656433aSmrg#endif
5609d656433aSmrg
5610300346aeSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
5611300346aeSmrg  defined __OS2__
5612d656433aSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
5613d656433aSmrg# define FOPEN_WB "wb"
5614d656433aSmrg# ifndef DIR_SEPARATOR_2
5615d656433aSmrg#  define DIR_SEPARATOR_2 '\\'
5616d656433aSmrg# endif
5617d656433aSmrg# ifndef PATH_SEPARATOR_2
5618d656433aSmrg#  define PATH_SEPARATOR_2 ';'
5619d656433aSmrg# endif
5620d656433aSmrg#endif
5621d656433aSmrg
5622d656433aSmrg#ifndef DIR_SEPARATOR_2
5623d656433aSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5624d656433aSmrg#else /* DIR_SEPARATOR_2 */
5625d656433aSmrg# define IS_DIR_SEPARATOR(ch) \
5626d656433aSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5627d656433aSmrg#endif /* DIR_SEPARATOR_2 */
5628d656433aSmrg
5629d656433aSmrg#ifndef PATH_SEPARATOR_2
5630d656433aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5631d656433aSmrg#else /* PATH_SEPARATOR_2 */
5632d656433aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5633d656433aSmrg#endif /* PATH_SEPARATOR_2 */
5634d656433aSmrg
5635d656433aSmrg#ifndef FOPEN_WB
5636d656433aSmrg# define FOPEN_WB "w"
5637d656433aSmrg#endif
5638d656433aSmrg#ifndef _O_BINARY
5639d656433aSmrg# define _O_BINARY 0
5640d656433aSmrg#endif
5641d656433aSmrg
5642d656433aSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
5643d656433aSmrg#define XFREE(stale) do { \
5644300346aeSmrg  if (stale) { free (stale); stale = 0; } \
5645d656433aSmrg} while (0)
5646d656433aSmrg
5647300346aeSmrg#if defined LT_DEBUGWRAPPER
5648555991fdSmrgstatic int lt_debug = 1;
5649d656433aSmrg#else
5650555991fdSmrgstatic int lt_debug = 0;
5651d656433aSmrg#endif
5652d656433aSmrg
5653555991fdSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5654d656433aSmrg
5655d656433aSmrgvoid *xmalloc (size_t num);
5656d656433aSmrgchar *xstrdup (const char *string);
5657d656433aSmrgconst char *base_name (const char *name);
5658d656433aSmrgchar *find_executable (const char *wrapper);
5659d656433aSmrgchar *chase_symlinks (const char *pathspec);
5660d656433aSmrgint make_executable (const char *path);
5661d656433aSmrgint check_executable (const char *path);
5662d656433aSmrgchar *strendzap (char *str, const char *pat);
5663555991fdSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
5664555991fdSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
5665555991fdSmrgstatic const char *nonnull (const char *s);
5666555991fdSmrgstatic const char *nonempty (const char *s);
5667d656433aSmrgvoid lt_setenv (const char *name, const char *value);
5668d656433aSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
5669d656433aSmrgvoid lt_update_exe_path (const char *name, const char *value);
5670d656433aSmrgvoid lt_update_lib_path (const char *name, const char *value);
5671555991fdSmrgchar **prepare_spawn (char **argv);
5672555991fdSmrgvoid lt_dump_script (FILE *f);
5673d656433aSmrgEOF
5674d656433aSmrg
5675d656433aSmrg	    cat <<EOF
5676300346aeSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
5677300346aeSmrg# define externally_visible volatile
5678300346aeSmrg#else
5679300346aeSmrg# define externally_visible __attribute__((externally_visible)) volatile
5680300346aeSmrg#endif
5681300346aeSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
5682d656433aSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
5683d656433aSmrgEOF
5684d656433aSmrg
5685300346aeSmrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
56863c15da26Smrg              func_to_host_path "$temp_rpath"
5687d656433aSmrg	      cat <<EOF
56883c15da26Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
5689126a8a12SmrgEOF
5690126a8a12Smrg	    else
5691d656433aSmrg	      cat <<"EOF"
5692d656433aSmrgconst char * LIB_PATH_VALUE   = "";
5693d656433aSmrgEOF
5694126a8a12Smrg	    fi
5695d656433aSmrg
5696d656433aSmrg	    if test -n "$dllsearchpath"; then
56973c15da26Smrg              func_to_host_path "$dllsearchpath:"
5698d656433aSmrg	      cat <<EOF
5699d656433aSmrgconst char * EXE_PATH_VARNAME = "PATH";
57003c15da26Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
5701d656433aSmrgEOF
5702126a8a12Smrg	    else
5703d656433aSmrg	      cat <<"EOF"
5704d656433aSmrgconst char * EXE_PATH_VARNAME = "";
5705d656433aSmrgconst char * EXE_PATH_VALUE   = "";
5706d656433aSmrgEOF
5707126a8a12Smrg	    fi
5708d656433aSmrg
5709300346aeSmrg	    if test yes = "$fast_install"; then
5710d656433aSmrg	      cat <<EOF
5711d656433aSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
5712d656433aSmrgEOF
5713126a8a12Smrg	    else
5714d656433aSmrg	      cat <<EOF
5715d656433aSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
5716d656433aSmrgEOF
5717126a8a12Smrg	    fi
5718126a8a12Smrg
5719126a8a12Smrg
5720d656433aSmrg	    cat <<"EOF"
5721126a8a12Smrg
5722d656433aSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
5723126a8a12Smrg
5724d656433aSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
5725d656433aSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
5726555991fdSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
5727126a8a12Smrg
5728d656433aSmrgint
5729d656433aSmrgmain (int argc, char *argv[])
5730d656433aSmrg{
5731d656433aSmrg  char **newargz;
5732d656433aSmrg  int  newargc;
5733d656433aSmrg  char *tmp_pathspec;
5734d656433aSmrg  char *actual_cwrapper_path;
5735d656433aSmrg  char *actual_cwrapper_name;
5736d656433aSmrg  char *target_name;
5737d656433aSmrg  char *lt_argv_zero;
5738300346aeSmrg  int rval = 127;
5739126a8a12Smrg
5740d656433aSmrg  int i;
5741126a8a12Smrg
5742d656433aSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
5743300346aeSmrg  newargz = XMALLOC (char *, (size_t) argc + 1);
5744126a8a12Smrg
5745555991fdSmrg  /* very simple arg parsing; don't want to rely on getopt
5746555991fdSmrg   * also, copy all non cwrapper options to newargz, except
5747555991fdSmrg   * argz[0], which is handled differently
5748555991fdSmrg   */
5749555991fdSmrg  newargc=0;
5750d656433aSmrg  for (i = 1; i < argc; i++)
5751d656433aSmrg    {
5752300346aeSmrg      if (STREQ (argv[i], dumpscript_opt))
5753d656433aSmrg	{
5754d656433aSmrgEOF
5755300346aeSmrg	    case $host in
5756d656433aSmrg	      *mingw* | *cygwin* )
5757d656433aSmrg		# make stdout use "unix" line endings
5758d656433aSmrg		echo "          setmode(1,_O_BINARY);"
5759d656433aSmrg		;;
5760d656433aSmrg	      esac
5761126a8a12Smrg
5762d656433aSmrg	    cat <<"EOF"
5763555991fdSmrg	  lt_dump_script (stdout);
5764d656433aSmrg	  return 0;
5765d656433aSmrg	}
5766300346aeSmrg      if (STREQ (argv[i], debug_opt))
5767555991fdSmrg	{
5768555991fdSmrg          lt_debug = 1;
5769555991fdSmrg          continue;
5770555991fdSmrg	}
5771300346aeSmrg      if (STREQ (argv[i], ltwrapper_option_prefix))
5772555991fdSmrg        {
5773555991fdSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5774555991fdSmrg             namespace, but it is not one of the ones we know about and
5775555991fdSmrg             have already dealt with, above (inluding dump-script), then
5776555991fdSmrg             report an error. Otherwise, targets might begin to believe
5777555991fdSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5778555991fdSmrg             namespace. The first time any user complains about this, we'll
5779555991fdSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5780555991fdSmrg             or a configure.ac-settable value.
5781555991fdSmrg           */
5782555991fdSmrg          lt_fatal (__FILE__, __LINE__,
5783555991fdSmrg		    "unrecognized %s option: '%s'",
5784555991fdSmrg                    ltwrapper_option_prefix, argv[i]);
5785555991fdSmrg        }
5786555991fdSmrg      /* otherwise ... */
5787555991fdSmrg      newargz[++newargc] = xstrdup (argv[i]);
5788d656433aSmrg    }
5789555991fdSmrg  newargz[++newargc] = NULL;
5790555991fdSmrg
5791555991fdSmrgEOF
5792555991fdSmrg	    cat <<EOF
5793555991fdSmrg  /* The GNU banner must be the first non-error debug message */
5794300346aeSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5795555991fdSmrgEOF
5796555991fdSmrg	    cat <<"EOF"
5797555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5798555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
5799126a8a12Smrg
5800d656433aSmrg  tmp_pathspec = find_executable (argv[0]);
5801d656433aSmrg  if (tmp_pathspec == NULL)
5802555991fdSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5803555991fdSmrg  lt_debugprintf (__FILE__, __LINE__,
5804555991fdSmrg                  "(main) found exe (before symlink chase) at: %s\n",
5805555991fdSmrg		  tmp_pathspec);
5806d656433aSmrg
5807d656433aSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5808555991fdSmrg  lt_debugprintf (__FILE__, __LINE__,
5809555991fdSmrg                  "(main) found exe (after symlink chase) at: %s\n",
5810555991fdSmrg		  actual_cwrapper_path);
5811d656433aSmrg  XFREE (tmp_pathspec);
5812d656433aSmrg
5813555991fdSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
5814d656433aSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
5815d656433aSmrg
5816d656433aSmrg  /* wrapper name transforms */
5817d656433aSmrg  strendzap (actual_cwrapper_name, ".exe");
5818d656433aSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
5819d656433aSmrg  XFREE (actual_cwrapper_name);
5820d656433aSmrg  actual_cwrapper_name = tmp_pathspec;
5821d656433aSmrg  tmp_pathspec = 0;
5822d656433aSmrg
5823d656433aSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
5824d656433aSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
5825d656433aSmrg  strendzap (target_name, ".exe");
5826d656433aSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
5827d656433aSmrg  XFREE (target_name);
5828d656433aSmrg  target_name = tmp_pathspec;
5829d656433aSmrg  tmp_pathspec = 0;
5830d656433aSmrg
5831555991fdSmrg  lt_debugprintf (__FILE__, __LINE__,
5832555991fdSmrg		  "(main) libtool target name: %s\n",
5833555991fdSmrg		  target_name);
5834d656433aSmrgEOF
5835126a8a12Smrg
5836d656433aSmrg	    cat <<EOF
5837d656433aSmrg  newargz[0] =
5838d656433aSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
5839d656433aSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
5840d656433aSmrg  strcpy (newargz[0], actual_cwrapper_path);
5841d656433aSmrg  strcat (newargz[0], "$objdir");
5842d656433aSmrg  strcat (newargz[0], "/");
5843d656433aSmrgEOF
5844126a8a12Smrg
5845d656433aSmrg	    cat <<"EOF"
5846d656433aSmrg  /* stop here, and copy so we don't have to do this twice */
5847d656433aSmrg  tmp_pathspec = xstrdup (newargz[0]);
5848126a8a12Smrg
5849d656433aSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
5850d656433aSmrg  strcat (newargz[0], actual_cwrapper_name);
5851126a8a12Smrg
5852d656433aSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
5853d656433aSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
5854d656433aSmrg  XFREE (tmp_pathspec);
5855d656433aSmrg  tmp_pathspec = NULL;
5856d656433aSmrgEOF
5857126a8a12Smrg
5858d656433aSmrg	    case $host_os in
5859d656433aSmrg	      mingw*)
5860d656433aSmrg	    cat <<"EOF"
5861d656433aSmrg  {
5862d656433aSmrg    char* p;
5863d656433aSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
5864d656433aSmrg      {
5865d656433aSmrg	*p = '/';
5866d656433aSmrg      }
5867d656433aSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
5868d656433aSmrg      {
5869d656433aSmrg	*p = '/';
5870d656433aSmrg      }
5871d656433aSmrg  }
5872d656433aSmrgEOF
5873d656433aSmrg	    ;;
5874d656433aSmrg	    esac
5875126a8a12Smrg
5876d656433aSmrg	    cat <<"EOF"
5877d656433aSmrg  XFREE (target_name);
5878d656433aSmrg  XFREE (actual_cwrapper_path);
5879d656433aSmrg  XFREE (actual_cwrapper_name);
5880126a8a12Smrg
5881d656433aSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
5882d656433aSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
58833c15da26Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
58843c15da26Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
58853c15da26Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
58863c15da26Smrg     libraries must come first. */
5887d656433aSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
58883c15da26Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
5889126a8a12Smrg
5890555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5891555991fdSmrg		  nonnull (lt_argv_zero));
5892d656433aSmrg  for (i = 0; i < newargc; i++)
5893d656433aSmrg    {
5894555991fdSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5895555991fdSmrg		      i, nonnull (newargz[i]));
5896d656433aSmrg    }
5897126a8a12Smrg
5898d656433aSmrgEOF
5899126a8a12Smrg
5900d656433aSmrg	    case $host_os in
5901d656433aSmrg	      mingw*)
5902d656433aSmrg		cat <<"EOF"
5903d656433aSmrg  /* execv doesn't actually work on mingw as expected on unix */
5904555991fdSmrg  newargz = prepare_spawn (newargz);
5905300346aeSmrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
5906d656433aSmrg  if (rval == -1)
5907d656433aSmrg    {
5908d656433aSmrg      /* failed to start process */
5909555991fdSmrg      lt_debugprintf (__FILE__, __LINE__,
5910555991fdSmrg		      "(main) failed to launch target \"%s\": %s\n",
5911555991fdSmrg		      lt_argv_zero, nonnull (strerror (errno)));
5912d656433aSmrg      return 127;
5913d656433aSmrg    }
5914d656433aSmrg  return rval;
5915d656433aSmrgEOF
5916d656433aSmrg		;;
5917d656433aSmrg	      *)
5918d656433aSmrg		cat <<"EOF"
5919d656433aSmrg  execv (lt_argv_zero, newargz);
5920d656433aSmrg  return rval; /* =127, but avoids unused variable warning */
5921d656433aSmrgEOF
5922d656433aSmrg		;;
5923d656433aSmrg	    esac
5924126a8a12Smrg
5925d656433aSmrg	    cat <<"EOF"
5926d656433aSmrg}
5927126a8a12Smrg
5928d656433aSmrgvoid *
5929d656433aSmrgxmalloc (size_t num)
5930d656433aSmrg{
5931d656433aSmrg  void *p = (void *) malloc (num);
5932d656433aSmrg  if (!p)
5933555991fdSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
5934126a8a12Smrg
5935d656433aSmrg  return p;
5936d656433aSmrg}
5937126a8a12Smrg
5938d656433aSmrgchar *
5939d656433aSmrgxstrdup (const char *string)
5940d656433aSmrg{
5941d656433aSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
5942d656433aSmrg			  string) : NULL;
5943d656433aSmrg}
5944126a8a12Smrg
5945d656433aSmrgconst char *
5946d656433aSmrgbase_name (const char *name)
5947d656433aSmrg{
5948d656433aSmrg  const char *base;
5949126a8a12Smrg
5950300346aeSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
5951d656433aSmrg  /* Skip over the disk name in MSDOS pathnames. */
5952d656433aSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
5953d656433aSmrg    name += 2;
5954d656433aSmrg#endif
5955126a8a12Smrg
5956d656433aSmrg  for (base = name; *name; name++)
5957d656433aSmrg    if (IS_DIR_SEPARATOR (*name))
5958d656433aSmrg      base = name + 1;
5959d656433aSmrg  return base;
5960d656433aSmrg}
5961126a8a12Smrg
5962d656433aSmrgint
5963d656433aSmrgcheck_executable (const char *path)
5964d656433aSmrg{
5965d656433aSmrg  struct stat st;
5966126a8a12Smrg
5967555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
5968555991fdSmrg                  nonempty (path));
5969d656433aSmrg  if ((!path) || (!*path))
5970d656433aSmrg    return 0;
5971126a8a12Smrg
5972d656433aSmrg  if ((stat (path, &st) >= 0)
5973d656433aSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
5974d656433aSmrg    return 1;
5975d656433aSmrg  else
5976d656433aSmrg    return 0;
5977d656433aSmrg}
5978126a8a12Smrg
5979d656433aSmrgint
5980d656433aSmrgmake_executable (const char *path)
5981d656433aSmrg{
5982d656433aSmrg  int rval = 0;
5983d656433aSmrg  struct stat st;
5984126a8a12Smrg
5985555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
5986555991fdSmrg                  nonempty (path));
5987d656433aSmrg  if ((!path) || (!*path))
5988d656433aSmrg    return 0;
5989126a8a12Smrg
5990d656433aSmrg  if (stat (path, &st) >= 0)
5991d656433aSmrg    {
5992d656433aSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
5993d656433aSmrg    }
5994d656433aSmrg  return rval;
5995d656433aSmrg}
5996126a8a12Smrg
5997d656433aSmrg/* Searches for the full path of the wrapper.  Returns
5998d656433aSmrg   newly allocated full path name if found, NULL otherwise
5999d656433aSmrg   Does not chase symlinks, even on platforms that support them.
6000d656433aSmrg*/
6001d656433aSmrgchar *
6002d656433aSmrgfind_executable (const char *wrapper)
6003d656433aSmrg{
6004d656433aSmrg  int has_slash = 0;
6005d656433aSmrg  const char *p;
6006d656433aSmrg  const char *p_next;
6007d656433aSmrg  /* static buffer for getcwd */
6008d656433aSmrg  char tmp[LT_PATHMAX + 1];
6009300346aeSmrg  size_t tmp_len;
6010d656433aSmrg  char *concat_name;
6011126a8a12Smrg
6012555991fdSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6013555991fdSmrg                  nonempty (wrapper));
6014126a8a12Smrg
6015d656433aSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
6016d656433aSmrg    return NULL;
6017126a8a12Smrg
6018d656433aSmrg  /* Absolute path? */
6019300346aeSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6020d656433aSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
6021d656433aSmrg    {
6022d656433aSmrg      concat_name = xstrdup (wrapper);
6023d656433aSmrg      if (check_executable (concat_name))
6024d656433aSmrg	return concat_name;
6025d656433aSmrg      XFREE (concat_name);
6026d656433aSmrg    }
6027d656433aSmrg  else
6028d656433aSmrg    {
6029d656433aSmrg#endif
6030d656433aSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
6031d656433aSmrg	{
6032d656433aSmrg	  concat_name = xstrdup (wrapper);
6033d656433aSmrg	  if (check_executable (concat_name))
6034d656433aSmrg	    return concat_name;
6035d656433aSmrg	  XFREE (concat_name);
6036d656433aSmrg	}
6037300346aeSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6038d656433aSmrg    }
6039d656433aSmrg#endif
6040126a8a12Smrg
6041d656433aSmrg  for (p = wrapper; *p; p++)
6042d656433aSmrg    if (*p == '/')
6043d656433aSmrg      {
6044d656433aSmrg	has_slash = 1;
6045d656433aSmrg	break;
6046d656433aSmrg      }
6047d656433aSmrg  if (!has_slash)
6048d656433aSmrg    {
6049d656433aSmrg      /* no slashes; search PATH */
6050d656433aSmrg      const char *path = getenv ("PATH");
6051d656433aSmrg      if (path != NULL)
6052d656433aSmrg	{
6053d656433aSmrg	  for (p = path; *p; p = p_next)
6054d656433aSmrg	    {
6055d656433aSmrg	      const char *q;
6056d656433aSmrg	      size_t p_len;
6057d656433aSmrg	      for (q = p; *q; q++)
6058d656433aSmrg		if (IS_PATH_SEPARATOR (*q))
6059d656433aSmrg		  break;
6060300346aeSmrg	      p_len = (size_t) (q - p);
6061d656433aSmrg	      p_next = (*q == '\0' ? q : q + 1);
6062d656433aSmrg	      if (p_len == 0)
6063d656433aSmrg		{
6064d656433aSmrg		  /* empty path: current directory */
6065d656433aSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
6066555991fdSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6067555991fdSmrg                              nonnull (strerror (errno)));
6068d656433aSmrg		  tmp_len = strlen (tmp);
6069d656433aSmrg		  concat_name =
6070d656433aSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6071d656433aSmrg		  memcpy (concat_name, tmp, tmp_len);
6072d656433aSmrg		  concat_name[tmp_len] = '/';
6073d656433aSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
6074d656433aSmrg		}
6075d656433aSmrg	      else
6076d656433aSmrg		{
6077d656433aSmrg		  concat_name =
6078d656433aSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
6079d656433aSmrg		  memcpy (concat_name, p, p_len);
6080d656433aSmrg		  concat_name[p_len] = '/';
6081d656433aSmrg		  strcpy (concat_name + p_len + 1, wrapper);
6082d656433aSmrg		}
6083d656433aSmrg	      if (check_executable (concat_name))
6084d656433aSmrg		return concat_name;
6085d656433aSmrg	      XFREE (concat_name);
6086d656433aSmrg	    }
6087d656433aSmrg	}
6088d656433aSmrg      /* not found in PATH; assume curdir */
6089d656433aSmrg    }
6090d656433aSmrg  /* Relative path | not found in path: prepend cwd */
6091d656433aSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
6092555991fdSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6093555991fdSmrg              nonnull (strerror (errno)));
6094d656433aSmrg  tmp_len = strlen (tmp);
6095d656433aSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6096d656433aSmrg  memcpy (concat_name, tmp, tmp_len);
6097d656433aSmrg  concat_name[tmp_len] = '/';
6098d656433aSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
6099126a8a12Smrg
6100d656433aSmrg  if (check_executable (concat_name))
6101d656433aSmrg    return concat_name;
6102d656433aSmrg  XFREE (concat_name);
6103d656433aSmrg  return NULL;
6104d656433aSmrg}
6105126a8a12Smrg
6106d656433aSmrgchar *
6107d656433aSmrgchase_symlinks (const char *pathspec)
6108d656433aSmrg{
6109d656433aSmrg#ifndef S_ISLNK
6110d656433aSmrg  return xstrdup (pathspec);
6111d656433aSmrg#else
6112d656433aSmrg  char buf[LT_PATHMAX];
6113d656433aSmrg  struct stat s;
6114d656433aSmrg  char *tmp_pathspec = xstrdup (pathspec);
6115d656433aSmrg  char *p;
6116d656433aSmrg  int has_symlinks = 0;
6117d656433aSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
6118d656433aSmrg    {
6119555991fdSmrg      lt_debugprintf (__FILE__, __LINE__,
6120555991fdSmrg		      "checking path component for symlinks: %s\n",
6121555991fdSmrg		      tmp_pathspec);
6122d656433aSmrg      if (lstat (tmp_pathspec, &s) == 0)
6123d656433aSmrg	{
6124d656433aSmrg	  if (S_ISLNK (s.st_mode) != 0)
6125d656433aSmrg	    {
6126d656433aSmrg	      has_symlinks = 1;
6127d656433aSmrg	      break;
6128d656433aSmrg	    }
6129126a8a12Smrg
6130d656433aSmrg	  /* search backwards for last DIR_SEPARATOR */
6131d656433aSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
6132d656433aSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6133d656433aSmrg	    p--;
6134d656433aSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6135d656433aSmrg	    {
6136d656433aSmrg	      /* no more DIR_SEPARATORS left */
6137d656433aSmrg	      break;
6138d656433aSmrg	    }
6139d656433aSmrg	  *p = '\0';
6140d656433aSmrg	}
6141d656433aSmrg      else
6142d656433aSmrg	{
6143555991fdSmrg	  lt_fatal (__FILE__, __LINE__,
6144555991fdSmrg		    "error accessing file \"%s\": %s",
6145555991fdSmrg		    tmp_pathspec, nonnull (strerror (errno)));
6146d656433aSmrg	}
6147d656433aSmrg    }
6148d656433aSmrg  XFREE (tmp_pathspec);
6149126a8a12Smrg
6150d656433aSmrg  if (!has_symlinks)
6151d656433aSmrg    {
6152d656433aSmrg      return xstrdup (pathspec);
6153d656433aSmrg    }
6154126a8a12Smrg
6155d656433aSmrg  tmp_pathspec = realpath (pathspec, buf);
6156d656433aSmrg  if (tmp_pathspec == 0)
6157d656433aSmrg    {
6158555991fdSmrg      lt_fatal (__FILE__, __LINE__,
6159555991fdSmrg		"could not follow symlinks for %s", pathspec);
6160d656433aSmrg    }
6161d656433aSmrg  return xstrdup (tmp_pathspec);
6162d656433aSmrg#endif
6163d656433aSmrg}
6164126a8a12Smrg
6165d656433aSmrgchar *
6166d656433aSmrgstrendzap (char *str, const char *pat)
6167d656433aSmrg{
6168d656433aSmrg  size_t len, patlen;
6169126a8a12Smrg
6170d656433aSmrg  assert (str != NULL);
6171d656433aSmrg  assert (pat != NULL);
6172126a8a12Smrg
6173d656433aSmrg  len = strlen (str);
6174d656433aSmrg  patlen = strlen (pat);
6175126a8a12Smrg
6176d656433aSmrg  if (patlen <= len)
6177d656433aSmrg    {
6178d656433aSmrg      str += len - patlen;
6179300346aeSmrg      if (STREQ (str, pat))
6180d656433aSmrg	*str = '\0';
6181d656433aSmrg    }
6182d656433aSmrg  return str;
6183d656433aSmrg}
6184126a8a12Smrg
6185555991fdSmrgvoid
6186555991fdSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
6187555991fdSmrg{
6188555991fdSmrg  va_list args;
6189555991fdSmrg  if (lt_debug)
6190555991fdSmrg    {
6191555991fdSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6192555991fdSmrg      va_start (args, fmt);
6193555991fdSmrg      (void) vfprintf (stderr, fmt, args);
6194555991fdSmrg      va_end (args);
6195555991fdSmrg    }
6196555991fdSmrg}
6197555991fdSmrg
6198d656433aSmrgstatic void
6199555991fdSmrglt_error_core (int exit_status, const char *file,
6200555991fdSmrg	       int line, const char *mode,
6201d656433aSmrg	       const char *message, va_list ap)
6202d656433aSmrg{
6203555991fdSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
6204d656433aSmrg  vfprintf (stderr, message, ap);
6205d656433aSmrg  fprintf (stderr, ".\n");
6206126a8a12Smrg
6207d656433aSmrg  if (exit_status >= 0)
6208d656433aSmrg    exit (exit_status);
6209d656433aSmrg}
6210126a8a12Smrg
6211d656433aSmrgvoid
6212555991fdSmrglt_fatal (const char *file, int line, const char *message, ...)
6213d656433aSmrg{
6214d656433aSmrg  va_list ap;
6215d656433aSmrg  va_start (ap, message);
6216555991fdSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
6217d656433aSmrg  va_end (ap);
6218d656433aSmrg}
6219126a8a12Smrg
6220555991fdSmrgstatic const char *
6221555991fdSmrgnonnull (const char *s)
6222555991fdSmrg{
6223555991fdSmrg  return s ? s : "(null)";
6224555991fdSmrg}
6225555991fdSmrg
6226555991fdSmrgstatic const char *
6227555991fdSmrgnonempty (const char *s)
6228555991fdSmrg{
6229555991fdSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
6230555991fdSmrg}
6231555991fdSmrg
6232d656433aSmrgvoid
6233d656433aSmrglt_setenv (const char *name, const char *value)
6234d656433aSmrg{
6235555991fdSmrg  lt_debugprintf (__FILE__, __LINE__,
6236555991fdSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
6237555991fdSmrg                  nonnull (name), nonnull (value));
6238d656433aSmrg  {
6239d656433aSmrg#ifdef HAVE_SETENV
6240d656433aSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
6241d656433aSmrg    char *str = xstrdup (value);
6242d656433aSmrg    setenv (name, str, 1);
6243d656433aSmrg#else
6244300346aeSmrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
6245d656433aSmrg    char *str = XMALLOC (char, len);
6246d656433aSmrg    sprintf (str, "%s=%s", name, value);
6247d656433aSmrg    if (putenv (str) != EXIT_SUCCESS)
6248d656433aSmrg      {
6249d656433aSmrg        XFREE (str);
6250d656433aSmrg      }
6251d656433aSmrg#endif
6252d656433aSmrg  }
6253d656433aSmrg}
6254126a8a12Smrg
6255d656433aSmrgchar *
6256d656433aSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
6257d656433aSmrg{
6258d656433aSmrg  char *new_value;
6259d656433aSmrg  if (orig_value && *orig_value)
6260d656433aSmrg    {
6261300346aeSmrg      size_t orig_value_len = strlen (orig_value);
6262300346aeSmrg      size_t add_len = strlen (add);
6263d656433aSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
6264d656433aSmrg      if (to_end)
6265d656433aSmrg        {
6266d656433aSmrg          strcpy (new_value, orig_value);
6267d656433aSmrg          strcpy (new_value + orig_value_len, add);
6268d656433aSmrg        }
6269d656433aSmrg      else
6270d656433aSmrg        {
6271d656433aSmrg          strcpy (new_value, add);
6272d656433aSmrg          strcpy (new_value + add_len, orig_value);
6273d656433aSmrg        }
6274d656433aSmrg    }
6275d656433aSmrg  else
6276d656433aSmrg    {
6277d656433aSmrg      new_value = xstrdup (add);
6278d656433aSmrg    }
6279d656433aSmrg  return new_value;
6280d656433aSmrg}
6281126a8a12Smrg
6282d656433aSmrgvoid
6283d656433aSmrglt_update_exe_path (const char *name, const char *value)
6284d656433aSmrg{
6285555991fdSmrg  lt_debugprintf (__FILE__, __LINE__,
6286555991fdSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6287555991fdSmrg                  nonnull (name), nonnull (value));
6288126a8a12Smrg
6289d656433aSmrg  if (name && *name && value && *value)
6290d656433aSmrg    {
6291d656433aSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
6292d656433aSmrg      /* some systems can't cope with a ':'-terminated path #' */
6293300346aeSmrg      size_t len = strlen (new_value);
6294300346aeSmrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
6295d656433aSmrg        {
6296300346aeSmrg          new_value[--len] = '\0';
6297d656433aSmrg        }
6298d656433aSmrg      lt_setenv (name, new_value);
6299d656433aSmrg      XFREE (new_value);
6300d656433aSmrg    }
6301d656433aSmrg}
6302126a8a12Smrg
6303d656433aSmrgvoid
6304d656433aSmrglt_update_lib_path (const char *name, const char *value)
6305d656433aSmrg{
6306555991fdSmrg  lt_debugprintf (__FILE__, __LINE__,
6307555991fdSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6308555991fdSmrg                  nonnull (name), nonnull (value));
6309126a8a12Smrg
6310d656433aSmrg  if (name && *name && value && *value)
6311d656433aSmrg    {
6312d656433aSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
6313d656433aSmrg      lt_setenv (name, new_value);
6314d656433aSmrg      XFREE (new_value);
6315d656433aSmrg    }
6316d656433aSmrg}
6317126a8a12Smrg
6318555991fdSmrgEOF
6319555991fdSmrg	    case $host_os in
6320555991fdSmrg	      mingw*)
6321555991fdSmrg		cat <<"EOF"
6322555991fdSmrg
6323555991fdSmrg/* Prepares an argument vector before calling spawn().
6324555991fdSmrg   Note that spawn() does not by itself call the command interpreter
6325555991fdSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6326555991fdSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6327555991fdSmrg         GetVersionEx(&v);
6328555991fdSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6329555991fdSmrg      }) ? "cmd.exe" : "command.com").
6330555991fdSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
6331555991fdSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
6332555991fdSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6333555991fdSmrg   special way:
6334555991fdSmrg   - Space and tab are interpreted as delimiters. They are not treated as
6335555991fdSmrg     delimiters if they are surrounded by double quotes: "...".
6336555991fdSmrg   - Unescaped double quotes are removed from the input. Their only effect is
6337555991fdSmrg     that within double quotes, space and tab are treated like normal
6338555991fdSmrg     characters.
6339555991fdSmrg   - Backslashes not followed by double quotes are not special.
6340555991fdSmrg   - But 2*n+1 backslashes followed by a double quote become
6341555991fdSmrg     n backslashes followed by a double quote (n >= 0):
6342555991fdSmrg       \" -> "
6343555991fdSmrg       \\\" -> \"
6344555991fdSmrg       \\\\\" -> \\"
6345555991fdSmrg */
6346555991fdSmrg#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"
6347555991fdSmrg#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"
6348555991fdSmrgchar **
6349555991fdSmrgprepare_spawn (char **argv)
6350555991fdSmrg{
6351555991fdSmrg  size_t argc;
6352555991fdSmrg  char **new_argv;
6353555991fdSmrg  size_t i;
6354555991fdSmrg
6355555991fdSmrg  /* Count number of arguments.  */
6356555991fdSmrg  for (argc = 0; argv[argc] != NULL; argc++)
6357555991fdSmrg    ;
6358555991fdSmrg
6359555991fdSmrg  /* Allocate new argument vector.  */
6360555991fdSmrg  new_argv = XMALLOC (char *, argc + 1);
6361555991fdSmrg
6362555991fdSmrg  /* Put quoted arguments into the new argument vector.  */
6363555991fdSmrg  for (i = 0; i < argc; i++)
6364555991fdSmrg    {
6365555991fdSmrg      const char *string = argv[i];
6366555991fdSmrg
6367555991fdSmrg      if (string[0] == '\0')
6368555991fdSmrg	new_argv[i] = xstrdup ("\"\"");
6369555991fdSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6370555991fdSmrg	{
6371555991fdSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6372555991fdSmrg	  size_t length;
6373555991fdSmrg	  unsigned int backslashes;
6374555991fdSmrg	  const char *s;
6375555991fdSmrg	  char *quoted_string;
6376555991fdSmrg	  char *p;
6377555991fdSmrg
6378555991fdSmrg	  length = 0;
6379555991fdSmrg	  backslashes = 0;
6380555991fdSmrg	  if (quote_around)
6381555991fdSmrg	    length++;
6382555991fdSmrg	  for (s = string; *s != '\0'; s++)
6383555991fdSmrg	    {
6384555991fdSmrg	      char c = *s;
6385555991fdSmrg	      if (c == '"')
6386555991fdSmrg		length += backslashes + 1;
6387555991fdSmrg	      length++;
6388555991fdSmrg	      if (c == '\\')
6389555991fdSmrg		backslashes++;
6390555991fdSmrg	      else
6391555991fdSmrg		backslashes = 0;
6392555991fdSmrg	    }
6393555991fdSmrg	  if (quote_around)
6394555991fdSmrg	    length += backslashes + 1;
6395555991fdSmrg
6396555991fdSmrg	  quoted_string = XMALLOC (char, length + 1);
6397555991fdSmrg
6398555991fdSmrg	  p = quoted_string;
6399555991fdSmrg	  backslashes = 0;
6400555991fdSmrg	  if (quote_around)
6401555991fdSmrg	    *p++ = '"';
6402555991fdSmrg	  for (s = string; *s != '\0'; s++)
6403555991fdSmrg	    {
6404555991fdSmrg	      char c = *s;
6405555991fdSmrg	      if (c == '"')
6406555991fdSmrg		{
6407555991fdSmrg		  unsigned int j;
6408555991fdSmrg		  for (j = backslashes + 1; j > 0; j--)
6409555991fdSmrg		    *p++ = '\\';
6410555991fdSmrg		}
6411555991fdSmrg	      *p++ = c;
6412555991fdSmrg	      if (c == '\\')
6413555991fdSmrg		backslashes++;
6414555991fdSmrg	      else
6415555991fdSmrg		backslashes = 0;
6416555991fdSmrg	    }
6417555991fdSmrg	  if (quote_around)
6418555991fdSmrg	    {
6419555991fdSmrg	      unsigned int j;
6420555991fdSmrg	      for (j = backslashes; j > 0; j--)
6421555991fdSmrg		*p++ = '\\';
6422555991fdSmrg	      *p++ = '"';
6423555991fdSmrg	    }
6424555991fdSmrg	  *p = '\0';
6425555991fdSmrg
6426555991fdSmrg	  new_argv[i] = quoted_string;
6427555991fdSmrg	}
6428555991fdSmrg      else
6429555991fdSmrg	new_argv[i] = (char *) string;
6430555991fdSmrg    }
6431555991fdSmrg  new_argv[argc] = NULL;
6432555991fdSmrg
6433555991fdSmrg  return new_argv;
6434555991fdSmrg}
6435555991fdSmrgEOF
6436555991fdSmrg		;;
6437555991fdSmrg	    esac
6438555991fdSmrg
6439555991fdSmrg            cat <<"EOF"
6440555991fdSmrgvoid lt_dump_script (FILE* f)
6441555991fdSmrg{
6442555991fdSmrgEOF
6443555991fdSmrg	    func_emit_wrapper yes |
64440a6b08f8Smrg	      $SED -n -e '
64450a6b08f8Smrgs/^\(.\{79\}\)\(..*\)/\1\
64460a6b08f8Smrg\2/
64470a6b08f8Smrgh
64480a6b08f8Smrgs/\([\\"]\)/\\\1/g
64490a6b08f8Smrgs/$/\\n/
64500a6b08f8Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
64510a6b08f8Smrgg
64520a6b08f8SmrgD'
6453555991fdSmrg            cat <<"EOF"
6454555991fdSmrg}
6455d656433aSmrgEOF
6456d656433aSmrg}
6457d656433aSmrg# end: func_emit_cwrapperexe_src
6458126a8a12Smrg
6459555991fdSmrg# func_win32_import_lib_p ARG
6460555991fdSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
6461555991fdSmrgfunc_win32_import_lib_p ()
6462555991fdSmrg{
6463300346aeSmrg    $debug_cmd
6464300346aeSmrg
6465555991fdSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6466555991fdSmrg    *import*) : ;;
6467555991fdSmrg    *) false ;;
6468555991fdSmrg    esac
6469555991fdSmrg}
6470555991fdSmrg
6471300346aeSmrg# func_suncc_cstd_abi
6472300346aeSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
6473300346aeSmrg# Several compiler flags select an ABI that is incompatible with the
6474300346aeSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
6475300346aeSmrgfunc_suncc_cstd_abi ()
6476300346aeSmrg{
6477300346aeSmrg    $debug_cmd
6478300346aeSmrg
6479300346aeSmrg    case " $compile_command " in
6480300346aeSmrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
6481300346aeSmrg      suncc_use_cstd_abi=no
6482300346aeSmrg      ;;
6483300346aeSmrg    *)
6484300346aeSmrg      suncc_use_cstd_abi=yes
6485300346aeSmrg      ;;
6486300346aeSmrg    esac
6487300346aeSmrg}
6488300346aeSmrg
6489d656433aSmrg# func_mode_link arg...
6490d656433aSmrgfunc_mode_link ()
6491d656433aSmrg{
6492300346aeSmrg    $debug_cmd
6493300346aeSmrg
6494d656433aSmrg    case $host in
6495d656433aSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6496d656433aSmrg      # It is impossible to link a dll without this setting, and
6497d656433aSmrg      # we shouldn't force the makefile maintainer to figure out
6498300346aeSmrg      # what system we are compiling for in order to pass an extra
6499d656433aSmrg      # flag for every libtool invocation.
6500d656433aSmrg      # allow_undefined=no
6501126a8a12Smrg
6502d656433aSmrg      # FIXME: Unfortunately, there are problems with the above when trying
6503300346aeSmrg      # to make a dll that has undefined symbols, in which case not
6504d656433aSmrg      # even a static library is built.  For now, we need to specify
6505d656433aSmrg      # -no-undefined on the libtool link line when we can be certain
6506d656433aSmrg      # that all symbols are satisfied, otherwise we get a static library.
6507d656433aSmrg      allow_undefined=yes
6508d656433aSmrg      ;;
6509d656433aSmrg    *)
6510d656433aSmrg      allow_undefined=yes
6511d656433aSmrg      ;;
6512d656433aSmrg    esac
6513d656433aSmrg    libtool_args=$nonopt
6514d656433aSmrg    base_compile="$nonopt $@"
6515d656433aSmrg    compile_command=$nonopt
6516d656433aSmrg    finalize_command=$nonopt
6517126a8a12Smrg
6518d656433aSmrg    compile_rpath=
6519d656433aSmrg    finalize_rpath=
6520d656433aSmrg    compile_shlibpath=
6521d656433aSmrg    finalize_shlibpath=
6522d656433aSmrg    convenience=
6523d656433aSmrg    old_convenience=
6524d656433aSmrg    deplibs=
6525d656433aSmrg    old_deplibs=
6526d656433aSmrg    compiler_flags=
6527d656433aSmrg    linker_flags=
6528d656433aSmrg    dllsearchpath=
6529d656433aSmrg    lib_search_path=`pwd`
6530d656433aSmrg    inst_prefix_dir=
6531d656433aSmrg    new_inherited_linker_flags=
6532126a8a12Smrg
6533d656433aSmrg    avoid_version=no
6534555991fdSmrg    bindir=
6535d656433aSmrg    dlfiles=
6536d656433aSmrg    dlprefiles=
6537d656433aSmrg    dlself=no
6538d656433aSmrg    export_dynamic=no
6539d656433aSmrg    export_symbols=
6540d656433aSmrg    export_symbols_regex=
6541d656433aSmrg    generated=
6542d656433aSmrg    libobjs=
6543d656433aSmrg    ltlibs=
6544d656433aSmrg    module=no
6545d656433aSmrg    no_install=no
6546d656433aSmrg    objs=
6547300346aeSmrg    os2dllname=
6548d656433aSmrg    non_pic_objects=
6549d656433aSmrg    precious_files_regex=
6550d656433aSmrg    prefer_static_libs=no
6551300346aeSmrg    preload=false
6552d656433aSmrg    prev=
6553d656433aSmrg    prevarg=
6554d656433aSmrg    release=
6555d656433aSmrg    rpath=
6556d656433aSmrg    xrpath=
6557d656433aSmrg    perm_rpath=
6558d656433aSmrg    temp_rpath=
6559d656433aSmrg    thread_safe=no
6560d656433aSmrg    vinfo=
6561d656433aSmrg    vinfo_number=no
6562d656433aSmrg    weak_libs=
6563300346aeSmrg    single_module=$wl-single_module
6564d656433aSmrg    func_infer_tag $base_compile
6565126a8a12Smrg
6566d656433aSmrg    # We need to know -static, to get the right output filenames.
6567d656433aSmrg    for arg
6568d656433aSmrg    do
6569d656433aSmrg      case $arg in
6570d656433aSmrg      -shared)
6571300346aeSmrg	test yes != "$build_libtool_libs" \
6572300346aeSmrg	  && func_fatal_configuration "cannot build a shared library"
6573d656433aSmrg	build_old_libs=no
6574d656433aSmrg	break
6575d656433aSmrg	;;
6576d656433aSmrg      -all-static | -static | -static-libtool-libs)
6577d656433aSmrg	case $arg in
6578d656433aSmrg	-all-static)
6579300346aeSmrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
6580d656433aSmrg	    func_warning "complete static linking is impossible in this configuration"
6581126a8a12Smrg	  fi
6582d656433aSmrg	  if test -n "$link_static_flag"; then
6583d656433aSmrg	    dlopen_self=$dlopen_self_static
6584126a8a12Smrg	  fi
6585d656433aSmrg	  prefer_static_libs=yes
6586126a8a12Smrg	  ;;
6587d656433aSmrg	-static)
6588d656433aSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6589d656433aSmrg	    dlopen_self=$dlopen_self_static
6590d656433aSmrg	  fi
6591d656433aSmrg	  prefer_static_libs=built
6592d656433aSmrg	  ;;
6593d656433aSmrg	-static-libtool-libs)
6594d656433aSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6595d656433aSmrg	    dlopen_self=$dlopen_self_static
6596d656433aSmrg	  fi
6597d656433aSmrg	  prefer_static_libs=yes
6598126a8a12Smrg	  ;;
6599126a8a12Smrg	esac
6600d656433aSmrg	build_libtool_libs=no
6601d656433aSmrg	build_old_libs=yes
6602d656433aSmrg	break
6603d656433aSmrg	;;
6604d656433aSmrg      esac
6605d656433aSmrg    done
6606126a8a12Smrg
6607d656433aSmrg    # See if our shared archives depend on static archives.
6608d656433aSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6609126a8a12Smrg
6610d656433aSmrg    # Go through the arguments, transforming them on the way.
6611d656433aSmrg    while test "$#" -gt 0; do
6612300346aeSmrg      arg=$1
6613d656433aSmrg      shift
6614d656433aSmrg      func_quote_for_eval "$arg"
6615d656433aSmrg      qarg=$func_quote_for_eval_unquoted_result
6616d656433aSmrg      func_append libtool_args " $func_quote_for_eval_result"
6617126a8a12Smrg
6618d656433aSmrg      # If the previous option needs an argument, assign it.
6619d656433aSmrg      if test -n "$prev"; then
6620d656433aSmrg	case $prev in
6621d656433aSmrg	output)
6622d656433aSmrg	  func_append compile_command " @OUTPUT@"
6623d656433aSmrg	  func_append finalize_command " @OUTPUT@"
6624d656433aSmrg	  ;;
6625d656433aSmrg	esac
6626126a8a12Smrg
6627d656433aSmrg	case $prev in
6628555991fdSmrg	bindir)
6629300346aeSmrg	  bindir=$arg
6630555991fdSmrg	  prev=
6631555991fdSmrg	  continue
6632555991fdSmrg	  ;;
6633d656433aSmrg	dlfiles|dlprefiles)
6634300346aeSmrg	  $preload || {
6635d656433aSmrg	    # Add the symbol object into the linking commands.
6636d656433aSmrg	    func_append compile_command " @SYMFILE@"
6637d656433aSmrg	    func_append finalize_command " @SYMFILE@"
6638300346aeSmrg	    preload=:
6639300346aeSmrg	  }
6640d656433aSmrg	  case $arg in
6641d656433aSmrg	  *.la | *.lo) ;;  # We handle these cases below.
6642d656433aSmrg	  force)
6643300346aeSmrg	    if test no = "$dlself"; then
6644d656433aSmrg	      dlself=needless
6645d656433aSmrg	      export_dynamic=yes
6646d656433aSmrg	    fi
6647d656433aSmrg	    prev=
6648d656433aSmrg	    continue
6649d656433aSmrg	    ;;
6650d656433aSmrg	  self)
6651300346aeSmrg	    if test dlprefiles = "$prev"; then
6652d656433aSmrg	      dlself=yes
6653300346aeSmrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
6654d656433aSmrg	      dlself=yes
6655d656433aSmrg	    else
6656d656433aSmrg	      dlself=needless
6657d656433aSmrg	      export_dynamic=yes
6658d656433aSmrg	    fi
6659d656433aSmrg	    prev=
6660d656433aSmrg	    continue
6661126a8a12Smrg	    ;;
6662126a8a12Smrg	  *)
6663300346aeSmrg	    if test dlfiles = "$prev"; then
66643c15da26Smrg	      func_append dlfiles " $arg"
6665d656433aSmrg	    else
66663c15da26Smrg	      func_append dlprefiles " $arg"
6667d656433aSmrg	    fi
6668d656433aSmrg	    prev=
6669d656433aSmrg	    continue
6670126a8a12Smrg	    ;;
6671126a8a12Smrg	  esac
6672d656433aSmrg	  ;;
6673d656433aSmrg	expsyms)
6674300346aeSmrg	  export_symbols=$arg
6675d656433aSmrg	  test -f "$arg" \
6676300346aeSmrg	    || func_fatal_error "symbol file '$arg' does not exist"
6677d656433aSmrg	  prev=
6678d656433aSmrg	  continue
6679d656433aSmrg	  ;;
6680d656433aSmrg	expsyms_regex)
6681300346aeSmrg	  export_symbols_regex=$arg
6682d656433aSmrg	  prev=
6683d656433aSmrg	  continue
6684d656433aSmrg	  ;;
6685d656433aSmrg	framework)
6686d656433aSmrg	  case $host in
6687d656433aSmrg	    *-*-darwin*)
6688d656433aSmrg	      case "$deplibs " in
6689d656433aSmrg		*" $qarg.ltframework "*) ;;
66903c15da26Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
6691d656433aSmrg		   ;;
6692d656433aSmrg	      esac
6693d656433aSmrg	      ;;
6694d656433aSmrg	  esac
6695d656433aSmrg	  prev=
6696d656433aSmrg	  continue
6697d656433aSmrg	  ;;
6698d656433aSmrg	inst_prefix)
6699300346aeSmrg	  inst_prefix_dir=$arg
6700300346aeSmrg	  prev=
6701300346aeSmrg	  continue
6702300346aeSmrg	  ;;
6703300346aeSmrg	mllvm)
6704300346aeSmrg	  # Clang does not use LLVM to link, so we can simply discard any
6705300346aeSmrg	  # '-mllvm $arg' options when doing the link step.
6706d656433aSmrg	  prev=
6707d656433aSmrg	  continue
6708d656433aSmrg	  ;;
6709d656433aSmrg	objectlist)
6710d656433aSmrg	  if test -f "$arg"; then
6711d656433aSmrg	    save_arg=$arg
6712d656433aSmrg	    moreargs=
6713d656433aSmrg	    for fil in `cat "$save_arg"`
6714d656433aSmrg	    do
67153c15da26Smrg#	      func_append moreargs " $fil"
6716d656433aSmrg	      arg=$fil
6717d656433aSmrg	      # A libtool-controlled object.
6718126a8a12Smrg
6719d656433aSmrg	      # Check to see that this really is a libtool object.
6720d656433aSmrg	      if func_lalib_unsafe_p "$arg"; then
6721d656433aSmrg		pic_object=
6722d656433aSmrg		non_pic_object=
6723126a8a12Smrg
6724d656433aSmrg		# Read the .lo file
6725d656433aSmrg		func_source "$arg"
6726126a8a12Smrg
6727d656433aSmrg		if test -z "$pic_object" ||
6728d656433aSmrg		   test -z "$non_pic_object" ||
6729300346aeSmrg		   test none = "$pic_object" &&
6730300346aeSmrg		   test none = "$non_pic_object"; then
6731300346aeSmrg		  func_fatal_error "cannot find name of object for '$arg'"
6732d656433aSmrg		fi
6733126a8a12Smrg
6734d656433aSmrg		# Extract subdirectory from the argument.
6735d656433aSmrg		func_dirname "$arg" "/" ""
6736300346aeSmrg		xdir=$func_dirname_result
6737126a8a12Smrg
6738300346aeSmrg		if test none != "$pic_object"; then
6739d656433aSmrg		  # Prepend the subdirectory the object is found in.
6740300346aeSmrg		  pic_object=$xdir$pic_object
6741126a8a12Smrg
6742300346aeSmrg		  if test dlfiles = "$prev"; then
6743300346aeSmrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
67443c15da26Smrg		      func_append dlfiles " $pic_object"
6745d656433aSmrg		      prev=
6746d656433aSmrg		      continue
6747d656433aSmrg		    else
6748d656433aSmrg		      # If libtool objects are unsupported, then we need to preload.
6749d656433aSmrg		      prev=dlprefiles
6750d656433aSmrg		    fi
6751d656433aSmrg		  fi
6752126a8a12Smrg
6753d656433aSmrg		  # CHECK ME:  I think I busted this.  -Ossama
6754300346aeSmrg		  if test dlprefiles = "$prev"; then
6755d656433aSmrg		    # Preload the old-style object.
67563c15da26Smrg		    func_append dlprefiles " $pic_object"
6757d656433aSmrg		    prev=
6758d656433aSmrg		  fi
6759126a8a12Smrg
6760d656433aSmrg		  # A PIC object.
6761d656433aSmrg		  func_append libobjs " $pic_object"
6762300346aeSmrg		  arg=$pic_object
6763d656433aSmrg		fi
6764126a8a12Smrg
6765d656433aSmrg		# Non-PIC object.
6766300346aeSmrg		if test none != "$non_pic_object"; then
6767d656433aSmrg		  # Prepend the subdirectory the object is found in.
6768300346aeSmrg		  non_pic_object=$xdir$non_pic_object
6769126a8a12Smrg
6770d656433aSmrg		  # A standard non-PIC object
6771d656433aSmrg		  func_append non_pic_objects " $non_pic_object"
6772300346aeSmrg		  if test -z "$pic_object" || test none = "$pic_object"; then
6773300346aeSmrg		    arg=$non_pic_object
6774d656433aSmrg		  fi
6775d656433aSmrg		else
6776d656433aSmrg		  # If the PIC object exists, use it instead.
6777d656433aSmrg		  # $xdir was prepended to $pic_object above.
6778300346aeSmrg		  non_pic_object=$pic_object
6779d656433aSmrg		  func_append non_pic_objects " $non_pic_object"
6780d656433aSmrg		fi
6781d656433aSmrg	      else
6782d656433aSmrg		# Only an error if not doing a dry-run.
6783d656433aSmrg		if $opt_dry_run; then
6784d656433aSmrg		  # Extract subdirectory from the argument.
6785d656433aSmrg		  func_dirname "$arg" "/" ""
6786300346aeSmrg		  xdir=$func_dirname_result
6787d656433aSmrg
6788d656433aSmrg		  func_lo2o "$arg"
6789d656433aSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
6790d656433aSmrg		  non_pic_object=$xdir$func_lo2o_result
6791d656433aSmrg		  func_append libobjs " $pic_object"
6792d656433aSmrg		  func_append non_pic_objects " $non_pic_object"
6793d656433aSmrg	        else
6794300346aeSmrg		  func_fatal_error "'$arg' is not a valid libtool object"
6795d656433aSmrg		fi
6796d656433aSmrg	      fi
6797d656433aSmrg	    done
6798d656433aSmrg	  else
6799300346aeSmrg	    func_fatal_error "link input file '$arg' does not exist"
6800d656433aSmrg	  fi
6801d656433aSmrg	  arg=$save_arg
6802d656433aSmrg	  prev=
6803d656433aSmrg	  continue
6804d656433aSmrg	  ;;
6805300346aeSmrg	os2dllname)
6806300346aeSmrg	  os2dllname=$arg
6807300346aeSmrg	  prev=
6808300346aeSmrg	  continue
6809300346aeSmrg	  ;;
6810d656433aSmrg	precious_regex)
6811300346aeSmrg	  precious_files_regex=$arg
6812d656433aSmrg	  prev=
6813d656433aSmrg	  continue
6814d656433aSmrg	  ;;
6815d656433aSmrg	release)
6816300346aeSmrg	  release=-$arg
6817d656433aSmrg	  prev=
6818d656433aSmrg	  continue
6819d656433aSmrg	  ;;
6820d656433aSmrg	rpath | xrpath)
6821d656433aSmrg	  # We need an absolute path.
6822d656433aSmrg	  case $arg in
6823d656433aSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
6824d656433aSmrg	  *)
6825d656433aSmrg	    func_fatal_error "only absolute run-paths are allowed"
6826d656433aSmrg	    ;;
6827d656433aSmrg	  esac
6828300346aeSmrg	  if test rpath = "$prev"; then
6829d656433aSmrg	    case "$rpath " in
6830d656433aSmrg	    *" $arg "*) ;;
68313c15da26Smrg	    *) func_append rpath " $arg" ;;
6832d656433aSmrg	    esac
6833d656433aSmrg	  else
6834d656433aSmrg	    case "$xrpath " in
6835d656433aSmrg	    *" $arg "*) ;;
68363c15da26Smrg	    *) func_append xrpath " $arg" ;;
6837d656433aSmrg	    esac
6838d656433aSmrg	  fi
6839d656433aSmrg	  prev=
6840d656433aSmrg	  continue
6841d656433aSmrg	  ;;
6842d656433aSmrg	shrext)
6843300346aeSmrg	  shrext_cmds=$arg
6844d656433aSmrg	  prev=
6845d656433aSmrg	  continue
6846d656433aSmrg	  ;;
6847d656433aSmrg	weak)
68483c15da26Smrg	  func_append weak_libs " $arg"
6849d656433aSmrg	  prev=
6850d656433aSmrg	  continue
6851d656433aSmrg	  ;;
6852d656433aSmrg	xcclinker)
68533c15da26Smrg	  func_append linker_flags " $qarg"
68543c15da26Smrg	  func_append compiler_flags " $qarg"
6855d656433aSmrg	  prev=
6856d656433aSmrg	  func_append compile_command " $qarg"
6857d656433aSmrg	  func_append finalize_command " $qarg"
6858d656433aSmrg	  continue
6859d656433aSmrg	  ;;
6860d656433aSmrg	xcompiler)
68613c15da26Smrg	  func_append compiler_flags " $qarg"
6862d656433aSmrg	  prev=
6863d656433aSmrg	  func_append compile_command " $qarg"
6864d656433aSmrg	  func_append finalize_command " $qarg"
6865d656433aSmrg	  continue
6866d656433aSmrg	  ;;
6867d656433aSmrg	xlinker)
68683c15da26Smrg	  func_append linker_flags " $qarg"
68693c15da26Smrg	  func_append compiler_flags " $wl$qarg"
6870d656433aSmrg	  prev=
6871d656433aSmrg	  func_append compile_command " $wl$qarg"
6872d656433aSmrg	  func_append finalize_command " $wl$qarg"
6873d656433aSmrg	  continue
6874d656433aSmrg	  ;;
6875d656433aSmrg	*)
6876d656433aSmrg	  eval "$prev=\"\$arg\""
6877d656433aSmrg	  prev=
6878d656433aSmrg	  continue
6879d656433aSmrg	  ;;
6880126a8a12Smrg	esac
6881d656433aSmrg      fi # test -n "$prev"
6882126a8a12Smrg
6883300346aeSmrg      prevarg=$arg
6884126a8a12Smrg
6885d656433aSmrg      case $arg in
6886d656433aSmrg      -all-static)
6887d656433aSmrg	if test -n "$link_static_flag"; then
6888d656433aSmrg	  # See comment for -static flag below, for more details.
6889d656433aSmrg	  func_append compile_command " $link_static_flag"
6890d656433aSmrg	  func_append finalize_command " $link_static_flag"
6891d656433aSmrg	fi
6892d656433aSmrg	continue
6893d656433aSmrg	;;
6894126a8a12Smrg
6895d656433aSmrg      -allow-undefined)
6896d656433aSmrg	# FIXME: remove this flag sometime in the future.
6897300346aeSmrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
6898d656433aSmrg	;;
6899126a8a12Smrg
6900d656433aSmrg      -avoid-version)
6901d656433aSmrg	avoid_version=yes
6902d656433aSmrg	continue
6903d656433aSmrg	;;
6904126a8a12Smrg
6905555991fdSmrg      -bindir)
6906555991fdSmrg	prev=bindir
6907555991fdSmrg	continue
6908555991fdSmrg	;;
6909555991fdSmrg
6910d656433aSmrg      -dlopen)
6911d656433aSmrg	prev=dlfiles
6912d656433aSmrg	continue
6913d656433aSmrg	;;
6914126a8a12Smrg
6915d656433aSmrg      -dlpreopen)
6916d656433aSmrg	prev=dlprefiles
6917d656433aSmrg	continue
6918d656433aSmrg	;;
6919126a8a12Smrg
6920d656433aSmrg      -export-dynamic)
6921d656433aSmrg	export_dynamic=yes
6922d656433aSmrg	continue
6923d656433aSmrg	;;
6924126a8a12Smrg
6925d656433aSmrg      -export-symbols | -export-symbols-regex)
6926d656433aSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
6927d656433aSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
6928d656433aSmrg	fi
6929300346aeSmrg	if test X-export-symbols = "X$arg"; then
6930d656433aSmrg	  prev=expsyms
6931d656433aSmrg	else
6932d656433aSmrg	  prev=expsyms_regex
6933d656433aSmrg	fi
6934d656433aSmrg	continue
6935d656433aSmrg	;;
6936126a8a12Smrg
6937d656433aSmrg      -framework)
6938d656433aSmrg	prev=framework
6939d656433aSmrg	continue
6940d656433aSmrg	;;
6941126a8a12Smrg
6942d656433aSmrg      -inst-prefix-dir)
6943d656433aSmrg	prev=inst_prefix
6944d656433aSmrg	continue
6945d656433aSmrg	;;
6946126a8a12Smrg
6947d656433aSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
6948d656433aSmrg      # so, if we see these flags be careful not to treat them like -L
6949d656433aSmrg      -L[A-Z][A-Z]*:*)
6950d656433aSmrg	case $with_gcc/$host in
6951d656433aSmrg	no/*-*-irix* | /*-*-irix*)
6952d656433aSmrg	  func_append compile_command " $arg"
6953d656433aSmrg	  func_append finalize_command " $arg"
6954d656433aSmrg	  ;;
6955d656433aSmrg	esac
6956d656433aSmrg	continue
6957d656433aSmrg	;;
6958126a8a12Smrg
6959d656433aSmrg      -L*)
69603c15da26Smrg	func_stripname "-L" '' "$arg"
69613c15da26Smrg	if test -z "$func_stripname_result"; then
6962d656433aSmrg	  if test "$#" -gt 0; then
6963300346aeSmrg	    func_fatal_error "require no space between '-L' and '$1'"
6964d656433aSmrg	  else
6965300346aeSmrg	    func_fatal_error "need path for '-L' option"
6966d656433aSmrg	  fi
6967d656433aSmrg	fi
69683c15da26Smrg	func_resolve_sysroot "$func_stripname_result"
69693c15da26Smrg	dir=$func_resolve_sysroot_result
6970d656433aSmrg	# We need an absolute path.
6971d656433aSmrg	case $dir in
6972d656433aSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
6973d656433aSmrg	*)
6974d656433aSmrg	  absdir=`cd "$dir" && pwd`
6975d656433aSmrg	  test -z "$absdir" && \
6976300346aeSmrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
6977300346aeSmrg	  dir=$absdir
6978d656433aSmrg	  ;;
6979d656433aSmrg	esac
6980d656433aSmrg	case "$deplibs " in
69813c15da26Smrg	*" -L$dir "* | *" $arg "*)
69823c15da26Smrg	  # Will only happen for absolute or sysroot arguments
69833c15da26Smrg	  ;;
6984d656433aSmrg	*)
69853c15da26Smrg	  # Preserve sysroot, but never include relative directories
69863c15da26Smrg	  case $dir in
69873c15da26Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
69883c15da26Smrg	    *) func_append deplibs " -L$dir" ;;
69893c15da26Smrg	  esac
69903c15da26Smrg	  func_append lib_search_path " $dir"
6991d656433aSmrg	  ;;
6992d656433aSmrg	esac
6993d656433aSmrg	case $host in
6994d656433aSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6995555991fdSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
6996d656433aSmrg	  case :$dllsearchpath: in
6997d656433aSmrg	  *":$dir:"*) ;;
6998d656433aSmrg	  ::) dllsearchpath=$dir;;
69993c15da26Smrg	  *) func_append dllsearchpath ":$dir";;
7000d656433aSmrg	  esac
7001d656433aSmrg	  case :$dllsearchpath: in
7002d656433aSmrg	  *":$testbindir:"*) ;;
7003d656433aSmrg	  ::) dllsearchpath=$testbindir;;
70043c15da26Smrg	  *) func_append dllsearchpath ":$testbindir";;
7005d656433aSmrg	  esac
7006d656433aSmrg	  ;;
7007d656433aSmrg	esac
7008d656433aSmrg	continue
7009d656433aSmrg	;;
7010126a8a12Smrg
7011d656433aSmrg      -l*)
7012300346aeSmrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
7013d656433aSmrg	  case $host in
7014555991fdSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
7015d656433aSmrg	    # These systems don't actually have a C or math library (as such)
7016d656433aSmrg	    continue
7017d656433aSmrg	    ;;
7018d656433aSmrg	  *-*-os2*)
7019d656433aSmrg	    # These systems don't actually have a C library (as such)
7020300346aeSmrg	    test X-lc = "X$arg" && continue
7021d656433aSmrg	    ;;
7022300346aeSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7023d656433aSmrg	    # Do not include libc due to us having libc/libc_r.
7024300346aeSmrg	    test X-lc = "X$arg" && continue
7025d656433aSmrg	    ;;
7026d656433aSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
7027d656433aSmrg	    # Rhapsody C and math libraries are in the System framework
70283c15da26Smrg	    func_append deplibs " System.ltframework"
7029d656433aSmrg	    continue
7030d656433aSmrg	    ;;
7031d656433aSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7032d656433aSmrg	    # Causes problems with __ctype
7033300346aeSmrg	    test X-lc = "X$arg" && continue
7034d656433aSmrg	    ;;
7035d656433aSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7036d656433aSmrg	    # Compiler inserts libc in the correct place for threads to work
7037300346aeSmrg	    test X-lc = "X$arg" && continue
7038d656433aSmrg	    ;;
7039d656433aSmrg	  esac
7040300346aeSmrg	elif test X-lc_r = "X$arg"; then
7041d656433aSmrg	 case $host in
7042300346aeSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7043d656433aSmrg	   # Do not include libc_r directly, use -pthread flag.
7044d656433aSmrg	   continue
7045d656433aSmrg	   ;;
7046d656433aSmrg	 esac
7047d656433aSmrg	fi
70483c15da26Smrg	func_append deplibs " $arg"
7049d656433aSmrg	continue
7050d656433aSmrg	;;
7051126a8a12Smrg
7052300346aeSmrg      -mllvm)
7053300346aeSmrg	prev=mllvm
7054300346aeSmrg	continue
7055300346aeSmrg	;;
7056300346aeSmrg
7057d656433aSmrg      -module)
7058d656433aSmrg	module=yes
7059d656433aSmrg	continue
7060d656433aSmrg	;;
7061126a8a12Smrg
7062d656433aSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
7063d656433aSmrg      # classes, name mangling, and exception handling.
7064d656433aSmrg      # Darwin uses the -arch flag to determine output architecture.
70653c15da26Smrg      -model|-arch|-isysroot|--sysroot)
70663c15da26Smrg	func_append compiler_flags " $arg"
7067d656433aSmrg	func_append compile_command " $arg"
7068d656433aSmrg	func_append finalize_command " $arg"
7069d656433aSmrg	prev=xcompiler
7070d656433aSmrg	continue
7071d656433aSmrg	;;
7072126a8a12Smrg
70730a6b08f8Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
70740a6b08f8Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
70753c15da26Smrg	func_append compiler_flags " $arg"
7076d656433aSmrg	func_append compile_command " $arg"
7077d656433aSmrg	func_append finalize_command " $arg"
7078d656433aSmrg	case "$new_inherited_linker_flags " in
7079d656433aSmrg	    *" $arg "*) ;;
70803c15da26Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
7081d656433aSmrg	esac
7082d656433aSmrg	continue
7083d656433aSmrg	;;
7084126a8a12Smrg
7085d656433aSmrg      -multi_module)
7086300346aeSmrg	single_module=$wl-multi_module
7087d656433aSmrg	continue
7088d656433aSmrg	;;
7089126a8a12Smrg
7090d656433aSmrg      -no-fast-install)
7091d656433aSmrg	fast_install=no
7092d656433aSmrg	continue
7093d656433aSmrg	;;
7094126a8a12Smrg
7095d656433aSmrg      -no-install)
7096d656433aSmrg	case $host in
7097d656433aSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
7098d656433aSmrg	  # The PATH hackery in wrapper scripts is required on Windows
7099d656433aSmrg	  # and Darwin in order for the loader to find any dlls it needs.
7100300346aeSmrg	  func_warning "'-no-install' is ignored for $host"
7101300346aeSmrg	  func_warning "assuming '-no-fast-install' instead"
7102d656433aSmrg	  fast_install=no
7103d656433aSmrg	  ;;
7104d656433aSmrg	*) no_install=yes ;;
7105d656433aSmrg	esac
7106d656433aSmrg	continue
7107d656433aSmrg	;;
7108126a8a12Smrg
7109d656433aSmrg      -no-undefined)
7110d656433aSmrg	allow_undefined=no
7111d656433aSmrg	continue
7112d656433aSmrg	;;
7113126a8a12Smrg
7114d656433aSmrg      -objectlist)
7115d656433aSmrg	prev=objectlist
7116d656433aSmrg	continue
7117d656433aSmrg	;;
7118126a8a12Smrg
7119300346aeSmrg      -os2dllname)
7120300346aeSmrg	prev=os2dllname
7121300346aeSmrg	continue
7122300346aeSmrg	;;
7123300346aeSmrg
7124d656433aSmrg      -o) prev=output ;;
7125126a8a12Smrg
7126d656433aSmrg      -precious-files-regex)
7127d656433aSmrg	prev=precious_regex
7128d656433aSmrg	continue
7129d656433aSmrg	;;
7130126a8a12Smrg
7131d656433aSmrg      -release)
7132d656433aSmrg	prev=release
7133d656433aSmrg	continue
7134d656433aSmrg	;;
7135126a8a12Smrg
7136d656433aSmrg      -rpath)
7137d656433aSmrg	prev=rpath
7138d656433aSmrg	continue
7139d656433aSmrg	;;
7140126a8a12Smrg
7141d656433aSmrg      -R)
7142d656433aSmrg	prev=xrpath
7143d656433aSmrg	continue
7144d656433aSmrg	;;
7145126a8a12Smrg
7146d656433aSmrg      -R*)
7147d656433aSmrg	func_stripname '-R' '' "$arg"
7148d656433aSmrg	dir=$func_stripname_result
7149d656433aSmrg	# We need an absolute path.
7150d656433aSmrg	case $dir in
7151d656433aSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
71523c15da26Smrg	=*)
71533c15da26Smrg	  func_stripname '=' '' "$dir"
71543c15da26Smrg	  dir=$lt_sysroot$func_stripname_result
71553c15da26Smrg	  ;;
7156d656433aSmrg	*)
7157d656433aSmrg	  func_fatal_error "only absolute run-paths are allowed"
7158d656433aSmrg	  ;;
7159d656433aSmrg	esac
7160d656433aSmrg	case "$xrpath " in
7161d656433aSmrg	*" $dir "*) ;;
71623c15da26Smrg	*) func_append xrpath " $dir" ;;
7163d656433aSmrg	esac
7164d656433aSmrg	continue
7165d656433aSmrg	;;
7166126a8a12Smrg
7167d656433aSmrg      -shared)
7168d656433aSmrg	# The effects of -shared are defined in a previous loop.
7169d656433aSmrg	continue
7170d656433aSmrg	;;
7171126a8a12Smrg
7172d656433aSmrg      -shrext)
7173d656433aSmrg	prev=shrext
7174d656433aSmrg	continue
7175d656433aSmrg	;;
7176126a8a12Smrg
7177d656433aSmrg      -static | -static-libtool-libs)
7178d656433aSmrg	# The effects of -static are defined in a previous loop.
7179d656433aSmrg	# We used to do the same as -all-static on platforms that
7180d656433aSmrg	# didn't have a PIC flag, but the assumption that the effects
7181d656433aSmrg	# would be equivalent was wrong.  It would break on at least
7182d656433aSmrg	# Digital Unix and AIX.
7183d656433aSmrg	continue
7184d656433aSmrg	;;
7185126a8a12Smrg
7186d656433aSmrg      -thread-safe)
7187d656433aSmrg	thread_safe=yes
7188d656433aSmrg	continue
7189d656433aSmrg	;;
7190126a8a12Smrg
7191d656433aSmrg      -version-info)
7192d656433aSmrg	prev=vinfo
7193d656433aSmrg	continue
7194d656433aSmrg	;;
7195126a8a12Smrg
7196d656433aSmrg      -version-number)
7197d656433aSmrg	prev=vinfo
7198d656433aSmrg	vinfo_number=yes
7199d656433aSmrg	continue
7200d656433aSmrg	;;
7201126a8a12Smrg
7202d656433aSmrg      -weak)
7203d656433aSmrg        prev=weak
7204d656433aSmrg	continue
7205d656433aSmrg	;;
7206126a8a12Smrg
7207d656433aSmrg      -Wc,*)
7208d656433aSmrg	func_stripname '-Wc,' '' "$arg"
7209d656433aSmrg	args=$func_stripname_result
7210d656433aSmrg	arg=
7211300346aeSmrg	save_ifs=$IFS; IFS=,
7212d656433aSmrg	for flag in $args; do
7213300346aeSmrg	  IFS=$save_ifs
7214d656433aSmrg          func_quote_for_eval "$flag"
72153c15da26Smrg	  func_append arg " $func_quote_for_eval_result"
72163c15da26Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
7217d656433aSmrg	done
7218300346aeSmrg	IFS=$save_ifs
7219d656433aSmrg	func_stripname ' ' '' "$arg"
7220d656433aSmrg	arg=$func_stripname_result
7221d656433aSmrg	;;
7222126a8a12Smrg
7223d656433aSmrg      -Wl,*)
7224d656433aSmrg	func_stripname '-Wl,' '' "$arg"
7225d656433aSmrg	args=$func_stripname_result
7226d656433aSmrg	arg=
7227300346aeSmrg	save_ifs=$IFS; IFS=,
7228d656433aSmrg	for flag in $args; do
7229300346aeSmrg	  IFS=$save_ifs
7230d656433aSmrg          func_quote_for_eval "$flag"
72313c15da26Smrg	  func_append arg " $wl$func_quote_for_eval_result"
72323c15da26Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
72333c15da26Smrg	  func_append linker_flags " $func_quote_for_eval_result"
7234d656433aSmrg	done
7235300346aeSmrg	IFS=$save_ifs
7236d656433aSmrg	func_stripname ' ' '' "$arg"
7237d656433aSmrg	arg=$func_stripname_result
7238d656433aSmrg	;;
7239126a8a12Smrg
7240d656433aSmrg      -Xcompiler)
7241d656433aSmrg	prev=xcompiler
7242d656433aSmrg	continue
7243d656433aSmrg	;;
7244126a8a12Smrg
7245d656433aSmrg      -Xlinker)
7246d656433aSmrg	prev=xlinker
7247d656433aSmrg	continue
7248d656433aSmrg	;;
7249126a8a12Smrg
7250d656433aSmrg      -XCClinker)
7251d656433aSmrg	prev=xcclinker
7252d656433aSmrg	continue
7253d656433aSmrg	;;
7254126a8a12Smrg
7255d656433aSmrg      # -msg_* for osf cc
7256d656433aSmrg      -msg_*)
7257d656433aSmrg	func_quote_for_eval "$arg"
7258300346aeSmrg	arg=$func_quote_for_eval_result
7259d656433aSmrg	;;
7260126a8a12Smrg
7261555991fdSmrg      # Flags to be passed through unchanged, with rationale:
7262555991fdSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
7263555991fdSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
7264555991fdSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7265555991fdSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
7266555991fdSmrg      # -q*                  compiler args for the IBM compiler
7267555991fdSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7268555991fdSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
7269555991fdSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
7270300346aeSmrg      # -fstack-protector*   stack protector flags for GCC
7271555991fdSmrg      # @file                GCC response files
7272555991fdSmrg      # -tp=*                Portland pgcc target processor selection
72733c15da26Smrg      # --sysroot=*          for sysroot support
7274300346aeSmrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
7275300346aeSmrg      # -specs=*             GCC specs files
7276300346aeSmrg      # -stdlib=*            select c++ std lib with clang
7277300346aeSmrg      # -fsanitize=*         Clang/GCC memory and address sanitizer
7278d656433aSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
72793c15da26Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
7280300346aeSmrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
7281300346aeSmrg      -specs=*|-fsanitize=*)
7282d656433aSmrg        func_quote_for_eval "$arg"
7283300346aeSmrg	arg=$func_quote_for_eval_result
7284d656433aSmrg        func_append compile_command " $arg"
7285d656433aSmrg        func_append finalize_command " $arg"
72863c15da26Smrg        func_append compiler_flags " $arg"
7287d656433aSmrg        continue
7288d656433aSmrg        ;;
7289126a8a12Smrg
7290300346aeSmrg      -Z*)
7291300346aeSmrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
7292300346aeSmrg          # OS/2 uses -Zxxx to specify OS/2-specific options
7293300346aeSmrg	  compiler_flags="$compiler_flags $arg"
7294300346aeSmrg	  func_append compile_command " $arg"
7295300346aeSmrg	  func_append finalize_command " $arg"
7296300346aeSmrg	  case $arg in
7297300346aeSmrg	  -Zlinker | -Zstack)
7298300346aeSmrg	    prev=xcompiler
7299300346aeSmrg	    ;;
7300300346aeSmrg	  esac
7301300346aeSmrg	  continue
7302300346aeSmrg        else
7303300346aeSmrg	  # Otherwise treat like 'Some other compiler flag' below
7304300346aeSmrg	  func_quote_for_eval "$arg"
7305300346aeSmrg	  arg=$func_quote_for_eval_result
7306300346aeSmrg        fi
7307300346aeSmrg	;;
7308300346aeSmrg
7309d656433aSmrg      # Some other compiler flag.
7310d656433aSmrg      -* | +*)
7311d656433aSmrg        func_quote_for_eval "$arg"
7312300346aeSmrg	arg=$func_quote_for_eval_result
7313d656433aSmrg	;;
7314126a8a12Smrg
7315d656433aSmrg      *.$objext)
7316d656433aSmrg	# A standard object.
73173c15da26Smrg	func_append objs " $arg"
7318d656433aSmrg	;;
7319d656433aSmrg
7320d656433aSmrg      *.lo)
7321d656433aSmrg	# A libtool-controlled object.
7322d656433aSmrg
7323d656433aSmrg	# Check to see that this really is a libtool object.
7324d656433aSmrg	if func_lalib_unsafe_p "$arg"; then
7325d656433aSmrg	  pic_object=
7326d656433aSmrg	  non_pic_object=
7327d656433aSmrg
7328d656433aSmrg	  # Read the .lo file
7329d656433aSmrg	  func_source "$arg"
7330d656433aSmrg
7331d656433aSmrg	  if test -z "$pic_object" ||
7332d656433aSmrg	     test -z "$non_pic_object" ||
7333300346aeSmrg	     test none = "$pic_object" &&
7334300346aeSmrg	     test none = "$non_pic_object"; then
7335300346aeSmrg	    func_fatal_error "cannot find name of object for '$arg'"
7336d656433aSmrg	  fi
7337d656433aSmrg
7338d656433aSmrg	  # Extract subdirectory from the argument.
7339d656433aSmrg	  func_dirname "$arg" "/" ""
7340300346aeSmrg	  xdir=$func_dirname_result
7341d656433aSmrg
7342300346aeSmrg	  test none = "$pic_object" || {
7343d656433aSmrg	    # Prepend the subdirectory the object is found in.
7344300346aeSmrg	    pic_object=$xdir$pic_object
7345d656433aSmrg
7346300346aeSmrg	    if test dlfiles = "$prev"; then
7347300346aeSmrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
73483c15da26Smrg		func_append dlfiles " $pic_object"
7349d656433aSmrg		prev=
7350d656433aSmrg		continue
7351d656433aSmrg	      else
7352d656433aSmrg		# If libtool objects are unsupported, then we need to preload.
7353d656433aSmrg		prev=dlprefiles
7354d656433aSmrg	      fi
7355d656433aSmrg	    fi
7356d656433aSmrg
7357d656433aSmrg	    # CHECK ME:  I think I busted this.  -Ossama
7358300346aeSmrg	    if test dlprefiles = "$prev"; then
7359d656433aSmrg	      # Preload the old-style object.
73603c15da26Smrg	      func_append dlprefiles " $pic_object"
7361d656433aSmrg	      prev=
7362d656433aSmrg	    fi
7363d656433aSmrg
7364d656433aSmrg	    # A PIC object.
7365d656433aSmrg	    func_append libobjs " $pic_object"
7366300346aeSmrg	    arg=$pic_object
7367300346aeSmrg	  }
7368d656433aSmrg
7369d656433aSmrg	  # Non-PIC object.
7370300346aeSmrg	  if test none != "$non_pic_object"; then
7371d656433aSmrg	    # Prepend the subdirectory the object is found in.
7372300346aeSmrg	    non_pic_object=$xdir$non_pic_object
7373d656433aSmrg
7374d656433aSmrg	    # A standard non-PIC object
7375d656433aSmrg	    func_append non_pic_objects " $non_pic_object"
7376300346aeSmrg	    if test -z "$pic_object" || test none = "$pic_object"; then
7377300346aeSmrg	      arg=$non_pic_object
7378d656433aSmrg	    fi
7379d656433aSmrg	  else
7380d656433aSmrg	    # If the PIC object exists, use it instead.
7381d656433aSmrg	    # $xdir was prepended to $pic_object above.
7382300346aeSmrg	    non_pic_object=$pic_object
7383d656433aSmrg	    func_append non_pic_objects " $non_pic_object"
7384d656433aSmrg	  fi
7385d656433aSmrg	else
7386d656433aSmrg	  # Only an error if not doing a dry-run.
7387d656433aSmrg	  if $opt_dry_run; then
7388d656433aSmrg	    # Extract subdirectory from the argument.
7389d656433aSmrg	    func_dirname "$arg" "/" ""
7390300346aeSmrg	    xdir=$func_dirname_result
7391d656433aSmrg
7392d656433aSmrg	    func_lo2o "$arg"
7393d656433aSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
7394d656433aSmrg	    non_pic_object=$xdir$func_lo2o_result
7395d656433aSmrg	    func_append libobjs " $pic_object"
7396d656433aSmrg	    func_append non_pic_objects " $non_pic_object"
7397d656433aSmrg	  else
7398300346aeSmrg	    func_fatal_error "'$arg' is not a valid libtool object"
7399d656433aSmrg	  fi
7400d656433aSmrg	fi
7401d656433aSmrg	;;
7402d656433aSmrg
7403d656433aSmrg      *.$libext)
7404d656433aSmrg	# An archive.
74053c15da26Smrg	func_append deplibs " $arg"
74063c15da26Smrg	func_append old_deplibs " $arg"
7407d656433aSmrg	continue
7408d656433aSmrg	;;
7409d656433aSmrg
7410d656433aSmrg      *.la)
7411d656433aSmrg	# A libtool-controlled library.
7412d656433aSmrg
74133c15da26Smrg	func_resolve_sysroot "$arg"
7414300346aeSmrg	if test dlfiles = "$prev"; then
7415d656433aSmrg	  # This library was specified with -dlopen.
74163c15da26Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
7417d656433aSmrg	  prev=
7418300346aeSmrg	elif test dlprefiles = "$prev"; then
7419d656433aSmrg	  # The library was specified with -dlpreopen.
74203c15da26Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
7421d656433aSmrg	  prev=
7422d656433aSmrg	else
74233c15da26Smrg	  func_append deplibs " $func_resolve_sysroot_result"
7424d656433aSmrg	fi
7425d656433aSmrg	continue
7426d656433aSmrg	;;
7427d656433aSmrg
7428d656433aSmrg      # Some other compiler argument.
7429d656433aSmrg      *)
7430d656433aSmrg	# Unknown arguments in both finalize_command and compile_command need
7431d656433aSmrg	# to be aesthetically quoted because they are evaled later.
7432d656433aSmrg	func_quote_for_eval "$arg"
7433300346aeSmrg	arg=$func_quote_for_eval_result
7434d656433aSmrg	;;
7435d656433aSmrg      esac # arg
7436d656433aSmrg
7437d656433aSmrg      # Now actually substitute the argument into the commands.
7438d656433aSmrg      if test -n "$arg"; then
7439d656433aSmrg	func_append compile_command " $arg"
7440d656433aSmrg	func_append finalize_command " $arg"
7441d656433aSmrg      fi
7442d656433aSmrg    done # argument parsing loop
7443d656433aSmrg
7444d656433aSmrg    test -n "$prev" && \
7445300346aeSmrg      func_fatal_help "the '$prevarg' option requires an argument"
7446d656433aSmrg
7447300346aeSmrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
7448d656433aSmrg      eval arg=\"$export_dynamic_flag_spec\"
7449d656433aSmrg      func_append compile_command " $arg"
7450d656433aSmrg      func_append finalize_command " $arg"
7451d656433aSmrg    fi
7452d656433aSmrg
7453d656433aSmrg    oldlibs=
7454d656433aSmrg    # calculate the name of the file, without its directory
7455d656433aSmrg    func_basename "$output"
7456300346aeSmrg    outputname=$func_basename_result
7457300346aeSmrg    libobjs_save=$libobjs
7458d656433aSmrg
7459d656433aSmrg    if test -n "$shlibpath_var"; then
7460d656433aSmrg      # get the directories listed in $shlibpath_var
7461300346aeSmrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7462126a8a12Smrg    else
7463d656433aSmrg      shlib_search_path=
7464126a8a12Smrg    fi
7465d656433aSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
7466d656433aSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7467126a8a12Smrg
7468300346aeSmrg    # Definition is injected by LT_CONFIG during libtool generation.
7469300346aeSmrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
7470300346aeSmrg
7471d656433aSmrg    func_dirname "$output" "/" ""
7472300346aeSmrg    output_objdir=$func_dirname_result$objdir
74733c15da26Smrg    func_to_tool_file "$output_objdir/"
74743c15da26Smrg    tool_output_objdir=$func_to_tool_file_result
7475d656433aSmrg    # Create the object directory.
7476d656433aSmrg    func_mkdir_p "$output_objdir"
7477126a8a12Smrg
7478d656433aSmrg    # Determine the type of output
7479d656433aSmrg    case $output in
7480d656433aSmrg    "")
7481d656433aSmrg      func_fatal_help "you must specify an output file"
7482d656433aSmrg      ;;
7483d656433aSmrg    *.$libext) linkmode=oldlib ;;
7484d656433aSmrg    *.lo | *.$objext) linkmode=obj ;;
7485d656433aSmrg    *.la) linkmode=lib ;;
7486d656433aSmrg    *) linkmode=prog ;; # Anything else should be a program.
7487d656433aSmrg    esac
7488d656433aSmrg
7489d656433aSmrg    specialdeplibs=
7490d656433aSmrg
7491d656433aSmrg    libs=
7492d656433aSmrg    # Find all interdependent deplibs by searching for libraries
7493d656433aSmrg    # that are linked more than once (e.g. -la -lb -la)
7494d656433aSmrg    for deplib in $deplibs; do
7495300346aeSmrg      if $opt_preserve_dup_deps; then
7496d656433aSmrg	case "$libs " in
74973c15da26Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
7498d656433aSmrg	esac
7499d656433aSmrg      fi
75003c15da26Smrg      func_append libs " $deplib"
7501d656433aSmrg    done
7502d656433aSmrg
7503300346aeSmrg    if test lib = "$linkmode"; then
7504d656433aSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
7505d656433aSmrg
7506d656433aSmrg      # Compute libraries that are listed more than once in $predeps
7507d656433aSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
7508d656433aSmrg      # not to be eliminated).
7509d656433aSmrg      pre_post_deps=
7510d656433aSmrg      if $opt_duplicate_compiler_generated_deps; then
7511d656433aSmrg	for pre_post_dep in $predeps $postdeps; do
7512d656433aSmrg	  case "$pre_post_deps " in
75133c15da26Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
7514d656433aSmrg	  esac
75153c15da26Smrg	  func_append pre_post_deps " $pre_post_dep"
7516d656433aSmrg	done
7517d656433aSmrg      fi
7518d656433aSmrg      pre_post_deps=
7519d656433aSmrg    fi
7520d656433aSmrg
7521d656433aSmrg    deplibs=
7522d656433aSmrg    newdependency_libs=
7523d656433aSmrg    newlib_search_path=
7524d656433aSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
7525d656433aSmrg    notinst_deplibs= # not-installed libtool libraries
7526d656433aSmrg    notinst_path= # paths that contain not-installed libtool libraries
7527d656433aSmrg
7528d656433aSmrg    case $linkmode in
7529d656433aSmrg    lib)
7530d656433aSmrg	passes="conv dlpreopen link"
7531d656433aSmrg	for file in $dlfiles $dlprefiles; do
7532d656433aSmrg	  case $file in
7533d656433aSmrg	  *.la) ;;
7534d656433aSmrg	  *)
7535300346aeSmrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
7536d656433aSmrg	    ;;
7537d656433aSmrg	  esac
7538d656433aSmrg	done
7539d656433aSmrg	;;
7540d656433aSmrg    prog)
7541d656433aSmrg	compile_deplibs=
7542d656433aSmrg	finalize_deplibs=
7543300346aeSmrg	alldeplibs=false
7544d656433aSmrg	newdlfiles=
7545d656433aSmrg	newdlprefiles=
7546d656433aSmrg	passes="conv scan dlopen dlpreopen link"
7547d656433aSmrg	;;
7548d656433aSmrg    *)  passes="conv"
7549d656433aSmrg	;;
7550d656433aSmrg    esac
7551d656433aSmrg
7552d656433aSmrg    for pass in $passes; do
7553d656433aSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
7554d656433aSmrg      # so that -L comes before libs that need it for instance...
7555300346aeSmrg      if test lib,link = "$linkmode,$pass"; then
7556d656433aSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
7557d656433aSmrg	##        order, and fix it there properly
7558d656433aSmrg        tmp_deplibs=
7559d656433aSmrg	for deplib in $deplibs; do
7560d656433aSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
7561d656433aSmrg	done
7562300346aeSmrg	deplibs=$tmp_deplibs
7563d656433aSmrg      fi
7564d656433aSmrg
7565300346aeSmrg      if test lib,link = "$linkmode,$pass" ||
7566300346aeSmrg	 test prog,scan = "$linkmode,$pass"; then
7567300346aeSmrg	libs=$deplibs
7568d656433aSmrg	deplibs=
7569d656433aSmrg      fi
7570300346aeSmrg      if test prog = "$linkmode"; then
7571d656433aSmrg	case $pass in
7572300346aeSmrg	dlopen) libs=$dlfiles ;;
7573300346aeSmrg	dlpreopen) libs=$dlprefiles ;;
7574300346aeSmrg	link)
7575300346aeSmrg	  libs="$deplibs %DEPLIBS%"
7576300346aeSmrg	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
7577300346aeSmrg	  ;;
7578d656433aSmrg	esac
7579d656433aSmrg      fi
7580300346aeSmrg      if test lib,dlpreopen = "$linkmode,$pass"; then
7581d656433aSmrg	# Collect and forward deplibs of preopened libtool libs
7582d656433aSmrg	for lib in $dlprefiles; do
7583d656433aSmrg	  # Ignore non-libtool-libs
7584d656433aSmrg	  dependency_libs=
75853c15da26Smrg	  func_resolve_sysroot "$lib"
7586d656433aSmrg	  case $lib in
75873c15da26Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
7588d656433aSmrg	  esac
7589d656433aSmrg
7590d656433aSmrg	  # Collect preopened libtool deplibs, except any this library
7591d656433aSmrg	  # has declared as weak libs
7592d656433aSmrg	  for deplib in $dependency_libs; do
7593555991fdSmrg	    func_basename "$deplib"
7594555991fdSmrg            deplib_base=$func_basename_result
7595d656433aSmrg	    case " $weak_libs " in
7596d656433aSmrg	    *" $deplib_base "*) ;;
75973c15da26Smrg	    *) func_append deplibs " $deplib" ;;
7598d656433aSmrg	    esac
7599d656433aSmrg	  done
7600d656433aSmrg	done
7601300346aeSmrg	libs=$dlprefiles
7602d656433aSmrg      fi
7603300346aeSmrg      if test dlopen = "$pass"; then
7604d656433aSmrg	# Collect dlpreopened libraries
7605300346aeSmrg	save_deplibs=$deplibs
7606d656433aSmrg	deplibs=
7607d656433aSmrg      fi
7608d656433aSmrg
7609d656433aSmrg      for deplib in $libs; do
7610d656433aSmrg	lib=
7611300346aeSmrg	found=false
7612d656433aSmrg	case $deplib in
76130a6b08f8Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
76140a6b08f8Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7615300346aeSmrg	  if test prog,link = "$linkmode,$pass"; then
7616d656433aSmrg	    compile_deplibs="$deplib $compile_deplibs"
7617d656433aSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
7618d656433aSmrg	  else
76193c15da26Smrg	    func_append compiler_flags " $deplib"
7620300346aeSmrg	    if test lib = "$linkmode"; then
7621d656433aSmrg		case "$new_inherited_linker_flags " in
7622d656433aSmrg		    *" $deplib "*) ;;
76233c15da26Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7624d656433aSmrg		esac
7625d656433aSmrg	    fi
7626d656433aSmrg	  fi
7627d656433aSmrg	  continue
7628d656433aSmrg	  ;;
7629d656433aSmrg	-l*)
7630300346aeSmrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
7631300346aeSmrg	    func_warning "'-l' is ignored for archives/objects"
7632d656433aSmrg	    continue
7633d656433aSmrg	  fi
7634d656433aSmrg	  func_stripname '-l' '' "$deplib"
7635d656433aSmrg	  name=$func_stripname_result
7636300346aeSmrg	  if test lib = "$linkmode"; then
7637d656433aSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
7638d656433aSmrg	  else
7639d656433aSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
7640d656433aSmrg	  fi
7641d656433aSmrg	  for searchdir in $searchdirs; do
7642d656433aSmrg	    for search_ext in .la $std_shrext .so .a; do
7643d656433aSmrg	      # Search the libtool library
7644300346aeSmrg	      lib=$searchdir/lib$name$search_ext
7645d656433aSmrg	      if test -f "$lib"; then
7646300346aeSmrg		if test .la = "$search_ext"; then
7647300346aeSmrg		  found=:
7648d656433aSmrg		else
7649300346aeSmrg		  found=false
7650d656433aSmrg		fi
7651d656433aSmrg		break 2
7652d656433aSmrg	      fi
7653d656433aSmrg	    done
7654d656433aSmrg	  done
7655300346aeSmrg	  if $found; then
7656300346aeSmrg	    # deplib is a libtool library
7657d656433aSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
7658d656433aSmrg	    # We need to do some special things here, and not later.
7659300346aeSmrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
7660d656433aSmrg	      case " $predeps $postdeps " in
7661d656433aSmrg	      *" $deplib "*)
7662d656433aSmrg		if func_lalib_p "$lib"; then
7663d656433aSmrg		  library_names=
7664d656433aSmrg		  old_library=
7665d656433aSmrg		  func_source "$lib"
7666d656433aSmrg		  for l in $old_library $library_names; do
7667300346aeSmrg		    ll=$l
7668d656433aSmrg		  done
7669300346aeSmrg		  if test "X$ll" = "X$old_library"; then # only static version available
7670300346aeSmrg		    found=false
7671d656433aSmrg		    func_dirname "$lib" "" "."
7672300346aeSmrg		    ladir=$func_dirname_result
7673d656433aSmrg		    lib=$ladir/$old_library
7674300346aeSmrg		    if test prog,link = "$linkmode,$pass"; then
7675d656433aSmrg		      compile_deplibs="$deplib $compile_deplibs"
7676d656433aSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
7677d656433aSmrg		    else
7678d656433aSmrg		      deplibs="$deplib $deplibs"
7679300346aeSmrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7680d656433aSmrg		    fi
7681d656433aSmrg		    continue
7682d656433aSmrg		  fi
7683d656433aSmrg		fi
7684d656433aSmrg		;;
7685d656433aSmrg	      *) ;;
7686d656433aSmrg	      esac
7687d656433aSmrg	    fi
7688300346aeSmrg	  else
7689300346aeSmrg	    # deplib doesn't seem to be a libtool library
7690300346aeSmrg	    if test prog,link = "$linkmode,$pass"; then
7691300346aeSmrg	      compile_deplibs="$deplib $compile_deplibs"
7692300346aeSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
7693300346aeSmrg	    else
7694300346aeSmrg	      deplibs="$deplib $deplibs"
7695300346aeSmrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7696300346aeSmrg	    fi
7697300346aeSmrg	    continue
7698d656433aSmrg	  fi
7699d656433aSmrg	  ;; # -l
7700d656433aSmrg	*.ltframework)
7701300346aeSmrg	  if test prog,link = "$linkmode,$pass"; then
7702d656433aSmrg	    compile_deplibs="$deplib $compile_deplibs"
7703d656433aSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
7704d656433aSmrg	  else
7705d656433aSmrg	    deplibs="$deplib $deplibs"
7706300346aeSmrg	    if test lib = "$linkmode"; then
7707d656433aSmrg		case "$new_inherited_linker_flags " in
7708d656433aSmrg		    *" $deplib "*) ;;
77093c15da26Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7710d656433aSmrg		esac
7711d656433aSmrg	    fi
7712d656433aSmrg	  fi
7713d656433aSmrg	  continue
7714d656433aSmrg	  ;;
7715d656433aSmrg	-L*)
7716d656433aSmrg	  case $linkmode in
7717d656433aSmrg	  lib)
7718d656433aSmrg	    deplibs="$deplib $deplibs"
7719300346aeSmrg	    test conv = "$pass" && continue
7720d656433aSmrg	    newdependency_libs="$deplib $newdependency_libs"
7721d656433aSmrg	    func_stripname '-L' '' "$deplib"
77223c15da26Smrg	    func_resolve_sysroot "$func_stripname_result"
77233c15da26Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
7724d656433aSmrg	    ;;
7725d656433aSmrg	  prog)
7726300346aeSmrg	    if test conv = "$pass"; then
7727d656433aSmrg	      deplibs="$deplib $deplibs"
7728d656433aSmrg	      continue
7729d656433aSmrg	    fi
7730300346aeSmrg	    if test scan = "$pass"; then
7731d656433aSmrg	      deplibs="$deplib $deplibs"
7732d656433aSmrg	    else
7733d656433aSmrg	      compile_deplibs="$deplib $compile_deplibs"
7734d656433aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
7735d656433aSmrg	    fi
7736d656433aSmrg	    func_stripname '-L' '' "$deplib"
77373c15da26Smrg	    func_resolve_sysroot "$func_stripname_result"
77383c15da26Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
7739d656433aSmrg	    ;;
7740d656433aSmrg	  *)
7741300346aeSmrg	    func_warning "'-L' is ignored for archives/objects"
7742d656433aSmrg	    ;;
7743d656433aSmrg	  esac # linkmode
7744d656433aSmrg	  continue
7745d656433aSmrg	  ;; # -L
7746d656433aSmrg	-R*)
7747300346aeSmrg	  if test link = "$pass"; then
7748d656433aSmrg	    func_stripname '-R' '' "$deplib"
77493c15da26Smrg	    func_resolve_sysroot "$func_stripname_result"
77503c15da26Smrg	    dir=$func_resolve_sysroot_result
7751d656433aSmrg	    # Make sure the xrpath contains only unique directories.
7752d656433aSmrg	    case "$xrpath " in
7753d656433aSmrg	    *" $dir "*) ;;
77543c15da26Smrg	    *) func_append xrpath " $dir" ;;
7755d656433aSmrg	    esac
7756d656433aSmrg	  fi
7757d656433aSmrg	  deplibs="$deplib $deplibs"
7758d656433aSmrg	  continue
7759d656433aSmrg	  ;;
77603c15da26Smrg	*.la)
77613c15da26Smrg	  func_resolve_sysroot "$deplib"
77623c15da26Smrg	  lib=$func_resolve_sysroot_result
77633c15da26Smrg	  ;;
7764d656433aSmrg	*.$libext)
7765300346aeSmrg	  if test conv = "$pass"; then
7766d656433aSmrg	    deplibs="$deplib $deplibs"
7767d656433aSmrg	    continue
7768d656433aSmrg	  fi
7769d656433aSmrg	  case $linkmode in
7770d656433aSmrg	  lib)
7771d656433aSmrg	    # Linking convenience modules into shared libraries is allowed,
7772d656433aSmrg	    # but linking other static libraries is non-portable.
7773d656433aSmrg	    case " $dlpreconveniencelibs " in
7774d656433aSmrg	    *" $deplib "*) ;;
7775d656433aSmrg	    *)
7776300346aeSmrg	      valid_a_lib=false
7777d656433aSmrg	      case $deplibs_check_method in
7778d656433aSmrg		match_pattern*)
7779d656433aSmrg		  set dummy $deplibs_check_method; shift
7780d656433aSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7781555991fdSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
7782d656433aSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
7783300346aeSmrg		    valid_a_lib=:
7784d656433aSmrg		  fi
7785d656433aSmrg		;;
7786d656433aSmrg		pass_all)
7787300346aeSmrg		  valid_a_lib=:
7788d656433aSmrg		;;
7789d656433aSmrg	      esac
7790300346aeSmrg	      if $valid_a_lib; then
7791300346aeSmrg		echo
7792300346aeSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
7793300346aeSmrg		$ECHO "*** static library $deplib is not portable!"
7794300346aeSmrg		deplibs="$deplib $deplibs"
7795300346aeSmrg	      else
7796555991fdSmrg		echo
7797d656433aSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
7798555991fdSmrg		echo "*** I have the capability to make that library automatically link in when"
7799555991fdSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7800555991fdSmrg		echo "*** shared version of the library, which you do not appear to have"
7801555991fdSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
7802555991fdSmrg		echo "*** that it is just a static archive that I should not use here."
7803d656433aSmrg	      fi
7804d656433aSmrg	      ;;
7805d656433aSmrg	    esac
7806d656433aSmrg	    continue
7807d656433aSmrg	    ;;
7808d656433aSmrg	  prog)
7809300346aeSmrg	    if test link != "$pass"; then
7810d656433aSmrg	      deplibs="$deplib $deplibs"
7811d656433aSmrg	    else
7812d656433aSmrg	      compile_deplibs="$deplib $compile_deplibs"
7813d656433aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
7814d656433aSmrg	    fi
7815d656433aSmrg	    continue
7816d656433aSmrg	    ;;
7817d656433aSmrg	  esac # linkmode
7818d656433aSmrg	  ;; # *.$libext
7819d656433aSmrg	*.lo | *.$objext)
7820300346aeSmrg	  if test conv = "$pass"; then
7821d656433aSmrg	    deplibs="$deplib $deplibs"
7822300346aeSmrg	  elif test prog = "$linkmode"; then
7823300346aeSmrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
7824d656433aSmrg	      # If there is no dlopen support or we're linking statically,
7825d656433aSmrg	      # we need to preload.
78263c15da26Smrg	      func_append newdlprefiles " $deplib"
7827d656433aSmrg	      compile_deplibs="$deplib $compile_deplibs"
7828d656433aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
7829d656433aSmrg	    else
78303c15da26Smrg	      func_append newdlfiles " $deplib"
7831d656433aSmrg	    fi
7832d656433aSmrg	  fi
7833d656433aSmrg	  continue
7834d656433aSmrg	  ;;
7835d656433aSmrg	%DEPLIBS%)
7836300346aeSmrg	  alldeplibs=:
7837d656433aSmrg	  continue
7838d656433aSmrg	  ;;
7839d656433aSmrg	esac # case $deplib
7840d656433aSmrg
7841300346aeSmrg	$found || test -f "$lib" \
7842300346aeSmrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
7843d656433aSmrg
7844d656433aSmrg	# Check to see that this really is a libtool archive.
7845d656433aSmrg	func_lalib_unsafe_p "$lib" \
7846300346aeSmrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
7847d656433aSmrg
7848d656433aSmrg	func_dirname "$lib" "" "."
7849300346aeSmrg	ladir=$func_dirname_result
7850d656433aSmrg
7851d656433aSmrg	dlname=
7852d656433aSmrg	dlopen=
7853d656433aSmrg	dlpreopen=
7854d656433aSmrg	libdir=
7855d656433aSmrg	library_names=
7856d656433aSmrg	old_library=
7857d656433aSmrg	inherited_linker_flags=
7858d656433aSmrg	# If the library was installed with an old release of libtool,
7859d656433aSmrg	# it will not redefine variables installed, or shouldnotlink
7860d656433aSmrg	installed=yes
7861d656433aSmrg	shouldnotlink=no
7862d656433aSmrg	avoidtemprpath=
7863d656433aSmrg
7864d656433aSmrg
7865d656433aSmrg	# Read the .la file
7866d656433aSmrg	func_source "$lib"
7867d656433aSmrg
7868d656433aSmrg	# Convert "-framework foo" to "foo.ltframework"
7869d656433aSmrg	if test -n "$inherited_linker_flags"; then
7870555991fdSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
7871d656433aSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
7872d656433aSmrg	    case " $new_inherited_linker_flags " in
7873d656433aSmrg	      *" $tmp_inherited_linker_flag "*) ;;
78743c15da26Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
7875d656433aSmrg	    esac
7876d656433aSmrg	  done
7877d656433aSmrg	fi
7878555991fdSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7879300346aeSmrg	if test lib,link = "$linkmode,$pass" ||
7880300346aeSmrg	   test prog,scan = "$linkmode,$pass" ||
7881300346aeSmrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
78823c15da26Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
78833c15da26Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
7884d656433aSmrg	fi
7885d656433aSmrg
7886300346aeSmrg	if test conv = "$pass"; then
7887d656433aSmrg	  # Only check for convenience libraries
7888d656433aSmrg	  deplibs="$lib $deplibs"
7889d656433aSmrg	  if test -z "$libdir"; then
7890d656433aSmrg	    if test -z "$old_library"; then
7891300346aeSmrg	      func_fatal_error "cannot find name of link library for '$lib'"
7892d656433aSmrg	    fi
7893d656433aSmrg	    # It is a libtool convenience library, so add in its objects.
78943c15da26Smrg	    func_append convenience " $ladir/$objdir/$old_library"
78953c15da26Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
7896300346aeSmrg	    tmp_libs=
7897300346aeSmrg	    for deplib in $dependency_libs; do
7898300346aeSmrg	      deplibs="$deplib $deplibs"
7899300346aeSmrg	      if $opt_preserve_dup_deps; then
7900300346aeSmrg		case "$tmp_libs " in
7901300346aeSmrg		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
7902300346aeSmrg		esac
7903300346aeSmrg	      fi
7904300346aeSmrg	      func_append tmp_libs " $deplib"
7905300346aeSmrg	    done
7906300346aeSmrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
7907300346aeSmrg	    func_fatal_error "'$lib' is not a convenience library"
7908d656433aSmrg	  fi
7909d656433aSmrg	  continue
7910d656433aSmrg	fi # $pass = conv
7911d656433aSmrg
7912d656433aSmrg
7913d656433aSmrg	# Get the name of the library we link against.
7914d656433aSmrg	linklib=
79153c15da26Smrg	if test -n "$old_library" &&
7916300346aeSmrg	   { test yes = "$prefer_static_libs" ||
7917300346aeSmrg	     test built,no = "$prefer_static_libs,$installed"; }; then
79183c15da26Smrg	  linklib=$old_library
79193c15da26Smrg	else
79203c15da26Smrg	  for l in $old_library $library_names; do
7921300346aeSmrg	    linklib=$l
79223c15da26Smrg	  done
79233c15da26Smrg	fi
7924d656433aSmrg	if test -z "$linklib"; then
7925300346aeSmrg	  func_fatal_error "cannot find name of link library for '$lib'"
7926d656433aSmrg	fi
7927d656433aSmrg
7928d656433aSmrg	# This library was specified with -dlopen.
7929300346aeSmrg	if test dlopen = "$pass"; then
7930300346aeSmrg	  test -z "$libdir" \
7931300346aeSmrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
7932d656433aSmrg	  if test -z "$dlname" ||
7933300346aeSmrg	     test yes != "$dlopen_support" ||
7934300346aeSmrg	     test no = "$build_libtool_libs"
7935300346aeSmrg	  then
7936d656433aSmrg	    # If there is no dlname, no dlopen support or we're linking
7937d656433aSmrg	    # statically, we need to preload.  We also need to preload any
7938d656433aSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
7939d656433aSmrg	    # bomb out in the load deplibs phase.
79403c15da26Smrg	    func_append dlprefiles " $lib $dependency_libs"
7941d656433aSmrg	  else
79423c15da26Smrg	    func_append newdlfiles " $lib"
7943d656433aSmrg	  fi
7944d656433aSmrg	  continue
7945d656433aSmrg	fi # $pass = dlopen
7946d656433aSmrg
7947d656433aSmrg	# We need an absolute path.
7948d656433aSmrg	case $ladir in
7949300346aeSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
7950d656433aSmrg	*)
7951d656433aSmrg	  abs_ladir=`cd "$ladir" && pwd`
7952d656433aSmrg	  if test -z "$abs_ladir"; then
7953300346aeSmrg	    func_warning "cannot determine absolute directory name of '$ladir'"
7954d656433aSmrg	    func_warning "passing it literally to the linker, although it might fail"
7955300346aeSmrg	    abs_ladir=$ladir
7956d656433aSmrg	  fi
7957d656433aSmrg	  ;;
7958d656433aSmrg	esac
7959d656433aSmrg	func_basename "$lib"
7960300346aeSmrg	laname=$func_basename_result
7961d656433aSmrg
7962d656433aSmrg	# Find the relevant object directory and library name.
7963300346aeSmrg	if test yes = "$installed"; then
79643c15da26Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7965300346aeSmrg	    func_warning "library '$lib' was moved."
7966300346aeSmrg	    dir=$ladir
7967300346aeSmrg	    absdir=$abs_ladir
7968300346aeSmrg	    libdir=$abs_ladir
7969d656433aSmrg	  else
7970300346aeSmrg	    dir=$lt_sysroot$libdir
7971300346aeSmrg	    absdir=$lt_sysroot$libdir
7972d656433aSmrg	  fi
7973300346aeSmrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
7974d656433aSmrg	else
7975d656433aSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7976300346aeSmrg	    dir=$ladir
7977300346aeSmrg	    absdir=$abs_ladir
7978d656433aSmrg	    # Remove this search path later
79793c15da26Smrg	    func_append notinst_path " $abs_ladir"
7980d656433aSmrg	  else
7981300346aeSmrg	    dir=$ladir/$objdir
7982300346aeSmrg	    absdir=$abs_ladir/$objdir
7983d656433aSmrg	    # Remove this search path later
79843c15da26Smrg	    func_append notinst_path " $abs_ladir"
7985d656433aSmrg	  fi
7986d656433aSmrg	fi # $installed = yes
7987d656433aSmrg	func_stripname 'lib' '.la' "$laname"
7988d656433aSmrg	name=$func_stripname_result
7989d656433aSmrg
7990d656433aSmrg	# This library was specified with -dlpreopen.
7991300346aeSmrg	if test dlpreopen = "$pass"; then
7992300346aeSmrg	  if test -z "$libdir" && test prog = "$linkmode"; then
7993300346aeSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
7994d656433aSmrg	  fi
7995300346aeSmrg	  case $host in
79963c15da26Smrg	    # special handling for platforms with PE-DLLs.
79973c15da26Smrg	    *cygwin* | *mingw* | *cegcc* )
79983c15da26Smrg	      # Linker will automatically link against shared library if both
79993c15da26Smrg	      # static and shared are present.  Therefore, ensure we extract
80003c15da26Smrg	      # symbols from the import library if a shared library is present
80013c15da26Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
80023c15da26Smrg	      # this by putting the import library name into $newdlprefiles.
80033c15da26Smrg	      # We recover the dlopen module name by 'saving' the la file
80043c15da26Smrg	      # name in a special purpose variable, and (later) extracting the
80053c15da26Smrg	      # dlname from the la file.
80063c15da26Smrg	      if test -n "$dlname"; then
80073c15da26Smrg	        func_tr_sh "$dir/$linklib"
80083c15da26Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
80093c15da26Smrg	        func_append newdlprefiles " $dir/$linklib"
80103c15da26Smrg	      else
80113c15da26Smrg	        func_append newdlprefiles " $dir/$old_library"
80123c15da26Smrg	        # Keep a list of preopened convenience libraries to check
80133c15da26Smrg	        # that they are being used correctly in the link pass.
80143c15da26Smrg	        test -z "$libdir" && \
80153c15da26Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
80163c15da26Smrg	      fi
80173c15da26Smrg	    ;;
80183c15da26Smrg	    * )
80193c15da26Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
80203c15da26Smrg	      # are required to link).
80213c15da26Smrg	      if test -n "$old_library"; then
80223c15da26Smrg	        func_append newdlprefiles " $dir/$old_library"
80233c15da26Smrg	        # Keep a list of preopened convenience libraries to check
80243c15da26Smrg	        # that they are being used correctly in the link pass.
80253c15da26Smrg	        test -z "$libdir" && \
80263c15da26Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
80273c15da26Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
80283c15da26Smrg	      elif test -n "$dlname"; then
80293c15da26Smrg	        func_append newdlprefiles " $dir/$dlname"
80303c15da26Smrg	      else
80313c15da26Smrg	        func_append newdlprefiles " $dir/$linklib"
80323c15da26Smrg	      fi
80333c15da26Smrg	    ;;
80343c15da26Smrg	  esac
8035d656433aSmrg	fi # $pass = dlpreopen
8036d656433aSmrg
8037d656433aSmrg	if test -z "$libdir"; then
8038d656433aSmrg	  # Link the convenience library
8039300346aeSmrg	  if test lib = "$linkmode"; then
8040d656433aSmrg	    deplibs="$dir/$old_library $deplibs"
8041300346aeSmrg	  elif test prog,link = "$linkmode,$pass"; then
8042d656433aSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
8043d656433aSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
8044d656433aSmrg	  else
8045d656433aSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
8046d656433aSmrg	  fi
8047d656433aSmrg	  continue
8048d656433aSmrg	fi
8049d656433aSmrg
8050d656433aSmrg
8051300346aeSmrg	if test prog = "$linkmode" && test link != "$pass"; then
80523c15da26Smrg	  func_append newlib_search_path " $ladir"
8053d656433aSmrg	  deplibs="$lib $deplibs"
8054d656433aSmrg
8055300346aeSmrg	  linkalldeplibs=false
8056300346aeSmrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
8057300346aeSmrg	     test no = "$build_libtool_libs"; then
8058300346aeSmrg	    linkalldeplibs=:
8059d656433aSmrg	  fi
8060d656433aSmrg
8061d656433aSmrg	  tmp_libs=
8062d656433aSmrg	  for deplib in $dependency_libs; do
8063d656433aSmrg	    case $deplib in
8064d656433aSmrg	    -L*) func_stripname '-L' '' "$deplib"
80653c15da26Smrg	         func_resolve_sysroot "$func_stripname_result"
80663c15da26Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
8067d656433aSmrg		 ;;
8068d656433aSmrg	    esac
8069d656433aSmrg	    # Need to link against all dependency_libs?
8070300346aeSmrg	    if $linkalldeplibs; then
8071d656433aSmrg	      deplibs="$deplib $deplibs"
8072d656433aSmrg	    else
8073d656433aSmrg	      # Need to hardcode shared library paths
8074d656433aSmrg	      # or/and link against static libraries
8075d656433aSmrg	      newdependency_libs="$deplib $newdependency_libs"
8076d656433aSmrg	    fi
8077300346aeSmrg	    if $opt_preserve_dup_deps; then
8078d656433aSmrg	      case "$tmp_libs " in
80793c15da26Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8080d656433aSmrg	      esac
8081d656433aSmrg	    fi
80823c15da26Smrg	    func_append tmp_libs " $deplib"
8083d656433aSmrg	  done # for deplib
8084d656433aSmrg	  continue
8085d656433aSmrg	fi # $linkmode = prog...
8086d656433aSmrg
8087300346aeSmrg	if test prog,link = "$linkmode,$pass"; then
8088d656433aSmrg	  if test -n "$library_names" &&
8089300346aeSmrg	     { { test no = "$prefer_static_libs" ||
8090300346aeSmrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
8091d656433aSmrg	       test -z "$old_library"; }; then
8092d656433aSmrg	    # We need to hardcode the library path
8093300346aeSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
8094d656433aSmrg	      # Make sure the rpath contains only unique directories.
8095300346aeSmrg	      case $temp_rpath: in
8096d656433aSmrg	      *"$absdir:"*) ;;
80973c15da26Smrg	      *) func_append temp_rpath "$absdir:" ;;
8098d656433aSmrg	      esac
8099d656433aSmrg	    fi
8100d656433aSmrg
8101d656433aSmrg	    # Hardcode the library path.
8102d656433aSmrg	    # Skip directories that are in the system default run-time
8103d656433aSmrg	    # search path.
8104d656433aSmrg	    case " $sys_lib_dlsearch_path " in
8105d656433aSmrg	    *" $absdir "*) ;;
8106d656433aSmrg	    *)
8107d656433aSmrg	      case "$compile_rpath " in
8108d656433aSmrg	      *" $absdir "*) ;;
81093c15da26Smrg	      *) func_append compile_rpath " $absdir" ;;
8110d656433aSmrg	      esac
8111d656433aSmrg	      ;;
8112d656433aSmrg	    esac
8113d656433aSmrg	    case " $sys_lib_dlsearch_path " in
8114d656433aSmrg	    *" $libdir "*) ;;
8115d656433aSmrg	    *)
8116d656433aSmrg	      case "$finalize_rpath " in
8117d656433aSmrg	      *" $libdir "*) ;;
81183c15da26Smrg	      *) func_append finalize_rpath " $libdir" ;;
8119d656433aSmrg	      esac
8120d656433aSmrg	      ;;
8121d656433aSmrg	    esac
8122d656433aSmrg	  fi # $linkmode,$pass = prog,link...
8123d656433aSmrg
8124300346aeSmrg	  if $alldeplibs &&
8125300346aeSmrg	     { test pass_all = "$deplibs_check_method" ||
8126300346aeSmrg	       { test yes = "$build_libtool_libs" &&
8127d656433aSmrg		 test -n "$library_names"; }; }; then
8128d656433aSmrg	    # We only need to search for static libraries
8129d656433aSmrg	    continue
8130d656433aSmrg	  fi
8131d656433aSmrg	fi
8132d656433aSmrg
8133d656433aSmrg	link_static=no # Whether the deplib will be linked statically
8134d656433aSmrg	use_static_libs=$prefer_static_libs
8135300346aeSmrg	if test built = "$use_static_libs" && test yes = "$installed"; then
8136d656433aSmrg	  use_static_libs=no
8137d656433aSmrg	fi
8138d656433aSmrg	if test -n "$library_names" &&
8139300346aeSmrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
8140d656433aSmrg	  case $host in
8141300346aeSmrg	  *cygwin* | *mingw* | *cegcc* | *os2*)
8142d656433aSmrg	      # No point in relinking DLLs because paths are not encoded
81433c15da26Smrg	      func_append notinst_deplibs " $lib"
8144d656433aSmrg	      need_relink=no
8145d656433aSmrg	    ;;
8146d656433aSmrg	  *)
8147300346aeSmrg	    if test no = "$installed"; then
81483c15da26Smrg	      func_append notinst_deplibs " $lib"
8149d656433aSmrg	      need_relink=yes
8150d656433aSmrg	    fi
8151d656433aSmrg	    ;;
8152d656433aSmrg	  esac
8153d656433aSmrg	  # This is a shared library
8154d656433aSmrg
8155d656433aSmrg	  # Warn about portability, can't link against -module's on some
8156d656433aSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
8157300346aeSmrg	  dlopenmodule=
8158d656433aSmrg	  for dlpremoduletest in $dlprefiles; do
8159d656433aSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
8160300346aeSmrg	      dlopenmodule=$dlpremoduletest
8161d656433aSmrg	      break
8162d656433aSmrg	    fi
8163d656433aSmrg	  done
8164300346aeSmrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8165555991fdSmrg	    echo
8166300346aeSmrg	    if test prog = "$linkmode"; then
8167d656433aSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
8168d656433aSmrg	    else
8169d656433aSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
8170d656433aSmrg	    fi
8171d656433aSmrg	    $ECHO "*** $linklib is not portable!"
8172d656433aSmrg	  fi
8173300346aeSmrg	  if test lib = "$linkmode" &&
8174300346aeSmrg	     test yes = "$hardcode_into_libs"; then
8175d656433aSmrg	    # Hardcode the library path.
8176d656433aSmrg	    # Skip directories that are in the system default run-time
8177d656433aSmrg	    # search path.
8178d656433aSmrg	    case " $sys_lib_dlsearch_path " in
8179d656433aSmrg	    *" $absdir "*) ;;
8180d656433aSmrg	    *)
8181d656433aSmrg	      case "$compile_rpath " in
8182d656433aSmrg	      *" $absdir "*) ;;
81833c15da26Smrg	      *) func_append compile_rpath " $absdir" ;;
8184d656433aSmrg	      esac
8185d656433aSmrg	      ;;
8186d656433aSmrg	    esac
8187d656433aSmrg	    case " $sys_lib_dlsearch_path " in
8188d656433aSmrg	    *" $libdir "*) ;;
8189d656433aSmrg	    *)
8190d656433aSmrg	      case "$finalize_rpath " in
8191d656433aSmrg	      *" $libdir "*) ;;
81923c15da26Smrg	      *) func_append finalize_rpath " $libdir" ;;
8193d656433aSmrg	      esac
8194d656433aSmrg	      ;;
8195d656433aSmrg	    esac
8196d656433aSmrg	  fi
8197d656433aSmrg
8198d656433aSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
8199d656433aSmrg	    # figure out the soname
8200d656433aSmrg	    set dummy $library_names
8201d656433aSmrg	    shift
8202300346aeSmrg	    realname=$1
8203d656433aSmrg	    shift
8204d656433aSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
8205d656433aSmrg	    # use dlname if we got it. it's perfectly good, no?
8206d656433aSmrg	    if test -n "$dlname"; then
8207300346aeSmrg	      soname=$dlname
8208d656433aSmrg	    elif test -n "$soname_spec"; then
8209d656433aSmrg	      # bleh windows
8210d656433aSmrg	      case $host in
8211300346aeSmrg	      *cygwin* | mingw* | *cegcc* | *os2*)
8212d656433aSmrg	        func_arith $current - $age
8213d656433aSmrg		major=$func_arith_result
8214300346aeSmrg		versuffix=-$major
8215d656433aSmrg		;;
8216d656433aSmrg	      esac
8217d656433aSmrg	      eval soname=\"$soname_spec\"
8218d656433aSmrg	    else
8219300346aeSmrg	      soname=$realname
8220d656433aSmrg	    fi
8221d656433aSmrg
8222d656433aSmrg	    # Make a new name for the extract_expsyms_cmds to use
8223300346aeSmrg	    soroot=$soname
8224d656433aSmrg	    func_basename "$soroot"
8225300346aeSmrg	    soname=$func_basename_result
8226d656433aSmrg	    func_stripname 'lib' '.dll' "$soname"
8227d656433aSmrg	    newlib=libimp-$func_stripname_result.a
8228d656433aSmrg
8229d656433aSmrg	    # If the library has no export list, then create one now
8230d656433aSmrg	    if test -f "$output_objdir/$soname-def"; then :
8231d656433aSmrg	    else
8232300346aeSmrg	      func_verbose "extracting exported symbol list from '$soname'"
8233d656433aSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
8234d656433aSmrg	    fi
8235d656433aSmrg
8236d656433aSmrg	    # Create $newlib
8237d656433aSmrg	    if test -f "$output_objdir/$newlib"; then :; else
8238300346aeSmrg	      func_verbose "generating import library for '$soname'"
8239d656433aSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
8240d656433aSmrg	    fi
8241d656433aSmrg	    # make sure the library variables are pointing to the new library
8242d656433aSmrg	    dir=$output_objdir
8243d656433aSmrg	    linklib=$newlib
8244d656433aSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
8245d656433aSmrg
8246300346aeSmrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
8247d656433aSmrg	    add_shlibpath=
8248d656433aSmrg	    add_dir=
8249d656433aSmrg	    add=
8250d656433aSmrg	    lib_linked=yes
8251d656433aSmrg	    case $hardcode_action in
8252d656433aSmrg	    immediate | unsupported)
8253300346aeSmrg	      if test no = "$hardcode_direct"; then
8254300346aeSmrg		add=$dir/$linklib
8255d656433aSmrg		case $host in
8256300346aeSmrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
8257300346aeSmrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
8258d656433aSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
8259300346aeSmrg		    *-*-unixware7*) add_dir=-L$dir ;;
8260d656433aSmrg		  *-*-darwin* )
8261300346aeSmrg		    # if the lib is a (non-dlopened) module then we cannot
8262d656433aSmrg		    # link against it, someone is ignoring the earlier warnings
8263d656433aSmrg		    if /usr/bin/file -L $add 2> /dev/null |
8264300346aeSmrg			 $GREP ": [^:]* bundle" >/dev/null; then
8265d656433aSmrg		      if test "X$dlopenmodule" != "X$lib"; then
8266d656433aSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
8267300346aeSmrg			if test -z "$old_library"; then
8268555991fdSmrg			  echo
8269555991fdSmrg			  echo "*** And there doesn't seem to be a static archive available"
8270555991fdSmrg			  echo "*** The link will probably fail, sorry"
8271d656433aSmrg			else
8272300346aeSmrg			  add=$dir/$old_library
8273d656433aSmrg			fi
8274d656433aSmrg		      elif test -n "$old_library"; then
8275300346aeSmrg			add=$dir/$old_library
8276d656433aSmrg		      fi
8277d656433aSmrg		    fi
8278d656433aSmrg		esac
8279300346aeSmrg	      elif test no = "$hardcode_minus_L"; then
8280d656433aSmrg		case $host in
8281300346aeSmrg		*-*-sunos*) add_shlibpath=$dir ;;
8282d656433aSmrg		esac
8283300346aeSmrg		add_dir=-L$dir
8284300346aeSmrg		add=-l$name
8285300346aeSmrg	      elif test no = "$hardcode_shlibpath_var"; then
8286300346aeSmrg		add_shlibpath=$dir
8287300346aeSmrg		add=-l$name
8288d656433aSmrg	      else
8289d656433aSmrg		lib_linked=no
8290d656433aSmrg	      fi
8291d656433aSmrg	      ;;
8292d656433aSmrg	    relink)
8293300346aeSmrg	      if test yes = "$hardcode_direct" &&
8294300346aeSmrg	         test no = "$hardcode_direct_absolute"; then
8295300346aeSmrg		add=$dir/$linklib
8296300346aeSmrg	      elif test yes = "$hardcode_minus_L"; then
8297300346aeSmrg		add_dir=-L$absdir
8298d656433aSmrg		# Try looking first in the location we're being installed to.
8299d656433aSmrg		if test -n "$inst_prefix_dir"; then
8300d656433aSmrg		  case $libdir in
8301d656433aSmrg		    [\\/]*)
83023c15da26Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
8303d656433aSmrg		      ;;
8304d656433aSmrg		  esac
8305d656433aSmrg		fi
8306300346aeSmrg		add=-l$name
8307300346aeSmrg	      elif test yes = "$hardcode_shlibpath_var"; then
8308300346aeSmrg		add_shlibpath=$dir
8309300346aeSmrg		add=-l$name
8310d656433aSmrg	      else
8311d656433aSmrg		lib_linked=no
8312d656433aSmrg	      fi
8313d656433aSmrg	      ;;
8314d656433aSmrg	    *) lib_linked=no ;;
8315d656433aSmrg	    esac
8316d656433aSmrg
8317300346aeSmrg	    if test yes != "$lib_linked"; then
8318d656433aSmrg	      func_fatal_configuration "unsupported hardcode properties"
8319d656433aSmrg	    fi
8320d656433aSmrg
8321d656433aSmrg	    if test -n "$add_shlibpath"; then
8322d656433aSmrg	      case :$compile_shlibpath: in
8323d656433aSmrg	      *":$add_shlibpath:"*) ;;
83243c15da26Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
8325d656433aSmrg	      esac
8326d656433aSmrg	    fi
8327300346aeSmrg	    if test prog = "$linkmode"; then
8328d656433aSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
8329d656433aSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
8330d656433aSmrg	    else
8331d656433aSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8332d656433aSmrg	      test -n "$add" && deplibs="$add $deplibs"
8333300346aeSmrg	      if test yes != "$hardcode_direct" &&
8334300346aeSmrg		 test yes != "$hardcode_minus_L" &&
8335300346aeSmrg		 test yes = "$hardcode_shlibpath_var"; then
8336d656433aSmrg		case :$finalize_shlibpath: in
8337d656433aSmrg		*":$libdir:"*) ;;
83383c15da26Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
8339d656433aSmrg		esac
8340d656433aSmrg	      fi
8341d656433aSmrg	    fi
8342d656433aSmrg	  fi
8343d656433aSmrg
8344300346aeSmrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
8345d656433aSmrg	    add_shlibpath=
8346d656433aSmrg	    add_dir=
8347d656433aSmrg	    add=
8348d656433aSmrg	    # Finalize command for both is simple: just hardcode it.
8349300346aeSmrg	    if test yes = "$hardcode_direct" &&
8350300346aeSmrg	       test no = "$hardcode_direct_absolute"; then
8351300346aeSmrg	      add=$libdir/$linklib
8352300346aeSmrg	    elif test yes = "$hardcode_minus_L"; then
8353300346aeSmrg	      add_dir=-L$libdir
8354300346aeSmrg	      add=-l$name
8355300346aeSmrg	    elif test yes = "$hardcode_shlibpath_var"; then
8356d656433aSmrg	      case :$finalize_shlibpath: in
8357d656433aSmrg	      *":$libdir:"*) ;;
83583c15da26Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
8359d656433aSmrg	      esac
8360300346aeSmrg	      add=-l$name
8361300346aeSmrg	    elif test yes = "$hardcode_automatic"; then
8362d656433aSmrg	      if test -n "$inst_prefix_dir" &&
8363300346aeSmrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
8364300346aeSmrg		add=$inst_prefix_dir$libdir/$linklib
8365d656433aSmrg	      else
8366300346aeSmrg		add=$libdir/$linklib
8367d656433aSmrg	      fi
8368d656433aSmrg	    else
8369d656433aSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
8370300346aeSmrg	      add_dir=-L$libdir
8371d656433aSmrg	      # Try looking first in the location we're being installed to.
8372d656433aSmrg	      if test -n "$inst_prefix_dir"; then
8373d656433aSmrg		case $libdir in
8374d656433aSmrg		  [\\/]*)
83753c15da26Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
8376d656433aSmrg		    ;;
8377d656433aSmrg		esac
8378d656433aSmrg	      fi
8379300346aeSmrg	      add=-l$name
8380d656433aSmrg	    fi
8381d656433aSmrg
8382300346aeSmrg	    if test prog = "$linkmode"; then
8383d656433aSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
8384d656433aSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
8385d656433aSmrg	    else
8386d656433aSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8387d656433aSmrg	      test -n "$add" && deplibs="$add $deplibs"
8388d656433aSmrg	    fi
8389d656433aSmrg	  fi
8390300346aeSmrg	elif test prog = "$linkmode"; then
8391d656433aSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
8392d656433aSmrg	  # is not unsupported.  This is valid on all known static and
8393d656433aSmrg	  # shared platforms.
8394300346aeSmrg	  if test unsupported != "$hardcode_direct"; then
8395300346aeSmrg	    test -n "$old_library" && linklib=$old_library
8396d656433aSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
8397d656433aSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
8398d656433aSmrg	  else
8399d656433aSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
8400d656433aSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
8401d656433aSmrg	  fi
8402300346aeSmrg	elif test yes = "$build_libtool_libs"; then
8403d656433aSmrg	  # Not a shared library
8404300346aeSmrg	  if test pass_all != "$deplibs_check_method"; then
8405d656433aSmrg	    # We're trying link a shared library against a static one
8406d656433aSmrg	    # but the system doesn't support it.
8407d656433aSmrg
8408d656433aSmrg	    # Just print a warning and add the library to dependency_libs so
8409d656433aSmrg	    # that the program can be linked against the static library.
8410555991fdSmrg	    echo
8411300346aeSmrg	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8412555991fdSmrg	    echo "*** I have the capability to make that library automatically link in when"
8413555991fdSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
8414555991fdSmrg	    echo "*** shared version of the library, which you do not appear to have."
8415300346aeSmrg	    if test yes = "$module"; then
8416555991fdSmrg	      echo "*** But as you try to build a module library, libtool will still create "
8417555991fdSmrg	      echo "*** a static module, that should work as long as the dlopening application"
8418555991fdSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
8419d656433aSmrg	      if test -z "$global_symbol_pipe"; then
8420555991fdSmrg		echo
8421555991fdSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
8422300346aeSmrg		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8423555991fdSmrg		echo "*** not find such a program.  So, this module is probably useless."
8424300346aeSmrg		echo "*** 'nm' from GNU binutils and a full rebuild may help."
8425d656433aSmrg	      fi
8426300346aeSmrg	      if test no = "$build_old_libs"; then
8427d656433aSmrg		build_libtool_libs=module
8428d656433aSmrg		build_old_libs=yes
8429d656433aSmrg	      else
8430d656433aSmrg		build_libtool_libs=no
8431d656433aSmrg	      fi
8432d656433aSmrg	    fi
8433d656433aSmrg	  else
8434d656433aSmrg	    deplibs="$dir/$old_library $deplibs"
8435d656433aSmrg	    link_static=yes
8436d656433aSmrg	  fi
8437d656433aSmrg	fi # link shared/static library?
8438d656433aSmrg
8439300346aeSmrg	if test lib = "$linkmode"; then
8440d656433aSmrg	  if test -n "$dependency_libs" &&
8441300346aeSmrg	     { test yes != "$hardcode_into_libs" ||
8442300346aeSmrg	       test yes = "$build_old_libs" ||
8443300346aeSmrg	       test yes = "$link_static"; }; then
8444d656433aSmrg	    # Extract -R from dependency_libs
8445d656433aSmrg	    temp_deplibs=
8446d656433aSmrg	    for libdir in $dependency_libs; do
8447d656433aSmrg	      case $libdir in
8448d656433aSmrg	      -R*) func_stripname '-R' '' "$libdir"
8449d656433aSmrg	           temp_xrpath=$func_stripname_result
8450d656433aSmrg		   case " $xrpath " in
8451d656433aSmrg		   *" $temp_xrpath "*) ;;
84523c15da26Smrg		   *) func_append xrpath " $temp_xrpath";;
8453d656433aSmrg		   esac;;
84543c15da26Smrg	      *) func_append temp_deplibs " $libdir";;
8455d656433aSmrg	      esac
8456d656433aSmrg	    done
8457300346aeSmrg	    dependency_libs=$temp_deplibs
8458d656433aSmrg	  fi
8459d656433aSmrg
84603c15da26Smrg	  func_append newlib_search_path " $absdir"
8461d656433aSmrg	  # Link against this library
8462300346aeSmrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
8463d656433aSmrg	  # ... and its dependency_libs
8464d656433aSmrg	  tmp_libs=
8465d656433aSmrg	  for deplib in $dependency_libs; do
8466d656433aSmrg	    newdependency_libs="$deplib $newdependency_libs"
84673c15da26Smrg	    case $deplib in
84683c15da26Smrg              -L*) func_stripname '-L' '' "$deplib"
84693c15da26Smrg                   func_resolve_sysroot "$func_stripname_result";;
84703c15da26Smrg              *) func_resolve_sysroot "$deplib" ;;
84713c15da26Smrg            esac
8472300346aeSmrg	    if $opt_preserve_dup_deps; then
8473d656433aSmrg	      case "$tmp_libs " in
84743c15da26Smrg	      *" $func_resolve_sysroot_result "*)
84753c15da26Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
8476d656433aSmrg	      esac
8477d656433aSmrg	    fi
84783c15da26Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
8479d656433aSmrg	  done
8480d656433aSmrg
8481300346aeSmrg	  if test no != "$link_all_deplibs"; then
8482d656433aSmrg	    # Add the search paths of all dependency libraries
8483d656433aSmrg	    for deplib in $dependency_libs; do
8484555991fdSmrg	      path=
8485d656433aSmrg	      case $deplib in
8486300346aeSmrg	      -L*) path=$deplib ;;
8487d656433aSmrg	      *.la)
84883c15da26Smrg	        func_resolve_sysroot "$deplib"
84893c15da26Smrg	        deplib=$func_resolve_sysroot_result
8490d656433aSmrg	        func_dirname "$deplib" "" "."
84913c15da26Smrg		dir=$func_dirname_result
8492d656433aSmrg		# We need an absolute path.
8493d656433aSmrg		case $dir in
8494300346aeSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
8495d656433aSmrg		*)
8496d656433aSmrg		  absdir=`cd "$dir" && pwd`
8497d656433aSmrg		  if test -z "$absdir"; then
8498300346aeSmrg		    func_warning "cannot determine absolute directory name of '$dir'"
8499300346aeSmrg		    absdir=$dir
8500d656433aSmrg		  fi
8501d656433aSmrg		  ;;
8502d656433aSmrg		esac
8503d656433aSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
8504d656433aSmrg		case $host in
8505d656433aSmrg		*-*-darwin*)
8506d656433aSmrg		  depdepl=
8507300346aeSmrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
8508300346aeSmrg		  if test -n "$deplibrary_names"; then
8509300346aeSmrg		    for tmp in $deplibrary_names; do
8510d656433aSmrg		      depdepl=$tmp
8511d656433aSmrg		    done
8512300346aeSmrg		    if test -f "$absdir/$objdir/$depdepl"; then
8513300346aeSmrg		      depdepl=$absdir/$objdir/$depdepl
8514300346aeSmrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8515d656433aSmrg                      if test -z "$darwin_install_name"; then
8516300346aeSmrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
8517d656433aSmrg                      fi
8518300346aeSmrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
8519300346aeSmrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
8520d656433aSmrg		      path=
8521d656433aSmrg		    fi
8522d656433aSmrg		  fi
8523d656433aSmrg		  ;;
8524d656433aSmrg		*)
8525300346aeSmrg		  path=-L$absdir/$objdir
8526d656433aSmrg		  ;;
8527d656433aSmrg		esac
8528d656433aSmrg		else
8529300346aeSmrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8530d656433aSmrg		  test -z "$libdir" && \
8531300346aeSmrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
8532d656433aSmrg		  test "$absdir" != "$libdir" && \
8533300346aeSmrg		    func_warning "'$deplib' seems to be moved"
8534d656433aSmrg
8535300346aeSmrg		  path=-L$absdir
8536d656433aSmrg		fi
8537d656433aSmrg		;;
8538d656433aSmrg	      esac
8539d656433aSmrg	      case " $deplibs " in
8540d656433aSmrg	      *" $path "*) ;;
8541d656433aSmrg	      *) deplibs="$path $deplibs" ;;
8542d656433aSmrg	      esac
8543d656433aSmrg	    done
8544d656433aSmrg	  fi # link_all_deplibs != no
8545d656433aSmrg	fi # linkmode = lib
8546d656433aSmrg      done # for deplib in $libs
8547300346aeSmrg      if test link = "$pass"; then
8548300346aeSmrg	if test prog = "$linkmode"; then
8549d656433aSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
8550d656433aSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
8551d656433aSmrg	else
8552555991fdSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8553d656433aSmrg	fi
8554d656433aSmrg      fi
8555300346aeSmrg      dependency_libs=$newdependency_libs
8556300346aeSmrg      if test dlpreopen = "$pass"; then
8557d656433aSmrg	# Link the dlpreopened libraries before other libraries
8558d656433aSmrg	for deplib in $save_deplibs; do
8559d656433aSmrg	  deplibs="$deplib $deplibs"
8560d656433aSmrg	done
8561d656433aSmrg      fi
8562300346aeSmrg      if test dlopen != "$pass"; then
8563300346aeSmrg	test conv = "$pass" || {
8564d656433aSmrg	  # Make sure lib_search_path contains only unique directories.
8565d656433aSmrg	  lib_search_path=
8566d656433aSmrg	  for dir in $newlib_search_path; do
8567d656433aSmrg	    case "$lib_search_path " in
8568d656433aSmrg	    *" $dir "*) ;;
85693c15da26Smrg	    *) func_append lib_search_path " $dir" ;;
8570d656433aSmrg	    esac
8571d656433aSmrg	  done
8572d656433aSmrg	  newlib_search_path=
8573300346aeSmrg	}
8574d656433aSmrg
8575300346aeSmrg	if test prog,link = "$linkmode,$pass"; then
8576d656433aSmrg	  vars="compile_deplibs finalize_deplibs"
8577300346aeSmrg	else
8578300346aeSmrg	  vars=deplibs
8579d656433aSmrg	fi
8580d656433aSmrg	for var in $vars dependency_libs; do
8581d656433aSmrg	  # Add libraries to $var in reverse order
8582d656433aSmrg	  eval tmp_libs=\"\$$var\"
8583d656433aSmrg	  new_libs=
8584d656433aSmrg	  for deplib in $tmp_libs; do
8585d656433aSmrg	    # FIXME: Pedantically, this is the right thing to do, so
8586d656433aSmrg	    #        that some nasty dependency loop isn't accidentally
8587d656433aSmrg	    #        broken:
8588d656433aSmrg	    #new_libs="$deplib $new_libs"
8589d656433aSmrg	    # Pragmatically, this seems to cause very few problems in
8590d656433aSmrg	    # practice:
8591d656433aSmrg	    case $deplib in
8592d656433aSmrg	    -L*) new_libs="$deplib $new_libs" ;;
8593d656433aSmrg	    -R*) ;;
8594d656433aSmrg	    *)
8595d656433aSmrg	      # And here is the reason: when a library appears more
8596d656433aSmrg	      # than once as an explicit dependence of a library, or
8597d656433aSmrg	      # is implicitly linked in more than once by the
8598d656433aSmrg	      # compiler, it is considered special, and multiple
8599d656433aSmrg	      # occurrences thereof are not removed.  Compare this
8600d656433aSmrg	      # with having the same library being listed as a
8601d656433aSmrg	      # dependency of multiple other libraries: in this case,
8602d656433aSmrg	      # we know (pedantically, we assume) the library does not
8603d656433aSmrg	      # need to be listed more than once, so we keep only the
8604d656433aSmrg	      # last copy.  This is not always right, but it is rare
8605d656433aSmrg	      # enough that we require users that really mean to play
8606d656433aSmrg	      # such unportable linking tricks to link the library
8607d656433aSmrg	      # using -Wl,-lname, so that libtool does not consider it
8608d656433aSmrg	      # for duplicate removal.
8609d656433aSmrg	      case " $specialdeplibs " in
8610d656433aSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
8611d656433aSmrg	      *)
8612d656433aSmrg		case " $new_libs " in
8613d656433aSmrg		*" $deplib "*) ;;
8614d656433aSmrg		*) new_libs="$deplib $new_libs" ;;
8615d656433aSmrg		esac
8616d656433aSmrg		;;
8617d656433aSmrg	      esac
8618d656433aSmrg	      ;;
8619d656433aSmrg	    esac
8620d656433aSmrg	  done
8621d656433aSmrg	  tmp_libs=
8622d656433aSmrg	  for deplib in $new_libs; do
8623d656433aSmrg	    case $deplib in
8624d656433aSmrg	    -L*)
8625d656433aSmrg	      case " $tmp_libs " in
8626d656433aSmrg	      *" $deplib "*) ;;
86273c15da26Smrg	      *) func_append tmp_libs " $deplib" ;;
8628d656433aSmrg	      esac
8629d656433aSmrg	      ;;
86303c15da26Smrg	    *) func_append tmp_libs " $deplib" ;;
8631d656433aSmrg	    esac
8632d656433aSmrg	  done
8633d656433aSmrg	  eval $var=\"$tmp_libs\"
8634d656433aSmrg	done # for var
8635d656433aSmrg      fi
8636300346aeSmrg
8637300346aeSmrg      # Add Sun CC postdeps if required:
8638300346aeSmrg      test CXX = "$tagname" && {
8639300346aeSmrg        case $host_os in
8640300346aeSmrg        linux*)
8641300346aeSmrg          case `$CC -V 2>&1 | sed 5q` in
8642300346aeSmrg          *Sun\ C*) # Sun C++ 5.9
8643300346aeSmrg            func_suncc_cstd_abi
8644300346aeSmrg
8645300346aeSmrg            if test no != "$suncc_use_cstd_abi"; then
8646300346aeSmrg              func_append postdeps ' -library=Cstd -library=Crun'
8647300346aeSmrg            fi
8648300346aeSmrg            ;;
8649300346aeSmrg          esac
8650300346aeSmrg          ;;
8651300346aeSmrg
8652300346aeSmrg        solaris*)
8653300346aeSmrg          func_cc_basename "$CC"
8654300346aeSmrg          case $func_cc_basename_result in
8655300346aeSmrg          CC* | sunCC*)
8656300346aeSmrg            func_suncc_cstd_abi
8657300346aeSmrg
8658300346aeSmrg            if test no != "$suncc_use_cstd_abi"; then
8659300346aeSmrg              func_append postdeps ' -library=Cstd -library=Crun'
8660300346aeSmrg            fi
8661300346aeSmrg            ;;
8662300346aeSmrg          esac
8663300346aeSmrg          ;;
8664300346aeSmrg        esac
8665300346aeSmrg      }
8666300346aeSmrg
8667d656433aSmrg      # Last step: remove runtime libs from dependency_libs
8668d656433aSmrg      # (they stay in deplibs)
8669d656433aSmrg      tmp_libs=
8670300346aeSmrg      for i in $dependency_libs; do
8671d656433aSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
8672d656433aSmrg	*" $i "*)
8673300346aeSmrg	  i=
8674d656433aSmrg	  ;;
8675d656433aSmrg	esac
8676300346aeSmrg	if test -n "$i"; then
86773c15da26Smrg	  func_append tmp_libs " $i"
8678d656433aSmrg	fi
8679d656433aSmrg      done
8680d656433aSmrg      dependency_libs=$tmp_libs
8681d656433aSmrg    done # for pass
8682300346aeSmrg    if test prog = "$linkmode"; then
8683300346aeSmrg      dlfiles=$newdlfiles
8684d656433aSmrg    fi
8685300346aeSmrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
8686300346aeSmrg      dlprefiles=$newdlprefiles
8687d656433aSmrg    fi
8688d656433aSmrg
8689d656433aSmrg    case $linkmode in
8690d656433aSmrg    oldlib)
8691300346aeSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
8692300346aeSmrg	func_warning "'-dlopen' is ignored for archives"
8693d656433aSmrg      fi
8694d656433aSmrg
8695d656433aSmrg      case " $deplibs" in
8696d656433aSmrg      *\ -l* | *\ -L*)
8697300346aeSmrg	func_warning "'-l' and '-L' are ignored for archives" ;;
8698d656433aSmrg      esac
8699d656433aSmrg
8700d656433aSmrg      test -n "$rpath" && \
8701300346aeSmrg	func_warning "'-rpath' is ignored for archives"
8702d656433aSmrg
8703d656433aSmrg      test -n "$xrpath" && \
8704300346aeSmrg	func_warning "'-R' is ignored for archives"
8705d656433aSmrg
8706d656433aSmrg      test -n "$vinfo" && \
8707300346aeSmrg	func_warning "'-version-info/-version-number' is ignored for archives"
8708d656433aSmrg
8709d656433aSmrg      test -n "$release" && \
8710300346aeSmrg	func_warning "'-release' is ignored for archives"
8711d656433aSmrg
8712d656433aSmrg      test -n "$export_symbols$export_symbols_regex" && \
8713300346aeSmrg	func_warning "'-export-symbols' is ignored for archives"
8714d656433aSmrg
8715d656433aSmrg      # Now set the variables for building old libraries.
8716d656433aSmrg      build_libtool_libs=no
8717300346aeSmrg      oldlibs=$output
87183c15da26Smrg      func_append objs "$old_deplibs"
8719d656433aSmrg      ;;
8720d656433aSmrg
8721d656433aSmrg    lib)
8722300346aeSmrg      # Make sure we only generate libraries of the form 'libNAME.la'.
8723d656433aSmrg      case $outputname in
8724d656433aSmrg      lib*)
8725d656433aSmrg	func_stripname 'lib' '.la' "$outputname"
8726d656433aSmrg	name=$func_stripname_result
8727d656433aSmrg	eval shared_ext=\"$shrext_cmds\"
8728d656433aSmrg	eval libname=\"$libname_spec\"
8729d656433aSmrg	;;
8730d656433aSmrg      *)
8731300346aeSmrg	test no = "$module" \
8732300346aeSmrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
8733d656433aSmrg
8734300346aeSmrg	if test no != "$need_lib_prefix"; then
8735d656433aSmrg	  # Add the "lib" prefix for modules if required
8736d656433aSmrg	  func_stripname '' '.la' "$outputname"
8737d656433aSmrg	  name=$func_stripname_result
8738d656433aSmrg	  eval shared_ext=\"$shrext_cmds\"
8739d656433aSmrg	  eval libname=\"$libname_spec\"
8740d656433aSmrg	else
8741d656433aSmrg	  func_stripname '' '.la' "$outputname"
8742d656433aSmrg	  libname=$func_stripname_result
8743d656433aSmrg	fi
8744d656433aSmrg	;;
8745d656433aSmrg      esac
8746d656433aSmrg
8747d656433aSmrg      if test -n "$objs"; then
8748300346aeSmrg	if test pass_all != "$deplibs_check_method"; then
8749300346aeSmrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
8750d656433aSmrg	else
8751555991fdSmrg	  echo
8752d656433aSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
8753d656433aSmrg	  $ECHO "*** objects $objs is not portable!"
87543c15da26Smrg	  func_append libobjs " $objs"
8755d656433aSmrg	fi
8756d656433aSmrg      fi
8757d656433aSmrg
8758300346aeSmrg      test no = "$dlself" \
8759300346aeSmrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
8760d656433aSmrg
8761d656433aSmrg      set dummy $rpath
8762d656433aSmrg      shift
8763300346aeSmrg      test 1 -lt "$#" \
8764300346aeSmrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
8765d656433aSmrg
8766300346aeSmrg      install_libdir=$1
8767d656433aSmrg
8768d656433aSmrg      oldlibs=
8769d656433aSmrg      if test -z "$rpath"; then
8770300346aeSmrg	if test yes = "$build_libtool_libs"; then
8771d656433aSmrg	  # Building a libtool convenience library.
8772300346aeSmrg	  # Some compilers have problems with a '.al' extension so
8773d656433aSmrg	  # convenience libraries should have the same extension an
8774d656433aSmrg	  # archive normally would.
8775d656433aSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
8776d656433aSmrg	  build_libtool_libs=convenience
8777d656433aSmrg	  build_old_libs=yes
8778d656433aSmrg	fi
8779d656433aSmrg
8780d656433aSmrg	test -n "$vinfo" && \
8781300346aeSmrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
8782d656433aSmrg
8783d656433aSmrg	test -n "$release" && \
8784300346aeSmrg	  func_warning "'-release' is ignored for convenience libraries"
8785d656433aSmrg      else
8786d656433aSmrg
8787d656433aSmrg	# Parse the version information argument.
8788300346aeSmrg	save_ifs=$IFS; IFS=:
8789d656433aSmrg	set dummy $vinfo 0 0 0
8790d656433aSmrg	shift
8791300346aeSmrg	IFS=$save_ifs
8792d656433aSmrg
8793d656433aSmrg	test -n "$7" && \
8794300346aeSmrg	  func_fatal_help "too many parameters to '-version-info'"
8795d656433aSmrg
8796d656433aSmrg	# convert absolute version numbers to libtool ages
8797d656433aSmrg	# this retains compatibility with .la files and attempts
8798d656433aSmrg	# to make the code below a bit more comprehensible
8799d656433aSmrg
8800d656433aSmrg	case $vinfo_number in
8801d656433aSmrg	yes)
8802300346aeSmrg	  number_major=$1
8803300346aeSmrg	  number_minor=$2
8804300346aeSmrg	  number_revision=$3
8805d656433aSmrg	  #
8806d656433aSmrg	  # There are really only two kinds -- those that
8807d656433aSmrg	  # use the current revision as the major version
8808d656433aSmrg	  # and those that subtract age and use age as
8809d656433aSmrg	  # a minor version.  But, then there is irix
8810300346aeSmrg	  # that has an extra 1 added just for fun
8811d656433aSmrg	  #
8812d656433aSmrg	  case $version_type in
88130a6b08f8Smrg	  # correct linux to gnu/linux during the next big refactor
8814300346aeSmrg	  darwin|freebsd-elf|linux|osf|windows|none)
8815d656433aSmrg	    func_arith $number_major + $number_minor
8816d656433aSmrg	    current=$func_arith_result
8817300346aeSmrg	    age=$number_minor
8818300346aeSmrg	    revision=$number_revision
8819d656433aSmrg	    ;;
8820300346aeSmrg	  freebsd-aout|qnx|sunos)
8821300346aeSmrg	    current=$number_major
8822300346aeSmrg	    revision=$number_minor
8823300346aeSmrg	    age=0
8824d656433aSmrg	    ;;
8825d656433aSmrg	  irix|nonstopux)
8826d656433aSmrg	    func_arith $number_major + $number_minor
8827d656433aSmrg	    current=$func_arith_result
8828300346aeSmrg	    age=$number_minor
8829300346aeSmrg	    revision=$number_minor
8830d656433aSmrg	    lt_irix_increment=no
8831d656433aSmrg	    ;;
8832300346aeSmrg	  *)
8833300346aeSmrg	    func_fatal_configuration "$modename: unknown library version type '$version_type'"
8834300346aeSmrg	    ;;
8835d656433aSmrg	  esac
8836d656433aSmrg	  ;;
8837d656433aSmrg	no)
8838300346aeSmrg	  current=$1
8839300346aeSmrg	  revision=$2
8840300346aeSmrg	  age=$3
8841d656433aSmrg	  ;;
8842d656433aSmrg	esac
8843d656433aSmrg
8844d656433aSmrg	# Check that each of the things are valid numbers.
8845d656433aSmrg	case $current in
8846d656433aSmrg	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]) ;;
8847d656433aSmrg	*)
8848300346aeSmrg	  func_error "CURRENT '$current' must be a nonnegative integer"
8849300346aeSmrg	  func_fatal_error "'$vinfo' is not valid version information"
8850d656433aSmrg	  ;;
8851d656433aSmrg	esac
8852d656433aSmrg
8853d656433aSmrg	case $revision in
8854d656433aSmrg	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]) ;;
8855d656433aSmrg	*)
8856300346aeSmrg	  func_error "REVISION '$revision' must be a nonnegative integer"
8857300346aeSmrg	  func_fatal_error "'$vinfo' is not valid version information"
8858d656433aSmrg	  ;;
8859d656433aSmrg	esac
8860d656433aSmrg
8861d656433aSmrg	case $age in
8862d656433aSmrg	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]) ;;
8863d656433aSmrg	*)
8864300346aeSmrg	  func_error "AGE '$age' must be a nonnegative integer"
8865300346aeSmrg	  func_fatal_error "'$vinfo' is not valid version information"
8866d656433aSmrg	  ;;
8867d656433aSmrg	esac
8868d656433aSmrg
8869d656433aSmrg	if test "$age" -gt "$current"; then
8870300346aeSmrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
8871300346aeSmrg	  func_fatal_error "'$vinfo' is not valid version information"
8872d656433aSmrg	fi
8873d656433aSmrg
8874d656433aSmrg	# Calculate the version variables.
8875d656433aSmrg	major=
8876d656433aSmrg	versuffix=
8877d656433aSmrg	verstring=
8878d656433aSmrg	case $version_type in
8879d656433aSmrg	none) ;;
8880d656433aSmrg
8881d656433aSmrg	darwin)
8882d656433aSmrg	  # Like Linux, but with the current version available in
8883d656433aSmrg	  # verstring for coding it into the library header
8884d656433aSmrg	  func_arith $current - $age
8885d656433aSmrg	  major=.$func_arith_result
8886300346aeSmrg	  versuffix=$major.$age.$revision
8887d656433aSmrg	  # Darwin ld doesn't like 0 for these options...
8888d656433aSmrg	  func_arith $current + 1
8889d656433aSmrg	  minor_current=$func_arith_result
8890300346aeSmrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8891d656433aSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8892300346aeSmrg          # On Darwin other compilers
8893300346aeSmrg          case $CC in
8894300346aeSmrg              nagfor*)
8895300346aeSmrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8896300346aeSmrg                  ;;
8897300346aeSmrg              *)
8898300346aeSmrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8899300346aeSmrg                  ;;
8900300346aeSmrg          esac
8901d656433aSmrg	  ;;
8902d656433aSmrg
8903d656433aSmrg	freebsd-aout)
8904300346aeSmrg	  major=.$current
8905300346aeSmrg	  versuffix=.$current.$revision
8906d656433aSmrg	  ;;
8907d656433aSmrg
8908d656433aSmrg	freebsd-elf)
8909300346aeSmrg	  func_arith $current - $age
8910300346aeSmrg	  major=.$func_arith_result
8911300346aeSmrg	  versuffix=$major.$age.$revision
8912d656433aSmrg	  ;;
8913d656433aSmrg
8914d656433aSmrg	irix | nonstopux)
8915300346aeSmrg	  if test no = "$lt_irix_increment"; then
8916d656433aSmrg	    func_arith $current - $age
8917d656433aSmrg	  else
8918d656433aSmrg	    func_arith $current - $age + 1
8919d656433aSmrg	  fi
8920d656433aSmrg	  major=$func_arith_result
8921d656433aSmrg
8922d656433aSmrg	  case $version_type in
8923d656433aSmrg	    nonstopux) verstring_prefix=nonstopux ;;
8924d656433aSmrg	    *)         verstring_prefix=sgi ;;
8925d656433aSmrg	  esac
8926300346aeSmrg	  verstring=$verstring_prefix$major.$revision
8927d656433aSmrg
8928d656433aSmrg	  # Add in all the interfaces that we are compatible with.
8929d656433aSmrg	  loop=$revision
8930300346aeSmrg	  while test 0 -ne "$loop"; do
8931d656433aSmrg	    func_arith $revision - $loop
8932d656433aSmrg	    iface=$func_arith_result
8933d656433aSmrg	    func_arith $loop - 1
8934d656433aSmrg	    loop=$func_arith_result
8935300346aeSmrg	    verstring=$verstring_prefix$major.$iface:$verstring
8936d656433aSmrg	  done
8937d656433aSmrg
8938300346aeSmrg	  # Before this point, $major must not contain '.'.
8939d656433aSmrg	  major=.$major
8940300346aeSmrg	  versuffix=$major.$revision
8941d656433aSmrg	  ;;
8942d656433aSmrg
89430a6b08f8Smrg	linux) # correct to gnu/linux during the next big refactor
8944d656433aSmrg	  func_arith $current - $age
8945d656433aSmrg	  major=.$func_arith_result
8946300346aeSmrg	  versuffix=$major.$age.$revision
8947d656433aSmrg	  ;;
8948d656433aSmrg
8949d656433aSmrg	osf)
8950d656433aSmrg	  func_arith $current - $age
8951d656433aSmrg	  major=.$func_arith_result
8952300346aeSmrg	  versuffix=.$current.$age.$revision
8953300346aeSmrg	  verstring=$current.$age.$revision
8954d656433aSmrg
8955d656433aSmrg	  # Add in all the interfaces that we are compatible with.
8956d656433aSmrg	  loop=$age
8957300346aeSmrg	  while test 0 -ne "$loop"; do
8958d656433aSmrg	    func_arith $current - $loop
8959d656433aSmrg	    iface=$func_arith_result
8960d656433aSmrg	    func_arith $loop - 1
8961d656433aSmrg	    loop=$func_arith_result
8962300346aeSmrg	    verstring=$verstring:$iface.0
8963d656433aSmrg	  done
8964d656433aSmrg
8965d656433aSmrg	  # Make executables depend on our current version.
8966300346aeSmrg	  func_append verstring ":$current.0"
8967d656433aSmrg	  ;;
8968d656433aSmrg
8969d656433aSmrg	qnx)
8970300346aeSmrg	  major=.$current
8971300346aeSmrg	  versuffix=.$current
8972300346aeSmrg	  ;;
8973300346aeSmrg
8974300346aeSmrg	sco)
8975300346aeSmrg	  major=.$current
8976300346aeSmrg	  versuffix=.$current
8977d656433aSmrg	  ;;
8978d656433aSmrg
8979d656433aSmrg	sunos)
8980300346aeSmrg	  major=.$current
8981300346aeSmrg	  versuffix=.$current.$revision
8982d656433aSmrg	  ;;
8983d656433aSmrg
8984d656433aSmrg	windows)
8985d656433aSmrg	  # Use '-' rather than '.', since we only want one
8986300346aeSmrg	  # extension on DOS 8.3 file systems.
8987d656433aSmrg	  func_arith $current - $age
8988d656433aSmrg	  major=$func_arith_result
8989300346aeSmrg	  versuffix=-$major
8990d656433aSmrg	  ;;
8991d656433aSmrg
8992d656433aSmrg	*)
8993300346aeSmrg	  func_fatal_configuration "unknown library version type '$version_type'"
8994d656433aSmrg	  ;;
8995d656433aSmrg	esac
8996d656433aSmrg
8997d656433aSmrg	# Clear the version info if we defaulted, and they specified a release.
8998d656433aSmrg	if test -z "$vinfo" && test -n "$release"; then
8999d656433aSmrg	  major=
9000d656433aSmrg	  case $version_type in
9001d656433aSmrg	  darwin)
9002d656433aSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
9003d656433aSmrg	    # problems, so we reset it completely
9004d656433aSmrg	    verstring=
9005d656433aSmrg	    ;;
9006d656433aSmrg	  *)
9007300346aeSmrg	    verstring=0.0
9008d656433aSmrg	    ;;
9009d656433aSmrg	  esac
9010300346aeSmrg	  if test no = "$need_version"; then
9011d656433aSmrg	    versuffix=
9012d656433aSmrg	  else
9013300346aeSmrg	    versuffix=.0.0
9014d656433aSmrg	  fi
9015d656433aSmrg	fi
9016d656433aSmrg
9017d656433aSmrg	# Remove version info from name if versioning should be avoided
9018300346aeSmrg	if test yes,no = "$avoid_version,$need_version"; then
9019d656433aSmrg	  major=
9020d656433aSmrg	  versuffix=
9021300346aeSmrg	  verstring=
9022d656433aSmrg	fi
9023d656433aSmrg
9024d656433aSmrg	# Check to see if the archive will have undefined symbols.
9025300346aeSmrg	if test yes = "$allow_undefined"; then
9026300346aeSmrg	  if test unsupported = "$allow_undefined_flag"; then
9027300346aeSmrg	    if test yes = "$build_old_libs"; then
9028300346aeSmrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
9029300346aeSmrg	      build_libtool_libs=no
9030300346aeSmrg	    else
9031300346aeSmrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
9032300346aeSmrg	    fi
9033d656433aSmrg	  fi
9034d656433aSmrg	else
9035d656433aSmrg	  # Don't allow undefined symbols.
9036300346aeSmrg	  allow_undefined_flag=$no_undefined_flag
9037d656433aSmrg	fi
9038d656433aSmrg
9039d656433aSmrg      fi
9040d656433aSmrg
9041300346aeSmrg      func_generate_dlsyms "$libname" "$libname" :
90423c15da26Smrg      func_append libobjs " $symfileobj"
9043300346aeSmrg      test " " = "$libobjs" && libobjs=
9044d656433aSmrg
9045300346aeSmrg      if test relink != "$opt_mode"; then
9046d656433aSmrg	# Remove our outputs, but don't remove object files since they
9047d656433aSmrg	# may have been created when compiling PIC objects.
9048d656433aSmrg	removelist=
9049d656433aSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
9050d656433aSmrg	for p in $tempremovelist; do
9051d656433aSmrg	  case $p in
9052d656433aSmrg	    *.$objext | *.gcno)
9053d656433aSmrg	       ;;
9054300346aeSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
9055300346aeSmrg	       if test -n "$precious_files_regex"; then
9056d656433aSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
9057d656433aSmrg		 then
9058d656433aSmrg		   continue
9059d656433aSmrg		 fi
9060d656433aSmrg	       fi
90613c15da26Smrg	       func_append removelist " $p"
9062d656433aSmrg	       ;;
9063d656433aSmrg	    *) ;;
9064d656433aSmrg	  esac
9065d656433aSmrg	done
9066d656433aSmrg	test -n "$removelist" && \
9067d656433aSmrg	  func_show_eval "${RM}r \$removelist"
9068d656433aSmrg      fi
9069d656433aSmrg
9070d656433aSmrg      # Now set the variables for building old libraries.
9071300346aeSmrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
90723c15da26Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
9073d656433aSmrg
9074d656433aSmrg	# Transform .lo files to .o files.
9075300346aeSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
9076d656433aSmrg      fi
9077d656433aSmrg
9078d656433aSmrg      # Eliminate all temporary directories.
9079d656433aSmrg      #for path in $notinst_path; do
9080555991fdSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9081555991fdSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9082555991fdSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
9083d656433aSmrg      #done
9084d656433aSmrg
9085d656433aSmrg      if test -n "$xrpath"; then
9086d656433aSmrg	# If the user specified any rpath flags, then add them.
9087d656433aSmrg	temp_xrpath=
9088d656433aSmrg	for libdir in $xrpath; do
90893c15da26Smrg	  func_replace_sysroot "$libdir"
90903c15da26Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
9091d656433aSmrg	  case "$finalize_rpath " in
9092d656433aSmrg	  *" $libdir "*) ;;
90933c15da26Smrg	  *) func_append finalize_rpath " $libdir" ;;
9094d656433aSmrg	  esac
9095d656433aSmrg	done
9096300346aeSmrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
9097d656433aSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
9098d656433aSmrg	fi
9099d656433aSmrg      fi
9100d656433aSmrg
9101d656433aSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
9102300346aeSmrg      old_dlfiles=$dlfiles
9103d656433aSmrg      dlfiles=
9104d656433aSmrg      for lib in $old_dlfiles; do
9105d656433aSmrg	case " $dlprefiles $dlfiles " in
9106d656433aSmrg	*" $lib "*) ;;
91073c15da26Smrg	*) func_append dlfiles " $lib" ;;
9108d656433aSmrg	esac
9109d656433aSmrg      done
9110d656433aSmrg
9111d656433aSmrg      # Make sure dlprefiles contains only unique files
9112300346aeSmrg      old_dlprefiles=$dlprefiles
9113d656433aSmrg      dlprefiles=
9114d656433aSmrg      for lib in $old_dlprefiles; do
9115d656433aSmrg	case "$dlprefiles " in
9116d656433aSmrg	*" $lib "*) ;;
91173c15da26Smrg	*) func_append dlprefiles " $lib" ;;
9118d656433aSmrg	esac
9119d656433aSmrg      done
9120d656433aSmrg
9121300346aeSmrg      if test yes = "$build_libtool_libs"; then
9122d656433aSmrg	if test -n "$rpath"; then
9123d656433aSmrg	  case $host in
9124555991fdSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
9125d656433aSmrg	    # these systems don't actually have a c library (as such)!
9126d656433aSmrg	    ;;
9127d656433aSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
9128d656433aSmrg	    # Rhapsody C library is in the System framework
91293c15da26Smrg	    func_append deplibs " System.ltframework"
9130d656433aSmrg	    ;;
9131d656433aSmrg	  *-*-netbsd*)
9132d656433aSmrg	    # Don't link with libc until the a.out ld.so is fixed.
9133d656433aSmrg	    ;;
9134d656433aSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
9135d656433aSmrg	    # Do not include libc due to us having libc/libc_r.
9136d656433aSmrg	    ;;
9137d656433aSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
9138d656433aSmrg	    # Causes problems with __ctype
9139d656433aSmrg	    ;;
9140d656433aSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
9141d656433aSmrg	    # Compiler inserts libc in the correct place for threads to work
9142d656433aSmrg	    ;;
9143d656433aSmrg	  *)
9144d656433aSmrg	    # Add libc to deplibs on all other systems if necessary.
9145300346aeSmrg	    if test yes = "$build_libtool_need_lc"; then
91463c15da26Smrg	      func_append deplibs " -lc"
9147d656433aSmrg	    fi
9148d656433aSmrg	    ;;
9149d656433aSmrg	  esac
9150d656433aSmrg	fi
9151d656433aSmrg
9152d656433aSmrg	# Transform deplibs into only deplibs that can be linked in shared.
9153d656433aSmrg	name_save=$name
9154d656433aSmrg	libname_save=$libname
9155d656433aSmrg	release_save=$release
9156d656433aSmrg	versuffix_save=$versuffix
9157d656433aSmrg	major_save=$major
9158d656433aSmrg	# I'm not sure if I'm treating the release correctly.  I think
9159d656433aSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
9160d656433aSmrg	# add it in twice.  Is that correct?
9161300346aeSmrg	release=
9162300346aeSmrg	versuffix=
9163300346aeSmrg	major=
9164d656433aSmrg	newdeplibs=
9165d656433aSmrg	droppeddeps=no
9166d656433aSmrg	case $deplibs_check_method in
9167d656433aSmrg	pass_all)
9168d656433aSmrg	  # Don't check for shared/static.  Everything works.
9169d656433aSmrg	  # This might be a little naive.  We might want to check
9170d656433aSmrg	  # whether the library exists or not.  But this is on
9171d656433aSmrg	  # osf3 & osf4 and I'm not really sure... Just
9172d656433aSmrg	  # implementing what was already the behavior.
9173d656433aSmrg	  newdeplibs=$deplibs
9174d656433aSmrg	  ;;
9175d656433aSmrg	test_compile)
9176d656433aSmrg	  # This code stresses the "libraries are programs" paradigm to its
9177d656433aSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
9178d656433aSmrg	  # against the deplibs as a proxy for the library.  Then we can check
9179d656433aSmrg	  # whether they linked in statically or dynamically with ldd.
9180d656433aSmrg	  $opt_dry_run || $RM conftest.c
9181d656433aSmrg	  cat > conftest.c <<EOF
9182d656433aSmrg	  int main() { return 0; }
9183d656433aSmrgEOF
9184d656433aSmrg	  $opt_dry_run || $RM conftest
9185d656433aSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
9186d656433aSmrg	    ldd_output=`ldd conftest`
9187d656433aSmrg	    for i in $deplibs; do
9188d656433aSmrg	      case $i in
9189d656433aSmrg	      -l*)
9190d656433aSmrg		func_stripname -l '' "$i"
9191d656433aSmrg		name=$func_stripname_result
9192300346aeSmrg		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9193d656433aSmrg		  case " $predeps $postdeps " in
9194d656433aSmrg		  *" $i "*)
91953c15da26Smrg		    func_append newdeplibs " $i"
9196300346aeSmrg		    i=
9197d656433aSmrg		    ;;
9198d656433aSmrg		  esac
9199d656433aSmrg		fi
9200300346aeSmrg		if test -n "$i"; then
9201d656433aSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
9202d656433aSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9203d656433aSmrg		  set dummy $deplib_matches; shift
9204d656433aSmrg		  deplib_match=$1
9205300346aeSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
92063c15da26Smrg		    func_append newdeplibs " $i"
9207d656433aSmrg		  else
9208d656433aSmrg		    droppeddeps=yes
9209555991fdSmrg		    echo
9210d656433aSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9211555991fdSmrg		    echo "*** I have the capability to make that library automatically link in when"
9212555991fdSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
9213555991fdSmrg		    echo "*** shared version of the library, which I believe you do not have"
9214555991fdSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
9215555991fdSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
9216d656433aSmrg		  fi
9217d656433aSmrg		fi
9218d656433aSmrg		;;
9219d656433aSmrg	      *)
92203c15da26Smrg		func_append newdeplibs " $i"
9221d656433aSmrg		;;
9222d656433aSmrg	      esac
9223d656433aSmrg	    done
9224d656433aSmrg	  else
9225d656433aSmrg	    # Error occurred in the first compile.  Let's try to salvage
9226d656433aSmrg	    # the situation: Compile a separate program for each library.
9227d656433aSmrg	    for i in $deplibs; do
9228d656433aSmrg	      case $i in
9229d656433aSmrg	      -l*)
9230d656433aSmrg		func_stripname -l '' "$i"
9231d656433aSmrg		name=$func_stripname_result
9232d656433aSmrg		$opt_dry_run || $RM conftest
9233d656433aSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
9234d656433aSmrg		  ldd_output=`ldd conftest`
9235300346aeSmrg		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9236d656433aSmrg		    case " $predeps $postdeps " in
9237d656433aSmrg		    *" $i "*)
92383c15da26Smrg		      func_append newdeplibs " $i"
9239300346aeSmrg		      i=
9240d656433aSmrg		      ;;
9241d656433aSmrg		    esac
9242d656433aSmrg		  fi
9243300346aeSmrg		  if test -n "$i"; then
9244d656433aSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
9245d656433aSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9246d656433aSmrg		    set dummy $deplib_matches; shift
9247d656433aSmrg		    deplib_match=$1
9248300346aeSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
92493c15da26Smrg		      func_append newdeplibs " $i"
9250d656433aSmrg		    else
9251d656433aSmrg		      droppeddeps=yes
9252555991fdSmrg		      echo
9253d656433aSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9254555991fdSmrg		      echo "*** I have the capability to make that library automatically link in when"
9255555991fdSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
9256555991fdSmrg		      echo "*** shared version of the library, which you do not appear to have"
9257555991fdSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
9258555991fdSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
9259d656433aSmrg		    fi
9260d656433aSmrg		  fi
9261d656433aSmrg		else
9262d656433aSmrg		  droppeddeps=yes
9263555991fdSmrg		  echo
9264d656433aSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
9265555991fdSmrg		  echo "*** make it link in!  You will probably need to install it or some"
9266555991fdSmrg		  echo "*** library that it depends on before this library will be fully"
9267555991fdSmrg		  echo "*** functional.  Installing it before continuing would be even better."
9268d656433aSmrg		fi
9269d656433aSmrg		;;
9270d656433aSmrg	      *)
92713c15da26Smrg		func_append newdeplibs " $i"
9272d656433aSmrg		;;
9273d656433aSmrg	      esac
9274d656433aSmrg	    done
9275d656433aSmrg	  fi
9276d656433aSmrg	  ;;
9277d656433aSmrg	file_magic*)
9278d656433aSmrg	  set dummy $deplibs_check_method; shift
9279d656433aSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9280d656433aSmrg	  for a_deplib in $deplibs; do
9281d656433aSmrg	    case $a_deplib in
9282d656433aSmrg	    -l*)
9283d656433aSmrg	      func_stripname -l '' "$a_deplib"
9284d656433aSmrg	      name=$func_stripname_result
9285300346aeSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9286d656433aSmrg		case " $predeps $postdeps " in
9287d656433aSmrg		*" $a_deplib "*)
92883c15da26Smrg		  func_append newdeplibs " $a_deplib"
9289300346aeSmrg		  a_deplib=
9290d656433aSmrg		  ;;
9291d656433aSmrg		esac
9292d656433aSmrg	      fi
9293300346aeSmrg	      if test -n "$a_deplib"; then
9294d656433aSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
92953c15da26Smrg		if test -n "$file_magic_glob"; then
92963c15da26Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
92973c15da26Smrg		else
92983c15da26Smrg		  libnameglob=$libname
92993c15da26Smrg		fi
9300300346aeSmrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
9301d656433aSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9302300346aeSmrg		  if test yes = "$want_nocaseglob"; then
93033c15da26Smrg		    shopt -s nocaseglob
93043c15da26Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
93053c15da26Smrg		    $nocaseglob
93063c15da26Smrg		  else
93073c15da26Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
93083c15da26Smrg		  fi
9309d656433aSmrg		  for potent_lib in $potential_libs; do
9310d656433aSmrg		      # Follow soft links.
9311d656433aSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
9312d656433aSmrg			 $GREP " -> " >/dev/null; then
9313d656433aSmrg			continue
9314d656433aSmrg		      fi
9315d656433aSmrg		      # The statement above tries to avoid entering an
9316d656433aSmrg		      # endless loop below, in case of cyclic links.
9317d656433aSmrg		      # We might still enter an endless loop, since a link
9318d656433aSmrg		      # loop can be closed while we follow links,
9319d656433aSmrg		      # but so what?
9320300346aeSmrg		      potlib=$potent_lib
9321d656433aSmrg		      while test -h "$potlib" 2>/dev/null; do
9322300346aeSmrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
9323d656433aSmrg			case $potliblink in
9324300346aeSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
9325300346aeSmrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
9326d656433aSmrg			esac
9327d656433aSmrg		      done
9328d656433aSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
9329d656433aSmrg			 $SED -e 10q |
9330d656433aSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
93313c15da26Smrg			func_append newdeplibs " $a_deplib"
9332300346aeSmrg			a_deplib=
9333d656433aSmrg			break 2
9334d656433aSmrg		      fi
9335d656433aSmrg		  done
9336d656433aSmrg		done
9337d656433aSmrg	      fi
9338300346aeSmrg	      if test -n "$a_deplib"; then
9339d656433aSmrg		droppeddeps=yes
9340555991fdSmrg		echo
9341d656433aSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9342555991fdSmrg		echo "*** I have the capability to make that library automatically link in when"
9343555991fdSmrg		echo "*** you link to this library.  But I can only do this if you have a"
9344555991fdSmrg		echo "*** shared version of the library, which you do not appear to have"
9345555991fdSmrg		echo "*** because I did check the linker path looking for a file starting"
9346300346aeSmrg		if test -z "$potlib"; then
9347d656433aSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
9348d656433aSmrg		else
9349d656433aSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9350d656433aSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
9351d656433aSmrg		fi
9352d656433aSmrg	      fi
9353d656433aSmrg	      ;;
9354d656433aSmrg	    *)
9355d656433aSmrg	      # Add a -L argument.
93563c15da26Smrg	      func_append newdeplibs " $a_deplib"
9357d656433aSmrg	      ;;
9358d656433aSmrg	    esac
9359d656433aSmrg	  done # Gone through all deplibs.
9360d656433aSmrg	  ;;
9361d656433aSmrg	match_pattern*)
9362d656433aSmrg	  set dummy $deplibs_check_method; shift
9363d656433aSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9364d656433aSmrg	  for a_deplib in $deplibs; do
9365d656433aSmrg	    case $a_deplib in
9366d656433aSmrg	    -l*)
9367d656433aSmrg	      func_stripname -l '' "$a_deplib"
9368d656433aSmrg	      name=$func_stripname_result
9369300346aeSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9370d656433aSmrg		case " $predeps $postdeps " in
9371d656433aSmrg		*" $a_deplib "*)
93723c15da26Smrg		  func_append newdeplibs " $a_deplib"
9373300346aeSmrg		  a_deplib=
9374d656433aSmrg		  ;;
9375d656433aSmrg		esac
9376d656433aSmrg	      fi
9377300346aeSmrg	      if test -n "$a_deplib"; then
9378d656433aSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9379d656433aSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9380d656433aSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
9381d656433aSmrg		  for potent_lib in $potential_libs; do
9382300346aeSmrg		    potlib=$potent_lib # see symlink-check above in file_magic test
9383555991fdSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
9384d656433aSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
93853c15da26Smrg		      func_append newdeplibs " $a_deplib"
9386300346aeSmrg		      a_deplib=
9387d656433aSmrg		      break 2
9388d656433aSmrg		    fi
9389d656433aSmrg		  done
9390d656433aSmrg		done
9391d656433aSmrg	      fi
9392300346aeSmrg	      if test -n "$a_deplib"; then
9393d656433aSmrg		droppeddeps=yes
9394555991fdSmrg		echo
9395d656433aSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9396555991fdSmrg		echo "*** I have the capability to make that library automatically link in when"
9397555991fdSmrg		echo "*** you link to this library.  But I can only do this if you have a"
9398555991fdSmrg		echo "*** shared version of the library, which you do not appear to have"
9399555991fdSmrg		echo "*** because I did check the linker path looking for a file starting"
9400300346aeSmrg		if test -z "$potlib"; then
9401d656433aSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
9402d656433aSmrg		else
9403d656433aSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9404d656433aSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
9405d656433aSmrg		fi
9406d656433aSmrg	      fi
9407d656433aSmrg	      ;;
9408d656433aSmrg	    *)
9409d656433aSmrg	      # Add a -L argument.
94103c15da26Smrg	      func_append newdeplibs " $a_deplib"
9411d656433aSmrg	      ;;
9412d656433aSmrg	    esac
9413d656433aSmrg	  done # Gone through all deplibs.
9414d656433aSmrg	  ;;
9415d656433aSmrg	none | unknown | *)
9416300346aeSmrg	  newdeplibs=
9417555991fdSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
9418300346aeSmrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9419300346aeSmrg	    for i in $predeps $postdeps; do
9420d656433aSmrg	      # can't use Xsed below, because $i might contain '/'
9421300346aeSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
9422d656433aSmrg	    done
9423d656433aSmrg	  fi
9424555991fdSmrg	  case $tmp_deplibs in
9425555991fdSmrg	  *[!\	\ ]*)
9426555991fdSmrg	    echo
9427300346aeSmrg	    if test none = "$deplibs_check_method"; then
9428555991fdSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
9429d656433aSmrg	    else
9430555991fdSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
9431d656433aSmrg	    fi
9432555991fdSmrg	    echo "*** All declared inter-library dependencies are being dropped."
9433d656433aSmrg	    droppeddeps=yes
9434555991fdSmrg	    ;;
9435555991fdSmrg	  esac
9436d656433aSmrg	  ;;
9437d656433aSmrg	esac
9438d656433aSmrg	versuffix=$versuffix_save
9439d656433aSmrg	major=$major_save
9440d656433aSmrg	release=$release_save
9441d656433aSmrg	libname=$libname_save
9442d656433aSmrg	name=$name_save
9443d656433aSmrg
9444d656433aSmrg	case $host in
9445d656433aSmrg	*-*-rhapsody* | *-*-darwin1.[012])
9446d656433aSmrg	  # On Rhapsody replace the C library with the System framework
9447555991fdSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
9448d656433aSmrg	  ;;
9449d656433aSmrg	esac
9450d656433aSmrg
9451300346aeSmrg	if test yes = "$droppeddeps"; then
9452300346aeSmrg	  if test yes = "$module"; then
9453555991fdSmrg	    echo
9454555991fdSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
9455d656433aSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
9456555991fdSmrg	    echo "*** a static module, that should work as long as the dlopening"
9457555991fdSmrg	    echo "*** application is linked with the -dlopen flag."
9458d656433aSmrg	    if test -z "$global_symbol_pipe"; then
9459555991fdSmrg	      echo
9460555991fdSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
9461300346aeSmrg	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9462555991fdSmrg	      echo "*** not find such a program.  So, this module is probably useless."
9463300346aeSmrg	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
9464d656433aSmrg	    fi
9465300346aeSmrg	    if test no = "$build_old_libs"; then
9466300346aeSmrg	      oldlibs=$output_objdir/$libname.$libext
9467d656433aSmrg	      build_libtool_libs=module
9468d656433aSmrg	      build_old_libs=yes
9469d656433aSmrg	    else
9470d656433aSmrg	      build_libtool_libs=no
9471d656433aSmrg	    fi
9472d656433aSmrg	  else
9473555991fdSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
9474555991fdSmrg	    echo "*** automatically added whenever a program is linked with this library"
9475555991fdSmrg	    echo "*** or is declared to -dlopen it."
9476d656433aSmrg
9477300346aeSmrg	    if test no = "$allow_undefined"; then
9478555991fdSmrg	      echo
9479555991fdSmrg	      echo "*** Since this library must not contain undefined symbols,"
9480555991fdSmrg	      echo "*** because either the platform does not support them or"
9481555991fdSmrg	      echo "*** it was explicitly requested with -no-undefined,"
9482555991fdSmrg	      echo "*** libtool will only create a static version of it."
9483300346aeSmrg	      if test no = "$build_old_libs"; then
9484300346aeSmrg		oldlibs=$output_objdir/$libname.$libext
9485d656433aSmrg		build_libtool_libs=module
9486d656433aSmrg		build_old_libs=yes
9487d656433aSmrg	      else
9488d656433aSmrg		build_libtool_libs=no
9489d656433aSmrg	      fi
9490d656433aSmrg	    fi
9491d656433aSmrg	  fi
9492d656433aSmrg	fi
9493d656433aSmrg	# Done checking deplibs!
9494d656433aSmrg	deplibs=$newdeplibs
9495d656433aSmrg      fi
9496d656433aSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9497d656433aSmrg      case $host in
9498d656433aSmrg	*-*-darwin*)
9499555991fdSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9500555991fdSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9501555991fdSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9502d656433aSmrg	  ;;
9503d656433aSmrg      esac
9504d656433aSmrg
9505d656433aSmrg      # move library search paths that coincide with paths to not yet
9506d656433aSmrg      # installed libraries to the beginning of the library search list
9507d656433aSmrg      new_libs=
9508d656433aSmrg      for path in $notinst_path; do
9509d656433aSmrg	case " $new_libs " in
9510d656433aSmrg	*" -L$path/$objdir "*) ;;
9511d656433aSmrg	*)
9512d656433aSmrg	  case " $deplibs " in
9513d656433aSmrg	  *" -L$path/$objdir "*)
95143c15da26Smrg	    func_append new_libs " -L$path/$objdir" ;;
9515d656433aSmrg	  esac
9516d656433aSmrg	  ;;
9517d656433aSmrg	esac
9518d656433aSmrg      done
9519d656433aSmrg      for deplib in $deplibs; do
9520d656433aSmrg	case $deplib in
9521d656433aSmrg	-L*)
9522d656433aSmrg	  case " $new_libs " in
9523d656433aSmrg	  *" $deplib "*) ;;
95243c15da26Smrg	  *) func_append new_libs " $deplib" ;;
9525d656433aSmrg	  esac
9526d656433aSmrg	  ;;
95273c15da26Smrg	*) func_append new_libs " $deplib" ;;
9528d656433aSmrg	esac
9529d656433aSmrg      done
9530300346aeSmrg      deplibs=$new_libs
9531d656433aSmrg
9532d656433aSmrg      # All the library-specific variables (install_libdir is set above).
9533d656433aSmrg      library_names=
9534d656433aSmrg      old_library=
9535d656433aSmrg      dlname=
9536d656433aSmrg
9537d656433aSmrg      # Test again, we may have decided not to build it any more
9538300346aeSmrg      if test yes = "$build_libtool_libs"; then
9539300346aeSmrg	# Remove $wl instances when linking with ld.
95400a6b08f8Smrg	# FIXME: should test the right _cmds variable.
95410a6b08f8Smrg	case $archive_cmds in
95420a6b08f8Smrg	  *\$LD\ *) wl= ;;
95430a6b08f8Smrg        esac
9544300346aeSmrg	if test yes = "$hardcode_into_libs"; then
9545d656433aSmrg	  # Hardcode the library paths
9546d656433aSmrg	  hardcode_libdirs=
9547d656433aSmrg	  dep_rpath=
9548300346aeSmrg	  rpath=$finalize_rpath
9549300346aeSmrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
9550d656433aSmrg	  for libdir in $rpath; do
9551d656433aSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
9552d656433aSmrg	      if test -n "$hardcode_libdir_separator"; then
95533c15da26Smrg		func_replace_sysroot "$libdir"
95543c15da26Smrg		libdir=$func_replace_sysroot_result
9555d656433aSmrg		if test -z "$hardcode_libdirs"; then
9556300346aeSmrg		  hardcode_libdirs=$libdir
9557d656433aSmrg		else
9558d656433aSmrg		  # Just accumulate the unique libdirs.
9559d656433aSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9560d656433aSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9561d656433aSmrg		    ;;
9562d656433aSmrg		  *)
95633c15da26Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
9564d656433aSmrg		    ;;
9565d656433aSmrg		  esac
9566d656433aSmrg		fi
9567d656433aSmrg	      else
9568d656433aSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
95693c15da26Smrg		func_append dep_rpath " $flag"
9570d656433aSmrg	      fi
9571d656433aSmrg	    elif test -n "$runpath_var"; then
9572d656433aSmrg	      case "$perm_rpath " in
9573d656433aSmrg	      *" $libdir "*) ;;
95740a6b08f8Smrg	      *) func_append perm_rpath " $libdir" ;;
9575d656433aSmrg	      esac
9576d656433aSmrg	    fi
9577d656433aSmrg	  done
9578d656433aSmrg	  # Substitute the hardcoded libdirs into the rpath.
9579d656433aSmrg	  if test -n "$hardcode_libdir_separator" &&
9580d656433aSmrg	     test -n "$hardcode_libdirs"; then
9581300346aeSmrg	    libdir=$hardcode_libdirs
95820a6b08f8Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
9583d656433aSmrg	  fi
9584d656433aSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
9585d656433aSmrg	    # We should set the runpath_var.
9586d656433aSmrg	    rpath=
9587d656433aSmrg	    for dir in $perm_rpath; do
95883c15da26Smrg	      func_append rpath "$dir:"
9589d656433aSmrg	    done
9590d656433aSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
9591d656433aSmrg	  fi
9592d656433aSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
9593d656433aSmrg	fi
9594126a8a12Smrg
9595300346aeSmrg	shlibpath=$finalize_shlibpath
9596300346aeSmrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
9597d656433aSmrg	if test -n "$shlibpath"; then
9598d656433aSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
9599d656433aSmrg	fi
9600126a8a12Smrg
9601d656433aSmrg	# Get the real and link names of the library.
9602d656433aSmrg	eval shared_ext=\"$shrext_cmds\"
9603d656433aSmrg	eval library_names=\"$library_names_spec\"
9604d656433aSmrg	set dummy $library_names
9605d656433aSmrg	shift
9606300346aeSmrg	realname=$1
9607d656433aSmrg	shift
9608126a8a12Smrg
9609d656433aSmrg	if test -n "$soname_spec"; then
9610d656433aSmrg	  eval soname=\"$soname_spec\"
9611d656433aSmrg	else
9612300346aeSmrg	  soname=$realname
9613d656433aSmrg	fi
9614d656433aSmrg	if test -z "$dlname"; then
9615d656433aSmrg	  dlname=$soname
9616d656433aSmrg	fi
9617126a8a12Smrg
9618300346aeSmrg	lib=$output_objdir/$realname
9619d656433aSmrg	linknames=
9620d656433aSmrg	for link
9621d656433aSmrg	do
96223c15da26Smrg	  func_append linknames " $link"
9623d656433aSmrg	done
9624126a8a12Smrg
9625d656433aSmrg	# Use standard objects if they are pic
9626555991fdSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
9627d656433aSmrg	test "X$libobjs" = "X " && libobjs=
9628126a8a12Smrg
9629d656433aSmrg	delfiles=
9630d656433aSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9631d656433aSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
9632300346aeSmrg	  export_symbols=$output_objdir/$libname.uexp
96333c15da26Smrg	  func_append delfiles " $export_symbols"
9634d656433aSmrg	fi
9635126a8a12Smrg
9636d656433aSmrg	orig_export_symbols=
9637d656433aSmrg	case $host_os in
9638d656433aSmrg	cygwin* | mingw* | cegcc*)
9639d656433aSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
9640d656433aSmrg	    # exporting using user supplied symfile
9641300346aeSmrg	    func_dll_def_p "$export_symbols" || {
9642d656433aSmrg	      # and it's NOT already a .def file. Must figure out
9643d656433aSmrg	      # which of the given symbols are data symbols and tag
9644d656433aSmrg	      # them as such. So, trigger use of export_symbols_cmds.
9645d656433aSmrg	      # export_symbols gets reassigned inside the "prepare
9646d656433aSmrg	      # the list of exported symbols" if statement, so the
9647d656433aSmrg	      # include_expsyms logic still works.
9648300346aeSmrg	      orig_export_symbols=$export_symbols
9649d656433aSmrg	      export_symbols=
9650d656433aSmrg	      always_export_symbols=yes
9651300346aeSmrg	    }
9652d656433aSmrg	  fi
9653d656433aSmrg	  ;;
9654d656433aSmrg	esac
9655126a8a12Smrg
9656d656433aSmrg	# Prepare the list of exported symbols
9657d656433aSmrg	if test -z "$export_symbols"; then
9658300346aeSmrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
9659300346aeSmrg	    func_verbose "generating symbol list for '$libname.la'"
9660300346aeSmrg	    export_symbols=$output_objdir/$libname.exp
9661d656433aSmrg	    $opt_dry_run || $RM $export_symbols
9662d656433aSmrg	    cmds=$export_symbols_cmds
9663300346aeSmrg	    save_ifs=$IFS; IFS='~'
96643c15da26Smrg	    for cmd1 in $cmds; do
9665300346aeSmrg	      IFS=$save_ifs
96663c15da26Smrg	      # Take the normal branch if the nm_file_list_spec branch
96673c15da26Smrg	      # doesn't work or if tool conversion is not needed.
96683c15da26Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
96693c15da26Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
96703c15da26Smrg		  try_normal_branch=yes
96713c15da26Smrg		  eval cmd=\"$cmd1\"
96723c15da26Smrg		  func_len " $cmd"
96733c15da26Smrg		  len=$func_len_result
96743c15da26Smrg		  ;;
96753c15da26Smrg		*)
96763c15da26Smrg		  try_normal_branch=no
96773c15da26Smrg		  ;;
96783c15da26Smrg	      esac
9679300346aeSmrg	      if test yes = "$try_normal_branch" \
96803c15da26Smrg		 && { test "$len" -lt "$max_cmd_len" \
96813c15da26Smrg		      || test "$max_cmd_len" -le -1; }
96823c15da26Smrg	      then
96833c15da26Smrg		func_show_eval "$cmd" 'exit $?'
96843c15da26Smrg		skipped_export=false
96853c15da26Smrg	      elif test -n "$nm_file_list_spec"; then
96863c15da26Smrg		func_basename "$output"
96873c15da26Smrg		output_la=$func_basename_result
96883c15da26Smrg		save_libobjs=$libobjs
96893c15da26Smrg		save_output=$output
9690300346aeSmrg		output=$output_objdir/$output_la.nm
96913c15da26Smrg		func_to_tool_file "$output"
96923c15da26Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
96933c15da26Smrg		func_append delfiles " $output"
96943c15da26Smrg		func_verbose "creating $NM input file list: $output"
96953c15da26Smrg		for obj in $save_libobjs; do
96963c15da26Smrg		  func_to_tool_file "$obj"
96973c15da26Smrg		  $ECHO "$func_to_tool_file_result"
96983c15da26Smrg		done > "$output"
96993c15da26Smrg		eval cmd=\"$cmd1\"
9700d656433aSmrg		func_show_eval "$cmd" 'exit $?'
97013c15da26Smrg		output=$save_output
97023c15da26Smrg		libobjs=$save_libobjs
9703d656433aSmrg		skipped_export=false
9704d656433aSmrg	      else
9705d656433aSmrg		# The command line is too long to execute in one step.
9706d656433aSmrg		func_verbose "using reloadable object file for export list..."
9707d656433aSmrg		skipped_export=:
9708d656433aSmrg		# Break out early, otherwise skipped_export may be
9709d656433aSmrg		# set to false by a later but shorter cmd.
9710d656433aSmrg		break
9711d656433aSmrg	      fi
9712d656433aSmrg	    done
9713300346aeSmrg	    IFS=$save_ifs
9714300346aeSmrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
9715d656433aSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9716d656433aSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9717d656433aSmrg	    fi
9718d656433aSmrg	  fi
9719d656433aSmrg	fi
9720126a8a12Smrg
9721d656433aSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9722300346aeSmrg	  tmp_export_symbols=$export_symbols
9723300346aeSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9724555991fdSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9725d656433aSmrg	fi
9726126a8a12Smrg
9727300346aeSmrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
9728d656433aSmrg	  # The given exports_symbols file has to be filtered, so filter it.
9729300346aeSmrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9730d656433aSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
9731300346aeSmrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
9732d656433aSmrg	  # though. Also, the filter scales superlinearly with the number of
9733d656433aSmrg	  # global variables. join(1) would be nice here, but unfortunately
9734d656433aSmrg	  # isn't a blessed tool.
9735d656433aSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
97363c15da26Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9737d656433aSmrg	  export_symbols=$output_objdir/$libname.def
9738d656433aSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9739126a8a12Smrg	fi
9740126a8a12Smrg
9741d656433aSmrg	tmp_deplibs=
9742d656433aSmrg	for test_deplib in $deplibs; do
9743d656433aSmrg	  case " $convenience " in
9744d656433aSmrg	  *" $test_deplib "*) ;;
9745d656433aSmrg	  *)
97463c15da26Smrg	    func_append tmp_deplibs " $test_deplib"
9747d656433aSmrg	    ;;
9748d656433aSmrg	  esac
9749d656433aSmrg	done
9750300346aeSmrg	deplibs=$tmp_deplibs
9751126a8a12Smrg
9752d656433aSmrg	if test -n "$convenience"; then
9753d656433aSmrg	  if test -n "$whole_archive_flag_spec" &&
9754300346aeSmrg	    test yes = "$compiler_needs_object" &&
9755d656433aSmrg	    test -z "$libobjs"; then
9756d656433aSmrg	    # extract the archives, so we have objects to list.
9757d656433aSmrg	    # TODO: could optimize this to just extract one archive.
9758d656433aSmrg	    whole_archive_flag_spec=
9759d656433aSmrg	  fi
9760d656433aSmrg	  if test -n "$whole_archive_flag_spec"; then
9761d656433aSmrg	    save_libobjs=$libobjs
9762d656433aSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9763d656433aSmrg	    test "X$libobjs" = "X " && libobjs=
9764d656433aSmrg	  else
9765300346aeSmrg	    gentop=$output_objdir/${outputname}x
97663c15da26Smrg	    func_append generated " $gentop"
9767126a8a12Smrg
9768d656433aSmrg	    func_extract_archives $gentop $convenience
97693c15da26Smrg	    func_append libobjs " $func_extract_archives_result"
9770d656433aSmrg	    test "X$libobjs" = "X " && libobjs=
9771d656433aSmrg	  fi
9772d656433aSmrg	fi
9773126a8a12Smrg
9774300346aeSmrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
9775d656433aSmrg	  eval flag=\"$thread_safe_flag_spec\"
97763c15da26Smrg	  func_append linker_flags " $flag"
9777d656433aSmrg	fi
9778126a8a12Smrg
9779d656433aSmrg	# Make a backup of the uninstalled library when relinking
9780300346aeSmrg	if test relink = "$opt_mode"; then
9781d656433aSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
9782126a8a12Smrg	fi
9783126a8a12Smrg
9784d656433aSmrg	# Do each of the archive commands.
9785300346aeSmrg	if test yes = "$module" && test -n "$module_cmds"; then
9786d656433aSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9787d656433aSmrg	    eval test_cmds=\"$module_expsym_cmds\"
9788d656433aSmrg	    cmds=$module_expsym_cmds
9789d656433aSmrg	  else
9790d656433aSmrg	    eval test_cmds=\"$module_cmds\"
9791d656433aSmrg	    cmds=$module_cmds
9792d656433aSmrg	  fi
9793d656433aSmrg	else
9794d656433aSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
9795d656433aSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
9796d656433aSmrg	    cmds=$archive_expsym_cmds
9797d656433aSmrg	  else
9798d656433aSmrg	    eval test_cmds=\"$archive_cmds\"
9799d656433aSmrg	    cmds=$archive_cmds
9800d656433aSmrg	  fi
9801126a8a12Smrg	fi
9802126a8a12Smrg
9803300346aeSmrg	if test : != "$skipped_export" &&
9804d656433aSmrg	   func_len " $test_cmds" &&
9805d656433aSmrg	   len=$func_len_result &&
9806d656433aSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9807d656433aSmrg	  :
9808d656433aSmrg	else
9809d656433aSmrg	  # The command line is too long to link in one step, link piecewise
9810d656433aSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
9811d656433aSmrg	  # script.
9812126a8a12Smrg
9813d656433aSmrg	  # Save the value of $output and $libobjs because we want to
9814d656433aSmrg	  # use them later.  If we have whole_archive_flag_spec, we
9815d656433aSmrg	  # want to use save_libobjs as it was before
9816d656433aSmrg	  # whole_archive_flag_spec was expanded, because we can't
9817d656433aSmrg	  # assume the linker understands whole_archive_flag_spec.
9818d656433aSmrg	  # This may have to be revisited, in case too many
9819d656433aSmrg	  # convenience libraries get linked in and end up exceeding
9820d656433aSmrg	  # the spec.
9821d656433aSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
9822d656433aSmrg	    save_libobjs=$libobjs
9823d656433aSmrg	  fi
9824d656433aSmrg	  save_output=$output
9825555991fdSmrg	  func_basename "$output"
9826555991fdSmrg	  output_la=$func_basename_result
9827126a8a12Smrg
9828d656433aSmrg	  # Clear the reloadable object creation command queue and
9829d656433aSmrg	  # initialize k to one.
9830d656433aSmrg	  test_cmds=
9831d656433aSmrg	  concat_cmds=
9832d656433aSmrg	  objlist=
9833d656433aSmrg	  last_robj=
9834d656433aSmrg	  k=1
9835126a8a12Smrg
9836300346aeSmrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
9837300346aeSmrg	    output=$output_objdir/$output_la.lnkscript
9838d656433aSmrg	    func_verbose "creating GNU ld script: $output"
9839555991fdSmrg	    echo 'INPUT (' > $output
9840d656433aSmrg	    for obj in $save_libobjs
9841d656433aSmrg	    do
98423c15da26Smrg	      func_to_tool_file "$obj"
98433c15da26Smrg	      $ECHO "$func_to_tool_file_result" >> $output
9844d656433aSmrg	    done
9845555991fdSmrg	    echo ')' >> $output
98463c15da26Smrg	    func_append delfiles " $output"
98473c15da26Smrg	    func_to_tool_file "$output"
98483c15da26Smrg	    output=$func_to_tool_file_result
9849300346aeSmrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
9850300346aeSmrg	    output=$output_objdir/$output_la.lnk
9851d656433aSmrg	    func_verbose "creating linker input file list: $output"
9852d656433aSmrg	    : > $output
9853d656433aSmrg	    set x $save_libobjs
9854d656433aSmrg	    shift
9855d656433aSmrg	    firstobj=
9856300346aeSmrg	    if test yes = "$compiler_needs_object"; then
9857d656433aSmrg	      firstobj="$1 "
9858d656433aSmrg	      shift
9859d656433aSmrg	    fi
9860d656433aSmrg	    for obj
9861d656433aSmrg	    do
98623c15da26Smrg	      func_to_tool_file "$obj"
98633c15da26Smrg	      $ECHO "$func_to_tool_file_result" >> $output
9864d656433aSmrg	    done
98653c15da26Smrg	    func_append delfiles " $output"
98663c15da26Smrg	    func_to_tool_file "$output"
98673c15da26Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
9868d656433aSmrg	  else
9869d656433aSmrg	    if test -n "$save_libobjs"; then
9870d656433aSmrg	      func_verbose "creating reloadable object files..."
9871300346aeSmrg	      output=$output_objdir/$output_la-$k.$objext
9872d656433aSmrg	      eval test_cmds=\"$reload_cmds\"
9873d656433aSmrg	      func_len " $test_cmds"
9874d656433aSmrg	      len0=$func_len_result
9875d656433aSmrg	      len=$len0
9876d656433aSmrg
9877d656433aSmrg	      # Loop over the list of objects to be linked.
9878d656433aSmrg	      for obj in $save_libobjs
9879d656433aSmrg	      do
9880d656433aSmrg		func_len " $obj"
9881d656433aSmrg		func_arith $len + $func_len_result
9882d656433aSmrg		len=$func_arith_result
9883300346aeSmrg		if test -z "$objlist" ||
9884d656433aSmrg		   test "$len" -lt "$max_cmd_len"; then
9885d656433aSmrg		  func_append objlist " $obj"
9886d656433aSmrg		else
9887d656433aSmrg		  # The command $test_cmds is almost too long, add a
9888d656433aSmrg		  # command to the queue.
9889300346aeSmrg		  if test 1 -eq "$k"; then
9890d656433aSmrg		    # The first file doesn't have a previous command to add.
9891555991fdSmrg		    reload_objs=$objlist
9892555991fdSmrg		    eval concat_cmds=\"$reload_cmds\"
9893d656433aSmrg		  else
9894d656433aSmrg		    # All subsequent reloadable object files will link in
9895d656433aSmrg		    # the last one created.
9896555991fdSmrg		    reload_objs="$objlist $last_robj"
9897555991fdSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
9898d656433aSmrg		  fi
9899300346aeSmrg		  last_robj=$output_objdir/$output_la-$k.$objext
9900d656433aSmrg		  func_arith $k + 1
9901d656433aSmrg		  k=$func_arith_result
9902300346aeSmrg		  output=$output_objdir/$output_la-$k.$objext
9903555991fdSmrg		  objlist=" $obj"
9904d656433aSmrg		  func_len " $last_robj"
9905d656433aSmrg		  func_arith $len0 + $func_len_result
9906d656433aSmrg		  len=$func_arith_result
9907d656433aSmrg		fi
9908d656433aSmrg	      done
9909d656433aSmrg	      # Handle the remaining objects by creating one last
9910d656433aSmrg	      # reloadable object file.  All subsequent reloadable object
9911d656433aSmrg	      # files will link in the last one created.
9912d656433aSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9913555991fdSmrg	      reload_objs="$objlist $last_robj"
9914300346aeSmrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
9915d656433aSmrg	      if test -n "$last_robj"; then
9916300346aeSmrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9917d656433aSmrg	      fi
99183c15da26Smrg	      func_append delfiles " $output"
9919126a8a12Smrg
9920d656433aSmrg	    else
9921d656433aSmrg	      output=
9922d656433aSmrg	    fi
9923d656433aSmrg
9924300346aeSmrg	    ${skipped_export-false} && {
9925300346aeSmrg	      func_verbose "generating symbol list for '$libname.la'"
9926300346aeSmrg	      export_symbols=$output_objdir/$libname.exp
9927d656433aSmrg	      $opt_dry_run || $RM $export_symbols
9928d656433aSmrg	      libobjs=$output
9929d656433aSmrg	      # Append the command to create the export file.
9930d656433aSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9931d656433aSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
9932d656433aSmrg	      if test -n "$last_robj"; then
9933d656433aSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9934d656433aSmrg	      fi
9935300346aeSmrg	    }
9936126a8a12Smrg
9937d656433aSmrg	    test -n "$save_libobjs" &&
9938d656433aSmrg	      func_verbose "creating a temporary reloadable object file: $output"
9939126a8a12Smrg
9940d656433aSmrg	    # Loop through the commands generated above and execute them.
9941300346aeSmrg	    save_ifs=$IFS; IFS='~'
9942d656433aSmrg	    for cmd in $concat_cmds; do
9943300346aeSmrg	      IFS=$save_ifs
9944300346aeSmrg	      $opt_quiet || {
9945d656433aSmrg		  func_quote_for_expand "$cmd"
9946d656433aSmrg		  eval "func_echo $func_quote_for_expand_result"
9947d656433aSmrg	      }
9948d656433aSmrg	      $opt_dry_run || eval "$cmd" || {
9949d656433aSmrg		lt_exit=$?
9950d656433aSmrg
9951d656433aSmrg		# Restore the uninstalled library and exit
9952300346aeSmrg		if test relink = "$opt_mode"; then
9953d656433aSmrg		  ( cd "$output_objdir" && \
9954d656433aSmrg		    $RM "${realname}T" && \
9955d656433aSmrg		    $MV "${realname}U" "$realname" )
9956d656433aSmrg		fi
9957126a8a12Smrg
9958d656433aSmrg		exit $lt_exit
9959d656433aSmrg	      }
9960d656433aSmrg	    done
9961300346aeSmrg	    IFS=$save_ifs
9962126a8a12Smrg
9963d656433aSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
9964d656433aSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9965d656433aSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9966126a8a12Smrg	    fi
9967126a8a12Smrg	  fi
9968126a8a12Smrg
9969300346aeSmrg          ${skipped_export-false} && {
9970d656433aSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
9971300346aeSmrg	      tmp_export_symbols=$export_symbols
9972300346aeSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9973555991fdSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9974d656433aSmrg	    fi
9975126a8a12Smrg
9976d656433aSmrg	    if test -n "$orig_export_symbols"; then
9977d656433aSmrg	      # The given exports_symbols file has to be filtered, so filter it.
9978300346aeSmrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9979d656433aSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
9980300346aeSmrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
9981d656433aSmrg	      # though. Also, the filter scales superlinearly with the number of
9982d656433aSmrg	      # global variables. join(1) would be nice here, but unfortunately
9983d656433aSmrg	      # isn't a blessed tool.
9984d656433aSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
99853c15da26Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9986d656433aSmrg	      export_symbols=$output_objdir/$libname.def
9987d656433aSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9988d656433aSmrg	    fi
9989300346aeSmrg	  }
9990126a8a12Smrg
9991d656433aSmrg	  libobjs=$output
9992d656433aSmrg	  # Restore the value of output.
9993d656433aSmrg	  output=$save_output
9994126a8a12Smrg
9995d656433aSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
9996d656433aSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9997d656433aSmrg	    test "X$libobjs" = "X " && libobjs=
9998d656433aSmrg	  fi
9999d656433aSmrg	  # Expand the library linking commands again to reset the
10000d656433aSmrg	  # value of $libobjs for piecewise linking.
10001d656433aSmrg
10002d656433aSmrg	  # Do each of the archive commands.
10003300346aeSmrg	  if test yes = "$module" && test -n "$module_cmds"; then
10004d656433aSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
10005d656433aSmrg	      cmds=$module_expsym_cmds
10006126a8a12Smrg	    else
10007d656433aSmrg	      cmds=$module_cmds
10008126a8a12Smrg	    fi
10009126a8a12Smrg	  else
10010d656433aSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
10011d656433aSmrg	      cmds=$archive_expsym_cmds
10012d656433aSmrg	    else
10013d656433aSmrg	      cmds=$archive_cmds
10014d656433aSmrg	    fi
10015126a8a12Smrg	  fi
10016126a8a12Smrg	fi
10017126a8a12Smrg
10018d656433aSmrg	if test -n "$delfiles"; then
10019d656433aSmrg	  # Append the command to remove temporary files to $cmds.
10020d656433aSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
10021d656433aSmrg	fi
10022126a8a12Smrg
10023d656433aSmrg	# Add any objects from preloaded convenience libraries
10024d656433aSmrg	if test -n "$dlprefiles"; then
10025300346aeSmrg	  gentop=$output_objdir/${outputname}x
100263c15da26Smrg	  func_append generated " $gentop"
10027126a8a12Smrg
10028d656433aSmrg	  func_extract_archives $gentop $dlprefiles
100293c15da26Smrg	  func_append libobjs " $func_extract_archives_result"
10030d656433aSmrg	  test "X$libobjs" = "X " && libobjs=
10031126a8a12Smrg	fi
10032126a8a12Smrg
10033300346aeSmrg	save_ifs=$IFS; IFS='~'
10034d656433aSmrg	for cmd in $cmds; do
10035300346aeSmrg	  IFS=$sp$nl
10036d656433aSmrg	  eval cmd=\"$cmd\"
10037300346aeSmrg	  IFS=$save_ifs
10038300346aeSmrg	  $opt_quiet || {
10039d656433aSmrg	    func_quote_for_expand "$cmd"
10040d656433aSmrg	    eval "func_echo $func_quote_for_expand_result"
10041d656433aSmrg	  }
10042d656433aSmrg	  $opt_dry_run || eval "$cmd" || {
10043d656433aSmrg	    lt_exit=$?
10044126a8a12Smrg
10045d656433aSmrg	    # Restore the uninstalled library and exit
10046300346aeSmrg	    if test relink = "$opt_mode"; then
10047d656433aSmrg	      ( cd "$output_objdir" && \
10048d656433aSmrg	        $RM "${realname}T" && \
10049d656433aSmrg		$MV "${realname}U" "$realname" )
10050126a8a12Smrg	    fi
10051126a8a12Smrg
10052d656433aSmrg	    exit $lt_exit
10053d656433aSmrg	  }
10054d656433aSmrg	done
10055300346aeSmrg	IFS=$save_ifs
10056126a8a12Smrg
10057d656433aSmrg	# Restore the uninstalled library and exit
10058300346aeSmrg	if test relink = "$opt_mode"; then
10059d656433aSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
10060126a8a12Smrg
10061d656433aSmrg	  if test -n "$convenience"; then
10062d656433aSmrg	    if test -z "$whole_archive_flag_spec"; then
10063d656433aSmrg	      func_show_eval '${RM}r "$gentop"'
10064d656433aSmrg	    fi
10065d656433aSmrg	  fi
10066126a8a12Smrg
10067d656433aSmrg	  exit $EXIT_SUCCESS
10068d656433aSmrg	fi
10069126a8a12Smrg
10070d656433aSmrg	# Create links to the real library.
10071d656433aSmrg	for linkname in $linknames; do
10072d656433aSmrg	  if test "$realname" != "$linkname"; then
10073d656433aSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
10074126a8a12Smrg	  fi
10075126a8a12Smrg	done
10076126a8a12Smrg
10077d656433aSmrg	# If -module or -export-dynamic was specified, set the dlname.
10078300346aeSmrg	if test yes = "$module" || test yes = "$export_dynamic"; then
10079d656433aSmrg	  # On all known operating systems, these are identical.
10080300346aeSmrg	  dlname=$soname
10081d656433aSmrg	fi
10082d656433aSmrg      fi
10083126a8a12Smrg      ;;
10084126a8a12Smrg
10085d656433aSmrg    obj)
10086300346aeSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
10087300346aeSmrg	func_warning "'-dlopen' is ignored for objects"
10088d656433aSmrg      fi
10089126a8a12Smrg
10090d656433aSmrg      case " $deplibs" in
10091d656433aSmrg      *\ -l* | *\ -L*)
10092300346aeSmrg	func_warning "'-l' and '-L' are ignored for objects" ;;
10093126a8a12Smrg      esac
10094126a8a12Smrg
10095d656433aSmrg      test -n "$rpath" && \
10096300346aeSmrg	func_warning "'-rpath' is ignored for objects"
10097126a8a12Smrg
10098d656433aSmrg      test -n "$xrpath" && \
10099300346aeSmrg	func_warning "'-R' is ignored for objects"
10100126a8a12Smrg
10101d656433aSmrg      test -n "$vinfo" && \
10102300346aeSmrg	func_warning "'-version-info' is ignored for objects"
10103d656433aSmrg
10104d656433aSmrg      test -n "$release" && \
10105300346aeSmrg	func_warning "'-release' is ignored for objects"
10106d656433aSmrg
10107d656433aSmrg      case $output in
10108d656433aSmrg      *.lo)
10109d656433aSmrg	test -n "$objs$old_deplibs" && \
10110300346aeSmrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
10111d656433aSmrg
10112d656433aSmrg	libobj=$output
10113d656433aSmrg	func_lo2o "$libobj"
10114d656433aSmrg	obj=$func_lo2o_result
10115126a8a12Smrg	;;
10116126a8a12Smrg      *)
10117d656433aSmrg	libobj=
10118300346aeSmrg	obj=$output
10119126a8a12Smrg	;;
10120126a8a12Smrg      esac
10121126a8a12Smrg
10122d656433aSmrg      # Delete the old objects.
10123d656433aSmrg      $opt_dry_run || $RM $obj $libobj
10124126a8a12Smrg
10125d656433aSmrg      # Objects from convenience libraries.  This assumes
10126d656433aSmrg      # single-version convenience libraries.  Whenever we create
10127d656433aSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
10128d656433aSmrg      # the extraction.
10129d656433aSmrg      reload_conv_objs=
10130d656433aSmrg      gentop=
10131300346aeSmrg      # if reload_cmds runs $LD directly, get rid of -Wl from
10132300346aeSmrg      # whole_archive_flag_spec and hope we can get by with turning comma
10133300346aeSmrg      # into space.
10134300346aeSmrg      case $reload_cmds in
10135300346aeSmrg        *\$LD[\ \$]*) wl= ;;
10136300346aeSmrg      esac
10137d656433aSmrg      if test -n "$convenience"; then
10138d656433aSmrg	if test -n "$whole_archive_flag_spec"; then
10139d656433aSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
10140300346aeSmrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
10141300346aeSmrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
10142d656433aSmrg	else
10143300346aeSmrg	  gentop=$output_objdir/${obj}x
101443c15da26Smrg	  func_append generated " $gentop"
10145126a8a12Smrg
10146d656433aSmrg	  func_extract_archives $gentop $convenience
10147d656433aSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
10148d656433aSmrg	fi
10149126a8a12Smrg      fi
10150126a8a12Smrg
101513c15da26Smrg      # If we're not building shared, we need to use non_pic_objs
10152300346aeSmrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
101533c15da26Smrg
10154d656433aSmrg      # Create the old-style object.
10155300346aeSmrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10156126a8a12Smrg
10157300346aeSmrg      output=$obj
10158d656433aSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
10159126a8a12Smrg
10160d656433aSmrg      # Exit if we aren't doing a library object file.
10161d656433aSmrg      if test -z "$libobj"; then
10162d656433aSmrg	if test -n "$gentop"; then
10163d656433aSmrg	  func_show_eval '${RM}r "$gentop"'
10164d656433aSmrg	fi
10165d656433aSmrg
10166d656433aSmrg	exit $EXIT_SUCCESS
10167126a8a12Smrg      fi
10168d656433aSmrg
10169300346aeSmrg      test yes = "$build_libtool_libs" || {
10170d656433aSmrg	if test -n "$gentop"; then
10171d656433aSmrg	  func_show_eval '${RM}r "$gentop"'
10172d656433aSmrg	fi
10173d656433aSmrg
10174d656433aSmrg	# Create an invalid libtool object if no PIC, so that we don't
10175d656433aSmrg	# accidentally link it into a program.
10176d656433aSmrg	# $show "echo timestamp > $libobj"
10177d656433aSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
10178d656433aSmrg	exit $EXIT_SUCCESS
10179300346aeSmrg      }
10180d656433aSmrg
10181300346aeSmrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
10182d656433aSmrg	# Only do commands if we really have different PIC objects.
10183d656433aSmrg	reload_objs="$libobjs $reload_conv_objs"
10184300346aeSmrg	output=$libobj
10185d656433aSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
10186d656433aSmrg      fi
10187d656433aSmrg
10188d656433aSmrg      if test -n "$gentop"; then
10189d656433aSmrg	func_show_eval '${RM}r "$gentop"'
10190d656433aSmrg      fi
10191d656433aSmrg
10192d656433aSmrg      exit $EXIT_SUCCESS
10193126a8a12Smrg      ;;
10194126a8a12Smrg
10195d656433aSmrg    prog)
10196d656433aSmrg      case $host in
10197d656433aSmrg	*cygwin*) func_stripname '' '.exe' "$output"
10198d656433aSmrg	          output=$func_stripname_result.exe;;
10199d656433aSmrg      esac
10200d656433aSmrg      test -n "$vinfo" && \
10201300346aeSmrg	func_warning "'-version-info' is ignored for programs"
10202126a8a12Smrg
10203d656433aSmrg      test -n "$release" && \
10204300346aeSmrg	func_warning "'-release' is ignored for programs"
10205126a8a12Smrg
10206300346aeSmrg      $preload \
10207300346aeSmrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
10208300346aeSmrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
10209d656433aSmrg
10210d656433aSmrg      case $host in
10211d656433aSmrg      *-*-rhapsody* | *-*-darwin1.[012])
10212d656433aSmrg	# On Rhapsody replace the C library is the System framework
10213555991fdSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10214555991fdSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10215126a8a12Smrg	;;
10216d656433aSmrg      esac
10217126a8a12Smrg
10218d656433aSmrg      case $host in
10219d656433aSmrg      *-*-darwin*)
10220d656433aSmrg	# Don't allow lazy linking, it breaks C++ global constructors
10221d656433aSmrg	# But is supposedly fixed on 10.4 or later (yay!).
10222300346aeSmrg	if test CXX = "$tagname"; then
10223d656433aSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10224d656433aSmrg	    10.[0123])
10225300346aeSmrg	      func_append compile_command " $wl-bind_at_load"
10226300346aeSmrg	      func_append finalize_command " $wl-bind_at_load"
10227d656433aSmrg	    ;;
10228d656433aSmrg	  esac
10229126a8a12Smrg	fi
10230d656433aSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
10231555991fdSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10232555991fdSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10233d656433aSmrg	;;
10234d656433aSmrg      esac
10235126a8a12Smrg
10236126a8a12Smrg
10237d656433aSmrg      # move library search paths that coincide with paths to not yet
10238d656433aSmrg      # installed libraries to the beginning of the library search list
10239d656433aSmrg      new_libs=
10240d656433aSmrg      for path in $notinst_path; do
10241d656433aSmrg	case " $new_libs " in
10242d656433aSmrg	*" -L$path/$objdir "*) ;;
10243d656433aSmrg	*)
10244d656433aSmrg	  case " $compile_deplibs " in
10245d656433aSmrg	  *" -L$path/$objdir "*)
102463c15da26Smrg	    func_append new_libs " -L$path/$objdir" ;;
10247126a8a12Smrg	  esac
10248d656433aSmrg	  ;;
10249d656433aSmrg	esac
10250d656433aSmrg      done
10251d656433aSmrg      for deplib in $compile_deplibs; do
10252d656433aSmrg	case $deplib in
10253d656433aSmrg	-L*)
10254d656433aSmrg	  case " $new_libs " in
10255d656433aSmrg	  *" $deplib "*) ;;
102563c15da26Smrg	  *) func_append new_libs " $deplib" ;;
10257126a8a12Smrg	  esac
10258d656433aSmrg	  ;;
102593c15da26Smrg	*) func_append new_libs " $deplib" ;;
10260d656433aSmrg	esac
10261d656433aSmrg      done
10262300346aeSmrg      compile_deplibs=$new_libs
10263126a8a12Smrg
10264126a8a12Smrg
102653c15da26Smrg      func_append compile_command " $compile_deplibs"
102663c15da26Smrg      func_append finalize_command " $finalize_deplibs"
10267126a8a12Smrg
10268d656433aSmrg      if test -n "$rpath$xrpath"; then
10269d656433aSmrg	# If the user specified any rpath flags, then add them.
10270d656433aSmrg	for libdir in $rpath $xrpath; do
10271d656433aSmrg	  # This is the magic to use -rpath.
10272d656433aSmrg	  case "$finalize_rpath " in
10273d656433aSmrg	  *" $libdir "*) ;;
102743c15da26Smrg	  *) func_append finalize_rpath " $libdir" ;;
10275d656433aSmrg	  esac
10276d656433aSmrg	done
10277d656433aSmrg      fi
10278126a8a12Smrg
10279d656433aSmrg      # Now hardcode the library paths
10280d656433aSmrg      rpath=
10281d656433aSmrg      hardcode_libdirs=
10282d656433aSmrg      for libdir in $compile_rpath $finalize_rpath; do
10283d656433aSmrg	if test -n "$hardcode_libdir_flag_spec"; then
10284d656433aSmrg	  if test -n "$hardcode_libdir_separator"; then
10285d656433aSmrg	    if test -z "$hardcode_libdirs"; then
10286300346aeSmrg	      hardcode_libdirs=$libdir
10287d656433aSmrg	    else
10288d656433aSmrg	      # Just accumulate the unique libdirs.
10289d656433aSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10290d656433aSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10291d656433aSmrg		;;
10292d656433aSmrg	      *)
102933c15da26Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10294d656433aSmrg		;;
10295d656433aSmrg	      esac
10296d656433aSmrg	    fi
10297126a8a12Smrg	  else
10298d656433aSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
102993c15da26Smrg	    func_append rpath " $flag"
10300126a8a12Smrg	  fi
10301d656433aSmrg	elif test -n "$runpath_var"; then
10302d656433aSmrg	  case "$perm_rpath " in
10303d656433aSmrg	  *" $libdir "*) ;;
103043c15da26Smrg	  *) func_append perm_rpath " $libdir" ;;
10305d656433aSmrg	  esac
10306d656433aSmrg	fi
10307d656433aSmrg	case $host in
10308d656433aSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
10309300346aeSmrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
10310d656433aSmrg	  case :$dllsearchpath: in
10311d656433aSmrg	  *":$libdir:"*) ;;
10312d656433aSmrg	  ::) dllsearchpath=$libdir;;
103133c15da26Smrg	  *) func_append dllsearchpath ":$libdir";;
10314d656433aSmrg	  esac
10315d656433aSmrg	  case :$dllsearchpath: in
10316d656433aSmrg	  *":$testbindir:"*) ;;
10317d656433aSmrg	  ::) dllsearchpath=$testbindir;;
103183c15da26Smrg	  *) func_append dllsearchpath ":$testbindir";;
10319d656433aSmrg	  esac
10320d656433aSmrg	  ;;
10321d656433aSmrg	esac
10322d656433aSmrg      done
10323d656433aSmrg      # Substitute the hardcoded libdirs into the rpath.
10324d656433aSmrg      if test -n "$hardcode_libdir_separator" &&
10325d656433aSmrg	 test -n "$hardcode_libdirs"; then
10326300346aeSmrg	libdir=$hardcode_libdirs
10327d656433aSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
10328d656433aSmrg      fi
10329300346aeSmrg      compile_rpath=$rpath
10330126a8a12Smrg
10331d656433aSmrg      rpath=
10332d656433aSmrg      hardcode_libdirs=
10333d656433aSmrg      for libdir in $finalize_rpath; do
10334d656433aSmrg	if test -n "$hardcode_libdir_flag_spec"; then
10335d656433aSmrg	  if test -n "$hardcode_libdir_separator"; then
10336d656433aSmrg	    if test -z "$hardcode_libdirs"; then
10337300346aeSmrg	      hardcode_libdirs=$libdir
10338d656433aSmrg	    else
10339d656433aSmrg	      # Just accumulate the unique libdirs.
10340d656433aSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10341d656433aSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10342d656433aSmrg		;;
10343d656433aSmrg	      *)
103443c15da26Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10345d656433aSmrg		;;
10346d656433aSmrg	      esac
10347d656433aSmrg	    fi
10348126a8a12Smrg	  else
10349d656433aSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
103503c15da26Smrg	    func_append rpath " $flag"
10351126a8a12Smrg	  fi
10352d656433aSmrg	elif test -n "$runpath_var"; then
10353d656433aSmrg	  case "$finalize_perm_rpath " in
10354d656433aSmrg	  *" $libdir "*) ;;
103553c15da26Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
10356d656433aSmrg	  esac
10357126a8a12Smrg	fi
10358d656433aSmrg      done
10359d656433aSmrg      # Substitute the hardcoded libdirs into the rpath.
10360d656433aSmrg      if test -n "$hardcode_libdir_separator" &&
10361d656433aSmrg	 test -n "$hardcode_libdirs"; then
10362300346aeSmrg	libdir=$hardcode_libdirs
10363d656433aSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
10364d656433aSmrg      fi
10365300346aeSmrg      finalize_rpath=$rpath
10366126a8a12Smrg
10367300346aeSmrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
10368d656433aSmrg	# Transform all the library objects into standard objects.
10369555991fdSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10370555991fdSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10371d656433aSmrg      fi
10372126a8a12Smrg
10373300346aeSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
10374126a8a12Smrg
10375d656433aSmrg      # template prelinking step
10376d656433aSmrg      if test -n "$prelink_cmds"; then
10377d656433aSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
10378d656433aSmrg      fi
10379126a8a12Smrg
10380300346aeSmrg      wrappers_required=:
10381d656433aSmrg      case $host in
10382555991fdSmrg      *cegcc* | *mingw32ce*)
10383555991fdSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
10384300346aeSmrg        wrappers_required=false
10385555991fdSmrg        ;;
10386d656433aSmrg      *cygwin* | *mingw* )
10387300346aeSmrg        test yes = "$build_libtool_libs" || wrappers_required=false
10388d656433aSmrg        ;;
10389d656433aSmrg      *)
10390300346aeSmrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
10391300346aeSmrg          wrappers_required=false
10392d656433aSmrg        fi
10393d656433aSmrg        ;;
10394d656433aSmrg      esac
10395300346aeSmrg      $wrappers_required || {
10396d656433aSmrg	# Replace the output file specification.
10397555991fdSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10398300346aeSmrg	link_command=$compile_command$compile_rpath
10399126a8a12Smrg
10400d656433aSmrg	# We have no uninstalled library dependencies, so finalize right now.
10401d656433aSmrg	exit_status=0
10402d656433aSmrg	func_show_eval "$link_command" 'exit_status=$?'
10403126a8a12Smrg
104043c15da26Smrg	if test -n "$postlink_cmds"; then
104053c15da26Smrg	  func_to_tool_file "$output"
104063c15da26Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
104073c15da26Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
104083c15da26Smrg	fi
104093c15da26Smrg
10410d656433aSmrg	# Delete the generated files.
10411300346aeSmrg	if test -f "$output_objdir/${outputname}S.$objext"; then
10412300346aeSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
10413126a8a12Smrg	fi
10414126a8a12Smrg
10415d656433aSmrg	exit $exit_status
10416300346aeSmrg      }
10417126a8a12Smrg
10418d656433aSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
10419d656433aSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
10420d656433aSmrg      fi
10421d656433aSmrg      if test -n "$finalize_shlibpath"; then
10422d656433aSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
10423d656433aSmrg      fi
10424126a8a12Smrg
10425d656433aSmrg      compile_var=
10426d656433aSmrg      finalize_var=
10427d656433aSmrg      if test -n "$runpath_var"; then
10428d656433aSmrg	if test -n "$perm_rpath"; then
10429d656433aSmrg	  # We should set the runpath_var.
10430d656433aSmrg	  rpath=
10431d656433aSmrg	  for dir in $perm_rpath; do
104323c15da26Smrg	    func_append rpath "$dir:"
10433d656433aSmrg	  done
10434d656433aSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10435126a8a12Smrg	fi
10436d656433aSmrg	if test -n "$finalize_perm_rpath"; then
10437d656433aSmrg	  # We should set the runpath_var.
10438d656433aSmrg	  rpath=
10439d656433aSmrg	  for dir in $finalize_perm_rpath; do
104403c15da26Smrg	    func_append rpath "$dir:"
10441d656433aSmrg	  done
10442d656433aSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
10443126a8a12Smrg	fi
10444d656433aSmrg      fi
10445126a8a12Smrg
10446300346aeSmrg      if test yes = "$no_install"; then
10447d656433aSmrg	# We don't need to create a wrapper script.
10448300346aeSmrg	link_command=$compile_var$compile_command$compile_rpath
10449d656433aSmrg	# Replace the output file specification.
10450555991fdSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10451d656433aSmrg	# Delete the old output file.
10452d656433aSmrg	$opt_dry_run || $RM $output
10453d656433aSmrg	# Link the executable and exit
10454d656433aSmrg	func_show_eval "$link_command" 'exit $?'
104553c15da26Smrg
104563c15da26Smrg	if test -n "$postlink_cmds"; then
104573c15da26Smrg	  func_to_tool_file "$output"
104583c15da26Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
104593c15da26Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
104603c15da26Smrg	fi
104613c15da26Smrg
10462126a8a12Smrg	exit $EXIT_SUCCESS
10463d656433aSmrg      fi
10464126a8a12Smrg
10465300346aeSmrg      case $hardcode_action,$fast_install in
10466300346aeSmrg        relink,*)
10467300346aeSmrg	  # Fast installation is not supported
10468300346aeSmrg	  link_command=$compile_var$compile_command$compile_rpath
10469300346aeSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10470d656433aSmrg
10471300346aeSmrg	  func_warning "this platform does not like uninstalled shared libraries"
10472300346aeSmrg	  func_warning "'$output' will be relinked during installation"
10473300346aeSmrg	  ;;
10474300346aeSmrg        *,yes)
10475300346aeSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
10476300346aeSmrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
10477300346aeSmrg          ;;
10478300346aeSmrg	*,no)
10479300346aeSmrg	  link_command=$compile_var$compile_command$compile_rpath
10480300346aeSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10481300346aeSmrg          ;;
10482300346aeSmrg	*,needless)
10483300346aeSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
10484300346aeSmrg	  relink_command=
10485300346aeSmrg          ;;
10486300346aeSmrg      esac
10487126a8a12Smrg
10488d656433aSmrg      # Replace the output file specification.
10489555991fdSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10490126a8a12Smrg
10491d656433aSmrg      # Delete the old output files.
10492d656433aSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10493126a8a12Smrg
10494d656433aSmrg      func_show_eval "$link_command" 'exit $?'
10495126a8a12Smrg
104963c15da26Smrg      if test -n "$postlink_cmds"; then
104973c15da26Smrg	func_to_tool_file "$output_objdir/$outputname"
104983c15da26Smrg	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'`
104993c15da26Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
105003c15da26Smrg      fi
105013c15da26Smrg
10502d656433aSmrg      # Now create the wrapper script.
10503d656433aSmrg      func_verbose "creating $output"
10504126a8a12Smrg
10505d656433aSmrg      # Quote the relink command for shipping.
10506d656433aSmrg      if test -n "$relink_command"; then
10507d656433aSmrg	# Preserve any variables that may affect compiler behavior
10508d656433aSmrg	for var in $variables_saved_for_relink; do
10509d656433aSmrg	  if eval test -z \"\${$var+set}\"; then
10510d656433aSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10511d656433aSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
10512d656433aSmrg	    relink_command="$var=; export $var; $relink_command"
10513126a8a12Smrg	  else
10514d656433aSmrg	    func_quote_for_eval "$var_value"
10515d656433aSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10516126a8a12Smrg	  fi
10517d656433aSmrg	done
10518d656433aSmrg	relink_command="(cd `pwd`; $relink_command)"
10519555991fdSmrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10520d656433aSmrg      fi
10521d656433aSmrg
10522d656433aSmrg      # Only actually do things if not in dry run mode.
10523d656433aSmrg      $opt_dry_run || {
10524d656433aSmrg	# win32 will think the script is a binary if it has
10525d656433aSmrg	# a .exe suffix, so we strip it off here.
10526d656433aSmrg	case $output in
10527d656433aSmrg	  *.exe) func_stripname '' '.exe' "$output"
10528d656433aSmrg	         output=$func_stripname_result ;;
10529d656433aSmrg	esac
10530d656433aSmrg	# test for cygwin because mv fails w/o .exe extensions
10531d656433aSmrg	case $host in
10532d656433aSmrg	  *cygwin*)
10533d656433aSmrg	    exeext=.exe
10534d656433aSmrg	    func_stripname '' '.exe' "$outputname"
10535d656433aSmrg	    outputname=$func_stripname_result ;;
10536d656433aSmrg	  *) exeext= ;;
10537126a8a12Smrg	esac
10538d656433aSmrg	case $host in
10539d656433aSmrg	  *cygwin* | *mingw* )
10540d656433aSmrg	    func_dirname_and_basename "$output" "" "."
10541d656433aSmrg	    output_name=$func_basename_result
10542d656433aSmrg	    output_path=$func_dirname_result
10543300346aeSmrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
10544300346aeSmrg	    cwrapper=$output_path/$output_name.exe
10545d656433aSmrg	    $RM $cwrappersource $cwrapper
10546d656433aSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
10547d656433aSmrg
10548d656433aSmrg	    func_emit_cwrapperexe_src > $cwrappersource
10549d656433aSmrg
10550d656433aSmrg	    # The wrapper executable is built using the $host compiler,
10551d656433aSmrg	    # because it contains $host paths and files. If cross-
10552d656433aSmrg	    # compiling, it, like the target executable, must be
10553d656433aSmrg	    # executed on the $host or under an emulation environment.
10554d656433aSmrg	    $opt_dry_run || {
10555d656433aSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
10556d656433aSmrg	      $STRIP $cwrapper
10557d656433aSmrg	    }
10558126a8a12Smrg
10559d656433aSmrg	    # Now, create the wrapper script for func_source use:
10560d656433aSmrg	    func_ltwrapper_scriptname $cwrapper
10561d656433aSmrg	    $RM $func_ltwrapper_scriptname_result
10562d656433aSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
10563d656433aSmrg	    $opt_dry_run || {
10564d656433aSmrg	      # note: this script will not be executed, so do not chmod.
10565300346aeSmrg	      if test "x$build" = "x$host"; then
10566d656433aSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10567d656433aSmrg	      else
10568d656433aSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
10569d656433aSmrg	      fi
10570d656433aSmrg	    }
10571d656433aSmrg	  ;;
10572d656433aSmrg	  * )
10573d656433aSmrg	    $RM $output
10574d656433aSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10575126a8a12Smrg
10576d656433aSmrg	    func_emit_wrapper no > $output
10577d656433aSmrg	    chmod +x $output
10578d656433aSmrg	  ;;
10579d656433aSmrg	esac
10580d656433aSmrg      }
10581d656433aSmrg      exit $EXIT_SUCCESS
10582d656433aSmrg      ;;
10583d656433aSmrg    esac
10584126a8a12Smrg
10585d656433aSmrg    # See if we need to build an old-fashioned archive.
10586d656433aSmrg    for oldlib in $oldlibs; do
10587126a8a12Smrg
10588300346aeSmrg      case $build_libtool_libs in
10589300346aeSmrg        convenience)
10590300346aeSmrg	  oldobjs="$libobjs_save $symfileobj"
10591300346aeSmrg	  addlibs=$convenience
10592d656433aSmrg	  build_libtool_libs=no
10593300346aeSmrg	  ;;
10594300346aeSmrg	module)
10595300346aeSmrg	  oldobjs=$libobjs_save
10596300346aeSmrg	  addlibs=$old_convenience
10597300346aeSmrg	  build_libtool_libs=no
10598300346aeSmrg          ;;
10599300346aeSmrg	*)
10600d656433aSmrg	  oldobjs="$old_deplibs $non_pic_objects"
10601300346aeSmrg	  $preload && test -f "$symfileobj" \
10602300346aeSmrg	    && func_append oldobjs " $symfileobj"
10603300346aeSmrg	  addlibs=$old_convenience
10604300346aeSmrg	  ;;
10605300346aeSmrg      esac
10606126a8a12Smrg
10607d656433aSmrg      if test -n "$addlibs"; then
10608300346aeSmrg	gentop=$output_objdir/${outputname}x
106093c15da26Smrg	func_append generated " $gentop"
10610126a8a12Smrg
10611d656433aSmrg	func_extract_archives $gentop $addlibs
106123c15da26Smrg	func_append oldobjs " $func_extract_archives_result"
10613d656433aSmrg      fi
10614126a8a12Smrg
10615d656433aSmrg      # Do each command in the archive commands.
10616300346aeSmrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
10617d656433aSmrg	cmds=$old_archive_from_new_cmds
10618d656433aSmrg      else
10619126a8a12Smrg
10620d656433aSmrg	# Add any objects from preloaded convenience libraries
10621d656433aSmrg	if test -n "$dlprefiles"; then
10622300346aeSmrg	  gentop=$output_objdir/${outputname}x
106233c15da26Smrg	  func_append generated " $gentop"
10624126a8a12Smrg
10625d656433aSmrg	  func_extract_archives $gentop $dlprefiles
106263c15da26Smrg	  func_append oldobjs " $func_extract_archives_result"
10627d656433aSmrg	fi
10628126a8a12Smrg
10629d656433aSmrg	# POSIX demands no paths to be encoded in archives.  We have
10630d656433aSmrg	# to avoid creating archives with duplicate basenames if we
10631d656433aSmrg	# might have to extract them afterwards, e.g., when creating a
10632d656433aSmrg	# static archive out of a convenience library, or when linking
10633d656433aSmrg	# the entirety of a libtool archive into another (currently
10634d656433aSmrg	# not supported by libtool).
10635d656433aSmrg	if (for obj in $oldobjs
10636d656433aSmrg	    do
10637d656433aSmrg	      func_basename "$obj"
10638d656433aSmrg	      $ECHO "$func_basename_result"
10639d656433aSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
10640d656433aSmrg	  :
10641d656433aSmrg	else
10642555991fdSmrg	  echo "copying selected object files to avoid basename conflicts..."
10643300346aeSmrg	  gentop=$output_objdir/${outputname}x
106443c15da26Smrg	  func_append generated " $gentop"
10645d656433aSmrg	  func_mkdir_p "$gentop"
10646d656433aSmrg	  save_oldobjs=$oldobjs
10647d656433aSmrg	  oldobjs=
10648d656433aSmrg	  counter=1
10649d656433aSmrg	  for obj in $save_oldobjs
10650d656433aSmrg	  do
10651d656433aSmrg	    func_basename "$obj"
10652300346aeSmrg	    objbase=$func_basename_result
10653d656433aSmrg	    case " $oldobjs " in
10654d656433aSmrg	    " ") oldobjs=$obj ;;
10655d656433aSmrg	    *[\ /]"$objbase "*)
10656d656433aSmrg	      while :; do
10657d656433aSmrg		# Make sure we don't pick an alternate name that also
10658d656433aSmrg		# overlaps.
10659d656433aSmrg		newobj=lt$counter-$objbase
10660d656433aSmrg		func_arith $counter + 1
10661d656433aSmrg		counter=$func_arith_result
10662d656433aSmrg		case " $oldobjs " in
10663d656433aSmrg		*[\ /]"$newobj "*) ;;
10664d656433aSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
10665d656433aSmrg		esac
10666d656433aSmrg	      done
10667d656433aSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
106683c15da26Smrg	      func_append oldobjs " $gentop/$newobj"
10669d656433aSmrg	      ;;
106703c15da26Smrg	    *) func_append oldobjs " $obj" ;;
10671d656433aSmrg	    esac
10672126a8a12Smrg	  done
10673126a8a12Smrg	fi
106740a6b08f8Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
106750a6b08f8Smrg	tool_oldlib=$func_to_tool_file_result
10676d656433aSmrg	eval cmds=\"$old_archive_cmds\"
10677126a8a12Smrg
10678d656433aSmrg	func_len " $cmds"
10679d656433aSmrg	len=$func_len_result
10680d656433aSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10681d656433aSmrg	  cmds=$old_archive_cmds
106823c15da26Smrg	elif test -n "$archiver_list_spec"; then
106833c15da26Smrg	  func_verbose "using command file archive linking..."
106843c15da26Smrg	  for obj in $oldobjs
106853c15da26Smrg	  do
106863c15da26Smrg	    func_to_tool_file "$obj"
106873c15da26Smrg	    $ECHO "$func_to_tool_file_result"
106883c15da26Smrg	  done > $output_objdir/$libname.libcmd
106893c15da26Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
106903c15da26Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
106913c15da26Smrg	  cmds=$old_archive_cmds
10692d656433aSmrg	else
10693d656433aSmrg	  # the command line is too long to link in one step, link in parts
10694d656433aSmrg	  func_verbose "using piecewise archive linking..."
10695d656433aSmrg	  save_RANLIB=$RANLIB
10696d656433aSmrg	  RANLIB=:
10697d656433aSmrg	  objlist=
10698d656433aSmrg	  concat_cmds=
10699d656433aSmrg	  save_oldobjs=$oldobjs
10700d656433aSmrg	  oldobjs=
10701d656433aSmrg	  # Is there a better way of finding the last object in the list?
10702d656433aSmrg	  for obj in $save_oldobjs
10703d656433aSmrg	  do
10704d656433aSmrg	    last_oldobj=$obj
10705d656433aSmrg	  done
10706d656433aSmrg	  eval test_cmds=\"$old_archive_cmds\"
10707d656433aSmrg	  func_len " $test_cmds"
10708d656433aSmrg	  len0=$func_len_result
10709d656433aSmrg	  len=$len0
10710d656433aSmrg	  for obj in $save_oldobjs
10711d656433aSmrg	  do
10712d656433aSmrg	    func_len " $obj"
10713d656433aSmrg	    func_arith $len + $func_len_result
10714d656433aSmrg	    len=$func_arith_result
10715d656433aSmrg	    func_append objlist " $obj"
10716d656433aSmrg	    if test "$len" -lt "$max_cmd_len"; then
10717d656433aSmrg	      :
10718d656433aSmrg	    else
10719d656433aSmrg	      # the above command should be used before it gets too long
10720d656433aSmrg	      oldobjs=$objlist
10721300346aeSmrg	      if test "$obj" = "$last_oldobj"; then
10722d656433aSmrg		RANLIB=$save_RANLIB
10723d656433aSmrg	      fi
10724d656433aSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10725300346aeSmrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
10726d656433aSmrg	      objlist=
10727d656433aSmrg	      len=$len0
10728d656433aSmrg	    fi
10729d656433aSmrg	  done
10730d656433aSmrg	  RANLIB=$save_RANLIB
10731d656433aSmrg	  oldobjs=$objlist
10732300346aeSmrg	  if test -z "$oldobjs"; then
10733d656433aSmrg	    eval cmds=\"\$concat_cmds\"
10734d656433aSmrg	  else
10735d656433aSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
10736d656433aSmrg	  fi
10737d656433aSmrg	fi
10738d656433aSmrg      fi
10739d656433aSmrg      func_execute_cmds "$cmds" 'exit $?'
10740126a8a12Smrg    done
10741126a8a12Smrg
10742d656433aSmrg    test -n "$generated" && \
10743d656433aSmrg      func_show_eval "${RM}r$generated"
10744126a8a12Smrg
10745d656433aSmrg    # Now create the libtool archive.
10746d656433aSmrg    case $output in
10747d656433aSmrg    *.la)
10748d656433aSmrg      old_library=
10749300346aeSmrg      test yes = "$build_old_libs" && old_library=$libname.$libext
10750d656433aSmrg      func_verbose "creating $output"
10751126a8a12Smrg
10752d656433aSmrg      # Preserve any variables that may affect compiler behavior
10753d656433aSmrg      for var in $variables_saved_for_relink; do
10754d656433aSmrg	if eval test -z \"\${$var+set}\"; then
10755d656433aSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10756d656433aSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
10757d656433aSmrg	  relink_command="$var=; export $var; $relink_command"
10758126a8a12Smrg	else
10759d656433aSmrg	  func_quote_for_eval "$var_value"
10760d656433aSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10761126a8a12Smrg	fi
10762d656433aSmrg      done
10763d656433aSmrg      # Quote the link command for shipping.
10764300346aeSmrg      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
10765555991fdSmrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10766300346aeSmrg      if test yes = "$hardcode_automatic"; then
10767d656433aSmrg	relink_command=
10768d656433aSmrg      fi
10769126a8a12Smrg
10770d656433aSmrg      # Only create the output if not a dry run.
10771d656433aSmrg      $opt_dry_run || {
10772d656433aSmrg	for installed in no yes; do
10773300346aeSmrg	  if test yes = "$installed"; then
10774d656433aSmrg	    if test -z "$install_libdir"; then
10775d656433aSmrg	      break
10776d656433aSmrg	    fi
10777300346aeSmrg	    output=$output_objdir/${outputname}i
10778d656433aSmrg	    # Replace all uninstalled libtool libraries with the installed ones
10779d656433aSmrg	    newdependency_libs=
10780d656433aSmrg	    for deplib in $dependency_libs; do
10781d656433aSmrg	      case $deplib in
10782d656433aSmrg	      *.la)
10783d656433aSmrg		func_basename "$deplib"
10784300346aeSmrg		name=$func_basename_result
107850a6b08f8Smrg		func_resolve_sysroot "$deplib"
10786300346aeSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
10787d656433aSmrg		test -z "$libdir" && \
10788300346aeSmrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
107893c15da26Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
107903c15da26Smrg		;;
107913c15da26Smrg	      -L*)
107923c15da26Smrg		func_stripname -L '' "$deplib"
107933c15da26Smrg		func_replace_sysroot "$func_stripname_result"
107943c15da26Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
107953c15da26Smrg		;;
107963c15da26Smrg	      -R*)
107973c15da26Smrg		func_stripname -R '' "$deplib"
107983c15da26Smrg		func_replace_sysroot "$func_stripname_result"
107993c15da26Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
10800d656433aSmrg		;;
108013c15da26Smrg	      *) func_append newdependency_libs " $deplib" ;;
10802d656433aSmrg	      esac
10803d656433aSmrg	    done
10804300346aeSmrg	    dependency_libs=$newdependency_libs
10805d656433aSmrg	    newdlfiles=
10806d656433aSmrg
10807d656433aSmrg	    for lib in $dlfiles; do
10808d656433aSmrg	      case $lib in
10809d656433aSmrg	      *.la)
10810d656433aSmrg	        func_basename "$lib"
10811300346aeSmrg		name=$func_basename_result
10812300346aeSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10813d656433aSmrg		test -z "$libdir" && \
10814300346aeSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
108153c15da26Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
10816d656433aSmrg		;;
108173c15da26Smrg	      *) func_append newdlfiles " $lib" ;;
10818d656433aSmrg	      esac
10819d656433aSmrg	    done
10820300346aeSmrg	    dlfiles=$newdlfiles
10821d656433aSmrg	    newdlprefiles=
10822d656433aSmrg	    for lib in $dlprefiles; do
10823d656433aSmrg	      case $lib in
10824d656433aSmrg	      *.la)
10825d656433aSmrg		# Only pass preopened files to the pseudo-archive (for
10826d656433aSmrg		# eventual linking with the app. that links it) if we
10827d656433aSmrg		# didn't already link the preopened objects directly into
10828d656433aSmrg		# the library:
10829d656433aSmrg		func_basename "$lib"
10830300346aeSmrg		name=$func_basename_result
10831300346aeSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10832d656433aSmrg		test -z "$libdir" && \
10833300346aeSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
108343c15da26Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
10835d656433aSmrg		;;
10836d656433aSmrg	      esac
10837d656433aSmrg	    done
10838300346aeSmrg	    dlprefiles=$newdlprefiles
10839d656433aSmrg	  else
10840d656433aSmrg	    newdlfiles=
10841d656433aSmrg	    for lib in $dlfiles; do
10842d656433aSmrg	      case $lib in
10843300346aeSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10844d656433aSmrg		*) abs=`pwd`"/$lib" ;;
10845d656433aSmrg	      esac
108463c15da26Smrg	      func_append newdlfiles " $abs"
10847d656433aSmrg	    done
10848300346aeSmrg	    dlfiles=$newdlfiles
10849d656433aSmrg	    newdlprefiles=
10850d656433aSmrg	    for lib in $dlprefiles; do
10851d656433aSmrg	      case $lib in
10852300346aeSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10853d656433aSmrg		*) abs=`pwd`"/$lib" ;;
10854d656433aSmrg	      esac
108553c15da26Smrg	      func_append newdlprefiles " $abs"
10856d656433aSmrg	    done
10857300346aeSmrg	    dlprefiles=$newdlprefiles
10858d656433aSmrg	  fi
10859d656433aSmrg	  $RM $output
10860d656433aSmrg	  # place dlname in correct position for cygwin
10861555991fdSmrg	  # In fact, it would be nice if we could use this code for all target
10862555991fdSmrg	  # systems that can't hard-code library paths into their executables
10863555991fdSmrg	  # and that have no shared library path variable independent of PATH,
10864555991fdSmrg	  # but it turns out we can't easily determine that from inspecting
10865555991fdSmrg	  # libtool variables, so we have to hard-code the OSs to which it
10866555991fdSmrg	  # applies here; at the moment, that means platforms that use the PE
10867555991fdSmrg	  # object format with DLL files.  See the long comment at the top of
10868555991fdSmrg	  # tests/bindir.at for full details.
10869d656433aSmrg	  tdlname=$dlname
10870d656433aSmrg	  case $host,$output,$installed,$module,$dlname in
10871555991fdSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10872555991fdSmrg	      # If a -bindir argument was supplied, place the dll there.
10873300346aeSmrg	      if test -n "$bindir"; then
10874555991fdSmrg		func_relative_path "$install_libdir" "$bindir"
10875300346aeSmrg		tdlname=$func_relative_path_result/$dlname
10876555991fdSmrg	      else
10877555991fdSmrg		# Otherwise fall back on heuristic.
10878555991fdSmrg		tdlname=../bin/$dlname
10879555991fdSmrg	      fi
10880555991fdSmrg	      ;;
10881d656433aSmrg	  esac
10882d656433aSmrg	  $ECHO > $output "\
10883d656433aSmrg# $outputname - a libtool library file
10884300346aeSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
10885d656433aSmrg#
10886d656433aSmrg# Please DO NOT delete this file!
10887d656433aSmrg# It is necessary for linking the library.
10888126a8a12Smrg
10889d656433aSmrg# The name that we can dlopen(3).
10890d656433aSmrgdlname='$tdlname'
10891126a8a12Smrg
10892d656433aSmrg# Names of this library.
10893d656433aSmrglibrary_names='$library_names'
10894126a8a12Smrg
10895d656433aSmrg# The name of the static archive.
10896d656433aSmrgold_library='$old_library'
10897126a8a12Smrg
10898300346aeSmrg# Linker flags that cannot go in dependency_libs.
10899d656433aSmrginherited_linker_flags='$new_inherited_linker_flags'
10900126a8a12Smrg
10901d656433aSmrg# Libraries that this one depends upon.
10902d656433aSmrgdependency_libs='$dependency_libs'
10903126a8a12Smrg
10904d656433aSmrg# Names of additional weak libraries provided by this library
10905d656433aSmrgweak_library_names='$weak_libs'
10906126a8a12Smrg
10907d656433aSmrg# Version information for $libname.
10908d656433aSmrgcurrent=$current
10909d656433aSmrgage=$age
10910d656433aSmrgrevision=$revision
10911126a8a12Smrg
10912d656433aSmrg# Is this an already installed library?
10913d656433aSmrginstalled=$installed
10914126a8a12Smrg
10915d656433aSmrg# Should we warn about portability when linking against -modules?
10916d656433aSmrgshouldnotlink=$module
10917126a8a12Smrg
10918d656433aSmrg# Files to dlopen/dlpreopen
10919d656433aSmrgdlopen='$dlfiles'
10920d656433aSmrgdlpreopen='$dlprefiles'
10921126a8a12Smrg
10922d656433aSmrg# Directory that this library needs to be installed in:
10923d656433aSmrglibdir='$install_libdir'"
10924300346aeSmrg	  if test no,yes = "$installed,$need_relink"; then
10925d656433aSmrg	    $ECHO >> $output "\
10926d656433aSmrgrelink_command=\"$relink_command\""
10927d656433aSmrg	  fi
10928d656433aSmrg	done
10929d656433aSmrg      }
10930126a8a12Smrg
10931d656433aSmrg      # Do a symbolic link so that the libtool archive can be found in
10932d656433aSmrg      # LD_LIBRARY_PATH before the program is installed.
10933d656433aSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
10934d656433aSmrg      ;;
10935d656433aSmrg    esac
10936d656433aSmrg    exit $EXIT_SUCCESS
10937d656433aSmrg}
10938126a8a12Smrg
10939300346aeSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
10940300346aeSmrg  func_mode_link ${1+"$@"}
10941300346aeSmrgfi
10942126a8a12Smrg
10943126a8a12Smrg
10944d656433aSmrg# func_mode_uninstall arg...
10945d656433aSmrgfunc_mode_uninstall ()
10946d656433aSmrg{
10947300346aeSmrg    $debug_cmd
10948300346aeSmrg
10949300346aeSmrg    RM=$nonopt
10950126a8a12Smrg    files=
10951300346aeSmrg    rmforce=false
10952126a8a12Smrg    exit_status=0
10953126a8a12Smrg
10954126a8a12Smrg    # This variable tells wrapper scripts just to set variables rather
10955126a8a12Smrg    # than running their programs.
10956300346aeSmrg    libtool_install_magic=$magic
10957126a8a12Smrg
10958126a8a12Smrg    for arg
10959126a8a12Smrg    do
10960126a8a12Smrg      case $arg in
10961300346aeSmrg      -f) func_append RM " $arg"; rmforce=: ;;
109623c15da26Smrg      -*) func_append RM " $arg" ;;
109633c15da26Smrg      *) func_append files " $arg" ;;
10964126a8a12Smrg      esac
10965126a8a12Smrg    done
10966126a8a12Smrg
10967d656433aSmrg    test -z "$RM" && \
10968d656433aSmrg      func_fatal_help "you must specify an RM program"
10969126a8a12Smrg
10970126a8a12Smrg    rmdirs=
10971126a8a12Smrg
10972126a8a12Smrg    for file in $files; do
10973d656433aSmrg      func_dirname "$file" "" "."
10974300346aeSmrg      dir=$func_dirname_result
10975300346aeSmrg      if test . = "$dir"; then
10976300346aeSmrg	odir=$objdir
10977126a8a12Smrg      else
10978300346aeSmrg	odir=$dir/$objdir
10979126a8a12Smrg      fi
10980d656433aSmrg      func_basename "$file"
10981300346aeSmrg      name=$func_basename_result
10982300346aeSmrg      test uninstall = "$opt_mode" && odir=$dir
10983126a8a12Smrg
109843c15da26Smrg      # Remember odir for removal later, being careful to avoid duplicates
10985300346aeSmrg      if test clean = "$opt_mode"; then
10986126a8a12Smrg	case " $rmdirs " in
109873c15da26Smrg	  *" $odir "*) ;;
109883c15da26Smrg	  *) func_append rmdirs " $odir" ;;
10989126a8a12Smrg	esac
10990126a8a12Smrg      fi
10991126a8a12Smrg
10992126a8a12Smrg      # Don't error if the file doesn't exist and rm -f was used.
10993d656433aSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
10994d656433aSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
10995d656433aSmrg	 test -f "$file"; then
10996126a8a12Smrg	:
10997126a8a12Smrg      elif test -d "$file"; then
10998126a8a12Smrg	exit_status=1
10999126a8a12Smrg	continue
11000300346aeSmrg      elif $rmforce; then
11001126a8a12Smrg	continue
11002126a8a12Smrg      fi
11003126a8a12Smrg
11004300346aeSmrg      rmfiles=$file
11005126a8a12Smrg
11006126a8a12Smrg      case $name in
11007126a8a12Smrg      *.la)
11008126a8a12Smrg	# Possibly a libtool archive, so verify it.
11009d656433aSmrg	if func_lalib_p "$file"; then
11010d656433aSmrg	  func_source $dir/$name
11011126a8a12Smrg
11012126a8a12Smrg	  # Delete the libtool libraries and symlinks.
11013126a8a12Smrg	  for n in $library_names; do
110143c15da26Smrg	    func_append rmfiles " $odir/$n"
11015126a8a12Smrg	  done
110163c15da26Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
11017126a8a12Smrg
11018300346aeSmrg	  case $opt_mode in
11019126a8a12Smrg	  clean)
110203c15da26Smrg	    case " $library_names " in
11021126a8a12Smrg	    *" $dlname "*) ;;
110223c15da26Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
11023126a8a12Smrg	    esac
110243c15da26Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
11025126a8a12Smrg	    ;;
11026126a8a12Smrg	  uninstall)
11027126a8a12Smrg	    if test -n "$library_names"; then
11028126a8a12Smrg	      # Do each command in the postuninstall commands.
11029300346aeSmrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
11030126a8a12Smrg	    fi
11031126a8a12Smrg
11032126a8a12Smrg	    if test -n "$old_library"; then
11033126a8a12Smrg	      # Do each command in the old_postuninstall commands.
11034300346aeSmrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
11035126a8a12Smrg	    fi
11036126a8a12Smrg	    # FIXME: should reinstall the best remaining shared library.
11037126a8a12Smrg	    ;;
11038126a8a12Smrg	  esac
11039126a8a12Smrg	fi
11040126a8a12Smrg	;;
11041126a8a12Smrg
11042126a8a12Smrg      *.lo)
11043126a8a12Smrg	# Possibly a libtool object, so verify it.
11044d656433aSmrg	if func_lalib_p "$file"; then
11045126a8a12Smrg
11046126a8a12Smrg	  # Read the .lo file
11047d656433aSmrg	  func_source $dir/$name
11048126a8a12Smrg
11049126a8a12Smrg	  # Add PIC object to the list of files to remove.
11050300346aeSmrg	  if test -n "$pic_object" && test none != "$pic_object"; then
110513c15da26Smrg	    func_append rmfiles " $dir/$pic_object"
11052126a8a12Smrg	  fi
11053126a8a12Smrg
11054126a8a12Smrg	  # Add non-PIC object to the list of files to remove.
11055300346aeSmrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
110563c15da26Smrg	    func_append rmfiles " $dir/$non_pic_object"
11057126a8a12Smrg	  fi
11058126a8a12Smrg	fi
11059126a8a12Smrg	;;
11060126a8a12Smrg
11061126a8a12Smrg      *)
11062300346aeSmrg	if test clean = "$opt_mode"; then
11063126a8a12Smrg	  noexename=$name
11064126a8a12Smrg	  case $file in
11065126a8a12Smrg	  *.exe)
11066d656433aSmrg	    func_stripname '' '.exe' "$file"
11067d656433aSmrg	    file=$func_stripname_result
11068d656433aSmrg	    func_stripname '' '.exe' "$name"
11069d656433aSmrg	    noexename=$func_stripname_result
11070126a8a12Smrg	    # $file with .exe has already been added to rmfiles,
11071126a8a12Smrg	    # add $file without .exe
110723c15da26Smrg	    func_append rmfiles " $file"
11073126a8a12Smrg	    ;;
11074126a8a12Smrg	  esac
11075126a8a12Smrg	  # Do a test to see if this is a libtool program.
11076d656433aSmrg	  if func_ltwrapper_p "$file"; then
11077d656433aSmrg	    if func_ltwrapper_executable_p "$file"; then
11078d656433aSmrg	      func_ltwrapper_scriptname "$file"
11079d656433aSmrg	      relink_command=
11080d656433aSmrg	      func_source $func_ltwrapper_scriptname_result
110813c15da26Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
11082d656433aSmrg	    else
11083d656433aSmrg	      relink_command=
11084d656433aSmrg	      func_source $dir/$noexename
11085d656433aSmrg	    fi
11086126a8a12Smrg
11087126a8a12Smrg	    # note $name still contains .exe if it was in $file originally
11088126a8a12Smrg	    # as does the version of $file that was added into $rmfiles
11089300346aeSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
11090300346aeSmrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
110913c15da26Smrg	      func_append rmfiles " $odir/lt-$name"
11092126a8a12Smrg	    fi
11093300346aeSmrg	    if test "X$noexename" != "X$name"; then
11094300346aeSmrg	      func_append rmfiles " $odir/lt-$noexename.c"
11095126a8a12Smrg	    fi
11096126a8a12Smrg	  fi
11097126a8a12Smrg	fi
11098126a8a12Smrg	;;
11099126a8a12Smrg      esac
11100d656433aSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
11101126a8a12Smrg    done
11102126a8a12Smrg
11103300346aeSmrg    # Try to remove the $objdir's in the directories where we deleted files
11104126a8a12Smrg    for dir in $rmdirs; do
11105126a8a12Smrg      if test -d "$dir"; then
11106d656433aSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
11107126a8a12Smrg      fi
11108126a8a12Smrg    done
11109126a8a12Smrg
11110126a8a12Smrg    exit $exit_status
11111d656433aSmrg}
11112126a8a12Smrg
11113300346aeSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
11114300346aeSmrg  func_mode_uninstall ${1+"$@"}
11115300346aeSmrgfi
11116126a8a12Smrg
111173c15da26Smrgtest -z "$opt_mode" && {
11118300346aeSmrg  help=$generic_help
11119d656433aSmrg  func_fatal_help "you must specify a MODE"
11120d656433aSmrg}
11121d656433aSmrg
11122d656433aSmrgtest -z "$exec_cmd" && \
11123300346aeSmrg  func_fatal_help "invalid operation mode '$opt_mode'"
11124126a8a12Smrg
11125126a8a12Smrgif test -n "$exec_cmd"; then
11126d656433aSmrg  eval exec "$exec_cmd"
11127126a8a12Smrg  exit $EXIT_FAILURE
11128126a8a12Smrgfi
11129126a8a12Smrg
11130d656433aSmrgexit $exit_status
11131126a8a12Smrg
11132126a8a12Smrg
11133126a8a12Smrg# The TAGs below are defined such that we never get into a situation
11134300346aeSmrg# where we disable both kinds of libraries.  Given conflicting
11135126a8a12Smrg# choices, we go for a static library, that is the most portable,
11136126a8a12Smrg# since we can't tell whether shared libraries were disabled because
11137126a8a12Smrg# the user asked for that or because the platform doesn't support
11138126a8a12Smrg# them.  This is particularly important on AIX, because we don't
11139126a8a12Smrg# support having both static and shared libraries enabled at the same
11140126a8a12Smrg# time on that platform, so we default to a shared-only configuration.
11141126a8a12Smrg# If a disable-shared tag is given, we'll fallback to a static-only
11142126a8a12Smrg# configuration.  But we'll never go from static-only to shared-only.
11143126a8a12Smrg
11144126a8a12Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
11145d656433aSmrgbuild_libtool_libs=no
11146d656433aSmrgbuild_old_libs=yes
11147126a8a12Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
11148126a8a12Smrg
11149126a8a12Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
11150d656433aSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11151126a8a12Smrg# ### END LIBTOOL TAG CONFIG: disable-static
11152126a8a12Smrg
11153126a8a12Smrg# Local Variables:
11154126a8a12Smrg# mode:shell-script
11155126a8a12Smrg# sh-indentation:2
11156126a8a12Smrg# End:
11157