1d21ab8bcSmrg#! /usr/bin/env sh
2d21ab8bcSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
3d21ab8bcSmrg##               by inline-source v2019-02-19.15
49c9ff80cSmrg
56ee7d557Smrg# libtool (GNU libtool) 2.5.4
6d21ab8bcSmrg# Provide generalized library-building support services.
79c9ff80cSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
89c9ff80cSmrg
96ee7d557Smrg# Copyright (C) 1996-2019, 2021-2024 Free Software Foundation, Inc.
109c9ff80cSmrg# This is free software; see the source for copying conditions.  There is NO
119c9ff80cSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
129c9ff80cSmrg
139c9ff80cSmrg# GNU Libtool is free software; you can redistribute it and/or modify
141f0ac6a5Smrg# it under the terms of the GNU General Public License as published by
151f0ac6a5Smrg# the Free Software Foundation; either version 2 of the License, or
161f0ac6a5Smrg# (at your option) any later version.
171f0ac6a5Smrg#
189c9ff80cSmrg# As a special exception to the GNU General Public License,
199c9ff80cSmrg# if you distribute this file as part of a program or library that
209c9ff80cSmrg# is built using GNU Libtool, you may include this file under the
219c9ff80cSmrg# same distribution terms that you use for the rest of that program.
229c9ff80cSmrg#
239c9ff80cSmrg# GNU Libtool is distributed in the hope that it will be useful, but
241f0ac6a5Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
251f0ac6a5Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
261f0ac6a5Smrg# General Public License for more details.
271f0ac6a5Smrg#
281f0ac6a5Smrg# You should have received a copy of the GNU General Public License
29d21ab8bcSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
301f0ac6a5Smrg
31d21ab8bcSmrg
32d21ab8bcSmrgPROGRAM=libtool
33d21ab8bcSmrgPACKAGE=libtool
346ee7d557SmrgVERSION=2.5.4
356ee7d557Smrgpackage_revision=2.5.4
36d21ab8bcSmrg
37d21ab8bcSmrg
38d21ab8bcSmrg## ------ ##
39d21ab8bcSmrg## Usage. ##
40d21ab8bcSmrg## ------ ##
41d21ab8bcSmrg
42d21ab8bcSmrg# Run './libtool --help' for help with using this script from the
43d21ab8bcSmrg# command line.
44d21ab8bcSmrg
45d21ab8bcSmrg
46d21ab8bcSmrg## ------------------------------- ##
47d21ab8bcSmrg## User overridable command paths. ##
48d21ab8bcSmrg## ------------------------------- ##
49d21ab8bcSmrg
50d21ab8bcSmrg# After configure completes, it has a better idea of some of the
51d21ab8bcSmrg# shell tools we need than the defaults used by the functions shared
52d21ab8bcSmrg# with bootstrap, so set those here where they can still be over-
53d21ab8bcSmrg# ridden by the user, but otherwise take precedence.
54d21ab8bcSmrg
55d21ab8bcSmrg: ${AUTOCONF="autoconf"}
56d21ab8bcSmrg: ${AUTOMAKE="automake"}
57d21ab8bcSmrg
58d21ab8bcSmrg
59d21ab8bcSmrg## -------------------------- ##
60d21ab8bcSmrg## Source external libraries. ##
61d21ab8bcSmrg## -------------------------- ##
62d21ab8bcSmrg
63d21ab8bcSmrg# Much of our low-level functionality needs to be sourced from external
64d21ab8bcSmrg# libraries, which are installed to $pkgauxdir.
65d21ab8bcSmrg
66d21ab8bcSmrg# Set a version string for this script.
67d21ab8bcSmrgscriptversion=2019-02-19.15; # UTC
68d21ab8bcSmrg
69d21ab8bcSmrg# General shell script boiler plate, and helper functions.
70d21ab8bcSmrg# Written by Gary V. Vaughan, 2004
71d21ab8bcSmrg
72d21ab8bcSmrg# This is free software.  There is NO warranty; not even for
73d21ab8bcSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
749c9ff80cSmrg#
756ee7d557Smrg# Copyright (C) 2004-2019, 2021, 2023-2024 Bootstrap Authors
769c9ff80cSmrg#
77d21ab8bcSmrg# This file is dual licensed under the terms of the MIT license
786ee7d557Smrg# <https://opensource.org/licenses/MIT>, and GPL version 2 or later
796ee7d557Smrg# <https://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
80d21ab8bcSmrg# these licenses when using or redistributing this software or any of
81d21ab8bcSmrg# the files within it.  See the URLs above, or the file `LICENSE`
82d21ab8bcSmrg# included in the Bootstrap distribution for the full license texts.
83d21ab8bcSmrg
84d21ab8bcSmrg# Please report bugs or propose patches to:
85d21ab8bcSmrg# <https://github.com/gnulib-modules/bootstrap/issues>
86d21ab8bcSmrg
87d21ab8bcSmrg
88d21ab8bcSmrg## ------ ##
89d21ab8bcSmrg## Usage. ##
90d21ab8bcSmrg## ------ ##
91d21ab8bcSmrg
92d21ab8bcSmrg# Evaluate this file near the top of your script to gain access to
93d21ab8bcSmrg# the functions and variables defined here:
949c9ff80cSmrg#
95d21ab8bcSmrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
969c9ff80cSmrg#
97d21ab8bcSmrg# If you need to override any of the default environment variable
98d21ab8bcSmrg# settings, do that before evaluating this file.
991f0ac6a5Smrg
100e5410a46Smrg
101d21ab8bcSmrg## -------------------- ##
102d21ab8bcSmrg## Shell normalisation. ##
103d21ab8bcSmrg## -------------------- ##
104d21ab8bcSmrg
105d21ab8bcSmrg# Some shells need a little help to be as Bourne compatible as possible.
106d21ab8bcSmrg# Before doing anything else, make sure all that help has been provided!
107d21ab8bcSmrg
108d21ab8bcSmrgDUALCASE=1; export DUALCASE # for MKS sh
109d21ab8bcSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
110e5410a46Smrg  emulate sh
111e5410a46Smrg  NULLCMD=:
112d21ab8bcSmrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
113e5410a46Smrg  # is contrary to our usage.  Disable this feature.
114e5410a46Smrg  alias -g '${1+"$@"}'='"$@"'
1151f0ac6a5Smrg  setopt NO_GLOB_SUBST
116e5410a46Smrgelse
117d21ab8bcSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
1181f0ac6a5Smrgfi
1196fae4e5dSmrg
120d21ab8bcSmrg# NLS nuisances: We save the old values in case they are required later.
121d21ab8bcSmrg_G_user_locale=
122d21ab8bcSmrg_G_safe_locale=
123d21ab8bcSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
124e5410a46Smrgdo
125d21ab8bcSmrg  eval "if test set = \"\${$_G_var+set}\"; then
126d21ab8bcSmrg          save_$_G_var=\$$_G_var
127d21ab8bcSmrg          $_G_var=C
128d21ab8bcSmrg	  export $_G_var
129d21ab8bcSmrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
130d21ab8bcSmrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
131e5410a46Smrg	fi"
132e5410a46Smrgdone
133d21ab8bcSmrg# These NLS vars are set unconditionally (bootstrap issue #24).  Unset those
134d21ab8bcSmrg# in case the environment reset is needed later and the $save_* variant is not
135d21ab8bcSmrg# defined (see the code above).
1366fae4e5dSmrgLC_ALL=C
1376fae4e5dSmrgLANGUAGE=C
1386fae4e5dSmrgexport LANGUAGE LC_ALL
139e5410a46Smrg
140d21ab8bcSmrg# Make sure IFS has a sensible default
141d21ab8bcSmrgsp=' '
142d21ab8bcSmrgnl='
143d21ab8bcSmrg'
144d21ab8bcSmrgIFS="$sp	$nl"
145d21ab8bcSmrg
1466ee7d557Smrg# There are apparently some systems that use ';' as a PATH separator!
147d21ab8bcSmrgif test "${PATH_SEPARATOR+set}" != set; then
148d21ab8bcSmrg  PATH_SEPARATOR=:
149d21ab8bcSmrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
150d21ab8bcSmrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
151d21ab8bcSmrg      PATH_SEPARATOR=';'
152d21ab8bcSmrg  }
153d21ab8bcSmrgfi
1549c9ff80cSmrg
1559c9ff80cSmrg
156d21ab8bcSmrg# func_unset VAR
157d21ab8bcSmrg# --------------
158d21ab8bcSmrg# Portably unset VAR.
159d21ab8bcSmrg# In some shells, an 'unset VAR' statement leaves a non-zero return
160d21ab8bcSmrg# status if VAR is already unset, which might be problematic if the
161d21ab8bcSmrg# statement is used at the end of a function (thus poisoning its return
162d21ab8bcSmrg# value) or when 'set -e' is active (causing even a spurious abort of
163d21ab8bcSmrg# the script in this case).
164d21ab8bcSmrgfunc_unset ()
165d21ab8bcSmrg{
166d21ab8bcSmrg    { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; }
167d21ab8bcSmrg}
1689c9ff80cSmrg
1699c9ff80cSmrg
170d21ab8bcSmrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir.
171d21ab8bcSmrgfunc_unset CDPATH
1729c9ff80cSmrg
173d21ab8bcSmrg# Make sure ${,E,F}GREP behave sanely.
174d21ab8bcSmrgfunc_unset GREP_OPTIONS
1759c9ff80cSmrg
1761f0ac6a5Smrg
177d21ab8bcSmrg## ------------------------- ##
178d21ab8bcSmrg## Locate command utilities. ##
179d21ab8bcSmrg## ------------------------- ##
1801f0ac6a5Smrg
1819c9ff80cSmrg
182d21ab8bcSmrg# func_executable_p FILE
183d21ab8bcSmrg# ----------------------
184d21ab8bcSmrg# Check that FILE is an executable regular file.
185d21ab8bcSmrgfunc_executable_p ()
1866fae4e5dSmrg{
187d21ab8bcSmrg    test -f "$1" && test -x "$1"
188d21ab8bcSmrg}
1896fae4e5dSmrg
1906fae4e5dSmrg
191d21ab8bcSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
192d21ab8bcSmrg# --------------------------------------------
193d21ab8bcSmrg# Search for either a program that responds to --version with output
194d21ab8bcSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
195d21ab8bcSmrg# trying all the directories in PATH with each of the elements of
196d21ab8bcSmrg# PROGS_LIST.
197d21ab8bcSmrg#
198d21ab8bcSmrg# CHECK_FUNC should accept the path to a candidate program, and
199d21ab8bcSmrg# set $func_check_prog_result if it truncates its output less than
200d21ab8bcSmrg# $_G_path_prog_max characters.
201d21ab8bcSmrgfunc_path_progs ()
2026fae4e5dSmrg{
203d21ab8bcSmrg    _G_progs_list=$1
204d21ab8bcSmrg    _G_check_func=$2
205d21ab8bcSmrg    _G_PATH=${3-"$PATH"}
206d21ab8bcSmrg
207d21ab8bcSmrg    _G_path_prog_max=0
208d21ab8bcSmrg    _G_path_prog_found=false
209d21ab8bcSmrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
210d21ab8bcSmrg    for _G_dir in $_G_PATH; do
211d21ab8bcSmrg      IFS=$_G_save_IFS
212d21ab8bcSmrg      test -z "$_G_dir" && _G_dir=.
213d21ab8bcSmrg      for _G_prog_name in $_G_progs_list; do
214d21ab8bcSmrg        for _exeext in '' .EXE; do
215d21ab8bcSmrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
216d21ab8bcSmrg          func_executable_p "$_G_path_prog" || continue
217d21ab8bcSmrg          case `"$_G_path_prog" --version 2>&1` in
218d21ab8bcSmrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
219d21ab8bcSmrg            *)     $_G_check_func $_G_path_prog
220d21ab8bcSmrg		   func_path_progs_result=$func_check_prog_result
221d21ab8bcSmrg		   ;;
222d21ab8bcSmrg          esac
223d21ab8bcSmrg          $_G_path_prog_found && break 3
224d21ab8bcSmrg        done
225d21ab8bcSmrg      done
226d21ab8bcSmrg    done
227d21ab8bcSmrg    IFS=$_G_save_IFS
228d21ab8bcSmrg    test -z "$func_path_progs_result" && {
229d21ab8bcSmrg      echo "no acceptable sed could be found in \$PATH" >&2
230d21ab8bcSmrg      exit 1
231d21ab8bcSmrg    }
232d21ab8bcSmrg}
2336fae4e5dSmrg
2346fae4e5dSmrg
235d21ab8bcSmrg# We want to be able to use the functions in this file before configure
236d21ab8bcSmrg# has figured out where the best binaries are kept, which means we have
237d21ab8bcSmrg# to search for them ourselves - except when the results are already set
238d21ab8bcSmrg# where we skip the searches.
2396fae4e5dSmrg
240d21ab8bcSmrg# Unless the user overrides by setting SED, search the path for either GNU
241d21ab8bcSmrg# sed, or the sed that truncates its output the least.
242d21ab8bcSmrgtest -z "$SED" && {
243d21ab8bcSmrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
244d21ab8bcSmrg  for _G_i in 1 2 3 4 5 6 7; do
245d21ab8bcSmrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
246d21ab8bcSmrg  done
247d21ab8bcSmrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
248d21ab8bcSmrg  _G_sed_script=
2496fae4e5dSmrg
250d21ab8bcSmrg  func_check_prog_sed ()
251d21ab8bcSmrg  {
252d21ab8bcSmrg    _G_path_prog=$1
2536fae4e5dSmrg
254d21ab8bcSmrg    _G_count=0
255d21ab8bcSmrg    printf 0123456789 >conftest.in
256d21ab8bcSmrg    while :
257d21ab8bcSmrg    do
258d21ab8bcSmrg      cat conftest.in conftest.in >conftest.tmp
259d21ab8bcSmrg      mv conftest.tmp conftest.in
260d21ab8bcSmrg      cp conftest.in conftest.nl
261d21ab8bcSmrg      echo '' >> conftest.nl
262d21ab8bcSmrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
263d21ab8bcSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
264d21ab8bcSmrg      _G_count=`expr $_G_count + 1`
265d21ab8bcSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
266d21ab8bcSmrg        # Best one so far, save it but keep looking for a better one
267d21ab8bcSmrg        func_check_prog_result=$_G_path_prog
268d21ab8bcSmrg        _G_path_prog_max=$_G_count
269d21ab8bcSmrg      fi
270d21ab8bcSmrg      # 10*(2^10) chars as input seems more than enough
271d21ab8bcSmrg      test 10 -lt "$_G_count" && break
272d21ab8bcSmrg    done
273d21ab8bcSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
274d21ab8bcSmrg  }
2756fae4e5dSmrg
276d21ab8bcSmrg  func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin"
277d21ab8bcSmrg  rm -f conftest.sed
278d21ab8bcSmrg  SED=$func_path_progs_result
279d21ab8bcSmrg}
2806fae4e5dSmrg
281d21ab8bcSmrg
282d21ab8bcSmrg# Unless the user overrides by setting GREP, search the path for either GNU
283d21ab8bcSmrg# grep, or the grep that truncates its output the least.
284d21ab8bcSmrgtest -z "$GREP" && {
285d21ab8bcSmrg  func_check_prog_grep ()
286d21ab8bcSmrg  {
287d21ab8bcSmrg    _G_path_prog=$1
288d21ab8bcSmrg
289d21ab8bcSmrg    _G_count=0
290d21ab8bcSmrg    _G_path_prog_max=0
291d21ab8bcSmrg    printf 0123456789 >conftest.in
292d21ab8bcSmrg    while :
293d21ab8bcSmrg    do
294d21ab8bcSmrg      cat conftest.in conftest.in >conftest.tmp
295d21ab8bcSmrg      mv conftest.tmp conftest.in
296d21ab8bcSmrg      cp conftest.in conftest.nl
297d21ab8bcSmrg      echo 'GREP' >> conftest.nl
298d21ab8bcSmrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
299d21ab8bcSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
300d21ab8bcSmrg      _G_count=`expr $_G_count + 1`
301d21ab8bcSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
302d21ab8bcSmrg        # Best one so far, save it but keep looking for a better one
303d21ab8bcSmrg        func_check_prog_result=$_G_path_prog
304d21ab8bcSmrg        _G_path_prog_max=$_G_count
305d21ab8bcSmrg      fi
306d21ab8bcSmrg      # 10*(2^10) chars as input seems more than enough
307d21ab8bcSmrg      test 10 -lt "$_G_count" && break
308d21ab8bcSmrg    done
309d21ab8bcSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
310d21ab8bcSmrg  }
311d21ab8bcSmrg
312d21ab8bcSmrg  func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin"
313d21ab8bcSmrg  GREP=$func_path_progs_result
314d21ab8bcSmrg}
315d21ab8bcSmrg
316d21ab8bcSmrg
317d21ab8bcSmrg## ------------------------------- ##
318d21ab8bcSmrg## User overridable command paths. ##
319d21ab8bcSmrg## ------------------------------- ##
320d21ab8bcSmrg
321d21ab8bcSmrg# All uppercase variable names are used for environment variables.  These
322d21ab8bcSmrg# variables can be overridden by the user before calling a script that
323d21ab8bcSmrg# uses them if a suitable command of that name is not already available
324d21ab8bcSmrg# in the command search PATH.
325d21ab8bcSmrg
326d21ab8bcSmrg: ${CP="cp -f"}
327d21ab8bcSmrg: ${ECHO="printf %s\n"}
328d21ab8bcSmrg: ${EGREP="$GREP -E"}
329d21ab8bcSmrg: ${FGREP="$GREP -F"}
330d21ab8bcSmrg: ${LN_S="ln -s"}
331d21ab8bcSmrg: ${MAKE="make"}
332d21ab8bcSmrg: ${MKDIR="mkdir"}
333d21ab8bcSmrg: ${MV="mv -f"}
334d21ab8bcSmrg: ${RM="rm -f"}
335d21ab8bcSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
336d21ab8bcSmrg
337d21ab8bcSmrg
338d21ab8bcSmrg## -------------------- ##
339d21ab8bcSmrg## Useful sed snippets. ##
340d21ab8bcSmrg## -------------------- ##
341d21ab8bcSmrg
342d21ab8bcSmrgsed_dirname='s|/[^/]*$||'
343d21ab8bcSmrgsed_basename='s|^.*/||'
344d21ab8bcSmrg
345d21ab8bcSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
346d21ab8bcSmrg# metacharacters that are still active within double-quoted strings.
347d21ab8bcSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
348d21ab8bcSmrg
349d21ab8bcSmrg# Same as above, but do not quote variable references.
350d21ab8bcSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
351d21ab8bcSmrg
352d21ab8bcSmrg# Sed substitution that turns a string into a regex matching for the
353d21ab8bcSmrg# string literally.
354d21ab8bcSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
355d21ab8bcSmrg
356d21ab8bcSmrg# Sed substitution that converts a w32 file name or path
357d21ab8bcSmrg# that contains forward slashes, into one that contains
358d21ab8bcSmrg# (escaped) backslashes.  A very naive implementation.
359d21ab8bcSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
360d21ab8bcSmrg
361d21ab8bcSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
362d21ab8bcSmrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
363d21ab8bcSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from
364d21ab8bcSmrg# expansion.  Since each input '\' is now two '\'s, look for any number
365d21ab8bcSmrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
366d21ab8bcSmrg_G_bs='\\'
367d21ab8bcSmrg_G_bs2='\\\\'
368d21ab8bcSmrg_G_bs4='\\\\\\\\'
369d21ab8bcSmrg_G_dollar='\$'
370d21ab8bcSmrgsed_double_backslash="\
371d21ab8bcSmrg  s/$_G_bs4/&\\
372d21ab8bcSmrg/g
373d21ab8bcSmrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
374d21ab8bcSmrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
375d21ab8bcSmrg  s/\n//g"
376d21ab8bcSmrg
377d21ab8bcSmrg# require_check_ifs_backslash
378d21ab8bcSmrg# ---------------------------
379d21ab8bcSmrg# Check if we can use backslash as IFS='\' separator, and set
380d21ab8bcSmrg# $check_ifs_backshlash_broken to ':' or 'false'.
381d21ab8bcSmrgrequire_check_ifs_backslash=func_require_check_ifs_backslash
382d21ab8bcSmrgfunc_require_check_ifs_backslash ()
3836fae4e5dSmrg{
384d21ab8bcSmrg  _G_save_IFS=$IFS
385d21ab8bcSmrg  IFS='\'
386d21ab8bcSmrg  _G_check_ifs_backshlash='a\\b'
387d21ab8bcSmrg  for _G_i in $_G_check_ifs_backshlash
388d21ab8bcSmrg  do
389d21ab8bcSmrg  case $_G_i in
390d21ab8bcSmrg  a)
391d21ab8bcSmrg    check_ifs_backshlash_broken=false
3926fae4e5dSmrg    ;;
393d21ab8bcSmrg  '')
394d21ab8bcSmrg    break
3956fae4e5dSmrg    ;;
396d21ab8bcSmrg  *)
397d21ab8bcSmrg    check_ifs_backshlash_broken=:
398d21ab8bcSmrg    break
3996fae4e5dSmrg    ;;
4006fae4e5dSmrg  esac
4016fae4e5dSmrg  done
402d21ab8bcSmrg  IFS=$_G_save_IFS
403d21ab8bcSmrg  require_check_ifs_backslash=:
4049c9ff80cSmrg}
4051f0ac6a5Smrg
4069c9ff80cSmrg
407d21ab8bcSmrg## ----------------- ##
408d21ab8bcSmrg## Global variables. ##
409d21ab8bcSmrg## ----------------- ##
4106fae4e5dSmrg
411d21ab8bcSmrg# Except for the global variables explicitly listed below, the following
412d21ab8bcSmrg# functions in the '^func_' namespace, and the '^require_' namespace
413d21ab8bcSmrg# variables initialised in the 'Resource management' section, sourcing
414d21ab8bcSmrg# this file will not pollute your global namespace with anything
415d21ab8bcSmrg# else. There's no portable way to scope variables in Bourne shell
416d21ab8bcSmrg# though, so actually running these functions will sometimes place
417d21ab8bcSmrg# results into a variable named after the function, and often use
418d21ab8bcSmrg# temporary variables in the '^_G_' namespace. If you are careful to
419d21ab8bcSmrg# avoid using those namespaces casually in your sourcing script, things
420d21ab8bcSmrg# should continue to work as you expect. And, of course, you can freely
421d21ab8bcSmrg# overwrite any of the functions or variables defined here before
422d21ab8bcSmrg# calling anything to customize them.
423d21ab8bcSmrg
424d21ab8bcSmrgEXIT_SUCCESS=0
425d21ab8bcSmrgEXIT_FAILURE=1
426d21ab8bcSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
427d21ab8bcSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
428d21ab8bcSmrg
429d21ab8bcSmrg# Allow overriding, eg assuming that you follow the convention of
430d21ab8bcSmrg# putting '$debug_cmd' at the start of all your functions, you can get
431d21ab8bcSmrg# bash to show function call trace with:
432d21ab8bcSmrg#
433d21ab8bcSmrg#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
434d21ab8bcSmrgdebug_cmd=${debug_cmd-":"}
435d21ab8bcSmrgexit_cmd=:
436d21ab8bcSmrg
437d21ab8bcSmrg# By convention, finish your script with:
438d21ab8bcSmrg#
439d21ab8bcSmrg#    exit $exit_status
440d21ab8bcSmrg#
441d21ab8bcSmrg# so that you can set exit_status to non-zero if you want to indicate
442d21ab8bcSmrg# something went wrong during execution without actually bailing out at
443d21ab8bcSmrg# the point of failure.
444d21ab8bcSmrgexit_status=$EXIT_SUCCESS
4459c9ff80cSmrg
446d21ab8bcSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
447d21ab8bcSmrg# is ksh but when the shell is invoked as "sh" and the current value of
448d21ab8bcSmrg# the _XPG environment variable is not equal to 1 (one), the special
449d21ab8bcSmrg# positional parameter $0, within a function call, is the name of the
450d21ab8bcSmrg# function.
451d21ab8bcSmrgprogpath=$0
452d21ab8bcSmrg
453d21ab8bcSmrg# The name of this program.
454d21ab8bcSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
4559c9ff80cSmrg
456d21ab8bcSmrg# Make sure we have an absolute progpath for reexecution:
4579c9ff80cSmrgcase $progpath in
4589c9ff80cSmrg  [\\/]*|[A-Za-z]:\\*) ;;
4599c9ff80cSmrg  *[\\/]*)
460d21ab8bcSmrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
4619c9ff80cSmrg     progdir=`cd "$progdir" && pwd`
462d21ab8bcSmrg     progpath=$progdir/$progname
4639c9ff80cSmrg     ;;
4649c9ff80cSmrg  *)
465d21ab8bcSmrg     _G_IFS=$IFS
46689c04b6cSmrg     IFS=${PATH_SEPARATOR-:}
4679c9ff80cSmrg     for progdir in $PATH; do
468d21ab8bcSmrg       IFS=$_G_IFS
4699c9ff80cSmrg       test -x "$progdir/$progname" && break
4709c9ff80cSmrg     done
471d21ab8bcSmrg     IFS=$_G_IFS
4729c9ff80cSmrg     test -n "$progdir" || progdir=`pwd`
473d21ab8bcSmrg     progpath=$progdir/$progname
4749c9ff80cSmrg     ;;
4759c9ff80cSmrgesac
4769c9ff80cSmrg
4779c9ff80cSmrg
478d21ab8bcSmrg## ----------------- ##
479d21ab8bcSmrg## Standard options. ##
480d21ab8bcSmrg## ----------------- ##
4816fae4e5dSmrg
482d21ab8bcSmrg# The following options affect the operation of the functions defined
483d21ab8bcSmrg# below, and should be set appropriately depending on run-time para-
484d21ab8bcSmrg# meters passed on the command line.
4859c9ff80cSmrg
4869c9ff80cSmrgopt_dry_run=false
4879c9ff80cSmrgopt_quiet=false
4889c9ff80cSmrgopt_verbose=false
4899c9ff80cSmrg
490d21ab8bcSmrg# Categories 'all' and 'none' are always available.  Append any others
491d21ab8bcSmrg# you will pass as the first argument to func_warning from your own
492d21ab8bcSmrg# code.
493d21ab8bcSmrgwarning_categories=
4949c9ff80cSmrg
495d21ab8bcSmrg# By default, display warnings according to 'opt_warning_types'.  Set
496d21ab8bcSmrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
497d21ab8bcSmrg# treat the next displayed warning as a fatal error.
498d21ab8bcSmrgwarning_func=func_warn_and_continue
4999c9ff80cSmrg
500d21ab8bcSmrg# Set to 'all' to display all warnings, 'none' to suppress all
501d21ab8bcSmrg# warnings, or a space delimited list of some subset of
502d21ab8bcSmrg# 'warning_categories' to display only the listed warnings.
503d21ab8bcSmrgopt_warning_types=all
5049c9ff80cSmrg
5056fae4e5dSmrg
506d21ab8bcSmrg## -------------------- ##
507d21ab8bcSmrg## Resource management. ##
508d21ab8bcSmrg## -------------------- ##
5099c9ff80cSmrg
510d21ab8bcSmrg# This section contains definitions for functions that each ensure a
511d21ab8bcSmrg# particular resource (a file, or a non-empty configuration variable for
512d21ab8bcSmrg# example) is available, and if appropriate to extract default values
513d21ab8bcSmrg# from pertinent package files. Call them using their associated
514d21ab8bcSmrg# 'require_*' variable to ensure that they are executed, at most, once.
515d21ab8bcSmrg#
516d21ab8bcSmrg# It's entirely deliberate that calling these functions can set
517d21ab8bcSmrg# variables that don't obey the namespace limitations obeyed by the rest
518d21ab8bcSmrg# of this file, in order that that they be as useful as possible to
519d21ab8bcSmrg# callers.
5209c9ff80cSmrg
5219c9ff80cSmrg
522d21ab8bcSmrg# require_term_colors
523d21ab8bcSmrg# -------------------
524d21ab8bcSmrg# Allow display of bold text on terminals that support it.
525d21ab8bcSmrgrequire_term_colors=func_require_term_colors
526d21ab8bcSmrgfunc_require_term_colors ()
5279c9ff80cSmrg{
528d21ab8bcSmrg    $debug_cmd
529d21ab8bcSmrg
530d21ab8bcSmrg    test -t 1 && {
531d21ab8bcSmrg      # COLORTERM and USE_ANSI_COLORS environment variables take
532d21ab8bcSmrg      # precedence, because most terminfo databases neglect to describe
533d21ab8bcSmrg      # whether color sequences are supported.
534d21ab8bcSmrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
535d21ab8bcSmrg
536d21ab8bcSmrg      if test 1 = "$USE_ANSI_COLORS"; then
537d21ab8bcSmrg        # Standard ANSI escape sequences
538d21ab8bcSmrg        tc_reset='[0m'
539d21ab8bcSmrg        tc_bold='[1m';   tc_standout='[7m'
540d21ab8bcSmrg        tc_red='[31m';   tc_green='[32m'
541d21ab8bcSmrg        tc_blue='[34m';  tc_cyan='[36m'
542d21ab8bcSmrg      else
543d21ab8bcSmrg        # Otherwise trust the terminfo database after all.
544d21ab8bcSmrg        test -n "`tput sgr0 2>/dev/null`" && {
545d21ab8bcSmrg          tc_reset=`tput sgr0`
546d21ab8bcSmrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
547d21ab8bcSmrg          tc_standout=$tc_bold
548d21ab8bcSmrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
549d21ab8bcSmrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
550d21ab8bcSmrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
551d21ab8bcSmrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
552d21ab8bcSmrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
553d21ab8bcSmrg        }
554d21ab8bcSmrg      fi
555d21ab8bcSmrg    }
5569c9ff80cSmrg
557d21ab8bcSmrg    require_term_colors=:
5589c9ff80cSmrg}
5599c9ff80cSmrg
5609c9ff80cSmrg
561d21ab8bcSmrg## ----------------- ##
562d21ab8bcSmrg## Function library. ##
563d21ab8bcSmrg## ----------------- ##
5649c9ff80cSmrg
565d21ab8bcSmrg# This section contains a variety of useful functions to call in your
566d21ab8bcSmrg# scripts. Take note of the portable wrappers for features provided by
567d21ab8bcSmrg# some modern shells, which will fall back to slower equivalents on
568d21ab8bcSmrg# less featureful shells.
5699c9ff80cSmrg
570d21ab8bcSmrg
571d21ab8bcSmrg# func_append VAR VALUE
572d21ab8bcSmrg# ---------------------
573d21ab8bcSmrg# Append VALUE onto the existing contents of VAR.
574d21ab8bcSmrg
575d21ab8bcSmrg  # We should try to minimise forks, especially on Windows where they are
576d21ab8bcSmrg  # unreasonably slow, so skip the feature probes when bash or zsh are
577d21ab8bcSmrg  # being used:
578d21ab8bcSmrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
579d21ab8bcSmrg    : ${_G_HAVE_ARITH_OP="yes"}
580d21ab8bcSmrg    : ${_G_HAVE_XSI_OPS="yes"}
581d21ab8bcSmrg    # The += operator was introduced in bash 3.1
582d21ab8bcSmrg    case $BASH_VERSION in
583d21ab8bcSmrg      [12].* | 3.0 | 3.0*) ;;
584d21ab8bcSmrg      *)
585d21ab8bcSmrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
586d21ab8bcSmrg        ;;
587d21ab8bcSmrg    esac
588d21ab8bcSmrg  fi
589d21ab8bcSmrg
590d21ab8bcSmrg  # _G_HAVE_PLUSEQ_OP
591d21ab8bcSmrg  # Can be empty, in which case the shell is probed, "yes" if += is
5926ee7d557Smrg  # usable or anything else if it does not work.
593d21ab8bcSmrg  test -z "$_G_HAVE_PLUSEQ_OP" \
594d21ab8bcSmrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
595d21ab8bcSmrg    && _G_HAVE_PLUSEQ_OP=yes
596d21ab8bcSmrg
597d21ab8bcSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"
598d21ab8bcSmrgthen
599d21ab8bcSmrg  # This is an XSI compatible shell, allowing a faster implementation...
600d21ab8bcSmrg  eval 'func_append ()
601d21ab8bcSmrg  {
602d21ab8bcSmrg    $debug_cmd
603d21ab8bcSmrg
604d21ab8bcSmrg    eval "$1+=\$2"
605d21ab8bcSmrg  }'
606d21ab8bcSmrgelse
607d21ab8bcSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
608d21ab8bcSmrg  func_append ()
609d21ab8bcSmrg  {
610d21ab8bcSmrg    $debug_cmd
611d21ab8bcSmrg
612d21ab8bcSmrg    eval "$1=\$$1\$2"
613d21ab8bcSmrg  }
614d21ab8bcSmrgfi
615d21ab8bcSmrg
616d21ab8bcSmrg
617d21ab8bcSmrg# func_append_quoted VAR VALUE
618d21ab8bcSmrg# ----------------------------
619d21ab8bcSmrg# Quote VALUE and append to the end of shell variable VAR, separated
620d21ab8bcSmrg# by a space.
621d21ab8bcSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
622d21ab8bcSmrg  eval 'func_append_quoted ()
623d21ab8bcSmrg  {
624d21ab8bcSmrg    $debug_cmd
625d21ab8bcSmrg
626d21ab8bcSmrg    func_quote_arg pretty "$2"
627d21ab8bcSmrg    eval "$1+=\\ \$func_quote_arg_result"
628d21ab8bcSmrg  }'
629d21ab8bcSmrgelse
630d21ab8bcSmrg  func_append_quoted ()
631d21ab8bcSmrg  {
632d21ab8bcSmrg    $debug_cmd
633d21ab8bcSmrg
634d21ab8bcSmrg    func_quote_arg pretty "$2"
635d21ab8bcSmrg    eval "$1=\$$1\\ \$func_quote_arg_result"
636d21ab8bcSmrg  }
637d21ab8bcSmrgfi
638d21ab8bcSmrg
639d21ab8bcSmrg
640d21ab8bcSmrg# func_append_uniq VAR VALUE
641d21ab8bcSmrg# --------------------------
642d21ab8bcSmrg# Append unique VALUE onto the existing contents of VAR, assuming
643d21ab8bcSmrg# entries are delimited by the first character of VALUE.  For example:
644d21ab8bcSmrg#
645d21ab8bcSmrg#   func_append_uniq options " --another-option option-argument"
646d21ab8bcSmrg#
647d21ab8bcSmrg# will only append to $options if " --another-option option-argument "
648d21ab8bcSmrg# is not already present somewhere in $options already (note spaces at
649d21ab8bcSmrg# each end implied by leading space in second argument).
650d21ab8bcSmrgfunc_append_uniq ()
651d21ab8bcSmrg{
652d21ab8bcSmrg    $debug_cmd
653d21ab8bcSmrg
654d21ab8bcSmrg    eval _G_current_value='`$ECHO $'$1'`'
655d21ab8bcSmrg    _G_delim=`expr "$2" : '\(.\)'`
656d21ab8bcSmrg
657d21ab8bcSmrg    case $_G_delim$_G_current_value$_G_delim in
658d21ab8bcSmrg      *"$2$_G_delim"*) ;;
659d21ab8bcSmrg      *) func_append "$@" ;;
660d21ab8bcSmrg    esac
661d21ab8bcSmrg}
662d21ab8bcSmrg
663d21ab8bcSmrg
664d21ab8bcSmrg# func_arith TERM...
665d21ab8bcSmrg# ------------------
666d21ab8bcSmrg# Set func_arith_result to the result of evaluating TERMs.
667d21ab8bcSmrg  test -z "$_G_HAVE_ARITH_OP" \
668d21ab8bcSmrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
669d21ab8bcSmrg    && _G_HAVE_ARITH_OP=yes
670d21ab8bcSmrg
671d21ab8bcSmrgif test yes = "$_G_HAVE_ARITH_OP"; then
672d21ab8bcSmrg  eval 'func_arith ()
673d21ab8bcSmrg  {
674d21ab8bcSmrg    $debug_cmd
675d21ab8bcSmrg
676d21ab8bcSmrg    func_arith_result=$(( $* ))
677d21ab8bcSmrg  }'
678d21ab8bcSmrgelse
679d21ab8bcSmrg  func_arith ()
680d21ab8bcSmrg  {
681d21ab8bcSmrg    $debug_cmd
682d21ab8bcSmrg
683d21ab8bcSmrg    func_arith_result=`expr "$@"`
684d21ab8bcSmrg  }
685d21ab8bcSmrgfi
686d21ab8bcSmrg
687d21ab8bcSmrg
688d21ab8bcSmrg# func_basename FILE
689d21ab8bcSmrg# ------------------
690d21ab8bcSmrg# Set func_basename_result to FILE with everything up to and including
691d21ab8bcSmrg# the last / stripped.
692d21ab8bcSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
693d21ab8bcSmrg  # If this shell supports suffix pattern removal, then use it to avoid
694d21ab8bcSmrg  # forking. Hide the definitions single quotes in case the shell chokes
695d21ab8bcSmrg  # on unsupported syntax...
696d21ab8bcSmrg  _b='func_basename_result=${1##*/}'
697d21ab8bcSmrg  _d='case $1 in
698d21ab8bcSmrg        */*) func_dirname_result=${1%/*}$2 ;;
699d21ab8bcSmrg        *  ) func_dirname_result=$3        ;;
700d21ab8bcSmrg      esac'
701d21ab8bcSmrg
702d21ab8bcSmrgelse
703d21ab8bcSmrg  # ...otherwise fall back to using sed.
704d21ab8bcSmrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
705d21ab8bcSmrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
706d21ab8bcSmrg      if test "X$func_dirname_result" = "X$1"; then
707d21ab8bcSmrg        func_dirname_result=$3
708d21ab8bcSmrg      else
709d21ab8bcSmrg        func_append func_dirname_result "$2"
710d21ab8bcSmrg      fi'
711d21ab8bcSmrgfi
712d21ab8bcSmrg
713d21ab8bcSmrgeval 'func_basename ()
714d21ab8bcSmrg{
715d21ab8bcSmrg    $debug_cmd
716d21ab8bcSmrg
717d21ab8bcSmrg    '"$_b"'
718d21ab8bcSmrg}'
719d21ab8bcSmrg
720d21ab8bcSmrg
721d21ab8bcSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
722d21ab8bcSmrg# -------------------------------------------
723d21ab8bcSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
724d21ab8bcSmrg# otherwise set result to NONDIR_REPLACEMENT.
725d21ab8bcSmrgeval 'func_dirname ()
726d21ab8bcSmrg{
727d21ab8bcSmrg    $debug_cmd
728d21ab8bcSmrg
729d21ab8bcSmrg    '"$_d"'
730d21ab8bcSmrg}'
731d21ab8bcSmrg
732d21ab8bcSmrg
733d21ab8bcSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
734d21ab8bcSmrg# --------------------------------------------------------
735d21ab8bcSmrg# Perform func_basename and func_dirname in a single function
736d21ab8bcSmrg# call:
737d21ab8bcSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
738d21ab8bcSmrg#             add APPEND to the result, otherwise set result
739d21ab8bcSmrg#             to NONDIR_REPLACEMENT.
740d21ab8bcSmrg#             value returned in "$func_dirname_result"
741d21ab8bcSmrg#   basename: Compute filename of FILE.
7426ee7d557Smrg#             value returned in "$func_basename_result"
743d21ab8bcSmrg# For efficiency, we do not delegate to the functions above but instead
744d21ab8bcSmrg# duplicate the functionality here.
745d21ab8bcSmrgeval 'func_dirname_and_basename ()
746d21ab8bcSmrg{
747d21ab8bcSmrg    $debug_cmd
748d21ab8bcSmrg
749d21ab8bcSmrg    '"$_b"'
750d21ab8bcSmrg    '"$_d"'
751d21ab8bcSmrg}'
752d21ab8bcSmrg
753d21ab8bcSmrg
754d21ab8bcSmrg# func_echo ARG...
755d21ab8bcSmrg# ----------------
756d21ab8bcSmrg# Echo program name prefixed message.
757d21ab8bcSmrgfunc_echo ()
758d21ab8bcSmrg{
759d21ab8bcSmrg    $debug_cmd
760d21ab8bcSmrg
761d21ab8bcSmrg    _G_message=$*
762d21ab8bcSmrg
763d21ab8bcSmrg    func_echo_IFS=$IFS
764d21ab8bcSmrg    IFS=$nl
765d21ab8bcSmrg    for _G_line in $_G_message; do
766d21ab8bcSmrg      IFS=$func_echo_IFS
767d21ab8bcSmrg      $ECHO "$progname: $_G_line"
768d21ab8bcSmrg    done
769d21ab8bcSmrg    IFS=$func_echo_IFS
770d21ab8bcSmrg}
771d21ab8bcSmrg
772d21ab8bcSmrg
773d21ab8bcSmrg# func_echo_all ARG...
774d21ab8bcSmrg# --------------------
775d21ab8bcSmrg# Invoke $ECHO with all args, space-separated.
776d21ab8bcSmrgfunc_echo_all ()
777d21ab8bcSmrg{
778d21ab8bcSmrg    $ECHO "$*"
779d21ab8bcSmrg}
780d21ab8bcSmrg
781d21ab8bcSmrg
782d21ab8bcSmrg# func_echo_infix_1 INFIX ARG...
783d21ab8bcSmrg# ------------------------------
784d21ab8bcSmrg# Echo program name, followed by INFIX on the first line, with any
785d21ab8bcSmrg# additional lines not showing INFIX.
786d21ab8bcSmrgfunc_echo_infix_1 ()
787d21ab8bcSmrg{
788d21ab8bcSmrg    $debug_cmd
789d21ab8bcSmrg
790d21ab8bcSmrg    $require_term_colors
791d21ab8bcSmrg
792d21ab8bcSmrg    _G_infix=$1; shift
793d21ab8bcSmrg    _G_indent=$_G_infix
794d21ab8bcSmrg    _G_prefix="$progname: $_G_infix: "
795d21ab8bcSmrg    _G_message=$*
796d21ab8bcSmrg
797d21ab8bcSmrg    # Strip color escape sequences before counting printable length
798d21ab8bcSmrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
799d21ab8bcSmrg    do
800d21ab8bcSmrg      test -n "$_G_tc" && {
801d21ab8bcSmrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
802d21ab8bcSmrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
803d21ab8bcSmrg      }
804d21ab8bcSmrg    done
805d21ab8bcSmrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
806d21ab8bcSmrg
807d21ab8bcSmrg    func_echo_infix_1_IFS=$IFS
808d21ab8bcSmrg    IFS=$nl
809d21ab8bcSmrg    for _G_line in $_G_message; do
810d21ab8bcSmrg      IFS=$func_echo_infix_1_IFS
811d21ab8bcSmrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
812d21ab8bcSmrg      _G_prefix=$_G_indent
813d21ab8bcSmrg    done
814d21ab8bcSmrg    IFS=$func_echo_infix_1_IFS
815d21ab8bcSmrg}
816d21ab8bcSmrg
817d21ab8bcSmrg
818d21ab8bcSmrg# func_error ARG...
819d21ab8bcSmrg# -----------------
820d21ab8bcSmrg# Echo program name prefixed message to standard error.
821d21ab8bcSmrgfunc_error ()
822d21ab8bcSmrg{
823d21ab8bcSmrg    $debug_cmd
824d21ab8bcSmrg
825d21ab8bcSmrg    $require_term_colors
826d21ab8bcSmrg
827d21ab8bcSmrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
828d21ab8bcSmrg}
829d21ab8bcSmrg
830d21ab8bcSmrg
831d21ab8bcSmrg# func_fatal_error ARG...
832d21ab8bcSmrg# -----------------------
833d21ab8bcSmrg# Echo program name prefixed message to standard error, and exit.
834d21ab8bcSmrgfunc_fatal_error ()
835d21ab8bcSmrg{
836d21ab8bcSmrg    $debug_cmd
837d21ab8bcSmrg
838d21ab8bcSmrg    func_error "$*"
839d21ab8bcSmrg    exit $EXIT_FAILURE
840d21ab8bcSmrg}
841d21ab8bcSmrg
842d21ab8bcSmrg
843d21ab8bcSmrg# func_grep EXPRESSION FILENAME
844d21ab8bcSmrg# -----------------------------
845d21ab8bcSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
846d21ab8bcSmrgfunc_grep ()
8479c9ff80cSmrg{
848d21ab8bcSmrg    $debug_cmd
849d21ab8bcSmrg
850d21ab8bcSmrg    $GREP "$1" "$2" >/dev/null 2>&1
851d21ab8bcSmrg}
852d21ab8bcSmrg
8539c9ff80cSmrg
854d21ab8bcSmrg# func_len STRING
855d21ab8bcSmrg# ---------------
856d21ab8bcSmrg# Set func_len_result to the length of STRING. STRING may not
857d21ab8bcSmrg# start with a hyphen.
858d21ab8bcSmrg  test -z "$_G_HAVE_XSI_OPS" \
859d21ab8bcSmrg    && (eval 'x=a/b/c;
860d21ab8bcSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
861d21ab8bcSmrg    && _G_HAVE_XSI_OPS=yes
862d21ab8bcSmrg
863d21ab8bcSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
864d21ab8bcSmrg  eval 'func_len ()
865d21ab8bcSmrg  {
866d21ab8bcSmrg    $debug_cmd
867d21ab8bcSmrg
868d21ab8bcSmrg    func_len_result=${#1}
869d21ab8bcSmrg  }'
870d21ab8bcSmrgelse
871d21ab8bcSmrg  func_len ()
872d21ab8bcSmrg  {
873d21ab8bcSmrg    $debug_cmd
874d21ab8bcSmrg
875d21ab8bcSmrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
876d21ab8bcSmrg  }
877d21ab8bcSmrgfi
878d21ab8bcSmrg
879d21ab8bcSmrg
880d21ab8bcSmrg# func_mkdir_p DIRECTORY-PATH
881d21ab8bcSmrg# ---------------------------
882d21ab8bcSmrg# Make sure the entire path to DIRECTORY-PATH is available.
883d21ab8bcSmrgfunc_mkdir_p ()
884d21ab8bcSmrg{
885d21ab8bcSmrg    $debug_cmd
8869c9ff80cSmrg
887d21ab8bcSmrg    _G_directory_path=$1
888d21ab8bcSmrg    _G_dir_list=
889d21ab8bcSmrg
890d21ab8bcSmrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
891d21ab8bcSmrg
892d21ab8bcSmrg      # Protect directory names starting with '-'
893d21ab8bcSmrg      case $_G_directory_path in
894d21ab8bcSmrg        -*) _G_directory_path=./$_G_directory_path ;;
8959c9ff80cSmrg      esac
8969c9ff80cSmrg
8979c9ff80cSmrg      # While some portion of DIR does not yet exist...
898d21ab8bcSmrg      while test ! -d "$_G_directory_path"; do
8999c9ff80cSmrg        # ...make a list in topmost first order.  Use a colon delimited
9006ee7d557Smrg	# list in case some portion of path contains whitespace.
901d21ab8bcSmrg        _G_dir_list=$_G_directory_path:$_G_dir_list
9029c9ff80cSmrg
9039c9ff80cSmrg        # If the last portion added has no slash in it, the list is done
904d21ab8bcSmrg        case $_G_directory_path in */*) ;; *) break ;; esac
9059c9ff80cSmrg
9069c9ff80cSmrg        # ...otherwise throw away the child directory and loop
907d21ab8bcSmrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
9089c9ff80cSmrg      done
909d21ab8bcSmrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
9109c9ff80cSmrg
911d21ab8bcSmrg      func_mkdir_p_IFS=$IFS; IFS=:
912d21ab8bcSmrg      for _G_dir in $_G_dir_list; do
913d21ab8bcSmrg	IFS=$func_mkdir_p_IFS
914d21ab8bcSmrg        # mkdir can fail with a 'File exist' error if two processes
9159c9ff80cSmrg        # try to create one of the directories concurrently.  Don't
9169c9ff80cSmrg        # stop in that case!
917d21ab8bcSmrg        $MKDIR "$_G_dir" 2>/dev/null || :
9189c9ff80cSmrg      done
919d21ab8bcSmrg      IFS=$func_mkdir_p_IFS
9209c9ff80cSmrg
9219c9ff80cSmrg      # Bail out if we (or some other process) failed to create a directory.
922d21ab8bcSmrg      test -d "$_G_directory_path" || \
923d21ab8bcSmrg        func_fatal_error "Failed to create '$1'"
9249c9ff80cSmrg    fi
9259c9ff80cSmrg}
9261f0ac6a5Smrg
9271f0ac6a5Smrg
928d21ab8bcSmrg# func_mktempdir [BASENAME]
929d21ab8bcSmrg# -------------------------
9301f0ac6a5Smrg# Make a temporary directory that won't clash with other running
9311f0ac6a5Smrg# libtool processes, and avoids race conditions if possible.  If
932d21ab8bcSmrg# given, BASENAME is the basename for that directory.
9331f0ac6a5Smrgfunc_mktempdir ()
9341f0ac6a5Smrg{
935d21ab8bcSmrg    $debug_cmd
9361f0ac6a5Smrg
937d21ab8bcSmrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
938d21ab8bcSmrg
939d21ab8bcSmrg    if test : = "$opt_dry_run"; then
9401f0ac6a5Smrg      # Return a directory name, but don't create it in dry-run mode
941d21ab8bcSmrg      _G_tmpdir=$_G_template-$$
9421f0ac6a5Smrg    else
9431f0ac6a5Smrg
9441f0ac6a5Smrg      # If mktemp works, use that first and foremost
945d21ab8bcSmrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
9461f0ac6a5Smrg
947d21ab8bcSmrg      if test ! -d "$_G_tmpdir"; then
9489c9ff80cSmrg        # Failing that, at least try and use $RANDOM to avoid a race
949d21ab8bcSmrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
9501f0ac6a5Smrg
951d21ab8bcSmrg        func_mktempdir_umask=`umask`
9529c9ff80cSmrg        umask 0077
953d21ab8bcSmrg        $MKDIR "$_G_tmpdir"
954d21ab8bcSmrg        umask $func_mktempdir_umask
9551f0ac6a5Smrg      fi
9561f0ac6a5Smrg
9571f0ac6a5Smrg      # If we're not in dry-run mode, bomb out on failure
958d21ab8bcSmrg      test -d "$_G_tmpdir" || \
959d21ab8bcSmrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
9601f0ac6a5Smrg    fi
9611f0ac6a5Smrg
962d21ab8bcSmrg    $ECHO "$_G_tmpdir"
9631f0ac6a5Smrg}
9641f0ac6a5Smrg
9651f0ac6a5Smrg
966d21ab8bcSmrg# func_normal_abspath PATH
967d21ab8bcSmrg# ------------------------
968d21ab8bcSmrg# Remove doubled-up and trailing slashes, "." path components,
969d21ab8bcSmrg# and cancel out any ".." path components in PATH after making
970d21ab8bcSmrg# it an absolute path.
971d21ab8bcSmrgfunc_normal_abspath ()
9721f0ac6a5Smrg{
973d21ab8bcSmrg    $debug_cmd
974d21ab8bcSmrg
975d21ab8bcSmrg    # These SED scripts presuppose an absolute path with a trailing slash.
976d21ab8bcSmrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
977d21ab8bcSmrg    _G_pathcdr='s|^/[^/]*||'
978d21ab8bcSmrg    _G_removedotparts=':dotsl
979d21ab8bcSmrg		s|/\./|/|g
980d21ab8bcSmrg		t dotsl
981d21ab8bcSmrg		s|/\.$|/|'
982d21ab8bcSmrg    _G_collapseslashes='s|/\{1,\}|/|g'
983d21ab8bcSmrg    _G_finalslash='s|/*$|/|'
984d21ab8bcSmrg
985d21ab8bcSmrg    # Start from root dir and reassemble the path.
986d21ab8bcSmrg    func_normal_abspath_result=
987d21ab8bcSmrg    func_normal_abspath_tpath=$1
988d21ab8bcSmrg    func_normal_abspath_altnamespace=
989d21ab8bcSmrg    case $func_normal_abspath_tpath in
990d21ab8bcSmrg      "")
991d21ab8bcSmrg        # Empty path, that just means $cwd.
992d21ab8bcSmrg        func_stripname '' '/' "`pwd`"
993d21ab8bcSmrg        func_normal_abspath_result=$func_stripname_result
994d21ab8bcSmrg        return
995d21ab8bcSmrg        ;;
996d21ab8bcSmrg      # The next three entries are used to spot a run of precisely
997d21ab8bcSmrg      # two leading slashes without using negated character classes;
998d21ab8bcSmrg      # we take advantage of case's first-match behaviour.
999d21ab8bcSmrg      ///*)
1000d21ab8bcSmrg        # Unusual form of absolute path, do nothing.
1001d21ab8bcSmrg        ;;
1002d21ab8bcSmrg      //*)
1003d21ab8bcSmrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
1004d21ab8bcSmrg        # and for example Cygwin uses it to access remote file shares
1005d21ab8bcSmrg        # over CIFS/SMB, so we conserve a leading double slash if found.
1006d21ab8bcSmrg        func_normal_abspath_altnamespace=/
1007d21ab8bcSmrg        ;;
1008d21ab8bcSmrg      /*)
1009d21ab8bcSmrg        # Absolute path, do nothing.
1010d21ab8bcSmrg        ;;
10119c9ff80cSmrg      *)
1012d21ab8bcSmrg        # Relative path, prepend $cwd.
1013d21ab8bcSmrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
1014d21ab8bcSmrg        ;;
10159c9ff80cSmrg    esac
10169c9ff80cSmrg
1017d21ab8bcSmrg    # Cancel out all the simple stuff to save iterations.  We also want
1018d21ab8bcSmrg    # the path to end with a slash for ease of parsing, so make sure
1019d21ab8bcSmrg    # there is one (and only one) here.
1020d21ab8bcSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
1021d21ab8bcSmrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
1022d21ab8bcSmrg    while :; do
1023d21ab8bcSmrg      # Processed it all yet?
1024d21ab8bcSmrg      if test / = "$func_normal_abspath_tpath"; then
1025d21ab8bcSmrg        # If we ascended to the root using ".." the result may be empty now.
1026d21ab8bcSmrg        if test -z "$func_normal_abspath_result"; then
1027d21ab8bcSmrg          func_normal_abspath_result=/
1028d21ab8bcSmrg        fi
1029d21ab8bcSmrg        break
1030d21ab8bcSmrg      fi
1031d21ab8bcSmrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
1032d21ab8bcSmrg          -e "$_G_pathcar"`
1033d21ab8bcSmrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
1034d21ab8bcSmrg          -e "$_G_pathcdr"`
1035d21ab8bcSmrg      # Figure out what to do with it
1036d21ab8bcSmrg      case $func_normal_abspath_tcomponent in
1037d21ab8bcSmrg        "")
1038d21ab8bcSmrg          # Trailing empty path component, ignore it.
1039d21ab8bcSmrg          ;;
1040d21ab8bcSmrg        ..)
1041d21ab8bcSmrg          # Parent dir; strip last assembled component from result.
1042d21ab8bcSmrg          func_dirname "$func_normal_abspath_result"
1043d21ab8bcSmrg          func_normal_abspath_result=$func_dirname_result
1044d21ab8bcSmrg          ;;
1045d21ab8bcSmrg        *)
1046d21ab8bcSmrg          # Actual path component, append it.
1047d21ab8bcSmrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1048d21ab8bcSmrg          ;;
1049d21ab8bcSmrg      esac
1050d21ab8bcSmrg    done
1051d21ab8bcSmrg    # Restore leading double-slash if one was found on entry.
1052d21ab8bcSmrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1053d21ab8bcSmrg}
1054d21ab8bcSmrg
1055d21ab8bcSmrg
1056d21ab8bcSmrg# func_notquiet ARG...
1057d21ab8bcSmrg# --------------------
1058d21ab8bcSmrg# Echo program name prefixed message only when not in quiet mode.
1059d21ab8bcSmrgfunc_notquiet ()
1060d21ab8bcSmrg{
1061d21ab8bcSmrg    $debug_cmd
1062d21ab8bcSmrg
1063d21ab8bcSmrg    $opt_quiet || func_echo ${1+"$@"}
1064d21ab8bcSmrg
1065d21ab8bcSmrg    # A bug in bash halts the script if the last line of a function
1066d21ab8bcSmrg    # fails when set -e is in force, so we need another command to
1067d21ab8bcSmrg    # work around that:
1068d21ab8bcSmrg    :
1069d21ab8bcSmrg}
1070d21ab8bcSmrg
1071d21ab8bcSmrg
1072d21ab8bcSmrg# func_relative_path SRCDIR DSTDIR
1073d21ab8bcSmrg# --------------------------------
1074d21ab8bcSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1075d21ab8bcSmrgfunc_relative_path ()
1076d21ab8bcSmrg{
1077d21ab8bcSmrg    $debug_cmd
1078d21ab8bcSmrg
1079d21ab8bcSmrg    func_relative_path_result=
1080d21ab8bcSmrg    func_normal_abspath "$1"
1081d21ab8bcSmrg    func_relative_path_tlibdir=$func_normal_abspath_result
1082d21ab8bcSmrg    func_normal_abspath "$2"
1083d21ab8bcSmrg    func_relative_path_tbindir=$func_normal_abspath_result
1084d21ab8bcSmrg
1085d21ab8bcSmrg    # Ascend the tree starting from libdir
1086d21ab8bcSmrg    while :; do
1087d21ab8bcSmrg      # check if we have found a prefix of bindir
1088d21ab8bcSmrg      case $func_relative_path_tbindir in
1089d21ab8bcSmrg        $func_relative_path_tlibdir)
1090d21ab8bcSmrg          # found an exact match
1091d21ab8bcSmrg          func_relative_path_tcancelled=
1092d21ab8bcSmrg          break
1093d21ab8bcSmrg          ;;
1094d21ab8bcSmrg        $func_relative_path_tlibdir*)
1095d21ab8bcSmrg          # found a matching prefix
1096d21ab8bcSmrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1097d21ab8bcSmrg          func_relative_path_tcancelled=$func_stripname_result
1098d21ab8bcSmrg          if test -z "$func_relative_path_result"; then
1099d21ab8bcSmrg            func_relative_path_result=.
1100d21ab8bcSmrg          fi
1101d21ab8bcSmrg          break
1102d21ab8bcSmrg          ;;
1103d21ab8bcSmrg        *)
1104d21ab8bcSmrg          func_dirname $func_relative_path_tlibdir
1105d21ab8bcSmrg          func_relative_path_tlibdir=$func_dirname_result
1106d21ab8bcSmrg          if test -z "$func_relative_path_tlibdir"; then
1107d21ab8bcSmrg            # Have to descend all the way to the root!
1108d21ab8bcSmrg            func_relative_path_result=../$func_relative_path_result
1109d21ab8bcSmrg            func_relative_path_tcancelled=$func_relative_path_tbindir
1110d21ab8bcSmrg            break
1111d21ab8bcSmrg          fi
1112d21ab8bcSmrg          func_relative_path_result=../$func_relative_path_result
1113d21ab8bcSmrg          ;;
1114d21ab8bcSmrg      esac
1115d21ab8bcSmrg    done
1116d21ab8bcSmrg
1117d21ab8bcSmrg    # Now calculate path; take care to avoid doubling-up slashes.
1118d21ab8bcSmrg    func_stripname '' '/' "$func_relative_path_result"
1119d21ab8bcSmrg    func_relative_path_result=$func_stripname_result
1120d21ab8bcSmrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
1121d21ab8bcSmrg    if test -n "$func_stripname_result"; then
1122d21ab8bcSmrg      func_append func_relative_path_result "/$func_stripname_result"
1123d21ab8bcSmrg    fi
1124d21ab8bcSmrg
1125d21ab8bcSmrg    # Normalisation. If bindir is libdir, return '.' else relative path.
1126d21ab8bcSmrg    if test -n "$func_relative_path_result"; then
1127d21ab8bcSmrg      func_stripname './' '' "$func_relative_path_result"
1128d21ab8bcSmrg      func_relative_path_result=$func_stripname_result
1129d21ab8bcSmrg    fi
1130d21ab8bcSmrg
1131d21ab8bcSmrg    test -n "$func_relative_path_result" || func_relative_path_result=.
1132d21ab8bcSmrg
1133d21ab8bcSmrg    :
1134d21ab8bcSmrg}
1135d21ab8bcSmrg
1136d21ab8bcSmrg
1137d21ab8bcSmrg# func_quote_portable EVAL ARG
1138d21ab8bcSmrg# ----------------------------
1139d21ab8bcSmrg# Internal function to portably implement func_quote_arg.  Note that we still
1140d21ab8bcSmrg# keep attention to performance here so we as much as possible try to avoid
1141d21ab8bcSmrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)).
1142d21ab8bcSmrgfunc_quote_portable ()
1143d21ab8bcSmrg{
1144d21ab8bcSmrg    $debug_cmd
1145d21ab8bcSmrg
1146d21ab8bcSmrg    $require_check_ifs_backslash
1147d21ab8bcSmrg
1148d21ab8bcSmrg    func_quote_portable_result=$2
1149d21ab8bcSmrg
1150d21ab8bcSmrg    # one-time-loop (easy break)
1151d21ab8bcSmrg    while true
1152d21ab8bcSmrg    do
1153d21ab8bcSmrg      if $1; then
1154d21ab8bcSmrg        func_quote_portable_result=`$ECHO "$2" | $SED \
1155d21ab8bcSmrg          -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
1156d21ab8bcSmrg        break
1157d21ab8bcSmrg      fi
1158d21ab8bcSmrg
1159d21ab8bcSmrg      # Quote for eval.
1160d21ab8bcSmrg      case $func_quote_portable_result in
1161d21ab8bcSmrg        *[\\\`\"\$]*)
1162d21ab8bcSmrg          # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string
1163d21ab8bcSmrg          # contains the shell wildcard characters.
1164d21ab8bcSmrg          case $check_ifs_backshlash_broken$func_quote_portable_result in
1165d21ab8bcSmrg            :*|*[\[\*\?]*)
1166d21ab8bcSmrg              func_quote_portable_result=`$ECHO "$func_quote_portable_result" \
1167d21ab8bcSmrg                  | $SED "$sed_quote_subst"`
1168d21ab8bcSmrg              break
1169d21ab8bcSmrg              ;;
1170d21ab8bcSmrg          esac
1171d21ab8bcSmrg
1172d21ab8bcSmrg          func_quote_portable_old_IFS=$IFS
1173d21ab8bcSmrg          for _G_char in '\' '`' '"' '$'
1174d21ab8bcSmrg          do
1175d21ab8bcSmrg            # STATE($1) PREV($2) SEPARATOR($3)
1176d21ab8bcSmrg            set start "" ""
1177d21ab8bcSmrg            func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
1178d21ab8bcSmrg            IFS=$_G_char
1179d21ab8bcSmrg            for _G_part in $func_quote_portable_result
1180d21ab8bcSmrg            do
1181d21ab8bcSmrg              case $1 in
1182d21ab8bcSmrg              quote)
1183d21ab8bcSmrg                func_append func_quote_portable_result "$3$2"
1184d21ab8bcSmrg                set quote "$_G_part" "\\$_G_char"
1185d21ab8bcSmrg                ;;
1186d21ab8bcSmrg              start)
1187d21ab8bcSmrg                set first "" ""
1188d21ab8bcSmrg                func_quote_portable_result=
1189d21ab8bcSmrg                ;;
1190d21ab8bcSmrg              first)
1191d21ab8bcSmrg                set quote "$_G_part" ""
1192d21ab8bcSmrg                ;;
1193d21ab8bcSmrg              esac
1194d21ab8bcSmrg            done
1195d21ab8bcSmrg          done
1196d21ab8bcSmrg          IFS=$func_quote_portable_old_IFS
1197d21ab8bcSmrg          ;;
1198d21ab8bcSmrg        *) ;;
1199d21ab8bcSmrg      esac
1200d21ab8bcSmrg      break
1201d21ab8bcSmrg    done
1202d21ab8bcSmrg
1203d21ab8bcSmrg    func_quote_portable_unquoted_result=$func_quote_portable_result
1204d21ab8bcSmrg    case $func_quote_portable_result in
1205d21ab8bcSmrg      # double-quote args containing shell metacharacters to delay
1206d21ab8bcSmrg      # word splitting, command substitution and variable expansion
1207d21ab8bcSmrg      # for a subsequent eval.
1208d21ab8bcSmrg      # many bourne shells cannot handle close brackets correctly
12099c9ff80cSmrg      # in scan sets, so we specify it separately.
12109c9ff80cSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1211d21ab8bcSmrg        func_quote_portable_result=\"$func_quote_portable_result\"
12129c9ff80cSmrg        ;;
12131f0ac6a5Smrg    esac
12141f0ac6a5Smrg}
12151f0ac6a5Smrg
12161f0ac6a5Smrg
1217d21ab8bcSmrg# func_quotefast_eval ARG
1218d21ab8bcSmrg# -----------------------
1219d21ab8bcSmrg# Quote one ARG (internal).  This is equivalent to 'func_quote_arg eval ARG',
1220d21ab8bcSmrg# but optimized for speed.  Result is stored in $func_quotefast_eval.
1221d21ab8bcSmrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
1222d21ab8bcSmrg  printf -v _GL_test_printf_tilde %q '~'
1223d21ab8bcSmrg  if test '\~' = "$_GL_test_printf_tilde"; then
1224d21ab8bcSmrg    func_quotefast_eval ()
1225d21ab8bcSmrg    {
1226d21ab8bcSmrg      printf -v func_quotefast_eval_result %q "$1"
1227d21ab8bcSmrg    }
1228d21ab8bcSmrg  else
1229d21ab8bcSmrg    # Broken older Bash implementations.  Make those faster too if possible.
1230d21ab8bcSmrg    func_quotefast_eval ()
1231d21ab8bcSmrg    {
1232d21ab8bcSmrg      case $1 in
1233d21ab8bcSmrg        '~'*)
1234d21ab8bcSmrg          func_quote_portable false "$1"
1235d21ab8bcSmrg          func_quotefast_eval_result=$func_quote_portable_result
1236d21ab8bcSmrg          ;;
1237d21ab8bcSmrg        *)
1238d21ab8bcSmrg          printf -v func_quotefast_eval_result %q "$1"
1239d21ab8bcSmrg          ;;
1240d21ab8bcSmrg      esac
1241d21ab8bcSmrg    }
1242d21ab8bcSmrg  fi
1243d21ab8bcSmrgelse
1244d21ab8bcSmrg  func_quotefast_eval ()
1245d21ab8bcSmrg  {
1246d21ab8bcSmrg    func_quote_portable false "$1"
1247d21ab8bcSmrg    func_quotefast_eval_result=$func_quote_portable_result
1248d21ab8bcSmrg  }
1249d21ab8bcSmrgfi
1250d21ab8bcSmrg
1251d21ab8bcSmrg
1252d21ab8bcSmrg# func_quote_arg MODEs ARG
1253d21ab8bcSmrg# ------------------------
1254d21ab8bcSmrg# Quote one ARG to be evaled later.  MODEs argument may contain zero or more
1255d21ab8bcSmrg# specifiers listed below separated by ',' character.  This function returns two
1256d21ab8bcSmrg# values:
1257d21ab8bcSmrg#   i) func_quote_arg_result
1258d21ab8bcSmrg#      double-quoted (when needed), suitable for a subsequent eval
1259d21ab8bcSmrg#  ii) func_quote_arg_unquoted_result
1260d21ab8bcSmrg#      has all characters that are still active within double
1261d21ab8bcSmrg#      quotes backslashified.  Available only if 'unquoted' is specified.
1262d21ab8bcSmrg#
1263d21ab8bcSmrg# Available modes:
1264d21ab8bcSmrg# ----------------
1265d21ab8bcSmrg# 'eval' (default)
1266d21ab8bcSmrg#       - escape shell special characters
1267d21ab8bcSmrg# 'expand'
1268d21ab8bcSmrg#       - the same as 'eval';  but do not quote variable references
1269d21ab8bcSmrg# 'pretty'
1270d21ab8bcSmrg#       - request aesthetic output, i.e. '"a b"' instead of 'a\ b'.  This might
1271d21ab8bcSmrg#         be used later in func_quote to get output like: 'echo "a b"' instead
1272d21ab8bcSmrg#         of 'echo a\ b'.  This is slower than default on some shells.
1273d21ab8bcSmrg# 'unquoted'
1274d21ab8bcSmrg#       - produce also $func_quote_arg_unquoted_result which does not contain
1275d21ab8bcSmrg#         wrapping double-quotes.
1276d21ab8bcSmrg#
1277d21ab8bcSmrg# Examples for 'func_quote_arg pretty,unquoted string':
1278d21ab8bcSmrg#
1279d21ab8bcSmrg#   string      | *_result              | *_unquoted_result
1280d21ab8bcSmrg#   ------------+-----------------------+-------------------
1281d21ab8bcSmrg#   "           | \"                    | \"
1282d21ab8bcSmrg#   a b         | "a b"                 | a b
1283d21ab8bcSmrg#   "a b"       | "\"a b\""             | \"a b\"
1284d21ab8bcSmrg#   *           | "*"                   | *
1285d21ab8bcSmrg#   z="${x-$y}" | "z=\"\${x-\$y}\""     | z=\"\${x-\$y}\"
1286d21ab8bcSmrg#
1287d21ab8bcSmrg# Examples for 'func_quote_arg pretty,unquoted,expand string':
1288d21ab8bcSmrg#
1289d21ab8bcSmrg#   string        |   *_result          |  *_unquoted_result
1290d21ab8bcSmrg#   --------------+---------------------+--------------------
1291d21ab8bcSmrg#   z="${x-$y}"   | "z=\"${x-$y}\""     | z=\"${x-$y}\"
1292d21ab8bcSmrgfunc_quote_arg ()
12931f0ac6a5Smrg{
1294d21ab8bcSmrg    _G_quote_expand=false
1295d21ab8bcSmrg    case ,$1, in
1296d21ab8bcSmrg      *,expand,*)
1297d21ab8bcSmrg        _G_quote_expand=:
1298d21ab8bcSmrg        ;;
12999c9ff80cSmrg    esac
13009c9ff80cSmrg
1301d21ab8bcSmrg    case ,$1, in
1302d21ab8bcSmrg      *,pretty,*|*,expand,*|*,unquoted,*)
1303d21ab8bcSmrg        func_quote_portable $_G_quote_expand "$2"
1304d21ab8bcSmrg        func_quote_arg_result=$func_quote_portable_result
1305d21ab8bcSmrg        func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
1306d21ab8bcSmrg        ;;
1307d21ab8bcSmrg      *)
1308d21ab8bcSmrg        # Faster quote-for-eval for some shells.
1309d21ab8bcSmrg        func_quotefast_eval "$2"
1310d21ab8bcSmrg        func_quote_arg_result=$func_quotefast_eval_result
13119c9ff80cSmrg        ;;
13129c9ff80cSmrg    esac
1313d21ab8bcSmrg}
1314d21ab8bcSmrg
13159c9ff80cSmrg
1316d21ab8bcSmrg# func_quote MODEs ARGs...
1317d21ab8bcSmrg# ------------------------
1318d21ab8bcSmrg# Quote all ARGs to be evaled later and join them into single command.  See
1319d21ab8bcSmrg# func_quote_arg's description for more info.
1320d21ab8bcSmrgfunc_quote ()
1321d21ab8bcSmrg{
1322d21ab8bcSmrg    $debug_cmd
1323d21ab8bcSmrg    _G_func_quote_mode=$1 ; shift
1324d21ab8bcSmrg    func_quote_result=
1325d21ab8bcSmrg    while test 0 -lt $#; do
1326d21ab8bcSmrg      func_quote_arg "$_G_func_quote_mode" "$1"
1327d21ab8bcSmrg      if test -n "$func_quote_result"; then
1328d21ab8bcSmrg        func_append func_quote_result " $func_quote_arg_result"
1329d21ab8bcSmrg      else
1330d21ab8bcSmrg        func_append func_quote_result "$func_quote_arg_result"
1331d21ab8bcSmrg      fi
1332d21ab8bcSmrg      shift
1333d21ab8bcSmrg    done
13341f0ac6a5Smrg}
13351f0ac6a5Smrg
13361f0ac6a5Smrg
1337d21ab8bcSmrg# func_stripname PREFIX SUFFIX NAME
1338d21ab8bcSmrg# ---------------------------------
1339d21ab8bcSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1340d21ab8bcSmrg# PREFIX and SUFFIX must not contain globbing or regex special
1341d21ab8bcSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
1342d21ab8bcSmrg# dot (in which case that matches only a dot).
1343d21ab8bcSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
1344d21ab8bcSmrg  eval 'func_stripname ()
1345d21ab8bcSmrg  {
1346d21ab8bcSmrg    $debug_cmd
1347d21ab8bcSmrg
1348d21ab8bcSmrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1349d21ab8bcSmrg    # positional parameters, so assign one to ordinary variable first.
1350d21ab8bcSmrg    func_stripname_result=$3
1351d21ab8bcSmrg    func_stripname_result=${func_stripname_result#"$1"}
1352d21ab8bcSmrg    func_stripname_result=${func_stripname_result%"$2"}
1353d21ab8bcSmrg  }'
1354d21ab8bcSmrgelse
1355d21ab8bcSmrg  func_stripname ()
1356d21ab8bcSmrg  {
1357d21ab8bcSmrg    $debug_cmd
1358d21ab8bcSmrg
1359d21ab8bcSmrg    case $2 in
1360d21ab8bcSmrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1361d21ab8bcSmrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1362d21ab8bcSmrg    esac
1363d21ab8bcSmrg  }
1364d21ab8bcSmrgfi
1365d21ab8bcSmrg
1366d21ab8bcSmrg
1367d21ab8bcSmrg# func_show_eval CMD [FAIL_EXP]
1368d21ab8bcSmrg# -----------------------------
1369d21ab8bcSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
13709c9ff80cSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
13719c9ff80cSmrg# is given, then evaluate it.
13729c9ff80cSmrgfunc_show_eval ()
13731f0ac6a5Smrg{
1374d21ab8bcSmrg    $debug_cmd
1375d21ab8bcSmrg
1376d21ab8bcSmrg    _G_cmd=$1
1377d21ab8bcSmrg    _G_fail_exp=${2-':'}
1378d21ab8bcSmrg
1379d21ab8bcSmrg    func_quote_arg pretty,expand "$_G_cmd"
1380d21ab8bcSmrg    eval "func_notquiet $func_quote_arg_result"
1381d21ab8bcSmrg
1382d21ab8bcSmrg    $opt_dry_run || {
1383d21ab8bcSmrg      eval "$_G_cmd"
1384d21ab8bcSmrg      _G_status=$?
1385d21ab8bcSmrg      if test 0 -ne "$_G_status"; then
1386d21ab8bcSmrg	eval "(exit $_G_status); $_G_fail_exp"
1387d21ab8bcSmrg      fi
1388d21ab8bcSmrg    }
1389d21ab8bcSmrg}
1390d21ab8bcSmrg
1391d21ab8bcSmrg
1392d21ab8bcSmrg# func_show_eval_locale CMD [FAIL_EXP]
1393d21ab8bcSmrg# ------------------------------------
1394d21ab8bcSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1395d21ab8bcSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1396d21ab8bcSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
1397d21ab8bcSmrgfunc_show_eval_locale ()
1398d21ab8bcSmrg{
1399d21ab8bcSmrg    $debug_cmd
1400d21ab8bcSmrg
1401d21ab8bcSmrg    _G_cmd=$1
1402d21ab8bcSmrg    _G_fail_exp=${2-':'}
1403d21ab8bcSmrg
1404d21ab8bcSmrg    $opt_quiet || {
1405d21ab8bcSmrg      func_quote_arg expand,pretty "$_G_cmd"
1406d21ab8bcSmrg      eval "func_echo $func_quote_arg_result"
1407d21ab8bcSmrg    }
1408d21ab8bcSmrg
1409d21ab8bcSmrg    $opt_dry_run || {
1410d21ab8bcSmrg      eval "$_G_user_locale
1411d21ab8bcSmrg	    $_G_cmd"
1412d21ab8bcSmrg      _G_status=$?
1413d21ab8bcSmrg      eval "$_G_safe_locale"
1414d21ab8bcSmrg      if test 0 -ne "$_G_status"; then
1415d21ab8bcSmrg	eval "(exit $_G_status); $_G_fail_exp"
1416d21ab8bcSmrg      fi
1417d21ab8bcSmrg    }
1418d21ab8bcSmrg}
1419d21ab8bcSmrg
1420d21ab8bcSmrg
1421d21ab8bcSmrg# func_tr_sh
1422d21ab8bcSmrg# ----------
1423d21ab8bcSmrg# Turn $1 into a string suitable for a shell variable name.
1424d21ab8bcSmrg# Result is stored in $func_tr_sh_result.  All characters
1425d21ab8bcSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1426d21ab8bcSmrg# if $1 begins with a digit, a '_' is prepended as well.
1427d21ab8bcSmrgfunc_tr_sh ()
1428d21ab8bcSmrg{
1429d21ab8bcSmrg    $debug_cmd
1430d21ab8bcSmrg
1431d21ab8bcSmrg    case $1 in
1432d21ab8bcSmrg    [0-9]* | *[!a-zA-Z0-9_]*)
1433d21ab8bcSmrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1434d21ab8bcSmrg      ;;
1435d21ab8bcSmrg    * )
1436d21ab8bcSmrg      func_tr_sh_result=$1
1437d21ab8bcSmrg      ;;
1438d21ab8bcSmrg    esac
1439d21ab8bcSmrg}
1440d21ab8bcSmrg
1441d21ab8bcSmrg
1442d21ab8bcSmrg# func_verbose ARG...
1443d21ab8bcSmrg# -------------------
1444d21ab8bcSmrg# Echo program name prefixed message in verbose mode only.
1445d21ab8bcSmrgfunc_verbose ()
1446d21ab8bcSmrg{
1447d21ab8bcSmrg    $debug_cmd
1448d21ab8bcSmrg
1449d21ab8bcSmrg    $opt_verbose && func_echo "$*"
1450d21ab8bcSmrg
1451d21ab8bcSmrg    :
1452d21ab8bcSmrg}
1453d21ab8bcSmrg
1454d21ab8bcSmrg
1455d21ab8bcSmrg# func_warn_and_continue ARG...
1456d21ab8bcSmrg# -----------------------------
1457d21ab8bcSmrg# Echo program name prefixed warning message to standard error.
1458d21ab8bcSmrgfunc_warn_and_continue ()
1459d21ab8bcSmrg{
1460d21ab8bcSmrg    $debug_cmd
1461d21ab8bcSmrg
1462d21ab8bcSmrg    $require_term_colors
1463d21ab8bcSmrg
1464d21ab8bcSmrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1465d21ab8bcSmrg}
1466d21ab8bcSmrg
1467d21ab8bcSmrg
1468d21ab8bcSmrg# func_warning CATEGORY ARG...
1469d21ab8bcSmrg# ----------------------------
1470d21ab8bcSmrg# Echo program name prefixed warning message to standard error. Warning
1471d21ab8bcSmrg# messages can be filtered according to CATEGORY, where this function
1472d21ab8bcSmrg# elides messages where CATEGORY is not listed in the global variable
1473d21ab8bcSmrg# 'opt_warning_types'.
1474d21ab8bcSmrgfunc_warning ()
1475d21ab8bcSmrg{
1476d21ab8bcSmrg    $debug_cmd
1477d21ab8bcSmrg
1478d21ab8bcSmrg    # CATEGORY must be in the warning_categories list!
1479d21ab8bcSmrg    case " $warning_categories " in
1480d21ab8bcSmrg      *" $1 "*) ;;
1481d21ab8bcSmrg      *) func_internal_error "invalid warning category '$1'" ;;
1482d21ab8bcSmrg    esac
1483d21ab8bcSmrg
1484d21ab8bcSmrg    _G_category=$1
1485d21ab8bcSmrg    shift
1486d21ab8bcSmrg
1487d21ab8bcSmrg    case " $opt_warning_types " in
1488d21ab8bcSmrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
1489d21ab8bcSmrg    esac
1490d21ab8bcSmrg}
1491d21ab8bcSmrg
1492d21ab8bcSmrg
1493d21ab8bcSmrg# func_sort_ver VER1 VER2
1494d21ab8bcSmrg# -----------------------
1495d21ab8bcSmrg# 'sort -V' is not generally available.
1496d21ab8bcSmrg# Note this deviates from the version comparison in automake
1497d21ab8bcSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1498d21ab8bcSmrg# but this should suffice as we won't be specifying old
1499d21ab8bcSmrg# version formats or redundant trailing .0 in bootstrap.conf.
1500d21ab8bcSmrg# If we did want full compatibility then we should probably
1501d21ab8bcSmrg# use m4_version_compare from autoconf.
1502d21ab8bcSmrgfunc_sort_ver ()
1503d21ab8bcSmrg{
1504d21ab8bcSmrg    $debug_cmd
1505d21ab8bcSmrg
1506d21ab8bcSmrg    printf '%s\n%s\n' "$1" "$2" \
1507d21ab8bcSmrg      | 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
1508d21ab8bcSmrg}
1509d21ab8bcSmrg
1510d21ab8bcSmrg# func_lt_ver PREV CURR
1511d21ab8bcSmrg# ---------------------
1512d21ab8bcSmrg# Return true if PREV and CURR are in the correct order according to
1513d21ab8bcSmrg# func_sort_ver, otherwise false.  Use it like this:
1514d21ab8bcSmrg#
1515d21ab8bcSmrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1516d21ab8bcSmrgfunc_lt_ver ()
1517d21ab8bcSmrg{
1518d21ab8bcSmrg    $debug_cmd
1519d21ab8bcSmrg
1520d21ab8bcSmrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1521d21ab8bcSmrg}
1522d21ab8bcSmrg
1523d21ab8bcSmrg
1524d21ab8bcSmrg# Local variables:
1525d21ab8bcSmrg# mode: shell-script
1526d21ab8bcSmrg# sh-indentation: 2
1527d21ab8bcSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1528d21ab8bcSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1529d21ab8bcSmrg# time-stamp-time-zone: "UTC"
1530d21ab8bcSmrg# End:
1531d21ab8bcSmrg#! /bin/sh
1532d21ab8bcSmrg
1533d21ab8bcSmrg# A portable, pluggable option parser for Bourne shell.
1534d21ab8bcSmrg# Written by Gary V. Vaughan, 2010
1535d21ab8bcSmrg
1536d21ab8bcSmrg# This is free software.  There is NO warranty; not even for
1537d21ab8bcSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1538d21ab8bcSmrg#
15396ee7d557Smrg# Copyright (C) 2010-2019, 2021, 2023-2024 Bootstrap Authors
1540d21ab8bcSmrg#
1541d21ab8bcSmrg# This file is dual licensed under the terms of the MIT license
15426ee7d557Smrg# <https://opensource.org/licenses/MIT>, and GPL version 2 or later
15436ee7d557Smrg# <https://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
1544d21ab8bcSmrg# these licenses when using or redistributing this software or any of
1545d21ab8bcSmrg# the files within it.  See the URLs above, or the file `LICENSE`
1546d21ab8bcSmrg# included in the Bootstrap distribution for the full license texts.
1547d21ab8bcSmrg
1548d21ab8bcSmrg# Please report bugs or propose patches to:
1549d21ab8bcSmrg# <https://github.com/gnulib-modules/bootstrap/issues>
1550d21ab8bcSmrg
1551d21ab8bcSmrg# Set a version string for this script.
1552d21ab8bcSmrgscriptversion=2019-02-19.15; # UTC
1553d21ab8bcSmrg
1554d21ab8bcSmrg
1555d21ab8bcSmrg## ------ ##
1556d21ab8bcSmrg## Usage. ##
1557d21ab8bcSmrg## ------ ##
1558d21ab8bcSmrg
1559d21ab8bcSmrg# This file is a library for parsing options in your shell scripts along
1560d21ab8bcSmrg# with assorted other useful supporting features that you can make use
1561d21ab8bcSmrg# of too.
1562d21ab8bcSmrg#
1563d21ab8bcSmrg# For the simplest scripts you might need only:
1564d21ab8bcSmrg#
1565d21ab8bcSmrg#   #!/bin/sh
1566d21ab8bcSmrg#   . relative/path/to/funclib.sh
1567d21ab8bcSmrg#   . relative/path/to/options-parser
1568d21ab8bcSmrg#   scriptversion=1.0
1569d21ab8bcSmrg#   func_options ${1+"$@"}
1570d21ab8bcSmrg#   eval set dummy "$func_options_result"; shift
1571d21ab8bcSmrg#   ...rest of your script...
1572d21ab8bcSmrg#
1573d21ab8bcSmrg# In order for the '--version' option to work, you will need to have a
1574d21ab8bcSmrg# suitably formatted comment like the one at the top of this file
1575d21ab8bcSmrg# starting with '# Written by ' and ending with '# Copyright'.
1576d21ab8bcSmrg#
1577d21ab8bcSmrg# For '-h' and '--help' to work, you will also need a one line
1578d21ab8bcSmrg# description of your script's purpose in a comment directly above the
1579d21ab8bcSmrg# '# Written by ' line, like the one at the top of this file.
1580d21ab8bcSmrg#
1581d21ab8bcSmrg# The default options also support '--debug', which will turn on shell
1582d21ab8bcSmrg# execution tracing (see the comment above debug_cmd below for another
1583d21ab8bcSmrg# use), and '--verbose' and the func_verbose function to allow your script
1584d21ab8bcSmrg# to display verbose messages only when your user has specified
1585d21ab8bcSmrg# '--verbose'.
1586d21ab8bcSmrg#
1587d21ab8bcSmrg# After sourcing this file, you can plug in processing for additional
1588d21ab8bcSmrg# options by amending the variables from the 'Configuration' section
1589d21ab8bcSmrg# below, and following the instructions in the 'Option parsing'
1590d21ab8bcSmrg# section further down.
1591d21ab8bcSmrg
1592d21ab8bcSmrg## -------------- ##
1593d21ab8bcSmrg## Configuration. ##
1594d21ab8bcSmrg## -------------- ##
1595d21ab8bcSmrg
1596d21ab8bcSmrg# You should override these variables in your script after sourcing this
1597d21ab8bcSmrg# file so that they reflect the customisations you have added to the
1598d21ab8bcSmrg# option parser.
1599d21ab8bcSmrg
1600d21ab8bcSmrg# The usage line for option parsing errors and the start of '-h' and
1601d21ab8bcSmrg# '--help' output messages. You can embed shell variables for delayed
1602d21ab8bcSmrg# expansion at the time the message is displayed, but you will need to
1603d21ab8bcSmrg# quote other shell meta-characters carefully to prevent them being
1604d21ab8bcSmrg# expanded when the contents are evaled.
1605d21ab8bcSmrgusage='$progpath [OPTION]...'
1606d21ab8bcSmrg
1607d21ab8bcSmrg# Short help message in response to '-h' and '--help'.  Add to this or
1608d21ab8bcSmrg# override it after sourcing this library to reflect the full set of
1609d21ab8bcSmrg# options your script accepts.
1610d21ab8bcSmrgusage_message="\
1611d21ab8bcSmrg       --debug        enable verbose shell tracing
1612d21ab8bcSmrg   -W, --warnings=CATEGORY
1613d21ab8bcSmrg                      report the warnings falling in CATEGORY [all]
1614d21ab8bcSmrg   -v, --verbose      verbosely report processing
1615d21ab8bcSmrg       --version      print version information and exit
1616d21ab8bcSmrg   -h, --help         print short or long help message and exit
1617d21ab8bcSmrg"
1618d21ab8bcSmrg
1619d21ab8bcSmrg# Additional text appended to 'usage_message' in response to '--help'.
1620d21ab8bcSmrglong_help_message="
1621d21ab8bcSmrgWarning categories include:
1622d21ab8bcSmrg       'all'          show all warnings
1623d21ab8bcSmrg       'none'         turn off all the warnings
1624d21ab8bcSmrg       'error'        warnings are treated as fatal errors"
1625d21ab8bcSmrg
1626d21ab8bcSmrg# Help message printed before fatal option parsing errors.
1627d21ab8bcSmrgfatal_help="Try '\$progname --help' for more information."
1628d21ab8bcSmrg
1629d21ab8bcSmrg
1630d21ab8bcSmrg
1631d21ab8bcSmrg## ------------------------- ##
1632d21ab8bcSmrg## Hook function management. ##
1633d21ab8bcSmrg## ------------------------- ##
1634d21ab8bcSmrg
1635d21ab8bcSmrg# This section contains functions for adding, removing, and running hooks
1636d21ab8bcSmrg# in the main code.  A hook is just a list of function names that can be
1637d21ab8bcSmrg# run in order later on.
1638d21ab8bcSmrg
1639d21ab8bcSmrg# func_hookable FUNC_NAME
1640d21ab8bcSmrg# -----------------------
1641d21ab8bcSmrg# Declare that FUNC_NAME will run hooks added with
1642d21ab8bcSmrg# 'func_add_hook FUNC_NAME ...'.
1643d21ab8bcSmrgfunc_hookable ()
1644d21ab8bcSmrg{
1645d21ab8bcSmrg    $debug_cmd
1646d21ab8bcSmrg
1647d21ab8bcSmrg    func_append hookable_fns " $1"
1648d21ab8bcSmrg}
1649d21ab8bcSmrg
1650d21ab8bcSmrg
1651d21ab8bcSmrg# func_add_hook FUNC_NAME HOOK_FUNC
1652d21ab8bcSmrg# ---------------------------------
1653d21ab8bcSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
1654d21ab8bcSmrg# first have been declared "hookable" by a call to 'func_hookable'.
1655d21ab8bcSmrgfunc_add_hook ()
1656d21ab8bcSmrg{
1657d21ab8bcSmrg    $debug_cmd
1658d21ab8bcSmrg
1659d21ab8bcSmrg    case " $hookable_fns " in
1660d21ab8bcSmrg      *" $1 "*) ;;
1661d21ab8bcSmrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
1662d21ab8bcSmrg    esac
1663d21ab8bcSmrg
1664d21ab8bcSmrg    eval func_append ${1}_hooks '" $2"'
1665d21ab8bcSmrg}
1666d21ab8bcSmrg
1667d21ab8bcSmrg
1668d21ab8bcSmrg# func_remove_hook FUNC_NAME HOOK_FUNC
1669d21ab8bcSmrg# ------------------------------------
1670d21ab8bcSmrg# Remove HOOK_FUNC from the list of hook functions to be called by
1671d21ab8bcSmrg# FUNC_NAME.
1672d21ab8bcSmrgfunc_remove_hook ()
1673d21ab8bcSmrg{
1674d21ab8bcSmrg    $debug_cmd
1675d21ab8bcSmrg
1676d21ab8bcSmrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1677d21ab8bcSmrg}
1678d21ab8bcSmrg
1679d21ab8bcSmrg
1680d21ab8bcSmrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B
1681d21ab8bcSmrg# ---------------------------------------------
1682d21ab8bcSmrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to
1683d21ab8bcSmrg# *_result variable of FUNC_NAME_B.
1684d21ab8bcSmrgfunc_propagate_result ()
1685d21ab8bcSmrg{
1686d21ab8bcSmrg    $debug_cmd
1687d21ab8bcSmrg
1688d21ab8bcSmrg    func_propagate_result_result=:
1689d21ab8bcSmrg    if eval "test \"\${${1}_result+set}\" = set"
1690d21ab8bcSmrg    then
1691d21ab8bcSmrg      eval "${2}_result=\$${1}_result"
1692d21ab8bcSmrg    else
1693d21ab8bcSmrg      func_propagate_result_result=false
1694d21ab8bcSmrg    fi
1695d21ab8bcSmrg}
1696d21ab8bcSmrg
1697d21ab8bcSmrg
1698d21ab8bcSmrg# func_run_hooks FUNC_NAME [ARG]...
1699d21ab8bcSmrg# ---------------------------------
1700d21ab8bcSmrg# Run all hook functions registered to FUNC_NAME.
1701d21ab8bcSmrg# It's assumed that the list of hook functions contains nothing more
1702d21ab8bcSmrg# than a whitespace-delimited list of legal shell function names, and
1703d21ab8bcSmrg# no effort is wasted trying to catch shell meta-characters or preserve
1704d21ab8bcSmrg# whitespace.
1705d21ab8bcSmrgfunc_run_hooks ()
1706d21ab8bcSmrg{
1707d21ab8bcSmrg    $debug_cmd
1708d21ab8bcSmrg
1709d21ab8bcSmrg    case " $hookable_fns " in
1710d21ab8bcSmrg      *" $1 "*) ;;
1711d21ab8bcSmrg      *) func_fatal_error "'$1' does not support hook functions." ;;
1712d21ab8bcSmrg    esac
1713d21ab8bcSmrg
1714d21ab8bcSmrg    eval _G_hook_fns=\$$1_hooks; shift
1715d21ab8bcSmrg
1716d21ab8bcSmrg    for _G_hook in $_G_hook_fns; do
1717d21ab8bcSmrg      func_unset "${_G_hook}_result"
1718d21ab8bcSmrg      eval $_G_hook '${1+"$@"}'
1719d21ab8bcSmrg      func_propagate_result $_G_hook func_run_hooks
1720d21ab8bcSmrg      if $func_propagate_result_result; then
1721d21ab8bcSmrg        eval set dummy "$func_run_hooks_result"; shift
1722d21ab8bcSmrg      fi
1723d21ab8bcSmrg    done
1724d21ab8bcSmrg}
1725d21ab8bcSmrg
1726d21ab8bcSmrg
1727d21ab8bcSmrg
1728d21ab8bcSmrg## --------------- ##
1729d21ab8bcSmrg## Option parsing. ##
1730d21ab8bcSmrg## --------------- ##
1731d21ab8bcSmrg
1732d21ab8bcSmrg# In order to add your own option parsing hooks, you must accept the
1733d21ab8bcSmrg# full positional parameter list from your hook function.  You may remove
1734d21ab8bcSmrg# or edit any options that you action, and then pass back the remaining
1735d21ab8bcSmrg# unprocessed options in '<hooked_function_name>_result', escaped
1736d21ab8bcSmrg# suitably for 'eval'.
1737d21ab8bcSmrg#
1738d21ab8bcSmrg# The '<hooked_function_name>_result' variable is automatically unset
1739d21ab8bcSmrg# before your hook gets called; for best performance, only set the
1740d21ab8bcSmrg# *_result variable when necessary (i.e. don't call the 'func_quote'
1741d21ab8bcSmrg# function unnecessarily because it can be an expensive operation on some
1742d21ab8bcSmrg# machines).
1743d21ab8bcSmrg#
1744d21ab8bcSmrg# Like this:
1745d21ab8bcSmrg#
1746d21ab8bcSmrg#    my_options_prep ()
1747d21ab8bcSmrg#    {
1748d21ab8bcSmrg#        $debug_cmd
1749d21ab8bcSmrg#
1750d21ab8bcSmrg#        # Extend the existing usage message.
1751d21ab8bcSmrg#        usage_message=$usage_message'
1752d21ab8bcSmrg#      -s, --silent       don'\''t print informational messages
1753d21ab8bcSmrg#    '
1754d21ab8bcSmrg#        # No change in '$@' (ignored completely by this hook).  Leave
1755d21ab8bcSmrg#        # my_options_prep_result variable intact.
1756d21ab8bcSmrg#    }
1757d21ab8bcSmrg#    func_add_hook func_options_prep my_options_prep
1758d21ab8bcSmrg#
1759d21ab8bcSmrg#
1760d21ab8bcSmrg#    my_silent_option ()
1761d21ab8bcSmrg#    {
1762d21ab8bcSmrg#        $debug_cmd
1763d21ab8bcSmrg#
1764d21ab8bcSmrg#        args_changed=false
1765d21ab8bcSmrg#
1766d21ab8bcSmrg#        # Note that, for efficiency, we parse as many options as we can
1767d21ab8bcSmrg#        # recognise in a loop before passing the remainder back to the
1768d21ab8bcSmrg#        # caller on the first unrecognised argument we encounter.
1769d21ab8bcSmrg#        while test $# -gt 0; do
1770d21ab8bcSmrg#          opt=$1; shift
1771d21ab8bcSmrg#          case $opt in
1772d21ab8bcSmrg#            --silent|-s) opt_silent=:
1773d21ab8bcSmrg#                         args_changed=:
1774d21ab8bcSmrg#                         ;;
1775d21ab8bcSmrg#            # Separate non-argument short options:
1776d21ab8bcSmrg#            -s*)         func_split_short_opt "$_G_opt"
1777d21ab8bcSmrg#                         set dummy "$func_split_short_opt_name" \
1778d21ab8bcSmrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
1779d21ab8bcSmrg#                         shift
1780d21ab8bcSmrg#                         args_changed=:
1781d21ab8bcSmrg#                         ;;
1782d21ab8bcSmrg#            *)           # Make sure the first unrecognised option "$_G_opt"
1783d21ab8bcSmrg#                         # is added back to "$@" in case we need it later,
1784d21ab8bcSmrg#                         # if $args_changed was set to 'true'.
1785d21ab8bcSmrg#                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1786d21ab8bcSmrg#          esac
1787d21ab8bcSmrg#        done
1788d21ab8bcSmrg#
1789d21ab8bcSmrg#        # Only call 'func_quote' here if we processed at least one argument.
1790d21ab8bcSmrg#        if $args_changed; then
1791d21ab8bcSmrg#          func_quote eval ${1+"$@"}
1792d21ab8bcSmrg#          my_silent_option_result=$func_quote_result
1793d21ab8bcSmrg#        fi
1794d21ab8bcSmrg#    }
1795d21ab8bcSmrg#    func_add_hook func_parse_options my_silent_option
1796d21ab8bcSmrg#
1797d21ab8bcSmrg#
1798d21ab8bcSmrg#    my_option_validation ()
1799d21ab8bcSmrg#    {
1800d21ab8bcSmrg#        $debug_cmd
1801d21ab8bcSmrg#
1802d21ab8bcSmrg#        $opt_silent && $opt_verbose && func_fatal_help "\
1803d21ab8bcSmrg#    '--silent' and '--verbose' options are mutually exclusive."
1804d21ab8bcSmrg#    }
1805d21ab8bcSmrg#    func_add_hook func_validate_options my_option_validation
1806d21ab8bcSmrg#
1807d21ab8bcSmrg# You'll also need to manually amend $usage_message to reflect the extra
1808d21ab8bcSmrg# options you parse.  It's preferable to append if you can, so that
1809d21ab8bcSmrg# multiple option parsing hooks can be added safely.
1810d21ab8bcSmrg
1811d21ab8bcSmrg
1812d21ab8bcSmrg# func_options_finish [ARG]...
1813d21ab8bcSmrg# ----------------------------
1814d21ab8bcSmrg# Finishing the option parse loop (call 'func_options' hooks ATM).
1815d21ab8bcSmrgfunc_options_finish ()
1816d21ab8bcSmrg{
1817d21ab8bcSmrg    $debug_cmd
1818d21ab8bcSmrg
1819d21ab8bcSmrg    func_run_hooks func_options ${1+"$@"}
1820d21ab8bcSmrg    func_propagate_result func_run_hooks func_options_finish
1821d21ab8bcSmrg}
1822d21ab8bcSmrg
1823d21ab8bcSmrg
1824d21ab8bcSmrg# func_options [ARG]...
1825d21ab8bcSmrg# ---------------------
1826d21ab8bcSmrg# All the functions called inside func_options are hookable. See the
1827d21ab8bcSmrg# individual implementations for details.
1828d21ab8bcSmrgfunc_hookable func_options
1829d21ab8bcSmrgfunc_options ()
1830d21ab8bcSmrg{
1831d21ab8bcSmrg    $debug_cmd
1832d21ab8bcSmrg
1833d21ab8bcSmrg    _G_options_quoted=false
1834d21ab8bcSmrg
1835d21ab8bcSmrg    for my_func in options_prep parse_options validate_options options_finish
1836d21ab8bcSmrg    do
1837d21ab8bcSmrg      func_unset func_${my_func}_result
1838d21ab8bcSmrg      func_unset func_run_hooks_result
1839d21ab8bcSmrg      eval func_$my_func '${1+"$@"}'
1840d21ab8bcSmrg      func_propagate_result func_$my_func func_options
1841d21ab8bcSmrg      if $func_propagate_result_result; then
1842d21ab8bcSmrg        eval set dummy "$func_options_result"; shift
1843d21ab8bcSmrg        _G_options_quoted=:
1844d21ab8bcSmrg      fi
1845d21ab8bcSmrg    done
1846d21ab8bcSmrg
1847d21ab8bcSmrg    $_G_options_quoted || {
1848d21ab8bcSmrg      # As we (func_options) are top-level options-parser function and
1849d21ab8bcSmrg      # nobody quoted "$@" for us yet, we need to do it explicitly for
1850d21ab8bcSmrg      # caller.
1851d21ab8bcSmrg      func_quote eval ${1+"$@"}
1852d21ab8bcSmrg      func_options_result=$func_quote_result
1853d21ab8bcSmrg    }
1854d21ab8bcSmrg}
1855d21ab8bcSmrg
1856d21ab8bcSmrg
1857d21ab8bcSmrg# func_options_prep [ARG]...
1858d21ab8bcSmrg# --------------------------
1859d21ab8bcSmrg# All initialisations required before starting the option parse loop.
1860d21ab8bcSmrg# Note that when calling hook functions, we pass through the list of
1861d21ab8bcSmrg# positional parameters.  If a hook function modifies that list, and
1862d21ab8bcSmrg# needs to propagate that back to rest of this script, then the complete
1863d21ab8bcSmrg# modified list must be put in 'func_run_hooks_result' before returning.
1864d21ab8bcSmrgfunc_hookable func_options_prep
1865d21ab8bcSmrgfunc_options_prep ()
1866d21ab8bcSmrg{
1867d21ab8bcSmrg    $debug_cmd
1868d21ab8bcSmrg
1869d21ab8bcSmrg    # Option defaults:
1870d21ab8bcSmrg    opt_verbose=false
1871d21ab8bcSmrg    opt_warning_types=
1872d21ab8bcSmrg
1873d21ab8bcSmrg    func_run_hooks func_options_prep ${1+"$@"}
1874d21ab8bcSmrg    func_propagate_result func_run_hooks func_options_prep
1875d21ab8bcSmrg}
1876d21ab8bcSmrg
1877d21ab8bcSmrg
1878d21ab8bcSmrg# func_parse_options [ARG]...
1879d21ab8bcSmrg# ---------------------------
1880d21ab8bcSmrg# The main option parsing loop.
1881d21ab8bcSmrgfunc_hookable func_parse_options
1882d21ab8bcSmrgfunc_parse_options ()
1883d21ab8bcSmrg{
1884d21ab8bcSmrg    $debug_cmd
1885d21ab8bcSmrg
1886d21ab8bcSmrg    _G_parse_options_requote=false
1887d21ab8bcSmrg    # this just eases exit handling
1888d21ab8bcSmrg    while test $# -gt 0; do
1889d21ab8bcSmrg      # Defer to hook functions for initial option parsing, so they
1890d21ab8bcSmrg      # get priority in the event of reusing an option name.
1891d21ab8bcSmrg      func_run_hooks func_parse_options ${1+"$@"}
1892d21ab8bcSmrg      func_propagate_result func_run_hooks func_parse_options
1893d21ab8bcSmrg      if $func_propagate_result_result; then
1894d21ab8bcSmrg        eval set dummy "$func_parse_options_result"; shift
1895d21ab8bcSmrg        # Even though we may have changed "$@", we passed the "$@" array
1896d21ab8bcSmrg        # down into the hook and it quoted it for us (because we are in
1897d21ab8bcSmrg        # this if-branch).  No need to quote it again.
1898d21ab8bcSmrg        _G_parse_options_requote=false
1899d21ab8bcSmrg      fi
1900d21ab8bcSmrg
1901d21ab8bcSmrg      # Break out of the loop if we already parsed every option.
1902d21ab8bcSmrg      test $# -gt 0 || break
1903d21ab8bcSmrg
1904d21ab8bcSmrg      # We expect that one of the options parsed in this function matches
1905d21ab8bcSmrg      # and thus we remove _G_opt from "$@" and need to re-quote.
1906d21ab8bcSmrg      _G_match_parse_options=:
1907d21ab8bcSmrg      _G_opt=$1
1908d21ab8bcSmrg      shift
1909d21ab8bcSmrg      case $_G_opt in
1910d21ab8bcSmrg        --debug|-x)   debug_cmd='set -x'
1911d21ab8bcSmrg                      func_echo "enabling shell trace mode" >&2
1912d21ab8bcSmrg                      $debug_cmd
1913d21ab8bcSmrg                      ;;
1914d21ab8bcSmrg
1915d21ab8bcSmrg        --no-warnings|--no-warning|--no-warn)
1916d21ab8bcSmrg                      set dummy --warnings none ${1+"$@"}
1917d21ab8bcSmrg                      shift
1918d21ab8bcSmrg		      ;;
19191f0ac6a5Smrg
1920d21ab8bcSmrg        --warnings|--warning|-W)
1921d21ab8bcSmrg                      if test $# = 0 && func_missing_arg $_G_opt; then
1922d21ab8bcSmrg                        _G_parse_options_requote=:
1923d21ab8bcSmrg                        break
1924d21ab8bcSmrg                      fi
1925d21ab8bcSmrg                      case " $warning_categories $1" in
1926d21ab8bcSmrg                        *" $1 "*)
1927d21ab8bcSmrg                          # trailing space prevents matching last $1 above
1928d21ab8bcSmrg                          func_append_uniq opt_warning_types " $1"
1929d21ab8bcSmrg                          ;;
1930d21ab8bcSmrg                        *all)
1931d21ab8bcSmrg                          opt_warning_types=$warning_categories
1932d21ab8bcSmrg                          ;;
1933d21ab8bcSmrg                        *none)
1934d21ab8bcSmrg                          opt_warning_types=none
1935d21ab8bcSmrg                          warning_func=:
1936d21ab8bcSmrg                          ;;
1937d21ab8bcSmrg                        *error)
1938d21ab8bcSmrg                          opt_warning_types=$warning_categories
1939d21ab8bcSmrg                          warning_func=func_fatal_error
1940d21ab8bcSmrg                          ;;
1941d21ab8bcSmrg                        *)
1942d21ab8bcSmrg                          func_fatal_error \
1943d21ab8bcSmrg                             "unsupported warning category: '$1'"
1944d21ab8bcSmrg                          ;;
1945d21ab8bcSmrg                      esac
1946d21ab8bcSmrg                      shift
1947d21ab8bcSmrg                      ;;
1948d21ab8bcSmrg
1949d21ab8bcSmrg        --verbose|-v) opt_verbose=: ;;
1950d21ab8bcSmrg        --version)    func_version ;;
1951d21ab8bcSmrg        -\?|-h)       func_usage ;;
1952d21ab8bcSmrg        --help)       func_help ;;
1953d21ab8bcSmrg
1954d21ab8bcSmrg	# Separate optargs to long options (plugins may need this):
1955d21ab8bcSmrg	--*=*)        func_split_equals "$_G_opt"
1956d21ab8bcSmrg	              set dummy "$func_split_equals_lhs" \
1957d21ab8bcSmrg                          "$func_split_equals_rhs" ${1+"$@"}
1958d21ab8bcSmrg                      shift
1959d21ab8bcSmrg                      ;;
1960d21ab8bcSmrg
1961d21ab8bcSmrg       # Separate optargs to short options:
1962d21ab8bcSmrg        -W*)
1963d21ab8bcSmrg                      func_split_short_opt "$_G_opt"
1964d21ab8bcSmrg                      set dummy "$func_split_short_opt_name" \
1965d21ab8bcSmrg                          "$func_split_short_opt_arg" ${1+"$@"}
1966d21ab8bcSmrg                      shift
1967d21ab8bcSmrg                      ;;
1968d21ab8bcSmrg
1969d21ab8bcSmrg        # Separate non-argument short options:
1970d21ab8bcSmrg        -\?*|-h*|-v*|-x*)
1971d21ab8bcSmrg                      func_split_short_opt "$_G_opt"
1972d21ab8bcSmrg                      set dummy "$func_split_short_opt_name" \
1973d21ab8bcSmrg                          "-$func_split_short_opt_arg" ${1+"$@"}
1974d21ab8bcSmrg                      shift
1975d21ab8bcSmrg                      ;;
1976d21ab8bcSmrg
1977d21ab8bcSmrg        --)           _G_parse_options_requote=: ; break ;;
1978d21ab8bcSmrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
1979d21ab8bcSmrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift
1980d21ab8bcSmrg                      _G_match_parse_options=false
1981d21ab8bcSmrg                      break
1982d21ab8bcSmrg                      ;;
1983d21ab8bcSmrg      esac
19849c9ff80cSmrg
1985d21ab8bcSmrg      if $_G_match_parse_options; then
1986d21ab8bcSmrg        _G_parse_options_requote=:
19879c9ff80cSmrg      fi
1988d21ab8bcSmrg    done
1989d21ab8bcSmrg
1990d21ab8bcSmrg    if $_G_parse_options_requote; then
1991d21ab8bcSmrg      # save modified positional parameters for caller
1992d21ab8bcSmrg      func_quote eval ${1+"$@"}
1993d21ab8bcSmrg      func_parse_options_result=$func_quote_result
19941f0ac6a5Smrg    fi
19951f0ac6a5Smrg}
19961f0ac6a5Smrg
19979c9ff80cSmrg
1998d21ab8bcSmrg# func_validate_options [ARG]...
1999d21ab8bcSmrg# ------------------------------
2000d21ab8bcSmrg# Perform any sanity checks on option settings and/or unconsumed
2001d21ab8bcSmrg# arguments.
2002d21ab8bcSmrgfunc_hookable func_validate_options
2003d21ab8bcSmrgfunc_validate_options ()
20041f0ac6a5Smrg{
2005d21ab8bcSmrg    $debug_cmd
20069c9ff80cSmrg
2007d21ab8bcSmrg    # Display all warnings if -W was not given.
2008d21ab8bcSmrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
20099c9ff80cSmrg
2010d21ab8bcSmrg    func_run_hooks func_validate_options ${1+"$@"}
2011d21ab8bcSmrg    func_propagate_result func_run_hooks func_validate_options
20121f0ac6a5Smrg
2013d21ab8bcSmrg    # Bail if the options were screwed!
2014d21ab8bcSmrg    $exit_cmd $EXIT_FAILURE
20156fae4e5dSmrg}
20169c9ff80cSmrg
20179c9ff80cSmrg
20186fae4e5dSmrg
2019d21ab8bcSmrg## ----------------- ##
2020d21ab8bcSmrg## Helper functions. ##
2021d21ab8bcSmrg## ----------------- ##
20229c9ff80cSmrg
2023d21ab8bcSmrg# This section contains the helper functions used by the rest of the
2024d21ab8bcSmrg# hookable option parser framework in ascii-betical order.
2025d21ab8bcSmrg
2026d21ab8bcSmrg
2027d21ab8bcSmrg# func_fatal_help ARG...
2028d21ab8bcSmrg# ----------------------
2029d21ab8bcSmrg# Echo program name prefixed message to standard error, followed by
2030d21ab8bcSmrg# a help hint, and exit.
2031d21ab8bcSmrgfunc_fatal_help ()
20329c9ff80cSmrg{
2033d21ab8bcSmrg    $debug_cmd
20346fae4e5dSmrg
2035d21ab8bcSmrg    eval \$ECHO \""Usage: $usage"\"
2036d21ab8bcSmrg    eval \$ECHO \""$fatal_help"\"
2037d21ab8bcSmrg    func_error ${1+"$@"}
2038d21ab8bcSmrg    exit $EXIT_FAILURE
20399c9ff80cSmrg}
20409c9ff80cSmrg
2041d21ab8bcSmrg
2042d21ab8bcSmrg# func_help
2043d21ab8bcSmrg# ---------
2044d21ab8bcSmrg# Echo long help message to standard output and exit.
20459c9ff80cSmrgfunc_help ()
20469c9ff80cSmrg{
2047d21ab8bcSmrg    $debug_cmd
2048d21ab8bcSmrg
2049d21ab8bcSmrg    func_usage_message
2050d21ab8bcSmrg    $ECHO "$long_help_message"
2051d21ab8bcSmrg    exit 0
20529c9ff80cSmrg}
20539c9ff80cSmrg
2054d21ab8bcSmrg
2055d21ab8bcSmrg# func_missing_arg ARGNAME
2056d21ab8bcSmrg# ------------------------
20579c9ff80cSmrg# Echo program name prefixed message to standard error and set global
20589c9ff80cSmrg# exit_cmd.
20599c9ff80cSmrgfunc_missing_arg ()
20609c9ff80cSmrg{
2061d21ab8bcSmrg    $debug_cmd
20626fae4e5dSmrg
2063d21ab8bcSmrg    func_error "Missing argument for '$1'."
20649c9ff80cSmrg    exit_cmd=exit
20651f0ac6a5Smrg}
20661f0ac6a5Smrg
20671f0ac6a5Smrg
2068d21ab8bcSmrg# func_split_equals STRING
2069d21ab8bcSmrg# ------------------------
2070d21ab8bcSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables
2071d21ab8bcSmrg# after splitting STRING at the '=' sign.
2072d21ab8bcSmrgtest -z "$_G_HAVE_XSI_OPS" \
2073d21ab8bcSmrg    && (eval 'x=a/b/c;
2074d21ab8bcSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
2075d21ab8bcSmrg    && _G_HAVE_XSI_OPS=yes
2076d21ab8bcSmrg
2077d21ab8bcSmrgif test yes = "$_G_HAVE_XSI_OPS"
2078d21ab8bcSmrgthen
2079d21ab8bcSmrg  # This is an XSI compatible shell, allowing a faster implementation...
2080d21ab8bcSmrg  eval 'func_split_equals ()
2081d21ab8bcSmrg  {
2082d21ab8bcSmrg      $debug_cmd
2083d21ab8bcSmrg
2084d21ab8bcSmrg      func_split_equals_lhs=${1%%=*}
2085d21ab8bcSmrg      func_split_equals_rhs=${1#*=}
2086d21ab8bcSmrg      if test "x$func_split_equals_lhs" = "x$1"; then
2087d21ab8bcSmrg        func_split_equals_rhs=
2088d21ab8bcSmrg      fi
2089d21ab8bcSmrg  }'
2090d21ab8bcSmrgelse
2091d21ab8bcSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
2092d21ab8bcSmrg  func_split_equals ()
2093d21ab8bcSmrg  {
2094d21ab8bcSmrg      $debug_cmd
2095d21ab8bcSmrg
2096d21ab8bcSmrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
2097d21ab8bcSmrg      func_split_equals_rhs=
2098d21ab8bcSmrg      test "x$func_split_equals_lhs=" = "x$1" \
2099d21ab8bcSmrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
2100d21ab8bcSmrg  }
2101d21ab8bcSmrgfi #func_split_equals
2102d21ab8bcSmrg
2103d21ab8bcSmrg
2104d21ab8bcSmrg# func_split_short_opt SHORTOPT
2105d21ab8bcSmrg# -----------------------------
21066fae4e5dSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
21076fae4e5dSmrg# variables after splitting SHORTOPT after the 2nd character.
2108d21ab8bcSmrgif test yes = "$_G_HAVE_XSI_OPS"
2109d21ab8bcSmrgthen
2110d21ab8bcSmrg  # This is an XSI compatible shell, allowing a faster implementation...
2111d21ab8bcSmrg  eval 'func_split_short_opt ()
2112d21ab8bcSmrg  {
2113d21ab8bcSmrg      $debug_cmd
2114d21ab8bcSmrg
2115d21ab8bcSmrg      func_split_short_opt_arg=${1#??}
2116d21ab8bcSmrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
2117d21ab8bcSmrg  }'
2118d21ab8bcSmrgelse
2119d21ab8bcSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
2120d21ab8bcSmrg  func_split_short_opt ()
2121d21ab8bcSmrg  {
2122d21ab8bcSmrg      $debug_cmd
2123d21ab8bcSmrg
2124d21ab8bcSmrg      func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'`
2125d21ab8bcSmrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
2126d21ab8bcSmrg  }
2127d21ab8bcSmrgfi #func_split_short_opt
2128d21ab8bcSmrg
2129d21ab8bcSmrg
2130d21ab8bcSmrg# func_usage
2131d21ab8bcSmrg# ----------
2132d21ab8bcSmrg# Echo short help message to standard output and exit.
2133d21ab8bcSmrgfunc_usage ()
21346fae4e5dSmrg{
2135d21ab8bcSmrg    $debug_cmd
21361f0ac6a5Smrg
2137d21ab8bcSmrg    func_usage_message
2138d21ab8bcSmrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
2139d21ab8bcSmrg    exit 0
2140d21ab8bcSmrg}
21416fae4e5dSmrg
21426fae4e5dSmrg
2143d21ab8bcSmrg# func_usage_message
2144d21ab8bcSmrg# ------------------
2145d21ab8bcSmrg# Echo short help message to standard output.
2146d21ab8bcSmrgfunc_usage_message ()
21476fae4e5dSmrg{
2148d21ab8bcSmrg    $debug_cmd
2149d21ab8bcSmrg
2150d21ab8bcSmrg    eval \$ECHO \""Usage: $usage"\"
2151d21ab8bcSmrg    echo
2152d21ab8bcSmrg    $SED -n 's|^# ||
2153d21ab8bcSmrg        /^Written by/{
2154d21ab8bcSmrg          x;p;x
2155d21ab8bcSmrg        }
2156d21ab8bcSmrg	h
2157d21ab8bcSmrg	/^Written by/q' < "$progpath"
2158d21ab8bcSmrg    echo
2159d21ab8bcSmrg    eval \$ECHO \""$usage_message"\"
2160d21ab8bcSmrg}
21616fae4e5dSmrg
21626fae4e5dSmrg
2163d21ab8bcSmrg# func_version
2164d21ab8bcSmrg# ------------
2165d21ab8bcSmrg# Echo version message to standard output and exit.
2166d21ab8bcSmrg# The version message is extracted from the calling file's header
2167d21ab8bcSmrg# comments, with leading '# ' stripped:
2168d21ab8bcSmrg#   1. First display the progname and version
2169d21ab8bcSmrg#   2. Followed by the header comment line matching  /^# Written by /
2170d21ab8bcSmrg#   3. Then a blank line followed by the first following line matching
2171d21ab8bcSmrg#      /^# Copyright /
2172d21ab8bcSmrg#   4. Immediately followed by any lines between the previous matches,
2173d21ab8bcSmrg#      except lines preceding the intervening completely blank line.
2174d21ab8bcSmrg# For example, see the header comments of this file.
2175d21ab8bcSmrgfunc_version ()
2176d21ab8bcSmrg{
2177d21ab8bcSmrg    $debug_cmd
21789c9ff80cSmrg
2179d21ab8bcSmrg    printf '%s\n' "$progname $scriptversion"
2180d21ab8bcSmrg    $SED -n '
2181d21ab8bcSmrg        /^# Written by /!b
2182d21ab8bcSmrg        s|^# ||; p; n
21839c9ff80cSmrg
2184d21ab8bcSmrg        :fwd2blnk
2185d21ab8bcSmrg        /./ {
2186d21ab8bcSmrg          n
2187d21ab8bcSmrg          b fwd2blnk
2188d21ab8bcSmrg        }
2189d21ab8bcSmrg        p; n
2190d21ab8bcSmrg
2191d21ab8bcSmrg        :holdwrnt
2192d21ab8bcSmrg        s|^# ||
2193d21ab8bcSmrg        s|^# *$||
2194d21ab8bcSmrg        /^Copyright /!{
2195d21ab8bcSmrg          /./H
2196d21ab8bcSmrg          n
2197d21ab8bcSmrg          b holdwrnt
2198d21ab8bcSmrg        }
21999c9ff80cSmrg
2200d21ab8bcSmrg        s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
2201d21ab8bcSmrg        G
2202d21ab8bcSmrg        s|\(\n\)\n*|\1|g
2203d21ab8bcSmrg        p; q' < "$progpath"
22041f0ac6a5Smrg
2205d21ab8bcSmrg    exit $?
2206d21ab8bcSmrg}
22071f0ac6a5Smrg
22081f0ac6a5Smrg
2209d21ab8bcSmrg# Local variables:
2210d21ab8bcSmrg# mode: shell-script
2211d21ab8bcSmrg# sh-indentation: 2
2212d21ab8bcSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
2213d21ab8bcSmrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"
2214d21ab8bcSmrg# time-stamp-time-zone: "UTC"
2215d21ab8bcSmrg# End:
22161f0ac6a5Smrg
2217d21ab8bcSmrg# Set a version string.
22186ee7d557Smrgscriptversion='(GNU libtool) 2.5.4'
22196ee7d557Smrg
22206ee7d557Smrg# func_version
22216ee7d557Smrg# ------------
22226ee7d557Smrg# Echo version message to standard output and exit.
22236ee7d557Smrgfunc_version ()
22246ee7d557Smrg{
22256ee7d557Smrg    $debug_cmd
22266ee7d557Smrg
22276ee7d557Smrg	year=`date +%Y`
22286ee7d557Smrg
22296ee7d557Smrg	cat <<EOF
22306ee7d557Smrg$progname $scriptversion
22316ee7d557SmrgCopyright (C) $year Free Software Foundation, Inc.
22326ee7d557SmrgLicense GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>
22336ee7d557SmrgThis is free software: you are free to change and redistribute it.
22346ee7d557SmrgThere is NO WARRANTY, to the extent permitted by law.
22356ee7d557Smrg
22366ee7d557SmrgOriginally written by Gordon Matzigkeit, 1996
22376ee7d557Smrg(See AUTHORS for complete contributor listing)
22386ee7d557SmrgEOF
22396ee7d557Smrg
22406ee7d557Smrg    exit $?
22416ee7d557Smrg}
22429c9ff80cSmrg
22436fae4e5dSmrg
2244d21ab8bcSmrg# func_echo ARG...
2245d21ab8bcSmrg# ----------------
2246d21ab8bcSmrg# Libtool also displays the current mode in messages, so override
2247d21ab8bcSmrg# funclib.sh func_echo with this custom definition.
2248d21ab8bcSmrgfunc_echo ()
22496fae4e5dSmrg{
2250d21ab8bcSmrg    $debug_cmd
22516fae4e5dSmrg
2252d21ab8bcSmrg    _G_message=$*
22536fae4e5dSmrg
2254d21ab8bcSmrg    func_echo_IFS=$IFS
2255d21ab8bcSmrg    IFS=$nl
2256d21ab8bcSmrg    for _G_line in $_G_message; do
2257d21ab8bcSmrg      IFS=$func_echo_IFS
2258d21ab8bcSmrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
2259d21ab8bcSmrg    done
2260d21ab8bcSmrg    IFS=$func_echo_IFS
2261d21ab8bcSmrg}
22626fae4e5dSmrg
22636fae4e5dSmrg
2264d21ab8bcSmrg## ---------------- ##
2265d21ab8bcSmrg## Options parsing. ##
2266d21ab8bcSmrg## ---------------- ##
2267d21ab8bcSmrg
2268d21ab8bcSmrg# Hook in the functions to make sure our own options are parsed during
2269d21ab8bcSmrg# the option parsing loop.
2270d21ab8bcSmrg
2271d21ab8bcSmrgusage='$progpath [OPTION]... [MODE-ARG]...'
2272d21ab8bcSmrg
2273d21ab8bcSmrg# Short help message in response to '-h'.
2274d21ab8bcSmrgusage_message="Options:
22756ee7d557Smrg       --config                 show all configuration variables
22766ee7d557Smrg       --debug                  enable verbose shell tracing
22776ee7d557Smrg   -n, --dry-run                display commands without modifying any files
22786ee7d557Smrg       --features               display basic configuration information
22796ee7d557Smrg       --finish                 use operation '--mode=finish'
22806ee7d557Smrg       --mode=MODE              use operation mode MODE
22816ee7d557Smrg       --no-finish              don't update shared library cache
22826ee7d557Smrg       --no-quiet, --no-silent  print default informational messages
22836ee7d557Smrg       --no-warnings            equivalent to '-Wnone'
22846ee7d557Smrg       --preserve-dup-deps      don't remove duplicate dependency libraries
22856ee7d557Smrg       --quiet, --silent        don't print informational messages
22866ee7d557Smrg       --reorder-cache=DIRS     reorder shared library cache for preferred DIRS
22876ee7d557Smrg       --tag=TAG                use configuration variables from tag TAG
22886ee7d557Smrg   -v, --verbose                print more informational messages than default
22896ee7d557Smrg       --version                print version information
22906ee7d557Smrg   -W, --warnings=CATEGORY      report the warnings falling in CATEGORY [all]
22916ee7d557Smrg   -h, --help, --help-all       print short, long, or detailed help message
2292d21ab8bcSmrg"
22936fae4e5dSmrg
2294d21ab8bcSmrg# Additional text appended to 'usage_message' in response to '--help'.
2295d21ab8bcSmrgfunc_help ()
22966fae4e5dSmrg{
2297d21ab8bcSmrg    $debug_cmd
2298d21ab8bcSmrg
2299d21ab8bcSmrg    func_usage_message
2300d21ab8bcSmrg    $ECHO "$long_help_message
2301d21ab8bcSmrg
2302d21ab8bcSmrgMODE must be one of the following:
2303d21ab8bcSmrg
2304d21ab8bcSmrg       clean           remove files from the build directory
2305d21ab8bcSmrg       compile         compile a source file into a libtool object
2306d21ab8bcSmrg       execute         automatically set library path, then run a program
2307d21ab8bcSmrg       finish          complete the installation of libtool libraries
2308d21ab8bcSmrg       install         install libraries or executables
2309d21ab8bcSmrg       link            create a library or an executable
2310d21ab8bcSmrg       uninstall       remove libraries from an installed directory
2311d21ab8bcSmrg
2312d21ab8bcSmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
2313d21ab8bcSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2314d21ab8bcSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
2315d21ab8bcSmrg
2316d21ab8bcSmrgWhen reporting a bug, please describe a test case to reproduce it and
2317d21ab8bcSmrginclude the following information:
2318d21ab8bcSmrg
2319d21ab8bcSmrg       host-triplet:   $host
2320d21ab8bcSmrg       shell:          $SHELL
2321d21ab8bcSmrg       compiler:       $LTCC
2322d21ab8bcSmrg       compiler flags: $LTCFLAGS
2323d21ab8bcSmrg       linker:         $LD (gnu? $with_gnu_ld)
23246ee7d557Smrg       version:        $progname $scriptversion
2325d21ab8bcSmrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2326d21ab8bcSmrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2327d21ab8bcSmrg
2328d21ab8bcSmrgReport bugs to <bug-libtool@gnu.org>.
23296ee7d557SmrgGNU libtool home page: <https://www.gnu.org/software/libtool/>.
23306ee7d557SmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>."
2331d21ab8bcSmrg    exit 0
2332d21ab8bcSmrg}
2333d21ab8bcSmrg
2334d21ab8bcSmrg
2335d21ab8bcSmrg# func_lo2o OBJECT-NAME
2336d21ab8bcSmrg# ---------------------
2337d21ab8bcSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2338d21ab8bcSmrg# object suffix.
2339d21ab8bcSmrg
2340d21ab8bcSmrglo2o=s/\\.lo\$/.$objext/
2341d21ab8bcSmrgo2lo=s/\\.$objext\$/.lo/
2342d21ab8bcSmrg
2343d21ab8bcSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
2344d21ab8bcSmrg  eval 'func_lo2o ()
2345d21ab8bcSmrg  {
2346d21ab8bcSmrg    case $1 in
2347d21ab8bcSmrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
2348d21ab8bcSmrg      *   ) func_lo2o_result=$1               ;;
2349d21ab8bcSmrg    esac
2350d21ab8bcSmrg  }'
2351d21ab8bcSmrg
2352d21ab8bcSmrg  # func_xform LIBOBJ-OR-SOURCE
2353d21ab8bcSmrg  # ---------------------------
2354d21ab8bcSmrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2355d21ab8bcSmrg  # suffix to a '.lo' libtool-object suffix.
2356d21ab8bcSmrg  eval 'func_xform ()
2357d21ab8bcSmrg  {
2358d21ab8bcSmrg    func_xform_result=${1%.*}.lo
2359d21ab8bcSmrg  }'
2360d21ab8bcSmrgelse
2361d21ab8bcSmrg  # ...otherwise fall back to using sed.
2362d21ab8bcSmrg  func_lo2o ()
2363d21ab8bcSmrg  {
2364d21ab8bcSmrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2365d21ab8bcSmrg  }
2366d21ab8bcSmrg
2367d21ab8bcSmrg  func_xform ()
2368d21ab8bcSmrg  {
2369d21ab8bcSmrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2370d21ab8bcSmrg  }
2371d21ab8bcSmrgfi
23726fae4e5dSmrg
23736fae4e5dSmrg
2374d21ab8bcSmrg# func_fatal_configuration ARG...
2375d21ab8bcSmrg# -------------------------------
23769c9ff80cSmrg# Echo program name prefixed message to standard error, followed by
23779c9ff80cSmrg# a configuration failure hint, and exit.
23789c9ff80cSmrgfunc_fatal_configuration ()
23799c9ff80cSmrg{
2380d21ab8bcSmrg    func_fatal_error ${1+"$@"} \
2381d21ab8bcSmrg      "See the $PACKAGE documentation for more information." \
2382d21ab8bcSmrg      "Fatal configuration error."
23839c9ff80cSmrg}
23841f0ac6a5Smrg
2385e5410a46Smrg
23869c9ff80cSmrg# func_config
2387d21ab8bcSmrg# -----------
23889c9ff80cSmrg# Display the configuration for all the tags in this script.
23899c9ff80cSmrgfunc_config ()
23909c9ff80cSmrg{
23919c9ff80cSmrg    re_begincf='^# ### BEGIN LIBTOOL'
23929c9ff80cSmrg    re_endcf='^# ### END LIBTOOL'
23939c9ff80cSmrg
23949c9ff80cSmrg    # Default configuration.
23959c9ff80cSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
23961f0ac6a5Smrg
23971f0ac6a5Smrg    # Now print the configurations for the tags.
23981f0ac6a5Smrg    for tagname in $taglist; do
23999c9ff80cSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
24001f0ac6a5Smrg    done
24011f0ac6a5Smrg
24029c9ff80cSmrg    exit $?
24039c9ff80cSmrg}
24041f0ac6a5Smrg
2405d21ab8bcSmrg
24069c9ff80cSmrg# func_features
2407d21ab8bcSmrg# -------------
24089c9ff80cSmrg# Display the features supported by this script.
24099c9ff80cSmrgfunc_features ()
24109c9ff80cSmrg{
24116fae4e5dSmrg    echo "host: $host"
2412d21ab8bcSmrg    if test yes = "$build_libtool_libs"; then
24136fae4e5dSmrg      echo "enable shared libraries"
24141f0ac6a5Smrg    else
24156fae4e5dSmrg      echo "disable shared libraries"
24161f0ac6a5Smrg    fi
2417d21ab8bcSmrg    if test yes = "$build_old_libs"; then
24186fae4e5dSmrg      echo "enable static libraries"
24191f0ac6a5Smrg    else
24206fae4e5dSmrg      echo "disable static libraries"
24211f0ac6a5Smrg    fi
24229c9ff80cSmrg
24231f0ac6a5Smrg    exit $?
24249c9ff80cSmrg}
24251f0ac6a5Smrg
2426d21ab8bcSmrg
2427d21ab8bcSmrg# func_enable_tag TAGNAME
2428d21ab8bcSmrg# -----------------------
24299c9ff80cSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
24309c9ff80cSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
24319c9ff80cSmrg# variable here.
24329c9ff80cSmrgfunc_enable_tag ()
24339c9ff80cSmrg{
2434d21ab8bcSmrg    # Global variable:
2435d21ab8bcSmrg    tagname=$1
24361f0ac6a5Smrg
2437d21ab8bcSmrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
2438d21ab8bcSmrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
2439d21ab8bcSmrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
24401f0ac6a5Smrg
2441d21ab8bcSmrg    # Validate tagname.
2442d21ab8bcSmrg    case $tagname in
2443d21ab8bcSmrg      *[!-_A-Za-z0-9,/]*)
2444d21ab8bcSmrg        func_fatal_error "invalid tag name: $tagname"
2445d21ab8bcSmrg        ;;
2446d21ab8bcSmrg    esac
24471f0ac6a5Smrg
2448d21ab8bcSmrg    # Don't test for the "default" C tag, as we know it's
2449d21ab8bcSmrg    # there but not specially marked.
2450d21ab8bcSmrg    case $tagname in
2451d21ab8bcSmrg        CC) ;;
24529c9ff80cSmrg    *)
2453d21ab8bcSmrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
2454d21ab8bcSmrg	  taglist="$taglist $tagname"
2455d21ab8bcSmrg
2456d21ab8bcSmrg	  # Evaluate the configuration.  Be careful to quote the path
2457d21ab8bcSmrg	  # and the sed script, to avoid splitting on whitespace, but
2458d21ab8bcSmrg	  # also don't use non-portable quotes within backquotes within
2459d21ab8bcSmrg	  # quotes we have to do it in 2 steps:
2460d21ab8bcSmrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
2461d21ab8bcSmrg	  eval "$extractedcf"
2462d21ab8bcSmrg        else
2463d21ab8bcSmrg	  func_error "ignoring unknown tag $tagname"
2464d21ab8bcSmrg        fi
2465d21ab8bcSmrg        ;;
2466d21ab8bcSmrg    esac
24679c9ff80cSmrg}
24689c9ff80cSmrg
2469d21ab8bcSmrg
24706fae4e5dSmrg# func_check_version_match
2471d21ab8bcSmrg# ------------------------
24726fae4e5dSmrg# Ensure that we are using m4 macros, and libtool script from the same
24736fae4e5dSmrg# release of libtool.
24746fae4e5dSmrgfunc_check_version_match ()
24759c9ff80cSmrg{
2476d21ab8bcSmrg    if test "$package_revision" != "$macro_revision"; then
2477d21ab8bcSmrg      if test "$VERSION" != "$macro_version"; then
2478d21ab8bcSmrg        if test -z "$macro_version"; then
2479d21ab8bcSmrg          cat >&2 <<_LT_EOF
24806fae4e5dSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
24816fae4e5dSmrg$progname: definition of this LT_INIT comes from an older release.
24826fae4e5dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
24836fae4e5dSmrg$progname: and run autoconf again.
24846fae4e5dSmrg_LT_EOF
2485d21ab8bcSmrg        else
2486d21ab8bcSmrg          cat >&2 <<_LT_EOF
24876fae4e5dSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
24886fae4e5dSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
24896fae4e5dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
24906fae4e5dSmrg$progname: and run autoconf again.
24916fae4e5dSmrg_LT_EOF
2492d21ab8bcSmrg        fi
2493d21ab8bcSmrg      else
2494d21ab8bcSmrg        cat >&2 <<_LT_EOF
24956fae4e5dSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
24966fae4e5dSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
24976fae4e5dSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
24986fae4e5dSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
24996fae4e5dSmrg_LT_EOF
2500d21ab8bcSmrg      fi
25011f0ac6a5Smrg
2502d21ab8bcSmrg      exit $EXIT_MISMATCH
2503d21ab8bcSmrg    fi
25046fae4e5dSmrg}
25056fae4e5dSmrg
25066fae4e5dSmrg
2507d21ab8bcSmrg# libtool_options_prep [ARG]...
2508d21ab8bcSmrg# -----------------------------
2509d21ab8bcSmrg# Preparation for options parsed by libtool.
2510d21ab8bcSmrglibtool_options_prep ()
2511d21ab8bcSmrg{
2512d21ab8bcSmrg    $debug_mode
25136fae4e5dSmrg
2514d21ab8bcSmrg    # Option defaults:
2515d21ab8bcSmrg    opt_config=false
2516d21ab8bcSmrg    opt_dlopen=
2517d21ab8bcSmrg    opt_dry_run=false
2518d21ab8bcSmrg    opt_help=false
2519d21ab8bcSmrg    opt_mode=
25206ee7d557Smrg    opt_reorder_cache=false
2521d21ab8bcSmrg    opt_preserve_dup_deps=false
2522d21ab8bcSmrg    opt_quiet=false
25236ee7d557Smrg    opt_finishing=true
25246ee7d557Smrg    opt_warning=
25256fae4e5dSmrg
2526d21ab8bcSmrg    nonopt=
2527d21ab8bcSmrg    preserve_args=
25281f0ac6a5Smrg
2529d21ab8bcSmrg    _G_rc_lt_options_prep=:
25306fae4e5dSmrg
2531d21ab8bcSmrg    # Shorthand for --mode=foo, only valid as the first argument
2532d21ab8bcSmrg    case $1 in
2533d21ab8bcSmrg    clean|clea|cle|cl)
2534d21ab8bcSmrg      shift; set dummy --mode clean ${1+"$@"}; shift
2535d21ab8bcSmrg      ;;
2536d21ab8bcSmrg    compile|compil|compi|comp|com|co|c)
2537d21ab8bcSmrg      shift; set dummy --mode compile ${1+"$@"}; shift
2538d21ab8bcSmrg      ;;
2539d21ab8bcSmrg    execute|execut|execu|exec|exe|ex|e)
2540d21ab8bcSmrg      shift; set dummy --mode execute ${1+"$@"}; shift
2541d21ab8bcSmrg      ;;
2542d21ab8bcSmrg    finish|finis|fini|fin|fi|f)
2543d21ab8bcSmrg      shift; set dummy --mode finish ${1+"$@"}; shift
2544d21ab8bcSmrg      ;;
2545d21ab8bcSmrg    install|instal|insta|inst|ins|in|i)
2546d21ab8bcSmrg      shift; set dummy --mode install ${1+"$@"}; shift
2547d21ab8bcSmrg      ;;
2548d21ab8bcSmrg    link|lin|li|l)
2549d21ab8bcSmrg      shift; set dummy --mode link ${1+"$@"}; shift
2550d21ab8bcSmrg      ;;
2551d21ab8bcSmrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
2552d21ab8bcSmrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
2553d21ab8bcSmrg      ;;
2554d21ab8bcSmrg    *)
2555d21ab8bcSmrg      _G_rc_lt_options_prep=false
2556d21ab8bcSmrg      ;;
25579c9ff80cSmrg    esac
25589c9ff80cSmrg
2559d21ab8bcSmrg    if $_G_rc_lt_options_prep; then
2560d21ab8bcSmrg      # Pass back the list of options.
2561d21ab8bcSmrg      func_quote eval ${1+"$@"}
2562d21ab8bcSmrg      libtool_options_prep_result=$func_quote_result
2563d21ab8bcSmrg    fi
2564d21ab8bcSmrg}
2565d21ab8bcSmrgfunc_add_hook func_options_prep libtool_options_prep
25666fae4e5dSmrg
25676fae4e5dSmrg
2568d21ab8bcSmrg# libtool_parse_options [ARG]...
2569d21ab8bcSmrg# ---------------------------------
2570d21ab8bcSmrg# Provide handling for libtool specific options.
2571d21ab8bcSmrglibtool_parse_options ()
2572d21ab8bcSmrg{
2573d21ab8bcSmrg    $debug_cmd
25749c9ff80cSmrg
2575d21ab8bcSmrg    _G_rc_lt_parse_options=false
25761f0ac6a5Smrg
2577d21ab8bcSmrg    # Perform our own loop to consume as many options as possible in
2578d21ab8bcSmrg    # each iteration.
2579d21ab8bcSmrg    while test $# -gt 0; do
2580d21ab8bcSmrg      _G_match_lt_parse_options=:
2581d21ab8bcSmrg      _G_opt=$1
2582d21ab8bcSmrg      shift
2583d21ab8bcSmrg      case $_G_opt in
2584d21ab8bcSmrg        --dry-run|--dryrun|-n)
2585d21ab8bcSmrg                        opt_dry_run=:
2586d21ab8bcSmrg                        ;;
2587d21ab8bcSmrg
2588d21ab8bcSmrg        --config)       func_config ;;
2589d21ab8bcSmrg
2590d21ab8bcSmrg        --dlopen|-dlopen)
2591d21ab8bcSmrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
2592d21ab8bcSmrg}$1"
2593d21ab8bcSmrg                        shift
2594d21ab8bcSmrg                        ;;
2595d21ab8bcSmrg
2596d21ab8bcSmrg        --preserve-dup-deps)
2597d21ab8bcSmrg                        opt_preserve_dup_deps=: ;;
2598d21ab8bcSmrg
2599d21ab8bcSmrg        --features)     func_features ;;
2600d21ab8bcSmrg
2601d21ab8bcSmrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
2602d21ab8bcSmrg
2603d21ab8bcSmrg        --help)         opt_help=: ;;
2604d21ab8bcSmrg
2605d21ab8bcSmrg        --help-all)     opt_help=': help-all' ;;
2606d21ab8bcSmrg
2607d21ab8bcSmrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
2608d21ab8bcSmrg                        opt_mode=$1
2609d21ab8bcSmrg                        case $1 in
2610d21ab8bcSmrg                          # Valid mode arguments:
2611d21ab8bcSmrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
2612d21ab8bcSmrg
2613d21ab8bcSmrg                          # Catch anything else as an error
26146ee7d557Smrg                          *) func_error "invalid argument '$1' for $_G_opt"
2615d21ab8bcSmrg                             exit_cmd=exit
2616d21ab8bcSmrg                             ;;
2617d21ab8bcSmrg                        esac
2618d21ab8bcSmrg                        shift
2619d21ab8bcSmrg                        ;;
2620d21ab8bcSmrg
26216ee7d557Smrg        --no-finish)
26226ee7d557Smrg                        opt_finishing=false
26236ee7d557Smrg                        func_append preserve_args " $_G_opt"
26246ee7d557Smrg                        ;;
26256ee7d557Smrg
2626d21ab8bcSmrg        --no-silent|--no-quiet)
2627d21ab8bcSmrg                        opt_quiet=false
2628d21ab8bcSmrg                        func_append preserve_args " $_G_opt"
2629d21ab8bcSmrg                        ;;
2630d21ab8bcSmrg
2631d21ab8bcSmrg        --no-warnings|--no-warning|--no-warn)
2632d21ab8bcSmrg                        opt_warning=false
2633d21ab8bcSmrg                        func_append preserve_args " $_G_opt"
2634d21ab8bcSmrg                        ;;
2635d21ab8bcSmrg
2636d21ab8bcSmrg        --no-verbose)
2637d21ab8bcSmrg                        opt_verbose=false
2638d21ab8bcSmrg                        func_append preserve_args " $_G_opt"
2639d21ab8bcSmrg                        ;;
2640d21ab8bcSmrg
26416ee7d557Smrg        --reorder-cache)
26426ee7d557Smrg                        opt_reorder_cache=true
26436ee7d557Smrg                        shared_lib_dirs=$1
26446ee7d557Smrg                        if test -n "$shared_lib_dirs"; then
26456ee7d557Smrg                          case $1 in
26466ee7d557Smrg                            # Must begin with /:
26476ee7d557Smrg                            /*) ;;
26486ee7d557Smrg
26496ee7d557Smrg                            # Catch anything else as an error (relative paths)
26506ee7d557Smrg                            *) func_error "invalid argument '$1' for $_G_opt"
26516ee7d557Smrg                               func_error "absolute paths are required for $_G_opt"
26526ee7d557Smrg                               exit_cmd=exit
26536ee7d557Smrg                               ;;
26546ee7d557Smrg                          esac
26556ee7d557Smrg                        fi
26566ee7d557Smrg                        shift
26576ee7d557Smrg                        ;;
26586ee7d557Smrg
2659d21ab8bcSmrg        --silent|--quiet)
2660d21ab8bcSmrg                        opt_quiet=:
2661d21ab8bcSmrg                        opt_verbose=false
2662d21ab8bcSmrg                        func_append preserve_args " $_G_opt"
2663d21ab8bcSmrg                        ;;
2664d21ab8bcSmrg
2665d21ab8bcSmrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
2666d21ab8bcSmrg                        opt_tag=$1
2667d21ab8bcSmrg                        func_append preserve_args " $_G_opt $1"
2668d21ab8bcSmrg                        func_enable_tag "$1"
2669d21ab8bcSmrg                        shift
2670d21ab8bcSmrg                        ;;
2671d21ab8bcSmrg
2672d21ab8bcSmrg        --verbose|-v)   opt_quiet=false
2673d21ab8bcSmrg                        opt_verbose=:
2674d21ab8bcSmrg                        func_append preserve_args " $_G_opt"
2675d21ab8bcSmrg                        ;;
2676d21ab8bcSmrg
2677d21ab8bcSmrg        # An option not handled by this hook function:
2678d21ab8bcSmrg        *)              set dummy "$_G_opt" ${1+"$@"} ; shift
2679d21ab8bcSmrg                        _G_match_lt_parse_options=false
2680d21ab8bcSmrg                        break
2681d21ab8bcSmrg                        ;;
2682d21ab8bcSmrg      esac
2683d21ab8bcSmrg      $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
2684d21ab8bcSmrg    done
26859c9ff80cSmrg
2686d21ab8bcSmrg    if $_G_rc_lt_parse_options; then
2687d21ab8bcSmrg      # save modified positional parameters for caller
2688d21ab8bcSmrg      func_quote eval ${1+"$@"}
2689d21ab8bcSmrg      libtool_parse_options_result=$func_quote_result
26909c9ff80cSmrg    fi
2691d21ab8bcSmrg}
2692d21ab8bcSmrgfunc_add_hook func_parse_options libtool_parse_options
2693d21ab8bcSmrg
26949c9ff80cSmrg
26956ee7d557Smrg# func_warning ARG...
26966ee7d557Smrg# -------------------
26976ee7d557Smrg# Libtool warnings are not categorized, so override funclib.sh
26986ee7d557Smrg# func_warning with this simpler definition.
26996ee7d557Smrgfunc_warning ()
27006ee7d557Smrg{
27016ee7d557Smrg    if $opt_warning; then
27026ee7d557Smrg        $debug_cmd
27036ee7d557Smrg        $warning_func ${1+"$@"}
27046ee7d557Smrg    fi
27056ee7d557Smrg}
27066ee7d557Smrg
27079c9ff80cSmrg
2708d21ab8bcSmrg# libtool_validate_options [ARG]...
2709d21ab8bcSmrg# ---------------------------------
2710d21ab8bcSmrg# Perform any sanity checks on option settings and/or unconsumed
2711d21ab8bcSmrg# arguments.
2712d21ab8bcSmrglibtool_validate_options ()
2713d21ab8bcSmrg{
2714d21ab8bcSmrg    # save first non-option argument
2715d21ab8bcSmrg    if test 0 -lt $#; then
2716d21ab8bcSmrg      nonopt=$1
2717d21ab8bcSmrg      shift
27186fae4e5dSmrg    fi
27191f0ac6a5Smrg
2720d21ab8bcSmrg    # preserve --debug
2721d21ab8bcSmrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
2722d21ab8bcSmrg
27236ee7d557Smrg    case $host_os in
2724d21ab8bcSmrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
2725d21ab8bcSmrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
27266ee7d557Smrg      cygwin* | mingw* | windows* | pw32* | cegcc* | solaris2* | os2*)
2727d21ab8bcSmrg        # don't eliminate duplications in $postdeps and $predeps
2728d21ab8bcSmrg        opt_duplicate_compiler_generated_deps=:
2729d21ab8bcSmrg        ;;
2730d21ab8bcSmrg      *)
2731d21ab8bcSmrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
2732d21ab8bcSmrg        ;;
2733d21ab8bcSmrg    esac
2734d21ab8bcSmrg
2735d21ab8bcSmrg    $opt_help || {
2736d21ab8bcSmrg      # Sanity checks first:
2737d21ab8bcSmrg      func_check_version_match
2738d21ab8bcSmrg
2739d21ab8bcSmrg      test yes != "$build_libtool_libs" \
2740d21ab8bcSmrg        && test yes != "$build_old_libs" \
2741d21ab8bcSmrg        && func_fatal_configuration "not configured to build any kind of library"
2742d21ab8bcSmrg
2743d21ab8bcSmrg      # Darwin sucks
2744d21ab8bcSmrg      eval std_shrext=\"$shrext_cmds\"
27459c9ff80cSmrg
2746d21ab8bcSmrg      # Only execute mode is allowed to have -dlopen flags.
2747d21ab8bcSmrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
2748d21ab8bcSmrg        func_error "unrecognized option '-dlopen'"
2749d21ab8bcSmrg        $ECHO "$help" 1>&2
2750d21ab8bcSmrg        exit $EXIT_FAILURE
2751d21ab8bcSmrg      fi
2752d21ab8bcSmrg
2753d21ab8bcSmrg      # Change the help message to a mode-specific one.
2754d21ab8bcSmrg      generic_help=$help
2755d21ab8bcSmrg      help="Try '$progname --help --mode=$opt_mode' for more information."
2756d21ab8bcSmrg    }
27579c9ff80cSmrg
2758d21ab8bcSmrg    # Pass back the unparsed argument list
2759d21ab8bcSmrg    func_quote eval ${1+"$@"}
2760d21ab8bcSmrg    libtool_validate_options_result=$func_quote_result
27616fae4e5dSmrg}
2762d21ab8bcSmrgfunc_add_hook func_validate_options libtool_validate_options
2763d21ab8bcSmrg
27649c9ff80cSmrg
2765d21ab8bcSmrg# Process options as early as possible so that --help and --version
2766d21ab8bcSmrg# can return quickly.
2767d21ab8bcSmrgfunc_options ${1+"$@"}
2768d21ab8bcSmrgeval set dummy "$func_options_result"; shift
27699c9ff80cSmrg
27701f0ac6a5Smrg
27711f0ac6a5Smrg
27726fae4e5dSmrg## ----------- ##
27736fae4e5dSmrg##    Main.    ##
27746fae4e5dSmrg## ----------- ##
27751f0ac6a5Smrg
2776d21ab8bcSmrgmagic='%%%MAGIC variable%%%'
2777d21ab8bcSmrgmagic_exe='%%%MAGIC EXE variable%%%'
2778d21ab8bcSmrg
2779d21ab8bcSmrg# Global variables.
2780d21ab8bcSmrgextracted_archives=
2781d21ab8bcSmrgextracted_serial=0
2782d21ab8bcSmrg
2783d21ab8bcSmrg# If this variable is set in any of the actions, the command in it
2784d21ab8bcSmrg# will be execed at the end.  This prevents here-documents from being
2785d21ab8bcSmrg# left over by shells.
2786d21ab8bcSmrgexec_cmd=
2787d21ab8bcSmrg
2788d21ab8bcSmrg
2789d21ab8bcSmrg# A function that is used when there is no print builtin or printf.
2790d21ab8bcSmrgfunc_fallback_echo ()
2791d21ab8bcSmrg{
2792d21ab8bcSmrg  eval 'cat <<_LTECHO_EOF
2793d21ab8bcSmrg$1
2794d21ab8bcSmrg_LTECHO_EOF'
2795d21ab8bcSmrg}
2796d21ab8bcSmrg
2797d21ab8bcSmrg# func_generated_by_libtool
2798d21ab8bcSmrg# True iff stdin has been generated by Libtool. This function is only
2799d21ab8bcSmrg# a basic sanity check; it will hardly flush out determined imposters.
2800d21ab8bcSmrgfunc_generated_by_libtool_p ()
2801d21ab8bcSmrg{
2802d21ab8bcSmrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
2803d21ab8bcSmrg}
2804d21ab8bcSmrg
28059c9ff80cSmrg# func_lalib_p file
2806d21ab8bcSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
28079c9ff80cSmrg# This function is only a basic sanity check; it will hardly flush out
28089c9ff80cSmrg# determined imposters.
28099c9ff80cSmrgfunc_lalib_p ()
28109c9ff80cSmrg{
28119c9ff80cSmrg    test -f "$1" &&
2812d21ab8bcSmrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
28139c9ff80cSmrg}
28141f0ac6a5Smrg
28159c9ff80cSmrg# func_lalib_unsafe_p file
2816d21ab8bcSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
28179c9ff80cSmrg# This function implements the same check as func_lalib_p without
28189c9ff80cSmrg# resorting to external programs.  To this end, it redirects stdin and
28199c9ff80cSmrg# closes it afterwards, without saving the original file descriptor.
28209c9ff80cSmrg# As a safety measure, use it only where a negative result would be
2821d21ab8bcSmrg# fatal anyway.  Works if 'file' does not exist.
28229c9ff80cSmrgfunc_lalib_unsafe_p ()
28239c9ff80cSmrg{
28249c9ff80cSmrg    lalib_p=no
28259c9ff80cSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
28269c9ff80cSmrg	for lalib_p_l in 1 2 3 4
28279c9ff80cSmrg	do
28289c9ff80cSmrg	    read lalib_p_line
2829d21ab8bcSmrg	    case $lalib_p_line in
28309c9ff80cSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
28319c9ff80cSmrg	    esac
28329c9ff80cSmrg	done
28339c9ff80cSmrg	exec 0<&5 5<&-
28349c9ff80cSmrg    fi
2835d21ab8bcSmrg    test yes = "$lalib_p"
28369c9ff80cSmrg}
28371f0ac6a5Smrg
28389c9ff80cSmrg# func_ltwrapper_script_p file
28399c9ff80cSmrg# True iff FILE is a libtool wrapper script
28409c9ff80cSmrg# This function is only a basic sanity check; it will hardly flush out
28419c9ff80cSmrg# determined imposters.
28429c9ff80cSmrgfunc_ltwrapper_script_p ()
28439c9ff80cSmrg{
2844d21ab8bcSmrg    test -f "$1" &&
2845d21ab8bcSmrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
28469c9ff80cSmrg}
28471f0ac6a5Smrg
28489c9ff80cSmrg# func_ltwrapper_executable_p file
28499c9ff80cSmrg# True iff FILE is a libtool wrapper executable
28509c9ff80cSmrg# This function is only a basic sanity check; it will hardly flush out
28519c9ff80cSmrg# determined imposters.
28529c9ff80cSmrgfunc_ltwrapper_executable_p ()
28539c9ff80cSmrg{
28549c9ff80cSmrg    func_ltwrapper_exec_suffix=
28559c9ff80cSmrg    case $1 in
28569c9ff80cSmrg    *.exe) ;;
28579c9ff80cSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
28589c9ff80cSmrg    esac
28599c9ff80cSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
28609c9ff80cSmrg}
28611f0ac6a5Smrg
28629c9ff80cSmrg# func_ltwrapper_scriptname file
28639c9ff80cSmrg# Assumes file is an ltwrapper_executable
28649c9ff80cSmrg# uses $file to determine the appropriate filename for a
28659c9ff80cSmrg# temporary ltwrapper_script.
28669c9ff80cSmrgfunc_ltwrapper_scriptname ()
28679c9ff80cSmrg{
28686fae4e5dSmrg    func_dirname_and_basename "$1" "" "."
28696fae4e5dSmrg    func_stripname '' '.exe' "$func_basename_result"
2870d21ab8bcSmrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
28719c9ff80cSmrg}
28729c9ff80cSmrg
28739c9ff80cSmrg# func_ltwrapper_p file
28749c9ff80cSmrg# True iff FILE is a libtool wrapper script or wrapper executable
28759c9ff80cSmrg# This function is only a basic sanity check; it will hardly flush out
28769c9ff80cSmrg# determined imposters.
28779c9ff80cSmrgfunc_ltwrapper_p ()
28789c9ff80cSmrg{
28799c9ff80cSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
28809c9ff80cSmrg}
28819c9ff80cSmrg
28829c9ff80cSmrg
28839c9ff80cSmrg# func_execute_cmds commands fail_cmd
28849c9ff80cSmrg# Execute tilde-delimited COMMANDS.
28859c9ff80cSmrg# If FAIL_CMD is given, eval that upon failure.
28869c9ff80cSmrg# FAIL_CMD may read-access the current command in variable CMD!
28879c9ff80cSmrgfunc_execute_cmds ()
28889c9ff80cSmrg{
2889d21ab8bcSmrg    $debug_cmd
2890d21ab8bcSmrg
28919c9ff80cSmrg    save_ifs=$IFS; IFS='~'
28929c9ff80cSmrg    for cmd in $1; do
2893d21ab8bcSmrg      IFS=$sp$nl
28949c9ff80cSmrg      eval cmd=\"$cmd\"
2895d21ab8bcSmrg      IFS=$save_ifs
28969c9ff80cSmrg      func_show_eval "$cmd" "${2-:}"
28979c9ff80cSmrg    done
28989c9ff80cSmrg    IFS=$save_ifs
28999c9ff80cSmrg}
29009c9ff80cSmrg
29019c9ff80cSmrg
29029c9ff80cSmrg# func_source file
29039c9ff80cSmrg# Source FILE, adding directory component if necessary.
29049c9ff80cSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
29059c9ff80cSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
29069c9ff80cSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
2907d21ab8bcSmrg# 'FILE.' does not work on cygwin managed mounts.
29089c9ff80cSmrgfunc_source ()
29099c9ff80cSmrg{
2910d21ab8bcSmrg    $debug_cmd
2911d21ab8bcSmrg
29129c9ff80cSmrg    case $1 in
29139c9ff80cSmrg    */* | *\\*)	. "$1" ;;
29149c9ff80cSmrg    *)		. "./$1" ;;
29159c9ff80cSmrg    esac
29169c9ff80cSmrg}
29179c9ff80cSmrg
29189c9ff80cSmrg
29196fae4e5dSmrg# func_resolve_sysroot PATH
29206fae4e5dSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
29216fae4e5dSmrg# func_resolve_sysroot_result
29226fae4e5dSmrgfunc_resolve_sysroot ()
29236fae4e5dSmrg{
29246fae4e5dSmrg  func_resolve_sysroot_result=$1
29256fae4e5dSmrg  case $func_resolve_sysroot_result in
29266fae4e5dSmrg  =*)
29276fae4e5dSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
29286fae4e5dSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
29296fae4e5dSmrg    ;;
29306fae4e5dSmrg  esac
29316fae4e5dSmrg}
29326fae4e5dSmrg
29336fae4e5dSmrg# func_replace_sysroot PATH
29346fae4e5dSmrg# If PATH begins with the sysroot, replace it with = and
29356fae4e5dSmrg# store the result into func_replace_sysroot_result.
29366fae4e5dSmrgfunc_replace_sysroot ()
29376fae4e5dSmrg{
2938d21ab8bcSmrg  case $lt_sysroot:$1 in
29396fae4e5dSmrg  ?*:"$lt_sysroot"*)
29406fae4e5dSmrg    func_stripname "$lt_sysroot" '' "$1"
2941d21ab8bcSmrg    func_replace_sysroot_result='='$func_stripname_result
29426fae4e5dSmrg    ;;
29436fae4e5dSmrg  *)
29446fae4e5dSmrg    # Including no sysroot.
29456fae4e5dSmrg    func_replace_sysroot_result=$1
29466fae4e5dSmrg    ;;
29476fae4e5dSmrg  esac
29486fae4e5dSmrg}
29496fae4e5dSmrg
29509c9ff80cSmrg# func_infer_tag arg
29519c9ff80cSmrg# Infer tagged configuration to use if any are available and
29529c9ff80cSmrg# if one wasn't chosen via the "--tag" command line option.
29539c9ff80cSmrg# Only attempt this if the compiler in the base compile
29549c9ff80cSmrg# command doesn't match the default compiler.
29559c9ff80cSmrg# arg is usually of the form 'gcc ...'
29569c9ff80cSmrgfunc_infer_tag ()
29579c9ff80cSmrg{
2958d21ab8bcSmrg    $debug_cmd
2959d21ab8bcSmrg
29609c9ff80cSmrg    if test -n "$available_tags" && test -z "$tagname"; then
29619c9ff80cSmrg      CC_quoted=
29629c9ff80cSmrg      for arg in $CC; do
29636fae4e5dSmrg	func_append_quoted CC_quoted "$arg"
29649c9ff80cSmrg      done
29656fae4e5dSmrg      CC_expanded=`func_echo_all $CC`
29666fae4e5dSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
29679c9ff80cSmrg      case $@ in
29689c9ff80cSmrg      # Blanks in the command may have been stripped by the calling shell,
29699c9ff80cSmrg      # but not from the CC environment variable when configure was run.
29706fae4e5dSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
29716fae4e5dSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
29729c9ff80cSmrg      # Blanks at the start of $base_compile will cause this to fail
29739c9ff80cSmrg      # if we don't check for them as well.
29749c9ff80cSmrg      *)
29759c9ff80cSmrg	for z in $available_tags; do
29769c9ff80cSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
29779c9ff80cSmrg	    # Evaluate the configuration.
2978d21ab8bcSmrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
29799c9ff80cSmrg	    CC_quoted=
29809c9ff80cSmrg	    for arg in $CC; do
29819c9ff80cSmrg	      # Double-quote args containing other shell metacharacters.
29826fae4e5dSmrg	      func_append_quoted CC_quoted "$arg"
29839c9ff80cSmrg	    done
29846fae4e5dSmrg	    CC_expanded=`func_echo_all $CC`
29856fae4e5dSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
29869c9ff80cSmrg	    case "$@ " in
29876fae4e5dSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
29886fae4e5dSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
29899c9ff80cSmrg	      # The compiler in the base compile command matches
29909c9ff80cSmrg	      # the one in the tagged configuration.
29919c9ff80cSmrg	      # Assume this is the tagged configuration we want.
29929c9ff80cSmrg	      tagname=$z
29939c9ff80cSmrg	      break
29949c9ff80cSmrg	      ;;
29959c9ff80cSmrg	    esac
29969c9ff80cSmrg	  fi
29979c9ff80cSmrg	done
29989c9ff80cSmrg	# If $tagname still isn't set, then no tagged configuration
29999c9ff80cSmrg	# was found and let the user know that the "--tag" command
30009c9ff80cSmrg	# line option must be used.
30019c9ff80cSmrg	if test -z "$tagname"; then
30029c9ff80cSmrg	  func_echo "unable to infer tagged configuration"
3003d21ab8bcSmrg	  func_fatal_error "specify a tag with '--tag'"
30049c9ff80cSmrg#	else
30059c9ff80cSmrg#	  func_verbose "using $tagname tagged configuration"
30069c9ff80cSmrg	fi
30079c9ff80cSmrg	;;
30089c9ff80cSmrg      esac
30099c9ff80cSmrg    fi
30109c9ff80cSmrg}
30119c9ff80cSmrg
30129c9ff80cSmrg
30139c9ff80cSmrg
30149c9ff80cSmrg# func_write_libtool_object output_name pic_name nonpic_name
30159c9ff80cSmrg# Create a libtool object file (analogous to a ".la" file),
30169c9ff80cSmrg# but don't create it if we're doing a dry run.
30179c9ff80cSmrgfunc_write_libtool_object ()
30189c9ff80cSmrg{
3019d21ab8bcSmrg    write_libobj=$1
3020d21ab8bcSmrg    if test yes = "$build_libtool_libs"; then
3021d21ab8bcSmrg      write_lobj=\'$2\'
30229c9ff80cSmrg    else
30239c9ff80cSmrg      write_lobj=none
30249c9ff80cSmrg    fi
30259c9ff80cSmrg
3026d21ab8bcSmrg    if test yes = "$build_old_libs"; then
3027d21ab8bcSmrg      write_oldobj=\'$3\'
30289c9ff80cSmrg    else
30299c9ff80cSmrg      write_oldobj=none
30309c9ff80cSmrg    fi
30319c9ff80cSmrg
30329c9ff80cSmrg    $opt_dry_run || {
30339c9ff80cSmrg      cat >${write_libobj}T <<EOF
30349c9ff80cSmrg# $write_libobj - a libtool object file
3035d21ab8bcSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
30369c9ff80cSmrg#
30379c9ff80cSmrg# Please DO NOT delete this file!
30389c9ff80cSmrg# It is necessary for linking the library.
30399c9ff80cSmrg
30409c9ff80cSmrg# Name of the PIC object.
30419c9ff80cSmrgpic_object=$write_lobj
30429c9ff80cSmrg
30439c9ff80cSmrg# Name of the non-PIC object
30449c9ff80cSmrgnon_pic_object=$write_oldobj
30459c9ff80cSmrg
30469c9ff80cSmrgEOF
3047d21ab8bcSmrg      $MV "${write_libobj}T" "$write_libobj"
30489c9ff80cSmrg    }
30499c9ff80cSmrg}
30509c9ff80cSmrg
30516fae4e5dSmrg
30526fae4e5dSmrg##################################################
30536fae4e5dSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
30546fae4e5dSmrg##################################################
30556fae4e5dSmrg
30566fae4e5dSmrg# func_convert_core_file_wine_to_w32 ARG
30576fae4e5dSmrg# Helper function used by file name conversion functions when $build is *nix,
30586ee7d557Smrg# and $host is mingw, windows, cygwin, or some other w32 environment. Relies on a
30596fae4e5dSmrg# correctly configured wine environment available, with the winepath program
30606fae4e5dSmrg# in $build's $PATH.
30616fae4e5dSmrg#
30626fae4e5dSmrg# ARG is the $build file name to be converted to w32 format.
30636fae4e5dSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
30646fae4e5dSmrg# be empty on error (or when ARG is empty)
30656fae4e5dSmrgfunc_convert_core_file_wine_to_w32 ()
30666fae4e5dSmrg{
3067d21ab8bcSmrg  $debug_cmd
3068d21ab8bcSmrg
3069d21ab8bcSmrg  func_convert_core_file_wine_to_w32_result=$1
30706fae4e5dSmrg  if test -n "$1"; then
30716fae4e5dSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
30726fae4e5dSmrg    # are forced to check the contents of stdout. On the other hand, if the
30736fae4e5dSmrg    # command is not found, the shell will set an exit code of 127 and print
30746fae4e5dSmrg    # *an error message* to stdout. So we must check for both error code of
30756fae4e5dSmrg    # zero AND non-empty stdout, which explains the odd construction:
30766fae4e5dSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
3077d21ab8bcSmrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
30786fae4e5dSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
3079d21ab8bcSmrg        $SED -e "$sed_naive_backslashify"`
30806fae4e5dSmrg    else
30816fae4e5dSmrg      func_convert_core_file_wine_to_w32_result=
30826fae4e5dSmrg    fi
30836fae4e5dSmrg  fi
30846fae4e5dSmrg}
30856fae4e5dSmrg# end: func_convert_core_file_wine_to_w32
30866fae4e5dSmrg
30876fae4e5dSmrg
30886fae4e5dSmrg# func_convert_core_path_wine_to_w32 ARG
30896fae4e5dSmrg# Helper function used by path conversion functions when $build is *nix, and
30906ee7d557Smrg# $host is mingw, windows, cygwin, or some other w32 environment. Relies on a
30916ee7d557Smrg# correctly configured wine environment available, with the winepath program
30926ee7d557Smrg# in $build's $PATH. Assumes ARG has no leading or trailing path separator
30936ee7d557Smrg# characters.
30946fae4e5dSmrg#
30956fae4e5dSmrg# ARG is path to be converted from $build format to win32.
30966fae4e5dSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
30976fae4e5dSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
30986fae4e5dSmrg# are convertible, then the result may be empty.
30996fae4e5dSmrgfunc_convert_core_path_wine_to_w32 ()
31006fae4e5dSmrg{
3101d21ab8bcSmrg  $debug_cmd
3102d21ab8bcSmrg
31036fae4e5dSmrg  # unfortunately, winepath doesn't convert paths, only file names
3104d21ab8bcSmrg  func_convert_core_path_wine_to_w32_result=
31056fae4e5dSmrg  if test -n "$1"; then
31066fae4e5dSmrg    oldIFS=$IFS
31076fae4e5dSmrg    IFS=:
31086fae4e5dSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
31096fae4e5dSmrg      IFS=$oldIFS
31106fae4e5dSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
3111d21ab8bcSmrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
31126fae4e5dSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
3113d21ab8bcSmrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
31146fae4e5dSmrg        else
31156fae4e5dSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
31166fae4e5dSmrg        fi
31176fae4e5dSmrg      fi
31186fae4e5dSmrg    done
31196fae4e5dSmrg    IFS=$oldIFS
31206fae4e5dSmrg  fi
31216fae4e5dSmrg}
31226fae4e5dSmrg# end: func_convert_core_path_wine_to_w32
31236fae4e5dSmrg
31246fae4e5dSmrg
31256fae4e5dSmrg# func_cygpath ARGS...
31266fae4e5dSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
31276fae4e5dSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
31286fae4e5dSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
31296fae4e5dSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
31306fae4e5dSmrg# file name or path is assumed to be in w32 format, as previously converted
31316fae4e5dSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
31326fae4e5dSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
31336fae4e5dSmrg# Cygwin format). Returns an empty string on error.
31346fae4e5dSmrg#
31356fae4e5dSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
31366fae4e5dSmrg# be converted.
31376fae4e5dSmrg#
31386fae4e5dSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
31396fae4e5dSmrg# environment variable; do not put it in $PATH.
31406fae4e5dSmrgfunc_cygpath ()
31416fae4e5dSmrg{
3142d21ab8bcSmrg  $debug_cmd
3143d21ab8bcSmrg
31446fae4e5dSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
31456fae4e5dSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
31466fae4e5dSmrg    if test "$?" -ne 0; then
31476fae4e5dSmrg      # on failure, ensure result is empty
31486fae4e5dSmrg      func_cygpath_result=
31496fae4e5dSmrg    fi
31506fae4e5dSmrg  else
31516fae4e5dSmrg    func_cygpath_result=
3152d21ab8bcSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
31536fae4e5dSmrg  fi
31546fae4e5dSmrg}
31556fae4e5dSmrg#end: func_cygpath
31566fae4e5dSmrg
31576fae4e5dSmrg
31586fae4e5dSmrg# func_convert_core_msys_to_w32 ARG
31596fae4e5dSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
31606fae4e5dSmrg# result in func_convert_core_msys_to_w32_result.
31616fae4e5dSmrgfunc_convert_core_msys_to_w32 ()
31626fae4e5dSmrg{
3163d21ab8bcSmrg  $debug_cmd
3164d21ab8bcSmrg
31656fae4e5dSmrg  # awkward: cmd appends spaces to result
31666fae4e5dSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
3167d21ab8bcSmrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
31686fae4e5dSmrg}
31696fae4e5dSmrg#end: func_convert_core_msys_to_w32
31706fae4e5dSmrg
31716fae4e5dSmrg
31726fae4e5dSmrg# func_convert_file_check ARG1 ARG2
31736fae4e5dSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
31746fae4e5dSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
31756fae4e5dSmrg# func_to_host_file_result to ARG1).
31766fae4e5dSmrgfunc_convert_file_check ()
31776fae4e5dSmrg{
3178d21ab8bcSmrg  $debug_cmd
3179d21ab8bcSmrg
3180d21ab8bcSmrg  if test -z "$2" && test -n "$1"; then
31816fae4e5dSmrg    func_error "Could not determine host file name corresponding to"
3182d21ab8bcSmrg    func_error "  '$1'"
31836fae4e5dSmrg    func_error "Continuing, but uninstalled executables may not work."
31846fae4e5dSmrg    # Fallback:
3185d21ab8bcSmrg    func_to_host_file_result=$1
31866fae4e5dSmrg  fi
31876fae4e5dSmrg}
31886fae4e5dSmrg# end func_convert_file_check
31896fae4e5dSmrg
31906fae4e5dSmrg
31916fae4e5dSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
31926fae4e5dSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
31936fae4e5dSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
31946fae4e5dSmrg# func_to_host_file_result to a simplistic fallback value (see below).
31956fae4e5dSmrgfunc_convert_path_check ()
31966fae4e5dSmrg{
3197d21ab8bcSmrg  $debug_cmd
3198d21ab8bcSmrg
31996fae4e5dSmrg  if test -z "$4" && test -n "$3"; then
32006fae4e5dSmrg    func_error "Could not determine the host path corresponding to"
3201d21ab8bcSmrg    func_error "  '$3'"
32026fae4e5dSmrg    func_error "Continuing, but uninstalled executables may not work."
32036fae4e5dSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
32046fae4e5dSmrg    # should not be "improved".  See libtool.info.
32056fae4e5dSmrg    if test "x$1" != "x$2"; then
32066fae4e5dSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
32076fae4e5dSmrg      func_to_host_path_result=`echo "$3" |
32086fae4e5dSmrg        $SED -e "$lt_replace_pathsep_chars"`
32096fae4e5dSmrg    else
3210d21ab8bcSmrg      func_to_host_path_result=$3
32116fae4e5dSmrg    fi
32126fae4e5dSmrg  fi
32136fae4e5dSmrg}
32146fae4e5dSmrg# end func_convert_path_check
32156fae4e5dSmrg
32166fae4e5dSmrg
32176fae4e5dSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
32186fae4e5dSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
32196fae4e5dSmrg# and appending REPL if ORIG matches BACKPAT.
32206fae4e5dSmrgfunc_convert_path_front_back_pathsep ()
32216fae4e5dSmrg{
3222d21ab8bcSmrg  $debug_cmd
3223d21ab8bcSmrg
32246fae4e5dSmrg  case $4 in
3225d21ab8bcSmrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
32266fae4e5dSmrg    ;;
32276fae4e5dSmrg  esac
32286fae4e5dSmrg  case $4 in
32296fae4e5dSmrg  $2 ) func_append func_to_host_path_result "$3"
32306fae4e5dSmrg    ;;
32316fae4e5dSmrg  esac
32326fae4e5dSmrg}
32336fae4e5dSmrg# end func_convert_path_front_back_pathsep
32346fae4e5dSmrg
32356fae4e5dSmrg
32366ee7d557Smrg# func_convert_delimited_path PATH ORIG_DELIMITER NEW_DELIMITER
32376ee7d557Smrg# Replaces a delimiter for a given path.
32386ee7d557Smrgfunc_convert_delimited_path ()
32396ee7d557Smrg{
32406ee7d557Smrg	converted_path=`$ECHO "$1" | $SED "s#$2#$3#g"`
32416ee7d557Smrg}
32426ee7d557Smrg# end func_convert_delimited_path
32436ee7d557Smrg
32446ee7d557Smrg
32456fae4e5dSmrg##################################################
32466fae4e5dSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
32476fae4e5dSmrg##################################################
3248d21ab8bcSmrg# invoked via '$to_host_file_cmd ARG'
32496fae4e5dSmrg#
32506fae4e5dSmrg# In each case, ARG is the path to be converted from $build to $host format.
32516fae4e5dSmrg# Result will be available in $func_to_host_file_result.
32526fae4e5dSmrg
32536fae4e5dSmrg
32546fae4e5dSmrg# func_to_host_file ARG
32556fae4e5dSmrg# Converts the file name ARG from $build format to $host format. Return result
32566fae4e5dSmrg# in func_to_host_file_result.
32576fae4e5dSmrgfunc_to_host_file ()
32586fae4e5dSmrg{
3259d21ab8bcSmrg  $debug_cmd
3260d21ab8bcSmrg
32616fae4e5dSmrg  $to_host_file_cmd "$1"
32626fae4e5dSmrg}
32636fae4e5dSmrg# end func_to_host_file
32646fae4e5dSmrg
32656fae4e5dSmrg
32666fae4e5dSmrg# func_to_tool_file ARG LAZY
32676fae4e5dSmrg# converts the file name ARG from $build format to toolchain format. Return
32686fae4e5dSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
32696fae4e5dSmrg# in (the comma separated) LAZY, no conversion takes place.
32706fae4e5dSmrgfunc_to_tool_file ()
32716fae4e5dSmrg{
3272d21ab8bcSmrg  $debug_cmd
3273d21ab8bcSmrg
32746fae4e5dSmrg  case ,$2, in
32756fae4e5dSmrg    *,"$to_tool_file_cmd",*)
32766fae4e5dSmrg      func_to_tool_file_result=$1
32776fae4e5dSmrg      ;;
32786fae4e5dSmrg    *)
32796fae4e5dSmrg      $to_tool_file_cmd "$1"
32806fae4e5dSmrg      func_to_tool_file_result=$func_to_host_file_result
32816fae4e5dSmrg      ;;
32826fae4e5dSmrg  esac
32836fae4e5dSmrg}
32846fae4e5dSmrg# end func_to_tool_file
32856fae4e5dSmrg
32866fae4e5dSmrg
32876fae4e5dSmrg# func_convert_file_noop ARG
32886fae4e5dSmrg# Copy ARG to func_to_host_file_result.
32896fae4e5dSmrgfunc_convert_file_noop ()
32906fae4e5dSmrg{
3291d21ab8bcSmrg  func_to_host_file_result=$1
32926fae4e5dSmrg}
32936fae4e5dSmrg# end func_convert_file_noop
32946fae4e5dSmrg
32956fae4e5dSmrg
32966fae4e5dSmrg# func_convert_file_msys_to_w32 ARG
32976fae4e5dSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
32986fae4e5dSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
32996fae4e5dSmrg# func_to_host_file_result.
33006fae4e5dSmrgfunc_convert_file_msys_to_w32 ()
33016fae4e5dSmrg{
3302d21ab8bcSmrg  $debug_cmd
3303d21ab8bcSmrg
3304d21ab8bcSmrg  func_to_host_file_result=$1
33056fae4e5dSmrg  if test -n "$1"; then
33066fae4e5dSmrg    func_convert_core_msys_to_w32 "$1"
3307d21ab8bcSmrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
33086fae4e5dSmrg  fi
33096fae4e5dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
33106fae4e5dSmrg}
33116fae4e5dSmrg# end func_convert_file_msys_to_w32
33126fae4e5dSmrg
33136fae4e5dSmrg
33146fae4e5dSmrg# func_convert_file_cygwin_to_w32 ARG
33156fae4e5dSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
33166fae4e5dSmrg# func_to_host_file_result.
33176fae4e5dSmrgfunc_convert_file_cygwin_to_w32 ()
33186fae4e5dSmrg{
3319d21ab8bcSmrg  $debug_cmd
3320d21ab8bcSmrg
3321d21ab8bcSmrg  func_to_host_file_result=$1
33226fae4e5dSmrg  if test -n "$1"; then
33236fae4e5dSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
33246fae4e5dSmrg    # LT_CYGPATH in this case.
33256fae4e5dSmrg    func_to_host_file_result=`cygpath -m "$1"`
33266fae4e5dSmrg  fi
33276fae4e5dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
33286fae4e5dSmrg}
33296fae4e5dSmrg# end func_convert_file_cygwin_to_w32
33306fae4e5dSmrg
33316fae4e5dSmrg
33326fae4e5dSmrg# func_convert_file_nix_to_w32 ARG
33336fae4e5dSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
33346fae4e5dSmrg# and a working winepath. Returns result in func_to_host_file_result.
33356fae4e5dSmrgfunc_convert_file_nix_to_w32 ()
33366fae4e5dSmrg{
3337d21ab8bcSmrg  $debug_cmd
3338d21ab8bcSmrg
3339d21ab8bcSmrg  func_to_host_file_result=$1
33406fae4e5dSmrg  if test -n "$1"; then
33416fae4e5dSmrg    func_convert_core_file_wine_to_w32 "$1"
3342d21ab8bcSmrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
33436fae4e5dSmrg  fi
33446fae4e5dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
33456fae4e5dSmrg}
33466fae4e5dSmrg# end func_convert_file_nix_to_w32
33476fae4e5dSmrg
33486fae4e5dSmrg
33496fae4e5dSmrg# func_convert_file_msys_to_cygwin ARG
33506fae4e5dSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
33516fae4e5dSmrg# Returns result in func_to_host_file_result.
33526fae4e5dSmrgfunc_convert_file_msys_to_cygwin ()
33536fae4e5dSmrg{
3354d21ab8bcSmrg  $debug_cmd
3355d21ab8bcSmrg
3356d21ab8bcSmrg  func_to_host_file_result=$1
33576fae4e5dSmrg  if test -n "$1"; then
33586fae4e5dSmrg    func_convert_core_msys_to_w32 "$1"
33596fae4e5dSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
3360d21ab8bcSmrg    func_to_host_file_result=$func_cygpath_result
33616fae4e5dSmrg  fi
33626fae4e5dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
33636fae4e5dSmrg}
33646fae4e5dSmrg# end func_convert_file_msys_to_cygwin
33656fae4e5dSmrg
33666fae4e5dSmrg
33676fae4e5dSmrg# func_convert_file_nix_to_cygwin ARG
33686fae4e5dSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
33696fae4e5dSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
33706fae4e5dSmrg# in func_to_host_file_result.
33716fae4e5dSmrgfunc_convert_file_nix_to_cygwin ()
33726fae4e5dSmrg{
3373d21ab8bcSmrg  $debug_cmd
3374d21ab8bcSmrg
3375d21ab8bcSmrg  func_to_host_file_result=$1
33766fae4e5dSmrg  if test -n "$1"; then
33776fae4e5dSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
33786fae4e5dSmrg    func_convert_core_file_wine_to_w32 "$1"
33796fae4e5dSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
3380d21ab8bcSmrg    func_to_host_file_result=$func_cygpath_result
33816fae4e5dSmrg  fi
33826fae4e5dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
33836fae4e5dSmrg}
33846fae4e5dSmrg# end func_convert_file_nix_to_cygwin
33856fae4e5dSmrg
33866fae4e5dSmrg
33876fae4e5dSmrg#############################################
33886fae4e5dSmrg# $build to $host PATH CONVERSION FUNCTIONS #
33896fae4e5dSmrg#############################################
3390d21ab8bcSmrg# invoked via '$to_host_path_cmd ARG'
33916fae4e5dSmrg#
33926fae4e5dSmrg# In each case, ARG is the path to be converted from $build to $host format.
33936fae4e5dSmrg# The result will be available in $func_to_host_path_result.
33946fae4e5dSmrg#
33956fae4e5dSmrg# Path separators are also converted from $build format to $host format.  If
33966fae4e5dSmrg# ARG begins or ends with a path separator character, it is preserved (but
33976fae4e5dSmrg# converted to $host format) on output.
33986fae4e5dSmrg#
33996fae4e5dSmrg# All path conversion functions are named using the following convention:
34006fae4e5dSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
34016fae4e5dSmrg#   path conversion function         : func_convert_path_X_to_Y ()
34026fae4e5dSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
34036fae4e5dSmrg# same.  If conversion functions are added for new $build/$host combinations,
34046fae4e5dSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
34056fae4e5dSmrg# will break.
34066fae4e5dSmrg
34076fae4e5dSmrg
34086fae4e5dSmrg# func_init_to_host_path_cmd
34096fae4e5dSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
34106fae4e5dSmrg# appropriate value, based on the value of $to_host_file_cmd.
34116fae4e5dSmrgto_host_path_cmd=
34126fae4e5dSmrgfunc_init_to_host_path_cmd ()
34136fae4e5dSmrg{
3414d21ab8bcSmrg  $debug_cmd
3415d21ab8bcSmrg
34166fae4e5dSmrg  if test -z "$to_host_path_cmd"; then
34176fae4e5dSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
3418d21ab8bcSmrg    to_host_path_cmd=func_convert_path_$func_stripname_result
34196fae4e5dSmrg  fi
34206fae4e5dSmrg}
34216fae4e5dSmrg
34226fae4e5dSmrg
34236fae4e5dSmrg# func_to_host_path ARG
34246fae4e5dSmrg# Converts the path ARG from $build format to $host format. Return result
34256fae4e5dSmrg# in func_to_host_path_result.
34266fae4e5dSmrgfunc_to_host_path ()
34276fae4e5dSmrg{
3428d21ab8bcSmrg  $debug_cmd
3429d21ab8bcSmrg
34306fae4e5dSmrg  func_init_to_host_path_cmd
34316fae4e5dSmrg  $to_host_path_cmd "$1"
34326fae4e5dSmrg}
34336fae4e5dSmrg# end func_to_host_path
34346fae4e5dSmrg
34356fae4e5dSmrg
34366fae4e5dSmrg# func_convert_path_noop ARG
34376fae4e5dSmrg# Copy ARG to func_to_host_path_result.
34386fae4e5dSmrgfunc_convert_path_noop ()
34396fae4e5dSmrg{
3440d21ab8bcSmrg  func_to_host_path_result=$1
34416fae4e5dSmrg}
34426fae4e5dSmrg# end func_convert_path_noop
34436fae4e5dSmrg
34446fae4e5dSmrg
34456fae4e5dSmrg# func_convert_path_msys_to_w32 ARG
34466fae4e5dSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
34476fae4e5dSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
34486fae4e5dSmrg# func_to_host_path_result.
34496fae4e5dSmrgfunc_convert_path_msys_to_w32 ()
34506fae4e5dSmrg{
3451d21ab8bcSmrg  $debug_cmd
3452d21ab8bcSmrg
3453d21ab8bcSmrg  func_to_host_path_result=$1
34546fae4e5dSmrg  if test -n "$1"; then
34556fae4e5dSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
34566fae4e5dSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
34576fae4e5dSmrg    # and winepath ignores them completely.
34586fae4e5dSmrg    func_stripname : : "$1"
34596fae4e5dSmrg    func_to_host_path_tmp1=$func_stripname_result
34606fae4e5dSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3461d21ab8bcSmrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
34626fae4e5dSmrg    func_convert_path_check : ";" \
34636fae4e5dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
34646fae4e5dSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
34656fae4e5dSmrg  fi
34666fae4e5dSmrg}
34676fae4e5dSmrg# end func_convert_path_msys_to_w32
34686fae4e5dSmrg
34696fae4e5dSmrg
34706fae4e5dSmrg# func_convert_path_cygwin_to_w32 ARG
34716fae4e5dSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
34726fae4e5dSmrg# func_to_host_file_result.
34736fae4e5dSmrgfunc_convert_path_cygwin_to_w32 ()
34746fae4e5dSmrg{
3475d21ab8bcSmrg  $debug_cmd
3476d21ab8bcSmrg
3477d21ab8bcSmrg  func_to_host_path_result=$1
34786fae4e5dSmrg  if test -n "$1"; then
34796fae4e5dSmrg    # See func_convert_path_msys_to_w32:
34806fae4e5dSmrg    func_stripname : : "$1"
34816fae4e5dSmrg    func_to_host_path_tmp1=$func_stripname_result
34826fae4e5dSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
34836fae4e5dSmrg    func_convert_path_check : ";" \
34846fae4e5dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
34856fae4e5dSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
34866fae4e5dSmrg  fi
34876fae4e5dSmrg}
34886fae4e5dSmrg# end func_convert_path_cygwin_to_w32
34896fae4e5dSmrg
34906fae4e5dSmrg
34916fae4e5dSmrg# func_convert_path_nix_to_w32 ARG
34926fae4e5dSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
34936fae4e5dSmrg# a working winepath.  Returns result in func_to_host_file_result.
34946fae4e5dSmrgfunc_convert_path_nix_to_w32 ()
34956fae4e5dSmrg{
3496d21ab8bcSmrg  $debug_cmd
3497d21ab8bcSmrg
3498d21ab8bcSmrg  func_to_host_path_result=$1
34996fae4e5dSmrg  if test -n "$1"; then
35006fae4e5dSmrg    # See func_convert_path_msys_to_w32:
35016fae4e5dSmrg    func_stripname : : "$1"
35026fae4e5dSmrg    func_to_host_path_tmp1=$func_stripname_result
35036fae4e5dSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3504d21ab8bcSmrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
35056fae4e5dSmrg    func_convert_path_check : ";" \
35066fae4e5dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
35076fae4e5dSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
35086fae4e5dSmrg  fi
35096fae4e5dSmrg}
35106fae4e5dSmrg# end func_convert_path_nix_to_w32
35116fae4e5dSmrg
35126fae4e5dSmrg
35136fae4e5dSmrg# func_convert_path_msys_to_cygwin ARG
35146fae4e5dSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
35156fae4e5dSmrg# Returns result in func_to_host_file_result.
35166fae4e5dSmrgfunc_convert_path_msys_to_cygwin ()
35176fae4e5dSmrg{
3518d21ab8bcSmrg  $debug_cmd
3519d21ab8bcSmrg
3520d21ab8bcSmrg  func_to_host_path_result=$1
35216fae4e5dSmrg  if test -n "$1"; then
35226fae4e5dSmrg    # See func_convert_path_msys_to_w32:
35236fae4e5dSmrg    func_stripname : : "$1"
35246fae4e5dSmrg    func_to_host_path_tmp1=$func_stripname_result
35256fae4e5dSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
35266fae4e5dSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
3527d21ab8bcSmrg    func_to_host_path_result=$func_cygpath_result
35286fae4e5dSmrg    func_convert_path_check : : \
35296fae4e5dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
35306fae4e5dSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
35316fae4e5dSmrg  fi
35326fae4e5dSmrg}
35336fae4e5dSmrg# end func_convert_path_msys_to_cygwin
35346fae4e5dSmrg
35356fae4e5dSmrg
35366fae4e5dSmrg# func_convert_path_nix_to_cygwin ARG
35376fae4e5dSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
35386fae4e5dSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
35396fae4e5dSmrg# func_to_host_file_result.
35406fae4e5dSmrgfunc_convert_path_nix_to_cygwin ()
35416fae4e5dSmrg{
3542d21ab8bcSmrg  $debug_cmd
3543d21ab8bcSmrg
3544d21ab8bcSmrg  func_to_host_path_result=$1
35456fae4e5dSmrg  if test -n "$1"; then
35466fae4e5dSmrg    # Remove leading and trailing path separator characters from
35476fae4e5dSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
35486fae4e5dSmrg    # into '.;' and ';.', and winepath ignores them completely.
35496fae4e5dSmrg    func_stripname : : "$1"
35506fae4e5dSmrg    func_to_host_path_tmp1=$func_stripname_result
35516fae4e5dSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
35526fae4e5dSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
3553d21ab8bcSmrg    func_to_host_path_result=$func_cygpath_result
35546fae4e5dSmrg    func_convert_path_check : : \
35556fae4e5dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
35566fae4e5dSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
35576fae4e5dSmrg  fi
35586fae4e5dSmrg}
35596fae4e5dSmrg# end func_convert_path_nix_to_cygwin
35606fae4e5dSmrg
35616fae4e5dSmrg
3562d21ab8bcSmrg# func_dll_def_p FILE
3563d21ab8bcSmrg# True iff FILE is a Windows DLL '.def' file.
3564d21ab8bcSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
3565d21ab8bcSmrgfunc_dll_def_p ()
3566d21ab8bcSmrg{
3567d21ab8bcSmrg  $debug_cmd
3568d21ab8bcSmrg
3569d21ab8bcSmrg  func_dll_def_p_tmp=`$SED -n \
3570d21ab8bcSmrg    -e 's/^[	 ]*//' \
3571d21ab8bcSmrg    -e '/^\(;.*\)*$/d' \
3572d21ab8bcSmrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
3573d21ab8bcSmrg    -e q \
3574d21ab8bcSmrg    "$1"`
3575d21ab8bcSmrg  test DEF = "$func_dll_def_p_tmp"
3576d21ab8bcSmrg}
3577d21ab8bcSmrg
3578d21ab8bcSmrg
35796ee7d557Smrg# func_reorder_shared_lib_cache DIRS
35806ee7d557Smrg# Reorder the shared library cache by unconfiguring previous shared library cache
35816ee7d557Smrg# and configuring preferred search directories before previous search directories.
35826ee7d557Smrg# Previous shared library cache: /usr/lib /usr/local/lib
35836ee7d557Smrg# Preferred search directories: /tmp/testing
35846ee7d557Smrg# Reordered shared library cache: /tmp/testing /usr/lib /usr/local/lib
35856ee7d557Smrgfunc_reorder_shared_lib_cache ()
35866ee7d557Smrg{
35876ee7d557Smrg	$debug_cmd
35886ee7d557Smrg
35896ee7d557Smrg	case $host_os in
35906ee7d557Smrg	  openbsd*)
35916ee7d557Smrg	    get_search_directories=`PATH="$PATH:/sbin" ldconfig -r | $GREP "search directories" | $SED "s#.*search directories:\ ##g"`
35926ee7d557Smrg	    func_convert_delimited_path "$get_search_directories" ':' '\ '
35936ee7d557Smrg	    save_search_directories=$converted_path
35946ee7d557Smrg	    func_convert_delimited_path "$1" ':' '\ '
35956ee7d557Smrg
35966ee7d557Smrg	    # Ensure directories exist
35976ee7d557Smrg	    for dir in $converted_path; do
35986ee7d557Smrg	      # Ensure each directory is an absolute path
35996ee7d557Smrg	      case $dir in
36006ee7d557Smrg	        /*) ;;
36016ee7d557Smrg	        *) func_error "Directory '$dir' is not an absolute path"
36026ee7d557Smrg	           exit $EXIT_FAILURE ;;
36036ee7d557Smrg	      esac
36046ee7d557Smrg	      # Ensure no trailing slashes
36056ee7d557Smrg	      func_stripname '' '/' "$dir"
36066ee7d557Smrg	      dir=$func_stripname_result
36076ee7d557Smrg	      if test -d "$dir"; then
36086ee7d557Smrg	        if test -n "$preferred_search_directories"; then
36096ee7d557Smrg	          preferred_search_directories="$preferred_search_directories $dir"
36106ee7d557Smrg	        else
36116ee7d557Smrg	          preferred_search_directories=$dir
36126ee7d557Smrg	        fi
36136ee7d557Smrg	      else
36146ee7d557Smrg	        func_error "Directory '$dir' does not exist"
36156ee7d557Smrg	        exit $EXIT_FAILURE
36166ee7d557Smrg	      fi
36176ee7d557Smrg	    done
36186ee7d557Smrg
36196ee7d557Smrg	    PATH="$PATH:/sbin" ldconfig -U $save_search_directories
36206ee7d557Smrg	    PATH="$PATH:/sbin" ldconfig -m $preferred_search_directories $save_search_directories
36216ee7d557Smrg	    get_search_directories=`PATH="$PATH:/sbin" ldconfig -r | $GREP "search directories" | $SED "s#.*search directories:\ ##g"`
36226ee7d557Smrg	    func_convert_delimited_path "$get_search_directories" ':' '\ '
36236ee7d557Smrg	    reordered_search_directories=$converted_path
36246ee7d557Smrg
36256ee7d557Smrg	    $ECHO "Original: $save_search_directories"
36266ee7d557Smrg	    $ECHO "Reordered: $reordered_search_directories"
36276ee7d557Smrg	    exit $EXIT_SUCCESS
36286ee7d557Smrg	  ;;
36296ee7d557Smrg	  *)
36306ee7d557Smrg	    func_error "--reorder-cache is not supported for host_os=$host_os."
36316ee7d557Smrg	    exit $EXIT_FAILURE
36326ee7d557Smrg	  ;;
36336ee7d557Smrg	esac
36346ee7d557Smrg}
36356ee7d557Smrg# end func_reorder_shared_lib_cache
36366ee7d557Smrg
36376ee7d557Smrg
36389c9ff80cSmrg# func_mode_compile arg...
36399c9ff80cSmrgfunc_mode_compile ()
36409c9ff80cSmrg{
3641d21ab8bcSmrg    $debug_cmd
3642d21ab8bcSmrg
36439c9ff80cSmrg    # Get the compilation command and the source file.
36449c9ff80cSmrg    base_compile=
3645d21ab8bcSmrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
36469c9ff80cSmrg    suppress_opt=yes
36479c9ff80cSmrg    suppress_output=
36489c9ff80cSmrg    arg_mode=normal
36499c9ff80cSmrg    libobj=
36509c9ff80cSmrg    later=
36519c9ff80cSmrg    pie_flag=
36529c9ff80cSmrg
36539c9ff80cSmrg    for arg
36549c9ff80cSmrg    do
36559c9ff80cSmrg      case $arg_mode in
36569c9ff80cSmrg      arg  )
36579c9ff80cSmrg	# do not "continue".  Instead, add this to base_compile
3658d21ab8bcSmrg	lastarg=$arg
36599c9ff80cSmrg	arg_mode=normal
36609c9ff80cSmrg	;;
36619c9ff80cSmrg
36629c9ff80cSmrg      target )
3663d21ab8bcSmrg	libobj=$arg
36649c9ff80cSmrg	arg_mode=normal
36659c9ff80cSmrg	continue
36669c9ff80cSmrg	;;
36679c9ff80cSmrg
36689c9ff80cSmrg      normal )
36699c9ff80cSmrg	# Accept any command-line options.
36709c9ff80cSmrg	case $arg in
36719c9ff80cSmrg	-o)
36729c9ff80cSmrg	  test -n "$libobj" && \
3673d21ab8bcSmrg	    func_fatal_error "you cannot specify '-o' more than once"
36749c9ff80cSmrg	  arg_mode=target
36759c9ff80cSmrg	  continue
36769c9ff80cSmrg	  ;;
36779c9ff80cSmrg
36789c9ff80cSmrg	-pie | -fpie | -fPIE)
36796fae4e5dSmrg          func_append pie_flag " $arg"
36809c9ff80cSmrg	  continue
36819c9ff80cSmrg	  ;;
36829c9ff80cSmrg
36839c9ff80cSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
36846fae4e5dSmrg	  func_append later " $arg"
36859c9ff80cSmrg	  continue
36869c9ff80cSmrg	  ;;
36879c9ff80cSmrg
36889c9ff80cSmrg	-no-suppress)
36891f0ac6a5Smrg	  suppress_opt=no
36901f0ac6a5Smrg	  continue
36911f0ac6a5Smrg	  ;;
36921f0ac6a5Smrg
36931f0ac6a5Smrg	-Xcompiler)
36941f0ac6a5Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
36951f0ac6a5Smrg	  continue      #  The current "srcfile" will either be retained or
36961f0ac6a5Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
36971f0ac6a5Smrg
36981f0ac6a5Smrg	-Wc,*)
36999c9ff80cSmrg	  func_stripname '-Wc,' '' "$arg"
37009c9ff80cSmrg	  args=$func_stripname_result
37011f0ac6a5Smrg	  lastarg=
3702d21ab8bcSmrg	  save_ifs=$IFS; IFS=,
37039c9ff80cSmrg	  for arg in $args; do
3704d21ab8bcSmrg	    IFS=$save_ifs
37056fae4e5dSmrg	    func_append_quoted lastarg "$arg"
37061f0ac6a5Smrg	  done
3707d21ab8bcSmrg	  IFS=$save_ifs
37089c9ff80cSmrg	  func_stripname ' ' '' "$lastarg"
37099c9ff80cSmrg	  lastarg=$func_stripname_result
37101f0ac6a5Smrg
37111f0ac6a5Smrg	  # Add the arguments to base_compile.
37126fae4e5dSmrg	  func_append base_compile " $lastarg"
37131f0ac6a5Smrg	  continue
37141f0ac6a5Smrg	  ;;
37151f0ac6a5Smrg
37169c9ff80cSmrg	*)
37171f0ac6a5Smrg	  # Accept the current argument as the source file.
37181f0ac6a5Smrg	  # The previous "srcfile" becomes the current argument.
37191f0ac6a5Smrg	  #
3720d21ab8bcSmrg	  lastarg=$srcfile
3721d21ab8bcSmrg	  srcfile=$arg
37221f0ac6a5Smrg	  ;;
37231f0ac6a5Smrg	esac  #  case $arg
37241f0ac6a5Smrg	;;
37251f0ac6a5Smrg      esac    #  case $arg_mode
37261f0ac6a5Smrg
37271f0ac6a5Smrg      # Aesthetically quote the previous argument.
37286fae4e5dSmrg      func_append_quoted base_compile "$lastarg"
37291f0ac6a5Smrg    done # for arg
37301f0ac6a5Smrg
37311f0ac6a5Smrg    case $arg_mode in
37321f0ac6a5Smrg    arg)
37339c9ff80cSmrg      func_fatal_error "you must specify an argument for -Xcompile"
37341f0ac6a5Smrg      ;;
37351f0ac6a5Smrg    target)
3736d21ab8bcSmrg      func_fatal_error "you must specify a target with '-o'"
37371f0ac6a5Smrg      ;;
37381f0ac6a5Smrg    *)
37391f0ac6a5Smrg      # Get the name of the library object.
37409c9ff80cSmrg      test -z "$libobj" && {
37419c9ff80cSmrg	func_basename "$srcfile"
3742d21ab8bcSmrg	libobj=$func_basename_result
37439c9ff80cSmrg      }
37441f0ac6a5Smrg      ;;
37451f0ac6a5Smrg    esac
37461f0ac6a5Smrg
37471f0ac6a5Smrg    # Recognize several different file suffixes.
37481f0ac6a5Smrg    # If the user specifies -o file.o, it is replaced with file.lo
37491f0ac6a5Smrg    case $libobj in
37509c9ff80cSmrg    *.[cCFSifmso] | \
37519c9ff80cSmrg    *.ada | *.adb | *.ads | *.asm | \
37529c9ff80cSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
375389c04b6cSmrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
37549c9ff80cSmrg      func_xform "$libobj"
37559c9ff80cSmrg      libobj=$func_xform_result
37569c9ff80cSmrg      ;;
37571f0ac6a5Smrg    esac
37581f0ac6a5Smrg
37591f0ac6a5Smrg    case $libobj in
37609c9ff80cSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
37611f0ac6a5Smrg    *)
3762d21ab8bcSmrg      func_fatal_error "cannot determine name of library object from '$libobj'"
37631f0ac6a5Smrg      ;;
37641f0ac6a5Smrg    esac
37651f0ac6a5Smrg
37661f0ac6a5Smrg    func_infer_tag $base_compile
37671f0ac6a5Smrg
37681f0ac6a5Smrg    for arg in $later; do
37691f0ac6a5Smrg      case $arg in
37709c9ff80cSmrg      -shared)
3771d21ab8bcSmrg	test yes = "$build_libtool_libs" \
3772d21ab8bcSmrg	  || func_fatal_configuration "cannot build a shared library"
37739c9ff80cSmrg	build_old_libs=no
37749c9ff80cSmrg	continue
37759c9ff80cSmrg	;;
37769c9ff80cSmrg
37771f0ac6a5Smrg      -static)
37789c9ff80cSmrg	build_libtool_libs=no
37791f0ac6a5Smrg	build_old_libs=yes
37801f0ac6a5Smrg	continue
37811f0ac6a5Smrg	;;
37821f0ac6a5Smrg
37831f0ac6a5Smrg      -prefer-pic)
37841f0ac6a5Smrg	pic_mode=yes
37851f0ac6a5Smrg	continue
37861f0ac6a5Smrg	;;
37871f0ac6a5Smrg
37881f0ac6a5Smrg      -prefer-non-pic)
37891f0ac6a5Smrg	pic_mode=no
37901f0ac6a5Smrg	continue
37911f0ac6a5Smrg	;;
37921f0ac6a5Smrg      esac
37931f0ac6a5Smrg    done
37941f0ac6a5Smrg
3795d21ab8bcSmrg    func_quote_arg pretty "$libobj"
3796d21ab8bcSmrg    test "X$libobj" != "X$func_quote_arg_result" \
37979c9ff80cSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
3798d21ab8bcSmrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
37999c9ff80cSmrg    func_dirname_and_basename "$obj" "/" ""
3800d21ab8bcSmrg    objname=$func_basename_result
3801d21ab8bcSmrg    xdir=$func_dirname_result
3802d21ab8bcSmrg    lobj=$xdir$objdir/$objname
38031f0ac6a5Smrg
38049c9ff80cSmrg    test -z "$base_compile" && \
38059c9ff80cSmrg      func_fatal_help "you must specify a compilation command"
38061f0ac6a5Smrg
38071f0ac6a5Smrg    # Delete any leftover library objects.
3808d21ab8bcSmrg    if test yes = "$build_old_libs"; then
38091f0ac6a5Smrg      removelist="$obj $lobj $libobj ${libobj}T"
38101f0ac6a5Smrg    else
38111f0ac6a5Smrg      removelist="$lobj $libobj ${libobj}T"
38121f0ac6a5Smrg    fi
38131f0ac6a5Smrg
38141f0ac6a5Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
38151f0ac6a5Smrg    case $host_os in
38166ee7d557Smrg    cygwin* | mingw* | windows* | pw32* | os2* | cegcc*)
38171f0ac6a5Smrg      pic_mode=default
38181f0ac6a5Smrg      ;;
38191f0ac6a5Smrg    esac
3820d21ab8bcSmrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
38211f0ac6a5Smrg      # non-PIC code in shared libraries is not supported
38221f0ac6a5Smrg      pic_mode=default
38231f0ac6a5Smrg    fi
38241f0ac6a5Smrg
38251f0ac6a5Smrg    # Calculate the filename of the output object if compiler does
38261f0ac6a5Smrg    # not support -o with -c
3827d21ab8bcSmrg    if test no = "$compiler_c_o"; then
3828d21ab8bcSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
3829d21ab8bcSmrg      lockfile=$output_obj.lock
38301f0ac6a5Smrg    else
38311f0ac6a5Smrg      output_obj=
38321f0ac6a5Smrg      need_locks=no
38331f0ac6a5Smrg      lockfile=
38341f0ac6a5Smrg    fi
38351f0ac6a5Smrg
38361f0ac6a5Smrg    # Lock this critical section if it is needed
38371f0ac6a5Smrg    # We use this script file to make the link, it avoids creating a new file
3838d21ab8bcSmrg    if test yes = "$need_locks"; then
38399c9ff80cSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
38409c9ff80cSmrg	func_echo "Waiting for $lockfile to be removed"
38411f0ac6a5Smrg	sleep 2
38421f0ac6a5Smrg      done
3843d21ab8bcSmrg    elif test warn = "$need_locks"; then
38441f0ac6a5Smrg      if test -f "$lockfile"; then
38459c9ff80cSmrg	$ECHO "\
38461f0ac6a5Smrg*** ERROR, $lockfile exists and contains:
38471f0ac6a5Smrg`cat $lockfile 2>/dev/null`
38481f0ac6a5Smrg
38491f0ac6a5SmrgThis indicates that another process is trying to use the same
38501f0ac6a5Smrgtemporary object file, and libtool could not work around it because
3851d21ab8bcSmrgyour compiler does not support '-c' and '-o' together.  If you
38521f0ac6a5Smrgrepeat this compilation, it may succeed, by chance, but you had better
38531f0ac6a5Smrgavoid parallel builds (make -j) in this platform, or get a better
38541f0ac6a5Smrgcompiler."
38551f0ac6a5Smrg
38569c9ff80cSmrg	$opt_dry_run || $RM $removelist
38571f0ac6a5Smrg	exit $EXIT_FAILURE
38581f0ac6a5Smrg      fi
38596fae4e5dSmrg      func_append removelist " $output_obj"
38609c9ff80cSmrg      $ECHO "$srcfile" > "$lockfile"
38611f0ac6a5Smrg    fi
38621f0ac6a5Smrg
38639c9ff80cSmrg    $opt_dry_run || $RM $removelist
38646fae4e5dSmrg    func_append removelist " $lockfile"
38659c9ff80cSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
38669c9ff80cSmrg
38676fae4e5dSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
38686fae4e5dSmrg    srcfile=$func_to_tool_file_result
3869d21ab8bcSmrg    func_quote_arg pretty "$srcfile"
3870d21ab8bcSmrg    qsrcfile=$func_quote_arg_result
38711f0ac6a5Smrg
38721f0ac6a5Smrg    # Only build a PIC object if we are building libtool libraries.
3873d21ab8bcSmrg    if test yes = "$build_libtool_libs"; then
38741f0ac6a5Smrg      # Without this assignment, base_compile gets emptied.
38751f0ac6a5Smrg      fbsd_hideous_sh_bug=$base_compile
38761f0ac6a5Smrg
3877d21ab8bcSmrg      if test no != "$pic_mode"; then
38781f0ac6a5Smrg	command="$base_compile $qsrcfile $pic_flag"
38791f0ac6a5Smrg      else
38801f0ac6a5Smrg	# Don't build PIC code
38811f0ac6a5Smrg	command="$base_compile $qsrcfile"
38821f0ac6a5Smrg      fi
38831f0ac6a5Smrg
38849c9ff80cSmrg      func_mkdir_p "$xdir$objdir"
38851f0ac6a5Smrg
38861f0ac6a5Smrg      if test -z "$output_obj"; then
38871f0ac6a5Smrg	# Place PIC objects in $objdir
38886fae4e5dSmrg	func_append command " -o $lobj"
38891f0ac6a5Smrg      fi
38901f0ac6a5Smrg
38919c9ff80cSmrg      func_show_eval_locale "$command"	\
38929c9ff80cSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
38931f0ac6a5Smrg
3894d21ab8bcSmrg      if test warn = "$need_locks" &&
38951f0ac6a5Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
38969c9ff80cSmrg	$ECHO "\
38971f0ac6a5Smrg*** ERROR, $lockfile contains:
38981f0ac6a5Smrg`cat $lockfile 2>/dev/null`
38991f0ac6a5Smrg
39001f0ac6a5Smrgbut it should contain:
39011f0ac6a5Smrg$srcfile
39021f0ac6a5Smrg
39031f0ac6a5SmrgThis indicates that another process is trying to use the same
39041f0ac6a5Smrgtemporary object file, and libtool could not work around it because
3905d21ab8bcSmrgyour compiler does not support '-c' and '-o' together.  If you
39061f0ac6a5Smrgrepeat this compilation, it may succeed, by chance, but you had better
39071f0ac6a5Smrgavoid parallel builds (make -j) in this platform, or get a better
39081f0ac6a5Smrgcompiler."
39091f0ac6a5Smrg
39109c9ff80cSmrg	$opt_dry_run || $RM $removelist
39111f0ac6a5Smrg	exit $EXIT_FAILURE
39121f0ac6a5Smrg      fi
39131f0ac6a5Smrg
39141f0ac6a5Smrg      # Just move the object if needed, then go on to compile the next one
39151f0ac6a5Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
39169c9ff80cSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
39179c9ff80cSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
39181f0ac6a5Smrg      fi
39191f0ac6a5Smrg
39201f0ac6a5Smrg      # Allow error messages only from the first compilation.
3921d21ab8bcSmrg      if test yes = "$suppress_opt"; then
39229c9ff80cSmrg	suppress_output=' >/dev/null 2>&1'
39231f0ac6a5Smrg      fi
39241f0ac6a5Smrg    fi
39251f0ac6a5Smrg
39261f0ac6a5Smrg    # Only build a position-dependent object if we build old libraries.
3927d21ab8bcSmrg    if test yes = "$build_old_libs"; then
3928d21ab8bcSmrg      if test yes != "$pic_mode"; then
39291f0ac6a5Smrg	# Don't build PIC code
39309c9ff80cSmrg	command="$base_compile $qsrcfile$pie_flag"
39311f0ac6a5Smrg      else
39321f0ac6a5Smrg	command="$base_compile $qsrcfile $pic_flag"
39331f0ac6a5Smrg      fi
3934d21ab8bcSmrg      if test yes = "$compiler_c_o"; then
39356fae4e5dSmrg	func_append command " -o $obj"
39361f0ac6a5Smrg      fi
39371f0ac6a5Smrg
39381f0ac6a5Smrg      # Suppress compiler output if we already did a PIC compilation.
39396fae4e5dSmrg      func_append command "$suppress_output"
39409c9ff80cSmrg      func_show_eval_locale "$command" \
39419c9ff80cSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
39421f0ac6a5Smrg
3943d21ab8bcSmrg      if test warn = "$need_locks" &&
39441f0ac6a5Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
39459c9ff80cSmrg	$ECHO "\
39461f0ac6a5Smrg*** ERROR, $lockfile contains:
39471f0ac6a5Smrg`cat $lockfile 2>/dev/null`
39481f0ac6a5Smrg
39491f0ac6a5Smrgbut it should contain:
39501f0ac6a5Smrg$srcfile
39511f0ac6a5Smrg
39521f0ac6a5SmrgThis indicates that another process is trying to use the same
39531f0ac6a5Smrgtemporary object file, and libtool could not work around it because
3954d21ab8bcSmrgyour compiler does not support '-c' and '-o' together.  If you
39551f0ac6a5Smrgrepeat this compilation, it may succeed, by chance, but you had better
39561f0ac6a5Smrgavoid parallel builds (make -j) in this platform, or get a better
39571f0ac6a5Smrgcompiler."
39581f0ac6a5Smrg
39599c9ff80cSmrg	$opt_dry_run || $RM $removelist
39601f0ac6a5Smrg	exit $EXIT_FAILURE
39611f0ac6a5Smrg      fi
39621f0ac6a5Smrg
39631f0ac6a5Smrg      # Just move the object if needed
39641f0ac6a5Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
39659c9ff80cSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
39669c9ff80cSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
39671f0ac6a5Smrg      fi
39681f0ac6a5Smrg    fi
39691f0ac6a5Smrg
39709c9ff80cSmrg    $opt_dry_run || {
39719c9ff80cSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
39721f0ac6a5Smrg
39739c9ff80cSmrg      # Unlock the critical section if it was locked
3974d21ab8bcSmrg      if test no != "$need_locks"; then
39759c9ff80cSmrg	removelist=$lockfile
39769c9ff80cSmrg        $RM "$lockfile"
39779c9ff80cSmrg      fi
39789c9ff80cSmrg    }
39791f0ac6a5Smrg
39801f0ac6a5Smrg    exit $EXIT_SUCCESS
39819c9ff80cSmrg}
39821f0ac6a5Smrg
39839c9ff80cSmrg$opt_help || {
3984d21ab8bcSmrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
39859c9ff80cSmrg}
39861f0ac6a5Smrg
39879c9ff80cSmrgfunc_mode_help ()
39889c9ff80cSmrg{
39899c9ff80cSmrg    # We need to display help for each of the modes.
39906fae4e5dSmrg    case $opt_mode in
39919c9ff80cSmrg      "")
39929c9ff80cSmrg        # Generic help is extracted from the usage comments
39939c9ff80cSmrg        # at the start of this file.
39949c9ff80cSmrg        func_help
39959c9ff80cSmrg        ;;
39961f0ac6a5Smrg
39979c9ff80cSmrg      clean)
39989c9ff80cSmrg        $ECHO \
39999c9ff80cSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
40001f0ac6a5Smrg
40019c9ff80cSmrgRemove files from the build directory.
40021f0ac6a5Smrg
40039c9ff80cSmrgRM is the name of the program to use to delete files associated with each FILE
4004d21ab8bcSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
40059c9ff80cSmrgto RM.
40061f0ac6a5Smrg
40079c9ff80cSmrgIf FILE is a libtool library, object or program, all the files associated
40089c9ff80cSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
40099c9ff80cSmrg        ;;
40101f0ac6a5Smrg
40119c9ff80cSmrg      compile)
40129c9ff80cSmrg      $ECHO \
40139c9ff80cSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
40141f0ac6a5Smrg
40159c9ff80cSmrgCompile a source file into a libtool library object.
40161f0ac6a5Smrg
40179c9ff80cSmrgThis mode accepts the following additional options:
40181f0ac6a5Smrg
40199c9ff80cSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
40209c9ff80cSmrg  -no-suppress      do not suppress compiler output for multiple passes
40216fae4e5dSmrg  -prefer-pic       try to build PIC objects only
40226fae4e5dSmrg  -prefer-non-pic   try to build non-PIC objects only
4023d21ab8bcSmrg  -shared           do not build a '.o' file suitable for static linking
4024d21ab8bcSmrg  -static           only build a '.o' file suitable for static linking
4025d21ab8bcSmrg  -Wc,FLAG
4026d21ab8bcSmrg  -Xcompiler FLAG   pass FLAG directly to the compiler
40271f0ac6a5Smrg
4028d21ab8bcSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
40299c9ff80cSmrgfrom the given SOURCEFILE.
40301f0ac6a5Smrg
40319c9ff80cSmrgThe output file name is determined by removing the directory component from
4032d21ab8bcSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
4033d21ab8bcSmrglibrary object suffix, '.lo'."
40349c9ff80cSmrg        ;;
40351f0ac6a5Smrg
40369c9ff80cSmrg      execute)
40379c9ff80cSmrg        $ECHO \
40389c9ff80cSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
40391f0ac6a5Smrg
40409c9ff80cSmrgAutomatically set library path, then run a program.
40411f0ac6a5Smrg
40429c9ff80cSmrgThis mode accepts the following additional options:
40431f0ac6a5Smrg
40449c9ff80cSmrg  -dlopen FILE      add the directory containing FILE to the library path
40451f0ac6a5Smrg
4046d21ab8bcSmrgThis mode sets the library path environment variable according to '-dlopen'
40479c9ff80cSmrgflags.
40481f0ac6a5Smrg
40499c9ff80cSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
40509c9ff80cSmrginto their corresponding uninstalled binary, and any of their required library
40519c9ff80cSmrgdirectories are added to the library path.
40521f0ac6a5Smrg
40539c9ff80cSmrgThen, COMMAND is executed, with ARGS as arguments."
40549c9ff80cSmrg        ;;
40551f0ac6a5Smrg
40569c9ff80cSmrg      finish)
40579c9ff80cSmrg        $ECHO \
40589c9ff80cSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
40591f0ac6a5Smrg
40609c9ff80cSmrgComplete the installation of libtool libraries.
40611f0ac6a5Smrg
40629c9ff80cSmrgEach LIBDIR is a directory that contains libtool libraries.
40631f0ac6a5Smrg
40649c9ff80cSmrgThe commands that this mode executes may require superuser privileges.  Use
4065d21ab8bcSmrgthe '--dry-run' option if you just want to see what would be executed."
40669c9ff80cSmrg        ;;
40671f0ac6a5Smrg
40689c9ff80cSmrg      install)
40699c9ff80cSmrg        $ECHO \
40709c9ff80cSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
40711f0ac6a5Smrg
40729c9ff80cSmrgInstall executables or libraries.
40731f0ac6a5Smrg
40749c9ff80cSmrgINSTALL-COMMAND is the installation command.  The first component should be
4075d21ab8bcSmrgeither the 'install' or 'cp' program.
40761f0ac6a5Smrg
40779c9ff80cSmrgThe following components of INSTALL-COMMAND are treated specially:
40781f0ac6a5Smrg
40796fae4e5dSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
40801f0ac6a5Smrg
40819c9ff80cSmrgThe rest of the components are interpreted as arguments to that command (only
40829c9ff80cSmrgBSD-compatible install options are recognized)."
40839c9ff80cSmrg        ;;
40841f0ac6a5Smrg
40859c9ff80cSmrg      link)
40869c9ff80cSmrg        $ECHO \
40879c9ff80cSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
40881f0ac6a5Smrg
40899c9ff80cSmrgLink object files or libraries together to form another library, or to
40909c9ff80cSmrgcreate an executable program.
40911f0ac6a5Smrg
40929c9ff80cSmrgLINK-COMMAND is a command using the C compiler that you would use to create
40939c9ff80cSmrga program from several object files.
40941f0ac6a5Smrg
40959c9ff80cSmrgThe following components of LINK-COMMAND are treated specially:
40961f0ac6a5Smrg
40979c9ff80cSmrg  -all-static       do not do any dynamic linking at all
40989c9ff80cSmrg  -avoid-version    do not add a version suffix if possible
40996fae4e5dSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
41006fae4e5dSmrg                    libraries must be found in the PATH setting at runtime)
4101d21ab8bcSmrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
41029c9ff80cSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
41039c9ff80cSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
41049c9ff80cSmrg  -export-symbols SYMFILE
41059c9ff80cSmrg                    try to export only the symbols listed in SYMFILE
41069c9ff80cSmrg  -export-symbols-regex REGEX
41079c9ff80cSmrg                    try to export only the symbols matching REGEX
41089c9ff80cSmrg  -LLIBDIR          search LIBDIR for required installed libraries
41099c9ff80cSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
41109c9ff80cSmrg  -module           build a library that can dlopened
41119c9ff80cSmrg  -no-fast-install  disable the fast-install mode
41129c9ff80cSmrg  -no-install       link a not-installable executable
41139c9ff80cSmrg  -no-undefined     declare that a library does not refer to external symbols
41149c9ff80cSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
4115d21ab8bcSmrg  -objectlist FILE  use a list of object files found in FILE to specify objects
4116d21ab8bcSmrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
41179c9ff80cSmrg  -precious-files-regex REGEX
41189c9ff80cSmrg                    don't remove output files matching REGEX
41199c9ff80cSmrg  -release RELEASE  specify package release information
41209c9ff80cSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
41219c9ff80cSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
41229c9ff80cSmrg  -shared           only do dynamic linking of libtool libraries
41239c9ff80cSmrg  -shrext SUFFIX    override the standard shared library file extension
41249c9ff80cSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
41259c9ff80cSmrg  -static-libtool-libs
41269c9ff80cSmrg                    do not do any dynamic linking of libtool libraries
41279c9ff80cSmrg  -version-info CURRENT[:REVISION[:AGE]]
41289c9ff80cSmrg                    specify library version info [each variable defaults to 0]
41299c9ff80cSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
41306fae4e5dSmrg  -Wc,FLAG
41316fae4e5dSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
4132d21ab8bcSmrg  -Wa,FLAG
4133d21ab8bcSmrg  -Xassembler FLAG  pass linker-specific FLAG directly to the assembler
41346fae4e5dSmrg  -Wl,FLAG
41356fae4e5dSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
41366fae4e5dSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
41371f0ac6a5Smrg
4138d21ab8bcSmrgAll other options (arguments beginning with '-') are ignored.
4139e5410a46Smrg
4140d21ab8bcSmrgEvery other argument is treated as a filename.  Files ending in '.la' are
41419c9ff80cSmrgtreated as uninstalled libtool libraries, other files are standard or library
41429c9ff80cSmrgobject files.
41431f0ac6a5Smrg
4144d21ab8bcSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
4145d21ab8bcSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is
41469c9ff80cSmrgrequired, except when creating a convenience library.
41471f0ac6a5Smrg
4148d21ab8bcSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
4149d21ab8bcSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
41501f0ac6a5Smrg
4151d21ab8bcSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
41529c9ff80cSmrgis created, otherwise an executable program is created."
41531f0ac6a5Smrg        ;;
41541f0ac6a5Smrg
41559c9ff80cSmrg      uninstall)
41569c9ff80cSmrg        $ECHO \
41579c9ff80cSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
41581f0ac6a5Smrg
41599c9ff80cSmrgRemove libraries from an installation directory.
41601f0ac6a5Smrg
41619c9ff80cSmrgRM is the name of the program to use to delete files associated with each FILE
4162d21ab8bcSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
41639c9ff80cSmrgto RM.
41641f0ac6a5Smrg
41659c9ff80cSmrgIf FILE is a libtool library, all the files associated with it are deleted.
41669c9ff80cSmrgOtherwise, only FILE itself is deleted using RM."
41679c9ff80cSmrg        ;;
41681f0ac6a5Smrg
41699c9ff80cSmrg      *)
4170d21ab8bcSmrg        func_fatal_help "invalid operation mode '$opt_mode'"
41719c9ff80cSmrg        ;;
41729c9ff80cSmrg    esac
41731f0ac6a5Smrg
41746fae4e5dSmrg    echo
4175d21ab8bcSmrg    $ECHO "Try '$progname --help' for more information about other modes."
41769c9ff80cSmrg}
41771f0ac6a5Smrg
41786fae4e5dSmrg# Now that we've collected a possible --mode arg, show help if necessary
41796fae4e5dSmrgif $opt_help; then
4180d21ab8bcSmrg  if test : = "$opt_help"; then
41816fae4e5dSmrg    func_mode_help
41826fae4e5dSmrg  else
41836fae4e5dSmrg    {
41846fae4e5dSmrg      func_help noexit
41856fae4e5dSmrg      for opt_mode in compile link execute install finish uninstall clean; do
41866fae4e5dSmrg	func_mode_help
41876fae4e5dSmrg      done
4188d21ab8bcSmrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
41896fae4e5dSmrg    {
41906fae4e5dSmrg      func_help noexit
41916fae4e5dSmrg      for opt_mode in compile link execute install finish uninstall clean; do
41926fae4e5dSmrg	echo
41936fae4e5dSmrg	func_mode_help
41946fae4e5dSmrg      done
41956fae4e5dSmrg    } |
4196d21ab8bcSmrg    $SED '1d
41976fae4e5dSmrg      /^When reporting/,/^Report/{
41986fae4e5dSmrg	H
41996fae4e5dSmrg	d
42006fae4e5dSmrg      }
42016fae4e5dSmrg      $x
42026fae4e5dSmrg      /information about other modes/d
42036fae4e5dSmrg      /more detailed .*MODE/d
42046fae4e5dSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
42056fae4e5dSmrg  fi
42066fae4e5dSmrg  exit $?
42076fae4e5dSmrgfi
42081f0ac6a5Smrg
42091f0ac6a5Smrg
42106ee7d557Smrg# If option '--reorder-cache', reorder the shared library cache and exit.
42116ee7d557Smrgif $opt_reorder_cache; then
42126ee7d557Smrg    func_reorder_shared_lib_cache $shared_lib_dirs
42136ee7d557Smrgfi
42146ee7d557Smrg
42156ee7d557Smrg
42169c9ff80cSmrg# func_mode_execute arg...
42179c9ff80cSmrgfunc_mode_execute ()
42189c9ff80cSmrg{
4219d21ab8bcSmrg    $debug_cmd
4220d21ab8bcSmrg
42219c9ff80cSmrg    # The first argument is the command name.
4222d21ab8bcSmrg    cmd=$nonopt
42239c9ff80cSmrg    test -z "$cmd" && \
42249c9ff80cSmrg      func_fatal_help "you must specify a COMMAND"
42251f0ac6a5Smrg
42269c9ff80cSmrg    # Handle -dlopen flags immediately.
42276fae4e5dSmrg    for file in $opt_dlopen; do
42289c9ff80cSmrg      test -f "$file" \
4229d21ab8bcSmrg	|| func_fatal_help "'$file' is not a file"
42301f0ac6a5Smrg
42319c9ff80cSmrg      dir=
42329c9ff80cSmrg      case $file in
42339c9ff80cSmrg      *.la)
42346fae4e5dSmrg	func_resolve_sysroot "$file"
42356fae4e5dSmrg	file=$func_resolve_sysroot_result
42366fae4e5dSmrg
42379c9ff80cSmrg	# Check to see that this really is a libtool archive.
42389c9ff80cSmrg	func_lalib_unsafe_p "$file" \
4239d21ab8bcSmrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
42401f0ac6a5Smrg
42419c9ff80cSmrg	# Read the libtool library.
42429c9ff80cSmrg	dlname=
42439c9ff80cSmrg	library_names=
42449c9ff80cSmrg	func_source "$file"
42451f0ac6a5Smrg
42469c9ff80cSmrg	# Skip this library if it cannot be dlopened.
42479c9ff80cSmrg	if test -z "$dlname"; then
42489c9ff80cSmrg	  # Warn if it was a shared library.
42499c9ff80cSmrg	  test -n "$library_names" && \
4250d21ab8bcSmrg	    func_warning "'$file' was not linked with '-export-dynamic'"
42519c9ff80cSmrg	  continue
42529c9ff80cSmrg	fi
42531f0ac6a5Smrg
42549c9ff80cSmrg	func_dirname "$file" "" "."
4255d21ab8bcSmrg	dir=$func_dirname_result
42561f0ac6a5Smrg
42579c9ff80cSmrg	if test -f "$dir/$objdir/$dlname"; then
42586fae4e5dSmrg	  func_append dir "/$objdir"
42599c9ff80cSmrg	else
42609c9ff80cSmrg	  if test ! -f "$dir/$dlname"; then
4261d21ab8bcSmrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
42629c9ff80cSmrg	  fi
42639c9ff80cSmrg	fi
42641f0ac6a5Smrg	;;
42651f0ac6a5Smrg
42669c9ff80cSmrg      *.lo)
42679c9ff80cSmrg	# Just add the directory containing the .lo file.
42689c9ff80cSmrg	func_dirname "$file" "" "."
4269d21ab8bcSmrg	dir=$func_dirname_result
42701f0ac6a5Smrg	;;
42711f0ac6a5Smrg
42729c9ff80cSmrg      *)
4273d21ab8bcSmrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
42741f0ac6a5Smrg	continue
42751f0ac6a5Smrg	;;
42769c9ff80cSmrg      esac
42771f0ac6a5Smrg
42789c9ff80cSmrg      # Get the absolute pathname.
42799c9ff80cSmrg      absdir=`cd "$dir" && pwd`
4280d21ab8bcSmrg      test -n "$absdir" && dir=$absdir
42811f0ac6a5Smrg
42829c9ff80cSmrg      # Now add the directory to shlibpath_var.
42839c9ff80cSmrg      if eval "test -z \"\$$shlibpath_var\""; then
42849c9ff80cSmrg	eval "$shlibpath_var=\"\$dir\""
42859c9ff80cSmrg      else
42869c9ff80cSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
42879c9ff80cSmrg      fi
42889c9ff80cSmrg    done
42891f0ac6a5Smrg
42909c9ff80cSmrg    # This variable tells wrapper scripts just to set shlibpath_var
42919c9ff80cSmrg    # rather than running their programs.
4292d21ab8bcSmrg    libtool_execute_magic=$magic
42931f0ac6a5Smrg
42949c9ff80cSmrg    # Check if any of the arguments is a wrapper script.
42959c9ff80cSmrg    args=
42969c9ff80cSmrg    for file
42979c9ff80cSmrg    do
42989c9ff80cSmrg      case $file in
42996fae4e5dSmrg      -* | *.la | *.lo ) ;;
43009c9ff80cSmrg      *)
43019c9ff80cSmrg	# Do a test to see if this is really a libtool program.
43029c9ff80cSmrg	if func_ltwrapper_script_p "$file"; then
43039c9ff80cSmrg	  func_source "$file"
43049c9ff80cSmrg	  # Transform arg to wrapped name.
4305d21ab8bcSmrg	  file=$progdir/$program
43069c9ff80cSmrg	elif func_ltwrapper_executable_p "$file"; then
43079c9ff80cSmrg	  func_ltwrapper_scriptname "$file"
43089c9ff80cSmrg	  func_source "$func_ltwrapper_scriptname_result"
43099c9ff80cSmrg	  # Transform arg to wrapped name.
4310d21ab8bcSmrg	  file=$progdir/$program
43119c9ff80cSmrg	fi
43129c9ff80cSmrg	;;
43139c9ff80cSmrg      esac
43149c9ff80cSmrg      # Quote arguments (to preserve shell metacharacters).
43156fae4e5dSmrg      func_append_quoted args "$file"
43169c9ff80cSmrg    done
43171f0ac6a5Smrg
4318d21ab8bcSmrg    if $opt_dry_run; then
4319d21ab8bcSmrg      # Display what would be done.
4320d21ab8bcSmrg      if test -n "$shlibpath_var"; then
4321d21ab8bcSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
4322d21ab8bcSmrg	echo "export $shlibpath_var"
4323d21ab8bcSmrg      fi
4324d21ab8bcSmrg      $ECHO "$cmd$args"
4325d21ab8bcSmrg      exit $EXIT_SUCCESS
4326d21ab8bcSmrg    else
43279c9ff80cSmrg      if test -n "$shlibpath_var"; then
43289c9ff80cSmrg	# Export the shlibpath_var.
43299c9ff80cSmrg	eval "export $shlibpath_var"
43309c9ff80cSmrg      fi
43311f0ac6a5Smrg
43329c9ff80cSmrg      # Restore saved environment variables
43339c9ff80cSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
43349c9ff80cSmrg      do
43359c9ff80cSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
43369c9ff80cSmrg                $lt_var=\$save_$lt_var; export $lt_var
43371f0ac6a5Smrg	      else
43389c9ff80cSmrg		$lt_unset $lt_var
43399c9ff80cSmrg	      fi"
43409c9ff80cSmrg      done
43411f0ac6a5Smrg
43429c9ff80cSmrg      # Now prepare to actually exec the command.
4343d21ab8bcSmrg      exec_cmd=\$cmd$args
43449c9ff80cSmrg    fi
43459c9ff80cSmrg}
43461f0ac6a5Smrg
4347d21ab8bcSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
43486fae4e5dSmrg
43496fae4e5dSmrg
43506fae4e5dSmrg# func_mode_finish arg...
43516fae4e5dSmrgfunc_mode_finish ()
43526fae4e5dSmrg{
4353d21ab8bcSmrg    $debug_cmd
4354d21ab8bcSmrg
43556fae4e5dSmrg    libs=
43566fae4e5dSmrg    libdirs=
43576fae4e5dSmrg    admincmds=
43586fae4e5dSmrg
43596fae4e5dSmrg    for opt in "$nonopt" ${1+"$@"}
43606fae4e5dSmrg    do
43616fae4e5dSmrg      if test -d "$opt"; then
43626fae4e5dSmrg	func_append libdirs " $opt"
43636fae4e5dSmrg
43646fae4e5dSmrg      elif test -f "$opt"; then
43656fae4e5dSmrg	if func_lalib_unsafe_p "$opt"; then
43666fae4e5dSmrg	  func_append libs " $opt"
43676fae4e5dSmrg	else
4368d21ab8bcSmrg	  func_warning "'$opt' is not a valid libtool archive"
43696fae4e5dSmrg	fi
43706fae4e5dSmrg
43716fae4e5dSmrg      else
4372d21ab8bcSmrg	func_fatal_error "invalid argument '$opt'"
43736fae4e5dSmrg      fi
43746fae4e5dSmrg    done
43751f0ac6a5Smrg
43766fae4e5dSmrg    if test -n "$libs"; then
43776fae4e5dSmrg      if test -n "$lt_sysroot"; then
43786fae4e5dSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
43796fae4e5dSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
43806fae4e5dSmrg      else
43816fae4e5dSmrg        sysroot_cmd=
43826fae4e5dSmrg      fi
43831f0ac6a5Smrg
43846fae4e5dSmrg      # Remove sysroot references
43856fae4e5dSmrg      if $opt_dry_run; then
43866fae4e5dSmrg        for lib in $libs; do
4387d21ab8bcSmrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
43886fae4e5dSmrg        done
43896fae4e5dSmrg      else
43906fae4e5dSmrg        tmpdir=`func_mktempdir`
43916fae4e5dSmrg        for lib in $libs; do
4392d21ab8bcSmrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
43936fae4e5dSmrg	    > $tmpdir/tmp-la
43946fae4e5dSmrg	  mv -f $tmpdir/tmp-la $lib
43956fae4e5dSmrg	done
43966fae4e5dSmrg        ${RM}r "$tmpdir"
43976fae4e5dSmrg      fi
43986fae4e5dSmrg    fi
43991f0ac6a5Smrg
44006ee7d557Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs" && $opt_finishing; then
44019c9ff80cSmrg      for libdir in $libdirs; do
44029c9ff80cSmrg	if test -n "$finish_cmds"; then
44039c9ff80cSmrg	  # Do each command in the finish commands.
44049c9ff80cSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
44059c9ff80cSmrg'"$cmd"'"'
44061f0ac6a5Smrg	fi
44079c9ff80cSmrg	if test -n "$finish_eval"; then
44089c9ff80cSmrg	  # Do the single finish_eval.
44099c9ff80cSmrg	  eval cmds=\"$finish_eval\"
44106fae4e5dSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
44119c9ff80cSmrg       $cmds"
44129c9ff80cSmrg	fi
44139c9ff80cSmrg      done
44149c9ff80cSmrg    fi
44151f0ac6a5Smrg
44169c9ff80cSmrg    # Exit here if they wanted silent mode.
4417d21ab8bcSmrg    $opt_quiet && exit $EXIT_SUCCESS
44181f0ac6a5Smrg
44196fae4e5dSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
44206fae4e5dSmrg      echo "----------------------------------------------------------------------"
44216fae4e5dSmrg      echo "Libraries have been installed in:"
44226fae4e5dSmrg      for libdir in $libdirs; do
44236fae4e5dSmrg	$ECHO "   $libdir"
44246fae4e5dSmrg      done
44256ee7d557Smrg      if test "false" = "$opt_finishing"; then
44266ee7d557Smrg        echo
44276ee7d557Smrg        echo "NOTE: finish_cmds were not executed during testing, so you must"
44286ee7d557Smrg        echo "manually run ldconfig to add a given test directory, LIBDIR, to"
44296ee7d557Smrg        echo "the search path for generated executables."
44306ee7d557Smrg      fi
44316fae4e5dSmrg      echo
44326fae4e5dSmrg      echo "If you ever happen to want to link against installed libraries"
44336fae4e5dSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
4434d21ab8bcSmrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
44356fae4e5dSmrg      echo "flag during linking and do at least one of the following:"
44366fae4e5dSmrg      if test -n "$shlibpath_var"; then
4437d21ab8bcSmrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
44386fae4e5dSmrg	echo "     during execution"
44396fae4e5dSmrg      fi
44406fae4e5dSmrg      if test -n "$runpath_var"; then
4441d21ab8bcSmrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
44426fae4e5dSmrg	echo "     during linking"
44436fae4e5dSmrg      fi
44446fae4e5dSmrg      if test -n "$hardcode_libdir_flag_spec"; then
44456fae4e5dSmrg	libdir=LIBDIR
44466fae4e5dSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
44479c9ff80cSmrg
4448d21ab8bcSmrg	$ECHO "   - use the '$flag' linker flag"
44496fae4e5dSmrg      fi
44506fae4e5dSmrg      if test -n "$admincmds"; then
44516fae4e5dSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
44526fae4e5dSmrg      fi
44536fae4e5dSmrg      if test -f /etc/ld.so.conf; then
4454d21ab8bcSmrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
44556fae4e5dSmrg      fi
44566fae4e5dSmrg      echo
44579c9ff80cSmrg
44586fae4e5dSmrg      echo "See any operating system documentation about shared libraries for"
44596fae4e5dSmrg      case $host in
44606fae4e5dSmrg	solaris2.[6789]|solaris2.1[0-9])
44616fae4e5dSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
44626fae4e5dSmrg	  echo "pages."
44636fae4e5dSmrg	  ;;
44646fae4e5dSmrg	*)
44656fae4e5dSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
44666fae4e5dSmrg	  ;;
44676fae4e5dSmrg      esac
44686fae4e5dSmrg      echo "----------------------------------------------------------------------"
44696fae4e5dSmrg    fi
44709c9ff80cSmrg    exit $EXIT_SUCCESS
44719c9ff80cSmrg}
44729c9ff80cSmrg
4473d21ab8bcSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
44749c9ff80cSmrg
44759c9ff80cSmrg
44769c9ff80cSmrg# func_mode_install arg...
44779c9ff80cSmrgfunc_mode_install ()
44789c9ff80cSmrg{
4479d21ab8bcSmrg    $debug_cmd
4480d21ab8bcSmrg
44819c9ff80cSmrg    # There may be an optional sh(1) argument at the beginning of
44829c9ff80cSmrg    # install_prog (especially on Windows NT).
4483d21ab8bcSmrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
44849c9ff80cSmrg       # Allow the use of GNU shtool's install command.
4485d21ab8bcSmrg       case $nonopt in *shtool*) :;; *) false;; esac
4486d21ab8bcSmrg    then
44879c9ff80cSmrg      # Aesthetically quote it.
4488d21ab8bcSmrg      func_quote_arg pretty "$nonopt"
4489d21ab8bcSmrg      install_prog="$func_quote_arg_result "
44909c9ff80cSmrg      arg=$1
44919c9ff80cSmrg      shift
44929c9ff80cSmrg    else
44939c9ff80cSmrg      install_prog=
44949c9ff80cSmrg      arg=$nonopt
44959c9ff80cSmrg    fi
44969c9ff80cSmrg
44979c9ff80cSmrg    # The real first argument should be the name of the installation program.
44989c9ff80cSmrg    # Aesthetically quote it.
4499d21ab8bcSmrg    func_quote_arg pretty "$arg"
4500d21ab8bcSmrg    func_append install_prog "$func_quote_arg_result"
45016fae4e5dSmrg    install_shared_prog=$install_prog
45026fae4e5dSmrg    case " $install_prog " in
45036fae4e5dSmrg      *[\\\ /]cp\ *) install_cp=: ;;
45046fae4e5dSmrg      *) install_cp=false ;;
45056fae4e5dSmrg    esac
45069c9ff80cSmrg
45079c9ff80cSmrg    # We need to accept at least all the BSD install flags.
45089c9ff80cSmrg    dest=
45099c9ff80cSmrg    files=
45109c9ff80cSmrg    opts=
45119c9ff80cSmrg    prev=
45129c9ff80cSmrg    install_type=
4513d21ab8bcSmrg    isdir=false
45149c9ff80cSmrg    stripme=
45156fae4e5dSmrg    no_mode=:
45169c9ff80cSmrg    for arg
45179c9ff80cSmrg    do
45186fae4e5dSmrg      arg2=
45199c9ff80cSmrg      if test -n "$dest"; then
45206fae4e5dSmrg	func_append files " $dest"
45219c9ff80cSmrg	dest=$arg
45229c9ff80cSmrg	continue
45239c9ff80cSmrg      fi
45249c9ff80cSmrg
45259c9ff80cSmrg      case $arg in
4526d21ab8bcSmrg      -d) isdir=: ;;
45279c9ff80cSmrg      -f)
45286fae4e5dSmrg	if $install_cp; then :; else
45296fae4e5dSmrg	  prev=$arg
45306fae4e5dSmrg	fi
45319c9ff80cSmrg	;;
45329c9ff80cSmrg      -g | -m | -o)
45339c9ff80cSmrg	prev=$arg
45349c9ff80cSmrg	;;
45359c9ff80cSmrg      -s)
45369c9ff80cSmrg	stripme=" -s"
45379c9ff80cSmrg	continue
45389c9ff80cSmrg	;;
45399c9ff80cSmrg      -*)
45409c9ff80cSmrg	;;
45419c9ff80cSmrg      *)
45429c9ff80cSmrg	# If the previous option needed an argument, then skip it.
45439c9ff80cSmrg	if test -n "$prev"; then
4544d21ab8bcSmrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
45456fae4e5dSmrg	    arg2=$install_override_mode
45466fae4e5dSmrg	    no_mode=false
45476fae4e5dSmrg	  fi
45481f0ac6a5Smrg	  prev=
45491f0ac6a5Smrg	else
45509c9ff80cSmrg	  dest=$arg
45519c9ff80cSmrg	  continue
45521f0ac6a5Smrg	fi
45531f0ac6a5Smrg	;;
45549c9ff80cSmrg      esac
45551f0ac6a5Smrg
45569c9ff80cSmrg      # Aesthetically quote the argument.
4557d21ab8bcSmrg      func_quote_arg pretty "$arg"
4558d21ab8bcSmrg      func_append install_prog " $func_quote_arg_result"
45596fae4e5dSmrg      if test -n "$arg2"; then
4560d21ab8bcSmrg	func_quote_arg pretty "$arg2"
45616fae4e5dSmrg      fi
4562d21ab8bcSmrg      func_append install_shared_prog " $func_quote_arg_result"
45639c9ff80cSmrg    done
45641f0ac6a5Smrg
45659c9ff80cSmrg    test -z "$install_prog" && \
45669c9ff80cSmrg      func_fatal_help "you must specify an install program"
45671f0ac6a5Smrg
45689c9ff80cSmrg    test -n "$prev" && \
4569d21ab8bcSmrg      func_fatal_help "the '$prev' option requires an argument"
45701f0ac6a5Smrg
45716fae4e5dSmrg    if test -n "$install_override_mode" && $no_mode; then
45726fae4e5dSmrg      if $install_cp; then :; else
4573d21ab8bcSmrg	func_quote_arg pretty "$install_override_mode"
4574d21ab8bcSmrg	func_append install_shared_prog " -m $func_quote_arg_result"
45756fae4e5dSmrg      fi
45766fae4e5dSmrg    fi
45776fae4e5dSmrg
45789c9ff80cSmrg    if test -z "$files"; then
45799c9ff80cSmrg      if test -z "$dest"; then
45809c9ff80cSmrg	func_fatal_help "no file or destination specified"
45819c9ff80cSmrg      else
45829c9ff80cSmrg	func_fatal_help "you must specify a destination"
45839c9ff80cSmrg      fi
45841f0ac6a5Smrg    fi
45851f0ac6a5Smrg
45869c9ff80cSmrg    # Strip any trailing slash from the destination.
45879c9ff80cSmrg    func_stripname '' '/' "$dest"
45889c9ff80cSmrg    dest=$func_stripname_result
45891f0ac6a5Smrg
45909c9ff80cSmrg    # Check to see that the destination is a directory.
4591d21ab8bcSmrg    test -d "$dest" && isdir=:
4592d21ab8bcSmrg    if $isdir; then
4593d21ab8bcSmrg      destdir=$dest
45949c9ff80cSmrg      destname=
45951f0ac6a5Smrg    else
45969c9ff80cSmrg      func_dirname_and_basename "$dest" "" "."
4597d21ab8bcSmrg      destdir=$func_dirname_result
4598d21ab8bcSmrg      destname=$func_basename_result
45991f0ac6a5Smrg
46009c9ff80cSmrg      # Not a directory, so check to see that there is only one file specified.
46019c9ff80cSmrg      set dummy $files; shift
46029c9ff80cSmrg      test "$#" -gt 1 && \
4603d21ab8bcSmrg	func_fatal_help "'$dest' is not a directory"
46041f0ac6a5Smrg    fi
46059c9ff80cSmrg    case $destdir in
46069c9ff80cSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
46071f0ac6a5Smrg    *)
46089c9ff80cSmrg      for file in $files; do
46099c9ff80cSmrg	case $file in
46109c9ff80cSmrg	*.lo) ;;
46119c9ff80cSmrg	*)
4612d21ab8bcSmrg	  func_fatal_help "'$destdir' must be an absolute directory name"
46139c9ff80cSmrg	  ;;
46149c9ff80cSmrg	esac
46159c9ff80cSmrg      done
46161f0ac6a5Smrg      ;;
46171f0ac6a5Smrg    esac
46181f0ac6a5Smrg
46199c9ff80cSmrg    # This variable tells wrapper scripts just to set variables rather
46209c9ff80cSmrg    # than running their programs.
4621d21ab8bcSmrg    libtool_install_magic=$magic
46221f0ac6a5Smrg
46239c9ff80cSmrg    staticlibs=
46249c9ff80cSmrg    future_libdirs=
46259c9ff80cSmrg    current_libdirs=
46269c9ff80cSmrg    for file in $files; do
46271f0ac6a5Smrg
46289c9ff80cSmrg      # Do each installation.
46299c9ff80cSmrg      case $file in
46309c9ff80cSmrg      *.$libext)
46319c9ff80cSmrg	# Do the static libraries later.
46326fae4e5dSmrg	func_append staticlibs " $file"
46339c9ff80cSmrg	;;
46349c9ff80cSmrg
46359c9ff80cSmrg      *.la)
46366fae4e5dSmrg	func_resolve_sysroot "$file"
46376fae4e5dSmrg	file=$func_resolve_sysroot_result
46386fae4e5dSmrg
46399c9ff80cSmrg	# Check to see that this really is a libtool archive.
46409c9ff80cSmrg	func_lalib_unsafe_p "$file" \
4641d21ab8bcSmrg	  || func_fatal_help "'$file' is not a valid libtool archive"
46429c9ff80cSmrg
46439c9ff80cSmrg	library_names=
46449c9ff80cSmrg	old_library=
46459c9ff80cSmrg	relink_command=
46469c9ff80cSmrg	func_source "$file"
46479c9ff80cSmrg
46489c9ff80cSmrg	# Add the libdir to current_libdirs if it is the destination.
46499c9ff80cSmrg	if test "X$destdir" = "X$libdir"; then
46509c9ff80cSmrg	  case "$current_libdirs " in
46519c9ff80cSmrg	  *" $libdir "*) ;;
46526fae4e5dSmrg	  *) func_append current_libdirs " $libdir" ;;
46531f0ac6a5Smrg	  esac
46549c9ff80cSmrg	else
46559c9ff80cSmrg	  # Note the libdir as a future libdir.
46569c9ff80cSmrg	  case "$future_libdirs " in
46579c9ff80cSmrg	  *" $libdir "*) ;;
46586fae4e5dSmrg	  *) func_append future_libdirs " $libdir" ;;
46599c9ff80cSmrg	  esac
46609c9ff80cSmrg	fi
46611f0ac6a5Smrg
46629c9ff80cSmrg	func_dirname "$file" "/" ""
4663d21ab8bcSmrg	dir=$func_dirname_result
46646fae4e5dSmrg	func_append dir "$objdir"
46659c9ff80cSmrg
46669c9ff80cSmrg	if test -n "$relink_command"; then
46676ee7d557Smrg	  # Strip any trailing slash from the destination.
46686ee7d557Smrg	  func_stripname '' '/' "$libdir"
46696ee7d557Smrg	  destlibdir=$func_stripname_result
46706ee7d557Smrg
46716ee7d557Smrg	  func_stripname '' '/' "$destdir"
46726ee7d557Smrg	  s_destdir=$func_stripname_result
46736ee7d557Smrg
46749c9ff80cSmrg	  # Determine the prefix the user has applied to our future dir.
46756ee7d557Smrg	  inst_prefix_dir=`$ECHO "X$s_destdir" | $Xsed -e "s%$destlibdir\$%%"`
46769c9ff80cSmrg
46779c9ff80cSmrg	  # Don't allow the user to place us outside of our expected
46789c9ff80cSmrg	  # location b/c this prevents finding dependent libraries that
46799c9ff80cSmrg	  # are installed to the same prefix.
46809c9ff80cSmrg	  # At present, this check doesn't affect windows .dll's that
46819c9ff80cSmrg	  # are installed into $libdir/../bin (currently, that works fine)
46829c9ff80cSmrg	  # but it's something to keep an eye on.
46839c9ff80cSmrg	  test "$inst_prefix_dir" = "$destdir" && \
4684d21ab8bcSmrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
46859c9ff80cSmrg
46869c9ff80cSmrg	  if test -n "$inst_prefix_dir"; then
46879c9ff80cSmrg	    # Stick the inst_prefix_dir data into the link command.
46886fae4e5dSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
46899c9ff80cSmrg	  else
46906fae4e5dSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
46919c9ff80cSmrg	  fi
46929c9ff80cSmrg
4693d21ab8bcSmrg	  func_warning "relinking '$file'"
46949c9ff80cSmrg	  func_show_eval "$relink_command" \
4695d21ab8bcSmrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
46969c9ff80cSmrg	fi
46979c9ff80cSmrg
46989c9ff80cSmrg	# See the names of the shared library.
46999c9ff80cSmrg	set dummy $library_names; shift
47009c9ff80cSmrg	if test -n "$1"; then
4701d21ab8bcSmrg	  realname=$1
47029c9ff80cSmrg	  shift
47039c9ff80cSmrg
4704d21ab8bcSmrg	  srcname=$realname
4705d21ab8bcSmrg	  test -n "$relink_command" && srcname=${realname}T
47069c9ff80cSmrg
47079c9ff80cSmrg	  # Install the shared library and build the symlinks.
47086fae4e5dSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
47099c9ff80cSmrg	      'exit $?'
4710d21ab8bcSmrg	  tstripme=$stripme
47119c9ff80cSmrg	  case $host_os in
47126ee7d557Smrg	  cygwin* | mingw* | windows* | pw32* | cegcc*)
47139c9ff80cSmrg	    case $realname in
47149c9ff80cSmrg	    *.dll.a)
4715d21ab8bcSmrg	      tstripme=
4716d21ab8bcSmrg	      ;;
4717d21ab8bcSmrg	    esac
4718d21ab8bcSmrg	    ;;
4719d21ab8bcSmrg	  os2*)
4720d21ab8bcSmrg	    case $realname in
4721d21ab8bcSmrg	    *_dll.a)
4722d21ab8bcSmrg	      tstripme=
47239c9ff80cSmrg	      ;;
47249c9ff80cSmrg	    esac
47251f0ac6a5Smrg	    ;;
47261f0ac6a5Smrg	  esac
47279c9ff80cSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
47289c9ff80cSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
47291f0ac6a5Smrg	  fi
47309c9ff80cSmrg
47319c9ff80cSmrg	  if test "$#" -gt 0; then
47329c9ff80cSmrg	    # Delete the old symlinks, and create new ones.
4733d21ab8bcSmrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
47349c9ff80cSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
47359c9ff80cSmrg	    # so we also need to try rm && ln -s.
47369c9ff80cSmrg	    for linkname
47379c9ff80cSmrg	    do
47389c9ff80cSmrg	      test "$linkname" != "$realname" \
47399c9ff80cSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
47401f0ac6a5Smrg	    done
47411f0ac6a5Smrg	  fi
47421f0ac6a5Smrg
47439c9ff80cSmrg	  # Do each command in the postinstall commands.
4744d21ab8bcSmrg	  lib=$destdir/$realname
47459c9ff80cSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
47461f0ac6a5Smrg	fi
47471f0ac6a5Smrg
47489c9ff80cSmrg	# Install the pseudo-library for information purposes.
47499c9ff80cSmrg	func_basename "$file"
4750d21ab8bcSmrg	name=$func_basename_result
4751d21ab8bcSmrg	instname=$dir/${name}i
47529c9ff80cSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
47531f0ac6a5Smrg
47549c9ff80cSmrg	# Maybe install the static library, too.
47556fae4e5dSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
47569c9ff80cSmrg	;;
47571f0ac6a5Smrg
47589c9ff80cSmrg      *.lo)
47599c9ff80cSmrg	# Install (i.e. copy) a libtool object.
47601f0ac6a5Smrg
47619c9ff80cSmrg	# Figure out destination file name, if it wasn't already specified.
47629c9ff80cSmrg	if test -n "$destname"; then
4763d21ab8bcSmrg	  destfile=$destdir/$destname
47649c9ff80cSmrg	else
47659c9ff80cSmrg	  func_basename "$file"
4766d21ab8bcSmrg	  destfile=$func_basename_result
4767d21ab8bcSmrg	  destfile=$destdir/$destfile
47681f0ac6a5Smrg	fi
47691f0ac6a5Smrg
47709c9ff80cSmrg	# Deduce the name of the destination old-style object file.
47719c9ff80cSmrg	case $destfile in
47729c9ff80cSmrg	*.lo)
47739c9ff80cSmrg	  func_lo2o "$destfile"
47749c9ff80cSmrg	  staticdest=$func_lo2o_result
47759c9ff80cSmrg	  ;;
47769c9ff80cSmrg	*.$objext)
4777d21ab8bcSmrg	  staticdest=$destfile
47789c9ff80cSmrg	  destfile=
47799c9ff80cSmrg	  ;;
47809c9ff80cSmrg	*)
4781d21ab8bcSmrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
47829c9ff80cSmrg	  ;;
47839c9ff80cSmrg	esac
47841f0ac6a5Smrg
47859c9ff80cSmrg	# Install the libtool object if requested.
47869c9ff80cSmrg	test -n "$destfile" && \
47879c9ff80cSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
47881f0ac6a5Smrg
47899c9ff80cSmrg	# Install the old object if enabled.
4790d21ab8bcSmrg	if test yes = "$build_old_libs"; then
47919c9ff80cSmrg	  # Deduce the name of the old-style object file.
47929c9ff80cSmrg	  func_lo2o "$file"
47939c9ff80cSmrg	  staticobj=$func_lo2o_result
47949c9ff80cSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
47951f0ac6a5Smrg	fi
47969c9ff80cSmrg	exit $EXIT_SUCCESS
47979c9ff80cSmrg	;;
47981f0ac6a5Smrg
47999c9ff80cSmrg      *)
48009c9ff80cSmrg	# Figure out destination file name, if it wasn't already specified.
48019c9ff80cSmrg	if test -n "$destname"; then
4802d21ab8bcSmrg	  destfile=$destdir/$destname
48039c9ff80cSmrg	else
48049c9ff80cSmrg	  func_basename "$file"
4805d21ab8bcSmrg	  destfile=$func_basename_result
4806d21ab8bcSmrg	  destfile=$destdir/$destfile
48079c9ff80cSmrg	fi
48081f0ac6a5Smrg
48099c9ff80cSmrg	# If the file is missing, and there is a .exe on the end, strip it
48109c9ff80cSmrg	# because it is most likely a libtool script we actually want to
48119c9ff80cSmrg	# install
4812d21ab8bcSmrg	stripped_ext=
48139c9ff80cSmrg	case $file in
48149c9ff80cSmrg	  *.exe)
48159c9ff80cSmrg	    if test ! -f "$file"; then
48169c9ff80cSmrg	      func_stripname '' '.exe' "$file"
48179c9ff80cSmrg	      file=$func_stripname_result
4818d21ab8bcSmrg	      stripped_ext=.exe
48199c9ff80cSmrg	    fi
48209c9ff80cSmrg	    ;;
48219c9ff80cSmrg	esac
48229c9ff80cSmrg
48239c9ff80cSmrg	# Do a test to see if this is really a libtool program.
48249c9ff80cSmrg	case $host in
48256ee7d557Smrg	*cygwin* | *mingw* | *windows*)
48269c9ff80cSmrg	    if func_ltwrapper_executable_p "$file"; then
48279c9ff80cSmrg	      func_ltwrapper_scriptname "$file"
48289c9ff80cSmrg	      wrapper=$func_ltwrapper_scriptname_result
48299c9ff80cSmrg	    else
48309c9ff80cSmrg	      func_stripname '' '.exe' "$file"
48319c9ff80cSmrg	      wrapper=$func_stripname_result
48329c9ff80cSmrg	    fi
48339c9ff80cSmrg	    ;;
48341f0ac6a5Smrg	*)
48359c9ff80cSmrg	    wrapper=$file
48369c9ff80cSmrg	    ;;
48379c9ff80cSmrg	esac
48389c9ff80cSmrg	if func_ltwrapper_script_p "$wrapper"; then
48399c9ff80cSmrg	  notinst_deplibs=
48409c9ff80cSmrg	  relink_command=
48419c9ff80cSmrg
48429c9ff80cSmrg	  func_source "$wrapper"
48439c9ff80cSmrg
48449c9ff80cSmrg	  # Check the variables that should have been set.
48459c9ff80cSmrg	  test -z "$generated_by_libtool_version" && \
4846d21ab8bcSmrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
48479c9ff80cSmrg
4848d21ab8bcSmrg	  finalize=:
48499c9ff80cSmrg	  for lib in $notinst_deplibs; do
48509c9ff80cSmrg	    # Check to see that each library is installed.
48519c9ff80cSmrg	    libdir=
48529c9ff80cSmrg	    if test -f "$lib"; then
48539c9ff80cSmrg	      func_source "$lib"
48549c9ff80cSmrg	    fi
4855d21ab8bcSmrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
48569c9ff80cSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
4857d21ab8bcSmrg	      func_warning "'$lib' has not been installed in '$libdir'"
4858d21ab8bcSmrg	      finalize=false
48599c9ff80cSmrg	    fi
48609c9ff80cSmrg	  done
48619c9ff80cSmrg
48629c9ff80cSmrg	  relink_command=
48639c9ff80cSmrg	  func_source "$wrapper"
48649c9ff80cSmrg
48659c9ff80cSmrg	  outputname=
4866d21ab8bcSmrg	  if test no = "$fast_install" && test -n "$relink_command"; then
48679c9ff80cSmrg	    $opt_dry_run || {
4868d21ab8bcSmrg	      if $finalize; then
48699c9ff80cSmrg	        tmpdir=`func_mktempdir`
48709c9ff80cSmrg		func_basename "$file$stripped_ext"
4871d21ab8bcSmrg		file=$func_basename_result
4872d21ab8bcSmrg	        outputname=$tmpdir/$file
48739c9ff80cSmrg	        # Replace the output file specification.
48746fae4e5dSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
48759c9ff80cSmrg
4876d21ab8bcSmrg	        $opt_quiet || {
4877d21ab8bcSmrg	          func_quote_arg expand,pretty "$relink_command"
4878d21ab8bcSmrg		  eval "func_echo $func_quote_arg_result"
48799c9ff80cSmrg	        }
48809c9ff80cSmrg	        if eval "$relink_command"; then :
48819c9ff80cSmrg	          else
4882d21ab8bcSmrg		  func_error "error: relink '$file' with the above command before installing it"
48839c9ff80cSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
48849c9ff80cSmrg		  continue
48859c9ff80cSmrg	        fi
4886d21ab8bcSmrg	        file=$outputname
48879c9ff80cSmrg	      else
4888d21ab8bcSmrg	        func_warning "cannot relink '$file'"
48899c9ff80cSmrg	      fi
48909c9ff80cSmrg	    }
48919c9ff80cSmrg	  else
48929c9ff80cSmrg	    # Install the binary that we compiled earlier.
48936fae4e5dSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
48941f0ac6a5Smrg	  fi
48959c9ff80cSmrg	fi
48969c9ff80cSmrg
48979c9ff80cSmrg	# remove .exe since cygwin /usr/bin/install will append another
48989c9ff80cSmrg	# one anyway
48999c9ff80cSmrg	case $install_prog,$host in
49009c9ff80cSmrg	*/usr/bin/install*,*cygwin*)
49019c9ff80cSmrg	  case $file:$destfile in
49029c9ff80cSmrg	  *.exe:*.exe)
49039c9ff80cSmrg	    # this is ok
49049c9ff80cSmrg	    ;;
49059c9ff80cSmrg	  *.exe:*)
49069c9ff80cSmrg	    destfile=$destfile.exe
49079c9ff80cSmrg	    ;;
49089c9ff80cSmrg	  *:*.exe)
49099c9ff80cSmrg	    func_stripname '' '.exe' "$destfile"
49109c9ff80cSmrg	    destfile=$func_stripname_result
49119c9ff80cSmrg	    ;;
49129c9ff80cSmrg	  esac
49131f0ac6a5Smrg	  ;;
49141f0ac6a5Smrg	esac
49159c9ff80cSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
49169c9ff80cSmrg	$opt_dry_run || if test -n "$outputname"; then
49179c9ff80cSmrg	  ${RM}r "$tmpdir"
49189c9ff80cSmrg	fi
49199c9ff80cSmrg	;;
49209c9ff80cSmrg      esac
49219c9ff80cSmrg    done
49221f0ac6a5Smrg
49239c9ff80cSmrg    for file in $staticlibs; do
49249c9ff80cSmrg      func_basename "$file"
4925d21ab8bcSmrg      name=$func_basename_result
49269c9ff80cSmrg
49279c9ff80cSmrg      # Set up the ranlib parameters.
4928d21ab8bcSmrg      oldlib=$destdir/$name
492989c04b6cSmrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
493089c04b6cSmrg      tool_oldlib=$func_to_tool_file_result
49319c9ff80cSmrg
49329c9ff80cSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
49339c9ff80cSmrg
49349c9ff80cSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
493589c04b6cSmrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
49369c9ff80cSmrg      fi
49379c9ff80cSmrg
49389c9ff80cSmrg      # Do each command in the postinstall commands.
49399c9ff80cSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
49409c9ff80cSmrg    done
49419c9ff80cSmrg
49429c9ff80cSmrg    test -n "$future_libdirs" && \
4943d21ab8bcSmrg      func_warning "remember to run '$progname --finish$future_libdirs'"
49449c9ff80cSmrg
49459c9ff80cSmrg    if test -n "$current_libdirs"; then
49469c9ff80cSmrg      # Maybe just do a dry run.
49479c9ff80cSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
4948d21ab8bcSmrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
49499c9ff80cSmrg    else
49509c9ff80cSmrg      exit $EXIT_SUCCESS
49519c9ff80cSmrg    fi
49529c9ff80cSmrg}
49539c9ff80cSmrg
4954d21ab8bcSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
49559c9ff80cSmrg
49569c9ff80cSmrg
49579c9ff80cSmrg# func_generate_dlsyms outputname originator pic_p
49589c9ff80cSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
49599c9ff80cSmrg# a dlpreopen symbol table.
49609c9ff80cSmrgfunc_generate_dlsyms ()
49619c9ff80cSmrg{
4962d21ab8bcSmrg    $debug_cmd
4963d21ab8bcSmrg
4964d21ab8bcSmrg    my_outputname=$1
4965d21ab8bcSmrg    my_originator=$2
4966d21ab8bcSmrg    my_pic_p=${3-false}
4967d21ab8bcSmrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
49689c9ff80cSmrg    my_dlsyms=
49699c9ff80cSmrg
4970d21ab8bcSmrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
49719c9ff80cSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
4972d21ab8bcSmrg	my_dlsyms=${my_outputname}S.c
49739c9ff80cSmrg      else
49749c9ff80cSmrg	func_error "not configured to extract global symbols from dlpreopened files"
49759c9ff80cSmrg      fi
49769c9ff80cSmrg    fi
49779c9ff80cSmrg
49789c9ff80cSmrg    if test -n "$my_dlsyms"; then
49799c9ff80cSmrg      case $my_dlsyms in
49809c9ff80cSmrg      "") ;;
49819c9ff80cSmrg      *.c)
49829c9ff80cSmrg	# Discover the nlist of each of the dlfiles.
4983d21ab8bcSmrg	nlist=$output_objdir/$my_outputname.nm
49849c9ff80cSmrg
49859c9ff80cSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
49869c9ff80cSmrg
49879c9ff80cSmrg	# Parse the name list into a source file.
49889c9ff80cSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
49899c9ff80cSmrg
49909c9ff80cSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
4991d21ab8bcSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
4992d21ab8bcSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
49939c9ff80cSmrg
49949c9ff80cSmrg#ifdef __cplusplus
49959c9ff80cSmrgextern \"C\" {
49969c9ff80cSmrg#endif
49979c9ff80cSmrg
4998d21ab8bcSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
49996fae4e5dSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
50006fae4e5dSmrg#endif
50016fae4e5dSmrg
50026fae4e5dSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
5003d21ab8bcSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
5004d21ab8bcSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
50056fae4e5dSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
50066fae4e5dSmrg# define LT_DLSYM_CONST
5007d21ab8bcSmrg#elif defined __osf__
50086fae4e5dSmrg/* This system does not cope well with relocations in const data.  */
50096fae4e5dSmrg# define LT_DLSYM_CONST
50106fae4e5dSmrg#else
50116fae4e5dSmrg# define LT_DLSYM_CONST const
50126fae4e5dSmrg#endif
50136fae4e5dSmrg
5014d21ab8bcSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5015d21ab8bcSmrg
50169c9ff80cSmrg/* External symbol declarations for the compiler. */\
50179c9ff80cSmrg"
50189c9ff80cSmrg
5019d21ab8bcSmrg	if test yes = "$dlself"; then
5020d21ab8bcSmrg	  func_verbose "generating symbol list for '$output'"
50219c9ff80cSmrg
50229c9ff80cSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
50239c9ff80cSmrg
50249c9ff80cSmrg	  # Add our own program objects to the symbol list.
50256fae4e5dSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
50269c9ff80cSmrg	  for progfile in $progfiles; do
50276fae4e5dSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
5028d21ab8bcSmrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
50296fae4e5dSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
50309c9ff80cSmrg	  done
50319c9ff80cSmrg
50329c9ff80cSmrg	  if test -n "$exclude_expsyms"; then
50339c9ff80cSmrg	    $opt_dry_run || {
50349c9ff80cSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
50359c9ff80cSmrg	      eval '$MV "$nlist"T "$nlist"'
50369c9ff80cSmrg	    }
50371f0ac6a5Smrg	  fi
50389c9ff80cSmrg
50399c9ff80cSmrg	  if test -n "$export_symbols_regex"; then
50409c9ff80cSmrg	    $opt_dry_run || {
50419c9ff80cSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
50429c9ff80cSmrg	      eval '$MV "$nlist"T "$nlist"'
50439c9ff80cSmrg	    }
50449c9ff80cSmrg	  fi
50459c9ff80cSmrg
50469c9ff80cSmrg	  # Prepare the list of exported symbols
50479c9ff80cSmrg	  if test -z "$export_symbols"; then
5048d21ab8bcSmrg	    export_symbols=$output_objdir/$outputname.exp
50499c9ff80cSmrg	    $opt_dry_run || {
50509c9ff80cSmrg	      $RM $export_symbols
5051d21ab8bcSmrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
50529c9ff80cSmrg	      case $host in
50536ee7d557Smrg	      *cygwin* | *mingw* | *windows* | *cegcc* )
50549c9ff80cSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
50559c9ff80cSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
50569c9ff80cSmrg	        ;;
50579c9ff80cSmrg	      esac
50589c9ff80cSmrg	    }
50591f0ac6a5Smrg	  else
50609c9ff80cSmrg	    $opt_dry_run || {
5061d21ab8bcSmrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
50629c9ff80cSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
50639c9ff80cSmrg	      eval '$MV "$nlist"T "$nlist"'
50649c9ff80cSmrg	      case $host in
50656ee7d557Smrg	        *cygwin* | *mingw* | *windows* | *cegcc* )
50669c9ff80cSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
50679c9ff80cSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
50689c9ff80cSmrg	          ;;
50699c9ff80cSmrg	      esac
50709c9ff80cSmrg	    }
50711f0ac6a5Smrg	  fi
50729c9ff80cSmrg	fi
50731f0ac6a5Smrg
50749c9ff80cSmrg	for dlprefile in $dlprefiles; do
5075d21ab8bcSmrg	  func_verbose "extracting global C symbols from '$dlprefile'"
50769c9ff80cSmrg	  func_basename "$dlprefile"
5077d21ab8bcSmrg	  name=$func_basename_result
50786fae4e5dSmrg          case $host in
50796ee7d557Smrg	    *cygwin* | *mingw* | *windows* | *cegcc* )
50806fae4e5dSmrg	      # if an import library, we need to obtain dlname
50816fae4e5dSmrg	      if func_win32_import_lib_p "$dlprefile"; then
50826fae4e5dSmrg	        func_tr_sh "$dlprefile"
50836fae4e5dSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
5084d21ab8bcSmrg	        dlprefile_dlbasename=
50856fae4e5dSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
50866fae4e5dSmrg	          # Use subshell, to avoid clobbering current variable values
50876fae4e5dSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
5088d21ab8bcSmrg	          if test -n "$dlprefile_dlname"; then
50896fae4e5dSmrg	            func_basename "$dlprefile_dlname"
5090d21ab8bcSmrg	            dlprefile_dlbasename=$func_basename_result
50916fae4e5dSmrg	          else
50926fae4e5dSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
50936fae4e5dSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
50946fae4e5dSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
50956fae4e5dSmrg	          fi
50966fae4e5dSmrg	        fi
50976fae4e5dSmrg	        $opt_dry_run || {
5098d21ab8bcSmrg	          if test -n "$dlprefile_dlbasename"; then
50996fae4e5dSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
51006fae4e5dSmrg	          else
51016fae4e5dSmrg	            func_warning "Could not compute DLL name from $name"
51026fae4e5dSmrg	            eval '$ECHO ": $name " >> "$nlist"'
51036fae4e5dSmrg	          fi
51046fae4e5dSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
51056ee7d557Smrg	          case $host in
51066ee7d557Smrg	            i[3456]86-*-mingw32*)
51076ee7d557Smrg	              eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
51086ee7d557Smrg	                $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
51096ee7d557Smrg	            ;;
51106ee7d557Smrg	            *)
51116ee7d557Smrg	              eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
51126ee7d557Smrg	                $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/__nm_//' >> '$nlist'"
51136ee7d557Smrg	            ;;
51146ee7d557Smrg	          esac
51156fae4e5dSmrg	        }
51166fae4e5dSmrg	      else # not an import lib
51176fae4e5dSmrg	        $opt_dry_run || {
51186fae4e5dSmrg	          eval '$ECHO ": $name " >> "$nlist"'
51196fae4e5dSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
51206fae4e5dSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
51216fae4e5dSmrg	        }
51226fae4e5dSmrg	      fi
51236fae4e5dSmrg	    ;;
51246fae4e5dSmrg	    *)
51256fae4e5dSmrg	      $opt_dry_run || {
51266fae4e5dSmrg	        eval '$ECHO ": $name " >> "$nlist"'
51276fae4e5dSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
51286fae4e5dSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
51296fae4e5dSmrg	      }
51306fae4e5dSmrg	    ;;
51316fae4e5dSmrg          esac
51329c9ff80cSmrg	done
51339c9ff80cSmrg
51349c9ff80cSmrg	$opt_dry_run || {
51359c9ff80cSmrg	  # Make sure we have at least an empty file.
51369c9ff80cSmrg	  test -f "$nlist" || : > "$nlist"
51379c9ff80cSmrg
51389c9ff80cSmrg	  if test -n "$exclude_expsyms"; then
51399c9ff80cSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
51409c9ff80cSmrg	    $MV "$nlist"T "$nlist"
51411f0ac6a5Smrg	  fi
51429c9ff80cSmrg
51439c9ff80cSmrg	  # Try sorting and uniquifying the output.
51449c9ff80cSmrg	  if $GREP -v "^: " < "$nlist" |
51459c9ff80cSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
51469c9ff80cSmrg		sort -k 3
51479c9ff80cSmrg	      else
51489c9ff80cSmrg		sort +2
51499c9ff80cSmrg	      fi |
51509c9ff80cSmrg	      uniq > "$nlist"S; then
51519c9ff80cSmrg	    :
51521f0ac6a5Smrg	  else
51539c9ff80cSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
51541f0ac6a5Smrg	  fi
51551f0ac6a5Smrg
51569c9ff80cSmrg	  if test -f "$nlist"S; then
51579c9ff80cSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
51581f0ac6a5Smrg	  else
51596fae4e5dSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
51601f0ac6a5Smrg	  fi
51611f0ac6a5Smrg
5162d21ab8bcSmrg	  func_show_eval '$RM "${nlist}I"'
5163d21ab8bcSmrg	  if test -n "$global_symbol_to_import"; then
5164d21ab8bcSmrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
5165d21ab8bcSmrg	  fi
5166d21ab8bcSmrg
51676fae4e5dSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
51681f0ac6a5Smrg
51699c9ff80cSmrg/* The mapping between symbol names and symbols.  */
51709c9ff80cSmrgtypedef struct {
51719c9ff80cSmrg  const char *name;
51729c9ff80cSmrg  void *address;
51739c9ff80cSmrg} lt_dlsymlist;
51746fae4e5dSmrgextern LT_DLSYM_CONST lt_dlsymlist
5175d21ab8bcSmrglt_${my_prefix}_LTX_preloaded_symbols[];\
5176d21ab8bcSmrg"
5177d21ab8bcSmrg
5178d21ab8bcSmrg	  if test -s "$nlist"I; then
5179d21ab8bcSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
5180d21ab8bcSmrgstatic void lt_syminit(void)
5181d21ab8bcSmrg{
5182d21ab8bcSmrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
5183d21ab8bcSmrg  for (; symbol->name; ++symbol)
5184d21ab8bcSmrg    {"
5185d21ab8bcSmrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
5186d21ab8bcSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
5187d21ab8bcSmrg    }
5188d21ab8bcSmrg}"
5189d21ab8bcSmrg	  fi
5190d21ab8bcSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
51916fae4e5dSmrgLT_DLSYM_CONST lt_dlsymlist
51929c9ff80cSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
5193d21ab8bcSmrg{ {\"$my_originator\", (void *) 0},"
5194d21ab8bcSmrg
5195d21ab8bcSmrg	  if test -s "$nlist"I; then
5196d21ab8bcSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
5197d21ab8bcSmrg  {\"@INIT@\", (void *) &lt_syminit},"
5198d21ab8bcSmrg	  fi
51991f0ac6a5Smrg
52009c9ff80cSmrg	  case $need_lib_prefix in
52019c9ff80cSmrg	  no)
52029c9ff80cSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
52039c9ff80cSmrg	    ;;
52049c9ff80cSmrg	  *)
52059c9ff80cSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
52069c9ff80cSmrg	    ;;
52079c9ff80cSmrg	  esac
52086fae4e5dSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
52099c9ff80cSmrg  {0, (void *) 0}
52109c9ff80cSmrg};
52111f0ac6a5Smrg
52129c9ff80cSmrg/* This works around a problem in FreeBSD linker */
52139c9ff80cSmrg#ifdef FREEBSD_WORKAROUND
52149c9ff80cSmrgstatic const void *lt_preloaded_setup() {
52159c9ff80cSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
52169c9ff80cSmrg}
52179c9ff80cSmrg#endif
52189c9ff80cSmrg
52199c9ff80cSmrg#ifdef __cplusplus
52209c9ff80cSmrg}
52219c9ff80cSmrg#endif\
52229c9ff80cSmrg"
52239c9ff80cSmrg	} # !$opt_dry_run
52249c9ff80cSmrg
52259c9ff80cSmrg	pic_flag_for_symtable=
52269c9ff80cSmrg	case "$compile_command " in
52279c9ff80cSmrg	*" -static "*) ;;
52289c9ff80cSmrg	*)
52299c9ff80cSmrg	  case $host in
52309c9ff80cSmrg	  # compiling the symbol table file with pic_flag works around
52319c9ff80cSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
52329c9ff80cSmrg	  # linked before any other PIC object.  But we must not use
52339c9ff80cSmrg	  # pic_flag when linking with -static.  The problem exists in
52349c9ff80cSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
523589c04b6cSmrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
52369c9ff80cSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
52379c9ff80cSmrg	  *-*-hpux*)
52389c9ff80cSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
52399c9ff80cSmrg	  *)
5240d21ab8bcSmrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
52419c9ff80cSmrg	    ;;
52429c9ff80cSmrg	  esac
52439c9ff80cSmrg	  ;;
52449c9ff80cSmrg	esac
52459c9ff80cSmrg	symtab_cflags=
52469c9ff80cSmrg	for arg in $LTCFLAGS; do
52479c9ff80cSmrg	  case $arg in
52489c9ff80cSmrg	  -pie | -fpie | -fPIE) ;;
52496fae4e5dSmrg	  *) func_append symtab_cflags " $arg" ;;
52509c9ff80cSmrg	  esac
52519c9ff80cSmrg	done
52521f0ac6a5Smrg
52539c9ff80cSmrg	# Now compile the dynamic symbol file.
52549c9ff80cSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
52551f0ac6a5Smrg
52569c9ff80cSmrg	# Clean up the generated files.
5257d21ab8bcSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
52581f0ac6a5Smrg
52599c9ff80cSmrg	# Transform the symbol file into the correct name.
5260d21ab8bcSmrg	symfileobj=$output_objdir/${my_outputname}S.$objext
52619c9ff80cSmrg	case $host in
52626ee7d557Smrg	*cygwin* | *mingw* | *windows* | *cegcc* )
52639c9ff80cSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
52646fae4e5dSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
52656fae4e5dSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
52669c9ff80cSmrg	  else
52676fae4e5dSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
52686fae4e5dSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
52691f0ac6a5Smrg	  fi
52709c9ff80cSmrg	  ;;
52719c9ff80cSmrg	*)
52726fae4e5dSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
52736fae4e5dSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
52749c9ff80cSmrg	  ;;
52759c9ff80cSmrg	esac
52769c9ff80cSmrg	;;
52779c9ff80cSmrg      *)
5278d21ab8bcSmrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
52799c9ff80cSmrg	;;
52809c9ff80cSmrg      esac
52819c9ff80cSmrg    else
52829c9ff80cSmrg      # We keep going just in case the user didn't refer to
52839c9ff80cSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
52849c9ff80cSmrg      # really was required.
52851f0ac6a5Smrg
52869c9ff80cSmrg      # Nullify the symbol file.
52876fae4e5dSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
52886fae4e5dSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
52899c9ff80cSmrg    fi
52909c9ff80cSmrg}
52911f0ac6a5Smrg
5292d21ab8bcSmrg# func_cygming_gnu_implib_p ARG
5293d21ab8bcSmrg# This predicate returns with zero status (TRUE) if
5294d21ab8bcSmrg# ARG is a GNU/binutils-style import library. Returns
5295d21ab8bcSmrg# with nonzero status (FALSE) otherwise.
5296d21ab8bcSmrgfunc_cygming_gnu_implib_p ()
5297d21ab8bcSmrg{
5298d21ab8bcSmrg  $debug_cmd
5299d21ab8bcSmrg
5300d21ab8bcSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
5301d21ab8bcSmrg  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)$'`
5302d21ab8bcSmrg  test -n "$func_cygming_gnu_implib_tmp"
5303d21ab8bcSmrg}
5304d21ab8bcSmrg
5305d21ab8bcSmrg# func_cygming_ms_implib_p ARG
5306d21ab8bcSmrg# This predicate returns with zero status (TRUE) if
5307d21ab8bcSmrg# ARG is an MS-style import library. Returns
5308d21ab8bcSmrg# with nonzero status (FALSE) otherwise.
5309d21ab8bcSmrgfunc_cygming_ms_implib_p ()
5310d21ab8bcSmrg{
5311d21ab8bcSmrg  $debug_cmd
5312d21ab8bcSmrg
5313d21ab8bcSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
5314d21ab8bcSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
5315d21ab8bcSmrg  test -n "$func_cygming_ms_implib_tmp"
5316d21ab8bcSmrg}
5317d21ab8bcSmrg
53189c9ff80cSmrg# func_win32_libid arg
53199c9ff80cSmrg# return the library type of file 'arg'
53209c9ff80cSmrg#
53219c9ff80cSmrg# Need a lot of goo to handle *both* DLLs and import libs
53229c9ff80cSmrg# Has to be a shell function in order to 'eat' the argument
53239c9ff80cSmrg# that is supplied when $file_magic_command is called.
53246fae4e5dSmrg# Despite the name, also deal with 64 bit binaries.
53259c9ff80cSmrgfunc_win32_libid ()
53269c9ff80cSmrg{
5327d21ab8bcSmrg  $debug_cmd
5328d21ab8bcSmrg
5329d21ab8bcSmrg  win32_libid_type=unknown
53309c9ff80cSmrg  win32_fileres=`file -L $1 2>/dev/null`
53319c9ff80cSmrg  case $win32_fileres in
53329c9ff80cSmrg  *ar\ archive\ import\ library*) # definitely import
53339c9ff80cSmrg    win32_libid_type="x86 archive import"
53349c9ff80cSmrg    ;;
53359c9ff80cSmrg  *ar\ archive*) # could be an import, or static
53366fae4e5dSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
53379c9ff80cSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
53386ee7d557Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|pe-aarch64)' >/dev/null; then
5339d21ab8bcSmrg      case $nm_interface in
5340d21ab8bcSmrg      "MS dumpbin")
5341d21ab8bcSmrg	if func_cygming_ms_implib_p "$1" ||
5342d21ab8bcSmrg	   func_cygming_gnu_implib_p "$1"
5343d21ab8bcSmrg	then
5344d21ab8bcSmrg	  win32_nmres=import
5345d21ab8bcSmrg	else
5346d21ab8bcSmrg	  win32_nmres=
5347d21ab8bcSmrg	fi
5348d21ab8bcSmrg	;;
5349d21ab8bcSmrg      *)
5350d21ab8bcSmrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
5351d21ab8bcSmrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
5352d21ab8bcSmrg	  $SED -n -e '
53539c9ff80cSmrg	    1,100{
53549c9ff80cSmrg		/ I /{
5355d21ab8bcSmrg		    s|.*|import|
53569c9ff80cSmrg		    p
53579c9ff80cSmrg		    q
53589c9ff80cSmrg		}
53599c9ff80cSmrg	    }'`
5360d21ab8bcSmrg	;;
5361d21ab8bcSmrg      esac
53629c9ff80cSmrg      case $win32_nmres in
53639c9ff80cSmrg      import*)  win32_libid_type="x86 archive import";;
53649c9ff80cSmrg      *)        win32_libid_type="x86 archive static";;
53659c9ff80cSmrg      esac
53669c9ff80cSmrg    fi
53679c9ff80cSmrg    ;;
53689c9ff80cSmrg  *DLL*)
53699c9ff80cSmrg    win32_libid_type="x86 DLL"
53709c9ff80cSmrg    ;;
53719c9ff80cSmrg  *executable*) # but shell scripts are "executable" too...
53729c9ff80cSmrg    case $win32_fileres in
53739c9ff80cSmrg    *MS\ Windows\ PE\ Intel*)
53749c9ff80cSmrg      win32_libid_type="x86 DLL"
53759c9ff80cSmrg      ;;
53769c9ff80cSmrg    esac
53779c9ff80cSmrg    ;;
53789c9ff80cSmrg  esac
53799c9ff80cSmrg  $ECHO "$win32_libid_type"
53809c9ff80cSmrg}
53811f0ac6a5Smrg
53826fae4e5dSmrg# func_cygming_dll_for_implib ARG
53836fae4e5dSmrg#
53846fae4e5dSmrg# Platform-specific function to extract the
53856fae4e5dSmrg# name of the DLL associated with the specified
53866fae4e5dSmrg# import library ARG.
53876fae4e5dSmrg# Invoked by eval'ing the libtool variable
53886fae4e5dSmrg#    $sharedlib_from_linklib_cmd
53896fae4e5dSmrg# Result is available in the variable
53906fae4e5dSmrg#    $sharedlib_from_linklib_result
53916fae4e5dSmrgfunc_cygming_dll_for_implib ()
53926fae4e5dSmrg{
5393d21ab8bcSmrg  $debug_cmd
5394d21ab8bcSmrg
53956fae4e5dSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
53966fae4e5dSmrg}
53976fae4e5dSmrg
53986fae4e5dSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
53996fae4e5dSmrg#
54006fae4e5dSmrg# The is the core of a fallback implementation of a
54016fae4e5dSmrg# platform-specific function to extract the name of the
54026fae4e5dSmrg# DLL associated with the specified import library LIBNAME.
54036fae4e5dSmrg#
54046fae4e5dSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
54056fae4e5dSmrg# on the platform and compiler that created the implib.
54066fae4e5dSmrg#
54076fae4e5dSmrg# Echos the name of the DLL associated with the
54086fae4e5dSmrg# specified import library.
54096fae4e5dSmrgfunc_cygming_dll_for_implib_fallback_core ()
54106fae4e5dSmrg{
5411d21ab8bcSmrg  $debug_cmd
5412d21ab8bcSmrg
54136fae4e5dSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
54146fae4e5dSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
54156fae4e5dSmrg    $SED '/^Contents of section '"$match_literal"':/{
54166fae4e5dSmrg      # Place marker at beginning of archive member dllname section
54176fae4e5dSmrg      s/.*/====MARK====/
54186fae4e5dSmrg      p
54196fae4e5dSmrg      d
54206fae4e5dSmrg    }
54216fae4e5dSmrg    # These lines can sometimes be longer than 43 characters, but
54226fae4e5dSmrg    # are always uninteresting
54236fae4e5dSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
54246fae4e5dSmrg    /^In archive [^:]*:/d
54256fae4e5dSmrg    # Ensure marker is printed
54266fae4e5dSmrg    /^====MARK====/p
54276fae4e5dSmrg    # Remove all lines with less than 43 characters
54286fae4e5dSmrg    /^.\{43\}/!d
54296fae4e5dSmrg    # From remaining lines, remove first 43 characters
54306fae4e5dSmrg    s/^.\{43\}//' |
54316fae4e5dSmrg    $SED -n '
54326fae4e5dSmrg      # Join marker and all lines until next marker into a single line
54336fae4e5dSmrg      /^====MARK====/ b para
54346fae4e5dSmrg      H
54356fae4e5dSmrg      $ b para
54366fae4e5dSmrg      b
54376fae4e5dSmrg      :para
54386fae4e5dSmrg      x
54396fae4e5dSmrg      s/\n//g
54406fae4e5dSmrg      # Remove the marker
54416fae4e5dSmrg      s/^====MARK====//
54426fae4e5dSmrg      # Remove trailing dots and whitespace
54436fae4e5dSmrg      s/[\. \t]*$//
54446fae4e5dSmrg      # Print
54456fae4e5dSmrg      /./p' |
54466fae4e5dSmrg    # we now have a list, one entry per line, of the stringified
54476fae4e5dSmrg    # contents of the appropriate section of all members of the
5448d21ab8bcSmrg    # archive that possess that section. Heuristic: eliminate
5449d21ab8bcSmrg    # all those that have a first or second character that is
54506fae4e5dSmrg    # a '.' (that is, objdump's representation of an unprintable
54516fae4e5dSmrg    # character.) This should work for all archives with less than
54526fae4e5dSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
54536fae4e5dSmrg    # begins with a literal '.' or a single character followed by
54546fae4e5dSmrg    # a '.'.
54556fae4e5dSmrg    #
54566fae4e5dSmrg    # Of those that remain, print the first one.
54576fae4e5dSmrg    $SED -e '/^\./d;/^.\./d;q'
54586fae4e5dSmrg}
54596fae4e5dSmrg
54606fae4e5dSmrg# func_cygming_dll_for_implib_fallback ARG
54616fae4e5dSmrg# Platform-specific function to extract the
54626fae4e5dSmrg# name of the DLL associated with the specified
54636fae4e5dSmrg# import library ARG.
54646fae4e5dSmrg#
54656fae4e5dSmrg# This fallback implementation is for use when $DLLTOOL
54666fae4e5dSmrg# does not support the --identify-strict option.
54676fae4e5dSmrg# Invoked by eval'ing the libtool variable
54686fae4e5dSmrg#    $sharedlib_from_linklib_cmd
54696fae4e5dSmrg# Result is available in the variable
54706fae4e5dSmrg#    $sharedlib_from_linklib_result
54716fae4e5dSmrgfunc_cygming_dll_for_implib_fallback ()
54726fae4e5dSmrg{
5473d21ab8bcSmrg  $debug_cmd
5474d21ab8bcSmrg
5475d21ab8bcSmrg  if func_cygming_gnu_implib_p "$1"; then
54766fae4e5dSmrg    # binutils import library
54776fae4e5dSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
5478d21ab8bcSmrg  elif func_cygming_ms_implib_p "$1"; then
54796fae4e5dSmrg    # ms-generated import library
54806fae4e5dSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
54816fae4e5dSmrg  else
54826fae4e5dSmrg    # unknown
5483d21ab8bcSmrg    sharedlib_from_linklib_result=
54846fae4e5dSmrg  fi
54856fae4e5dSmrg}
54861f0ac6a5Smrg
54871f0ac6a5Smrg
54889c9ff80cSmrg# func_extract_an_archive dir oldlib
54899c9ff80cSmrgfunc_extract_an_archive ()
54909c9ff80cSmrg{
5491d21ab8bcSmrg    $debug_cmd
5492d21ab8bcSmrg
5493d21ab8bcSmrg    f_ex_an_ar_dir=$1; shift
5494d21ab8bcSmrg    f_ex_an_ar_oldlib=$1
5495d21ab8bcSmrg    if test yes = "$lock_old_archive_extraction"; then
54966fae4e5dSmrg      lockfile=$f_ex_an_ar_oldlib.lock
54976fae4e5dSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
54986fae4e5dSmrg	func_echo "Waiting for $lockfile to be removed"
54996fae4e5dSmrg	sleep 2
55006fae4e5dSmrg      done
55016fae4e5dSmrg    fi
55026fae4e5dSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
55036fae4e5dSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
5504d21ab8bcSmrg    if test yes = "$lock_old_archive_extraction"; then
55056fae4e5dSmrg      $opt_dry_run || rm -f "$lockfile"
55066fae4e5dSmrg    fi
55079c9ff80cSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
55089c9ff80cSmrg     :
55099c9ff80cSmrg    else
55109c9ff80cSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
55119c9ff80cSmrg    fi
55129c9ff80cSmrg}
55131f0ac6a5Smrg
55141f0ac6a5Smrg
55159c9ff80cSmrg# func_extract_archives gentop oldlib ...
55169c9ff80cSmrgfunc_extract_archives ()
55179c9ff80cSmrg{
5518d21ab8bcSmrg    $debug_cmd
5519d21ab8bcSmrg
5520d21ab8bcSmrg    my_gentop=$1; shift
55219c9ff80cSmrg    my_oldlibs=${1+"$@"}
5522d21ab8bcSmrg    my_oldobjs=
5523d21ab8bcSmrg    my_xlib=
5524d21ab8bcSmrg    my_xabs=
5525d21ab8bcSmrg    my_xdir=
55261f0ac6a5Smrg
55279c9ff80cSmrg    for my_xlib in $my_oldlibs; do
55289c9ff80cSmrg      # Extract the objects.
55299c9ff80cSmrg      case $my_xlib in
5530d21ab8bcSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
55319c9ff80cSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
55329c9ff80cSmrg      esac
55339c9ff80cSmrg      func_basename "$my_xlib"
5534d21ab8bcSmrg      my_xlib=$func_basename_result
55359c9ff80cSmrg      my_xlib_u=$my_xlib
55369c9ff80cSmrg      while :; do
55379c9ff80cSmrg        case " $extracted_archives " in
55389c9ff80cSmrg	*" $my_xlib_u "*)
55399c9ff80cSmrg	  func_arith $extracted_serial + 1
55409c9ff80cSmrg	  extracted_serial=$func_arith_result
55419c9ff80cSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
55429c9ff80cSmrg	*) break ;;
55439c9ff80cSmrg	esac
55449c9ff80cSmrg      done
55459c9ff80cSmrg      extracted_archives="$extracted_archives $my_xlib_u"
5546d21ab8bcSmrg      my_xdir=$my_gentop/$my_xlib_u
55471f0ac6a5Smrg
55489c9ff80cSmrg      func_mkdir_p "$my_xdir"
55491f0ac6a5Smrg
55509c9ff80cSmrg      case $host in
55519c9ff80cSmrg      *-darwin*)
55529c9ff80cSmrg	func_verbose "Extracting $my_xabs"
55539c9ff80cSmrg	# Do not bother doing anything if just a dry run
55549c9ff80cSmrg	$opt_dry_run || {
55559c9ff80cSmrg	  darwin_orig_dir=`pwd`
55569c9ff80cSmrg	  cd $my_xdir || exit $?
55579c9ff80cSmrg	  darwin_archive=$my_xabs
55589c9ff80cSmrg	  darwin_curdir=`pwd`
5559d21ab8bcSmrg	  func_basename "$darwin_archive"
5560d21ab8bcSmrg	  darwin_base_archive=$func_basename_result
55619c9ff80cSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
55629c9ff80cSmrg	  if test -n "$darwin_arches"; then
55639c9ff80cSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
55649c9ff80cSmrg	    darwin_arch=
55659c9ff80cSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
5566d21ab8bcSmrg	    for darwin_arch in  $darwin_arches; do
5567d21ab8bcSmrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
5568d21ab8bcSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
5569d21ab8bcSmrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
5570d21ab8bcSmrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
55719c9ff80cSmrg	      cd "$darwin_curdir"
5572d21ab8bcSmrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
55739c9ff80cSmrg	    done # $darwin_arches
55749c9ff80cSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
5575d21ab8bcSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
55769c9ff80cSmrg	    darwin_file=
55779c9ff80cSmrg	    darwin_files=
55789c9ff80cSmrg	    for darwin_file in $darwin_filelist; do
55796fae4e5dSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
55809c9ff80cSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
55819c9ff80cSmrg	    done # $darwin_filelist
55829c9ff80cSmrg	    $RM -rf unfat-$$
55839c9ff80cSmrg	    cd "$darwin_orig_dir"
55841f0ac6a5Smrg	  else
55859c9ff80cSmrg	    cd $darwin_orig_dir
55869c9ff80cSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
55879c9ff80cSmrg	  fi # $darwin_arches
55889c9ff80cSmrg	} # !$opt_dry_run
55899c9ff80cSmrg	;;
55909c9ff80cSmrg      *)
55919c9ff80cSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
55929c9ff80cSmrg	;;
55939c9ff80cSmrg      esac
55946fae4e5dSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
55959c9ff80cSmrg    done
55961f0ac6a5Smrg
5597d21ab8bcSmrg    func_extract_archives_result=$my_oldobjs
55989c9ff80cSmrg}
55991f0ac6a5Smrg
56001f0ac6a5Smrg
56016fae4e5dSmrg# func_emit_wrapper [arg=no]
56026fae4e5dSmrg#
56036fae4e5dSmrg# Emit a libtool wrapper script on stdout.
56046fae4e5dSmrg# Don't directly open a file because we may want to
56056ee7d557Smrg# incorporate the script contents within a cygwin/mingw/windows
56066fae4e5dSmrg# wrapper executable.  Must ONLY be called from within
56076fae4e5dSmrg# func_mode_link because it depends on a number of variables
56086fae4e5dSmrg# set therein.
56099c9ff80cSmrg#
56106fae4e5dSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
56116fae4e5dSmrg# variable will take.  If 'yes', then the emitted script
5612d21ab8bcSmrg# will assume that the directory where it is stored is
56136ee7d557Smrg# the $objdir directory.  This is a cygwin/mingw/windows-specific
56146fae4e5dSmrg# behavior.
56156fae4e5dSmrgfunc_emit_wrapper ()
56169c9ff80cSmrg{
56176fae4e5dSmrg	func_emit_wrapper_arg1=${1-no}
56181f0ac6a5Smrg
56199c9ff80cSmrg	$ECHO "\
56209c9ff80cSmrg#! $SHELL
56211f0ac6a5Smrg
56229c9ff80cSmrg# $output - temporary wrapper script for $objdir/$outputname
5623d21ab8bcSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
56249c9ff80cSmrg#
56259c9ff80cSmrg# The $output program cannot be directly executed until all the libtool
56269c9ff80cSmrg# libraries that it depends on are installed.
56279c9ff80cSmrg#
56289c9ff80cSmrg# This wrapper script should never be moved out of the build directory.
56299c9ff80cSmrg# If it is, it will not operate correctly.
56301f0ac6a5Smrg
56319c9ff80cSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
56329c9ff80cSmrg# metacharacters that are still active within double-quoted strings.
56339c9ff80cSmrgsed_quote_subst='$sed_quote_subst'
56341f0ac6a5Smrg
56359c9ff80cSmrg# Be Bourne compatible
56369c9ff80cSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
56379c9ff80cSmrg  emulate sh
56389c9ff80cSmrg  NULLCMD=:
56399c9ff80cSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
56409c9ff80cSmrg  # is contrary to our usage.  Disable this feature.
56419c9ff80cSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
56429c9ff80cSmrg  setopt NO_GLOB_SUBST
56439c9ff80cSmrgelse
56449c9ff80cSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
56459c9ff80cSmrgfi
56469c9ff80cSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
56479c9ff80cSmrgDUALCASE=1; export DUALCASE # for MKS sh
56481f0ac6a5Smrg
56499c9ff80cSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
56509c9ff80cSmrg# if CDPATH is set.
56519c9ff80cSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
56521f0ac6a5Smrg
56539c9ff80cSmrgrelink_command=\"$relink_command\"
56541f0ac6a5Smrg
56559c9ff80cSmrg# This environment variable determines our operation mode.
56569c9ff80cSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
56579c9ff80cSmrg  # install mode needs the following variables:
56589c9ff80cSmrg  generated_by_libtool_version='$macro_version'
56599c9ff80cSmrg  notinst_deplibs='$notinst_deplibs'
56609c9ff80cSmrgelse
56619c9ff80cSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
56629c9ff80cSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
56636fae4e5dSmrg    file=\"\$0\""
56646fae4e5dSmrg
5665d21ab8bcSmrg    func_quote_arg pretty "$ECHO"
5666d21ab8bcSmrg    qECHO=$func_quote_arg_result
56676fae4e5dSmrg    $ECHO "\
56686fae4e5dSmrg
56696fae4e5dSmrg# A function that is used when there is no print builtin or printf.
56706fae4e5dSmrgfunc_fallback_echo ()
56716fae4e5dSmrg{
56726fae4e5dSmrg  eval 'cat <<_LTECHO_EOF
56736fae4e5dSmrg\$1
56746fae4e5dSmrg_LTECHO_EOF'
56756fae4e5dSmrg}
5676d21ab8bcSmrg    ECHO=$qECHO
56776fae4e5dSmrg  fi
56786fae4e5dSmrg
56796fae4e5dSmrg# Very basic option parsing. These options are (a) specific to
56806fae4e5dSmrg# the libtool wrapper, (b) are identical between the wrapper
5681d21ab8bcSmrg# /script/ and the wrapper /executable/ that is used only on
56826fae4e5dSmrg# windows platforms, and (c) all begin with the string "--lt-"
5683d21ab8bcSmrg# (application programs are unlikely to have options that match
56846fae4e5dSmrg# this pattern).
56856fae4e5dSmrg#
56866fae4e5dSmrg# There are only two supported options: --lt-debug and
56876fae4e5dSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
56886fae4e5dSmrg#
56896fae4e5dSmrg# The first argument to this parsing function should be the
56906fae4e5dSmrg# script's $0 value, followed by "$@".
56916fae4e5dSmrglt_option_debug=
56926fae4e5dSmrgfunc_parse_lt_options ()
56936fae4e5dSmrg{
56946fae4e5dSmrg  lt_script_arg0=\$0
56956fae4e5dSmrg  shift
56966fae4e5dSmrg  for lt_opt
56976fae4e5dSmrg  do
56986fae4e5dSmrg    case \"\$lt_opt\" in
56996fae4e5dSmrg    --lt-debug) lt_option_debug=1 ;;
57006fae4e5dSmrg    --lt-dump-script)
57016fae4e5dSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
57026fae4e5dSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
57036fae4e5dSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
57046fae4e5dSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
57056fae4e5dSmrg        exit 0
57066fae4e5dSmrg      ;;
57076fae4e5dSmrg    --lt-*)
57086fae4e5dSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
57096fae4e5dSmrg        exit 1
57106fae4e5dSmrg      ;;
57116fae4e5dSmrg    esac
57126fae4e5dSmrg  done
57136fae4e5dSmrg
57146fae4e5dSmrg  # Print the debug banner immediately:
57156fae4e5dSmrg  if test -n \"\$lt_option_debug\"; then
5716d21ab8bcSmrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
57176fae4e5dSmrg  fi
57186fae4e5dSmrg}
57196fae4e5dSmrg
57206fae4e5dSmrg# Used when --lt-debug. Prints its arguments to stdout
57216fae4e5dSmrg# (redirection is the responsibility of the caller)
57226fae4e5dSmrgfunc_lt_dump_args ()
57236fae4e5dSmrg{
57246fae4e5dSmrg  lt_dump_args_N=1;
57256fae4e5dSmrg  for lt_arg
57266fae4e5dSmrg  do
5727d21ab8bcSmrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
57286fae4e5dSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
57296fae4e5dSmrg  done
57306fae4e5dSmrg}
57316fae4e5dSmrg
57326fae4e5dSmrg# Core function for launching the target application
57336fae4e5dSmrgfunc_exec_program_core ()
57346fae4e5dSmrg{
57359c9ff80cSmrg"
57366fae4e5dSmrg  case $host in
57376fae4e5dSmrg  # Backslashes separate directories on plain windows
57386ee7d557Smrg  *-*-mingw* | *-*-windows* | *-*-os2* | *-cegcc*)
57396fae4e5dSmrg    $ECHO "\
57406fae4e5dSmrg      if test -n \"\$lt_option_debug\"; then
5741d21ab8bcSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
57426fae4e5dSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
57436fae4e5dSmrg      fi
57446fae4e5dSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
57456fae4e5dSmrg"
57466fae4e5dSmrg    ;;
57476fae4e5dSmrg
57486fae4e5dSmrg  *)
57496fae4e5dSmrg    $ECHO "\
57506fae4e5dSmrg      if test -n \"\$lt_option_debug\"; then
5751d21ab8bcSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
57526fae4e5dSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
57536fae4e5dSmrg      fi
57546fae4e5dSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
57556fae4e5dSmrg"
57566fae4e5dSmrg    ;;
57576fae4e5dSmrg  esac
57586fae4e5dSmrg  $ECHO "\
57596fae4e5dSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
57606fae4e5dSmrg      exit 1
57616fae4e5dSmrg}
57626fae4e5dSmrg
57636fae4e5dSmrg# A function to encapsulate launching the target application
57646fae4e5dSmrg# Strips options in the --lt-* namespace from \$@ and
57656fae4e5dSmrg# launches target application with the remaining arguments.
57666fae4e5dSmrgfunc_exec_program ()
57676fae4e5dSmrg{
576889c04b6cSmrg  case \" \$* \" in
576989c04b6cSmrg  *\\ --lt-*)
577089c04b6cSmrg    for lt_wr_arg
577189c04b6cSmrg    do
577289c04b6cSmrg      case \$lt_wr_arg in
577389c04b6cSmrg      --lt-*) ;;
577489c04b6cSmrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
577589c04b6cSmrg      esac
577689c04b6cSmrg      shift
577789c04b6cSmrg    done ;;
577889c04b6cSmrg  esac
57796fae4e5dSmrg  func_exec_program_core \${1+\"\$@\"}
57806fae4e5dSmrg}
57816fae4e5dSmrg
57826fae4e5dSmrg  # Parse options
57836fae4e5dSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
57841f0ac6a5Smrg
57859c9ff80cSmrg  # Find the directory that this script lives in.
57866fae4e5dSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
57879c9ff80cSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
57881f0ac6a5Smrg
57899c9ff80cSmrg  # Follow symbolic links until we get to the real thisdir.
57906fae4e5dSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
57919c9ff80cSmrg  while test -n \"\$file\"; do
57926fae4e5dSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
57931f0ac6a5Smrg
57949c9ff80cSmrg    # If there was a directory component, then change thisdir.
57959c9ff80cSmrg    if test \"x\$destdir\" != \"x\$file\"; then
57969c9ff80cSmrg      case \"\$destdir\" in
57979c9ff80cSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
57989c9ff80cSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
57991f0ac6a5Smrg      esac
58009c9ff80cSmrg    fi
58011f0ac6a5Smrg
58026fae4e5dSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
58036fae4e5dSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
58049c9ff80cSmrg  done
58051f0ac6a5Smrg
58066ee7d557Smrg  # Usually 'no', except on cygwin/mingw/windows when embedded into
58079c9ff80cSmrg  # the cwrapper.
58086fae4e5dSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
58099c9ff80cSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
58109c9ff80cSmrg    # special case for '.'
58119c9ff80cSmrg    if test \"\$thisdir\" = \".\"; then
58129c9ff80cSmrg      thisdir=\`pwd\`
58139c9ff80cSmrg    fi
58149c9ff80cSmrg    # remove .libs from thisdir
58159c9ff80cSmrg    case \"\$thisdir\" in
58166fae4e5dSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
58179c9ff80cSmrg    $objdir )   thisdir=. ;;
58189c9ff80cSmrg    esac
58199c9ff80cSmrg  fi
58209c9ff80cSmrg
58219c9ff80cSmrg  # Try to get the absolute directory name.
58229c9ff80cSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
58239c9ff80cSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
58249c9ff80cSmrg"
58259c9ff80cSmrg
5826d21ab8bcSmrg	if test yes = "$fast_install"; then
58279c9ff80cSmrg	  $ECHO "\
58289c9ff80cSmrg  program=lt-'$outputname'$exeext
58299c9ff80cSmrg  progdir=\"\$thisdir/$objdir\"
58309c9ff80cSmrg
58319c9ff80cSmrg  if test ! -f \"\$progdir/\$program\" ||
5832d21ab8bcSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
58339c9ff80cSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
58349c9ff80cSmrg
58359c9ff80cSmrg    file=\"\$\$-\$program\"
58369c9ff80cSmrg
58379c9ff80cSmrg    if test ! -d \"\$progdir\"; then
58389c9ff80cSmrg      $MKDIR \"\$progdir\"
58399c9ff80cSmrg    else
58409c9ff80cSmrg      $RM \"\$progdir/\$file\"
58419c9ff80cSmrg    fi"
58429c9ff80cSmrg
58439c9ff80cSmrg	  $ECHO "\
58449c9ff80cSmrg
58459c9ff80cSmrg    # relink executable if necessary
58469c9ff80cSmrg    if test -n \"\$relink_command\"; then
58479c9ff80cSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
58489c9ff80cSmrg      else
5849d21ab8bcSmrg	\$ECHO \"\$relink_command_output\" >&2
58509c9ff80cSmrg	$RM \"\$progdir/\$file\"
58519c9ff80cSmrg	exit 1
58521f0ac6a5Smrg      fi
58539c9ff80cSmrg    fi
58541f0ac6a5Smrg
58559c9ff80cSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
58569c9ff80cSmrg    { $RM \"\$progdir/\$program\";
58579c9ff80cSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
58589c9ff80cSmrg    $RM \"\$progdir/\$file\"
58599c9ff80cSmrg  fi"
58609c9ff80cSmrg	else
58619c9ff80cSmrg	  $ECHO "\
58629c9ff80cSmrg  program='$outputname'
58639c9ff80cSmrg  progdir=\"\$thisdir/$objdir\"
58649c9ff80cSmrg"
58651f0ac6a5Smrg	fi
58661f0ac6a5Smrg
58679c9ff80cSmrg	$ECHO "\
58681f0ac6a5Smrg
58699c9ff80cSmrg  if test -f \"\$progdir/\$program\"; then"
58701f0ac6a5Smrg
58716fae4e5dSmrg	# fixup the dll searchpath if we need to.
58726fae4e5dSmrg	#
58736fae4e5dSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
58746fae4e5dSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
58756fae4e5dSmrg	# libraries must come first.
58766fae4e5dSmrg	if test -n "$dllsearchpath"; then
58776fae4e5dSmrg	  $ECHO "\
58786fae4e5dSmrg    # Add the dll search path components to the executable PATH
58796fae4e5dSmrg    PATH=$dllsearchpath:\$PATH
58806fae4e5dSmrg"
58816fae4e5dSmrg	fi
58826fae4e5dSmrg
58839c9ff80cSmrg	# Export our shlibpath_var if we have one.
5884d21ab8bcSmrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
58859c9ff80cSmrg	  $ECHO "\
58869c9ff80cSmrg    # Add our own library path to $shlibpath_var
58879c9ff80cSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
58889c9ff80cSmrg
58899c9ff80cSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
58909c9ff80cSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
58916fae4e5dSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
58921f0ac6a5Smrg
58939c9ff80cSmrg    export $shlibpath_var
58949c9ff80cSmrg"
58951f0ac6a5Smrg	fi
58961f0ac6a5Smrg
58979c9ff80cSmrg	$ECHO "\
58989c9ff80cSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
58999c9ff80cSmrg      # Run the actual program with our arguments.
59006fae4e5dSmrg      func_exec_program \${1+\"\$@\"}
59019c9ff80cSmrg    fi
59029c9ff80cSmrg  else
59039c9ff80cSmrg    # The program doesn't exist.
5904d21ab8bcSmrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
59059c9ff80cSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
59066fae4e5dSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
59079c9ff80cSmrg    exit 1
59089c9ff80cSmrg  fi
59099c9ff80cSmrgfi\
59109c9ff80cSmrg"
59119c9ff80cSmrg}
59121f0ac6a5Smrg
59131f0ac6a5Smrg
59149c9ff80cSmrg# func_emit_cwrapperexe_src
59159c9ff80cSmrg# emit the source code for a wrapper executable on stdout
59169c9ff80cSmrg# Must ONLY be called from within func_mode_link because
59179c9ff80cSmrg# it depends on a number of variable set therein.
59189c9ff80cSmrgfunc_emit_cwrapperexe_src ()
59199c9ff80cSmrg{
59209c9ff80cSmrg	cat <<EOF
59211f0ac6a5Smrg
59229c9ff80cSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5923d21ab8bcSmrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
59241f0ac6a5Smrg
59259c9ff80cSmrg   The $output program cannot be directly executed until all the libtool
59269c9ff80cSmrg   libraries that it depends on are installed.
59271f0ac6a5Smrg
59289c9ff80cSmrg   This wrapper executable should never be moved out of the build directory.
59299c9ff80cSmrg   If it is, it will not operate correctly.
59309c9ff80cSmrg*/
59319c9ff80cSmrgEOF
59329c9ff80cSmrg	    cat <<"EOF"
59336fae4e5dSmrg#ifdef _MSC_VER
59346fae4e5dSmrg# define _CRT_SECURE_NO_DEPRECATE 1
59356fae4e5dSmrg#endif
59369c9ff80cSmrg#include <stdio.h>
59379c9ff80cSmrg#include <stdlib.h>
59386ee7d557Smrg#if defined _WIN32 && !defined __GNUC__
59399c9ff80cSmrg# include <direct.h>
59409c9ff80cSmrg# include <process.h>
59419c9ff80cSmrg# include <io.h>
59429c9ff80cSmrg#else
59439c9ff80cSmrg# include <unistd.h>
59449c9ff80cSmrg# include <stdint.h>
59459c9ff80cSmrg# ifdef __CYGWIN__
59469c9ff80cSmrg#  include <io.h>
59479c9ff80cSmrg# endif
59489c9ff80cSmrg#endif
59499c9ff80cSmrg#include <malloc.h>
59509c9ff80cSmrg#include <stdarg.h>
59519c9ff80cSmrg#include <assert.h>
59529c9ff80cSmrg#include <string.h>
59539c9ff80cSmrg#include <ctype.h>
59549c9ff80cSmrg#include <errno.h>
59559c9ff80cSmrg#include <fcntl.h>
59569c9ff80cSmrg#include <sys/stat.h>
59571f0ac6a5Smrg
5958d21ab8bcSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5959d21ab8bcSmrg
59606fae4e5dSmrg/* declarations of non-ANSI functions */
5961d21ab8bcSmrg#if defined __MINGW32__
59626fae4e5dSmrg# ifdef __STRICT_ANSI__
59636ee7d557Smrg_CRTIMP int __cdecl _putenv (const char *);
59646fae4e5dSmrg# endif
5965d21ab8bcSmrg#elif defined __CYGWIN__
59666fae4e5dSmrg# ifdef __STRICT_ANSI__
59676fae4e5dSmrgchar *realpath (const char *, char *);
59686fae4e5dSmrgint putenv (char *);
59696fae4e5dSmrgint setenv (const char *, const char *, int);
59706fae4e5dSmrg# endif
5971d21ab8bcSmrg/* #elif defined other_platform || defined ... */
59726fae4e5dSmrg#endif
59736fae4e5dSmrg
59746fae4e5dSmrg/* portability defines, excluding path handling macros */
5975d21ab8bcSmrg#if defined _MSC_VER
59766fae4e5dSmrg# define setmode _setmode
59776fae4e5dSmrg# define stat    _stat
59786fae4e5dSmrg# define chmod   _chmod
59796fae4e5dSmrg# define getcwd  _getcwd
59806fae4e5dSmrg# define putenv  _putenv
59816fae4e5dSmrg# define S_IXUSR _S_IEXEC
5982d21ab8bcSmrg#elif defined __MINGW32__
59836fae4e5dSmrg# define setmode _setmode
59846fae4e5dSmrg# define stat    _stat
59856fae4e5dSmrg# define chmod   _chmod
59866fae4e5dSmrg# define getcwd  _getcwd
59876fae4e5dSmrg# define putenv  _putenv
5988d21ab8bcSmrg#elif defined __CYGWIN__
59896fae4e5dSmrg# define HAVE_SETENV
59906fae4e5dSmrg# define FOPEN_WB "wb"
5991d21ab8bcSmrg/* #elif defined other platforms ... */
59926fae4e5dSmrg#endif
59936fae4e5dSmrg
5994d21ab8bcSmrg#if defined PATH_MAX
59959c9ff80cSmrg# define LT_PATHMAX PATH_MAX
5996d21ab8bcSmrg#elif defined MAXPATHLEN
59979c9ff80cSmrg# define LT_PATHMAX MAXPATHLEN
59989c9ff80cSmrg#else
59999c9ff80cSmrg# define LT_PATHMAX 1024
60009c9ff80cSmrg#endif
60011f0ac6a5Smrg
60029c9ff80cSmrg#ifndef S_IXOTH
60039c9ff80cSmrg# define S_IXOTH 0
60049c9ff80cSmrg#endif
60059c9ff80cSmrg#ifndef S_IXGRP
60069c9ff80cSmrg# define S_IXGRP 0
60079c9ff80cSmrg#endif
60081f0ac6a5Smrg
60096fae4e5dSmrg/* path handling portability macros */
60109c9ff80cSmrg#ifndef DIR_SEPARATOR
60119c9ff80cSmrg# define DIR_SEPARATOR '/'
60129c9ff80cSmrg# define PATH_SEPARATOR ':'
60139c9ff80cSmrg#endif
60141f0ac6a5Smrg
6015d21ab8bcSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
6016d21ab8bcSmrg  defined __OS2__
60179c9ff80cSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
60189c9ff80cSmrg# define FOPEN_WB "wb"
60199c9ff80cSmrg# ifndef DIR_SEPARATOR_2
60209c9ff80cSmrg#  define DIR_SEPARATOR_2 '\\'
60219c9ff80cSmrg# endif
60229c9ff80cSmrg# ifndef PATH_SEPARATOR_2
60239c9ff80cSmrg#  define PATH_SEPARATOR_2 ';'
60249c9ff80cSmrg# endif
60259c9ff80cSmrg#endif
60261f0ac6a5Smrg
60279c9ff80cSmrg#ifndef DIR_SEPARATOR_2
60289c9ff80cSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
60299c9ff80cSmrg#else /* DIR_SEPARATOR_2 */
60309c9ff80cSmrg# define IS_DIR_SEPARATOR(ch) \
60319c9ff80cSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
60329c9ff80cSmrg#endif /* DIR_SEPARATOR_2 */
60331f0ac6a5Smrg
60349c9ff80cSmrg#ifndef PATH_SEPARATOR_2
60359c9ff80cSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
60369c9ff80cSmrg#else /* PATH_SEPARATOR_2 */
60379c9ff80cSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
60389c9ff80cSmrg#endif /* PATH_SEPARATOR_2 */
60391f0ac6a5Smrg
60409c9ff80cSmrg#ifndef FOPEN_WB
60419c9ff80cSmrg# define FOPEN_WB "w"
60429c9ff80cSmrg#endif
60439c9ff80cSmrg#ifndef _O_BINARY
60449c9ff80cSmrg# define _O_BINARY 0
60459c9ff80cSmrg#endif
60461f0ac6a5Smrg
60479c9ff80cSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
60489c9ff80cSmrg#define XFREE(stale) do { \
6049d21ab8bcSmrg  if (stale) { free (stale); stale = 0; } \
60509c9ff80cSmrg} while (0)
60511f0ac6a5Smrg
6052d21ab8bcSmrg#if defined LT_DEBUGWRAPPER
60536fae4e5dSmrgstatic int lt_debug = 1;
60549c9ff80cSmrg#else
60556fae4e5dSmrgstatic int lt_debug = 0;
60569c9ff80cSmrg#endif
60571f0ac6a5Smrg
60586fae4e5dSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
60591f0ac6a5Smrg
60609c9ff80cSmrgvoid *xmalloc (size_t num);
60619c9ff80cSmrgchar *xstrdup (const char *string);
60629c9ff80cSmrgconst char *base_name (const char *name);
60639c9ff80cSmrgchar *find_executable (const char *wrapper);
60649c9ff80cSmrgchar *chase_symlinks (const char *pathspec);
60659c9ff80cSmrgint make_executable (const char *path);
60669c9ff80cSmrgint check_executable (const char *path);
60679c9ff80cSmrgchar *strendzap (char *str, const char *pat);
60686fae4e5dSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
60696fae4e5dSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
60706fae4e5dSmrgstatic const char *nonnull (const char *s);
60716fae4e5dSmrgstatic const char *nonempty (const char *s);
60729c9ff80cSmrgvoid lt_setenv (const char *name, const char *value);
60739c9ff80cSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
60749c9ff80cSmrgvoid lt_update_exe_path (const char *name, const char *value);
60759c9ff80cSmrgvoid lt_update_lib_path (const char *name, const char *value);
60766fae4e5dSmrgchar **prepare_spawn (char **argv);
60776fae4e5dSmrgvoid lt_dump_script (FILE *f);
60789c9ff80cSmrgEOF
60799c9ff80cSmrg
60809c9ff80cSmrg	    cat <<EOF
6081d21ab8bcSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
6082d21ab8bcSmrg# define externally_visible volatile
6083d21ab8bcSmrg#else
6084d21ab8bcSmrg# define externally_visible __attribute__((externally_visible)) volatile
6085d21ab8bcSmrg#endif
6086d21ab8bcSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
60879c9ff80cSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
60889c9ff80cSmrgEOF
60891f0ac6a5Smrg
6090d21ab8bcSmrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
60916fae4e5dSmrg              func_to_host_path "$temp_rpath"
60929c9ff80cSmrg	      cat <<EOF
60936fae4e5dSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
60949c9ff80cSmrgEOF
60959c9ff80cSmrg	    else
60969c9ff80cSmrg	      cat <<"EOF"
60979c9ff80cSmrgconst char * LIB_PATH_VALUE   = "";
60989c9ff80cSmrgEOF
60991f0ac6a5Smrg	    fi
61001f0ac6a5Smrg
61019c9ff80cSmrg	    if test -n "$dllsearchpath"; then
61026fae4e5dSmrg              func_to_host_path "$dllsearchpath:"
61039c9ff80cSmrg	      cat <<EOF
61049c9ff80cSmrgconst char * EXE_PATH_VARNAME = "PATH";
61056fae4e5dSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
61061f0ac6a5SmrgEOF
61071f0ac6a5Smrg	    else
61089c9ff80cSmrg	      cat <<"EOF"
61099c9ff80cSmrgconst char * EXE_PATH_VARNAME = "";
61109c9ff80cSmrgconst char * EXE_PATH_VALUE   = "";
61119c9ff80cSmrgEOF
61121f0ac6a5Smrg	    fi
61139c9ff80cSmrg
6114d21ab8bcSmrg	    if test yes = "$fast_install"; then
61159c9ff80cSmrg	      cat <<EOF
61169c9ff80cSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
61179c9ff80cSmrgEOF
61181f0ac6a5Smrg	    else
61199c9ff80cSmrg	      cat <<EOF
61209c9ff80cSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
61219c9ff80cSmrgEOF
61221f0ac6a5Smrg	    fi
61231f0ac6a5Smrg
61241f0ac6a5Smrg
61259c9ff80cSmrg	    cat <<"EOF"
61261f0ac6a5Smrg
61279c9ff80cSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
61281f0ac6a5Smrg
61299c9ff80cSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
61309c9ff80cSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
61316fae4e5dSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
61321f0ac6a5Smrg
61339c9ff80cSmrgint
61349c9ff80cSmrgmain (int argc, char *argv[])
61359c9ff80cSmrg{
61369c9ff80cSmrg  char **newargz;
61379c9ff80cSmrg  int  newargc;
61389c9ff80cSmrg  char *tmp_pathspec;
61399c9ff80cSmrg  char *actual_cwrapper_path;
61409c9ff80cSmrg  char *actual_cwrapper_name;
61419c9ff80cSmrg  char *target_name;
61429c9ff80cSmrg  char *lt_argv_zero;
6143d21ab8bcSmrg  int rval = 127;
61441f0ac6a5Smrg
61459c9ff80cSmrg  int i;
61461f0ac6a5Smrg
61479c9ff80cSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
6148d21ab8bcSmrg  newargz = XMALLOC (char *, (size_t) argc + 1);
61491f0ac6a5Smrg
61506fae4e5dSmrg  /* very simple arg parsing; don't want to rely on getopt
61516fae4e5dSmrg   * also, copy all non cwrapper options to newargz, except
61526fae4e5dSmrg   * argz[0], which is handled differently
61536fae4e5dSmrg   */
61546fae4e5dSmrg  newargc=0;
61559c9ff80cSmrg  for (i = 1; i < argc; i++)
61569c9ff80cSmrg    {
6157d21ab8bcSmrg      if (STREQ (argv[i], dumpscript_opt))
61589c9ff80cSmrg	{
61599c9ff80cSmrgEOF
6160d21ab8bcSmrg	    case $host in
61616ee7d557Smrg	      *mingw* | *windows* | *cygwin* )
61629c9ff80cSmrg		# make stdout use "unix" line endings
61639c9ff80cSmrg		echo "          setmode(1,_O_BINARY);"
61649c9ff80cSmrg		;;
61659c9ff80cSmrg	      esac
61661f0ac6a5Smrg
61679c9ff80cSmrg	    cat <<"EOF"
61686fae4e5dSmrg	  lt_dump_script (stdout);
61699c9ff80cSmrg	  return 0;
61709c9ff80cSmrg	}
6171d21ab8bcSmrg      if (STREQ (argv[i], debug_opt))
61726fae4e5dSmrg	{
61736fae4e5dSmrg          lt_debug = 1;
61746fae4e5dSmrg          continue;
61756fae4e5dSmrg	}
6176d21ab8bcSmrg      if (STREQ (argv[i], ltwrapper_option_prefix))
61776fae4e5dSmrg        {
61786fae4e5dSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
61796fae4e5dSmrg             namespace, but it is not one of the ones we know about and
61806ee7d557Smrg             have already dealt with, above (including dump-script), then
61816fae4e5dSmrg             report an error. Otherwise, targets might begin to believe
61826fae4e5dSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
61836fae4e5dSmrg             namespace. The first time any user complains about this, we'll
61846fae4e5dSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
61856fae4e5dSmrg             or a configure.ac-settable value.
61866fae4e5dSmrg           */
61876fae4e5dSmrg          lt_fatal (__FILE__, __LINE__,
61886fae4e5dSmrg		    "unrecognized %s option: '%s'",
61896fae4e5dSmrg                    ltwrapper_option_prefix, argv[i]);
61906fae4e5dSmrg        }
61916fae4e5dSmrg      /* otherwise ... */
61926fae4e5dSmrg      newargz[++newargc] = xstrdup (argv[i]);
61939c9ff80cSmrg    }
61946fae4e5dSmrg  newargz[++newargc] = NULL;
61956fae4e5dSmrg
61966fae4e5dSmrgEOF
61976fae4e5dSmrg	    cat <<EOF
61986fae4e5dSmrg  /* The GNU banner must be the first non-error debug message */
6199d21ab8bcSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
62006fae4e5dSmrgEOF
62016fae4e5dSmrg	    cat <<"EOF"
62026fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
62036fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
62041f0ac6a5Smrg
62059c9ff80cSmrg  tmp_pathspec = find_executable (argv[0]);
62069c9ff80cSmrg  if (tmp_pathspec == NULL)
62076fae4e5dSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
62086fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__,
62096fae4e5dSmrg                  "(main) found exe (before symlink chase) at: %s\n",
62106fae4e5dSmrg		  tmp_pathspec);
62119c9ff80cSmrg
62129c9ff80cSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
62136fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__,
62146fae4e5dSmrg                  "(main) found exe (after symlink chase) at: %s\n",
62156fae4e5dSmrg		  actual_cwrapper_path);
62169c9ff80cSmrg  XFREE (tmp_pathspec);
62179c9ff80cSmrg
62186fae4e5dSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
62199c9ff80cSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
62209c9ff80cSmrg
62219c9ff80cSmrg  /* wrapper name transforms */
62229c9ff80cSmrg  strendzap (actual_cwrapper_name, ".exe");
62239c9ff80cSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
62249c9ff80cSmrg  XFREE (actual_cwrapper_name);
62259c9ff80cSmrg  actual_cwrapper_name = tmp_pathspec;
62269c9ff80cSmrg  tmp_pathspec = 0;
62279c9ff80cSmrg
62289c9ff80cSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
62299c9ff80cSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
62309c9ff80cSmrg  strendzap (target_name, ".exe");
62319c9ff80cSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
62329c9ff80cSmrg  XFREE (target_name);
62339c9ff80cSmrg  target_name = tmp_pathspec;
62349c9ff80cSmrg  tmp_pathspec = 0;
62359c9ff80cSmrg
62366fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__,
62376fae4e5dSmrg		  "(main) libtool target name: %s\n",
62386fae4e5dSmrg		  target_name);
62399c9ff80cSmrgEOF
62401f0ac6a5Smrg
62419c9ff80cSmrg	    cat <<EOF
62429c9ff80cSmrg  newargz[0] =
62439c9ff80cSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
62449c9ff80cSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
62459c9ff80cSmrg  strcpy (newargz[0], actual_cwrapper_path);
62469c9ff80cSmrg  strcat (newargz[0], "$objdir");
62479c9ff80cSmrg  strcat (newargz[0], "/");
62489c9ff80cSmrgEOF
62491f0ac6a5Smrg
62509c9ff80cSmrg	    cat <<"EOF"
62519c9ff80cSmrg  /* stop here, and copy so we don't have to do this twice */
62529c9ff80cSmrg  tmp_pathspec = xstrdup (newargz[0]);
62531f0ac6a5Smrg
62549c9ff80cSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
62559c9ff80cSmrg  strcat (newargz[0], actual_cwrapper_name);
62561f0ac6a5Smrg
62579c9ff80cSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
62589c9ff80cSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
62599c9ff80cSmrg  XFREE (tmp_pathspec);
62609c9ff80cSmrg  tmp_pathspec = NULL;
62619c9ff80cSmrgEOF
62621f0ac6a5Smrg
62639c9ff80cSmrg	    case $host_os in
62646ee7d557Smrg	      mingw* | windows*)
62659c9ff80cSmrg	    cat <<"EOF"
62669c9ff80cSmrg  {
62679c9ff80cSmrg    char* p;
62689c9ff80cSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
62699c9ff80cSmrg      {
62709c9ff80cSmrg	*p = '/';
62719c9ff80cSmrg      }
62729c9ff80cSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
62739c9ff80cSmrg      {
62749c9ff80cSmrg	*p = '/';
62759c9ff80cSmrg      }
62769c9ff80cSmrg  }
62779c9ff80cSmrgEOF
62789c9ff80cSmrg	    ;;
62799c9ff80cSmrg	    esac
62801f0ac6a5Smrg
62819c9ff80cSmrg	    cat <<"EOF"
62829c9ff80cSmrg  XFREE (target_name);
62839c9ff80cSmrg  XFREE (actual_cwrapper_path);
62849c9ff80cSmrg  XFREE (actual_cwrapper_name);
62851f0ac6a5Smrg
62869c9ff80cSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
62879c9ff80cSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
62886fae4e5dSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
62896fae4e5dSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
62906fae4e5dSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
62916fae4e5dSmrg     libraries must come first. */
62929c9ff80cSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
62936fae4e5dSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
62941f0ac6a5Smrg
62956fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
62966fae4e5dSmrg		  nonnull (lt_argv_zero));
62979c9ff80cSmrg  for (i = 0; i < newargc; i++)
62989c9ff80cSmrg    {
62996fae4e5dSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
63006fae4e5dSmrg		      i, nonnull (newargz[i]));
63019c9ff80cSmrg    }
63021f0ac6a5Smrg
63039c9ff80cSmrgEOF
63041f0ac6a5Smrg
63059c9ff80cSmrg	    case $host_os in
63066ee7d557Smrg	      mingw* | windows*)
63079c9ff80cSmrg		cat <<"EOF"
63089c9ff80cSmrg  /* execv doesn't actually work on mingw as expected on unix */
63096fae4e5dSmrg  newargz = prepare_spawn (newargz);
6310d21ab8bcSmrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
63119c9ff80cSmrg  if (rval == -1)
63129c9ff80cSmrg    {
63139c9ff80cSmrg      /* failed to start process */
63146fae4e5dSmrg      lt_debugprintf (__FILE__, __LINE__,
63156fae4e5dSmrg		      "(main) failed to launch target \"%s\": %s\n",
63166fae4e5dSmrg		      lt_argv_zero, nonnull (strerror (errno)));
63179c9ff80cSmrg      return 127;
63189c9ff80cSmrg    }
63199c9ff80cSmrg  return rval;
63209c9ff80cSmrgEOF
63219c9ff80cSmrg		;;
63229c9ff80cSmrg	      *)
63239c9ff80cSmrg		cat <<"EOF"
63249c9ff80cSmrg  execv (lt_argv_zero, newargz);
63259c9ff80cSmrg  return rval; /* =127, but avoids unused variable warning */
63269c9ff80cSmrgEOF
63279c9ff80cSmrg		;;
63289c9ff80cSmrg	    esac
63291f0ac6a5Smrg
63309c9ff80cSmrg	    cat <<"EOF"
63319c9ff80cSmrg}
63321f0ac6a5Smrg
63339c9ff80cSmrgvoid *
63349c9ff80cSmrgxmalloc (size_t num)
63359c9ff80cSmrg{
63369c9ff80cSmrg  void *p = (void *) malloc (num);
63379c9ff80cSmrg  if (!p)
63386fae4e5dSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
63391f0ac6a5Smrg
63409c9ff80cSmrg  return p;
63419c9ff80cSmrg}
63421f0ac6a5Smrg
63439c9ff80cSmrgchar *
63449c9ff80cSmrgxstrdup (const char *string)
63459c9ff80cSmrg{
63469c9ff80cSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
63479c9ff80cSmrg			  string) : NULL;
63489c9ff80cSmrg}
63491f0ac6a5Smrg
63509c9ff80cSmrgconst char *
63519c9ff80cSmrgbase_name (const char *name)
63529c9ff80cSmrg{
63539c9ff80cSmrg  const char *base;
63541f0ac6a5Smrg
6355d21ab8bcSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
63569c9ff80cSmrg  /* Skip over the disk name in MSDOS pathnames. */
63579c9ff80cSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
63589c9ff80cSmrg    name += 2;
63599c9ff80cSmrg#endif
63601f0ac6a5Smrg
63619c9ff80cSmrg  for (base = name; *name; name++)
63629c9ff80cSmrg    if (IS_DIR_SEPARATOR (*name))
63639c9ff80cSmrg      base = name + 1;
63649c9ff80cSmrg  return base;
63659c9ff80cSmrg}
63661f0ac6a5Smrg
63679c9ff80cSmrgint
63689c9ff80cSmrgcheck_executable (const char *path)
63699c9ff80cSmrg{
63709c9ff80cSmrg  struct stat st;
63711f0ac6a5Smrg
63726fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
63736fae4e5dSmrg                  nonempty (path));
63749c9ff80cSmrg  if ((!path) || (!*path))
63759c9ff80cSmrg    return 0;
63761f0ac6a5Smrg
63779c9ff80cSmrg  if ((stat (path, &st) >= 0)
63789c9ff80cSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
63799c9ff80cSmrg    return 1;
63809c9ff80cSmrg  else
63819c9ff80cSmrg    return 0;
63829c9ff80cSmrg}
63831f0ac6a5Smrg
63849c9ff80cSmrgint
63859c9ff80cSmrgmake_executable (const char *path)
63869c9ff80cSmrg{
63879c9ff80cSmrg  int rval = 0;
63889c9ff80cSmrg  struct stat st;
63891f0ac6a5Smrg
63906fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
63916fae4e5dSmrg                  nonempty (path));
63929c9ff80cSmrg  if ((!path) || (!*path))
63939c9ff80cSmrg    return 0;
63941f0ac6a5Smrg
63959c9ff80cSmrg  if (stat (path, &st) >= 0)
63969c9ff80cSmrg    {
63979c9ff80cSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
63989c9ff80cSmrg    }
63999c9ff80cSmrg  return rval;
64009c9ff80cSmrg}
64011f0ac6a5Smrg
64029c9ff80cSmrg/* Searches for the full path of the wrapper.  Returns
64039c9ff80cSmrg   newly allocated full path name if found, NULL otherwise
64049c9ff80cSmrg   Does not chase symlinks, even on platforms that support them.
64059c9ff80cSmrg*/
64069c9ff80cSmrgchar *
64079c9ff80cSmrgfind_executable (const char *wrapper)
64089c9ff80cSmrg{
64099c9ff80cSmrg  int has_slash = 0;
64109c9ff80cSmrg  const char *p;
64119c9ff80cSmrg  const char *p_next;
64129c9ff80cSmrg  /* static buffer for getcwd */
64139c9ff80cSmrg  char tmp[LT_PATHMAX + 1];
6414d21ab8bcSmrg  size_t tmp_len;
64159c9ff80cSmrg  char *concat_name;
64161f0ac6a5Smrg
64176fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
64186fae4e5dSmrg                  nonempty (wrapper));
64191f0ac6a5Smrg
64209c9ff80cSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
64219c9ff80cSmrg    return NULL;
64221f0ac6a5Smrg
64239c9ff80cSmrg  /* Absolute path? */
6424d21ab8bcSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
64259c9ff80cSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
64269c9ff80cSmrg    {
64279c9ff80cSmrg      concat_name = xstrdup (wrapper);
64289c9ff80cSmrg      if (check_executable (concat_name))
64299c9ff80cSmrg	return concat_name;
64309c9ff80cSmrg      XFREE (concat_name);
64319c9ff80cSmrg    }
64329c9ff80cSmrg  else
64339c9ff80cSmrg    {
64349c9ff80cSmrg#endif
64359c9ff80cSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
64369c9ff80cSmrg	{
64379c9ff80cSmrg	  concat_name = xstrdup (wrapper);
64389c9ff80cSmrg	  if (check_executable (concat_name))
64399c9ff80cSmrg	    return concat_name;
64409c9ff80cSmrg	  XFREE (concat_name);
64419c9ff80cSmrg	}
6442d21ab8bcSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
64439c9ff80cSmrg    }
64449c9ff80cSmrg#endif
64451f0ac6a5Smrg
64469c9ff80cSmrg  for (p = wrapper; *p; p++)
64479c9ff80cSmrg    if (*p == '/')
64489c9ff80cSmrg      {
64499c9ff80cSmrg	has_slash = 1;
64509c9ff80cSmrg	break;
64519c9ff80cSmrg      }
64529c9ff80cSmrg  if (!has_slash)
64539c9ff80cSmrg    {
64549c9ff80cSmrg      /* no slashes; search PATH */
64559c9ff80cSmrg      const char *path = getenv ("PATH");
64569c9ff80cSmrg      if (path != NULL)
64579c9ff80cSmrg	{
64589c9ff80cSmrg	  for (p = path; *p; p = p_next)
64599c9ff80cSmrg	    {
64609c9ff80cSmrg	      const char *q;
64619c9ff80cSmrg	      size_t p_len;
64629c9ff80cSmrg	      for (q = p; *q; q++)
64639c9ff80cSmrg		if (IS_PATH_SEPARATOR (*q))
64649c9ff80cSmrg		  break;
6465d21ab8bcSmrg	      p_len = (size_t) (q - p);
64669c9ff80cSmrg	      p_next = (*q == '\0' ? q : q + 1);
64679c9ff80cSmrg	      if (p_len == 0)
64689c9ff80cSmrg		{
64699c9ff80cSmrg		  /* empty path: current directory */
64709c9ff80cSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
64716fae4e5dSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
64726fae4e5dSmrg                              nonnull (strerror (errno)));
64739c9ff80cSmrg		  tmp_len = strlen (tmp);
64749c9ff80cSmrg		  concat_name =
64759c9ff80cSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
64769c9ff80cSmrg		  memcpy (concat_name, tmp, tmp_len);
64779c9ff80cSmrg		  concat_name[tmp_len] = '/';
64789c9ff80cSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
64799c9ff80cSmrg		}
64809c9ff80cSmrg	      else
64819c9ff80cSmrg		{
64829c9ff80cSmrg		  concat_name =
64839c9ff80cSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
64849c9ff80cSmrg		  memcpy (concat_name, p, p_len);
64859c9ff80cSmrg		  concat_name[p_len] = '/';
64869c9ff80cSmrg		  strcpy (concat_name + p_len + 1, wrapper);
64879c9ff80cSmrg		}
64889c9ff80cSmrg	      if (check_executable (concat_name))
64899c9ff80cSmrg		return concat_name;
64909c9ff80cSmrg	      XFREE (concat_name);
64919c9ff80cSmrg	    }
64929c9ff80cSmrg	}
64939c9ff80cSmrg      /* not found in PATH; assume curdir */
64949c9ff80cSmrg    }
64959c9ff80cSmrg  /* Relative path | not found in path: prepend cwd */
64969c9ff80cSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
64976fae4e5dSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
64986fae4e5dSmrg              nonnull (strerror (errno)));
64999c9ff80cSmrg  tmp_len = strlen (tmp);
65009c9ff80cSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
65019c9ff80cSmrg  memcpy (concat_name, tmp, tmp_len);
65029c9ff80cSmrg  concat_name[tmp_len] = '/';
65039c9ff80cSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
65041f0ac6a5Smrg
65059c9ff80cSmrg  if (check_executable (concat_name))
65069c9ff80cSmrg    return concat_name;
65079c9ff80cSmrg  XFREE (concat_name);
65089c9ff80cSmrg  return NULL;
65099c9ff80cSmrg}
65101f0ac6a5Smrg
65119c9ff80cSmrgchar *
65129c9ff80cSmrgchase_symlinks (const char *pathspec)
65139c9ff80cSmrg{
65149c9ff80cSmrg#ifndef S_ISLNK
65159c9ff80cSmrg  return xstrdup (pathspec);
65169c9ff80cSmrg#else
65179c9ff80cSmrg  char buf[LT_PATHMAX];
65189c9ff80cSmrg  struct stat s;
65199c9ff80cSmrg  char *tmp_pathspec = xstrdup (pathspec);
65209c9ff80cSmrg  char *p;
65219c9ff80cSmrg  int has_symlinks = 0;
65229c9ff80cSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
65239c9ff80cSmrg    {
65246fae4e5dSmrg      lt_debugprintf (__FILE__, __LINE__,
65256fae4e5dSmrg		      "checking path component for symlinks: %s\n",
65266fae4e5dSmrg		      tmp_pathspec);
65279c9ff80cSmrg      if (lstat (tmp_pathspec, &s) == 0)
65289c9ff80cSmrg	{
65299c9ff80cSmrg	  if (S_ISLNK (s.st_mode) != 0)
65309c9ff80cSmrg	    {
65319c9ff80cSmrg	      has_symlinks = 1;
65329c9ff80cSmrg	      break;
65339c9ff80cSmrg	    }
65341f0ac6a5Smrg
65359c9ff80cSmrg	  /* search backwards for last DIR_SEPARATOR */
65369c9ff80cSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
65379c9ff80cSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
65389c9ff80cSmrg	    p--;
65399c9ff80cSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
65409c9ff80cSmrg	    {
65419c9ff80cSmrg	      /* no more DIR_SEPARATORS left */
65429c9ff80cSmrg	      break;
65439c9ff80cSmrg	    }
65449c9ff80cSmrg	  *p = '\0';
65459c9ff80cSmrg	}
65469c9ff80cSmrg      else
65479c9ff80cSmrg	{
65486fae4e5dSmrg	  lt_fatal (__FILE__, __LINE__,
65496fae4e5dSmrg		    "error accessing file \"%s\": %s",
65506fae4e5dSmrg		    tmp_pathspec, nonnull (strerror (errno)));
65519c9ff80cSmrg	}
65529c9ff80cSmrg    }
65539c9ff80cSmrg  XFREE (tmp_pathspec);
65541f0ac6a5Smrg
65559c9ff80cSmrg  if (!has_symlinks)
65569c9ff80cSmrg    {
65579c9ff80cSmrg      return xstrdup (pathspec);
65589c9ff80cSmrg    }
65591f0ac6a5Smrg
65609c9ff80cSmrg  tmp_pathspec = realpath (pathspec, buf);
65619c9ff80cSmrg  if (tmp_pathspec == 0)
65629c9ff80cSmrg    {
65636fae4e5dSmrg      lt_fatal (__FILE__, __LINE__,
65646fae4e5dSmrg		"could not follow symlinks for %s", pathspec);
65659c9ff80cSmrg    }
65669c9ff80cSmrg  return xstrdup (tmp_pathspec);
65679c9ff80cSmrg#endif
65689c9ff80cSmrg}
65691f0ac6a5Smrg
65709c9ff80cSmrgchar *
65719c9ff80cSmrgstrendzap (char *str, const char *pat)
65729c9ff80cSmrg{
65739c9ff80cSmrg  size_t len, patlen;
65741f0ac6a5Smrg
65759c9ff80cSmrg  assert (str != NULL);
65769c9ff80cSmrg  assert (pat != NULL);
65771f0ac6a5Smrg
65789c9ff80cSmrg  len = strlen (str);
65799c9ff80cSmrg  patlen = strlen (pat);
65801f0ac6a5Smrg
65819c9ff80cSmrg  if (patlen <= len)
65829c9ff80cSmrg    {
65839c9ff80cSmrg      str += len - patlen;
6584d21ab8bcSmrg      if (STREQ (str, pat))
65859c9ff80cSmrg	*str = '\0';
65869c9ff80cSmrg    }
65879c9ff80cSmrg  return str;
65889c9ff80cSmrg}
65891f0ac6a5Smrg
65906fae4e5dSmrgvoid
65916fae4e5dSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
65926fae4e5dSmrg{
65936fae4e5dSmrg  va_list args;
65946fae4e5dSmrg  if (lt_debug)
65956fae4e5dSmrg    {
65966fae4e5dSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
65976fae4e5dSmrg      va_start (args, fmt);
65986fae4e5dSmrg      (void) vfprintf (stderr, fmt, args);
65996fae4e5dSmrg      va_end (args);
66006fae4e5dSmrg    }
66016fae4e5dSmrg}
66026fae4e5dSmrg
66039c9ff80cSmrgstatic void
66046fae4e5dSmrglt_error_core (int exit_status, const char *file,
66056fae4e5dSmrg	       int line, const char *mode,
66069c9ff80cSmrg	       const char *message, va_list ap)
66079c9ff80cSmrg{
66086fae4e5dSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
66099c9ff80cSmrg  vfprintf (stderr, message, ap);
66109c9ff80cSmrg  fprintf (stderr, ".\n");
66111f0ac6a5Smrg
66129c9ff80cSmrg  if (exit_status >= 0)
66139c9ff80cSmrg    exit (exit_status);
66149c9ff80cSmrg}
66151f0ac6a5Smrg
66169c9ff80cSmrgvoid
66176fae4e5dSmrglt_fatal (const char *file, int line, const char *message, ...)
66189c9ff80cSmrg{
66199c9ff80cSmrg  va_list ap;
66209c9ff80cSmrg  va_start (ap, message);
66216fae4e5dSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
66229c9ff80cSmrg  va_end (ap);
66239c9ff80cSmrg}
66241f0ac6a5Smrg
66256fae4e5dSmrgstatic const char *
66266fae4e5dSmrgnonnull (const char *s)
66276fae4e5dSmrg{
66286fae4e5dSmrg  return s ? s : "(null)";
66296fae4e5dSmrg}
66306fae4e5dSmrg
66316fae4e5dSmrgstatic const char *
66326fae4e5dSmrgnonempty (const char *s)
66336fae4e5dSmrg{
66346fae4e5dSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
66356fae4e5dSmrg}
66366fae4e5dSmrg
66379c9ff80cSmrgvoid
66389c9ff80cSmrglt_setenv (const char *name, const char *value)
66399c9ff80cSmrg{
66406fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__,
66416fae4e5dSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
66426fae4e5dSmrg                  nonnull (name), nonnull (value));
66439c9ff80cSmrg  {
66449c9ff80cSmrg#ifdef HAVE_SETENV
66459c9ff80cSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
66469c9ff80cSmrg    char *str = xstrdup (value);
66479c9ff80cSmrg    setenv (name, str, 1);
66489c9ff80cSmrg#else
6649d21ab8bcSmrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
66509c9ff80cSmrg    char *str = XMALLOC (char, len);
66519c9ff80cSmrg    sprintf (str, "%s=%s", name, value);
66529c9ff80cSmrg    if (putenv (str) != EXIT_SUCCESS)
66539c9ff80cSmrg      {
66549c9ff80cSmrg        XFREE (str);
66559c9ff80cSmrg      }
66569c9ff80cSmrg#endif
66579c9ff80cSmrg  }
66589c9ff80cSmrg}
66591f0ac6a5Smrg
66609c9ff80cSmrgchar *
66619c9ff80cSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
66629c9ff80cSmrg{
66639c9ff80cSmrg  char *new_value;
66649c9ff80cSmrg  if (orig_value && *orig_value)
66659c9ff80cSmrg    {
6666d21ab8bcSmrg      size_t orig_value_len = strlen (orig_value);
6667d21ab8bcSmrg      size_t add_len = strlen (add);
66689c9ff80cSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
66699c9ff80cSmrg      if (to_end)
66709c9ff80cSmrg        {
66719c9ff80cSmrg          strcpy (new_value, orig_value);
66729c9ff80cSmrg          strcpy (new_value + orig_value_len, add);
66739c9ff80cSmrg        }
66749c9ff80cSmrg      else
66759c9ff80cSmrg        {
66769c9ff80cSmrg          strcpy (new_value, add);
66779c9ff80cSmrg          strcpy (new_value + add_len, orig_value);
66789c9ff80cSmrg        }
66799c9ff80cSmrg    }
66809c9ff80cSmrg  else
66819c9ff80cSmrg    {
66829c9ff80cSmrg      new_value = xstrdup (add);
66839c9ff80cSmrg    }
66849c9ff80cSmrg  return new_value;
66859c9ff80cSmrg}
66861f0ac6a5Smrg
66879c9ff80cSmrgvoid
66889c9ff80cSmrglt_update_exe_path (const char *name, const char *value)
66899c9ff80cSmrg{
66906fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__,
66916fae4e5dSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
66926fae4e5dSmrg                  nonnull (name), nonnull (value));
66931f0ac6a5Smrg
66949c9ff80cSmrg  if (name && *name && value && *value)
66959c9ff80cSmrg    {
66969c9ff80cSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
66979c9ff80cSmrg      /* some systems can't cope with a ':'-terminated path #' */
6698d21ab8bcSmrg      size_t len = strlen (new_value);
6699d21ab8bcSmrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
67009c9ff80cSmrg        {
6701d21ab8bcSmrg          new_value[--len] = '\0';
67029c9ff80cSmrg        }
67039c9ff80cSmrg      lt_setenv (name, new_value);
67049c9ff80cSmrg      XFREE (new_value);
67059c9ff80cSmrg    }
67069c9ff80cSmrg}
67071f0ac6a5Smrg
67089c9ff80cSmrgvoid
67099c9ff80cSmrglt_update_lib_path (const char *name, const char *value)
67109c9ff80cSmrg{
67116fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__,
67126fae4e5dSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
67136fae4e5dSmrg                  nonnull (name), nonnull (value));
67141f0ac6a5Smrg
67159c9ff80cSmrg  if (name && *name && value && *value)
67169c9ff80cSmrg    {
67179c9ff80cSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
67189c9ff80cSmrg      lt_setenv (name, new_value);
67199c9ff80cSmrg      XFREE (new_value);
67209c9ff80cSmrg    }
67219c9ff80cSmrg}
67221f0ac6a5Smrg
67236fae4e5dSmrgEOF
67246fae4e5dSmrg	    case $host_os in
67256ee7d557Smrg	      mingw* | windows*)
67266fae4e5dSmrg		cat <<"EOF"
67276fae4e5dSmrg
67286fae4e5dSmrg/* Prepares an argument vector before calling spawn().
67296fae4e5dSmrg   Note that spawn() does not by itself call the command interpreter
67306fae4e5dSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
67316fae4e5dSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
67326fae4e5dSmrg         GetVersionEx(&v);
67336fae4e5dSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
67346fae4e5dSmrg      }) ? "cmd.exe" : "command.com").
67356fae4e5dSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
67366fae4e5dSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
67376fae4e5dSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
67386fae4e5dSmrg   special way:
67396fae4e5dSmrg   - Space and tab are interpreted as delimiters. They are not treated as
67406fae4e5dSmrg     delimiters if they are surrounded by double quotes: "...".
67416fae4e5dSmrg   - Unescaped double quotes are removed from the input. Their only effect is
67426fae4e5dSmrg     that within double quotes, space and tab are treated like normal
67436fae4e5dSmrg     characters.
67446fae4e5dSmrg   - Backslashes not followed by double quotes are not special.
67456fae4e5dSmrg   - But 2*n+1 backslashes followed by a double quote become
67466fae4e5dSmrg     n backslashes followed by a double quote (n >= 0):
67476fae4e5dSmrg       \" -> "
67486fae4e5dSmrg       \\\" -> \"
67496fae4e5dSmrg       \\\\\" -> \\"
67506fae4e5dSmrg */
67516fae4e5dSmrg#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"
67526fae4e5dSmrg#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"
67536fae4e5dSmrgchar **
67546fae4e5dSmrgprepare_spawn (char **argv)
67556fae4e5dSmrg{
67566fae4e5dSmrg  size_t argc;
67576fae4e5dSmrg  char **new_argv;
67586fae4e5dSmrg  size_t i;
67596fae4e5dSmrg
67606fae4e5dSmrg  /* Count number of arguments.  */
67616fae4e5dSmrg  for (argc = 0; argv[argc] != NULL; argc++)
67626fae4e5dSmrg    ;
67636fae4e5dSmrg
67646fae4e5dSmrg  /* Allocate new argument vector.  */
67656fae4e5dSmrg  new_argv = XMALLOC (char *, argc + 1);
67666fae4e5dSmrg
67676fae4e5dSmrg  /* Put quoted arguments into the new argument vector.  */
67686fae4e5dSmrg  for (i = 0; i < argc; i++)
67696fae4e5dSmrg    {
67706fae4e5dSmrg      const char *string = argv[i];
67716fae4e5dSmrg
67726fae4e5dSmrg      if (string[0] == '\0')
67736fae4e5dSmrg	new_argv[i] = xstrdup ("\"\"");
67746fae4e5dSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
67756fae4e5dSmrg	{
67766fae4e5dSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
67776fae4e5dSmrg	  size_t length;
67786fae4e5dSmrg	  unsigned int backslashes;
67796fae4e5dSmrg	  const char *s;
67806fae4e5dSmrg	  char *quoted_string;
67816fae4e5dSmrg	  char *p;
67826fae4e5dSmrg
67836fae4e5dSmrg	  length = 0;
67846fae4e5dSmrg	  backslashes = 0;
67856fae4e5dSmrg	  if (quote_around)
67866fae4e5dSmrg	    length++;
67876fae4e5dSmrg	  for (s = string; *s != '\0'; s++)
67886fae4e5dSmrg	    {
67896fae4e5dSmrg	      char c = *s;
67906fae4e5dSmrg	      if (c == '"')
67916fae4e5dSmrg		length += backslashes + 1;
67926fae4e5dSmrg	      length++;
67936fae4e5dSmrg	      if (c == '\\')
67946fae4e5dSmrg		backslashes++;
67956fae4e5dSmrg	      else
67966fae4e5dSmrg		backslashes = 0;
67976fae4e5dSmrg	    }
67986fae4e5dSmrg	  if (quote_around)
67996fae4e5dSmrg	    length += backslashes + 1;
68006fae4e5dSmrg
68016fae4e5dSmrg	  quoted_string = XMALLOC (char, length + 1);
68026fae4e5dSmrg
68036fae4e5dSmrg	  p = quoted_string;
68046fae4e5dSmrg	  backslashes = 0;
68056fae4e5dSmrg	  if (quote_around)
68066fae4e5dSmrg	    *p++ = '"';
68076fae4e5dSmrg	  for (s = string; *s != '\0'; s++)
68086fae4e5dSmrg	    {
68096fae4e5dSmrg	      char c = *s;
68106fae4e5dSmrg	      if (c == '"')
68116fae4e5dSmrg		{
68126fae4e5dSmrg		  unsigned int j;
68136fae4e5dSmrg		  for (j = backslashes + 1; j > 0; j--)
68146fae4e5dSmrg		    *p++ = '\\';
68156fae4e5dSmrg		}
68166fae4e5dSmrg	      *p++ = c;
68176fae4e5dSmrg	      if (c == '\\')
68186fae4e5dSmrg		backslashes++;
68196fae4e5dSmrg	      else
68206fae4e5dSmrg		backslashes = 0;
68216fae4e5dSmrg	    }
68226fae4e5dSmrg	  if (quote_around)
68236fae4e5dSmrg	    {
68246fae4e5dSmrg	      unsigned int j;
68256fae4e5dSmrg	      for (j = backslashes; j > 0; j--)
68266fae4e5dSmrg		*p++ = '\\';
68276fae4e5dSmrg	      *p++ = '"';
68286fae4e5dSmrg	    }
68296fae4e5dSmrg	  *p = '\0';
68306fae4e5dSmrg
68316fae4e5dSmrg	  new_argv[i] = quoted_string;
68326fae4e5dSmrg	}
68336fae4e5dSmrg      else
68346fae4e5dSmrg	new_argv[i] = (char *) string;
68356fae4e5dSmrg    }
68366fae4e5dSmrg  new_argv[argc] = NULL;
68376fae4e5dSmrg
68386fae4e5dSmrg  return new_argv;
68396fae4e5dSmrg}
68406fae4e5dSmrgEOF
68416fae4e5dSmrg		;;
68426fae4e5dSmrg	    esac
68436fae4e5dSmrg
68446fae4e5dSmrg            cat <<"EOF"
68456fae4e5dSmrgvoid lt_dump_script (FILE* f)
68466fae4e5dSmrg{
68476fae4e5dSmrgEOF
68486fae4e5dSmrg	    func_emit_wrapper yes |
684989c04b6cSmrg	      $SED -n -e '
685089c04b6cSmrgs/^\(.\{79\}\)\(..*\)/\1\
685189c04b6cSmrg\2/
685289c04b6cSmrgh
685389c04b6cSmrgs/\([\\"]\)/\\\1/g
685489c04b6cSmrgs/$/\\n/
685589c04b6cSmrgs/\([^\n]*\).*/  fputs ("\1", f);/p
685689c04b6cSmrgg
685789c04b6cSmrgD'
68586fae4e5dSmrg            cat <<"EOF"
68596fae4e5dSmrg}
68609c9ff80cSmrgEOF
68619c9ff80cSmrg}
68629c9ff80cSmrg# end: func_emit_cwrapperexe_src
68631f0ac6a5Smrg
68646fae4e5dSmrg# func_win32_import_lib_p ARG
68656fae4e5dSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
68666fae4e5dSmrgfunc_win32_import_lib_p ()
68676fae4e5dSmrg{
6868d21ab8bcSmrg    $debug_cmd
6869d21ab8bcSmrg
68706fae4e5dSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
68716fae4e5dSmrg    *import*) : ;;
68726fae4e5dSmrg    *) false ;;
68736fae4e5dSmrg    esac
68746fae4e5dSmrg}
68756fae4e5dSmrg
6876d21ab8bcSmrg# func_suncc_cstd_abi
6877d21ab8bcSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
6878d21ab8bcSmrg# Several compiler flags select an ABI that is incompatible with the
6879d21ab8bcSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
6880d21ab8bcSmrgfunc_suncc_cstd_abi ()
6881d21ab8bcSmrg{
6882d21ab8bcSmrg    $debug_cmd
6883d21ab8bcSmrg
6884d21ab8bcSmrg    case " $compile_command " in
6885d21ab8bcSmrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
6886d21ab8bcSmrg      suncc_use_cstd_abi=no
6887d21ab8bcSmrg      ;;
6888d21ab8bcSmrg    *)
6889d21ab8bcSmrg      suncc_use_cstd_abi=yes
6890d21ab8bcSmrg      ;;
6891d21ab8bcSmrg    esac
6892d21ab8bcSmrg}
6893d21ab8bcSmrg
68949c9ff80cSmrg# func_mode_link arg...
68959c9ff80cSmrgfunc_mode_link ()
68969c9ff80cSmrg{
6897d21ab8bcSmrg    $debug_cmd
6898d21ab8bcSmrg
68999c9ff80cSmrg    case $host in
69006ee7d557Smrg    *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*)
69019c9ff80cSmrg      # It is impossible to link a dll without this setting, and
69029c9ff80cSmrg      # we shouldn't force the makefile maintainer to figure out
6903d21ab8bcSmrg      # what system we are compiling for in order to pass an extra
69049c9ff80cSmrg      # flag for every libtool invocation.
69059c9ff80cSmrg      # allow_undefined=no
69061f0ac6a5Smrg
69079c9ff80cSmrg      # FIXME: Unfortunately, there are problems with the above when trying
6908d21ab8bcSmrg      # to make a dll that has undefined symbols, in which case not
69099c9ff80cSmrg      # even a static library is built.  For now, we need to specify
69109c9ff80cSmrg      # -no-undefined on the libtool link line when we can be certain
69119c9ff80cSmrg      # that all symbols are satisfied, otherwise we get a static library.
69129c9ff80cSmrg      allow_undefined=yes
69139c9ff80cSmrg      ;;
69149c9ff80cSmrg    *)
69159c9ff80cSmrg      allow_undefined=yes
69169c9ff80cSmrg      ;;
69179c9ff80cSmrg    esac
69189c9ff80cSmrg    libtool_args=$nonopt
69199c9ff80cSmrg    base_compile="$nonopt $@"
69209c9ff80cSmrg    compile_command=$nonopt
69219c9ff80cSmrg    finalize_command=$nonopt
69221f0ac6a5Smrg
69239c9ff80cSmrg    compile_rpath=
69246ee7d557Smrg    compile_rpath_tail=
69259c9ff80cSmrg    finalize_rpath=
69269c9ff80cSmrg    compile_shlibpath=
69279c9ff80cSmrg    finalize_shlibpath=
69289c9ff80cSmrg    convenience=
69299c9ff80cSmrg    old_convenience=
69309c9ff80cSmrg    deplibs=
69319c9ff80cSmrg    old_deplibs=
69329c9ff80cSmrg    compiler_flags=
69339c9ff80cSmrg    linker_flags=
69349c9ff80cSmrg    dllsearchpath=
69359c9ff80cSmrg    lib_search_path=`pwd`
69369c9ff80cSmrg    inst_prefix_dir=
69379c9ff80cSmrg    new_inherited_linker_flags=
69381f0ac6a5Smrg
69399c9ff80cSmrg    avoid_version=no
69406fae4e5dSmrg    bindir=
69419c9ff80cSmrg    dlfiles=
69429c9ff80cSmrg    dlprefiles=
69439c9ff80cSmrg    dlself=no
69449c9ff80cSmrg    export_dynamic=no
69459c9ff80cSmrg    export_symbols=
69469c9ff80cSmrg    export_symbols_regex=
69479c9ff80cSmrg    generated=
69489c9ff80cSmrg    libobjs=
69499c9ff80cSmrg    ltlibs=
69509c9ff80cSmrg    module=no
69519c9ff80cSmrg    no_install=no
69529c9ff80cSmrg    objs=
6953d21ab8bcSmrg    os2dllname=
69549c9ff80cSmrg    non_pic_objects=
69559c9ff80cSmrg    precious_files_regex=
69569c9ff80cSmrg    prefer_static_libs=no
6957d21ab8bcSmrg    preload=false
69589c9ff80cSmrg    prev=
69599c9ff80cSmrg    prevarg=
69609c9ff80cSmrg    release=
69619c9ff80cSmrg    rpath=
69629c9ff80cSmrg    xrpath=
69639c9ff80cSmrg    perm_rpath=
69649c9ff80cSmrg    temp_rpath=
69656ee7d557Smrg    temp_rpath_tail=
69669c9ff80cSmrg    thread_safe=no
69679c9ff80cSmrg    vinfo=
69689c9ff80cSmrg    vinfo_number=no
69699c9ff80cSmrg    weak_libs=
69706ee7d557Smrg    rpath_arg=
6971d21ab8bcSmrg    single_module=$wl-single_module
69729c9ff80cSmrg    func_infer_tag $base_compile
69739c9ff80cSmrg
69749c9ff80cSmrg    # We need to know -static, to get the right output filenames.
69759c9ff80cSmrg    for arg
69769c9ff80cSmrg    do
69779c9ff80cSmrg      case $arg in
69789c9ff80cSmrg      -shared)
6979d21ab8bcSmrg	test yes != "$build_libtool_libs" \
6980d21ab8bcSmrg	  && func_fatal_configuration "cannot build a shared library"
69819c9ff80cSmrg	build_old_libs=no
69829c9ff80cSmrg	break
69839c9ff80cSmrg	;;
69849c9ff80cSmrg      -all-static | -static | -static-libtool-libs)
69859c9ff80cSmrg	case $arg in
69869c9ff80cSmrg	-all-static)
6987d21ab8bcSmrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
69889c9ff80cSmrg	    func_warning "complete static linking is impossible in this configuration"
69899c9ff80cSmrg	  fi
69909c9ff80cSmrg	  if test -n "$link_static_flag"; then
69919c9ff80cSmrg	    dlopen_self=$dlopen_self_static
69929c9ff80cSmrg	  fi
69939c9ff80cSmrg	  prefer_static_libs=yes
69949c9ff80cSmrg	  ;;
69959c9ff80cSmrg	-static)
69969c9ff80cSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
69979c9ff80cSmrg	    dlopen_self=$dlopen_self_static
69989c9ff80cSmrg	  fi
69999c9ff80cSmrg	  prefer_static_libs=built
70009c9ff80cSmrg	  ;;
70019c9ff80cSmrg	-static-libtool-libs)
70029c9ff80cSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
70039c9ff80cSmrg	    dlopen_self=$dlopen_self_static
70041f0ac6a5Smrg	  fi
70059c9ff80cSmrg	  prefer_static_libs=yes
70069c9ff80cSmrg	  ;;
70079c9ff80cSmrg	esac
70089c9ff80cSmrg	build_libtool_libs=no
70099c9ff80cSmrg	build_old_libs=yes
70109c9ff80cSmrg	break
70119c9ff80cSmrg	;;
70129c9ff80cSmrg      esac
70139c9ff80cSmrg    done
70141f0ac6a5Smrg
70159c9ff80cSmrg    # See if our shared archives depend on static archives.
70169c9ff80cSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
70171f0ac6a5Smrg
70189c9ff80cSmrg    # Go through the arguments, transforming them on the way.
70199c9ff80cSmrg    while test "$#" -gt 0; do
7020d21ab8bcSmrg      arg=$1
70219c9ff80cSmrg      shift
7022d21ab8bcSmrg      func_quote_arg pretty,unquoted "$arg"
7023d21ab8bcSmrg      qarg=$func_quote_arg_unquoted_result
7024d21ab8bcSmrg      func_append libtool_args " $func_quote_arg_result"
70251f0ac6a5Smrg
70269c9ff80cSmrg      # If the previous option needs an argument, assign it.
70279c9ff80cSmrg      if test -n "$prev"; then
70289c9ff80cSmrg	case $prev in
70299c9ff80cSmrg	output)
70309c9ff80cSmrg	  func_append compile_command " @OUTPUT@"
70319c9ff80cSmrg	  func_append finalize_command " @OUTPUT@"
70329c9ff80cSmrg	  ;;
70339c9ff80cSmrg	esac
70341f0ac6a5Smrg
70359c9ff80cSmrg	case $prev in
70366fae4e5dSmrg	bindir)
7037d21ab8bcSmrg	  bindir=$arg
70386fae4e5dSmrg	  prev=
70396fae4e5dSmrg	  continue
70406fae4e5dSmrg	  ;;
70419c9ff80cSmrg	dlfiles|dlprefiles)
7042d21ab8bcSmrg	  $preload || {
70439c9ff80cSmrg	    # Add the symbol object into the linking commands.
70449c9ff80cSmrg	    func_append compile_command " @SYMFILE@"
70459c9ff80cSmrg	    func_append finalize_command " @SYMFILE@"
7046d21ab8bcSmrg	    preload=:
7047d21ab8bcSmrg	  }
70489c9ff80cSmrg	  case $arg in
70499c9ff80cSmrg	  *.la | *.lo) ;;  # We handle these cases below.
70509c9ff80cSmrg	  force)
7051d21ab8bcSmrg	    if test no = "$dlself"; then
70529c9ff80cSmrg	      dlself=needless
70539c9ff80cSmrg	      export_dynamic=yes
70549c9ff80cSmrg	    fi
70559c9ff80cSmrg	    prev=
70569c9ff80cSmrg	    continue
70579c9ff80cSmrg	    ;;
70589c9ff80cSmrg	  self)
7059d21ab8bcSmrg	    if test dlprefiles = "$prev"; then
70609c9ff80cSmrg	      dlself=yes
7061d21ab8bcSmrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
70629c9ff80cSmrg	      dlself=yes
70631f0ac6a5Smrg	    else
70649c9ff80cSmrg	      dlself=needless
70659c9ff80cSmrg	      export_dynamic=yes
70661f0ac6a5Smrg	    fi
70679c9ff80cSmrg	    prev=
70689c9ff80cSmrg	    continue
70699c9ff80cSmrg	    ;;
70709c9ff80cSmrg	  *)
7071d21ab8bcSmrg	    if test dlfiles = "$prev"; then
70726fae4e5dSmrg	      func_append dlfiles " $arg"
70731f0ac6a5Smrg	    else
70746fae4e5dSmrg	      func_append dlprefiles " $arg"
70751f0ac6a5Smrg	    fi
70769c9ff80cSmrg	    prev=
70779c9ff80cSmrg	    continue
70789c9ff80cSmrg	    ;;
70799c9ff80cSmrg	  esac
70809c9ff80cSmrg	  ;;
70819c9ff80cSmrg	expsyms)
7082d21ab8bcSmrg	  export_symbols=$arg
70839c9ff80cSmrg	  test -f "$arg" \
7084d21ab8bcSmrg	    || func_fatal_error "symbol file '$arg' does not exist"
70859c9ff80cSmrg	  prev=
70869c9ff80cSmrg	  continue
70879c9ff80cSmrg	  ;;
70889c9ff80cSmrg	expsyms_regex)
7089d21ab8bcSmrg	  export_symbols_regex=$arg
70909c9ff80cSmrg	  prev=
70919c9ff80cSmrg	  continue
70929c9ff80cSmrg	  ;;
70939c9ff80cSmrg	framework)
70941f0ac6a5Smrg	  case $host in
70959c9ff80cSmrg	    *-*-darwin*)
70969c9ff80cSmrg	      case "$deplibs " in
70979c9ff80cSmrg		*" $qarg.ltframework "*) ;;
70986fae4e5dSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
70999c9ff80cSmrg		   ;;
71009c9ff80cSmrg	      esac
71019c9ff80cSmrg	      ;;
71021f0ac6a5Smrg	  esac
71039c9ff80cSmrg	  prev=
71049c9ff80cSmrg	  continue
71051f0ac6a5Smrg	  ;;
71069c9ff80cSmrg	inst_prefix)
7107d21ab8bcSmrg	  inst_prefix_dir=$arg
7108d21ab8bcSmrg	  prev=
7109d21ab8bcSmrg	  continue
7110d21ab8bcSmrg	  ;;
7111d21ab8bcSmrg	mllvm)
7112d21ab8bcSmrg	  # Clang does not use LLVM to link, so we can simply discard any
7113d21ab8bcSmrg	  # '-mllvm $arg' options when doing the link step.
71149c9ff80cSmrg	  prev=
71159c9ff80cSmrg	  continue
71161f0ac6a5Smrg	  ;;
71179c9ff80cSmrg	objectlist)
71189c9ff80cSmrg	  if test -f "$arg"; then
71199c9ff80cSmrg	    save_arg=$arg
71209c9ff80cSmrg	    moreargs=
71219c9ff80cSmrg	    for fil in `cat "$save_arg"`
71229c9ff80cSmrg	    do
71236fae4e5dSmrg#	      func_append moreargs " $fil"
71249c9ff80cSmrg	      arg=$fil
71259c9ff80cSmrg	      # A libtool-controlled object.
71261f0ac6a5Smrg
71279c9ff80cSmrg	      # Check to see that this really is a libtool object.
71289c9ff80cSmrg	      if func_lalib_unsafe_p "$arg"; then
71299c9ff80cSmrg		pic_object=
71309c9ff80cSmrg		non_pic_object=
71311f0ac6a5Smrg
71329c9ff80cSmrg		# Read the .lo file
71339c9ff80cSmrg		func_source "$arg"
71341f0ac6a5Smrg
71359c9ff80cSmrg		if test -z "$pic_object" ||
71369c9ff80cSmrg		   test -z "$non_pic_object" ||
7137d21ab8bcSmrg		   test none = "$pic_object" &&
7138d21ab8bcSmrg		   test none = "$non_pic_object"; then
7139d21ab8bcSmrg		  func_fatal_error "cannot find name of object for '$arg'"
71409c9ff80cSmrg		fi
71411f0ac6a5Smrg
71429c9ff80cSmrg		# Extract subdirectory from the argument.
71439c9ff80cSmrg		func_dirname "$arg" "/" ""
7144d21ab8bcSmrg		xdir=$func_dirname_result
71451f0ac6a5Smrg
7146d21ab8bcSmrg		if test none != "$pic_object"; then
71479c9ff80cSmrg		  # Prepend the subdirectory the object is found in.
7148d21ab8bcSmrg		  pic_object=$xdir$pic_object
71491f0ac6a5Smrg
7150d21ab8bcSmrg		  if test dlfiles = "$prev"; then
7151d21ab8bcSmrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
71526fae4e5dSmrg		      func_append dlfiles " $pic_object"
71539c9ff80cSmrg		      prev=
71549c9ff80cSmrg		      continue
71559c9ff80cSmrg		    else
71569c9ff80cSmrg		      # If libtool objects are unsupported, then we need to preload.
71579c9ff80cSmrg		      prev=dlprefiles
71589c9ff80cSmrg		    fi
71599c9ff80cSmrg		  fi
71601f0ac6a5Smrg
71619c9ff80cSmrg		  # CHECK ME:  I think I busted this.  -Ossama
7162d21ab8bcSmrg		  if test dlprefiles = "$prev"; then
71639c9ff80cSmrg		    # Preload the old-style object.
71646fae4e5dSmrg		    func_append dlprefiles " $pic_object"
71659c9ff80cSmrg		    prev=
71669c9ff80cSmrg		  fi
71671f0ac6a5Smrg
71689c9ff80cSmrg		  # A PIC object.
71699c9ff80cSmrg		  func_append libobjs " $pic_object"
7170d21ab8bcSmrg		  arg=$pic_object
71719c9ff80cSmrg		fi
71721f0ac6a5Smrg
71739c9ff80cSmrg		# Non-PIC object.
7174d21ab8bcSmrg		if test none != "$non_pic_object"; then
71759c9ff80cSmrg		  # Prepend the subdirectory the object is found in.
7176d21ab8bcSmrg		  non_pic_object=$xdir$non_pic_object
71771f0ac6a5Smrg
71789c9ff80cSmrg		  # A standard non-PIC object
71799c9ff80cSmrg		  func_append non_pic_objects " $non_pic_object"
7180d21ab8bcSmrg		  if test -z "$pic_object" || test none = "$pic_object"; then
7181d21ab8bcSmrg		    arg=$non_pic_object
71829c9ff80cSmrg		  fi
71839c9ff80cSmrg		else
71849c9ff80cSmrg		  # If the PIC object exists, use it instead.
71859c9ff80cSmrg		  # $xdir was prepended to $pic_object above.
7186d21ab8bcSmrg		  non_pic_object=$pic_object
71879c9ff80cSmrg		  func_append non_pic_objects " $non_pic_object"
71889c9ff80cSmrg		fi
71899c9ff80cSmrg	      else
71909c9ff80cSmrg		# Only an error if not doing a dry-run.
71919c9ff80cSmrg		if $opt_dry_run; then
71929c9ff80cSmrg		  # Extract subdirectory from the argument.
71939c9ff80cSmrg		  func_dirname "$arg" "/" ""
7194d21ab8bcSmrg		  xdir=$func_dirname_result
71959c9ff80cSmrg
71969c9ff80cSmrg		  func_lo2o "$arg"
71979c9ff80cSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
71989c9ff80cSmrg		  non_pic_object=$xdir$func_lo2o_result
71999c9ff80cSmrg		  func_append libobjs " $pic_object"
72009c9ff80cSmrg		  func_append non_pic_objects " $non_pic_object"
72019c9ff80cSmrg	        else
7202d21ab8bcSmrg		  func_fatal_error "'$arg' is not a valid libtool object"
72039c9ff80cSmrg		fi
72049c9ff80cSmrg	      fi
72059c9ff80cSmrg	    done
72061f0ac6a5Smrg	  else
7207d21ab8bcSmrg	    func_fatal_error "link input file '$arg' does not exist"
72081f0ac6a5Smrg	  fi
72099c9ff80cSmrg	  arg=$save_arg
72109c9ff80cSmrg	  prev=
72119c9ff80cSmrg	  continue
72129c9ff80cSmrg	  ;;
7213d21ab8bcSmrg	os2dllname)
7214d21ab8bcSmrg	  os2dllname=$arg
7215d21ab8bcSmrg	  prev=
7216d21ab8bcSmrg	  continue
7217d21ab8bcSmrg	  ;;
72189c9ff80cSmrg	precious_regex)
7219d21ab8bcSmrg	  precious_files_regex=$arg
72209c9ff80cSmrg	  prev=
72219c9ff80cSmrg	  continue
72229c9ff80cSmrg	  ;;
72239c9ff80cSmrg	release)
7224d21ab8bcSmrg	  release=-$arg
72259c9ff80cSmrg	  prev=
72269c9ff80cSmrg	  continue
72279c9ff80cSmrg	  ;;
72289c9ff80cSmrg	rpath | xrpath)
72299c9ff80cSmrg	  # We need an absolute path.
72309c9ff80cSmrg	  case $arg in
72319c9ff80cSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
72329c9ff80cSmrg	  *)
72336ee7d557Smrg	    func_fatal_error "argument to -rpath is not absolute: $arg"
72349c9ff80cSmrg	    ;;
72359c9ff80cSmrg	  esac
7236d21ab8bcSmrg	  if test rpath = "$prev"; then
72379c9ff80cSmrg	    case "$rpath " in
72389c9ff80cSmrg	    *" $arg "*) ;;
72396fae4e5dSmrg	    *) func_append rpath " $arg" ;;
72409c9ff80cSmrg	    esac
72411f0ac6a5Smrg	  else
72429c9ff80cSmrg	    case "$xrpath " in
72439c9ff80cSmrg	    *" $arg "*) ;;
72446fae4e5dSmrg	    *) func_append xrpath " $arg" ;;
72459c9ff80cSmrg	    esac
72461f0ac6a5Smrg	  fi
72479c9ff80cSmrg	  prev=
72489c9ff80cSmrg	  continue
72499c9ff80cSmrg	  ;;
72509c9ff80cSmrg	shrext)
7251d21ab8bcSmrg	  shrext_cmds=$arg
72529c9ff80cSmrg	  prev=
72539c9ff80cSmrg	  continue
72549c9ff80cSmrg	  ;;
72559c9ff80cSmrg	weak)
72566fae4e5dSmrg	  func_append weak_libs " $arg"
72579c9ff80cSmrg	  prev=
72589c9ff80cSmrg	  continue
72599c9ff80cSmrg	  ;;
7260d21ab8bcSmrg	xassembler)
7261d21ab8bcSmrg	  func_append compiler_flags " -Xassembler $qarg"
7262d21ab8bcSmrg	  prev=
7263d21ab8bcSmrg	  func_append compile_command " -Xassembler $qarg"
7264d21ab8bcSmrg	  func_append finalize_command " -Xassembler $qarg"
7265d21ab8bcSmrg	  continue
7266d21ab8bcSmrg	  ;;
72679c9ff80cSmrg	xcclinker)
72686fae4e5dSmrg	  func_append linker_flags " $qarg"
72696fae4e5dSmrg	  func_append compiler_flags " $qarg"
72709c9ff80cSmrg	  prev=
72719c9ff80cSmrg	  func_append compile_command " $qarg"
72729c9ff80cSmrg	  func_append finalize_command " $qarg"
72739c9ff80cSmrg	  continue
72749c9ff80cSmrg	  ;;
72759c9ff80cSmrg	xcompiler)
72766fae4e5dSmrg	  func_append compiler_flags " $qarg"
72779c9ff80cSmrg	  prev=
72789c9ff80cSmrg	  func_append compile_command " $qarg"
72799c9ff80cSmrg	  func_append finalize_command " $qarg"
72809c9ff80cSmrg	  continue
72819c9ff80cSmrg	  ;;
72829c9ff80cSmrg	xlinker)
72836fae4e5dSmrg	  func_append linker_flags " $qarg"
72846fae4e5dSmrg	  func_append compiler_flags " $wl$qarg"
72859c9ff80cSmrg	  prev=
72869c9ff80cSmrg	  func_append compile_command " $wl$qarg"
72879c9ff80cSmrg	  func_append finalize_command " $wl$qarg"
72889c9ff80cSmrg	  continue
72899c9ff80cSmrg	  ;;
72909c9ff80cSmrg	*)
72919c9ff80cSmrg	  eval "$prev=\"\$arg\""
72929c9ff80cSmrg	  prev=
72939c9ff80cSmrg	  continue
72949c9ff80cSmrg	  ;;
72951f0ac6a5Smrg	esac
72969c9ff80cSmrg      fi # test -n "$prev"
72971f0ac6a5Smrg
7298d21ab8bcSmrg      prevarg=$arg
72991f0ac6a5Smrg
73009c9ff80cSmrg      case $arg in
73019c9ff80cSmrg      -all-static)
73029c9ff80cSmrg	if test -n "$link_static_flag"; then
73039c9ff80cSmrg	  # See comment for -static flag below, for more details.
73049c9ff80cSmrg	  func_append compile_command " $link_static_flag"
73059c9ff80cSmrg	  func_append finalize_command " $link_static_flag"
73069c9ff80cSmrg	fi
73079c9ff80cSmrg	continue
73089c9ff80cSmrg	;;
73091f0ac6a5Smrg
73109c9ff80cSmrg      -allow-undefined)
73119c9ff80cSmrg	# FIXME: remove this flag sometime in the future.
7312d21ab8bcSmrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
73139c9ff80cSmrg	;;
73141f0ac6a5Smrg
73159c9ff80cSmrg      -avoid-version)
73169c9ff80cSmrg	avoid_version=yes
73179c9ff80cSmrg	continue
73189c9ff80cSmrg	;;
73191f0ac6a5Smrg
73206fae4e5dSmrg      -bindir)
73216fae4e5dSmrg	prev=bindir
73226fae4e5dSmrg	continue
73236fae4e5dSmrg	;;
73246fae4e5dSmrg
73259c9ff80cSmrg      -dlopen)
73269c9ff80cSmrg	prev=dlfiles
73279c9ff80cSmrg	continue
73289c9ff80cSmrg	;;
73291f0ac6a5Smrg
73309c9ff80cSmrg      -dlpreopen)
73319c9ff80cSmrg	prev=dlprefiles
73329c9ff80cSmrg	continue
73339c9ff80cSmrg	;;
73341f0ac6a5Smrg
73359c9ff80cSmrg      -export-dynamic)
73369c9ff80cSmrg	export_dynamic=yes
73379c9ff80cSmrg	continue
73389c9ff80cSmrg	;;
73391f0ac6a5Smrg
73409c9ff80cSmrg      -export-symbols | -export-symbols-regex)
73419c9ff80cSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
73429c9ff80cSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
73439c9ff80cSmrg	fi
7344d21ab8bcSmrg	if test X-export-symbols = "X$arg"; then
73459c9ff80cSmrg	  prev=expsyms
73469c9ff80cSmrg	else
73479c9ff80cSmrg	  prev=expsyms_regex
73489c9ff80cSmrg	fi
73499c9ff80cSmrg	continue
73509c9ff80cSmrg	;;
73511f0ac6a5Smrg
73529c9ff80cSmrg      -framework)
73539c9ff80cSmrg	prev=framework
73549c9ff80cSmrg	continue
73559c9ff80cSmrg	;;
73561f0ac6a5Smrg
73579c9ff80cSmrg      -inst-prefix-dir)
73589c9ff80cSmrg	prev=inst_prefix
73599c9ff80cSmrg	continue
73609c9ff80cSmrg	;;
73611f0ac6a5Smrg
73629c9ff80cSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
73639c9ff80cSmrg      # so, if we see these flags be careful not to treat them like -L
73649c9ff80cSmrg      -L[A-Z][A-Z]*:*)
73659c9ff80cSmrg	case $with_gcc/$host in
73669c9ff80cSmrg	no/*-*-irix* | /*-*-irix*)
73679c9ff80cSmrg	  func_append compile_command " $arg"
73689c9ff80cSmrg	  func_append finalize_command " $arg"
73699c9ff80cSmrg	  ;;
73709c9ff80cSmrg	esac
73719c9ff80cSmrg	continue
73729c9ff80cSmrg	;;
73731f0ac6a5Smrg
73749c9ff80cSmrg      -L*)
73756fae4e5dSmrg	func_stripname "-L" '' "$arg"
73766fae4e5dSmrg	if test -z "$func_stripname_result"; then
73779c9ff80cSmrg	  if test "$#" -gt 0; then
7378d21ab8bcSmrg	    func_fatal_error "require no space between '-L' and '$1'"
73799c9ff80cSmrg	  else
7380d21ab8bcSmrg	    func_fatal_error "need path for '-L' option"
73819c9ff80cSmrg	  fi
73829c9ff80cSmrg	fi
73836fae4e5dSmrg	func_resolve_sysroot "$func_stripname_result"
73846fae4e5dSmrg	dir=$func_resolve_sysroot_result
73859c9ff80cSmrg	# We need an absolute path.
73869c9ff80cSmrg	case $dir in
73879c9ff80cSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
73889c9ff80cSmrg	*)
73899c9ff80cSmrg	  absdir=`cd "$dir" && pwd`
73909c9ff80cSmrg	  test -z "$absdir" && \
7391d21ab8bcSmrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
7392d21ab8bcSmrg	  dir=$absdir
73939c9ff80cSmrg	  ;;
73949c9ff80cSmrg	esac
73959c9ff80cSmrg	case "$deplibs " in
73966fae4e5dSmrg	*" -L$dir "* | *" $arg "*)
73976fae4e5dSmrg	  # Will only happen for absolute or sysroot arguments
73986fae4e5dSmrg	  ;;
73999c9ff80cSmrg	*)
74006fae4e5dSmrg	  # Preserve sysroot, but never include relative directories
74016fae4e5dSmrg	  case $dir in
74026fae4e5dSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
74036fae4e5dSmrg	    *) func_append deplibs " -L$dir" ;;
74046fae4e5dSmrg	  esac
74056fae4e5dSmrg	  func_append lib_search_path " $dir"
74069c9ff80cSmrg	  ;;
74079c9ff80cSmrg	esac
74089c9ff80cSmrg	case $host in
74096ee7d557Smrg	*-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*)
74106fae4e5dSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
74119c9ff80cSmrg	  case :$dllsearchpath: in
74129c9ff80cSmrg	  *":$dir:"*) ;;
74139c9ff80cSmrg	  ::) dllsearchpath=$dir;;
74146fae4e5dSmrg	  *) func_append dllsearchpath ":$dir";;
74159c9ff80cSmrg	  esac
74169c9ff80cSmrg	  case :$dllsearchpath: in
74179c9ff80cSmrg	  *":$testbindir:"*) ;;
74189c9ff80cSmrg	  ::) dllsearchpath=$testbindir;;
74196fae4e5dSmrg	  *) func_append dllsearchpath ":$testbindir";;
74209c9ff80cSmrg	  esac
74219c9ff80cSmrg	  ;;
74229c9ff80cSmrg	esac
74239c9ff80cSmrg	continue
74249c9ff80cSmrg	;;
74251f0ac6a5Smrg
74269c9ff80cSmrg      -l*)
7427d21ab8bcSmrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
74289c9ff80cSmrg	  case $host in
74296ee7d557Smrg	  *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
74309c9ff80cSmrg	    # These systems don't actually have a C or math library (as such)
74319c9ff80cSmrg	    continue
74329c9ff80cSmrg	    ;;
74339c9ff80cSmrg	  *-*-os2*)
74349c9ff80cSmrg	    # These systems don't actually have a C library (as such)
7435d21ab8bcSmrg	    test X-lc = "X$arg" && continue
74369c9ff80cSmrg	    ;;
74376ee7d557Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
74389c9ff80cSmrg	    # Do not include libc due to us having libc/libc_r.
7439d21ab8bcSmrg	    test X-lc = "X$arg" && continue
74409c9ff80cSmrg	    ;;
74419c9ff80cSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
74429c9ff80cSmrg	    # Rhapsody C and math libraries are in the System framework
74436fae4e5dSmrg	    func_append deplibs " System.ltframework"
74449c9ff80cSmrg	    continue
74459c9ff80cSmrg	    ;;
74469c9ff80cSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
74479c9ff80cSmrg	    # Causes problems with __ctype
7448d21ab8bcSmrg	    test X-lc = "X$arg" && continue
74499c9ff80cSmrg	    ;;
74509c9ff80cSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
74519c9ff80cSmrg	    # Compiler inserts libc in the correct place for threads to work
7452d21ab8bcSmrg	    test X-lc = "X$arg" && continue
74539c9ff80cSmrg	    ;;
74549c9ff80cSmrg	  esac
7455d21ab8bcSmrg	elif test X-lc_r = "X$arg"; then
74569c9ff80cSmrg	 case $host in
74576ee7d557Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
74589c9ff80cSmrg	   # Do not include libc_r directly, use -pthread flag.
74599c9ff80cSmrg	   continue
74609c9ff80cSmrg	   ;;
74619c9ff80cSmrg	 esac
74629c9ff80cSmrg	fi
74636fae4e5dSmrg	func_append deplibs " $arg"
74649c9ff80cSmrg	continue
74659c9ff80cSmrg	;;
74661f0ac6a5Smrg
7467d21ab8bcSmrg      -mllvm)
7468d21ab8bcSmrg	prev=mllvm
7469d21ab8bcSmrg	continue
7470d21ab8bcSmrg	;;
7471d21ab8bcSmrg
74729c9ff80cSmrg      -module)
74739c9ff80cSmrg	module=yes
74749c9ff80cSmrg	continue
74759c9ff80cSmrg	;;
74761f0ac6a5Smrg
74779c9ff80cSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
74789c9ff80cSmrg      # classes, name mangling, and exception handling.
74799c9ff80cSmrg      # Darwin uses the -arch flag to determine output architecture.
74806ee7d557Smrg      # -q <option> for IBM XL C/C++ compiler.
74816ee7d557Smrg      -model|-arch|-isysroot|--sysroot|-q)
74826fae4e5dSmrg	func_append compiler_flags " $arg"
74839c9ff80cSmrg	func_append compile_command " $arg"
74849c9ff80cSmrg	func_append finalize_command " $arg"
74859c9ff80cSmrg	prev=xcompiler
74869c9ff80cSmrg	continue
74879c9ff80cSmrg	;;
7488d21ab8bcSmrg     # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199.
7489d21ab8bcSmrg     -pthread)
7490d21ab8bcSmrg	case $host in
7491d21ab8bcSmrg	  *solaris2*) ;;
7492d21ab8bcSmrg	  *)
7493d21ab8bcSmrg	    case "$new_inherited_linker_flags " in
7494d21ab8bcSmrg	        *" $arg "*) ;;
7495d21ab8bcSmrg	        * ) func_append new_inherited_linker_flags " $arg" ;;
7496d21ab8bcSmrg	    esac
7497d21ab8bcSmrg	  ;;
7498d21ab8bcSmrg	esac
7499d21ab8bcSmrg	continue
7500d21ab8bcSmrg	;;
7501d21ab8bcSmrg      -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \
75026ee7d557Smrg      |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
75036fae4e5dSmrg	func_append compiler_flags " $arg"
75049c9ff80cSmrg	func_append compile_command " $arg"
75059c9ff80cSmrg	func_append finalize_command " $arg"
75069c9ff80cSmrg	case "$new_inherited_linker_flags " in
75079c9ff80cSmrg	    *" $arg "*) ;;
75086fae4e5dSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
75099c9ff80cSmrg	esac
75109c9ff80cSmrg	continue
75119c9ff80cSmrg	;;
75121f0ac6a5Smrg
75139c9ff80cSmrg      -multi_module)
7514d21ab8bcSmrg	single_module=$wl-multi_module
75159c9ff80cSmrg	continue
75169c9ff80cSmrg	;;
75171f0ac6a5Smrg
75189c9ff80cSmrg      -no-fast-install)
75199c9ff80cSmrg	fast_install=no
75209c9ff80cSmrg	continue
75219c9ff80cSmrg	;;
75221f0ac6a5Smrg
75239c9ff80cSmrg      -no-install)
75249c9ff80cSmrg	case $host in
75256ee7d557Smrg	*-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
75269c9ff80cSmrg	  # The PATH hackery in wrapper scripts is required on Windows
75279c9ff80cSmrg	  # and Darwin in order for the loader to find any dlls it needs.
7528d21ab8bcSmrg	  func_warning "'-no-install' is ignored for $host"
7529d21ab8bcSmrg	  func_warning "assuming '-no-fast-install' instead"
75309c9ff80cSmrg	  fast_install=no
75319c9ff80cSmrg	  ;;
75329c9ff80cSmrg	*) no_install=yes ;;
75339c9ff80cSmrg	esac
75349c9ff80cSmrg	continue
75359c9ff80cSmrg	;;
75361f0ac6a5Smrg
75379c9ff80cSmrg      -no-undefined)
75389c9ff80cSmrg	allow_undefined=no
75399c9ff80cSmrg	continue
75409c9ff80cSmrg	;;
75411f0ac6a5Smrg
75429c9ff80cSmrg      -objectlist)
75439c9ff80cSmrg	prev=objectlist
75449c9ff80cSmrg	continue
75459c9ff80cSmrg	;;
75461f0ac6a5Smrg
7547d21ab8bcSmrg      -os2dllname)
7548d21ab8bcSmrg	prev=os2dllname
7549d21ab8bcSmrg	continue
7550d21ab8bcSmrg	;;
7551d21ab8bcSmrg
75529c9ff80cSmrg      -o) prev=output ;;
75531f0ac6a5Smrg
75549c9ff80cSmrg      -precious-files-regex)
75559c9ff80cSmrg	prev=precious_regex
75569c9ff80cSmrg	continue
75579c9ff80cSmrg	;;
75581f0ac6a5Smrg
75599c9ff80cSmrg      -release)
75609c9ff80cSmrg	prev=release
75619c9ff80cSmrg	continue
75629c9ff80cSmrg	;;
75631f0ac6a5Smrg
75649c9ff80cSmrg      -rpath)
75659c9ff80cSmrg	prev=rpath
75669c9ff80cSmrg	continue
75679c9ff80cSmrg	;;
75681f0ac6a5Smrg
75699c9ff80cSmrg      -R)
75709c9ff80cSmrg	prev=xrpath
75719c9ff80cSmrg	continue
75729c9ff80cSmrg	;;
75731f0ac6a5Smrg
75749c9ff80cSmrg      -R*)
75759c9ff80cSmrg	func_stripname '-R' '' "$arg"
75769c9ff80cSmrg	dir=$func_stripname_result
75779c9ff80cSmrg	# We need an absolute path.
75789c9ff80cSmrg	case $dir in
75799c9ff80cSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
75806fae4e5dSmrg	=*)
75816fae4e5dSmrg	  func_stripname '=' '' "$dir"
75826fae4e5dSmrg	  dir=$lt_sysroot$func_stripname_result
75836fae4e5dSmrg	  ;;
75849c9ff80cSmrg	*)
75856ee7d557Smrg	  func_fatal_error "argument ($arg) to '-R' is not an absolute path: $dir"
75869c9ff80cSmrg	  ;;
75879c9ff80cSmrg	esac
75889c9ff80cSmrg	case "$xrpath " in
75899c9ff80cSmrg	*" $dir "*) ;;
75906fae4e5dSmrg	*) func_append xrpath " $dir" ;;
75919c9ff80cSmrg	esac
75929c9ff80cSmrg	continue
75939c9ff80cSmrg	;;
75941f0ac6a5Smrg
75959c9ff80cSmrg      -shared)
75969c9ff80cSmrg	# The effects of -shared are defined in a previous loop.
75979c9ff80cSmrg	continue
75989c9ff80cSmrg	;;
75991f0ac6a5Smrg
76009c9ff80cSmrg      -shrext)
76019c9ff80cSmrg	prev=shrext
76029c9ff80cSmrg	continue
76039c9ff80cSmrg	;;
76041f0ac6a5Smrg
76059c9ff80cSmrg      -static | -static-libtool-libs)
76069c9ff80cSmrg	# The effects of -static are defined in a previous loop.
76079c9ff80cSmrg	# We used to do the same as -all-static on platforms that
76089c9ff80cSmrg	# didn't have a PIC flag, but the assumption that the effects
76099c9ff80cSmrg	# would be equivalent was wrong.  It would break on at least
76109c9ff80cSmrg	# Digital Unix and AIX.
76119c9ff80cSmrg	continue
76129c9ff80cSmrg	;;
76131f0ac6a5Smrg
76149c9ff80cSmrg      -thread-safe)
76159c9ff80cSmrg	thread_safe=yes
76169c9ff80cSmrg	continue
76179c9ff80cSmrg	;;
76181f0ac6a5Smrg
76199c9ff80cSmrg      -version-info)
76209c9ff80cSmrg	prev=vinfo
76219c9ff80cSmrg	continue
76229c9ff80cSmrg	;;
76231f0ac6a5Smrg
76249c9ff80cSmrg      -version-number)
76259c9ff80cSmrg	prev=vinfo
76269c9ff80cSmrg	vinfo_number=yes
76279c9ff80cSmrg	continue
76289c9ff80cSmrg	;;
76291f0ac6a5Smrg
76309c9ff80cSmrg      -weak)
76319c9ff80cSmrg        prev=weak
76329c9ff80cSmrg	continue
76339c9ff80cSmrg	;;
76341f0ac6a5Smrg
76359c9ff80cSmrg      -Wc,*)
76369c9ff80cSmrg	func_stripname '-Wc,' '' "$arg"
76379c9ff80cSmrg	args=$func_stripname_result
76389c9ff80cSmrg	arg=
7639d21ab8bcSmrg	save_ifs=$IFS; IFS=,
76409c9ff80cSmrg	for flag in $args; do
7641d21ab8bcSmrg	  IFS=$save_ifs
7642d21ab8bcSmrg          func_quote_arg pretty "$flag"
7643d21ab8bcSmrg	  func_append arg " $func_quote_arg_result"
7644d21ab8bcSmrg	  func_append compiler_flags " $func_quote_arg_result"
76459c9ff80cSmrg	done
7646d21ab8bcSmrg	IFS=$save_ifs
76479c9ff80cSmrg	func_stripname ' ' '' "$arg"
76489c9ff80cSmrg	arg=$func_stripname_result
76499c9ff80cSmrg	;;
76501f0ac6a5Smrg
76519c9ff80cSmrg      -Wl,*)
76529c9ff80cSmrg	func_stripname '-Wl,' '' "$arg"
76539c9ff80cSmrg	args=$func_stripname_result
76549c9ff80cSmrg	arg=
7655d21ab8bcSmrg	save_ifs=$IFS; IFS=,
76569c9ff80cSmrg	for flag in $args; do
7657d21ab8bcSmrg	  IFS=$save_ifs
7658d21ab8bcSmrg          func_quote_arg pretty "$flag"
7659d21ab8bcSmrg	  func_append arg " $wl$func_quote_arg_result"
7660d21ab8bcSmrg	  func_append compiler_flags " $wl$func_quote_arg_result"
7661d21ab8bcSmrg	  func_append linker_flags " $func_quote_arg_result"
76629c9ff80cSmrg	done
7663d21ab8bcSmrg	IFS=$save_ifs
76649c9ff80cSmrg	func_stripname ' ' '' "$arg"
76659c9ff80cSmrg	arg=$func_stripname_result
76669c9ff80cSmrg	;;
76671f0ac6a5Smrg
7668d21ab8bcSmrg      -Xassembler)
7669d21ab8bcSmrg        prev=xassembler
7670d21ab8bcSmrg        continue
7671d21ab8bcSmrg        ;;
7672d21ab8bcSmrg
76739c9ff80cSmrg      -Xcompiler)
76749c9ff80cSmrg	prev=xcompiler
76759c9ff80cSmrg	continue
76769c9ff80cSmrg	;;
76771f0ac6a5Smrg
76789c9ff80cSmrg      -Xlinker)
76799c9ff80cSmrg	prev=xlinker
76809c9ff80cSmrg	continue
76819c9ff80cSmrg	;;
76821f0ac6a5Smrg
76839c9ff80cSmrg      -XCClinker)
76849c9ff80cSmrg	prev=xcclinker
76859c9ff80cSmrg	continue
76869c9ff80cSmrg	;;
76871f0ac6a5Smrg
76889c9ff80cSmrg      # -msg_* for osf cc
76899c9ff80cSmrg      -msg_*)
7690d21ab8bcSmrg	func_quote_arg pretty "$arg"
7691d21ab8bcSmrg	arg=$func_quote_arg_result
76929c9ff80cSmrg	;;
76931f0ac6a5Smrg
76946fae4e5dSmrg      # Flags to be passed through unchanged, with rationale:
76956fae4e5dSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
76966fae4e5dSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
76976fae4e5dSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
76986fae4e5dSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
76996fae4e5dSmrg      # -q*                  compiler args for the IBM compiler
77006fae4e5dSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
77016fae4e5dSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
77026fae4e5dSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
7703d21ab8bcSmrg      # -fstack-protector*   stack protector flags for GCC
77046fae4e5dSmrg      # @file                GCC response files
77056fae4e5dSmrg      # -tp=*                Portland pgcc target processor selection
77066fae4e5dSmrg      # --sysroot=*          for sysroot support
7707d21ab8bcSmrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
7708d21ab8bcSmrg      # -specs=*             GCC specs files
7709d21ab8bcSmrg      # -stdlib=*            select c++ std lib with clang
77106ee7d557Smrg      # -fdiagnostics-color* simply affects output
77116ee7d557Smrg      # -frecord-gcc-switches used to verify flags were respected
7712d21ab8bcSmrg      # -fsanitize=*         Clang/GCC memory and address sanitizer
77136ee7d557Smrg      # -fno-sanitize*       Clang/GCC memory and address sanitizer
77146ee7d557Smrg      # -shared-libsan       Link with shared sanitizer runtimes (Clang)
77156ee7d557Smrg      # -static-libsan       Link with static sanitizer runtimes (Clang)
77166ee7d557Smrg      # -no-canonical-prefixes Do not expand any symbolic links
7717d21ab8bcSmrg      # -fuse-ld=*           Linker select flags for GCC
77186ee7d557Smrg      # -static-*            direct GCC to link specific libraries statically
77196ee7d557Smrg      # -fcilkplus           Cilk Plus language extension features for C/C++
77206ee7d557Smrg      # -rtlib=*             select c runtime lib with clang
77216ee7d557Smrg      # --unwindlib=*        select unwinder library with clang
77226ee7d557Smrg      # -f{file|debug|macro|profile}-prefix-map=* needed for lto linking
7723d21ab8bcSmrg      # -Wa,*                Pass flags directly to the assembler
77246ee7d557Smrg      # -Werror, -Werror=*   Report (specified) warnings as errors
77259c9ff80cSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
77266fae4e5dSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
77276ee7d557Smrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-no-canonical-prefixes| \
77286ee7d557Smrg      -stdlib=*|-rtlib=*|--unwindlib=*| \
77296ee7d557Smrg      -specs=*|-fsanitize=*|-fno-sanitize*|-shared-libsan|-static-libsan| \
77306ee7d557Smrg      -ffile-prefix-map=*|-fdebug-prefix-map=*|-fmacro-prefix-map=*|-fprofile-prefix-map=*| \
77316ee7d557Smrg      -fdiagnostics-color*|-frecord-gcc-switches| \
77326ee7d557Smrg      -fuse-ld=*|-static-*|-fcilkplus|-Wa,*|-Werror|-Werror=*)
7733d21ab8bcSmrg        func_quote_arg pretty "$arg"
7734d21ab8bcSmrg	arg=$func_quote_arg_result
77359c9ff80cSmrg        func_append compile_command " $arg"
77369c9ff80cSmrg        func_append finalize_command " $arg"
77376fae4e5dSmrg        func_append compiler_flags " $arg"
77389c9ff80cSmrg        continue
77399c9ff80cSmrg        ;;
77401f0ac6a5Smrg
7741d21ab8bcSmrg      -Z*)
7742d21ab8bcSmrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
7743d21ab8bcSmrg          # OS/2 uses -Zxxx to specify OS/2-specific options
7744d21ab8bcSmrg	  compiler_flags="$compiler_flags $arg"
7745d21ab8bcSmrg	  func_append compile_command " $arg"
7746d21ab8bcSmrg	  func_append finalize_command " $arg"
7747d21ab8bcSmrg	  case $arg in
7748d21ab8bcSmrg	  -Zlinker | -Zstack)
7749d21ab8bcSmrg	    prev=xcompiler
7750d21ab8bcSmrg	    ;;
7751d21ab8bcSmrg	  esac
7752d21ab8bcSmrg	  continue
7753d21ab8bcSmrg        else
7754d21ab8bcSmrg	  # Otherwise treat like 'Some other compiler flag' below
7755d21ab8bcSmrg	  func_quote_arg pretty "$arg"
7756d21ab8bcSmrg	  arg=$func_quote_arg_result
7757d21ab8bcSmrg        fi
7758d21ab8bcSmrg	;;
7759d21ab8bcSmrg
77609c9ff80cSmrg      # Some other compiler flag.
77619c9ff80cSmrg      -* | +*)
7762d21ab8bcSmrg        func_quote_arg pretty "$arg"
7763d21ab8bcSmrg	arg=$func_quote_arg_result
77649c9ff80cSmrg	;;
77651f0ac6a5Smrg
77669c9ff80cSmrg      *.$objext)
77679c9ff80cSmrg	# A standard object.
77686fae4e5dSmrg	func_append objs " $arg"
77699c9ff80cSmrg	;;
77701f0ac6a5Smrg
77719c9ff80cSmrg      *.lo)
77729c9ff80cSmrg	# A libtool-controlled object.
77731f0ac6a5Smrg
77749c9ff80cSmrg	# Check to see that this really is a libtool object.
77759c9ff80cSmrg	if func_lalib_unsafe_p "$arg"; then
77769c9ff80cSmrg	  pic_object=
77779c9ff80cSmrg	  non_pic_object=
77781f0ac6a5Smrg
77799c9ff80cSmrg	  # Read the .lo file
77809c9ff80cSmrg	  func_source "$arg"
77811f0ac6a5Smrg
77829c9ff80cSmrg	  if test -z "$pic_object" ||
77839c9ff80cSmrg	     test -z "$non_pic_object" ||
7784d21ab8bcSmrg	     test none = "$pic_object" &&
7785d21ab8bcSmrg	     test none = "$non_pic_object"; then
7786d21ab8bcSmrg	    func_fatal_error "cannot find name of object for '$arg'"
77879c9ff80cSmrg	  fi
77881f0ac6a5Smrg
77899c9ff80cSmrg	  # Extract subdirectory from the argument.
77909c9ff80cSmrg	  func_dirname "$arg" "/" ""
7791d21ab8bcSmrg	  xdir=$func_dirname_result
7792e5410a46Smrg
7793d21ab8bcSmrg	  test none = "$pic_object" || {
77949c9ff80cSmrg	    # Prepend the subdirectory the object is found in.
7795d21ab8bcSmrg	    pic_object=$xdir$pic_object
77961f0ac6a5Smrg
7797d21ab8bcSmrg	    if test dlfiles = "$prev"; then
7798d21ab8bcSmrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
77996fae4e5dSmrg		func_append dlfiles " $pic_object"
78009c9ff80cSmrg		prev=
78019c9ff80cSmrg		continue
78029c9ff80cSmrg	      else
78039c9ff80cSmrg		# If libtool objects are unsupported, then we need to preload.
78049c9ff80cSmrg		prev=dlprefiles
78059c9ff80cSmrg	      fi
78069c9ff80cSmrg	    fi
78071f0ac6a5Smrg
78089c9ff80cSmrg	    # CHECK ME:  I think I busted this.  -Ossama
7809d21ab8bcSmrg	    if test dlprefiles = "$prev"; then
78109c9ff80cSmrg	      # Preload the old-style object.
78116fae4e5dSmrg	      func_append dlprefiles " $pic_object"
78129c9ff80cSmrg	      prev=
78139c9ff80cSmrg	    fi
78141f0ac6a5Smrg
78159c9ff80cSmrg	    # A PIC object.
78169c9ff80cSmrg	    func_append libobjs " $pic_object"
7817d21ab8bcSmrg	    arg=$pic_object
7818d21ab8bcSmrg	  }
78191f0ac6a5Smrg
78209c9ff80cSmrg	  # Non-PIC object.
7821d21ab8bcSmrg	  if test none != "$non_pic_object"; then
78229c9ff80cSmrg	    # Prepend the subdirectory the object is found in.
7823d21ab8bcSmrg	    non_pic_object=$xdir$non_pic_object
78241f0ac6a5Smrg
78259c9ff80cSmrg	    # A standard non-PIC object
78269c9ff80cSmrg	    func_append non_pic_objects " $non_pic_object"
7827d21ab8bcSmrg	    if test -z "$pic_object" || test none = "$pic_object"; then
7828d21ab8bcSmrg	      arg=$non_pic_object
78299c9ff80cSmrg	    fi
78309c9ff80cSmrg	  else
78319c9ff80cSmrg	    # If the PIC object exists, use it instead.
78329c9ff80cSmrg	    # $xdir was prepended to $pic_object above.
7833d21ab8bcSmrg	    non_pic_object=$pic_object
78349c9ff80cSmrg	    func_append non_pic_objects " $non_pic_object"
78359c9ff80cSmrg	  fi
78369c9ff80cSmrg	else
78379c9ff80cSmrg	  # Only an error if not doing a dry-run.
78389c9ff80cSmrg	  if $opt_dry_run; then
78399c9ff80cSmrg	    # Extract subdirectory from the argument.
78409c9ff80cSmrg	    func_dirname "$arg" "/" ""
7841d21ab8bcSmrg	    xdir=$func_dirname_result
78429c9ff80cSmrg
78439c9ff80cSmrg	    func_lo2o "$arg"
78449c9ff80cSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
78459c9ff80cSmrg	    non_pic_object=$xdir$func_lo2o_result
78469c9ff80cSmrg	    func_append libobjs " $pic_object"
78479c9ff80cSmrg	    func_append non_pic_objects " $non_pic_object"
78489c9ff80cSmrg	  else
7849d21ab8bcSmrg	    func_fatal_error "'$arg' is not a valid libtool object"
78509c9ff80cSmrg	  fi
78519c9ff80cSmrg	fi
78529c9ff80cSmrg	;;
78531f0ac6a5Smrg
78549c9ff80cSmrg      *.$libext)
78559c9ff80cSmrg	# An archive.
78566fae4e5dSmrg	func_append deplibs " $arg"
78576fae4e5dSmrg	func_append old_deplibs " $arg"
78589c9ff80cSmrg	continue
78599c9ff80cSmrg	;;
78609c9ff80cSmrg
78619c9ff80cSmrg      *.la)
78629c9ff80cSmrg	# A libtool-controlled library.
78639c9ff80cSmrg
78646fae4e5dSmrg	func_resolve_sysroot "$arg"
7865d21ab8bcSmrg	if test dlfiles = "$prev"; then
78669c9ff80cSmrg	  # This library was specified with -dlopen.
78676fae4e5dSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
78689c9ff80cSmrg	  prev=
7869d21ab8bcSmrg	elif test dlprefiles = "$prev"; then
78709c9ff80cSmrg	  # The library was specified with -dlpreopen.
78716fae4e5dSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
78729c9ff80cSmrg	  prev=
78739c9ff80cSmrg	else
78746fae4e5dSmrg	  func_append deplibs " $func_resolve_sysroot_result"
78759c9ff80cSmrg	fi
78769c9ff80cSmrg	continue
78779c9ff80cSmrg	;;
78789c9ff80cSmrg
78799c9ff80cSmrg      # Some other compiler argument.
78809c9ff80cSmrg      *)
78819c9ff80cSmrg	# Unknown arguments in both finalize_command and compile_command need
78829c9ff80cSmrg	# to be aesthetically quoted because they are evaled later.
7883d21ab8bcSmrg	func_quote_arg pretty "$arg"
7884d21ab8bcSmrg	arg=$func_quote_arg_result
78859c9ff80cSmrg	;;
78869c9ff80cSmrg      esac # arg
78879c9ff80cSmrg
78889c9ff80cSmrg      # Now actually substitute the argument into the commands.
78899c9ff80cSmrg      if test -n "$arg"; then
78906ee7d557Smrg	if test -n "$rpath_arg"; then
78916ee7d557Smrg          func_append finalize_rpath " ${arg##*,}"
78926ee7d557Smrg	  unset rpath_arg
78936ee7d557Smrg	else
78946ee7d557Smrg	  case $arg in
78956ee7d557Smrg          -Wl,-rpath,*)
78966ee7d557Smrg	    func_append finalize_rpath " ${arg##*,}";;
78976ee7d557Smrg          -Wl,-rpath)
78986ee7d557Smrg	    rpath_arg=1;;
78996ee7d557Smrg          *)
79006ee7d557Smrg            func_append compile_command " $arg"
79016ee7d557Smrg	    func_append finalize_command " $arg"
79026ee7d557Smrg	  esac
79036ee7d557Smrg        fi
79049c9ff80cSmrg      fi
79059c9ff80cSmrg    done # argument parsing loop
79069c9ff80cSmrg
79079c9ff80cSmrg    test -n "$prev" && \
7908d21ab8bcSmrg      func_fatal_help "the '$prevarg' option requires an argument"
79099c9ff80cSmrg
7910d21ab8bcSmrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
79119c9ff80cSmrg      eval arg=\"$export_dynamic_flag_spec\"
79129c9ff80cSmrg      func_append compile_command " $arg"
79139c9ff80cSmrg      func_append finalize_command " $arg"
79149c9ff80cSmrg    fi
79159c9ff80cSmrg
79169c9ff80cSmrg    oldlibs=
79179c9ff80cSmrg    # calculate the name of the file, without its directory
79189c9ff80cSmrg    func_basename "$output"
7919d21ab8bcSmrg    outputname=$func_basename_result
7920d21ab8bcSmrg    libobjs_save=$libobjs
79219c9ff80cSmrg
79229c9ff80cSmrg    if test -n "$shlibpath_var"; then
79239c9ff80cSmrg      # get the directories listed in $shlibpath_var
7924d21ab8bcSmrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
79259c9ff80cSmrg    else
79269c9ff80cSmrg      shlib_search_path=
79279c9ff80cSmrg    fi
79289c9ff80cSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
79299c9ff80cSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
79309c9ff80cSmrg
7931d21ab8bcSmrg    # Definition is injected by LT_CONFIG during libtool generation.
7932d21ab8bcSmrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
7933d21ab8bcSmrg
79349c9ff80cSmrg    func_dirname "$output" "/" ""
7935d21ab8bcSmrg    output_objdir=$func_dirname_result$objdir
79366fae4e5dSmrg    func_to_tool_file "$output_objdir/"
79376fae4e5dSmrg    tool_output_objdir=$func_to_tool_file_result
79389c9ff80cSmrg    # Create the object directory.
79399c9ff80cSmrg    func_mkdir_p "$output_objdir"
79409c9ff80cSmrg
79419c9ff80cSmrg    # Determine the type of output
79429c9ff80cSmrg    case $output in
79439c9ff80cSmrg    "")
79449c9ff80cSmrg      func_fatal_help "you must specify an output file"
79459c9ff80cSmrg      ;;
79469c9ff80cSmrg    *.$libext) linkmode=oldlib ;;
79479c9ff80cSmrg    *.lo | *.$objext) linkmode=obj ;;
79489c9ff80cSmrg    *.la) linkmode=lib ;;
79499c9ff80cSmrg    *) linkmode=prog ;; # Anything else should be a program.
79509c9ff80cSmrg    esac
79519c9ff80cSmrg
79529c9ff80cSmrg    specialdeplibs=
79539c9ff80cSmrg
79549c9ff80cSmrg    libs=
79559c9ff80cSmrg    # Find all interdependent deplibs by searching for libraries
79569c9ff80cSmrg    # that are linked more than once (e.g. -la -lb -la)
79579c9ff80cSmrg    for deplib in $deplibs; do
7958d21ab8bcSmrg      if $opt_preserve_dup_deps; then
79599c9ff80cSmrg	case "$libs " in
79606fae4e5dSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
79619c9ff80cSmrg	esac
79629c9ff80cSmrg      fi
79636fae4e5dSmrg      func_append libs " $deplib"
79649c9ff80cSmrg    done
79659c9ff80cSmrg
7966d21ab8bcSmrg    if test lib = "$linkmode"; then
79679c9ff80cSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
79689c9ff80cSmrg
79699c9ff80cSmrg      # Compute libraries that are listed more than once in $predeps
79709c9ff80cSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
79719c9ff80cSmrg      # not to be eliminated).
79729c9ff80cSmrg      pre_post_deps=
79739c9ff80cSmrg      if $opt_duplicate_compiler_generated_deps; then
79749c9ff80cSmrg	for pre_post_dep in $predeps $postdeps; do
79759c9ff80cSmrg	  case "$pre_post_deps " in
79766fae4e5dSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
79779c9ff80cSmrg	  esac
79786fae4e5dSmrg	  func_append pre_post_deps " $pre_post_dep"
79799c9ff80cSmrg	done
79809c9ff80cSmrg      fi
79819c9ff80cSmrg      pre_post_deps=
79829c9ff80cSmrg    fi
79839c9ff80cSmrg
79849c9ff80cSmrg    deplibs=
79859c9ff80cSmrg    newdependency_libs=
79869c9ff80cSmrg    newlib_search_path=
79879c9ff80cSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
79889c9ff80cSmrg    notinst_deplibs= # not-installed libtool libraries
79899c9ff80cSmrg    notinst_path= # paths that contain not-installed libtool libraries
79909c9ff80cSmrg
79919c9ff80cSmrg    case $linkmode in
79929c9ff80cSmrg    lib)
79939c9ff80cSmrg	passes="conv dlpreopen link"
79949c9ff80cSmrg	for file in $dlfiles $dlprefiles; do
79959c9ff80cSmrg	  case $file in
79969c9ff80cSmrg	  *.la) ;;
79979c9ff80cSmrg	  *)
7998d21ab8bcSmrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
79999c9ff80cSmrg	    ;;
80009c9ff80cSmrg	  esac
80019c9ff80cSmrg	done
80029c9ff80cSmrg	;;
80039c9ff80cSmrg    prog)
80049c9ff80cSmrg	compile_deplibs=
80059c9ff80cSmrg	finalize_deplibs=
8006d21ab8bcSmrg	alldeplibs=false
80079c9ff80cSmrg	newdlfiles=
80089c9ff80cSmrg	newdlprefiles=
80099c9ff80cSmrg	passes="conv scan dlopen dlpreopen link"
80109c9ff80cSmrg	;;
80119c9ff80cSmrg    *)  passes="conv"
80129c9ff80cSmrg	;;
80139c9ff80cSmrg    esac
80149c9ff80cSmrg
80159c9ff80cSmrg    for pass in $passes; do
80169c9ff80cSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
80179c9ff80cSmrg      # so that -L comes before libs that need it for instance...
8018d21ab8bcSmrg      if test lib,link = "$linkmode,$pass"; then
80199c9ff80cSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
80209c9ff80cSmrg	##        order, and fix it there properly
80219c9ff80cSmrg        tmp_deplibs=
80229c9ff80cSmrg	for deplib in $deplibs; do
80239c9ff80cSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
80249c9ff80cSmrg	done
8025d21ab8bcSmrg	deplibs=$tmp_deplibs
80269c9ff80cSmrg      fi
80279c9ff80cSmrg
8028d21ab8bcSmrg      if test lib,link = "$linkmode,$pass" ||
8029d21ab8bcSmrg	 test prog,scan = "$linkmode,$pass"; then
8030d21ab8bcSmrg	libs=$deplibs
80319c9ff80cSmrg	deplibs=
80329c9ff80cSmrg      fi
8033d21ab8bcSmrg      if test prog = "$linkmode"; then
80349c9ff80cSmrg	case $pass in
8035d21ab8bcSmrg	dlopen) libs=$dlfiles ;;
8036d21ab8bcSmrg	dlpreopen) libs=$dlprefiles ;;
8037d21ab8bcSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
80389c9ff80cSmrg	esac
80399c9ff80cSmrg      fi
8040d21ab8bcSmrg      if test lib,dlpreopen = "$linkmode,$pass"; then
80419c9ff80cSmrg	# Collect and forward deplibs of preopened libtool libs
80429c9ff80cSmrg	for lib in $dlprefiles; do
80439c9ff80cSmrg	  # Ignore non-libtool-libs
80449c9ff80cSmrg	  dependency_libs=
80456fae4e5dSmrg	  func_resolve_sysroot "$lib"
80469c9ff80cSmrg	  case $lib in
80476fae4e5dSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
80489c9ff80cSmrg	  esac
80499c9ff80cSmrg
80509c9ff80cSmrg	  # Collect preopened libtool deplibs, except any this library
80519c9ff80cSmrg	  # has declared as weak libs
80529c9ff80cSmrg	  for deplib in $dependency_libs; do
80536fae4e5dSmrg	    func_basename "$deplib"
80546fae4e5dSmrg            deplib_base=$func_basename_result
80559c9ff80cSmrg	    case " $weak_libs " in
80569c9ff80cSmrg	    *" $deplib_base "*) ;;
80576fae4e5dSmrg	    *) func_append deplibs " $deplib" ;;
80589c9ff80cSmrg	    esac
80599c9ff80cSmrg	  done
80609c9ff80cSmrg	done
8061d21ab8bcSmrg	libs=$dlprefiles
80629c9ff80cSmrg      fi
8063d21ab8bcSmrg      if test dlopen = "$pass"; then
80649c9ff80cSmrg	# Collect dlpreopened libraries
8065d21ab8bcSmrg	save_deplibs=$deplibs
80669c9ff80cSmrg	deplibs=
80679c9ff80cSmrg      fi
80689c9ff80cSmrg
80699c9ff80cSmrg      for deplib in $libs; do
80709c9ff80cSmrg	lib=
8071d21ab8bcSmrg	found=false
80729c9ff80cSmrg	case $deplib in
807389c04b6cSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
80746ee7d557Smrg        |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
8075d21ab8bcSmrg	  if test prog,link = "$linkmode,$pass"; then
80769c9ff80cSmrg	    compile_deplibs="$deplib $compile_deplibs"
80779c9ff80cSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
80789c9ff80cSmrg	  else
80796fae4e5dSmrg	    func_append compiler_flags " $deplib"
8080d21ab8bcSmrg	    if test lib = "$linkmode"; then
80819c9ff80cSmrg		case "$new_inherited_linker_flags " in
80829c9ff80cSmrg		    *" $deplib "*) ;;
80836fae4e5dSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
80849c9ff80cSmrg		esac
80859c9ff80cSmrg	    fi
80869c9ff80cSmrg	  fi
80879c9ff80cSmrg	  continue
80889c9ff80cSmrg	  ;;
80899c9ff80cSmrg	-l*)
8090d21ab8bcSmrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
8091d21ab8bcSmrg	    func_warning "'-l' is ignored for archives/objects"
80929c9ff80cSmrg	    continue
80939c9ff80cSmrg	  fi
80949c9ff80cSmrg	  func_stripname '-l' '' "$deplib"
80959c9ff80cSmrg	  name=$func_stripname_result
8096d21ab8bcSmrg	  if test lib = "$linkmode"; then
80979c9ff80cSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
80989c9ff80cSmrg	  else
80999c9ff80cSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
81009c9ff80cSmrg	  fi
81019c9ff80cSmrg	  for searchdir in $searchdirs; do
81029c9ff80cSmrg	    for search_ext in .la $std_shrext .so .a; do
81039c9ff80cSmrg	      # Search the libtool library
8104d21ab8bcSmrg	      lib=$searchdir/lib$name$search_ext
81059c9ff80cSmrg	      if test -f "$lib"; then
8106d21ab8bcSmrg		if test .la = "$search_ext"; then
8107d21ab8bcSmrg		  found=:
81089c9ff80cSmrg		else
8109d21ab8bcSmrg		  found=false
81109c9ff80cSmrg		fi
81119c9ff80cSmrg		break 2
81129c9ff80cSmrg	      fi
81139c9ff80cSmrg	    done
81149c9ff80cSmrg	  done
8115d21ab8bcSmrg	  if $found; then
8116d21ab8bcSmrg	    # deplib is a libtool library
81179c9ff80cSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
81189c9ff80cSmrg	    # We need to do some special things here, and not later.
8119d21ab8bcSmrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
81209c9ff80cSmrg	      case " $predeps $postdeps " in
81219c9ff80cSmrg	      *" $deplib "*)
81229c9ff80cSmrg		if func_lalib_p "$lib"; then
81239c9ff80cSmrg		  library_names=
81249c9ff80cSmrg		  old_library=
81259c9ff80cSmrg		  func_source "$lib"
81269c9ff80cSmrg		  for l in $old_library $library_names; do
8127d21ab8bcSmrg		    ll=$l
81289c9ff80cSmrg		  done
8129d21ab8bcSmrg		  if test "X$ll" = "X$old_library"; then # only static version available
8130d21ab8bcSmrg		    found=false
81319c9ff80cSmrg		    func_dirname "$lib" "" "."
8132d21ab8bcSmrg		    ladir=$func_dirname_result
81339c9ff80cSmrg		    lib=$ladir/$old_library
8134d21ab8bcSmrg		    if test prog,link = "$linkmode,$pass"; then
81359c9ff80cSmrg		      compile_deplibs="$deplib $compile_deplibs"
81369c9ff80cSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
81379c9ff80cSmrg		    else
81389c9ff80cSmrg		      deplibs="$deplib $deplibs"
8139d21ab8bcSmrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
81409c9ff80cSmrg		    fi
81419c9ff80cSmrg		    continue
81429c9ff80cSmrg		  fi
81439c9ff80cSmrg		fi
81449c9ff80cSmrg		;;
81459c9ff80cSmrg	      *) ;;
81469c9ff80cSmrg	      esac
81479c9ff80cSmrg	    fi
8148d21ab8bcSmrg	  else
8149d21ab8bcSmrg	    # deplib doesn't seem to be a libtool library
8150d21ab8bcSmrg	    if test prog,link = "$linkmode,$pass"; then
8151d21ab8bcSmrg	      compile_deplibs="$deplib $compile_deplibs"
8152d21ab8bcSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
8153d21ab8bcSmrg	    else
8154d21ab8bcSmrg	      deplibs="$deplib $deplibs"
8155d21ab8bcSmrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
8156d21ab8bcSmrg	    fi
8157d21ab8bcSmrg	    continue
81589c9ff80cSmrg	  fi
81599c9ff80cSmrg	  ;; # -l
81609c9ff80cSmrg	*.ltframework)
8161d21ab8bcSmrg	  if test prog,link = "$linkmode,$pass"; then
81629c9ff80cSmrg	    compile_deplibs="$deplib $compile_deplibs"
81639c9ff80cSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
81649c9ff80cSmrg	  else
81659c9ff80cSmrg	    deplibs="$deplib $deplibs"
8166d21ab8bcSmrg	    if test lib = "$linkmode"; then
81679c9ff80cSmrg		case "$new_inherited_linker_flags " in
81689c9ff80cSmrg		    *" $deplib "*) ;;
81696fae4e5dSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
81709c9ff80cSmrg		esac
81719c9ff80cSmrg	    fi
81729c9ff80cSmrg	  fi
81739c9ff80cSmrg	  continue
81749c9ff80cSmrg	  ;;
81759c9ff80cSmrg	-L*)
81769c9ff80cSmrg	  case $linkmode in
81779c9ff80cSmrg	  lib)
81789c9ff80cSmrg	    deplibs="$deplib $deplibs"
8179d21ab8bcSmrg	    test conv = "$pass" && continue
81809c9ff80cSmrg	    newdependency_libs="$deplib $newdependency_libs"
81819c9ff80cSmrg	    func_stripname '-L' '' "$deplib"
81826fae4e5dSmrg	    func_resolve_sysroot "$func_stripname_result"
81836fae4e5dSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
81849c9ff80cSmrg	    ;;
81859c9ff80cSmrg	  prog)
8186d21ab8bcSmrg	    if test conv = "$pass"; then
81879c9ff80cSmrg	      deplibs="$deplib $deplibs"
81889c9ff80cSmrg	      continue
81899c9ff80cSmrg	    fi
8190d21ab8bcSmrg	    if test scan = "$pass"; then
81919c9ff80cSmrg	      deplibs="$deplib $deplibs"
81929c9ff80cSmrg	    else
81939c9ff80cSmrg	      compile_deplibs="$deplib $compile_deplibs"
81949c9ff80cSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
81959c9ff80cSmrg	    fi
81969c9ff80cSmrg	    func_stripname '-L' '' "$deplib"
81976fae4e5dSmrg	    func_resolve_sysroot "$func_stripname_result"
81986fae4e5dSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
81999c9ff80cSmrg	    ;;
82009c9ff80cSmrg	  *)
8201d21ab8bcSmrg	    func_warning "'-L' is ignored for archives/objects"
82029c9ff80cSmrg	    ;;
82039c9ff80cSmrg	  esac # linkmode
82049c9ff80cSmrg	  continue
82059c9ff80cSmrg	  ;; # -L
82069c9ff80cSmrg	-R*)
8207d21ab8bcSmrg	  if test link = "$pass"; then
82089c9ff80cSmrg	    func_stripname '-R' '' "$deplib"
82096fae4e5dSmrg	    func_resolve_sysroot "$func_stripname_result"
82106fae4e5dSmrg	    dir=$func_resolve_sysroot_result
82119c9ff80cSmrg	    # Make sure the xrpath contains only unique directories.
82129c9ff80cSmrg	    case "$xrpath " in
82139c9ff80cSmrg	    *" $dir "*) ;;
82146fae4e5dSmrg	    *) func_append xrpath " $dir" ;;
82159c9ff80cSmrg	    esac
82169c9ff80cSmrg	  fi
82179c9ff80cSmrg	  deplibs="$deplib $deplibs"
82189c9ff80cSmrg	  continue
82199c9ff80cSmrg	  ;;
82206fae4e5dSmrg	*.la)
82216fae4e5dSmrg	  func_resolve_sysroot "$deplib"
82226fae4e5dSmrg	  lib=$func_resolve_sysroot_result
82236fae4e5dSmrg	  ;;
82249c9ff80cSmrg	*.$libext)
8225d21ab8bcSmrg	  if test conv = "$pass"; then
82269c9ff80cSmrg	    deplibs="$deplib $deplibs"
82279c9ff80cSmrg	    continue
82289c9ff80cSmrg	  fi
82299c9ff80cSmrg	  case $linkmode in
82309c9ff80cSmrg	  lib)
82319c9ff80cSmrg	    # Linking convenience modules into shared libraries is allowed,
82329c9ff80cSmrg	    # but linking other static libraries is non-portable.
82339c9ff80cSmrg	    case " $dlpreconveniencelibs " in
82349c9ff80cSmrg	    *" $deplib "*) ;;
82359c9ff80cSmrg	    *)
8236d21ab8bcSmrg	      valid_a_lib=false
82379c9ff80cSmrg	      case $deplibs_check_method in
82389c9ff80cSmrg		match_pattern*)
82399c9ff80cSmrg		  set dummy $deplibs_check_method; shift
82409c9ff80cSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
82416fae4e5dSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
82429c9ff80cSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
8243d21ab8bcSmrg		    valid_a_lib=:
82449c9ff80cSmrg		  fi
82459c9ff80cSmrg		;;
82469c9ff80cSmrg		pass_all)
8247d21ab8bcSmrg		  valid_a_lib=:
82489c9ff80cSmrg		;;
82499c9ff80cSmrg	      esac
8250d21ab8bcSmrg	      if $valid_a_lib; then
82516ee7d557Smrg		func_warning "Linking the shared library $output against the static library $deplib is not portable!"
8252d21ab8bcSmrg		deplibs="$deplib $deplibs"
8253d21ab8bcSmrg	      else
82546ee7d557Smrg		func_warning "Trying to link with static lib archive $deplib."
82556ee7d557Smrg		func_warning "I have the capability to make that library automatically link in when"
82566ee7d557Smrg		func_warning "you link to this library.  But I can only do this if you have a"
82576ee7d557Smrg		func_warning "shared version of the library, which you do not appear to have"
82586ee7d557Smrg		func_warning "because the file extensions .$libext of this argument makes me believe"
82596ee7d557Smrg		func_warning "that it is just a static archive that I should not use here."
82609c9ff80cSmrg	      fi
82619c9ff80cSmrg	      ;;
82629c9ff80cSmrg	    esac
82639c9ff80cSmrg	    continue
82649c9ff80cSmrg	    ;;
82659c9ff80cSmrg	  prog)
8266d21ab8bcSmrg	    if test link != "$pass"; then
82679c9ff80cSmrg	      deplibs="$deplib $deplibs"
82689c9ff80cSmrg	    else
82699c9ff80cSmrg	      compile_deplibs="$deplib $compile_deplibs"
82709c9ff80cSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
82719c9ff80cSmrg	    fi
82729c9ff80cSmrg	    continue
82739c9ff80cSmrg	    ;;
82749c9ff80cSmrg	  esac # linkmode
82759c9ff80cSmrg	  ;; # *.$libext
82769c9ff80cSmrg	*.lo | *.$objext)
8277d21ab8bcSmrg	  if test conv = "$pass"; then
82789c9ff80cSmrg	    deplibs="$deplib $deplibs"
8279d21ab8bcSmrg	  elif test prog = "$linkmode"; then
8280d21ab8bcSmrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
82819c9ff80cSmrg	      # If there is no dlopen support or we're linking statically,
82829c9ff80cSmrg	      # we need to preload.
82836fae4e5dSmrg	      func_append newdlprefiles " $deplib"
82849c9ff80cSmrg	      compile_deplibs="$deplib $compile_deplibs"
82859c9ff80cSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
82869c9ff80cSmrg	    else
82876fae4e5dSmrg	      func_append newdlfiles " $deplib"
82889c9ff80cSmrg	    fi
82899c9ff80cSmrg	  fi
82909c9ff80cSmrg	  continue
82919c9ff80cSmrg	  ;;
82929c9ff80cSmrg	%DEPLIBS%)
8293d21ab8bcSmrg	  alldeplibs=:
82949c9ff80cSmrg	  continue
82959c9ff80cSmrg	  ;;
82969c9ff80cSmrg	esac # case $deplib
82979c9ff80cSmrg
8298d21ab8bcSmrg	$found || test -f "$lib" \
8299d21ab8bcSmrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
83009c9ff80cSmrg
83019c9ff80cSmrg	# Check to see that this really is a libtool archive.
83029c9ff80cSmrg	func_lalib_unsafe_p "$lib" \
8303d21ab8bcSmrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
83049c9ff80cSmrg
83059c9ff80cSmrg	func_dirname "$lib" "" "."
8306d21ab8bcSmrg	ladir=$func_dirname_result
83079c9ff80cSmrg
83089c9ff80cSmrg	dlname=
83099c9ff80cSmrg	dlopen=
83109c9ff80cSmrg	dlpreopen=
83119c9ff80cSmrg	libdir=
83129c9ff80cSmrg	library_names=
83139c9ff80cSmrg	old_library=
83149c9ff80cSmrg	inherited_linker_flags=
83159c9ff80cSmrg	# If the library was installed with an old release of libtool,
83169c9ff80cSmrg	# it will not redefine variables installed, or shouldnotlink
83179c9ff80cSmrg	installed=yes
83189c9ff80cSmrg	shouldnotlink=no
83199c9ff80cSmrg	avoidtemprpath=
83209c9ff80cSmrg
83219c9ff80cSmrg
83229c9ff80cSmrg	# Read the .la file
83239c9ff80cSmrg	func_source "$lib"
83249c9ff80cSmrg
83259c9ff80cSmrg	# Convert "-framework foo" to "foo.ltframework"
83269c9ff80cSmrg	if test -n "$inherited_linker_flags"; then
83276fae4e5dSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
83289c9ff80cSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
83299c9ff80cSmrg	    case " $new_inherited_linker_flags " in
83309c9ff80cSmrg	      *" $tmp_inherited_linker_flag "*) ;;
83316fae4e5dSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
83329c9ff80cSmrg	    esac
83339c9ff80cSmrg	  done
83349c9ff80cSmrg	fi
83356fae4e5dSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8336d21ab8bcSmrg	if test lib,link = "$linkmode,$pass" ||
8337d21ab8bcSmrg	   test prog,scan = "$linkmode,$pass" ||
8338d21ab8bcSmrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
83396fae4e5dSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
83406fae4e5dSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
83419c9ff80cSmrg	fi
83429c9ff80cSmrg
8343d21ab8bcSmrg	if test conv = "$pass"; then
83449c9ff80cSmrg	  # Only check for convenience libraries
83459c9ff80cSmrg	  deplibs="$lib $deplibs"
83469c9ff80cSmrg	  if test -z "$libdir"; then
83479c9ff80cSmrg	    if test -z "$old_library"; then
8348d21ab8bcSmrg	      func_fatal_error "cannot find name of link library for '$lib'"
83499c9ff80cSmrg	    fi
83509c9ff80cSmrg	    # It is a libtool convenience library, so add in its objects.
83516fae4e5dSmrg	    func_append convenience " $ladir/$objdir/$old_library"
83526fae4e5dSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
8353d21ab8bcSmrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
8354d21ab8bcSmrg	    func_fatal_error "'$lib' is not a convenience library"
83559c9ff80cSmrg	  fi
8356d21ab8bcSmrg	  tmp_libs=
8357d21ab8bcSmrg	  for deplib in $dependency_libs; do
8358d21ab8bcSmrg	    deplibs="$deplib $deplibs"
8359d21ab8bcSmrg	    if $opt_preserve_dup_deps; then
8360d21ab8bcSmrg	      case "$tmp_libs " in
8361d21ab8bcSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8362d21ab8bcSmrg	      esac
8363d21ab8bcSmrg	    fi
8364d21ab8bcSmrg	    func_append tmp_libs " $deplib"
8365d21ab8bcSmrg	  done
83669c9ff80cSmrg	  continue
83679c9ff80cSmrg	fi # $pass = conv
83689c9ff80cSmrg
83699c9ff80cSmrg
83709c9ff80cSmrg	# Get the name of the library we link against.
83719c9ff80cSmrg	linklib=
83726fae4e5dSmrg	if test -n "$old_library" &&
8373d21ab8bcSmrg	   { test yes = "$prefer_static_libs" ||
8374d21ab8bcSmrg	     test built,no = "$prefer_static_libs,$installed"; }; then
83756fae4e5dSmrg	  linklib=$old_library
83766fae4e5dSmrg	else
83776fae4e5dSmrg	  for l in $old_library $library_names; do
8378d21ab8bcSmrg	    linklib=$l
83796fae4e5dSmrg	  done
83806fae4e5dSmrg	fi
83819c9ff80cSmrg	if test -z "$linklib"; then
8382d21ab8bcSmrg	  func_fatal_error "cannot find name of link library for '$lib'"
83839c9ff80cSmrg	fi
83849c9ff80cSmrg
83859c9ff80cSmrg	# This library was specified with -dlopen.
8386d21ab8bcSmrg	if test dlopen = "$pass"; then
8387d21ab8bcSmrg	  test -z "$libdir" \
8388d21ab8bcSmrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
83899c9ff80cSmrg	  if test -z "$dlname" ||
8390d21ab8bcSmrg	     test yes != "$dlopen_support" ||
8391d21ab8bcSmrg	     test no = "$build_libtool_libs"
8392d21ab8bcSmrg	  then
83939c9ff80cSmrg	    # If there is no dlname, no dlopen support or we're linking
83949c9ff80cSmrg	    # statically, we need to preload.  We also need to preload any
83959c9ff80cSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
83969c9ff80cSmrg	    # bomb out in the load deplibs phase.
83976fae4e5dSmrg	    func_append dlprefiles " $lib $dependency_libs"
83989c9ff80cSmrg	  else
83996fae4e5dSmrg	    func_append newdlfiles " $lib"
84009c9ff80cSmrg	  fi
84019c9ff80cSmrg	  continue
84029c9ff80cSmrg	fi # $pass = dlopen
84039c9ff80cSmrg
84049c9ff80cSmrg	# We need an absolute path.
84059c9ff80cSmrg	case $ladir in
8406d21ab8bcSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
84079c9ff80cSmrg	*)
84089c9ff80cSmrg	  abs_ladir=`cd "$ladir" && pwd`
84099c9ff80cSmrg	  if test -z "$abs_ladir"; then
8410d21ab8bcSmrg	    func_warning "cannot determine absolute directory name of '$ladir'"
84119c9ff80cSmrg	    func_warning "passing it literally to the linker, although it might fail"
8412d21ab8bcSmrg	    abs_ladir=$ladir
84139c9ff80cSmrg	  fi
84149c9ff80cSmrg	  ;;
84159c9ff80cSmrg	esac
84169c9ff80cSmrg	func_basename "$lib"
8417d21ab8bcSmrg	laname=$func_basename_result
84189c9ff80cSmrg
84199c9ff80cSmrg	# Find the relevant object directory and library name.
8420d21ab8bcSmrg	if test yes = "$installed"; then
84216fae4e5dSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
8422d21ab8bcSmrg	    func_warning "library '$lib' was moved."
8423d21ab8bcSmrg	    dir=$ladir
8424d21ab8bcSmrg	    absdir=$abs_ladir
8425d21ab8bcSmrg	    libdir=$abs_ladir
84269c9ff80cSmrg	  else
8427d21ab8bcSmrg	    dir=$lt_sysroot$libdir
8428d21ab8bcSmrg	    absdir=$lt_sysroot$libdir
84299c9ff80cSmrg	  fi
8430d21ab8bcSmrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
84319c9ff80cSmrg	else
84329c9ff80cSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
8433d21ab8bcSmrg	    dir=$ladir
8434d21ab8bcSmrg	    absdir=$abs_ladir
84359c9ff80cSmrg	    # Remove this search path later
84366fae4e5dSmrg	    func_append notinst_path " $abs_ladir"
84379c9ff80cSmrg	  else
8438d21ab8bcSmrg	    dir=$ladir/$objdir
8439d21ab8bcSmrg	    absdir=$abs_ladir/$objdir
84409c9ff80cSmrg	    # Remove this search path later
84416fae4e5dSmrg	    func_append notinst_path " $abs_ladir"
84429c9ff80cSmrg	  fi
84439c9ff80cSmrg	fi # $installed = yes
84449c9ff80cSmrg	func_stripname 'lib' '.la' "$laname"
84459c9ff80cSmrg	name=$func_stripname_result
84469c9ff80cSmrg
84479c9ff80cSmrg	# This library was specified with -dlpreopen.
8448d21ab8bcSmrg	if test dlpreopen = "$pass"; then
8449d21ab8bcSmrg	  if test -z "$libdir" && test prog = "$linkmode"; then
8450d21ab8bcSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
84519c9ff80cSmrg	  fi
8452d21ab8bcSmrg	  case $host in
84536fae4e5dSmrg	    # special handling for platforms with PE-DLLs.
84546ee7d557Smrg	    *cygwin* | *mingw* | *windows* | *cegcc* )
84556fae4e5dSmrg	      # Linker will automatically link against shared library if both
84566fae4e5dSmrg	      # static and shared are present.  Therefore, ensure we extract
84576fae4e5dSmrg	      # symbols from the import library if a shared library is present
84586fae4e5dSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
84596fae4e5dSmrg	      # this by putting the import library name into $newdlprefiles.
84606fae4e5dSmrg	      # We recover the dlopen module name by 'saving' the la file
84616fae4e5dSmrg	      # name in a special purpose variable, and (later) extracting the
84626fae4e5dSmrg	      # dlname from the la file.
84636fae4e5dSmrg	      if test -n "$dlname"; then
84646fae4e5dSmrg	        func_tr_sh "$dir/$linklib"
84656fae4e5dSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
84666fae4e5dSmrg	        func_append newdlprefiles " $dir/$linklib"
84676fae4e5dSmrg	      else
84686fae4e5dSmrg	        func_append newdlprefiles " $dir/$old_library"
84696fae4e5dSmrg	        # Keep a list of preopened convenience libraries to check
84706fae4e5dSmrg	        # that they are being used correctly in the link pass.
84716fae4e5dSmrg	        test -z "$libdir" && \
84726fae4e5dSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
84736fae4e5dSmrg	      fi
84746fae4e5dSmrg	    ;;
84756fae4e5dSmrg	    * )
84766fae4e5dSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
84776fae4e5dSmrg	      # are required to link).
84786fae4e5dSmrg	      if test -n "$old_library"; then
84796fae4e5dSmrg	        func_append newdlprefiles " $dir/$old_library"
84806fae4e5dSmrg	        # Keep a list of preopened convenience libraries to check
84816fae4e5dSmrg	        # that they are being used correctly in the link pass.
84826fae4e5dSmrg	        test -z "$libdir" && \
84836fae4e5dSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
84846fae4e5dSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
84856fae4e5dSmrg	      elif test -n "$dlname"; then
84866fae4e5dSmrg	        func_append newdlprefiles " $dir/$dlname"
84876fae4e5dSmrg	      else
84886fae4e5dSmrg	        func_append newdlprefiles " $dir/$linklib"
84896fae4e5dSmrg	      fi
84906fae4e5dSmrg	    ;;
84916fae4e5dSmrg	  esac
84929c9ff80cSmrg	fi # $pass = dlpreopen
84939c9ff80cSmrg
84949c9ff80cSmrg	if test -z "$libdir"; then
84959c9ff80cSmrg	  # Link the convenience library
8496d21ab8bcSmrg	  if test lib = "$linkmode"; then
84979c9ff80cSmrg	    deplibs="$dir/$old_library $deplibs"
8498d21ab8bcSmrg	  elif test prog,link = "$linkmode,$pass"; then
84999c9ff80cSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
85009c9ff80cSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
85019c9ff80cSmrg	  else
85029c9ff80cSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
85039c9ff80cSmrg	  fi
85049c9ff80cSmrg	  continue
85059c9ff80cSmrg	fi
85069c9ff80cSmrg
85079c9ff80cSmrg
8508d21ab8bcSmrg	if test prog = "$linkmode" && test link != "$pass"; then
85096fae4e5dSmrg	  func_append newlib_search_path " $ladir"
85109c9ff80cSmrg	  deplibs="$lib $deplibs"
85119c9ff80cSmrg
8512d21ab8bcSmrg	  linkalldeplibs=false
8513d21ab8bcSmrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
8514d21ab8bcSmrg	     test no = "$build_libtool_libs"; then
8515d21ab8bcSmrg	    linkalldeplibs=:
85169c9ff80cSmrg	  fi
85179c9ff80cSmrg
85189c9ff80cSmrg	  tmp_libs=
85199c9ff80cSmrg	  for deplib in $dependency_libs; do
85209c9ff80cSmrg	    case $deplib in
85219c9ff80cSmrg	    -L*) func_stripname '-L' '' "$deplib"
85226fae4e5dSmrg	         func_resolve_sysroot "$func_stripname_result"
85236fae4e5dSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
85249c9ff80cSmrg		 ;;
85259c9ff80cSmrg	    esac
85269c9ff80cSmrg	    # Need to link against all dependency_libs?
8527d21ab8bcSmrg	    if $linkalldeplibs; then
85289c9ff80cSmrg	      deplibs="$deplib $deplibs"
85299c9ff80cSmrg	    else
85309c9ff80cSmrg	      # Need to hardcode shared library paths
85319c9ff80cSmrg	      # or/and link against static libraries
85329c9ff80cSmrg	      newdependency_libs="$deplib $newdependency_libs"
85339c9ff80cSmrg	    fi
8534d21ab8bcSmrg	    if $opt_preserve_dup_deps; then
85359c9ff80cSmrg	      case "$tmp_libs " in
85366fae4e5dSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
85379c9ff80cSmrg	      esac
85389c9ff80cSmrg	    fi
85396fae4e5dSmrg	    func_append tmp_libs " $deplib"
85409c9ff80cSmrg	  done # for deplib
85419c9ff80cSmrg	  continue
85429c9ff80cSmrg	fi # $linkmode = prog...
85439c9ff80cSmrg
8544d21ab8bcSmrg	if test prog,link = "$linkmode,$pass"; then
85459c9ff80cSmrg	  if test -n "$library_names" &&
8546d21ab8bcSmrg	     { { test no = "$prefer_static_libs" ||
8547d21ab8bcSmrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
85489c9ff80cSmrg	       test -z "$old_library"; }; then
85499c9ff80cSmrg	    # We need to hardcode the library path
8550d21ab8bcSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
85519c9ff80cSmrg	      # Make sure the rpath contains only unique directories.
8552d21ab8bcSmrg	      case $temp_rpath: in
85539c9ff80cSmrg	      *"$absdir:"*) ;;
85546ee7d557Smrg              *) case $absdir in
85556ee7d557Smrg                 "$progdir/"*) func_append temp_rpath "$absdir:" ;;
85566ee7d557Smrg                 *)            func_append temp_rpath_tail "$absdir:" ;;
85576ee7d557Smrg                 esac
85589c9ff80cSmrg	      esac
85599c9ff80cSmrg	    fi
85609c9ff80cSmrg
85619c9ff80cSmrg	    # Hardcode the library path.
85629c9ff80cSmrg	    # Skip directories that are in the system default run-time
85639c9ff80cSmrg	    # search path.
85649c9ff80cSmrg	    case " $sys_lib_dlsearch_path " in
85659c9ff80cSmrg	    *" $absdir "*) ;;
85669c9ff80cSmrg	    *)
85676ee7d557Smrg	      case "$compile_rpath$compile_rpath_tail " in
85689c9ff80cSmrg	      *" $absdir "*) ;;
85696ee7d557Smrg	      *) case $absdir in
85706ee7d557Smrg                 "$progdir/"*) func_append compile_rpath " $absdir" ;;
85716ee7d557Smrg                 *) func_append compile_rpath_tail " $absdir" ;;
85726ee7d557Smrg		 esac
85739c9ff80cSmrg	      esac
85749c9ff80cSmrg	      ;;
85759c9ff80cSmrg	    esac
85769c9ff80cSmrg	    case " $sys_lib_dlsearch_path " in
85779c9ff80cSmrg	    *" $libdir "*) ;;
85789c9ff80cSmrg	    *)
85799c9ff80cSmrg	      case "$finalize_rpath " in
85809c9ff80cSmrg	      *" $libdir "*) ;;
85816fae4e5dSmrg	      *) func_append finalize_rpath " $libdir" ;;
85829c9ff80cSmrg	      esac
85839c9ff80cSmrg	      ;;
85849c9ff80cSmrg	    esac
85859c9ff80cSmrg	  fi # $linkmode,$pass = prog,link...
85869c9ff80cSmrg
8587d21ab8bcSmrg	  if $alldeplibs &&
8588d21ab8bcSmrg	     { test pass_all = "$deplibs_check_method" ||
8589d21ab8bcSmrg	       { test yes = "$build_libtool_libs" &&
85909c9ff80cSmrg		 test -n "$library_names"; }; }; then
85919c9ff80cSmrg	    # We only need to search for static libraries
85929c9ff80cSmrg	    continue
85939c9ff80cSmrg	  fi
85949c9ff80cSmrg	fi
85959c9ff80cSmrg
85969c9ff80cSmrg	link_static=no # Whether the deplib will be linked statically
85979c9ff80cSmrg	use_static_libs=$prefer_static_libs
8598d21ab8bcSmrg	if test built = "$use_static_libs" && test yes = "$installed"; then
85999c9ff80cSmrg	  use_static_libs=no
86009c9ff80cSmrg	fi
86019c9ff80cSmrg	if test -n "$library_names" &&
8602d21ab8bcSmrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
86036ee7d557Smrg	  case $host_os in
86046ee7d557Smrg	  cygwin* | mingw* | windows* | cegcc* | os2*)
86059c9ff80cSmrg	      # No point in relinking DLLs because paths are not encoded
86066fae4e5dSmrg	      func_append notinst_deplibs " $lib"
86079c9ff80cSmrg	      need_relink=no
86089c9ff80cSmrg	    ;;
86099c9ff80cSmrg	  *)
8610d21ab8bcSmrg	    if test no = "$installed"; then
86116fae4e5dSmrg	      func_append notinst_deplibs " $lib"
86129c9ff80cSmrg	      need_relink=yes
86139c9ff80cSmrg	    fi
86149c9ff80cSmrg	    ;;
86159c9ff80cSmrg	  esac
86169c9ff80cSmrg	  # This is a shared library
86179c9ff80cSmrg
86189c9ff80cSmrg	  # Warn about portability, can't link against -module's on some
86199c9ff80cSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
8620d21ab8bcSmrg	  dlopenmodule=
86219c9ff80cSmrg	  for dlpremoduletest in $dlprefiles; do
86229c9ff80cSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
8623d21ab8bcSmrg	      dlopenmodule=$dlpremoduletest
86249c9ff80cSmrg	      break
86259c9ff80cSmrg	    fi
86269c9ff80cSmrg	  done
8627d21ab8bcSmrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
86286fae4e5dSmrg	    echo
8629d21ab8bcSmrg	    if test prog = "$linkmode"; then
86306ee7d557Smrg	      func_warning "Linking the executable $output against the loadable module"
86319c9ff80cSmrg	    else
86326ee7d557Smrg	      func_warning "Linking the shared library $output against the loadable module"
86339c9ff80cSmrg	    fi
86346ee7d557Smrg	    func_warning "$linklib is not portable!"
86359c9ff80cSmrg	  fi
8636d21ab8bcSmrg	  if test lib = "$linkmode" &&
8637d21ab8bcSmrg	     test yes = "$hardcode_into_libs"; then
86389c9ff80cSmrg	    # Hardcode the library path.
86399c9ff80cSmrg	    # Skip directories that are in the system default run-time
86409c9ff80cSmrg	    # search path.
86419c9ff80cSmrg	    case " $sys_lib_dlsearch_path " in
86429c9ff80cSmrg	    *" $absdir "*) ;;
86439c9ff80cSmrg	    *)
86446ee7d557Smrg	      case "$compile_rpath$compile_rpath_tail " in
86459c9ff80cSmrg	      *" $absdir "*) ;;
86466ee7d557Smrg	      *) case $absdir in
86476ee7d557Smrg                 "$progdir/"*) func_append compile_rpath " $absdir" ;;
86486ee7d557Smrg                 *) func_append compile_rpath_tail " $absdir" ;;
86496ee7d557Smrg		 esac
86509c9ff80cSmrg	      esac
86519c9ff80cSmrg	      ;;
86529c9ff80cSmrg	    esac
86539c9ff80cSmrg	    case " $sys_lib_dlsearch_path " in
86549c9ff80cSmrg	    *" $libdir "*) ;;
86559c9ff80cSmrg	    *)
86569c9ff80cSmrg	      case "$finalize_rpath " in
86579c9ff80cSmrg	      *" $libdir "*) ;;
86586fae4e5dSmrg	      *) func_append finalize_rpath " $libdir" ;;
86599c9ff80cSmrg	      esac
86609c9ff80cSmrg	      ;;
86619c9ff80cSmrg	    esac
86629c9ff80cSmrg	  fi
86639c9ff80cSmrg
86649c9ff80cSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
86659c9ff80cSmrg	    # figure out the soname
86669c9ff80cSmrg	    set dummy $library_names
86679c9ff80cSmrg	    shift
8668d21ab8bcSmrg	    realname=$1
86699c9ff80cSmrg	    shift
86709c9ff80cSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
86719c9ff80cSmrg	    # use dlname if we got it. it's perfectly good, no?
86729c9ff80cSmrg	    if test -n "$dlname"; then
8673d21ab8bcSmrg	      soname=$dlname
86749c9ff80cSmrg	    elif test -n "$soname_spec"; then
86759c9ff80cSmrg	      # bleh windows
86766ee7d557Smrg	      case $host_os in
86776ee7d557Smrg	      cygwin* | mingw* | windows* | cegcc* | os2*)
86789c9ff80cSmrg	        func_arith $current - $age
86799c9ff80cSmrg		major=$func_arith_result
8680d21ab8bcSmrg		versuffix=-$major
86819c9ff80cSmrg		;;
86829c9ff80cSmrg	      esac
86839c9ff80cSmrg	      eval soname=\"$soname_spec\"
86849c9ff80cSmrg	    else
8685d21ab8bcSmrg	      soname=$realname
86869c9ff80cSmrg	    fi
86879c9ff80cSmrg
86889c9ff80cSmrg	    # Make a new name for the extract_expsyms_cmds to use
8689d21ab8bcSmrg	    soroot=$soname
86909c9ff80cSmrg	    func_basename "$soroot"
8691d21ab8bcSmrg	    soname=$func_basename_result
86929c9ff80cSmrg	    func_stripname 'lib' '.dll' "$soname"
86939c9ff80cSmrg	    newlib=libimp-$func_stripname_result.a
86949c9ff80cSmrg
86959c9ff80cSmrg	    # If the library has no export list, then create one now
86969c9ff80cSmrg	    if test -f "$output_objdir/$soname-def"; then :
86979c9ff80cSmrg	    else
8698d21ab8bcSmrg	      func_verbose "extracting exported symbol list from '$soname'"
86999c9ff80cSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
87009c9ff80cSmrg	    fi
87019c9ff80cSmrg
87029c9ff80cSmrg	    # Create $newlib
87039c9ff80cSmrg	    if test -f "$output_objdir/$newlib"; then :; else
8704d21ab8bcSmrg	      func_verbose "generating import library for '$soname'"
87059c9ff80cSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
87069c9ff80cSmrg	    fi
87079c9ff80cSmrg	    # make sure the library variables are pointing to the new library
87089c9ff80cSmrg	    dir=$output_objdir
87099c9ff80cSmrg	    linklib=$newlib
87109c9ff80cSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
87119c9ff80cSmrg
8712d21ab8bcSmrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
87139c9ff80cSmrg	    add_shlibpath=
87149c9ff80cSmrg	    add_dir=
87159c9ff80cSmrg	    add=
87169c9ff80cSmrg	    lib_linked=yes
87179c9ff80cSmrg	    case $hardcode_action in
87189c9ff80cSmrg	    immediate | unsupported)
8719d21ab8bcSmrg	      if test no = "$hardcode_direct"; then
8720d21ab8bcSmrg		add=$dir/$linklib
87219c9ff80cSmrg		case $host in
8722d21ab8bcSmrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
8723d21ab8bcSmrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
87246ee7d557Smrg		  *-*-emscripten*) add_dir=-L$dir ;;
87259c9ff80cSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
8726d21ab8bcSmrg		    *-*-unixware7*) add_dir=-L$dir ;;
87279c9ff80cSmrg		  *-*-darwin* )
8728d21ab8bcSmrg		    # if the lib is a (non-dlopened) module then we cannot
87299c9ff80cSmrg		    # link against it, someone is ignoring the earlier warnings
87309c9ff80cSmrg		    if /usr/bin/file -L $add 2> /dev/null |
8731d21ab8bcSmrg			 $GREP ": [^:]* bundle" >/dev/null; then
87329c9ff80cSmrg		      if test "X$dlopenmodule" != "X$lib"; then
87336ee7d557Smrg			func_warning "lib $linklib is a module, not a shared library"
8734d21ab8bcSmrg			if test -z "$old_library"; then
87356ee7d557Smrg			  func_warning "And there doesn't seem to be a static archive available"
87366ee7d557Smrg			  func_warning "The link will probably fail, sorry"
87379c9ff80cSmrg			else
8738d21ab8bcSmrg			  add=$dir/$old_library
87399c9ff80cSmrg			fi
87409c9ff80cSmrg		      elif test -n "$old_library"; then
8741d21ab8bcSmrg			add=$dir/$old_library
87429c9ff80cSmrg		      fi
87439c9ff80cSmrg		    fi
87449c9ff80cSmrg		esac
8745d21ab8bcSmrg	      elif test no = "$hardcode_minus_L"; then
87469c9ff80cSmrg		case $host in
8747d21ab8bcSmrg		*-*-sunos*) add_shlibpath=$dir ;;
87489c9ff80cSmrg		esac
8749d21ab8bcSmrg		add_dir=-L$dir
8750d21ab8bcSmrg		add=-l$name
8751d21ab8bcSmrg	      elif test no = "$hardcode_shlibpath_var"; then
8752d21ab8bcSmrg		add_shlibpath=$dir
8753d21ab8bcSmrg		add=-l$name
87549c9ff80cSmrg	      else
87559c9ff80cSmrg		lib_linked=no
87569c9ff80cSmrg	      fi
87579c9ff80cSmrg	      ;;
87589c9ff80cSmrg	    relink)
8759d21ab8bcSmrg	      if test yes = "$hardcode_direct" &&
8760d21ab8bcSmrg	         test no = "$hardcode_direct_absolute"; then
8761d21ab8bcSmrg		add=$dir/$linklib
8762d21ab8bcSmrg	      elif test yes = "$hardcode_minus_L"; then
8763d21ab8bcSmrg		add_dir=-L$absdir
87649c9ff80cSmrg		# Try looking first in the location we're being installed to.
87659c9ff80cSmrg		if test -n "$inst_prefix_dir"; then
87669c9ff80cSmrg		  case $libdir in
87679c9ff80cSmrg		    [\\/]*)
87686fae4e5dSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
87699c9ff80cSmrg		      ;;
87709c9ff80cSmrg		  esac
87719c9ff80cSmrg		fi
8772d21ab8bcSmrg		add=-l$name
8773d21ab8bcSmrg	      elif test yes = "$hardcode_shlibpath_var"; then
8774d21ab8bcSmrg		add_shlibpath=$dir
8775d21ab8bcSmrg		add=-l$name
87769c9ff80cSmrg	      else
87779c9ff80cSmrg		lib_linked=no
87789c9ff80cSmrg	      fi
87799c9ff80cSmrg	      ;;
87809c9ff80cSmrg	    *) lib_linked=no ;;
87819c9ff80cSmrg	    esac
87829c9ff80cSmrg
8783d21ab8bcSmrg	    if test yes != "$lib_linked"; then
87849c9ff80cSmrg	      func_fatal_configuration "unsupported hardcode properties"
87859c9ff80cSmrg	    fi
87869c9ff80cSmrg
87879c9ff80cSmrg	    if test -n "$add_shlibpath"; then
87889c9ff80cSmrg	      case :$compile_shlibpath: in
87899c9ff80cSmrg	      *":$add_shlibpath:"*) ;;
87906fae4e5dSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
87919c9ff80cSmrg	      esac
87929c9ff80cSmrg	    fi
8793d21ab8bcSmrg	    if test prog = "$linkmode"; then
87949c9ff80cSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
87959c9ff80cSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
87969c9ff80cSmrg	    else
87979c9ff80cSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
87989c9ff80cSmrg	      test -n "$add" && deplibs="$add $deplibs"
8799d21ab8bcSmrg	      if test yes != "$hardcode_direct" &&
8800d21ab8bcSmrg		 test yes != "$hardcode_minus_L" &&
8801d21ab8bcSmrg		 test yes = "$hardcode_shlibpath_var"; then
88029c9ff80cSmrg		case :$finalize_shlibpath: in
88039c9ff80cSmrg		*":$libdir:"*) ;;
88046fae4e5dSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
88059c9ff80cSmrg		esac
88069c9ff80cSmrg	      fi
88079c9ff80cSmrg	    fi
88089c9ff80cSmrg	  fi
88099c9ff80cSmrg
8810d21ab8bcSmrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
88119c9ff80cSmrg	    add_shlibpath=
88129c9ff80cSmrg	    add_dir=
88139c9ff80cSmrg	    add=
88149c9ff80cSmrg	    # Finalize command for both is simple: just hardcode it.
8815d21ab8bcSmrg	    if test yes = "$hardcode_direct" &&
8816d21ab8bcSmrg	       test no = "$hardcode_direct_absolute"; then
8817d21ab8bcSmrg	      add=$libdir/$linklib
8818d21ab8bcSmrg	    elif test yes = "$hardcode_minus_L"; then
88196ee7d557Smrg	      add_dir=-L$lt_sysroot$libdir
8820d21ab8bcSmrg	      add=-l$name
8821d21ab8bcSmrg	    elif test yes = "$hardcode_shlibpath_var"; then
88229c9ff80cSmrg	      case :$finalize_shlibpath: in
88239c9ff80cSmrg	      *":$libdir:"*) ;;
88246fae4e5dSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
88259c9ff80cSmrg	      esac
8826d21ab8bcSmrg	      add=-l$name
8827d21ab8bcSmrg	    elif test yes = "$hardcode_automatic"; then
88289c9ff80cSmrg	      if test -n "$inst_prefix_dir" &&
8829d21ab8bcSmrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
8830d21ab8bcSmrg		add=$inst_prefix_dir$libdir/$linklib
88319c9ff80cSmrg	      else
8832d21ab8bcSmrg		add=$libdir/$linklib
88339c9ff80cSmrg	      fi
88349c9ff80cSmrg	    else
88359c9ff80cSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
88366ee7d557Smrg	      add_dir=-L$lt_sysroot$libdir
88379c9ff80cSmrg	      # Try looking first in the location we're being installed to.
88389c9ff80cSmrg	      if test -n "$inst_prefix_dir"; then
88399c9ff80cSmrg		case $libdir in
88409c9ff80cSmrg		  [\\/]*)
88416fae4e5dSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
88429c9ff80cSmrg		    ;;
88439c9ff80cSmrg		esac
88449c9ff80cSmrg	      fi
8845d21ab8bcSmrg	      add=-l$name
88469c9ff80cSmrg	    fi
88479c9ff80cSmrg
8848d21ab8bcSmrg	    if test prog = "$linkmode"; then
88499c9ff80cSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
88509c9ff80cSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
88519c9ff80cSmrg	    else
88529c9ff80cSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
88539c9ff80cSmrg	      test -n "$add" && deplibs="$add $deplibs"
88549c9ff80cSmrg	    fi
88559c9ff80cSmrg	  fi
8856d21ab8bcSmrg	elif test prog = "$linkmode"; then
88579c9ff80cSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
88589c9ff80cSmrg	  # is not unsupported.  This is valid on all known static and
88599c9ff80cSmrg	  # shared platforms.
8860d21ab8bcSmrg	  if test unsupported != "$hardcode_direct"; then
8861d21ab8bcSmrg	    test -n "$old_library" && linklib=$old_library
88629c9ff80cSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
88639c9ff80cSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
88649c9ff80cSmrg	  else
88659c9ff80cSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
88669c9ff80cSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
88679c9ff80cSmrg	  fi
8868d21ab8bcSmrg	elif test yes = "$build_libtool_libs"; then
88699c9ff80cSmrg	  # Not a shared library
8870d21ab8bcSmrg	  if test pass_all != "$deplibs_check_method"; then
88719c9ff80cSmrg	    # We're trying link a shared library against a static one
88729c9ff80cSmrg	    # but the system doesn't support it.
88739c9ff80cSmrg
88749c9ff80cSmrg	    # Just print a warning and add the library to dependency_libs so
88759c9ff80cSmrg	    # that the program can be linked against the static library.
88766ee7d557Smrg	    func_warning "This system cannot link to static lib archive $lib."
88776ee7d557Smrg	    func_warning "I have the capability to make that library automatically link in when"
88786ee7d557Smrg	    func_warning "you link to this library.  But I can only do this if you have a"
88796ee7d557Smrg	    func_warning "shared version of the library, which you do not appear to have."
8880d21ab8bcSmrg	    if test yes = "$module"; then
88816ee7d557Smrg	      func_warning "But as you try to build a module library, libtool will still create "
88826ee7d557Smrg	      func_warning "a static module, that should work as long as the dlopening application"
88836ee7d557Smrg	      func_warning "is linked with the -dlopen flag to resolve symbols at runtime."
88849c9ff80cSmrg	      if test -z "$global_symbol_pipe"; then
88856ee7d557Smrg		func_warning "However, this would only work if libtool was able to extract symbol"
88866ee7d557Smrg		func_warning "lists from a program, using 'nm' or equivalent, but libtool could"
88876ee7d557Smrg		func_warning "not find such a program.  So, this module is probably useless."
88886ee7d557Smrg		func_warning "'nm' from GNU binutils and a full rebuild may help."
88899c9ff80cSmrg	      fi
8890d21ab8bcSmrg	      if test no = "$build_old_libs"; then
88919c9ff80cSmrg		build_libtool_libs=module
88929c9ff80cSmrg		build_old_libs=yes
88939c9ff80cSmrg	      else
88949c9ff80cSmrg		build_libtool_libs=no
88959c9ff80cSmrg	      fi
88969c9ff80cSmrg	    fi
88979c9ff80cSmrg	  else
88989c9ff80cSmrg	    deplibs="$dir/$old_library $deplibs"
88999c9ff80cSmrg	    link_static=yes
89009c9ff80cSmrg	  fi
89019c9ff80cSmrg	fi # link shared/static library?
89029c9ff80cSmrg
8903d21ab8bcSmrg	if test lib = "$linkmode"; then
89049c9ff80cSmrg	  if test -n "$dependency_libs" &&
8905d21ab8bcSmrg	     { test yes != "$hardcode_into_libs" ||
8906d21ab8bcSmrg	       test yes = "$build_old_libs" ||
8907d21ab8bcSmrg	       test yes = "$link_static"; }; then
89089c9ff80cSmrg	    # Extract -R from dependency_libs
89099c9ff80cSmrg	    temp_deplibs=
89109c9ff80cSmrg	    for libdir in $dependency_libs; do
89119c9ff80cSmrg	      case $libdir in
89129c9ff80cSmrg	      -R*) func_stripname '-R' '' "$libdir"
89139c9ff80cSmrg	           temp_xrpath=$func_stripname_result
89149c9ff80cSmrg		   case " $xrpath " in
89159c9ff80cSmrg		   *" $temp_xrpath "*) ;;
89166fae4e5dSmrg		   *) func_append xrpath " $temp_xrpath";;
89179c9ff80cSmrg		   esac;;
89186fae4e5dSmrg	      *) func_append temp_deplibs " $libdir";;
89199c9ff80cSmrg	      esac
89209c9ff80cSmrg	    done
8921d21ab8bcSmrg	    dependency_libs=$temp_deplibs
89229c9ff80cSmrg	  fi
89239c9ff80cSmrg
89246fae4e5dSmrg	  func_append newlib_search_path " $absdir"
89259c9ff80cSmrg	  # Link against this library
8926d21ab8bcSmrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
89279c9ff80cSmrg	  # ... and its dependency_libs
89289c9ff80cSmrg	  tmp_libs=
89299c9ff80cSmrg	  for deplib in $dependency_libs; do
89309c9ff80cSmrg	    newdependency_libs="$deplib $newdependency_libs"
89316fae4e5dSmrg	    case $deplib in
89326fae4e5dSmrg              -L*) func_stripname '-L' '' "$deplib"
89336fae4e5dSmrg                   func_resolve_sysroot "$func_stripname_result";;
89346fae4e5dSmrg              *) func_resolve_sysroot "$deplib" ;;
89356fae4e5dSmrg            esac
8936d21ab8bcSmrg	    if $opt_preserve_dup_deps; then
89379c9ff80cSmrg	      case "$tmp_libs " in
89386fae4e5dSmrg	      *" $func_resolve_sysroot_result "*)
89396fae4e5dSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
89409c9ff80cSmrg	      esac
89419c9ff80cSmrg	    fi
89426fae4e5dSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
89439c9ff80cSmrg	  done
89449c9ff80cSmrg
8945d21ab8bcSmrg	  if test no != "$link_all_deplibs"; then
89469c9ff80cSmrg	    # Add the search paths of all dependency libraries
89479c9ff80cSmrg	    for deplib in $dependency_libs; do
89486fae4e5dSmrg	      path=
89499c9ff80cSmrg	      case $deplib in
8950d21ab8bcSmrg	      -L*) path=$deplib ;;
89519c9ff80cSmrg	      *.la)
89526fae4e5dSmrg	        func_resolve_sysroot "$deplib"
89536fae4e5dSmrg	        deplib=$func_resolve_sysroot_result
89549c9ff80cSmrg	        func_dirname "$deplib" "" "."
89556fae4e5dSmrg		dir=$func_dirname_result
89569c9ff80cSmrg		# We need an absolute path.
89579c9ff80cSmrg		case $dir in
8958d21ab8bcSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
89599c9ff80cSmrg		*)
89609c9ff80cSmrg		  absdir=`cd "$dir" && pwd`
89619c9ff80cSmrg		  if test -z "$absdir"; then
8962d21ab8bcSmrg		    func_warning "cannot determine absolute directory name of '$dir'"
8963d21ab8bcSmrg		    absdir=$dir
89649c9ff80cSmrg		  fi
89659c9ff80cSmrg		  ;;
89669c9ff80cSmrg		esac
89679c9ff80cSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
89689c9ff80cSmrg		case $host in
89699c9ff80cSmrg		*-*-darwin*)
89709c9ff80cSmrg		  depdepl=
8971d21ab8bcSmrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
8972d21ab8bcSmrg		  if test -n "$deplibrary_names"; then
8973d21ab8bcSmrg		    for tmp in $deplibrary_names; do
89749c9ff80cSmrg		      depdepl=$tmp
89759c9ff80cSmrg		    done
8976d21ab8bcSmrg		    if test -f "$absdir/$objdir/$depdepl"; then
8977d21ab8bcSmrg		      depdepl=$absdir/$objdir/$depdepl
8978d21ab8bcSmrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
89799c9ff80cSmrg                      if test -z "$darwin_install_name"; then
8980d21ab8bcSmrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
89819c9ff80cSmrg                      fi
8982d21ab8bcSmrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
8983d21ab8bcSmrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
89849c9ff80cSmrg		      path=
89859c9ff80cSmrg		    fi
89869c9ff80cSmrg		  fi
89879c9ff80cSmrg		  ;;
89889c9ff80cSmrg		*)
8989d21ab8bcSmrg		  path=-L$absdir/$objdir
89909c9ff80cSmrg		  ;;
89919c9ff80cSmrg		esac
89929c9ff80cSmrg		else
8993d21ab8bcSmrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
89949c9ff80cSmrg		  test -z "$libdir" && \
8995d21ab8bcSmrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
89969c9ff80cSmrg		  test "$absdir" != "$libdir" && \
8997d21ab8bcSmrg		    func_warning "'$deplib' seems to be moved"
89989c9ff80cSmrg
8999d21ab8bcSmrg		  path=-L$absdir
90009c9ff80cSmrg		fi
90019c9ff80cSmrg		;;
90029c9ff80cSmrg	      esac
90039c9ff80cSmrg	      case " $deplibs " in
90049c9ff80cSmrg	      *" $path "*) ;;
90059c9ff80cSmrg	      *) deplibs="$path $deplibs" ;;
90069c9ff80cSmrg	      esac
90079c9ff80cSmrg	    done
90089c9ff80cSmrg	  fi # link_all_deplibs != no
90099c9ff80cSmrg	fi # linkmode = lib
90109c9ff80cSmrg      done # for deplib in $libs
90116ee7d557Smrg
90126ee7d557Smrg      func_append temp_rpath "$temp_rpath_tail"
90136ee7d557Smrg      func_append compile_rpath "$compile_rpath_tail"
90146ee7d557Smrg
9015d21ab8bcSmrg      if test link = "$pass"; then
9016d21ab8bcSmrg	if test prog = "$linkmode"; then
90179c9ff80cSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
90189c9ff80cSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
90199c9ff80cSmrg	else
90206fae4e5dSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
90219c9ff80cSmrg	fi
90229c9ff80cSmrg      fi
9023d21ab8bcSmrg      dependency_libs=$newdependency_libs
9024d21ab8bcSmrg      if test dlpreopen = "$pass"; then
90259c9ff80cSmrg	# Link the dlpreopened libraries before other libraries
90269c9ff80cSmrg	for deplib in $save_deplibs; do
90279c9ff80cSmrg	  deplibs="$deplib $deplibs"
90289c9ff80cSmrg	done
90299c9ff80cSmrg      fi
9030d21ab8bcSmrg      if test dlopen != "$pass"; then
9031d21ab8bcSmrg	test conv = "$pass" || {
90329c9ff80cSmrg	  # Make sure lib_search_path contains only unique directories.
90339c9ff80cSmrg	  lib_search_path=
90349c9ff80cSmrg	  for dir in $newlib_search_path; do
90359c9ff80cSmrg	    case "$lib_search_path " in
90369c9ff80cSmrg	    *" $dir "*) ;;
90376fae4e5dSmrg	    *) func_append lib_search_path " $dir" ;;
90389c9ff80cSmrg	    esac
90399c9ff80cSmrg	  done
90409c9ff80cSmrg	  newlib_search_path=
9041d21ab8bcSmrg	}
90429c9ff80cSmrg
9043d21ab8bcSmrg	if test prog,link = "$linkmode,$pass"; then
90449c9ff80cSmrg	  vars="compile_deplibs finalize_deplibs"
9045d21ab8bcSmrg	else
9046d21ab8bcSmrg	  vars=deplibs
90479c9ff80cSmrg	fi
90489c9ff80cSmrg	for var in $vars dependency_libs; do
90499c9ff80cSmrg	  # Add libraries to $var in reverse order
90509c9ff80cSmrg	  eval tmp_libs=\"\$$var\"
90519c9ff80cSmrg	  new_libs=
90526ee7d557Smrg	  # FIXME: Pedantically, this is the right thing to do, so
90536ee7d557Smrg	  #        that some nasty dependency loop isn't accidentally
90546ee7d557Smrg	  #        broken: new_libs="$deplib $new_libs"
90559c9ff80cSmrg	  for deplib in $tmp_libs; do
90566ee7d557Smrg	    if $opt_preserve_dup_deps; then
90576ee7d557Smrg	      new_libs="$deplib $new_libs"
90586ee7d557Smrg	    else
90596ee7d557Smrg	      # Pragmatically, this seems to cause very few problems in
90606ee7d557Smrg	      # practice:
90616ee7d557Smrg	      case $deplib in
90626ee7d557Smrg	      -L*) new_libs="$deplib $new_libs" ;;
90636ee7d557Smrg	      -R*) ;;
90649c9ff80cSmrg	      *)
90656ee7d557Smrg	        # And here is the reason: when a library appears more
90666ee7d557Smrg	        # than once as an explicit dependence of a library, or
90676ee7d557Smrg	        # is implicitly linked in more than once by the
90686ee7d557Smrg	        # compiler, it is considered special, and multiple
90696ee7d557Smrg	        # occurrences thereof are not removed.  Compare this
90706ee7d557Smrg	        # with having the same library being listed as a
90716ee7d557Smrg	        # dependency of multiple other libraries: in this case,
90726ee7d557Smrg	        # we know (pedantically, we assume) the library does not
90736ee7d557Smrg	        # need to be listed more than once, so we keep only the
90746ee7d557Smrg	        # last copy.  This is not always right, but it is rare
90756ee7d557Smrg	        # enough that we require users that really mean to play
90766ee7d557Smrg	        # such unportable linking tricks to link the library
90776ee7d557Smrg	        # using -Wl,-lname, so that libtool does not consider it
90786ee7d557Smrg	        # for duplicate removal.  And if not possible for portability
90796ee7d557Smrg	        # reasons, then --preserve-dup-deps should be used.
90806ee7d557Smrg	        case " $specialdeplibs " in
90816ee7d557Smrg	        *" $deplib "*) new_libs="$deplib $new_libs" ;;
90826ee7d557Smrg	        *)
90836ee7d557Smrg	          case " $new_libs " in
90846ee7d557Smrg	          *" $deplib "*) ;;
90856ee7d557Smrg	          *) new_libs="$deplib $new_libs" ;;
90866ee7d557Smrg	          esac
90876ee7d557Smrg	          ;;
90886ee7d557Smrg	        esac
90896ee7d557Smrg	        ;;
90909c9ff80cSmrg	      esac
90916ee7d557Smrg	    fi
90929c9ff80cSmrg	  done
90939c9ff80cSmrg	  tmp_libs=
90949c9ff80cSmrg	  for deplib in $new_libs; do
90959c9ff80cSmrg	    case $deplib in
90969c9ff80cSmrg	    -L*)
90979c9ff80cSmrg	      case " $tmp_libs " in
90989c9ff80cSmrg	      *" $deplib "*) ;;
90996fae4e5dSmrg	      *) func_append tmp_libs " $deplib" ;;
91009c9ff80cSmrg	      esac
91019c9ff80cSmrg	      ;;
91026fae4e5dSmrg	    *) func_append tmp_libs " $deplib" ;;
91039c9ff80cSmrg	    esac
91049c9ff80cSmrg	  done
91059c9ff80cSmrg	  eval $var=\"$tmp_libs\"
91069c9ff80cSmrg	done # for var
91079c9ff80cSmrg      fi
9108d21ab8bcSmrg
9109d21ab8bcSmrg      # Add Sun CC postdeps if required:
9110d21ab8bcSmrg      test CXX = "$tagname" && {
9111d21ab8bcSmrg        case $host_os in
9112d21ab8bcSmrg        linux*)
9113d21ab8bcSmrg          case `$CC -V 2>&1 | $SED 5q` in
9114d21ab8bcSmrg          *Sun\ C*) # Sun C++ 5.9
9115d21ab8bcSmrg            func_suncc_cstd_abi
9116d21ab8bcSmrg
9117d21ab8bcSmrg            if test no != "$suncc_use_cstd_abi"; then
9118d21ab8bcSmrg              func_append postdeps ' -library=Cstd -library=Crun'
9119d21ab8bcSmrg            fi
9120d21ab8bcSmrg            ;;
9121d21ab8bcSmrg          esac
9122d21ab8bcSmrg          ;;
9123d21ab8bcSmrg
9124d21ab8bcSmrg        solaris*)
9125d21ab8bcSmrg          func_cc_basename "$CC"
9126d21ab8bcSmrg          case $func_cc_basename_result in
9127d21ab8bcSmrg          CC* | sunCC*)
9128d21ab8bcSmrg            func_suncc_cstd_abi
9129d21ab8bcSmrg
9130d21ab8bcSmrg            if test no != "$suncc_use_cstd_abi"; then
9131d21ab8bcSmrg              func_append postdeps ' -library=Cstd -library=Crun'
9132d21ab8bcSmrg            fi
9133d21ab8bcSmrg            ;;
9134d21ab8bcSmrg          esac
9135d21ab8bcSmrg          ;;
9136d21ab8bcSmrg        esac
9137d21ab8bcSmrg      }
9138d21ab8bcSmrg
91399c9ff80cSmrg      # Last step: remove runtime libs from dependency_libs
91409c9ff80cSmrg      # (they stay in deplibs)
91419c9ff80cSmrg      tmp_libs=
9142d21ab8bcSmrg      for i in $dependency_libs; do
91439c9ff80cSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
91449c9ff80cSmrg	*" $i "*)
9145d21ab8bcSmrg	  i=
91469c9ff80cSmrg	  ;;
91479c9ff80cSmrg	esac
9148d21ab8bcSmrg	if test -n "$i"; then
91496fae4e5dSmrg	  func_append tmp_libs " $i"
91509c9ff80cSmrg	fi
91519c9ff80cSmrg      done
91529c9ff80cSmrg      dependency_libs=$tmp_libs
91539c9ff80cSmrg    done # for pass
9154d21ab8bcSmrg    if test prog = "$linkmode"; then
9155d21ab8bcSmrg      dlfiles=$newdlfiles
91569c9ff80cSmrg    fi
9157d21ab8bcSmrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
9158d21ab8bcSmrg      dlprefiles=$newdlprefiles
91599c9ff80cSmrg    fi
91609c9ff80cSmrg
91619c9ff80cSmrg    case $linkmode in
91629c9ff80cSmrg    oldlib)
9163d21ab8bcSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
9164d21ab8bcSmrg	func_warning "'-dlopen' is ignored for archives"
91659c9ff80cSmrg      fi
91669c9ff80cSmrg
91679c9ff80cSmrg      case " $deplibs" in
91689c9ff80cSmrg      *\ -l* | *\ -L*)
9169d21ab8bcSmrg	func_warning "'-l' and '-L' are ignored for archives" ;;
91709c9ff80cSmrg      esac
91719c9ff80cSmrg
91729c9ff80cSmrg      test -n "$rpath" && \
9173d21ab8bcSmrg	func_warning "'-rpath' is ignored for archives"
91749c9ff80cSmrg
91759c9ff80cSmrg      test -n "$xrpath" && \
9176d21ab8bcSmrg	func_warning "'-R' is ignored for archives"
91779c9ff80cSmrg
91789c9ff80cSmrg      test -n "$vinfo" && \
9179d21ab8bcSmrg	func_warning "'-version-info/-version-number' is ignored for archives"
91809c9ff80cSmrg
91819c9ff80cSmrg      test -n "$release" && \
9182d21ab8bcSmrg	func_warning "'-release' is ignored for archives"
91839c9ff80cSmrg
91849c9ff80cSmrg      test -n "$export_symbols$export_symbols_regex" && \
9185d21ab8bcSmrg	func_warning "'-export-symbols' is ignored for archives"
91869c9ff80cSmrg
91879c9ff80cSmrg      # Now set the variables for building old libraries.
91889c9ff80cSmrg      build_libtool_libs=no
9189d21ab8bcSmrg      oldlibs=$output
91906fae4e5dSmrg      func_append objs "$old_deplibs"
91919c9ff80cSmrg      ;;
91929c9ff80cSmrg
91939c9ff80cSmrg    lib)
9194d21ab8bcSmrg      # Make sure we only generate libraries of the form 'libNAME.la'.
91959c9ff80cSmrg      case $outputname in
91969c9ff80cSmrg      lib*)
91979c9ff80cSmrg	func_stripname 'lib' '.la' "$outputname"
91989c9ff80cSmrg	name=$func_stripname_result
91999c9ff80cSmrg	eval shared_ext=\"$shrext_cmds\"
92009c9ff80cSmrg	eval libname=\"$libname_spec\"
92019c9ff80cSmrg	;;
92029c9ff80cSmrg      *)
9203d21ab8bcSmrg	test no = "$module" \
9204d21ab8bcSmrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
92059c9ff80cSmrg
9206d21ab8bcSmrg	if test no != "$need_lib_prefix"; then
92079c9ff80cSmrg	  # Add the "lib" prefix for modules if required
92089c9ff80cSmrg	  func_stripname '' '.la' "$outputname"
92099c9ff80cSmrg	  name=$func_stripname_result
92109c9ff80cSmrg	  eval shared_ext=\"$shrext_cmds\"
92119c9ff80cSmrg	  eval libname=\"$libname_spec\"
92129c9ff80cSmrg	else
92139c9ff80cSmrg	  func_stripname '' '.la' "$outputname"
92149c9ff80cSmrg	  libname=$func_stripname_result
92159c9ff80cSmrg	fi
92169c9ff80cSmrg	;;
92179c9ff80cSmrg      esac
92189c9ff80cSmrg
92199c9ff80cSmrg      if test -n "$objs"; then
9220d21ab8bcSmrg	if test pass_all != "$deplibs_check_method"; then
9221d21ab8bcSmrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
92229c9ff80cSmrg	else
92236ee7d557Smrg	  func_warning "Linking the shared library $output against the non-libtool objects $objs is not portable!"
92246fae4e5dSmrg	  func_append libobjs " $objs"
92259c9ff80cSmrg	fi
92269c9ff80cSmrg      fi
92279c9ff80cSmrg
9228d21ab8bcSmrg      test no = "$dlself" \
9229d21ab8bcSmrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
92309c9ff80cSmrg
92319c9ff80cSmrg      set dummy $rpath
92329c9ff80cSmrg      shift
9233d21ab8bcSmrg      test 1 -lt "$#" \
9234d21ab8bcSmrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
92359c9ff80cSmrg
9236d21ab8bcSmrg      install_libdir=$1
92379c9ff80cSmrg
92389c9ff80cSmrg      oldlibs=
92399c9ff80cSmrg      if test -z "$rpath"; then
9240d21ab8bcSmrg	if test yes = "$build_libtool_libs"; then
92419c9ff80cSmrg	  # Building a libtool convenience library.
9242d21ab8bcSmrg	  # Some compilers have problems with a '.al' extension so
92439c9ff80cSmrg	  # convenience libraries should have the same extension an
92449c9ff80cSmrg	  # archive normally would.
92459c9ff80cSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
92469c9ff80cSmrg	  build_libtool_libs=convenience
92479c9ff80cSmrg	  build_old_libs=yes
92489c9ff80cSmrg	fi
92499c9ff80cSmrg
92509c9ff80cSmrg	test -n "$vinfo" && \
9251d21ab8bcSmrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
92529c9ff80cSmrg
92539c9ff80cSmrg	test -n "$release" && \
9254d21ab8bcSmrg	  func_warning "'-release' is ignored for convenience libraries"
92559c9ff80cSmrg      else
92569c9ff80cSmrg
92579c9ff80cSmrg	# Parse the version information argument.
9258d21ab8bcSmrg	save_ifs=$IFS; IFS=:
92599c9ff80cSmrg	set dummy $vinfo 0 0 0
92609c9ff80cSmrg	shift
9261d21ab8bcSmrg	IFS=$save_ifs
92629c9ff80cSmrg
92639c9ff80cSmrg	test -n "$7" && \
9264d21ab8bcSmrg	  func_fatal_help "too many parameters to '-version-info'"
92659c9ff80cSmrg
92669c9ff80cSmrg	# convert absolute version numbers to libtool ages
92679c9ff80cSmrg	# this retains compatibility with .la files and attempts
92689c9ff80cSmrg	# to make the code below a bit more comprehensible
92699c9ff80cSmrg
92709c9ff80cSmrg	case $vinfo_number in
92719c9ff80cSmrg	yes)
9272d21ab8bcSmrg	  number_major=$1
9273d21ab8bcSmrg	  number_minor=$2
9274d21ab8bcSmrg	  number_revision=$3
92759c9ff80cSmrg	  #
92769c9ff80cSmrg	  # There are really only two kinds -- those that
92779c9ff80cSmrg	  # use the current revision as the major version
92789c9ff80cSmrg	  # and those that subtract age and use age as
92799c9ff80cSmrg	  # a minor version.  But, then there is irix
9280d21ab8bcSmrg	  # that has an extra 1 added just for fun
92819c9ff80cSmrg	  #
92829c9ff80cSmrg	  case $version_type in
928389c04b6cSmrg	  # correct linux to gnu/linux during the next big refactor
92846ee7d557Smrg	  darwin|freebsd-elf|linux|midnightbsd-elf|osf|qnx|windows|none)
92859c9ff80cSmrg	    func_arith $number_major + $number_minor
92869c9ff80cSmrg	    current=$func_arith_result
9287d21ab8bcSmrg	    age=$number_minor
9288d21ab8bcSmrg	    revision=$number_revision
92899c9ff80cSmrg	    ;;
92906ee7d557Smrg	  freebsd-aout|sco|sunos)
9291d21ab8bcSmrg	    current=$number_major
9292d21ab8bcSmrg	    revision=$number_minor
9293d21ab8bcSmrg	    age=0
92949c9ff80cSmrg	    ;;
92959c9ff80cSmrg	  irix|nonstopux)
92969c9ff80cSmrg	    func_arith $number_major + $number_minor
92979c9ff80cSmrg	    current=$func_arith_result
9298d21ab8bcSmrg	    age=$number_minor
9299d21ab8bcSmrg	    revision=$number_minor
93009c9ff80cSmrg	    lt_irix_increment=no
93019c9ff80cSmrg	    ;;
93026ee7d557Smrg	  *)
93036ee7d557Smrg	    func_fatal_configuration "$modename: unknown library version type '$version_type'"
93046ee7d557Smrg	    ;;
93059c9ff80cSmrg	  esac
93069c9ff80cSmrg	  ;;
93079c9ff80cSmrg	no)
9308d21ab8bcSmrg	  current=$1
9309d21ab8bcSmrg	  revision=$2
9310d21ab8bcSmrg	  age=$3
93119c9ff80cSmrg	  ;;
93129c9ff80cSmrg	esac
93139c9ff80cSmrg
93149c9ff80cSmrg	# Check that each of the things are valid numbers.
93159c9ff80cSmrg	case $current in
93169c9ff80cSmrg	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]) ;;
93179c9ff80cSmrg	*)
9318d21ab8bcSmrg	  func_error "CURRENT '$current' must be a nonnegative integer"
9319d21ab8bcSmrg	  func_fatal_error "'$vinfo' is not valid version information"
93209c9ff80cSmrg	  ;;
93219c9ff80cSmrg	esac
93229c9ff80cSmrg
93239c9ff80cSmrg	case $revision in
93249c9ff80cSmrg	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]) ;;
93259c9ff80cSmrg	*)
9326d21ab8bcSmrg	  func_error "REVISION '$revision' must be a nonnegative integer"
9327d21ab8bcSmrg	  func_fatal_error "'$vinfo' is not valid version information"
93289c9ff80cSmrg	  ;;
93299c9ff80cSmrg	esac
93309c9ff80cSmrg
93319c9ff80cSmrg	case $age in
93329c9ff80cSmrg	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]) ;;
93339c9ff80cSmrg	*)
9334d21ab8bcSmrg	  func_error "AGE '$age' must be a nonnegative integer"
9335d21ab8bcSmrg	  func_fatal_error "'$vinfo' is not valid version information"
93369c9ff80cSmrg	  ;;
93379c9ff80cSmrg	esac
93389c9ff80cSmrg
93399c9ff80cSmrg	if test "$age" -gt "$current"; then
9340d21ab8bcSmrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
9341d21ab8bcSmrg	  func_fatal_error "'$vinfo' is not valid version information"
93429c9ff80cSmrg	fi
93439c9ff80cSmrg
93449c9ff80cSmrg	# Calculate the version variables.
93459c9ff80cSmrg	major=
93469c9ff80cSmrg	versuffix=
93479c9ff80cSmrg	verstring=
93489c9ff80cSmrg	case $version_type in
93499c9ff80cSmrg	none) ;;
93509c9ff80cSmrg
93519c9ff80cSmrg	darwin)
93529c9ff80cSmrg	  # Like Linux, but with the current version available in
93539c9ff80cSmrg	  # verstring for coding it into the library header
93549c9ff80cSmrg	  func_arith $current - $age
93559c9ff80cSmrg	  major=.$func_arith_result
9356d21ab8bcSmrg	  versuffix=$major.$age.$revision
93579c9ff80cSmrg	  # Darwin ld doesn't like 0 for these options...
93589c9ff80cSmrg	  func_arith $current + 1
93599c9ff80cSmrg	  minor_current=$func_arith_result
9360d21ab8bcSmrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
93619c9ff80cSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
9362d21ab8bcSmrg          # On Darwin other compilers
9363d21ab8bcSmrg          case $CC in
9364d21ab8bcSmrg              nagfor*)
9365d21ab8bcSmrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
9366d21ab8bcSmrg                  ;;
9367d21ab8bcSmrg              *)
9368d21ab8bcSmrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
9369d21ab8bcSmrg                  ;;
9370d21ab8bcSmrg          esac
93719c9ff80cSmrg	  ;;
93729c9ff80cSmrg
93739c9ff80cSmrg	freebsd-aout)
9374d21ab8bcSmrg	  major=.$current
9375d21ab8bcSmrg	  versuffix=.$current.$revision
93769c9ff80cSmrg	  ;;
93779c9ff80cSmrg
9378d21ab8bcSmrg	freebsd-elf | midnightbsd-elf)
9379d21ab8bcSmrg	  func_arith $current - $age
9380d21ab8bcSmrg	  major=.$func_arith_result
9381d21ab8bcSmrg	  versuffix=$major.$age.$revision
93829c9ff80cSmrg	  ;;
93839c9ff80cSmrg
93849c9ff80cSmrg	irix | nonstopux)
9385d21ab8bcSmrg	  if test no = "$lt_irix_increment"; then
93869c9ff80cSmrg	    func_arith $current - $age
93879c9ff80cSmrg	  else
93889c9ff80cSmrg	    func_arith $current - $age + 1
93899c9ff80cSmrg	  fi
93909c9ff80cSmrg	  major=$func_arith_result
93919c9ff80cSmrg
93929c9ff80cSmrg	  case $version_type in
93939c9ff80cSmrg	    nonstopux) verstring_prefix=nonstopux ;;
93949c9ff80cSmrg	    *)         verstring_prefix=sgi ;;
93959c9ff80cSmrg	  esac
9396d21ab8bcSmrg	  verstring=$verstring_prefix$major.$revision
93979c9ff80cSmrg
93989c9ff80cSmrg	  # Add in all the interfaces that we are compatible with.
93999c9ff80cSmrg	  loop=$revision
9400d21ab8bcSmrg	  while test 0 -ne "$loop"; do
94019c9ff80cSmrg	    func_arith $revision - $loop
94029c9ff80cSmrg	    iface=$func_arith_result
94039c9ff80cSmrg	    func_arith $loop - 1
94049c9ff80cSmrg	    loop=$func_arith_result
9405d21ab8bcSmrg	    verstring=$verstring_prefix$major.$iface:$verstring
94069c9ff80cSmrg	  done
94079c9ff80cSmrg
9408d21ab8bcSmrg	  # Before this point, $major must not contain '.'.
94099c9ff80cSmrg	  major=.$major
9410d21ab8bcSmrg	  versuffix=$major.$revision
94119c9ff80cSmrg	  ;;
94129c9ff80cSmrg
941389c04b6cSmrg	linux) # correct to gnu/linux during the next big refactor
94149c9ff80cSmrg	  func_arith $current - $age
94159c9ff80cSmrg	  major=.$func_arith_result
9416d21ab8bcSmrg	  versuffix=$major.$age.$revision
94179c9ff80cSmrg	  ;;
94189c9ff80cSmrg
94199c9ff80cSmrg	osf)
94209c9ff80cSmrg	  func_arith $current - $age
94219c9ff80cSmrg	  major=.$func_arith_result
9422d21ab8bcSmrg	  versuffix=.$current.$age.$revision
9423d21ab8bcSmrg	  verstring=$current.$age.$revision
94249c9ff80cSmrg
94259c9ff80cSmrg	  # Add in all the interfaces that we are compatible with.
94269c9ff80cSmrg	  loop=$age
9427d21ab8bcSmrg	  while test 0 -ne "$loop"; do
94289c9ff80cSmrg	    func_arith $current - $loop
94299c9ff80cSmrg	    iface=$func_arith_result
94309c9ff80cSmrg	    func_arith $loop - 1
94319c9ff80cSmrg	    loop=$func_arith_result
9432d21ab8bcSmrg	    verstring=$verstring:$iface.0
94339c9ff80cSmrg	  done
94349c9ff80cSmrg
94359c9ff80cSmrg	  # Make executables depend on our current version.
9436d21ab8bcSmrg	  func_append verstring ":$current.0"
94379c9ff80cSmrg	  ;;
94389c9ff80cSmrg
94399c9ff80cSmrg	qnx)
94406ee7d557Smrg	  func_arith $current - $age
94416ee7d557Smrg	  major=.$func_arith_result
94426ee7d557Smrg	  versuffix=$major.$age.$revision
9443d21ab8bcSmrg	  ;;
9444d21ab8bcSmrg
9445d21ab8bcSmrg	sco)
9446d21ab8bcSmrg	  major=.$current
9447d21ab8bcSmrg	  versuffix=.$current
94489c9ff80cSmrg	  ;;
94499c9ff80cSmrg
94509c9ff80cSmrg	sunos)
9451d21ab8bcSmrg	  major=.$current
9452d21ab8bcSmrg	  versuffix=.$current.$revision
94539c9ff80cSmrg	  ;;
94549c9ff80cSmrg
94559c9ff80cSmrg	windows)
94569c9ff80cSmrg	  # Use '-' rather than '.', since we only want one
9457d21ab8bcSmrg	  # extension on DOS 8.3 file systems.
94589c9ff80cSmrg	  func_arith $current - $age
94599c9ff80cSmrg	  major=$func_arith_result
9460d21ab8bcSmrg	  versuffix=-$major
94619c9ff80cSmrg	  ;;
94629c9ff80cSmrg
94639c9ff80cSmrg	*)
9464d21ab8bcSmrg	  func_fatal_configuration "unknown library version type '$version_type'"
94659c9ff80cSmrg	  ;;
94669c9ff80cSmrg	esac
94679c9ff80cSmrg
94689c9ff80cSmrg	# Clear the version info if we defaulted, and they specified a release.
94699c9ff80cSmrg	if test -z "$vinfo" && test -n "$release"; then
94709c9ff80cSmrg	  major=
94719c9ff80cSmrg	  case $version_type in
94729c9ff80cSmrg	  darwin)
94739c9ff80cSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
94749c9ff80cSmrg	    # problems, so we reset it completely
94759c9ff80cSmrg	    verstring=
94769c9ff80cSmrg	    ;;
94779c9ff80cSmrg	  *)
9478d21ab8bcSmrg	    verstring=0.0
94799c9ff80cSmrg	    ;;
94809c9ff80cSmrg	  esac
9481d21ab8bcSmrg	  if test no = "$need_version"; then
94829c9ff80cSmrg	    versuffix=
94839c9ff80cSmrg	  else
9484d21ab8bcSmrg	    versuffix=.0.0
94859c9ff80cSmrg	  fi
94869c9ff80cSmrg	fi
94879c9ff80cSmrg
94889c9ff80cSmrg	# Remove version info from name if versioning should be avoided
9489d21ab8bcSmrg	if test yes,no = "$avoid_version,$need_version"; then
94909c9ff80cSmrg	  major=
94919c9ff80cSmrg	  versuffix=
9492d21ab8bcSmrg	  verstring=
94939c9ff80cSmrg	fi
94949c9ff80cSmrg
94959c9ff80cSmrg	# Check to see if the archive will have undefined symbols.
9496d21ab8bcSmrg	if test yes = "$allow_undefined"; then
9497d21ab8bcSmrg	  if test unsupported = "$allow_undefined_flag"; then
9498d21ab8bcSmrg	    if test yes = "$build_old_libs"; then
9499d21ab8bcSmrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
9500d21ab8bcSmrg	      build_libtool_libs=no
9501d21ab8bcSmrg	    else
9502d21ab8bcSmrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
9503d21ab8bcSmrg	    fi
95049c9ff80cSmrg	  fi
95059c9ff80cSmrg	else
95069c9ff80cSmrg	  # Don't allow undefined symbols.
9507d21ab8bcSmrg	  allow_undefined_flag=$no_undefined_flag
95089c9ff80cSmrg	fi
95099c9ff80cSmrg
95109c9ff80cSmrg      fi
95119c9ff80cSmrg
9512d21ab8bcSmrg      func_generate_dlsyms "$libname" "$libname" :
95136fae4e5dSmrg      func_append libobjs " $symfileobj"
9514d21ab8bcSmrg      test " " = "$libobjs" && libobjs=
95159c9ff80cSmrg
9516d21ab8bcSmrg      if test relink != "$opt_mode"; then
95179c9ff80cSmrg	# Remove our outputs, but don't remove object files since they
95189c9ff80cSmrg	# may have been created when compiling PIC objects.
95199c9ff80cSmrg	removelist=
95209c9ff80cSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
95219c9ff80cSmrg	for p in $tempremovelist; do
95229c9ff80cSmrg	  case $p in
95239c9ff80cSmrg	    *.$objext | *.gcno)
95249c9ff80cSmrg	       ;;
9525d21ab8bcSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
9526d21ab8bcSmrg	       if test -n "$precious_files_regex"; then
95279c9ff80cSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
95289c9ff80cSmrg		 then
95299c9ff80cSmrg		   continue
95309c9ff80cSmrg		 fi
95319c9ff80cSmrg	       fi
95326fae4e5dSmrg	       func_append removelist " $p"
95339c9ff80cSmrg	       ;;
95349c9ff80cSmrg	    *) ;;
95359c9ff80cSmrg	  esac
95369c9ff80cSmrg	done
95379c9ff80cSmrg	test -n "$removelist" && \
95389c9ff80cSmrg	  func_show_eval "${RM}r \$removelist"
95399c9ff80cSmrg      fi
95409c9ff80cSmrg
95419c9ff80cSmrg      # Now set the variables for building old libraries.
9542d21ab8bcSmrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
95436fae4e5dSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
95449c9ff80cSmrg
95459c9ff80cSmrg	# Transform .lo files to .o files.
9546d21ab8bcSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
95479c9ff80cSmrg      fi
95489c9ff80cSmrg
95499c9ff80cSmrg      # Eliminate all temporary directories.
95509c9ff80cSmrg      #for path in $notinst_path; do
95516fae4e5dSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
95526fae4e5dSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
95536fae4e5dSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
95549c9ff80cSmrg      #done
95559c9ff80cSmrg
95569c9ff80cSmrg      if test -n "$xrpath"; then
95579c9ff80cSmrg	# If the user specified any rpath flags, then add them.
95589c9ff80cSmrg	temp_xrpath=
95599c9ff80cSmrg	for libdir in $xrpath; do
95606fae4e5dSmrg	  func_replace_sysroot "$libdir"
95616fae4e5dSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
95629c9ff80cSmrg	  case "$finalize_rpath " in
95639c9ff80cSmrg	  *" $libdir "*) ;;
95646fae4e5dSmrg	  *) func_append finalize_rpath " $libdir" ;;
95659c9ff80cSmrg	  esac
95669c9ff80cSmrg	done
9567d21ab8bcSmrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
95689c9ff80cSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
95699c9ff80cSmrg	fi
95709c9ff80cSmrg      fi
95719c9ff80cSmrg
95729c9ff80cSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
9573d21ab8bcSmrg      old_dlfiles=$dlfiles
95749c9ff80cSmrg      dlfiles=
95759c9ff80cSmrg      for lib in $old_dlfiles; do
95769c9ff80cSmrg	case " $dlprefiles $dlfiles " in
95779c9ff80cSmrg	*" $lib "*) ;;
95786fae4e5dSmrg	*) func_append dlfiles " $lib" ;;
95799c9ff80cSmrg	esac
95809c9ff80cSmrg      done
95819c9ff80cSmrg
95829c9ff80cSmrg      # Make sure dlprefiles contains only unique files
9583d21ab8bcSmrg      old_dlprefiles=$dlprefiles
95849c9ff80cSmrg      dlprefiles=
95859c9ff80cSmrg      for lib in $old_dlprefiles; do
95869c9ff80cSmrg	case "$dlprefiles " in
95879c9ff80cSmrg	*" $lib "*) ;;
95886fae4e5dSmrg	*) func_append dlprefiles " $lib" ;;
95899c9ff80cSmrg	esac
95909c9ff80cSmrg      done
95919c9ff80cSmrg
9592d21ab8bcSmrg      if test yes = "$build_libtool_libs"; then
95939c9ff80cSmrg	if test -n "$rpath"; then
95949c9ff80cSmrg	  case $host in
95956ee7d557Smrg	  *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
95969c9ff80cSmrg	    # these systems don't actually have a c library (as such)!
95979c9ff80cSmrg	    ;;
95989c9ff80cSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
95999c9ff80cSmrg	    # Rhapsody C library is in the System framework
96006fae4e5dSmrg	    func_append deplibs " System.ltframework"
96019c9ff80cSmrg	    ;;
96029c9ff80cSmrg	  *-*-netbsd*)
96039c9ff80cSmrg	    # Don't link with libc until the a.out ld.so is fixed.
96049c9ff80cSmrg	    ;;
9605d21ab8bcSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
96069c9ff80cSmrg	    # Do not include libc due to us having libc/libc_r.
96079c9ff80cSmrg	    ;;
96089c9ff80cSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
96099c9ff80cSmrg	    # Causes problems with __ctype
96109c9ff80cSmrg	    ;;
96119c9ff80cSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
96129c9ff80cSmrg	    # Compiler inserts libc in the correct place for threads to work
96139c9ff80cSmrg	    ;;
96149c9ff80cSmrg	  *)
96159c9ff80cSmrg	    # Add libc to deplibs on all other systems if necessary.
9616d21ab8bcSmrg	    if test yes = "$build_libtool_need_lc"; then
96176fae4e5dSmrg	      func_append deplibs " -lc"
96189c9ff80cSmrg	    fi
96199c9ff80cSmrg	    ;;
96209c9ff80cSmrg	  esac
96219c9ff80cSmrg	fi
96229c9ff80cSmrg
96239c9ff80cSmrg	# Transform deplibs into only deplibs that can be linked in shared.
96249c9ff80cSmrg	name_save=$name
96259c9ff80cSmrg	libname_save=$libname
96269c9ff80cSmrg	release_save=$release
96279c9ff80cSmrg	versuffix_save=$versuffix
96289c9ff80cSmrg	major_save=$major
96299c9ff80cSmrg	# I'm not sure if I'm treating the release correctly.  I think
96309c9ff80cSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
96319c9ff80cSmrg	# add it in twice.  Is that correct?
9632d21ab8bcSmrg	release=
9633d21ab8bcSmrg	versuffix=
9634d21ab8bcSmrg	major=
96359c9ff80cSmrg	newdeplibs=
96369c9ff80cSmrg	droppeddeps=no
96379c9ff80cSmrg	case $deplibs_check_method in
96389c9ff80cSmrg	pass_all)
96399c9ff80cSmrg	  # Don't check for shared/static.  Everything works.
96409c9ff80cSmrg	  # This might be a little naive.  We might want to check
96419c9ff80cSmrg	  # whether the library exists or not.  But this is on
96429c9ff80cSmrg	  # osf3 & osf4 and I'm not really sure... Just
96439c9ff80cSmrg	  # implementing what was already the behavior.
96449c9ff80cSmrg	  newdeplibs=$deplibs
96459c9ff80cSmrg	  ;;
96469c9ff80cSmrg	file_magic*)
96479c9ff80cSmrg	  set dummy $deplibs_check_method; shift
96489c9ff80cSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
96499c9ff80cSmrg	  for a_deplib in $deplibs; do
96509c9ff80cSmrg	    case $a_deplib in
96519c9ff80cSmrg	    -l*)
96529c9ff80cSmrg	      func_stripname -l '' "$a_deplib"
96539c9ff80cSmrg	      name=$func_stripname_result
9654d21ab8bcSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
96559c9ff80cSmrg		case " $predeps $postdeps " in
96569c9ff80cSmrg		*" $a_deplib "*)
96576fae4e5dSmrg		  func_append newdeplibs " $a_deplib"
9658d21ab8bcSmrg		  a_deplib=
96599c9ff80cSmrg		  ;;
96609c9ff80cSmrg		esac
96619c9ff80cSmrg	      fi
9662d21ab8bcSmrg	      if test -n "$a_deplib"; then
96639c9ff80cSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
96646fae4e5dSmrg		if test -n "$file_magic_glob"; then
96656fae4e5dSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
96666fae4e5dSmrg		else
96676fae4e5dSmrg		  libnameglob=$libname
96686fae4e5dSmrg		fi
9669d21ab8bcSmrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
96709c9ff80cSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9671d21ab8bcSmrg		  if test yes = "$want_nocaseglob"; then
96726fae4e5dSmrg		    shopt -s nocaseglob
96736fae4e5dSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
96746fae4e5dSmrg		    $nocaseglob
96756fae4e5dSmrg		  else
96766fae4e5dSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
96776fae4e5dSmrg		  fi
96789c9ff80cSmrg		  for potent_lib in $potential_libs; do
96799c9ff80cSmrg		      # Follow soft links.
96809c9ff80cSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
96819c9ff80cSmrg			 $GREP " -> " >/dev/null; then
96829c9ff80cSmrg			continue
96839c9ff80cSmrg		      fi
96849c9ff80cSmrg		      # The statement above tries to avoid entering an
96859c9ff80cSmrg		      # endless loop below, in case of cyclic links.
96869c9ff80cSmrg		      # We might still enter an endless loop, since a link
96879c9ff80cSmrg		      # loop can be closed while we follow links,
96889c9ff80cSmrg		      # but so what?
9689d21ab8bcSmrg		      potlib=$potent_lib
96909c9ff80cSmrg		      while test -h "$potlib" 2>/dev/null; do
9691d21ab8bcSmrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
96929c9ff80cSmrg			case $potliblink in
9693d21ab8bcSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
9694d21ab8bcSmrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
96959c9ff80cSmrg			esac
96969c9ff80cSmrg		      done
96979c9ff80cSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
96989c9ff80cSmrg			 $SED -e 10q |
96999c9ff80cSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
97006fae4e5dSmrg			func_append newdeplibs " $a_deplib"
9701d21ab8bcSmrg			a_deplib=
97029c9ff80cSmrg			break 2
97039c9ff80cSmrg		      fi
97049c9ff80cSmrg		  done
97059c9ff80cSmrg		done
97069c9ff80cSmrg	      fi
9707d21ab8bcSmrg	      if test -n "$a_deplib"; then
97089c9ff80cSmrg		droppeddeps=yes
97096ee7d557Smrg		func_warning "Linker path does not have real file for library $a_deplib."
97106ee7d557Smrg		func_warning "I have the capability to make that library automatically link in when"
97116ee7d557Smrg		func_warning "you link to this library.  But I can only do this if you have a"
97126ee7d557Smrg		func_warning "shared version of the library, which you do not appear to have"
97136ee7d557Smrg		func_warning "because I did check the linker path looking for a file starting"
9714d21ab8bcSmrg		if test -z "$potlib"; then
97156ee7d557Smrg		  func_warning "with $libname but no candidates were found. (...for file magic test)"
97169c9ff80cSmrg		else
97176ee7d557Smrg		  func_warning "with $libname and none of the candidates passed a file format test"
97186ee7d557Smrg		  func_warning "using a file magic. Last file checked: $potlib"
97199c9ff80cSmrg		fi
97209c9ff80cSmrg	      fi
97219c9ff80cSmrg	      ;;
97229c9ff80cSmrg	    *)
97239c9ff80cSmrg	      # Add a -L argument.
97246fae4e5dSmrg	      func_append newdeplibs " $a_deplib"
97259c9ff80cSmrg	      ;;
97269c9ff80cSmrg	    esac
97279c9ff80cSmrg	  done # Gone through all deplibs.
97289c9ff80cSmrg	  ;;
97299c9ff80cSmrg	match_pattern*)
97309c9ff80cSmrg	  set dummy $deplibs_check_method; shift
97319c9ff80cSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
97329c9ff80cSmrg	  for a_deplib in $deplibs; do
97339c9ff80cSmrg	    case $a_deplib in
97349c9ff80cSmrg	    -l*)
97359c9ff80cSmrg	      func_stripname -l '' "$a_deplib"
97369c9ff80cSmrg	      name=$func_stripname_result
9737d21ab8bcSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
97389c9ff80cSmrg		case " $predeps $postdeps " in
97399c9ff80cSmrg		*" $a_deplib "*)
97406fae4e5dSmrg		  func_append newdeplibs " $a_deplib"
9741d21ab8bcSmrg		  a_deplib=
97429c9ff80cSmrg		  ;;
97439c9ff80cSmrg		esac
97449c9ff80cSmrg	      fi
9745d21ab8bcSmrg	      if test -n "$a_deplib"; then
97469c9ff80cSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
97479c9ff80cSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
97489c9ff80cSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
97499c9ff80cSmrg		  for potent_lib in $potential_libs; do
9750d21ab8bcSmrg		    potlib=$potent_lib # see symlink-check above in file_magic test
97516fae4e5dSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
97529c9ff80cSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
97536fae4e5dSmrg		      func_append newdeplibs " $a_deplib"
9754d21ab8bcSmrg		      a_deplib=
97559c9ff80cSmrg		      break 2
97569c9ff80cSmrg		    fi
97579c9ff80cSmrg		  done
97589c9ff80cSmrg		done
97599c9ff80cSmrg	      fi
9760d21ab8bcSmrg	      if test -n "$a_deplib"; then
97619c9ff80cSmrg		droppeddeps=yes
97626ee7d557Smrg		func_warning "Linker path does not have real file for library $a_deplib."
97636ee7d557Smrg		func_warning "I have the capability to make that library automatically link in when"
97646ee7d557Smrg		func_warning "you link to this library.  But I can only do this if you have a"
97656ee7d557Smrg		func_warning "shared version of the library, which you do not appear to have"
97666ee7d557Smrg		func_warning "because I did check the linker path looking for a file starting"
9767d21ab8bcSmrg		if test -z "$potlib"; then
97686ee7d557Smrg		  func_warning "with $libname but no candidates were found. (...for regex pattern test)"
97699c9ff80cSmrg		else
97706ee7d557Smrg		  func_warning "with $libname and none of the candidates passed a file format test"
97716ee7d557Smrg		  func_warning "using a regex pattern. Last file checked: $potlib"
97729c9ff80cSmrg		fi
97739c9ff80cSmrg	      fi
97749c9ff80cSmrg	      ;;
97759c9ff80cSmrg	    *)
97769c9ff80cSmrg	      # Add a -L argument.
97776fae4e5dSmrg	      func_append newdeplibs " $a_deplib"
97789c9ff80cSmrg	      ;;
97799c9ff80cSmrg	    esac
97809c9ff80cSmrg	  done # Gone through all deplibs.
97819c9ff80cSmrg	  ;;
97829c9ff80cSmrg	none | unknown | *)
9783d21ab8bcSmrg	  newdeplibs=
97846fae4e5dSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
9785d21ab8bcSmrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9786d21ab8bcSmrg	    for i in $predeps $postdeps; do
97879c9ff80cSmrg	      # can't use Xsed below, because $i might contain '/'
9788d21ab8bcSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
97899c9ff80cSmrg	    done
97909c9ff80cSmrg	  fi
97916fae4e5dSmrg	  case $tmp_deplibs in
97926fae4e5dSmrg	  *[!\	\ ]*)
97936fae4e5dSmrg	    echo
9794d21ab8bcSmrg	    if test none = "$deplibs_check_method"; then
97956ee7d557Smrg	      func_warning "Inter-library dependencies are not supported in this platform."
97969c9ff80cSmrg	    else
97976ee7d557Smrg	      func_warning "Inter-library dependencies are not known to be supported."
97989c9ff80cSmrg	    fi
97996ee7d557Smrg	    func_warning "All declared inter-library dependencies are being dropped."
98009c9ff80cSmrg	    droppeddeps=yes
98016fae4e5dSmrg	    ;;
98026fae4e5dSmrg	  esac
98039c9ff80cSmrg	  ;;
98049c9ff80cSmrg	esac
98059c9ff80cSmrg	versuffix=$versuffix_save
98069c9ff80cSmrg	major=$major_save
98079c9ff80cSmrg	release=$release_save
98089c9ff80cSmrg	libname=$libname_save
98099c9ff80cSmrg	name=$name_save
98109c9ff80cSmrg
98119c9ff80cSmrg	case $host in
98129c9ff80cSmrg	*-*-rhapsody* | *-*-darwin1.[012])
98139c9ff80cSmrg	  # On Rhapsody replace the C library with the System framework
98146fae4e5dSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
98159c9ff80cSmrg	  ;;
98169c9ff80cSmrg	esac
98179c9ff80cSmrg
9818d21ab8bcSmrg	if test yes = "$droppeddeps"; then
9819d21ab8bcSmrg	  if test yes = "$module"; then
98206ee7d557Smrg	    func_warning "libtool could not satisfy all declared inter-library"
98216ee7d557Smrg	    func_warning "dependencies of module $libname.  Therefore, libtool will create"
98226ee7d557Smrg	    func_warning "a static module, that should work as long as the dlopening"
98236ee7d557Smrg	    func_warning "application is linked with the -dlopen flag."
98249c9ff80cSmrg	    if test -z "$global_symbol_pipe"; then
98256ee7d557Smrg	      func_warning "However, this would only work if libtool was able to extract symbol"
98266ee7d557Smrg	      func_warning "lists from a program, using 'nm' or equivalent, but libtool could"
98276ee7d557Smrg	      func_warning "not find such a program.  So, this module is probably useless."
98286ee7d557Smrg	      func_warning "'nm' from GNU binutils and a full rebuild may help."
98299c9ff80cSmrg	    fi
9830d21ab8bcSmrg	    if test no = "$build_old_libs"; then
9831d21ab8bcSmrg	      oldlibs=$output_objdir/$libname.$libext
98329c9ff80cSmrg	      build_libtool_libs=module
98339c9ff80cSmrg	      build_old_libs=yes
98349c9ff80cSmrg	    else
98359c9ff80cSmrg	      build_libtool_libs=no
98369c9ff80cSmrg	    fi
98379c9ff80cSmrg	  else
98386fae4e5dSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
98396fae4e5dSmrg	    echo "*** automatically added whenever a program is linked with this library"
98406fae4e5dSmrg	    echo "*** or is declared to -dlopen it."
98419c9ff80cSmrg
9842d21ab8bcSmrg	    if test no = "$allow_undefined"; then
98436fae4e5dSmrg	      echo
98446fae4e5dSmrg	      echo "*** Since this library must not contain undefined symbols,"
98456fae4e5dSmrg	      echo "*** because either the platform does not support them or"
98466fae4e5dSmrg	      echo "*** it was explicitly requested with -no-undefined,"
98476fae4e5dSmrg	      echo "*** libtool will only create a static version of it."
9848d21ab8bcSmrg	      if test no = "$build_old_libs"; then
9849d21ab8bcSmrg		oldlibs=$output_objdir/$libname.$libext
98509c9ff80cSmrg		build_libtool_libs=module
98519c9ff80cSmrg		build_old_libs=yes
98529c9ff80cSmrg	      else
98539c9ff80cSmrg		build_libtool_libs=no
98549c9ff80cSmrg	      fi
98559c9ff80cSmrg	    fi
98569c9ff80cSmrg	  fi
98579c9ff80cSmrg	fi
98589c9ff80cSmrg	# Done checking deplibs!
98599c9ff80cSmrg	deplibs=$newdeplibs
98609c9ff80cSmrg      fi
98619c9ff80cSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
98629c9ff80cSmrg      case $host in
98639c9ff80cSmrg	*-*-darwin*)
98646fae4e5dSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
98656fae4e5dSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
98666fae4e5dSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
98679c9ff80cSmrg	  ;;
98689c9ff80cSmrg      esac
98699c9ff80cSmrg
98709c9ff80cSmrg      # move library search paths that coincide with paths to not yet
98719c9ff80cSmrg      # installed libraries to the beginning of the library search list
98729c9ff80cSmrg      new_libs=
98739c9ff80cSmrg      for path in $notinst_path; do
98749c9ff80cSmrg	case " $new_libs " in
98759c9ff80cSmrg	*" -L$path/$objdir "*) ;;
98769c9ff80cSmrg	*)
98779c9ff80cSmrg	  case " $deplibs " in
98789c9ff80cSmrg	  *" -L$path/$objdir "*)
98796fae4e5dSmrg	    func_append new_libs " -L$path/$objdir" ;;
98809c9ff80cSmrg	  esac
98819c9ff80cSmrg	  ;;
98829c9ff80cSmrg	esac
98839c9ff80cSmrg      done
98849c9ff80cSmrg      for deplib in $deplibs; do
98859c9ff80cSmrg	case $deplib in
98869c9ff80cSmrg	-L*)
98879c9ff80cSmrg	  case " $new_libs " in
98889c9ff80cSmrg	  *" $deplib "*) ;;
98896fae4e5dSmrg	  *) func_append new_libs " $deplib" ;;
98909c9ff80cSmrg	  esac
98919c9ff80cSmrg	  ;;
98926fae4e5dSmrg	*) func_append new_libs " $deplib" ;;
98939c9ff80cSmrg	esac
98949c9ff80cSmrg      done
9895d21ab8bcSmrg      deplibs=$new_libs
98969c9ff80cSmrg
98979c9ff80cSmrg      # All the library-specific variables (install_libdir is set above).
98989c9ff80cSmrg      library_names=
98999c9ff80cSmrg      old_library=
99009c9ff80cSmrg      dlname=
99019c9ff80cSmrg
99029c9ff80cSmrg      # Test again, we may have decided not to build it any more
9903d21ab8bcSmrg      if test yes = "$build_libtool_libs"; then
9904d21ab8bcSmrg	# Remove $wl instances when linking with ld.
990589c04b6cSmrg	# FIXME: should test the right _cmds variable.
990689c04b6cSmrg	case $archive_cmds in
990789c04b6cSmrg	  *\$LD\ *) wl= ;;
990889c04b6cSmrg        esac
9909d21ab8bcSmrg	if test yes = "$hardcode_into_libs"; then
99109c9ff80cSmrg	  # Hardcode the library paths
99119c9ff80cSmrg	  hardcode_libdirs=
99129c9ff80cSmrg	  dep_rpath=
9913d21ab8bcSmrg	  rpath=$finalize_rpath
9914d21ab8bcSmrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
99159c9ff80cSmrg	  for libdir in $rpath; do
99169c9ff80cSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
99179c9ff80cSmrg	      if test -n "$hardcode_libdir_separator"; then
99186fae4e5dSmrg		func_replace_sysroot "$libdir"
99196fae4e5dSmrg		libdir=$func_replace_sysroot_result
99209c9ff80cSmrg		if test -z "$hardcode_libdirs"; then
9921d21ab8bcSmrg		  hardcode_libdirs=$libdir
99229c9ff80cSmrg		else
99239c9ff80cSmrg		  # Just accumulate the unique libdirs.
99249c9ff80cSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
99259c9ff80cSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
99269c9ff80cSmrg		    ;;
99279c9ff80cSmrg		  *)
99286fae4e5dSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
99299c9ff80cSmrg		    ;;
99309c9ff80cSmrg		  esac
99319c9ff80cSmrg		fi
99329c9ff80cSmrg	      else
99339c9ff80cSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
99346fae4e5dSmrg		func_append dep_rpath " $flag"
99359c9ff80cSmrg	      fi
99369c9ff80cSmrg	    elif test -n "$runpath_var"; then
99379c9ff80cSmrg	      case "$perm_rpath " in
99389c9ff80cSmrg	      *" $libdir "*) ;;
993989c04b6cSmrg	      *) func_append perm_rpath " $libdir" ;;
99409c9ff80cSmrg	      esac
99419c9ff80cSmrg	    fi
99429c9ff80cSmrg	  done
99439c9ff80cSmrg	  # Substitute the hardcoded libdirs into the rpath.
99449c9ff80cSmrg	  if test -n "$hardcode_libdir_separator" &&
99459c9ff80cSmrg	     test -n "$hardcode_libdirs"; then
9946d21ab8bcSmrg	    libdir=$hardcode_libdirs
994789c04b6cSmrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
99489c9ff80cSmrg	  fi
99499c9ff80cSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
99509c9ff80cSmrg	    # We should set the runpath_var.
99519c9ff80cSmrg	    rpath=
99529c9ff80cSmrg	    for dir in $perm_rpath; do
99536fae4e5dSmrg	      func_append rpath "$dir:"
99549c9ff80cSmrg	    done
99559c9ff80cSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
99569c9ff80cSmrg	  fi
99579c9ff80cSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
99589c9ff80cSmrg	fi
99591f0ac6a5Smrg
9960d21ab8bcSmrg	shlibpath=$finalize_shlibpath
9961d21ab8bcSmrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
99629c9ff80cSmrg	if test -n "$shlibpath"; then
99639c9ff80cSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
99649c9ff80cSmrg	fi
99651f0ac6a5Smrg
99669c9ff80cSmrg	# Get the real and link names of the library.
99679c9ff80cSmrg	eval shared_ext=\"$shrext_cmds\"
99689c9ff80cSmrg	eval library_names=\"$library_names_spec\"
99699c9ff80cSmrg	set dummy $library_names
99709c9ff80cSmrg	shift
9971d21ab8bcSmrg	realname=$1
99729c9ff80cSmrg	shift
99731f0ac6a5Smrg
99749c9ff80cSmrg	if test -n "$soname_spec"; then
99759c9ff80cSmrg	  eval soname=\"$soname_spec\"
99769c9ff80cSmrg	else
9977d21ab8bcSmrg	  soname=$realname
99789c9ff80cSmrg	fi
99799c9ff80cSmrg	if test -z "$dlname"; then
99809c9ff80cSmrg	  dlname=$soname
99819c9ff80cSmrg	fi
99821f0ac6a5Smrg
9983d21ab8bcSmrg	lib=$output_objdir/$realname
99849c9ff80cSmrg	linknames=
99859c9ff80cSmrg	for link
99869c9ff80cSmrg	do
99876fae4e5dSmrg	  func_append linknames " $link"
99889c9ff80cSmrg	done
99891f0ac6a5Smrg
99909c9ff80cSmrg	# Use standard objects if they are pic
99916fae4e5dSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
99929c9ff80cSmrg	test "X$libobjs" = "X " && libobjs=
99931f0ac6a5Smrg
99949c9ff80cSmrg	delfiles=
99959c9ff80cSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
99969c9ff80cSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
9997d21ab8bcSmrg	  export_symbols=$output_objdir/$libname.uexp
99986fae4e5dSmrg	  func_append delfiles " $export_symbols"
99999c9ff80cSmrg	fi
100001f0ac6a5Smrg
100019c9ff80cSmrg	orig_export_symbols=
100029c9ff80cSmrg	case $host_os in
100036ee7d557Smrg	cygwin* | mingw* | windows* | cegcc*)
100049c9ff80cSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
100059c9ff80cSmrg	    # exporting using user supplied symfile
10006d21ab8bcSmrg	    func_dll_def_p "$export_symbols" || {
100079c9ff80cSmrg	      # and it's NOT already a .def file. Must figure out
100089c9ff80cSmrg	      # which of the given symbols are data symbols and tag
100099c9ff80cSmrg	      # them as such. So, trigger use of export_symbols_cmds.
100109c9ff80cSmrg	      # export_symbols gets reassigned inside the "prepare
100119c9ff80cSmrg	      # the list of exported symbols" if statement, so the
100129c9ff80cSmrg	      # include_expsyms logic still works.
10013d21ab8bcSmrg	      orig_export_symbols=$export_symbols
100149c9ff80cSmrg	      export_symbols=
100159c9ff80cSmrg	      always_export_symbols=yes
10016d21ab8bcSmrg	    }
100179c9ff80cSmrg	  fi
100189c9ff80cSmrg	  ;;
100199c9ff80cSmrg	esac
100201f0ac6a5Smrg
100219c9ff80cSmrg	# Prepare the list of exported symbols
100229c9ff80cSmrg	if test -z "$export_symbols"; then
10023d21ab8bcSmrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
10024d21ab8bcSmrg	    func_verbose "generating symbol list for '$libname.la'"
10025d21ab8bcSmrg	    export_symbols=$output_objdir/$libname.exp
100269c9ff80cSmrg	    $opt_dry_run || $RM $export_symbols
100279c9ff80cSmrg	    cmds=$export_symbols_cmds
10028d21ab8bcSmrg	    save_ifs=$IFS; IFS='~'
100296fae4e5dSmrg	    for cmd1 in $cmds; do
10030d21ab8bcSmrg	      IFS=$save_ifs
100316fae4e5dSmrg	      # Take the normal branch if the nm_file_list_spec branch
100326fae4e5dSmrg	      # doesn't work or if tool conversion is not needed.
100336fae4e5dSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
100346fae4e5dSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
100356fae4e5dSmrg		  try_normal_branch=yes
100366fae4e5dSmrg		  eval cmd=\"$cmd1\"
100376fae4e5dSmrg		  func_len " $cmd"
100386fae4e5dSmrg		  len=$func_len_result
100396fae4e5dSmrg		  ;;
100406fae4e5dSmrg		*)
100416fae4e5dSmrg		  try_normal_branch=no
100426fae4e5dSmrg		  ;;
100436fae4e5dSmrg	      esac
10044d21ab8bcSmrg	      if test yes = "$try_normal_branch" \
100456fae4e5dSmrg		 && { test "$len" -lt "$max_cmd_len" \
100466fae4e5dSmrg		      || test "$max_cmd_len" -le -1; }
100476fae4e5dSmrg	      then
100486fae4e5dSmrg		func_show_eval "$cmd" 'exit $?'
100496fae4e5dSmrg		skipped_export=false
100506fae4e5dSmrg	      elif test -n "$nm_file_list_spec"; then
100516fae4e5dSmrg		func_basename "$output"
100526fae4e5dSmrg		output_la=$func_basename_result
100536fae4e5dSmrg		save_libobjs=$libobjs
100546fae4e5dSmrg		save_output=$output
10055d21ab8bcSmrg		output=$output_objdir/$output_la.nm
100566fae4e5dSmrg		func_to_tool_file "$output"
100576fae4e5dSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
100586fae4e5dSmrg		func_append delfiles " $output"
100596fae4e5dSmrg		func_verbose "creating $NM input file list: $output"
100606fae4e5dSmrg		for obj in $save_libobjs; do
100616fae4e5dSmrg		  func_to_tool_file "$obj"
100626fae4e5dSmrg		  $ECHO "$func_to_tool_file_result"
100636fae4e5dSmrg		done > "$output"
100646fae4e5dSmrg		eval cmd=\"$cmd1\"
100659c9ff80cSmrg		func_show_eval "$cmd" 'exit $?'
100666fae4e5dSmrg		output=$save_output
100676fae4e5dSmrg		libobjs=$save_libobjs
100689c9ff80cSmrg		skipped_export=false
100699c9ff80cSmrg	      else
100709c9ff80cSmrg		# The command line is too long to execute in one step.
100719c9ff80cSmrg		func_verbose "using reloadable object file for export list..."
100729c9ff80cSmrg		skipped_export=:
100739c9ff80cSmrg		# Break out early, otherwise skipped_export may be
100749c9ff80cSmrg		# set to false by a later but shorter cmd.
100759c9ff80cSmrg		break
100769c9ff80cSmrg	      fi
100779c9ff80cSmrg	    done
10078d21ab8bcSmrg	    IFS=$save_ifs
10079d21ab8bcSmrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
100809c9ff80cSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
100819c9ff80cSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
100829c9ff80cSmrg	    fi
100839c9ff80cSmrg	  fi
100841f0ac6a5Smrg	fi
100851f0ac6a5Smrg
100869c9ff80cSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
10087d21ab8bcSmrg	  tmp_export_symbols=$export_symbols
10088d21ab8bcSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
100896fae4e5dSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
100909c9ff80cSmrg	fi
100911f0ac6a5Smrg
10092d21ab8bcSmrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
100939c9ff80cSmrg	  # The given exports_symbols file has to be filtered, so filter it.
10094d21ab8bcSmrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
100959c9ff80cSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
10096d21ab8bcSmrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
100979c9ff80cSmrg	  # though. Also, the filter scales superlinearly with the number of
100989c9ff80cSmrg	  # global variables. join(1) would be nice here, but unfortunately
100999c9ff80cSmrg	  # isn't a blessed tool.
101009c9ff80cSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
101016fae4e5dSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
101029c9ff80cSmrg	  export_symbols=$output_objdir/$libname.def
101039c9ff80cSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
101049c9ff80cSmrg	fi
101051f0ac6a5Smrg
101069c9ff80cSmrg	tmp_deplibs=
101079c9ff80cSmrg	for test_deplib in $deplibs; do
101089c9ff80cSmrg	  case " $convenience " in
101099c9ff80cSmrg	  *" $test_deplib "*) ;;
101109c9ff80cSmrg	  *)
101116fae4e5dSmrg	    func_append tmp_deplibs " $test_deplib"
101129c9ff80cSmrg	    ;;
101139c9ff80cSmrg	  esac
101149c9ff80cSmrg	done
10115d21ab8bcSmrg	deplibs=$tmp_deplibs
101161f0ac6a5Smrg
101179c9ff80cSmrg	if test -n "$convenience"; then
101189c9ff80cSmrg	  if test -n "$whole_archive_flag_spec" &&
10119d21ab8bcSmrg	    test yes = "$compiler_needs_object" &&
101209c9ff80cSmrg	    test -z "$libobjs"; then
101219c9ff80cSmrg	    # extract the archives, so we have objects to list.
101229c9ff80cSmrg	    # TODO: could optimize this to just extract one archive.
101239c9ff80cSmrg	    whole_archive_flag_spec=
101249c9ff80cSmrg	  fi
101259c9ff80cSmrg	  if test -n "$whole_archive_flag_spec"; then
101269c9ff80cSmrg	    save_libobjs=$libobjs
101279c9ff80cSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
101289c9ff80cSmrg	    test "X$libobjs" = "X " && libobjs=
101299c9ff80cSmrg	  else
10130d21ab8bcSmrg	    gentop=$output_objdir/${outputname}x
101316fae4e5dSmrg	    func_append generated " $gentop"
101321f0ac6a5Smrg
101339c9ff80cSmrg	    func_extract_archives $gentop $convenience
101346fae4e5dSmrg	    func_append libobjs " $func_extract_archives_result"
101359c9ff80cSmrg	    test "X$libobjs" = "X " && libobjs=
101369c9ff80cSmrg	  fi
101371f0ac6a5Smrg	fi
101381f0ac6a5Smrg
10139d21ab8bcSmrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
101409c9ff80cSmrg	  eval flag=\"$thread_safe_flag_spec\"
101416fae4e5dSmrg	  func_append linker_flags " $flag"
101421f0ac6a5Smrg	fi
101431f0ac6a5Smrg
101449c9ff80cSmrg	# Make a backup of the uninstalled library when relinking
10145d21ab8bcSmrg	if test relink = "$opt_mode"; then
101469c9ff80cSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
101479c9ff80cSmrg	fi
101481f0ac6a5Smrg
101499c9ff80cSmrg	# Do each of the archive commands.
10150d21ab8bcSmrg	if test yes = "$module" && test -n "$module_cmds"; then
101519c9ff80cSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
101529c9ff80cSmrg	    eval test_cmds=\"$module_expsym_cmds\"
101539c9ff80cSmrg	    cmds=$module_expsym_cmds
101549c9ff80cSmrg	  else
101559c9ff80cSmrg	    eval test_cmds=\"$module_cmds\"
101569c9ff80cSmrg	    cmds=$module_cmds
101579c9ff80cSmrg	  fi
101581f0ac6a5Smrg	else
101599c9ff80cSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
101609c9ff80cSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
101619c9ff80cSmrg	    cmds=$archive_expsym_cmds
101629c9ff80cSmrg	  else
101639c9ff80cSmrg	    eval test_cmds=\"$archive_cmds\"
101649c9ff80cSmrg	    cmds=$archive_cmds
101659c9ff80cSmrg	  fi
101661f0ac6a5Smrg	fi
101671f0ac6a5Smrg
10168d21ab8bcSmrg	if test : != "$skipped_export" &&
101699c9ff80cSmrg	   func_len " $test_cmds" &&
101709c9ff80cSmrg	   len=$func_len_result &&
101719c9ff80cSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
101729c9ff80cSmrg	  :
101739c9ff80cSmrg	else
101749c9ff80cSmrg	  # The command line is too long to link in one step, link piecewise
101759c9ff80cSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
101769c9ff80cSmrg	  # script.
101771f0ac6a5Smrg
101789c9ff80cSmrg	  # Save the value of $output and $libobjs because we want to
101799c9ff80cSmrg	  # use them later.  If we have whole_archive_flag_spec, we
101809c9ff80cSmrg	  # want to use save_libobjs as it was before
101819c9ff80cSmrg	  # whole_archive_flag_spec was expanded, because we can't
101829c9ff80cSmrg	  # assume the linker understands whole_archive_flag_spec.
101839c9ff80cSmrg	  # This may have to be revisited, in case too many
101849c9ff80cSmrg	  # convenience libraries get linked in and end up exceeding
101859c9ff80cSmrg	  # the spec.
101869c9ff80cSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
101879c9ff80cSmrg	    save_libobjs=$libobjs
101889c9ff80cSmrg	  fi
101899c9ff80cSmrg	  save_output=$output
101906fae4e5dSmrg	  func_basename "$output"
101916fae4e5dSmrg	  output_la=$func_basename_result
101921f0ac6a5Smrg
101939c9ff80cSmrg	  # Clear the reloadable object creation command queue and
101949c9ff80cSmrg	  # initialize k to one.
101959c9ff80cSmrg	  test_cmds=
101969c9ff80cSmrg	  concat_cmds=
101979c9ff80cSmrg	  objlist=
101989c9ff80cSmrg	  last_robj=
101999c9ff80cSmrg	  k=1
102009c9ff80cSmrg
102016ee7d557Smrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
10202d21ab8bcSmrg	    output=$output_objdir/$output_la.lnk
102039c9ff80cSmrg	    func_verbose "creating linker input file list: $output"
102049c9ff80cSmrg	    : > $output
102059c9ff80cSmrg	    set x $save_libobjs
102069c9ff80cSmrg	    shift
102079c9ff80cSmrg	    firstobj=
10208d21ab8bcSmrg	    if test yes = "$compiler_needs_object"; then
102099c9ff80cSmrg	      firstobj="$1 "
102109c9ff80cSmrg	      shift
102119c9ff80cSmrg	    fi
102129c9ff80cSmrg	    for obj
102139c9ff80cSmrg	    do
102146fae4e5dSmrg	      func_to_tool_file "$obj"
102156fae4e5dSmrg	      $ECHO "$func_to_tool_file_result" >> $output
102169c9ff80cSmrg	    done
102176fae4e5dSmrg	    func_append delfiles " $output"
102186fae4e5dSmrg	    func_to_tool_file "$output"
102196fae4e5dSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
102206ee7d557Smrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
102216ee7d557Smrg	    output=$output_objdir/$output_la.lnkscript
102226ee7d557Smrg	    func_verbose "creating GNU ld script: $output"
102236ee7d557Smrg	    echo 'INPUT (' > $output
102246ee7d557Smrg	    for obj in $save_libobjs
102256ee7d557Smrg	    do
102266ee7d557Smrg	      func_to_tool_file "$obj"
102276ee7d557Smrg	      $ECHO "$func_to_tool_file_result" >> $output
102286ee7d557Smrg	    done
102296ee7d557Smrg	    echo ')' >> $output
102306ee7d557Smrg	    func_append delfiles " $output"
102316ee7d557Smrg	    func_to_tool_file "$output"
102326ee7d557Smrg	    output=$func_to_tool_file_result
102339c9ff80cSmrg	  else
102349c9ff80cSmrg	    if test -n "$save_libobjs"; then
102359c9ff80cSmrg	      func_verbose "creating reloadable object files..."
10236d21ab8bcSmrg	      output=$output_objdir/$output_la-$k.$objext
102379c9ff80cSmrg	      eval test_cmds=\"$reload_cmds\"
102389c9ff80cSmrg	      func_len " $test_cmds"
102399c9ff80cSmrg	      len0=$func_len_result
102409c9ff80cSmrg	      len=$len0
102419c9ff80cSmrg
102429c9ff80cSmrg	      # Loop over the list of objects to be linked.
102439c9ff80cSmrg	      for obj in $save_libobjs
102449c9ff80cSmrg	      do
102459c9ff80cSmrg		func_len " $obj"
102469c9ff80cSmrg		func_arith $len + $func_len_result
102479c9ff80cSmrg		len=$func_arith_result
10248d21ab8bcSmrg		if test -z "$objlist" ||
102499c9ff80cSmrg		   test "$len" -lt "$max_cmd_len"; then
102509c9ff80cSmrg		  func_append objlist " $obj"
102519c9ff80cSmrg		else
102529c9ff80cSmrg		  # The command $test_cmds is almost too long, add a
102539c9ff80cSmrg		  # command to the queue.
10254d21ab8bcSmrg		  if test 1 -eq "$k"; then
102559c9ff80cSmrg		    # The first file doesn't have a previous command to add.
102566fae4e5dSmrg		    reload_objs=$objlist
102576fae4e5dSmrg		    eval concat_cmds=\"$reload_cmds\"
102589c9ff80cSmrg		  else
102599c9ff80cSmrg		    # All subsequent reloadable object files will link in
102609c9ff80cSmrg		    # the last one created.
102616fae4e5dSmrg		    reload_objs="$objlist $last_robj"
102626fae4e5dSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
102639c9ff80cSmrg		  fi
10264d21ab8bcSmrg		  last_robj=$output_objdir/$output_la-$k.$objext
102659c9ff80cSmrg		  func_arith $k + 1
102669c9ff80cSmrg		  k=$func_arith_result
10267d21ab8bcSmrg		  output=$output_objdir/$output_la-$k.$objext
102686fae4e5dSmrg		  objlist=" $obj"
102699c9ff80cSmrg		  func_len " $last_robj"
102709c9ff80cSmrg		  func_arith $len0 + $func_len_result
102719c9ff80cSmrg		  len=$func_arith_result
102729c9ff80cSmrg		fi
102739c9ff80cSmrg	      done
102749c9ff80cSmrg	      # Handle the remaining objects by creating one last
102759c9ff80cSmrg	      # reloadable object file.  All subsequent reloadable object
102769c9ff80cSmrg	      # files will link in the last one created.
102779c9ff80cSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
102786fae4e5dSmrg	      reload_objs="$objlist $last_robj"
10279d21ab8bcSmrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
102809c9ff80cSmrg	      if test -n "$last_robj"; then
10281d21ab8bcSmrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
102829c9ff80cSmrg	      fi
102836fae4e5dSmrg	      func_append delfiles " $output"
102841f0ac6a5Smrg
102859c9ff80cSmrg	    else
102869c9ff80cSmrg	      output=
102879c9ff80cSmrg	    fi
102881f0ac6a5Smrg
10289d21ab8bcSmrg	    ${skipped_export-false} && {
10290d21ab8bcSmrg	      func_verbose "generating symbol list for '$libname.la'"
10291d21ab8bcSmrg	      export_symbols=$output_objdir/$libname.exp
102929c9ff80cSmrg	      $opt_dry_run || $RM $export_symbols
102939c9ff80cSmrg	      libobjs=$output
102949c9ff80cSmrg	      # Append the command to create the export file.
102959c9ff80cSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
102969c9ff80cSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
102979c9ff80cSmrg	      if test -n "$last_robj"; then
102989c9ff80cSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
102999c9ff80cSmrg	      fi
10300d21ab8bcSmrg	    }
103011f0ac6a5Smrg
103029c9ff80cSmrg	    test -n "$save_libobjs" &&
103039c9ff80cSmrg	      func_verbose "creating a temporary reloadable object file: $output"
103041f0ac6a5Smrg
103059c9ff80cSmrg	    # Loop through the commands generated above and execute them.
10306d21ab8bcSmrg	    save_ifs=$IFS; IFS='~'
103079c9ff80cSmrg	    for cmd in $concat_cmds; do
10308d21ab8bcSmrg	      IFS=$save_ifs
10309d21ab8bcSmrg	      $opt_quiet || {
10310d21ab8bcSmrg		  func_quote_arg expand,pretty "$cmd"
10311d21ab8bcSmrg		  eval "func_echo $func_quote_arg_result"
103129c9ff80cSmrg	      }
103139c9ff80cSmrg	      $opt_dry_run || eval "$cmd" || {
103149c9ff80cSmrg		lt_exit=$?
103159c9ff80cSmrg
103169c9ff80cSmrg		# Restore the uninstalled library and exit
10317d21ab8bcSmrg		if test relink = "$opt_mode"; then
103189c9ff80cSmrg		  ( cd "$output_objdir" && \
103199c9ff80cSmrg		    $RM "${realname}T" && \
103209c9ff80cSmrg		    $MV "${realname}U" "$realname" )
103219c9ff80cSmrg		fi
103221f0ac6a5Smrg
103239c9ff80cSmrg		exit $lt_exit
103249c9ff80cSmrg	      }
103259c9ff80cSmrg	    done
10326d21ab8bcSmrg	    IFS=$save_ifs
103271f0ac6a5Smrg
103289c9ff80cSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
103299c9ff80cSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
103309c9ff80cSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
103311f0ac6a5Smrg	    fi
103321f0ac6a5Smrg	  fi
103331f0ac6a5Smrg
10334d21ab8bcSmrg          ${skipped_export-false} && {
103359c9ff80cSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
10336d21ab8bcSmrg	      tmp_export_symbols=$export_symbols
10337d21ab8bcSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
103386fae4e5dSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
103399c9ff80cSmrg	    fi
103401f0ac6a5Smrg
103419c9ff80cSmrg	    if test -n "$orig_export_symbols"; then
103429c9ff80cSmrg	      # The given exports_symbols file has to be filtered, so filter it.
10343d21ab8bcSmrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
103449c9ff80cSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
10345d21ab8bcSmrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
103469c9ff80cSmrg	      # though. Also, the filter scales superlinearly with the number of
103479c9ff80cSmrg	      # global variables. join(1) would be nice here, but unfortunately
103489c9ff80cSmrg	      # isn't a blessed tool.
103499c9ff80cSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
103506fae4e5dSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
103519c9ff80cSmrg	      export_symbols=$output_objdir/$libname.def
103529c9ff80cSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
103539c9ff80cSmrg	    fi
10354d21ab8bcSmrg	  }
103551f0ac6a5Smrg
103569c9ff80cSmrg	  libobjs=$output
103579c9ff80cSmrg	  # Restore the value of output.
103589c9ff80cSmrg	  output=$save_output
103591f0ac6a5Smrg
103609c9ff80cSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
103619c9ff80cSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
103629c9ff80cSmrg	    test "X$libobjs" = "X " && libobjs=
103639c9ff80cSmrg	  fi
103649c9ff80cSmrg	  # Expand the library linking commands again to reset the
103659c9ff80cSmrg	  # value of $libobjs for piecewise linking.
103661f0ac6a5Smrg
103679c9ff80cSmrg	  # Do each of the archive commands.
10368d21ab8bcSmrg	  if test yes = "$module" && test -n "$module_cmds"; then
103699c9ff80cSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
103709c9ff80cSmrg	      cmds=$module_expsym_cmds
103719c9ff80cSmrg	    else
103729c9ff80cSmrg	      cmds=$module_cmds
103731f0ac6a5Smrg	    fi
103741f0ac6a5Smrg	  else
103759c9ff80cSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
103769c9ff80cSmrg	      cmds=$archive_expsym_cmds
103779c9ff80cSmrg	    else
103789c9ff80cSmrg	      cmds=$archive_cmds
103799c9ff80cSmrg	    fi
103801f0ac6a5Smrg	  fi
103819c9ff80cSmrg	fi
103821f0ac6a5Smrg
103839c9ff80cSmrg	if test -n "$delfiles"; then
103849c9ff80cSmrg	  # Append the command to remove temporary files to $cmds.
103859c9ff80cSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
103869c9ff80cSmrg	fi
103871f0ac6a5Smrg
103889c9ff80cSmrg	# Add any objects from preloaded convenience libraries
103899c9ff80cSmrg	if test -n "$dlprefiles"; then
10390d21ab8bcSmrg	  gentop=$output_objdir/${outputname}x
103916fae4e5dSmrg	  func_append generated " $gentop"
103921f0ac6a5Smrg
103939c9ff80cSmrg	  func_extract_archives $gentop $dlprefiles
103946fae4e5dSmrg	  func_append libobjs " $func_extract_archives_result"
103959c9ff80cSmrg	  test "X$libobjs" = "X " && libobjs=
103969c9ff80cSmrg	fi
103971f0ac6a5Smrg
10398d21ab8bcSmrg	save_ifs=$IFS; IFS='~'
103999c9ff80cSmrg	for cmd in $cmds; do
10400d21ab8bcSmrg	  IFS=$sp$nl
104019c9ff80cSmrg	  eval cmd=\"$cmd\"
10402d21ab8bcSmrg	  IFS=$save_ifs
10403d21ab8bcSmrg	  $opt_quiet || {
10404d21ab8bcSmrg	    func_quote_arg expand,pretty "$cmd"
10405d21ab8bcSmrg	    eval "func_echo $func_quote_arg_result"
104069c9ff80cSmrg	  }
104079c9ff80cSmrg	  $opt_dry_run || eval "$cmd" || {
104089c9ff80cSmrg	    lt_exit=$?
104091f0ac6a5Smrg
104109c9ff80cSmrg	    # Restore the uninstalled library and exit
10411d21ab8bcSmrg	    if test relink = "$opt_mode"; then
104129c9ff80cSmrg	      ( cd "$output_objdir" && \
104139c9ff80cSmrg	        $RM "${realname}T" && \
104149c9ff80cSmrg		$MV "${realname}U" "$realname" )
104159c9ff80cSmrg	    fi
104161f0ac6a5Smrg
104179c9ff80cSmrg	    exit $lt_exit
104189c9ff80cSmrg	  }
104199c9ff80cSmrg	done
10420d21ab8bcSmrg	IFS=$save_ifs
104211f0ac6a5Smrg
104229c9ff80cSmrg	# Restore the uninstalled library and exit
10423d21ab8bcSmrg	if test relink = "$opt_mode"; then
104249c9ff80cSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
104251f0ac6a5Smrg
104269c9ff80cSmrg	  if test -n "$convenience"; then
104279c9ff80cSmrg	    if test -z "$whole_archive_flag_spec"; then
104289c9ff80cSmrg	      func_show_eval '${RM}r "$gentop"'
104299c9ff80cSmrg	    fi
104309c9ff80cSmrg	  fi
104311f0ac6a5Smrg
104329c9ff80cSmrg	  exit $EXIT_SUCCESS
104339c9ff80cSmrg	fi
104349c9ff80cSmrg
104359c9ff80cSmrg	# Create links to the real library.
104369c9ff80cSmrg	for linkname in $linknames; do
104379c9ff80cSmrg	  if test "$realname" != "$linkname"; then
104389c9ff80cSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
104391f0ac6a5Smrg	  fi
104401f0ac6a5Smrg	done
104411f0ac6a5Smrg
104429c9ff80cSmrg	# If -module or -export-dynamic was specified, set the dlname.
10443d21ab8bcSmrg	if test yes = "$module" || test yes = "$export_dynamic"; then
104449c9ff80cSmrg	  # On all known operating systems, these are identical.
10445d21ab8bcSmrg	  dlname=$soname
104469c9ff80cSmrg	fi
104479c9ff80cSmrg      fi
104481f0ac6a5Smrg      ;;
104491f0ac6a5Smrg
104509c9ff80cSmrg    obj)
10451d21ab8bcSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
10452d21ab8bcSmrg	func_warning "'-dlopen' is ignored for objects"
104539c9ff80cSmrg      fi
104541f0ac6a5Smrg
104559c9ff80cSmrg      case " $deplibs" in
104569c9ff80cSmrg      *\ -l* | *\ -L*)
10457d21ab8bcSmrg	func_warning "'-l' and '-L' are ignored for objects" ;;
104581f0ac6a5Smrg      esac
104591f0ac6a5Smrg
104609c9ff80cSmrg      test -n "$rpath" && \
10461d21ab8bcSmrg	func_warning "'-rpath' is ignored for objects"
104629c9ff80cSmrg
104639c9ff80cSmrg      test -n "$xrpath" && \
10464d21ab8bcSmrg	func_warning "'-R' is ignored for objects"
104651f0ac6a5Smrg
104669c9ff80cSmrg      test -n "$vinfo" && \
10467d21ab8bcSmrg	func_warning "'-version-info' is ignored for objects"
104681f0ac6a5Smrg
104699c9ff80cSmrg      test -n "$release" && \
10470d21ab8bcSmrg	func_warning "'-release' is ignored for objects"
104719c9ff80cSmrg
104729c9ff80cSmrg      case $output in
104739c9ff80cSmrg      *.lo)
104749c9ff80cSmrg	test -n "$objs$old_deplibs" && \
10475d21ab8bcSmrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
104769c9ff80cSmrg
104779c9ff80cSmrg	libobj=$output
104789c9ff80cSmrg	func_lo2o "$libobj"
104799c9ff80cSmrg	obj=$func_lo2o_result
104801f0ac6a5Smrg	;;
104811f0ac6a5Smrg      *)
104829c9ff80cSmrg	libobj=
10483d21ab8bcSmrg	obj=$output
104841f0ac6a5Smrg	;;
104851f0ac6a5Smrg      esac
104861f0ac6a5Smrg
104879c9ff80cSmrg      # Delete the old objects.
104889c9ff80cSmrg      $opt_dry_run || $RM $obj $libobj
104891f0ac6a5Smrg
104909c9ff80cSmrg      # Objects from convenience libraries.  This assumes
104919c9ff80cSmrg      # single-version convenience libraries.  Whenever we create
104929c9ff80cSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
104939c9ff80cSmrg      # the extraction.
104949c9ff80cSmrg      reload_conv_objs=
104959c9ff80cSmrg      gentop=
10496d21ab8bcSmrg      # if reload_cmds runs $LD directly, get rid of -Wl from
10497d21ab8bcSmrg      # whole_archive_flag_spec and hope we can get by with turning comma
10498d21ab8bcSmrg      # into space.
10499d21ab8bcSmrg      case $reload_cmds in
10500d21ab8bcSmrg        *\$LD[\ \$]*) wl= ;;
10501d21ab8bcSmrg      esac
105029c9ff80cSmrg      if test -n "$convenience"; then
105039c9ff80cSmrg	if test -n "$whole_archive_flag_spec"; then
105049c9ff80cSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
10505d21ab8bcSmrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
10506d21ab8bcSmrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
105079c9ff80cSmrg	else
10508d21ab8bcSmrg	  gentop=$output_objdir/${obj}x
105096fae4e5dSmrg	  func_append generated " $gentop"
105101f0ac6a5Smrg
105119c9ff80cSmrg	  func_extract_archives $gentop $convenience
105129c9ff80cSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
105139c9ff80cSmrg	fi
105141f0ac6a5Smrg      fi
105151f0ac6a5Smrg
105166fae4e5dSmrg      # If we're not building shared, we need to use non_pic_objs
10517d21ab8bcSmrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
105186fae4e5dSmrg
105199c9ff80cSmrg      # Create the old-style object.
10520d21ab8bcSmrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
105211f0ac6a5Smrg
10522d21ab8bcSmrg      output=$obj
105239c9ff80cSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
105241f0ac6a5Smrg
105259c9ff80cSmrg      # Exit if we aren't doing a library object file.
105269c9ff80cSmrg      if test -z "$libobj"; then
105279c9ff80cSmrg	if test -n "$gentop"; then
105289c9ff80cSmrg	  func_show_eval '${RM}r "$gentop"'
105299c9ff80cSmrg	fi
105309c9ff80cSmrg
105319c9ff80cSmrg	exit $EXIT_SUCCESS
105321f0ac6a5Smrg      fi
105339c9ff80cSmrg
10534d21ab8bcSmrg      test yes = "$build_libtool_libs" || {
105359c9ff80cSmrg	if test -n "$gentop"; then
105369c9ff80cSmrg	  func_show_eval '${RM}r "$gentop"'
105379c9ff80cSmrg	fi
105389c9ff80cSmrg
105399c9ff80cSmrg	# Create an invalid libtool object if no PIC, so that we don't
105409c9ff80cSmrg	# accidentally link it into a program.
105419c9ff80cSmrg	# $show "echo timestamp > $libobj"
105429c9ff80cSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
105439c9ff80cSmrg	exit $EXIT_SUCCESS
10544d21ab8bcSmrg      }
105459c9ff80cSmrg
10546d21ab8bcSmrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
105479c9ff80cSmrg	# Only do commands if we really have different PIC objects.
105489c9ff80cSmrg	reload_objs="$libobjs $reload_conv_objs"
10549d21ab8bcSmrg	output=$libobj
105509c9ff80cSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
105519c9ff80cSmrg      fi
105529c9ff80cSmrg
105539c9ff80cSmrg      if test -n "$gentop"; then
105549c9ff80cSmrg	func_show_eval '${RM}r "$gentop"'
105559c9ff80cSmrg      fi
105569c9ff80cSmrg
105579c9ff80cSmrg      exit $EXIT_SUCCESS
105581f0ac6a5Smrg      ;;
105591f0ac6a5Smrg
105609c9ff80cSmrg    prog)
105619c9ff80cSmrg      case $host in
105629c9ff80cSmrg	*cygwin*) func_stripname '' '.exe' "$output"
105639c9ff80cSmrg	          output=$func_stripname_result.exe;;
105649c9ff80cSmrg      esac
105659c9ff80cSmrg      test -n "$vinfo" && \
10566d21ab8bcSmrg	func_warning "'-version-info' is ignored for programs"
105671f0ac6a5Smrg
105689c9ff80cSmrg      test -n "$release" && \
10569d21ab8bcSmrg	func_warning "'-release' is ignored for programs"
105701f0ac6a5Smrg
10571d21ab8bcSmrg      $preload \
10572d21ab8bcSmrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
10573d21ab8bcSmrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
105749c9ff80cSmrg
105759c9ff80cSmrg      case $host in
105769c9ff80cSmrg      *-*-rhapsody* | *-*-darwin1.[012])
105779c9ff80cSmrg	# On Rhapsody replace the C library is the System framework
105786fae4e5dSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
105796fae4e5dSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
105801f0ac6a5Smrg	;;
105819c9ff80cSmrg      esac
105821f0ac6a5Smrg
105839c9ff80cSmrg      case $host in
105849c9ff80cSmrg      *-*-darwin*)
105859c9ff80cSmrg	# Don't allow lazy linking, it breaks C++ global constructors
105869c9ff80cSmrg	# But is supposedly fixed on 10.4 or later (yay!).
10587d21ab8bcSmrg	if test CXX = "$tagname"; then
105889c9ff80cSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
105899c9ff80cSmrg	    10.[0123])
10590d21ab8bcSmrg	      func_append compile_command " $wl-bind_at_load"
10591d21ab8bcSmrg	      func_append finalize_command " $wl-bind_at_load"
105929c9ff80cSmrg	    ;;
105939c9ff80cSmrg	  esac
105941f0ac6a5Smrg	fi
105959c9ff80cSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
105966fae4e5dSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
105976fae4e5dSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
105989c9ff80cSmrg	;;
105999c9ff80cSmrg      esac
106001f0ac6a5Smrg
106011f0ac6a5Smrg
106029c9ff80cSmrg      # move library search paths that coincide with paths to not yet
106039c9ff80cSmrg      # installed libraries to the beginning of the library search list
106049c9ff80cSmrg      new_libs=
106059c9ff80cSmrg      for path in $notinst_path; do
106069c9ff80cSmrg	case " $new_libs " in
106079c9ff80cSmrg	*" -L$path/$objdir "*) ;;
106089c9ff80cSmrg	*)
106099c9ff80cSmrg	  case " $compile_deplibs " in
106109c9ff80cSmrg	  *" -L$path/$objdir "*)
106116fae4e5dSmrg	    func_append new_libs " -L$path/$objdir" ;;
106121f0ac6a5Smrg	  esac
106139c9ff80cSmrg	  ;;
106149c9ff80cSmrg	esac
106159c9ff80cSmrg      done
106169c9ff80cSmrg      for deplib in $compile_deplibs; do
106179c9ff80cSmrg	case $deplib in
106189c9ff80cSmrg	-L*)
106199c9ff80cSmrg	  case " $new_libs " in
106209c9ff80cSmrg	  *" $deplib "*) ;;
106216fae4e5dSmrg	  *) func_append new_libs " $deplib" ;;
106221f0ac6a5Smrg	  esac
106239c9ff80cSmrg	  ;;
106246fae4e5dSmrg	*) func_append new_libs " $deplib" ;;
106259c9ff80cSmrg	esac
106269c9ff80cSmrg      done
10627d21ab8bcSmrg      compile_deplibs=$new_libs
106281f0ac6a5Smrg
106291f0ac6a5Smrg
106306fae4e5dSmrg      func_append compile_command " $compile_deplibs"
106316fae4e5dSmrg      func_append finalize_command " $finalize_deplibs"
106321f0ac6a5Smrg
106339c9ff80cSmrg      if test -n "$rpath$xrpath"; then
106349c9ff80cSmrg	# If the user specified any rpath flags, then add them.
106359c9ff80cSmrg	for libdir in $rpath $xrpath; do
106369c9ff80cSmrg	  # This is the magic to use -rpath.
106379c9ff80cSmrg	  case "$finalize_rpath " in
106389c9ff80cSmrg	  *" $libdir "*) ;;
106396fae4e5dSmrg	  *) func_append finalize_rpath " $libdir" ;;
106409c9ff80cSmrg	  esac
106419c9ff80cSmrg	done
106429c9ff80cSmrg      fi
106431f0ac6a5Smrg
106449c9ff80cSmrg      # Now hardcode the library paths
106459c9ff80cSmrg      rpath=
106469c9ff80cSmrg      hardcode_libdirs=
106479c9ff80cSmrg      for libdir in $compile_rpath $finalize_rpath; do
106489c9ff80cSmrg	if test -n "$hardcode_libdir_flag_spec"; then
106499c9ff80cSmrg	  if test -n "$hardcode_libdir_separator"; then
106509c9ff80cSmrg	    if test -z "$hardcode_libdirs"; then
10651d21ab8bcSmrg	      hardcode_libdirs=$libdir
106529c9ff80cSmrg	    else
106539c9ff80cSmrg	      # Just accumulate the unique libdirs.
106549c9ff80cSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
106559c9ff80cSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
106569c9ff80cSmrg		;;
106579c9ff80cSmrg	      *)
106586fae4e5dSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
106599c9ff80cSmrg		;;
106609c9ff80cSmrg	      esac
106619c9ff80cSmrg	    fi
106621f0ac6a5Smrg	  else
106639c9ff80cSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
106646fae4e5dSmrg	    func_append rpath " $flag"
106651f0ac6a5Smrg	  fi
106669c9ff80cSmrg	elif test -n "$runpath_var"; then
106679c9ff80cSmrg	  case "$perm_rpath " in
106689c9ff80cSmrg	  *" $libdir "*) ;;
106696fae4e5dSmrg	  *) func_append perm_rpath " $libdir" ;;
106709c9ff80cSmrg	  esac
106719c9ff80cSmrg	fi
106729c9ff80cSmrg	case $host in
106736ee7d557Smrg	*-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*)
10674d21ab8bcSmrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
106759c9ff80cSmrg	  case :$dllsearchpath: in
106769c9ff80cSmrg	  *":$libdir:"*) ;;
106779c9ff80cSmrg	  ::) dllsearchpath=$libdir;;
106786fae4e5dSmrg	  *) func_append dllsearchpath ":$libdir";;
106799c9ff80cSmrg	  esac
106809c9ff80cSmrg	  case :$dllsearchpath: in
106819c9ff80cSmrg	  *":$testbindir:"*) ;;
106829c9ff80cSmrg	  ::) dllsearchpath=$testbindir;;
106836fae4e5dSmrg	  *) func_append dllsearchpath ":$testbindir";;
106849c9ff80cSmrg	  esac
106859c9ff80cSmrg	  ;;
106869c9ff80cSmrg	esac
106879c9ff80cSmrg      done
106889c9ff80cSmrg      # Substitute the hardcoded libdirs into the rpath.
106899c9ff80cSmrg      if test -n "$hardcode_libdir_separator" &&
106909c9ff80cSmrg	 test -n "$hardcode_libdirs"; then
10691d21ab8bcSmrg	libdir=$hardcode_libdirs
106929c9ff80cSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
106939c9ff80cSmrg      fi
10694d21ab8bcSmrg      compile_rpath=$rpath
106951f0ac6a5Smrg
106969c9ff80cSmrg      rpath=
106979c9ff80cSmrg      hardcode_libdirs=
106989c9ff80cSmrg      for libdir in $finalize_rpath; do
106999c9ff80cSmrg	if test -n "$hardcode_libdir_flag_spec"; then
107009c9ff80cSmrg	  if test -n "$hardcode_libdir_separator"; then
107019c9ff80cSmrg	    if test -z "$hardcode_libdirs"; then
10702d21ab8bcSmrg	      hardcode_libdirs=$libdir
107039c9ff80cSmrg	    else
107049c9ff80cSmrg	      # Just accumulate the unique libdirs.
107059c9ff80cSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
107069c9ff80cSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
107079c9ff80cSmrg		;;
107089c9ff80cSmrg	      *)
107096fae4e5dSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
107109c9ff80cSmrg		;;
107119c9ff80cSmrg	      esac
107129c9ff80cSmrg	    fi
107131f0ac6a5Smrg	  else
107149c9ff80cSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
107156fae4e5dSmrg	    func_append rpath " $flag"
107161f0ac6a5Smrg	  fi
107179c9ff80cSmrg	elif test -n "$runpath_var"; then
107189c9ff80cSmrg	  case "$finalize_perm_rpath " in
107199c9ff80cSmrg	  *" $libdir "*) ;;
107206fae4e5dSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
107219c9ff80cSmrg	  esac
107221f0ac6a5Smrg	fi
107239c9ff80cSmrg      done
107249c9ff80cSmrg      # Substitute the hardcoded libdirs into the rpath.
107259c9ff80cSmrg      if test -n "$hardcode_libdir_separator" &&
107269c9ff80cSmrg	 test -n "$hardcode_libdirs"; then
10727d21ab8bcSmrg	libdir=$hardcode_libdirs
107289c9ff80cSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
107299c9ff80cSmrg      fi
10730d21ab8bcSmrg      finalize_rpath=$rpath
107311f0ac6a5Smrg
10732d21ab8bcSmrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
107339c9ff80cSmrg	# Transform all the library objects into standard objects.
107346fae4e5dSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
107356fae4e5dSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
107369c9ff80cSmrg      fi
107371f0ac6a5Smrg
10738d21ab8bcSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
107391f0ac6a5Smrg
107409c9ff80cSmrg      # template prelinking step
107419c9ff80cSmrg      if test -n "$prelink_cmds"; then
107429c9ff80cSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
107439c9ff80cSmrg      fi
107441f0ac6a5Smrg
10745d21ab8bcSmrg      wrappers_required=:
107469c9ff80cSmrg      case $host in
107476fae4e5dSmrg      *cegcc* | *mingw32ce*)
107486fae4e5dSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
10749d21ab8bcSmrg        wrappers_required=false
107506fae4e5dSmrg        ;;
107516ee7d557Smrg      *cygwin* | *mingw* | *windows* )
10752d21ab8bcSmrg        test yes = "$build_libtool_libs" || wrappers_required=false
107539c9ff80cSmrg        ;;
107549c9ff80cSmrg      *)
10755d21ab8bcSmrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
10756d21ab8bcSmrg          wrappers_required=false
107579c9ff80cSmrg        fi
107589c9ff80cSmrg        ;;
107599c9ff80cSmrg      esac
10760d21ab8bcSmrg      $wrappers_required || {
107619c9ff80cSmrg	# Replace the output file specification.
107626fae4e5dSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10763d21ab8bcSmrg	link_command=$compile_command$compile_rpath
107641f0ac6a5Smrg
107659c9ff80cSmrg	# We have no uninstalled library dependencies, so finalize right now.
107669c9ff80cSmrg	exit_status=0
107679c9ff80cSmrg	func_show_eval "$link_command" 'exit_status=$?'
107681f0ac6a5Smrg
107696fae4e5dSmrg	if test -n "$postlink_cmds"; then
107706fae4e5dSmrg	  func_to_tool_file "$output"
107716fae4e5dSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
107726fae4e5dSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
107736fae4e5dSmrg	fi
107746fae4e5dSmrg
107759c9ff80cSmrg	# Delete the generated files.
10776d21ab8bcSmrg	if test -f "$output_objdir/${outputname}S.$objext"; then
10777d21ab8bcSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
107781f0ac6a5Smrg	fi
107791f0ac6a5Smrg
107809c9ff80cSmrg	exit $exit_status
10781d21ab8bcSmrg      }
107821f0ac6a5Smrg
107839c9ff80cSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
107849c9ff80cSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
107859c9ff80cSmrg      fi
107869c9ff80cSmrg      if test -n "$finalize_shlibpath"; then
107879c9ff80cSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
107889c9ff80cSmrg      fi
107891f0ac6a5Smrg
107909c9ff80cSmrg      compile_var=
107919c9ff80cSmrg      finalize_var=
107929c9ff80cSmrg      if test -n "$runpath_var"; then
107939c9ff80cSmrg	if test -n "$perm_rpath"; then
107949c9ff80cSmrg	  # We should set the runpath_var.
107959c9ff80cSmrg	  rpath=
107969c9ff80cSmrg	  for dir in $perm_rpath; do
107976fae4e5dSmrg	    func_append rpath "$dir:"
107989c9ff80cSmrg	  done
107999c9ff80cSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
108001f0ac6a5Smrg	fi
108019c9ff80cSmrg	if test -n "$finalize_perm_rpath"; then
108029c9ff80cSmrg	  # We should set the runpath_var.
108039c9ff80cSmrg	  rpath=
108049c9ff80cSmrg	  for dir in $finalize_perm_rpath; do
108056fae4e5dSmrg	    func_append rpath "$dir:"
108069c9ff80cSmrg	  done
108079c9ff80cSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
108081f0ac6a5Smrg	fi
108099c9ff80cSmrg      fi
108101f0ac6a5Smrg
10811d21ab8bcSmrg      if test yes = "$no_install"; then
108129c9ff80cSmrg	# We don't need to create a wrapper script.
10813d21ab8bcSmrg	link_command=$compile_var$compile_command$compile_rpath
108149c9ff80cSmrg	# Replace the output file specification.
108156fae4e5dSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
108169c9ff80cSmrg	# Delete the old output file.
108179c9ff80cSmrg	$opt_dry_run || $RM $output
108189c9ff80cSmrg	# Link the executable and exit
108199c9ff80cSmrg	func_show_eval "$link_command" 'exit $?'
108206fae4e5dSmrg
108216fae4e5dSmrg	if test -n "$postlink_cmds"; then
108226fae4e5dSmrg	  func_to_tool_file "$output"
108236fae4e5dSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
108246fae4e5dSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
108256fae4e5dSmrg	fi
108266fae4e5dSmrg
108271f0ac6a5Smrg	exit $EXIT_SUCCESS
108289c9ff80cSmrg      fi
108291f0ac6a5Smrg
10830d21ab8bcSmrg      case $hardcode_action,$fast_install in
10831d21ab8bcSmrg        relink,*)
10832d21ab8bcSmrg	  # Fast installation is not supported
10833d21ab8bcSmrg	  link_command=$compile_var$compile_command$compile_rpath
10834d21ab8bcSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
108359c9ff80cSmrg
10836d21ab8bcSmrg	  func_warning "this platform does not like uninstalled shared libraries"
10837d21ab8bcSmrg	  func_warning "'$output' will be relinked during installation"
10838d21ab8bcSmrg	  ;;
10839d21ab8bcSmrg        *,yes)
10840d21ab8bcSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
10841d21ab8bcSmrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
10842d21ab8bcSmrg          ;;
10843d21ab8bcSmrg	*,no)
10844d21ab8bcSmrg	  link_command=$compile_var$compile_command$compile_rpath
10845d21ab8bcSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10846d21ab8bcSmrg          ;;
10847d21ab8bcSmrg	*,needless)
10848d21ab8bcSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
10849d21ab8bcSmrg	  relink_command=
10850d21ab8bcSmrg          ;;
10851d21ab8bcSmrg      esac
108521f0ac6a5Smrg
108539c9ff80cSmrg      # Replace the output file specification.
108546fae4e5dSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
108551f0ac6a5Smrg
108569c9ff80cSmrg      # Delete the old output files.
108579c9ff80cSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
108581f0ac6a5Smrg
108599c9ff80cSmrg      func_show_eval "$link_command" 'exit $?'
108601f0ac6a5Smrg
108616fae4e5dSmrg      if test -n "$postlink_cmds"; then
108626fae4e5dSmrg	func_to_tool_file "$output_objdir/$outputname"
108636fae4e5dSmrg	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'`
108646fae4e5dSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
108656fae4e5dSmrg      fi
108666fae4e5dSmrg
108679c9ff80cSmrg      # Now create the wrapper script.
108689c9ff80cSmrg      func_verbose "creating $output"
108691f0ac6a5Smrg
108709c9ff80cSmrg      # Quote the relink command for shipping.
108719c9ff80cSmrg      if test -n "$relink_command"; then
108729c9ff80cSmrg	# Preserve any variables that may affect compiler behavior
108739c9ff80cSmrg	for var in $variables_saved_for_relink; do
108749c9ff80cSmrg	  if eval test -z \"\${$var+set}\"; then
108759c9ff80cSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
108769c9ff80cSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
108779c9ff80cSmrg	    relink_command="$var=; export $var; $relink_command"
108781f0ac6a5Smrg	  else
10879d21ab8bcSmrg	    func_quote_arg pretty "$var_value"
10880d21ab8bcSmrg	    relink_command="$var=$func_quote_arg_result; export $var; $relink_command"
108811f0ac6a5Smrg	  fi
108829c9ff80cSmrg	done
10883d21ab8bcSmrg	func_quote eval cd "`pwd`"
10884d21ab8bcSmrg	func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)"
10885d21ab8bcSmrg	relink_command=$func_quote_arg_unquoted_result
108869c9ff80cSmrg      fi
108879c9ff80cSmrg
108889c9ff80cSmrg      # Only actually do things if not in dry run mode.
108899c9ff80cSmrg      $opt_dry_run || {
108909c9ff80cSmrg	# win32 will think the script is a binary if it has
108919c9ff80cSmrg	# a .exe suffix, so we strip it off here.
108929c9ff80cSmrg	case $output in
108939c9ff80cSmrg	  *.exe) func_stripname '' '.exe' "$output"
108949c9ff80cSmrg	         output=$func_stripname_result ;;
108959c9ff80cSmrg	esac
108969c9ff80cSmrg	# test for cygwin because mv fails w/o .exe extensions
108979c9ff80cSmrg	case $host in
108989c9ff80cSmrg	  *cygwin*)
108999c9ff80cSmrg	    exeext=.exe
109009c9ff80cSmrg	    func_stripname '' '.exe' "$outputname"
109019c9ff80cSmrg	    outputname=$func_stripname_result ;;
109029c9ff80cSmrg	  *) exeext= ;;
109031f0ac6a5Smrg	esac
109049c9ff80cSmrg	case $host in
109056ee7d557Smrg	  *cygwin* | *mingw* | windows* )
109069c9ff80cSmrg	    func_dirname_and_basename "$output" "" "."
109079c9ff80cSmrg	    output_name=$func_basename_result
109089c9ff80cSmrg	    output_path=$func_dirname_result
10909d21ab8bcSmrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
10910d21ab8bcSmrg	    cwrapper=$output_path/$output_name.exe
109119c9ff80cSmrg	    $RM $cwrappersource $cwrapper
109129c9ff80cSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
109139c9ff80cSmrg
109149c9ff80cSmrg	    func_emit_cwrapperexe_src > $cwrappersource
109159c9ff80cSmrg
109169c9ff80cSmrg	    # The wrapper executable is built using the $host compiler,
109179c9ff80cSmrg	    # because it contains $host paths and files. If cross-
109189c9ff80cSmrg	    # compiling, it, like the target executable, must be
109199c9ff80cSmrg	    # executed on the $host or under an emulation environment.
109209c9ff80cSmrg	    $opt_dry_run || {
109219c9ff80cSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
109229c9ff80cSmrg	      $STRIP $cwrapper
109239c9ff80cSmrg	    }
109241f0ac6a5Smrg
109259c9ff80cSmrg	    # Now, create the wrapper script for func_source use:
109269c9ff80cSmrg	    func_ltwrapper_scriptname $cwrapper
109279c9ff80cSmrg	    $RM $func_ltwrapper_scriptname_result
109289c9ff80cSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
109299c9ff80cSmrg	    $opt_dry_run || {
109309c9ff80cSmrg	      # note: this script will not be executed, so do not chmod.
10931d21ab8bcSmrg	      if test "x$build" = "x$host"; then
109329c9ff80cSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
109339c9ff80cSmrg	      else
109349c9ff80cSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
109359c9ff80cSmrg	      fi
109369c9ff80cSmrg	    }
109379c9ff80cSmrg	  ;;
109389c9ff80cSmrg	  * )
109399c9ff80cSmrg	    $RM $output
109409c9ff80cSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
109411f0ac6a5Smrg
109429c9ff80cSmrg	    func_emit_wrapper no > $output
109439c9ff80cSmrg	    chmod +x $output
109449c9ff80cSmrg	  ;;
109459c9ff80cSmrg	esac
109469c9ff80cSmrg      }
109479c9ff80cSmrg      exit $EXIT_SUCCESS
109489c9ff80cSmrg      ;;
109499c9ff80cSmrg    esac
109501f0ac6a5Smrg
109519c9ff80cSmrg    # See if we need to build an old-fashioned archive.
109529c9ff80cSmrg    for oldlib in $oldlibs; do
109531f0ac6a5Smrg
10954d21ab8bcSmrg      case $build_libtool_libs in
10955d21ab8bcSmrg        convenience)
10956d21ab8bcSmrg	  oldobjs="$libobjs_save $symfileobj"
10957d21ab8bcSmrg	  addlibs=$convenience
109589c9ff80cSmrg	  build_libtool_libs=no
10959d21ab8bcSmrg	  ;;
10960d21ab8bcSmrg	module)
10961d21ab8bcSmrg	  oldobjs=$libobjs_save
10962d21ab8bcSmrg	  addlibs=$old_convenience
10963d21ab8bcSmrg	  build_libtool_libs=no
10964d21ab8bcSmrg          ;;
10965d21ab8bcSmrg	*)
109669c9ff80cSmrg	  oldobjs="$old_deplibs $non_pic_objects"
10967d21ab8bcSmrg	  $preload && test -f "$symfileobj" \
10968d21ab8bcSmrg	    && func_append oldobjs " $symfileobj"
10969d21ab8bcSmrg	  addlibs=$old_convenience
10970d21ab8bcSmrg	  ;;
10971d21ab8bcSmrg      esac
109721f0ac6a5Smrg
109739c9ff80cSmrg      if test -n "$addlibs"; then
10974d21ab8bcSmrg	gentop=$output_objdir/${outputname}x
109756fae4e5dSmrg	func_append generated " $gentop"
109761f0ac6a5Smrg
109779c9ff80cSmrg	func_extract_archives $gentop $addlibs
109786fae4e5dSmrg	func_append oldobjs " $func_extract_archives_result"
109799c9ff80cSmrg      fi
109801f0ac6a5Smrg
109819c9ff80cSmrg      # Do each command in the archive commands.
10982d21ab8bcSmrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
109839c9ff80cSmrg	cmds=$old_archive_from_new_cmds
109849c9ff80cSmrg      else
109851f0ac6a5Smrg
109869c9ff80cSmrg	# Add any objects from preloaded convenience libraries
109879c9ff80cSmrg	if test -n "$dlprefiles"; then
10988d21ab8bcSmrg	  gentop=$output_objdir/${outputname}x
109896fae4e5dSmrg	  func_append generated " $gentop"
109901f0ac6a5Smrg
109919c9ff80cSmrg	  func_extract_archives $gentop $dlprefiles
109926fae4e5dSmrg	  func_append oldobjs " $func_extract_archives_result"
109939c9ff80cSmrg	fi
109941f0ac6a5Smrg
109959c9ff80cSmrg	# POSIX demands no paths to be encoded in archives.  We have
109969c9ff80cSmrg	# to avoid creating archives with duplicate basenames if we
109979c9ff80cSmrg	# might have to extract them afterwards, e.g., when creating a
109989c9ff80cSmrg	# static archive out of a convenience library, or when linking
109999c9ff80cSmrg	# the entirety of a libtool archive into another (currently
110009c9ff80cSmrg	# not supported by libtool).
110019c9ff80cSmrg	if (for obj in $oldobjs
110029c9ff80cSmrg	    do
110039c9ff80cSmrg	      func_basename "$obj"
110049c9ff80cSmrg	      $ECHO "$func_basename_result"
110059c9ff80cSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
110069c9ff80cSmrg	  :
110079c9ff80cSmrg	else
110086fae4e5dSmrg	  echo "copying selected object files to avoid basename conflicts..."
11009d21ab8bcSmrg	  gentop=$output_objdir/${outputname}x
110106fae4e5dSmrg	  func_append generated " $gentop"
110119c9ff80cSmrg	  func_mkdir_p "$gentop"
110129c9ff80cSmrg	  save_oldobjs=$oldobjs
110139c9ff80cSmrg	  oldobjs=
110149c9ff80cSmrg	  counter=1
110159c9ff80cSmrg	  for obj in $save_oldobjs
110169c9ff80cSmrg	  do
110179c9ff80cSmrg	    func_basename "$obj"
11018d21ab8bcSmrg	    objbase=$func_basename_result
110199c9ff80cSmrg	    case " $oldobjs " in
110209c9ff80cSmrg	    " ") oldobjs=$obj ;;
110219c9ff80cSmrg	    *[\ /]"$objbase "*)
110229c9ff80cSmrg	      while :; do
110239c9ff80cSmrg		# Make sure we don't pick an alternate name that also
110249c9ff80cSmrg		# overlaps.
110259c9ff80cSmrg		newobj=lt$counter-$objbase
110269c9ff80cSmrg		func_arith $counter + 1
110279c9ff80cSmrg		counter=$func_arith_result
110289c9ff80cSmrg		case " $oldobjs " in
110299c9ff80cSmrg		*[\ /]"$newobj "*) ;;
110309c9ff80cSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
110319c9ff80cSmrg		esac
110329c9ff80cSmrg	      done
110339c9ff80cSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
110346fae4e5dSmrg	      func_append oldobjs " $gentop/$newobj"
110359c9ff80cSmrg	      ;;
110366fae4e5dSmrg	    *) func_append oldobjs " $obj" ;;
110379c9ff80cSmrg	    esac
110381f0ac6a5Smrg	  done
110391f0ac6a5Smrg	fi
1104089c04b6cSmrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
1104189c04b6cSmrg	tool_oldlib=$func_to_tool_file_result
110429c9ff80cSmrg	eval cmds=\"$old_archive_cmds\"
110431f0ac6a5Smrg
110449c9ff80cSmrg	func_len " $cmds"
110459c9ff80cSmrg	len=$func_len_result
110469c9ff80cSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
110479c9ff80cSmrg	  cmds=$old_archive_cmds
110486fae4e5dSmrg	elif test -n "$archiver_list_spec"; then
110496fae4e5dSmrg	  func_verbose "using command file archive linking..."
110506fae4e5dSmrg	  for obj in $oldobjs
110516fae4e5dSmrg	  do
110526fae4e5dSmrg	    func_to_tool_file "$obj"
110536fae4e5dSmrg	    $ECHO "$func_to_tool_file_result"
110546fae4e5dSmrg	  done > $output_objdir/$libname.libcmd
110556fae4e5dSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
110566fae4e5dSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
110576fae4e5dSmrg	  cmds=$old_archive_cmds
110589c9ff80cSmrg	else
110599c9ff80cSmrg	  # the command line is too long to link in one step, link in parts
110609c9ff80cSmrg	  func_verbose "using piecewise archive linking..."
110619c9ff80cSmrg	  save_RANLIB=$RANLIB
110629c9ff80cSmrg	  RANLIB=:
110639c9ff80cSmrg	  objlist=
110649c9ff80cSmrg	  concat_cmds=
110659c9ff80cSmrg	  save_oldobjs=$oldobjs
110669c9ff80cSmrg	  oldobjs=
110679c9ff80cSmrg	  # Is there a better way of finding the last object in the list?
110689c9ff80cSmrg	  for obj in $save_oldobjs
110699c9ff80cSmrg	  do
110709c9ff80cSmrg	    last_oldobj=$obj
110719c9ff80cSmrg	  done
110729c9ff80cSmrg	  eval test_cmds=\"$old_archive_cmds\"
110739c9ff80cSmrg	  func_len " $test_cmds"
110749c9ff80cSmrg	  len0=$func_len_result
110759c9ff80cSmrg	  len=$len0
110769c9ff80cSmrg	  for obj in $save_oldobjs
110779c9ff80cSmrg	  do
110789c9ff80cSmrg	    func_len " $obj"
110799c9ff80cSmrg	    func_arith $len + $func_len_result
110809c9ff80cSmrg	    len=$func_arith_result
110819c9ff80cSmrg	    func_append objlist " $obj"
110829c9ff80cSmrg	    if test "$len" -lt "$max_cmd_len"; then
110839c9ff80cSmrg	      :
110849c9ff80cSmrg	    else
110859c9ff80cSmrg	      # the above command should be used before it gets too long
110869c9ff80cSmrg	      oldobjs=$objlist
11087d21ab8bcSmrg	      if test "$obj" = "$last_oldobj"; then
110889c9ff80cSmrg		RANLIB=$save_RANLIB
110899c9ff80cSmrg	      fi
110909c9ff80cSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
11091d21ab8bcSmrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
110929c9ff80cSmrg	      objlist=
110939c9ff80cSmrg	      len=$len0
110949c9ff80cSmrg	    fi
110959c9ff80cSmrg	  done
110969c9ff80cSmrg	  RANLIB=$save_RANLIB
110979c9ff80cSmrg	  oldobjs=$objlist
11098d21ab8bcSmrg	  if test -z "$oldobjs"; then
110999c9ff80cSmrg	    eval cmds=\"\$concat_cmds\"
111009c9ff80cSmrg	  else
111019c9ff80cSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
111029c9ff80cSmrg	  fi
111039c9ff80cSmrg	fi
111049c9ff80cSmrg      fi
111059c9ff80cSmrg      func_execute_cmds "$cmds" 'exit $?'
111061f0ac6a5Smrg    done
111071f0ac6a5Smrg
111089c9ff80cSmrg    test -n "$generated" && \
111099c9ff80cSmrg      func_show_eval "${RM}r$generated"
111101f0ac6a5Smrg
111119c9ff80cSmrg    # Now create the libtool archive.
111129c9ff80cSmrg    case $output in
111139c9ff80cSmrg    *.la)
111149c9ff80cSmrg      old_library=
11115d21ab8bcSmrg      test yes = "$build_old_libs" && old_library=$libname.$libext
111169c9ff80cSmrg      func_verbose "creating $output"
111171f0ac6a5Smrg
111189c9ff80cSmrg      # Preserve any variables that may affect compiler behavior
111199c9ff80cSmrg      for var in $variables_saved_for_relink; do
111209c9ff80cSmrg	if eval test -z \"\${$var+set}\"; then
111219c9ff80cSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
111229c9ff80cSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
111239c9ff80cSmrg	  relink_command="$var=; export $var; $relink_command"
111241f0ac6a5Smrg	else
11125d21ab8bcSmrg	  func_quote_arg pretty,unquoted "$var_value"
11126d21ab8bcSmrg	  relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command"
111271f0ac6a5Smrg	fi
111289c9ff80cSmrg      done
111299c9ff80cSmrg      # Quote the link command for shipping.
11130d21ab8bcSmrg      func_quote eval cd "`pwd`"
11131d21ab8bcSmrg      relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
11132d21ab8bcSmrg      func_quote_arg pretty,unquoted "$relink_command"
11133d21ab8bcSmrg      relink_command=$func_quote_arg_unquoted_result
11134d21ab8bcSmrg      if test yes = "$hardcode_automatic"; then
111359c9ff80cSmrg	relink_command=
111369c9ff80cSmrg      fi
111371f0ac6a5Smrg
111389c9ff80cSmrg      # Only create the output if not a dry run.
111399c9ff80cSmrg      $opt_dry_run || {
111409c9ff80cSmrg	for installed in no yes; do
11141d21ab8bcSmrg	  if test yes = "$installed"; then
111429c9ff80cSmrg	    if test -z "$install_libdir"; then
111439c9ff80cSmrg	      break
111449c9ff80cSmrg	    fi
11145d21ab8bcSmrg	    output=$output_objdir/${outputname}i
111469c9ff80cSmrg	    # Replace all uninstalled libtool libraries with the installed ones
111479c9ff80cSmrg	    newdependency_libs=
111489c9ff80cSmrg	    for deplib in $dependency_libs; do
111499c9ff80cSmrg	      case $deplib in
111509c9ff80cSmrg	      *.la)
111519c9ff80cSmrg		func_basename "$deplib"
11152d21ab8bcSmrg		name=$func_basename_result
1115389c04b6cSmrg		func_resolve_sysroot "$deplib"
11154d21ab8bcSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
111559c9ff80cSmrg		test -z "$libdir" && \
11156d21ab8bcSmrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
111576fae4e5dSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
111586fae4e5dSmrg		;;
111596fae4e5dSmrg	      -L*)
111606fae4e5dSmrg		func_stripname -L '' "$deplib"
111616fae4e5dSmrg		func_replace_sysroot "$func_stripname_result"
111626fae4e5dSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
111639c9ff80cSmrg		;;
111646fae4e5dSmrg	      -R*)
111656fae4e5dSmrg		func_stripname -R '' "$deplib"
111666fae4e5dSmrg		func_replace_sysroot "$func_stripname_result"
111676fae4e5dSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
111686fae4e5dSmrg		;;
111696fae4e5dSmrg	      *) func_append newdependency_libs " $deplib" ;;
111709c9ff80cSmrg	      esac
111719c9ff80cSmrg	    done
11172d21ab8bcSmrg	    dependency_libs=$newdependency_libs
111739c9ff80cSmrg	    newdlfiles=
111749c9ff80cSmrg
111759c9ff80cSmrg	    for lib in $dlfiles; do
111769c9ff80cSmrg	      case $lib in
111779c9ff80cSmrg	      *.la)
111789c9ff80cSmrg	        func_basename "$lib"
11179d21ab8bcSmrg		name=$func_basename_result
11180d21ab8bcSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
111819c9ff80cSmrg		test -z "$libdir" && \
11182d21ab8bcSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
111836fae4e5dSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
111849c9ff80cSmrg		;;
111856fae4e5dSmrg	      *) func_append newdlfiles " $lib" ;;
111869c9ff80cSmrg	      esac
111879c9ff80cSmrg	    done
11188d21ab8bcSmrg	    dlfiles=$newdlfiles
111899c9ff80cSmrg	    newdlprefiles=
111909c9ff80cSmrg	    for lib in $dlprefiles; do
111919c9ff80cSmrg	      case $lib in
111929c9ff80cSmrg	      *.la)
111939c9ff80cSmrg		# Only pass preopened files to the pseudo-archive (for
111949c9ff80cSmrg		# eventual linking with the app. that links it) if we
111959c9ff80cSmrg		# didn't already link the preopened objects directly into
111969c9ff80cSmrg		# the library:
111979c9ff80cSmrg		func_basename "$lib"
11198d21ab8bcSmrg		name=$func_basename_result
11199d21ab8bcSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
112009c9ff80cSmrg		test -z "$libdir" && \
11201d21ab8bcSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
112026fae4e5dSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
112039c9ff80cSmrg		;;
112049c9ff80cSmrg	      esac
112059c9ff80cSmrg	    done
11206d21ab8bcSmrg	    dlprefiles=$newdlprefiles
112079c9ff80cSmrg	  else
112089c9ff80cSmrg	    newdlfiles=
112099c9ff80cSmrg	    for lib in $dlfiles; do
112109c9ff80cSmrg	      case $lib in
11211d21ab8bcSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
112129c9ff80cSmrg		*) abs=`pwd`"/$lib" ;;
112139c9ff80cSmrg	      esac
112146fae4e5dSmrg	      func_append newdlfiles " $abs"
112159c9ff80cSmrg	    done
11216d21ab8bcSmrg	    dlfiles=$newdlfiles
112179c9ff80cSmrg	    newdlprefiles=
112189c9ff80cSmrg	    for lib in $dlprefiles; do
112199c9ff80cSmrg	      case $lib in
11220d21ab8bcSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
112219c9ff80cSmrg		*) abs=`pwd`"/$lib" ;;
112229c9ff80cSmrg	      esac
112236fae4e5dSmrg	      func_append newdlprefiles " $abs"
112249c9ff80cSmrg	    done
11225d21ab8bcSmrg	    dlprefiles=$newdlprefiles
112269c9ff80cSmrg	  fi
112279c9ff80cSmrg	  $RM $output
112289c9ff80cSmrg	  # place dlname in correct position for cygwin
112296fae4e5dSmrg	  # In fact, it would be nice if we could use this code for all target
112306fae4e5dSmrg	  # systems that can't hard-code library paths into their executables
112316fae4e5dSmrg	  # and that have no shared library path variable independent of PATH,
112326fae4e5dSmrg	  # but it turns out we can't easily determine that from inspecting
112336fae4e5dSmrg	  # libtool variables, so we have to hard-code the OSs to which it
112346fae4e5dSmrg	  # applies here; at the moment, that means platforms that use the PE
112356fae4e5dSmrg	  # object format with DLL files.  See the long comment at the top of
112366fae4e5dSmrg	  # tests/bindir.at for full details.
112379c9ff80cSmrg	  tdlname=$dlname
112389c9ff80cSmrg	  case $host,$output,$installed,$module,$dlname in
112396ee7d557Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *windows*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
112406fae4e5dSmrg	      # If a -bindir argument was supplied, place the dll there.
11241d21ab8bcSmrg	      if test -n "$bindir"; then
112426fae4e5dSmrg		func_relative_path "$install_libdir" "$bindir"
11243d21ab8bcSmrg		tdlname=$func_relative_path_result/$dlname
112446fae4e5dSmrg	      else
112456fae4e5dSmrg		# Otherwise fall back on heuristic.
112466fae4e5dSmrg		tdlname=../bin/$dlname
112476fae4e5dSmrg	      fi
112486fae4e5dSmrg	      ;;
112499c9ff80cSmrg	  esac
112509c9ff80cSmrg	  $ECHO > $output "\
112519c9ff80cSmrg# $outputname - a libtool library file
11252d21ab8bcSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
112539c9ff80cSmrg#
112549c9ff80cSmrg# Please DO NOT delete this file!
112559c9ff80cSmrg# It is necessary for linking the library.
112561f0ac6a5Smrg
112579c9ff80cSmrg# The name that we can dlopen(3).
112589c9ff80cSmrgdlname='$tdlname'
112591f0ac6a5Smrg
112609c9ff80cSmrg# Names of this library.
112619c9ff80cSmrglibrary_names='$library_names'
112621f0ac6a5Smrg
112639c9ff80cSmrg# The name of the static archive.
112649c9ff80cSmrgold_library='$old_library'
112651f0ac6a5Smrg
11266d21ab8bcSmrg# Linker flags that cannot go in dependency_libs.
112679c9ff80cSmrginherited_linker_flags='$new_inherited_linker_flags'
112681f0ac6a5Smrg
112699c9ff80cSmrg# Libraries that this one depends upon.
112709c9ff80cSmrgdependency_libs='$dependency_libs'
112711f0ac6a5Smrg
112729c9ff80cSmrg# Names of additional weak libraries provided by this library
112739c9ff80cSmrgweak_library_names='$weak_libs'
112741f0ac6a5Smrg
112759c9ff80cSmrg# Version information for $libname.
112769c9ff80cSmrgcurrent=$current
112779c9ff80cSmrgage=$age
112789c9ff80cSmrgrevision=$revision
112791f0ac6a5Smrg
112809c9ff80cSmrg# Is this an already installed library?
112819c9ff80cSmrginstalled=$installed
112821f0ac6a5Smrg
112839c9ff80cSmrg# Should we warn about portability when linking against -modules?
112849c9ff80cSmrgshouldnotlink=$module
112851f0ac6a5Smrg
112869c9ff80cSmrg# Files to dlopen/dlpreopen
112879c9ff80cSmrgdlopen='$dlfiles'
112889c9ff80cSmrgdlpreopen='$dlprefiles'
112891f0ac6a5Smrg
112909c9ff80cSmrg# Directory that this library needs to be installed in:
112919c9ff80cSmrglibdir='$install_libdir'"
11292d21ab8bcSmrg	  if test no,yes = "$installed,$need_relink"; then
112939c9ff80cSmrg	    $ECHO >> $output "\
112949c9ff80cSmrgrelink_command=\"$relink_command\""
112959c9ff80cSmrg	  fi
112969c9ff80cSmrg	done
112979c9ff80cSmrg      }
112981f0ac6a5Smrg
112999c9ff80cSmrg      # Do a symbolic link so that the libtool archive can be found in
113009c9ff80cSmrg      # LD_LIBRARY_PATH before the program is installed.
113019c9ff80cSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
113029c9ff80cSmrg      ;;
113039c9ff80cSmrg    esac
113049c9ff80cSmrg    exit $EXIT_SUCCESS
113059c9ff80cSmrg}
113061f0ac6a5Smrg
11307d21ab8bcSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
11308d21ab8bcSmrg  func_mode_link ${1+"$@"}
11309d21ab8bcSmrgfi
113101f0ac6a5Smrg
113111f0ac6a5Smrg
113129c9ff80cSmrg# func_mode_uninstall arg...
113139c9ff80cSmrgfunc_mode_uninstall ()
113149c9ff80cSmrg{
11315d21ab8bcSmrg    $debug_cmd
11316d21ab8bcSmrg
11317d21ab8bcSmrg    RM=$nonopt
113181f0ac6a5Smrg    files=
11319d21ab8bcSmrg    rmforce=false
113201f0ac6a5Smrg    exit_status=0
113211f0ac6a5Smrg
113221f0ac6a5Smrg    # This variable tells wrapper scripts just to set variables rather
113231f0ac6a5Smrg    # than running their programs.
11324d21ab8bcSmrg    libtool_install_magic=$magic
113251f0ac6a5Smrg
113261f0ac6a5Smrg    for arg
113271f0ac6a5Smrg    do
113281f0ac6a5Smrg      case $arg in
11329d21ab8bcSmrg      -f) func_append RM " $arg"; rmforce=: ;;
113306fae4e5dSmrg      -*) func_append RM " $arg" ;;
113316fae4e5dSmrg      *) func_append files " $arg" ;;
113321f0ac6a5Smrg      esac
113331f0ac6a5Smrg    done
113341f0ac6a5Smrg
113359c9ff80cSmrg    test -z "$RM" && \
113369c9ff80cSmrg      func_fatal_help "you must specify an RM program"
113371f0ac6a5Smrg
113381f0ac6a5Smrg    rmdirs=
113391f0ac6a5Smrg
113401f0ac6a5Smrg    for file in $files; do
113419c9ff80cSmrg      func_dirname "$file" "" "."
11342d21ab8bcSmrg      dir=$func_dirname_result
11343d21ab8bcSmrg      if test . = "$dir"; then
11344d21ab8bcSmrg	odir=$objdir
113451f0ac6a5Smrg      else
11346d21ab8bcSmrg	odir=$dir/$objdir
113471f0ac6a5Smrg      fi
113489c9ff80cSmrg      func_basename "$file"
11349d21ab8bcSmrg      name=$func_basename_result
11350d21ab8bcSmrg      test uninstall = "$opt_mode" && odir=$dir
113511f0ac6a5Smrg
113526fae4e5dSmrg      # Remember odir for removal later, being careful to avoid duplicates
11353d21ab8bcSmrg      if test clean = "$opt_mode"; then
113541f0ac6a5Smrg	case " $rmdirs " in
113556fae4e5dSmrg	  *" $odir "*) ;;
113566fae4e5dSmrg	  *) func_append rmdirs " $odir" ;;
113571f0ac6a5Smrg	esac
113581f0ac6a5Smrg      fi
113591f0ac6a5Smrg
113601f0ac6a5Smrg      # Don't error if the file doesn't exist and rm -f was used.
113619c9ff80cSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
113629c9ff80cSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
113639c9ff80cSmrg	 test -f "$file"; then
113641f0ac6a5Smrg	:
113651f0ac6a5Smrg      elif test -d "$file"; then
113661f0ac6a5Smrg	exit_status=1
113671f0ac6a5Smrg	continue
11368d21ab8bcSmrg      elif $rmforce; then
113691f0ac6a5Smrg	continue
113701f0ac6a5Smrg      fi
113711f0ac6a5Smrg
11372d21ab8bcSmrg      rmfiles=$file
113731f0ac6a5Smrg
113741f0ac6a5Smrg      case $name in
113751f0ac6a5Smrg      *.la)
113761f0ac6a5Smrg	# Possibly a libtool archive, so verify it.
113779c9ff80cSmrg	if func_lalib_p "$file"; then
113789c9ff80cSmrg	  func_source $dir/$name
113791f0ac6a5Smrg
113801f0ac6a5Smrg	  # Delete the libtool libraries and symlinks.
113811f0ac6a5Smrg	  for n in $library_names; do
113826fae4e5dSmrg	    func_append rmfiles " $odir/$n"
113831f0ac6a5Smrg	  done
113846fae4e5dSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
113851f0ac6a5Smrg
11386d21ab8bcSmrg	  case $opt_mode in
113871f0ac6a5Smrg	  clean)
113886fae4e5dSmrg	    case " $library_names " in
113891f0ac6a5Smrg	    *" $dlname "*) ;;
113906fae4e5dSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
113911f0ac6a5Smrg	    esac
113926fae4e5dSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
113931f0ac6a5Smrg	    ;;
113941f0ac6a5Smrg	  uninstall)
113951f0ac6a5Smrg	    if test -n "$library_names"; then
113961f0ac6a5Smrg	      # Do each command in the postuninstall commands.
11397d21ab8bcSmrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
113981f0ac6a5Smrg	    fi
113991f0ac6a5Smrg
114001f0ac6a5Smrg	    if test -n "$old_library"; then
114011f0ac6a5Smrg	      # Do each command in the old_postuninstall commands.
11402d21ab8bcSmrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
114031f0ac6a5Smrg	    fi
114041f0ac6a5Smrg	    # FIXME: should reinstall the best remaining shared library.
114051f0ac6a5Smrg	    ;;
114061f0ac6a5Smrg	  esac
114071f0ac6a5Smrg	fi
114081f0ac6a5Smrg	;;
114091f0ac6a5Smrg
114101f0ac6a5Smrg      *.lo)
114111f0ac6a5Smrg	# Possibly a libtool object, so verify it.
114129c9ff80cSmrg	if func_lalib_p "$file"; then
114131f0ac6a5Smrg
114141f0ac6a5Smrg	  # Read the .lo file
114159c9ff80cSmrg	  func_source $dir/$name
114161f0ac6a5Smrg
114171f0ac6a5Smrg	  # Add PIC object to the list of files to remove.
11418d21ab8bcSmrg	  if test -n "$pic_object" && test none != "$pic_object"; then
114196fae4e5dSmrg	    func_append rmfiles " $dir/$pic_object"
114201f0ac6a5Smrg	  fi
114211f0ac6a5Smrg
114221f0ac6a5Smrg	  # Add non-PIC object to the list of files to remove.
11423d21ab8bcSmrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
114246fae4e5dSmrg	    func_append rmfiles " $dir/$non_pic_object"
114251f0ac6a5Smrg	  fi
114261f0ac6a5Smrg	fi
114271f0ac6a5Smrg	;;
114281f0ac6a5Smrg
114291f0ac6a5Smrg      *)
11430d21ab8bcSmrg	if test clean = "$opt_mode"; then
114311f0ac6a5Smrg	  noexename=$name
114321f0ac6a5Smrg	  case $file in
114331f0ac6a5Smrg	  *.exe)
114349c9ff80cSmrg	    func_stripname '' '.exe' "$file"
114359c9ff80cSmrg	    file=$func_stripname_result
114369c9ff80cSmrg	    func_stripname '' '.exe' "$name"
114379c9ff80cSmrg	    noexename=$func_stripname_result
114381f0ac6a5Smrg	    # $file with .exe has already been added to rmfiles,
114391f0ac6a5Smrg	    # add $file without .exe
114406fae4e5dSmrg	    func_append rmfiles " $file"
114411f0ac6a5Smrg	    ;;
114421f0ac6a5Smrg	  esac
114431f0ac6a5Smrg	  # Do a test to see if this is a libtool program.
114449c9ff80cSmrg	  if func_ltwrapper_p "$file"; then
114459c9ff80cSmrg	    if func_ltwrapper_executable_p "$file"; then
114469c9ff80cSmrg	      func_ltwrapper_scriptname "$file"
114479c9ff80cSmrg	      relink_command=
114489c9ff80cSmrg	      func_source $func_ltwrapper_scriptname_result
114496fae4e5dSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
114509c9ff80cSmrg	    else
114519c9ff80cSmrg	      relink_command=
114529c9ff80cSmrg	      func_source $dir/$noexename
114539c9ff80cSmrg	    fi
114541f0ac6a5Smrg
114551f0ac6a5Smrg	    # note $name still contains .exe if it was in $file originally
114561f0ac6a5Smrg	    # as does the version of $file that was added into $rmfiles
11457d21ab8bcSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
11458d21ab8bcSmrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
114596fae4e5dSmrg	      func_append rmfiles " $odir/lt-$name"
114601f0ac6a5Smrg	    fi
11461d21ab8bcSmrg	    if test "X$noexename" != "X$name"; then
11462d21ab8bcSmrg	      func_append rmfiles " $odir/lt-$noexename.c"
114631f0ac6a5Smrg	    fi
114641f0ac6a5Smrg	  fi
114651f0ac6a5Smrg	fi
114661f0ac6a5Smrg	;;
114671f0ac6a5Smrg      esac
114689c9ff80cSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
114691f0ac6a5Smrg    done
114701f0ac6a5Smrg
11471d21ab8bcSmrg    # Try to remove the $objdir's in the directories where we deleted files
114721f0ac6a5Smrg    for dir in $rmdirs; do
114731f0ac6a5Smrg      if test -d "$dir"; then
114749c9ff80cSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
114751f0ac6a5Smrg      fi
114761f0ac6a5Smrg    done
114771f0ac6a5Smrg
114781f0ac6a5Smrg    exit $exit_status
114799c9ff80cSmrg}
114801f0ac6a5Smrg
11481d21ab8bcSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
11482d21ab8bcSmrg  func_mode_uninstall ${1+"$@"}
11483d21ab8bcSmrgfi
114841f0ac6a5Smrg
114856fae4e5dSmrgtest -z "$opt_mode" && {
11486d21ab8bcSmrg  help=$generic_help
114879c9ff80cSmrg  func_fatal_help "you must specify a MODE"
114889c9ff80cSmrg}
114899c9ff80cSmrg
114909c9ff80cSmrgtest -z "$exec_cmd" && \
11491d21ab8bcSmrg  func_fatal_help "invalid operation mode '$opt_mode'"
114921f0ac6a5Smrg
114931f0ac6a5Smrgif test -n "$exec_cmd"; then
114949c9ff80cSmrg  eval exec "$exec_cmd"
114951f0ac6a5Smrg  exit $EXIT_FAILURE
114961f0ac6a5Smrgfi
114971f0ac6a5Smrg
114989c9ff80cSmrgexit $exit_status
114991f0ac6a5Smrg
115001f0ac6a5Smrg
115011f0ac6a5Smrg# The TAGs below are defined such that we never get into a situation
11502d21ab8bcSmrg# where we disable both kinds of libraries.  Given conflicting
115031f0ac6a5Smrg# choices, we go for a static library, that is the most portable,
115041f0ac6a5Smrg# since we can't tell whether shared libraries were disabled because
115051f0ac6a5Smrg# the user asked for that or because the platform doesn't support
115061f0ac6a5Smrg# them.  This is particularly important on AIX, because we don't
115071f0ac6a5Smrg# support having both static and shared libraries enabled at the same
115081f0ac6a5Smrg# time on that platform, so we default to a shared-only configuration.
115091f0ac6a5Smrg# If a disable-shared tag is given, we'll fallback to a static-only
115101f0ac6a5Smrg# configuration.  But we'll never go from static-only to shared-only.
115111f0ac6a5Smrg
115121f0ac6a5Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
115139c9ff80cSmrgbuild_libtool_libs=no
115149c9ff80cSmrgbuild_old_libs=yes
115151f0ac6a5Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
115161f0ac6a5Smrg
115171f0ac6a5Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
115189c9ff80cSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
115191f0ac6a5Smrg# ### END LIBTOOL TAG CONFIG: disable-static
115201f0ac6a5Smrg
115211f0ac6a5Smrg# Local Variables:
115221f0ac6a5Smrg# mode:shell-script
115231f0ac6a5Smrg# sh-indentation:2
115241f0ac6a5Smrg# End:
11525