1636c353eSmrg#! /usr/bin/env sh
2e07dc26bSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
3636c353eSmrg##               by inline-source v2019-02-19.15
4e07dc26bSmrg
5636c353eSmrg# libtool (GNU libtool) 2.4.7
6e07dc26bSmrg# Provide generalized library-building support services.
7e07dc26bSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8e07dc26bSmrg
9636c353eSmrg# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc.
10e07dc26bSmrg# This is free software; see the source for copying conditions.  There is NO
11e07dc26bSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12e07dc26bSmrg
13e07dc26bSmrg# GNU Libtool is free software; you can redistribute it and/or modify
14e07dc26bSmrg# it under the terms of the GNU General Public License as published by
15e07dc26bSmrg# the Free Software Foundation; either version 2 of the License, or
16e07dc26bSmrg# (at your option) any later version.
17e07dc26bSmrg#
18e07dc26bSmrg# As a special exception to the GNU General Public License,
19e07dc26bSmrg# if you distribute this file as part of a program or library that
20e07dc26bSmrg# is built using GNU Libtool, you may include this file under the
21e07dc26bSmrg# same distribution terms that you use for the rest of that program.
22e07dc26bSmrg#
23e07dc26bSmrg# GNU Libtool is distributed in the hope that it will be useful, but
24e07dc26bSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
25e07dc26bSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26e07dc26bSmrg# General Public License for more details.
27e07dc26bSmrg#
28e07dc26bSmrg# You should have received a copy of the GNU General Public License
29e07dc26bSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
30e07dc26bSmrg
31e07dc26bSmrg
32e07dc26bSmrgPROGRAM=libtool
33e07dc26bSmrgPACKAGE=libtool
34636c353eSmrgVERSION=2.4.7
35636c353eSmrgpackage_revision=2.4.7
36e07dc26bSmrg
37e07dc26bSmrg
38e07dc26bSmrg## ------ ##
39e07dc26bSmrg## Usage. ##
40e07dc26bSmrg## ------ ##
41e07dc26bSmrg
42e07dc26bSmrg# Run './libtool --help' for help with using this script from the
43e07dc26bSmrg# command line.
44e07dc26bSmrg
45e07dc26bSmrg
46e07dc26bSmrg## ------------------------------- ##
47e07dc26bSmrg## User overridable command paths. ##
48e07dc26bSmrg## ------------------------------- ##
49e07dc26bSmrg
50e07dc26bSmrg# After configure completes, it has a better idea of some of the
51e07dc26bSmrg# shell tools we need than the defaults used by the functions shared
52e07dc26bSmrg# with bootstrap, so set those here where they can still be over-
53e07dc26bSmrg# ridden by the user, but otherwise take precedence.
54e07dc26bSmrg
55e07dc26bSmrg: ${AUTOCONF="autoconf"}
56e07dc26bSmrg: ${AUTOMAKE="automake"}
57e07dc26bSmrg
58e07dc26bSmrg
59e07dc26bSmrg## -------------------------- ##
60e07dc26bSmrg## Source external libraries. ##
61e07dc26bSmrg## -------------------------- ##
62e07dc26bSmrg
63e07dc26bSmrg# Much of our low-level functionality needs to be sourced from external
64e07dc26bSmrg# libraries, which are installed to $pkgauxdir.
65e07dc26bSmrg
66e07dc26bSmrg# Set a version string for this script.
67636c353eSmrgscriptversion=2019-02-19.15; # UTC
68e07dc26bSmrg
69e07dc26bSmrg# General shell script boiler plate, and helper functions.
70e07dc26bSmrg# Written by Gary V. Vaughan, 2004
71e07dc26bSmrg
72636c353eSmrg# This is free software.  There is NO warranty; not even for
73636c353eSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
74636c353eSmrg#
75636c353eSmrg# Copyright (C) 2004-2019, 2021 Bootstrap Authors
76636c353eSmrg#
77636c353eSmrg# This file is dual licensed under the terms of the MIT license
78636c353eSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later
79636c353eSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
80636c353eSmrg# these licenses when using or redistributing this software or any of
81636c353eSmrg# the files within it.  See the URLs above, or the file `LICENSE`
82636c353eSmrg# included in the Bootstrap distribution for the full license texts.
83e07dc26bSmrg
84636c353eSmrg# Please report bugs or propose patches to:
85636c353eSmrg# <https://github.com/gnulib-modules/bootstrap/issues>
86e07dc26bSmrg
87e07dc26bSmrg
88e07dc26bSmrg## ------ ##
89e07dc26bSmrg## Usage. ##
90e07dc26bSmrg## ------ ##
91e07dc26bSmrg
92e07dc26bSmrg# Evaluate this file near the top of your script to gain access to
93e07dc26bSmrg# the functions and variables defined here:
94e07dc26bSmrg#
95e07dc26bSmrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
96e07dc26bSmrg#
97e07dc26bSmrg# If you need to override any of the default environment variable
98e07dc26bSmrg# settings, do that before evaluating this file.
99e07dc26bSmrg
100e07dc26bSmrg
101e07dc26bSmrg## -------------------- ##
102e07dc26bSmrg## Shell normalisation. ##
103e07dc26bSmrg## -------------------- ##
104e07dc26bSmrg
105e07dc26bSmrg# Some shells need a little help to be as Bourne compatible as possible.
106e07dc26bSmrg# Before doing anything else, make sure all that help has been provided!
107e07dc26bSmrg
108e07dc26bSmrgDUALCASE=1; export DUALCASE # for MKS sh
109e07dc26bSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
110e07dc26bSmrg  emulate sh
111e07dc26bSmrg  NULLCMD=:
112e07dc26bSmrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
113e07dc26bSmrg  # is contrary to our usage.  Disable this feature.
114e07dc26bSmrg  alias -g '${1+"$@"}'='"$@"'
115e07dc26bSmrg  setopt NO_GLOB_SUBST
116e07dc26bSmrgelse
117e07dc26bSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
118e07dc26bSmrgfi
119e07dc26bSmrg
120e07dc26bSmrg# NLS nuisances: We save the old values in case they are required later.
121e07dc26bSmrg_G_user_locale=
122e07dc26bSmrg_G_safe_locale=
123e07dc26bSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
124e07dc26bSmrgdo
125e07dc26bSmrg  eval "if test set = \"\${$_G_var+set}\"; then
126e07dc26bSmrg          save_$_G_var=\$$_G_var
127e07dc26bSmrg          $_G_var=C
128e07dc26bSmrg	  export $_G_var
129e07dc26bSmrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
130e07dc26bSmrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
131e07dc26bSmrg	fi"
132e07dc26bSmrgdone
133636c353eSmrg# These NLS vars are set unconditionally (bootstrap issue #24).  Unset those
134636c353eSmrg# in case the environment reset is needed later and the $save_* variant is not
135636c353eSmrg# defined (see the code above).
136636c353eSmrgLC_ALL=C
137636c353eSmrgLANGUAGE=C
138636c353eSmrgexport LANGUAGE LC_ALL
139e07dc26bSmrg
140e07dc26bSmrg# Make sure IFS has a sensible default
141e07dc26bSmrgsp=' '
142e07dc26bSmrgnl='
143e07dc26bSmrg'
144e07dc26bSmrgIFS="$sp	$nl"
145e07dc26bSmrg
146e07dc26bSmrg# There are apparently some retarded systems that use ';' as a PATH separator!
147e07dc26bSmrgif test "${PATH_SEPARATOR+set}" != set; then
148e07dc26bSmrg  PATH_SEPARATOR=:
149e07dc26bSmrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
150e07dc26bSmrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
151e07dc26bSmrg      PATH_SEPARATOR=';'
152e07dc26bSmrg  }
153e07dc26bSmrgfi
154e07dc26bSmrg
155e07dc26bSmrg
156636c353eSmrg# func_unset VAR
157636c353eSmrg# --------------
158636c353eSmrg# Portably unset VAR.
159636c353eSmrg# In some shells, an 'unset VAR' statement leaves a non-zero return
160636c353eSmrg# status if VAR is already unset, which might be problematic if the
161636c353eSmrg# statement is used at the end of a function (thus poisoning its return
162636c353eSmrg# value) or when 'set -e' is active (causing even a spurious abort of
163636c353eSmrg# the script in this case).
164636c353eSmrgfunc_unset ()
165636c353eSmrg{
166636c353eSmrg    { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; }
167636c353eSmrg}
168636c353eSmrg
169636c353eSmrg
170636c353eSmrg# Make sure CDPATH doesn't cause `cd` commands to output the target dir.
171636c353eSmrgfunc_unset CDPATH
172636c353eSmrg
173636c353eSmrg# Make sure ${,E,F}GREP behave sanely.
174636c353eSmrgfunc_unset GREP_OPTIONS
175636c353eSmrg
176e07dc26bSmrg
177e07dc26bSmrg## ------------------------- ##
178e07dc26bSmrg## Locate command utilities. ##
179e07dc26bSmrg## ------------------------- ##
180e07dc26bSmrg
181e07dc26bSmrg
182e07dc26bSmrg# func_executable_p FILE
183e07dc26bSmrg# ----------------------
184e07dc26bSmrg# Check that FILE is an executable regular file.
185e07dc26bSmrgfunc_executable_p ()
186e07dc26bSmrg{
187e07dc26bSmrg    test -f "$1" && test -x "$1"
188e07dc26bSmrg}
189e07dc26bSmrg
190e07dc26bSmrg
191e07dc26bSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
192e07dc26bSmrg# --------------------------------------------
193e07dc26bSmrg# Search for either a program that responds to --version with output
194e07dc26bSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
195e07dc26bSmrg# trying all the directories in PATH with each of the elements of
196e07dc26bSmrg# PROGS_LIST.
197e07dc26bSmrg#
198e07dc26bSmrg# CHECK_FUNC should accept the path to a candidate program, and
199e07dc26bSmrg# set $func_check_prog_result if it truncates its output less than
200e07dc26bSmrg# $_G_path_prog_max characters.
201e07dc26bSmrgfunc_path_progs ()
202e07dc26bSmrg{
203e07dc26bSmrg    _G_progs_list=$1
204e07dc26bSmrg    _G_check_func=$2
205e07dc26bSmrg    _G_PATH=${3-"$PATH"}
206e07dc26bSmrg
207e07dc26bSmrg    _G_path_prog_max=0
208e07dc26bSmrg    _G_path_prog_found=false
209e07dc26bSmrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
210e07dc26bSmrg    for _G_dir in $_G_PATH; do
211e07dc26bSmrg      IFS=$_G_save_IFS
212e07dc26bSmrg      test -z "$_G_dir" && _G_dir=.
213e07dc26bSmrg      for _G_prog_name in $_G_progs_list; do
214e07dc26bSmrg        for _exeext in '' .EXE; do
215e07dc26bSmrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
216e07dc26bSmrg          func_executable_p "$_G_path_prog" || continue
217e07dc26bSmrg          case `"$_G_path_prog" --version 2>&1` in
218e07dc26bSmrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
219e07dc26bSmrg            *)     $_G_check_func $_G_path_prog
220e07dc26bSmrg		   func_path_progs_result=$func_check_prog_result
221e07dc26bSmrg		   ;;
222e07dc26bSmrg          esac
223e07dc26bSmrg          $_G_path_prog_found && break 3
224e07dc26bSmrg        done
225e07dc26bSmrg      done
226e07dc26bSmrg    done
227e07dc26bSmrg    IFS=$_G_save_IFS
228e07dc26bSmrg    test -z "$func_path_progs_result" && {
229e07dc26bSmrg      echo "no acceptable sed could be found in \$PATH" >&2
230e07dc26bSmrg      exit 1
231e07dc26bSmrg    }
232e07dc26bSmrg}
233e07dc26bSmrg
234e07dc26bSmrg
235e07dc26bSmrg# We want to be able to use the functions in this file before configure
236e07dc26bSmrg# has figured out where the best binaries are kept, which means we have
237e07dc26bSmrg# to search for them ourselves - except when the results are already set
238e07dc26bSmrg# where we skip the searches.
239e07dc26bSmrg
240e07dc26bSmrg# Unless the user overrides by setting SED, search the path for either GNU
241e07dc26bSmrg# sed, or the sed that truncates its output the least.
242e07dc26bSmrgtest -z "$SED" && {
243e07dc26bSmrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
244e07dc26bSmrg  for _G_i in 1 2 3 4 5 6 7; do
245e07dc26bSmrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
246e07dc26bSmrg  done
247e07dc26bSmrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
248e07dc26bSmrg  _G_sed_script=
249e07dc26bSmrg
250e07dc26bSmrg  func_check_prog_sed ()
251e07dc26bSmrg  {
252e07dc26bSmrg    _G_path_prog=$1
253e07dc26bSmrg
254e07dc26bSmrg    _G_count=0
255e07dc26bSmrg    printf 0123456789 >conftest.in
256e07dc26bSmrg    while :
257e07dc26bSmrg    do
258e07dc26bSmrg      cat conftest.in conftest.in >conftest.tmp
259e07dc26bSmrg      mv conftest.tmp conftest.in
260e07dc26bSmrg      cp conftest.in conftest.nl
261e07dc26bSmrg      echo '' >> conftest.nl
262e07dc26bSmrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
263e07dc26bSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
264e07dc26bSmrg      _G_count=`expr $_G_count + 1`
265e07dc26bSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
266e07dc26bSmrg        # Best one so far, save it but keep looking for a better one
267e07dc26bSmrg        func_check_prog_result=$_G_path_prog
268e07dc26bSmrg        _G_path_prog_max=$_G_count
269e07dc26bSmrg      fi
270e07dc26bSmrg      # 10*(2^10) chars as input seems more than enough
271e07dc26bSmrg      test 10 -lt "$_G_count" && break
272e07dc26bSmrg    done
273e07dc26bSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
274e07dc26bSmrg  }
275e07dc26bSmrg
276636c353eSmrg  func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin"
277e07dc26bSmrg  rm -f conftest.sed
278e07dc26bSmrg  SED=$func_path_progs_result
279e07dc26bSmrg}
280e07dc26bSmrg
281e07dc26bSmrg
282e07dc26bSmrg# Unless the user overrides by setting GREP, search the path for either GNU
283e07dc26bSmrg# grep, or the grep that truncates its output the least.
284e07dc26bSmrgtest -z "$GREP" && {
285e07dc26bSmrg  func_check_prog_grep ()
286e07dc26bSmrg  {
287e07dc26bSmrg    _G_path_prog=$1
288e07dc26bSmrg
289e07dc26bSmrg    _G_count=0
290e07dc26bSmrg    _G_path_prog_max=0
291e07dc26bSmrg    printf 0123456789 >conftest.in
292e07dc26bSmrg    while :
293e07dc26bSmrg    do
294e07dc26bSmrg      cat conftest.in conftest.in >conftest.tmp
295e07dc26bSmrg      mv conftest.tmp conftest.in
296e07dc26bSmrg      cp conftest.in conftest.nl
297e07dc26bSmrg      echo 'GREP' >> conftest.nl
298e07dc26bSmrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
299e07dc26bSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
300e07dc26bSmrg      _G_count=`expr $_G_count + 1`
301e07dc26bSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
302e07dc26bSmrg        # Best one so far, save it but keep looking for a better one
303e07dc26bSmrg        func_check_prog_result=$_G_path_prog
304e07dc26bSmrg        _G_path_prog_max=$_G_count
305e07dc26bSmrg      fi
306e07dc26bSmrg      # 10*(2^10) chars as input seems more than enough
307e07dc26bSmrg      test 10 -lt "$_G_count" && break
308e07dc26bSmrg    done
309e07dc26bSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
310e07dc26bSmrg  }
311e07dc26bSmrg
312636c353eSmrg  func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin"
313e07dc26bSmrg  GREP=$func_path_progs_result
314e07dc26bSmrg}
315e07dc26bSmrg
316e07dc26bSmrg
317e07dc26bSmrg## ------------------------------- ##
318e07dc26bSmrg## User overridable command paths. ##
319e07dc26bSmrg## ------------------------------- ##
320e07dc26bSmrg
321e07dc26bSmrg# All uppercase variable names are used for environment variables.  These
322e07dc26bSmrg# variables can be overridden by the user before calling a script that
323e07dc26bSmrg# uses them if a suitable command of that name is not already available
324e07dc26bSmrg# in the command search PATH.
325e07dc26bSmrg
326e07dc26bSmrg: ${CP="cp -f"}
327e07dc26bSmrg: ${ECHO="printf %s\n"}
328e07dc26bSmrg: ${EGREP="$GREP -E"}
329e07dc26bSmrg: ${FGREP="$GREP -F"}
330e07dc26bSmrg: ${LN_S="ln -s"}
331e07dc26bSmrg: ${MAKE="make"}
332e07dc26bSmrg: ${MKDIR="mkdir"}
333e07dc26bSmrg: ${MV="mv -f"}
334e07dc26bSmrg: ${RM="rm -f"}
335e07dc26bSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
336e07dc26bSmrg
337e07dc26bSmrg
338e07dc26bSmrg## -------------------- ##
339e07dc26bSmrg## Useful sed snippets. ##
340e07dc26bSmrg## -------------------- ##
341e07dc26bSmrg
342e07dc26bSmrgsed_dirname='s|/[^/]*$||'
343e07dc26bSmrgsed_basename='s|^.*/||'
344e07dc26bSmrg
345e07dc26bSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
346e07dc26bSmrg# metacharacters that are still active within double-quoted strings.
347e07dc26bSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
348e07dc26bSmrg
349e07dc26bSmrg# Same as above, but do not quote variable references.
350e07dc26bSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
351e07dc26bSmrg
352e07dc26bSmrg# Sed substitution that turns a string into a regex matching for the
353e07dc26bSmrg# string literally.
354e07dc26bSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
355e07dc26bSmrg
356e07dc26bSmrg# Sed substitution that converts a w32 file name or path
357e07dc26bSmrg# that contains forward slashes, into one that contains
358e07dc26bSmrg# (escaped) backslashes.  A very naive implementation.
359e07dc26bSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
360e07dc26bSmrg
361e07dc26bSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
362e07dc26bSmrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
363e07dc26bSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from
364e07dc26bSmrg# expansion.  Since each input '\' is now two '\'s, look for any number
365e07dc26bSmrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
366e07dc26bSmrg_G_bs='\\'
367e07dc26bSmrg_G_bs2='\\\\'
368e07dc26bSmrg_G_bs4='\\\\\\\\'
369e07dc26bSmrg_G_dollar='\$'
370e07dc26bSmrgsed_double_backslash="\
371e07dc26bSmrg  s/$_G_bs4/&\\
372e07dc26bSmrg/g
373e07dc26bSmrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
374e07dc26bSmrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
375e07dc26bSmrg  s/\n//g"
376e07dc26bSmrg
377636c353eSmrg# require_check_ifs_backslash
378636c353eSmrg# ---------------------------
379636c353eSmrg# Check if we can use backslash as IFS='\' separator, and set
380636c353eSmrg# $check_ifs_backshlash_broken to ':' or 'false'.
381636c353eSmrgrequire_check_ifs_backslash=func_require_check_ifs_backslash
382636c353eSmrgfunc_require_check_ifs_backslash ()
383636c353eSmrg{
384636c353eSmrg  _G_save_IFS=$IFS
385636c353eSmrg  IFS='\'
386636c353eSmrg  _G_check_ifs_backshlash='a\\b'
387636c353eSmrg  for _G_i in $_G_check_ifs_backshlash
388636c353eSmrg  do
389636c353eSmrg  case $_G_i in
390636c353eSmrg  a)
391636c353eSmrg    check_ifs_backshlash_broken=false
392636c353eSmrg    ;;
393636c353eSmrg  '')
394636c353eSmrg    break
395636c353eSmrg    ;;
396636c353eSmrg  *)
397636c353eSmrg    check_ifs_backshlash_broken=:
398636c353eSmrg    break
399636c353eSmrg    ;;
400636c353eSmrg  esac
401636c353eSmrg  done
402636c353eSmrg  IFS=$_G_save_IFS
403636c353eSmrg  require_check_ifs_backslash=:
404636c353eSmrg}
405636c353eSmrg
406e07dc26bSmrg
407e07dc26bSmrg## ----------------- ##
408e07dc26bSmrg## Global variables. ##
409e07dc26bSmrg## ----------------- ##
410e07dc26bSmrg
411e07dc26bSmrg# Except for the global variables explicitly listed below, the following
412e07dc26bSmrg# functions in the '^func_' namespace, and the '^require_' namespace
413e07dc26bSmrg# variables initialised in the 'Resource management' section, sourcing
414e07dc26bSmrg# this file will not pollute your global namespace with anything
415e07dc26bSmrg# else. There's no portable way to scope variables in Bourne shell
416e07dc26bSmrg# though, so actually running these functions will sometimes place
417e07dc26bSmrg# results into a variable named after the function, and often use
418e07dc26bSmrg# temporary variables in the '^_G_' namespace. If you are careful to
419e07dc26bSmrg# avoid using those namespaces casually in your sourcing script, things
420e07dc26bSmrg# should continue to work as you expect. And, of course, you can freely
421e07dc26bSmrg# overwrite any of the functions or variables defined here before
422e07dc26bSmrg# calling anything to customize them.
423e07dc26bSmrg
424e07dc26bSmrgEXIT_SUCCESS=0
425e07dc26bSmrgEXIT_FAILURE=1
426e07dc26bSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
427e07dc26bSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
428e07dc26bSmrg
429e07dc26bSmrg# Allow overriding, eg assuming that you follow the convention of
430e07dc26bSmrg# putting '$debug_cmd' at the start of all your functions, you can get
431e07dc26bSmrg# bash to show function call trace with:
432e07dc26bSmrg#
433e07dc26bSmrg#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
434e07dc26bSmrgdebug_cmd=${debug_cmd-":"}
435e07dc26bSmrgexit_cmd=:
436e07dc26bSmrg
437e07dc26bSmrg# By convention, finish your script with:
438e07dc26bSmrg#
439e07dc26bSmrg#    exit $exit_status
440e07dc26bSmrg#
441e07dc26bSmrg# so that you can set exit_status to non-zero if you want to indicate
442e07dc26bSmrg# something went wrong during execution without actually bailing out at
443e07dc26bSmrg# the point of failure.
444e07dc26bSmrgexit_status=$EXIT_SUCCESS
445e07dc26bSmrg
446e07dc26bSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
447e07dc26bSmrg# is ksh but when the shell is invoked as "sh" and the current value of
448e07dc26bSmrg# the _XPG environment variable is not equal to 1 (one), the special
449e07dc26bSmrg# positional parameter $0, within a function call, is the name of the
450e07dc26bSmrg# function.
451e07dc26bSmrgprogpath=$0
452e07dc26bSmrg
453e07dc26bSmrg# The name of this program.
454e07dc26bSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
455e07dc26bSmrg
456e07dc26bSmrg# Make sure we have an absolute progpath for reexecution:
457e07dc26bSmrgcase $progpath in
458e07dc26bSmrg  [\\/]*|[A-Za-z]:\\*) ;;
459e07dc26bSmrg  *[\\/]*)
460e07dc26bSmrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
461e07dc26bSmrg     progdir=`cd "$progdir" && pwd`
462e07dc26bSmrg     progpath=$progdir/$progname
463e07dc26bSmrg     ;;
464e07dc26bSmrg  *)
465e07dc26bSmrg     _G_IFS=$IFS
466e07dc26bSmrg     IFS=${PATH_SEPARATOR-:}
467e07dc26bSmrg     for progdir in $PATH; do
468e07dc26bSmrg       IFS=$_G_IFS
469e07dc26bSmrg       test -x "$progdir/$progname" && break
470e07dc26bSmrg     done
471e07dc26bSmrg     IFS=$_G_IFS
472e07dc26bSmrg     test -n "$progdir" || progdir=`pwd`
473e07dc26bSmrg     progpath=$progdir/$progname
474e07dc26bSmrg     ;;
475e07dc26bSmrgesac
476e07dc26bSmrg
477e07dc26bSmrg
478e07dc26bSmrg## ----------------- ##
479e07dc26bSmrg## Standard options. ##
480e07dc26bSmrg## ----------------- ##
481e07dc26bSmrg
482e07dc26bSmrg# The following options affect the operation of the functions defined
483e07dc26bSmrg# below, and should be set appropriately depending on run-time para-
484e07dc26bSmrg# meters passed on the command line.
485e07dc26bSmrg
486e07dc26bSmrgopt_dry_run=false
487e07dc26bSmrgopt_quiet=false
488e07dc26bSmrgopt_verbose=false
489e07dc26bSmrg
490e07dc26bSmrg# Categories 'all' and 'none' are always available.  Append any others
491e07dc26bSmrg# you will pass as the first argument to func_warning from your own
492e07dc26bSmrg# code.
493e07dc26bSmrgwarning_categories=
494e07dc26bSmrg
495e07dc26bSmrg# By default, display warnings according to 'opt_warning_types'.  Set
496e07dc26bSmrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
497e07dc26bSmrg# treat the next displayed warning as a fatal error.
498e07dc26bSmrgwarning_func=func_warn_and_continue
499e07dc26bSmrg
500e07dc26bSmrg# Set to 'all' to display all warnings, 'none' to suppress all
501e07dc26bSmrg# warnings, or a space delimited list of some subset of
502e07dc26bSmrg# 'warning_categories' to display only the listed warnings.
503e07dc26bSmrgopt_warning_types=all
504e07dc26bSmrg
505e07dc26bSmrg
506e07dc26bSmrg## -------------------- ##
507e07dc26bSmrg## Resource management. ##
508e07dc26bSmrg## -------------------- ##
509e07dc26bSmrg
510e07dc26bSmrg# This section contains definitions for functions that each ensure a
511e07dc26bSmrg# particular resource (a file, or a non-empty configuration variable for
512e07dc26bSmrg# example) is available, and if appropriate to extract default values
513e07dc26bSmrg# from pertinent package files. Call them using their associated
514e07dc26bSmrg# 'require_*' variable to ensure that they are executed, at most, once.
515e07dc26bSmrg#
516e07dc26bSmrg# It's entirely deliberate that calling these functions can set
517e07dc26bSmrg# variables that don't obey the namespace limitations obeyed by the rest
518e07dc26bSmrg# of this file, in order that that they be as useful as possible to
519e07dc26bSmrg# callers.
520e07dc26bSmrg
521e07dc26bSmrg
522e07dc26bSmrg# require_term_colors
523e07dc26bSmrg# -------------------
524e07dc26bSmrg# Allow display of bold text on terminals that support it.
525e07dc26bSmrgrequire_term_colors=func_require_term_colors
526e07dc26bSmrgfunc_require_term_colors ()
527e07dc26bSmrg{
528e07dc26bSmrg    $debug_cmd
529e07dc26bSmrg
530e07dc26bSmrg    test -t 1 && {
531e07dc26bSmrg      # COLORTERM and USE_ANSI_COLORS environment variables take
532e07dc26bSmrg      # precedence, because most terminfo databases neglect to describe
533e07dc26bSmrg      # whether color sequences are supported.
534e07dc26bSmrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
535e07dc26bSmrg
536e07dc26bSmrg      if test 1 = "$USE_ANSI_COLORS"; then
537e07dc26bSmrg        # Standard ANSI escape sequences
538e07dc26bSmrg        tc_reset='[0m'
539e07dc26bSmrg        tc_bold='[1m';   tc_standout='[7m'
540e07dc26bSmrg        tc_red='[31m';   tc_green='[32m'
541e07dc26bSmrg        tc_blue='[34m';  tc_cyan='[36m'
542e07dc26bSmrg      else
543e07dc26bSmrg        # Otherwise trust the terminfo database after all.
544e07dc26bSmrg        test -n "`tput sgr0 2>/dev/null`" && {
545e07dc26bSmrg          tc_reset=`tput sgr0`
546e07dc26bSmrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
547e07dc26bSmrg          tc_standout=$tc_bold
548e07dc26bSmrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
549e07dc26bSmrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
550e07dc26bSmrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
551e07dc26bSmrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
552e07dc26bSmrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
553e07dc26bSmrg        }
554e07dc26bSmrg      fi
555e07dc26bSmrg    }
556e07dc26bSmrg
557e07dc26bSmrg    require_term_colors=:
558e07dc26bSmrg}
559e07dc26bSmrg
560e07dc26bSmrg
561e07dc26bSmrg## ----------------- ##
562e07dc26bSmrg## Function library. ##
563e07dc26bSmrg## ----------------- ##
564e07dc26bSmrg
565e07dc26bSmrg# This section contains a variety of useful functions to call in your
566e07dc26bSmrg# scripts. Take note of the portable wrappers for features provided by
567e07dc26bSmrg# some modern shells, which will fall back to slower equivalents on
568e07dc26bSmrg# less featureful shells.
569e07dc26bSmrg
570e07dc26bSmrg
571e07dc26bSmrg# func_append VAR VALUE
572e07dc26bSmrg# ---------------------
573e07dc26bSmrg# Append VALUE onto the existing contents of VAR.
574e07dc26bSmrg
575e07dc26bSmrg  # We should try to minimise forks, especially on Windows where they are
576e07dc26bSmrg  # unreasonably slow, so skip the feature probes when bash or zsh are
577e07dc26bSmrg  # being used:
578e07dc26bSmrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
579e07dc26bSmrg    : ${_G_HAVE_ARITH_OP="yes"}
580e07dc26bSmrg    : ${_G_HAVE_XSI_OPS="yes"}
581e07dc26bSmrg    # The += operator was introduced in bash 3.1
582e07dc26bSmrg    case $BASH_VERSION in
583e07dc26bSmrg      [12].* | 3.0 | 3.0*) ;;
584e07dc26bSmrg      *)
585e07dc26bSmrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
586e07dc26bSmrg        ;;
587e07dc26bSmrg    esac
588e07dc26bSmrg  fi
589e07dc26bSmrg
590e07dc26bSmrg  # _G_HAVE_PLUSEQ_OP
591e07dc26bSmrg  # Can be empty, in which case the shell is probed, "yes" if += is
592e07dc26bSmrg  # useable or anything else if it does not work.
593e07dc26bSmrg  test -z "$_G_HAVE_PLUSEQ_OP" \
594e07dc26bSmrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
595e07dc26bSmrg    && _G_HAVE_PLUSEQ_OP=yes
596e07dc26bSmrg
597e07dc26bSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"
598e07dc26bSmrgthen
599e07dc26bSmrg  # This is an XSI compatible shell, allowing a faster implementation...
600e07dc26bSmrg  eval 'func_append ()
601e07dc26bSmrg  {
602e07dc26bSmrg    $debug_cmd
603e07dc26bSmrg
604e07dc26bSmrg    eval "$1+=\$2"
605e07dc26bSmrg  }'
606e07dc26bSmrgelse
607e07dc26bSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
608e07dc26bSmrg  func_append ()
609e07dc26bSmrg  {
610e07dc26bSmrg    $debug_cmd
611e07dc26bSmrg
612e07dc26bSmrg    eval "$1=\$$1\$2"
613e07dc26bSmrg  }
614e07dc26bSmrgfi
615e07dc26bSmrg
616e07dc26bSmrg
617e07dc26bSmrg# func_append_quoted VAR VALUE
618e07dc26bSmrg# ----------------------------
619e07dc26bSmrg# Quote VALUE and append to the end of shell variable VAR, separated
620e07dc26bSmrg# by a space.
621e07dc26bSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
622e07dc26bSmrg  eval 'func_append_quoted ()
623e07dc26bSmrg  {
624e07dc26bSmrg    $debug_cmd
625e07dc26bSmrg
626636c353eSmrg    func_quote_arg pretty "$2"
627636c353eSmrg    eval "$1+=\\ \$func_quote_arg_result"
628e07dc26bSmrg  }'
629e07dc26bSmrgelse
630e07dc26bSmrg  func_append_quoted ()
631e07dc26bSmrg  {
632e07dc26bSmrg    $debug_cmd
633e07dc26bSmrg
634636c353eSmrg    func_quote_arg pretty "$2"
635636c353eSmrg    eval "$1=\$$1\\ \$func_quote_arg_result"
636e07dc26bSmrg  }
637e07dc26bSmrgfi
638e07dc26bSmrg
639e07dc26bSmrg
640e07dc26bSmrg# func_append_uniq VAR VALUE
641e07dc26bSmrg# --------------------------
642e07dc26bSmrg# Append unique VALUE onto the existing contents of VAR, assuming
643e07dc26bSmrg# entries are delimited by the first character of VALUE.  For example:
644e07dc26bSmrg#
645e07dc26bSmrg#   func_append_uniq options " --another-option option-argument"
646e07dc26bSmrg#
647e07dc26bSmrg# will only append to $options if " --another-option option-argument "
648e07dc26bSmrg# is not already present somewhere in $options already (note spaces at
649e07dc26bSmrg# each end implied by leading space in second argument).
650e07dc26bSmrgfunc_append_uniq ()
651e07dc26bSmrg{
652e07dc26bSmrg    $debug_cmd
653e07dc26bSmrg
654e07dc26bSmrg    eval _G_current_value='`$ECHO $'$1'`'
655e07dc26bSmrg    _G_delim=`expr "$2" : '\(.\)'`
656e07dc26bSmrg
657e07dc26bSmrg    case $_G_delim$_G_current_value$_G_delim in
658e07dc26bSmrg      *"$2$_G_delim"*) ;;
659e07dc26bSmrg      *) func_append "$@" ;;
660e07dc26bSmrg    esac
661e07dc26bSmrg}
662e07dc26bSmrg
663e07dc26bSmrg
664e07dc26bSmrg# func_arith TERM...
665e07dc26bSmrg# ------------------
666e07dc26bSmrg# Set func_arith_result to the result of evaluating TERMs.
667e07dc26bSmrg  test -z "$_G_HAVE_ARITH_OP" \
668e07dc26bSmrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
669e07dc26bSmrg    && _G_HAVE_ARITH_OP=yes
670e07dc26bSmrg
671e07dc26bSmrgif test yes = "$_G_HAVE_ARITH_OP"; then
672e07dc26bSmrg  eval 'func_arith ()
673e07dc26bSmrg  {
674e07dc26bSmrg    $debug_cmd
675e07dc26bSmrg
676e07dc26bSmrg    func_arith_result=$(( $* ))
677e07dc26bSmrg  }'
678e07dc26bSmrgelse
679e07dc26bSmrg  func_arith ()
680e07dc26bSmrg  {
681e07dc26bSmrg    $debug_cmd
682e07dc26bSmrg
683e07dc26bSmrg    func_arith_result=`expr "$@"`
684e07dc26bSmrg  }
685e07dc26bSmrgfi
686e07dc26bSmrg
687e07dc26bSmrg
688e07dc26bSmrg# func_basename FILE
689e07dc26bSmrg# ------------------
690e07dc26bSmrg# Set func_basename_result to FILE with everything up to and including
691e07dc26bSmrg# the last / stripped.
692e07dc26bSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
693e07dc26bSmrg  # If this shell supports suffix pattern removal, then use it to avoid
694e07dc26bSmrg  # forking. Hide the definitions single quotes in case the shell chokes
695e07dc26bSmrg  # on unsupported syntax...
696e07dc26bSmrg  _b='func_basename_result=${1##*/}'
697e07dc26bSmrg  _d='case $1 in
698e07dc26bSmrg        */*) func_dirname_result=${1%/*}$2 ;;
699e07dc26bSmrg        *  ) func_dirname_result=$3        ;;
700e07dc26bSmrg      esac'
701e07dc26bSmrg
702e07dc26bSmrgelse
703e07dc26bSmrg  # ...otherwise fall back to using sed.
704e07dc26bSmrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
705e07dc26bSmrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
706e07dc26bSmrg      if test "X$func_dirname_result" = "X$1"; then
707e07dc26bSmrg        func_dirname_result=$3
708e07dc26bSmrg      else
709e07dc26bSmrg        func_append func_dirname_result "$2"
710e07dc26bSmrg      fi'
711e07dc26bSmrgfi
712e07dc26bSmrg
713e07dc26bSmrgeval 'func_basename ()
714e07dc26bSmrg{
715e07dc26bSmrg    $debug_cmd
716e07dc26bSmrg
717e07dc26bSmrg    '"$_b"'
718e07dc26bSmrg}'
719e07dc26bSmrg
720e07dc26bSmrg
721e07dc26bSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
722e07dc26bSmrg# -------------------------------------------
723e07dc26bSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
724e07dc26bSmrg# otherwise set result to NONDIR_REPLACEMENT.
725e07dc26bSmrgeval 'func_dirname ()
726e07dc26bSmrg{
727e07dc26bSmrg    $debug_cmd
728e07dc26bSmrg
729e07dc26bSmrg    '"$_d"'
730e07dc26bSmrg}'
731e07dc26bSmrg
732e07dc26bSmrg
733e07dc26bSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
734e07dc26bSmrg# --------------------------------------------------------
735e07dc26bSmrg# Perform func_basename and func_dirname in a single function
736e07dc26bSmrg# call:
737e07dc26bSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
738e07dc26bSmrg#             add APPEND to the result, otherwise set result
739e07dc26bSmrg#             to NONDIR_REPLACEMENT.
740e07dc26bSmrg#             value returned in "$func_dirname_result"
741e07dc26bSmrg#   basename: Compute filename of FILE.
742e07dc26bSmrg#             value retuned in "$func_basename_result"
743e07dc26bSmrg# For efficiency, we do not delegate to the functions above but instead
744e07dc26bSmrg# duplicate the functionality here.
745e07dc26bSmrgeval 'func_dirname_and_basename ()
746e07dc26bSmrg{
747e07dc26bSmrg    $debug_cmd
748e07dc26bSmrg
749e07dc26bSmrg    '"$_b"'
750e07dc26bSmrg    '"$_d"'
751e07dc26bSmrg}'
752e07dc26bSmrg
753e07dc26bSmrg
754e07dc26bSmrg# func_echo ARG...
755e07dc26bSmrg# ----------------
756e07dc26bSmrg# Echo program name prefixed message.
757e07dc26bSmrgfunc_echo ()
758e07dc26bSmrg{
759e07dc26bSmrg    $debug_cmd
760e07dc26bSmrg
761e07dc26bSmrg    _G_message=$*
762e07dc26bSmrg
763e07dc26bSmrg    func_echo_IFS=$IFS
764e07dc26bSmrg    IFS=$nl
765e07dc26bSmrg    for _G_line in $_G_message; do
766e07dc26bSmrg      IFS=$func_echo_IFS
767e07dc26bSmrg      $ECHO "$progname: $_G_line"
768e07dc26bSmrg    done
769e07dc26bSmrg    IFS=$func_echo_IFS
770e07dc26bSmrg}
771e07dc26bSmrg
772e07dc26bSmrg
773e07dc26bSmrg# func_echo_all ARG...
774e07dc26bSmrg# --------------------
775e07dc26bSmrg# Invoke $ECHO with all args, space-separated.
776e07dc26bSmrgfunc_echo_all ()
777e07dc26bSmrg{
778e07dc26bSmrg    $ECHO "$*"
779e07dc26bSmrg}
780e07dc26bSmrg
781e07dc26bSmrg
782e07dc26bSmrg# func_echo_infix_1 INFIX ARG...
783e07dc26bSmrg# ------------------------------
784e07dc26bSmrg# Echo program name, followed by INFIX on the first line, with any
785e07dc26bSmrg# additional lines not showing INFIX.
786e07dc26bSmrgfunc_echo_infix_1 ()
787e07dc26bSmrg{
788e07dc26bSmrg    $debug_cmd
789e07dc26bSmrg
790e07dc26bSmrg    $require_term_colors
791e07dc26bSmrg
792e07dc26bSmrg    _G_infix=$1; shift
793e07dc26bSmrg    _G_indent=$_G_infix
794e07dc26bSmrg    _G_prefix="$progname: $_G_infix: "
795e07dc26bSmrg    _G_message=$*
796e07dc26bSmrg
797e07dc26bSmrg    # Strip color escape sequences before counting printable length
798e07dc26bSmrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
799e07dc26bSmrg    do
800e07dc26bSmrg      test -n "$_G_tc" && {
801e07dc26bSmrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
802e07dc26bSmrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
803e07dc26bSmrg      }
804e07dc26bSmrg    done
805e07dc26bSmrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
806e07dc26bSmrg
807e07dc26bSmrg    func_echo_infix_1_IFS=$IFS
808e07dc26bSmrg    IFS=$nl
809e07dc26bSmrg    for _G_line in $_G_message; do
810e07dc26bSmrg      IFS=$func_echo_infix_1_IFS
811e07dc26bSmrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
812e07dc26bSmrg      _G_prefix=$_G_indent
813e07dc26bSmrg    done
814e07dc26bSmrg    IFS=$func_echo_infix_1_IFS
815e07dc26bSmrg}
816e07dc26bSmrg
817e07dc26bSmrg
818e07dc26bSmrg# func_error ARG...
819e07dc26bSmrg# -----------------
820e07dc26bSmrg# Echo program name prefixed message to standard error.
821e07dc26bSmrgfunc_error ()
822e07dc26bSmrg{
823e07dc26bSmrg    $debug_cmd
824e07dc26bSmrg
825e07dc26bSmrg    $require_term_colors
826e07dc26bSmrg
827e07dc26bSmrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
828e07dc26bSmrg}
829e07dc26bSmrg
830e07dc26bSmrg
831e07dc26bSmrg# func_fatal_error ARG...
832e07dc26bSmrg# -----------------------
833e07dc26bSmrg# Echo program name prefixed message to standard error, and exit.
834e07dc26bSmrgfunc_fatal_error ()
835e07dc26bSmrg{
836e07dc26bSmrg    $debug_cmd
837e07dc26bSmrg
838e07dc26bSmrg    func_error "$*"
839e07dc26bSmrg    exit $EXIT_FAILURE
840e07dc26bSmrg}
841e07dc26bSmrg
842e07dc26bSmrg
843e07dc26bSmrg# func_grep EXPRESSION FILENAME
844e07dc26bSmrg# -----------------------------
845e07dc26bSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
846e07dc26bSmrgfunc_grep ()
847e07dc26bSmrg{
848e07dc26bSmrg    $debug_cmd
849e07dc26bSmrg
850e07dc26bSmrg    $GREP "$1" "$2" >/dev/null 2>&1
851e07dc26bSmrg}
852e07dc26bSmrg
853e07dc26bSmrg
854e07dc26bSmrg# func_len STRING
855e07dc26bSmrg# ---------------
856e07dc26bSmrg# Set func_len_result to the length of STRING. STRING may not
857e07dc26bSmrg# start with a hyphen.
858e07dc26bSmrg  test -z "$_G_HAVE_XSI_OPS" \
859e07dc26bSmrg    && (eval 'x=a/b/c;
860e07dc26bSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
861e07dc26bSmrg    && _G_HAVE_XSI_OPS=yes
862e07dc26bSmrg
863e07dc26bSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
864e07dc26bSmrg  eval 'func_len ()
865e07dc26bSmrg  {
866e07dc26bSmrg    $debug_cmd
867e07dc26bSmrg
868e07dc26bSmrg    func_len_result=${#1}
869e07dc26bSmrg  }'
870e07dc26bSmrgelse
871e07dc26bSmrg  func_len ()
872e07dc26bSmrg  {
873e07dc26bSmrg    $debug_cmd
874e07dc26bSmrg
875e07dc26bSmrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
876e07dc26bSmrg  }
877e07dc26bSmrgfi
878e07dc26bSmrg
879e07dc26bSmrg
880e07dc26bSmrg# func_mkdir_p DIRECTORY-PATH
881e07dc26bSmrg# ---------------------------
882e07dc26bSmrg# Make sure the entire path to DIRECTORY-PATH is available.
883e07dc26bSmrgfunc_mkdir_p ()
884e07dc26bSmrg{
885e07dc26bSmrg    $debug_cmd
886e07dc26bSmrg
887e07dc26bSmrg    _G_directory_path=$1
888e07dc26bSmrg    _G_dir_list=
889e07dc26bSmrg
890e07dc26bSmrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
891e07dc26bSmrg
892e07dc26bSmrg      # Protect directory names starting with '-'
893e07dc26bSmrg      case $_G_directory_path in
894e07dc26bSmrg        -*) _G_directory_path=./$_G_directory_path ;;
895e07dc26bSmrg      esac
896e07dc26bSmrg
897e07dc26bSmrg      # While some portion of DIR does not yet exist...
898e07dc26bSmrg      while test ! -d "$_G_directory_path"; do
899e07dc26bSmrg        # ...make a list in topmost first order.  Use a colon delimited
900e07dc26bSmrg	# list incase some portion of path contains whitespace.
901e07dc26bSmrg        _G_dir_list=$_G_directory_path:$_G_dir_list
902e07dc26bSmrg
903e07dc26bSmrg        # If the last portion added has no slash in it, the list is done
904e07dc26bSmrg        case $_G_directory_path in */*) ;; *) break ;; esac
905e07dc26bSmrg
906e07dc26bSmrg        # ...otherwise throw away the child directory and loop
907e07dc26bSmrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
908e07dc26bSmrg      done
909e07dc26bSmrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
910e07dc26bSmrg
911e07dc26bSmrg      func_mkdir_p_IFS=$IFS; IFS=:
912e07dc26bSmrg      for _G_dir in $_G_dir_list; do
913e07dc26bSmrg	IFS=$func_mkdir_p_IFS
914e07dc26bSmrg        # mkdir can fail with a 'File exist' error if two processes
915e07dc26bSmrg        # try to create one of the directories concurrently.  Don't
916e07dc26bSmrg        # stop in that case!
917e07dc26bSmrg        $MKDIR "$_G_dir" 2>/dev/null || :
918e07dc26bSmrg      done
919e07dc26bSmrg      IFS=$func_mkdir_p_IFS
920e07dc26bSmrg
921e07dc26bSmrg      # Bail out if we (or some other process) failed to create a directory.
922e07dc26bSmrg      test -d "$_G_directory_path" || \
923e07dc26bSmrg        func_fatal_error "Failed to create '$1'"
924e07dc26bSmrg    fi
925e07dc26bSmrg}
926e07dc26bSmrg
927e07dc26bSmrg
928e07dc26bSmrg# func_mktempdir [BASENAME]
929e07dc26bSmrg# -------------------------
930e07dc26bSmrg# Make a temporary directory that won't clash with other running
931e07dc26bSmrg# libtool processes, and avoids race conditions if possible.  If
932e07dc26bSmrg# given, BASENAME is the basename for that directory.
933e07dc26bSmrgfunc_mktempdir ()
934e07dc26bSmrg{
935e07dc26bSmrg    $debug_cmd
936e07dc26bSmrg
937e07dc26bSmrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
938e07dc26bSmrg
939e07dc26bSmrg    if test : = "$opt_dry_run"; then
940e07dc26bSmrg      # Return a directory name, but don't create it in dry-run mode
941e07dc26bSmrg      _G_tmpdir=$_G_template-$$
942e07dc26bSmrg    else
943e07dc26bSmrg
944e07dc26bSmrg      # If mktemp works, use that first and foremost
945e07dc26bSmrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
946e07dc26bSmrg
947e07dc26bSmrg      if test ! -d "$_G_tmpdir"; then
948e07dc26bSmrg        # Failing that, at least try and use $RANDOM to avoid a race
949e07dc26bSmrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
950e07dc26bSmrg
951e07dc26bSmrg        func_mktempdir_umask=`umask`
952e07dc26bSmrg        umask 0077
953e07dc26bSmrg        $MKDIR "$_G_tmpdir"
954e07dc26bSmrg        umask $func_mktempdir_umask
955e07dc26bSmrg      fi
956e07dc26bSmrg
957e07dc26bSmrg      # If we're not in dry-run mode, bomb out on failure
958e07dc26bSmrg      test -d "$_G_tmpdir" || \
959e07dc26bSmrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
960e07dc26bSmrg    fi
961e07dc26bSmrg
962e07dc26bSmrg    $ECHO "$_G_tmpdir"
963e07dc26bSmrg}
964e07dc26bSmrg
965e07dc26bSmrg
966e07dc26bSmrg# func_normal_abspath PATH
967e07dc26bSmrg# ------------------------
968e07dc26bSmrg# Remove doubled-up and trailing slashes, "." path components,
969e07dc26bSmrg# and cancel out any ".." path components in PATH after making
970e07dc26bSmrg# it an absolute path.
971e07dc26bSmrgfunc_normal_abspath ()
972e07dc26bSmrg{
973e07dc26bSmrg    $debug_cmd
974e07dc26bSmrg
975e07dc26bSmrg    # These SED scripts presuppose an absolute path with a trailing slash.
976e07dc26bSmrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
977e07dc26bSmrg    _G_pathcdr='s|^/[^/]*||'
978e07dc26bSmrg    _G_removedotparts=':dotsl
979e07dc26bSmrg		s|/\./|/|g
980e07dc26bSmrg		t dotsl
981e07dc26bSmrg		s|/\.$|/|'
982e07dc26bSmrg    _G_collapseslashes='s|/\{1,\}|/|g'
983e07dc26bSmrg    _G_finalslash='s|/*$|/|'
984e07dc26bSmrg
985e07dc26bSmrg    # Start from root dir and reassemble the path.
986e07dc26bSmrg    func_normal_abspath_result=
987e07dc26bSmrg    func_normal_abspath_tpath=$1
988e07dc26bSmrg    func_normal_abspath_altnamespace=
989e07dc26bSmrg    case $func_normal_abspath_tpath in
990e07dc26bSmrg      "")
991e07dc26bSmrg        # Empty path, that just means $cwd.
992e07dc26bSmrg        func_stripname '' '/' "`pwd`"
993e07dc26bSmrg        func_normal_abspath_result=$func_stripname_result
994e07dc26bSmrg        return
995e07dc26bSmrg        ;;
996e07dc26bSmrg      # The next three entries are used to spot a run of precisely
997e07dc26bSmrg      # two leading slashes without using negated character classes;
998e07dc26bSmrg      # we take advantage of case's first-match behaviour.
999e07dc26bSmrg      ///*)
1000e07dc26bSmrg        # Unusual form of absolute path, do nothing.
1001e07dc26bSmrg        ;;
1002e07dc26bSmrg      //*)
1003e07dc26bSmrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
1004e07dc26bSmrg        # and for example Cygwin uses it to access remote file shares
1005e07dc26bSmrg        # over CIFS/SMB, so we conserve a leading double slash if found.
1006e07dc26bSmrg        func_normal_abspath_altnamespace=/
1007e07dc26bSmrg        ;;
1008e07dc26bSmrg      /*)
1009e07dc26bSmrg        # Absolute path, do nothing.
1010e07dc26bSmrg        ;;
1011e07dc26bSmrg      *)
1012e07dc26bSmrg        # Relative path, prepend $cwd.
1013e07dc26bSmrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
1014e07dc26bSmrg        ;;
1015e07dc26bSmrg    esac
1016e07dc26bSmrg
1017e07dc26bSmrg    # Cancel out all the simple stuff to save iterations.  We also want
1018e07dc26bSmrg    # the path to end with a slash for ease of parsing, so make sure
1019e07dc26bSmrg    # there is one (and only one) here.
1020e07dc26bSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
1021e07dc26bSmrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
1022e07dc26bSmrg    while :; do
1023e07dc26bSmrg      # Processed it all yet?
1024e07dc26bSmrg      if test / = "$func_normal_abspath_tpath"; then
1025e07dc26bSmrg        # If we ascended to the root using ".." the result may be empty now.
1026e07dc26bSmrg        if test -z "$func_normal_abspath_result"; then
1027e07dc26bSmrg          func_normal_abspath_result=/
1028e07dc26bSmrg        fi
1029e07dc26bSmrg        break
1030e07dc26bSmrg      fi
1031e07dc26bSmrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
1032e07dc26bSmrg          -e "$_G_pathcar"`
1033e07dc26bSmrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
1034e07dc26bSmrg          -e "$_G_pathcdr"`
1035e07dc26bSmrg      # Figure out what to do with it
1036e07dc26bSmrg      case $func_normal_abspath_tcomponent in
1037e07dc26bSmrg        "")
1038e07dc26bSmrg          # Trailing empty path component, ignore it.
1039e07dc26bSmrg          ;;
1040e07dc26bSmrg        ..)
1041e07dc26bSmrg          # Parent dir; strip last assembled component from result.
1042e07dc26bSmrg          func_dirname "$func_normal_abspath_result"
1043e07dc26bSmrg          func_normal_abspath_result=$func_dirname_result
1044e07dc26bSmrg          ;;
1045e07dc26bSmrg        *)
1046e07dc26bSmrg          # Actual path component, append it.
1047e07dc26bSmrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1048e07dc26bSmrg          ;;
1049e07dc26bSmrg      esac
1050e07dc26bSmrg    done
1051e07dc26bSmrg    # Restore leading double-slash if one was found on entry.
1052e07dc26bSmrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1053e07dc26bSmrg}
1054e07dc26bSmrg
1055e07dc26bSmrg
1056e07dc26bSmrg# func_notquiet ARG...
1057e07dc26bSmrg# --------------------
1058e07dc26bSmrg# Echo program name prefixed message only when not in quiet mode.
1059e07dc26bSmrgfunc_notquiet ()
1060e07dc26bSmrg{
1061e07dc26bSmrg    $debug_cmd
1062e07dc26bSmrg
1063e07dc26bSmrg    $opt_quiet || func_echo ${1+"$@"}
1064e07dc26bSmrg
1065e07dc26bSmrg    # A bug in bash halts the script if the last line of a function
1066e07dc26bSmrg    # fails when set -e is in force, so we need another command to
1067e07dc26bSmrg    # work around that:
1068e07dc26bSmrg    :
1069e07dc26bSmrg}
1070e07dc26bSmrg
1071e07dc26bSmrg
1072e07dc26bSmrg# func_relative_path SRCDIR DSTDIR
1073e07dc26bSmrg# --------------------------------
1074e07dc26bSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1075e07dc26bSmrgfunc_relative_path ()
1076e07dc26bSmrg{
1077e07dc26bSmrg    $debug_cmd
1078e07dc26bSmrg
1079e07dc26bSmrg    func_relative_path_result=
1080e07dc26bSmrg    func_normal_abspath "$1"
1081e07dc26bSmrg    func_relative_path_tlibdir=$func_normal_abspath_result
1082e07dc26bSmrg    func_normal_abspath "$2"
1083e07dc26bSmrg    func_relative_path_tbindir=$func_normal_abspath_result
1084e07dc26bSmrg
1085e07dc26bSmrg    # Ascend the tree starting from libdir
1086e07dc26bSmrg    while :; do
1087e07dc26bSmrg      # check if we have found a prefix of bindir
1088e07dc26bSmrg      case $func_relative_path_tbindir in
1089e07dc26bSmrg        $func_relative_path_tlibdir)
1090e07dc26bSmrg          # found an exact match
1091e07dc26bSmrg          func_relative_path_tcancelled=
1092e07dc26bSmrg          break
1093e07dc26bSmrg          ;;
1094e07dc26bSmrg        $func_relative_path_tlibdir*)
1095e07dc26bSmrg          # found a matching prefix
1096e07dc26bSmrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1097e07dc26bSmrg          func_relative_path_tcancelled=$func_stripname_result
1098e07dc26bSmrg          if test -z "$func_relative_path_result"; then
1099e07dc26bSmrg            func_relative_path_result=.
1100e07dc26bSmrg          fi
1101e07dc26bSmrg          break
1102e07dc26bSmrg          ;;
1103e07dc26bSmrg        *)
1104e07dc26bSmrg          func_dirname $func_relative_path_tlibdir
1105e07dc26bSmrg          func_relative_path_tlibdir=$func_dirname_result
1106e07dc26bSmrg          if test -z "$func_relative_path_tlibdir"; then
1107e07dc26bSmrg            # Have to descend all the way to the root!
1108e07dc26bSmrg            func_relative_path_result=../$func_relative_path_result
1109e07dc26bSmrg            func_relative_path_tcancelled=$func_relative_path_tbindir
1110e07dc26bSmrg            break
1111e07dc26bSmrg          fi
1112e07dc26bSmrg          func_relative_path_result=../$func_relative_path_result
1113e07dc26bSmrg          ;;
1114e07dc26bSmrg      esac
1115e07dc26bSmrg    done
1116e07dc26bSmrg
1117e07dc26bSmrg    # Now calculate path; take care to avoid doubling-up slashes.
1118e07dc26bSmrg    func_stripname '' '/' "$func_relative_path_result"
1119e07dc26bSmrg    func_relative_path_result=$func_stripname_result
1120e07dc26bSmrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
1121e07dc26bSmrg    if test -n "$func_stripname_result"; then
1122e07dc26bSmrg      func_append func_relative_path_result "/$func_stripname_result"
1123e07dc26bSmrg    fi
1124e07dc26bSmrg
1125e07dc26bSmrg    # Normalisation. If bindir is libdir, return '.' else relative path.
1126e07dc26bSmrg    if test -n "$func_relative_path_result"; then
1127e07dc26bSmrg      func_stripname './' '' "$func_relative_path_result"
1128e07dc26bSmrg      func_relative_path_result=$func_stripname_result
1129e07dc26bSmrg    fi
1130e07dc26bSmrg
1131e07dc26bSmrg    test -n "$func_relative_path_result" || func_relative_path_result=.
1132e07dc26bSmrg
1133e07dc26bSmrg    :
1134e07dc26bSmrg}
1135e07dc26bSmrg
1136e07dc26bSmrg
1137636c353eSmrg# func_quote_portable EVAL ARG
1138636c353eSmrg# ----------------------------
1139636c353eSmrg# Internal function to portably implement func_quote_arg.  Note that we still
1140636c353eSmrg# keep attention to performance here so we as much as possible try to avoid
1141636c353eSmrg# calling sed binary (so far O(N) complexity as long as func_append is O(1)).
1142636c353eSmrgfunc_quote_portable ()
1143e07dc26bSmrg{
1144e07dc26bSmrg    $debug_cmd
1145e07dc26bSmrg
1146636c353eSmrg    $require_check_ifs_backslash
1147636c353eSmrg
1148636c353eSmrg    func_quote_portable_result=$2
1149636c353eSmrg
1150636c353eSmrg    # one-time-loop (easy break)
1151636c353eSmrg    while true
1152636c353eSmrg    do
1153636c353eSmrg      if $1; then
1154636c353eSmrg        func_quote_portable_result=`$ECHO "$2" | $SED \
1155636c353eSmrg          -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
1156636c353eSmrg        break
1157e07dc26bSmrg      fi
1158e07dc26bSmrg
1159636c353eSmrg      # Quote for eval.
1160636c353eSmrg      case $func_quote_portable_result in
1161636c353eSmrg        *[\\\`\"\$]*)
1162636c353eSmrg          # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string
1163636c353eSmrg          # contains the shell wildcard characters.
1164636c353eSmrg          case $check_ifs_backshlash_broken$func_quote_portable_result in
1165636c353eSmrg            :*|*[\[\*\?]*)
1166636c353eSmrg              func_quote_portable_result=`$ECHO "$func_quote_portable_result" \
1167636c353eSmrg                  | $SED "$sed_quote_subst"`
1168636c353eSmrg              break
1169636c353eSmrg              ;;
1170636c353eSmrg          esac
1171636c353eSmrg
1172636c353eSmrg          func_quote_portable_old_IFS=$IFS
1173636c353eSmrg          for _G_char in '\' '`' '"' '$'
1174636c353eSmrg          do
1175636c353eSmrg            # STATE($1) PREV($2) SEPARATOR($3)
1176636c353eSmrg            set start "" ""
1177636c353eSmrg            func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
1178636c353eSmrg            IFS=$_G_char
1179636c353eSmrg            for _G_part in $func_quote_portable_result
1180636c353eSmrg            do
1181636c353eSmrg              case $1 in
1182636c353eSmrg              quote)
1183636c353eSmrg                func_append func_quote_portable_result "$3$2"
1184636c353eSmrg                set quote "$_G_part" "\\$_G_char"
1185636c353eSmrg                ;;
1186636c353eSmrg              start)
1187636c353eSmrg                set first "" ""
1188636c353eSmrg                func_quote_portable_result=
1189636c353eSmrg                ;;
1190636c353eSmrg              first)
1191636c353eSmrg                set quote "$_G_part" ""
1192636c353eSmrg                ;;
1193636c353eSmrg              esac
1194636c353eSmrg            done
1195636c353eSmrg          done
1196636c353eSmrg          IFS=$func_quote_portable_old_IFS
1197e07dc26bSmrg          ;;
1198636c353eSmrg        *) ;;
1199e07dc26bSmrg      esac
1200636c353eSmrg      break
1201e07dc26bSmrg    done
1202636c353eSmrg
1203636c353eSmrg    func_quote_portable_unquoted_result=$func_quote_portable_result
1204636c353eSmrg    case $func_quote_portable_result in
1205636c353eSmrg      # double-quote args containing shell metacharacters to delay
1206636c353eSmrg      # word splitting, command substitution and variable expansion
1207636c353eSmrg      # for a subsequent eval.
1208636c353eSmrg      # many bourne shells cannot handle close brackets correctly
1209636c353eSmrg      # in scan sets, so we specify it separately.
1210636c353eSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1211636c353eSmrg        func_quote_portable_result=\"$func_quote_portable_result\"
1212636c353eSmrg        ;;
1213636c353eSmrg    esac
1214e07dc26bSmrg}
1215e07dc26bSmrg
1216e07dc26bSmrg
1217636c353eSmrg# func_quotefast_eval ARG
1218636c353eSmrg# -----------------------
1219636c353eSmrg# Quote one ARG (internal).  This is equivalent to 'func_quote_arg eval ARG',
1220636c353eSmrg# but optimized for speed.  Result is stored in $func_quotefast_eval.
1221636c353eSmrgif test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
1222636c353eSmrg  printf -v _GL_test_printf_tilde %q '~'
1223636c353eSmrg  if test '\~' = "$_GL_test_printf_tilde"; then
1224636c353eSmrg    func_quotefast_eval ()
1225636c353eSmrg    {
1226636c353eSmrg      printf -v func_quotefast_eval_result %q "$1"
1227636c353eSmrg    }
1228636c353eSmrg  else
1229636c353eSmrg    # Broken older Bash implementations.  Make those faster too if possible.
1230636c353eSmrg    func_quotefast_eval ()
1231636c353eSmrg    {
1232636c353eSmrg      case $1 in
1233636c353eSmrg        '~'*)
1234636c353eSmrg          func_quote_portable false "$1"
1235636c353eSmrg          func_quotefast_eval_result=$func_quote_portable_result
1236636c353eSmrg          ;;
1237636c353eSmrg        *)
1238636c353eSmrg          printf -v func_quotefast_eval_result %q "$1"
1239636c353eSmrg          ;;
1240636c353eSmrg      esac
1241636c353eSmrg    }
1242636c353eSmrg  fi
1243636c353eSmrgelse
1244636c353eSmrg  func_quotefast_eval ()
1245636c353eSmrg  {
1246636c353eSmrg    func_quote_portable false "$1"
1247636c353eSmrg    func_quotefast_eval_result=$func_quote_portable_result
1248636c353eSmrg  }
1249636c353eSmrgfi
1250e07dc26bSmrg
1251636c353eSmrg
1252636c353eSmrg# func_quote_arg MODEs ARG
1253636c353eSmrg# ------------------------
1254636c353eSmrg# Quote one ARG to be evaled later.  MODEs argument may contain zero or more
1255636c353eSmrg# specifiers listed below separated by ',' character.  This function returns two
1256636c353eSmrg# values:
1257636c353eSmrg#   i) func_quote_arg_result
1258636c353eSmrg#      double-quoted (when needed), suitable for a subsequent eval
1259636c353eSmrg#  ii) func_quote_arg_unquoted_result
1260636c353eSmrg#      has all characters that are still active within double
1261636c353eSmrg#      quotes backslashified.  Available only if 'unquoted' is specified.
1262636c353eSmrg#
1263636c353eSmrg# Available modes:
1264636c353eSmrg# ----------------
1265636c353eSmrg# 'eval' (default)
1266636c353eSmrg#       - escape shell special characters
1267636c353eSmrg# 'expand'
1268636c353eSmrg#       - the same as 'eval';  but do not quote variable references
1269636c353eSmrg# 'pretty'
1270636c353eSmrg#       - request aesthetic output, i.e. '"a b"' instead of 'a\ b'.  This might
1271636c353eSmrg#         be used later in func_quote to get output like: 'echo "a b"' instead
1272636c353eSmrg#         of 'echo a\ b'.  This is slower than default on some shells.
1273636c353eSmrg# 'unquoted'
1274636c353eSmrg#       - produce also $func_quote_arg_unquoted_result which does not contain
1275636c353eSmrg#         wrapping double-quotes.
1276636c353eSmrg#
1277636c353eSmrg# Examples for 'func_quote_arg pretty,unquoted string':
1278636c353eSmrg#
1279636c353eSmrg#   string      | *_result              | *_unquoted_result
1280636c353eSmrg#   ------------+-----------------------+-------------------
1281636c353eSmrg#   "           | \"                    | \"
1282636c353eSmrg#   a b         | "a b"                 | a b
1283636c353eSmrg#   "a b"       | "\"a b\""             | \"a b\"
1284636c353eSmrg#   *           | "*"                   | *
1285636c353eSmrg#   z="${x-$y}" | "z=\"\${x-\$y}\""     | z=\"\${x-\$y}\"
1286636c353eSmrg#
1287636c353eSmrg# Examples for 'func_quote_arg pretty,unquoted,expand string':
1288636c353eSmrg#
1289636c353eSmrg#   string        |   *_result          |  *_unquoted_result
1290636c353eSmrg#   --------------+---------------------+--------------------
1291636c353eSmrg#   z="${x-$y}"   | "z=\"${x-$y}\""     | z=\"${x-$y}\"
1292636c353eSmrgfunc_quote_arg ()
1293636c353eSmrg{
1294636c353eSmrg    _G_quote_expand=false
1295636c353eSmrg    case ,$1, in
1296636c353eSmrg      *,expand,*)
1297636c353eSmrg        _G_quote_expand=:
1298636c353eSmrg        ;;
1299e07dc26bSmrg    esac
1300e07dc26bSmrg
1301636c353eSmrg    case ,$1, in
1302636c353eSmrg      *,pretty,*|*,expand,*|*,unquoted,*)
1303636c353eSmrg        func_quote_portable $_G_quote_expand "$2"
1304636c353eSmrg        func_quote_arg_result=$func_quote_portable_result
1305636c353eSmrg        func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
1306636c353eSmrg        ;;
1307636c353eSmrg      *)
1308636c353eSmrg        # Faster quote-for-eval for some shells.
1309636c353eSmrg        func_quotefast_eval "$2"
1310636c353eSmrg        func_quote_arg_result=$func_quotefast_eval_result
1311e07dc26bSmrg        ;;
1312e07dc26bSmrg    esac
1313636c353eSmrg}
1314636c353eSmrg
1315e07dc26bSmrg
1316636c353eSmrg# func_quote MODEs ARGs...
1317636c353eSmrg# ------------------------
1318636c353eSmrg# Quote all ARGs to be evaled later and join them into single command.  See
1319636c353eSmrg# func_quote_arg's description for more info.
1320636c353eSmrgfunc_quote ()
1321636c353eSmrg{
1322636c353eSmrg    $debug_cmd
1323636c353eSmrg    _G_func_quote_mode=$1 ; shift
1324636c353eSmrg    func_quote_result=
1325636c353eSmrg    while test 0 -lt $#; do
1326636c353eSmrg      func_quote_arg "$_G_func_quote_mode" "$1"
1327636c353eSmrg      if test -n "$func_quote_result"; then
1328636c353eSmrg        func_append func_quote_result " $func_quote_arg_result"
1329636c353eSmrg      else
1330636c353eSmrg        func_append func_quote_result "$func_quote_arg_result"
1331636c353eSmrg      fi
1332636c353eSmrg      shift
1333636c353eSmrg    done
1334e07dc26bSmrg}
1335e07dc26bSmrg
1336e07dc26bSmrg
1337e07dc26bSmrg# func_stripname PREFIX SUFFIX NAME
1338e07dc26bSmrg# ---------------------------------
1339e07dc26bSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1340e07dc26bSmrg# PREFIX and SUFFIX must not contain globbing or regex special
1341e07dc26bSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
1342e07dc26bSmrg# dot (in which case that matches only a dot).
1343e07dc26bSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
1344e07dc26bSmrg  eval 'func_stripname ()
1345e07dc26bSmrg  {
1346e07dc26bSmrg    $debug_cmd
1347e07dc26bSmrg
1348e07dc26bSmrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1349e07dc26bSmrg    # positional parameters, so assign one to ordinary variable first.
1350e07dc26bSmrg    func_stripname_result=$3
1351e07dc26bSmrg    func_stripname_result=${func_stripname_result#"$1"}
1352e07dc26bSmrg    func_stripname_result=${func_stripname_result%"$2"}
1353e07dc26bSmrg  }'
1354e07dc26bSmrgelse
1355e07dc26bSmrg  func_stripname ()
1356e07dc26bSmrg  {
1357e07dc26bSmrg    $debug_cmd
1358e07dc26bSmrg
1359e07dc26bSmrg    case $2 in
1360e07dc26bSmrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1361e07dc26bSmrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1362e07dc26bSmrg    esac
1363e07dc26bSmrg  }
1364e07dc26bSmrgfi
1365e07dc26bSmrg
1366e07dc26bSmrg
1367e07dc26bSmrg# func_show_eval CMD [FAIL_EXP]
1368e07dc26bSmrg# -----------------------------
1369e07dc26bSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1370e07dc26bSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1371e07dc26bSmrg# is given, then evaluate it.
1372e07dc26bSmrgfunc_show_eval ()
1373e07dc26bSmrg{
1374e07dc26bSmrg    $debug_cmd
1375e07dc26bSmrg
1376e07dc26bSmrg    _G_cmd=$1
1377e07dc26bSmrg    _G_fail_exp=${2-':'}
1378e07dc26bSmrg
1379636c353eSmrg    func_quote_arg pretty,expand "$_G_cmd"
1380636c353eSmrg    eval "func_notquiet $func_quote_arg_result"
1381e07dc26bSmrg
1382e07dc26bSmrg    $opt_dry_run || {
1383e07dc26bSmrg      eval "$_G_cmd"
1384e07dc26bSmrg      _G_status=$?
1385e07dc26bSmrg      if test 0 -ne "$_G_status"; then
1386e07dc26bSmrg	eval "(exit $_G_status); $_G_fail_exp"
1387e07dc26bSmrg      fi
1388e07dc26bSmrg    }
1389e07dc26bSmrg}
1390e07dc26bSmrg
1391e07dc26bSmrg
1392e07dc26bSmrg# func_show_eval_locale CMD [FAIL_EXP]
1393e07dc26bSmrg# ------------------------------------
1394e07dc26bSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1395e07dc26bSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1396e07dc26bSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
1397e07dc26bSmrgfunc_show_eval_locale ()
1398e07dc26bSmrg{
1399e07dc26bSmrg    $debug_cmd
1400e07dc26bSmrg
1401e07dc26bSmrg    _G_cmd=$1
1402e07dc26bSmrg    _G_fail_exp=${2-':'}
1403e07dc26bSmrg
1404e07dc26bSmrg    $opt_quiet || {
1405636c353eSmrg      func_quote_arg expand,pretty "$_G_cmd"
1406636c353eSmrg      eval "func_echo $func_quote_arg_result"
1407e07dc26bSmrg    }
1408e07dc26bSmrg
1409e07dc26bSmrg    $opt_dry_run || {
1410e07dc26bSmrg      eval "$_G_user_locale
1411e07dc26bSmrg	    $_G_cmd"
1412e07dc26bSmrg      _G_status=$?
1413e07dc26bSmrg      eval "$_G_safe_locale"
1414e07dc26bSmrg      if test 0 -ne "$_G_status"; then
1415e07dc26bSmrg	eval "(exit $_G_status); $_G_fail_exp"
1416e07dc26bSmrg      fi
1417e07dc26bSmrg    }
1418e07dc26bSmrg}
1419e07dc26bSmrg
1420e07dc26bSmrg
1421e07dc26bSmrg# func_tr_sh
1422e07dc26bSmrg# ----------
1423e07dc26bSmrg# Turn $1 into a string suitable for a shell variable name.
1424e07dc26bSmrg# Result is stored in $func_tr_sh_result.  All characters
1425e07dc26bSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1426e07dc26bSmrg# if $1 begins with a digit, a '_' is prepended as well.
1427e07dc26bSmrgfunc_tr_sh ()
1428e07dc26bSmrg{
1429e07dc26bSmrg    $debug_cmd
1430e07dc26bSmrg
1431e07dc26bSmrg    case $1 in
1432e07dc26bSmrg    [0-9]* | *[!a-zA-Z0-9_]*)
1433e07dc26bSmrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1434e07dc26bSmrg      ;;
1435e07dc26bSmrg    * )
1436e07dc26bSmrg      func_tr_sh_result=$1
1437e07dc26bSmrg      ;;
1438e07dc26bSmrg    esac
1439e07dc26bSmrg}
1440e07dc26bSmrg
1441e07dc26bSmrg
1442e07dc26bSmrg# func_verbose ARG...
1443e07dc26bSmrg# -------------------
1444e07dc26bSmrg# Echo program name prefixed message in verbose mode only.
1445e07dc26bSmrgfunc_verbose ()
1446e07dc26bSmrg{
1447e07dc26bSmrg    $debug_cmd
1448e07dc26bSmrg
1449e07dc26bSmrg    $opt_verbose && func_echo "$*"
1450e07dc26bSmrg
1451e07dc26bSmrg    :
1452e07dc26bSmrg}
1453e07dc26bSmrg
1454e07dc26bSmrg
1455e07dc26bSmrg# func_warn_and_continue ARG...
1456e07dc26bSmrg# -----------------------------
1457e07dc26bSmrg# Echo program name prefixed warning message to standard error.
1458e07dc26bSmrgfunc_warn_and_continue ()
1459e07dc26bSmrg{
1460e07dc26bSmrg    $debug_cmd
1461e07dc26bSmrg
1462e07dc26bSmrg    $require_term_colors
1463e07dc26bSmrg
1464e07dc26bSmrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1465e07dc26bSmrg}
1466e07dc26bSmrg
1467e07dc26bSmrg
1468e07dc26bSmrg# func_warning CATEGORY ARG...
1469e07dc26bSmrg# ----------------------------
1470e07dc26bSmrg# Echo program name prefixed warning message to standard error. Warning
1471e07dc26bSmrg# messages can be filtered according to CATEGORY, where this function
1472e07dc26bSmrg# elides messages where CATEGORY is not listed in the global variable
1473e07dc26bSmrg# 'opt_warning_types'.
1474e07dc26bSmrgfunc_warning ()
1475e07dc26bSmrg{
1476e07dc26bSmrg    $debug_cmd
1477e07dc26bSmrg
1478e07dc26bSmrg    # CATEGORY must be in the warning_categories list!
1479e07dc26bSmrg    case " $warning_categories " in
1480e07dc26bSmrg      *" $1 "*) ;;
1481e07dc26bSmrg      *) func_internal_error "invalid warning category '$1'" ;;
1482e07dc26bSmrg    esac
1483e07dc26bSmrg
1484e07dc26bSmrg    _G_category=$1
1485e07dc26bSmrg    shift
1486e07dc26bSmrg
1487e07dc26bSmrg    case " $opt_warning_types " in
1488e07dc26bSmrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
1489e07dc26bSmrg    esac
1490e07dc26bSmrg}
1491e07dc26bSmrg
1492e07dc26bSmrg
1493e07dc26bSmrg# func_sort_ver VER1 VER2
1494e07dc26bSmrg# -----------------------
1495e07dc26bSmrg# 'sort -V' is not generally available.
1496e07dc26bSmrg# Note this deviates from the version comparison in automake
1497e07dc26bSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1498e07dc26bSmrg# but this should suffice as we won't be specifying old
1499e07dc26bSmrg# version formats or redundant trailing .0 in bootstrap.conf.
1500e07dc26bSmrg# If we did want full compatibility then we should probably
1501e07dc26bSmrg# use m4_version_compare from autoconf.
1502e07dc26bSmrgfunc_sort_ver ()
1503e07dc26bSmrg{
1504e07dc26bSmrg    $debug_cmd
1505e07dc26bSmrg
1506e07dc26bSmrg    printf '%s\n%s\n' "$1" "$2" \
1507e07dc26bSmrg      | 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
1508e07dc26bSmrg}
1509e07dc26bSmrg
1510e07dc26bSmrg# func_lt_ver PREV CURR
1511e07dc26bSmrg# ---------------------
1512e07dc26bSmrg# Return true if PREV and CURR are in the correct order according to
1513e07dc26bSmrg# func_sort_ver, otherwise false.  Use it like this:
1514e07dc26bSmrg#
1515e07dc26bSmrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1516e07dc26bSmrgfunc_lt_ver ()
1517e07dc26bSmrg{
1518e07dc26bSmrg    $debug_cmd
1519e07dc26bSmrg
1520e07dc26bSmrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1521e07dc26bSmrg}
1522e07dc26bSmrg
1523e07dc26bSmrg
1524e07dc26bSmrg# Local variables:
1525e07dc26bSmrg# mode: shell-script
1526e07dc26bSmrg# sh-indentation: 2
1527e07dc26bSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1528e07dc26bSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1529e07dc26bSmrg# time-stamp-time-zone: "UTC"
1530e07dc26bSmrg# End:
1531e07dc26bSmrg#! /bin/sh
1532e07dc26bSmrg
1533e07dc26bSmrg# A portable, pluggable option parser for Bourne shell.
1534e07dc26bSmrg# Written by Gary V. Vaughan, 2010
1535e07dc26bSmrg
1536636c353eSmrg# This is free software.  There is NO warranty; not even for
1537636c353eSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1538636c353eSmrg#
1539636c353eSmrg# Copyright (C) 2010-2019, 2021 Bootstrap Authors
1540636c353eSmrg#
1541636c353eSmrg# This file is dual licensed under the terms of the MIT license
1542636c353eSmrg# <https://opensource.org/license/MIT>, and GPL version 2 or later
1543636c353eSmrg# <http://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
1544636c353eSmrg# these licenses when using or redistributing this software or any of
1545636c353eSmrg# the files within it.  See the URLs above, or the file `LICENSE`
1546636c353eSmrg# included in the Bootstrap distribution for the full license texts.
1547e07dc26bSmrg
1548636c353eSmrg# Please report bugs or propose patches to:
1549636c353eSmrg# <https://github.com/gnulib-modules/bootstrap/issues>
1550e07dc26bSmrg
1551636c353eSmrg# Set a version string for this script.
1552636c353eSmrgscriptversion=2019-02-19.15; # UTC
1553e07dc26bSmrg
1554e07dc26bSmrg
1555e07dc26bSmrg## ------ ##
1556e07dc26bSmrg## Usage. ##
1557e07dc26bSmrg## ------ ##
1558e07dc26bSmrg
1559e07dc26bSmrg# This file is a library for parsing options in your shell scripts along
1560e07dc26bSmrg# with assorted other useful supporting features that you can make use
1561e07dc26bSmrg# of too.
1562e07dc26bSmrg#
1563e07dc26bSmrg# For the simplest scripts you might need only:
1564e07dc26bSmrg#
1565e07dc26bSmrg#   #!/bin/sh
1566e07dc26bSmrg#   . relative/path/to/funclib.sh
1567e07dc26bSmrg#   . relative/path/to/options-parser
1568e07dc26bSmrg#   scriptversion=1.0
1569e07dc26bSmrg#   func_options ${1+"$@"}
1570e07dc26bSmrg#   eval set dummy "$func_options_result"; shift
1571e07dc26bSmrg#   ...rest of your script...
1572e07dc26bSmrg#
1573e07dc26bSmrg# In order for the '--version' option to work, you will need to have a
1574e07dc26bSmrg# suitably formatted comment like the one at the top of this file
1575636c353eSmrg# starting with '# Written by ' and ending with '# Copyright'.
1576e07dc26bSmrg#
1577e07dc26bSmrg# For '-h' and '--help' to work, you will also need a one line
1578e07dc26bSmrg# description of your script's purpose in a comment directly above the
1579e07dc26bSmrg# '# Written by ' line, like the one at the top of this file.
1580e07dc26bSmrg#
1581e07dc26bSmrg# The default options also support '--debug', which will turn on shell
1582e07dc26bSmrg# execution tracing (see the comment above debug_cmd below for another
1583e07dc26bSmrg# use), and '--verbose' and the func_verbose function to allow your script
1584e07dc26bSmrg# to display verbose messages only when your user has specified
1585e07dc26bSmrg# '--verbose'.
1586e07dc26bSmrg#
1587636c353eSmrg# After sourcing this file, you can plug in processing for additional
1588e07dc26bSmrg# options by amending the variables from the 'Configuration' section
1589e07dc26bSmrg# below, and following the instructions in the 'Option parsing'
1590e07dc26bSmrg# section further down.
1591e07dc26bSmrg
1592e07dc26bSmrg## -------------- ##
1593e07dc26bSmrg## Configuration. ##
1594e07dc26bSmrg## -------------- ##
1595e07dc26bSmrg
1596e07dc26bSmrg# You should override these variables in your script after sourcing this
1597e07dc26bSmrg# file so that they reflect the customisations you have added to the
1598e07dc26bSmrg# option parser.
1599e07dc26bSmrg
1600e07dc26bSmrg# The usage line for option parsing errors and the start of '-h' and
1601e07dc26bSmrg# '--help' output messages. You can embed shell variables for delayed
1602e07dc26bSmrg# expansion at the time the message is displayed, but you will need to
1603e07dc26bSmrg# quote other shell meta-characters carefully to prevent them being
1604e07dc26bSmrg# expanded when the contents are evaled.
1605e07dc26bSmrgusage='$progpath [OPTION]...'
1606e07dc26bSmrg
1607e07dc26bSmrg# Short help message in response to '-h' and '--help'.  Add to this or
1608e07dc26bSmrg# override it after sourcing this library to reflect the full set of
1609e07dc26bSmrg# options your script accepts.
1610e07dc26bSmrgusage_message="\
1611e07dc26bSmrg       --debug        enable verbose shell tracing
1612e07dc26bSmrg   -W, --warnings=CATEGORY
1613e07dc26bSmrg                      report the warnings falling in CATEGORY [all]
1614e07dc26bSmrg   -v, --verbose      verbosely report processing
1615e07dc26bSmrg       --version      print version information and exit
1616e07dc26bSmrg   -h, --help         print short or long help message and exit
1617e07dc26bSmrg"
1618e07dc26bSmrg
1619e07dc26bSmrg# Additional text appended to 'usage_message' in response to '--help'.
1620e07dc26bSmrglong_help_message="
1621e07dc26bSmrgWarning categories include:
1622e07dc26bSmrg       'all'          show all warnings
1623e07dc26bSmrg       'none'         turn off all the warnings
1624e07dc26bSmrg       'error'        warnings are treated as fatal errors"
1625e07dc26bSmrg
1626e07dc26bSmrg# Help message printed before fatal option parsing errors.
1627e07dc26bSmrgfatal_help="Try '\$progname --help' for more information."
1628e07dc26bSmrg
1629e07dc26bSmrg
1630e07dc26bSmrg
1631e07dc26bSmrg## ------------------------- ##
1632e07dc26bSmrg## Hook function management. ##
1633e07dc26bSmrg## ------------------------- ##
1634e07dc26bSmrg
1635e07dc26bSmrg# This section contains functions for adding, removing, and running hooks
1636636c353eSmrg# in the main code.  A hook is just a list of function names that can be
1637636c353eSmrg# run in order later on.
1638e07dc26bSmrg
1639e07dc26bSmrg# func_hookable FUNC_NAME
1640e07dc26bSmrg# -----------------------
1641e07dc26bSmrg# Declare that FUNC_NAME will run hooks added with
1642e07dc26bSmrg# 'func_add_hook FUNC_NAME ...'.
1643e07dc26bSmrgfunc_hookable ()
1644e07dc26bSmrg{
1645e07dc26bSmrg    $debug_cmd
1646e07dc26bSmrg
1647e07dc26bSmrg    func_append hookable_fns " $1"
1648e07dc26bSmrg}
1649e07dc26bSmrg
1650e07dc26bSmrg
1651e07dc26bSmrg# func_add_hook FUNC_NAME HOOK_FUNC
1652e07dc26bSmrg# ---------------------------------
1653e07dc26bSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
1654e07dc26bSmrg# first have been declared "hookable" by a call to 'func_hookable'.
1655e07dc26bSmrgfunc_add_hook ()
1656e07dc26bSmrg{
1657e07dc26bSmrg    $debug_cmd
1658e07dc26bSmrg
1659e07dc26bSmrg    case " $hookable_fns " in
1660e07dc26bSmrg      *" $1 "*) ;;
1661e07dc26bSmrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
1662e07dc26bSmrg    esac
1663e07dc26bSmrg
1664e07dc26bSmrg    eval func_append ${1}_hooks '" $2"'
1665e07dc26bSmrg}
1666e07dc26bSmrg
1667e07dc26bSmrg
1668e07dc26bSmrg# func_remove_hook FUNC_NAME HOOK_FUNC
1669e07dc26bSmrg# ------------------------------------
1670636c353eSmrg# Remove HOOK_FUNC from the list of hook functions to be called by
1671636c353eSmrg# FUNC_NAME.
1672e07dc26bSmrgfunc_remove_hook ()
1673e07dc26bSmrg{
1674e07dc26bSmrg    $debug_cmd
1675e07dc26bSmrg
1676e07dc26bSmrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1677e07dc26bSmrg}
1678e07dc26bSmrg
1679e07dc26bSmrg
1680636c353eSmrg# func_propagate_result FUNC_NAME_A FUNC_NAME_B
1681636c353eSmrg# ---------------------------------------------
1682636c353eSmrg# If the *_result variable of FUNC_NAME_A _is set_, assign its value to
1683636c353eSmrg# *_result variable of FUNC_NAME_B.
1684636c353eSmrgfunc_propagate_result ()
1685636c353eSmrg{
1686636c353eSmrg    $debug_cmd
1687636c353eSmrg
1688636c353eSmrg    func_propagate_result_result=:
1689636c353eSmrg    if eval "test \"\${${1}_result+set}\" = set"
1690636c353eSmrg    then
1691636c353eSmrg      eval "${2}_result=\$${1}_result"
1692636c353eSmrg    else
1693636c353eSmrg      func_propagate_result_result=false
1694636c353eSmrg    fi
1695636c353eSmrg}
1696636c353eSmrg
1697636c353eSmrg
1698e07dc26bSmrg# func_run_hooks FUNC_NAME [ARG]...
1699e07dc26bSmrg# ---------------------------------
1700e07dc26bSmrg# Run all hook functions registered to FUNC_NAME.
1701636c353eSmrg# It's assumed that the list of hook functions contains nothing more
1702e07dc26bSmrg# than a whitespace-delimited list of legal shell function names, and
1703e07dc26bSmrg# no effort is wasted trying to catch shell meta-characters or preserve
1704e07dc26bSmrg# whitespace.
1705e07dc26bSmrgfunc_run_hooks ()
1706e07dc26bSmrg{
1707e07dc26bSmrg    $debug_cmd
1708e07dc26bSmrg
1709e07dc26bSmrg    case " $hookable_fns " in
1710e07dc26bSmrg      *" $1 "*) ;;
1711636c353eSmrg      *) func_fatal_error "'$1' does not support hook functions." ;;
1712e07dc26bSmrg    esac
1713e07dc26bSmrg
1714e07dc26bSmrg    eval _G_hook_fns=\$$1_hooks; shift
1715e07dc26bSmrg
1716e07dc26bSmrg    for _G_hook in $_G_hook_fns; do
1717636c353eSmrg      func_unset "${_G_hook}_result"
1718636c353eSmrg      eval $_G_hook '${1+"$@"}'
1719636c353eSmrg      func_propagate_result $_G_hook func_run_hooks
1720636c353eSmrg      if $func_propagate_result_result; then
1721636c353eSmrg        eval set dummy "$func_run_hooks_result"; shift
1722636c353eSmrg      fi
1723e07dc26bSmrg    done
1724e07dc26bSmrg}
1725e07dc26bSmrg
1726e07dc26bSmrg
1727e07dc26bSmrg
1728e07dc26bSmrg## --------------- ##
1729e07dc26bSmrg## Option parsing. ##
1730e07dc26bSmrg## --------------- ##
1731e07dc26bSmrg
1732e07dc26bSmrg# In order to add your own option parsing hooks, you must accept the
1733636c353eSmrg# full positional parameter list from your hook function.  You may remove
1734636c353eSmrg# or edit any options that you action, and then pass back the remaining
1735636c353eSmrg# unprocessed options in '<hooked_function_name>_result', escaped
1736636c353eSmrg# suitably for 'eval'.
1737636c353eSmrg#
1738636c353eSmrg# The '<hooked_function_name>_result' variable is automatically unset
1739636c353eSmrg# before your hook gets called; for best performance, only set the
1740636c353eSmrg# *_result variable when necessary (i.e. don't call the 'func_quote'
1741636c353eSmrg# function unnecessarily because it can be an expensive operation on some
1742636c353eSmrg# machines).
1743636c353eSmrg#
1744636c353eSmrg# Like this:
1745e07dc26bSmrg#
1746e07dc26bSmrg#    my_options_prep ()
1747e07dc26bSmrg#    {
1748e07dc26bSmrg#        $debug_cmd
1749e07dc26bSmrg#
1750e07dc26bSmrg#        # Extend the existing usage message.
1751e07dc26bSmrg#        usage_message=$usage_message'
1752e07dc26bSmrg#      -s, --silent       don'\''t print informational messages
1753e07dc26bSmrg#    '
1754636c353eSmrg#        # No change in '$@' (ignored completely by this hook).  Leave
1755636c353eSmrg#        # my_options_prep_result variable intact.
1756e07dc26bSmrg#    }
1757e07dc26bSmrg#    func_add_hook func_options_prep my_options_prep
1758e07dc26bSmrg#
1759e07dc26bSmrg#
1760e07dc26bSmrg#    my_silent_option ()
1761e07dc26bSmrg#    {
1762e07dc26bSmrg#        $debug_cmd
1763e07dc26bSmrg#
1764636c353eSmrg#        args_changed=false
1765636c353eSmrg#
1766636c353eSmrg#        # Note that, for efficiency, we parse as many options as we can
1767e07dc26bSmrg#        # recognise in a loop before passing the remainder back to the
1768e07dc26bSmrg#        # caller on the first unrecognised argument we encounter.
1769e07dc26bSmrg#        while test $# -gt 0; do
1770e07dc26bSmrg#          opt=$1; shift
1771e07dc26bSmrg#          case $opt in
1772636c353eSmrg#            --silent|-s) opt_silent=:
1773636c353eSmrg#                         args_changed=:
1774636c353eSmrg#                         ;;
1775e07dc26bSmrg#            # Separate non-argument short options:
1776e07dc26bSmrg#            -s*)         func_split_short_opt "$_G_opt"
1777e07dc26bSmrg#                         set dummy "$func_split_short_opt_name" \
1778e07dc26bSmrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
1779e07dc26bSmrg#                         shift
1780636c353eSmrg#                         args_changed=:
1781e07dc26bSmrg#                         ;;
1782636c353eSmrg#            *)           # Make sure the first unrecognised option "$_G_opt"
1783636c353eSmrg#                         # is added back to "$@" in case we need it later,
1784636c353eSmrg#                         # if $args_changed was set to 'true'.
1785636c353eSmrg#                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1786e07dc26bSmrg#          esac
1787e07dc26bSmrg#        done
1788e07dc26bSmrg#
1789636c353eSmrg#        # Only call 'func_quote' here if we processed at least one argument.
1790636c353eSmrg#        if $args_changed; then
1791636c353eSmrg#          func_quote eval ${1+"$@"}
1792636c353eSmrg#          my_silent_option_result=$func_quote_result
1793636c353eSmrg#        fi
1794e07dc26bSmrg#    }
1795e07dc26bSmrg#    func_add_hook func_parse_options my_silent_option
1796e07dc26bSmrg#
1797e07dc26bSmrg#
1798e07dc26bSmrg#    my_option_validation ()
1799e07dc26bSmrg#    {
1800e07dc26bSmrg#        $debug_cmd
1801e07dc26bSmrg#
1802e07dc26bSmrg#        $opt_silent && $opt_verbose && func_fatal_help "\
1803e07dc26bSmrg#    '--silent' and '--verbose' options are mutually exclusive."
1804e07dc26bSmrg#    }
1805e07dc26bSmrg#    func_add_hook func_validate_options my_option_validation
1806e07dc26bSmrg#
1807636c353eSmrg# You'll also need to manually amend $usage_message to reflect the extra
1808e07dc26bSmrg# options you parse.  It's preferable to append if you can, so that
1809e07dc26bSmrg# multiple option parsing hooks can be added safely.
1810e07dc26bSmrg
1811e07dc26bSmrg
1812636c353eSmrg# func_options_finish [ARG]...
1813636c353eSmrg# ----------------------------
1814636c353eSmrg# Finishing the option parse loop (call 'func_options' hooks ATM).
1815636c353eSmrgfunc_options_finish ()
1816636c353eSmrg{
1817636c353eSmrg    $debug_cmd
1818636c353eSmrg
1819636c353eSmrg    func_run_hooks func_options ${1+"$@"}
1820636c353eSmrg    func_propagate_result func_run_hooks func_options_finish
1821636c353eSmrg}
1822636c353eSmrg
1823636c353eSmrg
1824e07dc26bSmrg# func_options [ARG]...
1825e07dc26bSmrg# ---------------------
1826e07dc26bSmrg# All the functions called inside func_options are hookable. See the
1827e07dc26bSmrg# individual implementations for details.
1828e07dc26bSmrgfunc_hookable func_options
1829e07dc26bSmrgfunc_options ()
1830e07dc26bSmrg{
1831e07dc26bSmrg    $debug_cmd
1832e07dc26bSmrg
1833636c353eSmrg    _G_options_quoted=false
1834e07dc26bSmrg
1835636c353eSmrg    for my_func in options_prep parse_options validate_options options_finish
1836636c353eSmrg    do
1837636c353eSmrg      func_unset func_${my_func}_result
1838636c353eSmrg      func_unset func_run_hooks_result
1839636c353eSmrg      eval func_$my_func '${1+"$@"}'
1840636c353eSmrg      func_propagate_result func_$my_func func_options
1841636c353eSmrg      if $func_propagate_result_result; then
1842636c353eSmrg        eval set dummy "$func_options_result"; shift
1843636c353eSmrg        _G_options_quoted=:
1844636c353eSmrg      fi
1845636c353eSmrg    done
1846e07dc26bSmrg
1847636c353eSmrg    $_G_options_quoted || {
1848636c353eSmrg      # As we (func_options) are top-level options-parser function and
1849636c353eSmrg      # nobody quoted "$@" for us yet, we need to do it explicitly for
1850636c353eSmrg      # caller.
1851636c353eSmrg      func_quote eval ${1+"$@"}
1852636c353eSmrg      func_options_result=$func_quote_result
1853636c353eSmrg    }
1854e07dc26bSmrg}
1855e07dc26bSmrg
1856e07dc26bSmrg
1857e07dc26bSmrg# func_options_prep [ARG]...
1858e07dc26bSmrg# --------------------------
1859e07dc26bSmrg# All initialisations required before starting the option parse loop.
1860e07dc26bSmrg# Note that when calling hook functions, we pass through the list of
1861e07dc26bSmrg# positional parameters.  If a hook function modifies that list, and
1862636c353eSmrg# needs to propagate that back to rest of this script, then the complete
1863636c353eSmrg# modified list must be put in 'func_run_hooks_result' before returning.
1864e07dc26bSmrgfunc_hookable func_options_prep
1865e07dc26bSmrgfunc_options_prep ()
1866e07dc26bSmrg{
1867e07dc26bSmrg    $debug_cmd
1868e07dc26bSmrg
1869e07dc26bSmrg    # Option defaults:
1870e07dc26bSmrg    opt_verbose=false
1871e07dc26bSmrg    opt_warning_types=
1872e07dc26bSmrg
1873e07dc26bSmrg    func_run_hooks func_options_prep ${1+"$@"}
1874636c353eSmrg    func_propagate_result func_run_hooks func_options_prep
1875e07dc26bSmrg}
1876e07dc26bSmrg
1877e07dc26bSmrg
1878e07dc26bSmrg# func_parse_options [ARG]...
1879e07dc26bSmrg# ---------------------------
1880e07dc26bSmrg# The main option parsing loop.
1881e07dc26bSmrgfunc_hookable func_parse_options
1882e07dc26bSmrgfunc_parse_options ()
1883e07dc26bSmrg{
1884e07dc26bSmrg    $debug_cmd
1885e07dc26bSmrg
1886636c353eSmrg    _G_parse_options_requote=false
1887e07dc26bSmrg    # this just eases exit handling
1888e07dc26bSmrg    while test $# -gt 0; do
1889e07dc26bSmrg      # Defer to hook functions for initial option parsing, so they
1890e07dc26bSmrg      # get priority in the event of reusing an option name.
1891e07dc26bSmrg      func_run_hooks func_parse_options ${1+"$@"}
1892636c353eSmrg      func_propagate_result func_run_hooks func_parse_options
1893636c353eSmrg      if $func_propagate_result_result; then
1894636c353eSmrg        eval set dummy "$func_parse_options_result"; shift
1895636c353eSmrg        # Even though we may have changed "$@", we passed the "$@" array
1896636c353eSmrg        # down into the hook and it quoted it for us (because we are in
1897636c353eSmrg        # this if-branch).  No need to quote it again.
1898636c353eSmrg        _G_parse_options_requote=false
1899636c353eSmrg      fi
1900e07dc26bSmrg
1901e07dc26bSmrg      # Break out of the loop if we already parsed every option.
1902e07dc26bSmrg      test $# -gt 0 || break
1903e07dc26bSmrg
1904636c353eSmrg      # We expect that one of the options parsed in this function matches
1905636c353eSmrg      # and thus we remove _G_opt from "$@" and need to re-quote.
1906636c353eSmrg      _G_match_parse_options=:
1907e07dc26bSmrg      _G_opt=$1
1908e07dc26bSmrg      shift
1909e07dc26bSmrg      case $_G_opt in
1910e07dc26bSmrg        --debug|-x)   debug_cmd='set -x'
1911636c353eSmrg                      func_echo "enabling shell trace mode" >&2
1912e07dc26bSmrg                      $debug_cmd
1913e07dc26bSmrg                      ;;
1914e07dc26bSmrg
1915e07dc26bSmrg        --no-warnings|--no-warning|--no-warn)
1916e07dc26bSmrg                      set dummy --warnings none ${1+"$@"}
1917e07dc26bSmrg                      shift
1918e07dc26bSmrg		      ;;
1919e07dc26bSmrg
1920e07dc26bSmrg        --warnings|--warning|-W)
1921636c353eSmrg                      if test $# = 0 && func_missing_arg $_G_opt; then
1922636c353eSmrg                        _G_parse_options_requote=:
1923636c353eSmrg                        break
1924636c353eSmrg                      fi
1925e07dc26bSmrg                      case " $warning_categories $1" in
1926e07dc26bSmrg                        *" $1 "*)
1927e07dc26bSmrg                          # trailing space prevents matching last $1 above
1928e07dc26bSmrg                          func_append_uniq opt_warning_types " $1"
1929e07dc26bSmrg                          ;;
1930e07dc26bSmrg                        *all)
1931e07dc26bSmrg                          opt_warning_types=$warning_categories
1932e07dc26bSmrg                          ;;
1933e07dc26bSmrg                        *none)
1934e07dc26bSmrg                          opt_warning_types=none
1935e07dc26bSmrg                          warning_func=:
1936e07dc26bSmrg                          ;;
1937e07dc26bSmrg                        *error)
1938e07dc26bSmrg                          opt_warning_types=$warning_categories
1939e07dc26bSmrg                          warning_func=func_fatal_error
1940e07dc26bSmrg                          ;;
1941e07dc26bSmrg                        *)
1942e07dc26bSmrg                          func_fatal_error \
1943e07dc26bSmrg                             "unsupported warning category: '$1'"
1944e07dc26bSmrg                          ;;
1945e07dc26bSmrg                      esac
1946e07dc26bSmrg                      shift
1947e07dc26bSmrg                      ;;
1948e07dc26bSmrg
1949e07dc26bSmrg        --verbose|-v) opt_verbose=: ;;
1950e07dc26bSmrg        --version)    func_version ;;
1951e07dc26bSmrg        -\?|-h)       func_usage ;;
1952e07dc26bSmrg        --help)       func_help ;;
1953e07dc26bSmrg
1954e07dc26bSmrg	# Separate optargs to long options (plugins may need this):
1955e07dc26bSmrg	--*=*)        func_split_equals "$_G_opt"
1956e07dc26bSmrg	              set dummy "$func_split_equals_lhs" \
1957e07dc26bSmrg                          "$func_split_equals_rhs" ${1+"$@"}
1958e07dc26bSmrg                      shift
1959e07dc26bSmrg                      ;;
1960e07dc26bSmrg
1961e07dc26bSmrg       # Separate optargs to short options:
1962e07dc26bSmrg        -W*)
1963e07dc26bSmrg                      func_split_short_opt "$_G_opt"
1964e07dc26bSmrg                      set dummy "$func_split_short_opt_name" \
1965e07dc26bSmrg                          "$func_split_short_opt_arg" ${1+"$@"}
1966e07dc26bSmrg                      shift
1967e07dc26bSmrg                      ;;
1968e07dc26bSmrg
1969e07dc26bSmrg        # Separate non-argument short options:
1970e07dc26bSmrg        -\?*|-h*|-v*|-x*)
1971e07dc26bSmrg                      func_split_short_opt "$_G_opt"
1972e07dc26bSmrg                      set dummy "$func_split_short_opt_name" \
1973e07dc26bSmrg                          "-$func_split_short_opt_arg" ${1+"$@"}
1974e07dc26bSmrg                      shift
1975e07dc26bSmrg                      ;;
1976e07dc26bSmrg
1977636c353eSmrg        --)           _G_parse_options_requote=: ; break ;;
1978e07dc26bSmrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
1979636c353eSmrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift
1980636c353eSmrg                      _G_match_parse_options=false
1981636c353eSmrg                      break
1982636c353eSmrg                      ;;
1983e07dc26bSmrg      esac
1984636c353eSmrg
1985636c353eSmrg      if $_G_match_parse_options; then
1986636c353eSmrg        _G_parse_options_requote=:
1987636c353eSmrg      fi
1988e07dc26bSmrg    done
1989e07dc26bSmrg
1990636c353eSmrg    if $_G_parse_options_requote; then
1991636c353eSmrg      # save modified positional parameters for caller
1992636c353eSmrg      func_quote eval ${1+"$@"}
1993636c353eSmrg      func_parse_options_result=$func_quote_result
1994636c353eSmrg    fi
1995e07dc26bSmrg}
1996e07dc26bSmrg
1997e07dc26bSmrg
1998e07dc26bSmrg# func_validate_options [ARG]...
1999e07dc26bSmrg# ------------------------------
2000e07dc26bSmrg# Perform any sanity checks on option settings and/or unconsumed
2001e07dc26bSmrg# arguments.
2002e07dc26bSmrgfunc_hookable func_validate_options
2003e07dc26bSmrgfunc_validate_options ()
2004e07dc26bSmrg{
2005e07dc26bSmrg    $debug_cmd
2006e07dc26bSmrg
2007e07dc26bSmrg    # Display all warnings if -W was not given.
2008e07dc26bSmrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
2009e07dc26bSmrg
2010e07dc26bSmrg    func_run_hooks func_validate_options ${1+"$@"}
2011636c353eSmrg    func_propagate_result func_run_hooks func_validate_options
2012e07dc26bSmrg
2013e07dc26bSmrg    # Bail if the options were screwed!
2014e07dc26bSmrg    $exit_cmd $EXIT_FAILURE
2015e07dc26bSmrg}
2016e07dc26bSmrg
2017e07dc26bSmrg
2018e07dc26bSmrg
2019e07dc26bSmrg## ----------------- ##
2020e07dc26bSmrg## Helper functions. ##
2021e07dc26bSmrg## ----------------- ##
2022e07dc26bSmrg
2023e07dc26bSmrg# This section contains the helper functions used by the rest of the
2024e07dc26bSmrg# hookable option parser framework in ascii-betical order.
2025e07dc26bSmrg
2026e07dc26bSmrg
2027e07dc26bSmrg# func_fatal_help ARG...
2028e07dc26bSmrg# ----------------------
2029e07dc26bSmrg# Echo program name prefixed message to standard error, followed by
2030e07dc26bSmrg# a help hint, and exit.
2031e07dc26bSmrgfunc_fatal_help ()
2032e07dc26bSmrg{
2033e07dc26bSmrg    $debug_cmd
2034e07dc26bSmrg
2035e07dc26bSmrg    eval \$ECHO \""Usage: $usage"\"
2036e07dc26bSmrg    eval \$ECHO \""$fatal_help"\"
2037e07dc26bSmrg    func_error ${1+"$@"}
2038e07dc26bSmrg    exit $EXIT_FAILURE
2039e07dc26bSmrg}
2040e07dc26bSmrg
2041e07dc26bSmrg
2042e07dc26bSmrg# func_help
2043e07dc26bSmrg# ---------
2044e07dc26bSmrg# Echo long help message to standard output and exit.
2045e07dc26bSmrgfunc_help ()
2046e07dc26bSmrg{
2047e07dc26bSmrg    $debug_cmd
2048e07dc26bSmrg
2049e07dc26bSmrg    func_usage_message
2050e07dc26bSmrg    $ECHO "$long_help_message"
2051e07dc26bSmrg    exit 0
2052e07dc26bSmrg}
2053e07dc26bSmrg
2054e07dc26bSmrg
2055e07dc26bSmrg# func_missing_arg ARGNAME
2056e07dc26bSmrg# ------------------------
2057e07dc26bSmrg# Echo program name prefixed message to standard error and set global
2058e07dc26bSmrg# exit_cmd.
2059e07dc26bSmrgfunc_missing_arg ()
2060e07dc26bSmrg{
2061e07dc26bSmrg    $debug_cmd
2062e07dc26bSmrg
2063e07dc26bSmrg    func_error "Missing argument for '$1'."
2064e07dc26bSmrg    exit_cmd=exit
2065e07dc26bSmrg}
2066e07dc26bSmrg
2067e07dc26bSmrg
2068e07dc26bSmrg# func_split_equals STRING
2069e07dc26bSmrg# ------------------------
2070636c353eSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables
2071636c353eSmrg# after splitting STRING at the '=' sign.
2072e07dc26bSmrgtest -z "$_G_HAVE_XSI_OPS" \
2073e07dc26bSmrg    && (eval 'x=a/b/c;
2074e07dc26bSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
2075e07dc26bSmrg    && _G_HAVE_XSI_OPS=yes
2076e07dc26bSmrg
2077e07dc26bSmrgif test yes = "$_G_HAVE_XSI_OPS"
2078e07dc26bSmrgthen
2079e07dc26bSmrg  # This is an XSI compatible shell, allowing a faster implementation...
2080e07dc26bSmrg  eval 'func_split_equals ()
2081e07dc26bSmrg  {
2082e07dc26bSmrg      $debug_cmd
2083e07dc26bSmrg
2084e07dc26bSmrg      func_split_equals_lhs=${1%%=*}
2085e07dc26bSmrg      func_split_equals_rhs=${1#*=}
2086636c353eSmrg      if test "x$func_split_equals_lhs" = "x$1"; then
2087636c353eSmrg        func_split_equals_rhs=
2088636c353eSmrg      fi
2089e07dc26bSmrg  }'
2090e07dc26bSmrgelse
2091e07dc26bSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
2092e07dc26bSmrg  func_split_equals ()
2093e07dc26bSmrg  {
2094e07dc26bSmrg      $debug_cmd
2095e07dc26bSmrg
2096e07dc26bSmrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
2097e07dc26bSmrg      func_split_equals_rhs=
2098636c353eSmrg      test "x$func_split_equals_lhs=" = "x$1" \
2099e07dc26bSmrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
2100e07dc26bSmrg  }
2101e07dc26bSmrgfi #func_split_equals
2102e07dc26bSmrg
2103e07dc26bSmrg
2104e07dc26bSmrg# func_split_short_opt SHORTOPT
2105e07dc26bSmrg# -----------------------------
2106e07dc26bSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
2107e07dc26bSmrg# variables after splitting SHORTOPT after the 2nd character.
2108e07dc26bSmrgif test yes = "$_G_HAVE_XSI_OPS"
2109e07dc26bSmrgthen
2110e07dc26bSmrg  # This is an XSI compatible shell, allowing a faster implementation...
2111e07dc26bSmrg  eval 'func_split_short_opt ()
2112e07dc26bSmrg  {
2113e07dc26bSmrg      $debug_cmd
2114e07dc26bSmrg
2115e07dc26bSmrg      func_split_short_opt_arg=${1#??}
2116e07dc26bSmrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
2117e07dc26bSmrg  }'
2118e07dc26bSmrgelse
2119e07dc26bSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
2120e07dc26bSmrg  func_split_short_opt ()
2121e07dc26bSmrg  {
2122e07dc26bSmrg      $debug_cmd
2123e07dc26bSmrg
2124636c353eSmrg      func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'`
2125e07dc26bSmrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
2126e07dc26bSmrg  }
2127e07dc26bSmrgfi #func_split_short_opt
2128e07dc26bSmrg
2129e07dc26bSmrg
2130e07dc26bSmrg# func_usage
2131e07dc26bSmrg# ----------
2132e07dc26bSmrg# Echo short help message to standard output and exit.
2133e07dc26bSmrgfunc_usage ()
2134e07dc26bSmrg{
2135e07dc26bSmrg    $debug_cmd
2136e07dc26bSmrg
2137e07dc26bSmrg    func_usage_message
2138e07dc26bSmrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
2139e07dc26bSmrg    exit 0
2140e07dc26bSmrg}
2141e07dc26bSmrg
2142e07dc26bSmrg
2143e07dc26bSmrg# func_usage_message
2144e07dc26bSmrg# ------------------
2145e07dc26bSmrg# Echo short help message to standard output.
2146e07dc26bSmrgfunc_usage_message ()
2147e07dc26bSmrg{
2148e07dc26bSmrg    $debug_cmd
2149e07dc26bSmrg
2150e07dc26bSmrg    eval \$ECHO \""Usage: $usage"\"
2151e07dc26bSmrg    echo
2152e07dc26bSmrg    $SED -n 's|^# ||
2153e07dc26bSmrg        /^Written by/{
2154e07dc26bSmrg          x;p;x
2155e07dc26bSmrg        }
2156e07dc26bSmrg	h
2157e07dc26bSmrg	/^Written by/q' < "$progpath"
2158e07dc26bSmrg    echo
2159e07dc26bSmrg    eval \$ECHO \""$usage_message"\"
2160e07dc26bSmrg}
2161e07dc26bSmrg
2162e07dc26bSmrg
2163e07dc26bSmrg# func_version
2164e07dc26bSmrg# ------------
2165e07dc26bSmrg# Echo version message to standard output and exit.
2166636c353eSmrg# The version message is extracted from the calling file's header
2167636c353eSmrg# comments, with leading '# ' stripped:
2168636c353eSmrg#   1. First display the progname and version
2169636c353eSmrg#   2. Followed by the header comment line matching  /^# Written by /
2170636c353eSmrg#   3. Then a blank line followed by the first following line matching
2171636c353eSmrg#      /^# Copyright /
2172636c353eSmrg#   4. Immediately followed by any lines between the previous matches,
2173636c353eSmrg#      except lines preceding the intervening completely blank line.
2174636c353eSmrg# For example, see the header comments of this file.
2175e07dc26bSmrgfunc_version ()
2176e07dc26bSmrg{
2177e07dc26bSmrg    $debug_cmd
2178e07dc26bSmrg
2179e07dc26bSmrg    printf '%s\n' "$progname $scriptversion"
2180e07dc26bSmrg    $SED -n '
2181636c353eSmrg        /^# Written by /!b
2182636c353eSmrg        s|^# ||; p; n
2183636c353eSmrg
2184636c353eSmrg        :fwd2blnk
2185636c353eSmrg        /./ {
2186636c353eSmrg          n
2187636c353eSmrg          b fwd2blnk
2188e07dc26bSmrg        }
2189636c353eSmrg        p; n
2190636c353eSmrg
2191636c353eSmrg        :holdwrnt
2192636c353eSmrg        s|^# ||
2193636c353eSmrg        s|^# *$||
2194636c353eSmrg        /^Copyright /!{
2195636c353eSmrg          /./H
2196636c353eSmrg          n
2197636c353eSmrg          b holdwrnt
2198e07dc26bSmrg        }
2199636c353eSmrg
2200636c353eSmrg        s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
2201636c353eSmrg        G
2202636c353eSmrg        s|\(\n\)\n*|\1|g
2203636c353eSmrg        p; q' < "$progpath"
2204e07dc26bSmrg
2205e07dc26bSmrg    exit $?
2206e07dc26bSmrg}
2207e07dc26bSmrg
2208e07dc26bSmrg
2209e07dc26bSmrg# Local variables:
2210e07dc26bSmrg# mode: shell-script
2211e07dc26bSmrg# sh-indentation: 2
2212e07dc26bSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
2213636c353eSmrg# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"
2214e07dc26bSmrg# time-stamp-time-zone: "UTC"
2215e07dc26bSmrg# End:
2216e07dc26bSmrg
2217e07dc26bSmrg# Set a version string.
2218636c353eSmrgscriptversion='(GNU libtool) 2.4.7'
2219e07dc26bSmrg
2220e07dc26bSmrg
2221e07dc26bSmrg# func_echo ARG...
2222e07dc26bSmrg# ----------------
2223e07dc26bSmrg# Libtool also displays the current mode in messages, so override
2224e07dc26bSmrg# funclib.sh func_echo with this custom definition.
2225e07dc26bSmrgfunc_echo ()
2226e07dc26bSmrg{
2227e07dc26bSmrg    $debug_cmd
2228e07dc26bSmrg
2229e07dc26bSmrg    _G_message=$*
2230e07dc26bSmrg
2231e07dc26bSmrg    func_echo_IFS=$IFS
2232e07dc26bSmrg    IFS=$nl
2233e07dc26bSmrg    for _G_line in $_G_message; do
2234e07dc26bSmrg      IFS=$func_echo_IFS
2235e07dc26bSmrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
2236e07dc26bSmrg    done
2237e07dc26bSmrg    IFS=$func_echo_IFS
2238e07dc26bSmrg}
2239e07dc26bSmrg
2240e07dc26bSmrg
2241e07dc26bSmrg# func_warning ARG...
2242e07dc26bSmrg# -------------------
2243e07dc26bSmrg# Libtool warnings are not categorized, so override funclib.sh
2244e07dc26bSmrg# func_warning with this simpler definition.
2245e07dc26bSmrgfunc_warning ()
2246e07dc26bSmrg{
2247e07dc26bSmrg    $debug_cmd
2248e07dc26bSmrg
2249e07dc26bSmrg    $warning_func ${1+"$@"}
2250e07dc26bSmrg}
2251e07dc26bSmrg
2252e07dc26bSmrg
2253e07dc26bSmrg## ---------------- ##
2254e07dc26bSmrg## Options parsing. ##
2255e07dc26bSmrg## ---------------- ##
2256e07dc26bSmrg
2257e07dc26bSmrg# Hook in the functions to make sure our own options are parsed during
2258e07dc26bSmrg# the option parsing loop.
2259e07dc26bSmrg
2260e07dc26bSmrgusage='$progpath [OPTION]... [MODE-ARG]...'
2261e07dc26bSmrg
2262e07dc26bSmrg# Short help message in response to '-h'.
2263e07dc26bSmrgusage_message="Options:
2264e07dc26bSmrg       --config             show all configuration variables
2265e07dc26bSmrg       --debug              enable verbose shell tracing
2266e07dc26bSmrg   -n, --dry-run            display commands without modifying any files
2267e07dc26bSmrg       --features           display basic configuration information and exit
2268e07dc26bSmrg       --mode=MODE          use operation mode MODE
2269e07dc26bSmrg       --no-warnings        equivalent to '-Wnone'
2270e07dc26bSmrg       --preserve-dup-deps  don't remove duplicate dependency libraries
2271e07dc26bSmrg       --quiet, --silent    don't print informational messages
2272e07dc26bSmrg       --tag=TAG            use configuration variables from tag TAG
2273e07dc26bSmrg   -v, --verbose            print more informational messages than default
2274e07dc26bSmrg       --version            print version information
2275e07dc26bSmrg   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
2276e07dc26bSmrg   -h, --help, --help-all   print short, long, or detailed help message
2277e07dc26bSmrg"
2278e07dc26bSmrg
2279e07dc26bSmrg# Additional text appended to 'usage_message' in response to '--help'.
2280e07dc26bSmrgfunc_help ()
2281e07dc26bSmrg{
2282e07dc26bSmrg    $debug_cmd
2283e07dc26bSmrg
2284e07dc26bSmrg    func_usage_message
2285e07dc26bSmrg    $ECHO "$long_help_message
2286e07dc26bSmrg
2287e07dc26bSmrgMODE must be one of the following:
2288e07dc26bSmrg
2289e07dc26bSmrg       clean           remove files from the build directory
2290e07dc26bSmrg       compile         compile a source file into a libtool object
2291e07dc26bSmrg       execute         automatically set library path, then run a program
2292e07dc26bSmrg       finish          complete the installation of libtool libraries
2293e07dc26bSmrg       install         install libraries or executables
2294e07dc26bSmrg       link            create a library or an executable
2295e07dc26bSmrg       uninstall       remove libraries from an installed directory
2296e07dc26bSmrg
2297e07dc26bSmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
2298e07dc26bSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2299e07dc26bSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
2300e07dc26bSmrg
2301e07dc26bSmrgWhen reporting a bug, please describe a test case to reproduce it and
2302e07dc26bSmrginclude the following information:
2303e07dc26bSmrg
2304e07dc26bSmrg       host-triplet:   $host
2305e07dc26bSmrg       shell:          $SHELL
2306e07dc26bSmrg       compiler:       $LTCC
2307e07dc26bSmrg       compiler flags: $LTCFLAGS
2308e07dc26bSmrg       linker:         $LD (gnu? $with_gnu_ld)
2309636c353eSmrg       version:        $progname (GNU libtool) 2.4.7
2310e07dc26bSmrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2311e07dc26bSmrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2312e07dc26bSmrg
2313e07dc26bSmrgReport bugs to <bug-libtool@gnu.org>.
2314636c353eSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>.
2315e07dc26bSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
2316e07dc26bSmrg    exit 0
2317e07dc26bSmrg}
2318e07dc26bSmrg
2319e07dc26bSmrg
2320e07dc26bSmrg# func_lo2o OBJECT-NAME
2321e07dc26bSmrg# ---------------------
2322e07dc26bSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2323e07dc26bSmrg# object suffix.
2324e07dc26bSmrg
2325e07dc26bSmrglo2o=s/\\.lo\$/.$objext/
2326e07dc26bSmrgo2lo=s/\\.$objext\$/.lo/
2327e07dc26bSmrg
2328e07dc26bSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
2329e07dc26bSmrg  eval 'func_lo2o ()
2330e07dc26bSmrg  {
2331e07dc26bSmrg    case $1 in
2332e07dc26bSmrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
2333e07dc26bSmrg      *   ) func_lo2o_result=$1               ;;
2334e07dc26bSmrg    esac
2335e07dc26bSmrg  }'
2336e07dc26bSmrg
2337e07dc26bSmrg  # func_xform LIBOBJ-OR-SOURCE
2338e07dc26bSmrg  # ---------------------------
2339e07dc26bSmrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2340e07dc26bSmrg  # suffix to a '.lo' libtool-object suffix.
2341e07dc26bSmrg  eval 'func_xform ()
2342e07dc26bSmrg  {
2343e07dc26bSmrg    func_xform_result=${1%.*}.lo
2344e07dc26bSmrg  }'
2345e07dc26bSmrgelse
2346e07dc26bSmrg  # ...otherwise fall back to using sed.
2347e07dc26bSmrg  func_lo2o ()
2348e07dc26bSmrg  {
2349e07dc26bSmrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2350e07dc26bSmrg  }
2351e07dc26bSmrg
2352e07dc26bSmrg  func_xform ()
2353e07dc26bSmrg  {
2354e07dc26bSmrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2355e07dc26bSmrg  }
2356e07dc26bSmrgfi
2357e07dc26bSmrg
2358e07dc26bSmrg
2359e07dc26bSmrg# func_fatal_configuration ARG...
2360e07dc26bSmrg# -------------------------------
2361e07dc26bSmrg# Echo program name prefixed message to standard error, followed by
2362e07dc26bSmrg# a configuration failure hint, and exit.
2363e07dc26bSmrgfunc_fatal_configuration ()
2364e07dc26bSmrg{
2365636c353eSmrg    func_fatal_error ${1+"$@"} \
2366e07dc26bSmrg      "See the $PACKAGE documentation for more information." \
2367e07dc26bSmrg      "Fatal configuration error."
2368e07dc26bSmrg}
2369e07dc26bSmrg
2370e07dc26bSmrg
2371e07dc26bSmrg# func_config
2372e07dc26bSmrg# -----------
2373e07dc26bSmrg# Display the configuration for all the tags in this script.
2374e07dc26bSmrgfunc_config ()
2375e07dc26bSmrg{
2376e07dc26bSmrg    re_begincf='^# ### BEGIN LIBTOOL'
2377e07dc26bSmrg    re_endcf='^# ### END LIBTOOL'
2378e07dc26bSmrg
2379e07dc26bSmrg    # Default configuration.
2380e07dc26bSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
2381e07dc26bSmrg
2382e07dc26bSmrg    # Now print the configurations for the tags.
2383e07dc26bSmrg    for tagname in $taglist; do
2384e07dc26bSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2385e07dc26bSmrg    done
2386e07dc26bSmrg
2387e07dc26bSmrg    exit $?
2388e07dc26bSmrg}
2389e07dc26bSmrg
2390e07dc26bSmrg
2391e07dc26bSmrg# func_features
2392e07dc26bSmrg# -------------
2393e07dc26bSmrg# Display the features supported by this script.
2394e07dc26bSmrgfunc_features ()
2395e07dc26bSmrg{
2396e07dc26bSmrg    echo "host: $host"
2397e07dc26bSmrg    if test yes = "$build_libtool_libs"; then
2398e07dc26bSmrg      echo "enable shared libraries"
2399e07dc26bSmrg    else
2400e07dc26bSmrg      echo "disable shared libraries"
2401e07dc26bSmrg    fi
2402e07dc26bSmrg    if test yes = "$build_old_libs"; then
2403e07dc26bSmrg      echo "enable static libraries"
2404e07dc26bSmrg    else
2405e07dc26bSmrg      echo "disable static libraries"
2406e07dc26bSmrg    fi
2407e07dc26bSmrg
2408e07dc26bSmrg    exit $?
2409e07dc26bSmrg}
2410e07dc26bSmrg
2411e07dc26bSmrg
2412e07dc26bSmrg# func_enable_tag TAGNAME
2413e07dc26bSmrg# -----------------------
2414e07dc26bSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
2415e07dc26bSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
2416e07dc26bSmrg# variable here.
2417e07dc26bSmrgfunc_enable_tag ()
2418e07dc26bSmrg{
2419e07dc26bSmrg    # Global variable:
2420e07dc26bSmrg    tagname=$1
2421e07dc26bSmrg
2422e07dc26bSmrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
2423e07dc26bSmrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
2424e07dc26bSmrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
2425e07dc26bSmrg
2426e07dc26bSmrg    # Validate tagname.
2427e07dc26bSmrg    case $tagname in
2428e07dc26bSmrg      *[!-_A-Za-z0-9,/]*)
2429e07dc26bSmrg        func_fatal_error "invalid tag name: $tagname"
2430e07dc26bSmrg        ;;
2431e07dc26bSmrg    esac
2432e07dc26bSmrg
2433e07dc26bSmrg    # Don't test for the "default" C tag, as we know it's
2434e07dc26bSmrg    # there but not specially marked.
2435e07dc26bSmrg    case $tagname in
2436e07dc26bSmrg        CC) ;;
2437e07dc26bSmrg    *)
2438e07dc26bSmrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
2439e07dc26bSmrg	  taglist="$taglist $tagname"
2440e07dc26bSmrg
2441e07dc26bSmrg	  # Evaluate the configuration.  Be careful to quote the path
2442e07dc26bSmrg	  # and the sed script, to avoid splitting on whitespace, but
2443e07dc26bSmrg	  # also don't use non-portable quotes within backquotes within
2444e07dc26bSmrg	  # quotes we have to do it in 2 steps:
2445e07dc26bSmrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
2446e07dc26bSmrg	  eval "$extractedcf"
2447e07dc26bSmrg        else
2448e07dc26bSmrg	  func_error "ignoring unknown tag $tagname"
2449e07dc26bSmrg        fi
2450e07dc26bSmrg        ;;
2451e07dc26bSmrg    esac
2452e07dc26bSmrg}
2453e07dc26bSmrg
2454e07dc26bSmrg
2455e07dc26bSmrg# func_check_version_match
2456e07dc26bSmrg# ------------------------
2457e07dc26bSmrg# Ensure that we are using m4 macros, and libtool script from the same
2458e07dc26bSmrg# release of libtool.
2459e07dc26bSmrgfunc_check_version_match ()
2460e07dc26bSmrg{
2461e07dc26bSmrg    if test "$package_revision" != "$macro_revision"; then
2462e07dc26bSmrg      if test "$VERSION" != "$macro_version"; then
2463e07dc26bSmrg        if test -z "$macro_version"; then
2464e07dc26bSmrg          cat >&2 <<_LT_EOF
2465e07dc26bSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2466e07dc26bSmrg$progname: definition of this LT_INIT comes from an older release.
2467e07dc26bSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2468e07dc26bSmrg$progname: and run autoconf again.
2469e07dc26bSmrg_LT_EOF
2470e07dc26bSmrg        else
2471e07dc26bSmrg          cat >&2 <<_LT_EOF
2472e07dc26bSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2473e07dc26bSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2474e07dc26bSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2475e07dc26bSmrg$progname: and run autoconf again.
2476e07dc26bSmrg_LT_EOF
2477e07dc26bSmrg        fi
2478e07dc26bSmrg      else
2479e07dc26bSmrg        cat >&2 <<_LT_EOF
2480e07dc26bSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
2481e07dc26bSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
2482e07dc26bSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
2483e07dc26bSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
2484e07dc26bSmrg_LT_EOF
2485e07dc26bSmrg      fi
2486e07dc26bSmrg
2487e07dc26bSmrg      exit $EXIT_MISMATCH
2488e07dc26bSmrg    fi
2489e07dc26bSmrg}
2490e07dc26bSmrg
2491e07dc26bSmrg
2492e07dc26bSmrg# libtool_options_prep [ARG]...
2493e07dc26bSmrg# -----------------------------
2494e07dc26bSmrg# Preparation for options parsed by libtool.
2495e07dc26bSmrglibtool_options_prep ()
2496e07dc26bSmrg{
2497e07dc26bSmrg    $debug_mode
2498e07dc26bSmrg
2499e07dc26bSmrg    # Option defaults:
2500e07dc26bSmrg    opt_config=false
2501e07dc26bSmrg    opt_dlopen=
2502e07dc26bSmrg    opt_dry_run=false
2503e07dc26bSmrg    opt_help=false
2504e07dc26bSmrg    opt_mode=
2505e07dc26bSmrg    opt_preserve_dup_deps=false
2506e07dc26bSmrg    opt_quiet=false
2507e07dc26bSmrg
2508e07dc26bSmrg    nonopt=
2509e07dc26bSmrg    preserve_args=
2510e07dc26bSmrg
2511636c353eSmrg    _G_rc_lt_options_prep=:
2512636c353eSmrg
2513e07dc26bSmrg    # Shorthand for --mode=foo, only valid as the first argument
2514e07dc26bSmrg    case $1 in
2515e07dc26bSmrg    clean|clea|cle|cl)
2516e07dc26bSmrg      shift; set dummy --mode clean ${1+"$@"}; shift
2517e07dc26bSmrg      ;;
2518e07dc26bSmrg    compile|compil|compi|comp|com|co|c)
2519e07dc26bSmrg      shift; set dummy --mode compile ${1+"$@"}; shift
2520e07dc26bSmrg      ;;
2521e07dc26bSmrg    execute|execut|execu|exec|exe|ex|e)
2522e07dc26bSmrg      shift; set dummy --mode execute ${1+"$@"}; shift
2523e07dc26bSmrg      ;;
2524e07dc26bSmrg    finish|finis|fini|fin|fi|f)
2525e07dc26bSmrg      shift; set dummy --mode finish ${1+"$@"}; shift
2526e07dc26bSmrg      ;;
2527e07dc26bSmrg    install|instal|insta|inst|ins|in|i)
2528e07dc26bSmrg      shift; set dummy --mode install ${1+"$@"}; shift
2529e07dc26bSmrg      ;;
2530e07dc26bSmrg    link|lin|li|l)
2531e07dc26bSmrg      shift; set dummy --mode link ${1+"$@"}; shift
2532e07dc26bSmrg      ;;
2533e07dc26bSmrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
2534e07dc26bSmrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
2535e07dc26bSmrg      ;;
2536636c353eSmrg    *)
2537636c353eSmrg      _G_rc_lt_options_prep=false
2538636c353eSmrg      ;;
2539e07dc26bSmrg    esac
2540e07dc26bSmrg
2541636c353eSmrg    if $_G_rc_lt_options_prep; then
2542636c353eSmrg      # Pass back the list of options.
2543636c353eSmrg      func_quote eval ${1+"$@"}
2544636c353eSmrg      libtool_options_prep_result=$func_quote_result
2545636c353eSmrg    fi
2546e07dc26bSmrg}
2547e07dc26bSmrgfunc_add_hook func_options_prep libtool_options_prep
2548e07dc26bSmrg
2549e07dc26bSmrg
2550e07dc26bSmrg# libtool_parse_options [ARG]...
2551e07dc26bSmrg# ---------------------------------
2552e07dc26bSmrg# Provide handling for libtool specific options.
2553e07dc26bSmrglibtool_parse_options ()
2554e07dc26bSmrg{
2555e07dc26bSmrg    $debug_cmd
2556e07dc26bSmrg
2557636c353eSmrg    _G_rc_lt_parse_options=false
2558636c353eSmrg
2559e07dc26bSmrg    # Perform our own loop to consume as many options as possible in
2560e07dc26bSmrg    # each iteration.
2561e07dc26bSmrg    while test $# -gt 0; do
2562636c353eSmrg      _G_match_lt_parse_options=:
2563e07dc26bSmrg      _G_opt=$1
2564e07dc26bSmrg      shift
2565e07dc26bSmrg      case $_G_opt in
2566e07dc26bSmrg        --dry-run|--dryrun|-n)
2567e07dc26bSmrg                        opt_dry_run=:
2568e07dc26bSmrg                        ;;
2569e07dc26bSmrg
2570e07dc26bSmrg        --config)       func_config ;;
2571e07dc26bSmrg
2572e07dc26bSmrg        --dlopen|-dlopen)
2573e07dc26bSmrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
2574e07dc26bSmrg}$1"
2575e07dc26bSmrg                        shift
2576e07dc26bSmrg                        ;;
2577e07dc26bSmrg
2578e07dc26bSmrg        --preserve-dup-deps)
2579e07dc26bSmrg                        opt_preserve_dup_deps=: ;;
2580e07dc26bSmrg
2581e07dc26bSmrg        --features)     func_features ;;
2582e07dc26bSmrg
2583e07dc26bSmrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
2584e07dc26bSmrg
2585e07dc26bSmrg        --help)         opt_help=: ;;
2586e07dc26bSmrg
2587e07dc26bSmrg        --help-all)     opt_help=': help-all' ;;
2588e07dc26bSmrg
2589e07dc26bSmrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
2590e07dc26bSmrg                        opt_mode=$1
2591e07dc26bSmrg                        case $1 in
2592e07dc26bSmrg                          # Valid mode arguments:
2593e07dc26bSmrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
2594e07dc26bSmrg
2595e07dc26bSmrg                          # Catch anything else as an error
2596e07dc26bSmrg                          *) func_error "invalid argument for $_G_opt"
2597e07dc26bSmrg                             exit_cmd=exit
2598e07dc26bSmrg                             break
2599e07dc26bSmrg                             ;;
2600e07dc26bSmrg                        esac
2601e07dc26bSmrg                        shift
2602e07dc26bSmrg                        ;;
2603e07dc26bSmrg
2604e07dc26bSmrg        --no-silent|--no-quiet)
2605e07dc26bSmrg                        opt_quiet=false
2606e07dc26bSmrg                        func_append preserve_args " $_G_opt"
2607e07dc26bSmrg                        ;;
2608e07dc26bSmrg
2609e07dc26bSmrg        --no-warnings|--no-warning|--no-warn)
2610e07dc26bSmrg                        opt_warning=false
2611e07dc26bSmrg                        func_append preserve_args " $_G_opt"
2612e07dc26bSmrg                        ;;
2613e07dc26bSmrg
2614e07dc26bSmrg        --no-verbose)
2615e07dc26bSmrg                        opt_verbose=false
2616e07dc26bSmrg                        func_append preserve_args " $_G_opt"
2617e07dc26bSmrg                        ;;
2618e07dc26bSmrg
2619e07dc26bSmrg        --silent|--quiet)
2620e07dc26bSmrg                        opt_quiet=:
2621e07dc26bSmrg                        opt_verbose=false
2622e07dc26bSmrg                        func_append preserve_args " $_G_opt"
2623e07dc26bSmrg                        ;;
2624e07dc26bSmrg
2625e07dc26bSmrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
2626e07dc26bSmrg                        opt_tag=$1
2627e07dc26bSmrg                        func_append preserve_args " $_G_opt $1"
2628e07dc26bSmrg                        func_enable_tag "$1"
2629e07dc26bSmrg                        shift
2630e07dc26bSmrg                        ;;
2631e07dc26bSmrg
2632e07dc26bSmrg        --verbose|-v)   opt_quiet=false
2633e07dc26bSmrg                        opt_verbose=:
2634e07dc26bSmrg                        func_append preserve_args " $_G_opt"
2635e07dc26bSmrg                        ;;
2636e07dc26bSmrg
2637636c353eSmrg        # An option not handled by this hook function:
2638636c353eSmrg        *)              set dummy "$_G_opt" ${1+"$@"} ; shift
2639636c353eSmrg                        _G_match_lt_parse_options=false
2640636c353eSmrg                        break
2641636c353eSmrg                        ;;
2642e07dc26bSmrg      esac
2643636c353eSmrg      $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
2644e07dc26bSmrg    done
2645e07dc26bSmrg
2646636c353eSmrg    if $_G_rc_lt_parse_options; then
2647636c353eSmrg      # save modified positional parameters for caller
2648636c353eSmrg      func_quote eval ${1+"$@"}
2649636c353eSmrg      libtool_parse_options_result=$func_quote_result
2650636c353eSmrg    fi
2651e07dc26bSmrg}
2652e07dc26bSmrgfunc_add_hook func_parse_options libtool_parse_options
2653e07dc26bSmrg
2654e07dc26bSmrg
2655e07dc26bSmrg
2656e07dc26bSmrg# libtool_validate_options [ARG]...
2657e07dc26bSmrg# ---------------------------------
2658e07dc26bSmrg# Perform any sanity checks on option settings and/or unconsumed
2659e07dc26bSmrg# arguments.
2660e07dc26bSmrglibtool_validate_options ()
2661e07dc26bSmrg{
2662e07dc26bSmrg    # save first non-option argument
2663e07dc26bSmrg    if test 0 -lt $#; then
2664e07dc26bSmrg      nonopt=$1
2665e07dc26bSmrg      shift
2666e07dc26bSmrg    fi
2667e07dc26bSmrg
2668e07dc26bSmrg    # preserve --debug
2669e07dc26bSmrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
2670e07dc26bSmrg
2671e07dc26bSmrg    case $host in
2672e07dc26bSmrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
2673e07dc26bSmrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
2674e07dc26bSmrg      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
2675e07dc26bSmrg        # don't eliminate duplications in $postdeps and $predeps
2676e07dc26bSmrg        opt_duplicate_compiler_generated_deps=:
2677e07dc26bSmrg        ;;
2678e07dc26bSmrg      *)
2679e07dc26bSmrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
2680e07dc26bSmrg        ;;
2681e07dc26bSmrg    esac
2682e07dc26bSmrg
2683e07dc26bSmrg    $opt_help || {
2684e07dc26bSmrg      # Sanity checks first:
2685e07dc26bSmrg      func_check_version_match
2686e07dc26bSmrg
2687e07dc26bSmrg      test yes != "$build_libtool_libs" \
2688e07dc26bSmrg        && test yes != "$build_old_libs" \
2689e07dc26bSmrg        && func_fatal_configuration "not configured to build any kind of library"
2690e07dc26bSmrg
2691e07dc26bSmrg      # Darwin sucks
2692e07dc26bSmrg      eval std_shrext=\"$shrext_cmds\"
2693e07dc26bSmrg
2694e07dc26bSmrg      # Only execute mode is allowed to have -dlopen flags.
2695e07dc26bSmrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
2696e07dc26bSmrg        func_error "unrecognized option '-dlopen'"
2697e07dc26bSmrg        $ECHO "$help" 1>&2
2698e07dc26bSmrg        exit $EXIT_FAILURE
2699e07dc26bSmrg      fi
2700e07dc26bSmrg
2701e07dc26bSmrg      # Change the help message to a mode-specific one.
2702e07dc26bSmrg      generic_help=$help
2703e07dc26bSmrg      help="Try '$progname --help --mode=$opt_mode' for more information."
2704e07dc26bSmrg    }
2705e07dc26bSmrg
2706e07dc26bSmrg    # Pass back the unparsed argument list
2707636c353eSmrg    func_quote eval ${1+"$@"}
2708636c353eSmrg    libtool_validate_options_result=$func_quote_result
2709e07dc26bSmrg}
2710e07dc26bSmrgfunc_add_hook func_validate_options libtool_validate_options
2711e07dc26bSmrg
2712e07dc26bSmrg
2713e07dc26bSmrg# Process options as early as possible so that --help and --version
2714e07dc26bSmrg# can return quickly.
2715e07dc26bSmrgfunc_options ${1+"$@"}
2716e07dc26bSmrgeval set dummy "$func_options_result"; shift
2717e07dc26bSmrg
2718e07dc26bSmrg
2719e07dc26bSmrg
2720e07dc26bSmrg## ----------- ##
2721e07dc26bSmrg##    Main.    ##
2722e07dc26bSmrg## ----------- ##
2723e07dc26bSmrg
2724e07dc26bSmrgmagic='%%%MAGIC variable%%%'
2725e07dc26bSmrgmagic_exe='%%%MAGIC EXE variable%%%'
2726e07dc26bSmrg
2727e07dc26bSmrg# Global variables.
2728e07dc26bSmrgextracted_archives=
2729e07dc26bSmrgextracted_serial=0
2730e07dc26bSmrg
2731e07dc26bSmrg# If this variable is set in any of the actions, the command in it
2732e07dc26bSmrg# will be execed at the end.  This prevents here-documents from being
2733e07dc26bSmrg# left over by shells.
2734e07dc26bSmrgexec_cmd=
2735e07dc26bSmrg
2736e07dc26bSmrg
2737e07dc26bSmrg# A function that is used when there is no print builtin or printf.
2738e07dc26bSmrgfunc_fallback_echo ()
2739e07dc26bSmrg{
2740e07dc26bSmrg  eval 'cat <<_LTECHO_EOF
2741e07dc26bSmrg$1
2742e07dc26bSmrg_LTECHO_EOF'
2743e07dc26bSmrg}
2744e07dc26bSmrg
2745e07dc26bSmrg# func_generated_by_libtool
2746e07dc26bSmrg# True iff stdin has been generated by Libtool. This function is only
2747e07dc26bSmrg# a basic sanity check; it will hardly flush out determined imposters.
2748e07dc26bSmrgfunc_generated_by_libtool_p ()
2749e07dc26bSmrg{
2750e07dc26bSmrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
2751e07dc26bSmrg}
2752e07dc26bSmrg
2753e07dc26bSmrg# func_lalib_p file
2754e07dc26bSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
2755e07dc26bSmrg# This function is only a basic sanity check; it will hardly flush out
2756e07dc26bSmrg# determined imposters.
2757e07dc26bSmrgfunc_lalib_p ()
2758e07dc26bSmrg{
2759e07dc26bSmrg    test -f "$1" &&
2760e07dc26bSmrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
2761e07dc26bSmrg}
2762e07dc26bSmrg
2763e07dc26bSmrg# func_lalib_unsafe_p file
2764e07dc26bSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
2765e07dc26bSmrg# This function implements the same check as func_lalib_p without
2766e07dc26bSmrg# resorting to external programs.  To this end, it redirects stdin and
2767e07dc26bSmrg# closes it afterwards, without saving the original file descriptor.
2768e07dc26bSmrg# As a safety measure, use it only where a negative result would be
2769e07dc26bSmrg# fatal anyway.  Works if 'file' does not exist.
2770e07dc26bSmrgfunc_lalib_unsafe_p ()
2771e07dc26bSmrg{
2772e07dc26bSmrg    lalib_p=no
2773e07dc26bSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
2774e07dc26bSmrg	for lalib_p_l in 1 2 3 4
2775e07dc26bSmrg	do
2776e07dc26bSmrg	    read lalib_p_line
2777e07dc26bSmrg	    case $lalib_p_line in
2778e07dc26bSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
2779e07dc26bSmrg	    esac
2780e07dc26bSmrg	done
2781e07dc26bSmrg	exec 0<&5 5<&-
2782e07dc26bSmrg    fi
2783e07dc26bSmrg    test yes = "$lalib_p"
2784e07dc26bSmrg}
2785e07dc26bSmrg
2786e07dc26bSmrg# func_ltwrapper_script_p file
2787e07dc26bSmrg# True iff FILE is a libtool wrapper script
2788e07dc26bSmrg# This function is only a basic sanity check; it will hardly flush out
2789e07dc26bSmrg# determined imposters.
2790e07dc26bSmrgfunc_ltwrapper_script_p ()
2791e07dc26bSmrg{
2792e07dc26bSmrg    test -f "$1" &&
2793e07dc26bSmrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
2794e07dc26bSmrg}
2795e07dc26bSmrg
2796e07dc26bSmrg# func_ltwrapper_executable_p file
2797e07dc26bSmrg# True iff FILE is a libtool wrapper executable
2798e07dc26bSmrg# This function is only a basic sanity check; it will hardly flush out
2799e07dc26bSmrg# determined imposters.
2800e07dc26bSmrgfunc_ltwrapper_executable_p ()
2801e07dc26bSmrg{
2802e07dc26bSmrg    func_ltwrapper_exec_suffix=
2803e07dc26bSmrg    case $1 in
2804e07dc26bSmrg    *.exe) ;;
2805e07dc26bSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
2806e07dc26bSmrg    esac
2807e07dc26bSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
2808e07dc26bSmrg}
2809e07dc26bSmrg
2810e07dc26bSmrg# func_ltwrapper_scriptname file
2811e07dc26bSmrg# Assumes file is an ltwrapper_executable
2812e07dc26bSmrg# uses $file to determine the appropriate filename for a
2813e07dc26bSmrg# temporary ltwrapper_script.
2814e07dc26bSmrgfunc_ltwrapper_scriptname ()
2815e07dc26bSmrg{
2816e07dc26bSmrg    func_dirname_and_basename "$1" "" "."
2817e07dc26bSmrg    func_stripname '' '.exe' "$func_basename_result"
2818e07dc26bSmrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
2819e07dc26bSmrg}
2820e07dc26bSmrg
2821e07dc26bSmrg# func_ltwrapper_p file
2822e07dc26bSmrg# True iff FILE is a libtool wrapper script or wrapper executable
2823e07dc26bSmrg# This function is only a basic sanity check; it will hardly flush out
2824e07dc26bSmrg# determined imposters.
2825e07dc26bSmrgfunc_ltwrapper_p ()
2826e07dc26bSmrg{
2827e07dc26bSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
2828e07dc26bSmrg}
2829e07dc26bSmrg
2830e07dc26bSmrg
2831e07dc26bSmrg# func_execute_cmds commands fail_cmd
2832e07dc26bSmrg# Execute tilde-delimited COMMANDS.
2833e07dc26bSmrg# If FAIL_CMD is given, eval that upon failure.
2834e07dc26bSmrg# FAIL_CMD may read-access the current command in variable CMD!
2835e07dc26bSmrgfunc_execute_cmds ()
2836e07dc26bSmrg{
2837e07dc26bSmrg    $debug_cmd
2838e07dc26bSmrg
2839e07dc26bSmrg    save_ifs=$IFS; IFS='~'
2840e07dc26bSmrg    for cmd in $1; do
2841e07dc26bSmrg      IFS=$sp$nl
2842e07dc26bSmrg      eval cmd=\"$cmd\"
2843e07dc26bSmrg      IFS=$save_ifs
2844e07dc26bSmrg      func_show_eval "$cmd" "${2-:}"
2845e07dc26bSmrg    done
2846e07dc26bSmrg    IFS=$save_ifs
2847e07dc26bSmrg}
2848e07dc26bSmrg
2849e07dc26bSmrg
2850e07dc26bSmrg# func_source file
2851e07dc26bSmrg# Source FILE, adding directory component if necessary.
2852e07dc26bSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
2853e07dc26bSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
2854e07dc26bSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
2855e07dc26bSmrg# 'FILE.' does not work on cygwin managed mounts.
2856e07dc26bSmrgfunc_source ()
2857e07dc26bSmrg{
2858e07dc26bSmrg    $debug_cmd
2859e07dc26bSmrg
2860e07dc26bSmrg    case $1 in
2861e07dc26bSmrg    */* | *\\*)	. "$1" ;;
2862e07dc26bSmrg    *)		. "./$1" ;;
2863e07dc26bSmrg    esac
2864e07dc26bSmrg}
2865e07dc26bSmrg
2866e07dc26bSmrg
2867e07dc26bSmrg# func_resolve_sysroot PATH
2868e07dc26bSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
2869e07dc26bSmrg# func_resolve_sysroot_result
2870e07dc26bSmrgfunc_resolve_sysroot ()
2871e07dc26bSmrg{
2872e07dc26bSmrg  func_resolve_sysroot_result=$1
2873e07dc26bSmrg  case $func_resolve_sysroot_result in
2874e07dc26bSmrg  =*)
2875e07dc26bSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
2876e07dc26bSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2877e07dc26bSmrg    ;;
2878e07dc26bSmrg  esac
2879e07dc26bSmrg}
2880e07dc26bSmrg
2881e07dc26bSmrg# func_replace_sysroot PATH
2882e07dc26bSmrg# If PATH begins with the sysroot, replace it with = and
2883e07dc26bSmrg# store the result into func_replace_sysroot_result.
2884e07dc26bSmrgfunc_replace_sysroot ()
2885e07dc26bSmrg{
2886e07dc26bSmrg  case $lt_sysroot:$1 in
2887e07dc26bSmrg  ?*:"$lt_sysroot"*)
2888e07dc26bSmrg    func_stripname "$lt_sysroot" '' "$1"
2889e07dc26bSmrg    func_replace_sysroot_result='='$func_stripname_result
2890e07dc26bSmrg    ;;
2891e07dc26bSmrg  *)
2892e07dc26bSmrg    # Including no sysroot.
2893e07dc26bSmrg    func_replace_sysroot_result=$1
2894e07dc26bSmrg    ;;
2895e07dc26bSmrg  esac
2896e07dc26bSmrg}
2897e07dc26bSmrg
2898e07dc26bSmrg# func_infer_tag arg
2899e07dc26bSmrg# Infer tagged configuration to use if any are available and
2900e07dc26bSmrg# if one wasn't chosen via the "--tag" command line option.
2901e07dc26bSmrg# Only attempt this if the compiler in the base compile
2902e07dc26bSmrg# command doesn't match the default compiler.
2903e07dc26bSmrg# arg is usually of the form 'gcc ...'
2904e07dc26bSmrgfunc_infer_tag ()
2905e07dc26bSmrg{
2906e07dc26bSmrg    $debug_cmd
2907e07dc26bSmrg
2908e07dc26bSmrg    if test -n "$available_tags" && test -z "$tagname"; then
2909e07dc26bSmrg      CC_quoted=
2910e07dc26bSmrg      for arg in $CC; do
2911e07dc26bSmrg	func_append_quoted CC_quoted "$arg"
2912e07dc26bSmrg      done
2913e07dc26bSmrg      CC_expanded=`func_echo_all $CC`
2914e07dc26bSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
2915e07dc26bSmrg      case $@ in
2916e07dc26bSmrg      # Blanks in the command may have been stripped by the calling shell,
2917e07dc26bSmrg      # but not from the CC environment variable when configure was run.
2918e07dc26bSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2919e07dc26bSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
2920e07dc26bSmrg      # Blanks at the start of $base_compile will cause this to fail
2921e07dc26bSmrg      # if we don't check for them as well.
2922e07dc26bSmrg      *)
2923e07dc26bSmrg	for z in $available_tags; do
2924e07dc26bSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2925e07dc26bSmrg	    # Evaluate the configuration.
2926e07dc26bSmrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2927e07dc26bSmrg	    CC_quoted=
2928e07dc26bSmrg	    for arg in $CC; do
2929e07dc26bSmrg	      # Double-quote args containing other shell metacharacters.
2930e07dc26bSmrg	      func_append_quoted CC_quoted "$arg"
2931e07dc26bSmrg	    done
2932e07dc26bSmrg	    CC_expanded=`func_echo_all $CC`
2933e07dc26bSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
2934e07dc26bSmrg	    case "$@ " in
2935e07dc26bSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2936e07dc26bSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
2937e07dc26bSmrg	      # The compiler in the base compile command matches
2938e07dc26bSmrg	      # the one in the tagged configuration.
2939e07dc26bSmrg	      # Assume this is the tagged configuration we want.
2940e07dc26bSmrg	      tagname=$z
2941e07dc26bSmrg	      break
2942e07dc26bSmrg	      ;;
2943e07dc26bSmrg	    esac
2944e07dc26bSmrg	  fi
2945e07dc26bSmrg	done
2946e07dc26bSmrg	# If $tagname still isn't set, then no tagged configuration
2947e07dc26bSmrg	# was found and let the user know that the "--tag" command
2948e07dc26bSmrg	# line option must be used.
2949e07dc26bSmrg	if test -z "$tagname"; then
2950e07dc26bSmrg	  func_echo "unable to infer tagged configuration"
2951e07dc26bSmrg	  func_fatal_error "specify a tag with '--tag'"
2952e07dc26bSmrg#	else
2953e07dc26bSmrg#	  func_verbose "using $tagname tagged configuration"
2954e07dc26bSmrg	fi
2955e07dc26bSmrg	;;
2956e07dc26bSmrg      esac
2957e07dc26bSmrg    fi
2958e07dc26bSmrg}
2959e07dc26bSmrg
2960e07dc26bSmrg
2961e07dc26bSmrg
2962e07dc26bSmrg# func_write_libtool_object output_name pic_name nonpic_name
2963e07dc26bSmrg# Create a libtool object file (analogous to a ".la" file),
2964e07dc26bSmrg# but don't create it if we're doing a dry run.
2965e07dc26bSmrgfunc_write_libtool_object ()
2966e07dc26bSmrg{
2967e07dc26bSmrg    write_libobj=$1
2968e07dc26bSmrg    if test yes = "$build_libtool_libs"; then
2969e07dc26bSmrg      write_lobj=\'$2\'
2970e07dc26bSmrg    else
2971e07dc26bSmrg      write_lobj=none
2972e07dc26bSmrg    fi
2973e07dc26bSmrg
2974e07dc26bSmrg    if test yes = "$build_old_libs"; then
2975e07dc26bSmrg      write_oldobj=\'$3\'
2976e07dc26bSmrg    else
2977e07dc26bSmrg      write_oldobj=none
2978e07dc26bSmrg    fi
2979e07dc26bSmrg
2980e07dc26bSmrg    $opt_dry_run || {
2981e07dc26bSmrg      cat >${write_libobj}T <<EOF
2982e07dc26bSmrg# $write_libobj - a libtool object file
2983e07dc26bSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2984e07dc26bSmrg#
2985e07dc26bSmrg# Please DO NOT delete this file!
2986e07dc26bSmrg# It is necessary for linking the library.
2987e07dc26bSmrg
2988e07dc26bSmrg# Name of the PIC object.
2989e07dc26bSmrgpic_object=$write_lobj
2990e07dc26bSmrg
2991e07dc26bSmrg# Name of the non-PIC object
2992e07dc26bSmrgnon_pic_object=$write_oldobj
2993e07dc26bSmrg
2994e07dc26bSmrgEOF
2995e07dc26bSmrg      $MV "${write_libobj}T" "$write_libobj"
2996e07dc26bSmrg    }
2997e07dc26bSmrg}
2998e07dc26bSmrg
2999e07dc26bSmrg
3000e07dc26bSmrg##################################################
3001e07dc26bSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
3002e07dc26bSmrg##################################################
3003e07dc26bSmrg
3004e07dc26bSmrg# func_convert_core_file_wine_to_w32 ARG
3005e07dc26bSmrg# Helper function used by file name conversion functions when $build is *nix,
3006e07dc26bSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
3007e07dc26bSmrg# correctly configured wine environment available, with the winepath program
3008e07dc26bSmrg# in $build's $PATH.
3009e07dc26bSmrg#
3010e07dc26bSmrg# ARG is the $build file name to be converted to w32 format.
3011e07dc26bSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
3012e07dc26bSmrg# be empty on error (or when ARG is empty)
3013e07dc26bSmrgfunc_convert_core_file_wine_to_w32 ()
3014e07dc26bSmrg{
3015e07dc26bSmrg  $debug_cmd
3016e07dc26bSmrg
3017e07dc26bSmrg  func_convert_core_file_wine_to_w32_result=$1
3018e07dc26bSmrg  if test -n "$1"; then
3019e07dc26bSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
3020e07dc26bSmrg    # are forced to check the contents of stdout. On the other hand, if the
3021e07dc26bSmrg    # command is not found, the shell will set an exit code of 127 and print
3022e07dc26bSmrg    # *an error message* to stdout. So we must check for both error code of
3023e07dc26bSmrg    # zero AND non-empty stdout, which explains the odd construction:
3024e07dc26bSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
3025e07dc26bSmrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
3026e07dc26bSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
3027e07dc26bSmrg        $SED -e "$sed_naive_backslashify"`
3028e07dc26bSmrg    else
3029e07dc26bSmrg      func_convert_core_file_wine_to_w32_result=
3030e07dc26bSmrg    fi
3031e07dc26bSmrg  fi
3032e07dc26bSmrg}
3033e07dc26bSmrg# end: func_convert_core_file_wine_to_w32
3034e07dc26bSmrg
3035e07dc26bSmrg
3036e07dc26bSmrg# func_convert_core_path_wine_to_w32 ARG
3037e07dc26bSmrg# Helper function used by path conversion functions when $build is *nix, and
3038e07dc26bSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
3039e07dc26bSmrg# configured wine environment available, with the winepath program in $build's
3040e07dc26bSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
3041e07dc26bSmrg#
3042e07dc26bSmrg# ARG is path to be converted from $build format to win32.
3043e07dc26bSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
3044e07dc26bSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
3045e07dc26bSmrg# are convertible, then the result may be empty.
3046e07dc26bSmrgfunc_convert_core_path_wine_to_w32 ()
3047e07dc26bSmrg{
3048e07dc26bSmrg  $debug_cmd
3049e07dc26bSmrg
3050e07dc26bSmrg  # unfortunately, winepath doesn't convert paths, only file names
3051e07dc26bSmrg  func_convert_core_path_wine_to_w32_result=
3052e07dc26bSmrg  if test -n "$1"; then
3053e07dc26bSmrg    oldIFS=$IFS
3054e07dc26bSmrg    IFS=:
3055e07dc26bSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
3056e07dc26bSmrg      IFS=$oldIFS
3057e07dc26bSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
3058e07dc26bSmrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
3059e07dc26bSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
3060e07dc26bSmrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
3061e07dc26bSmrg        else
3062e07dc26bSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
3063e07dc26bSmrg        fi
3064e07dc26bSmrg      fi
3065e07dc26bSmrg    done
3066e07dc26bSmrg    IFS=$oldIFS
3067e07dc26bSmrg  fi
3068e07dc26bSmrg}
3069e07dc26bSmrg# end: func_convert_core_path_wine_to_w32
3070e07dc26bSmrg
3071e07dc26bSmrg
3072e07dc26bSmrg# func_cygpath ARGS...
3073e07dc26bSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
3074e07dc26bSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
3075e07dc26bSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
3076e07dc26bSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
3077e07dc26bSmrg# file name or path is assumed to be in w32 format, as previously converted
3078e07dc26bSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
3079e07dc26bSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
3080e07dc26bSmrg# Cygwin format). Returns an empty string on error.
3081e07dc26bSmrg#
3082e07dc26bSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
3083e07dc26bSmrg# be converted.
3084e07dc26bSmrg#
3085e07dc26bSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
3086e07dc26bSmrg# environment variable; do not put it in $PATH.
3087e07dc26bSmrgfunc_cygpath ()
3088e07dc26bSmrg{
3089e07dc26bSmrg  $debug_cmd
3090e07dc26bSmrg
3091e07dc26bSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
3092e07dc26bSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
3093e07dc26bSmrg    if test "$?" -ne 0; then
3094e07dc26bSmrg      # on failure, ensure result is empty
3095e07dc26bSmrg      func_cygpath_result=
3096e07dc26bSmrg    fi
3097e07dc26bSmrg  else
3098e07dc26bSmrg    func_cygpath_result=
3099e07dc26bSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
3100e07dc26bSmrg  fi
3101e07dc26bSmrg}
3102e07dc26bSmrg#end: func_cygpath
3103e07dc26bSmrg
3104e07dc26bSmrg
3105e07dc26bSmrg# func_convert_core_msys_to_w32 ARG
3106e07dc26bSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
3107e07dc26bSmrg# result in func_convert_core_msys_to_w32_result.
3108e07dc26bSmrgfunc_convert_core_msys_to_w32 ()
3109e07dc26bSmrg{
3110e07dc26bSmrg  $debug_cmd
3111e07dc26bSmrg
3112e07dc26bSmrg  # awkward: cmd appends spaces to result
3113e07dc26bSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
3114e07dc26bSmrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
3115e07dc26bSmrg}
3116e07dc26bSmrg#end: func_convert_core_msys_to_w32
3117e07dc26bSmrg
3118e07dc26bSmrg
3119e07dc26bSmrg# func_convert_file_check ARG1 ARG2
3120e07dc26bSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
3121e07dc26bSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
3122e07dc26bSmrg# func_to_host_file_result to ARG1).
3123e07dc26bSmrgfunc_convert_file_check ()
3124e07dc26bSmrg{
3125e07dc26bSmrg  $debug_cmd
3126e07dc26bSmrg
3127e07dc26bSmrg  if test -z "$2" && test -n "$1"; then
3128e07dc26bSmrg    func_error "Could not determine host file name corresponding to"
3129e07dc26bSmrg    func_error "  '$1'"
3130e07dc26bSmrg    func_error "Continuing, but uninstalled executables may not work."
3131e07dc26bSmrg    # Fallback:
3132e07dc26bSmrg    func_to_host_file_result=$1
3133e07dc26bSmrg  fi
3134e07dc26bSmrg}
3135e07dc26bSmrg# end func_convert_file_check
3136e07dc26bSmrg
3137e07dc26bSmrg
3138e07dc26bSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
3139e07dc26bSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
3140e07dc26bSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
3141e07dc26bSmrg# func_to_host_file_result to a simplistic fallback value (see below).
3142e07dc26bSmrgfunc_convert_path_check ()
3143e07dc26bSmrg{
3144e07dc26bSmrg  $debug_cmd
3145e07dc26bSmrg
3146e07dc26bSmrg  if test -z "$4" && test -n "$3"; then
3147e07dc26bSmrg    func_error "Could not determine the host path corresponding to"
3148e07dc26bSmrg    func_error "  '$3'"
3149e07dc26bSmrg    func_error "Continuing, but uninstalled executables may not work."
3150e07dc26bSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
3151e07dc26bSmrg    # should not be "improved".  See libtool.info.
3152e07dc26bSmrg    if test "x$1" != "x$2"; then
3153e07dc26bSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
3154e07dc26bSmrg      func_to_host_path_result=`echo "$3" |
3155e07dc26bSmrg        $SED -e "$lt_replace_pathsep_chars"`
3156e07dc26bSmrg    else
3157e07dc26bSmrg      func_to_host_path_result=$3
3158e07dc26bSmrg    fi
3159e07dc26bSmrg  fi
3160e07dc26bSmrg}
3161e07dc26bSmrg# end func_convert_path_check
3162e07dc26bSmrg
3163e07dc26bSmrg
3164e07dc26bSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
3165e07dc26bSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
3166e07dc26bSmrg# and appending REPL if ORIG matches BACKPAT.
3167e07dc26bSmrgfunc_convert_path_front_back_pathsep ()
3168e07dc26bSmrg{
3169e07dc26bSmrg  $debug_cmd
3170e07dc26bSmrg
3171e07dc26bSmrg  case $4 in
3172e07dc26bSmrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
3173e07dc26bSmrg    ;;
3174e07dc26bSmrg  esac
3175e07dc26bSmrg  case $4 in
3176e07dc26bSmrg  $2 ) func_append func_to_host_path_result "$3"
3177e07dc26bSmrg    ;;
3178e07dc26bSmrg  esac
3179e07dc26bSmrg}
3180e07dc26bSmrg# end func_convert_path_front_back_pathsep
3181e07dc26bSmrg
3182e07dc26bSmrg
3183e07dc26bSmrg##################################################
3184e07dc26bSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
3185e07dc26bSmrg##################################################
3186e07dc26bSmrg# invoked via '$to_host_file_cmd ARG'
3187e07dc26bSmrg#
3188e07dc26bSmrg# In each case, ARG is the path to be converted from $build to $host format.
3189e07dc26bSmrg# Result will be available in $func_to_host_file_result.
3190e07dc26bSmrg
3191e07dc26bSmrg
3192e07dc26bSmrg# func_to_host_file ARG
3193e07dc26bSmrg# Converts the file name ARG from $build format to $host format. Return result
3194e07dc26bSmrg# in func_to_host_file_result.
3195e07dc26bSmrgfunc_to_host_file ()
3196e07dc26bSmrg{
3197e07dc26bSmrg  $debug_cmd
3198e07dc26bSmrg
3199e07dc26bSmrg  $to_host_file_cmd "$1"
3200e07dc26bSmrg}
3201e07dc26bSmrg# end func_to_host_file
3202e07dc26bSmrg
3203e07dc26bSmrg
3204e07dc26bSmrg# func_to_tool_file ARG LAZY
3205e07dc26bSmrg# converts the file name ARG from $build format to toolchain format. Return
3206e07dc26bSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
3207e07dc26bSmrg# in (the comma separated) LAZY, no conversion takes place.
3208e07dc26bSmrgfunc_to_tool_file ()
3209e07dc26bSmrg{
3210e07dc26bSmrg  $debug_cmd
3211e07dc26bSmrg
3212e07dc26bSmrg  case ,$2, in
3213e07dc26bSmrg    *,"$to_tool_file_cmd",*)
3214e07dc26bSmrg      func_to_tool_file_result=$1
3215e07dc26bSmrg      ;;
3216e07dc26bSmrg    *)
3217e07dc26bSmrg      $to_tool_file_cmd "$1"
3218e07dc26bSmrg      func_to_tool_file_result=$func_to_host_file_result
3219e07dc26bSmrg      ;;
3220e07dc26bSmrg  esac
3221e07dc26bSmrg}
3222e07dc26bSmrg# end func_to_tool_file
3223e07dc26bSmrg
3224e07dc26bSmrg
3225e07dc26bSmrg# func_convert_file_noop ARG
3226e07dc26bSmrg# Copy ARG to func_to_host_file_result.
3227e07dc26bSmrgfunc_convert_file_noop ()
3228e07dc26bSmrg{
3229e07dc26bSmrg  func_to_host_file_result=$1
3230e07dc26bSmrg}
3231e07dc26bSmrg# end func_convert_file_noop
3232e07dc26bSmrg
3233e07dc26bSmrg
3234e07dc26bSmrg# func_convert_file_msys_to_w32 ARG
3235e07dc26bSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
3236e07dc26bSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3237e07dc26bSmrg# func_to_host_file_result.
3238e07dc26bSmrgfunc_convert_file_msys_to_w32 ()
3239e07dc26bSmrg{
3240e07dc26bSmrg  $debug_cmd
3241e07dc26bSmrg
3242e07dc26bSmrg  func_to_host_file_result=$1
3243e07dc26bSmrg  if test -n "$1"; then
3244e07dc26bSmrg    func_convert_core_msys_to_w32 "$1"
3245e07dc26bSmrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
3246e07dc26bSmrg  fi
3247e07dc26bSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3248e07dc26bSmrg}
3249e07dc26bSmrg# end func_convert_file_msys_to_w32
3250e07dc26bSmrg
3251e07dc26bSmrg
3252e07dc26bSmrg# func_convert_file_cygwin_to_w32 ARG
3253e07dc26bSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
3254e07dc26bSmrg# func_to_host_file_result.
3255e07dc26bSmrgfunc_convert_file_cygwin_to_w32 ()
3256e07dc26bSmrg{
3257e07dc26bSmrg  $debug_cmd
3258e07dc26bSmrg
3259e07dc26bSmrg  func_to_host_file_result=$1
3260e07dc26bSmrg  if test -n "$1"; then
3261e07dc26bSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3262e07dc26bSmrg    # LT_CYGPATH in this case.
3263e07dc26bSmrg    func_to_host_file_result=`cygpath -m "$1"`
3264e07dc26bSmrg  fi
3265e07dc26bSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3266e07dc26bSmrg}
3267e07dc26bSmrg# end func_convert_file_cygwin_to_w32
3268e07dc26bSmrg
3269e07dc26bSmrg
3270e07dc26bSmrg# func_convert_file_nix_to_w32 ARG
3271e07dc26bSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
3272e07dc26bSmrg# and a working winepath. Returns result in func_to_host_file_result.
3273e07dc26bSmrgfunc_convert_file_nix_to_w32 ()
3274e07dc26bSmrg{
3275e07dc26bSmrg  $debug_cmd
3276e07dc26bSmrg
3277e07dc26bSmrg  func_to_host_file_result=$1
3278e07dc26bSmrg  if test -n "$1"; then
3279e07dc26bSmrg    func_convert_core_file_wine_to_w32 "$1"
3280e07dc26bSmrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3281e07dc26bSmrg  fi
3282e07dc26bSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3283e07dc26bSmrg}
3284e07dc26bSmrg# end func_convert_file_nix_to_w32
3285e07dc26bSmrg
3286e07dc26bSmrg
3287e07dc26bSmrg# func_convert_file_msys_to_cygwin ARG
3288e07dc26bSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3289e07dc26bSmrg# Returns result in func_to_host_file_result.
3290e07dc26bSmrgfunc_convert_file_msys_to_cygwin ()
3291e07dc26bSmrg{
3292e07dc26bSmrg  $debug_cmd
3293e07dc26bSmrg
3294e07dc26bSmrg  func_to_host_file_result=$1
3295e07dc26bSmrg  if test -n "$1"; then
3296e07dc26bSmrg    func_convert_core_msys_to_w32 "$1"
3297e07dc26bSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
3298e07dc26bSmrg    func_to_host_file_result=$func_cygpath_result
3299e07dc26bSmrg  fi
3300e07dc26bSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3301e07dc26bSmrg}
3302e07dc26bSmrg# end func_convert_file_msys_to_cygwin
3303e07dc26bSmrg
3304e07dc26bSmrg
3305e07dc26bSmrg# func_convert_file_nix_to_cygwin ARG
3306e07dc26bSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
3307e07dc26bSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
3308e07dc26bSmrg# in func_to_host_file_result.
3309e07dc26bSmrgfunc_convert_file_nix_to_cygwin ()
3310e07dc26bSmrg{
3311e07dc26bSmrg  $debug_cmd
3312e07dc26bSmrg
3313e07dc26bSmrg  func_to_host_file_result=$1
3314e07dc26bSmrg  if test -n "$1"; then
3315e07dc26bSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3316e07dc26bSmrg    func_convert_core_file_wine_to_w32 "$1"
3317e07dc26bSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
3318e07dc26bSmrg    func_to_host_file_result=$func_cygpath_result
3319e07dc26bSmrg  fi
3320e07dc26bSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
3321e07dc26bSmrg}
3322e07dc26bSmrg# end func_convert_file_nix_to_cygwin
3323e07dc26bSmrg
3324e07dc26bSmrg
3325e07dc26bSmrg#############################################
3326e07dc26bSmrg# $build to $host PATH CONVERSION FUNCTIONS #
3327e07dc26bSmrg#############################################
3328e07dc26bSmrg# invoked via '$to_host_path_cmd ARG'
3329e07dc26bSmrg#
3330e07dc26bSmrg# In each case, ARG is the path to be converted from $build to $host format.
3331e07dc26bSmrg# The result will be available in $func_to_host_path_result.
3332e07dc26bSmrg#
3333e07dc26bSmrg# Path separators are also converted from $build format to $host format.  If
3334e07dc26bSmrg# ARG begins or ends with a path separator character, it is preserved (but
3335e07dc26bSmrg# converted to $host format) on output.
3336e07dc26bSmrg#
3337e07dc26bSmrg# All path conversion functions are named using the following convention:
3338e07dc26bSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
3339e07dc26bSmrg#   path conversion function         : func_convert_path_X_to_Y ()
3340e07dc26bSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
3341e07dc26bSmrg# same.  If conversion functions are added for new $build/$host combinations,
3342e07dc26bSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
3343e07dc26bSmrg# will break.
3344e07dc26bSmrg
3345e07dc26bSmrg
3346e07dc26bSmrg# func_init_to_host_path_cmd
3347e07dc26bSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
3348e07dc26bSmrg# appropriate value, based on the value of $to_host_file_cmd.
3349e07dc26bSmrgto_host_path_cmd=
3350e07dc26bSmrgfunc_init_to_host_path_cmd ()
3351e07dc26bSmrg{
3352e07dc26bSmrg  $debug_cmd
3353e07dc26bSmrg
3354e07dc26bSmrg  if test -z "$to_host_path_cmd"; then
3355e07dc26bSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
3356e07dc26bSmrg    to_host_path_cmd=func_convert_path_$func_stripname_result
3357e07dc26bSmrg  fi
3358e07dc26bSmrg}
3359e07dc26bSmrg
3360e07dc26bSmrg
3361e07dc26bSmrg# func_to_host_path ARG
3362e07dc26bSmrg# Converts the path ARG from $build format to $host format. Return result
3363e07dc26bSmrg# in func_to_host_path_result.
3364e07dc26bSmrgfunc_to_host_path ()
3365e07dc26bSmrg{
3366e07dc26bSmrg  $debug_cmd
3367e07dc26bSmrg
3368e07dc26bSmrg  func_init_to_host_path_cmd
3369e07dc26bSmrg  $to_host_path_cmd "$1"
3370e07dc26bSmrg}
3371e07dc26bSmrg# end func_to_host_path
3372e07dc26bSmrg
3373e07dc26bSmrg
3374e07dc26bSmrg# func_convert_path_noop ARG
3375e07dc26bSmrg# Copy ARG to func_to_host_path_result.
3376e07dc26bSmrgfunc_convert_path_noop ()
3377e07dc26bSmrg{
3378e07dc26bSmrg  func_to_host_path_result=$1
3379e07dc26bSmrg}
3380e07dc26bSmrg# end func_convert_path_noop
3381e07dc26bSmrg
3382e07dc26bSmrg
3383e07dc26bSmrg# func_convert_path_msys_to_w32 ARG
3384e07dc26bSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3385e07dc26bSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3386e07dc26bSmrg# func_to_host_path_result.
3387e07dc26bSmrgfunc_convert_path_msys_to_w32 ()
3388e07dc26bSmrg{
3389e07dc26bSmrg  $debug_cmd
3390e07dc26bSmrg
3391e07dc26bSmrg  func_to_host_path_result=$1
3392e07dc26bSmrg  if test -n "$1"; then
3393e07dc26bSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
3394e07dc26bSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3395e07dc26bSmrg    # and winepath ignores them completely.
3396e07dc26bSmrg    func_stripname : : "$1"
3397e07dc26bSmrg    func_to_host_path_tmp1=$func_stripname_result
3398e07dc26bSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3399e07dc26bSmrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
3400e07dc26bSmrg    func_convert_path_check : ";" \
3401e07dc26bSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3402e07dc26bSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3403e07dc26bSmrg  fi
3404e07dc26bSmrg}
3405e07dc26bSmrg# end func_convert_path_msys_to_w32
3406e07dc26bSmrg
3407e07dc26bSmrg
3408e07dc26bSmrg# func_convert_path_cygwin_to_w32 ARG
3409e07dc26bSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
3410e07dc26bSmrg# func_to_host_file_result.
3411e07dc26bSmrgfunc_convert_path_cygwin_to_w32 ()
3412e07dc26bSmrg{
3413e07dc26bSmrg  $debug_cmd
3414e07dc26bSmrg
3415e07dc26bSmrg  func_to_host_path_result=$1
3416e07dc26bSmrg  if test -n "$1"; then
3417e07dc26bSmrg    # See func_convert_path_msys_to_w32:
3418e07dc26bSmrg    func_stripname : : "$1"
3419e07dc26bSmrg    func_to_host_path_tmp1=$func_stripname_result
3420e07dc26bSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3421e07dc26bSmrg    func_convert_path_check : ";" \
3422e07dc26bSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3423e07dc26bSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3424e07dc26bSmrg  fi
3425e07dc26bSmrg}
3426e07dc26bSmrg# end func_convert_path_cygwin_to_w32
3427e07dc26bSmrg
3428e07dc26bSmrg
3429e07dc26bSmrg# func_convert_path_nix_to_w32 ARG
3430e07dc26bSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
3431e07dc26bSmrg# a working winepath.  Returns result in func_to_host_file_result.
3432e07dc26bSmrgfunc_convert_path_nix_to_w32 ()
3433e07dc26bSmrg{
3434e07dc26bSmrg  $debug_cmd
3435e07dc26bSmrg
3436e07dc26bSmrg  func_to_host_path_result=$1
3437e07dc26bSmrg  if test -n "$1"; then
3438e07dc26bSmrg    # See func_convert_path_msys_to_w32:
3439e07dc26bSmrg    func_stripname : : "$1"
3440e07dc26bSmrg    func_to_host_path_tmp1=$func_stripname_result
3441e07dc26bSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3442e07dc26bSmrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3443e07dc26bSmrg    func_convert_path_check : ";" \
3444e07dc26bSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3445e07dc26bSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3446e07dc26bSmrg  fi
3447e07dc26bSmrg}
3448e07dc26bSmrg# end func_convert_path_nix_to_w32
3449e07dc26bSmrg
3450e07dc26bSmrg
3451e07dc26bSmrg# func_convert_path_msys_to_cygwin ARG
3452e07dc26bSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3453e07dc26bSmrg# Returns result in func_to_host_file_result.
3454e07dc26bSmrgfunc_convert_path_msys_to_cygwin ()
3455e07dc26bSmrg{
3456e07dc26bSmrg  $debug_cmd
3457e07dc26bSmrg
3458e07dc26bSmrg  func_to_host_path_result=$1
3459e07dc26bSmrg  if test -n "$1"; then
3460e07dc26bSmrg    # See func_convert_path_msys_to_w32:
3461e07dc26bSmrg    func_stripname : : "$1"
3462e07dc26bSmrg    func_to_host_path_tmp1=$func_stripname_result
3463e07dc26bSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3464e07dc26bSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
3465e07dc26bSmrg    func_to_host_path_result=$func_cygpath_result
3466e07dc26bSmrg    func_convert_path_check : : \
3467e07dc26bSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3468e07dc26bSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3469e07dc26bSmrg  fi
3470e07dc26bSmrg}
3471e07dc26bSmrg# end func_convert_path_msys_to_cygwin
3472e07dc26bSmrg
3473e07dc26bSmrg
3474e07dc26bSmrg# func_convert_path_nix_to_cygwin ARG
3475e07dc26bSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
3476e07dc26bSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
3477e07dc26bSmrg# func_to_host_file_result.
3478e07dc26bSmrgfunc_convert_path_nix_to_cygwin ()
3479e07dc26bSmrg{
3480e07dc26bSmrg  $debug_cmd
3481e07dc26bSmrg
3482e07dc26bSmrg  func_to_host_path_result=$1
3483e07dc26bSmrg  if test -n "$1"; then
3484e07dc26bSmrg    # Remove leading and trailing path separator characters from
3485e07dc26bSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
3486e07dc26bSmrg    # into '.;' and ';.', and winepath ignores them completely.
3487e07dc26bSmrg    func_stripname : : "$1"
3488e07dc26bSmrg    func_to_host_path_tmp1=$func_stripname_result
3489e07dc26bSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3490e07dc26bSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
3491e07dc26bSmrg    func_to_host_path_result=$func_cygpath_result
3492e07dc26bSmrg    func_convert_path_check : : \
3493e07dc26bSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3494e07dc26bSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3495e07dc26bSmrg  fi
3496e07dc26bSmrg}
3497e07dc26bSmrg# end func_convert_path_nix_to_cygwin
3498e07dc26bSmrg
3499e07dc26bSmrg
3500e07dc26bSmrg# func_dll_def_p FILE
3501e07dc26bSmrg# True iff FILE is a Windows DLL '.def' file.
3502e07dc26bSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
3503e07dc26bSmrgfunc_dll_def_p ()
3504e07dc26bSmrg{
3505e07dc26bSmrg  $debug_cmd
3506e07dc26bSmrg
3507e07dc26bSmrg  func_dll_def_p_tmp=`$SED -n \
3508e07dc26bSmrg    -e 's/^[	 ]*//' \
3509e07dc26bSmrg    -e '/^\(;.*\)*$/d' \
3510e07dc26bSmrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
3511e07dc26bSmrg    -e q \
3512e07dc26bSmrg    "$1"`
3513e07dc26bSmrg  test DEF = "$func_dll_def_p_tmp"
3514e07dc26bSmrg}
3515e07dc26bSmrg
3516e07dc26bSmrg
3517e07dc26bSmrg# func_mode_compile arg...
3518e07dc26bSmrgfunc_mode_compile ()
3519e07dc26bSmrg{
3520e07dc26bSmrg    $debug_cmd
3521e07dc26bSmrg
3522e07dc26bSmrg    # Get the compilation command and the source file.
3523e07dc26bSmrg    base_compile=
3524e07dc26bSmrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
3525e07dc26bSmrg    suppress_opt=yes
3526e07dc26bSmrg    suppress_output=
3527e07dc26bSmrg    arg_mode=normal
3528e07dc26bSmrg    libobj=
3529e07dc26bSmrg    later=
3530e07dc26bSmrg    pie_flag=
3531e07dc26bSmrg
3532e07dc26bSmrg    for arg
3533e07dc26bSmrg    do
3534e07dc26bSmrg      case $arg_mode in
3535e07dc26bSmrg      arg  )
3536e07dc26bSmrg	# do not "continue".  Instead, add this to base_compile
3537e07dc26bSmrg	lastarg=$arg
3538e07dc26bSmrg	arg_mode=normal
3539e07dc26bSmrg	;;
3540e07dc26bSmrg
3541e07dc26bSmrg      target )
3542e07dc26bSmrg	libobj=$arg
3543e07dc26bSmrg	arg_mode=normal
3544e07dc26bSmrg	continue
3545e07dc26bSmrg	;;
3546e07dc26bSmrg
3547e07dc26bSmrg      normal )
3548e07dc26bSmrg	# Accept any command-line options.
3549e07dc26bSmrg	case $arg in
3550e07dc26bSmrg	-o)
3551e07dc26bSmrg	  test -n "$libobj" && \
3552e07dc26bSmrg	    func_fatal_error "you cannot specify '-o' more than once"
3553e07dc26bSmrg	  arg_mode=target
3554e07dc26bSmrg	  continue
3555e07dc26bSmrg	  ;;
3556e07dc26bSmrg
3557e07dc26bSmrg	-pie | -fpie | -fPIE)
3558e07dc26bSmrg          func_append pie_flag " $arg"
3559e07dc26bSmrg	  continue
3560e07dc26bSmrg	  ;;
3561e07dc26bSmrg
3562e07dc26bSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
3563e07dc26bSmrg	  func_append later " $arg"
3564e07dc26bSmrg	  continue
3565e07dc26bSmrg	  ;;
3566e07dc26bSmrg
3567e07dc26bSmrg	-no-suppress)
3568e07dc26bSmrg	  suppress_opt=no
3569e07dc26bSmrg	  continue
3570e07dc26bSmrg	  ;;
3571e07dc26bSmrg
3572e07dc26bSmrg	-Xcompiler)
3573e07dc26bSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
3574e07dc26bSmrg	  continue      #  The current "srcfile" will either be retained or
3575e07dc26bSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
3576e07dc26bSmrg
3577e07dc26bSmrg	-Wc,*)
3578e07dc26bSmrg	  func_stripname '-Wc,' '' "$arg"
3579e07dc26bSmrg	  args=$func_stripname_result
3580e07dc26bSmrg	  lastarg=
3581e07dc26bSmrg	  save_ifs=$IFS; IFS=,
3582e07dc26bSmrg	  for arg in $args; do
3583e07dc26bSmrg	    IFS=$save_ifs
3584e07dc26bSmrg	    func_append_quoted lastarg "$arg"
3585e07dc26bSmrg	  done
3586e07dc26bSmrg	  IFS=$save_ifs
3587e07dc26bSmrg	  func_stripname ' ' '' "$lastarg"
3588e07dc26bSmrg	  lastarg=$func_stripname_result
3589e07dc26bSmrg
3590e07dc26bSmrg	  # Add the arguments to base_compile.
3591e07dc26bSmrg	  func_append base_compile " $lastarg"
3592e07dc26bSmrg	  continue
3593e07dc26bSmrg	  ;;
3594e07dc26bSmrg
3595e07dc26bSmrg	*)
3596e07dc26bSmrg	  # Accept the current argument as the source file.
3597e07dc26bSmrg	  # The previous "srcfile" becomes the current argument.
3598e07dc26bSmrg	  #
3599e07dc26bSmrg	  lastarg=$srcfile
3600e07dc26bSmrg	  srcfile=$arg
3601e07dc26bSmrg	  ;;
3602e07dc26bSmrg	esac  #  case $arg
3603e07dc26bSmrg	;;
3604e07dc26bSmrg      esac    #  case $arg_mode
3605e07dc26bSmrg
3606e07dc26bSmrg      # Aesthetically quote the previous argument.
3607e07dc26bSmrg      func_append_quoted base_compile "$lastarg"
3608e07dc26bSmrg    done # for arg
3609e07dc26bSmrg
3610e07dc26bSmrg    case $arg_mode in
3611e07dc26bSmrg    arg)
3612e07dc26bSmrg      func_fatal_error "you must specify an argument for -Xcompile"
3613e07dc26bSmrg      ;;
3614e07dc26bSmrg    target)
3615e07dc26bSmrg      func_fatal_error "you must specify a target with '-o'"
3616e07dc26bSmrg      ;;
3617e07dc26bSmrg    *)
3618e07dc26bSmrg      # Get the name of the library object.
3619e07dc26bSmrg      test -z "$libobj" && {
3620e07dc26bSmrg	func_basename "$srcfile"
3621e07dc26bSmrg	libobj=$func_basename_result
3622e07dc26bSmrg      }
3623e07dc26bSmrg      ;;
3624e07dc26bSmrg    esac
3625e07dc26bSmrg
3626e07dc26bSmrg    # Recognize several different file suffixes.
3627e07dc26bSmrg    # If the user specifies -o file.o, it is replaced with file.lo
3628e07dc26bSmrg    case $libobj in
3629e07dc26bSmrg    *.[cCFSifmso] | \
3630e07dc26bSmrg    *.ada | *.adb | *.ads | *.asm | \
3631e07dc26bSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3632e07dc26bSmrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
3633e07dc26bSmrg      func_xform "$libobj"
3634e07dc26bSmrg      libobj=$func_xform_result
3635e07dc26bSmrg      ;;
3636e07dc26bSmrg    esac
3637e07dc26bSmrg
3638e07dc26bSmrg    case $libobj in
3639e07dc26bSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3640e07dc26bSmrg    *)
3641e07dc26bSmrg      func_fatal_error "cannot determine name of library object from '$libobj'"
3642e07dc26bSmrg      ;;
3643e07dc26bSmrg    esac
3644e07dc26bSmrg
3645e07dc26bSmrg    func_infer_tag $base_compile
3646e07dc26bSmrg
3647e07dc26bSmrg    for arg in $later; do
3648e07dc26bSmrg      case $arg in
3649e07dc26bSmrg      -shared)
3650e07dc26bSmrg	test yes = "$build_libtool_libs" \
3651e07dc26bSmrg	  || func_fatal_configuration "cannot build a shared library"
3652e07dc26bSmrg	build_old_libs=no
3653e07dc26bSmrg	continue
3654e07dc26bSmrg	;;
3655e07dc26bSmrg
3656e07dc26bSmrg      -static)
3657e07dc26bSmrg	build_libtool_libs=no
3658e07dc26bSmrg	build_old_libs=yes
3659e07dc26bSmrg	continue
3660e07dc26bSmrg	;;
3661e07dc26bSmrg
3662e07dc26bSmrg      -prefer-pic)
3663e07dc26bSmrg	pic_mode=yes
3664e07dc26bSmrg	continue
3665e07dc26bSmrg	;;
3666e07dc26bSmrg
3667e07dc26bSmrg      -prefer-non-pic)
3668e07dc26bSmrg	pic_mode=no
3669e07dc26bSmrg	continue
3670e07dc26bSmrg	;;
3671e07dc26bSmrg      esac
3672e07dc26bSmrg    done
3673e07dc26bSmrg
3674636c353eSmrg    func_quote_arg pretty "$libobj"
3675636c353eSmrg    test "X$libobj" != "X$func_quote_arg_result" \
3676e07dc26bSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
3677e07dc26bSmrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
3678e07dc26bSmrg    func_dirname_and_basename "$obj" "/" ""
3679e07dc26bSmrg    objname=$func_basename_result
3680e07dc26bSmrg    xdir=$func_dirname_result
3681e07dc26bSmrg    lobj=$xdir$objdir/$objname
3682e07dc26bSmrg
3683e07dc26bSmrg    test -z "$base_compile" && \
3684e07dc26bSmrg      func_fatal_help "you must specify a compilation command"
3685e07dc26bSmrg
3686e07dc26bSmrg    # Delete any leftover library objects.
3687e07dc26bSmrg    if test yes = "$build_old_libs"; then
3688e07dc26bSmrg      removelist="$obj $lobj $libobj ${libobj}T"
3689e07dc26bSmrg    else
3690e07dc26bSmrg      removelist="$lobj $libobj ${libobj}T"
3691e07dc26bSmrg    fi
3692e07dc26bSmrg
3693e07dc26bSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
3694e07dc26bSmrg    case $host_os in
3695e07dc26bSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
3696e07dc26bSmrg      pic_mode=default
3697e07dc26bSmrg      ;;
3698e07dc26bSmrg    esac
3699e07dc26bSmrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3700e07dc26bSmrg      # non-PIC code in shared libraries is not supported
3701e07dc26bSmrg      pic_mode=default
3702e07dc26bSmrg    fi
3703e07dc26bSmrg
3704e07dc26bSmrg    # Calculate the filename of the output object if compiler does
3705e07dc26bSmrg    # not support -o with -c
3706e07dc26bSmrg    if test no = "$compiler_c_o"; then
3707e07dc26bSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
3708e07dc26bSmrg      lockfile=$output_obj.lock
3709e07dc26bSmrg    else
3710e07dc26bSmrg      output_obj=
3711e07dc26bSmrg      need_locks=no
3712e07dc26bSmrg      lockfile=
3713e07dc26bSmrg    fi
3714e07dc26bSmrg
3715e07dc26bSmrg    # Lock this critical section if it is needed
3716e07dc26bSmrg    # We use this script file to make the link, it avoids creating a new file
3717e07dc26bSmrg    if test yes = "$need_locks"; then
3718e07dc26bSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3719e07dc26bSmrg	func_echo "Waiting for $lockfile to be removed"
3720e07dc26bSmrg	sleep 2
3721e07dc26bSmrg      done
3722e07dc26bSmrg    elif test warn = "$need_locks"; then
3723e07dc26bSmrg      if test -f "$lockfile"; then
3724e07dc26bSmrg	$ECHO "\
3725e07dc26bSmrg*** ERROR, $lockfile exists and contains:
3726e07dc26bSmrg`cat $lockfile 2>/dev/null`
3727e07dc26bSmrg
3728e07dc26bSmrgThis indicates that another process is trying to use the same
3729e07dc26bSmrgtemporary object file, and libtool could not work around it because
3730e07dc26bSmrgyour compiler does not support '-c' and '-o' together.  If you
3731e07dc26bSmrgrepeat this compilation, it may succeed, by chance, but you had better
3732e07dc26bSmrgavoid parallel builds (make -j) in this platform, or get a better
3733e07dc26bSmrgcompiler."
3734e07dc26bSmrg
3735e07dc26bSmrg	$opt_dry_run || $RM $removelist
3736e07dc26bSmrg	exit $EXIT_FAILURE
3737e07dc26bSmrg      fi
3738e07dc26bSmrg      func_append removelist " $output_obj"
3739e07dc26bSmrg      $ECHO "$srcfile" > "$lockfile"
3740e07dc26bSmrg    fi
3741e07dc26bSmrg
3742e07dc26bSmrg    $opt_dry_run || $RM $removelist
3743e07dc26bSmrg    func_append removelist " $lockfile"
3744e07dc26bSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
3745e07dc26bSmrg
3746e07dc26bSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3747e07dc26bSmrg    srcfile=$func_to_tool_file_result
3748636c353eSmrg    func_quote_arg pretty "$srcfile"
3749636c353eSmrg    qsrcfile=$func_quote_arg_result
3750e07dc26bSmrg
3751e07dc26bSmrg    # Only build a PIC object if we are building libtool libraries.
3752e07dc26bSmrg    if test yes = "$build_libtool_libs"; then
3753e07dc26bSmrg      # Without this assignment, base_compile gets emptied.
3754e07dc26bSmrg      fbsd_hideous_sh_bug=$base_compile
3755e07dc26bSmrg
3756e07dc26bSmrg      if test no != "$pic_mode"; then
3757e07dc26bSmrg	command="$base_compile $qsrcfile $pic_flag"
3758e07dc26bSmrg      else
3759e07dc26bSmrg	# Don't build PIC code
3760e07dc26bSmrg	command="$base_compile $qsrcfile"
3761e07dc26bSmrg      fi
3762e07dc26bSmrg
3763e07dc26bSmrg      func_mkdir_p "$xdir$objdir"
3764e07dc26bSmrg
3765e07dc26bSmrg      if test -z "$output_obj"; then
3766e07dc26bSmrg	# Place PIC objects in $objdir
3767e07dc26bSmrg	func_append command " -o $lobj"
3768e07dc26bSmrg      fi
3769e07dc26bSmrg
3770e07dc26bSmrg      func_show_eval_locale "$command"	\
3771e07dc26bSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3772e07dc26bSmrg
3773e07dc26bSmrg      if test warn = "$need_locks" &&
3774e07dc26bSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3775e07dc26bSmrg	$ECHO "\
3776e07dc26bSmrg*** ERROR, $lockfile contains:
3777e07dc26bSmrg`cat $lockfile 2>/dev/null`
3778e07dc26bSmrg
3779e07dc26bSmrgbut it should contain:
3780e07dc26bSmrg$srcfile
3781e07dc26bSmrg
3782e07dc26bSmrgThis indicates that another process is trying to use the same
3783e07dc26bSmrgtemporary object file, and libtool could not work around it because
3784e07dc26bSmrgyour compiler does not support '-c' and '-o' together.  If you
3785e07dc26bSmrgrepeat this compilation, it may succeed, by chance, but you had better
3786e07dc26bSmrgavoid parallel builds (make -j) in this platform, or get a better
3787e07dc26bSmrgcompiler."
3788e07dc26bSmrg
3789e07dc26bSmrg	$opt_dry_run || $RM $removelist
3790e07dc26bSmrg	exit $EXIT_FAILURE
3791e07dc26bSmrg      fi
3792e07dc26bSmrg
3793e07dc26bSmrg      # Just move the object if needed, then go on to compile the next one
3794e07dc26bSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
3795e07dc26bSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
3796e07dc26bSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3797e07dc26bSmrg      fi
3798e07dc26bSmrg
3799e07dc26bSmrg      # Allow error messages only from the first compilation.
3800e07dc26bSmrg      if test yes = "$suppress_opt"; then
3801e07dc26bSmrg	suppress_output=' >/dev/null 2>&1'
3802e07dc26bSmrg      fi
3803e07dc26bSmrg    fi
3804e07dc26bSmrg
3805e07dc26bSmrg    # Only build a position-dependent object if we build old libraries.
3806e07dc26bSmrg    if test yes = "$build_old_libs"; then
3807e07dc26bSmrg      if test yes != "$pic_mode"; then
3808e07dc26bSmrg	# Don't build PIC code
3809e07dc26bSmrg	command="$base_compile $qsrcfile$pie_flag"
3810e07dc26bSmrg      else
3811e07dc26bSmrg	command="$base_compile $qsrcfile $pic_flag"
3812e07dc26bSmrg      fi
3813e07dc26bSmrg      if test yes = "$compiler_c_o"; then
3814e07dc26bSmrg	func_append command " -o $obj"
3815e07dc26bSmrg      fi
3816e07dc26bSmrg
3817e07dc26bSmrg      # Suppress compiler output if we already did a PIC compilation.
3818e07dc26bSmrg      func_append command "$suppress_output"
3819e07dc26bSmrg      func_show_eval_locale "$command" \
3820e07dc26bSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3821e07dc26bSmrg
3822e07dc26bSmrg      if test warn = "$need_locks" &&
3823e07dc26bSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3824e07dc26bSmrg	$ECHO "\
3825e07dc26bSmrg*** ERROR, $lockfile contains:
3826e07dc26bSmrg`cat $lockfile 2>/dev/null`
3827e07dc26bSmrg
3828e07dc26bSmrgbut it should contain:
3829e07dc26bSmrg$srcfile
3830e07dc26bSmrg
3831e07dc26bSmrgThis indicates that another process is trying to use the same
3832e07dc26bSmrgtemporary object file, and libtool could not work around it because
3833e07dc26bSmrgyour compiler does not support '-c' and '-o' together.  If you
3834e07dc26bSmrgrepeat this compilation, it may succeed, by chance, but you had better
3835e07dc26bSmrgavoid parallel builds (make -j) in this platform, or get a better
3836e07dc26bSmrgcompiler."
3837e07dc26bSmrg
3838e07dc26bSmrg	$opt_dry_run || $RM $removelist
3839e07dc26bSmrg	exit $EXIT_FAILURE
3840e07dc26bSmrg      fi
3841e07dc26bSmrg
3842e07dc26bSmrg      # Just move the object if needed
3843e07dc26bSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
3844e07dc26bSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
3845e07dc26bSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3846e07dc26bSmrg      fi
3847e07dc26bSmrg    fi
3848e07dc26bSmrg
3849e07dc26bSmrg    $opt_dry_run || {
3850e07dc26bSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3851e07dc26bSmrg
3852e07dc26bSmrg      # Unlock the critical section if it was locked
3853e07dc26bSmrg      if test no != "$need_locks"; then
3854e07dc26bSmrg	removelist=$lockfile
3855e07dc26bSmrg        $RM "$lockfile"
3856e07dc26bSmrg      fi
3857e07dc26bSmrg    }
3858e07dc26bSmrg
3859e07dc26bSmrg    exit $EXIT_SUCCESS
3860e07dc26bSmrg}
3861e07dc26bSmrg
3862e07dc26bSmrg$opt_help || {
3863e07dc26bSmrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
3864e07dc26bSmrg}
3865e07dc26bSmrg
3866e07dc26bSmrgfunc_mode_help ()
3867e07dc26bSmrg{
3868e07dc26bSmrg    # We need to display help for each of the modes.
3869e07dc26bSmrg    case $opt_mode in
3870e07dc26bSmrg      "")
3871e07dc26bSmrg        # Generic help is extracted from the usage comments
3872e07dc26bSmrg        # at the start of this file.
3873e07dc26bSmrg        func_help
3874e07dc26bSmrg        ;;
3875e07dc26bSmrg
3876e07dc26bSmrg      clean)
3877e07dc26bSmrg        $ECHO \
3878e07dc26bSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3879e07dc26bSmrg
3880e07dc26bSmrgRemove files from the build directory.
3881e07dc26bSmrg
3882e07dc26bSmrgRM is the name of the program to use to delete files associated with each FILE
3883e07dc26bSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
3884e07dc26bSmrgto RM.
3885e07dc26bSmrg
3886e07dc26bSmrgIf FILE is a libtool library, object or program, all the files associated
3887e07dc26bSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
3888e07dc26bSmrg        ;;
3889e07dc26bSmrg
3890e07dc26bSmrg      compile)
3891e07dc26bSmrg      $ECHO \
3892e07dc26bSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3893e07dc26bSmrg
3894e07dc26bSmrgCompile a source file into a libtool library object.
3895e07dc26bSmrg
3896e07dc26bSmrgThis mode accepts the following additional options:
3897e07dc26bSmrg
3898e07dc26bSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
3899e07dc26bSmrg  -no-suppress      do not suppress compiler output for multiple passes
3900e07dc26bSmrg  -prefer-pic       try to build PIC objects only
3901e07dc26bSmrg  -prefer-non-pic   try to build non-PIC objects only
3902e07dc26bSmrg  -shared           do not build a '.o' file suitable for static linking
3903e07dc26bSmrg  -static           only build a '.o' file suitable for static linking
3904636c353eSmrg  -Wc,FLAG
3905636c353eSmrg  -Xcompiler FLAG   pass FLAG directly to the compiler
3906e07dc26bSmrg
3907e07dc26bSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
3908e07dc26bSmrgfrom the given SOURCEFILE.
3909e07dc26bSmrg
3910e07dc26bSmrgThe output file name is determined by removing the directory component from
3911e07dc26bSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
3912e07dc26bSmrglibrary object suffix, '.lo'."
3913e07dc26bSmrg        ;;
3914e07dc26bSmrg
3915e07dc26bSmrg      execute)
3916e07dc26bSmrg        $ECHO \
3917e07dc26bSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3918e07dc26bSmrg
3919e07dc26bSmrgAutomatically set library path, then run a program.
3920e07dc26bSmrg
3921e07dc26bSmrgThis mode accepts the following additional options:
3922e07dc26bSmrg
3923e07dc26bSmrg  -dlopen FILE      add the directory containing FILE to the library path
3924e07dc26bSmrg
3925e07dc26bSmrgThis mode sets the library path environment variable according to '-dlopen'
3926e07dc26bSmrgflags.
3927e07dc26bSmrg
3928e07dc26bSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
3929e07dc26bSmrginto their corresponding uninstalled binary, and any of their required library
3930e07dc26bSmrgdirectories are added to the library path.
3931e07dc26bSmrg
3932e07dc26bSmrgThen, COMMAND is executed, with ARGS as arguments."
3933e07dc26bSmrg        ;;
3934e07dc26bSmrg
3935e07dc26bSmrg      finish)
3936e07dc26bSmrg        $ECHO \
3937e07dc26bSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3938e07dc26bSmrg
3939e07dc26bSmrgComplete the installation of libtool libraries.
3940e07dc26bSmrg
3941e07dc26bSmrgEach LIBDIR is a directory that contains libtool libraries.
3942e07dc26bSmrg
3943e07dc26bSmrgThe commands that this mode executes may require superuser privileges.  Use
3944e07dc26bSmrgthe '--dry-run' option if you just want to see what would be executed."
3945e07dc26bSmrg        ;;
3946e07dc26bSmrg
3947e07dc26bSmrg      install)
3948e07dc26bSmrg        $ECHO \
3949e07dc26bSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3950e07dc26bSmrg
3951e07dc26bSmrgInstall executables or libraries.
3952e07dc26bSmrg
3953e07dc26bSmrgINSTALL-COMMAND is the installation command.  The first component should be
3954e07dc26bSmrgeither the 'install' or 'cp' program.
3955e07dc26bSmrg
3956e07dc26bSmrgThe following components of INSTALL-COMMAND are treated specially:
3957e07dc26bSmrg
3958e07dc26bSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
3959e07dc26bSmrg
3960e07dc26bSmrgThe rest of the components are interpreted as arguments to that command (only
3961e07dc26bSmrgBSD-compatible install options are recognized)."
3962e07dc26bSmrg        ;;
3963e07dc26bSmrg
3964e07dc26bSmrg      link)
3965e07dc26bSmrg        $ECHO \
3966e07dc26bSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3967e07dc26bSmrg
3968e07dc26bSmrgLink object files or libraries together to form another library, or to
3969e07dc26bSmrgcreate an executable program.
3970e07dc26bSmrg
3971e07dc26bSmrgLINK-COMMAND is a command using the C compiler that you would use to create
3972e07dc26bSmrga program from several object files.
3973e07dc26bSmrg
3974e07dc26bSmrgThe following components of LINK-COMMAND are treated specially:
3975e07dc26bSmrg
3976e07dc26bSmrg  -all-static       do not do any dynamic linking at all
3977e07dc26bSmrg  -avoid-version    do not add a version suffix if possible
3978e07dc26bSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
3979e07dc26bSmrg                    libraries must be found in the PATH setting at runtime)
3980e07dc26bSmrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
3981e07dc26bSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
3982e07dc26bSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3983e07dc26bSmrg  -export-symbols SYMFILE
3984e07dc26bSmrg                    try to export only the symbols listed in SYMFILE
3985e07dc26bSmrg  -export-symbols-regex REGEX
3986e07dc26bSmrg                    try to export only the symbols matching REGEX
3987e07dc26bSmrg  -LLIBDIR          search LIBDIR for required installed libraries
3988e07dc26bSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
3989e07dc26bSmrg  -module           build a library that can dlopened
3990e07dc26bSmrg  -no-fast-install  disable the fast-install mode
3991e07dc26bSmrg  -no-install       link a not-installable executable
3992e07dc26bSmrg  -no-undefined     declare that a library does not refer to external symbols
3993e07dc26bSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
3994e07dc26bSmrg  -objectlist FILE  use a list of object files found in FILE to specify objects
3995e07dc26bSmrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
3996e07dc26bSmrg  -precious-files-regex REGEX
3997e07dc26bSmrg                    don't remove output files matching REGEX
3998e07dc26bSmrg  -release RELEASE  specify package release information
3999e07dc26bSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
4000e07dc26bSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
4001e07dc26bSmrg  -shared           only do dynamic linking of libtool libraries
4002e07dc26bSmrg  -shrext SUFFIX    override the standard shared library file extension
4003e07dc26bSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
4004e07dc26bSmrg  -static-libtool-libs
4005e07dc26bSmrg                    do not do any dynamic linking of libtool libraries
4006e07dc26bSmrg  -version-info CURRENT[:REVISION[:AGE]]
4007e07dc26bSmrg                    specify library version info [each variable defaults to 0]
4008e07dc26bSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
4009e07dc26bSmrg  -Wc,FLAG
4010e07dc26bSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
4011636c353eSmrg  -Wa,FLAG
4012636c353eSmrg  -Xassembler FLAG  pass linker-specific FLAG directly to the assembler
4013e07dc26bSmrg  -Wl,FLAG
4014e07dc26bSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
4015e07dc26bSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
4016e07dc26bSmrg
4017e07dc26bSmrgAll other options (arguments beginning with '-') are ignored.
4018e07dc26bSmrg
4019e07dc26bSmrgEvery other argument is treated as a filename.  Files ending in '.la' are
4020e07dc26bSmrgtreated as uninstalled libtool libraries, other files are standard or library
4021e07dc26bSmrgobject files.
4022e07dc26bSmrg
4023e07dc26bSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
4024e07dc26bSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is
4025e07dc26bSmrgrequired, except when creating a convenience library.
4026e07dc26bSmrg
4027e07dc26bSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
4028e07dc26bSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
4029e07dc26bSmrg
4030e07dc26bSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
4031e07dc26bSmrgis created, otherwise an executable program is created."
4032e07dc26bSmrg        ;;
4033e07dc26bSmrg
4034e07dc26bSmrg      uninstall)
4035e07dc26bSmrg        $ECHO \
4036e07dc26bSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
4037e07dc26bSmrg
4038e07dc26bSmrgRemove libraries from an installation directory.
4039e07dc26bSmrg
4040e07dc26bSmrgRM is the name of the program to use to delete files associated with each FILE
4041e07dc26bSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
4042e07dc26bSmrgto RM.
4043e07dc26bSmrg
4044e07dc26bSmrgIf FILE is a libtool library, all the files associated with it are deleted.
4045e07dc26bSmrgOtherwise, only FILE itself is deleted using RM."
4046e07dc26bSmrg        ;;
4047e07dc26bSmrg
4048e07dc26bSmrg      *)
4049e07dc26bSmrg        func_fatal_help "invalid operation mode '$opt_mode'"
4050e07dc26bSmrg        ;;
4051e07dc26bSmrg    esac
4052e07dc26bSmrg
4053e07dc26bSmrg    echo
4054e07dc26bSmrg    $ECHO "Try '$progname --help' for more information about other modes."
4055e07dc26bSmrg}
4056e07dc26bSmrg
4057e07dc26bSmrg# Now that we've collected a possible --mode arg, show help if necessary
4058e07dc26bSmrgif $opt_help; then
4059e07dc26bSmrg  if test : = "$opt_help"; then
4060e07dc26bSmrg    func_mode_help
4061e07dc26bSmrg  else
4062e07dc26bSmrg    {
4063e07dc26bSmrg      func_help noexit
4064e07dc26bSmrg      for opt_mode in compile link execute install finish uninstall clean; do
4065e07dc26bSmrg	func_mode_help
4066e07dc26bSmrg      done
4067e07dc26bSmrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
4068e07dc26bSmrg    {
4069e07dc26bSmrg      func_help noexit
4070e07dc26bSmrg      for opt_mode in compile link execute install finish uninstall clean; do
4071e07dc26bSmrg	echo
4072e07dc26bSmrg	func_mode_help
4073e07dc26bSmrg      done
4074e07dc26bSmrg    } |
4075e07dc26bSmrg    $SED '1d
4076e07dc26bSmrg      /^When reporting/,/^Report/{
4077e07dc26bSmrg	H
4078e07dc26bSmrg	d
4079e07dc26bSmrg      }
4080e07dc26bSmrg      $x
4081e07dc26bSmrg      /information about other modes/d
4082e07dc26bSmrg      /more detailed .*MODE/d
4083e07dc26bSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
4084e07dc26bSmrg  fi
4085e07dc26bSmrg  exit $?
4086e07dc26bSmrgfi
4087e07dc26bSmrg
4088e07dc26bSmrg
4089e07dc26bSmrg# func_mode_execute arg...
4090e07dc26bSmrgfunc_mode_execute ()
4091e07dc26bSmrg{
4092e07dc26bSmrg    $debug_cmd
4093e07dc26bSmrg
4094e07dc26bSmrg    # The first argument is the command name.
4095e07dc26bSmrg    cmd=$nonopt
4096e07dc26bSmrg    test -z "$cmd" && \
4097e07dc26bSmrg      func_fatal_help "you must specify a COMMAND"
4098e07dc26bSmrg
4099e07dc26bSmrg    # Handle -dlopen flags immediately.
4100e07dc26bSmrg    for file in $opt_dlopen; do
4101e07dc26bSmrg      test -f "$file" \
4102e07dc26bSmrg	|| func_fatal_help "'$file' is not a file"
4103e07dc26bSmrg
4104e07dc26bSmrg      dir=
4105e07dc26bSmrg      case $file in
4106e07dc26bSmrg      *.la)
4107e07dc26bSmrg	func_resolve_sysroot "$file"
4108e07dc26bSmrg	file=$func_resolve_sysroot_result
4109e07dc26bSmrg
4110e07dc26bSmrg	# Check to see that this really is a libtool archive.
4111e07dc26bSmrg	func_lalib_unsafe_p "$file" \
4112e07dc26bSmrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
4113e07dc26bSmrg
4114e07dc26bSmrg	# Read the libtool library.
4115e07dc26bSmrg	dlname=
4116e07dc26bSmrg	library_names=
4117e07dc26bSmrg	func_source "$file"
4118e07dc26bSmrg
4119e07dc26bSmrg	# Skip this library if it cannot be dlopened.
4120e07dc26bSmrg	if test -z "$dlname"; then
4121e07dc26bSmrg	  # Warn if it was a shared library.
4122e07dc26bSmrg	  test -n "$library_names" && \
4123e07dc26bSmrg	    func_warning "'$file' was not linked with '-export-dynamic'"
4124e07dc26bSmrg	  continue
4125e07dc26bSmrg	fi
4126e07dc26bSmrg
4127e07dc26bSmrg	func_dirname "$file" "" "."
4128e07dc26bSmrg	dir=$func_dirname_result
4129e07dc26bSmrg
4130e07dc26bSmrg	if test -f "$dir/$objdir/$dlname"; then
4131e07dc26bSmrg	  func_append dir "/$objdir"
4132e07dc26bSmrg	else
4133e07dc26bSmrg	  if test ! -f "$dir/$dlname"; then
4134e07dc26bSmrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
4135e07dc26bSmrg	  fi
4136e07dc26bSmrg	fi
4137e07dc26bSmrg	;;
4138e07dc26bSmrg
4139e07dc26bSmrg      *.lo)
4140e07dc26bSmrg	# Just add the directory containing the .lo file.
4141e07dc26bSmrg	func_dirname "$file" "" "."
4142e07dc26bSmrg	dir=$func_dirname_result
4143e07dc26bSmrg	;;
4144e07dc26bSmrg
4145e07dc26bSmrg      *)
4146e07dc26bSmrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
4147e07dc26bSmrg	continue
4148e07dc26bSmrg	;;
4149e07dc26bSmrg      esac
4150e07dc26bSmrg
4151e07dc26bSmrg      # Get the absolute pathname.
4152e07dc26bSmrg      absdir=`cd "$dir" && pwd`
4153e07dc26bSmrg      test -n "$absdir" && dir=$absdir
4154e07dc26bSmrg
4155e07dc26bSmrg      # Now add the directory to shlibpath_var.
4156e07dc26bSmrg      if eval "test -z \"\$$shlibpath_var\""; then
4157e07dc26bSmrg	eval "$shlibpath_var=\"\$dir\""
4158e07dc26bSmrg      else
4159e07dc26bSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
4160e07dc26bSmrg      fi
4161e07dc26bSmrg    done
4162e07dc26bSmrg
4163e07dc26bSmrg    # This variable tells wrapper scripts just to set shlibpath_var
4164e07dc26bSmrg    # rather than running their programs.
4165e07dc26bSmrg    libtool_execute_magic=$magic
4166e07dc26bSmrg
4167e07dc26bSmrg    # Check if any of the arguments is a wrapper script.
4168e07dc26bSmrg    args=
4169e07dc26bSmrg    for file
4170e07dc26bSmrg    do
4171e07dc26bSmrg      case $file in
4172e07dc26bSmrg      -* | *.la | *.lo ) ;;
4173e07dc26bSmrg      *)
4174e07dc26bSmrg	# Do a test to see if this is really a libtool program.
4175e07dc26bSmrg	if func_ltwrapper_script_p "$file"; then
4176e07dc26bSmrg	  func_source "$file"
4177e07dc26bSmrg	  # Transform arg to wrapped name.
4178e07dc26bSmrg	  file=$progdir/$program
4179e07dc26bSmrg	elif func_ltwrapper_executable_p "$file"; then
4180e07dc26bSmrg	  func_ltwrapper_scriptname "$file"
4181e07dc26bSmrg	  func_source "$func_ltwrapper_scriptname_result"
4182e07dc26bSmrg	  # Transform arg to wrapped name.
4183e07dc26bSmrg	  file=$progdir/$program
4184e07dc26bSmrg	fi
4185e07dc26bSmrg	;;
4186e07dc26bSmrg      esac
4187e07dc26bSmrg      # Quote arguments (to preserve shell metacharacters).
4188e07dc26bSmrg      func_append_quoted args "$file"
4189e07dc26bSmrg    done
4190e07dc26bSmrg
4191e07dc26bSmrg    if $opt_dry_run; then
4192e07dc26bSmrg      # Display what would be done.
4193e07dc26bSmrg      if test -n "$shlibpath_var"; then
4194e07dc26bSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
4195e07dc26bSmrg	echo "export $shlibpath_var"
4196e07dc26bSmrg      fi
4197e07dc26bSmrg      $ECHO "$cmd$args"
4198e07dc26bSmrg      exit $EXIT_SUCCESS
4199e07dc26bSmrg    else
4200e07dc26bSmrg      if test -n "$shlibpath_var"; then
4201e07dc26bSmrg	# Export the shlibpath_var.
4202e07dc26bSmrg	eval "export $shlibpath_var"
4203e07dc26bSmrg      fi
4204e07dc26bSmrg
4205e07dc26bSmrg      # Restore saved environment variables
4206e07dc26bSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
4207e07dc26bSmrg      do
4208e07dc26bSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
4209e07dc26bSmrg                $lt_var=\$save_$lt_var; export $lt_var
4210e07dc26bSmrg	      else
4211e07dc26bSmrg		$lt_unset $lt_var
4212e07dc26bSmrg	      fi"
4213e07dc26bSmrg      done
4214e07dc26bSmrg
4215e07dc26bSmrg      # Now prepare to actually exec the command.
4216e07dc26bSmrg      exec_cmd=\$cmd$args
4217e07dc26bSmrg    fi
4218e07dc26bSmrg}
4219e07dc26bSmrg
4220e07dc26bSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
4221e07dc26bSmrg
4222e07dc26bSmrg
4223e07dc26bSmrg# func_mode_finish arg...
4224e07dc26bSmrgfunc_mode_finish ()
4225e07dc26bSmrg{
4226e07dc26bSmrg    $debug_cmd
4227e07dc26bSmrg
4228e07dc26bSmrg    libs=
4229e07dc26bSmrg    libdirs=
4230e07dc26bSmrg    admincmds=
4231e07dc26bSmrg
4232e07dc26bSmrg    for opt in "$nonopt" ${1+"$@"}
4233e07dc26bSmrg    do
4234e07dc26bSmrg      if test -d "$opt"; then
4235e07dc26bSmrg	func_append libdirs " $opt"
4236e07dc26bSmrg
4237e07dc26bSmrg      elif test -f "$opt"; then
4238e07dc26bSmrg	if func_lalib_unsafe_p "$opt"; then
4239e07dc26bSmrg	  func_append libs " $opt"
4240e07dc26bSmrg	else
4241e07dc26bSmrg	  func_warning "'$opt' is not a valid libtool archive"
4242e07dc26bSmrg	fi
4243e07dc26bSmrg
4244e07dc26bSmrg      else
4245e07dc26bSmrg	func_fatal_error "invalid argument '$opt'"
4246e07dc26bSmrg      fi
4247e07dc26bSmrg    done
4248e07dc26bSmrg
4249e07dc26bSmrg    if test -n "$libs"; then
4250e07dc26bSmrg      if test -n "$lt_sysroot"; then
4251e07dc26bSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
4252e07dc26bSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
4253e07dc26bSmrg      else
4254e07dc26bSmrg        sysroot_cmd=
4255e07dc26bSmrg      fi
4256e07dc26bSmrg
4257e07dc26bSmrg      # Remove sysroot references
4258e07dc26bSmrg      if $opt_dry_run; then
4259e07dc26bSmrg        for lib in $libs; do
4260e07dc26bSmrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4261e07dc26bSmrg        done
4262e07dc26bSmrg      else
4263e07dc26bSmrg        tmpdir=`func_mktempdir`
4264e07dc26bSmrg        for lib in $libs; do
4265e07dc26bSmrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4266e07dc26bSmrg	    > $tmpdir/tmp-la
4267e07dc26bSmrg	  mv -f $tmpdir/tmp-la $lib
4268e07dc26bSmrg	done
4269e07dc26bSmrg        ${RM}r "$tmpdir"
4270e07dc26bSmrg      fi
4271e07dc26bSmrg    fi
4272e07dc26bSmrg
4273e07dc26bSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4274e07dc26bSmrg      for libdir in $libdirs; do
4275e07dc26bSmrg	if test -n "$finish_cmds"; then
4276e07dc26bSmrg	  # Do each command in the finish commands.
4277e07dc26bSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
4278e07dc26bSmrg'"$cmd"'"'
4279e07dc26bSmrg	fi
4280e07dc26bSmrg	if test -n "$finish_eval"; then
4281e07dc26bSmrg	  # Do the single finish_eval.
4282e07dc26bSmrg	  eval cmds=\"$finish_eval\"
4283e07dc26bSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
4284e07dc26bSmrg       $cmds"
4285e07dc26bSmrg	fi
4286e07dc26bSmrg      done
4287e07dc26bSmrg    fi
4288e07dc26bSmrg
4289e07dc26bSmrg    # Exit here if they wanted silent mode.
4290e07dc26bSmrg    $opt_quiet && exit $EXIT_SUCCESS
4291e07dc26bSmrg
4292e07dc26bSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4293e07dc26bSmrg      echo "----------------------------------------------------------------------"
4294e07dc26bSmrg      echo "Libraries have been installed in:"
4295e07dc26bSmrg      for libdir in $libdirs; do
4296e07dc26bSmrg	$ECHO "   $libdir"
4297e07dc26bSmrg      done
4298e07dc26bSmrg      echo
4299e07dc26bSmrg      echo "If you ever happen to want to link against installed libraries"
4300e07dc26bSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
4301e07dc26bSmrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4302e07dc26bSmrg      echo "flag during linking and do at least one of the following:"
4303e07dc26bSmrg      if test -n "$shlibpath_var"; then
4304e07dc26bSmrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
4305e07dc26bSmrg	echo "     during execution"
4306e07dc26bSmrg      fi
4307e07dc26bSmrg      if test -n "$runpath_var"; then
4308e07dc26bSmrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
4309e07dc26bSmrg	echo "     during linking"
4310e07dc26bSmrg      fi
4311e07dc26bSmrg      if test -n "$hardcode_libdir_flag_spec"; then
4312e07dc26bSmrg	libdir=LIBDIR
4313e07dc26bSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
4314e07dc26bSmrg
4315e07dc26bSmrg	$ECHO "   - use the '$flag' linker flag"
4316e07dc26bSmrg      fi
4317e07dc26bSmrg      if test -n "$admincmds"; then
4318e07dc26bSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
4319e07dc26bSmrg      fi
4320e07dc26bSmrg      if test -f /etc/ld.so.conf; then
4321e07dc26bSmrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4322e07dc26bSmrg      fi
4323e07dc26bSmrg      echo
4324e07dc26bSmrg
4325e07dc26bSmrg      echo "See any operating system documentation about shared libraries for"
4326e07dc26bSmrg      case $host in
4327e07dc26bSmrg	solaris2.[6789]|solaris2.1[0-9])
4328e07dc26bSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4329e07dc26bSmrg	  echo "pages."
4330e07dc26bSmrg	  ;;
4331e07dc26bSmrg	*)
4332e07dc26bSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
4333e07dc26bSmrg	  ;;
4334e07dc26bSmrg      esac
4335e07dc26bSmrg      echo "----------------------------------------------------------------------"
4336e07dc26bSmrg    fi
4337e07dc26bSmrg    exit $EXIT_SUCCESS
4338e07dc26bSmrg}
4339e07dc26bSmrg
4340e07dc26bSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
4341e07dc26bSmrg
4342e07dc26bSmrg
4343e07dc26bSmrg# func_mode_install arg...
4344e07dc26bSmrgfunc_mode_install ()
4345e07dc26bSmrg{
4346e07dc26bSmrg    $debug_cmd
4347e07dc26bSmrg
4348e07dc26bSmrg    # There may be an optional sh(1) argument at the beginning of
4349e07dc26bSmrg    # install_prog (especially on Windows NT).
4350e07dc26bSmrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
4351e07dc26bSmrg       # Allow the use of GNU shtool's install command.
4352e07dc26bSmrg       case $nonopt in *shtool*) :;; *) false;; esac
4353e07dc26bSmrg    then
4354e07dc26bSmrg      # Aesthetically quote it.
4355636c353eSmrg      func_quote_arg pretty "$nonopt"
4356636c353eSmrg      install_prog="$func_quote_arg_result "
4357e07dc26bSmrg      arg=$1
4358e07dc26bSmrg      shift
4359e07dc26bSmrg    else
4360e07dc26bSmrg      install_prog=
4361e07dc26bSmrg      arg=$nonopt
4362e07dc26bSmrg    fi
4363e07dc26bSmrg
4364e07dc26bSmrg    # The real first argument should be the name of the installation program.
4365e07dc26bSmrg    # Aesthetically quote it.
4366636c353eSmrg    func_quote_arg pretty "$arg"
4367636c353eSmrg    func_append install_prog "$func_quote_arg_result"
4368e07dc26bSmrg    install_shared_prog=$install_prog
4369e07dc26bSmrg    case " $install_prog " in
4370e07dc26bSmrg      *[\\\ /]cp\ *) install_cp=: ;;
4371e07dc26bSmrg      *) install_cp=false ;;
4372e07dc26bSmrg    esac
4373e07dc26bSmrg
4374e07dc26bSmrg    # We need to accept at least all the BSD install flags.
4375e07dc26bSmrg    dest=
4376e07dc26bSmrg    files=
4377e07dc26bSmrg    opts=
4378e07dc26bSmrg    prev=
4379e07dc26bSmrg    install_type=
4380e07dc26bSmrg    isdir=false
4381e07dc26bSmrg    stripme=
4382e07dc26bSmrg    no_mode=:
4383e07dc26bSmrg    for arg
4384e07dc26bSmrg    do
4385e07dc26bSmrg      arg2=
4386e07dc26bSmrg      if test -n "$dest"; then
4387e07dc26bSmrg	func_append files " $dest"
4388e07dc26bSmrg	dest=$arg
4389e07dc26bSmrg	continue
4390e07dc26bSmrg      fi
4391e07dc26bSmrg
4392e07dc26bSmrg      case $arg in
4393e07dc26bSmrg      -d) isdir=: ;;
4394e07dc26bSmrg      -f)
4395e07dc26bSmrg	if $install_cp; then :; else
4396e07dc26bSmrg	  prev=$arg
4397e07dc26bSmrg	fi
4398e07dc26bSmrg	;;
4399e07dc26bSmrg      -g | -m | -o)
4400e07dc26bSmrg	prev=$arg
4401e07dc26bSmrg	;;
4402e07dc26bSmrg      -s)
4403e07dc26bSmrg	stripme=" -s"
4404e07dc26bSmrg	continue
4405e07dc26bSmrg	;;
4406e07dc26bSmrg      -*)
4407e07dc26bSmrg	;;
4408e07dc26bSmrg      *)
4409e07dc26bSmrg	# If the previous option needed an argument, then skip it.
4410e07dc26bSmrg	if test -n "$prev"; then
4411e07dc26bSmrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
4412e07dc26bSmrg	    arg2=$install_override_mode
4413e07dc26bSmrg	    no_mode=false
4414e07dc26bSmrg	  fi
4415e07dc26bSmrg	  prev=
4416e07dc26bSmrg	else
4417e07dc26bSmrg	  dest=$arg
4418e07dc26bSmrg	  continue
4419e07dc26bSmrg	fi
4420e07dc26bSmrg	;;
4421e07dc26bSmrg      esac
4422e07dc26bSmrg
4423e07dc26bSmrg      # Aesthetically quote the argument.
4424636c353eSmrg      func_quote_arg pretty "$arg"
4425636c353eSmrg      func_append install_prog " $func_quote_arg_result"
4426e07dc26bSmrg      if test -n "$arg2"; then
4427636c353eSmrg	func_quote_arg pretty "$arg2"
4428e07dc26bSmrg      fi
4429636c353eSmrg      func_append install_shared_prog " $func_quote_arg_result"
4430e07dc26bSmrg    done
4431e07dc26bSmrg
4432e07dc26bSmrg    test -z "$install_prog" && \
4433e07dc26bSmrg      func_fatal_help "you must specify an install program"
4434e07dc26bSmrg
4435e07dc26bSmrg    test -n "$prev" && \
4436e07dc26bSmrg      func_fatal_help "the '$prev' option requires an argument"
4437e07dc26bSmrg
4438e07dc26bSmrg    if test -n "$install_override_mode" && $no_mode; then
4439e07dc26bSmrg      if $install_cp; then :; else
4440636c353eSmrg	func_quote_arg pretty "$install_override_mode"
4441636c353eSmrg	func_append install_shared_prog " -m $func_quote_arg_result"
4442e07dc26bSmrg      fi
4443e07dc26bSmrg    fi
4444e07dc26bSmrg
4445e07dc26bSmrg    if test -z "$files"; then
4446e07dc26bSmrg      if test -z "$dest"; then
4447e07dc26bSmrg	func_fatal_help "no file or destination specified"
4448e07dc26bSmrg      else
4449e07dc26bSmrg	func_fatal_help "you must specify a destination"
4450e07dc26bSmrg      fi
4451e07dc26bSmrg    fi
4452e07dc26bSmrg
4453e07dc26bSmrg    # Strip any trailing slash from the destination.
4454e07dc26bSmrg    func_stripname '' '/' "$dest"
4455e07dc26bSmrg    dest=$func_stripname_result
4456e07dc26bSmrg
4457e07dc26bSmrg    # Check to see that the destination is a directory.
4458e07dc26bSmrg    test -d "$dest" && isdir=:
4459e07dc26bSmrg    if $isdir; then
4460e07dc26bSmrg      destdir=$dest
4461e07dc26bSmrg      destname=
4462e07dc26bSmrg    else
4463e07dc26bSmrg      func_dirname_and_basename "$dest" "" "."
4464e07dc26bSmrg      destdir=$func_dirname_result
4465e07dc26bSmrg      destname=$func_basename_result
4466e07dc26bSmrg
4467e07dc26bSmrg      # Not a directory, so check to see that there is only one file specified.
4468e07dc26bSmrg      set dummy $files; shift
4469e07dc26bSmrg      test "$#" -gt 1 && \
4470e07dc26bSmrg	func_fatal_help "'$dest' is not a directory"
4471e07dc26bSmrg    fi
4472e07dc26bSmrg    case $destdir in
4473e07dc26bSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
4474e07dc26bSmrg    *)
4475e07dc26bSmrg      for file in $files; do
4476e07dc26bSmrg	case $file in
4477e07dc26bSmrg	*.lo) ;;
4478e07dc26bSmrg	*)
4479e07dc26bSmrg	  func_fatal_help "'$destdir' must be an absolute directory name"
4480e07dc26bSmrg	  ;;
4481e07dc26bSmrg	esac
4482e07dc26bSmrg      done
4483e07dc26bSmrg      ;;
4484e07dc26bSmrg    esac
4485e07dc26bSmrg
4486e07dc26bSmrg    # This variable tells wrapper scripts just to set variables rather
4487e07dc26bSmrg    # than running their programs.
4488e07dc26bSmrg    libtool_install_magic=$magic
4489e07dc26bSmrg
4490e07dc26bSmrg    staticlibs=
4491e07dc26bSmrg    future_libdirs=
4492e07dc26bSmrg    current_libdirs=
4493e07dc26bSmrg    for file in $files; do
4494e07dc26bSmrg
4495e07dc26bSmrg      # Do each installation.
4496e07dc26bSmrg      case $file in
4497e07dc26bSmrg      *.$libext)
4498e07dc26bSmrg	# Do the static libraries later.
4499e07dc26bSmrg	func_append staticlibs " $file"
4500e07dc26bSmrg	;;
4501e07dc26bSmrg
4502e07dc26bSmrg      *.la)
4503e07dc26bSmrg	func_resolve_sysroot "$file"
4504e07dc26bSmrg	file=$func_resolve_sysroot_result
4505e07dc26bSmrg
4506e07dc26bSmrg	# Check to see that this really is a libtool archive.
4507e07dc26bSmrg	func_lalib_unsafe_p "$file" \
4508e07dc26bSmrg	  || func_fatal_help "'$file' is not a valid libtool archive"
4509e07dc26bSmrg
4510e07dc26bSmrg	library_names=
4511e07dc26bSmrg	old_library=
4512e07dc26bSmrg	relink_command=
4513e07dc26bSmrg	func_source "$file"
4514e07dc26bSmrg
4515e07dc26bSmrg	# Add the libdir to current_libdirs if it is the destination.
4516e07dc26bSmrg	if test "X$destdir" = "X$libdir"; then
4517e07dc26bSmrg	  case "$current_libdirs " in
4518e07dc26bSmrg	  *" $libdir "*) ;;
4519e07dc26bSmrg	  *) func_append current_libdirs " $libdir" ;;
4520e07dc26bSmrg	  esac
4521e07dc26bSmrg	else
4522e07dc26bSmrg	  # Note the libdir as a future libdir.
4523e07dc26bSmrg	  case "$future_libdirs " in
4524e07dc26bSmrg	  *" $libdir "*) ;;
4525e07dc26bSmrg	  *) func_append future_libdirs " $libdir" ;;
4526e07dc26bSmrg	  esac
4527e07dc26bSmrg	fi
4528e07dc26bSmrg
4529e07dc26bSmrg	func_dirname "$file" "/" ""
4530e07dc26bSmrg	dir=$func_dirname_result
4531e07dc26bSmrg	func_append dir "$objdir"
4532e07dc26bSmrg
4533e07dc26bSmrg	if test -n "$relink_command"; then
4534e07dc26bSmrg	  # Determine the prefix the user has applied to our future dir.
4535e07dc26bSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
4536e07dc26bSmrg
4537e07dc26bSmrg	  # Don't allow the user to place us outside of our expected
4538e07dc26bSmrg	  # location b/c this prevents finding dependent libraries that
4539e07dc26bSmrg	  # are installed to the same prefix.
4540e07dc26bSmrg	  # At present, this check doesn't affect windows .dll's that
4541e07dc26bSmrg	  # are installed into $libdir/../bin (currently, that works fine)
4542e07dc26bSmrg	  # but it's something to keep an eye on.
4543e07dc26bSmrg	  test "$inst_prefix_dir" = "$destdir" && \
4544e07dc26bSmrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
4545e07dc26bSmrg
4546e07dc26bSmrg	  if test -n "$inst_prefix_dir"; then
4547e07dc26bSmrg	    # Stick the inst_prefix_dir data into the link command.
4548e07dc26bSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
4549e07dc26bSmrg	  else
4550e07dc26bSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
4551e07dc26bSmrg	  fi
4552e07dc26bSmrg
4553e07dc26bSmrg	  func_warning "relinking '$file'"
4554e07dc26bSmrg	  func_show_eval "$relink_command" \
4555e07dc26bSmrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
4556e07dc26bSmrg	fi
4557e07dc26bSmrg
4558e07dc26bSmrg	# See the names of the shared library.
4559e07dc26bSmrg	set dummy $library_names; shift
4560e07dc26bSmrg	if test -n "$1"; then
4561e07dc26bSmrg	  realname=$1
4562e07dc26bSmrg	  shift
4563e07dc26bSmrg
4564e07dc26bSmrg	  srcname=$realname
4565e07dc26bSmrg	  test -n "$relink_command" && srcname=${realname}T
4566e07dc26bSmrg
4567e07dc26bSmrg	  # Install the shared library and build the symlinks.
4568e07dc26bSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
4569e07dc26bSmrg	      'exit $?'
4570e07dc26bSmrg	  tstripme=$stripme
4571e07dc26bSmrg	  case $host_os in
4572e07dc26bSmrg	  cygwin* | mingw* | pw32* | cegcc*)
4573e07dc26bSmrg	    case $realname in
4574e07dc26bSmrg	    *.dll.a)
4575e07dc26bSmrg	      tstripme=
4576e07dc26bSmrg	      ;;
4577e07dc26bSmrg	    esac
4578e07dc26bSmrg	    ;;
4579e07dc26bSmrg	  os2*)
4580e07dc26bSmrg	    case $realname in
4581e07dc26bSmrg	    *_dll.a)
4582e07dc26bSmrg	      tstripme=
4583e07dc26bSmrg	      ;;
4584e07dc26bSmrg	    esac
4585e07dc26bSmrg	    ;;
4586e07dc26bSmrg	  esac
4587e07dc26bSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
4588e07dc26bSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
4589e07dc26bSmrg	  fi
4590e07dc26bSmrg
4591e07dc26bSmrg	  if test "$#" -gt 0; then
4592e07dc26bSmrg	    # Delete the old symlinks, and create new ones.
4593e07dc26bSmrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
4594e07dc26bSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
4595e07dc26bSmrg	    # so we also need to try rm && ln -s.
4596e07dc26bSmrg	    for linkname
4597e07dc26bSmrg	    do
4598e07dc26bSmrg	      test "$linkname" != "$realname" \
4599e07dc26bSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4600e07dc26bSmrg	    done
4601e07dc26bSmrg	  fi
4602e07dc26bSmrg
4603e07dc26bSmrg	  # Do each command in the postinstall commands.
4604e07dc26bSmrg	  lib=$destdir/$realname
4605e07dc26bSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
4606e07dc26bSmrg	fi
4607e07dc26bSmrg
4608e07dc26bSmrg	# Install the pseudo-library for information purposes.
4609e07dc26bSmrg	func_basename "$file"
4610e07dc26bSmrg	name=$func_basename_result
4611e07dc26bSmrg	instname=$dir/${name}i
4612e07dc26bSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4613e07dc26bSmrg
4614e07dc26bSmrg	# Maybe install the static library, too.
4615e07dc26bSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
4616e07dc26bSmrg	;;
4617e07dc26bSmrg
4618e07dc26bSmrg      *.lo)
4619e07dc26bSmrg	# Install (i.e. copy) a libtool object.
4620e07dc26bSmrg
4621e07dc26bSmrg	# Figure out destination file name, if it wasn't already specified.
4622e07dc26bSmrg	if test -n "$destname"; then
4623e07dc26bSmrg	  destfile=$destdir/$destname
4624e07dc26bSmrg	else
4625e07dc26bSmrg	  func_basename "$file"
4626e07dc26bSmrg	  destfile=$func_basename_result
4627e07dc26bSmrg	  destfile=$destdir/$destfile
4628e07dc26bSmrg	fi
4629e07dc26bSmrg
4630e07dc26bSmrg	# Deduce the name of the destination old-style object file.
4631e07dc26bSmrg	case $destfile in
4632e07dc26bSmrg	*.lo)
4633e07dc26bSmrg	  func_lo2o "$destfile"
4634e07dc26bSmrg	  staticdest=$func_lo2o_result
4635e07dc26bSmrg	  ;;
4636e07dc26bSmrg	*.$objext)
4637e07dc26bSmrg	  staticdest=$destfile
4638e07dc26bSmrg	  destfile=
4639e07dc26bSmrg	  ;;
4640e07dc26bSmrg	*)
4641e07dc26bSmrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
4642e07dc26bSmrg	  ;;
4643e07dc26bSmrg	esac
4644e07dc26bSmrg
4645e07dc26bSmrg	# Install the libtool object if requested.
4646e07dc26bSmrg	test -n "$destfile" && \
4647e07dc26bSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
4648e07dc26bSmrg
4649e07dc26bSmrg	# Install the old object if enabled.
4650e07dc26bSmrg	if test yes = "$build_old_libs"; then
4651e07dc26bSmrg	  # Deduce the name of the old-style object file.
4652e07dc26bSmrg	  func_lo2o "$file"
4653e07dc26bSmrg	  staticobj=$func_lo2o_result
4654e07dc26bSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4655e07dc26bSmrg	fi
4656e07dc26bSmrg	exit $EXIT_SUCCESS
4657e07dc26bSmrg	;;
4658e07dc26bSmrg
4659e07dc26bSmrg      *)
4660e07dc26bSmrg	# Figure out destination file name, if it wasn't already specified.
4661e07dc26bSmrg	if test -n "$destname"; then
4662e07dc26bSmrg	  destfile=$destdir/$destname
4663e07dc26bSmrg	else
4664e07dc26bSmrg	  func_basename "$file"
4665e07dc26bSmrg	  destfile=$func_basename_result
4666e07dc26bSmrg	  destfile=$destdir/$destfile
4667e07dc26bSmrg	fi
4668e07dc26bSmrg
4669e07dc26bSmrg	# If the file is missing, and there is a .exe on the end, strip it
4670e07dc26bSmrg	# because it is most likely a libtool script we actually want to
4671e07dc26bSmrg	# install
4672e07dc26bSmrg	stripped_ext=
4673e07dc26bSmrg	case $file in
4674e07dc26bSmrg	  *.exe)
4675e07dc26bSmrg	    if test ! -f "$file"; then
4676e07dc26bSmrg	      func_stripname '' '.exe' "$file"
4677e07dc26bSmrg	      file=$func_stripname_result
4678e07dc26bSmrg	      stripped_ext=.exe
4679e07dc26bSmrg	    fi
4680e07dc26bSmrg	    ;;
4681e07dc26bSmrg	esac
4682e07dc26bSmrg
4683e07dc26bSmrg	# Do a test to see if this is really a libtool program.
4684e07dc26bSmrg	case $host in
4685e07dc26bSmrg	*cygwin* | *mingw*)
4686e07dc26bSmrg	    if func_ltwrapper_executable_p "$file"; then
4687e07dc26bSmrg	      func_ltwrapper_scriptname "$file"
4688e07dc26bSmrg	      wrapper=$func_ltwrapper_scriptname_result
4689e07dc26bSmrg	    else
4690e07dc26bSmrg	      func_stripname '' '.exe' "$file"
4691e07dc26bSmrg	      wrapper=$func_stripname_result
4692e07dc26bSmrg	    fi
4693e07dc26bSmrg	    ;;
4694e07dc26bSmrg	*)
4695e07dc26bSmrg	    wrapper=$file
4696e07dc26bSmrg	    ;;
4697e07dc26bSmrg	esac
4698e07dc26bSmrg	if func_ltwrapper_script_p "$wrapper"; then
4699e07dc26bSmrg	  notinst_deplibs=
4700e07dc26bSmrg	  relink_command=
4701e07dc26bSmrg
4702e07dc26bSmrg	  func_source "$wrapper"
4703e07dc26bSmrg
4704e07dc26bSmrg	  # Check the variables that should have been set.
4705e07dc26bSmrg	  test -z "$generated_by_libtool_version" && \
4706e07dc26bSmrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
4707e07dc26bSmrg
4708e07dc26bSmrg	  finalize=:
4709e07dc26bSmrg	  for lib in $notinst_deplibs; do
4710e07dc26bSmrg	    # Check to see that each library is installed.
4711e07dc26bSmrg	    libdir=
4712e07dc26bSmrg	    if test -f "$lib"; then
4713e07dc26bSmrg	      func_source "$lib"
4714e07dc26bSmrg	    fi
4715e07dc26bSmrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
4716e07dc26bSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
4717e07dc26bSmrg	      func_warning "'$lib' has not been installed in '$libdir'"
4718e07dc26bSmrg	      finalize=false
4719e07dc26bSmrg	    fi
4720e07dc26bSmrg	  done
4721e07dc26bSmrg
4722e07dc26bSmrg	  relink_command=
4723e07dc26bSmrg	  func_source "$wrapper"
4724e07dc26bSmrg
4725e07dc26bSmrg	  outputname=
4726e07dc26bSmrg	  if test no = "$fast_install" && test -n "$relink_command"; then
4727e07dc26bSmrg	    $opt_dry_run || {
4728e07dc26bSmrg	      if $finalize; then
4729e07dc26bSmrg	        tmpdir=`func_mktempdir`
4730e07dc26bSmrg		func_basename "$file$stripped_ext"
4731e07dc26bSmrg		file=$func_basename_result
4732e07dc26bSmrg	        outputname=$tmpdir/$file
4733e07dc26bSmrg	        # Replace the output file specification.
4734e07dc26bSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
4735e07dc26bSmrg
4736e07dc26bSmrg	        $opt_quiet || {
4737636c353eSmrg	          func_quote_arg expand,pretty "$relink_command"
4738636c353eSmrg		  eval "func_echo $func_quote_arg_result"
4739e07dc26bSmrg	        }
4740e07dc26bSmrg	        if eval "$relink_command"; then :
4741e07dc26bSmrg	          else
4742e07dc26bSmrg		  func_error "error: relink '$file' with the above command before installing it"
4743e07dc26bSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
4744e07dc26bSmrg		  continue
4745e07dc26bSmrg	        fi
4746e07dc26bSmrg	        file=$outputname
4747e07dc26bSmrg	      else
4748e07dc26bSmrg	        func_warning "cannot relink '$file'"
4749e07dc26bSmrg	      fi
4750e07dc26bSmrg	    }
4751e07dc26bSmrg	  else
4752e07dc26bSmrg	    # Install the binary that we compiled earlier.
4753e07dc26bSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4754e07dc26bSmrg	  fi
4755e07dc26bSmrg	fi
4756e07dc26bSmrg
4757e07dc26bSmrg	# remove .exe since cygwin /usr/bin/install will append another
4758e07dc26bSmrg	# one anyway
4759e07dc26bSmrg	case $install_prog,$host in
4760e07dc26bSmrg	*/usr/bin/install*,*cygwin*)
4761e07dc26bSmrg	  case $file:$destfile in
4762e07dc26bSmrg	  *.exe:*.exe)
4763e07dc26bSmrg	    # this is ok
4764e07dc26bSmrg	    ;;
4765e07dc26bSmrg	  *.exe:*)
4766e07dc26bSmrg	    destfile=$destfile.exe
4767e07dc26bSmrg	    ;;
4768e07dc26bSmrg	  *:*.exe)
4769e07dc26bSmrg	    func_stripname '' '.exe' "$destfile"
4770e07dc26bSmrg	    destfile=$func_stripname_result
4771e07dc26bSmrg	    ;;
4772e07dc26bSmrg	  esac
4773e07dc26bSmrg	  ;;
4774e07dc26bSmrg	esac
4775e07dc26bSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
4776e07dc26bSmrg	$opt_dry_run || if test -n "$outputname"; then
4777e07dc26bSmrg	  ${RM}r "$tmpdir"
4778e07dc26bSmrg	fi
4779e07dc26bSmrg	;;
4780e07dc26bSmrg      esac
4781e07dc26bSmrg    done
4782e07dc26bSmrg
4783e07dc26bSmrg    for file in $staticlibs; do
4784e07dc26bSmrg      func_basename "$file"
4785e07dc26bSmrg      name=$func_basename_result
4786e07dc26bSmrg
4787e07dc26bSmrg      # Set up the ranlib parameters.
4788e07dc26bSmrg      oldlib=$destdir/$name
4789e07dc26bSmrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4790e07dc26bSmrg      tool_oldlib=$func_to_tool_file_result
4791e07dc26bSmrg
4792e07dc26bSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
4793e07dc26bSmrg
4794e07dc26bSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
4795e07dc26bSmrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
4796e07dc26bSmrg      fi
4797e07dc26bSmrg
4798e07dc26bSmrg      # Do each command in the postinstall commands.
4799e07dc26bSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
4800e07dc26bSmrg    done
4801e07dc26bSmrg
4802e07dc26bSmrg    test -n "$future_libdirs" && \
4803e07dc26bSmrg      func_warning "remember to run '$progname --finish$future_libdirs'"
4804e07dc26bSmrg
4805e07dc26bSmrg    if test -n "$current_libdirs"; then
4806e07dc26bSmrg      # Maybe just do a dry run.
4807e07dc26bSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
4808e07dc26bSmrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
4809e07dc26bSmrg    else
4810e07dc26bSmrg      exit $EXIT_SUCCESS
4811e07dc26bSmrg    fi
4812e07dc26bSmrg}
4813e07dc26bSmrg
4814e07dc26bSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
4815e07dc26bSmrg
4816e07dc26bSmrg
4817e07dc26bSmrg# func_generate_dlsyms outputname originator pic_p
4818e07dc26bSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
4819e07dc26bSmrg# a dlpreopen symbol table.
4820e07dc26bSmrgfunc_generate_dlsyms ()
4821e07dc26bSmrg{
4822e07dc26bSmrg    $debug_cmd
4823e07dc26bSmrg
4824e07dc26bSmrg    my_outputname=$1
4825e07dc26bSmrg    my_originator=$2
4826e07dc26bSmrg    my_pic_p=${3-false}
4827e07dc26bSmrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
4828e07dc26bSmrg    my_dlsyms=
4829e07dc26bSmrg
4830e07dc26bSmrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
4831e07dc26bSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
4832e07dc26bSmrg	my_dlsyms=${my_outputname}S.c
4833e07dc26bSmrg      else
4834e07dc26bSmrg	func_error "not configured to extract global symbols from dlpreopened files"
4835e07dc26bSmrg      fi
4836e07dc26bSmrg    fi
4837e07dc26bSmrg
4838e07dc26bSmrg    if test -n "$my_dlsyms"; then
4839e07dc26bSmrg      case $my_dlsyms in
4840e07dc26bSmrg      "") ;;
4841e07dc26bSmrg      *.c)
4842e07dc26bSmrg	# Discover the nlist of each of the dlfiles.
4843e07dc26bSmrg	nlist=$output_objdir/$my_outputname.nm
4844e07dc26bSmrg
4845e07dc26bSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
4846e07dc26bSmrg
4847e07dc26bSmrg	# Parse the name list into a source file.
4848e07dc26bSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
4849e07dc26bSmrg
4850e07dc26bSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
4851e07dc26bSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
4852e07dc26bSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
4853e07dc26bSmrg
4854e07dc26bSmrg#ifdef __cplusplus
4855e07dc26bSmrgextern \"C\" {
4856e07dc26bSmrg#endif
4857e07dc26bSmrg
4858e07dc26bSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4859e07dc26bSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4860e07dc26bSmrg#endif
4861e07dc26bSmrg
4862e07dc26bSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
4863e07dc26bSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
4864e07dc26bSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
4865e07dc26bSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
4866e07dc26bSmrg# define LT_DLSYM_CONST
4867e07dc26bSmrg#elif defined __osf__
4868e07dc26bSmrg/* This system does not cope well with relocations in const data.  */
4869e07dc26bSmrg# define LT_DLSYM_CONST
4870e07dc26bSmrg#else
4871e07dc26bSmrg# define LT_DLSYM_CONST const
4872e07dc26bSmrg#endif
4873e07dc26bSmrg
4874e07dc26bSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
4875e07dc26bSmrg
4876e07dc26bSmrg/* External symbol declarations for the compiler. */\
4877e07dc26bSmrg"
4878e07dc26bSmrg
4879e07dc26bSmrg	if test yes = "$dlself"; then
4880e07dc26bSmrg	  func_verbose "generating symbol list for '$output'"
4881e07dc26bSmrg
4882e07dc26bSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
4883e07dc26bSmrg
4884e07dc26bSmrg	  # Add our own program objects to the symbol list.
4885e07dc26bSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
4886e07dc26bSmrg	  for progfile in $progfiles; do
4887e07dc26bSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
4888e07dc26bSmrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4889e07dc26bSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
4890e07dc26bSmrg	  done
4891e07dc26bSmrg
4892e07dc26bSmrg	  if test -n "$exclude_expsyms"; then
4893e07dc26bSmrg	    $opt_dry_run || {
4894e07dc26bSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4895e07dc26bSmrg	      eval '$MV "$nlist"T "$nlist"'
4896e07dc26bSmrg	    }
4897e07dc26bSmrg	  fi
4898e07dc26bSmrg
4899e07dc26bSmrg	  if test -n "$export_symbols_regex"; then
4900e07dc26bSmrg	    $opt_dry_run || {
4901e07dc26bSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4902e07dc26bSmrg	      eval '$MV "$nlist"T "$nlist"'
4903e07dc26bSmrg	    }
4904e07dc26bSmrg	  fi
4905e07dc26bSmrg
4906e07dc26bSmrg	  # Prepare the list of exported symbols
4907e07dc26bSmrg	  if test -z "$export_symbols"; then
4908e07dc26bSmrg	    export_symbols=$output_objdir/$outputname.exp
4909e07dc26bSmrg	    $opt_dry_run || {
4910e07dc26bSmrg	      $RM $export_symbols
4911e07dc26bSmrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4912e07dc26bSmrg	      case $host in
4913e07dc26bSmrg	      *cygwin* | *mingw* | *cegcc* )
4914e07dc26bSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4915e07dc26bSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4916e07dc26bSmrg	        ;;
4917e07dc26bSmrg	      esac
4918e07dc26bSmrg	    }
4919e07dc26bSmrg	  else
4920e07dc26bSmrg	    $opt_dry_run || {
4921e07dc26bSmrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4922e07dc26bSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4923e07dc26bSmrg	      eval '$MV "$nlist"T "$nlist"'
4924e07dc26bSmrg	      case $host in
4925e07dc26bSmrg	        *cygwin* | *mingw* | *cegcc* )
4926e07dc26bSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4927e07dc26bSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4928e07dc26bSmrg	          ;;
4929e07dc26bSmrg	      esac
4930e07dc26bSmrg	    }
4931e07dc26bSmrg	  fi
4932e07dc26bSmrg	fi
4933e07dc26bSmrg
4934e07dc26bSmrg	for dlprefile in $dlprefiles; do
4935e07dc26bSmrg	  func_verbose "extracting global C symbols from '$dlprefile'"
4936e07dc26bSmrg	  func_basename "$dlprefile"
4937e07dc26bSmrg	  name=$func_basename_result
4938e07dc26bSmrg          case $host in
4939e07dc26bSmrg	    *cygwin* | *mingw* | *cegcc* )
4940e07dc26bSmrg	      # if an import library, we need to obtain dlname
4941e07dc26bSmrg	      if func_win32_import_lib_p "$dlprefile"; then
4942e07dc26bSmrg	        func_tr_sh "$dlprefile"
4943e07dc26bSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
4944e07dc26bSmrg	        dlprefile_dlbasename=
4945e07dc26bSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4946e07dc26bSmrg	          # Use subshell, to avoid clobbering current variable values
4947e07dc26bSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
4948e07dc26bSmrg	          if test -n "$dlprefile_dlname"; then
4949e07dc26bSmrg	            func_basename "$dlprefile_dlname"
4950e07dc26bSmrg	            dlprefile_dlbasename=$func_basename_result
4951e07dc26bSmrg	          else
4952e07dc26bSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
4953e07dc26bSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
4954e07dc26bSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
4955e07dc26bSmrg	          fi
4956e07dc26bSmrg	        fi
4957e07dc26bSmrg	        $opt_dry_run || {
4958e07dc26bSmrg	          if test -n "$dlprefile_dlbasename"; then
4959e07dc26bSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4960e07dc26bSmrg	          else
4961e07dc26bSmrg	            func_warning "Could not compute DLL name from $name"
4962e07dc26bSmrg	            eval '$ECHO ": $name " >> "$nlist"'
4963e07dc26bSmrg	          fi
4964e07dc26bSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4965e07dc26bSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4966e07dc26bSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4967e07dc26bSmrg	        }
4968e07dc26bSmrg	      else # not an import lib
4969e07dc26bSmrg	        $opt_dry_run || {
4970e07dc26bSmrg	          eval '$ECHO ": $name " >> "$nlist"'
4971e07dc26bSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4972e07dc26bSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4973e07dc26bSmrg	        }
4974e07dc26bSmrg	      fi
4975e07dc26bSmrg	    ;;
4976e07dc26bSmrg	    *)
4977e07dc26bSmrg	      $opt_dry_run || {
4978e07dc26bSmrg	        eval '$ECHO ": $name " >> "$nlist"'
4979e07dc26bSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4980e07dc26bSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4981e07dc26bSmrg	      }
4982e07dc26bSmrg	    ;;
4983e07dc26bSmrg          esac
4984e07dc26bSmrg	done
4985e07dc26bSmrg
4986e07dc26bSmrg	$opt_dry_run || {
4987e07dc26bSmrg	  # Make sure we have at least an empty file.
4988e07dc26bSmrg	  test -f "$nlist" || : > "$nlist"
4989e07dc26bSmrg
4990e07dc26bSmrg	  if test -n "$exclude_expsyms"; then
4991e07dc26bSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4992e07dc26bSmrg	    $MV "$nlist"T "$nlist"
4993e07dc26bSmrg	  fi
4994e07dc26bSmrg
4995e07dc26bSmrg	  # Try sorting and uniquifying the output.
4996e07dc26bSmrg	  if $GREP -v "^: " < "$nlist" |
4997e07dc26bSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
4998e07dc26bSmrg		sort -k 3
4999e07dc26bSmrg	      else
5000e07dc26bSmrg		sort +2
5001e07dc26bSmrg	      fi |
5002e07dc26bSmrg	      uniq > "$nlist"S; then
5003e07dc26bSmrg	    :
5004e07dc26bSmrg	  else
5005e07dc26bSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
5006e07dc26bSmrg	  fi
5007e07dc26bSmrg
5008e07dc26bSmrg	  if test -f "$nlist"S; then
5009e07dc26bSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
5010e07dc26bSmrg	  else
5011e07dc26bSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
5012e07dc26bSmrg	  fi
5013e07dc26bSmrg
5014e07dc26bSmrg	  func_show_eval '$RM "${nlist}I"'
5015e07dc26bSmrg	  if test -n "$global_symbol_to_import"; then
5016e07dc26bSmrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
5017e07dc26bSmrg	  fi
5018e07dc26bSmrg
5019e07dc26bSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
5020e07dc26bSmrg
5021e07dc26bSmrg/* The mapping between symbol names and symbols.  */
5022e07dc26bSmrgtypedef struct {
5023e07dc26bSmrg  const char *name;
5024e07dc26bSmrg  void *address;
5025e07dc26bSmrg} lt_dlsymlist;
5026e07dc26bSmrgextern LT_DLSYM_CONST lt_dlsymlist
5027e07dc26bSmrglt_${my_prefix}_LTX_preloaded_symbols[];\
5028e07dc26bSmrg"
5029e07dc26bSmrg
5030e07dc26bSmrg	  if test -s "$nlist"I; then
5031e07dc26bSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
5032e07dc26bSmrgstatic void lt_syminit(void)
5033e07dc26bSmrg{
5034e07dc26bSmrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
5035e07dc26bSmrg  for (; symbol->name; ++symbol)
5036e07dc26bSmrg    {"
5037e07dc26bSmrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
5038e07dc26bSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
5039e07dc26bSmrg    }
5040e07dc26bSmrg}"
5041e07dc26bSmrg	  fi
5042e07dc26bSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
5043e07dc26bSmrgLT_DLSYM_CONST lt_dlsymlist
5044e07dc26bSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
5045e07dc26bSmrg{ {\"$my_originator\", (void *) 0},"
5046e07dc26bSmrg
5047e07dc26bSmrg	  if test -s "$nlist"I; then
5048e07dc26bSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
5049e07dc26bSmrg  {\"@INIT@\", (void *) &lt_syminit},"
5050e07dc26bSmrg	  fi
5051e07dc26bSmrg
5052e07dc26bSmrg	  case $need_lib_prefix in
5053e07dc26bSmrg	  no)
5054e07dc26bSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
5055e07dc26bSmrg	    ;;
5056e07dc26bSmrg	  *)
5057e07dc26bSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
5058e07dc26bSmrg	    ;;
5059e07dc26bSmrg	  esac
5060e07dc26bSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
5061e07dc26bSmrg  {0, (void *) 0}
5062e07dc26bSmrg};
5063e07dc26bSmrg
5064e07dc26bSmrg/* This works around a problem in FreeBSD linker */
5065e07dc26bSmrg#ifdef FREEBSD_WORKAROUND
5066e07dc26bSmrgstatic const void *lt_preloaded_setup() {
5067e07dc26bSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
5068e07dc26bSmrg}
5069e07dc26bSmrg#endif
5070e07dc26bSmrg
5071e07dc26bSmrg#ifdef __cplusplus
5072e07dc26bSmrg}
5073e07dc26bSmrg#endif\
5074e07dc26bSmrg"
5075e07dc26bSmrg	} # !$opt_dry_run
5076e07dc26bSmrg
5077e07dc26bSmrg	pic_flag_for_symtable=
5078e07dc26bSmrg	case "$compile_command " in
5079e07dc26bSmrg	*" -static "*) ;;
5080e07dc26bSmrg	*)
5081e07dc26bSmrg	  case $host in
5082e07dc26bSmrg	  # compiling the symbol table file with pic_flag works around
5083e07dc26bSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
5084e07dc26bSmrg	  # linked before any other PIC object.  But we must not use
5085e07dc26bSmrg	  # pic_flag when linking with -static.  The problem exists in
5086e07dc26bSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
5087e07dc26bSmrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
5088e07dc26bSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
5089e07dc26bSmrg	  *-*-hpux*)
5090e07dc26bSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
5091e07dc26bSmrg	  *)
5092e07dc26bSmrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
5093e07dc26bSmrg	    ;;
5094e07dc26bSmrg	  esac
5095e07dc26bSmrg	  ;;
5096e07dc26bSmrg	esac
5097e07dc26bSmrg	symtab_cflags=
5098e07dc26bSmrg	for arg in $LTCFLAGS; do
5099e07dc26bSmrg	  case $arg in
5100e07dc26bSmrg	  -pie | -fpie | -fPIE) ;;
5101e07dc26bSmrg	  *) func_append symtab_cflags " $arg" ;;
5102e07dc26bSmrg	  esac
5103e07dc26bSmrg	done
5104e07dc26bSmrg
5105e07dc26bSmrg	# Now compile the dynamic symbol file.
5106e07dc26bSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
5107e07dc26bSmrg
5108e07dc26bSmrg	# Clean up the generated files.
5109e07dc26bSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
5110e07dc26bSmrg
5111e07dc26bSmrg	# Transform the symbol file into the correct name.
5112e07dc26bSmrg	symfileobj=$output_objdir/${my_outputname}S.$objext
5113e07dc26bSmrg	case $host in
5114e07dc26bSmrg	*cygwin* | *mingw* | *cegcc* )
5115e07dc26bSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
5116e07dc26bSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
5117e07dc26bSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
5118e07dc26bSmrg	  else
5119e07dc26bSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
5120e07dc26bSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
5121e07dc26bSmrg	  fi
5122e07dc26bSmrg	  ;;
5123e07dc26bSmrg	*)
5124e07dc26bSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
5125e07dc26bSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
5126e07dc26bSmrg	  ;;
5127e07dc26bSmrg	esac
5128e07dc26bSmrg	;;
5129e07dc26bSmrg      *)
5130e07dc26bSmrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
5131e07dc26bSmrg	;;
5132e07dc26bSmrg      esac
5133e07dc26bSmrg    else
5134e07dc26bSmrg      # We keep going just in case the user didn't refer to
5135e07dc26bSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
5136e07dc26bSmrg      # really was required.
5137e07dc26bSmrg
5138e07dc26bSmrg      # Nullify the symbol file.
5139e07dc26bSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
5140e07dc26bSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
5141e07dc26bSmrg    fi
5142e07dc26bSmrg}
5143e07dc26bSmrg
5144e07dc26bSmrg# func_cygming_gnu_implib_p ARG
5145e07dc26bSmrg# This predicate returns with zero status (TRUE) if
5146e07dc26bSmrg# ARG is a GNU/binutils-style import library. Returns
5147e07dc26bSmrg# with nonzero status (FALSE) otherwise.
5148e07dc26bSmrgfunc_cygming_gnu_implib_p ()
5149e07dc26bSmrg{
5150e07dc26bSmrg  $debug_cmd
5151e07dc26bSmrg
5152e07dc26bSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
5153e07dc26bSmrg  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)$'`
5154e07dc26bSmrg  test -n "$func_cygming_gnu_implib_tmp"
5155e07dc26bSmrg}
5156e07dc26bSmrg
5157e07dc26bSmrg# func_cygming_ms_implib_p ARG
5158e07dc26bSmrg# This predicate returns with zero status (TRUE) if
5159e07dc26bSmrg# ARG is an MS-style import library. Returns
5160e07dc26bSmrg# with nonzero status (FALSE) otherwise.
5161e07dc26bSmrgfunc_cygming_ms_implib_p ()
5162e07dc26bSmrg{
5163e07dc26bSmrg  $debug_cmd
5164e07dc26bSmrg
5165e07dc26bSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
5166e07dc26bSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
5167e07dc26bSmrg  test -n "$func_cygming_ms_implib_tmp"
5168e07dc26bSmrg}
5169e07dc26bSmrg
5170e07dc26bSmrg# func_win32_libid arg
5171e07dc26bSmrg# return the library type of file 'arg'
5172e07dc26bSmrg#
5173e07dc26bSmrg# Need a lot of goo to handle *both* DLLs and import libs
5174e07dc26bSmrg# Has to be a shell function in order to 'eat' the argument
5175e07dc26bSmrg# that is supplied when $file_magic_command is called.
5176e07dc26bSmrg# Despite the name, also deal with 64 bit binaries.
5177e07dc26bSmrgfunc_win32_libid ()
5178e07dc26bSmrg{
5179e07dc26bSmrg  $debug_cmd
5180e07dc26bSmrg
5181e07dc26bSmrg  win32_libid_type=unknown
5182e07dc26bSmrg  win32_fileres=`file -L $1 2>/dev/null`
5183e07dc26bSmrg  case $win32_fileres in
5184e07dc26bSmrg  *ar\ archive\ import\ library*) # definitely import
5185e07dc26bSmrg    win32_libid_type="x86 archive import"
5186e07dc26bSmrg    ;;
5187e07dc26bSmrg  *ar\ archive*) # could be an import, or static
5188e07dc26bSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
5189e07dc26bSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
5190e07dc26bSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
5191e07dc26bSmrg      case $nm_interface in
5192e07dc26bSmrg      "MS dumpbin")
5193e07dc26bSmrg	if func_cygming_ms_implib_p "$1" ||
5194e07dc26bSmrg	   func_cygming_gnu_implib_p "$1"
5195e07dc26bSmrg	then
5196e07dc26bSmrg	  win32_nmres=import
5197e07dc26bSmrg	else
5198e07dc26bSmrg	  win32_nmres=
5199e07dc26bSmrg	fi
5200e07dc26bSmrg	;;
5201e07dc26bSmrg      *)
5202e07dc26bSmrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
5203e07dc26bSmrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
5204e07dc26bSmrg	  $SED -n -e '
5205e07dc26bSmrg	    1,100{
5206e07dc26bSmrg		/ I /{
5207e07dc26bSmrg		    s|.*|import|
5208e07dc26bSmrg		    p
5209e07dc26bSmrg		    q
5210e07dc26bSmrg		}
5211e07dc26bSmrg	    }'`
5212e07dc26bSmrg	;;
5213e07dc26bSmrg      esac
5214e07dc26bSmrg      case $win32_nmres in
5215e07dc26bSmrg      import*)  win32_libid_type="x86 archive import";;
5216e07dc26bSmrg      *)        win32_libid_type="x86 archive static";;
5217e07dc26bSmrg      esac
5218e07dc26bSmrg    fi
5219e07dc26bSmrg    ;;
5220e07dc26bSmrg  *DLL*)
5221e07dc26bSmrg    win32_libid_type="x86 DLL"
5222e07dc26bSmrg    ;;
5223e07dc26bSmrg  *executable*) # but shell scripts are "executable" too...
5224e07dc26bSmrg    case $win32_fileres in
5225e07dc26bSmrg    *MS\ Windows\ PE\ Intel*)
5226e07dc26bSmrg      win32_libid_type="x86 DLL"
5227e07dc26bSmrg      ;;
5228e07dc26bSmrg    esac
5229e07dc26bSmrg    ;;
5230e07dc26bSmrg  esac
5231e07dc26bSmrg  $ECHO "$win32_libid_type"
5232e07dc26bSmrg}
5233e07dc26bSmrg
5234e07dc26bSmrg# func_cygming_dll_for_implib ARG
5235e07dc26bSmrg#
5236e07dc26bSmrg# Platform-specific function to extract the
5237e07dc26bSmrg# name of the DLL associated with the specified
5238e07dc26bSmrg# import library ARG.
5239e07dc26bSmrg# Invoked by eval'ing the libtool variable
5240e07dc26bSmrg#    $sharedlib_from_linklib_cmd
5241e07dc26bSmrg# Result is available in the variable
5242e07dc26bSmrg#    $sharedlib_from_linklib_result
5243e07dc26bSmrgfunc_cygming_dll_for_implib ()
5244e07dc26bSmrg{
5245e07dc26bSmrg  $debug_cmd
5246e07dc26bSmrg
5247e07dc26bSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
5248e07dc26bSmrg}
5249e07dc26bSmrg
5250e07dc26bSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
5251e07dc26bSmrg#
5252e07dc26bSmrg# The is the core of a fallback implementation of a
5253e07dc26bSmrg# platform-specific function to extract the name of the
5254e07dc26bSmrg# DLL associated with the specified import library LIBNAME.
5255e07dc26bSmrg#
5256e07dc26bSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
5257e07dc26bSmrg# on the platform and compiler that created the implib.
5258e07dc26bSmrg#
5259e07dc26bSmrg# Echos the name of the DLL associated with the
5260e07dc26bSmrg# specified import library.
5261e07dc26bSmrgfunc_cygming_dll_for_implib_fallback_core ()
5262e07dc26bSmrg{
5263e07dc26bSmrg  $debug_cmd
5264e07dc26bSmrg
5265e07dc26bSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5266e07dc26bSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5267e07dc26bSmrg    $SED '/^Contents of section '"$match_literal"':/{
5268e07dc26bSmrg      # Place marker at beginning of archive member dllname section
5269e07dc26bSmrg      s/.*/====MARK====/
5270e07dc26bSmrg      p
5271e07dc26bSmrg      d
5272e07dc26bSmrg    }
5273e07dc26bSmrg    # These lines can sometimes be longer than 43 characters, but
5274e07dc26bSmrg    # are always uninteresting
5275e07dc26bSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
5276e07dc26bSmrg    /^In archive [^:]*:/d
5277e07dc26bSmrg    # Ensure marker is printed
5278e07dc26bSmrg    /^====MARK====/p
5279e07dc26bSmrg    # Remove all lines with less than 43 characters
5280e07dc26bSmrg    /^.\{43\}/!d
5281e07dc26bSmrg    # From remaining lines, remove first 43 characters
5282e07dc26bSmrg    s/^.\{43\}//' |
5283e07dc26bSmrg    $SED -n '
5284e07dc26bSmrg      # Join marker and all lines until next marker into a single line
5285e07dc26bSmrg      /^====MARK====/ b para
5286e07dc26bSmrg      H
5287e07dc26bSmrg      $ b para
5288e07dc26bSmrg      b
5289e07dc26bSmrg      :para
5290e07dc26bSmrg      x
5291e07dc26bSmrg      s/\n//g
5292e07dc26bSmrg      # Remove the marker
5293e07dc26bSmrg      s/^====MARK====//
5294e07dc26bSmrg      # Remove trailing dots and whitespace
5295e07dc26bSmrg      s/[\. \t]*$//
5296e07dc26bSmrg      # Print
5297e07dc26bSmrg      /./p' |
5298e07dc26bSmrg    # we now have a list, one entry per line, of the stringified
5299e07dc26bSmrg    # contents of the appropriate section of all members of the
5300e07dc26bSmrg    # archive that possess that section. Heuristic: eliminate
5301e07dc26bSmrg    # all those that have a first or second character that is
5302e07dc26bSmrg    # a '.' (that is, objdump's representation of an unprintable
5303e07dc26bSmrg    # character.) This should work for all archives with less than
5304e07dc26bSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
5305e07dc26bSmrg    # begins with a literal '.' or a single character followed by
5306e07dc26bSmrg    # a '.'.
5307e07dc26bSmrg    #
5308e07dc26bSmrg    # Of those that remain, print the first one.
5309e07dc26bSmrg    $SED -e '/^\./d;/^.\./d;q'
5310e07dc26bSmrg}
5311e07dc26bSmrg
5312e07dc26bSmrg# func_cygming_dll_for_implib_fallback ARG
5313e07dc26bSmrg# Platform-specific function to extract the
5314e07dc26bSmrg# name of the DLL associated with the specified
5315e07dc26bSmrg# import library ARG.
5316e07dc26bSmrg#
5317e07dc26bSmrg# This fallback implementation is for use when $DLLTOOL
5318e07dc26bSmrg# does not support the --identify-strict option.
5319e07dc26bSmrg# Invoked by eval'ing the libtool variable
5320e07dc26bSmrg#    $sharedlib_from_linklib_cmd
5321e07dc26bSmrg# Result is available in the variable
5322e07dc26bSmrg#    $sharedlib_from_linklib_result
5323e07dc26bSmrgfunc_cygming_dll_for_implib_fallback ()
5324e07dc26bSmrg{
5325e07dc26bSmrg  $debug_cmd
5326e07dc26bSmrg
5327e07dc26bSmrg  if func_cygming_gnu_implib_p "$1"; then
5328e07dc26bSmrg    # binutils import library
5329e07dc26bSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
5330e07dc26bSmrg  elif func_cygming_ms_implib_p "$1"; then
5331e07dc26bSmrg    # ms-generated import library
5332e07dc26bSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5333e07dc26bSmrg  else
5334e07dc26bSmrg    # unknown
5335e07dc26bSmrg    sharedlib_from_linklib_result=
5336e07dc26bSmrg  fi
5337e07dc26bSmrg}
5338e07dc26bSmrg
5339e07dc26bSmrg
5340e07dc26bSmrg# func_extract_an_archive dir oldlib
5341e07dc26bSmrgfunc_extract_an_archive ()
5342e07dc26bSmrg{
5343e07dc26bSmrg    $debug_cmd
5344e07dc26bSmrg
5345e07dc26bSmrg    f_ex_an_ar_dir=$1; shift
5346e07dc26bSmrg    f_ex_an_ar_oldlib=$1
5347e07dc26bSmrg    if test yes = "$lock_old_archive_extraction"; then
5348e07dc26bSmrg      lockfile=$f_ex_an_ar_oldlib.lock
5349e07dc26bSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5350e07dc26bSmrg	func_echo "Waiting for $lockfile to be removed"
5351e07dc26bSmrg	sleep 2
5352e07dc26bSmrg      done
5353e07dc26bSmrg    fi
5354e07dc26bSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5355e07dc26bSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
5356e07dc26bSmrg    if test yes = "$lock_old_archive_extraction"; then
5357e07dc26bSmrg      $opt_dry_run || rm -f "$lockfile"
5358e07dc26bSmrg    fi
5359e07dc26bSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
5360e07dc26bSmrg     :
5361e07dc26bSmrg    else
5362e07dc26bSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
5363e07dc26bSmrg    fi
5364e07dc26bSmrg}
5365e07dc26bSmrg
5366e07dc26bSmrg
5367e07dc26bSmrg# func_extract_archives gentop oldlib ...
5368e07dc26bSmrgfunc_extract_archives ()
5369e07dc26bSmrg{
5370e07dc26bSmrg    $debug_cmd
5371e07dc26bSmrg
5372e07dc26bSmrg    my_gentop=$1; shift
5373e07dc26bSmrg    my_oldlibs=${1+"$@"}
5374e07dc26bSmrg    my_oldobjs=
5375e07dc26bSmrg    my_xlib=
5376e07dc26bSmrg    my_xabs=
5377e07dc26bSmrg    my_xdir=
5378e07dc26bSmrg
5379e07dc26bSmrg    for my_xlib in $my_oldlibs; do
5380e07dc26bSmrg      # Extract the objects.
5381e07dc26bSmrg      case $my_xlib in
5382e07dc26bSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
5383e07dc26bSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
5384e07dc26bSmrg      esac
5385e07dc26bSmrg      func_basename "$my_xlib"
5386e07dc26bSmrg      my_xlib=$func_basename_result
5387e07dc26bSmrg      my_xlib_u=$my_xlib
5388e07dc26bSmrg      while :; do
5389e07dc26bSmrg        case " $extracted_archives " in
5390e07dc26bSmrg	*" $my_xlib_u "*)
5391e07dc26bSmrg	  func_arith $extracted_serial + 1
5392e07dc26bSmrg	  extracted_serial=$func_arith_result
5393e07dc26bSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
5394e07dc26bSmrg	*) break ;;
5395e07dc26bSmrg	esac
5396e07dc26bSmrg      done
5397e07dc26bSmrg      extracted_archives="$extracted_archives $my_xlib_u"
5398e07dc26bSmrg      my_xdir=$my_gentop/$my_xlib_u
5399e07dc26bSmrg
5400e07dc26bSmrg      func_mkdir_p "$my_xdir"
5401e07dc26bSmrg
5402e07dc26bSmrg      case $host in
5403e07dc26bSmrg      *-darwin*)
5404e07dc26bSmrg	func_verbose "Extracting $my_xabs"
5405e07dc26bSmrg	# Do not bother doing anything if just a dry run
5406e07dc26bSmrg	$opt_dry_run || {
5407e07dc26bSmrg	  darwin_orig_dir=`pwd`
5408e07dc26bSmrg	  cd $my_xdir || exit $?
5409e07dc26bSmrg	  darwin_archive=$my_xabs
5410e07dc26bSmrg	  darwin_curdir=`pwd`
5411e07dc26bSmrg	  func_basename "$darwin_archive"
5412e07dc26bSmrg	  darwin_base_archive=$func_basename_result
5413e07dc26bSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
5414e07dc26bSmrg	  if test -n "$darwin_arches"; then
5415e07dc26bSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
5416e07dc26bSmrg	    darwin_arch=
5417e07dc26bSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
5418e07dc26bSmrg	    for darwin_arch in  $darwin_arches; do
5419e07dc26bSmrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
5420e07dc26bSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
5421e07dc26bSmrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
5422e07dc26bSmrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
5423e07dc26bSmrg	      cd "$darwin_curdir"
5424e07dc26bSmrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
5425e07dc26bSmrg	    done # $darwin_arches
5426e07dc26bSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
5427e07dc26bSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
5428e07dc26bSmrg	    darwin_file=
5429e07dc26bSmrg	    darwin_files=
5430e07dc26bSmrg	    for darwin_file in $darwin_filelist; do
5431e07dc26bSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
5432e07dc26bSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
5433e07dc26bSmrg	    done # $darwin_filelist
5434e07dc26bSmrg	    $RM -rf unfat-$$
5435e07dc26bSmrg	    cd "$darwin_orig_dir"
5436e07dc26bSmrg	  else
5437e07dc26bSmrg	    cd $darwin_orig_dir
5438e07dc26bSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
5439e07dc26bSmrg	  fi # $darwin_arches
5440e07dc26bSmrg	} # !$opt_dry_run
5441e07dc26bSmrg	;;
5442e07dc26bSmrg      *)
5443e07dc26bSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
5444e07dc26bSmrg	;;
5445e07dc26bSmrg      esac
5446e07dc26bSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
5447e07dc26bSmrg    done
5448e07dc26bSmrg
5449e07dc26bSmrg    func_extract_archives_result=$my_oldobjs
5450e07dc26bSmrg}
5451e07dc26bSmrg
5452e07dc26bSmrg
5453e07dc26bSmrg# func_emit_wrapper [arg=no]
5454e07dc26bSmrg#
5455e07dc26bSmrg# Emit a libtool wrapper script on stdout.
5456e07dc26bSmrg# Don't directly open a file because we may want to
5457e07dc26bSmrg# incorporate the script contents within a cygwin/mingw
5458e07dc26bSmrg# wrapper executable.  Must ONLY be called from within
5459e07dc26bSmrg# func_mode_link because it depends on a number of variables
5460e07dc26bSmrg# set therein.
5461e07dc26bSmrg#
5462e07dc26bSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5463e07dc26bSmrg# variable will take.  If 'yes', then the emitted script
5464e07dc26bSmrg# will assume that the directory where it is stored is
5465e07dc26bSmrg# the $objdir directory.  This is a cygwin/mingw-specific
5466e07dc26bSmrg# behavior.
5467e07dc26bSmrgfunc_emit_wrapper ()
5468e07dc26bSmrg{
5469e07dc26bSmrg	func_emit_wrapper_arg1=${1-no}
5470e07dc26bSmrg
5471e07dc26bSmrg	$ECHO "\
5472e07dc26bSmrg#! $SHELL
5473e07dc26bSmrg
5474e07dc26bSmrg# $output - temporary wrapper script for $objdir/$outputname
5475e07dc26bSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5476e07dc26bSmrg#
5477e07dc26bSmrg# The $output program cannot be directly executed until all the libtool
5478e07dc26bSmrg# libraries that it depends on are installed.
5479e07dc26bSmrg#
5480e07dc26bSmrg# This wrapper script should never be moved out of the build directory.
5481e07dc26bSmrg# If it is, it will not operate correctly.
5482e07dc26bSmrg
5483e07dc26bSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
5484e07dc26bSmrg# metacharacters that are still active within double-quoted strings.
5485e07dc26bSmrgsed_quote_subst='$sed_quote_subst'
5486e07dc26bSmrg
5487e07dc26bSmrg# Be Bourne compatible
5488e07dc26bSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5489e07dc26bSmrg  emulate sh
5490e07dc26bSmrg  NULLCMD=:
5491e07dc26bSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5492e07dc26bSmrg  # is contrary to our usage.  Disable this feature.
5493e07dc26bSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
5494e07dc26bSmrg  setopt NO_GLOB_SUBST
5495e07dc26bSmrgelse
5496e07dc26bSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5497e07dc26bSmrgfi
5498e07dc26bSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
5499e07dc26bSmrgDUALCASE=1; export DUALCASE # for MKS sh
5500e07dc26bSmrg
5501e07dc26bSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
5502e07dc26bSmrg# if CDPATH is set.
5503e07dc26bSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5504e07dc26bSmrg
5505e07dc26bSmrgrelink_command=\"$relink_command\"
5506e07dc26bSmrg
5507e07dc26bSmrg# This environment variable determines our operation mode.
5508e07dc26bSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
5509e07dc26bSmrg  # install mode needs the following variables:
5510e07dc26bSmrg  generated_by_libtool_version='$macro_version'
5511e07dc26bSmrg  notinst_deplibs='$notinst_deplibs'
5512e07dc26bSmrgelse
5513e07dc26bSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
5514e07dc26bSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5515e07dc26bSmrg    file=\"\$0\""
5516e07dc26bSmrg
5517636c353eSmrg    func_quote_arg pretty "$ECHO"
5518636c353eSmrg    qECHO=$func_quote_arg_result
5519e07dc26bSmrg    $ECHO "\
5520e07dc26bSmrg
5521e07dc26bSmrg# A function that is used when there is no print builtin or printf.
5522e07dc26bSmrgfunc_fallback_echo ()
5523e07dc26bSmrg{
5524e07dc26bSmrg  eval 'cat <<_LTECHO_EOF
5525e07dc26bSmrg\$1
5526e07dc26bSmrg_LTECHO_EOF'
5527e07dc26bSmrg}
5528636c353eSmrg    ECHO=$qECHO
5529e07dc26bSmrg  fi
5530e07dc26bSmrg
5531e07dc26bSmrg# Very basic option parsing. These options are (a) specific to
5532e07dc26bSmrg# the libtool wrapper, (b) are identical between the wrapper
5533e07dc26bSmrg# /script/ and the wrapper /executable/ that is used only on
5534e07dc26bSmrg# windows platforms, and (c) all begin with the string "--lt-"
5535e07dc26bSmrg# (application programs are unlikely to have options that match
5536e07dc26bSmrg# this pattern).
5537e07dc26bSmrg#
5538e07dc26bSmrg# There are only two supported options: --lt-debug and
5539e07dc26bSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
5540e07dc26bSmrg#
5541e07dc26bSmrg# The first argument to this parsing function should be the
5542e07dc26bSmrg# script's $0 value, followed by "$@".
5543e07dc26bSmrglt_option_debug=
5544e07dc26bSmrgfunc_parse_lt_options ()
5545e07dc26bSmrg{
5546e07dc26bSmrg  lt_script_arg0=\$0
5547e07dc26bSmrg  shift
5548e07dc26bSmrg  for lt_opt
5549e07dc26bSmrg  do
5550e07dc26bSmrg    case \"\$lt_opt\" in
5551e07dc26bSmrg    --lt-debug) lt_option_debug=1 ;;
5552e07dc26bSmrg    --lt-dump-script)
5553e07dc26bSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5554e07dc26bSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5555e07dc26bSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5556e07dc26bSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
5557e07dc26bSmrg        exit 0
5558e07dc26bSmrg      ;;
5559e07dc26bSmrg    --lt-*)
5560e07dc26bSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5561e07dc26bSmrg        exit 1
5562e07dc26bSmrg      ;;
5563e07dc26bSmrg    esac
5564e07dc26bSmrg  done
5565e07dc26bSmrg
5566e07dc26bSmrg  # Print the debug banner immediately:
5567e07dc26bSmrg  if test -n \"\$lt_option_debug\"; then
5568e07dc26bSmrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5569e07dc26bSmrg  fi
5570e07dc26bSmrg}
5571e07dc26bSmrg
5572e07dc26bSmrg# Used when --lt-debug. Prints its arguments to stdout
5573e07dc26bSmrg# (redirection is the responsibility of the caller)
5574e07dc26bSmrgfunc_lt_dump_args ()
5575e07dc26bSmrg{
5576e07dc26bSmrg  lt_dump_args_N=1;
5577e07dc26bSmrg  for lt_arg
5578e07dc26bSmrg  do
5579e07dc26bSmrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5580e07dc26bSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5581e07dc26bSmrg  done
5582e07dc26bSmrg}
5583e07dc26bSmrg
5584e07dc26bSmrg# Core function for launching the target application
5585e07dc26bSmrgfunc_exec_program_core ()
5586e07dc26bSmrg{
5587e07dc26bSmrg"
5588e07dc26bSmrg  case $host in
5589e07dc26bSmrg  # Backslashes separate directories on plain windows
5590e07dc26bSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
5591e07dc26bSmrg    $ECHO "\
5592e07dc26bSmrg      if test -n \"\$lt_option_debug\"; then
5593e07dc26bSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5594e07dc26bSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5595e07dc26bSmrg      fi
5596e07dc26bSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5597e07dc26bSmrg"
5598e07dc26bSmrg    ;;
5599e07dc26bSmrg
5600e07dc26bSmrg  *)
5601e07dc26bSmrg    $ECHO "\
5602e07dc26bSmrg      if test -n \"\$lt_option_debug\"; then
5603e07dc26bSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5604e07dc26bSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
5605e07dc26bSmrg      fi
5606e07dc26bSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5607e07dc26bSmrg"
5608e07dc26bSmrg    ;;
5609e07dc26bSmrg  esac
5610e07dc26bSmrg  $ECHO "\
5611e07dc26bSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5612e07dc26bSmrg      exit 1
5613e07dc26bSmrg}
5614e07dc26bSmrg
5615e07dc26bSmrg# A function to encapsulate launching the target application
5616e07dc26bSmrg# Strips options in the --lt-* namespace from \$@ and
5617e07dc26bSmrg# launches target application with the remaining arguments.
5618e07dc26bSmrgfunc_exec_program ()
5619e07dc26bSmrg{
5620e07dc26bSmrg  case \" \$* \" in
5621e07dc26bSmrg  *\\ --lt-*)
5622e07dc26bSmrg    for lt_wr_arg
5623e07dc26bSmrg    do
5624e07dc26bSmrg      case \$lt_wr_arg in
5625e07dc26bSmrg      --lt-*) ;;
5626e07dc26bSmrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5627e07dc26bSmrg      esac
5628e07dc26bSmrg      shift
5629e07dc26bSmrg    done ;;
5630e07dc26bSmrg  esac
5631e07dc26bSmrg  func_exec_program_core \${1+\"\$@\"}
5632e07dc26bSmrg}
5633e07dc26bSmrg
5634e07dc26bSmrg  # Parse options
5635e07dc26bSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5636e07dc26bSmrg
5637e07dc26bSmrg  # Find the directory that this script lives in.
5638e07dc26bSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
5639e07dc26bSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5640e07dc26bSmrg
5641e07dc26bSmrg  # Follow symbolic links until we get to the real thisdir.
5642e07dc26bSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
5643e07dc26bSmrg  while test -n \"\$file\"; do
5644e07dc26bSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5645e07dc26bSmrg
5646e07dc26bSmrg    # If there was a directory component, then change thisdir.
5647e07dc26bSmrg    if test \"x\$destdir\" != \"x\$file\"; then
5648e07dc26bSmrg      case \"\$destdir\" in
5649e07dc26bSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5650e07dc26bSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5651e07dc26bSmrg      esac
5652e07dc26bSmrg    fi
5653e07dc26bSmrg
5654e07dc26bSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5655e07dc26bSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
5656e07dc26bSmrg  done
5657e07dc26bSmrg
5658e07dc26bSmrg  # Usually 'no', except on cygwin/mingw when embedded into
5659e07dc26bSmrg  # the cwrapper.
5660e07dc26bSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
5661e07dc26bSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
5662e07dc26bSmrg    # special case for '.'
5663e07dc26bSmrg    if test \"\$thisdir\" = \".\"; then
5664e07dc26bSmrg      thisdir=\`pwd\`
5665e07dc26bSmrg    fi
5666e07dc26bSmrg    # remove .libs from thisdir
5667e07dc26bSmrg    case \"\$thisdir\" in
5668e07dc26bSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
5669e07dc26bSmrg    $objdir )   thisdir=. ;;
5670e07dc26bSmrg    esac
5671e07dc26bSmrg  fi
5672e07dc26bSmrg
5673e07dc26bSmrg  # Try to get the absolute directory name.
5674e07dc26bSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
5675e07dc26bSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5676e07dc26bSmrg"
5677e07dc26bSmrg
5678e07dc26bSmrg	if test yes = "$fast_install"; then
5679e07dc26bSmrg	  $ECHO "\
5680e07dc26bSmrg  program=lt-'$outputname'$exeext
5681e07dc26bSmrg  progdir=\"\$thisdir/$objdir\"
5682e07dc26bSmrg
5683e07dc26bSmrg  if test ! -f \"\$progdir/\$program\" ||
5684e07dc26bSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
5685e07dc26bSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5686e07dc26bSmrg
5687e07dc26bSmrg    file=\"\$\$-\$program\"
5688e07dc26bSmrg
5689e07dc26bSmrg    if test ! -d \"\$progdir\"; then
5690e07dc26bSmrg      $MKDIR \"\$progdir\"
5691e07dc26bSmrg    else
5692e07dc26bSmrg      $RM \"\$progdir/\$file\"
5693e07dc26bSmrg    fi"
5694e07dc26bSmrg
5695e07dc26bSmrg	  $ECHO "\
5696e07dc26bSmrg
5697e07dc26bSmrg    # relink executable if necessary
5698e07dc26bSmrg    if test -n \"\$relink_command\"; then
5699e07dc26bSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5700e07dc26bSmrg      else
5701e07dc26bSmrg	\$ECHO \"\$relink_command_output\" >&2
5702e07dc26bSmrg	$RM \"\$progdir/\$file\"
5703e07dc26bSmrg	exit 1
5704e07dc26bSmrg      fi
5705e07dc26bSmrg    fi
5706e07dc26bSmrg
5707e07dc26bSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5708e07dc26bSmrg    { $RM \"\$progdir/\$program\";
5709e07dc26bSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5710e07dc26bSmrg    $RM \"\$progdir/\$file\"
5711e07dc26bSmrg  fi"
5712e07dc26bSmrg	else
5713e07dc26bSmrg	  $ECHO "\
5714e07dc26bSmrg  program='$outputname'
5715e07dc26bSmrg  progdir=\"\$thisdir/$objdir\"
5716e07dc26bSmrg"
5717e07dc26bSmrg	fi
5718e07dc26bSmrg
5719e07dc26bSmrg	$ECHO "\
5720e07dc26bSmrg
5721e07dc26bSmrg  if test -f \"\$progdir/\$program\"; then"
5722e07dc26bSmrg
5723e07dc26bSmrg	# fixup the dll searchpath if we need to.
5724e07dc26bSmrg	#
5725e07dc26bSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
5726e07dc26bSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
5727e07dc26bSmrg	# libraries must come first.
5728e07dc26bSmrg	if test -n "$dllsearchpath"; then
5729e07dc26bSmrg	  $ECHO "\
5730e07dc26bSmrg    # Add the dll search path components to the executable PATH
5731e07dc26bSmrg    PATH=$dllsearchpath:\$PATH
5732e07dc26bSmrg"
5733e07dc26bSmrg	fi
5734e07dc26bSmrg
5735e07dc26bSmrg	# Export our shlibpath_var if we have one.
5736e07dc26bSmrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5737e07dc26bSmrg	  $ECHO "\
5738e07dc26bSmrg    # Add our own library path to $shlibpath_var
5739e07dc26bSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5740e07dc26bSmrg
5741e07dc26bSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
5742e07dc26bSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
5743e07dc26bSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5744e07dc26bSmrg
5745e07dc26bSmrg    export $shlibpath_var
5746e07dc26bSmrg"
5747e07dc26bSmrg	fi
5748e07dc26bSmrg
5749e07dc26bSmrg	$ECHO "\
5750e07dc26bSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5751e07dc26bSmrg      # Run the actual program with our arguments.
5752e07dc26bSmrg      func_exec_program \${1+\"\$@\"}
5753e07dc26bSmrg    fi
5754e07dc26bSmrg  else
5755e07dc26bSmrg    # The program doesn't exist.
5756e07dc26bSmrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
5757e07dc26bSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5758e07dc26bSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
5759e07dc26bSmrg    exit 1
5760e07dc26bSmrg  fi
5761e07dc26bSmrgfi\
5762e07dc26bSmrg"
5763e07dc26bSmrg}
5764e07dc26bSmrg
5765e07dc26bSmrg
5766e07dc26bSmrg# func_emit_cwrapperexe_src
5767e07dc26bSmrg# emit the source code for a wrapper executable on stdout
5768e07dc26bSmrg# Must ONLY be called from within func_mode_link because
5769e07dc26bSmrg# it depends on a number of variable set therein.
5770e07dc26bSmrgfunc_emit_cwrapperexe_src ()
5771e07dc26bSmrg{
5772e07dc26bSmrg	cat <<EOF
5773e07dc26bSmrg
5774e07dc26bSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5775e07dc26bSmrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5776e07dc26bSmrg
5777e07dc26bSmrg   The $output program cannot be directly executed until all the libtool
5778e07dc26bSmrg   libraries that it depends on are installed.
5779e07dc26bSmrg
5780e07dc26bSmrg   This wrapper executable should never be moved out of the build directory.
5781e07dc26bSmrg   If it is, it will not operate correctly.
5782e07dc26bSmrg*/
5783e07dc26bSmrgEOF
5784e07dc26bSmrg	    cat <<"EOF"
5785e07dc26bSmrg#ifdef _MSC_VER
5786e07dc26bSmrg# define _CRT_SECURE_NO_DEPRECATE 1
5787e07dc26bSmrg#endif
5788e07dc26bSmrg#include <stdio.h>
5789e07dc26bSmrg#include <stdlib.h>
5790e07dc26bSmrg#ifdef _MSC_VER
5791e07dc26bSmrg# include <direct.h>
5792e07dc26bSmrg# include <process.h>
5793e07dc26bSmrg# include <io.h>
5794e07dc26bSmrg#else
5795e07dc26bSmrg# include <unistd.h>
5796e07dc26bSmrg# include <stdint.h>
5797e07dc26bSmrg# ifdef __CYGWIN__
5798e07dc26bSmrg#  include <io.h>
5799e07dc26bSmrg# endif
5800e07dc26bSmrg#endif
5801e07dc26bSmrg#include <malloc.h>
5802e07dc26bSmrg#include <stdarg.h>
5803e07dc26bSmrg#include <assert.h>
5804e07dc26bSmrg#include <string.h>
5805e07dc26bSmrg#include <ctype.h>
5806e07dc26bSmrg#include <errno.h>
5807e07dc26bSmrg#include <fcntl.h>
5808e07dc26bSmrg#include <sys/stat.h>
5809e07dc26bSmrg
5810e07dc26bSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5811e07dc26bSmrg
5812e07dc26bSmrg/* declarations of non-ANSI functions */
5813e07dc26bSmrg#if defined __MINGW32__
5814e07dc26bSmrg# ifdef __STRICT_ANSI__
5815e07dc26bSmrgint _putenv (const char *);
5816e07dc26bSmrg# endif
5817e07dc26bSmrg#elif defined __CYGWIN__
5818e07dc26bSmrg# ifdef __STRICT_ANSI__
5819e07dc26bSmrgchar *realpath (const char *, char *);
5820e07dc26bSmrgint putenv (char *);
5821e07dc26bSmrgint setenv (const char *, const char *, int);
5822e07dc26bSmrg# endif
5823e07dc26bSmrg/* #elif defined other_platform || defined ... */
5824e07dc26bSmrg#endif
5825e07dc26bSmrg
5826e07dc26bSmrg/* portability defines, excluding path handling macros */
5827e07dc26bSmrg#if defined _MSC_VER
5828e07dc26bSmrg# define setmode _setmode
5829e07dc26bSmrg# define stat    _stat
5830e07dc26bSmrg# define chmod   _chmod
5831e07dc26bSmrg# define getcwd  _getcwd
5832e07dc26bSmrg# define putenv  _putenv
5833e07dc26bSmrg# define S_IXUSR _S_IEXEC
5834e07dc26bSmrg#elif defined __MINGW32__
5835e07dc26bSmrg# define setmode _setmode
5836e07dc26bSmrg# define stat    _stat
5837e07dc26bSmrg# define chmod   _chmod
5838e07dc26bSmrg# define getcwd  _getcwd
5839e07dc26bSmrg# define putenv  _putenv
5840e07dc26bSmrg#elif defined __CYGWIN__
5841e07dc26bSmrg# define HAVE_SETENV
5842e07dc26bSmrg# define FOPEN_WB "wb"
5843e07dc26bSmrg/* #elif defined other platforms ... */
5844e07dc26bSmrg#endif
5845e07dc26bSmrg
5846e07dc26bSmrg#if defined PATH_MAX
5847e07dc26bSmrg# define LT_PATHMAX PATH_MAX
5848e07dc26bSmrg#elif defined MAXPATHLEN
5849e07dc26bSmrg# define LT_PATHMAX MAXPATHLEN
5850e07dc26bSmrg#else
5851e07dc26bSmrg# define LT_PATHMAX 1024
5852e07dc26bSmrg#endif
5853e07dc26bSmrg
5854e07dc26bSmrg#ifndef S_IXOTH
5855e07dc26bSmrg# define S_IXOTH 0
5856e07dc26bSmrg#endif
5857e07dc26bSmrg#ifndef S_IXGRP
5858e07dc26bSmrg# define S_IXGRP 0
5859e07dc26bSmrg#endif
5860e07dc26bSmrg
5861e07dc26bSmrg/* path handling portability macros */
5862e07dc26bSmrg#ifndef DIR_SEPARATOR
5863e07dc26bSmrg# define DIR_SEPARATOR '/'
5864e07dc26bSmrg# define PATH_SEPARATOR ':'
5865e07dc26bSmrg#endif
5866e07dc26bSmrg
5867e07dc26bSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
5868e07dc26bSmrg  defined __OS2__
5869e07dc26bSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
5870e07dc26bSmrg# define FOPEN_WB "wb"
5871e07dc26bSmrg# ifndef DIR_SEPARATOR_2
5872e07dc26bSmrg#  define DIR_SEPARATOR_2 '\\'
5873e07dc26bSmrg# endif
5874e07dc26bSmrg# ifndef PATH_SEPARATOR_2
5875e07dc26bSmrg#  define PATH_SEPARATOR_2 ';'
5876e07dc26bSmrg# endif
5877e07dc26bSmrg#endif
5878e07dc26bSmrg
5879e07dc26bSmrg#ifndef DIR_SEPARATOR_2
5880e07dc26bSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5881e07dc26bSmrg#else /* DIR_SEPARATOR_2 */
5882e07dc26bSmrg# define IS_DIR_SEPARATOR(ch) \
5883e07dc26bSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5884e07dc26bSmrg#endif /* DIR_SEPARATOR_2 */
5885e07dc26bSmrg
5886e07dc26bSmrg#ifndef PATH_SEPARATOR_2
5887e07dc26bSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5888e07dc26bSmrg#else /* PATH_SEPARATOR_2 */
5889e07dc26bSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5890e07dc26bSmrg#endif /* PATH_SEPARATOR_2 */
5891e07dc26bSmrg
5892e07dc26bSmrg#ifndef FOPEN_WB
5893e07dc26bSmrg# define FOPEN_WB "w"
5894e07dc26bSmrg#endif
5895e07dc26bSmrg#ifndef _O_BINARY
5896e07dc26bSmrg# define _O_BINARY 0
5897e07dc26bSmrg#endif
5898e07dc26bSmrg
5899e07dc26bSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
5900e07dc26bSmrg#define XFREE(stale) do { \
5901e07dc26bSmrg  if (stale) { free (stale); stale = 0; } \
5902e07dc26bSmrg} while (0)
5903e07dc26bSmrg
5904e07dc26bSmrg#if defined LT_DEBUGWRAPPER
5905e07dc26bSmrgstatic int lt_debug = 1;
5906e07dc26bSmrg#else
5907e07dc26bSmrgstatic int lt_debug = 0;
5908e07dc26bSmrg#endif
5909e07dc26bSmrg
5910e07dc26bSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5911e07dc26bSmrg
5912e07dc26bSmrgvoid *xmalloc (size_t num);
5913e07dc26bSmrgchar *xstrdup (const char *string);
5914e07dc26bSmrgconst char *base_name (const char *name);
5915e07dc26bSmrgchar *find_executable (const char *wrapper);
5916e07dc26bSmrgchar *chase_symlinks (const char *pathspec);
5917e07dc26bSmrgint make_executable (const char *path);
5918e07dc26bSmrgint check_executable (const char *path);
5919e07dc26bSmrgchar *strendzap (char *str, const char *pat);
5920e07dc26bSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
5921e07dc26bSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
5922e07dc26bSmrgstatic const char *nonnull (const char *s);
5923e07dc26bSmrgstatic const char *nonempty (const char *s);
5924e07dc26bSmrgvoid lt_setenv (const char *name, const char *value);
5925e07dc26bSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
5926e07dc26bSmrgvoid lt_update_exe_path (const char *name, const char *value);
5927e07dc26bSmrgvoid lt_update_lib_path (const char *name, const char *value);
5928e07dc26bSmrgchar **prepare_spawn (char **argv);
5929e07dc26bSmrgvoid lt_dump_script (FILE *f);
5930e07dc26bSmrgEOF
5931e07dc26bSmrg
5932e07dc26bSmrg	    cat <<EOF
5933e07dc26bSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
5934e07dc26bSmrg# define externally_visible volatile
5935e07dc26bSmrg#else
5936e07dc26bSmrg# define externally_visible __attribute__((externally_visible)) volatile
5937e07dc26bSmrg#endif
5938e07dc26bSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
5939e07dc26bSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
5940e07dc26bSmrgEOF
5941e07dc26bSmrg
5942e07dc26bSmrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5943e07dc26bSmrg              func_to_host_path "$temp_rpath"
5944e07dc26bSmrg	      cat <<EOF
5945e07dc26bSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
5946e07dc26bSmrgEOF
5947e07dc26bSmrg	    else
5948e07dc26bSmrg	      cat <<"EOF"
5949e07dc26bSmrgconst char * LIB_PATH_VALUE   = "";
5950e07dc26bSmrgEOF
5951e07dc26bSmrg	    fi
5952e07dc26bSmrg
5953e07dc26bSmrg	    if test -n "$dllsearchpath"; then
5954e07dc26bSmrg              func_to_host_path "$dllsearchpath:"
5955e07dc26bSmrg	      cat <<EOF
5956e07dc26bSmrgconst char * EXE_PATH_VARNAME = "PATH";
5957e07dc26bSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
5958e07dc26bSmrgEOF
5959e07dc26bSmrg	    else
5960e07dc26bSmrg	      cat <<"EOF"
5961e07dc26bSmrgconst char * EXE_PATH_VARNAME = "";
5962e07dc26bSmrgconst char * EXE_PATH_VALUE   = "";
5963e07dc26bSmrgEOF
5964e07dc26bSmrg	    fi
5965e07dc26bSmrg
5966e07dc26bSmrg	    if test yes = "$fast_install"; then
5967e07dc26bSmrg	      cat <<EOF
5968e07dc26bSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
5969e07dc26bSmrgEOF
5970e07dc26bSmrg	    else
5971e07dc26bSmrg	      cat <<EOF
5972e07dc26bSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
5973e07dc26bSmrgEOF
5974e07dc26bSmrg	    fi
5975e07dc26bSmrg
5976e07dc26bSmrg
5977e07dc26bSmrg	    cat <<"EOF"
5978e07dc26bSmrg
5979e07dc26bSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
5980e07dc26bSmrg
5981e07dc26bSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
5982e07dc26bSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
5983e07dc26bSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
5984e07dc26bSmrg
5985e07dc26bSmrgint
5986e07dc26bSmrgmain (int argc, char *argv[])
5987e07dc26bSmrg{
5988e07dc26bSmrg  char **newargz;
5989e07dc26bSmrg  int  newargc;
5990e07dc26bSmrg  char *tmp_pathspec;
5991e07dc26bSmrg  char *actual_cwrapper_path;
5992e07dc26bSmrg  char *actual_cwrapper_name;
5993e07dc26bSmrg  char *target_name;
5994e07dc26bSmrg  char *lt_argv_zero;
5995e07dc26bSmrg  int rval = 127;
5996e07dc26bSmrg
5997e07dc26bSmrg  int i;
5998e07dc26bSmrg
5999e07dc26bSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
6000e07dc26bSmrg  newargz = XMALLOC (char *, (size_t) argc + 1);
6001e07dc26bSmrg
6002e07dc26bSmrg  /* very simple arg parsing; don't want to rely on getopt
6003e07dc26bSmrg   * also, copy all non cwrapper options to newargz, except
6004e07dc26bSmrg   * argz[0], which is handled differently
6005e07dc26bSmrg   */
6006e07dc26bSmrg  newargc=0;
6007e07dc26bSmrg  for (i = 1; i < argc; i++)
6008e07dc26bSmrg    {
6009e07dc26bSmrg      if (STREQ (argv[i], dumpscript_opt))
6010e07dc26bSmrg	{
6011e07dc26bSmrgEOF
6012e07dc26bSmrg	    case $host in
6013e07dc26bSmrg	      *mingw* | *cygwin* )
6014e07dc26bSmrg		# make stdout use "unix" line endings
6015e07dc26bSmrg		echo "          setmode(1,_O_BINARY);"
6016e07dc26bSmrg		;;
6017e07dc26bSmrg	      esac
6018e07dc26bSmrg
6019e07dc26bSmrg	    cat <<"EOF"
6020e07dc26bSmrg	  lt_dump_script (stdout);
6021e07dc26bSmrg	  return 0;
6022e07dc26bSmrg	}
6023e07dc26bSmrg      if (STREQ (argv[i], debug_opt))
6024e07dc26bSmrg	{
6025e07dc26bSmrg          lt_debug = 1;
6026e07dc26bSmrg          continue;
6027e07dc26bSmrg	}
6028e07dc26bSmrg      if (STREQ (argv[i], ltwrapper_option_prefix))
6029e07dc26bSmrg        {
6030e07dc26bSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
6031e07dc26bSmrg             namespace, but it is not one of the ones we know about and
6032e07dc26bSmrg             have already dealt with, above (inluding dump-script), then
6033e07dc26bSmrg             report an error. Otherwise, targets might begin to believe
6034e07dc26bSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
6035e07dc26bSmrg             namespace. The first time any user complains about this, we'll
6036e07dc26bSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
6037e07dc26bSmrg             or a configure.ac-settable value.
6038e07dc26bSmrg           */
6039e07dc26bSmrg          lt_fatal (__FILE__, __LINE__,
6040e07dc26bSmrg		    "unrecognized %s option: '%s'",
6041e07dc26bSmrg                    ltwrapper_option_prefix, argv[i]);
6042e07dc26bSmrg        }
6043e07dc26bSmrg      /* otherwise ... */
6044e07dc26bSmrg      newargz[++newargc] = xstrdup (argv[i]);
6045e07dc26bSmrg    }
6046e07dc26bSmrg  newargz[++newargc] = NULL;
6047e07dc26bSmrg
6048e07dc26bSmrgEOF
6049e07dc26bSmrg	    cat <<EOF
6050e07dc26bSmrg  /* The GNU banner must be the first non-error debug message */
6051e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
6052e07dc26bSmrgEOF
6053e07dc26bSmrg	    cat <<"EOF"
6054e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
6055e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
6056e07dc26bSmrg
6057e07dc26bSmrg  tmp_pathspec = find_executable (argv[0]);
6058e07dc26bSmrg  if (tmp_pathspec == NULL)
6059e07dc26bSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
6060e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__,
6061e07dc26bSmrg                  "(main) found exe (before symlink chase) at: %s\n",
6062e07dc26bSmrg		  tmp_pathspec);
6063e07dc26bSmrg
6064e07dc26bSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
6065e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__,
6066e07dc26bSmrg                  "(main) found exe (after symlink chase) at: %s\n",
6067e07dc26bSmrg		  actual_cwrapper_path);
6068e07dc26bSmrg  XFREE (tmp_pathspec);
6069e07dc26bSmrg
6070e07dc26bSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
6071e07dc26bSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
6072e07dc26bSmrg
6073e07dc26bSmrg  /* wrapper name transforms */
6074e07dc26bSmrg  strendzap (actual_cwrapper_name, ".exe");
6075e07dc26bSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
6076e07dc26bSmrg  XFREE (actual_cwrapper_name);
6077e07dc26bSmrg  actual_cwrapper_name = tmp_pathspec;
6078e07dc26bSmrg  tmp_pathspec = 0;
6079e07dc26bSmrg
6080e07dc26bSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
6081e07dc26bSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
6082e07dc26bSmrg  strendzap (target_name, ".exe");
6083e07dc26bSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
6084e07dc26bSmrg  XFREE (target_name);
6085e07dc26bSmrg  target_name = tmp_pathspec;
6086e07dc26bSmrg  tmp_pathspec = 0;
6087e07dc26bSmrg
6088e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__,
6089e07dc26bSmrg		  "(main) libtool target name: %s\n",
6090e07dc26bSmrg		  target_name);
6091e07dc26bSmrgEOF
6092e07dc26bSmrg
6093e07dc26bSmrg	    cat <<EOF
6094e07dc26bSmrg  newargz[0] =
6095e07dc26bSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
6096e07dc26bSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
6097e07dc26bSmrg  strcpy (newargz[0], actual_cwrapper_path);
6098e07dc26bSmrg  strcat (newargz[0], "$objdir");
6099e07dc26bSmrg  strcat (newargz[0], "/");
6100e07dc26bSmrgEOF
6101e07dc26bSmrg
6102e07dc26bSmrg	    cat <<"EOF"
6103e07dc26bSmrg  /* stop here, and copy so we don't have to do this twice */
6104e07dc26bSmrg  tmp_pathspec = xstrdup (newargz[0]);
6105e07dc26bSmrg
6106e07dc26bSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
6107e07dc26bSmrg  strcat (newargz[0], actual_cwrapper_name);
6108e07dc26bSmrg
6109e07dc26bSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
6110e07dc26bSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
6111e07dc26bSmrg  XFREE (tmp_pathspec);
6112e07dc26bSmrg  tmp_pathspec = NULL;
6113e07dc26bSmrgEOF
6114e07dc26bSmrg
6115e07dc26bSmrg	    case $host_os in
6116e07dc26bSmrg	      mingw*)
6117e07dc26bSmrg	    cat <<"EOF"
6118e07dc26bSmrg  {
6119e07dc26bSmrg    char* p;
6120e07dc26bSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
6121e07dc26bSmrg      {
6122e07dc26bSmrg	*p = '/';
6123e07dc26bSmrg      }
6124e07dc26bSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
6125e07dc26bSmrg      {
6126e07dc26bSmrg	*p = '/';
6127e07dc26bSmrg      }
6128e07dc26bSmrg  }
6129e07dc26bSmrgEOF
6130e07dc26bSmrg	    ;;
6131e07dc26bSmrg	    esac
6132e07dc26bSmrg
6133e07dc26bSmrg	    cat <<"EOF"
6134e07dc26bSmrg  XFREE (target_name);
6135e07dc26bSmrg  XFREE (actual_cwrapper_path);
6136e07dc26bSmrg  XFREE (actual_cwrapper_name);
6137e07dc26bSmrg
6138e07dc26bSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
6139e07dc26bSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
6140e07dc26bSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
6141e07dc26bSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
6142e07dc26bSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
6143e07dc26bSmrg     libraries must come first. */
6144e07dc26bSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
6145e07dc26bSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
6146e07dc26bSmrg
6147e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
6148e07dc26bSmrg		  nonnull (lt_argv_zero));
6149e07dc26bSmrg  for (i = 0; i < newargc; i++)
6150e07dc26bSmrg    {
6151e07dc26bSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
6152e07dc26bSmrg		      i, nonnull (newargz[i]));
6153e07dc26bSmrg    }
6154e07dc26bSmrg
6155e07dc26bSmrgEOF
6156e07dc26bSmrg
6157e07dc26bSmrg	    case $host_os in
6158e07dc26bSmrg	      mingw*)
6159e07dc26bSmrg		cat <<"EOF"
6160e07dc26bSmrg  /* execv doesn't actually work on mingw as expected on unix */
6161e07dc26bSmrg  newargz = prepare_spawn (newargz);
6162e07dc26bSmrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
6163e07dc26bSmrg  if (rval == -1)
6164e07dc26bSmrg    {
6165e07dc26bSmrg      /* failed to start process */
6166e07dc26bSmrg      lt_debugprintf (__FILE__, __LINE__,
6167e07dc26bSmrg		      "(main) failed to launch target \"%s\": %s\n",
6168e07dc26bSmrg		      lt_argv_zero, nonnull (strerror (errno)));
6169e07dc26bSmrg      return 127;
6170e07dc26bSmrg    }
6171e07dc26bSmrg  return rval;
6172e07dc26bSmrgEOF
6173e07dc26bSmrg		;;
6174e07dc26bSmrg	      *)
6175e07dc26bSmrg		cat <<"EOF"
6176e07dc26bSmrg  execv (lt_argv_zero, newargz);
6177e07dc26bSmrg  return rval; /* =127, but avoids unused variable warning */
6178e07dc26bSmrgEOF
6179e07dc26bSmrg		;;
6180e07dc26bSmrg	    esac
6181e07dc26bSmrg
6182e07dc26bSmrg	    cat <<"EOF"
6183e07dc26bSmrg}
6184e07dc26bSmrg
6185e07dc26bSmrgvoid *
6186e07dc26bSmrgxmalloc (size_t num)
6187e07dc26bSmrg{
6188e07dc26bSmrg  void *p = (void *) malloc (num);
6189e07dc26bSmrg  if (!p)
6190e07dc26bSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
6191e07dc26bSmrg
6192e07dc26bSmrg  return p;
6193e07dc26bSmrg}
6194e07dc26bSmrg
6195e07dc26bSmrgchar *
6196e07dc26bSmrgxstrdup (const char *string)
6197e07dc26bSmrg{
6198e07dc26bSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
6199e07dc26bSmrg			  string) : NULL;
6200e07dc26bSmrg}
6201e07dc26bSmrg
6202e07dc26bSmrgconst char *
6203e07dc26bSmrgbase_name (const char *name)
6204e07dc26bSmrg{
6205e07dc26bSmrg  const char *base;
6206e07dc26bSmrg
6207e07dc26bSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6208e07dc26bSmrg  /* Skip over the disk name in MSDOS pathnames. */
6209e07dc26bSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
6210e07dc26bSmrg    name += 2;
6211e07dc26bSmrg#endif
6212e07dc26bSmrg
6213e07dc26bSmrg  for (base = name; *name; name++)
6214e07dc26bSmrg    if (IS_DIR_SEPARATOR (*name))
6215e07dc26bSmrg      base = name + 1;
6216e07dc26bSmrg  return base;
6217e07dc26bSmrg}
6218e07dc26bSmrg
6219e07dc26bSmrgint
6220e07dc26bSmrgcheck_executable (const char *path)
6221e07dc26bSmrg{
6222e07dc26bSmrg  struct stat st;
6223e07dc26bSmrg
6224e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
6225e07dc26bSmrg                  nonempty (path));
6226e07dc26bSmrg  if ((!path) || (!*path))
6227e07dc26bSmrg    return 0;
6228e07dc26bSmrg
6229e07dc26bSmrg  if ((stat (path, &st) >= 0)
6230e07dc26bSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
6231e07dc26bSmrg    return 1;
6232e07dc26bSmrg  else
6233e07dc26bSmrg    return 0;
6234e07dc26bSmrg}
6235e07dc26bSmrg
6236e07dc26bSmrgint
6237e07dc26bSmrgmake_executable (const char *path)
6238e07dc26bSmrg{
6239e07dc26bSmrg  int rval = 0;
6240e07dc26bSmrg  struct stat st;
6241e07dc26bSmrg
6242e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
6243e07dc26bSmrg                  nonempty (path));
6244e07dc26bSmrg  if ((!path) || (!*path))
6245e07dc26bSmrg    return 0;
6246e07dc26bSmrg
6247e07dc26bSmrg  if (stat (path, &st) >= 0)
6248e07dc26bSmrg    {
6249e07dc26bSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
6250e07dc26bSmrg    }
6251e07dc26bSmrg  return rval;
6252e07dc26bSmrg}
6253e07dc26bSmrg
6254e07dc26bSmrg/* Searches for the full path of the wrapper.  Returns
6255e07dc26bSmrg   newly allocated full path name if found, NULL otherwise
6256e07dc26bSmrg   Does not chase symlinks, even on platforms that support them.
6257e07dc26bSmrg*/
6258e07dc26bSmrgchar *
6259e07dc26bSmrgfind_executable (const char *wrapper)
6260e07dc26bSmrg{
6261e07dc26bSmrg  int has_slash = 0;
6262e07dc26bSmrg  const char *p;
6263e07dc26bSmrg  const char *p_next;
6264e07dc26bSmrg  /* static buffer for getcwd */
6265e07dc26bSmrg  char tmp[LT_PATHMAX + 1];
6266e07dc26bSmrg  size_t tmp_len;
6267e07dc26bSmrg  char *concat_name;
6268e07dc26bSmrg
6269e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6270e07dc26bSmrg                  nonempty (wrapper));
6271e07dc26bSmrg
6272e07dc26bSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
6273e07dc26bSmrg    return NULL;
6274e07dc26bSmrg
6275e07dc26bSmrg  /* Absolute path? */
6276e07dc26bSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6277e07dc26bSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
6278e07dc26bSmrg    {
6279e07dc26bSmrg      concat_name = xstrdup (wrapper);
6280e07dc26bSmrg      if (check_executable (concat_name))
6281e07dc26bSmrg	return concat_name;
6282e07dc26bSmrg      XFREE (concat_name);
6283e07dc26bSmrg    }
6284e07dc26bSmrg  else
6285e07dc26bSmrg    {
6286e07dc26bSmrg#endif
6287e07dc26bSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
6288e07dc26bSmrg	{
6289e07dc26bSmrg	  concat_name = xstrdup (wrapper);
6290e07dc26bSmrg	  if (check_executable (concat_name))
6291e07dc26bSmrg	    return concat_name;
6292e07dc26bSmrg	  XFREE (concat_name);
6293e07dc26bSmrg	}
6294e07dc26bSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
6295e07dc26bSmrg    }
6296e07dc26bSmrg#endif
6297e07dc26bSmrg
6298e07dc26bSmrg  for (p = wrapper; *p; p++)
6299e07dc26bSmrg    if (*p == '/')
6300e07dc26bSmrg      {
6301e07dc26bSmrg	has_slash = 1;
6302e07dc26bSmrg	break;
6303e07dc26bSmrg      }
6304e07dc26bSmrg  if (!has_slash)
6305e07dc26bSmrg    {
6306e07dc26bSmrg      /* no slashes; search PATH */
6307e07dc26bSmrg      const char *path = getenv ("PATH");
6308e07dc26bSmrg      if (path != NULL)
6309e07dc26bSmrg	{
6310e07dc26bSmrg	  for (p = path; *p; p = p_next)
6311e07dc26bSmrg	    {
6312e07dc26bSmrg	      const char *q;
6313e07dc26bSmrg	      size_t p_len;
6314e07dc26bSmrg	      for (q = p; *q; q++)
6315e07dc26bSmrg		if (IS_PATH_SEPARATOR (*q))
6316e07dc26bSmrg		  break;
6317e07dc26bSmrg	      p_len = (size_t) (q - p);
6318e07dc26bSmrg	      p_next = (*q == '\0' ? q : q + 1);
6319e07dc26bSmrg	      if (p_len == 0)
6320e07dc26bSmrg		{
6321e07dc26bSmrg		  /* empty path: current directory */
6322e07dc26bSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
6323e07dc26bSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6324e07dc26bSmrg                              nonnull (strerror (errno)));
6325e07dc26bSmrg		  tmp_len = strlen (tmp);
6326e07dc26bSmrg		  concat_name =
6327e07dc26bSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6328e07dc26bSmrg		  memcpy (concat_name, tmp, tmp_len);
6329e07dc26bSmrg		  concat_name[tmp_len] = '/';
6330e07dc26bSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
6331e07dc26bSmrg		}
6332e07dc26bSmrg	      else
6333e07dc26bSmrg		{
6334e07dc26bSmrg		  concat_name =
6335e07dc26bSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
6336e07dc26bSmrg		  memcpy (concat_name, p, p_len);
6337e07dc26bSmrg		  concat_name[p_len] = '/';
6338e07dc26bSmrg		  strcpy (concat_name + p_len + 1, wrapper);
6339e07dc26bSmrg		}
6340e07dc26bSmrg	      if (check_executable (concat_name))
6341e07dc26bSmrg		return concat_name;
6342e07dc26bSmrg	      XFREE (concat_name);
6343e07dc26bSmrg	    }
6344e07dc26bSmrg	}
6345e07dc26bSmrg      /* not found in PATH; assume curdir */
6346e07dc26bSmrg    }
6347e07dc26bSmrg  /* Relative path | not found in path: prepend cwd */
6348e07dc26bSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
6349e07dc26bSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6350e07dc26bSmrg              nonnull (strerror (errno)));
6351e07dc26bSmrg  tmp_len = strlen (tmp);
6352e07dc26bSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6353e07dc26bSmrg  memcpy (concat_name, tmp, tmp_len);
6354e07dc26bSmrg  concat_name[tmp_len] = '/';
6355e07dc26bSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
6356e07dc26bSmrg
6357e07dc26bSmrg  if (check_executable (concat_name))
6358e07dc26bSmrg    return concat_name;
6359e07dc26bSmrg  XFREE (concat_name);
6360e07dc26bSmrg  return NULL;
6361e07dc26bSmrg}
6362e07dc26bSmrg
6363e07dc26bSmrgchar *
6364e07dc26bSmrgchase_symlinks (const char *pathspec)
6365e07dc26bSmrg{
6366e07dc26bSmrg#ifndef S_ISLNK
6367e07dc26bSmrg  return xstrdup (pathspec);
6368e07dc26bSmrg#else
6369e07dc26bSmrg  char buf[LT_PATHMAX];
6370e07dc26bSmrg  struct stat s;
6371e07dc26bSmrg  char *tmp_pathspec = xstrdup (pathspec);
6372e07dc26bSmrg  char *p;
6373e07dc26bSmrg  int has_symlinks = 0;
6374e07dc26bSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
6375e07dc26bSmrg    {
6376e07dc26bSmrg      lt_debugprintf (__FILE__, __LINE__,
6377e07dc26bSmrg		      "checking path component for symlinks: %s\n",
6378e07dc26bSmrg		      tmp_pathspec);
6379e07dc26bSmrg      if (lstat (tmp_pathspec, &s) == 0)
6380e07dc26bSmrg	{
6381e07dc26bSmrg	  if (S_ISLNK (s.st_mode) != 0)
6382e07dc26bSmrg	    {
6383e07dc26bSmrg	      has_symlinks = 1;
6384e07dc26bSmrg	      break;
6385e07dc26bSmrg	    }
6386e07dc26bSmrg
6387e07dc26bSmrg	  /* search backwards for last DIR_SEPARATOR */
6388e07dc26bSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
6389e07dc26bSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6390e07dc26bSmrg	    p--;
6391e07dc26bSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6392e07dc26bSmrg	    {
6393e07dc26bSmrg	      /* no more DIR_SEPARATORS left */
6394e07dc26bSmrg	      break;
6395e07dc26bSmrg	    }
6396e07dc26bSmrg	  *p = '\0';
6397e07dc26bSmrg	}
6398e07dc26bSmrg      else
6399e07dc26bSmrg	{
6400e07dc26bSmrg	  lt_fatal (__FILE__, __LINE__,
6401e07dc26bSmrg		    "error accessing file \"%s\": %s",
6402e07dc26bSmrg		    tmp_pathspec, nonnull (strerror (errno)));
6403e07dc26bSmrg	}
6404e07dc26bSmrg    }
6405e07dc26bSmrg  XFREE (tmp_pathspec);
6406e07dc26bSmrg
6407e07dc26bSmrg  if (!has_symlinks)
6408e07dc26bSmrg    {
6409e07dc26bSmrg      return xstrdup (pathspec);
6410e07dc26bSmrg    }
6411e07dc26bSmrg
6412e07dc26bSmrg  tmp_pathspec = realpath (pathspec, buf);
6413e07dc26bSmrg  if (tmp_pathspec == 0)
6414e07dc26bSmrg    {
6415e07dc26bSmrg      lt_fatal (__FILE__, __LINE__,
6416e07dc26bSmrg		"could not follow symlinks for %s", pathspec);
6417e07dc26bSmrg    }
6418e07dc26bSmrg  return xstrdup (tmp_pathspec);
6419e07dc26bSmrg#endif
6420e07dc26bSmrg}
6421e07dc26bSmrg
6422e07dc26bSmrgchar *
6423e07dc26bSmrgstrendzap (char *str, const char *pat)
6424e07dc26bSmrg{
6425e07dc26bSmrg  size_t len, patlen;
6426e07dc26bSmrg
6427e07dc26bSmrg  assert (str != NULL);
6428e07dc26bSmrg  assert (pat != NULL);
6429e07dc26bSmrg
6430e07dc26bSmrg  len = strlen (str);
6431e07dc26bSmrg  patlen = strlen (pat);
6432e07dc26bSmrg
6433e07dc26bSmrg  if (patlen <= len)
6434e07dc26bSmrg    {
6435e07dc26bSmrg      str += len - patlen;
6436e07dc26bSmrg      if (STREQ (str, pat))
6437e07dc26bSmrg	*str = '\0';
6438e07dc26bSmrg    }
6439e07dc26bSmrg  return str;
6440e07dc26bSmrg}
6441e07dc26bSmrg
6442e07dc26bSmrgvoid
6443e07dc26bSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
6444e07dc26bSmrg{
6445e07dc26bSmrg  va_list args;
6446e07dc26bSmrg  if (lt_debug)
6447e07dc26bSmrg    {
6448e07dc26bSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6449e07dc26bSmrg      va_start (args, fmt);
6450e07dc26bSmrg      (void) vfprintf (stderr, fmt, args);
6451e07dc26bSmrg      va_end (args);
6452e07dc26bSmrg    }
6453e07dc26bSmrg}
6454e07dc26bSmrg
6455e07dc26bSmrgstatic void
6456e07dc26bSmrglt_error_core (int exit_status, const char *file,
6457e07dc26bSmrg	       int line, const char *mode,
6458e07dc26bSmrg	       const char *message, va_list ap)
6459e07dc26bSmrg{
6460e07dc26bSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
6461e07dc26bSmrg  vfprintf (stderr, message, ap);
6462e07dc26bSmrg  fprintf (stderr, ".\n");
6463e07dc26bSmrg
6464e07dc26bSmrg  if (exit_status >= 0)
6465e07dc26bSmrg    exit (exit_status);
6466e07dc26bSmrg}
6467e07dc26bSmrg
6468e07dc26bSmrgvoid
6469e07dc26bSmrglt_fatal (const char *file, int line, const char *message, ...)
6470e07dc26bSmrg{
6471e07dc26bSmrg  va_list ap;
6472e07dc26bSmrg  va_start (ap, message);
6473e07dc26bSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
6474e07dc26bSmrg  va_end (ap);
6475e07dc26bSmrg}
6476e07dc26bSmrg
6477e07dc26bSmrgstatic const char *
6478e07dc26bSmrgnonnull (const char *s)
6479e07dc26bSmrg{
6480e07dc26bSmrg  return s ? s : "(null)";
6481e07dc26bSmrg}
6482e07dc26bSmrg
6483e07dc26bSmrgstatic const char *
6484e07dc26bSmrgnonempty (const char *s)
6485e07dc26bSmrg{
6486e07dc26bSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
6487e07dc26bSmrg}
6488e07dc26bSmrg
6489e07dc26bSmrgvoid
6490e07dc26bSmrglt_setenv (const char *name, const char *value)
6491e07dc26bSmrg{
6492e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__,
6493e07dc26bSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
6494e07dc26bSmrg                  nonnull (name), nonnull (value));
6495e07dc26bSmrg  {
6496e07dc26bSmrg#ifdef HAVE_SETENV
6497e07dc26bSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
6498e07dc26bSmrg    char *str = xstrdup (value);
6499e07dc26bSmrg    setenv (name, str, 1);
6500e07dc26bSmrg#else
6501e07dc26bSmrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
6502e07dc26bSmrg    char *str = XMALLOC (char, len);
6503e07dc26bSmrg    sprintf (str, "%s=%s", name, value);
6504e07dc26bSmrg    if (putenv (str) != EXIT_SUCCESS)
6505e07dc26bSmrg      {
6506e07dc26bSmrg        XFREE (str);
6507e07dc26bSmrg      }
6508e07dc26bSmrg#endif
6509e07dc26bSmrg  }
6510e07dc26bSmrg}
6511e07dc26bSmrg
6512e07dc26bSmrgchar *
6513e07dc26bSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
6514e07dc26bSmrg{
6515e07dc26bSmrg  char *new_value;
6516e07dc26bSmrg  if (orig_value && *orig_value)
6517e07dc26bSmrg    {
6518e07dc26bSmrg      size_t orig_value_len = strlen (orig_value);
6519e07dc26bSmrg      size_t add_len = strlen (add);
6520e07dc26bSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
6521e07dc26bSmrg      if (to_end)
6522e07dc26bSmrg        {
6523e07dc26bSmrg          strcpy (new_value, orig_value);
6524e07dc26bSmrg          strcpy (new_value + orig_value_len, add);
6525e07dc26bSmrg        }
6526e07dc26bSmrg      else
6527e07dc26bSmrg        {
6528e07dc26bSmrg          strcpy (new_value, add);
6529e07dc26bSmrg          strcpy (new_value + add_len, orig_value);
6530e07dc26bSmrg        }
6531e07dc26bSmrg    }
6532e07dc26bSmrg  else
6533e07dc26bSmrg    {
6534e07dc26bSmrg      new_value = xstrdup (add);
6535e07dc26bSmrg    }
6536e07dc26bSmrg  return new_value;
6537e07dc26bSmrg}
6538e07dc26bSmrg
6539e07dc26bSmrgvoid
6540e07dc26bSmrglt_update_exe_path (const char *name, const char *value)
6541e07dc26bSmrg{
6542e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__,
6543e07dc26bSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6544e07dc26bSmrg                  nonnull (name), nonnull (value));
6545e07dc26bSmrg
6546e07dc26bSmrg  if (name && *name && value && *value)
6547e07dc26bSmrg    {
6548e07dc26bSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
6549e07dc26bSmrg      /* some systems can't cope with a ':'-terminated path #' */
6550e07dc26bSmrg      size_t len = strlen (new_value);
6551e07dc26bSmrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
6552e07dc26bSmrg        {
6553e07dc26bSmrg          new_value[--len] = '\0';
6554e07dc26bSmrg        }
6555e07dc26bSmrg      lt_setenv (name, new_value);
6556e07dc26bSmrg      XFREE (new_value);
6557e07dc26bSmrg    }
6558e07dc26bSmrg}
6559e07dc26bSmrg
6560e07dc26bSmrgvoid
6561e07dc26bSmrglt_update_lib_path (const char *name, const char *value)
6562e07dc26bSmrg{
6563e07dc26bSmrg  lt_debugprintf (__FILE__, __LINE__,
6564e07dc26bSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6565e07dc26bSmrg                  nonnull (name), nonnull (value));
6566e07dc26bSmrg
6567e07dc26bSmrg  if (name && *name && value && *value)
6568e07dc26bSmrg    {
6569e07dc26bSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
6570e07dc26bSmrg      lt_setenv (name, new_value);
6571e07dc26bSmrg      XFREE (new_value);
6572e07dc26bSmrg    }
6573e07dc26bSmrg}
6574e07dc26bSmrg
6575e07dc26bSmrgEOF
6576e07dc26bSmrg	    case $host_os in
6577e07dc26bSmrg	      mingw*)
6578e07dc26bSmrg		cat <<"EOF"
6579e07dc26bSmrg
6580e07dc26bSmrg/* Prepares an argument vector before calling spawn().
6581e07dc26bSmrg   Note that spawn() does not by itself call the command interpreter
6582e07dc26bSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6583e07dc26bSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6584e07dc26bSmrg         GetVersionEx(&v);
6585e07dc26bSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6586e07dc26bSmrg      }) ? "cmd.exe" : "command.com").
6587e07dc26bSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
6588e07dc26bSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
6589e07dc26bSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6590e07dc26bSmrg   special way:
6591e07dc26bSmrg   - Space and tab are interpreted as delimiters. They are not treated as
6592e07dc26bSmrg     delimiters if they are surrounded by double quotes: "...".
6593e07dc26bSmrg   - Unescaped double quotes are removed from the input. Their only effect is
6594e07dc26bSmrg     that within double quotes, space and tab are treated like normal
6595e07dc26bSmrg     characters.
6596e07dc26bSmrg   - Backslashes not followed by double quotes are not special.
6597e07dc26bSmrg   - But 2*n+1 backslashes followed by a double quote become
6598e07dc26bSmrg     n backslashes followed by a double quote (n >= 0):
6599e07dc26bSmrg       \" -> "
6600e07dc26bSmrg       \\\" -> \"
6601e07dc26bSmrg       \\\\\" -> \\"
6602e07dc26bSmrg */
6603e07dc26bSmrg#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"
6604e07dc26bSmrg#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"
6605e07dc26bSmrgchar **
6606e07dc26bSmrgprepare_spawn (char **argv)
6607e07dc26bSmrg{
6608e07dc26bSmrg  size_t argc;
6609e07dc26bSmrg  char **new_argv;
6610e07dc26bSmrg  size_t i;
6611e07dc26bSmrg
6612e07dc26bSmrg  /* Count number of arguments.  */
6613e07dc26bSmrg  for (argc = 0; argv[argc] != NULL; argc++)
6614e07dc26bSmrg    ;
6615e07dc26bSmrg
6616e07dc26bSmrg  /* Allocate new argument vector.  */
6617e07dc26bSmrg  new_argv = XMALLOC (char *, argc + 1);
6618e07dc26bSmrg
6619e07dc26bSmrg  /* Put quoted arguments into the new argument vector.  */
6620e07dc26bSmrg  for (i = 0; i < argc; i++)
6621e07dc26bSmrg    {
6622e07dc26bSmrg      const char *string = argv[i];
6623e07dc26bSmrg
6624e07dc26bSmrg      if (string[0] == '\0')
6625e07dc26bSmrg	new_argv[i] = xstrdup ("\"\"");
6626e07dc26bSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6627e07dc26bSmrg	{
6628e07dc26bSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6629e07dc26bSmrg	  size_t length;
6630e07dc26bSmrg	  unsigned int backslashes;
6631e07dc26bSmrg	  const char *s;
6632e07dc26bSmrg	  char *quoted_string;
6633e07dc26bSmrg	  char *p;
6634e07dc26bSmrg
6635e07dc26bSmrg	  length = 0;
6636e07dc26bSmrg	  backslashes = 0;
6637e07dc26bSmrg	  if (quote_around)
6638e07dc26bSmrg	    length++;
6639e07dc26bSmrg	  for (s = string; *s != '\0'; s++)
6640e07dc26bSmrg	    {
6641e07dc26bSmrg	      char c = *s;
6642e07dc26bSmrg	      if (c == '"')
6643e07dc26bSmrg		length += backslashes + 1;
6644e07dc26bSmrg	      length++;
6645e07dc26bSmrg	      if (c == '\\')
6646e07dc26bSmrg		backslashes++;
6647e07dc26bSmrg	      else
6648e07dc26bSmrg		backslashes = 0;
6649e07dc26bSmrg	    }
6650e07dc26bSmrg	  if (quote_around)
6651e07dc26bSmrg	    length += backslashes + 1;
6652e07dc26bSmrg
6653e07dc26bSmrg	  quoted_string = XMALLOC (char, length + 1);
6654e07dc26bSmrg
6655e07dc26bSmrg	  p = quoted_string;
6656e07dc26bSmrg	  backslashes = 0;
6657e07dc26bSmrg	  if (quote_around)
6658e07dc26bSmrg	    *p++ = '"';
6659e07dc26bSmrg	  for (s = string; *s != '\0'; s++)
6660e07dc26bSmrg	    {
6661e07dc26bSmrg	      char c = *s;
6662e07dc26bSmrg	      if (c == '"')
6663e07dc26bSmrg		{
6664e07dc26bSmrg		  unsigned int j;
6665e07dc26bSmrg		  for (j = backslashes + 1; j > 0; j--)
6666e07dc26bSmrg		    *p++ = '\\';
6667e07dc26bSmrg		}
6668e07dc26bSmrg	      *p++ = c;
6669e07dc26bSmrg	      if (c == '\\')
6670e07dc26bSmrg		backslashes++;
6671e07dc26bSmrg	      else
6672e07dc26bSmrg		backslashes = 0;
6673e07dc26bSmrg	    }
6674e07dc26bSmrg	  if (quote_around)
6675e07dc26bSmrg	    {
6676e07dc26bSmrg	      unsigned int j;
6677e07dc26bSmrg	      for (j = backslashes; j > 0; j--)
6678e07dc26bSmrg		*p++ = '\\';
6679e07dc26bSmrg	      *p++ = '"';
6680e07dc26bSmrg	    }
6681e07dc26bSmrg	  *p = '\0';
6682e07dc26bSmrg
6683e07dc26bSmrg	  new_argv[i] = quoted_string;
6684e07dc26bSmrg	}
6685e07dc26bSmrg      else
6686e07dc26bSmrg	new_argv[i] = (char *) string;
6687e07dc26bSmrg    }
6688e07dc26bSmrg  new_argv[argc] = NULL;
6689e07dc26bSmrg
6690e07dc26bSmrg  return new_argv;
6691e07dc26bSmrg}
6692e07dc26bSmrgEOF
6693e07dc26bSmrg		;;
6694e07dc26bSmrg	    esac
6695e07dc26bSmrg
6696e07dc26bSmrg            cat <<"EOF"
6697e07dc26bSmrgvoid lt_dump_script (FILE* f)
6698e07dc26bSmrg{
6699e07dc26bSmrgEOF
6700e07dc26bSmrg	    func_emit_wrapper yes |
6701e07dc26bSmrg	      $SED -n -e '
6702e07dc26bSmrgs/^\(.\{79\}\)\(..*\)/\1\
6703e07dc26bSmrg\2/
6704e07dc26bSmrgh
6705e07dc26bSmrgs/\([\\"]\)/\\\1/g
6706e07dc26bSmrgs/$/\\n/
6707e07dc26bSmrgs/\([^\n]*\).*/  fputs ("\1", f);/p
6708e07dc26bSmrgg
6709e07dc26bSmrgD'
6710e07dc26bSmrg            cat <<"EOF"
6711e07dc26bSmrg}
6712e07dc26bSmrgEOF
6713e07dc26bSmrg}
6714e07dc26bSmrg# end: func_emit_cwrapperexe_src
6715e07dc26bSmrg
6716e07dc26bSmrg# func_win32_import_lib_p ARG
6717e07dc26bSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
6718e07dc26bSmrgfunc_win32_import_lib_p ()
6719e07dc26bSmrg{
6720e07dc26bSmrg    $debug_cmd
6721e07dc26bSmrg
6722e07dc26bSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6723e07dc26bSmrg    *import*) : ;;
6724e07dc26bSmrg    *) false ;;
6725e07dc26bSmrg    esac
6726e07dc26bSmrg}
6727e07dc26bSmrg
6728e07dc26bSmrg# func_suncc_cstd_abi
6729e07dc26bSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
6730e07dc26bSmrg# Several compiler flags select an ABI that is incompatible with the
6731e07dc26bSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
6732e07dc26bSmrgfunc_suncc_cstd_abi ()
6733e07dc26bSmrg{
6734e07dc26bSmrg    $debug_cmd
6735e07dc26bSmrg
6736e07dc26bSmrg    case " $compile_command " in
6737e07dc26bSmrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
6738e07dc26bSmrg      suncc_use_cstd_abi=no
6739e07dc26bSmrg      ;;
6740e07dc26bSmrg    *)
6741e07dc26bSmrg      suncc_use_cstd_abi=yes
6742e07dc26bSmrg      ;;
6743e07dc26bSmrg    esac
6744e07dc26bSmrg}
6745e07dc26bSmrg
6746e07dc26bSmrg# func_mode_link arg...
6747e07dc26bSmrgfunc_mode_link ()
6748e07dc26bSmrg{
6749e07dc26bSmrg    $debug_cmd
6750e07dc26bSmrg
6751e07dc26bSmrg    case $host in
6752e07dc26bSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6753e07dc26bSmrg      # It is impossible to link a dll without this setting, and
6754e07dc26bSmrg      # we shouldn't force the makefile maintainer to figure out
6755e07dc26bSmrg      # what system we are compiling for in order to pass an extra
6756e07dc26bSmrg      # flag for every libtool invocation.
6757e07dc26bSmrg      # allow_undefined=no
6758e07dc26bSmrg
6759e07dc26bSmrg      # FIXME: Unfortunately, there are problems with the above when trying
6760e07dc26bSmrg      # to make a dll that has undefined symbols, in which case not
6761e07dc26bSmrg      # even a static library is built.  For now, we need to specify
6762e07dc26bSmrg      # -no-undefined on the libtool link line when we can be certain
6763e07dc26bSmrg      # that all symbols are satisfied, otherwise we get a static library.
6764e07dc26bSmrg      allow_undefined=yes
6765e07dc26bSmrg      ;;
6766e07dc26bSmrg    *)
6767e07dc26bSmrg      allow_undefined=yes
6768e07dc26bSmrg      ;;
6769e07dc26bSmrg    esac
6770e07dc26bSmrg    libtool_args=$nonopt
6771e07dc26bSmrg    base_compile="$nonopt $@"
6772e07dc26bSmrg    compile_command=$nonopt
6773e07dc26bSmrg    finalize_command=$nonopt
6774e07dc26bSmrg
6775e07dc26bSmrg    compile_rpath=
6776e07dc26bSmrg    finalize_rpath=
6777e07dc26bSmrg    compile_shlibpath=
6778e07dc26bSmrg    finalize_shlibpath=
6779e07dc26bSmrg    convenience=
6780e07dc26bSmrg    old_convenience=
6781e07dc26bSmrg    deplibs=
6782e07dc26bSmrg    old_deplibs=
6783e07dc26bSmrg    compiler_flags=
6784e07dc26bSmrg    linker_flags=
6785e07dc26bSmrg    dllsearchpath=
6786e07dc26bSmrg    lib_search_path=`pwd`
6787e07dc26bSmrg    inst_prefix_dir=
6788e07dc26bSmrg    new_inherited_linker_flags=
6789e07dc26bSmrg
6790e07dc26bSmrg    avoid_version=no
6791e07dc26bSmrg    bindir=
6792e07dc26bSmrg    dlfiles=
6793e07dc26bSmrg    dlprefiles=
6794e07dc26bSmrg    dlself=no
6795e07dc26bSmrg    export_dynamic=no
6796e07dc26bSmrg    export_symbols=
6797e07dc26bSmrg    export_symbols_regex=
6798e07dc26bSmrg    generated=
6799e07dc26bSmrg    libobjs=
6800e07dc26bSmrg    ltlibs=
6801e07dc26bSmrg    module=no
6802e07dc26bSmrg    no_install=no
6803e07dc26bSmrg    objs=
6804e07dc26bSmrg    os2dllname=
6805e07dc26bSmrg    non_pic_objects=
6806e07dc26bSmrg    precious_files_regex=
6807e07dc26bSmrg    prefer_static_libs=no
6808e07dc26bSmrg    preload=false
6809e07dc26bSmrg    prev=
6810e07dc26bSmrg    prevarg=
6811e07dc26bSmrg    release=
6812e07dc26bSmrg    rpath=
6813e07dc26bSmrg    xrpath=
6814e07dc26bSmrg    perm_rpath=
6815e07dc26bSmrg    temp_rpath=
6816e07dc26bSmrg    thread_safe=no
6817e07dc26bSmrg    vinfo=
6818e07dc26bSmrg    vinfo_number=no
6819e07dc26bSmrg    weak_libs=
6820e07dc26bSmrg    single_module=$wl-single_module
6821e07dc26bSmrg    func_infer_tag $base_compile
6822e07dc26bSmrg
6823e07dc26bSmrg    # We need to know -static, to get the right output filenames.
6824e07dc26bSmrg    for arg
6825e07dc26bSmrg    do
6826e07dc26bSmrg      case $arg in
6827e07dc26bSmrg      -shared)
6828e07dc26bSmrg	test yes != "$build_libtool_libs" \
6829e07dc26bSmrg	  && func_fatal_configuration "cannot build a shared library"
6830e07dc26bSmrg	build_old_libs=no
6831e07dc26bSmrg	break
6832e07dc26bSmrg	;;
6833e07dc26bSmrg      -all-static | -static | -static-libtool-libs)
6834e07dc26bSmrg	case $arg in
6835e07dc26bSmrg	-all-static)
6836e07dc26bSmrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
6837e07dc26bSmrg	    func_warning "complete static linking is impossible in this configuration"
6838e07dc26bSmrg	  fi
6839e07dc26bSmrg	  if test -n "$link_static_flag"; then
6840e07dc26bSmrg	    dlopen_self=$dlopen_self_static
6841e07dc26bSmrg	  fi
6842e07dc26bSmrg	  prefer_static_libs=yes
6843e07dc26bSmrg	  ;;
6844e07dc26bSmrg	-static)
6845e07dc26bSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6846e07dc26bSmrg	    dlopen_self=$dlopen_self_static
6847e07dc26bSmrg	  fi
6848e07dc26bSmrg	  prefer_static_libs=built
6849e07dc26bSmrg	  ;;
6850e07dc26bSmrg	-static-libtool-libs)
6851e07dc26bSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6852e07dc26bSmrg	    dlopen_self=$dlopen_self_static
6853e07dc26bSmrg	  fi
6854e07dc26bSmrg	  prefer_static_libs=yes
6855e07dc26bSmrg	  ;;
6856e07dc26bSmrg	esac
6857e07dc26bSmrg	build_libtool_libs=no
6858e07dc26bSmrg	build_old_libs=yes
6859e07dc26bSmrg	break
6860e07dc26bSmrg	;;
6861e07dc26bSmrg      esac
6862e07dc26bSmrg    done
6863e07dc26bSmrg
6864e07dc26bSmrg    # See if our shared archives depend on static archives.
6865e07dc26bSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6866e07dc26bSmrg
6867e07dc26bSmrg    # Go through the arguments, transforming them on the way.
6868e07dc26bSmrg    while test "$#" -gt 0; do
6869e07dc26bSmrg      arg=$1
6870e07dc26bSmrg      shift
6871636c353eSmrg      func_quote_arg pretty,unquoted "$arg"
6872636c353eSmrg      qarg=$func_quote_arg_unquoted_result
6873636c353eSmrg      func_append libtool_args " $func_quote_arg_result"
6874e07dc26bSmrg
6875e07dc26bSmrg      # If the previous option needs an argument, assign it.
6876e07dc26bSmrg      if test -n "$prev"; then
6877e07dc26bSmrg	case $prev in
6878e07dc26bSmrg	output)
6879e07dc26bSmrg	  func_append compile_command " @OUTPUT@"
6880e07dc26bSmrg	  func_append finalize_command " @OUTPUT@"
6881e07dc26bSmrg	  ;;
6882e07dc26bSmrg	esac
6883e07dc26bSmrg
6884e07dc26bSmrg	case $prev in
6885e07dc26bSmrg	bindir)
6886e07dc26bSmrg	  bindir=$arg
6887e07dc26bSmrg	  prev=
6888e07dc26bSmrg	  continue
6889e07dc26bSmrg	  ;;
6890e07dc26bSmrg	dlfiles|dlprefiles)
6891e07dc26bSmrg	  $preload || {
6892e07dc26bSmrg	    # Add the symbol object into the linking commands.
6893e07dc26bSmrg	    func_append compile_command " @SYMFILE@"
6894e07dc26bSmrg	    func_append finalize_command " @SYMFILE@"
6895e07dc26bSmrg	    preload=:
6896e07dc26bSmrg	  }
6897e07dc26bSmrg	  case $arg in
6898e07dc26bSmrg	  *.la | *.lo) ;;  # We handle these cases below.
6899e07dc26bSmrg	  force)
6900e07dc26bSmrg	    if test no = "$dlself"; then
6901e07dc26bSmrg	      dlself=needless
6902e07dc26bSmrg	      export_dynamic=yes
6903e07dc26bSmrg	    fi
6904e07dc26bSmrg	    prev=
6905e07dc26bSmrg	    continue
6906e07dc26bSmrg	    ;;
6907e07dc26bSmrg	  self)
6908e07dc26bSmrg	    if test dlprefiles = "$prev"; then
6909e07dc26bSmrg	      dlself=yes
6910e07dc26bSmrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
6911e07dc26bSmrg	      dlself=yes
6912e07dc26bSmrg	    else
6913e07dc26bSmrg	      dlself=needless
6914e07dc26bSmrg	      export_dynamic=yes
6915e07dc26bSmrg	    fi
6916e07dc26bSmrg	    prev=
6917e07dc26bSmrg	    continue
6918e07dc26bSmrg	    ;;
6919e07dc26bSmrg	  *)
6920e07dc26bSmrg	    if test dlfiles = "$prev"; then
6921e07dc26bSmrg	      func_append dlfiles " $arg"
6922e07dc26bSmrg	    else
6923e07dc26bSmrg	      func_append dlprefiles " $arg"
6924e07dc26bSmrg	    fi
6925e07dc26bSmrg	    prev=
6926e07dc26bSmrg	    continue
6927e07dc26bSmrg	    ;;
6928e07dc26bSmrg	  esac
6929e07dc26bSmrg	  ;;
6930e07dc26bSmrg	expsyms)
6931e07dc26bSmrg	  export_symbols=$arg
6932e07dc26bSmrg	  test -f "$arg" \
6933e07dc26bSmrg	    || func_fatal_error "symbol file '$arg' does not exist"
6934e07dc26bSmrg	  prev=
6935e07dc26bSmrg	  continue
6936e07dc26bSmrg	  ;;
6937e07dc26bSmrg	expsyms_regex)
6938e07dc26bSmrg	  export_symbols_regex=$arg
6939e07dc26bSmrg	  prev=
6940e07dc26bSmrg	  continue
6941e07dc26bSmrg	  ;;
6942e07dc26bSmrg	framework)
6943e07dc26bSmrg	  case $host in
6944e07dc26bSmrg	    *-*-darwin*)
6945e07dc26bSmrg	      case "$deplibs " in
6946e07dc26bSmrg		*" $qarg.ltframework "*) ;;
6947e07dc26bSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
6948e07dc26bSmrg		   ;;
6949e07dc26bSmrg	      esac
6950e07dc26bSmrg	      ;;
6951e07dc26bSmrg	  esac
6952e07dc26bSmrg	  prev=
6953e07dc26bSmrg	  continue
6954e07dc26bSmrg	  ;;
6955e07dc26bSmrg	inst_prefix)
6956e07dc26bSmrg	  inst_prefix_dir=$arg
6957e07dc26bSmrg	  prev=
6958e07dc26bSmrg	  continue
6959e07dc26bSmrg	  ;;
6960e07dc26bSmrg	mllvm)
6961e07dc26bSmrg	  # Clang does not use LLVM to link, so we can simply discard any
6962e07dc26bSmrg	  # '-mllvm $arg' options when doing the link step.
6963e07dc26bSmrg	  prev=
6964e07dc26bSmrg	  continue
6965e07dc26bSmrg	  ;;
6966e07dc26bSmrg	objectlist)
6967e07dc26bSmrg	  if test -f "$arg"; then
6968e07dc26bSmrg	    save_arg=$arg
6969e07dc26bSmrg	    moreargs=
6970e07dc26bSmrg	    for fil in `cat "$save_arg"`
6971e07dc26bSmrg	    do
6972e07dc26bSmrg#	      func_append moreargs " $fil"
6973e07dc26bSmrg	      arg=$fil
6974e07dc26bSmrg	      # A libtool-controlled object.
6975e07dc26bSmrg
6976e07dc26bSmrg	      # Check to see that this really is a libtool object.
6977e07dc26bSmrg	      if func_lalib_unsafe_p "$arg"; then
6978e07dc26bSmrg		pic_object=
6979e07dc26bSmrg		non_pic_object=
6980e07dc26bSmrg
6981e07dc26bSmrg		# Read the .lo file
6982e07dc26bSmrg		func_source "$arg"
6983e07dc26bSmrg
6984e07dc26bSmrg		if test -z "$pic_object" ||
6985e07dc26bSmrg		   test -z "$non_pic_object" ||
6986e07dc26bSmrg		   test none = "$pic_object" &&
6987e07dc26bSmrg		   test none = "$non_pic_object"; then
6988e07dc26bSmrg		  func_fatal_error "cannot find name of object for '$arg'"
6989e07dc26bSmrg		fi
6990e07dc26bSmrg
6991e07dc26bSmrg		# Extract subdirectory from the argument.
6992e07dc26bSmrg		func_dirname "$arg" "/" ""
6993e07dc26bSmrg		xdir=$func_dirname_result
6994e07dc26bSmrg
6995e07dc26bSmrg		if test none != "$pic_object"; then
6996e07dc26bSmrg		  # Prepend the subdirectory the object is found in.
6997e07dc26bSmrg		  pic_object=$xdir$pic_object
6998e07dc26bSmrg
6999e07dc26bSmrg		  if test dlfiles = "$prev"; then
7000e07dc26bSmrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7001e07dc26bSmrg		      func_append dlfiles " $pic_object"
7002e07dc26bSmrg		      prev=
7003e07dc26bSmrg		      continue
7004e07dc26bSmrg		    else
7005e07dc26bSmrg		      # If libtool objects are unsupported, then we need to preload.
7006e07dc26bSmrg		      prev=dlprefiles
7007e07dc26bSmrg		    fi
7008e07dc26bSmrg		  fi
7009e07dc26bSmrg
7010e07dc26bSmrg		  # CHECK ME:  I think I busted this.  -Ossama
7011e07dc26bSmrg		  if test dlprefiles = "$prev"; then
7012e07dc26bSmrg		    # Preload the old-style object.
7013e07dc26bSmrg		    func_append dlprefiles " $pic_object"
7014e07dc26bSmrg		    prev=
7015e07dc26bSmrg		  fi
7016e07dc26bSmrg
7017e07dc26bSmrg		  # A PIC object.
7018e07dc26bSmrg		  func_append libobjs " $pic_object"
7019e07dc26bSmrg		  arg=$pic_object
7020e07dc26bSmrg		fi
7021e07dc26bSmrg
7022e07dc26bSmrg		# Non-PIC object.
7023e07dc26bSmrg		if test none != "$non_pic_object"; then
7024e07dc26bSmrg		  # Prepend the subdirectory the object is found in.
7025e07dc26bSmrg		  non_pic_object=$xdir$non_pic_object
7026e07dc26bSmrg
7027e07dc26bSmrg		  # A standard non-PIC object
7028e07dc26bSmrg		  func_append non_pic_objects " $non_pic_object"
7029e07dc26bSmrg		  if test -z "$pic_object" || test none = "$pic_object"; then
7030e07dc26bSmrg		    arg=$non_pic_object
7031e07dc26bSmrg		  fi
7032e07dc26bSmrg		else
7033e07dc26bSmrg		  # If the PIC object exists, use it instead.
7034e07dc26bSmrg		  # $xdir was prepended to $pic_object above.
7035e07dc26bSmrg		  non_pic_object=$pic_object
7036e07dc26bSmrg		  func_append non_pic_objects " $non_pic_object"
7037e07dc26bSmrg		fi
7038e07dc26bSmrg	      else
7039e07dc26bSmrg		# Only an error if not doing a dry-run.
7040e07dc26bSmrg		if $opt_dry_run; then
7041e07dc26bSmrg		  # Extract subdirectory from the argument.
7042e07dc26bSmrg		  func_dirname "$arg" "/" ""
7043e07dc26bSmrg		  xdir=$func_dirname_result
7044e07dc26bSmrg
7045e07dc26bSmrg		  func_lo2o "$arg"
7046e07dc26bSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
7047e07dc26bSmrg		  non_pic_object=$xdir$func_lo2o_result
7048e07dc26bSmrg		  func_append libobjs " $pic_object"
7049e07dc26bSmrg		  func_append non_pic_objects " $non_pic_object"
7050e07dc26bSmrg	        else
7051e07dc26bSmrg		  func_fatal_error "'$arg' is not a valid libtool object"
7052e07dc26bSmrg		fi
7053e07dc26bSmrg	      fi
7054e07dc26bSmrg	    done
7055e07dc26bSmrg	  else
7056e07dc26bSmrg	    func_fatal_error "link input file '$arg' does not exist"
7057e07dc26bSmrg	  fi
7058e07dc26bSmrg	  arg=$save_arg
7059e07dc26bSmrg	  prev=
7060e07dc26bSmrg	  continue
7061e07dc26bSmrg	  ;;
7062e07dc26bSmrg	os2dllname)
7063e07dc26bSmrg	  os2dllname=$arg
7064e07dc26bSmrg	  prev=
7065e07dc26bSmrg	  continue
7066e07dc26bSmrg	  ;;
7067e07dc26bSmrg	precious_regex)
7068e07dc26bSmrg	  precious_files_regex=$arg
7069e07dc26bSmrg	  prev=
7070e07dc26bSmrg	  continue
7071e07dc26bSmrg	  ;;
7072e07dc26bSmrg	release)
7073e07dc26bSmrg	  release=-$arg
7074e07dc26bSmrg	  prev=
7075e07dc26bSmrg	  continue
7076e07dc26bSmrg	  ;;
7077e07dc26bSmrg	rpath | xrpath)
7078e07dc26bSmrg	  # We need an absolute path.
7079e07dc26bSmrg	  case $arg in
7080e07dc26bSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
7081e07dc26bSmrg	  *)
7082e07dc26bSmrg	    func_fatal_error "only absolute run-paths are allowed"
7083e07dc26bSmrg	    ;;
7084e07dc26bSmrg	  esac
7085e07dc26bSmrg	  if test rpath = "$prev"; then
7086e07dc26bSmrg	    case "$rpath " in
7087e07dc26bSmrg	    *" $arg "*) ;;
7088e07dc26bSmrg	    *) func_append rpath " $arg" ;;
7089e07dc26bSmrg	    esac
7090e07dc26bSmrg	  else
7091e07dc26bSmrg	    case "$xrpath " in
7092e07dc26bSmrg	    *" $arg "*) ;;
7093e07dc26bSmrg	    *) func_append xrpath " $arg" ;;
7094e07dc26bSmrg	    esac
7095e07dc26bSmrg	  fi
7096e07dc26bSmrg	  prev=
7097e07dc26bSmrg	  continue
7098e07dc26bSmrg	  ;;
7099e07dc26bSmrg	shrext)
7100e07dc26bSmrg	  shrext_cmds=$arg
7101e07dc26bSmrg	  prev=
7102e07dc26bSmrg	  continue
7103e07dc26bSmrg	  ;;
7104e07dc26bSmrg	weak)
7105e07dc26bSmrg	  func_append weak_libs " $arg"
7106e07dc26bSmrg	  prev=
7107e07dc26bSmrg	  continue
7108e07dc26bSmrg	  ;;
7109636c353eSmrg	xassembler)
7110636c353eSmrg	  func_append compiler_flags " -Xassembler $qarg"
7111636c353eSmrg	  prev=
7112636c353eSmrg	  func_append compile_command " -Xassembler $qarg"
7113636c353eSmrg	  func_append finalize_command " -Xassembler $qarg"
7114636c353eSmrg	  continue
7115636c353eSmrg	  ;;
7116e07dc26bSmrg	xcclinker)
7117e07dc26bSmrg	  func_append linker_flags " $qarg"
7118e07dc26bSmrg	  func_append compiler_flags " $qarg"
7119e07dc26bSmrg	  prev=
7120e07dc26bSmrg	  func_append compile_command " $qarg"
7121e07dc26bSmrg	  func_append finalize_command " $qarg"
7122e07dc26bSmrg	  continue
7123e07dc26bSmrg	  ;;
7124e07dc26bSmrg	xcompiler)
7125e07dc26bSmrg	  func_append compiler_flags " $qarg"
7126e07dc26bSmrg	  prev=
7127e07dc26bSmrg	  func_append compile_command " $qarg"
7128e07dc26bSmrg	  func_append finalize_command " $qarg"
7129e07dc26bSmrg	  continue
7130e07dc26bSmrg	  ;;
7131e07dc26bSmrg	xlinker)
7132e07dc26bSmrg	  func_append linker_flags " $qarg"
7133e07dc26bSmrg	  func_append compiler_flags " $wl$qarg"
7134e07dc26bSmrg	  prev=
7135e07dc26bSmrg	  func_append compile_command " $wl$qarg"
7136e07dc26bSmrg	  func_append finalize_command " $wl$qarg"
7137e07dc26bSmrg	  continue
7138e07dc26bSmrg	  ;;
7139e07dc26bSmrg	*)
7140e07dc26bSmrg	  eval "$prev=\"\$arg\""
7141e07dc26bSmrg	  prev=
7142e07dc26bSmrg	  continue
7143e07dc26bSmrg	  ;;
7144e07dc26bSmrg	esac
7145e07dc26bSmrg      fi # test -n "$prev"
7146e07dc26bSmrg
7147e07dc26bSmrg      prevarg=$arg
7148e07dc26bSmrg
7149e07dc26bSmrg      case $arg in
7150e07dc26bSmrg      -all-static)
7151e07dc26bSmrg	if test -n "$link_static_flag"; then
7152e07dc26bSmrg	  # See comment for -static flag below, for more details.
7153e07dc26bSmrg	  func_append compile_command " $link_static_flag"
7154e07dc26bSmrg	  func_append finalize_command " $link_static_flag"
7155e07dc26bSmrg	fi
7156e07dc26bSmrg	continue
7157e07dc26bSmrg	;;
7158e07dc26bSmrg
7159e07dc26bSmrg      -allow-undefined)
7160e07dc26bSmrg	# FIXME: remove this flag sometime in the future.
7161e07dc26bSmrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
7162e07dc26bSmrg	;;
7163e07dc26bSmrg
7164e07dc26bSmrg      -avoid-version)
7165e07dc26bSmrg	avoid_version=yes
7166e07dc26bSmrg	continue
7167e07dc26bSmrg	;;
7168e07dc26bSmrg
7169e07dc26bSmrg      -bindir)
7170e07dc26bSmrg	prev=bindir
7171e07dc26bSmrg	continue
7172e07dc26bSmrg	;;
7173e07dc26bSmrg
7174e07dc26bSmrg      -dlopen)
7175e07dc26bSmrg	prev=dlfiles
7176e07dc26bSmrg	continue
7177e07dc26bSmrg	;;
7178e07dc26bSmrg
7179e07dc26bSmrg      -dlpreopen)
7180e07dc26bSmrg	prev=dlprefiles
7181e07dc26bSmrg	continue
7182e07dc26bSmrg	;;
7183e07dc26bSmrg
7184e07dc26bSmrg      -export-dynamic)
7185e07dc26bSmrg	export_dynamic=yes
7186e07dc26bSmrg	continue
7187e07dc26bSmrg	;;
7188e07dc26bSmrg
7189e07dc26bSmrg      -export-symbols | -export-symbols-regex)
7190e07dc26bSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
7191e07dc26bSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
7192e07dc26bSmrg	fi
7193e07dc26bSmrg	if test X-export-symbols = "X$arg"; then
7194e07dc26bSmrg	  prev=expsyms
7195e07dc26bSmrg	else
7196e07dc26bSmrg	  prev=expsyms_regex
7197e07dc26bSmrg	fi
7198e07dc26bSmrg	continue
7199e07dc26bSmrg	;;
7200e07dc26bSmrg
7201e07dc26bSmrg      -framework)
7202e07dc26bSmrg	prev=framework
7203e07dc26bSmrg	continue
7204e07dc26bSmrg	;;
7205e07dc26bSmrg
7206e07dc26bSmrg      -inst-prefix-dir)
7207e07dc26bSmrg	prev=inst_prefix
7208e07dc26bSmrg	continue
7209e07dc26bSmrg	;;
7210e07dc26bSmrg
7211e07dc26bSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
7212e07dc26bSmrg      # so, if we see these flags be careful not to treat them like -L
7213e07dc26bSmrg      -L[A-Z][A-Z]*:*)
7214e07dc26bSmrg	case $with_gcc/$host in
7215e07dc26bSmrg	no/*-*-irix* | /*-*-irix*)
7216e07dc26bSmrg	  func_append compile_command " $arg"
7217e07dc26bSmrg	  func_append finalize_command " $arg"
7218e07dc26bSmrg	  ;;
7219e07dc26bSmrg	esac
7220e07dc26bSmrg	continue
7221e07dc26bSmrg	;;
7222e07dc26bSmrg
7223e07dc26bSmrg      -L*)
7224e07dc26bSmrg	func_stripname "-L" '' "$arg"
7225e07dc26bSmrg	if test -z "$func_stripname_result"; then
7226e07dc26bSmrg	  if test "$#" -gt 0; then
7227e07dc26bSmrg	    func_fatal_error "require no space between '-L' and '$1'"
7228e07dc26bSmrg	  else
7229e07dc26bSmrg	    func_fatal_error "need path for '-L' option"
7230e07dc26bSmrg	  fi
7231e07dc26bSmrg	fi
7232e07dc26bSmrg	func_resolve_sysroot "$func_stripname_result"
7233e07dc26bSmrg	dir=$func_resolve_sysroot_result
7234e07dc26bSmrg	# We need an absolute path.
7235e07dc26bSmrg	case $dir in
7236e07dc26bSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
7237e07dc26bSmrg	*)
7238e07dc26bSmrg	  absdir=`cd "$dir" && pwd`
7239e07dc26bSmrg	  test -z "$absdir" && \
7240e07dc26bSmrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
7241e07dc26bSmrg	  dir=$absdir
7242e07dc26bSmrg	  ;;
7243e07dc26bSmrg	esac
7244e07dc26bSmrg	case "$deplibs " in
7245e07dc26bSmrg	*" -L$dir "* | *" $arg "*)
7246e07dc26bSmrg	  # Will only happen for absolute or sysroot arguments
7247e07dc26bSmrg	  ;;
7248e07dc26bSmrg	*)
7249e07dc26bSmrg	  # Preserve sysroot, but never include relative directories
7250e07dc26bSmrg	  case $dir in
7251e07dc26bSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
7252e07dc26bSmrg	    *) func_append deplibs " -L$dir" ;;
7253e07dc26bSmrg	  esac
7254e07dc26bSmrg	  func_append lib_search_path " $dir"
7255e07dc26bSmrg	  ;;
7256e07dc26bSmrg	esac
7257e07dc26bSmrg	case $host in
7258e07dc26bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7259e07dc26bSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
7260e07dc26bSmrg	  case :$dllsearchpath: in
7261e07dc26bSmrg	  *":$dir:"*) ;;
7262e07dc26bSmrg	  ::) dllsearchpath=$dir;;
7263e07dc26bSmrg	  *) func_append dllsearchpath ":$dir";;
7264e07dc26bSmrg	  esac
7265e07dc26bSmrg	  case :$dllsearchpath: in
7266e07dc26bSmrg	  *":$testbindir:"*) ;;
7267e07dc26bSmrg	  ::) dllsearchpath=$testbindir;;
7268e07dc26bSmrg	  *) func_append dllsearchpath ":$testbindir";;
7269e07dc26bSmrg	  esac
7270e07dc26bSmrg	  ;;
7271e07dc26bSmrg	esac
7272e07dc26bSmrg	continue
7273e07dc26bSmrg	;;
7274e07dc26bSmrg
7275e07dc26bSmrg      -l*)
7276e07dc26bSmrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
7277e07dc26bSmrg	  case $host in
7278e07dc26bSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
7279e07dc26bSmrg	    # These systems don't actually have a C or math library (as such)
7280e07dc26bSmrg	    continue
7281e07dc26bSmrg	    ;;
7282e07dc26bSmrg	  *-*-os2*)
7283e07dc26bSmrg	    # These systems don't actually have a C library (as such)
7284e07dc26bSmrg	    test X-lc = "X$arg" && continue
7285e07dc26bSmrg	    ;;
7286636c353eSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*)
7287e07dc26bSmrg	    # Do not include libc due to us having libc/libc_r.
7288e07dc26bSmrg	    test X-lc = "X$arg" && continue
7289e07dc26bSmrg	    ;;
7290e07dc26bSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
7291e07dc26bSmrg	    # Rhapsody C and math libraries are in the System framework
7292e07dc26bSmrg	    func_append deplibs " System.ltframework"
7293e07dc26bSmrg	    continue
7294e07dc26bSmrg	    ;;
7295e07dc26bSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7296e07dc26bSmrg	    # Causes problems with __ctype
7297e07dc26bSmrg	    test X-lc = "X$arg" && continue
7298e07dc26bSmrg	    ;;
7299e07dc26bSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7300e07dc26bSmrg	    # Compiler inserts libc in the correct place for threads to work
7301e07dc26bSmrg	    test X-lc = "X$arg" && continue
7302e07dc26bSmrg	    ;;
7303e07dc26bSmrg	  esac
7304e07dc26bSmrg	elif test X-lc_r = "X$arg"; then
7305e07dc26bSmrg	 case $host in
7306636c353eSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*)
7307e07dc26bSmrg	   # Do not include libc_r directly, use -pthread flag.
7308e07dc26bSmrg	   continue
7309e07dc26bSmrg	   ;;
7310e07dc26bSmrg	 esac
7311e07dc26bSmrg	fi
7312e07dc26bSmrg	func_append deplibs " $arg"
7313e07dc26bSmrg	continue
7314e07dc26bSmrg	;;
7315e07dc26bSmrg
7316e07dc26bSmrg      -mllvm)
7317e07dc26bSmrg	prev=mllvm
7318e07dc26bSmrg	continue
7319e07dc26bSmrg	;;
7320e07dc26bSmrg
7321e07dc26bSmrg      -module)
7322e07dc26bSmrg	module=yes
7323e07dc26bSmrg	continue
7324e07dc26bSmrg	;;
7325e07dc26bSmrg
7326e07dc26bSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
7327e07dc26bSmrg      # classes, name mangling, and exception handling.
7328e07dc26bSmrg      # Darwin uses the -arch flag to determine output architecture.
7329e07dc26bSmrg      -model|-arch|-isysroot|--sysroot)
7330e07dc26bSmrg	func_append compiler_flags " $arg"
7331e07dc26bSmrg	func_append compile_command " $arg"
7332e07dc26bSmrg	func_append finalize_command " $arg"
7333e07dc26bSmrg	prev=xcompiler
7334e07dc26bSmrg	continue
7335e07dc26bSmrg	;;
7336636c353eSmrg     # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199.
7337636c353eSmrg     -pthread)
7338636c353eSmrg	case $host in
7339636c353eSmrg	  *solaris2*) ;;
7340636c353eSmrg	  *)
7341636c353eSmrg	    case "$new_inherited_linker_flags " in
7342636c353eSmrg	        *" $arg "*) ;;
7343636c353eSmrg	        * ) func_append new_inherited_linker_flags " $arg" ;;
7344636c353eSmrg	    esac
7345636c353eSmrg	  ;;
7346636c353eSmrg	esac
7347636c353eSmrg	continue
7348636c353eSmrg	;;
7349636c353eSmrg      -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \
7350e07dc26bSmrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7351e07dc26bSmrg	func_append compiler_flags " $arg"
7352e07dc26bSmrg	func_append compile_command " $arg"
7353e07dc26bSmrg	func_append finalize_command " $arg"
7354e07dc26bSmrg	case "$new_inherited_linker_flags " in
7355e07dc26bSmrg	    *" $arg "*) ;;
7356e07dc26bSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
7357e07dc26bSmrg	esac
7358e07dc26bSmrg	continue
7359e07dc26bSmrg	;;
7360e07dc26bSmrg
7361e07dc26bSmrg      -multi_module)
7362e07dc26bSmrg	single_module=$wl-multi_module
7363e07dc26bSmrg	continue
7364e07dc26bSmrg	;;
7365e07dc26bSmrg
7366e07dc26bSmrg      -no-fast-install)
7367e07dc26bSmrg	fast_install=no
7368e07dc26bSmrg	continue
7369e07dc26bSmrg	;;
7370e07dc26bSmrg
7371e07dc26bSmrg      -no-install)
7372e07dc26bSmrg	case $host in
7373e07dc26bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
7374e07dc26bSmrg	  # The PATH hackery in wrapper scripts is required on Windows
7375e07dc26bSmrg	  # and Darwin in order for the loader to find any dlls it needs.
7376e07dc26bSmrg	  func_warning "'-no-install' is ignored for $host"
7377e07dc26bSmrg	  func_warning "assuming '-no-fast-install' instead"
7378e07dc26bSmrg	  fast_install=no
7379e07dc26bSmrg	  ;;
7380e07dc26bSmrg	*) no_install=yes ;;
7381e07dc26bSmrg	esac
7382e07dc26bSmrg	continue
7383e07dc26bSmrg	;;
7384e07dc26bSmrg
7385e07dc26bSmrg      -no-undefined)
7386e07dc26bSmrg	allow_undefined=no
7387e07dc26bSmrg	continue
7388e07dc26bSmrg	;;
7389e07dc26bSmrg
7390e07dc26bSmrg      -objectlist)
7391e07dc26bSmrg	prev=objectlist
7392e07dc26bSmrg	continue
7393e07dc26bSmrg	;;
7394e07dc26bSmrg
7395e07dc26bSmrg      -os2dllname)
7396e07dc26bSmrg	prev=os2dllname
7397e07dc26bSmrg	continue
7398e07dc26bSmrg	;;
7399e07dc26bSmrg
7400e07dc26bSmrg      -o) prev=output ;;
7401e07dc26bSmrg
7402e07dc26bSmrg      -precious-files-regex)
7403e07dc26bSmrg	prev=precious_regex
7404e07dc26bSmrg	continue
7405e07dc26bSmrg	;;
7406e07dc26bSmrg
7407e07dc26bSmrg      -release)
7408e07dc26bSmrg	prev=release
7409e07dc26bSmrg	continue
7410e07dc26bSmrg	;;
7411e07dc26bSmrg
7412e07dc26bSmrg      -rpath)
7413e07dc26bSmrg	prev=rpath
7414e07dc26bSmrg	continue
7415e07dc26bSmrg	;;
7416e07dc26bSmrg
7417e07dc26bSmrg      -R)
7418e07dc26bSmrg	prev=xrpath
7419e07dc26bSmrg	continue
7420e07dc26bSmrg	;;
7421e07dc26bSmrg
7422e07dc26bSmrg      -R*)
7423e07dc26bSmrg	func_stripname '-R' '' "$arg"
7424e07dc26bSmrg	dir=$func_stripname_result
7425e07dc26bSmrg	# We need an absolute path.
7426e07dc26bSmrg	case $dir in
7427e07dc26bSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
7428e07dc26bSmrg	=*)
7429e07dc26bSmrg	  func_stripname '=' '' "$dir"
7430e07dc26bSmrg	  dir=$lt_sysroot$func_stripname_result
7431e07dc26bSmrg	  ;;
7432e07dc26bSmrg	*)
7433e07dc26bSmrg	  func_fatal_error "only absolute run-paths are allowed"
7434e07dc26bSmrg	  ;;
7435e07dc26bSmrg	esac
7436e07dc26bSmrg	case "$xrpath " in
7437e07dc26bSmrg	*" $dir "*) ;;
7438e07dc26bSmrg	*) func_append xrpath " $dir" ;;
7439e07dc26bSmrg	esac
7440e07dc26bSmrg	continue
7441e07dc26bSmrg	;;
7442e07dc26bSmrg
7443e07dc26bSmrg      -shared)
7444e07dc26bSmrg	# The effects of -shared are defined in a previous loop.
7445e07dc26bSmrg	continue
7446e07dc26bSmrg	;;
7447e07dc26bSmrg
7448e07dc26bSmrg      -shrext)
7449e07dc26bSmrg	prev=shrext
7450e07dc26bSmrg	continue
7451e07dc26bSmrg	;;
7452e07dc26bSmrg
7453e07dc26bSmrg      -static | -static-libtool-libs)
7454e07dc26bSmrg	# The effects of -static are defined in a previous loop.
7455e07dc26bSmrg	# We used to do the same as -all-static on platforms that
7456e07dc26bSmrg	# didn't have a PIC flag, but the assumption that the effects
7457e07dc26bSmrg	# would be equivalent was wrong.  It would break on at least
7458e07dc26bSmrg	# Digital Unix and AIX.
7459e07dc26bSmrg	continue
7460e07dc26bSmrg	;;
7461e07dc26bSmrg
7462e07dc26bSmrg      -thread-safe)
7463e07dc26bSmrg	thread_safe=yes
7464e07dc26bSmrg	continue
7465e07dc26bSmrg	;;
7466e07dc26bSmrg
7467e07dc26bSmrg      -version-info)
7468e07dc26bSmrg	prev=vinfo
7469e07dc26bSmrg	continue
7470e07dc26bSmrg	;;
7471e07dc26bSmrg
7472e07dc26bSmrg      -version-number)
7473e07dc26bSmrg	prev=vinfo
7474e07dc26bSmrg	vinfo_number=yes
7475e07dc26bSmrg	continue
7476e07dc26bSmrg	;;
7477e07dc26bSmrg
7478e07dc26bSmrg      -weak)
7479e07dc26bSmrg        prev=weak
7480e07dc26bSmrg	continue
7481e07dc26bSmrg	;;
7482e07dc26bSmrg
7483e07dc26bSmrg      -Wc,*)
7484e07dc26bSmrg	func_stripname '-Wc,' '' "$arg"
7485e07dc26bSmrg	args=$func_stripname_result
7486e07dc26bSmrg	arg=
7487e07dc26bSmrg	save_ifs=$IFS; IFS=,
7488e07dc26bSmrg	for flag in $args; do
7489e07dc26bSmrg	  IFS=$save_ifs
7490636c353eSmrg          func_quote_arg pretty "$flag"
7491636c353eSmrg	  func_append arg " $func_quote_arg_result"
7492636c353eSmrg	  func_append compiler_flags " $func_quote_arg_result"
7493e07dc26bSmrg	done
7494e07dc26bSmrg	IFS=$save_ifs
7495e07dc26bSmrg	func_stripname ' ' '' "$arg"
7496e07dc26bSmrg	arg=$func_stripname_result
7497e07dc26bSmrg	;;
7498e07dc26bSmrg
7499e07dc26bSmrg      -Wl,*)
7500e07dc26bSmrg	func_stripname '-Wl,' '' "$arg"
7501e07dc26bSmrg	args=$func_stripname_result
7502e07dc26bSmrg	arg=
7503e07dc26bSmrg	save_ifs=$IFS; IFS=,
7504e07dc26bSmrg	for flag in $args; do
7505e07dc26bSmrg	  IFS=$save_ifs
7506636c353eSmrg          func_quote_arg pretty "$flag"
7507636c353eSmrg	  func_append arg " $wl$func_quote_arg_result"
7508636c353eSmrg	  func_append compiler_flags " $wl$func_quote_arg_result"
7509636c353eSmrg	  func_append linker_flags " $func_quote_arg_result"
7510e07dc26bSmrg	done
7511e07dc26bSmrg	IFS=$save_ifs
7512e07dc26bSmrg	func_stripname ' ' '' "$arg"
7513e07dc26bSmrg	arg=$func_stripname_result
7514e07dc26bSmrg	;;
7515e07dc26bSmrg
7516636c353eSmrg      -Xassembler)
7517636c353eSmrg        prev=xassembler
7518636c353eSmrg        continue
7519636c353eSmrg        ;;
7520636c353eSmrg
7521e07dc26bSmrg      -Xcompiler)
7522e07dc26bSmrg	prev=xcompiler
7523e07dc26bSmrg	continue
7524e07dc26bSmrg	;;
7525e07dc26bSmrg
7526e07dc26bSmrg      -Xlinker)
7527e07dc26bSmrg	prev=xlinker
7528e07dc26bSmrg	continue
7529e07dc26bSmrg	;;
7530e07dc26bSmrg
7531e07dc26bSmrg      -XCClinker)
7532e07dc26bSmrg	prev=xcclinker
7533e07dc26bSmrg	continue
7534e07dc26bSmrg	;;
7535e07dc26bSmrg
7536e07dc26bSmrg      # -msg_* for osf cc
7537e07dc26bSmrg      -msg_*)
7538636c353eSmrg	func_quote_arg pretty "$arg"
7539636c353eSmrg	arg=$func_quote_arg_result
7540e07dc26bSmrg	;;
7541e07dc26bSmrg
7542e07dc26bSmrg      # Flags to be passed through unchanged, with rationale:
7543e07dc26bSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
7544e07dc26bSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
7545e07dc26bSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7546e07dc26bSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
7547e07dc26bSmrg      # -q*                  compiler args for the IBM compiler
7548e07dc26bSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7549e07dc26bSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
7550e07dc26bSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
7551e07dc26bSmrg      # -fstack-protector*   stack protector flags for GCC
7552e07dc26bSmrg      # @file                GCC response files
7553e07dc26bSmrg      # -tp=*                Portland pgcc target processor selection
7554e07dc26bSmrg      # --sysroot=*          for sysroot support
7555e07dc26bSmrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
7556e07dc26bSmrg      # -specs=*             GCC specs files
7557e07dc26bSmrg      # -stdlib=*            select c++ std lib with clang
7558e07dc26bSmrg      # -fsanitize=*         Clang/GCC memory and address sanitizer
7559636c353eSmrg      # -fuse-ld=*           Linker select flags for GCC
7560636c353eSmrg      # -Wa,*                Pass flags directly to the assembler
7561e07dc26bSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7562e07dc26bSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
7563e07dc26bSmrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
7564636c353eSmrg      -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*)
7565636c353eSmrg        func_quote_arg pretty "$arg"
7566636c353eSmrg	arg=$func_quote_arg_result
7567e07dc26bSmrg        func_append compile_command " $arg"
7568e07dc26bSmrg        func_append finalize_command " $arg"
7569e07dc26bSmrg        func_append compiler_flags " $arg"
7570e07dc26bSmrg        continue
7571e07dc26bSmrg        ;;
7572e07dc26bSmrg
7573e07dc26bSmrg      -Z*)
7574e07dc26bSmrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
7575e07dc26bSmrg          # OS/2 uses -Zxxx to specify OS/2-specific options
7576e07dc26bSmrg	  compiler_flags="$compiler_flags $arg"
7577e07dc26bSmrg	  func_append compile_command " $arg"
7578e07dc26bSmrg	  func_append finalize_command " $arg"
7579e07dc26bSmrg	  case $arg in
7580e07dc26bSmrg	  -Zlinker | -Zstack)
7581e07dc26bSmrg	    prev=xcompiler
7582e07dc26bSmrg	    ;;
7583e07dc26bSmrg	  esac
7584e07dc26bSmrg	  continue
7585e07dc26bSmrg        else
7586e07dc26bSmrg	  # Otherwise treat like 'Some other compiler flag' below
7587636c353eSmrg	  func_quote_arg pretty "$arg"
7588636c353eSmrg	  arg=$func_quote_arg_result
7589e07dc26bSmrg        fi
7590e07dc26bSmrg	;;
7591e07dc26bSmrg
7592e07dc26bSmrg      # Some other compiler flag.
7593e07dc26bSmrg      -* | +*)
7594636c353eSmrg        func_quote_arg pretty "$arg"
7595636c353eSmrg	arg=$func_quote_arg_result
7596e07dc26bSmrg	;;
7597e07dc26bSmrg
7598e07dc26bSmrg      *.$objext)
7599e07dc26bSmrg	# A standard object.
7600e07dc26bSmrg	func_append objs " $arg"
7601e07dc26bSmrg	;;
7602e07dc26bSmrg
7603e07dc26bSmrg      *.lo)
7604e07dc26bSmrg	# A libtool-controlled object.
7605e07dc26bSmrg
7606e07dc26bSmrg	# Check to see that this really is a libtool object.
7607e07dc26bSmrg	if func_lalib_unsafe_p "$arg"; then
7608e07dc26bSmrg	  pic_object=
7609e07dc26bSmrg	  non_pic_object=
7610e07dc26bSmrg
7611e07dc26bSmrg	  # Read the .lo file
7612e07dc26bSmrg	  func_source "$arg"
7613e07dc26bSmrg
7614e07dc26bSmrg	  if test -z "$pic_object" ||
7615e07dc26bSmrg	     test -z "$non_pic_object" ||
7616e07dc26bSmrg	     test none = "$pic_object" &&
7617e07dc26bSmrg	     test none = "$non_pic_object"; then
7618e07dc26bSmrg	    func_fatal_error "cannot find name of object for '$arg'"
7619e07dc26bSmrg	  fi
7620e07dc26bSmrg
7621e07dc26bSmrg	  # Extract subdirectory from the argument.
7622e07dc26bSmrg	  func_dirname "$arg" "/" ""
7623e07dc26bSmrg	  xdir=$func_dirname_result
7624e07dc26bSmrg
7625e07dc26bSmrg	  test none = "$pic_object" || {
7626e07dc26bSmrg	    # Prepend the subdirectory the object is found in.
7627e07dc26bSmrg	    pic_object=$xdir$pic_object
7628e07dc26bSmrg
7629e07dc26bSmrg	    if test dlfiles = "$prev"; then
7630e07dc26bSmrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7631e07dc26bSmrg		func_append dlfiles " $pic_object"
7632e07dc26bSmrg		prev=
7633e07dc26bSmrg		continue
7634e07dc26bSmrg	      else
7635e07dc26bSmrg		# If libtool objects are unsupported, then we need to preload.
7636e07dc26bSmrg		prev=dlprefiles
7637e07dc26bSmrg	      fi
7638e07dc26bSmrg	    fi
7639e07dc26bSmrg
7640e07dc26bSmrg	    # CHECK ME:  I think I busted this.  -Ossama
7641e07dc26bSmrg	    if test dlprefiles = "$prev"; then
7642e07dc26bSmrg	      # Preload the old-style object.
7643e07dc26bSmrg	      func_append dlprefiles " $pic_object"
7644e07dc26bSmrg	      prev=
7645e07dc26bSmrg	    fi
7646e07dc26bSmrg
7647e07dc26bSmrg	    # A PIC object.
7648e07dc26bSmrg	    func_append libobjs " $pic_object"
7649e07dc26bSmrg	    arg=$pic_object
7650e07dc26bSmrg	  }
7651e07dc26bSmrg
7652e07dc26bSmrg	  # Non-PIC object.
7653e07dc26bSmrg	  if test none != "$non_pic_object"; then
7654e07dc26bSmrg	    # Prepend the subdirectory the object is found in.
7655e07dc26bSmrg	    non_pic_object=$xdir$non_pic_object
7656e07dc26bSmrg
7657e07dc26bSmrg	    # A standard non-PIC object
7658e07dc26bSmrg	    func_append non_pic_objects " $non_pic_object"
7659e07dc26bSmrg	    if test -z "$pic_object" || test none = "$pic_object"; then
7660e07dc26bSmrg	      arg=$non_pic_object
7661e07dc26bSmrg	    fi
7662e07dc26bSmrg	  else
7663e07dc26bSmrg	    # If the PIC object exists, use it instead.
7664e07dc26bSmrg	    # $xdir was prepended to $pic_object above.
7665e07dc26bSmrg	    non_pic_object=$pic_object
7666e07dc26bSmrg	    func_append non_pic_objects " $non_pic_object"
7667e07dc26bSmrg	  fi
7668e07dc26bSmrg	else
7669e07dc26bSmrg	  # Only an error if not doing a dry-run.
7670e07dc26bSmrg	  if $opt_dry_run; then
7671e07dc26bSmrg	    # Extract subdirectory from the argument.
7672e07dc26bSmrg	    func_dirname "$arg" "/" ""
7673e07dc26bSmrg	    xdir=$func_dirname_result
7674e07dc26bSmrg
7675e07dc26bSmrg	    func_lo2o "$arg"
7676e07dc26bSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
7677e07dc26bSmrg	    non_pic_object=$xdir$func_lo2o_result
7678e07dc26bSmrg	    func_append libobjs " $pic_object"
7679e07dc26bSmrg	    func_append non_pic_objects " $non_pic_object"
7680e07dc26bSmrg	  else
7681e07dc26bSmrg	    func_fatal_error "'$arg' is not a valid libtool object"
7682e07dc26bSmrg	  fi
7683e07dc26bSmrg	fi
7684e07dc26bSmrg	;;
7685e07dc26bSmrg
7686e07dc26bSmrg      *.$libext)
7687e07dc26bSmrg	# An archive.
7688e07dc26bSmrg	func_append deplibs " $arg"
7689e07dc26bSmrg	func_append old_deplibs " $arg"
7690e07dc26bSmrg	continue
7691e07dc26bSmrg	;;
7692e07dc26bSmrg
7693e07dc26bSmrg      *.la)
7694e07dc26bSmrg	# A libtool-controlled library.
7695e07dc26bSmrg
7696e07dc26bSmrg	func_resolve_sysroot "$arg"
7697e07dc26bSmrg	if test dlfiles = "$prev"; then
7698e07dc26bSmrg	  # This library was specified with -dlopen.
7699e07dc26bSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
7700e07dc26bSmrg	  prev=
7701e07dc26bSmrg	elif test dlprefiles = "$prev"; then
7702e07dc26bSmrg	  # The library was specified with -dlpreopen.
7703e07dc26bSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
7704e07dc26bSmrg	  prev=
7705e07dc26bSmrg	else
7706e07dc26bSmrg	  func_append deplibs " $func_resolve_sysroot_result"
7707e07dc26bSmrg	fi
7708e07dc26bSmrg	continue
7709e07dc26bSmrg	;;
7710e07dc26bSmrg
7711e07dc26bSmrg      # Some other compiler argument.
7712e07dc26bSmrg      *)
7713e07dc26bSmrg	# Unknown arguments in both finalize_command and compile_command need
7714e07dc26bSmrg	# to be aesthetically quoted because they are evaled later.
7715636c353eSmrg	func_quote_arg pretty "$arg"
7716636c353eSmrg	arg=$func_quote_arg_result
7717e07dc26bSmrg	;;
7718e07dc26bSmrg      esac # arg
7719e07dc26bSmrg
7720e07dc26bSmrg      # Now actually substitute the argument into the commands.
7721e07dc26bSmrg      if test -n "$arg"; then
7722e07dc26bSmrg	func_append compile_command " $arg"
7723e07dc26bSmrg	func_append finalize_command " $arg"
7724e07dc26bSmrg      fi
7725e07dc26bSmrg    done # argument parsing loop
7726e07dc26bSmrg
7727e07dc26bSmrg    test -n "$prev" && \
7728e07dc26bSmrg      func_fatal_help "the '$prevarg' option requires an argument"
7729e07dc26bSmrg
7730e07dc26bSmrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
7731e07dc26bSmrg      eval arg=\"$export_dynamic_flag_spec\"
7732e07dc26bSmrg      func_append compile_command " $arg"
7733e07dc26bSmrg      func_append finalize_command " $arg"
7734e07dc26bSmrg    fi
7735e07dc26bSmrg
7736e07dc26bSmrg    oldlibs=
7737e07dc26bSmrg    # calculate the name of the file, without its directory
7738e07dc26bSmrg    func_basename "$output"
7739e07dc26bSmrg    outputname=$func_basename_result
7740e07dc26bSmrg    libobjs_save=$libobjs
7741e07dc26bSmrg
7742e07dc26bSmrg    if test -n "$shlibpath_var"; then
7743e07dc26bSmrg      # get the directories listed in $shlibpath_var
7744e07dc26bSmrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7745e07dc26bSmrg    else
7746e07dc26bSmrg      shlib_search_path=
7747e07dc26bSmrg    fi
7748e07dc26bSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
7749e07dc26bSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7750e07dc26bSmrg
7751e07dc26bSmrg    # Definition is injected by LT_CONFIG during libtool generation.
7752e07dc26bSmrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
7753e07dc26bSmrg
7754e07dc26bSmrg    func_dirname "$output" "/" ""
7755e07dc26bSmrg    output_objdir=$func_dirname_result$objdir
7756e07dc26bSmrg    func_to_tool_file "$output_objdir/"
7757e07dc26bSmrg    tool_output_objdir=$func_to_tool_file_result
7758e07dc26bSmrg    # Create the object directory.
7759e07dc26bSmrg    func_mkdir_p "$output_objdir"
7760e07dc26bSmrg
7761e07dc26bSmrg    # Determine the type of output
7762e07dc26bSmrg    case $output in
7763e07dc26bSmrg    "")
7764e07dc26bSmrg      func_fatal_help "you must specify an output file"
7765e07dc26bSmrg      ;;
7766e07dc26bSmrg    *.$libext) linkmode=oldlib ;;
7767e07dc26bSmrg    *.lo | *.$objext) linkmode=obj ;;
7768e07dc26bSmrg    *.la) linkmode=lib ;;
7769e07dc26bSmrg    *) linkmode=prog ;; # Anything else should be a program.
7770e07dc26bSmrg    esac
7771e07dc26bSmrg
7772e07dc26bSmrg    specialdeplibs=
7773e07dc26bSmrg
7774e07dc26bSmrg    libs=
7775e07dc26bSmrg    # Find all interdependent deplibs by searching for libraries
7776e07dc26bSmrg    # that are linked more than once (e.g. -la -lb -la)
7777e07dc26bSmrg    for deplib in $deplibs; do
7778e07dc26bSmrg      if $opt_preserve_dup_deps; then
7779e07dc26bSmrg	case "$libs " in
7780e07dc26bSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
7781e07dc26bSmrg	esac
7782e07dc26bSmrg      fi
7783e07dc26bSmrg      func_append libs " $deplib"
7784e07dc26bSmrg    done
7785e07dc26bSmrg
7786e07dc26bSmrg    if test lib = "$linkmode"; then
7787e07dc26bSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
7788e07dc26bSmrg
7789e07dc26bSmrg      # Compute libraries that are listed more than once in $predeps
7790e07dc26bSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
7791e07dc26bSmrg      # not to be eliminated).
7792e07dc26bSmrg      pre_post_deps=
7793e07dc26bSmrg      if $opt_duplicate_compiler_generated_deps; then
7794e07dc26bSmrg	for pre_post_dep in $predeps $postdeps; do
7795e07dc26bSmrg	  case "$pre_post_deps " in
7796e07dc26bSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
7797e07dc26bSmrg	  esac
7798e07dc26bSmrg	  func_append pre_post_deps " $pre_post_dep"
7799e07dc26bSmrg	done
7800e07dc26bSmrg      fi
7801e07dc26bSmrg      pre_post_deps=
7802e07dc26bSmrg    fi
7803e07dc26bSmrg
7804e07dc26bSmrg    deplibs=
7805e07dc26bSmrg    newdependency_libs=
7806e07dc26bSmrg    newlib_search_path=
7807e07dc26bSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
7808e07dc26bSmrg    notinst_deplibs= # not-installed libtool libraries
7809e07dc26bSmrg    notinst_path= # paths that contain not-installed libtool libraries
7810e07dc26bSmrg
7811e07dc26bSmrg    case $linkmode in
7812e07dc26bSmrg    lib)
7813e07dc26bSmrg	passes="conv dlpreopen link"
7814e07dc26bSmrg	for file in $dlfiles $dlprefiles; do
7815e07dc26bSmrg	  case $file in
7816e07dc26bSmrg	  *.la) ;;
7817e07dc26bSmrg	  *)
7818e07dc26bSmrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
7819e07dc26bSmrg	    ;;
7820e07dc26bSmrg	  esac
7821e07dc26bSmrg	done
7822e07dc26bSmrg	;;
7823e07dc26bSmrg    prog)
7824e07dc26bSmrg	compile_deplibs=
7825e07dc26bSmrg	finalize_deplibs=
7826e07dc26bSmrg	alldeplibs=false
7827e07dc26bSmrg	newdlfiles=
7828e07dc26bSmrg	newdlprefiles=
7829e07dc26bSmrg	passes="conv scan dlopen dlpreopen link"
7830e07dc26bSmrg	;;
7831e07dc26bSmrg    *)  passes="conv"
7832e07dc26bSmrg	;;
7833e07dc26bSmrg    esac
7834e07dc26bSmrg
7835e07dc26bSmrg    for pass in $passes; do
7836e07dc26bSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
7837e07dc26bSmrg      # so that -L comes before libs that need it for instance...
7838e07dc26bSmrg      if test lib,link = "$linkmode,$pass"; then
7839e07dc26bSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
7840e07dc26bSmrg	##        order, and fix it there properly
7841e07dc26bSmrg        tmp_deplibs=
7842e07dc26bSmrg	for deplib in $deplibs; do
7843e07dc26bSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
7844e07dc26bSmrg	done
7845e07dc26bSmrg	deplibs=$tmp_deplibs
7846e07dc26bSmrg      fi
7847e07dc26bSmrg
7848e07dc26bSmrg      if test lib,link = "$linkmode,$pass" ||
7849e07dc26bSmrg	 test prog,scan = "$linkmode,$pass"; then
7850e07dc26bSmrg	libs=$deplibs
7851e07dc26bSmrg	deplibs=
7852e07dc26bSmrg      fi
7853e07dc26bSmrg      if test prog = "$linkmode"; then
7854e07dc26bSmrg	case $pass in
7855e07dc26bSmrg	dlopen) libs=$dlfiles ;;
7856e07dc26bSmrg	dlpreopen) libs=$dlprefiles ;;
7857636c353eSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
7858e07dc26bSmrg	esac
7859e07dc26bSmrg      fi
7860e07dc26bSmrg      if test lib,dlpreopen = "$linkmode,$pass"; then
7861e07dc26bSmrg	# Collect and forward deplibs of preopened libtool libs
7862e07dc26bSmrg	for lib in $dlprefiles; do
7863e07dc26bSmrg	  # Ignore non-libtool-libs
7864e07dc26bSmrg	  dependency_libs=
7865e07dc26bSmrg	  func_resolve_sysroot "$lib"
7866e07dc26bSmrg	  case $lib in
7867e07dc26bSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
7868e07dc26bSmrg	  esac
7869e07dc26bSmrg
7870e07dc26bSmrg	  # Collect preopened libtool deplibs, except any this library
7871e07dc26bSmrg	  # has declared as weak libs
7872e07dc26bSmrg	  for deplib in $dependency_libs; do
7873e07dc26bSmrg	    func_basename "$deplib"
7874e07dc26bSmrg            deplib_base=$func_basename_result
7875e07dc26bSmrg	    case " $weak_libs " in
7876e07dc26bSmrg	    *" $deplib_base "*) ;;
7877e07dc26bSmrg	    *) func_append deplibs " $deplib" ;;
7878e07dc26bSmrg	    esac
7879e07dc26bSmrg	  done
7880e07dc26bSmrg	done
7881e07dc26bSmrg	libs=$dlprefiles
7882e07dc26bSmrg      fi
7883e07dc26bSmrg      if test dlopen = "$pass"; then
7884e07dc26bSmrg	# Collect dlpreopened libraries
7885e07dc26bSmrg	save_deplibs=$deplibs
7886e07dc26bSmrg	deplibs=
7887e07dc26bSmrg      fi
7888e07dc26bSmrg
7889e07dc26bSmrg      for deplib in $libs; do
7890e07dc26bSmrg	lib=
7891e07dc26bSmrg	found=false
7892e07dc26bSmrg	case $deplib in
7893e07dc26bSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7894e07dc26bSmrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7895e07dc26bSmrg	  if test prog,link = "$linkmode,$pass"; then
7896e07dc26bSmrg	    compile_deplibs="$deplib $compile_deplibs"
7897e07dc26bSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
7898e07dc26bSmrg	  else
7899e07dc26bSmrg	    func_append compiler_flags " $deplib"
7900e07dc26bSmrg	    if test lib = "$linkmode"; then
7901e07dc26bSmrg		case "$new_inherited_linker_flags " in
7902e07dc26bSmrg		    *" $deplib "*) ;;
7903e07dc26bSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7904e07dc26bSmrg		esac
7905e07dc26bSmrg	    fi
7906e07dc26bSmrg	  fi
7907e07dc26bSmrg	  continue
7908e07dc26bSmrg	  ;;
7909e07dc26bSmrg	-l*)
7910e07dc26bSmrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
7911e07dc26bSmrg	    func_warning "'-l' is ignored for archives/objects"
7912e07dc26bSmrg	    continue
7913e07dc26bSmrg	  fi
7914e07dc26bSmrg	  func_stripname '-l' '' "$deplib"
7915e07dc26bSmrg	  name=$func_stripname_result
7916e07dc26bSmrg	  if test lib = "$linkmode"; then
7917e07dc26bSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
7918e07dc26bSmrg	  else
7919e07dc26bSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
7920e07dc26bSmrg	  fi
7921e07dc26bSmrg	  for searchdir in $searchdirs; do
7922e07dc26bSmrg	    for search_ext in .la $std_shrext .so .a; do
7923e07dc26bSmrg	      # Search the libtool library
7924e07dc26bSmrg	      lib=$searchdir/lib$name$search_ext
7925e07dc26bSmrg	      if test -f "$lib"; then
7926e07dc26bSmrg		if test .la = "$search_ext"; then
7927e07dc26bSmrg		  found=:
7928e07dc26bSmrg		else
7929e07dc26bSmrg		  found=false
7930e07dc26bSmrg		fi
7931e07dc26bSmrg		break 2
7932e07dc26bSmrg	      fi
7933e07dc26bSmrg	    done
7934e07dc26bSmrg	  done
7935e07dc26bSmrg	  if $found; then
7936e07dc26bSmrg	    # deplib is a libtool library
7937e07dc26bSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
7938e07dc26bSmrg	    # We need to do some special things here, and not later.
7939e07dc26bSmrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
7940e07dc26bSmrg	      case " $predeps $postdeps " in
7941e07dc26bSmrg	      *" $deplib "*)
7942e07dc26bSmrg		if func_lalib_p "$lib"; then
7943e07dc26bSmrg		  library_names=
7944e07dc26bSmrg		  old_library=
7945e07dc26bSmrg		  func_source "$lib"
7946e07dc26bSmrg		  for l in $old_library $library_names; do
7947e07dc26bSmrg		    ll=$l
7948e07dc26bSmrg		  done
7949e07dc26bSmrg		  if test "X$ll" = "X$old_library"; then # only static version available
7950e07dc26bSmrg		    found=false
7951e07dc26bSmrg		    func_dirname "$lib" "" "."
7952e07dc26bSmrg		    ladir=$func_dirname_result
7953e07dc26bSmrg		    lib=$ladir/$old_library
7954e07dc26bSmrg		    if test prog,link = "$linkmode,$pass"; then
7955e07dc26bSmrg		      compile_deplibs="$deplib $compile_deplibs"
7956e07dc26bSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
7957e07dc26bSmrg		    else
7958e07dc26bSmrg		      deplibs="$deplib $deplibs"
7959e07dc26bSmrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7960e07dc26bSmrg		    fi
7961e07dc26bSmrg		    continue
7962e07dc26bSmrg		  fi
7963e07dc26bSmrg		fi
7964e07dc26bSmrg		;;
7965e07dc26bSmrg	      *) ;;
7966e07dc26bSmrg	      esac
7967e07dc26bSmrg	    fi
7968e07dc26bSmrg	  else
7969e07dc26bSmrg	    # deplib doesn't seem to be a libtool library
7970e07dc26bSmrg	    if test prog,link = "$linkmode,$pass"; then
7971e07dc26bSmrg	      compile_deplibs="$deplib $compile_deplibs"
7972e07dc26bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
7973e07dc26bSmrg	    else
7974e07dc26bSmrg	      deplibs="$deplib $deplibs"
7975e07dc26bSmrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7976e07dc26bSmrg	    fi
7977e07dc26bSmrg	    continue
7978e07dc26bSmrg	  fi
7979e07dc26bSmrg	  ;; # -l
7980e07dc26bSmrg	*.ltframework)
7981e07dc26bSmrg	  if test prog,link = "$linkmode,$pass"; then
7982e07dc26bSmrg	    compile_deplibs="$deplib $compile_deplibs"
7983e07dc26bSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
7984e07dc26bSmrg	  else
7985e07dc26bSmrg	    deplibs="$deplib $deplibs"
7986e07dc26bSmrg	    if test lib = "$linkmode"; then
7987e07dc26bSmrg		case "$new_inherited_linker_flags " in
7988e07dc26bSmrg		    *" $deplib "*) ;;
7989e07dc26bSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7990e07dc26bSmrg		esac
7991e07dc26bSmrg	    fi
7992e07dc26bSmrg	  fi
7993e07dc26bSmrg	  continue
7994e07dc26bSmrg	  ;;
7995e07dc26bSmrg	-L*)
7996e07dc26bSmrg	  case $linkmode in
7997e07dc26bSmrg	  lib)
7998e07dc26bSmrg	    deplibs="$deplib $deplibs"
7999e07dc26bSmrg	    test conv = "$pass" && continue
8000e07dc26bSmrg	    newdependency_libs="$deplib $newdependency_libs"
8001e07dc26bSmrg	    func_stripname '-L' '' "$deplib"
8002e07dc26bSmrg	    func_resolve_sysroot "$func_stripname_result"
8003e07dc26bSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
8004e07dc26bSmrg	    ;;
8005e07dc26bSmrg	  prog)
8006e07dc26bSmrg	    if test conv = "$pass"; then
8007e07dc26bSmrg	      deplibs="$deplib $deplibs"
8008e07dc26bSmrg	      continue
8009e07dc26bSmrg	    fi
8010e07dc26bSmrg	    if test scan = "$pass"; then
8011e07dc26bSmrg	      deplibs="$deplib $deplibs"
8012e07dc26bSmrg	    else
8013e07dc26bSmrg	      compile_deplibs="$deplib $compile_deplibs"
8014e07dc26bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
8015e07dc26bSmrg	    fi
8016e07dc26bSmrg	    func_stripname '-L' '' "$deplib"
8017e07dc26bSmrg	    func_resolve_sysroot "$func_stripname_result"
8018e07dc26bSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
8019e07dc26bSmrg	    ;;
8020e07dc26bSmrg	  *)
8021e07dc26bSmrg	    func_warning "'-L' is ignored for archives/objects"
8022e07dc26bSmrg	    ;;
8023e07dc26bSmrg	  esac # linkmode
8024e07dc26bSmrg	  continue
8025e07dc26bSmrg	  ;; # -L
8026e07dc26bSmrg	-R*)
8027e07dc26bSmrg	  if test link = "$pass"; then
8028e07dc26bSmrg	    func_stripname '-R' '' "$deplib"
8029e07dc26bSmrg	    func_resolve_sysroot "$func_stripname_result"
8030e07dc26bSmrg	    dir=$func_resolve_sysroot_result
8031e07dc26bSmrg	    # Make sure the xrpath contains only unique directories.
8032e07dc26bSmrg	    case "$xrpath " in
8033e07dc26bSmrg	    *" $dir "*) ;;
8034e07dc26bSmrg	    *) func_append xrpath " $dir" ;;
8035e07dc26bSmrg	    esac
8036e07dc26bSmrg	  fi
8037e07dc26bSmrg	  deplibs="$deplib $deplibs"
8038e07dc26bSmrg	  continue
8039e07dc26bSmrg	  ;;
8040e07dc26bSmrg	*.la)
8041e07dc26bSmrg	  func_resolve_sysroot "$deplib"
8042e07dc26bSmrg	  lib=$func_resolve_sysroot_result
8043e07dc26bSmrg	  ;;
8044e07dc26bSmrg	*.$libext)
8045e07dc26bSmrg	  if test conv = "$pass"; then
8046e07dc26bSmrg	    deplibs="$deplib $deplibs"
8047e07dc26bSmrg	    continue
8048e07dc26bSmrg	  fi
8049e07dc26bSmrg	  case $linkmode in
8050e07dc26bSmrg	  lib)
8051e07dc26bSmrg	    # Linking convenience modules into shared libraries is allowed,
8052e07dc26bSmrg	    # but linking other static libraries is non-portable.
8053e07dc26bSmrg	    case " $dlpreconveniencelibs " in
8054e07dc26bSmrg	    *" $deplib "*) ;;
8055e07dc26bSmrg	    *)
8056e07dc26bSmrg	      valid_a_lib=false
8057e07dc26bSmrg	      case $deplibs_check_method in
8058e07dc26bSmrg		match_pattern*)
8059e07dc26bSmrg		  set dummy $deplibs_check_method; shift
8060e07dc26bSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
8061e07dc26bSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
8062e07dc26bSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
8063e07dc26bSmrg		    valid_a_lib=:
8064e07dc26bSmrg		  fi
8065e07dc26bSmrg		;;
8066e07dc26bSmrg		pass_all)
8067e07dc26bSmrg		  valid_a_lib=:
8068e07dc26bSmrg		;;
8069e07dc26bSmrg	      esac
8070e07dc26bSmrg	      if $valid_a_lib; then
8071e07dc26bSmrg		echo
8072e07dc26bSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
8073e07dc26bSmrg		$ECHO "*** static library $deplib is not portable!"
8074e07dc26bSmrg		deplibs="$deplib $deplibs"
8075e07dc26bSmrg	      else
8076e07dc26bSmrg		echo
8077e07dc26bSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
8078e07dc26bSmrg		echo "*** I have the capability to make that library automatically link in when"
8079e07dc26bSmrg		echo "*** you link to this library.  But I can only do this if you have a"
8080e07dc26bSmrg		echo "*** shared version of the library, which you do not appear to have"
8081e07dc26bSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
8082e07dc26bSmrg		echo "*** that it is just a static archive that I should not use here."
8083e07dc26bSmrg	      fi
8084e07dc26bSmrg	      ;;
8085e07dc26bSmrg	    esac
8086e07dc26bSmrg	    continue
8087e07dc26bSmrg	    ;;
8088e07dc26bSmrg	  prog)
8089e07dc26bSmrg	    if test link != "$pass"; then
8090e07dc26bSmrg	      deplibs="$deplib $deplibs"
8091e07dc26bSmrg	    else
8092e07dc26bSmrg	      compile_deplibs="$deplib $compile_deplibs"
8093e07dc26bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
8094e07dc26bSmrg	    fi
8095e07dc26bSmrg	    continue
8096e07dc26bSmrg	    ;;
8097e07dc26bSmrg	  esac # linkmode
8098e07dc26bSmrg	  ;; # *.$libext
8099e07dc26bSmrg	*.lo | *.$objext)
8100e07dc26bSmrg	  if test conv = "$pass"; then
8101e07dc26bSmrg	    deplibs="$deplib $deplibs"
8102e07dc26bSmrg	  elif test prog = "$linkmode"; then
8103e07dc26bSmrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
8104e07dc26bSmrg	      # If there is no dlopen support or we're linking statically,
8105e07dc26bSmrg	      # we need to preload.
8106e07dc26bSmrg	      func_append newdlprefiles " $deplib"
8107e07dc26bSmrg	      compile_deplibs="$deplib $compile_deplibs"
8108e07dc26bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
8109e07dc26bSmrg	    else
8110e07dc26bSmrg	      func_append newdlfiles " $deplib"
8111e07dc26bSmrg	    fi
8112e07dc26bSmrg	  fi
8113e07dc26bSmrg	  continue
8114e07dc26bSmrg	  ;;
8115e07dc26bSmrg	%DEPLIBS%)
8116e07dc26bSmrg	  alldeplibs=:
8117e07dc26bSmrg	  continue
8118e07dc26bSmrg	  ;;
8119e07dc26bSmrg	esac # case $deplib
8120e07dc26bSmrg
8121e07dc26bSmrg	$found || test -f "$lib" \
8122e07dc26bSmrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
8123e07dc26bSmrg
8124e07dc26bSmrg	# Check to see that this really is a libtool archive.
8125e07dc26bSmrg	func_lalib_unsafe_p "$lib" \
8126e07dc26bSmrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
8127e07dc26bSmrg
8128e07dc26bSmrg	func_dirname "$lib" "" "."
8129e07dc26bSmrg	ladir=$func_dirname_result
8130e07dc26bSmrg
8131e07dc26bSmrg	dlname=
8132e07dc26bSmrg	dlopen=
8133e07dc26bSmrg	dlpreopen=
8134e07dc26bSmrg	libdir=
8135e07dc26bSmrg	library_names=
8136e07dc26bSmrg	old_library=
8137e07dc26bSmrg	inherited_linker_flags=
8138e07dc26bSmrg	# If the library was installed with an old release of libtool,
8139e07dc26bSmrg	# it will not redefine variables installed, or shouldnotlink
8140e07dc26bSmrg	installed=yes
8141e07dc26bSmrg	shouldnotlink=no
8142e07dc26bSmrg	avoidtemprpath=
8143e07dc26bSmrg
8144e07dc26bSmrg
8145e07dc26bSmrg	# Read the .la file
8146e07dc26bSmrg	func_source "$lib"
8147e07dc26bSmrg
8148e07dc26bSmrg	# Convert "-framework foo" to "foo.ltframework"
8149e07dc26bSmrg	if test -n "$inherited_linker_flags"; then
8150e07dc26bSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
8151e07dc26bSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
8152e07dc26bSmrg	    case " $new_inherited_linker_flags " in
8153e07dc26bSmrg	      *" $tmp_inherited_linker_flag "*) ;;
8154e07dc26bSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
8155e07dc26bSmrg	    esac
8156e07dc26bSmrg	  done
8157e07dc26bSmrg	fi
8158e07dc26bSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8159e07dc26bSmrg	if test lib,link = "$linkmode,$pass" ||
8160e07dc26bSmrg	   test prog,scan = "$linkmode,$pass" ||
8161e07dc26bSmrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
8162e07dc26bSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
8163e07dc26bSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
8164e07dc26bSmrg	fi
8165e07dc26bSmrg
8166e07dc26bSmrg	if test conv = "$pass"; then
8167e07dc26bSmrg	  # Only check for convenience libraries
8168e07dc26bSmrg	  deplibs="$lib $deplibs"
8169e07dc26bSmrg	  if test -z "$libdir"; then
8170e07dc26bSmrg	    if test -z "$old_library"; then
8171e07dc26bSmrg	      func_fatal_error "cannot find name of link library for '$lib'"
8172e07dc26bSmrg	    fi
8173e07dc26bSmrg	    # It is a libtool convenience library, so add in its objects.
8174e07dc26bSmrg	    func_append convenience " $ladir/$objdir/$old_library"
8175e07dc26bSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
8176e07dc26bSmrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
8177e07dc26bSmrg	    func_fatal_error "'$lib' is not a convenience library"
8178e07dc26bSmrg	  fi
8179636c353eSmrg	  tmp_libs=
8180636c353eSmrg	  for deplib in $dependency_libs; do
8181636c353eSmrg	    deplibs="$deplib $deplibs"
8182636c353eSmrg	    if $opt_preserve_dup_deps; then
8183636c353eSmrg	      case "$tmp_libs " in
8184636c353eSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8185636c353eSmrg	      esac
8186636c353eSmrg	    fi
8187636c353eSmrg	    func_append tmp_libs " $deplib"
8188636c353eSmrg	  done
8189e07dc26bSmrg	  continue
8190e07dc26bSmrg	fi # $pass = conv
8191e07dc26bSmrg
8192e07dc26bSmrg
8193e07dc26bSmrg	# Get the name of the library we link against.
8194e07dc26bSmrg	linklib=
8195e07dc26bSmrg	if test -n "$old_library" &&
8196e07dc26bSmrg	   { test yes = "$prefer_static_libs" ||
8197e07dc26bSmrg	     test built,no = "$prefer_static_libs,$installed"; }; then
8198e07dc26bSmrg	  linklib=$old_library
8199e07dc26bSmrg	else
8200e07dc26bSmrg	  for l in $old_library $library_names; do
8201e07dc26bSmrg	    linklib=$l
8202e07dc26bSmrg	  done
8203e07dc26bSmrg	fi
8204e07dc26bSmrg	if test -z "$linklib"; then
8205e07dc26bSmrg	  func_fatal_error "cannot find name of link library for '$lib'"
8206e07dc26bSmrg	fi
8207e07dc26bSmrg
8208e07dc26bSmrg	# This library was specified with -dlopen.
8209e07dc26bSmrg	if test dlopen = "$pass"; then
8210e07dc26bSmrg	  test -z "$libdir" \
8211e07dc26bSmrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
8212e07dc26bSmrg	  if test -z "$dlname" ||
8213e07dc26bSmrg	     test yes != "$dlopen_support" ||
8214e07dc26bSmrg	     test no = "$build_libtool_libs"
8215e07dc26bSmrg	  then
8216e07dc26bSmrg	    # If there is no dlname, no dlopen support or we're linking
8217e07dc26bSmrg	    # statically, we need to preload.  We also need to preload any
8218e07dc26bSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
8219e07dc26bSmrg	    # bomb out in the load deplibs phase.
8220e07dc26bSmrg	    func_append dlprefiles " $lib $dependency_libs"
8221e07dc26bSmrg	  else
8222e07dc26bSmrg	    func_append newdlfiles " $lib"
8223e07dc26bSmrg	  fi
8224e07dc26bSmrg	  continue
8225e07dc26bSmrg	fi # $pass = dlopen
8226e07dc26bSmrg
8227e07dc26bSmrg	# We need an absolute path.
8228e07dc26bSmrg	case $ladir in
8229e07dc26bSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
8230e07dc26bSmrg	*)
8231e07dc26bSmrg	  abs_ladir=`cd "$ladir" && pwd`
8232e07dc26bSmrg	  if test -z "$abs_ladir"; then
8233e07dc26bSmrg	    func_warning "cannot determine absolute directory name of '$ladir'"
8234e07dc26bSmrg	    func_warning "passing it literally to the linker, although it might fail"
8235e07dc26bSmrg	    abs_ladir=$ladir
8236e07dc26bSmrg	  fi
8237e07dc26bSmrg	  ;;
8238e07dc26bSmrg	esac
8239e07dc26bSmrg	func_basename "$lib"
8240e07dc26bSmrg	laname=$func_basename_result
8241e07dc26bSmrg
8242e07dc26bSmrg	# Find the relevant object directory and library name.
8243e07dc26bSmrg	if test yes = "$installed"; then
8244e07dc26bSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
8245e07dc26bSmrg	    func_warning "library '$lib' was moved."
8246e07dc26bSmrg	    dir=$ladir
8247e07dc26bSmrg	    absdir=$abs_ladir
8248e07dc26bSmrg	    libdir=$abs_ladir
8249e07dc26bSmrg	  else
8250e07dc26bSmrg	    dir=$lt_sysroot$libdir
8251e07dc26bSmrg	    absdir=$lt_sysroot$libdir
8252e07dc26bSmrg	  fi
8253e07dc26bSmrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
8254e07dc26bSmrg	else
8255e07dc26bSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
8256e07dc26bSmrg	    dir=$ladir
8257e07dc26bSmrg	    absdir=$abs_ladir
8258e07dc26bSmrg	    # Remove this search path later
8259e07dc26bSmrg	    func_append notinst_path " $abs_ladir"
8260e07dc26bSmrg	  else
8261e07dc26bSmrg	    dir=$ladir/$objdir
8262e07dc26bSmrg	    absdir=$abs_ladir/$objdir
8263e07dc26bSmrg	    # Remove this search path later
8264e07dc26bSmrg	    func_append notinst_path " $abs_ladir"
8265e07dc26bSmrg	  fi
8266e07dc26bSmrg	fi # $installed = yes
8267e07dc26bSmrg	func_stripname 'lib' '.la' "$laname"
8268e07dc26bSmrg	name=$func_stripname_result
8269e07dc26bSmrg
8270e07dc26bSmrg	# This library was specified with -dlpreopen.
8271e07dc26bSmrg	if test dlpreopen = "$pass"; then
8272e07dc26bSmrg	  if test -z "$libdir" && test prog = "$linkmode"; then
8273e07dc26bSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
8274e07dc26bSmrg	  fi
8275e07dc26bSmrg	  case $host in
8276e07dc26bSmrg	    # special handling for platforms with PE-DLLs.
8277e07dc26bSmrg	    *cygwin* | *mingw* | *cegcc* )
8278e07dc26bSmrg	      # Linker will automatically link against shared library if both
8279e07dc26bSmrg	      # static and shared are present.  Therefore, ensure we extract
8280e07dc26bSmrg	      # symbols from the import library if a shared library is present
8281e07dc26bSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
8282e07dc26bSmrg	      # this by putting the import library name into $newdlprefiles.
8283e07dc26bSmrg	      # We recover the dlopen module name by 'saving' the la file
8284e07dc26bSmrg	      # name in a special purpose variable, and (later) extracting the
8285e07dc26bSmrg	      # dlname from the la file.
8286e07dc26bSmrg	      if test -n "$dlname"; then
8287e07dc26bSmrg	        func_tr_sh "$dir/$linklib"
8288e07dc26bSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8289e07dc26bSmrg	        func_append newdlprefiles " $dir/$linklib"
8290e07dc26bSmrg	      else
8291e07dc26bSmrg	        func_append newdlprefiles " $dir/$old_library"
8292e07dc26bSmrg	        # Keep a list of preopened convenience libraries to check
8293e07dc26bSmrg	        # that they are being used correctly in the link pass.
8294e07dc26bSmrg	        test -z "$libdir" && \
8295e07dc26bSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8296e07dc26bSmrg	      fi
8297e07dc26bSmrg	    ;;
8298e07dc26bSmrg	    * )
8299e07dc26bSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
8300e07dc26bSmrg	      # are required to link).
8301e07dc26bSmrg	      if test -n "$old_library"; then
8302e07dc26bSmrg	        func_append newdlprefiles " $dir/$old_library"
8303e07dc26bSmrg	        # Keep a list of preopened convenience libraries to check
8304e07dc26bSmrg	        # that they are being used correctly in the link pass.
8305e07dc26bSmrg	        test -z "$libdir" && \
8306e07dc26bSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8307e07dc26bSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
8308e07dc26bSmrg	      elif test -n "$dlname"; then
8309e07dc26bSmrg	        func_append newdlprefiles " $dir/$dlname"
8310e07dc26bSmrg	      else
8311e07dc26bSmrg	        func_append newdlprefiles " $dir/$linklib"
8312e07dc26bSmrg	      fi
8313e07dc26bSmrg	    ;;
8314e07dc26bSmrg	  esac
8315e07dc26bSmrg	fi # $pass = dlpreopen
8316e07dc26bSmrg
8317e07dc26bSmrg	if test -z "$libdir"; then
8318e07dc26bSmrg	  # Link the convenience library
8319e07dc26bSmrg	  if test lib = "$linkmode"; then
8320e07dc26bSmrg	    deplibs="$dir/$old_library $deplibs"
8321e07dc26bSmrg	  elif test prog,link = "$linkmode,$pass"; then
8322e07dc26bSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
8323e07dc26bSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
8324e07dc26bSmrg	  else
8325e07dc26bSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
8326e07dc26bSmrg	  fi
8327e07dc26bSmrg	  continue
8328e07dc26bSmrg	fi
8329e07dc26bSmrg
8330e07dc26bSmrg
8331e07dc26bSmrg	if test prog = "$linkmode" && test link != "$pass"; then
8332e07dc26bSmrg	  func_append newlib_search_path " $ladir"
8333e07dc26bSmrg	  deplibs="$lib $deplibs"
8334e07dc26bSmrg
8335e07dc26bSmrg	  linkalldeplibs=false
8336e07dc26bSmrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
8337e07dc26bSmrg	     test no = "$build_libtool_libs"; then
8338e07dc26bSmrg	    linkalldeplibs=:
8339e07dc26bSmrg	  fi
8340e07dc26bSmrg
8341e07dc26bSmrg	  tmp_libs=
8342e07dc26bSmrg	  for deplib in $dependency_libs; do
8343e07dc26bSmrg	    case $deplib in
8344e07dc26bSmrg	    -L*) func_stripname '-L' '' "$deplib"
8345e07dc26bSmrg	         func_resolve_sysroot "$func_stripname_result"
8346e07dc26bSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
8347e07dc26bSmrg		 ;;
8348e07dc26bSmrg	    esac
8349e07dc26bSmrg	    # Need to link against all dependency_libs?
8350e07dc26bSmrg	    if $linkalldeplibs; then
8351e07dc26bSmrg	      deplibs="$deplib $deplibs"
8352e07dc26bSmrg	    else
8353e07dc26bSmrg	      # Need to hardcode shared library paths
8354e07dc26bSmrg	      # or/and link against static libraries
8355e07dc26bSmrg	      newdependency_libs="$deplib $newdependency_libs"
8356e07dc26bSmrg	    fi
8357e07dc26bSmrg	    if $opt_preserve_dup_deps; then
8358e07dc26bSmrg	      case "$tmp_libs " in
8359e07dc26bSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8360e07dc26bSmrg	      esac
8361e07dc26bSmrg	    fi
8362e07dc26bSmrg	    func_append tmp_libs " $deplib"
8363e07dc26bSmrg	  done # for deplib
8364e07dc26bSmrg	  continue
8365e07dc26bSmrg	fi # $linkmode = prog...
8366e07dc26bSmrg
8367e07dc26bSmrg	if test prog,link = "$linkmode,$pass"; then
8368e07dc26bSmrg	  if test -n "$library_names" &&
8369e07dc26bSmrg	     { { test no = "$prefer_static_libs" ||
8370e07dc26bSmrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
8371e07dc26bSmrg	       test -z "$old_library"; }; then
8372e07dc26bSmrg	    # We need to hardcode the library path
8373e07dc26bSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
8374e07dc26bSmrg	      # Make sure the rpath contains only unique directories.
8375e07dc26bSmrg	      case $temp_rpath: in
8376e07dc26bSmrg	      *"$absdir:"*) ;;
8377e07dc26bSmrg	      *) func_append temp_rpath "$absdir:" ;;
8378e07dc26bSmrg	      esac
8379e07dc26bSmrg	    fi
8380e07dc26bSmrg
8381e07dc26bSmrg	    # Hardcode the library path.
8382e07dc26bSmrg	    # Skip directories that are in the system default run-time
8383e07dc26bSmrg	    # search path.
8384e07dc26bSmrg	    case " $sys_lib_dlsearch_path " in
8385e07dc26bSmrg	    *" $absdir "*) ;;
8386e07dc26bSmrg	    *)
8387e07dc26bSmrg	      case "$compile_rpath " in
8388e07dc26bSmrg	      *" $absdir "*) ;;
8389e07dc26bSmrg	      *) func_append compile_rpath " $absdir" ;;
8390e07dc26bSmrg	      esac
8391e07dc26bSmrg	      ;;
8392e07dc26bSmrg	    esac
8393e07dc26bSmrg	    case " $sys_lib_dlsearch_path " in
8394e07dc26bSmrg	    *" $libdir "*) ;;
8395e07dc26bSmrg	    *)
8396e07dc26bSmrg	      case "$finalize_rpath " in
8397e07dc26bSmrg	      *" $libdir "*) ;;
8398e07dc26bSmrg	      *) func_append finalize_rpath " $libdir" ;;
8399e07dc26bSmrg	      esac
8400e07dc26bSmrg	      ;;
8401e07dc26bSmrg	    esac
8402e07dc26bSmrg	  fi # $linkmode,$pass = prog,link...
8403e07dc26bSmrg
8404e07dc26bSmrg	  if $alldeplibs &&
8405e07dc26bSmrg	     { test pass_all = "$deplibs_check_method" ||
8406e07dc26bSmrg	       { test yes = "$build_libtool_libs" &&
8407e07dc26bSmrg		 test -n "$library_names"; }; }; then
8408e07dc26bSmrg	    # We only need to search for static libraries
8409e07dc26bSmrg	    continue
8410e07dc26bSmrg	  fi
8411e07dc26bSmrg	fi
8412e07dc26bSmrg
8413e07dc26bSmrg	link_static=no # Whether the deplib will be linked statically
8414e07dc26bSmrg	use_static_libs=$prefer_static_libs
8415e07dc26bSmrg	if test built = "$use_static_libs" && test yes = "$installed"; then
8416e07dc26bSmrg	  use_static_libs=no
8417e07dc26bSmrg	fi
8418e07dc26bSmrg	if test -n "$library_names" &&
8419e07dc26bSmrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
8420e07dc26bSmrg	  case $host in
8421e07dc26bSmrg	  *cygwin* | *mingw* | *cegcc* | *os2*)
8422e07dc26bSmrg	      # No point in relinking DLLs because paths are not encoded
8423e07dc26bSmrg	      func_append notinst_deplibs " $lib"
8424e07dc26bSmrg	      need_relink=no
8425e07dc26bSmrg	    ;;
8426e07dc26bSmrg	  *)
8427e07dc26bSmrg	    if test no = "$installed"; then
8428e07dc26bSmrg	      func_append notinst_deplibs " $lib"
8429e07dc26bSmrg	      need_relink=yes
8430e07dc26bSmrg	    fi
8431e07dc26bSmrg	    ;;
8432e07dc26bSmrg	  esac
8433e07dc26bSmrg	  # This is a shared library
8434e07dc26bSmrg
8435e07dc26bSmrg	  # Warn about portability, can't link against -module's on some
8436e07dc26bSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
8437e07dc26bSmrg	  dlopenmodule=
8438e07dc26bSmrg	  for dlpremoduletest in $dlprefiles; do
8439e07dc26bSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
8440e07dc26bSmrg	      dlopenmodule=$dlpremoduletest
8441e07dc26bSmrg	      break
8442e07dc26bSmrg	    fi
8443e07dc26bSmrg	  done
8444e07dc26bSmrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8445e07dc26bSmrg	    echo
8446e07dc26bSmrg	    if test prog = "$linkmode"; then
8447e07dc26bSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
8448e07dc26bSmrg	    else
8449e07dc26bSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
8450e07dc26bSmrg	    fi
8451e07dc26bSmrg	    $ECHO "*** $linklib is not portable!"
8452e07dc26bSmrg	  fi
8453e07dc26bSmrg	  if test lib = "$linkmode" &&
8454e07dc26bSmrg	     test yes = "$hardcode_into_libs"; then
8455e07dc26bSmrg	    # Hardcode the library path.
8456e07dc26bSmrg	    # Skip directories that are in the system default run-time
8457e07dc26bSmrg	    # search path.
8458e07dc26bSmrg	    case " $sys_lib_dlsearch_path " in
8459e07dc26bSmrg	    *" $absdir "*) ;;
8460e07dc26bSmrg	    *)
8461e07dc26bSmrg	      case "$compile_rpath " in
8462e07dc26bSmrg	      *" $absdir "*) ;;
8463e07dc26bSmrg	      *) func_append compile_rpath " $absdir" ;;
8464e07dc26bSmrg	      esac
8465e07dc26bSmrg	      ;;
8466e07dc26bSmrg	    esac
8467e07dc26bSmrg	    case " $sys_lib_dlsearch_path " in
8468e07dc26bSmrg	    *" $libdir "*) ;;
8469e07dc26bSmrg	    *)
8470e07dc26bSmrg	      case "$finalize_rpath " in
8471e07dc26bSmrg	      *" $libdir "*) ;;
8472e07dc26bSmrg	      *) func_append finalize_rpath " $libdir" ;;
8473e07dc26bSmrg	      esac
8474e07dc26bSmrg	      ;;
8475e07dc26bSmrg	    esac
8476e07dc26bSmrg	  fi
8477e07dc26bSmrg
8478e07dc26bSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
8479e07dc26bSmrg	    # figure out the soname
8480e07dc26bSmrg	    set dummy $library_names
8481e07dc26bSmrg	    shift
8482e07dc26bSmrg	    realname=$1
8483e07dc26bSmrg	    shift
8484e07dc26bSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
8485e07dc26bSmrg	    # use dlname if we got it. it's perfectly good, no?
8486e07dc26bSmrg	    if test -n "$dlname"; then
8487e07dc26bSmrg	      soname=$dlname
8488e07dc26bSmrg	    elif test -n "$soname_spec"; then
8489e07dc26bSmrg	      # bleh windows
8490e07dc26bSmrg	      case $host in
8491e07dc26bSmrg	      *cygwin* | mingw* | *cegcc* | *os2*)
8492e07dc26bSmrg	        func_arith $current - $age
8493e07dc26bSmrg		major=$func_arith_result
8494e07dc26bSmrg		versuffix=-$major
8495e07dc26bSmrg		;;
8496e07dc26bSmrg	      esac
8497e07dc26bSmrg	      eval soname=\"$soname_spec\"
8498e07dc26bSmrg	    else
8499e07dc26bSmrg	      soname=$realname
8500e07dc26bSmrg	    fi
8501e07dc26bSmrg
8502e07dc26bSmrg	    # Make a new name for the extract_expsyms_cmds to use
8503e07dc26bSmrg	    soroot=$soname
8504e07dc26bSmrg	    func_basename "$soroot"
8505e07dc26bSmrg	    soname=$func_basename_result
8506e07dc26bSmrg	    func_stripname 'lib' '.dll' "$soname"
8507e07dc26bSmrg	    newlib=libimp-$func_stripname_result.a
8508e07dc26bSmrg
8509e07dc26bSmrg	    # If the library has no export list, then create one now
8510e07dc26bSmrg	    if test -f "$output_objdir/$soname-def"; then :
8511e07dc26bSmrg	    else
8512e07dc26bSmrg	      func_verbose "extracting exported symbol list from '$soname'"
8513e07dc26bSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
8514e07dc26bSmrg	    fi
8515e07dc26bSmrg
8516e07dc26bSmrg	    # Create $newlib
8517e07dc26bSmrg	    if test -f "$output_objdir/$newlib"; then :; else
8518e07dc26bSmrg	      func_verbose "generating import library for '$soname'"
8519e07dc26bSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
8520e07dc26bSmrg	    fi
8521e07dc26bSmrg	    # make sure the library variables are pointing to the new library
8522e07dc26bSmrg	    dir=$output_objdir
8523e07dc26bSmrg	    linklib=$newlib
8524e07dc26bSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
8525e07dc26bSmrg
8526e07dc26bSmrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
8527e07dc26bSmrg	    add_shlibpath=
8528e07dc26bSmrg	    add_dir=
8529e07dc26bSmrg	    add=
8530e07dc26bSmrg	    lib_linked=yes
8531e07dc26bSmrg	    case $hardcode_action in
8532e07dc26bSmrg	    immediate | unsupported)
8533e07dc26bSmrg	      if test no = "$hardcode_direct"; then
8534e07dc26bSmrg		add=$dir/$linklib
8535e07dc26bSmrg		case $host in
8536e07dc26bSmrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
8537e07dc26bSmrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
8538e07dc26bSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
8539e07dc26bSmrg		    *-*-unixware7*) add_dir=-L$dir ;;
8540e07dc26bSmrg		  *-*-darwin* )
8541e07dc26bSmrg		    # if the lib is a (non-dlopened) module then we cannot
8542e07dc26bSmrg		    # link against it, someone is ignoring the earlier warnings
8543e07dc26bSmrg		    if /usr/bin/file -L $add 2> /dev/null |
8544e07dc26bSmrg			 $GREP ": [^:]* bundle" >/dev/null; then
8545e07dc26bSmrg		      if test "X$dlopenmodule" != "X$lib"; then
8546e07dc26bSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
8547e07dc26bSmrg			if test -z "$old_library"; then
8548e07dc26bSmrg			  echo
8549e07dc26bSmrg			  echo "*** And there doesn't seem to be a static archive available"
8550e07dc26bSmrg			  echo "*** The link will probably fail, sorry"
8551e07dc26bSmrg			else
8552e07dc26bSmrg			  add=$dir/$old_library
8553e07dc26bSmrg			fi
8554e07dc26bSmrg		      elif test -n "$old_library"; then
8555e07dc26bSmrg			add=$dir/$old_library
8556e07dc26bSmrg		      fi
8557e07dc26bSmrg		    fi
8558e07dc26bSmrg		esac
8559e07dc26bSmrg	      elif test no = "$hardcode_minus_L"; then
8560e07dc26bSmrg		case $host in
8561e07dc26bSmrg		*-*-sunos*) add_shlibpath=$dir ;;
8562e07dc26bSmrg		esac
8563e07dc26bSmrg		add_dir=-L$dir
8564e07dc26bSmrg		add=-l$name
8565e07dc26bSmrg	      elif test no = "$hardcode_shlibpath_var"; then
8566e07dc26bSmrg		add_shlibpath=$dir
8567e07dc26bSmrg		add=-l$name
8568e07dc26bSmrg	      else
8569e07dc26bSmrg		lib_linked=no
8570e07dc26bSmrg	      fi
8571e07dc26bSmrg	      ;;
8572e07dc26bSmrg	    relink)
8573e07dc26bSmrg	      if test yes = "$hardcode_direct" &&
8574e07dc26bSmrg	         test no = "$hardcode_direct_absolute"; then
8575e07dc26bSmrg		add=$dir/$linklib
8576e07dc26bSmrg	      elif test yes = "$hardcode_minus_L"; then
8577e07dc26bSmrg		add_dir=-L$absdir
8578e07dc26bSmrg		# Try looking first in the location we're being installed to.
8579e07dc26bSmrg		if test -n "$inst_prefix_dir"; then
8580e07dc26bSmrg		  case $libdir in
8581e07dc26bSmrg		    [\\/]*)
8582e07dc26bSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
8583e07dc26bSmrg		      ;;
8584e07dc26bSmrg		  esac
8585e07dc26bSmrg		fi
8586e07dc26bSmrg		add=-l$name
8587e07dc26bSmrg	      elif test yes = "$hardcode_shlibpath_var"; then
8588e07dc26bSmrg		add_shlibpath=$dir
8589e07dc26bSmrg		add=-l$name
8590e07dc26bSmrg	      else
8591e07dc26bSmrg		lib_linked=no
8592e07dc26bSmrg	      fi
8593e07dc26bSmrg	      ;;
8594e07dc26bSmrg	    *) lib_linked=no ;;
8595e07dc26bSmrg	    esac
8596e07dc26bSmrg
8597e07dc26bSmrg	    if test yes != "$lib_linked"; then
8598e07dc26bSmrg	      func_fatal_configuration "unsupported hardcode properties"
8599e07dc26bSmrg	    fi
8600e07dc26bSmrg
8601e07dc26bSmrg	    if test -n "$add_shlibpath"; then
8602e07dc26bSmrg	      case :$compile_shlibpath: in
8603e07dc26bSmrg	      *":$add_shlibpath:"*) ;;
8604e07dc26bSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
8605e07dc26bSmrg	      esac
8606e07dc26bSmrg	    fi
8607e07dc26bSmrg	    if test prog = "$linkmode"; then
8608e07dc26bSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
8609e07dc26bSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
8610e07dc26bSmrg	    else
8611e07dc26bSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8612e07dc26bSmrg	      test -n "$add" && deplibs="$add $deplibs"
8613e07dc26bSmrg	      if test yes != "$hardcode_direct" &&
8614e07dc26bSmrg		 test yes != "$hardcode_minus_L" &&
8615e07dc26bSmrg		 test yes = "$hardcode_shlibpath_var"; then
8616e07dc26bSmrg		case :$finalize_shlibpath: in
8617e07dc26bSmrg		*":$libdir:"*) ;;
8618e07dc26bSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
8619e07dc26bSmrg		esac
8620e07dc26bSmrg	      fi
8621e07dc26bSmrg	    fi
8622e07dc26bSmrg	  fi
8623e07dc26bSmrg
8624e07dc26bSmrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
8625e07dc26bSmrg	    add_shlibpath=
8626e07dc26bSmrg	    add_dir=
8627e07dc26bSmrg	    add=
8628e07dc26bSmrg	    # Finalize command for both is simple: just hardcode it.
8629e07dc26bSmrg	    if test yes = "$hardcode_direct" &&
8630e07dc26bSmrg	       test no = "$hardcode_direct_absolute"; then
8631e07dc26bSmrg	      add=$libdir/$linklib
8632e07dc26bSmrg	    elif test yes = "$hardcode_minus_L"; then
8633e07dc26bSmrg	      add_dir=-L$libdir
8634e07dc26bSmrg	      add=-l$name
8635e07dc26bSmrg	    elif test yes = "$hardcode_shlibpath_var"; then
8636e07dc26bSmrg	      case :$finalize_shlibpath: in
8637e07dc26bSmrg	      *":$libdir:"*) ;;
8638e07dc26bSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
8639e07dc26bSmrg	      esac
8640e07dc26bSmrg	      add=-l$name
8641e07dc26bSmrg	    elif test yes = "$hardcode_automatic"; then
8642e07dc26bSmrg	      if test -n "$inst_prefix_dir" &&
8643e07dc26bSmrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
8644e07dc26bSmrg		add=$inst_prefix_dir$libdir/$linklib
8645e07dc26bSmrg	      else
8646e07dc26bSmrg		add=$libdir/$linklib
8647e07dc26bSmrg	      fi
8648e07dc26bSmrg	    else
8649e07dc26bSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
8650e07dc26bSmrg	      add_dir=-L$libdir
8651e07dc26bSmrg	      # Try looking first in the location we're being installed to.
8652e07dc26bSmrg	      if test -n "$inst_prefix_dir"; then
8653e07dc26bSmrg		case $libdir in
8654e07dc26bSmrg		  [\\/]*)
8655e07dc26bSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
8656e07dc26bSmrg		    ;;
8657e07dc26bSmrg		esac
8658e07dc26bSmrg	      fi
8659e07dc26bSmrg	      add=-l$name
8660e07dc26bSmrg	    fi
8661e07dc26bSmrg
8662e07dc26bSmrg	    if test prog = "$linkmode"; then
8663e07dc26bSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
8664e07dc26bSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
8665e07dc26bSmrg	    else
8666e07dc26bSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8667e07dc26bSmrg	      test -n "$add" && deplibs="$add $deplibs"
8668e07dc26bSmrg	    fi
8669e07dc26bSmrg	  fi
8670e07dc26bSmrg	elif test prog = "$linkmode"; then
8671e07dc26bSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
8672e07dc26bSmrg	  # is not unsupported.  This is valid on all known static and
8673e07dc26bSmrg	  # shared platforms.
8674e07dc26bSmrg	  if test unsupported != "$hardcode_direct"; then
8675e07dc26bSmrg	    test -n "$old_library" && linklib=$old_library
8676e07dc26bSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
8677e07dc26bSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
8678e07dc26bSmrg	  else
8679e07dc26bSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
8680e07dc26bSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
8681e07dc26bSmrg	  fi
8682e07dc26bSmrg	elif test yes = "$build_libtool_libs"; then
8683e07dc26bSmrg	  # Not a shared library
8684e07dc26bSmrg	  if test pass_all != "$deplibs_check_method"; then
8685e07dc26bSmrg	    # We're trying link a shared library against a static one
8686e07dc26bSmrg	    # but the system doesn't support it.
8687e07dc26bSmrg
8688e07dc26bSmrg	    # Just print a warning and add the library to dependency_libs so
8689e07dc26bSmrg	    # that the program can be linked against the static library.
8690e07dc26bSmrg	    echo
8691e07dc26bSmrg	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8692e07dc26bSmrg	    echo "*** I have the capability to make that library automatically link in when"
8693e07dc26bSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
8694e07dc26bSmrg	    echo "*** shared version of the library, which you do not appear to have."
8695e07dc26bSmrg	    if test yes = "$module"; then
8696e07dc26bSmrg	      echo "*** But as you try to build a module library, libtool will still create "
8697e07dc26bSmrg	      echo "*** a static module, that should work as long as the dlopening application"
8698e07dc26bSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
8699e07dc26bSmrg	      if test -z "$global_symbol_pipe"; then
8700e07dc26bSmrg		echo
8701e07dc26bSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
8702e07dc26bSmrg		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8703e07dc26bSmrg		echo "*** not find such a program.  So, this module is probably useless."
8704e07dc26bSmrg		echo "*** 'nm' from GNU binutils and a full rebuild may help."
8705e07dc26bSmrg	      fi
8706e07dc26bSmrg	      if test no = "$build_old_libs"; then
8707e07dc26bSmrg		build_libtool_libs=module
8708e07dc26bSmrg		build_old_libs=yes
8709e07dc26bSmrg	      else
8710e07dc26bSmrg		build_libtool_libs=no
8711e07dc26bSmrg	      fi
8712e07dc26bSmrg	    fi
8713e07dc26bSmrg	  else
8714e07dc26bSmrg	    deplibs="$dir/$old_library $deplibs"
8715e07dc26bSmrg	    link_static=yes
8716e07dc26bSmrg	  fi
8717e07dc26bSmrg	fi # link shared/static library?
8718e07dc26bSmrg
8719e07dc26bSmrg	if test lib = "$linkmode"; then
8720e07dc26bSmrg	  if test -n "$dependency_libs" &&
8721e07dc26bSmrg	     { test yes != "$hardcode_into_libs" ||
8722e07dc26bSmrg	       test yes = "$build_old_libs" ||
8723e07dc26bSmrg	       test yes = "$link_static"; }; then
8724e07dc26bSmrg	    # Extract -R from dependency_libs
8725e07dc26bSmrg	    temp_deplibs=
8726e07dc26bSmrg	    for libdir in $dependency_libs; do
8727e07dc26bSmrg	      case $libdir in
8728e07dc26bSmrg	      -R*) func_stripname '-R' '' "$libdir"
8729e07dc26bSmrg	           temp_xrpath=$func_stripname_result
8730e07dc26bSmrg		   case " $xrpath " in
8731e07dc26bSmrg		   *" $temp_xrpath "*) ;;
8732e07dc26bSmrg		   *) func_append xrpath " $temp_xrpath";;
8733e07dc26bSmrg		   esac;;
8734e07dc26bSmrg	      *) func_append temp_deplibs " $libdir";;
8735e07dc26bSmrg	      esac
8736e07dc26bSmrg	    done
8737e07dc26bSmrg	    dependency_libs=$temp_deplibs
8738e07dc26bSmrg	  fi
8739e07dc26bSmrg
8740e07dc26bSmrg	  func_append newlib_search_path " $absdir"
8741e07dc26bSmrg	  # Link against this library
8742e07dc26bSmrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
8743e07dc26bSmrg	  # ... and its dependency_libs
8744e07dc26bSmrg	  tmp_libs=
8745e07dc26bSmrg	  for deplib in $dependency_libs; do
8746e07dc26bSmrg	    newdependency_libs="$deplib $newdependency_libs"
8747e07dc26bSmrg	    case $deplib in
8748e07dc26bSmrg              -L*) func_stripname '-L' '' "$deplib"
8749e07dc26bSmrg                   func_resolve_sysroot "$func_stripname_result";;
8750e07dc26bSmrg              *) func_resolve_sysroot "$deplib" ;;
8751e07dc26bSmrg            esac
8752e07dc26bSmrg	    if $opt_preserve_dup_deps; then
8753e07dc26bSmrg	      case "$tmp_libs " in
8754e07dc26bSmrg	      *" $func_resolve_sysroot_result "*)
8755e07dc26bSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
8756e07dc26bSmrg	      esac
8757e07dc26bSmrg	    fi
8758e07dc26bSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
8759e07dc26bSmrg	  done
8760e07dc26bSmrg
8761e07dc26bSmrg	  if test no != "$link_all_deplibs"; then
8762e07dc26bSmrg	    # Add the search paths of all dependency libraries
8763e07dc26bSmrg	    for deplib in $dependency_libs; do
8764e07dc26bSmrg	      path=
8765e07dc26bSmrg	      case $deplib in
8766e07dc26bSmrg	      -L*) path=$deplib ;;
8767e07dc26bSmrg	      *.la)
8768e07dc26bSmrg	        func_resolve_sysroot "$deplib"
8769e07dc26bSmrg	        deplib=$func_resolve_sysroot_result
8770e07dc26bSmrg	        func_dirname "$deplib" "" "."
8771e07dc26bSmrg		dir=$func_dirname_result
8772e07dc26bSmrg		# We need an absolute path.
8773e07dc26bSmrg		case $dir in
8774e07dc26bSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
8775e07dc26bSmrg		*)
8776e07dc26bSmrg		  absdir=`cd "$dir" && pwd`
8777e07dc26bSmrg		  if test -z "$absdir"; then
8778e07dc26bSmrg		    func_warning "cannot determine absolute directory name of '$dir'"
8779e07dc26bSmrg		    absdir=$dir
8780e07dc26bSmrg		  fi
8781e07dc26bSmrg		  ;;
8782e07dc26bSmrg		esac
8783e07dc26bSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
8784e07dc26bSmrg		case $host in
8785e07dc26bSmrg		*-*-darwin*)
8786e07dc26bSmrg		  depdepl=
8787e07dc26bSmrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
8788e07dc26bSmrg		  if test -n "$deplibrary_names"; then
8789e07dc26bSmrg		    for tmp in $deplibrary_names; do
8790e07dc26bSmrg		      depdepl=$tmp
8791e07dc26bSmrg		    done
8792e07dc26bSmrg		    if test -f "$absdir/$objdir/$depdepl"; then
8793e07dc26bSmrg		      depdepl=$absdir/$objdir/$depdepl
8794e07dc26bSmrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8795e07dc26bSmrg                      if test -z "$darwin_install_name"; then
8796e07dc26bSmrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
8797e07dc26bSmrg                      fi
8798e07dc26bSmrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
8799e07dc26bSmrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
8800e07dc26bSmrg		      path=
8801e07dc26bSmrg		    fi
8802e07dc26bSmrg		  fi
8803e07dc26bSmrg		  ;;
8804e07dc26bSmrg		*)
8805e07dc26bSmrg		  path=-L$absdir/$objdir
8806e07dc26bSmrg		  ;;
8807e07dc26bSmrg		esac
8808e07dc26bSmrg		else
8809e07dc26bSmrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8810e07dc26bSmrg		  test -z "$libdir" && \
8811e07dc26bSmrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
8812e07dc26bSmrg		  test "$absdir" != "$libdir" && \
8813e07dc26bSmrg		    func_warning "'$deplib' seems to be moved"
8814e07dc26bSmrg
8815e07dc26bSmrg		  path=-L$absdir
8816e07dc26bSmrg		fi
8817e07dc26bSmrg		;;
8818e07dc26bSmrg	      esac
8819e07dc26bSmrg	      case " $deplibs " in
8820e07dc26bSmrg	      *" $path "*) ;;
8821e07dc26bSmrg	      *) deplibs="$path $deplibs" ;;
8822e07dc26bSmrg	      esac
8823e07dc26bSmrg	    done
8824e07dc26bSmrg	  fi # link_all_deplibs != no
8825e07dc26bSmrg	fi # linkmode = lib
8826e07dc26bSmrg      done # for deplib in $libs
8827e07dc26bSmrg      if test link = "$pass"; then
8828e07dc26bSmrg	if test prog = "$linkmode"; then
8829e07dc26bSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
8830e07dc26bSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
8831e07dc26bSmrg	else
8832e07dc26bSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8833e07dc26bSmrg	fi
8834e07dc26bSmrg      fi
8835e07dc26bSmrg      dependency_libs=$newdependency_libs
8836e07dc26bSmrg      if test dlpreopen = "$pass"; then
8837e07dc26bSmrg	# Link the dlpreopened libraries before other libraries
8838e07dc26bSmrg	for deplib in $save_deplibs; do
8839e07dc26bSmrg	  deplibs="$deplib $deplibs"
8840e07dc26bSmrg	done
8841e07dc26bSmrg      fi
8842e07dc26bSmrg      if test dlopen != "$pass"; then
8843e07dc26bSmrg	test conv = "$pass" || {
8844e07dc26bSmrg	  # Make sure lib_search_path contains only unique directories.
8845e07dc26bSmrg	  lib_search_path=
8846e07dc26bSmrg	  for dir in $newlib_search_path; do
8847e07dc26bSmrg	    case "$lib_search_path " in
8848e07dc26bSmrg	    *" $dir "*) ;;
8849e07dc26bSmrg	    *) func_append lib_search_path " $dir" ;;
8850e07dc26bSmrg	    esac
8851e07dc26bSmrg	  done
8852e07dc26bSmrg	  newlib_search_path=
8853e07dc26bSmrg	}
8854e07dc26bSmrg
8855e07dc26bSmrg	if test prog,link = "$linkmode,$pass"; then
8856e07dc26bSmrg	  vars="compile_deplibs finalize_deplibs"
8857e07dc26bSmrg	else
8858e07dc26bSmrg	  vars=deplibs
8859e07dc26bSmrg	fi
8860e07dc26bSmrg	for var in $vars dependency_libs; do
8861e07dc26bSmrg	  # Add libraries to $var in reverse order
8862e07dc26bSmrg	  eval tmp_libs=\"\$$var\"
8863e07dc26bSmrg	  new_libs=
8864e07dc26bSmrg	  for deplib in $tmp_libs; do
8865e07dc26bSmrg	    # FIXME: Pedantically, this is the right thing to do, so
8866e07dc26bSmrg	    #        that some nasty dependency loop isn't accidentally
8867e07dc26bSmrg	    #        broken:
8868e07dc26bSmrg	    #new_libs="$deplib $new_libs"
8869e07dc26bSmrg	    # Pragmatically, this seems to cause very few problems in
8870e07dc26bSmrg	    # practice:
8871e07dc26bSmrg	    case $deplib in
8872e07dc26bSmrg	    -L*) new_libs="$deplib $new_libs" ;;
8873e07dc26bSmrg	    -R*) ;;
8874e07dc26bSmrg	    *)
8875e07dc26bSmrg	      # And here is the reason: when a library appears more
8876e07dc26bSmrg	      # than once as an explicit dependence of a library, or
8877e07dc26bSmrg	      # is implicitly linked in more than once by the
8878e07dc26bSmrg	      # compiler, it is considered special, and multiple
8879e07dc26bSmrg	      # occurrences thereof are not removed.  Compare this
8880e07dc26bSmrg	      # with having the same library being listed as a
8881e07dc26bSmrg	      # dependency of multiple other libraries: in this case,
8882e07dc26bSmrg	      # we know (pedantically, we assume) the library does not
8883e07dc26bSmrg	      # need to be listed more than once, so we keep only the
8884e07dc26bSmrg	      # last copy.  This is not always right, but it is rare
8885e07dc26bSmrg	      # enough that we require users that really mean to play
8886e07dc26bSmrg	      # such unportable linking tricks to link the library
8887e07dc26bSmrg	      # using -Wl,-lname, so that libtool does not consider it
8888e07dc26bSmrg	      # for duplicate removal.
8889e07dc26bSmrg	      case " $specialdeplibs " in
8890e07dc26bSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
8891e07dc26bSmrg	      *)
8892e07dc26bSmrg		case " $new_libs " in
8893e07dc26bSmrg		*" $deplib "*) ;;
8894e07dc26bSmrg		*) new_libs="$deplib $new_libs" ;;
8895e07dc26bSmrg		esac
8896e07dc26bSmrg		;;
8897e07dc26bSmrg	      esac
8898e07dc26bSmrg	      ;;
8899e07dc26bSmrg	    esac
8900e07dc26bSmrg	  done
8901e07dc26bSmrg	  tmp_libs=
8902e07dc26bSmrg	  for deplib in $new_libs; do
8903e07dc26bSmrg	    case $deplib in
8904e07dc26bSmrg	    -L*)
8905e07dc26bSmrg	      case " $tmp_libs " in
8906e07dc26bSmrg	      *" $deplib "*) ;;
8907e07dc26bSmrg	      *) func_append tmp_libs " $deplib" ;;
8908e07dc26bSmrg	      esac
8909e07dc26bSmrg	      ;;
8910e07dc26bSmrg	    *) func_append tmp_libs " $deplib" ;;
8911e07dc26bSmrg	    esac
8912e07dc26bSmrg	  done
8913e07dc26bSmrg	  eval $var=\"$tmp_libs\"
8914e07dc26bSmrg	done # for var
8915e07dc26bSmrg      fi
8916e07dc26bSmrg
8917e07dc26bSmrg      # Add Sun CC postdeps if required:
8918e07dc26bSmrg      test CXX = "$tagname" && {
8919e07dc26bSmrg        case $host_os in
8920e07dc26bSmrg        linux*)
8921636c353eSmrg          case `$CC -V 2>&1 | $SED 5q` in
8922e07dc26bSmrg          *Sun\ C*) # Sun C++ 5.9
8923e07dc26bSmrg            func_suncc_cstd_abi
8924e07dc26bSmrg
8925e07dc26bSmrg            if test no != "$suncc_use_cstd_abi"; then
8926e07dc26bSmrg              func_append postdeps ' -library=Cstd -library=Crun'
8927e07dc26bSmrg            fi
8928e07dc26bSmrg            ;;
8929e07dc26bSmrg          esac
8930e07dc26bSmrg          ;;
8931e07dc26bSmrg
8932e07dc26bSmrg        solaris*)
8933e07dc26bSmrg          func_cc_basename "$CC"
8934e07dc26bSmrg          case $func_cc_basename_result in
8935e07dc26bSmrg          CC* | sunCC*)
8936e07dc26bSmrg            func_suncc_cstd_abi
8937e07dc26bSmrg
8938e07dc26bSmrg            if test no != "$suncc_use_cstd_abi"; then
8939e07dc26bSmrg              func_append postdeps ' -library=Cstd -library=Crun'
8940e07dc26bSmrg            fi
8941e07dc26bSmrg            ;;
8942e07dc26bSmrg          esac
8943e07dc26bSmrg          ;;
8944e07dc26bSmrg        esac
8945e07dc26bSmrg      }
8946e07dc26bSmrg
8947e07dc26bSmrg      # Last step: remove runtime libs from dependency_libs
8948e07dc26bSmrg      # (they stay in deplibs)
8949e07dc26bSmrg      tmp_libs=
8950e07dc26bSmrg      for i in $dependency_libs; do
8951e07dc26bSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
8952e07dc26bSmrg	*" $i "*)
8953e07dc26bSmrg	  i=
8954e07dc26bSmrg	  ;;
8955e07dc26bSmrg	esac
8956e07dc26bSmrg	if test -n "$i"; then
8957e07dc26bSmrg	  func_append tmp_libs " $i"
8958e07dc26bSmrg	fi
8959e07dc26bSmrg      done
8960e07dc26bSmrg      dependency_libs=$tmp_libs
8961e07dc26bSmrg    done # for pass
8962e07dc26bSmrg    if test prog = "$linkmode"; then
8963e07dc26bSmrg      dlfiles=$newdlfiles
8964e07dc26bSmrg    fi
8965e07dc26bSmrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
8966e07dc26bSmrg      dlprefiles=$newdlprefiles
8967e07dc26bSmrg    fi
8968e07dc26bSmrg
8969e07dc26bSmrg    case $linkmode in
8970e07dc26bSmrg    oldlib)
8971e07dc26bSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
8972e07dc26bSmrg	func_warning "'-dlopen' is ignored for archives"
8973e07dc26bSmrg      fi
8974e07dc26bSmrg
8975e07dc26bSmrg      case " $deplibs" in
8976e07dc26bSmrg      *\ -l* | *\ -L*)
8977e07dc26bSmrg	func_warning "'-l' and '-L' are ignored for archives" ;;
8978e07dc26bSmrg      esac
8979e07dc26bSmrg
8980e07dc26bSmrg      test -n "$rpath" && \
8981e07dc26bSmrg	func_warning "'-rpath' is ignored for archives"
8982e07dc26bSmrg
8983e07dc26bSmrg      test -n "$xrpath" && \
8984e07dc26bSmrg	func_warning "'-R' is ignored for archives"
8985e07dc26bSmrg
8986e07dc26bSmrg      test -n "$vinfo" && \
8987e07dc26bSmrg	func_warning "'-version-info/-version-number' is ignored for archives"
8988e07dc26bSmrg
8989e07dc26bSmrg      test -n "$release" && \
8990e07dc26bSmrg	func_warning "'-release' is ignored for archives"
8991e07dc26bSmrg
8992e07dc26bSmrg      test -n "$export_symbols$export_symbols_regex" && \
8993e07dc26bSmrg	func_warning "'-export-symbols' is ignored for archives"
8994e07dc26bSmrg
8995e07dc26bSmrg      # Now set the variables for building old libraries.
8996e07dc26bSmrg      build_libtool_libs=no
8997e07dc26bSmrg      oldlibs=$output
8998e07dc26bSmrg      func_append objs "$old_deplibs"
8999e07dc26bSmrg      ;;
9000e07dc26bSmrg
9001e07dc26bSmrg    lib)
9002e07dc26bSmrg      # Make sure we only generate libraries of the form 'libNAME.la'.
9003e07dc26bSmrg      case $outputname in
9004e07dc26bSmrg      lib*)
9005e07dc26bSmrg	func_stripname 'lib' '.la' "$outputname"
9006e07dc26bSmrg	name=$func_stripname_result
9007e07dc26bSmrg	eval shared_ext=\"$shrext_cmds\"
9008e07dc26bSmrg	eval libname=\"$libname_spec\"
9009e07dc26bSmrg	;;
9010e07dc26bSmrg      *)
9011e07dc26bSmrg	test no = "$module" \
9012e07dc26bSmrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
9013e07dc26bSmrg
9014e07dc26bSmrg	if test no != "$need_lib_prefix"; then
9015e07dc26bSmrg	  # Add the "lib" prefix for modules if required
9016e07dc26bSmrg	  func_stripname '' '.la' "$outputname"
9017e07dc26bSmrg	  name=$func_stripname_result
9018e07dc26bSmrg	  eval shared_ext=\"$shrext_cmds\"
9019e07dc26bSmrg	  eval libname=\"$libname_spec\"
9020e07dc26bSmrg	else
9021e07dc26bSmrg	  func_stripname '' '.la' "$outputname"
9022e07dc26bSmrg	  libname=$func_stripname_result
9023e07dc26bSmrg	fi
9024e07dc26bSmrg	;;
9025e07dc26bSmrg      esac
9026e07dc26bSmrg
9027e07dc26bSmrg      if test -n "$objs"; then
9028e07dc26bSmrg	if test pass_all != "$deplibs_check_method"; then
9029e07dc26bSmrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
9030e07dc26bSmrg	else
9031e07dc26bSmrg	  echo
9032e07dc26bSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
9033e07dc26bSmrg	  $ECHO "*** objects $objs is not portable!"
9034e07dc26bSmrg	  func_append libobjs " $objs"
9035e07dc26bSmrg	fi
9036e07dc26bSmrg      fi
9037e07dc26bSmrg
9038e07dc26bSmrg      test no = "$dlself" \
9039e07dc26bSmrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
9040e07dc26bSmrg
9041e07dc26bSmrg      set dummy $rpath
9042e07dc26bSmrg      shift
9043e07dc26bSmrg      test 1 -lt "$#" \
9044e07dc26bSmrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
9045e07dc26bSmrg
9046e07dc26bSmrg      install_libdir=$1
9047e07dc26bSmrg
9048e07dc26bSmrg      oldlibs=
9049e07dc26bSmrg      if test -z "$rpath"; then
9050e07dc26bSmrg	if test yes = "$build_libtool_libs"; then
9051e07dc26bSmrg	  # Building a libtool convenience library.
9052e07dc26bSmrg	  # Some compilers have problems with a '.al' extension so
9053e07dc26bSmrg	  # convenience libraries should have the same extension an
9054e07dc26bSmrg	  # archive normally would.
9055e07dc26bSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
9056e07dc26bSmrg	  build_libtool_libs=convenience
9057e07dc26bSmrg	  build_old_libs=yes
9058e07dc26bSmrg	fi
9059e07dc26bSmrg
9060e07dc26bSmrg	test -n "$vinfo" && \
9061e07dc26bSmrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
9062e07dc26bSmrg
9063e07dc26bSmrg	test -n "$release" && \
9064e07dc26bSmrg	  func_warning "'-release' is ignored for convenience libraries"
9065e07dc26bSmrg      else
9066e07dc26bSmrg
9067e07dc26bSmrg	# Parse the version information argument.
9068e07dc26bSmrg	save_ifs=$IFS; IFS=:
9069e07dc26bSmrg	set dummy $vinfo 0 0 0
9070e07dc26bSmrg	shift
9071e07dc26bSmrg	IFS=$save_ifs
9072e07dc26bSmrg
9073e07dc26bSmrg	test -n "$7" && \
9074e07dc26bSmrg	  func_fatal_help "too many parameters to '-version-info'"
9075e07dc26bSmrg
9076e07dc26bSmrg	# convert absolute version numbers to libtool ages
9077e07dc26bSmrg	# this retains compatibility with .la files and attempts
9078e07dc26bSmrg	# to make the code below a bit more comprehensible
9079e07dc26bSmrg
9080e07dc26bSmrg	case $vinfo_number in
9081e07dc26bSmrg	yes)
9082e07dc26bSmrg	  number_major=$1
9083e07dc26bSmrg	  number_minor=$2
9084e07dc26bSmrg	  number_revision=$3
9085e07dc26bSmrg	  #
9086e07dc26bSmrg	  # There are really only two kinds -- those that
9087e07dc26bSmrg	  # use the current revision as the major version
9088e07dc26bSmrg	  # and those that subtract age and use age as
9089e07dc26bSmrg	  # a minor version.  But, then there is irix
9090e07dc26bSmrg	  # that has an extra 1 added just for fun
9091e07dc26bSmrg	  #
9092e07dc26bSmrg	  case $version_type in
9093e07dc26bSmrg	  # correct linux to gnu/linux during the next big refactor
9094636c353eSmrg	  darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none)
9095e07dc26bSmrg	    func_arith $number_major + $number_minor
9096e07dc26bSmrg	    current=$func_arith_result
9097e07dc26bSmrg	    age=$number_minor
9098e07dc26bSmrg	    revision=$number_revision
9099e07dc26bSmrg	    ;;
9100e07dc26bSmrg	  freebsd-aout|qnx|sunos)
9101e07dc26bSmrg	    current=$number_major
9102e07dc26bSmrg	    revision=$number_minor
9103e07dc26bSmrg	    age=0
9104e07dc26bSmrg	    ;;
9105e07dc26bSmrg	  irix|nonstopux)
9106e07dc26bSmrg	    func_arith $number_major + $number_minor
9107e07dc26bSmrg	    current=$func_arith_result
9108e07dc26bSmrg	    age=$number_minor
9109e07dc26bSmrg	    revision=$number_minor
9110e07dc26bSmrg	    lt_irix_increment=no
9111e07dc26bSmrg	    ;;
9112e07dc26bSmrg	  esac
9113e07dc26bSmrg	  ;;
9114e07dc26bSmrg	no)
9115e07dc26bSmrg	  current=$1
9116e07dc26bSmrg	  revision=$2
9117e07dc26bSmrg	  age=$3
9118e07dc26bSmrg	  ;;
9119e07dc26bSmrg	esac
9120e07dc26bSmrg
9121e07dc26bSmrg	# Check that each of the things are valid numbers.
9122e07dc26bSmrg	case $current in
9123e07dc26bSmrg	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]) ;;
9124e07dc26bSmrg	*)
9125e07dc26bSmrg	  func_error "CURRENT '$current' must be a nonnegative integer"
9126e07dc26bSmrg	  func_fatal_error "'$vinfo' is not valid version information"
9127e07dc26bSmrg	  ;;
9128e07dc26bSmrg	esac
9129e07dc26bSmrg
9130e07dc26bSmrg	case $revision in
9131e07dc26bSmrg	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]) ;;
9132e07dc26bSmrg	*)
9133e07dc26bSmrg	  func_error "REVISION '$revision' must be a nonnegative integer"
9134e07dc26bSmrg	  func_fatal_error "'$vinfo' is not valid version information"
9135e07dc26bSmrg	  ;;
9136e07dc26bSmrg	esac
9137e07dc26bSmrg
9138e07dc26bSmrg	case $age in
9139e07dc26bSmrg	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]) ;;
9140e07dc26bSmrg	*)
9141e07dc26bSmrg	  func_error "AGE '$age' must be a nonnegative integer"
9142e07dc26bSmrg	  func_fatal_error "'$vinfo' is not valid version information"
9143e07dc26bSmrg	  ;;
9144e07dc26bSmrg	esac
9145e07dc26bSmrg
9146e07dc26bSmrg	if test "$age" -gt "$current"; then
9147e07dc26bSmrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
9148e07dc26bSmrg	  func_fatal_error "'$vinfo' is not valid version information"
9149e07dc26bSmrg	fi
9150e07dc26bSmrg
9151e07dc26bSmrg	# Calculate the version variables.
9152e07dc26bSmrg	major=
9153e07dc26bSmrg	versuffix=
9154e07dc26bSmrg	verstring=
9155e07dc26bSmrg	case $version_type in
9156e07dc26bSmrg	none) ;;
9157e07dc26bSmrg
9158e07dc26bSmrg	darwin)
9159e07dc26bSmrg	  # Like Linux, but with the current version available in
9160e07dc26bSmrg	  # verstring for coding it into the library header
9161e07dc26bSmrg	  func_arith $current - $age
9162e07dc26bSmrg	  major=.$func_arith_result
9163e07dc26bSmrg	  versuffix=$major.$age.$revision
9164e07dc26bSmrg	  # Darwin ld doesn't like 0 for these options...
9165e07dc26bSmrg	  func_arith $current + 1
9166e07dc26bSmrg	  minor_current=$func_arith_result
9167e07dc26bSmrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
9168e07dc26bSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
9169e07dc26bSmrg          # On Darwin other compilers
9170e07dc26bSmrg          case $CC in
9171e07dc26bSmrg              nagfor*)
9172e07dc26bSmrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
9173e07dc26bSmrg                  ;;
9174e07dc26bSmrg              *)
9175e07dc26bSmrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
9176e07dc26bSmrg                  ;;
9177e07dc26bSmrg          esac
9178e07dc26bSmrg	  ;;
9179e07dc26bSmrg
9180e07dc26bSmrg	freebsd-aout)
9181e07dc26bSmrg	  major=.$current
9182e07dc26bSmrg	  versuffix=.$current.$revision
9183e07dc26bSmrg	  ;;
9184e07dc26bSmrg
9185636c353eSmrg	freebsd-elf | midnightbsd-elf)
9186e07dc26bSmrg	  func_arith $current - $age
9187e07dc26bSmrg	  major=.$func_arith_result
9188e07dc26bSmrg	  versuffix=$major.$age.$revision
9189e07dc26bSmrg	  ;;
9190e07dc26bSmrg
9191e07dc26bSmrg	irix | nonstopux)
9192e07dc26bSmrg	  if test no = "$lt_irix_increment"; then
9193e07dc26bSmrg	    func_arith $current - $age
9194e07dc26bSmrg	  else
9195e07dc26bSmrg	    func_arith $current - $age + 1
9196e07dc26bSmrg	  fi
9197e07dc26bSmrg	  major=$func_arith_result
9198e07dc26bSmrg
9199e07dc26bSmrg	  case $version_type in
9200e07dc26bSmrg	    nonstopux) verstring_prefix=nonstopux ;;
9201e07dc26bSmrg	    *)         verstring_prefix=sgi ;;
9202e07dc26bSmrg	  esac
9203e07dc26bSmrg	  verstring=$verstring_prefix$major.$revision
9204e07dc26bSmrg
9205e07dc26bSmrg	  # Add in all the interfaces that we are compatible with.
9206e07dc26bSmrg	  loop=$revision
9207e07dc26bSmrg	  while test 0 -ne "$loop"; do
9208e07dc26bSmrg	    func_arith $revision - $loop
9209e07dc26bSmrg	    iface=$func_arith_result
9210e07dc26bSmrg	    func_arith $loop - 1
9211e07dc26bSmrg	    loop=$func_arith_result
9212e07dc26bSmrg	    verstring=$verstring_prefix$major.$iface:$verstring
9213e07dc26bSmrg	  done
9214e07dc26bSmrg
9215e07dc26bSmrg	  # Before this point, $major must not contain '.'.
9216e07dc26bSmrg	  major=.$major
9217e07dc26bSmrg	  versuffix=$major.$revision
9218e07dc26bSmrg	  ;;
9219e07dc26bSmrg
9220e07dc26bSmrg	linux) # correct to gnu/linux during the next big refactor
9221e07dc26bSmrg	  func_arith $current - $age
9222e07dc26bSmrg	  major=.$func_arith_result
9223e07dc26bSmrg	  versuffix=$major.$age.$revision
9224e07dc26bSmrg	  ;;
9225e07dc26bSmrg
9226e07dc26bSmrg	osf)
9227e07dc26bSmrg	  func_arith $current - $age
9228e07dc26bSmrg	  major=.$func_arith_result
9229e07dc26bSmrg	  versuffix=.$current.$age.$revision
9230e07dc26bSmrg	  verstring=$current.$age.$revision
9231e07dc26bSmrg
9232e07dc26bSmrg	  # Add in all the interfaces that we are compatible with.
9233e07dc26bSmrg	  loop=$age
9234e07dc26bSmrg	  while test 0 -ne "$loop"; do
9235e07dc26bSmrg	    func_arith $current - $loop
9236e07dc26bSmrg	    iface=$func_arith_result
9237e07dc26bSmrg	    func_arith $loop - 1
9238e07dc26bSmrg	    loop=$func_arith_result
9239e07dc26bSmrg	    verstring=$verstring:$iface.0
9240e07dc26bSmrg	  done
9241e07dc26bSmrg
9242e07dc26bSmrg	  # Make executables depend on our current version.
9243e07dc26bSmrg	  func_append verstring ":$current.0"
9244e07dc26bSmrg	  ;;
9245e07dc26bSmrg
9246e07dc26bSmrg	qnx)
9247e07dc26bSmrg	  major=.$current
9248e07dc26bSmrg	  versuffix=.$current
9249e07dc26bSmrg	  ;;
9250e07dc26bSmrg
9251e07dc26bSmrg	sco)
9252e07dc26bSmrg	  major=.$current
9253e07dc26bSmrg	  versuffix=.$current
9254e07dc26bSmrg	  ;;
9255e07dc26bSmrg
9256e07dc26bSmrg	sunos)
9257e07dc26bSmrg	  major=.$current
9258e07dc26bSmrg	  versuffix=.$current.$revision
9259e07dc26bSmrg	  ;;
9260e07dc26bSmrg
9261e07dc26bSmrg	windows)
9262e07dc26bSmrg	  # Use '-' rather than '.', since we only want one
9263e07dc26bSmrg	  # extension on DOS 8.3 file systems.
9264e07dc26bSmrg	  func_arith $current - $age
9265e07dc26bSmrg	  major=$func_arith_result
9266e07dc26bSmrg	  versuffix=-$major
9267e07dc26bSmrg	  ;;
9268e07dc26bSmrg
9269e07dc26bSmrg	*)
9270e07dc26bSmrg	  func_fatal_configuration "unknown library version type '$version_type'"
9271e07dc26bSmrg	  ;;
9272e07dc26bSmrg	esac
9273e07dc26bSmrg
9274e07dc26bSmrg	# Clear the version info if we defaulted, and they specified a release.
9275e07dc26bSmrg	if test -z "$vinfo" && test -n "$release"; then
9276e07dc26bSmrg	  major=
9277e07dc26bSmrg	  case $version_type in
9278e07dc26bSmrg	  darwin)
9279e07dc26bSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
9280e07dc26bSmrg	    # problems, so we reset it completely
9281e07dc26bSmrg	    verstring=
9282e07dc26bSmrg	    ;;
9283e07dc26bSmrg	  *)
9284e07dc26bSmrg	    verstring=0.0
9285e07dc26bSmrg	    ;;
9286e07dc26bSmrg	  esac
9287e07dc26bSmrg	  if test no = "$need_version"; then
9288e07dc26bSmrg	    versuffix=
9289e07dc26bSmrg	  else
9290e07dc26bSmrg	    versuffix=.0.0
9291e07dc26bSmrg	  fi
9292e07dc26bSmrg	fi
9293e07dc26bSmrg
9294e07dc26bSmrg	# Remove version info from name if versioning should be avoided
9295e07dc26bSmrg	if test yes,no = "$avoid_version,$need_version"; then
9296e07dc26bSmrg	  major=
9297e07dc26bSmrg	  versuffix=
9298e07dc26bSmrg	  verstring=
9299e07dc26bSmrg	fi
9300e07dc26bSmrg
9301e07dc26bSmrg	# Check to see if the archive will have undefined symbols.
9302e07dc26bSmrg	if test yes = "$allow_undefined"; then
9303e07dc26bSmrg	  if test unsupported = "$allow_undefined_flag"; then
9304e07dc26bSmrg	    if test yes = "$build_old_libs"; then
9305e07dc26bSmrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
9306e07dc26bSmrg	      build_libtool_libs=no
9307e07dc26bSmrg	    else
9308e07dc26bSmrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
9309e07dc26bSmrg	    fi
9310e07dc26bSmrg	  fi
9311e07dc26bSmrg	else
9312e07dc26bSmrg	  # Don't allow undefined symbols.
9313e07dc26bSmrg	  allow_undefined_flag=$no_undefined_flag
9314e07dc26bSmrg	fi
9315e07dc26bSmrg
9316e07dc26bSmrg      fi
9317e07dc26bSmrg
9318e07dc26bSmrg      func_generate_dlsyms "$libname" "$libname" :
9319e07dc26bSmrg      func_append libobjs " $symfileobj"
9320e07dc26bSmrg      test " " = "$libobjs" && libobjs=
9321e07dc26bSmrg
9322e07dc26bSmrg      if test relink != "$opt_mode"; then
9323e07dc26bSmrg	# Remove our outputs, but don't remove object files since they
9324e07dc26bSmrg	# may have been created when compiling PIC objects.
9325e07dc26bSmrg	removelist=
9326e07dc26bSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
9327e07dc26bSmrg	for p in $tempremovelist; do
9328e07dc26bSmrg	  case $p in
9329e07dc26bSmrg	    *.$objext | *.gcno)
9330e07dc26bSmrg	       ;;
9331e07dc26bSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
9332e07dc26bSmrg	       if test -n "$precious_files_regex"; then
9333e07dc26bSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
9334e07dc26bSmrg		 then
9335e07dc26bSmrg		   continue
9336e07dc26bSmrg		 fi
9337e07dc26bSmrg	       fi
9338e07dc26bSmrg	       func_append removelist " $p"
9339e07dc26bSmrg	       ;;
9340e07dc26bSmrg	    *) ;;
9341e07dc26bSmrg	  esac
9342e07dc26bSmrg	done
9343e07dc26bSmrg	test -n "$removelist" && \
9344e07dc26bSmrg	  func_show_eval "${RM}r \$removelist"
9345e07dc26bSmrg      fi
9346e07dc26bSmrg
9347e07dc26bSmrg      # Now set the variables for building old libraries.
9348e07dc26bSmrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9349e07dc26bSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
9350e07dc26bSmrg
9351e07dc26bSmrg	# Transform .lo files to .o files.
9352e07dc26bSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
9353e07dc26bSmrg      fi
9354e07dc26bSmrg
9355e07dc26bSmrg      # Eliminate all temporary directories.
9356e07dc26bSmrg      #for path in $notinst_path; do
9357e07dc26bSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9358e07dc26bSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9359e07dc26bSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
9360e07dc26bSmrg      #done
9361e07dc26bSmrg
9362e07dc26bSmrg      if test -n "$xrpath"; then
9363e07dc26bSmrg	# If the user specified any rpath flags, then add them.
9364e07dc26bSmrg	temp_xrpath=
9365e07dc26bSmrg	for libdir in $xrpath; do
9366e07dc26bSmrg	  func_replace_sysroot "$libdir"
9367e07dc26bSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
9368e07dc26bSmrg	  case "$finalize_rpath " in
9369e07dc26bSmrg	  *" $libdir "*) ;;
9370e07dc26bSmrg	  *) func_append finalize_rpath " $libdir" ;;
9371e07dc26bSmrg	  esac
9372e07dc26bSmrg	done
9373e07dc26bSmrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
9374e07dc26bSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
9375e07dc26bSmrg	fi
9376e07dc26bSmrg      fi
9377e07dc26bSmrg
9378e07dc26bSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
9379e07dc26bSmrg      old_dlfiles=$dlfiles
9380e07dc26bSmrg      dlfiles=
9381e07dc26bSmrg      for lib in $old_dlfiles; do
9382e07dc26bSmrg	case " $dlprefiles $dlfiles " in
9383e07dc26bSmrg	*" $lib "*) ;;
9384e07dc26bSmrg	*) func_append dlfiles " $lib" ;;
9385e07dc26bSmrg	esac
9386e07dc26bSmrg      done
9387e07dc26bSmrg
9388e07dc26bSmrg      # Make sure dlprefiles contains only unique files
9389e07dc26bSmrg      old_dlprefiles=$dlprefiles
9390e07dc26bSmrg      dlprefiles=
9391e07dc26bSmrg      for lib in $old_dlprefiles; do
9392e07dc26bSmrg	case "$dlprefiles " in
9393e07dc26bSmrg	*" $lib "*) ;;
9394e07dc26bSmrg	*) func_append dlprefiles " $lib" ;;
9395e07dc26bSmrg	esac
9396e07dc26bSmrg      done
9397e07dc26bSmrg
9398e07dc26bSmrg      if test yes = "$build_libtool_libs"; then
9399e07dc26bSmrg	if test -n "$rpath"; then
9400e07dc26bSmrg	  case $host in
9401e07dc26bSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
9402e07dc26bSmrg	    # these systems don't actually have a c library (as such)!
9403e07dc26bSmrg	    ;;
9404e07dc26bSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
9405e07dc26bSmrg	    # Rhapsody C library is in the System framework
9406e07dc26bSmrg	    func_append deplibs " System.ltframework"
9407e07dc26bSmrg	    ;;
9408e07dc26bSmrg	  *-*-netbsd*)
9409e07dc26bSmrg	    # Don't link with libc until the a.out ld.so is fixed.
9410e07dc26bSmrg	    ;;
9411636c353eSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
9412e07dc26bSmrg	    # Do not include libc due to us having libc/libc_r.
9413e07dc26bSmrg	    ;;
9414e07dc26bSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
9415e07dc26bSmrg	    # Causes problems with __ctype
9416e07dc26bSmrg	    ;;
9417e07dc26bSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
9418e07dc26bSmrg	    # Compiler inserts libc in the correct place for threads to work
9419e07dc26bSmrg	    ;;
9420e07dc26bSmrg	  *)
9421e07dc26bSmrg	    # Add libc to deplibs on all other systems if necessary.
9422e07dc26bSmrg	    if test yes = "$build_libtool_need_lc"; then
9423e07dc26bSmrg	      func_append deplibs " -lc"
9424e07dc26bSmrg	    fi
9425e07dc26bSmrg	    ;;
9426e07dc26bSmrg	  esac
9427e07dc26bSmrg	fi
9428e07dc26bSmrg
9429e07dc26bSmrg	# Transform deplibs into only deplibs that can be linked in shared.
9430e07dc26bSmrg	name_save=$name
9431e07dc26bSmrg	libname_save=$libname
9432e07dc26bSmrg	release_save=$release
9433e07dc26bSmrg	versuffix_save=$versuffix
9434e07dc26bSmrg	major_save=$major
9435e07dc26bSmrg	# I'm not sure if I'm treating the release correctly.  I think
9436e07dc26bSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
9437e07dc26bSmrg	# add it in twice.  Is that correct?
9438e07dc26bSmrg	release=
9439e07dc26bSmrg	versuffix=
9440e07dc26bSmrg	major=
9441e07dc26bSmrg	newdeplibs=
9442e07dc26bSmrg	droppeddeps=no
9443e07dc26bSmrg	case $deplibs_check_method in
9444e07dc26bSmrg	pass_all)
9445e07dc26bSmrg	  # Don't check for shared/static.  Everything works.
9446e07dc26bSmrg	  # This might be a little naive.  We might want to check
9447e07dc26bSmrg	  # whether the library exists or not.  But this is on
9448e07dc26bSmrg	  # osf3 & osf4 and I'm not really sure... Just
9449e07dc26bSmrg	  # implementing what was already the behavior.
9450e07dc26bSmrg	  newdeplibs=$deplibs
9451e07dc26bSmrg	  ;;
9452e07dc26bSmrg	test_compile)
9453e07dc26bSmrg	  # This code stresses the "libraries are programs" paradigm to its
9454e07dc26bSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
9455e07dc26bSmrg	  # against the deplibs as a proxy for the library.  Then we can check
9456e07dc26bSmrg	  # whether they linked in statically or dynamically with ldd.
9457e07dc26bSmrg	  $opt_dry_run || $RM conftest.c
9458e07dc26bSmrg	  cat > conftest.c <<EOF
9459e07dc26bSmrg	  int main() { return 0; }
9460e07dc26bSmrgEOF
9461e07dc26bSmrg	  $opt_dry_run || $RM conftest
9462e07dc26bSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
9463e07dc26bSmrg	    ldd_output=`ldd conftest`
9464e07dc26bSmrg	    for i in $deplibs; do
9465e07dc26bSmrg	      case $i in
9466e07dc26bSmrg	      -l*)
9467e07dc26bSmrg		func_stripname -l '' "$i"
9468e07dc26bSmrg		name=$func_stripname_result
9469e07dc26bSmrg		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9470e07dc26bSmrg		  case " $predeps $postdeps " in
9471e07dc26bSmrg		  *" $i "*)
9472e07dc26bSmrg		    func_append newdeplibs " $i"
9473e07dc26bSmrg		    i=
9474e07dc26bSmrg		    ;;
9475e07dc26bSmrg		  esac
9476e07dc26bSmrg		fi
9477e07dc26bSmrg		if test -n "$i"; then
9478e07dc26bSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
9479e07dc26bSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9480e07dc26bSmrg		  set dummy $deplib_matches; shift
9481e07dc26bSmrg		  deplib_match=$1
9482e07dc26bSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9483e07dc26bSmrg		    func_append newdeplibs " $i"
9484e07dc26bSmrg		  else
9485e07dc26bSmrg		    droppeddeps=yes
9486e07dc26bSmrg		    echo
9487e07dc26bSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9488e07dc26bSmrg		    echo "*** I have the capability to make that library automatically link in when"
9489e07dc26bSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
9490e07dc26bSmrg		    echo "*** shared version of the library, which I believe you do not have"
9491e07dc26bSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
9492e07dc26bSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
9493e07dc26bSmrg		  fi
9494e07dc26bSmrg		fi
9495e07dc26bSmrg		;;
9496e07dc26bSmrg	      *)
9497e07dc26bSmrg		func_append newdeplibs " $i"
9498e07dc26bSmrg		;;
9499e07dc26bSmrg	      esac
9500e07dc26bSmrg	    done
9501e07dc26bSmrg	  else
9502e07dc26bSmrg	    # Error occurred in the first compile.  Let's try to salvage
9503e07dc26bSmrg	    # the situation: Compile a separate program for each library.
9504e07dc26bSmrg	    for i in $deplibs; do
9505e07dc26bSmrg	      case $i in
9506e07dc26bSmrg	      -l*)
9507e07dc26bSmrg		func_stripname -l '' "$i"
9508e07dc26bSmrg		name=$func_stripname_result
9509e07dc26bSmrg		$opt_dry_run || $RM conftest
9510e07dc26bSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
9511e07dc26bSmrg		  ldd_output=`ldd conftest`
9512e07dc26bSmrg		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9513e07dc26bSmrg		    case " $predeps $postdeps " in
9514e07dc26bSmrg		    *" $i "*)
9515e07dc26bSmrg		      func_append newdeplibs " $i"
9516e07dc26bSmrg		      i=
9517e07dc26bSmrg		      ;;
9518e07dc26bSmrg		    esac
9519e07dc26bSmrg		  fi
9520e07dc26bSmrg		  if test -n "$i"; then
9521e07dc26bSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
9522e07dc26bSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9523e07dc26bSmrg		    set dummy $deplib_matches; shift
9524e07dc26bSmrg		    deplib_match=$1
9525e07dc26bSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9526e07dc26bSmrg		      func_append newdeplibs " $i"
9527e07dc26bSmrg		    else
9528e07dc26bSmrg		      droppeddeps=yes
9529e07dc26bSmrg		      echo
9530e07dc26bSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9531e07dc26bSmrg		      echo "*** I have the capability to make that library automatically link in when"
9532e07dc26bSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
9533e07dc26bSmrg		      echo "*** shared version of the library, which you do not appear to have"
9534e07dc26bSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
9535e07dc26bSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
9536e07dc26bSmrg		    fi
9537e07dc26bSmrg		  fi
9538e07dc26bSmrg		else
9539e07dc26bSmrg		  droppeddeps=yes
9540e07dc26bSmrg		  echo
9541e07dc26bSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
9542e07dc26bSmrg		  echo "*** make it link in!  You will probably need to install it or some"
9543e07dc26bSmrg		  echo "*** library that it depends on before this library will be fully"
9544e07dc26bSmrg		  echo "*** functional.  Installing it before continuing would be even better."
9545e07dc26bSmrg		fi
9546e07dc26bSmrg		;;
9547e07dc26bSmrg	      *)
9548e07dc26bSmrg		func_append newdeplibs " $i"
9549e07dc26bSmrg		;;
9550e07dc26bSmrg	      esac
9551e07dc26bSmrg	    done
9552e07dc26bSmrg	  fi
9553e07dc26bSmrg	  ;;
9554e07dc26bSmrg	file_magic*)
9555e07dc26bSmrg	  set dummy $deplibs_check_method; shift
9556e07dc26bSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9557e07dc26bSmrg	  for a_deplib in $deplibs; do
9558e07dc26bSmrg	    case $a_deplib in
9559e07dc26bSmrg	    -l*)
9560e07dc26bSmrg	      func_stripname -l '' "$a_deplib"
9561e07dc26bSmrg	      name=$func_stripname_result
9562e07dc26bSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9563e07dc26bSmrg		case " $predeps $postdeps " in
9564e07dc26bSmrg		*" $a_deplib "*)
9565e07dc26bSmrg		  func_append newdeplibs " $a_deplib"
9566e07dc26bSmrg		  a_deplib=
9567e07dc26bSmrg		  ;;
9568e07dc26bSmrg		esac
9569e07dc26bSmrg	      fi
9570e07dc26bSmrg	      if test -n "$a_deplib"; then
9571e07dc26bSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9572e07dc26bSmrg		if test -n "$file_magic_glob"; then
9573e07dc26bSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9574e07dc26bSmrg		else
9575e07dc26bSmrg		  libnameglob=$libname
9576e07dc26bSmrg		fi
9577e07dc26bSmrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
9578e07dc26bSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9579e07dc26bSmrg		  if test yes = "$want_nocaseglob"; then
9580e07dc26bSmrg		    shopt -s nocaseglob
9581e07dc26bSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9582e07dc26bSmrg		    $nocaseglob
9583e07dc26bSmrg		  else
9584e07dc26bSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9585e07dc26bSmrg		  fi
9586e07dc26bSmrg		  for potent_lib in $potential_libs; do
9587e07dc26bSmrg		      # Follow soft links.
9588e07dc26bSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
9589e07dc26bSmrg			 $GREP " -> " >/dev/null; then
9590e07dc26bSmrg			continue
9591e07dc26bSmrg		      fi
9592e07dc26bSmrg		      # The statement above tries to avoid entering an
9593e07dc26bSmrg		      # endless loop below, in case of cyclic links.
9594e07dc26bSmrg		      # We might still enter an endless loop, since a link
9595e07dc26bSmrg		      # loop can be closed while we follow links,
9596e07dc26bSmrg		      # but so what?
9597e07dc26bSmrg		      potlib=$potent_lib
9598e07dc26bSmrg		      while test -h "$potlib" 2>/dev/null; do
9599e07dc26bSmrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
9600e07dc26bSmrg			case $potliblink in
9601e07dc26bSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
9602e07dc26bSmrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
9603e07dc26bSmrg			esac
9604e07dc26bSmrg		      done
9605e07dc26bSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
9606e07dc26bSmrg			 $SED -e 10q |
9607e07dc26bSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
9608e07dc26bSmrg			func_append newdeplibs " $a_deplib"
9609e07dc26bSmrg			a_deplib=
9610e07dc26bSmrg			break 2
9611e07dc26bSmrg		      fi
9612e07dc26bSmrg		  done
9613e07dc26bSmrg		done
9614e07dc26bSmrg	      fi
9615e07dc26bSmrg	      if test -n "$a_deplib"; then
9616e07dc26bSmrg		droppeddeps=yes
9617e07dc26bSmrg		echo
9618e07dc26bSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9619e07dc26bSmrg		echo "*** I have the capability to make that library automatically link in when"
9620e07dc26bSmrg		echo "*** you link to this library.  But I can only do this if you have a"
9621e07dc26bSmrg		echo "*** shared version of the library, which you do not appear to have"
9622e07dc26bSmrg		echo "*** because I did check the linker path looking for a file starting"
9623e07dc26bSmrg		if test -z "$potlib"; then
9624e07dc26bSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
9625e07dc26bSmrg		else
9626e07dc26bSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9627e07dc26bSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
9628e07dc26bSmrg		fi
9629e07dc26bSmrg	      fi
9630e07dc26bSmrg	      ;;
9631e07dc26bSmrg	    *)
9632e07dc26bSmrg	      # Add a -L argument.
9633e07dc26bSmrg	      func_append newdeplibs " $a_deplib"
9634e07dc26bSmrg	      ;;
9635e07dc26bSmrg	    esac
9636e07dc26bSmrg	  done # Gone through all deplibs.
9637e07dc26bSmrg	  ;;
9638e07dc26bSmrg	match_pattern*)
9639e07dc26bSmrg	  set dummy $deplibs_check_method; shift
9640e07dc26bSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9641e07dc26bSmrg	  for a_deplib in $deplibs; do
9642e07dc26bSmrg	    case $a_deplib in
9643e07dc26bSmrg	    -l*)
9644e07dc26bSmrg	      func_stripname -l '' "$a_deplib"
9645e07dc26bSmrg	      name=$func_stripname_result
9646e07dc26bSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9647e07dc26bSmrg		case " $predeps $postdeps " in
9648e07dc26bSmrg		*" $a_deplib "*)
9649e07dc26bSmrg		  func_append newdeplibs " $a_deplib"
9650e07dc26bSmrg		  a_deplib=
9651e07dc26bSmrg		  ;;
9652e07dc26bSmrg		esac
9653e07dc26bSmrg	      fi
9654e07dc26bSmrg	      if test -n "$a_deplib"; then
9655e07dc26bSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9656e07dc26bSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9657e07dc26bSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
9658e07dc26bSmrg		  for potent_lib in $potential_libs; do
9659e07dc26bSmrg		    potlib=$potent_lib # see symlink-check above in file_magic test
9660e07dc26bSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
9661e07dc26bSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
9662e07dc26bSmrg		      func_append newdeplibs " $a_deplib"
9663e07dc26bSmrg		      a_deplib=
9664e07dc26bSmrg		      break 2
9665e07dc26bSmrg		    fi
9666e07dc26bSmrg		  done
9667e07dc26bSmrg		done
9668e07dc26bSmrg	      fi
9669e07dc26bSmrg	      if test -n "$a_deplib"; then
9670e07dc26bSmrg		droppeddeps=yes
9671e07dc26bSmrg		echo
9672e07dc26bSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9673e07dc26bSmrg		echo "*** I have the capability to make that library automatically link in when"
9674e07dc26bSmrg		echo "*** you link to this library.  But I can only do this if you have a"
9675e07dc26bSmrg		echo "*** shared version of the library, which you do not appear to have"
9676e07dc26bSmrg		echo "*** because I did check the linker path looking for a file starting"
9677e07dc26bSmrg		if test -z "$potlib"; then
9678e07dc26bSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
9679e07dc26bSmrg		else
9680e07dc26bSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9681e07dc26bSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
9682e07dc26bSmrg		fi
9683e07dc26bSmrg	      fi
9684e07dc26bSmrg	      ;;
9685e07dc26bSmrg	    *)
9686e07dc26bSmrg	      # Add a -L argument.
9687e07dc26bSmrg	      func_append newdeplibs " $a_deplib"
9688e07dc26bSmrg	      ;;
9689e07dc26bSmrg	    esac
9690e07dc26bSmrg	  done # Gone through all deplibs.
9691e07dc26bSmrg	  ;;
9692e07dc26bSmrg	none | unknown | *)
9693e07dc26bSmrg	  newdeplibs=
9694e07dc26bSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
9695e07dc26bSmrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9696e07dc26bSmrg	    for i in $predeps $postdeps; do
9697e07dc26bSmrg	      # can't use Xsed below, because $i might contain '/'
9698e07dc26bSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
9699e07dc26bSmrg	    done
9700e07dc26bSmrg	  fi
9701e07dc26bSmrg	  case $tmp_deplibs in
9702e07dc26bSmrg	  *[!\	\ ]*)
9703e07dc26bSmrg	    echo
9704e07dc26bSmrg	    if test none = "$deplibs_check_method"; then
9705e07dc26bSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
9706e07dc26bSmrg	    else
9707e07dc26bSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
9708e07dc26bSmrg	    fi
9709e07dc26bSmrg	    echo "*** All declared inter-library dependencies are being dropped."
9710e07dc26bSmrg	    droppeddeps=yes
9711e07dc26bSmrg	    ;;
9712e07dc26bSmrg	  esac
9713e07dc26bSmrg	  ;;
9714e07dc26bSmrg	esac
9715e07dc26bSmrg	versuffix=$versuffix_save
9716e07dc26bSmrg	major=$major_save
9717e07dc26bSmrg	release=$release_save
9718e07dc26bSmrg	libname=$libname_save
9719e07dc26bSmrg	name=$name_save
9720e07dc26bSmrg
9721e07dc26bSmrg	case $host in
9722e07dc26bSmrg	*-*-rhapsody* | *-*-darwin1.[012])
9723e07dc26bSmrg	  # On Rhapsody replace the C library with the System framework
9724e07dc26bSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
9725e07dc26bSmrg	  ;;
9726e07dc26bSmrg	esac
9727e07dc26bSmrg
9728e07dc26bSmrg	if test yes = "$droppeddeps"; then
9729e07dc26bSmrg	  if test yes = "$module"; then
9730e07dc26bSmrg	    echo
9731e07dc26bSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
9732e07dc26bSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
9733e07dc26bSmrg	    echo "*** a static module, that should work as long as the dlopening"
9734e07dc26bSmrg	    echo "*** application is linked with the -dlopen flag."
9735e07dc26bSmrg	    if test -z "$global_symbol_pipe"; then
9736e07dc26bSmrg	      echo
9737e07dc26bSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
9738e07dc26bSmrg	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9739e07dc26bSmrg	      echo "*** not find such a program.  So, this module is probably useless."
9740e07dc26bSmrg	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
9741e07dc26bSmrg	    fi
9742e07dc26bSmrg	    if test no = "$build_old_libs"; then
9743e07dc26bSmrg	      oldlibs=$output_objdir/$libname.$libext
9744e07dc26bSmrg	      build_libtool_libs=module
9745e07dc26bSmrg	      build_old_libs=yes
9746e07dc26bSmrg	    else
9747e07dc26bSmrg	      build_libtool_libs=no
9748e07dc26bSmrg	    fi
9749e07dc26bSmrg	  else
9750e07dc26bSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
9751e07dc26bSmrg	    echo "*** automatically added whenever a program is linked with this library"
9752e07dc26bSmrg	    echo "*** or is declared to -dlopen it."
9753e07dc26bSmrg
9754e07dc26bSmrg	    if test no = "$allow_undefined"; then
9755e07dc26bSmrg	      echo
9756e07dc26bSmrg	      echo "*** Since this library must not contain undefined symbols,"
9757e07dc26bSmrg	      echo "*** because either the platform does not support them or"
9758e07dc26bSmrg	      echo "*** it was explicitly requested with -no-undefined,"
9759e07dc26bSmrg	      echo "*** libtool will only create a static version of it."
9760e07dc26bSmrg	      if test no = "$build_old_libs"; then
9761e07dc26bSmrg		oldlibs=$output_objdir/$libname.$libext
9762e07dc26bSmrg		build_libtool_libs=module
9763e07dc26bSmrg		build_old_libs=yes
9764e07dc26bSmrg	      else
9765e07dc26bSmrg		build_libtool_libs=no
9766e07dc26bSmrg	      fi
9767e07dc26bSmrg	    fi
9768e07dc26bSmrg	  fi
9769e07dc26bSmrg	fi
9770e07dc26bSmrg	# Done checking deplibs!
9771e07dc26bSmrg	deplibs=$newdeplibs
9772e07dc26bSmrg      fi
9773e07dc26bSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9774e07dc26bSmrg      case $host in
9775e07dc26bSmrg	*-*-darwin*)
9776e07dc26bSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9777e07dc26bSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9778e07dc26bSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9779e07dc26bSmrg	  ;;
9780e07dc26bSmrg      esac
9781e07dc26bSmrg
9782e07dc26bSmrg      # move library search paths that coincide with paths to not yet
9783e07dc26bSmrg      # installed libraries to the beginning of the library search list
9784e07dc26bSmrg      new_libs=
9785e07dc26bSmrg      for path in $notinst_path; do
9786e07dc26bSmrg	case " $new_libs " in
9787e07dc26bSmrg	*" -L$path/$objdir "*) ;;
9788e07dc26bSmrg	*)
9789e07dc26bSmrg	  case " $deplibs " in
9790e07dc26bSmrg	  *" -L$path/$objdir "*)
9791e07dc26bSmrg	    func_append new_libs " -L$path/$objdir" ;;
9792e07dc26bSmrg	  esac
9793e07dc26bSmrg	  ;;
9794e07dc26bSmrg	esac
9795e07dc26bSmrg      done
9796e07dc26bSmrg      for deplib in $deplibs; do
9797e07dc26bSmrg	case $deplib in
9798e07dc26bSmrg	-L*)
9799e07dc26bSmrg	  case " $new_libs " in
9800e07dc26bSmrg	  *" $deplib "*) ;;
9801e07dc26bSmrg	  *) func_append new_libs " $deplib" ;;
9802e07dc26bSmrg	  esac
9803e07dc26bSmrg	  ;;
9804e07dc26bSmrg	*) func_append new_libs " $deplib" ;;
9805e07dc26bSmrg	esac
9806e07dc26bSmrg      done
9807e07dc26bSmrg      deplibs=$new_libs
9808e07dc26bSmrg
9809e07dc26bSmrg      # All the library-specific variables (install_libdir is set above).
9810e07dc26bSmrg      library_names=
9811e07dc26bSmrg      old_library=
9812e07dc26bSmrg      dlname=
9813e07dc26bSmrg
9814e07dc26bSmrg      # Test again, we may have decided not to build it any more
9815e07dc26bSmrg      if test yes = "$build_libtool_libs"; then
9816e07dc26bSmrg	# Remove $wl instances when linking with ld.
9817e07dc26bSmrg	# FIXME: should test the right _cmds variable.
9818e07dc26bSmrg	case $archive_cmds in
9819e07dc26bSmrg	  *\$LD\ *) wl= ;;
9820e07dc26bSmrg        esac
9821e07dc26bSmrg	if test yes = "$hardcode_into_libs"; then
9822e07dc26bSmrg	  # Hardcode the library paths
9823e07dc26bSmrg	  hardcode_libdirs=
9824e07dc26bSmrg	  dep_rpath=
9825e07dc26bSmrg	  rpath=$finalize_rpath
9826e07dc26bSmrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
9827e07dc26bSmrg	  for libdir in $rpath; do
9828e07dc26bSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
9829e07dc26bSmrg	      if test -n "$hardcode_libdir_separator"; then
9830e07dc26bSmrg		func_replace_sysroot "$libdir"
9831e07dc26bSmrg		libdir=$func_replace_sysroot_result
9832e07dc26bSmrg		if test -z "$hardcode_libdirs"; then
9833e07dc26bSmrg		  hardcode_libdirs=$libdir
9834e07dc26bSmrg		else
9835e07dc26bSmrg		  # Just accumulate the unique libdirs.
9836e07dc26bSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9837e07dc26bSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9838e07dc26bSmrg		    ;;
9839e07dc26bSmrg		  *)
9840e07dc26bSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
9841e07dc26bSmrg		    ;;
9842e07dc26bSmrg		  esac
9843e07dc26bSmrg		fi
9844e07dc26bSmrg	      else
9845e07dc26bSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
9846e07dc26bSmrg		func_append dep_rpath " $flag"
9847e07dc26bSmrg	      fi
9848e07dc26bSmrg	    elif test -n "$runpath_var"; then
9849e07dc26bSmrg	      case "$perm_rpath " in
9850e07dc26bSmrg	      *" $libdir "*) ;;
9851e07dc26bSmrg	      *) func_append perm_rpath " $libdir" ;;
9852e07dc26bSmrg	      esac
9853e07dc26bSmrg	    fi
9854e07dc26bSmrg	  done
9855e07dc26bSmrg	  # Substitute the hardcoded libdirs into the rpath.
9856e07dc26bSmrg	  if test -n "$hardcode_libdir_separator" &&
9857e07dc26bSmrg	     test -n "$hardcode_libdirs"; then
9858e07dc26bSmrg	    libdir=$hardcode_libdirs
9859e07dc26bSmrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
9860e07dc26bSmrg	  fi
9861e07dc26bSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
9862e07dc26bSmrg	    # We should set the runpath_var.
9863e07dc26bSmrg	    rpath=
9864e07dc26bSmrg	    for dir in $perm_rpath; do
9865e07dc26bSmrg	      func_append rpath "$dir:"
9866e07dc26bSmrg	    done
9867e07dc26bSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
9868e07dc26bSmrg	  fi
9869e07dc26bSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
9870e07dc26bSmrg	fi
9871e07dc26bSmrg
9872e07dc26bSmrg	shlibpath=$finalize_shlibpath
9873e07dc26bSmrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
9874e07dc26bSmrg	if test -n "$shlibpath"; then
9875e07dc26bSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
9876e07dc26bSmrg	fi
9877e07dc26bSmrg
9878e07dc26bSmrg	# Get the real and link names of the library.
9879e07dc26bSmrg	eval shared_ext=\"$shrext_cmds\"
9880e07dc26bSmrg	eval library_names=\"$library_names_spec\"
9881e07dc26bSmrg	set dummy $library_names
9882e07dc26bSmrg	shift
9883e07dc26bSmrg	realname=$1
9884e07dc26bSmrg	shift
9885e07dc26bSmrg
9886e07dc26bSmrg	if test -n "$soname_spec"; then
9887e07dc26bSmrg	  eval soname=\"$soname_spec\"
9888e07dc26bSmrg	else
9889e07dc26bSmrg	  soname=$realname
9890e07dc26bSmrg	fi
9891e07dc26bSmrg	if test -z "$dlname"; then
9892e07dc26bSmrg	  dlname=$soname
9893e07dc26bSmrg	fi
9894e07dc26bSmrg
9895e07dc26bSmrg	lib=$output_objdir/$realname
9896e07dc26bSmrg	linknames=
9897e07dc26bSmrg	for link
9898e07dc26bSmrg	do
9899e07dc26bSmrg	  func_append linknames " $link"
9900e07dc26bSmrg	done
9901e07dc26bSmrg
9902e07dc26bSmrg	# Use standard objects if they are pic
9903e07dc26bSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
9904e07dc26bSmrg	test "X$libobjs" = "X " && libobjs=
9905e07dc26bSmrg
9906e07dc26bSmrg	delfiles=
9907e07dc26bSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9908e07dc26bSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
9909e07dc26bSmrg	  export_symbols=$output_objdir/$libname.uexp
9910e07dc26bSmrg	  func_append delfiles " $export_symbols"
9911e07dc26bSmrg	fi
9912e07dc26bSmrg
9913e07dc26bSmrg	orig_export_symbols=
9914e07dc26bSmrg	case $host_os in
9915e07dc26bSmrg	cygwin* | mingw* | cegcc*)
9916e07dc26bSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
9917e07dc26bSmrg	    # exporting using user supplied symfile
9918e07dc26bSmrg	    func_dll_def_p "$export_symbols" || {
9919e07dc26bSmrg	      # and it's NOT already a .def file. Must figure out
9920e07dc26bSmrg	      # which of the given symbols are data symbols and tag
9921e07dc26bSmrg	      # them as such. So, trigger use of export_symbols_cmds.
9922e07dc26bSmrg	      # export_symbols gets reassigned inside the "prepare
9923e07dc26bSmrg	      # the list of exported symbols" if statement, so the
9924e07dc26bSmrg	      # include_expsyms logic still works.
9925e07dc26bSmrg	      orig_export_symbols=$export_symbols
9926e07dc26bSmrg	      export_symbols=
9927e07dc26bSmrg	      always_export_symbols=yes
9928e07dc26bSmrg	    }
9929e07dc26bSmrg	  fi
9930e07dc26bSmrg	  ;;
9931e07dc26bSmrg	esac
9932e07dc26bSmrg
9933e07dc26bSmrg	# Prepare the list of exported symbols
9934e07dc26bSmrg	if test -z "$export_symbols"; then
9935e07dc26bSmrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
9936e07dc26bSmrg	    func_verbose "generating symbol list for '$libname.la'"
9937e07dc26bSmrg	    export_symbols=$output_objdir/$libname.exp
9938e07dc26bSmrg	    $opt_dry_run || $RM $export_symbols
9939e07dc26bSmrg	    cmds=$export_symbols_cmds
9940e07dc26bSmrg	    save_ifs=$IFS; IFS='~'
9941e07dc26bSmrg	    for cmd1 in $cmds; do
9942e07dc26bSmrg	      IFS=$save_ifs
9943e07dc26bSmrg	      # Take the normal branch if the nm_file_list_spec branch
9944e07dc26bSmrg	      # doesn't work or if tool conversion is not needed.
9945e07dc26bSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
9946e07dc26bSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9947e07dc26bSmrg		  try_normal_branch=yes
9948e07dc26bSmrg		  eval cmd=\"$cmd1\"
9949e07dc26bSmrg		  func_len " $cmd"
9950e07dc26bSmrg		  len=$func_len_result
9951e07dc26bSmrg		  ;;
9952e07dc26bSmrg		*)
9953e07dc26bSmrg		  try_normal_branch=no
9954e07dc26bSmrg		  ;;
9955e07dc26bSmrg	      esac
9956e07dc26bSmrg	      if test yes = "$try_normal_branch" \
9957e07dc26bSmrg		 && { test "$len" -lt "$max_cmd_len" \
9958e07dc26bSmrg		      || test "$max_cmd_len" -le -1; }
9959e07dc26bSmrg	      then
9960e07dc26bSmrg		func_show_eval "$cmd" 'exit $?'
9961e07dc26bSmrg		skipped_export=false
9962e07dc26bSmrg	      elif test -n "$nm_file_list_spec"; then
9963e07dc26bSmrg		func_basename "$output"
9964e07dc26bSmrg		output_la=$func_basename_result
9965e07dc26bSmrg		save_libobjs=$libobjs
9966e07dc26bSmrg		save_output=$output
9967e07dc26bSmrg		output=$output_objdir/$output_la.nm
9968e07dc26bSmrg		func_to_tool_file "$output"
9969e07dc26bSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
9970e07dc26bSmrg		func_append delfiles " $output"
9971e07dc26bSmrg		func_verbose "creating $NM input file list: $output"
9972e07dc26bSmrg		for obj in $save_libobjs; do
9973e07dc26bSmrg		  func_to_tool_file "$obj"
9974e07dc26bSmrg		  $ECHO "$func_to_tool_file_result"
9975e07dc26bSmrg		done > "$output"
9976e07dc26bSmrg		eval cmd=\"$cmd1\"
9977e07dc26bSmrg		func_show_eval "$cmd" 'exit $?'
9978e07dc26bSmrg		output=$save_output
9979e07dc26bSmrg		libobjs=$save_libobjs
9980e07dc26bSmrg		skipped_export=false
9981e07dc26bSmrg	      else
9982e07dc26bSmrg		# The command line is too long to execute in one step.
9983e07dc26bSmrg		func_verbose "using reloadable object file for export list..."
9984e07dc26bSmrg		skipped_export=:
9985e07dc26bSmrg		# Break out early, otherwise skipped_export may be
9986e07dc26bSmrg		# set to false by a later but shorter cmd.
9987e07dc26bSmrg		break
9988e07dc26bSmrg	      fi
9989e07dc26bSmrg	    done
9990e07dc26bSmrg	    IFS=$save_ifs
9991e07dc26bSmrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
9992e07dc26bSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9993e07dc26bSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9994e07dc26bSmrg	    fi
9995e07dc26bSmrg	  fi
9996e07dc26bSmrg	fi
9997e07dc26bSmrg
9998e07dc26bSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9999e07dc26bSmrg	  tmp_export_symbols=$export_symbols
10000e07dc26bSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
10001e07dc26bSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
10002e07dc26bSmrg	fi
10003e07dc26bSmrg
10004e07dc26bSmrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
10005e07dc26bSmrg	  # The given exports_symbols file has to be filtered, so filter it.
10006e07dc26bSmrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
10007e07dc26bSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
10008e07dc26bSmrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
10009e07dc26bSmrg	  # though. Also, the filter scales superlinearly with the number of
10010e07dc26bSmrg	  # global variables. join(1) would be nice here, but unfortunately
10011e07dc26bSmrg	  # isn't a blessed tool.
10012e07dc26bSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
10013e07dc26bSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
10014e07dc26bSmrg	  export_symbols=$output_objdir/$libname.def
10015e07dc26bSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
10016e07dc26bSmrg	fi
10017e07dc26bSmrg
10018e07dc26bSmrg	tmp_deplibs=
10019e07dc26bSmrg	for test_deplib in $deplibs; do
10020e07dc26bSmrg	  case " $convenience " in
10021e07dc26bSmrg	  *" $test_deplib "*) ;;
10022e07dc26bSmrg	  *)
10023e07dc26bSmrg	    func_append tmp_deplibs " $test_deplib"
10024e07dc26bSmrg	    ;;
10025e07dc26bSmrg	  esac
10026e07dc26bSmrg	done
10027e07dc26bSmrg	deplibs=$tmp_deplibs
10028e07dc26bSmrg
10029e07dc26bSmrg	if test -n "$convenience"; then
10030e07dc26bSmrg	  if test -n "$whole_archive_flag_spec" &&
10031e07dc26bSmrg	    test yes = "$compiler_needs_object" &&
10032e07dc26bSmrg	    test -z "$libobjs"; then
10033e07dc26bSmrg	    # extract the archives, so we have objects to list.
10034e07dc26bSmrg	    # TODO: could optimize this to just extract one archive.
10035e07dc26bSmrg	    whole_archive_flag_spec=
10036e07dc26bSmrg	  fi
10037e07dc26bSmrg	  if test -n "$whole_archive_flag_spec"; then
10038e07dc26bSmrg	    save_libobjs=$libobjs
10039e07dc26bSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
10040e07dc26bSmrg	    test "X$libobjs" = "X " && libobjs=
10041e07dc26bSmrg	  else
10042e07dc26bSmrg	    gentop=$output_objdir/${outputname}x
10043e07dc26bSmrg	    func_append generated " $gentop"
10044e07dc26bSmrg
10045e07dc26bSmrg	    func_extract_archives $gentop $convenience
10046e07dc26bSmrg	    func_append libobjs " $func_extract_archives_result"
10047e07dc26bSmrg	    test "X$libobjs" = "X " && libobjs=
10048e07dc26bSmrg	  fi
10049e07dc26bSmrg	fi
10050e07dc26bSmrg
10051e07dc26bSmrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
10052e07dc26bSmrg	  eval flag=\"$thread_safe_flag_spec\"
10053e07dc26bSmrg	  func_append linker_flags " $flag"
10054e07dc26bSmrg	fi
10055e07dc26bSmrg
10056e07dc26bSmrg	# Make a backup of the uninstalled library when relinking
10057e07dc26bSmrg	if test relink = "$opt_mode"; then
10058e07dc26bSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
10059e07dc26bSmrg	fi
10060e07dc26bSmrg
10061e07dc26bSmrg	# Do each of the archive commands.
10062e07dc26bSmrg	if test yes = "$module" && test -n "$module_cmds"; then
10063e07dc26bSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
10064e07dc26bSmrg	    eval test_cmds=\"$module_expsym_cmds\"
10065e07dc26bSmrg	    cmds=$module_expsym_cmds
10066e07dc26bSmrg	  else
10067e07dc26bSmrg	    eval test_cmds=\"$module_cmds\"
10068e07dc26bSmrg	    cmds=$module_cmds
10069e07dc26bSmrg	  fi
10070e07dc26bSmrg	else
10071e07dc26bSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
10072e07dc26bSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
10073e07dc26bSmrg	    cmds=$archive_expsym_cmds
10074e07dc26bSmrg	  else
10075e07dc26bSmrg	    eval test_cmds=\"$archive_cmds\"
10076e07dc26bSmrg	    cmds=$archive_cmds
10077e07dc26bSmrg	  fi
10078e07dc26bSmrg	fi
10079e07dc26bSmrg
10080e07dc26bSmrg	if test : != "$skipped_export" &&
10081e07dc26bSmrg	   func_len " $test_cmds" &&
10082e07dc26bSmrg	   len=$func_len_result &&
10083e07dc26bSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10084e07dc26bSmrg	  :
10085e07dc26bSmrg	else
10086e07dc26bSmrg	  # The command line is too long to link in one step, link piecewise
10087e07dc26bSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
10088e07dc26bSmrg	  # script.
10089e07dc26bSmrg
10090e07dc26bSmrg	  # Save the value of $output and $libobjs because we want to
10091e07dc26bSmrg	  # use them later.  If we have whole_archive_flag_spec, we
10092e07dc26bSmrg	  # want to use save_libobjs as it was before
10093e07dc26bSmrg	  # whole_archive_flag_spec was expanded, because we can't
10094e07dc26bSmrg	  # assume the linker understands whole_archive_flag_spec.
10095e07dc26bSmrg	  # This may have to be revisited, in case too many
10096e07dc26bSmrg	  # convenience libraries get linked in and end up exceeding
10097e07dc26bSmrg	  # the spec.
10098e07dc26bSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
10099e07dc26bSmrg	    save_libobjs=$libobjs
10100e07dc26bSmrg	  fi
10101e07dc26bSmrg	  save_output=$output
10102e07dc26bSmrg	  func_basename "$output"
10103e07dc26bSmrg	  output_la=$func_basename_result
10104e07dc26bSmrg
10105e07dc26bSmrg	  # Clear the reloadable object creation command queue and
10106e07dc26bSmrg	  # initialize k to one.
10107e07dc26bSmrg	  test_cmds=
10108e07dc26bSmrg	  concat_cmds=
10109e07dc26bSmrg	  objlist=
10110e07dc26bSmrg	  last_robj=
10111e07dc26bSmrg	  k=1
10112e07dc26bSmrg
10113e07dc26bSmrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
10114e07dc26bSmrg	    output=$output_objdir/$output_la.lnkscript
10115e07dc26bSmrg	    func_verbose "creating GNU ld script: $output"
10116e07dc26bSmrg	    echo 'INPUT (' > $output
10117e07dc26bSmrg	    for obj in $save_libobjs
10118e07dc26bSmrg	    do
10119e07dc26bSmrg	      func_to_tool_file "$obj"
10120e07dc26bSmrg	      $ECHO "$func_to_tool_file_result" >> $output
10121e07dc26bSmrg	    done
10122e07dc26bSmrg	    echo ')' >> $output
10123e07dc26bSmrg	    func_append delfiles " $output"
10124e07dc26bSmrg	    func_to_tool_file "$output"
10125e07dc26bSmrg	    output=$func_to_tool_file_result
10126e07dc26bSmrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
10127e07dc26bSmrg	    output=$output_objdir/$output_la.lnk
10128e07dc26bSmrg	    func_verbose "creating linker input file list: $output"
10129e07dc26bSmrg	    : > $output
10130e07dc26bSmrg	    set x $save_libobjs
10131e07dc26bSmrg	    shift
10132e07dc26bSmrg	    firstobj=
10133e07dc26bSmrg	    if test yes = "$compiler_needs_object"; then
10134e07dc26bSmrg	      firstobj="$1 "
10135e07dc26bSmrg	      shift
10136e07dc26bSmrg	    fi
10137e07dc26bSmrg	    for obj
10138e07dc26bSmrg	    do
10139e07dc26bSmrg	      func_to_tool_file "$obj"
10140e07dc26bSmrg	      $ECHO "$func_to_tool_file_result" >> $output
10141e07dc26bSmrg	    done
10142e07dc26bSmrg	    func_append delfiles " $output"
10143e07dc26bSmrg	    func_to_tool_file "$output"
10144e07dc26bSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
10145e07dc26bSmrg	  else
10146e07dc26bSmrg	    if test -n "$save_libobjs"; then
10147e07dc26bSmrg	      func_verbose "creating reloadable object files..."
10148e07dc26bSmrg	      output=$output_objdir/$output_la-$k.$objext
10149e07dc26bSmrg	      eval test_cmds=\"$reload_cmds\"
10150e07dc26bSmrg	      func_len " $test_cmds"
10151e07dc26bSmrg	      len0=$func_len_result
10152e07dc26bSmrg	      len=$len0
10153e07dc26bSmrg
10154e07dc26bSmrg	      # Loop over the list of objects to be linked.
10155e07dc26bSmrg	      for obj in $save_libobjs
10156e07dc26bSmrg	      do
10157e07dc26bSmrg		func_len " $obj"
10158e07dc26bSmrg		func_arith $len + $func_len_result
10159e07dc26bSmrg		len=$func_arith_result
10160e07dc26bSmrg		if test -z "$objlist" ||
10161e07dc26bSmrg		   test "$len" -lt "$max_cmd_len"; then
10162e07dc26bSmrg		  func_append objlist " $obj"
10163e07dc26bSmrg		else
10164e07dc26bSmrg		  # The command $test_cmds is almost too long, add a
10165e07dc26bSmrg		  # command to the queue.
10166e07dc26bSmrg		  if test 1 -eq "$k"; then
10167e07dc26bSmrg		    # The first file doesn't have a previous command to add.
10168e07dc26bSmrg		    reload_objs=$objlist
10169e07dc26bSmrg		    eval concat_cmds=\"$reload_cmds\"
10170e07dc26bSmrg		  else
10171e07dc26bSmrg		    # All subsequent reloadable object files will link in
10172e07dc26bSmrg		    # the last one created.
10173e07dc26bSmrg		    reload_objs="$objlist $last_robj"
10174e07dc26bSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
10175e07dc26bSmrg		  fi
10176e07dc26bSmrg		  last_robj=$output_objdir/$output_la-$k.$objext
10177e07dc26bSmrg		  func_arith $k + 1
10178e07dc26bSmrg		  k=$func_arith_result
10179e07dc26bSmrg		  output=$output_objdir/$output_la-$k.$objext
10180e07dc26bSmrg		  objlist=" $obj"
10181e07dc26bSmrg		  func_len " $last_robj"
10182e07dc26bSmrg		  func_arith $len0 + $func_len_result
10183e07dc26bSmrg		  len=$func_arith_result
10184e07dc26bSmrg		fi
10185e07dc26bSmrg	      done
10186e07dc26bSmrg	      # Handle the remaining objects by creating one last
10187e07dc26bSmrg	      # reloadable object file.  All subsequent reloadable object
10188e07dc26bSmrg	      # files will link in the last one created.
10189e07dc26bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10190e07dc26bSmrg	      reload_objs="$objlist $last_robj"
10191e07dc26bSmrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
10192e07dc26bSmrg	      if test -n "$last_robj"; then
10193e07dc26bSmrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
10194e07dc26bSmrg	      fi
10195e07dc26bSmrg	      func_append delfiles " $output"
10196e07dc26bSmrg
10197e07dc26bSmrg	    else
10198e07dc26bSmrg	      output=
10199e07dc26bSmrg	    fi
10200e07dc26bSmrg
10201e07dc26bSmrg	    ${skipped_export-false} && {
10202e07dc26bSmrg	      func_verbose "generating symbol list for '$libname.la'"
10203e07dc26bSmrg	      export_symbols=$output_objdir/$libname.exp
10204e07dc26bSmrg	      $opt_dry_run || $RM $export_symbols
10205e07dc26bSmrg	      libobjs=$output
10206e07dc26bSmrg	      # Append the command to create the export file.
10207e07dc26bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10208e07dc26bSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
10209e07dc26bSmrg	      if test -n "$last_robj"; then
10210e07dc26bSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
10211e07dc26bSmrg	      fi
10212e07dc26bSmrg	    }
10213e07dc26bSmrg
10214e07dc26bSmrg	    test -n "$save_libobjs" &&
10215e07dc26bSmrg	      func_verbose "creating a temporary reloadable object file: $output"
10216e07dc26bSmrg
10217e07dc26bSmrg	    # Loop through the commands generated above and execute them.
10218e07dc26bSmrg	    save_ifs=$IFS; IFS='~'
10219e07dc26bSmrg	    for cmd in $concat_cmds; do
10220e07dc26bSmrg	      IFS=$save_ifs
10221e07dc26bSmrg	      $opt_quiet || {
10222636c353eSmrg		  func_quote_arg expand,pretty "$cmd"
10223636c353eSmrg		  eval "func_echo $func_quote_arg_result"
10224e07dc26bSmrg	      }
10225e07dc26bSmrg	      $opt_dry_run || eval "$cmd" || {
10226e07dc26bSmrg		lt_exit=$?
10227e07dc26bSmrg
10228e07dc26bSmrg		# Restore the uninstalled library and exit
10229e07dc26bSmrg		if test relink = "$opt_mode"; then
10230e07dc26bSmrg		  ( cd "$output_objdir" && \
10231e07dc26bSmrg		    $RM "${realname}T" && \
10232e07dc26bSmrg		    $MV "${realname}U" "$realname" )
10233e07dc26bSmrg		fi
10234e07dc26bSmrg
10235e07dc26bSmrg		exit $lt_exit
10236e07dc26bSmrg	      }
10237e07dc26bSmrg	    done
10238e07dc26bSmrg	    IFS=$save_ifs
10239e07dc26bSmrg
10240e07dc26bSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
10241e07dc26bSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
10242e07dc26bSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
10243e07dc26bSmrg	    fi
10244e07dc26bSmrg	  fi
10245e07dc26bSmrg
10246e07dc26bSmrg          ${skipped_export-false} && {
10247e07dc26bSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
10248e07dc26bSmrg	      tmp_export_symbols=$export_symbols
10249e07dc26bSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
10250e07dc26bSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
10251e07dc26bSmrg	    fi
10252e07dc26bSmrg
10253e07dc26bSmrg	    if test -n "$orig_export_symbols"; then
10254e07dc26bSmrg	      # The given exports_symbols file has to be filtered, so filter it.
10255e07dc26bSmrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
10256e07dc26bSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
10257e07dc26bSmrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
10258e07dc26bSmrg	      # though. Also, the filter scales superlinearly with the number of
10259e07dc26bSmrg	      # global variables. join(1) would be nice here, but unfortunately
10260e07dc26bSmrg	      # isn't a blessed tool.
10261e07dc26bSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
10262e07dc26bSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
10263e07dc26bSmrg	      export_symbols=$output_objdir/$libname.def
10264e07dc26bSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
10265e07dc26bSmrg	    fi
10266e07dc26bSmrg	  }
10267e07dc26bSmrg
10268e07dc26bSmrg	  libobjs=$output
10269e07dc26bSmrg	  # Restore the value of output.
10270e07dc26bSmrg	  output=$save_output
10271e07dc26bSmrg
10272e07dc26bSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
10273e07dc26bSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
10274e07dc26bSmrg	    test "X$libobjs" = "X " && libobjs=
10275e07dc26bSmrg	  fi
10276e07dc26bSmrg	  # Expand the library linking commands again to reset the
10277e07dc26bSmrg	  # value of $libobjs for piecewise linking.
10278e07dc26bSmrg
10279e07dc26bSmrg	  # Do each of the archive commands.
10280e07dc26bSmrg	  if test yes = "$module" && test -n "$module_cmds"; then
10281e07dc26bSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
10282e07dc26bSmrg	      cmds=$module_expsym_cmds
10283e07dc26bSmrg	    else
10284e07dc26bSmrg	      cmds=$module_cmds
10285e07dc26bSmrg	    fi
10286e07dc26bSmrg	  else
10287e07dc26bSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
10288e07dc26bSmrg	      cmds=$archive_expsym_cmds
10289e07dc26bSmrg	    else
10290e07dc26bSmrg	      cmds=$archive_cmds
10291e07dc26bSmrg	    fi
10292e07dc26bSmrg	  fi
10293e07dc26bSmrg	fi
10294e07dc26bSmrg
10295e07dc26bSmrg	if test -n "$delfiles"; then
10296e07dc26bSmrg	  # Append the command to remove temporary files to $cmds.
10297e07dc26bSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
10298e07dc26bSmrg	fi
10299e07dc26bSmrg
10300e07dc26bSmrg	# Add any objects from preloaded convenience libraries
10301e07dc26bSmrg	if test -n "$dlprefiles"; then
10302e07dc26bSmrg	  gentop=$output_objdir/${outputname}x
10303e07dc26bSmrg	  func_append generated " $gentop"
10304e07dc26bSmrg
10305e07dc26bSmrg	  func_extract_archives $gentop $dlprefiles
10306e07dc26bSmrg	  func_append libobjs " $func_extract_archives_result"
10307e07dc26bSmrg	  test "X$libobjs" = "X " && libobjs=
10308e07dc26bSmrg	fi
10309e07dc26bSmrg
10310e07dc26bSmrg	save_ifs=$IFS; IFS='~'
10311e07dc26bSmrg	for cmd in $cmds; do
10312e07dc26bSmrg	  IFS=$sp$nl
10313e07dc26bSmrg	  eval cmd=\"$cmd\"
10314e07dc26bSmrg	  IFS=$save_ifs
10315e07dc26bSmrg	  $opt_quiet || {
10316636c353eSmrg	    func_quote_arg expand,pretty "$cmd"
10317636c353eSmrg	    eval "func_echo $func_quote_arg_result"
10318e07dc26bSmrg	  }
10319e07dc26bSmrg	  $opt_dry_run || eval "$cmd" || {
10320e07dc26bSmrg	    lt_exit=$?
10321e07dc26bSmrg
10322e07dc26bSmrg	    # Restore the uninstalled library and exit
10323e07dc26bSmrg	    if test relink = "$opt_mode"; then
10324e07dc26bSmrg	      ( cd "$output_objdir" && \
10325e07dc26bSmrg	        $RM "${realname}T" && \
10326e07dc26bSmrg		$MV "${realname}U" "$realname" )
10327e07dc26bSmrg	    fi
10328e07dc26bSmrg
10329e07dc26bSmrg	    exit $lt_exit
10330e07dc26bSmrg	  }
10331e07dc26bSmrg	done
10332e07dc26bSmrg	IFS=$save_ifs
10333e07dc26bSmrg
10334e07dc26bSmrg	# Restore the uninstalled library and exit
10335e07dc26bSmrg	if test relink = "$opt_mode"; then
10336e07dc26bSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
10337e07dc26bSmrg
10338e07dc26bSmrg	  if test -n "$convenience"; then
10339e07dc26bSmrg	    if test -z "$whole_archive_flag_spec"; then
10340e07dc26bSmrg	      func_show_eval '${RM}r "$gentop"'
10341e07dc26bSmrg	    fi
10342e07dc26bSmrg	  fi
10343e07dc26bSmrg
10344e07dc26bSmrg	  exit $EXIT_SUCCESS
10345e07dc26bSmrg	fi
10346e07dc26bSmrg
10347e07dc26bSmrg	# Create links to the real library.
10348e07dc26bSmrg	for linkname in $linknames; do
10349e07dc26bSmrg	  if test "$realname" != "$linkname"; then
10350e07dc26bSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
10351e07dc26bSmrg	  fi
10352e07dc26bSmrg	done
10353e07dc26bSmrg
10354e07dc26bSmrg	# If -module or -export-dynamic was specified, set the dlname.
10355e07dc26bSmrg	if test yes = "$module" || test yes = "$export_dynamic"; then
10356e07dc26bSmrg	  # On all known operating systems, these are identical.
10357e07dc26bSmrg	  dlname=$soname
10358e07dc26bSmrg	fi
10359e07dc26bSmrg      fi
10360e07dc26bSmrg      ;;
10361e07dc26bSmrg
10362e07dc26bSmrg    obj)
10363e07dc26bSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
10364e07dc26bSmrg	func_warning "'-dlopen' is ignored for objects"
10365e07dc26bSmrg      fi
10366e07dc26bSmrg
10367e07dc26bSmrg      case " $deplibs" in
10368e07dc26bSmrg      *\ -l* | *\ -L*)
10369e07dc26bSmrg	func_warning "'-l' and '-L' are ignored for objects" ;;
10370e07dc26bSmrg      esac
10371e07dc26bSmrg
10372e07dc26bSmrg      test -n "$rpath" && \
10373e07dc26bSmrg	func_warning "'-rpath' is ignored for objects"
10374e07dc26bSmrg
10375e07dc26bSmrg      test -n "$xrpath" && \
10376e07dc26bSmrg	func_warning "'-R' is ignored for objects"
10377e07dc26bSmrg
10378e07dc26bSmrg      test -n "$vinfo" && \
10379e07dc26bSmrg	func_warning "'-version-info' is ignored for objects"
10380e07dc26bSmrg
10381e07dc26bSmrg      test -n "$release" && \
10382e07dc26bSmrg	func_warning "'-release' is ignored for objects"
10383e07dc26bSmrg
10384e07dc26bSmrg      case $output in
10385e07dc26bSmrg      *.lo)
10386e07dc26bSmrg	test -n "$objs$old_deplibs" && \
10387e07dc26bSmrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
10388e07dc26bSmrg
10389e07dc26bSmrg	libobj=$output
10390e07dc26bSmrg	func_lo2o "$libobj"
10391e07dc26bSmrg	obj=$func_lo2o_result
10392e07dc26bSmrg	;;
10393e07dc26bSmrg      *)
10394e07dc26bSmrg	libobj=
10395e07dc26bSmrg	obj=$output
10396e07dc26bSmrg	;;
10397e07dc26bSmrg      esac
10398e07dc26bSmrg
10399e07dc26bSmrg      # Delete the old objects.
10400e07dc26bSmrg      $opt_dry_run || $RM $obj $libobj
10401e07dc26bSmrg
10402e07dc26bSmrg      # Objects from convenience libraries.  This assumes
10403e07dc26bSmrg      # single-version convenience libraries.  Whenever we create
10404e07dc26bSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
10405e07dc26bSmrg      # the extraction.
10406e07dc26bSmrg      reload_conv_objs=
10407e07dc26bSmrg      gentop=
10408e07dc26bSmrg      # if reload_cmds runs $LD directly, get rid of -Wl from
10409e07dc26bSmrg      # whole_archive_flag_spec and hope we can get by with turning comma
10410e07dc26bSmrg      # into space.
10411e07dc26bSmrg      case $reload_cmds in
10412e07dc26bSmrg        *\$LD[\ \$]*) wl= ;;
10413e07dc26bSmrg      esac
10414e07dc26bSmrg      if test -n "$convenience"; then
10415e07dc26bSmrg	if test -n "$whole_archive_flag_spec"; then
10416e07dc26bSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
10417e07dc26bSmrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
10418e07dc26bSmrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
10419e07dc26bSmrg	else
10420e07dc26bSmrg	  gentop=$output_objdir/${obj}x
10421e07dc26bSmrg	  func_append generated " $gentop"
10422e07dc26bSmrg
10423e07dc26bSmrg	  func_extract_archives $gentop $convenience
10424e07dc26bSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
10425e07dc26bSmrg	fi
10426e07dc26bSmrg      fi
10427e07dc26bSmrg
10428e07dc26bSmrg      # If we're not building shared, we need to use non_pic_objs
10429e07dc26bSmrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10430e07dc26bSmrg
10431e07dc26bSmrg      # Create the old-style object.
10432e07dc26bSmrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10433e07dc26bSmrg
10434e07dc26bSmrg      output=$obj
10435e07dc26bSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
10436e07dc26bSmrg
10437e07dc26bSmrg      # Exit if we aren't doing a library object file.
10438e07dc26bSmrg      if test -z "$libobj"; then
10439e07dc26bSmrg	if test -n "$gentop"; then
10440e07dc26bSmrg	  func_show_eval '${RM}r "$gentop"'
10441e07dc26bSmrg	fi
10442e07dc26bSmrg
10443e07dc26bSmrg	exit $EXIT_SUCCESS
10444e07dc26bSmrg      fi
10445e07dc26bSmrg
10446e07dc26bSmrg      test yes = "$build_libtool_libs" || {
10447e07dc26bSmrg	if test -n "$gentop"; then
10448e07dc26bSmrg	  func_show_eval '${RM}r "$gentop"'
10449e07dc26bSmrg	fi
10450e07dc26bSmrg
10451e07dc26bSmrg	# Create an invalid libtool object if no PIC, so that we don't
10452e07dc26bSmrg	# accidentally link it into a program.
10453e07dc26bSmrg	# $show "echo timestamp > $libobj"
10454e07dc26bSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
10455e07dc26bSmrg	exit $EXIT_SUCCESS
10456e07dc26bSmrg      }
10457e07dc26bSmrg
10458e07dc26bSmrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
10459e07dc26bSmrg	# Only do commands if we really have different PIC objects.
10460e07dc26bSmrg	reload_objs="$libobjs $reload_conv_objs"
10461e07dc26bSmrg	output=$libobj
10462e07dc26bSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
10463e07dc26bSmrg      fi
10464e07dc26bSmrg
10465e07dc26bSmrg      if test -n "$gentop"; then
10466e07dc26bSmrg	func_show_eval '${RM}r "$gentop"'
10467e07dc26bSmrg      fi
10468e07dc26bSmrg
10469e07dc26bSmrg      exit $EXIT_SUCCESS
10470e07dc26bSmrg      ;;
10471e07dc26bSmrg
10472e07dc26bSmrg    prog)
10473e07dc26bSmrg      case $host in
10474e07dc26bSmrg	*cygwin*) func_stripname '' '.exe' "$output"
10475e07dc26bSmrg	          output=$func_stripname_result.exe;;
10476e07dc26bSmrg      esac
10477e07dc26bSmrg      test -n "$vinfo" && \
10478e07dc26bSmrg	func_warning "'-version-info' is ignored for programs"
10479e07dc26bSmrg
10480e07dc26bSmrg      test -n "$release" && \
10481e07dc26bSmrg	func_warning "'-release' is ignored for programs"
10482e07dc26bSmrg
10483e07dc26bSmrg      $preload \
10484e07dc26bSmrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
10485e07dc26bSmrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
10486e07dc26bSmrg
10487e07dc26bSmrg      case $host in
10488e07dc26bSmrg      *-*-rhapsody* | *-*-darwin1.[012])
10489e07dc26bSmrg	# On Rhapsody replace the C library is the System framework
10490e07dc26bSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10491e07dc26bSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10492e07dc26bSmrg	;;
10493e07dc26bSmrg      esac
10494e07dc26bSmrg
10495e07dc26bSmrg      case $host in
10496e07dc26bSmrg      *-*-darwin*)
10497e07dc26bSmrg	# Don't allow lazy linking, it breaks C++ global constructors
10498e07dc26bSmrg	# But is supposedly fixed on 10.4 or later (yay!).
10499e07dc26bSmrg	if test CXX = "$tagname"; then
10500e07dc26bSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10501e07dc26bSmrg	    10.[0123])
10502e07dc26bSmrg	      func_append compile_command " $wl-bind_at_load"
10503e07dc26bSmrg	      func_append finalize_command " $wl-bind_at_load"
10504e07dc26bSmrg	    ;;
10505e07dc26bSmrg	  esac
10506e07dc26bSmrg	fi
10507e07dc26bSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
10508e07dc26bSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10509e07dc26bSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10510e07dc26bSmrg	;;
10511e07dc26bSmrg      esac
10512e07dc26bSmrg
10513e07dc26bSmrg
10514e07dc26bSmrg      # move library search paths that coincide with paths to not yet
10515e07dc26bSmrg      # installed libraries to the beginning of the library search list
10516e07dc26bSmrg      new_libs=
10517e07dc26bSmrg      for path in $notinst_path; do
10518e07dc26bSmrg	case " $new_libs " in
10519e07dc26bSmrg	*" -L$path/$objdir "*) ;;
10520e07dc26bSmrg	*)
10521e07dc26bSmrg	  case " $compile_deplibs " in
10522e07dc26bSmrg	  *" -L$path/$objdir "*)
10523e07dc26bSmrg	    func_append new_libs " -L$path/$objdir" ;;
10524e07dc26bSmrg	  esac
10525e07dc26bSmrg	  ;;
10526e07dc26bSmrg	esac
10527e07dc26bSmrg      done
10528e07dc26bSmrg      for deplib in $compile_deplibs; do
10529e07dc26bSmrg	case $deplib in
10530e07dc26bSmrg	-L*)
10531e07dc26bSmrg	  case " $new_libs " in
10532e07dc26bSmrg	  *" $deplib "*) ;;
10533e07dc26bSmrg	  *) func_append new_libs " $deplib" ;;
10534e07dc26bSmrg	  esac
10535e07dc26bSmrg	  ;;
10536e07dc26bSmrg	*) func_append new_libs " $deplib" ;;
10537e07dc26bSmrg	esac
10538e07dc26bSmrg      done
10539e07dc26bSmrg      compile_deplibs=$new_libs
10540e07dc26bSmrg
10541e07dc26bSmrg
10542e07dc26bSmrg      func_append compile_command " $compile_deplibs"
10543e07dc26bSmrg      func_append finalize_command " $finalize_deplibs"
10544e07dc26bSmrg
10545e07dc26bSmrg      if test -n "$rpath$xrpath"; then
10546e07dc26bSmrg	# If the user specified any rpath flags, then add them.
10547e07dc26bSmrg	for libdir in $rpath $xrpath; do
10548e07dc26bSmrg	  # This is the magic to use -rpath.
10549e07dc26bSmrg	  case "$finalize_rpath " in
10550e07dc26bSmrg	  *" $libdir "*) ;;
10551e07dc26bSmrg	  *) func_append finalize_rpath " $libdir" ;;
10552e07dc26bSmrg	  esac
10553e07dc26bSmrg	done
10554e07dc26bSmrg      fi
10555e07dc26bSmrg
10556e07dc26bSmrg      # Now hardcode the library paths
10557e07dc26bSmrg      rpath=
10558e07dc26bSmrg      hardcode_libdirs=
10559e07dc26bSmrg      for libdir in $compile_rpath $finalize_rpath; do
10560e07dc26bSmrg	if test -n "$hardcode_libdir_flag_spec"; then
10561e07dc26bSmrg	  if test -n "$hardcode_libdir_separator"; then
10562e07dc26bSmrg	    if test -z "$hardcode_libdirs"; then
10563e07dc26bSmrg	      hardcode_libdirs=$libdir
10564e07dc26bSmrg	    else
10565e07dc26bSmrg	      # Just accumulate the unique libdirs.
10566e07dc26bSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10567e07dc26bSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10568e07dc26bSmrg		;;
10569e07dc26bSmrg	      *)
10570e07dc26bSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10571e07dc26bSmrg		;;
10572e07dc26bSmrg	      esac
10573e07dc26bSmrg	    fi
10574e07dc26bSmrg	  else
10575e07dc26bSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10576e07dc26bSmrg	    func_append rpath " $flag"
10577e07dc26bSmrg	  fi
10578e07dc26bSmrg	elif test -n "$runpath_var"; then
10579e07dc26bSmrg	  case "$perm_rpath " in
10580e07dc26bSmrg	  *" $libdir "*) ;;
10581e07dc26bSmrg	  *) func_append perm_rpath " $libdir" ;;
10582e07dc26bSmrg	  esac
10583e07dc26bSmrg	fi
10584e07dc26bSmrg	case $host in
10585e07dc26bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
10586e07dc26bSmrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
10587e07dc26bSmrg	  case :$dllsearchpath: in
10588e07dc26bSmrg	  *":$libdir:"*) ;;
10589e07dc26bSmrg	  ::) dllsearchpath=$libdir;;
10590e07dc26bSmrg	  *) func_append dllsearchpath ":$libdir";;
10591e07dc26bSmrg	  esac
10592e07dc26bSmrg	  case :$dllsearchpath: in
10593e07dc26bSmrg	  *":$testbindir:"*) ;;
10594e07dc26bSmrg	  ::) dllsearchpath=$testbindir;;
10595e07dc26bSmrg	  *) func_append dllsearchpath ":$testbindir";;
10596e07dc26bSmrg	  esac
10597e07dc26bSmrg	  ;;
10598e07dc26bSmrg	esac
10599e07dc26bSmrg      done
10600e07dc26bSmrg      # Substitute the hardcoded libdirs into the rpath.
10601e07dc26bSmrg      if test -n "$hardcode_libdir_separator" &&
10602e07dc26bSmrg	 test -n "$hardcode_libdirs"; then
10603e07dc26bSmrg	libdir=$hardcode_libdirs
10604e07dc26bSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
10605e07dc26bSmrg      fi
10606e07dc26bSmrg      compile_rpath=$rpath
10607e07dc26bSmrg
10608e07dc26bSmrg      rpath=
10609e07dc26bSmrg      hardcode_libdirs=
10610e07dc26bSmrg      for libdir in $finalize_rpath; do
10611e07dc26bSmrg	if test -n "$hardcode_libdir_flag_spec"; then
10612e07dc26bSmrg	  if test -n "$hardcode_libdir_separator"; then
10613e07dc26bSmrg	    if test -z "$hardcode_libdirs"; then
10614e07dc26bSmrg	      hardcode_libdirs=$libdir
10615e07dc26bSmrg	    else
10616e07dc26bSmrg	      # Just accumulate the unique libdirs.
10617e07dc26bSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10618e07dc26bSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10619e07dc26bSmrg		;;
10620e07dc26bSmrg	      *)
10621e07dc26bSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10622e07dc26bSmrg		;;
10623e07dc26bSmrg	      esac
10624e07dc26bSmrg	    fi
10625e07dc26bSmrg	  else
10626e07dc26bSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10627e07dc26bSmrg	    func_append rpath " $flag"
10628e07dc26bSmrg	  fi
10629e07dc26bSmrg	elif test -n "$runpath_var"; then
10630e07dc26bSmrg	  case "$finalize_perm_rpath " in
10631e07dc26bSmrg	  *" $libdir "*) ;;
10632e07dc26bSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
10633e07dc26bSmrg	  esac
10634e07dc26bSmrg	fi
10635e07dc26bSmrg      done
10636e07dc26bSmrg      # Substitute the hardcoded libdirs into the rpath.
10637e07dc26bSmrg      if test -n "$hardcode_libdir_separator" &&
10638e07dc26bSmrg	 test -n "$hardcode_libdirs"; then
10639e07dc26bSmrg	libdir=$hardcode_libdirs
10640e07dc26bSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
10641e07dc26bSmrg      fi
10642e07dc26bSmrg      finalize_rpath=$rpath
10643e07dc26bSmrg
10644e07dc26bSmrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
10645e07dc26bSmrg	# Transform all the library objects into standard objects.
10646e07dc26bSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10647e07dc26bSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10648e07dc26bSmrg      fi
10649e07dc26bSmrg
10650e07dc26bSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
10651e07dc26bSmrg
10652e07dc26bSmrg      # template prelinking step
10653e07dc26bSmrg      if test -n "$prelink_cmds"; then
10654e07dc26bSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
10655e07dc26bSmrg      fi
10656e07dc26bSmrg
10657e07dc26bSmrg      wrappers_required=:
10658e07dc26bSmrg      case $host in
10659e07dc26bSmrg      *cegcc* | *mingw32ce*)
10660e07dc26bSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
10661e07dc26bSmrg        wrappers_required=false
10662e07dc26bSmrg        ;;
10663e07dc26bSmrg      *cygwin* | *mingw* )
10664e07dc26bSmrg        test yes = "$build_libtool_libs" || wrappers_required=false
10665e07dc26bSmrg        ;;
10666e07dc26bSmrg      *)
10667e07dc26bSmrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
10668e07dc26bSmrg          wrappers_required=false
10669e07dc26bSmrg        fi
10670e07dc26bSmrg        ;;
10671e07dc26bSmrg      esac
10672e07dc26bSmrg      $wrappers_required || {
10673e07dc26bSmrg	# Replace the output file specification.
10674e07dc26bSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10675e07dc26bSmrg	link_command=$compile_command$compile_rpath
10676e07dc26bSmrg
10677e07dc26bSmrg	# We have no uninstalled library dependencies, so finalize right now.
10678e07dc26bSmrg	exit_status=0
10679e07dc26bSmrg	func_show_eval "$link_command" 'exit_status=$?'
10680e07dc26bSmrg
10681e07dc26bSmrg	if test -n "$postlink_cmds"; then
10682e07dc26bSmrg	  func_to_tool_file "$output"
10683e07dc26bSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10684e07dc26bSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10685e07dc26bSmrg	fi
10686e07dc26bSmrg
10687e07dc26bSmrg	# Delete the generated files.
10688e07dc26bSmrg	if test -f "$output_objdir/${outputname}S.$objext"; then
10689e07dc26bSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
10690e07dc26bSmrg	fi
10691e07dc26bSmrg
10692e07dc26bSmrg	exit $exit_status
10693e07dc26bSmrg      }
10694e07dc26bSmrg
10695e07dc26bSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
10696e07dc26bSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
10697e07dc26bSmrg      fi
10698e07dc26bSmrg      if test -n "$finalize_shlibpath"; then
10699e07dc26bSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
10700e07dc26bSmrg      fi
10701e07dc26bSmrg
10702e07dc26bSmrg      compile_var=
10703e07dc26bSmrg      finalize_var=
10704e07dc26bSmrg      if test -n "$runpath_var"; then
10705e07dc26bSmrg	if test -n "$perm_rpath"; then
10706e07dc26bSmrg	  # We should set the runpath_var.
10707e07dc26bSmrg	  rpath=
10708e07dc26bSmrg	  for dir in $perm_rpath; do
10709e07dc26bSmrg	    func_append rpath "$dir:"
10710e07dc26bSmrg	  done
10711e07dc26bSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10712e07dc26bSmrg	fi
10713e07dc26bSmrg	if test -n "$finalize_perm_rpath"; then
10714e07dc26bSmrg	  # We should set the runpath_var.
10715e07dc26bSmrg	  rpath=
10716e07dc26bSmrg	  for dir in $finalize_perm_rpath; do
10717e07dc26bSmrg	    func_append rpath "$dir:"
10718e07dc26bSmrg	  done
10719e07dc26bSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
10720e07dc26bSmrg	fi
10721e07dc26bSmrg      fi
10722e07dc26bSmrg
10723e07dc26bSmrg      if test yes = "$no_install"; then
10724e07dc26bSmrg	# We don't need to create a wrapper script.
10725e07dc26bSmrg	link_command=$compile_var$compile_command$compile_rpath
10726e07dc26bSmrg	# Replace the output file specification.
10727e07dc26bSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10728e07dc26bSmrg	# Delete the old output file.
10729e07dc26bSmrg	$opt_dry_run || $RM $output
10730e07dc26bSmrg	# Link the executable and exit
10731e07dc26bSmrg	func_show_eval "$link_command" 'exit $?'
10732e07dc26bSmrg
10733e07dc26bSmrg	if test -n "$postlink_cmds"; then
10734e07dc26bSmrg	  func_to_tool_file "$output"
10735e07dc26bSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10736e07dc26bSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10737e07dc26bSmrg	fi
10738e07dc26bSmrg
10739e07dc26bSmrg	exit $EXIT_SUCCESS
10740e07dc26bSmrg      fi
10741e07dc26bSmrg
10742e07dc26bSmrg      case $hardcode_action,$fast_install in
10743e07dc26bSmrg        relink,*)
10744e07dc26bSmrg	  # Fast installation is not supported
10745e07dc26bSmrg	  link_command=$compile_var$compile_command$compile_rpath
10746e07dc26bSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10747e07dc26bSmrg
10748e07dc26bSmrg	  func_warning "this platform does not like uninstalled shared libraries"
10749e07dc26bSmrg	  func_warning "'$output' will be relinked during installation"
10750e07dc26bSmrg	  ;;
10751e07dc26bSmrg        *,yes)
10752e07dc26bSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
10753e07dc26bSmrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
10754e07dc26bSmrg          ;;
10755e07dc26bSmrg	*,no)
10756e07dc26bSmrg	  link_command=$compile_var$compile_command$compile_rpath
10757e07dc26bSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10758e07dc26bSmrg          ;;
10759e07dc26bSmrg	*,needless)
10760e07dc26bSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
10761e07dc26bSmrg	  relink_command=
10762e07dc26bSmrg          ;;
10763e07dc26bSmrg      esac
10764e07dc26bSmrg
10765e07dc26bSmrg      # Replace the output file specification.
10766e07dc26bSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10767e07dc26bSmrg
10768e07dc26bSmrg      # Delete the old output files.
10769e07dc26bSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10770e07dc26bSmrg
10771e07dc26bSmrg      func_show_eval "$link_command" 'exit $?'
10772e07dc26bSmrg
10773e07dc26bSmrg      if test -n "$postlink_cmds"; then
10774e07dc26bSmrg	func_to_tool_file "$output_objdir/$outputname"
10775e07dc26bSmrg	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'`
10776e07dc26bSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
10777e07dc26bSmrg      fi
10778e07dc26bSmrg
10779e07dc26bSmrg      # Now create the wrapper script.
10780e07dc26bSmrg      func_verbose "creating $output"
10781e07dc26bSmrg
10782e07dc26bSmrg      # Quote the relink command for shipping.
10783e07dc26bSmrg      if test -n "$relink_command"; then
10784e07dc26bSmrg	# Preserve any variables that may affect compiler behavior
10785e07dc26bSmrg	for var in $variables_saved_for_relink; do
10786e07dc26bSmrg	  if eval test -z \"\${$var+set}\"; then
10787e07dc26bSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10788e07dc26bSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
10789e07dc26bSmrg	    relink_command="$var=; export $var; $relink_command"
10790e07dc26bSmrg	  else
10791636c353eSmrg	    func_quote_arg pretty "$var_value"
10792636c353eSmrg	    relink_command="$var=$func_quote_arg_result; export $var; $relink_command"
10793e07dc26bSmrg	  fi
10794e07dc26bSmrg	done
10795636c353eSmrg	func_quote eval cd "`pwd`"
10796636c353eSmrg	func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)"
10797636c353eSmrg	relink_command=$func_quote_arg_unquoted_result
10798e07dc26bSmrg      fi
10799e07dc26bSmrg
10800e07dc26bSmrg      # Only actually do things if not in dry run mode.
10801e07dc26bSmrg      $opt_dry_run || {
10802e07dc26bSmrg	# win32 will think the script is a binary if it has
10803e07dc26bSmrg	# a .exe suffix, so we strip it off here.
10804e07dc26bSmrg	case $output in
10805e07dc26bSmrg	  *.exe) func_stripname '' '.exe' "$output"
10806e07dc26bSmrg	         output=$func_stripname_result ;;
10807e07dc26bSmrg	esac
10808e07dc26bSmrg	# test for cygwin because mv fails w/o .exe extensions
10809e07dc26bSmrg	case $host in
10810e07dc26bSmrg	  *cygwin*)
10811e07dc26bSmrg	    exeext=.exe
10812e07dc26bSmrg	    func_stripname '' '.exe' "$outputname"
10813e07dc26bSmrg	    outputname=$func_stripname_result ;;
10814e07dc26bSmrg	  *) exeext= ;;
10815e07dc26bSmrg	esac
10816e07dc26bSmrg	case $host in
10817e07dc26bSmrg	  *cygwin* | *mingw* )
10818e07dc26bSmrg	    func_dirname_and_basename "$output" "" "."
10819e07dc26bSmrg	    output_name=$func_basename_result
10820e07dc26bSmrg	    output_path=$func_dirname_result
10821e07dc26bSmrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
10822e07dc26bSmrg	    cwrapper=$output_path/$output_name.exe
10823e07dc26bSmrg	    $RM $cwrappersource $cwrapper
10824e07dc26bSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
10825e07dc26bSmrg
10826e07dc26bSmrg	    func_emit_cwrapperexe_src > $cwrappersource
10827e07dc26bSmrg
10828e07dc26bSmrg	    # The wrapper executable is built using the $host compiler,
10829e07dc26bSmrg	    # because it contains $host paths and files. If cross-
10830e07dc26bSmrg	    # compiling, it, like the target executable, must be
10831e07dc26bSmrg	    # executed on the $host or under an emulation environment.
10832e07dc26bSmrg	    $opt_dry_run || {
10833e07dc26bSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
10834e07dc26bSmrg	      $STRIP $cwrapper
10835e07dc26bSmrg	    }
10836e07dc26bSmrg
10837e07dc26bSmrg	    # Now, create the wrapper script for func_source use:
10838e07dc26bSmrg	    func_ltwrapper_scriptname $cwrapper
10839e07dc26bSmrg	    $RM $func_ltwrapper_scriptname_result
10840e07dc26bSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
10841e07dc26bSmrg	    $opt_dry_run || {
10842e07dc26bSmrg	      # note: this script will not be executed, so do not chmod.
10843e07dc26bSmrg	      if test "x$build" = "x$host"; then
10844e07dc26bSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10845e07dc26bSmrg	      else
10846e07dc26bSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
10847e07dc26bSmrg	      fi
10848e07dc26bSmrg	    }
10849e07dc26bSmrg	  ;;
10850e07dc26bSmrg	  * )
10851e07dc26bSmrg	    $RM $output
10852e07dc26bSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10853e07dc26bSmrg
10854e07dc26bSmrg	    func_emit_wrapper no > $output
10855e07dc26bSmrg	    chmod +x $output
10856e07dc26bSmrg	  ;;
10857e07dc26bSmrg	esac
10858e07dc26bSmrg      }
10859e07dc26bSmrg      exit $EXIT_SUCCESS
10860e07dc26bSmrg      ;;
10861e07dc26bSmrg    esac
10862e07dc26bSmrg
10863e07dc26bSmrg    # See if we need to build an old-fashioned archive.
10864e07dc26bSmrg    for oldlib in $oldlibs; do
10865e07dc26bSmrg
10866e07dc26bSmrg      case $build_libtool_libs in
10867e07dc26bSmrg        convenience)
10868e07dc26bSmrg	  oldobjs="$libobjs_save $symfileobj"
10869e07dc26bSmrg	  addlibs=$convenience
10870e07dc26bSmrg	  build_libtool_libs=no
10871e07dc26bSmrg	  ;;
10872e07dc26bSmrg	module)
10873e07dc26bSmrg	  oldobjs=$libobjs_save
10874e07dc26bSmrg	  addlibs=$old_convenience
10875e07dc26bSmrg	  build_libtool_libs=no
10876e07dc26bSmrg          ;;
10877e07dc26bSmrg	*)
10878e07dc26bSmrg	  oldobjs="$old_deplibs $non_pic_objects"
10879e07dc26bSmrg	  $preload && test -f "$symfileobj" \
10880e07dc26bSmrg	    && func_append oldobjs " $symfileobj"
10881e07dc26bSmrg	  addlibs=$old_convenience
10882e07dc26bSmrg	  ;;
10883e07dc26bSmrg      esac
10884e07dc26bSmrg
10885e07dc26bSmrg      if test -n "$addlibs"; then
10886e07dc26bSmrg	gentop=$output_objdir/${outputname}x
10887e07dc26bSmrg	func_append generated " $gentop"
10888e07dc26bSmrg
10889e07dc26bSmrg	func_extract_archives $gentop $addlibs
10890e07dc26bSmrg	func_append oldobjs " $func_extract_archives_result"
10891e07dc26bSmrg      fi
10892e07dc26bSmrg
10893e07dc26bSmrg      # Do each command in the archive commands.
10894e07dc26bSmrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
10895e07dc26bSmrg	cmds=$old_archive_from_new_cmds
10896e07dc26bSmrg      else
10897e07dc26bSmrg
10898e07dc26bSmrg	# Add any objects from preloaded convenience libraries
10899e07dc26bSmrg	if test -n "$dlprefiles"; then
10900e07dc26bSmrg	  gentop=$output_objdir/${outputname}x
10901e07dc26bSmrg	  func_append generated " $gentop"
10902e07dc26bSmrg
10903e07dc26bSmrg	  func_extract_archives $gentop $dlprefiles
10904e07dc26bSmrg	  func_append oldobjs " $func_extract_archives_result"
10905e07dc26bSmrg	fi
10906e07dc26bSmrg
10907e07dc26bSmrg	# POSIX demands no paths to be encoded in archives.  We have
10908e07dc26bSmrg	# to avoid creating archives with duplicate basenames if we
10909e07dc26bSmrg	# might have to extract them afterwards, e.g., when creating a
10910e07dc26bSmrg	# static archive out of a convenience library, or when linking
10911e07dc26bSmrg	# the entirety of a libtool archive into another (currently
10912e07dc26bSmrg	# not supported by libtool).
10913e07dc26bSmrg	if (for obj in $oldobjs
10914e07dc26bSmrg	    do
10915e07dc26bSmrg	      func_basename "$obj"
10916e07dc26bSmrg	      $ECHO "$func_basename_result"
10917e07dc26bSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
10918e07dc26bSmrg	  :
10919e07dc26bSmrg	else
10920e07dc26bSmrg	  echo "copying selected object files to avoid basename conflicts..."
10921e07dc26bSmrg	  gentop=$output_objdir/${outputname}x
10922e07dc26bSmrg	  func_append generated " $gentop"
10923e07dc26bSmrg	  func_mkdir_p "$gentop"
10924e07dc26bSmrg	  save_oldobjs=$oldobjs
10925e07dc26bSmrg	  oldobjs=
10926e07dc26bSmrg	  counter=1
10927e07dc26bSmrg	  for obj in $save_oldobjs
10928e07dc26bSmrg	  do
10929e07dc26bSmrg	    func_basename "$obj"
10930e07dc26bSmrg	    objbase=$func_basename_result
10931e07dc26bSmrg	    case " $oldobjs " in
10932e07dc26bSmrg	    " ") oldobjs=$obj ;;
10933e07dc26bSmrg	    *[\ /]"$objbase "*)
10934e07dc26bSmrg	      while :; do
10935e07dc26bSmrg		# Make sure we don't pick an alternate name that also
10936e07dc26bSmrg		# overlaps.
10937e07dc26bSmrg		newobj=lt$counter-$objbase
10938e07dc26bSmrg		func_arith $counter + 1
10939e07dc26bSmrg		counter=$func_arith_result
10940e07dc26bSmrg		case " $oldobjs " in
10941e07dc26bSmrg		*[\ /]"$newobj "*) ;;
10942e07dc26bSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
10943e07dc26bSmrg		esac
10944e07dc26bSmrg	      done
10945e07dc26bSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10946e07dc26bSmrg	      func_append oldobjs " $gentop/$newobj"
10947e07dc26bSmrg	      ;;
10948e07dc26bSmrg	    *) func_append oldobjs " $obj" ;;
10949e07dc26bSmrg	    esac
10950e07dc26bSmrg	  done
10951e07dc26bSmrg	fi
10952e07dc26bSmrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10953e07dc26bSmrg	tool_oldlib=$func_to_tool_file_result
10954e07dc26bSmrg	eval cmds=\"$old_archive_cmds\"
10955e07dc26bSmrg
10956e07dc26bSmrg	func_len " $cmds"
10957e07dc26bSmrg	len=$func_len_result
10958e07dc26bSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10959e07dc26bSmrg	  cmds=$old_archive_cmds
10960e07dc26bSmrg	elif test -n "$archiver_list_spec"; then
10961e07dc26bSmrg	  func_verbose "using command file archive linking..."
10962e07dc26bSmrg	  for obj in $oldobjs
10963e07dc26bSmrg	  do
10964e07dc26bSmrg	    func_to_tool_file "$obj"
10965e07dc26bSmrg	    $ECHO "$func_to_tool_file_result"
10966e07dc26bSmrg	  done > $output_objdir/$libname.libcmd
10967e07dc26bSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
10968e07dc26bSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10969e07dc26bSmrg	  cmds=$old_archive_cmds
10970e07dc26bSmrg	else
10971e07dc26bSmrg	  # the command line is too long to link in one step, link in parts
10972e07dc26bSmrg	  func_verbose "using piecewise archive linking..."
10973e07dc26bSmrg	  save_RANLIB=$RANLIB
10974e07dc26bSmrg	  RANLIB=:
10975e07dc26bSmrg	  objlist=
10976e07dc26bSmrg	  concat_cmds=
10977e07dc26bSmrg	  save_oldobjs=$oldobjs
10978e07dc26bSmrg	  oldobjs=
10979e07dc26bSmrg	  # Is there a better way of finding the last object in the list?
10980e07dc26bSmrg	  for obj in $save_oldobjs
10981e07dc26bSmrg	  do
10982e07dc26bSmrg	    last_oldobj=$obj
10983e07dc26bSmrg	  done
10984e07dc26bSmrg	  eval test_cmds=\"$old_archive_cmds\"
10985e07dc26bSmrg	  func_len " $test_cmds"
10986e07dc26bSmrg	  len0=$func_len_result
10987e07dc26bSmrg	  len=$len0
10988e07dc26bSmrg	  for obj in $save_oldobjs
10989e07dc26bSmrg	  do
10990e07dc26bSmrg	    func_len " $obj"
10991e07dc26bSmrg	    func_arith $len + $func_len_result
10992e07dc26bSmrg	    len=$func_arith_result
10993e07dc26bSmrg	    func_append objlist " $obj"
10994e07dc26bSmrg	    if test "$len" -lt "$max_cmd_len"; then
10995e07dc26bSmrg	      :
10996e07dc26bSmrg	    else
10997e07dc26bSmrg	      # the above command should be used before it gets too long
10998e07dc26bSmrg	      oldobjs=$objlist
10999e07dc26bSmrg	      if test "$obj" = "$last_oldobj"; then
11000e07dc26bSmrg		RANLIB=$save_RANLIB
11001e07dc26bSmrg	      fi
11002e07dc26bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
11003e07dc26bSmrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
11004e07dc26bSmrg	      objlist=
11005e07dc26bSmrg	      len=$len0
11006e07dc26bSmrg	    fi
11007e07dc26bSmrg	  done
11008e07dc26bSmrg	  RANLIB=$save_RANLIB
11009e07dc26bSmrg	  oldobjs=$objlist
11010e07dc26bSmrg	  if test -z "$oldobjs"; then
11011e07dc26bSmrg	    eval cmds=\"\$concat_cmds\"
11012e07dc26bSmrg	  else
11013e07dc26bSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
11014e07dc26bSmrg	  fi
11015e07dc26bSmrg	fi
11016e07dc26bSmrg      fi
11017e07dc26bSmrg      func_execute_cmds "$cmds" 'exit $?'
11018e07dc26bSmrg    done
11019e07dc26bSmrg
11020e07dc26bSmrg    test -n "$generated" && \
11021e07dc26bSmrg      func_show_eval "${RM}r$generated"
11022e07dc26bSmrg
11023e07dc26bSmrg    # Now create the libtool archive.
11024e07dc26bSmrg    case $output in
11025e07dc26bSmrg    *.la)
11026e07dc26bSmrg      old_library=
11027e07dc26bSmrg      test yes = "$build_old_libs" && old_library=$libname.$libext
11028e07dc26bSmrg      func_verbose "creating $output"
11029e07dc26bSmrg
11030e07dc26bSmrg      # Preserve any variables that may affect compiler behavior
11031e07dc26bSmrg      for var in $variables_saved_for_relink; do
11032e07dc26bSmrg	if eval test -z \"\${$var+set}\"; then
11033e07dc26bSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
11034e07dc26bSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
11035e07dc26bSmrg	  relink_command="$var=; export $var; $relink_command"
11036e07dc26bSmrg	else
11037636c353eSmrg	  func_quote_arg pretty,unquoted "$var_value"
11038636c353eSmrg	  relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command"
11039e07dc26bSmrg	fi
11040e07dc26bSmrg      done
11041e07dc26bSmrg      # Quote the link command for shipping.
11042636c353eSmrg      func_quote eval cd "`pwd`"
11043636c353eSmrg      relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
11044636c353eSmrg      func_quote_arg pretty,unquoted "$relink_command"
11045636c353eSmrg      relink_command=$func_quote_arg_unquoted_result
11046e07dc26bSmrg      if test yes = "$hardcode_automatic"; then
11047e07dc26bSmrg	relink_command=
11048e07dc26bSmrg      fi
11049e07dc26bSmrg
11050e07dc26bSmrg      # Only create the output if not a dry run.
11051e07dc26bSmrg      $opt_dry_run || {
11052e07dc26bSmrg	for installed in no yes; do
11053e07dc26bSmrg	  if test yes = "$installed"; then
11054e07dc26bSmrg	    if test -z "$install_libdir"; then
11055e07dc26bSmrg	      break
11056e07dc26bSmrg	    fi
11057e07dc26bSmrg	    output=$output_objdir/${outputname}i
11058e07dc26bSmrg	    # Replace all uninstalled libtool libraries with the installed ones
11059e07dc26bSmrg	    newdependency_libs=
11060e07dc26bSmrg	    for deplib in $dependency_libs; do
11061e07dc26bSmrg	      case $deplib in
11062e07dc26bSmrg	      *.la)
11063e07dc26bSmrg		func_basename "$deplib"
11064e07dc26bSmrg		name=$func_basename_result
11065e07dc26bSmrg		func_resolve_sysroot "$deplib"
11066e07dc26bSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
11067e07dc26bSmrg		test -z "$libdir" && \
11068e07dc26bSmrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
11069e07dc26bSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
11070e07dc26bSmrg		;;
11071e07dc26bSmrg	      -L*)
11072e07dc26bSmrg		func_stripname -L '' "$deplib"
11073e07dc26bSmrg		func_replace_sysroot "$func_stripname_result"
11074e07dc26bSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
11075e07dc26bSmrg		;;
11076e07dc26bSmrg	      -R*)
11077e07dc26bSmrg		func_stripname -R '' "$deplib"
11078e07dc26bSmrg		func_replace_sysroot "$func_stripname_result"
11079e07dc26bSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
11080e07dc26bSmrg		;;
11081e07dc26bSmrg	      *) func_append newdependency_libs " $deplib" ;;
11082e07dc26bSmrg	      esac
11083e07dc26bSmrg	    done
11084e07dc26bSmrg	    dependency_libs=$newdependency_libs
11085e07dc26bSmrg	    newdlfiles=
11086e07dc26bSmrg
11087e07dc26bSmrg	    for lib in $dlfiles; do
11088e07dc26bSmrg	      case $lib in
11089e07dc26bSmrg	      *.la)
11090e07dc26bSmrg	        func_basename "$lib"
11091e07dc26bSmrg		name=$func_basename_result
11092e07dc26bSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
11093e07dc26bSmrg		test -z "$libdir" && \
11094e07dc26bSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
11095e07dc26bSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
11096e07dc26bSmrg		;;
11097e07dc26bSmrg	      *) func_append newdlfiles " $lib" ;;
11098e07dc26bSmrg	      esac
11099e07dc26bSmrg	    done
11100e07dc26bSmrg	    dlfiles=$newdlfiles
11101e07dc26bSmrg	    newdlprefiles=
11102e07dc26bSmrg	    for lib in $dlprefiles; do
11103e07dc26bSmrg	      case $lib in
11104e07dc26bSmrg	      *.la)
11105e07dc26bSmrg		# Only pass preopened files to the pseudo-archive (for
11106e07dc26bSmrg		# eventual linking with the app. that links it) if we
11107e07dc26bSmrg		# didn't already link the preopened objects directly into
11108e07dc26bSmrg		# the library:
11109e07dc26bSmrg		func_basename "$lib"
11110e07dc26bSmrg		name=$func_basename_result
11111e07dc26bSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
11112e07dc26bSmrg		test -z "$libdir" && \
11113e07dc26bSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
11114e07dc26bSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
11115e07dc26bSmrg		;;
11116e07dc26bSmrg	      esac
11117e07dc26bSmrg	    done
11118e07dc26bSmrg	    dlprefiles=$newdlprefiles
11119e07dc26bSmrg	  else
11120e07dc26bSmrg	    newdlfiles=
11121e07dc26bSmrg	    for lib in $dlfiles; do
11122e07dc26bSmrg	      case $lib in
11123e07dc26bSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
11124e07dc26bSmrg		*) abs=`pwd`"/$lib" ;;
11125e07dc26bSmrg	      esac
11126e07dc26bSmrg	      func_append newdlfiles " $abs"
11127e07dc26bSmrg	    done
11128e07dc26bSmrg	    dlfiles=$newdlfiles
11129e07dc26bSmrg	    newdlprefiles=
11130e07dc26bSmrg	    for lib in $dlprefiles; do
11131e07dc26bSmrg	      case $lib in
11132e07dc26bSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
11133e07dc26bSmrg		*) abs=`pwd`"/$lib" ;;
11134e07dc26bSmrg	      esac
11135e07dc26bSmrg	      func_append newdlprefiles " $abs"
11136e07dc26bSmrg	    done
11137e07dc26bSmrg	    dlprefiles=$newdlprefiles
11138e07dc26bSmrg	  fi
11139e07dc26bSmrg	  $RM $output
11140e07dc26bSmrg	  # place dlname in correct position for cygwin
11141e07dc26bSmrg	  # In fact, it would be nice if we could use this code for all target
11142e07dc26bSmrg	  # systems that can't hard-code library paths into their executables
11143e07dc26bSmrg	  # and that have no shared library path variable independent of PATH,
11144e07dc26bSmrg	  # but it turns out we can't easily determine that from inspecting
11145e07dc26bSmrg	  # libtool variables, so we have to hard-code the OSs to which it
11146e07dc26bSmrg	  # applies here; at the moment, that means platforms that use the PE
11147e07dc26bSmrg	  # object format with DLL files.  See the long comment at the top of
11148e07dc26bSmrg	  # tests/bindir.at for full details.
11149e07dc26bSmrg	  tdlname=$dlname
11150e07dc26bSmrg	  case $host,$output,$installed,$module,$dlname in
11151e07dc26bSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
11152e07dc26bSmrg	      # If a -bindir argument was supplied, place the dll there.
11153e07dc26bSmrg	      if test -n "$bindir"; then
11154e07dc26bSmrg		func_relative_path "$install_libdir" "$bindir"
11155e07dc26bSmrg		tdlname=$func_relative_path_result/$dlname
11156e07dc26bSmrg	      else
11157e07dc26bSmrg		# Otherwise fall back on heuristic.
11158e07dc26bSmrg		tdlname=../bin/$dlname
11159e07dc26bSmrg	      fi
11160e07dc26bSmrg	      ;;
11161e07dc26bSmrg	  esac
11162e07dc26bSmrg	  $ECHO > $output "\
11163e07dc26bSmrg# $outputname - a libtool library file
11164e07dc26bSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
11165e07dc26bSmrg#
11166e07dc26bSmrg# Please DO NOT delete this file!
11167e07dc26bSmrg# It is necessary for linking the library.
11168e07dc26bSmrg
11169e07dc26bSmrg# The name that we can dlopen(3).
11170e07dc26bSmrgdlname='$tdlname'
11171e07dc26bSmrg
11172e07dc26bSmrg# Names of this library.
11173e07dc26bSmrglibrary_names='$library_names'
11174e07dc26bSmrg
11175e07dc26bSmrg# The name of the static archive.
11176e07dc26bSmrgold_library='$old_library'
11177e07dc26bSmrg
11178e07dc26bSmrg# Linker flags that cannot go in dependency_libs.
11179e07dc26bSmrginherited_linker_flags='$new_inherited_linker_flags'
11180e07dc26bSmrg
11181e07dc26bSmrg# Libraries that this one depends upon.
11182e07dc26bSmrgdependency_libs='$dependency_libs'
11183e07dc26bSmrg
11184e07dc26bSmrg# Names of additional weak libraries provided by this library
11185e07dc26bSmrgweak_library_names='$weak_libs'
11186e07dc26bSmrg
11187e07dc26bSmrg# Version information for $libname.
11188e07dc26bSmrgcurrent=$current
11189e07dc26bSmrgage=$age
11190e07dc26bSmrgrevision=$revision
11191e07dc26bSmrg
11192e07dc26bSmrg# Is this an already installed library?
11193e07dc26bSmrginstalled=$installed
11194e07dc26bSmrg
11195e07dc26bSmrg# Should we warn about portability when linking against -modules?
11196e07dc26bSmrgshouldnotlink=$module
11197e07dc26bSmrg
11198e07dc26bSmrg# Files to dlopen/dlpreopen
11199e07dc26bSmrgdlopen='$dlfiles'
11200e07dc26bSmrgdlpreopen='$dlprefiles'
11201e07dc26bSmrg
11202e07dc26bSmrg# Directory that this library needs to be installed in:
11203e07dc26bSmrglibdir='$install_libdir'"
11204e07dc26bSmrg	  if test no,yes = "$installed,$need_relink"; then
11205e07dc26bSmrg	    $ECHO >> $output "\
11206e07dc26bSmrgrelink_command=\"$relink_command\""
11207e07dc26bSmrg	  fi
11208e07dc26bSmrg	done
11209e07dc26bSmrg      }
11210e07dc26bSmrg
11211e07dc26bSmrg      # Do a symbolic link so that the libtool archive can be found in
11212e07dc26bSmrg      # LD_LIBRARY_PATH before the program is installed.
11213e07dc26bSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
11214e07dc26bSmrg      ;;
11215e07dc26bSmrg    esac
11216e07dc26bSmrg    exit $EXIT_SUCCESS
11217e07dc26bSmrg}
11218e07dc26bSmrg
11219e07dc26bSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
11220e07dc26bSmrg  func_mode_link ${1+"$@"}
11221e07dc26bSmrgfi
11222e07dc26bSmrg
11223e07dc26bSmrg
11224e07dc26bSmrg# func_mode_uninstall arg...
11225e07dc26bSmrgfunc_mode_uninstall ()
11226e07dc26bSmrg{
11227e07dc26bSmrg    $debug_cmd
11228e07dc26bSmrg
11229e07dc26bSmrg    RM=$nonopt
11230e07dc26bSmrg    files=
11231e07dc26bSmrg    rmforce=false
11232e07dc26bSmrg    exit_status=0
11233e07dc26bSmrg
11234e07dc26bSmrg    # This variable tells wrapper scripts just to set variables rather
11235e07dc26bSmrg    # than running their programs.
11236e07dc26bSmrg    libtool_install_magic=$magic
11237e07dc26bSmrg
11238e07dc26bSmrg    for arg
11239e07dc26bSmrg    do
11240e07dc26bSmrg      case $arg in
11241e07dc26bSmrg      -f) func_append RM " $arg"; rmforce=: ;;
11242e07dc26bSmrg      -*) func_append RM " $arg" ;;
11243e07dc26bSmrg      *) func_append files " $arg" ;;
11244e07dc26bSmrg      esac
11245e07dc26bSmrg    done
11246e07dc26bSmrg
11247e07dc26bSmrg    test -z "$RM" && \
11248e07dc26bSmrg      func_fatal_help "you must specify an RM program"
11249e07dc26bSmrg
11250e07dc26bSmrg    rmdirs=
11251e07dc26bSmrg
11252e07dc26bSmrg    for file in $files; do
11253e07dc26bSmrg      func_dirname "$file" "" "."
11254e07dc26bSmrg      dir=$func_dirname_result
11255e07dc26bSmrg      if test . = "$dir"; then
11256e07dc26bSmrg	odir=$objdir
11257e07dc26bSmrg      else
11258e07dc26bSmrg	odir=$dir/$objdir
11259e07dc26bSmrg      fi
11260e07dc26bSmrg      func_basename "$file"
11261e07dc26bSmrg      name=$func_basename_result
11262e07dc26bSmrg      test uninstall = "$opt_mode" && odir=$dir
11263e07dc26bSmrg
11264e07dc26bSmrg      # Remember odir for removal later, being careful to avoid duplicates
11265e07dc26bSmrg      if test clean = "$opt_mode"; then
11266e07dc26bSmrg	case " $rmdirs " in
11267e07dc26bSmrg	  *" $odir "*) ;;
11268e07dc26bSmrg	  *) func_append rmdirs " $odir" ;;
11269e07dc26bSmrg	esac
11270e07dc26bSmrg      fi
11271e07dc26bSmrg
11272e07dc26bSmrg      # Don't error if the file doesn't exist and rm -f was used.
11273e07dc26bSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
11274e07dc26bSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
11275e07dc26bSmrg	 test -f "$file"; then
11276e07dc26bSmrg	:
11277e07dc26bSmrg      elif test -d "$file"; then
11278e07dc26bSmrg	exit_status=1
11279e07dc26bSmrg	continue
11280e07dc26bSmrg      elif $rmforce; then
11281e07dc26bSmrg	continue
11282e07dc26bSmrg      fi
11283e07dc26bSmrg
11284e07dc26bSmrg      rmfiles=$file
11285e07dc26bSmrg
11286e07dc26bSmrg      case $name in
11287e07dc26bSmrg      *.la)
11288e07dc26bSmrg	# Possibly a libtool archive, so verify it.
11289e07dc26bSmrg	if func_lalib_p "$file"; then
11290e07dc26bSmrg	  func_source $dir/$name
11291e07dc26bSmrg
11292e07dc26bSmrg	  # Delete the libtool libraries and symlinks.
11293e07dc26bSmrg	  for n in $library_names; do
11294e07dc26bSmrg	    func_append rmfiles " $odir/$n"
11295e07dc26bSmrg	  done
11296e07dc26bSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
11297e07dc26bSmrg
11298e07dc26bSmrg	  case $opt_mode in
11299e07dc26bSmrg	  clean)
11300e07dc26bSmrg	    case " $library_names " in
11301e07dc26bSmrg	    *" $dlname "*) ;;
11302e07dc26bSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
11303e07dc26bSmrg	    esac
11304e07dc26bSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
11305e07dc26bSmrg	    ;;
11306e07dc26bSmrg	  uninstall)
11307e07dc26bSmrg	    if test -n "$library_names"; then
11308e07dc26bSmrg	      # Do each command in the postuninstall commands.
11309e07dc26bSmrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
11310e07dc26bSmrg	    fi
11311e07dc26bSmrg
11312e07dc26bSmrg	    if test -n "$old_library"; then
11313e07dc26bSmrg	      # Do each command in the old_postuninstall commands.
11314e07dc26bSmrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
11315e07dc26bSmrg	    fi
11316e07dc26bSmrg	    # FIXME: should reinstall the best remaining shared library.
11317e07dc26bSmrg	    ;;
11318e07dc26bSmrg	  esac
11319e07dc26bSmrg	fi
11320e07dc26bSmrg	;;
11321e07dc26bSmrg
11322e07dc26bSmrg      *.lo)
11323e07dc26bSmrg	# Possibly a libtool object, so verify it.
11324e07dc26bSmrg	if func_lalib_p "$file"; then
11325e07dc26bSmrg
11326e07dc26bSmrg	  # Read the .lo file
11327e07dc26bSmrg	  func_source $dir/$name
11328e07dc26bSmrg
11329e07dc26bSmrg	  # Add PIC object to the list of files to remove.
11330e07dc26bSmrg	  if test -n "$pic_object" && test none != "$pic_object"; then
11331e07dc26bSmrg	    func_append rmfiles " $dir/$pic_object"
11332e07dc26bSmrg	  fi
11333e07dc26bSmrg
11334e07dc26bSmrg	  # Add non-PIC object to the list of files to remove.
11335e07dc26bSmrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11336e07dc26bSmrg	    func_append rmfiles " $dir/$non_pic_object"
11337e07dc26bSmrg	  fi
11338e07dc26bSmrg	fi
11339e07dc26bSmrg	;;
11340e07dc26bSmrg
11341e07dc26bSmrg      *)
11342e07dc26bSmrg	if test clean = "$opt_mode"; then
11343e07dc26bSmrg	  noexename=$name
11344e07dc26bSmrg	  case $file in
11345e07dc26bSmrg	  *.exe)
11346e07dc26bSmrg	    func_stripname '' '.exe' "$file"
11347e07dc26bSmrg	    file=$func_stripname_result
11348e07dc26bSmrg	    func_stripname '' '.exe' "$name"
11349e07dc26bSmrg	    noexename=$func_stripname_result
11350e07dc26bSmrg	    # $file with .exe has already been added to rmfiles,
11351e07dc26bSmrg	    # add $file without .exe
11352e07dc26bSmrg	    func_append rmfiles " $file"
11353e07dc26bSmrg	    ;;
11354e07dc26bSmrg	  esac
11355e07dc26bSmrg	  # Do a test to see if this is a libtool program.
11356e07dc26bSmrg	  if func_ltwrapper_p "$file"; then
11357e07dc26bSmrg	    if func_ltwrapper_executable_p "$file"; then
11358e07dc26bSmrg	      func_ltwrapper_scriptname "$file"
11359e07dc26bSmrg	      relink_command=
11360e07dc26bSmrg	      func_source $func_ltwrapper_scriptname_result
11361e07dc26bSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
11362e07dc26bSmrg	    else
11363e07dc26bSmrg	      relink_command=
11364e07dc26bSmrg	      func_source $dir/$noexename
11365e07dc26bSmrg	    fi
11366e07dc26bSmrg
11367e07dc26bSmrg	    # note $name still contains .exe if it was in $file originally
11368e07dc26bSmrg	    # as does the version of $file that was added into $rmfiles
11369e07dc26bSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
11370e07dc26bSmrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
11371e07dc26bSmrg	      func_append rmfiles " $odir/lt-$name"
11372e07dc26bSmrg	    fi
11373e07dc26bSmrg	    if test "X$noexename" != "X$name"; then
11374e07dc26bSmrg	      func_append rmfiles " $odir/lt-$noexename.c"
11375e07dc26bSmrg	    fi
11376e07dc26bSmrg	  fi
11377e07dc26bSmrg	fi
11378e07dc26bSmrg	;;
11379e07dc26bSmrg      esac
11380e07dc26bSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
11381e07dc26bSmrg    done
11382e07dc26bSmrg
11383e07dc26bSmrg    # Try to remove the $objdir's in the directories where we deleted files
11384e07dc26bSmrg    for dir in $rmdirs; do
11385e07dc26bSmrg      if test -d "$dir"; then
11386e07dc26bSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
11387e07dc26bSmrg      fi
11388e07dc26bSmrg    done
11389e07dc26bSmrg
11390e07dc26bSmrg    exit $exit_status
11391e07dc26bSmrg}
11392e07dc26bSmrg
11393e07dc26bSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
11394e07dc26bSmrg  func_mode_uninstall ${1+"$@"}
11395e07dc26bSmrgfi
11396e07dc26bSmrg
11397e07dc26bSmrgtest -z "$opt_mode" && {
11398e07dc26bSmrg  help=$generic_help
11399e07dc26bSmrg  func_fatal_help "you must specify a MODE"
11400e07dc26bSmrg}
11401e07dc26bSmrg
11402e07dc26bSmrgtest -z "$exec_cmd" && \
11403e07dc26bSmrg  func_fatal_help "invalid operation mode '$opt_mode'"
11404e07dc26bSmrg
11405e07dc26bSmrgif test -n "$exec_cmd"; then
11406e07dc26bSmrg  eval exec "$exec_cmd"
11407e07dc26bSmrg  exit $EXIT_FAILURE
11408e07dc26bSmrgfi
11409e07dc26bSmrg
11410e07dc26bSmrgexit $exit_status
11411e07dc26bSmrg
11412e07dc26bSmrg
11413e07dc26bSmrg# The TAGs below are defined such that we never get into a situation
11414e07dc26bSmrg# where we disable both kinds of libraries.  Given conflicting
11415e07dc26bSmrg# choices, we go for a static library, that is the most portable,
11416e07dc26bSmrg# since we can't tell whether shared libraries were disabled because
11417e07dc26bSmrg# the user asked for that or because the platform doesn't support
11418e07dc26bSmrg# them.  This is particularly important on AIX, because we don't
11419e07dc26bSmrg# support having both static and shared libraries enabled at the same
11420e07dc26bSmrg# time on that platform, so we default to a shared-only configuration.
11421e07dc26bSmrg# If a disable-shared tag is given, we'll fallback to a static-only
11422e07dc26bSmrg# configuration.  But we'll never go from static-only to shared-only.
11423e07dc26bSmrg
11424e07dc26bSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
11425e07dc26bSmrgbuild_libtool_libs=no
11426e07dc26bSmrgbuild_old_libs=yes
11427e07dc26bSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
11428e07dc26bSmrg
11429e07dc26bSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
11430e07dc26bSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11431e07dc26bSmrg# ### END LIBTOOL TAG CONFIG: disable-static
11432e07dc26bSmrg
11433e07dc26bSmrg# Local Variables:
11434e07dc26bSmrg# mode:shell-script
11435e07dc26bSmrg# sh-indentation:2
11436e07dc26bSmrg# End:
11437