ltmain.sh revision 38ae11fc
1862bcd1aSmrg#! /bin/sh
2862bcd1aSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
3862bcd1aSmrg##               by inline-source v2014-01-03.01
488de56ccSmrg
5862bcd1aSmrg# libtool (GNU libtool) 2.4.6
6862bcd1aSmrg# Provide generalized library-building support services.
788de56ccSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
888de56ccSmrg
9862bcd1aSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc.
1088de56ccSmrg# This is free software; see the source for copying conditions.  There is NO
1188de56ccSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1288de56ccSmrg
1388de56ccSmrg# GNU Libtool is free software; you can redistribute it and/or modify
141ab64890Smrg# it under the terms of the GNU General Public License as published by
151ab64890Smrg# the Free Software Foundation; either version 2 of the License, or
161ab64890Smrg# (at your option) any later version.
171ab64890Smrg#
1888de56ccSmrg# As a special exception to the GNU General Public License,
1988de56ccSmrg# if you distribute this file as part of a program or library that
2088de56ccSmrg# is built using GNU Libtool, you may include this file under the
2188de56ccSmrg# same distribution terms that you use for the rest of that program.
2288de56ccSmrg#
2388de56ccSmrg# GNU Libtool is distributed in the hope that it will be useful, but
241ab64890Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
251ab64890Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
261ab64890Smrg# General Public License for more details.
271ab64890Smrg#
281ab64890Smrg# You should have received a copy of the GNU General Public License
29862bcd1aSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
30b4ee4795Smrg
311ab64890Smrg
32e9fcaa8aSmrgPROGRAM=libtool
331ab64890SmrgPACKAGE=libtool
3438ae11fcSmrgVERSION=2.4.6
35862bcd1aSmrgpackage_revision=2.4.6
361ab64890Smrg
37862bcd1aSmrg
38862bcd1aSmrg## ------ ##
39862bcd1aSmrg## Usage. ##
40862bcd1aSmrg## ------ ##
41862bcd1aSmrg
42862bcd1aSmrg# Run './libtool --help' for help with using this script from the
43862bcd1aSmrg# command line.
44862bcd1aSmrg
45862bcd1aSmrg
46862bcd1aSmrg## ------------------------------- ##
47862bcd1aSmrg## User overridable command paths. ##
48862bcd1aSmrg## ------------------------------- ##
49862bcd1aSmrg
50862bcd1aSmrg# After configure completes, it has a better idea of some of the
51862bcd1aSmrg# shell tools we need than the defaults used by the functions shared
52862bcd1aSmrg# with bootstrap, so set those here where they can still be over-
53862bcd1aSmrg# ridden by the user, but otherwise take precedence.
54862bcd1aSmrg
55862bcd1aSmrg: ${AUTOCONF="autoconf"}
56862bcd1aSmrg: ${AUTOMAKE="automake"}
57862bcd1aSmrg
58862bcd1aSmrg
59862bcd1aSmrg## -------------------------- ##
60862bcd1aSmrg## Source external libraries. ##
61862bcd1aSmrg## -------------------------- ##
62862bcd1aSmrg
63862bcd1aSmrg# Much of our low-level functionality needs to be sourced from external
64862bcd1aSmrg# libraries, which are installed to $pkgauxdir.
65862bcd1aSmrg
66862bcd1aSmrg# Set a version string for this script.
6738ae11fcSmrgscriptversion=2015-10-04.22; # UTC
68862bcd1aSmrg
69862bcd1aSmrg# General shell script boiler plate, and helper functions.
70862bcd1aSmrg# Written by Gary V. Vaughan, 2004
71862bcd1aSmrg
72862bcd1aSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc.
73862bcd1aSmrg# This is free software; see the source for copying conditions.  There is NO
74862bcd1aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
75862bcd1aSmrg
76862bcd1aSmrg# This program is free software; you can redistribute it and/or modify
77862bcd1aSmrg# it under the terms of the GNU General Public License as published by
78862bcd1aSmrg# the Free Software Foundation; either version 3 of the License, or
79862bcd1aSmrg# (at your option) any later version.
80862bcd1aSmrg
81862bcd1aSmrg# As a special exception to the GNU General Public License, if you distribute
82862bcd1aSmrg# this file as part of a program or library that is built using GNU Libtool,
83862bcd1aSmrg# you may include this file under the same distribution terms that you use
84862bcd1aSmrg# for the rest of that program.
85862bcd1aSmrg
86862bcd1aSmrg# This program is distributed in the hope that it will be useful,
87862bcd1aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
88862bcd1aSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
89862bcd1aSmrg# General Public License for more details.
90862bcd1aSmrg
91862bcd1aSmrg# You should have received a copy of the GNU General Public License
92862bcd1aSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>.
93862bcd1aSmrg
94862bcd1aSmrg# Please report bugs or propose patches to gary@gnu.org.
95862bcd1aSmrg
96862bcd1aSmrg
97862bcd1aSmrg## ------ ##
98862bcd1aSmrg## Usage. ##
99862bcd1aSmrg## ------ ##
100862bcd1aSmrg
101862bcd1aSmrg# Evaluate this file near the top of your script to gain access to
102862bcd1aSmrg# the functions and variables defined here:
103862bcd1aSmrg#
104862bcd1aSmrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
105862bcd1aSmrg#
106862bcd1aSmrg# If you need to override any of the default environment variable
107862bcd1aSmrg# settings, do that before evaluating this file.
108862bcd1aSmrg
109862bcd1aSmrg
110862bcd1aSmrg## -------------------- ##
111862bcd1aSmrg## Shell normalisation. ##
112862bcd1aSmrg## -------------------- ##
113862bcd1aSmrg
114862bcd1aSmrg# Some shells need a little help to be as Bourne compatible as possible.
115862bcd1aSmrg# Before doing anything else, make sure all that help has been provided!
116862bcd1aSmrg
117862bcd1aSmrgDUALCASE=1; export DUALCASE # for MKS sh
118862bcd1aSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
1191ab64890Smrg  emulate sh
1201ab64890Smrg  NULLCMD=:
121862bcd1aSmrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
1221ab64890Smrg  # is contrary to our usage.  Disable this feature.
1231ab64890Smrg  alias -g '${1+"$@"}'='"$@"'
1241ab64890Smrg  setopt NO_GLOB_SUBST
1251ab64890Smrgelse
126862bcd1aSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
1271ab64890Smrgfi
128e9fcaa8aSmrg
129862bcd1aSmrg# NLS nuisances: We save the old values in case they are required later.
130862bcd1aSmrg_G_user_locale=
131862bcd1aSmrg_G_safe_locale=
132862bcd1aSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1331ab64890Smrgdo
134862bcd1aSmrg  eval "if test set = \"\${$_G_var+set}\"; then
135862bcd1aSmrg          save_$_G_var=\$$_G_var
136862bcd1aSmrg          $_G_var=C
137862bcd1aSmrg	  export $_G_var
138862bcd1aSmrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
139862bcd1aSmrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
1401ab64890Smrg	fi"
1411ab64890Smrgdone
1421ab64890Smrg
143862bcd1aSmrg# CDPATH.
144862bcd1aSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
14588de56ccSmrg
146862bcd1aSmrg# Make sure IFS has a sensible default
147862bcd1aSmrgsp=' '
148862bcd1aSmrgnl='
149862bcd1aSmrg'
150862bcd1aSmrgIFS="$sp	$nl"
151862bcd1aSmrg
152862bcd1aSmrg# There are apparently some retarded systems that use ';' as a PATH separator!
153862bcd1aSmrgif test "${PATH_SEPARATOR+set}" != set; then
154862bcd1aSmrg  PATH_SEPARATOR=:
155862bcd1aSmrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
156862bcd1aSmrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
157862bcd1aSmrg      PATH_SEPARATOR=';'
158862bcd1aSmrg  }
159862bcd1aSmrgfi
16088de56ccSmrg
16188de56ccSmrg
16288de56ccSmrg
163862bcd1aSmrg## ------------------------- ##
164862bcd1aSmrg## Locate command utilities. ##
165862bcd1aSmrg## ------------------------- ##
166862bcd1aSmrg
167862bcd1aSmrg
168862bcd1aSmrg# func_executable_p FILE
169862bcd1aSmrg# ----------------------
170862bcd1aSmrg# Check that FILE is an executable regular file.
171862bcd1aSmrgfunc_executable_p ()
172862bcd1aSmrg{
173862bcd1aSmrg    test -f "$1" && test -x "$1"
174862bcd1aSmrg}
175862bcd1aSmrg
176862bcd1aSmrg
177862bcd1aSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
178862bcd1aSmrg# --------------------------------------------
179862bcd1aSmrg# Search for either a program that responds to --version with output
180862bcd1aSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
181862bcd1aSmrg# trying all the directories in PATH with each of the elements of
182862bcd1aSmrg# PROGS_LIST.
183862bcd1aSmrg#
184862bcd1aSmrg# CHECK_FUNC should accept the path to a candidate program, and
185862bcd1aSmrg# set $func_check_prog_result if it truncates its output less than
186862bcd1aSmrg# $_G_path_prog_max characters.
187862bcd1aSmrgfunc_path_progs ()
188862bcd1aSmrg{
189862bcd1aSmrg    _G_progs_list=$1
190862bcd1aSmrg    _G_check_func=$2
191862bcd1aSmrg    _G_PATH=${3-"$PATH"}
192862bcd1aSmrg
193862bcd1aSmrg    _G_path_prog_max=0
194862bcd1aSmrg    _G_path_prog_found=false
195862bcd1aSmrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
196862bcd1aSmrg    for _G_dir in $_G_PATH; do
197862bcd1aSmrg      IFS=$_G_save_IFS
198862bcd1aSmrg      test -z "$_G_dir" && _G_dir=.
199862bcd1aSmrg      for _G_prog_name in $_G_progs_list; do
200862bcd1aSmrg        for _exeext in '' .EXE; do
201862bcd1aSmrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
202862bcd1aSmrg          func_executable_p "$_G_path_prog" || continue
203862bcd1aSmrg          case `"$_G_path_prog" --version 2>&1` in
204862bcd1aSmrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
205862bcd1aSmrg            *)     $_G_check_func $_G_path_prog
206862bcd1aSmrg		   func_path_progs_result=$func_check_prog_result
207862bcd1aSmrg		   ;;
208862bcd1aSmrg          esac
209862bcd1aSmrg          $_G_path_prog_found && break 3
210862bcd1aSmrg        done
211862bcd1aSmrg      done
212862bcd1aSmrg    done
213862bcd1aSmrg    IFS=$_G_save_IFS
214862bcd1aSmrg    test -z "$func_path_progs_result" && {
215862bcd1aSmrg      echo "no acceptable sed could be found in \$PATH" >&2
216862bcd1aSmrg      exit 1
217862bcd1aSmrg    }
218862bcd1aSmrg}
219862bcd1aSmrg
220862bcd1aSmrg
221862bcd1aSmrg# We want to be able to use the functions in this file before configure
222862bcd1aSmrg# has figured out where the best binaries are kept, which means we have
223862bcd1aSmrg# to search for them ourselves - except when the results are already set
224862bcd1aSmrg# where we skip the searches.
225862bcd1aSmrg
226862bcd1aSmrg# Unless the user overrides by setting SED, search the path for either GNU
227862bcd1aSmrg# sed, or the sed that truncates its output the least.
228862bcd1aSmrgtest -z "$SED" && {
229862bcd1aSmrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
230862bcd1aSmrg  for _G_i in 1 2 3 4 5 6 7; do
231862bcd1aSmrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
232862bcd1aSmrg  done
233862bcd1aSmrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
234862bcd1aSmrg  _G_sed_script=
235862bcd1aSmrg
236862bcd1aSmrg  func_check_prog_sed ()
237862bcd1aSmrg  {
238862bcd1aSmrg    _G_path_prog=$1
239862bcd1aSmrg
240862bcd1aSmrg    _G_count=0
241862bcd1aSmrg    printf 0123456789 >conftest.in
242862bcd1aSmrg    while :
243862bcd1aSmrg    do
244862bcd1aSmrg      cat conftest.in conftest.in >conftest.tmp
245862bcd1aSmrg      mv conftest.tmp conftest.in
246862bcd1aSmrg      cp conftest.in conftest.nl
247862bcd1aSmrg      echo '' >> conftest.nl
248862bcd1aSmrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
249862bcd1aSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
250862bcd1aSmrg      _G_count=`expr $_G_count + 1`
251862bcd1aSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
252862bcd1aSmrg        # Best one so far, save it but keep looking for a better one
253862bcd1aSmrg        func_check_prog_result=$_G_path_prog
254862bcd1aSmrg        _G_path_prog_max=$_G_count
255862bcd1aSmrg      fi
256862bcd1aSmrg      # 10*(2^10) chars as input seems more than enough
257862bcd1aSmrg      test 10 -lt "$_G_count" && break
258862bcd1aSmrg    done
259862bcd1aSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
260862bcd1aSmrg  }
261862bcd1aSmrg
262862bcd1aSmrg  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
263862bcd1aSmrg  rm -f conftest.sed
264862bcd1aSmrg  SED=$func_path_progs_result
265862bcd1aSmrg}
266862bcd1aSmrg
267862bcd1aSmrg
268862bcd1aSmrg# Unless the user overrides by setting GREP, search the path for either GNU
269862bcd1aSmrg# grep, or the grep that truncates its output the least.
270862bcd1aSmrgtest -z "$GREP" && {
271862bcd1aSmrg  func_check_prog_grep ()
272862bcd1aSmrg  {
273862bcd1aSmrg    _G_path_prog=$1
274862bcd1aSmrg
275862bcd1aSmrg    _G_count=0
276862bcd1aSmrg    _G_path_prog_max=0
277862bcd1aSmrg    printf 0123456789 >conftest.in
278862bcd1aSmrg    while :
279862bcd1aSmrg    do
280862bcd1aSmrg      cat conftest.in conftest.in >conftest.tmp
281862bcd1aSmrg      mv conftest.tmp conftest.in
282862bcd1aSmrg      cp conftest.in conftest.nl
283862bcd1aSmrg      echo 'GREP' >> conftest.nl
284862bcd1aSmrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
285862bcd1aSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
286862bcd1aSmrg      _G_count=`expr $_G_count + 1`
287862bcd1aSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
288862bcd1aSmrg        # Best one so far, save it but keep looking for a better one
289862bcd1aSmrg        func_check_prog_result=$_G_path_prog
290862bcd1aSmrg        _G_path_prog_max=$_G_count
291862bcd1aSmrg      fi
292862bcd1aSmrg      # 10*(2^10) chars as input seems more than enough
293862bcd1aSmrg      test 10 -lt "$_G_count" && break
294862bcd1aSmrg    done
295862bcd1aSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
296862bcd1aSmrg  }
297862bcd1aSmrg
298862bcd1aSmrg  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
299862bcd1aSmrg  GREP=$func_path_progs_result
300862bcd1aSmrg}
301862bcd1aSmrg
302862bcd1aSmrg
303862bcd1aSmrg## ------------------------------- ##
304862bcd1aSmrg## User overridable command paths. ##
305862bcd1aSmrg## ------------------------------- ##
306862bcd1aSmrg
307862bcd1aSmrg# All uppercase variable names are used for environment variables.  These
308862bcd1aSmrg# variables can be overridden by the user before calling a script that
309862bcd1aSmrg# uses them if a suitable command of that name is not already available
310862bcd1aSmrg# in the command search PATH.
31188de56ccSmrg
31288de56ccSmrg: ${CP="cp -f"}
313862bcd1aSmrg: ${ECHO="printf %s\n"}
314862bcd1aSmrg: ${EGREP="$GREP -E"}
315862bcd1aSmrg: ${FGREP="$GREP -F"}
316862bcd1aSmrg: ${LN_S="ln -s"}
31788de56ccSmrg: ${MAKE="make"}
31888de56ccSmrg: ${MKDIR="mkdir"}
31988de56ccSmrg: ${MV="mv -f"}
32088de56ccSmrg: ${RM="rm -f"}
32188de56ccSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
3221ab64890Smrg
32388de56ccSmrg
324862bcd1aSmrg## -------------------- ##
325862bcd1aSmrg## Useful sed snippets. ##
326862bcd1aSmrg## -------------------- ##
327e9fcaa8aSmrg
328862bcd1aSmrgsed_dirname='s|/[^/]*$||'
329862bcd1aSmrgsed_basename='s|^.*/||'
330e9fcaa8aSmrg
331862bcd1aSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
332862bcd1aSmrg# metacharacters that are still active within double-quoted strings.
333862bcd1aSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
334e9fcaa8aSmrg
335862bcd1aSmrg# Same as above, but do not quote variable references.
336862bcd1aSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
337e9fcaa8aSmrg
338862bcd1aSmrg# Sed substitution that turns a string into a regex matching for the
339862bcd1aSmrg# string literally.
340862bcd1aSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
341e9fcaa8aSmrg
342862bcd1aSmrg# Sed substitution that converts a w32 file name or path
343862bcd1aSmrg# that contains forward slashes, into one that contains
344862bcd1aSmrg# (escaped) backslashes.  A very naive implementation.
345862bcd1aSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
346862bcd1aSmrg
347862bcd1aSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
348862bcd1aSmrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
349862bcd1aSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from
350862bcd1aSmrg# expansion.  Since each input '\' is now two '\'s, look for any number
351862bcd1aSmrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
352862bcd1aSmrg_G_bs='\\'
353862bcd1aSmrg_G_bs2='\\\\'
354862bcd1aSmrg_G_bs4='\\\\\\\\'
355862bcd1aSmrg_G_dollar='\$'
356862bcd1aSmrgsed_double_backslash="\
357862bcd1aSmrg  s/$_G_bs4/&\\
358862bcd1aSmrg/g
359862bcd1aSmrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
360862bcd1aSmrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
361862bcd1aSmrg  s/\n//g"
362e9fcaa8aSmrg
363e9fcaa8aSmrg
364862bcd1aSmrg## ----------------- ##
365862bcd1aSmrg## Global variables. ##
366862bcd1aSmrg## ----------------- ##
367e9fcaa8aSmrg
368862bcd1aSmrg# Except for the global variables explicitly listed below, the following
369862bcd1aSmrg# functions in the '^func_' namespace, and the '^require_' namespace
370862bcd1aSmrg# variables initialised in the 'Resource management' section, sourcing
371862bcd1aSmrg# this file will not pollute your global namespace with anything
372862bcd1aSmrg# else. There's no portable way to scope variables in Bourne shell
373862bcd1aSmrg# though, so actually running these functions will sometimes place
374862bcd1aSmrg# results into a variable named after the function, and often use
375862bcd1aSmrg# temporary variables in the '^_G_' namespace. If you are careful to
376862bcd1aSmrg# avoid using those namespaces casually in your sourcing script, things
377862bcd1aSmrg# should continue to work as you expect. And, of course, you can freely
378862bcd1aSmrg# overwrite any of the functions or variables defined here before
379862bcd1aSmrg# calling anything to customize them.
380e9fcaa8aSmrg
381862bcd1aSmrgEXIT_SUCCESS=0
382862bcd1aSmrgEXIT_FAILURE=1
383862bcd1aSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
384862bcd1aSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
3852e9c7c8cSmrg
386862bcd1aSmrg# Allow overriding, eg assuming that you follow the convention of
387862bcd1aSmrg# putting '$debug_cmd' at the start of all your functions, you can get
388862bcd1aSmrg# bash to show function call trace with:
389862bcd1aSmrg#
390862bcd1aSmrg#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
391862bcd1aSmrgdebug_cmd=${debug_cmd-":"}
392862bcd1aSmrgexit_cmd=:
39388de56ccSmrg
394862bcd1aSmrg# By convention, finish your script with:
395862bcd1aSmrg#
396862bcd1aSmrg#    exit $exit_status
397862bcd1aSmrg#
398862bcd1aSmrg# so that you can set exit_status to non-zero if you want to indicate
399862bcd1aSmrg# something went wrong during execution without actually bailing out at
400862bcd1aSmrg# the point of failure.
401862bcd1aSmrgexit_status=$EXIT_SUCCESS
402e9fcaa8aSmrg
403862bcd1aSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
404862bcd1aSmrg# is ksh but when the shell is invoked as "sh" and the current value of
405862bcd1aSmrg# the _XPG environment variable is not equal to 1 (one), the special
406862bcd1aSmrg# positional parameter $0, within a function call, is the name of the
407862bcd1aSmrg# function.
408862bcd1aSmrgprogpath=$0
40988de56ccSmrg
410862bcd1aSmrg# The name of this program.
411862bcd1aSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
41288de56ccSmrg
413862bcd1aSmrg# Make sure we have an absolute progpath for reexecution:
41488de56ccSmrgcase $progpath in
41588de56ccSmrg  [\\/]*|[A-Za-z]:\\*) ;;
41688de56ccSmrg  *[\\/]*)
417862bcd1aSmrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
41888de56ccSmrg     progdir=`cd "$progdir" && pwd`
419862bcd1aSmrg     progpath=$progdir/$progname
42088de56ccSmrg     ;;
42188de56ccSmrg  *)
422862bcd1aSmrg     _G_IFS=$IFS
423eb411b4bSmrg     IFS=${PATH_SEPARATOR-:}
42488de56ccSmrg     for progdir in $PATH; do
425862bcd1aSmrg       IFS=$_G_IFS
42688de56ccSmrg       test -x "$progdir/$progname" && break
42788de56ccSmrg     done
428862bcd1aSmrg     IFS=$_G_IFS
42988de56ccSmrg     test -n "$progdir" || progdir=`pwd`
430862bcd1aSmrg     progpath=$progdir/$progname
43188de56ccSmrg     ;;
43288de56ccSmrgesac
43388de56ccSmrg
43488de56ccSmrg
435862bcd1aSmrg## ----------------- ##
436862bcd1aSmrg## Standard options. ##
437862bcd1aSmrg## ----------------- ##
438e9fcaa8aSmrg
439862bcd1aSmrg# The following options affect the operation of the functions defined
440862bcd1aSmrg# below, and should be set appropriately depending on run-time para-
441862bcd1aSmrg# meters passed on the command line.
44288de56ccSmrg
44388de56ccSmrgopt_dry_run=false
44488de56ccSmrgopt_quiet=false
44588de56ccSmrgopt_verbose=false
44688de56ccSmrg
447862bcd1aSmrg# Categories 'all' and 'none' are always available.  Append any others
448862bcd1aSmrg# you will pass as the first argument to func_warning from your own
449862bcd1aSmrg# code.
450862bcd1aSmrgwarning_categories=
45188de56ccSmrg
452862bcd1aSmrg# By default, display warnings according to 'opt_warning_types'.  Set
453862bcd1aSmrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
454862bcd1aSmrg# treat the next displayed warning as a fatal error.
455862bcd1aSmrgwarning_func=func_warn_and_continue
45688de56ccSmrg
457862bcd1aSmrg# Set to 'all' to display all warnings, 'none' to suppress all
458862bcd1aSmrg# warnings, or a space delimited list of some subset of
459862bcd1aSmrg# 'warning_categories' to display only the listed warnings.
460862bcd1aSmrgopt_warning_types=all
46188de56ccSmrg
462e9fcaa8aSmrg
463862bcd1aSmrg## -------------------- ##
464862bcd1aSmrg## Resource management. ##
465862bcd1aSmrg## -------------------- ##
46688de56ccSmrg
467862bcd1aSmrg# This section contains definitions for functions that each ensure a
468862bcd1aSmrg# particular resource (a file, or a non-empty configuration variable for
469862bcd1aSmrg# example) is available, and if appropriate to extract default values
470862bcd1aSmrg# from pertinent package files. Call them using their associated
471862bcd1aSmrg# 'require_*' variable to ensure that they are executed, at most, once.
472862bcd1aSmrg#
473862bcd1aSmrg# It's entirely deliberate that calling these functions can set
474862bcd1aSmrg# variables that don't obey the namespace limitations obeyed by the rest
475862bcd1aSmrg# of this file, in order that that they be as useful as possible to
476862bcd1aSmrg# callers.
47788de56ccSmrg
47888de56ccSmrg
479862bcd1aSmrg# require_term_colors
480862bcd1aSmrg# -------------------
481862bcd1aSmrg# Allow display of bold text on terminals that support it.
482862bcd1aSmrgrequire_term_colors=func_require_term_colors
483862bcd1aSmrgfunc_require_term_colors ()
48488de56ccSmrg{
485862bcd1aSmrg    $debug_cmd
486862bcd1aSmrg
487862bcd1aSmrg    test -t 1 && {
488862bcd1aSmrg      # COLORTERM and USE_ANSI_COLORS environment variables take
489862bcd1aSmrg      # precedence, because most terminfo databases neglect to describe
490862bcd1aSmrg      # whether color sequences are supported.
491862bcd1aSmrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
492862bcd1aSmrg
493862bcd1aSmrg      if test 1 = "$USE_ANSI_COLORS"; then
494862bcd1aSmrg        # Standard ANSI escape sequences
495862bcd1aSmrg        tc_reset='[0m'
496862bcd1aSmrg        tc_bold='[1m';   tc_standout='[7m'
497862bcd1aSmrg        tc_red='[31m';   tc_green='[32m'
498862bcd1aSmrg        tc_blue='[34m';  tc_cyan='[36m'
499862bcd1aSmrg      else
500862bcd1aSmrg        # Otherwise trust the terminfo database after all.
501862bcd1aSmrg        test -n "`tput sgr0 2>/dev/null`" && {
502862bcd1aSmrg          tc_reset=`tput sgr0`
503862bcd1aSmrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
504862bcd1aSmrg          tc_standout=$tc_bold
505862bcd1aSmrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
506862bcd1aSmrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
507862bcd1aSmrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
508862bcd1aSmrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
509862bcd1aSmrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
510862bcd1aSmrg        }
511862bcd1aSmrg      fi
512862bcd1aSmrg    }
51388de56ccSmrg
514862bcd1aSmrg    require_term_colors=:
51588de56ccSmrg}
51688de56ccSmrg
51788de56ccSmrg
518862bcd1aSmrg## ----------------- ##
519862bcd1aSmrg## Function library. ##
520862bcd1aSmrg## ----------------- ##
521862bcd1aSmrg
522862bcd1aSmrg# This section contains a variety of useful functions to call in your
523862bcd1aSmrg# scripts. Take note of the portable wrappers for features provided by
524862bcd1aSmrg# some modern shells, which will fall back to slower equivalents on
525862bcd1aSmrg# less featureful shells.
526862bcd1aSmrg
527862bcd1aSmrg
528862bcd1aSmrg# func_append VAR VALUE
529862bcd1aSmrg# ---------------------
530862bcd1aSmrg# Append VALUE onto the existing contents of VAR.
531862bcd1aSmrg
532862bcd1aSmrg  # We should try to minimise forks, especially on Windows where they are
533862bcd1aSmrg  # unreasonably slow, so skip the feature probes when bash or zsh are
534862bcd1aSmrg  # being used:
535862bcd1aSmrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
536862bcd1aSmrg    : ${_G_HAVE_ARITH_OP="yes"}
537862bcd1aSmrg    : ${_G_HAVE_XSI_OPS="yes"}
538862bcd1aSmrg    # The += operator was introduced in bash 3.1
539862bcd1aSmrg    case $BASH_VERSION in
540862bcd1aSmrg      [12].* | 3.0 | 3.0*) ;;
541862bcd1aSmrg      *)
542862bcd1aSmrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
543862bcd1aSmrg        ;;
544862bcd1aSmrg    esac
545862bcd1aSmrg  fi
546862bcd1aSmrg
547862bcd1aSmrg  # _G_HAVE_PLUSEQ_OP
548862bcd1aSmrg  # Can be empty, in which case the shell is probed, "yes" if += is
549862bcd1aSmrg  # useable or anything else if it does not work.
550862bcd1aSmrg  test -z "$_G_HAVE_PLUSEQ_OP" \
551862bcd1aSmrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
552862bcd1aSmrg    && _G_HAVE_PLUSEQ_OP=yes
553862bcd1aSmrg
554862bcd1aSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"
555862bcd1aSmrgthen
556862bcd1aSmrg  # This is an XSI compatible shell, allowing a faster implementation...
557862bcd1aSmrg  eval 'func_append ()
558862bcd1aSmrg  {
559862bcd1aSmrg    $debug_cmd
560862bcd1aSmrg
561862bcd1aSmrg    eval "$1+=\$2"
562862bcd1aSmrg  }'
563862bcd1aSmrgelse
564862bcd1aSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
565862bcd1aSmrg  func_append ()
566862bcd1aSmrg  {
567862bcd1aSmrg    $debug_cmd
568862bcd1aSmrg
569862bcd1aSmrg    eval "$1=\$$1\$2"
570862bcd1aSmrg  }
571862bcd1aSmrgfi
572862bcd1aSmrg
573862bcd1aSmrg
574862bcd1aSmrg# func_append_quoted VAR VALUE
575862bcd1aSmrg# ----------------------------
576862bcd1aSmrg# Quote VALUE and append to the end of shell variable VAR, separated
577862bcd1aSmrg# by a space.
578862bcd1aSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
579862bcd1aSmrg  eval 'func_append_quoted ()
580862bcd1aSmrg  {
581862bcd1aSmrg    $debug_cmd
582862bcd1aSmrg
583862bcd1aSmrg    func_quote_for_eval "$2"
584862bcd1aSmrg    eval "$1+=\\ \$func_quote_for_eval_result"
585862bcd1aSmrg  }'
586862bcd1aSmrgelse
587862bcd1aSmrg  func_append_quoted ()
588862bcd1aSmrg  {
589862bcd1aSmrg    $debug_cmd
590862bcd1aSmrg
591862bcd1aSmrg    func_quote_for_eval "$2"
592862bcd1aSmrg    eval "$1=\$$1\\ \$func_quote_for_eval_result"
593862bcd1aSmrg  }
594862bcd1aSmrgfi
595862bcd1aSmrg
596862bcd1aSmrg
597862bcd1aSmrg# func_append_uniq VAR VALUE
598862bcd1aSmrg# --------------------------
599862bcd1aSmrg# Append unique VALUE onto the existing contents of VAR, assuming
600862bcd1aSmrg# entries are delimited by the first character of VALUE.  For example:
601862bcd1aSmrg#
602862bcd1aSmrg#   func_append_uniq options " --another-option option-argument"
603862bcd1aSmrg#
604862bcd1aSmrg# will only append to $options if " --another-option option-argument "
605862bcd1aSmrg# is not already present somewhere in $options already (note spaces at
606862bcd1aSmrg# each end implied by leading space in second argument).
607862bcd1aSmrgfunc_append_uniq ()
608862bcd1aSmrg{
609862bcd1aSmrg    $debug_cmd
610862bcd1aSmrg
611862bcd1aSmrg    eval _G_current_value='`$ECHO $'$1'`'
612862bcd1aSmrg    _G_delim=`expr "$2" : '\(.\)'`
613862bcd1aSmrg
614862bcd1aSmrg    case $_G_delim$_G_current_value$_G_delim in
615862bcd1aSmrg      *"$2$_G_delim"*) ;;
616862bcd1aSmrg      *) func_append "$@" ;;
617862bcd1aSmrg    esac
618862bcd1aSmrg}
619862bcd1aSmrg
620862bcd1aSmrg
621862bcd1aSmrg# func_arith TERM...
622862bcd1aSmrg# ------------------
623862bcd1aSmrg# Set func_arith_result to the result of evaluating TERMs.
624862bcd1aSmrg  test -z "$_G_HAVE_ARITH_OP" \
625862bcd1aSmrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
626862bcd1aSmrg    && _G_HAVE_ARITH_OP=yes
627862bcd1aSmrg
628862bcd1aSmrgif test yes = "$_G_HAVE_ARITH_OP"; then
629862bcd1aSmrg  eval 'func_arith ()
630862bcd1aSmrg  {
631862bcd1aSmrg    $debug_cmd
632862bcd1aSmrg
633862bcd1aSmrg    func_arith_result=$(( $* ))
634862bcd1aSmrg  }'
635862bcd1aSmrgelse
636862bcd1aSmrg  func_arith ()
637862bcd1aSmrg  {
638862bcd1aSmrg    $debug_cmd
639862bcd1aSmrg
640862bcd1aSmrg    func_arith_result=`expr "$@"`
641862bcd1aSmrg  }
642862bcd1aSmrgfi
643862bcd1aSmrg
644862bcd1aSmrg
645862bcd1aSmrg# func_basename FILE
646862bcd1aSmrg# ------------------
647862bcd1aSmrg# Set func_basename_result to FILE with everything up to and including
648862bcd1aSmrg# the last / stripped.
649862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
650862bcd1aSmrg  # If this shell supports suffix pattern removal, then use it to avoid
651862bcd1aSmrg  # forking. Hide the definitions single quotes in case the shell chokes
652862bcd1aSmrg  # on unsupported syntax...
653862bcd1aSmrg  _b='func_basename_result=${1##*/}'
654862bcd1aSmrg  _d='case $1 in
655862bcd1aSmrg        */*) func_dirname_result=${1%/*}$2 ;;
656862bcd1aSmrg        *  ) func_dirname_result=$3        ;;
657862bcd1aSmrg      esac'
658862bcd1aSmrg
659862bcd1aSmrgelse
660862bcd1aSmrg  # ...otherwise fall back to using sed.
661862bcd1aSmrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
662862bcd1aSmrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
663862bcd1aSmrg      if test "X$func_dirname_result" = "X$1"; then
664862bcd1aSmrg        func_dirname_result=$3
665862bcd1aSmrg      else
666862bcd1aSmrg        func_append func_dirname_result "$2"
667862bcd1aSmrg      fi'
668862bcd1aSmrgfi
669862bcd1aSmrg
670862bcd1aSmrgeval 'func_basename ()
671862bcd1aSmrg{
672862bcd1aSmrg    $debug_cmd
673862bcd1aSmrg
674862bcd1aSmrg    '"$_b"'
675862bcd1aSmrg}'
676862bcd1aSmrg
677862bcd1aSmrg
678862bcd1aSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
679862bcd1aSmrg# -------------------------------------------
680862bcd1aSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
681862bcd1aSmrg# otherwise set result to NONDIR_REPLACEMENT.
682862bcd1aSmrgeval 'func_dirname ()
683862bcd1aSmrg{
684862bcd1aSmrg    $debug_cmd
685862bcd1aSmrg
686862bcd1aSmrg    '"$_d"'
687862bcd1aSmrg}'
688862bcd1aSmrg
689862bcd1aSmrg
690862bcd1aSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
691862bcd1aSmrg# --------------------------------------------------------
692862bcd1aSmrg# Perform func_basename and func_dirname in a single function
693862bcd1aSmrg# call:
694862bcd1aSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
695862bcd1aSmrg#             add APPEND to the result, otherwise set result
696862bcd1aSmrg#             to NONDIR_REPLACEMENT.
697862bcd1aSmrg#             value returned in "$func_dirname_result"
698862bcd1aSmrg#   basename: Compute filename of FILE.
699862bcd1aSmrg#             value retuned in "$func_basename_result"
700862bcd1aSmrg# For efficiency, we do not delegate to the functions above but instead
701862bcd1aSmrg# duplicate the functionality here.
702862bcd1aSmrgeval 'func_dirname_and_basename ()
703862bcd1aSmrg{
704862bcd1aSmrg    $debug_cmd
705862bcd1aSmrg
706862bcd1aSmrg    '"$_b"'
707862bcd1aSmrg    '"$_d"'
708862bcd1aSmrg}'
709862bcd1aSmrg
710862bcd1aSmrg
711862bcd1aSmrg# func_echo ARG...
712862bcd1aSmrg# ----------------
713862bcd1aSmrg# Echo program name prefixed message.
714862bcd1aSmrgfunc_echo ()
715862bcd1aSmrg{
716862bcd1aSmrg    $debug_cmd
717862bcd1aSmrg
718862bcd1aSmrg    _G_message=$*
719862bcd1aSmrg
720862bcd1aSmrg    func_echo_IFS=$IFS
721862bcd1aSmrg    IFS=$nl
722862bcd1aSmrg    for _G_line in $_G_message; do
723862bcd1aSmrg      IFS=$func_echo_IFS
724862bcd1aSmrg      $ECHO "$progname: $_G_line"
725862bcd1aSmrg    done
726862bcd1aSmrg    IFS=$func_echo_IFS
727862bcd1aSmrg}
728862bcd1aSmrg
729862bcd1aSmrg
730862bcd1aSmrg# func_echo_all ARG...
731862bcd1aSmrg# --------------------
732862bcd1aSmrg# Invoke $ECHO with all args, space-separated.
733862bcd1aSmrgfunc_echo_all ()
734862bcd1aSmrg{
735862bcd1aSmrg    $ECHO "$*"
736862bcd1aSmrg}
737862bcd1aSmrg
738862bcd1aSmrg
739862bcd1aSmrg# func_echo_infix_1 INFIX ARG...
740862bcd1aSmrg# ------------------------------
741862bcd1aSmrg# Echo program name, followed by INFIX on the first line, with any
742862bcd1aSmrg# additional lines not showing INFIX.
743862bcd1aSmrgfunc_echo_infix_1 ()
744862bcd1aSmrg{
745862bcd1aSmrg    $debug_cmd
746862bcd1aSmrg
747862bcd1aSmrg    $require_term_colors
748862bcd1aSmrg
749862bcd1aSmrg    _G_infix=$1; shift
750862bcd1aSmrg    _G_indent=$_G_infix
751862bcd1aSmrg    _G_prefix="$progname: $_G_infix: "
752862bcd1aSmrg    _G_message=$*
753862bcd1aSmrg
754862bcd1aSmrg    # Strip color escape sequences before counting printable length
755862bcd1aSmrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
756862bcd1aSmrg    do
757862bcd1aSmrg      test -n "$_G_tc" && {
758862bcd1aSmrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
759862bcd1aSmrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
760862bcd1aSmrg      }
761862bcd1aSmrg    done
762862bcd1aSmrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
763862bcd1aSmrg
764862bcd1aSmrg    func_echo_infix_1_IFS=$IFS
765862bcd1aSmrg    IFS=$nl
766862bcd1aSmrg    for _G_line in $_G_message; do
767862bcd1aSmrg      IFS=$func_echo_infix_1_IFS
768862bcd1aSmrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
769862bcd1aSmrg      _G_prefix=$_G_indent
770862bcd1aSmrg    done
771862bcd1aSmrg    IFS=$func_echo_infix_1_IFS
772862bcd1aSmrg}
773862bcd1aSmrg
774862bcd1aSmrg
775862bcd1aSmrg# func_error ARG...
776862bcd1aSmrg# -----------------
777862bcd1aSmrg# Echo program name prefixed message to standard error.
778862bcd1aSmrgfunc_error ()
779862bcd1aSmrg{
780862bcd1aSmrg    $debug_cmd
781862bcd1aSmrg
782862bcd1aSmrg    $require_term_colors
783862bcd1aSmrg
784862bcd1aSmrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
785862bcd1aSmrg}
786862bcd1aSmrg
787862bcd1aSmrg
788862bcd1aSmrg# func_fatal_error ARG...
789862bcd1aSmrg# -----------------------
790862bcd1aSmrg# Echo program name prefixed message to standard error, and exit.
791862bcd1aSmrgfunc_fatal_error ()
792862bcd1aSmrg{
793862bcd1aSmrg    $debug_cmd
794862bcd1aSmrg
795862bcd1aSmrg    func_error "$*"
796862bcd1aSmrg    exit $EXIT_FAILURE
797862bcd1aSmrg}
798862bcd1aSmrg
799862bcd1aSmrg
800862bcd1aSmrg# func_grep EXPRESSION FILENAME
801862bcd1aSmrg# -----------------------------
80288de56ccSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
80388de56ccSmrgfunc_grep ()
80488de56ccSmrg{
805862bcd1aSmrg    $debug_cmd
806862bcd1aSmrg
80788de56ccSmrg    $GREP "$1" "$2" >/dev/null 2>&1
80888de56ccSmrg}
80988de56ccSmrg
81088de56ccSmrg
811862bcd1aSmrg# func_len STRING
812862bcd1aSmrg# ---------------
813862bcd1aSmrg# Set func_len_result to the length of STRING. STRING may not
814862bcd1aSmrg# start with a hyphen.
815862bcd1aSmrg  test -z "$_G_HAVE_XSI_OPS" \
816862bcd1aSmrg    && (eval 'x=a/b/c;
817862bcd1aSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
818862bcd1aSmrg    && _G_HAVE_XSI_OPS=yes
819862bcd1aSmrg
820862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
821862bcd1aSmrg  eval 'func_len ()
822862bcd1aSmrg  {
823862bcd1aSmrg    $debug_cmd
824862bcd1aSmrg
825862bcd1aSmrg    func_len_result=${#1}
826862bcd1aSmrg  }'
827862bcd1aSmrgelse
828862bcd1aSmrg  func_len ()
829862bcd1aSmrg  {
830862bcd1aSmrg    $debug_cmd
831862bcd1aSmrg
832862bcd1aSmrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
833862bcd1aSmrg  }
834862bcd1aSmrgfi
835862bcd1aSmrg
836862bcd1aSmrg
837862bcd1aSmrg# func_mkdir_p DIRECTORY-PATH
838862bcd1aSmrg# ---------------------------
83988de56ccSmrg# Make sure the entire path to DIRECTORY-PATH is available.
84088de56ccSmrgfunc_mkdir_p ()
84188de56ccSmrg{
842862bcd1aSmrg    $debug_cmd
843862bcd1aSmrg
844862bcd1aSmrg    _G_directory_path=$1
845862bcd1aSmrg    _G_dir_list=
84688de56ccSmrg
847862bcd1aSmrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
84888de56ccSmrg
849862bcd1aSmrg      # Protect directory names starting with '-'
850862bcd1aSmrg      case $_G_directory_path in
851862bcd1aSmrg        -*) _G_directory_path=./$_G_directory_path ;;
85288de56ccSmrg      esac
85388de56ccSmrg
85488de56ccSmrg      # While some portion of DIR does not yet exist...
855862bcd1aSmrg      while test ! -d "$_G_directory_path"; do
85688de56ccSmrg        # ...make a list in topmost first order.  Use a colon delimited
85788de56ccSmrg	# list incase some portion of path contains whitespace.
858862bcd1aSmrg        _G_dir_list=$_G_directory_path:$_G_dir_list
85988de56ccSmrg
86088de56ccSmrg        # If the last portion added has no slash in it, the list is done
861862bcd1aSmrg        case $_G_directory_path in */*) ;; *) break ;; esac
86288de56ccSmrg
86388de56ccSmrg        # ...otherwise throw away the child directory and loop
864862bcd1aSmrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
86588de56ccSmrg      done
866862bcd1aSmrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
86788de56ccSmrg
868862bcd1aSmrg      func_mkdir_p_IFS=$IFS; IFS=:
869862bcd1aSmrg      for _G_dir in $_G_dir_list; do
870862bcd1aSmrg	IFS=$func_mkdir_p_IFS
871862bcd1aSmrg        # mkdir can fail with a 'File exist' error if two processes
87288de56ccSmrg        # try to create one of the directories concurrently.  Don't
87388de56ccSmrg        # stop in that case!
874862bcd1aSmrg        $MKDIR "$_G_dir" 2>/dev/null || :
87588de56ccSmrg      done
876862bcd1aSmrg      IFS=$func_mkdir_p_IFS
87788de56ccSmrg
87888de56ccSmrg      # Bail out if we (or some other process) failed to create a directory.
879862bcd1aSmrg      test -d "$_G_directory_path" || \
880862bcd1aSmrg        func_fatal_error "Failed to create '$1'"
88188de56ccSmrg    fi
88288de56ccSmrg}
8831ab64890Smrg
8841ab64890Smrg
885862bcd1aSmrg# func_mktempdir [BASENAME]
886862bcd1aSmrg# -------------------------
8871ab64890Smrg# Make a temporary directory that won't clash with other running
8881ab64890Smrg# libtool processes, and avoids race conditions if possible.  If
889862bcd1aSmrg# given, BASENAME is the basename for that directory.
8901ab64890Smrgfunc_mktempdir ()
8911ab64890Smrg{
892862bcd1aSmrg    $debug_cmd
893862bcd1aSmrg
894862bcd1aSmrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
8951ab64890Smrg
896862bcd1aSmrg    if test : = "$opt_dry_run"; then
8971ab64890Smrg      # Return a directory name, but don't create it in dry-run mode
898862bcd1aSmrg      _G_tmpdir=$_G_template-$$
8991ab64890Smrg    else
9001ab64890Smrg
9011ab64890Smrg      # If mktemp works, use that first and foremost
902862bcd1aSmrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
9031ab64890Smrg
904862bcd1aSmrg      if test ! -d "$_G_tmpdir"; then
90588de56ccSmrg        # Failing that, at least try and use $RANDOM to avoid a race
906862bcd1aSmrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
9071ab64890Smrg
908862bcd1aSmrg        func_mktempdir_umask=`umask`
90988de56ccSmrg        umask 0077
910862bcd1aSmrg        $MKDIR "$_G_tmpdir"
911862bcd1aSmrg        umask $func_mktempdir_umask
9121ab64890Smrg      fi
9131ab64890Smrg
9141ab64890Smrg      # If we're not in dry-run mode, bomb out on failure
915862bcd1aSmrg      test -d "$_G_tmpdir" || \
916862bcd1aSmrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
9171ab64890Smrg    fi
9181ab64890Smrg
919862bcd1aSmrg    $ECHO "$_G_tmpdir"
9201ab64890Smrg}
9211ab64890Smrg
9221ab64890Smrg
923862bcd1aSmrg# func_normal_abspath PATH
924862bcd1aSmrg# ------------------------
925862bcd1aSmrg# Remove doubled-up and trailing slashes, "." path components,
926862bcd1aSmrg# and cancel out any ".." path components in PATH after making
927862bcd1aSmrg# it an absolute path.
928862bcd1aSmrgfunc_normal_abspath ()
9291ab64890Smrg{
930862bcd1aSmrg    $debug_cmd
93188de56ccSmrg
932862bcd1aSmrg    # These SED scripts presuppose an absolute path with a trailing slash.
933862bcd1aSmrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
934862bcd1aSmrg    _G_pathcdr='s|^/[^/]*||'
935862bcd1aSmrg    _G_removedotparts=':dotsl
936862bcd1aSmrg		s|/\./|/|g
937862bcd1aSmrg		t dotsl
938862bcd1aSmrg		s|/\.$|/|'
939862bcd1aSmrg    _G_collapseslashes='s|/\{1,\}|/|g'
940862bcd1aSmrg    _G_finalslash='s|/*$|/|'
941862bcd1aSmrg
942862bcd1aSmrg    # Start from root dir and reassemble the path.
943862bcd1aSmrg    func_normal_abspath_result=
944862bcd1aSmrg    func_normal_abspath_tpath=$1
945862bcd1aSmrg    func_normal_abspath_altnamespace=
946862bcd1aSmrg    case $func_normal_abspath_tpath in
947862bcd1aSmrg      "")
948862bcd1aSmrg        # Empty path, that just means $cwd.
949862bcd1aSmrg        func_stripname '' '/' "`pwd`"
950862bcd1aSmrg        func_normal_abspath_result=$func_stripname_result
951862bcd1aSmrg        return
952862bcd1aSmrg        ;;
953862bcd1aSmrg      # The next three entries are used to spot a run of precisely
954862bcd1aSmrg      # two leading slashes without using negated character classes;
955862bcd1aSmrg      # we take advantage of case's first-match behaviour.
956862bcd1aSmrg      ///*)
957862bcd1aSmrg        # Unusual form of absolute path, do nothing.
958862bcd1aSmrg        ;;
959862bcd1aSmrg      //*)
960862bcd1aSmrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
961862bcd1aSmrg        # and for example Cygwin uses it to access remote file shares
962862bcd1aSmrg        # over CIFS/SMB, so we conserve a leading double slash if found.
963862bcd1aSmrg        func_normal_abspath_altnamespace=/
964862bcd1aSmrg        ;;
965862bcd1aSmrg      /*)
966862bcd1aSmrg        # Absolute path, do nothing.
96788de56ccSmrg        ;;
96888de56ccSmrg      *)
969862bcd1aSmrg        # Relative path, prepend $cwd.
970862bcd1aSmrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
971862bcd1aSmrg        ;;
9721ab64890Smrg    esac
973862bcd1aSmrg
974862bcd1aSmrg    # Cancel out all the simple stuff to save iterations.  We also want
975862bcd1aSmrg    # the path to end with a slash for ease of parsing, so make sure
976862bcd1aSmrg    # there is one (and only one) here.
977862bcd1aSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
978862bcd1aSmrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
979862bcd1aSmrg    while :; do
980862bcd1aSmrg      # Processed it all yet?
981862bcd1aSmrg      if test / = "$func_normal_abspath_tpath"; then
982862bcd1aSmrg        # If we ascended to the root using ".." the result may be empty now.
983862bcd1aSmrg        if test -z "$func_normal_abspath_result"; then
984862bcd1aSmrg          func_normal_abspath_result=/
985862bcd1aSmrg        fi
986862bcd1aSmrg        break
987862bcd1aSmrg      fi
988862bcd1aSmrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
989862bcd1aSmrg          -e "$_G_pathcar"`
990862bcd1aSmrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
991862bcd1aSmrg          -e "$_G_pathcdr"`
992862bcd1aSmrg      # Figure out what to do with it
993862bcd1aSmrg      case $func_normal_abspath_tcomponent in
994862bcd1aSmrg        "")
995862bcd1aSmrg          # Trailing empty path component, ignore it.
996862bcd1aSmrg          ;;
997862bcd1aSmrg        ..)
998862bcd1aSmrg          # Parent dir; strip last assembled component from result.
999862bcd1aSmrg          func_dirname "$func_normal_abspath_result"
1000862bcd1aSmrg          func_normal_abspath_result=$func_dirname_result
1001862bcd1aSmrg          ;;
1002862bcd1aSmrg        *)
1003862bcd1aSmrg          # Actual path component, append it.
1004862bcd1aSmrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1005862bcd1aSmrg          ;;
1006862bcd1aSmrg      esac
1007862bcd1aSmrg    done
1008862bcd1aSmrg    # Restore leading double-slash if one was found on entry.
1009862bcd1aSmrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1010862bcd1aSmrg}
1011862bcd1aSmrg
1012862bcd1aSmrg
1013862bcd1aSmrg# func_notquiet ARG...
1014862bcd1aSmrg# --------------------
1015862bcd1aSmrg# Echo program name prefixed message only when not in quiet mode.
1016862bcd1aSmrgfunc_notquiet ()
1017862bcd1aSmrg{
1018862bcd1aSmrg    $debug_cmd
1019862bcd1aSmrg
1020862bcd1aSmrg    $opt_quiet || func_echo ${1+"$@"}
1021862bcd1aSmrg
1022862bcd1aSmrg    # A bug in bash halts the script if the last line of a function
1023862bcd1aSmrg    # fails when set -e is in force, so we need another command to
1024862bcd1aSmrg    # work around that:
1025862bcd1aSmrg    :
1026862bcd1aSmrg}
1027862bcd1aSmrg
1028862bcd1aSmrg
1029862bcd1aSmrg# func_relative_path SRCDIR DSTDIR
1030862bcd1aSmrg# --------------------------------
1031862bcd1aSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1032862bcd1aSmrgfunc_relative_path ()
1033862bcd1aSmrg{
1034862bcd1aSmrg    $debug_cmd
1035862bcd1aSmrg
1036862bcd1aSmrg    func_relative_path_result=
1037862bcd1aSmrg    func_normal_abspath "$1"
1038862bcd1aSmrg    func_relative_path_tlibdir=$func_normal_abspath_result
1039862bcd1aSmrg    func_normal_abspath "$2"
1040862bcd1aSmrg    func_relative_path_tbindir=$func_normal_abspath_result
1041862bcd1aSmrg
1042862bcd1aSmrg    # Ascend the tree starting from libdir
1043862bcd1aSmrg    while :; do
1044862bcd1aSmrg      # check if we have found a prefix of bindir
1045862bcd1aSmrg      case $func_relative_path_tbindir in
1046862bcd1aSmrg        $func_relative_path_tlibdir)
1047862bcd1aSmrg          # found an exact match
1048862bcd1aSmrg          func_relative_path_tcancelled=
1049862bcd1aSmrg          break
1050862bcd1aSmrg          ;;
1051862bcd1aSmrg        $func_relative_path_tlibdir*)
1052862bcd1aSmrg          # found a matching prefix
1053862bcd1aSmrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1054862bcd1aSmrg          func_relative_path_tcancelled=$func_stripname_result
1055862bcd1aSmrg          if test -z "$func_relative_path_result"; then
1056862bcd1aSmrg            func_relative_path_result=.
1057862bcd1aSmrg          fi
1058862bcd1aSmrg          break
1059862bcd1aSmrg          ;;
1060862bcd1aSmrg        *)
1061862bcd1aSmrg          func_dirname $func_relative_path_tlibdir
1062862bcd1aSmrg          func_relative_path_tlibdir=$func_dirname_result
1063862bcd1aSmrg          if test -z "$func_relative_path_tlibdir"; then
1064862bcd1aSmrg            # Have to descend all the way to the root!
1065862bcd1aSmrg            func_relative_path_result=../$func_relative_path_result
1066862bcd1aSmrg            func_relative_path_tcancelled=$func_relative_path_tbindir
1067862bcd1aSmrg            break
1068862bcd1aSmrg          fi
1069862bcd1aSmrg          func_relative_path_result=../$func_relative_path_result
1070862bcd1aSmrg          ;;
1071862bcd1aSmrg      esac
1072862bcd1aSmrg    done
1073862bcd1aSmrg
1074862bcd1aSmrg    # Now calculate path; take care to avoid doubling-up slashes.
1075862bcd1aSmrg    func_stripname '' '/' "$func_relative_path_result"
1076862bcd1aSmrg    func_relative_path_result=$func_stripname_result
1077862bcd1aSmrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
1078862bcd1aSmrg    if test -n "$func_stripname_result"; then
1079862bcd1aSmrg      func_append func_relative_path_result "/$func_stripname_result"
1080862bcd1aSmrg    fi
1081862bcd1aSmrg
1082862bcd1aSmrg    # Normalisation. If bindir is libdir, return '.' else relative path.
1083862bcd1aSmrg    if test -n "$func_relative_path_result"; then
1084862bcd1aSmrg      func_stripname './' '' "$func_relative_path_result"
1085862bcd1aSmrg      func_relative_path_result=$func_stripname_result
1086862bcd1aSmrg    fi
1087862bcd1aSmrg
1088862bcd1aSmrg    test -n "$func_relative_path_result" || func_relative_path_result=.
1089862bcd1aSmrg
1090862bcd1aSmrg    :
10911ab64890Smrg}
10921ab64890Smrg
10931ab64890Smrg
109438ae11fcSmrg# func_quote ARG
109538ae11fcSmrg# --------------
109638ae11fcSmrg# Aesthetically quote one ARG, store the result into $func_quote_result.  Note
109738ae11fcSmrg# that we keep attention to performance here (so far O(N) complexity as long as
109838ae11fcSmrg# func_append is O(1)).
109938ae11fcSmrgfunc_quote ()
110038ae11fcSmrg{
110138ae11fcSmrg    $debug_cmd
110238ae11fcSmrg
110338ae11fcSmrg    func_quote_result=$1
110438ae11fcSmrg
110538ae11fcSmrg    case $func_quote_result in
110638ae11fcSmrg      *[\\\`\"\$]*)
110738ae11fcSmrg        case $func_quote_result in
110838ae11fcSmrg          *[\[\*\?]*)
110938ae11fcSmrg            func_quote_result=`$ECHO "$func_quote_result" | $SED "$sed_quote_subst"`
111038ae11fcSmrg            return 0
111138ae11fcSmrg            ;;
111238ae11fcSmrg        esac
111338ae11fcSmrg
111438ae11fcSmrg        func_quote_old_IFS=$IFS
111538ae11fcSmrg        for _G_char in '\' '`' '"' '$'
111638ae11fcSmrg        do
111738ae11fcSmrg          # STATE($1) PREV($2) SEPARATOR($3)
111838ae11fcSmrg          set start "" ""
111938ae11fcSmrg          func_quote_result=dummy"$_G_char$func_quote_result$_G_char"dummy
112038ae11fcSmrg          IFS=$_G_char
112138ae11fcSmrg          for _G_part in $func_quote_result
112238ae11fcSmrg          do
112338ae11fcSmrg            case $1 in
112438ae11fcSmrg            quote)
112538ae11fcSmrg              func_append func_quote_result "$3$2"
112638ae11fcSmrg              set quote "$_G_part" "\\$_G_char"
112738ae11fcSmrg              ;;
112838ae11fcSmrg            start)
112938ae11fcSmrg              set first "" ""
113038ae11fcSmrg              func_quote_result=
113138ae11fcSmrg              ;;
113238ae11fcSmrg            first)
113338ae11fcSmrg              set quote "$_G_part" ""
113438ae11fcSmrg              ;;
113538ae11fcSmrg            esac
113638ae11fcSmrg          done
113738ae11fcSmrg          IFS=$func_quote_old_IFS
113838ae11fcSmrg        done
113938ae11fcSmrg        ;;
114038ae11fcSmrg      *) ;;
114138ae11fcSmrg    esac
114238ae11fcSmrg}
114338ae11fcSmrg
114438ae11fcSmrg
1145862bcd1aSmrg# func_quote_for_eval ARG...
1146862bcd1aSmrg# --------------------------
1147862bcd1aSmrg# Aesthetically quote ARGs to be evaled later.
1148862bcd1aSmrg# This function returns two values:
1149862bcd1aSmrg#   i) func_quote_for_eval_result
1150862bcd1aSmrg#      double-quoted, suitable for a subsequent eval
1151862bcd1aSmrg#  ii) func_quote_for_eval_unquoted_result
1152862bcd1aSmrg#      has all characters that are still active within double
1153862bcd1aSmrg#      quotes backslashified.
1154862bcd1aSmrgfunc_quote_for_eval ()
1155862bcd1aSmrg{
1156862bcd1aSmrg    $debug_cmd
1157862bcd1aSmrg
1158862bcd1aSmrg    func_quote_for_eval_unquoted_result=
1159862bcd1aSmrg    func_quote_for_eval_result=
1160862bcd1aSmrg    while test 0 -lt $#; do
116138ae11fcSmrg      func_quote "$1"
116238ae11fcSmrg      _G_unquoted_arg=$func_quote_result
1163862bcd1aSmrg      if test -n "$func_quote_for_eval_unquoted_result"; then
1164862bcd1aSmrg	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1165862bcd1aSmrg      else
1166862bcd1aSmrg        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1167862bcd1aSmrg      fi
1168862bcd1aSmrg
1169862bcd1aSmrg      case $_G_unquoted_arg in
1170862bcd1aSmrg        # Double-quote args containing shell metacharacters to delay
1171862bcd1aSmrg        # word splitting, command substitution and variable expansion
1172862bcd1aSmrg        # for a subsequent eval.
1173862bcd1aSmrg        # Many Bourne shells cannot handle close brackets correctly
1174862bcd1aSmrg        # in scan sets, so we specify it separately.
1175862bcd1aSmrg        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1176862bcd1aSmrg          _G_quoted_arg=\"$_G_unquoted_arg\"
1177862bcd1aSmrg          ;;
1178862bcd1aSmrg        *)
1179862bcd1aSmrg          _G_quoted_arg=$_G_unquoted_arg
1180862bcd1aSmrg	  ;;
1181862bcd1aSmrg      esac
1182862bcd1aSmrg
1183862bcd1aSmrg      if test -n "$func_quote_for_eval_result"; then
1184862bcd1aSmrg	func_append func_quote_for_eval_result " $_G_quoted_arg"
1185862bcd1aSmrg      else
1186862bcd1aSmrg        func_append func_quote_for_eval_result "$_G_quoted_arg"
1187862bcd1aSmrg      fi
1188862bcd1aSmrg      shift
1189862bcd1aSmrg    done
1190862bcd1aSmrg}
1191862bcd1aSmrg
1192862bcd1aSmrg
1193862bcd1aSmrg# func_quote_for_expand ARG
1194862bcd1aSmrg# -------------------------
119588de56ccSmrg# Aesthetically quote ARG to be evaled later; same as above,
119688de56ccSmrg# but do not quote variable references.
119788de56ccSmrgfunc_quote_for_expand ()
11981ab64890Smrg{
1199862bcd1aSmrg    $debug_cmd
1200862bcd1aSmrg
120188de56ccSmrg    case $1 in
120288de56ccSmrg      *[\\\`\"]*)
1203862bcd1aSmrg	_G_arg=`$ECHO "$1" | $SED \
1204862bcd1aSmrg	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
12051ab64890Smrg      *)
1206862bcd1aSmrg        _G_arg=$1 ;;
120788de56ccSmrg    esac
120888de56ccSmrg
1209862bcd1aSmrg    case $_G_arg in
121088de56ccSmrg      # Double-quote args containing shell metacharacters to delay
121188de56ccSmrg      # word splitting and command substitution for a subsequent eval.
121288de56ccSmrg      # Many Bourne shells cannot handle close brackets correctly
121388de56ccSmrg      # in scan sets, so we specify it separately.
121488de56ccSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1215862bcd1aSmrg        _G_arg=\"$_G_arg\"
121688de56ccSmrg        ;;
121788de56ccSmrg    esac
121888de56ccSmrg
1219862bcd1aSmrg    func_quote_for_expand_result=$_G_arg
1220862bcd1aSmrg}
1221862bcd1aSmrg
1222862bcd1aSmrg
1223862bcd1aSmrg# func_stripname PREFIX SUFFIX NAME
1224862bcd1aSmrg# ---------------------------------
1225862bcd1aSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1226862bcd1aSmrg# PREFIX and SUFFIX must not contain globbing or regex special
1227862bcd1aSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
1228862bcd1aSmrg# dot (in which case that matches only a dot).
1229862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
1230862bcd1aSmrg  eval 'func_stripname ()
1231862bcd1aSmrg  {
1232862bcd1aSmrg    $debug_cmd
1233862bcd1aSmrg
1234862bcd1aSmrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1235862bcd1aSmrg    # positional parameters, so assign one to ordinary variable first.
1236862bcd1aSmrg    func_stripname_result=$3
1237862bcd1aSmrg    func_stripname_result=${func_stripname_result#"$1"}
1238862bcd1aSmrg    func_stripname_result=${func_stripname_result%"$2"}
1239862bcd1aSmrg  }'
1240862bcd1aSmrgelse
1241862bcd1aSmrg  func_stripname ()
1242862bcd1aSmrg  {
1243862bcd1aSmrg    $debug_cmd
1244862bcd1aSmrg
1245862bcd1aSmrg    case $2 in
1246862bcd1aSmrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1247862bcd1aSmrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1248862bcd1aSmrg    esac
1249862bcd1aSmrg  }
1250862bcd1aSmrgfi
1251862bcd1aSmrg
1252862bcd1aSmrg
1253862bcd1aSmrg# func_show_eval CMD [FAIL_EXP]
1254862bcd1aSmrg# -----------------------------
1255862bcd1aSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1256862bcd1aSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1257862bcd1aSmrg# is given, then evaluate it.
1258862bcd1aSmrgfunc_show_eval ()
1259862bcd1aSmrg{
1260862bcd1aSmrg    $debug_cmd
1261862bcd1aSmrg
1262862bcd1aSmrg    _G_cmd=$1
1263862bcd1aSmrg    _G_fail_exp=${2-':'}
1264862bcd1aSmrg
1265862bcd1aSmrg    func_quote_for_expand "$_G_cmd"
1266862bcd1aSmrg    eval "func_notquiet $func_quote_for_expand_result"
1267862bcd1aSmrg
1268862bcd1aSmrg    $opt_dry_run || {
1269862bcd1aSmrg      eval "$_G_cmd"
1270862bcd1aSmrg      _G_status=$?
1271862bcd1aSmrg      if test 0 -ne "$_G_status"; then
1272862bcd1aSmrg	eval "(exit $_G_status); $_G_fail_exp"
1273862bcd1aSmrg      fi
1274862bcd1aSmrg    }
1275862bcd1aSmrg}
1276862bcd1aSmrg
1277862bcd1aSmrg
1278862bcd1aSmrg# func_show_eval_locale CMD [FAIL_EXP]
1279862bcd1aSmrg# ------------------------------------
1280862bcd1aSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1281862bcd1aSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1282862bcd1aSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
1283862bcd1aSmrgfunc_show_eval_locale ()
1284862bcd1aSmrg{
1285862bcd1aSmrg    $debug_cmd
1286862bcd1aSmrg
1287862bcd1aSmrg    _G_cmd=$1
1288862bcd1aSmrg    _G_fail_exp=${2-':'}
1289862bcd1aSmrg
1290862bcd1aSmrg    $opt_quiet || {
1291862bcd1aSmrg      func_quote_for_expand "$_G_cmd"
1292862bcd1aSmrg      eval "func_echo $func_quote_for_expand_result"
1293862bcd1aSmrg    }
1294862bcd1aSmrg
1295862bcd1aSmrg    $opt_dry_run || {
1296862bcd1aSmrg      eval "$_G_user_locale
1297862bcd1aSmrg	    $_G_cmd"
1298862bcd1aSmrg      _G_status=$?
1299862bcd1aSmrg      eval "$_G_safe_locale"
1300862bcd1aSmrg      if test 0 -ne "$_G_status"; then
1301862bcd1aSmrg	eval "(exit $_G_status); $_G_fail_exp"
1302862bcd1aSmrg      fi
1303862bcd1aSmrg    }
1304862bcd1aSmrg}
1305862bcd1aSmrg
1306862bcd1aSmrg
1307862bcd1aSmrg# func_tr_sh
1308862bcd1aSmrg# ----------
1309862bcd1aSmrg# Turn $1 into a string suitable for a shell variable name.
1310862bcd1aSmrg# Result is stored in $func_tr_sh_result.  All characters
1311862bcd1aSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1312862bcd1aSmrg# if $1 begins with a digit, a '_' is prepended as well.
1313862bcd1aSmrgfunc_tr_sh ()
1314862bcd1aSmrg{
1315862bcd1aSmrg    $debug_cmd
1316862bcd1aSmrg
1317862bcd1aSmrg    case $1 in
1318862bcd1aSmrg    [0-9]* | *[!a-zA-Z0-9_]*)
1319862bcd1aSmrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1320862bcd1aSmrg      ;;
1321862bcd1aSmrg    * )
1322862bcd1aSmrg      func_tr_sh_result=$1
1323862bcd1aSmrg      ;;
1324862bcd1aSmrg    esac
1325862bcd1aSmrg}
1326862bcd1aSmrg
1327862bcd1aSmrg
1328862bcd1aSmrg# func_verbose ARG...
1329862bcd1aSmrg# -------------------
1330862bcd1aSmrg# Echo program name prefixed message in verbose mode only.
1331862bcd1aSmrgfunc_verbose ()
1332862bcd1aSmrg{
1333862bcd1aSmrg    $debug_cmd
1334862bcd1aSmrg
1335862bcd1aSmrg    $opt_verbose && func_echo "$*"
1336862bcd1aSmrg
1337862bcd1aSmrg    :
1338862bcd1aSmrg}
1339862bcd1aSmrg
1340862bcd1aSmrg
1341862bcd1aSmrg# func_warn_and_continue ARG...
1342862bcd1aSmrg# -----------------------------
1343862bcd1aSmrg# Echo program name prefixed warning message to standard error.
1344862bcd1aSmrgfunc_warn_and_continue ()
1345862bcd1aSmrg{
1346862bcd1aSmrg    $debug_cmd
1347862bcd1aSmrg
1348862bcd1aSmrg    $require_term_colors
1349862bcd1aSmrg
1350862bcd1aSmrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1351862bcd1aSmrg}
1352862bcd1aSmrg
1353862bcd1aSmrg
1354862bcd1aSmrg# func_warning CATEGORY ARG...
1355862bcd1aSmrg# ----------------------------
1356862bcd1aSmrg# Echo program name prefixed warning message to standard error. Warning
1357862bcd1aSmrg# messages can be filtered according to CATEGORY, where this function
1358862bcd1aSmrg# elides messages where CATEGORY is not listed in the global variable
1359862bcd1aSmrg# 'opt_warning_types'.
1360862bcd1aSmrgfunc_warning ()
1361862bcd1aSmrg{
1362862bcd1aSmrg    $debug_cmd
1363862bcd1aSmrg
1364862bcd1aSmrg    # CATEGORY must be in the warning_categories list!
1365862bcd1aSmrg    case " $warning_categories " in
1366862bcd1aSmrg      *" $1 "*) ;;
1367862bcd1aSmrg      *) func_internal_error "invalid warning category '$1'" ;;
1368862bcd1aSmrg    esac
1369862bcd1aSmrg
1370862bcd1aSmrg    _G_category=$1
1371862bcd1aSmrg    shift
1372862bcd1aSmrg
1373862bcd1aSmrg    case " $opt_warning_types " in
1374862bcd1aSmrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
1375862bcd1aSmrg    esac
13761ab64890Smrg}
13771ab64890Smrg
13781ab64890Smrg
1379862bcd1aSmrg# func_sort_ver VER1 VER2
1380862bcd1aSmrg# -----------------------
1381862bcd1aSmrg# 'sort -V' is not generally available.
1382862bcd1aSmrg# Note this deviates from the version comparison in automake
1383862bcd1aSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1384862bcd1aSmrg# but this should suffice as we won't be specifying old
1385862bcd1aSmrg# version formats or redundant trailing .0 in bootstrap.conf.
1386862bcd1aSmrg# If we did want full compatibility then we should probably
1387862bcd1aSmrg# use m4_version_compare from autoconf.
1388862bcd1aSmrgfunc_sort_ver ()
1389862bcd1aSmrg{
1390862bcd1aSmrg    $debug_cmd
1391862bcd1aSmrg
1392862bcd1aSmrg    printf '%s\n%s\n' "$1" "$2" \
1393862bcd1aSmrg      | 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
1394862bcd1aSmrg}
1395862bcd1aSmrg
1396862bcd1aSmrg# func_lt_ver PREV CURR
1397862bcd1aSmrg# ---------------------
1398862bcd1aSmrg# Return true if PREV and CURR are in the correct order according to
1399862bcd1aSmrg# func_sort_ver, otherwise false.  Use it like this:
1400862bcd1aSmrg#
1401862bcd1aSmrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1402862bcd1aSmrgfunc_lt_ver ()
1403862bcd1aSmrg{
1404862bcd1aSmrg    $debug_cmd
1405862bcd1aSmrg
1406862bcd1aSmrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1407862bcd1aSmrg}
1408862bcd1aSmrg
1409862bcd1aSmrg
1410862bcd1aSmrg# Local variables:
1411862bcd1aSmrg# mode: shell-script
1412862bcd1aSmrg# sh-indentation: 2
1413862bcd1aSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1414862bcd1aSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1415862bcd1aSmrg# time-stamp-time-zone: "UTC"
1416862bcd1aSmrg# End:
1417862bcd1aSmrg#! /bin/sh
1418862bcd1aSmrg
1419862bcd1aSmrg# Set a version string for this script.
1420862bcd1aSmrgscriptversion=2014-01-07.03; # UTC
1421862bcd1aSmrg
1422862bcd1aSmrg# A portable, pluggable option parser for Bourne shell.
1423862bcd1aSmrg# Written by Gary V. Vaughan, 2010
1424862bcd1aSmrg
1425862bcd1aSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc.
1426862bcd1aSmrg# This is free software; see the source for copying conditions.  There is NO
1427862bcd1aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1428862bcd1aSmrg
1429862bcd1aSmrg# This program is free software: you can redistribute it and/or modify
1430862bcd1aSmrg# it under the terms of the GNU General Public License as published by
1431862bcd1aSmrg# the Free Software Foundation, either version 3 of the License, or
1432862bcd1aSmrg# (at your option) any later version.
1433862bcd1aSmrg
1434862bcd1aSmrg# This program is distributed in the hope that it will be useful,
1435862bcd1aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1436862bcd1aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1437862bcd1aSmrg# GNU General Public License for more details.
1438862bcd1aSmrg
1439862bcd1aSmrg# You should have received a copy of the GNU General Public License
1440862bcd1aSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
1441862bcd1aSmrg
1442862bcd1aSmrg# Please report bugs or propose patches to gary@gnu.org.
1443862bcd1aSmrg
1444862bcd1aSmrg
1445862bcd1aSmrg## ------ ##
1446862bcd1aSmrg## Usage. ##
1447862bcd1aSmrg## ------ ##
1448862bcd1aSmrg
1449862bcd1aSmrg# This file is a library for parsing options in your shell scripts along
1450862bcd1aSmrg# with assorted other useful supporting features that you can make use
1451862bcd1aSmrg# of too.
1452862bcd1aSmrg#
1453862bcd1aSmrg# For the simplest scripts you might need only:
1454862bcd1aSmrg#
1455862bcd1aSmrg#   #!/bin/sh
1456862bcd1aSmrg#   . relative/path/to/funclib.sh
1457862bcd1aSmrg#   . relative/path/to/options-parser
1458862bcd1aSmrg#   scriptversion=1.0
1459862bcd1aSmrg#   func_options ${1+"$@"}
1460862bcd1aSmrg#   eval set dummy "$func_options_result"; shift
1461862bcd1aSmrg#   ...rest of your script...
1462862bcd1aSmrg#
1463862bcd1aSmrg# In order for the '--version' option to work, you will need to have a
1464862bcd1aSmrg# suitably formatted comment like the one at the top of this file
1465862bcd1aSmrg# starting with '# Written by ' and ending with '# warranty; '.
1466862bcd1aSmrg#
1467862bcd1aSmrg# For '-h' and '--help' to work, you will also need a one line
1468862bcd1aSmrg# description of your script's purpose in a comment directly above the
1469862bcd1aSmrg# '# Written by ' line, like the one at the top of this file.
1470862bcd1aSmrg#
1471862bcd1aSmrg# The default options also support '--debug', which will turn on shell
1472862bcd1aSmrg# execution tracing (see the comment above debug_cmd below for another
1473862bcd1aSmrg# use), and '--verbose' and the func_verbose function to allow your script
1474862bcd1aSmrg# to display verbose messages only when your user has specified
1475862bcd1aSmrg# '--verbose'.
1476862bcd1aSmrg#
1477862bcd1aSmrg# After sourcing this file, you can plug processing for additional
1478862bcd1aSmrg# options by amending the variables from the 'Configuration' section
1479862bcd1aSmrg# below, and following the instructions in the 'Option parsing'
1480862bcd1aSmrg# section further down.
1481862bcd1aSmrg
1482862bcd1aSmrg## -------------- ##
1483862bcd1aSmrg## Configuration. ##
1484862bcd1aSmrg## -------------- ##
1485862bcd1aSmrg
1486862bcd1aSmrg# You should override these variables in your script after sourcing this
1487862bcd1aSmrg# file so that they reflect the customisations you have added to the
1488862bcd1aSmrg# option parser.
1489862bcd1aSmrg
1490862bcd1aSmrg# The usage line for option parsing errors and the start of '-h' and
1491862bcd1aSmrg# '--help' output messages. You can embed shell variables for delayed
1492862bcd1aSmrg# expansion at the time the message is displayed, but you will need to
1493862bcd1aSmrg# quote other shell meta-characters carefully to prevent them being
1494862bcd1aSmrg# expanded when the contents are evaled.
1495862bcd1aSmrgusage='$progpath [OPTION]...'
1496862bcd1aSmrg
1497862bcd1aSmrg# Short help message in response to '-h' and '--help'.  Add to this or
1498862bcd1aSmrg# override it after sourcing this library to reflect the full set of
1499862bcd1aSmrg# options your script accepts.
1500862bcd1aSmrgusage_message="\
1501862bcd1aSmrg       --debug        enable verbose shell tracing
1502862bcd1aSmrg   -W, --warnings=CATEGORY
1503862bcd1aSmrg                      report the warnings falling in CATEGORY [all]
1504862bcd1aSmrg   -v, --verbose      verbosely report processing
1505862bcd1aSmrg       --version      print version information and exit
1506862bcd1aSmrg   -h, --help         print short or long help message and exit
1507862bcd1aSmrg"
1508862bcd1aSmrg
1509862bcd1aSmrg# Additional text appended to 'usage_message' in response to '--help'.
1510862bcd1aSmrglong_help_message="
1511862bcd1aSmrgWarning categories include:
1512862bcd1aSmrg       'all'          show all warnings
1513862bcd1aSmrg       'none'         turn off all the warnings
1514862bcd1aSmrg       'error'        warnings are treated as fatal errors"
1515862bcd1aSmrg
1516862bcd1aSmrg# Help message printed before fatal option parsing errors.
1517862bcd1aSmrgfatal_help="Try '\$progname --help' for more information."
1518862bcd1aSmrg
1519862bcd1aSmrg
1520862bcd1aSmrg
1521862bcd1aSmrg## ------------------------- ##
1522862bcd1aSmrg## Hook function management. ##
1523862bcd1aSmrg## ------------------------- ##
1524862bcd1aSmrg
1525862bcd1aSmrg# This section contains functions for adding, removing, and running hooks
1526862bcd1aSmrg# to the main code.  A hook is just a named list of of function, that can
1527862bcd1aSmrg# be run in order later on.
1528862bcd1aSmrg
1529862bcd1aSmrg# func_hookable FUNC_NAME
1530862bcd1aSmrg# -----------------------
1531862bcd1aSmrg# Declare that FUNC_NAME will run hooks added with
1532862bcd1aSmrg# 'func_add_hook FUNC_NAME ...'.
1533862bcd1aSmrgfunc_hookable ()
1534862bcd1aSmrg{
1535862bcd1aSmrg    $debug_cmd
1536862bcd1aSmrg
1537862bcd1aSmrg    func_append hookable_fns " $1"
1538862bcd1aSmrg}
1539862bcd1aSmrg
1540862bcd1aSmrg
1541862bcd1aSmrg# func_add_hook FUNC_NAME HOOK_FUNC
1542862bcd1aSmrg# ---------------------------------
1543862bcd1aSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
1544862bcd1aSmrg# first have been declared "hookable" by a call to 'func_hookable'.
1545862bcd1aSmrgfunc_add_hook ()
1546862bcd1aSmrg{
1547862bcd1aSmrg    $debug_cmd
1548862bcd1aSmrg
1549862bcd1aSmrg    case " $hookable_fns " in
1550862bcd1aSmrg      *" $1 "*) ;;
1551862bcd1aSmrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
1552862bcd1aSmrg    esac
1553862bcd1aSmrg
1554862bcd1aSmrg    eval func_append ${1}_hooks '" $2"'
1555862bcd1aSmrg}
1556862bcd1aSmrg
1557862bcd1aSmrg
1558862bcd1aSmrg# func_remove_hook FUNC_NAME HOOK_FUNC
1559862bcd1aSmrg# ------------------------------------
1560862bcd1aSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
1561862bcd1aSmrgfunc_remove_hook ()
1562862bcd1aSmrg{
1563862bcd1aSmrg    $debug_cmd
1564862bcd1aSmrg
1565862bcd1aSmrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1566862bcd1aSmrg}
1567862bcd1aSmrg
1568862bcd1aSmrg
1569862bcd1aSmrg# func_run_hooks FUNC_NAME [ARG]...
1570862bcd1aSmrg# ---------------------------------
1571862bcd1aSmrg# Run all hook functions registered to FUNC_NAME.
1572862bcd1aSmrg# It is assumed that the list of hook functions contains nothing more
1573862bcd1aSmrg# than a whitespace-delimited list of legal shell function names, and
1574862bcd1aSmrg# no effort is wasted trying to catch shell meta-characters or preserve
1575862bcd1aSmrg# whitespace.
1576862bcd1aSmrgfunc_run_hooks ()
1577862bcd1aSmrg{
1578862bcd1aSmrg    $debug_cmd
1579862bcd1aSmrg
1580862bcd1aSmrg    case " $hookable_fns " in
1581862bcd1aSmrg      *" $1 "*) ;;
1582862bcd1aSmrg      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
1583862bcd1aSmrg    esac
1584862bcd1aSmrg
1585862bcd1aSmrg    eval _G_hook_fns=\$$1_hooks; shift
1586862bcd1aSmrg
1587862bcd1aSmrg    for _G_hook in $_G_hook_fns; do
1588862bcd1aSmrg      eval $_G_hook '"$@"'
1589862bcd1aSmrg
1590862bcd1aSmrg      # store returned options list back into positional
1591862bcd1aSmrg      # parameters for next 'cmd' execution.
1592862bcd1aSmrg      eval _G_hook_result=\$${_G_hook}_result
1593862bcd1aSmrg      eval set dummy "$_G_hook_result"; shift
1594862bcd1aSmrg    done
1595862bcd1aSmrg
1596862bcd1aSmrg    func_quote_for_eval ${1+"$@"}
1597862bcd1aSmrg    func_run_hooks_result=$func_quote_for_eval_result
1598862bcd1aSmrg}
1599862bcd1aSmrg
1600862bcd1aSmrg
1601862bcd1aSmrg
1602862bcd1aSmrg## --------------- ##
1603862bcd1aSmrg## Option parsing. ##
1604862bcd1aSmrg## --------------- ##
1605862bcd1aSmrg
1606862bcd1aSmrg# In order to add your own option parsing hooks, you must accept the
1607862bcd1aSmrg# full positional parameter list in your hook function, remove any
1608862bcd1aSmrg# options that you action, and then pass back the remaining unprocessed
1609862bcd1aSmrg# options in '<hooked_function_name>_result', escaped suitably for
1610862bcd1aSmrg# 'eval'.  Like this:
1611862bcd1aSmrg#
1612862bcd1aSmrg#    my_options_prep ()
1613862bcd1aSmrg#    {
1614862bcd1aSmrg#        $debug_cmd
1615862bcd1aSmrg#
1616862bcd1aSmrg#        # Extend the existing usage message.
1617862bcd1aSmrg#        usage_message=$usage_message'
1618862bcd1aSmrg#      -s, --silent       don'\''t print informational messages
1619862bcd1aSmrg#    '
1620862bcd1aSmrg#
1621862bcd1aSmrg#        func_quote_for_eval ${1+"$@"}
1622862bcd1aSmrg#        my_options_prep_result=$func_quote_for_eval_result
1623862bcd1aSmrg#    }
1624862bcd1aSmrg#    func_add_hook func_options_prep my_options_prep
1625862bcd1aSmrg#
1626862bcd1aSmrg#
1627862bcd1aSmrg#    my_silent_option ()
1628862bcd1aSmrg#    {
1629862bcd1aSmrg#        $debug_cmd
1630862bcd1aSmrg#
1631862bcd1aSmrg#        # Note that for efficiency, we parse as many options as we can
1632862bcd1aSmrg#        # recognise in a loop before passing the remainder back to the
1633862bcd1aSmrg#        # caller on the first unrecognised argument we encounter.
1634862bcd1aSmrg#        while test $# -gt 0; do
1635862bcd1aSmrg#          opt=$1; shift
1636862bcd1aSmrg#          case $opt in
1637862bcd1aSmrg#            --silent|-s) opt_silent=: ;;
1638862bcd1aSmrg#            # Separate non-argument short options:
1639862bcd1aSmrg#            -s*)         func_split_short_opt "$_G_opt"
1640862bcd1aSmrg#                         set dummy "$func_split_short_opt_name" \
1641862bcd1aSmrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
1642862bcd1aSmrg#                         shift
1643862bcd1aSmrg#                         ;;
1644862bcd1aSmrg#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
1645862bcd1aSmrg#          esac
1646862bcd1aSmrg#        done
1647862bcd1aSmrg#
1648862bcd1aSmrg#        func_quote_for_eval ${1+"$@"}
1649862bcd1aSmrg#        my_silent_option_result=$func_quote_for_eval_result
1650862bcd1aSmrg#    }
1651862bcd1aSmrg#    func_add_hook func_parse_options my_silent_option
1652862bcd1aSmrg#
1653862bcd1aSmrg#
1654862bcd1aSmrg#    my_option_validation ()
1655862bcd1aSmrg#    {
1656862bcd1aSmrg#        $debug_cmd
1657862bcd1aSmrg#
1658862bcd1aSmrg#        $opt_silent && $opt_verbose && func_fatal_help "\
1659862bcd1aSmrg#    '--silent' and '--verbose' options are mutually exclusive."
1660862bcd1aSmrg#
1661862bcd1aSmrg#        func_quote_for_eval ${1+"$@"}
1662862bcd1aSmrg#        my_option_validation_result=$func_quote_for_eval_result
1663862bcd1aSmrg#    }
1664862bcd1aSmrg#    func_add_hook func_validate_options my_option_validation
1665862bcd1aSmrg#
1666862bcd1aSmrg# You'll alse need to manually amend $usage_message to reflect the extra
1667862bcd1aSmrg# options you parse.  It's preferable to append if you can, so that
1668862bcd1aSmrg# multiple option parsing hooks can be added safely.
1669862bcd1aSmrg
1670862bcd1aSmrg
1671862bcd1aSmrg# func_options [ARG]...
1672862bcd1aSmrg# ---------------------
1673862bcd1aSmrg# All the functions called inside func_options are hookable. See the
1674862bcd1aSmrg# individual implementations for details.
1675862bcd1aSmrgfunc_hookable func_options
1676862bcd1aSmrgfunc_options ()
16771ab64890Smrg{
1678862bcd1aSmrg    $debug_cmd
16792e9c7c8cSmrg
1680862bcd1aSmrg    func_options_prep ${1+"$@"}
1681862bcd1aSmrg    eval func_parse_options \
1682862bcd1aSmrg        ${func_options_prep_result+"$func_options_prep_result"}
1683862bcd1aSmrg    eval func_validate_options \
1684862bcd1aSmrg        ${func_parse_options_result+"$func_parse_options_result"}
168588de56ccSmrg
1686862bcd1aSmrg    eval func_run_hooks func_options \
1687862bcd1aSmrg        ${func_validate_options_result+"$func_validate_options_result"}
1688862bcd1aSmrg
1689862bcd1aSmrg    # save modified positional parameters for caller
1690862bcd1aSmrg    func_options_result=$func_run_hooks_result
16911ab64890Smrg}
16921ab64890Smrg
169388de56ccSmrg
1694862bcd1aSmrg# func_options_prep [ARG]...
1695862bcd1aSmrg# --------------------------
1696862bcd1aSmrg# All initialisations required before starting the option parse loop.
1697862bcd1aSmrg# Note that when calling hook functions, we pass through the list of
1698862bcd1aSmrg# positional parameters.  If a hook function modifies that list, and
1699862bcd1aSmrg# needs to propogate that back to rest of this script, then the complete
1700862bcd1aSmrg# modified list must be put in 'func_run_hooks_result' before
1701862bcd1aSmrg# returning.
1702862bcd1aSmrgfunc_hookable func_options_prep
1703862bcd1aSmrgfunc_options_prep ()
17041ab64890Smrg{
1705862bcd1aSmrg    $debug_cmd
170688de56ccSmrg
1707862bcd1aSmrg    # Option defaults:
1708862bcd1aSmrg    opt_verbose=false
1709862bcd1aSmrg    opt_warning_types=
171088de56ccSmrg
1711862bcd1aSmrg    func_run_hooks func_options_prep ${1+"$@"}
1712862bcd1aSmrg
1713862bcd1aSmrg    # save modified positional parameters for caller
1714862bcd1aSmrg    func_options_prep_result=$func_run_hooks_result
171588de56ccSmrg}
17161ab64890Smrg
1717862bcd1aSmrg
1718862bcd1aSmrg# func_parse_options [ARG]...
1719862bcd1aSmrg# ---------------------------
1720862bcd1aSmrg# The main option parsing loop.
1721862bcd1aSmrgfunc_hookable func_parse_options
1722862bcd1aSmrgfunc_parse_options ()
1723e9fcaa8aSmrg{
1724862bcd1aSmrg    $debug_cmd
1725862bcd1aSmrg
1726862bcd1aSmrg    func_parse_options_result=
1727862bcd1aSmrg
1728862bcd1aSmrg    # this just eases exit handling
1729862bcd1aSmrg    while test $# -gt 0; do
1730862bcd1aSmrg      # Defer to hook functions for initial option parsing, so they
1731862bcd1aSmrg      # get priority in the event of reusing an option name.
1732862bcd1aSmrg      func_run_hooks func_parse_options ${1+"$@"}
1733862bcd1aSmrg
1734862bcd1aSmrg      # Adjust func_parse_options positional parameters to match
1735862bcd1aSmrg      eval set dummy "$func_run_hooks_result"; shift
1736862bcd1aSmrg
1737862bcd1aSmrg      # Break out of the loop if we already parsed every option.
1738862bcd1aSmrg      test $# -gt 0 || break
1739862bcd1aSmrg
1740862bcd1aSmrg      _G_opt=$1
1741862bcd1aSmrg      shift
1742862bcd1aSmrg      case $_G_opt in
1743862bcd1aSmrg        --debug|-x)   debug_cmd='set -x'
1744862bcd1aSmrg                      func_echo "enabling shell trace mode"
1745862bcd1aSmrg                      $debug_cmd
1746862bcd1aSmrg                      ;;
1747862bcd1aSmrg
1748862bcd1aSmrg        --no-warnings|--no-warning|--no-warn)
1749862bcd1aSmrg                      set dummy --warnings none ${1+"$@"}
1750862bcd1aSmrg                      shift
1751862bcd1aSmrg		      ;;
1752862bcd1aSmrg
1753862bcd1aSmrg        --warnings|--warning|-W)
1754862bcd1aSmrg                      test $# = 0 && func_missing_arg $_G_opt && break
1755862bcd1aSmrg                      case " $warning_categories $1" in
1756862bcd1aSmrg                        *" $1 "*)
1757862bcd1aSmrg                          # trailing space prevents matching last $1 above
1758862bcd1aSmrg                          func_append_uniq opt_warning_types " $1"
1759862bcd1aSmrg                          ;;
1760862bcd1aSmrg                        *all)
1761862bcd1aSmrg                          opt_warning_types=$warning_categories
1762862bcd1aSmrg                          ;;
1763862bcd1aSmrg                        *none)
1764862bcd1aSmrg                          opt_warning_types=none
1765862bcd1aSmrg                          warning_func=:
1766862bcd1aSmrg                          ;;
1767862bcd1aSmrg                        *error)
1768862bcd1aSmrg                          opt_warning_types=$warning_categories
1769862bcd1aSmrg                          warning_func=func_fatal_error
1770862bcd1aSmrg                          ;;
1771862bcd1aSmrg                        *)
1772862bcd1aSmrg                          func_fatal_error \
1773862bcd1aSmrg                             "unsupported warning category: '$1'"
1774862bcd1aSmrg                          ;;
1775862bcd1aSmrg                      esac
1776862bcd1aSmrg                      shift
1777862bcd1aSmrg                      ;;
1778862bcd1aSmrg
1779862bcd1aSmrg        --verbose|-v) opt_verbose=: ;;
1780862bcd1aSmrg        --version)    func_version ;;
1781862bcd1aSmrg        -\?|-h)       func_usage ;;
1782862bcd1aSmrg        --help)       func_help ;;
1783862bcd1aSmrg
1784862bcd1aSmrg	# Separate optargs to long options (plugins may need this):
1785862bcd1aSmrg	--*=*)        func_split_equals "$_G_opt"
1786862bcd1aSmrg	              set dummy "$func_split_equals_lhs" \
1787862bcd1aSmrg                          "$func_split_equals_rhs" ${1+"$@"}
1788862bcd1aSmrg                      shift
1789862bcd1aSmrg                      ;;
1790862bcd1aSmrg
1791862bcd1aSmrg       # Separate optargs to short options:
1792862bcd1aSmrg        -W*)
1793862bcd1aSmrg                      func_split_short_opt "$_G_opt"
1794862bcd1aSmrg                      set dummy "$func_split_short_opt_name" \
1795862bcd1aSmrg                          "$func_split_short_opt_arg" ${1+"$@"}
1796862bcd1aSmrg                      shift
1797862bcd1aSmrg                      ;;
1798862bcd1aSmrg
1799862bcd1aSmrg        # Separate non-argument short options:
1800862bcd1aSmrg        -\?*|-h*|-v*|-x*)
1801862bcd1aSmrg                      func_split_short_opt "$_G_opt"
1802862bcd1aSmrg                      set dummy "$func_split_short_opt_name" \
1803862bcd1aSmrg                          "-$func_split_short_opt_arg" ${1+"$@"}
1804862bcd1aSmrg                      shift
1805862bcd1aSmrg                      ;;
1806862bcd1aSmrg
1807862bcd1aSmrg        --)           break ;;
1808862bcd1aSmrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
1809862bcd1aSmrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1810862bcd1aSmrg      esac
1811862bcd1aSmrg    done
1812862bcd1aSmrg
1813862bcd1aSmrg    # save modified positional parameters for caller
1814862bcd1aSmrg    func_quote_for_eval ${1+"$@"}
1815862bcd1aSmrg    func_parse_options_result=$func_quote_for_eval_result
1816e9fcaa8aSmrg}
181788de56ccSmrg
181888de56ccSmrg
1819862bcd1aSmrg# func_validate_options [ARG]...
1820862bcd1aSmrg# ------------------------------
1821862bcd1aSmrg# Perform any sanity checks on option settings and/or unconsumed
1822862bcd1aSmrg# arguments.
1823862bcd1aSmrgfunc_hookable func_validate_options
1824862bcd1aSmrgfunc_validate_options ()
182588de56ccSmrg{
1826862bcd1aSmrg    $debug_cmd
1827e9fcaa8aSmrg
1828862bcd1aSmrg    # Display all warnings if -W was not given.
1829862bcd1aSmrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1830862bcd1aSmrg
1831862bcd1aSmrg    func_run_hooks func_validate_options ${1+"$@"}
1832862bcd1aSmrg
1833862bcd1aSmrg    # Bail if the options were screwed!
1834862bcd1aSmrg    $exit_cmd $EXIT_FAILURE
1835862bcd1aSmrg
1836862bcd1aSmrg    # save modified positional parameters for caller
1837862bcd1aSmrg    func_validate_options_result=$func_run_hooks_result
183888de56ccSmrg}
183988de56ccSmrg
1840862bcd1aSmrg
1841862bcd1aSmrg
1842862bcd1aSmrg## ----------------- ##
1843862bcd1aSmrg## Helper functions. ##
1844862bcd1aSmrg## ----------------- ##
1845862bcd1aSmrg
1846862bcd1aSmrg# This section contains the helper functions used by the rest of the
1847862bcd1aSmrg# hookable option parser framework in ascii-betical order.
1848862bcd1aSmrg
1849862bcd1aSmrg
1850862bcd1aSmrg# func_fatal_help ARG...
1851862bcd1aSmrg# ----------------------
1852862bcd1aSmrg# Echo program name prefixed message to standard error, followed by
1853862bcd1aSmrg# a help hint, and exit.
1854862bcd1aSmrgfunc_fatal_help ()
185588de56ccSmrg{
1856862bcd1aSmrg    $debug_cmd
1857e9fcaa8aSmrg
1858862bcd1aSmrg    eval \$ECHO \""Usage: $usage"\"
1859862bcd1aSmrg    eval \$ECHO \""$fatal_help"\"
1860862bcd1aSmrg    func_error ${1+"$@"}
1861862bcd1aSmrg    exit $EXIT_FAILURE
186288de56ccSmrg}
186388de56ccSmrg
1864862bcd1aSmrg
1865862bcd1aSmrg# func_help
1866862bcd1aSmrg# ---------
1867862bcd1aSmrg# Echo long help message to standard output and exit.
186888de56ccSmrgfunc_help ()
186988de56ccSmrg{
1870862bcd1aSmrg    $debug_cmd
1871862bcd1aSmrg
1872862bcd1aSmrg    func_usage_message
1873862bcd1aSmrg    $ECHO "$long_help_message"
1874862bcd1aSmrg    exit 0
187588de56ccSmrg}
187688de56ccSmrg
1877862bcd1aSmrg
1878862bcd1aSmrg# func_missing_arg ARGNAME
1879862bcd1aSmrg# ------------------------
188088de56ccSmrg# Echo program name prefixed message to standard error and set global
188188de56ccSmrg# exit_cmd.
188288de56ccSmrgfunc_missing_arg ()
188388de56ccSmrg{
1884862bcd1aSmrg    $debug_cmd
1885e9fcaa8aSmrg
1886862bcd1aSmrg    func_error "Missing argument for '$1'."
188788de56ccSmrg    exit_cmd=exit
18881ab64890Smrg}
18891ab64890Smrg
18902e9c7c8cSmrg
1891862bcd1aSmrg# func_split_equals STRING
1892862bcd1aSmrg# ------------------------
1893862bcd1aSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
1894862bcd1aSmrg# splitting STRING at the '=' sign.
1895862bcd1aSmrgtest -z "$_G_HAVE_XSI_OPS" \
1896862bcd1aSmrg    && (eval 'x=a/b/c;
1897862bcd1aSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1898862bcd1aSmrg    && _G_HAVE_XSI_OPS=yes
1899862bcd1aSmrg
1900862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"
1901862bcd1aSmrgthen
1902862bcd1aSmrg  # This is an XSI compatible shell, allowing a faster implementation...
1903862bcd1aSmrg  eval 'func_split_equals ()
1904862bcd1aSmrg  {
1905862bcd1aSmrg      $debug_cmd
1906862bcd1aSmrg
1907862bcd1aSmrg      func_split_equals_lhs=${1%%=*}
1908862bcd1aSmrg      func_split_equals_rhs=${1#*=}
1909862bcd1aSmrg      test "x$func_split_equals_lhs" = "x$1" \
1910862bcd1aSmrg        && func_split_equals_rhs=
1911862bcd1aSmrg  }'
1912862bcd1aSmrgelse
1913862bcd1aSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
1914862bcd1aSmrg  func_split_equals ()
1915862bcd1aSmrg  {
1916862bcd1aSmrg      $debug_cmd
1917862bcd1aSmrg
1918862bcd1aSmrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
1919862bcd1aSmrg      func_split_equals_rhs=
1920862bcd1aSmrg      test "x$func_split_equals_lhs" = "x$1" \
1921862bcd1aSmrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
1922862bcd1aSmrg  }
1923862bcd1aSmrgfi #func_split_equals
1924862bcd1aSmrg
1925862bcd1aSmrg
1926862bcd1aSmrg# func_split_short_opt SHORTOPT
1927862bcd1aSmrg# -----------------------------
1928e9fcaa8aSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
1929e9fcaa8aSmrg# variables after splitting SHORTOPT after the 2nd character.
1930862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"
1931862bcd1aSmrgthen
1932862bcd1aSmrg  # This is an XSI compatible shell, allowing a faster implementation...
1933862bcd1aSmrg  eval 'func_split_short_opt ()
1934862bcd1aSmrg  {
1935862bcd1aSmrg      $debug_cmd
1936862bcd1aSmrg
1937862bcd1aSmrg      func_split_short_opt_arg=${1#??}
1938862bcd1aSmrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1939862bcd1aSmrg  }'
1940862bcd1aSmrgelse
1941862bcd1aSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
1942862bcd1aSmrg  func_split_short_opt ()
1943862bcd1aSmrg  {
1944862bcd1aSmrg      $debug_cmd
1945862bcd1aSmrg
1946862bcd1aSmrg      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
1947862bcd1aSmrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
1948862bcd1aSmrg  }
1949862bcd1aSmrgfi #func_split_short_opt
1950862bcd1aSmrg
1951862bcd1aSmrg
1952862bcd1aSmrg# func_usage
1953862bcd1aSmrg# ----------
1954862bcd1aSmrg# Echo short help message to standard output and exit.
1955862bcd1aSmrgfunc_usage ()
1956e9fcaa8aSmrg{
1957862bcd1aSmrg    $debug_cmd
1958e9fcaa8aSmrg
1959862bcd1aSmrg    func_usage_message
1960862bcd1aSmrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
1961862bcd1aSmrg    exit 0
1962862bcd1aSmrg}
19632e9c7c8cSmrg
196488de56ccSmrg
1965862bcd1aSmrg# func_usage_message
1966862bcd1aSmrg# ------------------
1967862bcd1aSmrg# Echo short help message to standard output.
1968862bcd1aSmrgfunc_usage_message ()
1969e9fcaa8aSmrg{
1970862bcd1aSmrg    $debug_cmd
1971e9fcaa8aSmrg
1972862bcd1aSmrg    eval \$ECHO \""Usage: $usage"\"
1973862bcd1aSmrg    echo
1974862bcd1aSmrg    $SED -n 's|^# ||
1975862bcd1aSmrg        /^Written by/{
1976862bcd1aSmrg          x;p;x
1977862bcd1aSmrg        }
1978862bcd1aSmrg	h
1979862bcd1aSmrg	/^Written by/q' < "$progpath"
1980862bcd1aSmrg    echo
1981862bcd1aSmrg    eval \$ECHO \""$usage_message"\"
1982862bcd1aSmrg}
1983e9fcaa8aSmrg
1984e9fcaa8aSmrg
1985862bcd1aSmrg# func_version
1986862bcd1aSmrg# ------------
1987862bcd1aSmrg# Echo version message to standard output and exit.
1988862bcd1aSmrgfunc_version ()
1989862bcd1aSmrg{
1990862bcd1aSmrg    $debug_cmd
199188de56ccSmrg
1992862bcd1aSmrg    printf '%s\n' "$progname $scriptversion"
1993862bcd1aSmrg    $SED -n '
1994862bcd1aSmrg        /(C)/!b go
1995862bcd1aSmrg        :more
1996862bcd1aSmrg        /\./!{
1997862bcd1aSmrg          N
1998862bcd1aSmrg          s|\n# | |
1999862bcd1aSmrg          b more
2000862bcd1aSmrg        }
2001862bcd1aSmrg        :go
2002862bcd1aSmrg        /^# Written by /,/# warranty; / {
2003862bcd1aSmrg          s|^# ||
2004862bcd1aSmrg          s|^# *$||
2005862bcd1aSmrg          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
2006862bcd1aSmrg          p
2007862bcd1aSmrg        }
2008862bcd1aSmrg        /^# Written by / {
2009862bcd1aSmrg          s|^# ||
2010862bcd1aSmrg          p
2011862bcd1aSmrg        }
2012862bcd1aSmrg        /^warranty; /q' < "$progpath"
201388de56ccSmrg
2014862bcd1aSmrg    exit $?
2015862bcd1aSmrg}
20161ab64890Smrg
20171ab64890Smrg
2018862bcd1aSmrg# Local variables:
2019862bcd1aSmrg# mode: shell-script
2020862bcd1aSmrg# sh-indentation: 2
2021862bcd1aSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
2022862bcd1aSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
2023862bcd1aSmrg# time-stamp-time-zone: "UTC"
2024862bcd1aSmrg# End:
20251ab64890Smrg
2026862bcd1aSmrg# Set a version string.
2027862bcd1aSmrgscriptversion='(GNU libtool) 2.4.6'
20282e9c7c8cSmrg
202988de56ccSmrg
2030862bcd1aSmrg# func_echo ARG...
2031862bcd1aSmrg# ----------------
2032862bcd1aSmrg# Libtool also displays the current mode in messages, so override
2033862bcd1aSmrg# funclib.sh func_echo with this custom definition.
2034862bcd1aSmrgfunc_echo ()
2035e9fcaa8aSmrg{
2036862bcd1aSmrg    $debug_cmd
2037e9fcaa8aSmrg
2038862bcd1aSmrg    _G_message=$*
2039862bcd1aSmrg
2040862bcd1aSmrg    func_echo_IFS=$IFS
2041862bcd1aSmrg    IFS=$nl
2042862bcd1aSmrg    for _G_line in $_G_message; do
2043862bcd1aSmrg      IFS=$func_echo_IFS
2044862bcd1aSmrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
2045862bcd1aSmrg    done
2046862bcd1aSmrg    IFS=$func_echo_IFS
2047862bcd1aSmrg}
2048e9fcaa8aSmrg
2049e9fcaa8aSmrg
2050862bcd1aSmrg# func_warning ARG...
2051862bcd1aSmrg# -------------------
2052862bcd1aSmrg# Libtool warnings are not categorized, so override funclib.sh
2053862bcd1aSmrg# func_warning with this simpler definition.
2054862bcd1aSmrgfunc_warning ()
2055e9fcaa8aSmrg{
2056862bcd1aSmrg    $debug_cmd
2057862bcd1aSmrg
2058862bcd1aSmrg    $warning_func ${1+"$@"}
2059862bcd1aSmrg}
2060862bcd1aSmrg
2061e9fcaa8aSmrg
2062862bcd1aSmrg## ---------------- ##
2063862bcd1aSmrg## Options parsing. ##
2064862bcd1aSmrg## ---------------- ##
2065862bcd1aSmrg
2066862bcd1aSmrg# Hook in the functions to make sure our own options are parsed during
2067862bcd1aSmrg# the option parsing loop.
2068862bcd1aSmrg
2069862bcd1aSmrgusage='$progpath [OPTION]... [MODE-ARG]...'
2070862bcd1aSmrg
2071862bcd1aSmrg# Short help message in response to '-h'.
2072862bcd1aSmrgusage_message="Options:
2073862bcd1aSmrg       --config             show all configuration variables
2074862bcd1aSmrg       --debug              enable verbose shell tracing
2075862bcd1aSmrg   -n, --dry-run            display commands without modifying any files
2076862bcd1aSmrg       --features           display basic configuration information and exit
2077862bcd1aSmrg       --mode=MODE          use operation mode MODE
2078862bcd1aSmrg       --no-warnings        equivalent to '-Wnone'
2079862bcd1aSmrg       --preserve-dup-deps  don't remove duplicate dependency libraries
2080862bcd1aSmrg       --quiet, --silent    don't print informational messages
2081862bcd1aSmrg       --tag=TAG            use configuration variables from tag TAG
2082862bcd1aSmrg   -v, --verbose            print more informational messages than default
2083862bcd1aSmrg       --version            print version information
2084862bcd1aSmrg   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
2085862bcd1aSmrg   -h, --help, --help-all   print short, long, or detailed help message
2086862bcd1aSmrg"
2087e9fcaa8aSmrg
2088862bcd1aSmrg# Additional text appended to 'usage_message' in response to '--help'.
2089862bcd1aSmrgfunc_help ()
2090e9fcaa8aSmrg{
2091862bcd1aSmrg    $debug_cmd
2092862bcd1aSmrg
2093862bcd1aSmrg    func_usage_message
2094862bcd1aSmrg    $ECHO "$long_help_message
2095862bcd1aSmrg
2096862bcd1aSmrgMODE must be one of the following:
2097862bcd1aSmrg
2098862bcd1aSmrg       clean           remove files from the build directory
2099862bcd1aSmrg       compile         compile a source file into a libtool object
2100862bcd1aSmrg       execute         automatically set library path, then run a program
2101862bcd1aSmrg       finish          complete the installation of libtool libraries
2102862bcd1aSmrg       install         install libraries or executables
2103862bcd1aSmrg       link            create a library or an executable
2104862bcd1aSmrg       uninstall       remove libraries from an installed directory
2105862bcd1aSmrg
2106862bcd1aSmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
2107862bcd1aSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2108862bcd1aSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
2109862bcd1aSmrg
2110862bcd1aSmrgWhen reporting a bug, please describe a test case to reproduce it and
2111862bcd1aSmrginclude the following information:
2112862bcd1aSmrg
2113862bcd1aSmrg       host-triplet:   $host
2114862bcd1aSmrg       shell:          $SHELL
2115862bcd1aSmrg       compiler:       $LTCC
2116862bcd1aSmrg       compiler flags: $LTCFLAGS
2117862bcd1aSmrg       linker:         $LD (gnu? $with_gnu_ld)
2118862bcd1aSmrg       version:        $progname (GNU libtool) 2.4.6
2119862bcd1aSmrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2120862bcd1aSmrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2121862bcd1aSmrg
2122862bcd1aSmrgReport bugs to <bug-libtool@gnu.org>.
212338ae11fcSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>.
2124862bcd1aSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
2125862bcd1aSmrg    exit 0
2126862bcd1aSmrg}
2127e9fcaa8aSmrg
2128e9fcaa8aSmrg
2129862bcd1aSmrg# func_lo2o OBJECT-NAME
2130862bcd1aSmrg# ---------------------
2131862bcd1aSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2132862bcd1aSmrg# object suffix.
2133e9fcaa8aSmrg
2134862bcd1aSmrglo2o=s/\\.lo\$/.$objext/
2135862bcd1aSmrgo2lo=s/\\.$objext\$/.lo/
2136e9fcaa8aSmrg
2137862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
2138862bcd1aSmrg  eval 'func_lo2o ()
2139862bcd1aSmrg  {
2140862bcd1aSmrg    case $1 in
2141862bcd1aSmrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
2142862bcd1aSmrg      *   ) func_lo2o_result=$1               ;;
2143862bcd1aSmrg    esac
2144862bcd1aSmrg  }'
2145862bcd1aSmrg
2146862bcd1aSmrg  # func_xform LIBOBJ-OR-SOURCE
2147862bcd1aSmrg  # ---------------------------
2148862bcd1aSmrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2149862bcd1aSmrg  # suffix to a '.lo' libtool-object suffix.
2150862bcd1aSmrg  eval 'func_xform ()
2151862bcd1aSmrg  {
2152862bcd1aSmrg    func_xform_result=${1%.*}.lo
2153862bcd1aSmrg  }'
2154862bcd1aSmrgelse
2155862bcd1aSmrg  # ...otherwise fall back to using sed.
2156862bcd1aSmrg  func_lo2o ()
2157862bcd1aSmrg  {
2158862bcd1aSmrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2159862bcd1aSmrg  }
2160862bcd1aSmrg
2161862bcd1aSmrg  func_xform ()
2162862bcd1aSmrg  {
2163862bcd1aSmrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2164862bcd1aSmrg  }
2165862bcd1aSmrgfi
2166e9fcaa8aSmrg
2167e9fcaa8aSmrg
2168862bcd1aSmrg# func_fatal_configuration ARG...
2169862bcd1aSmrg# -------------------------------
217088de56ccSmrg# Echo program name prefixed message to standard error, followed by
217188de56ccSmrg# a configuration failure hint, and exit.
217288de56ccSmrgfunc_fatal_configuration ()
217388de56ccSmrg{
2174862bcd1aSmrg    func__fatal_error ${1+"$@"} \
2175862bcd1aSmrg      "See the $PACKAGE documentation for more information." \
2176862bcd1aSmrg      "Fatal configuration error."
217788de56ccSmrg}
21781ab64890Smrg
21792e9c7c8cSmrg
218088de56ccSmrg# func_config
2181862bcd1aSmrg# -----------
218288de56ccSmrg# Display the configuration for all the tags in this script.
218388de56ccSmrgfunc_config ()
218488de56ccSmrg{
218588de56ccSmrg    re_begincf='^# ### BEGIN LIBTOOL'
218688de56ccSmrg    re_endcf='^# ### END LIBTOOL'
218788de56ccSmrg
218888de56ccSmrg    # Default configuration.
218988de56ccSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
21901ab64890Smrg
21911ab64890Smrg    # Now print the configurations for the tags.
21921ab64890Smrg    for tagname in $taglist; do
219388de56ccSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
21941ab64890Smrg    done
2195b4ee4795Smrg
219688de56ccSmrg    exit $?
219788de56ccSmrg}
2198b4ee4795Smrg
2199862bcd1aSmrg
220088de56ccSmrg# func_features
2201862bcd1aSmrg# -------------
220288de56ccSmrg# Display the features supported by this script.
220388de56ccSmrgfunc_features ()
220488de56ccSmrg{
2205e9fcaa8aSmrg    echo "host: $host"
2206862bcd1aSmrg    if test yes = "$build_libtool_libs"; then
2207e9fcaa8aSmrg      echo "enable shared libraries"
22081ab64890Smrg    else
2209e9fcaa8aSmrg      echo "disable shared libraries"
22101ab64890Smrg    fi
2211862bcd1aSmrg    if test yes = "$build_old_libs"; then
2212e9fcaa8aSmrg      echo "enable static libraries"
22131ab64890Smrg    else
2214e9fcaa8aSmrg      echo "disable static libraries"
22151ab64890Smrg    fi
221688de56ccSmrg
22171ab64890Smrg    exit $?
221888de56ccSmrg}
22191ab64890Smrg
2220862bcd1aSmrg
2221862bcd1aSmrg# func_enable_tag TAGNAME
2222862bcd1aSmrg# -----------------------
222388de56ccSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
222488de56ccSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
222588de56ccSmrg# variable here.
222688de56ccSmrgfunc_enable_tag ()
222788de56ccSmrg{
2228862bcd1aSmrg    # Global variable:
2229862bcd1aSmrg    tagname=$1
22301ab64890Smrg
2231862bcd1aSmrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
2232862bcd1aSmrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
2233862bcd1aSmrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
22342e9c7c8cSmrg
2235862bcd1aSmrg    # Validate tagname.
2236862bcd1aSmrg    case $tagname in
2237862bcd1aSmrg      *[!-_A-Za-z0-9,/]*)
2238862bcd1aSmrg        func_fatal_error "invalid tag name: $tagname"
2239862bcd1aSmrg        ;;
2240862bcd1aSmrg    esac
22411ab64890Smrg
2242862bcd1aSmrg    # Don't test for the "default" C tag, as we know it's
2243862bcd1aSmrg    # there but not specially marked.
2244862bcd1aSmrg    case $tagname in
2245862bcd1aSmrg        CC) ;;
224688de56ccSmrg    *)
2247862bcd1aSmrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
2248862bcd1aSmrg	  taglist="$taglist $tagname"
2249862bcd1aSmrg
2250862bcd1aSmrg	  # Evaluate the configuration.  Be careful to quote the path
2251862bcd1aSmrg	  # and the sed script, to avoid splitting on whitespace, but
2252862bcd1aSmrg	  # also don't use non-portable quotes within backquotes within
2253862bcd1aSmrg	  # quotes we have to do it in 2 steps:
2254862bcd1aSmrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
2255862bcd1aSmrg	  eval "$extractedcf"
2256862bcd1aSmrg        else
2257862bcd1aSmrg	  func_error "ignoring unknown tag $tagname"
2258862bcd1aSmrg        fi
2259862bcd1aSmrg        ;;
2260862bcd1aSmrg    esac
226188de56ccSmrg}
226288de56ccSmrg
2263862bcd1aSmrg
2264e9fcaa8aSmrg# func_check_version_match
2265862bcd1aSmrg# ------------------------
2266e9fcaa8aSmrg# Ensure that we are using m4 macros, and libtool script from the same
2267e9fcaa8aSmrg# release of libtool.
2268e9fcaa8aSmrgfunc_check_version_match ()
226988de56ccSmrg{
2270862bcd1aSmrg    if test "$package_revision" != "$macro_revision"; then
2271862bcd1aSmrg      if test "$VERSION" != "$macro_version"; then
2272862bcd1aSmrg        if test -z "$macro_version"; then
2273862bcd1aSmrg          cat >&2 <<_LT_EOF
2274e9fcaa8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2275e9fcaa8aSmrg$progname: definition of this LT_INIT comes from an older release.
2276e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2277e9fcaa8aSmrg$progname: and run autoconf again.
2278e9fcaa8aSmrg_LT_EOF
2279862bcd1aSmrg        else
2280862bcd1aSmrg          cat >&2 <<_LT_EOF
2281e9fcaa8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2282e9fcaa8aSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2283e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2284e9fcaa8aSmrg$progname: and run autoconf again.
2285e9fcaa8aSmrg_LT_EOF
2286862bcd1aSmrg        fi
2287862bcd1aSmrg      else
2288862bcd1aSmrg        cat >&2 <<_LT_EOF
2289e9fcaa8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
2290e9fcaa8aSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
2291e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
2292e9fcaa8aSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
2293e9fcaa8aSmrg_LT_EOF
2294862bcd1aSmrg      fi
2295e9fcaa8aSmrg
2296862bcd1aSmrg      exit $EXIT_MISMATCH
2297862bcd1aSmrg    fi
2298e9fcaa8aSmrg}
2299e9fcaa8aSmrg
2300e9fcaa8aSmrg
2301862bcd1aSmrg# libtool_options_prep [ARG]...
2302862bcd1aSmrg# -----------------------------
2303862bcd1aSmrg# Preparation for options parsed by libtool.
2304862bcd1aSmrglibtool_options_prep ()
2305862bcd1aSmrg{
2306862bcd1aSmrg    $debug_mode
2307b4ee4795Smrg
2308862bcd1aSmrg    # Option defaults:
2309862bcd1aSmrg    opt_config=false
2310862bcd1aSmrg    opt_dlopen=
2311862bcd1aSmrg    opt_dry_run=false
2312862bcd1aSmrg    opt_help=false
2313862bcd1aSmrg    opt_mode=
2314862bcd1aSmrg    opt_preserve_dup_deps=false
2315862bcd1aSmrg    opt_quiet=false
23161ab64890Smrg
2317862bcd1aSmrg    nonopt=
2318862bcd1aSmrg    preserve_args=
2319e9fcaa8aSmrg
2320862bcd1aSmrg    # Shorthand for --mode=foo, only valid as the first argument
2321862bcd1aSmrg    case $1 in
2322862bcd1aSmrg    clean|clea|cle|cl)
2323862bcd1aSmrg      shift; set dummy --mode clean ${1+"$@"}; shift
2324862bcd1aSmrg      ;;
2325862bcd1aSmrg    compile|compil|compi|comp|com|co|c)
2326862bcd1aSmrg      shift; set dummy --mode compile ${1+"$@"}; shift
2327862bcd1aSmrg      ;;
2328862bcd1aSmrg    execute|execut|execu|exec|exe|ex|e)
2329862bcd1aSmrg      shift; set dummy --mode execute ${1+"$@"}; shift
2330862bcd1aSmrg      ;;
2331862bcd1aSmrg    finish|finis|fini|fin|fi|f)
2332862bcd1aSmrg      shift; set dummy --mode finish ${1+"$@"}; shift
2333862bcd1aSmrg      ;;
2334862bcd1aSmrg    install|instal|insta|inst|ins|in|i)
2335862bcd1aSmrg      shift; set dummy --mode install ${1+"$@"}; shift
2336862bcd1aSmrg      ;;
2337862bcd1aSmrg    link|lin|li|l)
2338862bcd1aSmrg      shift; set dummy --mode link ${1+"$@"}; shift
2339862bcd1aSmrg      ;;
2340862bcd1aSmrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
2341862bcd1aSmrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
2342862bcd1aSmrg      ;;
2343862bcd1aSmrg    esac
2344862bcd1aSmrg
2345862bcd1aSmrg    # Pass back the list of options.
2346862bcd1aSmrg    func_quote_for_eval ${1+"$@"}
2347862bcd1aSmrg    libtool_options_prep_result=$func_quote_for_eval_result
2348862bcd1aSmrg}
2349862bcd1aSmrgfunc_add_hook func_options_prep libtool_options_prep
2350e9fcaa8aSmrg
2351e9fcaa8aSmrg
2352862bcd1aSmrg# libtool_parse_options [ARG]...
2353862bcd1aSmrg# ---------------------------------
2354862bcd1aSmrg# Provide handling for libtool specific options.
2355862bcd1aSmrglibtool_parse_options ()
2356e9fcaa8aSmrg{
2357862bcd1aSmrg    $debug_cmd
235888de56ccSmrg
2359862bcd1aSmrg    # Perform our own loop to consume as many options as possible in
2360862bcd1aSmrg    # each iteration.
2361862bcd1aSmrg    while test $# -gt 0; do
2362862bcd1aSmrg      _G_opt=$1
2363862bcd1aSmrg      shift
2364862bcd1aSmrg      case $_G_opt in
2365862bcd1aSmrg        --dry-run|--dryrun|-n)
2366862bcd1aSmrg                        opt_dry_run=:
2367862bcd1aSmrg                        ;;
2368862bcd1aSmrg
2369862bcd1aSmrg        --config)       func_config ;;
2370862bcd1aSmrg
2371862bcd1aSmrg        --dlopen|-dlopen)
2372862bcd1aSmrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
2373862bcd1aSmrg}$1"
2374862bcd1aSmrg                        shift
2375862bcd1aSmrg                        ;;
2376862bcd1aSmrg
2377862bcd1aSmrg        --preserve-dup-deps)
2378862bcd1aSmrg                        opt_preserve_dup_deps=: ;;
2379862bcd1aSmrg
2380862bcd1aSmrg        --features)     func_features ;;
2381862bcd1aSmrg
2382862bcd1aSmrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
2383862bcd1aSmrg
2384862bcd1aSmrg        --help)         opt_help=: ;;
2385862bcd1aSmrg
2386862bcd1aSmrg        --help-all)     opt_help=': help-all' ;;
2387862bcd1aSmrg
2388862bcd1aSmrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
2389862bcd1aSmrg                        opt_mode=$1
2390862bcd1aSmrg                        case $1 in
2391862bcd1aSmrg                          # Valid mode arguments:
2392862bcd1aSmrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
2393862bcd1aSmrg
2394862bcd1aSmrg                          # Catch anything else as an error
2395862bcd1aSmrg                          *) func_error "invalid argument for $_G_opt"
2396862bcd1aSmrg                             exit_cmd=exit
2397862bcd1aSmrg                             break
2398862bcd1aSmrg                             ;;
2399862bcd1aSmrg                        esac
2400862bcd1aSmrg                        shift
2401862bcd1aSmrg                        ;;
2402862bcd1aSmrg
2403862bcd1aSmrg        --no-silent|--no-quiet)
2404862bcd1aSmrg                        opt_quiet=false
2405862bcd1aSmrg                        func_append preserve_args " $_G_opt"
2406862bcd1aSmrg                        ;;
2407862bcd1aSmrg
2408862bcd1aSmrg        --no-warnings|--no-warning|--no-warn)
2409862bcd1aSmrg                        opt_warning=false
2410862bcd1aSmrg                        func_append preserve_args " $_G_opt"
2411862bcd1aSmrg                        ;;
2412862bcd1aSmrg
2413862bcd1aSmrg        --no-verbose)
2414862bcd1aSmrg                        opt_verbose=false
2415862bcd1aSmrg                        func_append preserve_args " $_G_opt"
2416862bcd1aSmrg                        ;;
2417862bcd1aSmrg
2418862bcd1aSmrg        --silent|--quiet)
2419862bcd1aSmrg                        opt_quiet=:
2420862bcd1aSmrg                        opt_verbose=false
2421862bcd1aSmrg                        func_append preserve_args " $_G_opt"
2422862bcd1aSmrg                        ;;
2423862bcd1aSmrg
2424862bcd1aSmrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
2425862bcd1aSmrg                        opt_tag=$1
2426862bcd1aSmrg                        func_append preserve_args " $_G_opt $1"
2427862bcd1aSmrg                        func_enable_tag "$1"
2428862bcd1aSmrg                        shift
2429862bcd1aSmrg                        ;;
2430862bcd1aSmrg
2431862bcd1aSmrg        --verbose|-v)   opt_quiet=false
2432862bcd1aSmrg                        opt_verbose=:
2433862bcd1aSmrg                        func_append preserve_args " $_G_opt"
2434862bcd1aSmrg                        ;;
2435862bcd1aSmrg
2436862bcd1aSmrg	# An option not handled by this hook function:
2437862bcd1aSmrg        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
2438862bcd1aSmrg      esac
2439862bcd1aSmrg    done
2440e9fcaa8aSmrg
2441e9fcaa8aSmrg
2442862bcd1aSmrg    # save modified positional parameters for caller
2443862bcd1aSmrg    func_quote_for_eval ${1+"$@"}
2444862bcd1aSmrg    libtool_parse_options_result=$func_quote_for_eval_result
2445862bcd1aSmrg}
2446862bcd1aSmrgfunc_add_hook func_parse_options libtool_parse_options
244788de56ccSmrg
24482e9c7c8cSmrg
244988de56ccSmrg
2450862bcd1aSmrg# libtool_validate_options [ARG]...
2451862bcd1aSmrg# ---------------------------------
2452862bcd1aSmrg# Perform any sanity checks on option settings and/or unconsumed
2453862bcd1aSmrg# arguments.
2454862bcd1aSmrglibtool_validate_options ()
2455862bcd1aSmrg{
2456862bcd1aSmrg    # save first non-option argument
2457862bcd1aSmrg    if test 0 -lt $#; then
2458862bcd1aSmrg      nonopt=$1
2459862bcd1aSmrg      shift
246088de56ccSmrg    fi
246188de56ccSmrg
2462862bcd1aSmrg    # preserve --debug
2463862bcd1aSmrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
246488de56ccSmrg
2465862bcd1aSmrg    case $host in
2466862bcd1aSmrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
2467862bcd1aSmrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
2468862bcd1aSmrg      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
2469862bcd1aSmrg        # don't eliminate duplications in $postdeps and $predeps
2470862bcd1aSmrg        opt_duplicate_compiler_generated_deps=:
2471862bcd1aSmrg        ;;
2472862bcd1aSmrg      *)
2473862bcd1aSmrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
2474862bcd1aSmrg        ;;
2475862bcd1aSmrg    esac
24761ab64890Smrg
2477862bcd1aSmrg    $opt_help || {
2478862bcd1aSmrg      # Sanity checks first:
2479862bcd1aSmrg      func_check_version_match
248088de56ccSmrg
2481862bcd1aSmrg      test yes != "$build_libtool_libs" \
2482862bcd1aSmrg        && test yes != "$build_old_libs" \
2483862bcd1aSmrg        && func_fatal_configuration "not configured to build any kind of library"
248488de56ccSmrg
2485862bcd1aSmrg      # Darwin sucks
2486862bcd1aSmrg      eval std_shrext=\"$shrext_cmds\"
2487862bcd1aSmrg
2488862bcd1aSmrg      # Only execute mode is allowed to have -dlopen flags.
2489862bcd1aSmrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
2490862bcd1aSmrg        func_error "unrecognized option '-dlopen'"
2491862bcd1aSmrg        $ECHO "$help" 1>&2
2492862bcd1aSmrg        exit $EXIT_FAILURE
2493862bcd1aSmrg      fi
2494862bcd1aSmrg
2495862bcd1aSmrg      # Change the help message to a mode-specific one.
2496862bcd1aSmrg      generic_help=$help
2497862bcd1aSmrg      help="Try '$progname --help --mode=$opt_mode' for more information."
2498862bcd1aSmrg    }
2499862bcd1aSmrg
2500862bcd1aSmrg    # Pass back the unparsed argument list
2501862bcd1aSmrg    func_quote_for_eval ${1+"$@"}
2502862bcd1aSmrg    libtool_validate_options_result=$func_quote_for_eval_result
2503e9fcaa8aSmrg}
2504862bcd1aSmrgfunc_add_hook func_validate_options libtool_validate_options
2505862bcd1aSmrg
250688de56ccSmrg
2507862bcd1aSmrg# Process options as early as possible so that --help and --version
2508862bcd1aSmrg# can return quickly.
2509862bcd1aSmrgfunc_options ${1+"$@"}
2510862bcd1aSmrgeval set dummy "$func_options_result"; shift
251188de56ccSmrg
25121ab64890Smrg
25131ab64890Smrg
2514e9fcaa8aSmrg## ----------- ##
2515e9fcaa8aSmrg##    Main.    ##
2516e9fcaa8aSmrg## ----------- ##
25171ab64890Smrg
2518862bcd1aSmrgmagic='%%%MAGIC variable%%%'
2519862bcd1aSmrgmagic_exe='%%%MAGIC EXE variable%%%'
2520862bcd1aSmrg
2521862bcd1aSmrg# Global variables.
2522862bcd1aSmrgextracted_archives=
2523862bcd1aSmrgextracted_serial=0
2524862bcd1aSmrg
2525862bcd1aSmrg# If this variable is set in any of the actions, the command in it
2526862bcd1aSmrg# will be execed at the end.  This prevents here-documents from being
2527862bcd1aSmrg# left over by shells.
2528862bcd1aSmrgexec_cmd=
2529862bcd1aSmrg
2530862bcd1aSmrg
2531862bcd1aSmrg# A function that is used when there is no print builtin or printf.
2532862bcd1aSmrgfunc_fallback_echo ()
2533862bcd1aSmrg{
2534862bcd1aSmrg  eval 'cat <<_LTECHO_EOF
2535862bcd1aSmrg$1
2536862bcd1aSmrg_LTECHO_EOF'
2537862bcd1aSmrg}
2538862bcd1aSmrg
2539862bcd1aSmrg# func_generated_by_libtool
2540862bcd1aSmrg# True iff stdin has been generated by Libtool. This function is only
2541862bcd1aSmrg# a basic sanity check; it will hardly flush out determined imposters.
2542862bcd1aSmrgfunc_generated_by_libtool_p ()
2543862bcd1aSmrg{
2544862bcd1aSmrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
2545862bcd1aSmrg}
2546862bcd1aSmrg
254788de56ccSmrg# func_lalib_p file
2548862bcd1aSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
254988de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
255088de56ccSmrg# determined imposters.
255188de56ccSmrgfunc_lalib_p ()
255288de56ccSmrg{
255388de56ccSmrg    test -f "$1" &&
2554862bcd1aSmrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
255588de56ccSmrg}
25561ab64890Smrg
255788de56ccSmrg# func_lalib_unsafe_p file
2558862bcd1aSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
255988de56ccSmrg# This function implements the same check as func_lalib_p without
256088de56ccSmrg# resorting to external programs.  To this end, it redirects stdin and
256188de56ccSmrg# closes it afterwards, without saving the original file descriptor.
256288de56ccSmrg# As a safety measure, use it only where a negative result would be
2563862bcd1aSmrg# fatal anyway.  Works if 'file' does not exist.
256488de56ccSmrgfunc_lalib_unsafe_p ()
256588de56ccSmrg{
256688de56ccSmrg    lalib_p=no
256788de56ccSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
256888de56ccSmrg	for lalib_p_l in 1 2 3 4
256988de56ccSmrg	do
257088de56ccSmrg	    read lalib_p_line
2571862bcd1aSmrg	    case $lalib_p_line in
257288de56ccSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
257388de56ccSmrg	    esac
257488de56ccSmrg	done
257588de56ccSmrg	exec 0<&5 5<&-
257688de56ccSmrg    fi
2577862bcd1aSmrg    test yes = "$lalib_p"
257888de56ccSmrg}
25791ab64890Smrg
258088de56ccSmrg# func_ltwrapper_script_p file
258188de56ccSmrg# True iff FILE is a libtool wrapper script
258288de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
258388de56ccSmrg# determined imposters.
258488de56ccSmrgfunc_ltwrapper_script_p ()
258588de56ccSmrg{
2586862bcd1aSmrg    test -f "$1" &&
2587862bcd1aSmrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
258888de56ccSmrg}
25891ab64890Smrg
259088de56ccSmrg# func_ltwrapper_executable_p file
259188de56ccSmrg# True iff FILE is a libtool wrapper executable
259288de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
259388de56ccSmrg# determined imposters.
259488de56ccSmrgfunc_ltwrapper_executable_p ()
259588de56ccSmrg{
259688de56ccSmrg    func_ltwrapper_exec_suffix=
259788de56ccSmrg    case $1 in
259888de56ccSmrg    *.exe) ;;
259988de56ccSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
260088de56ccSmrg    esac
260188de56ccSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
260288de56ccSmrg}
26032e9c7c8cSmrg
260488de56ccSmrg# func_ltwrapper_scriptname file
260588de56ccSmrg# Assumes file is an ltwrapper_executable
260688de56ccSmrg# uses $file to determine the appropriate filename for a
260788de56ccSmrg# temporary ltwrapper_script.
260888de56ccSmrgfunc_ltwrapper_scriptname ()
260988de56ccSmrg{
2610e9fcaa8aSmrg    func_dirname_and_basename "$1" "" "."
2611e9fcaa8aSmrg    func_stripname '' '.exe' "$func_basename_result"
2612862bcd1aSmrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
261388de56ccSmrg}
261488de56ccSmrg
261588de56ccSmrg# func_ltwrapper_p file
261688de56ccSmrg# True iff FILE is a libtool wrapper script or wrapper executable
261788de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
261888de56ccSmrg# determined imposters.
261988de56ccSmrgfunc_ltwrapper_p ()
262088de56ccSmrg{
262188de56ccSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
262288de56ccSmrg}
262388de56ccSmrg
262488de56ccSmrg
262588de56ccSmrg# func_execute_cmds commands fail_cmd
262688de56ccSmrg# Execute tilde-delimited COMMANDS.
262788de56ccSmrg# If FAIL_CMD is given, eval that upon failure.
262888de56ccSmrg# FAIL_CMD may read-access the current command in variable CMD!
262988de56ccSmrgfunc_execute_cmds ()
263088de56ccSmrg{
2631862bcd1aSmrg    $debug_cmd
2632862bcd1aSmrg
263388de56ccSmrg    save_ifs=$IFS; IFS='~'
263488de56ccSmrg    for cmd in $1; do
2635862bcd1aSmrg      IFS=$sp$nl
263688de56ccSmrg      eval cmd=\"$cmd\"
2637862bcd1aSmrg      IFS=$save_ifs
263888de56ccSmrg      func_show_eval "$cmd" "${2-:}"
263988de56ccSmrg    done
264088de56ccSmrg    IFS=$save_ifs
264188de56ccSmrg}
264288de56ccSmrg
264388de56ccSmrg
264488de56ccSmrg# func_source file
264588de56ccSmrg# Source FILE, adding directory component if necessary.
264688de56ccSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
264788de56ccSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
264888de56ccSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
2649862bcd1aSmrg# 'FILE.' does not work on cygwin managed mounts.
265088de56ccSmrgfunc_source ()
265188de56ccSmrg{
2652862bcd1aSmrg    $debug_cmd
2653862bcd1aSmrg
265488de56ccSmrg    case $1 in
265588de56ccSmrg    */* | *\\*)	. "$1" ;;
265688de56ccSmrg    *)		. "./$1" ;;
265788de56ccSmrg    esac
265888de56ccSmrg}
265988de56ccSmrg
266088de56ccSmrg
2661e9fcaa8aSmrg# func_resolve_sysroot PATH
2662e9fcaa8aSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
2663e9fcaa8aSmrg# func_resolve_sysroot_result
2664e9fcaa8aSmrgfunc_resolve_sysroot ()
2665e9fcaa8aSmrg{
2666e9fcaa8aSmrg  func_resolve_sysroot_result=$1
2667e9fcaa8aSmrg  case $func_resolve_sysroot_result in
2668e9fcaa8aSmrg  =*)
2669e9fcaa8aSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
2670e9fcaa8aSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2671e9fcaa8aSmrg    ;;
2672e9fcaa8aSmrg  esac
2673e9fcaa8aSmrg}
2674e9fcaa8aSmrg
2675e9fcaa8aSmrg# func_replace_sysroot PATH
2676e9fcaa8aSmrg# If PATH begins with the sysroot, replace it with = and
2677e9fcaa8aSmrg# store the result into func_replace_sysroot_result.
2678e9fcaa8aSmrgfunc_replace_sysroot ()
2679e9fcaa8aSmrg{
2680862bcd1aSmrg  case $lt_sysroot:$1 in
2681e9fcaa8aSmrg  ?*:"$lt_sysroot"*)
2682e9fcaa8aSmrg    func_stripname "$lt_sysroot" '' "$1"
2683862bcd1aSmrg    func_replace_sysroot_result='='$func_stripname_result
2684e9fcaa8aSmrg    ;;
2685e9fcaa8aSmrg  *)
2686e9fcaa8aSmrg    # Including no sysroot.
2687e9fcaa8aSmrg    func_replace_sysroot_result=$1
2688e9fcaa8aSmrg    ;;
2689e9fcaa8aSmrg  esac
2690e9fcaa8aSmrg}
2691e9fcaa8aSmrg
269288de56ccSmrg# func_infer_tag arg
269388de56ccSmrg# Infer tagged configuration to use if any are available and
269488de56ccSmrg# if one wasn't chosen via the "--tag" command line option.
269588de56ccSmrg# Only attempt this if the compiler in the base compile
269688de56ccSmrg# command doesn't match the default compiler.
269788de56ccSmrg# arg is usually of the form 'gcc ...'
269888de56ccSmrgfunc_infer_tag ()
269988de56ccSmrg{
2700862bcd1aSmrg    $debug_cmd
2701862bcd1aSmrg
270288de56ccSmrg    if test -n "$available_tags" && test -z "$tagname"; then
270388de56ccSmrg      CC_quoted=
270488de56ccSmrg      for arg in $CC; do
2705e9fcaa8aSmrg	func_append_quoted CC_quoted "$arg"
270688de56ccSmrg      done
2707e9fcaa8aSmrg      CC_expanded=`func_echo_all $CC`
2708e9fcaa8aSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
270988de56ccSmrg      case $@ in
271088de56ccSmrg      # Blanks in the command may have been stripped by the calling shell,
271188de56ccSmrg      # but not from the CC environment variable when configure was run.
2712e9fcaa8aSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2713e9fcaa8aSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
271488de56ccSmrg      # Blanks at the start of $base_compile will cause this to fail
271588de56ccSmrg      # if we don't check for them as well.
271688de56ccSmrg      *)
271788de56ccSmrg	for z in $available_tags; do
271888de56ccSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
271988de56ccSmrg	    # Evaluate the configuration.
2720862bcd1aSmrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
272188de56ccSmrg	    CC_quoted=
272288de56ccSmrg	    for arg in $CC; do
272388de56ccSmrg	      # Double-quote args containing other shell metacharacters.
2724e9fcaa8aSmrg	      func_append_quoted CC_quoted "$arg"
272588de56ccSmrg	    done
2726e9fcaa8aSmrg	    CC_expanded=`func_echo_all $CC`
2727e9fcaa8aSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
272888de56ccSmrg	    case "$@ " in
2729e9fcaa8aSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2730e9fcaa8aSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
273188de56ccSmrg	      # The compiler in the base compile command matches
273288de56ccSmrg	      # the one in the tagged configuration.
273388de56ccSmrg	      # Assume this is the tagged configuration we want.
273488de56ccSmrg	      tagname=$z
273588de56ccSmrg	      break
273688de56ccSmrg	      ;;
273788de56ccSmrg	    esac
273888de56ccSmrg	  fi
273988de56ccSmrg	done
274088de56ccSmrg	# If $tagname still isn't set, then no tagged configuration
274188de56ccSmrg	# was found and let the user know that the "--tag" command
274288de56ccSmrg	# line option must be used.
274388de56ccSmrg	if test -z "$tagname"; then
274488de56ccSmrg	  func_echo "unable to infer tagged configuration"
2745862bcd1aSmrg	  func_fatal_error "specify a tag with '--tag'"
274688de56ccSmrg#	else
274788de56ccSmrg#	  func_verbose "using $tagname tagged configuration"
274888de56ccSmrg	fi
274988de56ccSmrg	;;
275088de56ccSmrg      esac
275188de56ccSmrg    fi
275288de56ccSmrg}
275388de56ccSmrg
275488de56ccSmrg
275588de56ccSmrg
275688de56ccSmrg# func_write_libtool_object output_name pic_name nonpic_name
275788de56ccSmrg# Create a libtool object file (analogous to a ".la" file),
275888de56ccSmrg# but don't create it if we're doing a dry run.
275988de56ccSmrgfunc_write_libtool_object ()
276088de56ccSmrg{
2761862bcd1aSmrg    write_libobj=$1
2762862bcd1aSmrg    if test yes = "$build_libtool_libs"; then
2763862bcd1aSmrg      write_lobj=\'$2\'
276488de56ccSmrg    else
276588de56ccSmrg      write_lobj=none
276688de56ccSmrg    fi
276788de56ccSmrg
2768862bcd1aSmrg    if test yes = "$build_old_libs"; then
2769862bcd1aSmrg      write_oldobj=\'$3\'
277088de56ccSmrg    else
277188de56ccSmrg      write_oldobj=none
277288de56ccSmrg    fi
277388de56ccSmrg
277488de56ccSmrg    $opt_dry_run || {
277588de56ccSmrg      cat >${write_libobj}T <<EOF
277688de56ccSmrg# $write_libobj - a libtool object file
2777862bcd1aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
277888de56ccSmrg#
277988de56ccSmrg# Please DO NOT delete this file!
278088de56ccSmrg# It is necessary for linking the library.
278188de56ccSmrg
278288de56ccSmrg# Name of the PIC object.
278388de56ccSmrgpic_object=$write_lobj
278488de56ccSmrg
278588de56ccSmrg# Name of the non-PIC object
278688de56ccSmrgnon_pic_object=$write_oldobj
278788de56ccSmrg
278888de56ccSmrgEOF
2789862bcd1aSmrg      $MV "${write_libobj}T" "$write_libobj"
279088de56ccSmrg    }
279188de56ccSmrg}
279288de56ccSmrg
2793e9fcaa8aSmrg
2794e9fcaa8aSmrg##################################################
2795e9fcaa8aSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2796e9fcaa8aSmrg##################################################
2797e9fcaa8aSmrg
2798e9fcaa8aSmrg# func_convert_core_file_wine_to_w32 ARG
2799e9fcaa8aSmrg# Helper function used by file name conversion functions when $build is *nix,
2800e9fcaa8aSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
2801e9fcaa8aSmrg# correctly configured wine environment available, with the winepath program
2802e9fcaa8aSmrg# in $build's $PATH.
2803e9fcaa8aSmrg#
2804e9fcaa8aSmrg# ARG is the $build file name to be converted to w32 format.
2805e9fcaa8aSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
2806e9fcaa8aSmrg# be empty on error (or when ARG is empty)
2807e9fcaa8aSmrgfunc_convert_core_file_wine_to_w32 ()
2808e9fcaa8aSmrg{
2809862bcd1aSmrg  $debug_cmd
2810862bcd1aSmrg
2811862bcd1aSmrg  func_convert_core_file_wine_to_w32_result=$1
2812e9fcaa8aSmrg  if test -n "$1"; then
2813e9fcaa8aSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
2814e9fcaa8aSmrg    # are forced to check the contents of stdout. On the other hand, if the
2815e9fcaa8aSmrg    # command is not found, the shell will set an exit code of 127 and print
2816e9fcaa8aSmrg    # *an error message* to stdout. So we must check for both error code of
2817e9fcaa8aSmrg    # zero AND non-empty stdout, which explains the odd construction:
2818e9fcaa8aSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
2819862bcd1aSmrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2820e9fcaa8aSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
2821862bcd1aSmrg        $SED -e "$sed_naive_backslashify"`
2822e9fcaa8aSmrg    else
2823e9fcaa8aSmrg      func_convert_core_file_wine_to_w32_result=
2824e9fcaa8aSmrg    fi
2825e9fcaa8aSmrg  fi
2826e9fcaa8aSmrg}
2827e9fcaa8aSmrg# end: func_convert_core_file_wine_to_w32
2828e9fcaa8aSmrg
2829e9fcaa8aSmrg
2830e9fcaa8aSmrg# func_convert_core_path_wine_to_w32 ARG
2831e9fcaa8aSmrg# Helper function used by path conversion functions when $build is *nix, and
2832e9fcaa8aSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2833e9fcaa8aSmrg# configured wine environment available, with the winepath program in $build's
2834e9fcaa8aSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
2835e9fcaa8aSmrg#
2836e9fcaa8aSmrg# ARG is path to be converted from $build format to win32.
2837e9fcaa8aSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
2838e9fcaa8aSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
2839e9fcaa8aSmrg# are convertible, then the result may be empty.
2840e9fcaa8aSmrgfunc_convert_core_path_wine_to_w32 ()
2841e9fcaa8aSmrg{
2842862bcd1aSmrg  $debug_cmd
2843862bcd1aSmrg
2844e9fcaa8aSmrg  # unfortunately, winepath doesn't convert paths, only file names
2845862bcd1aSmrg  func_convert_core_path_wine_to_w32_result=
2846e9fcaa8aSmrg  if test -n "$1"; then
2847e9fcaa8aSmrg    oldIFS=$IFS
2848e9fcaa8aSmrg    IFS=:
2849e9fcaa8aSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
2850e9fcaa8aSmrg      IFS=$oldIFS
2851e9fcaa8aSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
2852862bcd1aSmrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
2853e9fcaa8aSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
2854862bcd1aSmrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2855e9fcaa8aSmrg        else
2856e9fcaa8aSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2857e9fcaa8aSmrg        fi
2858e9fcaa8aSmrg      fi
2859e9fcaa8aSmrg    done
2860e9fcaa8aSmrg    IFS=$oldIFS
2861e9fcaa8aSmrg  fi
2862e9fcaa8aSmrg}
2863e9fcaa8aSmrg# end: func_convert_core_path_wine_to_w32
2864e9fcaa8aSmrg
2865e9fcaa8aSmrg
2866e9fcaa8aSmrg# func_cygpath ARGS...
2867e9fcaa8aSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2868e9fcaa8aSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2869e9fcaa8aSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2870e9fcaa8aSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
2871e9fcaa8aSmrg# file name or path is assumed to be in w32 format, as previously converted
2872e9fcaa8aSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
2873e9fcaa8aSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
2874e9fcaa8aSmrg# Cygwin format). Returns an empty string on error.
2875e9fcaa8aSmrg#
2876e9fcaa8aSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
2877e9fcaa8aSmrg# be converted.
2878e9fcaa8aSmrg#
2879e9fcaa8aSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2880e9fcaa8aSmrg# environment variable; do not put it in $PATH.
2881e9fcaa8aSmrgfunc_cygpath ()
2882e9fcaa8aSmrg{
2883862bcd1aSmrg  $debug_cmd
2884862bcd1aSmrg
2885e9fcaa8aSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2886e9fcaa8aSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2887e9fcaa8aSmrg    if test "$?" -ne 0; then
2888e9fcaa8aSmrg      # on failure, ensure result is empty
2889e9fcaa8aSmrg      func_cygpath_result=
2890e9fcaa8aSmrg    fi
2891e9fcaa8aSmrg  else
2892e9fcaa8aSmrg    func_cygpath_result=
2893862bcd1aSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2894e9fcaa8aSmrg  fi
2895e9fcaa8aSmrg}
2896e9fcaa8aSmrg#end: func_cygpath
2897e9fcaa8aSmrg
2898e9fcaa8aSmrg
2899e9fcaa8aSmrg# func_convert_core_msys_to_w32 ARG
2900e9fcaa8aSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
2901e9fcaa8aSmrg# result in func_convert_core_msys_to_w32_result.
2902e9fcaa8aSmrgfunc_convert_core_msys_to_w32 ()
2903e9fcaa8aSmrg{
2904862bcd1aSmrg  $debug_cmd
2905862bcd1aSmrg
2906e9fcaa8aSmrg  # awkward: cmd appends spaces to result
2907e9fcaa8aSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
2908862bcd1aSmrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2909e9fcaa8aSmrg}
2910e9fcaa8aSmrg#end: func_convert_core_msys_to_w32
2911e9fcaa8aSmrg
2912e9fcaa8aSmrg
2913e9fcaa8aSmrg# func_convert_file_check ARG1 ARG2
2914e9fcaa8aSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
2915e9fcaa8aSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
2916e9fcaa8aSmrg# func_to_host_file_result to ARG1).
2917e9fcaa8aSmrgfunc_convert_file_check ()
2918e9fcaa8aSmrg{
2919862bcd1aSmrg  $debug_cmd
2920862bcd1aSmrg
2921862bcd1aSmrg  if test -z "$2" && test -n "$1"; then
2922e9fcaa8aSmrg    func_error "Could not determine host file name corresponding to"
2923862bcd1aSmrg    func_error "  '$1'"
2924e9fcaa8aSmrg    func_error "Continuing, but uninstalled executables may not work."
2925e9fcaa8aSmrg    # Fallback:
2926862bcd1aSmrg    func_to_host_file_result=$1
2927e9fcaa8aSmrg  fi
2928e9fcaa8aSmrg}
2929e9fcaa8aSmrg# end func_convert_file_check
2930e9fcaa8aSmrg
2931e9fcaa8aSmrg
2932e9fcaa8aSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2933e9fcaa8aSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
2934e9fcaa8aSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2935e9fcaa8aSmrg# func_to_host_file_result to a simplistic fallback value (see below).
2936e9fcaa8aSmrgfunc_convert_path_check ()
2937e9fcaa8aSmrg{
2938862bcd1aSmrg  $debug_cmd
2939862bcd1aSmrg
2940e9fcaa8aSmrg  if test -z "$4" && test -n "$3"; then
2941e9fcaa8aSmrg    func_error "Could not determine the host path corresponding to"
2942862bcd1aSmrg    func_error "  '$3'"
2943e9fcaa8aSmrg    func_error "Continuing, but uninstalled executables may not work."
2944e9fcaa8aSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
2945e9fcaa8aSmrg    # should not be "improved".  See libtool.info.
2946e9fcaa8aSmrg    if test "x$1" != "x$2"; then
2947e9fcaa8aSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
2948e9fcaa8aSmrg      func_to_host_path_result=`echo "$3" |
2949e9fcaa8aSmrg        $SED -e "$lt_replace_pathsep_chars"`
2950e9fcaa8aSmrg    else
2951862bcd1aSmrg      func_to_host_path_result=$3
2952e9fcaa8aSmrg    fi
2953e9fcaa8aSmrg  fi
2954e9fcaa8aSmrg}
2955e9fcaa8aSmrg# end func_convert_path_check
2956e9fcaa8aSmrg
2957e9fcaa8aSmrg
2958e9fcaa8aSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2959e9fcaa8aSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2960e9fcaa8aSmrg# and appending REPL if ORIG matches BACKPAT.
2961e9fcaa8aSmrgfunc_convert_path_front_back_pathsep ()
2962e9fcaa8aSmrg{
2963862bcd1aSmrg  $debug_cmd
2964862bcd1aSmrg
2965e9fcaa8aSmrg  case $4 in
2966862bcd1aSmrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
2967e9fcaa8aSmrg    ;;
2968e9fcaa8aSmrg  esac
2969e9fcaa8aSmrg  case $4 in
2970e9fcaa8aSmrg  $2 ) func_append func_to_host_path_result "$3"
2971e9fcaa8aSmrg    ;;
2972e9fcaa8aSmrg  esac
2973e9fcaa8aSmrg}
2974e9fcaa8aSmrg# end func_convert_path_front_back_pathsep
2975e9fcaa8aSmrg
2976e9fcaa8aSmrg
2977e9fcaa8aSmrg##################################################
2978e9fcaa8aSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
2979e9fcaa8aSmrg##################################################
2980862bcd1aSmrg# invoked via '$to_host_file_cmd ARG'
2981e9fcaa8aSmrg#
2982e9fcaa8aSmrg# In each case, ARG is the path to be converted from $build to $host format.
2983e9fcaa8aSmrg# Result will be available in $func_to_host_file_result.
2984e9fcaa8aSmrg
2985e9fcaa8aSmrg
2986e9fcaa8aSmrg# func_to_host_file ARG
2987e9fcaa8aSmrg# Converts the file name ARG from $build format to $host format. Return result
2988e9fcaa8aSmrg# in func_to_host_file_result.
2989e9fcaa8aSmrgfunc_to_host_file ()
2990e9fcaa8aSmrg{
2991862bcd1aSmrg  $debug_cmd
2992862bcd1aSmrg
2993e9fcaa8aSmrg  $to_host_file_cmd "$1"
2994e9fcaa8aSmrg}
2995e9fcaa8aSmrg# end func_to_host_file
2996e9fcaa8aSmrg
2997e9fcaa8aSmrg
2998e9fcaa8aSmrg# func_to_tool_file ARG LAZY
2999e9fcaa8aSmrg# converts the file name ARG from $build format to toolchain format. Return
3000e9fcaa8aSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
3001e9fcaa8aSmrg# in (the comma separated) LAZY, no conversion takes place.
3002e9fcaa8aSmrgfunc_to_tool_file ()
3003e9fcaa8aSmrg{
3004862bcd1aSmrg  $debug_cmd
3005862bcd1aSmrg
3006e9fcaa8aSmrg  case ,$2, in
3007e9fcaa8aSmrg    *,"$to_tool_file_cmd",*)
3008e9fcaa8aSmrg      func_to_tool_file_result=$1
3009e9fcaa8aSmrg      ;;
3010e9fcaa8aSmrg    *)
3011e9fcaa8aSmrg      $to_tool_file_cmd "$1"
3012e9fcaa8aSmrg      func_to_tool_file_result=$func_to_host_file_result
3013e9fcaa8aSmrg      ;;
3014e9fcaa8aSmrg  esac
3015e9fcaa8aSmrg}
3016e9fcaa8aSmrg# end func_to_tool_file
3017e9fcaa8aSmrg
3018e9fcaa8aSmrg
3019e9fcaa8aSmrg# func_convert_file_noop ARG
3020e9fcaa8aSmrg# Copy ARG to func_to_host_file_result.
3021e9fcaa8aSmrgfunc_convert_file_noop ()
3022e9fcaa8aSmrg{
3023862bcd1aSmrg  func_to_host_file_result=$1
3024e9fcaa8aSmrg}
3025e9fcaa8aSmrg# end func_convert_file_noop
3026e9fcaa8aSmrg
3027e9fcaa8aSmrg
3028e9fcaa8aSmrg# func_convert_file_msys_to_w32 ARG
3029e9fcaa8aSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
3030e9fcaa8aSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3031e9fcaa8aSmrg# func_to_host_file_result.
3032e9fcaa8aSmrgfunc_convert_file_msys_to_w32 ()
3033e9fcaa8aSmrg{
3034862bcd1aSmrg  $debug_cmd
3035862bcd1aSmrg
3036862bcd1aSmrg  func_to_host_file_result=$1
3037e9fcaa8aSmrg  if test -n "$1"; then
3038e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$1"
3039862bcd1aSmrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
3040e9fcaa8aSmrg  fi
3041e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3042e9fcaa8aSmrg}
3043e9fcaa8aSmrg# end func_convert_file_msys_to_w32
3044e9fcaa8aSmrg
3045e9fcaa8aSmrg
3046e9fcaa8aSmrg# func_convert_file_cygwin_to_w32 ARG
3047e9fcaa8aSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
3048e9fcaa8aSmrg# func_to_host_file_result.
3049e9fcaa8aSmrgfunc_convert_file_cygwin_to_w32 ()
3050e9fcaa8aSmrg{
3051862bcd1aSmrg  $debug_cmd
3052862bcd1aSmrg
3053862bcd1aSmrg  func_to_host_file_result=$1
3054e9fcaa8aSmrg  if test -n "$1"; then
3055e9fcaa8aSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3056e9fcaa8aSmrg    # LT_CYGPATH in this case.
3057e9fcaa8aSmrg    func_to_host_file_result=`cygpath -m "$1"`
3058e9fcaa8aSmrg  fi
3059e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3060e9fcaa8aSmrg}
3061e9fcaa8aSmrg# end func_convert_file_cygwin_to_w32
3062e9fcaa8aSmrg
3063e9fcaa8aSmrg
3064e9fcaa8aSmrg# func_convert_file_nix_to_w32 ARG
3065e9fcaa8aSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
3066e9fcaa8aSmrg# and a working winepath. Returns result in func_to_host_file_result.
3067e9fcaa8aSmrgfunc_convert_file_nix_to_w32 ()
3068e9fcaa8aSmrg{
3069862bcd1aSmrg  $debug_cmd
3070862bcd1aSmrg
3071862bcd1aSmrg  func_to_host_file_result=$1
3072e9fcaa8aSmrg  if test -n "$1"; then
3073e9fcaa8aSmrg    func_convert_core_file_wine_to_w32 "$1"
3074862bcd1aSmrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3075e9fcaa8aSmrg  fi
3076e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3077e9fcaa8aSmrg}
3078e9fcaa8aSmrg# end func_convert_file_nix_to_w32
3079e9fcaa8aSmrg
3080e9fcaa8aSmrg
3081e9fcaa8aSmrg# func_convert_file_msys_to_cygwin ARG
3082e9fcaa8aSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3083e9fcaa8aSmrg# Returns result in func_to_host_file_result.
3084e9fcaa8aSmrgfunc_convert_file_msys_to_cygwin ()
3085e9fcaa8aSmrg{
3086862bcd1aSmrg  $debug_cmd
3087862bcd1aSmrg
3088862bcd1aSmrg  func_to_host_file_result=$1
3089e9fcaa8aSmrg  if test -n "$1"; then
3090e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$1"
3091e9fcaa8aSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
3092862bcd1aSmrg    func_to_host_file_result=$func_cygpath_result
3093e9fcaa8aSmrg  fi
3094e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3095e9fcaa8aSmrg}
3096e9fcaa8aSmrg# end func_convert_file_msys_to_cygwin
3097e9fcaa8aSmrg
3098e9fcaa8aSmrg
3099e9fcaa8aSmrg# func_convert_file_nix_to_cygwin ARG
3100e9fcaa8aSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
3101e9fcaa8aSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
3102e9fcaa8aSmrg# in func_to_host_file_result.
3103e9fcaa8aSmrgfunc_convert_file_nix_to_cygwin ()
3104e9fcaa8aSmrg{
3105862bcd1aSmrg  $debug_cmd
3106862bcd1aSmrg
3107862bcd1aSmrg  func_to_host_file_result=$1
3108e9fcaa8aSmrg  if test -n "$1"; then
3109e9fcaa8aSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3110e9fcaa8aSmrg    func_convert_core_file_wine_to_w32 "$1"
3111e9fcaa8aSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
3112862bcd1aSmrg    func_to_host_file_result=$func_cygpath_result
3113e9fcaa8aSmrg  fi
3114e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3115e9fcaa8aSmrg}
3116e9fcaa8aSmrg# end func_convert_file_nix_to_cygwin
3117e9fcaa8aSmrg
3118e9fcaa8aSmrg
3119e9fcaa8aSmrg#############################################
3120e9fcaa8aSmrg# $build to $host PATH CONVERSION FUNCTIONS #
3121e9fcaa8aSmrg#############################################
3122862bcd1aSmrg# invoked via '$to_host_path_cmd ARG'
3123e9fcaa8aSmrg#
3124e9fcaa8aSmrg# In each case, ARG is the path to be converted from $build to $host format.
3125e9fcaa8aSmrg# The result will be available in $func_to_host_path_result.
3126e9fcaa8aSmrg#
3127e9fcaa8aSmrg# Path separators are also converted from $build format to $host format.  If
3128e9fcaa8aSmrg# ARG begins or ends with a path separator character, it is preserved (but
3129e9fcaa8aSmrg# converted to $host format) on output.
3130e9fcaa8aSmrg#
3131e9fcaa8aSmrg# All path conversion functions are named using the following convention:
3132e9fcaa8aSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
3133e9fcaa8aSmrg#   path conversion function         : func_convert_path_X_to_Y ()
3134e9fcaa8aSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
3135e9fcaa8aSmrg# same.  If conversion functions are added for new $build/$host combinations,
3136e9fcaa8aSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
3137e9fcaa8aSmrg# will break.
3138e9fcaa8aSmrg
3139e9fcaa8aSmrg
3140e9fcaa8aSmrg# func_init_to_host_path_cmd
3141e9fcaa8aSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
3142e9fcaa8aSmrg# appropriate value, based on the value of $to_host_file_cmd.
3143e9fcaa8aSmrgto_host_path_cmd=
3144e9fcaa8aSmrgfunc_init_to_host_path_cmd ()
3145e9fcaa8aSmrg{
3146862bcd1aSmrg  $debug_cmd
3147862bcd1aSmrg
3148e9fcaa8aSmrg  if test -z "$to_host_path_cmd"; then
3149e9fcaa8aSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
3150862bcd1aSmrg    to_host_path_cmd=func_convert_path_$func_stripname_result
3151e9fcaa8aSmrg  fi
3152e9fcaa8aSmrg}
3153e9fcaa8aSmrg
3154e9fcaa8aSmrg
3155e9fcaa8aSmrg# func_to_host_path ARG
3156e9fcaa8aSmrg# Converts the path ARG from $build format to $host format. Return result
3157e9fcaa8aSmrg# in func_to_host_path_result.
3158e9fcaa8aSmrgfunc_to_host_path ()
3159e9fcaa8aSmrg{
3160862bcd1aSmrg  $debug_cmd
3161862bcd1aSmrg
3162e9fcaa8aSmrg  func_init_to_host_path_cmd
3163e9fcaa8aSmrg  $to_host_path_cmd "$1"
3164e9fcaa8aSmrg}
3165e9fcaa8aSmrg# end func_to_host_path
3166e9fcaa8aSmrg
3167e9fcaa8aSmrg
3168e9fcaa8aSmrg# func_convert_path_noop ARG
3169e9fcaa8aSmrg# Copy ARG to func_to_host_path_result.
3170e9fcaa8aSmrgfunc_convert_path_noop ()
3171e9fcaa8aSmrg{
3172862bcd1aSmrg  func_to_host_path_result=$1
3173e9fcaa8aSmrg}
3174e9fcaa8aSmrg# end func_convert_path_noop
3175e9fcaa8aSmrg
3176e9fcaa8aSmrg
3177e9fcaa8aSmrg# func_convert_path_msys_to_w32 ARG
3178e9fcaa8aSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3179e9fcaa8aSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3180e9fcaa8aSmrg# func_to_host_path_result.
3181e9fcaa8aSmrgfunc_convert_path_msys_to_w32 ()
3182e9fcaa8aSmrg{
3183862bcd1aSmrg  $debug_cmd
3184862bcd1aSmrg
3185862bcd1aSmrg  func_to_host_path_result=$1
3186e9fcaa8aSmrg  if test -n "$1"; then
3187e9fcaa8aSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
3188e9fcaa8aSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3189e9fcaa8aSmrg    # and winepath ignores them completely.
3190e9fcaa8aSmrg    func_stripname : : "$1"
3191e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
3192e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3193862bcd1aSmrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
3194e9fcaa8aSmrg    func_convert_path_check : ";" \
3195e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3196e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3197e9fcaa8aSmrg  fi
3198e9fcaa8aSmrg}
3199e9fcaa8aSmrg# end func_convert_path_msys_to_w32
3200e9fcaa8aSmrg
3201e9fcaa8aSmrg
3202e9fcaa8aSmrg# func_convert_path_cygwin_to_w32 ARG
3203e9fcaa8aSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
3204e9fcaa8aSmrg# func_to_host_file_result.
3205e9fcaa8aSmrgfunc_convert_path_cygwin_to_w32 ()
3206e9fcaa8aSmrg{
3207862bcd1aSmrg  $debug_cmd
3208862bcd1aSmrg
3209862bcd1aSmrg  func_to_host_path_result=$1
3210e9fcaa8aSmrg  if test -n "$1"; then
3211e9fcaa8aSmrg    # See func_convert_path_msys_to_w32:
3212e9fcaa8aSmrg    func_stripname : : "$1"
3213e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
3214e9fcaa8aSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3215e9fcaa8aSmrg    func_convert_path_check : ";" \
3216e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3217e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3218e9fcaa8aSmrg  fi
3219e9fcaa8aSmrg}
3220e9fcaa8aSmrg# end func_convert_path_cygwin_to_w32
3221e9fcaa8aSmrg
3222e9fcaa8aSmrg
3223e9fcaa8aSmrg# func_convert_path_nix_to_w32 ARG
3224e9fcaa8aSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
3225e9fcaa8aSmrg# a working winepath.  Returns result in func_to_host_file_result.
3226e9fcaa8aSmrgfunc_convert_path_nix_to_w32 ()
3227e9fcaa8aSmrg{
3228862bcd1aSmrg  $debug_cmd
3229862bcd1aSmrg
3230862bcd1aSmrg  func_to_host_path_result=$1
3231e9fcaa8aSmrg  if test -n "$1"; then
3232e9fcaa8aSmrg    # See func_convert_path_msys_to_w32:
3233e9fcaa8aSmrg    func_stripname : : "$1"
3234e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
3235e9fcaa8aSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3236862bcd1aSmrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3237e9fcaa8aSmrg    func_convert_path_check : ";" \
3238e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3239e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3240e9fcaa8aSmrg  fi
3241e9fcaa8aSmrg}
3242e9fcaa8aSmrg# end func_convert_path_nix_to_w32
3243e9fcaa8aSmrg
3244e9fcaa8aSmrg
3245e9fcaa8aSmrg# func_convert_path_msys_to_cygwin ARG
3246e9fcaa8aSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3247e9fcaa8aSmrg# Returns result in func_to_host_file_result.
3248e9fcaa8aSmrgfunc_convert_path_msys_to_cygwin ()
3249e9fcaa8aSmrg{
3250862bcd1aSmrg  $debug_cmd
3251862bcd1aSmrg
3252862bcd1aSmrg  func_to_host_path_result=$1
3253e9fcaa8aSmrg  if test -n "$1"; then
3254e9fcaa8aSmrg    # See func_convert_path_msys_to_w32:
3255e9fcaa8aSmrg    func_stripname : : "$1"
3256e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
3257e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3258e9fcaa8aSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
3259862bcd1aSmrg    func_to_host_path_result=$func_cygpath_result
3260e9fcaa8aSmrg    func_convert_path_check : : \
3261e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3262e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3263e9fcaa8aSmrg  fi
3264e9fcaa8aSmrg}
3265e9fcaa8aSmrg# end func_convert_path_msys_to_cygwin
3266e9fcaa8aSmrg
3267e9fcaa8aSmrg
3268e9fcaa8aSmrg# func_convert_path_nix_to_cygwin ARG
3269e9fcaa8aSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
3270e9fcaa8aSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
3271e9fcaa8aSmrg# func_to_host_file_result.
3272e9fcaa8aSmrgfunc_convert_path_nix_to_cygwin ()
3273e9fcaa8aSmrg{
3274862bcd1aSmrg  $debug_cmd
3275862bcd1aSmrg
3276862bcd1aSmrg  func_to_host_path_result=$1
3277e9fcaa8aSmrg  if test -n "$1"; then
3278e9fcaa8aSmrg    # Remove leading and trailing path separator characters from
3279e9fcaa8aSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
3280e9fcaa8aSmrg    # into '.;' and ';.', and winepath ignores them completely.
3281e9fcaa8aSmrg    func_stripname : : "$1"
3282e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
3283e9fcaa8aSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3284e9fcaa8aSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
3285862bcd1aSmrg    func_to_host_path_result=$func_cygpath_result
3286e9fcaa8aSmrg    func_convert_path_check : : \
3287e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3288e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3289e9fcaa8aSmrg  fi
3290e9fcaa8aSmrg}
3291e9fcaa8aSmrg# end func_convert_path_nix_to_cygwin
3292e9fcaa8aSmrg
3293e9fcaa8aSmrg
3294862bcd1aSmrg# func_dll_def_p FILE
3295862bcd1aSmrg# True iff FILE is a Windows DLL '.def' file.
3296862bcd1aSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
3297862bcd1aSmrgfunc_dll_def_p ()
3298862bcd1aSmrg{
3299862bcd1aSmrg  $debug_cmd
3300862bcd1aSmrg
3301862bcd1aSmrg  func_dll_def_p_tmp=`$SED -n \
3302862bcd1aSmrg    -e 's/^[	 ]*//' \
3303862bcd1aSmrg    -e '/^\(;.*\)*$/d' \
3304862bcd1aSmrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
3305862bcd1aSmrg    -e q \
3306862bcd1aSmrg    "$1"`
3307862bcd1aSmrg  test DEF = "$func_dll_def_p_tmp"
3308862bcd1aSmrg}
3309862bcd1aSmrg
3310862bcd1aSmrg
331188de56ccSmrg# func_mode_compile arg...
331288de56ccSmrgfunc_mode_compile ()
331388de56ccSmrg{
3314862bcd1aSmrg    $debug_cmd
3315862bcd1aSmrg
331688de56ccSmrg    # Get the compilation command and the source file.
331788de56ccSmrg    base_compile=
3318862bcd1aSmrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
331988de56ccSmrg    suppress_opt=yes
332088de56ccSmrg    suppress_output=
332188de56ccSmrg    arg_mode=normal
332288de56ccSmrg    libobj=
332388de56ccSmrg    later=
332488de56ccSmrg    pie_flag=
332588de56ccSmrg
332688de56ccSmrg    for arg
332788de56ccSmrg    do
332888de56ccSmrg      case $arg_mode in
332988de56ccSmrg      arg  )
333088de56ccSmrg	# do not "continue".  Instead, add this to base_compile
3331862bcd1aSmrg	lastarg=$arg
333288de56ccSmrg	arg_mode=normal
333388de56ccSmrg	;;
333488de56ccSmrg
333588de56ccSmrg      target )
3336862bcd1aSmrg	libobj=$arg
333788de56ccSmrg	arg_mode=normal
333888de56ccSmrg	continue
333988de56ccSmrg	;;
334088de56ccSmrg
334188de56ccSmrg      normal )
334288de56ccSmrg	# Accept any command-line options.
334388de56ccSmrg	case $arg in
334488de56ccSmrg	-o)
334588de56ccSmrg	  test -n "$libobj" && \
3346862bcd1aSmrg	    func_fatal_error "you cannot specify '-o' more than once"
334788de56ccSmrg	  arg_mode=target
334888de56ccSmrg	  continue
334988de56ccSmrg	  ;;
335088de56ccSmrg
335188de56ccSmrg	-pie | -fpie | -fPIE)
3352e9fcaa8aSmrg          func_append pie_flag " $arg"
335388de56ccSmrg	  continue
335488de56ccSmrg	  ;;
335588de56ccSmrg
335688de56ccSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
3357e9fcaa8aSmrg	  func_append later " $arg"
335888de56ccSmrg	  continue
335988de56ccSmrg	  ;;
336088de56ccSmrg
336188de56ccSmrg	-no-suppress)
33621ab64890Smrg	  suppress_opt=no
33631ab64890Smrg	  continue
33641ab64890Smrg	  ;;
33651ab64890Smrg
33661ab64890Smrg	-Xcompiler)
33671ab64890Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
33681ab64890Smrg	  continue      #  The current "srcfile" will either be retained or
33691ab64890Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
33701ab64890Smrg
33711ab64890Smrg	-Wc,*)
337288de56ccSmrg	  func_stripname '-Wc,' '' "$arg"
337388de56ccSmrg	  args=$func_stripname_result
33741ab64890Smrg	  lastarg=
3375862bcd1aSmrg	  save_ifs=$IFS; IFS=,
337688de56ccSmrg	  for arg in $args; do
3377862bcd1aSmrg	    IFS=$save_ifs
3378e9fcaa8aSmrg	    func_append_quoted lastarg "$arg"
33791ab64890Smrg	  done
3380862bcd1aSmrg	  IFS=$save_ifs
338188de56ccSmrg	  func_stripname ' ' '' "$lastarg"
338288de56ccSmrg	  lastarg=$func_stripname_result
33831ab64890Smrg
33841ab64890Smrg	  # Add the arguments to base_compile.
3385e9fcaa8aSmrg	  func_append base_compile " $lastarg"
33861ab64890Smrg	  continue
33871ab64890Smrg	  ;;
33881ab64890Smrg
338988de56ccSmrg	*)
33901ab64890Smrg	  # Accept the current argument as the source file.
33911ab64890Smrg	  # The previous "srcfile" becomes the current argument.
33921ab64890Smrg	  #
3393862bcd1aSmrg	  lastarg=$srcfile
3394862bcd1aSmrg	  srcfile=$arg
33951ab64890Smrg	  ;;
33961ab64890Smrg	esac  #  case $arg
33971ab64890Smrg	;;
33981ab64890Smrg      esac    #  case $arg_mode
33991ab64890Smrg
34001ab64890Smrg      # Aesthetically quote the previous argument.
3401e9fcaa8aSmrg      func_append_quoted base_compile "$lastarg"
34021ab64890Smrg    done # for arg
34031ab64890Smrg
34041ab64890Smrg    case $arg_mode in
34051ab64890Smrg    arg)
340688de56ccSmrg      func_fatal_error "you must specify an argument for -Xcompile"
34071ab64890Smrg      ;;
34081ab64890Smrg    target)
3409862bcd1aSmrg      func_fatal_error "you must specify a target with '-o'"
34101ab64890Smrg      ;;
34111ab64890Smrg    *)
34121ab64890Smrg      # Get the name of the library object.
341388de56ccSmrg      test -z "$libobj" && {
341488de56ccSmrg	func_basename "$srcfile"
3415862bcd1aSmrg	libobj=$func_basename_result
341688de56ccSmrg      }
34171ab64890Smrg      ;;
34181ab64890Smrg    esac
34191ab64890Smrg
34201ab64890Smrg    # Recognize several different file suffixes.
34211ab64890Smrg    # If the user specifies -o file.o, it is replaced with file.lo
34221ab64890Smrg    case $libobj in
342388de56ccSmrg    *.[cCFSifmso] | \
342488de56ccSmrg    *.ada | *.adb | *.ads | *.asm | \
342588de56ccSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3426eb411b4bSmrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
342788de56ccSmrg      func_xform "$libobj"
342888de56ccSmrg      libobj=$func_xform_result
342988de56ccSmrg      ;;
34301ab64890Smrg    esac
34311ab64890Smrg
34321ab64890Smrg    case $libobj in
343388de56ccSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
34341ab64890Smrg    *)
3435862bcd1aSmrg      func_fatal_error "cannot determine name of library object from '$libobj'"
34361ab64890Smrg      ;;
34371ab64890Smrg    esac
34381ab64890Smrg
34391ab64890Smrg    func_infer_tag $base_compile
34401ab64890Smrg
34411ab64890Smrg    for arg in $later; do
34421ab64890Smrg      case $arg in
344388de56ccSmrg      -shared)
3444862bcd1aSmrg	test yes = "$build_libtool_libs" \
3445862bcd1aSmrg	  || func_fatal_configuration "cannot build a shared library"
344688de56ccSmrg	build_old_libs=no
344788de56ccSmrg	continue
344888de56ccSmrg	;;
344988de56ccSmrg
34501ab64890Smrg      -static)
345188de56ccSmrg	build_libtool_libs=no
34521ab64890Smrg	build_old_libs=yes
34531ab64890Smrg	continue
34541ab64890Smrg	;;
34551ab64890Smrg
34561ab64890Smrg      -prefer-pic)
34571ab64890Smrg	pic_mode=yes
34581ab64890Smrg	continue
34591ab64890Smrg	;;
34601ab64890Smrg
34611ab64890Smrg      -prefer-non-pic)
34621ab64890Smrg	pic_mode=no
34631ab64890Smrg	continue
34641ab64890Smrg	;;
34651ab64890Smrg      esac
34661ab64890Smrg    done
34671ab64890Smrg
346888de56ccSmrg    func_quote_for_eval "$libobj"
346988de56ccSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
347088de56ccSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
3471862bcd1aSmrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
347288de56ccSmrg    func_dirname_and_basename "$obj" "/" ""
3473862bcd1aSmrg    objname=$func_basename_result
3474862bcd1aSmrg    xdir=$func_dirname_result
3475862bcd1aSmrg    lobj=$xdir$objdir/$objname
34761ab64890Smrg
347788de56ccSmrg    test -z "$base_compile" && \
347888de56ccSmrg      func_fatal_help "you must specify a compilation command"
34791ab64890Smrg
34801ab64890Smrg    # Delete any leftover library objects.
3481862bcd1aSmrg    if test yes = "$build_old_libs"; then
34821ab64890Smrg      removelist="$obj $lobj $libobj ${libobj}T"
34831ab64890Smrg    else
34841ab64890Smrg      removelist="$lobj $libobj ${libobj}T"
34851ab64890Smrg    fi
34861ab64890Smrg
34871ab64890Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
34881ab64890Smrg    case $host_os in
348988de56ccSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
34901ab64890Smrg      pic_mode=default
34911ab64890Smrg      ;;
34921ab64890Smrg    esac
3493862bcd1aSmrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
34941ab64890Smrg      # non-PIC code in shared libraries is not supported
34951ab64890Smrg      pic_mode=default
34961ab64890Smrg    fi
34971ab64890Smrg
34981ab64890Smrg    # Calculate the filename of the output object if compiler does
34991ab64890Smrg    # not support -o with -c
3500862bcd1aSmrg    if test no = "$compiler_c_o"; then
3501862bcd1aSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
3502862bcd1aSmrg      lockfile=$output_obj.lock
35031ab64890Smrg    else
35041ab64890Smrg      output_obj=
35051ab64890Smrg      need_locks=no
35061ab64890Smrg      lockfile=
35071ab64890Smrg    fi
35081ab64890Smrg
35091ab64890Smrg    # Lock this critical section if it is needed
35101ab64890Smrg    # We use this script file to make the link, it avoids creating a new file
3511862bcd1aSmrg    if test yes = "$need_locks"; then
351288de56ccSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
351388de56ccSmrg	func_echo "Waiting for $lockfile to be removed"
35141ab64890Smrg	sleep 2
35151ab64890Smrg      done
3516862bcd1aSmrg    elif test warn = "$need_locks"; then
35171ab64890Smrg      if test -f "$lockfile"; then
351888de56ccSmrg	$ECHO "\
35191ab64890Smrg*** ERROR, $lockfile exists and contains:
35201ab64890Smrg`cat $lockfile 2>/dev/null`
35211ab64890Smrg
35221ab64890SmrgThis indicates that another process is trying to use the same
35231ab64890Smrgtemporary object file, and libtool could not work around it because
3524862bcd1aSmrgyour compiler does not support '-c' and '-o' together.  If you
35251ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
35261ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
35271ab64890Smrgcompiler."
35281ab64890Smrg
352988de56ccSmrg	$opt_dry_run || $RM $removelist
35301ab64890Smrg	exit $EXIT_FAILURE
35311ab64890Smrg      fi
3532e9fcaa8aSmrg      func_append removelist " $output_obj"
353388de56ccSmrg      $ECHO "$srcfile" > "$lockfile"
35341ab64890Smrg    fi
35351ab64890Smrg
353688de56ccSmrg    $opt_dry_run || $RM $removelist
3537e9fcaa8aSmrg    func_append removelist " $lockfile"
353888de56ccSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
353988de56ccSmrg
3540e9fcaa8aSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3541e9fcaa8aSmrg    srcfile=$func_to_tool_file_result
354288de56ccSmrg    func_quote_for_eval "$srcfile"
354388de56ccSmrg    qsrcfile=$func_quote_for_eval_result
35441ab64890Smrg
35451ab64890Smrg    # Only build a PIC object if we are building libtool libraries.
3546862bcd1aSmrg    if test yes = "$build_libtool_libs"; then
35471ab64890Smrg      # Without this assignment, base_compile gets emptied.
35481ab64890Smrg      fbsd_hideous_sh_bug=$base_compile
35491ab64890Smrg
3550862bcd1aSmrg      if test no != "$pic_mode"; then
35511ab64890Smrg	command="$base_compile $qsrcfile $pic_flag"
35521ab64890Smrg      else
35531ab64890Smrg	# Don't build PIC code
35541ab64890Smrg	command="$base_compile $qsrcfile"
35551ab64890Smrg      fi
35561ab64890Smrg
355788de56ccSmrg      func_mkdir_p "$xdir$objdir"
35581ab64890Smrg
35591ab64890Smrg      if test -z "$output_obj"; then
35601ab64890Smrg	# Place PIC objects in $objdir
3561e9fcaa8aSmrg	func_append command " -o $lobj"
35621ab64890Smrg      fi
35631ab64890Smrg
356488de56ccSmrg      func_show_eval_locale "$command"	\
356588de56ccSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
35661ab64890Smrg
3567862bcd1aSmrg      if test warn = "$need_locks" &&
35681ab64890Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
356988de56ccSmrg	$ECHO "\
35701ab64890Smrg*** ERROR, $lockfile contains:
35711ab64890Smrg`cat $lockfile 2>/dev/null`
35721ab64890Smrg
35731ab64890Smrgbut it should contain:
35741ab64890Smrg$srcfile
35751ab64890Smrg
35761ab64890SmrgThis indicates that another process is trying to use the same
35771ab64890Smrgtemporary object file, and libtool could not work around it because
3578862bcd1aSmrgyour compiler does not support '-c' and '-o' together.  If you
35791ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
35801ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
35811ab64890Smrgcompiler."
35821ab64890Smrg
358388de56ccSmrg	$opt_dry_run || $RM $removelist
35841ab64890Smrg	exit $EXIT_FAILURE
35851ab64890Smrg      fi
35861ab64890Smrg
35871ab64890Smrg      # Just move the object if needed, then go on to compile the next one
35881ab64890Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
358988de56ccSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
359088de56ccSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
35911ab64890Smrg      fi
35921ab64890Smrg
35931ab64890Smrg      # Allow error messages only from the first compilation.
3594862bcd1aSmrg      if test yes = "$suppress_opt"; then
359588de56ccSmrg	suppress_output=' >/dev/null 2>&1'
35961ab64890Smrg      fi
35971ab64890Smrg    fi
35981ab64890Smrg
35991ab64890Smrg    # Only build a position-dependent object if we build old libraries.
3600862bcd1aSmrg    if test yes = "$build_old_libs"; then
3601862bcd1aSmrg      if test yes != "$pic_mode"; then
36021ab64890Smrg	# Don't build PIC code
360388de56ccSmrg	command="$base_compile $qsrcfile$pie_flag"
36041ab64890Smrg      else
36051ab64890Smrg	command="$base_compile $qsrcfile $pic_flag"
36061ab64890Smrg      fi
3607862bcd1aSmrg      if test yes = "$compiler_c_o"; then
3608e9fcaa8aSmrg	func_append command " -o $obj"
36091ab64890Smrg      fi
36101ab64890Smrg
36111ab64890Smrg      # Suppress compiler output if we already did a PIC compilation.
3612e9fcaa8aSmrg      func_append command "$suppress_output"
361388de56ccSmrg      func_show_eval_locale "$command" \
361488de56ccSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
36151ab64890Smrg
3616862bcd1aSmrg      if test warn = "$need_locks" &&
36171ab64890Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
361888de56ccSmrg	$ECHO "\
36191ab64890Smrg*** ERROR, $lockfile contains:
36201ab64890Smrg`cat $lockfile 2>/dev/null`
36211ab64890Smrg
36221ab64890Smrgbut it should contain:
36231ab64890Smrg$srcfile
36241ab64890Smrg
36251ab64890SmrgThis indicates that another process is trying to use the same
36261ab64890Smrgtemporary object file, and libtool could not work around it because
3627862bcd1aSmrgyour compiler does not support '-c' and '-o' together.  If you
36281ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
36291ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
36301ab64890Smrgcompiler."
36311ab64890Smrg
363288de56ccSmrg	$opt_dry_run || $RM $removelist
36331ab64890Smrg	exit $EXIT_FAILURE
36341ab64890Smrg      fi
36351ab64890Smrg
36361ab64890Smrg      # Just move the object if needed
36371ab64890Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
363888de56ccSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
363988de56ccSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
36401ab64890Smrg      fi
36411ab64890Smrg    fi
36421ab64890Smrg
364388de56ccSmrg    $opt_dry_run || {
364488de56ccSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
36451ab64890Smrg
364688de56ccSmrg      # Unlock the critical section if it was locked
3647862bcd1aSmrg      if test no != "$need_locks"; then
364888de56ccSmrg	removelist=$lockfile
364988de56ccSmrg        $RM "$lockfile"
365088de56ccSmrg      fi
365188de56ccSmrg    }
36521ab64890Smrg
36531ab64890Smrg    exit $EXIT_SUCCESS
365488de56ccSmrg}
36551ab64890Smrg
365688de56ccSmrg$opt_help || {
3657862bcd1aSmrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
365888de56ccSmrg}
36591ab64890Smrg
366088de56ccSmrgfunc_mode_help ()
366188de56ccSmrg{
366288de56ccSmrg    # We need to display help for each of the modes.
3663e9fcaa8aSmrg    case $opt_mode in
366488de56ccSmrg      "")
366588de56ccSmrg        # Generic help is extracted from the usage comments
366688de56ccSmrg        # at the start of this file.
366788de56ccSmrg        func_help
366888de56ccSmrg        ;;
36691ab64890Smrg
367088de56ccSmrg      clean)
367188de56ccSmrg        $ECHO \
367288de56ccSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
36731ab64890Smrg
367488de56ccSmrgRemove files from the build directory.
36751ab64890Smrg
367688de56ccSmrgRM is the name of the program to use to delete files associated with each FILE
3677862bcd1aSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
367888de56ccSmrgto RM.
36791ab64890Smrg
368088de56ccSmrgIf FILE is a libtool library, object or program, all the files associated
368188de56ccSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
368288de56ccSmrg        ;;
36831ab64890Smrg
368488de56ccSmrg      compile)
368588de56ccSmrg      $ECHO \
368688de56ccSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
36871ab64890Smrg
368888de56ccSmrgCompile a source file into a libtool library object.
36891ab64890Smrg
369088de56ccSmrgThis mode accepts the following additional options:
36911ab64890Smrg
369288de56ccSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
369388de56ccSmrg  -no-suppress      do not suppress compiler output for multiple passes
3694e9fcaa8aSmrg  -prefer-pic       try to build PIC objects only
3695e9fcaa8aSmrg  -prefer-non-pic   try to build non-PIC objects only
3696862bcd1aSmrg  -shared           do not build a '.o' file suitable for static linking
3697862bcd1aSmrg  -static           only build a '.o' file suitable for static linking
3698e9fcaa8aSmrg  -Wc,FLAG          pass FLAG directly to the compiler
36991ab64890Smrg
3700862bcd1aSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
370188de56ccSmrgfrom the given SOURCEFILE.
37021ab64890Smrg
370388de56ccSmrgThe output file name is determined by removing the directory component from
3704862bcd1aSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
3705862bcd1aSmrglibrary object suffix, '.lo'."
370688de56ccSmrg        ;;
37071ab64890Smrg
370888de56ccSmrg      execute)
370988de56ccSmrg        $ECHO \
371088de56ccSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
37111ab64890Smrg
371288de56ccSmrgAutomatically set library path, then run a program.
37131ab64890Smrg
371488de56ccSmrgThis mode accepts the following additional options:
37151ab64890Smrg
371688de56ccSmrg  -dlopen FILE      add the directory containing FILE to the library path
37171ab64890Smrg
3718862bcd1aSmrgThis mode sets the library path environment variable according to '-dlopen'
371988de56ccSmrgflags.
37201ab64890Smrg
372188de56ccSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
372288de56ccSmrginto their corresponding uninstalled binary, and any of their required library
372388de56ccSmrgdirectories are added to the library path.
37241ab64890Smrg
372588de56ccSmrgThen, COMMAND is executed, with ARGS as arguments."
372688de56ccSmrg        ;;
37271ab64890Smrg
372888de56ccSmrg      finish)
372988de56ccSmrg        $ECHO \
373088de56ccSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
37311ab64890Smrg
373288de56ccSmrgComplete the installation of libtool libraries.
37331ab64890Smrg
373488de56ccSmrgEach LIBDIR is a directory that contains libtool libraries.
37351ab64890Smrg
373688de56ccSmrgThe commands that this mode executes may require superuser privileges.  Use
3737862bcd1aSmrgthe '--dry-run' option if you just want to see what would be executed."
373888de56ccSmrg        ;;
37391ab64890Smrg
374088de56ccSmrg      install)
374188de56ccSmrg        $ECHO \
374288de56ccSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
37431ab64890Smrg
374488de56ccSmrgInstall executables or libraries.
37451ab64890Smrg
374688de56ccSmrgINSTALL-COMMAND is the installation command.  The first component should be
3747862bcd1aSmrgeither the 'install' or 'cp' program.
37481ab64890Smrg
374988de56ccSmrgThe following components of INSTALL-COMMAND are treated specially:
37501ab64890Smrg
3751e9fcaa8aSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
37521ab64890Smrg
375388de56ccSmrgThe rest of the components are interpreted as arguments to that command (only
375488de56ccSmrgBSD-compatible install options are recognized)."
375588de56ccSmrg        ;;
37561ab64890Smrg
375788de56ccSmrg      link)
375888de56ccSmrg        $ECHO \
375988de56ccSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
37601ab64890Smrg
376188de56ccSmrgLink object files or libraries together to form another library, or to
376288de56ccSmrgcreate an executable program.
37631ab64890Smrg
376488de56ccSmrgLINK-COMMAND is a command using the C compiler that you would use to create
376588de56ccSmrga program from several object files.
37661ab64890Smrg
376788de56ccSmrgThe following components of LINK-COMMAND are treated specially:
37681ab64890Smrg
376988de56ccSmrg  -all-static       do not do any dynamic linking at all
377088de56ccSmrg  -avoid-version    do not add a version suffix if possible
3771e9fcaa8aSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
3772e9fcaa8aSmrg                    libraries must be found in the PATH setting at runtime)
3773862bcd1aSmrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
377488de56ccSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
377588de56ccSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
377688de56ccSmrg  -export-symbols SYMFILE
377788de56ccSmrg                    try to export only the symbols listed in SYMFILE
377888de56ccSmrg  -export-symbols-regex REGEX
377988de56ccSmrg                    try to export only the symbols matching REGEX
378088de56ccSmrg  -LLIBDIR          search LIBDIR for required installed libraries
378188de56ccSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
378288de56ccSmrg  -module           build a library that can dlopened
378388de56ccSmrg  -no-fast-install  disable the fast-install mode
378488de56ccSmrg  -no-install       link a not-installable executable
378588de56ccSmrg  -no-undefined     declare that a library does not refer to external symbols
378688de56ccSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
3787862bcd1aSmrg  -objectlist FILE  use a list of object files found in FILE to specify objects
3788862bcd1aSmrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
378988de56ccSmrg  -precious-files-regex REGEX
379088de56ccSmrg                    don't remove output files matching REGEX
379188de56ccSmrg  -release RELEASE  specify package release information
379288de56ccSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
379388de56ccSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
379488de56ccSmrg  -shared           only do dynamic linking of libtool libraries
379588de56ccSmrg  -shrext SUFFIX    override the standard shared library file extension
379688de56ccSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
379788de56ccSmrg  -static-libtool-libs
379888de56ccSmrg                    do not do any dynamic linking of libtool libraries
379988de56ccSmrg  -version-info CURRENT[:REVISION[:AGE]]
380088de56ccSmrg                    specify library version info [each variable defaults to 0]
380188de56ccSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
3802e9fcaa8aSmrg  -Wc,FLAG
3803e9fcaa8aSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
3804e9fcaa8aSmrg  -Wl,FLAG
3805e9fcaa8aSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
3806e9fcaa8aSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
38071ab64890Smrg
3808862bcd1aSmrgAll other options (arguments beginning with '-') are ignored.
38091ab64890Smrg
3810862bcd1aSmrgEvery other argument is treated as a filename.  Files ending in '.la' are
381188de56ccSmrgtreated as uninstalled libtool libraries, other files are standard or library
381288de56ccSmrgobject files.
38131ab64890Smrg
3814862bcd1aSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
3815862bcd1aSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is
381688de56ccSmrgrequired, except when creating a convenience library.
38171ab64890Smrg
3818862bcd1aSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
3819862bcd1aSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
38201ab64890Smrg
3821862bcd1aSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
382288de56ccSmrgis created, otherwise an executable program is created."
3823b4ee4795Smrg        ;;
38241ab64890Smrg
382588de56ccSmrg      uninstall)
382688de56ccSmrg        $ECHO \
382788de56ccSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
38281ab64890Smrg
382988de56ccSmrgRemove libraries from an installation directory.
38301ab64890Smrg
383188de56ccSmrgRM is the name of the program to use to delete files associated with each FILE
3832862bcd1aSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
383388de56ccSmrgto RM.
38342e9c7c8cSmrg
383588de56ccSmrgIf FILE is a libtool library, all the files associated with it are deleted.
383688de56ccSmrgOtherwise, only FILE itself is deleted using RM."
383788de56ccSmrg        ;;
38382e9c7c8cSmrg
383988de56ccSmrg      *)
3840862bcd1aSmrg        func_fatal_help "invalid operation mode '$opt_mode'"
384188de56ccSmrg        ;;
384288de56ccSmrg    esac
38432e9c7c8cSmrg
3844e9fcaa8aSmrg    echo
3845862bcd1aSmrg    $ECHO "Try '$progname --help' for more information about other modes."
384688de56ccSmrg}
38472e9c7c8cSmrg
3848e9fcaa8aSmrg# Now that we've collected a possible --mode arg, show help if necessary
3849e9fcaa8aSmrgif $opt_help; then
3850862bcd1aSmrg  if test : = "$opt_help"; then
3851e9fcaa8aSmrg    func_mode_help
3852e9fcaa8aSmrg  else
3853e9fcaa8aSmrg    {
3854e9fcaa8aSmrg      func_help noexit
3855e9fcaa8aSmrg      for opt_mode in compile link execute install finish uninstall clean; do
3856e9fcaa8aSmrg	func_mode_help
3857e9fcaa8aSmrg      done
3858862bcd1aSmrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
3859e9fcaa8aSmrg    {
3860e9fcaa8aSmrg      func_help noexit
3861e9fcaa8aSmrg      for opt_mode in compile link execute install finish uninstall clean; do
3862e9fcaa8aSmrg	echo
3863e9fcaa8aSmrg	func_mode_help
3864e9fcaa8aSmrg      done
3865e9fcaa8aSmrg    } |
3866862bcd1aSmrg    $SED '1d
3867e9fcaa8aSmrg      /^When reporting/,/^Report/{
3868e9fcaa8aSmrg	H
3869e9fcaa8aSmrg	d
3870e9fcaa8aSmrg      }
3871e9fcaa8aSmrg      $x
3872e9fcaa8aSmrg      /information about other modes/d
3873e9fcaa8aSmrg      /more detailed .*MODE/d
3874e9fcaa8aSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3875e9fcaa8aSmrg  fi
3876e9fcaa8aSmrg  exit $?
3877e9fcaa8aSmrgfi
38782e9c7c8cSmrg
38792e9c7c8cSmrg
388088de56ccSmrg# func_mode_execute arg...
388188de56ccSmrgfunc_mode_execute ()
388288de56ccSmrg{
3883862bcd1aSmrg    $debug_cmd
3884862bcd1aSmrg
388588de56ccSmrg    # The first argument is the command name.
3886862bcd1aSmrg    cmd=$nonopt
388788de56ccSmrg    test -z "$cmd" && \
388888de56ccSmrg      func_fatal_help "you must specify a COMMAND"
3889b4ee4795Smrg
389088de56ccSmrg    # Handle -dlopen flags immediately.
3891e9fcaa8aSmrg    for file in $opt_dlopen; do
389288de56ccSmrg      test -f "$file" \
3893862bcd1aSmrg	|| func_fatal_help "'$file' is not a file"
3894b4ee4795Smrg
389588de56ccSmrg      dir=
389688de56ccSmrg      case $file in
389788de56ccSmrg      *.la)
3898e9fcaa8aSmrg	func_resolve_sysroot "$file"
3899e9fcaa8aSmrg	file=$func_resolve_sysroot_result
3900e9fcaa8aSmrg
390188de56ccSmrg	# Check to see that this really is a libtool archive.
390288de56ccSmrg	func_lalib_unsafe_p "$file" \
3903862bcd1aSmrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
3904b4ee4795Smrg
390588de56ccSmrg	# Read the libtool library.
390688de56ccSmrg	dlname=
390788de56ccSmrg	library_names=
390888de56ccSmrg	func_source "$file"
39091ab64890Smrg
391088de56ccSmrg	# Skip this library if it cannot be dlopened.
391188de56ccSmrg	if test -z "$dlname"; then
391288de56ccSmrg	  # Warn if it was a shared library.
391388de56ccSmrg	  test -n "$library_names" && \
3914862bcd1aSmrg	    func_warning "'$file' was not linked with '-export-dynamic'"
391588de56ccSmrg	  continue
391688de56ccSmrg	fi
39171ab64890Smrg
391888de56ccSmrg	func_dirname "$file" "" "."
3919862bcd1aSmrg	dir=$func_dirname_result
39201ab64890Smrg
392188de56ccSmrg	if test -f "$dir/$objdir/$dlname"; then
3922e9fcaa8aSmrg	  func_append dir "/$objdir"
392388de56ccSmrg	else
392488de56ccSmrg	  if test ! -f "$dir/$dlname"; then
3925862bcd1aSmrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
392688de56ccSmrg	  fi
392788de56ccSmrg	fi
3928b4ee4795Smrg	;;
39291ab64890Smrg
393088de56ccSmrg      *.lo)
393188de56ccSmrg	# Just add the directory containing the .lo file.
393288de56ccSmrg	func_dirname "$file" "" "."
3933862bcd1aSmrg	dir=$func_dirname_result
3934b4ee4795Smrg	;;
39351ab64890Smrg
393688de56ccSmrg      *)
3937862bcd1aSmrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
3938b4ee4795Smrg	continue
3939b4ee4795Smrg	;;
394088de56ccSmrg      esac
39411ab64890Smrg
394288de56ccSmrg      # Get the absolute pathname.
394388de56ccSmrg      absdir=`cd "$dir" && pwd`
3944862bcd1aSmrg      test -n "$absdir" && dir=$absdir
39452e9c7c8cSmrg
394688de56ccSmrg      # Now add the directory to shlibpath_var.
394788de56ccSmrg      if eval "test -z \"\$$shlibpath_var\""; then
394888de56ccSmrg	eval "$shlibpath_var=\"\$dir\""
394988de56ccSmrg      else
395088de56ccSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
395188de56ccSmrg      fi
395288de56ccSmrg    done
39532e9c7c8cSmrg
395488de56ccSmrg    # This variable tells wrapper scripts just to set shlibpath_var
395588de56ccSmrg    # rather than running their programs.
3956862bcd1aSmrg    libtool_execute_magic=$magic
39572e9c7c8cSmrg
395888de56ccSmrg    # Check if any of the arguments is a wrapper script.
395988de56ccSmrg    args=
396088de56ccSmrg    for file
396188de56ccSmrg    do
396288de56ccSmrg      case $file in
3963e9fcaa8aSmrg      -* | *.la | *.lo ) ;;
396488de56ccSmrg      *)
396588de56ccSmrg	# Do a test to see if this is really a libtool program.
396688de56ccSmrg	if func_ltwrapper_script_p "$file"; then
396788de56ccSmrg	  func_source "$file"
396888de56ccSmrg	  # Transform arg to wrapped name.
3969862bcd1aSmrg	  file=$progdir/$program
397088de56ccSmrg	elif func_ltwrapper_executable_p "$file"; then
397188de56ccSmrg	  func_ltwrapper_scriptname "$file"
397288de56ccSmrg	  func_source "$func_ltwrapper_scriptname_result"
397388de56ccSmrg	  # Transform arg to wrapped name.
3974862bcd1aSmrg	  file=$progdir/$program
397588de56ccSmrg	fi
397688de56ccSmrg	;;
397788de56ccSmrg      esac
397888de56ccSmrg      # Quote arguments (to preserve shell metacharacters).
3979e9fcaa8aSmrg      func_append_quoted args "$file"
398088de56ccSmrg    done
39812e9c7c8cSmrg
3982862bcd1aSmrg    if $opt_dry_run; then
3983862bcd1aSmrg      # Display what would be done.
3984862bcd1aSmrg      if test -n "$shlibpath_var"; then
3985862bcd1aSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
3986862bcd1aSmrg	echo "export $shlibpath_var"
3987862bcd1aSmrg      fi
3988862bcd1aSmrg      $ECHO "$cmd$args"
3989862bcd1aSmrg      exit $EXIT_SUCCESS
3990862bcd1aSmrg    else
399188de56ccSmrg      if test -n "$shlibpath_var"; then
399288de56ccSmrg	# Export the shlibpath_var.
399388de56ccSmrg	eval "export $shlibpath_var"
399488de56ccSmrg      fi
39952e9c7c8cSmrg
399688de56ccSmrg      # Restore saved environment variables
399788de56ccSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
399888de56ccSmrg      do
399988de56ccSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
400088de56ccSmrg                $lt_var=\$save_$lt_var; export $lt_var
4001b4ee4795Smrg	      else
400288de56ccSmrg		$lt_unset $lt_var
400388de56ccSmrg	      fi"
400488de56ccSmrg      done
40052e9c7c8cSmrg
400688de56ccSmrg      # Now prepare to actually exec the command.
4007862bcd1aSmrg      exec_cmd=\$cmd$args
400888de56ccSmrg    fi
400988de56ccSmrg}
40102e9c7c8cSmrg
4011862bcd1aSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
40122e9c7c8cSmrg
4013b4ee4795Smrg
401488de56ccSmrg# func_mode_finish arg...
401588de56ccSmrgfunc_mode_finish ()
401688de56ccSmrg{
4017862bcd1aSmrg    $debug_cmd
4018862bcd1aSmrg
4019e9fcaa8aSmrg    libs=
4020e9fcaa8aSmrg    libdirs=
402188de56ccSmrg    admincmds=
40221ab64890Smrg
4023e9fcaa8aSmrg    for opt in "$nonopt" ${1+"$@"}
4024e9fcaa8aSmrg    do
4025e9fcaa8aSmrg      if test -d "$opt"; then
4026e9fcaa8aSmrg	func_append libdirs " $opt"
4027e9fcaa8aSmrg
4028e9fcaa8aSmrg      elif test -f "$opt"; then
4029e9fcaa8aSmrg	if func_lalib_unsafe_p "$opt"; then
4030e9fcaa8aSmrg	  func_append libs " $opt"
4031e9fcaa8aSmrg	else
4032862bcd1aSmrg	  func_warning "'$opt' is not a valid libtool archive"
4033e9fcaa8aSmrg	fi
4034e9fcaa8aSmrg
4035e9fcaa8aSmrg      else
4036862bcd1aSmrg	func_fatal_error "invalid argument '$opt'"
4037e9fcaa8aSmrg      fi
4038e9fcaa8aSmrg    done
4039e9fcaa8aSmrg
4040e9fcaa8aSmrg    if test -n "$libs"; then
4041e9fcaa8aSmrg      if test -n "$lt_sysroot"; then
4042e9fcaa8aSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
4043e9fcaa8aSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
4044e9fcaa8aSmrg      else
4045e9fcaa8aSmrg        sysroot_cmd=
4046e9fcaa8aSmrg      fi
40471ab64890Smrg
4048e9fcaa8aSmrg      # Remove sysroot references
4049e9fcaa8aSmrg      if $opt_dry_run; then
4050e9fcaa8aSmrg        for lib in $libs; do
4051862bcd1aSmrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4052e9fcaa8aSmrg        done
4053e9fcaa8aSmrg      else
4054e9fcaa8aSmrg        tmpdir=`func_mktempdir`
4055e9fcaa8aSmrg        for lib in $libs; do
4056862bcd1aSmrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4057e9fcaa8aSmrg	    > $tmpdir/tmp-la
4058e9fcaa8aSmrg	  mv -f $tmpdir/tmp-la $lib
4059e9fcaa8aSmrg	done
4060e9fcaa8aSmrg        ${RM}r "$tmpdir"
4061e9fcaa8aSmrg      fi
4062e9fcaa8aSmrg    fi
4063e9fcaa8aSmrg
4064e9fcaa8aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
406588de56ccSmrg      for libdir in $libdirs; do
406688de56ccSmrg	if test -n "$finish_cmds"; then
406788de56ccSmrg	  # Do each command in the finish commands.
406888de56ccSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
406988de56ccSmrg'"$cmd"'"'
4070b4ee4795Smrg	fi
407188de56ccSmrg	if test -n "$finish_eval"; then
407288de56ccSmrg	  # Do the single finish_eval.
407388de56ccSmrg	  eval cmds=\"$finish_eval\"
4074e9fcaa8aSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
407588de56ccSmrg       $cmds"
407688de56ccSmrg	fi
407788de56ccSmrg      done
407888de56ccSmrg    fi
40791ab64890Smrg
408088de56ccSmrg    # Exit here if they wanted silent mode.
4081862bcd1aSmrg    $opt_quiet && exit $EXIT_SUCCESS
40821ab64890Smrg
4083e9fcaa8aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4084e9fcaa8aSmrg      echo "----------------------------------------------------------------------"
4085e9fcaa8aSmrg      echo "Libraries have been installed in:"
4086e9fcaa8aSmrg      for libdir in $libdirs; do
4087e9fcaa8aSmrg	$ECHO "   $libdir"
4088e9fcaa8aSmrg      done
4089e9fcaa8aSmrg      echo
4090e9fcaa8aSmrg      echo "If you ever happen to want to link against installed libraries"
4091e9fcaa8aSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
4092862bcd1aSmrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4093e9fcaa8aSmrg      echo "flag during linking and do at least one of the following:"
4094e9fcaa8aSmrg      if test -n "$shlibpath_var"; then
4095862bcd1aSmrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
4096e9fcaa8aSmrg	echo "     during execution"
4097e9fcaa8aSmrg      fi
4098e9fcaa8aSmrg      if test -n "$runpath_var"; then
4099862bcd1aSmrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
4100e9fcaa8aSmrg	echo "     during linking"
4101e9fcaa8aSmrg      fi
4102e9fcaa8aSmrg      if test -n "$hardcode_libdir_flag_spec"; then
4103e9fcaa8aSmrg	libdir=LIBDIR
4104e9fcaa8aSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
410588de56ccSmrg
4106862bcd1aSmrg	$ECHO "   - use the '$flag' linker flag"
4107e9fcaa8aSmrg      fi
4108e9fcaa8aSmrg      if test -n "$admincmds"; then
4109e9fcaa8aSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
4110e9fcaa8aSmrg      fi
4111e9fcaa8aSmrg      if test -f /etc/ld.so.conf; then
4112862bcd1aSmrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4113e9fcaa8aSmrg      fi
4114e9fcaa8aSmrg      echo
411588de56ccSmrg
4116e9fcaa8aSmrg      echo "See any operating system documentation about shared libraries for"
4117e9fcaa8aSmrg      case $host in
4118e9fcaa8aSmrg	solaris2.[6789]|solaris2.1[0-9])
4119e9fcaa8aSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4120e9fcaa8aSmrg	  echo "pages."
4121e9fcaa8aSmrg	  ;;
4122e9fcaa8aSmrg	*)
4123e9fcaa8aSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
4124e9fcaa8aSmrg	  ;;
4125e9fcaa8aSmrg      esac
4126e9fcaa8aSmrg      echo "----------------------------------------------------------------------"
4127e9fcaa8aSmrg    fi
412888de56ccSmrg    exit $EXIT_SUCCESS
412988de56ccSmrg}
413088de56ccSmrg
4131862bcd1aSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
413288de56ccSmrg
413388de56ccSmrg
413488de56ccSmrg# func_mode_install arg...
413588de56ccSmrgfunc_mode_install ()
413688de56ccSmrg{
4137862bcd1aSmrg    $debug_cmd
4138862bcd1aSmrg
413988de56ccSmrg    # There may be an optional sh(1) argument at the beginning of
414088de56ccSmrg    # install_prog (especially on Windows NT).
4141862bcd1aSmrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
414288de56ccSmrg       # Allow the use of GNU shtool's install command.
4143862bcd1aSmrg       case $nonopt in *shtool*) :;; *) false;; esac
4144862bcd1aSmrg    then
414588de56ccSmrg      # Aesthetically quote it.
414688de56ccSmrg      func_quote_for_eval "$nonopt"
414788de56ccSmrg      install_prog="$func_quote_for_eval_result "
414888de56ccSmrg      arg=$1
414988de56ccSmrg      shift
415088de56ccSmrg    else
415188de56ccSmrg      install_prog=
415288de56ccSmrg      arg=$nonopt
415388de56ccSmrg    fi
415488de56ccSmrg
415588de56ccSmrg    # The real first argument should be the name of the installation program.
415688de56ccSmrg    # Aesthetically quote it.
415788de56ccSmrg    func_quote_for_eval "$arg"
4158e9fcaa8aSmrg    func_append install_prog "$func_quote_for_eval_result"
4159e9fcaa8aSmrg    install_shared_prog=$install_prog
4160e9fcaa8aSmrg    case " $install_prog " in
4161e9fcaa8aSmrg      *[\\\ /]cp\ *) install_cp=: ;;
4162e9fcaa8aSmrg      *) install_cp=false ;;
4163e9fcaa8aSmrg    esac
416488de56ccSmrg
416588de56ccSmrg    # We need to accept at least all the BSD install flags.
416688de56ccSmrg    dest=
416788de56ccSmrg    files=
416888de56ccSmrg    opts=
416988de56ccSmrg    prev=
417088de56ccSmrg    install_type=
4171862bcd1aSmrg    isdir=false
417288de56ccSmrg    stripme=
4173e9fcaa8aSmrg    no_mode=:
417488de56ccSmrg    for arg
417588de56ccSmrg    do
4176e9fcaa8aSmrg      arg2=
417788de56ccSmrg      if test -n "$dest"; then
4178e9fcaa8aSmrg	func_append files " $dest"
417988de56ccSmrg	dest=$arg
418088de56ccSmrg	continue
418188de56ccSmrg      fi
418288de56ccSmrg
418388de56ccSmrg      case $arg in
4184862bcd1aSmrg      -d) isdir=: ;;
418588de56ccSmrg      -f)
4186e9fcaa8aSmrg	if $install_cp; then :; else
4187e9fcaa8aSmrg	  prev=$arg
4188e9fcaa8aSmrg	fi
418988de56ccSmrg	;;
419088de56ccSmrg      -g | -m | -o)
419188de56ccSmrg	prev=$arg
419288de56ccSmrg	;;
419388de56ccSmrg      -s)
419488de56ccSmrg	stripme=" -s"
419588de56ccSmrg	continue
419688de56ccSmrg	;;
419788de56ccSmrg      -*)
419888de56ccSmrg	;;
419988de56ccSmrg      *)
420088de56ccSmrg	# If the previous option needed an argument, then skip it.
420188de56ccSmrg	if test -n "$prev"; then
4202862bcd1aSmrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
4203e9fcaa8aSmrg	    arg2=$install_override_mode
4204e9fcaa8aSmrg	    no_mode=false
4205e9fcaa8aSmrg	  fi
4206b4ee4795Smrg	  prev=
42072e9c7c8cSmrg	else
420888de56ccSmrg	  dest=$arg
420988de56ccSmrg	  continue
42101ab64890Smrg	fi
4211b4ee4795Smrg	;;
421288de56ccSmrg      esac
42131ab64890Smrg
421488de56ccSmrg      # Aesthetically quote the argument.
421588de56ccSmrg      func_quote_for_eval "$arg"
4216e9fcaa8aSmrg      func_append install_prog " $func_quote_for_eval_result"
4217e9fcaa8aSmrg      if test -n "$arg2"; then
4218e9fcaa8aSmrg	func_quote_for_eval "$arg2"
4219e9fcaa8aSmrg      fi
4220e9fcaa8aSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
422188de56ccSmrg    done
42221ab64890Smrg
422388de56ccSmrg    test -z "$install_prog" && \
422488de56ccSmrg      func_fatal_help "you must specify an install program"
42251ab64890Smrg
422688de56ccSmrg    test -n "$prev" && \
4227862bcd1aSmrg      func_fatal_help "the '$prev' option requires an argument"
42282e9c7c8cSmrg
4229e9fcaa8aSmrg    if test -n "$install_override_mode" && $no_mode; then
4230e9fcaa8aSmrg      if $install_cp; then :; else
4231e9fcaa8aSmrg	func_quote_for_eval "$install_override_mode"
4232e9fcaa8aSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
4233e9fcaa8aSmrg      fi
4234e9fcaa8aSmrg    fi
4235e9fcaa8aSmrg
423688de56ccSmrg    if test -z "$files"; then
423788de56ccSmrg      if test -z "$dest"; then
423888de56ccSmrg	func_fatal_help "no file or destination specified"
423988de56ccSmrg      else
424088de56ccSmrg	func_fatal_help "you must specify a destination"
424188de56ccSmrg      fi
4242b4ee4795Smrg    fi
42432e9c7c8cSmrg
424488de56ccSmrg    # Strip any trailing slash from the destination.
424588de56ccSmrg    func_stripname '' '/' "$dest"
424688de56ccSmrg    dest=$func_stripname_result
42472e9c7c8cSmrg
424888de56ccSmrg    # Check to see that the destination is a directory.
4249862bcd1aSmrg    test -d "$dest" && isdir=:
4250862bcd1aSmrg    if $isdir; then
4251862bcd1aSmrg      destdir=$dest
425288de56ccSmrg      destname=
4253b4ee4795Smrg    else
425488de56ccSmrg      func_dirname_and_basename "$dest" "" "."
4255862bcd1aSmrg      destdir=$func_dirname_result
4256862bcd1aSmrg      destname=$func_basename_result
42572e9c7c8cSmrg
425888de56ccSmrg      # Not a directory, so check to see that there is only one file specified.
425988de56ccSmrg      set dummy $files; shift
426088de56ccSmrg      test "$#" -gt 1 && \
4261862bcd1aSmrg	func_fatal_help "'$dest' is not a directory"
42622e9c7c8cSmrg    fi
426388de56ccSmrg    case $destdir in
426488de56ccSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
4265b4ee4795Smrg    *)
426688de56ccSmrg      for file in $files; do
426788de56ccSmrg	case $file in
426888de56ccSmrg	*.lo) ;;
426988de56ccSmrg	*)
4270862bcd1aSmrg	  func_fatal_help "'$destdir' must be an absolute directory name"
427188de56ccSmrg	  ;;
427288de56ccSmrg	esac
427388de56ccSmrg      done
4274b4ee4795Smrg      ;;
4275b4ee4795Smrg    esac
42761ab64890Smrg
427788de56ccSmrg    # This variable tells wrapper scripts just to set variables rather
427888de56ccSmrg    # than running their programs.
4279862bcd1aSmrg    libtool_install_magic=$magic
42801ab64890Smrg
428188de56ccSmrg    staticlibs=
428288de56ccSmrg    future_libdirs=
428388de56ccSmrg    current_libdirs=
428488de56ccSmrg    for file in $files; do
42851ab64890Smrg
428688de56ccSmrg      # Do each installation.
428788de56ccSmrg      case $file in
428888de56ccSmrg      *.$libext)
428988de56ccSmrg	# Do the static libraries later.
4290e9fcaa8aSmrg	func_append staticlibs " $file"
429188de56ccSmrg	;;
429288de56ccSmrg
429388de56ccSmrg      *.la)
4294e9fcaa8aSmrg	func_resolve_sysroot "$file"
4295e9fcaa8aSmrg	file=$func_resolve_sysroot_result
4296e9fcaa8aSmrg
429788de56ccSmrg	# Check to see that this really is a libtool archive.
429888de56ccSmrg	func_lalib_unsafe_p "$file" \
4299862bcd1aSmrg	  || func_fatal_help "'$file' is not a valid libtool archive"
430088de56ccSmrg
430188de56ccSmrg	library_names=
430288de56ccSmrg	old_library=
430388de56ccSmrg	relink_command=
430488de56ccSmrg	func_source "$file"
430588de56ccSmrg
430688de56ccSmrg	# Add the libdir to current_libdirs if it is the destination.
430788de56ccSmrg	if test "X$destdir" = "X$libdir"; then
430888de56ccSmrg	  case "$current_libdirs " in
430988de56ccSmrg	  *" $libdir "*) ;;
4310e9fcaa8aSmrg	  *) func_append current_libdirs " $libdir" ;;
43112e9c7c8cSmrg	  esac
431288de56ccSmrg	else
431388de56ccSmrg	  # Note the libdir as a future libdir.
431488de56ccSmrg	  case "$future_libdirs " in
431588de56ccSmrg	  *" $libdir "*) ;;
4316e9fcaa8aSmrg	  *) func_append future_libdirs " $libdir" ;;
431788de56ccSmrg	  esac
431888de56ccSmrg	fi
43192e9c7c8cSmrg
432088de56ccSmrg	func_dirname "$file" "/" ""
4321862bcd1aSmrg	dir=$func_dirname_result
4322e9fcaa8aSmrg	func_append dir "$objdir"
432388de56ccSmrg
432488de56ccSmrg	if test -n "$relink_command"; then
432588de56ccSmrg	  # Determine the prefix the user has applied to our future dir.
4326e9fcaa8aSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
432788de56ccSmrg
432888de56ccSmrg	  # Don't allow the user to place us outside of our expected
432988de56ccSmrg	  # location b/c this prevents finding dependent libraries that
433088de56ccSmrg	  # are installed to the same prefix.
433188de56ccSmrg	  # At present, this check doesn't affect windows .dll's that
433288de56ccSmrg	  # are installed into $libdir/../bin (currently, that works fine)
433388de56ccSmrg	  # but it's something to keep an eye on.
433488de56ccSmrg	  test "$inst_prefix_dir" = "$destdir" && \
4335862bcd1aSmrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
433688de56ccSmrg
433788de56ccSmrg	  if test -n "$inst_prefix_dir"; then
433888de56ccSmrg	    # Stick the inst_prefix_dir data into the link command.
4339e9fcaa8aSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
434088de56ccSmrg	  else
4341e9fcaa8aSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
434288de56ccSmrg	  fi
434388de56ccSmrg
4344862bcd1aSmrg	  func_warning "relinking '$file'"
434588de56ccSmrg	  func_show_eval "$relink_command" \
4346862bcd1aSmrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
434788de56ccSmrg	fi
434888de56ccSmrg
434988de56ccSmrg	# See the names of the shared library.
435088de56ccSmrg	set dummy $library_names; shift
435188de56ccSmrg	if test -n "$1"; then
4352862bcd1aSmrg	  realname=$1
435388de56ccSmrg	  shift
435488de56ccSmrg
4355862bcd1aSmrg	  srcname=$realname
4356862bcd1aSmrg	  test -n "$relink_command" && srcname=${realname}T
435788de56ccSmrg
435888de56ccSmrg	  # Install the shared library and build the symlinks.
4359e9fcaa8aSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
436088de56ccSmrg	      'exit $?'
4361862bcd1aSmrg	  tstripme=$stripme
436288de56ccSmrg	  case $host_os in
436388de56ccSmrg	  cygwin* | mingw* | pw32* | cegcc*)
436488de56ccSmrg	    case $realname in
436588de56ccSmrg	    *.dll.a)
4366862bcd1aSmrg	      tstripme=
4367862bcd1aSmrg	      ;;
4368862bcd1aSmrg	    esac
4369862bcd1aSmrg	    ;;
4370862bcd1aSmrg	  os2*)
4371862bcd1aSmrg	    case $realname in
4372862bcd1aSmrg	    *_dll.a)
4373862bcd1aSmrg	      tstripme=
437488de56ccSmrg	      ;;
437588de56ccSmrg	    esac
43762e9c7c8cSmrg	    ;;
43772e9c7c8cSmrg	  esac
437888de56ccSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
437988de56ccSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
4380b4ee4795Smrg	  fi
438188de56ccSmrg
438288de56ccSmrg	  if test "$#" -gt 0; then
438388de56ccSmrg	    # Delete the old symlinks, and create new ones.
4384862bcd1aSmrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
438588de56ccSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
438688de56ccSmrg	    # so we also need to try rm && ln -s.
438788de56ccSmrg	    for linkname
438888de56ccSmrg	    do
438988de56ccSmrg	      test "$linkname" != "$realname" \
439088de56ccSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4391b4ee4795Smrg	    done
4392b4ee4795Smrg	  fi
43931ab64890Smrg
439488de56ccSmrg	  # Do each command in the postinstall commands.
4395862bcd1aSmrg	  lib=$destdir/$realname
439688de56ccSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
4397b4ee4795Smrg	fi
43981ab64890Smrg
439988de56ccSmrg	# Install the pseudo-library for information purposes.
440088de56ccSmrg	func_basename "$file"
4401862bcd1aSmrg	name=$func_basename_result
4402862bcd1aSmrg	instname=$dir/${name}i
440388de56ccSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
44041ab64890Smrg
440588de56ccSmrg	# Maybe install the static library, too.
4406e9fcaa8aSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
440788de56ccSmrg	;;
44081ab64890Smrg
440988de56ccSmrg      *.lo)
441088de56ccSmrg	# Install (i.e. copy) a libtool object.
44111ab64890Smrg
441288de56ccSmrg	# Figure out destination file name, if it wasn't already specified.
441388de56ccSmrg	if test -n "$destname"; then
4414862bcd1aSmrg	  destfile=$destdir/$destname
441588de56ccSmrg	else
441688de56ccSmrg	  func_basename "$file"
4417862bcd1aSmrg	  destfile=$func_basename_result
4418862bcd1aSmrg	  destfile=$destdir/$destfile
4419b4ee4795Smrg	fi
44201ab64890Smrg
442188de56ccSmrg	# Deduce the name of the destination old-style object file.
442288de56ccSmrg	case $destfile in
442388de56ccSmrg	*.lo)
442488de56ccSmrg	  func_lo2o "$destfile"
442588de56ccSmrg	  staticdest=$func_lo2o_result
442688de56ccSmrg	  ;;
442788de56ccSmrg	*.$objext)
4428862bcd1aSmrg	  staticdest=$destfile
442988de56ccSmrg	  destfile=
443088de56ccSmrg	  ;;
443188de56ccSmrg	*)
4432862bcd1aSmrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
443388de56ccSmrg	  ;;
443488de56ccSmrg	esac
44351ab64890Smrg
443688de56ccSmrg	# Install the libtool object if requested.
443788de56ccSmrg	test -n "$destfile" && \
443888de56ccSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
44391ab64890Smrg
444088de56ccSmrg	# Install the old object if enabled.
4441862bcd1aSmrg	if test yes = "$build_old_libs"; then
444288de56ccSmrg	  # Deduce the name of the old-style object file.
444388de56ccSmrg	  func_lo2o "$file"
444488de56ccSmrg	  staticobj=$func_lo2o_result
444588de56ccSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
44461ab64890Smrg	fi
444788de56ccSmrg	exit $EXIT_SUCCESS
444888de56ccSmrg	;;
44491ab64890Smrg
445088de56ccSmrg      *)
445188de56ccSmrg	# Figure out destination file name, if it wasn't already specified.
445288de56ccSmrg	if test -n "$destname"; then
4453862bcd1aSmrg	  destfile=$destdir/$destname
445488de56ccSmrg	else
445588de56ccSmrg	  func_basename "$file"
4456862bcd1aSmrg	  destfile=$func_basename_result
4457862bcd1aSmrg	  destfile=$destdir/$destfile
445888de56ccSmrg	fi
44591ab64890Smrg
446088de56ccSmrg	# If the file is missing, and there is a .exe on the end, strip it
446188de56ccSmrg	# because it is most likely a libtool script we actually want to
446288de56ccSmrg	# install
4463862bcd1aSmrg	stripped_ext=
446488de56ccSmrg	case $file in
446588de56ccSmrg	  *.exe)
446688de56ccSmrg	    if test ! -f "$file"; then
446788de56ccSmrg	      func_stripname '' '.exe' "$file"
446888de56ccSmrg	      file=$func_stripname_result
4469862bcd1aSmrg	      stripped_ext=.exe
447088de56ccSmrg	    fi
447188de56ccSmrg	    ;;
447288de56ccSmrg	esac
447388de56ccSmrg
447488de56ccSmrg	# Do a test to see if this is really a libtool program.
447588de56ccSmrg	case $host in
447688de56ccSmrg	*cygwin* | *mingw*)
447788de56ccSmrg	    if func_ltwrapper_executable_p "$file"; then
447888de56ccSmrg	      func_ltwrapper_scriptname "$file"
447988de56ccSmrg	      wrapper=$func_ltwrapper_scriptname_result
448088de56ccSmrg	    else
448188de56ccSmrg	      func_stripname '' '.exe' "$file"
448288de56ccSmrg	      wrapper=$func_stripname_result
448388de56ccSmrg	    fi
448488de56ccSmrg	    ;;
4485b4ee4795Smrg	*)
448688de56ccSmrg	    wrapper=$file
448788de56ccSmrg	    ;;
448888de56ccSmrg	esac
448988de56ccSmrg	if func_ltwrapper_script_p "$wrapper"; then
449088de56ccSmrg	  notinst_deplibs=
449188de56ccSmrg	  relink_command=
449288de56ccSmrg
449388de56ccSmrg	  func_source "$wrapper"
449488de56ccSmrg
449588de56ccSmrg	  # Check the variables that should have been set.
449688de56ccSmrg	  test -z "$generated_by_libtool_version" && \
4497862bcd1aSmrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
449888de56ccSmrg
4499862bcd1aSmrg	  finalize=:
450088de56ccSmrg	  for lib in $notinst_deplibs; do
450188de56ccSmrg	    # Check to see that each library is installed.
450288de56ccSmrg	    libdir=
450388de56ccSmrg	    if test -f "$lib"; then
450488de56ccSmrg	      func_source "$lib"
450588de56ccSmrg	    fi
4506862bcd1aSmrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
450788de56ccSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
4508862bcd1aSmrg	      func_warning "'$lib' has not been installed in '$libdir'"
4509862bcd1aSmrg	      finalize=false
451088de56ccSmrg	    fi
451188de56ccSmrg	  done
451288de56ccSmrg
451388de56ccSmrg	  relink_command=
451488de56ccSmrg	  func_source "$wrapper"
451588de56ccSmrg
451688de56ccSmrg	  outputname=
4517862bcd1aSmrg	  if test no = "$fast_install" && test -n "$relink_command"; then
451888de56ccSmrg	    $opt_dry_run || {
4519862bcd1aSmrg	      if $finalize; then
452088de56ccSmrg	        tmpdir=`func_mktempdir`
452188de56ccSmrg		func_basename "$file$stripped_ext"
4522862bcd1aSmrg		file=$func_basename_result
4523862bcd1aSmrg	        outputname=$tmpdir/$file
452488de56ccSmrg	        # Replace the output file specification.
4525e9fcaa8aSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
452688de56ccSmrg
4527862bcd1aSmrg	        $opt_quiet || {
452888de56ccSmrg	          func_quote_for_expand "$relink_command"
452988de56ccSmrg		  eval "func_echo $func_quote_for_expand_result"
453088de56ccSmrg	        }
453188de56ccSmrg	        if eval "$relink_command"; then :
453288de56ccSmrg	          else
4533862bcd1aSmrg		  func_error "error: relink '$file' with the above command before installing it"
453488de56ccSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
453588de56ccSmrg		  continue
453688de56ccSmrg	        fi
4537862bcd1aSmrg	        file=$outputname
453888de56ccSmrg	      else
4539862bcd1aSmrg	        func_warning "cannot relink '$file'"
454088de56ccSmrg	      fi
454188de56ccSmrg	    }
454288de56ccSmrg	  else
454388de56ccSmrg	    # Install the binary that we compiled earlier.
4544e9fcaa8aSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4545b4ee4795Smrg	  fi
454688de56ccSmrg	fi
454788de56ccSmrg
454888de56ccSmrg	# remove .exe since cygwin /usr/bin/install will append another
454988de56ccSmrg	# one anyway
455088de56ccSmrg	case $install_prog,$host in
455188de56ccSmrg	*/usr/bin/install*,*cygwin*)
455288de56ccSmrg	  case $file:$destfile in
455388de56ccSmrg	  *.exe:*.exe)
455488de56ccSmrg	    # this is ok
455588de56ccSmrg	    ;;
455688de56ccSmrg	  *.exe:*)
455788de56ccSmrg	    destfile=$destfile.exe
455888de56ccSmrg	    ;;
455988de56ccSmrg	  *:*.exe)
456088de56ccSmrg	    func_stripname '' '.exe' "$destfile"
456188de56ccSmrg	    destfile=$func_stripname_result
456288de56ccSmrg	    ;;
456388de56ccSmrg	  esac
4564b4ee4795Smrg	  ;;
4565b4ee4795Smrg	esac
456688de56ccSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
456788de56ccSmrg	$opt_dry_run || if test -n "$outputname"; then
456888de56ccSmrg	  ${RM}r "$tmpdir"
456988de56ccSmrg	fi
457088de56ccSmrg	;;
457188de56ccSmrg      esac
457288de56ccSmrg    done
45731ab64890Smrg
457488de56ccSmrg    for file in $staticlibs; do
457588de56ccSmrg      func_basename "$file"
4576862bcd1aSmrg      name=$func_basename_result
457788de56ccSmrg
457888de56ccSmrg      # Set up the ranlib parameters.
4579862bcd1aSmrg      oldlib=$destdir/$name
4580eb411b4bSmrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4581eb411b4bSmrg      tool_oldlib=$func_to_tool_file_result
458288de56ccSmrg
458388de56ccSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
458488de56ccSmrg
458588de56ccSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
4586eb411b4bSmrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
458788de56ccSmrg      fi
458888de56ccSmrg
458988de56ccSmrg      # Do each command in the postinstall commands.
459088de56ccSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
459188de56ccSmrg    done
459288de56ccSmrg
459388de56ccSmrg    test -n "$future_libdirs" && \
4594862bcd1aSmrg      func_warning "remember to run '$progname --finish$future_libdirs'"
459588de56ccSmrg
459688de56ccSmrg    if test -n "$current_libdirs"; then
459788de56ccSmrg      # Maybe just do a dry run.
459888de56ccSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
4599862bcd1aSmrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
460088de56ccSmrg    else
460188de56ccSmrg      exit $EXIT_SUCCESS
460288de56ccSmrg    fi
460388de56ccSmrg}
460488de56ccSmrg
4605862bcd1aSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
460688de56ccSmrg
460788de56ccSmrg
460888de56ccSmrg# func_generate_dlsyms outputname originator pic_p
460988de56ccSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
461088de56ccSmrg# a dlpreopen symbol table.
461188de56ccSmrgfunc_generate_dlsyms ()
461288de56ccSmrg{
4613862bcd1aSmrg    $debug_cmd
4614862bcd1aSmrg
4615862bcd1aSmrg    my_outputname=$1
4616862bcd1aSmrg    my_originator=$2
4617862bcd1aSmrg    my_pic_p=${3-false}
4618862bcd1aSmrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
461988de56ccSmrg    my_dlsyms=
462088de56ccSmrg
4621862bcd1aSmrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
462288de56ccSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
4623862bcd1aSmrg	my_dlsyms=${my_outputname}S.c
462488de56ccSmrg      else
462588de56ccSmrg	func_error "not configured to extract global symbols from dlpreopened files"
462688de56ccSmrg      fi
462788de56ccSmrg    fi
462888de56ccSmrg
462988de56ccSmrg    if test -n "$my_dlsyms"; then
463088de56ccSmrg      case $my_dlsyms in
463188de56ccSmrg      "") ;;
463288de56ccSmrg      *.c)
463388de56ccSmrg	# Discover the nlist of each of the dlfiles.
4634862bcd1aSmrg	nlist=$output_objdir/$my_outputname.nm
463588de56ccSmrg
463688de56ccSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
463788de56ccSmrg
463888de56ccSmrg	# Parse the name list into a source file.
463988de56ccSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
464088de56ccSmrg
464188de56ccSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
4642862bcd1aSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
4643862bcd1aSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
464488de56ccSmrg
464588de56ccSmrg#ifdef __cplusplus
464688de56ccSmrgextern \"C\" {
464788de56ccSmrg#endif
464888de56ccSmrg
4649862bcd1aSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4650e9fcaa8aSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4651e9fcaa8aSmrg#endif
4652e9fcaa8aSmrg
4653e9fcaa8aSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
4654862bcd1aSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
4655862bcd1aSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
4656e9fcaa8aSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
4657e9fcaa8aSmrg# define LT_DLSYM_CONST
4658862bcd1aSmrg#elif defined __osf__
4659e9fcaa8aSmrg/* This system does not cope well with relocations in const data.  */
4660e9fcaa8aSmrg# define LT_DLSYM_CONST
4661e9fcaa8aSmrg#else
4662e9fcaa8aSmrg# define LT_DLSYM_CONST const
4663e9fcaa8aSmrg#endif
4664e9fcaa8aSmrg
4665862bcd1aSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
4666862bcd1aSmrg
466788de56ccSmrg/* External symbol declarations for the compiler. */\
466888de56ccSmrg"
466988de56ccSmrg
4670862bcd1aSmrg	if test yes = "$dlself"; then
4671862bcd1aSmrg	  func_verbose "generating symbol list for '$output'"
467288de56ccSmrg
467388de56ccSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
467488de56ccSmrg
467588de56ccSmrg	  # Add our own program objects to the symbol list.
4676e9fcaa8aSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
467788de56ccSmrg	  for progfile in $progfiles; do
4678e9fcaa8aSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
4679862bcd1aSmrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4680e9fcaa8aSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
468188de56ccSmrg	  done
468288de56ccSmrg
468388de56ccSmrg	  if test -n "$exclude_expsyms"; then
468488de56ccSmrg	    $opt_dry_run || {
468588de56ccSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
468688de56ccSmrg	      eval '$MV "$nlist"T "$nlist"'
468788de56ccSmrg	    }
4688b4ee4795Smrg	  fi
468988de56ccSmrg
469088de56ccSmrg	  if test -n "$export_symbols_regex"; then
469188de56ccSmrg	    $opt_dry_run || {
469288de56ccSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
469388de56ccSmrg	      eval '$MV "$nlist"T "$nlist"'
469488de56ccSmrg	    }
469588de56ccSmrg	  fi
469688de56ccSmrg
469788de56ccSmrg	  # Prepare the list of exported symbols
469888de56ccSmrg	  if test -z "$export_symbols"; then
4699862bcd1aSmrg	    export_symbols=$output_objdir/$outputname.exp
470088de56ccSmrg	    $opt_dry_run || {
470188de56ccSmrg	      $RM $export_symbols
4702862bcd1aSmrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
470388de56ccSmrg	      case $host in
470488de56ccSmrg	      *cygwin* | *mingw* | *cegcc* )
470588de56ccSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
470688de56ccSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
470788de56ccSmrg	        ;;
470888de56ccSmrg	      esac
470988de56ccSmrg	    }
4710b4ee4795Smrg	  else
471188de56ccSmrg	    $opt_dry_run || {
4712862bcd1aSmrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
471388de56ccSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
471488de56ccSmrg	      eval '$MV "$nlist"T "$nlist"'
471588de56ccSmrg	      case $host in
4716e9fcaa8aSmrg	        *cygwin* | *mingw* | *cegcc* )
471788de56ccSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
471888de56ccSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
471988de56ccSmrg	          ;;
472088de56ccSmrg	      esac
472188de56ccSmrg	    }
4722b4ee4795Smrg	  fi
472388de56ccSmrg	fi
47241ab64890Smrg
472588de56ccSmrg	for dlprefile in $dlprefiles; do
4726862bcd1aSmrg	  func_verbose "extracting global C symbols from '$dlprefile'"
472788de56ccSmrg	  func_basename "$dlprefile"
4728862bcd1aSmrg	  name=$func_basename_result
4729e9fcaa8aSmrg          case $host in
4730e9fcaa8aSmrg	    *cygwin* | *mingw* | *cegcc* )
4731e9fcaa8aSmrg	      # if an import library, we need to obtain dlname
4732e9fcaa8aSmrg	      if func_win32_import_lib_p "$dlprefile"; then
4733e9fcaa8aSmrg	        func_tr_sh "$dlprefile"
4734e9fcaa8aSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
4735862bcd1aSmrg	        dlprefile_dlbasename=
4736e9fcaa8aSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4737e9fcaa8aSmrg	          # Use subshell, to avoid clobbering current variable values
4738e9fcaa8aSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
4739862bcd1aSmrg	          if test -n "$dlprefile_dlname"; then
4740e9fcaa8aSmrg	            func_basename "$dlprefile_dlname"
4741862bcd1aSmrg	            dlprefile_dlbasename=$func_basename_result
4742e9fcaa8aSmrg	          else
4743e9fcaa8aSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
4744e9fcaa8aSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
4745e9fcaa8aSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
4746e9fcaa8aSmrg	          fi
4747e9fcaa8aSmrg	        fi
4748e9fcaa8aSmrg	        $opt_dry_run || {
4749862bcd1aSmrg	          if test -n "$dlprefile_dlbasename"; then
4750e9fcaa8aSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4751e9fcaa8aSmrg	          else
4752e9fcaa8aSmrg	            func_warning "Could not compute DLL name from $name"
4753e9fcaa8aSmrg	            eval '$ECHO ": $name " >> "$nlist"'
4754e9fcaa8aSmrg	          fi
4755e9fcaa8aSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4756e9fcaa8aSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4757e9fcaa8aSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4758e9fcaa8aSmrg	        }
4759e9fcaa8aSmrg	      else # not an import lib
4760e9fcaa8aSmrg	        $opt_dry_run || {
4761e9fcaa8aSmrg	          eval '$ECHO ": $name " >> "$nlist"'
4762e9fcaa8aSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4763e9fcaa8aSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4764e9fcaa8aSmrg	        }
4765e9fcaa8aSmrg	      fi
4766e9fcaa8aSmrg	    ;;
4767e9fcaa8aSmrg	    *)
4768e9fcaa8aSmrg	      $opt_dry_run || {
4769e9fcaa8aSmrg	        eval '$ECHO ": $name " >> "$nlist"'
4770e9fcaa8aSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4771e9fcaa8aSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4772e9fcaa8aSmrg	      }
4773e9fcaa8aSmrg	    ;;
4774e9fcaa8aSmrg          esac
477588de56ccSmrg	done
477688de56ccSmrg
477788de56ccSmrg	$opt_dry_run || {
477888de56ccSmrg	  # Make sure we have at least an empty file.
477988de56ccSmrg	  test -f "$nlist" || : > "$nlist"
478088de56ccSmrg
478188de56ccSmrg	  if test -n "$exclude_expsyms"; then
478288de56ccSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
478388de56ccSmrg	    $MV "$nlist"T "$nlist"
4784b4ee4795Smrg	  fi
478588de56ccSmrg
478688de56ccSmrg	  # Try sorting and uniquifying the output.
478788de56ccSmrg	  if $GREP -v "^: " < "$nlist" |
478888de56ccSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
478988de56ccSmrg		sort -k 3
479088de56ccSmrg	      else
479188de56ccSmrg		sort +2
479288de56ccSmrg	      fi |
479388de56ccSmrg	      uniq > "$nlist"S; then
479488de56ccSmrg	    :
4795b4ee4795Smrg	  else
479688de56ccSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
4797b4ee4795Smrg	  fi
47981ab64890Smrg
479988de56ccSmrg	  if test -f "$nlist"S; then
480088de56ccSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
4801b4ee4795Smrg	  else
4802e9fcaa8aSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
4803b4ee4795Smrg	  fi
48041ab64890Smrg
4805862bcd1aSmrg	  func_show_eval '$RM "${nlist}I"'
4806862bcd1aSmrg	  if test -n "$global_symbol_to_import"; then
4807862bcd1aSmrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
4808862bcd1aSmrg	  fi
4809862bcd1aSmrg
4810e9fcaa8aSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
48111ab64890Smrg
481288de56ccSmrg/* The mapping between symbol names and symbols.  */
481388de56ccSmrgtypedef struct {
481488de56ccSmrg  const char *name;
481588de56ccSmrg  void *address;
481688de56ccSmrg} lt_dlsymlist;
4817e9fcaa8aSmrgextern LT_DLSYM_CONST lt_dlsymlist
4818862bcd1aSmrglt_${my_prefix}_LTX_preloaded_symbols[];\
4819862bcd1aSmrg"
4820862bcd1aSmrg
4821862bcd1aSmrg	  if test -s "$nlist"I; then
4822862bcd1aSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
4823862bcd1aSmrgstatic void lt_syminit(void)
4824862bcd1aSmrg{
4825862bcd1aSmrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
4826862bcd1aSmrg  for (; symbol->name; ++symbol)
4827862bcd1aSmrg    {"
4828862bcd1aSmrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
4829862bcd1aSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
4830862bcd1aSmrg    }
4831862bcd1aSmrg}"
4832862bcd1aSmrg	  fi
4833862bcd1aSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
4834e9fcaa8aSmrgLT_DLSYM_CONST lt_dlsymlist
483588de56ccSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
4836862bcd1aSmrg{ {\"$my_originator\", (void *) 0},"
4837862bcd1aSmrg
4838862bcd1aSmrg	  if test -s "$nlist"I; then
4839862bcd1aSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
4840862bcd1aSmrg  {\"@INIT@\", (void *) &lt_syminit},"
4841862bcd1aSmrg	  fi
48421ab64890Smrg
484388de56ccSmrg	  case $need_lib_prefix in
484488de56ccSmrg	  no)
484588de56ccSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
484688de56ccSmrg	    ;;
484788de56ccSmrg	  *)
484888de56ccSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
484988de56ccSmrg	    ;;
485088de56ccSmrg	  esac
4851e9fcaa8aSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
485288de56ccSmrg  {0, (void *) 0}
485388de56ccSmrg};
48541ab64890Smrg
485588de56ccSmrg/* This works around a problem in FreeBSD linker */
485688de56ccSmrg#ifdef FREEBSD_WORKAROUND
485788de56ccSmrgstatic const void *lt_preloaded_setup() {
485888de56ccSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
485988de56ccSmrg}
486088de56ccSmrg#endif
486188de56ccSmrg
486288de56ccSmrg#ifdef __cplusplus
486388de56ccSmrg}
486488de56ccSmrg#endif\
486588de56ccSmrg"
486688de56ccSmrg	} # !$opt_dry_run
486788de56ccSmrg
486888de56ccSmrg	pic_flag_for_symtable=
486988de56ccSmrg	case "$compile_command " in
487088de56ccSmrg	*" -static "*) ;;
487188de56ccSmrg	*)
487288de56ccSmrg	  case $host in
487388de56ccSmrg	  # compiling the symbol table file with pic_flag works around
487488de56ccSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
487588de56ccSmrg	  # linked before any other PIC object.  But we must not use
487688de56ccSmrg	  # pic_flag when linking with -static.  The problem exists in
487788de56ccSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4878eb411b4bSmrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
487988de56ccSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
488088de56ccSmrg	  *-*-hpux*)
488188de56ccSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
488288de56ccSmrg	  *)
4883862bcd1aSmrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
488488de56ccSmrg	    ;;
488588de56ccSmrg	  esac
488688de56ccSmrg	  ;;
488788de56ccSmrg	esac
488888de56ccSmrg	symtab_cflags=
488988de56ccSmrg	for arg in $LTCFLAGS; do
489088de56ccSmrg	  case $arg in
489188de56ccSmrg	  -pie | -fpie | -fPIE) ;;
4892e9fcaa8aSmrg	  *) func_append symtab_cflags " $arg" ;;
489388de56ccSmrg	  esac
489488de56ccSmrg	done
48951ab64890Smrg
489688de56ccSmrg	# Now compile the dynamic symbol file.
489788de56ccSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
48982e9c7c8cSmrg
489988de56ccSmrg	# Clean up the generated files.
4900862bcd1aSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
49011ab64890Smrg
490288de56ccSmrg	# Transform the symbol file into the correct name.
4903862bcd1aSmrg	symfileobj=$output_objdir/${my_outputname}S.$objext
490488de56ccSmrg	case $host in
490588de56ccSmrg	*cygwin* | *mingw* | *cegcc* )
490688de56ccSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
4907e9fcaa8aSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4908e9fcaa8aSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
490988de56ccSmrg	  else
4910e9fcaa8aSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4911e9fcaa8aSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4912b4ee4795Smrg	  fi
491388de56ccSmrg	  ;;
491488de56ccSmrg	*)
4915e9fcaa8aSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4916e9fcaa8aSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
491788de56ccSmrg	  ;;
491888de56ccSmrg	esac
491988de56ccSmrg	;;
492088de56ccSmrg      *)
4921862bcd1aSmrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
492288de56ccSmrg	;;
492388de56ccSmrg      esac
492488de56ccSmrg    else
492588de56ccSmrg      # We keep going just in case the user didn't refer to
492688de56ccSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
492788de56ccSmrg      # really was required.
49281ab64890Smrg
492988de56ccSmrg      # Nullify the symbol file.
4930e9fcaa8aSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4931e9fcaa8aSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
493288de56ccSmrg    fi
493388de56ccSmrg}
49342e9c7c8cSmrg
4935862bcd1aSmrg# func_cygming_gnu_implib_p ARG
4936862bcd1aSmrg# This predicate returns with zero status (TRUE) if
4937862bcd1aSmrg# ARG is a GNU/binutils-style import library. Returns
4938862bcd1aSmrg# with nonzero status (FALSE) otherwise.
4939862bcd1aSmrgfunc_cygming_gnu_implib_p ()
4940862bcd1aSmrg{
4941862bcd1aSmrg  $debug_cmd
4942862bcd1aSmrg
4943862bcd1aSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
4944862bcd1aSmrg  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)$'`
4945862bcd1aSmrg  test -n "$func_cygming_gnu_implib_tmp"
4946862bcd1aSmrg}
4947862bcd1aSmrg
4948862bcd1aSmrg# func_cygming_ms_implib_p ARG
4949862bcd1aSmrg# This predicate returns with zero status (TRUE) if
4950862bcd1aSmrg# ARG is an MS-style import library. Returns
4951862bcd1aSmrg# with nonzero status (FALSE) otherwise.
4952862bcd1aSmrgfunc_cygming_ms_implib_p ()
4953862bcd1aSmrg{
4954862bcd1aSmrg  $debug_cmd
4955862bcd1aSmrg
4956862bcd1aSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
4957862bcd1aSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
4958862bcd1aSmrg  test -n "$func_cygming_ms_implib_tmp"
4959862bcd1aSmrg}
4960862bcd1aSmrg
496188de56ccSmrg# func_win32_libid arg
496288de56ccSmrg# return the library type of file 'arg'
496388de56ccSmrg#
496488de56ccSmrg# Need a lot of goo to handle *both* DLLs and import libs
496588de56ccSmrg# Has to be a shell function in order to 'eat' the argument
496688de56ccSmrg# that is supplied when $file_magic_command is called.
4967e9fcaa8aSmrg# Despite the name, also deal with 64 bit binaries.
496888de56ccSmrgfunc_win32_libid ()
496988de56ccSmrg{
4970862bcd1aSmrg  $debug_cmd
4971862bcd1aSmrg
4972862bcd1aSmrg  win32_libid_type=unknown
497388de56ccSmrg  win32_fileres=`file -L $1 2>/dev/null`
497488de56ccSmrg  case $win32_fileres in
497588de56ccSmrg  *ar\ archive\ import\ library*) # definitely import
497688de56ccSmrg    win32_libid_type="x86 archive import"
497788de56ccSmrg    ;;
497888de56ccSmrg  *ar\ archive*) # could be an import, or static
4979e9fcaa8aSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
498088de56ccSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
4981e9fcaa8aSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
4982862bcd1aSmrg      case $nm_interface in
4983862bcd1aSmrg      "MS dumpbin")
4984862bcd1aSmrg	if func_cygming_ms_implib_p "$1" ||
4985862bcd1aSmrg	   func_cygming_gnu_implib_p "$1"
4986862bcd1aSmrg	then
4987862bcd1aSmrg	  win32_nmres=import
4988862bcd1aSmrg	else
4989862bcd1aSmrg	  win32_nmres=
4990862bcd1aSmrg	fi
4991862bcd1aSmrg	;;
4992862bcd1aSmrg      *)
4993862bcd1aSmrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
4994862bcd1aSmrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
4995862bcd1aSmrg	  $SED -n -e '
499688de56ccSmrg	    1,100{
499788de56ccSmrg		/ I /{
4998862bcd1aSmrg		    s|.*|import|
499988de56ccSmrg		    p
500088de56ccSmrg		    q
500188de56ccSmrg		}
500288de56ccSmrg	    }'`
5003862bcd1aSmrg	;;
5004862bcd1aSmrg      esac
500588de56ccSmrg      case $win32_nmres in
500688de56ccSmrg      import*)  win32_libid_type="x86 archive import";;
500788de56ccSmrg      *)        win32_libid_type="x86 archive static";;
500888de56ccSmrg      esac
500988de56ccSmrg    fi
501088de56ccSmrg    ;;
501188de56ccSmrg  *DLL*)
501288de56ccSmrg    win32_libid_type="x86 DLL"
501388de56ccSmrg    ;;
501488de56ccSmrg  *executable*) # but shell scripts are "executable" too...
501588de56ccSmrg    case $win32_fileres in
501688de56ccSmrg    *MS\ Windows\ PE\ Intel*)
501788de56ccSmrg      win32_libid_type="x86 DLL"
501888de56ccSmrg      ;;
501988de56ccSmrg    esac
502088de56ccSmrg    ;;
502188de56ccSmrg  esac
502288de56ccSmrg  $ECHO "$win32_libid_type"
502388de56ccSmrg}
50242e9c7c8cSmrg
5025e9fcaa8aSmrg# func_cygming_dll_for_implib ARG
5026e9fcaa8aSmrg#
5027e9fcaa8aSmrg# Platform-specific function to extract the
5028e9fcaa8aSmrg# name of the DLL associated with the specified
5029e9fcaa8aSmrg# import library ARG.
5030e9fcaa8aSmrg# Invoked by eval'ing the libtool variable
5031e9fcaa8aSmrg#    $sharedlib_from_linklib_cmd
5032e9fcaa8aSmrg# Result is available in the variable
5033e9fcaa8aSmrg#    $sharedlib_from_linklib_result
5034e9fcaa8aSmrgfunc_cygming_dll_for_implib ()
5035e9fcaa8aSmrg{
5036862bcd1aSmrg  $debug_cmd
5037862bcd1aSmrg
5038e9fcaa8aSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
5039e9fcaa8aSmrg}
5040e9fcaa8aSmrg
5041e9fcaa8aSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
5042e9fcaa8aSmrg#
5043e9fcaa8aSmrg# The is the core of a fallback implementation of a
5044e9fcaa8aSmrg# platform-specific function to extract the name of the
5045e9fcaa8aSmrg# DLL associated with the specified import library LIBNAME.
5046e9fcaa8aSmrg#
5047e9fcaa8aSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
5048e9fcaa8aSmrg# on the platform and compiler that created the implib.
5049e9fcaa8aSmrg#
5050e9fcaa8aSmrg# Echos the name of the DLL associated with the
5051e9fcaa8aSmrg# specified import library.
5052e9fcaa8aSmrgfunc_cygming_dll_for_implib_fallback_core ()
5053e9fcaa8aSmrg{
5054862bcd1aSmrg  $debug_cmd
5055862bcd1aSmrg
5056e9fcaa8aSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5057e9fcaa8aSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5058e9fcaa8aSmrg    $SED '/^Contents of section '"$match_literal"':/{
5059e9fcaa8aSmrg      # Place marker at beginning of archive member dllname section
5060e9fcaa8aSmrg      s/.*/====MARK====/
5061e9fcaa8aSmrg      p
5062e9fcaa8aSmrg      d
5063e9fcaa8aSmrg    }
5064e9fcaa8aSmrg    # These lines can sometimes be longer than 43 characters, but
5065e9fcaa8aSmrg    # are always uninteresting
5066e9fcaa8aSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
5067e9fcaa8aSmrg    /^In archive [^:]*:/d
5068e9fcaa8aSmrg    # Ensure marker is printed
5069e9fcaa8aSmrg    /^====MARK====/p
5070e9fcaa8aSmrg    # Remove all lines with less than 43 characters
5071e9fcaa8aSmrg    /^.\{43\}/!d
5072e9fcaa8aSmrg    # From remaining lines, remove first 43 characters
5073e9fcaa8aSmrg    s/^.\{43\}//' |
5074e9fcaa8aSmrg    $SED -n '
5075e9fcaa8aSmrg      # Join marker and all lines until next marker into a single line
5076e9fcaa8aSmrg      /^====MARK====/ b para
5077e9fcaa8aSmrg      H
5078e9fcaa8aSmrg      $ b para
5079e9fcaa8aSmrg      b
5080e9fcaa8aSmrg      :para
5081e9fcaa8aSmrg      x
5082e9fcaa8aSmrg      s/\n//g
5083e9fcaa8aSmrg      # Remove the marker
5084e9fcaa8aSmrg      s/^====MARK====//
5085e9fcaa8aSmrg      # Remove trailing dots and whitespace
5086e9fcaa8aSmrg      s/[\. \t]*$//
5087e9fcaa8aSmrg      # Print
5088e9fcaa8aSmrg      /./p' |
5089e9fcaa8aSmrg    # we now have a list, one entry per line, of the stringified
5090e9fcaa8aSmrg    # contents of the appropriate section of all members of the
5091862bcd1aSmrg    # archive that possess that section. Heuristic: eliminate
5092862bcd1aSmrg    # all those that have a first or second character that is
5093e9fcaa8aSmrg    # a '.' (that is, objdump's representation of an unprintable
5094e9fcaa8aSmrg    # character.) This should work for all archives with less than
5095e9fcaa8aSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
5096e9fcaa8aSmrg    # begins with a literal '.' or a single character followed by
5097e9fcaa8aSmrg    # a '.'.
5098e9fcaa8aSmrg    #
5099e9fcaa8aSmrg    # Of those that remain, print the first one.
5100e9fcaa8aSmrg    $SED -e '/^\./d;/^.\./d;q'
5101e9fcaa8aSmrg}
5102e9fcaa8aSmrg
5103e9fcaa8aSmrg# func_cygming_dll_for_implib_fallback ARG
5104e9fcaa8aSmrg# Platform-specific function to extract the
5105e9fcaa8aSmrg# name of the DLL associated with the specified
5106e9fcaa8aSmrg# import library ARG.
5107e9fcaa8aSmrg#
5108e9fcaa8aSmrg# This fallback implementation is for use when $DLLTOOL
5109e9fcaa8aSmrg# does not support the --identify-strict option.
5110e9fcaa8aSmrg# Invoked by eval'ing the libtool variable
5111e9fcaa8aSmrg#    $sharedlib_from_linklib_cmd
5112e9fcaa8aSmrg# Result is available in the variable
5113e9fcaa8aSmrg#    $sharedlib_from_linklib_result
5114e9fcaa8aSmrgfunc_cygming_dll_for_implib_fallback ()
5115e9fcaa8aSmrg{
5116862bcd1aSmrg  $debug_cmd
5117862bcd1aSmrg
5118862bcd1aSmrg  if func_cygming_gnu_implib_p "$1"; then
5119e9fcaa8aSmrg    # binutils import library
5120e9fcaa8aSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
5121862bcd1aSmrg  elif func_cygming_ms_implib_p "$1"; then
5122e9fcaa8aSmrg    # ms-generated import library
5123e9fcaa8aSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5124e9fcaa8aSmrg  else
5125e9fcaa8aSmrg    # unknown
5126862bcd1aSmrg    sharedlib_from_linklib_result=
5127e9fcaa8aSmrg  fi
5128e9fcaa8aSmrg}
51292e9c7c8cSmrg
51302e9c7c8cSmrg
513188de56ccSmrg# func_extract_an_archive dir oldlib
513288de56ccSmrgfunc_extract_an_archive ()
513388de56ccSmrg{
5134862bcd1aSmrg    $debug_cmd
5135862bcd1aSmrg
5136862bcd1aSmrg    f_ex_an_ar_dir=$1; shift
5137862bcd1aSmrg    f_ex_an_ar_oldlib=$1
5138862bcd1aSmrg    if test yes = "$lock_old_archive_extraction"; then
5139e9fcaa8aSmrg      lockfile=$f_ex_an_ar_oldlib.lock
5140e9fcaa8aSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5141e9fcaa8aSmrg	func_echo "Waiting for $lockfile to be removed"
5142e9fcaa8aSmrg	sleep 2
5143e9fcaa8aSmrg      done
5144e9fcaa8aSmrg    fi
5145e9fcaa8aSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5146e9fcaa8aSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
5147862bcd1aSmrg    if test yes = "$lock_old_archive_extraction"; then
5148e9fcaa8aSmrg      $opt_dry_run || rm -f "$lockfile"
5149e9fcaa8aSmrg    fi
515088de56ccSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
515188de56ccSmrg     :
515288de56ccSmrg    else
515388de56ccSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
515488de56ccSmrg    fi
515588de56ccSmrg}
51561ab64890Smrg
51571ab64890Smrg
515888de56ccSmrg# func_extract_archives gentop oldlib ...
515988de56ccSmrgfunc_extract_archives ()
516088de56ccSmrg{
5161862bcd1aSmrg    $debug_cmd
5162862bcd1aSmrg
5163862bcd1aSmrg    my_gentop=$1; shift
516488de56ccSmrg    my_oldlibs=${1+"$@"}
5165862bcd1aSmrg    my_oldobjs=
5166862bcd1aSmrg    my_xlib=
5167862bcd1aSmrg    my_xabs=
5168862bcd1aSmrg    my_xdir=
51691ab64890Smrg
517088de56ccSmrg    for my_xlib in $my_oldlibs; do
517188de56ccSmrg      # Extract the objects.
517288de56ccSmrg      case $my_xlib in
5173862bcd1aSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
517488de56ccSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
517588de56ccSmrg      esac
517688de56ccSmrg      func_basename "$my_xlib"
5177862bcd1aSmrg      my_xlib=$func_basename_result
517888de56ccSmrg      my_xlib_u=$my_xlib
517988de56ccSmrg      while :; do
518088de56ccSmrg        case " $extracted_archives " in
518188de56ccSmrg	*" $my_xlib_u "*)
518288de56ccSmrg	  func_arith $extracted_serial + 1
518388de56ccSmrg	  extracted_serial=$func_arith_result
518488de56ccSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
518588de56ccSmrg	*) break ;;
518688de56ccSmrg	esac
518788de56ccSmrg      done
518888de56ccSmrg      extracted_archives="$extracted_archives $my_xlib_u"
5189862bcd1aSmrg      my_xdir=$my_gentop/$my_xlib_u
51901ab64890Smrg
519188de56ccSmrg      func_mkdir_p "$my_xdir"
51922e9c7c8cSmrg
519388de56ccSmrg      case $host in
519488de56ccSmrg      *-darwin*)
519588de56ccSmrg	func_verbose "Extracting $my_xabs"
519688de56ccSmrg	# Do not bother doing anything if just a dry run
519788de56ccSmrg	$opt_dry_run || {
519888de56ccSmrg	  darwin_orig_dir=`pwd`
519988de56ccSmrg	  cd $my_xdir || exit $?
520088de56ccSmrg	  darwin_archive=$my_xabs
520188de56ccSmrg	  darwin_curdir=`pwd`
5202862bcd1aSmrg	  func_basename "$darwin_archive"
5203862bcd1aSmrg	  darwin_base_archive=$func_basename_result
520488de56ccSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
520588de56ccSmrg	  if test -n "$darwin_arches"; then
520688de56ccSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
520788de56ccSmrg	    darwin_arch=
520888de56ccSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
5209862bcd1aSmrg	    for darwin_arch in  $darwin_arches; do
5210862bcd1aSmrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
5211862bcd1aSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
5212862bcd1aSmrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
5213862bcd1aSmrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
521488de56ccSmrg	      cd "$darwin_curdir"
5215862bcd1aSmrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
521688de56ccSmrg	    done # $darwin_arches
521788de56ccSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
5218862bcd1aSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
521988de56ccSmrg	    darwin_file=
522088de56ccSmrg	    darwin_files=
522188de56ccSmrg	    for darwin_file in $darwin_filelist; do
5222e9fcaa8aSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
522388de56ccSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
522488de56ccSmrg	    done # $darwin_filelist
522588de56ccSmrg	    $RM -rf unfat-$$
522688de56ccSmrg	    cd "$darwin_orig_dir"
5227b4ee4795Smrg	  else
522888de56ccSmrg	    cd $darwin_orig_dir
522988de56ccSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
523088de56ccSmrg	  fi # $darwin_arches
523188de56ccSmrg	} # !$opt_dry_run
523288de56ccSmrg	;;
523388de56ccSmrg      *)
523488de56ccSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
523588de56ccSmrg	;;
523688de56ccSmrg      esac
5237e9fcaa8aSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
523888de56ccSmrg    done
52391ab64890Smrg
5240862bcd1aSmrg    func_extract_archives_result=$my_oldobjs
524188de56ccSmrg}
52421ab64890Smrg
52431ab64890Smrg
5244e9fcaa8aSmrg# func_emit_wrapper [arg=no]
5245e9fcaa8aSmrg#
5246e9fcaa8aSmrg# Emit a libtool wrapper script on stdout.
5247e9fcaa8aSmrg# Don't directly open a file because we may want to
5248e9fcaa8aSmrg# incorporate the script contents within a cygwin/mingw
5249e9fcaa8aSmrg# wrapper executable.  Must ONLY be called from within
5250e9fcaa8aSmrg# func_mode_link because it depends on a number of variables
5251e9fcaa8aSmrg# set therein.
525288de56ccSmrg#
5253e9fcaa8aSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5254e9fcaa8aSmrg# variable will take.  If 'yes', then the emitted script
5255862bcd1aSmrg# will assume that the directory where it is stored is
5256e9fcaa8aSmrg# the $objdir directory.  This is a cygwin/mingw-specific
5257e9fcaa8aSmrg# behavior.
5258e9fcaa8aSmrgfunc_emit_wrapper ()
525988de56ccSmrg{
5260e9fcaa8aSmrg	func_emit_wrapper_arg1=${1-no}
5261b4ee4795Smrg
526288de56ccSmrg	$ECHO "\
526388de56ccSmrg#! $SHELL
52641ab64890Smrg
526588de56ccSmrg# $output - temporary wrapper script for $objdir/$outputname
5266862bcd1aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
526788de56ccSmrg#
526888de56ccSmrg# The $output program cannot be directly executed until all the libtool
526988de56ccSmrg# libraries that it depends on are installed.
527088de56ccSmrg#
527188de56ccSmrg# This wrapper script should never be moved out of the build directory.
527288de56ccSmrg# If it is, it will not operate correctly.
52731ab64890Smrg
527488de56ccSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
527588de56ccSmrg# metacharacters that are still active within double-quoted strings.
527688de56ccSmrgsed_quote_subst='$sed_quote_subst'
52771ab64890Smrg
527888de56ccSmrg# Be Bourne compatible
527988de56ccSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
528088de56ccSmrg  emulate sh
528188de56ccSmrg  NULLCMD=:
528288de56ccSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
528388de56ccSmrg  # is contrary to our usage.  Disable this feature.
528488de56ccSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
528588de56ccSmrg  setopt NO_GLOB_SUBST
528688de56ccSmrgelse
528788de56ccSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
528888de56ccSmrgfi
528988de56ccSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
529088de56ccSmrgDUALCASE=1; export DUALCASE # for MKS sh
52911ab64890Smrg
529288de56ccSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
529388de56ccSmrg# if CDPATH is set.
529488de56ccSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
52951ab64890Smrg
529688de56ccSmrgrelink_command=\"$relink_command\"
52971ab64890Smrg
529888de56ccSmrg# This environment variable determines our operation mode.
529988de56ccSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
530088de56ccSmrg  # install mode needs the following variables:
530188de56ccSmrg  generated_by_libtool_version='$macro_version'
530288de56ccSmrg  notinst_deplibs='$notinst_deplibs'
530388de56ccSmrgelse
530488de56ccSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
530588de56ccSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5306e9fcaa8aSmrg    file=\"\$0\""
5307e9fcaa8aSmrg
530838ae11fcSmrg    func_quote "$ECHO"
530938ae11fcSmrg    qECHO=$func_quote_result
5310e9fcaa8aSmrg    $ECHO "\
5311e9fcaa8aSmrg
5312e9fcaa8aSmrg# A function that is used when there is no print builtin or printf.
5313e9fcaa8aSmrgfunc_fallback_echo ()
5314e9fcaa8aSmrg{
5315e9fcaa8aSmrg  eval 'cat <<_LTECHO_EOF
5316e9fcaa8aSmrg\$1
5317e9fcaa8aSmrg_LTECHO_EOF'
5318e9fcaa8aSmrg}
5319e9fcaa8aSmrg    ECHO=\"$qECHO\"
5320e9fcaa8aSmrg  fi
5321e9fcaa8aSmrg
5322e9fcaa8aSmrg# Very basic option parsing. These options are (a) specific to
5323e9fcaa8aSmrg# the libtool wrapper, (b) are identical between the wrapper
5324862bcd1aSmrg# /script/ and the wrapper /executable/ that is used only on
5325e9fcaa8aSmrg# windows platforms, and (c) all begin with the string "--lt-"
5326862bcd1aSmrg# (application programs are unlikely to have options that match
5327e9fcaa8aSmrg# this pattern).
5328e9fcaa8aSmrg#
5329e9fcaa8aSmrg# There are only two supported options: --lt-debug and
5330e9fcaa8aSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
5331e9fcaa8aSmrg#
5332e9fcaa8aSmrg# The first argument to this parsing function should be the
5333e9fcaa8aSmrg# script's $0 value, followed by "$@".
5334e9fcaa8aSmrglt_option_debug=
5335e9fcaa8aSmrgfunc_parse_lt_options ()
5336e9fcaa8aSmrg{
5337e9fcaa8aSmrg  lt_script_arg0=\$0
5338e9fcaa8aSmrg  shift
5339e9fcaa8aSmrg  for lt_opt
5340e9fcaa8aSmrg  do
5341e9fcaa8aSmrg    case \"\$lt_opt\" in
5342e9fcaa8aSmrg    --lt-debug) lt_option_debug=1 ;;
5343e9fcaa8aSmrg    --lt-dump-script)
5344e9fcaa8aSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5345e9fcaa8aSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5346e9fcaa8aSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5347e9fcaa8aSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
5348e9fcaa8aSmrg        exit 0
5349e9fcaa8aSmrg      ;;
5350e9fcaa8aSmrg    --lt-*)
5351e9fcaa8aSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5352e9fcaa8aSmrg        exit 1
5353e9fcaa8aSmrg      ;;
5354e9fcaa8aSmrg    esac
5355e9fcaa8aSmrg  done
5356e9fcaa8aSmrg
5357e9fcaa8aSmrg  # Print the debug banner immediately:
5358e9fcaa8aSmrg  if test -n \"\$lt_option_debug\"; then
5359862bcd1aSmrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5360e9fcaa8aSmrg  fi
5361e9fcaa8aSmrg}
5362e9fcaa8aSmrg
5363e9fcaa8aSmrg# Used when --lt-debug. Prints its arguments to stdout
5364e9fcaa8aSmrg# (redirection is the responsibility of the caller)
5365e9fcaa8aSmrgfunc_lt_dump_args ()
5366e9fcaa8aSmrg{
5367e9fcaa8aSmrg  lt_dump_args_N=1;
5368e9fcaa8aSmrg  for lt_arg
5369e9fcaa8aSmrg  do
5370862bcd1aSmrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5371e9fcaa8aSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5372e9fcaa8aSmrg  done
5373e9fcaa8aSmrg}
5374e9fcaa8aSmrg
5375e9fcaa8aSmrg# Core function for launching the target application
5376e9fcaa8aSmrgfunc_exec_program_core ()
5377e9fcaa8aSmrg{
537888de56ccSmrg"
5379e9fcaa8aSmrg  case $host in
5380e9fcaa8aSmrg  # Backslashes separate directories on plain windows
5381e9fcaa8aSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
5382e9fcaa8aSmrg    $ECHO "\
5383e9fcaa8aSmrg      if test -n \"\$lt_option_debug\"; then
5384862bcd1aSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5385e9fcaa8aSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5386e9fcaa8aSmrg      fi
5387e9fcaa8aSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5388e9fcaa8aSmrg"
5389e9fcaa8aSmrg    ;;
5390e9fcaa8aSmrg
5391e9fcaa8aSmrg  *)
5392e9fcaa8aSmrg    $ECHO "\
5393e9fcaa8aSmrg      if test -n \"\$lt_option_debug\"; then
5394862bcd1aSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5395e9fcaa8aSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5396e9fcaa8aSmrg      fi
5397e9fcaa8aSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5398e9fcaa8aSmrg"
5399e9fcaa8aSmrg    ;;
5400e9fcaa8aSmrg  esac
5401e9fcaa8aSmrg  $ECHO "\
5402e9fcaa8aSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5403e9fcaa8aSmrg      exit 1
5404e9fcaa8aSmrg}
5405e9fcaa8aSmrg
5406e9fcaa8aSmrg# A function to encapsulate launching the target application
5407e9fcaa8aSmrg# Strips options in the --lt-* namespace from \$@ and
5408e9fcaa8aSmrg# launches target application with the remaining arguments.
5409e9fcaa8aSmrgfunc_exec_program ()
5410e9fcaa8aSmrg{
5411eb411b4bSmrg  case \" \$* \" in
5412eb411b4bSmrg  *\\ --lt-*)
5413eb411b4bSmrg    for lt_wr_arg
5414eb411b4bSmrg    do
5415eb411b4bSmrg      case \$lt_wr_arg in
5416eb411b4bSmrg      --lt-*) ;;
5417eb411b4bSmrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5418eb411b4bSmrg      esac
5419eb411b4bSmrg      shift
5420eb411b4bSmrg    done ;;
5421eb411b4bSmrg  esac
5422e9fcaa8aSmrg  func_exec_program_core \${1+\"\$@\"}
5423e9fcaa8aSmrg}
5424e9fcaa8aSmrg
5425e9fcaa8aSmrg  # Parse options
5426e9fcaa8aSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
54271ab64890Smrg
542888de56ccSmrg  # Find the directory that this script lives in.
5429e9fcaa8aSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
543088de56ccSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
54311ab64890Smrg
543288de56ccSmrg  # Follow symbolic links until we get to the real thisdir.
5433e9fcaa8aSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
543488de56ccSmrg  while test -n \"\$file\"; do
5435e9fcaa8aSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
54361ab64890Smrg
543788de56ccSmrg    # If there was a directory component, then change thisdir.
543888de56ccSmrg    if test \"x\$destdir\" != \"x\$file\"; then
543988de56ccSmrg      case \"\$destdir\" in
544088de56ccSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
544188de56ccSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5442b4ee4795Smrg      esac
544388de56ccSmrg    fi
54441ab64890Smrg
5445e9fcaa8aSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5446e9fcaa8aSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
544788de56ccSmrg  done
54481ab64890Smrg
544988de56ccSmrg  # Usually 'no', except on cygwin/mingw when embedded into
545088de56ccSmrg  # the cwrapper.
5451e9fcaa8aSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
545288de56ccSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
545388de56ccSmrg    # special case for '.'
545488de56ccSmrg    if test \"\$thisdir\" = \".\"; then
545588de56ccSmrg      thisdir=\`pwd\`
545688de56ccSmrg    fi
545788de56ccSmrg    # remove .libs from thisdir
545888de56ccSmrg    case \"\$thisdir\" in
5459e9fcaa8aSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
546088de56ccSmrg    $objdir )   thisdir=. ;;
546188de56ccSmrg    esac
546288de56ccSmrg  fi
546388de56ccSmrg
546488de56ccSmrg  # Try to get the absolute directory name.
546588de56ccSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
546688de56ccSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
546788de56ccSmrg"
546888de56ccSmrg
5469862bcd1aSmrg	if test yes = "$fast_install"; then
547088de56ccSmrg	  $ECHO "\
547188de56ccSmrg  program=lt-'$outputname'$exeext
547288de56ccSmrg  progdir=\"\$thisdir/$objdir\"
547388de56ccSmrg
547488de56ccSmrg  if test ! -f \"\$progdir/\$program\" ||
5475862bcd1aSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
547688de56ccSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
547788de56ccSmrg
547888de56ccSmrg    file=\"\$\$-\$program\"
547988de56ccSmrg
548088de56ccSmrg    if test ! -d \"\$progdir\"; then
548188de56ccSmrg      $MKDIR \"\$progdir\"
548288de56ccSmrg    else
548388de56ccSmrg      $RM \"\$progdir/\$file\"
548488de56ccSmrg    fi"
548588de56ccSmrg
548688de56ccSmrg	  $ECHO "\
548788de56ccSmrg
548888de56ccSmrg    # relink executable if necessary
548988de56ccSmrg    if test -n \"\$relink_command\"; then
549088de56ccSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
549188de56ccSmrg      else
5492862bcd1aSmrg	\$ECHO \"\$relink_command_output\" >&2
549388de56ccSmrg	$RM \"\$progdir/\$file\"
549488de56ccSmrg	exit 1
5495b4ee4795Smrg      fi
549688de56ccSmrg    fi
54971ab64890Smrg
549888de56ccSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
549988de56ccSmrg    { $RM \"\$progdir/\$program\";
550088de56ccSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
550188de56ccSmrg    $RM \"\$progdir/\$file\"
550288de56ccSmrg  fi"
550388de56ccSmrg	else
550488de56ccSmrg	  $ECHO "\
550588de56ccSmrg  program='$outputname'
550688de56ccSmrg  progdir=\"\$thisdir/$objdir\"
550788de56ccSmrg"
5508b4ee4795Smrg	fi
55091ab64890Smrg
551088de56ccSmrg	$ECHO "\
55111ab64890Smrg
551288de56ccSmrg  if test -f \"\$progdir/\$program\"; then"
55131ab64890Smrg
5514e9fcaa8aSmrg	# fixup the dll searchpath if we need to.
5515e9fcaa8aSmrg	#
5516e9fcaa8aSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
5517e9fcaa8aSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
5518e9fcaa8aSmrg	# libraries must come first.
5519e9fcaa8aSmrg	if test -n "$dllsearchpath"; then
5520e9fcaa8aSmrg	  $ECHO "\
5521e9fcaa8aSmrg    # Add the dll search path components to the executable PATH
5522e9fcaa8aSmrg    PATH=$dllsearchpath:\$PATH
5523e9fcaa8aSmrg"
5524e9fcaa8aSmrg	fi
5525e9fcaa8aSmrg
552688de56ccSmrg	# Export our shlibpath_var if we have one.
5527862bcd1aSmrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
552888de56ccSmrg	  $ECHO "\
552988de56ccSmrg    # Add our own library path to $shlibpath_var
553088de56ccSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
553188de56ccSmrg
553288de56ccSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
553388de56ccSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
5534e9fcaa8aSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
55351ab64890Smrg
553688de56ccSmrg    export $shlibpath_var
553788de56ccSmrg"
5538b4ee4795Smrg	fi
55391ab64890Smrg
554088de56ccSmrg	$ECHO "\
554188de56ccSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
554288de56ccSmrg      # Run the actual program with our arguments.
5543e9fcaa8aSmrg      func_exec_program \${1+\"\$@\"}
554488de56ccSmrg    fi
554588de56ccSmrg  else
554688de56ccSmrg    # The program doesn't exist.
5547862bcd1aSmrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
554888de56ccSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5549e9fcaa8aSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
555088de56ccSmrg    exit 1
555188de56ccSmrg  fi
555288de56ccSmrgfi\
555388de56ccSmrg"
555488de56ccSmrg}
55551ab64890Smrg
55561ab64890Smrg
555788de56ccSmrg# func_emit_cwrapperexe_src
555888de56ccSmrg# emit the source code for a wrapper executable on stdout
555988de56ccSmrg# Must ONLY be called from within func_mode_link because
556088de56ccSmrg# it depends on a number of variable set therein.
556188de56ccSmrgfunc_emit_cwrapperexe_src ()
556288de56ccSmrg{
556388de56ccSmrg	cat <<EOF
55641ab64890Smrg
556588de56ccSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5566862bcd1aSmrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
55671ab64890Smrg
556888de56ccSmrg   The $output program cannot be directly executed until all the libtool
556988de56ccSmrg   libraries that it depends on are installed.
55701ab64890Smrg
557188de56ccSmrg   This wrapper executable should never be moved out of the build directory.
557288de56ccSmrg   If it is, it will not operate correctly.
557388de56ccSmrg*/
557488de56ccSmrgEOF
557588de56ccSmrg	    cat <<"EOF"
5576e9fcaa8aSmrg#ifdef _MSC_VER
5577e9fcaa8aSmrg# define _CRT_SECURE_NO_DEPRECATE 1
5578e9fcaa8aSmrg#endif
557988de56ccSmrg#include <stdio.h>
558088de56ccSmrg#include <stdlib.h>
558188de56ccSmrg#ifdef _MSC_VER
558288de56ccSmrg# include <direct.h>
558388de56ccSmrg# include <process.h>
558488de56ccSmrg# include <io.h>
558588de56ccSmrg#else
558688de56ccSmrg# include <unistd.h>
558788de56ccSmrg# include <stdint.h>
558888de56ccSmrg# ifdef __CYGWIN__
558988de56ccSmrg#  include <io.h>
5590e9fcaa8aSmrg# endif
5591e9fcaa8aSmrg#endif
5592e9fcaa8aSmrg#include <malloc.h>
5593e9fcaa8aSmrg#include <stdarg.h>
5594e9fcaa8aSmrg#include <assert.h>
5595e9fcaa8aSmrg#include <string.h>
5596e9fcaa8aSmrg#include <ctype.h>
5597e9fcaa8aSmrg#include <errno.h>
5598e9fcaa8aSmrg#include <fcntl.h>
5599e9fcaa8aSmrg#include <sys/stat.h>
5600e9fcaa8aSmrg
5601862bcd1aSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5602862bcd1aSmrg
5603e9fcaa8aSmrg/* declarations of non-ANSI functions */
5604862bcd1aSmrg#if defined __MINGW32__
5605e9fcaa8aSmrg# ifdef __STRICT_ANSI__
5606e9fcaa8aSmrgint _putenv (const char *);
5607e9fcaa8aSmrg# endif
5608862bcd1aSmrg#elif defined __CYGWIN__
5609e9fcaa8aSmrg# ifdef __STRICT_ANSI__
561088de56ccSmrgchar *realpath (const char *, char *);
561188de56ccSmrgint putenv (char *);
561288de56ccSmrgint setenv (const char *, const char *, int);
561388de56ccSmrg# endif
5614862bcd1aSmrg/* #elif defined other_platform || defined ... */
5615e9fcaa8aSmrg#endif
5616e9fcaa8aSmrg
5617e9fcaa8aSmrg/* portability defines, excluding path handling macros */
5618862bcd1aSmrg#if defined _MSC_VER
5619e9fcaa8aSmrg# define setmode _setmode
5620e9fcaa8aSmrg# define stat    _stat
5621e9fcaa8aSmrg# define chmod   _chmod
5622e9fcaa8aSmrg# define getcwd  _getcwd
5623e9fcaa8aSmrg# define putenv  _putenv
5624e9fcaa8aSmrg# define S_IXUSR _S_IEXEC
5625862bcd1aSmrg#elif defined __MINGW32__
5626e9fcaa8aSmrg# define setmode _setmode
5627e9fcaa8aSmrg# define stat    _stat
5628e9fcaa8aSmrg# define chmod   _chmod
5629e9fcaa8aSmrg# define getcwd  _getcwd
5630e9fcaa8aSmrg# define putenv  _putenv
5631862bcd1aSmrg#elif defined __CYGWIN__
5632e9fcaa8aSmrg# define HAVE_SETENV
5633e9fcaa8aSmrg# define FOPEN_WB "wb"
5634862bcd1aSmrg/* #elif defined other platforms ... */
563588de56ccSmrg#endif
56361ab64890Smrg
5637862bcd1aSmrg#if defined PATH_MAX
563888de56ccSmrg# define LT_PATHMAX PATH_MAX
5639862bcd1aSmrg#elif defined MAXPATHLEN
564088de56ccSmrg# define LT_PATHMAX MAXPATHLEN
564188de56ccSmrg#else
564288de56ccSmrg# define LT_PATHMAX 1024
564388de56ccSmrg#endif
56441ab64890Smrg
564588de56ccSmrg#ifndef S_IXOTH
564688de56ccSmrg# define S_IXOTH 0
564788de56ccSmrg#endif
564888de56ccSmrg#ifndef S_IXGRP
564988de56ccSmrg# define S_IXGRP 0
565088de56ccSmrg#endif
56511ab64890Smrg
5652e9fcaa8aSmrg/* path handling portability macros */
565388de56ccSmrg#ifndef DIR_SEPARATOR
565488de56ccSmrg# define DIR_SEPARATOR '/'
565588de56ccSmrg# define PATH_SEPARATOR ':'
565688de56ccSmrg#endif
56571ab64890Smrg
5658862bcd1aSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
5659862bcd1aSmrg  defined __OS2__
566088de56ccSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
566188de56ccSmrg# define FOPEN_WB "wb"
566288de56ccSmrg# ifndef DIR_SEPARATOR_2
566388de56ccSmrg#  define DIR_SEPARATOR_2 '\\'
566488de56ccSmrg# endif
566588de56ccSmrg# ifndef PATH_SEPARATOR_2
566688de56ccSmrg#  define PATH_SEPARATOR_2 ';'
566788de56ccSmrg# endif
566888de56ccSmrg#endif
56691ab64890Smrg
567088de56ccSmrg#ifndef DIR_SEPARATOR_2
567188de56ccSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
567288de56ccSmrg#else /* DIR_SEPARATOR_2 */
567388de56ccSmrg# define IS_DIR_SEPARATOR(ch) \
567488de56ccSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
567588de56ccSmrg#endif /* DIR_SEPARATOR_2 */
56761ab64890Smrg
567788de56ccSmrg#ifndef PATH_SEPARATOR_2
567888de56ccSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
567988de56ccSmrg#else /* PATH_SEPARATOR_2 */
568088de56ccSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
568188de56ccSmrg#endif /* PATH_SEPARATOR_2 */
56821ab64890Smrg
568388de56ccSmrg#ifndef FOPEN_WB
568488de56ccSmrg# define FOPEN_WB "w"
568588de56ccSmrg#endif
568688de56ccSmrg#ifndef _O_BINARY
568788de56ccSmrg# define _O_BINARY 0
568888de56ccSmrg#endif
56891ab64890Smrg
569088de56ccSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
569188de56ccSmrg#define XFREE(stale) do { \
5692862bcd1aSmrg  if (stale) { free (stale); stale = 0; } \
569388de56ccSmrg} while (0)
56941ab64890Smrg
5695862bcd1aSmrg#if defined LT_DEBUGWRAPPER
5696e9fcaa8aSmrgstatic int lt_debug = 1;
569788de56ccSmrg#else
5698e9fcaa8aSmrgstatic int lt_debug = 0;
569988de56ccSmrg#endif
57001ab64890Smrg
5701e9fcaa8aSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
57021ab64890Smrg
570388de56ccSmrgvoid *xmalloc (size_t num);
570488de56ccSmrgchar *xstrdup (const char *string);
570588de56ccSmrgconst char *base_name (const char *name);
570688de56ccSmrgchar *find_executable (const char *wrapper);
570788de56ccSmrgchar *chase_symlinks (const char *pathspec);
570888de56ccSmrgint make_executable (const char *path);
570988de56ccSmrgint check_executable (const char *path);
571088de56ccSmrgchar *strendzap (char *str, const char *pat);
5711e9fcaa8aSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
5712e9fcaa8aSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
5713e9fcaa8aSmrgstatic const char *nonnull (const char *s);
5714e9fcaa8aSmrgstatic const char *nonempty (const char *s);
571588de56ccSmrgvoid lt_setenv (const char *name, const char *value);
571688de56ccSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
571788de56ccSmrgvoid lt_update_exe_path (const char *name, const char *value);
571888de56ccSmrgvoid lt_update_lib_path (const char *name, const char *value);
5719e9fcaa8aSmrgchar **prepare_spawn (char **argv);
5720e9fcaa8aSmrgvoid lt_dump_script (FILE *f);
572188de56ccSmrgEOF
572288de56ccSmrg
572388de56ccSmrg	    cat <<EOF
5724862bcd1aSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
5725862bcd1aSmrg# define externally_visible volatile
5726862bcd1aSmrg#else
5727862bcd1aSmrg# define externally_visible __attribute__((externally_visible)) volatile
5728862bcd1aSmrg#endif
5729862bcd1aSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
573088de56ccSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
573188de56ccSmrgEOF
57321ab64890Smrg
5733862bcd1aSmrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5734e9fcaa8aSmrg              func_to_host_path "$temp_rpath"
573588de56ccSmrg	      cat <<EOF
5736e9fcaa8aSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
573788de56ccSmrgEOF
573888de56ccSmrg	    else
573988de56ccSmrg	      cat <<"EOF"
574088de56ccSmrgconst char * LIB_PATH_VALUE   = "";
574188de56ccSmrgEOF
5742b4ee4795Smrg	    fi
57431ab64890Smrg
574488de56ccSmrg	    if test -n "$dllsearchpath"; then
5745e9fcaa8aSmrg              func_to_host_path "$dllsearchpath:"
574688de56ccSmrg	      cat <<EOF
574788de56ccSmrgconst char * EXE_PATH_VARNAME = "PATH";
5748e9fcaa8aSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
5749b4ee4795SmrgEOF
5750b4ee4795Smrg	    else
575188de56ccSmrg	      cat <<"EOF"
575288de56ccSmrgconst char * EXE_PATH_VARNAME = "";
575388de56ccSmrgconst char * EXE_PATH_VALUE   = "";
575488de56ccSmrgEOF
5755b4ee4795Smrg	    fi
575688de56ccSmrg
5757862bcd1aSmrg	    if test yes = "$fast_install"; then
575888de56ccSmrg	      cat <<EOF
575988de56ccSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
576088de56ccSmrgEOF
5761b4ee4795Smrg	    else
576288de56ccSmrg	      cat <<EOF
576388de56ccSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
576488de56ccSmrgEOF
5765b4ee4795Smrg	    fi
57661ab64890Smrg
57671ab64890Smrg
576888de56ccSmrg	    cat <<"EOF"
57691ab64890Smrg
577088de56ccSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
57711ab64890Smrg
577288de56ccSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
577388de56ccSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
5774e9fcaa8aSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
57751ab64890Smrg
577688de56ccSmrgint
577788de56ccSmrgmain (int argc, char *argv[])
577888de56ccSmrg{
577988de56ccSmrg  char **newargz;
578088de56ccSmrg  int  newargc;
578188de56ccSmrg  char *tmp_pathspec;
578288de56ccSmrg  char *actual_cwrapper_path;
578388de56ccSmrg  char *actual_cwrapper_name;
578488de56ccSmrg  char *target_name;
578588de56ccSmrg  char *lt_argv_zero;
5786862bcd1aSmrg  int rval = 127;
57871ab64890Smrg
578888de56ccSmrg  int i;
57891ab64890Smrg
579088de56ccSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
5791862bcd1aSmrg  newargz = XMALLOC (char *, (size_t) argc + 1);
57921ab64890Smrg
5793e9fcaa8aSmrg  /* very simple arg parsing; don't want to rely on getopt
5794e9fcaa8aSmrg   * also, copy all non cwrapper options to newargz, except
5795e9fcaa8aSmrg   * argz[0], which is handled differently
5796e9fcaa8aSmrg   */
5797e9fcaa8aSmrg  newargc=0;
579888de56ccSmrg  for (i = 1; i < argc; i++)
579988de56ccSmrg    {
5800862bcd1aSmrg      if (STREQ (argv[i], dumpscript_opt))
580188de56ccSmrg	{
580288de56ccSmrgEOF
5803862bcd1aSmrg	    case $host in
580488de56ccSmrg	      *mingw* | *cygwin* )
580588de56ccSmrg		# make stdout use "unix" line endings
580688de56ccSmrg		echo "          setmode(1,_O_BINARY);"
580788de56ccSmrg		;;
580888de56ccSmrg	      esac
58091ab64890Smrg
581088de56ccSmrg	    cat <<"EOF"
5811e9fcaa8aSmrg	  lt_dump_script (stdout);
581288de56ccSmrg	  return 0;
581388de56ccSmrg	}
5814862bcd1aSmrg      if (STREQ (argv[i], debug_opt))
5815e9fcaa8aSmrg	{
5816e9fcaa8aSmrg          lt_debug = 1;
5817e9fcaa8aSmrg          continue;
5818e9fcaa8aSmrg	}
5819862bcd1aSmrg      if (STREQ (argv[i], ltwrapper_option_prefix))
5820e9fcaa8aSmrg        {
5821e9fcaa8aSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5822e9fcaa8aSmrg             namespace, but it is not one of the ones we know about and
5823e9fcaa8aSmrg             have already dealt with, above (inluding dump-script), then
5824e9fcaa8aSmrg             report an error. Otherwise, targets might begin to believe
5825e9fcaa8aSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5826e9fcaa8aSmrg             namespace. The first time any user complains about this, we'll
5827e9fcaa8aSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5828e9fcaa8aSmrg             or a configure.ac-settable value.
5829e9fcaa8aSmrg           */
5830e9fcaa8aSmrg          lt_fatal (__FILE__, __LINE__,
5831e9fcaa8aSmrg		    "unrecognized %s option: '%s'",
5832e9fcaa8aSmrg                    ltwrapper_option_prefix, argv[i]);
5833e9fcaa8aSmrg        }
5834e9fcaa8aSmrg      /* otherwise ... */
5835e9fcaa8aSmrg      newargz[++newargc] = xstrdup (argv[i]);
583688de56ccSmrg    }
5837e9fcaa8aSmrg  newargz[++newargc] = NULL;
5838e9fcaa8aSmrg
5839e9fcaa8aSmrgEOF
5840e9fcaa8aSmrg	    cat <<EOF
5841e9fcaa8aSmrg  /* The GNU banner must be the first non-error debug message */
5842862bcd1aSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5843e9fcaa8aSmrgEOF
5844e9fcaa8aSmrg	    cat <<"EOF"
5845e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5846e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
58471ab64890Smrg
584888de56ccSmrg  tmp_pathspec = find_executable (argv[0]);
584988de56ccSmrg  if (tmp_pathspec == NULL)
5850e9fcaa8aSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5851e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
5852e9fcaa8aSmrg                  "(main) found exe (before symlink chase) at: %s\n",
5853e9fcaa8aSmrg		  tmp_pathspec);
585488de56ccSmrg
585588de56ccSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5856e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
5857e9fcaa8aSmrg                  "(main) found exe (after symlink chase) at: %s\n",
5858e9fcaa8aSmrg		  actual_cwrapper_path);
585988de56ccSmrg  XFREE (tmp_pathspec);
586088de56ccSmrg
5861e9fcaa8aSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
586288de56ccSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
586388de56ccSmrg
586488de56ccSmrg  /* wrapper name transforms */
586588de56ccSmrg  strendzap (actual_cwrapper_name, ".exe");
586688de56ccSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
586788de56ccSmrg  XFREE (actual_cwrapper_name);
586888de56ccSmrg  actual_cwrapper_name = tmp_pathspec;
586988de56ccSmrg  tmp_pathspec = 0;
587088de56ccSmrg
587188de56ccSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
587288de56ccSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
587388de56ccSmrg  strendzap (target_name, ".exe");
587488de56ccSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
587588de56ccSmrg  XFREE (target_name);
587688de56ccSmrg  target_name = tmp_pathspec;
587788de56ccSmrg  tmp_pathspec = 0;
587888de56ccSmrg
5879e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
5880e9fcaa8aSmrg		  "(main) libtool target name: %s\n",
5881e9fcaa8aSmrg		  target_name);
588288de56ccSmrgEOF
58831ab64890Smrg
588488de56ccSmrg	    cat <<EOF
588588de56ccSmrg  newargz[0] =
588688de56ccSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
588788de56ccSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
588888de56ccSmrg  strcpy (newargz[0], actual_cwrapper_path);
588988de56ccSmrg  strcat (newargz[0], "$objdir");
589088de56ccSmrg  strcat (newargz[0], "/");
589188de56ccSmrgEOF
58921ab64890Smrg
589388de56ccSmrg	    cat <<"EOF"
589488de56ccSmrg  /* stop here, and copy so we don't have to do this twice */
589588de56ccSmrg  tmp_pathspec = xstrdup (newargz[0]);
58961ab64890Smrg
589788de56ccSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
589888de56ccSmrg  strcat (newargz[0], actual_cwrapper_name);
58991ab64890Smrg
590088de56ccSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
590188de56ccSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
590288de56ccSmrg  XFREE (tmp_pathspec);
590388de56ccSmrg  tmp_pathspec = NULL;
590488de56ccSmrgEOF
59051ab64890Smrg
590688de56ccSmrg	    case $host_os in
590788de56ccSmrg	      mingw*)
590888de56ccSmrg	    cat <<"EOF"
590988de56ccSmrg  {
591088de56ccSmrg    char* p;
591188de56ccSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
591288de56ccSmrg      {
591388de56ccSmrg	*p = '/';
591488de56ccSmrg      }
591588de56ccSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
591688de56ccSmrg      {
591788de56ccSmrg	*p = '/';
591888de56ccSmrg      }
591988de56ccSmrg  }
592088de56ccSmrgEOF
592188de56ccSmrg	    ;;
592288de56ccSmrg	    esac
59231ab64890Smrg
592488de56ccSmrg	    cat <<"EOF"
592588de56ccSmrg  XFREE (target_name);
592688de56ccSmrg  XFREE (actual_cwrapper_path);
592788de56ccSmrg  XFREE (actual_cwrapper_name);
59281ab64890Smrg
592988de56ccSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
593088de56ccSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
5931e9fcaa8aSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
5932e9fcaa8aSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5933e9fcaa8aSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
5934e9fcaa8aSmrg     libraries must come first. */
593588de56ccSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5936e9fcaa8aSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
59371ab64890Smrg
5938e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5939e9fcaa8aSmrg		  nonnull (lt_argv_zero));
594088de56ccSmrg  for (i = 0; i < newargc; i++)
594188de56ccSmrg    {
5942e9fcaa8aSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5943e9fcaa8aSmrg		      i, nonnull (newargz[i]));
594488de56ccSmrg    }
59451ab64890Smrg
594688de56ccSmrgEOF
59471ab64890Smrg
594888de56ccSmrg	    case $host_os in
594988de56ccSmrg	      mingw*)
595088de56ccSmrg		cat <<"EOF"
595188de56ccSmrg  /* execv doesn't actually work on mingw as expected on unix */
5952e9fcaa8aSmrg  newargz = prepare_spawn (newargz);
5953862bcd1aSmrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
595488de56ccSmrg  if (rval == -1)
595588de56ccSmrg    {
595688de56ccSmrg      /* failed to start process */
5957e9fcaa8aSmrg      lt_debugprintf (__FILE__, __LINE__,
5958e9fcaa8aSmrg		      "(main) failed to launch target \"%s\": %s\n",
5959e9fcaa8aSmrg		      lt_argv_zero, nonnull (strerror (errno)));
596088de56ccSmrg      return 127;
596188de56ccSmrg    }
596288de56ccSmrg  return rval;
596388de56ccSmrgEOF
596488de56ccSmrg		;;
596588de56ccSmrg	      *)
596688de56ccSmrg		cat <<"EOF"
596788de56ccSmrg  execv (lt_argv_zero, newargz);
596888de56ccSmrg  return rval; /* =127, but avoids unused variable warning */
596988de56ccSmrgEOF
597088de56ccSmrg		;;
597188de56ccSmrg	    esac
59721ab64890Smrg
597388de56ccSmrg	    cat <<"EOF"
597488de56ccSmrg}
59751ab64890Smrg
597688de56ccSmrgvoid *
597788de56ccSmrgxmalloc (size_t num)
597888de56ccSmrg{
597988de56ccSmrg  void *p = (void *) malloc (num);
598088de56ccSmrg  if (!p)
5981e9fcaa8aSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
59821ab64890Smrg
598388de56ccSmrg  return p;
598488de56ccSmrg}
59851ab64890Smrg
598688de56ccSmrgchar *
598788de56ccSmrgxstrdup (const char *string)
598888de56ccSmrg{
598988de56ccSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
599088de56ccSmrg			  string) : NULL;
599188de56ccSmrg}
59921ab64890Smrg
599388de56ccSmrgconst char *
599488de56ccSmrgbase_name (const char *name)
599588de56ccSmrg{
599688de56ccSmrg  const char *base;
5997b4ee4795Smrg
5998862bcd1aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
599988de56ccSmrg  /* Skip over the disk name in MSDOS pathnames. */
600088de56ccSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
600188de56ccSmrg    name += 2;
600288de56ccSmrg#endif
6003b4ee4795Smrg
600488de56ccSmrg  for (base = name; *name; name++)
600588de56ccSmrg    if (IS_DIR_SEPARATOR (*name))
600688de56ccSmrg      base = name + 1;
600788de56ccSmrg  return base;
600888de56ccSmrg}
6009b4ee4795Smrg
601088de56ccSmrgint
601188de56ccSmrgcheck_executable (const char *path)
601288de56ccSmrg{
601388de56ccSmrg  struct stat st;
6014b4ee4795Smrg
6015e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
6016e9fcaa8aSmrg                  nonempty (path));
601788de56ccSmrg  if ((!path) || (!*path))
601888de56ccSmrg    return 0;
6019b4ee4795Smrg
602088de56ccSmrg  if ((stat (path, &st) >= 0)
602188de56ccSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
602288de56ccSmrg    return 1;
602388de56ccSmrg  else
602488de56ccSmrg    return 0;
602588de56ccSmrg}
60261ab64890Smrg
602788de56ccSmrgint
602888de56ccSmrgmake_executable (const char *path)
602988de56ccSmrg{
603088de56ccSmrg  int rval = 0;
603188de56ccSmrg  struct stat st;
60321ab64890Smrg
6033e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
6034e9fcaa8aSmrg                  nonempty (path));
603588de56ccSmrg  if ((!path) || (!*path))
603688de56ccSmrg    return 0;
60371ab64890Smrg
603888de56ccSmrg  if (stat (path, &st) >= 0)
603988de56ccSmrg    {
604088de56ccSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
604188de56ccSmrg    }
604288de56ccSmrg  return rval;
604388de56ccSmrg}
6044b4ee4795Smrg
604588de56ccSmrg/* Searches for the full path of the wrapper.  Returns
604688de56ccSmrg   newly allocated full path name if found, NULL otherwise
604788de56ccSmrg   Does not chase symlinks, even on platforms that support them.
604888de56ccSmrg*/
604988de56ccSmrgchar *
605088de56ccSmrgfind_executable (const char *wrapper)
605188de56ccSmrg{
605288de56ccSmrg  int has_slash = 0;
605388de56ccSmrg  const char *p;
605488de56ccSmrg  const char *p_next;
605588de56ccSmrg  /* static buffer for getcwd */
605688de56ccSmrg  char tmp[LT_PATHMAX + 1];
6057862bcd1aSmrg  size_t tmp_len;
605888de56ccSmrg  char *concat_name;
6059b4ee4795Smrg
6060e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6061e9fcaa8aSmrg                  nonempty (wrapper));
6062b4ee4795Smrg
606388de56ccSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
606488de56ccSmrg    return NULL;
6065b4ee4795Smrg
606688de56ccSmrg  /* Absolute path? */
6067862bcd1aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
606888de56ccSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
606988de56ccSmrg    {
607088de56ccSmrg      concat_name = xstrdup (wrapper);
607188de56ccSmrg      if (check_executable (concat_name))
607288de56ccSmrg	return concat_name;
607388de56ccSmrg      XFREE (concat_name);
607488de56ccSmrg    }
607588de56ccSmrg  else
607688de56ccSmrg    {
607788de56ccSmrg#endif
607888de56ccSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
607988de56ccSmrg	{
608088de56ccSmrg	  concat_name = xstrdup (wrapper);
608188de56ccSmrg	  if (check_executable (concat_name))
608288de56ccSmrg	    return concat_name;
608388de56ccSmrg	  XFREE (concat_name);
608488de56ccSmrg	}
6085862bcd1aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
608688de56ccSmrg    }
608788de56ccSmrg#endif
60881ab64890Smrg
608988de56ccSmrg  for (p = wrapper; *p; p++)
609088de56ccSmrg    if (*p == '/')
609188de56ccSmrg      {
609288de56ccSmrg	has_slash = 1;
609388de56ccSmrg	break;
609488de56ccSmrg      }
609588de56ccSmrg  if (!has_slash)
609688de56ccSmrg    {
609788de56ccSmrg      /* no slashes; search PATH */
609888de56ccSmrg      const char *path = getenv ("PATH");
609988de56ccSmrg      if (path != NULL)
610088de56ccSmrg	{
610188de56ccSmrg	  for (p = path; *p; p = p_next)
610288de56ccSmrg	    {
610388de56ccSmrg	      const char *q;
610488de56ccSmrg	      size_t p_len;
610588de56ccSmrg	      for (q = p; *q; q++)
610688de56ccSmrg		if (IS_PATH_SEPARATOR (*q))
610788de56ccSmrg		  break;
6108862bcd1aSmrg	      p_len = (size_t) (q - p);
610988de56ccSmrg	      p_next = (*q == '\0' ? q : q + 1);
611088de56ccSmrg	      if (p_len == 0)
611188de56ccSmrg		{
611288de56ccSmrg		  /* empty path: current directory */
611388de56ccSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
6114e9fcaa8aSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6115e9fcaa8aSmrg                              nonnull (strerror (errno)));
611688de56ccSmrg		  tmp_len = strlen (tmp);
611788de56ccSmrg		  concat_name =
611888de56ccSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
611988de56ccSmrg		  memcpy (concat_name, tmp, tmp_len);
612088de56ccSmrg		  concat_name[tmp_len] = '/';
612188de56ccSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
612288de56ccSmrg		}
612388de56ccSmrg	      else
612488de56ccSmrg		{
612588de56ccSmrg		  concat_name =
612688de56ccSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
612788de56ccSmrg		  memcpy (concat_name, p, p_len);
612888de56ccSmrg		  concat_name[p_len] = '/';
612988de56ccSmrg		  strcpy (concat_name + p_len + 1, wrapper);
613088de56ccSmrg		}
613188de56ccSmrg	      if (check_executable (concat_name))
613288de56ccSmrg		return concat_name;
613388de56ccSmrg	      XFREE (concat_name);
613488de56ccSmrg	    }
613588de56ccSmrg	}
613688de56ccSmrg      /* not found in PATH; assume curdir */
613788de56ccSmrg    }
613888de56ccSmrg  /* Relative path | not found in path: prepend cwd */
613988de56ccSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
6140e9fcaa8aSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6141e9fcaa8aSmrg              nonnull (strerror (errno)));
614288de56ccSmrg  tmp_len = strlen (tmp);
614388de56ccSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
614488de56ccSmrg  memcpy (concat_name, tmp, tmp_len);
614588de56ccSmrg  concat_name[tmp_len] = '/';
614688de56ccSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
61471ab64890Smrg
614888de56ccSmrg  if (check_executable (concat_name))
614988de56ccSmrg    return concat_name;
615088de56ccSmrg  XFREE (concat_name);
615188de56ccSmrg  return NULL;
615288de56ccSmrg}
61531ab64890Smrg
615488de56ccSmrgchar *
615588de56ccSmrgchase_symlinks (const char *pathspec)
615688de56ccSmrg{
615788de56ccSmrg#ifndef S_ISLNK
615888de56ccSmrg  return xstrdup (pathspec);
615988de56ccSmrg#else
616088de56ccSmrg  char buf[LT_PATHMAX];
616188de56ccSmrg  struct stat s;
616288de56ccSmrg  char *tmp_pathspec = xstrdup (pathspec);
616388de56ccSmrg  char *p;
616488de56ccSmrg  int has_symlinks = 0;
616588de56ccSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
616688de56ccSmrg    {
6167e9fcaa8aSmrg      lt_debugprintf (__FILE__, __LINE__,
6168e9fcaa8aSmrg		      "checking path component for symlinks: %s\n",
6169e9fcaa8aSmrg		      tmp_pathspec);
617088de56ccSmrg      if (lstat (tmp_pathspec, &s) == 0)
617188de56ccSmrg	{
617288de56ccSmrg	  if (S_ISLNK (s.st_mode) != 0)
617388de56ccSmrg	    {
617488de56ccSmrg	      has_symlinks = 1;
617588de56ccSmrg	      break;
617688de56ccSmrg	    }
61771ab64890Smrg
617888de56ccSmrg	  /* search backwards for last DIR_SEPARATOR */
617988de56ccSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
618088de56ccSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
618188de56ccSmrg	    p--;
618288de56ccSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
618388de56ccSmrg	    {
618488de56ccSmrg	      /* no more DIR_SEPARATORS left */
618588de56ccSmrg	      break;
618688de56ccSmrg	    }
618788de56ccSmrg	  *p = '\0';
618888de56ccSmrg	}
618988de56ccSmrg      else
619088de56ccSmrg	{
6191e9fcaa8aSmrg	  lt_fatal (__FILE__, __LINE__,
6192e9fcaa8aSmrg		    "error accessing file \"%s\": %s",
6193e9fcaa8aSmrg		    tmp_pathspec, nonnull (strerror (errno)));
619488de56ccSmrg	}
619588de56ccSmrg    }
619688de56ccSmrg  XFREE (tmp_pathspec);
61971ab64890Smrg
619888de56ccSmrg  if (!has_symlinks)
619988de56ccSmrg    {
620088de56ccSmrg      return xstrdup (pathspec);
620188de56ccSmrg    }
62021ab64890Smrg
620388de56ccSmrg  tmp_pathspec = realpath (pathspec, buf);
620488de56ccSmrg  if (tmp_pathspec == 0)
620588de56ccSmrg    {
6206e9fcaa8aSmrg      lt_fatal (__FILE__, __LINE__,
6207e9fcaa8aSmrg		"could not follow symlinks for %s", pathspec);
620888de56ccSmrg    }
620988de56ccSmrg  return xstrdup (tmp_pathspec);
621088de56ccSmrg#endif
621188de56ccSmrg}
62121ab64890Smrg
621388de56ccSmrgchar *
621488de56ccSmrgstrendzap (char *str, const char *pat)
621588de56ccSmrg{
621688de56ccSmrg  size_t len, patlen;
62171ab64890Smrg
621888de56ccSmrg  assert (str != NULL);
621988de56ccSmrg  assert (pat != NULL);
62201ab64890Smrg
622188de56ccSmrg  len = strlen (str);
622288de56ccSmrg  patlen = strlen (pat);
62231ab64890Smrg
622488de56ccSmrg  if (patlen <= len)
622588de56ccSmrg    {
622688de56ccSmrg      str += len - patlen;
6227862bcd1aSmrg      if (STREQ (str, pat))
622888de56ccSmrg	*str = '\0';
622988de56ccSmrg    }
623088de56ccSmrg  return str;
623188de56ccSmrg}
62321ab64890Smrg
6233e9fcaa8aSmrgvoid
6234e9fcaa8aSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
6235e9fcaa8aSmrg{
6236e9fcaa8aSmrg  va_list args;
6237e9fcaa8aSmrg  if (lt_debug)
6238e9fcaa8aSmrg    {
6239e9fcaa8aSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6240e9fcaa8aSmrg      va_start (args, fmt);
6241e9fcaa8aSmrg      (void) vfprintf (stderr, fmt, args);
6242e9fcaa8aSmrg      va_end (args);
6243e9fcaa8aSmrg    }
6244e9fcaa8aSmrg}
6245e9fcaa8aSmrg
624688de56ccSmrgstatic void
6247e9fcaa8aSmrglt_error_core (int exit_status, const char *file,
6248e9fcaa8aSmrg	       int line, const char *mode,
624988de56ccSmrg	       const char *message, va_list ap)
625088de56ccSmrg{
6251e9fcaa8aSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
625288de56ccSmrg  vfprintf (stderr, message, ap);
625388de56ccSmrg  fprintf (stderr, ".\n");
62541ab64890Smrg
625588de56ccSmrg  if (exit_status >= 0)
625688de56ccSmrg    exit (exit_status);
625788de56ccSmrg}
62581ab64890Smrg
625988de56ccSmrgvoid
6260e9fcaa8aSmrglt_fatal (const char *file, int line, const char *message, ...)
626188de56ccSmrg{
626288de56ccSmrg  va_list ap;
626388de56ccSmrg  va_start (ap, message);
6264e9fcaa8aSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
626588de56ccSmrg  va_end (ap);
626688de56ccSmrg}
62672e9c7c8cSmrg
6268e9fcaa8aSmrgstatic const char *
6269e9fcaa8aSmrgnonnull (const char *s)
6270e9fcaa8aSmrg{
6271e9fcaa8aSmrg  return s ? s : "(null)";
6272e9fcaa8aSmrg}
6273e9fcaa8aSmrg
6274e9fcaa8aSmrgstatic const char *
6275e9fcaa8aSmrgnonempty (const char *s)
6276e9fcaa8aSmrg{
6277e9fcaa8aSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
6278e9fcaa8aSmrg}
6279e9fcaa8aSmrg
628088de56ccSmrgvoid
628188de56ccSmrglt_setenv (const char *name, const char *value)
628288de56ccSmrg{
6283e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
6284e9fcaa8aSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
6285e9fcaa8aSmrg                  nonnull (name), nonnull (value));
628688de56ccSmrg  {
628788de56ccSmrg#ifdef HAVE_SETENV
628888de56ccSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
628988de56ccSmrg    char *str = xstrdup (value);
629088de56ccSmrg    setenv (name, str, 1);
629188de56ccSmrg#else
6292862bcd1aSmrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
629388de56ccSmrg    char *str = XMALLOC (char, len);
629488de56ccSmrg    sprintf (str, "%s=%s", name, value);
629588de56ccSmrg    if (putenv (str) != EXIT_SUCCESS)
629688de56ccSmrg      {
629788de56ccSmrg        XFREE (str);
629888de56ccSmrg      }
629988de56ccSmrg#endif
630088de56ccSmrg  }
630188de56ccSmrg}
63021ab64890Smrg
630388de56ccSmrgchar *
630488de56ccSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
630588de56ccSmrg{
630688de56ccSmrg  char *new_value;
630788de56ccSmrg  if (orig_value && *orig_value)
630888de56ccSmrg    {
6309862bcd1aSmrg      size_t orig_value_len = strlen (orig_value);
6310862bcd1aSmrg      size_t add_len = strlen (add);
631188de56ccSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
631288de56ccSmrg      if (to_end)
631388de56ccSmrg        {
631488de56ccSmrg          strcpy (new_value, orig_value);
631588de56ccSmrg          strcpy (new_value + orig_value_len, add);
631688de56ccSmrg        }
631788de56ccSmrg      else
631888de56ccSmrg        {
631988de56ccSmrg          strcpy (new_value, add);
632088de56ccSmrg          strcpy (new_value + add_len, orig_value);
632188de56ccSmrg        }
632288de56ccSmrg    }
632388de56ccSmrg  else
632488de56ccSmrg    {
632588de56ccSmrg      new_value = xstrdup (add);
632688de56ccSmrg    }
632788de56ccSmrg  return new_value;
632888de56ccSmrg}
63291ab64890Smrg
633088de56ccSmrgvoid
633188de56ccSmrglt_update_exe_path (const char *name, const char *value)
633288de56ccSmrg{
6333e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
6334e9fcaa8aSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6335e9fcaa8aSmrg                  nonnull (name), nonnull (value));
63361ab64890Smrg
633788de56ccSmrg  if (name && *name && value && *value)
633888de56ccSmrg    {
633988de56ccSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
634088de56ccSmrg      /* some systems can't cope with a ':'-terminated path #' */
6341862bcd1aSmrg      size_t len = strlen (new_value);
6342862bcd1aSmrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
634388de56ccSmrg        {
6344862bcd1aSmrg          new_value[--len] = '\0';
634588de56ccSmrg        }
634688de56ccSmrg      lt_setenv (name, new_value);
634788de56ccSmrg      XFREE (new_value);
634888de56ccSmrg    }
634988de56ccSmrg}
63501ab64890Smrg
635188de56ccSmrgvoid
635288de56ccSmrglt_update_lib_path (const char *name, const char *value)
635388de56ccSmrg{
6354e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
6355e9fcaa8aSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6356e9fcaa8aSmrg                  nonnull (name), nonnull (value));
63571ab64890Smrg
635888de56ccSmrg  if (name && *name && value && *value)
635988de56ccSmrg    {
636088de56ccSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
636188de56ccSmrg      lt_setenv (name, new_value);
636288de56ccSmrg      XFREE (new_value);
636388de56ccSmrg    }
636488de56ccSmrg}
63651ab64890Smrg
6366e9fcaa8aSmrgEOF
6367e9fcaa8aSmrg	    case $host_os in
6368e9fcaa8aSmrg	      mingw*)
6369e9fcaa8aSmrg		cat <<"EOF"
6370e9fcaa8aSmrg
6371e9fcaa8aSmrg/* Prepares an argument vector before calling spawn().
6372e9fcaa8aSmrg   Note that spawn() does not by itself call the command interpreter
6373e9fcaa8aSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6374e9fcaa8aSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6375e9fcaa8aSmrg         GetVersionEx(&v);
6376e9fcaa8aSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6377e9fcaa8aSmrg      }) ? "cmd.exe" : "command.com").
6378e9fcaa8aSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
6379e9fcaa8aSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
6380e9fcaa8aSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6381e9fcaa8aSmrg   special way:
6382e9fcaa8aSmrg   - Space and tab are interpreted as delimiters. They are not treated as
6383e9fcaa8aSmrg     delimiters if they are surrounded by double quotes: "...".
6384e9fcaa8aSmrg   - Unescaped double quotes are removed from the input. Their only effect is
6385e9fcaa8aSmrg     that within double quotes, space and tab are treated like normal
6386e9fcaa8aSmrg     characters.
6387e9fcaa8aSmrg   - Backslashes not followed by double quotes are not special.
6388e9fcaa8aSmrg   - But 2*n+1 backslashes followed by a double quote become
6389e9fcaa8aSmrg     n backslashes followed by a double quote (n >= 0):
6390e9fcaa8aSmrg       \" -> "
6391e9fcaa8aSmrg       \\\" -> \"
6392e9fcaa8aSmrg       \\\\\" -> \\"
6393e9fcaa8aSmrg */
6394e9fcaa8aSmrg#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"
6395e9fcaa8aSmrg#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"
6396e9fcaa8aSmrgchar **
6397e9fcaa8aSmrgprepare_spawn (char **argv)
6398e9fcaa8aSmrg{
6399e9fcaa8aSmrg  size_t argc;
6400e9fcaa8aSmrg  char **new_argv;
6401e9fcaa8aSmrg  size_t i;
6402e9fcaa8aSmrg
6403e9fcaa8aSmrg  /* Count number of arguments.  */
6404e9fcaa8aSmrg  for (argc = 0; argv[argc] != NULL; argc++)
6405e9fcaa8aSmrg    ;
6406e9fcaa8aSmrg
6407e9fcaa8aSmrg  /* Allocate new argument vector.  */
6408e9fcaa8aSmrg  new_argv = XMALLOC (char *, argc + 1);
6409e9fcaa8aSmrg
6410e9fcaa8aSmrg  /* Put quoted arguments into the new argument vector.  */
6411e9fcaa8aSmrg  for (i = 0; i < argc; i++)
6412e9fcaa8aSmrg    {
6413e9fcaa8aSmrg      const char *string = argv[i];
6414e9fcaa8aSmrg
6415e9fcaa8aSmrg      if (string[0] == '\0')
6416e9fcaa8aSmrg	new_argv[i] = xstrdup ("\"\"");
6417e9fcaa8aSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6418e9fcaa8aSmrg	{
6419e9fcaa8aSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6420e9fcaa8aSmrg	  size_t length;
6421e9fcaa8aSmrg	  unsigned int backslashes;
6422e9fcaa8aSmrg	  const char *s;
6423e9fcaa8aSmrg	  char *quoted_string;
6424e9fcaa8aSmrg	  char *p;
6425e9fcaa8aSmrg
6426e9fcaa8aSmrg	  length = 0;
6427e9fcaa8aSmrg	  backslashes = 0;
6428e9fcaa8aSmrg	  if (quote_around)
6429e9fcaa8aSmrg	    length++;
6430e9fcaa8aSmrg	  for (s = string; *s != '\0'; s++)
6431e9fcaa8aSmrg	    {
6432e9fcaa8aSmrg	      char c = *s;
6433e9fcaa8aSmrg	      if (c == '"')
6434e9fcaa8aSmrg		length += backslashes + 1;
6435e9fcaa8aSmrg	      length++;
6436e9fcaa8aSmrg	      if (c == '\\')
6437e9fcaa8aSmrg		backslashes++;
6438e9fcaa8aSmrg	      else
6439e9fcaa8aSmrg		backslashes = 0;
6440e9fcaa8aSmrg	    }
6441e9fcaa8aSmrg	  if (quote_around)
6442e9fcaa8aSmrg	    length += backslashes + 1;
6443e9fcaa8aSmrg
6444e9fcaa8aSmrg	  quoted_string = XMALLOC (char, length + 1);
6445e9fcaa8aSmrg
6446e9fcaa8aSmrg	  p = quoted_string;
6447e9fcaa8aSmrg	  backslashes = 0;
6448e9fcaa8aSmrg	  if (quote_around)
6449e9fcaa8aSmrg	    *p++ = '"';
6450e9fcaa8aSmrg	  for (s = string; *s != '\0'; s++)
6451e9fcaa8aSmrg	    {
6452e9fcaa8aSmrg	      char c = *s;
6453e9fcaa8aSmrg	      if (c == '"')
6454e9fcaa8aSmrg		{
6455e9fcaa8aSmrg		  unsigned int j;
6456e9fcaa8aSmrg		  for (j = backslashes + 1; j > 0; j--)
6457e9fcaa8aSmrg		    *p++ = '\\';
6458e9fcaa8aSmrg		}
6459e9fcaa8aSmrg	      *p++ = c;
6460e9fcaa8aSmrg	      if (c == '\\')
6461e9fcaa8aSmrg		backslashes++;
6462e9fcaa8aSmrg	      else
6463e9fcaa8aSmrg		backslashes = 0;
6464e9fcaa8aSmrg	    }
6465e9fcaa8aSmrg	  if (quote_around)
6466e9fcaa8aSmrg	    {
6467e9fcaa8aSmrg	      unsigned int j;
6468e9fcaa8aSmrg	      for (j = backslashes; j > 0; j--)
6469e9fcaa8aSmrg		*p++ = '\\';
6470e9fcaa8aSmrg	      *p++ = '"';
6471e9fcaa8aSmrg	    }
6472e9fcaa8aSmrg	  *p = '\0';
6473e9fcaa8aSmrg
6474e9fcaa8aSmrg	  new_argv[i] = quoted_string;
6475e9fcaa8aSmrg	}
6476e9fcaa8aSmrg      else
6477e9fcaa8aSmrg	new_argv[i] = (char *) string;
6478e9fcaa8aSmrg    }
6479e9fcaa8aSmrg  new_argv[argc] = NULL;
6480e9fcaa8aSmrg
6481e9fcaa8aSmrg  return new_argv;
6482e9fcaa8aSmrg}
6483e9fcaa8aSmrgEOF
6484e9fcaa8aSmrg		;;
6485e9fcaa8aSmrg	    esac
6486e9fcaa8aSmrg
6487e9fcaa8aSmrg            cat <<"EOF"
6488e9fcaa8aSmrgvoid lt_dump_script (FILE* f)
6489e9fcaa8aSmrg{
6490e9fcaa8aSmrgEOF
6491e9fcaa8aSmrg	    func_emit_wrapper yes |
6492eb411b4bSmrg	      $SED -n -e '
6493eb411b4bSmrgs/^\(.\{79\}\)\(..*\)/\1\
6494eb411b4bSmrg\2/
6495eb411b4bSmrgh
6496eb411b4bSmrgs/\([\\"]\)/\\\1/g
6497eb411b4bSmrgs/$/\\n/
6498eb411b4bSmrgs/\([^\n]*\).*/  fputs ("\1", f);/p
6499eb411b4bSmrgg
6500eb411b4bSmrgD'
6501e9fcaa8aSmrg            cat <<"EOF"
6502e9fcaa8aSmrg}
650388de56ccSmrgEOF
650488de56ccSmrg}
650588de56ccSmrg# end: func_emit_cwrapperexe_src
65061ab64890Smrg
6507e9fcaa8aSmrg# func_win32_import_lib_p ARG
6508e9fcaa8aSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
6509e9fcaa8aSmrgfunc_win32_import_lib_p ()
6510e9fcaa8aSmrg{
6511862bcd1aSmrg    $debug_cmd
6512862bcd1aSmrg
6513e9fcaa8aSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6514e9fcaa8aSmrg    *import*) : ;;
6515e9fcaa8aSmrg    *) false ;;
6516e9fcaa8aSmrg    esac
6517e9fcaa8aSmrg}
6518e9fcaa8aSmrg
6519862bcd1aSmrg# func_suncc_cstd_abi
6520862bcd1aSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
6521862bcd1aSmrg# Several compiler flags select an ABI that is incompatible with the
6522862bcd1aSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
6523862bcd1aSmrgfunc_suncc_cstd_abi ()
6524862bcd1aSmrg{
6525862bcd1aSmrg    $debug_cmd
6526862bcd1aSmrg
6527862bcd1aSmrg    case " $compile_command " in
6528862bcd1aSmrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
6529862bcd1aSmrg      suncc_use_cstd_abi=no
6530862bcd1aSmrg      ;;
6531862bcd1aSmrg    *)
6532862bcd1aSmrg      suncc_use_cstd_abi=yes
6533862bcd1aSmrg      ;;
6534862bcd1aSmrg    esac
6535862bcd1aSmrg}
6536862bcd1aSmrg
653788de56ccSmrg# func_mode_link arg...
653888de56ccSmrgfunc_mode_link ()
653988de56ccSmrg{
6540862bcd1aSmrg    $debug_cmd
6541862bcd1aSmrg
654288de56ccSmrg    case $host in
654388de56ccSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
654488de56ccSmrg      # It is impossible to link a dll without this setting, and
654588de56ccSmrg      # we shouldn't force the makefile maintainer to figure out
6546862bcd1aSmrg      # what system we are compiling for in order to pass an extra
654788de56ccSmrg      # flag for every libtool invocation.
654888de56ccSmrg      # allow_undefined=no
65491ab64890Smrg
655088de56ccSmrg      # FIXME: Unfortunately, there are problems with the above when trying
6551862bcd1aSmrg      # to make a dll that has undefined symbols, in which case not
655288de56ccSmrg      # even a static library is built.  For now, we need to specify
655388de56ccSmrg      # -no-undefined on the libtool link line when we can be certain
655488de56ccSmrg      # that all symbols are satisfied, otherwise we get a static library.
655588de56ccSmrg      allow_undefined=yes
655688de56ccSmrg      ;;
655788de56ccSmrg    *)
655888de56ccSmrg      allow_undefined=yes
655988de56ccSmrg      ;;
656088de56ccSmrg    esac
656188de56ccSmrg    libtool_args=$nonopt
656288de56ccSmrg    base_compile="$nonopt $@"
656388de56ccSmrg    compile_command=$nonopt
656488de56ccSmrg    finalize_command=$nonopt
65651ab64890Smrg
656688de56ccSmrg    compile_rpath=
656788de56ccSmrg    finalize_rpath=
656888de56ccSmrg    compile_shlibpath=
656988de56ccSmrg    finalize_shlibpath=
657088de56ccSmrg    convenience=
657188de56ccSmrg    old_convenience=
657288de56ccSmrg    deplibs=
657388de56ccSmrg    old_deplibs=
657488de56ccSmrg    compiler_flags=
657588de56ccSmrg    linker_flags=
657688de56ccSmrg    dllsearchpath=
657788de56ccSmrg    lib_search_path=`pwd`
657888de56ccSmrg    inst_prefix_dir=
657988de56ccSmrg    new_inherited_linker_flags=
65801ab64890Smrg
658188de56ccSmrg    avoid_version=no
6582e9fcaa8aSmrg    bindir=
658388de56ccSmrg    dlfiles=
658488de56ccSmrg    dlprefiles=
658588de56ccSmrg    dlself=no
658688de56ccSmrg    export_dynamic=no
658788de56ccSmrg    export_symbols=
658888de56ccSmrg    export_symbols_regex=
658988de56ccSmrg    generated=
659088de56ccSmrg    libobjs=
659188de56ccSmrg    ltlibs=
659288de56ccSmrg    module=no
659388de56ccSmrg    no_install=no
659488de56ccSmrg    objs=
6595862bcd1aSmrg    os2dllname=
659688de56ccSmrg    non_pic_objects=
659788de56ccSmrg    precious_files_regex=
659888de56ccSmrg    prefer_static_libs=no
6599862bcd1aSmrg    preload=false
660088de56ccSmrg    prev=
660188de56ccSmrg    prevarg=
660288de56ccSmrg    release=
660388de56ccSmrg    rpath=
660488de56ccSmrg    xrpath=
660588de56ccSmrg    perm_rpath=
660688de56ccSmrg    temp_rpath=
660788de56ccSmrg    thread_safe=no
660888de56ccSmrg    vinfo=
660988de56ccSmrg    vinfo_number=no
661088de56ccSmrg    weak_libs=
6611862bcd1aSmrg    single_module=$wl-single_module
661288de56ccSmrg    func_infer_tag $base_compile
661388de56ccSmrg
661488de56ccSmrg    # We need to know -static, to get the right output filenames.
661588de56ccSmrg    for arg
661688de56ccSmrg    do
661788de56ccSmrg      case $arg in
661888de56ccSmrg      -shared)
6619862bcd1aSmrg	test yes != "$build_libtool_libs" \
6620862bcd1aSmrg	  && func_fatal_configuration "cannot build a shared library"
662188de56ccSmrg	build_old_libs=no
662288de56ccSmrg	break
662388de56ccSmrg	;;
662488de56ccSmrg      -all-static | -static | -static-libtool-libs)
662588de56ccSmrg	case $arg in
662688de56ccSmrg	-all-static)
6627862bcd1aSmrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
662888de56ccSmrg	    func_warning "complete static linking is impossible in this configuration"
662988de56ccSmrg	  fi
663088de56ccSmrg	  if test -n "$link_static_flag"; then
663188de56ccSmrg	    dlopen_self=$dlopen_self_static
663288de56ccSmrg	  fi
663388de56ccSmrg	  prefer_static_libs=yes
663488de56ccSmrg	  ;;
663588de56ccSmrg	-static)
663688de56ccSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
663788de56ccSmrg	    dlopen_self=$dlopen_self_static
663888de56ccSmrg	  fi
663988de56ccSmrg	  prefer_static_libs=built
664088de56ccSmrg	  ;;
664188de56ccSmrg	-static-libtool-libs)
664288de56ccSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
664388de56ccSmrg	    dlopen_self=$dlopen_self_static
6644b4ee4795Smrg	  fi
664588de56ccSmrg	  prefer_static_libs=yes
664688de56ccSmrg	  ;;
664788de56ccSmrg	esac
664888de56ccSmrg	build_libtool_libs=no
664988de56ccSmrg	build_old_libs=yes
665088de56ccSmrg	break
665188de56ccSmrg	;;
665288de56ccSmrg      esac
665388de56ccSmrg    done
66541ab64890Smrg
665588de56ccSmrg    # See if our shared archives depend on static archives.
665688de56ccSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
66571ab64890Smrg
665888de56ccSmrg    # Go through the arguments, transforming them on the way.
665988de56ccSmrg    while test "$#" -gt 0; do
6660862bcd1aSmrg      arg=$1
666188de56ccSmrg      shift
666288de56ccSmrg      func_quote_for_eval "$arg"
666388de56ccSmrg      qarg=$func_quote_for_eval_unquoted_result
666488de56ccSmrg      func_append libtool_args " $func_quote_for_eval_result"
66651ab64890Smrg
666688de56ccSmrg      # If the previous option needs an argument, assign it.
666788de56ccSmrg      if test -n "$prev"; then
666888de56ccSmrg	case $prev in
666988de56ccSmrg	output)
667088de56ccSmrg	  func_append compile_command " @OUTPUT@"
667188de56ccSmrg	  func_append finalize_command " @OUTPUT@"
667288de56ccSmrg	  ;;
667388de56ccSmrg	esac
66741ab64890Smrg
667588de56ccSmrg	case $prev in
6676e9fcaa8aSmrg	bindir)
6677862bcd1aSmrg	  bindir=$arg
6678e9fcaa8aSmrg	  prev=
6679e9fcaa8aSmrg	  continue
6680e9fcaa8aSmrg	  ;;
668188de56ccSmrg	dlfiles|dlprefiles)
6682862bcd1aSmrg	  $preload || {
668388de56ccSmrg	    # Add the symbol object into the linking commands.
668488de56ccSmrg	    func_append compile_command " @SYMFILE@"
668588de56ccSmrg	    func_append finalize_command " @SYMFILE@"
6686862bcd1aSmrg	    preload=:
6687862bcd1aSmrg	  }
668888de56ccSmrg	  case $arg in
668988de56ccSmrg	  *.la | *.lo) ;;  # We handle these cases below.
669088de56ccSmrg	  force)
6691862bcd1aSmrg	    if test no = "$dlself"; then
669288de56ccSmrg	      dlself=needless
669388de56ccSmrg	      export_dynamic=yes
669488de56ccSmrg	    fi
669588de56ccSmrg	    prev=
669688de56ccSmrg	    continue
669788de56ccSmrg	    ;;
669888de56ccSmrg	  self)
6699862bcd1aSmrg	    if test dlprefiles = "$prev"; then
670088de56ccSmrg	      dlself=yes
6701862bcd1aSmrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
670288de56ccSmrg	      dlself=yes
6703b4ee4795Smrg	    else
670488de56ccSmrg	      dlself=needless
670588de56ccSmrg	      export_dynamic=yes
6706b4ee4795Smrg	    fi
670788de56ccSmrg	    prev=
670888de56ccSmrg	    continue
670988de56ccSmrg	    ;;
671088de56ccSmrg	  *)
6711862bcd1aSmrg	    if test dlfiles = "$prev"; then
6712e9fcaa8aSmrg	      func_append dlfiles " $arg"
6713b4ee4795Smrg	    else
6714e9fcaa8aSmrg	      func_append dlprefiles " $arg"
6715b4ee4795Smrg	    fi
671688de56ccSmrg	    prev=
671788de56ccSmrg	    continue
671888de56ccSmrg	    ;;
671988de56ccSmrg	  esac
672088de56ccSmrg	  ;;
672188de56ccSmrg	expsyms)
6722862bcd1aSmrg	  export_symbols=$arg
672388de56ccSmrg	  test -f "$arg" \
6724862bcd1aSmrg	    || func_fatal_error "symbol file '$arg' does not exist"
672588de56ccSmrg	  prev=
672688de56ccSmrg	  continue
672788de56ccSmrg	  ;;
672888de56ccSmrg	expsyms_regex)
6729862bcd1aSmrg	  export_symbols_regex=$arg
673088de56ccSmrg	  prev=
673188de56ccSmrg	  continue
673288de56ccSmrg	  ;;
673388de56ccSmrg	framework)
6734b4ee4795Smrg	  case $host in
673588de56ccSmrg	    *-*-darwin*)
673688de56ccSmrg	      case "$deplibs " in
673788de56ccSmrg		*" $qarg.ltframework "*) ;;
6738e9fcaa8aSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
673988de56ccSmrg		   ;;
674088de56ccSmrg	      esac
674188de56ccSmrg	      ;;
6742b4ee4795Smrg	  esac
674388de56ccSmrg	  prev=
674488de56ccSmrg	  continue
6745b4ee4795Smrg	  ;;
674688de56ccSmrg	inst_prefix)
6747862bcd1aSmrg	  inst_prefix_dir=$arg
6748862bcd1aSmrg	  prev=
6749862bcd1aSmrg	  continue
6750862bcd1aSmrg	  ;;
6751862bcd1aSmrg	mllvm)
6752862bcd1aSmrg	  # Clang does not use LLVM to link, so we can simply discard any
6753862bcd1aSmrg	  # '-mllvm $arg' options when doing the link step.
675488de56ccSmrg	  prev=
675588de56ccSmrg	  continue
6756b4ee4795Smrg	  ;;
675788de56ccSmrg	objectlist)
675888de56ccSmrg	  if test -f "$arg"; then
675988de56ccSmrg	    save_arg=$arg
676088de56ccSmrg	    moreargs=
676188de56ccSmrg	    for fil in `cat "$save_arg"`
676288de56ccSmrg	    do
6763e9fcaa8aSmrg#	      func_append moreargs " $fil"
676488de56ccSmrg	      arg=$fil
676588de56ccSmrg	      # A libtool-controlled object.
67662e9c7c8cSmrg
676788de56ccSmrg	      # Check to see that this really is a libtool object.
676888de56ccSmrg	      if func_lalib_unsafe_p "$arg"; then
676988de56ccSmrg		pic_object=
677088de56ccSmrg		non_pic_object=
67712e9c7c8cSmrg
677288de56ccSmrg		# Read the .lo file
677388de56ccSmrg		func_source "$arg"
67742e9c7c8cSmrg
677588de56ccSmrg		if test -z "$pic_object" ||
677688de56ccSmrg		   test -z "$non_pic_object" ||
6777862bcd1aSmrg		   test none = "$pic_object" &&
6778862bcd1aSmrg		   test none = "$non_pic_object"; then
6779862bcd1aSmrg		  func_fatal_error "cannot find name of object for '$arg'"
678088de56ccSmrg		fi
67812e9c7c8cSmrg
678288de56ccSmrg		# Extract subdirectory from the argument.
678388de56ccSmrg		func_dirname "$arg" "/" ""
6784862bcd1aSmrg		xdir=$func_dirname_result
67852e9c7c8cSmrg
6786862bcd1aSmrg		if test none != "$pic_object"; then
678788de56ccSmrg		  # Prepend the subdirectory the object is found in.
6788862bcd1aSmrg		  pic_object=$xdir$pic_object
67892e9c7c8cSmrg
6790862bcd1aSmrg		  if test dlfiles = "$prev"; then
6791862bcd1aSmrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6792e9fcaa8aSmrg		      func_append dlfiles " $pic_object"
679388de56ccSmrg		      prev=
679488de56ccSmrg		      continue
679588de56ccSmrg		    else
679688de56ccSmrg		      # If libtool objects are unsupported, then we need to preload.
679788de56ccSmrg		      prev=dlprefiles
679888de56ccSmrg		    fi
679988de56ccSmrg		  fi
68002e9c7c8cSmrg
680188de56ccSmrg		  # CHECK ME:  I think I busted this.  -Ossama
6802862bcd1aSmrg		  if test dlprefiles = "$prev"; then
680388de56ccSmrg		    # Preload the old-style object.
6804e9fcaa8aSmrg		    func_append dlprefiles " $pic_object"
680588de56ccSmrg		    prev=
680688de56ccSmrg		  fi
68072e9c7c8cSmrg
680888de56ccSmrg		  # A PIC object.
680988de56ccSmrg		  func_append libobjs " $pic_object"
6810862bcd1aSmrg		  arg=$pic_object
681188de56ccSmrg		fi
68122e9c7c8cSmrg
681388de56ccSmrg		# Non-PIC object.
6814862bcd1aSmrg		if test none != "$non_pic_object"; then
681588de56ccSmrg		  # Prepend the subdirectory the object is found in.
6816862bcd1aSmrg		  non_pic_object=$xdir$non_pic_object
68172e9c7c8cSmrg
681888de56ccSmrg		  # A standard non-PIC object
681988de56ccSmrg		  func_append non_pic_objects " $non_pic_object"
6820862bcd1aSmrg		  if test -z "$pic_object" || test none = "$pic_object"; then
6821862bcd1aSmrg		    arg=$non_pic_object
682288de56ccSmrg		  fi
682388de56ccSmrg		else
682488de56ccSmrg		  # If the PIC object exists, use it instead.
682588de56ccSmrg		  # $xdir was prepended to $pic_object above.
6826862bcd1aSmrg		  non_pic_object=$pic_object
682788de56ccSmrg		  func_append non_pic_objects " $non_pic_object"
682888de56ccSmrg		fi
682988de56ccSmrg	      else
683088de56ccSmrg		# Only an error if not doing a dry-run.
683188de56ccSmrg		if $opt_dry_run; then
683288de56ccSmrg		  # Extract subdirectory from the argument.
683388de56ccSmrg		  func_dirname "$arg" "/" ""
6834862bcd1aSmrg		  xdir=$func_dirname_result
683588de56ccSmrg
683688de56ccSmrg		  func_lo2o "$arg"
683788de56ccSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
683888de56ccSmrg		  non_pic_object=$xdir$func_lo2o_result
683988de56ccSmrg		  func_append libobjs " $pic_object"
684088de56ccSmrg		  func_append non_pic_objects " $non_pic_object"
684188de56ccSmrg	        else
6842862bcd1aSmrg		  func_fatal_error "'$arg' is not a valid libtool object"
684388de56ccSmrg		fi
684488de56ccSmrg	      fi
684588de56ccSmrg	    done
6846b4ee4795Smrg	  else
6847862bcd1aSmrg	    func_fatal_error "link input file '$arg' does not exist"
6848b4ee4795Smrg	  fi
684988de56ccSmrg	  arg=$save_arg
685088de56ccSmrg	  prev=
685188de56ccSmrg	  continue
685288de56ccSmrg	  ;;
6853862bcd1aSmrg	os2dllname)
6854862bcd1aSmrg	  os2dllname=$arg
6855862bcd1aSmrg	  prev=
6856862bcd1aSmrg	  continue
6857862bcd1aSmrg	  ;;
685888de56ccSmrg	precious_regex)
6859862bcd1aSmrg	  precious_files_regex=$arg
686088de56ccSmrg	  prev=
686188de56ccSmrg	  continue
686288de56ccSmrg	  ;;
686388de56ccSmrg	release)
6864862bcd1aSmrg	  release=-$arg
686588de56ccSmrg	  prev=
686688de56ccSmrg	  continue
686788de56ccSmrg	  ;;
686888de56ccSmrg	rpath | xrpath)
686988de56ccSmrg	  # We need an absolute path.
687088de56ccSmrg	  case $arg in
687188de56ccSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
687288de56ccSmrg	  *)
687388de56ccSmrg	    func_fatal_error "only absolute run-paths are allowed"
687488de56ccSmrg	    ;;
687588de56ccSmrg	  esac
6876862bcd1aSmrg	  if test rpath = "$prev"; then
687788de56ccSmrg	    case "$rpath " in
687888de56ccSmrg	    *" $arg "*) ;;
6879e9fcaa8aSmrg	    *) func_append rpath " $arg" ;;
688088de56ccSmrg	    esac
6881b4ee4795Smrg	  else
688288de56ccSmrg	    case "$xrpath " in
688388de56ccSmrg	    *" $arg "*) ;;
6884e9fcaa8aSmrg	    *) func_append xrpath " $arg" ;;
688588de56ccSmrg	    esac
6886b4ee4795Smrg	  fi
688788de56ccSmrg	  prev=
688888de56ccSmrg	  continue
688988de56ccSmrg	  ;;
689088de56ccSmrg	shrext)
6891862bcd1aSmrg	  shrext_cmds=$arg
689288de56ccSmrg	  prev=
689388de56ccSmrg	  continue
689488de56ccSmrg	  ;;
689588de56ccSmrg	weak)
6896e9fcaa8aSmrg	  func_append weak_libs " $arg"
689788de56ccSmrg	  prev=
689888de56ccSmrg	  continue
689988de56ccSmrg	  ;;
690088de56ccSmrg	xcclinker)
6901e9fcaa8aSmrg	  func_append linker_flags " $qarg"
6902e9fcaa8aSmrg	  func_append compiler_flags " $qarg"
690388de56ccSmrg	  prev=
690488de56ccSmrg	  func_append compile_command " $qarg"
690588de56ccSmrg	  func_append finalize_command " $qarg"
690688de56ccSmrg	  continue
690788de56ccSmrg	  ;;
690888de56ccSmrg	xcompiler)
6909e9fcaa8aSmrg	  func_append compiler_flags " $qarg"
691088de56ccSmrg	  prev=
691188de56ccSmrg	  func_append compile_command " $qarg"
691288de56ccSmrg	  func_append finalize_command " $qarg"
691388de56ccSmrg	  continue
691488de56ccSmrg	  ;;
691588de56ccSmrg	xlinker)
6916e9fcaa8aSmrg	  func_append linker_flags " $qarg"
6917e9fcaa8aSmrg	  func_append compiler_flags " $wl$qarg"
691888de56ccSmrg	  prev=
691988de56ccSmrg	  func_append compile_command " $wl$qarg"
692088de56ccSmrg	  func_append finalize_command " $wl$qarg"
692188de56ccSmrg	  continue
692288de56ccSmrg	  ;;
692388de56ccSmrg	*)
692488de56ccSmrg	  eval "$prev=\"\$arg\""
692588de56ccSmrg	  prev=
692688de56ccSmrg	  continue
692788de56ccSmrg	  ;;
69282e9c7c8cSmrg	esac
692988de56ccSmrg      fi # test -n "$prev"
69302e9c7c8cSmrg
6931862bcd1aSmrg      prevarg=$arg
69322e9c7c8cSmrg
693388de56ccSmrg      case $arg in
693488de56ccSmrg      -all-static)
693588de56ccSmrg	if test -n "$link_static_flag"; then
693688de56ccSmrg	  # See comment for -static flag below, for more details.
693788de56ccSmrg	  func_append compile_command " $link_static_flag"
693888de56ccSmrg	  func_append finalize_command " $link_static_flag"
693988de56ccSmrg	fi
694088de56ccSmrg	continue
694188de56ccSmrg	;;
69422e9c7c8cSmrg
694388de56ccSmrg      -allow-undefined)
694488de56ccSmrg	# FIXME: remove this flag sometime in the future.
6945862bcd1aSmrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
694688de56ccSmrg	;;
69472e9c7c8cSmrg
694888de56ccSmrg      -avoid-version)
694988de56ccSmrg	avoid_version=yes
695088de56ccSmrg	continue
695188de56ccSmrg	;;
69522e9c7c8cSmrg
6953e9fcaa8aSmrg      -bindir)
6954e9fcaa8aSmrg	prev=bindir
6955e9fcaa8aSmrg	continue
6956e9fcaa8aSmrg	;;
6957e9fcaa8aSmrg
695888de56ccSmrg      -dlopen)
695988de56ccSmrg	prev=dlfiles
696088de56ccSmrg	continue
696188de56ccSmrg	;;
69622e9c7c8cSmrg
696388de56ccSmrg      -dlpreopen)
696488de56ccSmrg	prev=dlprefiles
696588de56ccSmrg	continue
696688de56ccSmrg	;;
69672e9c7c8cSmrg
696888de56ccSmrg      -export-dynamic)
696988de56ccSmrg	export_dynamic=yes
697088de56ccSmrg	continue
697188de56ccSmrg	;;
69722e9c7c8cSmrg
697388de56ccSmrg      -export-symbols | -export-symbols-regex)
697488de56ccSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
697588de56ccSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
697688de56ccSmrg	fi
6977862bcd1aSmrg	if test X-export-symbols = "X$arg"; then
697888de56ccSmrg	  prev=expsyms
697988de56ccSmrg	else
698088de56ccSmrg	  prev=expsyms_regex
698188de56ccSmrg	fi
698288de56ccSmrg	continue
698388de56ccSmrg	;;
69842e9c7c8cSmrg
698588de56ccSmrg      -framework)
698688de56ccSmrg	prev=framework
698788de56ccSmrg	continue
698888de56ccSmrg	;;
69892e9c7c8cSmrg
699088de56ccSmrg      -inst-prefix-dir)
699188de56ccSmrg	prev=inst_prefix
699288de56ccSmrg	continue
699388de56ccSmrg	;;
69942e9c7c8cSmrg
699588de56ccSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
699688de56ccSmrg      # so, if we see these flags be careful not to treat them like -L
699788de56ccSmrg      -L[A-Z][A-Z]*:*)
699888de56ccSmrg	case $with_gcc/$host in
699988de56ccSmrg	no/*-*-irix* | /*-*-irix*)
700088de56ccSmrg	  func_append compile_command " $arg"
700188de56ccSmrg	  func_append finalize_command " $arg"
700288de56ccSmrg	  ;;
700388de56ccSmrg	esac
700488de56ccSmrg	continue
700588de56ccSmrg	;;
70062e9c7c8cSmrg
700788de56ccSmrg      -L*)
7008e9fcaa8aSmrg	func_stripname "-L" '' "$arg"
7009e9fcaa8aSmrg	if test -z "$func_stripname_result"; then
701088de56ccSmrg	  if test "$#" -gt 0; then
7011862bcd1aSmrg	    func_fatal_error "require no space between '-L' and '$1'"
701288de56ccSmrg	  else
7013862bcd1aSmrg	    func_fatal_error "need path for '-L' option"
701488de56ccSmrg	  fi
701588de56ccSmrg	fi
7016e9fcaa8aSmrg	func_resolve_sysroot "$func_stripname_result"
7017e9fcaa8aSmrg	dir=$func_resolve_sysroot_result
701888de56ccSmrg	# We need an absolute path.
701988de56ccSmrg	case $dir in
702088de56ccSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
702188de56ccSmrg	*)
702288de56ccSmrg	  absdir=`cd "$dir" && pwd`
702388de56ccSmrg	  test -z "$absdir" && \
7024862bcd1aSmrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
7025862bcd1aSmrg	  dir=$absdir
702688de56ccSmrg	  ;;
702788de56ccSmrg	esac
702888de56ccSmrg	case "$deplibs " in
7029e9fcaa8aSmrg	*" -L$dir "* | *" $arg "*)
7030e9fcaa8aSmrg	  # Will only happen for absolute or sysroot arguments
7031e9fcaa8aSmrg	  ;;
703288de56ccSmrg	*)
7033e9fcaa8aSmrg	  # Preserve sysroot, but never include relative directories
7034e9fcaa8aSmrg	  case $dir in
7035e9fcaa8aSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
7036e9fcaa8aSmrg	    *) func_append deplibs " -L$dir" ;;
7037e9fcaa8aSmrg	  esac
7038e9fcaa8aSmrg	  func_append lib_search_path " $dir"
703988de56ccSmrg	  ;;
704088de56ccSmrg	esac
704188de56ccSmrg	case $host in
704288de56ccSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7043e9fcaa8aSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
704488de56ccSmrg	  case :$dllsearchpath: in
704588de56ccSmrg	  *":$dir:"*) ;;
704688de56ccSmrg	  ::) dllsearchpath=$dir;;
7047e9fcaa8aSmrg	  *) func_append dllsearchpath ":$dir";;
704888de56ccSmrg	  esac
704988de56ccSmrg	  case :$dllsearchpath: in
705088de56ccSmrg	  *":$testbindir:"*) ;;
705188de56ccSmrg	  ::) dllsearchpath=$testbindir;;
7052e9fcaa8aSmrg	  *) func_append dllsearchpath ":$testbindir";;
705388de56ccSmrg	  esac
705488de56ccSmrg	  ;;
705588de56ccSmrg	esac
705688de56ccSmrg	continue
705788de56ccSmrg	;;
70582e9c7c8cSmrg
705988de56ccSmrg      -l*)
7060862bcd1aSmrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
706188de56ccSmrg	  case $host in
7062e9fcaa8aSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
706388de56ccSmrg	    # These systems don't actually have a C or math library (as such)
706488de56ccSmrg	    continue
706588de56ccSmrg	    ;;
706688de56ccSmrg	  *-*-os2*)
706788de56ccSmrg	    # These systems don't actually have a C library (as such)
7068862bcd1aSmrg	    test X-lc = "X$arg" && continue
706988de56ccSmrg	    ;;
7070862bcd1aSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
707188de56ccSmrg	    # Do not include libc due to us having libc/libc_r.
7072862bcd1aSmrg	    test X-lc = "X$arg" && continue
707388de56ccSmrg	    ;;
707488de56ccSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
707588de56ccSmrg	    # Rhapsody C and math libraries are in the System framework
7076e9fcaa8aSmrg	    func_append deplibs " System.ltframework"
707788de56ccSmrg	    continue
707888de56ccSmrg	    ;;
707988de56ccSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
708088de56ccSmrg	    # Causes problems with __ctype
7081862bcd1aSmrg	    test X-lc = "X$arg" && continue
708288de56ccSmrg	    ;;
708388de56ccSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
708488de56ccSmrg	    # Compiler inserts libc in the correct place for threads to work
7085862bcd1aSmrg	    test X-lc = "X$arg" && continue
708688de56ccSmrg	    ;;
708788de56ccSmrg	  esac
7088862bcd1aSmrg	elif test X-lc_r = "X$arg"; then
708988de56ccSmrg	 case $host in
7090862bcd1aSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
709188de56ccSmrg	   # Do not include libc_r directly, use -pthread flag.
709288de56ccSmrg	   continue
709388de56ccSmrg	   ;;
709488de56ccSmrg	 esac
709588de56ccSmrg	fi
7096e9fcaa8aSmrg	func_append deplibs " $arg"
709788de56ccSmrg	continue
709888de56ccSmrg	;;
70992e9c7c8cSmrg
7100862bcd1aSmrg      -mllvm)
7101862bcd1aSmrg	prev=mllvm
7102862bcd1aSmrg	continue
7103862bcd1aSmrg	;;
7104862bcd1aSmrg
710588de56ccSmrg      -module)
710688de56ccSmrg	module=yes
710788de56ccSmrg	continue
710888de56ccSmrg	;;
71092e9c7c8cSmrg
711088de56ccSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
711188de56ccSmrg      # classes, name mangling, and exception handling.
711288de56ccSmrg      # Darwin uses the -arch flag to determine output architecture.
7113e9fcaa8aSmrg      -model|-arch|-isysroot|--sysroot)
7114e9fcaa8aSmrg	func_append compiler_flags " $arg"
711588de56ccSmrg	func_append compile_command " $arg"
711688de56ccSmrg	func_append finalize_command " $arg"
711788de56ccSmrg	prev=xcompiler
711888de56ccSmrg	continue
711988de56ccSmrg	;;
71202e9c7c8cSmrg
7121eb411b4bSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7122eb411b4bSmrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7123e9fcaa8aSmrg	func_append compiler_flags " $arg"
712488de56ccSmrg	func_append compile_command " $arg"
712588de56ccSmrg	func_append finalize_command " $arg"
712688de56ccSmrg	case "$new_inherited_linker_flags " in
712788de56ccSmrg	    *" $arg "*) ;;
7128e9fcaa8aSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
712988de56ccSmrg	esac
713088de56ccSmrg	continue
713188de56ccSmrg	;;
71322e9c7c8cSmrg
713388de56ccSmrg      -multi_module)
7134862bcd1aSmrg	single_module=$wl-multi_module
713588de56ccSmrg	continue
713688de56ccSmrg	;;
71372e9c7c8cSmrg
713888de56ccSmrg      -no-fast-install)
713988de56ccSmrg	fast_install=no
714088de56ccSmrg	continue
714188de56ccSmrg	;;
71422e9c7c8cSmrg
714388de56ccSmrg      -no-install)
714488de56ccSmrg	case $host in
714588de56ccSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
714688de56ccSmrg	  # The PATH hackery in wrapper scripts is required on Windows
714788de56ccSmrg	  # and Darwin in order for the loader to find any dlls it needs.
7148862bcd1aSmrg	  func_warning "'-no-install' is ignored for $host"
7149862bcd1aSmrg	  func_warning "assuming '-no-fast-install' instead"
715088de56ccSmrg	  fast_install=no
715188de56ccSmrg	  ;;
715288de56ccSmrg	*) no_install=yes ;;
715388de56ccSmrg	esac
715488de56ccSmrg	continue
715588de56ccSmrg	;;
71562e9c7c8cSmrg
715788de56ccSmrg      -no-undefined)
715888de56ccSmrg	allow_undefined=no
715988de56ccSmrg	continue
716088de56ccSmrg	;;
71612e9c7c8cSmrg
716288de56ccSmrg      -objectlist)
716388de56ccSmrg	prev=objectlist
716488de56ccSmrg	continue
716588de56ccSmrg	;;
71662e9c7c8cSmrg
7167862bcd1aSmrg      -os2dllname)
7168862bcd1aSmrg	prev=os2dllname
7169862bcd1aSmrg	continue
7170862bcd1aSmrg	;;
7171862bcd1aSmrg
717288de56ccSmrg      -o) prev=output ;;
71732e9c7c8cSmrg
717488de56ccSmrg      -precious-files-regex)
717588de56ccSmrg	prev=precious_regex
717688de56ccSmrg	continue
717788de56ccSmrg	;;
71782e9c7c8cSmrg
717988de56ccSmrg      -release)
718088de56ccSmrg	prev=release
718188de56ccSmrg	continue
718288de56ccSmrg	;;
71832e9c7c8cSmrg
718488de56ccSmrg      -rpath)
718588de56ccSmrg	prev=rpath
718688de56ccSmrg	continue
718788de56ccSmrg	;;
71882e9c7c8cSmrg
718988de56ccSmrg      -R)
719088de56ccSmrg	prev=xrpath
719188de56ccSmrg	continue
719288de56ccSmrg	;;
71932e9c7c8cSmrg
719488de56ccSmrg      -R*)
719588de56ccSmrg	func_stripname '-R' '' "$arg"
719688de56ccSmrg	dir=$func_stripname_result
719788de56ccSmrg	# We need an absolute path.
719888de56ccSmrg	case $dir in
719988de56ccSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
7200e9fcaa8aSmrg	=*)
7201e9fcaa8aSmrg	  func_stripname '=' '' "$dir"
7202e9fcaa8aSmrg	  dir=$lt_sysroot$func_stripname_result
7203e9fcaa8aSmrg	  ;;
720488de56ccSmrg	*)
720588de56ccSmrg	  func_fatal_error "only absolute run-paths are allowed"
720688de56ccSmrg	  ;;
720788de56ccSmrg	esac
720888de56ccSmrg	case "$xrpath " in
720988de56ccSmrg	*" $dir "*) ;;
7210e9fcaa8aSmrg	*) func_append xrpath " $dir" ;;
721188de56ccSmrg	esac
721288de56ccSmrg	continue
721388de56ccSmrg	;;
72142e9c7c8cSmrg
721588de56ccSmrg      -shared)
721688de56ccSmrg	# The effects of -shared are defined in a previous loop.
721788de56ccSmrg	continue
721888de56ccSmrg	;;
72192e9c7c8cSmrg
722088de56ccSmrg      -shrext)
722188de56ccSmrg	prev=shrext
722288de56ccSmrg	continue
722388de56ccSmrg	;;
72242e9c7c8cSmrg
722588de56ccSmrg      -static | -static-libtool-libs)
722688de56ccSmrg	# The effects of -static are defined in a previous loop.
722788de56ccSmrg	# We used to do the same as -all-static on platforms that
722888de56ccSmrg	# didn't have a PIC flag, but the assumption that the effects
722988de56ccSmrg	# would be equivalent was wrong.  It would break on at least
723088de56ccSmrg	# Digital Unix and AIX.
723188de56ccSmrg	continue
723288de56ccSmrg	;;
72332e9c7c8cSmrg
723488de56ccSmrg      -thread-safe)
723588de56ccSmrg	thread_safe=yes
723688de56ccSmrg	continue
723788de56ccSmrg	;;
72382e9c7c8cSmrg
723988de56ccSmrg      -version-info)
724088de56ccSmrg	prev=vinfo
724188de56ccSmrg	continue
724288de56ccSmrg	;;
72432e9c7c8cSmrg
724488de56ccSmrg      -version-number)
724588de56ccSmrg	prev=vinfo
724688de56ccSmrg	vinfo_number=yes
724788de56ccSmrg	continue
724888de56ccSmrg	;;
72492e9c7c8cSmrg
725088de56ccSmrg      -weak)
725188de56ccSmrg        prev=weak
725288de56ccSmrg	continue
725388de56ccSmrg	;;
72541ab64890Smrg
725588de56ccSmrg      -Wc,*)
725688de56ccSmrg	func_stripname '-Wc,' '' "$arg"
725788de56ccSmrg	args=$func_stripname_result
725888de56ccSmrg	arg=
7259862bcd1aSmrg	save_ifs=$IFS; IFS=,
726088de56ccSmrg	for flag in $args; do
7261862bcd1aSmrg	  IFS=$save_ifs
726288de56ccSmrg          func_quote_for_eval "$flag"
7263e9fcaa8aSmrg	  func_append arg " $func_quote_for_eval_result"
7264e9fcaa8aSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
726588de56ccSmrg	done
7266862bcd1aSmrg	IFS=$save_ifs
726788de56ccSmrg	func_stripname ' ' '' "$arg"
726888de56ccSmrg	arg=$func_stripname_result
726988de56ccSmrg	;;
7270b4ee4795Smrg
727188de56ccSmrg      -Wl,*)
727288de56ccSmrg	func_stripname '-Wl,' '' "$arg"
727388de56ccSmrg	args=$func_stripname_result
727488de56ccSmrg	arg=
7275862bcd1aSmrg	save_ifs=$IFS; IFS=,
727688de56ccSmrg	for flag in $args; do
7277862bcd1aSmrg	  IFS=$save_ifs
727888de56ccSmrg          func_quote_for_eval "$flag"
7279e9fcaa8aSmrg	  func_append arg " $wl$func_quote_for_eval_result"
7280e9fcaa8aSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
7281e9fcaa8aSmrg	  func_append linker_flags " $func_quote_for_eval_result"
728288de56ccSmrg	done
7283862bcd1aSmrg	IFS=$save_ifs
728488de56ccSmrg	func_stripname ' ' '' "$arg"
728588de56ccSmrg	arg=$func_stripname_result
728688de56ccSmrg	;;
7287b4ee4795Smrg
728888de56ccSmrg      -Xcompiler)
728988de56ccSmrg	prev=xcompiler
729088de56ccSmrg	continue
729188de56ccSmrg	;;
7292b4ee4795Smrg
729388de56ccSmrg      -Xlinker)
729488de56ccSmrg	prev=xlinker
729588de56ccSmrg	continue
729688de56ccSmrg	;;
7297b4ee4795Smrg
729888de56ccSmrg      -XCClinker)
729988de56ccSmrg	prev=xcclinker
730088de56ccSmrg	continue
730188de56ccSmrg	;;
7302b4ee4795Smrg
730388de56ccSmrg      # -msg_* for osf cc
730488de56ccSmrg      -msg_*)
730588de56ccSmrg	func_quote_for_eval "$arg"
7306862bcd1aSmrg	arg=$func_quote_for_eval_result
730788de56ccSmrg	;;
7308b4ee4795Smrg
7309e9fcaa8aSmrg      # Flags to be passed through unchanged, with rationale:
7310e9fcaa8aSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
7311e9fcaa8aSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
7312e9fcaa8aSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7313e9fcaa8aSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
7314e9fcaa8aSmrg      # -q*                  compiler args for the IBM compiler
7315e9fcaa8aSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7316e9fcaa8aSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
7317e9fcaa8aSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
7318862bcd1aSmrg      # -fstack-protector*   stack protector flags for GCC
7319e9fcaa8aSmrg      # @file                GCC response files
7320e9fcaa8aSmrg      # -tp=*                Portland pgcc target processor selection
7321e9fcaa8aSmrg      # --sysroot=*          for sysroot support
7322862bcd1aSmrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
73233233502eSmrg      # -specs=*             GCC specs files
7324862bcd1aSmrg      # -stdlib=*            select c++ std lib with clang
73253233502eSmrg      # -fsanitize=*         Clang/GCC memory and address sanitizer
732638ae11fcSmrg      # -fuse-ld=*           Linker select flags for GCC
732788de56ccSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7328e9fcaa8aSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
73293233502eSmrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
733038ae11fcSmrg      -specs=*|-fsanitize=*|-fuse-ld=*)
733188de56ccSmrg        func_quote_for_eval "$arg"
7332862bcd1aSmrg	arg=$func_quote_for_eval_result
733388de56ccSmrg        func_append compile_command " $arg"
733488de56ccSmrg        func_append finalize_command " $arg"
7335e9fcaa8aSmrg        func_append compiler_flags " $arg"
733688de56ccSmrg        continue
733788de56ccSmrg        ;;
7338b4ee4795Smrg
7339862bcd1aSmrg      -Z*)
7340862bcd1aSmrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
7341862bcd1aSmrg          # OS/2 uses -Zxxx to specify OS/2-specific options
7342862bcd1aSmrg	  compiler_flags="$compiler_flags $arg"
7343862bcd1aSmrg	  func_append compile_command " $arg"
7344862bcd1aSmrg	  func_append finalize_command " $arg"
7345862bcd1aSmrg	  case $arg in
7346862bcd1aSmrg	  -Zlinker | -Zstack)
7347862bcd1aSmrg	    prev=xcompiler
7348862bcd1aSmrg	    ;;
7349862bcd1aSmrg	  esac
7350862bcd1aSmrg	  continue
7351862bcd1aSmrg        else
7352862bcd1aSmrg	  # Otherwise treat like 'Some other compiler flag' below
7353862bcd1aSmrg	  func_quote_for_eval "$arg"
7354862bcd1aSmrg	  arg=$func_quote_for_eval_result
7355862bcd1aSmrg        fi
7356862bcd1aSmrg	;;
7357862bcd1aSmrg
735888de56ccSmrg      # Some other compiler flag.
735988de56ccSmrg      -* | +*)
736088de56ccSmrg        func_quote_for_eval "$arg"
7361862bcd1aSmrg	arg=$func_quote_for_eval_result
736288de56ccSmrg	;;
7363b4ee4795Smrg
736488de56ccSmrg      *.$objext)
736588de56ccSmrg	# A standard object.
7366e9fcaa8aSmrg	func_append objs " $arg"
736788de56ccSmrg	;;
7368b4ee4795Smrg
736988de56ccSmrg      *.lo)
737088de56ccSmrg	# A libtool-controlled object.
7371b4ee4795Smrg
737288de56ccSmrg	# Check to see that this really is a libtool object.
737388de56ccSmrg	if func_lalib_unsafe_p "$arg"; then
737488de56ccSmrg	  pic_object=
737588de56ccSmrg	  non_pic_object=
7376b4ee4795Smrg
737788de56ccSmrg	  # Read the .lo file
737888de56ccSmrg	  func_source "$arg"
7379b4ee4795Smrg
738088de56ccSmrg	  if test -z "$pic_object" ||
738188de56ccSmrg	     test -z "$non_pic_object" ||
7382862bcd1aSmrg	     test none = "$pic_object" &&
7383862bcd1aSmrg	     test none = "$non_pic_object"; then
7384862bcd1aSmrg	    func_fatal_error "cannot find name of object for '$arg'"
738588de56ccSmrg	  fi
7386b4ee4795Smrg
738788de56ccSmrg	  # Extract subdirectory from the argument.
738888de56ccSmrg	  func_dirname "$arg" "/" ""
7389862bcd1aSmrg	  xdir=$func_dirname_result
7390b4ee4795Smrg
7391862bcd1aSmrg	  test none = "$pic_object" || {
739288de56ccSmrg	    # Prepend the subdirectory the object is found in.
7393862bcd1aSmrg	    pic_object=$xdir$pic_object
7394b4ee4795Smrg
7395862bcd1aSmrg	    if test dlfiles = "$prev"; then
7396862bcd1aSmrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7397e9fcaa8aSmrg		func_append dlfiles " $pic_object"
739888de56ccSmrg		prev=
739988de56ccSmrg		continue
740088de56ccSmrg	      else
740188de56ccSmrg		# If libtool objects are unsupported, then we need to preload.
740288de56ccSmrg		prev=dlprefiles
740388de56ccSmrg	      fi
740488de56ccSmrg	    fi
7405b4ee4795Smrg
740688de56ccSmrg	    # CHECK ME:  I think I busted this.  -Ossama
7407862bcd1aSmrg	    if test dlprefiles = "$prev"; then
740888de56ccSmrg	      # Preload the old-style object.
7409e9fcaa8aSmrg	      func_append dlprefiles " $pic_object"
741088de56ccSmrg	      prev=
741188de56ccSmrg	    fi
74121ab64890Smrg
741388de56ccSmrg	    # A PIC object.
741488de56ccSmrg	    func_append libobjs " $pic_object"
7415862bcd1aSmrg	    arg=$pic_object
7416862bcd1aSmrg	  }
74171ab64890Smrg
741888de56ccSmrg	  # Non-PIC object.
7419862bcd1aSmrg	  if test none != "$non_pic_object"; then
742088de56ccSmrg	    # Prepend the subdirectory the object is found in.
7421862bcd1aSmrg	    non_pic_object=$xdir$non_pic_object
74221ab64890Smrg
742388de56ccSmrg	    # A standard non-PIC object
742488de56ccSmrg	    func_append non_pic_objects " $non_pic_object"
7425862bcd1aSmrg	    if test -z "$pic_object" || test none = "$pic_object"; then
7426862bcd1aSmrg	      arg=$non_pic_object
742788de56ccSmrg	    fi
742888de56ccSmrg	  else
742988de56ccSmrg	    # If the PIC object exists, use it instead.
743088de56ccSmrg	    # $xdir was prepended to $pic_object above.
7431862bcd1aSmrg	    non_pic_object=$pic_object
743288de56ccSmrg	    func_append non_pic_objects " $non_pic_object"
743388de56ccSmrg	  fi
743488de56ccSmrg	else
743588de56ccSmrg	  # Only an error if not doing a dry-run.
743688de56ccSmrg	  if $opt_dry_run; then
743788de56ccSmrg	    # Extract subdirectory from the argument.
743888de56ccSmrg	    func_dirname "$arg" "/" ""
7439862bcd1aSmrg	    xdir=$func_dirname_result
744088de56ccSmrg
744188de56ccSmrg	    func_lo2o "$arg"
744288de56ccSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
744388de56ccSmrg	    non_pic_object=$xdir$func_lo2o_result
744488de56ccSmrg	    func_append libobjs " $pic_object"
744588de56ccSmrg	    func_append non_pic_objects " $non_pic_object"
744688de56ccSmrg	  else
7447862bcd1aSmrg	    func_fatal_error "'$arg' is not a valid libtool object"
744888de56ccSmrg	  fi
744988de56ccSmrg	fi
745088de56ccSmrg	;;
74511ab64890Smrg
745288de56ccSmrg      *.$libext)
745388de56ccSmrg	# An archive.
7454e9fcaa8aSmrg	func_append deplibs " $arg"
7455e9fcaa8aSmrg	func_append old_deplibs " $arg"
745688de56ccSmrg	continue
745788de56ccSmrg	;;
745888de56ccSmrg
745988de56ccSmrg      *.la)
746088de56ccSmrg	# A libtool-controlled library.
746188de56ccSmrg
7462e9fcaa8aSmrg	func_resolve_sysroot "$arg"
7463862bcd1aSmrg	if test dlfiles = "$prev"; then
746488de56ccSmrg	  # This library was specified with -dlopen.
7465e9fcaa8aSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
746688de56ccSmrg	  prev=
7467862bcd1aSmrg	elif test dlprefiles = "$prev"; then
746888de56ccSmrg	  # The library was specified with -dlpreopen.
7469e9fcaa8aSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
747088de56ccSmrg	  prev=
747188de56ccSmrg	else
7472e9fcaa8aSmrg	  func_append deplibs " $func_resolve_sysroot_result"
747388de56ccSmrg	fi
747488de56ccSmrg	continue
747588de56ccSmrg	;;
747688de56ccSmrg
747788de56ccSmrg      # Some other compiler argument.
747888de56ccSmrg      *)
747988de56ccSmrg	# Unknown arguments in both finalize_command and compile_command need
748088de56ccSmrg	# to be aesthetically quoted because they are evaled later.
748188de56ccSmrg	func_quote_for_eval "$arg"
7482862bcd1aSmrg	arg=$func_quote_for_eval_result
748388de56ccSmrg	;;
748488de56ccSmrg      esac # arg
748588de56ccSmrg
748688de56ccSmrg      # Now actually substitute the argument into the commands.
748788de56ccSmrg      if test -n "$arg"; then
748888de56ccSmrg	func_append compile_command " $arg"
748988de56ccSmrg	func_append finalize_command " $arg"
749088de56ccSmrg      fi
749188de56ccSmrg    done # argument parsing loop
749288de56ccSmrg
749388de56ccSmrg    test -n "$prev" && \
7494862bcd1aSmrg      func_fatal_help "the '$prevarg' option requires an argument"
749588de56ccSmrg
7496862bcd1aSmrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
749788de56ccSmrg      eval arg=\"$export_dynamic_flag_spec\"
749888de56ccSmrg      func_append compile_command " $arg"
749988de56ccSmrg      func_append finalize_command " $arg"
750088de56ccSmrg    fi
750188de56ccSmrg
750288de56ccSmrg    oldlibs=
750388de56ccSmrg    # calculate the name of the file, without its directory
750488de56ccSmrg    func_basename "$output"
7505862bcd1aSmrg    outputname=$func_basename_result
7506862bcd1aSmrg    libobjs_save=$libobjs
750788de56ccSmrg
750888de56ccSmrg    if test -n "$shlibpath_var"; then
750988de56ccSmrg      # get the directories listed in $shlibpath_var
7510862bcd1aSmrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
751188de56ccSmrg    else
751288de56ccSmrg      shlib_search_path=
751388de56ccSmrg    fi
751488de56ccSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
751588de56ccSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
751688de56ccSmrg
7517862bcd1aSmrg    # Definition is injected by LT_CONFIG during libtool generation.
7518862bcd1aSmrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
7519862bcd1aSmrg
752088de56ccSmrg    func_dirname "$output" "/" ""
7521862bcd1aSmrg    output_objdir=$func_dirname_result$objdir
7522e9fcaa8aSmrg    func_to_tool_file "$output_objdir/"
7523e9fcaa8aSmrg    tool_output_objdir=$func_to_tool_file_result
752488de56ccSmrg    # Create the object directory.
752588de56ccSmrg    func_mkdir_p "$output_objdir"
752688de56ccSmrg
752788de56ccSmrg    # Determine the type of output
752888de56ccSmrg    case $output in
752988de56ccSmrg    "")
753088de56ccSmrg      func_fatal_help "you must specify an output file"
753188de56ccSmrg      ;;
753288de56ccSmrg    *.$libext) linkmode=oldlib ;;
753388de56ccSmrg    *.lo | *.$objext) linkmode=obj ;;
753488de56ccSmrg    *.la) linkmode=lib ;;
753588de56ccSmrg    *) linkmode=prog ;; # Anything else should be a program.
753688de56ccSmrg    esac
753788de56ccSmrg
753888de56ccSmrg    specialdeplibs=
753988de56ccSmrg
754088de56ccSmrg    libs=
754188de56ccSmrg    # Find all interdependent deplibs by searching for libraries
754288de56ccSmrg    # that are linked more than once (e.g. -la -lb -la)
754388de56ccSmrg    for deplib in $deplibs; do
7544862bcd1aSmrg      if $opt_preserve_dup_deps; then
754588de56ccSmrg	case "$libs " in
7546e9fcaa8aSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
754788de56ccSmrg	esac
754888de56ccSmrg      fi
7549e9fcaa8aSmrg      func_append libs " $deplib"
755088de56ccSmrg    done
755188de56ccSmrg
7552862bcd1aSmrg    if test lib = "$linkmode"; then
755388de56ccSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
755488de56ccSmrg
755588de56ccSmrg      # Compute libraries that are listed more than once in $predeps
755688de56ccSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
755788de56ccSmrg      # not to be eliminated).
755888de56ccSmrg      pre_post_deps=
755988de56ccSmrg      if $opt_duplicate_compiler_generated_deps; then
756088de56ccSmrg	for pre_post_dep in $predeps $postdeps; do
756188de56ccSmrg	  case "$pre_post_deps " in
7562e9fcaa8aSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
756388de56ccSmrg	  esac
7564e9fcaa8aSmrg	  func_append pre_post_deps " $pre_post_dep"
756588de56ccSmrg	done
756688de56ccSmrg      fi
756788de56ccSmrg      pre_post_deps=
756888de56ccSmrg    fi
756988de56ccSmrg
757088de56ccSmrg    deplibs=
757188de56ccSmrg    newdependency_libs=
757288de56ccSmrg    newlib_search_path=
757388de56ccSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
757488de56ccSmrg    notinst_deplibs= # not-installed libtool libraries
757588de56ccSmrg    notinst_path= # paths that contain not-installed libtool libraries
757688de56ccSmrg
757788de56ccSmrg    case $linkmode in
757888de56ccSmrg    lib)
757988de56ccSmrg	passes="conv dlpreopen link"
758088de56ccSmrg	for file in $dlfiles $dlprefiles; do
758188de56ccSmrg	  case $file in
758288de56ccSmrg	  *.la) ;;
758388de56ccSmrg	  *)
7584862bcd1aSmrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
758588de56ccSmrg	    ;;
758688de56ccSmrg	  esac
758788de56ccSmrg	done
758888de56ccSmrg	;;
758988de56ccSmrg    prog)
759088de56ccSmrg	compile_deplibs=
759188de56ccSmrg	finalize_deplibs=
7592862bcd1aSmrg	alldeplibs=false
759388de56ccSmrg	newdlfiles=
759488de56ccSmrg	newdlprefiles=
759588de56ccSmrg	passes="conv scan dlopen dlpreopen link"
759688de56ccSmrg	;;
759788de56ccSmrg    *)  passes="conv"
759888de56ccSmrg	;;
759988de56ccSmrg    esac
760088de56ccSmrg
760188de56ccSmrg    for pass in $passes; do
760288de56ccSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
760388de56ccSmrg      # so that -L comes before libs that need it for instance...
7604862bcd1aSmrg      if test lib,link = "$linkmode,$pass"; then
760588de56ccSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
760688de56ccSmrg	##        order, and fix it there properly
760788de56ccSmrg        tmp_deplibs=
760888de56ccSmrg	for deplib in $deplibs; do
760988de56ccSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
761088de56ccSmrg	done
7611862bcd1aSmrg	deplibs=$tmp_deplibs
761288de56ccSmrg      fi
761388de56ccSmrg
7614862bcd1aSmrg      if test lib,link = "$linkmode,$pass" ||
7615862bcd1aSmrg	 test prog,scan = "$linkmode,$pass"; then
7616862bcd1aSmrg	libs=$deplibs
761788de56ccSmrg	deplibs=
761888de56ccSmrg      fi
7619862bcd1aSmrg      if test prog = "$linkmode"; then
762088de56ccSmrg	case $pass in
7621862bcd1aSmrg	dlopen) libs=$dlfiles ;;
7622862bcd1aSmrg	dlpreopen) libs=$dlprefiles ;;
762338ae11fcSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
762488de56ccSmrg	esac
762588de56ccSmrg      fi
7626862bcd1aSmrg      if test lib,dlpreopen = "$linkmode,$pass"; then
762788de56ccSmrg	# Collect and forward deplibs of preopened libtool libs
762888de56ccSmrg	for lib in $dlprefiles; do
762988de56ccSmrg	  # Ignore non-libtool-libs
763088de56ccSmrg	  dependency_libs=
7631e9fcaa8aSmrg	  func_resolve_sysroot "$lib"
763288de56ccSmrg	  case $lib in
7633e9fcaa8aSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
763488de56ccSmrg	  esac
763588de56ccSmrg
763688de56ccSmrg	  # Collect preopened libtool deplibs, except any this library
763788de56ccSmrg	  # has declared as weak libs
763888de56ccSmrg	  for deplib in $dependency_libs; do
7639e9fcaa8aSmrg	    func_basename "$deplib"
7640e9fcaa8aSmrg            deplib_base=$func_basename_result
764188de56ccSmrg	    case " $weak_libs " in
764288de56ccSmrg	    *" $deplib_base "*) ;;
7643e9fcaa8aSmrg	    *) func_append deplibs " $deplib" ;;
764488de56ccSmrg	    esac
764588de56ccSmrg	  done
764688de56ccSmrg	done
7647862bcd1aSmrg	libs=$dlprefiles
764888de56ccSmrg      fi
7649862bcd1aSmrg      if test dlopen = "$pass"; then
765088de56ccSmrg	# Collect dlpreopened libraries
7651862bcd1aSmrg	save_deplibs=$deplibs
765288de56ccSmrg	deplibs=
765388de56ccSmrg      fi
765488de56ccSmrg
765588de56ccSmrg      for deplib in $libs; do
765688de56ccSmrg	lib=
7657862bcd1aSmrg	found=false
765888de56ccSmrg	case $deplib in
7659eb411b4bSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7660eb411b4bSmrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7661862bcd1aSmrg	  if test prog,link = "$linkmode,$pass"; then
766288de56ccSmrg	    compile_deplibs="$deplib $compile_deplibs"
766388de56ccSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
766488de56ccSmrg	  else
7665e9fcaa8aSmrg	    func_append compiler_flags " $deplib"
7666862bcd1aSmrg	    if test lib = "$linkmode"; then
766788de56ccSmrg		case "$new_inherited_linker_flags " in
766888de56ccSmrg		    *" $deplib "*) ;;
7669e9fcaa8aSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
767088de56ccSmrg		esac
767188de56ccSmrg	    fi
767288de56ccSmrg	  fi
767388de56ccSmrg	  continue
767488de56ccSmrg	  ;;
767588de56ccSmrg	-l*)
7676862bcd1aSmrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
7677862bcd1aSmrg	    func_warning "'-l' is ignored for archives/objects"
767888de56ccSmrg	    continue
767988de56ccSmrg	  fi
768088de56ccSmrg	  func_stripname '-l' '' "$deplib"
768188de56ccSmrg	  name=$func_stripname_result
7682862bcd1aSmrg	  if test lib = "$linkmode"; then
768388de56ccSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
768488de56ccSmrg	  else
768588de56ccSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
768688de56ccSmrg	  fi
768788de56ccSmrg	  for searchdir in $searchdirs; do
768888de56ccSmrg	    for search_ext in .la $std_shrext .so .a; do
768988de56ccSmrg	      # Search the libtool library
7690862bcd1aSmrg	      lib=$searchdir/lib$name$search_ext
769188de56ccSmrg	      if test -f "$lib"; then
7692862bcd1aSmrg		if test .la = "$search_ext"; then
7693862bcd1aSmrg		  found=:
769488de56ccSmrg		else
7695862bcd1aSmrg		  found=false
769688de56ccSmrg		fi
769788de56ccSmrg		break 2
769888de56ccSmrg	      fi
769988de56ccSmrg	    done
770088de56ccSmrg	  done
7701862bcd1aSmrg	  if $found; then
7702862bcd1aSmrg	    # deplib is a libtool library
770388de56ccSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
770488de56ccSmrg	    # We need to do some special things here, and not later.
7705862bcd1aSmrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
770688de56ccSmrg	      case " $predeps $postdeps " in
770788de56ccSmrg	      *" $deplib "*)
770888de56ccSmrg		if func_lalib_p "$lib"; then
770988de56ccSmrg		  library_names=
771088de56ccSmrg		  old_library=
771188de56ccSmrg		  func_source "$lib"
771288de56ccSmrg		  for l in $old_library $library_names; do
7713862bcd1aSmrg		    ll=$l
771488de56ccSmrg		  done
7715862bcd1aSmrg		  if test "X$ll" = "X$old_library"; then # only static version available
7716862bcd1aSmrg		    found=false
771788de56ccSmrg		    func_dirname "$lib" "" "."
7718862bcd1aSmrg		    ladir=$func_dirname_result
771988de56ccSmrg		    lib=$ladir/$old_library
7720862bcd1aSmrg		    if test prog,link = "$linkmode,$pass"; then
772188de56ccSmrg		      compile_deplibs="$deplib $compile_deplibs"
772288de56ccSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
772388de56ccSmrg		    else
772488de56ccSmrg		      deplibs="$deplib $deplibs"
7725862bcd1aSmrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
772688de56ccSmrg		    fi
772788de56ccSmrg		    continue
772888de56ccSmrg		  fi
772988de56ccSmrg		fi
773088de56ccSmrg		;;
773188de56ccSmrg	      *) ;;
773288de56ccSmrg	      esac
773388de56ccSmrg	    fi
7734862bcd1aSmrg	  else
7735862bcd1aSmrg	    # deplib doesn't seem to be a libtool library
7736862bcd1aSmrg	    if test prog,link = "$linkmode,$pass"; then
7737862bcd1aSmrg	      compile_deplibs="$deplib $compile_deplibs"
7738862bcd1aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
7739862bcd1aSmrg	    else
7740862bcd1aSmrg	      deplibs="$deplib $deplibs"
7741862bcd1aSmrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7742862bcd1aSmrg	    fi
7743862bcd1aSmrg	    continue
774488de56ccSmrg	  fi
774588de56ccSmrg	  ;; # -l
774688de56ccSmrg	*.ltframework)
7747862bcd1aSmrg	  if test prog,link = "$linkmode,$pass"; then
774888de56ccSmrg	    compile_deplibs="$deplib $compile_deplibs"
774988de56ccSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
775088de56ccSmrg	  else
775188de56ccSmrg	    deplibs="$deplib $deplibs"
7752862bcd1aSmrg	    if test lib = "$linkmode"; then
775388de56ccSmrg		case "$new_inherited_linker_flags " in
775488de56ccSmrg		    *" $deplib "*) ;;
7755e9fcaa8aSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
775688de56ccSmrg		esac
775788de56ccSmrg	    fi
775888de56ccSmrg	  fi
775988de56ccSmrg	  continue
776088de56ccSmrg	  ;;
776188de56ccSmrg	-L*)
776288de56ccSmrg	  case $linkmode in
776388de56ccSmrg	  lib)
776488de56ccSmrg	    deplibs="$deplib $deplibs"
7765862bcd1aSmrg	    test conv = "$pass" && continue
776688de56ccSmrg	    newdependency_libs="$deplib $newdependency_libs"
776788de56ccSmrg	    func_stripname '-L' '' "$deplib"
7768e9fcaa8aSmrg	    func_resolve_sysroot "$func_stripname_result"
7769e9fcaa8aSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
777088de56ccSmrg	    ;;
777188de56ccSmrg	  prog)
7772862bcd1aSmrg	    if test conv = "$pass"; then
777388de56ccSmrg	      deplibs="$deplib $deplibs"
777488de56ccSmrg	      continue
777588de56ccSmrg	    fi
7776862bcd1aSmrg	    if test scan = "$pass"; then
777788de56ccSmrg	      deplibs="$deplib $deplibs"
777888de56ccSmrg	    else
777988de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
778088de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
778188de56ccSmrg	    fi
778288de56ccSmrg	    func_stripname '-L' '' "$deplib"
7783e9fcaa8aSmrg	    func_resolve_sysroot "$func_stripname_result"
7784e9fcaa8aSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
778588de56ccSmrg	    ;;
778688de56ccSmrg	  *)
7787862bcd1aSmrg	    func_warning "'-L' is ignored for archives/objects"
778888de56ccSmrg	    ;;
778988de56ccSmrg	  esac # linkmode
779088de56ccSmrg	  continue
779188de56ccSmrg	  ;; # -L
779288de56ccSmrg	-R*)
7793862bcd1aSmrg	  if test link = "$pass"; then
779488de56ccSmrg	    func_stripname '-R' '' "$deplib"
7795e9fcaa8aSmrg	    func_resolve_sysroot "$func_stripname_result"
7796e9fcaa8aSmrg	    dir=$func_resolve_sysroot_result
779788de56ccSmrg	    # Make sure the xrpath contains only unique directories.
779888de56ccSmrg	    case "$xrpath " in
779988de56ccSmrg	    *" $dir "*) ;;
7800e9fcaa8aSmrg	    *) func_append xrpath " $dir" ;;
780188de56ccSmrg	    esac
780288de56ccSmrg	  fi
780388de56ccSmrg	  deplibs="$deplib $deplibs"
780488de56ccSmrg	  continue
780588de56ccSmrg	  ;;
7806e9fcaa8aSmrg	*.la)
7807e9fcaa8aSmrg	  func_resolve_sysroot "$deplib"
7808e9fcaa8aSmrg	  lib=$func_resolve_sysroot_result
7809e9fcaa8aSmrg	  ;;
781088de56ccSmrg	*.$libext)
7811862bcd1aSmrg	  if test conv = "$pass"; then
781288de56ccSmrg	    deplibs="$deplib $deplibs"
781388de56ccSmrg	    continue
781488de56ccSmrg	  fi
781588de56ccSmrg	  case $linkmode in
781688de56ccSmrg	  lib)
781788de56ccSmrg	    # Linking convenience modules into shared libraries is allowed,
781888de56ccSmrg	    # but linking other static libraries is non-portable.
781988de56ccSmrg	    case " $dlpreconveniencelibs " in
782088de56ccSmrg	    *" $deplib "*) ;;
782188de56ccSmrg	    *)
7822862bcd1aSmrg	      valid_a_lib=false
782388de56ccSmrg	      case $deplibs_check_method in
782488de56ccSmrg		match_pattern*)
782588de56ccSmrg		  set dummy $deplibs_check_method; shift
782688de56ccSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7827e9fcaa8aSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
782888de56ccSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
7829862bcd1aSmrg		    valid_a_lib=:
783088de56ccSmrg		  fi
783188de56ccSmrg		;;
783288de56ccSmrg		pass_all)
7833862bcd1aSmrg		  valid_a_lib=:
783488de56ccSmrg		;;
783588de56ccSmrg	      esac
7836862bcd1aSmrg	      if $valid_a_lib; then
7837862bcd1aSmrg		echo
7838862bcd1aSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
7839862bcd1aSmrg		$ECHO "*** static library $deplib is not portable!"
7840862bcd1aSmrg		deplibs="$deplib $deplibs"
7841862bcd1aSmrg	      else
7842e9fcaa8aSmrg		echo
784388de56ccSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
7844e9fcaa8aSmrg		echo "*** I have the capability to make that library automatically link in when"
7845e9fcaa8aSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7846e9fcaa8aSmrg		echo "*** shared version of the library, which you do not appear to have"
7847e9fcaa8aSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
7848e9fcaa8aSmrg		echo "*** that it is just a static archive that I should not use here."
784988de56ccSmrg	      fi
785088de56ccSmrg	      ;;
785188de56ccSmrg	    esac
785288de56ccSmrg	    continue
785388de56ccSmrg	    ;;
785488de56ccSmrg	  prog)
7855862bcd1aSmrg	    if test link != "$pass"; then
785688de56ccSmrg	      deplibs="$deplib $deplibs"
785788de56ccSmrg	    else
785888de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
785988de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
786088de56ccSmrg	    fi
786188de56ccSmrg	    continue
786288de56ccSmrg	    ;;
786388de56ccSmrg	  esac # linkmode
786488de56ccSmrg	  ;; # *.$libext
786588de56ccSmrg	*.lo | *.$objext)
7866862bcd1aSmrg	  if test conv = "$pass"; then
786788de56ccSmrg	    deplibs="$deplib $deplibs"
7868862bcd1aSmrg	  elif test prog = "$linkmode"; then
7869862bcd1aSmrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
787088de56ccSmrg	      # If there is no dlopen support or we're linking statically,
787188de56ccSmrg	      # we need to preload.
7872e9fcaa8aSmrg	      func_append newdlprefiles " $deplib"
787388de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
787488de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
787588de56ccSmrg	    else
7876e9fcaa8aSmrg	      func_append newdlfiles " $deplib"
787788de56ccSmrg	    fi
787888de56ccSmrg	  fi
787988de56ccSmrg	  continue
788088de56ccSmrg	  ;;
788188de56ccSmrg	%DEPLIBS%)
7882862bcd1aSmrg	  alldeplibs=:
788388de56ccSmrg	  continue
788488de56ccSmrg	  ;;
788588de56ccSmrg	esac # case $deplib
788688de56ccSmrg
7887862bcd1aSmrg	$found || test -f "$lib" \
7888862bcd1aSmrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
788988de56ccSmrg
789088de56ccSmrg	# Check to see that this really is a libtool archive.
789188de56ccSmrg	func_lalib_unsafe_p "$lib" \
7892862bcd1aSmrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
789388de56ccSmrg
789488de56ccSmrg	func_dirname "$lib" "" "."
7895862bcd1aSmrg	ladir=$func_dirname_result
789688de56ccSmrg
789788de56ccSmrg	dlname=
789888de56ccSmrg	dlopen=
789988de56ccSmrg	dlpreopen=
790088de56ccSmrg	libdir=
790188de56ccSmrg	library_names=
790288de56ccSmrg	old_library=
790388de56ccSmrg	inherited_linker_flags=
790488de56ccSmrg	# If the library was installed with an old release of libtool,
790588de56ccSmrg	# it will not redefine variables installed, or shouldnotlink
790688de56ccSmrg	installed=yes
790788de56ccSmrg	shouldnotlink=no
790888de56ccSmrg	avoidtemprpath=
790988de56ccSmrg
791088de56ccSmrg
791188de56ccSmrg	# Read the .la file
791288de56ccSmrg	func_source "$lib"
791388de56ccSmrg
791488de56ccSmrg	# Convert "-framework foo" to "foo.ltframework"
791588de56ccSmrg	if test -n "$inherited_linker_flags"; then
7916e9fcaa8aSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
791788de56ccSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
791888de56ccSmrg	    case " $new_inherited_linker_flags " in
791988de56ccSmrg	      *" $tmp_inherited_linker_flag "*) ;;
7920e9fcaa8aSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
792188de56ccSmrg	    esac
792288de56ccSmrg	  done
792388de56ccSmrg	fi
7924e9fcaa8aSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7925862bcd1aSmrg	if test lib,link = "$linkmode,$pass" ||
7926862bcd1aSmrg	   test prog,scan = "$linkmode,$pass" ||
7927862bcd1aSmrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7928e9fcaa8aSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
7929e9fcaa8aSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
793088de56ccSmrg	fi
793188de56ccSmrg
7932862bcd1aSmrg	if test conv = "$pass"; then
793388de56ccSmrg	  # Only check for convenience libraries
793488de56ccSmrg	  deplibs="$lib $deplibs"
793588de56ccSmrg	  if test -z "$libdir"; then
793688de56ccSmrg	    if test -z "$old_library"; then
7937862bcd1aSmrg	      func_fatal_error "cannot find name of link library for '$lib'"
793888de56ccSmrg	    fi
793988de56ccSmrg	    # It is a libtool convenience library, so add in its objects.
7940e9fcaa8aSmrg	    func_append convenience " $ladir/$objdir/$old_library"
7941e9fcaa8aSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
7942862bcd1aSmrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
7943862bcd1aSmrg	    func_fatal_error "'$lib' is not a convenience library"
794488de56ccSmrg	  fi
794538ae11fcSmrg	  tmp_libs=
794638ae11fcSmrg	  for deplib in $dependency_libs; do
794738ae11fcSmrg	    deplibs="$deplib $deplibs"
794838ae11fcSmrg	    if $opt_preserve_dup_deps; then
794938ae11fcSmrg	      case "$tmp_libs " in
795038ae11fcSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
795138ae11fcSmrg	      esac
795238ae11fcSmrg	    fi
795338ae11fcSmrg	    func_append tmp_libs " $deplib"
795438ae11fcSmrg	  done
795588de56ccSmrg	  continue
795688de56ccSmrg	fi # $pass = conv
795788de56ccSmrg
795888de56ccSmrg
795988de56ccSmrg	# Get the name of the library we link against.
796088de56ccSmrg	linklib=
7961e9fcaa8aSmrg	if test -n "$old_library" &&
7962862bcd1aSmrg	   { test yes = "$prefer_static_libs" ||
7963862bcd1aSmrg	     test built,no = "$prefer_static_libs,$installed"; }; then
7964e9fcaa8aSmrg	  linklib=$old_library
7965e9fcaa8aSmrg	else
7966e9fcaa8aSmrg	  for l in $old_library $library_names; do
7967862bcd1aSmrg	    linklib=$l
7968e9fcaa8aSmrg	  done
7969e9fcaa8aSmrg	fi
797088de56ccSmrg	if test -z "$linklib"; then
7971862bcd1aSmrg	  func_fatal_error "cannot find name of link library for '$lib'"
797288de56ccSmrg	fi
797388de56ccSmrg
797488de56ccSmrg	# This library was specified with -dlopen.
7975862bcd1aSmrg	if test dlopen = "$pass"; then
7976862bcd1aSmrg	  test -z "$libdir" \
7977862bcd1aSmrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
797888de56ccSmrg	  if test -z "$dlname" ||
7979862bcd1aSmrg	     test yes != "$dlopen_support" ||
7980862bcd1aSmrg	     test no = "$build_libtool_libs"
7981862bcd1aSmrg	  then
798288de56ccSmrg	    # If there is no dlname, no dlopen support or we're linking
798388de56ccSmrg	    # statically, we need to preload.  We also need to preload any
798488de56ccSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
798588de56ccSmrg	    # bomb out in the load deplibs phase.
7986e9fcaa8aSmrg	    func_append dlprefiles " $lib $dependency_libs"
798788de56ccSmrg	  else
7988e9fcaa8aSmrg	    func_append newdlfiles " $lib"
798988de56ccSmrg	  fi
799088de56ccSmrg	  continue
799188de56ccSmrg	fi # $pass = dlopen
799288de56ccSmrg
799388de56ccSmrg	# We need an absolute path.
799488de56ccSmrg	case $ladir in
7995862bcd1aSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
799688de56ccSmrg	*)
799788de56ccSmrg	  abs_ladir=`cd "$ladir" && pwd`
799888de56ccSmrg	  if test -z "$abs_ladir"; then
7999862bcd1aSmrg	    func_warning "cannot determine absolute directory name of '$ladir'"
800088de56ccSmrg	    func_warning "passing it literally to the linker, although it might fail"
8001862bcd1aSmrg	    abs_ladir=$ladir
800288de56ccSmrg	  fi
800388de56ccSmrg	  ;;
800488de56ccSmrg	esac
800588de56ccSmrg	func_basename "$lib"
8006862bcd1aSmrg	laname=$func_basename_result
800788de56ccSmrg
800888de56ccSmrg	# Find the relevant object directory and library name.
8009862bcd1aSmrg	if test yes = "$installed"; then
8010e9fcaa8aSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
8011862bcd1aSmrg	    func_warning "library '$lib' was moved."
8012862bcd1aSmrg	    dir=$ladir
8013862bcd1aSmrg	    absdir=$abs_ladir
8014862bcd1aSmrg	    libdir=$abs_ladir
801588de56ccSmrg	  else
8016862bcd1aSmrg	    dir=$lt_sysroot$libdir
8017862bcd1aSmrg	    absdir=$lt_sysroot$libdir
801888de56ccSmrg	  fi
8019862bcd1aSmrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
802088de56ccSmrg	else
802188de56ccSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
8022862bcd1aSmrg	    dir=$ladir
8023862bcd1aSmrg	    absdir=$abs_ladir
802488de56ccSmrg	    # Remove this search path later
8025e9fcaa8aSmrg	    func_append notinst_path " $abs_ladir"
802688de56ccSmrg	  else
8027862bcd1aSmrg	    dir=$ladir/$objdir
8028862bcd1aSmrg	    absdir=$abs_ladir/$objdir
802988de56ccSmrg	    # Remove this search path later
8030e9fcaa8aSmrg	    func_append notinst_path " $abs_ladir"
803188de56ccSmrg	  fi
803288de56ccSmrg	fi # $installed = yes
803388de56ccSmrg	func_stripname 'lib' '.la' "$laname"
803488de56ccSmrg	name=$func_stripname_result
803588de56ccSmrg
803688de56ccSmrg	# This library was specified with -dlpreopen.
8037862bcd1aSmrg	if test dlpreopen = "$pass"; then
8038862bcd1aSmrg	  if test -z "$libdir" && test prog = "$linkmode"; then
8039862bcd1aSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
804088de56ccSmrg	  fi
8041862bcd1aSmrg	  case $host in
8042e9fcaa8aSmrg	    # special handling for platforms with PE-DLLs.
8043e9fcaa8aSmrg	    *cygwin* | *mingw* | *cegcc* )
8044e9fcaa8aSmrg	      # Linker will automatically link against shared library if both
8045e9fcaa8aSmrg	      # static and shared are present.  Therefore, ensure we extract
8046e9fcaa8aSmrg	      # symbols from the import library if a shared library is present
8047e9fcaa8aSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
8048e9fcaa8aSmrg	      # this by putting the import library name into $newdlprefiles.
8049e9fcaa8aSmrg	      # We recover the dlopen module name by 'saving' the la file
8050e9fcaa8aSmrg	      # name in a special purpose variable, and (later) extracting the
8051e9fcaa8aSmrg	      # dlname from the la file.
8052e9fcaa8aSmrg	      if test -n "$dlname"; then
8053e9fcaa8aSmrg	        func_tr_sh "$dir/$linklib"
8054e9fcaa8aSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8055e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$linklib"
8056e9fcaa8aSmrg	      else
8057e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$old_library"
8058e9fcaa8aSmrg	        # Keep a list of preopened convenience libraries to check
8059e9fcaa8aSmrg	        # that they are being used correctly in the link pass.
8060e9fcaa8aSmrg	        test -z "$libdir" && \
8061e9fcaa8aSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8062e9fcaa8aSmrg	      fi
8063e9fcaa8aSmrg	    ;;
8064e9fcaa8aSmrg	    * )
8065e9fcaa8aSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
8066e9fcaa8aSmrg	      # are required to link).
8067e9fcaa8aSmrg	      if test -n "$old_library"; then
8068e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$old_library"
8069e9fcaa8aSmrg	        # Keep a list of preopened convenience libraries to check
8070e9fcaa8aSmrg	        # that they are being used correctly in the link pass.
8071e9fcaa8aSmrg	        test -z "$libdir" && \
8072e9fcaa8aSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8073e9fcaa8aSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
8074e9fcaa8aSmrg	      elif test -n "$dlname"; then
8075e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$dlname"
8076e9fcaa8aSmrg	      else
8077e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$linklib"
8078e9fcaa8aSmrg	      fi
8079e9fcaa8aSmrg	    ;;
8080e9fcaa8aSmrg	  esac
808188de56ccSmrg	fi # $pass = dlpreopen
808288de56ccSmrg
808388de56ccSmrg	if test -z "$libdir"; then
808488de56ccSmrg	  # Link the convenience library
8085862bcd1aSmrg	  if test lib = "$linkmode"; then
808688de56ccSmrg	    deplibs="$dir/$old_library $deplibs"
8087862bcd1aSmrg	  elif test prog,link = "$linkmode,$pass"; then
808888de56ccSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
808988de56ccSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
809088de56ccSmrg	  else
809188de56ccSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
809288de56ccSmrg	  fi
809388de56ccSmrg	  continue
809488de56ccSmrg	fi
809588de56ccSmrg
809688de56ccSmrg
8097862bcd1aSmrg	if test prog = "$linkmode" && test link != "$pass"; then
8098e9fcaa8aSmrg	  func_append newlib_search_path " $ladir"
809988de56ccSmrg	  deplibs="$lib $deplibs"
810088de56ccSmrg
8101862bcd1aSmrg	  linkalldeplibs=false
8102862bcd1aSmrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
8103862bcd1aSmrg	     test no = "$build_libtool_libs"; then
8104862bcd1aSmrg	    linkalldeplibs=:
810588de56ccSmrg	  fi
810688de56ccSmrg
810788de56ccSmrg	  tmp_libs=
810888de56ccSmrg	  for deplib in $dependency_libs; do
810988de56ccSmrg	    case $deplib in
811088de56ccSmrg	    -L*) func_stripname '-L' '' "$deplib"
8111e9fcaa8aSmrg	         func_resolve_sysroot "$func_stripname_result"
8112e9fcaa8aSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
811388de56ccSmrg		 ;;
811488de56ccSmrg	    esac
811588de56ccSmrg	    # Need to link against all dependency_libs?
8116862bcd1aSmrg	    if $linkalldeplibs; then
811788de56ccSmrg	      deplibs="$deplib $deplibs"
811888de56ccSmrg	    else
811988de56ccSmrg	      # Need to hardcode shared library paths
812088de56ccSmrg	      # or/and link against static libraries
812188de56ccSmrg	      newdependency_libs="$deplib $newdependency_libs"
812288de56ccSmrg	    fi
8123862bcd1aSmrg	    if $opt_preserve_dup_deps; then
812488de56ccSmrg	      case "$tmp_libs " in
8125e9fcaa8aSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
812688de56ccSmrg	      esac
812788de56ccSmrg	    fi
8128e9fcaa8aSmrg	    func_append tmp_libs " $deplib"
812988de56ccSmrg	  done # for deplib
813088de56ccSmrg	  continue
813188de56ccSmrg	fi # $linkmode = prog...
813288de56ccSmrg
8133862bcd1aSmrg	if test prog,link = "$linkmode,$pass"; then
813488de56ccSmrg	  if test -n "$library_names" &&
8135862bcd1aSmrg	     { { test no = "$prefer_static_libs" ||
8136862bcd1aSmrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
813788de56ccSmrg	       test -z "$old_library"; }; then
813888de56ccSmrg	    # We need to hardcode the library path
8139862bcd1aSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
814088de56ccSmrg	      # Make sure the rpath contains only unique directories.
8141862bcd1aSmrg	      case $temp_rpath: in
814288de56ccSmrg	      *"$absdir:"*) ;;
8143e9fcaa8aSmrg	      *) func_append temp_rpath "$absdir:" ;;
814488de56ccSmrg	      esac
814588de56ccSmrg	    fi
814688de56ccSmrg
814788de56ccSmrg	    # Hardcode the library path.
814888de56ccSmrg	    # Skip directories that are in the system default run-time
814988de56ccSmrg	    # search path.
815088de56ccSmrg	    case " $sys_lib_dlsearch_path " in
815188de56ccSmrg	    *" $absdir "*) ;;
815288de56ccSmrg	    *)
815388de56ccSmrg	      case "$compile_rpath " in
815488de56ccSmrg	      *" $absdir "*) ;;
8155e9fcaa8aSmrg	      *) func_append compile_rpath " $absdir" ;;
815688de56ccSmrg	      esac
815788de56ccSmrg	      ;;
815888de56ccSmrg	    esac
815988de56ccSmrg	    case " $sys_lib_dlsearch_path " in
816088de56ccSmrg	    *" $libdir "*) ;;
816188de56ccSmrg	    *)
816288de56ccSmrg	      case "$finalize_rpath " in
816388de56ccSmrg	      *" $libdir "*) ;;
8164e9fcaa8aSmrg	      *) func_append finalize_rpath " $libdir" ;;
816588de56ccSmrg	      esac
816688de56ccSmrg	      ;;
816788de56ccSmrg	    esac
816888de56ccSmrg	  fi # $linkmode,$pass = prog,link...
816988de56ccSmrg
8170862bcd1aSmrg	  if $alldeplibs &&
8171862bcd1aSmrg	     { test pass_all = "$deplibs_check_method" ||
8172862bcd1aSmrg	       { test yes = "$build_libtool_libs" &&
817388de56ccSmrg		 test -n "$library_names"; }; }; then
817488de56ccSmrg	    # We only need to search for static libraries
817588de56ccSmrg	    continue
817688de56ccSmrg	  fi
817788de56ccSmrg	fi
817888de56ccSmrg
817988de56ccSmrg	link_static=no # Whether the deplib will be linked statically
818088de56ccSmrg	use_static_libs=$prefer_static_libs
8181862bcd1aSmrg	if test built = "$use_static_libs" && test yes = "$installed"; then
818288de56ccSmrg	  use_static_libs=no
818388de56ccSmrg	fi
818488de56ccSmrg	if test -n "$library_names" &&
8185862bcd1aSmrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
818688de56ccSmrg	  case $host in
8187862bcd1aSmrg	  *cygwin* | *mingw* | *cegcc* | *os2*)
818888de56ccSmrg	      # No point in relinking DLLs because paths are not encoded
8189e9fcaa8aSmrg	      func_append notinst_deplibs " $lib"
819088de56ccSmrg	      need_relink=no
819188de56ccSmrg	    ;;
819288de56ccSmrg	  *)
8193862bcd1aSmrg	    if test no = "$installed"; then
8194e9fcaa8aSmrg	      func_append notinst_deplibs " $lib"
819588de56ccSmrg	      need_relink=yes
819688de56ccSmrg	    fi
819788de56ccSmrg	    ;;
819888de56ccSmrg	  esac
819988de56ccSmrg	  # This is a shared library
820088de56ccSmrg
820188de56ccSmrg	  # Warn about portability, can't link against -module's on some
820288de56ccSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
8203862bcd1aSmrg	  dlopenmodule=
820488de56ccSmrg	  for dlpremoduletest in $dlprefiles; do
820588de56ccSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
8206862bcd1aSmrg	      dlopenmodule=$dlpremoduletest
820788de56ccSmrg	      break
820888de56ccSmrg	    fi
820988de56ccSmrg	  done
8210862bcd1aSmrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8211e9fcaa8aSmrg	    echo
8212862bcd1aSmrg	    if test prog = "$linkmode"; then
821388de56ccSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
821488de56ccSmrg	    else
821588de56ccSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
821688de56ccSmrg	    fi
821788de56ccSmrg	    $ECHO "*** $linklib is not portable!"
821888de56ccSmrg	  fi
8219862bcd1aSmrg	  if test lib = "$linkmode" &&
8220862bcd1aSmrg	     test yes = "$hardcode_into_libs"; then
822188de56ccSmrg	    # Hardcode the library path.
822288de56ccSmrg	    # Skip directories that are in the system default run-time
822388de56ccSmrg	    # search path.
822488de56ccSmrg	    case " $sys_lib_dlsearch_path " in
822588de56ccSmrg	    *" $absdir "*) ;;
822688de56ccSmrg	    *)
822788de56ccSmrg	      case "$compile_rpath " in
822888de56ccSmrg	      *" $absdir "*) ;;
8229e9fcaa8aSmrg	      *) func_append compile_rpath " $absdir" ;;
823088de56ccSmrg	      esac
823188de56ccSmrg	      ;;
823288de56ccSmrg	    esac
823388de56ccSmrg	    case " $sys_lib_dlsearch_path " in
823488de56ccSmrg	    *" $libdir "*) ;;
823588de56ccSmrg	    *)
823688de56ccSmrg	      case "$finalize_rpath " in
823788de56ccSmrg	      *" $libdir "*) ;;
8238e9fcaa8aSmrg	      *) func_append finalize_rpath " $libdir" ;;
823988de56ccSmrg	      esac
824088de56ccSmrg	      ;;
824188de56ccSmrg	    esac
824288de56ccSmrg	  fi
824388de56ccSmrg
824488de56ccSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
824588de56ccSmrg	    # figure out the soname
824688de56ccSmrg	    set dummy $library_names
824788de56ccSmrg	    shift
8248862bcd1aSmrg	    realname=$1
824988de56ccSmrg	    shift
825088de56ccSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
825188de56ccSmrg	    # use dlname if we got it. it's perfectly good, no?
825288de56ccSmrg	    if test -n "$dlname"; then
8253862bcd1aSmrg	      soname=$dlname
825488de56ccSmrg	    elif test -n "$soname_spec"; then
825588de56ccSmrg	      # bleh windows
825688de56ccSmrg	      case $host in
8257862bcd1aSmrg	      *cygwin* | mingw* | *cegcc* | *os2*)
825888de56ccSmrg	        func_arith $current - $age
825988de56ccSmrg		major=$func_arith_result
8260862bcd1aSmrg		versuffix=-$major
826188de56ccSmrg		;;
826288de56ccSmrg	      esac
826388de56ccSmrg	      eval soname=\"$soname_spec\"
826488de56ccSmrg	    else
8265862bcd1aSmrg	      soname=$realname
826688de56ccSmrg	    fi
826788de56ccSmrg
826888de56ccSmrg	    # Make a new name for the extract_expsyms_cmds to use
8269862bcd1aSmrg	    soroot=$soname
827088de56ccSmrg	    func_basename "$soroot"
8271862bcd1aSmrg	    soname=$func_basename_result
827288de56ccSmrg	    func_stripname 'lib' '.dll' "$soname"
827388de56ccSmrg	    newlib=libimp-$func_stripname_result.a
827488de56ccSmrg
827588de56ccSmrg	    # If the library has no export list, then create one now
827688de56ccSmrg	    if test -f "$output_objdir/$soname-def"; then :
827788de56ccSmrg	    else
8278862bcd1aSmrg	      func_verbose "extracting exported symbol list from '$soname'"
827988de56ccSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
828088de56ccSmrg	    fi
828188de56ccSmrg
828288de56ccSmrg	    # Create $newlib
828388de56ccSmrg	    if test -f "$output_objdir/$newlib"; then :; else
8284862bcd1aSmrg	      func_verbose "generating import library for '$soname'"
828588de56ccSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
828688de56ccSmrg	    fi
828788de56ccSmrg	    # make sure the library variables are pointing to the new library
828888de56ccSmrg	    dir=$output_objdir
828988de56ccSmrg	    linklib=$newlib
829088de56ccSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
829188de56ccSmrg
8292862bcd1aSmrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
829388de56ccSmrg	    add_shlibpath=
829488de56ccSmrg	    add_dir=
829588de56ccSmrg	    add=
829688de56ccSmrg	    lib_linked=yes
829788de56ccSmrg	    case $hardcode_action in
829888de56ccSmrg	    immediate | unsupported)
8299862bcd1aSmrg	      if test no = "$hardcode_direct"; then
8300862bcd1aSmrg		add=$dir/$linklib
830188de56ccSmrg		case $host in
8302862bcd1aSmrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
8303862bcd1aSmrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
830488de56ccSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
8305862bcd1aSmrg		    *-*-unixware7*) add_dir=-L$dir ;;
830688de56ccSmrg		  *-*-darwin* )
8307862bcd1aSmrg		    # if the lib is a (non-dlopened) module then we cannot
830888de56ccSmrg		    # link against it, someone is ignoring the earlier warnings
830988de56ccSmrg		    if /usr/bin/file -L $add 2> /dev/null |
8310862bcd1aSmrg			 $GREP ": [^:]* bundle" >/dev/null; then
831188de56ccSmrg		      if test "X$dlopenmodule" != "X$lib"; then
831288de56ccSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
8313862bcd1aSmrg			if test -z "$old_library"; then
8314e9fcaa8aSmrg			  echo
8315e9fcaa8aSmrg			  echo "*** And there doesn't seem to be a static archive available"
8316e9fcaa8aSmrg			  echo "*** The link will probably fail, sorry"
831788de56ccSmrg			else
8318862bcd1aSmrg			  add=$dir/$old_library
831988de56ccSmrg			fi
832088de56ccSmrg		      elif test -n "$old_library"; then
8321862bcd1aSmrg			add=$dir/$old_library
832288de56ccSmrg		      fi
832388de56ccSmrg		    fi
832488de56ccSmrg		esac
8325862bcd1aSmrg	      elif test no = "$hardcode_minus_L"; then
832688de56ccSmrg		case $host in
8327862bcd1aSmrg		*-*-sunos*) add_shlibpath=$dir ;;
832888de56ccSmrg		esac
8329862bcd1aSmrg		add_dir=-L$dir
8330862bcd1aSmrg		add=-l$name
8331862bcd1aSmrg	      elif test no = "$hardcode_shlibpath_var"; then
8332862bcd1aSmrg		add_shlibpath=$dir
8333862bcd1aSmrg		add=-l$name
833488de56ccSmrg	      else
833588de56ccSmrg		lib_linked=no
833688de56ccSmrg	      fi
833788de56ccSmrg	      ;;
833888de56ccSmrg	    relink)
8339862bcd1aSmrg	      if test yes = "$hardcode_direct" &&
8340862bcd1aSmrg	         test no = "$hardcode_direct_absolute"; then
8341862bcd1aSmrg		add=$dir/$linklib
8342862bcd1aSmrg	      elif test yes = "$hardcode_minus_L"; then
8343862bcd1aSmrg		add_dir=-L$absdir
834488de56ccSmrg		# Try looking first in the location we're being installed to.
834588de56ccSmrg		if test -n "$inst_prefix_dir"; then
834688de56ccSmrg		  case $libdir in
834788de56ccSmrg		    [\\/]*)
8348e9fcaa8aSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
834988de56ccSmrg		      ;;
835088de56ccSmrg		  esac
835188de56ccSmrg		fi
8352862bcd1aSmrg		add=-l$name
8353862bcd1aSmrg	      elif test yes = "$hardcode_shlibpath_var"; then
8354862bcd1aSmrg		add_shlibpath=$dir
8355862bcd1aSmrg		add=-l$name
835688de56ccSmrg	      else
835788de56ccSmrg		lib_linked=no
835888de56ccSmrg	      fi
835988de56ccSmrg	      ;;
836088de56ccSmrg	    *) lib_linked=no ;;
836188de56ccSmrg	    esac
836288de56ccSmrg
8363862bcd1aSmrg	    if test yes != "$lib_linked"; then
836488de56ccSmrg	      func_fatal_configuration "unsupported hardcode properties"
836588de56ccSmrg	    fi
836688de56ccSmrg
836788de56ccSmrg	    if test -n "$add_shlibpath"; then
836888de56ccSmrg	      case :$compile_shlibpath: in
836988de56ccSmrg	      *":$add_shlibpath:"*) ;;
8370e9fcaa8aSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
837188de56ccSmrg	      esac
837288de56ccSmrg	    fi
8373862bcd1aSmrg	    if test prog = "$linkmode"; then
837488de56ccSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
837588de56ccSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
837688de56ccSmrg	    else
837788de56ccSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
837888de56ccSmrg	      test -n "$add" && deplibs="$add $deplibs"
8379862bcd1aSmrg	      if test yes != "$hardcode_direct" &&
8380862bcd1aSmrg		 test yes != "$hardcode_minus_L" &&
8381862bcd1aSmrg		 test yes = "$hardcode_shlibpath_var"; then
838288de56ccSmrg		case :$finalize_shlibpath: in
838388de56ccSmrg		*":$libdir:"*) ;;
8384e9fcaa8aSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
838588de56ccSmrg		esac
838688de56ccSmrg	      fi
838788de56ccSmrg	    fi
838888de56ccSmrg	  fi
838988de56ccSmrg
8390862bcd1aSmrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
839188de56ccSmrg	    add_shlibpath=
839288de56ccSmrg	    add_dir=
839388de56ccSmrg	    add=
839488de56ccSmrg	    # Finalize command for both is simple: just hardcode it.
8395862bcd1aSmrg	    if test yes = "$hardcode_direct" &&
8396862bcd1aSmrg	       test no = "$hardcode_direct_absolute"; then
8397862bcd1aSmrg	      add=$libdir/$linklib
8398862bcd1aSmrg	    elif test yes = "$hardcode_minus_L"; then
8399862bcd1aSmrg	      add_dir=-L$libdir
8400862bcd1aSmrg	      add=-l$name
8401862bcd1aSmrg	    elif test yes = "$hardcode_shlibpath_var"; then
840288de56ccSmrg	      case :$finalize_shlibpath: in
840388de56ccSmrg	      *":$libdir:"*) ;;
8404e9fcaa8aSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
840588de56ccSmrg	      esac
8406862bcd1aSmrg	      add=-l$name
8407862bcd1aSmrg	    elif test yes = "$hardcode_automatic"; then
840888de56ccSmrg	      if test -n "$inst_prefix_dir" &&
8409862bcd1aSmrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
8410862bcd1aSmrg		add=$inst_prefix_dir$libdir/$linklib
841188de56ccSmrg	      else
8412862bcd1aSmrg		add=$libdir/$linklib
841388de56ccSmrg	      fi
841488de56ccSmrg	    else
841588de56ccSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
8416862bcd1aSmrg	      add_dir=-L$libdir
841788de56ccSmrg	      # Try looking first in the location we're being installed to.
841888de56ccSmrg	      if test -n "$inst_prefix_dir"; then
841988de56ccSmrg		case $libdir in
842088de56ccSmrg		  [\\/]*)
8421e9fcaa8aSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
842288de56ccSmrg		    ;;
842388de56ccSmrg		esac
842488de56ccSmrg	      fi
8425862bcd1aSmrg	      add=-l$name
842688de56ccSmrg	    fi
842788de56ccSmrg
8428862bcd1aSmrg	    if test prog = "$linkmode"; then
842988de56ccSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
843088de56ccSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
843188de56ccSmrg	    else
843288de56ccSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
843388de56ccSmrg	      test -n "$add" && deplibs="$add $deplibs"
843488de56ccSmrg	    fi
843588de56ccSmrg	  fi
8436862bcd1aSmrg	elif test prog = "$linkmode"; then
843788de56ccSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
843888de56ccSmrg	  # is not unsupported.  This is valid on all known static and
843988de56ccSmrg	  # shared platforms.
8440862bcd1aSmrg	  if test unsupported != "$hardcode_direct"; then
8441862bcd1aSmrg	    test -n "$old_library" && linklib=$old_library
844288de56ccSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
844388de56ccSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
844488de56ccSmrg	  else
844588de56ccSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
844688de56ccSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
844788de56ccSmrg	  fi
8448862bcd1aSmrg	elif test yes = "$build_libtool_libs"; then
844988de56ccSmrg	  # Not a shared library
8450862bcd1aSmrg	  if test pass_all != "$deplibs_check_method"; then
845188de56ccSmrg	    # We're trying link a shared library against a static one
845288de56ccSmrg	    # but the system doesn't support it.
845388de56ccSmrg
845488de56ccSmrg	    # Just print a warning and add the library to dependency_libs so
845588de56ccSmrg	    # that the program can be linked against the static library.
8456e9fcaa8aSmrg	    echo
8457862bcd1aSmrg	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8458e9fcaa8aSmrg	    echo "*** I have the capability to make that library automatically link in when"
8459e9fcaa8aSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
8460e9fcaa8aSmrg	    echo "*** shared version of the library, which you do not appear to have."
8461862bcd1aSmrg	    if test yes = "$module"; then
8462e9fcaa8aSmrg	      echo "*** But as you try to build a module library, libtool will still create "
8463e9fcaa8aSmrg	      echo "*** a static module, that should work as long as the dlopening application"
8464e9fcaa8aSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
846588de56ccSmrg	      if test -z "$global_symbol_pipe"; then
8466e9fcaa8aSmrg		echo
8467e9fcaa8aSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
8468862bcd1aSmrg		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8469e9fcaa8aSmrg		echo "*** not find such a program.  So, this module is probably useless."
8470862bcd1aSmrg		echo "*** 'nm' from GNU binutils and a full rebuild may help."
847188de56ccSmrg	      fi
8472862bcd1aSmrg	      if test no = "$build_old_libs"; then
847388de56ccSmrg		build_libtool_libs=module
847488de56ccSmrg		build_old_libs=yes
847588de56ccSmrg	      else
847688de56ccSmrg		build_libtool_libs=no
847788de56ccSmrg	      fi
847888de56ccSmrg	    fi
847988de56ccSmrg	  else
848088de56ccSmrg	    deplibs="$dir/$old_library $deplibs"
848188de56ccSmrg	    link_static=yes
848288de56ccSmrg	  fi
848388de56ccSmrg	fi # link shared/static library?
848488de56ccSmrg
8485862bcd1aSmrg	if test lib = "$linkmode"; then
848688de56ccSmrg	  if test -n "$dependency_libs" &&
8487862bcd1aSmrg	     { test yes != "$hardcode_into_libs" ||
8488862bcd1aSmrg	       test yes = "$build_old_libs" ||
8489862bcd1aSmrg	       test yes = "$link_static"; }; then
849088de56ccSmrg	    # Extract -R from dependency_libs
849188de56ccSmrg	    temp_deplibs=
849288de56ccSmrg	    for libdir in $dependency_libs; do
849388de56ccSmrg	      case $libdir in
849488de56ccSmrg	      -R*) func_stripname '-R' '' "$libdir"
849588de56ccSmrg	           temp_xrpath=$func_stripname_result
849688de56ccSmrg		   case " $xrpath " in
849788de56ccSmrg		   *" $temp_xrpath "*) ;;
8498e9fcaa8aSmrg		   *) func_append xrpath " $temp_xrpath";;
849988de56ccSmrg		   esac;;
8500e9fcaa8aSmrg	      *) func_append temp_deplibs " $libdir";;
850188de56ccSmrg	      esac
850288de56ccSmrg	    done
8503862bcd1aSmrg	    dependency_libs=$temp_deplibs
850488de56ccSmrg	  fi
850588de56ccSmrg
8506e9fcaa8aSmrg	  func_append newlib_search_path " $absdir"
850788de56ccSmrg	  # Link against this library
8508862bcd1aSmrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
850988de56ccSmrg	  # ... and its dependency_libs
851088de56ccSmrg	  tmp_libs=
851188de56ccSmrg	  for deplib in $dependency_libs; do
851288de56ccSmrg	    newdependency_libs="$deplib $newdependency_libs"
8513e9fcaa8aSmrg	    case $deplib in
8514e9fcaa8aSmrg              -L*) func_stripname '-L' '' "$deplib"
8515e9fcaa8aSmrg                   func_resolve_sysroot "$func_stripname_result";;
8516e9fcaa8aSmrg              *) func_resolve_sysroot "$deplib" ;;
8517e9fcaa8aSmrg            esac
8518862bcd1aSmrg	    if $opt_preserve_dup_deps; then
851988de56ccSmrg	      case "$tmp_libs " in
8520e9fcaa8aSmrg	      *" $func_resolve_sysroot_result "*)
8521e9fcaa8aSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
852288de56ccSmrg	      esac
852388de56ccSmrg	    fi
8524e9fcaa8aSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
852588de56ccSmrg	  done
852688de56ccSmrg
8527862bcd1aSmrg	  if test no != "$link_all_deplibs"; then
852888de56ccSmrg	    # Add the search paths of all dependency libraries
852988de56ccSmrg	    for deplib in $dependency_libs; do
853047f86ac1Smrg	      path=
853188de56ccSmrg	      case $deplib in
8532862bcd1aSmrg	      -L*) path=$deplib ;;
853388de56ccSmrg	      *.la)
8534e9fcaa8aSmrg	        func_resolve_sysroot "$deplib"
8535e9fcaa8aSmrg	        deplib=$func_resolve_sysroot_result
853688de56ccSmrg	        func_dirname "$deplib" "" "."
8537e9fcaa8aSmrg		dir=$func_dirname_result
853888de56ccSmrg		# We need an absolute path.
853988de56ccSmrg		case $dir in
8540862bcd1aSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
854188de56ccSmrg		*)
854288de56ccSmrg		  absdir=`cd "$dir" && pwd`
854388de56ccSmrg		  if test -z "$absdir"; then
8544862bcd1aSmrg		    func_warning "cannot determine absolute directory name of '$dir'"
8545862bcd1aSmrg		    absdir=$dir
854688de56ccSmrg		  fi
854788de56ccSmrg		  ;;
854888de56ccSmrg		esac
854988de56ccSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
855088de56ccSmrg		case $host in
855188de56ccSmrg		*-*-darwin*)
855288de56ccSmrg		  depdepl=
8553862bcd1aSmrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
8554862bcd1aSmrg		  if test -n "$deplibrary_names"; then
8555862bcd1aSmrg		    for tmp in $deplibrary_names; do
855688de56ccSmrg		      depdepl=$tmp
855788de56ccSmrg		    done
8558862bcd1aSmrg		    if test -f "$absdir/$objdir/$depdepl"; then
8559862bcd1aSmrg		      depdepl=$absdir/$objdir/$depdepl
8560862bcd1aSmrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
856188de56ccSmrg                      if test -z "$darwin_install_name"; then
8562862bcd1aSmrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
856388de56ccSmrg                      fi
8564862bcd1aSmrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
8565862bcd1aSmrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
856688de56ccSmrg		      path=
856788de56ccSmrg		    fi
856888de56ccSmrg		  fi
856988de56ccSmrg		  ;;
857088de56ccSmrg		*)
8571862bcd1aSmrg		  path=-L$absdir/$objdir
857288de56ccSmrg		  ;;
857388de56ccSmrg		esac
857488de56ccSmrg		else
8575862bcd1aSmrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
857688de56ccSmrg		  test -z "$libdir" && \
8577862bcd1aSmrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
857888de56ccSmrg		  test "$absdir" != "$libdir" && \
8579862bcd1aSmrg		    func_warning "'$deplib' seems to be moved"
858088de56ccSmrg
8581862bcd1aSmrg		  path=-L$absdir
858288de56ccSmrg		fi
858388de56ccSmrg		;;
858488de56ccSmrg	      esac
858588de56ccSmrg	      case " $deplibs " in
858688de56ccSmrg	      *" $path "*) ;;
858788de56ccSmrg	      *) deplibs="$path $deplibs" ;;
858888de56ccSmrg	      esac
858988de56ccSmrg	    done
859088de56ccSmrg	  fi # link_all_deplibs != no
859188de56ccSmrg	fi # linkmode = lib
859288de56ccSmrg      done # for deplib in $libs
8593862bcd1aSmrg      if test link = "$pass"; then
8594862bcd1aSmrg	if test prog = "$linkmode"; then
859588de56ccSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
859688de56ccSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
859788de56ccSmrg	else
8598e9fcaa8aSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
859988de56ccSmrg	fi
860088de56ccSmrg      fi
8601862bcd1aSmrg      dependency_libs=$newdependency_libs
8602862bcd1aSmrg      if test dlpreopen = "$pass"; then
860388de56ccSmrg	# Link the dlpreopened libraries before other libraries
860488de56ccSmrg	for deplib in $save_deplibs; do
860588de56ccSmrg	  deplibs="$deplib $deplibs"
860688de56ccSmrg	done
860788de56ccSmrg      fi
8608862bcd1aSmrg      if test dlopen != "$pass"; then
8609862bcd1aSmrg	test conv = "$pass" || {
861088de56ccSmrg	  # Make sure lib_search_path contains only unique directories.
861188de56ccSmrg	  lib_search_path=
861288de56ccSmrg	  for dir in $newlib_search_path; do
861388de56ccSmrg	    case "$lib_search_path " in
861488de56ccSmrg	    *" $dir "*) ;;
8615e9fcaa8aSmrg	    *) func_append lib_search_path " $dir" ;;
861688de56ccSmrg	    esac
861788de56ccSmrg	  done
861888de56ccSmrg	  newlib_search_path=
8619862bcd1aSmrg	}
862088de56ccSmrg
8621862bcd1aSmrg	if test prog,link = "$linkmode,$pass"; then
862288de56ccSmrg	  vars="compile_deplibs finalize_deplibs"
8623862bcd1aSmrg	else
8624862bcd1aSmrg	  vars=deplibs
862588de56ccSmrg	fi
862688de56ccSmrg	for var in $vars dependency_libs; do
862788de56ccSmrg	  # Add libraries to $var in reverse order
862888de56ccSmrg	  eval tmp_libs=\"\$$var\"
862988de56ccSmrg	  new_libs=
863088de56ccSmrg	  for deplib in $tmp_libs; do
863188de56ccSmrg	    # FIXME: Pedantically, this is the right thing to do, so
863288de56ccSmrg	    #        that some nasty dependency loop isn't accidentally
863388de56ccSmrg	    #        broken:
863488de56ccSmrg	    #new_libs="$deplib $new_libs"
863588de56ccSmrg	    # Pragmatically, this seems to cause very few problems in
863688de56ccSmrg	    # practice:
863788de56ccSmrg	    case $deplib in
863888de56ccSmrg	    -L*) new_libs="$deplib $new_libs" ;;
863988de56ccSmrg	    -R*) ;;
864088de56ccSmrg	    *)
864188de56ccSmrg	      # And here is the reason: when a library appears more
864288de56ccSmrg	      # than once as an explicit dependence of a library, or
864388de56ccSmrg	      # is implicitly linked in more than once by the
864488de56ccSmrg	      # compiler, it is considered special, and multiple
864588de56ccSmrg	      # occurrences thereof are not removed.  Compare this
864688de56ccSmrg	      # with having the same library being listed as a
864788de56ccSmrg	      # dependency of multiple other libraries: in this case,
864888de56ccSmrg	      # we know (pedantically, we assume) the library does not
864988de56ccSmrg	      # need to be listed more than once, so we keep only the
865088de56ccSmrg	      # last copy.  This is not always right, but it is rare
865188de56ccSmrg	      # enough that we require users that really mean to play
865288de56ccSmrg	      # such unportable linking tricks to link the library
865388de56ccSmrg	      # using -Wl,-lname, so that libtool does not consider it
865488de56ccSmrg	      # for duplicate removal.
865588de56ccSmrg	      case " $specialdeplibs " in
865688de56ccSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
865788de56ccSmrg	      *)
865888de56ccSmrg		case " $new_libs " in
865988de56ccSmrg		*" $deplib "*) ;;
866088de56ccSmrg		*) new_libs="$deplib $new_libs" ;;
866188de56ccSmrg		esac
866288de56ccSmrg		;;
866388de56ccSmrg	      esac
866488de56ccSmrg	      ;;
866588de56ccSmrg	    esac
866688de56ccSmrg	  done
866788de56ccSmrg	  tmp_libs=
866888de56ccSmrg	  for deplib in $new_libs; do
866988de56ccSmrg	    case $deplib in
867088de56ccSmrg	    -L*)
867188de56ccSmrg	      case " $tmp_libs " in
867288de56ccSmrg	      *" $deplib "*) ;;
8673e9fcaa8aSmrg	      *) func_append tmp_libs " $deplib" ;;
867488de56ccSmrg	      esac
867588de56ccSmrg	      ;;
8676e9fcaa8aSmrg	    *) func_append tmp_libs " $deplib" ;;
867788de56ccSmrg	    esac
867888de56ccSmrg	  done
867988de56ccSmrg	  eval $var=\"$tmp_libs\"
868088de56ccSmrg	done # for var
868188de56ccSmrg      fi
8682862bcd1aSmrg
8683862bcd1aSmrg      # Add Sun CC postdeps if required:
8684862bcd1aSmrg      test CXX = "$tagname" && {
8685862bcd1aSmrg        case $host_os in
8686862bcd1aSmrg        linux*)
8687862bcd1aSmrg          case `$CC -V 2>&1 | sed 5q` in
8688862bcd1aSmrg          *Sun\ C*) # Sun C++ 5.9
8689862bcd1aSmrg            func_suncc_cstd_abi
8690862bcd1aSmrg
8691862bcd1aSmrg            if test no != "$suncc_use_cstd_abi"; then
8692862bcd1aSmrg              func_append postdeps ' -library=Cstd -library=Crun'
8693862bcd1aSmrg            fi
8694862bcd1aSmrg            ;;
8695862bcd1aSmrg          esac
8696862bcd1aSmrg          ;;
8697862bcd1aSmrg
8698862bcd1aSmrg        solaris*)
8699862bcd1aSmrg          func_cc_basename "$CC"
8700862bcd1aSmrg          case $func_cc_basename_result in
8701862bcd1aSmrg          CC* | sunCC*)
8702862bcd1aSmrg            func_suncc_cstd_abi
8703862bcd1aSmrg
8704862bcd1aSmrg            if test no != "$suncc_use_cstd_abi"; then
8705862bcd1aSmrg              func_append postdeps ' -library=Cstd -library=Crun'
8706862bcd1aSmrg            fi
8707862bcd1aSmrg            ;;
8708862bcd1aSmrg          esac
8709862bcd1aSmrg          ;;
8710862bcd1aSmrg        esac
8711862bcd1aSmrg      }
8712862bcd1aSmrg
871388de56ccSmrg      # Last step: remove runtime libs from dependency_libs
871488de56ccSmrg      # (they stay in deplibs)
871588de56ccSmrg      tmp_libs=
8716862bcd1aSmrg      for i in $dependency_libs; do
871788de56ccSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
871888de56ccSmrg	*" $i "*)
8719862bcd1aSmrg	  i=
872088de56ccSmrg	  ;;
872188de56ccSmrg	esac
8722862bcd1aSmrg	if test -n "$i"; then
8723e9fcaa8aSmrg	  func_append tmp_libs " $i"
872488de56ccSmrg	fi
872588de56ccSmrg      done
872688de56ccSmrg      dependency_libs=$tmp_libs
872788de56ccSmrg    done # for pass
8728862bcd1aSmrg    if test prog = "$linkmode"; then
8729862bcd1aSmrg      dlfiles=$newdlfiles
873088de56ccSmrg    fi
8731862bcd1aSmrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
8732862bcd1aSmrg      dlprefiles=$newdlprefiles
873388de56ccSmrg    fi
873488de56ccSmrg
873588de56ccSmrg    case $linkmode in
873688de56ccSmrg    oldlib)
8737862bcd1aSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
8738862bcd1aSmrg	func_warning "'-dlopen' is ignored for archives"
873988de56ccSmrg      fi
874088de56ccSmrg
874188de56ccSmrg      case " $deplibs" in
874288de56ccSmrg      *\ -l* | *\ -L*)
8743862bcd1aSmrg	func_warning "'-l' and '-L' are ignored for archives" ;;
874488de56ccSmrg      esac
874588de56ccSmrg
874688de56ccSmrg      test -n "$rpath" && \
8747862bcd1aSmrg	func_warning "'-rpath' is ignored for archives"
874888de56ccSmrg
874988de56ccSmrg      test -n "$xrpath" && \
8750862bcd1aSmrg	func_warning "'-R' is ignored for archives"
875188de56ccSmrg
875288de56ccSmrg      test -n "$vinfo" && \
8753862bcd1aSmrg	func_warning "'-version-info/-version-number' is ignored for archives"
875488de56ccSmrg
875588de56ccSmrg      test -n "$release" && \
8756862bcd1aSmrg	func_warning "'-release' is ignored for archives"
875788de56ccSmrg
875888de56ccSmrg      test -n "$export_symbols$export_symbols_regex" && \
8759862bcd1aSmrg	func_warning "'-export-symbols' is ignored for archives"
876088de56ccSmrg
876188de56ccSmrg      # Now set the variables for building old libraries.
876288de56ccSmrg      build_libtool_libs=no
8763862bcd1aSmrg      oldlibs=$output
8764e9fcaa8aSmrg      func_append objs "$old_deplibs"
876588de56ccSmrg      ;;
876688de56ccSmrg
876788de56ccSmrg    lib)
8768862bcd1aSmrg      # Make sure we only generate libraries of the form 'libNAME.la'.
876988de56ccSmrg      case $outputname in
877088de56ccSmrg      lib*)
877188de56ccSmrg	func_stripname 'lib' '.la' "$outputname"
877288de56ccSmrg	name=$func_stripname_result
877388de56ccSmrg	eval shared_ext=\"$shrext_cmds\"
877488de56ccSmrg	eval libname=\"$libname_spec\"
877588de56ccSmrg	;;
877688de56ccSmrg      *)
8777862bcd1aSmrg	test no = "$module" \
8778862bcd1aSmrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
877988de56ccSmrg
8780862bcd1aSmrg	if test no != "$need_lib_prefix"; then
878188de56ccSmrg	  # Add the "lib" prefix for modules if required
878288de56ccSmrg	  func_stripname '' '.la' "$outputname"
878388de56ccSmrg	  name=$func_stripname_result
878488de56ccSmrg	  eval shared_ext=\"$shrext_cmds\"
878588de56ccSmrg	  eval libname=\"$libname_spec\"
878688de56ccSmrg	else
878788de56ccSmrg	  func_stripname '' '.la' "$outputname"
878888de56ccSmrg	  libname=$func_stripname_result
878988de56ccSmrg	fi
879088de56ccSmrg	;;
879188de56ccSmrg      esac
879288de56ccSmrg
879388de56ccSmrg      if test -n "$objs"; then
8794862bcd1aSmrg	if test pass_all != "$deplibs_check_method"; then
8795862bcd1aSmrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
879688de56ccSmrg	else
8797e9fcaa8aSmrg	  echo
879888de56ccSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
879988de56ccSmrg	  $ECHO "*** objects $objs is not portable!"
8800e9fcaa8aSmrg	  func_append libobjs " $objs"
880188de56ccSmrg	fi
880288de56ccSmrg      fi
880388de56ccSmrg
8804862bcd1aSmrg      test no = "$dlself" \
8805862bcd1aSmrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
880688de56ccSmrg
880788de56ccSmrg      set dummy $rpath
880888de56ccSmrg      shift
8809862bcd1aSmrg      test 1 -lt "$#" \
8810862bcd1aSmrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
881188de56ccSmrg
8812862bcd1aSmrg      install_libdir=$1
881388de56ccSmrg
881488de56ccSmrg      oldlibs=
881588de56ccSmrg      if test -z "$rpath"; then
8816862bcd1aSmrg	if test yes = "$build_libtool_libs"; then
881788de56ccSmrg	  # Building a libtool convenience library.
8818862bcd1aSmrg	  # Some compilers have problems with a '.al' extension so
881988de56ccSmrg	  # convenience libraries should have the same extension an
882088de56ccSmrg	  # archive normally would.
882188de56ccSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
882288de56ccSmrg	  build_libtool_libs=convenience
882388de56ccSmrg	  build_old_libs=yes
882488de56ccSmrg	fi
882588de56ccSmrg
882688de56ccSmrg	test -n "$vinfo" && \
8827862bcd1aSmrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
882888de56ccSmrg
882988de56ccSmrg	test -n "$release" && \
8830862bcd1aSmrg	  func_warning "'-release' is ignored for convenience libraries"
883188de56ccSmrg      else
883288de56ccSmrg
883388de56ccSmrg	# Parse the version information argument.
8834862bcd1aSmrg	save_ifs=$IFS; IFS=:
883588de56ccSmrg	set dummy $vinfo 0 0 0
883688de56ccSmrg	shift
8837862bcd1aSmrg	IFS=$save_ifs
883888de56ccSmrg
883988de56ccSmrg	test -n "$7" && \
8840862bcd1aSmrg	  func_fatal_help "too many parameters to '-version-info'"
884188de56ccSmrg
884288de56ccSmrg	# convert absolute version numbers to libtool ages
884388de56ccSmrg	# this retains compatibility with .la files and attempts
884488de56ccSmrg	# to make the code below a bit more comprehensible
884588de56ccSmrg
884688de56ccSmrg	case $vinfo_number in
884788de56ccSmrg	yes)
8848862bcd1aSmrg	  number_major=$1
8849862bcd1aSmrg	  number_minor=$2
8850862bcd1aSmrg	  number_revision=$3
885188de56ccSmrg	  #
885288de56ccSmrg	  # There are really only two kinds -- those that
885388de56ccSmrg	  # use the current revision as the major version
885488de56ccSmrg	  # and those that subtract age and use age as
885588de56ccSmrg	  # a minor version.  But, then there is irix
8856862bcd1aSmrg	  # that has an extra 1 added just for fun
885788de56ccSmrg	  #
885888de56ccSmrg	  case $version_type in
8859eb411b4bSmrg	  # correct linux to gnu/linux during the next big refactor
8860862bcd1aSmrg	  darwin|freebsd-elf|linux|osf|windows|none)
886188de56ccSmrg	    func_arith $number_major + $number_minor
886288de56ccSmrg	    current=$func_arith_result
8863862bcd1aSmrg	    age=$number_minor
8864862bcd1aSmrg	    revision=$number_revision
886588de56ccSmrg	    ;;
8866862bcd1aSmrg	  freebsd-aout|qnx|sunos)
8867862bcd1aSmrg	    current=$number_major
8868862bcd1aSmrg	    revision=$number_minor
8869862bcd1aSmrg	    age=0
887088de56ccSmrg	    ;;
887188de56ccSmrg	  irix|nonstopux)
887288de56ccSmrg	    func_arith $number_major + $number_minor
887388de56ccSmrg	    current=$func_arith_result
8874862bcd1aSmrg	    age=$number_minor
8875862bcd1aSmrg	    revision=$number_minor
887688de56ccSmrg	    lt_irix_increment=no
887788de56ccSmrg	    ;;
887888de56ccSmrg	  esac
887988de56ccSmrg	  ;;
888088de56ccSmrg	no)
8881862bcd1aSmrg	  current=$1
8882862bcd1aSmrg	  revision=$2
8883862bcd1aSmrg	  age=$3
888488de56ccSmrg	  ;;
888588de56ccSmrg	esac
888688de56ccSmrg
888788de56ccSmrg	# Check that each of the things are valid numbers.
888888de56ccSmrg	case $current in
888988de56ccSmrg	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]) ;;
889088de56ccSmrg	*)
8891862bcd1aSmrg	  func_error "CURRENT '$current' must be a nonnegative integer"
8892862bcd1aSmrg	  func_fatal_error "'$vinfo' is not valid version information"
889388de56ccSmrg	  ;;
889488de56ccSmrg	esac
889588de56ccSmrg
889688de56ccSmrg	case $revision in
889788de56ccSmrg	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]) ;;
889888de56ccSmrg	*)
8899862bcd1aSmrg	  func_error "REVISION '$revision' must be a nonnegative integer"
8900862bcd1aSmrg	  func_fatal_error "'$vinfo' is not valid version information"
890188de56ccSmrg	  ;;
890288de56ccSmrg	esac
890388de56ccSmrg
890488de56ccSmrg	case $age in
890588de56ccSmrg	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]) ;;
890688de56ccSmrg	*)
8907862bcd1aSmrg	  func_error "AGE '$age' must be a nonnegative integer"
8908862bcd1aSmrg	  func_fatal_error "'$vinfo' is not valid version information"
890988de56ccSmrg	  ;;
891088de56ccSmrg	esac
891188de56ccSmrg
891288de56ccSmrg	if test "$age" -gt "$current"; then
8913862bcd1aSmrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
8914862bcd1aSmrg	  func_fatal_error "'$vinfo' is not valid version information"
891588de56ccSmrg	fi
891688de56ccSmrg
891788de56ccSmrg	# Calculate the version variables.
891888de56ccSmrg	major=
891988de56ccSmrg	versuffix=
892088de56ccSmrg	verstring=
892188de56ccSmrg	case $version_type in
892288de56ccSmrg	none) ;;
892388de56ccSmrg
892488de56ccSmrg	darwin)
892588de56ccSmrg	  # Like Linux, but with the current version available in
892688de56ccSmrg	  # verstring for coding it into the library header
892788de56ccSmrg	  func_arith $current - $age
892888de56ccSmrg	  major=.$func_arith_result
8929862bcd1aSmrg	  versuffix=$major.$age.$revision
893088de56ccSmrg	  # Darwin ld doesn't like 0 for these options...
893188de56ccSmrg	  func_arith $current + 1
893288de56ccSmrg	  minor_current=$func_arith_result
8933862bcd1aSmrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
893488de56ccSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8935862bcd1aSmrg          # On Darwin other compilers
8936862bcd1aSmrg          case $CC in
8937862bcd1aSmrg              nagfor*)
8938862bcd1aSmrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8939862bcd1aSmrg                  ;;
8940862bcd1aSmrg              *)
8941862bcd1aSmrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8942862bcd1aSmrg                  ;;
8943862bcd1aSmrg          esac
894488de56ccSmrg	  ;;
894588de56ccSmrg
894688de56ccSmrg	freebsd-aout)
8947862bcd1aSmrg	  major=.$current
8948862bcd1aSmrg	  versuffix=.$current.$revision
894988de56ccSmrg	  ;;
895088de56ccSmrg
895188de56ccSmrg	freebsd-elf)
8952862bcd1aSmrg	  func_arith $current - $age
8953862bcd1aSmrg	  major=.$func_arith_result
8954862bcd1aSmrg	  versuffix=$major.$age.$revision
895588de56ccSmrg	  ;;
895688de56ccSmrg
895788de56ccSmrg	irix | nonstopux)
8958862bcd1aSmrg	  if test no = "$lt_irix_increment"; then
895988de56ccSmrg	    func_arith $current - $age
896088de56ccSmrg	  else
896188de56ccSmrg	    func_arith $current - $age + 1
896288de56ccSmrg	  fi
896388de56ccSmrg	  major=$func_arith_result
896488de56ccSmrg
896588de56ccSmrg	  case $version_type in
896688de56ccSmrg	    nonstopux) verstring_prefix=nonstopux ;;
896788de56ccSmrg	    *)         verstring_prefix=sgi ;;
896888de56ccSmrg	  esac
8969862bcd1aSmrg	  verstring=$verstring_prefix$major.$revision
897088de56ccSmrg
897188de56ccSmrg	  # Add in all the interfaces that we are compatible with.
897288de56ccSmrg	  loop=$revision
8973862bcd1aSmrg	  while test 0 -ne "$loop"; do
897488de56ccSmrg	    func_arith $revision - $loop
897588de56ccSmrg	    iface=$func_arith_result
897688de56ccSmrg	    func_arith $loop - 1
897788de56ccSmrg	    loop=$func_arith_result
8978862bcd1aSmrg	    verstring=$verstring_prefix$major.$iface:$verstring
897988de56ccSmrg	  done
898088de56ccSmrg
8981862bcd1aSmrg	  # Before this point, $major must not contain '.'.
898288de56ccSmrg	  major=.$major
8983862bcd1aSmrg	  versuffix=$major.$revision
898488de56ccSmrg	  ;;
898588de56ccSmrg
8986eb411b4bSmrg	linux) # correct to gnu/linux during the next big refactor
898788de56ccSmrg	  func_arith $current - $age
898888de56ccSmrg	  major=.$func_arith_result
8989862bcd1aSmrg	  versuffix=$major.$age.$revision
899088de56ccSmrg	  ;;
899188de56ccSmrg
899288de56ccSmrg	osf)
899388de56ccSmrg	  func_arith $current - $age
899488de56ccSmrg	  major=.$func_arith_result
8995862bcd1aSmrg	  versuffix=.$current.$age.$revision
8996862bcd1aSmrg	  verstring=$current.$age.$revision
899788de56ccSmrg
899888de56ccSmrg	  # Add in all the interfaces that we are compatible with.
899988de56ccSmrg	  loop=$age
9000862bcd1aSmrg	  while test 0 -ne "$loop"; do
900188de56ccSmrg	    func_arith $current - $loop
900288de56ccSmrg	    iface=$func_arith_result
900388de56ccSmrg	    func_arith $loop - 1
900488de56ccSmrg	    loop=$func_arith_result
9005862bcd1aSmrg	    verstring=$verstring:$iface.0
900688de56ccSmrg	  done
900788de56ccSmrg
900888de56ccSmrg	  # Make executables depend on our current version.
9009862bcd1aSmrg	  func_append verstring ":$current.0"
901088de56ccSmrg	  ;;
901188de56ccSmrg
901288de56ccSmrg	qnx)
9013862bcd1aSmrg	  major=.$current
9014862bcd1aSmrg	  versuffix=.$current
9015862bcd1aSmrg	  ;;
9016862bcd1aSmrg
9017862bcd1aSmrg	sco)
9018862bcd1aSmrg	  major=.$current
9019862bcd1aSmrg	  versuffix=.$current
902088de56ccSmrg	  ;;
902188de56ccSmrg
902288de56ccSmrg	sunos)
9023862bcd1aSmrg	  major=.$current
9024862bcd1aSmrg	  versuffix=.$current.$revision
902588de56ccSmrg	  ;;
902688de56ccSmrg
902788de56ccSmrg	windows)
902888de56ccSmrg	  # Use '-' rather than '.', since we only want one
9029862bcd1aSmrg	  # extension on DOS 8.3 file systems.
903088de56ccSmrg	  func_arith $current - $age
903188de56ccSmrg	  major=$func_arith_result
9032862bcd1aSmrg	  versuffix=-$major
903388de56ccSmrg	  ;;
903488de56ccSmrg
903588de56ccSmrg	*)
9036862bcd1aSmrg	  func_fatal_configuration "unknown library version type '$version_type'"
903788de56ccSmrg	  ;;
903888de56ccSmrg	esac
903988de56ccSmrg
904088de56ccSmrg	# Clear the version info if we defaulted, and they specified a release.
904188de56ccSmrg	if test -z "$vinfo" && test -n "$release"; then
904288de56ccSmrg	  major=
904388de56ccSmrg	  case $version_type in
904488de56ccSmrg	  darwin)
904588de56ccSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
904688de56ccSmrg	    # problems, so we reset it completely
904788de56ccSmrg	    verstring=
904888de56ccSmrg	    ;;
904988de56ccSmrg	  *)
9050862bcd1aSmrg	    verstring=0.0
905188de56ccSmrg	    ;;
905288de56ccSmrg	  esac
9053862bcd1aSmrg	  if test no = "$need_version"; then
905488de56ccSmrg	    versuffix=
905588de56ccSmrg	  else
9056862bcd1aSmrg	    versuffix=.0.0
905788de56ccSmrg	  fi
905888de56ccSmrg	fi
905988de56ccSmrg
906088de56ccSmrg	# Remove version info from name if versioning should be avoided
9061862bcd1aSmrg	if test yes,no = "$avoid_version,$need_version"; then
906288de56ccSmrg	  major=
906388de56ccSmrg	  versuffix=
9064862bcd1aSmrg	  verstring=
906588de56ccSmrg	fi
906688de56ccSmrg
906788de56ccSmrg	# Check to see if the archive will have undefined symbols.
9068862bcd1aSmrg	if test yes = "$allow_undefined"; then
9069862bcd1aSmrg	  if test unsupported = "$allow_undefined_flag"; then
9070862bcd1aSmrg	    if test yes = "$build_old_libs"; then
9071862bcd1aSmrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
9072862bcd1aSmrg	      build_libtool_libs=no
9073862bcd1aSmrg	    else
9074862bcd1aSmrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
9075862bcd1aSmrg	    fi
907688de56ccSmrg	  fi
907788de56ccSmrg	else
907888de56ccSmrg	  # Don't allow undefined symbols.
9079862bcd1aSmrg	  allow_undefined_flag=$no_undefined_flag
908088de56ccSmrg	fi
908188de56ccSmrg
908288de56ccSmrg      fi
908388de56ccSmrg
9084862bcd1aSmrg      func_generate_dlsyms "$libname" "$libname" :
9085e9fcaa8aSmrg      func_append libobjs " $symfileobj"
9086862bcd1aSmrg      test " " = "$libobjs" && libobjs=
908788de56ccSmrg
9088862bcd1aSmrg      if test relink != "$opt_mode"; then
908988de56ccSmrg	# Remove our outputs, but don't remove object files since they
909088de56ccSmrg	# may have been created when compiling PIC objects.
909188de56ccSmrg	removelist=
909288de56ccSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
909388de56ccSmrg	for p in $tempremovelist; do
909488de56ccSmrg	  case $p in
909588de56ccSmrg	    *.$objext | *.gcno)
909688de56ccSmrg	       ;;
9097862bcd1aSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
9098862bcd1aSmrg	       if test -n "$precious_files_regex"; then
909988de56ccSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
910088de56ccSmrg		 then
910188de56ccSmrg		   continue
910288de56ccSmrg		 fi
910388de56ccSmrg	       fi
9104e9fcaa8aSmrg	       func_append removelist " $p"
910588de56ccSmrg	       ;;
910688de56ccSmrg	    *) ;;
910788de56ccSmrg	  esac
910888de56ccSmrg	done
910988de56ccSmrg	test -n "$removelist" && \
911088de56ccSmrg	  func_show_eval "${RM}r \$removelist"
911188de56ccSmrg      fi
911288de56ccSmrg
911388de56ccSmrg      # Now set the variables for building old libraries.
9114862bcd1aSmrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9115e9fcaa8aSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
911688de56ccSmrg
911788de56ccSmrg	# Transform .lo files to .o files.
9118862bcd1aSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
911988de56ccSmrg      fi
912088de56ccSmrg
912188de56ccSmrg      # Eliminate all temporary directories.
912288de56ccSmrg      #for path in $notinst_path; do
9123e9fcaa8aSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9124e9fcaa8aSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9125e9fcaa8aSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
912688de56ccSmrg      #done
912788de56ccSmrg
912888de56ccSmrg      if test -n "$xrpath"; then
912988de56ccSmrg	# If the user specified any rpath flags, then add them.
913088de56ccSmrg	temp_xrpath=
913188de56ccSmrg	for libdir in $xrpath; do
9132e9fcaa8aSmrg	  func_replace_sysroot "$libdir"
9133e9fcaa8aSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
913488de56ccSmrg	  case "$finalize_rpath " in
913588de56ccSmrg	  *" $libdir "*) ;;
9136e9fcaa8aSmrg	  *) func_append finalize_rpath " $libdir" ;;
913788de56ccSmrg	  esac
913888de56ccSmrg	done
9139862bcd1aSmrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
914088de56ccSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
914188de56ccSmrg	fi
914288de56ccSmrg      fi
914388de56ccSmrg
914488de56ccSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
9145862bcd1aSmrg      old_dlfiles=$dlfiles
914688de56ccSmrg      dlfiles=
914788de56ccSmrg      for lib in $old_dlfiles; do
914888de56ccSmrg	case " $dlprefiles $dlfiles " in
914988de56ccSmrg	*" $lib "*) ;;
9150e9fcaa8aSmrg	*) func_append dlfiles " $lib" ;;
915188de56ccSmrg	esac
915288de56ccSmrg      done
915388de56ccSmrg
915488de56ccSmrg      # Make sure dlprefiles contains only unique files
9155862bcd1aSmrg      old_dlprefiles=$dlprefiles
915688de56ccSmrg      dlprefiles=
915788de56ccSmrg      for lib in $old_dlprefiles; do
915888de56ccSmrg	case "$dlprefiles " in
915988de56ccSmrg	*" $lib "*) ;;
9160e9fcaa8aSmrg	*) func_append dlprefiles " $lib" ;;
916188de56ccSmrg	esac
916288de56ccSmrg      done
916388de56ccSmrg
9164862bcd1aSmrg      if test yes = "$build_libtool_libs"; then
916588de56ccSmrg	if test -n "$rpath"; then
916688de56ccSmrg	  case $host in
9167e9fcaa8aSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
916888de56ccSmrg	    # these systems don't actually have a c library (as such)!
916988de56ccSmrg	    ;;
917088de56ccSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
917188de56ccSmrg	    # Rhapsody C library is in the System framework
9172e9fcaa8aSmrg	    func_append deplibs " System.ltframework"
917388de56ccSmrg	    ;;
917488de56ccSmrg	  *-*-netbsd*)
917588de56ccSmrg	    # Don't link with libc until the a.out ld.so is fixed.
917688de56ccSmrg	    ;;
917788de56ccSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
917888de56ccSmrg	    # Do not include libc due to us having libc/libc_r.
917988de56ccSmrg	    ;;
918088de56ccSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
918188de56ccSmrg	    # Causes problems with __ctype
918288de56ccSmrg	    ;;
918388de56ccSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
918488de56ccSmrg	    # Compiler inserts libc in the correct place for threads to work
918588de56ccSmrg	    ;;
918688de56ccSmrg	  *)
918788de56ccSmrg	    # Add libc to deplibs on all other systems if necessary.
9188862bcd1aSmrg	    if test yes = "$build_libtool_need_lc"; then
9189e9fcaa8aSmrg	      func_append deplibs " -lc"
919088de56ccSmrg	    fi
919188de56ccSmrg	    ;;
919288de56ccSmrg	  esac
919388de56ccSmrg	fi
919488de56ccSmrg
919588de56ccSmrg	# Transform deplibs into only deplibs that can be linked in shared.
919688de56ccSmrg	name_save=$name
919788de56ccSmrg	libname_save=$libname
919888de56ccSmrg	release_save=$release
919988de56ccSmrg	versuffix_save=$versuffix
920088de56ccSmrg	major_save=$major
920188de56ccSmrg	# I'm not sure if I'm treating the release correctly.  I think
920288de56ccSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
920388de56ccSmrg	# add it in twice.  Is that correct?
9204862bcd1aSmrg	release=
9205862bcd1aSmrg	versuffix=
9206862bcd1aSmrg	major=
920788de56ccSmrg	newdeplibs=
920888de56ccSmrg	droppeddeps=no
920988de56ccSmrg	case $deplibs_check_method in
921088de56ccSmrg	pass_all)
921188de56ccSmrg	  # Don't check for shared/static.  Everything works.
921288de56ccSmrg	  # This might be a little naive.  We might want to check
921388de56ccSmrg	  # whether the library exists or not.  But this is on
921488de56ccSmrg	  # osf3 & osf4 and I'm not really sure... Just
921588de56ccSmrg	  # implementing what was already the behavior.
921688de56ccSmrg	  newdeplibs=$deplibs
921788de56ccSmrg	  ;;
921888de56ccSmrg	test_compile)
921988de56ccSmrg	  # This code stresses the "libraries are programs" paradigm to its
922088de56ccSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
922188de56ccSmrg	  # against the deplibs as a proxy for the library.  Then we can check
922288de56ccSmrg	  # whether they linked in statically or dynamically with ldd.
922388de56ccSmrg	  $opt_dry_run || $RM conftest.c
922488de56ccSmrg	  cat > conftest.c <<EOF
922588de56ccSmrg	  int main() { return 0; }
922688de56ccSmrgEOF
922788de56ccSmrg	  $opt_dry_run || $RM conftest
922888de56ccSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
922988de56ccSmrg	    ldd_output=`ldd conftest`
923088de56ccSmrg	    for i in $deplibs; do
923188de56ccSmrg	      case $i in
923288de56ccSmrg	      -l*)
923388de56ccSmrg		func_stripname -l '' "$i"
923488de56ccSmrg		name=$func_stripname_result
9235862bcd1aSmrg		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
923688de56ccSmrg		  case " $predeps $postdeps " in
923788de56ccSmrg		  *" $i "*)
9238e9fcaa8aSmrg		    func_append newdeplibs " $i"
9239862bcd1aSmrg		    i=
924088de56ccSmrg		    ;;
924188de56ccSmrg		  esac
924288de56ccSmrg		fi
9243862bcd1aSmrg		if test -n "$i"; then
924488de56ccSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
924588de56ccSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
924688de56ccSmrg		  set dummy $deplib_matches; shift
924788de56ccSmrg		  deplib_match=$1
9248862bcd1aSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9249e9fcaa8aSmrg		    func_append newdeplibs " $i"
925088de56ccSmrg		  else
925188de56ccSmrg		    droppeddeps=yes
9252e9fcaa8aSmrg		    echo
925388de56ccSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9254e9fcaa8aSmrg		    echo "*** I have the capability to make that library automatically link in when"
9255e9fcaa8aSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
9256e9fcaa8aSmrg		    echo "*** shared version of the library, which I believe you do not have"
9257e9fcaa8aSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
9258e9fcaa8aSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
925988de56ccSmrg		  fi
926088de56ccSmrg		fi
926188de56ccSmrg		;;
926288de56ccSmrg	      *)
9263e9fcaa8aSmrg		func_append newdeplibs " $i"
926488de56ccSmrg		;;
926588de56ccSmrg	      esac
926688de56ccSmrg	    done
926788de56ccSmrg	  else
926888de56ccSmrg	    # Error occurred in the first compile.  Let's try to salvage
926988de56ccSmrg	    # the situation: Compile a separate program for each library.
927088de56ccSmrg	    for i in $deplibs; do
927188de56ccSmrg	      case $i in
927288de56ccSmrg	      -l*)
927388de56ccSmrg		func_stripname -l '' "$i"
927488de56ccSmrg		name=$func_stripname_result
927588de56ccSmrg		$opt_dry_run || $RM conftest
927688de56ccSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
927788de56ccSmrg		  ldd_output=`ldd conftest`
9278862bcd1aSmrg		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
927988de56ccSmrg		    case " $predeps $postdeps " in
928088de56ccSmrg		    *" $i "*)
9281e9fcaa8aSmrg		      func_append newdeplibs " $i"
9282862bcd1aSmrg		      i=
928388de56ccSmrg		      ;;
928488de56ccSmrg		    esac
928588de56ccSmrg		  fi
9286862bcd1aSmrg		  if test -n "$i"; then
928788de56ccSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
928888de56ccSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
928988de56ccSmrg		    set dummy $deplib_matches; shift
929088de56ccSmrg		    deplib_match=$1
9291862bcd1aSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9292e9fcaa8aSmrg		      func_append newdeplibs " $i"
929388de56ccSmrg		    else
929488de56ccSmrg		      droppeddeps=yes
9295e9fcaa8aSmrg		      echo
929688de56ccSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9297e9fcaa8aSmrg		      echo "*** I have the capability to make that library automatically link in when"
9298e9fcaa8aSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
9299e9fcaa8aSmrg		      echo "*** shared version of the library, which you do not appear to have"
9300e9fcaa8aSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
9301e9fcaa8aSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
930288de56ccSmrg		    fi
930388de56ccSmrg		  fi
930488de56ccSmrg		else
930588de56ccSmrg		  droppeddeps=yes
9306e9fcaa8aSmrg		  echo
930788de56ccSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
9308e9fcaa8aSmrg		  echo "*** make it link in!  You will probably need to install it or some"
9309e9fcaa8aSmrg		  echo "*** library that it depends on before this library will be fully"
9310e9fcaa8aSmrg		  echo "*** functional.  Installing it before continuing would be even better."
931188de56ccSmrg		fi
931288de56ccSmrg		;;
931388de56ccSmrg	      *)
9314e9fcaa8aSmrg		func_append newdeplibs " $i"
931588de56ccSmrg		;;
931688de56ccSmrg	      esac
931788de56ccSmrg	    done
931888de56ccSmrg	  fi
931988de56ccSmrg	  ;;
932088de56ccSmrg	file_magic*)
932188de56ccSmrg	  set dummy $deplibs_check_method; shift
932288de56ccSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
932388de56ccSmrg	  for a_deplib in $deplibs; do
932488de56ccSmrg	    case $a_deplib in
932588de56ccSmrg	    -l*)
932688de56ccSmrg	      func_stripname -l '' "$a_deplib"
932788de56ccSmrg	      name=$func_stripname_result
9328862bcd1aSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
932988de56ccSmrg		case " $predeps $postdeps " in
933088de56ccSmrg		*" $a_deplib "*)
9331e9fcaa8aSmrg		  func_append newdeplibs " $a_deplib"
9332862bcd1aSmrg		  a_deplib=
933388de56ccSmrg		  ;;
933488de56ccSmrg		esac
933588de56ccSmrg	      fi
9336862bcd1aSmrg	      if test -n "$a_deplib"; then
933788de56ccSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9338e9fcaa8aSmrg		if test -n "$file_magic_glob"; then
9339e9fcaa8aSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9340e9fcaa8aSmrg		else
9341e9fcaa8aSmrg		  libnameglob=$libname
9342e9fcaa8aSmrg		fi
9343862bcd1aSmrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
934488de56ccSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9345862bcd1aSmrg		  if test yes = "$want_nocaseglob"; then
9346e9fcaa8aSmrg		    shopt -s nocaseglob
9347e9fcaa8aSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9348e9fcaa8aSmrg		    $nocaseglob
9349e9fcaa8aSmrg		  else
9350e9fcaa8aSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9351e9fcaa8aSmrg		  fi
935288de56ccSmrg		  for potent_lib in $potential_libs; do
935388de56ccSmrg		      # Follow soft links.
935488de56ccSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
935588de56ccSmrg			 $GREP " -> " >/dev/null; then
935688de56ccSmrg			continue
935788de56ccSmrg		      fi
935888de56ccSmrg		      # The statement above tries to avoid entering an
935988de56ccSmrg		      # endless loop below, in case of cyclic links.
936088de56ccSmrg		      # We might still enter an endless loop, since a link
936188de56ccSmrg		      # loop can be closed while we follow links,
936288de56ccSmrg		      # but so what?
9363862bcd1aSmrg		      potlib=$potent_lib
936488de56ccSmrg		      while test -h "$potlib" 2>/dev/null; do
9365862bcd1aSmrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
936688de56ccSmrg			case $potliblink in
9367862bcd1aSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
9368862bcd1aSmrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
936988de56ccSmrg			esac
937088de56ccSmrg		      done
937188de56ccSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
937288de56ccSmrg			 $SED -e 10q |
937388de56ccSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
9374e9fcaa8aSmrg			func_append newdeplibs " $a_deplib"
9375862bcd1aSmrg			a_deplib=
937688de56ccSmrg			break 2
937788de56ccSmrg		      fi
937888de56ccSmrg		  done
937988de56ccSmrg		done
938088de56ccSmrg	      fi
9381862bcd1aSmrg	      if test -n "$a_deplib"; then
938288de56ccSmrg		droppeddeps=yes
9383e9fcaa8aSmrg		echo
938488de56ccSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9385e9fcaa8aSmrg		echo "*** I have the capability to make that library automatically link in when"
9386e9fcaa8aSmrg		echo "*** you link to this library.  But I can only do this if you have a"
9387e9fcaa8aSmrg		echo "*** shared version of the library, which you do not appear to have"
9388e9fcaa8aSmrg		echo "*** because I did check the linker path looking for a file starting"
9389862bcd1aSmrg		if test -z "$potlib"; then
939088de56ccSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
939188de56ccSmrg		else
939288de56ccSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
939388de56ccSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
939488de56ccSmrg		fi
939588de56ccSmrg	      fi
939688de56ccSmrg	      ;;
939788de56ccSmrg	    *)
939888de56ccSmrg	      # Add a -L argument.
9399e9fcaa8aSmrg	      func_append newdeplibs " $a_deplib"
940088de56ccSmrg	      ;;
940188de56ccSmrg	    esac
940288de56ccSmrg	  done # Gone through all deplibs.
940388de56ccSmrg	  ;;
940488de56ccSmrg	match_pattern*)
940588de56ccSmrg	  set dummy $deplibs_check_method; shift
940688de56ccSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
940788de56ccSmrg	  for a_deplib in $deplibs; do
940888de56ccSmrg	    case $a_deplib in
940988de56ccSmrg	    -l*)
941088de56ccSmrg	      func_stripname -l '' "$a_deplib"
941188de56ccSmrg	      name=$func_stripname_result
9412862bcd1aSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
941388de56ccSmrg		case " $predeps $postdeps " in
941488de56ccSmrg		*" $a_deplib "*)
9415e9fcaa8aSmrg		  func_append newdeplibs " $a_deplib"
9416862bcd1aSmrg		  a_deplib=
941788de56ccSmrg		  ;;
941888de56ccSmrg		esac
941988de56ccSmrg	      fi
9420862bcd1aSmrg	      if test -n "$a_deplib"; then
942188de56ccSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
942288de56ccSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
942388de56ccSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
942488de56ccSmrg		  for potent_lib in $potential_libs; do
9425862bcd1aSmrg		    potlib=$potent_lib # see symlink-check above in file_magic test
9426e9fcaa8aSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
942788de56ccSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
9428e9fcaa8aSmrg		      func_append newdeplibs " $a_deplib"
9429862bcd1aSmrg		      a_deplib=
943088de56ccSmrg		      break 2
943188de56ccSmrg		    fi
943288de56ccSmrg		  done
943388de56ccSmrg		done
943488de56ccSmrg	      fi
9435862bcd1aSmrg	      if test -n "$a_deplib"; then
943688de56ccSmrg		droppeddeps=yes
9437e9fcaa8aSmrg		echo
943888de56ccSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9439e9fcaa8aSmrg		echo "*** I have the capability to make that library automatically link in when"
9440e9fcaa8aSmrg		echo "*** you link to this library.  But I can only do this if you have a"
9441e9fcaa8aSmrg		echo "*** shared version of the library, which you do not appear to have"
9442e9fcaa8aSmrg		echo "*** because I did check the linker path looking for a file starting"
9443862bcd1aSmrg		if test -z "$potlib"; then
944488de56ccSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
944588de56ccSmrg		else
944688de56ccSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
944788de56ccSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
944888de56ccSmrg		fi
944988de56ccSmrg	      fi
945088de56ccSmrg	      ;;
945188de56ccSmrg	    *)
945288de56ccSmrg	      # Add a -L argument.
9453e9fcaa8aSmrg	      func_append newdeplibs " $a_deplib"
945488de56ccSmrg	      ;;
945588de56ccSmrg	    esac
945688de56ccSmrg	  done # Gone through all deplibs.
945788de56ccSmrg	  ;;
945888de56ccSmrg	none | unknown | *)
9459862bcd1aSmrg	  newdeplibs=
9460e9fcaa8aSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
9461862bcd1aSmrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9462862bcd1aSmrg	    for i in $predeps $postdeps; do
946388de56ccSmrg	      # can't use Xsed below, because $i might contain '/'
9464862bcd1aSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
946588de56ccSmrg	    done
946688de56ccSmrg	  fi
9467e9fcaa8aSmrg	  case $tmp_deplibs in
9468e9fcaa8aSmrg	  *[!\	\ ]*)
9469e9fcaa8aSmrg	    echo
9470862bcd1aSmrg	    if test none = "$deplibs_check_method"; then
9471e9fcaa8aSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
947288de56ccSmrg	    else
9473e9fcaa8aSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
947488de56ccSmrg	    fi
9475e9fcaa8aSmrg	    echo "*** All declared inter-library dependencies are being dropped."
947688de56ccSmrg	    droppeddeps=yes
9477e9fcaa8aSmrg	    ;;
9478e9fcaa8aSmrg	  esac
947988de56ccSmrg	  ;;
948088de56ccSmrg	esac
948188de56ccSmrg	versuffix=$versuffix_save
948288de56ccSmrg	major=$major_save
948388de56ccSmrg	release=$release_save
948488de56ccSmrg	libname=$libname_save
948588de56ccSmrg	name=$name_save
948688de56ccSmrg
948788de56ccSmrg	case $host in
948888de56ccSmrg	*-*-rhapsody* | *-*-darwin1.[012])
948988de56ccSmrg	  # On Rhapsody replace the C library with the System framework
9490e9fcaa8aSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
949188de56ccSmrg	  ;;
949288de56ccSmrg	esac
949388de56ccSmrg
9494862bcd1aSmrg	if test yes = "$droppeddeps"; then
9495862bcd1aSmrg	  if test yes = "$module"; then
9496e9fcaa8aSmrg	    echo
9497e9fcaa8aSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
949888de56ccSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
9499e9fcaa8aSmrg	    echo "*** a static module, that should work as long as the dlopening"
9500e9fcaa8aSmrg	    echo "*** application is linked with the -dlopen flag."
950188de56ccSmrg	    if test -z "$global_symbol_pipe"; then
9502e9fcaa8aSmrg	      echo
9503e9fcaa8aSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
9504862bcd1aSmrg	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9505e9fcaa8aSmrg	      echo "*** not find such a program.  So, this module is probably useless."
9506862bcd1aSmrg	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
950788de56ccSmrg	    fi
9508862bcd1aSmrg	    if test no = "$build_old_libs"; then
9509862bcd1aSmrg	      oldlibs=$output_objdir/$libname.$libext
951088de56ccSmrg	      build_libtool_libs=module
951188de56ccSmrg	      build_old_libs=yes
951288de56ccSmrg	    else
951388de56ccSmrg	      build_libtool_libs=no
951488de56ccSmrg	    fi
951588de56ccSmrg	  else
9516e9fcaa8aSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
9517e9fcaa8aSmrg	    echo "*** automatically added whenever a program is linked with this library"
9518e9fcaa8aSmrg	    echo "*** or is declared to -dlopen it."
951988de56ccSmrg
9520862bcd1aSmrg	    if test no = "$allow_undefined"; then
9521e9fcaa8aSmrg	      echo
9522e9fcaa8aSmrg	      echo "*** Since this library must not contain undefined symbols,"
9523e9fcaa8aSmrg	      echo "*** because either the platform does not support them or"
9524e9fcaa8aSmrg	      echo "*** it was explicitly requested with -no-undefined,"
9525e9fcaa8aSmrg	      echo "*** libtool will only create a static version of it."
9526862bcd1aSmrg	      if test no = "$build_old_libs"; then
9527862bcd1aSmrg		oldlibs=$output_objdir/$libname.$libext
952888de56ccSmrg		build_libtool_libs=module
952988de56ccSmrg		build_old_libs=yes
953088de56ccSmrg	      else
953188de56ccSmrg		build_libtool_libs=no
953288de56ccSmrg	      fi
953388de56ccSmrg	    fi
953488de56ccSmrg	  fi
953588de56ccSmrg	fi
953688de56ccSmrg	# Done checking deplibs!
953788de56ccSmrg	deplibs=$newdeplibs
953888de56ccSmrg      fi
953988de56ccSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
954088de56ccSmrg      case $host in
954188de56ccSmrg	*-*-darwin*)
9542e9fcaa8aSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9543e9fcaa8aSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9544e9fcaa8aSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
954588de56ccSmrg	  ;;
954688de56ccSmrg      esac
954788de56ccSmrg
954888de56ccSmrg      # move library search paths that coincide with paths to not yet
954988de56ccSmrg      # installed libraries to the beginning of the library search list
955088de56ccSmrg      new_libs=
955188de56ccSmrg      for path in $notinst_path; do
955288de56ccSmrg	case " $new_libs " in
955388de56ccSmrg	*" -L$path/$objdir "*) ;;
955488de56ccSmrg	*)
955588de56ccSmrg	  case " $deplibs " in
955688de56ccSmrg	  *" -L$path/$objdir "*)
9557e9fcaa8aSmrg	    func_append new_libs " -L$path/$objdir" ;;
955888de56ccSmrg	  esac
955988de56ccSmrg	  ;;
956088de56ccSmrg	esac
956188de56ccSmrg      done
956288de56ccSmrg      for deplib in $deplibs; do
956388de56ccSmrg	case $deplib in
956488de56ccSmrg	-L*)
956588de56ccSmrg	  case " $new_libs " in
956688de56ccSmrg	  *" $deplib "*) ;;
9567e9fcaa8aSmrg	  *) func_append new_libs " $deplib" ;;
956888de56ccSmrg	  esac
956988de56ccSmrg	  ;;
9570e9fcaa8aSmrg	*) func_append new_libs " $deplib" ;;
957188de56ccSmrg	esac
957288de56ccSmrg      done
9573862bcd1aSmrg      deplibs=$new_libs
957488de56ccSmrg
957588de56ccSmrg      # All the library-specific variables (install_libdir is set above).
957688de56ccSmrg      library_names=
957788de56ccSmrg      old_library=
957888de56ccSmrg      dlname=
957988de56ccSmrg
958088de56ccSmrg      # Test again, we may have decided not to build it any more
9581862bcd1aSmrg      if test yes = "$build_libtool_libs"; then
9582862bcd1aSmrg	# Remove $wl instances when linking with ld.
9583eb411b4bSmrg	# FIXME: should test the right _cmds variable.
9584eb411b4bSmrg	case $archive_cmds in
9585eb411b4bSmrg	  *\$LD\ *) wl= ;;
9586eb411b4bSmrg        esac
9587862bcd1aSmrg	if test yes = "$hardcode_into_libs"; then
958888de56ccSmrg	  # Hardcode the library paths
958988de56ccSmrg	  hardcode_libdirs=
959088de56ccSmrg	  dep_rpath=
9591862bcd1aSmrg	  rpath=$finalize_rpath
9592862bcd1aSmrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
959388de56ccSmrg	  for libdir in $rpath; do
959488de56ccSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
959588de56ccSmrg	      if test -n "$hardcode_libdir_separator"; then
9596e9fcaa8aSmrg		func_replace_sysroot "$libdir"
9597e9fcaa8aSmrg		libdir=$func_replace_sysroot_result
959888de56ccSmrg		if test -z "$hardcode_libdirs"; then
9599862bcd1aSmrg		  hardcode_libdirs=$libdir
960088de56ccSmrg		else
960188de56ccSmrg		  # Just accumulate the unique libdirs.
960288de56ccSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
960388de56ccSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
960488de56ccSmrg		    ;;
960588de56ccSmrg		  *)
9606e9fcaa8aSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
960788de56ccSmrg		    ;;
960888de56ccSmrg		  esac
960988de56ccSmrg		fi
961088de56ccSmrg	      else
961188de56ccSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
9612e9fcaa8aSmrg		func_append dep_rpath " $flag"
961388de56ccSmrg	      fi
961488de56ccSmrg	    elif test -n "$runpath_var"; then
961588de56ccSmrg	      case "$perm_rpath " in
961688de56ccSmrg	      *" $libdir "*) ;;
9617eb411b4bSmrg	      *) func_append perm_rpath " $libdir" ;;
961888de56ccSmrg	      esac
961988de56ccSmrg	    fi
962088de56ccSmrg	  done
962188de56ccSmrg	  # Substitute the hardcoded libdirs into the rpath.
962288de56ccSmrg	  if test -n "$hardcode_libdir_separator" &&
962388de56ccSmrg	     test -n "$hardcode_libdirs"; then
9624862bcd1aSmrg	    libdir=$hardcode_libdirs
9625eb411b4bSmrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
962688de56ccSmrg	  fi
962788de56ccSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
962888de56ccSmrg	    # We should set the runpath_var.
962988de56ccSmrg	    rpath=
963088de56ccSmrg	    for dir in $perm_rpath; do
9631e9fcaa8aSmrg	      func_append rpath "$dir:"
963288de56ccSmrg	    done
963388de56ccSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
963488de56ccSmrg	  fi
963588de56ccSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
963688de56ccSmrg	fi
96371ab64890Smrg
9638862bcd1aSmrg	shlibpath=$finalize_shlibpath
9639862bcd1aSmrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
964088de56ccSmrg	if test -n "$shlibpath"; then
964188de56ccSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
964288de56ccSmrg	fi
96431ab64890Smrg
964488de56ccSmrg	# Get the real and link names of the library.
964588de56ccSmrg	eval shared_ext=\"$shrext_cmds\"
964688de56ccSmrg	eval library_names=\"$library_names_spec\"
964788de56ccSmrg	set dummy $library_names
964888de56ccSmrg	shift
9649862bcd1aSmrg	realname=$1
965088de56ccSmrg	shift
96511ab64890Smrg
965288de56ccSmrg	if test -n "$soname_spec"; then
965388de56ccSmrg	  eval soname=\"$soname_spec\"
965488de56ccSmrg	else
9655862bcd1aSmrg	  soname=$realname
965688de56ccSmrg	fi
965788de56ccSmrg	if test -z "$dlname"; then
965888de56ccSmrg	  dlname=$soname
965988de56ccSmrg	fi
96601ab64890Smrg
9661862bcd1aSmrg	lib=$output_objdir/$realname
966288de56ccSmrg	linknames=
966388de56ccSmrg	for link
966488de56ccSmrg	do
9665e9fcaa8aSmrg	  func_append linknames " $link"
966688de56ccSmrg	done
96671ab64890Smrg
966888de56ccSmrg	# Use standard objects if they are pic
9669e9fcaa8aSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
967088de56ccSmrg	test "X$libobjs" = "X " && libobjs=
96711ab64890Smrg
967288de56ccSmrg	delfiles=
967388de56ccSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
967488de56ccSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
9675862bcd1aSmrg	  export_symbols=$output_objdir/$libname.uexp
9676e9fcaa8aSmrg	  func_append delfiles " $export_symbols"
967788de56ccSmrg	fi
96781ab64890Smrg
967988de56ccSmrg	orig_export_symbols=
968088de56ccSmrg	case $host_os in
968188de56ccSmrg	cygwin* | mingw* | cegcc*)
968288de56ccSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
968388de56ccSmrg	    # exporting using user supplied symfile
9684862bcd1aSmrg	    func_dll_def_p "$export_symbols" || {
968588de56ccSmrg	      # and it's NOT already a .def file. Must figure out
968688de56ccSmrg	      # which of the given symbols are data symbols and tag
968788de56ccSmrg	      # them as such. So, trigger use of export_symbols_cmds.
968888de56ccSmrg	      # export_symbols gets reassigned inside the "prepare
968988de56ccSmrg	      # the list of exported symbols" if statement, so the
969088de56ccSmrg	      # include_expsyms logic still works.
9691862bcd1aSmrg	      orig_export_symbols=$export_symbols
969288de56ccSmrg	      export_symbols=
969388de56ccSmrg	      always_export_symbols=yes
9694862bcd1aSmrg	    }
969588de56ccSmrg	  fi
969688de56ccSmrg	  ;;
969788de56ccSmrg	esac
96981ab64890Smrg
969988de56ccSmrg	# Prepare the list of exported symbols
970088de56ccSmrg	if test -z "$export_symbols"; then
9701862bcd1aSmrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
9702862bcd1aSmrg	    func_verbose "generating symbol list for '$libname.la'"
9703862bcd1aSmrg	    export_symbols=$output_objdir/$libname.exp
970488de56ccSmrg	    $opt_dry_run || $RM $export_symbols
970588de56ccSmrg	    cmds=$export_symbols_cmds
9706862bcd1aSmrg	    save_ifs=$IFS; IFS='~'
9707e9fcaa8aSmrg	    for cmd1 in $cmds; do
9708862bcd1aSmrg	      IFS=$save_ifs
9709e9fcaa8aSmrg	      # Take the normal branch if the nm_file_list_spec branch
9710e9fcaa8aSmrg	      # doesn't work or if tool conversion is not needed.
9711e9fcaa8aSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
9712e9fcaa8aSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9713e9fcaa8aSmrg		  try_normal_branch=yes
9714e9fcaa8aSmrg		  eval cmd=\"$cmd1\"
9715e9fcaa8aSmrg		  func_len " $cmd"
9716e9fcaa8aSmrg		  len=$func_len_result
9717e9fcaa8aSmrg		  ;;
9718e9fcaa8aSmrg		*)
9719e9fcaa8aSmrg		  try_normal_branch=no
9720e9fcaa8aSmrg		  ;;
9721e9fcaa8aSmrg	      esac
9722862bcd1aSmrg	      if test yes = "$try_normal_branch" \
9723e9fcaa8aSmrg		 && { test "$len" -lt "$max_cmd_len" \
9724e9fcaa8aSmrg		      || test "$max_cmd_len" -le -1; }
9725e9fcaa8aSmrg	      then
9726e9fcaa8aSmrg		func_show_eval "$cmd" 'exit $?'
9727e9fcaa8aSmrg		skipped_export=false
9728e9fcaa8aSmrg	      elif test -n "$nm_file_list_spec"; then
9729e9fcaa8aSmrg		func_basename "$output"
9730e9fcaa8aSmrg		output_la=$func_basename_result
9731e9fcaa8aSmrg		save_libobjs=$libobjs
9732e9fcaa8aSmrg		save_output=$output
9733862bcd1aSmrg		output=$output_objdir/$output_la.nm
9734e9fcaa8aSmrg		func_to_tool_file "$output"
9735e9fcaa8aSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
9736e9fcaa8aSmrg		func_append delfiles " $output"
9737e9fcaa8aSmrg		func_verbose "creating $NM input file list: $output"
9738e9fcaa8aSmrg		for obj in $save_libobjs; do
9739e9fcaa8aSmrg		  func_to_tool_file "$obj"
9740e9fcaa8aSmrg		  $ECHO "$func_to_tool_file_result"
9741e9fcaa8aSmrg		done > "$output"
9742e9fcaa8aSmrg		eval cmd=\"$cmd1\"
974388de56ccSmrg		func_show_eval "$cmd" 'exit $?'
9744e9fcaa8aSmrg		output=$save_output
9745e9fcaa8aSmrg		libobjs=$save_libobjs
974688de56ccSmrg		skipped_export=false
974788de56ccSmrg	      else
974888de56ccSmrg		# The command line is too long to execute in one step.
974988de56ccSmrg		func_verbose "using reloadable object file for export list..."
975088de56ccSmrg		skipped_export=:
975188de56ccSmrg		# Break out early, otherwise skipped_export may be
975288de56ccSmrg		# set to false by a later but shorter cmd.
975388de56ccSmrg		break
975488de56ccSmrg	      fi
975588de56ccSmrg	    done
9756862bcd1aSmrg	    IFS=$save_ifs
9757862bcd1aSmrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
975888de56ccSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
975988de56ccSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
976088de56ccSmrg	    fi
976188de56ccSmrg	  fi
97621ab64890Smrg	fi
97631ab64890Smrg
976488de56ccSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9765862bcd1aSmrg	  tmp_export_symbols=$export_symbols
9766862bcd1aSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9767e9fcaa8aSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
976888de56ccSmrg	fi
97691ab64890Smrg
9770862bcd1aSmrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
977188de56ccSmrg	  # The given exports_symbols file has to be filtered, so filter it.
9772862bcd1aSmrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
977388de56ccSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
9774862bcd1aSmrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
977588de56ccSmrg	  # though. Also, the filter scales superlinearly with the number of
977688de56ccSmrg	  # global variables. join(1) would be nice here, but unfortunately
977788de56ccSmrg	  # isn't a blessed tool.
977888de56ccSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9779e9fcaa8aSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
978088de56ccSmrg	  export_symbols=$output_objdir/$libname.def
978188de56ccSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
978288de56ccSmrg	fi
97831ab64890Smrg
978488de56ccSmrg	tmp_deplibs=
978588de56ccSmrg	for test_deplib in $deplibs; do
978688de56ccSmrg	  case " $convenience " in
978788de56ccSmrg	  *" $test_deplib "*) ;;
978888de56ccSmrg	  *)
9789e9fcaa8aSmrg	    func_append tmp_deplibs " $test_deplib"
979088de56ccSmrg	    ;;
979188de56ccSmrg	  esac
979288de56ccSmrg	done
9793862bcd1aSmrg	deplibs=$tmp_deplibs
97941ab64890Smrg
979588de56ccSmrg	if test -n "$convenience"; then
979688de56ccSmrg	  if test -n "$whole_archive_flag_spec" &&
9797862bcd1aSmrg	    test yes = "$compiler_needs_object" &&
979888de56ccSmrg	    test -z "$libobjs"; then
979988de56ccSmrg	    # extract the archives, so we have objects to list.
980088de56ccSmrg	    # TODO: could optimize this to just extract one archive.
980188de56ccSmrg	    whole_archive_flag_spec=
980288de56ccSmrg	  fi
980388de56ccSmrg	  if test -n "$whole_archive_flag_spec"; then
980488de56ccSmrg	    save_libobjs=$libobjs
980588de56ccSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
980688de56ccSmrg	    test "X$libobjs" = "X " && libobjs=
980788de56ccSmrg	  else
9808862bcd1aSmrg	    gentop=$output_objdir/${outputname}x
9809e9fcaa8aSmrg	    func_append generated " $gentop"
98101ab64890Smrg
981188de56ccSmrg	    func_extract_archives $gentop $convenience
9812e9fcaa8aSmrg	    func_append libobjs " $func_extract_archives_result"
981388de56ccSmrg	    test "X$libobjs" = "X " && libobjs=
981488de56ccSmrg	  fi
9815b4ee4795Smrg	fi
98161ab64890Smrg
9817862bcd1aSmrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
981888de56ccSmrg	  eval flag=\"$thread_safe_flag_spec\"
9819e9fcaa8aSmrg	  func_append linker_flags " $flag"
9820b4ee4795Smrg	fi
98212e9c7c8cSmrg
982288de56ccSmrg	# Make a backup of the uninstalled library when relinking
9823862bcd1aSmrg	if test relink = "$opt_mode"; then
982488de56ccSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
982588de56ccSmrg	fi
98261ab64890Smrg
982788de56ccSmrg	# Do each of the archive commands.
9828862bcd1aSmrg	if test yes = "$module" && test -n "$module_cmds"; then
982988de56ccSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
983088de56ccSmrg	    eval test_cmds=\"$module_expsym_cmds\"
983188de56ccSmrg	    cmds=$module_expsym_cmds
983288de56ccSmrg	  else
983388de56ccSmrg	    eval test_cmds=\"$module_cmds\"
983488de56ccSmrg	    cmds=$module_cmds
983588de56ccSmrg	  fi
9836b4ee4795Smrg	else
983788de56ccSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
983888de56ccSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
983988de56ccSmrg	    cmds=$archive_expsym_cmds
984088de56ccSmrg	  else
984188de56ccSmrg	    eval test_cmds=\"$archive_cmds\"
984288de56ccSmrg	    cmds=$archive_cmds
984388de56ccSmrg	  fi
9844b4ee4795Smrg	fi
98451ab64890Smrg
9846862bcd1aSmrg	if test : != "$skipped_export" &&
984788de56ccSmrg	   func_len " $test_cmds" &&
984888de56ccSmrg	   len=$func_len_result &&
984988de56ccSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
985088de56ccSmrg	  :
985188de56ccSmrg	else
985288de56ccSmrg	  # The command line is too long to link in one step, link piecewise
985388de56ccSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
985488de56ccSmrg	  # script.
98551ab64890Smrg
985688de56ccSmrg	  # Save the value of $output and $libobjs because we want to
985788de56ccSmrg	  # use them later.  If we have whole_archive_flag_spec, we
985888de56ccSmrg	  # want to use save_libobjs as it was before
985988de56ccSmrg	  # whole_archive_flag_spec was expanded, because we can't
986088de56ccSmrg	  # assume the linker understands whole_archive_flag_spec.
986188de56ccSmrg	  # This may have to be revisited, in case too many
986288de56ccSmrg	  # convenience libraries get linked in and end up exceeding
986388de56ccSmrg	  # the spec.
986488de56ccSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
986588de56ccSmrg	    save_libobjs=$libobjs
986688de56ccSmrg	  fi
986788de56ccSmrg	  save_output=$output
9868e9fcaa8aSmrg	  func_basename "$output"
9869e9fcaa8aSmrg	  output_la=$func_basename_result
98701ab64890Smrg
987188de56ccSmrg	  # Clear the reloadable object creation command queue and
987288de56ccSmrg	  # initialize k to one.
987388de56ccSmrg	  test_cmds=
987488de56ccSmrg	  concat_cmds=
987588de56ccSmrg	  objlist=
987688de56ccSmrg	  last_robj=
987788de56ccSmrg	  k=1
987888de56ccSmrg
9879862bcd1aSmrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
9880862bcd1aSmrg	    output=$output_objdir/$output_la.lnkscript
988188de56ccSmrg	    func_verbose "creating GNU ld script: $output"
9882e9fcaa8aSmrg	    echo 'INPUT (' > $output
988388de56ccSmrg	    for obj in $save_libobjs
9884b4ee4795Smrg	    do
9885e9fcaa8aSmrg	      func_to_tool_file "$obj"
9886e9fcaa8aSmrg	      $ECHO "$func_to_tool_file_result" >> $output
988788de56ccSmrg	    done
9888e9fcaa8aSmrg	    echo ')' >> $output
9889e9fcaa8aSmrg	    func_append delfiles " $output"
9890e9fcaa8aSmrg	    func_to_tool_file "$output"
9891e9fcaa8aSmrg	    output=$func_to_tool_file_result
9892862bcd1aSmrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
9893862bcd1aSmrg	    output=$output_objdir/$output_la.lnk
989488de56ccSmrg	    func_verbose "creating linker input file list: $output"
989588de56ccSmrg	    : > $output
989688de56ccSmrg	    set x $save_libobjs
989788de56ccSmrg	    shift
989888de56ccSmrg	    firstobj=
9899862bcd1aSmrg	    if test yes = "$compiler_needs_object"; then
990088de56ccSmrg	      firstobj="$1 "
990188de56ccSmrg	      shift
990288de56ccSmrg	    fi
990388de56ccSmrg	    for obj
990488de56ccSmrg	    do
9905e9fcaa8aSmrg	      func_to_tool_file "$obj"
9906e9fcaa8aSmrg	      $ECHO "$func_to_tool_file_result" >> $output
990788de56ccSmrg	    done
9908e9fcaa8aSmrg	    func_append delfiles " $output"
9909e9fcaa8aSmrg	    func_to_tool_file "$output"
9910e9fcaa8aSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
991188de56ccSmrg	  else
991288de56ccSmrg	    if test -n "$save_libobjs"; then
991388de56ccSmrg	      func_verbose "creating reloadable object files..."
9914862bcd1aSmrg	      output=$output_objdir/$output_la-$k.$objext
991588de56ccSmrg	      eval test_cmds=\"$reload_cmds\"
991688de56ccSmrg	      func_len " $test_cmds"
991788de56ccSmrg	      len0=$func_len_result
991888de56ccSmrg	      len=$len0
991988de56ccSmrg
992088de56ccSmrg	      # Loop over the list of objects to be linked.
992188de56ccSmrg	      for obj in $save_libobjs
992288de56ccSmrg	      do
992388de56ccSmrg		func_len " $obj"
992488de56ccSmrg		func_arith $len + $func_len_result
992588de56ccSmrg		len=$func_arith_result
9926862bcd1aSmrg		if test -z "$objlist" ||
992788de56ccSmrg		   test "$len" -lt "$max_cmd_len"; then
992888de56ccSmrg		  func_append objlist " $obj"
992988de56ccSmrg		else
993088de56ccSmrg		  # The command $test_cmds is almost too long, add a
993188de56ccSmrg		  # command to the queue.
9932862bcd1aSmrg		  if test 1 -eq "$k"; then
993388de56ccSmrg		    # The first file doesn't have a previous command to add.
9934e9fcaa8aSmrg		    reload_objs=$objlist
9935e9fcaa8aSmrg		    eval concat_cmds=\"$reload_cmds\"
993688de56ccSmrg		  else
993788de56ccSmrg		    # All subsequent reloadable object files will link in
993888de56ccSmrg		    # the last one created.
9939e9fcaa8aSmrg		    reload_objs="$objlist $last_robj"
9940e9fcaa8aSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
994188de56ccSmrg		  fi
9942862bcd1aSmrg		  last_robj=$output_objdir/$output_la-$k.$objext
994388de56ccSmrg		  func_arith $k + 1
994488de56ccSmrg		  k=$func_arith_result
9945862bcd1aSmrg		  output=$output_objdir/$output_la-$k.$objext
9946e9fcaa8aSmrg		  objlist=" $obj"
994788de56ccSmrg		  func_len " $last_robj"
994888de56ccSmrg		  func_arith $len0 + $func_len_result
994988de56ccSmrg		  len=$func_arith_result
995088de56ccSmrg		fi
995188de56ccSmrg	      done
995288de56ccSmrg	      # Handle the remaining objects by creating one last
995388de56ccSmrg	      # reloadable object file.  All subsequent reloadable object
995488de56ccSmrg	      # files will link in the last one created.
995588de56ccSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9956e9fcaa8aSmrg	      reload_objs="$objlist $last_robj"
9957862bcd1aSmrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
995888de56ccSmrg	      if test -n "$last_robj"; then
9959862bcd1aSmrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
996088de56ccSmrg	      fi
9961e9fcaa8aSmrg	      func_append delfiles " $output"
99621ab64890Smrg
996388de56ccSmrg	    else
996488de56ccSmrg	      output=
996588de56ccSmrg	    fi
99661ab64890Smrg
9967862bcd1aSmrg	    ${skipped_export-false} && {
9968862bcd1aSmrg	      func_verbose "generating symbol list for '$libname.la'"
9969862bcd1aSmrg	      export_symbols=$output_objdir/$libname.exp
997088de56ccSmrg	      $opt_dry_run || $RM $export_symbols
997188de56ccSmrg	      libobjs=$output
997288de56ccSmrg	      # Append the command to create the export file.
997388de56ccSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
997488de56ccSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
997588de56ccSmrg	      if test -n "$last_robj"; then
997688de56ccSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
997788de56ccSmrg	      fi
9978862bcd1aSmrg	    }
99791ab64890Smrg
998088de56ccSmrg	    test -n "$save_libobjs" &&
998188de56ccSmrg	      func_verbose "creating a temporary reloadable object file: $output"
99821ab64890Smrg
998388de56ccSmrg	    # Loop through the commands generated above and execute them.
9984862bcd1aSmrg	    save_ifs=$IFS; IFS='~'
998588de56ccSmrg	    for cmd in $concat_cmds; do
9986862bcd1aSmrg	      IFS=$save_ifs
9987862bcd1aSmrg	      $opt_quiet || {
998888de56ccSmrg		  func_quote_for_expand "$cmd"
998988de56ccSmrg		  eval "func_echo $func_quote_for_expand_result"
999088de56ccSmrg	      }
999188de56ccSmrg	      $opt_dry_run || eval "$cmd" || {
999288de56ccSmrg		lt_exit=$?
999388de56ccSmrg
999488de56ccSmrg		# Restore the uninstalled library and exit
9995862bcd1aSmrg		if test relink = "$opt_mode"; then
999688de56ccSmrg		  ( cd "$output_objdir" && \
999788de56ccSmrg		    $RM "${realname}T" && \
999888de56ccSmrg		    $MV "${realname}U" "$realname" )
999988de56ccSmrg		fi
100001ab64890Smrg
1000188de56ccSmrg		exit $lt_exit
1000288de56ccSmrg	      }
1000388de56ccSmrg	    done
10004862bcd1aSmrg	    IFS=$save_ifs
10005b4ee4795Smrg
1000688de56ccSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
1000788de56ccSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
1000888de56ccSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
100091ab64890Smrg	    fi
100101ab64890Smrg	  fi
100111ab64890Smrg
10012862bcd1aSmrg          ${skipped_export-false} && {
1001388de56ccSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
10014862bcd1aSmrg	      tmp_export_symbols=$export_symbols
10015862bcd1aSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
10016e9fcaa8aSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
1001788de56ccSmrg	    fi
100182e9c7c8cSmrg
1001988de56ccSmrg	    if test -n "$orig_export_symbols"; then
1002088de56ccSmrg	      # The given exports_symbols file has to be filtered, so filter it.
10021862bcd1aSmrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
1002288de56ccSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
10023862bcd1aSmrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
1002488de56ccSmrg	      # though. Also, the filter scales superlinearly with the number of
1002588de56ccSmrg	      # global variables. join(1) would be nice here, but unfortunately
1002688de56ccSmrg	      # isn't a blessed tool.
1002788de56ccSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
10028e9fcaa8aSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
1002988de56ccSmrg	      export_symbols=$output_objdir/$libname.def
1003088de56ccSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
1003188de56ccSmrg	    fi
10032862bcd1aSmrg	  }
100331ab64890Smrg
1003488de56ccSmrg	  libobjs=$output
1003588de56ccSmrg	  # Restore the value of output.
1003688de56ccSmrg	  output=$save_output
100371ab64890Smrg
1003888de56ccSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
1003988de56ccSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
1004088de56ccSmrg	    test "X$libobjs" = "X " && libobjs=
1004188de56ccSmrg	  fi
1004288de56ccSmrg	  # Expand the library linking commands again to reset the
1004388de56ccSmrg	  # value of $libobjs for piecewise linking.
100441ab64890Smrg
1004588de56ccSmrg	  # Do each of the archive commands.
10046862bcd1aSmrg	  if test yes = "$module" && test -n "$module_cmds"; then
1004788de56ccSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
1004888de56ccSmrg	      cmds=$module_expsym_cmds
1004988de56ccSmrg	    else
1005088de56ccSmrg	      cmds=$module_cmds
10051b4ee4795Smrg	    fi
10052b4ee4795Smrg	  else
1005388de56ccSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
1005488de56ccSmrg	      cmds=$archive_expsym_cmds
1005588de56ccSmrg	    else
1005688de56ccSmrg	      cmds=$archive_cmds
1005788de56ccSmrg	    fi
10058b4ee4795Smrg	  fi
1005988de56ccSmrg	fi
100601ab64890Smrg
1006188de56ccSmrg	if test -n "$delfiles"; then
1006288de56ccSmrg	  # Append the command to remove temporary files to $cmds.
1006388de56ccSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
1006488de56ccSmrg	fi
100651ab64890Smrg
1006688de56ccSmrg	# Add any objects from preloaded convenience libraries
1006788de56ccSmrg	if test -n "$dlprefiles"; then
10068862bcd1aSmrg	  gentop=$output_objdir/${outputname}x
10069e9fcaa8aSmrg	  func_append generated " $gentop"
100701ab64890Smrg
1007188de56ccSmrg	  func_extract_archives $gentop $dlprefiles
10072e9fcaa8aSmrg	  func_append libobjs " $func_extract_archives_result"
1007388de56ccSmrg	  test "X$libobjs" = "X " && libobjs=
1007488de56ccSmrg	fi
100751ab64890Smrg
10076862bcd1aSmrg	save_ifs=$IFS; IFS='~'
1007788de56ccSmrg	for cmd in $cmds; do
10078862bcd1aSmrg	  IFS=$sp$nl
1007988de56ccSmrg	  eval cmd=\"$cmd\"
10080862bcd1aSmrg	  IFS=$save_ifs
10081862bcd1aSmrg	  $opt_quiet || {
1008288de56ccSmrg	    func_quote_for_expand "$cmd"
1008388de56ccSmrg	    eval "func_echo $func_quote_for_expand_result"
1008488de56ccSmrg	  }
1008588de56ccSmrg	  $opt_dry_run || eval "$cmd" || {
1008688de56ccSmrg	    lt_exit=$?
100872e9c7c8cSmrg
1008888de56ccSmrg	    # Restore the uninstalled library and exit
10089862bcd1aSmrg	    if test relink = "$opt_mode"; then
1009088de56ccSmrg	      ( cd "$output_objdir" && \
1009188de56ccSmrg	        $RM "${realname}T" && \
1009288de56ccSmrg		$MV "${realname}U" "$realname" )
1009388de56ccSmrg	    fi
100942e9c7c8cSmrg
1009588de56ccSmrg	    exit $lt_exit
1009688de56ccSmrg	  }
1009788de56ccSmrg	done
10098862bcd1aSmrg	IFS=$save_ifs
100992e9c7c8cSmrg
1010088de56ccSmrg	# Restore the uninstalled library and exit
10101862bcd1aSmrg	if test relink = "$opt_mode"; then
1010288de56ccSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
101032e9c7c8cSmrg
1010488de56ccSmrg	  if test -n "$convenience"; then
1010588de56ccSmrg	    if test -z "$whole_archive_flag_spec"; then
1010688de56ccSmrg	      func_show_eval '${RM}r "$gentop"'
1010788de56ccSmrg	    fi
1010888de56ccSmrg	  fi
101092e9c7c8cSmrg
1011088de56ccSmrg	  exit $EXIT_SUCCESS
1011188de56ccSmrg	fi
1011288de56ccSmrg
1011388de56ccSmrg	# Create links to the real library.
1011488de56ccSmrg	for linkname in $linknames; do
1011588de56ccSmrg	  if test "$realname" != "$linkname"; then
1011688de56ccSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
10117b4ee4795Smrg	  fi
10118b4ee4795Smrg	done
101192e9c7c8cSmrg
1012088de56ccSmrg	# If -module or -export-dynamic was specified, set the dlname.
10121862bcd1aSmrg	if test yes = "$module" || test yes = "$export_dynamic"; then
1012288de56ccSmrg	  # On all known operating systems, these are identical.
10123862bcd1aSmrg	  dlname=$soname
1012488de56ccSmrg	fi
1012588de56ccSmrg      fi
101261ab64890Smrg      ;;
101271ab64890Smrg
1012888de56ccSmrg    obj)
10129862bcd1aSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
10130862bcd1aSmrg	func_warning "'-dlopen' is ignored for objects"
1013188de56ccSmrg      fi
10132b4ee4795Smrg
1013388de56ccSmrg      case " $deplibs" in
1013488de56ccSmrg      *\ -l* | *\ -L*)
10135862bcd1aSmrg	func_warning "'-l' and '-L' are ignored for objects" ;;
101362e9c7c8cSmrg      esac
101371ab64890Smrg
1013888de56ccSmrg      test -n "$rpath" && \
10139862bcd1aSmrg	func_warning "'-rpath' is ignored for objects"
1014088de56ccSmrg
1014188de56ccSmrg      test -n "$xrpath" && \
10142862bcd1aSmrg	func_warning "'-R' is ignored for objects"
101431ab64890Smrg
1014488de56ccSmrg      test -n "$vinfo" && \
10145862bcd1aSmrg	func_warning "'-version-info' is ignored for objects"
101462e9c7c8cSmrg
1014788de56ccSmrg      test -n "$release" && \
10148862bcd1aSmrg	func_warning "'-release' is ignored for objects"
1014988de56ccSmrg
1015088de56ccSmrg      case $output in
1015188de56ccSmrg      *.lo)
1015288de56ccSmrg	test -n "$objs$old_deplibs" && \
10153862bcd1aSmrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
1015488de56ccSmrg
1015588de56ccSmrg	libobj=$output
1015688de56ccSmrg	func_lo2o "$libobj"
1015788de56ccSmrg	obj=$func_lo2o_result
10158b4ee4795Smrg	;;
10159b4ee4795Smrg      *)
1016088de56ccSmrg	libobj=
10161862bcd1aSmrg	obj=$output
101621ab64890Smrg	;;
101632e9c7c8cSmrg      esac
101641ab64890Smrg
1016588de56ccSmrg      # Delete the old objects.
1016688de56ccSmrg      $opt_dry_run || $RM $obj $libobj
101671ab64890Smrg
1016888de56ccSmrg      # Objects from convenience libraries.  This assumes
1016988de56ccSmrg      # single-version convenience libraries.  Whenever we create
1017088de56ccSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
1017188de56ccSmrg      # the extraction.
1017288de56ccSmrg      reload_conv_objs=
1017388de56ccSmrg      gentop=
10174862bcd1aSmrg      # if reload_cmds runs $LD directly, get rid of -Wl from
10175862bcd1aSmrg      # whole_archive_flag_spec and hope we can get by with turning comma
10176862bcd1aSmrg      # into space.
10177862bcd1aSmrg      case $reload_cmds in
10178862bcd1aSmrg        *\$LD[\ \$]*) wl= ;;
10179862bcd1aSmrg      esac
1018088de56ccSmrg      if test -n "$convenience"; then
1018188de56ccSmrg	if test -n "$whole_archive_flag_spec"; then
1018288de56ccSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
10183862bcd1aSmrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
10184862bcd1aSmrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
1018588de56ccSmrg	else
10186862bcd1aSmrg	  gentop=$output_objdir/${obj}x
10187e9fcaa8aSmrg	  func_append generated " $gentop"
10188b4ee4795Smrg
1018988de56ccSmrg	  func_extract_archives $gentop $convenience
1019088de56ccSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
1019188de56ccSmrg	fi
10192b4ee4795Smrg      fi
10193b4ee4795Smrg
10194e9fcaa8aSmrg      # If we're not building shared, we need to use non_pic_objs
10195862bcd1aSmrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10196e9fcaa8aSmrg
1019788de56ccSmrg      # Create the old-style object.
10198862bcd1aSmrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10199b4ee4795Smrg
10200862bcd1aSmrg      output=$obj
1020188de56ccSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
10202b4ee4795Smrg
1020388de56ccSmrg      # Exit if we aren't doing a library object file.
1020488de56ccSmrg      if test -z "$libobj"; then
1020588de56ccSmrg	if test -n "$gentop"; then
1020688de56ccSmrg	  func_show_eval '${RM}r "$gentop"'
1020788de56ccSmrg	fi
1020888de56ccSmrg
1020988de56ccSmrg	exit $EXIT_SUCCESS
10210b4ee4795Smrg      fi
1021188de56ccSmrg
10212862bcd1aSmrg      test yes = "$build_libtool_libs" || {
1021388de56ccSmrg	if test -n "$gentop"; then
1021488de56ccSmrg	  func_show_eval '${RM}r "$gentop"'
1021588de56ccSmrg	fi
1021688de56ccSmrg
1021788de56ccSmrg	# Create an invalid libtool object if no PIC, so that we don't
1021888de56ccSmrg	# accidentally link it into a program.
1021988de56ccSmrg	# $show "echo timestamp > $libobj"
1022088de56ccSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
1022188de56ccSmrg	exit $EXIT_SUCCESS
10222862bcd1aSmrg      }
1022388de56ccSmrg
10224862bcd1aSmrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
1022588de56ccSmrg	# Only do commands if we really have different PIC objects.
1022688de56ccSmrg	reload_objs="$libobjs $reload_conv_objs"
10227862bcd1aSmrg	output=$libobj
1022888de56ccSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
1022988de56ccSmrg      fi
1023088de56ccSmrg
1023188de56ccSmrg      if test -n "$gentop"; then
1023288de56ccSmrg	func_show_eval '${RM}r "$gentop"'
1023388de56ccSmrg      fi
1023488de56ccSmrg
1023588de56ccSmrg      exit $EXIT_SUCCESS
10236b4ee4795Smrg      ;;
102371ab64890Smrg
1023888de56ccSmrg    prog)
1023988de56ccSmrg      case $host in
1024088de56ccSmrg	*cygwin*) func_stripname '' '.exe' "$output"
1024188de56ccSmrg	          output=$func_stripname_result.exe;;
1024288de56ccSmrg      esac
1024388de56ccSmrg      test -n "$vinfo" && \
10244862bcd1aSmrg	func_warning "'-version-info' is ignored for programs"
102451ab64890Smrg
1024688de56ccSmrg      test -n "$release" && \
10247862bcd1aSmrg	func_warning "'-release' is ignored for programs"
102481ab64890Smrg
10249862bcd1aSmrg      $preload \
10250862bcd1aSmrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
10251862bcd1aSmrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
1025288de56ccSmrg
1025388de56ccSmrg      case $host in
1025488de56ccSmrg      *-*-rhapsody* | *-*-darwin1.[012])
1025588de56ccSmrg	# On Rhapsody replace the C library is the System framework
10256e9fcaa8aSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10257e9fcaa8aSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10258b4ee4795Smrg	;;
1025988de56ccSmrg      esac
10260b4ee4795Smrg
1026188de56ccSmrg      case $host in
1026288de56ccSmrg      *-*-darwin*)
1026388de56ccSmrg	# Don't allow lazy linking, it breaks C++ global constructors
1026488de56ccSmrg	# But is supposedly fixed on 10.4 or later (yay!).
10265862bcd1aSmrg	if test CXX = "$tagname"; then
1026688de56ccSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
1026788de56ccSmrg	    10.[0123])
10268862bcd1aSmrg	      func_append compile_command " $wl-bind_at_load"
10269862bcd1aSmrg	      func_append finalize_command " $wl-bind_at_load"
1027088de56ccSmrg	    ;;
1027188de56ccSmrg	  esac
10272b4ee4795Smrg	fi
1027388de56ccSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
10274e9fcaa8aSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10275e9fcaa8aSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
1027688de56ccSmrg	;;
1027788de56ccSmrg      esac
10278b4ee4795Smrg
10279b4ee4795Smrg
1028088de56ccSmrg      # move library search paths that coincide with paths to not yet
1028188de56ccSmrg      # installed libraries to the beginning of the library search list
1028288de56ccSmrg      new_libs=
1028388de56ccSmrg      for path in $notinst_path; do
1028488de56ccSmrg	case " $new_libs " in
1028588de56ccSmrg	*" -L$path/$objdir "*) ;;
1028688de56ccSmrg	*)
1028788de56ccSmrg	  case " $compile_deplibs " in
1028888de56ccSmrg	  *" -L$path/$objdir "*)
10289e9fcaa8aSmrg	    func_append new_libs " -L$path/$objdir" ;;
102902e9c7c8cSmrg	  esac
1029188de56ccSmrg	  ;;
1029288de56ccSmrg	esac
1029388de56ccSmrg      done
1029488de56ccSmrg      for deplib in $compile_deplibs; do
1029588de56ccSmrg	case $deplib in
1029688de56ccSmrg	-L*)
1029788de56ccSmrg	  case " $new_libs " in
1029888de56ccSmrg	  *" $deplib "*) ;;
10299e9fcaa8aSmrg	  *) func_append new_libs " $deplib" ;;
103002e9c7c8cSmrg	  esac
1030188de56ccSmrg	  ;;
10302e9fcaa8aSmrg	*) func_append new_libs " $deplib" ;;
1030388de56ccSmrg	esac
1030488de56ccSmrg      done
10305862bcd1aSmrg      compile_deplibs=$new_libs
103061ab64890Smrg
10307b4ee4795Smrg
10308e9fcaa8aSmrg      func_append compile_command " $compile_deplibs"
10309e9fcaa8aSmrg      func_append finalize_command " $finalize_deplibs"
10310b4ee4795Smrg
1031188de56ccSmrg      if test -n "$rpath$xrpath"; then
1031288de56ccSmrg	# If the user specified any rpath flags, then add them.
1031388de56ccSmrg	for libdir in $rpath $xrpath; do
1031488de56ccSmrg	  # This is the magic to use -rpath.
1031588de56ccSmrg	  case "$finalize_rpath " in
1031688de56ccSmrg	  *" $libdir "*) ;;
10317e9fcaa8aSmrg	  *) func_append finalize_rpath " $libdir" ;;
1031888de56ccSmrg	  esac
1031988de56ccSmrg	done
1032088de56ccSmrg      fi
10321b4ee4795Smrg
1032288de56ccSmrg      # Now hardcode the library paths
1032388de56ccSmrg      rpath=
1032488de56ccSmrg      hardcode_libdirs=
1032588de56ccSmrg      for libdir in $compile_rpath $finalize_rpath; do
1032688de56ccSmrg	if test -n "$hardcode_libdir_flag_spec"; then
1032788de56ccSmrg	  if test -n "$hardcode_libdir_separator"; then
1032888de56ccSmrg	    if test -z "$hardcode_libdirs"; then
10329862bcd1aSmrg	      hardcode_libdirs=$libdir
1033088de56ccSmrg	    else
1033188de56ccSmrg	      # Just accumulate the unique libdirs.
1033288de56ccSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
1033388de56ccSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
1033488de56ccSmrg		;;
1033588de56ccSmrg	      *)
10336e9fcaa8aSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
1033788de56ccSmrg		;;
1033888de56ccSmrg	      esac
1033988de56ccSmrg	    fi
10340b4ee4795Smrg	  else
1034188de56ccSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10342e9fcaa8aSmrg	    func_append rpath " $flag"
10343b4ee4795Smrg	  fi
1034488de56ccSmrg	elif test -n "$runpath_var"; then
1034588de56ccSmrg	  case "$perm_rpath " in
1034688de56ccSmrg	  *" $libdir "*) ;;
10347e9fcaa8aSmrg	  *) func_append perm_rpath " $libdir" ;;
1034888de56ccSmrg	  esac
1034988de56ccSmrg	fi
1035088de56ccSmrg	case $host in
1035188de56ccSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
10352862bcd1aSmrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
1035388de56ccSmrg	  case :$dllsearchpath: in
1035488de56ccSmrg	  *":$libdir:"*) ;;
1035588de56ccSmrg	  ::) dllsearchpath=$libdir;;
10356e9fcaa8aSmrg	  *) func_append dllsearchpath ":$libdir";;
1035788de56ccSmrg	  esac
1035888de56ccSmrg	  case :$dllsearchpath: in
1035988de56ccSmrg	  *":$testbindir:"*) ;;
1036088de56ccSmrg	  ::) dllsearchpath=$testbindir;;
10361e9fcaa8aSmrg	  *) func_append dllsearchpath ":$testbindir";;
1036288de56ccSmrg	  esac
1036388de56ccSmrg	  ;;
1036488de56ccSmrg	esac
1036588de56ccSmrg      done
1036688de56ccSmrg      # Substitute the hardcoded libdirs into the rpath.
1036788de56ccSmrg      if test -n "$hardcode_libdir_separator" &&
1036888de56ccSmrg	 test -n "$hardcode_libdirs"; then
10369862bcd1aSmrg	libdir=$hardcode_libdirs
1037088de56ccSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
1037188de56ccSmrg      fi
10372862bcd1aSmrg      compile_rpath=$rpath
10373b4ee4795Smrg
1037488de56ccSmrg      rpath=
1037588de56ccSmrg      hardcode_libdirs=
1037688de56ccSmrg      for libdir in $finalize_rpath; do
1037788de56ccSmrg	if test -n "$hardcode_libdir_flag_spec"; then
1037888de56ccSmrg	  if test -n "$hardcode_libdir_separator"; then
1037988de56ccSmrg	    if test -z "$hardcode_libdirs"; then
10380862bcd1aSmrg	      hardcode_libdirs=$libdir
1038188de56ccSmrg	    else
1038288de56ccSmrg	      # Just accumulate the unique libdirs.
1038388de56ccSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
1038488de56ccSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
1038588de56ccSmrg		;;
1038688de56ccSmrg	      *)
10387e9fcaa8aSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
1038888de56ccSmrg		;;
1038988de56ccSmrg	      esac
1039088de56ccSmrg	    fi
103911ab64890Smrg	  else
1039288de56ccSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10393e9fcaa8aSmrg	    func_append rpath " $flag"
103941ab64890Smrg	  fi
1039588de56ccSmrg	elif test -n "$runpath_var"; then
1039688de56ccSmrg	  case "$finalize_perm_rpath " in
1039788de56ccSmrg	  *" $libdir "*) ;;
10398e9fcaa8aSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
1039988de56ccSmrg	  esac
104001ab64890Smrg	fi
1040188de56ccSmrg      done
1040288de56ccSmrg      # Substitute the hardcoded libdirs into the rpath.
1040388de56ccSmrg      if test -n "$hardcode_libdir_separator" &&
1040488de56ccSmrg	 test -n "$hardcode_libdirs"; then
10405862bcd1aSmrg	libdir=$hardcode_libdirs
1040688de56ccSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
1040788de56ccSmrg      fi
10408862bcd1aSmrg      finalize_rpath=$rpath
104091ab64890Smrg
10410862bcd1aSmrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
1041188de56ccSmrg	# Transform all the library objects into standard objects.
10412e9fcaa8aSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10413e9fcaa8aSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
1041488de56ccSmrg      fi
104151ab64890Smrg
10416862bcd1aSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
104171ab64890Smrg
1041888de56ccSmrg      # template prelinking step
1041988de56ccSmrg      if test -n "$prelink_cmds"; then
1042088de56ccSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
1042188de56ccSmrg      fi
104221ab64890Smrg
10423862bcd1aSmrg      wrappers_required=:
1042488de56ccSmrg      case $host in
10425e9fcaa8aSmrg      *cegcc* | *mingw32ce*)
10426e9fcaa8aSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
10427862bcd1aSmrg        wrappers_required=false
10428e9fcaa8aSmrg        ;;
1042988de56ccSmrg      *cygwin* | *mingw* )
10430862bcd1aSmrg        test yes = "$build_libtool_libs" || wrappers_required=false
1043188de56ccSmrg        ;;
1043288de56ccSmrg      *)
10433862bcd1aSmrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
10434862bcd1aSmrg          wrappers_required=false
1043588de56ccSmrg        fi
1043688de56ccSmrg        ;;
1043788de56ccSmrg      esac
10438862bcd1aSmrg      $wrappers_required || {
1043988de56ccSmrg	# Replace the output file specification.
10440e9fcaa8aSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10441862bcd1aSmrg	link_command=$compile_command$compile_rpath
104421ab64890Smrg
1044388de56ccSmrg	# We have no uninstalled library dependencies, so finalize right now.
1044488de56ccSmrg	exit_status=0
1044588de56ccSmrg	func_show_eval "$link_command" 'exit_status=$?'
104461ab64890Smrg
10447e9fcaa8aSmrg	if test -n "$postlink_cmds"; then
10448e9fcaa8aSmrg	  func_to_tool_file "$output"
10449e9fcaa8aSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10450e9fcaa8aSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10451e9fcaa8aSmrg	fi
10452e9fcaa8aSmrg
1045388de56ccSmrg	# Delete the generated files.
10454862bcd1aSmrg	if test -f "$output_objdir/${outputname}S.$objext"; then
10455862bcd1aSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
104561ab64890Smrg	fi
104571ab64890Smrg
1045888de56ccSmrg	exit $exit_status
10459862bcd1aSmrg      }
104601ab64890Smrg
1046188de56ccSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
1046288de56ccSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
1046388de56ccSmrg      fi
1046488de56ccSmrg      if test -n "$finalize_shlibpath"; then
1046588de56ccSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
1046688de56ccSmrg      fi
10467b4ee4795Smrg
1046888de56ccSmrg      compile_var=
1046988de56ccSmrg      finalize_var=
1047088de56ccSmrg      if test -n "$runpath_var"; then
1047188de56ccSmrg	if test -n "$perm_rpath"; then
1047288de56ccSmrg	  # We should set the runpath_var.
1047388de56ccSmrg	  rpath=
1047488de56ccSmrg	  for dir in $perm_rpath; do
10475e9fcaa8aSmrg	    func_append rpath "$dir:"
1047688de56ccSmrg	  done
1047788de56ccSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
104781ab64890Smrg	fi
1047988de56ccSmrg	if test -n "$finalize_perm_rpath"; then
1048088de56ccSmrg	  # We should set the runpath_var.
1048188de56ccSmrg	  rpath=
1048288de56ccSmrg	  for dir in $finalize_perm_rpath; do
10483e9fcaa8aSmrg	    func_append rpath "$dir:"
1048488de56ccSmrg	  done
1048588de56ccSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
104861ab64890Smrg	fi
1048788de56ccSmrg      fi
104881ab64890Smrg
10489862bcd1aSmrg      if test yes = "$no_install"; then
1049088de56ccSmrg	# We don't need to create a wrapper script.
10491862bcd1aSmrg	link_command=$compile_var$compile_command$compile_rpath
1049288de56ccSmrg	# Replace the output file specification.
10493e9fcaa8aSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
1049488de56ccSmrg	# Delete the old output file.
1049588de56ccSmrg	$opt_dry_run || $RM $output
1049688de56ccSmrg	# Link the executable and exit
1049788de56ccSmrg	func_show_eval "$link_command" 'exit $?'
10498e9fcaa8aSmrg
10499e9fcaa8aSmrg	if test -n "$postlink_cmds"; then
10500e9fcaa8aSmrg	  func_to_tool_file "$output"
10501e9fcaa8aSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10502e9fcaa8aSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10503e9fcaa8aSmrg	fi
10504e9fcaa8aSmrg
10505b4ee4795Smrg	exit $EXIT_SUCCESS
1050688de56ccSmrg      fi
105072e9c7c8cSmrg
10508862bcd1aSmrg      case $hardcode_action,$fast_install in
10509862bcd1aSmrg        relink,*)
10510862bcd1aSmrg	  # Fast installation is not supported
10511862bcd1aSmrg	  link_command=$compile_var$compile_command$compile_rpath
10512862bcd1aSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
1051388de56ccSmrg
10514862bcd1aSmrg	  func_warning "this platform does not like uninstalled shared libraries"
10515862bcd1aSmrg	  func_warning "'$output' will be relinked during installation"
10516862bcd1aSmrg	  ;;
10517862bcd1aSmrg        *,yes)
10518862bcd1aSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
10519862bcd1aSmrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
10520862bcd1aSmrg          ;;
10521862bcd1aSmrg	*,no)
10522862bcd1aSmrg	  link_command=$compile_var$compile_command$compile_rpath
10523862bcd1aSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10524862bcd1aSmrg          ;;
10525862bcd1aSmrg	*,needless)
10526862bcd1aSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
10527862bcd1aSmrg	  relink_command=
10528862bcd1aSmrg          ;;
10529862bcd1aSmrg      esac
105301ab64890Smrg
1053188de56ccSmrg      # Replace the output file specification.
10532e9fcaa8aSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
105331ab64890Smrg
1053488de56ccSmrg      # Delete the old output files.
1053588de56ccSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
105361ab64890Smrg
1053788de56ccSmrg      func_show_eval "$link_command" 'exit $?'
10538b4ee4795Smrg
10539e9fcaa8aSmrg      if test -n "$postlink_cmds"; then
10540e9fcaa8aSmrg	func_to_tool_file "$output_objdir/$outputname"
10541e9fcaa8aSmrg	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'`
10542e9fcaa8aSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
10543e9fcaa8aSmrg      fi
10544e9fcaa8aSmrg
1054588de56ccSmrg      # Now create the wrapper script.
1054688de56ccSmrg      func_verbose "creating $output"
10547b4ee4795Smrg
1054888de56ccSmrg      # Quote the relink command for shipping.
1054988de56ccSmrg      if test -n "$relink_command"; then
1055088de56ccSmrg	# Preserve any variables that may affect compiler behavior
1055188de56ccSmrg	for var in $variables_saved_for_relink; do
1055288de56ccSmrg	  if eval test -z \"\${$var+set}\"; then
1055388de56ccSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
1055488de56ccSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
1055588de56ccSmrg	    relink_command="$var=; export $var; $relink_command"
105561ab64890Smrg	  else
1055788de56ccSmrg	    func_quote_for_eval "$var_value"
1055888de56ccSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
105591ab64890Smrg	  fi
1056088de56ccSmrg	done
1056138ae11fcSmrg	func_quote "(cd `pwd`; $relink_command)"
1056238ae11fcSmrg	relink_command=$func_quote_result
1056388de56ccSmrg      fi
1056488de56ccSmrg
1056588de56ccSmrg      # Only actually do things if not in dry run mode.
1056688de56ccSmrg      $opt_dry_run || {
1056788de56ccSmrg	# win32 will think the script is a binary if it has
1056888de56ccSmrg	# a .exe suffix, so we strip it off here.
1056988de56ccSmrg	case $output in
1057088de56ccSmrg	  *.exe) func_stripname '' '.exe' "$output"
1057188de56ccSmrg	         output=$func_stripname_result ;;
1057288de56ccSmrg	esac
1057388de56ccSmrg	# test for cygwin because mv fails w/o .exe extensions
1057488de56ccSmrg	case $host in
1057588de56ccSmrg	  *cygwin*)
1057688de56ccSmrg	    exeext=.exe
1057788de56ccSmrg	    func_stripname '' '.exe' "$outputname"
1057888de56ccSmrg	    outputname=$func_stripname_result ;;
1057988de56ccSmrg	  *) exeext= ;;
105801ab64890Smrg	esac
1058188de56ccSmrg	case $host in
1058288de56ccSmrg	  *cygwin* | *mingw* )
1058388de56ccSmrg	    func_dirname_and_basename "$output" "" "."
1058488de56ccSmrg	    output_name=$func_basename_result
1058588de56ccSmrg	    output_path=$func_dirname_result
10586862bcd1aSmrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
10587862bcd1aSmrg	    cwrapper=$output_path/$output_name.exe
1058888de56ccSmrg	    $RM $cwrappersource $cwrapper
1058988de56ccSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
1059088de56ccSmrg
1059188de56ccSmrg	    func_emit_cwrapperexe_src > $cwrappersource
1059288de56ccSmrg
1059388de56ccSmrg	    # The wrapper executable is built using the $host compiler,
1059488de56ccSmrg	    # because it contains $host paths and files. If cross-
1059588de56ccSmrg	    # compiling, it, like the target executable, must be
1059688de56ccSmrg	    # executed on the $host or under an emulation environment.
1059788de56ccSmrg	    $opt_dry_run || {
1059888de56ccSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
1059988de56ccSmrg	      $STRIP $cwrapper
1060088de56ccSmrg	    }
106011ab64890Smrg
1060288de56ccSmrg	    # Now, create the wrapper script for func_source use:
1060388de56ccSmrg	    func_ltwrapper_scriptname $cwrapper
1060488de56ccSmrg	    $RM $func_ltwrapper_scriptname_result
1060588de56ccSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
1060688de56ccSmrg	    $opt_dry_run || {
1060788de56ccSmrg	      # note: this script will not be executed, so do not chmod.
10608862bcd1aSmrg	      if test "x$build" = "x$host"; then
1060988de56ccSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
1061088de56ccSmrg	      else
1061188de56ccSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
1061288de56ccSmrg	      fi
1061388de56ccSmrg	    }
1061488de56ccSmrg	  ;;
1061588de56ccSmrg	  * )
1061688de56ccSmrg	    $RM $output
1061788de56ccSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
106181ab64890Smrg
1061988de56ccSmrg	    func_emit_wrapper no > $output
1062088de56ccSmrg	    chmod +x $output
1062188de56ccSmrg	  ;;
1062288de56ccSmrg	esac
1062388de56ccSmrg      }
1062488de56ccSmrg      exit $EXIT_SUCCESS
1062588de56ccSmrg      ;;
1062688de56ccSmrg    esac
106271ab64890Smrg
1062888de56ccSmrg    # See if we need to build an old-fashioned archive.
1062988de56ccSmrg    for oldlib in $oldlibs; do
106301ab64890Smrg
10631862bcd1aSmrg      case $build_libtool_libs in
10632862bcd1aSmrg        convenience)
10633862bcd1aSmrg	  oldobjs="$libobjs_save $symfileobj"
10634862bcd1aSmrg	  addlibs=$convenience
1063588de56ccSmrg	  build_libtool_libs=no
10636862bcd1aSmrg	  ;;
10637862bcd1aSmrg	module)
10638862bcd1aSmrg	  oldobjs=$libobjs_save
10639862bcd1aSmrg	  addlibs=$old_convenience
10640862bcd1aSmrg	  build_libtool_libs=no
10641862bcd1aSmrg          ;;
10642862bcd1aSmrg	*)
1064388de56ccSmrg	  oldobjs="$old_deplibs $non_pic_objects"
10644862bcd1aSmrg	  $preload && test -f "$symfileobj" \
10645862bcd1aSmrg	    && func_append oldobjs " $symfileobj"
10646862bcd1aSmrg	  addlibs=$old_convenience
10647862bcd1aSmrg	  ;;
10648862bcd1aSmrg      esac
106491ab64890Smrg
1065088de56ccSmrg      if test -n "$addlibs"; then
10651862bcd1aSmrg	gentop=$output_objdir/${outputname}x
10652e9fcaa8aSmrg	func_append generated " $gentop"
106531ab64890Smrg
1065488de56ccSmrg	func_extract_archives $gentop $addlibs
10655e9fcaa8aSmrg	func_append oldobjs " $func_extract_archives_result"
1065688de56ccSmrg      fi
106571ab64890Smrg
1065888de56ccSmrg      # Do each command in the archive commands.
10659862bcd1aSmrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
1066088de56ccSmrg	cmds=$old_archive_from_new_cmds
1066188de56ccSmrg      else
106621ab64890Smrg
1066388de56ccSmrg	# Add any objects from preloaded convenience libraries
1066488de56ccSmrg	if test -n "$dlprefiles"; then
10665862bcd1aSmrg	  gentop=$output_objdir/${outputname}x
10666e9fcaa8aSmrg	  func_append generated " $gentop"
106671ab64890Smrg
1066888de56ccSmrg	  func_extract_archives $gentop $dlprefiles
10669e9fcaa8aSmrg	  func_append oldobjs " $func_extract_archives_result"
1067088de56ccSmrg	fi
106711ab64890Smrg
1067288de56ccSmrg	# POSIX demands no paths to be encoded in archives.  We have
1067388de56ccSmrg	# to avoid creating archives with duplicate basenames if we
1067488de56ccSmrg	# might have to extract them afterwards, e.g., when creating a
1067588de56ccSmrg	# static archive out of a convenience library, or when linking
1067688de56ccSmrg	# the entirety of a libtool archive into another (currently
1067788de56ccSmrg	# not supported by libtool).
1067888de56ccSmrg	if (for obj in $oldobjs
1067988de56ccSmrg	    do
1068088de56ccSmrg	      func_basename "$obj"
1068188de56ccSmrg	      $ECHO "$func_basename_result"
1068288de56ccSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
1068388de56ccSmrg	  :
1068488de56ccSmrg	else
10685e9fcaa8aSmrg	  echo "copying selected object files to avoid basename conflicts..."
10686862bcd1aSmrg	  gentop=$output_objdir/${outputname}x
10687e9fcaa8aSmrg	  func_append generated " $gentop"
1068888de56ccSmrg	  func_mkdir_p "$gentop"
1068988de56ccSmrg	  save_oldobjs=$oldobjs
1069088de56ccSmrg	  oldobjs=
1069188de56ccSmrg	  counter=1
1069288de56ccSmrg	  for obj in $save_oldobjs
1069388de56ccSmrg	  do
1069488de56ccSmrg	    func_basename "$obj"
10695862bcd1aSmrg	    objbase=$func_basename_result
1069688de56ccSmrg	    case " $oldobjs " in
1069788de56ccSmrg	    " ") oldobjs=$obj ;;
1069888de56ccSmrg	    *[\ /]"$objbase "*)
1069988de56ccSmrg	      while :; do
1070088de56ccSmrg		# Make sure we don't pick an alternate name that also
1070188de56ccSmrg		# overlaps.
1070288de56ccSmrg		newobj=lt$counter-$objbase
1070388de56ccSmrg		func_arith $counter + 1
1070488de56ccSmrg		counter=$func_arith_result
1070588de56ccSmrg		case " $oldobjs " in
1070688de56ccSmrg		*[\ /]"$newobj "*) ;;
1070788de56ccSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
1070888de56ccSmrg		esac
1070988de56ccSmrg	      done
1071088de56ccSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10711e9fcaa8aSmrg	      func_append oldobjs " $gentop/$newobj"
1071288de56ccSmrg	      ;;
10713e9fcaa8aSmrg	    *) func_append oldobjs " $obj" ;;
1071488de56ccSmrg	    esac
107151ab64890Smrg	  done
107162e9c7c8cSmrg	fi
10717eb411b4bSmrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10718eb411b4bSmrg	tool_oldlib=$func_to_tool_file_result
1071988de56ccSmrg	eval cmds=\"$old_archive_cmds\"
10720b4ee4795Smrg
1072188de56ccSmrg	func_len " $cmds"
1072288de56ccSmrg	len=$func_len_result
1072388de56ccSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
1072488de56ccSmrg	  cmds=$old_archive_cmds
10725e9fcaa8aSmrg	elif test -n "$archiver_list_spec"; then
10726e9fcaa8aSmrg	  func_verbose "using command file archive linking..."
10727e9fcaa8aSmrg	  for obj in $oldobjs
10728e9fcaa8aSmrg	  do
10729e9fcaa8aSmrg	    func_to_tool_file "$obj"
10730e9fcaa8aSmrg	    $ECHO "$func_to_tool_file_result"
10731e9fcaa8aSmrg	  done > $output_objdir/$libname.libcmd
10732e9fcaa8aSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
10733e9fcaa8aSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10734e9fcaa8aSmrg	  cmds=$old_archive_cmds
1073588de56ccSmrg	else
1073688de56ccSmrg	  # the command line is too long to link in one step, link in parts
1073788de56ccSmrg	  func_verbose "using piecewise archive linking..."
1073888de56ccSmrg	  save_RANLIB=$RANLIB
1073988de56ccSmrg	  RANLIB=:
1074088de56ccSmrg	  objlist=
1074188de56ccSmrg	  concat_cmds=
1074288de56ccSmrg	  save_oldobjs=$oldobjs
1074388de56ccSmrg	  oldobjs=
1074488de56ccSmrg	  # Is there a better way of finding the last object in the list?
1074588de56ccSmrg	  for obj in $save_oldobjs
1074688de56ccSmrg	  do
1074788de56ccSmrg	    last_oldobj=$obj
1074888de56ccSmrg	  done
1074988de56ccSmrg	  eval test_cmds=\"$old_archive_cmds\"
1075088de56ccSmrg	  func_len " $test_cmds"
1075188de56ccSmrg	  len0=$func_len_result
1075288de56ccSmrg	  len=$len0
1075388de56ccSmrg	  for obj in $save_oldobjs
1075488de56ccSmrg	  do
1075588de56ccSmrg	    func_len " $obj"
1075688de56ccSmrg	    func_arith $len + $func_len_result
1075788de56ccSmrg	    len=$func_arith_result
1075888de56ccSmrg	    func_append objlist " $obj"
1075988de56ccSmrg	    if test "$len" -lt "$max_cmd_len"; then
1076088de56ccSmrg	      :
1076188de56ccSmrg	    else
1076288de56ccSmrg	      # the above command should be used before it gets too long
1076388de56ccSmrg	      oldobjs=$objlist
10764862bcd1aSmrg	      if test "$obj" = "$last_oldobj"; then
1076588de56ccSmrg		RANLIB=$save_RANLIB
1076688de56ccSmrg	      fi
1076788de56ccSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10768862bcd1aSmrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
1076988de56ccSmrg	      objlist=
1077088de56ccSmrg	      len=$len0
1077188de56ccSmrg	    fi
1077288de56ccSmrg	  done
1077388de56ccSmrg	  RANLIB=$save_RANLIB
1077488de56ccSmrg	  oldobjs=$objlist
10775862bcd1aSmrg	  if test -z "$oldobjs"; then
1077688de56ccSmrg	    eval cmds=\"\$concat_cmds\"
1077788de56ccSmrg	  else
1077888de56ccSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
1077988de56ccSmrg	  fi
1078088de56ccSmrg	fi
1078188de56ccSmrg      fi
1078288de56ccSmrg      func_execute_cmds "$cmds" 'exit $?'
107831ab64890Smrg    done
107841ab64890Smrg
1078588de56ccSmrg    test -n "$generated" && \
1078688de56ccSmrg      func_show_eval "${RM}r$generated"
107871ab64890Smrg
1078888de56ccSmrg    # Now create the libtool archive.
1078988de56ccSmrg    case $output in
1079088de56ccSmrg    *.la)
1079188de56ccSmrg      old_library=
10792862bcd1aSmrg      test yes = "$build_old_libs" && old_library=$libname.$libext
1079388de56ccSmrg      func_verbose "creating $output"
107942e9c7c8cSmrg
1079588de56ccSmrg      # Preserve any variables that may affect compiler behavior
1079688de56ccSmrg      for var in $variables_saved_for_relink; do
1079788de56ccSmrg	if eval test -z \"\${$var+set}\"; then
1079888de56ccSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
1079988de56ccSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
1080088de56ccSmrg	  relink_command="$var=; export $var; $relink_command"
10801b4ee4795Smrg	else
1080288de56ccSmrg	  func_quote_for_eval "$var_value"
1080388de56ccSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10804b4ee4795Smrg	fi
1080588de56ccSmrg      done
1080688de56ccSmrg      # Quote the link command for shipping.
10807862bcd1aSmrg      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
1080838ae11fcSmrg      func_quote "$relink_command"
1080938ae11fcSmrg      relink_command=$func_quote_result
10810862bcd1aSmrg      if test yes = "$hardcode_automatic"; then
1081188de56ccSmrg	relink_command=
1081288de56ccSmrg      fi
108131ab64890Smrg
1081488de56ccSmrg      # Only create the output if not a dry run.
1081588de56ccSmrg      $opt_dry_run || {
1081688de56ccSmrg	for installed in no yes; do
10817862bcd1aSmrg	  if test yes = "$installed"; then
1081888de56ccSmrg	    if test -z "$install_libdir"; then
1081988de56ccSmrg	      break
1082088de56ccSmrg	    fi
10821862bcd1aSmrg	    output=$output_objdir/${outputname}i
1082288de56ccSmrg	    # Replace all uninstalled libtool libraries with the installed ones
1082388de56ccSmrg	    newdependency_libs=
1082488de56ccSmrg	    for deplib in $dependency_libs; do
1082588de56ccSmrg	      case $deplib in
1082688de56ccSmrg	      *.la)
1082788de56ccSmrg		func_basename "$deplib"
10828862bcd1aSmrg		name=$func_basename_result
10829eb411b4bSmrg		func_resolve_sysroot "$deplib"
10830862bcd1aSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
1083188de56ccSmrg		test -z "$libdir" && \
10832862bcd1aSmrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
10833e9fcaa8aSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10834e9fcaa8aSmrg		;;
10835e9fcaa8aSmrg	      -L*)
10836e9fcaa8aSmrg		func_stripname -L '' "$deplib"
10837e9fcaa8aSmrg		func_replace_sysroot "$func_stripname_result"
10838e9fcaa8aSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
1083988de56ccSmrg		;;
10840e9fcaa8aSmrg	      -R*)
10841e9fcaa8aSmrg		func_stripname -R '' "$deplib"
10842e9fcaa8aSmrg		func_replace_sysroot "$func_stripname_result"
10843e9fcaa8aSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
10844e9fcaa8aSmrg		;;
10845e9fcaa8aSmrg	      *) func_append newdependency_libs " $deplib" ;;
1084688de56ccSmrg	      esac
1084788de56ccSmrg	    done
10848862bcd1aSmrg	    dependency_libs=$newdependency_libs
1084988de56ccSmrg	    newdlfiles=
1085088de56ccSmrg
1085188de56ccSmrg	    for lib in $dlfiles; do
1085288de56ccSmrg	      case $lib in
1085388de56ccSmrg	      *.la)
1085488de56ccSmrg	        func_basename "$lib"
10855862bcd1aSmrg		name=$func_basename_result
10856862bcd1aSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
1085788de56ccSmrg		test -z "$libdir" && \
10858862bcd1aSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10859e9fcaa8aSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
1086088de56ccSmrg		;;
10861e9fcaa8aSmrg	      *) func_append newdlfiles " $lib" ;;
1086288de56ccSmrg	      esac
1086388de56ccSmrg	    done
10864862bcd1aSmrg	    dlfiles=$newdlfiles
1086588de56ccSmrg	    newdlprefiles=
1086688de56ccSmrg	    for lib in $dlprefiles; do
1086788de56ccSmrg	      case $lib in
1086888de56ccSmrg	      *.la)
1086988de56ccSmrg		# Only pass preopened files to the pseudo-archive (for
1087088de56ccSmrg		# eventual linking with the app. that links it) if we
1087188de56ccSmrg		# didn't already link the preopened objects directly into
1087288de56ccSmrg		# the library:
1087388de56ccSmrg		func_basename "$lib"
10874862bcd1aSmrg		name=$func_basename_result
10875862bcd1aSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
1087688de56ccSmrg		test -z "$libdir" && \
10877862bcd1aSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10878e9fcaa8aSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
1087988de56ccSmrg		;;
1088088de56ccSmrg	      esac
1088188de56ccSmrg	    done
10882862bcd1aSmrg	    dlprefiles=$newdlprefiles
1088388de56ccSmrg	  else
1088488de56ccSmrg	    newdlfiles=
1088588de56ccSmrg	    for lib in $dlfiles; do
1088688de56ccSmrg	      case $lib in
10887862bcd1aSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
1088888de56ccSmrg		*) abs=`pwd`"/$lib" ;;
1088988de56ccSmrg	      esac
10890e9fcaa8aSmrg	      func_append newdlfiles " $abs"
1089188de56ccSmrg	    done
10892862bcd1aSmrg	    dlfiles=$newdlfiles
1089388de56ccSmrg	    newdlprefiles=
1089488de56ccSmrg	    for lib in $dlprefiles; do
1089588de56ccSmrg	      case $lib in
10896862bcd1aSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
1089788de56ccSmrg		*) abs=`pwd`"/$lib" ;;
1089888de56ccSmrg	      esac
10899e9fcaa8aSmrg	      func_append newdlprefiles " $abs"
1090088de56ccSmrg	    done
10901862bcd1aSmrg	    dlprefiles=$newdlprefiles
1090288de56ccSmrg	  fi
1090388de56ccSmrg	  $RM $output
1090488de56ccSmrg	  # place dlname in correct position for cygwin
10905e9fcaa8aSmrg	  # In fact, it would be nice if we could use this code for all target
10906e9fcaa8aSmrg	  # systems that can't hard-code library paths into their executables
10907e9fcaa8aSmrg	  # and that have no shared library path variable independent of PATH,
10908e9fcaa8aSmrg	  # but it turns out we can't easily determine that from inspecting
10909e9fcaa8aSmrg	  # libtool variables, so we have to hard-code the OSs to which it
10910e9fcaa8aSmrg	  # applies here; at the moment, that means platforms that use the PE
10911e9fcaa8aSmrg	  # object format with DLL files.  See the long comment at the top of
10912e9fcaa8aSmrg	  # tests/bindir.at for full details.
1091388de56ccSmrg	  tdlname=$dlname
1091488de56ccSmrg	  case $host,$output,$installed,$module,$dlname in
10915e9fcaa8aSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10916e9fcaa8aSmrg	      # If a -bindir argument was supplied, place the dll there.
10917862bcd1aSmrg	      if test -n "$bindir"; then
10918e9fcaa8aSmrg		func_relative_path "$install_libdir" "$bindir"
10919862bcd1aSmrg		tdlname=$func_relative_path_result/$dlname
10920e9fcaa8aSmrg	      else
10921e9fcaa8aSmrg		# Otherwise fall back on heuristic.
10922e9fcaa8aSmrg		tdlname=../bin/$dlname
10923e9fcaa8aSmrg	      fi
10924e9fcaa8aSmrg	      ;;
1092588de56ccSmrg	  esac
1092688de56ccSmrg	  $ECHO > $output "\
1092788de56ccSmrg# $outputname - a libtool library file
10928862bcd1aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
1092988de56ccSmrg#
1093088de56ccSmrg# Please DO NOT delete this file!
1093188de56ccSmrg# It is necessary for linking the library.
109321ab64890Smrg
1093388de56ccSmrg# The name that we can dlopen(3).
1093488de56ccSmrgdlname='$tdlname'
109351ab64890Smrg
1093688de56ccSmrg# Names of this library.
1093788de56ccSmrglibrary_names='$library_names'
109381ab64890Smrg
1093988de56ccSmrg# The name of the static archive.
1094088de56ccSmrgold_library='$old_library'
109411ab64890Smrg
10942862bcd1aSmrg# Linker flags that cannot go in dependency_libs.
1094388de56ccSmrginherited_linker_flags='$new_inherited_linker_flags'
109441ab64890Smrg
1094588de56ccSmrg# Libraries that this one depends upon.
1094688de56ccSmrgdependency_libs='$dependency_libs'
109471ab64890Smrg
1094888de56ccSmrg# Names of additional weak libraries provided by this library
1094988de56ccSmrgweak_library_names='$weak_libs'
109501ab64890Smrg
1095188de56ccSmrg# Version information for $libname.
1095288de56ccSmrgcurrent=$current
1095388de56ccSmrgage=$age
1095488de56ccSmrgrevision=$revision
109551ab64890Smrg
1095688de56ccSmrg# Is this an already installed library?
1095788de56ccSmrginstalled=$installed
109581ab64890Smrg
1095988de56ccSmrg# Should we warn about portability when linking against -modules?
1096088de56ccSmrgshouldnotlink=$module
109611ab64890Smrg
1096288de56ccSmrg# Files to dlopen/dlpreopen
1096388de56ccSmrgdlopen='$dlfiles'
1096488de56ccSmrgdlpreopen='$dlprefiles'
109651ab64890Smrg
1096688de56ccSmrg# Directory that this library needs to be installed in:
1096788de56ccSmrglibdir='$install_libdir'"
10968862bcd1aSmrg	  if test no,yes = "$installed,$need_relink"; then
1096988de56ccSmrg	    $ECHO >> $output "\
1097088de56ccSmrgrelink_command=\"$relink_command\""
1097188de56ccSmrg	  fi
1097288de56ccSmrg	done
1097388de56ccSmrg      }
109741ab64890Smrg
1097588de56ccSmrg      # Do a symbolic link so that the libtool archive can be found in
1097688de56ccSmrg      # LD_LIBRARY_PATH before the program is installed.
1097788de56ccSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
1097888de56ccSmrg      ;;
1097988de56ccSmrg    esac
1098088de56ccSmrg    exit $EXIT_SUCCESS
1098188de56ccSmrg}
10982b4ee4795Smrg
10983862bcd1aSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
10984862bcd1aSmrg  func_mode_link ${1+"$@"}
10985862bcd1aSmrgfi
109861ab64890Smrg
109871ab64890Smrg
1098888de56ccSmrg# func_mode_uninstall arg...
1098988de56ccSmrgfunc_mode_uninstall ()
1099088de56ccSmrg{
10991862bcd1aSmrg    $debug_cmd
10992862bcd1aSmrg
10993862bcd1aSmrg    RM=$nonopt
109941ab64890Smrg    files=
10995862bcd1aSmrg    rmforce=false
109961ab64890Smrg    exit_status=0
109971ab64890Smrg
109981ab64890Smrg    # This variable tells wrapper scripts just to set variables rather
109991ab64890Smrg    # than running their programs.
11000862bcd1aSmrg    libtool_install_magic=$magic
110011ab64890Smrg
110021ab64890Smrg    for arg
110031ab64890Smrg    do
110041ab64890Smrg      case $arg in
11005862bcd1aSmrg      -f) func_append RM " $arg"; rmforce=: ;;
11006e9fcaa8aSmrg      -*) func_append RM " $arg" ;;
11007e9fcaa8aSmrg      *) func_append files " $arg" ;;
110081ab64890Smrg      esac
110091ab64890Smrg    done
110101ab64890Smrg
1101188de56ccSmrg    test -z "$RM" && \
1101288de56ccSmrg      func_fatal_help "you must specify an RM program"
110131ab64890Smrg
110141ab64890Smrg    rmdirs=
110151ab64890Smrg
110161ab64890Smrg    for file in $files; do
1101788de56ccSmrg      func_dirname "$file" "" "."
11018862bcd1aSmrg      dir=$func_dirname_result
11019862bcd1aSmrg      if test . = "$dir"; then
11020862bcd1aSmrg	odir=$objdir
110211ab64890Smrg      else
11022862bcd1aSmrg	odir=$dir/$objdir
110231ab64890Smrg      fi
1102488de56ccSmrg      func_basename "$file"
11025862bcd1aSmrg      name=$func_basename_result
11026862bcd1aSmrg      test uninstall = "$opt_mode" && odir=$dir
110271ab64890Smrg
11028e9fcaa8aSmrg      # Remember odir for removal later, being careful to avoid duplicates
11029862bcd1aSmrg      if test clean = "$opt_mode"; then
110301ab64890Smrg	case " $rmdirs " in
11031e9fcaa8aSmrg	  *" $odir "*) ;;
11032e9fcaa8aSmrg	  *) func_append rmdirs " $odir" ;;
110331ab64890Smrg	esac
110341ab64890Smrg      fi
110351ab64890Smrg
110361ab64890Smrg      # Don't error if the file doesn't exist and rm -f was used.
1103788de56ccSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
1103888de56ccSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
1103988de56ccSmrg	 test -f "$file"; then
110401ab64890Smrg	:
110411ab64890Smrg      elif test -d "$file"; then
110421ab64890Smrg	exit_status=1
110431ab64890Smrg	continue
11044862bcd1aSmrg      elif $rmforce; then
110451ab64890Smrg	continue
110461ab64890Smrg      fi
110471ab64890Smrg
11048862bcd1aSmrg      rmfiles=$file
110491ab64890Smrg
110501ab64890Smrg      case $name in
110511ab64890Smrg      *.la)
110521ab64890Smrg	# Possibly a libtool archive, so verify it.
1105388de56ccSmrg	if func_lalib_p "$file"; then
1105488de56ccSmrg	  func_source $dir/$name
110551ab64890Smrg
110561ab64890Smrg	  # Delete the libtool libraries and symlinks.
110571ab64890Smrg	  for n in $library_names; do
11058e9fcaa8aSmrg	    func_append rmfiles " $odir/$n"
110591ab64890Smrg	  done
11060e9fcaa8aSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
110611ab64890Smrg
11062862bcd1aSmrg	  case $opt_mode in
110631ab64890Smrg	  clean)
11064e9fcaa8aSmrg	    case " $library_names " in
110651ab64890Smrg	    *" $dlname "*) ;;
11066e9fcaa8aSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
110671ab64890Smrg	    esac
11068e9fcaa8aSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
110691ab64890Smrg	    ;;
110701ab64890Smrg	  uninstall)
110711ab64890Smrg	    if test -n "$library_names"; then
110721ab64890Smrg	      # Do each command in the postuninstall commands.
11073862bcd1aSmrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
110741ab64890Smrg	    fi
110751ab64890Smrg
110761ab64890Smrg	    if test -n "$old_library"; then
110771ab64890Smrg	      # Do each command in the old_postuninstall commands.
11078862bcd1aSmrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
110791ab64890Smrg	    fi
110801ab64890Smrg	    # FIXME: should reinstall the best remaining shared library.
110811ab64890Smrg	    ;;
110821ab64890Smrg	  esac
110831ab64890Smrg	fi
110841ab64890Smrg	;;
110851ab64890Smrg
110861ab64890Smrg      *.lo)
110871ab64890Smrg	# Possibly a libtool object, so verify it.
1108888de56ccSmrg	if func_lalib_p "$file"; then
110891ab64890Smrg
110901ab64890Smrg	  # Read the .lo file
1109188de56ccSmrg	  func_source $dir/$name
110921ab64890Smrg
110931ab64890Smrg	  # Add PIC object to the list of files to remove.
11094862bcd1aSmrg	  if test -n "$pic_object" && test none != "$pic_object"; then
11095e9fcaa8aSmrg	    func_append rmfiles " $dir/$pic_object"
110961ab64890Smrg	  fi
110971ab64890Smrg
110981ab64890Smrg	  # Add non-PIC object to the list of files to remove.
11099862bcd1aSmrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11100e9fcaa8aSmrg	    func_append rmfiles " $dir/$non_pic_object"
111011ab64890Smrg	  fi
111021ab64890Smrg	fi
111031ab64890Smrg	;;
111041ab64890Smrg
111051ab64890Smrg      *)
11106862bcd1aSmrg	if test clean = "$opt_mode"; then
111071ab64890Smrg	  noexename=$name
111081ab64890Smrg	  case $file in
111091ab64890Smrg	  *.exe)
1111088de56ccSmrg	    func_stripname '' '.exe' "$file"
1111188de56ccSmrg	    file=$func_stripname_result
1111288de56ccSmrg	    func_stripname '' '.exe' "$name"
1111388de56ccSmrg	    noexename=$func_stripname_result
111141ab64890Smrg	    # $file with .exe has already been added to rmfiles,
111151ab64890Smrg	    # add $file without .exe
11116e9fcaa8aSmrg	    func_append rmfiles " $file"
111171ab64890Smrg	    ;;
111181ab64890Smrg	  esac
111191ab64890Smrg	  # Do a test to see if this is a libtool program.
1112088de56ccSmrg	  if func_ltwrapper_p "$file"; then
1112188de56ccSmrg	    if func_ltwrapper_executable_p "$file"; then
1112288de56ccSmrg	      func_ltwrapper_scriptname "$file"
1112388de56ccSmrg	      relink_command=
1112488de56ccSmrg	      func_source $func_ltwrapper_scriptname_result
11125e9fcaa8aSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
1112688de56ccSmrg	    else
1112788de56ccSmrg	      relink_command=
1112888de56ccSmrg	      func_source $dir/$noexename
1112988de56ccSmrg	    fi
111301ab64890Smrg
111311ab64890Smrg	    # note $name still contains .exe if it was in $file originally
111321ab64890Smrg	    # as does the version of $file that was added into $rmfiles
11133862bcd1aSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
11134862bcd1aSmrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
11135e9fcaa8aSmrg	      func_append rmfiles " $odir/lt-$name"
111361ab64890Smrg	    fi
11137862bcd1aSmrg	    if test "X$noexename" != "X$name"; then
11138862bcd1aSmrg	      func_append rmfiles " $odir/lt-$noexename.c"
111391ab64890Smrg	    fi
111401ab64890Smrg	  fi
111411ab64890Smrg	fi
111421ab64890Smrg	;;
111431ab64890Smrg      esac
1114488de56ccSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
111451ab64890Smrg    done
111461ab64890Smrg
11147862bcd1aSmrg    # Try to remove the $objdir's in the directories where we deleted files
111481ab64890Smrg    for dir in $rmdirs; do
111491ab64890Smrg      if test -d "$dir"; then
1115088de56ccSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
111511ab64890Smrg      fi
111521ab64890Smrg    done
111531ab64890Smrg
111541ab64890Smrg    exit $exit_status
1115588de56ccSmrg}
111561ab64890Smrg
11157862bcd1aSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
11158862bcd1aSmrg  func_mode_uninstall ${1+"$@"}
11159862bcd1aSmrgfi
111602e9c7c8cSmrg
11161e9fcaa8aSmrgtest -z "$opt_mode" && {
11162862bcd1aSmrg  help=$generic_help
1116388de56ccSmrg  func_fatal_help "you must specify a MODE"
1116488de56ccSmrg}
1116588de56ccSmrg
1116688de56ccSmrgtest -z "$exec_cmd" && \
11167862bcd1aSmrg  func_fatal_help "invalid operation mode '$opt_mode'"
111681ab64890Smrg
111691ab64890Smrgif test -n "$exec_cmd"; then
1117088de56ccSmrg  eval exec "$exec_cmd"
111711ab64890Smrg  exit $EXIT_FAILURE
111721ab64890Smrgfi
111731ab64890Smrg
1117488de56ccSmrgexit $exit_status
111751ab64890Smrg
111761ab64890Smrg
111771ab64890Smrg# The TAGs below are defined such that we never get into a situation
11178862bcd1aSmrg# where we disable both kinds of libraries.  Given conflicting
111791ab64890Smrg# choices, we go for a static library, that is the most portable,
111801ab64890Smrg# since we can't tell whether shared libraries were disabled because
111811ab64890Smrg# the user asked for that or because the platform doesn't support
111821ab64890Smrg# them.  This is particularly important on AIX, because we don't
111831ab64890Smrg# support having both static and shared libraries enabled at the same
111841ab64890Smrg# time on that platform, so we default to a shared-only configuration.
111851ab64890Smrg# If a disable-shared tag is given, we'll fallback to a static-only
111861ab64890Smrg# configuration.  But we'll never go from static-only to shared-only.
111871ab64890Smrg
111881ab64890Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
1118988de56ccSmrgbuild_libtool_libs=no
1119088de56ccSmrgbuild_old_libs=yes
111911ab64890Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
111921ab64890Smrg
111931ab64890Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
1119488de56ccSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
111951ab64890Smrg# ### END LIBTOOL TAG CONFIG: disable-static
111961ab64890Smrg
111971ab64890Smrg# Local Variables:
111981ab64890Smrg# mode:shell-script
111991ab64890Smrg# sh-indentation:2
112001ab64890Smrg# End:
11201