ltmain.sh revision d4a3aaf4
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
34d4a3aaf4SmrgVERSION="2.4.6 Debian-2.4.6-14"
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.
675afda2e6Smrgscriptversion=2015-01-20.17; # 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#
390d4a3aaf4Smrg#    debug_cmd='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
1094862bcd1aSmrg# func_quote_for_eval ARG...
1095862bcd1aSmrg# --------------------------
1096862bcd1aSmrg# Aesthetically quote ARGs to be evaled later.
1097862bcd1aSmrg# This function returns two values:
1098862bcd1aSmrg#   i) func_quote_for_eval_result
1099862bcd1aSmrg#      double-quoted, suitable for a subsequent eval
1100862bcd1aSmrg#  ii) func_quote_for_eval_unquoted_result
1101862bcd1aSmrg#      has all characters that are still active within double
1102862bcd1aSmrg#      quotes backslashified.
1103862bcd1aSmrgfunc_quote_for_eval ()
1104862bcd1aSmrg{
1105862bcd1aSmrg    $debug_cmd
1106862bcd1aSmrg
1107862bcd1aSmrg    func_quote_for_eval_unquoted_result=
1108862bcd1aSmrg    func_quote_for_eval_result=
1109862bcd1aSmrg    while test 0 -lt $#; do
11105afda2e6Smrg      case $1 in
11115afda2e6Smrg        *[\\\`\"\$]*)
11125afda2e6Smrg	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
11135afda2e6Smrg        *)
11145afda2e6Smrg          _G_unquoted_arg=$1 ;;
11155afda2e6Smrg      esac
1116862bcd1aSmrg      if test -n "$func_quote_for_eval_unquoted_result"; then
1117862bcd1aSmrg	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1118862bcd1aSmrg      else
1119862bcd1aSmrg        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1120862bcd1aSmrg      fi
1121862bcd1aSmrg
1122862bcd1aSmrg      case $_G_unquoted_arg in
1123862bcd1aSmrg        # Double-quote args containing shell metacharacters to delay
1124862bcd1aSmrg        # word splitting, command substitution and variable expansion
1125862bcd1aSmrg        # for a subsequent eval.
1126862bcd1aSmrg        # Many Bourne shells cannot handle close brackets correctly
1127862bcd1aSmrg        # in scan sets, so we specify it separately.
1128862bcd1aSmrg        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1129862bcd1aSmrg          _G_quoted_arg=\"$_G_unquoted_arg\"
1130862bcd1aSmrg          ;;
1131862bcd1aSmrg        *)
1132862bcd1aSmrg          _G_quoted_arg=$_G_unquoted_arg
1133862bcd1aSmrg	  ;;
1134862bcd1aSmrg      esac
1135862bcd1aSmrg
1136862bcd1aSmrg      if test -n "$func_quote_for_eval_result"; then
1137862bcd1aSmrg	func_append func_quote_for_eval_result " $_G_quoted_arg"
1138862bcd1aSmrg      else
1139862bcd1aSmrg        func_append func_quote_for_eval_result "$_G_quoted_arg"
1140862bcd1aSmrg      fi
1141862bcd1aSmrg      shift
1142862bcd1aSmrg    done
1143862bcd1aSmrg}
1144862bcd1aSmrg
1145862bcd1aSmrg
1146862bcd1aSmrg# func_quote_for_expand ARG
1147862bcd1aSmrg# -------------------------
114888de56ccSmrg# Aesthetically quote ARG to be evaled later; same as above,
114988de56ccSmrg# but do not quote variable references.
115088de56ccSmrgfunc_quote_for_expand ()
11511ab64890Smrg{
1152862bcd1aSmrg    $debug_cmd
1153862bcd1aSmrg
115488de56ccSmrg    case $1 in
115588de56ccSmrg      *[\\\`\"]*)
1156862bcd1aSmrg	_G_arg=`$ECHO "$1" | $SED \
1157862bcd1aSmrg	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
11581ab64890Smrg      *)
1159862bcd1aSmrg        _G_arg=$1 ;;
116088de56ccSmrg    esac
116188de56ccSmrg
1162862bcd1aSmrg    case $_G_arg in
116388de56ccSmrg      # Double-quote args containing shell metacharacters to delay
116488de56ccSmrg      # word splitting and command substitution for a subsequent eval.
116588de56ccSmrg      # Many Bourne shells cannot handle close brackets correctly
116688de56ccSmrg      # in scan sets, so we specify it separately.
116788de56ccSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1168862bcd1aSmrg        _G_arg=\"$_G_arg\"
116988de56ccSmrg        ;;
117088de56ccSmrg    esac
117188de56ccSmrg
1172862bcd1aSmrg    func_quote_for_expand_result=$_G_arg
1173862bcd1aSmrg}
1174862bcd1aSmrg
1175862bcd1aSmrg
1176862bcd1aSmrg# func_stripname PREFIX SUFFIX NAME
1177862bcd1aSmrg# ---------------------------------
1178862bcd1aSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1179862bcd1aSmrg# PREFIX and SUFFIX must not contain globbing or regex special
1180862bcd1aSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
1181862bcd1aSmrg# dot (in which case that matches only a dot).
1182862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
1183862bcd1aSmrg  eval 'func_stripname ()
1184862bcd1aSmrg  {
1185862bcd1aSmrg    $debug_cmd
1186862bcd1aSmrg
1187862bcd1aSmrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1188862bcd1aSmrg    # positional parameters, so assign one to ordinary variable first.
1189862bcd1aSmrg    func_stripname_result=$3
1190862bcd1aSmrg    func_stripname_result=${func_stripname_result#"$1"}
1191862bcd1aSmrg    func_stripname_result=${func_stripname_result%"$2"}
1192862bcd1aSmrg  }'
1193862bcd1aSmrgelse
1194862bcd1aSmrg  func_stripname ()
1195862bcd1aSmrg  {
1196862bcd1aSmrg    $debug_cmd
1197862bcd1aSmrg
1198862bcd1aSmrg    case $2 in
1199862bcd1aSmrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1200862bcd1aSmrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1201862bcd1aSmrg    esac
1202862bcd1aSmrg  }
1203862bcd1aSmrgfi
1204862bcd1aSmrg
1205862bcd1aSmrg
1206862bcd1aSmrg# func_show_eval CMD [FAIL_EXP]
1207862bcd1aSmrg# -----------------------------
1208862bcd1aSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1209862bcd1aSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1210862bcd1aSmrg# is given, then evaluate it.
1211862bcd1aSmrgfunc_show_eval ()
1212862bcd1aSmrg{
1213862bcd1aSmrg    $debug_cmd
1214862bcd1aSmrg
1215862bcd1aSmrg    _G_cmd=$1
1216862bcd1aSmrg    _G_fail_exp=${2-':'}
1217862bcd1aSmrg
1218862bcd1aSmrg    func_quote_for_expand "$_G_cmd"
1219862bcd1aSmrg    eval "func_notquiet $func_quote_for_expand_result"
1220862bcd1aSmrg
1221862bcd1aSmrg    $opt_dry_run || {
1222862bcd1aSmrg      eval "$_G_cmd"
1223862bcd1aSmrg      _G_status=$?
1224862bcd1aSmrg      if test 0 -ne "$_G_status"; then
1225862bcd1aSmrg	eval "(exit $_G_status); $_G_fail_exp"
1226862bcd1aSmrg      fi
1227862bcd1aSmrg    }
1228862bcd1aSmrg}
1229862bcd1aSmrg
1230862bcd1aSmrg
1231862bcd1aSmrg# func_show_eval_locale CMD [FAIL_EXP]
1232862bcd1aSmrg# ------------------------------------
1233862bcd1aSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1234862bcd1aSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1235862bcd1aSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
1236862bcd1aSmrgfunc_show_eval_locale ()
1237862bcd1aSmrg{
1238862bcd1aSmrg    $debug_cmd
1239862bcd1aSmrg
1240862bcd1aSmrg    _G_cmd=$1
1241862bcd1aSmrg    _G_fail_exp=${2-':'}
1242862bcd1aSmrg
1243862bcd1aSmrg    $opt_quiet || {
1244862bcd1aSmrg      func_quote_for_expand "$_G_cmd"
1245862bcd1aSmrg      eval "func_echo $func_quote_for_expand_result"
1246862bcd1aSmrg    }
1247862bcd1aSmrg
1248862bcd1aSmrg    $opt_dry_run || {
1249862bcd1aSmrg      eval "$_G_user_locale
1250862bcd1aSmrg	    $_G_cmd"
1251862bcd1aSmrg      _G_status=$?
1252862bcd1aSmrg      eval "$_G_safe_locale"
1253862bcd1aSmrg      if test 0 -ne "$_G_status"; then
1254862bcd1aSmrg	eval "(exit $_G_status); $_G_fail_exp"
1255862bcd1aSmrg      fi
1256862bcd1aSmrg    }
1257862bcd1aSmrg}
1258862bcd1aSmrg
1259862bcd1aSmrg
1260862bcd1aSmrg# func_tr_sh
1261862bcd1aSmrg# ----------
1262862bcd1aSmrg# Turn $1 into a string suitable for a shell variable name.
1263862bcd1aSmrg# Result is stored in $func_tr_sh_result.  All characters
1264862bcd1aSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1265862bcd1aSmrg# if $1 begins with a digit, a '_' is prepended as well.
1266862bcd1aSmrgfunc_tr_sh ()
1267862bcd1aSmrg{
1268862bcd1aSmrg    $debug_cmd
1269862bcd1aSmrg
1270862bcd1aSmrg    case $1 in
1271862bcd1aSmrg    [0-9]* | *[!a-zA-Z0-9_]*)
1272862bcd1aSmrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1273862bcd1aSmrg      ;;
1274862bcd1aSmrg    * )
1275862bcd1aSmrg      func_tr_sh_result=$1
1276862bcd1aSmrg      ;;
1277862bcd1aSmrg    esac
1278862bcd1aSmrg}
1279862bcd1aSmrg
1280862bcd1aSmrg
1281862bcd1aSmrg# func_verbose ARG...
1282862bcd1aSmrg# -------------------
1283862bcd1aSmrg# Echo program name prefixed message in verbose mode only.
1284862bcd1aSmrgfunc_verbose ()
1285862bcd1aSmrg{
1286862bcd1aSmrg    $debug_cmd
1287862bcd1aSmrg
1288862bcd1aSmrg    $opt_verbose && func_echo "$*"
1289862bcd1aSmrg
1290862bcd1aSmrg    :
1291862bcd1aSmrg}
1292862bcd1aSmrg
1293862bcd1aSmrg
1294862bcd1aSmrg# func_warn_and_continue ARG...
1295862bcd1aSmrg# -----------------------------
1296862bcd1aSmrg# Echo program name prefixed warning message to standard error.
1297862bcd1aSmrgfunc_warn_and_continue ()
1298862bcd1aSmrg{
1299862bcd1aSmrg    $debug_cmd
1300862bcd1aSmrg
1301862bcd1aSmrg    $require_term_colors
1302862bcd1aSmrg
1303862bcd1aSmrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1304862bcd1aSmrg}
1305862bcd1aSmrg
1306862bcd1aSmrg
1307862bcd1aSmrg# func_warning CATEGORY ARG...
1308862bcd1aSmrg# ----------------------------
1309862bcd1aSmrg# Echo program name prefixed warning message to standard error. Warning
1310862bcd1aSmrg# messages can be filtered according to CATEGORY, where this function
1311862bcd1aSmrg# elides messages where CATEGORY is not listed in the global variable
1312862bcd1aSmrg# 'opt_warning_types'.
1313862bcd1aSmrgfunc_warning ()
1314862bcd1aSmrg{
1315862bcd1aSmrg    $debug_cmd
1316862bcd1aSmrg
1317862bcd1aSmrg    # CATEGORY must be in the warning_categories list!
1318862bcd1aSmrg    case " $warning_categories " in
1319862bcd1aSmrg      *" $1 "*) ;;
1320862bcd1aSmrg      *) func_internal_error "invalid warning category '$1'" ;;
1321862bcd1aSmrg    esac
1322862bcd1aSmrg
1323862bcd1aSmrg    _G_category=$1
1324862bcd1aSmrg    shift
1325862bcd1aSmrg
1326862bcd1aSmrg    case " $opt_warning_types " in
1327862bcd1aSmrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
1328862bcd1aSmrg    esac
13291ab64890Smrg}
13301ab64890Smrg
13311ab64890Smrg
1332862bcd1aSmrg# func_sort_ver VER1 VER2
1333862bcd1aSmrg# -----------------------
1334862bcd1aSmrg# 'sort -V' is not generally available.
1335862bcd1aSmrg# Note this deviates from the version comparison in automake
1336862bcd1aSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1337862bcd1aSmrg# but this should suffice as we won't be specifying old
1338862bcd1aSmrg# version formats or redundant trailing .0 in bootstrap.conf.
1339862bcd1aSmrg# If we did want full compatibility then we should probably
1340862bcd1aSmrg# use m4_version_compare from autoconf.
1341862bcd1aSmrgfunc_sort_ver ()
1342862bcd1aSmrg{
1343862bcd1aSmrg    $debug_cmd
1344862bcd1aSmrg
1345862bcd1aSmrg    printf '%s\n%s\n' "$1" "$2" \
1346862bcd1aSmrg      | 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
1347862bcd1aSmrg}
1348862bcd1aSmrg
1349862bcd1aSmrg# func_lt_ver PREV CURR
1350862bcd1aSmrg# ---------------------
1351862bcd1aSmrg# Return true if PREV and CURR are in the correct order according to
1352862bcd1aSmrg# func_sort_ver, otherwise false.  Use it like this:
1353862bcd1aSmrg#
1354862bcd1aSmrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1355862bcd1aSmrgfunc_lt_ver ()
1356862bcd1aSmrg{
1357862bcd1aSmrg    $debug_cmd
1358862bcd1aSmrg
1359862bcd1aSmrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1360862bcd1aSmrg}
1361862bcd1aSmrg
1362862bcd1aSmrg
1363862bcd1aSmrg# Local variables:
1364862bcd1aSmrg# mode: shell-script
1365862bcd1aSmrg# sh-indentation: 2
1366862bcd1aSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1367862bcd1aSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1368862bcd1aSmrg# time-stamp-time-zone: "UTC"
1369862bcd1aSmrg# End:
1370862bcd1aSmrg#! /bin/sh
1371862bcd1aSmrg
1372862bcd1aSmrg# Set a version string for this script.
1373d4a3aaf4Smrgscriptversion=2015-10-07.11; # UTC
1374862bcd1aSmrg
1375862bcd1aSmrg# A portable, pluggable option parser for Bourne shell.
1376862bcd1aSmrg# Written by Gary V. Vaughan, 2010
1377862bcd1aSmrg
1378862bcd1aSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc.
1379862bcd1aSmrg# This is free software; see the source for copying conditions.  There is NO
1380862bcd1aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1381862bcd1aSmrg
1382862bcd1aSmrg# This program is free software: you can redistribute it and/or modify
1383862bcd1aSmrg# it under the terms of the GNU General Public License as published by
1384862bcd1aSmrg# the Free Software Foundation, either version 3 of the License, or
1385862bcd1aSmrg# (at your option) any later version.
1386862bcd1aSmrg
1387862bcd1aSmrg# This program is distributed in the hope that it will be useful,
1388862bcd1aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1389862bcd1aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1390862bcd1aSmrg# GNU General Public License for more details.
1391862bcd1aSmrg
1392862bcd1aSmrg# You should have received a copy of the GNU General Public License
1393862bcd1aSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
1394862bcd1aSmrg
1395862bcd1aSmrg# Please report bugs or propose patches to gary@gnu.org.
1396862bcd1aSmrg
1397862bcd1aSmrg
1398862bcd1aSmrg## ------ ##
1399862bcd1aSmrg## Usage. ##
1400862bcd1aSmrg## ------ ##
1401862bcd1aSmrg
1402862bcd1aSmrg# This file is a library for parsing options in your shell scripts along
1403862bcd1aSmrg# with assorted other useful supporting features that you can make use
1404862bcd1aSmrg# of too.
1405862bcd1aSmrg#
1406862bcd1aSmrg# For the simplest scripts you might need only:
1407862bcd1aSmrg#
1408862bcd1aSmrg#   #!/bin/sh
1409862bcd1aSmrg#   . relative/path/to/funclib.sh
1410862bcd1aSmrg#   . relative/path/to/options-parser
1411862bcd1aSmrg#   scriptversion=1.0
1412862bcd1aSmrg#   func_options ${1+"$@"}
1413862bcd1aSmrg#   eval set dummy "$func_options_result"; shift
1414862bcd1aSmrg#   ...rest of your script...
1415862bcd1aSmrg#
1416862bcd1aSmrg# In order for the '--version' option to work, you will need to have a
1417862bcd1aSmrg# suitably formatted comment like the one at the top of this file
1418862bcd1aSmrg# starting with '# Written by ' and ending with '# warranty; '.
1419862bcd1aSmrg#
1420862bcd1aSmrg# For '-h' and '--help' to work, you will also need a one line
1421862bcd1aSmrg# description of your script's purpose in a comment directly above the
1422862bcd1aSmrg# '# Written by ' line, like the one at the top of this file.
1423862bcd1aSmrg#
1424862bcd1aSmrg# The default options also support '--debug', which will turn on shell
1425862bcd1aSmrg# execution tracing (see the comment above debug_cmd below for another
1426862bcd1aSmrg# use), and '--verbose' and the func_verbose function to allow your script
1427862bcd1aSmrg# to display verbose messages only when your user has specified
1428862bcd1aSmrg# '--verbose'.
1429862bcd1aSmrg#
1430862bcd1aSmrg# After sourcing this file, you can plug processing for additional
1431862bcd1aSmrg# options by amending the variables from the 'Configuration' section
1432862bcd1aSmrg# below, and following the instructions in the 'Option parsing'
1433862bcd1aSmrg# section further down.
1434862bcd1aSmrg
1435862bcd1aSmrg## -------------- ##
1436862bcd1aSmrg## Configuration. ##
1437862bcd1aSmrg## -------------- ##
1438862bcd1aSmrg
1439862bcd1aSmrg# You should override these variables in your script after sourcing this
1440862bcd1aSmrg# file so that they reflect the customisations you have added to the
1441862bcd1aSmrg# option parser.
1442862bcd1aSmrg
1443862bcd1aSmrg# The usage line for option parsing errors and the start of '-h' and
1444862bcd1aSmrg# '--help' output messages. You can embed shell variables for delayed
1445862bcd1aSmrg# expansion at the time the message is displayed, but you will need to
1446862bcd1aSmrg# quote other shell meta-characters carefully to prevent them being
1447862bcd1aSmrg# expanded when the contents are evaled.
1448862bcd1aSmrgusage='$progpath [OPTION]...'
1449862bcd1aSmrg
1450862bcd1aSmrg# Short help message in response to '-h' and '--help'.  Add to this or
1451862bcd1aSmrg# override it after sourcing this library to reflect the full set of
1452862bcd1aSmrg# options your script accepts.
1453862bcd1aSmrgusage_message="\
1454862bcd1aSmrg       --debug        enable verbose shell tracing
1455862bcd1aSmrg   -W, --warnings=CATEGORY
1456862bcd1aSmrg                      report the warnings falling in CATEGORY [all]
1457862bcd1aSmrg   -v, --verbose      verbosely report processing
1458862bcd1aSmrg       --version      print version information and exit
1459862bcd1aSmrg   -h, --help         print short or long help message and exit
1460862bcd1aSmrg"
1461862bcd1aSmrg
1462862bcd1aSmrg# Additional text appended to 'usage_message' in response to '--help'.
1463862bcd1aSmrglong_help_message="
1464862bcd1aSmrgWarning categories include:
1465862bcd1aSmrg       'all'          show all warnings
1466862bcd1aSmrg       'none'         turn off all the warnings
1467862bcd1aSmrg       'error'        warnings are treated as fatal errors"
1468862bcd1aSmrg
1469862bcd1aSmrg# Help message printed before fatal option parsing errors.
1470862bcd1aSmrgfatal_help="Try '\$progname --help' for more information."
1471862bcd1aSmrg
1472862bcd1aSmrg
1473862bcd1aSmrg
1474862bcd1aSmrg## ------------------------- ##
1475862bcd1aSmrg## Hook function management. ##
1476862bcd1aSmrg## ------------------------- ##
1477862bcd1aSmrg
1478862bcd1aSmrg# This section contains functions for adding, removing, and running hooks
1479862bcd1aSmrg# to the main code.  A hook is just a named list of of function, that can
1480862bcd1aSmrg# be run in order later on.
1481862bcd1aSmrg
1482862bcd1aSmrg# func_hookable FUNC_NAME
1483862bcd1aSmrg# -----------------------
1484862bcd1aSmrg# Declare that FUNC_NAME will run hooks added with
1485862bcd1aSmrg# 'func_add_hook FUNC_NAME ...'.
1486862bcd1aSmrgfunc_hookable ()
1487862bcd1aSmrg{
1488862bcd1aSmrg    $debug_cmd
1489862bcd1aSmrg
1490862bcd1aSmrg    func_append hookable_fns " $1"
1491862bcd1aSmrg}
1492862bcd1aSmrg
1493862bcd1aSmrg
1494862bcd1aSmrg# func_add_hook FUNC_NAME HOOK_FUNC
1495862bcd1aSmrg# ---------------------------------
1496862bcd1aSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
1497862bcd1aSmrg# first have been declared "hookable" by a call to 'func_hookable'.
1498862bcd1aSmrgfunc_add_hook ()
1499862bcd1aSmrg{
1500862bcd1aSmrg    $debug_cmd
1501862bcd1aSmrg
1502862bcd1aSmrg    case " $hookable_fns " in
1503862bcd1aSmrg      *" $1 "*) ;;
1504862bcd1aSmrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
1505862bcd1aSmrg    esac
1506862bcd1aSmrg
1507862bcd1aSmrg    eval func_append ${1}_hooks '" $2"'
1508862bcd1aSmrg}
1509862bcd1aSmrg
1510862bcd1aSmrg
1511862bcd1aSmrg# func_remove_hook FUNC_NAME HOOK_FUNC
1512862bcd1aSmrg# ------------------------------------
1513862bcd1aSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
1514862bcd1aSmrgfunc_remove_hook ()
1515862bcd1aSmrg{
1516862bcd1aSmrg    $debug_cmd
1517862bcd1aSmrg
1518862bcd1aSmrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1519862bcd1aSmrg}
1520862bcd1aSmrg
1521862bcd1aSmrg
1522862bcd1aSmrg# func_run_hooks FUNC_NAME [ARG]...
1523862bcd1aSmrg# ---------------------------------
1524862bcd1aSmrg# Run all hook functions registered to FUNC_NAME.
1525862bcd1aSmrg# It is assumed that the list of hook functions contains nothing more
1526862bcd1aSmrg# than a whitespace-delimited list of legal shell function names, and
1527862bcd1aSmrg# no effort is wasted trying to catch shell meta-characters or preserve
1528862bcd1aSmrg# whitespace.
1529862bcd1aSmrgfunc_run_hooks ()
1530862bcd1aSmrg{
1531862bcd1aSmrg    $debug_cmd
1532862bcd1aSmrg
1533d4a3aaf4Smrg    _G_rc_run_hooks=false
1534d4a3aaf4Smrg
1535862bcd1aSmrg    case " $hookable_fns " in
1536862bcd1aSmrg      *" $1 "*) ;;
1537862bcd1aSmrg      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
1538862bcd1aSmrg    esac
1539862bcd1aSmrg
1540862bcd1aSmrg    eval _G_hook_fns=\$$1_hooks; shift
1541862bcd1aSmrg
1542862bcd1aSmrg    for _G_hook in $_G_hook_fns; do
1543d4a3aaf4Smrg      if eval $_G_hook '"$@"'; then
1544d4a3aaf4Smrg        # store returned options list back into positional
1545d4a3aaf4Smrg        # parameters for next 'cmd' execution.
1546d4a3aaf4Smrg        eval _G_hook_result=\$${_G_hook}_result
1547d4a3aaf4Smrg        eval set dummy "$_G_hook_result"; shift
1548d4a3aaf4Smrg        _G_rc_run_hooks=:
1549d4a3aaf4Smrg      fi
1550862bcd1aSmrg    done
1551862bcd1aSmrg
1552d4a3aaf4Smrg    $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result
1553862bcd1aSmrg}
1554862bcd1aSmrg
1555862bcd1aSmrg
1556862bcd1aSmrg
1557862bcd1aSmrg## --------------- ##
1558862bcd1aSmrg## Option parsing. ##
1559862bcd1aSmrg## --------------- ##
1560862bcd1aSmrg
1561862bcd1aSmrg# In order to add your own option parsing hooks, you must accept the
1562d4a3aaf4Smrg# full positional parameter list in your hook function, you may remove/edit
1563d4a3aaf4Smrg# any options that you action, and then pass back the remaining unprocessed
1564862bcd1aSmrg# options in '<hooked_function_name>_result', escaped suitably for
1565d4a3aaf4Smrg# 'eval'.  In this case you also must return $EXIT_SUCCESS to let the
1566d4a3aaf4Smrg# hook's caller know that it should pay attention to
1567d4a3aaf4Smrg# '<hooked_function_name>_result'.  Returning $EXIT_FAILURE signalizes that
1568d4a3aaf4Smrg# arguments are left untouched by the hook and therefore caller will ignore the
1569d4a3aaf4Smrg# result variable.
1570d4a3aaf4Smrg#
1571d4a3aaf4Smrg# Like this:
1572862bcd1aSmrg#
1573862bcd1aSmrg#    my_options_prep ()
1574862bcd1aSmrg#    {
1575862bcd1aSmrg#        $debug_cmd
1576862bcd1aSmrg#
1577862bcd1aSmrg#        # Extend the existing usage message.
1578862bcd1aSmrg#        usage_message=$usage_message'
1579862bcd1aSmrg#      -s, --silent       don'\''t print informational messages
1580862bcd1aSmrg#    '
1581d4a3aaf4Smrg#        # No change in '$@' (ignored completely by this hook).  There is
1582d4a3aaf4Smrg#        # no need to do the equivalent (but slower) action:
1583d4a3aaf4Smrg#        # func_quote_for_eval ${1+"$@"}
1584d4a3aaf4Smrg#        # my_options_prep_result=$func_quote_for_eval_result
1585d4a3aaf4Smrg#        false
1586862bcd1aSmrg#    }
1587862bcd1aSmrg#    func_add_hook func_options_prep my_options_prep
1588862bcd1aSmrg#
1589862bcd1aSmrg#
1590862bcd1aSmrg#    my_silent_option ()
1591862bcd1aSmrg#    {
1592862bcd1aSmrg#        $debug_cmd
1593862bcd1aSmrg#
1594d4a3aaf4Smrg#        args_changed=false
1595d4a3aaf4Smrg#
1596862bcd1aSmrg#        # Note that for efficiency, we parse as many options as we can
1597862bcd1aSmrg#        # recognise in a loop before passing the remainder back to the
1598862bcd1aSmrg#        # caller on the first unrecognised argument we encounter.
1599862bcd1aSmrg#        while test $# -gt 0; do
1600862bcd1aSmrg#          opt=$1; shift
1601862bcd1aSmrg#          case $opt in
1602d4a3aaf4Smrg#            --silent|-s) opt_silent=:
1603d4a3aaf4Smrg#                         args_changed=:
1604d4a3aaf4Smrg#                         ;;
1605862bcd1aSmrg#            # Separate non-argument short options:
1606862bcd1aSmrg#            -s*)         func_split_short_opt "$_G_opt"
1607862bcd1aSmrg#                         set dummy "$func_split_short_opt_name" \
1608862bcd1aSmrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
1609862bcd1aSmrg#                         shift
1610d4a3aaf4Smrg#                         args_changed=:
1611862bcd1aSmrg#                         ;;
1612d4a3aaf4Smrg#            *)           # Make sure the first unrecognised option "$_G_opt"
1613d4a3aaf4Smrg#                         # is added back to "$@", we could need that later
1614d4a3aaf4Smrg#                         # if $args_changed is true.
1615d4a3aaf4Smrg#                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1616862bcd1aSmrg#          esac
1617862bcd1aSmrg#        done
1618862bcd1aSmrg#
1619d4a3aaf4Smrg#        if $args_changed; then
1620d4a3aaf4Smrg#          func_quote_for_eval ${1+"$@"}
1621d4a3aaf4Smrg#          my_silent_option_result=$func_quote_for_eval_result
1622d4a3aaf4Smrg#        fi
1623d4a3aaf4Smrg#
1624d4a3aaf4Smrg#        $args_changed
1625862bcd1aSmrg#    }
1626862bcd1aSmrg#    func_add_hook func_parse_options my_silent_option
1627862bcd1aSmrg#
1628862bcd1aSmrg#
1629862bcd1aSmrg#    my_option_validation ()
1630862bcd1aSmrg#    {
1631862bcd1aSmrg#        $debug_cmd
1632862bcd1aSmrg#
1633862bcd1aSmrg#        $opt_silent && $opt_verbose && func_fatal_help "\
1634862bcd1aSmrg#    '--silent' and '--verbose' options are mutually exclusive."
1635862bcd1aSmrg#
1636d4a3aaf4Smrg#        false
1637862bcd1aSmrg#    }
1638862bcd1aSmrg#    func_add_hook func_validate_options my_option_validation
1639862bcd1aSmrg#
1640d4a3aaf4Smrg# You'll also need to manually amend $usage_message to reflect the extra
1641862bcd1aSmrg# options you parse.  It's preferable to append if you can, so that
1642862bcd1aSmrg# multiple option parsing hooks can be added safely.
1643862bcd1aSmrg
1644862bcd1aSmrg
1645d4a3aaf4Smrg# func_options_finish [ARG]...
1646d4a3aaf4Smrg# ----------------------------
1647d4a3aaf4Smrg# Finishing the option parse loop (call 'func_options' hooks ATM).
1648d4a3aaf4Smrgfunc_options_finish ()
1649d4a3aaf4Smrg{
1650d4a3aaf4Smrg    $debug_cmd
1651d4a3aaf4Smrg
1652d4a3aaf4Smrg    _G_func_options_finish_exit=false
1653d4a3aaf4Smrg    if func_run_hooks func_options ${1+"$@"}; then
1654d4a3aaf4Smrg      func_options_finish_result=$func_run_hooks_result
1655d4a3aaf4Smrg      _G_func_options_finish_exit=:
1656d4a3aaf4Smrg    fi
1657d4a3aaf4Smrg
1658d4a3aaf4Smrg    $_G_func_options_finish_exit
1659d4a3aaf4Smrg}
1660d4a3aaf4Smrg
1661d4a3aaf4Smrg
1662862bcd1aSmrg# func_options [ARG]...
1663862bcd1aSmrg# ---------------------
1664862bcd1aSmrg# All the functions called inside func_options are hookable. See the
1665862bcd1aSmrg# individual implementations for details.
1666862bcd1aSmrgfunc_hookable func_options
1667862bcd1aSmrgfunc_options ()
16681ab64890Smrg{
1669862bcd1aSmrg    $debug_cmd
16702e9c7c8cSmrg
1671d4a3aaf4Smrg    _G_rc_options=false
167288de56ccSmrg
1673d4a3aaf4Smrg    for my_func in options_prep parse_options validate_options options_finish
1674d4a3aaf4Smrg    do
1675d4a3aaf4Smrg      if eval func_$my_func '${1+"$@"}'; then
1676d4a3aaf4Smrg        eval _G_res_var='$'"func_${my_func}_result"
1677d4a3aaf4Smrg        eval set dummy "$_G_res_var" ; shift
1678d4a3aaf4Smrg        _G_rc_options=:
1679d4a3aaf4Smrg      fi
1680d4a3aaf4Smrg    done
1681862bcd1aSmrg
1682d4a3aaf4Smrg    # Save modified positional parameters for caller.  As a top-level
1683d4a3aaf4Smrg    # options-parser function we always need to set the 'func_options_result'
1684d4a3aaf4Smrg    # variable (regardless the $_G_rc_options value).
1685d4a3aaf4Smrg    if $_G_rc_options; then
1686d4a3aaf4Smrg      func_options_result=$_G_res_var
1687d4a3aaf4Smrg    else
1688d4a3aaf4Smrg      func_quote_for_eval ${1+"$@"}
1689d4a3aaf4Smrg      func_options_result=$func_quote_for_eval_result
1690d4a3aaf4Smrg    fi
1691d4a3aaf4Smrg
1692d4a3aaf4Smrg    $_G_rc_options
16931ab64890Smrg}
16941ab64890Smrg
169588de56ccSmrg
1696862bcd1aSmrg# func_options_prep [ARG]...
1697862bcd1aSmrg# --------------------------
1698862bcd1aSmrg# All initialisations required before starting the option parse loop.
1699862bcd1aSmrg# Note that when calling hook functions, we pass through the list of
1700862bcd1aSmrg# positional parameters.  If a hook function modifies that list, and
1701d4a3aaf4Smrg# needs to propagate that back to rest of this script, then the complete
1702862bcd1aSmrg# modified list must be put in 'func_run_hooks_result' before
1703d4a3aaf4Smrg# returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned).
1704862bcd1aSmrgfunc_hookable func_options_prep
1705862bcd1aSmrgfunc_options_prep ()
17061ab64890Smrg{
1707862bcd1aSmrg    $debug_cmd
170888de56ccSmrg
1709862bcd1aSmrg    # Option defaults:
1710862bcd1aSmrg    opt_verbose=false
1711862bcd1aSmrg    opt_warning_types=
171288de56ccSmrg
1713d4a3aaf4Smrg    _G_rc_options_prep=false
1714d4a3aaf4Smrg    if func_run_hooks func_options_prep ${1+"$@"}; then
1715d4a3aaf4Smrg      _G_rc_options_prep=:
1716d4a3aaf4Smrg      # save modified positional parameters for caller
1717d4a3aaf4Smrg      func_options_prep_result=$func_run_hooks_result
1718d4a3aaf4Smrg    fi
1719862bcd1aSmrg
1720d4a3aaf4Smrg    $_G_rc_options_prep
172188de56ccSmrg}
17221ab64890Smrg
1723862bcd1aSmrg
1724862bcd1aSmrg# func_parse_options [ARG]...
1725862bcd1aSmrg# ---------------------------
1726862bcd1aSmrg# The main option parsing loop.
1727862bcd1aSmrgfunc_hookable func_parse_options
1728862bcd1aSmrgfunc_parse_options ()
1729e9fcaa8aSmrg{
1730862bcd1aSmrg    $debug_cmd
1731862bcd1aSmrg
1732862bcd1aSmrg    func_parse_options_result=
1733862bcd1aSmrg
1734d4a3aaf4Smrg    _G_rc_parse_options=false
1735862bcd1aSmrg    # this just eases exit handling
1736862bcd1aSmrg    while test $# -gt 0; do
1737862bcd1aSmrg      # Defer to hook functions for initial option parsing, so they
1738862bcd1aSmrg      # get priority in the event of reusing an option name.
1739d4a3aaf4Smrg      if func_run_hooks func_parse_options ${1+"$@"}; then
1740d4a3aaf4Smrg        eval set dummy "$func_run_hooks_result"; shift
1741d4a3aaf4Smrg        _G_rc_parse_options=:
1742d4a3aaf4Smrg      fi
1743862bcd1aSmrg
1744862bcd1aSmrg      # Break out of the loop if we already parsed every option.
1745862bcd1aSmrg      test $# -gt 0 || break
1746862bcd1aSmrg
1747d4a3aaf4Smrg      _G_match_parse_options=:
1748862bcd1aSmrg      _G_opt=$1
1749862bcd1aSmrg      shift
1750862bcd1aSmrg      case $_G_opt in
1751862bcd1aSmrg        --debug|-x)   debug_cmd='set -x'
1752862bcd1aSmrg                      func_echo "enabling shell trace mode"
1753862bcd1aSmrg                      $debug_cmd
1754862bcd1aSmrg                      ;;
1755862bcd1aSmrg
1756862bcd1aSmrg        --no-warnings|--no-warning|--no-warn)
1757862bcd1aSmrg                      set dummy --warnings none ${1+"$@"}
1758862bcd1aSmrg                      shift
1759862bcd1aSmrg		      ;;
1760862bcd1aSmrg
1761862bcd1aSmrg        --warnings|--warning|-W)
1762d4a3aaf4Smrg                      if test $# = 0 && func_missing_arg $_G_opt; then
1763d4a3aaf4Smrg                        _G_rc_parse_options=:
1764d4a3aaf4Smrg                        break
1765d4a3aaf4Smrg                      fi
1766862bcd1aSmrg                      case " $warning_categories $1" in
1767862bcd1aSmrg                        *" $1 "*)
1768862bcd1aSmrg                          # trailing space prevents matching last $1 above
1769862bcd1aSmrg                          func_append_uniq opt_warning_types " $1"
1770862bcd1aSmrg                          ;;
1771862bcd1aSmrg                        *all)
1772862bcd1aSmrg                          opt_warning_types=$warning_categories
1773862bcd1aSmrg                          ;;
1774862bcd1aSmrg                        *none)
1775862bcd1aSmrg                          opt_warning_types=none
1776862bcd1aSmrg                          warning_func=:
1777862bcd1aSmrg                          ;;
1778862bcd1aSmrg                        *error)
1779862bcd1aSmrg                          opt_warning_types=$warning_categories
1780862bcd1aSmrg                          warning_func=func_fatal_error
1781862bcd1aSmrg                          ;;
1782862bcd1aSmrg                        *)
1783862bcd1aSmrg                          func_fatal_error \
1784862bcd1aSmrg                             "unsupported warning category: '$1'"
1785862bcd1aSmrg                          ;;
1786862bcd1aSmrg                      esac
1787862bcd1aSmrg                      shift
1788862bcd1aSmrg                      ;;
1789862bcd1aSmrg
1790862bcd1aSmrg        --verbose|-v) opt_verbose=: ;;
1791862bcd1aSmrg        --version)    func_version ;;
1792862bcd1aSmrg        -\?|-h)       func_usage ;;
1793862bcd1aSmrg        --help)       func_help ;;
1794862bcd1aSmrg
1795862bcd1aSmrg	# Separate optargs to long options (plugins may need this):
1796862bcd1aSmrg	--*=*)        func_split_equals "$_G_opt"
1797862bcd1aSmrg	              set dummy "$func_split_equals_lhs" \
1798862bcd1aSmrg                          "$func_split_equals_rhs" ${1+"$@"}
1799862bcd1aSmrg                      shift
1800862bcd1aSmrg                      ;;
1801862bcd1aSmrg
1802862bcd1aSmrg       # Separate optargs to short options:
1803862bcd1aSmrg        -W*)
1804862bcd1aSmrg                      func_split_short_opt "$_G_opt"
1805862bcd1aSmrg                      set dummy "$func_split_short_opt_name" \
1806862bcd1aSmrg                          "$func_split_short_opt_arg" ${1+"$@"}
1807862bcd1aSmrg                      shift
1808862bcd1aSmrg                      ;;
1809862bcd1aSmrg
1810862bcd1aSmrg        # Separate non-argument short options:
1811862bcd1aSmrg        -\?*|-h*|-v*|-x*)
1812862bcd1aSmrg                      func_split_short_opt "$_G_opt"
1813862bcd1aSmrg                      set dummy "$func_split_short_opt_name" \
1814862bcd1aSmrg                          "-$func_split_short_opt_arg" ${1+"$@"}
1815862bcd1aSmrg                      shift
1816862bcd1aSmrg                      ;;
1817862bcd1aSmrg
1818d4a3aaf4Smrg        --)           _G_rc_parse_options=: ; break ;;
1819862bcd1aSmrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
1820d4a3aaf4Smrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift
1821d4a3aaf4Smrg                      _G_match_parse_options=false
1822d4a3aaf4Smrg                      break
1823d4a3aaf4Smrg                      ;;
1824862bcd1aSmrg      esac
1825d4a3aaf4Smrg
1826d4a3aaf4Smrg      $_G_match_parse_options && _G_rc_parse_options=:
1827862bcd1aSmrg    done
1828862bcd1aSmrg
1829d4a3aaf4Smrg
1830d4a3aaf4Smrg    if $_G_rc_parse_options; then
1831d4a3aaf4Smrg      # save modified positional parameters for caller
1832d4a3aaf4Smrg      func_quote_for_eval ${1+"$@"}
1833d4a3aaf4Smrg      func_parse_options_result=$func_quote_for_eval_result
1834d4a3aaf4Smrg    fi
1835d4a3aaf4Smrg
1836d4a3aaf4Smrg    $_G_rc_parse_options
1837e9fcaa8aSmrg}
183888de56ccSmrg
183988de56ccSmrg
1840862bcd1aSmrg# func_validate_options [ARG]...
1841862bcd1aSmrg# ------------------------------
1842862bcd1aSmrg# Perform any sanity checks on option settings and/or unconsumed
1843862bcd1aSmrg# arguments.
1844862bcd1aSmrgfunc_hookable func_validate_options
1845862bcd1aSmrgfunc_validate_options ()
184688de56ccSmrg{
1847862bcd1aSmrg    $debug_cmd
1848e9fcaa8aSmrg
1849d4a3aaf4Smrg    _G_rc_validate_options=false
1850d4a3aaf4Smrg
1851862bcd1aSmrg    # Display all warnings if -W was not given.
1852862bcd1aSmrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1853862bcd1aSmrg
1854d4a3aaf4Smrg    if func_run_hooks func_validate_options ${1+"$@"}; then
1855d4a3aaf4Smrg      # save modified positional parameters for caller
1856d4a3aaf4Smrg      func_validate_options_result=$func_run_hooks_result
1857d4a3aaf4Smrg      _G_rc_validate_options=:
1858d4a3aaf4Smrg    fi
1859862bcd1aSmrg
1860862bcd1aSmrg    # Bail if the options were screwed!
1861862bcd1aSmrg    $exit_cmd $EXIT_FAILURE
1862862bcd1aSmrg
1863d4a3aaf4Smrg    $_G_rc_validate_options
186488de56ccSmrg}
186588de56ccSmrg
1866862bcd1aSmrg
1867862bcd1aSmrg
1868862bcd1aSmrg## ----------------- ##
1869862bcd1aSmrg## Helper functions. ##
1870862bcd1aSmrg## ----------------- ##
1871862bcd1aSmrg
1872862bcd1aSmrg# This section contains the helper functions used by the rest of the
1873862bcd1aSmrg# hookable option parser framework in ascii-betical order.
1874862bcd1aSmrg
1875862bcd1aSmrg
1876862bcd1aSmrg# func_fatal_help ARG...
1877862bcd1aSmrg# ----------------------
1878862bcd1aSmrg# Echo program name prefixed message to standard error, followed by
1879862bcd1aSmrg# a help hint, and exit.
1880862bcd1aSmrgfunc_fatal_help ()
188188de56ccSmrg{
1882862bcd1aSmrg    $debug_cmd
1883e9fcaa8aSmrg
1884862bcd1aSmrg    eval \$ECHO \""Usage: $usage"\"
1885862bcd1aSmrg    eval \$ECHO \""$fatal_help"\"
1886862bcd1aSmrg    func_error ${1+"$@"}
1887862bcd1aSmrg    exit $EXIT_FAILURE
188888de56ccSmrg}
188988de56ccSmrg
1890862bcd1aSmrg
1891862bcd1aSmrg# func_help
1892862bcd1aSmrg# ---------
1893862bcd1aSmrg# Echo long help message to standard output and exit.
189488de56ccSmrgfunc_help ()
189588de56ccSmrg{
1896862bcd1aSmrg    $debug_cmd
1897862bcd1aSmrg
1898862bcd1aSmrg    func_usage_message
1899862bcd1aSmrg    $ECHO "$long_help_message"
1900862bcd1aSmrg    exit 0
190188de56ccSmrg}
190288de56ccSmrg
1903862bcd1aSmrg
1904862bcd1aSmrg# func_missing_arg ARGNAME
1905862bcd1aSmrg# ------------------------
190688de56ccSmrg# Echo program name prefixed message to standard error and set global
190788de56ccSmrg# exit_cmd.
190888de56ccSmrgfunc_missing_arg ()
190988de56ccSmrg{
1910862bcd1aSmrg    $debug_cmd
1911e9fcaa8aSmrg
1912862bcd1aSmrg    func_error "Missing argument for '$1'."
191388de56ccSmrg    exit_cmd=exit
19141ab64890Smrg}
19151ab64890Smrg
19162e9c7c8cSmrg
1917862bcd1aSmrg# func_split_equals STRING
1918862bcd1aSmrg# ------------------------
1919862bcd1aSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
1920862bcd1aSmrg# splitting STRING at the '=' sign.
1921862bcd1aSmrgtest -z "$_G_HAVE_XSI_OPS" \
1922862bcd1aSmrg    && (eval 'x=a/b/c;
1923862bcd1aSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1924862bcd1aSmrg    && _G_HAVE_XSI_OPS=yes
1925862bcd1aSmrg
1926862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"
1927862bcd1aSmrgthen
1928862bcd1aSmrg  # This is an XSI compatible shell, allowing a faster implementation...
1929862bcd1aSmrg  eval 'func_split_equals ()
1930862bcd1aSmrg  {
1931862bcd1aSmrg      $debug_cmd
1932862bcd1aSmrg
1933862bcd1aSmrg      func_split_equals_lhs=${1%%=*}
1934862bcd1aSmrg      func_split_equals_rhs=${1#*=}
1935862bcd1aSmrg      test "x$func_split_equals_lhs" = "x$1" \
1936862bcd1aSmrg        && func_split_equals_rhs=
1937862bcd1aSmrg  }'
1938862bcd1aSmrgelse
1939862bcd1aSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
1940862bcd1aSmrg  func_split_equals ()
1941862bcd1aSmrg  {
1942862bcd1aSmrg      $debug_cmd
1943862bcd1aSmrg
1944862bcd1aSmrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
1945862bcd1aSmrg      func_split_equals_rhs=
1946862bcd1aSmrg      test "x$func_split_equals_lhs" = "x$1" \
1947862bcd1aSmrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
1948862bcd1aSmrg  }
1949862bcd1aSmrgfi #func_split_equals
1950862bcd1aSmrg
1951862bcd1aSmrg
1952862bcd1aSmrg# func_split_short_opt SHORTOPT
1953862bcd1aSmrg# -----------------------------
1954e9fcaa8aSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
1955e9fcaa8aSmrg# variables after splitting SHORTOPT after the 2nd character.
1956862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"
1957862bcd1aSmrgthen
1958862bcd1aSmrg  # This is an XSI compatible shell, allowing a faster implementation...
1959862bcd1aSmrg  eval 'func_split_short_opt ()
1960862bcd1aSmrg  {
1961862bcd1aSmrg      $debug_cmd
1962862bcd1aSmrg
1963862bcd1aSmrg      func_split_short_opt_arg=${1#??}
1964862bcd1aSmrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1965862bcd1aSmrg  }'
1966862bcd1aSmrgelse
1967862bcd1aSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
1968862bcd1aSmrg  func_split_short_opt ()
1969862bcd1aSmrg  {
1970862bcd1aSmrg      $debug_cmd
1971862bcd1aSmrg
1972862bcd1aSmrg      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
1973862bcd1aSmrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
1974862bcd1aSmrg  }
1975862bcd1aSmrgfi #func_split_short_opt
1976862bcd1aSmrg
1977862bcd1aSmrg
1978862bcd1aSmrg# func_usage
1979862bcd1aSmrg# ----------
1980862bcd1aSmrg# Echo short help message to standard output and exit.
1981862bcd1aSmrgfunc_usage ()
1982e9fcaa8aSmrg{
1983862bcd1aSmrg    $debug_cmd
1984e9fcaa8aSmrg
1985862bcd1aSmrg    func_usage_message
1986862bcd1aSmrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
1987862bcd1aSmrg    exit 0
1988862bcd1aSmrg}
19892e9c7c8cSmrg
199088de56ccSmrg
1991862bcd1aSmrg# func_usage_message
1992862bcd1aSmrg# ------------------
1993862bcd1aSmrg# Echo short help message to standard output.
1994862bcd1aSmrgfunc_usage_message ()
1995e9fcaa8aSmrg{
1996862bcd1aSmrg    $debug_cmd
1997e9fcaa8aSmrg
1998862bcd1aSmrg    eval \$ECHO \""Usage: $usage"\"
1999862bcd1aSmrg    echo
2000862bcd1aSmrg    $SED -n 's|^# ||
2001862bcd1aSmrg        /^Written by/{
2002862bcd1aSmrg          x;p;x
2003862bcd1aSmrg        }
2004862bcd1aSmrg	h
2005862bcd1aSmrg	/^Written by/q' < "$progpath"
2006862bcd1aSmrg    echo
2007862bcd1aSmrg    eval \$ECHO \""$usage_message"\"
2008862bcd1aSmrg}
2009e9fcaa8aSmrg
2010e9fcaa8aSmrg
2011862bcd1aSmrg# func_version
2012862bcd1aSmrg# ------------
2013862bcd1aSmrg# Echo version message to standard output and exit.
2014862bcd1aSmrgfunc_version ()
2015862bcd1aSmrg{
2016862bcd1aSmrg    $debug_cmd
201788de56ccSmrg
2018862bcd1aSmrg    printf '%s\n' "$progname $scriptversion"
2019862bcd1aSmrg    $SED -n '
2020862bcd1aSmrg        /(C)/!b go
2021862bcd1aSmrg        :more
2022862bcd1aSmrg        /\./!{
2023862bcd1aSmrg          N
2024862bcd1aSmrg          s|\n# | |
2025862bcd1aSmrg          b more
2026862bcd1aSmrg        }
2027862bcd1aSmrg        :go
2028862bcd1aSmrg        /^# Written by /,/# warranty; / {
2029862bcd1aSmrg          s|^# ||
2030862bcd1aSmrg          s|^# *$||
2031862bcd1aSmrg          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
2032862bcd1aSmrg          p
2033862bcd1aSmrg        }
2034862bcd1aSmrg        /^# Written by / {
2035862bcd1aSmrg          s|^# ||
2036862bcd1aSmrg          p
2037862bcd1aSmrg        }
2038862bcd1aSmrg        /^warranty; /q' < "$progpath"
203988de56ccSmrg
2040862bcd1aSmrg    exit $?
2041862bcd1aSmrg}
20421ab64890Smrg
20431ab64890Smrg
2044862bcd1aSmrg# Local variables:
2045862bcd1aSmrg# mode: shell-script
2046862bcd1aSmrg# sh-indentation: 2
2047862bcd1aSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
2048862bcd1aSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
2049862bcd1aSmrg# time-stamp-time-zone: "UTC"
2050862bcd1aSmrg# End:
20511ab64890Smrg
2052862bcd1aSmrg# Set a version string.
2053862bcd1aSmrgscriptversion='(GNU libtool) 2.4.6'
20542e9c7c8cSmrg
205588de56ccSmrg
2056862bcd1aSmrg# func_echo ARG...
2057862bcd1aSmrg# ----------------
2058862bcd1aSmrg# Libtool also displays the current mode in messages, so override
2059862bcd1aSmrg# funclib.sh func_echo with this custom definition.
2060862bcd1aSmrgfunc_echo ()
2061e9fcaa8aSmrg{
2062862bcd1aSmrg    $debug_cmd
2063e9fcaa8aSmrg
2064862bcd1aSmrg    _G_message=$*
2065862bcd1aSmrg
2066862bcd1aSmrg    func_echo_IFS=$IFS
2067862bcd1aSmrg    IFS=$nl
2068862bcd1aSmrg    for _G_line in $_G_message; do
2069862bcd1aSmrg      IFS=$func_echo_IFS
2070862bcd1aSmrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
2071862bcd1aSmrg    done
2072862bcd1aSmrg    IFS=$func_echo_IFS
2073862bcd1aSmrg}
2074e9fcaa8aSmrg
2075e9fcaa8aSmrg
2076862bcd1aSmrg# func_warning ARG...
2077862bcd1aSmrg# -------------------
2078862bcd1aSmrg# Libtool warnings are not categorized, so override funclib.sh
2079862bcd1aSmrg# func_warning with this simpler definition.
2080862bcd1aSmrgfunc_warning ()
2081e9fcaa8aSmrg{
2082862bcd1aSmrg    $debug_cmd
2083862bcd1aSmrg
2084862bcd1aSmrg    $warning_func ${1+"$@"}
2085862bcd1aSmrg}
2086862bcd1aSmrg
2087e9fcaa8aSmrg
2088862bcd1aSmrg## ---------------- ##
2089862bcd1aSmrg## Options parsing. ##
2090862bcd1aSmrg## ---------------- ##
2091862bcd1aSmrg
2092862bcd1aSmrg# Hook in the functions to make sure our own options are parsed during
2093862bcd1aSmrg# the option parsing loop.
2094862bcd1aSmrg
2095862bcd1aSmrgusage='$progpath [OPTION]... [MODE-ARG]...'
2096862bcd1aSmrg
2097862bcd1aSmrg# Short help message in response to '-h'.
2098862bcd1aSmrgusage_message="Options:
2099862bcd1aSmrg       --config             show all configuration variables
2100862bcd1aSmrg       --debug              enable verbose shell tracing
2101862bcd1aSmrg   -n, --dry-run            display commands without modifying any files
2102862bcd1aSmrg       --features           display basic configuration information and exit
2103862bcd1aSmrg       --mode=MODE          use operation mode MODE
2104862bcd1aSmrg       --no-warnings        equivalent to '-Wnone'
2105862bcd1aSmrg       --preserve-dup-deps  don't remove duplicate dependency libraries
2106862bcd1aSmrg       --quiet, --silent    don't print informational messages
2107862bcd1aSmrg       --tag=TAG            use configuration variables from tag TAG
2108862bcd1aSmrg   -v, --verbose            print more informational messages than default
2109862bcd1aSmrg       --version            print version information
2110862bcd1aSmrg   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
2111862bcd1aSmrg   -h, --help, --help-all   print short, long, or detailed help message
2112862bcd1aSmrg"
2113e9fcaa8aSmrg
2114862bcd1aSmrg# Additional text appended to 'usage_message' in response to '--help'.
2115862bcd1aSmrgfunc_help ()
2116e9fcaa8aSmrg{
2117862bcd1aSmrg    $debug_cmd
2118862bcd1aSmrg
2119862bcd1aSmrg    func_usage_message
2120862bcd1aSmrg    $ECHO "$long_help_message
2121862bcd1aSmrg
2122862bcd1aSmrgMODE must be one of the following:
2123862bcd1aSmrg
2124862bcd1aSmrg       clean           remove files from the build directory
2125862bcd1aSmrg       compile         compile a source file into a libtool object
2126862bcd1aSmrg       execute         automatically set library path, then run a program
2127862bcd1aSmrg       finish          complete the installation of libtool libraries
2128862bcd1aSmrg       install         install libraries or executables
2129862bcd1aSmrg       link            create a library or an executable
2130862bcd1aSmrg       uninstall       remove libraries from an installed directory
2131862bcd1aSmrg
2132862bcd1aSmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
2133862bcd1aSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2134862bcd1aSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
2135862bcd1aSmrg
2136862bcd1aSmrgWhen reporting a bug, please describe a test case to reproduce it and
2137862bcd1aSmrginclude the following information:
2138862bcd1aSmrg
2139862bcd1aSmrg       host-triplet:   $host
2140862bcd1aSmrg       shell:          $SHELL
2141862bcd1aSmrg       compiler:       $LTCC
2142862bcd1aSmrg       compiler flags: $LTCFLAGS
2143862bcd1aSmrg       linker:         $LD (gnu? $with_gnu_ld)
2144d4a3aaf4Smrg       version:        $progname $scriptversion Debian-2.4.6-14
2145862bcd1aSmrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2146862bcd1aSmrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2147862bcd1aSmrg
2148862bcd1aSmrgReport bugs to <bug-libtool@gnu.org>.
21499c019ec5SmayaGNU libtool home page: <http://www.gnu.org/s/libtool/>.
2150862bcd1aSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
2151862bcd1aSmrg    exit 0
2152862bcd1aSmrg}
2153e9fcaa8aSmrg
2154e9fcaa8aSmrg
2155862bcd1aSmrg# func_lo2o OBJECT-NAME
2156862bcd1aSmrg# ---------------------
2157862bcd1aSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2158862bcd1aSmrg# object suffix.
2159e9fcaa8aSmrg
2160862bcd1aSmrglo2o=s/\\.lo\$/.$objext/
2161862bcd1aSmrgo2lo=s/\\.$objext\$/.lo/
2162e9fcaa8aSmrg
2163862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
2164862bcd1aSmrg  eval 'func_lo2o ()
2165862bcd1aSmrg  {
2166862bcd1aSmrg    case $1 in
2167862bcd1aSmrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
2168862bcd1aSmrg      *   ) func_lo2o_result=$1               ;;
2169862bcd1aSmrg    esac
2170862bcd1aSmrg  }'
2171862bcd1aSmrg
2172862bcd1aSmrg  # func_xform LIBOBJ-OR-SOURCE
2173862bcd1aSmrg  # ---------------------------
2174862bcd1aSmrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2175862bcd1aSmrg  # suffix to a '.lo' libtool-object suffix.
2176862bcd1aSmrg  eval 'func_xform ()
2177862bcd1aSmrg  {
2178862bcd1aSmrg    func_xform_result=${1%.*}.lo
2179862bcd1aSmrg  }'
2180862bcd1aSmrgelse
2181862bcd1aSmrg  # ...otherwise fall back to using sed.
2182862bcd1aSmrg  func_lo2o ()
2183862bcd1aSmrg  {
2184862bcd1aSmrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2185862bcd1aSmrg  }
2186862bcd1aSmrg
2187862bcd1aSmrg  func_xform ()
2188862bcd1aSmrg  {
2189862bcd1aSmrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2190862bcd1aSmrg  }
2191862bcd1aSmrgfi
2192e9fcaa8aSmrg
2193e9fcaa8aSmrg
2194862bcd1aSmrg# func_fatal_configuration ARG...
2195862bcd1aSmrg# -------------------------------
219688de56ccSmrg# Echo program name prefixed message to standard error, followed by
219788de56ccSmrg# a configuration failure hint, and exit.
219888de56ccSmrgfunc_fatal_configuration ()
219988de56ccSmrg{
22009c019ec5Smaya    func__fatal_error ${1+"$@"} \
2201862bcd1aSmrg      "See the $PACKAGE documentation for more information." \
2202862bcd1aSmrg      "Fatal configuration error."
220388de56ccSmrg}
22041ab64890Smrg
22052e9c7c8cSmrg
220688de56ccSmrg# func_config
2207862bcd1aSmrg# -----------
220888de56ccSmrg# Display the configuration for all the tags in this script.
220988de56ccSmrgfunc_config ()
221088de56ccSmrg{
221188de56ccSmrg    re_begincf='^# ### BEGIN LIBTOOL'
221288de56ccSmrg    re_endcf='^# ### END LIBTOOL'
221388de56ccSmrg
221488de56ccSmrg    # Default configuration.
221588de56ccSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
22161ab64890Smrg
22171ab64890Smrg    # Now print the configurations for the tags.
22181ab64890Smrg    for tagname in $taglist; do
221988de56ccSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
22201ab64890Smrg    done
2221b4ee4795Smrg
222288de56ccSmrg    exit $?
222388de56ccSmrg}
2224b4ee4795Smrg
2225862bcd1aSmrg
222688de56ccSmrg# func_features
2227862bcd1aSmrg# -------------
222888de56ccSmrg# Display the features supported by this script.
222988de56ccSmrgfunc_features ()
223088de56ccSmrg{
2231e9fcaa8aSmrg    echo "host: $host"
2232862bcd1aSmrg    if test yes = "$build_libtool_libs"; then
2233e9fcaa8aSmrg      echo "enable shared libraries"
22341ab64890Smrg    else
2235e9fcaa8aSmrg      echo "disable shared libraries"
22361ab64890Smrg    fi
2237862bcd1aSmrg    if test yes = "$build_old_libs"; then
2238e9fcaa8aSmrg      echo "enable static libraries"
22391ab64890Smrg    else
2240e9fcaa8aSmrg      echo "disable static libraries"
22411ab64890Smrg    fi
224288de56ccSmrg
22431ab64890Smrg    exit $?
224488de56ccSmrg}
22451ab64890Smrg
2246862bcd1aSmrg
2247862bcd1aSmrg# func_enable_tag TAGNAME
2248862bcd1aSmrg# -----------------------
224988de56ccSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
225088de56ccSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
225188de56ccSmrg# variable here.
225288de56ccSmrgfunc_enable_tag ()
225388de56ccSmrg{
2254862bcd1aSmrg    # Global variable:
2255862bcd1aSmrg    tagname=$1
22561ab64890Smrg
2257862bcd1aSmrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
2258862bcd1aSmrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
2259862bcd1aSmrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
22602e9c7c8cSmrg
2261862bcd1aSmrg    # Validate tagname.
2262862bcd1aSmrg    case $tagname in
2263862bcd1aSmrg      *[!-_A-Za-z0-9,/]*)
2264862bcd1aSmrg        func_fatal_error "invalid tag name: $tagname"
2265862bcd1aSmrg        ;;
2266862bcd1aSmrg    esac
22671ab64890Smrg
2268862bcd1aSmrg    # Don't test for the "default" C tag, as we know it's
2269862bcd1aSmrg    # there but not specially marked.
2270862bcd1aSmrg    case $tagname in
2271862bcd1aSmrg        CC) ;;
227288de56ccSmrg    *)
2273862bcd1aSmrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
2274862bcd1aSmrg	  taglist="$taglist $tagname"
2275862bcd1aSmrg
2276862bcd1aSmrg	  # Evaluate the configuration.  Be careful to quote the path
2277862bcd1aSmrg	  # and the sed script, to avoid splitting on whitespace, but
2278862bcd1aSmrg	  # also don't use non-portable quotes within backquotes within
2279862bcd1aSmrg	  # quotes we have to do it in 2 steps:
2280862bcd1aSmrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
2281862bcd1aSmrg	  eval "$extractedcf"
2282862bcd1aSmrg        else
2283862bcd1aSmrg	  func_error "ignoring unknown tag $tagname"
2284862bcd1aSmrg        fi
2285862bcd1aSmrg        ;;
2286862bcd1aSmrg    esac
228788de56ccSmrg}
228888de56ccSmrg
2289862bcd1aSmrg
2290e9fcaa8aSmrg# func_check_version_match
2291862bcd1aSmrg# ------------------------
2292e9fcaa8aSmrg# Ensure that we are using m4 macros, and libtool script from the same
2293e9fcaa8aSmrg# release of libtool.
2294e9fcaa8aSmrgfunc_check_version_match ()
229588de56ccSmrg{
2296862bcd1aSmrg    if test "$package_revision" != "$macro_revision"; then
2297862bcd1aSmrg      if test "$VERSION" != "$macro_version"; then
2298862bcd1aSmrg        if test -z "$macro_version"; then
2299862bcd1aSmrg          cat >&2 <<_LT_EOF
2300e9fcaa8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2301e9fcaa8aSmrg$progname: definition of this LT_INIT comes from an older release.
2302e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2303e9fcaa8aSmrg$progname: and run autoconf again.
2304e9fcaa8aSmrg_LT_EOF
2305862bcd1aSmrg        else
2306862bcd1aSmrg          cat >&2 <<_LT_EOF
2307e9fcaa8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2308e9fcaa8aSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2309e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2310e9fcaa8aSmrg$progname: and run autoconf again.
2311e9fcaa8aSmrg_LT_EOF
2312862bcd1aSmrg        fi
2313862bcd1aSmrg      else
2314862bcd1aSmrg        cat >&2 <<_LT_EOF
2315e9fcaa8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
2316e9fcaa8aSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
2317e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
2318e9fcaa8aSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
2319e9fcaa8aSmrg_LT_EOF
2320862bcd1aSmrg      fi
2321e9fcaa8aSmrg
2322862bcd1aSmrg      exit $EXIT_MISMATCH
2323862bcd1aSmrg    fi
2324e9fcaa8aSmrg}
2325e9fcaa8aSmrg
2326e9fcaa8aSmrg
2327862bcd1aSmrg# libtool_options_prep [ARG]...
2328862bcd1aSmrg# -----------------------------
2329862bcd1aSmrg# Preparation for options parsed by libtool.
2330862bcd1aSmrglibtool_options_prep ()
2331862bcd1aSmrg{
2332862bcd1aSmrg    $debug_mode
2333b4ee4795Smrg
2334862bcd1aSmrg    # Option defaults:
2335862bcd1aSmrg    opt_config=false
2336862bcd1aSmrg    opt_dlopen=
2337862bcd1aSmrg    opt_dry_run=false
2338862bcd1aSmrg    opt_help=false
2339862bcd1aSmrg    opt_mode=
2340862bcd1aSmrg    opt_preserve_dup_deps=false
2341862bcd1aSmrg    opt_quiet=false
23421ab64890Smrg
2343862bcd1aSmrg    nonopt=
2344862bcd1aSmrg    preserve_args=
2345e9fcaa8aSmrg
2346d4a3aaf4Smrg    _G_rc_lt_options_prep=:
2347d4a3aaf4Smrg
2348862bcd1aSmrg    # Shorthand for --mode=foo, only valid as the first argument
2349862bcd1aSmrg    case $1 in
2350862bcd1aSmrg    clean|clea|cle|cl)
2351862bcd1aSmrg      shift; set dummy --mode clean ${1+"$@"}; shift
2352862bcd1aSmrg      ;;
2353862bcd1aSmrg    compile|compil|compi|comp|com|co|c)
2354862bcd1aSmrg      shift; set dummy --mode compile ${1+"$@"}; shift
2355862bcd1aSmrg      ;;
2356862bcd1aSmrg    execute|execut|execu|exec|exe|ex|e)
2357862bcd1aSmrg      shift; set dummy --mode execute ${1+"$@"}; shift
2358862bcd1aSmrg      ;;
2359862bcd1aSmrg    finish|finis|fini|fin|fi|f)
2360862bcd1aSmrg      shift; set dummy --mode finish ${1+"$@"}; shift
2361862bcd1aSmrg      ;;
2362862bcd1aSmrg    install|instal|insta|inst|ins|in|i)
2363862bcd1aSmrg      shift; set dummy --mode install ${1+"$@"}; shift
2364862bcd1aSmrg      ;;
2365862bcd1aSmrg    link|lin|li|l)
2366862bcd1aSmrg      shift; set dummy --mode link ${1+"$@"}; shift
2367862bcd1aSmrg      ;;
2368862bcd1aSmrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
2369862bcd1aSmrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
2370862bcd1aSmrg      ;;
2371d4a3aaf4Smrg    *)
2372d4a3aaf4Smrg      _G_rc_lt_options_prep=false
2373d4a3aaf4Smrg      ;;
2374862bcd1aSmrg    esac
2375862bcd1aSmrg
2376d4a3aaf4Smrg    if $_G_rc_lt_options_prep; then
2377d4a3aaf4Smrg      # Pass back the list of options.
2378d4a3aaf4Smrg      func_quote_for_eval ${1+"$@"}
2379d4a3aaf4Smrg      libtool_options_prep_result=$func_quote_for_eval_result
2380d4a3aaf4Smrg    fi
2381d4a3aaf4Smrg
2382d4a3aaf4Smrg    $_G_rc_lt_options_prep
2383862bcd1aSmrg}
2384862bcd1aSmrgfunc_add_hook func_options_prep libtool_options_prep
2385e9fcaa8aSmrg
2386e9fcaa8aSmrg
2387862bcd1aSmrg# libtool_parse_options [ARG]...
2388862bcd1aSmrg# ---------------------------------
2389862bcd1aSmrg# Provide handling for libtool specific options.
2390862bcd1aSmrglibtool_parse_options ()
2391e9fcaa8aSmrg{
2392862bcd1aSmrg    $debug_cmd
239388de56ccSmrg
2394d4a3aaf4Smrg    _G_rc_lt_parse_options=false
2395d4a3aaf4Smrg
2396862bcd1aSmrg    # Perform our own loop to consume as many options as possible in
2397862bcd1aSmrg    # each iteration.
2398862bcd1aSmrg    while test $# -gt 0; do
2399d4a3aaf4Smrg      _G_match_lt_parse_options=:
2400862bcd1aSmrg      _G_opt=$1
2401862bcd1aSmrg      shift
2402862bcd1aSmrg      case $_G_opt in
2403862bcd1aSmrg        --dry-run|--dryrun|-n)
2404862bcd1aSmrg                        opt_dry_run=:
2405862bcd1aSmrg                        ;;
2406862bcd1aSmrg
2407862bcd1aSmrg        --config)       func_config ;;
2408862bcd1aSmrg
2409862bcd1aSmrg        --dlopen|-dlopen)
2410862bcd1aSmrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
2411862bcd1aSmrg}$1"
2412862bcd1aSmrg                        shift
2413862bcd1aSmrg                        ;;
2414862bcd1aSmrg
2415862bcd1aSmrg        --preserve-dup-deps)
2416862bcd1aSmrg                        opt_preserve_dup_deps=: ;;
2417862bcd1aSmrg
2418862bcd1aSmrg        --features)     func_features ;;
2419862bcd1aSmrg
2420862bcd1aSmrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
2421862bcd1aSmrg
2422862bcd1aSmrg        --help)         opt_help=: ;;
2423862bcd1aSmrg
2424862bcd1aSmrg        --help-all)     opt_help=': help-all' ;;
2425862bcd1aSmrg
2426862bcd1aSmrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
2427862bcd1aSmrg                        opt_mode=$1
2428862bcd1aSmrg                        case $1 in
2429862bcd1aSmrg                          # Valid mode arguments:
2430862bcd1aSmrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
2431862bcd1aSmrg
2432862bcd1aSmrg                          # Catch anything else as an error
2433862bcd1aSmrg                          *) func_error "invalid argument for $_G_opt"
2434862bcd1aSmrg                             exit_cmd=exit
2435862bcd1aSmrg                             break
2436862bcd1aSmrg                             ;;
2437862bcd1aSmrg                        esac
2438862bcd1aSmrg                        shift
2439862bcd1aSmrg                        ;;
2440862bcd1aSmrg
2441862bcd1aSmrg        --no-silent|--no-quiet)
2442862bcd1aSmrg                        opt_quiet=false
2443862bcd1aSmrg                        func_append preserve_args " $_G_opt"
2444862bcd1aSmrg                        ;;
2445862bcd1aSmrg
2446862bcd1aSmrg        --no-warnings|--no-warning|--no-warn)
2447862bcd1aSmrg                        opt_warning=false
2448862bcd1aSmrg                        func_append preserve_args " $_G_opt"
2449862bcd1aSmrg                        ;;
2450862bcd1aSmrg
2451862bcd1aSmrg        --no-verbose)
2452862bcd1aSmrg                        opt_verbose=false
2453862bcd1aSmrg                        func_append preserve_args " $_G_opt"
2454862bcd1aSmrg                        ;;
2455862bcd1aSmrg
2456862bcd1aSmrg        --silent|--quiet)
2457862bcd1aSmrg                        opt_quiet=:
2458862bcd1aSmrg                        opt_verbose=false
2459862bcd1aSmrg                        func_append preserve_args " $_G_opt"
2460862bcd1aSmrg                        ;;
2461862bcd1aSmrg
2462862bcd1aSmrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
2463862bcd1aSmrg                        opt_tag=$1
2464862bcd1aSmrg                        func_append preserve_args " $_G_opt $1"
2465862bcd1aSmrg                        func_enable_tag "$1"
2466862bcd1aSmrg                        shift
2467862bcd1aSmrg                        ;;
2468862bcd1aSmrg
2469862bcd1aSmrg        --verbose|-v)   opt_quiet=false
2470862bcd1aSmrg                        opt_verbose=:
2471862bcd1aSmrg                        func_append preserve_args " $_G_opt"
2472862bcd1aSmrg                        ;;
2473862bcd1aSmrg
2474d4a3aaf4Smrg        # An option not handled by this hook function:
2475d4a3aaf4Smrg        *)              set dummy "$_G_opt" ${1+"$@"} ; shift
2476d4a3aaf4Smrg                        _G_match_lt_parse_options=false
2477d4a3aaf4Smrg                        break
2478d4a3aaf4Smrg                        ;;
2479862bcd1aSmrg      esac
2480d4a3aaf4Smrg      $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
2481862bcd1aSmrg    done
2482e9fcaa8aSmrg
2483d4a3aaf4Smrg    if $_G_rc_lt_parse_options; then
2484d4a3aaf4Smrg      # save modified positional parameters for caller
2485d4a3aaf4Smrg      func_quote_for_eval ${1+"$@"}
2486d4a3aaf4Smrg      libtool_parse_options_result=$func_quote_for_eval_result
2487d4a3aaf4Smrg    fi
2488e9fcaa8aSmrg
2489d4a3aaf4Smrg    $_G_rc_lt_parse_options
2490862bcd1aSmrg}
2491862bcd1aSmrgfunc_add_hook func_parse_options libtool_parse_options
249288de56ccSmrg
24932e9c7c8cSmrg
249488de56ccSmrg
2495862bcd1aSmrg# libtool_validate_options [ARG]...
2496862bcd1aSmrg# ---------------------------------
2497862bcd1aSmrg# Perform any sanity checks on option settings and/or unconsumed
2498862bcd1aSmrg# arguments.
2499862bcd1aSmrglibtool_validate_options ()
2500862bcd1aSmrg{
2501862bcd1aSmrg    # save first non-option argument
2502862bcd1aSmrg    if test 0 -lt $#; then
2503862bcd1aSmrg      nonopt=$1
2504862bcd1aSmrg      shift
250588de56ccSmrg    fi
250688de56ccSmrg
2507862bcd1aSmrg    # preserve --debug
2508862bcd1aSmrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
250988de56ccSmrg
2510862bcd1aSmrg    case $host in
2511862bcd1aSmrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
2512862bcd1aSmrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
2513862bcd1aSmrg      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
2514862bcd1aSmrg        # don't eliminate duplications in $postdeps and $predeps
2515862bcd1aSmrg        opt_duplicate_compiler_generated_deps=:
2516862bcd1aSmrg        ;;
2517862bcd1aSmrg      *)
2518862bcd1aSmrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
2519862bcd1aSmrg        ;;
2520862bcd1aSmrg    esac
25211ab64890Smrg
2522862bcd1aSmrg    $opt_help || {
2523862bcd1aSmrg      # Sanity checks first:
2524862bcd1aSmrg      func_check_version_match
252588de56ccSmrg
2526862bcd1aSmrg      test yes != "$build_libtool_libs" \
2527862bcd1aSmrg        && test yes != "$build_old_libs" \
2528862bcd1aSmrg        && func_fatal_configuration "not configured to build any kind of library"
252988de56ccSmrg
2530862bcd1aSmrg      # Darwin sucks
2531862bcd1aSmrg      eval std_shrext=\"$shrext_cmds\"
2532862bcd1aSmrg
2533862bcd1aSmrg      # Only execute mode is allowed to have -dlopen flags.
2534862bcd1aSmrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
2535862bcd1aSmrg        func_error "unrecognized option '-dlopen'"
2536862bcd1aSmrg        $ECHO "$help" 1>&2
2537862bcd1aSmrg        exit $EXIT_FAILURE
2538862bcd1aSmrg      fi
2539862bcd1aSmrg
2540862bcd1aSmrg      # Change the help message to a mode-specific one.
2541862bcd1aSmrg      generic_help=$help
2542862bcd1aSmrg      help="Try '$progname --help --mode=$opt_mode' for more information."
2543862bcd1aSmrg    }
2544862bcd1aSmrg
2545862bcd1aSmrg    # Pass back the unparsed argument list
2546862bcd1aSmrg    func_quote_for_eval ${1+"$@"}
2547862bcd1aSmrg    libtool_validate_options_result=$func_quote_for_eval_result
2548e9fcaa8aSmrg}
2549862bcd1aSmrgfunc_add_hook func_validate_options libtool_validate_options
2550862bcd1aSmrg
255188de56ccSmrg
2552862bcd1aSmrg# Process options as early as possible so that --help and --version
2553862bcd1aSmrg# can return quickly.
2554862bcd1aSmrgfunc_options ${1+"$@"}
2555862bcd1aSmrgeval set dummy "$func_options_result"; shift
255688de56ccSmrg
25571ab64890Smrg
25581ab64890Smrg
2559e9fcaa8aSmrg## ----------- ##
2560e9fcaa8aSmrg##    Main.    ##
2561e9fcaa8aSmrg## ----------- ##
25621ab64890Smrg
2563862bcd1aSmrgmagic='%%%MAGIC variable%%%'
2564862bcd1aSmrgmagic_exe='%%%MAGIC EXE variable%%%'
2565862bcd1aSmrg
2566862bcd1aSmrg# Global variables.
2567862bcd1aSmrgextracted_archives=
2568862bcd1aSmrgextracted_serial=0
2569862bcd1aSmrg
2570862bcd1aSmrg# If this variable is set in any of the actions, the command in it
2571862bcd1aSmrg# will be execed at the end.  This prevents here-documents from being
2572862bcd1aSmrg# left over by shells.
2573862bcd1aSmrgexec_cmd=
2574862bcd1aSmrg
2575862bcd1aSmrg
2576862bcd1aSmrg# A function that is used when there is no print builtin or printf.
2577862bcd1aSmrgfunc_fallback_echo ()
2578862bcd1aSmrg{
2579862bcd1aSmrg  eval 'cat <<_LTECHO_EOF
2580862bcd1aSmrg$1
2581862bcd1aSmrg_LTECHO_EOF'
2582862bcd1aSmrg}
2583862bcd1aSmrg
2584862bcd1aSmrg# func_generated_by_libtool
2585862bcd1aSmrg# True iff stdin has been generated by Libtool. This function is only
2586862bcd1aSmrg# a basic sanity check; it will hardly flush out determined imposters.
2587862bcd1aSmrgfunc_generated_by_libtool_p ()
2588862bcd1aSmrg{
2589862bcd1aSmrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
2590862bcd1aSmrg}
2591862bcd1aSmrg
259288de56ccSmrg# func_lalib_p file
2593862bcd1aSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
259488de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
259588de56ccSmrg# determined imposters.
259688de56ccSmrgfunc_lalib_p ()
259788de56ccSmrg{
259888de56ccSmrg    test -f "$1" &&
2599862bcd1aSmrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
260088de56ccSmrg}
26011ab64890Smrg
260288de56ccSmrg# func_lalib_unsafe_p file
2603862bcd1aSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
260488de56ccSmrg# This function implements the same check as func_lalib_p without
260588de56ccSmrg# resorting to external programs.  To this end, it redirects stdin and
260688de56ccSmrg# closes it afterwards, without saving the original file descriptor.
260788de56ccSmrg# As a safety measure, use it only where a negative result would be
2608862bcd1aSmrg# fatal anyway.  Works if 'file' does not exist.
260988de56ccSmrgfunc_lalib_unsafe_p ()
261088de56ccSmrg{
261188de56ccSmrg    lalib_p=no
261288de56ccSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
261388de56ccSmrg	for lalib_p_l in 1 2 3 4
261488de56ccSmrg	do
261588de56ccSmrg	    read lalib_p_line
2616862bcd1aSmrg	    case $lalib_p_line in
261788de56ccSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
261888de56ccSmrg	    esac
261988de56ccSmrg	done
262088de56ccSmrg	exec 0<&5 5<&-
262188de56ccSmrg    fi
2622862bcd1aSmrg    test yes = "$lalib_p"
262388de56ccSmrg}
26241ab64890Smrg
262588de56ccSmrg# func_ltwrapper_script_p file
262688de56ccSmrg# True iff FILE is a libtool wrapper script
262788de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
262888de56ccSmrg# determined imposters.
262988de56ccSmrgfunc_ltwrapper_script_p ()
263088de56ccSmrg{
2631862bcd1aSmrg    test -f "$1" &&
2632862bcd1aSmrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
263388de56ccSmrg}
26341ab64890Smrg
263588de56ccSmrg# func_ltwrapper_executable_p file
263688de56ccSmrg# True iff FILE is a libtool wrapper executable
263788de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
263888de56ccSmrg# determined imposters.
263988de56ccSmrgfunc_ltwrapper_executable_p ()
264088de56ccSmrg{
264188de56ccSmrg    func_ltwrapper_exec_suffix=
264288de56ccSmrg    case $1 in
264388de56ccSmrg    *.exe) ;;
264488de56ccSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
264588de56ccSmrg    esac
264688de56ccSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
264788de56ccSmrg}
26482e9c7c8cSmrg
264988de56ccSmrg# func_ltwrapper_scriptname file
265088de56ccSmrg# Assumes file is an ltwrapper_executable
265188de56ccSmrg# uses $file to determine the appropriate filename for a
265288de56ccSmrg# temporary ltwrapper_script.
265388de56ccSmrgfunc_ltwrapper_scriptname ()
265488de56ccSmrg{
2655e9fcaa8aSmrg    func_dirname_and_basename "$1" "" "."
2656e9fcaa8aSmrg    func_stripname '' '.exe' "$func_basename_result"
2657862bcd1aSmrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
265888de56ccSmrg}
265988de56ccSmrg
266088de56ccSmrg# func_ltwrapper_p file
266188de56ccSmrg# True iff FILE is a libtool wrapper script or wrapper executable
266288de56ccSmrg# This function is only a basic sanity check; it will hardly flush out
266388de56ccSmrg# determined imposters.
266488de56ccSmrgfunc_ltwrapper_p ()
266588de56ccSmrg{
266688de56ccSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
266788de56ccSmrg}
266888de56ccSmrg
266988de56ccSmrg
267088de56ccSmrg# func_execute_cmds commands fail_cmd
267188de56ccSmrg# Execute tilde-delimited COMMANDS.
267288de56ccSmrg# If FAIL_CMD is given, eval that upon failure.
267388de56ccSmrg# FAIL_CMD may read-access the current command in variable CMD!
267488de56ccSmrgfunc_execute_cmds ()
267588de56ccSmrg{
2676862bcd1aSmrg    $debug_cmd
2677862bcd1aSmrg
267888de56ccSmrg    save_ifs=$IFS; IFS='~'
267988de56ccSmrg    for cmd in $1; do
2680862bcd1aSmrg      IFS=$sp$nl
268188de56ccSmrg      eval cmd=\"$cmd\"
2682862bcd1aSmrg      IFS=$save_ifs
268388de56ccSmrg      func_show_eval "$cmd" "${2-:}"
268488de56ccSmrg    done
268588de56ccSmrg    IFS=$save_ifs
268688de56ccSmrg}
268788de56ccSmrg
268888de56ccSmrg
268988de56ccSmrg# func_source file
269088de56ccSmrg# Source FILE, adding directory component if necessary.
269188de56ccSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
269288de56ccSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
269388de56ccSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
2694862bcd1aSmrg# 'FILE.' does not work on cygwin managed mounts.
269588de56ccSmrgfunc_source ()
269688de56ccSmrg{
2697862bcd1aSmrg    $debug_cmd
2698862bcd1aSmrg
269988de56ccSmrg    case $1 in
270088de56ccSmrg    */* | *\\*)	. "$1" ;;
270188de56ccSmrg    *)		. "./$1" ;;
270288de56ccSmrg    esac
270388de56ccSmrg}
270488de56ccSmrg
270588de56ccSmrg
2706e9fcaa8aSmrg# func_resolve_sysroot PATH
2707e9fcaa8aSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
2708e9fcaa8aSmrg# func_resolve_sysroot_result
2709e9fcaa8aSmrgfunc_resolve_sysroot ()
2710e9fcaa8aSmrg{
2711e9fcaa8aSmrg  func_resolve_sysroot_result=$1
2712e9fcaa8aSmrg  case $func_resolve_sysroot_result in
2713e9fcaa8aSmrg  =*)
2714e9fcaa8aSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
2715e9fcaa8aSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2716e9fcaa8aSmrg    ;;
2717e9fcaa8aSmrg  esac
2718e9fcaa8aSmrg}
2719e9fcaa8aSmrg
2720e9fcaa8aSmrg# func_replace_sysroot PATH
2721e9fcaa8aSmrg# If PATH begins with the sysroot, replace it with = and
2722e9fcaa8aSmrg# store the result into func_replace_sysroot_result.
2723e9fcaa8aSmrgfunc_replace_sysroot ()
2724e9fcaa8aSmrg{
2725862bcd1aSmrg  case $lt_sysroot:$1 in
2726e9fcaa8aSmrg  ?*:"$lt_sysroot"*)
2727e9fcaa8aSmrg    func_stripname "$lt_sysroot" '' "$1"
2728862bcd1aSmrg    func_replace_sysroot_result='='$func_stripname_result
2729e9fcaa8aSmrg    ;;
2730e9fcaa8aSmrg  *)
2731e9fcaa8aSmrg    # Including no sysroot.
2732e9fcaa8aSmrg    func_replace_sysroot_result=$1
2733e9fcaa8aSmrg    ;;
2734e9fcaa8aSmrg  esac
2735e9fcaa8aSmrg}
2736e9fcaa8aSmrg
273788de56ccSmrg# func_infer_tag arg
273888de56ccSmrg# Infer tagged configuration to use if any are available and
273988de56ccSmrg# if one wasn't chosen via the "--tag" command line option.
274088de56ccSmrg# Only attempt this if the compiler in the base compile
274188de56ccSmrg# command doesn't match the default compiler.
274288de56ccSmrg# arg is usually of the form 'gcc ...'
274388de56ccSmrgfunc_infer_tag ()
274488de56ccSmrg{
2745862bcd1aSmrg    $debug_cmd
2746862bcd1aSmrg
274788de56ccSmrg    if test -n "$available_tags" && test -z "$tagname"; then
274888de56ccSmrg      CC_quoted=
274988de56ccSmrg      for arg in $CC; do
2750e9fcaa8aSmrg	func_append_quoted CC_quoted "$arg"
275188de56ccSmrg      done
2752e9fcaa8aSmrg      CC_expanded=`func_echo_all $CC`
2753e9fcaa8aSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
275488de56ccSmrg      case $@ in
275588de56ccSmrg      # Blanks in the command may have been stripped by the calling shell,
275688de56ccSmrg      # but not from the CC environment variable when configure was run.
2757e9fcaa8aSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2758e9fcaa8aSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
275988de56ccSmrg      # Blanks at the start of $base_compile will cause this to fail
276088de56ccSmrg      # if we don't check for them as well.
276188de56ccSmrg      *)
276288de56ccSmrg	for z in $available_tags; do
276388de56ccSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
276488de56ccSmrg	    # Evaluate the configuration.
2765862bcd1aSmrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
276688de56ccSmrg	    CC_quoted=
276788de56ccSmrg	    for arg in $CC; do
276888de56ccSmrg	      # Double-quote args containing other shell metacharacters.
2769e9fcaa8aSmrg	      func_append_quoted CC_quoted "$arg"
277088de56ccSmrg	    done
2771e9fcaa8aSmrg	    CC_expanded=`func_echo_all $CC`
2772e9fcaa8aSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
277388de56ccSmrg	    case "$@ " in
2774e9fcaa8aSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2775e9fcaa8aSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
277688de56ccSmrg	      # The compiler in the base compile command matches
277788de56ccSmrg	      # the one in the tagged configuration.
277888de56ccSmrg	      # Assume this is the tagged configuration we want.
277988de56ccSmrg	      tagname=$z
278088de56ccSmrg	      break
278188de56ccSmrg	      ;;
278288de56ccSmrg	    esac
278388de56ccSmrg	  fi
278488de56ccSmrg	done
278588de56ccSmrg	# If $tagname still isn't set, then no tagged configuration
278688de56ccSmrg	# was found and let the user know that the "--tag" command
278788de56ccSmrg	# line option must be used.
278888de56ccSmrg	if test -z "$tagname"; then
278988de56ccSmrg	  func_echo "unable to infer tagged configuration"
2790862bcd1aSmrg	  func_fatal_error "specify a tag with '--tag'"
279188de56ccSmrg#	else
279288de56ccSmrg#	  func_verbose "using $tagname tagged configuration"
279388de56ccSmrg	fi
279488de56ccSmrg	;;
279588de56ccSmrg      esac
279688de56ccSmrg    fi
279788de56ccSmrg}
279888de56ccSmrg
279988de56ccSmrg
280088de56ccSmrg
280188de56ccSmrg# func_write_libtool_object output_name pic_name nonpic_name
280288de56ccSmrg# Create a libtool object file (analogous to a ".la" file),
280388de56ccSmrg# but don't create it if we're doing a dry run.
280488de56ccSmrgfunc_write_libtool_object ()
280588de56ccSmrg{
2806862bcd1aSmrg    write_libobj=$1
2807862bcd1aSmrg    if test yes = "$build_libtool_libs"; then
2808862bcd1aSmrg      write_lobj=\'$2\'
280988de56ccSmrg    else
281088de56ccSmrg      write_lobj=none
281188de56ccSmrg    fi
281288de56ccSmrg
2813862bcd1aSmrg    if test yes = "$build_old_libs"; then
2814862bcd1aSmrg      write_oldobj=\'$3\'
281588de56ccSmrg    else
281688de56ccSmrg      write_oldobj=none
281788de56ccSmrg    fi
281888de56ccSmrg
281988de56ccSmrg    $opt_dry_run || {
282088de56ccSmrg      cat >${write_libobj}T <<EOF
282188de56ccSmrg# $write_libobj - a libtool object file
2822862bcd1aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
282388de56ccSmrg#
282488de56ccSmrg# Please DO NOT delete this file!
282588de56ccSmrg# It is necessary for linking the library.
282688de56ccSmrg
282788de56ccSmrg# Name of the PIC object.
282888de56ccSmrgpic_object=$write_lobj
282988de56ccSmrg
283088de56ccSmrg# Name of the non-PIC object
283188de56ccSmrgnon_pic_object=$write_oldobj
283288de56ccSmrg
283388de56ccSmrgEOF
2834862bcd1aSmrg      $MV "${write_libobj}T" "$write_libobj"
283588de56ccSmrg    }
283688de56ccSmrg}
283788de56ccSmrg
2838e9fcaa8aSmrg
2839e9fcaa8aSmrg##################################################
2840e9fcaa8aSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2841e9fcaa8aSmrg##################################################
2842e9fcaa8aSmrg
2843e9fcaa8aSmrg# func_convert_core_file_wine_to_w32 ARG
2844e9fcaa8aSmrg# Helper function used by file name conversion functions when $build is *nix,
2845e9fcaa8aSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
2846e9fcaa8aSmrg# correctly configured wine environment available, with the winepath program
2847e9fcaa8aSmrg# in $build's $PATH.
2848e9fcaa8aSmrg#
2849e9fcaa8aSmrg# ARG is the $build file name to be converted to w32 format.
2850e9fcaa8aSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
2851e9fcaa8aSmrg# be empty on error (or when ARG is empty)
2852e9fcaa8aSmrgfunc_convert_core_file_wine_to_w32 ()
2853e9fcaa8aSmrg{
2854862bcd1aSmrg  $debug_cmd
2855862bcd1aSmrg
2856862bcd1aSmrg  func_convert_core_file_wine_to_w32_result=$1
2857e9fcaa8aSmrg  if test -n "$1"; then
2858e9fcaa8aSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
2859e9fcaa8aSmrg    # are forced to check the contents of stdout. On the other hand, if the
2860e9fcaa8aSmrg    # command is not found, the shell will set an exit code of 127 and print
2861e9fcaa8aSmrg    # *an error message* to stdout. So we must check for both error code of
2862e9fcaa8aSmrg    # zero AND non-empty stdout, which explains the odd construction:
2863e9fcaa8aSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
2864862bcd1aSmrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2865e9fcaa8aSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
2866862bcd1aSmrg        $SED -e "$sed_naive_backslashify"`
2867e9fcaa8aSmrg    else
2868e9fcaa8aSmrg      func_convert_core_file_wine_to_w32_result=
2869e9fcaa8aSmrg    fi
2870e9fcaa8aSmrg  fi
2871e9fcaa8aSmrg}
2872e9fcaa8aSmrg# end: func_convert_core_file_wine_to_w32
2873e9fcaa8aSmrg
2874e9fcaa8aSmrg
2875e9fcaa8aSmrg# func_convert_core_path_wine_to_w32 ARG
2876e9fcaa8aSmrg# Helper function used by path conversion functions when $build is *nix, and
2877e9fcaa8aSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2878e9fcaa8aSmrg# configured wine environment available, with the winepath program in $build's
2879e9fcaa8aSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
2880e9fcaa8aSmrg#
2881e9fcaa8aSmrg# ARG is path to be converted from $build format to win32.
2882e9fcaa8aSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
2883e9fcaa8aSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
2884e9fcaa8aSmrg# are convertible, then the result may be empty.
2885e9fcaa8aSmrgfunc_convert_core_path_wine_to_w32 ()
2886e9fcaa8aSmrg{
2887862bcd1aSmrg  $debug_cmd
2888862bcd1aSmrg
2889e9fcaa8aSmrg  # unfortunately, winepath doesn't convert paths, only file names
2890862bcd1aSmrg  func_convert_core_path_wine_to_w32_result=
2891e9fcaa8aSmrg  if test -n "$1"; then
2892e9fcaa8aSmrg    oldIFS=$IFS
2893e9fcaa8aSmrg    IFS=:
2894e9fcaa8aSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
2895e9fcaa8aSmrg      IFS=$oldIFS
2896e9fcaa8aSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
2897862bcd1aSmrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
2898e9fcaa8aSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
2899862bcd1aSmrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2900e9fcaa8aSmrg        else
2901e9fcaa8aSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2902e9fcaa8aSmrg        fi
2903e9fcaa8aSmrg      fi
2904e9fcaa8aSmrg    done
2905e9fcaa8aSmrg    IFS=$oldIFS
2906e9fcaa8aSmrg  fi
2907e9fcaa8aSmrg}
2908e9fcaa8aSmrg# end: func_convert_core_path_wine_to_w32
2909e9fcaa8aSmrg
2910e9fcaa8aSmrg
2911e9fcaa8aSmrg# func_cygpath ARGS...
2912e9fcaa8aSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2913e9fcaa8aSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2914e9fcaa8aSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2915e9fcaa8aSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
2916e9fcaa8aSmrg# file name or path is assumed to be in w32 format, as previously converted
2917e9fcaa8aSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
2918e9fcaa8aSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
2919e9fcaa8aSmrg# Cygwin format). Returns an empty string on error.
2920e9fcaa8aSmrg#
2921e9fcaa8aSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
2922e9fcaa8aSmrg# be converted.
2923e9fcaa8aSmrg#
2924e9fcaa8aSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2925e9fcaa8aSmrg# environment variable; do not put it in $PATH.
2926e9fcaa8aSmrgfunc_cygpath ()
2927e9fcaa8aSmrg{
2928862bcd1aSmrg  $debug_cmd
2929862bcd1aSmrg
2930e9fcaa8aSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2931e9fcaa8aSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2932e9fcaa8aSmrg    if test "$?" -ne 0; then
2933e9fcaa8aSmrg      # on failure, ensure result is empty
2934e9fcaa8aSmrg      func_cygpath_result=
2935e9fcaa8aSmrg    fi
2936e9fcaa8aSmrg  else
2937e9fcaa8aSmrg    func_cygpath_result=
2938862bcd1aSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2939e9fcaa8aSmrg  fi
2940e9fcaa8aSmrg}
2941e9fcaa8aSmrg#end: func_cygpath
2942e9fcaa8aSmrg
2943e9fcaa8aSmrg
2944e9fcaa8aSmrg# func_convert_core_msys_to_w32 ARG
2945e9fcaa8aSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
2946e9fcaa8aSmrg# result in func_convert_core_msys_to_w32_result.
2947e9fcaa8aSmrgfunc_convert_core_msys_to_w32 ()
2948e9fcaa8aSmrg{
2949862bcd1aSmrg  $debug_cmd
2950862bcd1aSmrg
2951e9fcaa8aSmrg  # awkward: cmd appends spaces to result
2952e9fcaa8aSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
2953862bcd1aSmrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2954e9fcaa8aSmrg}
2955e9fcaa8aSmrg#end: func_convert_core_msys_to_w32
2956e9fcaa8aSmrg
2957e9fcaa8aSmrg
2958e9fcaa8aSmrg# func_convert_file_check ARG1 ARG2
2959e9fcaa8aSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
2960e9fcaa8aSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
2961e9fcaa8aSmrg# func_to_host_file_result to ARG1).
2962e9fcaa8aSmrgfunc_convert_file_check ()
2963e9fcaa8aSmrg{
2964862bcd1aSmrg  $debug_cmd
2965862bcd1aSmrg
2966862bcd1aSmrg  if test -z "$2" && test -n "$1"; then
2967e9fcaa8aSmrg    func_error "Could not determine host file name corresponding to"
2968862bcd1aSmrg    func_error "  '$1'"
2969e9fcaa8aSmrg    func_error "Continuing, but uninstalled executables may not work."
2970e9fcaa8aSmrg    # Fallback:
2971862bcd1aSmrg    func_to_host_file_result=$1
2972e9fcaa8aSmrg  fi
2973e9fcaa8aSmrg}
2974e9fcaa8aSmrg# end func_convert_file_check
2975e9fcaa8aSmrg
2976e9fcaa8aSmrg
2977e9fcaa8aSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2978e9fcaa8aSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
2979e9fcaa8aSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2980e9fcaa8aSmrg# func_to_host_file_result to a simplistic fallback value (see below).
2981e9fcaa8aSmrgfunc_convert_path_check ()
2982e9fcaa8aSmrg{
2983862bcd1aSmrg  $debug_cmd
2984862bcd1aSmrg
2985e9fcaa8aSmrg  if test -z "$4" && test -n "$3"; then
2986e9fcaa8aSmrg    func_error "Could not determine the host path corresponding to"
2987862bcd1aSmrg    func_error "  '$3'"
2988e9fcaa8aSmrg    func_error "Continuing, but uninstalled executables may not work."
2989e9fcaa8aSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
2990e9fcaa8aSmrg    # should not be "improved".  See libtool.info.
2991e9fcaa8aSmrg    if test "x$1" != "x$2"; then
2992e9fcaa8aSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
2993e9fcaa8aSmrg      func_to_host_path_result=`echo "$3" |
2994e9fcaa8aSmrg        $SED -e "$lt_replace_pathsep_chars"`
2995e9fcaa8aSmrg    else
2996862bcd1aSmrg      func_to_host_path_result=$3
2997e9fcaa8aSmrg    fi
2998e9fcaa8aSmrg  fi
2999e9fcaa8aSmrg}
3000e9fcaa8aSmrg# end func_convert_path_check
3001e9fcaa8aSmrg
3002e9fcaa8aSmrg
3003e9fcaa8aSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
3004e9fcaa8aSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
3005e9fcaa8aSmrg# and appending REPL if ORIG matches BACKPAT.
3006e9fcaa8aSmrgfunc_convert_path_front_back_pathsep ()
3007e9fcaa8aSmrg{
3008862bcd1aSmrg  $debug_cmd
3009862bcd1aSmrg
3010e9fcaa8aSmrg  case $4 in
3011862bcd1aSmrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
3012e9fcaa8aSmrg    ;;
3013e9fcaa8aSmrg  esac
3014e9fcaa8aSmrg  case $4 in
3015e9fcaa8aSmrg  $2 ) func_append func_to_host_path_result "$3"
3016e9fcaa8aSmrg    ;;
3017e9fcaa8aSmrg  esac
3018e9fcaa8aSmrg}
3019e9fcaa8aSmrg# end func_convert_path_front_back_pathsep
3020e9fcaa8aSmrg
3021e9fcaa8aSmrg
3022e9fcaa8aSmrg##################################################
3023e9fcaa8aSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
3024e9fcaa8aSmrg##################################################
3025862bcd1aSmrg# invoked via '$to_host_file_cmd ARG'
3026e9fcaa8aSmrg#
3027e9fcaa8aSmrg# In each case, ARG is the path to be converted from $build to $host format.
3028e9fcaa8aSmrg# Result will be available in $func_to_host_file_result.
3029e9fcaa8aSmrg
3030e9fcaa8aSmrg
3031e9fcaa8aSmrg# func_to_host_file ARG
3032e9fcaa8aSmrg# Converts the file name ARG from $build format to $host format. Return result
3033e9fcaa8aSmrg# in func_to_host_file_result.
3034e9fcaa8aSmrgfunc_to_host_file ()
3035e9fcaa8aSmrg{
3036862bcd1aSmrg  $debug_cmd
3037862bcd1aSmrg
3038e9fcaa8aSmrg  $to_host_file_cmd "$1"
3039e9fcaa8aSmrg}
3040e9fcaa8aSmrg# end func_to_host_file
3041e9fcaa8aSmrg
3042e9fcaa8aSmrg
3043e9fcaa8aSmrg# func_to_tool_file ARG LAZY
3044e9fcaa8aSmrg# converts the file name ARG from $build format to toolchain format. Return
3045e9fcaa8aSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
3046e9fcaa8aSmrg# in (the comma separated) LAZY, no conversion takes place.
3047e9fcaa8aSmrgfunc_to_tool_file ()
3048e9fcaa8aSmrg{
3049862bcd1aSmrg  $debug_cmd
3050862bcd1aSmrg
3051e9fcaa8aSmrg  case ,$2, in
3052e9fcaa8aSmrg    *,"$to_tool_file_cmd",*)
3053e9fcaa8aSmrg      func_to_tool_file_result=$1
3054e9fcaa8aSmrg      ;;
3055e9fcaa8aSmrg    *)
3056e9fcaa8aSmrg      $to_tool_file_cmd "$1"
3057e9fcaa8aSmrg      func_to_tool_file_result=$func_to_host_file_result
3058e9fcaa8aSmrg      ;;
3059e9fcaa8aSmrg  esac
3060e9fcaa8aSmrg}
3061e9fcaa8aSmrg# end func_to_tool_file
3062e9fcaa8aSmrg
3063e9fcaa8aSmrg
3064e9fcaa8aSmrg# func_convert_file_noop ARG
3065e9fcaa8aSmrg# Copy ARG to func_to_host_file_result.
3066e9fcaa8aSmrgfunc_convert_file_noop ()
3067e9fcaa8aSmrg{
3068862bcd1aSmrg  func_to_host_file_result=$1
3069e9fcaa8aSmrg}
3070e9fcaa8aSmrg# end func_convert_file_noop
3071e9fcaa8aSmrg
3072e9fcaa8aSmrg
3073e9fcaa8aSmrg# func_convert_file_msys_to_w32 ARG
3074e9fcaa8aSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
3075e9fcaa8aSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3076e9fcaa8aSmrg# func_to_host_file_result.
3077e9fcaa8aSmrgfunc_convert_file_msys_to_w32 ()
3078e9fcaa8aSmrg{
3079862bcd1aSmrg  $debug_cmd
3080862bcd1aSmrg
3081862bcd1aSmrg  func_to_host_file_result=$1
3082e9fcaa8aSmrg  if test -n "$1"; then
3083e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$1"
3084862bcd1aSmrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
3085e9fcaa8aSmrg  fi
3086e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3087e9fcaa8aSmrg}
3088e9fcaa8aSmrg# end func_convert_file_msys_to_w32
3089e9fcaa8aSmrg
3090e9fcaa8aSmrg
3091e9fcaa8aSmrg# func_convert_file_cygwin_to_w32 ARG
3092e9fcaa8aSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
3093e9fcaa8aSmrg# func_to_host_file_result.
3094e9fcaa8aSmrgfunc_convert_file_cygwin_to_w32 ()
3095e9fcaa8aSmrg{
3096862bcd1aSmrg  $debug_cmd
3097862bcd1aSmrg
3098862bcd1aSmrg  func_to_host_file_result=$1
3099e9fcaa8aSmrg  if test -n "$1"; then
3100e9fcaa8aSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3101e9fcaa8aSmrg    # LT_CYGPATH in this case.
3102e9fcaa8aSmrg    func_to_host_file_result=`cygpath -m "$1"`
3103e9fcaa8aSmrg  fi
3104e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3105e9fcaa8aSmrg}
3106e9fcaa8aSmrg# end func_convert_file_cygwin_to_w32
3107e9fcaa8aSmrg
3108e9fcaa8aSmrg
3109e9fcaa8aSmrg# func_convert_file_nix_to_w32 ARG
3110e9fcaa8aSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
3111e9fcaa8aSmrg# and a working winepath. Returns result in func_to_host_file_result.
3112e9fcaa8aSmrgfunc_convert_file_nix_to_w32 ()
3113e9fcaa8aSmrg{
3114862bcd1aSmrg  $debug_cmd
3115862bcd1aSmrg
3116862bcd1aSmrg  func_to_host_file_result=$1
3117e9fcaa8aSmrg  if test -n "$1"; then
3118e9fcaa8aSmrg    func_convert_core_file_wine_to_w32 "$1"
3119862bcd1aSmrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3120e9fcaa8aSmrg  fi
3121e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3122e9fcaa8aSmrg}
3123e9fcaa8aSmrg# end func_convert_file_nix_to_w32
3124e9fcaa8aSmrg
3125e9fcaa8aSmrg
3126e9fcaa8aSmrg# func_convert_file_msys_to_cygwin ARG
3127e9fcaa8aSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3128e9fcaa8aSmrg# Returns result in func_to_host_file_result.
3129e9fcaa8aSmrgfunc_convert_file_msys_to_cygwin ()
3130e9fcaa8aSmrg{
3131862bcd1aSmrg  $debug_cmd
3132862bcd1aSmrg
3133862bcd1aSmrg  func_to_host_file_result=$1
3134e9fcaa8aSmrg  if test -n "$1"; then
3135e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$1"
3136e9fcaa8aSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
3137862bcd1aSmrg    func_to_host_file_result=$func_cygpath_result
3138e9fcaa8aSmrg  fi
3139e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3140e9fcaa8aSmrg}
3141e9fcaa8aSmrg# end func_convert_file_msys_to_cygwin
3142e9fcaa8aSmrg
3143e9fcaa8aSmrg
3144e9fcaa8aSmrg# func_convert_file_nix_to_cygwin ARG
3145e9fcaa8aSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
3146e9fcaa8aSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
3147e9fcaa8aSmrg# in func_to_host_file_result.
3148e9fcaa8aSmrgfunc_convert_file_nix_to_cygwin ()
3149e9fcaa8aSmrg{
3150862bcd1aSmrg  $debug_cmd
3151862bcd1aSmrg
3152862bcd1aSmrg  func_to_host_file_result=$1
3153e9fcaa8aSmrg  if test -n "$1"; then
3154e9fcaa8aSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3155e9fcaa8aSmrg    func_convert_core_file_wine_to_w32 "$1"
3156e9fcaa8aSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
3157862bcd1aSmrg    func_to_host_file_result=$func_cygpath_result
3158e9fcaa8aSmrg  fi
3159e9fcaa8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3160e9fcaa8aSmrg}
3161e9fcaa8aSmrg# end func_convert_file_nix_to_cygwin
3162e9fcaa8aSmrg
3163e9fcaa8aSmrg
3164e9fcaa8aSmrg#############################################
3165e9fcaa8aSmrg# $build to $host PATH CONVERSION FUNCTIONS #
3166e9fcaa8aSmrg#############################################
3167862bcd1aSmrg# invoked via '$to_host_path_cmd ARG'
3168e9fcaa8aSmrg#
3169e9fcaa8aSmrg# In each case, ARG is the path to be converted from $build to $host format.
3170e9fcaa8aSmrg# The result will be available in $func_to_host_path_result.
3171e9fcaa8aSmrg#
3172e9fcaa8aSmrg# Path separators are also converted from $build format to $host format.  If
3173e9fcaa8aSmrg# ARG begins or ends with a path separator character, it is preserved (but
3174e9fcaa8aSmrg# converted to $host format) on output.
3175e9fcaa8aSmrg#
3176e9fcaa8aSmrg# All path conversion functions are named using the following convention:
3177e9fcaa8aSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
3178e9fcaa8aSmrg#   path conversion function         : func_convert_path_X_to_Y ()
3179e9fcaa8aSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
3180e9fcaa8aSmrg# same.  If conversion functions are added for new $build/$host combinations,
3181e9fcaa8aSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
3182e9fcaa8aSmrg# will break.
3183e9fcaa8aSmrg
3184e9fcaa8aSmrg
3185e9fcaa8aSmrg# func_init_to_host_path_cmd
3186e9fcaa8aSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
3187e9fcaa8aSmrg# appropriate value, based on the value of $to_host_file_cmd.
3188e9fcaa8aSmrgto_host_path_cmd=
3189e9fcaa8aSmrgfunc_init_to_host_path_cmd ()
3190e9fcaa8aSmrg{
3191862bcd1aSmrg  $debug_cmd
3192862bcd1aSmrg
3193e9fcaa8aSmrg  if test -z "$to_host_path_cmd"; then
3194e9fcaa8aSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
3195862bcd1aSmrg    to_host_path_cmd=func_convert_path_$func_stripname_result
3196e9fcaa8aSmrg  fi
3197e9fcaa8aSmrg}
3198e9fcaa8aSmrg
3199e9fcaa8aSmrg
3200e9fcaa8aSmrg# func_to_host_path ARG
3201e9fcaa8aSmrg# Converts the path ARG from $build format to $host format. Return result
3202e9fcaa8aSmrg# in func_to_host_path_result.
3203e9fcaa8aSmrgfunc_to_host_path ()
3204e9fcaa8aSmrg{
3205862bcd1aSmrg  $debug_cmd
3206862bcd1aSmrg
3207e9fcaa8aSmrg  func_init_to_host_path_cmd
3208e9fcaa8aSmrg  $to_host_path_cmd "$1"
3209e9fcaa8aSmrg}
3210e9fcaa8aSmrg# end func_to_host_path
3211e9fcaa8aSmrg
3212e9fcaa8aSmrg
3213e9fcaa8aSmrg# func_convert_path_noop ARG
3214e9fcaa8aSmrg# Copy ARG to func_to_host_path_result.
3215e9fcaa8aSmrgfunc_convert_path_noop ()
3216e9fcaa8aSmrg{
3217862bcd1aSmrg  func_to_host_path_result=$1
3218e9fcaa8aSmrg}
3219e9fcaa8aSmrg# end func_convert_path_noop
3220e9fcaa8aSmrg
3221e9fcaa8aSmrg
3222e9fcaa8aSmrg# func_convert_path_msys_to_w32 ARG
3223e9fcaa8aSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3224e9fcaa8aSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3225e9fcaa8aSmrg# func_to_host_path_result.
3226e9fcaa8aSmrgfunc_convert_path_msys_to_w32 ()
3227e9fcaa8aSmrg{
3228862bcd1aSmrg  $debug_cmd
3229862bcd1aSmrg
3230862bcd1aSmrg  func_to_host_path_result=$1
3231e9fcaa8aSmrg  if test -n "$1"; then
3232e9fcaa8aSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
3233e9fcaa8aSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3234e9fcaa8aSmrg    # and winepath ignores them completely.
3235e9fcaa8aSmrg    func_stripname : : "$1"
3236e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
3237e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3238862bcd1aSmrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
3239e9fcaa8aSmrg    func_convert_path_check : ";" \
3240e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3241e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3242e9fcaa8aSmrg  fi
3243e9fcaa8aSmrg}
3244e9fcaa8aSmrg# end func_convert_path_msys_to_w32
3245e9fcaa8aSmrg
3246e9fcaa8aSmrg
3247e9fcaa8aSmrg# func_convert_path_cygwin_to_w32 ARG
3248e9fcaa8aSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
3249e9fcaa8aSmrg# func_to_host_file_result.
3250e9fcaa8aSmrgfunc_convert_path_cygwin_to_w32 ()
3251e9fcaa8aSmrg{
3252862bcd1aSmrg  $debug_cmd
3253862bcd1aSmrg
3254862bcd1aSmrg  func_to_host_path_result=$1
3255e9fcaa8aSmrg  if test -n "$1"; then
3256e9fcaa8aSmrg    # See func_convert_path_msys_to_w32:
3257e9fcaa8aSmrg    func_stripname : : "$1"
3258e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
3259e9fcaa8aSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
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_cygwin_to_w32
3266e9fcaa8aSmrg
3267e9fcaa8aSmrg
3268e9fcaa8aSmrg# func_convert_path_nix_to_w32 ARG
3269e9fcaa8aSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
3270e9fcaa8aSmrg# a working winepath.  Returns result in func_to_host_file_result.
3271e9fcaa8aSmrgfunc_convert_path_nix_to_w32 ()
3272e9fcaa8aSmrg{
3273862bcd1aSmrg  $debug_cmd
3274862bcd1aSmrg
3275862bcd1aSmrg  func_to_host_path_result=$1
3276e9fcaa8aSmrg  if test -n "$1"; then
3277e9fcaa8aSmrg    # See func_convert_path_msys_to_w32:
3278e9fcaa8aSmrg    func_stripname : : "$1"
3279e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
3280e9fcaa8aSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3281862bcd1aSmrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3282e9fcaa8aSmrg    func_convert_path_check : ";" \
3283e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3284e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3285e9fcaa8aSmrg  fi
3286e9fcaa8aSmrg}
3287e9fcaa8aSmrg# end func_convert_path_nix_to_w32
3288e9fcaa8aSmrg
3289e9fcaa8aSmrg
3290e9fcaa8aSmrg# func_convert_path_msys_to_cygwin ARG
3291e9fcaa8aSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3292e9fcaa8aSmrg# Returns result in func_to_host_file_result.
3293e9fcaa8aSmrgfunc_convert_path_msys_to_cygwin ()
3294e9fcaa8aSmrg{
3295862bcd1aSmrg  $debug_cmd
3296862bcd1aSmrg
3297862bcd1aSmrg  func_to_host_path_result=$1
3298e9fcaa8aSmrg  if test -n "$1"; then
3299e9fcaa8aSmrg    # See func_convert_path_msys_to_w32:
3300e9fcaa8aSmrg    func_stripname : : "$1"
3301e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
3302e9fcaa8aSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3303e9fcaa8aSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
3304862bcd1aSmrg    func_to_host_path_result=$func_cygpath_result
3305e9fcaa8aSmrg    func_convert_path_check : : \
3306e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3307e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3308e9fcaa8aSmrg  fi
3309e9fcaa8aSmrg}
3310e9fcaa8aSmrg# end func_convert_path_msys_to_cygwin
3311e9fcaa8aSmrg
3312e9fcaa8aSmrg
3313e9fcaa8aSmrg# func_convert_path_nix_to_cygwin ARG
3314e9fcaa8aSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
3315e9fcaa8aSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
3316e9fcaa8aSmrg# func_to_host_file_result.
3317e9fcaa8aSmrgfunc_convert_path_nix_to_cygwin ()
3318e9fcaa8aSmrg{
3319862bcd1aSmrg  $debug_cmd
3320862bcd1aSmrg
3321862bcd1aSmrg  func_to_host_path_result=$1
3322e9fcaa8aSmrg  if test -n "$1"; then
3323e9fcaa8aSmrg    # Remove leading and trailing path separator characters from
3324e9fcaa8aSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
3325e9fcaa8aSmrg    # into '.;' and ';.', and winepath ignores them completely.
3326e9fcaa8aSmrg    func_stripname : : "$1"
3327e9fcaa8aSmrg    func_to_host_path_tmp1=$func_stripname_result
3328e9fcaa8aSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3329e9fcaa8aSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
3330862bcd1aSmrg    func_to_host_path_result=$func_cygpath_result
3331e9fcaa8aSmrg    func_convert_path_check : : \
3332e9fcaa8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3333e9fcaa8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3334e9fcaa8aSmrg  fi
3335e9fcaa8aSmrg}
3336e9fcaa8aSmrg# end func_convert_path_nix_to_cygwin
3337e9fcaa8aSmrg
3338e9fcaa8aSmrg
3339862bcd1aSmrg# func_dll_def_p FILE
3340862bcd1aSmrg# True iff FILE is a Windows DLL '.def' file.
3341862bcd1aSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
3342862bcd1aSmrgfunc_dll_def_p ()
3343862bcd1aSmrg{
3344862bcd1aSmrg  $debug_cmd
3345862bcd1aSmrg
3346862bcd1aSmrg  func_dll_def_p_tmp=`$SED -n \
3347862bcd1aSmrg    -e 's/^[	 ]*//' \
3348862bcd1aSmrg    -e '/^\(;.*\)*$/d' \
3349862bcd1aSmrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
3350862bcd1aSmrg    -e q \
3351862bcd1aSmrg    "$1"`
3352862bcd1aSmrg  test DEF = "$func_dll_def_p_tmp"
3353862bcd1aSmrg}
3354862bcd1aSmrg
3355862bcd1aSmrg
335688de56ccSmrg# func_mode_compile arg...
335788de56ccSmrgfunc_mode_compile ()
335888de56ccSmrg{
3359862bcd1aSmrg    $debug_cmd
3360862bcd1aSmrg
336188de56ccSmrg    # Get the compilation command and the source file.
336288de56ccSmrg    base_compile=
3363862bcd1aSmrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
336488de56ccSmrg    suppress_opt=yes
336588de56ccSmrg    suppress_output=
336688de56ccSmrg    arg_mode=normal
336788de56ccSmrg    libobj=
336888de56ccSmrg    later=
336988de56ccSmrg    pie_flag=
337088de56ccSmrg
337188de56ccSmrg    for arg
337288de56ccSmrg    do
337388de56ccSmrg      case $arg_mode in
337488de56ccSmrg      arg  )
337588de56ccSmrg	# do not "continue".  Instead, add this to base_compile
3376862bcd1aSmrg	lastarg=$arg
337788de56ccSmrg	arg_mode=normal
337888de56ccSmrg	;;
337988de56ccSmrg
338088de56ccSmrg      target )
3381862bcd1aSmrg	libobj=$arg
338288de56ccSmrg	arg_mode=normal
338388de56ccSmrg	continue
338488de56ccSmrg	;;
338588de56ccSmrg
338688de56ccSmrg      normal )
338788de56ccSmrg	# Accept any command-line options.
338888de56ccSmrg	case $arg in
338988de56ccSmrg	-o)
339088de56ccSmrg	  test -n "$libobj" && \
3391862bcd1aSmrg	    func_fatal_error "you cannot specify '-o' more than once"
339288de56ccSmrg	  arg_mode=target
339388de56ccSmrg	  continue
339488de56ccSmrg	  ;;
339588de56ccSmrg
339688de56ccSmrg	-pie | -fpie | -fPIE)
3397e9fcaa8aSmrg          func_append pie_flag " $arg"
339888de56ccSmrg	  continue
339988de56ccSmrg	  ;;
340088de56ccSmrg
340188de56ccSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
3402e9fcaa8aSmrg	  func_append later " $arg"
340388de56ccSmrg	  continue
340488de56ccSmrg	  ;;
340588de56ccSmrg
340688de56ccSmrg	-no-suppress)
34071ab64890Smrg	  suppress_opt=no
34081ab64890Smrg	  continue
34091ab64890Smrg	  ;;
34101ab64890Smrg
34111ab64890Smrg	-Xcompiler)
34121ab64890Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
34131ab64890Smrg	  continue      #  The current "srcfile" will either be retained or
34141ab64890Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
34151ab64890Smrg
34161ab64890Smrg	-Wc,*)
341788de56ccSmrg	  func_stripname '-Wc,' '' "$arg"
341888de56ccSmrg	  args=$func_stripname_result
34191ab64890Smrg	  lastarg=
3420862bcd1aSmrg	  save_ifs=$IFS; IFS=,
342188de56ccSmrg	  for arg in $args; do
3422862bcd1aSmrg	    IFS=$save_ifs
3423e9fcaa8aSmrg	    func_append_quoted lastarg "$arg"
34241ab64890Smrg	  done
3425862bcd1aSmrg	  IFS=$save_ifs
342688de56ccSmrg	  func_stripname ' ' '' "$lastarg"
342788de56ccSmrg	  lastarg=$func_stripname_result
34281ab64890Smrg
34291ab64890Smrg	  # Add the arguments to base_compile.
3430e9fcaa8aSmrg	  func_append base_compile " $lastarg"
34311ab64890Smrg	  continue
34321ab64890Smrg	  ;;
34331ab64890Smrg
343488de56ccSmrg	*)
34351ab64890Smrg	  # Accept the current argument as the source file.
34361ab64890Smrg	  # The previous "srcfile" becomes the current argument.
34371ab64890Smrg	  #
3438862bcd1aSmrg	  lastarg=$srcfile
3439862bcd1aSmrg	  srcfile=$arg
34401ab64890Smrg	  ;;
34411ab64890Smrg	esac  #  case $arg
34421ab64890Smrg	;;
34431ab64890Smrg      esac    #  case $arg_mode
34441ab64890Smrg
34451ab64890Smrg      # Aesthetically quote the previous argument.
3446e9fcaa8aSmrg      func_append_quoted base_compile "$lastarg"
34471ab64890Smrg    done # for arg
34481ab64890Smrg
34491ab64890Smrg    case $arg_mode in
34501ab64890Smrg    arg)
345188de56ccSmrg      func_fatal_error "you must specify an argument for -Xcompile"
34521ab64890Smrg      ;;
34531ab64890Smrg    target)
3454862bcd1aSmrg      func_fatal_error "you must specify a target with '-o'"
34551ab64890Smrg      ;;
34561ab64890Smrg    *)
34571ab64890Smrg      # Get the name of the library object.
345888de56ccSmrg      test -z "$libobj" && {
345988de56ccSmrg	func_basename "$srcfile"
3460862bcd1aSmrg	libobj=$func_basename_result
346188de56ccSmrg      }
34621ab64890Smrg      ;;
34631ab64890Smrg    esac
34641ab64890Smrg
34651ab64890Smrg    # Recognize several different file suffixes.
34661ab64890Smrg    # If the user specifies -o file.o, it is replaced with file.lo
34671ab64890Smrg    case $libobj in
346888de56ccSmrg    *.[cCFSifmso] | \
346988de56ccSmrg    *.ada | *.adb | *.ads | *.asm | \
347088de56ccSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3471eb411b4bSmrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
347288de56ccSmrg      func_xform "$libobj"
347388de56ccSmrg      libobj=$func_xform_result
347488de56ccSmrg      ;;
34751ab64890Smrg    esac
34761ab64890Smrg
34771ab64890Smrg    case $libobj in
347888de56ccSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
34791ab64890Smrg    *)
3480862bcd1aSmrg      func_fatal_error "cannot determine name of library object from '$libobj'"
34811ab64890Smrg      ;;
34821ab64890Smrg    esac
34831ab64890Smrg
34841ab64890Smrg    func_infer_tag $base_compile
34851ab64890Smrg
34861ab64890Smrg    for arg in $later; do
34871ab64890Smrg      case $arg in
348888de56ccSmrg      -shared)
3489862bcd1aSmrg	test yes = "$build_libtool_libs" \
3490862bcd1aSmrg	  || func_fatal_configuration "cannot build a shared library"
349188de56ccSmrg	build_old_libs=no
349288de56ccSmrg	continue
349388de56ccSmrg	;;
349488de56ccSmrg
34951ab64890Smrg      -static)
349688de56ccSmrg	build_libtool_libs=no
34971ab64890Smrg	build_old_libs=yes
34981ab64890Smrg	continue
34991ab64890Smrg	;;
35001ab64890Smrg
35011ab64890Smrg      -prefer-pic)
35021ab64890Smrg	pic_mode=yes
35031ab64890Smrg	continue
35041ab64890Smrg	;;
35051ab64890Smrg
35061ab64890Smrg      -prefer-non-pic)
35071ab64890Smrg	pic_mode=no
35081ab64890Smrg	continue
35091ab64890Smrg	;;
35101ab64890Smrg      esac
35111ab64890Smrg    done
35121ab64890Smrg
351388de56ccSmrg    func_quote_for_eval "$libobj"
351488de56ccSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
351588de56ccSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
3516862bcd1aSmrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
351788de56ccSmrg    func_dirname_and_basename "$obj" "/" ""
3518862bcd1aSmrg    objname=$func_basename_result
3519862bcd1aSmrg    xdir=$func_dirname_result
3520862bcd1aSmrg    lobj=$xdir$objdir/$objname
35211ab64890Smrg
352288de56ccSmrg    test -z "$base_compile" && \
352388de56ccSmrg      func_fatal_help "you must specify a compilation command"
35241ab64890Smrg
35251ab64890Smrg    # Delete any leftover library objects.
3526862bcd1aSmrg    if test yes = "$build_old_libs"; then
35271ab64890Smrg      removelist="$obj $lobj $libobj ${libobj}T"
35281ab64890Smrg    else
35291ab64890Smrg      removelist="$lobj $libobj ${libobj}T"
35301ab64890Smrg    fi
35311ab64890Smrg
35321ab64890Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
35331ab64890Smrg    case $host_os in
353488de56ccSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
35351ab64890Smrg      pic_mode=default
35361ab64890Smrg      ;;
35371ab64890Smrg    esac
3538862bcd1aSmrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
35391ab64890Smrg      # non-PIC code in shared libraries is not supported
35401ab64890Smrg      pic_mode=default
35411ab64890Smrg    fi
35421ab64890Smrg
35431ab64890Smrg    # Calculate the filename of the output object if compiler does
35441ab64890Smrg    # not support -o with -c
3545862bcd1aSmrg    if test no = "$compiler_c_o"; then
3546862bcd1aSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
3547862bcd1aSmrg      lockfile=$output_obj.lock
35481ab64890Smrg    else
35491ab64890Smrg      output_obj=
35501ab64890Smrg      need_locks=no
35511ab64890Smrg      lockfile=
35521ab64890Smrg    fi
35531ab64890Smrg
35541ab64890Smrg    # Lock this critical section if it is needed
35551ab64890Smrg    # We use this script file to make the link, it avoids creating a new file
3556862bcd1aSmrg    if test yes = "$need_locks"; then
355788de56ccSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
355888de56ccSmrg	func_echo "Waiting for $lockfile to be removed"
35591ab64890Smrg	sleep 2
35601ab64890Smrg      done
3561862bcd1aSmrg    elif test warn = "$need_locks"; then
35621ab64890Smrg      if test -f "$lockfile"; then
356388de56ccSmrg	$ECHO "\
35641ab64890Smrg*** ERROR, $lockfile exists and contains:
35651ab64890Smrg`cat $lockfile 2>/dev/null`
35661ab64890Smrg
35671ab64890SmrgThis indicates that another process is trying to use the same
35681ab64890Smrgtemporary object file, and libtool could not work around it because
3569862bcd1aSmrgyour compiler does not support '-c' and '-o' together.  If you
35701ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
35711ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
35721ab64890Smrgcompiler."
35731ab64890Smrg
357488de56ccSmrg	$opt_dry_run || $RM $removelist
35751ab64890Smrg	exit $EXIT_FAILURE
35761ab64890Smrg      fi
3577e9fcaa8aSmrg      func_append removelist " $output_obj"
357888de56ccSmrg      $ECHO "$srcfile" > "$lockfile"
35791ab64890Smrg    fi
35801ab64890Smrg
358188de56ccSmrg    $opt_dry_run || $RM $removelist
3582e9fcaa8aSmrg    func_append removelist " $lockfile"
358388de56ccSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
358488de56ccSmrg
3585e9fcaa8aSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3586e9fcaa8aSmrg    srcfile=$func_to_tool_file_result
358788de56ccSmrg    func_quote_for_eval "$srcfile"
358888de56ccSmrg    qsrcfile=$func_quote_for_eval_result
35891ab64890Smrg
35901ab64890Smrg    # Only build a PIC object if we are building libtool libraries.
3591862bcd1aSmrg    if test yes = "$build_libtool_libs"; then
35921ab64890Smrg      # Without this assignment, base_compile gets emptied.
35931ab64890Smrg      fbsd_hideous_sh_bug=$base_compile
35941ab64890Smrg
3595862bcd1aSmrg      if test no != "$pic_mode"; then
35961ab64890Smrg	command="$base_compile $qsrcfile $pic_flag"
35971ab64890Smrg      else
35981ab64890Smrg	# Don't build PIC code
35991ab64890Smrg	command="$base_compile $qsrcfile"
36001ab64890Smrg      fi
36011ab64890Smrg
360288de56ccSmrg      func_mkdir_p "$xdir$objdir"
36031ab64890Smrg
36041ab64890Smrg      if test -z "$output_obj"; then
36051ab64890Smrg	# Place PIC objects in $objdir
3606e9fcaa8aSmrg	func_append command " -o $lobj"
36071ab64890Smrg      fi
36081ab64890Smrg
360988de56ccSmrg      func_show_eval_locale "$command"	\
361088de56ccSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
36111ab64890Smrg
3612862bcd1aSmrg      if test warn = "$need_locks" &&
36131ab64890Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
361488de56ccSmrg	$ECHO "\
36151ab64890Smrg*** ERROR, $lockfile contains:
36161ab64890Smrg`cat $lockfile 2>/dev/null`
36171ab64890Smrg
36181ab64890Smrgbut it should contain:
36191ab64890Smrg$srcfile
36201ab64890Smrg
36211ab64890SmrgThis indicates that another process is trying to use the same
36221ab64890Smrgtemporary object file, and libtool could not work around it because
3623862bcd1aSmrgyour compiler does not support '-c' and '-o' together.  If you
36241ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
36251ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
36261ab64890Smrgcompiler."
36271ab64890Smrg
362888de56ccSmrg	$opt_dry_run || $RM $removelist
36291ab64890Smrg	exit $EXIT_FAILURE
36301ab64890Smrg      fi
36311ab64890Smrg
36321ab64890Smrg      # Just move the object if needed, then go on to compile the next one
36331ab64890Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
363488de56ccSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
363588de56ccSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
36361ab64890Smrg      fi
36371ab64890Smrg
36381ab64890Smrg      # Allow error messages only from the first compilation.
3639862bcd1aSmrg      if test yes = "$suppress_opt"; then
364088de56ccSmrg	suppress_output=' >/dev/null 2>&1'
36411ab64890Smrg      fi
36421ab64890Smrg    fi
36431ab64890Smrg
36441ab64890Smrg    # Only build a position-dependent object if we build old libraries.
3645862bcd1aSmrg    if test yes = "$build_old_libs"; then
3646862bcd1aSmrg      if test yes != "$pic_mode"; then
36471ab64890Smrg	# Don't build PIC code
364888de56ccSmrg	command="$base_compile $qsrcfile$pie_flag"
36491ab64890Smrg      else
36501ab64890Smrg	command="$base_compile $qsrcfile $pic_flag"
36511ab64890Smrg      fi
3652862bcd1aSmrg      if test yes = "$compiler_c_o"; then
3653e9fcaa8aSmrg	func_append command " -o $obj"
36541ab64890Smrg      fi
36551ab64890Smrg
36561ab64890Smrg      # Suppress compiler output if we already did a PIC compilation.
3657e9fcaa8aSmrg      func_append command "$suppress_output"
365888de56ccSmrg      func_show_eval_locale "$command" \
365988de56ccSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
36601ab64890Smrg
3661862bcd1aSmrg      if test warn = "$need_locks" &&
36621ab64890Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
366388de56ccSmrg	$ECHO "\
36641ab64890Smrg*** ERROR, $lockfile contains:
36651ab64890Smrg`cat $lockfile 2>/dev/null`
36661ab64890Smrg
36671ab64890Smrgbut it should contain:
36681ab64890Smrg$srcfile
36691ab64890Smrg
36701ab64890SmrgThis indicates that another process is trying to use the same
36711ab64890Smrgtemporary object file, and libtool could not work around it because
3672862bcd1aSmrgyour compiler does not support '-c' and '-o' together.  If you
36731ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better
36741ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better
36751ab64890Smrgcompiler."
36761ab64890Smrg
367788de56ccSmrg	$opt_dry_run || $RM $removelist
36781ab64890Smrg	exit $EXIT_FAILURE
36791ab64890Smrg      fi
36801ab64890Smrg
36811ab64890Smrg      # Just move the object if needed
36821ab64890Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
368388de56ccSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
368488de56ccSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
36851ab64890Smrg      fi
36861ab64890Smrg    fi
36871ab64890Smrg
368888de56ccSmrg    $opt_dry_run || {
368988de56ccSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
36901ab64890Smrg
369188de56ccSmrg      # Unlock the critical section if it was locked
3692862bcd1aSmrg      if test no != "$need_locks"; then
369388de56ccSmrg	removelist=$lockfile
369488de56ccSmrg        $RM "$lockfile"
369588de56ccSmrg      fi
369688de56ccSmrg    }
36971ab64890Smrg
36981ab64890Smrg    exit $EXIT_SUCCESS
369988de56ccSmrg}
37001ab64890Smrg
370188de56ccSmrg$opt_help || {
3702862bcd1aSmrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
370388de56ccSmrg}
37041ab64890Smrg
370588de56ccSmrgfunc_mode_help ()
370688de56ccSmrg{
370788de56ccSmrg    # We need to display help for each of the modes.
3708e9fcaa8aSmrg    case $opt_mode in
370988de56ccSmrg      "")
371088de56ccSmrg        # Generic help is extracted from the usage comments
371188de56ccSmrg        # at the start of this file.
371288de56ccSmrg        func_help
371388de56ccSmrg        ;;
37141ab64890Smrg
371588de56ccSmrg      clean)
371688de56ccSmrg        $ECHO \
371788de56ccSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
37181ab64890Smrg
371988de56ccSmrgRemove files from the build directory.
37201ab64890Smrg
372188de56ccSmrgRM is the name of the program to use to delete files associated with each FILE
3722862bcd1aSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
372388de56ccSmrgto RM.
37241ab64890Smrg
372588de56ccSmrgIf FILE is a libtool library, object or program, all the files associated
372688de56ccSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
372788de56ccSmrg        ;;
37281ab64890Smrg
372988de56ccSmrg      compile)
373088de56ccSmrg      $ECHO \
373188de56ccSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
37321ab64890Smrg
373388de56ccSmrgCompile a source file into a libtool library object.
37341ab64890Smrg
373588de56ccSmrgThis mode accepts the following additional options:
37361ab64890Smrg
373788de56ccSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
373888de56ccSmrg  -no-suppress      do not suppress compiler output for multiple passes
3739e9fcaa8aSmrg  -prefer-pic       try to build PIC objects only
3740e9fcaa8aSmrg  -prefer-non-pic   try to build non-PIC objects only
3741862bcd1aSmrg  -shared           do not build a '.o' file suitable for static linking
3742862bcd1aSmrg  -static           only build a '.o' file suitable for static linking
3743e9fcaa8aSmrg  -Wc,FLAG          pass FLAG directly to the compiler
37441ab64890Smrg
3745862bcd1aSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
374688de56ccSmrgfrom the given SOURCEFILE.
37471ab64890Smrg
374888de56ccSmrgThe output file name is determined by removing the directory component from
3749862bcd1aSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
3750862bcd1aSmrglibrary object suffix, '.lo'."
375188de56ccSmrg        ;;
37521ab64890Smrg
375388de56ccSmrg      execute)
375488de56ccSmrg        $ECHO \
375588de56ccSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
37561ab64890Smrg
375788de56ccSmrgAutomatically set library path, then run a program.
37581ab64890Smrg
375988de56ccSmrgThis mode accepts the following additional options:
37601ab64890Smrg
376188de56ccSmrg  -dlopen FILE      add the directory containing FILE to the library path
37621ab64890Smrg
3763862bcd1aSmrgThis mode sets the library path environment variable according to '-dlopen'
376488de56ccSmrgflags.
37651ab64890Smrg
376688de56ccSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
376788de56ccSmrginto their corresponding uninstalled binary, and any of their required library
376888de56ccSmrgdirectories are added to the library path.
37691ab64890Smrg
377088de56ccSmrgThen, COMMAND is executed, with ARGS as arguments."
377188de56ccSmrg        ;;
37721ab64890Smrg
377388de56ccSmrg      finish)
377488de56ccSmrg        $ECHO \
377588de56ccSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
37761ab64890Smrg
377788de56ccSmrgComplete the installation of libtool libraries.
37781ab64890Smrg
377988de56ccSmrgEach LIBDIR is a directory that contains libtool libraries.
37801ab64890Smrg
378188de56ccSmrgThe commands that this mode executes may require superuser privileges.  Use
3782862bcd1aSmrgthe '--dry-run' option if you just want to see what would be executed."
378388de56ccSmrg        ;;
37841ab64890Smrg
378588de56ccSmrg      install)
378688de56ccSmrg        $ECHO \
378788de56ccSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
37881ab64890Smrg
378988de56ccSmrgInstall executables or libraries.
37901ab64890Smrg
379188de56ccSmrgINSTALL-COMMAND is the installation command.  The first component should be
3792862bcd1aSmrgeither the 'install' or 'cp' program.
37931ab64890Smrg
379488de56ccSmrgThe following components of INSTALL-COMMAND are treated specially:
37951ab64890Smrg
3796e9fcaa8aSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
37971ab64890Smrg
379888de56ccSmrgThe rest of the components are interpreted as arguments to that command (only
379988de56ccSmrgBSD-compatible install options are recognized)."
380088de56ccSmrg        ;;
38011ab64890Smrg
380288de56ccSmrg      link)
380388de56ccSmrg        $ECHO \
380488de56ccSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
38051ab64890Smrg
380688de56ccSmrgLink object files or libraries together to form another library, or to
380788de56ccSmrgcreate an executable program.
38081ab64890Smrg
380988de56ccSmrgLINK-COMMAND is a command using the C compiler that you would use to create
381088de56ccSmrga program from several object files.
38111ab64890Smrg
381288de56ccSmrgThe following components of LINK-COMMAND are treated specially:
38131ab64890Smrg
381488de56ccSmrg  -all-static       do not do any dynamic linking at all
381588de56ccSmrg  -avoid-version    do not add a version suffix if possible
3816e9fcaa8aSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
3817e9fcaa8aSmrg                    libraries must be found in the PATH setting at runtime)
3818862bcd1aSmrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
381988de56ccSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
382088de56ccSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
382188de56ccSmrg  -export-symbols SYMFILE
382288de56ccSmrg                    try to export only the symbols listed in SYMFILE
382388de56ccSmrg  -export-symbols-regex REGEX
382488de56ccSmrg                    try to export only the symbols matching REGEX
382588de56ccSmrg  -LLIBDIR          search LIBDIR for required installed libraries
382688de56ccSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
382788de56ccSmrg  -module           build a library that can dlopened
382888de56ccSmrg  -no-fast-install  disable the fast-install mode
382988de56ccSmrg  -no-install       link a not-installable executable
383088de56ccSmrg  -no-undefined     declare that a library does not refer to external symbols
383188de56ccSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
3832862bcd1aSmrg  -objectlist FILE  use a list of object files found in FILE to specify objects
3833862bcd1aSmrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
383488de56ccSmrg  -precious-files-regex REGEX
383588de56ccSmrg                    don't remove output files matching REGEX
383688de56ccSmrg  -release RELEASE  specify package release information
383788de56ccSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
383888de56ccSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
383988de56ccSmrg  -shared           only do dynamic linking of libtool libraries
384088de56ccSmrg  -shrext SUFFIX    override the standard shared library file extension
384188de56ccSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
384288de56ccSmrg  -static-libtool-libs
384388de56ccSmrg                    do not do any dynamic linking of libtool libraries
384488de56ccSmrg  -version-info CURRENT[:REVISION[:AGE]]
384588de56ccSmrg                    specify library version info [each variable defaults to 0]
384688de56ccSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
3847e9fcaa8aSmrg  -Wc,FLAG
3848e9fcaa8aSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
3849e9fcaa8aSmrg  -Wl,FLAG
3850e9fcaa8aSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
3851e9fcaa8aSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
38521ab64890Smrg
3853862bcd1aSmrgAll other options (arguments beginning with '-') are ignored.
38541ab64890Smrg
3855862bcd1aSmrgEvery other argument is treated as a filename.  Files ending in '.la' are
385688de56ccSmrgtreated as uninstalled libtool libraries, other files are standard or library
385788de56ccSmrgobject files.
38581ab64890Smrg
3859862bcd1aSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
3860862bcd1aSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is
386188de56ccSmrgrequired, except when creating a convenience library.
38621ab64890Smrg
3863862bcd1aSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
3864862bcd1aSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
38651ab64890Smrg
3866862bcd1aSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
386788de56ccSmrgis created, otherwise an executable program is created."
3868b4ee4795Smrg        ;;
38691ab64890Smrg
387088de56ccSmrg      uninstall)
387188de56ccSmrg        $ECHO \
387288de56ccSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
38731ab64890Smrg
387488de56ccSmrgRemove libraries from an installation directory.
38751ab64890Smrg
387688de56ccSmrgRM is the name of the program to use to delete files associated with each FILE
3877862bcd1aSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
387888de56ccSmrgto RM.
38792e9c7c8cSmrg
388088de56ccSmrgIf FILE is a libtool library, all the files associated with it are deleted.
388188de56ccSmrgOtherwise, only FILE itself is deleted using RM."
388288de56ccSmrg        ;;
38832e9c7c8cSmrg
388488de56ccSmrg      *)
3885862bcd1aSmrg        func_fatal_help "invalid operation mode '$opt_mode'"
388688de56ccSmrg        ;;
388788de56ccSmrg    esac
38882e9c7c8cSmrg
3889e9fcaa8aSmrg    echo
3890862bcd1aSmrg    $ECHO "Try '$progname --help' for more information about other modes."
389188de56ccSmrg}
38922e9c7c8cSmrg
3893e9fcaa8aSmrg# Now that we've collected a possible --mode arg, show help if necessary
3894e9fcaa8aSmrgif $opt_help; then
3895862bcd1aSmrg  if test : = "$opt_help"; then
3896e9fcaa8aSmrg    func_mode_help
3897e9fcaa8aSmrg  else
3898e9fcaa8aSmrg    {
3899e9fcaa8aSmrg      func_help noexit
3900e9fcaa8aSmrg      for opt_mode in compile link execute install finish uninstall clean; do
3901e9fcaa8aSmrg	func_mode_help
3902e9fcaa8aSmrg      done
3903862bcd1aSmrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
3904e9fcaa8aSmrg    {
3905e9fcaa8aSmrg      func_help noexit
3906e9fcaa8aSmrg      for opt_mode in compile link execute install finish uninstall clean; do
3907e9fcaa8aSmrg	echo
3908e9fcaa8aSmrg	func_mode_help
3909e9fcaa8aSmrg      done
3910e9fcaa8aSmrg    } |
3911862bcd1aSmrg    $SED '1d
3912e9fcaa8aSmrg      /^When reporting/,/^Report/{
3913e9fcaa8aSmrg	H
3914e9fcaa8aSmrg	d
3915e9fcaa8aSmrg      }
3916e9fcaa8aSmrg      $x
3917e9fcaa8aSmrg      /information about other modes/d
3918e9fcaa8aSmrg      /more detailed .*MODE/d
3919e9fcaa8aSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3920e9fcaa8aSmrg  fi
3921e9fcaa8aSmrg  exit $?
3922e9fcaa8aSmrgfi
39232e9c7c8cSmrg
39242e9c7c8cSmrg
392588de56ccSmrg# func_mode_execute arg...
392688de56ccSmrgfunc_mode_execute ()
392788de56ccSmrg{
3928862bcd1aSmrg    $debug_cmd
3929862bcd1aSmrg
393088de56ccSmrg    # The first argument is the command name.
3931862bcd1aSmrg    cmd=$nonopt
393288de56ccSmrg    test -z "$cmd" && \
393388de56ccSmrg      func_fatal_help "you must specify a COMMAND"
3934b4ee4795Smrg
393588de56ccSmrg    # Handle -dlopen flags immediately.
3936e9fcaa8aSmrg    for file in $opt_dlopen; do
393788de56ccSmrg      test -f "$file" \
3938862bcd1aSmrg	|| func_fatal_help "'$file' is not a file"
3939b4ee4795Smrg
394088de56ccSmrg      dir=
394188de56ccSmrg      case $file in
394288de56ccSmrg      *.la)
3943e9fcaa8aSmrg	func_resolve_sysroot "$file"
3944e9fcaa8aSmrg	file=$func_resolve_sysroot_result
3945e9fcaa8aSmrg
394688de56ccSmrg	# Check to see that this really is a libtool archive.
394788de56ccSmrg	func_lalib_unsafe_p "$file" \
3948862bcd1aSmrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
3949b4ee4795Smrg
395088de56ccSmrg	# Read the libtool library.
395188de56ccSmrg	dlname=
395288de56ccSmrg	library_names=
395388de56ccSmrg	func_source "$file"
39541ab64890Smrg
395588de56ccSmrg	# Skip this library if it cannot be dlopened.
395688de56ccSmrg	if test -z "$dlname"; then
395788de56ccSmrg	  # Warn if it was a shared library.
395888de56ccSmrg	  test -n "$library_names" && \
3959862bcd1aSmrg	    func_warning "'$file' was not linked with '-export-dynamic'"
396088de56ccSmrg	  continue
396188de56ccSmrg	fi
39621ab64890Smrg
396388de56ccSmrg	func_dirname "$file" "" "."
3964862bcd1aSmrg	dir=$func_dirname_result
39651ab64890Smrg
396688de56ccSmrg	if test -f "$dir/$objdir/$dlname"; then
3967e9fcaa8aSmrg	  func_append dir "/$objdir"
396888de56ccSmrg	else
396988de56ccSmrg	  if test ! -f "$dir/$dlname"; then
3970862bcd1aSmrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
397188de56ccSmrg	  fi
397288de56ccSmrg	fi
3973b4ee4795Smrg	;;
39741ab64890Smrg
397588de56ccSmrg      *.lo)
397688de56ccSmrg	# Just add the directory containing the .lo file.
397788de56ccSmrg	func_dirname "$file" "" "."
3978862bcd1aSmrg	dir=$func_dirname_result
3979b4ee4795Smrg	;;
39801ab64890Smrg
398188de56ccSmrg      *)
3982862bcd1aSmrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
3983b4ee4795Smrg	continue
3984b4ee4795Smrg	;;
398588de56ccSmrg      esac
39861ab64890Smrg
398788de56ccSmrg      # Get the absolute pathname.
398888de56ccSmrg      absdir=`cd "$dir" && pwd`
3989862bcd1aSmrg      test -n "$absdir" && dir=$absdir
39902e9c7c8cSmrg
399188de56ccSmrg      # Now add the directory to shlibpath_var.
399288de56ccSmrg      if eval "test -z \"\$$shlibpath_var\""; then
399388de56ccSmrg	eval "$shlibpath_var=\"\$dir\""
399488de56ccSmrg      else
399588de56ccSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
399688de56ccSmrg      fi
399788de56ccSmrg    done
39982e9c7c8cSmrg
399988de56ccSmrg    # This variable tells wrapper scripts just to set shlibpath_var
400088de56ccSmrg    # rather than running their programs.
4001862bcd1aSmrg    libtool_execute_magic=$magic
40022e9c7c8cSmrg
400388de56ccSmrg    # Check if any of the arguments is a wrapper script.
400488de56ccSmrg    args=
400588de56ccSmrg    for file
400688de56ccSmrg    do
400788de56ccSmrg      case $file in
4008e9fcaa8aSmrg      -* | *.la | *.lo ) ;;
400988de56ccSmrg      *)
401088de56ccSmrg	# Do a test to see if this is really a libtool program.
401188de56ccSmrg	if func_ltwrapper_script_p "$file"; then
401288de56ccSmrg	  func_source "$file"
401388de56ccSmrg	  # Transform arg to wrapped name.
4014862bcd1aSmrg	  file=$progdir/$program
401588de56ccSmrg	elif func_ltwrapper_executable_p "$file"; then
401688de56ccSmrg	  func_ltwrapper_scriptname "$file"
401788de56ccSmrg	  func_source "$func_ltwrapper_scriptname_result"
401888de56ccSmrg	  # Transform arg to wrapped name.
4019862bcd1aSmrg	  file=$progdir/$program
402088de56ccSmrg	fi
402188de56ccSmrg	;;
402288de56ccSmrg      esac
402388de56ccSmrg      # Quote arguments (to preserve shell metacharacters).
4024e9fcaa8aSmrg      func_append_quoted args "$file"
402588de56ccSmrg    done
40262e9c7c8cSmrg
4027862bcd1aSmrg    if $opt_dry_run; then
4028862bcd1aSmrg      # Display what would be done.
4029862bcd1aSmrg      if test -n "$shlibpath_var"; then
4030862bcd1aSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
4031862bcd1aSmrg	echo "export $shlibpath_var"
4032862bcd1aSmrg      fi
4033862bcd1aSmrg      $ECHO "$cmd$args"
4034862bcd1aSmrg      exit $EXIT_SUCCESS
4035862bcd1aSmrg    else
403688de56ccSmrg      if test -n "$shlibpath_var"; then
403788de56ccSmrg	# Export the shlibpath_var.
403888de56ccSmrg	eval "export $shlibpath_var"
403988de56ccSmrg      fi
40402e9c7c8cSmrg
404188de56ccSmrg      # Restore saved environment variables
404288de56ccSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
404388de56ccSmrg      do
404488de56ccSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
404588de56ccSmrg                $lt_var=\$save_$lt_var; export $lt_var
4046b4ee4795Smrg	      else
404788de56ccSmrg		$lt_unset $lt_var
404888de56ccSmrg	      fi"
404988de56ccSmrg      done
40502e9c7c8cSmrg
405188de56ccSmrg      # Now prepare to actually exec the command.
4052862bcd1aSmrg      exec_cmd=\$cmd$args
405388de56ccSmrg    fi
405488de56ccSmrg}
40552e9c7c8cSmrg
4056862bcd1aSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
40572e9c7c8cSmrg
4058b4ee4795Smrg
405988de56ccSmrg# func_mode_finish arg...
406088de56ccSmrgfunc_mode_finish ()
406188de56ccSmrg{
4062862bcd1aSmrg    $debug_cmd
4063862bcd1aSmrg
4064e9fcaa8aSmrg    libs=
4065e9fcaa8aSmrg    libdirs=
406688de56ccSmrg    admincmds=
40671ab64890Smrg
4068e9fcaa8aSmrg    for opt in "$nonopt" ${1+"$@"}
4069e9fcaa8aSmrg    do
4070e9fcaa8aSmrg      if test -d "$opt"; then
4071e9fcaa8aSmrg	func_append libdirs " $opt"
4072e9fcaa8aSmrg
4073e9fcaa8aSmrg      elif test -f "$opt"; then
4074e9fcaa8aSmrg	if func_lalib_unsafe_p "$opt"; then
4075e9fcaa8aSmrg	  func_append libs " $opt"
4076e9fcaa8aSmrg	else
4077862bcd1aSmrg	  func_warning "'$opt' is not a valid libtool archive"
4078e9fcaa8aSmrg	fi
4079e9fcaa8aSmrg
4080e9fcaa8aSmrg      else
4081862bcd1aSmrg	func_fatal_error "invalid argument '$opt'"
4082e9fcaa8aSmrg      fi
4083e9fcaa8aSmrg    done
4084e9fcaa8aSmrg
4085e9fcaa8aSmrg    if test -n "$libs"; then
4086e9fcaa8aSmrg      if test -n "$lt_sysroot"; then
4087e9fcaa8aSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
4088e9fcaa8aSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
4089e9fcaa8aSmrg      else
4090e9fcaa8aSmrg        sysroot_cmd=
4091e9fcaa8aSmrg      fi
40921ab64890Smrg
4093e9fcaa8aSmrg      # Remove sysroot references
4094e9fcaa8aSmrg      if $opt_dry_run; then
4095e9fcaa8aSmrg        for lib in $libs; do
4096862bcd1aSmrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4097e9fcaa8aSmrg        done
4098e9fcaa8aSmrg      else
4099e9fcaa8aSmrg        tmpdir=`func_mktempdir`
4100e9fcaa8aSmrg        for lib in $libs; do
4101862bcd1aSmrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4102e9fcaa8aSmrg	    > $tmpdir/tmp-la
4103e9fcaa8aSmrg	  mv -f $tmpdir/tmp-la $lib
4104e9fcaa8aSmrg	done
4105e9fcaa8aSmrg        ${RM}r "$tmpdir"
4106e9fcaa8aSmrg      fi
4107e9fcaa8aSmrg    fi
4108e9fcaa8aSmrg
4109e9fcaa8aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
411088de56ccSmrg      for libdir in $libdirs; do
411188de56ccSmrg	if test -n "$finish_cmds"; then
411288de56ccSmrg	  # Do each command in the finish commands.
411388de56ccSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
411488de56ccSmrg'"$cmd"'"'
4115b4ee4795Smrg	fi
411688de56ccSmrg	if test -n "$finish_eval"; then
411788de56ccSmrg	  # Do the single finish_eval.
411888de56ccSmrg	  eval cmds=\"$finish_eval\"
4119e9fcaa8aSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
412088de56ccSmrg       $cmds"
412188de56ccSmrg	fi
412288de56ccSmrg      done
412388de56ccSmrg    fi
41241ab64890Smrg
412588de56ccSmrg    # Exit here if they wanted silent mode.
4126862bcd1aSmrg    $opt_quiet && exit $EXIT_SUCCESS
41271ab64890Smrg
4128e9fcaa8aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4129e9fcaa8aSmrg      echo "----------------------------------------------------------------------"
4130e9fcaa8aSmrg      echo "Libraries have been installed in:"
4131e9fcaa8aSmrg      for libdir in $libdirs; do
4132e9fcaa8aSmrg	$ECHO "   $libdir"
4133e9fcaa8aSmrg      done
4134e9fcaa8aSmrg      echo
4135e9fcaa8aSmrg      echo "If you ever happen to want to link against installed libraries"
4136e9fcaa8aSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
4137862bcd1aSmrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4138e9fcaa8aSmrg      echo "flag during linking and do at least one of the following:"
4139e9fcaa8aSmrg      if test -n "$shlibpath_var"; then
4140862bcd1aSmrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
4141e9fcaa8aSmrg	echo "     during execution"
4142e9fcaa8aSmrg      fi
4143e9fcaa8aSmrg      if test -n "$runpath_var"; then
4144862bcd1aSmrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
4145e9fcaa8aSmrg	echo "     during linking"
4146e9fcaa8aSmrg      fi
4147e9fcaa8aSmrg      if test -n "$hardcode_libdir_flag_spec"; then
4148e9fcaa8aSmrg	libdir=LIBDIR
4149e9fcaa8aSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
415088de56ccSmrg
4151862bcd1aSmrg	$ECHO "   - use the '$flag' linker flag"
4152e9fcaa8aSmrg      fi
4153e9fcaa8aSmrg      if test -n "$admincmds"; then
4154e9fcaa8aSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
4155e9fcaa8aSmrg      fi
4156e9fcaa8aSmrg      if test -f /etc/ld.so.conf; then
4157862bcd1aSmrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4158e9fcaa8aSmrg      fi
4159e9fcaa8aSmrg      echo
416088de56ccSmrg
4161e9fcaa8aSmrg      echo "See any operating system documentation about shared libraries for"
4162e9fcaa8aSmrg      case $host in
4163e9fcaa8aSmrg	solaris2.[6789]|solaris2.1[0-9])
4164e9fcaa8aSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4165e9fcaa8aSmrg	  echo "pages."
4166e9fcaa8aSmrg	  ;;
4167e9fcaa8aSmrg	*)
4168e9fcaa8aSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
4169e9fcaa8aSmrg	  ;;
4170e9fcaa8aSmrg      esac
4171e9fcaa8aSmrg      echo "----------------------------------------------------------------------"
4172e9fcaa8aSmrg    fi
417388de56ccSmrg    exit $EXIT_SUCCESS
417488de56ccSmrg}
417588de56ccSmrg
4176862bcd1aSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
417788de56ccSmrg
417888de56ccSmrg
417988de56ccSmrg# func_mode_install arg...
418088de56ccSmrgfunc_mode_install ()
418188de56ccSmrg{
4182862bcd1aSmrg    $debug_cmd
4183862bcd1aSmrg
418488de56ccSmrg    # There may be an optional sh(1) argument at the beginning of
418588de56ccSmrg    # install_prog (especially on Windows NT).
4186862bcd1aSmrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
418788de56ccSmrg       # Allow the use of GNU shtool's install command.
4188862bcd1aSmrg       case $nonopt in *shtool*) :;; *) false;; esac
4189862bcd1aSmrg    then
419088de56ccSmrg      # Aesthetically quote it.
419188de56ccSmrg      func_quote_for_eval "$nonopt"
419288de56ccSmrg      install_prog="$func_quote_for_eval_result "
419388de56ccSmrg      arg=$1
419488de56ccSmrg      shift
419588de56ccSmrg    else
419688de56ccSmrg      install_prog=
419788de56ccSmrg      arg=$nonopt
419888de56ccSmrg    fi
419988de56ccSmrg
420088de56ccSmrg    # The real first argument should be the name of the installation program.
420188de56ccSmrg    # Aesthetically quote it.
420288de56ccSmrg    func_quote_for_eval "$arg"
4203e9fcaa8aSmrg    func_append install_prog "$func_quote_for_eval_result"
4204e9fcaa8aSmrg    install_shared_prog=$install_prog
4205e9fcaa8aSmrg    case " $install_prog " in
4206e9fcaa8aSmrg      *[\\\ /]cp\ *) install_cp=: ;;
4207e9fcaa8aSmrg      *) install_cp=false ;;
4208e9fcaa8aSmrg    esac
420988de56ccSmrg
421088de56ccSmrg    # We need to accept at least all the BSD install flags.
421188de56ccSmrg    dest=
421288de56ccSmrg    files=
421388de56ccSmrg    opts=
421488de56ccSmrg    prev=
421588de56ccSmrg    install_type=
4216862bcd1aSmrg    isdir=false
421788de56ccSmrg    stripme=
4218e9fcaa8aSmrg    no_mode=:
421988de56ccSmrg    for arg
422088de56ccSmrg    do
4221e9fcaa8aSmrg      arg2=
422288de56ccSmrg      if test -n "$dest"; then
4223e9fcaa8aSmrg	func_append files " $dest"
422488de56ccSmrg	dest=$arg
422588de56ccSmrg	continue
422688de56ccSmrg      fi
422788de56ccSmrg
422888de56ccSmrg      case $arg in
4229862bcd1aSmrg      -d) isdir=: ;;
423088de56ccSmrg      -f)
4231e9fcaa8aSmrg	if $install_cp; then :; else
4232e9fcaa8aSmrg	  prev=$arg
4233e9fcaa8aSmrg	fi
423488de56ccSmrg	;;
423588de56ccSmrg      -g | -m | -o)
423688de56ccSmrg	prev=$arg
423788de56ccSmrg	;;
423888de56ccSmrg      -s)
423988de56ccSmrg	stripme=" -s"
424088de56ccSmrg	continue
424188de56ccSmrg	;;
424288de56ccSmrg      -*)
424388de56ccSmrg	;;
424488de56ccSmrg      *)
424588de56ccSmrg	# If the previous option needed an argument, then skip it.
424688de56ccSmrg	if test -n "$prev"; then
4247862bcd1aSmrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
4248e9fcaa8aSmrg	    arg2=$install_override_mode
4249e9fcaa8aSmrg	    no_mode=false
4250e9fcaa8aSmrg	  fi
4251b4ee4795Smrg	  prev=
42522e9c7c8cSmrg	else
425388de56ccSmrg	  dest=$arg
425488de56ccSmrg	  continue
42551ab64890Smrg	fi
4256b4ee4795Smrg	;;
425788de56ccSmrg      esac
42581ab64890Smrg
425988de56ccSmrg      # Aesthetically quote the argument.
426088de56ccSmrg      func_quote_for_eval "$arg"
4261e9fcaa8aSmrg      func_append install_prog " $func_quote_for_eval_result"
4262e9fcaa8aSmrg      if test -n "$arg2"; then
4263e9fcaa8aSmrg	func_quote_for_eval "$arg2"
4264e9fcaa8aSmrg      fi
4265e9fcaa8aSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
426688de56ccSmrg    done
42671ab64890Smrg
426888de56ccSmrg    test -z "$install_prog" && \
426988de56ccSmrg      func_fatal_help "you must specify an install program"
42701ab64890Smrg
427188de56ccSmrg    test -n "$prev" && \
4272862bcd1aSmrg      func_fatal_help "the '$prev' option requires an argument"
42732e9c7c8cSmrg
4274e9fcaa8aSmrg    if test -n "$install_override_mode" && $no_mode; then
4275e9fcaa8aSmrg      if $install_cp; then :; else
4276e9fcaa8aSmrg	func_quote_for_eval "$install_override_mode"
4277e9fcaa8aSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
4278e9fcaa8aSmrg      fi
4279e9fcaa8aSmrg    fi
4280e9fcaa8aSmrg
428188de56ccSmrg    if test -z "$files"; then
428288de56ccSmrg      if test -z "$dest"; then
428388de56ccSmrg	func_fatal_help "no file or destination specified"
428488de56ccSmrg      else
428588de56ccSmrg	func_fatal_help "you must specify a destination"
428688de56ccSmrg      fi
4287b4ee4795Smrg    fi
42882e9c7c8cSmrg
428988de56ccSmrg    # Strip any trailing slash from the destination.
429088de56ccSmrg    func_stripname '' '/' "$dest"
429188de56ccSmrg    dest=$func_stripname_result
42922e9c7c8cSmrg
429388de56ccSmrg    # Check to see that the destination is a directory.
4294862bcd1aSmrg    test -d "$dest" && isdir=:
4295862bcd1aSmrg    if $isdir; then
4296862bcd1aSmrg      destdir=$dest
429788de56ccSmrg      destname=
4298b4ee4795Smrg    else
429988de56ccSmrg      func_dirname_and_basename "$dest" "" "."
4300862bcd1aSmrg      destdir=$func_dirname_result
4301862bcd1aSmrg      destname=$func_basename_result
43022e9c7c8cSmrg
430388de56ccSmrg      # Not a directory, so check to see that there is only one file specified.
430488de56ccSmrg      set dummy $files; shift
430588de56ccSmrg      test "$#" -gt 1 && \
4306862bcd1aSmrg	func_fatal_help "'$dest' is not a directory"
43072e9c7c8cSmrg    fi
430888de56ccSmrg    case $destdir in
430988de56ccSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
4310b4ee4795Smrg    *)
431188de56ccSmrg      for file in $files; do
431288de56ccSmrg	case $file in
431388de56ccSmrg	*.lo) ;;
431488de56ccSmrg	*)
4315862bcd1aSmrg	  func_fatal_help "'$destdir' must be an absolute directory name"
431688de56ccSmrg	  ;;
431788de56ccSmrg	esac
431888de56ccSmrg      done
4319b4ee4795Smrg      ;;
4320b4ee4795Smrg    esac
43211ab64890Smrg
432288de56ccSmrg    # This variable tells wrapper scripts just to set variables rather
432388de56ccSmrg    # than running their programs.
4324862bcd1aSmrg    libtool_install_magic=$magic
43251ab64890Smrg
432688de56ccSmrg    staticlibs=
432788de56ccSmrg    future_libdirs=
432888de56ccSmrg    current_libdirs=
432988de56ccSmrg    for file in $files; do
43301ab64890Smrg
433188de56ccSmrg      # Do each installation.
433288de56ccSmrg      case $file in
433388de56ccSmrg      *.$libext)
433488de56ccSmrg	# Do the static libraries later.
4335e9fcaa8aSmrg	func_append staticlibs " $file"
433688de56ccSmrg	;;
433788de56ccSmrg
433888de56ccSmrg      *.la)
4339e9fcaa8aSmrg	func_resolve_sysroot "$file"
4340e9fcaa8aSmrg	file=$func_resolve_sysroot_result
4341e9fcaa8aSmrg
434288de56ccSmrg	# Check to see that this really is a libtool archive.
434388de56ccSmrg	func_lalib_unsafe_p "$file" \
4344862bcd1aSmrg	  || func_fatal_help "'$file' is not a valid libtool archive"
434588de56ccSmrg
434688de56ccSmrg	library_names=
434788de56ccSmrg	old_library=
434888de56ccSmrg	relink_command=
434988de56ccSmrg	func_source "$file"
435088de56ccSmrg
435188de56ccSmrg	# Add the libdir to current_libdirs if it is the destination.
435288de56ccSmrg	if test "X$destdir" = "X$libdir"; then
435388de56ccSmrg	  case "$current_libdirs " in
435488de56ccSmrg	  *" $libdir "*) ;;
4355e9fcaa8aSmrg	  *) func_append current_libdirs " $libdir" ;;
43562e9c7c8cSmrg	  esac
435788de56ccSmrg	else
435888de56ccSmrg	  # Note the libdir as a future libdir.
435988de56ccSmrg	  case "$future_libdirs " in
436088de56ccSmrg	  *" $libdir "*) ;;
4361e9fcaa8aSmrg	  *) func_append future_libdirs " $libdir" ;;
436288de56ccSmrg	  esac
436388de56ccSmrg	fi
43642e9c7c8cSmrg
436588de56ccSmrg	func_dirname "$file" "/" ""
4366862bcd1aSmrg	dir=$func_dirname_result
4367e9fcaa8aSmrg	func_append dir "$objdir"
436888de56ccSmrg
436988de56ccSmrg	if test -n "$relink_command"; then
437088de56ccSmrg	  # Determine the prefix the user has applied to our future dir.
4371e9fcaa8aSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
437288de56ccSmrg
437388de56ccSmrg	  # Don't allow the user to place us outside of our expected
437488de56ccSmrg	  # location b/c this prevents finding dependent libraries that
437588de56ccSmrg	  # are installed to the same prefix.
437688de56ccSmrg	  # At present, this check doesn't affect windows .dll's that
437788de56ccSmrg	  # are installed into $libdir/../bin (currently, that works fine)
437888de56ccSmrg	  # but it's something to keep an eye on.
437988de56ccSmrg	  test "$inst_prefix_dir" = "$destdir" && \
4380862bcd1aSmrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
438188de56ccSmrg
438288de56ccSmrg	  if test -n "$inst_prefix_dir"; then
438388de56ccSmrg	    # Stick the inst_prefix_dir data into the link command.
4384e9fcaa8aSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
438588de56ccSmrg	  else
4386e9fcaa8aSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
438788de56ccSmrg	  fi
438888de56ccSmrg
4389862bcd1aSmrg	  func_warning "relinking '$file'"
439088de56ccSmrg	  func_show_eval "$relink_command" \
4391862bcd1aSmrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
439288de56ccSmrg	fi
439388de56ccSmrg
439488de56ccSmrg	# See the names of the shared library.
439588de56ccSmrg	set dummy $library_names; shift
439688de56ccSmrg	if test -n "$1"; then
4397862bcd1aSmrg	  realname=$1
439888de56ccSmrg	  shift
439988de56ccSmrg
4400862bcd1aSmrg	  srcname=$realname
4401862bcd1aSmrg	  test -n "$relink_command" && srcname=${realname}T
440288de56ccSmrg
440388de56ccSmrg	  # Install the shared library and build the symlinks.
4404e9fcaa8aSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
440588de56ccSmrg	      'exit $?'
4406862bcd1aSmrg	  tstripme=$stripme
440788de56ccSmrg	  case $host_os in
440888de56ccSmrg	  cygwin* | mingw* | pw32* | cegcc*)
440988de56ccSmrg	    case $realname in
441088de56ccSmrg	    *.dll.a)
4411862bcd1aSmrg	      tstripme=
4412862bcd1aSmrg	      ;;
4413862bcd1aSmrg	    esac
4414862bcd1aSmrg	    ;;
4415862bcd1aSmrg	  os2*)
4416862bcd1aSmrg	    case $realname in
4417862bcd1aSmrg	    *_dll.a)
4418862bcd1aSmrg	      tstripme=
441988de56ccSmrg	      ;;
442088de56ccSmrg	    esac
44212e9c7c8cSmrg	    ;;
44222e9c7c8cSmrg	  esac
442388de56ccSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
442488de56ccSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
4425b4ee4795Smrg	  fi
442688de56ccSmrg
442788de56ccSmrg	  if test "$#" -gt 0; then
442888de56ccSmrg	    # Delete the old symlinks, and create new ones.
4429862bcd1aSmrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
443088de56ccSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
443188de56ccSmrg	    # so we also need to try rm && ln -s.
443288de56ccSmrg	    for linkname
443388de56ccSmrg	    do
443488de56ccSmrg	      test "$linkname" != "$realname" \
443588de56ccSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4436b4ee4795Smrg	    done
4437b4ee4795Smrg	  fi
44381ab64890Smrg
443988de56ccSmrg	  # Do each command in the postinstall commands.
4440862bcd1aSmrg	  lib=$destdir/$realname
444188de56ccSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
4442b4ee4795Smrg	fi
44431ab64890Smrg
444488de56ccSmrg	# Install the pseudo-library for information purposes.
444588de56ccSmrg	func_basename "$file"
4446862bcd1aSmrg	name=$func_basename_result
4447862bcd1aSmrg	instname=$dir/${name}i
444888de56ccSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
44491ab64890Smrg
445088de56ccSmrg	# Maybe install the static library, too.
4451e9fcaa8aSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
445288de56ccSmrg	;;
44531ab64890Smrg
445488de56ccSmrg      *.lo)
445588de56ccSmrg	# Install (i.e. copy) a libtool object.
44561ab64890Smrg
445788de56ccSmrg	# Figure out destination file name, if it wasn't already specified.
445888de56ccSmrg	if test -n "$destname"; then
4459862bcd1aSmrg	  destfile=$destdir/$destname
446088de56ccSmrg	else
446188de56ccSmrg	  func_basename "$file"
4462862bcd1aSmrg	  destfile=$func_basename_result
4463862bcd1aSmrg	  destfile=$destdir/$destfile
4464b4ee4795Smrg	fi
44651ab64890Smrg
446688de56ccSmrg	# Deduce the name of the destination old-style object file.
446788de56ccSmrg	case $destfile in
446888de56ccSmrg	*.lo)
446988de56ccSmrg	  func_lo2o "$destfile"
447088de56ccSmrg	  staticdest=$func_lo2o_result
447188de56ccSmrg	  ;;
447288de56ccSmrg	*.$objext)
4473862bcd1aSmrg	  staticdest=$destfile
447488de56ccSmrg	  destfile=
447588de56ccSmrg	  ;;
447688de56ccSmrg	*)
4477862bcd1aSmrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
447888de56ccSmrg	  ;;
447988de56ccSmrg	esac
44801ab64890Smrg
448188de56ccSmrg	# Install the libtool object if requested.
448288de56ccSmrg	test -n "$destfile" && \
448388de56ccSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
44841ab64890Smrg
448588de56ccSmrg	# Install the old object if enabled.
4486862bcd1aSmrg	if test yes = "$build_old_libs"; then
448788de56ccSmrg	  # Deduce the name of the old-style object file.
448888de56ccSmrg	  func_lo2o "$file"
448988de56ccSmrg	  staticobj=$func_lo2o_result
449088de56ccSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
44911ab64890Smrg	fi
449288de56ccSmrg	exit $EXIT_SUCCESS
449388de56ccSmrg	;;
44941ab64890Smrg
449588de56ccSmrg      *)
449688de56ccSmrg	# Figure out destination file name, if it wasn't already specified.
449788de56ccSmrg	if test -n "$destname"; then
4498862bcd1aSmrg	  destfile=$destdir/$destname
449988de56ccSmrg	else
450088de56ccSmrg	  func_basename "$file"
4501862bcd1aSmrg	  destfile=$func_basename_result
4502862bcd1aSmrg	  destfile=$destdir/$destfile
450388de56ccSmrg	fi
45041ab64890Smrg
450588de56ccSmrg	# If the file is missing, and there is a .exe on the end, strip it
450688de56ccSmrg	# because it is most likely a libtool script we actually want to
450788de56ccSmrg	# install
4508862bcd1aSmrg	stripped_ext=
450988de56ccSmrg	case $file in
451088de56ccSmrg	  *.exe)
451188de56ccSmrg	    if test ! -f "$file"; then
451288de56ccSmrg	      func_stripname '' '.exe' "$file"
451388de56ccSmrg	      file=$func_stripname_result
4514862bcd1aSmrg	      stripped_ext=.exe
451588de56ccSmrg	    fi
451688de56ccSmrg	    ;;
451788de56ccSmrg	esac
451888de56ccSmrg
451988de56ccSmrg	# Do a test to see if this is really a libtool program.
452088de56ccSmrg	case $host in
452188de56ccSmrg	*cygwin* | *mingw*)
452288de56ccSmrg	    if func_ltwrapper_executable_p "$file"; then
452388de56ccSmrg	      func_ltwrapper_scriptname "$file"
452488de56ccSmrg	      wrapper=$func_ltwrapper_scriptname_result
452588de56ccSmrg	    else
452688de56ccSmrg	      func_stripname '' '.exe' "$file"
452788de56ccSmrg	      wrapper=$func_stripname_result
452888de56ccSmrg	    fi
452988de56ccSmrg	    ;;
4530b4ee4795Smrg	*)
453188de56ccSmrg	    wrapper=$file
453288de56ccSmrg	    ;;
453388de56ccSmrg	esac
453488de56ccSmrg	if func_ltwrapper_script_p "$wrapper"; then
453588de56ccSmrg	  notinst_deplibs=
453688de56ccSmrg	  relink_command=
453788de56ccSmrg
453888de56ccSmrg	  func_source "$wrapper"
453988de56ccSmrg
454088de56ccSmrg	  # Check the variables that should have been set.
454188de56ccSmrg	  test -z "$generated_by_libtool_version" && \
4542862bcd1aSmrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
454388de56ccSmrg
4544862bcd1aSmrg	  finalize=:
454588de56ccSmrg	  for lib in $notinst_deplibs; do
454688de56ccSmrg	    # Check to see that each library is installed.
454788de56ccSmrg	    libdir=
454888de56ccSmrg	    if test -f "$lib"; then
454988de56ccSmrg	      func_source "$lib"
455088de56ccSmrg	    fi
4551862bcd1aSmrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
455288de56ccSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
4553862bcd1aSmrg	      func_warning "'$lib' has not been installed in '$libdir'"
4554862bcd1aSmrg	      finalize=false
455588de56ccSmrg	    fi
455688de56ccSmrg	  done
455788de56ccSmrg
455888de56ccSmrg	  relink_command=
455988de56ccSmrg	  func_source "$wrapper"
456088de56ccSmrg
456188de56ccSmrg	  outputname=
4562862bcd1aSmrg	  if test no = "$fast_install" && test -n "$relink_command"; then
456388de56ccSmrg	    $opt_dry_run || {
4564862bcd1aSmrg	      if $finalize; then
456588de56ccSmrg	        tmpdir=`func_mktempdir`
456688de56ccSmrg		func_basename "$file$stripped_ext"
4567862bcd1aSmrg		file=$func_basename_result
4568862bcd1aSmrg	        outputname=$tmpdir/$file
456988de56ccSmrg	        # Replace the output file specification.
4570e9fcaa8aSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
457188de56ccSmrg
4572862bcd1aSmrg	        $opt_quiet || {
457388de56ccSmrg	          func_quote_for_expand "$relink_command"
457488de56ccSmrg		  eval "func_echo $func_quote_for_expand_result"
457588de56ccSmrg	        }
457688de56ccSmrg	        if eval "$relink_command"; then :
457788de56ccSmrg	          else
4578862bcd1aSmrg		  func_error "error: relink '$file' with the above command before installing it"
457988de56ccSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
458088de56ccSmrg		  continue
458188de56ccSmrg	        fi
4582862bcd1aSmrg	        file=$outputname
458388de56ccSmrg	      else
4584862bcd1aSmrg	        func_warning "cannot relink '$file'"
458588de56ccSmrg	      fi
458688de56ccSmrg	    }
458788de56ccSmrg	  else
458888de56ccSmrg	    # Install the binary that we compiled earlier.
4589e9fcaa8aSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4590b4ee4795Smrg	  fi
459188de56ccSmrg	fi
459288de56ccSmrg
459388de56ccSmrg	# remove .exe since cygwin /usr/bin/install will append another
459488de56ccSmrg	# one anyway
459588de56ccSmrg	case $install_prog,$host in
459688de56ccSmrg	*/usr/bin/install*,*cygwin*)
459788de56ccSmrg	  case $file:$destfile in
459888de56ccSmrg	  *.exe:*.exe)
459988de56ccSmrg	    # this is ok
460088de56ccSmrg	    ;;
460188de56ccSmrg	  *.exe:*)
460288de56ccSmrg	    destfile=$destfile.exe
460388de56ccSmrg	    ;;
460488de56ccSmrg	  *:*.exe)
460588de56ccSmrg	    func_stripname '' '.exe' "$destfile"
460688de56ccSmrg	    destfile=$func_stripname_result
460788de56ccSmrg	    ;;
460888de56ccSmrg	  esac
4609b4ee4795Smrg	  ;;
4610b4ee4795Smrg	esac
461188de56ccSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
461288de56ccSmrg	$opt_dry_run || if test -n "$outputname"; then
461388de56ccSmrg	  ${RM}r "$tmpdir"
461488de56ccSmrg	fi
461588de56ccSmrg	;;
461688de56ccSmrg      esac
461788de56ccSmrg    done
46181ab64890Smrg
461988de56ccSmrg    for file in $staticlibs; do
462088de56ccSmrg      func_basename "$file"
4621862bcd1aSmrg      name=$func_basename_result
462288de56ccSmrg
462388de56ccSmrg      # Set up the ranlib parameters.
4624862bcd1aSmrg      oldlib=$destdir/$name
4625eb411b4bSmrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4626eb411b4bSmrg      tool_oldlib=$func_to_tool_file_result
462788de56ccSmrg
462888de56ccSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
462988de56ccSmrg
463088de56ccSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
4631eb411b4bSmrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
463288de56ccSmrg      fi
463388de56ccSmrg
463488de56ccSmrg      # Do each command in the postinstall commands.
463588de56ccSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
463688de56ccSmrg    done
463788de56ccSmrg
463888de56ccSmrg    test -n "$future_libdirs" && \
4639862bcd1aSmrg      func_warning "remember to run '$progname --finish$future_libdirs'"
464088de56ccSmrg
464188de56ccSmrg    if test -n "$current_libdirs"; then
464288de56ccSmrg      # Maybe just do a dry run.
464388de56ccSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
4644862bcd1aSmrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
464588de56ccSmrg    else
464688de56ccSmrg      exit $EXIT_SUCCESS
464788de56ccSmrg    fi
464888de56ccSmrg}
464988de56ccSmrg
4650862bcd1aSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
465188de56ccSmrg
465288de56ccSmrg
465388de56ccSmrg# func_generate_dlsyms outputname originator pic_p
465488de56ccSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
465588de56ccSmrg# a dlpreopen symbol table.
465688de56ccSmrgfunc_generate_dlsyms ()
465788de56ccSmrg{
4658862bcd1aSmrg    $debug_cmd
4659862bcd1aSmrg
4660862bcd1aSmrg    my_outputname=$1
4661862bcd1aSmrg    my_originator=$2
4662862bcd1aSmrg    my_pic_p=${3-false}
4663862bcd1aSmrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
466488de56ccSmrg    my_dlsyms=
466588de56ccSmrg
4666862bcd1aSmrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
466788de56ccSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
4668862bcd1aSmrg	my_dlsyms=${my_outputname}S.c
466988de56ccSmrg      else
467088de56ccSmrg	func_error "not configured to extract global symbols from dlpreopened files"
467188de56ccSmrg      fi
467288de56ccSmrg    fi
467388de56ccSmrg
467488de56ccSmrg    if test -n "$my_dlsyms"; then
467588de56ccSmrg      case $my_dlsyms in
467688de56ccSmrg      "") ;;
467788de56ccSmrg      *.c)
467888de56ccSmrg	# Discover the nlist of each of the dlfiles.
4679862bcd1aSmrg	nlist=$output_objdir/$my_outputname.nm
468088de56ccSmrg
468188de56ccSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
468288de56ccSmrg
468388de56ccSmrg	# Parse the name list into a source file.
468488de56ccSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
468588de56ccSmrg
468688de56ccSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
4687862bcd1aSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
4688862bcd1aSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
468988de56ccSmrg
469088de56ccSmrg#ifdef __cplusplus
469188de56ccSmrgextern \"C\" {
469288de56ccSmrg#endif
469388de56ccSmrg
4694862bcd1aSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4695e9fcaa8aSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4696e9fcaa8aSmrg#endif
4697e9fcaa8aSmrg
4698e9fcaa8aSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
4699862bcd1aSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
4700862bcd1aSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
4701e9fcaa8aSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
4702e9fcaa8aSmrg# define LT_DLSYM_CONST
4703862bcd1aSmrg#elif defined __osf__
4704e9fcaa8aSmrg/* This system does not cope well with relocations in const data.  */
4705e9fcaa8aSmrg# define LT_DLSYM_CONST
4706e9fcaa8aSmrg#else
4707e9fcaa8aSmrg# define LT_DLSYM_CONST const
4708e9fcaa8aSmrg#endif
4709e9fcaa8aSmrg
4710862bcd1aSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
4711862bcd1aSmrg
471288de56ccSmrg/* External symbol declarations for the compiler. */\
471388de56ccSmrg"
471488de56ccSmrg
4715862bcd1aSmrg	if test yes = "$dlself"; then
4716862bcd1aSmrg	  func_verbose "generating symbol list for '$output'"
471788de56ccSmrg
471888de56ccSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
471988de56ccSmrg
472088de56ccSmrg	  # Add our own program objects to the symbol list.
4721e9fcaa8aSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
472288de56ccSmrg	  for progfile in $progfiles; do
4723e9fcaa8aSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
4724862bcd1aSmrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4725e9fcaa8aSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
472688de56ccSmrg	  done
472788de56ccSmrg
472888de56ccSmrg	  if test -n "$exclude_expsyms"; then
472988de56ccSmrg	    $opt_dry_run || {
473088de56ccSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
473188de56ccSmrg	      eval '$MV "$nlist"T "$nlist"'
473288de56ccSmrg	    }
4733b4ee4795Smrg	  fi
473488de56ccSmrg
473588de56ccSmrg	  if test -n "$export_symbols_regex"; then
473688de56ccSmrg	    $opt_dry_run || {
473788de56ccSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
473888de56ccSmrg	      eval '$MV "$nlist"T "$nlist"'
473988de56ccSmrg	    }
474088de56ccSmrg	  fi
474188de56ccSmrg
474288de56ccSmrg	  # Prepare the list of exported symbols
474388de56ccSmrg	  if test -z "$export_symbols"; then
4744862bcd1aSmrg	    export_symbols=$output_objdir/$outputname.exp
474588de56ccSmrg	    $opt_dry_run || {
474688de56ccSmrg	      $RM $export_symbols
4747862bcd1aSmrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
474888de56ccSmrg	      case $host in
474988de56ccSmrg	      *cygwin* | *mingw* | *cegcc* )
475088de56ccSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
475188de56ccSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
475288de56ccSmrg	        ;;
475388de56ccSmrg	      esac
475488de56ccSmrg	    }
4755b4ee4795Smrg	  else
475688de56ccSmrg	    $opt_dry_run || {
4757862bcd1aSmrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
475888de56ccSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
475988de56ccSmrg	      eval '$MV "$nlist"T "$nlist"'
476088de56ccSmrg	      case $host in
4761e9fcaa8aSmrg	        *cygwin* | *mingw* | *cegcc* )
476288de56ccSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
476388de56ccSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
476488de56ccSmrg	          ;;
476588de56ccSmrg	      esac
476688de56ccSmrg	    }
4767b4ee4795Smrg	  fi
476888de56ccSmrg	fi
47691ab64890Smrg
477088de56ccSmrg	for dlprefile in $dlprefiles; do
4771862bcd1aSmrg	  func_verbose "extracting global C symbols from '$dlprefile'"
477288de56ccSmrg	  func_basename "$dlprefile"
4773862bcd1aSmrg	  name=$func_basename_result
4774e9fcaa8aSmrg          case $host in
4775e9fcaa8aSmrg	    *cygwin* | *mingw* | *cegcc* )
4776e9fcaa8aSmrg	      # if an import library, we need to obtain dlname
4777e9fcaa8aSmrg	      if func_win32_import_lib_p "$dlprefile"; then
4778e9fcaa8aSmrg	        func_tr_sh "$dlprefile"
4779e9fcaa8aSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
4780862bcd1aSmrg	        dlprefile_dlbasename=
4781e9fcaa8aSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4782e9fcaa8aSmrg	          # Use subshell, to avoid clobbering current variable values
4783e9fcaa8aSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
4784862bcd1aSmrg	          if test -n "$dlprefile_dlname"; then
4785e9fcaa8aSmrg	            func_basename "$dlprefile_dlname"
4786862bcd1aSmrg	            dlprefile_dlbasename=$func_basename_result
4787e9fcaa8aSmrg	          else
4788e9fcaa8aSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
4789e9fcaa8aSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
4790e9fcaa8aSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
4791e9fcaa8aSmrg	          fi
4792e9fcaa8aSmrg	        fi
4793e9fcaa8aSmrg	        $opt_dry_run || {
4794862bcd1aSmrg	          if test -n "$dlprefile_dlbasename"; then
4795e9fcaa8aSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4796e9fcaa8aSmrg	          else
4797e9fcaa8aSmrg	            func_warning "Could not compute DLL name from $name"
4798e9fcaa8aSmrg	            eval '$ECHO ": $name " >> "$nlist"'
4799e9fcaa8aSmrg	          fi
4800e9fcaa8aSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4801e9fcaa8aSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4802e9fcaa8aSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4803e9fcaa8aSmrg	        }
4804e9fcaa8aSmrg	      else # not an import lib
4805e9fcaa8aSmrg	        $opt_dry_run || {
4806e9fcaa8aSmrg	          eval '$ECHO ": $name " >> "$nlist"'
4807e9fcaa8aSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4808e9fcaa8aSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4809e9fcaa8aSmrg	        }
4810e9fcaa8aSmrg	      fi
4811e9fcaa8aSmrg	    ;;
4812e9fcaa8aSmrg	    *)
4813e9fcaa8aSmrg	      $opt_dry_run || {
4814e9fcaa8aSmrg	        eval '$ECHO ": $name " >> "$nlist"'
4815e9fcaa8aSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4816e9fcaa8aSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4817e9fcaa8aSmrg	      }
4818e9fcaa8aSmrg	    ;;
4819e9fcaa8aSmrg          esac
482088de56ccSmrg	done
482188de56ccSmrg
482288de56ccSmrg	$opt_dry_run || {
482388de56ccSmrg	  # Make sure we have at least an empty file.
482488de56ccSmrg	  test -f "$nlist" || : > "$nlist"
482588de56ccSmrg
482688de56ccSmrg	  if test -n "$exclude_expsyms"; then
482788de56ccSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
482888de56ccSmrg	    $MV "$nlist"T "$nlist"
4829b4ee4795Smrg	  fi
483088de56ccSmrg
483188de56ccSmrg	  # Try sorting and uniquifying the output.
483288de56ccSmrg	  if $GREP -v "^: " < "$nlist" |
483388de56ccSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
483488de56ccSmrg		sort -k 3
483588de56ccSmrg	      else
483688de56ccSmrg		sort +2
483788de56ccSmrg	      fi |
483888de56ccSmrg	      uniq > "$nlist"S; then
483988de56ccSmrg	    :
4840b4ee4795Smrg	  else
484188de56ccSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
4842b4ee4795Smrg	  fi
48431ab64890Smrg
484488de56ccSmrg	  if test -f "$nlist"S; then
484588de56ccSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
4846b4ee4795Smrg	  else
4847e9fcaa8aSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
4848b4ee4795Smrg	  fi
48491ab64890Smrg
4850862bcd1aSmrg	  func_show_eval '$RM "${nlist}I"'
4851862bcd1aSmrg	  if test -n "$global_symbol_to_import"; then
4852862bcd1aSmrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
4853862bcd1aSmrg	  fi
4854862bcd1aSmrg
4855e9fcaa8aSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
48561ab64890Smrg
485788de56ccSmrg/* The mapping between symbol names and symbols.  */
485888de56ccSmrgtypedef struct {
485988de56ccSmrg  const char *name;
486088de56ccSmrg  void *address;
486188de56ccSmrg} lt_dlsymlist;
4862e9fcaa8aSmrgextern LT_DLSYM_CONST lt_dlsymlist
4863862bcd1aSmrglt_${my_prefix}_LTX_preloaded_symbols[];\
4864862bcd1aSmrg"
4865862bcd1aSmrg
4866862bcd1aSmrg	  if test -s "$nlist"I; then
4867862bcd1aSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
4868862bcd1aSmrgstatic void lt_syminit(void)
4869862bcd1aSmrg{
4870862bcd1aSmrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
4871862bcd1aSmrg  for (; symbol->name; ++symbol)
4872862bcd1aSmrg    {"
4873862bcd1aSmrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
4874862bcd1aSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
4875862bcd1aSmrg    }
4876862bcd1aSmrg}"
4877862bcd1aSmrg	  fi
4878862bcd1aSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
4879e9fcaa8aSmrgLT_DLSYM_CONST lt_dlsymlist
488088de56ccSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
4881862bcd1aSmrg{ {\"$my_originator\", (void *) 0},"
4882862bcd1aSmrg
4883862bcd1aSmrg	  if test -s "$nlist"I; then
4884862bcd1aSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
4885862bcd1aSmrg  {\"@INIT@\", (void *) &lt_syminit},"
4886862bcd1aSmrg	  fi
48871ab64890Smrg
488888de56ccSmrg	  case $need_lib_prefix in
488988de56ccSmrg	  no)
489088de56ccSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
489188de56ccSmrg	    ;;
489288de56ccSmrg	  *)
489388de56ccSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
489488de56ccSmrg	    ;;
489588de56ccSmrg	  esac
4896e9fcaa8aSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
489788de56ccSmrg  {0, (void *) 0}
489888de56ccSmrg};
48991ab64890Smrg
490088de56ccSmrg/* This works around a problem in FreeBSD linker */
490188de56ccSmrg#ifdef FREEBSD_WORKAROUND
490288de56ccSmrgstatic const void *lt_preloaded_setup() {
490388de56ccSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
490488de56ccSmrg}
490588de56ccSmrg#endif
490688de56ccSmrg
490788de56ccSmrg#ifdef __cplusplus
490888de56ccSmrg}
490988de56ccSmrg#endif\
491088de56ccSmrg"
491188de56ccSmrg	} # !$opt_dry_run
491288de56ccSmrg
491388de56ccSmrg	pic_flag_for_symtable=
491488de56ccSmrg	case "$compile_command " in
491588de56ccSmrg	*" -static "*) ;;
491688de56ccSmrg	*)
491788de56ccSmrg	  case $host in
491888de56ccSmrg	  # compiling the symbol table file with pic_flag works around
491988de56ccSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
492088de56ccSmrg	  # linked before any other PIC object.  But we must not use
492188de56ccSmrg	  # pic_flag when linking with -static.  The problem exists in
492288de56ccSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4923eb411b4bSmrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
492488de56ccSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
492588de56ccSmrg	  *-*-hpux*)
492688de56ccSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
492788de56ccSmrg	  *)
4928862bcd1aSmrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
492988de56ccSmrg	    ;;
493088de56ccSmrg	  esac
493188de56ccSmrg	  ;;
493288de56ccSmrg	esac
493388de56ccSmrg	symtab_cflags=
493488de56ccSmrg	for arg in $LTCFLAGS; do
493588de56ccSmrg	  case $arg in
493688de56ccSmrg	  -pie | -fpie | -fPIE) ;;
4937e9fcaa8aSmrg	  *) func_append symtab_cflags " $arg" ;;
493888de56ccSmrg	  esac
493988de56ccSmrg	done
49401ab64890Smrg
494188de56ccSmrg	# Now compile the dynamic symbol file.
494288de56ccSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
49432e9c7c8cSmrg
494488de56ccSmrg	# Clean up the generated files.
4945862bcd1aSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
49461ab64890Smrg
494788de56ccSmrg	# Transform the symbol file into the correct name.
4948862bcd1aSmrg	symfileobj=$output_objdir/${my_outputname}S.$objext
494988de56ccSmrg	case $host in
495088de56ccSmrg	*cygwin* | *mingw* | *cegcc* )
495188de56ccSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
4952e9fcaa8aSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4953e9fcaa8aSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
495488de56ccSmrg	  else
4955e9fcaa8aSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4956e9fcaa8aSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4957b4ee4795Smrg	  fi
495888de56ccSmrg	  ;;
495988de56ccSmrg	*)
4960e9fcaa8aSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4961e9fcaa8aSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
496288de56ccSmrg	  ;;
496388de56ccSmrg	esac
496488de56ccSmrg	;;
496588de56ccSmrg      *)
4966862bcd1aSmrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
496788de56ccSmrg	;;
496888de56ccSmrg      esac
496988de56ccSmrg    else
497088de56ccSmrg      # We keep going just in case the user didn't refer to
497188de56ccSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
497288de56ccSmrg      # really was required.
49731ab64890Smrg
497488de56ccSmrg      # Nullify the symbol file.
4975e9fcaa8aSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4976e9fcaa8aSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
497788de56ccSmrg    fi
497888de56ccSmrg}
49792e9c7c8cSmrg
4980862bcd1aSmrg# func_cygming_gnu_implib_p ARG
4981862bcd1aSmrg# This predicate returns with zero status (TRUE) if
4982862bcd1aSmrg# ARG is a GNU/binutils-style import library. Returns
4983862bcd1aSmrg# with nonzero status (FALSE) otherwise.
4984862bcd1aSmrgfunc_cygming_gnu_implib_p ()
4985862bcd1aSmrg{
4986862bcd1aSmrg  $debug_cmd
4987862bcd1aSmrg
4988862bcd1aSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
4989862bcd1aSmrg  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)$'`
4990862bcd1aSmrg  test -n "$func_cygming_gnu_implib_tmp"
4991862bcd1aSmrg}
4992862bcd1aSmrg
4993862bcd1aSmrg# func_cygming_ms_implib_p ARG
4994862bcd1aSmrg# This predicate returns with zero status (TRUE) if
4995862bcd1aSmrg# ARG is an MS-style import library. Returns
4996862bcd1aSmrg# with nonzero status (FALSE) otherwise.
4997862bcd1aSmrgfunc_cygming_ms_implib_p ()
4998862bcd1aSmrg{
4999862bcd1aSmrg  $debug_cmd
5000862bcd1aSmrg
5001862bcd1aSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
5002862bcd1aSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
5003862bcd1aSmrg  test -n "$func_cygming_ms_implib_tmp"
5004862bcd1aSmrg}
5005862bcd1aSmrg
500688de56ccSmrg# func_win32_libid arg
500788de56ccSmrg# return the library type of file 'arg'
500888de56ccSmrg#
500988de56ccSmrg# Need a lot of goo to handle *both* DLLs and import libs
501088de56ccSmrg# Has to be a shell function in order to 'eat' the argument
501188de56ccSmrg# that is supplied when $file_magic_command is called.
5012e9fcaa8aSmrg# Despite the name, also deal with 64 bit binaries.
501388de56ccSmrgfunc_win32_libid ()
501488de56ccSmrg{
5015862bcd1aSmrg  $debug_cmd
5016862bcd1aSmrg
5017862bcd1aSmrg  win32_libid_type=unknown
501888de56ccSmrg  win32_fileres=`file -L $1 2>/dev/null`
501988de56ccSmrg  case $win32_fileres in
502088de56ccSmrg  *ar\ archive\ import\ library*) # definitely import
502188de56ccSmrg    win32_libid_type="x86 archive import"
502288de56ccSmrg    ;;
502388de56ccSmrg  *ar\ archive*) # could be an import, or static
5024e9fcaa8aSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
502588de56ccSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
5026e9fcaa8aSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
5027862bcd1aSmrg      case $nm_interface in
5028862bcd1aSmrg      "MS dumpbin")
5029862bcd1aSmrg	if func_cygming_ms_implib_p "$1" ||
5030862bcd1aSmrg	   func_cygming_gnu_implib_p "$1"
5031862bcd1aSmrg	then
5032862bcd1aSmrg	  win32_nmres=import
5033862bcd1aSmrg	else
5034862bcd1aSmrg	  win32_nmres=
5035862bcd1aSmrg	fi
5036862bcd1aSmrg	;;
5037862bcd1aSmrg      *)
5038862bcd1aSmrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
5039862bcd1aSmrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
5040862bcd1aSmrg	  $SED -n -e '
504188de56ccSmrg	    1,100{
504288de56ccSmrg		/ I /{
5043862bcd1aSmrg		    s|.*|import|
504488de56ccSmrg		    p
504588de56ccSmrg		    q
504688de56ccSmrg		}
504788de56ccSmrg	    }'`
5048862bcd1aSmrg	;;
5049862bcd1aSmrg      esac
505088de56ccSmrg      case $win32_nmres in
505188de56ccSmrg      import*)  win32_libid_type="x86 archive import";;
505288de56ccSmrg      *)        win32_libid_type="x86 archive static";;
505388de56ccSmrg      esac
505488de56ccSmrg    fi
505588de56ccSmrg    ;;
505688de56ccSmrg  *DLL*)
505788de56ccSmrg    win32_libid_type="x86 DLL"
505888de56ccSmrg    ;;
505988de56ccSmrg  *executable*) # but shell scripts are "executable" too...
506088de56ccSmrg    case $win32_fileres in
506188de56ccSmrg    *MS\ Windows\ PE\ Intel*)
506288de56ccSmrg      win32_libid_type="x86 DLL"
506388de56ccSmrg      ;;
506488de56ccSmrg    esac
506588de56ccSmrg    ;;
506688de56ccSmrg  esac
506788de56ccSmrg  $ECHO "$win32_libid_type"
506888de56ccSmrg}
50692e9c7c8cSmrg
5070e9fcaa8aSmrg# func_cygming_dll_for_implib ARG
5071e9fcaa8aSmrg#
5072e9fcaa8aSmrg# Platform-specific function to extract the
5073e9fcaa8aSmrg# name of the DLL associated with the specified
5074e9fcaa8aSmrg# import library ARG.
5075e9fcaa8aSmrg# Invoked by eval'ing the libtool variable
5076e9fcaa8aSmrg#    $sharedlib_from_linklib_cmd
5077e9fcaa8aSmrg# Result is available in the variable
5078e9fcaa8aSmrg#    $sharedlib_from_linklib_result
5079e9fcaa8aSmrgfunc_cygming_dll_for_implib ()
5080e9fcaa8aSmrg{
5081862bcd1aSmrg  $debug_cmd
5082862bcd1aSmrg
5083e9fcaa8aSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
5084e9fcaa8aSmrg}
5085e9fcaa8aSmrg
5086e9fcaa8aSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
5087e9fcaa8aSmrg#
5088e9fcaa8aSmrg# The is the core of a fallback implementation of a
5089e9fcaa8aSmrg# platform-specific function to extract the name of the
5090e9fcaa8aSmrg# DLL associated with the specified import library LIBNAME.
5091e9fcaa8aSmrg#
5092e9fcaa8aSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
5093e9fcaa8aSmrg# on the platform and compiler that created the implib.
5094e9fcaa8aSmrg#
5095e9fcaa8aSmrg# Echos the name of the DLL associated with the
5096e9fcaa8aSmrg# specified import library.
5097e9fcaa8aSmrgfunc_cygming_dll_for_implib_fallback_core ()
5098e9fcaa8aSmrg{
5099862bcd1aSmrg  $debug_cmd
5100862bcd1aSmrg
5101e9fcaa8aSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5102e9fcaa8aSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5103e9fcaa8aSmrg    $SED '/^Contents of section '"$match_literal"':/{
5104e9fcaa8aSmrg      # Place marker at beginning of archive member dllname section
5105e9fcaa8aSmrg      s/.*/====MARK====/
5106e9fcaa8aSmrg      p
5107e9fcaa8aSmrg      d
5108e9fcaa8aSmrg    }
5109e9fcaa8aSmrg    # These lines can sometimes be longer than 43 characters, but
5110e9fcaa8aSmrg    # are always uninteresting
5111e9fcaa8aSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
5112e9fcaa8aSmrg    /^In archive [^:]*:/d
5113e9fcaa8aSmrg    # Ensure marker is printed
5114e9fcaa8aSmrg    /^====MARK====/p
5115e9fcaa8aSmrg    # Remove all lines with less than 43 characters
5116e9fcaa8aSmrg    /^.\{43\}/!d
5117e9fcaa8aSmrg    # From remaining lines, remove first 43 characters
5118e9fcaa8aSmrg    s/^.\{43\}//' |
5119e9fcaa8aSmrg    $SED -n '
5120e9fcaa8aSmrg      # Join marker and all lines until next marker into a single line
5121e9fcaa8aSmrg      /^====MARK====/ b para
5122e9fcaa8aSmrg      H
5123e9fcaa8aSmrg      $ b para
5124e9fcaa8aSmrg      b
5125e9fcaa8aSmrg      :para
5126e9fcaa8aSmrg      x
5127e9fcaa8aSmrg      s/\n//g
5128e9fcaa8aSmrg      # Remove the marker
5129e9fcaa8aSmrg      s/^====MARK====//
5130e9fcaa8aSmrg      # Remove trailing dots and whitespace
5131e9fcaa8aSmrg      s/[\. \t]*$//
5132e9fcaa8aSmrg      # Print
5133e9fcaa8aSmrg      /./p' |
5134e9fcaa8aSmrg    # we now have a list, one entry per line, of the stringified
5135e9fcaa8aSmrg    # contents of the appropriate section of all members of the
5136862bcd1aSmrg    # archive that possess that section. Heuristic: eliminate
5137862bcd1aSmrg    # all those that have a first or second character that is
5138e9fcaa8aSmrg    # a '.' (that is, objdump's representation of an unprintable
5139e9fcaa8aSmrg    # character.) This should work for all archives with less than
5140e9fcaa8aSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
5141e9fcaa8aSmrg    # begins with a literal '.' or a single character followed by
5142e9fcaa8aSmrg    # a '.'.
5143e9fcaa8aSmrg    #
5144e9fcaa8aSmrg    # Of those that remain, print the first one.
5145e9fcaa8aSmrg    $SED -e '/^\./d;/^.\./d;q'
5146e9fcaa8aSmrg}
5147e9fcaa8aSmrg
5148e9fcaa8aSmrg# func_cygming_dll_for_implib_fallback ARG
5149e9fcaa8aSmrg# Platform-specific function to extract the
5150e9fcaa8aSmrg# name of the DLL associated with the specified
5151e9fcaa8aSmrg# import library ARG.
5152e9fcaa8aSmrg#
5153e9fcaa8aSmrg# This fallback implementation is for use when $DLLTOOL
5154e9fcaa8aSmrg# does not support the --identify-strict option.
5155e9fcaa8aSmrg# Invoked by eval'ing the libtool variable
5156e9fcaa8aSmrg#    $sharedlib_from_linklib_cmd
5157e9fcaa8aSmrg# Result is available in the variable
5158e9fcaa8aSmrg#    $sharedlib_from_linklib_result
5159e9fcaa8aSmrgfunc_cygming_dll_for_implib_fallback ()
5160e9fcaa8aSmrg{
5161862bcd1aSmrg  $debug_cmd
5162862bcd1aSmrg
5163862bcd1aSmrg  if func_cygming_gnu_implib_p "$1"; then
5164e9fcaa8aSmrg    # binutils import library
5165e9fcaa8aSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
5166862bcd1aSmrg  elif func_cygming_ms_implib_p "$1"; then
5167e9fcaa8aSmrg    # ms-generated import library
5168e9fcaa8aSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5169e9fcaa8aSmrg  else
5170e9fcaa8aSmrg    # unknown
5171862bcd1aSmrg    sharedlib_from_linklib_result=
5172e9fcaa8aSmrg  fi
5173e9fcaa8aSmrg}
51742e9c7c8cSmrg
51752e9c7c8cSmrg
517688de56ccSmrg# func_extract_an_archive dir oldlib
517788de56ccSmrgfunc_extract_an_archive ()
517888de56ccSmrg{
5179862bcd1aSmrg    $debug_cmd
5180862bcd1aSmrg
5181862bcd1aSmrg    f_ex_an_ar_dir=$1; shift
5182862bcd1aSmrg    f_ex_an_ar_oldlib=$1
5183862bcd1aSmrg    if test yes = "$lock_old_archive_extraction"; then
5184e9fcaa8aSmrg      lockfile=$f_ex_an_ar_oldlib.lock
5185e9fcaa8aSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5186e9fcaa8aSmrg	func_echo "Waiting for $lockfile to be removed"
5187e9fcaa8aSmrg	sleep 2
5188e9fcaa8aSmrg      done
5189e9fcaa8aSmrg    fi
5190e9fcaa8aSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5191e9fcaa8aSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
5192862bcd1aSmrg    if test yes = "$lock_old_archive_extraction"; then
5193e9fcaa8aSmrg      $opt_dry_run || rm -f "$lockfile"
5194e9fcaa8aSmrg    fi
519588de56ccSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
519688de56ccSmrg     :
519788de56ccSmrg    else
519888de56ccSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
519988de56ccSmrg    fi
520088de56ccSmrg}
52011ab64890Smrg
52021ab64890Smrg
520388de56ccSmrg# func_extract_archives gentop oldlib ...
520488de56ccSmrgfunc_extract_archives ()
520588de56ccSmrg{
5206862bcd1aSmrg    $debug_cmd
5207862bcd1aSmrg
5208862bcd1aSmrg    my_gentop=$1; shift
520988de56ccSmrg    my_oldlibs=${1+"$@"}
5210862bcd1aSmrg    my_oldobjs=
5211862bcd1aSmrg    my_xlib=
5212862bcd1aSmrg    my_xabs=
5213862bcd1aSmrg    my_xdir=
52141ab64890Smrg
521588de56ccSmrg    for my_xlib in $my_oldlibs; do
521688de56ccSmrg      # Extract the objects.
521788de56ccSmrg      case $my_xlib in
5218862bcd1aSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
521988de56ccSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
522088de56ccSmrg      esac
522188de56ccSmrg      func_basename "$my_xlib"
5222862bcd1aSmrg      my_xlib=$func_basename_result
522388de56ccSmrg      my_xlib_u=$my_xlib
522488de56ccSmrg      while :; do
522588de56ccSmrg        case " $extracted_archives " in
522688de56ccSmrg	*" $my_xlib_u "*)
522788de56ccSmrg	  func_arith $extracted_serial + 1
522888de56ccSmrg	  extracted_serial=$func_arith_result
522988de56ccSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
523088de56ccSmrg	*) break ;;
523188de56ccSmrg	esac
523288de56ccSmrg      done
523388de56ccSmrg      extracted_archives="$extracted_archives $my_xlib_u"
5234862bcd1aSmrg      my_xdir=$my_gentop/$my_xlib_u
52351ab64890Smrg
523688de56ccSmrg      func_mkdir_p "$my_xdir"
52372e9c7c8cSmrg
523888de56ccSmrg      case $host in
523988de56ccSmrg      *-darwin*)
524088de56ccSmrg	func_verbose "Extracting $my_xabs"
524188de56ccSmrg	# Do not bother doing anything if just a dry run
524288de56ccSmrg	$opt_dry_run || {
524388de56ccSmrg	  darwin_orig_dir=`pwd`
524488de56ccSmrg	  cd $my_xdir || exit $?
524588de56ccSmrg	  darwin_archive=$my_xabs
524688de56ccSmrg	  darwin_curdir=`pwd`
5247862bcd1aSmrg	  func_basename "$darwin_archive"
5248862bcd1aSmrg	  darwin_base_archive=$func_basename_result
524988de56ccSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
525088de56ccSmrg	  if test -n "$darwin_arches"; then
525188de56ccSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
525288de56ccSmrg	    darwin_arch=
525388de56ccSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
5254862bcd1aSmrg	    for darwin_arch in  $darwin_arches; do
5255862bcd1aSmrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
5256862bcd1aSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
5257862bcd1aSmrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
5258862bcd1aSmrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
525988de56ccSmrg	      cd "$darwin_curdir"
5260862bcd1aSmrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
526188de56ccSmrg	    done # $darwin_arches
526288de56ccSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
5263862bcd1aSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
526488de56ccSmrg	    darwin_file=
526588de56ccSmrg	    darwin_files=
526688de56ccSmrg	    for darwin_file in $darwin_filelist; do
5267e9fcaa8aSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
526888de56ccSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
526988de56ccSmrg	    done # $darwin_filelist
527088de56ccSmrg	    $RM -rf unfat-$$
527188de56ccSmrg	    cd "$darwin_orig_dir"
5272b4ee4795Smrg	  else
527388de56ccSmrg	    cd $darwin_orig_dir
527488de56ccSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
527588de56ccSmrg	  fi # $darwin_arches
527688de56ccSmrg	} # !$opt_dry_run
527788de56ccSmrg	;;
527888de56ccSmrg      *)
527988de56ccSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
528088de56ccSmrg	;;
528188de56ccSmrg      esac
5282e9fcaa8aSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
528388de56ccSmrg    done
52841ab64890Smrg
5285862bcd1aSmrg    func_extract_archives_result=$my_oldobjs
528688de56ccSmrg}
52871ab64890Smrg
52881ab64890Smrg
5289e9fcaa8aSmrg# func_emit_wrapper [arg=no]
5290e9fcaa8aSmrg#
5291e9fcaa8aSmrg# Emit a libtool wrapper script on stdout.
5292e9fcaa8aSmrg# Don't directly open a file because we may want to
5293e9fcaa8aSmrg# incorporate the script contents within a cygwin/mingw
5294e9fcaa8aSmrg# wrapper executable.  Must ONLY be called from within
5295e9fcaa8aSmrg# func_mode_link because it depends on a number of variables
5296e9fcaa8aSmrg# set therein.
529788de56ccSmrg#
5298e9fcaa8aSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5299e9fcaa8aSmrg# variable will take.  If 'yes', then the emitted script
5300862bcd1aSmrg# will assume that the directory where it is stored is
5301e9fcaa8aSmrg# the $objdir directory.  This is a cygwin/mingw-specific
5302e9fcaa8aSmrg# behavior.
5303e9fcaa8aSmrgfunc_emit_wrapper ()
530488de56ccSmrg{
5305e9fcaa8aSmrg	func_emit_wrapper_arg1=${1-no}
5306b4ee4795Smrg
530788de56ccSmrg	$ECHO "\
530888de56ccSmrg#! $SHELL
53091ab64890Smrg
531088de56ccSmrg# $output - temporary wrapper script for $objdir/$outputname
5311862bcd1aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
531288de56ccSmrg#
531388de56ccSmrg# The $output program cannot be directly executed until all the libtool
531488de56ccSmrg# libraries that it depends on are installed.
531588de56ccSmrg#
531688de56ccSmrg# This wrapper script should never be moved out of the build directory.
531788de56ccSmrg# If it is, it will not operate correctly.
53181ab64890Smrg
531988de56ccSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
532088de56ccSmrg# metacharacters that are still active within double-quoted strings.
532188de56ccSmrgsed_quote_subst='$sed_quote_subst'
53221ab64890Smrg
532388de56ccSmrg# Be Bourne compatible
532488de56ccSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
532588de56ccSmrg  emulate sh
532688de56ccSmrg  NULLCMD=:
532788de56ccSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
532888de56ccSmrg  # is contrary to our usage.  Disable this feature.
532988de56ccSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
533088de56ccSmrg  setopt NO_GLOB_SUBST
533188de56ccSmrgelse
533288de56ccSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
533388de56ccSmrgfi
533488de56ccSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
533588de56ccSmrgDUALCASE=1; export DUALCASE # for MKS sh
53361ab64890Smrg
533788de56ccSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
533888de56ccSmrg# if CDPATH is set.
533988de56ccSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
53401ab64890Smrg
534188de56ccSmrgrelink_command=\"$relink_command\"
53421ab64890Smrg
534388de56ccSmrg# This environment variable determines our operation mode.
534488de56ccSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
534588de56ccSmrg  # install mode needs the following variables:
534688de56ccSmrg  generated_by_libtool_version='$macro_version'
534788de56ccSmrg  notinst_deplibs='$notinst_deplibs'
534888de56ccSmrgelse
534988de56ccSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
535088de56ccSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5351e9fcaa8aSmrg    file=\"\$0\""
5352e9fcaa8aSmrg
53535afda2e6Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
5354e9fcaa8aSmrg    $ECHO "\
5355e9fcaa8aSmrg
5356e9fcaa8aSmrg# A function that is used when there is no print builtin or printf.
5357e9fcaa8aSmrgfunc_fallback_echo ()
5358e9fcaa8aSmrg{
5359e9fcaa8aSmrg  eval 'cat <<_LTECHO_EOF
5360e9fcaa8aSmrg\$1
5361e9fcaa8aSmrg_LTECHO_EOF'
5362e9fcaa8aSmrg}
5363e9fcaa8aSmrg    ECHO=\"$qECHO\"
5364e9fcaa8aSmrg  fi
5365e9fcaa8aSmrg
5366e9fcaa8aSmrg# Very basic option parsing. These options are (a) specific to
5367e9fcaa8aSmrg# the libtool wrapper, (b) are identical between the wrapper
5368862bcd1aSmrg# /script/ and the wrapper /executable/ that is used only on
5369e9fcaa8aSmrg# windows platforms, and (c) all begin with the string "--lt-"
5370862bcd1aSmrg# (application programs are unlikely to have options that match
5371e9fcaa8aSmrg# this pattern).
5372e9fcaa8aSmrg#
5373e9fcaa8aSmrg# There are only two supported options: --lt-debug and
5374e9fcaa8aSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
5375e9fcaa8aSmrg#
5376e9fcaa8aSmrg# The first argument to this parsing function should be the
5377e9fcaa8aSmrg# script's $0 value, followed by "$@".
5378e9fcaa8aSmrglt_option_debug=
5379e9fcaa8aSmrgfunc_parse_lt_options ()
5380e9fcaa8aSmrg{
5381e9fcaa8aSmrg  lt_script_arg0=\$0
5382e9fcaa8aSmrg  shift
5383e9fcaa8aSmrg  for lt_opt
5384e9fcaa8aSmrg  do
5385e9fcaa8aSmrg    case \"\$lt_opt\" in
5386e9fcaa8aSmrg    --lt-debug) lt_option_debug=1 ;;
5387e9fcaa8aSmrg    --lt-dump-script)
5388e9fcaa8aSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5389e9fcaa8aSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5390e9fcaa8aSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5391e9fcaa8aSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
5392e9fcaa8aSmrg        exit 0
5393e9fcaa8aSmrg      ;;
5394e9fcaa8aSmrg    --lt-*)
5395e9fcaa8aSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5396e9fcaa8aSmrg        exit 1
5397e9fcaa8aSmrg      ;;
5398e9fcaa8aSmrg    esac
5399e9fcaa8aSmrg  done
5400e9fcaa8aSmrg
5401e9fcaa8aSmrg  # Print the debug banner immediately:
5402e9fcaa8aSmrg  if test -n \"\$lt_option_debug\"; then
5403862bcd1aSmrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5404e9fcaa8aSmrg  fi
5405e9fcaa8aSmrg}
5406e9fcaa8aSmrg
5407e9fcaa8aSmrg# Used when --lt-debug. Prints its arguments to stdout
5408e9fcaa8aSmrg# (redirection is the responsibility of the caller)
5409e9fcaa8aSmrgfunc_lt_dump_args ()
5410e9fcaa8aSmrg{
5411e9fcaa8aSmrg  lt_dump_args_N=1;
5412e9fcaa8aSmrg  for lt_arg
5413e9fcaa8aSmrg  do
5414862bcd1aSmrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5415e9fcaa8aSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5416e9fcaa8aSmrg  done
5417e9fcaa8aSmrg}
5418e9fcaa8aSmrg
5419e9fcaa8aSmrg# Core function for launching the target application
5420e9fcaa8aSmrgfunc_exec_program_core ()
5421e9fcaa8aSmrg{
542288de56ccSmrg"
5423e9fcaa8aSmrg  case $host in
5424e9fcaa8aSmrg  # Backslashes separate directories on plain windows
5425e9fcaa8aSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
5426e9fcaa8aSmrg    $ECHO "\
5427e9fcaa8aSmrg      if test -n \"\$lt_option_debug\"; then
5428862bcd1aSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5429e9fcaa8aSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5430e9fcaa8aSmrg      fi
5431e9fcaa8aSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5432e9fcaa8aSmrg"
5433e9fcaa8aSmrg    ;;
5434e9fcaa8aSmrg
5435e9fcaa8aSmrg  *)
5436e9fcaa8aSmrg    $ECHO "\
5437e9fcaa8aSmrg      if test -n \"\$lt_option_debug\"; then
5438862bcd1aSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5439e9fcaa8aSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5440e9fcaa8aSmrg      fi
5441e9fcaa8aSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5442e9fcaa8aSmrg"
5443e9fcaa8aSmrg    ;;
5444e9fcaa8aSmrg  esac
5445e9fcaa8aSmrg  $ECHO "\
5446e9fcaa8aSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5447e9fcaa8aSmrg      exit 1
5448e9fcaa8aSmrg}
5449e9fcaa8aSmrg
5450e9fcaa8aSmrg# A function to encapsulate launching the target application
5451e9fcaa8aSmrg# Strips options in the --lt-* namespace from \$@ and
5452e9fcaa8aSmrg# launches target application with the remaining arguments.
5453e9fcaa8aSmrgfunc_exec_program ()
5454e9fcaa8aSmrg{
5455eb411b4bSmrg  case \" \$* \" in
5456eb411b4bSmrg  *\\ --lt-*)
5457eb411b4bSmrg    for lt_wr_arg
5458eb411b4bSmrg    do
5459eb411b4bSmrg      case \$lt_wr_arg in
5460eb411b4bSmrg      --lt-*) ;;
5461eb411b4bSmrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5462eb411b4bSmrg      esac
5463eb411b4bSmrg      shift
5464eb411b4bSmrg    done ;;
5465eb411b4bSmrg  esac
5466e9fcaa8aSmrg  func_exec_program_core \${1+\"\$@\"}
5467e9fcaa8aSmrg}
5468e9fcaa8aSmrg
5469e9fcaa8aSmrg  # Parse options
5470e9fcaa8aSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
54711ab64890Smrg
547288de56ccSmrg  # Find the directory that this script lives in.
5473e9fcaa8aSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
547488de56ccSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
54751ab64890Smrg
547688de56ccSmrg  # Follow symbolic links until we get to the real thisdir.
5477e9fcaa8aSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
547888de56ccSmrg  while test -n \"\$file\"; do
5479e9fcaa8aSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
54801ab64890Smrg
548188de56ccSmrg    # If there was a directory component, then change thisdir.
548288de56ccSmrg    if test \"x\$destdir\" != \"x\$file\"; then
548388de56ccSmrg      case \"\$destdir\" in
548488de56ccSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
548588de56ccSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5486b4ee4795Smrg      esac
548788de56ccSmrg    fi
54881ab64890Smrg
5489e9fcaa8aSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5490e9fcaa8aSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
549188de56ccSmrg  done
54921ab64890Smrg
549388de56ccSmrg  # Usually 'no', except on cygwin/mingw when embedded into
549488de56ccSmrg  # the cwrapper.
5495e9fcaa8aSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
549688de56ccSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
549788de56ccSmrg    # special case for '.'
549888de56ccSmrg    if test \"\$thisdir\" = \".\"; then
549988de56ccSmrg      thisdir=\`pwd\`
550088de56ccSmrg    fi
550188de56ccSmrg    # remove .libs from thisdir
550288de56ccSmrg    case \"\$thisdir\" in
5503e9fcaa8aSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
550488de56ccSmrg    $objdir )   thisdir=. ;;
550588de56ccSmrg    esac
550688de56ccSmrg  fi
550788de56ccSmrg
550888de56ccSmrg  # Try to get the absolute directory name.
550988de56ccSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
551088de56ccSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
551188de56ccSmrg"
551288de56ccSmrg
5513862bcd1aSmrg	if test yes = "$fast_install"; then
551488de56ccSmrg	  $ECHO "\
551588de56ccSmrg  program=lt-'$outputname'$exeext
551688de56ccSmrg  progdir=\"\$thisdir/$objdir\"
551788de56ccSmrg
551888de56ccSmrg  if test ! -f \"\$progdir/\$program\" ||
5519862bcd1aSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
552088de56ccSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
552188de56ccSmrg
552288de56ccSmrg    file=\"\$\$-\$program\"
552388de56ccSmrg
552488de56ccSmrg    if test ! -d \"\$progdir\"; then
552588de56ccSmrg      $MKDIR \"\$progdir\"
552688de56ccSmrg    else
552788de56ccSmrg      $RM \"\$progdir/\$file\"
552888de56ccSmrg    fi"
552988de56ccSmrg
553088de56ccSmrg	  $ECHO "\
553188de56ccSmrg
553288de56ccSmrg    # relink executable if necessary
553388de56ccSmrg    if test -n \"\$relink_command\"; then
553488de56ccSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
553588de56ccSmrg      else
5536862bcd1aSmrg	\$ECHO \"\$relink_command_output\" >&2
553788de56ccSmrg	$RM \"\$progdir/\$file\"
553888de56ccSmrg	exit 1
5539b4ee4795Smrg      fi
554088de56ccSmrg    fi
55411ab64890Smrg
554288de56ccSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
554388de56ccSmrg    { $RM \"\$progdir/\$program\";
554488de56ccSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
554588de56ccSmrg    $RM \"\$progdir/\$file\"
554688de56ccSmrg  fi"
554788de56ccSmrg	else
554888de56ccSmrg	  $ECHO "\
554988de56ccSmrg  program='$outputname'
555088de56ccSmrg  progdir=\"\$thisdir/$objdir\"
555188de56ccSmrg"
5552b4ee4795Smrg	fi
55531ab64890Smrg
555488de56ccSmrg	$ECHO "\
55551ab64890Smrg
555688de56ccSmrg  if test -f \"\$progdir/\$program\"; then"
55571ab64890Smrg
5558e9fcaa8aSmrg	# fixup the dll searchpath if we need to.
5559e9fcaa8aSmrg	#
5560e9fcaa8aSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
5561e9fcaa8aSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
5562e9fcaa8aSmrg	# libraries must come first.
5563e9fcaa8aSmrg	if test -n "$dllsearchpath"; then
5564e9fcaa8aSmrg	  $ECHO "\
5565e9fcaa8aSmrg    # Add the dll search path components to the executable PATH
5566e9fcaa8aSmrg    PATH=$dllsearchpath:\$PATH
5567e9fcaa8aSmrg"
5568e9fcaa8aSmrg	fi
5569e9fcaa8aSmrg
557088de56ccSmrg	# Export our shlibpath_var if we have one.
5571862bcd1aSmrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
557288de56ccSmrg	  $ECHO "\
557388de56ccSmrg    # Add our own library path to $shlibpath_var
557488de56ccSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
557588de56ccSmrg
557688de56ccSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
557788de56ccSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
5578e9fcaa8aSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
55791ab64890Smrg
558088de56ccSmrg    export $shlibpath_var
558188de56ccSmrg"
5582b4ee4795Smrg	fi
55831ab64890Smrg
558488de56ccSmrg	$ECHO "\
558588de56ccSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
558688de56ccSmrg      # Run the actual program with our arguments.
5587e9fcaa8aSmrg      func_exec_program \${1+\"\$@\"}
558888de56ccSmrg    fi
558988de56ccSmrg  else
559088de56ccSmrg    # The program doesn't exist.
5591862bcd1aSmrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
559288de56ccSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5593e9fcaa8aSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
559488de56ccSmrg    exit 1
559588de56ccSmrg  fi
559688de56ccSmrgfi\
559788de56ccSmrg"
559888de56ccSmrg}
55991ab64890Smrg
56001ab64890Smrg
560188de56ccSmrg# func_emit_cwrapperexe_src
560288de56ccSmrg# emit the source code for a wrapper executable on stdout
560388de56ccSmrg# Must ONLY be called from within func_mode_link because
560488de56ccSmrg# it depends on a number of variable set therein.
560588de56ccSmrgfunc_emit_cwrapperexe_src ()
560688de56ccSmrg{
560788de56ccSmrg	cat <<EOF
56081ab64890Smrg
560988de56ccSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5610862bcd1aSmrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
56111ab64890Smrg
561288de56ccSmrg   The $output program cannot be directly executed until all the libtool
561388de56ccSmrg   libraries that it depends on are installed.
56141ab64890Smrg
561588de56ccSmrg   This wrapper executable should never be moved out of the build directory.
561688de56ccSmrg   If it is, it will not operate correctly.
561788de56ccSmrg*/
561888de56ccSmrgEOF
561988de56ccSmrg	    cat <<"EOF"
5620e9fcaa8aSmrg#ifdef _MSC_VER
5621e9fcaa8aSmrg# define _CRT_SECURE_NO_DEPRECATE 1
5622e9fcaa8aSmrg#endif
562388de56ccSmrg#include <stdio.h>
562488de56ccSmrg#include <stdlib.h>
562588de56ccSmrg#ifdef _MSC_VER
562688de56ccSmrg# include <direct.h>
562788de56ccSmrg# include <process.h>
562888de56ccSmrg# include <io.h>
562988de56ccSmrg#else
563088de56ccSmrg# include <unistd.h>
563188de56ccSmrg# include <stdint.h>
563288de56ccSmrg# ifdef __CYGWIN__
563388de56ccSmrg#  include <io.h>
5634e9fcaa8aSmrg# endif
5635e9fcaa8aSmrg#endif
5636e9fcaa8aSmrg#include <malloc.h>
5637e9fcaa8aSmrg#include <stdarg.h>
5638e9fcaa8aSmrg#include <assert.h>
5639e9fcaa8aSmrg#include <string.h>
5640e9fcaa8aSmrg#include <ctype.h>
5641e9fcaa8aSmrg#include <errno.h>
5642e9fcaa8aSmrg#include <fcntl.h>
5643e9fcaa8aSmrg#include <sys/stat.h>
5644e9fcaa8aSmrg
5645862bcd1aSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5646862bcd1aSmrg
5647e9fcaa8aSmrg/* declarations of non-ANSI functions */
5648862bcd1aSmrg#if defined __MINGW32__
5649e9fcaa8aSmrg# ifdef __STRICT_ANSI__
5650e9fcaa8aSmrgint _putenv (const char *);
5651e9fcaa8aSmrg# endif
5652862bcd1aSmrg#elif defined __CYGWIN__
5653e9fcaa8aSmrg# ifdef __STRICT_ANSI__
565488de56ccSmrgchar *realpath (const char *, char *);
565588de56ccSmrgint putenv (char *);
565688de56ccSmrgint setenv (const char *, const char *, int);
565788de56ccSmrg# endif
5658862bcd1aSmrg/* #elif defined other_platform || defined ... */
5659e9fcaa8aSmrg#endif
5660e9fcaa8aSmrg
5661e9fcaa8aSmrg/* portability defines, excluding path handling macros */
5662862bcd1aSmrg#if defined _MSC_VER
5663e9fcaa8aSmrg# define setmode _setmode
5664e9fcaa8aSmrg# define stat    _stat
5665e9fcaa8aSmrg# define chmod   _chmod
5666e9fcaa8aSmrg# define getcwd  _getcwd
5667e9fcaa8aSmrg# define putenv  _putenv
5668e9fcaa8aSmrg# define S_IXUSR _S_IEXEC
5669862bcd1aSmrg#elif defined __MINGW32__
5670e9fcaa8aSmrg# define setmode _setmode
5671e9fcaa8aSmrg# define stat    _stat
5672e9fcaa8aSmrg# define chmod   _chmod
5673e9fcaa8aSmrg# define getcwd  _getcwd
5674e9fcaa8aSmrg# define putenv  _putenv
5675862bcd1aSmrg#elif defined __CYGWIN__
5676e9fcaa8aSmrg# define HAVE_SETENV
5677e9fcaa8aSmrg# define FOPEN_WB "wb"
5678862bcd1aSmrg/* #elif defined other platforms ... */
567988de56ccSmrg#endif
56801ab64890Smrg
5681862bcd1aSmrg#if defined PATH_MAX
568288de56ccSmrg# define LT_PATHMAX PATH_MAX
5683862bcd1aSmrg#elif defined MAXPATHLEN
568488de56ccSmrg# define LT_PATHMAX MAXPATHLEN
568588de56ccSmrg#else
568688de56ccSmrg# define LT_PATHMAX 1024
568788de56ccSmrg#endif
56881ab64890Smrg
568988de56ccSmrg#ifndef S_IXOTH
569088de56ccSmrg# define S_IXOTH 0
569188de56ccSmrg#endif
569288de56ccSmrg#ifndef S_IXGRP
569388de56ccSmrg# define S_IXGRP 0
569488de56ccSmrg#endif
56951ab64890Smrg
5696e9fcaa8aSmrg/* path handling portability macros */
569788de56ccSmrg#ifndef DIR_SEPARATOR
569888de56ccSmrg# define DIR_SEPARATOR '/'
569988de56ccSmrg# define PATH_SEPARATOR ':'
570088de56ccSmrg#endif
57011ab64890Smrg
5702862bcd1aSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
5703862bcd1aSmrg  defined __OS2__
570488de56ccSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
570588de56ccSmrg# define FOPEN_WB "wb"
570688de56ccSmrg# ifndef DIR_SEPARATOR_2
570788de56ccSmrg#  define DIR_SEPARATOR_2 '\\'
570888de56ccSmrg# endif
570988de56ccSmrg# ifndef PATH_SEPARATOR_2
571088de56ccSmrg#  define PATH_SEPARATOR_2 ';'
571188de56ccSmrg# endif
571288de56ccSmrg#endif
57131ab64890Smrg
571488de56ccSmrg#ifndef DIR_SEPARATOR_2
571588de56ccSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
571688de56ccSmrg#else /* DIR_SEPARATOR_2 */
571788de56ccSmrg# define IS_DIR_SEPARATOR(ch) \
571888de56ccSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
571988de56ccSmrg#endif /* DIR_SEPARATOR_2 */
57201ab64890Smrg
572188de56ccSmrg#ifndef PATH_SEPARATOR_2
572288de56ccSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
572388de56ccSmrg#else /* PATH_SEPARATOR_2 */
572488de56ccSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
572588de56ccSmrg#endif /* PATH_SEPARATOR_2 */
57261ab64890Smrg
572788de56ccSmrg#ifndef FOPEN_WB
572888de56ccSmrg# define FOPEN_WB "w"
572988de56ccSmrg#endif
573088de56ccSmrg#ifndef _O_BINARY
573188de56ccSmrg# define _O_BINARY 0
573288de56ccSmrg#endif
57331ab64890Smrg
573488de56ccSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
573588de56ccSmrg#define XFREE(stale) do { \
5736862bcd1aSmrg  if (stale) { free (stale); stale = 0; } \
573788de56ccSmrg} while (0)
57381ab64890Smrg
5739862bcd1aSmrg#if defined LT_DEBUGWRAPPER
5740e9fcaa8aSmrgstatic int lt_debug = 1;
574188de56ccSmrg#else
5742e9fcaa8aSmrgstatic int lt_debug = 0;
574388de56ccSmrg#endif
57441ab64890Smrg
5745e9fcaa8aSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
57461ab64890Smrg
574788de56ccSmrgvoid *xmalloc (size_t num);
574888de56ccSmrgchar *xstrdup (const char *string);
574988de56ccSmrgconst char *base_name (const char *name);
575088de56ccSmrgchar *find_executable (const char *wrapper);
575188de56ccSmrgchar *chase_symlinks (const char *pathspec);
575288de56ccSmrgint make_executable (const char *path);
575388de56ccSmrgint check_executable (const char *path);
575488de56ccSmrgchar *strendzap (char *str, const char *pat);
5755e9fcaa8aSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
5756e9fcaa8aSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
5757e9fcaa8aSmrgstatic const char *nonnull (const char *s);
5758e9fcaa8aSmrgstatic const char *nonempty (const char *s);
575988de56ccSmrgvoid lt_setenv (const char *name, const char *value);
576088de56ccSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
576188de56ccSmrgvoid lt_update_exe_path (const char *name, const char *value);
576288de56ccSmrgvoid lt_update_lib_path (const char *name, const char *value);
5763e9fcaa8aSmrgchar **prepare_spawn (char **argv);
5764e9fcaa8aSmrgvoid lt_dump_script (FILE *f);
576588de56ccSmrgEOF
576688de56ccSmrg
576788de56ccSmrg	    cat <<EOF
5768862bcd1aSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
5769862bcd1aSmrg# define externally_visible volatile
5770862bcd1aSmrg#else
5771862bcd1aSmrg# define externally_visible __attribute__((externally_visible)) volatile
5772862bcd1aSmrg#endif
5773862bcd1aSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
577488de56ccSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
577588de56ccSmrgEOF
57761ab64890Smrg
5777862bcd1aSmrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5778e9fcaa8aSmrg              func_to_host_path "$temp_rpath"
577988de56ccSmrg	      cat <<EOF
5780e9fcaa8aSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
578188de56ccSmrgEOF
578288de56ccSmrg	    else
578388de56ccSmrg	      cat <<"EOF"
578488de56ccSmrgconst char * LIB_PATH_VALUE   = "";
578588de56ccSmrgEOF
5786b4ee4795Smrg	    fi
57871ab64890Smrg
578888de56ccSmrg	    if test -n "$dllsearchpath"; then
5789e9fcaa8aSmrg              func_to_host_path "$dllsearchpath:"
579088de56ccSmrg	      cat <<EOF
579188de56ccSmrgconst char * EXE_PATH_VARNAME = "PATH";
5792e9fcaa8aSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
5793b4ee4795SmrgEOF
5794b4ee4795Smrg	    else
579588de56ccSmrg	      cat <<"EOF"
579688de56ccSmrgconst char * EXE_PATH_VARNAME = "";
579788de56ccSmrgconst char * EXE_PATH_VALUE   = "";
579888de56ccSmrgEOF
5799b4ee4795Smrg	    fi
580088de56ccSmrg
5801862bcd1aSmrg	    if test yes = "$fast_install"; then
580288de56ccSmrg	      cat <<EOF
580388de56ccSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
580488de56ccSmrgEOF
5805b4ee4795Smrg	    else
580688de56ccSmrg	      cat <<EOF
580788de56ccSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
580888de56ccSmrgEOF
5809b4ee4795Smrg	    fi
58101ab64890Smrg
58111ab64890Smrg
581288de56ccSmrg	    cat <<"EOF"
58131ab64890Smrg
581488de56ccSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
58151ab64890Smrg
581688de56ccSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
581788de56ccSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
5818e9fcaa8aSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
58191ab64890Smrg
582088de56ccSmrgint
582188de56ccSmrgmain (int argc, char *argv[])
582288de56ccSmrg{
582388de56ccSmrg  char **newargz;
582488de56ccSmrg  int  newargc;
582588de56ccSmrg  char *tmp_pathspec;
582688de56ccSmrg  char *actual_cwrapper_path;
582788de56ccSmrg  char *actual_cwrapper_name;
582888de56ccSmrg  char *target_name;
582988de56ccSmrg  char *lt_argv_zero;
5830862bcd1aSmrg  int rval = 127;
58311ab64890Smrg
583288de56ccSmrg  int i;
58331ab64890Smrg
583488de56ccSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
5835862bcd1aSmrg  newargz = XMALLOC (char *, (size_t) argc + 1);
58361ab64890Smrg
5837e9fcaa8aSmrg  /* very simple arg parsing; don't want to rely on getopt
5838e9fcaa8aSmrg   * also, copy all non cwrapper options to newargz, except
5839e9fcaa8aSmrg   * argz[0], which is handled differently
5840e9fcaa8aSmrg   */
5841e9fcaa8aSmrg  newargc=0;
584288de56ccSmrg  for (i = 1; i < argc; i++)
584388de56ccSmrg    {
5844862bcd1aSmrg      if (STREQ (argv[i], dumpscript_opt))
584588de56ccSmrg	{
584688de56ccSmrgEOF
5847862bcd1aSmrg	    case $host in
584888de56ccSmrg	      *mingw* | *cygwin* )
584988de56ccSmrg		# make stdout use "unix" line endings
585088de56ccSmrg		echo "          setmode(1,_O_BINARY);"
585188de56ccSmrg		;;
585288de56ccSmrg	      esac
58531ab64890Smrg
585488de56ccSmrg	    cat <<"EOF"
5855e9fcaa8aSmrg	  lt_dump_script (stdout);
585688de56ccSmrg	  return 0;
585788de56ccSmrg	}
5858862bcd1aSmrg      if (STREQ (argv[i], debug_opt))
5859e9fcaa8aSmrg	{
5860e9fcaa8aSmrg          lt_debug = 1;
5861e9fcaa8aSmrg          continue;
5862e9fcaa8aSmrg	}
5863862bcd1aSmrg      if (STREQ (argv[i], ltwrapper_option_prefix))
5864e9fcaa8aSmrg        {
5865e9fcaa8aSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5866e9fcaa8aSmrg             namespace, but it is not one of the ones we know about and
5867e9fcaa8aSmrg             have already dealt with, above (inluding dump-script), then
5868e9fcaa8aSmrg             report an error. Otherwise, targets might begin to believe
5869e9fcaa8aSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5870e9fcaa8aSmrg             namespace. The first time any user complains about this, we'll
5871e9fcaa8aSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5872e9fcaa8aSmrg             or a configure.ac-settable value.
5873e9fcaa8aSmrg           */
5874e9fcaa8aSmrg          lt_fatal (__FILE__, __LINE__,
5875e9fcaa8aSmrg		    "unrecognized %s option: '%s'",
5876e9fcaa8aSmrg                    ltwrapper_option_prefix, argv[i]);
5877e9fcaa8aSmrg        }
5878e9fcaa8aSmrg      /* otherwise ... */
5879e9fcaa8aSmrg      newargz[++newargc] = xstrdup (argv[i]);
588088de56ccSmrg    }
5881e9fcaa8aSmrg  newargz[++newargc] = NULL;
5882e9fcaa8aSmrg
5883e9fcaa8aSmrgEOF
5884e9fcaa8aSmrg	    cat <<EOF
5885e9fcaa8aSmrg  /* The GNU banner must be the first non-error debug message */
5886862bcd1aSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5887e9fcaa8aSmrgEOF
5888e9fcaa8aSmrg	    cat <<"EOF"
5889e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5890e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
58911ab64890Smrg
589288de56ccSmrg  tmp_pathspec = find_executable (argv[0]);
589388de56ccSmrg  if (tmp_pathspec == NULL)
5894e9fcaa8aSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5895e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
5896e9fcaa8aSmrg                  "(main) found exe (before symlink chase) at: %s\n",
5897e9fcaa8aSmrg		  tmp_pathspec);
589888de56ccSmrg
589988de56ccSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5900e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
5901e9fcaa8aSmrg                  "(main) found exe (after symlink chase) at: %s\n",
5902e9fcaa8aSmrg		  actual_cwrapper_path);
590388de56ccSmrg  XFREE (tmp_pathspec);
590488de56ccSmrg
5905e9fcaa8aSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
590688de56ccSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
590788de56ccSmrg
590888de56ccSmrg  /* wrapper name transforms */
590988de56ccSmrg  strendzap (actual_cwrapper_name, ".exe");
591088de56ccSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
591188de56ccSmrg  XFREE (actual_cwrapper_name);
591288de56ccSmrg  actual_cwrapper_name = tmp_pathspec;
591388de56ccSmrg  tmp_pathspec = 0;
591488de56ccSmrg
591588de56ccSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
591688de56ccSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
591788de56ccSmrg  strendzap (target_name, ".exe");
591888de56ccSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
591988de56ccSmrg  XFREE (target_name);
592088de56ccSmrg  target_name = tmp_pathspec;
592188de56ccSmrg  tmp_pathspec = 0;
592288de56ccSmrg
5923e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
5924e9fcaa8aSmrg		  "(main) libtool target name: %s\n",
5925e9fcaa8aSmrg		  target_name);
592688de56ccSmrgEOF
59271ab64890Smrg
592888de56ccSmrg	    cat <<EOF
592988de56ccSmrg  newargz[0] =
593088de56ccSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
593188de56ccSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
593288de56ccSmrg  strcpy (newargz[0], actual_cwrapper_path);
593388de56ccSmrg  strcat (newargz[0], "$objdir");
593488de56ccSmrg  strcat (newargz[0], "/");
593588de56ccSmrgEOF
59361ab64890Smrg
593788de56ccSmrg	    cat <<"EOF"
593888de56ccSmrg  /* stop here, and copy so we don't have to do this twice */
593988de56ccSmrg  tmp_pathspec = xstrdup (newargz[0]);
59401ab64890Smrg
594188de56ccSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
594288de56ccSmrg  strcat (newargz[0], actual_cwrapper_name);
59431ab64890Smrg
594488de56ccSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
594588de56ccSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
594688de56ccSmrg  XFREE (tmp_pathspec);
594788de56ccSmrg  tmp_pathspec = NULL;
594888de56ccSmrgEOF
59491ab64890Smrg
595088de56ccSmrg	    case $host_os in
595188de56ccSmrg	      mingw*)
595288de56ccSmrg	    cat <<"EOF"
595388de56ccSmrg  {
595488de56ccSmrg    char* p;
595588de56ccSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
595688de56ccSmrg      {
595788de56ccSmrg	*p = '/';
595888de56ccSmrg      }
595988de56ccSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
596088de56ccSmrg      {
596188de56ccSmrg	*p = '/';
596288de56ccSmrg      }
596388de56ccSmrg  }
596488de56ccSmrgEOF
596588de56ccSmrg	    ;;
596688de56ccSmrg	    esac
59671ab64890Smrg
596888de56ccSmrg	    cat <<"EOF"
596988de56ccSmrg  XFREE (target_name);
597088de56ccSmrg  XFREE (actual_cwrapper_path);
597188de56ccSmrg  XFREE (actual_cwrapper_name);
59721ab64890Smrg
597388de56ccSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
597488de56ccSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
5975e9fcaa8aSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
5976e9fcaa8aSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5977e9fcaa8aSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
5978e9fcaa8aSmrg     libraries must come first. */
597988de56ccSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5980e9fcaa8aSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
59811ab64890Smrg
5982e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5983e9fcaa8aSmrg		  nonnull (lt_argv_zero));
598488de56ccSmrg  for (i = 0; i < newargc; i++)
598588de56ccSmrg    {
5986e9fcaa8aSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5987e9fcaa8aSmrg		      i, nonnull (newargz[i]));
598888de56ccSmrg    }
59891ab64890Smrg
599088de56ccSmrgEOF
59911ab64890Smrg
599288de56ccSmrg	    case $host_os in
599388de56ccSmrg	      mingw*)
599488de56ccSmrg		cat <<"EOF"
599588de56ccSmrg  /* execv doesn't actually work on mingw as expected on unix */
5996e9fcaa8aSmrg  newargz = prepare_spawn (newargz);
5997862bcd1aSmrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
599888de56ccSmrg  if (rval == -1)
599988de56ccSmrg    {
600088de56ccSmrg      /* failed to start process */
6001e9fcaa8aSmrg      lt_debugprintf (__FILE__, __LINE__,
6002e9fcaa8aSmrg		      "(main) failed to launch target \"%s\": %s\n",
6003e9fcaa8aSmrg		      lt_argv_zero, nonnull (strerror (errno)));
600488de56ccSmrg      return 127;
600588de56ccSmrg    }
600688de56ccSmrg  return rval;
600788de56ccSmrgEOF
600888de56ccSmrg		;;
600988de56ccSmrg	      *)
601088de56ccSmrg		cat <<"EOF"
601188de56ccSmrg  execv (lt_argv_zero, newargz);
601288de56ccSmrg  return rval; /* =127, but avoids unused variable warning */
601388de56ccSmrgEOF
601488de56ccSmrg		;;
601588de56ccSmrg	    esac
60161ab64890Smrg
601788de56ccSmrg	    cat <<"EOF"
601888de56ccSmrg}
60191ab64890Smrg
602088de56ccSmrgvoid *
602188de56ccSmrgxmalloc (size_t num)
602288de56ccSmrg{
602388de56ccSmrg  void *p = (void *) malloc (num);
602488de56ccSmrg  if (!p)
6025e9fcaa8aSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
60261ab64890Smrg
602788de56ccSmrg  return p;
602888de56ccSmrg}
60291ab64890Smrg
603088de56ccSmrgchar *
603188de56ccSmrgxstrdup (const char *string)
603288de56ccSmrg{
603388de56ccSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
603488de56ccSmrg			  string) : NULL;
603588de56ccSmrg}
60361ab64890Smrg
603788de56ccSmrgconst char *
603888de56ccSmrgbase_name (const char *name)
603988de56ccSmrg{
604088de56ccSmrg  const char *base;
6041b4ee4795Smrg
6042862bcd1aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
604388de56ccSmrg  /* Skip over the disk name in MSDOS pathnames. */
604488de56ccSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
604588de56ccSmrg    name += 2;
604688de56ccSmrg#endif
6047b4ee4795Smrg
604888de56ccSmrg  for (base = name; *name; name++)
604988de56ccSmrg    if (IS_DIR_SEPARATOR (*name))
605088de56ccSmrg      base = name + 1;
605188de56ccSmrg  return base;
605288de56ccSmrg}
6053b4ee4795Smrg
605488de56ccSmrgint
605588de56ccSmrgcheck_executable (const char *path)
605688de56ccSmrg{
605788de56ccSmrg  struct stat st;
6058b4ee4795Smrg
6059e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
6060e9fcaa8aSmrg                  nonempty (path));
606188de56ccSmrg  if ((!path) || (!*path))
606288de56ccSmrg    return 0;
6063b4ee4795Smrg
606488de56ccSmrg  if ((stat (path, &st) >= 0)
606588de56ccSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
606688de56ccSmrg    return 1;
606788de56ccSmrg  else
606888de56ccSmrg    return 0;
606988de56ccSmrg}
60701ab64890Smrg
607188de56ccSmrgint
607288de56ccSmrgmake_executable (const char *path)
607388de56ccSmrg{
607488de56ccSmrg  int rval = 0;
607588de56ccSmrg  struct stat st;
60761ab64890Smrg
6077e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
6078e9fcaa8aSmrg                  nonempty (path));
607988de56ccSmrg  if ((!path) || (!*path))
608088de56ccSmrg    return 0;
60811ab64890Smrg
608288de56ccSmrg  if (stat (path, &st) >= 0)
608388de56ccSmrg    {
608488de56ccSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
608588de56ccSmrg    }
608688de56ccSmrg  return rval;
608788de56ccSmrg}
6088b4ee4795Smrg
608988de56ccSmrg/* Searches for the full path of the wrapper.  Returns
609088de56ccSmrg   newly allocated full path name if found, NULL otherwise
609188de56ccSmrg   Does not chase symlinks, even on platforms that support them.
609288de56ccSmrg*/
609388de56ccSmrgchar *
609488de56ccSmrgfind_executable (const char *wrapper)
609588de56ccSmrg{
609688de56ccSmrg  int has_slash = 0;
609788de56ccSmrg  const char *p;
609888de56ccSmrg  const char *p_next;
609988de56ccSmrg  /* static buffer for getcwd */
610088de56ccSmrg  char tmp[LT_PATHMAX + 1];
6101862bcd1aSmrg  size_t tmp_len;
610288de56ccSmrg  char *concat_name;
6103b4ee4795Smrg
6104e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6105e9fcaa8aSmrg                  nonempty (wrapper));
6106b4ee4795Smrg
610788de56ccSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
610888de56ccSmrg    return NULL;
6109b4ee4795Smrg
611088de56ccSmrg  /* Absolute path? */
6111862bcd1aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
611288de56ccSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
611388de56ccSmrg    {
611488de56ccSmrg      concat_name = xstrdup (wrapper);
611588de56ccSmrg      if (check_executable (concat_name))
611688de56ccSmrg	return concat_name;
611788de56ccSmrg      XFREE (concat_name);
611888de56ccSmrg    }
611988de56ccSmrg  else
612088de56ccSmrg    {
612188de56ccSmrg#endif
612288de56ccSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
612388de56ccSmrg	{
612488de56ccSmrg	  concat_name = xstrdup (wrapper);
612588de56ccSmrg	  if (check_executable (concat_name))
612688de56ccSmrg	    return concat_name;
612788de56ccSmrg	  XFREE (concat_name);
612888de56ccSmrg	}
6129862bcd1aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
613088de56ccSmrg    }
613188de56ccSmrg#endif
61321ab64890Smrg
613388de56ccSmrg  for (p = wrapper; *p; p++)
613488de56ccSmrg    if (*p == '/')
613588de56ccSmrg      {
613688de56ccSmrg	has_slash = 1;
613788de56ccSmrg	break;
613888de56ccSmrg      }
613988de56ccSmrg  if (!has_slash)
614088de56ccSmrg    {
614188de56ccSmrg      /* no slashes; search PATH */
614288de56ccSmrg      const char *path = getenv ("PATH");
614388de56ccSmrg      if (path != NULL)
614488de56ccSmrg	{
614588de56ccSmrg	  for (p = path; *p; p = p_next)
614688de56ccSmrg	    {
614788de56ccSmrg	      const char *q;
614888de56ccSmrg	      size_t p_len;
614988de56ccSmrg	      for (q = p; *q; q++)
615088de56ccSmrg		if (IS_PATH_SEPARATOR (*q))
615188de56ccSmrg		  break;
6152862bcd1aSmrg	      p_len = (size_t) (q - p);
615388de56ccSmrg	      p_next = (*q == '\0' ? q : q + 1);
615488de56ccSmrg	      if (p_len == 0)
615588de56ccSmrg		{
615688de56ccSmrg		  /* empty path: current directory */
615788de56ccSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
6158e9fcaa8aSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6159e9fcaa8aSmrg                              nonnull (strerror (errno)));
616088de56ccSmrg		  tmp_len = strlen (tmp);
616188de56ccSmrg		  concat_name =
616288de56ccSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
616388de56ccSmrg		  memcpy (concat_name, tmp, tmp_len);
616488de56ccSmrg		  concat_name[tmp_len] = '/';
616588de56ccSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
616688de56ccSmrg		}
616788de56ccSmrg	      else
616888de56ccSmrg		{
616988de56ccSmrg		  concat_name =
617088de56ccSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
617188de56ccSmrg		  memcpy (concat_name, p, p_len);
617288de56ccSmrg		  concat_name[p_len] = '/';
617388de56ccSmrg		  strcpy (concat_name + p_len + 1, wrapper);
617488de56ccSmrg		}
617588de56ccSmrg	      if (check_executable (concat_name))
617688de56ccSmrg		return concat_name;
617788de56ccSmrg	      XFREE (concat_name);
617888de56ccSmrg	    }
617988de56ccSmrg	}
618088de56ccSmrg      /* not found in PATH; assume curdir */
618188de56ccSmrg    }
618288de56ccSmrg  /* Relative path | not found in path: prepend cwd */
618388de56ccSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
6184e9fcaa8aSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6185e9fcaa8aSmrg              nonnull (strerror (errno)));
618688de56ccSmrg  tmp_len = strlen (tmp);
618788de56ccSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
618888de56ccSmrg  memcpy (concat_name, tmp, tmp_len);
618988de56ccSmrg  concat_name[tmp_len] = '/';
619088de56ccSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
61911ab64890Smrg
619288de56ccSmrg  if (check_executable (concat_name))
619388de56ccSmrg    return concat_name;
619488de56ccSmrg  XFREE (concat_name);
619588de56ccSmrg  return NULL;
619688de56ccSmrg}
61971ab64890Smrg
619888de56ccSmrgchar *
619988de56ccSmrgchase_symlinks (const char *pathspec)
620088de56ccSmrg{
620188de56ccSmrg#ifndef S_ISLNK
620288de56ccSmrg  return xstrdup (pathspec);
620388de56ccSmrg#else
620488de56ccSmrg  char buf[LT_PATHMAX];
620588de56ccSmrg  struct stat s;
620688de56ccSmrg  char *tmp_pathspec = xstrdup (pathspec);
620788de56ccSmrg  char *p;
620888de56ccSmrg  int has_symlinks = 0;
620988de56ccSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
621088de56ccSmrg    {
6211e9fcaa8aSmrg      lt_debugprintf (__FILE__, __LINE__,
6212e9fcaa8aSmrg		      "checking path component for symlinks: %s\n",
6213e9fcaa8aSmrg		      tmp_pathspec);
621488de56ccSmrg      if (lstat (tmp_pathspec, &s) == 0)
621588de56ccSmrg	{
621688de56ccSmrg	  if (S_ISLNK (s.st_mode) != 0)
621788de56ccSmrg	    {
621888de56ccSmrg	      has_symlinks = 1;
621988de56ccSmrg	      break;
622088de56ccSmrg	    }
62211ab64890Smrg
622288de56ccSmrg	  /* search backwards for last DIR_SEPARATOR */
622388de56ccSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
622488de56ccSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
622588de56ccSmrg	    p--;
622688de56ccSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
622788de56ccSmrg	    {
622888de56ccSmrg	      /* no more DIR_SEPARATORS left */
622988de56ccSmrg	      break;
623088de56ccSmrg	    }
623188de56ccSmrg	  *p = '\0';
623288de56ccSmrg	}
623388de56ccSmrg      else
623488de56ccSmrg	{
6235e9fcaa8aSmrg	  lt_fatal (__FILE__, __LINE__,
6236e9fcaa8aSmrg		    "error accessing file \"%s\": %s",
6237e9fcaa8aSmrg		    tmp_pathspec, nonnull (strerror (errno)));
623888de56ccSmrg	}
623988de56ccSmrg    }
624088de56ccSmrg  XFREE (tmp_pathspec);
62411ab64890Smrg
624288de56ccSmrg  if (!has_symlinks)
624388de56ccSmrg    {
624488de56ccSmrg      return xstrdup (pathspec);
624588de56ccSmrg    }
62461ab64890Smrg
624788de56ccSmrg  tmp_pathspec = realpath (pathspec, buf);
624888de56ccSmrg  if (tmp_pathspec == 0)
624988de56ccSmrg    {
6250e9fcaa8aSmrg      lt_fatal (__FILE__, __LINE__,
6251e9fcaa8aSmrg		"could not follow symlinks for %s", pathspec);
625288de56ccSmrg    }
625388de56ccSmrg  return xstrdup (tmp_pathspec);
625488de56ccSmrg#endif
625588de56ccSmrg}
62561ab64890Smrg
625788de56ccSmrgchar *
625888de56ccSmrgstrendzap (char *str, const char *pat)
625988de56ccSmrg{
626088de56ccSmrg  size_t len, patlen;
62611ab64890Smrg
626288de56ccSmrg  assert (str != NULL);
626388de56ccSmrg  assert (pat != NULL);
62641ab64890Smrg
626588de56ccSmrg  len = strlen (str);
626688de56ccSmrg  patlen = strlen (pat);
62671ab64890Smrg
626888de56ccSmrg  if (patlen <= len)
626988de56ccSmrg    {
627088de56ccSmrg      str += len - patlen;
6271862bcd1aSmrg      if (STREQ (str, pat))
627288de56ccSmrg	*str = '\0';
627388de56ccSmrg    }
627488de56ccSmrg  return str;
627588de56ccSmrg}
62761ab64890Smrg
6277e9fcaa8aSmrgvoid
6278e9fcaa8aSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
6279e9fcaa8aSmrg{
6280e9fcaa8aSmrg  va_list args;
6281e9fcaa8aSmrg  if (lt_debug)
6282e9fcaa8aSmrg    {
6283e9fcaa8aSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6284e9fcaa8aSmrg      va_start (args, fmt);
6285e9fcaa8aSmrg      (void) vfprintf (stderr, fmt, args);
6286e9fcaa8aSmrg      va_end (args);
6287e9fcaa8aSmrg    }
6288e9fcaa8aSmrg}
6289e9fcaa8aSmrg
629088de56ccSmrgstatic void
6291e9fcaa8aSmrglt_error_core (int exit_status, const char *file,
6292e9fcaa8aSmrg	       int line, const char *mode,
629388de56ccSmrg	       const char *message, va_list ap)
629488de56ccSmrg{
6295e9fcaa8aSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
629688de56ccSmrg  vfprintf (stderr, message, ap);
629788de56ccSmrg  fprintf (stderr, ".\n");
62981ab64890Smrg
629988de56ccSmrg  if (exit_status >= 0)
630088de56ccSmrg    exit (exit_status);
630188de56ccSmrg}
63021ab64890Smrg
630388de56ccSmrgvoid
6304e9fcaa8aSmrglt_fatal (const char *file, int line, const char *message, ...)
630588de56ccSmrg{
630688de56ccSmrg  va_list ap;
630788de56ccSmrg  va_start (ap, message);
6308e9fcaa8aSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
630988de56ccSmrg  va_end (ap);
631088de56ccSmrg}
63112e9c7c8cSmrg
6312e9fcaa8aSmrgstatic const char *
6313e9fcaa8aSmrgnonnull (const char *s)
6314e9fcaa8aSmrg{
6315e9fcaa8aSmrg  return s ? s : "(null)";
6316e9fcaa8aSmrg}
6317e9fcaa8aSmrg
6318e9fcaa8aSmrgstatic const char *
6319e9fcaa8aSmrgnonempty (const char *s)
6320e9fcaa8aSmrg{
6321e9fcaa8aSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
6322e9fcaa8aSmrg}
6323e9fcaa8aSmrg
632488de56ccSmrgvoid
632588de56ccSmrglt_setenv (const char *name, const char *value)
632688de56ccSmrg{
6327e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
6328e9fcaa8aSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
6329e9fcaa8aSmrg                  nonnull (name), nonnull (value));
633088de56ccSmrg  {
633188de56ccSmrg#ifdef HAVE_SETENV
633288de56ccSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
633388de56ccSmrg    char *str = xstrdup (value);
633488de56ccSmrg    setenv (name, str, 1);
633588de56ccSmrg#else
6336862bcd1aSmrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
633788de56ccSmrg    char *str = XMALLOC (char, len);
633888de56ccSmrg    sprintf (str, "%s=%s", name, value);
633988de56ccSmrg    if (putenv (str) != EXIT_SUCCESS)
634088de56ccSmrg      {
634188de56ccSmrg        XFREE (str);
634288de56ccSmrg      }
634388de56ccSmrg#endif
634488de56ccSmrg  }
634588de56ccSmrg}
63461ab64890Smrg
634788de56ccSmrgchar *
634888de56ccSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
634988de56ccSmrg{
635088de56ccSmrg  char *new_value;
635188de56ccSmrg  if (orig_value && *orig_value)
635288de56ccSmrg    {
6353862bcd1aSmrg      size_t orig_value_len = strlen (orig_value);
6354862bcd1aSmrg      size_t add_len = strlen (add);
635588de56ccSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
635688de56ccSmrg      if (to_end)
635788de56ccSmrg        {
635888de56ccSmrg          strcpy (new_value, orig_value);
635988de56ccSmrg          strcpy (new_value + orig_value_len, add);
636088de56ccSmrg        }
636188de56ccSmrg      else
636288de56ccSmrg        {
636388de56ccSmrg          strcpy (new_value, add);
636488de56ccSmrg          strcpy (new_value + add_len, orig_value);
636588de56ccSmrg        }
636688de56ccSmrg    }
636788de56ccSmrg  else
636888de56ccSmrg    {
636988de56ccSmrg      new_value = xstrdup (add);
637088de56ccSmrg    }
637188de56ccSmrg  return new_value;
637288de56ccSmrg}
63731ab64890Smrg
637488de56ccSmrgvoid
637588de56ccSmrglt_update_exe_path (const char *name, const char *value)
637688de56ccSmrg{
6377e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
6378e9fcaa8aSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6379e9fcaa8aSmrg                  nonnull (name), nonnull (value));
63801ab64890Smrg
638188de56ccSmrg  if (name && *name && value && *value)
638288de56ccSmrg    {
638388de56ccSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
638488de56ccSmrg      /* some systems can't cope with a ':'-terminated path #' */
6385862bcd1aSmrg      size_t len = strlen (new_value);
6386862bcd1aSmrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
638788de56ccSmrg        {
6388862bcd1aSmrg          new_value[--len] = '\0';
638988de56ccSmrg        }
639088de56ccSmrg      lt_setenv (name, new_value);
639188de56ccSmrg      XFREE (new_value);
639288de56ccSmrg    }
639388de56ccSmrg}
63941ab64890Smrg
639588de56ccSmrgvoid
639688de56ccSmrglt_update_lib_path (const char *name, const char *value)
639788de56ccSmrg{
6398e9fcaa8aSmrg  lt_debugprintf (__FILE__, __LINE__,
6399e9fcaa8aSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6400e9fcaa8aSmrg                  nonnull (name), nonnull (value));
64011ab64890Smrg
640288de56ccSmrg  if (name && *name && value && *value)
640388de56ccSmrg    {
640488de56ccSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
640588de56ccSmrg      lt_setenv (name, new_value);
640688de56ccSmrg      XFREE (new_value);
640788de56ccSmrg    }
640888de56ccSmrg}
64091ab64890Smrg
6410e9fcaa8aSmrgEOF
6411e9fcaa8aSmrg	    case $host_os in
6412e9fcaa8aSmrg	      mingw*)
6413e9fcaa8aSmrg		cat <<"EOF"
6414e9fcaa8aSmrg
6415e9fcaa8aSmrg/* Prepares an argument vector before calling spawn().
6416e9fcaa8aSmrg   Note that spawn() does not by itself call the command interpreter
6417e9fcaa8aSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6418e9fcaa8aSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6419e9fcaa8aSmrg         GetVersionEx(&v);
6420e9fcaa8aSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6421e9fcaa8aSmrg      }) ? "cmd.exe" : "command.com").
6422e9fcaa8aSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
6423e9fcaa8aSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
6424e9fcaa8aSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6425e9fcaa8aSmrg   special way:
6426e9fcaa8aSmrg   - Space and tab are interpreted as delimiters. They are not treated as
6427e9fcaa8aSmrg     delimiters if they are surrounded by double quotes: "...".
6428e9fcaa8aSmrg   - Unescaped double quotes are removed from the input. Their only effect is
6429e9fcaa8aSmrg     that within double quotes, space and tab are treated like normal
6430e9fcaa8aSmrg     characters.
6431e9fcaa8aSmrg   - Backslashes not followed by double quotes are not special.
6432e9fcaa8aSmrg   - But 2*n+1 backslashes followed by a double quote become
6433e9fcaa8aSmrg     n backslashes followed by a double quote (n >= 0):
6434e9fcaa8aSmrg       \" -> "
6435e9fcaa8aSmrg       \\\" -> \"
6436e9fcaa8aSmrg       \\\\\" -> \\"
6437e9fcaa8aSmrg */
6438e9fcaa8aSmrg#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"
6439e9fcaa8aSmrg#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"
6440e9fcaa8aSmrgchar **
6441e9fcaa8aSmrgprepare_spawn (char **argv)
6442e9fcaa8aSmrg{
6443e9fcaa8aSmrg  size_t argc;
6444e9fcaa8aSmrg  char **new_argv;
6445e9fcaa8aSmrg  size_t i;
6446e9fcaa8aSmrg
6447e9fcaa8aSmrg  /* Count number of arguments.  */
6448e9fcaa8aSmrg  for (argc = 0; argv[argc] != NULL; argc++)
6449e9fcaa8aSmrg    ;
6450e9fcaa8aSmrg
6451e9fcaa8aSmrg  /* Allocate new argument vector.  */
6452e9fcaa8aSmrg  new_argv = XMALLOC (char *, argc + 1);
6453e9fcaa8aSmrg
6454e9fcaa8aSmrg  /* Put quoted arguments into the new argument vector.  */
6455e9fcaa8aSmrg  for (i = 0; i < argc; i++)
6456e9fcaa8aSmrg    {
6457e9fcaa8aSmrg      const char *string = argv[i];
6458e9fcaa8aSmrg
6459e9fcaa8aSmrg      if (string[0] == '\0')
6460e9fcaa8aSmrg	new_argv[i] = xstrdup ("\"\"");
6461e9fcaa8aSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6462e9fcaa8aSmrg	{
6463e9fcaa8aSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6464e9fcaa8aSmrg	  size_t length;
6465e9fcaa8aSmrg	  unsigned int backslashes;
6466e9fcaa8aSmrg	  const char *s;
6467e9fcaa8aSmrg	  char *quoted_string;
6468e9fcaa8aSmrg	  char *p;
6469e9fcaa8aSmrg
6470e9fcaa8aSmrg	  length = 0;
6471e9fcaa8aSmrg	  backslashes = 0;
6472e9fcaa8aSmrg	  if (quote_around)
6473e9fcaa8aSmrg	    length++;
6474e9fcaa8aSmrg	  for (s = string; *s != '\0'; s++)
6475e9fcaa8aSmrg	    {
6476e9fcaa8aSmrg	      char c = *s;
6477e9fcaa8aSmrg	      if (c == '"')
6478e9fcaa8aSmrg		length += backslashes + 1;
6479e9fcaa8aSmrg	      length++;
6480e9fcaa8aSmrg	      if (c == '\\')
6481e9fcaa8aSmrg		backslashes++;
6482e9fcaa8aSmrg	      else
6483e9fcaa8aSmrg		backslashes = 0;
6484e9fcaa8aSmrg	    }
6485e9fcaa8aSmrg	  if (quote_around)
6486e9fcaa8aSmrg	    length += backslashes + 1;
6487e9fcaa8aSmrg
6488e9fcaa8aSmrg	  quoted_string = XMALLOC (char, length + 1);
6489e9fcaa8aSmrg
6490e9fcaa8aSmrg	  p = quoted_string;
6491e9fcaa8aSmrg	  backslashes = 0;
6492e9fcaa8aSmrg	  if (quote_around)
6493e9fcaa8aSmrg	    *p++ = '"';
6494e9fcaa8aSmrg	  for (s = string; *s != '\0'; s++)
6495e9fcaa8aSmrg	    {
6496e9fcaa8aSmrg	      char c = *s;
6497e9fcaa8aSmrg	      if (c == '"')
6498e9fcaa8aSmrg		{
6499e9fcaa8aSmrg		  unsigned int j;
6500e9fcaa8aSmrg		  for (j = backslashes + 1; j > 0; j--)
6501e9fcaa8aSmrg		    *p++ = '\\';
6502e9fcaa8aSmrg		}
6503e9fcaa8aSmrg	      *p++ = c;
6504e9fcaa8aSmrg	      if (c == '\\')
6505e9fcaa8aSmrg		backslashes++;
6506e9fcaa8aSmrg	      else
6507e9fcaa8aSmrg		backslashes = 0;
6508e9fcaa8aSmrg	    }
6509e9fcaa8aSmrg	  if (quote_around)
6510e9fcaa8aSmrg	    {
6511e9fcaa8aSmrg	      unsigned int j;
6512e9fcaa8aSmrg	      for (j = backslashes; j > 0; j--)
6513e9fcaa8aSmrg		*p++ = '\\';
6514e9fcaa8aSmrg	      *p++ = '"';
6515e9fcaa8aSmrg	    }
6516e9fcaa8aSmrg	  *p = '\0';
6517e9fcaa8aSmrg
6518e9fcaa8aSmrg	  new_argv[i] = quoted_string;
6519e9fcaa8aSmrg	}
6520e9fcaa8aSmrg      else
6521e9fcaa8aSmrg	new_argv[i] = (char *) string;
6522e9fcaa8aSmrg    }
6523e9fcaa8aSmrg  new_argv[argc] = NULL;
6524e9fcaa8aSmrg
6525e9fcaa8aSmrg  return new_argv;
6526e9fcaa8aSmrg}
6527e9fcaa8aSmrgEOF
6528e9fcaa8aSmrg		;;
6529e9fcaa8aSmrg	    esac
6530e9fcaa8aSmrg
6531e9fcaa8aSmrg            cat <<"EOF"
6532e9fcaa8aSmrgvoid lt_dump_script (FILE* f)
6533e9fcaa8aSmrg{
6534e9fcaa8aSmrgEOF
6535e9fcaa8aSmrg	    func_emit_wrapper yes |
6536eb411b4bSmrg	      $SED -n -e '
6537eb411b4bSmrgs/^\(.\{79\}\)\(..*\)/\1\
6538eb411b4bSmrg\2/
6539eb411b4bSmrgh
6540eb411b4bSmrgs/\([\\"]\)/\\\1/g
6541eb411b4bSmrgs/$/\\n/
6542eb411b4bSmrgs/\([^\n]*\).*/  fputs ("\1", f);/p
6543eb411b4bSmrgg
6544eb411b4bSmrgD'
6545e9fcaa8aSmrg            cat <<"EOF"
6546e9fcaa8aSmrg}
654788de56ccSmrgEOF
654888de56ccSmrg}
654988de56ccSmrg# end: func_emit_cwrapperexe_src
65501ab64890Smrg
6551e9fcaa8aSmrg# func_win32_import_lib_p ARG
6552e9fcaa8aSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
6553e9fcaa8aSmrgfunc_win32_import_lib_p ()
6554e9fcaa8aSmrg{
6555862bcd1aSmrg    $debug_cmd
6556862bcd1aSmrg
6557e9fcaa8aSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6558e9fcaa8aSmrg    *import*) : ;;
6559e9fcaa8aSmrg    *) false ;;
6560e9fcaa8aSmrg    esac
6561e9fcaa8aSmrg}
6562e9fcaa8aSmrg
6563862bcd1aSmrg# func_suncc_cstd_abi
6564862bcd1aSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
6565862bcd1aSmrg# Several compiler flags select an ABI that is incompatible with the
6566862bcd1aSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
6567862bcd1aSmrgfunc_suncc_cstd_abi ()
6568862bcd1aSmrg{
6569862bcd1aSmrg    $debug_cmd
6570862bcd1aSmrg
6571862bcd1aSmrg    case " $compile_command " in
6572862bcd1aSmrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
6573862bcd1aSmrg      suncc_use_cstd_abi=no
6574862bcd1aSmrg      ;;
6575862bcd1aSmrg    *)
6576862bcd1aSmrg      suncc_use_cstd_abi=yes
6577862bcd1aSmrg      ;;
6578862bcd1aSmrg    esac
6579862bcd1aSmrg}
6580862bcd1aSmrg
658188de56ccSmrg# func_mode_link arg...
658288de56ccSmrgfunc_mode_link ()
658388de56ccSmrg{
6584862bcd1aSmrg    $debug_cmd
6585862bcd1aSmrg
658688de56ccSmrg    case $host in
658788de56ccSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
658888de56ccSmrg      # It is impossible to link a dll without this setting, and
658988de56ccSmrg      # we shouldn't force the makefile maintainer to figure out
6590862bcd1aSmrg      # what system we are compiling for in order to pass an extra
659188de56ccSmrg      # flag for every libtool invocation.
659288de56ccSmrg      # allow_undefined=no
65931ab64890Smrg
659488de56ccSmrg      # FIXME: Unfortunately, there are problems with the above when trying
6595862bcd1aSmrg      # to make a dll that has undefined symbols, in which case not
659688de56ccSmrg      # even a static library is built.  For now, we need to specify
659788de56ccSmrg      # -no-undefined on the libtool link line when we can be certain
659888de56ccSmrg      # that all symbols are satisfied, otherwise we get a static library.
659988de56ccSmrg      allow_undefined=yes
660088de56ccSmrg      ;;
660188de56ccSmrg    *)
660288de56ccSmrg      allow_undefined=yes
660388de56ccSmrg      ;;
660488de56ccSmrg    esac
660588de56ccSmrg    libtool_args=$nonopt
660688de56ccSmrg    base_compile="$nonopt $@"
660788de56ccSmrg    compile_command=$nonopt
660888de56ccSmrg    finalize_command=$nonopt
66091ab64890Smrg
661088de56ccSmrg    compile_rpath=
661188de56ccSmrg    finalize_rpath=
661288de56ccSmrg    compile_shlibpath=
661388de56ccSmrg    finalize_shlibpath=
661488de56ccSmrg    convenience=
661588de56ccSmrg    old_convenience=
661688de56ccSmrg    deplibs=
661788de56ccSmrg    old_deplibs=
661888de56ccSmrg    compiler_flags=
661988de56ccSmrg    linker_flags=
662088de56ccSmrg    dllsearchpath=
662188de56ccSmrg    lib_search_path=`pwd`
662288de56ccSmrg    inst_prefix_dir=
662388de56ccSmrg    new_inherited_linker_flags=
66241ab64890Smrg
662588de56ccSmrg    avoid_version=no
6626e9fcaa8aSmrg    bindir=
662788de56ccSmrg    dlfiles=
662888de56ccSmrg    dlprefiles=
662988de56ccSmrg    dlself=no
663088de56ccSmrg    export_dynamic=no
663188de56ccSmrg    export_symbols=
663288de56ccSmrg    export_symbols_regex=
663388de56ccSmrg    generated=
663488de56ccSmrg    libobjs=
663588de56ccSmrg    ltlibs=
663688de56ccSmrg    module=no
663788de56ccSmrg    no_install=no
663888de56ccSmrg    objs=
6639862bcd1aSmrg    os2dllname=
664088de56ccSmrg    non_pic_objects=
664188de56ccSmrg    precious_files_regex=
664288de56ccSmrg    prefer_static_libs=no
6643862bcd1aSmrg    preload=false
664488de56ccSmrg    prev=
664588de56ccSmrg    prevarg=
664688de56ccSmrg    release=
664788de56ccSmrg    rpath=
664888de56ccSmrg    xrpath=
664988de56ccSmrg    perm_rpath=
665088de56ccSmrg    temp_rpath=
665188de56ccSmrg    thread_safe=no
665288de56ccSmrg    vinfo=
665388de56ccSmrg    vinfo_number=no
665488de56ccSmrg    weak_libs=
6655862bcd1aSmrg    single_module=$wl-single_module
665688de56ccSmrg    func_infer_tag $base_compile
665788de56ccSmrg
665888de56ccSmrg    # We need to know -static, to get the right output filenames.
665988de56ccSmrg    for arg
666088de56ccSmrg    do
666188de56ccSmrg      case $arg in
666288de56ccSmrg      -shared)
6663862bcd1aSmrg	test yes != "$build_libtool_libs" \
6664862bcd1aSmrg	  && func_fatal_configuration "cannot build a shared library"
666588de56ccSmrg	build_old_libs=no
666688de56ccSmrg	break
666788de56ccSmrg	;;
666888de56ccSmrg      -all-static | -static | -static-libtool-libs)
666988de56ccSmrg	case $arg in
667088de56ccSmrg	-all-static)
6671862bcd1aSmrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
667288de56ccSmrg	    func_warning "complete static linking is impossible in this configuration"
667388de56ccSmrg	  fi
667488de56ccSmrg	  if test -n "$link_static_flag"; then
667588de56ccSmrg	    dlopen_self=$dlopen_self_static
667688de56ccSmrg	  fi
667788de56ccSmrg	  prefer_static_libs=yes
667888de56ccSmrg	  ;;
667988de56ccSmrg	-static)
668088de56ccSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
668188de56ccSmrg	    dlopen_self=$dlopen_self_static
668288de56ccSmrg	  fi
668388de56ccSmrg	  prefer_static_libs=built
668488de56ccSmrg	  ;;
668588de56ccSmrg	-static-libtool-libs)
668688de56ccSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
668788de56ccSmrg	    dlopen_self=$dlopen_self_static
6688b4ee4795Smrg	  fi
668988de56ccSmrg	  prefer_static_libs=yes
669088de56ccSmrg	  ;;
669188de56ccSmrg	esac
669288de56ccSmrg	build_libtool_libs=no
669388de56ccSmrg	build_old_libs=yes
669488de56ccSmrg	break
669588de56ccSmrg	;;
669688de56ccSmrg      esac
669788de56ccSmrg    done
66981ab64890Smrg
669988de56ccSmrg    # See if our shared archives depend on static archives.
670088de56ccSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
67011ab64890Smrg
670288de56ccSmrg    # Go through the arguments, transforming them on the way.
670388de56ccSmrg    while test "$#" -gt 0; do
6704862bcd1aSmrg      arg=$1
670588de56ccSmrg      shift
670688de56ccSmrg      func_quote_for_eval "$arg"
670788de56ccSmrg      qarg=$func_quote_for_eval_unquoted_result
670888de56ccSmrg      func_append libtool_args " $func_quote_for_eval_result"
67091ab64890Smrg
671088de56ccSmrg      # If the previous option needs an argument, assign it.
671188de56ccSmrg      if test -n "$prev"; then
671288de56ccSmrg	case $prev in
671388de56ccSmrg	output)
671488de56ccSmrg	  func_append compile_command " @OUTPUT@"
671588de56ccSmrg	  func_append finalize_command " @OUTPUT@"
671688de56ccSmrg	  ;;
671788de56ccSmrg	esac
67181ab64890Smrg
671988de56ccSmrg	case $prev in
6720e9fcaa8aSmrg	bindir)
6721862bcd1aSmrg	  bindir=$arg
6722e9fcaa8aSmrg	  prev=
6723e9fcaa8aSmrg	  continue
6724e9fcaa8aSmrg	  ;;
672588de56ccSmrg	dlfiles|dlprefiles)
6726862bcd1aSmrg	  $preload || {
672788de56ccSmrg	    # Add the symbol object into the linking commands.
672888de56ccSmrg	    func_append compile_command " @SYMFILE@"
672988de56ccSmrg	    func_append finalize_command " @SYMFILE@"
6730862bcd1aSmrg	    preload=:
6731862bcd1aSmrg	  }
673288de56ccSmrg	  case $arg in
673388de56ccSmrg	  *.la | *.lo) ;;  # We handle these cases below.
673488de56ccSmrg	  force)
6735862bcd1aSmrg	    if test no = "$dlself"; then
673688de56ccSmrg	      dlself=needless
673788de56ccSmrg	      export_dynamic=yes
673888de56ccSmrg	    fi
673988de56ccSmrg	    prev=
674088de56ccSmrg	    continue
674188de56ccSmrg	    ;;
674288de56ccSmrg	  self)
6743862bcd1aSmrg	    if test dlprefiles = "$prev"; then
674488de56ccSmrg	      dlself=yes
6745862bcd1aSmrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
674688de56ccSmrg	      dlself=yes
6747b4ee4795Smrg	    else
674888de56ccSmrg	      dlself=needless
674988de56ccSmrg	      export_dynamic=yes
6750b4ee4795Smrg	    fi
675188de56ccSmrg	    prev=
675288de56ccSmrg	    continue
675388de56ccSmrg	    ;;
675488de56ccSmrg	  *)
6755862bcd1aSmrg	    if test dlfiles = "$prev"; then
6756e9fcaa8aSmrg	      func_append dlfiles " $arg"
6757b4ee4795Smrg	    else
6758e9fcaa8aSmrg	      func_append dlprefiles " $arg"
6759b4ee4795Smrg	    fi
676088de56ccSmrg	    prev=
676188de56ccSmrg	    continue
676288de56ccSmrg	    ;;
676388de56ccSmrg	  esac
676488de56ccSmrg	  ;;
676588de56ccSmrg	expsyms)
6766862bcd1aSmrg	  export_symbols=$arg
676788de56ccSmrg	  test -f "$arg" \
6768862bcd1aSmrg	    || func_fatal_error "symbol file '$arg' does not exist"
676988de56ccSmrg	  prev=
677088de56ccSmrg	  continue
677188de56ccSmrg	  ;;
677288de56ccSmrg	expsyms_regex)
6773862bcd1aSmrg	  export_symbols_regex=$arg
677488de56ccSmrg	  prev=
677588de56ccSmrg	  continue
677688de56ccSmrg	  ;;
677788de56ccSmrg	framework)
6778b4ee4795Smrg	  case $host in
677988de56ccSmrg	    *-*-darwin*)
678088de56ccSmrg	      case "$deplibs " in
678188de56ccSmrg		*" $qarg.ltframework "*) ;;
6782e9fcaa8aSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
678388de56ccSmrg		   ;;
678488de56ccSmrg	      esac
678588de56ccSmrg	      ;;
6786b4ee4795Smrg	  esac
678788de56ccSmrg	  prev=
678888de56ccSmrg	  continue
6789b4ee4795Smrg	  ;;
679088de56ccSmrg	inst_prefix)
6791862bcd1aSmrg	  inst_prefix_dir=$arg
6792862bcd1aSmrg	  prev=
6793862bcd1aSmrg	  continue
6794862bcd1aSmrg	  ;;
6795862bcd1aSmrg	mllvm)
6796862bcd1aSmrg	  # Clang does not use LLVM to link, so we can simply discard any
6797862bcd1aSmrg	  # '-mllvm $arg' options when doing the link step.
679888de56ccSmrg	  prev=
679988de56ccSmrg	  continue
6800b4ee4795Smrg	  ;;
680188de56ccSmrg	objectlist)
680288de56ccSmrg	  if test -f "$arg"; then
680388de56ccSmrg	    save_arg=$arg
680488de56ccSmrg	    moreargs=
680588de56ccSmrg	    for fil in `cat "$save_arg"`
680688de56ccSmrg	    do
6807e9fcaa8aSmrg#	      func_append moreargs " $fil"
680888de56ccSmrg	      arg=$fil
680988de56ccSmrg	      # A libtool-controlled object.
68102e9c7c8cSmrg
681188de56ccSmrg	      # Check to see that this really is a libtool object.
681288de56ccSmrg	      if func_lalib_unsafe_p "$arg"; then
681388de56ccSmrg		pic_object=
681488de56ccSmrg		non_pic_object=
68152e9c7c8cSmrg
681688de56ccSmrg		# Read the .lo file
681788de56ccSmrg		func_source "$arg"
68182e9c7c8cSmrg
681988de56ccSmrg		if test -z "$pic_object" ||
682088de56ccSmrg		   test -z "$non_pic_object" ||
6821862bcd1aSmrg		   test none = "$pic_object" &&
6822862bcd1aSmrg		   test none = "$non_pic_object"; then
6823862bcd1aSmrg		  func_fatal_error "cannot find name of object for '$arg'"
682488de56ccSmrg		fi
68252e9c7c8cSmrg
682688de56ccSmrg		# Extract subdirectory from the argument.
682788de56ccSmrg		func_dirname "$arg" "/" ""
6828862bcd1aSmrg		xdir=$func_dirname_result
68292e9c7c8cSmrg
6830862bcd1aSmrg		if test none != "$pic_object"; then
683188de56ccSmrg		  # Prepend the subdirectory the object is found in.
6832862bcd1aSmrg		  pic_object=$xdir$pic_object
68332e9c7c8cSmrg
6834862bcd1aSmrg		  if test dlfiles = "$prev"; then
6835862bcd1aSmrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6836e9fcaa8aSmrg		      func_append dlfiles " $pic_object"
683788de56ccSmrg		      prev=
683888de56ccSmrg		      continue
683988de56ccSmrg		    else
684088de56ccSmrg		      # If libtool objects are unsupported, then we need to preload.
684188de56ccSmrg		      prev=dlprefiles
684288de56ccSmrg		    fi
684388de56ccSmrg		  fi
68442e9c7c8cSmrg
684588de56ccSmrg		  # CHECK ME:  I think I busted this.  -Ossama
6846862bcd1aSmrg		  if test dlprefiles = "$prev"; then
684788de56ccSmrg		    # Preload the old-style object.
6848e9fcaa8aSmrg		    func_append dlprefiles " $pic_object"
684988de56ccSmrg		    prev=
685088de56ccSmrg		  fi
68512e9c7c8cSmrg
685288de56ccSmrg		  # A PIC object.
685388de56ccSmrg		  func_append libobjs " $pic_object"
6854862bcd1aSmrg		  arg=$pic_object
685588de56ccSmrg		fi
68562e9c7c8cSmrg
685788de56ccSmrg		# Non-PIC object.
6858862bcd1aSmrg		if test none != "$non_pic_object"; then
685988de56ccSmrg		  # Prepend the subdirectory the object is found in.
6860862bcd1aSmrg		  non_pic_object=$xdir$non_pic_object
68612e9c7c8cSmrg
686288de56ccSmrg		  # A standard non-PIC object
686388de56ccSmrg		  func_append non_pic_objects " $non_pic_object"
6864862bcd1aSmrg		  if test -z "$pic_object" || test none = "$pic_object"; then
6865862bcd1aSmrg		    arg=$non_pic_object
686688de56ccSmrg		  fi
686788de56ccSmrg		else
686888de56ccSmrg		  # If the PIC object exists, use it instead.
686988de56ccSmrg		  # $xdir was prepended to $pic_object above.
6870862bcd1aSmrg		  non_pic_object=$pic_object
687188de56ccSmrg		  func_append non_pic_objects " $non_pic_object"
687288de56ccSmrg		fi
687388de56ccSmrg	      else
687488de56ccSmrg		# Only an error if not doing a dry-run.
687588de56ccSmrg		if $opt_dry_run; then
687688de56ccSmrg		  # Extract subdirectory from the argument.
687788de56ccSmrg		  func_dirname "$arg" "/" ""
6878862bcd1aSmrg		  xdir=$func_dirname_result
687988de56ccSmrg
688088de56ccSmrg		  func_lo2o "$arg"
688188de56ccSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
688288de56ccSmrg		  non_pic_object=$xdir$func_lo2o_result
688388de56ccSmrg		  func_append libobjs " $pic_object"
688488de56ccSmrg		  func_append non_pic_objects " $non_pic_object"
688588de56ccSmrg	        else
6886862bcd1aSmrg		  func_fatal_error "'$arg' is not a valid libtool object"
688788de56ccSmrg		fi
688888de56ccSmrg	      fi
688988de56ccSmrg	    done
6890b4ee4795Smrg	  else
6891862bcd1aSmrg	    func_fatal_error "link input file '$arg' does not exist"
6892b4ee4795Smrg	  fi
689388de56ccSmrg	  arg=$save_arg
689488de56ccSmrg	  prev=
689588de56ccSmrg	  continue
689688de56ccSmrg	  ;;
6897862bcd1aSmrg	os2dllname)
6898862bcd1aSmrg	  os2dllname=$arg
6899862bcd1aSmrg	  prev=
6900862bcd1aSmrg	  continue
6901862bcd1aSmrg	  ;;
690288de56ccSmrg	precious_regex)
6903862bcd1aSmrg	  precious_files_regex=$arg
690488de56ccSmrg	  prev=
690588de56ccSmrg	  continue
690688de56ccSmrg	  ;;
690788de56ccSmrg	release)
6908862bcd1aSmrg	  release=-$arg
690988de56ccSmrg	  prev=
691088de56ccSmrg	  continue
691188de56ccSmrg	  ;;
691288de56ccSmrg	rpath | xrpath)
691388de56ccSmrg	  # We need an absolute path.
691488de56ccSmrg	  case $arg in
691588de56ccSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
691688de56ccSmrg	  *)
691788de56ccSmrg	    func_fatal_error "only absolute run-paths are allowed"
691888de56ccSmrg	    ;;
691988de56ccSmrg	  esac
6920862bcd1aSmrg	  if test rpath = "$prev"; then
692188de56ccSmrg	    case "$rpath " in
692288de56ccSmrg	    *" $arg "*) ;;
6923e9fcaa8aSmrg	    *) func_append rpath " $arg" ;;
692488de56ccSmrg	    esac
6925b4ee4795Smrg	  else
692688de56ccSmrg	    case "$xrpath " in
692788de56ccSmrg	    *" $arg "*) ;;
6928e9fcaa8aSmrg	    *) func_append xrpath " $arg" ;;
692988de56ccSmrg	    esac
6930b4ee4795Smrg	  fi
693188de56ccSmrg	  prev=
693288de56ccSmrg	  continue
693388de56ccSmrg	  ;;
693488de56ccSmrg	shrext)
6935862bcd1aSmrg	  shrext_cmds=$arg
693688de56ccSmrg	  prev=
693788de56ccSmrg	  continue
693888de56ccSmrg	  ;;
693988de56ccSmrg	weak)
6940e9fcaa8aSmrg	  func_append weak_libs " $arg"
694188de56ccSmrg	  prev=
694288de56ccSmrg	  continue
694388de56ccSmrg	  ;;
694488de56ccSmrg	xcclinker)
6945e9fcaa8aSmrg	  func_append linker_flags " $qarg"
6946e9fcaa8aSmrg	  func_append compiler_flags " $qarg"
694788de56ccSmrg	  prev=
694888de56ccSmrg	  func_append compile_command " $qarg"
694988de56ccSmrg	  func_append finalize_command " $qarg"
695088de56ccSmrg	  continue
695188de56ccSmrg	  ;;
695288de56ccSmrg	xcompiler)
6953e9fcaa8aSmrg	  func_append compiler_flags " $qarg"
695488de56ccSmrg	  prev=
695588de56ccSmrg	  func_append compile_command " $qarg"
695688de56ccSmrg	  func_append finalize_command " $qarg"
695788de56ccSmrg	  continue
695888de56ccSmrg	  ;;
695988de56ccSmrg	xlinker)
6960e9fcaa8aSmrg	  func_append linker_flags " $qarg"
6961e9fcaa8aSmrg	  func_append compiler_flags " $wl$qarg"
696288de56ccSmrg	  prev=
696388de56ccSmrg	  func_append compile_command " $wl$qarg"
696488de56ccSmrg	  func_append finalize_command " $wl$qarg"
696588de56ccSmrg	  continue
696688de56ccSmrg	  ;;
696788de56ccSmrg	*)
696888de56ccSmrg	  eval "$prev=\"\$arg\""
696988de56ccSmrg	  prev=
697088de56ccSmrg	  continue
697188de56ccSmrg	  ;;
69722e9c7c8cSmrg	esac
697388de56ccSmrg      fi # test -n "$prev"
69742e9c7c8cSmrg
6975862bcd1aSmrg      prevarg=$arg
69762e9c7c8cSmrg
697788de56ccSmrg      case $arg in
697888de56ccSmrg      -all-static)
697988de56ccSmrg	if test -n "$link_static_flag"; then
698088de56ccSmrg	  # See comment for -static flag below, for more details.
698188de56ccSmrg	  func_append compile_command " $link_static_flag"
698288de56ccSmrg	  func_append finalize_command " $link_static_flag"
698388de56ccSmrg	fi
698488de56ccSmrg	continue
698588de56ccSmrg	;;
69862e9c7c8cSmrg
698788de56ccSmrg      -allow-undefined)
698888de56ccSmrg	# FIXME: remove this flag sometime in the future.
6989862bcd1aSmrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
699088de56ccSmrg	;;
69912e9c7c8cSmrg
699288de56ccSmrg      -avoid-version)
699388de56ccSmrg	avoid_version=yes
699488de56ccSmrg	continue
699588de56ccSmrg	;;
69962e9c7c8cSmrg
6997e9fcaa8aSmrg      -bindir)
6998e9fcaa8aSmrg	prev=bindir
6999e9fcaa8aSmrg	continue
7000e9fcaa8aSmrg	;;
7001e9fcaa8aSmrg
700288de56ccSmrg      -dlopen)
700388de56ccSmrg	prev=dlfiles
700488de56ccSmrg	continue
700588de56ccSmrg	;;
70062e9c7c8cSmrg
700788de56ccSmrg      -dlpreopen)
700888de56ccSmrg	prev=dlprefiles
700988de56ccSmrg	continue
701088de56ccSmrg	;;
70112e9c7c8cSmrg
701288de56ccSmrg      -export-dynamic)
701388de56ccSmrg	export_dynamic=yes
701488de56ccSmrg	continue
701588de56ccSmrg	;;
70162e9c7c8cSmrg
701788de56ccSmrg      -export-symbols | -export-symbols-regex)
701888de56ccSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
701988de56ccSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
702088de56ccSmrg	fi
7021862bcd1aSmrg	if test X-export-symbols = "X$arg"; then
702288de56ccSmrg	  prev=expsyms
702388de56ccSmrg	else
702488de56ccSmrg	  prev=expsyms_regex
702588de56ccSmrg	fi
702688de56ccSmrg	continue
702788de56ccSmrg	;;
70282e9c7c8cSmrg
702988de56ccSmrg      -framework)
703088de56ccSmrg	prev=framework
703188de56ccSmrg	continue
703288de56ccSmrg	;;
70332e9c7c8cSmrg
703488de56ccSmrg      -inst-prefix-dir)
703588de56ccSmrg	prev=inst_prefix
703688de56ccSmrg	continue
703788de56ccSmrg	;;
70382e9c7c8cSmrg
703988de56ccSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
704088de56ccSmrg      # so, if we see these flags be careful not to treat them like -L
704188de56ccSmrg      -L[A-Z][A-Z]*:*)
704288de56ccSmrg	case $with_gcc/$host in
704388de56ccSmrg	no/*-*-irix* | /*-*-irix*)
704488de56ccSmrg	  func_append compile_command " $arg"
704588de56ccSmrg	  func_append finalize_command " $arg"
704688de56ccSmrg	  ;;
704788de56ccSmrg	esac
704888de56ccSmrg	continue
704988de56ccSmrg	;;
70502e9c7c8cSmrg
705188de56ccSmrg      -L*)
7052e9fcaa8aSmrg	func_stripname "-L" '' "$arg"
7053e9fcaa8aSmrg	if test -z "$func_stripname_result"; then
705488de56ccSmrg	  if test "$#" -gt 0; then
7055862bcd1aSmrg	    func_fatal_error "require no space between '-L' and '$1'"
705688de56ccSmrg	  else
7057862bcd1aSmrg	    func_fatal_error "need path for '-L' option"
705888de56ccSmrg	  fi
705988de56ccSmrg	fi
7060e9fcaa8aSmrg	func_resolve_sysroot "$func_stripname_result"
7061e9fcaa8aSmrg	dir=$func_resolve_sysroot_result
706288de56ccSmrg	# We need an absolute path.
706388de56ccSmrg	case $dir in
706488de56ccSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
706588de56ccSmrg	*)
706688de56ccSmrg	  absdir=`cd "$dir" && pwd`
706788de56ccSmrg	  test -z "$absdir" && \
7068862bcd1aSmrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
7069862bcd1aSmrg	  dir=$absdir
707088de56ccSmrg	  ;;
707188de56ccSmrg	esac
707288de56ccSmrg	case "$deplibs " in
7073e9fcaa8aSmrg	*" -L$dir "* | *" $arg "*)
7074e9fcaa8aSmrg	  # Will only happen for absolute or sysroot arguments
7075e9fcaa8aSmrg	  ;;
707688de56ccSmrg	*)
7077e9fcaa8aSmrg	  # Preserve sysroot, but never include relative directories
7078e9fcaa8aSmrg	  case $dir in
7079e9fcaa8aSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
7080e9fcaa8aSmrg	    *) func_append deplibs " -L$dir" ;;
7081e9fcaa8aSmrg	  esac
7082e9fcaa8aSmrg	  func_append lib_search_path " $dir"
708388de56ccSmrg	  ;;
708488de56ccSmrg	esac
708588de56ccSmrg	case $host in
708688de56ccSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7087e9fcaa8aSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
708888de56ccSmrg	  case :$dllsearchpath: in
708988de56ccSmrg	  *":$dir:"*) ;;
709088de56ccSmrg	  ::) dllsearchpath=$dir;;
7091e9fcaa8aSmrg	  *) func_append dllsearchpath ":$dir";;
709288de56ccSmrg	  esac
709388de56ccSmrg	  case :$dllsearchpath: in
709488de56ccSmrg	  *":$testbindir:"*) ;;
709588de56ccSmrg	  ::) dllsearchpath=$testbindir;;
7096e9fcaa8aSmrg	  *) func_append dllsearchpath ":$testbindir";;
709788de56ccSmrg	  esac
709888de56ccSmrg	  ;;
709988de56ccSmrg	esac
710088de56ccSmrg	continue
710188de56ccSmrg	;;
71022e9c7c8cSmrg
710388de56ccSmrg      -l*)
7104862bcd1aSmrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
710588de56ccSmrg	  case $host in
7106e9fcaa8aSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
710788de56ccSmrg	    # These systems don't actually have a C or math library (as such)
710888de56ccSmrg	    continue
710988de56ccSmrg	    ;;
711088de56ccSmrg	  *-*-os2*)
711188de56ccSmrg	    # These systems don't actually have a C library (as such)
7112862bcd1aSmrg	    test X-lc = "X$arg" && continue
711388de56ccSmrg	    ;;
7114862bcd1aSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
711588de56ccSmrg	    # Do not include libc due to us having libc/libc_r.
7116862bcd1aSmrg	    test X-lc = "X$arg" && continue
711788de56ccSmrg	    ;;
711888de56ccSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
711988de56ccSmrg	    # Rhapsody C and math libraries are in the System framework
7120e9fcaa8aSmrg	    func_append deplibs " System.ltframework"
712188de56ccSmrg	    continue
712288de56ccSmrg	    ;;
712388de56ccSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
712488de56ccSmrg	    # Causes problems with __ctype
7125862bcd1aSmrg	    test X-lc = "X$arg" && continue
712688de56ccSmrg	    ;;
712788de56ccSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
712888de56ccSmrg	    # Compiler inserts libc in the correct place for threads to work
7129862bcd1aSmrg	    test X-lc = "X$arg" && continue
713088de56ccSmrg	    ;;
713188de56ccSmrg	  esac
7132862bcd1aSmrg	elif test X-lc_r = "X$arg"; then
713388de56ccSmrg	 case $host in
7134862bcd1aSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
713588de56ccSmrg	   # Do not include libc_r directly, use -pthread flag.
713688de56ccSmrg	   continue
713788de56ccSmrg	   ;;
713888de56ccSmrg	 esac
713988de56ccSmrg	fi
7140e9fcaa8aSmrg	func_append deplibs " $arg"
714188de56ccSmrg	continue
714288de56ccSmrg	;;
71432e9c7c8cSmrg
7144862bcd1aSmrg      -mllvm)
7145862bcd1aSmrg	prev=mllvm
7146862bcd1aSmrg	continue
7147862bcd1aSmrg	;;
7148862bcd1aSmrg
714988de56ccSmrg      -module)
715088de56ccSmrg	module=yes
715188de56ccSmrg	continue
715288de56ccSmrg	;;
71532e9c7c8cSmrg
715488de56ccSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
715588de56ccSmrg      # classes, name mangling, and exception handling.
715688de56ccSmrg      # Darwin uses the -arch flag to determine output architecture.
7157e9fcaa8aSmrg      -model|-arch|-isysroot|--sysroot)
7158e9fcaa8aSmrg	func_append compiler_flags " $arg"
715988de56ccSmrg	func_append compile_command " $arg"
716088de56ccSmrg	func_append finalize_command " $arg"
716188de56ccSmrg	prev=xcompiler
716288de56ccSmrg	continue
716388de56ccSmrg	;;
71642e9c7c8cSmrg
7165eb411b4bSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7166eb411b4bSmrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7167e9fcaa8aSmrg	func_append compiler_flags " $arg"
716888de56ccSmrg	func_append compile_command " $arg"
716988de56ccSmrg	func_append finalize_command " $arg"
717088de56ccSmrg	case "$new_inherited_linker_flags " in
717188de56ccSmrg	    *" $arg "*) ;;
7172e9fcaa8aSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
717388de56ccSmrg	esac
717488de56ccSmrg	continue
717588de56ccSmrg	;;
71762e9c7c8cSmrg
717788de56ccSmrg      -multi_module)
7178862bcd1aSmrg	single_module=$wl-multi_module
717988de56ccSmrg	continue
718088de56ccSmrg	;;
71812e9c7c8cSmrg
718288de56ccSmrg      -no-fast-install)
718388de56ccSmrg	fast_install=no
718488de56ccSmrg	continue
718588de56ccSmrg	;;
71862e9c7c8cSmrg
718788de56ccSmrg      -no-install)
718888de56ccSmrg	case $host in
718988de56ccSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
719088de56ccSmrg	  # The PATH hackery in wrapper scripts is required on Windows
719188de56ccSmrg	  # and Darwin in order for the loader to find any dlls it needs.
7192862bcd1aSmrg	  func_warning "'-no-install' is ignored for $host"
7193862bcd1aSmrg	  func_warning "assuming '-no-fast-install' instead"
719488de56ccSmrg	  fast_install=no
719588de56ccSmrg	  ;;
719688de56ccSmrg	*) no_install=yes ;;
719788de56ccSmrg	esac
719888de56ccSmrg	continue
719988de56ccSmrg	;;
72002e9c7c8cSmrg
720188de56ccSmrg      -no-undefined)
720288de56ccSmrg	allow_undefined=no
720388de56ccSmrg	continue
720488de56ccSmrg	;;
72052e9c7c8cSmrg
720688de56ccSmrg      -objectlist)
720788de56ccSmrg	prev=objectlist
720888de56ccSmrg	continue
720988de56ccSmrg	;;
72102e9c7c8cSmrg
7211862bcd1aSmrg      -os2dllname)
7212862bcd1aSmrg	prev=os2dllname
7213862bcd1aSmrg	continue
7214862bcd1aSmrg	;;
7215862bcd1aSmrg
721688de56ccSmrg      -o) prev=output ;;
72172e9c7c8cSmrg
721888de56ccSmrg      -precious-files-regex)
721988de56ccSmrg	prev=precious_regex
722088de56ccSmrg	continue
722188de56ccSmrg	;;
72222e9c7c8cSmrg
722388de56ccSmrg      -release)
722488de56ccSmrg	prev=release
722588de56ccSmrg	continue
722688de56ccSmrg	;;
72272e9c7c8cSmrg
722888de56ccSmrg      -rpath)
722988de56ccSmrg	prev=rpath
723088de56ccSmrg	continue
723188de56ccSmrg	;;
72322e9c7c8cSmrg
723388de56ccSmrg      -R)
723488de56ccSmrg	prev=xrpath
723588de56ccSmrg	continue
723688de56ccSmrg	;;
72372e9c7c8cSmrg
723888de56ccSmrg      -R*)
723988de56ccSmrg	func_stripname '-R' '' "$arg"
724088de56ccSmrg	dir=$func_stripname_result
724188de56ccSmrg	# We need an absolute path.
724288de56ccSmrg	case $dir in
724388de56ccSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
7244e9fcaa8aSmrg	=*)
7245e9fcaa8aSmrg	  func_stripname '=' '' "$dir"
7246e9fcaa8aSmrg	  dir=$lt_sysroot$func_stripname_result
7247e9fcaa8aSmrg	  ;;
724888de56ccSmrg	*)
724988de56ccSmrg	  func_fatal_error "only absolute run-paths are allowed"
725088de56ccSmrg	  ;;
725188de56ccSmrg	esac
725288de56ccSmrg	case "$xrpath " in
725388de56ccSmrg	*" $dir "*) ;;
7254e9fcaa8aSmrg	*) func_append xrpath " $dir" ;;
725588de56ccSmrg	esac
725688de56ccSmrg	continue
725788de56ccSmrg	;;
72582e9c7c8cSmrg
725988de56ccSmrg      -shared)
726088de56ccSmrg	# The effects of -shared are defined in a previous loop.
726188de56ccSmrg	continue
726288de56ccSmrg	;;
72632e9c7c8cSmrg
726488de56ccSmrg      -shrext)
726588de56ccSmrg	prev=shrext
726688de56ccSmrg	continue
726788de56ccSmrg	;;
72682e9c7c8cSmrg
726988de56ccSmrg      -static | -static-libtool-libs)
727088de56ccSmrg	# The effects of -static are defined in a previous loop.
727188de56ccSmrg	# We used to do the same as -all-static on platforms that
727288de56ccSmrg	# didn't have a PIC flag, but the assumption that the effects
727388de56ccSmrg	# would be equivalent was wrong.  It would break on at least
727488de56ccSmrg	# Digital Unix and AIX.
727588de56ccSmrg	continue
727688de56ccSmrg	;;
72772e9c7c8cSmrg
727888de56ccSmrg      -thread-safe)
727988de56ccSmrg	thread_safe=yes
728088de56ccSmrg	continue
728188de56ccSmrg	;;
72822e9c7c8cSmrg
728388de56ccSmrg      -version-info)
728488de56ccSmrg	prev=vinfo
728588de56ccSmrg	continue
728688de56ccSmrg	;;
72872e9c7c8cSmrg
728888de56ccSmrg      -version-number)
728988de56ccSmrg	prev=vinfo
729088de56ccSmrg	vinfo_number=yes
729188de56ccSmrg	continue
729288de56ccSmrg	;;
72932e9c7c8cSmrg
729488de56ccSmrg      -weak)
729588de56ccSmrg        prev=weak
729688de56ccSmrg	continue
729788de56ccSmrg	;;
72981ab64890Smrg
729988de56ccSmrg      -Wc,*)
730088de56ccSmrg	func_stripname '-Wc,' '' "$arg"
730188de56ccSmrg	args=$func_stripname_result
730288de56ccSmrg	arg=
7303862bcd1aSmrg	save_ifs=$IFS; IFS=,
730488de56ccSmrg	for flag in $args; do
7305862bcd1aSmrg	  IFS=$save_ifs
730688de56ccSmrg          func_quote_for_eval "$flag"
7307e9fcaa8aSmrg	  func_append arg " $func_quote_for_eval_result"
7308e9fcaa8aSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
730988de56ccSmrg	done
7310862bcd1aSmrg	IFS=$save_ifs
731188de56ccSmrg	func_stripname ' ' '' "$arg"
731288de56ccSmrg	arg=$func_stripname_result
731388de56ccSmrg	;;
7314b4ee4795Smrg
731588de56ccSmrg      -Wl,*)
731688de56ccSmrg	func_stripname '-Wl,' '' "$arg"
731788de56ccSmrg	args=$func_stripname_result
731888de56ccSmrg	arg=
7319862bcd1aSmrg	save_ifs=$IFS; IFS=,
732088de56ccSmrg	for flag in $args; do
7321862bcd1aSmrg	  IFS=$save_ifs
732288de56ccSmrg          func_quote_for_eval "$flag"
7323e9fcaa8aSmrg	  func_append arg " $wl$func_quote_for_eval_result"
7324e9fcaa8aSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
7325e9fcaa8aSmrg	  func_append linker_flags " $func_quote_for_eval_result"
732688de56ccSmrg	done
7327862bcd1aSmrg	IFS=$save_ifs
732888de56ccSmrg	func_stripname ' ' '' "$arg"
732988de56ccSmrg	arg=$func_stripname_result
733088de56ccSmrg	;;
7331b4ee4795Smrg
733288de56ccSmrg      -Xcompiler)
733388de56ccSmrg	prev=xcompiler
733488de56ccSmrg	continue
733588de56ccSmrg	;;
7336b4ee4795Smrg
733788de56ccSmrg      -Xlinker)
733888de56ccSmrg	prev=xlinker
733988de56ccSmrg	continue
734088de56ccSmrg	;;
7341b4ee4795Smrg
734288de56ccSmrg      -XCClinker)
734388de56ccSmrg	prev=xcclinker
734488de56ccSmrg	continue
734588de56ccSmrg	;;
7346b4ee4795Smrg
734788de56ccSmrg      # -msg_* for osf cc
734888de56ccSmrg      -msg_*)
734988de56ccSmrg	func_quote_for_eval "$arg"
7350862bcd1aSmrg	arg=$func_quote_for_eval_result
735188de56ccSmrg	;;
7352b4ee4795Smrg
7353e9fcaa8aSmrg      # Flags to be passed through unchanged, with rationale:
7354e9fcaa8aSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
7355e9fcaa8aSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
7356e9fcaa8aSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7357e9fcaa8aSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
7358e9fcaa8aSmrg      # -q*                  compiler args for the IBM compiler
7359e9fcaa8aSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7360e9fcaa8aSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
7361e9fcaa8aSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
7362862bcd1aSmrg      # -fstack-protector*   stack protector flags for GCC
7363e9fcaa8aSmrg      # @file                GCC response files
7364e9fcaa8aSmrg      # -tp=*                Portland pgcc target processor selection
7365e9fcaa8aSmrg      # --sysroot=*          for sysroot support
7366862bcd1aSmrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
73673233502eSmrg      # -specs=*             GCC specs files
7368862bcd1aSmrg      # -stdlib=*            select c++ std lib with clang
73699c019ec5Smaya      # -fsanitize=*         Clang/GCC memory and address sanitizer
7370d4a3aaf4Smrg      # -fuse-ld=*           Linker select flags for GCC
7371d4a3aaf4Smrg      # -static-*            direct GCC to link specific libraries statically
7372d4a3aaf4Smrg      # -fcilkplus           Cilk Plus language extension features for C/C++
737388de56ccSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7374e9fcaa8aSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
73753233502eSmrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
7376d4a3aaf4Smrg      -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus)
737788de56ccSmrg        func_quote_for_eval "$arg"
7378862bcd1aSmrg	arg=$func_quote_for_eval_result
737988de56ccSmrg        func_append compile_command " $arg"
738088de56ccSmrg        func_append finalize_command " $arg"
7381e9fcaa8aSmrg        func_append compiler_flags " $arg"
738288de56ccSmrg        continue
738388de56ccSmrg        ;;
7384b4ee4795Smrg
7385862bcd1aSmrg      -Z*)
7386862bcd1aSmrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
7387862bcd1aSmrg          # OS/2 uses -Zxxx to specify OS/2-specific options
7388862bcd1aSmrg	  compiler_flags="$compiler_flags $arg"
7389862bcd1aSmrg	  func_append compile_command " $arg"
7390862bcd1aSmrg	  func_append finalize_command " $arg"
7391862bcd1aSmrg	  case $arg in
7392862bcd1aSmrg	  -Zlinker | -Zstack)
7393862bcd1aSmrg	    prev=xcompiler
7394862bcd1aSmrg	    ;;
7395862bcd1aSmrg	  esac
7396862bcd1aSmrg	  continue
7397862bcd1aSmrg        else
7398862bcd1aSmrg	  # Otherwise treat like 'Some other compiler flag' below
7399862bcd1aSmrg	  func_quote_for_eval "$arg"
7400862bcd1aSmrg	  arg=$func_quote_for_eval_result
7401862bcd1aSmrg        fi
7402862bcd1aSmrg	;;
7403862bcd1aSmrg
740488de56ccSmrg      # Some other compiler flag.
740588de56ccSmrg      -* | +*)
740688de56ccSmrg        func_quote_for_eval "$arg"
7407862bcd1aSmrg	arg=$func_quote_for_eval_result
740888de56ccSmrg	;;
7409b4ee4795Smrg
741088de56ccSmrg      *.$objext)
741188de56ccSmrg	# A standard object.
7412e9fcaa8aSmrg	func_append objs " $arg"
741388de56ccSmrg	;;
7414b4ee4795Smrg
741588de56ccSmrg      *.lo)
741688de56ccSmrg	# A libtool-controlled object.
7417b4ee4795Smrg
741888de56ccSmrg	# Check to see that this really is a libtool object.
741988de56ccSmrg	if func_lalib_unsafe_p "$arg"; then
742088de56ccSmrg	  pic_object=
742188de56ccSmrg	  non_pic_object=
7422b4ee4795Smrg
742388de56ccSmrg	  # Read the .lo file
742488de56ccSmrg	  func_source "$arg"
7425b4ee4795Smrg
742688de56ccSmrg	  if test -z "$pic_object" ||
742788de56ccSmrg	     test -z "$non_pic_object" ||
7428862bcd1aSmrg	     test none = "$pic_object" &&
7429862bcd1aSmrg	     test none = "$non_pic_object"; then
7430862bcd1aSmrg	    func_fatal_error "cannot find name of object for '$arg'"
743188de56ccSmrg	  fi
7432b4ee4795Smrg
743388de56ccSmrg	  # Extract subdirectory from the argument.
743488de56ccSmrg	  func_dirname "$arg" "/" ""
7435862bcd1aSmrg	  xdir=$func_dirname_result
7436b4ee4795Smrg
7437862bcd1aSmrg	  test none = "$pic_object" || {
743888de56ccSmrg	    # Prepend the subdirectory the object is found in.
7439862bcd1aSmrg	    pic_object=$xdir$pic_object
7440b4ee4795Smrg
7441862bcd1aSmrg	    if test dlfiles = "$prev"; then
7442862bcd1aSmrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7443e9fcaa8aSmrg		func_append dlfiles " $pic_object"
744488de56ccSmrg		prev=
744588de56ccSmrg		continue
744688de56ccSmrg	      else
744788de56ccSmrg		# If libtool objects are unsupported, then we need to preload.
744888de56ccSmrg		prev=dlprefiles
744988de56ccSmrg	      fi
745088de56ccSmrg	    fi
7451b4ee4795Smrg
745288de56ccSmrg	    # CHECK ME:  I think I busted this.  -Ossama
7453862bcd1aSmrg	    if test dlprefiles = "$prev"; then
745488de56ccSmrg	      # Preload the old-style object.
7455e9fcaa8aSmrg	      func_append dlprefiles " $pic_object"
745688de56ccSmrg	      prev=
745788de56ccSmrg	    fi
74581ab64890Smrg
745988de56ccSmrg	    # A PIC object.
746088de56ccSmrg	    func_append libobjs " $pic_object"
7461862bcd1aSmrg	    arg=$pic_object
7462862bcd1aSmrg	  }
74631ab64890Smrg
746488de56ccSmrg	  # Non-PIC object.
7465862bcd1aSmrg	  if test none != "$non_pic_object"; then
746688de56ccSmrg	    # Prepend the subdirectory the object is found in.
7467862bcd1aSmrg	    non_pic_object=$xdir$non_pic_object
74681ab64890Smrg
746988de56ccSmrg	    # A standard non-PIC object
747088de56ccSmrg	    func_append non_pic_objects " $non_pic_object"
7471862bcd1aSmrg	    if test -z "$pic_object" || test none = "$pic_object"; then
7472862bcd1aSmrg	      arg=$non_pic_object
747388de56ccSmrg	    fi
747488de56ccSmrg	  else
747588de56ccSmrg	    # If the PIC object exists, use it instead.
747688de56ccSmrg	    # $xdir was prepended to $pic_object above.
7477862bcd1aSmrg	    non_pic_object=$pic_object
747888de56ccSmrg	    func_append non_pic_objects " $non_pic_object"
747988de56ccSmrg	  fi
748088de56ccSmrg	else
748188de56ccSmrg	  # Only an error if not doing a dry-run.
748288de56ccSmrg	  if $opt_dry_run; then
748388de56ccSmrg	    # Extract subdirectory from the argument.
748488de56ccSmrg	    func_dirname "$arg" "/" ""
7485862bcd1aSmrg	    xdir=$func_dirname_result
748688de56ccSmrg
748788de56ccSmrg	    func_lo2o "$arg"
748888de56ccSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
748988de56ccSmrg	    non_pic_object=$xdir$func_lo2o_result
749088de56ccSmrg	    func_append libobjs " $pic_object"
749188de56ccSmrg	    func_append non_pic_objects " $non_pic_object"
749288de56ccSmrg	  else
7493862bcd1aSmrg	    func_fatal_error "'$arg' is not a valid libtool object"
749488de56ccSmrg	  fi
749588de56ccSmrg	fi
749688de56ccSmrg	;;
74971ab64890Smrg
749888de56ccSmrg      *.$libext)
749988de56ccSmrg	# An archive.
7500e9fcaa8aSmrg	func_append deplibs " $arg"
7501e9fcaa8aSmrg	func_append old_deplibs " $arg"
750288de56ccSmrg	continue
750388de56ccSmrg	;;
750488de56ccSmrg
750588de56ccSmrg      *.la)
750688de56ccSmrg	# A libtool-controlled library.
750788de56ccSmrg
7508e9fcaa8aSmrg	func_resolve_sysroot "$arg"
7509862bcd1aSmrg	if test dlfiles = "$prev"; then
751088de56ccSmrg	  # This library was specified with -dlopen.
7511e9fcaa8aSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
751288de56ccSmrg	  prev=
7513862bcd1aSmrg	elif test dlprefiles = "$prev"; then
751488de56ccSmrg	  # The library was specified with -dlpreopen.
7515e9fcaa8aSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
751688de56ccSmrg	  prev=
751788de56ccSmrg	else
7518e9fcaa8aSmrg	  func_append deplibs " $func_resolve_sysroot_result"
751988de56ccSmrg	fi
752088de56ccSmrg	continue
752188de56ccSmrg	;;
752288de56ccSmrg
752388de56ccSmrg      # Some other compiler argument.
752488de56ccSmrg      *)
752588de56ccSmrg	# Unknown arguments in both finalize_command and compile_command need
752688de56ccSmrg	# to be aesthetically quoted because they are evaled later.
752788de56ccSmrg	func_quote_for_eval "$arg"
7528862bcd1aSmrg	arg=$func_quote_for_eval_result
752988de56ccSmrg	;;
753088de56ccSmrg      esac # arg
753188de56ccSmrg
753288de56ccSmrg      # Now actually substitute the argument into the commands.
753388de56ccSmrg      if test -n "$arg"; then
753488de56ccSmrg	func_append compile_command " $arg"
753588de56ccSmrg	func_append finalize_command " $arg"
753688de56ccSmrg      fi
753788de56ccSmrg    done # argument parsing loop
753888de56ccSmrg
753988de56ccSmrg    test -n "$prev" && \
7540862bcd1aSmrg      func_fatal_help "the '$prevarg' option requires an argument"
754188de56ccSmrg
7542862bcd1aSmrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
754388de56ccSmrg      eval arg=\"$export_dynamic_flag_spec\"
754488de56ccSmrg      func_append compile_command " $arg"
754588de56ccSmrg      func_append finalize_command " $arg"
754688de56ccSmrg    fi
754788de56ccSmrg
754888de56ccSmrg    oldlibs=
754988de56ccSmrg    # calculate the name of the file, without its directory
755088de56ccSmrg    func_basename "$output"
7551862bcd1aSmrg    outputname=$func_basename_result
7552862bcd1aSmrg    libobjs_save=$libobjs
755388de56ccSmrg
755488de56ccSmrg    if test -n "$shlibpath_var"; then
755588de56ccSmrg      # get the directories listed in $shlibpath_var
7556862bcd1aSmrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
755788de56ccSmrg    else
755888de56ccSmrg      shlib_search_path=
755988de56ccSmrg    fi
756088de56ccSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
756188de56ccSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
756288de56ccSmrg
7563862bcd1aSmrg    # Definition is injected by LT_CONFIG during libtool generation.
7564862bcd1aSmrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
7565862bcd1aSmrg
756688de56ccSmrg    func_dirname "$output" "/" ""
7567862bcd1aSmrg    output_objdir=$func_dirname_result$objdir
7568e9fcaa8aSmrg    func_to_tool_file "$output_objdir/"
7569e9fcaa8aSmrg    tool_output_objdir=$func_to_tool_file_result
757088de56ccSmrg    # Create the object directory.
757188de56ccSmrg    func_mkdir_p "$output_objdir"
757288de56ccSmrg
757388de56ccSmrg    # Determine the type of output
757488de56ccSmrg    case $output in
757588de56ccSmrg    "")
757688de56ccSmrg      func_fatal_help "you must specify an output file"
757788de56ccSmrg      ;;
757888de56ccSmrg    *.$libext) linkmode=oldlib ;;
757988de56ccSmrg    *.lo | *.$objext) linkmode=obj ;;
758088de56ccSmrg    *.la) linkmode=lib ;;
758188de56ccSmrg    *) linkmode=prog ;; # Anything else should be a program.
758288de56ccSmrg    esac
758388de56ccSmrg
758488de56ccSmrg    specialdeplibs=
758588de56ccSmrg
758688de56ccSmrg    libs=
758788de56ccSmrg    # Find all interdependent deplibs by searching for libraries
758888de56ccSmrg    # that are linked more than once (e.g. -la -lb -la)
758988de56ccSmrg    for deplib in $deplibs; do
7590862bcd1aSmrg      if $opt_preserve_dup_deps; then
759188de56ccSmrg	case "$libs " in
7592e9fcaa8aSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
759388de56ccSmrg	esac
759488de56ccSmrg      fi
7595e9fcaa8aSmrg      func_append libs " $deplib"
759688de56ccSmrg    done
759788de56ccSmrg
7598862bcd1aSmrg    if test lib = "$linkmode"; then
759988de56ccSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
760088de56ccSmrg
760188de56ccSmrg      # Compute libraries that are listed more than once in $predeps
760288de56ccSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
760388de56ccSmrg      # not to be eliminated).
760488de56ccSmrg      pre_post_deps=
760588de56ccSmrg      if $opt_duplicate_compiler_generated_deps; then
760688de56ccSmrg	for pre_post_dep in $predeps $postdeps; do
760788de56ccSmrg	  case "$pre_post_deps " in
7608e9fcaa8aSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
760988de56ccSmrg	  esac
7610e9fcaa8aSmrg	  func_append pre_post_deps " $pre_post_dep"
761188de56ccSmrg	done
761288de56ccSmrg      fi
761388de56ccSmrg      pre_post_deps=
761488de56ccSmrg    fi
761588de56ccSmrg
761688de56ccSmrg    deplibs=
761788de56ccSmrg    newdependency_libs=
761888de56ccSmrg    newlib_search_path=
761988de56ccSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
762088de56ccSmrg    notinst_deplibs= # not-installed libtool libraries
762188de56ccSmrg    notinst_path= # paths that contain not-installed libtool libraries
762288de56ccSmrg
762388de56ccSmrg    case $linkmode in
762488de56ccSmrg    lib)
762588de56ccSmrg	passes="conv dlpreopen link"
762688de56ccSmrg	for file in $dlfiles $dlprefiles; do
762788de56ccSmrg	  case $file in
762888de56ccSmrg	  *.la) ;;
762988de56ccSmrg	  *)
7630862bcd1aSmrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
763188de56ccSmrg	    ;;
763288de56ccSmrg	  esac
763388de56ccSmrg	done
763488de56ccSmrg	;;
763588de56ccSmrg    prog)
763688de56ccSmrg	compile_deplibs=
763788de56ccSmrg	finalize_deplibs=
7638862bcd1aSmrg	alldeplibs=false
763988de56ccSmrg	newdlfiles=
764088de56ccSmrg	newdlprefiles=
764188de56ccSmrg	passes="conv scan dlopen dlpreopen link"
764288de56ccSmrg	;;
764388de56ccSmrg    *)  passes="conv"
764488de56ccSmrg	;;
764588de56ccSmrg    esac
764688de56ccSmrg
764788de56ccSmrg    for pass in $passes; do
764888de56ccSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
764988de56ccSmrg      # so that -L comes before libs that need it for instance...
7650862bcd1aSmrg      if test lib,link = "$linkmode,$pass"; then
765188de56ccSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
765288de56ccSmrg	##        order, and fix it there properly
765388de56ccSmrg        tmp_deplibs=
765488de56ccSmrg	for deplib in $deplibs; do
765588de56ccSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
765688de56ccSmrg	done
7657862bcd1aSmrg	deplibs=$tmp_deplibs
765888de56ccSmrg      fi
765988de56ccSmrg
7660862bcd1aSmrg      if test lib,link = "$linkmode,$pass" ||
7661862bcd1aSmrg	 test prog,scan = "$linkmode,$pass"; then
7662862bcd1aSmrg	libs=$deplibs
766388de56ccSmrg	deplibs=
766488de56ccSmrg      fi
7665862bcd1aSmrg      if test prog = "$linkmode"; then
766688de56ccSmrg	case $pass in
7667862bcd1aSmrg	dlopen) libs=$dlfiles ;;
7668862bcd1aSmrg	dlpreopen) libs=$dlprefiles ;;
76699c019ec5Smaya	link)
76709c019ec5Smaya	  libs="$deplibs %DEPLIBS%"
76719c019ec5Smaya	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
76729c019ec5Smaya	  ;;
767388de56ccSmrg	esac
767488de56ccSmrg      fi
7675862bcd1aSmrg      if test lib,dlpreopen = "$linkmode,$pass"; then
767688de56ccSmrg	# Collect and forward deplibs of preopened libtool libs
767788de56ccSmrg	for lib in $dlprefiles; do
767888de56ccSmrg	  # Ignore non-libtool-libs
767988de56ccSmrg	  dependency_libs=
7680e9fcaa8aSmrg	  func_resolve_sysroot "$lib"
768188de56ccSmrg	  case $lib in
7682e9fcaa8aSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
768388de56ccSmrg	  esac
768488de56ccSmrg
768588de56ccSmrg	  # Collect preopened libtool deplibs, except any this library
768688de56ccSmrg	  # has declared as weak libs
768788de56ccSmrg	  for deplib in $dependency_libs; do
7688e9fcaa8aSmrg	    func_basename "$deplib"
7689e9fcaa8aSmrg            deplib_base=$func_basename_result
769088de56ccSmrg	    case " $weak_libs " in
769188de56ccSmrg	    *" $deplib_base "*) ;;
7692e9fcaa8aSmrg	    *) func_append deplibs " $deplib" ;;
769388de56ccSmrg	    esac
769488de56ccSmrg	  done
769588de56ccSmrg	done
7696862bcd1aSmrg	libs=$dlprefiles
769788de56ccSmrg      fi
7698862bcd1aSmrg      if test dlopen = "$pass"; then
769988de56ccSmrg	# Collect dlpreopened libraries
7700862bcd1aSmrg	save_deplibs=$deplibs
770188de56ccSmrg	deplibs=
770288de56ccSmrg      fi
770388de56ccSmrg
770488de56ccSmrg      for deplib in $libs; do
770588de56ccSmrg	lib=
7706862bcd1aSmrg	found=false
770788de56ccSmrg	case $deplib in
7708eb411b4bSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7709eb411b4bSmrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7710862bcd1aSmrg	  if test prog,link = "$linkmode,$pass"; then
771188de56ccSmrg	    compile_deplibs="$deplib $compile_deplibs"
771288de56ccSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
771388de56ccSmrg	  else
7714e9fcaa8aSmrg	    func_append compiler_flags " $deplib"
7715862bcd1aSmrg	    if test lib = "$linkmode"; then
771688de56ccSmrg		case "$new_inherited_linker_flags " in
771788de56ccSmrg		    *" $deplib "*) ;;
7718e9fcaa8aSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
771988de56ccSmrg		esac
772088de56ccSmrg	    fi
772188de56ccSmrg	  fi
772288de56ccSmrg	  continue
772388de56ccSmrg	  ;;
772488de56ccSmrg	-l*)
7725862bcd1aSmrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
7726862bcd1aSmrg	    func_warning "'-l' is ignored for archives/objects"
772788de56ccSmrg	    continue
772888de56ccSmrg	  fi
772988de56ccSmrg	  func_stripname '-l' '' "$deplib"
773088de56ccSmrg	  name=$func_stripname_result
7731862bcd1aSmrg	  if test lib = "$linkmode"; then
773288de56ccSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
773388de56ccSmrg	  else
773488de56ccSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
773588de56ccSmrg	  fi
773688de56ccSmrg	  for searchdir in $searchdirs; do
773788de56ccSmrg	    for search_ext in .la $std_shrext .so .a; do
773888de56ccSmrg	      # Search the libtool library
7739862bcd1aSmrg	      lib=$searchdir/lib$name$search_ext
774088de56ccSmrg	      if test -f "$lib"; then
7741862bcd1aSmrg		if test .la = "$search_ext"; then
7742862bcd1aSmrg		  found=:
774388de56ccSmrg		else
7744862bcd1aSmrg		  found=false
774588de56ccSmrg		fi
774688de56ccSmrg		break 2
774788de56ccSmrg	      fi
774888de56ccSmrg	    done
774988de56ccSmrg	  done
7750862bcd1aSmrg	  if $found; then
7751862bcd1aSmrg	    # deplib is a libtool library
775288de56ccSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
775388de56ccSmrg	    # We need to do some special things here, and not later.
7754862bcd1aSmrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
775588de56ccSmrg	      case " $predeps $postdeps " in
775688de56ccSmrg	      *" $deplib "*)
775788de56ccSmrg		if func_lalib_p "$lib"; then
775888de56ccSmrg		  library_names=
775988de56ccSmrg		  old_library=
776088de56ccSmrg		  func_source "$lib"
776188de56ccSmrg		  for l in $old_library $library_names; do
7762862bcd1aSmrg		    ll=$l
776388de56ccSmrg		  done
7764862bcd1aSmrg		  if test "X$ll" = "X$old_library"; then # only static version available
7765862bcd1aSmrg		    found=false
776688de56ccSmrg		    func_dirname "$lib" "" "."
7767862bcd1aSmrg		    ladir=$func_dirname_result
776888de56ccSmrg		    lib=$ladir/$old_library
7769862bcd1aSmrg		    if test prog,link = "$linkmode,$pass"; then
777088de56ccSmrg		      compile_deplibs="$deplib $compile_deplibs"
777188de56ccSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
777288de56ccSmrg		    else
777388de56ccSmrg		      deplibs="$deplib $deplibs"
7774862bcd1aSmrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
777588de56ccSmrg		    fi
777688de56ccSmrg		    continue
777788de56ccSmrg		  fi
777888de56ccSmrg		fi
777988de56ccSmrg		;;
778088de56ccSmrg	      *) ;;
778188de56ccSmrg	      esac
778288de56ccSmrg	    fi
7783862bcd1aSmrg	  else
7784862bcd1aSmrg	    # deplib doesn't seem to be a libtool library
7785862bcd1aSmrg	    if test prog,link = "$linkmode,$pass"; then
7786862bcd1aSmrg	      compile_deplibs="$deplib $compile_deplibs"
7787862bcd1aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
7788862bcd1aSmrg	    else
7789862bcd1aSmrg	      deplibs="$deplib $deplibs"
7790862bcd1aSmrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7791862bcd1aSmrg	    fi
7792862bcd1aSmrg	    continue
779388de56ccSmrg	  fi
779488de56ccSmrg	  ;; # -l
779588de56ccSmrg	*.ltframework)
7796862bcd1aSmrg	  if test prog,link = "$linkmode,$pass"; then
779788de56ccSmrg	    compile_deplibs="$deplib $compile_deplibs"
779888de56ccSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
779988de56ccSmrg	  else
780088de56ccSmrg	    deplibs="$deplib $deplibs"
7801862bcd1aSmrg	    if test lib = "$linkmode"; then
780288de56ccSmrg		case "$new_inherited_linker_flags " in
780388de56ccSmrg		    *" $deplib "*) ;;
7804e9fcaa8aSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
780588de56ccSmrg		esac
780688de56ccSmrg	    fi
780788de56ccSmrg	  fi
780888de56ccSmrg	  continue
780988de56ccSmrg	  ;;
781088de56ccSmrg	-L*)
781188de56ccSmrg	  case $linkmode in
781288de56ccSmrg	  lib)
781388de56ccSmrg	    deplibs="$deplib $deplibs"
7814862bcd1aSmrg	    test conv = "$pass" && continue
781588de56ccSmrg	    newdependency_libs="$deplib $newdependency_libs"
781688de56ccSmrg	    func_stripname '-L' '' "$deplib"
7817e9fcaa8aSmrg	    func_resolve_sysroot "$func_stripname_result"
7818e9fcaa8aSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
781988de56ccSmrg	    ;;
782088de56ccSmrg	  prog)
7821862bcd1aSmrg	    if test conv = "$pass"; then
782288de56ccSmrg	      deplibs="$deplib $deplibs"
782388de56ccSmrg	      continue
782488de56ccSmrg	    fi
7825862bcd1aSmrg	    if test scan = "$pass"; then
782688de56ccSmrg	      deplibs="$deplib $deplibs"
782788de56ccSmrg	    else
782888de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
782988de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
783088de56ccSmrg	    fi
783188de56ccSmrg	    func_stripname '-L' '' "$deplib"
7832e9fcaa8aSmrg	    func_resolve_sysroot "$func_stripname_result"
7833e9fcaa8aSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
783488de56ccSmrg	    ;;
783588de56ccSmrg	  *)
7836862bcd1aSmrg	    func_warning "'-L' is ignored for archives/objects"
783788de56ccSmrg	    ;;
783888de56ccSmrg	  esac # linkmode
783988de56ccSmrg	  continue
784088de56ccSmrg	  ;; # -L
784188de56ccSmrg	-R*)
7842862bcd1aSmrg	  if test link = "$pass"; then
784388de56ccSmrg	    func_stripname '-R' '' "$deplib"
7844e9fcaa8aSmrg	    func_resolve_sysroot "$func_stripname_result"
7845e9fcaa8aSmrg	    dir=$func_resolve_sysroot_result
784688de56ccSmrg	    # Make sure the xrpath contains only unique directories.
784788de56ccSmrg	    case "$xrpath " in
784888de56ccSmrg	    *" $dir "*) ;;
7849e9fcaa8aSmrg	    *) func_append xrpath " $dir" ;;
785088de56ccSmrg	    esac
785188de56ccSmrg	  fi
785288de56ccSmrg	  deplibs="$deplib $deplibs"
785388de56ccSmrg	  continue
785488de56ccSmrg	  ;;
7855e9fcaa8aSmrg	*.la)
7856e9fcaa8aSmrg	  func_resolve_sysroot "$deplib"
7857e9fcaa8aSmrg	  lib=$func_resolve_sysroot_result
7858e9fcaa8aSmrg	  ;;
785988de56ccSmrg	*.$libext)
7860862bcd1aSmrg	  if test conv = "$pass"; then
786188de56ccSmrg	    deplibs="$deplib $deplibs"
786288de56ccSmrg	    continue
786388de56ccSmrg	  fi
786488de56ccSmrg	  case $linkmode in
786588de56ccSmrg	  lib)
786688de56ccSmrg	    # Linking convenience modules into shared libraries is allowed,
786788de56ccSmrg	    # but linking other static libraries is non-portable.
786888de56ccSmrg	    case " $dlpreconveniencelibs " in
786988de56ccSmrg	    *" $deplib "*) ;;
787088de56ccSmrg	    *)
7871862bcd1aSmrg	      valid_a_lib=false
787288de56ccSmrg	      case $deplibs_check_method in
787388de56ccSmrg		match_pattern*)
787488de56ccSmrg		  set dummy $deplibs_check_method; shift
787588de56ccSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7876e9fcaa8aSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
787788de56ccSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
7878862bcd1aSmrg		    valid_a_lib=:
787988de56ccSmrg		  fi
788088de56ccSmrg		;;
788188de56ccSmrg		pass_all)
7882862bcd1aSmrg		  valid_a_lib=:
788388de56ccSmrg		;;
788488de56ccSmrg	      esac
7885862bcd1aSmrg	      if $valid_a_lib; then
7886862bcd1aSmrg		echo
7887862bcd1aSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
7888862bcd1aSmrg		$ECHO "*** static library $deplib is not portable!"
7889862bcd1aSmrg		deplibs="$deplib $deplibs"
7890862bcd1aSmrg	      else
7891e9fcaa8aSmrg		echo
789288de56ccSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
7893e9fcaa8aSmrg		echo "*** I have the capability to make that library automatically link in when"
7894e9fcaa8aSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7895e9fcaa8aSmrg		echo "*** shared version of the library, which you do not appear to have"
7896e9fcaa8aSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
7897e9fcaa8aSmrg		echo "*** that it is just a static archive that I should not use here."
789888de56ccSmrg	      fi
789988de56ccSmrg	      ;;
790088de56ccSmrg	    esac
790188de56ccSmrg	    continue
790288de56ccSmrg	    ;;
790388de56ccSmrg	  prog)
7904862bcd1aSmrg	    if test link != "$pass"; then
790588de56ccSmrg	      deplibs="$deplib $deplibs"
790688de56ccSmrg	    else
790788de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
790888de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
790988de56ccSmrg	    fi
791088de56ccSmrg	    continue
791188de56ccSmrg	    ;;
791288de56ccSmrg	  esac # linkmode
791388de56ccSmrg	  ;; # *.$libext
791488de56ccSmrg	*.lo | *.$objext)
7915862bcd1aSmrg	  if test conv = "$pass"; then
791688de56ccSmrg	    deplibs="$deplib $deplibs"
7917862bcd1aSmrg	  elif test prog = "$linkmode"; then
7918862bcd1aSmrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
791988de56ccSmrg	      # If there is no dlopen support or we're linking statically,
792088de56ccSmrg	      # we need to preload.
7921e9fcaa8aSmrg	      func_append newdlprefiles " $deplib"
792288de56ccSmrg	      compile_deplibs="$deplib $compile_deplibs"
792388de56ccSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
792488de56ccSmrg	    else
7925e9fcaa8aSmrg	      func_append newdlfiles " $deplib"
792688de56ccSmrg	    fi
792788de56ccSmrg	  fi
792888de56ccSmrg	  continue
792988de56ccSmrg	  ;;
793088de56ccSmrg	%DEPLIBS%)
7931862bcd1aSmrg	  alldeplibs=:
793288de56ccSmrg	  continue
793388de56ccSmrg	  ;;
793488de56ccSmrg	esac # case $deplib
793588de56ccSmrg
7936862bcd1aSmrg	$found || test -f "$lib" \
7937862bcd1aSmrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
793888de56ccSmrg
793988de56ccSmrg	# Check to see that this really is a libtool archive.
794088de56ccSmrg	func_lalib_unsafe_p "$lib" \
7941862bcd1aSmrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
794288de56ccSmrg
794388de56ccSmrg	func_dirname "$lib" "" "."
7944862bcd1aSmrg	ladir=$func_dirname_result
794588de56ccSmrg
794688de56ccSmrg	dlname=
794788de56ccSmrg	dlopen=
794888de56ccSmrg	dlpreopen=
794988de56ccSmrg	libdir=
795088de56ccSmrg	library_names=
795188de56ccSmrg	old_library=
795288de56ccSmrg	inherited_linker_flags=
795388de56ccSmrg	# If the library was installed with an old release of libtool,
795488de56ccSmrg	# it will not redefine variables installed, or shouldnotlink
795588de56ccSmrg	installed=yes
795688de56ccSmrg	shouldnotlink=no
795788de56ccSmrg	avoidtemprpath=
795888de56ccSmrg
795988de56ccSmrg
796088de56ccSmrg	# Read the .la file
796188de56ccSmrg	func_source "$lib"
796288de56ccSmrg
796388de56ccSmrg	# Convert "-framework foo" to "foo.ltframework"
796488de56ccSmrg	if test -n "$inherited_linker_flags"; then
7965e9fcaa8aSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
796688de56ccSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
796788de56ccSmrg	    case " $new_inherited_linker_flags " in
796888de56ccSmrg	      *" $tmp_inherited_linker_flag "*) ;;
7969e9fcaa8aSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
797088de56ccSmrg	    esac
797188de56ccSmrg	  done
797288de56ccSmrg	fi
7973e9fcaa8aSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7974862bcd1aSmrg	if test lib,link = "$linkmode,$pass" ||
7975862bcd1aSmrg	   test prog,scan = "$linkmode,$pass" ||
7976862bcd1aSmrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7977e9fcaa8aSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
7978e9fcaa8aSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
797988de56ccSmrg	fi
798088de56ccSmrg
7981862bcd1aSmrg	if test conv = "$pass"; then
798288de56ccSmrg	  # Only check for convenience libraries
798388de56ccSmrg	  deplibs="$lib $deplibs"
798488de56ccSmrg	  if test -z "$libdir"; then
798588de56ccSmrg	    if test -z "$old_library"; then
7986862bcd1aSmrg	      func_fatal_error "cannot find name of link library for '$lib'"
798788de56ccSmrg	    fi
798888de56ccSmrg	    # It is a libtool convenience library, so add in its objects.
7989e9fcaa8aSmrg	    func_append convenience " $ladir/$objdir/$old_library"
7990e9fcaa8aSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
79919c019ec5Smaya	    tmp_libs=
79929c019ec5Smaya	    for deplib in $dependency_libs; do
79939c019ec5Smaya	      deplibs="$deplib $deplibs"
79949c019ec5Smaya	      if $opt_preserve_dup_deps; then
79959c019ec5Smaya		case "$tmp_libs " in
79969c019ec5Smaya		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
79979c019ec5Smaya		esac
79989c019ec5Smaya	      fi
79999c019ec5Smaya	      func_append tmp_libs " $deplib"
80009c019ec5Smaya	    done
8001862bcd1aSmrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
8002862bcd1aSmrg	    func_fatal_error "'$lib' is not a convenience library"
800388de56ccSmrg	  fi
800488de56ccSmrg	  continue
800588de56ccSmrg	fi # $pass = conv
800688de56ccSmrg
800788de56ccSmrg
800888de56ccSmrg	# Get the name of the library we link against.
800988de56ccSmrg	linklib=
8010e9fcaa8aSmrg	if test -n "$old_library" &&
8011862bcd1aSmrg	   { test yes = "$prefer_static_libs" ||
8012862bcd1aSmrg	     test built,no = "$prefer_static_libs,$installed"; }; then
8013e9fcaa8aSmrg	  linklib=$old_library
8014e9fcaa8aSmrg	else
8015e9fcaa8aSmrg	  for l in $old_library $library_names; do
8016862bcd1aSmrg	    linklib=$l
8017e9fcaa8aSmrg	  done
8018e9fcaa8aSmrg	fi
801988de56ccSmrg	if test -z "$linklib"; then
8020862bcd1aSmrg	  func_fatal_error "cannot find name of link library for '$lib'"
802188de56ccSmrg	fi
802288de56ccSmrg
802388de56ccSmrg	# This library was specified with -dlopen.
8024862bcd1aSmrg	if test dlopen = "$pass"; then
8025862bcd1aSmrg	  test -z "$libdir" \
8026862bcd1aSmrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
802788de56ccSmrg	  if test -z "$dlname" ||
8028862bcd1aSmrg	     test yes != "$dlopen_support" ||
8029862bcd1aSmrg	     test no = "$build_libtool_libs"
8030862bcd1aSmrg	  then
803188de56ccSmrg	    # If there is no dlname, no dlopen support or we're linking
803288de56ccSmrg	    # statically, we need to preload.  We also need to preload any
803388de56ccSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
803488de56ccSmrg	    # bomb out in the load deplibs phase.
8035e9fcaa8aSmrg	    func_append dlprefiles " $lib $dependency_libs"
803688de56ccSmrg	  else
8037e9fcaa8aSmrg	    func_append newdlfiles " $lib"
803888de56ccSmrg	  fi
803988de56ccSmrg	  continue
804088de56ccSmrg	fi # $pass = dlopen
804188de56ccSmrg
804288de56ccSmrg	# We need an absolute path.
804388de56ccSmrg	case $ladir in
8044862bcd1aSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
804588de56ccSmrg	*)
804688de56ccSmrg	  abs_ladir=`cd "$ladir" && pwd`
804788de56ccSmrg	  if test -z "$abs_ladir"; then
8048862bcd1aSmrg	    func_warning "cannot determine absolute directory name of '$ladir'"
804988de56ccSmrg	    func_warning "passing it literally to the linker, although it might fail"
8050862bcd1aSmrg	    abs_ladir=$ladir
805188de56ccSmrg	  fi
805288de56ccSmrg	  ;;
805388de56ccSmrg	esac
805488de56ccSmrg	func_basename "$lib"
8055862bcd1aSmrg	laname=$func_basename_result
805688de56ccSmrg
805788de56ccSmrg	# Find the relevant object directory and library name.
8058862bcd1aSmrg	if test yes = "$installed"; then
8059e9fcaa8aSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
8060862bcd1aSmrg	    func_warning "library '$lib' was moved."
8061862bcd1aSmrg	    dir=$ladir
8062862bcd1aSmrg	    absdir=$abs_ladir
8063862bcd1aSmrg	    libdir=$abs_ladir
806488de56ccSmrg	  else
8065862bcd1aSmrg	    dir=$lt_sysroot$libdir
8066862bcd1aSmrg	    absdir=$lt_sysroot$libdir
806788de56ccSmrg	  fi
8068862bcd1aSmrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
806988de56ccSmrg	else
807088de56ccSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
8071862bcd1aSmrg	    dir=$ladir
8072862bcd1aSmrg	    absdir=$abs_ladir
807388de56ccSmrg	    # Remove this search path later
8074e9fcaa8aSmrg	    func_append notinst_path " $abs_ladir"
807588de56ccSmrg	  else
8076862bcd1aSmrg	    dir=$ladir/$objdir
8077862bcd1aSmrg	    absdir=$abs_ladir/$objdir
807888de56ccSmrg	    # Remove this search path later
8079e9fcaa8aSmrg	    func_append notinst_path " $abs_ladir"
808088de56ccSmrg	  fi
808188de56ccSmrg	fi # $installed = yes
808288de56ccSmrg	func_stripname 'lib' '.la' "$laname"
808388de56ccSmrg	name=$func_stripname_result
808488de56ccSmrg
808588de56ccSmrg	# This library was specified with -dlpreopen.
8086862bcd1aSmrg	if test dlpreopen = "$pass"; then
8087862bcd1aSmrg	  if test -z "$libdir" && test prog = "$linkmode"; then
8088862bcd1aSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
808988de56ccSmrg	  fi
8090862bcd1aSmrg	  case $host in
8091e9fcaa8aSmrg	    # special handling for platforms with PE-DLLs.
8092e9fcaa8aSmrg	    *cygwin* | *mingw* | *cegcc* )
8093e9fcaa8aSmrg	      # Linker will automatically link against shared library if both
8094e9fcaa8aSmrg	      # static and shared are present.  Therefore, ensure we extract
8095e9fcaa8aSmrg	      # symbols from the import library if a shared library is present
8096e9fcaa8aSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
8097e9fcaa8aSmrg	      # this by putting the import library name into $newdlprefiles.
8098e9fcaa8aSmrg	      # We recover the dlopen module name by 'saving' the la file
8099e9fcaa8aSmrg	      # name in a special purpose variable, and (later) extracting the
8100e9fcaa8aSmrg	      # dlname from the la file.
8101e9fcaa8aSmrg	      if test -n "$dlname"; then
8102e9fcaa8aSmrg	        func_tr_sh "$dir/$linklib"
8103e9fcaa8aSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8104e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$linklib"
8105e9fcaa8aSmrg	      else
8106e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$old_library"
8107e9fcaa8aSmrg	        # Keep a list of preopened convenience libraries to check
8108e9fcaa8aSmrg	        # that they are being used correctly in the link pass.
8109e9fcaa8aSmrg	        test -z "$libdir" && \
8110e9fcaa8aSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8111e9fcaa8aSmrg	      fi
8112e9fcaa8aSmrg	    ;;
8113e9fcaa8aSmrg	    * )
8114e9fcaa8aSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
8115e9fcaa8aSmrg	      # are required to link).
8116e9fcaa8aSmrg	      if test -n "$old_library"; then
8117e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$old_library"
8118e9fcaa8aSmrg	        # Keep a list of preopened convenience libraries to check
8119e9fcaa8aSmrg	        # that they are being used correctly in the link pass.
8120e9fcaa8aSmrg	        test -z "$libdir" && \
8121e9fcaa8aSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8122e9fcaa8aSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
8123e9fcaa8aSmrg	      elif test -n "$dlname"; then
8124e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$dlname"
8125e9fcaa8aSmrg	      else
8126e9fcaa8aSmrg	        func_append newdlprefiles " $dir/$linklib"
8127e9fcaa8aSmrg	      fi
8128e9fcaa8aSmrg	    ;;
8129e9fcaa8aSmrg	  esac
813088de56ccSmrg	fi # $pass = dlpreopen
813188de56ccSmrg
813288de56ccSmrg	if test -z "$libdir"; then
813388de56ccSmrg	  # Link the convenience library
8134862bcd1aSmrg	  if test lib = "$linkmode"; then
813588de56ccSmrg	    deplibs="$dir/$old_library $deplibs"
8136862bcd1aSmrg	  elif test prog,link = "$linkmode,$pass"; then
813788de56ccSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
813888de56ccSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
813988de56ccSmrg	  else
814088de56ccSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
814188de56ccSmrg	  fi
814288de56ccSmrg	  continue
814388de56ccSmrg	fi
814488de56ccSmrg
814588de56ccSmrg
8146862bcd1aSmrg	if test prog = "$linkmode" && test link != "$pass"; then
8147e9fcaa8aSmrg	  func_append newlib_search_path " $ladir"
814888de56ccSmrg	  deplibs="$lib $deplibs"
814988de56ccSmrg
8150862bcd1aSmrg	  linkalldeplibs=false
8151862bcd1aSmrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
8152862bcd1aSmrg	     test no = "$build_libtool_libs"; then
8153862bcd1aSmrg	    linkalldeplibs=:
815488de56ccSmrg	  fi
815588de56ccSmrg
815688de56ccSmrg	  tmp_libs=
815788de56ccSmrg	  for deplib in $dependency_libs; do
815888de56ccSmrg	    case $deplib in
815988de56ccSmrg	    -L*) func_stripname '-L' '' "$deplib"
8160e9fcaa8aSmrg	         func_resolve_sysroot "$func_stripname_result"
8161e9fcaa8aSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
816288de56ccSmrg		 ;;
816388de56ccSmrg	    esac
816488de56ccSmrg	    # Need to link against all dependency_libs?
8165862bcd1aSmrg	    if $linkalldeplibs; then
816688de56ccSmrg	      deplibs="$deplib $deplibs"
816788de56ccSmrg	    else
816888de56ccSmrg	      # Need to hardcode shared library paths
816988de56ccSmrg	      # or/and link against static libraries
817088de56ccSmrg	      newdependency_libs="$deplib $newdependency_libs"
817188de56ccSmrg	    fi
8172862bcd1aSmrg	    if $opt_preserve_dup_deps; then
817388de56ccSmrg	      case "$tmp_libs " in
8174e9fcaa8aSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
817588de56ccSmrg	      esac
817688de56ccSmrg	    fi
8177e9fcaa8aSmrg	    func_append tmp_libs " $deplib"
817888de56ccSmrg	  done # for deplib
817988de56ccSmrg	  continue
818088de56ccSmrg	fi # $linkmode = prog...
818188de56ccSmrg
8182862bcd1aSmrg	if test prog,link = "$linkmode,$pass"; then
818388de56ccSmrg	  if test -n "$library_names" &&
8184862bcd1aSmrg	     { { test no = "$prefer_static_libs" ||
8185862bcd1aSmrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
818688de56ccSmrg	       test -z "$old_library"; }; then
818788de56ccSmrg	    # We need to hardcode the library path
8188862bcd1aSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
818988de56ccSmrg	      # Make sure the rpath contains only unique directories.
8190862bcd1aSmrg	      case $temp_rpath: in
819188de56ccSmrg	      *"$absdir:"*) ;;
8192e9fcaa8aSmrg	      *) func_append temp_rpath "$absdir:" ;;
819388de56ccSmrg	      esac
819488de56ccSmrg	    fi
819588de56ccSmrg
819688de56ccSmrg	    # Hardcode the library path.
819788de56ccSmrg	    # Skip directories that are in the system default run-time
819888de56ccSmrg	    # search path.
819988de56ccSmrg	    case " $sys_lib_dlsearch_path " in
820088de56ccSmrg	    *" $absdir "*) ;;
820188de56ccSmrg	    *)
820288de56ccSmrg	      case "$compile_rpath " in
820388de56ccSmrg	      *" $absdir "*) ;;
8204e9fcaa8aSmrg	      *) func_append compile_rpath " $absdir" ;;
820588de56ccSmrg	      esac
820688de56ccSmrg	      ;;
820788de56ccSmrg	    esac
820888de56ccSmrg	    case " $sys_lib_dlsearch_path " in
820988de56ccSmrg	    *" $libdir "*) ;;
821088de56ccSmrg	    *)
821188de56ccSmrg	      case "$finalize_rpath " in
821288de56ccSmrg	      *" $libdir "*) ;;
8213e9fcaa8aSmrg	      *) func_append finalize_rpath " $libdir" ;;
821488de56ccSmrg	      esac
821588de56ccSmrg	      ;;
821688de56ccSmrg	    esac
821788de56ccSmrg	  fi # $linkmode,$pass = prog,link...
821888de56ccSmrg
8219862bcd1aSmrg	  if $alldeplibs &&
8220862bcd1aSmrg	     { test pass_all = "$deplibs_check_method" ||
8221862bcd1aSmrg	       { test yes = "$build_libtool_libs" &&
822288de56ccSmrg		 test -n "$library_names"; }; }; then
822388de56ccSmrg	    # We only need to search for static libraries
822488de56ccSmrg	    continue
822588de56ccSmrg	  fi
822688de56ccSmrg	fi
822788de56ccSmrg
822888de56ccSmrg	link_static=no # Whether the deplib will be linked statically
822988de56ccSmrg	use_static_libs=$prefer_static_libs
8230862bcd1aSmrg	if test built = "$use_static_libs" && test yes = "$installed"; then
823188de56ccSmrg	  use_static_libs=no
823288de56ccSmrg	fi
823388de56ccSmrg	if test -n "$library_names" &&
8234862bcd1aSmrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
823588de56ccSmrg	  case $host in
8236862bcd1aSmrg	  *cygwin* | *mingw* | *cegcc* | *os2*)
823788de56ccSmrg	      # No point in relinking DLLs because paths are not encoded
8238e9fcaa8aSmrg	      func_append notinst_deplibs " $lib"
823988de56ccSmrg	      need_relink=no
824088de56ccSmrg	    ;;
824188de56ccSmrg	  *)
8242862bcd1aSmrg	    if test no = "$installed"; then
8243e9fcaa8aSmrg	      func_append notinst_deplibs " $lib"
824488de56ccSmrg	      need_relink=yes
824588de56ccSmrg	    fi
824688de56ccSmrg	    ;;
824788de56ccSmrg	  esac
824888de56ccSmrg	  # This is a shared library
824988de56ccSmrg
825088de56ccSmrg	  # Warn about portability, can't link against -module's on some
825188de56ccSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
8252862bcd1aSmrg	  dlopenmodule=
825388de56ccSmrg	  for dlpremoduletest in $dlprefiles; do
825488de56ccSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
8255862bcd1aSmrg	      dlopenmodule=$dlpremoduletest
825688de56ccSmrg	      break
825788de56ccSmrg	    fi
825888de56ccSmrg	  done
8259862bcd1aSmrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8260e9fcaa8aSmrg	    echo
8261862bcd1aSmrg	    if test prog = "$linkmode"; then
826288de56ccSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
826388de56ccSmrg	    else
826488de56ccSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
826588de56ccSmrg	    fi
826688de56ccSmrg	    $ECHO "*** $linklib is not portable!"
826788de56ccSmrg	  fi
8268862bcd1aSmrg	  if test lib = "$linkmode" &&
8269862bcd1aSmrg	     test yes = "$hardcode_into_libs"; then
827088de56ccSmrg	    # Hardcode the library path.
827188de56ccSmrg	    # Skip directories that are in the system default run-time
827288de56ccSmrg	    # search path.
827388de56ccSmrg	    case " $sys_lib_dlsearch_path " in
827488de56ccSmrg	    *" $absdir "*) ;;
827588de56ccSmrg	    *)
827688de56ccSmrg	      case "$compile_rpath " in
827788de56ccSmrg	      *" $absdir "*) ;;
8278e9fcaa8aSmrg	      *) func_append compile_rpath " $absdir" ;;
827988de56ccSmrg	      esac
828088de56ccSmrg	      ;;
828188de56ccSmrg	    esac
828288de56ccSmrg	    case " $sys_lib_dlsearch_path " in
828388de56ccSmrg	    *" $libdir "*) ;;
828488de56ccSmrg	    *)
828588de56ccSmrg	      case "$finalize_rpath " in
828688de56ccSmrg	      *" $libdir "*) ;;
8287e9fcaa8aSmrg	      *) func_append finalize_rpath " $libdir" ;;
828888de56ccSmrg	      esac
828988de56ccSmrg	      ;;
829088de56ccSmrg	    esac
829188de56ccSmrg	  fi
829288de56ccSmrg
829388de56ccSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
829488de56ccSmrg	    # figure out the soname
829588de56ccSmrg	    set dummy $library_names
829688de56ccSmrg	    shift
8297862bcd1aSmrg	    realname=$1
829888de56ccSmrg	    shift
829988de56ccSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
830088de56ccSmrg	    # use dlname if we got it. it's perfectly good, no?
830188de56ccSmrg	    if test -n "$dlname"; then
8302862bcd1aSmrg	      soname=$dlname
830388de56ccSmrg	    elif test -n "$soname_spec"; then
830488de56ccSmrg	      # bleh windows
830588de56ccSmrg	      case $host in
8306862bcd1aSmrg	      *cygwin* | mingw* | *cegcc* | *os2*)
830788de56ccSmrg	        func_arith $current - $age
830888de56ccSmrg		major=$func_arith_result
8309862bcd1aSmrg		versuffix=-$major
831088de56ccSmrg		;;
831188de56ccSmrg	      esac
831288de56ccSmrg	      eval soname=\"$soname_spec\"
831388de56ccSmrg	    else
8314862bcd1aSmrg	      soname=$realname
831588de56ccSmrg	    fi
831688de56ccSmrg
831788de56ccSmrg	    # Make a new name for the extract_expsyms_cmds to use
8318862bcd1aSmrg	    soroot=$soname
831988de56ccSmrg	    func_basename "$soroot"
8320862bcd1aSmrg	    soname=$func_basename_result
832188de56ccSmrg	    func_stripname 'lib' '.dll' "$soname"
832288de56ccSmrg	    newlib=libimp-$func_stripname_result.a
832388de56ccSmrg
832488de56ccSmrg	    # If the library has no export list, then create one now
832588de56ccSmrg	    if test -f "$output_objdir/$soname-def"; then :
832688de56ccSmrg	    else
8327862bcd1aSmrg	      func_verbose "extracting exported symbol list from '$soname'"
832888de56ccSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
832988de56ccSmrg	    fi
833088de56ccSmrg
833188de56ccSmrg	    # Create $newlib
833288de56ccSmrg	    if test -f "$output_objdir/$newlib"; then :; else
8333862bcd1aSmrg	      func_verbose "generating import library for '$soname'"
833488de56ccSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
833588de56ccSmrg	    fi
833688de56ccSmrg	    # make sure the library variables are pointing to the new library
833788de56ccSmrg	    dir=$output_objdir
833888de56ccSmrg	    linklib=$newlib
833988de56ccSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
834088de56ccSmrg
8341862bcd1aSmrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
834288de56ccSmrg	    add_shlibpath=
834388de56ccSmrg	    add_dir=
834488de56ccSmrg	    add=
834588de56ccSmrg	    lib_linked=yes
834688de56ccSmrg	    case $hardcode_action in
834788de56ccSmrg	    immediate | unsupported)
8348862bcd1aSmrg	      if test no = "$hardcode_direct"; then
8349862bcd1aSmrg		add=$dir/$linklib
835088de56ccSmrg		case $host in
8351862bcd1aSmrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
8352862bcd1aSmrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
835388de56ccSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
8354862bcd1aSmrg		    *-*-unixware7*) add_dir=-L$dir ;;
835588de56ccSmrg		  *-*-darwin* )
8356862bcd1aSmrg		    # if the lib is a (non-dlopened) module then we cannot
835788de56ccSmrg		    # link against it, someone is ignoring the earlier warnings
835888de56ccSmrg		    if /usr/bin/file -L $add 2> /dev/null |
8359862bcd1aSmrg			 $GREP ": [^:]* bundle" >/dev/null; then
836088de56ccSmrg		      if test "X$dlopenmodule" != "X$lib"; then
836188de56ccSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
8362862bcd1aSmrg			if test -z "$old_library"; then
8363e9fcaa8aSmrg			  echo
8364e9fcaa8aSmrg			  echo "*** And there doesn't seem to be a static archive available"
8365e9fcaa8aSmrg			  echo "*** The link will probably fail, sorry"
836688de56ccSmrg			else
8367862bcd1aSmrg			  add=$dir/$old_library
836888de56ccSmrg			fi
836988de56ccSmrg		      elif test -n "$old_library"; then
8370862bcd1aSmrg			add=$dir/$old_library
837188de56ccSmrg		      fi
837288de56ccSmrg		    fi
837388de56ccSmrg		esac
8374862bcd1aSmrg	      elif test no = "$hardcode_minus_L"; then
837588de56ccSmrg		case $host in
8376862bcd1aSmrg		*-*-sunos*) add_shlibpath=$dir ;;
837788de56ccSmrg		esac
8378862bcd1aSmrg		add_dir=-L$dir
8379862bcd1aSmrg		add=-l$name
8380862bcd1aSmrg	      elif test no = "$hardcode_shlibpath_var"; then
8381862bcd1aSmrg		add_shlibpath=$dir
8382862bcd1aSmrg		add=-l$name
838388de56ccSmrg	      else
838488de56ccSmrg		lib_linked=no
838588de56ccSmrg	      fi
838688de56ccSmrg	      ;;
838788de56ccSmrg	    relink)
8388862bcd1aSmrg	      if test yes = "$hardcode_direct" &&
8389862bcd1aSmrg	         test no = "$hardcode_direct_absolute"; then
8390862bcd1aSmrg		add=$dir/$linklib
8391862bcd1aSmrg	      elif test yes = "$hardcode_minus_L"; then
8392862bcd1aSmrg		add_dir=-L$absdir
839388de56ccSmrg		# Try looking first in the location we're being installed to.
839488de56ccSmrg		if test -n "$inst_prefix_dir"; then
839588de56ccSmrg		  case $libdir in
839688de56ccSmrg		    [\\/]*)
8397e9fcaa8aSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
839888de56ccSmrg		      ;;
839988de56ccSmrg		  esac
840088de56ccSmrg		fi
8401862bcd1aSmrg		add=-l$name
8402862bcd1aSmrg	      elif test yes = "$hardcode_shlibpath_var"; then
8403862bcd1aSmrg		add_shlibpath=$dir
8404862bcd1aSmrg		add=-l$name
840588de56ccSmrg	      else
840688de56ccSmrg		lib_linked=no
840788de56ccSmrg	      fi
840888de56ccSmrg	      ;;
840988de56ccSmrg	    *) lib_linked=no ;;
841088de56ccSmrg	    esac
841188de56ccSmrg
8412862bcd1aSmrg	    if test yes != "$lib_linked"; then
841388de56ccSmrg	      func_fatal_configuration "unsupported hardcode properties"
841488de56ccSmrg	    fi
841588de56ccSmrg
841688de56ccSmrg	    if test -n "$add_shlibpath"; then
841788de56ccSmrg	      case :$compile_shlibpath: in
841888de56ccSmrg	      *":$add_shlibpath:"*) ;;
8419e9fcaa8aSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
842088de56ccSmrg	      esac
842188de56ccSmrg	    fi
8422862bcd1aSmrg	    if test prog = "$linkmode"; then
842388de56ccSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
842488de56ccSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
842588de56ccSmrg	    else
842688de56ccSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
842788de56ccSmrg	      test -n "$add" && deplibs="$add $deplibs"
8428862bcd1aSmrg	      if test yes != "$hardcode_direct" &&
8429862bcd1aSmrg		 test yes != "$hardcode_minus_L" &&
8430862bcd1aSmrg		 test yes = "$hardcode_shlibpath_var"; then
843188de56ccSmrg		case :$finalize_shlibpath: in
843288de56ccSmrg		*":$libdir:"*) ;;
8433e9fcaa8aSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
843488de56ccSmrg		esac
843588de56ccSmrg	      fi
843688de56ccSmrg	    fi
843788de56ccSmrg	  fi
843888de56ccSmrg
8439862bcd1aSmrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
844088de56ccSmrg	    add_shlibpath=
844188de56ccSmrg	    add_dir=
844288de56ccSmrg	    add=
844388de56ccSmrg	    # Finalize command for both is simple: just hardcode it.
8444862bcd1aSmrg	    if test yes = "$hardcode_direct" &&
8445862bcd1aSmrg	       test no = "$hardcode_direct_absolute"; then
8446862bcd1aSmrg	      add=$libdir/$linklib
8447862bcd1aSmrg	    elif test yes = "$hardcode_minus_L"; then
8448862bcd1aSmrg	      add_dir=-L$libdir
8449862bcd1aSmrg	      add=-l$name
8450862bcd1aSmrg	    elif test yes = "$hardcode_shlibpath_var"; then
845188de56ccSmrg	      case :$finalize_shlibpath: in
845288de56ccSmrg	      *":$libdir:"*) ;;
8453e9fcaa8aSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
845488de56ccSmrg	      esac
8455862bcd1aSmrg	      add=-l$name
8456862bcd1aSmrg	    elif test yes = "$hardcode_automatic"; then
845788de56ccSmrg	      if test -n "$inst_prefix_dir" &&
8458862bcd1aSmrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
8459862bcd1aSmrg		add=$inst_prefix_dir$libdir/$linklib
846088de56ccSmrg	      else
8461862bcd1aSmrg		add=$libdir/$linklib
846288de56ccSmrg	      fi
846388de56ccSmrg	    else
846488de56ccSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
8465862bcd1aSmrg	      add_dir=-L$libdir
846688de56ccSmrg	      # Try looking first in the location we're being installed to.
846788de56ccSmrg	      if test -n "$inst_prefix_dir"; then
846888de56ccSmrg		case $libdir in
846988de56ccSmrg		  [\\/]*)
8470e9fcaa8aSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
847188de56ccSmrg		    ;;
847288de56ccSmrg		esac
847388de56ccSmrg	      fi
8474862bcd1aSmrg	      add=-l$name
847588de56ccSmrg	    fi
847688de56ccSmrg
8477862bcd1aSmrg	    if test prog = "$linkmode"; then
847888de56ccSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
847988de56ccSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
848088de56ccSmrg	    else
848188de56ccSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
848288de56ccSmrg	      test -n "$add" && deplibs="$add $deplibs"
848388de56ccSmrg	    fi
848488de56ccSmrg	  fi
8485862bcd1aSmrg	elif test prog = "$linkmode"; then
848688de56ccSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
848788de56ccSmrg	  # is not unsupported.  This is valid on all known static and
848888de56ccSmrg	  # shared platforms.
8489862bcd1aSmrg	  if test unsupported != "$hardcode_direct"; then
8490862bcd1aSmrg	    test -n "$old_library" && linklib=$old_library
849188de56ccSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
849288de56ccSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
849388de56ccSmrg	  else
849488de56ccSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
849588de56ccSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
849688de56ccSmrg	  fi
8497862bcd1aSmrg	elif test yes = "$build_libtool_libs"; then
849888de56ccSmrg	  # Not a shared library
8499862bcd1aSmrg	  if test pass_all != "$deplibs_check_method"; then
850088de56ccSmrg	    # We're trying link a shared library against a static one
850188de56ccSmrg	    # but the system doesn't support it.
850288de56ccSmrg
850388de56ccSmrg	    # Just print a warning and add the library to dependency_libs so
850488de56ccSmrg	    # that the program can be linked against the static library.
8505e9fcaa8aSmrg	    echo
8506862bcd1aSmrg	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8507e9fcaa8aSmrg	    echo "*** I have the capability to make that library automatically link in when"
8508e9fcaa8aSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
8509e9fcaa8aSmrg	    echo "*** shared version of the library, which you do not appear to have."
8510862bcd1aSmrg	    if test yes = "$module"; then
8511e9fcaa8aSmrg	      echo "*** But as you try to build a module library, libtool will still create "
8512e9fcaa8aSmrg	      echo "*** a static module, that should work as long as the dlopening application"
8513e9fcaa8aSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
851488de56ccSmrg	      if test -z "$global_symbol_pipe"; then
8515e9fcaa8aSmrg		echo
8516e9fcaa8aSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
8517862bcd1aSmrg		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8518e9fcaa8aSmrg		echo "*** not find such a program.  So, this module is probably useless."
8519862bcd1aSmrg		echo "*** 'nm' from GNU binutils and a full rebuild may help."
852088de56ccSmrg	      fi
8521862bcd1aSmrg	      if test no = "$build_old_libs"; then
852288de56ccSmrg		build_libtool_libs=module
852388de56ccSmrg		build_old_libs=yes
852488de56ccSmrg	      else
852588de56ccSmrg		build_libtool_libs=no
852688de56ccSmrg	      fi
852788de56ccSmrg	    fi
852888de56ccSmrg	  else
852988de56ccSmrg	    deplibs="$dir/$old_library $deplibs"
853088de56ccSmrg	    link_static=yes
853188de56ccSmrg	  fi
853288de56ccSmrg	fi # link shared/static library?
853388de56ccSmrg
8534862bcd1aSmrg	if test lib = "$linkmode"; then
853588de56ccSmrg	  if test -n "$dependency_libs" &&
8536862bcd1aSmrg	     { test yes != "$hardcode_into_libs" ||
8537862bcd1aSmrg	       test yes = "$build_old_libs" ||
8538862bcd1aSmrg	       test yes = "$link_static"; }; then
853988de56ccSmrg	    # Extract -R from dependency_libs
854088de56ccSmrg	    temp_deplibs=
854188de56ccSmrg	    for libdir in $dependency_libs; do
854288de56ccSmrg	      case $libdir in
854388de56ccSmrg	      -R*) func_stripname '-R' '' "$libdir"
854488de56ccSmrg	           temp_xrpath=$func_stripname_result
854588de56ccSmrg		   case " $xrpath " in
854688de56ccSmrg		   *" $temp_xrpath "*) ;;
8547e9fcaa8aSmrg		   *) func_append xrpath " $temp_xrpath";;
854888de56ccSmrg		   esac;;
8549e9fcaa8aSmrg	      *) func_append temp_deplibs " $libdir";;
855088de56ccSmrg	      esac
855188de56ccSmrg	    done
8552862bcd1aSmrg	    dependency_libs=$temp_deplibs
855388de56ccSmrg	  fi
855488de56ccSmrg
8555e9fcaa8aSmrg	  func_append newlib_search_path " $absdir"
855688de56ccSmrg	  # Link against this library
8557862bcd1aSmrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
855888de56ccSmrg	  # ... and its dependency_libs
855988de56ccSmrg	  tmp_libs=
856088de56ccSmrg	  for deplib in $dependency_libs; do
856188de56ccSmrg	    newdependency_libs="$deplib $newdependency_libs"
8562e9fcaa8aSmrg	    case $deplib in
8563e9fcaa8aSmrg              -L*) func_stripname '-L' '' "$deplib"
8564e9fcaa8aSmrg                   func_resolve_sysroot "$func_stripname_result";;
8565e9fcaa8aSmrg              *) func_resolve_sysroot "$deplib" ;;
8566e9fcaa8aSmrg            esac
8567862bcd1aSmrg	    if $opt_preserve_dup_deps; then
856888de56ccSmrg	      case "$tmp_libs " in
8569e9fcaa8aSmrg	      *" $func_resolve_sysroot_result "*)
8570e9fcaa8aSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
857188de56ccSmrg	      esac
857288de56ccSmrg	    fi
8573e9fcaa8aSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
857488de56ccSmrg	  done
857588de56ccSmrg
8576862bcd1aSmrg	  if test no != "$link_all_deplibs"; then
857788de56ccSmrg	    # Add the search paths of all dependency libraries
857888de56ccSmrg	    for deplib in $dependency_libs; do
857947f86ac1Smrg	      path=
858088de56ccSmrg	      case $deplib in
8581862bcd1aSmrg	      -L*) path=$deplib ;;
858288de56ccSmrg	      *.la)
8583e9fcaa8aSmrg	        func_resolve_sysroot "$deplib"
8584e9fcaa8aSmrg	        deplib=$func_resolve_sysroot_result
858588de56ccSmrg	        func_dirname "$deplib" "" "."
8586e9fcaa8aSmrg		dir=$func_dirname_result
858788de56ccSmrg		# We need an absolute path.
858888de56ccSmrg		case $dir in
8589862bcd1aSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
859088de56ccSmrg		*)
859188de56ccSmrg		  absdir=`cd "$dir" && pwd`
859288de56ccSmrg		  if test -z "$absdir"; then
8593862bcd1aSmrg		    func_warning "cannot determine absolute directory name of '$dir'"
8594862bcd1aSmrg		    absdir=$dir
859588de56ccSmrg		  fi
859688de56ccSmrg		  ;;
859788de56ccSmrg		esac
859888de56ccSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
859988de56ccSmrg		case $host in
860088de56ccSmrg		*-*-darwin*)
860188de56ccSmrg		  depdepl=
8602862bcd1aSmrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
8603862bcd1aSmrg		  if test -n "$deplibrary_names"; then
8604862bcd1aSmrg		    for tmp in $deplibrary_names; do
860588de56ccSmrg		      depdepl=$tmp
860688de56ccSmrg		    done
8607862bcd1aSmrg		    if test -f "$absdir/$objdir/$depdepl"; then
8608862bcd1aSmrg		      depdepl=$absdir/$objdir/$depdepl
8609862bcd1aSmrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
861088de56ccSmrg                      if test -z "$darwin_install_name"; then
8611862bcd1aSmrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
861288de56ccSmrg                      fi
8613862bcd1aSmrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
8614862bcd1aSmrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
861588de56ccSmrg		      path=
861688de56ccSmrg		    fi
861788de56ccSmrg		  fi
861888de56ccSmrg		  ;;
861988de56ccSmrg		*)
8620862bcd1aSmrg		  path=-L$absdir/$objdir
862188de56ccSmrg		  ;;
862288de56ccSmrg		esac
862388de56ccSmrg		else
8624862bcd1aSmrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
862588de56ccSmrg		  test -z "$libdir" && \
8626862bcd1aSmrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
862788de56ccSmrg		  test "$absdir" != "$libdir" && \
8628862bcd1aSmrg		    func_warning "'$deplib' seems to be moved"
862988de56ccSmrg
8630862bcd1aSmrg		  path=-L$absdir
863188de56ccSmrg		fi
863288de56ccSmrg		;;
863388de56ccSmrg	      esac
863488de56ccSmrg	      case " $deplibs " in
863588de56ccSmrg	      *" $path "*) ;;
863688de56ccSmrg	      *) deplibs="$path $deplibs" ;;
863788de56ccSmrg	      esac
863888de56ccSmrg	    done
863988de56ccSmrg	  fi # link_all_deplibs != no
864088de56ccSmrg	fi # linkmode = lib
864188de56ccSmrg      done # for deplib in $libs
8642862bcd1aSmrg      if test link = "$pass"; then
8643862bcd1aSmrg	if test prog = "$linkmode"; then
864488de56ccSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
864588de56ccSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
864688de56ccSmrg	else
8647e9fcaa8aSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
864888de56ccSmrg	fi
864988de56ccSmrg      fi
8650862bcd1aSmrg      dependency_libs=$newdependency_libs
8651862bcd1aSmrg      if test dlpreopen = "$pass"; then
865288de56ccSmrg	# Link the dlpreopened libraries before other libraries
865388de56ccSmrg	for deplib in $save_deplibs; do
865488de56ccSmrg	  deplibs="$deplib $deplibs"
865588de56ccSmrg	done
865688de56ccSmrg      fi
8657862bcd1aSmrg      if test dlopen != "$pass"; then
8658862bcd1aSmrg	test conv = "$pass" || {
865988de56ccSmrg	  # Make sure lib_search_path contains only unique directories.
866088de56ccSmrg	  lib_search_path=
866188de56ccSmrg	  for dir in $newlib_search_path; do
866288de56ccSmrg	    case "$lib_search_path " in
866388de56ccSmrg	    *" $dir "*) ;;
8664e9fcaa8aSmrg	    *) func_append lib_search_path " $dir" ;;
866588de56ccSmrg	    esac
866688de56ccSmrg	  done
866788de56ccSmrg	  newlib_search_path=
8668862bcd1aSmrg	}
866988de56ccSmrg
8670862bcd1aSmrg	if test prog,link = "$linkmode,$pass"; then
867188de56ccSmrg	  vars="compile_deplibs finalize_deplibs"
8672862bcd1aSmrg	else
8673862bcd1aSmrg	  vars=deplibs
867488de56ccSmrg	fi
867588de56ccSmrg	for var in $vars dependency_libs; do
867688de56ccSmrg	  # Add libraries to $var in reverse order
867788de56ccSmrg	  eval tmp_libs=\"\$$var\"
867888de56ccSmrg	  new_libs=
867988de56ccSmrg	  for deplib in $tmp_libs; do
868088de56ccSmrg	    # FIXME: Pedantically, this is the right thing to do, so
868188de56ccSmrg	    #        that some nasty dependency loop isn't accidentally
868288de56ccSmrg	    #        broken:
868388de56ccSmrg	    #new_libs="$deplib $new_libs"
868488de56ccSmrg	    # Pragmatically, this seems to cause very few problems in
868588de56ccSmrg	    # practice:
868688de56ccSmrg	    case $deplib in
868788de56ccSmrg	    -L*) new_libs="$deplib $new_libs" ;;
868888de56ccSmrg	    -R*) ;;
868988de56ccSmrg	    *)
869088de56ccSmrg	      # And here is the reason: when a library appears more
869188de56ccSmrg	      # than once as an explicit dependence of a library, or
869288de56ccSmrg	      # is implicitly linked in more than once by the
869388de56ccSmrg	      # compiler, it is considered special, and multiple
869488de56ccSmrg	      # occurrences thereof are not removed.  Compare this
869588de56ccSmrg	      # with having the same library being listed as a
869688de56ccSmrg	      # dependency of multiple other libraries: in this case,
869788de56ccSmrg	      # we know (pedantically, we assume) the library does not
869888de56ccSmrg	      # need to be listed more than once, so we keep only the
869988de56ccSmrg	      # last copy.  This is not always right, but it is rare
870088de56ccSmrg	      # enough that we require users that really mean to play
870188de56ccSmrg	      # such unportable linking tricks to link the library
870288de56ccSmrg	      # using -Wl,-lname, so that libtool does not consider it
870388de56ccSmrg	      # for duplicate removal.
870488de56ccSmrg	      case " $specialdeplibs " in
870588de56ccSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
870688de56ccSmrg	      *)
870788de56ccSmrg		case " $new_libs " in
870888de56ccSmrg		*" $deplib "*) ;;
870988de56ccSmrg		*) new_libs="$deplib $new_libs" ;;
871088de56ccSmrg		esac
871188de56ccSmrg		;;
871288de56ccSmrg	      esac
871388de56ccSmrg	      ;;
871488de56ccSmrg	    esac
871588de56ccSmrg	  done
871688de56ccSmrg	  tmp_libs=
871788de56ccSmrg	  for deplib in $new_libs; do
871888de56ccSmrg	    case $deplib in
871988de56ccSmrg	    -L*)
872088de56ccSmrg	      case " $tmp_libs " in
872188de56ccSmrg	      *" $deplib "*) ;;
8722e9fcaa8aSmrg	      *) func_append tmp_libs " $deplib" ;;
872388de56ccSmrg	      esac
872488de56ccSmrg	      ;;
8725e9fcaa8aSmrg	    *) func_append tmp_libs " $deplib" ;;
872688de56ccSmrg	    esac
872788de56ccSmrg	  done
872888de56ccSmrg	  eval $var=\"$tmp_libs\"
872988de56ccSmrg	done # for var
873088de56ccSmrg      fi
8731862bcd1aSmrg
8732862bcd1aSmrg      # Add Sun CC postdeps if required:
8733862bcd1aSmrg      test CXX = "$tagname" && {
8734862bcd1aSmrg        case $host_os in
8735862bcd1aSmrg        linux*)
8736862bcd1aSmrg          case `$CC -V 2>&1 | sed 5q` in
8737862bcd1aSmrg          *Sun\ C*) # Sun C++ 5.9
8738862bcd1aSmrg            func_suncc_cstd_abi
8739862bcd1aSmrg
8740862bcd1aSmrg            if test no != "$suncc_use_cstd_abi"; then
8741862bcd1aSmrg              func_append postdeps ' -library=Cstd -library=Crun'
8742862bcd1aSmrg            fi
8743862bcd1aSmrg            ;;
8744862bcd1aSmrg          esac
8745862bcd1aSmrg          ;;
8746862bcd1aSmrg
8747862bcd1aSmrg        solaris*)
8748862bcd1aSmrg          func_cc_basename "$CC"
8749862bcd1aSmrg          case $func_cc_basename_result in
8750862bcd1aSmrg          CC* | sunCC*)
8751862bcd1aSmrg            func_suncc_cstd_abi
8752862bcd1aSmrg
8753862bcd1aSmrg            if test no != "$suncc_use_cstd_abi"; then
8754862bcd1aSmrg              func_append postdeps ' -library=Cstd -library=Crun'
8755862bcd1aSmrg            fi
8756862bcd1aSmrg            ;;
8757862bcd1aSmrg          esac
8758862bcd1aSmrg          ;;
8759862bcd1aSmrg        esac
8760862bcd1aSmrg      }
8761862bcd1aSmrg
876288de56ccSmrg      # Last step: remove runtime libs from dependency_libs
876388de56ccSmrg      # (they stay in deplibs)
876488de56ccSmrg      tmp_libs=
8765862bcd1aSmrg      for i in $dependency_libs; do
876688de56ccSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
876788de56ccSmrg	*" $i "*)
8768862bcd1aSmrg	  i=
876988de56ccSmrg	  ;;
877088de56ccSmrg	esac
8771862bcd1aSmrg	if test -n "$i"; then
8772e9fcaa8aSmrg	  func_append tmp_libs " $i"
877388de56ccSmrg	fi
877488de56ccSmrg      done
877588de56ccSmrg      dependency_libs=$tmp_libs
877688de56ccSmrg    done # for pass
8777862bcd1aSmrg    if test prog = "$linkmode"; then
8778862bcd1aSmrg      dlfiles=$newdlfiles
877988de56ccSmrg    fi
8780862bcd1aSmrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
8781862bcd1aSmrg      dlprefiles=$newdlprefiles
878288de56ccSmrg    fi
878388de56ccSmrg
878488de56ccSmrg    case $linkmode in
878588de56ccSmrg    oldlib)
8786862bcd1aSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
8787862bcd1aSmrg	func_warning "'-dlopen' is ignored for archives"
878888de56ccSmrg      fi
878988de56ccSmrg
879088de56ccSmrg      case " $deplibs" in
879188de56ccSmrg      *\ -l* | *\ -L*)
8792862bcd1aSmrg	func_warning "'-l' and '-L' are ignored for archives" ;;
879388de56ccSmrg      esac
879488de56ccSmrg
879588de56ccSmrg      test -n "$rpath" && \
8796862bcd1aSmrg	func_warning "'-rpath' is ignored for archives"
879788de56ccSmrg
879888de56ccSmrg      test -n "$xrpath" && \
8799862bcd1aSmrg	func_warning "'-R' is ignored for archives"
880088de56ccSmrg
880188de56ccSmrg      test -n "$vinfo" && \
8802862bcd1aSmrg	func_warning "'-version-info/-version-number' is ignored for archives"
880388de56ccSmrg
880488de56ccSmrg      test -n "$release" && \
8805862bcd1aSmrg	func_warning "'-release' is ignored for archives"
880688de56ccSmrg
880788de56ccSmrg      test -n "$export_symbols$export_symbols_regex" && \
8808862bcd1aSmrg	func_warning "'-export-symbols' is ignored for archives"
880988de56ccSmrg
881088de56ccSmrg      # Now set the variables for building old libraries.
881188de56ccSmrg      build_libtool_libs=no
8812862bcd1aSmrg      oldlibs=$output
8813e9fcaa8aSmrg      func_append objs "$old_deplibs"
881488de56ccSmrg      ;;
881588de56ccSmrg
881688de56ccSmrg    lib)
8817862bcd1aSmrg      # Make sure we only generate libraries of the form 'libNAME.la'.
881888de56ccSmrg      case $outputname in
881988de56ccSmrg      lib*)
882088de56ccSmrg	func_stripname 'lib' '.la' "$outputname"
882188de56ccSmrg	name=$func_stripname_result
882288de56ccSmrg	eval shared_ext=\"$shrext_cmds\"
882388de56ccSmrg	eval libname=\"$libname_spec\"
882488de56ccSmrg	;;
882588de56ccSmrg      *)
8826862bcd1aSmrg	test no = "$module" \
8827862bcd1aSmrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
882888de56ccSmrg
8829862bcd1aSmrg	if test no != "$need_lib_prefix"; then
883088de56ccSmrg	  # Add the "lib" prefix for modules if required
883188de56ccSmrg	  func_stripname '' '.la' "$outputname"
883288de56ccSmrg	  name=$func_stripname_result
883388de56ccSmrg	  eval shared_ext=\"$shrext_cmds\"
883488de56ccSmrg	  eval libname=\"$libname_spec\"
883588de56ccSmrg	else
883688de56ccSmrg	  func_stripname '' '.la' "$outputname"
883788de56ccSmrg	  libname=$func_stripname_result
883888de56ccSmrg	fi
883988de56ccSmrg	;;
884088de56ccSmrg      esac
884188de56ccSmrg
884288de56ccSmrg      if test -n "$objs"; then
8843862bcd1aSmrg	if test pass_all != "$deplibs_check_method"; then
8844862bcd1aSmrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
884588de56ccSmrg	else
8846e9fcaa8aSmrg	  echo
884788de56ccSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
884888de56ccSmrg	  $ECHO "*** objects $objs is not portable!"
8849e9fcaa8aSmrg	  func_append libobjs " $objs"
885088de56ccSmrg	fi
885188de56ccSmrg      fi
885288de56ccSmrg
8853862bcd1aSmrg      test no = "$dlself" \
8854862bcd1aSmrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
885588de56ccSmrg
885688de56ccSmrg      set dummy $rpath
885788de56ccSmrg      shift
8858862bcd1aSmrg      test 1 -lt "$#" \
8859862bcd1aSmrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
886088de56ccSmrg
8861862bcd1aSmrg      install_libdir=$1
886288de56ccSmrg
886388de56ccSmrg      oldlibs=
886488de56ccSmrg      if test -z "$rpath"; then
8865862bcd1aSmrg	if test yes = "$build_libtool_libs"; then
886688de56ccSmrg	  # Building a libtool convenience library.
8867862bcd1aSmrg	  # Some compilers have problems with a '.al' extension so
886888de56ccSmrg	  # convenience libraries should have the same extension an
886988de56ccSmrg	  # archive normally would.
887088de56ccSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
887188de56ccSmrg	  build_libtool_libs=convenience
887288de56ccSmrg	  build_old_libs=yes
887388de56ccSmrg	fi
887488de56ccSmrg
887588de56ccSmrg	test -n "$vinfo" && \
8876862bcd1aSmrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
887788de56ccSmrg
887888de56ccSmrg	test -n "$release" && \
8879862bcd1aSmrg	  func_warning "'-release' is ignored for convenience libraries"
888088de56ccSmrg      else
888188de56ccSmrg
888288de56ccSmrg	# Parse the version information argument.
8883862bcd1aSmrg	save_ifs=$IFS; IFS=:
888488de56ccSmrg	set dummy $vinfo 0 0 0
888588de56ccSmrg	shift
8886862bcd1aSmrg	IFS=$save_ifs
888788de56ccSmrg
888888de56ccSmrg	test -n "$7" && \
8889862bcd1aSmrg	  func_fatal_help "too many parameters to '-version-info'"
889088de56ccSmrg
889188de56ccSmrg	# convert absolute version numbers to libtool ages
889288de56ccSmrg	# this retains compatibility with .la files and attempts
889388de56ccSmrg	# to make the code below a bit more comprehensible
889488de56ccSmrg
889588de56ccSmrg	case $vinfo_number in
889688de56ccSmrg	yes)
8897862bcd1aSmrg	  number_major=$1
8898862bcd1aSmrg	  number_minor=$2
8899862bcd1aSmrg	  number_revision=$3
890088de56ccSmrg	  #
890188de56ccSmrg	  # There are really only two kinds -- those that
890288de56ccSmrg	  # use the current revision as the major version
890388de56ccSmrg	  # and those that subtract age and use age as
890488de56ccSmrg	  # a minor version.  But, then there is irix
8905862bcd1aSmrg	  # that has an extra 1 added just for fun
890688de56ccSmrg	  #
890788de56ccSmrg	  case $version_type in
8908eb411b4bSmrg	  # correct linux to gnu/linux during the next big refactor
8909862bcd1aSmrg	  darwin|freebsd-elf|linux|osf|windows|none)
891088de56ccSmrg	    func_arith $number_major + $number_minor
891188de56ccSmrg	    current=$func_arith_result
8912862bcd1aSmrg	    age=$number_minor
8913862bcd1aSmrg	    revision=$number_revision
891488de56ccSmrg	    ;;
8915862bcd1aSmrg	  freebsd-aout|qnx|sunos)
8916862bcd1aSmrg	    current=$number_major
8917862bcd1aSmrg	    revision=$number_minor
8918862bcd1aSmrg	    age=0
891988de56ccSmrg	    ;;
892088de56ccSmrg	  irix|nonstopux)
892188de56ccSmrg	    func_arith $number_major + $number_minor
892288de56ccSmrg	    current=$func_arith_result
8923862bcd1aSmrg	    age=$number_minor
8924862bcd1aSmrg	    revision=$number_minor
892588de56ccSmrg	    lt_irix_increment=no
892688de56ccSmrg	    ;;
89279c019ec5Smaya	  *)
89289c019ec5Smaya	    func_fatal_configuration "$modename: unknown library version type '$version_type'"
89299c019ec5Smaya	    ;;
893088de56ccSmrg	  esac
893188de56ccSmrg	  ;;
893288de56ccSmrg	no)
8933862bcd1aSmrg	  current=$1
8934862bcd1aSmrg	  revision=$2
8935862bcd1aSmrg	  age=$3
893688de56ccSmrg	  ;;
893788de56ccSmrg	esac
893888de56ccSmrg
893988de56ccSmrg	# Check that each of the things are valid numbers.
894088de56ccSmrg	case $current in
894188de56ccSmrg	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]) ;;
894288de56ccSmrg	*)
8943862bcd1aSmrg	  func_error "CURRENT '$current' must be a nonnegative integer"
8944862bcd1aSmrg	  func_fatal_error "'$vinfo' is not valid version information"
894588de56ccSmrg	  ;;
894688de56ccSmrg	esac
894788de56ccSmrg
894888de56ccSmrg	case $revision in
894988de56ccSmrg	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]) ;;
895088de56ccSmrg	*)
8951862bcd1aSmrg	  func_error "REVISION '$revision' must be a nonnegative integer"
8952862bcd1aSmrg	  func_fatal_error "'$vinfo' is not valid version information"
895388de56ccSmrg	  ;;
895488de56ccSmrg	esac
895588de56ccSmrg
895688de56ccSmrg	case $age in
895788de56ccSmrg	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]) ;;
895888de56ccSmrg	*)
8959862bcd1aSmrg	  func_error "AGE '$age' must be a nonnegative integer"
8960862bcd1aSmrg	  func_fatal_error "'$vinfo' is not valid version information"
896188de56ccSmrg	  ;;
896288de56ccSmrg	esac
896388de56ccSmrg
896488de56ccSmrg	if test "$age" -gt "$current"; then
8965862bcd1aSmrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
8966862bcd1aSmrg	  func_fatal_error "'$vinfo' is not valid version information"
896788de56ccSmrg	fi
896888de56ccSmrg
896988de56ccSmrg	# Calculate the version variables.
897088de56ccSmrg	major=
897188de56ccSmrg	versuffix=
897288de56ccSmrg	verstring=
897388de56ccSmrg	case $version_type in
897488de56ccSmrg	none) ;;
897588de56ccSmrg
897688de56ccSmrg	darwin)
897788de56ccSmrg	  # Like Linux, but with the current version available in
897888de56ccSmrg	  # verstring for coding it into the library header
897988de56ccSmrg	  func_arith $current - $age
898088de56ccSmrg	  major=.$func_arith_result
8981862bcd1aSmrg	  versuffix=$major.$age.$revision
898288de56ccSmrg	  # Darwin ld doesn't like 0 for these options...
898388de56ccSmrg	  func_arith $current + 1
898488de56ccSmrg	  minor_current=$func_arith_result
8985862bcd1aSmrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
898688de56ccSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8987862bcd1aSmrg          # On Darwin other compilers
8988862bcd1aSmrg          case $CC in
8989862bcd1aSmrg              nagfor*)
8990862bcd1aSmrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8991862bcd1aSmrg                  ;;
8992862bcd1aSmrg              *)
8993862bcd1aSmrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8994862bcd1aSmrg                  ;;
8995862bcd1aSmrg          esac
899688de56ccSmrg	  ;;
899788de56ccSmrg
899888de56ccSmrg	freebsd-aout)
8999862bcd1aSmrg	  major=.$current
9000862bcd1aSmrg	  versuffix=.$current.$revision
900188de56ccSmrg	  ;;
900288de56ccSmrg
900388de56ccSmrg	freebsd-elf)
9004862bcd1aSmrg	  func_arith $current - $age
9005862bcd1aSmrg	  major=.$func_arith_result
9006862bcd1aSmrg	  versuffix=$major.$age.$revision
900788de56ccSmrg	  ;;
900888de56ccSmrg
900988de56ccSmrg	irix | nonstopux)
9010862bcd1aSmrg	  if test no = "$lt_irix_increment"; then
901188de56ccSmrg	    func_arith $current - $age
901288de56ccSmrg	  else
901388de56ccSmrg	    func_arith $current - $age + 1
901488de56ccSmrg	  fi
901588de56ccSmrg	  major=$func_arith_result
901688de56ccSmrg
901788de56ccSmrg	  case $version_type in
901888de56ccSmrg	    nonstopux) verstring_prefix=nonstopux ;;
901988de56ccSmrg	    *)         verstring_prefix=sgi ;;
902088de56ccSmrg	  esac
9021862bcd1aSmrg	  verstring=$verstring_prefix$major.$revision
902288de56ccSmrg
902388de56ccSmrg	  # Add in all the interfaces that we are compatible with.
902488de56ccSmrg	  loop=$revision
9025862bcd1aSmrg	  while test 0 -ne "$loop"; do
902688de56ccSmrg	    func_arith $revision - $loop
902788de56ccSmrg	    iface=$func_arith_result
902888de56ccSmrg	    func_arith $loop - 1
902988de56ccSmrg	    loop=$func_arith_result
9030862bcd1aSmrg	    verstring=$verstring_prefix$major.$iface:$verstring
903188de56ccSmrg	  done
903288de56ccSmrg
9033862bcd1aSmrg	  # Before this point, $major must not contain '.'.
903488de56ccSmrg	  major=.$major
9035862bcd1aSmrg	  versuffix=$major.$revision
903688de56ccSmrg	  ;;
903788de56ccSmrg
9038eb411b4bSmrg	linux) # correct to gnu/linux during the next big refactor
903988de56ccSmrg	  func_arith $current - $age
904088de56ccSmrg	  major=.$func_arith_result
9041862bcd1aSmrg	  versuffix=$major.$age.$revision
904288de56ccSmrg	  ;;
904388de56ccSmrg
904488de56ccSmrg	osf)
904588de56ccSmrg	  func_arith $current - $age
904688de56ccSmrg	  major=.$func_arith_result
9047862bcd1aSmrg	  versuffix=.$current.$age.$revision
9048862bcd1aSmrg	  verstring=$current.$age.$revision
904988de56ccSmrg
905088de56ccSmrg	  # Add in all the interfaces that we are compatible with.
905188de56ccSmrg	  loop=$age
9052862bcd1aSmrg	  while test 0 -ne "$loop"; do
905388de56ccSmrg	    func_arith $current - $loop
905488de56ccSmrg	    iface=$func_arith_result
905588de56ccSmrg	    func_arith $loop - 1
905688de56ccSmrg	    loop=$func_arith_result
9057862bcd1aSmrg	    verstring=$verstring:$iface.0
905888de56ccSmrg	  done
905988de56ccSmrg
906088de56ccSmrg	  # Make executables depend on our current version.
9061862bcd1aSmrg	  func_append verstring ":$current.0"
906288de56ccSmrg	  ;;
906388de56ccSmrg
906488de56ccSmrg	qnx)
9065862bcd1aSmrg	  major=.$current
9066862bcd1aSmrg	  versuffix=.$current
9067862bcd1aSmrg	  ;;
9068862bcd1aSmrg
9069862bcd1aSmrg	sco)
9070862bcd1aSmrg	  major=.$current
9071862bcd1aSmrg	  versuffix=.$current
907288de56ccSmrg	  ;;
907388de56ccSmrg
907488de56ccSmrg	sunos)
9075862bcd1aSmrg	  major=.$current
9076862bcd1aSmrg	  versuffix=.$current.$revision
907788de56ccSmrg	  ;;
907888de56ccSmrg
907988de56ccSmrg	windows)
908088de56ccSmrg	  # Use '-' rather than '.', since we only want one
9081862bcd1aSmrg	  # extension on DOS 8.3 file systems.
908288de56ccSmrg	  func_arith $current - $age
908388de56ccSmrg	  major=$func_arith_result
9084862bcd1aSmrg	  versuffix=-$major
908588de56ccSmrg	  ;;
908688de56ccSmrg
908788de56ccSmrg	*)
9088862bcd1aSmrg	  func_fatal_configuration "unknown library version type '$version_type'"
908988de56ccSmrg	  ;;
909088de56ccSmrg	esac
909188de56ccSmrg
909288de56ccSmrg	# Clear the version info if we defaulted, and they specified a release.
909388de56ccSmrg	if test -z "$vinfo" && test -n "$release"; then
909488de56ccSmrg	  major=
909588de56ccSmrg	  case $version_type in
909688de56ccSmrg	  darwin)
909788de56ccSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
909888de56ccSmrg	    # problems, so we reset it completely
909988de56ccSmrg	    verstring=
910088de56ccSmrg	    ;;
910188de56ccSmrg	  *)
9102862bcd1aSmrg	    verstring=0.0
910388de56ccSmrg	    ;;
910488de56ccSmrg	  esac
9105862bcd1aSmrg	  if test no = "$need_version"; then
910688de56ccSmrg	    versuffix=
910788de56ccSmrg	  else
9108862bcd1aSmrg	    versuffix=.0.0
910988de56ccSmrg	  fi
911088de56ccSmrg	fi
911188de56ccSmrg
911288de56ccSmrg	# Remove version info from name if versioning should be avoided
9113862bcd1aSmrg	if test yes,no = "$avoid_version,$need_version"; then
911488de56ccSmrg	  major=
911588de56ccSmrg	  versuffix=
9116862bcd1aSmrg	  verstring=
911788de56ccSmrg	fi
911888de56ccSmrg
911988de56ccSmrg	# Check to see if the archive will have undefined symbols.
9120862bcd1aSmrg	if test yes = "$allow_undefined"; then
9121862bcd1aSmrg	  if test unsupported = "$allow_undefined_flag"; then
9122862bcd1aSmrg	    if test yes = "$build_old_libs"; then
9123862bcd1aSmrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
9124862bcd1aSmrg	      build_libtool_libs=no
9125862bcd1aSmrg	    else
9126862bcd1aSmrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
9127862bcd1aSmrg	    fi
912888de56ccSmrg	  fi
912988de56ccSmrg	else
913088de56ccSmrg	  # Don't allow undefined symbols.
9131862bcd1aSmrg	  allow_undefined_flag=$no_undefined_flag
913288de56ccSmrg	fi
913388de56ccSmrg
913488de56ccSmrg      fi
913588de56ccSmrg
9136862bcd1aSmrg      func_generate_dlsyms "$libname" "$libname" :
9137e9fcaa8aSmrg      func_append libobjs " $symfileobj"
9138862bcd1aSmrg      test " " = "$libobjs" && libobjs=
913988de56ccSmrg
9140862bcd1aSmrg      if test relink != "$opt_mode"; then
914188de56ccSmrg	# Remove our outputs, but don't remove object files since they
914288de56ccSmrg	# may have been created when compiling PIC objects.
914388de56ccSmrg	removelist=
914488de56ccSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
914588de56ccSmrg	for p in $tempremovelist; do
914688de56ccSmrg	  case $p in
914788de56ccSmrg	    *.$objext | *.gcno)
914888de56ccSmrg	       ;;
9149862bcd1aSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
9150862bcd1aSmrg	       if test -n "$precious_files_regex"; then
915188de56ccSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
915288de56ccSmrg		 then
915388de56ccSmrg		   continue
915488de56ccSmrg		 fi
915588de56ccSmrg	       fi
9156e9fcaa8aSmrg	       func_append removelist " $p"
915788de56ccSmrg	       ;;
915888de56ccSmrg	    *) ;;
915988de56ccSmrg	  esac
916088de56ccSmrg	done
916188de56ccSmrg	test -n "$removelist" && \
916288de56ccSmrg	  func_show_eval "${RM}r \$removelist"
916388de56ccSmrg      fi
916488de56ccSmrg
916588de56ccSmrg      # Now set the variables for building old libraries.
9166862bcd1aSmrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9167e9fcaa8aSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
916888de56ccSmrg
916988de56ccSmrg	# Transform .lo files to .o files.
9170862bcd1aSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
917188de56ccSmrg      fi
917288de56ccSmrg
917388de56ccSmrg      # Eliminate all temporary directories.
917488de56ccSmrg      #for path in $notinst_path; do
9175e9fcaa8aSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9176e9fcaa8aSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9177e9fcaa8aSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
917888de56ccSmrg      #done
917988de56ccSmrg
918088de56ccSmrg      if test -n "$xrpath"; then
918188de56ccSmrg	# If the user specified any rpath flags, then add them.
918288de56ccSmrg	temp_xrpath=
918388de56ccSmrg	for libdir in $xrpath; do
9184e9fcaa8aSmrg	  func_replace_sysroot "$libdir"
9185e9fcaa8aSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
918688de56ccSmrg	  case "$finalize_rpath " in
918788de56ccSmrg	  *" $libdir "*) ;;
9188e9fcaa8aSmrg	  *) func_append finalize_rpath " $libdir" ;;
918988de56ccSmrg	  esac
919088de56ccSmrg	done
9191862bcd1aSmrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
919288de56ccSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
919388de56ccSmrg	fi
919488de56ccSmrg      fi
919588de56ccSmrg
919688de56ccSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
9197862bcd1aSmrg      old_dlfiles=$dlfiles
919888de56ccSmrg      dlfiles=
919988de56ccSmrg      for lib in $old_dlfiles; do
920088de56ccSmrg	case " $dlprefiles $dlfiles " in
920188de56ccSmrg	*" $lib "*) ;;
9202e9fcaa8aSmrg	*) func_append dlfiles " $lib" ;;
920388de56ccSmrg	esac
920488de56ccSmrg      done
920588de56ccSmrg
920688de56ccSmrg      # Make sure dlprefiles contains only unique files
9207862bcd1aSmrg      old_dlprefiles=$dlprefiles
920888de56ccSmrg      dlprefiles=
920988de56ccSmrg      for lib in $old_dlprefiles; do
921088de56ccSmrg	case "$dlprefiles " in
921188de56ccSmrg	*" $lib "*) ;;
9212e9fcaa8aSmrg	*) func_append dlprefiles " $lib" ;;
921388de56ccSmrg	esac
921488de56ccSmrg      done
921588de56ccSmrg
9216862bcd1aSmrg      if test yes = "$build_libtool_libs"; then
921788de56ccSmrg	if test -n "$rpath"; then
921888de56ccSmrg	  case $host in
9219e9fcaa8aSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
922088de56ccSmrg	    # these systems don't actually have a c library (as such)!
922188de56ccSmrg	    ;;
922288de56ccSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
922388de56ccSmrg	    # Rhapsody C library is in the System framework
9224e9fcaa8aSmrg	    func_append deplibs " System.ltframework"
922588de56ccSmrg	    ;;
922688de56ccSmrg	  *-*-netbsd*)
922788de56ccSmrg	    # Don't link with libc until the a.out ld.so is fixed.
922888de56ccSmrg	    ;;
922988de56ccSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
923088de56ccSmrg	    # Do not include libc due to us having libc/libc_r.
923188de56ccSmrg	    ;;
923288de56ccSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
923388de56ccSmrg	    # Causes problems with __ctype
923488de56ccSmrg	    ;;
923588de56ccSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
923688de56ccSmrg	    # Compiler inserts libc in the correct place for threads to work
923788de56ccSmrg	    ;;
923888de56ccSmrg	  *)
923988de56ccSmrg	    # Add libc to deplibs on all other systems if necessary.
9240862bcd1aSmrg	    if test yes = "$build_libtool_need_lc"; then
9241e9fcaa8aSmrg	      func_append deplibs " -lc"
924288de56ccSmrg	    fi
924388de56ccSmrg	    ;;
924488de56ccSmrg	  esac
924588de56ccSmrg	fi
924688de56ccSmrg
924788de56ccSmrg	# Transform deplibs into only deplibs that can be linked in shared.
924888de56ccSmrg	name_save=$name
924988de56ccSmrg	libname_save=$libname
925088de56ccSmrg	release_save=$release
925188de56ccSmrg	versuffix_save=$versuffix
925288de56ccSmrg	major_save=$major
925388de56ccSmrg	# I'm not sure if I'm treating the release correctly.  I think
925488de56ccSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
925588de56ccSmrg	# add it in twice.  Is that correct?
9256862bcd1aSmrg	release=
9257862bcd1aSmrg	versuffix=
9258862bcd1aSmrg	major=
925988de56ccSmrg	newdeplibs=
926088de56ccSmrg	droppeddeps=no
926188de56ccSmrg	case $deplibs_check_method in
926288de56ccSmrg	pass_all)
926388de56ccSmrg	  # Don't check for shared/static.  Everything works.
926488de56ccSmrg	  # This might be a little naive.  We might want to check
926588de56ccSmrg	  # whether the library exists or not.  But this is on
926688de56ccSmrg	  # osf3 & osf4 and I'm not really sure... Just
926788de56ccSmrg	  # implementing what was already the behavior.
926888de56ccSmrg	  newdeplibs=$deplibs
926988de56ccSmrg	  ;;
927088de56ccSmrg	test_compile)
927188de56ccSmrg	  # This code stresses the "libraries are programs" paradigm to its
927288de56ccSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
927388de56ccSmrg	  # against the deplibs as a proxy for the library.  Then we can check
927488de56ccSmrg	  # whether they linked in statically or dynamically with ldd.
927588de56ccSmrg	  $opt_dry_run || $RM conftest.c
927688de56ccSmrg	  cat > conftest.c <<EOF
927788de56ccSmrg	  int main() { return 0; }
927888de56ccSmrgEOF
927988de56ccSmrg	  $opt_dry_run || $RM conftest
928088de56ccSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
928188de56ccSmrg	    ldd_output=`ldd conftest`
928288de56ccSmrg	    for i in $deplibs; do
928388de56ccSmrg	      case $i in
928488de56ccSmrg	      -l*)
928588de56ccSmrg		func_stripname -l '' "$i"
928688de56ccSmrg		name=$func_stripname_result
9287862bcd1aSmrg		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
928888de56ccSmrg		  case " $predeps $postdeps " in
928988de56ccSmrg		  *" $i "*)
9290e9fcaa8aSmrg		    func_append newdeplibs " $i"
9291862bcd1aSmrg		    i=
929288de56ccSmrg		    ;;
929388de56ccSmrg		  esac
929488de56ccSmrg		fi
9295862bcd1aSmrg		if test -n "$i"; then
929688de56ccSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
929788de56ccSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
929888de56ccSmrg		  set dummy $deplib_matches; shift
929988de56ccSmrg		  deplib_match=$1
9300862bcd1aSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9301e9fcaa8aSmrg		    func_append newdeplibs " $i"
930288de56ccSmrg		  else
930388de56ccSmrg		    droppeddeps=yes
9304e9fcaa8aSmrg		    echo
930588de56ccSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9306e9fcaa8aSmrg		    echo "*** I have the capability to make that library automatically link in when"
9307e9fcaa8aSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
9308e9fcaa8aSmrg		    echo "*** shared version of the library, which I believe you do not have"
9309e9fcaa8aSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
9310e9fcaa8aSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
931188de56ccSmrg		  fi
931288de56ccSmrg		fi
931388de56ccSmrg		;;
931488de56ccSmrg	      *)
9315e9fcaa8aSmrg		func_append newdeplibs " $i"
931688de56ccSmrg		;;
931788de56ccSmrg	      esac
931888de56ccSmrg	    done
931988de56ccSmrg	  else
932088de56ccSmrg	    # Error occurred in the first compile.  Let's try to salvage
932188de56ccSmrg	    # the situation: Compile a separate program for each library.
932288de56ccSmrg	    for i in $deplibs; do
932388de56ccSmrg	      case $i in
932488de56ccSmrg	      -l*)
932588de56ccSmrg		func_stripname -l '' "$i"
932688de56ccSmrg		name=$func_stripname_result
932788de56ccSmrg		$opt_dry_run || $RM conftest
932888de56ccSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
932988de56ccSmrg		  ldd_output=`ldd conftest`
9330862bcd1aSmrg		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
933188de56ccSmrg		    case " $predeps $postdeps " in
933288de56ccSmrg		    *" $i "*)
9333e9fcaa8aSmrg		      func_append newdeplibs " $i"
9334862bcd1aSmrg		      i=
933588de56ccSmrg		      ;;
933688de56ccSmrg		    esac
933788de56ccSmrg		  fi
9338862bcd1aSmrg		  if test -n "$i"; then
933988de56ccSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
934088de56ccSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
934188de56ccSmrg		    set dummy $deplib_matches; shift
934288de56ccSmrg		    deplib_match=$1
9343862bcd1aSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9344e9fcaa8aSmrg		      func_append newdeplibs " $i"
934588de56ccSmrg		    else
934688de56ccSmrg		      droppeddeps=yes
9347e9fcaa8aSmrg		      echo
934888de56ccSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9349e9fcaa8aSmrg		      echo "*** I have the capability to make that library automatically link in when"
9350e9fcaa8aSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
9351e9fcaa8aSmrg		      echo "*** shared version of the library, which you do not appear to have"
9352e9fcaa8aSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
9353e9fcaa8aSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
935488de56ccSmrg		    fi
935588de56ccSmrg		  fi
935688de56ccSmrg		else
935788de56ccSmrg		  droppeddeps=yes
9358e9fcaa8aSmrg		  echo
935988de56ccSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
9360e9fcaa8aSmrg		  echo "*** make it link in!  You will probably need to install it or some"
9361e9fcaa8aSmrg		  echo "*** library that it depends on before this library will be fully"
9362e9fcaa8aSmrg		  echo "*** functional.  Installing it before continuing would be even better."
936388de56ccSmrg		fi
936488de56ccSmrg		;;
936588de56ccSmrg	      *)
9366e9fcaa8aSmrg		func_append newdeplibs " $i"
936788de56ccSmrg		;;
936888de56ccSmrg	      esac
936988de56ccSmrg	    done
937088de56ccSmrg	  fi
937188de56ccSmrg	  ;;
937288de56ccSmrg	file_magic*)
937388de56ccSmrg	  set dummy $deplibs_check_method; shift
937488de56ccSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
937588de56ccSmrg	  for a_deplib in $deplibs; do
937688de56ccSmrg	    case $a_deplib in
937788de56ccSmrg	    -l*)
937888de56ccSmrg	      func_stripname -l '' "$a_deplib"
937988de56ccSmrg	      name=$func_stripname_result
9380862bcd1aSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
938188de56ccSmrg		case " $predeps $postdeps " in
938288de56ccSmrg		*" $a_deplib "*)
9383e9fcaa8aSmrg		  func_append newdeplibs " $a_deplib"
9384862bcd1aSmrg		  a_deplib=
938588de56ccSmrg		  ;;
938688de56ccSmrg		esac
938788de56ccSmrg	      fi
9388862bcd1aSmrg	      if test -n "$a_deplib"; then
938988de56ccSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9390e9fcaa8aSmrg		if test -n "$file_magic_glob"; then
9391e9fcaa8aSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9392e9fcaa8aSmrg		else
9393e9fcaa8aSmrg		  libnameglob=$libname
9394e9fcaa8aSmrg		fi
9395862bcd1aSmrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
939688de56ccSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9397862bcd1aSmrg		  if test yes = "$want_nocaseglob"; then
9398e9fcaa8aSmrg		    shopt -s nocaseglob
9399e9fcaa8aSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9400e9fcaa8aSmrg		    $nocaseglob
9401e9fcaa8aSmrg		  else
9402e9fcaa8aSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9403e9fcaa8aSmrg		  fi
940488de56ccSmrg		  for potent_lib in $potential_libs; do
940588de56ccSmrg		      # Follow soft links.
940688de56ccSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
940788de56ccSmrg			 $GREP " -> " >/dev/null; then
940888de56ccSmrg			continue
940988de56ccSmrg		      fi
941088de56ccSmrg		      # The statement above tries to avoid entering an
941188de56ccSmrg		      # endless loop below, in case of cyclic links.
941288de56ccSmrg		      # We might still enter an endless loop, since a link
941388de56ccSmrg		      # loop can be closed while we follow links,
941488de56ccSmrg		      # but so what?
9415862bcd1aSmrg		      potlib=$potent_lib
941688de56ccSmrg		      while test -h "$potlib" 2>/dev/null; do
9417862bcd1aSmrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
941888de56ccSmrg			case $potliblink in
9419862bcd1aSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
9420862bcd1aSmrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
942188de56ccSmrg			esac
942288de56ccSmrg		      done
942388de56ccSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
942488de56ccSmrg			 $SED -e 10q |
942588de56ccSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
9426e9fcaa8aSmrg			func_append newdeplibs " $a_deplib"
9427862bcd1aSmrg			a_deplib=
942888de56ccSmrg			break 2
942988de56ccSmrg		      fi
943088de56ccSmrg		  done
943188de56ccSmrg		done
943288de56ccSmrg	      fi
9433862bcd1aSmrg	      if test -n "$a_deplib"; then
943488de56ccSmrg		droppeddeps=yes
9435e9fcaa8aSmrg		echo
943688de56ccSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9437e9fcaa8aSmrg		echo "*** I have the capability to make that library automatically link in when"
9438e9fcaa8aSmrg		echo "*** you link to this library.  But I can only do this if you have a"
9439e9fcaa8aSmrg		echo "*** shared version of the library, which you do not appear to have"
9440e9fcaa8aSmrg		echo "*** because I did check the linker path looking for a file starting"
9441862bcd1aSmrg		if test -z "$potlib"; then
944288de56ccSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
944388de56ccSmrg		else
944488de56ccSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
944588de56ccSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
944688de56ccSmrg		fi
944788de56ccSmrg	      fi
944888de56ccSmrg	      ;;
944988de56ccSmrg	    *)
945088de56ccSmrg	      # Add a -L argument.
9451e9fcaa8aSmrg	      func_append newdeplibs " $a_deplib"
945288de56ccSmrg	      ;;
945388de56ccSmrg	    esac
945488de56ccSmrg	  done # Gone through all deplibs.
945588de56ccSmrg	  ;;
945688de56ccSmrg	match_pattern*)
945788de56ccSmrg	  set dummy $deplibs_check_method; shift
945888de56ccSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
945988de56ccSmrg	  for a_deplib in $deplibs; do
946088de56ccSmrg	    case $a_deplib in
946188de56ccSmrg	    -l*)
946288de56ccSmrg	      func_stripname -l '' "$a_deplib"
946388de56ccSmrg	      name=$func_stripname_result
9464862bcd1aSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
946588de56ccSmrg		case " $predeps $postdeps " in
946688de56ccSmrg		*" $a_deplib "*)
9467e9fcaa8aSmrg		  func_append newdeplibs " $a_deplib"
9468862bcd1aSmrg		  a_deplib=
946988de56ccSmrg		  ;;
947088de56ccSmrg		esac
947188de56ccSmrg	      fi
9472862bcd1aSmrg	      if test -n "$a_deplib"; then
947388de56ccSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
947488de56ccSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
947588de56ccSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
947688de56ccSmrg		  for potent_lib in $potential_libs; do
9477862bcd1aSmrg		    potlib=$potent_lib # see symlink-check above in file_magic test
9478e9fcaa8aSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
947988de56ccSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
9480e9fcaa8aSmrg		      func_append newdeplibs " $a_deplib"
9481862bcd1aSmrg		      a_deplib=
948288de56ccSmrg		      break 2
948388de56ccSmrg		    fi
948488de56ccSmrg		  done
948588de56ccSmrg		done
948688de56ccSmrg	      fi
9487862bcd1aSmrg	      if test -n "$a_deplib"; then
948888de56ccSmrg		droppeddeps=yes
9489e9fcaa8aSmrg		echo
949088de56ccSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9491e9fcaa8aSmrg		echo "*** I have the capability to make that library automatically link in when"
9492e9fcaa8aSmrg		echo "*** you link to this library.  But I can only do this if you have a"
9493e9fcaa8aSmrg		echo "*** shared version of the library, which you do not appear to have"
9494e9fcaa8aSmrg		echo "*** because I did check the linker path looking for a file starting"
9495862bcd1aSmrg		if test -z "$potlib"; then
949688de56ccSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
949788de56ccSmrg		else
949888de56ccSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
949988de56ccSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
950088de56ccSmrg		fi
950188de56ccSmrg	      fi
950288de56ccSmrg	      ;;
950388de56ccSmrg	    *)
950488de56ccSmrg	      # Add a -L argument.
9505e9fcaa8aSmrg	      func_append newdeplibs " $a_deplib"
950688de56ccSmrg	      ;;
950788de56ccSmrg	    esac
950888de56ccSmrg	  done # Gone through all deplibs.
950988de56ccSmrg	  ;;
951088de56ccSmrg	none | unknown | *)
9511862bcd1aSmrg	  newdeplibs=
9512e9fcaa8aSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
9513862bcd1aSmrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9514862bcd1aSmrg	    for i in $predeps $postdeps; do
951588de56ccSmrg	      # can't use Xsed below, because $i might contain '/'
9516862bcd1aSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
951788de56ccSmrg	    done
951888de56ccSmrg	  fi
9519e9fcaa8aSmrg	  case $tmp_deplibs in
9520e9fcaa8aSmrg	  *[!\	\ ]*)
9521e9fcaa8aSmrg	    echo
9522862bcd1aSmrg	    if test none = "$deplibs_check_method"; then
9523e9fcaa8aSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
952488de56ccSmrg	    else
9525e9fcaa8aSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
952688de56ccSmrg	    fi
9527e9fcaa8aSmrg	    echo "*** All declared inter-library dependencies are being dropped."
952888de56ccSmrg	    droppeddeps=yes
9529e9fcaa8aSmrg	    ;;
9530e9fcaa8aSmrg	  esac
953188de56ccSmrg	  ;;
953288de56ccSmrg	esac
953388de56ccSmrg	versuffix=$versuffix_save
953488de56ccSmrg	major=$major_save
953588de56ccSmrg	release=$release_save
953688de56ccSmrg	libname=$libname_save
953788de56ccSmrg	name=$name_save
953888de56ccSmrg
953988de56ccSmrg	case $host in
954088de56ccSmrg	*-*-rhapsody* | *-*-darwin1.[012])
954188de56ccSmrg	  # On Rhapsody replace the C library with the System framework
9542e9fcaa8aSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
954388de56ccSmrg	  ;;
954488de56ccSmrg	esac
954588de56ccSmrg
9546862bcd1aSmrg	if test yes = "$droppeddeps"; then
9547862bcd1aSmrg	  if test yes = "$module"; then
9548e9fcaa8aSmrg	    echo
9549e9fcaa8aSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
955088de56ccSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
9551e9fcaa8aSmrg	    echo "*** a static module, that should work as long as the dlopening"
9552e9fcaa8aSmrg	    echo "*** application is linked with the -dlopen flag."
955388de56ccSmrg	    if test -z "$global_symbol_pipe"; then
9554e9fcaa8aSmrg	      echo
9555e9fcaa8aSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
9556862bcd1aSmrg	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9557e9fcaa8aSmrg	      echo "*** not find such a program.  So, this module is probably useless."
9558862bcd1aSmrg	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
955988de56ccSmrg	    fi
9560862bcd1aSmrg	    if test no = "$build_old_libs"; then
9561862bcd1aSmrg	      oldlibs=$output_objdir/$libname.$libext
956288de56ccSmrg	      build_libtool_libs=module
956388de56ccSmrg	      build_old_libs=yes
956488de56ccSmrg	    else
956588de56ccSmrg	      build_libtool_libs=no
956688de56ccSmrg	    fi
956788de56ccSmrg	  else
9568e9fcaa8aSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
9569e9fcaa8aSmrg	    echo "*** automatically added whenever a program is linked with this library"
9570e9fcaa8aSmrg	    echo "*** or is declared to -dlopen it."
957188de56ccSmrg
9572862bcd1aSmrg	    if test no = "$allow_undefined"; then
9573e9fcaa8aSmrg	      echo
9574e9fcaa8aSmrg	      echo "*** Since this library must not contain undefined symbols,"
9575e9fcaa8aSmrg	      echo "*** because either the platform does not support them or"
9576e9fcaa8aSmrg	      echo "*** it was explicitly requested with -no-undefined,"
9577e9fcaa8aSmrg	      echo "*** libtool will only create a static version of it."
9578862bcd1aSmrg	      if test no = "$build_old_libs"; then
9579862bcd1aSmrg		oldlibs=$output_objdir/$libname.$libext
958088de56ccSmrg		build_libtool_libs=module
958188de56ccSmrg		build_old_libs=yes
958288de56ccSmrg	      else
958388de56ccSmrg		build_libtool_libs=no
958488de56ccSmrg	      fi
958588de56ccSmrg	    fi
958688de56ccSmrg	  fi
958788de56ccSmrg	fi
958888de56ccSmrg	# Done checking deplibs!
958988de56ccSmrg	deplibs=$newdeplibs
959088de56ccSmrg      fi
959188de56ccSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
959288de56ccSmrg      case $host in
959388de56ccSmrg	*-*-darwin*)
9594e9fcaa8aSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9595e9fcaa8aSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9596e9fcaa8aSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
959788de56ccSmrg	  ;;
959888de56ccSmrg      esac
959988de56ccSmrg
960088de56ccSmrg      # move library search paths that coincide with paths to not yet
960188de56ccSmrg      # installed libraries to the beginning of the library search list
960288de56ccSmrg      new_libs=
960388de56ccSmrg      for path in $notinst_path; do
960488de56ccSmrg	case " $new_libs " in
960588de56ccSmrg	*" -L$path/$objdir "*) ;;
960688de56ccSmrg	*)
960788de56ccSmrg	  case " $deplibs " in
960888de56ccSmrg	  *" -L$path/$objdir "*)
9609e9fcaa8aSmrg	    func_append new_libs " -L$path/$objdir" ;;
961088de56ccSmrg	  esac
961188de56ccSmrg	  ;;
961288de56ccSmrg	esac
961388de56ccSmrg      done
961488de56ccSmrg      for deplib in $deplibs; do
961588de56ccSmrg	case $deplib in
961688de56ccSmrg	-L*)
961788de56ccSmrg	  case " $new_libs " in
961888de56ccSmrg	  *" $deplib "*) ;;
9619e9fcaa8aSmrg	  *) func_append new_libs " $deplib" ;;
962088de56ccSmrg	  esac
962188de56ccSmrg	  ;;
9622e9fcaa8aSmrg	*) func_append new_libs " $deplib" ;;
962388de56ccSmrg	esac
962488de56ccSmrg      done
9625862bcd1aSmrg      deplibs=$new_libs
962688de56ccSmrg
962788de56ccSmrg      # All the library-specific variables (install_libdir is set above).
962888de56ccSmrg      library_names=
962988de56ccSmrg      old_library=
963088de56ccSmrg      dlname=
963188de56ccSmrg
963288de56ccSmrg      # Test again, we may have decided not to build it any more
9633862bcd1aSmrg      if test yes = "$build_libtool_libs"; then
9634862bcd1aSmrg	# Remove $wl instances when linking with ld.
9635eb411b4bSmrg	# FIXME: should test the right _cmds variable.
9636eb411b4bSmrg	case $archive_cmds in
9637eb411b4bSmrg	  *\$LD\ *) wl= ;;
9638eb411b4bSmrg        esac
9639862bcd1aSmrg	if test yes = "$hardcode_into_libs"; then
964088de56ccSmrg	  # Hardcode the library paths
964188de56ccSmrg	  hardcode_libdirs=
964288de56ccSmrg	  dep_rpath=
9643862bcd1aSmrg	  rpath=$finalize_rpath
9644862bcd1aSmrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
964588de56ccSmrg	  for libdir in $rpath; do
964688de56ccSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
964788de56ccSmrg	      if test -n "$hardcode_libdir_separator"; then
9648e9fcaa8aSmrg		func_replace_sysroot "$libdir"
9649e9fcaa8aSmrg		libdir=$func_replace_sysroot_result
965088de56ccSmrg		if test -z "$hardcode_libdirs"; then
9651862bcd1aSmrg		  hardcode_libdirs=$libdir
965288de56ccSmrg		else
965388de56ccSmrg		  # Just accumulate the unique libdirs.
965488de56ccSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
965588de56ccSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
965688de56ccSmrg		    ;;
965788de56ccSmrg		  *)
9658e9fcaa8aSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
965988de56ccSmrg		    ;;
966088de56ccSmrg		  esac
966188de56ccSmrg		fi
966288de56ccSmrg	      else
966388de56ccSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
9664e9fcaa8aSmrg		func_append dep_rpath " $flag"
966588de56ccSmrg	      fi
966688de56ccSmrg	    elif test -n "$runpath_var"; then
966788de56ccSmrg	      case "$perm_rpath " in
966888de56ccSmrg	      *" $libdir "*) ;;
9669eb411b4bSmrg	      *) func_append perm_rpath " $libdir" ;;
967088de56ccSmrg	      esac
967188de56ccSmrg	    fi
967288de56ccSmrg	  done
967388de56ccSmrg	  # Substitute the hardcoded libdirs into the rpath.
967488de56ccSmrg	  if test -n "$hardcode_libdir_separator" &&
967588de56ccSmrg	     test -n "$hardcode_libdirs"; then
9676862bcd1aSmrg	    libdir=$hardcode_libdirs
9677eb411b4bSmrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
967888de56ccSmrg	  fi
967988de56ccSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
968088de56ccSmrg	    # We should set the runpath_var.
968188de56ccSmrg	    rpath=
968288de56ccSmrg	    for dir in $perm_rpath; do
9683e9fcaa8aSmrg	      func_append rpath "$dir:"
968488de56ccSmrg	    done
968588de56ccSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
968688de56ccSmrg	  fi
968788de56ccSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
968888de56ccSmrg	fi
96891ab64890Smrg
9690862bcd1aSmrg	shlibpath=$finalize_shlibpath
9691862bcd1aSmrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
969288de56ccSmrg	if test -n "$shlibpath"; then
969388de56ccSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
969488de56ccSmrg	fi
96951ab64890Smrg
969688de56ccSmrg	# Get the real and link names of the library.
969788de56ccSmrg	eval shared_ext=\"$shrext_cmds\"
969888de56ccSmrg	eval library_names=\"$library_names_spec\"
969988de56ccSmrg	set dummy $library_names
970088de56ccSmrg	shift
9701862bcd1aSmrg	realname=$1
970288de56ccSmrg	shift
97031ab64890Smrg
970488de56ccSmrg	if test -n "$soname_spec"; then
970588de56ccSmrg	  eval soname=\"$soname_spec\"
970688de56ccSmrg	else
9707862bcd1aSmrg	  soname=$realname
970888de56ccSmrg	fi
970988de56ccSmrg	if test -z "$dlname"; then
971088de56ccSmrg	  dlname=$soname
971188de56ccSmrg	fi
97121ab64890Smrg
9713862bcd1aSmrg	lib=$output_objdir/$realname
971488de56ccSmrg	linknames=
971588de56ccSmrg	for link
971688de56ccSmrg	do
9717e9fcaa8aSmrg	  func_append linknames " $link"
971888de56ccSmrg	done
97191ab64890Smrg
972088de56ccSmrg	# Use standard objects if they are pic
9721e9fcaa8aSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
972288de56ccSmrg	test "X$libobjs" = "X " && libobjs=
97231ab64890Smrg
972488de56ccSmrg	delfiles=
972588de56ccSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
972688de56ccSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
9727862bcd1aSmrg	  export_symbols=$output_objdir/$libname.uexp
9728e9fcaa8aSmrg	  func_append delfiles " $export_symbols"
972988de56ccSmrg	fi
97301ab64890Smrg
973188de56ccSmrg	orig_export_symbols=
973288de56ccSmrg	case $host_os in
973388de56ccSmrg	cygwin* | mingw* | cegcc*)
973488de56ccSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
973588de56ccSmrg	    # exporting using user supplied symfile
9736862bcd1aSmrg	    func_dll_def_p "$export_symbols" || {
973788de56ccSmrg	      # and it's NOT already a .def file. Must figure out
973888de56ccSmrg	      # which of the given symbols are data symbols and tag
973988de56ccSmrg	      # them as such. So, trigger use of export_symbols_cmds.
974088de56ccSmrg	      # export_symbols gets reassigned inside the "prepare
974188de56ccSmrg	      # the list of exported symbols" if statement, so the
974288de56ccSmrg	      # include_expsyms logic still works.
9743862bcd1aSmrg	      orig_export_symbols=$export_symbols
974488de56ccSmrg	      export_symbols=
974588de56ccSmrg	      always_export_symbols=yes
9746862bcd1aSmrg	    }
974788de56ccSmrg	  fi
974888de56ccSmrg	  ;;
974988de56ccSmrg	esac
97501ab64890Smrg
975188de56ccSmrg	# Prepare the list of exported symbols
975288de56ccSmrg	if test -z "$export_symbols"; then
9753862bcd1aSmrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
9754862bcd1aSmrg	    func_verbose "generating symbol list for '$libname.la'"
9755862bcd1aSmrg	    export_symbols=$output_objdir/$libname.exp
975688de56ccSmrg	    $opt_dry_run || $RM $export_symbols
975788de56ccSmrg	    cmds=$export_symbols_cmds
9758862bcd1aSmrg	    save_ifs=$IFS; IFS='~'
9759e9fcaa8aSmrg	    for cmd1 in $cmds; do
9760862bcd1aSmrg	      IFS=$save_ifs
9761e9fcaa8aSmrg	      # Take the normal branch if the nm_file_list_spec branch
9762e9fcaa8aSmrg	      # doesn't work or if tool conversion is not needed.
9763e9fcaa8aSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
9764e9fcaa8aSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9765e9fcaa8aSmrg		  try_normal_branch=yes
9766e9fcaa8aSmrg		  eval cmd=\"$cmd1\"
9767e9fcaa8aSmrg		  func_len " $cmd"
9768e9fcaa8aSmrg		  len=$func_len_result
9769e9fcaa8aSmrg		  ;;
9770e9fcaa8aSmrg		*)
9771e9fcaa8aSmrg		  try_normal_branch=no
9772e9fcaa8aSmrg		  ;;
9773e9fcaa8aSmrg	      esac
9774862bcd1aSmrg	      if test yes = "$try_normal_branch" \
9775e9fcaa8aSmrg		 && { test "$len" -lt "$max_cmd_len" \
9776e9fcaa8aSmrg		      || test "$max_cmd_len" -le -1; }
9777e9fcaa8aSmrg	      then
9778e9fcaa8aSmrg		func_show_eval "$cmd" 'exit $?'
9779e9fcaa8aSmrg		skipped_export=false
9780e9fcaa8aSmrg	      elif test -n "$nm_file_list_spec"; then
9781e9fcaa8aSmrg		func_basename "$output"
9782e9fcaa8aSmrg		output_la=$func_basename_result
9783e9fcaa8aSmrg		save_libobjs=$libobjs
9784e9fcaa8aSmrg		save_output=$output
9785862bcd1aSmrg		output=$output_objdir/$output_la.nm
9786e9fcaa8aSmrg		func_to_tool_file "$output"
9787e9fcaa8aSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
9788e9fcaa8aSmrg		func_append delfiles " $output"
9789e9fcaa8aSmrg		func_verbose "creating $NM input file list: $output"
9790e9fcaa8aSmrg		for obj in $save_libobjs; do
9791e9fcaa8aSmrg		  func_to_tool_file "$obj"
9792e9fcaa8aSmrg		  $ECHO "$func_to_tool_file_result"
9793e9fcaa8aSmrg		done > "$output"
9794e9fcaa8aSmrg		eval cmd=\"$cmd1\"
979588de56ccSmrg		func_show_eval "$cmd" 'exit $?'
9796e9fcaa8aSmrg		output=$save_output
9797e9fcaa8aSmrg		libobjs=$save_libobjs
979888de56ccSmrg		skipped_export=false
979988de56ccSmrg	      else
980088de56ccSmrg		# The command line is too long to execute in one step.
980188de56ccSmrg		func_verbose "using reloadable object file for export list..."
980288de56ccSmrg		skipped_export=:
980388de56ccSmrg		# Break out early, otherwise skipped_export may be
980488de56ccSmrg		# set to false by a later but shorter cmd.
980588de56ccSmrg		break
980688de56ccSmrg	      fi
980788de56ccSmrg	    done
9808862bcd1aSmrg	    IFS=$save_ifs
9809862bcd1aSmrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
981088de56ccSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
981188de56ccSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
981288de56ccSmrg	    fi
981388de56ccSmrg	  fi
98141ab64890Smrg	fi
98151ab64890Smrg
981688de56ccSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9817862bcd1aSmrg	  tmp_export_symbols=$export_symbols
9818862bcd1aSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9819e9fcaa8aSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
982088de56ccSmrg	fi
98211ab64890Smrg
9822862bcd1aSmrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
982388de56ccSmrg	  # The given exports_symbols file has to be filtered, so filter it.
9824862bcd1aSmrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
982588de56ccSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
9826862bcd1aSmrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
982788de56ccSmrg	  # though. Also, the filter scales superlinearly with the number of
982888de56ccSmrg	  # global variables. join(1) would be nice here, but unfortunately
982988de56ccSmrg	  # isn't a blessed tool.
983088de56ccSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9831e9fcaa8aSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
983288de56ccSmrg	  export_symbols=$output_objdir/$libname.def
983388de56ccSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
983488de56ccSmrg	fi
98351ab64890Smrg
983688de56ccSmrg	tmp_deplibs=
983788de56ccSmrg	for test_deplib in $deplibs; do
983888de56ccSmrg	  case " $convenience " in
983988de56ccSmrg	  *" $test_deplib "*) ;;
984088de56ccSmrg	  *)
9841e9fcaa8aSmrg	    func_append tmp_deplibs " $test_deplib"
984288de56ccSmrg	    ;;
984388de56ccSmrg	  esac
984488de56ccSmrg	done
9845862bcd1aSmrg	deplibs=$tmp_deplibs
98461ab64890Smrg
984788de56ccSmrg	if test -n "$convenience"; then
984888de56ccSmrg	  if test -n "$whole_archive_flag_spec" &&
9849862bcd1aSmrg	    test yes = "$compiler_needs_object" &&
985088de56ccSmrg	    test -z "$libobjs"; then
985188de56ccSmrg	    # extract the archives, so we have objects to list.
985288de56ccSmrg	    # TODO: could optimize this to just extract one archive.
985388de56ccSmrg	    whole_archive_flag_spec=
985488de56ccSmrg	  fi
985588de56ccSmrg	  if test -n "$whole_archive_flag_spec"; then
985688de56ccSmrg	    save_libobjs=$libobjs
985788de56ccSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
985888de56ccSmrg	    test "X$libobjs" = "X " && libobjs=
985988de56ccSmrg	  else
9860862bcd1aSmrg	    gentop=$output_objdir/${outputname}x
9861e9fcaa8aSmrg	    func_append generated " $gentop"
98621ab64890Smrg
986388de56ccSmrg	    func_extract_archives $gentop $convenience
9864e9fcaa8aSmrg	    func_append libobjs " $func_extract_archives_result"
986588de56ccSmrg	    test "X$libobjs" = "X " && libobjs=
986688de56ccSmrg	  fi
9867b4ee4795Smrg	fi
98681ab64890Smrg
9869862bcd1aSmrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
987088de56ccSmrg	  eval flag=\"$thread_safe_flag_spec\"
9871e9fcaa8aSmrg	  func_append linker_flags " $flag"
9872b4ee4795Smrg	fi
98732e9c7c8cSmrg
987488de56ccSmrg	# Make a backup of the uninstalled library when relinking
9875862bcd1aSmrg	if test relink = "$opt_mode"; then
987688de56ccSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
987788de56ccSmrg	fi
98781ab64890Smrg
987988de56ccSmrg	# Do each of the archive commands.
9880862bcd1aSmrg	if test yes = "$module" && test -n "$module_cmds"; then
988188de56ccSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
988288de56ccSmrg	    eval test_cmds=\"$module_expsym_cmds\"
988388de56ccSmrg	    cmds=$module_expsym_cmds
988488de56ccSmrg	  else
988588de56ccSmrg	    eval test_cmds=\"$module_cmds\"
988688de56ccSmrg	    cmds=$module_cmds
988788de56ccSmrg	  fi
9888b4ee4795Smrg	else
988988de56ccSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
989088de56ccSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
989188de56ccSmrg	    cmds=$archive_expsym_cmds
989288de56ccSmrg	  else
989388de56ccSmrg	    eval test_cmds=\"$archive_cmds\"
989488de56ccSmrg	    cmds=$archive_cmds
989588de56ccSmrg	  fi
9896b4ee4795Smrg	fi
98971ab64890Smrg
9898862bcd1aSmrg	if test : != "$skipped_export" &&
989988de56ccSmrg	   func_len " $test_cmds" &&
990088de56ccSmrg	   len=$func_len_result &&
990188de56ccSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
990288de56ccSmrg	  :
990388de56ccSmrg	else
990488de56ccSmrg	  # The command line is too long to link in one step, link piecewise
990588de56ccSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
990688de56ccSmrg	  # script.
99071ab64890Smrg
990888de56ccSmrg	  # Save the value of $output and $libobjs because we want to
990988de56ccSmrg	  # use them later.  If we have whole_archive_flag_spec, we
991088de56ccSmrg	  # want to use save_libobjs as it was before
991188de56ccSmrg	  # whole_archive_flag_spec was expanded, because we can't
991288de56ccSmrg	  # assume the linker understands whole_archive_flag_spec.
991388de56ccSmrg	  # This may have to be revisited, in case too many
991488de56ccSmrg	  # convenience libraries get linked in and end up exceeding
991588de56ccSmrg	  # the spec.
991688de56ccSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
991788de56ccSmrg	    save_libobjs=$libobjs
991888de56ccSmrg	  fi
991988de56ccSmrg	  save_output=$output
9920e9fcaa8aSmrg	  func_basename "$output"
9921e9fcaa8aSmrg	  output_la=$func_basename_result
99221ab64890Smrg
992388de56ccSmrg	  # Clear the reloadable object creation command queue and
992488de56ccSmrg	  # initialize k to one.
992588de56ccSmrg	  test_cmds=
992688de56ccSmrg	  concat_cmds=
992788de56ccSmrg	  objlist=
992888de56ccSmrg	  last_robj=
992988de56ccSmrg	  k=1
993088de56ccSmrg
9931862bcd1aSmrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
9932862bcd1aSmrg	    output=$output_objdir/$output_la.lnkscript
993388de56ccSmrg	    func_verbose "creating GNU ld script: $output"
9934e9fcaa8aSmrg	    echo 'INPUT (' > $output
993588de56ccSmrg	    for obj in $save_libobjs
9936b4ee4795Smrg	    do
9937e9fcaa8aSmrg	      func_to_tool_file "$obj"
9938e9fcaa8aSmrg	      $ECHO "$func_to_tool_file_result" >> $output
993988de56ccSmrg	    done
9940e9fcaa8aSmrg	    echo ')' >> $output
9941e9fcaa8aSmrg	    func_append delfiles " $output"
9942e9fcaa8aSmrg	    func_to_tool_file "$output"
9943e9fcaa8aSmrg	    output=$func_to_tool_file_result
9944862bcd1aSmrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
9945862bcd1aSmrg	    output=$output_objdir/$output_la.lnk
994688de56ccSmrg	    func_verbose "creating linker input file list: $output"
994788de56ccSmrg	    : > $output
994888de56ccSmrg	    set x $save_libobjs
994988de56ccSmrg	    shift
995088de56ccSmrg	    firstobj=
9951862bcd1aSmrg	    if test yes = "$compiler_needs_object"; then
995288de56ccSmrg	      firstobj="$1 "
995388de56ccSmrg	      shift
995488de56ccSmrg	    fi
995588de56ccSmrg	    for obj
995688de56ccSmrg	    do
9957e9fcaa8aSmrg	      func_to_tool_file "$obj"
9958e9fcaa8aSmrg	      $ECHO "$func_to_tool_file_result" >> $output
995988de56ccSmrg	    done
9960e9fcaa8aSmrg	    func_append delfiles " $output"
9961e9fcaa8aSmrg	    func_to_tool_file "$output"
9962e9fcaa8aSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
996388de56ccSmrg	  else
996488de56ccSmrg	    if test -n "$save_libobjs"; then
996588de56ccSmrg	      func_verbose "creating reloadable object files..."
9966862bcd1aSmrg	      output=$output_objdir/$output_la-$k.$objext
996788de56ccSmrg	      eval test_cmds=\"$reload_cmds\"
996888de56ccSmrg	      func_len " $test_cmds"
996988de56ccSmrg	      len0=$func_len_result
997088de56ccSmrg	      len=$len0
997188de56ccSmrg
997288de56ccSmrg	      # Loop over the list of objects to be linked.
997388de56ccSmrg	      for obj in $save_libobjs
997488de56ccSmrg	      do
997588de56ccSmrg		func_len " $obj"
997688de56ccSmrg		func_arith $len + $func_len_result
997788de56ccSmrg		len=$func_arith_result
9978862bcd1aSmrg		if test -z "$objlist" ||
997988de56ccSmrg		   test "$len" -lt "$max_cmd_len"; then
998088de56ccSmrg		  func_append objlist " $obj"
998188de56ccSmrg		else
998288de56ccSmrg		  # The command $test_cmds is almost too long, add a
998388de56ccSmrg		  # command to the queue.
9984862bcd1aSmrg		  if test 1 -eq "$k"; then
998588de56ccSmrg		    # The first file doesn't have a previous command to add.
9986e9fcaa8aSmrg		    reload_objs=$objlist
9987e9fcaa8aSmrg		    eval concat_cmds=\"$reload_cmds\"
998888de56ccSmrg		  else
998988de56ccSmrg		    # All subsequent reloadable object files will link in
999088de56ccSmrg		    # the last one created.
9991e9fcaa8aSmrg		    reload_objs="$objlist $last_robj"
9992e9fcaa8aSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
999388de56ccSmrg		  fi
9994862bcd1aSmrg		  last_robj=$output_objdir/$output_la-$k.$objext
999588de56ccSmrg		  func_arith $k + 1
999688de56ccSmrg		  k=$func_arith_result
9997862bcd1aSmrg		  output=$output_objdir/$output_la-$k.$objext
9998e9fcaa8aSmrg		  objlist=" $obj"
999988de56ccSmrg		  func_len " $last_robj"
1000088de56ccSmrg		  func_arith $len0 + $func_len_result
1000188de56ccSmrg		  len=$func_arith_result
1000288de56ccSmrg		fi
1000388de56ccSmrg	      done
1000488de56ccSmrg	      # Handle the remaining objects by creating one last
1000588de56ccSmrg	      # reloadable object file.  All subsequent reloadable object
1000688de56ccSmrg	      # files will link in the last one created.
1000788de56ccSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10008e9fcaa8aSmrg	      reload_objs="$objlist $last_robj"
10009862bcd1aSmrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
1001088de56ccSmrg	      if test -n "$last_robj"; then
10011862bcd1aSmrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
1001288de56ccSmrg	      fi
10013e9fcaa8aSmrg	      func_append delfiles " $output"
100141ab64890Smrg
1001588de56ccSmrg	    else
1001688de56ccSmrg	      output=
1001788de56ccSmrg	    fi
100181ab64890Smrg
10019862bcd1aSmrg	    ${skipped_export-false} && {
10020862bcd1aSmrg	      func_verbose "generating symbol list for '$libname.la'"
10021862bcd1aSmrg	      export_symbols=$output_objdir/$libname.exp
1002288de56ccSmrg	      $opt_dry_run || $RM $export_symbols
1002388de56ccSmrg	      libobjs=$output
1002488de56ccSmrg	      # Append the command to create the export file.
1002588de56ccSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
1002688de56ccSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
1002788de56ccSmrg	      if test -n "$last_robj"; then
1002888de56ccSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
1002988de56ccSmrg	      fi
10030862bcd1aSmrg	    }
100311ab64890Smrg
1003288de56ccSmrg	    test -n "$save_libobjs" &&
1003388de56ccSmrg	      func_verbose "creating a temporary reloadable object file: $output"
100341ab64890Smrg
1003588de56ccSmrg	    # Loop through the commands generated above and execute them.
10036862bcd1aSmrg	    save_ifs=$IFS; IFS='~'
1003788de56ccSmrg	    for cmd in $concat_cmds; do
10038862bcd1aSmrg	      IFS=$save_ifs
10039862bcd1aSmrg	      $opt_quiet || {
1004088de56ccSmrg		  func_quote_for_expand "$cmd"
1004188de56ccSmrg		  eval "func_echo $func_quote_for_expand_result"
1004288de56ccSmrg	      }
1004388de56ccSmrg	      $opt_dry_run || eval "$cmd" || {
1004488de56ccSmrg		lt_exit=$?
1004588de56ccSmrg
1004688de56ccSmrg		# Restore the uninstalled library and exit
10047862bcd1aSmrg		if test relink = "$opt_mode"; then
1004888de56ccSmrg		  ( cd "$output_objdir" && \
1004988de56ccSmrg		    $RM "${realname}T" && \
1005088de56ccSmrg		    $MV "${realname}U" "$realname" )
1005188de56ccSmrg		fi
100521ab64890Smrg
1005388de56ccSmrg		exit $lt_exit
1005488de56ccSmrg	      }
1005588de56ccSmrg	    done
10056862bcd1aSmrg	    IFS=$save_ifs
10057b4ee4795Smrg
1005888de56ccSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
1005988de56ccSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
1006088de56ccSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
100611ab64890Smrg	    fi
100621ab64890Smrg	  fi
100631ab64890Smrg
10064862bcd1aSmrg          ${skipped_export-false} && {
1006588de56ccSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
10066862bcd1aSmrg	      tmp_export_symbols=$export_symbols
10067862bcd1aSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
10068e9fcaa8aSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
1006988de56ccSmrg	    fi
100702e9c7c8cSmrg
1007188de56ccSmrg	    if test -n "$orig_export_symbols"; then
1007288de56ccSmrg	      # The given exports_symbols file has to be filtered, so filter it.
10073862bcd1aSmrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
1007488de56ccSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
10075862bcd1aSmrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
1007688de56ccSmrg	      # though. Also, the filter scales superlinearly with the number of
1007788de56ccSmrg	      # global variables. join(1) would be nice here, but unfortunately
1007888de56ccSmrg	      # isn't a blessed tool.
1007988de56ccSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
10080e9fcaa8aSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
1008188de56ccSmrg	      export_symbols=$output_objdir/$libname.def
1008288de56ccSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
1008388de56ccSmrg	    fi
10084862bcd1aSmrg	  }
100851ab64890Smrg
1008688de56ccSmrg	  libobjs=$output
1008788de56ccSmrg	  # Restore the value of output.
1008888de56ccSmrg	  output=$save_output
100891ab64890Smrg
1009088de56ccSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
1009188de56ccSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
1009288de56ccSmrg	    test "X$libobjs" = "X " && libobjs=
1009388de56ccSmrg	  fi
1009488de56ccSmrg	  # Expand the library linking commands again to reset the
1009588de56ccSmrg	  # value of $libobjs for piecewise linking.
100961ab64890Smrg
1009788de56ccSmrg	  # Do each of the archive commands.
10098862bcd1aSmrg	  if test yes = "$module" && test -n "$module_cmds"; then
1009988de56ccSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
1010088de56ccSmrg	      cmds=$module_expsym_cmds
1010188de56ccSmrg	    else
1010288de56ccSmrg	      cmds=$module_cmds
10103b4ee4795Smrg	    fi
10104b4ee4795Smrg	  else
1010588de56ccSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
1010688de56ccSmrg	      cmds=$archive_expsym_cmds
1010788de56ccSmrg	    else
1010888de56ccSmrg	      cmds=$archive_cmds
1010988de56ccSmrg	    fi
10110b4ee4795Smrg	  fi
1011188de56ccSmrg	fi
101121ab64890Smrg
1011388de56ccSmrg	if test -n "$delfiles"; then
1011488de56ccSmrg	  # Append the command to remove temporary files to $cmds.
1011588de56ccSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
1011688de56ccSmrg	fi
101171ab64890Smrg
1011888de56ccSmrg	# Add any objects from preloaded convenience libraries
1011988de56ccSmrg	if test -n "$dlprefiles"; then
10120862bcd1aSmrg	  gentop=$output_objdir/${outputname}x
10121e9fcaa8aSmrg	  func_append generated " $gentop"
101221ab64890Smrg
1012388de56ccSmrg	  func_extract_archives $gentop $dlprefiles
10124e9fcaa8aSmrg	  func_append libobjs " $func_extract_archives_result"
1012588de56ccSmrg	  test "X$libobjs" = "X " && libobjs=
1012688de56ccSmrg	fi
101271ab64890Smrg
10128862bcd1aSmrg	save_ifs=$IFS; IFS='~'
1012988de56ccSmrg	for cmd in $cmds; do
10130862bcd1aSmrg	  IFS=$sp$nl
1013188de56ccSmrg	  eval cmd=\"$cmd\"
10132862bcd1aSmrg	  IFS=$save_ifs
10133862bcd1aSmrg	  $opt_quiet || {
1013488de56ccSmrg	    func_quote_for_expand "$cmd"
1013588de56ccSmrg	    eval "func_echo $func_quote_for_expand_result"
1013688de56ccSmrg	  }
1013788de56ccSmrg	  $opt_dry_run || eval "$cmd" || {
1013888de56ccSmrg	    lt_exit=$?
101392e9c7c8cSmrg
1014088de56ccSmrg	    # Restore the uninstalled library and exit
10141862bcd1aSmrg	    if test relink = "$opt_mode"; then
1014288de56ccSmrg	      ( cd "$output_objdir" && \
1014388de56ccSmrg	        $RM "${realname}T" && \
1014488de56ccSmrg		$MV "${realname}U" "$realname" )
1014588de56ccSmrg	    fi
101462e9c7c8cSmrg
1014788de56ccSmrg	    exit $lt_exit
1014888de56ccSmrg	  }
1014988de56ccSmrg	done
10150862bcd1aSmrg	IFS=$save_ifs
101512e9c7c8cSmrg
1015288de56ccSmrg	# Restore the uninstalled library and exit
10153862bcd1aSmrg	if test relink = "$opt_mode"; then
1015488de56ccSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
101552e9c7c8cSmrg
1015688de56ccSmrg	  if test -n "$convenience"; then
1015788de56ccSmrg	    if test -z "$whole_archive_flag_spec"; then
1015888de56ccSmrg	      func_show_eval '${RM}r "$gentop"'
1015988de56ccSmrg	    fi
1016088de56ccSmrg	  fi
101612e9c7c8cSmrg
1016288de56ccSmrg	  exit $EXIT_SUCCESS
1016388de56ccSmrg	fi
1016488de56ccSmrg
1016588de56ccSmrg	# Create links to the real library.
1016688de56ccSmrg	for linkname in $linknames; do
1016788de56ccSmrg	  if test "$realname" != "$linkname"; then
1016888de56ccSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
10169b4ee4795Smrg	  fi
10170b4ee4795Smrg	done
101712e9c7c8cSmrg
1017288de56ccSmrg	# If -module or -export-dynamic was specified, set the dlname.
10173862bcd1aSmrg	if test yes = "$module" || test yes = "$export_dynamic"; then
1017488de56ccSmrg	  # On all known operating systems, these are identical.
10175862bcd1aSmrg	  dlname=$soname
1017688de56ccSmrg	fi
1017788de56ccSmrg      fi
101781ab64890Smrg      ;;
101791ab64890Smrg
1018088de56ccSmrg    obj)
10181862bcd1aSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
10182862bcd1aSmrg	func_warning "'-dlopen' is ignored for objects"
1018388de56ccSmrg      fi
10184b4ee4795Smrg
1018588de56ccSmrg      case " $deplibs" in
1018688de56ccSmrg      *\ -l* | *\ -L*)
10187862bcd1aSmrg	func_warning "'-l' and '-L' are ignored for objects" ;;
101882e9c7c8cSmrg      esac
101891ab64890Smrg
1019088de56ccSmrg      test -n "$rpath" && \
10191862bcd1aSmrg	func_warning "'-rpath' is ignored for objects"
1019288de56ccSmrg
1019388de56ccSmrg      test -n "$xrpath" && \
10194862bcd1aSmrg	func_warning "'-R' is ignored for objects"
101951ab64890Smrg
1019688de56ccSmrg      test -n "$vinfo" && \
10197862bcd1aSmrg	func_warning "'-version-info' is ignored for objects"
101982e9c7c8cSmrg
1019988de56ccSmrg      test -n "$release" && \
10200862bcd1aSmrg	func_warning "'-release' is ignored for objects"
1020188de56ccSmrg
1020288de56ccSmrg      case $output in
1020388de56ccSmrg      *.lo)
1020488de56ccSmrg	test -n "$objs$old_deplibs" && \
10205862bcd1aSmrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
1020688de56ccSmrg
1020788de56ccSmrg	libobj=$output
1020888de56ccSmrg	func_lo2o "$libobj"
1020988de56ccSmrg	obj=$func_lo2o_result
10210b4ee4795Smrg	;;
10211b4ee4795Smrg      *)
1021288de56ccSmrg	libobj=
10213862bcd1aSmrg	obj=$output
102141ab64890Smrg	;;
102152e9c7c8cSmrg      esac
102161ab64890Smrg
1021788de56ccSmrg      # Delete the old objects.
1021888de56ccSmrg      $opt_dry_run || $RM $obj $libobj
102191ab64890Smrg
1022088de56ccSmrg      # Objects from convenience libraries.  This assumes
1022188de56ccSmrg      # single-version convenience libraries.  Whenever we create
1022288de56ccSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
1022388de56ccSmrg      # the extraction.
1022488de56ccSmrg      reload_conv_objs=
1022588de56ccSmrg      gentop=
10226862bcd1aSmrg      # if reload_cmds runs $LD directly, get rid of -Wl from
10227862bcd1aSmrg      # whole_archive_flag_spec and hope we can get by with turning comma
10228862bcd1aSmrg      # into space.
10229862bcd1aSmrg      case $reload_cmds in
10230862bcd1aSmrg        *\$LD[\ \$]*) wl= ;;
10231862bcd1aSmrg      esac
1023288de56ccSmrg      if test -n "$convenience"; then
1023388de56ccSmrg	if test -n "$whole_archive_flag_spec"; then
1023488de56ccSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
10235862bcd1aSmrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
10236862bcd1aSmrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
1023788de56ccSmrg	else
10238862bcd1aSmrg	  gentop=$output_objdir/${obj}x
10239e9fcaa8aSmrg	  func_append generated " $gentop"
10240b4ee4795Smrg
1024188de56ccSmrg	  func_extract_archives $gentop $convenience
1024288de56ccSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
1024388de56ccSmrg	fi
10244b4ee4795Smrg      fi
10245b4ee4795Smrg
10246e9fcaa8aSmrg      # If we're not building shared, we need to use non_pic_objs
10247862bcd1aSmrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10248e9fcaa8aSmrg
1024988de56ccSmrg      # Create the old-style object.
10250862bcd1aSmrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10251b4ee4795Smrg
10252862bcd1aSmrg      output=$obj
1025388de56ccSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
10254b4ee4795Smrg
1025588de56ccSmrg      # Exit if we aren't doing a library object file.
1025688de56ccSmrg      if test -z "$libobj"; then
1025788de56ccSmrg	if test -n "$gentop"; then
1025888de56ccSmrg	  func_show_eval '${RM}r "$gentop"'
1025988de56ccSmrg	fi
1026088de56ccSmrg
1026188de56ccSmrg	exit $EXIT_SUCCESS
10262b4ee4795Smrg      fi
1026388de56ccSmrg
10264862bcd1aSmrg      test yes = "$build_libtool_libs" || {
1026588de56ccSmrg	if test -n "$gentop"; then
1026688de56ccSmrg	  func_show_eval '${RM}r "$gentop"'
1026788de56ccSmrg	fi
1026888de56ccSmrg
1026988de56ccSmrg	# Create an invalid libtool object if no PIC, so that we don't
1027088de56ccSmrg	# accidentally link it into a program.
1027188de56ccSmrg	# $show "echo timestamp > $libobj"
1027288de56ccSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
1027388de56ccSmrg	exit $EXIT_SUCCESS
10274862bcd1aSmrg      }
1027588de56ccSmrg
10276862bcd1aSmrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
1027788de56ccSmrg	# Only do commands if we really have different PIC objects.
1027888de56ccSmrg	reload_objs="$libobjs $reload_conv_objs"
10279862bcd1aSmrg	output=$libobj
1028088de56ccSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
1028188de56ccSmrg      fi
1028288de56ccSmrg
1028388de56ccSmrg      if test -n "$gentop"; then
1028488de56ccSmrg	func_show_eval '${RM}r "$gentop"'
1028588de56ccSmrg      fi
1028688de56ccSmrg
1028788de56ccSmrg      exit $EXIT_SUCCESS
10288b4ee4795Smrg      ;;
102891ab64890Smrg
1029088de56ccSmrg    prog)
1029188de56ccSmrg      case $host in
1029288de56ccSmrg	*cygwin*) func_stripname '' '.exe' "$output"
1029388de56ccSmrg	          output=$func_stripname_result.exe;;
1029488de56ccSmrg      esac
1029588de56ccSmrg      test -n "$vinfo" && \
10296862bcd1aSmrg	func_warning "'-version-info' is ignored for programs"
102971ab64890Smrg
1029888de56ccSmrg      test -n "$release" && \
10299862bcd1aSmrg	func_warning "'-release' is ignored for programs"
103001ab64890Smrg
10301862bcd1aSmrg      $preload \
10302862bcd1aSmrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
10303862bcd1aSmrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
1030488de56ccSmrg
1030588de56ccSmrg      case $host in
1030688de56ccSmrg      *-*-rhapsody* | *-*-darwin1.[012])
1030788de56ccSmrg	# On Rhapsody replace the C library is the System framework
10308e9fcaa8aSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10309e9fcaa8aSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10310b4ee4795Smrg	;;
1031188de56ccSmrg      esac
10312b4ee4795Smrg
1031388de56ccSmrg      case $host in
1031488de56ccSmrg      *-*-darwin*)
1031588de56ccSmrg	# Don't allow lazy linking, it breaks C++ global constructors
1031688de56ccSmrg	# But is supposedly fixed on 10.4 or later (yay!).
10317862bcd1aSmrg	if test CXX = "$tagname"; then
1031888de56ccSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
1031988de56ccSmrg	    10.[0123])
10320862bcd1aSmrg	      func_append compile_command " $wl-bind_at_load"
10321862bcd1aSmrg	      func_append finalize_command " $wl-bind_at_load"
1032288de56ccSmrg	    ;;
1032388de56ccSmrg	  esac
10324b4ee4795Smrg	fi
1032588de56ccSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
10326e9fcaa8aSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10327e9fcaa8aSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
1032888de56ccSmrg	;;
1032988de56ccSmrg      esac
10330b4ee4795Smrg
10331b4ee4795Smrg
1033288de56ccSmrg      # move library search paths that coincide with paths to not yet
1033388de56ccSmrg      # installed libraries to the beginning of the library search list
1033488de56ccSmrg      new_libs=
1033588de56ccSmrg      for path in $notinst_path; do
1033688de56ccSmrg	case " $new_libs " in
1033788de56ccSmrg	*" -L$path/$objdir "*) ;;
1033888de56ccSmrg	*)
1033988de56ccSmrg	  case " $compile_deplibs " in
1034088de56ccSmrg	  *" -L$path/$objdir "*)
10341e9fcaa8aSmrg	    func_append new_libs " -L$path/$objdir" ;;
103422e9c7c8cSmrg	  esac
1034388de56ccSmrg	  ;;
1034488de56ccSmrg	esac
1034588de56ccSmrg      done
1034688de56ccSmrg      for deplib in $compile_deplibs; do
1034788de56ccSmrg	case $deplib in
1034888de56ccSmrg	-L*)
1034988de56ccSmrg	  case " $new_libs " in
1035088de56ccSmrg	  *" $deplib "*) ;;
10351e9fcaa8aSmrg	  *) func_append new_libs " $deplib" ;;
103522e9c7c8cSmrg	  esac
1035388de56ccSmrg	  ;;
10354e9fcaa8aSmrg	*) func_append new_libs " $deplib" ;;
1035588de56ccSmrg	esac
1035688de56ccSmrg      done
10357862bcd1aSmrg      compile_deplibs=$new_libs
103581ab64890Smrg
10359b4ee4795Smrg
10360e9fcaa8aSmrg      func_append compile_command " $compile_deplibs"
10361e9fcaa8aSmrg      func_append finalize_command " $finalize_deplibs"
10362b4ee4795Smrg
1036388de56ccSmrg      if test -n "$rpath$xrpath"; then
1036488de56ccSmrg	# If the user specified any rpath flags, then add them.
1036588de56ccSmrg	for libdir in $rpath $xrpath; do
1036688de56ccSmrg	  # This is the magic to use -rpath.
1036788de56ccSmrg	  case "$finalize_rpath " in
1036888de56ccSmrg	  *" $libdir "*) ;;
10369e9fcaa8aSmrg	  *) func_append finalize_rpath " $libdir" ;;
1037088de56ccSmrg	  esac
1037188de56ccSmrg	done
1037288de56ccSmrg      fi
10373b4ee4795Smrg
1037488de56ccSmrg      # Now hardcode the library paths
1037588de56ccSmrg      rpath=
1037688de56ccSmrg      hardcode_libdirs=
1037788de56ccSmrg      for libdir in $compile_rpath $finalize_rpath; do
1037888de56ccSmrg	if test -n "$hardcode_libdir_flag_spec"; then
1037988de56ccSmrg	  if test -n "$hardcode_libdir_separator"; then
1038088de56ccSmrg	    if test -z "$hardcode_libdirs"; then
10381862bcd1aSmrg	      hardcode_libdirs=$libdir
1038288de56ccSmrg	    else
1038388de56ccSmrg	      # Just accumulate the unique libdirs.
1038488de56ccSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
1038588de56ccSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
1038688de56ccSmrg		;;
1038788de56ccSmrg	      *)
10388e9fcaa8aSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
1038988de56ccSmrg		;;
1039088de56ccSmrg	      esac
1039188de56ccSmrg	    fi
10392b4ee4795Smrg	  else
1039388de56ccSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10394e9fcaa8aSmrg	    func_append rpath " $flag"
10395b4ee4795Smrg	  fi
1039688de56ccSmrg	elif test -n "$runpath_var"; then
1039788de56ccSmrg	  case "$perm_rpath " in
1039888de56ccSmrg	  *" $libdir "*) ;;
10399e9fcaa8aSmrg	  *) func_append perm_rpath " $libdir" ;;
1040088de56ccSmrg	  esac
1040188de56ccSmrg	fi
1040288de56ccSmrg	case $host in
1040388de56ccSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
10404862bcd1aSmrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
1040588de56ccSmrg	  case :$dllsearchpath: in
1040688de56ccSmrg	  *":$libdir:"*) ;;
1040788de56ccSmrg	  ::) dllsearchpath=$libdir;;
10408e9fcaa8aSmrg	  *) func_append dllsearchpath ":$libdir";;
1040988de56ccSmrg	  esac
1041088de56ccSmrg	  case :$dllsearchpath: in
1041188de56ccSmrg	  *":$testbindir:"*) ;;
1041288de56ccSmrg	  ::) dllsearchpath=$testbindir;;
10413e9fcaa8aSmrg	  *) func_append dllsearchpath ":$testbindir";;
1041488de56ccSmrg	  esac
1041588de56ccSmrg	  ;;
1041688de56ccSmrg	esac
1041788de56ccSmrg      done
1041888de56ccSmrg      # Substitute the hardcoded libdirs into the rpath.
1041988de56ccSmrg      if test -n "$hardcode_libdir_separator" &&
1042088de56ccSmrg	 test -n "$hardcode_libdirs"; then
10421862bcd1aSmrg	libdir=$hardcode_libdirs
1042288de56ccSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
1042388de56ccSmrg      fi
10424862bcd1aSmrg      compile_rpath=$rpath
10425b4ee4795Smrg
1042688de56ccSmrg      rpath=
1042788de56ccSmrg      hardcode_libdirs=
1042888de56ccSmrg      for libdir in $finalize_rpath; do
1042988de56ccSmrg	if test -n "$hardcode_libdir_flag_spec"; then
1043088de56ccSmrg	  if test -n "$hardcode_libdir_separator"; then
1043188de56ccSmrg	    if test -z "$hardcode_libdirs"; then
10432862bcd1aSmrg	      hardcode_libdirs=$libdir
1043388de56ccSmrg	    else
1043488de56ccSmrg	      # Just accumulate the unique libdirs.
1043588de56ccSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
1043688de56ccSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
1043788de56ccSmrg		;;
1043888de56ccSmrg	      *)
10439e9fcaa8aSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
1044088de56ccSmrg		;;
1044188de56ccSmrg	      esac
1044288de56ccSmrg	    fi
104431ab64890Smrg	  else
1044488de56ccSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10445e9fcaa8aSmrg	    func_append rpath " $flag"
104461ab64890Smrg	  fi
1044788de56ccSmrg	elif test -n "$runpath_var"; then
1044888de56ccSmrg	  case "$finalize_perm_rpath " in
1044988de56ccSmrg	  *" $libdir "*) ;;
10450e9fcaa8aSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
1045188de56ccSmrg	  esac
104521ab64890Smrg	fi
1045388de56ccSmrg      done
1045488de56ccSmrg      # Substitute the hardcoded libdirs into the rpath.
1045588de56ccSmrg      if test -n "$hardcode_libdir_separator" &&
1045688de56ccSmrg	 test -n "$hardcode_libdirs"; then
10457862bcd1aSmrg	libdir=$hardcode_libdirs
1045888de56ccSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
1045988de56ccSmrg      fi
10460862bcd1aSmrg      finalize_rpath=$rpath
104611ab64890Smrg
10462862bcd1aSmrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
1046388de56ccSmrg	# Transform all the library objects into standard objects.
10464e9fcaa8aSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10465e9fcaa8aSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
1046688de56ccSmrg      fi
104671ab64890Smrg
10468862bcd1aSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
104691ab64890Smrg
1047088de56ccSmrg      # template prelinking step
1047188de56ccSmrg      if test -n "$prelink_cmds"; then
1047288de56ccSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
1047388de56ccSmrg      fi
104741ab64890Smrg
10475862bcd1aSmrg      wrappers_required=:
1047688de56ccSmrg      case $host in
10477e9fcaa8aSmrg      *cegcc* | *mingw32ce*)
10478e9fcaa8aSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
10479862bcd1aSmrg        wrappers_required=false
10480e9fcaa8aSmrg        ;;
1048188de56ccSmrg      *cygwin* | *mingw* )
10482862bcd1aSmrg        test yes = "$build_libtool_libs" || wrappers_required=false
1048388de56ccSmrg        ;;
1048488de56ccSmrg      *)
10485862bcd1aSmrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
10486862bcd1aSmrg          wrappers_required=false
1048788de56ccSmrg        fi
1048888de56ccSmrg        ;;
1048988de56ccSmrg      esac
10490862bcd1aSmrg      $wrappers_required || {
1049188de56ccSmrg	# Replace the output file specification.
10492e9fcaa8aSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10493862bcd1aSmrg	link_command=$compile_command$compile_rpath
104941ab64890Smrg
1049588de56ccSmrg	# We have no uninstalled library dependencies, so finalize right now.
1049688de56ccSmrg	exit_status=0
1049788de56ccSmrg	func_show_eval "$link_command" 'exit_status=$?'
104981ab64890Smrg
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
1050588de56ccSmrg	# Delete the generated files.
10506862bcd1aSmrg	if test -f "$output_objdir/${outputname}S.$objext"; then
10507862bcd1aSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
105081ab64890Smrg	fi
105091ab64890Smrg
1051088de56ccSmrg	exit $exit_status
10511862bcd1aSmrg      }
105121ab64890Smrg
1051388de56ccSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
1051488de56ccSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
1051588de56ccSmrg      fi
1051688de56ccSmrg      if test -n "$finalize_shlibpath"; then
1051788de56ccSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
1051888de56ccSmrg      fi
10519b4ee4795Smrg
1052088de56ccSmrg      compile_var=
1052188de56ccSmrg      finalize_var=
1052288de56ccSmrg      if test -n "$runpath_var"; then
1052388de56ccSmrg	if test -n "$perm_rpath"; then
1052488de56ccSmrg	  # We should set the runpath_var.
1052588de56ccSmrg	  rpath=
1052688de56ccSmrg	  for dir in $perm_rpath; do
10527e9fcaa8aSmrg	    func_append rpath "$dir:"
1052888de56ccSmrg	  done
1052988de56ccSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
105301ab64890Smrg	fi
1053188de56ccSmrg	if test -n "$finalize_perm_rpath"; then
1053288de56ccSmrg	  # We should set the runpath_var.
1053388de56ccSmrg	  rpath=
1053488de56ccSmrg	  for dir in $finalize_perm_rpath; do
10535e9fcaa8aSmrg	    func_append rpath "$dir:"
1053688de56ccSmrg	  done
1053788de56ccSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
105381ab64890Smrg	fi
1053988de56ccSmrg      fi
105401ab64890Smrg
10541862bcd1aSmrg      if test yes = "$no_install"; then
1054288de56ccSmrg	# We don't need to create a wrapper script.
10543862bcd1aSmrg	link_command=$compile_var$compile_command$compile_rpath
1054488de56ccSmrg	# Replace the output file specification.
10545e9fcaa8aSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
1054688de56ccSmrg	# Delete the old output file.
1054788de56ccSmrg	$opt_dry_run || $RM $output
1054888de56ccSmrg	# Link the executable and exit
1054988de56ccSmrg	func_show_eval "$link_command" 'exit $?'
10550e9fcaa8aSmrg
10551e9fcaa8aSmrg	if test -n "$postlink_cmds"; then
10552e9fcaa8aSmrg	  func_to_tool_file "$output"
10553e9fcaa8aSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10554e9fcaa8aSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10555e9fcaa8aSmrg	fi
10556e9fcaa8aSmrg
10557b4ee4795Smrg	exit $EXIT_SUCCESS
1055888de56ccSmrg      fi
105592e9c7c8cSmrg
10560862bcd1aSmrg      case $hardcode_action,$fast_install in
10561862bcd1aSmrg        relink,*)
10562862bcd1aSmrg	  # Fast installation is not supported
10563862bcd1aSmrg	  link_command=$compile_var$compile_command$compile_rpath
10564862bcd1aSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
1056588de56ccSmrg
10566862bcd1aSmrg	  func_warning "this platform does not like uninstalled shared libraries"
10567862bcd1aSmrg	  func_warning "'$output' will be relinked during installation"
10568862bcd1aSmrg	  ;;
10569862bcd1aSmrg        *,yes)
10570862bcd1aSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
10571862bcd1aSmrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
10572862bcd1aSmrg          ;;
10573862bcd1aSmrg	*,no)
10574862bcd1aSmrg	  link_command=$compile_var$compile_command$compile_rpath
10575862bcd1aSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10576862bcd1aSmrg          ;;
10577862bcd1aSmrg	*,needless)
10578862bcd1aSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
10579862bcd1aSmrg	  relink_command=
10580862bcd1aSmrg          ;;
10581862bcd1aSmrg      esac
105821ab64890Smrg
1058388de56ccSmrg      # Replace the output file specification.
10584e9fcaa8aSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
105851ab64890Smrg
1058688de56ccSmrg      # Delete the old output files.
1058788de56ccSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
105881ab64890Smrg
1058988de56ccSmrg      func_show_eval "$link_command" 'exit $?'
10590b4ee4795Smrg
10591e9fcaa8aSmrg      if test -n "$postlink_cmds"; then
10592e9fcaa8aSmrg	func_to_tool_file "$output_objdir/$outputname"
10593e9fcaa8aSmrg	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'`
10594e9fcaa8aSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
10595e9fcaa8aSmrg      fi
10596e9fcaa8aSmrg
1059788de56ccSmrg      # Now create the wrapper script.
1059888de56ccSmrg      func_verbose "creating $output"
10599b4ee4795Smrg
1060088de56ccSmrg      # Quote the relink command for shipping.
1060188de56ccSmrg      if test -n "$relink_command"; then
1060288de56ccSmrg	# Preserve any variables that may affect compiler behavior
1060388de56ccSmrg	for var in $variables_saved_for_relink; do
1060488de56ccSmrg	  if eval test -z \"\${$var+set}\"; then
1060588de56ccSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
1060688de56ccSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
1060788de56ccSmrg	    relink_command="$var=; export $var; $relink_command"
106081ab64890Smrg	  else
1060988de56ccSmrg	    func_quote_for_eval "$var_value"
1061088de56ccSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
106111ab64890Smrg	  fi
1061288de56ccSmrg	done
106135afda2e6Smrg	relink_command="(cd `pwd`; $relink_command)"
106145afda2e6Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
1061588de56ccSmrg      fi
1061688de56ccSmrg
1061788de56ccSmrg      # Only actually do things if not in dry run mode.
1061888de56ccSmrg      $opt_dry_run || {
1061988de56ccSmrg	# win32 will think the script is a binary if it has
1062088de56ccSmrg	# a .exe suffix, so we strip it off here.
1062188de56ccSmrg	case $output in
1062288de56ccSmrg	  *.exe) func_stripname '' '.exe' "$output"
1062388de56ccSmrg	         output=$func_stripname_result ;;
1062488de56ccSmrg	esac
1062588de56ccSmrg	# test for cygwin because mv fails w/o .exe extensions
1062688de56ccSmrg	case $host in
1062788de56ccSmrg	  *cygwin*)
1062888de56ccSmrg	    exeext=.exe
1062988de56ccSmrg	    func_stripname '' '.exe' "$outputname"
1063088de56ccSmrg	    outputname=$func_stripname_result ;;
1063188de56ccSmrg	  *) exeext= ;;
106321ab64890Smrg	esac
1063388de56ccSmrg	case $host in
1063488de56ccSmrg	  *cygwin* | *mingw* )
1063588de56ccSmrg	    func_dirname_and_basename "$output" "" "."
1063688de56ccSmrg	    output_name=$func_basename_result
1063788de56ccSmrg	    output_path=$func_dirname_result
10638862bcd1aSmrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
10639862bcd1aSmrg	    cwrapper=$output_path/$output_name.exe
1064088de56ccSmrg	    $RM $cwrappersource $cwrapper
1064188de56ccSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
1064288de56ccSmrg
1064388de56ccSmrg	    func_emit_cwrapperexe_src > $cwrappersource
1064488de56ccSmrg
1064588de56ccSmrg	    # The wrapper executable is built using the $host compiler,
1064688de56ccSmrg	    # because it contains $host paths and files. If cross-
1064788de56ccSmrg	    # compiling, it, like the target executable, must be
1064888de56ccSmrg	    # executed on the $host or under an emulation environment.
1064988de56ccSmrg	    $opt_dry_run || {
1065088de56ccSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
1065188de56ccSmrg	      $STRIP $cwrapper
1065288de56ccSmrg	    }
106531ab64890Smrg
1065488de56ccSmrg	    # Now, create the wrapper script for func_source use:
1065588de56ccSmrg	    func_ltwrapper_scriptname $cwrapper
1065688de56ccSmrg	    $RM $func_ltwrapper_scriptname_result
1065788de56ccSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
1065888de56ccSmrg	    $opt_dry_run || {
1065988de56ccSmrg	      # note: this script will not be executed, so do not chmod.
10660862bcd1aSmrg	      if test "x$build" = "x$host"; then
1066188de56ccSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
1066288de56ccSmrg	      else
1066388de56ccSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
1066488de56ccSmrg	      fi
1066588de56ccSmrg	    }
1066688de56ccSmrg	  ;;
1066788de56ccSmrg	  * )
1066888de56ccSmrg	    $RM $output
1066988de56ccSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
106701ab64890Smrg
1067188de56ccSmrg	    func_emit_wrapper no > $output
1067288de56ccSmrg	    chmod +x $output
1067388de56ccSmrg	  ;;
1067488de56ccSmrg	esac
1067588de56ccSmrg      }
1067688de56ccSmrg      exit $EXIT_SUCCESS
1067788de56ccSmrg      ;;
1067888de56ccSmrg    esac
106791ab64890Smrg
1068088de56ccSmrg    # See if we need to build an old-fashioned archive.
1068188de56ccSmrg    for oldlib in $oldlibs; do
106821ab64890Smrg
10683862bcd1aSmrg      case $build_libtool_libs in
10684862bcd1aSmrg        convenience)
10685862bcd1aSmrg	  oldobjs="$libobjs_save $symfileobj"
10686862bcd1aSmrg	  addlibs=$convenience
1068788de56ccSmrg	  build_libtool_libs=no
10688862bcd1aSmrg	  ;;
10689862bcd1aSmrg	module)
10690862bcd1aSmrg	  oldobjs=$libobjs_save
10691862bcd1aSmrg	  addlibs=$old_convenience
10692862bcd1aSmrg	  build_libtool_libs=no
10693862bcd1aSmrg          ;;
10694862bcd1aSmrg	*)
1069588de56ccSmrg	  oldobjs="$old_deplibs $non_pic_objects"
10696862bcd1aSmrg	  $preload && test -f "$symfileobj" \
10697862bcd1aSmrg	    && func_append oldobjs " $symfileobj"
10698862bcd1aSmrg	  addlibs=$old_convenience
10699862bcd1aSmrg	  ;;
10700862bcd1aSmrg      esac
107011ab64890Smrg
1070288de56ccSmrg      if test -n "$addlibs"; then
10703862bcd1aSmrg	gentop=$output_objdir/${outputname}x
10704e9fcaa8aSmrg	func_append generated " $gentop"
107051ab64890Smrg
1070688de56ccSmrg	func_extract_archives $gentop $addlibs
10707e9fcaa8aSmrg	func_append oldobjs " $func_extract_archives_result"
1070888de56ccSmrg      fi
107091ab64890Smrg
1071088de56ccSmrg      # Do each command in the archive commands.
10711862bcd1aSmrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
1071288de56ccSmrg	cmds=$old_archive_from_new_cmds
1071388de56ccSmrg      else
107141ab64890Smrg
1071588de56ccSmrg	# Add any objects from preloaded convenience libraries
1071688de56ccSmrg	if test -n "$dlprefiles"; then
10717862bcd1aSmrg	  gentop=$output_objdir/${outputname}x
10718e9fcaa8aSmrg	  func_append generated " $gentop"
107191ab64890Smrg
1072088de56ccSmrg	  func_extract_archives $gentop $dlprefiles
10721e9fcaa8aSmrg	  func_append oldobjs " $func_extract_archives_result"
1072288de56ccSmrg	fi
107231ab64890Smrg
1072488de56ccSmrg	# POSIX demands no paths to be encoded in archives.  We have
1072588de56ccSmrg	# to avoid creating archives with duplicate basenames if we
1072688de56ccSmrg	# might have to extract them afterwards, e.g., when creating a
1072788de56ccSmrg	# static archive out of a convenience library, or when linking
1072888de56ccSmrg	# the entirety of a libtool archive into another (currently
1072988de56ccSmrg	# not supported by libtool).
1073088de56ccSmrg	if (for obj in $oldobjs
1073188de56ccSmrg	    do
1073288de56ccSmrg	      func_basename "$obj"
1073388de56ccSmrg	      $ECHO "$func_basename_result"
1073488de56ccSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
1073588de56ccSmrg	  :
1073688de56ccSmrg	else
10737e9fcaa8aSmrg	  echo "copying selected object files to avoid basename conflicts..."
10738862bcd1aSmrg	  gentop=$output_objdir/${outputname}x
10739e9fcaa8aSmrg	  func_append generated " $gentop"
1074088de56ccSmrg	  func_mkdir_p "$gentop"
1074188de56ccSmrg	  save_oldobjs=$oldobjs
1074288de56ccSmrg	  oldobjs=
1074388de56ccSmrg	  counter=1
1074488de56ccSmrg	  for obj in $save_oldobjs
1074588de56ccSmrg	  do
1074688de56ccSmrg	    func_basename "$obj"
10747862bcd1aSmrg	    objbase=$func_basename_result
1074888de56ccSmrg	    case " $oldobjs " in
1074988de56ccSmrg	    " ") oldobjs=$obj ;;
1075088de56ccSmrg	    *[\ /]"$objbase "*)
1075188de56ccSmrg	      while :; do
1075288de56ccSmrg		# Make sure we don't pick an alternate name that also
1075388de56ccSmrg		# overlaps.
1075488de56ccSmrg		newobj=lt$counter-$objbase
1075588de56ccSmrg		func_arith $counter + 1
1075688de56ccSmrg		counter=$func_arith_result
1075788de56ccSmrg		case " $oldobjs " in
1075888de56ccSmrg		*[\ /]"$newobj "*) ;;
1075988de56ccSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
1076088de56ccSmrg		esac
1076188de56ccSmrg	      done
1076288de56ccSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10763e9fcaa8aSmrg	      func_append oldobjs " $gentop/$newobj"
1076488de56ccSmrg	      ;;
10765e9fcaa8aSmrg	    *) func_append oldobjs " $obj" ;;
1076688de56ccSmrg	    esac
107671ab64890Smrg	  done
107682e9c7c8cSmrg	fi
10769eb411b4bSmrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10770eb411b4bSmrg	tool_oldlib=$func_to_tool_file_result
1077188de56ccSmrg	eval cmds=\"$old_archive_cmds\"
10772b4ee4795Smrg
1077388de56ccSmrg	func_len " $cmds"
1077488de56ccSmrg	len=$func_len_result
1077588de56ccSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
1077688de56ccSmrg	  cmds=$old_archive_cmds
10777e9fcaa8aSmrg	elif test -n "$archiver_list_spec"; then
10778e9fcaa8aSmrg	  func_verbose "using command file archive linking..."
10779e9fcaa8aSmrg	  for obj in $oldobjs
10780e9fcaa8aSmrg	  do
10781e9fcaa8aSmrg	    func_to_tool_file "$obj"
10782e9fcaa8aSmrg	    $ECHO "$func_to_tool_file_result"
10783e9fcaa8aSmrg	  done > $output_objdir/$libname.libcmd
10784e9fcaa8aSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
10785e9fcaa8aSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10786e9fcaa8aSmrg	  cmds=$old_archive_cmds
1078788de56ccSmrg	else
1078888de56ccSmrg	  # the command line is too long to link in one step, link in parts
1078988de56ccSmrg	  func_verbose "using piecewise archive linking..."
1079088de56ccSmrg	  save_RANLIB=$RANLIB
1079188de56ccSmrg	  RANLIB=:
1079288de56ccSmrg	  objlist=
1079388de56ccSmrg	  concat_cmds=
1079488de56ccSmrg	  save_oldobjs=$oldobjs
1079588de56ccSmrg	  oldobjs=
1079688de56ccSmrg	  # Is there a better way of finding the last object in the list?
1079788de56ccSmrg	  for obj in $save_oldobjs
1079888de56ccSmrg	  do
1079988de56ccSmrg	    last_oldobj=$obj
1080088de56ccSmrg	  done
1080188de56ccSmrg	  eval test_cmds=\"$old_archive_cmds\"
1080288de56ccSmrg	  func_len " $test_cmds"
1080388de56ccSmrg	  len0=$func_len_result
1080488de56ccSmrg	  len=$len0
1080588de56ccSmrg	  for obj in $save_oldobjs
1080688de56ccSmrg	  do
1080788de56ccSmrg	    func_len " $obj"
1080888de56ccSmrg	    func_arith $len + $func_len_result
1080988de56ccSmrg	    len=$func_arith_result
1081088de56ccSmrg	    func_append objlist " $obj"
1081188de56ccSmrg	    if test "$len" -lt "$max_cmd_len"; then
1081288de56ccSmrg	      :
1081388de56ccSmrg	    else
1081488de56ccSmrg	      # the above command should be used before it gets too long
1081588de56ccSmrg	      oldobjs=$objlist
10816862bcd1aSmrg	      if test "$obj" = "$last_oldobj"; then
1081788de56ccSmrg		RANLIB=$save_RANLIB
1081888de56ccSmrg	      fi
1081988de56ccSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10820862bcd1aSmrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
1082188de56ccSmrg	      objlist=
1082288de56ccSmrg	      len=$len0
1082388de56ccSmrg	    fi
1082488de56ccSmrg	  done
1082588de56ccSmrg	  RANLIB=$save_RANLIB
1082688de56ccSmrg	  oldobjs=$objlist
10827862bcd1aSmrg	  if test -z "$oldobjs"; then
1082888de56ccSmrg	    eval cmds=\"\$concat_cmds\"
1082988de56ccSmrg	  else
1083088de56ccSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
1083188de56ccSmrg	  fi
1083288de56ccSmrg	fi
1083388de56ccSmrg      fi
1083488de56ccSmrg      func_execute_cmds "$cmds" 'exit $?'
108351ab64890Smrg    done
108361ab64890Smrg
1083788de56ccSmrg    test -n "$generated" && \
1083888de56ccSmrg      func_show_eval "${RM}r$generated"
108391ab64890Smrg
1084088de56ccSmrg    # Now create the libtool archive.
1084188de56ccSmrg    case $output in
1084288de56ccSmrg    *.la)
1084388de56ccSmrg      old_library=
10844862bcd1aSmrg      test yes = "$build_old_libs" && old_library=$libname.$libext
1084588de56ccSmrg      func_verbose "creating $output"
108462e9c7c8cSmrg
1084788de56ccSmrg      # Preserve any variables that may affect compiler behavior
1084888de56ccSmrg      for var in $variables_saved_for_relink; do
1084988de56ccSmrg	if eval test -z \"\${$var+set}\"; then
1085088de56ccSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
1085188de56ccSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
1085288de56ccSmrg	  relink_command="$var=; export $var; $relink_command"
10853b4ee4795Smrg	else
1085488de56ccSmrg	  func_quote_for_eval "$var_value"
1085588de56ccSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10856b4ee4795Smrg	fi
1085788de56ccSmrg      done
1085888de56ccSmrg      # Quote the link command for shipping.
10859862bcd1aSmrg      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
108605afda2e6Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10861862bcd1aSmrg      if test yes = "$hardcode_automatic"; then
1086288de56ccSmrg	relink_command=
1086388de56ccSmrg      fi
108641ab64890Smrg
1086588de56ccSmrg      # Only create the output if not a dry run.
1086688de56ccSmrg      $opt_dry_run || {
1086788de56ccSmrg	for installed in no yes; do
10868862bcd1aSmrg	  if test yes = "$installed"; then
1086988de56ccSmrg	    if test -z "$install_libdir"; then
1087088de56ccSmrg	      break
1087188de56ccSmrg	    fi
10872862bcd1aSmrg	    output=$output_objdir/${outputname}i
1087388de56ccSmrg	    # Replace all uninstalled libtool libraries with the installed ones
1087488de56ccSmrg	    newdependency_libs=
1087588de56ccSmrg	    for deplib in $dependency_libs; do
1087688de56ccSmrg	      case $deplib in
1087788de56ccSmrg	      *.la)
1087888de56ccSmrg		func_basename "$deplib"
10879862bcd1aSmrg		name=$func_basename_result
10880eb411b4bSmrg		func_resolve_sysroot "$deplib"
10881862bcd1aSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
1088288de56ccSmrg		test -z "$libdir" && \
10883862bcd1aSmrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
10884e9fcaa8aSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10885e9fcaa8aSmrg		;;
10886e9fcaa8aSmrg	      -L*)
10887e9fcaa8aSmrg		func_stripname -L '' "$deplib"
10888e9fcaa8aSmrg		func_replace_sysroot "$func_stripname_result"
10889e9fcaa8aSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
1089088de56ccSmrg		;;
10891e9fcaa8aSmrg	      -R*)
10892e9fcaa8aSmrg		func_stripname -R '' "$deplib"
10893e9fcaa8aSmrg		func_replace_sysroot "$func_stripname_result"
10894e9fcaa8aSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
10895e9fcaa8aSmrg		;;
10896e9fcaa8aSmrg	      *) func_append newdependency_libs " $deplib" ;;
1089788de56ccSmrg	      esac
1089888de56ccSmrg	    done
10899862bcd1aSmrg	    dependency_libs=$newdependency_libs
1090088de56ccSmrg	    newdlfiles=
1090188de56ccSmrg
1090288de56ccSmrg	    for lib in $dlfiles; do
1090388de56ccSmrg	      case $lib in
1090488de56ccSmrg	      *.la)
1090588de56ccSmrg	        func_basename "$lib"
10906862bcd1aSmrg		name=$func_basename_result
10907862bcd1aSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
1090888de56ccSmrg		test -z "$libdir" && \
10909862bcd1aSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10910e9fcaa8aSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
1091188de56ccSmrg		;;
10912e9fcaa8aSmrg	      *) func_append newdlfiles " $lib" ;;
1091388de56ccSmrg	      esac
1091488de56ccSmrg	    done
10915862bcd1aSmrg	    dlfiles=$newdlfiles
1091688de56ccSmrg	    newdlprefiles=
1091788de56ccSmrg	    for lib in $dlprefiles; do
1091888de56ccSmrg	      case $lib in
1091988de56ccSmrg	      *.la)
1092088de56ccSmrg		# Only pass preopened files to the pseudo-archive (for
1092188de56ccSmrg		# eventual linking with the app. that links it) if we
1092288de56ccSmrg		# didn't already link the preopened objects directly into
1092388de56ccSmrg		# the library:
1092488de56ccSmrg		func_basename "$lib"
10925862bcd1aSmrg		name=$func_basename_result
10926862bcd1aSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
1092788de56ccSmrg		test -z "$libdir" && \
10928862bcd1aSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10929e9fcaa8aSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
1093088de56ccSmrg		;;
1093188de56ccSmrg	      esac
1093288de56ccSmrg	    done
10933862bcd1aSmrg	    dlprefiles=$newdlprefiles
1093488de56ccSmrg	  else
1093588de56ccSmrg	    newdlfiles=
1093688de56ccSmrg	    for lib in $dlfiles; do
1093788de56ccSmrg	      case $lib in
10938862bcd1aSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
1093988de56ccSmrg		*) abs=`pwd`"/$lib" ;;
1094088de56ccSmrg	      esac
10941e9fcaa8aSmrg	      func_append newdlfiles " $abs"
1094288de56ccSmrg	    done
10943862bcd1aSmrg	    dlfiles=$newdlfiles
1094488de56ccSmrg	    newdlprefiles=
1094588de56ccSmrg	    for lib in $dlprefiles; do
1094688de56ccSmrg	      case $lib in
10947862bcd1aSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
1094888de56ccSmrg		*) abs=`pwd`"/$lib" ;;
1094988de56ccSmrg	      esac
10950e9fcaa8aSmrg	      func_append newdlprefiles " $abs"
1095188de56ccSmrg	    done
10952862bcd1aSmrg	    dlprefiles=$newdlprefiles
1095388de56ccSmrg	  fi
1095488de56ccSmrg	  $RM $output
1095588de56ccSmrg	  # place dlname in correct position for cygwin
10956e9fcaa8aSmrg	  # In fact, it would be nice if we could use this code for all target
10957e9fcaa8aSmrg	  # systems that can't hard-code library paths into their executables
10958e9fcaa8aSmrg	  # and that have no shared library path variable independent of PATH,
10959e9fcaa8aSmrg	  # but it turns out we can't easily determine that from inspecting
10960e9fcaa8aSmrg	  # libtool variables, so we have to hard-code the OSs to which it
10961e9fcaa8aSmrg	  # applies here; at the moment, that means platforms that use the PE
10962e9fcaa8aSmrg	  # object format with DLL files.  See the long comment at the top of
10963e9fcaa8aSmrg	  # tests/bindir.at for full details.
1096488de56ccSmrg	  tdlname=$dlname
1096588de56ccSmrg	  case $host,$output,$installed,$module,$dlname in
10966e9fcaa8aSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10967e9fcaa8aSmrg	      # If a -bindir argument was supplied, place the dll there.
10968862bcd1aSmrg	      if test -n "$bindir"; then
10969e9fcaa8aSmrg		func_relative_path "$install_libdir" "$bindir"
10970862bcd1aSmrg		tdlname=$func_relative_path_result/$dlname
10971e9fcaa8aSmrg	      else
10972e9fcaa8aSmrg		# Otherwise fall back on heuristic.
10973e9fcaa8aSmrg		tdlname=../bin/$dlname
10974e9fcaa8aSmrg	      fi
10975e9fcaa8aSmrg	      ;;
1097688de56ccSmrg	  esac
1097788de56ccSmrg	  $ECHO > $output "\
1097888de56ccSmrg# $outputname - a libtool library file
10979862bcd1aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
1098088de56ccSmrg#
1098188de56ccSmrg# Please DO NOT delete this file!
1098288de56ccSmrg# It is necessary for linking the library.
109831ab64890Smrg
1098488de56ccSmrg# The name that we can dlopen(3).
1098588de56ccSmrgdlname='$tdlname'
109861ab64890Smrg
1098788de56ccSmrg# Names of this library.
1098888de56ccSmrglibrary_names='$library_names'
109891ab64890Smrg
1099088de56ccSmrg# The name of the static archive.
1099188de56ccSmrgold_library='$old_library'
109921ab64890Smrg
10993862bcd1aSmrg# Linker flags that cannot go in dependency_libs.
1099488de56ccSmrginherited_linker_flags='$new_inherited_linker_flags'
109951ab64890Smrg
1099688de56ccSmrg# Libraries that this one depends upon.
1099788de56ccSmrgdependency_libs='$dependency_libs'
109981ab64890Smrg
1099988de56ccSmrg# Names of additional weak libraries provided by this library
1100088de56ccSmrgweak_library_names='$weak_libs'
110011ab64890Smrg
1100288de56ccSmrg# Version information for $libname.
1100388de56ccSmrgcurrent=$current
1100488de56ccSmrgage=$age
1100588de56ccSmrgrevision=$revision
110061ab64890Smrg
1100788de56ccSmrg# Is this an already installed library?
1100888de56ccSmrginstalled=$installed
110091ab64890Smrg
1101088de56ccSmrg# Should we warn about portability when linking against -modules?
1101188de56ccSmrgshouldnotlink=$module
110121ab64890Smrg
1101388de56ccSmrg# Files to dlopen/dlpreopen
1101488de56ccSmrgdlopen='$dlfiles'
1101588de56ccSmrgdlpreopen='$dlprefiles'
110161ab64890Smrg
1101788de56ccSmrg# Directory that this library needs to be installed in:
1101888de56ccSmrglibdir='$install_libdir'"
11019862bcd1aSmrg	  if test no,yes = "$installed,$need_relink"; then
1102088de56ccSmrg	    $ECHO >> $output "\
1102188de56ccSmrgrelink_command=\"$relink_command\""
1102288de56ccSmrg	  fi
1102388de56ccSmrg	done
1102488de56ccSmrg      }
110251ab64890Smrg
1102688de56ccSmrg      # Do a symbolic link so that the libtool archive can be found in
1102788de56ccSmrg      # LD_LIBRARY_PATH before the program is installed.
1102888de56ccSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
1102988de56ccSmrg      ;;
1103088de56ccSmrg    esac
1103188de56ccSmrg    exit $EXIT_SUCCESS
1103288de56ccSmrg}
11033b4ee4795Smrg
11034862bcd1aSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
11035862bcd1aSmrg  func_mode_link ${1+"$@"}
11036862bcd1aSmrgfi
110371ab64890Smrg
110381ab64890Smrg
1103988de56ccSmrg# func_mode_uninstall arg...
1104088de56ccSmrgfunc_mode_uninstall ()
1104188de56ccSmrg{
11042862bcd1aSmrg    $debug_cmd
11043862bcd1aSmrg
11044862bcd1aSmrg    RM=$nonopt
110451ab64890Smrg    files=
11046862bcd1aSmrg    rmforce=false
110471ab64890Smrg    exit_status=0
110481ab64890Smrg
110491ab64890Smrg    # This variable tells wrapper scripts just to set variables rather
110501ab64890Smrg    # than running their programs.
11051862bcd1aSmrg    libtool_install_magic=$magic
110521ab64890Smrg
110531ab64890Smrg    for arg
110541ab64890Smrg    do
110551ab64890Smrg      case $arg in
11056862bcd1aSmrg      -f) func_append RM " $arg"; rmforce=: ;;
11057e9fcaa8aSmrg      -*) func_append RM " $arg" ;;
11058e9fcaa8aSmrg      *) func_append files " $arg" ;;
110591ab64890Smrg      esac
110601ab64890Smrg    done
110611ab64890Smrg
1106288de56ccSmrg    test -z "$RM" && \
1106388de56ccSmrg      func_fatal_help "you must specify an RM program"
110641ab64890Smrg
110651ab64890Smrg    rmdirs=
110661ab64890Smrg
110671ab64890Smrg    for file in $files; do
1106888de56ccSmrg      func_dirname "$file" "" "."
11069862bcd1aSmrg      dir=$func_dirname_result
11070862bcd1aSmrg      if test . = "$dir"; then
11071862bcd1aSmrg	odir=$objdir
110721ab64890Smrg      else
11073862bcd1aSmrg	odir=$dir/$objdir
110741ab64890Smrg      fi
1107588de56ccSmrg      func_basename "$file"
11076862bcd1aSmrg      name=$func_basename_result
11077862bcd1aSmrg      test uninstall = "$opt_mode" && odir=$dir
110781ab64890Smrg
11079e9fcaa8aSmrg      # Remember odir for removal later, being careful to avoid duplicates
11080862bcd1aSmrg      if test clean = "$opt_mode"; then
110811ab64890Smrg	case " $rmdirs " in
11082e9fcaa8aSmrg	  *" $odir "*) ;;
11083e9fcaa8aSmrg	  *) func_append rmdirs " $odir" ;;
110841ab64890Smrg	esac
110851ab64890Smrg      fi
110861ab64890Smrg
110871ab64890Smrg      # Don't error if the file doesn't exist and rm -f was used.
1108888de56ccSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
1108988de56ccSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
1109088de56ccSmrg	 test -f "$file"; then
110911ab64890Smrg	:
110921ab64890Smrg      elif test -d "$file"; then
110931ab64890Smrg	exit_status=1
110941ab64890Smrg	continue
11095862bcd1aSmrg      elif $rmforce; then
110961ab64890Smrg	continue
110971ab64890Smrg      fi
110981ab64890Smrg
11099862bcd1aSmrg      rmfiles=$file
111001ab64890Smrg
111011ab64890Smrg      case $name in
111021ab64890Smrg      *.la)
111031ab64890Smrg	# Possibly a libtool archive, so verify it.
1110488de56ccSmrg	if func_lalib_p "$file"; then
1110588de56ccSmrg	  func_source $dir/$name
111061ab64890Smrg
111071ab64890Smrg	  # Delete the libtool libraries and symlinks.
111081ab64890Smrg	  for n in $library_names; do
11109e9fcaa8aSmrg	    func_append rmfiles " $odir/$n"
111101ab64890Smrg	  done
11111e9fcaa8aSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
111121ab64890Smrg
11113862bcd1aSmrg	  case $opt_mode in
111141ab64890Smrg	  clean)
11115e9fcaa8aSmrg	    case " $library_names " in
111161ab64890Smrg	    *" $dlname "*) ;;
11117e9fcaa8aSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
111181ab64890Smrg	    esac
11119e9fcaa8aSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
111201ab64890Smrg	    ;;
111211ab64890Smrg	  uninstall)
111221ab64890Smrg	    if test -n "$library_names"; then
111231ab64890Smrg	      # Do each command in the postuninstall commands.
11124862bcd1aSmrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
111251ab64890Smrg	    fi
111261ab64890Smrg
111271ab64890Smrg	    if test -n "$old_library"; then
111281ab64890Smrg	      # Do each command in the old_postuninstall commands.
11129862bcd1aSmrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
111301ab64890Smrg	    fi
111311ab64890Smrg	    # FIXME: should reinstall the best remaining shared library.
111321ab64890Smrg	    ;;
111331ab64890Smrg	  esac
111341ab64890Smrg	fi
111351ab64890Smrg	;;
111361ab64890Smrg
111371ab64890Smrg      *.lo)
111381ab64890Smrg	# Possibly a libtool object, so verify it.
1113988de56ccSmrg	if func_lalib_p "$file"; then
111401ab64890Smrg
111411ab64890Smrg	  # Read the .lo file
1114288de56ccSmrg	  func_source $dir/$name
111431ab64890Smrg
111441ab64890Smrg	  # Add PIC object to the list of files to remove.
11145862bcd1aSmrg	  if test -n "$pic_object" && test none != "$pic_object"; then
11146e9fcaa8aSmrg	    func_append rmfiles " $dir/$pic_object"
111471ab64890Smrg	  fi
111481ab64890Smrg
111491ab64890Smrg	  # Add non-PIC object to the list of files to remove.
11150862bcd1aSmrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11151e9fcaa8aSmrg	    func_append rmfiles " $dir/$non_pic_object"
111521ab64890Smrg	  fi
111531ab64890Smrg	fi
111541ab64890Smrg	;;
111551ab64890Smrg
111561ab64890Smrg      *)
11157862bcd1aSmrg	if test clean = "$opt_mode"; then
111581ab64890Smrg	  noexename=$name
111591ab64890Smrg	  case $file in
111601ab64890Smrg	  *.exe)
1116188de56ccSmrg	    func_stripname '' '.exe' "$file"
1116288de56ccSmrg	    file=$func_stripname_result
1116388de56ccSmrg	    func_stripname '' '.exe' "$name"
1116488de56ccSmrg	    noexename=$func_stripname_result
111651ab64890Smrg	    # $file with .exe has already been added to rmfiles,
111661ab64890Smrg	    # add $file without .exe
11167e9fcaa8aSmrg	    func_append rmfiles " $file"
111681ab64890Smrg	    ;;
111691ab64890Smrg	  esac
111701ab64890Smrg	  # Do a test to see if this is a libtool program.
1117188de56ccSmrg	  if func_ltwrapper_p "$file"; then
1117288de56ccSmrg	    if func_ltwrapper_executable_p "$file"; then
1117388de56ccSmrg	      func_ltwrapper_scriptname "$file"
1117488de56ccSmrg	      relink_command=
1117588de56ccSmrg	      func_source $func_ltwrapper_scriptname_result
11176e9fcaa8aSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
1117788de56ccSmrg	    else
1117888de56ccSmrg	      relink_command=
1117988de56ccSmrg	      func_source $dir/$noexename
1118088de56ccSmrg	    fi
111811ab64890Smrg
111821ab64890Smrg	    # note $name still contains .exe if it was in $file originally
111831ab64890Smrg	    # as does the version of $file that was added into $rmfiles
11184862bcd1aSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
11185862bcd1aSmrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
11186e9fcaa8aSmrg	      func_append rmfiles " $odir/lt-$name"
111871ab64890Smrg	    fi
11188862bcd1aSmrg	    if test "X$noexename" != "X$name"; then
11189862bcd1aSmrg	      func_append rmfiles " $odir/lt-$noexename.c"
111901ab64890Smrg	    fi
111911ab64890Smrg	  fi
111921ab64890Smrg	fi
111931ab64890Smrg	;;
111941ab64890Smrg      esac
1119588de56ccSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
111961ab64890Smrg    done
111971ab64890Smrg
11198862bcd1aSmrg    # Try to remove the $objdir's in the directories where we deleted files
111991ab64890Smrg    for dir in $rmdirs; do
112001ab64890Smrg      if test -d "$dir"; then
1120188de56ccSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
112021ab64890Smrg      fi
112031ab64890Smrg    done
112041ab64890Smrg
112051ab64890Smrg    exit $exit_status
1120688de56ccSmrg}
112071ab64890Smrg
11208862bcd1aSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
11209862bcd1aSmrg  func_mode_uninstall ${1+"$@"}
11210862bcd1aSmrgfi
112112e9c7c8cSmrg
11212e9fcaa8aSmrgtest -z "$opt_mode" && {
11213862bcd1aSmrg  help=$generic_help
1121488de56ccSmrg  func_fatal_help "you must specify a MODE"
1121588de56ccSmrg}
1121688de56ccSmrg
1121788de56ccSmrgtest -z "$exec_cmd" && \
11218862bcd1aSmrg  func_fatal_help "invalid operation mode '$opt_mode'"
112191ab64890Smrg
112201ab64890Smrgif test -n "$exec_cmd"; then
1122188de56ccSmrg  eval exec "$exec_cmd"
112221ab64890Smrg  exit $EXIT_FAILURE
112231ab64890Smrgfi
112241ab64890Smrg
1122588de56ccSmrgexit $exit_status
112261ab64890Smrg
112271ab64890Smrg
112281ab64890Smrg# The TAGs below are defined such that we never get into a situation
11229862bcd1aSmrg# where we disable both kinds of libraries.  Given conflicting
112301ab64890Smrg# choices, we go for a static library, that is the most portable,
112311ab64890Smrg# since we can't tell whether shared libraries were disabled because
112321ab64890Smrg# the user asked for that or because the platform doesn't support
112331ab64890Smrg# them.  This is particularly important on AIX, because we don't
112341ab64890Smrg# support having both static and shared libraries enabled at the same
112351ab64890Smrg# time on that platform, so we default to a shared-only configuration.
112361ab64890Smrg# If a disable-shared tag is given, we'll fallback to a static-only
112371ab64890Smrg# configuration.  But we'll never go from static-only to shared-only.
112381ab64890Smrg
112391ab64890Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
1124088de56ccSmrgbuild_libtool_libs=no
1124188de56ccSmrgbuild_old_libs=yes
112421ab64890Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
112431ab64890Smrg
112441ab64890Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
1124588de56ccSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
112461ab64890Smrg# ### END LIBTOOL TAG CONFIG: disable-static
112471ab64890Smrg
112481ab64890Smrg# Local Variables:
112491ab64890Smrg# mode:shell-script
112501ab64890Smrg# sh-indentation:2
112511ab64890Smrg# End:
11252