1348980Sdes#! /bin/sh
2348980Sdes## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
3348980Sdes##               by inline-source v2014-01-03.01
4228692Sdes
5348980Sdes# libtool (GNU libtool) 2.4.6
6348980Sdes# Provide generalized library-building support services.
7228692Sdes# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8228692Sdes
9348980Sdes# Copyright (C) 1996-2015 Free Software Foundation, Inc.
10228692Sdes# This is free software; see the source for copying conditions.  There is NO
11228692Sdes# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12228692Sdes
13228692Sdes# GNU Libtool is free software; you can redistribute it and/or modify
14117610Sdes# it under the terms of the GNU General Public License as published by
15117610Sdes# the Free Software Foundation; either version 2 of the License, or
16117610Sdes# (at your option) any later version.
17117610Sdes#
18228692Sdes# As a special exception to the GNU General Public License,
19228692Sdes# if you distribute this file as part of a program or library that
20228692Sdes# is built using GNU Libtool, you may include this file under the
21228692Sdes# same distribution terms that you use for the rest of that program.
22228692Sdes#
23228692Sdes# GNU Libtool is distributed in the hope that it will be useful, but
24117610Sdes# WITHOUT ANY WARRANTY; without even the implied warranty of
25117610Sdes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26117610Sdes# General Public License for more details.
27117610Sdes#
28117610Sdes# You should have received a copy of the GNU General Public License
29348980Sdes# along with this program.  If not, see <http://www.gnu.org/licenses/>.
30228692Sdes
31117610Sdes
32228692SdesPROGRAM=libtool
33141098SdesPACKAGE=libtool
34348980SdesVERSION=2.4.6
35348980Sdespackage_revision=2.4.6
36141098Sdes
37348980Sdes
38348980Sdes## ------ ##
39348980Sdes## Usage. ##
40348980Sdes## ------ ##
41348980Sdes
42348980Sdes# Run './libtool --help' for help with using this script from the
43348980Sdes# command line.
44348980Sdes
45348980Sdes
46348980Sdes## ------------------------------- ##
47348980Sdes## User overridable command paths. ##
48348980Sdes## ------------------------------- ##
49348980Sdes
50348980Sdes# After configure completes, it has a better idea of some of the
51348980Sdes# shell tools we need than the defaults used by the functions shared
52348980Sdes# with bootstrap, so set those here where they can still be over-
53348980Sdes# ridden by the user, but otherwise take precedence.
54348980Sdes
55348980Sdes: ${AUTOCONF="autoconf"}
56348980Sdes: ${AUTOMAKE="automake"}
57348980Sdes
58348980Sdes
59348980Sdes## -------------------------- ##
60348980Sdes## Source external libraries. ##
61348980Sdes## -------------------------- ##
62348980Sdes
63348980Sdes# Much of our low-level functionality needs to be sourced from external
64348980Sdes# libraries, which are installed to $pkgauxdir.
65348980Sdes
66348980Sdes# Set a version string for this script.
67348980Sdesscriptversion=2015-01-20.17; # UTC
68348980Sdes
69348980Sdes# General shell script boiler plate, and helper functions.
70348980Sdes# Written by Gary V. Vaughan, 2004
71348980Sdes
72348980Sdes# Copyright (C) 2004-2015 Free Software Foundation, Inc.
73348980Sdes# This is free software; see the source for copying conditions.  There is NO
74348980Sdes# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
75348980Sdes
76348980Sdes# This program is free software; you can redistribute it and/or modify
77348980Sdes# it under the terms of the GNU General Public License as published by
78348980Sdes# the Free Software Foundation; either version 3 of the License, or
79348980Sdes# (at your option) any later version.
80348980Sdes
81348980Sdes# As a special exception to the GNU General Public License, if you distribute
82348980Sdes# this file as part of a program or library that is built using GNU Libtool,
83348980Sdes# you may include this file under the same distribution terms that you use
84348980Sdes# for the rest of that program.
85348980Sdes
86348980Sdes# This program is distributed in the hope that it will be useful,
87348980Sdes# but WITHOUT ANY WARRANTY; without even the implied warranty of
88348980Sdes# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
89348980Sdes# General Public License for more details.
90348980Sdes
91348980Sdes# You should have received a copy of the GNU General Public License
92348980Sdes# along with this program. If not, see <http://www.gnu.org/licenses/>.
93348980Sdes
94348980Sdes# Please report bugs or propose patches to gary@gnu.org.
95348980Sdes
96348980Sdes
97348980Sdes## ------ ##
98348980Sdes## Usage. ##
99348980Sdes## ------ ##
100348980Sdes
101348980Sdes# Evaluate this file near the top of your script to gain access to
102348980Sdes# the functions and variables defined here:
103348980Sdes#
104348980Sdes#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
105348980Sdes#
106348980Sdes# If you need to override any of the default environment variable
107348980Sdes# settings, do that before evaluating this file.
108348980Sdes
109348980Sdes
110348980Sdes## -------------------- ##
111348980Sdes## Shell normalisation. ##
112348980Sdes## -------------------- ##
113348980Sdes
114348980Sdes# Some shells need a little help to be as Bourne compatible as possible.
115348980Sdes# Before doing anything else, make sure all that help has been provided!
116348980Sdes
117348980SdesDUALCASE=1; export DUALCASE # for MKS sh
118348980Sdesif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
119174832Sdes  emulate sh
120174832Sdes  NULLCMD=:
121348980Sdes  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
122174832Sdes  # is contrary to our usage.  Disable this feature.
123174832Sdes  alias -g '${1+"$@"}'='"$@"'
124141098Sdes  setopt NO_GLOB_SUBST
125174832Sdeselse
126348980Sdes  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
127141098Sdesfi
128141098Sdes
129348980Sdes# NLS nuisances: We save the old values in case they are required later.
130348980Sdes_G_user_locale=
131348980Sdes_G_safe_locale=
132348980Sdesfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
133174832Sdesdo
134348980Sdes  eval "if test set = \"\${$_G_var+set}\"; then
135348980Sdes          save_$_G_var=\$$_G_var
136348980Sdes          $_G_var=C
137348980Sdes	  export $_G_var
138348980Sdes	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
139348980Sdes	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
140174832Sdes	fi"
141174832Sdesdone
142117610Sdes
143348980Sdes# CDPATH.
144348980Sdes(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
145228692Sdes
146348980Sdes# Make sure IFS has a sensible default
147348980Sdessp=' '
148348980Sdesnl='
149348980Sdes'
150348980SdesIFS="$sp	$nl"
151228692Sdes
152348980Sdes# There are apparently some retarded systems that use ';' as a PATH separator!
153348980Sdesif test "${PATH_SEPARATOR+set}" != set; then
154348980Sdes  PATH_SEPARATOR=:
155348980Sdes  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
156348980Sdes    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
157348980Sdes      PATH_SEPARATOR=';'
158348980Sdes  }
159348980Sdesfi
160228692Sdes
161228692Sdes
162228692Sdes
163348980Sdes## ------------------------- ##
164348980Sdes## Locate command utilities. ##
165348980Sdes## ------------------------- ##
166348980Sdes
167348980Sdes
168348980Sdes# func_executable_p FILE
169348980Sdes# ----------------------
170348980Sdes# Check that FILE is an executable regular file.
171348980Sdesfunc_executable_p ()
172348980Sdes{
173348980Sdes    test -f "$1" && test -x "$1"
174348980Sdes}
175348980Sdes
176348980Sdes
177348980Sdes# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
178348980Sdes# --------------------------------------------
179348980Sdes# Search for either a program that responds to --version with output
180348980Sdes# containing "GNU", or else returned by CHECK_FUNC otherwise, by
181348980Sdes# trying all the directories in PATH with each of the elements of
182348980Sdes# PROGS_LIST.
183348980Sdes#
184348980Sdes# CHECK_FUNC should accept the path to a candidate program, and
185348980Sdes# set $func_check_prog_result if it truncates its output less than
186348980Sdes# $_G_path_prog_max characters.
187348980Sdesfunc_path_progs ()
188348980Sdes{
189348980Sdes    _G_progs_list=$1
190348980Sdes    _G_check_func=$2
191348980Sdes    _G_PATH=${3-"$PATH"}
192348980Sdes
193348980Sdes    _G_path_prog_max=0
194348980Sdes    _G_path_prog_found=false
195348980Sdes    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
196348980Sdes    for _G_dir in $_G_PATH; do
197348980Sdes      IFS=$_G_save_IFS
198348980Sdes      test -z "$_G_dir" && _G_dir=.
199348980Sdes      for _G_prog_name in $_G_progs_list; do
200348980Sdes        for _exeext in '' .EXE; do
201348980Sdes          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
202348980Sdes          func_executable_p "$_G_path_prog" || continue
203348980Sdes          case `"$_G_path_prog" --version 2>&1` in
204348980Sdes            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
205348980Sdes            *)     $_G_check_func $_G_path_prog
206348980Sdes		   func_path_progs_result=$func_check_prog_result
207348980Sdes		   ;;
208348980Sdes          esac
209348980Sdes          $_G_path_prog_found && break 3
210348980Sdes        done
211348980Sdes      done
212348980Sdes    done
213348980Sdes    IFS=$_G_save_IFS
214348980Sdes    test -z "$func_path_progs_result" && {
215348980Sdes      echo "no acceptable sed could be found in \$PATH" >&2
216348980Sdes      exit 1
217348980Sdes    }
218348980Sdes}
219348980Sdes
220348980Sdes
221348980Sdes# We want to be able to use the functions in this file before configure
222348980Sdes# has figured out where the best binaries are kept, which means we have
223348980Sdes# to search for them ourselves - except when the results are already set
224348980Sdes# where we skip the searches.
225348980Sdes
226348980Sdes# Unless the user overrides by setting SED, search the path for either GNU
227348980Sdes# sed, or the sed that truncates its output the least.
228348980Sdestest -z "$SED" && {
229348980Sdes  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
230348980Sdes  for _G_i in 1 2 3 4 5 6 7; do
231348980Sdes    _G_sed_script=$_G_sed_script$nl$_G_sed_script
232348980Sdes  done
233348980Sdes  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
234348980Sdes  _G_sed_script=
235348980Sdes
236348980Sdes  func_check_prog_sed ()
237348980Sdes  {
238348980Sdes    _G_path_prog=$1
239348980Sdes
240348980Sdes    _G_count=0
241348980Sdes    printf 0123456789 >conftest.in
242348980Sdes    while :
243348980Sdes    do
244348980Sdes      cat conftest.in conftest.in >conftest.tmp
245348980Sdes      mv conftest.tmp conftest.in
246348980Sdes      cp conftest.in conftest.nl
247348980Sdes      echo '' >> conftest.nl
248348980Sdes      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
249348980Sdes      diff conftest.out conftest.nl >/dev/null 2>&1 || break
250348980Sdes      _G_count=`expr $_G_count + 1`
251348980Sdes      if test "$_G_count" -gt "$_G_path_prog_max"; then
252348980Sdes        # Best one so far, save it but keep looking for a better one
253348980Sdes        func_check_prog_result=$_G_path_prog
254348980Sdes        _G_path_prog_max=$_G_count
255348980Sdes      fi
256348980Sdes      # 10*(2^10) chars as input seems more than enough
257348980Sdes      test 10 -lt "$_G_count" && break
258348980Sdes    done
259348980Sdes    rm -f conftest.in conftest.tmp conftest.nl conftest.out
260348980Sdes  }
261348980Sdes
262348980Sdes  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
263348980Sdes  rm -f conftest.sed
264348980Sdes  SED=$func_path_progs_result
265348980Sdes}
266348980Sdes
267348980Sdes
268348980Sdes# Unless the user overrides by setting GREP, search the path for either GNU
269348980Sdes# grep, or the grep that truncates its output the least.
270348980Sdestest -z "$GREP" && {
271348980Sdes  func_check_prog_grep ()
272348980Sdes  {
273348980Sdes    _G_path_prog=$1
274348980Sdes
275348980Sdes    _G_count=0
276348980Sdes    _G_path_prog_max=0
277348980Sdes    printf 0123456789 >conftest.in
278348980Sdes    while :
279348980Sdes    do
280348980Sdes      cat conftest.in conftest.in >conftest.tmp
281348980Sdes      mv conftest.tmp conftest.in
282348980Sdes      cp conftest.in conftest.nl
283348980Sdes      echo 'GREP' >> conftest.nl
284348980Sdes      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
285348980Sdes      diff conftest.out conftest.nl >/dev/null 2>&1 || break
286348980Sdes      _G_count=`expr $_G_count + 1`
287348980Sdes      if test "$_G_count" -gt "$_G_path_prog_max"; then
288348980Sdes        # Best one so far, save it but keep looking for a better one
289348980Sdes        func_check_prog_result=$_G_path_prog
290348980Sdes        _G_path_prog_max=$_G_count
291348980Sdes      fi
292348980Sdes      # 10*(2^10) chars as input seems more than enough
293348980Sdes      test 10 -lt "$_G_count" && break
294348980Sdes    done
295348980Sdes    rm -f conftest.in conftest.tmp conftest.nl conftest.out
296348980Sdes  }
297348980Sdes
298348980Sdes  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
299348980Sdes  GREP=$func_path_progs_result
300348980Sdes}
301348980Sdes
302348980Sdes
303348980Sdes## ------------------------------- ##
304348980Sdes## User overridable command paths. ##
305348980Sdes## ------------------------------- ##
306348980Sdes
307348980Sdes# All uppercase variable names are used for environment variables.  These
308348980Sdes# variables can be overridden by the user before calling a script that
309348980Sdes# uses them if a suitable command of that name is not already available
310348980Sdes# in the command search PATH.
311348980Sdes
312228692Sdes: ${CP="cp -f"}
313348980Sdes: ${ECHO="printf %s\n"}
314348980Sdes: ${EGREP="$GREP -E"}
315348980Sdes: ${FGREP="$GREP -F"}
316348980Sdes: ${LN_S="ln -s"}
317228692Sdes: ${MAKE="make"}
318228692Sdes: ${MKDIR="mkdir"}
319228692Sdes: ${MV="mv -f"}
320228692Sdes: ${RM="rm -f"}
321228692Sdes: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
322228692Sdes
323228692Sdes
324348980Sdes## -------------------- ##
325348980Sdes## Useful sed snippets. ##
326348980Sdes## -------------------- ##
327228692Sdes
328348980Sdessed_dirname='s|/[^/]*$||'
329348980Sdessed_basename='s|^.*/||'
330117610Sdes
331348980Sdes# Sed substitution that helps us do robust quoting.  It backslashifies
332348980Sdes# metacharacters that are still active within double-quoted strings.
333348980Sdessed_quote_subst='s|\([`"$\\]\)|\\\1|g'
334117610Sdes
335348980Sdes# Same as above, but do not quote variable references.
336348980Sdessed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
337117610Sdes
338348980Sdes# Sed substitution that turns a string into a regex matching for the
339348980Sdes# string literally.
340348980Sdessed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
341141098Sdes
342348980Sdes# Sed substitution that converts a w32 file name or path
343348980Sdes# that contains forward slashes, into one that contains
344348980Sdes# (escaped) backslashes.  A very naive implementation.
345348980Sdessed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
346228692Sdes
347348980Sdes# Re-'\' parameter expansions in output of sed_double_quote_subst that
348348980Sdes# were '\'-ed in input to the same.  If an odd number of '\' preceded a
349348980Sdes# '$' in input to sed_double_quote_subst, that '$' was protected from
350348980Sdes# expansion.  Since each input '\' is now two '\'s, look for any number
351348980Sdes# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
352348980Sdes_G_bs='\\'
353348980Sdes_G_bs2='\\\\'
354348980Sdes_G_bs4='\\\\\\\\'
355348980Sdes_G_dollar='\$'
356348980Sdessed_double_backslash="\
357348980Sdes  s/$_G_bs4/&\\
358348980Sdes/g
359348980Sdes  s/^$_G_bs2$_G_dollar/$_G_bs&/
360348980Sdes  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
361348980Sdes  s/\n//g"
362228692Sdes
363228692Sdes
364348980Sdes## ----------------- ##
365348980Sdes## Global variables. ##
366348980Sdes## ----------------- ##
367228692Sdes
368348980Sdes# Except for the global variables explicitly listed below, the following
369348980Sdes# functions in the '^func_' namespace, and the '^require_' namespace
370348980Sdes# variables initialised in the 'Resource management' section, sourcing
371348980Sdes# this file will not pollute your global namespace with anything
372348980Sdes# else. There's no portable way to scope variables in Bourne shell
373348980Sdes# though, so actually running these functions will sometimes place
374348980Sdes# results into a variable named after the function, and often use
375348980Sdes# temporary variables in the '^_G_' namespace. If you are careful to
376348980Sdes# avoid using those namespaces casually in your sourcing script, things
377348980Sdes# should continue to work as you expect. And, of course, you can freely
378348980Sdes# overwrite any of the functions or variables defined here before
379348980Sdes# calling anything to customize them.
380228692Sdes
381348980SdesEXIT_SUCCESS=0
382348980SdesEXIT_FAILURE=1
383348980SdesEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
384348980SdesEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
385228692Sdes
386348980Sdes# Allow overriding, eg assuming that you follow the convention of
387348980Sdes# putting '$debug_cmd' at the start of all your functions, you can get
388348980Sdes# bash to show function call trace with:
389348980Sdes#
390348980Sdes#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
391348980Sdesdebug_cmd=${debug_cmd-":"}
392348980Sdesexit_cmd=:
393228692Sdes
394348980Sdes# By convention, finish your script with:
395348980Sdes#
396348980Sdes#    exit $exit_status
397348980Sdes#
398348980Sdes# so that you can set exit_status to non-zero if you want to indicate
399348980Sdes# something went wrong during execution without actually bailing out at
400348980Sdes# the point of failure.
401348980Sdesexit_status=$EXIT_SUCCESS
402228692Sdes
403348980Sdes# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
404348980Sdes# is ksh but when the shell is invoked as "sh" and the current value of
405348980Sdes# the _XPG environment variable is not equal to 1 (one), the special
406348980Sdes# positional parameter $0, within a function call, is the name of the
407348980Sdes# function.
408348980Sdesprogpath=$0
409228692Sdes
410348980Sdes# The name of this program.
411348980Sdesprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
412228692Sdes
413348980Sdes# Make sure we have an absolute progpath for reexecution:
414228692Sdescase $progpath in
415228692Sdes  [\\/]*|[A-Za-z]:\\*) ;;
416228692Sdes  *[\\/]*)
417348980Sdes     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
418228692Sdes     progdir=`cd "$progdir" && pwd`
419348980Sdes     progpath=$progdir/$progname
420228692Sdes     ;;
421228692Sdes  *)
422348980Sdes     _G_IFS=$IFS
423236109Sdes     IFS=${PATH_SEPARATOR-:}
424228692Sdes     for progdir in $PATH; do
425348980Sdes       IFS=$_G_IFS
426228692Sdes       test -x "$progdir/$progname" && break
427228692Sdes     done
428348980Sdes     IFS=$_G_IFS
429228692Sdes     test -n "$progdir" || progdir=`pwd`
430348980Sdes     progpath=$progdir/$progname
431228692Sdes     ;;
432228692Sdesesac
433228692Sdes
434228692Sdes
435348980Sdes## ----------------- ##
436348980Sdes## Standard options. ##
437348980Sdes## ----------------- ##
438228692Sdes
439348980Sdes# The following options affect the operation of the functions defined
440348980Sdes# below, and should be set appropriately depending on run-time para-
441348980Sdes# meters passed on the command line.
442228692Sdes
443228692Sdesopt_dry_run=false
444228692Sdesopt_quiet=false
445228692Sdesopt_verbose=false
446228692Sdes
447348980Sdes# Categories 'all' and 'none' are always available.  Append any others
448348980Sdes# you will pass as the first argument to func_warning from your own
449348980Sdes# code.
450348980Sdeswarning_categories=
451348980Sdes
452348980Sdes# By default, display warnings according to 'opt_warning_types'.  Set
453348980Sdes# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
454348980Sdes# treat the next displayed warning as a fatal error.
455348980Sdeswarning_func=func_warn_and_continue
456348980Sdes
457348980Sdes# Set to 'all' to display all warnings, 'none' to suppress all
458348980Sdes# warnings, or a space delimited list of some subset of
459348980Sdes# 'warning_categories' to display only the listed warnings.
460348980Sdesopt_warning_types=all
461348980Sdes
462348980Sdes
463348980Sdes## -------------------- ##
464348980Sdes## Resource management. ##
465348980Sdes## -------------------- ##
466348980Sdes
467348980Sdes# This section contains definitions for functions that each ensure a
468348980Sdes# particular resource (a file, or a non-empty configuration variable for
469348980Sdes# example) is available, and if appropriate to extract default values
470348980Sdes# from pertinent package files. Call them using their associated
471348980Sdes# 'require_*' variable to ensure that they are executed, at most, once.
472348980Sdes#
473348980Sdes# It's entirely deliberate that calling these functions can set
474348980Sdes# variables that don't obey the namespace limitations obeyed by the rest
475348980Sdes# of this file, in order that that they be as useful as possible to
476348980Sdes# callers.
477348980Sdes
478348980Sdes
479348980Sdes# require_term_colors
480348980Sdes# -------------------
481348980Sdes# Allow display of bold text on terminals that support it.
482348980Sdesrequire_term_colors=func_require_term_colors
483348980Sdesfunc_require_term_colors ()
484228692Sdes{
485348980Sdes    $debug_cmd
486348980Sdes
487348980Sdes    test -t 1 && {
488348980Sdes      # COLORTERM and USE_ANSI_COLORS environment variables take
489348980Sdes      # precedence, because most terminfo databases neglect to describe
490348980Sdes      # whether color sequences are supported.
491348980Sdes      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
492348980Sdes
493348980Sdes      if test 1 = "$USE_ANSI_COLORS"; then
494348980Sdes        # Standard ANSI escape sequences
495348980Sdes        tc_reset='[0m'
496348980Sdes        tc_bold='[1m';   tc_standout='[7m'
497348980Sdes        tc_red='[31m';   tc_green='[32m'
498348980Sdes        tc_blue='[34m';  tc_cyan='[36m'
499348980Sdes      else
500348980Sdes        # Otherwise trust the terminfo database after all.
501348980Sdes        test -n "`tput sgr0 2>/dev/null`" && {
502348980Sdes          tc_reset=`tput sgr0`
503348980Sdes          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
504348980Sdes          tc_standout=$tc_bold
505348980Sdes          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
506348980Sdes          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
507348980Sdes          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
508348980Sdes          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
509348980Sdes          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
510348980Sdes        }
511348980Sdes      fi
512348980Sdes    }
513348980Sdes
514348980Sdes    require_term_colors=:
515228692Sdes}
516228692Sdes
517348980Sdes
518348980Sdes## ----------------- ##
519348980Sdes## Function library. ##
520348980Sdes## ----------------- ##
521348980Sdes
522348980Sdes# This section contains a variety of useful functions to call in your
523348980Sdes# scripts. Take note of the portable wrappers for features provided by
524348980Sdes# some modern shells, which will fall back to slower equivalents on
525348980Sdes# less featureful shells.
526348980Sdes
527348980Sdes
528348980Sdes# func_append VAR VALUE
529348980Sdes# ---------------------
530348980Sdes# Append VALUE onto the existing contents of VAR.
531348980Sdes
532348980Sdes  # We should try to minimise forks, especially on Windows where they are
533348980Sdes  # unreasonably slow, so skip the feature probes when bash or zsh are
534348980Sdes  # being used:
535348980Sdes  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
536348980Sdes    : ${_G_HAVE_ARITH_OP="yes"}
537348980Sdes    : ${_G_HAVE_XSI_OPS="yes"}
538348980Sdes    # The += operator was introduced in bash 3.1
539348980Sdes    case $BASH_VERSION in
540348980Sdes      [12].* | 3.0 | 3.0*) ;;
541348980Sdes      *)
542348980Sdes        : ${_G_HAVE_PLUSEQ_OP="yes"}
543348980Sdes        ;;
544348980Sdes    esac
545348980Sdes  fi
546348980Sdes
547348980Sdes  # _G_HAVE_PLUSEQ_OP
548348980Sdes  # Can be empty, in which case the shell is probed, "yes" if += is
549348980Sdes  # useable or anything else if it does not work.
550348980Sdes  test -z "$_G_HAVE_PLUSEQ_OP" \
551348980Sdes    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
552348980Sdes    && _G_HAVE_PLUSEQ_OP=yes
553348980Sdes
554348980Sdesif test yes = "$_G_HAVE_PLUSEQ_OP"
555348980Sdesthen
556348980Sdes  # This is an XSI compatible shell, allowing a faster implementation...
557348980Sdes  eval 'func_append ()
558348980Sdes  {
559348980Sdes    $debug_cmd
560348980Sdes
561348980Sdes    eval "$1+=\$2"
562348980Sdes  }'
563348980Sdeselse
564348980Sdes  # ...otherwise fall back to using expr, which is often a shell builtin.
565348980Sdes  func_append ()
566348980Sdes  {
567348980Sdes    $debug_cmd
568348980Sdes
569348980Sdes    eval "$1=\$$1\$2"
570348980Sdes  }
571348980Sdesfi
572348980Sdes
573348980Sdes
574348980Sdes# func_append_quoted VAR VALUE
575348980Sdes# ----------------------------
576348980Sdes# Quote VALUE and append to the end of shell variable VAR, separated
577348980Sdes# by a space.
578348980Sdesif test yes = "$_G_HAVE_PLUSEQ_OP"; then
579348980Sdes  eval 'func_append_quoted ()
580348980Sdes  {
581348980Sdes    $debug_cmd
582348980Sdes
583348980Sdes    func_quote_for_eval "$2"
584348980Sdes    eval "$1+=\\ \$func_quote_for_eval_result"
585348980Sdes  }'
586348980Sdeselse
587348980Sdes  func_append_quoted ()
588348980Sdes  {
589348980Sdes    $debug_cmd
590348980Sdes
591348980Sdes    func_quote_for_eval "$2"
592348980Sdes    eval "$1=\$$1\\ \$func_quote_for_eval_result"
593348980Sdes  }
594348980Sdesfi
595348980Sdes
596348980Sdes
597348980Sdes# func_append_uniq VAR VALUE
598348980Sdes# --------------------------
599348980Sdes# Append unique VALUE onto the existing contents of VAR, assuming
600348980Sdes# entries are delimited by the first character of VALUE.  For example:
601348980Sdes#
602348980Sdes#   func_append_uniq options " --another-option option-argument"
603348980Sdes#
604348980Sdes# will only append to $options if " --another-option option-argument "
605348980Sdes# is not already present somewhere in $options already (note spaces at
606348980Sdes# each end implied by leading space in second argument).
607348980Sdesfunc_append_uniq ()
608228692Sdes{
609348980Sdes    $debug_cmd
610228692Sdes
611348980Sdes    eval _G_current_value='`$ECHO $'$1'`'
612348980Sdes    _G_delim=`expr "$2" : '\(.\)'`
613348980Sdes
614348980Sdes    case $_G_delim$_G_current_value$_G_delim in
615348980Sdes      *"$2$_G_delim"*) ;;
616348980Sdes      *) func_append "$@" ;;
617348980Sdes    esac
618228692Sdes}
619228692Sdes
620348980Sdes
621348980Sdes# func_arith TERM...
622348980Sdes# ------------------
623348980Sdes# Set func_arith_result to the result of evaluating TERMs.
624348980Sdes  test -z "$_G_HAVE_ARITH_OP" \
625348980Sdes    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
626348980Sdes    && _G_HAVE_ARITH_OP=yes
627348980Sdes
628348980Sdesif test yes = "$_G_HAVE_ARITH_OP"; then
629348980Sdes  eval 'func_arith ()
630348980Sdes  {
631348980Sdes    $debug_cmd
632348980Sdes
633348980Sdes    func_arith_result=$(( $* ))
634348980Sdes  }'
635348980Sdeselse
636348980Sdes  func_arith ()
637348980Sdes  {
638348980Sdes    $debug_cmd
639348980Sdes
640348980Sdes    func_arith_result=`expr "$@"`
641348980Sdes  }
642348980Sdesfi
643348980Sdes
644348980Sdes
645348980Sdes# func_basename FILE
646348980Sdes# ------------------
647348980Sdes# Set func_basename_result to FILE with everything up to and including
648348980Sdes# the last / stripped.
649348980Sdesif test yes = "$_G_HAVE_XSI_OPS"; then
650348980Sdes  # If this shell supports suffix pattern removal, then use it to avoid
651348980Sdes  # forking. Hide the definitions single quotes in case the shell chokes
652348980Sdes  # on unsupported syntax...
653348980Sdes  _b='func_basename_result=${1##*/}'
654348980Sdes  _d='case $1 in
655348980Sdes        */*) func_dirname_result=${1%/*}$2 ;;
656348980Sdes        *  ) func_dirname_result=$3        ;;
657348980Sdes      esac'
658348980Sdes
659348980Sdeselse
660348980Sdes  # ...otherwise fall back to using sed.
661348980Sdes  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
662348980Sdes  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
663348980Sdes      if test "X$func_dirname_result" = "X$1"; then
664348980Sdes        func_dirname_result=$3
665348980Sdes      else
666348980Sdes        func_append func_dirname_result "$2"
667348980Sdes      fi'
668348980Sdesfi
669348980Sdes
670348980Sdeseval 'func_basename ()
671348980Sdes{
672348980Sdes    $debug_cmd
673348980Sdes
674348980Sdes    '"$_b"'
675348980Sdes}'
676348980Sdes
677348980Sdes
678348980Sdes# func_dirname FILE APPEND NONDIR_REPLACEMENT
679348980Sdes# -------------------------------------------
680348980Sdes# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
681348980Sdes# otherwise set result to NONDIR_REPLACEMENT.
682348980Sdeseval 'func_dirname ()
683348980Sdes{
684348980Sdes    $debug_cmd
685348980Sdes
686348980Sdes    '"$_d"'
687348980Sdes}'
688348980Sdes
689348980Sdes
690348980Sdes# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
691348980Sdes# --------------------------------------------------------
692348980Sdes# Perform func_basename and func_dirname in a single function
693348980Sdes# call:
694348980Sdes#   dirname:  Compute the dirname of FILE.  If nonempty,
695348980Sdes#             add APPEND to the result, otherwise set result
696348980Sdes#             to NONDIR_REPLACEMENT.
697348980Sdes#             value returned in "$func_dirname_result"
698348980Sdes#   basename: Compute filename of FILE.
699348980Sdes#             value retuned in "$func_basename_result"
700348980Sdes# For efficiency, we do not delegate to the functions above but instead
701348980Sdes# duplicate the functionality here.
702348980Sdeseval 'func_dirname_and_basename ()
703348980Sdes{
704348980Sdes    $debug_cmd
705348980Sdes
706348980Sdes    '"$_b"'
707348980Sdes    '"$_d"'
708348980Sdes}'
709348980Sdes
710348980Sdes
711348980Sdes# func_echo ARG...
712348980Sdes# ----------------
713348980Sdes# Echo program name prefixed message.
714348980Sdesfunc_echo ()
715348980Sdes{
716348980Sdes    $debug_cmd
717348980Sdes
718348980Sdes    _G_message=$*
719348980Sdes
720348980Sdes    func_echo_IFS=$IFS
721348980Sdes    IFS=$nl
722348980Sdes    for _G_line in $_G_message; do
723348980Sdes      IFS=$func_echo_IFS
724348980Sdes      $ECHO "$progname: $_G_line"
725348980Sdes    done
726348980Sdes    IFS=$func_echo_IFS
727348980Sdes}
728348980Sdes
729348980Sdes
730348980Sdes# func_echo_all ARG...
731348980Sdes# --------------------
732228692Sdes# Invoke $ECHO with all args, space-separated.
733228692Sdesfunc_echo_all ()
734228692Sdes{
735228692Sdes    $ECHO "$*"
736228692Sdes}
737228692Sdes
738348980Sdes
739348980Sdes# func_echo_infix_1 INFIX ARG...
740348980Sdes# ------------------------------
741348980Sdes# Echo program name, followed by INFIX on the first line, with any
742348980Sdes# additional lines not showing INFIX.
743348980Sdesfunc_echo_infix_1 ()
744228692Sdes{
745348980Sdes    $debug_cmd
746348980Sdes
747348980Sdes    $require_term_colors
748348980Sdes
749348980Sdes    _G_infix=$1; shift
750348980Sdes    _G_indent=$_G_infix
751348980Sdes    _G_prefix="$progname: $_G_infix: "
752348980Sdes    _G_message=$*
753348980Sdes
754348980Sdes    # Strip color escape sequences before counting printable length
755348980Sdes    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
756348980Sdes    do
757348980Sdes      test -n "$_G_tc" && {
758348980Sdes        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
759348980Sdes        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
760348980Sdes      }
761348980Sdes    done
762348980Sdes    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
763348980Sdes
764348980Sdes    func_echo_infix_1_IFS=$IFS
765348980Sdes    IFS=$nl
766348980Sdes    for _G_line in $_G_message; do
767348980Sdes      IFS=$func_echo_infix_1_IFS
768348980Sdes      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
769348980Sdes      _G_prefix=$_G_indent
770348980Sdes    done
771348980Sdes    IFS=$func_echo_infix_1_IFS
772228692Sdes}
773228692Sdes
774348980Sdes
775348980Sdes# func_error ARG...
776348980Sdes# -----------------
777348980Sdes# Echo program name prefixed message to standard error.
778348980Sdesfunc_error ()
779228692Sdes{
780348980Sdes    $debug_cmd
781228692Sdes
782348980Sdes    $require_term_colors
783348980Sdes
784348980Sdes    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
785228692Sdes}
786228692Sdes
787348980Sdes
788348980Sdes# func_fatal_error ARG...
789348980Sdes# -----------------------
790228692Sdes# Echo program name prefixed message to standard error, and exit.
791228692Sdesfunc_fatal_error ()
792228692Sdes{
793348980Sdes    $debug_cmd
794348980Sdes
795348980Sdes    func_error "$*"
796228692Sdes    exit $EXIT_FAILURE
797228692Sdes}
798228692Sdes
799228692Sdes
800348980Sdes# func_grep EXPRESSION FILENAME
801348980Sdes# -----------------------------
802228692Sdes# Check whether EXPRESSION matches any line of FILENAME, without output.
803228692Sdesfunc_grep ()
804228692Sdes{
805348980Sdes    $debug_cmd
806348980Sdes
807228692Sdes    $GREP "$1" "$2" >/dev/null 2>&1
808228692Sdes}
809228692Sdes
810228692Sdes
811348980Sdes# func_len STRING
812348980Sdes# ---------------
813348980Sdes# Set func_len_result to the length of STRING. STRING may not
814348980Sdes# start with a hyphen.
815348980Sdes  test -z "$_G_HAVE_XSI_OPS" \
816348980Sdes    && (eval 'x=a/b/c;
817348980Sdes      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
818348980Sdes    && _G_HAVE_XSI_OPS=yes
819348980Sdes
820348980Sdesif test yes = "$_G_HAVE_XSI_OPS"; then
821348980Sdes  eval 'func_len ()
822348980Sdes  {
823348980Sdes    $debug_cmd
824348980Sdes
825348980Sdes    func_len_result=${#1}
826348980Sdes  }'
827348980Sdeselse
828348980Sdes  func_len ()
829348980Sdes  {
830348980Sdes    $debug_cmd
831348980Sdes
832348980Sdes    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
833348980Sdes  }
834348980Sdesfi
835348980Sdes
836348980Sdes
837348980Sdes# func_mkdir_p DIRECTORY-PATH
838348980Sdes# ---------------------------
839228692Sdes# Make sure the entire path to DIRECTORY-PATH is available.
840228692Sdesfunc_mkdir_p ()
841228692Sdes{
842348980Sdes    $debug_cmd
843228692Sdes
844348980Sdes    _G_directory_path=$1
845348980Sdes    _G_dir_list=
846228692Sdes
847348980Sdes    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
848348980Sdes
849348980Sdes      # Protect directory names starting with '-'
850348980Sdes      case $_G_directory_path in
851348980Sdes        -*) _G_directory_path=./$_G_directory_path ;;
852228692Sdes      esac
853228692Sdes
854228692Sdes      # While some portion of DIR does not yet exist...
855348980Sdes      while test ! -d "$_G_directory_path"; do
856228692Sdes        # ...make a list in topmost first order.  Use a colon delimited
857228692Sdes	# list incase some portion of path contains whitespace.
858348980Sdes        _G_dir_list=$_G_directory_path:$_G_dir_list
859228692Sdes
860228692Sdes        # If the last portion added has no slash in it, the list is done
861348980Sdes        case $_G_directory_path in */*) ;; *) break ;; esac
862228692Sdes
863228692Sdes        # ...otherwise throw away the child directory and loop
864348980Sdes        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
865228692Sdes      done
866348980Sdes      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
867228692Sdes
868348980Sdes      func_mkdir_p_IFS=$IFS; IFS=:
869348980Sdes      for _G_dir in $_G_dir_list; do
870348980Sdes	IFS=$func_mkdir_p_IFS
871348980Sdes        # mkdir can fail with a 'File exist' error if two processes
872228692Sdes        # try to create one of the directories concurrently.  Don't
873228692Sdes        # stop in that case!
874348980Sdes        $MKDIR "$_G_dir" 2>/dev/null || :
875228692Sdes      done
876348980Sdes      IFS=$func_mkdir_p_IFS
877228692Sdes
878228692Sdes      # Bail out if we (or some other process) failed to create a directory.
879348980Sdes      test -d "$_G_directory_path" || \
880348980Sdes        func_fatal_error "Failed to create '$1'"
881228692Sdes    fi
882228692Sdes}
883228692Sdes
884228692Sdes
885348980Sdes# func_mktempdir [BASENAME]
886348980Sdes# -------------------------
887174832Sdes# Make a temporary directory that won't clash with other running
888174832Sdes# libtool processes, and avoids race conditions if possible.  If
889348980Sdes# given, BASENAME is the basename for that directory.
890174832Sdesfunc_mktempdir ()
891174832Sdes{
892348980Sdes    $debug_cmd
893174832Sdes
894348980Sdes    _G_template=${TMPDIR-/tmp}/${1-$progname}
895348980Sdes
896348980Sdes    if test : = "$opt_dry_run"; then
897174832Sdes      # Return a directory name, but don't create it in dry-run mode
898348980Sdes      _G_tmpdir=$_G_template-$$
899174832Sdes    else
900174832Sdes
901174832Sdes      # If mktemp works, use that first and foremost
902348980Sdes      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
903174832Sdes
904348980Sdes      if test ! -d "$_G_tmpdir"; then
905228692Sdes        # Failing that, at least try and use $RANDOM to avoid a race
906348980Sdes        _G_tmpdir=$_G_template-${RANDOM-0}$$
907174832Sdes
908348980Sdes        func_mktempdir_umask=`umask`
909228692Sdes        umask 0077
910348980Sdes        $MKDIR "$_G_tmpdir"
911348980Sdes        umask $func_mktempdir_umask
912174832Sdes      fi
913174832Sdes
914174832Sdes      # If we're not in dry-run mode, bomb out on failure
915348980Sdes      test -d "$_G_tmpdir" || \
916348980Sdes        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
917174832Sdes    fi
918174832Sdes
919348980Sdes    $ECHO "$_G_tmpdir"
920174832Sdes}
921174832Sdes
922174832Sdes
923348980Sdes# func_normal_abspath PATH
924348980Sdes# ------------------------
925348980Sdes# Remove doubled-up and trailing slashes, "." path components,
926348980Sdes# and cancel out any ".." path components in PATH after making
927348980Sdes# it an absolute path.
928348980Sdesfunc_normal_abspath ()
929147455Sdes{
930348980Sdes    $debug_cmd
931228692Sdes
932348980Sdes    # These SED scripts presuppose an absolute path with a trailing slash.
933348980Sdes    _G_pathcar='s|^/\([^/]*\).*$|\1|'
934348980Sdes    _G_pathcdr='s|^/[^/]*||'
935348980Sdes    _G_removedotparts=':dotsl
936348980Sdes		s|/\./|/|g
937348980Sdes		t dotsl
938348980Sdes		s|/\.$|/|'
939348980Sdes    _G_collapseslashes='s|/\{1,\}|/|g'
940348980Sdes    _G_finalslash='s|/*$|/|'
941348980Sdes
942348980Sdes    # Start from root dir and reassemble the path.
943348980Sdes    func_normal_abspath_result=
944348980Sdes    func_normal_abspath_tpath=$1
945348980Sdes    func_normal_abspath_altnamespace=
946348980Sdes    case $func_normal_abspath_tpath in
947348980Sdes      "")
948348980Sdes        # Empty path, that just means $cwd.
949348980Sdes        func_stripname '' '/' "`pwd`"
950348980Sdes        func_normal_abspath_result=$func_stripname_result
951348980Sdes        return
952228692Sdes        ;;
953348980Sdes      # The next three entries are used to spot a run of precisely
954348980Sdes      # two leading slashes without using negated character classes;
955348980Sdes      # we take advantage of case's first-match behaviour.
956348980Sdes      ///*)
957348980Sdes        # Unusual form of absolute path, do nothing.
958348980Sdes        ;;
959348980Sdes      //*)
960348980Sdes        # Not necessarily an ordinary path; POSIX reserves leading '//'
961348980Sdes        # and for example Cygwin uses it to access remote file shares
962348980Sdes        # over CIFS/SMB, so we conserve a leading double slash if found.
963348980Sdes        func_normal_abspath_altnamespace=/
964348980Sdes        ;;
965348980Sdes      /*)
966348980Sdes        # Absolute path, do nothing.
967348980Sdes        ;;
968228692Sdes      *)
969348980Sdes        # Relative path, prepend $cwd.
970348980Sdes        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
971348980Sdes        ;;
972228692Sdes    esac
973348980Sdes
974348980Sdes    # Cancel out all the simple stuff to save iterations.  We also want
975348980Sdes    # the path to end with a slash for ease of parsing, so make sure
976348980Sdes    # there is one (and only one) here.
977348980Sdes    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
978348980Sdes          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
979348980Sdes    while :; do
980348980Sdes      # Processed it all yet?
981348980Sdes      if test / = "$func_normal_abspath_tpath"; then
982348980Sdes        # If we ascended to the root using ".." the result may be empty now.
983348980Sdes        if test -z "$func_normal_abspath_result"; then
984348980Sdes          func_normal_abspath_result=/
985348980Sdes        fi
986348980Sdes        break
987348980Sdes      fi
988348980Sdes      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
989348980Sdes          -e "$_G_pathcar"`
990348980Sdes      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
991348980Sdes          -e "$_G_pathcdr"`
992348980Sdes      # Figure out what to do with it
993348980Sdes      case $func_normal_abspath_tcomponent in
994348980Sdes        "")
995348980Sdes          # Trailing empty path component, ignore it.
996348980Sdes          ;;
997348980Sdes        ..)
998348980Sdes          # Parent dir; strip last assembled component from result.
999348980Sdes          func_dirname "$func_normal_abspath_result"
1000348980Sdes          func_normal_abspath_result=$func_dirname_result
1001348980Sdes          ;;
1002348980Sdes        *)
1003348980Sdes          # Actual path component, append it.
1004348980Sdes          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1005348980Sdes          ;;
1006348980Sdes      esac
1007348980Sdes    done
1008348980Sdes    # Restore leading double-slash if one was found on entry.
1009348980Sdes    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1010228692Sdes}
1011228692Sdes
1012228692Sdes
1013348980Sdes# func_notquiet ARG...
1014348980Sdes# --------------------
1015348980Sdes# Echo program name prefixed message only when not in quiet mode.
1016348980Sdesfunc_notquiet ()
1017348980Sdes{
1018348980Sdes    $debug_cmd
1019348980Sdes
1020348980Sdes    $opt_quiet || func_echo ${1+"$@"}
1021348980Sdes
1022348980Sdes    # A bug in bash halts the script if the last line of a function
1023348980Sdes    # fails when set -e is in force, so we need another command to
1024348980Sdes    # work around that:
1025348980Sdes    :
1026348980Sdes}
1027348980Sdes
1028348980Sdes
1029348980Sdes# func_relative_path SRCDIR DSTDIR
1030348980Sdes# --------------------------------
1031348980Sdes# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1032348980Sdesfunc_relative_path ()
1033348980Sdes{
1034348980Sdes    $debug_cmd
1035348980Sdes
1036348980Sdes    func_relative_path_result=
1037348980Sdes    func_normal_abspath "$1"
1038348980Sdes    func_relative_path_tlibdir=$func_normal_abspath_result
1039348980Sdes    func_normal_abspath "$2"
1040348980Sdes    func_relative_path_tbindir=$func_normal_abspath_result
1041348980Sdes
1042348980Sdes    # Ascend the tree starting from libdir
1043348980Sdes    while :; do
1044348980Sdes      # check if we have found a prefix of bindir
1045348980Sdes      case $func_relative_path_tbindir in
1046348980Sdes        $func_relative_path_tlibdir)
1047348980Sdes          # found an exact match
1048348980Sdes          func_relative_path_tcancelled=
1049348980Sdes          break
1050348980Sdes          ;;
1051348980Sdes        $func_relative_path_tlibdir*)
1052348980Sdes          # found a matching prefix
1053348980Sdes          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1054348980Sdes          func_relative_path_tcancelled=$func_stripname_result
1055348980Sdes          if test -z "$func_relative_path_result"; then
1056348980Sdes            func_relative_path_result=.
1057348980Sdes          fi
1058348980Sdes          break
1059348980Sdes          ;;
1060348980Sdes        *)
1061348980Sdes          func_dirname $func_relative_path_tlibdir
1062348980Sdes          func_relative_path_tlibdir=$func_dirname_result
1063348980Sdes          if test -z "$func_relative_path_tlibdir"; then
1064348980Sdes            # Have to descend all the way to the root!
1065348980Sdes            func_relative_path_result=../$func_relative_path_result
1066348980Sdes            func_relative_path_tcancelled=$func_relative_path_tbindir
1067348980Sdes            break
1068348980Sdes          fi
1069348980Sdes          func_relative_path_result=../$func_relative_path_result
1070348980Sdes          ;;
1071348980Sdes      esac
1072348980Sdes    done
1073348980Sdes
1074348980Sdes    # Now calculate path; take care to avoid doubling-up slashes.
1075348980Sdes    func_stripname '' '/' "$func_relative_path_result"
1076348980Sdes    func_relative_path_result=$func_stripname_result
1077348980Sdes    func_stripname '/' '/' "$func_relative_path_tcancelled"
1078348980Sdes    if test -n "$func_stripname_result"; then
1079348980Sdes      func_append func_relative_path_result "/$func_stripname_result"
1080348980Sdes    fi
1081348980Sdes
1082348980Sdes    # Normalisation. If bindir is libdir, return '.' else relative path.
1083348980Sdes    if test -n "$func_relative_path_result"; then
1084348980Sdes      func_stripname './' '' "$func_relative_path_result"
1085348980Sdes      func_relative_path_result=$func_stripname_result
1086348980Sdes    fi
1087348980Sdes
1088348980Sdes    test -n "$func_relative_path_result" || func_relative_path_result=.
1089348980Sdes
1090348980Sdes    :
1091348980Sdes}
1092348980Sdes
1093348980Sdes
1094348980Sdes# func_quote_for_eval ARG...
1095348980Sdes# --------------------------
1096348980Sdes# Aesthetically quote ARGs to be evaled later.
1097348980Sdes# This function returns two values:
1098348980Sdes#   i) func_quote_for_eval_result
1099348980Sdes#      double-quoted, suitable for a subsequent eval
1100348980Sdes#  ii) func_quote_for_eval_unquoted_result
1101348980Sdes#      has all characters that are still active within double
1102348980Sdes#      quotes backslashified.
1103348980Sdesfunc_quote_for_eval ()
1104348980Sdes{
1105348980Sdes    $debug_cmd
1106348980Sdes
1107348980Sdes    func_quote_for_eval_unquoted_result=
1108348980Sdes    func_quote_for_eval_result=
1109348980Sdes    while test 0 -lt $#; do
1110348980Sdes      case $1 in
1111348980Sdes        *[\\\`\"\$]*)
1112348980Sdes	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
1113348980Sdes        *)
1114348980Sdes          _G_unquoted_arg=$1 ;;
1115348980Sdes      esac
1116348980Sdes      if test -n "$func_quote_for_eval_unquoted_result"; then
1117348980Sdes	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1118348980Sdes      else
1119348980Sdes        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1120348980Sdes      fi
1121348980Sdes
1122348980Sdes      case $_G_unquoted_arg in
1123348980Sdes        # Double-quote args containing shell metacharacters to delay
1124348980Sdes        # word splitting, command substitution and variable expansion
1125348980Sdes        # for a subsequent eval.
1126348980Sdes        # Many Bourne shells cannot handle close brackets correctly
1127348980Sdes        # in scan sets, so we specify it separately.
1128348980Sdes        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1129348980Sdes          _G_quoted_arg=\"$_G_unquoted_arg\"
1130348980Sdes          ;;
1131348980Sdes        *)
1132348980Sdes          _G_quoted_arg=$_G_unquoted_arg
1133348980Sdes	  ;;
1134348980Sdes      esac
1135348980Sdes
1136348980Sdes      if test -n "$func_quote_for_eval_result"; then
1137348980Sdes	func_append func_quote_for_eval_result " $_G_quoted_arg"
1138348980Sdes      else
1139348980Sdes        func_append func_quote_for_eval_result "$_G_quoted_arg"
1140348980Sdes      fi
1141348980Sdes      shift
1142348980Sdes    done
1143348980Sdes}
1144348980Sdes
1145348980Sdes
1146348980Sdes# func_quote_for_expand ARG
1147348980Sdes# -------------------------
1148228692Sdes# Aesthetically quote ARG to be evaled later; same as above,
1149228692Sdes# but do not quote variable references.
1150228692Sdesfunc_quote_for_expand ()
1151228692Sdes{
1152348980Sdes    $debug_cmd
1153348980Sdes
1154228692Sdes    case $1 in
1155228692Sdes      *[\\\`\"]*)
1156348980Sdes	_G_arg=`$ECHO "$1" | $SED \
1157348980Sdes	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
1158228692Sdes      *)
1159348980Sdes        _G_arg=$1 ;;
1160228692Sdes    esac
1161228692Sdes
1162348980Sdes    case $_G_arg in
1163228692Sdes      # Double-quote args containing shell metacharacters to delay
1164228692Sdes      # word splitting and command substitution for a subsequent eval.
1165228692Sdes      # Many Bourne shells cannot handle close brackets correctly
1166228692Sdes      # in scan sets, so we specify it separately.
1167228692Sdes      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1168348980Sdes        _G_arg=\"$_G_arg\"
1169228692Sdes        ;;
1170228692Sdes    esac
1171228692Sdes
1172348980Sdes    func_quote_for_expand_result=$_G_arg
1173228692Sdes}
1174228692Sdes
1175228692Sdes
1176348980Sdes# func_stripname PREFIX SUFFIX NAME
1177348980Sdes# ---------------------------------
1178348980Sdes# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1179348980Sdes# PREFIX and SUFFIX must not contain globbing or regex special
1180348980Sdes# characters, hashes, percent signs, but SUFFIX may contain a leading
1181348980Sdes# dot (in which case that matches only a dot).
1182348980Sdesif test yes = "$_G_HAVE_XSI_OPS"; then
1183348980Sdes  eval 'func_stripname ()
1184348980Sdes  {
1185348980Sdes    $debug_cmd
1186348980Sdes
1187348980Sdes    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1188348980Sdes    # positional parameters, so assign one to ordinary variable first.
1189348980Sdes    func_stripname_result=$3
1190348980Sdes    func_stripname_result=${func_stripname_result#"$1"}
1191348980Sdes    func_stripname_result=${func_stripname_result%"$2"}
1192348980Sdes  }'
1193348980Sdeselse
1194348980Sdes  func_stripname ()
1195348980Sdes  {
1196348980Sdes    $debug_cmd
1197348980Sdes
1198348980Sdes    case $2 in
1199348980Sdes      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1200348980Sdes      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1201348980Sdes    esac
1202348980Sdes  }
1203348980Sdesfi
1204348980Sdes
1205348980Sdes
1206348980Sdes# func_show_eval CMD [FAIL_EXP]
1207348980Sdes# -----------------------------
1208348980Sdes# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1209228692Sdes# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1210228692Sdes# is given, then evaluate it.
1211228692Sdesfunc_show_eval ()
1212228692Sdes{
1213348980Sdes    $debug_cmd
1214228692Sdes
1215348980Sdes    _G_cmd=$1
1216348980Sdes    _G_fail_exp=${2-':'}
1217228692Sdes
1218348980Sdes    func_quote_for_expand "$_G_cmd"
1219348980Sdes    eval "func_notquiet $func_quote_for_expand_result"
1220348980Sdes
1221348980Sdes    $opt_dry_run || {
1222348980Sdes      eval "$_G_cmd"
1223348980Sdes      _G_status=$?
1224348980Sdes      if test 0 -ne "$_G_status"; then
1225348980Sdes	eval "(exit $_G_status); $_G_fail_exp"
1226228692Sdes      fi
1227348980Sdes    }
1228228692Sdes}
1229228692Sdes
1230228692Sdes
1231348980Sdes# func_show_eval_locale CMD [FAIL_EXP]
1232348980Sdes# ------------------------------------
1233348980Sdes# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1234228692Sdes# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1235228692Sdes# is given, then evaluate it.  Use the saved locale for evaluation.
1236228692Sdesfunc_show_eval_locale ()
1237228692Sdes{
1238348980Sdes    $debug_cmd
1239228692Sdes
1240348980Sdes    _G_cmd=$1
1241348980Sdes    _G_fail_exp=${2-':'}
1242348980Sdes
1243348980Sdes    $opt_quiet || {
1244348980Sdes      func_quote_for_expand "$_G_cmd"
1245228692Sdes      eval "func_echo $func_quote_for_expand_result"
1246228692Sdes    }
1247228692Sdes
1248348980Sdes    $opt_dry_run || {
1249348980Sdes      eval "$_G_user_locale
1250348980Sdes	    $_G_cmd"
1251348980Sdes      _G_status=$?
1252348980Sdes      eval "$_G_safe_locale"
1253348980Sdes      if test 0 -ne "$_G_status"; then
1254348980Sdes	eval "(exit $_G_status); $_G_fail_exp"
1255228692Sdes      fi
1256348980Sdes    }
1257228692Sdes}
1258228692Sdes
1259348980Sdes
1260228692Sdes# func_tr_sh
1261348980Sdes# ----------
1262228692Sdes# Turn $1 into a string suitable for a shell variable name.
1263228692Sdes# Result is stored in $func_tr_sh_result.  All characters
1264228692Sdes# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1265228692Sdes# if $1 begins with a digit, a '_' is prepended as well.
1266228692Sdesfunc_tr_sh ()
1267228692Sdes{
1268348980Sdes    $debug_cmd
1269348980Sdes
1270348980Sdes    case $1 in
1271348980Sdes    [0-9]* | *[!a-zA-Z0-9_]*)
1272348980Sdes      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1273348980Sdes      ;;
1274348980Sdes    * )
1275348980Sdes      func_tr_sh_result=$1
1276348980Sdes      ;;
1277348980Sdes    esac
1278228692Sdes}
1279228692Sdes
1280228692Sdes
1281348980Sdes# func_verbose ARG...
1282348980Sdes# -------------------
1283348980Sdes# Echo program name prefixed message in verbose mode only.
1284348980Sdesfunc_verbose ()
1285228692Sdes{
1286348980Sdes    $debug_cmd
1287228692Sdes
1288348980Sdes    $opt_verbose && func_echo "$*"
1289348980Sdes
1290348980Sdes    :
1291228692Sdes}
1292228692Sdes
1293348980Sdes
1294348980Sdes# func_warn_and_continue ARG...
1295348980Sdes# -----------------------------
1296348980Sdes# Echo program name prefixed warning message to standard error.
1297348980Sdesfunc_warn_and_continue ()
1298228692Sdes{
1299348980Sdes    $debug_cmd
1300228692Sdes
1301348980Sdes    $require_term_colors
1302348980Sdes
1303348980Sdes    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1304228692Sdes}
1305228692Sdes
1306348980Sdes
1307348980Sdes# func_warning CATEGORY ARG...
1308348980Sdes# ----------------------------
1309348980Sdes# Echo program name prefixed warning message to standard error. Warning
1310348980Sdes# messages can be filtered according to CATEGORY, where this function
1311348980Sdes# elides messages where CATEGORY is not listed in the global variable
1312348980Sdes# 'opt_warning_types'.
1313348980Sdesfunc_warning ()
1314348980Sdes{
1315348980Sdes    $debug_cmd
1316348980Sdes
1317348980Sdes    # CATEGORY must be in the warning_categories list!
1318348980Sdes    case " $warning_categories " in
1319348980Sdes      *" $1 "*) ;;
1320348980Sdes      *) func_internal_error "invalid warning category '$1'" ;;
1321348980Sdes    esac
1322348980Sdes
1323348980Sdes    _G_category=$1
1324348980Sdes    shift
1325348980Sdes
1326348980Sdes    case " $opt_warning_types " in
1327348980Sdes      *" $_G_category "*) $warning_func ${1+"$@"} ;;
1328348980Sdes    esac
1329348980Sdes}
1330348980Sdes
1331348980Sdes
1332348980Sdes# func_sort_ver VER1 VER2
1333348980Sdes# -----------------------
1334348980Sdes# 'sort -V' is not generally available.
1335348980Sdes# Note this deviates from the version comparison in automake
1336348980Sdes# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1337348980Sdes# but this should suffice as we won't be specifying old
1338348980Sdes# version formats or redundant trailing .0 in bootstrap.conf.
1339348980Sdes# If we did want full compatibility then we should probably
1340348980Sdes# use m4_version_compare from autoconf.
1341348980Sdesfunc_sort_ver ()
1342348980Sdes{
1343348980Sdes    $debug_cmd
1344348980Sdes
1345348980Sdes    printf '%s\n%s\n' "$1" "$2" \
1346348980Sdes      | 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
1347348980Sdes}
1348348980Sdes
1349348980Sdes# func_lt_ver PREV CURR
1350348980Sdes# ---------------------
1351348980Sdes# Return true if PREV and CURR are in the correct order according to
1352348980Sdes# func_sort_ver, otherwise false.  Use it like this:
1353348980Sdes#
1354348980Sdes#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1355348980Sdesfunc_lt_ver ()
1356348980Sdes{
1357348980Sdes    $debug_cmd
1358348980Sdes
1359348980Sdes    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1360348980Sdes}
1361348980Sdes
1362348980Sdes
1363348980Sdes# Local variables:
1364348980Sdes# mode: shell-script
1365348980Sdes# sh-indentation: 2
1366348980Sdes# eval: (add-hook 'before-save-hook 'time-stamp)
1367348980Sdes# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1368348980Sdes# time-stamp-time-zone: "UTC"
1369348980Sdes# End:
1370348980Sdes#! /bin/sh
1371348980Sdes
1372348980Sdes# Set a version string for this script.
1373348980Sdesscriptversion=2014-01-07.03; # UTC
1374348980Sdes
1375348980Sdes# A portable, pluggable option parser for Bourne shell.
1376348980Sdes# Written by Gary V. Vaughan, 2010
1377348980Sdes
1378348980Sdes# Copyright (C) 2010-2015 Free Software Foundation, Inc.
1379348980Sdes# This is free software; see the source for copying conditions.  There is NO
1380348980Sdes# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1381348980Sdes
1382348980Sdes# This program is free software: you can redistribute it and/or modify
1383348980Sdes# it under the terms of the GNU General Public License as published by
1384348980Sdes# the Free Software Foundation, either version 3 of the License, or
1385348980Sdes# (at your option) any later version.
1386348980Sdes
1387348980Sdes# This program is distributed in the hope that it will be useful,
1388348980Sdes# but WITHOUT ANY WARRANTY; without even the implied warranty of
1389348980Sdes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1390348980Sdes# GNU General Public License for more details.
1391348980Sdes
1392348980Sdes# You should have received a copy of the GNU General Public License
1393348980Sdes# along with this program.  If not, see <http://www.gnu.org/licenses/>.
1394348980Sdes
1395348980Sdes# Please report bugs or propose patches to gary@gnu.org.
1396348980Sdes
1397348980Sdes
1398348980Sdes## ------ ##
1399348980Sdes## Usage. ##
1400348980Sdes## ------ ##
1401348980Sdes
1402348980Sdes# This file is a library for parsing options in your shell scripts along
1403348980Sdes# with assorted other useful supporting features that you can make use
1404348980Sdes# of too.
1405348980Sdes#
1406348980Sdes# For the simplest scripts you might need only:
1407348980Sdes#
1408348980Sdes#   #!/bin/sh
1409348980Sdes#   . relative/path/to/funclib.sh
1410348980Sdes#   . relative/path/to/options-parser
1411348980Sdes#   scriptversion=1.0
1412348980Sdes#   func_options ${1+"$@"}
1413348980Sdes#   eval set dummy "$func_options_result"; shift
1414348980Sdes#   ...rest of your script...
1415348980Sdes#
1416348980Sdes# In order for the '--version' option to work, you will need to have a
1417348980Sdes# suitably formatted comment like the one at the top of this file
1418348980Sdes# starting with '# Written by ' and ending with '# warranty; '.
1419348980Sdes#
1420348980Sdes# For '-h' and '--help' to work, you will also need a one line
1421348980Sdes# description of your script's purpose in a comment directly above the
1422348980Sdes# '# Written by ' line, like the one at the top of this file.
1423348980Sdes#
1424348980Sdes# The default options also support '--debug', which will turn on shell
1425348980Sdes# execution tracing (see the comment above debug_cmd below for another
1426348980Sdes# use), and '--verbose' and the func_verbose function to allow your script
1427348980Sdes# to display verbose messages only when your user has specified
1428348980Sdes# '--verbose'.
1429348980Sdes#
1430348980Sdes# After sourcing this file, you can plug processing for additional
1431348980Sdes# options by amending the variables from the 'Configuration' section
1432348980Sdes# below, and following the instructions in the 'Option parsing'
1433348980Sdes# section further down.
1434348980Sdes
1435348980Sdes## -------------- ##
1436348980Sdes## Configuration. ##
1437348980Sdes## -------------- ##
1438348980Sdes
1439348980Sdes# You should override these variables in your script after sourcing this
1440348980Sdes# file so that they reflect the customisations you have added to the
1441348980Sdes# option parser.
1442348980Sdes
1443348980Sdes# The usage line for option parsing errors and the start of '-h' and
1444348980Sdes# '--help' output messages. You can embed shell variables for delayed
1445348980Sdes# expansion at the time the message is displayed, but you will need to
1446348980Sdes# quote other shell meta-characters carefully to prevent them being
1447348980Sdes# expanded when the contents are evaled.
1448348980Sdesusage='$progpath [OPTION]...'
1449348980Sdes
1450348980Sdes# Short help message in response to '-h' and '--help'.  Add to this or
1451348980Sdes# override it after sourcing this library to reflect the full set of
1452348980Sdes# options your script accepts.
1453348980Sdesusage_message="\
1454348980Sdes       --debug        enable verbose shell tracing
1455348980Sdes   -W, --warnings=CATEGORY
1456348980Sdes                      report the warnings falling in CATEGORY [all]
1457348980Sdes   -v, --verbose      verbosely report processing
1458348980Sdes       --version      print version information and exit
1459348980Sdes   -h, --help         print short or long help message and exit
1460348980Sdes"
1461348980Sdes
1462348980Sdes# Additional text appended to 'usage_message' in response to '--help'.
1463348980Sdeslong_help_message="
1464348980SdesWarning categories include:
1465348980Sdes       'all'          show all warnings
1466348980Sdes       'none'         turn off all the warnings
1467348980Sdes       'error'        warnings are treated as fatal errors"
1468348980Sdes
1469348980Sdes# Help message printed before fatal option parsing errors.
1470348980Sdesfatal_help="Try '\$progname --help' for more information."
1471348980Sdes
1472348980Sdes
1473348980Sdes
1474348980Sdes## ------------------------- ##
1475348980Sdes## Hook function management. ##
1476348980Sdes## ------------------------- ##
1477348980Sdes
1478348980Sdes# This section contains functions for adding, removing, and running hooks
1479348980Sdes# to the main code.  A hook is just a named list of of function, that can
1480348980Sdes# be run in order later on.
1481348980Sdes
1482348980Sdes# func_hookable FUNC_NAME
1483348980Sdes# -----------------------
1484348980Sdes# Declare that FUNC_NAME will run hooks added with
1485348980Sdes# 'func_add_hook FUNC_NAME ...'.
1486348980Sdesfunc_hookable ()
1487348980Sdes{
1488348980Sdes    $debug_cmd
1489348980Sdes
1490348980Sdes    func_append hookable_fns " $1"
1491348980Sdes}
1492348980Sdes
1493348980Sdes
1494348980Sdes# func_add_hook FUNC_NAME HOOK_FUNC
1495348980Sdes# ---------------------------------
1496348980Sdes# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
1497348980Sdes# first have been declared "hookable" by a call to 'func_hookable'.
1498348980Sdesfunc_add_hook ()
1499348980Sdes{
1500348980Sdes    $debug_cmd
1501348980Sdes
1502348980Sdes    case " $hookable_fns " in
1503348980Sdes      *" $1 "*) ;;
1504348980Sdes      *) func_fatal_error "'$1' does not accept hook functions." ;;
1505348980Sdes    esac
1506348980Sdes
1507348980Sdes    eval func_append ${1}_hooks '" $2"'
1508348980Sdes}
1509348980Sdes
1510348980Sdes
1511348980Sdes# func_remove_hook FUNC_NAME HOOK_FUNC
1512348980Sdes# ------------------------------------
1513348980Sdes# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
1514348980Sdesfunc_remove_hook ()
1515348980Sdes{
1516348980Sdes    $debug_cmd
1517348980Sdes
1518348980Sdes    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1519348980Sdes}
1520348980Sdes
1521348980Sdes
1522348980Sdes# func_run_hooks FUNC_NAME [ARG]...
1523348980Sdes# ---------------------------------
1524348980Sdes# Run all hook functions registered to FUNC_NAME.
1525348980Sdes# It is assumed that the list of hook functions contains nothing more
1526348980Sdes# than a whitespace-delimited list of legal shell function names, and
1527348980Sdes# no effort is wasted trying to catch shell meta-characters or preserve
1528348980Sdes# whitespace.
1529348980Sdesfunc_run_hooks ()
1530348980Sdes{
1531348980Sdes    $debug_cmd
1532348980Sdes
1533348980Sdes    case " $hookable_fns " in
1534348980Sdes      *" $1 "*) ;;
1535348980Sdes      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
1536348980Sdes    esac
1537348980Sdes
1538348980Sdes    eval _G_hook_fns=\$$1_hooks; shift
1539348980Sdes
1540348980Sdes    for _G_hook in $_G_hook_fns; do
1541348980Sdes      eval $_G_hook '"$@"'
1542348980Sdes
1543348980Sdes      # store returned options list back into positional
1544348980Sdes      # parameters for next 'cmd' execution.
1545348980Sdes      eval _G_hook_result=\$${_G_hook}_result
1546348980Sdes      eval set dummy "$_G_hook_result"; shift
1547348980Sdes    done
1548348980Sdes
1549348980Sdes    func_quote_for_eval ${1+"$@"}
1550348980Sdes    func_run_hooks_result=$func_quote_for_eval_result
1551348980Sdes}
1552348980Sdes
1553348980Sdes
1554348980Sdes
1555348980Sdes## --------------- ##
1556348980Sdes## Option parsing. ##
1557348980Sdes## --------------- ##
1558348980Sdes
1559348980Sdes# In order to add your own option parsing hooks, you must accept the
1560348980Sdes# full positional parameter list in your hook function, remove any
1561348980Sdes# options that you action, and then pass back the remaining unprocessed
1562348980Sdes# options in '<hooked_function_name>_result', escaped suitably for
1563348980Sdes# 'eval'.  Like this:
1564348980Sdes#
1565348980Sdes#    my_options_prep ()
1566348980Sdes#    {
1567348980Sdes#        $debug_cmd
1568348980Sdes#
1569348980Sdes#        # Extend the existing usage message.
1570348980Sdes#        usage_message=$usage_message'
1571348980Sdes#      -s, --silent       don'\''t print informational messages
1572348980Sdes#    '
1573348980Sdes#
1574348980Sdes#        func_quote_for_eval ${1+"$@"}
1575348980Sdes#        my_options_prep_result=$func_quote_for_eval_result
1576348980Sdes#    }
1577348980Sdes#    func_add_hook func_options_prep my_options_prep
1578348980Sdes#
1579348980Sdes#
1580348980Sdes#    my_silent_option ()
1581348980Sdes#    {
1582348980Sdes#        $debug_cmd
1583348980Sdes#
1584348980Sdes#        # Note that for efficiency, we parse as many options as we can
1585348980Sdes#        # recognise in a loop before passing the remainder back to the
1586348980Sdes#        # caller on the first unrecognised argument we encounter.
1587348980Sdes#        while test $# -gt 0; do
1588348980Sdes#          opt=$1; shift
1589348980Sdes#          case $opt in
1590348980Sdes#            --silent|-s) opt_silent=: ;;
1591348980Sdes#            # Separate non-argument short options:
1592348980Sdes#            -s*)         func_split_short_opt "$_G_opt"
1593348980Sdes#                         set dummy "$func_split_short_opt_name" \
1594348980Sdes#                             "-$func_split_short_opt_arg" ${1+"$@"}
1595348980Sdes#                         shift
1596348980Sdes#                         ;;
1597348980Sdes#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
1598348980Sdes#          esac
1599348980Sdes#        done
1600348980Sdes#
1601348980Sdes#        func_quote_for_eval ${1+"$@"}
1602348980Sdes#        my_silent_option_result=$func_quote_for_eval_result
1603348980Sdes#    }
1604348980Sdes#    func_add_hook func_parse_options my_silent_option
1605348980Sdes#
1606348980Sdes#
1607348980Sdes#    my_option_validation ()
1608348980Sdes#    {
1609348980Sdes#        $debug_cmd
1610348980Sdes#
1611348980Sdes#        $opt_silent && $opt_verbose && func_fatal_help "\
1612348980Sdes#    '--silent' and '--verbose' options are mutually exclusive."
1613348980Sdes#
1614348980Sdes#        func_quote_for_eval ${1+"$@"}
1615348980Sdes#        my_option_validation_result=$func_quote_for_eval_result
1616348980Sdes#    }
1617348980Sdes#    func_add_hook func_validate_options my_option_validation
1618348980Sdes#
1619348980Sdes# You'll alse need to manually amend $usage_message to reflect the extra
1620348980Sdes# options you parse.  It's preferable to append if you can, so that
1621348980Sdes# multiple option parsing hooks can be added safely.
1622348980Sdes
1623348980Sdes
1624348980Sdes# func_options [ARG]...
1625348980Sdes# ---------------------
1626348980Sdes# All the functions called inside func_options are hookable. See the
1627348980Sdes# individual implementations for details.
1628348980Sdesfunc_hookable func_options
1629348980Sdesfunc_options ()
1630348980Sdes{
1631348980Sdes    $debug_cmd
1632348980Sdes
1633348980Sdes    func_options_prep ${1+"$@"}
1634348980Sdes    eval func_parse_options \
1635348980Sdes        ${func_options_prep_result+"$func_options_prep_result"}
1636348980Sdes    eval func_validate_options \
1637348980Sdes        ${func_parse_options_result+"$func_parse_options_result"}
1638348980Sdes
1639348980Sdes    eval func_run_hooks func_options \
1640348980Sdes        ${func_validate_options_result+"$func_validate_options_result"}
1641348980Sdes
1642348980Sdes    # save modified positional parameters for caller
1643348980Sdes    func_options_result=$func_run_hooks_result
1644348980Sdes}
1645348980Sdes
1646348980Sdes
1647348980Sdes# func_options_prep [ARG]...
1648348980Sdes# --------------------------
1649348980Sdes# All initialisations required before starting the option parse loop.
1650348980Sdes# Note that when calling hook functions, we pass through the list of
1651348980Sdes# positional parameters.  If a hook function modifies that list, and
1652348980Sdes# needs to propogate that back to rest of this script, then the complete
1653348980Sdes# modified list must be put in 'func_run_hooks_result' before
1654348980Sdes# returning.
1655348980Sdesfunc_hookable func_options_prep
1656348980Sdesfunc_options_prep ()
1657348980Sdes{
1658348980Sdes    $debug_cmd
1659348980Sdes
1660348980Sdes    # Option defaults:
1661348980Sdes    opt_verbose=false
1662348980Sdes    opt_warning_types=
1663348980Sdes
1664348980Sdes    func_run_hooks func_options_prep ${1+"$@"}
1665348980Sdes
1666348980Sdes    # save modified positional parameters for caller
1667348980Sdes    func_options_prep_result=$func_run_hooks_result
1668348980Sdes}
1669348980Sdes
1670348980Sdes
1671348980Sdes# func_parse_options [ARG]...
1672348980Sdes# ---------------------------
1673348980Sdes# The main option parsing loop.
1674348980Sdesfunc_hookable func_parse_options
1675348980Sdesfunc_parse_options ()
1676348980Sdes{
1677348980Sdes    $debug_cmd
1678348980Sdes
1679348980Sdes    func_parse_options_result=
1680348980Sdes
1681348980Sdes    # this just eases exit handling
1682348980Sdes    while test $# -gt 0; do
1683348980Sdes      # Defer to hook functions for initial option parsing, so they
1684348980Sdes      # get priority in the event of reusing an option name.
1685348980Sdes      func_run_hooks func_parse_options ${1+"$@"}
1686348980Sdes
1687348980Sdes      # Adjust func_parse_options positional parameters to match
1688348980Sdes      eval set dummy "$func_run_hooks_result"; shift
1689348980Sdes
1690348980Sdes      # Break out of the loop if we already parsed every option.
1691348980Sdes      test $# -gt 0 || break
1692348980Sdes
1693348980Sdes      _G_opt=$1
1694348980Sdes      shift
1695348980Sdes      case $_G_opt in
1696348980Sdes        --debug|-x)   debug_cmd='set -x'
1697348980Sdes                      func_echo "enabling shell trace mode"
1698348980Sdes                      $debug_cmd
1699348980Sdes                      ;;
1700348980Sdes
1701348980Sdes        --no-warnings|--no-warning|--no-warn)
1702348980Sdes                      set dummy --warnings none ${1+"$@"}
1703348980Sdes                      shift
1704348980Sdes		      ;;
1705348980Sdes
1706348980Sdes        --warnings|--warning|-W)
1707348980Sdes                      test $# = 0 && func_missing_arg $_G_opt && break
1708348980Sdes                      case " $warning_categories $1" in
1709348980Sdes                        *" $1 "*)
1710348980Sdes                          # trailing space prevents matching last $1 above
1711348980Sdes                          func_append_uniq opt_warning_types " $1"
1712348980Sdes                          ;;
1713348980Sdes                        *all)
1714348980Sdes                          opt_warning_types=$warning_categories
1715348980Sdes                          ;;
1716348980Sdes                        *none)
1717348980Sdes                          opt_warning_types=none
1718348980Sdes                          warning_func=:
1719348980Sdes                          ;;
1720348980Sdes                        *error)
1721348980Sdes                          opt_warning_types=$warning_categories
1722348980Sdes                          warning_func=func_fatal_error
1723348980Sdes                          ;;
1724348980Sdes                        *)
1725348980Sdes                          func_fatal_error \
1726348980Sdes                             "unsupported warning category: '$1'"
1727348980Sdes                          ;;
1728348980Sdes                      esac
1729348980Sdes                      shift
1730348980Sdes                      ;;
1731348980Sdes
1732348980Sdes        --verbose|-v) opt_verbose=: ;;
1733348980Sdes        --version)    func_version ;;
1734348980Sdes        -\?|-h)       func_usage ;;
1735348980Sdes        --help)       func_help ;;
1736348980Sdes
1737348980Sdes	# Separate optargs to long options (plugins may need this):
1738348980Sdes	--*=*)        func_split_equals "$_G_opt"
1739348980Sdes	              set dummy "$func_split_equals_lhs" \
1740348980Sdes                          "$func_split_equals_rhs" ${1+"$@"}
1741348980Sdes                      shift
1742348980Sdes                      ;;
1743348980Sdes
1744348980Sdes       # Separate optargs to short options:
1745348980Sdes        -W*)
1746348980Sdes                      func_split_short_opt "$_G_opt"
1747348980Sdes                      set dummy "$func_split_short_opt_name" \
1748348980Sdes                          "$func_split_short_opt_arg" ${1+"$@"}
1749348980Sdes                      shift
1750348980Sdes                      ;;
1751348980Sdes
1752348980Sdes        # Separate non-argument short options:
1753348980Sdes        -\?*|-h*|-v*|-x*)
1754348980Sdes                      func_split_short_opt "$_G_opt"
1755348980Sdes                      set dummy "$func_split_short_opt_name" \
1756348980Sdes                          "-$func_split_short_opt_arg" ${1+"$@"}
1757348980Sdes                      shift
1758348980Sdes                      ;;
1759348980Sdes
1760348980Sdes        --)           break ;;
1761348980Sdes        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
1762348980Sdes        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1763348980Sdes      esac
1764348980Sdes    done
1765348980Sdes
1766348980Sdes    # save modified positional parameters for caller
1767348980Sdes    func_quote_for_eval ${1+"$@"}
1768348980Sdes    func_parse_options_result=$func_quote_for_eval_result
1769348980Sdes}
1770348980Sdes
1771348980Sdes
1772348980Sdes# func_validate_options [ARG]...
1773348980Sdes# ------------------------------
1774348980Sdes# Perform any sanity checks on option settings and/or unconsumed
1775348980Sdes# arguments.
1776348980Sdesfunc_hookable func_validate_options
1777348980Sdesfunc_validate_options ()
1778348980Sdes{
1779348980Sdes    $debug_cmd
1780348980Sdes
1781348980Sdes    # Display all warnings if -W was not given.
1782348980Sdes    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1783348980Sdes
1784348980Sdes    func_run_hooks func_validate_options ${1+"$@"}
1785348980Sdes
1786348980Sdes    # Bail if the options were screwed!
1787348980Sdes    $exit_cmd $EXIT_FAILURE
1788348980Sdes
1789348980Sdes    # save modified positional parameters for caller
1790348980Sdes    func_validate_options_result=$func_run_hooks_result
1791348980Sdes}
1792348980Sdes
1793348980Sdes
1794348980Sdes
1795348980Sdes## ----------------- ##
1796348980Sdes## Helper functions. ##
1797348980Sdes## ----------------- ##
1798348980Sdes
1799348980Sdes# This section contains the helper functions used by the rest of the
1800348980Sdes# hookable option parser framework in ascii-betical order.
1801348980Sdes
1802348980Sdes
1803348980Sdes# func_fatal_help ARG...
1804348980Sdes# ----------------------
1805348980Sdes# Echo program name prefixed message to standard error, followed by
1806348980Sdes# a help hint, and exit.
1807348980Sdesfunc_fatal_help ()
1808348980Sdes{
1809348980Sdes    $debug_cmd
1810348980Sdes
1811348980Sdes    eval \$ECHO \""Usage: $usage"\"
1812348980Sdes    eval \$ECHO \""$fatal_help"\"
1813348980Sdes    func_error ${1+"$@"}
1814348980Sdes    exit $EXIT_FAILURE
1815348980Sdes}
1816348980Sdes
1817348980Sdes
1818348980Sdes# func_help
1819348980Sdes# ---------
1820348980Sdes# Echo long help message to standard output and exit.
1821228692Sdesfunc_help ()
1822228692Sdes{
1823348980Sdes    $debug_cmd
1824228692Sdes
1825348980Sdes    func_usage_message
1826348980Sdes    $ECHO "$long_help_message"
1827348980Sdes    exit 0
1828228692Sdes}
1829228692Sdes
1830348980Sdes
1831348980Sdes# func_missing_arg ARGNAME
1832348980Sdes# ------------------------
1833228692Sdes# Echo program name prefixed message to standard error and set global
1834228692Sdes# exit_cmd.
1835228692Sdesfunc_missing_arg ()
1836228692Sdes{
1837348980Sdes    $debug_cmd
1838228692Sdes
1839348980Sdes    func_error "Missing argument for '$1'."
1840228692Sdes    exit_cmd=exit
1841228692Sdes}
1842228692Sdes
1843228692Sdes
1844348980Sdes# func_split_equals STRING
1845348980Sdes# ------------------------
1846348980Sdes# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
1847348980Sdes# splitting STRING at the '=' sign.
1848348980Sdestest -z "$_G_HAVE_XSI_OPS" \
1849348980Sdes    && (eval 'x=a/b/c;
1850348980Sdes      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1851348980Sdes    && _G_HAVE_XSI_OPS=yes
1852348980Sdes
1853348980Sdesif test yes = "$_G_HAVE_XSI_OPS"
1854348980Sdesthen
1855348980Sdes  # This is an XSI compatible shell, allowing a faster implementation...
1856348980Sdes  eval 'func_split_equals ()
1857348980Sdes  {
1858348980Sdes      $debug_cmd
1859348980Sdes
1860348980Sdes      func_split_equals_lhs=${1%%=*}
1861348980Sdes      func_split_equals_rhs=${1#*=}
1862348980Sdes      test "x$func_split_equals_lhs" = "x$1" \
1863348980Sdes        && func_split_equals_rhs=
1864348980Sdes  }'
1865348980Sdeselse
1866348980Sdes  # ...otherwise fall back to using expr, which is often a shell builtin.
1867348980Sdes  func_split_equals ()
1868348980Sdes  {
1869348980Sdes      $debug_cmd
1870348980Sdes
1871348980Sdes      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
1872348980Sdes      func_split_equals_rhs=
1873348980Sdes      test "x$func_split_equals_lhs" = "x$1" \
1874348980Sdes        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
1875348980Sdes  }
1876348980Sdesfi #func_split_equals
1877348980Sdes
1878348980Sdes
1879348980Sdes# func_split_short_opt SHORTOPT
1880348980Sdes# -----------------------------
1881228692Sdes# Set func_split_short_opt_name and func_split_short_opt_arg shell
1882228692Sdes# variables after splitting SHORTOPT after the 2nd character.
1883348980Sdesif test yes = "$_G_HAVE_XSI_OPS"
1884348980Sdesthen
1885348980Sdes  # This is an XSI compatible shell, allowing a faster implementation...
1886348980Sdes  eval 'func_split_short_opt ()
1887348980Sdes  {
1888348980Sdes      $debug_cmd
1889348980Sdes
1890348980Sdes      func_split_short_opt_arg=${1#??}
1891348980Sdes      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1892348980Sdes  }'
1893348980Sdeselse
1894348980Sdes  # ...otherwise fall back to using expr, which is often a shell builtin.
1895348980Sdes  func_split_short_opt ()
1896348980Sdes  {
1897348980Sdes      $debug_cmd
1898348980Sdes
1899348980Sdes      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
1900348980Sdes      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
1901348980Sdes  }
1902348980Sdesfi #func_split_short_opt
1903348980Sdes
1904348980Sdes
1905348980Sdes# func_usage
1906348980Sdes# ----------
1907348980Sdes# Echo short help message to standard output and exit.
1908348980Sdesfunc_usage ()
1909228692Sdes{
1910348980Sdes    $debug_cmd
1911228692Sdes
1912348980Sdes    func_usage_message
1913348980Sdes    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
1914348980Sdes    exit 0
1915348980Sdes}
1916228692Sdes
1917228692Sdes
1918348980Sdes# func_usage_message
1919348980Sdes# ------------------
1920348980Sdes# Echo short help message to standard output.
1921348980Sdesfunc_usage_message ()
1922228692Sdes{
1923348980Sdes    $debug_cmd
1924228692Sdes
1925348980Sdes    eval \$ECHO \""Usage: $usage"\"
1926348980Sdes    echo
1927348980Sdes    $SED -n 's|^# ||
1928348980Sdes        /^Written by/{
1929348980Sdes          x;p;x
1930348980Sdes        }
1931348980Sdes	h
1932348980Sdes	/^Written by/q' < "$progpath"
1933348980Sdes    echo
1934348980Sdes    eval \$ECHO \""$usage_message"\"
1935348980Sdes}
1936228692Sdes
1937228692Sdes
1938348980Sdes# func_version
1939348980Sdes# ------------
1940348980Sdes# Echo version message to standard output and exit.
1941348980Sdesfunc_version ()
1942348980Sdes{
1943348980Sdes    $debug_cmd
1944228692Sdes
1945348980Sdes    printf '%s\n' "$progname $scriptversion"
1946348980Sdes    $SED -n '
1947348980Sdes        /(C)/!b go
1948348980Sdes        :more
1949348980Sdes        /\./!{
1950348980Sdes          N
1951348980Sdes          s|\n# | |
1952348980Sdes          b more
1953348980Sdes        }
1954348980Sdes        :go
1955348980Sdes        /^# Written by /,/# warranty; / {
1956348980Sdes          s|^# ||
1957348980Sdes          s|^# *$||
1958348980Sdes          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
1959348980Sdes          p
1960348980Sdes        }
1961348980Sdes        /^# Written by / {
1962348980Sdes          s|^# ||
1963348980Sdes          p
1964348980Sdes        }
1965348980Sdes        /^warranty; /q' < "$progpath"
1966228692Sdes
1967348980Sdes    exit $?
1968348980Sdes}
1969228692Sdes
1970228692Sdes
1971348980Sdes# Local variables:
1972348980Sdes# mode: shell-script
1973348980Sdes# sh-indentation: 2
1974348980Sdes# eval: (add-hook 'before-save-hook 'time-stamp)
1975348980Sdes# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1976348980Sdes# time-stamp-time-zone: "UTC"
1977348980Sdes# End:
1978228692Sdes
1979348980Sdes# Set a version string.
1980348980Sdesscriptversion='(GNU libtool) 2.4.6'
1981228692Sdes
1982228692Sdes
1983348980Sdes# func_echo ARG...
1984348980Sdes# ----------------
1985348980Sdes# Libtool also displays the current mode in messages, so override
1986348980Sdes# funclib.sh func_echo with this custom definition.
1987348980Sdesfunc_echo ()
1988228692Sdes{
1989348980Sdes    $debug_cmd
1990228692Sdes
1991348980Sdes    _G_message=$*
1992228692Sdes
1993348980Sdes    func_echo_IFS=$IFS
1994348980Sdes    IFS=$nl
1995348980Sdes    for _G_line in $_G_message; do
1996348980Sdes      IFS=$func_echo_IFS
1997348980Sdes      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
1998348980Sdes    done
1999348980Sdes    IFS=$func_echo_IFS
2000348980Sdes}
2001228692Sdes
2002348980Sdes
2003348980Sdes# func_warning ARG...
2004348980Sdes# -------------------
2005348980Sdes# Libtool warnings are not categorized, so override funclib.sh
2006348980Sdes# func_warning with this simpler definition.
2007348980Sdesfunc_warning ()
2008228692Sdes{
2009348980Sdes    $debug_cmd
2010228692Sdes
2011348980Sdes    $warning_func ${1+"$@"}
2012348980Sdes}
2013228692Sdes
2014228692Sdes
2015348980Sdes## ---------------- ##
2016348980Sdes## Options parsing. ##
2017348980Sdes## ---------------- ##
2018228692Sdes
2019348980Sdes# Hook in the functions to make sure our own options are parsed during
2020348980Sdes# the option parsing loop.
2021228692Sdes
2022348980Sdesusage='$progpath [OPTION]... [MODE-ARG]...'
2023228692Sdes
2024348980Sdes# Short help message in response to '-h'.
2025348980Sdesusage_message="Options:
2026348980Sdes       --config             show all configuration variables
2027348980Sdes       --debug              enable verbose shell tracing
2028348980Sdes   -n, --dry-run            display commands without modifying any files
2029348980Sdes       --features           display basic configuration information and exit
2030348980Sdes       --mode=MODE          use operation mode MODE
2031348980Sdes       --no-warnings        equivalent to '-Wnone'
2032348980Sdes       --preserve-dup-deps  don't remove duplicate dependency libraries
2033348980Sdes       --quiet, --silent    don't print informational messages
2034348980Sdes       --tag=TAG            use configuration variables from tag TAG
2035348980Sdes   -v, --verbose            print more informational messages than default
2036348980Sdes       --version            print version information
2037348980Sdes   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
2038348980Sdes   -h, --help, --help-all   print short, long, or detailed help message
2039348980Sdes"
2040348980Sdes
2041348980Sdes# Additional text appended to 'usage_message' in response to '--help'.
2042348980Sdesfunc_help ()
2043228692Sdes{
2044348980Sdes    $debug_cmd
2045228692Sdes
2046348980Sdes    func_usage_message
2047348980Sdes    $ECHO "$long_help_message
2048228692Sdes
2049348980SdesMODE must be one of the following:
2050348980Sdes
2051348980Sdes       clean           remove files from the build directory
2052348980Sdes       compile         compile a source file into a libtool object
2053348980Sdes       execute         automatically set library path, then run a program
2054348980Sdes       finish          complete the installation of libtool libraries
2055348980Sdes       install         install libraries or executables
2056348980Sdes       link            create a library or an executable
2057348980Sdes       uninstall       remove libraries from an installed directory
2058348980Sdes
2059348980SdesMODE-ARGS vary depending on the MODE.  When passed as first option,
2060348980Sdes'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2061348980SdesTry '$progname --help --mode=MODE' for a more detailed description of MODE.
2062348980Sdes
2063348980SdesWhen reporting a bug, please describe a test case to reproduce it and
2064348980Sdesinclude the following information:
2065348980Sdes
2066348980Sdes       host-triplet:   $host
2067348980Sdes       shell:          $SHELL
2068348980Sdes       compiler:       $LTCC
2069348980Sdes       compiler flags: $LTCFLAGS
2070348980Sdes       linker:         $LD (gnu? $with_gnu_ld)
2071348980Sdes       version:        $progname (GNU libtool) 2.4.6
2072348980Sdes       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2073348980Sdes       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2074348980Sdes
2075348980SdesReport bugs to <bug-libtool@gnu.org>.
2076348980SdesGNU libtool home page: <http://www.gnu.org/software/libtool/>.
2077348980SdesGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
2078348980Sdes    exit 0
2079348980Sdes}
2080348980Sdes
2081348980Sdes
2082348980Sdes# func_lo2o OBJECT-NAME
2083348980Sdes# ---------------------
2084348980Sdes# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2085348980Sdes# object suffix.
2086348980Sdes
2087348980Sdeslo2o=s/\\.lo\$/.$objext/
2088348980Sdeso2lo=s/\\.$objext\$/.lo/
2089348980Sdes
2090348980Sdesif test yes = "$_G_HAVE_XSI_OPS"; then
2091348980Sdes  eval 'func_lo2o ()
2092348980Sdes  {
2093348980Sdes    case $1 in
2094348980Sdes      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
2095348980Sdes      *   ) func_lo2o_result=$1               ;;
2096348980Sdes    esac
2097348980Sdes  }'
2098348980Sdes
2099348980Sdes  # func_xform LIBOBJ-OR-SOURCE
2100348980Sdes  # ---------------------------
2101348980Sdes  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2102348980Sdes  # suffix to a '.lo' libtool-object suffix.
2103348980Sdes  eval 'func_xform ()
2104348980Sdes  {
2105348980Sdes    func_xform_result=${1%.*}.lo
2106348980Sdes  }'
2107348980Sdeselse
2108348980Sdes  # ...otherwise fall back to using sed.
2109348980Sdes  func_lo2o ()
2110348980Sdes  {
2111348980Sdes    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2112348980Sdes  }
2113348980Sdes
2114348980Sdes  func_xform ()
2115348980Sdes  {
2116348980Sdes    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2117348980Sdes  }
2118348980Sdesfi
2119348980Sdes
2120348980Sdes
2121348980Sdes# func_fatal_configuration ARG...
2122348980Sdes# -------------------------------
2123228692Sdes# Echo program name prefixed message to standard error, followed by
2124228692Sdes# a configuration failure hint, and exit.
2125228692Sdesfunc_fatal_configuration ()
2126228692Sdes{
2127348980Sdes    func__fatal_error ${1+"$@"} \
2128348980Sdes      "See the $PACKAGE documentation for more information." \
2129348980Sdes      "Fatal configuration error."
2130228692Sdes}
2131228692Sdes
2132228692Sdes
2133228692Sdes# func_config
2134348980Sdes# -----------
2135228692Sdes# Display the configuration for all the tags in this script.
2136228692Sdesfunc_config ()
2137228692Sdes{
2138228692Sdes    re_begincf='^# ### BEGIN LIBTOOL'
2139228692Sdes    re_endcf='^# ### END LIBTOOL'
2140228692Sdes
2141228692Sdes    # Default configuration.
2142228692Sdes    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
2143228692Sdes
2144228692Sdes    # Now print the configurations for the tags.
2145228692Sdes    for tagname in $taglist; do
2146228692Sdes      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2147228692Sdes    done
2148228692Sdes
2149228692Sdes    exit $?
2150228692Sdes}
2151228692Sdes
2152348980Sdes
2153228692Sdes# func_features
2154348980Sdes# -------------
2155228692Sdes# Display the features supported by this script.
2156228692Sdesfunc_features ()
2157228692Sdes{
2158228692Sdes    echo "host: $host"
2159348980Sdes    if test yes = "$build_libtool_libs"; then
2160228692Sdes      echo "enable shared libraries"
2161228692Sdes    else
2162228692Sdes      echo "disable shared libraries"
2163228692Sdes    fi
2164348980Sdes    if test yes = "$build_old_libs"; then
2165228692Sdes      echo "enable static libraries"
2166228692Sdes    else
2167228692Sdes      echo "disable static libraries"
2168228692Sdes    fi
2169228692Sdes
2170228692Sdes    exit $?
2171228692Sdes}
2172228692Sdes
2173348980Sdes
2174348980Sdes# func_enable_tag TAGNAME
2175348980Sdes# -----------------------
2176228692Sdes# Verify that TAGNAME is valid, and either flag an error and exit, or
2177228692Sdes# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
2178228692Sdes# variable here.
2179228692Sdesfunc_enable_tag ()
2180228692Sdes{
2181348980Sdes    # Global variable:
2182348980Sdes    tagname=$1
2183228692Sdes
2184348980Sdes    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
2185348980Sdes    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
2186348980Sdes    sed_extractcf=/$re_begincf/,/$re_endcf/p
2187228692Sdes
2188348980Sdes    # Validate tagname.
2189348980Sdes    case $tagname in
2190348980Sdes      *[!-_A-Za-z0-9,/]*)
2191348980Sdes        func_fatal_error "invalid tag name: $tagname"
2192348980Sdes        ;;
2193348980Sdes    esac
2194228692Sdes
2195348980Sdes    # Don't test for the "default" C tag, as we know it's
2196348980Sdes    # there but not specially marked.
2197348980Sdes    case $tagname in
2198348980Sdes        CC) ;;
2199228692Sdes    *)
2200348980Sdes        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
2201348980Sdes	  taglist="$taglist $tagname"
2202228692Sdes
2203348980Sdes	  # Evaluate the configuration.  Be careful to quote the path
2204348980Sdes	  # and the sed script, to avoid splitting on whitespace, but
2205348980Sdes	  # also don't use non-portable quotes within backquotes within
2206348980Sdes	  # quotes we have to do it in 2 steps:
2207348980Sdes	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
2208348980Sdes	  eval "$extractedcf"
2209348980Sdes        else
2210348980Sdes	  func_error "ignoring unknown tag $tagname"
2211348980Sdes        fi
2212348980Sdes        ;;
2213348980Sdes    esac
2214228692Sdes}
2215228692Sdes
2216348980Sdes
2217228692Sdes# func_check_version_match
2218348980Sdes# ------------------------
2219228692Sdes# Ensure that we are using m4 macros, and libtool script from the same
2220228692Sdes# release of libtool.
2221228692Sdesfunc_check_version_match ()
2222228692Sdes{
2223348980Sdes    if test "$package_revision" != "$macro_revision"; then
2224348980Sdes      if test "$VERSION" != "$macro_version"; then
2225348980Sdes        if test -z "$macro_version"; then
2226348980Sdes          cat >&2 <<_LT_EOF
2227228692Sdes$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2228228692Sdes$progname: definition of this LT_INIT comes from an older release.
2229228692Sdes$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2230228692Sdes$progname: and run autoconf again.
2231228692Sdes_LT_EOF
2232348980Sdes        else
2233348980Sdes          cat >&2 <<_LT_EOF
2234228692Sdes$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2235228692Sdes$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2236228692Sdes$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2237228692Sdes$progname: and run autoconf again.
2238228692Sdes_LT_EOF
2239348980Sdes        fi
2240348980Sdes      else
2241348980Sdes        cat >&2 <<_LT_EOF
2242228692Sdes$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
2243228692Sdes$progname: but the definition of this LT_INIT comes from revision $macro_revision.
2244228692Sdes$progname: You should recreate aclocal.m4 with macros from revision $package_revision
2245228692Sdes$progname: of $PACKAGE $VERSION and run autoconf again.
2246228692Sdes_LT_EOF
2247348980Sdes      fi
2248348980Sdes
2249348980Sdes      exit $EXIT_MISMATCH
2250228692Sdes    fi
2251228692Sdes}
2252228692Sdes
2253228692Sdes
2254348980Sdes# libtool_options_prep [ARG]...
2255348980Sdes# -----------------------------
2256348980Sdes# Preparation for options parsed by libtool.
2257348980Sdeslibtool_options_prep ()
2258348980Sdes{
2259348980Sdes    $debug_mode
2260228692Sdes
2261348980Sdes    # Option defaults:
2262348980Sdes    opt_config=false
2263348980Sdes    opt_dlopen=
2264348980Sdes    opt_dry_run=false
2265348980Sdes    opt_help=false
2266348980Sdes    opt_mode=
2267348980Sdes    opt_preserve_dup_deps=false
2268348980Sdes    opt_quiet=false
2269228692Sdes
2270348980Sdes    nonopt=
2271348980Sdes    preserve_args=
2272228692Sdes
2273348980Sdes    # Shorthand for --mode=foo, only valid as the first argument
2274348980Sdes    case $1 in
2275348980Sdes    clean|clea|cle|cl)
2276348980Sdes      shift; set dummy --mode clean ${1+"$@"}; shift
2277348980Sdes      ;;
2278348980Sdes    compile|compil|compi|comp|com|co|c)
2279348980Sdes      shift; set dummy --mode compile ${1+"$@"}; shift
2280348980Sdes      ;;
2281348980Sdes    execute|execut|execu|exec|exe|ex|e)
2282348980Sdes      shift; set dummy --mode execute ${1+"$@"}; shift
2283348980Sdes      ;;
2284348980Sdes    finish|finis|fini|fin|fi|f)
2285348980Sdes      shift; set dummy --mode finish ${1+"$@"}; shift
2286348980Sdes      ;;
2287348980Sdes    install|instal|insta|inst|ins|in|i)
2288348980Sdes      shift; set dummy --mode install ${1+"$@"}; shift
2289348980Sdes      ;;
2290348980Sdes    link|lin|li|l)
2291348980Sdes      shift; set dummy --mode link ${1+"$@"}; shift
2292348980Sdes      ;;
2293348980Sdes    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
2294348980Sdes      shift; set dummy --mode uninstall ${1+"$@"}; shift
2295348980Sdes      ;;
2296348980Sdes    esac
2297228692Sdes
2298348980Sdes    # Pass back the list of options.
2299348980Sdes    func_quote_for_eval ${1+"$@"}
2300348980Sdes    libtool_options_prep_result=$func_quote_for_eval_result
2301348980Sdes}
2302348980Sdesfunc_add_hook func_options_prep libtool_options_prep
2303228692Sdes
2304348980Sdes
2305348980Sdes# libtool_parse_options [ARG]...
2306348980Sdes# ---------------------------------
2307348980Sdes# Provide handling for libtool specific options.
2308348980Sdeslibtool_parse_options ()
2309228692Sdes{
2310348980Sdes    $debug_cmd
2311228692Sdes
2312348980Sdes    # Perform our own loop to consume as many options as possible in
2313348980Sdes    # each iteration.
2314348980Sdes    while test $# -gt 0; do
2315348980Sdes      _G_opt=$1
2316348980Sdes      shift
2317348980Sdes      case $_G_opt in
2318348980Sdes        --dry-run|--dryrun|-n)
2319348980Sdes                        opt_dry_run=:
2320348980Sdes                        ;;
2321228692Sdes
2322348980Sdes        --config)       func_config ;;
2323228692Sdes
2324348980Sdes        --dlopen|-dlopen)
2325348980Sdes                        opt_dlopen="${opt_dlopen+$opt_dlopen
2326348980Sdes}$1"
2327348980Sdes                        shift
2328348980Sdes                        ;;
2329228692Sdes
2330348980Sdes        --preserve-dup-deps)
2331348980Sdes                        opt_preserve_dup_deps=: ;;
2332228692Sdes
2333348980Sdes        --features)     func_features ;;
2334228692Sdes
2335348980Sdes        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
2336228692Sdes
2337348980Sdes        --help)         opt_help=: ;;
2338228692Sdes
2339348980Sdes        --help-all)     opt_help=': help-all' ;;
2340228692Sdes
2341348980Sdes        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
2342348980Sdes                        opt_mode=$1
2343348980Sdes                        case $1 in
2344348980Sdes                          # Valid mode arguments:
2345348980Sdes                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
2346228692Sdes
2347348980Sdes                          # Catch anything else as an error
2348348980Sdes                          *) func_error "invalid argument for $_G_opt"
2349348980Sdes                             exit_cmd=exit
2350348980Sdes                             break
2351348980Sdes                             ;;
2352348980Sdes                        esac
2353348980Sdes                        shift
2354348980Sdes                        ;;
2355228692Sdes
2356348980Sdes        --no-silent|--no-quiet)
2357348980Sdes                        opt_quiet=false
2358348980Sdes                        func_append preserve_args " $_G_opt"
2359348980Sdes                        ;;
2360228692Sdes
2361348980Sdes        --no-warnings|--no-warning|--no-warn)
2362348980Sdes                        opt_warning=false
2363348980Sdes                        func_append preserve_args " $_G_opt"
2364348980Sdes                        ;;
2365228692Sdes
2366348980Sdes        --no-verbose)
2367348980Sdes                        opt_verbose=false
2368348980Sdes                        func_append preserve_args " $_G_opt"
2369348980Sdes                        ;;
2370348980Sdes
2371348980Sdes        --silent|--quiet)
2372348980Sdes                        opt_quiet=:
2373348980Sdes                        opt_verbose=false
2374348980Sdes                        func_append preserve_args " $_G_opt"
2375348980Sdes                        ;;
2376348980Sdes
2377348980Sdes        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
2378348980Sdes                        opt_tag=$1
2379348980Sdes                        func_append preserve_args " $_G_opt $1"
2380348980Sdes                        func_enable_tag "$1"
2381348980Sdes                        shift
2382348980Sdes                        ;;
2383348980Sdes
2384348980Sdes        --verbose|-v)   opt_quiet=false
2385348980Sdes                        opt_verbose=:
2386348980Sdes                        func_append preserve_args " $_G_opt"
2387348980Sdes                        ;;
2388348980Sdes
2389348980Sdes	# An option not handled by this hook function:
2390348980Sdes        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
2391348980Sdes      esac
2392348980Sdes    done
2393348980Sdes
2394348980Sdes
2395348980Sdes    # save modified positional parameters for caller
2396348980Sdes    func_quote_for_eval ${1+"$@"}
2397348980Sdes    libtool_parse_options_result=$func_quote_for_eval_result
2398348980Sdes}
2399348980Sdesfunc_add_hook func_parse_options libtool_parse_options
2400348980Sdes
2401348980Sdes
2402348980Sdes
2403348980Sdes# libtool_validate_options [ARG]...
2404348980Sdes# ---------------------------------
2405348980Sdes# Perform any sanity checks on option settings and/or unconsumed
2406348980Sdes# arguments.
2407348980Sdeslibtool_validate_options ()
2408348980Sdes{
2409348980Sdes    # save first non-option argument
2410348980Sdes    if test 0 -lt $#; then
2411348980Sdes      nonopt=$1
2412348980Sdes      shift
2413228692Sdes    fi
2414228692Sdes
2415348980Sdes    # preserve --debug
2416348980Sdes    test : = "$debug_cmd" || func_append preserve_args " --debug"
2417228692Sdes
2418348980Sdes    case $host in
2419348980Sdes      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
2420348980Sdes      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
2421348980Sdes      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
2422348980Sdes        # don't eliminate duplications in $postdeps and $predeps
2423348980Sdes        opt_duplicate_compiler_generated_deps=:
2424348980Sdes        ;;
2425348980Sdes      *)
2426348980Sdes        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
2427348980Sdes        ;;
2428348980Sdes    esac
2429228692Sdes
2430348980Sdes    $opt_help || {
2431348980Sdes      # Sanity checks first:
2432348980Sdes      func_check_version_match
2433348980Sdes
2434348980Sdes      test yes != "$build_libtool_libs" \
2435348980Sdes        && test yes != "$build_old_libs" \
2436348980Sdes        && func_fatal_configuration "not configured to build any kind of library"
2437348980Sdes
2438348980Sdes      # Darwin sucks
2439348980Sdes      eval std_shrext=\"$shrext_cmds\"
2440348980Sdes
2441348980Sdes      # Only execute mode is allowed to have -dlopen flags.
2442348980Sdes      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
2443348980Sdes        func_error "unrecognized option '-dlopen'"
2444348980Sdes        $ECHO "$help" 1>&2
2445348980Sdes        exit $EXIT_FAILURE
2446348980Sdes      fi
2447348980Sdes
2448348980Sdes      # Change the help message to a mode-specific one.
2449348980Sdes      generic_help=$help
2450348980Sdes      help="Try '$progname --help --mode=$opt_mode' for more information."
2451348980Sdes    }
2452348980Sdes
2453348980Sdes    # Pass back the unparsed argument list
2454348980Sdes    func_quote_for_eval ${1+"$@"}
2455348980Sdes    libtool_validate_options_result=$func_quote_for_eval_result
2456228692Sdes}
2457348980Sdesfunc_add_hook func_validate_options libtool_validate_options
2458228692Sdes
2459228692Sdes
2460348980Sdes# Process options as early as possible so that --help and --version
2461348980Sdes# can return quickly.
2462348980Sdesfunc_options ${1+"$@"}
2463348980Sdeseval set dummy "$func_options_result"; shift
2464228692Sdes
2465228692Sdes
2466348980Sdes
2467228692Sdes## ----------- ##
2468228692Sdes##    Main.    ##
2469228692Sdes## ----------- ##
2470228692Sdes
2471348980Sdesmagic='%%%MAGIC variable%%%'
2472348980Sdesmagic_exe='%%%MAGIC EXE variable%%%'
2473348980Sdes
2474348980Sdes# Global variables.
2475348980Sdesextracted_archives=
2476348980Sdesextracted_serial=0
2477348980Sdes
2478348980Sdes# If this variable is set in any of the actions, the command in it
2479348980Sdes# will be execed at the end.  This prevents here-documents from being
2480348980Sdes# left over by shells.
2481348980Sdesexec_cmd=
2482348980Sdes
2483348980Sdes
2484348980Sdes# A function that is used when there is no print builtin or printf.
2485348980Sdesfunc_fallback_echo ()
2486348980Sdes{
2487348980Sdes  eval 'cat <<_LTECHO_EOF
2488348980Sdes$1
2489348980Sdes_LTECHO_EOF'
2490348980Sdes}
2491348980Sdes
2492348980Sdes# func_generated_by_libtool
2493348980Sdes# True iff stdin has been generated by Libtool. This function is only
2494348980Sdes# a basic sanity check; it will hardly flush out determined imposters.
2495348980Sdesfunc_generated_by_libtool_p ()
2496348980Sdes{
2497348980Sdes  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
2498348980Sdes}
2499348980Sdes
2500228692Sdes# func_lalib_p file
2501348980Sdes# True iff FILE is a libtool '.la' library or '.lo' object file.
2502228692Sdes# This function is only a basic sanity check; it will hardly flush out
2503228692Sdes# determined imposters.
2504228692Sdesfunc_lalib_p ()
2505228692Sdes{
2506228692Sdes    test -f "$1" &&
2507348980Sdes      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
2508228692Sdes}
2509228692Sdes
2510228692Sdes# func_lalib_unsafe_p file
2511348980Sdes# True iff FILE is a libtool '.la' library or '.lo' object file.
2512228692Sdes# This function implements the same check as func_lalib_p without
2513228692Sdes# resorting to external programs.  To this end, it redirects stdin and
2514228692Sdes# closes it afterwards, without saving the original file descriptor.
2515228692Sdes# As a safety measure, use it only where a negative result would be
2516348980Sdes# fatal anyway.  Works if 'file' does not exist.
2517228692Sdesfunc_lalib_unsafe_p ()
2518228692Sdes{
2519228692Sdes    lalib_p=no
2520228692Sdes    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
2521228692Sdes	for lalib_p_l in 1 2 3 4
2522228692Sdes	do
2523228692Sdes	    read lalib_p_line
2524348980Sdes	    case $lalib_p_line in
2525228692Sdes		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
2526228692Sdes	    esac
2527228692Sdes	done
2528228692Sdes	exec 0<&5 5<&-
2529228692Sdes    fi
2530348980Sdes    test yes = "$lalib_p"
2531228692Sdes}
2532228692Sdes
2533228692Sdes# func_ltwrapper_script_p file
2534228692Sdes# True iff FILE is a libtool wrapper script
2535228692Sdes# This function is only a basic sanity check; it will hardly flush out
2536228692Sdes# determined imposters.
2537228692Sdesfunc_ltwrapper_script_p ()
2538228692Sdes{
2539348980Sdes    test -f "$1" &&
2540348980Sdes      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
2541228692Sdes}
2542228692Sdes
2543228692Sdes# func_ltwrapper_executable_p file
2544228692Sdes# True iff FILE is a libtool wrapper executable
2545228692Sdes# This function is only a basic sanity check; it will hardly flush out
2546228692Sdes# determined imposters.
2547228692Sdesfunc_ltwrapper_executable_p ()
2548228692Sdes{
2549228692Sdes    func_ltwrapper_exec_suffix=
2550228692Sdes    case $1 in
2551228692Sdes    *.exe) ;;
2552228692Sdes    *) func_ltwrapper_exec_suffix=.exe ;;
2553228692Sdes    esac
2554228692Sdes    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
2555228692Sdes}
2556228692Sdes
2557228692Sdes# func_ltwrapper_scriptname file
2558228692Sdes# Assumes file is an ltwrapper_executable
2559228692Sdes# uses $file to determine the appropriate filename for a
2560228692Sdes# temporary ltwrapper_script.
2561228692Sdesfunc_ltwrapper_scriptname ()
2562228692Sdes{
2563228692Sdes    func_dirname_and_basename "$1" "" "."
2564228692Sdes    func_stripname '' '.exe' "$func_basename_result"
2565348980Sdes    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
2566228692Sdes}
2567228692Sdes
2568228692Sdes# func_ltwrapper_p file
2569228692Sdes# True iff FILE is a libtool wrapper script or wrapper executable
2570228692Sdes# This function is only a basic sanity check; it will hardly flush out
2571228692Sdes# determined imposters.
2572228692Sdesfunc_ltwrapper_p ()
2573228692Sdes{
2574228692Sdes    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
2575228692Sdes}
2576228692Sdes
2577228692Sdes
2578228692Sdes# func_execute_cmds commands fail_cmd
2579228692Sdes# Execute tilde-delimited COMMANDS.
2580228692Sdes# If FAIL_CMD is given, eval that upon failure.
2581228692Sdes# FAIL_CMD may read-access the current command in variable CMD!
2582228692Sdesfunc_execute_cmds ()
2583228692Sdes{
2584348980Sdes    $debug_cmd
2585348980Sdes
2586228692Sdes    save_ifs=$IFS; IFS='~'
2587228692Sdes    for cmd in $1; do
2588348980Sdes      IFS=$sp$nl
2589348980Sdes      eval cmd=\"$cmd\"
2590228692Sdes      IFS=$save_ifs
2591228692Sdes      func_show_eval "$cmd" "${2-:}"
2592228692Sdes    done
2593228692Sdes    IFS=$save_ifs
2594228692Sdes}
2595228692Sdes
2596228692Sdes
2597228692Sdes# func_source file
2598228692Sdes# Source FILE, adding directory component if necessary.
2599228692Sdes# Note that it is not necessary on cygwin/mingw to append a dot to
2600228692Sdes# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
2601228692Sdes# behavior happens only for exec(3), not for open(2)!  Also, sourcing
2602348980Sdes# 'FILE.' does not work on cygwin managed mounts.
2603228692Sdesfunc_source ()
2604228692Sdes{
2605348980Sdes    $debug_cmd
2606348980Sdes
2607228692Sdes    case $1 in
2608228692Sdes    */* | *\\*)	. "$1" ;;
2609228692Sdes    *)		. "./$1" ;;
2610228692Sdes    esac
2611228692Sdes}
2612228692Sdes
2613228692Sdes
2614228692Sdes# func_resolve_sysroot PATH
2615228692Sdes# Replace a leading = in PATH with a sysroot.  Store the result into
2616228692Sdes# func_resolve_sysroot_result
2617228692Sdesfunc_resolve_sysroot ()
2618228692Sdes{
2619228692Sdes  func_resolve_sysroot_result=$1
2620228692Sdes  case $func_resolve_sysroot_result in
2621228692Sdes  =*)
2622228692Sdes    func_stripname '=' '' "$func_resolve_sysroot_result"
2623228692Sdes    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2624141098Sdes    ;;
2625141098Sdes  esac
2626141098Sdes}
2627141098Sdes
2628228692Sdes# func_replace_sysroot PATH
2629228692Sdes# If PATH begins with the sysroot, replace it with = and
2630228692Sdes# store the result into func_replace_sysroot_result.
2631228692Sdesfunc_replace_sysroot ()
2632228692Sdes{
2633348980Sdes  case $lt_sysroot:$1 in
2634228692Sdes  ?*:"$lt_sysroot"*)
2635228692Sdes    func_stripname "$lt_sysroot" '' "$1"
2636348980Sdes    func_replace_sysroot_result='='$func_stripname_result
2637228692Sdes    ;;
2638228692Sdes  *)
2639228692Sdes    # Including no sysroot.
2640228692Sdes    func_replace_sysroot_result=$1
2641228692Sdes    ;;
2642228692Sdes  esac
2643228692Sdes}
2644141098Sdes
2645141098Sdes# func_infer_tag arg
2646141098Sdes# Infer tagged configuration to use if any are available and
2647141098Sdes# if one wasn't chosen via the "--tag" command line option.
2648141098Sdes# Only attempt this if the compiler in the base compile
2649141098Sdes# command doesn't match the default compiler.
2650141098Sdes# arg is usually of the form 'gcc ...'
2651147455Sdesfunc_infer_tag ()
2652147455Sdes{
2653348980Sdes    $debug_cmd
2654228692Sdes
2655141098Sdes    if test -n "$available_tags" && test -z "$tagname"; then
2656141098Sdes      CC_quoted=
2657141098Sdes      for arg in $CC; do
2658228692Sdes	func_append_quoted CC_quoted "$arg"
2659141098Sdes      done
2660228692Sdes      CC_expanded=`func_echo_all $CC`
2661228692Sdes      CC_quoted_expanded=`func_echo_all $CC_quoted`
2662141098Sdes      case $@ in
2663141098Sdes      # Blanks in the command may have been stripped by the calling shell,
2664141098Sdes      # but not from the CC environment variable when configure was run.
2665228692Sdes      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2666228692Sdes      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
2667141098Sdes      # Blanks at the start of $base_compile will cause this to fail
2668141098Sdes      # if we don't check for them as well.
2669141098Sdes      *)
2670141098Sdes	for z in $available_tags; do
2671228692Sdes	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2672141098Sdes	    # Evaluate the configuration.
2673348980Sdes	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2674141098Sdes	    CC_quoted=
2675141098Sdes	    for arg in $CC; do
2676228692Sdes	      # Double-quote args containing other shell metacharacters.
2677228692Sdes	      func_append_quoted CC_quoted "$arg"
2678228692Sdes	    done
2679228692Sdes	    CC_expanded=`func_echo_all $CC`
2680228692Sdes	    CC_quoted_expanded=`func_echo_all $CC_quoted`
2681141098Sdes	    case "$@ " in
2682228692Sdes	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2683228692Sdes	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
2684141098Sdes	      # The compiler in the base compile command matches
2685141098Sdes	      # the one in the tagged configuration.
2686141098Sdes	      # Assume this is the tagged configuration we want.
2687141098Sdes	      tagname=$z
2688141098Sdes	      break
2689141098Sdes	      ;;
2690141098Sdes	    esac
2691348980Sdes	  fi
2692141098Sdes	done
2693141098Sdes	# If $tagname still isn't set, then no tagged configuration
2694141098Sdes	# was found and let the user know that the "--tag" command
2695141098Sdes	# line option must be used.
2696141098Sdes	if test -z "$tagname"; then
2697228692Sdes	  func_echo "unable to infer tagged configuration"
2698348980Sdes	  func_fatal_error "specify a tag with '--tag'"
2699228692Sdes#	else
2700228692Sdes#	  func_verbose "using $tagname tagged configuration"
2701141098Sdes	fi
2702141098Sdes	;;
2703141098Sdes      esac
2704141098Sdes    fi
2705141098Sdes}
2706141098Sdes
2707141098Sdes
2708228692Sdes
2709228692Sdes# func_write_libtool_object output_name pic_name nonpic_name
2710228692Sdes# Create a libtool object file (analogous to a ".la" file),
2711228692Sdes# but don't create it if we're doing a dry run.
2712228692Sdesfunc_write_libtool_object ()
2713147455Sdes{
2714348980Sdes    write_libobj=$1
2715348980Sdes    if test yes = "$build_libtool_libs"; then
2716348980Sdes      write_lobj=\'$2\'
2717228692Sdes    else
2718228692Sdes      write_lobj=none
2719228692Sdes    fi
2720147455Sdes
2721348980Sdes    if test yes = "$build_old_libs"; then
2722348980Sdes      write_oldobj=\'$3\'
2723147455Sdes    else
2724228692Sdes      write_oldobj=none
2725147455Sdes    fi
2726228692Sdes
2727228692Sdes    $opt_dry_run || {
2728228692Sdes      cat >${write_libobj}T <<EOF
2729228692Sdes# $write_libobj - a libtool object file
2730348980Sdes# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2731228692Sdes#
2732228692Sdes# Please DO NOT delete this file!
2733228692Sdes# It is necessary for linking the library.
2734228692Sdes
2735228692Sdes# Name of the PIC object.
2736228692Sdespic_object=$write_lobj
2737228692Sdes
2738228692Sdes# Name of the non-PIC object
2739228692Sdesnon_pic_object=$write_oldobj
2740228692Sdes
2741228692SdesEOF
2742348980Sdes      $MV "${write_libobj}T" "$write_libobj"
2743228692Sdes    }
2744147455Sdes}
2745147455Sdes
2746228692Sdes
2747228692Sdes##################################################
2748228692Sdes# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2749228692Sdes##################################################
2750228692Sdes
2751228692Sdes# func_convert_core_file_wine_to_w32 ARG
2752228692Sdes# Helper function used by file name conversion functions when $build is *nix,
2753228692Sdes# and $host is mingw, cygwin, or some other w32 environment. Relies on a
2754228692Sdes# correctly configured wine environment available, with the winepath program
2755228692Sdes# in $build's $PATH.
2756228692Sdes#
2757228692Sdes# ARG is the $build file name to be converted to w32 format.
2758228692Sdes# Result is available in $func_convert_core_file_wine_to_w32_result, and will
2759228692Sdes# be empty on error (or when ARG is empty)
2760228692Sdesfunc_convert_core_file_wine_to_w32 ()
2761147455Sdes{
2762348980Sdes  $debug_cmd
2763348980Sdes
2764348980Sdes  func_convert_core_file_wine_to_w32_result=$1
2765228692Sdes  if test -n "$1"; then
2766228692Sdes    # Unfortunately, winepath does not exit with a non-zero error code, so we
2767228692Sdes    # are forced to check the contents of stdout. On the other hand, if the
2768228692Sdes    # command is not found, the shell will set an exit code of 127 and print
2769228692Sdes    # *an error message* to stdout. So we must check for both error code of
2770228692Sdes    # zero AND non-empty stdout, which explains the odd construction:
2771228692Sdes    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
2772348980Sdes    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2773228692Sdes      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
2774348980Sdes        $SED -e "$sed_naive_backslashify"`
2775228692Sdes    else
2776228692Sdes      func_convert_core_file_wine_to_w32_result=
2777141098Sdes    fi
2778228692Sdes  fi
2779228692Sdes}
2780228692Sdes# end: func_convert_core_file_wine_to_w32
2781141098Sdes
2782141098Sdes
2783228692Sdes# func_convert_core_path_wine_to_w32 ARG
2784228692Sdes# Helper function used by path conversion functions when $build is *nix, and
2785228692Sdes# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2786228692Sdes# configured wine environment available, with the winepath program in $build's
2787228692Sdes# $PATH. Assumes ARG has no leading or trailing path separator characters.
2788228692Sdes#
2789228692Sdes# ARG is path to be converted from $build format to win32.
2790228692Sdes# Result is available in $func_convert_core_path_wine_to_w32_result.
2791228692Sdes# Unconvertible file (directory) names in ARG are skipped; if no directory names
2792228692Sdes# are convertible, then the result may be empty.
2793228692Sdesfunc_convert_core_path_wine_to_w32 ()
2794228692Sdes{
2795348980Sdes  $debug_cmd
2796348980Sdes
2797228692Sdes  # unfortunately, winepath doesn't convert paths, only file names
2798348980Sdes  func_convert_core_path_wine_to_w32_result=
2799228692Sdes  if test -n "$1"; then
2800228692Sdes    oldIFS=$IFS
2801228692Sdes    IFS=:
2802228692Sdes    for func_convert_core_path_wine_to_w32_f in $1; do
2803228692Sdes      IFS=$oldIFS
2804228692Sdes      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
2805348980Sdes      if test -n "$func_convert_core_file_wine_to_w32_result"; then
2806228692Sdes        if test -z "$func_convert_core_path_wine_to_w32_result"; then
2807348980Sdes          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2808228692Sdes        else
2809228692Sdes          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2810228692Sdes        fi
2811141098Sdes      fi
2812141098Sdes    done
2813228692Sdes    IFS=$oldIFS
2814228692Sdes  fi
2815141098Sdes}
2816228692Sdes# end: func_convert_core_path_wine_to_w32
2817141098Sdes
2818141098Sdes
2819228692Sdes# func_cygpath ARGS...
2820228692Sdes# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2821228692Sdes# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2822228692Sdes# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2823228692Sdes# (2), returns the Cygwin file name or path in func_cygpath_result (input
2824228692Sdes# file name or path is assumed to be in w32 format, as previously converted
2825228692Sdes# from $build's *nix or MSYS format). In case (3), returns the w32 file name
2826228692Sdes# or path in func_cygpath_result (input file name or path is assumed to be in
2827228692Sdes# Cygwin format). Returns an empty string on error.
2828228692Sdes#
2829228692Sdes# ARGS are passed to cygpath, with the last one being the file name or path to
2830228692Sdes# be converted.
2831228692Sdes#
2832228692Sdes# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2833228692Sdes# environment variable; do not put it in $PATH.
2834228692Sdesfunc_cygpath ()
2835228692Sdes{
2836348980Sdes  $debug_cmd
2837348980Sdes
2838228692Sdes  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2839228692Sdes    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2840228692Sdes    if test "$?" -ne 0; then
2841228692Sdes      # on failure, ensure result is empty
2842228692Sdes      func_cygpath_result=
2843228692Sdes    fi
2844228692Sdes  else
2845228692Sdes    func_cygpath_result=
2846348980Sdes    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2847228692Sdes  fi
2848228692Sdes}
2849228692Sdes#end: func_cygpath
2850174832Sdes
2851117610Sdes
2852228692Sdes# func_convert_core_msys_to_w32 ARG
2853228692Sdes# Convert file name or path ARG from MSYS format to w32 format.  Return
2854228692Sdes# result in func_convert_core_msys_to_w32_result.
2855228692Sdesfunc_convert_core_msys_to_w32 ()
2856228692Sdes{
2857348980Sdes  $debug_cmd
2858348980Sdes
2859228692Sdes  # awkward: cmd appends spaces to result
2860228692Sdes  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
2861348980Sdes    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2862228692Sdes}
2863228692Sdes#end: func_convert_core_msys_to_w32
2864228692Sdes
2865228692Sdes
2866228692Sdes# func_convert_file_check ARG1 ARG2
2867228692Sdes# Verify that ARG1 (a file name in $build format) was converted to $host
2868228692Sdes# format in ARG2. Otherwise, emit an error message, but continue (resetting
2869228692Sdes# func_to_host_file_result to ARG1).
2870228692Sdesfunc_convert_file_check ()
2871228692Sdes{
2872348980Sdes  $debug_cmd
2873348980Sdes
2874348980Sdes  if test -z "$2" && test -n "$1"; then
2875228692Sdes    func_error "Could not determine host file name corresponding to"
2876348980Sdes    func_error "  '$1'"
2877228692Sdes    func_error "Continuing, but uninstalled executables may not work."
2878228692Sdes    # Fallback:
2879348980Sdes    func_to_host_file_result=$1
2880228692Sdes  fi
2881228692Sdes}
2882228692Sdes# end func_convert_file_check
2883228692Sdes
2884228692Sdes
2885228692Sdes# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2886228692Sdes# Verify that FROM_PATH (a path in $build format) was converted to $host
2887228692Sdes# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2888228692Sdes# func_to_host_file_result to a simplistic fallback value (see below).
2889228692Sdesfunc_convert_path_check ()
2890228692Sdes{
2891348980Sdes  $debug_cmd
2892348980Sdes
2893228692Sdes  if test -z "$4" && test -n "$3"; then
2894228692Sdes    func_error "Could not determine the host path corresponding to"
2895348980Sdes    func_error "  '$3'"
2896228692Sdes    func_error "Continuing, but uninstalled executables may not work."
2897228692Sdes    # Fallback.  This is a deliberately simplistic "conversion" and
2898228692Sdes    # should not be "improved".  See libtool.info.
2899228692Sdes    if test "x$1" != "x$2"; then
2900228692Sdes      lt_replace_pathsep_chars="s|$1|$2|g"
2901228692Sdes      func_to_host_path_result=`echo "$3" |
2902228692Sdes        $SED -e "$lt_replace_pathsep_chars"`
2903228692Sdes    else
2904348980Sdes      func_to_host_path_result=$3
2905228692Sdes    fi
2906228692Sdes  fi
2907228692Sdes}
2908228692Sdes# end func_convert_path_check
2909228692Sdes
2910228692Sdes
2911228692Sdes# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2912228692Sdes# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2913228692Sdes# and appending REPL if ORIG matches BACKPAT.
2914228692Sdesfunc_convert_path_front_back_pathsep ()
2915228692Sdes{
2916348980Sdes  $debug_cmd
2917348980Sdes
2918228692Sdes  case $4 in
2919348980Sdes  $1 ) func_to_host_path_result=$3$func_to_host_path_result
2920228692Sdes    ;;
2921117610Sdes  esac
2922228692Sdes  case $4 in
2923228692Sdes  $2 ) func_append func_to_host_path_result "$3"
2924228692Sdes    ;;
2925228692Sdes  esac
2926228692Sdes}
2927228692Sdes# end func_convert_path_front_back_pathsep
2928117610Sdes
2929141098Sdes
2930228692Sdes##################################################
2931228692Sdes# $build to $host FILE NAME CONVERSION FUNCTIONS #
2932228692Sdes##################################################
2933348980Sdes# invoked via '$to_host_file_cmd ARG'
2934228692Sdes#
2935228692Sdes# In each case, ARG is the path to be converted from $build to $host format.
2936228692Sdes# Result will be available in $func_to_host_file_result.
2937141098Sdes
2938228692Sdes
2939228692Sdes# func_to_host_file ARG
2940228692Sdes# Converts the file name ARG from $build format to $host format. Return result
2941228692Sdes# in func_to_host_file_result.
2942228692Sdesfunc_to_host_file ()
2943228692Sdes{
2944348980Sdes  $debug_cmd
2945348980Sdes
2946228692Sdes  $to_host_file_cmd "$1"
2947228692Sdes}
2948228692Sdes# end func_to_host_file
2949228692Sdes
2950228692Sdes
2951228692Sdes# func_to_tool_file ARG LAZY
2952228692Sdes# converts the file name ARG from $build format to toolchain format. Return
2953228692Sdes# result in func_to_tool_file_result.  If the conversion in use is listed
2954228692Sdes# in (the comma separated) LAZY, no conversion takes place.
2955228692Sdesfunc_to_tool_file ()
2956228692Sdes{
2957348980Sdes  $debug_cmd
2958348980Sdes
2959228692Sdes  case ,$2, in
2960228692Sdes    *,"$to_tool_file_cmd",*)
2961228692Sdes      func_to_tool_file_result=$1
2962141098Sdes      ;;
2963117610Sdes    *)
2964228692Sdes      $to_tool_file_cmd "$1"
2965228692Sdes      func_to_tool_file_result=$func_to_host_file_result
2966117610Sdes      ;;
2967228692Sdes  esac
2968228692Sdes}
2969228692Sdes# end func_to_tool_file
2970117610Sdes
2971228692Sdes
2972228692Sdes# func_convert_file_noop ARG
2973228692Sdes# Copy ARG to func_to_host_file_result.
2974228692Sdesfunc_convert_file_noop ()
2975228692Sdes{
2976348980Sdes  func_to_host_file_result=$1
2977228692Sdes}
2978228692Sdes# end func_convert_file_noop
2979228692Sdes
2980228692Sdes
2981228692Sdes# func_convert_file_msys_to_w32 ARG
2982228692Sdes# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
2983228692Sdes# conversion to w32 is not available inside the cwrapper.  Returns result in
2984228692Sdes# func_to_host_file_result.
2985228692Sdesfunc_convert_file_msys_to_w32 ()
2986228692Sdes{
2987348980Sdes  $debug_cmd
2988348980Sdes
2989348980Sdes  func_to_host_file_result=$1
2990228692Sdes  if test -n "$1"; then
2991228692Sdes    func_convert_core_msys_to_w32 "$1"
2992348980Sdes    func_to_host_file_result=$func_convert_core_msys_to_w32_result
2993117610Sdes  fi
2994228692Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
2995228692Sdes}
2996228692Sdes# end func_convert_file_msys_to_w32
2997117610Sdes
2998117610Sdes
2999228692Sdes# func_convert_file_cygwin_to_w32 ARG
3000228692Sdes# Convert file name ARG from Cygwin to w32 format.  Returns result in
3001228692Sdes# func_to_host_file_result.
3002228692Sdesfunc_convert_file_cygwin_to_w32 ()
3003228692Sdes{
3004348980Sdes  $debug_cmd
3005348980Sdes
3006348980Sdes  func_to_host_file_result=$1
3007228692Sdes  if test -n "$1"; then
3008228692Sdes    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3009228692Sdes    # LT_CYGPATH in this case.
3010228692Sdes    func_to_host_file_result=`cygpath -m "$1"`
3011228692Sdes  fi
3012228692Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
3013228692Sdes}
3014228692Sdes# end func_convert_file_cygwin_to_w32
3015174832Sdes
3016117610Sdes
3017228692Sdes# func_convert_file_nix_to_w32 ARG
3018228692Sdes# Convert file name ARG from *nix to w32 format.  Requires a wine environment
3019228692Sdes# and a working winepath. Returns result in func_to_host_file_result.
3020228692Sdesfunc_convert_file_nix_to_w32 ()
3021228692Sdes{
3022348980Sdes  $debug_cmd
3023348980Sdes
3024348980Sdes  func_to_host_file_result=$1
3025228692Sdes  if test -n "$1"; then
3026228692Sdes    func_convert_core_file_wine_to_w32 "$1"
3027348980Sdes    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3028228692Sdes  fi
3029228692Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
3030228692Sdes}
3031228692Sdes# end func_convert_file_nix_to_w32
3032117610Sdes
3033117610Sdes
3034228692Sdes# func_convert_file_msys_to_cygwin ARG
3035228692Sdes# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3036228692Sdes# Returns result in func_to_host_file_result.
3037228692Sdesfunc_convert_file_msys_to_cygwin ()
3038228692Sdes{
3039348980Sdes  $debug_cmd
3040348980Sdes
3041348980Sdes  func_to_host_file_result=$1
3042228692Sdes  if test -n "$1"; then
3043228692Sdes    func_convert_core_msys_to_w32 "$1"
3044228692Sdes    func_cygpath -u "$func_convert_core_msys_to_w32_result"
3045348980Sdes    func_to_host_file_result=$func_cygpath_result
3046228692Sdes  fi
3047228692Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
3048228692Sdes}
3049228692Sdes# end func_convert_file_msys_to_cygwin
3050117610Sdes
3051117610Sdes
3052228692Sdes# func_convert_file_nix_to_cygwin ARG
3053228692Sdes# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
3054228692Sdes# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
3055228692Sdes# in func_to_host_file_result.
3056228692Sdesfunc_convert_file_nix_to_cygwin ()
3057228692Sdes{
3058348980Sdes  $debug_cmd
3059348980Sdes
3060348980Sdes  func_to_host_file_result=$1
3061228692Sdes  if test -n "$1"; then
3062228692Sdes    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3063228692Sdes    func_convert_core_file_wine_to_w32 "$1"
3064228692Sdes    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
3065348980Sdes    func_to_host_file_result=$func_cygpath_result
3066228692Sdes  fi
3067228692Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
3068228692Sdes}
3069228692Sdes# end func_convert_file_nix_to_cygwin
3070117610Sdes
3071117610Sdes
3072228692Sdes#############################################
3073228692Sdes# $build to $host PATH CONVERSION FUNCTIONS #
3074228692Sdes#############################################
3075348980Sdes# invoked via '$to_host_path_cmd ARG'
3076228692Sdes#
3077228692Sdes# In each case, ARG is the path to be converted from $build to $host format.
3078228692Sdes# The result will be available in $func_to_host_path_result.
3079228692Sdes#
3080228692Sdes# Path separators are also converted from $build format to $host format.  If
3081228692Sdes# ARG begins or ends with a path separator character, it is preserved (but
3082228692Sdes# converted to $host format) on output.
3083228692Sdes#
3084228692Sdes# All path conversion functions are named using the following convention:
3085228692Sdes#   file name conversion function    : func_convert_file_X_to_Y ()
3086228692Sdes#   path conversion function         : func_convert_path_X_to_Y ()
3087228692Sdes# where, for any given $build/$host combination the 'X_to_Y' value is the
3088228692Sdes# same.  If conversion functions are added for new $build/$host combinations,
3089228692Sdes# the two new functions must follow this pattern, or func_init_to_host_path_cmd
3090228692Sdes# will break.
3091125647Sdes
3092117610Sdes
3093228692Sdes# func_init_to_host_path_cmd
3094228692Sdes# Ensures that function "pointer" variable $to_host_path_cmd is set to the
3095228692Sdes# appropriate value, based on the value of $to_host_file_cmd.
3096228692Sdesto_host_path_cmd=
3097228692Sdesfunc_init_to_host_path_cmd ()
3098228692Sdes{
3099348980Sdes  $debug_cmd
3100348980Sdes
3101228692Sdes  if test -z "$to_host_path_cmd"; then
3102228692Sdes    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
3103348980Sdes    to_host_path_cmd=func_convert_path_$func_stripname_result
3104228692Sdes  fi
3105228692Sdes}
3106141098Sdes
3107117610Sdes
3108228692Sdes# func_to_host_path ARG
3109228692Sdes# Converts the path ARG from $build format to $host format. Return result
3110228692Sdes# in func_to_host_path_result.
3111228692Sdesfunc_to_host_path ()
3112228692Sdes{
3113348980Sdes  $debug_cmd
3114348980Sdes
3115228692Sdes  func_init_to_host_path_cmd
3116228692Sdes  $to_host_path_cmd "$1"
3117228692Sdes}
3118228692Sdes# end func_to_host_path
3119117610Sdes
3120117610Sdes
3121228692Sdes# func_convert_path_noop ARG
3122228692Sdes# Copy ARG to func_to_host_path_result.
3123228692Sdesfunc_convert_path_noop ()
3124228692Sdes{
3125348980Sdes  func_to_host_path_result=$1
3126228692Sdes}
3127228692Sdes# end func_convert_path_noop
3128117610Sdes
3129174832Sdes
3130228692Sdes# func_convert_path_msys_to_w32 ARG
3131228692Sdes# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3132228692Sdes# conversion to w32 is not available inside the cwrapper.  Returns result in
3133228692Sdes# func_to_host_path_result.
3134228692Sdesfunc_convert_path_msys_to_w32 ()
3135228692Sdes{
3136348980Sdes  $debug_cmd
3137348980Sdes
3138348980Sdes  func_to_host_path_result=$1
3139228692Sdes  if test -n "$1"; then
3140228692Sdes    # Remove leading and trailing path separator characters from ARG.  MSYS
3141228692Sdes    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3142228692Sdes    # and winepath ignores them completely.
3143228692Sdes    func_stripname : : "$1"
3144228692Sdes    func_to_host_path_tmp1=$func_stripname_result
3145228692Sdes    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3146348980Sdes    func_to_host_path_result=$func_convert_core_msys_to_w32_result
3147228692Sdes    func_convert_path_check : ";" \
3148228692Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3149228692Sdes    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3150228692Sdes  fi
3151228692Sdes}
3152228692Sdes# end func_convert_path_msys_to_w32
3153125647Sdes
3154117610Sdes
3155228692Sdes# func_convert_path_cygwin_to_w32 ARG
3156228692Sdes# Convert path ARG from Cygwin to w32 format.  Returns result in
3157228692Sdes# func_to_host_file_result.
3158228692Sdesfunc_convert_path_cygwin_to_w32 ()
3159228692Sdes{
3160348980Sdes  $debug_cmd
3161348980Sdes
3162348980Sdes  func_to_host_path_result=$1
3163228692Sdes  if test -n "$1"; then
3164228692Sdes    # See func_convert_path_msys_to_w32:
3165228692Sdes    func_stripname : : "$1"
3166228692Sdes    func_to_host_path_tmp1=$func_stripname_result
3167228692Sdes    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3168228692Sdes    func_convert_path_check : ";" \
3169228692Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3170228692Sdes    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3171228692Sdes  fi
3172228692Sdes}
3173228692Sdes# end func_convert_path_cygwin_to_w32
3174117610Sdes
3175228692Sdes
3176228692Sdes# func_convert_path_nix_to_w32 ARG
3177228692Sdes# Convert path ARG from *nix to w32 format.  Requires a wine environment and
3178228692Sdes# a working winepath.  Returns result in func_to_host_file_result.
3179228692Sdesfunc_convert_path_nix_to_w32 ()
3180228692Sdes{
3181348980Sdes  $debug_cmd
3182348980Sdes
3183348980Sdes  func_to_host_path_result=$1
3184228692Sdes  if test -n "$1"; then
3185228692Sdes    # See func_convert_path_msys_to_w32:
3186228692Sdes    func_stripname : : "$1"
3187228692Sdes    func_to_host_path_tmp1=$func_stripname_result
3188228692Sdes    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3189348980Sdes    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3190228692Sdes    func_convert_path_check : ";" \
3191228692Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3192228692Sdes    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3193117610Sdes  fi
3194228692Sdes}
3195228692Sdes# end func_convert_path_nix_to_w32
3196117610Sdes
3197228692Sdes
3198228692Sdes# func_convert_path_msys_to_cygwin ARG
3199228692Sdes# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3200228692Sdes# Returns result in func_to_host_file_result.
3201228692Sdesfunc_convert_path_msys_to_cygwin ()
3202228692Sdes{
3203348980Sdes  $debug_cmd
3204348980Sdes
3205348980Sdes  func_to_host_path_result=$1
3206228692Sdes  if test -n "$1"; then
3207228692Sdes    # See func_convert_path_msys_to_w32:
3208228692Sdes    func_stripname : : "$1"
3209228692Sdes    func_to_host_path_tmp1=$func_stripname_result
3210228692Sdes    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3211228692Sdes    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
3212348980Sdes    func_to_host_path_result=$func_cygpath_result
3213228692Sdes    func_convert_path_check : : \
3214228692Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3215228692Sdes    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3216117610Sdes  fi
3217228692Sdes}
3218228692Sdes# end func_convert_path_msys_to_cygwin
3219117610Sdes
3220117610Sdes
3221228692Sdes# func_convert_path_nix_to_cygwin ARG
3222228692Sdes# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
3223228692Sdes# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
3224228692Sdes# func_to_host_file_result.
3225228692Sdesfunc_convert_path_nix_to_cygwin ()
3226228692Sdes{
3227348980Sdes  $debug_cmd
3228348980Sdes
3229348980Sdes  func_to_host_path_result=$1
3230228692Sdes  if test -n "$1"; then
3231228692Sdes    # Remove leading and trailing path separator characters from
3232228692Sdes    # ARG. msys behavior is inconsistent here, cygpath turns them
3233228692Sdes    # into '.;' and ';.', and winepath ignores them completely.
3234228692Sdes    func_stripname : : "$1"
3235228692Sdes    func_to_host_path_tmp1=$func_stripname_result
3236228692Sdes    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3237228692Sdes    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
3238348980Sdes    func_to_host_path_result=$func_cygpath_result
3239228692Sdes    func_convert_path_check : : \
3240228692Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3241228692Sdes    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3242228692Sdes  fi
3243228692Sdes}
3244228692Sdes# end func_convert_path_nix_to_cygwin
3245228692Sdes
3246228692Sdes
3247348980Sdes# func_dll_def_p FILE
3248348980Sdes# True iff FILE is a Windows DLL '.def' file.
3249348980Sdes# Keep in sync with _LT_DLL_DEF_P in libtool.m4
3250348980Sdesfunc_dll_def_p ()
3251348980Sdes{
3252348980Sdes  $debug_cmd
3253348980Sdes
3254348980Sdes  func_dll_def_p_tmp=`$SED -n \
3255348980Sdes    -e 's/^[	 ]*//' \
3256348980Sdes    -e '/^\(;.*\)*$/d' \
3257348980Sdes    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
3258348980Sdes    -e q \
3259348980Sdes    "$1"`
3260348980Sdes  test DEF = "$func_dll_def_p_tmp"
3261348980Sdes}
3262348980Sdes
3263348980Sdes
3264228692Sdes# func_mode_compile arg...
3265228692Sdesfunc_mode_compile ()
3266228692Sdes{
3267348980Sdes    $debug_cmd
3268348980Sdes
3269117610Sdes    # Get the compilation command and the source file.
3270117610Sdes    base_compile=
3271348980Sdes    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
3272141098Sdes    suppress_opt=yes
3273117610Sdes    suppress_output=
3274141098Sdes    arg_mode=normal
3275141098Sdes    libobj=
3276141098Sdes    later=
3277228692Sdes    pie_flag=
3278117610Sdes
3279117610Sdes    for arg
3280117610Sdes    do
3281174832Sdes      case $arg_mode in
3282141098Sdes      arg  )
3283141098Sdes	# do not "continue".  Instead, add this to base_compile
3284348980Sdes	lastarg=$arg
3285141098Sdes	arg_mode=normal
3286141098Sdes	;;
3287125647Sdes
3288141098Sdes      target )
3289348980Sdes	libobj=$arg
3290141098Sdes	arg_mode=normal
3291125647Sdes	continue
3292125647Sdes	;;
3293125647Sdes
3294141098Sdes      normal )
3295141098Sdes	# Accept any command-line options.
3296141098Sdes	case $arg in
3297141098Sdes	-o)
3298228692Sdes	  test -n "$libobj" && \
3299348980Sdes	    func_fatal_error "you cannot specify '-o' more than once"
3300141098Sdes	  arg_mode=target
3301141098Sdes	  continue
3302141098Sdes	  ;;
3303117610Sdes
3304228692Sdes	-pie | -fpie | -fPIE)
3305228692Sdes          func_append pie_flag " $arg"
3306141098Sdes	  continue
3307141098Sdes	  ;;
3308125647Sdes
3309228692Sdes	-shared | -static | -prefer-pic | -prefer-non-pic)
3310228692Sdes	  func_append later " $arg"
3311228692Sdes	  continue
3312228692Sdes	  ;;
3313228692Sdes
3314141098Sdes	-no-suppress)
3315141098Sdes	  suppress_opt=no
3316141098Sdes	  continue
3317141098Sdes	  ;;
3318125647Sdes
3319141098Sdes	-Xcompiler)
3320141098Sdes	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
3321141098Sdes	  continue      #  The current "srcfile" will either be retained or
3322141098Sdes	  ;;            #  replaced later.  I would guess that would be a bug.
3323125647Sdes
3324141098Sdes	-Wc,*)
3325228692Sdes	  func_stripname '-Wc,' '' "$arg"
3326228692Sdes	  args=$func_stripname_result
3327141098Sdes	  lastarg=
3328348980Sdes	  save_ifs=$IFS; IFS=,
3329228692Sdes	  for arg in $args; do
3330348980Sdes	    IFS=$save_ifs
3331228692Sdes	    func_append_quoted lastarg "$arg"
3332141098Sdes	  done
3333348980Sdes	  IFS=$save_ifs
3334228692Sdes	  func_stripname ' ' '' "$lastarg"
3335228692Sdes	  lastarg=$func_stripname_result
3336125647Sdes
3337141098Sdes	  # Add the arguments to base_compile.
3338228692Sdes	  func_append base_compile " $lastarg"
3339141098Sdes	  continue
3340141098Sdes	  ;;
3341117610Sdes
3342228692Sdes	*)
3343141098Sdes	  # Accept the current argument as the source file.
3344141098Sdes	  # The previous "srcfile" becomes the current argument.
3345141098Sdes	  #
3346348980Sdes	  lastarg=$srcfile
3347348980Sdes	  srcfile=$arg
3348141098Sdes	  ;;
3349141098Sdes	esac  #  case $arg
3350117610Sdes	;;
3351141098Sdes      esac    #  case $arg_mode
3352117610Sdes
3353117610Sdes      # Aesthetically quote the previous argument.
3354228692Sdes      func_append_quoted base_compile "$lastarg"
3355141098Sdes    done # for arg
3356117610Sdes
3357141098Sdes    case $arg_mode in
3358141098Sdes    arg)
3359228692Sdes      func_fatal_error "you must specify an argument for -Xcompile"
3360117610Sdes      ;;
3361141098Sdes    target)
3362348980Sdes      func_fatal_error "you must specify a target with '-o'"
3363117610Sdes      ;;
3364117610Sdes    *)
3365141098Sdes      # Get the name of the library object.
3366228692Sdes      test -z "$libobj" && {
3367228692Sdes	func_basename "$srcfile"
3368348980Sdes	libobj=$func_basename_result
3369228692Sdes      }
3370117610Sdes      ;;
3371117610Sdes    esac
3372117610Sdes
3373117610Sdes    # Recognize several different file suffixes.
3374117610Sdes    # If the user specifies -o file.o, it is replaced with file.lo
3375125647Sdes    case $libobj in
3376228692Sdes    *.[cCFSifmso] | \
3377228692Sdes    *.ada | *.adb | *.ads | *.asm | \
3378228692Sdes    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3379236109Sdes    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
3380228692Sdes      func_xform "$libobj"
3381228692Sdes      libobj=$func_xform_result
3382228692Sdes      ;;
3383117610Sdes    esac
3384117610Sdes
3385125647Sdes    case $libobj in
3386228692Sdes    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3387117610Sdes    *)
3388348980Sdes      func_fatal_error "cannot determine name of library object from '$libobj'"
3389117610Sdes      ;;
3390117610Sdes    esac
3391117610Sdes
3392141098Sdes    func_infer_tag $base_compile
3393141098Sdes
3394141098Sdes    for arg in $later; do
3395141098Sdes      case $arg in
3396228692Sdes      -shared)
3397348980Sdes	test yes = "$build_libtool_libs" \
3398348980Sdes	  || func_fatal_configuration "cannot build a shared library"
3399228692Sdes	build_old_libs=no
3400228692Sdes	continue
3401228692Sdes	;;
3402228692Sdes
3403141098Sdes      -static)
3404228692Sdes	build_libtool_libs=no
3405141098Sdes	build_old_libs=yes
3406141098Sdes	continue
3407141098Sdes	;;
3408141098Sdes
3409141098Sdes      -prefer-pic)
3410141098Sdes	pic_mode=yes
3411141098Sdes	continue
3412141098Sdes	;;
3413141098Sdes
3414141098Sdes      -prefer-non-pic)
3415141098Sdes	pic_mode=no
3416141098Sdes	continue
3417141098Sdes	;;
3418141098Sdes      esac
3419141098Sdes    done
3420141098Sdes
3421228692Sdes    func_quote_for_eval "$libobj"
3422228692Sdes    test "X$libobj" != "X$func_quote_for_eval_result" \
3423228692Sdes      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
3424348980Sdes      && func_warning "libobj name '$libobj' may not contain shell special characters."
3425228692Sdes    func_dirname_and_basename "$obj" "/" ""
3426348980Sdes    objname=$func_basename_result
3427348980Sdes    xdir=$func_dirname_result
3428348980Sdes    lobj=$xdir$objdir/$objname
3429141098Sdes
3430228692Sdes    test -z "$base_compile" && \
3431228692Sdes      func_fatal_help "you must specify a compilation command"
3432117610Sdes
3433117610Sdes    # Delete any leftover library objects.
3434348980Sdes    if test yes = "$build_old_libs"; then
3435141098Sdes      removelist="$obj $lobj $libobj ${libobj}T"
3436117610Sdes    else
3437141098Sdes      removelist="$lobj $libobj ${libobj}T"
3438117610Sdes    fi
3439117610Sdes
3440125647Sdes    # On Cygwin there's no "real" PIC flag so we must build both object types
3441125647Sdes    case $host_os in
3442228692Sdes    cygwin* | mingw* | pw32* | os2* | cegcc*)
3443125647Sdes      pic_mode=default
3444125647Sdes      ;;
3445125647Sdes    esac
3446348980Sdes    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3447125647Sdes      # non-PIC code in shared libraries is not supported
3448125647Sdes      pic_mode=default
3449125647Sdes    fi
3450125647Sdes
3451117610Sdes    # Calculate the filename of the output object if compiler does
3452117610Sdes    # not support -o with -c
3453348980Sdes    if test no = "$compiler_c_o"; then
3454348980Sdes      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
3455348980Sdes      lockfile=$output_obj.lock
3456117610Sdes    else
3457141098Sdes      output_obj=
3458117610Sdes      need_locks=no
3459117610Sdes      lockfile=
3460117610Sdes    fi
3461117610Sdes
3462117610Sdes    # Lock this critical section if it is needed
3463117610Sdes    # We use this script file to make the link, it avoids creating a new file
3464348980Sdes    if test yes = "$need_locks"; then
3465228692Sdes      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3466228692Sdes	func_echo "Waiting for $lockfile to be removed"
3467117610Sdes	sleep 2
3468117610Sdes      done
3469348980Sdes    elif test warn = "$need_locks"; then
3470117610Sdes      if test -f "$lockfile"; then
3471228692Sdes	$ECHO "\
3472117610Sdes*** ERROR, $lockfile exists and contains:
3473117610Sdes`cat $lockfile 2>/dev/null`
3474117610Sdes
3475117610SdesThis indicates that another process is trying to use the same
3476117610Sdestemporary object file, and libtool could not work around it because
3477348980Sdesyour compiler does not support '-c' and '-o' together.  If you
3478117610Sdesrepeat this compilation, it may succeed, by chance, but you had better
3479117610Sdesavoid parallel builds (make -j) in this platform, or get a better
3480117610Sdescompiler."
3481117610Sdes
3482228692Sdes	$opt_dry_run || $RM $removelist
3483141098Sdes	exit $EXIT_FAILURE
3484117610Sdes      fi
3485228692Sdes      func_append removelist " $output_obj"
3486228692Sdes      $ECHO "$srcfile" > "$lockfile"
3487117610Sdes    fi
3488117610Sdes
3489228692Sdes    $opt_dry_run || $RM $removelist
3490228692Sdes    func_append removelist " $lockfile"
3491228692Sdes    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
3492117610Sdes
3493228692Sdes    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3494228692Sdes    srcfile=$func_to_tool_file_result
3495228692Sdes    func_quote_for_eval "$srcfile"
3496228692Sdes    qsrcfile=$func_quote_for_eval_result
3497141098Sdes
3498117610Sdes    # Only build a PIC object if we are building libtool libraries.
3499348980Sdes    if test yes = "$build_libtool_libs"; then
3500117610Sdes      # Without this assignment, base_compile gets emptied.
3501117610Sdes      fbsd_hideous_sh_bug=$base_compile
3502117610Sdes
3503348980Sdes      if test no != "$pic_mode"; then
3504174832Sdes	command="$base_compile $qsrcfile $pic_flag"
3505125647Sdes      else
3506125647Sdes	# Don't build PIC code
3507174832Sdes	command="$base_compile $qsrcfile"
3508125647Sdes      fi
3509117610Sdes
3510228692Sdes      func_mkdir_p "$xdir$objdir"
3511141098Sdes
3512141098Sdes      if test -z "$output_obj"; then
3513141098Sdes	# Place PIC objects in $objdir
3514228692Sdes	func_append command " -o $lobj"
3515117610Sdes      fi
3516117610Sdes
3517228692Sdes      func_show_eval_locale "$command"	\
3518228692Sdes          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3519141098Sdes
3520348980Sdes      if test warn = "$need_locks" &&
3521141098Sdes	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3522228692Sdes	$ECHO "\
3523117610Sdes*** ERROR, $lockfile contains:
3524117610Sdes`cat $lockfile 2>/dev/null`
3525117610Sdes
3526117610Sdesbut it should contain:
3527117610Sdes$srcfile
3528117610Sdes
3529117610SdesThis indicates that another process is trying to use the same
3530117610Sdestemporary object file, and libtool could not work around it because
3531348980Sdesyour compiler does not support '-c' and '-o' together.  If you
3532117610Sdesrepeat this compilation, it may succeed, by chance, but you had better
3533117610Sdesavoid parallel builds (make -j) in this platform, or get a better
3534117610Sdescompiler."
3535117610Sdes
3536228692Sdes	$opt_dry_run || $RM $removelist
3537141098Sdes	exit $EXIT_FAILURE
3538117610Sdes      fi
3539117610Sdes
3540117610Sdes      # Just move the object if needed, then go on to compile the next one
3541141098Sdes      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
3542228692Sdes	func_show_eval '$MV "$output_obj" "$lobj"' \
3543228692Sdes	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3544117610Sdes      fi
3545117610Sdes
3546141098Sdes      # Allow error messages only from the first compilation.
3547348980Sdes      if test yes = "$suppress_opt"; then
3548228692Sdes	suppress_output=' >/dev/null 2>&1'
3549117610Sdes      fi
3550117610Sdes    fi
3551117610Sdes
3552117610Sdes    # Only build a position-dependent object if we build old libraries.
3553348980Sdes    if test yes = "$build_old_libs"; then
3554348980Sdes      if test yes != "$pic_mode"; then
3555125647Sdes	# Don't build PIC code
3556228692Sdes	command="$base_compile $qsrcfile$pie_flag"
3557125647Sdes      else
3558174832Sdes	command="$base_compile $qsrcfile $pic_flag"
3559125647Sdes      fi
3560348980Sdes      if test yes = "$compiler_c_o"; then
3561228692Sdes	func_append command " -o $obj"
3562117610Sdes      fi
3563117610Sdes
3564117610Sdes      # Suppress compiler output if we already did a PIC compilation.
3565228692Sdes      func_append command "$suppress_output"
3566228692Sdes      func_show_eval_locale "$command" \
3567228692Sdes        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3568117610Sdes
3569348980Sdes      if test warn = "$need_locks" &&
3570141098Sdes	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3571228692Sdes	$ECHO "\
3572117610Sdes*** ERROR, $lockfile contains:
3573117610Sdes`cat $lockfile 2>/dev/null`
3574117610Sdes
3575117610Sdesbut it should contain:
3576117610Sdes$srcfile
3577117610Sdes
3578117610SdesThis indicates that another process is trying to use the same
3579117610Sdestemporary object file, and libtool could not work around it because
3580348980Sdesyour compiler does not support '-c' and '-o' together.  If you
3581117610Sdesrepeat this compilation, it may succeed, by chance, but you had better
3582117610Sdesavoid parallel builds (make -j) in this platform, or get a better
3583117610Sdescompiler."
3584117610Sdes
3585228692Sdes	$opt_dry_run || $RM $removelist
3586141098Sdes	exit $EXIT_FAILURE
3587117610Sdes      fi
3588117610Sdes
3589117610Sdes      # Just move the object if needed
3590141098Sdes      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
3591228692Sdes	func_show_eval '$MV "$output_obj" "$obj"' \
3592228692Sdes	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3593228692Sdes      fi
3594228692Sdes    fi
3595228692Sdes
3596228692Sdes    $opt_dry_run || {
3597228692Sdes      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3598228692Sdes
3599228692Sdes      # Unlock the critical section if it was locked
3600348980Sdes      if test no != "$need_locks"; then
3601228692Sdes	removelist=$lockfile
3602228692Sdes        $RM "$lockfile"
3603228692Sdes      fi
3604228692Sdes    }
3605228692Sdes
3606228692Sdes    exit $EXIT_SUCCESS
3607228692Sdes}
3608228692Sdes
3609228692Sdes$opt_help || {
3610348980Sdes  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
3611228692Sdes}
3612228692Sdes
3613228692Sdesfunc_mode_help ()
3614228692Sdes{
3615228692Sdes    # We need to display help for each of the modes.
3616228692Sdes    case $opt_mode in
3617228692Sdes      "")
3618228692Sdes        # Generic help is extracted from the usage comments
3619228692Sdes        # at the start of this file.
3620228692Sdes        func_help
3621228692Sdes        ;;
3622228692Sdes
3623228692Sdes      clean)
3624228692Sdes        $ECHO \
3625228692Sdes"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3626228692Sdes
3627228692SdesRemove files from the build directory.
3628228692Sdes
3629228692SdesRM is the name of the program to use to delete files associated with each FILE
3630348980Sdes(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
3631228692Sdesto RM.
3632228692Sdes
3633228692SdesIf FILE is a libtool library, object or program, all the files associated
3634228692Sdeswith it are deleted. Otherwise, only FILE itself is deleted using RM."
3635228692Sdes        ;;
3636228692Sdes
3637228692Sdes      compile)
3638228692Sdes      $ECHO \
3639228692Sdes"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3640228692Sdes
3641228692SdesCompile a source file into a libtool library object.
3642228692Sdes
3643228692SdesThis mode accepts the following additional options:
3644228692Sdes
3645228692Sdes  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
3646228692Sdes  -no-suppress      do not suppress compiler output for multiple passes
3647228692Sdes  -prefer-pic       try to build PIC objects only
3648228692Sdes  -prefer-non-pic   try to build non-PIC objects only
3649348980Sdes  -shared           do not build a '.o' file suitable for static linking
3650348980Sdes  -static           only build a '.o' file suitable for static linking
3651228692Sdes  -Wc,FLAG          pass FLAG directly to the compiler
3652228692Sdes
3653348980SdesCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
3654228692Sdesfrom the given SOURCEFILE.
3655228692Sdes
3656228692SdesThe output file name is determined by removing the directory component from
3657348980SdesSOURCEFILE, then substituting the C source code suffix '.c' with the
3658348980Sdeslibrary object suffix, '.lo'."
3659228692Sdes        ;;
3660228692Sdes
3661228692Sdes      execute)
3662228692Sdes        $ECHO \
3663228692Sdes"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3664228692Sdes
3665228692SdesAutomatically set library path, then run a program.
3666228692Sdes
3667228692SdesThis mode accepts the following additional options:
3668228692Sdes
3669228692Sdes  -dlopen FILE      add the directory containing FILE to the library path
3670228692Sdes
3671348980SdesThis mode sets the library path environment variable according to '-dlopen'
3672228692Sdesflags.
3673228692Sdes
3674228692SdesIf any of the ARGS are libtool executable wrappers, then they are translated
3675228692Sdesinto their corresponding uninstalled binary, and any of their required library
3676228692Sdesdirectories are added to the library path.
3677228692Sdes
3678228692SdesThen, COMMAND is executed, with ARGS as arguments."
3679228692Sdes        ;;
3680228692Sdes
3681228692Sdes      finish)
3682228692Sdes        $ECHO \
3683228692Sdes"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3684228692Sdes
3685228692SdesComplete the installation of libtool libraries.
3686228692Sdes
3687228692SdesEach LIBDIR is a directory that contains libtool libraries.
3688228692Sdes
3689228692SdesThe commands that this mode executes may require superuser privileges.  Use
3690348980Sdesthe '--dry-run' option if you just want to see what would be executed."
3691228692Sdes        ;;
3692228692Sdes
3693228692Sdes      install)
3694228692Sdes        $ECHO \
3695228692Sdes"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3696228692Sdes
3697228692SdesInstall executables or libraries.
3698228692Sdes
3699228692SdesINSTALL-COMMAND is the installation command.  The first component should be
3700348980Sdeseither the 'install' or 'cp' program.
3701228692Sdes
3702228692SdesThe following components of INSTALL-COMMAND are treated specially:
3703228692Sdes
3704228692Sdes  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
3705228692Sdes
3706228692SdesThe rest of the components are interpreted as arguments to that command (only
3707228692SdesBSD-compatible install options are recognized)."
3708228692Sdes        ;;
3709228692Sdes
3710228692Sdes      link)
3711228692Sdes        $ECHO \
3712228692Sdes"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3713228692Sdes
3714228692SdesLink object files or libraries together to form another library, or to
3715228692Sdescreate an executable program.
3716228692Sdes
3717228692SdesLINK-COMMAND is a command using the C compiler that you would use to create
3718228692Sdesa program from several object files.
3719228692Sdes
3720228692SdesThe following components of LINK-COMMAND are treated specially:
3721228692Sdes
3722228692Sdes  -all-static       do not do any dynamic linking at all
3723228692Sdes  -avoid-version    do not add a version suffix if possible
3724228692Sdes  -bindir BINDIR    specify path to binaries directory (for systems where
3725228692Sdes                    libraries must be found in the PATH setting at runtime)
3726348980Sdes  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
3727228692Sdes  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
3728228692Sdes  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3729228692Sdes  -export-symbols SYMFILE
3730228692Sdes                    try to export only the symbols listed in SYMFILE
3731228692Sdes  -export-symbols-regex REGEX
3732228692Sdes                    try to export only the symbols matching REGEX
3733228692Sdes  -LLIBDIR          search LIBDIR for required installed libraries
3734228692Sdes  -lNAME            OUTPUT-FILE requires the installed library libNAME
3735228692Sdes  -module           build a library that can dlopened
3736228692Sdes  -no-fast-install  disable the fast-install mode
3737228692Sdes  -no-install       link a not-installable executable
3738228692Sdes  -no-undefined     declare that a library does not refer to external symbols
3739228692Sdes  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
3740348980Sdes  -objectlist FILE  use a list of object files found in FILE to specify objects
3741348980Sdes  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
3742228692Sdes  -precious-files-regex REGEX
3743228692Sdes                    don't remove output files matching REGEX
3744228692Sdes  -release RELEASE  specify package release information
3745228692Sdes  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
3746228692Sdes  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
3747228692Sdes  -shared           only do dynamic linking of libtool libraries
3748228692Sdes  -shrext SUFFIX    override the standard shared library file extension
3749228692Sdes  -static           do not do any dynamic linking of uninstalled libtool libraries
3750228692Sdes  -static-libtool-libs
3751228692Sdes                    do not do any dynamic linking of libtool libraries
3752228692Sdes  -version-info CURRENT[:REVISION[:AGE]]
3753228692Sdes                    specify library version info [each variable defaults to 0]
3754228692Sdes  -weak LIBNAME     declare that the target provides the LIBNAME interface
3755228692Sdes  -Wc,FLAG
3756228692Sdes  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
3757228692Sdes  -Wl,FLAG
3758228692Sdes  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
3759228692Sdes  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
3760228692Sdes
3761348980SdesAll other options (arguments beginning with '-') are ignored.
3762228692Sdes
3763348980SdesEvery other argument is treated as a filename.  Files ending in '.la' are
3764228692Sdestreated as uninstalled libtool libraries, other files are standard or library
3765228692Sdesobject files.
3766228692Sdes
3767348980SdesIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
3768348980Sdesonly library objects ('.lo' files) may be specified, and '-rpath' is
3769228692Sdesrequired, except when creating a convenience library.
3770228692Sdes
3771348980SdesIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
3772348980Sdesusing 'ar' and 'ranlib', or on Windows using 'lib'.
3773228692Sdes
3774348980SdesIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
3775228692Sdesis created, otherwise an executable program is created."
3776228692Sdes        ;;
3777228692Sdes
3778228692Sdes      uninstall)
3779228692Sdes        $ECHO \
3780228692Sdes"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3781228692Sdes
3782228692SdesRemove libraries from an installation directory.
3783228692Sdes
3784228692SdesRM is the name of the program to use to delete files associated with each FILE
3785348980Sdes(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
3786228692Sdesto RM.
3787228692Sdes
3788228692SdesIf FILE is a libtool library, all the files associated with it are deleted.
3789228692SdesOtherwise, only FILE itself is deleted using RM."
3790228692Sdes        ;;
3791228692Sdes
3792228692Sdes      *)
3793348980Sdes        func_fatal_help "invalid operation mode '$opt_mode'"
3794228692Sdes        ;;
3795228692Sdes    esac
3796228692Sdes
3797228692Sdes    echo
3798348980Sdes    $ECHO "Try '$progname --help' for more information about other modes."
3799228692Sdes}
3800228692Sdes
3801228692Sdes# Now that we've collected a possible --mode arg, show help if necessary
3802228692Sdesif $opt_help; then
3803348980Sdes  if test : = "$opt_help"; then
3804228692Sdes    func_mode_help
3805228692Sdes  else
3806228692Sdes    {
3807228692Sdes      func_help noexit
3808228692Sdes      for opt_mode in compile link execute install finish uninstall clean; do
3809228692Sdes	func_mode_help
3810228692Sdes      done
3811348980Sdes    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
3812228692Sdes    {
3813228692Sdes      func_help noexit
3814228692Sdes      for opt_mode in compile link execute install finish uninstall clean; do
3815228692Sdes	echo
3816228692Sdes	func_mode_help
3817228692Sdes      done
3818228692Sdes    } |
3819348980Sdes    $SED '1d
3820228692Sdes      /^When reporting/,/^Report/{
3821228692Sdes	H
3822228692Sdes	d
3823228692Sdes      }
3824228692Sdes      $x
3825228692Sdes      /information about other modes/d
3826228692Sdes      /more detailed .*MODE/d
3827228692Sdes      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3828228692Sdes  fi
3829228692Sdes  exit $?
3830228692Sdesfi
3831228692Sdes
3832228692Sdes
3833228692Sdes# func_mode_execute arg...
3834228692Sdesfunc_mode_execute ()
3835228692Sdes{
3836348980Sdes    $debug_cmd
3837348980Sdes
3838228692Sdes    # The first argument is the command name.
3839348980Sdes    cmd=$nonopt
3840228692Sdes    test -z "$cmd" && \
3841228692Sdes      func_fatal_help "you must specify a COMMAND"
3842228692Sdes
3843228692Sdes    # Handle -dlopen flags immediately.
3844228692Sdes    for file in $opt_dlopen; do
3845228692Sdes      test -f "$file" \
3846348980Sdes	|| func_fatal_help "'$file' is not a file"
3847228692Sdes
3848228692Sdes      dir=
3849228692Sdes      case $file in
3850228692Sdes      *.la)
3851228692Sdes	func_resolve_sysroot "$file"
3852228692Sdes	file=$func_resolve_sysroot_result
3853228692Sdes
3854228692Sdes	# Check to see that this really is a libtool archive.
3855228692Sdes	func_lalib_unsafe_p "$file" \
3856348980Sdes	  || func_fatal_help "'$lib' is not a valid libtool archive"
3857228692Sdes
3858228692Sdes	# Read the libtool library.
3859228692Sdes	dlname=
3860228692Sdes	library_names=
3861228692Sdes	func_source "$file"
3862228692Sdes
3863228692Sdes	# Skip this library if it cannot be dlopened.
3864228692Sdes	if test -z "$dlname"; then
3865228692Sdes	  # Warn if it was a shared library.
3866228692Sdes	  test -n "$library_names" && \
3867348980Sdes	    func_warning "'$file' was not linked with '-export-dynamic'"
3868228692Sdes	  continue
3869228692Sdes	fi
3870228692Sdes
3871228692Sdes	func_dirname "$file" "" "."
3872348980Sdes	dir=$func_dirname_result
3873228692Sdes
3874228692Sdes	if test -f "$dir/$objdir/$dlname"; then
3875228692Sdes	  func_append dir "/$objdir"
3876117610Sdes	else
3877228692Sdes	  if test ! -f "$dir/$dlname"; then
3878348980Sdes	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
3879228692Sdes	  fi
3880117610Sdes	fi
3881228692Sdes	;;
3882228692Sdes
3883228692Sdes      *.lo)
3884228692Sdes	# Just add the directory containing the .lo file.
3885228692Sdes	func_dirname "$file" "" "."
3886348980Sdes	dir=$func_dirname_result
3887228692Sdes	;;
3888228692Sdes
3889228692Sdes      *)
3890348980Sdes	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
3891228692Sdes	continue
3892228692Sdes	;;
3893228692Sdes      esac
3894228692Sdes
3895228692Sdes      # Get the absolute pathname.
3896228692Sdes      absdir=`cd "$dir" && pwd`
3897348980Sdes      test -n "$absdir" && dir=$absdir
3898228692Sdes
3899228692Sdes      # Now add the directory to shlibpath_var.
3900228692Sdes      if eval "test -z \"\$$shlibpath_var\""; then
3901228692Sdes	eval "$shlibpath_var=\"\$dir\""
3902228692Sdes      else
3903228692Sdes	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
3904117610Sdes      fi
3905228692Sdes    done
3906117610Sdes
3907228692Sdes    # This variable tells wrapper scripts just to set shlibpath_var
3908228692Sdes    # rather than running their programs.
3909348980Sdes    libtool_execute_magic=$magic
3910141098Sdes
3911228692Sdes    # Check if any of the arguments is a wrapper script.
3912228692Sdes    args=
3913228692Sdes    for file
3914228692Sdes    do
3915228692Sdes      case $file in
3916228692Sdes      -* | *.la | *.lo ) ;;
3917228692Sdes      *)
3918228692Sdes	# Do a test to see if this is really a libtool program.
3919228692Sdes	if func_ltwrapper_script_p "$file"; then
3920228692Sdes	  func_source "$file"
3921228692Sdes	  # Transform arg to wrapped name.
3922348980Sdes	  file=$progdir/$program
3923228692Sdes	elif func_ltwrapper_executable_p "$file"; then
3924228692Sdes	  func_ltwrapper_scriptname "$file"
3925228692Sdes	  func_source "$func_ltwrapper_scriptname_result"
3926228692Sdes	  # Transform arg to wrapped name.
3927348980Sdes	  file=$progdir/$program
3928228692Sdes	fi
3929228692Sdes	;;
3930228692Sdes      esac
3931228692Sdes      # Quote arguments (to preserve shell metacharacters).
3932228692Sdes      func_append_quoted args "$file"
3933228692Sdes    done
3934228692Sdes
3935348980Sdes    if $opt_dry_run; then
3936348980Sdes      # Display what would be done.
3937228692Sdes      if test -n "$shlibpath_var"; then
3938348980Sdes	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
3939348980Sdes	echo "export $shlibpath_var"
3940348980Sdes      fi
3941348980Sdes      $ECHO "$cmd$args"
3942348980Sdes      exit $EXIT_SUCCESS
3943348980Sdes    else
3944348980Sdes      if test -n "$shlibpath_var"; then
3945228692Sdes	# Export the shlibpath_var.
3946228692Sdes	eval "export $shlibpath_var"
3947228692Sdes      fi
3948228692Sdes
3949228692Sdes      # Restore saved environment variables
3950228692Sdes      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
3951228692Sdes      do
3952228692Sdes	eval "if test \"\${save_$lt_var+set}\" = set; then
3953228692Sdes                $lt_var=\$save_$lt_var; export $lt_var
3954228692Sdes	      else
3955228692Sdes		$lt_unset $lt_var
3956228692Sdes	      fi"
3957228692Sdes      done
3958228692Sdes
3959228692Sdes      # Now prepare to actually exec the command.
3960348980Sdes      exec_cmd=\$cmd$args
3961228692Sdes    fi
3962228692Sdes}
3963141098Sdes
3964348980Sdestest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
3965228692Sdes
3966228692Sdes
3967228692Sdes# func_mode_finish arg...
3968228692Sdesfunc_mode_finish ()
3969228692Sdes{
3970348980Sdes    $debug_cmd
3971348980Sdes
3972228692Sdes    libs=
3973228692Sdes    libdirs=
3974228692Sdes    admincmds=
3975228692Sdes
3976228692Sdes    for opt in "$nonopt" ${1+"$@"}
3977228692Sdes    do
3978228692Sdes      if test -d "$opt"; then
3979228692Sdes	func_append libdirs " $opt"
3980228692Sdes
3981228692Sdes      elif test -f "$opt"; then
3982228692Sdes	if func_lalib_unsafe_p "$opt"; then
3983228692Sdes	  func_append libs " $opt"
3984228692Sdes	else
3985348980Sdes	  func_warning "'$opt' is not a valid libtool archive"
3986228692Sdes	fi
3987228692Sdes
3988228692Sdes      else
3989348980Sdes	func_fatal_error "invalid argument '$opt'"
3990228692Sdes      fi
3991228692Sdes    done
3992228692Sdes
3993228692Sdes    if test -n "$libs"; then
3994228692Sdes      if test -n "$lt_sysroot"; then
3995228692Sdes        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
3996228692Sdes        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
3997228692Sdes      else
3998228692Sdes        sysroot_cmd=
3999228692Sdes      fi
4000228692Sdes
4001228692Sdes      # Remove sysroot references
4002228692Sdes      if $opt_dry_run; then
4003228692Sdes        for lib in $libs; do
4004348980Sdes          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4005228692Sdes        done
4006228692Sdes      else
4007228692Sdes        tmpdir=`func_mktempdir`
4008228692Sdes        for lib in $libs; do
4009348980Sdes	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4010228692Sdes	    > $tmpdir/tmp-la
4011228692Sdes	  mv -f $tmpdir/tmp-la $lib
4012228692Sdes	done
4013228692Sdes        ${RM}r "$tmpdir"
4014228692Sdes      fi
4015117610Sdes    fi
4016117610Sdes
4017228692Sdes    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4018228692Sdes      for libdir in $libdirs; do
4019228692Sdes	if test -n "$finish_cmds"; then
4020228692Sdes	  # Do each command in the finish commands.
4021228692Sdes	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
4022228692Sdes'"$cmd"'"'
4023228692Sdes	fi
4024228692Sdes	if test -n "$finish_eval"; then
4025228692Sdes	  # Do the single finish_eval.
4026228692Sdes	  eval cmds=\"$finish_eval\"
4027228692Sdes	  $opt_dry_run || eval "$cmds" || func_append admincmds "
4028228692Sdes       $cmds"
4029228692Sdes	fi
4030228692Sdes      done
4031228692Sdes    fi
4032141098Sdes
4033228692Sdes    # Exit here if they wanted silent mode.
4034348980Sdes    $opt_quiet && exit $EXIT_SUCCESS
4035228692Sdes
4036228692Sdes    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4037228692Sdes      echo "----------------------------------------------------------------------"
4038228692Sdes      echo "Libraries have been installed in:"
4039228692Sdes      for libdir in $libdirs; do
4040228692Sdes	$ECHO "   $libdir"
4041228692Sdes      done
4042228692Sdes      echo
4043228692Sdes      echo "If you ever happen to want to link against installed libraries"
4044228692Sdes      echo "in a given directory, LIBDIR, you must either use libtool, and"
4045348980Sdes      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4046228692Sdes      echo "flag during linking and do at least one of the following:"
4047228692Sdes      if test -n "$shlibpath_var"; then
4048348980Sdes	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
4049228692Sdes	echo "     during execution"
4050228692Sdes      fi
4051228692Sdes      if test -n "$runpath_var"; then
4052348980Sdes	echo "   - add LIBDIR to the '$runpath_var' environment variable"
4053228692Sdes	echo "     during linking"
4054228692Sdes      fi
4055228692Sdes      if test -n "$hardcode_libdir_flag_spec"; then
4056228692Sdes	libdir=LIBDIR
4057228692Sdes	eval flag=\"$hardcode_libdir_flag_spec\"
4058228692Sdes
4059348980Sdes	$ECHO "   - use the '$flag' linker flag"
4060228692Sdes      fi
4061228692Sdes      if test -n "$admincmds"; then
4062228692Sdes	$ECHO "   - have your system administrator run these commands:$admincmds"
4063228692Sdes      fi
4064228692Sdes      if test -f /etc/ld.so.conf; then
4065348980Sdes	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4066228692Sdes      fi
4067228692Sdes      echo
4068228692Sdes
4069228692Sdes      echo "See any operating system documentation about shared libraries for"
4070228692Sdes      case $host in
4071228692Sdes	solaris2.[6789]|solaris2.1[0-9])
4072228692Sdes	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4073228692Sdes	  echo "pages."
4074228692Sdes	  ;;
4075228692Sdes	*)
4076228692Sdes	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
4077228692Sdes	  ;;
4078228692Sdes      esac
4079228692Sdes      echo "----------------------------------------------------------------------"
4080117610Sdes    fi
4081228692Sdes    exit $EXIT_SUCCESS
4082228692Sdes}
4083117610Sdes
4084348980Sdestest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
4085228692Sdes
4086228692Sdes
4087228692Sdes# func_mode_install arg...
4088228692Sdesfunc_mode_install ()
4089228692Sdes{
4090348980Sdes    $debug_cmd
4091348980Sdes
4092228692Sdes    # There may be an optional sh(1) argument at the beginning of
4093228692Sdes    # install_prog (especially on Windows NT).
4094348980Sdes    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
4095228692Sdes       # Allow the use of GNU shtool's install command.
4096348980Sdes       case $nonopt in *shtool*) :;; *) false;; esac
4097348980Sdes    then
4098228692Sdes      # Aesthetically quote it.
4099228692Sdes      func_quote_for_eval "$nonopt"
4100228692Sdes      install_prog="$func_quote_for_eval_result "
4101228692Sdes      arg=$1
4102228692Sdes      shift
4103228692Sdes    else
4104228692Sdes      install_prog=
4105228692Sdes      arg=$nonopt
4106228692Sdes    fi
4107228692Sdes
4108228692Sdes    # The real first argument should be the name of the installation program.
4109228692Sdes    # Aesthetically quote it.
4110228692Sdes    func_quote_for_eval "$arg"
4111228692Sdes    func_append install_prog "$func_quote_for_eval_result"
4112228692Sdes    install_shared_prog=$install_prog
4113228692Sdes    case " $install_prog " in
4114228692Sdes      *[\\\ /]cp\ *) install_cp=: ;;
4115228692Sdes      *) install_cp=false ;;
4116228692Sdes    esac
4117228692Sdes
4118228692Sdes    # We need to accept at least all the BSD install flags.
4119228692Sdes    dest=
4120228692Sdes    files=
4121228692Sdes    opts=
4122228692Sdes    prev=
4123228692Sdes    install_type=
4124348980Sdes    isdir=false
4125228692Sdes    stripme=
4126228692Sdes    no_mode=:
4127228692Sdes    for arg
4128228692Sdes    do
4129228692Sdes      arg2=
4130228692Sdes      if test -n "$dest"; then
4131228692Sdes	func_append files " $dest"
4132228692Sdes	dest=$arg
4133228692Sdes	continue
4134228692Sdes      fi
4135228692Sdes
4136228692Sdes      case $arg in
4137348980Sdes      -d) isdir=: ;;
4138228692Sdes      -f)
4139228692Sdes	if $install_cp; then :; else
4140228692Sdes	  prev=$arg
4141228692Sdes	fi
4142228692Sdes	;;
4143228692Sdes      -g | -m | -o)
4144228692Sdes	prev=$arg
4145228692Sdes	;;
4146228692Sdes      -s)
4147228692Sdes	stripme=" -s"
4148228692Sdes	continue
4149228692Sdes	;;
4150228692Sdes      -*)
4151228692Sdes	;;
4152228692Sdes      *)
4153228692Sdes	# If the previous option needed an argument, then skip it.
4154228692Sdes	if test -n "$prev"; then
4155348980Sdes	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
4156228692Sdes	    arg2=$install_override_mode
4157228692Sdes	    no_mode=false
4158228692Sdes	  fi
4159228692Sdes	  prev=
4160228692Sdes	else
4161228692Sdes	  dest=$arg
4162228692Sdes	  continue
4163228692Sdes	fi
4164228692Sdes	;;
4165228692Sdes      esac
4166228692Sdes
4167228692Sdes      # Aesthetically quote the argument.
4168228692Sdes      func_quote_for_eval "$arg"
4169228692Sdes      func_append install_prog " $func_quote_for_eval_result"
4170228692Sdes      if test -n "$arg2"; then
4171228692Sdes	func_quote_for_eval "$arg2"
4172228692Sdes      fi
4173228692Sdes      func_append install_shared_prog " $func_quote_for_eval_result"
4174228692Sdes    done
4175228692Sdes
4176228692Sdes    test -z "$install_prog" && \
4177228692Sdes      func_fatal_help "you must specify an install program"
4178228692Sdes
4179228692Sdes    test -n "$prev" && \
4180348980Sdes      func_fatal_help "the '$prev' option requires an argument"
4181228692Sdes
4182228692Sdes    if test -n "$install_override_mode" && $no_mode; then
4183228692Sdes      if $install_cp; then :; else
4184228692Sdes	func_quote_for_eval "$install_override_mode"
4185228692Sdes	func_append install_shared_prog " -m $func_quote_for_eval_result"
4186228692Sdes      fi
4187228692Sdes    fi
4188228692Sdes
4189228692Sdes    if test -z "$files"; then
4190228692Sdes      if test -z "$dest"; then
4191228692Sdes	func_fatal_help "no file or destination specified"
4192228692Sdes      else
4193228692Sdes	func_fatal_help "you must specify a destination"
4194228692Sdes      fi
4195228692Sdes    fi
4196228692Sdes
4197228692Sdes    # Strip any trailing slash from the destination.
4198228692Sdes    func_stripname '' '/' "$dest"
4199228692Sdes    dest=$func_stripname_result
4200228692Sdes
4201228692Sdes    # Check to see that the destination is a directory.
4202348980Sdes    test -d "$dest" && isdir=:
4203348980Sdes    if $isdir; then
4204348980Sdes      destdir=$dest
4205228692Sdes      destname=
4206228692Sdes    else
4207228692Sdes      func_dirname_and_basename "$dest" "" "."
4208348980Sdes      destdir=$func_dirname_result
4209348980Sdes      destname=$func_basename_result
4210228692Sdes
4211228692Sdes      # Not a directory, so check to see that there is only one file specified.
4212228692Sdes      set dummy $files; shift
4213228692Sdes      test "$#" -gt 1 && \
4214348980Sdes	func_fatal_help "'$dest' is not a directory"
4215228692Sdes    fi
4216228692Sdes    case $destdir in
4217228692Sdes    [\\/]* | [A-Za-z]:[\\/]*) ;;
4218228692Sdes    *)
4219228692Sdes      for file in $files; do
4220228692Sdes	case $file in
4221228692Sdes	*.lo) ;;
4222228692Sdes	*)
4223348980Sdes	  func_fatal_help "'$destdir' must be an absolute directory name"
4224228692Sdes	  ;;
4225228692Sdes	esac
4226228692Sdes      done
4227228692Sdes      ;;
4228228692Sdes    esac
4229228692Sdes
4230228692Sdes    # This variable tells wrapper scripts just to set variables rather
4231228692Sdes    # than running their programs.
4232348980Sdes    libtool_install_magic=$magic
4233228692Sdes
4234228692Sdes    staticlibs=
4235228692Sdes    future_libdirs=
4236228692Sdes    current_libdirs=
4237228692Sdes    for file in $files; do
4238228692Sdes
4239228692Sdes      # Do each installation.
4240228692Sdes      case $file in
4241228692Sdes      *.$libext)
4242228692Sdes	# Do the static libraries later.
4243228692Sdes	func_append staticlibs " $file"
4244228692Sdes	;;
4245228692Sdes
4246228692Sdes      *.la)
4247228692Sdes	func_resolve_sysroot "$file"
4248228692Sdes	file=$func_resolve_sysroot_result
4249228692Sdes
4250228692Sdes	# Check to see that this really is a libtool archive.
4251228692Sdes	func_lalib_unsafe_p "$file" \
4252348980Sdes	  || func_fatal_help "'$file' is not a valid libtool archive"
4253228692Sdes
4254228692Sdes	library_names=
4255228692Sdes	old_library=
4256228692Sdes	relink_command=
4257228692Sdes	func_source "$file"
4258228692Sdes
4259228692Sdes	# Add the libdir to current_libdirs if it is the destination.
4260228692Sdes	if test "X$destdir" = "X$libdir"; then
4261228692Sdes	  case "$current_libdirs " in
4262228692Sdes	  *" $libdir "*) ;;
4263228692Sdes	  *) func_append current_libdirs " $libdir" ;;
4264228692Sdes	  esac
4265228692Sdes	else
4266228692Sdes	  # Note the libdir as a future libdir.
4267228692Sdes	  case "$future_libdirs " in
4268228692Sdes	  *" $libdir "*) ;;
4269228692Sdes	  *) func_append future_libdirs " $libdir" ;;
4270228692Sdes	  esac
4271228692Sdes	fi
4272228692Sdes
4273228692Sdes	func_dirname "$file" "/" ""
4274348980Sdes	dir=$func_dirname_result
4275228692Sdes	func_append dir "$objdir"
4276228692Sdes
4277228692Sdes	if test -n "$relink_command"; then
4278228692Sdes	  # Determine the prefix the user has applied to our future dir.
4279228692Sdes	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
4280228692Sdes
4281228692Sdes	  # Don't allow the user to place us outside of our expected
4282228692Sdes	  # location b/c this prevents finding dependent libraries that
4283228692Sdes	  # are installed to the same prefix.
4284228692Sdes	  # At present, this check doesn't affect windows .dll's that
4285228692Sdes	  # are installed into $libdir/../bin (currently, that works fine)
4286228692Sdes	  # but it's something to keep an eye on.
4287228692Sdes	  test "$inst_prefix_dir" = "$destdir" && \
4288348980Sdes	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
4289228692Sdes
4290228692Sdes	  if test -n "$inst_prefix_dir"; then
4291228692Sdes	    # Stick the inst_prefix_dir data into the link command.
4292228692Sdes	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
4293228692Sdes	  else
4294228692Sdes	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
4295228692Sdes	  fi
4296228692Sdes
4297348980Sdes	  func_warning "relinking '$file'"
4298228692Sdes	  func_show_eval "$relink_command" \
4299348980Sdes	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
4300228692Sdes	fi
4301228692Sdes
4302228692Sdes	# See the names of the shared library.
4303228692Sdes	set dummy $library_names; shift
4304228692Sdes	if test -n "$1"; then
4305348980Sdes	  realname=$1
4306228692Sdes	  shift
4307228692Sdes
4308348980Sdes	  srcname=$realname
4309348980Sdes	  test -n "$relink_command" && srcname=${realname}T
4310228692Sdes
4311228692Sdes	  # Install the shared library and build the symlinks.
4312228692Sdes	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
4313228692Sdes	      'exit $?'
4314348980Sdes	  tstripme=$stripme
4315228692Sdes	  case $host_os in
4316228692Sdes	  cygwin* | mingw* | pw32* | cegcc*)
4317228692Sdes	    case $realname in
4318228692Sdes	    *.dll.a)
4319348980Sdes	      tstripme=
4320228692Sdes	      ;;
4321228692Sdes	    esac
4322228692Sdes	    ;;
4323348980Sdes	  os2*)
4324348980Sdes	    case $realname in
4325348980Sdes	    *_dll.a)
4326348980Sdes	      tstripme=
4327348980Sdes	      ;;
4328348980Sdes	    esac
4329348980Sdes	    ;;
4330228692Sdes	  esac
4331228692Sdes	  if test -n "$tstripme" && test -n "$striplib"; then
4332228692Sdes	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
4333228692Sdes	  fi
4334228692Sdes
4335228692Sdes	  if test "$#" -gt 0; then
4336228692Sdes	    # Delete the old symlinks, and create new ones.
4337348980Sdes	    # Try 'ln -sf' first, because the 'ln' binary might depend on
4338228692Sdes	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
4339228692Sdes	    # so we also need to try rm && ln -s.
4340228692Sdes	    for linkname
4341228692Sdes	    do
4342228692Sdes	      test "$linkname" != "$realname" \
4343228692Sdes		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4344228692Sdes	    done
4345228692Sdes	  fi
4346228692Sdes
4347228692Sdes	  # Do each command in the postinstall commands.
4348348980Sdes	  lib=$destdir/$realname
4349228692Sdes	  func_execute_cmds "$postinstall_cmds" 'exit $?'
4350228692Sdes	fi
4351228692Sdes
4352228692Sdes	# Install the pseudo-library for information purposes.
4353228692Sdes	func_basename "$file"
4354348980Sdes	name=$func_basename_result
4355348980Sdes	instname=$dir/${name}i
4356228692Sdes	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4357228692Sdes
4358228692Sdes	# Maybe install the static library, too.
4359228692Sdes	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
4360228692Sdes	;;
4361228692Sdes
4362228692Sdes      *.lo)
4363228692Sdes	# Install (i.e. copy) a libtool object.
4364228692Sdes
4365228692Sdes	# Figure out destination file name, if it wasn't already specified.
4366228692Sdes	if test -n "$destname"; then
4367348980Sdes	  destfile=$destdir/$destname
4368228692Sdes	else
4369228692Sdes	  func_basename "$file"
4370348980Sdes	  destfile=$func_basename_result
4371348980Sdes	  destfile=$destdir/$destfile
4372228692Sdes	fi
4373228692Sdes
4374228692Sdes	# Deduce the name of the destination old-style object file.
4375228692Sdes	case $destfile in
4376228692Sdes	*.lo)
4377228692Sdes	  func_lo2o "$destfile"
4378228692Sdes	  staticdest=$func_lo2o_result
4379228692Sdes	  ;;
4380228692Sdes	*.$objext)
4381348980Sdes	  staticdest=$destfile
4382228692Sdes	  destfile=
4383228692Sdes	  ;;
4384228692Sdes	*)
4385348980Sdes	  func_fatal_help "cannot copy a libtool object to '$destfile'"
4386228692Sdes	  ;;
4387228692Sdes	esac
4388228692Sdes
4389228692Sdes	# Install the libtool object if requested.
4390228692Sdes	test -n "$destfile" && \
4391228692Sdes	  func_show_eval "$install_prog $file $destfile" 'exit $?'
4392228692Sdes
4393228692Sdes	# Install the old object if enabled.
4394348980Sdes	if test yes = "$build_old_libs"; then
4395228692Sdes	  # Deduce the name of the old-style object file.
4396228692Sdes	  func_lo2o "$file"
4397228692Sdes	  staticobj=$func_lo2o_result
4398228692Sdes	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4399228692Sdes	fi
4400228692Sdes	exit $EXIT_SUCCESS
4401228692Sdes	;;
4402228692Sdes
4403228692Sdes      *)
4404228692Sdes	# Figure out destination file name, if it wasn't already specified.
4405228692Sdes	if test -n "$destname"; then
4406348980Sdes	  destfile=$destdir/$destname
4407228692Sdes	else
4408228692Sdes	  func_basename "$file"
4409348980Sdes	  destfile=$func_basename_result
4410348980Sdes	  destfile=$destdir/$destfile
4411228692Sdes	fi
4412228692Sdes
4413228692Sdes	# If the file is missing, and there is a .exe on the end, strip it
4414228692Sdes	# because it is most likely a libtool script we actually want to
4415228692Sdes	# install
4416348980Sdes	stripped_ext=
4417228692Sdes	case $file in
4418228692Sdes	  *.exe)
4419228692Sdes	    if test ! -f "$file"; then
4420228692Sdes	      func_stripname '' '.exe' "$file"
4421228692Sdes	      file=$func_stripname_result
4422348980Sdes	      stripped_ext=.exe
4423228692Sdes	    fi
4424228692Sdes	    ;;
4425228692Sdes	esac
4426228692Sdes
4427228692Sdes	# Do a test to see if this is really a libtool program.
4428228692Sdes	case $host in
4429228692Sdes	*cygwin* | *mingw*)
4430228692Sdes	    if func_ltwrapper_executable_p "$file"; then
4431228692Sdes	      func_ltwrapper_scriptname "$file"
4432228692Sdes	      wrapper=$func_ltwrapper_scriptname_result
4433228692Sdes	    else
4434228692Sdes	      func_stripname '' '.exe' "$file"
4435228692Sdes	      wrapper=$func_stripname_result
4436228692Sdes	    fi
4437228692Sdes	    ;;
4438228692Sdes	*)
4439228692Sdes	    wrapper=$file
4440228692Sdes	    ;;
4441228692Sdes	esac
4442228692Sdes	if func_ltwrapper_script_p "$wrapper"; then
4443228692Sdes	  notinst_deplibs=
4444228692Sdes	  relink_command=
4445228692Sdes
4446228692Sdes	  func_source "$wrapper"
4447228692Sdes
4448228692Sdes	  # Check the variables that should have been set.
4449228692Sdes	  test -z "$generated_by_libtool_version" && \
4450348980Sdes	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
4451228692Sdes
4452348980Sdes	  finalize=:
4453228692Sdes	  for lib in $notinst_deplibs; do
4454228692Sdes	    # Check to see that each library is installed.
4455228692Sdes	    libdir=
4456228692Sdes	    if test -f "$lib"; then
4457228692Sdes	      func_source "$lib"
4458228692Sdes	    fi
4459348980Sdes	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
4460228692Sdes	    if test -n "$libdir" && test ! -f "$libfile"; then
4461348980Sdes	      func_warning "'$lib' has not been installed in '$libdir'"
4462348980Sdes	      finalize=false
4463228692Sdes	    fi
4464228692Sdes	  done
4465228692Sdes
4466228692Sdes	  relink_command=
4467228692Sdes	  func_source "$wrapper"
4468228692Sdes
4469228692Sdes	  outputname=
4470348980Sdes	  if test no = "$fast_install" && test -n "$relink_command"; then
4471228692Sdes	    $opt_dry_run || {
4472348980Sdes	      if $finalize; then
4473228692Sdes	        tmpdir=`func_mktempdir`
4474228692Sdes		func_basename "$file$stripped_ext"
4475348980Sdes		file=$func_basename_result
4476348980Sdes	        outputname=$tmpdir/$file
4477228692Sdes	        # Replace the output file specification.
4478228692Sdes	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
4479228692Sdes
4480348980Sdes	        $opt_quiet || {
4481228692Sdes	          func_quote_for_expand "$relink_command"
4482228692Sdes		  eval "func_echo $func_quote_for_expand_result"
4483228692Sdes	        }
4484228692Sdes	        if eval "$relink_command"; then :
4485228692Sdes	          else
4486348980Sdes		  func_error "error: relink '$file' with the above command before installing it"
4487228692Sdes		  $opt_dry_run || ${RM}r "$tmpdir"
4488228692Sdes		  continue
4489228692Sdes	        fi
4490348980Sdes	        file=$outputname
4491228692Sdes	      else
4492348980Sdes	        func_warning "cannot relink '$file'"
4493228692Sdes	      fi
4494228692Sdes	    }
4495228692Sdes	  else
4496228692Sdes	    # Install the binary that we compiled earlier.
4497228692Sdes	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4498228692Sdes	  fi
4499228692Sdes	fi
4500228692Sdes
4501228692Sdes	# remove .exe since cygwin /usr/bin/install will append another
4502228692Sdes	# one anyway
4503228692Sdes	case $install_prog,$host in
4504228692Sdes	*/usr/bin/install*,*cygwin*)
4505228692Sdes	  case $file:$destfile in
4506228692Sdes	  *.exe:*.exe)
4507228692Sdes	    # this is ok
4508228692Sdes	    ;;
4509228692Sdes	  *.exe:*)
4510228692Sdes	    destfile=$destfile.exe
4511228692Sdes	    ;;
4512228692Sdes	  *:*.exe)
4513228692Sdes	    func_stripname '' '.exe' "$destfile"
4514228692Sdes	    destfile=$func_stripname_result
4515228692Sdes	    ;;
4516228692Sdes	  esac
4517228692Sdes	  ;;
4518228692Sdes	esac
4519228692Sdes	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
4520228692Sdes	$opt_dry_run || if test -n "$outputname"; then
4521228692Sdes	  ${RM}r "$tmpdir"
4522228692Sdes	fi
4523228692Sdes	;;
4524228692Sdes      esac
4525228692Sdes    done
4526228692Sdes
4527228692Sdes    for file in $staticlibs; do
4528228692Sdes      func_basename "$file"
4529348980Sdes      name=$func_basename_result
4530228692Sdes
4531228692Sdes      # Set up the ranlib parameters.
4532348980Sdes      oldlib=$destdir/$name
4533236109Sdes      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4534236109Sdes      tool_oldlib=$func_to_tool_file_result
4535228692Sdes
4536228692Sdes      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
4537228692Sdes
4538228692Sdes      if test -n "$stripme" && test -n "$old_striplib"; then
4539236109Sdes	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
4540228692Sdes      fi
4541228692Sdes
4542228692Sdes      # Do each command in the postinstall commands.
4543228692Sdes      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
4544228692Sdes    done
4545228692Sdes
4546228692Sdes    test -n "$future_libdirs" && \
4547348980Sdes      func_warning "remember to run '$progname --finish$future_libdirs'"
4548228692Sdes
4549228692Sdes    if test -n "$current_libdirs"; then
4550228692Sdes      # Maybe just do a dry run.
4551228692Sdes      $opt_dry_run && current_libdirs=" -n$current_libdirs"
4552348980Sdes      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
4553228692Sdes    else
4554228692Sdes      exit $EXIT_SUCCESS
4555228692Sdes    fi
4556228692Sdes}
4557228692Sdes
4558348980Sdestest install = "$opt_mode" && func_mode_install ${1+"$@"}
4559228692Sdes
4560228692Sdes
4561228692Sdes# func_generate_dlsyms outputname originator pic_p
4562228692Sdes# Extract symbols from dlprefiles and create ${outputname}S.o with
4563228692Sdes# a dlpreopen symbol table.
4564228692Sdesfunc_generate_dlsyms ()
4565228692Sdes{
4566348980Sdes    $debug_cmd
4567348980Sdes
4568348980Sdes    my_outputname=$1
4569348980Sdes    my_originator=$2
4570348980Sdes    my_pic_p=${3-false}
4571348980Sdes    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
4572228692Sdes    my_dlsyms=
4573228692Sdes
4574348980Sdes    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
4575228692Sdes      if test -n "$NM" && test -n "$global_symbol_pipe"; then
4576348980Sdes	my_dlsyms=${my_outputname}S.c
4577228692Sdes      else
4578228692Sdes	func_error "not configured to extract global symbols from dlpreopened files"
4579228692Sdes      fi
4580228692Sdes    fi
4581228692Sdes
4582228692Sdes    if test -n "$my_dlsyms"; then
4583228692Sdes      case $my_dlsyms in
4584228692Sdes      "") ;;
4585228692Sdes      *.c)
4586228692Sdes	# Discover the nlist of each of the dlfiles.
4587348980Sdes	nlist=$output_objdir/$my_outputname.nm
4588228692Sdes
4589228692Sdes	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
4590228692Sdes
4591228692Sdes	# Parse the name list into a source file.
4592228692Sdes	func_verbose "creating $output_objdir/$my_dlsyms"
4593228692Sdes
4594228692Sdes	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
4595348980Sdes/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
4596348980Sdes/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
4597228692Sdes
4598228692Sdes#ifdef __cplusplus
4599228692Sdesextern \"C\" {
4600228692Sdes#endif
4601228692Sdes
4602348980Sdes#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4603228692Sdes#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4604228692Sdes#endif
4605228692Sdes
4606228692Sdes/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
4607348980Sdes#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
4608348980Sdes/* DATA imports from DLLs on WIN32 can't be const, because runtime
4609228692Sdes   relocations are performed -- see ld's documentation on pseudo-relocs.  */
4610228692Sdes# define LT_DLSYM_CONST
4611348980Sdes#elif defined __osf__
4612228692Sdes/* This system does not cope well with relocations in const data.  */
4613228692Sdes# define LT_DLSYM_CONST
4614228692Sdes#else
4615228692Sdes# define LT_DLSYM_CONST const
4616228692Sdes#endif
4617228692Sdes
4618348980Sdes#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
4619348980Sdes
4620228692Sdes/* External symbol declarations for the compiler. */\
4621228692Sdes"
4622228692Sdes
4623348980Sdes	if test yes = "$dlself"; then
4624348980Sdes	  func_verbose "generating symbol list for '$output'"
4625228692Sdes
4626228692Sdes	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
4627228692Sdes
4628228692Sdes	  # Add our own program objects to the symbol list.
4629228692Sdes	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
4630228692Sdes	  for progfile in $progfiles; do
4631228692Sdes	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
4632348980Sdes	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4633228692Sdes	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
4634228692Sdes	  done
4635228692Sdes
4636228692Sdes	  if test -n "$exclude_expsyms"; then
4637228692Sdes	    $opt_dry_run || {
4638228692Sdes	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4639228692Sdes	      eval '$MV "$nlist"T "$nlist"'
4640228692Sdes	    }
4641228692Sdes	  fi
4642228692Sdes
4643228692Sdes	  if test -n "$export_symbols_regex"; then
4644228692Sdes	    $opt_dry_run || {
4645228692Sdes	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4646228692Sdes	      eval '$MV "$nlist"T "$nlist"'
4647228692Sdes	    }
4648228692Sdes	  fi
4649228692Sdes
4650228692Sdes	  # Prepare the list of exported symbols
4651228692Sdes	  if test -z "$export_symbols"; then
4652348980Sdes	    export_symbols=$output_objdir/$outputname.exp
4653228692Sdes	    $opt_dry_run || {
4654228692Sdes	      $RM $export_symbols
4655348980Sdes	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4656228692Sdes	      case $host in
4657228692Sdes	      *cygwin* | *mingw* | *cegcc* )
4658228692Sdes                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4659228692Sdes                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4660228692Sdes	        ;;
4661228692Sdes	      esac
4662228692Sdes	    }
4663228692Sdes	  else
4664228692Sdes	    $opt_dry_run || {
4665348980Sdes	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4666228692Sdes	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4667228692Sdes	      eval '$MV "$nlist"T "$nlist"'
4668228692Sdes	      case $host in
4669228692Sdes	        *cygwin* | *mingw* | *cegcc* )
4670228692Sdes	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4671228692Sdes	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4672228692Sdes	          ;;
4673228692Sdes	      esac
4674228692Sdes	    }
4675228692Sdes	  fi
4676228692Sdes	fi
4677228692Sdes
4678228692Sdes	for dlprefile in $dlprefiles; do
4679348980Sdes	  func_verbose "extracting global C symbols from '$dlprefile'"
4680228692Sdes	  func_basename "$dlprefile"
4681348980Sdes	  name=$func_basename_result
4682228692Sdes          case $host in
4683228692Sdes	    *cygwin* | *mingw* | *cegcc* )
4684228692Sdes	      # if an import library, we need to obtain dlname
4685228692Sdes	      if func_win32_import_lib_p "$dlprefile"; then
4686228692Sdes	        func_tr_sh "$dlprefile"
4687228692Sdes	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
4688348980Sdes	        dlprefile_dlbasename=
4689228692Sdes	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4690228692Sdes	          # Use subshell, to avoid clobbering current variable values
4691228692Sdes	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
4692348980Sdes	          if test -n "$dlprefile_dlname"; then
4693228692Sdes	            func_basename "$dlprefile_dlname"
4694348980Sdes	            dlprefile_dlbasename=$func_basename_result
4695228692Sdes	          else
4696228692Sdes	            # no lafile. user explicitly requested -dlpreopen <import library>.
4697228692Sdes	            $sharedlib_from_linklib_cmd "$dlprefile"
4698228692Sdes	            dlprefile_dlbasename=$sharedlib_from_linklib_result
4699228692Sdes	          fi
4700228692Sdes	        fi
4701228692Sdes	        $opt_dry_run || {
4702348980Sdes	          if test -n "$dlprefile_dlbasename"; then
4703228692Sdes	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4704228692Sdes	          else
4705228692Sdes	            func_warning "Could not compute DLL name from $name"
4706228692Sdes	            eval '$ECHO ": $name " >> "$nlist"'
4707228692Sdes	          fi
4708228692Sdes	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4709228692Sdes	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4710228692Sdes	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4711228692Sdes	        }
4712228692Sdes	      else # not an import lib
4713228692Sdes	        $opt_dry_run || {
4714228692Sdes	          eval '$ECHO ": $name " >> "$nlist"'
4715228692Sdes	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4716228692Sdes	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4717228692Sdes	        }
4718228692Sdes	      fi
4719228692Sdes	    ;;
4720228692Sdes	    *)
4721228692Sdes	      $opt_dry_run || {
4722228692Sdes	        eval '$ECHO ": $name " >> "$nlist"'
4723228692Sdes	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4724228692Sdes	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4725228692Sdes	      }
4726228692Sdes	    ;;
4727228692Sdes          esac
4728228692Sdes	done
4729228692Sdes
4730228692Sdes	$opt_dry_run || {
4731228692Sdes	  # Make sure we have at least an empty file.
4732228692Sdes	  test -f "$nlist" || : > "$nlist"
4733228692Sdes
4734228692Sdes	  if test -n "$exclude_expsyms"; then
4735228692Sdes	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4736228692Sdes	    $MV "$nlist"T "$nlist"
4737228692Sdes	  fi
4738228692Sdes
4739228692Sdes	  # Try sorting and uniquifying the output.
4740228692Sdes	  if $GREP -v "^: " < "$nlist" |
4741228692Sdes	      if sort -k 3 </dev/null >/dev/null 2>&1; then
4742228692Sdes		sort -k 3
4743228692Sdes	      else
4744228692Sdes		sort +2
4745228692Sdes	      fi |
4746228692Sdes	      uniq > "$nlist"S; then
4747228692Sdes	    :
4748228692Sdes	  else
4749228692Sdes	    $GREP -v "^: " < "$nlist" > "$nlist"S
4750228692Sdes	  fi
4751228692Sdes
4752228692Sdes	  if test -f "$nlist"S; then
4753228692Sdes	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
4754228692Sdes	  else
4755228692Sdes	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
4756228692Sdes	  fi
4757228692Sdes
4758348980Sdes	  func_show_eval '$RM "${nlist}I"'
4759348980Sdes	  if test -n "$global_symbol_to_import"; then
4760348980Sdes	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
4761348980Sdes	  fi
4762348980Sdes
4763228692Sdes	  echo >> "$output_objdir/$my_dlsyms" "\
4764228692Sdes
4765228692Sdes/* The mapping between symbol names and symbols.  */
4766228692Sdestypedef struct {
4767228692Sdes  const char *name;
4768228692Sdes  void *address;
4769228692Sdes} lt_dlsymlist;
4770228692Sdesextern LT_DLSYM_CONST lt_dlsymlist
4771348980Sdeslt_${my_prefix}_LTX_preloaded_symbols[];\
4772348980Sdes"
4773348980Sdes
4774348980Sdes	  if test -s "$nlist"I; then
4775348980Sdes	    echo >> "$output_objdir/$my_dlsyms" "\
4776348980Sdesstatic void lt_syminit(void)
4777348980Sdes{
4778348980Sdes  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
4779348980Sdes  for (; symbol->name; ++symbol)
4780348980Sdes    {"
4781348980Sdes	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
4782348980Sdes	    echo >> "$output_objdir/$my_dlsyms" "\
4783348980Sdes    }
4784348980Sdes}"
4785348980Sdes	  fi
4786348980Sdes	  echo >> "$output_objdir/$my_dlsyms" "\
4787228692SdesLT_DLSYM_CONST lt_dlsymlist
4788228692Sdeslt_${my_prefix}_LTX_preloaded_symbols[] =
4789348980Sdes{ {\"$my_originator\", (void *) 0},"
4790228692Sdes
4791348980Sdes	  if test -s "$nlist"I; then
4792348980Sdes	    echo >> "$output_objdir/$my_dlsyms" "\
4793348980Sdes  {\"@INIT@\", (void *) &lt_syminit},"
4794348980Sdes	  fi
4795348980Sdes
4796228692Sdes	  case $need_lib_prefix in
4797228692Sdes	  no)
4798228692Sdes	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
4799228692Sdes	    ;;
4800228692Sdes	  *)
4801228692Sdes	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
4802228692Sdes	    ;;
4803228692Sdes	  esac
4804228692Sdes	  echo >> "$output_objdir/$my_dlsyms" "\
4805228692Sdes  {0, (void *) 0}
4806228692Sdes};
4807228692Sdes
4808228692Sdes/* This works around a problem in FreeBSD linker */
4809228692Sdes#ifdef FREEBSD_WORKAROUND
4810228692Sdesstatic const void *lt_preloaded_setup() {
4811228692Sdes  return lt_${my_prefix}_LTX_preloaded_symbols;
4812228692Sdes}
4813228692Sdes#endif
4814228692Sdes
4815228692Sdes#ifdef __cplusplus
4816228692Sdes}
4817228692Sdes#endif\
4818228692Sdes"
4819228692Sdes	} # !$opt_dry_run
4820228692Sdes
4821228692Sdes	pic_flag_for_symtable=
4822228692Sdes	case "$compile_command " in
4823228692Sdes	*" -static "*) ;;
4824228692Sdes	*)
4825228692Sdes	  case $host in
4826228692Sdes	  # compiling the symbol table file with pic_flag works around
4827228692Sdes	  # a FreeBSD bug that causes programs to crash when -lm is
4828228692Sdes	  # linked before any other PIC object.  But we must not use
4829228692Sdes	  # pic_flag when linking with -static.  The problem exists in
4830228692Sdes	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4831236109Sdes	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4832228692Sdes	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
4833228692Sdes	  *-*-hpux*)
4834228692Sdes	    pic_flag_for_symtable=" $pic_flag"  ;;
4835228692Sdes	  *)
4836348980Sdes	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
4837228692Sdes	    ;;
4838228692Sdes	  esac
4839228692Sdes	  ;;
4840228692Sdes	esac
4841228692Sdes	symtab_cflags=
4842228692Sdes	for arg in $LTCFLAGS; do
4843228692Sdes	  case $arg in
4844228692Sdes	  -pie | -fpie | -fPIE) ;;
4845228692Sdes	  *) func_append symtab_cflags " $arg" ;;
4846228692Sdes	  esac
4847228692Sdes	done
4848228692Sdes
4849228692Sdes	# Now compile the dynamic symbol file.
4850228692Sdes	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
4851228692Sdes
4852228692Sdes	# Clean up the generated files.
4853348980Sdes	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
4854228692Sdes
4855228692Sdes	# Transform the symbol file into the correct name.
4856348980Sdes	symfileobj=$output_objdir/${my_outputname}S.$objext
4857228692Sdes	case $host in
4858228692Sdes	*cygwin* | *mingw* | *cegcc* )
4859228692Sdes	  if test -f "$output_objdir/$my_outputname.def"; then
4860228692Sdes	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4861228692Sdes	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4862228692Sdes	  else
4863228692Sdes	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4864228692Sdes	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4865228692Sdes	  fi
4866228692Sdes	  ;;
4867228692Sdes	*)
4868228692Sdes	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4869228692Sdes	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4870228692Sdes	  ;;
4871228692Sdes	esac
4872228692Sdes	;;
4873228692Sdes      *)
4874348980Sdes	func_fatal_error "unknown suffix for '$my_dlsyms'"
4875228692Sdes	;;
4876228692Sdes      esac
4877228692Sdes    else
4878228692Sdes      # We keep going just in case the user didn't refer to
4879228692Sdes      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
4880228692Sdes      # really was required.
4881228692Sdes
4882228692Sdes      # Nullify the symbol file.
4883228692Sdes      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4884228692Sdes      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
4885228692Sdes    fi
4886228692Sdes}
4887228692Sdes
4888348980Sdes# func_cygming_gnu_implib_p ARG
4889348980Sdes# This predicate returns with zero status (TRUE) if
4890348980Sdes# ARG is a GNU/binutils-style import library. Returns
4891348980Sdes# with nonzero status (FALSE) otherwise.
4892348980Sdesfunc_cygming_gnu_implib_p ()
4893348980Sdes{
4894348980Sdes  $debug_cmd
4895348980Sdes
4896348980Sdes  func_to_tool_file "$1" func_convert_file_msys_to_w32
4897348980Sdes  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)$'`
4898348980Sdes  test -n "$func_cygming_gnu_implib_tmp"
4899348980Sdes}
4900348980Sdes
4901348980Sdes# func_cygming_ms_implib_p ARG
4902348980Sdes# This predicate returns with zero status (TRUE) if
4903348980Sdes# ARG is an MS-style import library. Returns
4904348980Sdes# with nonzero status (FALSE) otherwise.
4905348980Sdesfunc_cygming_ms_implib_p ()
4906348980Sdes{
4907348980Sdes  $debug_cmd
4908348980Sdes
4909348980Sdes  func_to_tool_file "$1" func_convert_file_msys_to_w32
4910348980Sdes  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
4911348980Sdes  test -n "$func_cygming_ms_implib_tmp"
4912348980Sdes}
4913348980Sdes
4914228692Sdes# func_win32_libid arg
4915228692Sdes# return the library type of file 'arg'
4916228692Sdes#
4917228692Sdes# Need a lot of goo to handle *both* DLLs and import libs
4918228692Sdes# Has to be a shell function in order to 'eat' the argument
4919228692Sdes# that is supplied when $file_magic_command is called.
4920228692Sdes# Despite the name, also deal with 64 bit binaries.
4921228692Sdesfunc_win32_libid ()
4922228692Sdes{
4923348980Sdes  $debug_cmd
4924348980Sdes
4925348980Sdes  win32_libid_type=unknown
4926228692Sdes  win32_fileres=`file -L $1 2>/dev/null`
4927228692Sdes  case $win32_fileres in
4928228692Sdes  *ar\ archive\ import\ library*) # definitely import
4929228692Sdes    win32_libid_type="x86 archive import"
4930117610Sdes    ;;
4931228692Sdes  *ar\ archive*) # could be an import, or static
4932228692Sdes    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
4933228692Sdes    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
4934228692Sdes       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
4935348980Sdes      case $nm_interface in
4936348980Sdes      "MS dumpbin")
4937348980Sdes	if func_cygming_ms_implib_p "$1" ||
4938348980Sdes	   func_cygming_gnu_implib_p "$1"
4939348980Sdes	then
4940348980Sdes	  win32_nmres=import
4941348980Sdes	else
4942348980Sdes	  win32_nmres=
4943348980Sdes	fi
4944348980Sdes	;;
4945348980Sdes      *)
4946348980Sdes	func_to_tool_file "$1" func_convert_file_msys_to_w32
4947348980Sdes	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
4948348980Sdes	  $SED -n -e '
4949228692Sdes	    1,100{
4950228692Sdes		/ I /{
4951348980Sdes		    s|.*|import|
4952228692Sdes		    p
4953228692Sdes		    q
4954228692Sdes		}
4955228692Sdes	    }'`
4956348980Sdes	;;
4957348980Sdes      esac
4958228692Sdes      case $win32_nmres in
4959228692Sdes      import*)  win32_libid_type="x86 archive import";;
4960228692Sdes      *)        win32_libid_type="x86 archive static";;
4961228692Sdes      esac
4962228692Sdes    fi
4963228692Sdes    ;;
4964228692Sdes  *DLL*)
4965228692Sdes    win32_libid_type="x86 DLL"
4966228692Sdes    ;;
4967228692Sdes  *executable*) # but shell scripts are "executable" too...
4968228692Sdes    case $win32_fileres in
4969228692Sdes    *MS\ Windows\ PE\ Intel*)
4970228692Sdes      win32_libid_type="x86 DLL"
4971228692Sdes      ;;
4972228692Sdes    esac
4973228692Sdes    ;;
4974228692Sdes  esac
4975228692Sdes  $ECHO "$win32_libid_type"
4976228692Sdes}
4977117610Sdes
4978228692Sdes# func_cygming_dll_for_implib ARG
4979228692Sdes#
4980228692Sdes# Platform-specific function to extract the
4981228692Sdes# name of the DLL associated with the specified
4982228692Sdes# import library ARG.
4983228692Sdes# Invoked by eval'ing the libtool variable
4984228692Sdes#    $sharedlib_from_linklib_cmd
4985228692Sdes# Result is available in the variable
4986228692Sdes#    $sharedlib_from_linklib_result
4987228692Sdesfunc_cygming_dll_for_implib ()
4988228692Sdes{
4989348980Sdes  $debug_cmd
4990348980Sdes
4991228692Sdes  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
4992228692Sdes}
4993228692Sdes
4994228692Sdes# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
4995228692Sdes#
4996228692Sdes# The is the core of a fallback implementation of a
4997228692Sdes# platform-specific function to extract the name of the
4998228692Sdes# DLL associated with the specified import library LIBNAME.
4999228692Sdes#
5000228692Sdes# SECTION_NAME is either .idata$6 or .idata$7, depending
5001228692Sdes# on the platform and compiler that created the implib.
5002228692Sdes#
5003228692Sdes# Echos the name of the DLL associated with the
5004228692Sdes# specified import library.
5005228692Sdesfunc_cygming_dll_for_implib_fallback_core ()
5006228692Sdes{
5007348980Sdes  $debug_cmd
5008348980Sdes
5009228692Sdes  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5010228692Sdes  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5011228692Sdes    $SED '/^Contents of section '"$match_literal"':/{
5012228692Sdes      # Place marker at beginning of archive member dllname section
5013228692Sdes      s/.*/====MARK====/
5014228692Sdes      p
5015228692Sdes      d
5016228692Sdes    }
5017228692Sdes    # These lines can sometimes be longer than 43 characters, but
5018228692Sdes    # are always uninteresting
5019228692Sdes    /:[	 ]*file format pe[i]\{,1\}-/d
5020228692Sdes    /^In archive [^:]*:/d
5021228692Sdes    # Ensure marker is printed
5022228692Sdes    /^====MARK====/p
5023228692Sdes    # Remove all lines with less than 43 characters
5024228692Sdes    /^.\{43\}/!d
5025228692Sdes    # From remaining lines, remove first 43 characters
5026228692Sdes    s/^.\{43\}//' |
5027228692Sdes    $SED -n '
5028228692Sdes      # Join marker and all lines until next marker into a single line
5029228692Sdes      /^====MARK====/ b para
5030228692Sdes      H
5031228692Sdes      $ b para
5032228692Sdes      b
5033228692Sdes      :para
5034228692Sdes      x
5035228692Sdes      s/\n//g
5036228692Sdes      # Remove the marker
5037228692Sdes      s/^====MARK====//
5038228692Sdes      # Remove trailing dots and whitespace
5039228692Sdes      s/[\. \t]*$//
5040228692Sdes      # Print
5041228692Sdes      /./p' |
5042228692Sdes    # we now have a list, one entry per line, of the stringified
5043228692Sdes    # contents of the appropriate section of all members of the
5044348980Sdes    # archive that possess that section. Heuristic: eliminate
5045348980Sdes    # all those that have a first or second character that is
5046228692Sdes    # a '.' (that is, objdump's representation of an unprintable
5047228692Sdes    # character.) This should work for all archives with less than
5048228692Sdes    # 0x302f exports -- but will fail for DLLs whose name actually
5049228692Sdes    # begins with a literal '.' or a single character followed by
5050228692Sdes    # a '.'.
5051228692Sdes    #
5052228692Sdes    # Of those that remain, print the first one.
5053228692Sdes    $SED -e '/^\./d;/^.\./d;q'
5054228692Sdes}
5055228692Sdes
5056228692Sdes# func_cygming_dll_for_implib_fallback ARG
5057228692Sdes# Platform-specific function to extract the
5058228692Sdes# name of the DLL associated with the specified
5059228692Sdes# import library ARG.
5060228692Sdes#
5061228692Sdes# This fallback implementation is for use when $DLLTOOL
5062228692Sdes# does not support the --identify-strict option.
5063228692Sdes# Invoked by eval'ing the libtool variable
5064228692Sdes#    $sharedlib_from_linklib_cmd
5065228692Sdes# Result is available in the variable
5066228692Sdes#    $sharedlib_from_linklib_result
5067228692Sdesfunc_cygming_dll_for_implib_fallback ()
5068228692Sdes{
5069348980Sdes  $debug_cmd
5070348980Sdes
5071348980Sdes  if func_cygming_gnu_implib_p "$1"; then
5072228692Sdes    # binutils import library
5073228692Sdes    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
5074348980Sdes  elif func_cygming_ms_implib_p "$1"; then
5075228692Sdes    # ms-generated import library
5076228692Sdes    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5077228692Sdes  else
5078228692Sdes    # unknown
5079348980Sdes    sharedlib_from_linklib_result=
5080228692Sdes  fi
5081228692Sdes}
5082228692Sdes
5083228692Sdes
5084228692Sdes# func_extract_an_archive dir oldlib
5085228692Sdesfunc_extract_an_archive ()
5086228692Sdes{
5087348980Sdes    $debug_cmd
5088348980Sdes
5089348980Sdes    f_ex_an_ar_dir=$1; shift
5090348980Sdes    f_ex_an_ar_oldlib=$1
5091348980Sdes    if test yes = "$lock_old_archive_extraction"; then
5092228692Sdes      lockfile=$f_ex_an_ar_oldlib.lock
5093228692Sdes      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
5094228692Sdes	func_echo "Waiting for $lockfile to be removed"
5095228692Sdes	sleep 2
5096228692Sdes      done
5097228692Sdes    fi
5098228692Sdes    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
5099228692Sdes		   'stat=$?; rm -f "$lockfile"; exit $stat'
5100348980Sdes    if test yes = "$lock_old_archive_extraction"; then
5101228692Sdes      $opt_dry_run || rm -f "$lockfile"
5102228692Sdes    fi
5103228692Sdes    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
5104228692Sdes     :
5105228692Sdes    else
5106228692Sdes      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
5107228692Sdes    fi
5108228692Sdes}
5109228692Sdes
5110228692Sdes
5111228692Sdes# func_extract_archives gentop oldlib ...
5112228692Sdesfunc_extract_archives ()
5113228692Sdes{
5114348980Sdes    $debug_cmd
5115348980Sdes
5116348980Sdes    my_gentop=$1; shift
5117228692Sdes    my_oldlibs=${1+"$@"}
5118348980Sdes    my_oldobjs=
5119348980Sdes    my_xlib=
5120348980Sdes    my_xabs=
5121348980Sdes    my_xdir=
5122228692Sdes
5123228692Sdes    for my_xlib in $my_oldlibs; do
5124228692Sdes      # Extract the objects.
5125228692Sdes      case $my_xlib in
5126348980Sdes	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
5127228692Sdes	*) my_xabs=`pwd`"/$my_xlib" ;;
5128228692Sdes      esac
5129228692Sdes      func_basename "$my_xlib"
5130348980Sdes      my_xlib=$func_basename_result
5131228692Sdes      my_xlib_u=$my_xlib
5132228692Sdes      while :; do
5133228692Sdes        case " $extracted_archives " in
5134228692Sdes	*" $my_xlib_u "*)
5135228692Sdes	  func_arith $extracted_serial + 1
5136228692Sdes	  extracted_serial=$func_arith_result
5137228692Sdes	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
5138228692Sdes	*) break ;;
5139228692Sdes	esac
5140228692Sdes      done
5141228692Sdes      extracted_archives="$extracted_archives $my_xlib_u"
5142348980Sdes      my_xdir=$my_gentop/$my_xlib_u
5143228692Sdes
5144228692Sdes      func_mkdir_p "$my_xdir"
5145228692Sdes
5146228692Sdes      case $host in
5147228692Sdes      *-darwin*)
5148228692Sdes	func_verbose "Extracting $my_xabs"
5149228692Sdes	# Do not bother doing anything if just a dry run
5150228692Sdes	$opt_dry_run || {
5151228692Sdes	  darwin_orig_dir=`pwd`
5152228692Sdes	  cd $my_xdir || exit $?
5153228692Sdes	  darwin_archive=$my_xabs
5154228692Sdes	  darwin_curdir=`pwd`
5155348980Sdes	  func_basename "$darwin_archive"
5156348980Sdes	  darwin_base_archive=$func_basename_result
5157228692Sdes	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
5158228692Sdes	  if test -n "$darwin_arches"; then
5159228692Sdes	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
5160228692Sdes	    darwin_arch=
5161228692Sdes	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
5162348980Sdes	    for darwin_arch in  $darwin_arches; do
5163348980Sdes	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
5164348980Sdes	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
5165348980Sdes	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
5166348980Sdes	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
5167228692Sdes	      cd "$darwin_curdir"
5168348980Sdes	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
5169228692Sdes	    done # $darwin_arches
5170228692Sdes            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
5171348980Sdes	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
5172228692Sdes	    darwin_file=
5173228692Sdes	    darwin_files=
5174228692Sdes	    for darwin_file in $darwin_filelist; do
5175228692Sdes	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
5176228692Sdes	      $LIPO -create -output "$darwin_file" $darwin_files
5177228692Sdes	    done # $darwin_filelist
5178228692Sdes	    $RM -rf unfat-$$
5179228692Sdes	    cd "$darwin_orig_dir"
5180228692Sdes	  else
5181228692Sdes	    cd $darwin_orig_dir
5182228692Sdes	    func_extract_an_archive "$my_xdir" "$my_xabs"
5183228692Sdes	  fi # $darwin_arches
5184228692Sdes	} # !$opt_dry_run
5185228692Sdes	;;
5186228692Sdes      *)
5187228692Sdes        func_extract_an_archive "$my_xdir" "$my_xabs"
5188228692Sdes	;;
5189228692Sdes      esac
5190228692Sdes      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
5191228692Sdes    done
5192228692Sdes
5193348980Sdes    func_extract_archives_result=$my_oldobjs
5194228692Sdes}
5195228692Sdes
5196228692Sdes
5197228692Sdes# func_emit_wrapper [arg=no]
5198228692Sdes#
5199228692Sdes# Emit a libtool wrapper script on stdout.
5200228692Sdes# Don't directly open a file because we may want to
5201228692Sdes# incorporate the script contents within a cygwin/mingw
5202228692Sdes# wrapper executable.  Must ONLY be called from within
5203228692Sdes# func_mode_link because it depends on a number of variables
5204228692Sdes# set therein.
5205228692Sdes#
5206228692Sdes# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5207228692Sdes# variable will take.  If 'yes', then the emitted script
5208348980Sdes# will assume that the directory where it is stored is
5209228692Sdes# the $objdir directory.  This is a cygwin/mingw-specific
5210228692Sdes# behavior.
5211228692Sdesfunc_emit_wrapper ()
5212228692Sdes{
5213228692Sdes	func_emit_wrapper_arg1=${1-no}
5214228692Sdes
5215228692Sdes	$ECHO "\
5216228692Sdes#! $SHELL
5217228692Sdes
5218228692Sdes# $output - temporary wrapper script for $objdir/$outputname
5219348980Sdes# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5220228692Sdes#
5221228692Sdes# The $output program cannot be directly executed until all the libtool
5222228692Sdes# libraries that it depends on are installed.
5223228692Sdes#
5224228692Sdes# This wrapper script should never be moved out of the build directory.
5225228692Sdes# If it is, it will not operate correctly.
5226228692Sdes
5227228692Sdes# Sed substitution that helps us do robust quoting.  It backslashifies
5228228692Sdes# metacharacters that are still active within double-quoted strings.
5229228692Sdessed_quote_subst='$sed_quote_subst'
5230228692Sdes
5231228692Sdes# Be Bourne compatible
5232228692Sdesif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5233228692Sdes  emulate sh
5234228692Sdes  NULLCMD=:
5235228692Sdes  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5236228692Sdes  # is contrary to our usage.  Disable this feature.
5237228692Sdes  alias -g '\${1+\"\$@\"}'='\"\$@\"'
5238228692Sdes  setopt NO_GLOB_SUBST
5239228692Sdeselse
5240228692Sdes  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5241228692Sdesfi
5242228692SdesBIN_SH=xpg4; export BIN_SH # for Tru64
5243228692SdesDUALCASE=1; export DUALCASE # for MKS sh
5244228692Sdes
5245228692Sdes# The HP-UX ksh and POSIX shell print the target directory to stdout
5246228692Sdes# if CDPATH is set.
5247228692Sdes(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5248228692Sdes
5249228692Sdesrelink_command=\"$relink_command\"
5250228692Sdes
5251228692Sdes# This environment variable determines our operation mode.
5252228692Sdesif test \"\$libtool_install_magic\" = \"$magic\"; then
5253228692Sdes  # install mode needs the following variables:
5254228692Sdes  generated_by_libtool_version='$macro_version'
5255228692Sdes  notinst_deplibs='$notinst_deplibs'
5256228692Sdeselse
5257228692Sdes  # When we are sourced in execute mode, \$file and \$ECHO are already set.
5258228692Sdes  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5259228692Sdes    file=\"\$0\""
5260228692Sdes
5261228692Sdes    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
5262228692Sdes    $ECHO "\
5263228692Sdes
5264228692Sdes# A function that is used when there is no print builtin or printf.
5265228692Sdesfunc_fallback_echo ()
5266228692Sdes{
5267228692Sdes  eval 'cat <<_LTECHO_EOF
5268228692Sdes\$1
5269228692Sdes_LTECHO_EOF'
5270228692Sdes}
5271228692Sdes    ECHO=\"$qECHO\"
5272228692Sdes  fi
5273228692Sdes
5274228692Sdes# Very basic option parsing. These options are (a) specific to
5275228692Sdes# the libtool wrapper, (b) are identical between the wrapper
5276348980Sdes# /script/ and the wrapper /executable/ that is used only on
5277228692Sdes# windows platforms, and (c) all begin with the string "--lt-"
5278348980Sdes# (application programs are unlikely to have options that match
5279228692Sdes# this pattern).
5280228692Sdes#
5281228692Sdes# There are only two supported options: --lt-debug and
5282228692Sdes# --lt-dump-script. There is, deliberately, no --lt-help.
5283228692Sdes#
5284228692Sdes# The first argument to this parsing function should be the
5285228692Sdes# script's $0 value, followed by "$@".
5286228692Sdeslt_option_debug=
5287228692Sdesfunc_parse_lt_options ()
5288228692Sdes{
5289228692Sdes  lt_script_arg0=\$0
5290228692Sdes  shift
5291228692Sdes  for lt_opt
5292228692Sdes  do
5293228692Sdes    case \"\$lt_opt\" in
5294228692Sdes    --lt-debug) lt_option_debug=1 ;;
5295228692Sdes    --lt-dump-script)
5296228692Sdes        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5297228692Sdes        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5298228692Sdes        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5299228692Sdes        cat \"\$lt_dump_D/\$lt_dump_F\"
5300228692Sdes        exit 0
5301228692Sdes      ;;
5302228692Sdes    --lt-*)
5303228692Sdes        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5304228692Sdes        exit 1
5305228692Sdes      ;;
5306228692Sdes    esac
5307228692Sdes  done
5308228692Sdes
5309228692Sdes  # Print the debug banner immediately:
5310228692Sdes  if test -n \"\$lt_option_debug\"; then
5311348980Sdes    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5312228692Sdes  fi
5313228692Sdes}
5314228692Sdes
5315228692Sdes# Used when --lt-debug. Prints its arguments to stdout
5316228692Sdes# (redirection is the responsibility of the caller)
5317228692Sdesfunc_lt_dump_args ()
5318228692Sdes{
5319228692Sdes  lt_dump_args_N=1;
5320228692Sdes  for lt_arg
5321228692Sdes  do
5322348980Sdes    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5323228692Sdes    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5324228692Sdes  done
5325228692Sdes}
5326228692Sdes
5327228692Sdes# Core function for launching the target application
5328228692Sdesfunc_exec_program_core ()
5329228692Sdes{
5330228692Sdes"
5331228692Sdes  case $host in
5332228692Sdes  # Backslashes separate directories on plain windows
5333228692Sdes  *-*-mingw | *-*-os2* | *-cegcc*)
5334228692Sdes    $ECHO "\
5335228692Sdes      if test -n \"\$lt_option_debug\"; then
5336348980Sdes        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5337228692Sdes        func_lt_dump_args \${1+\"\$@\"} 1>&2
5338228692Sdes      fi
5339228692Sdes      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5340228692Sdes"
5341228692Sdes    ;;
5342228692Sdes
5343228692Sdes  *)
5344228692Sdes    $ECHO "\
5345228692Sdes      if test -n \"\$lt_option_debug\"; then
5346348980Sdes        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5347228692Sdes        func_lt_dump_args \${1+\"\$@\"} 1>&2
5348228692Sdes      fi
5349228692Sdes      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5350228692Sdes"
5351228692Sdes    ;;
5352228692Sdes  esac
5353228692Sdes  $ECHO "\
5354228692Sdes      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5355228692Sdes      exit 1
5356228692Sdes}
5357228692Sdes
5358228692Sdes# A function to encapsulate launching the target application
5359228692Sdes# Strips options in the --lt-* namespace from \$@ and
5360228692Sdes# launches target application with the remaining arguments.
5361228692Sdesfunc_exec_program ()
5362228692Sdes{
5363236109Sdes  case \" \$* \" in
5364236109Sdes  *\\ --lt-*)
5365236109Sdes    for lt_wr_arg
5366236109Sdes    do
5367236109Sdes      case \$lt_wr_arg in
5368236109Sdes      --lt-*) ;;
5369236109Sdes      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5370236109Sdes      esac
5371236109Sdes      shift
5372236109Sdes    done ;;
5373236109Sdes  esac
5374228692Sdes  func_exec_program_core \${1+\"\$@\"}
5375228692Sdes}
5376228692Sdes
5377228692Sdes  # Parse options
5378228692Sdes  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5379228692Sdes
5380228692Sdes  # Find the directory that this script lives in.
5381228692Sdes  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
5382228692Sdes  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5383228692Sdes
5384228692Sdes  # Follow symbolic links until we get to the real thisdir.
5385228692Sdes  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
5386228692Sdes  while test -n \"\$file\"; do
5387228692Sdes    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5388228692Sdes
5389228692Sdes    # If there was a directory component, then change thisdir.
5390228692Sdes    if test \"x\$destdir\" != \"x\$file\"; then
5391228692Sdes      case \"\$destdir\" in
5392228692Sdes      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5393228692Sdes      *) thisdir=\"\$thisdir/\$destdir\" ;;
5394228692Sdes      esac
5395228692Sdes    fi
5396228692Sdes
5397228692Sdes    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5398228692Sdes    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
5399228692Sdes  done
5400228692Sdes
5401228692Sdes  # Usually 'no', except on cygwin/mingw when embedded into
5402228692Sdes  # the cwrapper.
5403228692Sdes  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
5404228692Sdes  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
5405228692Sdes    # special case for '.'
5406228692Sdes    if test \"\$thisdir\" = \".\"; then
5407228692Sdes      thisdir=\`pwd\`
5408228692Sdes    fi
5409228692Sdes    # remove .libs from thisdir
5410228692Sdes    case \"\$thisdir\" in
5411228692Sdes    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
5412228692Sdes    $objdir )   thisdir=. ;;
5413228692Sdes    esac
5414228692Sdes  fi
5415228692Sdes
5416228692Sdes  # Try to get the absolute directory name.
5417228692Sdes  absdir=\`cd \"\$thisdir\" && pwd\`
5418228692Sdes  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5419228692Sdes"
5420228692Sdes
5421348980Sdes	if test yes = "$fast_install"; then
5422228692Sdes	  $ECHO "\
5423228692Sdes  program=lt-'$outputname'$exeext
5424228692Sdes  progdir=\"\$thisdir/$objdir\"
5425228692Sdes
5426228692Sdes  if test ! -f \"\$progdir/\$program\" ||
5427348980Sdes     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
5428228692Sdes       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5429228692Sdes
5430228692Sdes    file=\"\$\$-\$program\"
5431228692Sdes
5432228692Sdes    if test ! -d \"\$progdir\"; then
5433228692Sdes      $MKDIR \"\$progdir\"
5434228692Sdes    else
5435228692Sdes      $RM \"\$progdir/\$file\"
5436228692Sdes    fi"
5437228692Sdes
5438228692Sdes	  $ECHO "\
5439228692Sdes
5440228692Sdes    # relink executable if necessary
5441228692Sdes    if test -n \"\$relink_command\"; then
5442228692Sdes      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5443228692Sdes      else
5444348980Sdes	\$ECHO \"\$relink_command_output\" >&2
5445228692Sdes	$RM \"\$progdir/\$file\"
5446228692Sdes	exit 1
5447228692Sdes      fi
5448228692Sdes    fi
5449228692Sdes
5450228692Sdes    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5451228692Sdes    { $RM \"\$progdir/\$program\";
5452228692Sdes      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5453228692Sdes    $RM \"\$progdir/\$file\"
5454228692Sdes  fi"
5455228692Sdes	else
5456228692Sdes	  $ECHO "\
5457228692Sdes  program='$outputname'
5458228692Sdes  progdir=\"\$thisdir/$objdir\"
5459228692Sdes"
5460228692Sdes	fi
5461228692Sdes
5462228692Sdes	$ECHO "\
5463228692Sdes
5464228692Sdes  if test -f \"\$progdir/\$program\"; then"
5465228692Sdes
5466228692Sdes	# fixup the dll searchpath if we need to.
5467228692Sdes	#
5468228692Sdes	# Fix the DLL searchpath if we need to.  Do this before prepending
5469228692Sdes	# to shlibpath, because on Windows, both are PATH and uninstalled
5470228692Sdes	# libraries must come first.
5471228692Sdes	if test -n "$dllsearchpath"; then
5472228692Sdes	  $ECHO "\
5473228692Sdes    # Add the dll search path components to the executable PATH
5474228692Sdes    PATH=$dllsearchpath:\$PATH
5475228692Sdes"
5476228692Sdes	fi
5477228692Sdes
5478228692Sdes	# Export our shlibpath_var if we have one.
5479348980Sdes	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5480228692Sdes	  $ECHO "\
5481228692Sdes    # Add our own library path to $shlibpath_var
5482228692Sdes    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5483228692Sdes
5484228692Sdes    # Some systems cannot cope with colon-terminated $shlibpath_var
5485228692Sdes    # The second colon is a workaround for a bug in BeOS R4 sed
5486228692Sdes    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5487228692Sdes
5488228692Sdes    export $shlibpath_var
5489228692Sdes"
5490228692Sdes	fi
5491228692Sdes
5492228692Sdes	$ECHO "\
5493228692Sdes    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5494228692Sdes      # Run the actual program with our arguments.
5495228692Sdes      func_exec_program \${1+\"\$@\"}
5496228692Sdes    fi
5497228692Sdes  else
5498228692Sdes    # The program doesn't exist.
5499348980Sdes    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
5500228692Sdes    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5501228692Sdes    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
5502228692Sdes    exit 1
5503228692Sdes  fi
5504228692Sdesfi\
5505228692Sdes"
5506228692Sdes}
5507228692Sdes
5508228692Sdes
5509228692Sdes# func_emit_cwrapperexe_src
5510228692Sdes# emit the source code for a wrapper executable on stdout
5511228692Sdes# Must ONLY be called from within func_mode_link because
5512228692Sdes# it depends on a number of variable set therein.
5513228692Sdesfunc_emit_cwrapperexe_src ()
5514228692Sdes{
5515228692Sdes	cat <<EOF
5516228692Sdes
5517228692Sdes/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5518348980Sdes   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5519228692Sdes
5520228692Sdes   The $output program cannot be directly executed until all the libtool
5521228692Sdes   libraries that it depends on are installed.
5522228692Sdes
5523228692Sdes   This wrapper executable should never be moved out of the build directory.
5524228692Sdes   If it is, it will not operate correctly.
5525228692Sdes*/
5526228692SdesEOF
5527228692Sdes	    cat <<"EOF"
5528228692Sdes#ifdef _MSC_VER
5529228692Sdes# define _CRT_SECURE_NO_DEPRECATE 1
5530228692Sdes#endif
5531228692Sdes#include <stdio.h>
5532228692Sdes#include <stdlib.h>
5533228692Sdes#ifdef _MSC_VER
5534228692Sdes# include <direct.h>
5535228692Sdes# include <process.h>
5536228692Sdes# include <io.h>
5537228692Sdes#else
5538228692Sdes# include <unistd.h>
5539228692Sdes# include <stdint.h>
5540228692Sdes# ifdef __CYGWIN__
5541228692Sdes#  include <io.h>
5542228692Sdes# endif
5543228692Sdes#endif
5544228692Sdes#include <malloc.h>
5545228692Sdes#include <stdarg.h>
5546228692Sdes#include <assert.h>
5547228692Sdes#include <string.h>
5548228692Sdes#include <ctype.h>
5549228692Sdes#include <errno.h>
5550228692Sdes#include <fcntl.h>
5551228692Sdes#include <sys/stat.h>
5552228692Sdes
5553348980Sdes#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5554348980Sdes
5555228692Sdes/* declarations of non-ANSI functions */
5556348980Sdes#if defined __MINGW32__
5557228692Sdes# ifdef __STRICT_ANSI__
5558228692Sdesint _putenv (const char *);
5559228692Sdes# endif
5560348980Sdes#elif defined __CYGWIN__
5561228692Sdes# ifdef __STRICT_ANSI__
5562228692Sdeschar *realpath (const char *, char *);
5563228692Sdesint putenv (char *);
5564228692Sdesint setenv (const char *, const char *, int);
5565228692Sdes# endif
5566348980Sdes/* #elif defined other_platform || defined ... */
5567228692Sdes#endif
5568228692Sdes
5569228692Sdes/* portability defines, excluding path handling macros */
5570348980Sdes#if defined _MSC_VER
5571228692Sdes# define setmode _setmode
5572228692Sdes# define stat    _stat
5573228692Sdes# define chmod   _chmod
5574228692Sdes# define getcwd  _getcwd
5575228692Sdes# define putenv  _putenv
5576228692Sdes# define S_IXUSR _S_IEXEC
5577348980Sdes#elif defined __MINGW32__
5578228692Sdes# define setmode _setmode
5579228692Sdes# define stat    _stat
5580228692Sdes# define chmod   _chmod
5581228692Sdes# define getcwd  _getcwd
5582228692Sdes# define putenv  _putenv
5583348980Sdes#elif defined __CYGWIN__
5584228692Sdes# define HAVE_SETENV
5585228692Sdes# define FOPEN_WB "wb"
5586348980Sdes/* #elif defined other platforms ... */
5587228692Sdes#endif
5588228692Sdes
5589348980Sdes#if defined PATH_MAX
5590228692Sdes# define LT_PATHMAX PATH_MAX
5591348980Sdes#elif defined MAXPATHLEN
5592228692Sdes# define LT_PATHMAX MAXPATHLEN
5593228692Sdes#else
5594228692Sdes# define LT_PATHMAX 1024
5595228692Sdes#endif
5596228692Sdes
5597228692Sdes#ifndef S_IXOTH
5598228692Sdes# define S_IXOTH 0
5599228692Sdes#endif
5600228692Sdes#ifndef S_IXGRP
5601228692Sdes# define S_IXGRP 0
5602228692Sdes#endif
5603228692Sdes
5604228692Sdes/* path handling portability macros */
5605228692Sdes#ifndef DIR_SEPARATOR
5606228692Sdes# define DIR_SEPARATOR '/'
5607228692Sdes# define PATH_SEPARATOR ':'
5608228692Sdes#endif
5609228692Sdes
5610348980Sdes#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
5611348980Sdes  defined __OS2__
5612228692Sdes# define HAVE_DOS_BASED_FILE_SYSTEM
5613228692Sdes# define FOPEN_WB "wb"
5614228692Sdes# ifndef DIR_SEPARATOR_2
5615228692Sdes#  define DIR_SEPARATOR_2 '\\'
5616228692Sdes# endif
5617228692Sdes# ifndef PATH_SEPARATOR_2
5618228692Sdes#  define PATH_SEPARATOR_2 ';'
5619228692Sdes# endif
5620228692Sdes#endif
5621228692Sdes
5622228692Sdes#ifndef DIR_SEPARATOR_2
5623228692Sdes# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5624228692Sdes#else /* DIR_SEPARATOR_2 */
5625228692Sdes# define IS_DIR_SEPARATOR(ch) \
5626228692Sdes	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5627228692Sdes#endif /* DIR_SEPARATOR_2 */
5628228692Sdes
5629228692Sdes#ifndef PATH_SEPARATOR_2
5630228692Sdes# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5631228692Sdes#else /* PATH_SEPARATOR_2 */
5632228692Sdes# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5633228692Sdes#endif /* PATH_SEPARATOR_2 */
5634228692Sdes
5635228692Sdes#ifndef FOPEN_WB
5636228692Sdes# define FOPEN_WB "w"
5637228692Sdes#endif
5638228692Sdes#ifndef _O_BINARY
5639228692Sdes# define _O_BINARY 0
5640228692Sdes#endif
5641228692Sdes
5642228692Sdes#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
5643228692Sdes#define XFREE(stale) do { \
5644348980Sdes  if (stale) { free (stale); stale = 0; } \
5645228692Sdes} while (0)
5646228692Sdes
5647348980Sdes#if defined LT_DEBUGWRAPPER
5648228692Sdesstatic int lt_debug = 1;
5649228692Sdes#else
5650228692Sdesstatic int lt_debug = 0;
5651228692Sdes#endif
5652228692Sdes
5653228692Sdesconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5654228692Sdes
5655228692Sdesvoid *xmalloc (size_t num);
5656228692Sdeschar *xstrdup (const char *string);
5657228692Sdesconst char *base_name (const char *name);
5658228692Sdeschar *find_executable (const char *wrapper);
5659228692Sdeschar *chase_symlinks (const char *pathspec);
5660228692Sdesint make_executable (const char *path);
5661228692Sdesint check_executable (const char *path);
5662228692Sdeschar *strendzap (char *str, const char *pat);
5663228692Sdesvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
5664228692Sdesvoid lt_fatal (const char *file, int line, const char *message, ...);
5665228692Sdesstatic const char *nonnull (const char *s);
5666228692Sdesstatic const char *nonempty (const char *s);
5667228692Sdesvoid lt_setenv (const char *name, const char *value);
5668228692Sdeschar *lt_extend_str (const char *orig_value, const char *add, int to_end);
5669228692Sdesvoid lt_update_exe_path (const char *name, const char *value);
5670228692Sdesvoid lt_update_lib_path (const char *name, const char *value);
5671228692Sdeschar **prepare_spawn (char **argv);
5672228692Sdesvoid lt_dump_script (FILE *f);
5673228692SdesEOF
5674228692Sdes
5675228692Sdes	    cat <<EOF
5676348980Sdes#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
5677348980Sdes# define externally_visible volatile
5678348980Sdes#else
5679348980Sdes# define externally_visible __attribute__((externally_visible)) volatile
5680348980Sdes#endif
5681348980Sdesexternally_visible const char * MAGIC_EXE = "$magic_exe";
5682228692Sdesconst char * LIB_PATH_VARNAME = "$shlibpath_var";
5683228692SdesEOF
5684228692Sdes
5685348980Sdes	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5686228692Sdes              func_to_host_path "$temp_rpath"
5687228692Sdes	      cat <<EOF
5688228692Sdesconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
5689228692SdesEOF
5690228692Sdes	    else
5691228692Sdes	      cat <<"EOF"
5692228692Sdesconst char * LIB_PATH_VALUE   = "";
5693228692SdesEOF
5694228692Sdes	    fi
5695228692Sdes
5696228692Sdes	    if test -n "$dllsearchpath"; then
5697228692Sdes              func_to_host_path "$dllsearchpath:"
5698228692Sdes	      cat <<EOF
5699228692Sdesconst char * EXE_PATH_VARNAME = "PATH";
5700228692Sdesconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
5701228692SdesEOF
5702228692Sdes	    else
5703228692Sdes	      cat <<"EOF"
5704228692Sdesconst char * EXE_PATH_VARNAME = "";
5705228692Sdesconst char * EXE_PATH_VALUE   = "";
5706228692SdesEOF
5707228692Sdes	    fi
5708228692Sdes
5709348980Sdes	    if test yes = "$fast_install"; then
5710228692Sdes	      cat <<EOF
5711228692Sdesconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
5712228692SdesEOF
5713228692Sdes	    else
5714228692Sdes	      cat <<EOF
5715228692Sdesconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
5716228692SdesEOF
5717228692Sdes	    fi
5718228692Sdes
5719228692Sdes
5720228692Sdes	    cat <<"EOF"
5721228692Sdes
5722228692Sdes#define LTWRAPPER_OPTION_PREFIX         "--lt-"
5723228692Sdes
5724228692Sdesstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
5725228692Sdesstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
5726228692Sdesstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
5727228692Sdes
5728228692Sdesint
5729228692Sdesmain (int argc, char *argv[])
5730228692Sdes{
5731228692Sdes  char **newargz;
5732228692Sdes  int  newargc;
5733228692Sdes  char *tmp_pathspec;
5734228692Sdes  char *actual_cwrapper_path;
5735228692Sdes  char *actual_cwrapper_name;
5736228692Sdes  char *target_name;
5737228692Sdes  char *lt_argv_zero;
5738348980Sdes  int rval = 127;
5739228692Sdes
5740228692Sdes  int i;
5741228692Sdes
5742228692Sdes  program_name = (char *) xstrdup (base_name (argv[0]));
5743348980Sdes  newargz = XMALLOC (char *, (size_t) argc + 1);
5744228692Sdes
5745228692Sdes  /* very simple arg parsing; don't want to rely on getopt
5746228692Sdes   * also, copy all non cwrapper options to newargz, except
5747228692Sdes   * argz[0], which is handled differently
5748228692Sdes   */
5749228692Sdes  newargc=0;
5750228692Sdes  for (i = 1; i < argc; i++)
5751228692Sdes    {
5752348980Sdes      if (STREQ (argv[i], dumpscript_opt))
5753228692Sdes	{
5754228692SdesEOF
5755348980Sdes	    case $host in
5756228692Sdes	      *mingw* | *cygwin* )
5757228692Sdes		# make stdout use "unix" line endings
5758228692Sdes		echo "          setmode(1,_O_BINARY);"
5759228692Sdes		;;
5760228692Sdes	      esac
5761228692Sdes
5762228692Sdes	    cat <<"EOF"
5763228692Sdes	  lt_dump_script (stdout);
5764228692Sdes	  return 0;
5765228692Sdes	}
5766348980Sdes      if (STREQ (argv[i], debug_opt))
5767228692Sdes	{
5768228692Sdes          lt_debug = 1;
5769228692Sdes          continue;
5770228692Sdes	}
5771348980Sdes      if (STREQ (argv[i], ltwrapper_option_prefix))
5772228692Sdes        {
5773228692Sdes          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5774228692Sdes             namespace, but it is not one of the ones we know about and
5775228692Sdes             have already dealt with, above (inluding dump-script), then
5776228692Sdes             report an error. Otherwise, targets might begin to believe
5777228692Sdes             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5778228692Sdes             namespace. The first time any user complains about this, we'll
5779228692Sdes             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5780228692Sdes             or a configure.ac-settable value.
5781228692Sdes           */
5782228692Sdes          lt_fatal (__FILE__, __LINE__,
5783228692Sdes		    "unrecognized %s option: '%s'",
5784228692Sdes                    ltwrapper_option_prefix, argv[i]);
5785228692Sdes        }
5786228692Sdes      /* otherwise ... */
5787228692Sdes      newargz[++newargc] = xstrdup (argv[i]);
5788228692Sdes    }
5789228692Sdes  newargz[++newargc] = NULL;
5790228692Sdes
5791228692SdesEOF
5792228692Sdes	    cat <<EOF
5793228692Sdes  /* The GNU banner must be the first non-error debug message */
5794348980Sdes  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5795228692SdesEOF
5796228692Sdes	    cat <<"EOF"
5797228692Sdes  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5798228692Sdes  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
5799228692Sdes
5800228692Sdes  tmp_pathspec = find_executable (argv[0]);
5801228692Sdes  if (tmp_pathspec == NULL)
5802228692Sdes    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5803228692Sdes  lt_debugprintf (__FILE__, __LINE__,
5804228692Sdes                  "(main) found exe (before symlink chase) at: %s\n",
5805228692Sdes		  tmp_pathspec);
5806228692Sdes
5807228692Sdes  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5808228692Sdes  lt_debugprintf (__FILE__, __LINE__,
5809228692Sdes                  "(main) found exe (after symlink chase) at: %s\n",
5810228692Sdes		  actual_cwrapper_path);
5811228692Sdes  XFREE (tmp_pathspec);
5812228692Sdes
5813228692Sdes  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
5814228692Sdes  strendzap (actual_cwrapper_path, actual_cwrapper_name);
5815228692Sdes
5816228692Sdes  /* wrapper name transforms */
5817228692Sdes  strendzap (actual_cwrapper_name, ".exe");
5818228692Sdes  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
5819228692Sdes  XFREE (actual_cwrapper_name);
5820228692Sdes  actual_cwrapper_name = tmp_pathspec;
5821228692Sdes  tmp_pathspec = 0;
5822228692Sdes
5823228692Sdes  /* target_name transforms -- use actual target program name; might have lt- prefix */
5824228692Sdes  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
5825228692Sdes  strendzap (target_name, ".exe");
5826228692Sdes  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
5827228692Sdes  XFREE (target_name);
5828228692Sdes  target_name = tmp_pathspec;
5829228692Sdes  tmp_pathspec = 0;
5830228692Sdes
5831228692Sdes  lt_debugprintf (__FILE__, __LINE__,
5832228692Sdes		  "(main) libtool target name: %s\n",
5833228692Sdes		  target_name);
5834228692SdesEOF
5835228692Sdes
5836228692Sdes	    cat <<EOF
5837228692Sdes  newargz[0] =
5838228692Sdes    XMALLOC (char, (strlen (actual_cwrapper_path) +
5839228692Sdes		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
5840228692Sdes  strcpy (newargz[0], actual_cwrapper_path);
5841228692Sdes  strcat (newargz[0], "$objdir");
5842228692Sdes  strcat (newargz[0], "/");
5843228692SdesEOF
5844228692Sdes
5845228692Sdes	    cat <<"EOF"
5846228692Sdes  /* stop here, and copy so we don't have to do this twice */
5847228692Sdes  tmp_pathspec = xstrdup (newargz[0]);
5848228692Sdes
5849228692Sdes  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
5850228692Sdes  strcat (newargz[0], actual_cwrapper_name);
5851228692Sdes
5852228692Sdes  /* DO want the lt- prefix here if it exists, so use target_name */
5853228692Sdes  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
5854228692Sdes  XFREE (tmp_pathspec);
5855228692Sdes  tmp_pathspec = NULL;
5856228692SdesEOF
5857228692Sdes
5858228692Sdes	    case $host_os in
5859228692Sdes	      mingw*)
5860228692Sdes	    cat <<"EOF"
5861228692Sdes  {
5862228692Sdes    char* p;
5863228692Sdes    while ((p = strchr (newargz[0], '\\')) != NULL)
5864228692Sdes      {
5865228692Sdes	*p = '/';
5866228692Sdes      }
5867228692Sdes    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
5868228692Sdes      {
5869228692Sdes	*p = '/';
5870228692Sdes      }
5871228692Sdes  }
5872228692SdesEOF
5873228692Sdes	    ;;
5874228692Sdes	    esac
5875228692Sdes
5876228692Sdes	    cat <<"EOF"
5877228692Sdes  XFREE (target_name);
5878228692Sdes  XFREE (actual_cwrapper_path);
5879228692Sdes  XFREE (actual_cwrapper_name);
5880228692Sdes
5881228692Sdes  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
5882228692Sdes  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
5883228692Sdes  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
5884228692Sdes     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5885228692Sdes     because on Windows, both *_VARNAMEs are PATH but uninstalled
5886228692Sdes     libraries must come first. */
5887228692Sdes  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5888228692Sdes  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
5889228692Sdes
5890228692Sdes  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5891228692Sdes		  nonnull (lt_argv_zero));
5892228692Sdes  for (i = 0; i < newargc; i++)
5893228692Sdes    {
5894228692Sdes      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5895228692Sdes		      i, nonnull (newargz[i]));
5896228692Sdes    }
5897228692Sdes
5898228692SdesEOF
5899228692Sdes
5900228692Sdes	    case $host_os in
5901228692Sdes	      mingw*)
5902228692Sdes		cat <<"EOF"
5903228692Sdes  /* execv doesn't actually work on mingw as expected on unix */
5904228692Sdes  newargz = prepare_spawn (newargz);
5905348980Sdes  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
5906228692Sdes  if (rval == -1)
5907228692Sdes    {
5908228692Sdes      /* failed to start process */
5909228692Sdes      lt_debugprintf (__FILE__, __LINE__,
5910228692Sdes		      "(main) failed to launch target \"%s\": %s\n",
5911228692Sdes		      lt_argv_zero, nonnull (strerror (errno)));
5912228692Sdes      return 127;
5913228692Sdes    }
5914228692Sdes  return rval;
5915228692SdesEOF
5916228692Sdes		;;
5917228692Sdes	      *)
5918228692Sdes		cat <<"EOF"
5919228692Sdes  execv (lt_argv_zero, newargz);
5920228692Sdes  return rval; /* =127, but avoids unused variable warning */
5921228692SdesEOF
5922228692Sdes		;;
5923228692Sdes	    esac
5924228692Sdes
5925228692Sdes	    cat <<"EOF"
5926228692Sdes}
5927228692Sdes
5928228692Sdesvoid *
5929228692Sdesxmalloc (size_t num)
5930228692Sdes{
5931228692Sdes  void *p = (void *) malloc (num);
5932228692Sdes  if (!p)
5933228692Sdes    lt_fatal (__FILE__, __LINE__, "memory exhausted");
5934228692Sdes
5935228692Sdes  return p;
5936228692Sdes}
5937228692Sdes
5938228692Sdeschar *
5939228692Sdesxstrdup (const char *string)
5940228692Sdes{
5941228692Sdes  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
5942228692Sdes			  string) : NULL;
5943228692Sdes}
5944228692Sdes
5945228692Sdesconst char *
5946228692Sdesbase_name (const char *name)
5947228692Sdes{
5948228692Sdes  const char *base;
5949228692Sdes
5950348980Sdes#if defined HAVE_DOS_BASED_FILE_SYSTEM
5951228692Sdes  /* Skip over the disk name in MSDOS pathnames. */
5952228692Sdes  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
5953228692Sdes    name += 2;
5954228692Sdes#endif
5955228692Sdes
5956228692Sdes  for (base = name; *name; name++)
5957228692Sdes    if (IS_DIR_SEPARATOR (*name))
5958228692Sdes      base = name + 1;
5959228692Sdes  return base;
5960228692Sdes}
5961228692Sdes
5962228692Sdesint
5963228692Sdescheck_executable (const char *path)
5964228692Sdes{
5965228692Sdes  struct stat st;
5966228692Sdes
5967228692Sdes  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
5968228692Sdes                  nonempty (path));
5969228692Sdes  if ((!path) || (!*path))
5970228692Sdes    return 0;
5971228692Sdes
5972228692Sdes  if ((stat (path, &st) >= 0)
5973228692Sdes      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
5974228692Sdes    return 1;
5975228692Sdes  else
5976228692Sdes    return 0;
5977228692Sdes}
5978228692Sdes
5979228692Sdesint
5980228692Sdesmake_executable (const char *path)
5981228692Sdes{
5982228692Sdes  int rval = 0;
5983228692Sdes  struct stat st;
5984228692Sdes
5985228692Sdes  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
5986228692Sdes                  nonempty (path));
5987228692Sdes  if ((!path) || (!*path))
5988228692Sdes    return 0;
5989228692Sdes
5990228692Sdes  if (stat (path, &st) >= 0)
5991228692Sdes    {
5992228692Sdes      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
5993228692Sdes    }
5994228692Sdes  return rval;
5995228692Sdes}
5996228692Sdes
5997228692Sdes/* Searches for the full path of the wrapper.  Returns
5998228692Sdes   newly allocated full path name if found, NULL otherwise
5999228692Sdes   Does not chase symlinks, even on platforms that support them.
6000228692Sdes*/
6001228692Sdeschar *
6002228692Sdesfind_executable (const char *wrapper)
6003228692Sdes{
6004228692Sdes  int has_slash = 0;
6005228692Sdes  const char *p;
6006228692Sdes  const char *p_next;
6007228692Sdes  /* static buffer for getcwd */
6008228692Sdes  char tmp[LT_PATHMAX + 1];
6009348980Sdes  size_t tmp_len;
6010228692Sdes  char *concat_name;
6011228692Sdes
6012228692Sdes  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
6013228692Sdes                  nonempty (wrapper));
6014228692Sdes
6015228692Sdes  if ((wrapper == NULL) || (*wrapper == '\0'))
6016228692Sdes    return NULL;
6017228692Sdes
6018228692Sdes  /* Absolute path? */
6019348980Sdes#if defined HAVE_DOS_BASED_FILE_SYSTEM
6020228692Sdes  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
6021228692Sdes    {
6022228692Sdes      concat_name = xstrdup (wrapper);
6023228692Sdes      if (check_executable (concat_name))
6024228692Sdes	return concat_name;
6025228692Sdes      XFREE (concat_name);
6026228692Sdes    }
6027228692Sdes  else
6028228692Sdes    {
6029228692Sdes#endif
6030228692Sdes      if (IS_DIR_SEPARATOR (wrapper[0]))
6031228692Sdes	{
6032228692Sdes	  concat_name = xstrdup (wrapper);
6033228692Sdes	  if (check_executable (concat_name))
6034228692Sdes	    return concat_name;
6035228692Sdes	  XFREE (concat_name);
6036228692Sdes	}
6037348980Sdes#if defined HAVE_DOS_BASED_FILE_SYSTEM
6038228692Sdes    }
6039228692Sdes#endif
6040228692Sdes
6041228692Sdes  for (p = wrapper; *p; p++)
6042228692Sdes    if (*p == '/')
6043228692Sdes      {
6044228692Sdes	has_slash = 1;
6045228692Sdes	break;
6046228692Sdes      }
6047228692Sdes  if (!has_slash)
6048228692Sdes    {
6049228692Sdes      /* no slashes; search PATH */
6050228692Sdes      const char *path = getenv ("PATH");
6051228692Sdes      if (path != NULL)
6052228692Sdes	{
6053228692Sdes	  for (p = path; *p; p = p_next)
6054228692Sdes	    {
6055228692Sdes	      const char *q;
6056228692Sdes	      size_t p_len;
6057228692Sdes	      for (q = p; *q; q++)
6058228692Sdes		if (IS_PATH_SEPARATOR (*q))
6059228692Sdes		  break;
6060348980Sdes	      p_len = (size_t) (q - p);
6061228692Sdes	      p_next = (*q == '\0' ? q : q + 1);
6062228692Sdes	      if (p_len == 0)
6063228692Sdes		{
6064228692Sdes		  /* empty path: current directory */
6065228692Sdes		  if (getcwd (tmp, LT_PATHMAX) == NULL)
6066228692Sdes		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6067228692Sdes                              nonnull (strerror (errno)));
6068228692Sdes		  tmp_len = strlen (tmp);
6069228692Sdes		  concat_name =
6070228692Sdes		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6071228692Sdes		  memcpy (concat_name, tmp, tmp_len);
6072228692Sdes		  concat_name[tmp_len] = '/';
6073228692Sdes		  strcpy (concat_name + tmp_len + 1, wrapper);
6074228692Sdes		}
6075228692Sdes	      else
6076228692Sdes		{
6077228692Sdes		  concat_name =
6078228692Sdes		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
6079228692Sdes		  memcpy (concat_name, p, p_len);
6080228692Sdes		  concat_name[p_len] = '/';
6081228692Sdes		  strcpy (concat_name + p_len + 1, wrapper);
6082228692Sdes		}
6083228692Sdes	      if (check_executable (concat_name))
6084228692Sdes		return concat_name;
6085228692Sdes	      XFREE (concat_name);
6086228692Sdes	    }
6087228692Sdes	}
6088228692Sdes      /* not found in PATH; assume curdir */
6089228692Sdes    }
6090228692Sdes  /* Relative path | not found in path: prepend cwd */
6091228692Sdes  if (getcwd (tmp, LT_PATHMAX) == NULL)
6092228692Sdes    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
6093228692Sdes              nonnull (strerror (errno)));
6094228692Sdes  tmp_len = strlen (tmp);
6095228692Sdes  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
6096228692Sdes  memcpy (concat_name, tmp, tmp_len);
6097228692Sdes  concat_name[tmp_len] = '/';
6098228692Sdes  strcpy (concat_name + tmp_len + 1, wrapper);
6099228692Sdes
6100228692Sdes  if (check_executable (concat_name))
6101228692Sdes    return concat_name;
6102228692Sdes  XFREE (concat_name);
6103228692Sdes  return NULL;
6104228692Sdes}
6105228692Sdes
6106228692Sdeschar *
6107228692Sdeschase_symlinks (const char *pathspec)
6108228692Sdes{
6109228692Sdes#ifndef S_ISLNK
6110228692Sdes  return xstrdup (pathspec);
6111228692Sdes#else
6112228692Sdes  char buf[LT_PATHMAX];
6113228692Sdes  struct stat s;
6114228692Sdes  char *tmp_pathspec = xstrdup (pathspec);
6115228692Sdes  char *p;
6116228692Sdes  int has_symlinks = 0;
6117228692Sdes  while (strlen (tmp_pathspec) && !has_symlinks)
6118228692Sdes    {
6119228692Sdes      lt_debugprintf (__FILE__, __LINE__,
6120228692Sdes		      "checking path component for symlinks: %s\n",
6121228692Sdes		      tmp_pathspec);
6122228692Sdes      if (lstat (tmp_pathspec, &s) == 0)
6123228692Sdes	{
6124228692Sdes	  if (S_ISLNK (s.st_mode) != 0)
6125228692Sdes	    {
6126228692Sdes	      has_symlinks = 1;
6127228692Sdes	      break;
6128228692Sdes	    }
6129228692Sdes
6130228692Sdes	  /* search backwards for last DIR_SEPARATOR */
6131228692Sdes	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
6132228692Sdes	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6133228692Sdes	    p--;
6134228692Sdes	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6135228692Sdes	    {
6136228692Sdes	      /* no more DIR_SEPARATORS left */
6137228692Sdes	      break;
6138228692Sdes	    }
6139228692Sdes	  *p = '\0';
6140228692Sdes	}
6141228692Sdes      else
6142228692Sdes	{
6143228692Sdes	  lt_fatal (__FILE__, __LINE__,
6144228692Sdes		    "error accessing file \"%s\": %s",
6145228692Sdes		    tmp_pathspec, nonnull (strerror (errno)));
6146228692Sdes	}
6147228692Sdes    }
6148228692Sdes  XFREE (tmp_pathspec);
6149228692Sdes
6150228692Sdes  if (!has_symlinks)
6151228692Sdes    {
6152228692Sdes      return xstrdup (pathspec);
6153228692Sdes    }
6154228692Sdes
6155228692Sdes  tmp_pathspec = realpath (pathspec, buf);
6156228692Sdes  if (tmp_pathspec == 0)
6157228692Sdes    {
6158228692Sdes      lt_fatal (__FILE__, __LINE__,
6159228692Sdes		"could not follow symlinks for %s", pathspec);
6160228692Sdes    }
6161228692Sdes  return xstrdup (tmp_pathspec);
6162228692Sdes#endif
6163228692Sdes}
6164228692Sdes
6165228692Sdeschar *
6166228692Sdesstrendzap (char *str, const char *pat)
6167228692Sdes{
6168228692Sdes  size_t len, patlen;
6169228692Sdes
6170228692Sdes  assert (str != NULL);
6171228692Sdes  assert (pat != NULL);
6172228692Sdes
6173228692Sdes  len = strlen (str);
6174228692Sdes  patlen = strlen (pat);
6175228692Sdes
6176228692Sdes  if (patlen <= len)
6177228692Sdes    {
6178228692Sdes      str += len - patlen;
6179348980Sdes      if (STREQ (str, pat))
6180228692Sdes	*str = '\0';
6181228692Sdes    }
6182228692Sdes  return str;
6183228692Sdes}
6184228692Sdes
6185228692Sdesvoid
6186228692Sdeslt_debugprintf (const char *file, int line, const char *fmt, ...)
6187228692Sdes{
6188228692Sdes  va_list args;
6189228692Sdes  if (lt_debug)
6190228692Sdes    {
6191228692Sdes      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6192228692Sdes      va_start (args, fmt);
6193228692Sdes      (void) vfprintf (stderr, fmt, args);
6194228692Sdes      va_end (args);
6195228692Sdes    }
6196228692Sdes}
6197228692Sdes
6198228692Sdesstatic void
6199228692Sdeslt_error_core (int exit_status, const char *file,
6200228692Sdes	       int line, const char *mode,
6201228692Sdes	       const char *message, va_list ap)
6202228692Sdes{
6203228692Sdes  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
6204228692Sdes  vfprintf (stderr, message, ap);
6205228692Sdes  fprintf (stderr, ".\n");
6206228692Sdes
6207228692Sdes  if (exit_status >= 0)
6208228692Sdes    exit (exit_status);
6209228692Sdes}
6210228692Sdes
6211228692Sdesvoid
6212228692Sdeslt_fatal (const char *file, int line, const char *message, ...)
6213228692Sdes{
6214228692Sdes  va_list ap;
6215228692Sdes  va_start (ap, message);
6216228692Sdes  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
6217228692Sdes  va_end (ap);
6218228692Sdes}
6219228692Sdes
6220228692Sdesstatic const char *
6221228692Sdesnonnull (const char *s)
6222228692Sdes{
6223228692Sdes  return s ? s : "(null)";
6224228692Sdes}
6225228692Sdes
6226228692Sdesstatic const char *
6227228692Sdesnonempty (const char *s)
6228228692Sdes{
6229228692Sdes  return (s && !*s) ? "(empty)" : nonnull (s);
6230228692Sdes}
6231228692Sdes
6232228692Sdesvoid
6233228692Sdeslt_setenv (const char *name, const char *value)
6234228692Sdes{
6235228692Sdes  lt_debugprintf (__FILE__, __LINE__,
6236228692Sdes		  "(lt_setenv) setting '%s' to '%s'\n",
6237228692Sdes                  nonnull (name), nonnull (value));
6238228692Sdes  {
6239228692Sdes#ifdef HAVE_SETENV
6240228692Sdes    /* always make a copy, for consistency with !HAVE_SETENV */
6241228692Sdes    char *str = xstrdup (value);
6242228692Sdes    setenv (name, str, 1);
6243228692Sdes#else
6244348980Sdes    size_t len = strlen (name) + 1 + strlen (value) + 1;
6245228692Sdes    char *str = XMALLOC (char, len);
6246228692Sdes    sprintf (str, "%s=%s", name, value);
6247228692Sdes    if (putenv (str) != EXIT_SUCCESS)
6248228692Sdes      {
6249228692Sdes        XFREE (str);
6250228692Sdes      }
6251228692Sdes#endif
6252228692Sdes  }
6253228692Sdes}
6254228692Sdes
6255228692Sdeschar *
6256228692Sdeslt_extend_str (const char *orig_value, const char *add, int to_end)
6257228692Sdes{
6258228692Sdes  char *new_value;
6259228692Sdes  if (orig_value && *orig_value)
6260228692Sdes    {
6261348980Sdes      size_t orig_value_len = strlen (orig_value);
6262348980Sdes      size_t add_len = strlen (add);
6263228692Sdes      new_value = XMALLOC (char, add_len + orig_value_len + 1);
6264228692Sdes      if (to_end)
6265228692Sdes        {
6266228692Sdes          strcpy (new_value, orig_value);
6267228692Sdes          strcpy (new_value + orig_value_len, add);
6268228692Sdes        }
6269228692Sdes      else
6270228692Sdes        {
6271228692Sdes          strcpy (new_value, add);
6272228692Sdes          strcpy (new_value + add_len, orig_value);
6273228692Sdes        }
6274228692Sdes    }
6275228692Sdes  else
6276228692Sdes    {
6277228692Sdes      new_value = xstrdup (add);
6278228692Sdes    }
6279228692Sdes  return new_value;
6280228692Sdes}
6281228692Sdes
6282228692Sdesvoid
6283228692Sdeslt_update_exe_path (const char *name, const char *value)
6284228692Sdes{
6285228692Sdes  lt_debugprintf (__FILE__, __LINE__,
6286228692Sdes		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6287228692Sdes                  nonnull (name), nonnull (value));
6288228692Sdes
6289228692Sdes  if (name && *name && value && *value)
6290228692Sdes    {
6291228692Sdes      char *new_value = lt_extend_str (getenv (name), value, 0);
6292228692Sdes      /* some systems can't cope with a ':'-terminated path #' */
6293348980Sdes      size_t len = strlen (new_value);
6294348980Sdes      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
6295228692Sdes        {
6296348980Sdes          new_value[--len] = '\0';
6297228692Sdes        }
6298228692Sdes      lt_setenv (name, new_value);
6299228692Sdes      XFREE (new_value);
6300228692Sdes    }
6301228692Sdes}
6302228692Sdes
6303228692Sdesvoid
6304228692Sdeslt_update_lib_path (const char *name, const char *value)
6305228692Sdes{
6306228692Sdes  lt_debugprintf (__FILE__, __LINE__,
6307228692Sdes		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6308228692Sdes                  nonnull (name), nonnull (value));
6309228692Sdes
6310228692Sdes  if (name && *name && value && *value)
6311228692Sdes    {
6312228692Sdes      char *new_value = lt_extend_str (getenv (name), value, 0);
6313228692Sdes      lt_setenv (name, new_value);
6314228692Sdes      XFREE (new_value);
6315228692Sdes    }
6316228692Sdes}
6317228692Sdes
6318228692SdesEOF
6319228692Sdes	    case $host_os in
6320228692Sdes	      mingw*)
6321228692Sdes		cat <<"EOF"
6322228692Sdes
6323228692Sdes/* Prepares an argument vector before calling spawn().
6324228692Sdes   Note that spawn() does not by itself call the command interpreter
6325228692Sdes     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6326228692Sdes      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6327228692Sdes         GetVersionEx(&v);
6328228692Sdes         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6329228692Sdes      }) ? "cmd.exe" : "command.com").
6330228692Sdes   Instead it simply concatenates the arguments, separated by ' ', and calls
6331228692Sdes   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
6332228692Sdes   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6333228692Sdes   special way:
6334228692Sdes   - Space and tab are interpreted as delimiters. They are not treated as
6335228692Sdes     delimiters if they are surrounded by double quotes: "...".
6336228692Sdes   - Unescaped double quotes are removed from the input. Their only effect is
6337228692Sdes     that within double quotes, space and tab are treated like normal
6338228692Sdes     characters.
6339228692Sdes   - Backslashes not followed by double quotes are not special.
6340228692Sdes   - But 2*n+1 backslashes followed by a double quote become
6341228692Sdes     n backslashes followed by a double quote (n >= 0):
6342228692Sdes       \" -> "
6343228692Sdes       \\\" -> \"
6344228692Sdes       \\\\\" -> \\"
6345228692Sdes */
6346228692Sdes#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"
6347228692Sdes#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"
6348228692Sdeschar **
6349228692Sdesprepare_spawn (char **argv)
6350228692Sdes{
6351228692Sdes  size_t argc;
6352228692Sdes  char **new_argv;
6353228692Sdes  size_t i;
6354228692Sdes
6355228692Sdes  /* Count number of arguments.  */
6356228692Sdes  for (argc = 0; argv[argc] != NULL; argc++)
6357228692Sdes    ;
6358228692Sdes
6359228692Sdes  /* Allocate new argument vector.  */
6360228692Sdes  new_argv = XMALLOC (char *, argc + 1);
6361228692Sdes
6362228692Sdes  /* Put quoted arguments into the new argument vector.  */
6363228692Sdes  for (i = 0; i < argc; i++)
6364228692Sdes    {
6365228692Sdes      const char *string = argv[i];
6366228692Sdes
6367228692Sdes      if (string[0] == '\0')
6368228692Sdes	new_argv[i] = xstrdup ("\"\"");
6369228692Sdes      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6370228692Sdes	{
6371228692Sdes	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6372228692Sdes	  size_t length;
6373228692Sdes	  unsigned int backslashes;
6374228692Sdes	  const char *s;
6375228692Sdes	  char *quoted_string;
6376228692Sdes	  char *p;
6377228692Sdes
6378228692Sdes	  length = 0;
6379228692Sdes	  backslashes = 0;
6380228692Sdes	  if (quote_around)
6381228692Sdes	    length++;
6382228692Sdes	  for (s = string; *s != '\0'; s++)
6383228692Sdes	    {
6384228692Sdes	      char c = *s;
6385228692Sdes	      if (c == '"')
6386228692Sdes		length += backslashes + 1;
6387228692Sdes	      length++;
6388228692Sdes	      if (c == '\\')
6389228692Sdes		backslashes++;
6390228692Sdes	      else
6391228692Sdes		backslashes = 0;
6392228692Sdes	    }
6393228692Sdes	  if (quote_around)
6394228692Sdes	    length += backslashes + 1;
6395228692Sdes
6396228692Sdes	  quoted_string = XMALLOC (char, length + 1);
6397228692Sdes
6398228692Sdes	  p = quoted_string;
6399228692Sdes	  backslashes = 0;
6400228692Sdes	  if (quote_around)
6401228692Sdes	    *p++ = '"';
6402228692Sdes	  for (s = string; *s != '\0'; s++)
6403228692Sdes	    {
6404228692Sdes	      char c = *s;
6405228692Sdes	      if (c == '"')
6406228692Sdes		{
6407228692Sdes		  unsigned int j;
6408228692Sdes		  for (j = backslashes + 1; j > 0; j--)
6409228692Sdes		    *p++ = '\\';
6410228692Sdes		}
6411228692Sdes	      *p++ = c;
6412228692Sdes	      if (c == '\\')
6413228692Sdes		backslashes++;
6414228692Sdes	      else
6415228692Sdes		backslashes = 0;
6416228692Sdes	    }
6417228692Sdes	  if (quote_around)
6418228692Sdes	    {
6419228692Sdes	      unsigned int j;
6420228692Sdes	      for (j = backslashes; j > 0; j--)
6421228692Sdes		*p++ = '\\';
6422228692Sdes	      *p++ = '"';
6423228692Sdes	    }
6424228692Sdes	  *p = '\0';
6425228692Sdes
6426228692Sdes	  new_argv[i] = quoted_string;
6427228692Sdes	}
6428228692Sdes      else
6429228692Sdes	new_argv[i] = (char *) string;
6430228692Sdes    }
6431228692Sdes  new_argv[argc] = NULL;
6432228692Sdes
6433228692Sdes  return new_argv;
6434228692Sdes}
6435228692SdesEOF
6436228692Sdes		;;
6437228692Sdes	    esac
6438228692Sdes
6439228692Sdes            cat <<"EOF"
6440228692Sdesvoid lt_dump_script (FILE* f)
6441228692Sdes{
6442228692SdesEOF
6443228692Sdes	    func_emit_wrapper yes |
6444236109Sdes	      $SED -n -e '
6445236109Sdess/^\(.\{79\}\)\(..*\)/\1\
6446236109Sdes\2/
6447236109Sdesh
6448236109Sdess/\([\\"]\)/\\\1/g
6449236109Sdess/$/\\n/
6450236109Sdess/\([^\n]*\).*/  fputs ("\1", f);/p
6451236109Sdesg
6452236109SdesD'
6453228692Sdes            cat <<"EOF"
6454228692Sdes}
6455228692SdesEOF
6456228692Sdes}
6457228692Sdes# end: func_emit_cwrapperexe_src
6458228692Sdes
6459228692Sdes# func_win32_import_lib_p ARG
6460228692Sdes# True if ARG is an import lib, as indicated by $file_magic_cmd
6461228692Sdesfunc_win32_import_lib_p ()
6462228692Sdes{
6463348980Sdes    $debug_cmd
6464348980Sdes
6465228692Sdes    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6466228692Sdes    *import*) : ;;
6467228692Sdes    *) false ;;
6468228692Sdes    esac
6469228692Sdes}
6470228692Sdes
6471348980Sdes# func_suncc_cstd_abi
6472348980Sdes# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
6473348980Sdes# Several compiler flags select an ABI that is incompatible with the
6474348980Sdes# Cstd library. Avoid specifying it if any are in CXXFLAGS.
6475348980Sdesfunc_suncc_cstd_abi ()
6476348980Sdes{
6477348980Sdes    $debug_cmd
6478348980Sdes
6479348980Sdes    case " $compile_command " in
6480348980Sdes    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
6481348980Sdes      suncc_use_cstd_abi=no
6482348980Sdes      ;;
6483348980Sdes    *)
6484348980Sdes      suncc_use_cstd_abi=yes
6485348980Sdes      ;;
6486348980Sdes    esac
6487348980Sdes}
6488348980Sdes
6489228692Sdes# func_mode_link arg...
6490228692Sdesfunc_mode_link ()
6491228692Sdes{
6492348980Sdes    $debug_cmd
6493348980Sdes
6494125647Sdes    case $host in
6495228692Sdes    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6496117610Sdes      # It is impossible to link a dll without this setting, and
6497117610Sdes      # we shouldn't force the makefile maintainer to figure out
6498348980Sdes      # what system we are compiling for in order to pass an extra
6499141098Sdes      # flag for every libtool invocation.
6500117610Sdes      # allow_undefined=no
6501117610Sdes
6502117610Sdes      # FIXME: Unfortunately, there are problems with the above when trying
6503348980Sdes      # to make a dll that has undefined symbols, in which case not
6504117610Sdes      # even a static library is built.  For now, we need to specify
6505117610Sdes      # -no-undefined on the libtool link line when we can be certain
6506117610Sdes      # that all symbols are satisfied, otherwise we get a static library.
6507117610Sdes      allow_undefined=yes
6508117610Sdes      ;;
6509117610Sdes    *)
6510117610Sdes      allow_undefined=yes
6511117610Sdes      ;;
6512117610Sdes    esac
6513228692Sdes    libtool_args=$nonopt
6514141098Sdes    base_compile="$nonopt $@"
6515228692Sdes    compile_command=$nonopt
6516228692Sdes    finalize_command=$nonopt
6517117610Sdes
6518117610Sdes    compile_rpath=
6519117610Sdes    finalize_rpath=
6520117610Sdes    compile_shlibpath=
6521117610Sdes    finalize_shlibpath=
6522117610Sdes    convenience=
6523117610Sdes    old_convenience=
6524117610Sdes    deplibs=
6525125647Sdes    old_deplibs=
6526125647Sdes    compiler_flags=
6527125647Sdes    linker_flags=
6528125647Sdes    dllsearchpath=
6529125647Sdes    lib_search_path=`pwd`
6530141098Sdes    inst_prefix_dir=
6531228692Sdes    new_inherited_linker_flags=
6532117610Sdes
6533117610Sdes    avoid_version=no
6534228692Sdes    bindir=
6535117610Sdes    dlfiles=
6536117610Sdes    dlprefiles=
6537117610Sdes    dlself=no
6538117610Sdes    export_dynamic=no
6539117610Sdes    export_symbols=
6540117610Sdes    export_symbols_regex=
6541117610Sdes    generated=
6542117610Sdes    libobjs=
6543117610Sdes    ltlibs=
6544117610Sdes    module=no
6545125647Sdes    no_install=no
6546117610Sdes    objs=
6547348980Sdes    os2dllname=
6548141098Sdes    non_pic_objects=
6549141098Sdes    precious_files_regex=
6550117610Sdes    prefer_static_libs=no
6551348980Sdes    preload=false
6552117610Sdes    prev=
6553117610Sdes    prevarg=
6554117610Sdes    release=
6555117610Sdes    rpath=
6556117610Sdes    xrpath=
6557117610Sdes    perm_rpath=
6558117610Sdes    temp_rpath=
6559117610Sdes    thread_safe=no
6560117610Sdes    vinfo=
6561141098Sdes    vinfo_number=no
6562228692Sdes    weak_libs=
6563348980Sdes    single_module=$wl-single_module
6564141098Sdes    func_infer_tag $base_compile
6565141098Sdes
6566117610Sdes    # We need to know -static, to get the right output filenames.
6567117610Sdes    for arg
6568117610Sdes    do
6569125647Sdes      case $arg in
6570228692Sdes      -shared)
6571348980Sdes	test yes != "$build_libtool_libs" \
6572348980Sdes	  && func_fatal_configuration "cannot build a shared library"
6573228692Sdes	build_old_libs=no
6574228692Sdes	break
6575228692Sdes	;;
6576174832Sdes      -all-static | -static | -static-libtool-libs)
6577174832Sdes	case $arg in
6578174832Sdes	-all-static)
6579348980Sdes	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
6580228692Sdes	    func_warning "complete static linking is impossible in this configuration"
6581117610Sdes	  fi
6582117610Sdes	  if test -n "$link_static_flag"; then
6583117610Sdes	    dlopen_self=$dlopen_self_static
6584117610Sdes	  fi
6585174832Sdes	  prefer_static_libs=yes
6586174832Sdes	  ;;
6587174832Sdes	-static)
6588117610Sdes	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6589117610Sdes	    dlopen_self=$dlopen_self_static
6590117610Sdes	  fi
6591174832Sdes	  prefer_static_libs=built
6592174832Sdes	  ;;
6593174832Sdes	-static-libtool-libs)
6594174832Sdes	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
6595174832Sdes	    dlopen_self=$dlopen_self_static
6596174832Sdes	  fi
6597174832Sdes	  prefer_static_libs=yes
6598174832Sdes	  ;;
6599174832Sdes	esac
6600117610Sdes	build_libtool_libs=no
6601117610Sdes	build_old_libs=yes
6602117610Sdes	break
6603117610Sdes	;;
6604117610Sdes      esac
6605117610Sdes    done
6606117610Sdes
6607117610Sdes    # See if our shared archives depend on static archives.
6608117610Sdes    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6609117610Sdes
6610117610Sdes    # Go through the arguments, transforming them on the way.
6611141098Sdes    while test "$#" -gt 0; do
6612348980Sdes      arg=$1
6613117610Sdes      shift
6614228692Sdes      func_quote_for_eval "$arg"
6615228692Sdes      qarg=$func_quote_for_eval_unquoted_result
6616228692Sdes      func_append libtool_args " $func_quote_for_eval_result"
6617117610Sdes
6618117610Sdes      # If the previous option needs an argument, assign it.
6619117610Sdes      if test -n "$prev"; then
6620125647Sdes	case $prev in
6621117610Sdes	output)
6622228692Sdes	  func_append compile_command " @OUTPUT@"
6623228692Sdes	  func_append finalize_command " @OUTPUT@"
6624117610Sdes	  ;;
6625117610Sdes	esac
6626117610Sdes
6627125647Sdes	case $prev in
6628228692Sdes	bindir)
6629348980Sdes	  bindir=$arg
6630228692Sdes	  prev=
6631228692Sdes	  continue
6632228692Sdes	  ;;
6633117610Sdes	dlfiles|dlprefiles)
6634348980Sdes	  $preload || {
6635117610Sdes	    # Add the symbol object into the linking commands.
6636228692Sdes	    func_append compile_command " @SYMFILE@"
6637228692Sdes	    func_append finalize_command " @SYMFILE@"
6638348980Sdes	    preload=:
6639348980Sdes	  }
6640125647Sdes	  case $arg in
6641117610Sdes	  *.la | *.lo) ;;  # We handle these cases below.
6642117610Sdes	  force)
6643348980Sdes	    if test no = "$dlself"; then
6644117610Sdes	      dlself=needless
6645117610Sdes	      export_dynamic=yes
6646117610Sdes	    fi
6647117610Sdes	    prev=
6648117610Sdes	    continue
6649117610Sdes	    ;;
6650117610Sdes	  self)
6651348980Sdes	    if test dlprefiles = "$prev"; then
6652117610Sdes	      dlself=yes
6653348980Sdes	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
6654117610Sdes	      dlself=yes
6655117610Sdes	    else
6656117610Sdes	      dlself=needless
6657117610Sdes	      export_dynamic=yes
6658117610Sdes	    fi
6659117610Sdes	    prev=
6660117610Sdes	    continue
6661117610Sdes	    ;;
6662117610Sdes	  *)
6663348980Sdes	    if test dlfiles = "$prev"; then
6664228692Sdes	      func_append dlfiles " $arg"
6665117610Sdes	    else
6666228692Sdes	      func_append dlprefiles " $arg"
6667117610Sdes	    fi
6668117610Sdes	    prev=
6669125647Sdes	    continue
6670117610Sdes	    ;;
6671117610Sdes	  esac
6672117610Sdes	  ;;
6673117610Sdes	expsyms)
6674348980Sdes	  export_symbols=$arg
6675228692Sdes	  test -f "$arg" \
6676348980Sdes	    || func_fatal_error "symbol file '$arg' does not exist"
6677117610Sdes	  prev=
6678117610Sdes	  continue
6679117610Sdes	  ;;
6680117610Sdes	expsyms_regex)
6681348980Sdes	  export_symbols_regex=$arg
6682117610Sdes	  prev=
6683117610Sdes	  continue
6684117610Sdes	  ;;
6685228692Sdes	framework)
6686228692Sdes	  case $host in
6687228692Sdes	    *-*-darwin*)
6688228692Sdes	      case "$deplibs " in
6689228692Sdes		*" $qarg.ltframework "*) ;;
6690228692Sdes		*) func_append deplibs " $qarg.ltframework" # this is fixed later
6691228692Sdes		   ;;
6692228692Sdes	      esac
6693228692Sdes	      ;;
6694228692Sdes	  esac
6695141098Sdes	  prev=
6696141098Sdes	  continue
6697141098Sdes	  ;;
6698228692Sdes	inst_prefix)
6699348980Sdes	  inst_prefix_dir=$arg
6700141098Sdes	  prev=
6701141098Sdes	  continue
6702141098Sdes	  ;;
6703348980Sdes	mllvm)
6704348980Sdes	  # Clang does not use LLVM to link, so we can simply discard any
6705348980Sdes	  # '-mllvm $arg' options when doing the link step.
6706348980Sdes	  prev=
6707348980Sdes	  continue
6708348980Sdes	  ;;
6709141098Sdes	objectlist)
6710141098Sdes	  if test -f "$arg"; then
6711141098Sdes	    save_arg=$arg
6712141098Sdes	    moreargs=
6713228692Sdes	    for fil in `cat "$save_arg"`
6714141098Sdes	    do
6715228692Sdes#	      func_append moreargs " $fil"
6716141098Sdes	      arg=$fil
6717141098Sdes	      # A libtool-controlled object.
6718141098Sdes
6719141098Sdes	      # Check to see that this really is a libtool object.
6720228692Sdes	      if func_lalib_unsafe_p "$arg"; then
6721141098Sdes		pic_object=
6722141098Sdes		non_pic_object=
6723141098Sdes
6724141098Sdes		# Read the .lo file
6725228692Sdes		func_source "$arg"
6726141098Sdes
6727228692Sdes		if test -z "$pic_object" ||
6728141098Sdes		   test -z "$non_pic_object" ||
6729348980Sdes		   test none = "$pic_object" &&
6730348980Sdes		   test none = "$non_pic_object"; then
6731348980Sdes		  func_fatal_error "cannot find name of object for '$arg'"
6732141098Sdes		fi
6733141098Sdes
6734141098Sdes		# Extract subdirectory from the argument.
6735228692Sdes		func_dirname "$arg" "/" ""
6736348980Sdes		xdir=$func_dirname_result
6737141098Sdes
6738348980Sdes		if test none != "$pic_object"; then
6739141098Sdes		  # Prepend the subdirectory the object is found in.
6740348980Sdes		  pic_object=$xdir$pic_object
6741141098Sdes
6742348980Sdes		  if test dlfiles = "$prev"; then
6743348980Sdes		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6744228692Sdes		      func_append dlfiles " $pic_object"
6745141098Sdes		      prev=
6746141098Sdes		      continue
6747141098Sdes		    else
6748141098Sdes		      # If libtool objects are unsupported, then we need to preload.
6749141098Sdes		      prev=dlprefiles
6750141098Sdes		    fi
6751141098Sdes		  fi
6752141098Sdes
6753141098Sdes		  # CHECK ME:  I think I busted this.  -Ossama
6754348980Sdes		  if test dlprefiles = "$prev"; then
6755141098Sdes		    # Preload the old-style object.
6756228692Sdes		    func_append dlprefiles " $pic_object"
6757141098Sdes		    prev=
6758141098Sdes		  fi
6759141098Sdes
6760141098Sdes		  # A PIC object.
6761228692Sdes		  func_append libobjs " $pic_object"
6762348980Sdes		  arg=$pic_object
6763141098Sdes		fi
6764141098Sdes
6765141098Sdes		# Non-PIC object.
6766348980Sdes		if test none != "$non_pic_object"; then
6767141098Sdes		  # Prepend the subdirectory the object is found in.
6768348980Sdes		  non_pic_object=$xdir$non_pic_object
6769141098Sdes
6770141098Sdes		  # A standard non-PIC object
6771228692Sdes		  func_append non_pic_objects " $non_pic_object"
6772348980Sdes		  if test -z "$pic_object" || test none = "$pic_object"; then
6773348980Sdes		    arg=$non_pic_object
6774141098Sdes		  fi
6775174832Sdes		else
6776174832Sdes		  # If the PIC object exists, use it instead.
6777174832Sdes		  # $xdir was prepended to $pic_object above.
6778348980Sdes		  non_pic_object=$pic_object
6779228692Sdes		  func_append non_pic_objects " $non_pic_object"
6780141098Sdes		fi
6781141098Sdes	      else
6782141098Sdes		# Only an error if not doing a dry-run.
6783228692Sdes		if $opt_dry_run; then
6784141098Sdes		  # Extract subdirectory from the argument.
6785228692Sdes		  func_dirname "$arg" "/" ""
6786348980Sdes		  xdir=$func_dirname_result
6787141098Sdes
6788228692Sdes		  func_lo2o "$arg"
6789228692Sdes		  pic_object=$xdir$objdir/$func_lo2o_result
6790228692Sdes		  non_pic_object=$xdir$func_lo2o_result
6791228692Sdes		  func_append libobjs " $pic_object"
6792228692Sdes		  func_append non_pic_objects " $non_pic_object"
6793228692Sdes	        else
6794348980Sdes		  func_fatal_error "'$arg' is not a valid libtool object"
6795141098Sdes		fi
6796141098Sdes	      fi
6797141098Sdes	    done
6798141098Sdes	  else
6799348980Sdes	    func_fatal_error "link input file '$arg' does not exist"
6800141098Sdes	  fi
6801141098Sdes	  arg=$save_arg
6802141098Sdes	  prev=
6803141098Sdes	  continue
6804141098Sdes	  ;;
6805348980Sdes	os2dllname)
6806348980Sdes	  os2dllname=$arg
6807348980Sdes	  prev=
6808348980Sdes	  continue
6809348980Sdes	  ;;
6810228692Sdes	precious_regex)
6811348980Sdes	  precious_files_regex=$arg
6812228692Sdes	  prev=
6813228692Sdes	  continue
6814228692Sdes	  ;;
6815228692Sdes	release)
6816348980Sdes	  release=-$arg
6817228692Sdes	  prev=
6818228692Sdes	  continue
6819228692Sdes	  ;;
6820117610Sdes	rpath | xrpath)
6821117610Sdes	  # We need an absolute path.
6822125647Sdes	  case $arg in
6823117610Sdes	  [\\/]* | [A-Za-z]:[\\/]*) ;;
6824117610Sdes	  *)
6825228692Sdes	    func_fatal_error "only absolute run-paths are allowed"
6826117610Sdes	    ;;
6827117610Sdes	  esac
6828348980Sdes	  if test rpath = "$prev"; then
6829117610Sdes	    case "$rpath " in
6830117610Sdes	    *" $arg "*) ;;
6831228692Sdes	    *) func_append rpath " $arg" ;;
6832117610Sdes	    esac
6833117610Sdes	  else
6834117610Sdes	    case "$xrpath " in
6835117610Sdes	    *" $arg "*) ;;
6836228692Sdes	    *) func_append xrpath " $arg" ;;
6837117610Sdes	    esac
6838117610Sdes	  fi
6839117610Sdes	  prev=
6840117610Sdes	  continue
6841117610Sdes	  ;;
6842228692Sdes	shrext)
6843348980Sdes	  shrext_cmds=$arg
6844125647Sdes	  prev=
6845125647Sdes	  continue
6846125647Sdes	  ;;
6847228692Sdes	weak)
6848228692Sdes	  func_append weak_libs " $arg"
6849125647Sdes	  prev=
6850125647Sdes	  continue
6851125647Sdes	  ;;
6852141098Sdes	xcclinker)
6853228692Sdes	  func_append linker_flags " $qarg"
6854228692Sdes	  func_append compiler_flags " $qarg"
6855141098Sdes	  prev=
6856228692Sdes	  func_append compile_command " $qarg"
6857228692Sdes	  func_append finalize_command " $qarg"
6858141098Sdes	  continue
6859141098Sdes	  ;;
6860228692Sdes	xcompiler)
6861228692Sdes	  func_append compiler_flags " $qarg"
6862141098Sdes	  prev=
6863228692Sdes	  func_append compile_command " $qarg"
6864228692Sdes	  func_append finalize_command " $qarg"
6865141098Sdes	  continue
6866141098Sdes	  ;;
6867228692Sdes	xlinker)
6868228692Sdes	  func_append linker_flags " $qarg"
6869228692Sdes	  func_append compiler_flags " $wl$qarg"
6870147455Sdes	  prev=
6871228692Sdes	  func_append compile_command " $wl$qarg"
6872228692Sdes	  func_append finalize_command " $wl$qarg"
6873147455Sdes	  continue
6874147455Sdes	  ;;
6875117610Sdes	*)
6876117610Sdes	  eval "$prev=\"\$arg\""
6877117610Sdes	  prev=
6878117610Sdes	  continue
6879117610Sdes	  ;;
6880117610Sdes	esac
6881141098Sdes      fi # test -n "$prev"
6882117610Sdes
6883348980Sdes      prevarg=$arg
6884117610Sdes
6885125647Sdes      case $arg in
6886117610Sdes      -all-static)
6887117610Sdes	if test -n "$link_static_flag"; then
6888228692Sdes	  # See comment for -static flag below, for more details.
6889228692Sdes	  func_append compile_command " $link_static_flag"
6890228692Sdes	  func_append finalize_command " $link_static_flag"
6891117610Sdes	fi
6892117610Sdes	continue
6893117610Sdes	;;
6894117610Sdes
6895117610Sdes      -allow-undefined)
6896117610Sdes	# FIXME: remove this flag sometime in the future.
6897348980Sdes	func_fatal_error "'-allow-undefined' must not be used because it is the default"
6898117610Sdes	;;
6899117610Sdes
6900117610Sdes      -avoid-version)
6901117610Sdes	avoid_version=yes
6902117610Sdes	continue
6903117610Sdes	;;
6904117610Sdes
6905228692Sdes      -bindir)
6906228692Sdes	prev=bindir
6907228692Sdes	continue
6908228692Sdes	;;
6909228692Sdes
6910117610Sdes      -dlopen)
6911117610Sdes	prev=dlfiles
6912117610Sdes	continue
6913117610Sdes	;;
6914117610Sdes
6915117610Sdes      -dlpreopen)
6916117610Sdes	prev=dlprefiles
6917117610Sdes	continue
6918117610Sdes	;;
6919117610Sdes
6920117610Sdes      -export-dynamic)
6921117610Sdes	export_dynamic=yes
6922117610Sdes	continue
6923117610Sdes	;;
6924117610Sdes
6925117610Sdes      -export-symbols | -export-symbols-regex)
6926117610Sdes	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
6927228692Sdes	  func_fatal_error "more than one -exported-symbols argument is not allowed"
6928117610Sdes	fi
6929348980Sdes	if test X-export-symbols = "X$arg"; then
6930117610Sdes	  prev=expsyms
6931117610Sdes	else
6932117610Sdes	  prev=expsyms_regex
6933117610Sdes	fi
6934117610Sdes	continue
6935117610Sdes	;;
6936117610Sdes
6937228692Sdes      -framework)
6938228692Sdes	prev=framework
6939174832Sdes	continue
6940174832Sdes	;;
6941147455Sdes
6942141098Sdes      -inst-prefix-dir)
6943141098Sdes	prev=inst_prefix
6944141098Sdes	continue
6945141098Sdes	;;
6946141098Sdes
6947125647Sdes      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
6948125647Sdes      # so, if we see these flags be careful not to treat them like -L
6949125647Sdes      -L[A-Z][A-Z]*:*)
6950125647Sdes	case $with_gcc/$host in
6951141098Sdes	no/*-*-irix* | /*-*-irix*)
6952228692Sdes	  func_append compile_command " $arg"
6953228692Sdes	  func_append finalize_command " $arg"
6954125647Sdes	  ;;
6955125647Sdes	esac
6956125647Sdes	continue
6957125647Sdes	;;
6958125647Sdes
6959117610Sdes      -L*)
6960228692Sdes	func_stripname "-L" '' "$arg"
6961228692Sdes	if test -z "$func_stripname_result"; then
6962228692Sdes	  if test "$#" -gt 0; then
6963348980Sdes	    func_fatal_error "require no space between '-L' and '$1'"
6964228692Sdes	  else
6965348980Sdes	    func_fatal_error "need path for '-L' option"
6966228692Sdes	  fi
6967228692Sdes	fi
6968228692Sdes	func_resolve_sysroot "$func_stripname_result"
6969228692Sdes	dir=$func_resolve_sysroot_result
6970117610Sdes	# We need an absolute path.
6971125647Sdes	case $dir in
6972117610Sdes	[\\/]* | [A-Za-z]:[\\/]*) ;;
6973117610Sdes	*)
6974117610Sdes	  absdir=`cd "$dir" && pwd`
6975228692Sdes	  test -z "$absdir" && \
6976348980Sdes	    func_fatal_error "cannot determine absolute directory name of '$dir'"
6977348980Sdes	  dir=$absdir
6978117610Sdes	  ;;
6979117610Sdes	esac
6980125647Sdes	case "$deplibs " in
6981228692Sdes	*" -L$dir "* | *" $arg "*)
6982228692Sdes	  # Will only happen for absolute or sysroot arguments
6983228692Sdes	  ;;
6984125647Sdes	*)
6985228692Sdes	  # Preserve sysroot, but never include relative directories
6986228692Sdes	  case $dir in
6987228692Sdes	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
6988228692Sdes	    *) func_append deplibs " -L$dir" ;;
6989228692Sdes	  esac
6990228692Sdes	  func_append lib_search_path " $dir"
6991125647Sdes	  ;;
6992117610Sdes	esac
6993125647Sdes	case $host in
6994228692Sdes	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6995228692Sdes	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
6996125647Sdes	  case :$dllsearchpath: in
6997125647Sdes	  *":$dir:"*) ;;
6998228692Sdes	  ::) dllsearchpath=$dir;;
6999228692Sdes	  *) func_append dllsearchpath ":$dir";;
7000117610Sdes	  esac
7001174832Sdes	  case :$dllsearchpath: in
7002174832Sdes	  *":$testbindir:"*) ;;
7003228692Sdes	  ::) dllsearchpath=$testbindir;;
7004228692Sdes	  *) func_append dllsearchpath ":$testbindir";;
7005174832Sdes	  esac
7006117610Sdes	  ;;
7007117610Sdes	esac
7008125647Sdes	continue
7009117610Sdes	;;
7010117610Sdes
7011117610Sdes      -l*)
7012348980Sdes	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
7013125647Sdes	  case $host in
7014228692Sdes	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
7015125647Sdes	    # These systems don't actually have a C or math library (as such)
7016117610Sdes	    continue
7017117610Sdes	    ;;
7018174832Sdes	  *-*-os2*)
7019125647Sdes	    # These systems don't actually have a C library (as such)
7020348980Sdes	    test X-lc = "X$arg" && continue
7021125647Sdes	    ;;
7022348980Sdes	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7023125647Sdes	    # Do not include libc due to us having libc/libc_r.
7024348980Sdes	    test X-lc = "X$arg" && continue
7025125647Sdes	    ;;
7026141098Sdes	  *-*-rhapsody* | *-*-darwin1.[012])
7027141098Sdes	    # Rhapsody C and math libraries are in the System framework
7028228692Sdes	    func_append deplibs " System.ltframework"
7029117610Sdes	    continue
7030174832Sdes	    ;;
7031174832Sdes	  *-*-sco3.2v5* | *-*-sco5v6*)
7032174832Sdes	    # Causes problems with __ctype
7033348980Sdes	    test X-lc = "X$arg" && continue
7034174832Sdes	    ;;
7035174832Sdes	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7036174832Sdes	    # Compiler inserts libc in the correct place for threads to work
7037348980Sdes	    test X-lc = "X$arg" && continue
7038174832Sdes	    ;;
7039117610Sdes	  esac
7040348980Sdes	elif test X-lc_r = "X$arg"; then
7041141098Sdes	 case $host in
7042348980Sdes	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
7043141098Sdes	   # Do not include libc_r directly, use -pthread flag.
7044141098Sdes	   continue
7045141098Sdes	   ;;
7046141098Sdes	 esac
7047117610Sdes	fi
7048228692Sdes	func_append deplibs " $arg"
7049125647Sdes	continue
7050117610Sdes	;;
7051117610Sdes
7052348980Sdes      -mllvm)
7053348980Sdes	prev=mllvm
7054348980Sdes	continue
7055348980Sdes	;;
7056348980Sdes
7057228692Sdes      -module)
7058228692Sdes	module=yes
7059228692Sdes	continue
7060228692Sdes	;;
7061228692Sdes
7062147455Sdes      # Tru64 UNIX uses -model [arg] to determine the layout of C++
7063147455Sdes      # classes, name mangling, and exception handling.
7064228692Sdes      # Darwin uses the -arch flag to determine output architecture.
7065228692Sdes      -model|-arch|-isysroot|--sysroot)
7066228692Sdes	func_append compiler_flags " $arg"
7067228692Sdes	func_append compile_command " $arg"
7068228692Sdes	func_append finalize_command " $arg"
7069147455Sdes	prev=xcompiler
7070147455Sdes	continue
7071147455Sdes	;;
7072147455Sdes
7073236109Sdes      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7074236109Sdes      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7075228692Sdes	func_append compiler_flags " $arg"
7076228692Sdes	func_append compile_command " $arg"
7077228692Sdes	func_append finalize_command " $arg"
7078228692Sdes	case "$new_inherited_linker_flags " in
7079228692Sdes	    *" $arg "*) ;;
7080228692Sdes	    * ) func_append new_inherited_linker_flags " $arg" ;;
7081228692Sdes	esac
7082141098Sdes	continue
7083141098Sdes	;;
7084141098Sdes
7085228692Sdes      -multi_module)
7086348980Sdes	single_module=$wl-multi_module
7087141098Sdes	continue
7088141098Sdes	;;
7089141098Sdes
7090125647Sdes      -no-fast-install)
7091125647Sdes	fast_install=no
7092125647Sdes	continue
7093125647Sdes	;;
7094125647Sdes
7095125647Sdes      -no-install)
7096125647Sdes	case $host in
7097228692Sdes	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
7098125647Sdes	  # The PATH hackery in wrapper scripts is required on Windows
7099174832Sdes	  # and Darwin in order for the loader to find any dlls it needs.
7100348980Sdes	  func_warning "'-no-install' is ignored for $host"
7101348980Sdes	  func_warning "assuming '-no-fast-install' instead"
7102125647Sdes	  fast_install=no
7103125647Sdes	  ;;
7104125647Sdes	*) no_install=yes ;;
7105125647Sdes	esac
7106125647Sdes	continue
7107125647Sdes	;;
7108125647Sdes
7109117610Sdes      -no-undefined)
7110117610Sdes	allow_undefined=no
7111117610Sdes	continue
7112117610Sdes	;;
7113117610Sdes
7114141098Sdes      -objectlist)
7115141098Sdes	prev=objectlist
7116141098Sdes	continue
7117141098Sdes	;;
7118141098Sdes
7119348980Sdes      -os2dllname)
7120348980Sdes	prev=os2dllname
7121348980Sdes	continue
7122348980Sdes	;;
7123348980Sdes
7124117610Sdes      -o) prev=output ;;
7125117610Sdes
7126141098Sdes      -precious-files-regex)
7127141098Sdes	prev=precious_regex
7128141098Sdes	continue
7129141098Sdes	;;
7130141098Sdes
7131117610Sdes      -release)
7132117610Sdes	prev=release
7133117610Sdes	continue
7134117610Sdes	;;
7135117610Sdes
7136117610Sdes      -rpath)
7137117610Sdes	prev=rpath
7138117610Sdes	continue
7139117610Sdes	;;
7140117610Sdes
7141117610Sdes      -R)
7142117610Sdes	prev=xrpath
7143117610Sdes	continue
7144117610Sdes	;;
7145117610Sdes
7146117610Sdes      -R*)
7147228692Sdes	func_stripname '-R' '' "$arg"
7148228692Sdes	dir=$func_stripname_result
7149117610Sdes	# We need an absolute path.
7150125647Sdes	case $dir in
7151117610Sdes	[\\/]* | [A-Za-z]:[\\/]*) ;;
7152228692Sdes	=*)
7153228692Sdes	  func_stripname '=' '' "$dir"
7154228692Sdes	  dir=$lt_sysroot$func_stripname_result
7155228692Sdes	  ;;
7156117610Sdes	*)
7157228692Sdes	  func_fatal_error "only absolute run-paths are allowed"
7158117610Sdes	  ;;
7159117610Sdes	esac
7160117610Sdes	case "$xrpath " in
7161117610Sdes	*" $dir "*) ;;
7162228692Sdes	*) func_append xrpath " $dir" ;;
7163117610Sdes	esac
7164117610Sdes	continue
7165117610Sdes	;;
7166117610Sdes
7167228692Sdes      -shared)
7168228692Sdes	# The effects of -shared are defined in a previous loop.
7169228692Sdes	continue
7170228692Sdes	;;
7171228692Sdes
7172228692Sdes      -shrext)
7173228692Sdes	prev=shrext
7174228692Sdes	continue
7175228692Sdes	;;
7176228692Sdes
7177174832Sdes      -static | -static-libtool-libs)
7178125647Sdes	# The effects of -static are defined in a previous loop.
7179125647Sdes	# We used to do the same as -all-static on platforms that
7180125647Sdes	# didn't have a PIC flag, but the assumption that the effects
7181125647Sdes	# would be equivalent was wrong.  It would break on at least
7182125647Sdes	# Digital Unix and AIX.
7183117610Sdes	continue
7184117610Sdes	;;
7185117610Sdes
7186117610Sdes      -thread-safe)
7187117610Sdes	thread_safe=yes
7188117610Sdes	continue
7189117610Sdes	;;
7190117610Sdes
7191117610Sdes      -version-info)
7192117610Sdes	prev=vinfo
7193117610Sdes	continue
7194117610Sdes	;;
7195228692Sdes
7196141098Sdes      -version-number)
7197141098Sdes	prev=vinfo
7198141098Sdes	vinfo_number=yes
7199141098Sdes	continue
7200141098Sdes	;;
7201117610Sdes
7202228692Sdes      -weak)
7203228692Sdes        prev=weak
7204228692Sdes	continue
7205228692Sdes	;;
7206228692Sdes
7207125647Sdes      -Wc,*)
7208228692Sdes	func_stripname '-Wc,' '' "$arg"
7209228692Sdes	args=$func_stripname_result
7210125647Sdes	arg=
7211348980Sdes	save_ifs=$IFS; IFS=,
7212125647Sdes	for flag in $args; do
7213348980Sdes	  IFS=$save_ifs
7214228692Sdes          func_quote_for_eval "$flag"
7215228692Sdes	  func_append arg " $func_quote_for_eval_result"
7216228692Sdes	  func_append compiler_flags " $func_quote_for_eval_result"
7217125647Sdes	done
7218348980Sdes	IFS=$save_ifs
7219228692Sdes	func_stripname ' ' '' "$arg"
7220228692Sdes	arg=$func_stripname_result
7221125647Sdes	;;
7222125647Sdes
7223125647Sdes      -Wl,*)
7224228692Sdes	func_stripname '-Wl,' '' "$arg"
7225228692Sdes	args=$func_stripname_result
7226125647Sdes	arg=
7227348980Sdes	save_ifs=$IFS; IFS=,
7228125647Sdes	for flag in $args; do
7229348980Sdes	  IFS=$save_ifs
7230228692Sdes          func_quote_for_eval "$flag"
7231228692Sdes	  func_append arg " $wl$func_quote_for_eval_result"
7232228692Sdes	  func_append compiler_flags " $wl$func_quote_for_eval_result"
7233228692Sdes	  func_append linker_flags " $func_quote_for_eval_result"
7234125647Sdes	done
7235348980Sdes	IFS=$save_ifs
7236228692Sdes	func_stripname ' ' '' "$arg"
7237228692Sdes	arg=$func_stripname_result
7238125647Sdes	;;
7239125647Sdes
7240125647Sdes      -Xcompiler)
7241125647Sdes	prev=xcompiler
7242125647Sdes	continue
7243125647Sdes	;;
7244125647Sdes
7245125647Sdes      -Xlinker)
7246125647Sdes	prev=xlinker
7247125647Sdes	continue
7248125647Sdes	;;
7249125647Sdes
7250141098Sdes      -XCClinker)
7251141098Sdes	prev=xcclinker
7252141098Sdes	continue
7253141098Sdes	;;
7254141098Sdes
7255228692Sdes      # -msg_* for osf cc
7256228692Sdes      -msg_*)
7257228692Sdes	func_quote_for_eval "$arg"
7258348980Sdes	arg=$func_quote_for_eval_result
7259228692Sdes	;;
7260228692Sdes
7261228692Sdes      # Flags to be passed through unchanged, with rationale:
7262228692Sdes      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
7263228692Sdes      # -r[0-9][0-9]*        specify processor for the SGI compiler
7264228692Sdes      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7265228692Sdes      # +DA*, +DD*           enable 64-bit mode for the HP compiler
7266228692Sdes      # -q*                  compiler args for the IBM compiler
7267228692Sdes      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7268228692Sdes      # -F/path              path to uninstalled frameworks, gcc on darwin
7269228692Sdes      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
7270348980Sdes      # -fstack-protector*   stack protector flags for GCC
7271228692Sdes      # @file                GCC response files
7272228692Sdes      # -tp=*                Portland pgcc target processor selection
7273228692Sdes      # --sysroot=*          for sysroot support
7274348980Sdes      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
7275348980Sdes      # -stdlib=*            select c++ std lib with clang
7276228692Sdes      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7277228692Sdes      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
7278348980Sdes      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
7279228692Sdes        func_quote_for_eval "$arg"
7280348980Sdes	arg=$func_quote_for_eval_result
7281228692Sdes        func_append compile_command " $arg"
7282228692Sdes        func_append finalize_command " $arg"
7283228692Sdes        func_append compiler_flags " $arg"
7284228692Sdes        continue
7285228692Sdes        ;;
7286228692Sdes
7287348980Sdes      -Z*)
7288348980Sdes        if test os2 = "`expr $host : '.*\(os2\)'`"; then
7289348980Sdes          # OS/2 uses -Zxxx to specify OS/2-specific options
7290348980Sdes	  compiler_flags="$compiler_flags $arg"
7291348980Sdes	  func_append compile_command " $arg"
7292348980Sdes	  func_append finalize_command " $arg"
7293348980Sdes	  case $arg in
7294348980Sdes	  -Zlinker | -Zstack)
7295348980Sdes	    prev=xcompiler
7296348980Sdes	    ;;
7297348980Sdes	  esac
7298348980Sdes	  continue
7299348980Sdes        else
7300348980Sdes	  # Otherwise treat like 'Some other compiler flag' below
7301348980Sdes	  func_quote_for_eval "$arg"
7302348980Sdes	  arg=$func_quote_for_eval_result
7303348980Sdes        fi
7304348980Sdes	;;
7305348980Sdes
7306117610Sdes      # Some other compiler flag.
7307117610Sdes      -* | +*)
7308228692Sdes        func_quote_for_eval "$arg"
7309348980Sdes	arg=$func_quote_for_eval_result
7310117610Sdes	;;
7311117610Sdes
7312141098Sdes      *.$objext)
7313141098Sdes	# A standard object.
7314228692Sdes	func_append objs " $arg"
7315141098Sdes	;;
7316141098Sdes
7317141098Sdes      *.lo)
7318141098Sdes	# A libtool-controlled object.
7319141098Sdes
7320141098Sdes	# Check to see that this really is a libtool object.
7321228692Sdes	if func_lalib_unsafe_p "$arg"; then
7322141098Sdes	  pic_object=
7323141098Sdes	  non_pic_object=
7324141098Sdes
7325141098Sdes	  # Read the .lo file
7326228692Sdes	  func_source "$arg"
7327141098Sdes
7328228692Sdes	  if test -z "$pic_object" ||
7329141098Sdes	     test -z "$non_pic_object" ||
7330348980Sdes	     test none = "$pic_object" &&
7331348980Sdes	     test none = "$non_pic_object"; then
7332348980Sdes	    func_fatal_error "cannot find name of object for '$arg'"
7333117610Sdes	  fi
7334117610Sdes
7335141098Sdes	  # Extract subdirectory from the argument.
7336228692Sdes	  func_dirname "$arg" "/" ""
7337348980Sdes	  xdir=$func_dirname_result
7338141098Sdes
7339348980Sdes	  test none = "$pic_object" || {
7340141098Sdes	    # Prepend the subdirectory the object is found in.
7341348980Sdes	    pic_object=$xdir$pic_object
7342141098Sdes
7343348980Sdes	    if test dlfiles = "$prev"; then
7344348980Sdes	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7345228692Sdes		func_append dlfiles " $pic_object"
7346141098Sdes		prev=
7347141098Sdes		continue
7348141098Sdes	      else
7349141098Sdes		# If libtool objects are unsupported, then we need to preload.
7350141098Sdes		prev=dlprefiles
7351141098Sdes	      fi
7352141098Sdes	    fi
7353141098Sdes
7354141098Sdes	    # CHECK ME:  I think I busted this.  -Ossama
7355348980Sdes	    if test dlprefiles = "$prev"; then
7356141098Sdes	      # Preload the old-style object.
7357228692Sdes	      func_append dlprefiles " $pic_object"
7358141098Sdes	      prev=
7359141098Sdes	    fi
7360141098Sdes
7361141098Sdes	    # A PIC object.
7362228692Sdes	    func_append libobjs " $pic_object"
7363348980Sdes	    arg=$pic_object
7364348980Sdes	  }
7365141098Sdes
7366141098Sdes	  # Non-PIC object.
7367348980Sdes	  if test none != "$non_pic_object"; then
7368141098Sdes	    # Prepend the subdirectory the object is found in.
7369348980Sdes	    non_pic_object=$xdir$non_pic_object
7370141098Sdes
7371141098Sdes	    # A standard non-PIC object
7372228692Sdes	    func_append non_pic_objects " $non_pic_object"
7373348980Sdes	    if test -z "$pic_object" || test none = "$pic_object"; then
7374348980Sdes	      arg=$non_pic_object
7375141098Sdes	    fi
7376174832Sdes	  else
7377174832Sdes	    # If the PIC object exists, use it instead.
7378174832Sdes	    # $xdir was prepended to $pic_object above.
7379348980Sdes	    non_pic_object=$pic_object
7380228692Sdes	    func_append non_pic_objects " $non_pic_object"
7381141098Sdes	  fi
7382125647Sdes	else
7383141098Sdes	  # Only an error if not doing a dry-run.
7384228692Sdes	  if $opt_dry_run; then
7385141098Sdes	    # Extract subdirectory from the argument.
7386228692Sdes	    func_dirname "$arg" "/" ""
7387348980Sdes	    xdir=$func_dirname_result
7388141098Sdes
7389228692Sdes	    func_lo2o "$arg"
7390228692Sdes	    pic_object=$xdir$objdir/$func_lo2o_result
7391228692Sdes	    non_pic_object=$xdir$func_lo2o_result
7392228692Sdes	    func_append libobjs " $pic_object"
7393228692Sdes	    func_append non_pic_objects " $non_pic_object"
7394228692Sdes	  else
7395348980Sdes	    func_fatal_error "'$arg' is not a valid libtool object"
7396141098Sdes	  fi
7397117610Sdes	fi
7398117610Sdes	;;
7399117610Sdes
7400125647Sdes      *.$libext)
7401125647Sdes	# An archive.
7402228692Sdes	func_append deplibs " $arg"
7403228692Sdes	func_append old_deplibs " $arg"
7404125647Sdes	continue
7405125647Sdes	;;
7406125647Sdes
7407117610Sdes      *.la)
7408117610Sdes	# A libtool-controlled library.
7409117610Sdes
7410228692Sdes	func_resolve_sysroot "$arg"
7411348980Sdes	if test dlfiles = "$prev"; then
7412125647Sdes	  # This library was specified with -dlopen.
7413228692Sdes	  func_append dlfiles " $func_resolve_sysroot_result"
7414125647Sdes	  prev=
7415348980Sdes	elif test dlprefiles = "$prev"; then
7416125647Sdes	  # The library was specified with -dlpreopen.
7417228692Sdes	  func_append dlprefiles " $func_resolve_sysroot_result"
7418125647Sdes	  prev=
7419125647Sdes	else
7420228692Sdes	  func_append deplibs " $func_resolve_sysroot_result"
7421125647Sdes	fi
7422125647Sdes	continue
7423125647Sdes	;;
7424117610Sdes
7425125647Sdes      # Some other compiler argument.
7426125647Sdes      *)
7427125647Sdes	# Unknown arguments in both finalize_command and compile_command need
7428125647Sdes	# to be aesthetically quoted because they are evaled later.
7429228692Sdes	func_quote_for_eval "$arg"
7430348980Sdes	arg=$func_quote_for_eval_result
7431125647Sdes	;;
7432125647Sdes      esac # arg
7433125647Sdes
7434125647Sdes      # Now actually substitute the argument into the commands.
7435125647Sdes      if test -n "$arg"; then
7436228692Sdes	func_append compile_command " $arg"
7437228692Sdes	func_append finalize_command " $arg"
7438125647Sdes      fi
7439125647Sdes    done # argument parsing loop
7440125647Sdes
7441228692Sdes    test -n "$prev" && \
7442348980Sdes      func_fatal_help "the '$prevarg' option requires an argument"
7443125647Sdes
7444348980Sdes    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
7445125647Sdes      eval arg=\"$export_dynamic_flag_spec\"
7446228692Sdes      func_append compile_command " $arg"
7447228692Sdes      func_append finalize_command " $arg"
7448125647Sdes    fi
7449125647Sdes
7450141098Sdes    oldlibs=
7451125647Sdes    # calculate the name of the file, without its directory
7452228692Sdes    func_basename "$output"
7453348980Sdes    outputname=$func_basename_result
7454348980Sdes    libobjs_save=$libobjs
7455125647Sdes
7456125647Sdes    if test -n "$shlibpath_var"; then
7457125647Sdes      # get the directories listed in $shlibpath_var
7458348980Sdes      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7459125647Sdes    else
7460125647Sdes      shlib_search_path=
7461125647Sdes    fi
7462125647Sdes    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
7463125647Sdes    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7464125647Sdes
7465348980Sdes    # Definition is injected by LT_CONFIG during libtool generation.
7466348980Sdes    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
7467348980Sdes
7468228692Sdes    func_dirname "$output" "/" ""
7469348980Sdes    output_objdir=$func_dirname_result$objdir
7470228692Sdes    func_to_tool_file "$output_objdir/"
7471228692Sdes    tool_output_objdir=$func_to_tool_file_result
7472125647Sdes    # Create the object directory.
7473228692Sdes    func_mkdir_p "$output_objdir"
7474125647Sdes
7475125647Sdes    # Determine the type of output
7476125647Sdes    case $output in
7477125647Sdes    "")
7478228692Sdes      func_fatal_help "you must specify an output file"
7479125647Sdes      ;;
7480125647Sdes    *.$libext) linkmode=oldlib ;;
7481125647Sdes    *.lo | *.$objext) linkmode=obj ;;
7482125647Sdes    *.la) linkmode=lib ;;
7483125647Sdes    *) linkmode=prog ;; # Anything else should be a program.
7484125647Sdes    esac
7485125647Sdes
7486125647Sdes    specialdeplibs=
7487141098Sdes
7488125647Sdes    libs=
7489125647Sdes    # Find all interdependent deplibs by searching for libraries
7490125647Sdes    # that are linked more than once (e.g. -la -lb -la)
7491125647Sdes    for deplib in $deplibs; do
7492348980Sdes      if $opt_preserve_dup_deps; then
7493125647Sdes	case "$libs " in
7494228692Sdes	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
7495125647Sdes	esac
7496125647Sdes      fi
7497228692Sdes      func_append libs " $deplib"
7498125647Sdes    done
7499141098Sdes
7500348980Sdes    if test lib = "$linkmode"; then
7501141098Sdes      libs="$predeps $libs $compiler_lib_search_path $postdeps"
7502141098Sdes
7503141098Sdes      # Compute libraries that are listed more than once in $predeps
7504141098Sdes      # $postdeps and mark them as special (i.e., whose duplicates are
7505141098Sdes      # not to be eliminated).
7506141098Sdes      pre_post_deps=
7507228692Sdes      if $opt_duplicate_compiler_generated_deps; then
7508141098Sdes	for pre_post_dep in $predeps $postdeps; do
7509141098Sdes	  case "$pre_post_deps " in
7510228692Sdes	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
7511141098Sdes	  esac
7512228692Sdes	  func_append pre_post_deps " $pre_post_dep"
7513141098Sdes	done
7514141098Sdes      fi
7515141098Sdes      pre_post_deps=
7516141098Sdes    fi
7517141098Sdes
7518125647Sdes    deplibs=
7519125647Sdes    newdependency_libs=
7520125647Sdes    newlib_search_path=
7521125647Sdes    need_relink=no # whether we're linking any uninstalled libtool libraries
7522125647Sdes    notinst_deplibs= # not-installed libtool libraries
7523228692Sdes    notinst_path= # paths that contain not-installed libtool libraries
7524228692Sdes
7525125647Sdes    case $linkmode in
7526125647Sdes    lib)
7527228692Sdes	passes="conv dlpreopen link"
7528125647Sdes	for file in $dlfiles $dlprefiles; do
7529125647Sdes	  case $file in
7530125647Sdes	  *.la) ;;
7531125647Sdes	  *)
7532348980Sdes	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
7533125647Sdes	    ;;
7534125647Sdes	  esac
7535125647Sdes	done
7536125647Sdes	;;
7537125647Sdes    prog)
7538125647Sdes	compile_deplibs=
7539125647Sdes	finalize_deplibs=
7540348980Sdes	alldeplibs=false
7541125647Sdes	newdlfiles=
7542125647Sdes	newdlprefiles=
7543125647Sdes	passes="conv scan dlopen dlpreopen link"
7544125647Sdes	;;
7545125647Sdes    *)  passes="conv"
7546125647Sdes	;;
7547125647Sdes    esac
7548228692Sdes
7549125647Sdes    for pass in $passes; do
7550228692Sdes      # The preopen pass in lib mode reverses $deplibs; put it back here
7551228692Sdes      # so that -L comes before libs that need it for instance...
7552348980Sdes      if test lib,link = "$linkmode,$pass"; then
7553228692Sdes	## FIXME: Find the place where the list is rebuilt in the wrong
7554228692Sdes	##        order, and fix it there properly
7555228692Sdes        tmp_deplibs=
7556228692Sdes	for deplib in $deplibs; do
7557228692Sdes	  tmp_deplibs="$deplib $tmp_deplibs"
7558228692Sdes	done
7559348980Sdes	deplibs=$tmp_deplibs
7560228692Sdes      fi
7561228692Sdes
7562348980Sdes      if test lib,link = "$linkmode,$pass" ||
7563348980Sdes	 test prog,scan = "$linkmode,$pass"; then
7564348980Sdes	libs=$deplibs
7565141098Sdes	deplibs=
7566141098Sdes      fi
7567348980Sdes      if test prog = "$linkmode"; then
7568125647Sdes	case $pass in
7569348980Sdes	dlopen) libs=$dlfiles ;;
7570348980Sdes	dlpreopen) libs=$dlprefiles ;;
7571125647Sdes	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
7572125647Sdes	esac
7573125647Sdes      fi
7574348980Sdes      if test lib,dlpreopen = "$linkmode,$pass"; then
7575228692Sdes	# Collect and forward deplibs of preopened libtool libs
7576228692Sdes	for lib in $dlprefiles; do
7577228692Sdes	  # Ignore non-libtool-libs
7578228692Sdes	  dependency_libs=
7579228692Sdes	  func_resolve_sysroot "$lib"
7580228692Sdes	  case $lib in
7581228692Sdes	  *.la)	func_source "$func_resolve_sysroot_result" ;;
7582228692Sdes	  esac
7583228692Sdes
7584228692Sdes	  # Collect preopened libtool deplibs, except any this library
7585228692Sdes	  # has declared as weak libs
7586228692Sdes	  for deplib in $dependency_libs; do
7587228692Sdes	    func_basename "$deplib"
7588228692Sdes            deplib_base=$func_basename_result
7589228692Sdes	    case " $weak_libs " in
7590228692Sdes	    *" $deplib_base "*) ;;
7591228692Sdes	    *) func_append deplibs " $deplib" ;;
7592228692Sdes	    esac
7593228692Sdes	  done
7594228692Sdes	done
7595348980Sdes	libs=$dlprefiles
7596228692Sdes      fi
7597348980Sdes      if test dlopen = "$pass"; then
7598141098Sdes	# Collect dlpreopened libraries
7599348980Sdes	save_deplibs=$deplibs
7600141098Sdes	deplibs=
7601141098Sdes      fi
7602228692Sdes
7603125647Sdes      for deplib in $libs; do
7604125647Sdes	lib=
7605348980Sdes	found=false
7606125647Sdes	case $deplib in
7607236109Sdes	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7608236109Sdes        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7609348980Sdes	  if test prog,link = "$linkmode,$pass"; then
7610141098Sdes	    compile_deplibs="$deplib $compile_deplibs"
7611141098Sdes	    finalize_deplibs="$deplib $finalize_deplibs"
7612141098Sdes	  else
7613228692Sdes	    func_append compiler_flags " $deplib"
7614348980Sdes	    if test lib = "$linkmode"; then
7615348980Sdes		case "$new_inherited_linker_flags " in
7616348980Sdes		    *" $deplib "*) ;;
7617348980Sdes		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7618348980Sdes		esac
7619348980Sdes	    fi
7620141098Sdes	  fi
7621141098Sdes	  continue
7622141098Sdes	  ;;
7623125647Sdes	-l*)
7624348980Sdes	  if test lib != "$linkmode" && test prog != "$linkmode"; then
7625348980Sdes	    func_warning "'-l' is ignored for archives/objects"
7626125647Sdes	    continue
7627125647Sdes	  fi
7628228692Sdes	  func_stripname '-l' '' "$deplib"
7629228692Sdes	  name=$func_stripname_result
7630348980Sdes	  if test lib = "$linkmode"; then
7631228692Sdes	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
7632228692Sdes	  else
7633228692Sdes	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
7634228692Sdes	  fi
7635228692Sdes	  for searchdir in $searchdirs; do
7636141098Sdes	    for search_ext in .la $std_shrext .so .a; do
7637141098Sdes	      # Search the libtool library
7638348980Sdes	      lib=$searchdir/lib$name$search_ext
7639141098Sdes	      if test -f "$lib"; then
7640348980Sdes		if test .la = "$search_ext"; then
7641348980Sdes		  found=:
7642141098Sdes		else
7643348980Sdes		  found=false
7644141098Sdes		fi
7645141098Sdes		break 2
7646141098Sdes	      fi
7647141098Sdes	    done
7648125647Sdes	  done
7649348980Sdes	  if $found; then
7650348980Sdes	    # deplib is a libtool library
7651141098Sdes	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
7652141098Sdes	    # We need to do some special things here, and not later.
7653348980Sdes	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
7654141098Sdes	      case " $predeps $postdeps " in
7655141098Sdes	      *" $deplib "*)
7656228692Sdes		if func_lalib_p "$lib"; then
7657141098Sdes		  library_names=
7658141098Sdes		  old_library=
7659228692Sdes		  func_source "$lib"
7660141098Sdes		  for l in $old_library $library_names; do
7661348980Sdes		    ll=$l
7662141098Sdes		  done
7663348980Sdes		  if test "X$ll" = "X$old_library"; then # only static version available
7664348980Sdes		    found=false
7665228692Sdes		    func_dirname "$lib" "" "."
7666348980Sdes		    ladir=$func_dirname_result
7667141098Sdes		    lib=$ladir/$old_library
7668348980Sdes		    if test prog,link = "$linkmode,$pass"; then
7669141098Sdes		      compile_deplibs="$deplib $compile_deplibs"
7670141098Sdes		      finalize_deplibs="$deplib $finalize_deplibs"
7671141098Sdes		    else
7672141098Sdes		      deplibs="$deplib $deplibs"
7673348980Sdes		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7674141098Sdes		    fi
7675141098Sdes		    continue
7676141098Sdes		  fi
7677141098Sdes		fi
7678228692Sdes		;;
7679141098Sdes	      *) ;;
7680141098Sdes	      esac
7681141098Sdes	    fi
7682348980Sdes	  else
7683348980Sdes	    # deplib doesn't seem to be a libtool library
7684348980Sdes	    if test prog,link = "$linkmode,$pass"; then
7685348980Sdes	      compile_deplibs="$deplib $compile_deplibs"
7686348980Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
7687348980Sdes	    else
7688348980Sdes	      deplibs="$deplib $deplibs"
7689348980Sdes	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7690348980Sdes	    fi
7691348980Sdes	    continue
7692125647Sdes	  fi
7693125647Sdes	  ;; # -l
7694228692Sdes	*.ltframework)
7695348980Sdes	  if test prog,link = "$linkmode,$pass"; then
7696228692Sdes	    compile_deplibs="$deplib $compile_deplibs"
7697228692Sdes	    finalize_deplibs="$deplib $finalize_deplibs"
7698228692Sdes	  else
7699228692Sdes	    deplibs="$deplib $deplibs"
7700348980Sdes	    if test lib = "$linkmode"; then
7701228692Sdes		case "$new_inherited_linker_flags " in
7702228692Sdes		    *" $deplib "*) ;;
7703228692Sdes		    * ) func_append new_inherited_linker_flags " $deplib" ;;
7704228692Sdes		esac
7705228692Sdes	    fi
7706228692Sdes	  fi
7707228692Sdes	  continue
7708228692Sdes	  ;;
7709125647Sdes	-L*)
7710125647Sdes	  case $linkmode in
7711125647Sdes	  lib)
7712125647Sdes	    deplibs="$deplib $deplibs"
7713348980Sdes	    test conv = "$pass" && continue
7714125647Sdes	    newdependency_libs="$deplib $newdependency_libs"
7715228692Sdes	    func_stripname '-L' '' "$deplib"
7716228692Sdes	    func_resolve_sysroot "$func_stripname_result"
7717228692Sdes	    func_append newlib_search_path " $func_resolve_sysroot_result"
7718125647Sdes	    ;;
7719125647Sdes	  prog)
7720348980Sdes	    if test conv = "$pass"; then
7721125647Sdes	      deplibs="$deplib $deplibs"
7722125647Sdes	      continue
7723125647Sdes	    fi
7724348980Sdes	    if test scan = "$pass"; then
7725125647Sdes	      deplibs="$deplib $deplibs"
7726125647Sdes	    else
7727125647Sdes	      compile_deplibs="$deplib $compile_deplibs"
7728125647Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
7729125647Sdes	    fi
7730228692Sdes	    func_stripname '-L' '' "$deplib"
7731228692Sdes	    func_resolve_sysroot "$func_stripname_result"
7732228692Sdes	    func_append newlib_search_path " $func_resolve_sysroot_result"
7733125647Sdes	    ;;
7734125647Sdes	  *)
7735348980Sdes	    func_warning "'-L' is ignored for archives/objects"
7736125647Sdes	    ;;
7737125647Sdes	  esac # linkmode
7738125647Sdes	  continue
7739125647Sdes	  ;; # -L
7740125647Sdes	-R*)
7741348980Sdes	  if test link = "$pass"; then
7742228692Sdes	    func_stripname '-R' '' "$deplib"
7743228692Sdes	    func_resolve_sysroot "$func_stripname_result"
7744228692Sdes	    dir=$func_resolve_sysroot_result
7745125647Sdes	    # Make sure the xrpath contains only unique directories.
7746125647Sdes	    case "$xrpath " in
7747125647Sdes	    *" $dir "*) ;;
7748228692Sdes	    *) func_append xrpath " $dir" ;;
7749125647Sdes	    esac
7750125647Sdes	  fi
7751125647Sdes	  deplibs="$deplib $deplibs"
7752125647Sdes	  continue
7753125647Sdes	  ;;
7754228692Sdes	*.la)
7755228692Sdes	  func_resolve_sysroot "$deplib"
7756228692Sdes	  lib=$func_resolve_sysroot_result
7757228692Sdes	  ;;
7758125647Sdes	*.$libext)
7759348980Sdes	  if test conv = "$pass"; then
7760125647Sdes	    deplibs="$deplib $deplibs"
7761125647Sdes	    continue
7762125647Sdes	  fi
7763125647Sdes	  case $linkmode in
7764125647Sdes	  lib)
7765228692Sdes	    # Linking convenience modules into shared libraries is allowed,
7766228692Sdes	    # but linking other static libraries is non-portable.
7767228692Sdes	    case " $dlpreconveniencelibs " in
7768228692Sdes	    *" $deplib "*) ;;
7769228692Sdes	    *)
7770348980Sdes	      valid_a_lib=false
7771228692Sdes	      case $deplibs_check_method in
7772228692Sdes		match_pattern*)
7773228692Sdes		  set dummy $deplibs_check_method; shift
7774228692Sdes		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7775228692Sdes		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
7776141098Sdes		    | $EGREP "$match_pattern_regex" > /dev/null; then
7777348980Sdes		    valid_a_lib=:
7778228692Sdes		  fi
7779228692Sdes		;;
7780228692Sdes		pass_all)
7781348980Sdes		  valid_a_lib=:
7782141098Sdes		;;
7783228692Sdes	      esac
7784348980Sdes	      if $valid_a_lib; then
7785228692Sdes		echo
7786348980Sdes		$ECHO "*** Warning: Linking the shared library $output against the"
7787348980Sdes		$ECHO "*** static library $deplib is not portable!"
7788348980Sdes		deplibs="$deplib $deplibs"
7789348980Sdes	      else
7790348980Sdes		echo
7791228692Sdes		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
7792228692Sdes		echo "*** I have the capability to make that library automatically link in when"
7793228692Sdes		echo "*** you link to this library.  But I can only do this if you have a"
7794228692Sdes		echo "*** shared version of the library, which you do not appear to have"
7795228692Sdes		echo "*** because the file extensions .$libext of this argument makes me believe"
7796228692Sdes		echo "*** that it is just a static archive that I should not use here."
7797228692Sdes	      fi
7798228692Sdes	      ;;
7799228692Sdes	    esac
7800125647Sdes	    continue
7801125647Sdes	    ;;
7802125647Sdes	  prog)
7803348980Sdes	    if test link != "$pass"; then
7804125647Sdes	      deplibs="$deplib $deplibs"
7805125647Sdes	    else
7806125647Sdes	      compile_deplibs="$deplib $compile_deplibs"
7807125647Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
7808125647Sdes	    fi
7809125647Sdes	    continue
7810125647Sdes	    ;;
7811125647Sdes	  esac # linkmode
7812125647Sdes	  ;; # *.$libext
7813125647Sdes	*.lo | *.$objext)
7814348980Sdes	  if test conv = "$pass"; then
7815141098Sdes	    deplibs="$deplib $deplibs"
7816348980Sdes	  elif test prog = "$linkmode"; then
7817348980Sdes	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
7818141098Sdes	      # If there is no dlopen support or we're linking statically,
7819141098Sdes	      # we need to preload.
7820228692Sdes	      func_append newdlprefiles " $deplib"
7821141098Sdes	      compile_deplibs="$deplib $compile_deplibs"
7822141098Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
7823141098Sdes	    else
7824228692Sdes	      func_append newdlfiles " $deplib"
7825141098Sdes	    fi
7826125647Sdes	  fi
7827125647Sdes	  continue
7828125647Sdes	  ;;
7829125647Sdes	%DEPLIBS%)
7830348980Sdes	  alldeplibs=:
7831125647Sdes	  continue
7832125647Sdes	  ;;
7833125647Sdes	esac # case $deplib
7834228692Sdes
7835348980Sdes	$found || test -f "$lib" \
7836348980Sdes	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
7837125647Sdes
7838117610Sdes	# Check to see that this really is a libtool archive.
7839228692Sdes	func_lalib_unsafe_p "$lib" \
7840348980Sdes	  || func_fatal_error "'$lib' is not a valid libtool archive"
7841117610Sdes
7842228692Sdes	func_dirname "$lib" "" "."
7843348980Sdes	ladir=$func_dirname_result
7844125647Sdes
7845125647Sdes	dlname=
7846125647Sdes	dlopen=
7847125647Sdes	dlpreopen=
7848125647Sdes	libdir=
7849125647Sdes	library_names=
7850125647Sdes	old_library=
7851228692Sdes	inherited_linker_flags=
7852117610Sdes	# If the library was installed with an old release of libtool,
7853141098Sdes	# it will not redefine variables installed, or shouldnotlink
7854117610Sdes	installed=yes
7855141098Sdes	shouldnotlink=no
7856147455Sdes	avoidtemprpath=
7857117610Sdes
7858147455Sdes
7859117610Sdes	# Read the .la file
7860228692Sdes	func_source "$lib"
7861117610Sdes
7862228692Sdes	# Convert "-framework foo" to "foo.ltframework"
7863228692Sdes	if test -n "$inherited_linker_flags"; then
7864228692Sdes	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
7865228692Sdes	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
7866228692Sdes	    case " $new_inherited_linker_flags " in
7867228692Sdes	      *" $tmp_inherited_linker_flag "*) ;;
7868228692Sdes	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
7869228692Sdes	    esac
7870228692Sdes	  done
7871228692Sdes	fi
7872228692Sdes	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7873348980Sdes	if test lib,link = "$linkmode,$pass" ||
7874348980Sdes	   test prog,scan = "$linkmode,$pass" ||
7875348980Sdes	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7876228692Sdes	  test -n "$dlopen" && func_append dlfiles " $dlopen"
7877228692Sdes	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
7878125647Sdes	fi
7879125647Sdes
7880348980Sdes	if test conv = "$pass"; then
7881125647Sdes	  # Only check for convenience libraries
7882125647Sdes	  deplibs="$lib $deplibs"
7883125647Sdes	  if test -z "$libdir"; then
7884125647Sdes	    if test -z "$old_library"; then
7885348980Sdes	      func_fatal_error "cannot find name of link library for '$lib'"
7886125647Sdes	    fi
7887125647Sdes	    # It is a libtool convenience library, so add in its objects.
7888228692Sdes	    func_append convenience " $ladir/$objdir/$old_library"
7889228692Sdes	    func_append old_convenience " $ladir/$objdir/$old_library"
7890348980Sdes	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
7891348980Sdes	    func_fatal_error "'$lib' is not a convenience library"
7892125647Sdes	  fi
7893228692Sdes	  tmp_libs=
7894228692Sdes	  for deplib in $dependency_libs; do
7895228692Sdes	    deplibs="$deplib $deplibs"
7896348980Sdes	    if $opt_preserve_dup_deps; then
7897228692Sdes	      case "$tmp_libs " in
7898228692Sdes	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7899228692Sdes	      esac
7900228692Sdes	    fi
7901228692Sdes	    func_append tmp_libs " $deplib"
7902228692Sdes	  done
7903125647Sdes	  continue
7904125647Sdes	fi # $pass = conv
7905125647Sdes
7906141098Sdes
7907117610Sdes	# Get the name of the library we link against.
7908117610Sdes	linklib=
7909228692Sdes	if test -n "$old_library" &&
7910348980Sdes	   { test yes = "$prefer_static_libs" ||
7911348980Sdes	     test built,no = "$prefer_static_libs,$installed"; }; then
7912228692Sdes	  linklib=$old_library
7913228692Sdes	else
7914228692Sdes	  for l in $old_library $library_names; do
7915348980Sdes	    linklib=$l
7916228692Sdes	  done
7917228692Sdes	fi
7918117610Sdes	if test -z "$linklib"; then
7919348980Sdes	  func_fatal_error "cannot find name of link library for '$lib'"
7920117610Sdes	fi
7921117610Sdes
7922125647Sdes	# This library was specified with -dlopen.
7923348980Sdes	if test dlopen = "$pass"; then
7924348980Sdes	  test -z "$libdir" \
7925348980Sdes	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
7926141098Sdes	  if test -z "$dlname" ||
7927348980Sdes	     test yes != "$dlopen_support" ||
7928348980Sdes	     test no = "$build_libtool_libs"
7929348980Sdes	  then
7930125647Sdes	    # If there is no dlname, no dlopen support or we're linking
7931141098Sdes	    # statically, we need to preload.  We also need to preload any
7932141098Sdes	    # dependent libraries so libltdl's deplib preloader doesn't
7933141098Sdes	    # bomb out in the load deplibs phase.
7934228692Sdes	    func_append dlprefiles " $lib $dependency_libs"
7935117610Sdes	  else
7936228692Sdes	    func_append newdlfiles " $lib"
7937117610Sdes	  fi
7938125647Sdes	  continue
7939125647Sdes	fi # $pass = dlopen
7940117610Sdes
7941125647Sdes	# We need an absolute path.
7942125647Sdes	case $ladir in
7943348980Sdes	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
7944125647Sdes	*)
7945125647Sdes	  abs_ladir=`cd "$ladir" && pwd`
7946125647Sdes	  if test -z "$abs_ladir"; then
7947348980Sdes	    func_warning "cannot determine absolute directory name of '$ladir'"
7948228692Sdes	    func_warning "passing it literally to the linker, although it might fail"
7949348980Sdes	    abs_ladir=$ladir
7950125647Sdes	  fi
7951125647Sdes	  ;;
7952125647Sdes	esac
7953228692Sdes	func_basename "$lib"
7954348980Sdes	laname=$func_basename_result
7955117610Sdes
7956125647Sdes	# Find the relevant object directory and library name.
7957348980Sdes	if test yes = "$installed"; then
7958228692Sdes	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7959348980Sdes	    func_warning "library '$lib' was moved."
7960348980Sdes	    dir=$ladir
7961348980Sdes	    absdir=$abs_ladir
7962348980Sdes	    libdir=$abs_ladir
7963117610Sdes	  else
7964348980Sdes	    dir=$lt_sysroot$libdir
7965348980Sdes	    absdir=$lt_sysroot$libdir
7966117610Sdes	  fi
7967348980Sdes	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
7968125647Sdes	else
7969141098Sdes	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7970348980Sdes	    dir=$ladir
7971348980Sdes	    absdir=$abs_ladir
7972141098Sdes	    # Remove this search path later
7973228692Sdes	    func_append notinst_path " $abs_ladir"
7974141098Sdes	  else
7975348980Sdes	    dir=$ladir/$objdir
7976348980Sdes	    absdir=$abs_ladir/$objdir
7977141098Sdes	    # Remove this search path later
7978228692Sdes	    func_append notinst_path " $abs_ladir"
7979141098Sdes	  fi
7980125647Sdes	fi # $installed = yes
7981228692Sdes	func_stripname 'lib' '.la' "$laname"
7982228692Sdes	name=$func_stripname_result
7983117610Sdes
7984125647Sdes	# This library was specified with -dlpreopen.
7985348980Sdes	if test dlpreopen = "$pass"; then
7986348980Sdes	  if test -z "$libdir" && test prog = "$linkmode"; then
7987348980Sdes	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
7988125647Sdes	  fi
7989348980Sdes	  case $host in
7990228692Sdes	    # special handling for platforms with PE-DLLs.
7991228692Sdes	    *cygwin* | *mingw* | *cegcc* )
7992228692Sdes	      # Linker will automatically link against shared library if both
7993228692Sdes	      # static and shared are present.  Therefore, ensure we extract
7994228692Sdes	      # symbols from the import library if a shared library is present
7995228692Sdes	      # (otherwise, the dlopen module name will be incorrect).  We do
7996228692Sdes	      # this by putting the import library name into $newdlprefiles.
7997228692Sdes	      # We recover the dlopen module name by 'saving' the la file
7998228692Sdes	      # name in a special purpose variable, and (later) extracting the
7999228692Sdes	      # dlname from the la file.
8000228692Sdes	      if test -n "$dlname"; then
8001228692Sdes	        func_tr_sh "$dir/$linklib"
8002228692Sdes	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8003228692Sdes	        func_append newdlprefiles " $dir/$linklib"
8004228692Sdes	      else
8005228692Sdes	        func_append newdlprefiles " $dir/$old_library"
8006228692Sdes	        # Keep a list of preopened convenience libraries to check
8007228692Sdes	        # that they are being used correctly in the link pass.
8008228692Sdes	        test -z "$libdir" && \
8009228692Sdes	          func_append dlpreconveniencelibs " $dir/$old_library"
8010228692Sdes	      fi
8011228692Sdes	    ;;
8012228692Sdes	    * )
8013228692Sdes	      # Prefer using a static library (so that no silly _DYNAMIC symbols
8014228692Sdes	      # are required to link).
8015228692Sdes	      if test -n "$old_library"; then
8016228692Sdes	        func_append newdlprefiles " $dir/$old_library"
8017228692Sdes	        # Keep a list of preopened convenience libraries to check
8018228692Sdes	        # that they are being used correctly in the link pass.
8019228692Sdes	        test -z "$libdir" && \
8020228692Sdes	          func_append dlpreconveniencelibs " $dir/$old_library"
8021228692Sdes	      # Otherwise, use the dlname, so that lt_dlopen finds it.
8022228692Sdes	      elif test -n "$dlname"; then
8023228692Sdes	        func_append newdlprefiles " $dir/$dlname"
8024228692Sdes	      else
8025228692Sdes	        func_append newdlprefiles " $dir/$linklib"
8026228692Sdes	      fi
8027228692Sdes	    ;;
8028228692Sdes	  esac
8029125647Sdes	fi # $pass = dlpreopen
8030125647Sdes
8031125647Sdes	if test -z "$libdir"; then
8032125647Sdes	  # Link the convenience library
8033348980Sdes	  if test lib = "$linkmode"; then
8034125647Sdes	    deplibs="$dir/$old_library $deplibs"
8035348980Sdes	  elif test prog,link = "$linkmode,$pass"; then
8036125647Sdes	    compile_deplibs="$dir/$old_library $compile_deplibs"
8037125647Sdes	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
8038125647Sdes	  else
8039141098Sdes	    deplibs="$lib $deplibs" # used for prog,scan pass
8040125647Sdes	  fi
8041125647Sdes	  continue
8042117610Sdes	fi
8043117610Sdes
8044141098Sdes
8045348980Sdes	if test prog = "$linkmode" && test link != "$pass"; then
8046228692Sdes	  func_append newlib_search_path " $ladir"
8047125647Sdes	  deplibs="$lib $deplibs"
8048125647Sdes
8049348980Sdes	  linkalldeplibs=false
8050348980Sdes	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
8051348980Sdes	     test no = "$build_libtool_libs"; then
8052348980Sdes	    linkalldeplibs=:
8053125647Sdes	  fi
8054125647Sdes
8055125647Sdes	  tmp_libs=
8056125647Sdes	  for deplib in $dependency_libs; do
8057125647Sdes	    case $deplib in
8058228692Sdes	    -L*) func_stripname '-L' '' "$deplib"
8059228692Sdes	         func_resolve_sysroot "$func_stripname_result"
8060228692Sdes	         func_append newlib_search_path " $func_resolve_sysroot_result"
8061228692Sdes		 ;;
8062125647Sdes	    esac
8063125647Sdes	    # Need to link against all dependency_libs?
8064348980Sdes	    if $linkalldeplibs; then
8065125647Sdes	      deplibs="$deplib $deplibs"
8066125647Sdes	    else
8067125647Sdes	      # Need to hardcode shared library paths
8068125647Sdes	      # or/and link against static libraries
8069125647Sdes	      newdependency_libs="$deplib $newdependency_libs"
8070125647Sdes	    fi
8071348980Sdes	    if $opt_preserve_dup_deps; then
8072125647Sdes	      case "$tmp_libs " in
8073228692Sdes	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
8074125647Sdes	      esac
8075125647Sdes	    fi
8076228692Sdes	    func_append tmp_libs " $deplib"
8077125647Sdes	  done # for deplib
8078125647Sdes	  continue
8079125647Sdes	fi # $linkmode = prog...
8080125647Sdes
8081348980Sdes	if test prog,link = "$linkmode,$pass"; then
8082141098Sdes	  if test -n "$library_names" &&
8083348980Sdes	     { { test no = "$prefer_static_libs" ||
8084348980Sdes	         test built,yes = "$prefer_static_libs,$installed"; } ||
8085174832Sdes	       test -z "$old_library"; }; then
8086141098Sdes	    # We need to hardcode the library path
8087348980Sdes	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
8088141098Sdes	      # Make sure the rpath contains only unique directories.
8089348980Sdes	      case $temp_rpath: in
8090228692Sdes	      *"$absdir:"*) ;;
8091228692Sdes	      *) func_append temp_rpath "$absdir:" ;;
8092141098Sdes	      esac
8093141098Sdes	    fi
8094117610Sdes
8095125647Sdes	    # Hardcode the library path.
8096125647Sdes	    # Skip directories that are in the system default run-time
8097125647Sdes	    # search path.
8098125647Sdes	    case " $sys_lib_dlsearch_path " in
8099117610Sdes	    *" $absdir "*) ;;
8100125647Sdes	    *)
8101125647Sdes	      case "$compile_rpath " in
8102125647Sdes	      *" $absdir "*) ;;
8103228692Sdes	      *) func_append compile_rpath " $absdir" ;;
8104125647Sdes	      esac
8105125647Sdes	      ;;
8106117610Sdes	    esac
8107125647Sdes	    case " $sys_lib_dlsearch_path " in
8108117610Sdes	    *" $libdir "*) ;;
8109125647Sdes	    *)
8110125647Sdes	      case "$finalize_rpath " in
8111125647Sdes	      *" $libdir "*) ;;
8112228692Sdes	      *) func_append finalize_rpath " $libdir" ;;
8113125647Sdes	      esac
8114125647Sdes	      ;;
8115117610Sdes	    esac
8116125647Sdes	  fi # $linkmode,$pass = prog,link...
8117117610Sdes
8118348980Sdes	  if $alldeplibs &&
8119348980Sdes	     { test pass_all = "$deplibs_check_method" ||
8120348980Sdes	       { test yes = "$build_libtool_libs" &&
8121125647Sdes		 test -n "$library_names"; }; }; then
8122125647Sdes	    # We only need to search for static libraries
8123125647Sdes	    continue
8124125647Sdes	  fi
8125141098Sdes	fi
8126125647Sdes
8127141098Sdes	link_static=no # Whether the deplib will be linked statically
8128174832Sdes	use_static_libs=$prefer_static_libs
8129348980Sdes	if test built = "$use_static_libs" && test yes = "$installed"; then
8130174832Sdes	  use_static_libs=no
8131174832Sdes	fi
8132141098Sdes	if test -n "$library_names" &&
8133348980Sdes	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
8134228692Sdes	  case $host in
8135348980Sdes	  *cygwin* | *mingw* | *cegcc* | *os2*)
8136228692Sdes	      # No point in relinking DLLs because paths are not encoded
8137228692Sdes	      func_append notinst_deplibs " $lib"
8138228692Sdes	      need_relink=no
8139228692Sdes	    ;;
8140228692Sdes	  *)
8141348980Sdes	    if test no = "$installed"; then
8142228692Sdes	      func_append notinst_deplibs " $lib"
8143228692Sdes	      need_relink=yes
8144228692Sdes	    fi
8145228692Sdes	    ;;
8146228692Sdes	  esac
8147141098Sdes	  # This is a shared library
8148125647Sdes
8149228692Sdes	  # Warn about portability, can't link against -module's on some
8150228692Sdes	  # systems (darwin).  Don't bleat about dlopened modules though!
8151348980Sdes	  dlopenmodule=
8152228692Sdes	  for dlpremoduletest in $dlprefiles; do
8153228692Sdes	    if test "X$dlpremoduletest" = "X$lib"; then
8154348980Sdes	      dlopenmodule=$dlpremoduletest
8155228692Sdes	      break
8156228692Sdes	    fi
8157228692Sdes	  done
8158348980Sdes	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
8159228692Sdes	    echo
8160348980Sdes	    if test prog = "$linkmode"; then
8161228692Sdes	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
8162141098Sdes	    else
8163228692Sdes	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
8164141098Sdes	    fi
8165228692Sdes	    $ECHO "*** $linklib is not portable!"
8166141098Sdes	  fi
8167348980Sdes	  if test lib = "$linkmode" &&
8168348980Sdes	     test yes = "$hardcode_into_libs"; then
8169141098Sdes	    # Hardcode the library path.
8170141098Sdes	    # Skip directories that are in the system default run-time
8171141098Sdes	    # search path.
8172141098Sdes	    case " $sys_lib_dlsearch_path " in
8173141098Sdes	    *" $absdir "*) ;;
8174141098Sdes	    *)
8175141098Sdes	      case "$compile_rpath " in
8176141098Sdes	      *" $absdir "*) ;;
8177228692Sdes	      *) func_append compile_rpath " $absdir" ;;
8178141098Sdes	      esac
8179141098Sdes	      ;;
8180141098Sdes	    esac
8181141098Sdes	    case " $sys_lib_dlsearch_path " in
8182141098Sdes	    *" $libdir "*) ;;
8183141098Sdes	    *)
8184141098Sdes	      case "$finalize_rpath " in
8185141098Sdes	      *" $libdir "*) ;;
8186228692Sdes	      *) func_append finalize_rpath " $libdir" ;;
8187141098Sdes	      esac
8188141098Sdes	      ;;
8189141098Sdes	    esac
8190141098Sdes	  fi
8191141098Sdes
8192125647Sdes	  if test -n "$old_archive_from_expsyms_cmds"; then
8193125647Sdes	    # figure out the soname
8194125647Sdes	    set dummy $library_names
8195228692Sdes	    shift
8196348980Sdes	    realname=$1
8197228692Sdes	    shift
8198228692Sdes	    libname=`eval "\\$ECHO \"$libname_spec\""`
8199125647Sdes	    # use dlname if we got it. it's perfectly good, no?
8200125647Sdes	    if test -n "$dlname"; then
8201348980Sdes	      soname=$dlname
8202125647Sdes	    elif test -n "$soname_spec"; then
8203125647Sdes	      # bleh windows
8204125647Sdes	      case $host in
8205348980Sdes	      *cygwin* | mingw* | *cegcc* | *os2*)
8206228692Sdes	        func_arith $current - $age
8207228692Sdes		major=$func_arith_result
8208348980Sdes		versuffix=-$major
8209117610Sdes		;;
8210117610Sdes	      esac
8211125647Sdes	      eval soname=\"$soname_spec\"
8212125647Sdes	    else
8213348980Sdes	      soname=$realname
8214125647Sdes	    fi
8215125647Sdes
8216125647Sdes	    # Make a new name for the extract_expsyms_cmds to use
8217348980Sdes	    soroot=$soname
8218228692Sdes	    func_basename "$soroot"
8219348980Sdes	    soname=$func_basename_result
8220228692Sdes	    func_stripname 'lib' '.dll' "$soname"
8221228692Sdes	    newlib=libimp-$func_stripname_result.a
8222125647Sdes
8223125647Sdes	    # If the library has no export list, then create one now
8224125647Sdes	    if test -f "$output_objdir/$soname-def"; then :
8225125647Sdes	    else
8226348980Sdes	      func_verbose "extracting exported symbol list from '$soname'"
8227228692Sdes	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
8228125647Sdes	    fi
8229125647Sdes
8230125647Sdes	    # Create $newlib
8231125647Sdes	    if test -f "$output_objdir/$newlib"; then :; else
8232348980Sdes	      func_verbose "generating import library for '$soname'"
8233228692Sdes	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
8234125647Sdes	    fi
8235125647Sdes	    # make sure the library variables are pointing to the new library
8236125647Sdes	    dir=$output_objdir
8237125647Sdes	    linklib=$newlib
8238141098Sdes	  fi # test -n "$old_archive_from_expsyms_cmds"
8239125647Sdes
8240348980Sdes	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
8241125647Sdes	    add_shlibpath=
8242125647Sdes	    add_dir=
8243125647Sdes	    add=
8244125647Sdes	    lib_linked=yes
8245125647Sdes	    case $hardcode_action in
8246125647Sdes	    immediate | unsupported)
8247348980Sdes	      if test no = "$hardcode_direct"; then
8248348980Sdes		add=$dir/$linklib
8249141098Sdes		case $host in
8250348980Sdes		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
8251348980Sdes		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
8252174832Sdes		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
8253348980Sdes		    *-*-unixware7*) add_dir=-L$dir ;;
8254141098Sdes		  *-*-darwin* )
8255348980Sdes		    # if the lib is a (non-dlopened) module then we cannot
8256228692Sdes		    # link against it, someone is ignoring the earlier warnings
8257174832Sdes		    if /usr/bin/file -L $add 2> /dev/null |
8258348980Sdes			 $GREP ": [^:]* bundle" >/dev/null; then
8259228692Sdes		      if test "X$dlopenmodule" != "X$lib"; then
8260228692Sdes			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
8261348980Sdes			if test -z "$old_library"; then
8262228692Sdes			  echo
8263228692Sdes			  echo "*** And there doesn't seem to be a static archive available"
8264228692Sdes			  echo "*** The link will probably fail, sorry"
8265228692Sdes			else
8266348980Sdes			  add=$dir/$old_library
8267228692Sdes			fi
8268228692Sdes		      elif test -n "$old_library"; then
8269348980Sdes			add=$dir/$old_library
8270141098Sdes		      fi
8271141098Sdes		    fi
8272141098Sdes		esac
8273348980Sdes	      elif test no = "$hardcode_minus_L"; then
8274125647Sdes		case $host in
8275348980Sdes		*-*-sunos*) add_shlibpath=$dir ;;
8276125647Sdes		esac
8277348980Sdes		add_dir=-L$dir
8278348980Sdes		add=-l$name
8279348980Sdes	      elif test no = "$hardcode_shlibpath_var"; then
8280348980Sdes		add_shlibpath=$dir
8281348980Sdes		add=-l$name
8282125647Sdes	      else
8283125647Sdes		lib_linked=no
8284125647Sdes	      fi
8285125647Sdes	      ;;
8286125647Sdes	    relink)
8287348980Sdes	      if test yes = "$hardcode_direct" &&
8288348980Sdes	         test no = "$hardcode_direct_absolute"; then
8289348980Sdes		add=$dir/$linklib
8290348980Sdes	      elif test yes = "$hardcode_minus_L"; then
8291348980Sdes		add_dir=-L$absdir
8292141098Sdes		# Try looking first in the location we're being installed to.
8293141098Sdes		if test -n "$inst_prefix_dir"; then
8294174832Sdes		  case $libdir in
8295141098Sdes		    [\\/]*)
8296228692Sdes		      func_append add_dir " -L$inst_prefix_dir$libdir"
8297141098Sdes		      ;;
8298141098Sdes		  esac
8299141098Sdes		fi
8300348980Sdes		add=-l$name
8301348980Sdes	      elif test yes = "$hardcode_shlibpath_var"; then
8302348980Sdes		add_shlibpath=$dir
8303348980Sdes		add=-l$name
8304125647Sdes	      else
8305125647Sdes		lib_linked=no
8306125647Sdes	      fi
8307125647Sdes	      ;;
8308125647Sdes	    *) lib_linked=no ;;
8309125647Sdes	    esac
8310125647Sdes
8311348980Sdes	    if test yes != "$lib_linked"; then
8312228692Sdes	      func_fatal_configuration "unsupported hardcode properties"
8313125647Sdes	    fi
8314125647Sdes
8315125647Sdes	    if test -n "$add_shlibpath"; then
8316125647Sdes	      case :$compile_shlibpath: in
8317125647Sdes	      *":$add_shlibpath:"*) ;;
8318228692Sdes	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
8319117610Sdes	      esac
8320125647Sdes	    fi
8321348980Sdes	    if test prog = "$linkmode"; then
8322125647Sdes	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
8323125647Sdes	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
8324117610Sdes	    else
8325125647Sdes	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8326125647Sdes	      test -n "$add" && deplibs="$add $deplibs"
8327348980Sdes	      if test yes != "$hardcode_direct" &&
8328348980Sdes		 test yes != "$hardcode_minus_L" &&
8329348980Sdes		 test yes = "$hardcode_shlibpath_var"; then
8330125647Sdes		case :$finalize_shlibpath: in
8331125647Sdes		*":$libdir:"*) ;;
8332228692Sdes		*) func_append finalize_shlibpath "$libdir:" ;;
8333125647Sdes		esac
8334125647Sdes	      fi
8335117610Sdes	    fi
8336125647Sdes	  fi
8337117610Sdes
8338348980Sdes	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
8339125647Sdes	    add_shlibpath=
8340125647Sdes	    add_dir=
8341125647Sdes	    add=
8342125647Sdes	    # Finalize command for both is simple: just hardcode it.
8343348980Sdes	    if test yes = "$hardcode_direct" &&
8344348980Sdes	       test no = "$hardcode_direct_absolute"; then
8345348980Sdes	      add=$libdir/$linklib
8346348980Sdes	    elif test yes = "$hardcode_minus_L"; then
8347348980Sdes	      add_dir=-L$libdir
8348348980Sdes	      add=-l$name
8349348980Sdes	    elif test yes = "$hardcode_shlibpath_var"; then
8350125647Sdes	      case :$finalize_shlibpath: in
8351125647Sdes	      *":$libdir:"*) ;;
8352228692Sdes	      *) func_append finalize_shlibpath "$libdir:" ;;
8353117610Sdes	      esac
8354348980Sdes	      add=-l$name
8355348980Sdes	    elif test yes = "$hardcode_automatic"; then
8356141098Sdes	      if test -n "$inst_prefix_dir" &&
8357348980Sdes		 test -f "$inst_prefix_dir$libdir/$linklib"; then
8358348980Sdes		add=$inst_prefix_dir$libdir/$linklib
8359141098Sdes	      else
8360348980Sdes		add=$libdir/$linklib
8361141098Sdes	      fi
8362117610Sdes	    else
8363125647Sdes	      # We cannot seem to hardcode it, guess we'll fake it.
8364348980Sdes	      add_dir=-L$libdir
8365141098Sdes	      # Try looking first in the location we're being installed to.
8366141098Sdes	      if test -n "$inst_prefix_dir"; then
8367174832Sdes		case $libdir in
8368141098Sdes		  [\\/]*)
8369228692Sdes		    func_append add_dir " -L$inst_prefix_dir$libdir"
8370141098Sdes		    ;;
8371141098Sdes		esac
8372141098Sdes	      fi
8373348980Sdes	      add=-l$name
8374117610Sdes	    fi
8375117610Sdes
8376348980Sdes	    if test prog = "$linkmode"; then
8377125647Sdes	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
8378125647Sdes	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
8379125647Sdes	    else
8380125647Sdes	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
8381125647Sdes	      test -n "$add" && deplibs="$add $deplibs"
8382125647Sdes	    fi
8383117610Sdes	  fi
8384348980Sdes	elif test prog = "$linkmode"; then
8385117610Sdes	  # Here we assume that one of hardcode_direct or hardcode_minus_L
8386117610Sdes	  # is not unsupported.  This is valid on all known static and
8387117610Sdes	  # shared platforms.
8388348980Sdes	  if test unsupported != "$hardcode_direct"; then
8389348980Sdes	    test -n "$old_library" && linklib=$old_library
8390125647Sdes	    compile_deplibs="$dir/$linklib $compile_deplibs"
8391125647Sdes	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
8392117610Sdes	  else
8393125647Sdes	    compile_deplibs="-l$name -L$dir $compile_deplibs"
8394125647Sdes	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
8395117610Sdes	  fi
8396348980Sdes	elif test yes = "$build_libtool_libs"; then
8397125647Sdes	  # Not a shared library
8398348980Sdes	  if test pass_all != "$deplibs_check_method"; then
8399125647Sdes	    # We're trying link a shared library against a static one
8400125647Sdes	    # but the system doesn't support it.
8401117610Sdes
8402125647Sdes	    # Just print a warning and add the library to dependency_libs so
8403125647Sdes	    # that the program can be linked against the static library.
8404228692Sdes	    echo
8405348980Sdes	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8406228692Sdes	    echo "*** I have the capability to make that library automatically link in when"
8407228692Sdes	    echo "*** you link to this library.  But I can only do this if you have a"
8408228692Sdes	    echo "*** shared version of the library, which you do not appear to have."
8409348980Sdes	    if test yes = "$module"; then
8410228692Sdes	      echo "*** But as you try to build a module library, libtool will still create "
8411228692Sdes	      echo "*** a static module, that should work as long as the dlopening application"
8412228692Sdes	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
8413125647Sdes	      if test -z "$global_symbol_pipe"; then
8414228692Sdes		echo
8415228692Sdes		echo "*** However, this would only work if libtool was able to extract symbol"
8416348980Sdes		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8417228692Sdes		echo "*** not find such a program.  So, this module is probably useless."
8418348980Sdes		echo "*** 'nm' from GNU binutils and a full rebuild may help."
8419125647Sdes	      fi
8420348980Sdes	      if test no = "$build_old_libs"; then
8421125647Sdes		build_libtool_libs=module
8422125647Sdes		build_old_libs=yes
8423125647Sdes	      else
8424125647Sdes		build_libtool_libs=no
8425125647Sdes	      fi
8426125647Sdes	    fi
8427125647Sdes	  else
8428125647Sdes	    deplibs="$dir/$old_library $deplibs"
8429125647Sdes	    link_static=yes
8430125647Sdes	  fi
8431125647Sdes	fi # link shared/static library?
8432117610Sdes
8433348980Sdes	if test lib = "$linkmode"; then
8434125647Sdes	  if test -n "$dependency_libs" &&
8435348980Sdes	     { test yes != "$hardcode_into_libs" ||
8436348980Sdes	       test yes = "$build_old_libs" ||
8437348980Sdes	       test yes = "$link_static"; }; then
8438125647Sdes	    # Extract -R from dependency_libs
8439125647Sdes	    temp_deplibs=
8440125647Sdes	    for libdir in $dependency_libs; do
8441125647Sdes	      case $libdir in
8442228692Sdes	      -R*) func_stripname '-R' '' "$libdir"
8443228692Sdes	           temp_xrpath=$func_stripname_result
8444125647Sdes		   case " $xrpath " in
8445125647Sdes		   *" $temp_xrpath "*) ;;
8446228692Sdes		   *) func_append xrpath " $temp_xrpath";;
8447125647Sdes		   esac;;
8448228692Sdes	      *) func_append temp_deplibs " $libdir";;
8449125647Sdes	      esac
8450125647Sdes	    done
8451348980Sdes	    dependency_libs=$temp_deplibs
8452125647Sdes	  fi
8453117610Sdes
8454228692Sdes	  func_append newlib_search_path " $absdir"
8455125647Sdes	  # Link against this library
8456348980Sdes	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
8457125647Sdes	  # ... and its dependency_libs
8458125647Sdes	  tmp_libs=
8459125647Sdes	  for deplib in $dependency_libs; do
8460125647Sdes	    newdependency_libs="$deplib $newdependency_libs"
8461228692Sdes	    case $deplib in
8462228692Sdes              -L*) func_stripname '-L' '' "$deplib"
8463228692Sdes                   func_resolve_sysroot "$func_stripname_result";;
8464228692Sdes              *) func_resolve_sysroot "$deplib" ;;
8465228692Sdes            esac
8466348980Sdes	    if $opt_preserve_dup_deps; then
8467125647Sdes	      case "$tmp_libs " in
8468228692Sdes	      *" $func_resolve_sysroot_result "*)
8469228692Sdes                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
8470125647Sdes	      esac
8471125647Sdes	    fi
8472228692Sdes	    func_append tmp_libs " $func_resolve_sysroot_result"
8473125647Sdes	  done
8474117610Sdes
8475348980Sdes	  if test no != "$link_all_deplibs"; then
8476125647Sdes	    # Add the search paths of all dependency libraries
8477125647Sdes	    for deplib in $dependency_libs; do
8478228692Sdes	      path=
8479125647Sdes	      case $deplib in
8480348980Sdes	      -L*) path=$deplib ;;
8481125647Sdes	      *.la)
8482228692Sdes	        func_resolve_sysroot "$deplib"
8483228692Sdes	        deplib=$func_resolve_sysroot_result
8484228692Sdes	        func_dirname "$deplib" "" "."
8485228692Sdes		dir=$func_dirname_result
8486125647Sdes		# We need an absolute path.
8487125647Sdes		case $dir in
8488348980Sdes		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
8489125647Sdes		*)
8490125647Sdes		  absdir=`cd "$dir" && pwd`
8491125647Sdes		  if test -z "$absdir"; then
8492348980Sdes		    func_warning "cannot determine absolute directory name of '$dir'"
8493348980Sdes		    absdir=$dir
8494125647Sdes		  fi
8495125647Sdes		  ;;
8496125647Sdes		esac
8497228692Sdes		if $GREP "^installed=no" $deplib > /dev/null; then
8498141098Sdes		case $host in
8499141098Sdes		*-*-darwin*)
8500228692Sdes		  depdepl=
8501348980Sdes		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
8502348980Sdes		  if test -n "$deplibrary_names"; then
8503348980Sdes		    for tmp in $deplibrary_names; do
8504141098Sdes		      depdepl=$tmp
8505141098Sdes		    done
8506348980Sdes		    if test -f "$absdir/$objdir/$depdepl"; then
8507348980Sdes		      depdepl=$absdir/$objdir/$depdepl
8508348980Sdes		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8509228692Sdes                      if test -z "$darwin_install_name"; then
8510348980Sdes                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
8511228692Sdes                      fi
8512348980Sdes		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
8513348980Sdes		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
8514228692Sdes		      path=
8515141098Sdes		    fi
8516141098Sdes		  fi
8517141098Sdes		  ;;
8518141098Sdes		*)
8519348980Sdes		  path=-L$absdir/$objdir
8520141098Sdes		  ;;
8521141098Sdes		esac
8522228692Sdes		else
8523348980Sdes		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8524228692Sdes		  test -z "$libdir" && \
8525348980Sdes		    func_fatal_error "'$deplib' is not a valid libtool archive"
8526228692Sdes		  test "$absdir" != "$libdir" && \
8527348980Sdes		    func_warning "'$deplib' seems to be moved"
8528228692Sdes
8529348980Sdes		  path=-L$absdir
8530228692Sdes		fi
8531125647Sdes		;;
8532125647Sdes	      esac
8533125647Sdes	      case " $deplibs " in
8534174832Sdes	      *" $path "*) ;;
8535174832Sdes	      *) deplibs="$path $deplibs" ;;
8536174832Sdes	      esac
8537125647Sdes	    done
8538125647Sdes	  fi # link_all_deplibs != no
8539125647Sdes	fi # linkmode = lib
8540125647Sdes      done # for deplib in $libs
8541348980Sdes      if test link = "$pass"; then
8542348980Sdes	if test prog = "$linkmode"; then
8543228692Sdes	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
8544228692Sdes	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
8545228692Sdes	else
8546228692Sdes	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8547228692Sdes	fi
8548228692Sdes      fi
8549348980Sdes      dependency_libs=$newdependency_libs
8550348980Sdes      if test dlpreopen = "$pass"; then
8551125647Sdes	# Link the dlpreopened libraries before other libraries
8552125647Sdes	for deplib in $save_deplibs; do
8553125647Sdes	  deplibs="$deplib $deplibs"
8554125647Sdes	done
8555117610Sdes      fi
8556348980Sdes      if test dlopen != "$pass"; then
8557348980Sdes	test conv = "$pass" || {
8558125647Sdes	  # Make sure lib_search_path contains only unique directories.
8559125647Sdes	  lib_search_path=
8560125647Sdes	  for dir in $newlib_search_path; do
8561125647Sdes	    case "$lib_search_path " in
8562125647Sdes	    *" $dir "*) ;;
8563228692Sdes	    *) func_append lib_search_path " $dir" ;;
8564125647Sdes	    esac
8565125647Sdes	  done
8566125647Sdes	  newlib_search_path=
8567348980Sdes	}
8568117610Sdes
8569348980Sdes	if test prog,link = "$linkmode,$pass"; then
8570348980Sdes	  vars="compile_deplibs finalize_deplibs"
8571125647Sdes	else
8572348980Sdes	  vars=deplibs
8573125647Sdes	fi
8574125647Sdes	for var in $vars dependency_libs; do
8575125647Sdes	  # Add libraries to $var in reverse order
8576125647Sdes	  eval tmp_libs=\"\$$var\"
8577125647Sdes	  new_libs=
8578125647Sdes	  for deplib in $tmp_libs; do
8579141098Sdes	    # FIXME: Pedantically, this is the right thing to do, so
8580141098Sdes	    #        that some nasty dependency loop isn't accidentally
8581141098Sdes	    #        broken:
8582141098Sdes	    #new_libs="$deplib $new_libs"
8583141098Sdes	    # Pragmatically, this seems to cause very few problems in
8584141098Sdes	    # practice:
8585125647Sdes	    case $deplib in
8586125647Sdes	    -L*) new_libs="$deplib $new_libs" ;;
8587141098Sdes	    -R*) ;;
8588125647Sdes	    *)
8589141098Sdes	      # And here is the reason: when a library appears more
8590141098Sdes	      # than once as an explicit dependence of a library, or
8591141098Sdes	      # is implicitly linked in more than once by the
8592141098Sdes	      # compiler, it is considered special, and multiple
8593141098Sdes	      # occurrences thereof are not removed.  Compare this
8594141098Sdes	      # with having the same library being listed as a
8595141098Sdes	      # dependency of multiple other libraries: in this case,
8596141098Sdes	      # we know (pedantically, we assume) the library does not
8597141098Sdes	      # need to be listed more than once, so we keep only the
8598141098Sdes	      # last copy.  This is not always right, but it is rare
8599141098Sdes	      # enough that we require users that really mean to play
8600141098Sdes	      # such unportable linking tricks to link the library
8601141098Sdes	      # using -Wl,-lname, so that libtool does not consider it
8602141098Sdes	      # for duplicate removal.
8603125647Sdes	      case " $specialdeplibs " in
8604125647Sdes	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
8605125647Sdes	      *)
8606125647Sdes		case " $new_libs " in
8607125647Sdes		*" $deplib "*) ;;
8608125647Sdes		*) new_libs="$deplib $new_libs" ;;
8609125647Sdes		esac
8610125647Sdes		;;
8611125647Sdes	      esac
8612125647Sdes	      ;;
8613125647Sdes	    esac
8614125647Sdes	  done
8615125647Sdes	  tmp_libs=
8616125647Sdes	  for deplib in $new_libs; do
8617125647Sdes	    case $deplib in
8618125647Sdes	    -L*)
8619125647Sdes	      case " $tmp_libs " in
8620125647Sdes	      *" $deplib "*) ;;
8621228692Sdes	      *) func_append tmp_libs " $deplib" ;;
8622125647Sdes	      esac
8623125647Sdes	      ;;
8624228692Sdes	    *) func_append tmp_libs " $deplib" ;;
8625125647Sdes	    esac
8626125647Sdes	  done
8627125647Sdes	  eval $var=\"$tmp_libs\"
8628125647Sdes	done # for var
8629117610Sdes      fi
8630348980Sdes
8631348980Sdes      # Add Sun CC postdeps if required:
8632348980Sdes      test CXX = "$tagname" && {
8633348980Sdes        case $host_os in
8634348980Sdes        linux*)
8635348980Sdes          case `$CC -V 2>&1 | sed 5q` in
8636348980Sdes          *Sun\ C*) # Sun C++ 5.9
8637348980Sdes            func_suncc_cstd_abi
8638348980Sdes
8639348980Sdes            if test no != "$suncc_use_cstd_abi"; then
8640348980Sdes              func_append postdeps ' -library=Cstd -library=Crun'
8641348980Sdes            fi
8642348980Sdes            ;;
8643348980Sdes          esac
8644348980Sdes          ;;
8645348980Sdes
8646348980Sdes        solaris*)
8647348980Sdes          func_cc_basename "$CC"
8648348980Sdes          case $func_cc_basename_result in
8649348980Sdes          CC* | sunCC*)
8650348980Sdes            func_suncc_cstd_abi
8651348980Sdes
8652348980Sdes            if test no != "$suncc_use_cstd_abi"; then
8653348980Sdes              func_append postdeps ' -library=Cstd -library=Crun'
8654348980Sdes            fi
8655348980Sdes            ;;
8656348980Sdes          esac
8657348980Sdes          ;;
8658348980Sdes        esac
8659348980Sdes      }
8660348980Sdes
8661141098Sdes      # Last step: remove runtime libs from dependency_libs
8662141098Sdes      # (they stay in deplibs)
8663141098Sdes      tmp_libs=
8664348980Sdes      for i in $dependency_libs; do
8665141098Sdes	case " $predeps $postdeps $compiler_lib_search_path " in
8666141098Sdes	*" $i "*)
8667348980Sdes	  i=
8668141098Sdes	  ;;
8669141098Sdes	esac
8670348980Sdes	if test -n "$i"; then
8671228692Sdes	  func_append tmp_libs " $i"
8672141098Sdes	fi
8673141098Sdes      done
8674141098Sdes      dependency_libs=$tmp_libs
8675125647Sdes    done # for pass
8676348980Sdes    if test prog = "$linkmode"; then
8677348980Sdes      dlfiles=$newdlfiles
8678228692Sdes    fi
8679348980Sdes    if test prog = "$linkmode" || test lib = "$linkmode"; then
8680348980Sdes      dlprefiles=$newdlprefiles
8681125647Sdes    fi
8682117610Sdes
8683125647Sdes    case $linkmode in
8684125647Sdes    oldlib)
8685348980Sdes      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
8686348980Sdes	func_warning "'-dlopen' is ignored for archives"
8687117610Sdes      fi
8688117610Sdes
8689228692Sdes      case " $deplibs" in
8690228692Sdes      *\ -l* | *\ -L*)
8691348980Sdes	func_warning "'-l' and '-L' are ignored for archives" ;;
8692228692Sdes      esac
8693117610Sdes
8694228692Sdes      test -n "$rpath" && \
8695348980Sdes	func_warning "'-rpath' is ignored for archives"
8696117610Sdes
8697228692Sdes      test -n "$xrpath" && \
8698348980Sdes	func_warning "'-R' is ignored for archives"
8699117610Sdes
8700228692Sdes      test -n "$vinfo" && \
8701348980Sdes	func_warning "'-version-info/-version-number' is ignored for archives"
8702117610Sdes
8703228692Sdes      test -n "$release" && \
8704348980Sdes	func_warning "'-release' is ignored for archives"
8705117610Sdes
8706228692Sdes      test -n "$export_symbols$export_symbols_regex" && \
8707348980Sdes	func_warning "'-export-symbols' is ignored for archives"
8708228692Sdes
8709117610Sdes      # Now set the variables for building old libraries.
8710117610Sdes      build_libtool_libs=no
8711348980Sdes      oldlibs=$output
8712228692Sdes      func_append objs "$old_deplibs"
8713117610Sdes      ;;
8714117610Sdes
8715125647Sdes    lib)
8716348980Sdes      # Make sure we only generate libraries of the form 'libNAME.la'.
8717125647Sdes      case $outputname in
8718117610Sdes      lib*)
8719228692Sdes	func_stripname 'lib' '.la' "$outputname"
8720228692Sdes	name=$func_stripname_result
8721141098Sdes	eval shared_ext=\"$shrext_cmds\"
8722117610Sdes	eval libname=\"$libname_spec\"
8723117610Sdes	;;
8724117610Sdes      *)
8725348980Sdes	test no = "$module" \
8726348980Sdes	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
8727228692Sdes
8728348980Sdes	if test no != "$need_lib_prefix"; then
8729117610Sdes	  # Add the "lib" prefix for modules if required
8730228692Sdes	  func_stripname '' '.la' "$outputname"
8731228692Sdes	  name=$func_stripname_result
8732141098Sdes	  eval shared_ext=\"$shrext_cmds\"
8733117610Sdes	  eval libname=\"$libname_spec\"
8734117610Sdes	else
8735228692Sdes	  func_stripname '' '.la' "$outputname"
8736228692Sdes	  libname=$func_stripname_result
8737117610Sdes	fi
8738117610Sdes	;;
8739117610Sdes      esac
8740117610Sdes
8741117610Sdes      if test -n "$objs"; then
8742348980Sdes	if test pass_all != "$deplibs_check_method"; then
8743348980Sdes	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
8744125647Sdes	else
8745228692Sdes	  echo
8746228692Sdes	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
8747228692Sdes	  $ECHO "*** objects $objs is not portable!"
8748228692Sdes	  func_append libobjs " $objs"
8749125647Sdes	fi
8750117610Sdes      fi
8751117610Sdes
8752348980Sdes      test no = "$dlself" \
8753348980Sdes	|| func_warning "'-dlopen self' is ignored for libtool libraries"
8754117610Sdes
8755117610Sdes      set dummy $rpath
8756228692Sdes      shift
8757348980Sdes      test 1 -lt "$#" \
8758348980Sdes	&& func_warning "ignoring multiple '-rpath's for a libtool library"
8759117610Sdes
8760348980Sdes      install_libdir=$1
8761228692Sdes
8762117610Sdes      oldlibs=
8763117610Sdes      if test -z "$rpath"; then
8764348980Sdes	if test yes = "$build_libtool_libs"; then
8765117610Sdes	  # Building a libtool convenience library.
8766348980Sdes	  # Some compilers have problems with a '.al' extension so
8767141098Sdes	  # convenience libraries should have the same extension an
8768141098Sdes	  # archive normally would.
8769117610Sdes	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
8770117610Sdes	  build_libtool_libs=convenience
8771117610Sdes	  build_old_libs=yes
8772117610Sdes	fi
8773117610Sdes
8774228692Sdes	test -n "$vinfo" && \
8775348980Sdes	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
8776117610Sdes
8777228692Sdes	test -n "$release" && \
8778348980Sdes	  func_warning "'-release' is ignored for convenience libraries"
8779117610Sdes      else
8780117610Sdes
8781117610Sdes	# Parse the version information argument.
8782348980Sdes	save_ifs=$IFS; IFS=:
8783117610Sdes	set dummy $vinfo 0 0 0
8784228692Sdes	shift
8785348980Sdes	IFS=$save_ifs
8786117610Sdes
8787228692Sdes	test -n "$7" && \
8788348980Sdes	  func_fatal_help "too many parameters to '-version-info'"
8789117610Sdes
8790141098Sdes	# convert absolute version numbers to libtool ages
8791141098Sdes	# this retains compatibility with .la files and attempts
8792141098Sdes	# to make the code below a bit more comprehensible
8793117610Sdes
8794141098Sdes	case $vinfo_number in
8795141098Sdes	yes)
8796348980Sdes	  number_major=$1
8797348980Sdes	  number_minor=$2
8798348980Sdes	  number_revision=$3
8799141098Sdes	  #
8800141098Sdes	  # There are really only two kinds -- those that
8801141098Sdes	  # use the current revision as the major version
8802141098Sdes	  # and those that subtract age and use age as
8803141098Sdes	  # a minor version.  But, then there is irix
8804348980Sdes	  # that has an extra 1 added just for fun
8805141098Sdes	  #
8806141098Sdes	  case $version_type in
8807236109Sdes	  # correct linux to gnu/linux during the next big refactor
8808348980Sdes	  darwin|freebsd-elf|linux|osf|windows|none)
8809228692Sdes	    func_arith $number_major + $number_minor
8810228692Sdes	    current=$func_arith_result
8811348980Sdes	    age=$number_minor
8812348980Sdes	    revision=$number_revision
8813141098Sdes	    ;;
8814348980Sdes	  freebsd-aout|qnx|sunos)
8815348980Sdes	    current=$number_major
8816348980Sdes	    revision=$number_minor
8817348980Sdes	    age=0
8818141098Sdes	    ;;
8819141098Sdes	  irix|nonstopux)
8820228692Sdes	    func_arith $number_major + $number_minor
8821228692Sdes	    current=$func_arith_result
8822348980Sdes	    age=$number_minor
8823348980Sdes	    revision=$number_minor
8824174832Sdes	    lt_irix_increment=no
8825141098Sdes	    ;;
8826141098Sdes	  esac
8827141098Sdes	  ;;
8828141098Sdes	no)
8829348980Sdes	  current=$1
8830348980Sdes	  revision=$2
8831348980Sdes	  age=$3
8832141098Sdes	  ;;
8833141098Sdes	esac
8834141098Sdes
8835117610Sdes	# Check that each of the things are valid numbers.
8836125647Sdes	case $current in
8837147455Sdes	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]) ;;
8838117610Sdes	*)
8839348980Sdes	  func_error "CURRENT '$current' must be a nonnegative integer"
8840348980Sdes	  func_fatal_error "'$vinfo' is not valid version information"
8841117610Sdes	  ;;
8842117610Sdes	esac
8843117610Sdes
8844125647Sdes	case $revision in
8845147455Sdes	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]) ;;
8846117610Sdes	*)
8847348980Sdes	  func_error "REVISION '$revision' must be a nonnegative integer"
8848348980Sdes	  func_fatal_error "'$vinfo' is not valid version information"
8849117610Sdes	  ;;
8850117610Sdes	esac
8851117610Sdes
8852125647Sdes	case $age in
8853147455Sdes	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]) ;;
8854117610Sdes	*)
8855348980Sdes	  func_error "AGE '$age' must be a nonnegative integer"
8856348980Sdes	  func_fatal_error "'$vinfo' is not valid version information"
8857117610Sdes	  ;;
8858117610Sdes	esac
8859117610Sdes
8860141098Sdes	if test "$age" -gt "$current"; then
8861348980Sdes	  func_error "AGE '$age' is greater than the current interface number '$current'"
8862348980Sdes	  func_fatal_error "'$vinfo' is not valid version information"
8863117610Sdes	fi
8864117610Sdes
8865117610Sdes	# Calculate the version variables.
8866117610Sdes	major=
8867117610Sdes	versuffix=
8868117610Sdes	verstring=
8869125647Sdes	case $version_type in
8870117610Sdes	none) ;;
8871117610Sdes
8872125647Sdes	darwin)
8873125647Sdes	  # Like Linux, but with the current version available in
8874125647Sdes	  # verstring for coding it into the library header
8875228692Sdes	  func_arith $current - $age
8876228692Sdes	  major=.$func_arith_result
8877348980Sdes	  versuffix=$major.$age.$revision
8878125647Sdes	  # Darwin ld doesn't like 0 for these options...
8879228692Sdes	  func_arith $current + 1
8880228692Sdes	  minor_current=$func_arith_result
8881348980Sdes	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8882174832Sdes	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8883348980Sdes          # On Darwin other compilers
8884348980Sdes          case $CC in
8885348980Sdes              nagfor*)
8886348980Sdes                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8887348980Sdes                  ;;
8888348980Sdes              *)
8889348980Sdes                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8890348980Sdes                  ;;
8891348980Sdes          esac
8892125647Sdes	  ;;
8893125647Sdes
8894125647Sdes	freebsd-aout)
8895348980Sdes	  major=.$current
8896348980Sdes	  versuffix=.$current.$revision
8897125647Sdes	  ;;
8898125647Sdes
8899125647Sdes	freebsd-elf)
8900348980Sdes	  func_arith $current - $age
8901348980Sdes	  major=.$func_arith_result
8902348980Sdes	  versuffix=$major.$age.$revision
8903125647Sdes	  ;;
8904125647Sdes
8905125647Sdes	irix | nonstopux)
8906348980Sdes	  if test no = "$lt_irix_increment"; then
8907228692Sdes	    func_arith $current - $age
8908174832Sdes	  else
8909228692Sdes	    func_arith $current - $age + 1
8910174832Sdes	  fi
8911228692Sdes	  major=$func_arith_result
8912228692Sdes
8913125647Sdes	  case $version_type in
8914125647Sdes	    nonstopux) verstring_prefix=nonstopux ;;
8915125647Sdes	    *)         verstring_prefix=sgi ;;
8916125647Sdes	  esac
8917348980Sdes	  verstring=$verstring_prefix$major.$revision
8918125647Sdes
8919117610Sdes	  # Add in all the interfaces that we are compatible with.
8920117610Sdes	  loop=$revision
8921348980Sdes	  while test 0 -ne "$loop"; do
8922228692Sdes	    func_arith $revision - $loop
8923228692Sdes	    iface=$func_arith_result
8924228692Sdes	    func_arith $loop - 1
8925228692Sdes	    loop=$func_arith_result
8926348980Sdes	    verstring=$verstring_prefix$major.$iface:$verstring
8927117610Sdes	  done
8928125647Sdes
8929348980Sdes	  # Before this point, $major must not contain '.'.
8930125647Sdes	  major=.$major
8931348980Sdes	  versuffix=$major.$revision
8932117610Sdes	  ;;
8933117610Sdes
8934236109Sdes	linux) # correct to gnu/linux during the next big refactor
8935228692Sdes	  func_arith $current - $age
8936228692Sdes	  major=.$func_arith_result
8937348980Sdes	  versuffix=$major.$age.$revision
8938117610Sdes	  ;;
8939117610Sdes
8940117610Sdes	osf)
8941228692Sdes	  func_arith $current - $age
8942228692Sdes	  major=.$func_arith_result
8943348980Sdes	  versuffix=.$current.$age.$revision
8944348980Sdes	  verstring=$current.$age.$revision
8945117610Sdes
8946117610Sdes	  # Add in all the interfaces that we are compatible with.
8947117610Sdes	  loop=$age
8948348980Sdes	  while test 0 -ne "$loop"; do
8949228692Sdes	    func_arith $current - $loop
8950228692Sdes	    iface=$func_arith_result
8951228692Sdes	    func_arith $loop - 1
8952228692Sdes	    loop=$func_arith_result
8953348980Sdes	    verstring=$verstring:$iface.0
8954117610Sdes	  done
8955117610Sdes
8956117610Sdes	  # Make executables depend on our current version.
8957348980Sdes	  func_append verstring ":$current.0"
8958117610Sdes	  ;;
8959117610Sdes
8960228692Sdes	qnx)
8961348980Sdes	  major=.$current
8962348980Sdes	  versuffix=.$current
8963228692Sdes	  ;;
8964228692Sdes
8965348980Sdes	sco)
8966348980Sdes	  major=.$current
8967348980Sdes	  versuffix=.$current
8968348980Sdes	  ;;
8969348980Sdes
8970117610Sdes	sunos)
8971348980Sdes	  major=.$current
8972348980Sdes	  versuffix=.$current.$revision
8973117610Sdes	  ;;
8974117610Sdes
8975117610Sdes	windows)
8976125647Sdes	  # Use '-' rather than '.', since we only want one
8977348980Sdes	  # extension on DOS 8.3 file systems.
8978228692Sdes	  func_arith $current - $age
8979228692Sdes	  major=$func_arith_result
8980348980Sdes	  versuffix=-$major
8981117610Sdes	  ;;
8982117610Sdes
8983117610Sdes	*)
8984348980Sdes	  func_fatal_configuration "unknown library version type '$version_type'"
8985117610Sdes	  ;;
8986117610Sdes	esac
8987117610Sdes
8988117610Sdes	# Clear the version info if we defaulted, and they specified a release.
8989117610Sdes	if test -z "$vinfo" && test -n "$release"; then
8990117610Sdes	  major=
8991125647Sdes	  case $version_type in
8992125647Sdes	  darwin)
8993125647Sdes	    # we can't check for "0.0" in archive_cmds due to quoting
8994125647Sdes	    # problems, so we reset it completely
8995141098Sdes	    verstring=
8996125647Sdes	    ;;
8997125647Sdes	  *)
8998348980Sdes	    verstring=0.0
8999125647Sdes	    ;;
9000125647Sdes	  esac
9001348980Sdes	  if test no = "$need_version"; then
9002117610Sdes	    versuffix=
9003117610Sdes	  else
9004348980Sdes	    versuffix=.0.0
9005117610Sdes	  fi
9006117610Sdes	fi
9007117610Sdes
9008117610Sdes	# Remove version info from name if versioning should be avoided
9009348980Sdes	if test yes,no = "$avoid_version,$need_version"; then
9010117610Sdes	  major=
9011117610Sdes	  versuffix=
9012348980Sdes	  verstring=
9013117610Sdes	fi
9014125647Sdes
9015117610Sdes	# Check to see if the archive will have undefined symbols.
9016348980Sdes	if test yes = "$allow_undefined"; then
9017348980Sdes	  if test unsupported = "$allow_undefined_flag"; then
9018348980Sdes	    if test yes = "$build_old_libs"; then
9019348980Sdes	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
9020348980Sdes	      build_libtool_libs=no
9021348980Sdes	    else
9022348980Sdes	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
9023348980Sdes	    fi
9024117610Sdes	  fi
9025117610Sdes	else
9026117610Sdes	  # Don't allow undefined symbols.
9027348980Sdes	  allow_undefined_flag=$no_undefined_flag
9028117610Sdes	fi
9029228692Sdes
9030125647Sdes      fi
9031117610Sdes
9032348980Sdes      func_generate_dlsyms "$libname" "$libname" :
9033228692Sdes      func_append libobjs " $symfileobj"
9034348980Sdes      test " " = "$libobjs" && libobjs=
9035228692Sdes
9036348980Sdes      if test relink != "$opt_mode"; then
9037141098Sdes	# Remove our outputs, but don't remove object files since they
9038141098Sdes	# may have been created when compiling PIC objects.
9039141098Sdes	removelist=
9040228692Sdes	tempremovelist=`$ECHO "$output_objdir/*"`
9041141098Sdes	for p in $tempremovelist; do
9042141098Sdes	  case $p in
9043228692Sdes	    *.$objext | *.gcno)
9044141098Sdes	       ;;
9045348980Sdes	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
9046348980Sdes	       if test -n "$precious_files_regex"; then
9047228692Sdes		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
9048228692Sdes		 then
9049141098Sdes		   continue
9050141098Sdes		 fi
9051141098Sdes	       fi
9052228692Sdes	       func_append removelist " $p"
9053141098Sdes	       ;;
9054141098Sdes	    *) ;;
9055141098Sdes	  esac
9056141098Sdes	done
9057228692Sdes	test -n "$removelist" && \
9058228692Sdes	  func_show_eval "${RM}r \$removelist"
9059117610Sdes      fi
9060117610Sdes
9061125647Sdes      # Now set the variables for building old libraries.
9062348980Sdes      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9063228692Sdes	func_append oldlibs " $output_objdir/$libname.$libext"
9064125647Sdes
9065125647Sdes	# Transform .lo files to .o files.
9066348980Sdes	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
9067125647Sdes      fi
9068125647Sdes
9069125647Sdes      # Eliminate all temporary directories.
9070174832Sdes      #for path in $notinst_path; do
9071228692Sdes      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
9072228692Sdes      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
9073228692Sdes      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
9074174832Sdes      #done
9075125647Sdes
9076125647Sdes      if test -n "$xrpath"; then
9077117610Sdes	# If the user specified any rpath flags, then add them.
9078125647Sdes	temp_xrpath=
9079125647Sdes	for libdir in $xrpath; do
9080228692Sdes	  func_replace_sysroot "$libdir"
9081228692Sdes	  func_append temp_xrpath " -R$func_replace_sysroot_result"
9082117610Sdes	  case "$finalize_rpath " in
9083117610Sdes	  *" $libdir "*) ;;
9084228692Sdes	  *) func_append finalize_rpath " $libdir" ;;
9085117610Sdes	  esac
9086117610Sdes	done
9087348980Sdes	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
9088125647Sdes	  dependency_libs="$temp_xrpath $dependency_libs"
9089125647Sdes	fi
9090117610Sdes      fi
9091117610Sdes
9092125647Sdes      # Make sure dlfiles contains only unique files that won't be dlpreopened
9093348980Sdes      old_dlfiles=$dlfiles
9094125647Sdes      dlfiles=
9095125647Sdes      for lib in $old_dlfiles; do
9096125647Sdes	case " $dlprefiles $dlfiles " in
9097125647Sdes	*" $lib "*) ;;
9098228692Sdes	*) func_append dlfiles " $lib" ;;
9099125647Sdes	esac
9100117610Sdes      done
9101117610Sdes
9102125647Sdes      # Make sure dlprefiles contains only unique files
9103348980Sdes      old_dlprefiles=$dlprefiles
9104125647Sdes      dlprefiles=
9105125647Sdes      for lib in $old_dlprefiles; do
9106125647Sdes	case "$dlprefiles " in
9107125647Sdes	*" $lib "*) ;;
9108228692Sdes	*) func_append dlprefiles " $lib" ;;
9109125647Sdes	esac
9110125647Sdes      done
9111125647Sdes
9112348980Sdes      if test yes = "$build_libtool_libs"; then
9113125647Sdes	if test -n "$rpath"; then
9114125647Sdes	  case $host in
9115228692Sdes	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
9116125647Sdes	    # these systems don't actually have a c library (as such)!
9117125647Sdes	    ;;
9118125647Sdes	  *-*-rhapsody* | *-*-darwin1.[012])
9119125647Sdes	    # Rhapsody C library is in the System framework
9120228692Sdes	    func_append deplibs " System.ltframework"
9121125647Sdes	    ;;
9122125647Sdes	  *-*-netbsd*)
9123125647Sdes	    # Don't link with libc until the a.out ld.so is fixed.
9124125647Sdes	    ;;
9125147455Sdes	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
9126125647Sdes	    # Do not include libc due to us having libc/libc_r.
9127125647Sdes	    ;;
9128174832Sdes	  *-*-sco3.2v5* | *-*-sco5v6*)
9129174832Sdes	    # Causes problems with __ctype
9130174832Sdes	    ;;
9131174832Sdes	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
9132174832Sdes	    # Compiler inserts libc in the correct place for threads to work
9133174832Sdes	    ;;
9134228692Sdes	  *)
9135125647Sdes	    # Add libc to deplibs on all other systems if necessary.
9136348980Sdes	    if test yes = "$build_libtool_need_lc"; then
9137228692Sdes	      func_append deplibs " -lc"
9138117610Sdes	    fi
9139125647Sdes	    ;;
9140117610Sdes	  esac
9141117610Sdes	fi
9142117610Sdes
9143117610Sdes	# Transform deplibs into only deplibs that can be linked in shared.
9144117610Sdes	name_save=$name
9145117610Sdes	libname_save=$libname
9146117610Sdes	release_save=$release
9147117610Sdes	versuffix_save=$versuffix
9148117610Sdes	major_save=$major
9149117610Sdes	# I'm not sure if I'm treating the release correctly.  I think
9150117610Sdes	# release should show up in the -l (ie -lgmp5) so we don't want to
9151117610Sdes	# add it in twice.  Is that correct?
9152348980Sdes	release=
9153348980Sdes	versuffix=
9154348980Sdes	major=
9155117610Sdes	newdeplibs=
9156117610Sdes	droppeddeps=no
9157125647Sdes	case $deplibs_check_method in
9158117610Sdes	pass_all)
9159117610Sdes	  # Don't check for shared/static.  Everything works.
9160117610Sdes	  # This might be a little naive.  We might want to check
9161117610Sdes	  # whether the library exists or not.  But this is on
9162117610Sdes	  # osf3 & osf4 and I'm not really sure... Just
9163141098Sdes	  # implementing what was already the behavior.
9164117610Sdes	  newdeplibs=$deplibs
9165117610Sdes	  ;;
9166117610Sdes	test_compile)
9167117610Sdes	  # This code stresses the "libraries are programs" paradigm to its
9168117610Sdes	  # limits. Maybe even breaks it.  We compile a program, linking it
9169117610Sdes	  # against the deplibs as a proxy for the library.  Then we can check
9170117610Sdes	  # whether they linked in statically or dynamically with ldd.
9171228692Sdes	  $opt_dry_run || $RM conftest.c
9172117610Sdes	  cat > conftest.c <<EOF
9173117610Sdes	  int main() { return 0; }
9174117610SdesEOF
9175228692Sdes	  $opt_dry_run || $RM conftest
9176174832Sdes	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
9177117610Sdes	    ldd_output=`ldd conftest`
9178117610Sdes	    for i in $deplibs; do
9179228692Sdes	      case $i in
9180228692Sdes	      -l*)
9181228692Sdes		func_stripname -l '' "$i"
9182228692Sdes		name=$func_stripname_result
9183348980Sdes		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9184141098Sdes		  case " $predeps $postdeps " in
9185141098Sdes		  *" $i "*)
9186228692Sdes		    func_append newdeplibs " $i"
9187348980Sdes		    i=
9188141098Sdes		    ;;
9189141098Sdes		  esac
9190228692Sdes		fi
9191348980Sdes		if test -n "$i"; then
9192228692Sdes		  libname=`eval "\\$ECHO \"$libname_spec\""`
9193228692Sdes		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9194228692Sdes		  set dummy $deplib_matches; shift
9195228692Sdes		  deplib_match=$1
9196348980Sdes		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9197228692Sdes		    func_append newdeplibs " $i"
9198141098Sdes		  else
9199141098Sdes		    droppeddeps=yes
9200228692Sdes		    echo
9201228692Sdes		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9202228692Sdes		    echo "*** I have the capability to make that library automatically link in when"
9203228692Sdes		    echo "*** you link to this library.  But I can only do this if you have a"
9204228692Sdes		    echo "*** shared version of the library, which I believe you do not have"
9205228692Sdes		    echo "*** because a test_compile did reveal that the linker did not use it for"
9206228692Sdes		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
9207141098Sdes		  fi
9208117610Sdes		fi
9209228692Sdes		;;
9210228692Sdes	      *)
9211228692Sdes		func_append newdeplibs " $i"
9212228692Sdes		;;
9213228692Sdes	      esac
9214117610Sdes	    done
9215117610Sdes	  else
9216141098Sdes	    # Error occurred in the first compile.  Let's try to salvage
9217125647Sdes	    # the situation: Compile a separate program for each library.
9218117610Sdes	    for i in $deplibs; do
9219228692Sdes	      case $i in
9220228692Sdes	      -l*)
9221228692Sdes		func_stripname -l '' "$i"
9222228692Sdes		name=$func_stripname_result
9223228692Sdes		$opt_dry_run || $RM conftest
9224174832Sdes		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
9225117610Sdes		  ldd_output=`ldd conftest`
9226348980Sdes		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9227141098Sdes		    case " $predeps $postdeps " in
9228141098Sdes		    *" $i "*)
9229228692Sdes		      func_append newdeplibs " $i"
9230348980Sdes		      i=
9231141098Sdes		      ;;
9232141098Sdes		    esac
9233117610Sdes		  fi
9234348980Sdes		  if test -n "$i"; then
9235228692Sdes		    libname=`eval "\\$ECHO \"$libname_spec\""`
9236228692Sdes		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9237228692Sdes		    set dummy $deplib_matches; shift
9238228692Sdes		    deplib_match=$1
9239348980Sdes		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9240228692Sdes		      func_append newdeplibs " $i"
9241141098Sdes		    else
9242141098Sdes		      droppeddeps=yes
9243228692Sdes		      echo
9244228692Sdes		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9245228692Sdes		      echo "*** I have the capability to make that library automatically link in when"
9246228692Sdes		      echo "*** you link to this library.  But I can only do this if you have a"
9247228692Sdes		      echo "*** shared version of the library, which you do not appear to have"
9248228692Sdes		      echo "*** because a test_compile did reveal that the linker did not use this one"
9249228692Sdes		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
9250141098Sdes		    fi
9251141098Sdes		  fi
9252117610Sdes		else
9253117610Sdes		  droppeddeps=yes
9254228692Sdes		  echo
9255228692Sdes		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
9256228692Sdes		  echo "*** make it link in!  You will probably need to install it or some"
9257228692Sdes		  echo "*** library that it depends on before this library will be fully"
9258228692Sdes		  echo "*** functional.  Installing it before continuing would be even better."
9259117610Sdes		fi
9260228692Sdes		;;
9261228692Sdes	      *)
9262228692Sdes		func_append newdeplibs " $i"
9263228692Sdes		;;
9264228692Sdes	      esac
9265117610Sdes	    done
9266117610Sdes	  fi
9267117610Sdes	  ;;
9268117610Sdes	file_magic*)
9269228692Sdes	  set dummy $deplibs_check_method; shift
9270228692Sdes	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9271117610Sdes	  for a_deplib in $deplibs; do
9272228692Sdes	    case $a_deplib in
9273228692Sdes	    -l*)
9274228692Sdes	      func_stripname -l '' "$a_deplib"
9275228692Sdes	      name=$func_stripname_result
9276348980Sdes	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9277141098Sdes		case " $predeps $postdeps " in
9278141098Sdes		*" $a_deplib "*)
9279228692Sdes		  func_append newdeplibs " $a_deplib"
9280348980Sdes		  a_deplib=
9281141098Sdes		  ;;
9282141098Sdes		esac
9283141098Sdes	      fi
9284348980Sdes	      if test -n "$a_deplib"; then
9285228692Sdes		libname=`eval "\\$ECHO \"$libname_spec\""`
9286228692Sdes		if test -n "$file_magic_glob"; then
9287228692Sdes		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9288228692Sdes		else
9289228692Sdes		  libnameglob=$libname
9290228692Sdes		fi
9291348980Sdes		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
9292141098Sdes		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9293348980Sdes		  if test yes = "$want_nocaseglob"; then
9294228692Sdes		    shopt -s nocaseglob
9295228692Sdes		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9296228692Sdes		    $nocaseglob
9297228692Sdes		  else
9298228692Sdes		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9299228692Sdes		  fi
9300141098Sdes		  for potent_lib in $potential_libs; do
9301117610Sdes		      # Follow soft links.
9302228692Sdes		      if ls -lLd "$potent_lib" 2>/dev/null |
9303228692Sdes			 $GREP " -> " >/dev/null; then
9304125647Sdes			continue
9305117610Sdes		      fi
9306117610Sdes		      # The statement above tries to avoid entering an
9307117610Sdes		      # endless loop below, in case of cyclic links.
9308117610Sdes		      # We might still enter an endless loop, since a link
9309117610Sdes		      # loop can be closed while we follow links,
9310117610Sdes		      # but so what?
9311348980Sdes		      potlib=$potent_lib
9312117610Sdes		      while test -h "$potlib" 2>/dev/null; do
9313348980Sdes			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
9314125647Sdes			case $potliblink in
9315348980Sdes			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
9316348980Sdes			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
9317117610Sdes			esac
9318117610Sdes		      done
9319228692Sdes		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
9320228692Sdes			 $SED -e 10q |
9321228692Sdes			 $EGREP "$file_magic_regex" > /dev/null; then
9322228692Sdes			func_append newdeplibs " $a_deplib"
9323348980Sdes			a_deplib=
9324117610Sdes			break 2
9325117610Sdes		      fi
9326141098Sdes		  done
9327141098Sdes		done
9328141098Sdes	      fi
9329348980Sdes	      if test -n "$a_deplib"; then
9330117610Sdes		droppeddeps=yes
9331228692Sdes		echo
9332228692Sdes		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9333228692Sdes		echo "*** I have the capability to make that library automatically link in when"
9334228692Sdes		echo "*** you link to this library.  But I can only do this if you have a"
9335228692Sdes		echo "*** shared version of the library, which you do not appear to have"
9336228692Sdes		echo "*** because I did check the linker path looking for a file starting"
9337348980Sdes		if test -z "$potlib"; then
9338228692Sdes		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
9339125647Sdes		else
9340228692Sdes		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9341228692Sdes		  $ECHO "*** using a file magic. Last file checked: $potlib"
9342125647Sdes		fi
9343117610Sdes	      fi
9344228692Sdes	      ;;
9345228692Sdes	    *)
9346117610Sdes	      # Add a -L argument.
9347228692Sdes	      func_append newdeplibs " $a_deplib"
9348228692Sdes	      ;;
9349228692Sdes	    esac
9350117610Sdes	  done # Gone through all deplibs.
9351117610Sdes	  ;;
9352125647Sdes	match_pattern*)
9353228692Sdes	  set dummy $deplibs_check_method; shift
9354228692Sdes	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9355125647Sdes	  for a_deplib in $deplibs; do
9356228692Sdes	    case $a_deplib in
9357228692Sdes	    -l*)
9358228692Sdes	      func_stripname -l '' "$a_deplib"
9359228692Sdes	      name=$func_stripname_result
9360348980Sdes	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9361141098Sdes		case " $predeps $postdeps " in
9362141098Sdes		*" $a_deplib "*)
9363228692Sdes		  func_append newdeplibs " $a_deplib"
9364348980Sdes		  a_deplib=
9365141098Sdes		  ;;
9366141098Sdes		esac
9367141098Sdes	      fi
9368348980Sdes	      if test -n "$a_deplib"; then
9369228692Sdes		libname=`eval "\\$ECHO \"$libname_spec\""`
9370141098Sdes		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9371141098Sdes		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
9372141098Sdes		  for potent_lib in $potential_libs; do
9373348980Sdes		    potlib=$potent_lib # see symlink-check above in file_magic test
9374228692Sdes		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
9375228692Sdes		       $EGREP "$match_pattern_regex" > /dev/null; then
9376228692Sdes		      func_append newdeplibs " $a_deplib"
9377348980Sdes		      a_deplib=
9378141098Sdes		      break 2
9379141098Sdes		    fi
9380141098Sdes		  done
9381125647Sdes		done
9382141098Sdes	      fi
9383348980Sdes	      if test -n "$a_deplib"; then
9384125647Sdes		droppeddeps=yes
9385228692Sdes		echo
9386228692Sdes		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9387228692Sdes		echo "*** I have the capability to make that library automatically link in when"
9388228692Sdes		echo "*** you link to this library.  But I can only do this if you have a"
9389228692Sdes		echo "*** shared version of the library, which you do not appear to have"
9390228692Sdes		echo "*** because I did check the linker path looking for a file starting"
9391348980Sdes		if test -z "$potlib"; then
9392228692Sdes		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
9393125647Sdes		else
9394228692Sdes		  $ECHO "*** with $libname and none of the candidates passed a file format test"
9395228692Sdes		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
9396125647Sdes		fi
9397125647Sdes	      fi
9398228692Sdes	      ;;
9399228692Sdes	    *)
9400125647Sdes	      # Add a -L argument.
9401228692Sdes	      func_append newdeplibs " $a_deplib"
9402228692Sdes	      ;;
9403228692Sdes	    esac
9404125647Sdes	  done # Gone through all deplibs.
9405125647Sdes	  ;;
9406117610Sdes	none | unknown | *)
9407348980Sdes	  newdeplibs=
9408228692Sdes	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
9409348980Sdes	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9410348980Sdes	    for i in $predeps $postdeps; do
9411141098Sdes	      # can't use Xsed below, because $i might contain '/'
9412348980Sdes	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
9413141098Sdes	    done
9414141098Sdes	  fi
9415228692Sdes	  case $tmp_deplibs in
9416228692Sdes	  *[!\	\ ]*)
9417228692Sdes	    echo
9418348980Sdes	    if test none = "$deplibs_check_method"; then
9419228692Sdes	      echo "*** Warning: inter-library dependencies are not supported in this platform."
9420117610Sdes	    else
9421228692Sdes	      echo "*** Warning: inter-library dependencies are not known to be supported."
9422117610Sdes	    fi
9423228692Sdes	    echo "*** All declared inter-library dependencies are being dropped."
9424117610Sdes	    droppeddeps=yes
9425228692Sdes	    ;;
9426228692Sdes	  esac
9427117610Sdes	  ;;
9428117610Sdes	esac
9429117610Sdes	versuffix=$versuffix_save
9430117610Sdes	major=$major_save
9431117610Sdes	release=$release_save
9432117610Sdes	libname=$libname_save
9433117610Sdes	name=$name_save
9434117610Sdes
9435125647Sdes	case $host in
9436125647Sdes	*-*-rhapsody* | *-*-darwin1.[012])
9437228692Sdes	  # On Rhapsody replace the C library with the System framework
9438228692Sdes	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
9439125647Sdes	  ;;
9440125647Sdes	esac
9441125647Sdes
9442348980Sdes	if test yes = "$droppeddeps"; then
9443348980Sdes	  if test yes = "$module"; then
9444228692Sdes	    echo
9445228692Sdes	    echo "*** Warning: libtool could not satisfy all declared inter-library"
9446228692Sdes	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
9447228692Sdes	    echo "*** a static module, that should work as long as the dlopening"
9448228692Sdes	    echo "*** application is linked with the -dlopen flag."
9449117610Sdes	    if test -z "$global_symbol_pipe"; then
9450228692Sdes	      echo
9451228692Sdes	      echo "*** However, this would only work if libtool was able to extract symbol"
9452348980Sdes	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9453228692Sdes	      echo "*** not find such a program.  So, this module is probably useless."
9454348980Sdes	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
9455117610Sdes	    fi
9456348980Sdes	    if test no = "$build_old_libs"; then
9457348980Sdes	      oldlibs=$output_objdir/$libname.$libext
9458117610Sdes	      build_libtool_libs=module
9459117610Sdes	      build_old_libs=yes
9460117610Sdes	    else
9461117610Sdes	      build_libtool_libs=no
9462117610Sdes	    fi
9463117610Sdes	  else
9464228692Sdes	    echo "*** The inter-library dependencies that have been dropped here will be"
9465228692Sdes	    echo "*** automatically added whenever a program is linked with this library"
9466228692Sdes	    echo "*** or is declared to -dlopen it."
9467125647Sdes
9468348980Sdes	    if test no = "$allow_undefined"; then
9469228692Sdes	      echo
9470228692Sdes	      echo "*** Since this library must not contain undefined symbols,"
9471228692Sdes	      echo "*** because either the platform does not support them or"
9472228692Sdes	      echo "*** it was explicitly requested with -no-undefined,"
9473228692Sdes	      echo "*** libtool will only create a static version of it."
9474348980Sdes	      if test no = "$build_old_libs"; then
9475348980Sdes		oldlibs=$output_objdir/$libname.$libext
9476125647Sdes		build_libtool_libs=module
9477125647Sdes		build_old_libs=yes
9478125647Sdes	      else
9479125647Sdes		build_libtool_libs=no
9480125647Sdes	      fi
9481125647Sdes	    fi
9482117610Sdes	  fi
9483117610Sdes	fi
9484117610Sdes	# Done checking deplibs!
9485117610Sdes	deplibs=$newdeplibs
9486117610Sdes      fi
9487228692Sdes      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9488228692Sdes      case $host in
9489228692Sdes	*-*-darwin*)
9490228692Sdes	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9491228692Sdes	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9492228692Sdes	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9493228692Sdes	  ;;
9494228692Sdes      esac
9495117610Sdes
9496174832Sdes      # move library search paths that coincide with paths to not yet
9497174832Sdes      # installed libraries to the beginning of the library search list
9498174832Sdes      new_libs=
9499174832Sdes      for path in $notinst_path; do
9500174832Sdes	case " $new_libs " in
9501174832Sdes	*" -L$path/$objdir "*) ;;
9502174832Sdes	*)
9503174832Sdes	  case " $deplibs " in
9504174832Sdes	  *" -L$path/$objdir "*)
9505228692Sdes	    func_append new_libs " -L$path/$objdir" ;;
9506174832Sdes	  esac
9507174832Sdes	  ;;
9508174832Sdes	esac
9509174832Sdes      done
9510174832Sdes      for deplib in $deplibs; do
9511174832Sdes	case $deplib in
9512174832Sdes	-L*)
9513174832Sdes	  case " $new_libs " in
9514174832Sdes	  *" $deplib "*) ;;
9515228692Sdes	  *) func_append new_libs " $deplib" ;;
9516174832Sdes	  esac
9517174832Sdes	  ;;
9518228692Sdes	*) func_append new_libs " $deplib" ;;
9519174832Sdes	esac
9520174832Sdes      done
9521348980Sdes      deplibs=$new_libs
9522174832Sdes
9523117610Sdes      # All the library-specific variables (install_libdir is set above).
9524117610Sdes      library_names=
9525117610Sdes      old_library=
9526117610Sdes      dlname=
9527125647Sdes
9528117610Sdes      # Test again, we may have decided not to build it any more
9529348980Sdes      if test yes = "$build_libtool_libs"; then
9530348980Sdes	# Remove $wl instances when linking with ld.
9531236109Sdes	# FIXME: should test the right _cmds variable.
9532236109Sdes	case $archive_cmds in
9533236109Sdes	  *\$LD\ *) wl= ;;
9534236109Sdes        esac
9535348980Sdes	if test yes = "$hardcode_into_libs"; then
9536125647Sdes	  # Hardcode the library paths
9537125647Sdes	  hardcode_libdirs=
9538125647Sdes	  dep_rpath=
9539348980Sdes	  rpath=$finalize_rpath
9540348980Sdes	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
9541125647Sdes	  for libdir in $rpath; do
9542125647Sdes	    if test -n "$hardcode_libdir_flag_spec"; then
9543125647Sdes	      if test -n "$hardcode_libdir_separator"; then
9544228692Sdes		func_replace_sysroot "$libdir"
9545228692Sdes		libdir=$func_replace_sysroot_result
9546125647Sdes		if test -z "$hardcode_libdirs"; then
9547348980Sdes		  hardcode_libdirs=$libdir
9548125647Sdes		else
9549125647Sdes		  # Just accumulate the unique libdirs.
9550125647Sdes		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9551125647Sdes		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9552125647Sdes		    ;;
9553125647Sdes		  *)
9554228692Sdes		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
9555125647Sdes		    ;;
9556125647Sdes		  esac
9557125647Sdes		fi
9558125647Sdes	      else
9559125647Sdes		eval flag=\"$hardcode_libdir_flag_spec\"
9560228692Sdes		func_append dep_rpath " $flag"
9561125647Sdes	      fi
9562125647Sdes	    elif test -n "$runpath_var"; then
9563125647Sdes	      case "$perm_rpath " in
9564125647Sdes	      *" $libdir "*) ;;
9565236109Sdes	      *) func_append perm_rpath " $libdir" ;;
9566125647Sdes	      esac
9567125647Sdes	    fi
9568125647Sdes	  done
9569125647Sdes	  # Substitute the hardcoded libdirs into the rpath.
9570125647Sdes	  if test -n "$hardcode_libdir_separator" &&
9571125647Sdes	     test -n "$hardcode_libdirs"; then
9572348980Sdes	    libdir=$hardcode_libdirs
9573236109Sdes	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
9574125647Sdes	  fi
9575125647Sdes	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
9576125647Sdes	    # We should set the runpath_var.
9577125647Sdes	    rpath=
9578125647Sdes	    for dir in $perm_rpath; do
9579228692Sdes	      func_append rpath "$dir:"
9580125647Sdes	    done
9581125647Sdes	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
9582125647Sdes	  fi
9583125647Sdes	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
9584125647Sdes	fi
9585125647Sdes
9586348980Sdes	shlibpath=$finalize_shlibpath
9587348980Sdes	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
9588125647Sdes	if test -n "$shlibpath"; then
9589125647Sdes	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
9590125647Sdes	fi
9591125647Sdes
9592117610Sdes	# Get the real and link names of the library.
9593141098Sdes	eval shared_ext=\"$shrext_cmds\"
9594117610Sdes	eval library_names=\"$library_names_spec\"
9595117610Sdes	set dummy $library_names
9596228692Sdes	shift
9597348980Sdes	realname=$1
9598228692Sdes	shift
9599117610Sdes
9600117610Sdes	if test -n "$soname_spec"; then
9601117610Sdes	  eval soname=\"$soname_spec\"
9602117610Sdes	else
9603348980Sdes	  soname=$realname
9604117610Sdes	fi
9605141098Sdes	if test -z "$dlname"; then
9606141098Sdes	  dlname=$soname
9607141098Sdes	fi
9608117610Sdes
9609348980Sdes	lib=$output_objdir/$realname
9610174832Sdes	linknames=
9611117610Sdes	for link
9612117610Sdes	do
9613228692Sdes	  func_append linknames " $link"
9614117610Sdes	done
9615117610Sdes
9616117610Sdes	# Use standard objects if they are pic
9617228692Sdes	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
9618228692Sdes	test "X$libobjs" = "X " && libobjs=
9619117610Sdes
9620228692Sdes	delfiles=
9621228692Sdes	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9622228692Sdes	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
9623348980Sdes	  export_symbols=$output_objdir/$libname.uexp
9624228692Sdes	  func_append delfiles " $export_symbols"
9625228692Sdes	fi
9626228692Sdes
9627228692Sdes	orig_export_symbols=
9628228692Sdes	case $host_os in
9629228692Sdes	cygwin* | mingw* | cegcc*)
9630228692Sdes	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
9631228692Sdes	    # exporting using user supplied symfile
9632348980Sdes	    func_dll_def_p "$export_symbols" || {
9633228692Sdes	      # and it's NOT already a .def file. Must figure out
9634228692Sdes	      # which of the given symbols are data symbols and tag
9635228692Sdes	      # them as such. So, trigger use of export_symbols_cmds.
9636228692Sdes	      # export_symbols gets reassigned inside the "prepare
9637228692Sdes	      # the list of exported symbols" if statement, so the
9638228692Sdes	      # include_expsyms logic still works.
9639348980Sdes	      orig_export_symbols=$export_symbols
9640228692Sdes	      export_symbols=
9641228692Sdes	      always_export_symbols=yes
9642348980Sdes	    }
9643228692Sdes	  fi
9644228692Sdes	  ;;
9645228692Sdes	esac
9646228692Sdes
9647117610Sdes	# Prepare the list of exported symbols
9648117610Sdes	if test -z "$export_symbols"; then
9649348980Sdes	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
9650348980Sdes	    func_verbose "generating symbol list for '$libname.la'"
9651348980Sdes	    export_symbols=$output_objdir/$libname.exp
9652228692Sdes	    $opt_dry_run || $RM $export_symbols
9653141098Sdes	    cmds=$export_symbols_cmds
9654348980Sdes	    save_ifs=$IFS; IFS='~'
9655228692Sdes	    for cmd1 in $cmds; do
9656348980Sdes	      IFS=$save_ifs
9657228692Sdes	      # Take the normal branch if the nm_file_list_spec branch
9658228692Sdes	      # doesn't work or if tool conversion is not needed.
9659228692Sdes	      case $nm_file_list_spec~$to_tool_file_cmd in
9660228692Sdes		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9661228692Sdes		  try_normal_branch=yes
9662228692Sdes		  eval cmd=\"$cmd1\"
9663228692Sdes		  func_len " $cmd"
9664228692Sdes		  len=$func_len_result
9665228692Sdes		  ;;
9666228692Sdes		*)
9667228692Sdes		  try_normal_branch=no
9668228692Sdes		  ;;
9669228692Sdes	      esac
9670348980Sdes	      if test yes = "$try_normal_branch" \
9671228692Sdes		 && { test "$len" -lt "$max_cmd_len" \
9672228692Sdes		      || test "$max_cmd_len" -le -1; }
9673228692Sdes	      then
9674228692Sdes		func_show_eval "$cmd" 'exit $?'
9675228692Sdes		skipped_export=false
9676228692Sdes	      elif test -n "$nm_file_list_spec"; then
9677228692Sdes		func_basename "$output"
9678228692Sdes		output_la=$func_basename_result
9679228692Sdes		save_libobjs=$libobjs
9680228692Sdes		save_output=$output
9681348980Sdes		output=$output_objdir/$output_la.nm
9682228692Sdes		func_to_tool_file "$output"
9683228692Sdes		libobjs=$nm_file_list_spec$func_to_tool_file_result
9684228692Sdes		func_append delfiles " $output"
9685228692Sdes		func_verbose "creating $NM input file list: $output"
9686228692Sdes		for obj in $save_libobjs; do
9687228692Sdes		  func_to_tool_file "$obj"
9688228692Sdes		  $ECHO "$func_to_tool_file_result"
9689228692Sdes		done > "$output"
9690228692Sdes		eval cmd=\"$cmd1\"
9691228692Sdes		func_show_eval "$cmd" 'exit $?'
9692228692Sdes		output=$save_output
9693228692Sdes		libobjs=$save_libobjs
9694228692Sdes		skipped_export=false
9695141098Sdes	      else
9696228692Sdes		# The command line is too long to execute in one step.
9697228692Sdes		func_verbose "using reloadable object file for export list..."
9698228692Sdes		skipped_export=:
9699174832Sdes		# Break out early, otherwise skipped_export may be
9700174832Sdes		# set to false by a later but shorter cmd.
9701174832Sdes		break
9702141098Sdes	      fi
9703117610Sdes	    done
9704348980Sdes	    IFS=$save_ifs
9705348980Sdes	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
9706228692Sdes	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9707228692Sdes	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9708117610Sdes	    fi
9709117610Sdes	  fi
9710117610Sdes	fi
9711117610Sdes
9712117610Sdes	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9713348980Sdes	  tmp_export_symbols=$export_symbols
9714348980Sdes	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9715228692Sdes	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9716117610Sdes	fi
9717117610Sdes
9718348980Sdes	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
9719228692Sdes	  # The given exports_symbols file has to be filtered, so filter it.
9720348980Sdes	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9721228692Sdes	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
9722348980Sdes	  # 's' commands, which not all seds can handle. GNU sed should be fine
9723228692Sdes	  # though. Also, the filter scales superlinearly with the number of
9724228692Sdes	  # global variables. join(1) would be nice here, but unfortunately
9725228692Sdes	  # isn't a blessed tool.
9726228692Sdes	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9727228692Sdes	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9728228692Sdes	  export_symbols=$output_objdir/$libname.def
9729228692Sdes	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9730228692Sdes	fi
9731228692Sdes
9732141098Sdes	tmp_deplibs=
9733141098Sdes	for test_deplib in $deplibs; do
9734228692Sdes	  case " $convenience " in
9735228692Sdes	  *" $test_deplib "*) ;;
9736228692Sdes	  *)
9737228692Sdes	    func_append tmp_deplibs " $test_deplib"
9738228692Sdes	    ;;
9739228692Sdes	  esac
9740141098Sdes	done
9741348980Sdes	deplibs=$tmp_deplibs
9742141098Sdes
9743117610Sdes	if test -n "$convenience"; then
9744228692Sdes	  if test -n "$whole_archive_flag_spec" &&
9745348980Sdes	    test yes = "$compiler_needs_object" &&
9746228692Sdes	    test -z "$libobjs"; then
9747228692Sdes	    # extract the archives, so we have objects to list.
9748228692Sdes	    # TODO: could optimize this to just extract one archive.
9749228692Sdes	    whole_archive_flag_spec=
9750228692Sdes	  fi
9751117610Sdes	  if test -n "$whole_archive_flag_spec"; then
9752141098Sdes	    save_libobjs=$libobjs
9753117610Sdes	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9754228692Sdes	    test "X$libobjs" = "X " && libobjs=
9755117610Sdes	  else
9756348980Sdes	    gentop=$output_objdir/${outputname}x
9757228692Sdes	    func_append generated " $gentop"
9758117610Sdes
9759141098Sdes	    func_extract_archives $gentop $convenience
9760228692Sdes	    func_append libobjs " $func_extract_archives_result"
9761228692Sdes	    test "X$libobjs" = "X " && libobjs=
9762117610Sdes	  fi
9763117610Sdes	fi
9764228692Sdes
9765348980Sdes	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
9766117610Sdes	  eval flag=\"$thread_safe_flag_spec\"
9767228692Sdes	  func_append linker_flags " $flag"
9768117610Sdes	fi
9769117610Sdes
9770125647Sdes	# Make a backup of the uninstalled library when relinking
9771348980Sdes	if test relink = "$opt_mode"; then
9772228692Sdes	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
9773125647Sdes	fi
9774125647Sdes
9775117610Sdes	# Do each of the archive commands.
9776348980Sdes	if test yes = "$module" && test -n "$module_cmds"; then
9777141098Sdes	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9778141098Sdes	    eval test_cmds=\"$module_expsym_cmds\"
9779141098Sdes	    cmds=$module_expsym_cmds
9780141098Sdes	  else
9781141098Sdes	    eval test_cmds=\"$module_cmds\"
9782141098Sdes	    cmds=$module_cmds
9783141098Sdes	  fi
9784141098Sdes	else
9785228692Sdes	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
9786228692Sdes	    eval test_cmds=\"$archive_expsym_cmds\"
9787228692Sdes	    cmds=$archive_expsym_cmds
9788228692Sdes	  else
9789228692Sdes	    eval test_cmds=\"$archive_cmds\"
9790228692Sdes	    cmds=$archive_cmds
9791141098Sdes	  fi
9792141098Sdes	fi
9793141098Sdes
9794348980Sdes	if test : != "$skipped_export" &&
9795228692Sdes	   func_len " $test_cmds" &&
9796228692Sdes	   len=$func_len_result &&
9797228692Sdes	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9798141098Sdes	  :
9799141098Sdes	else
9800228692Sdes	  # The command line is too long to link in one step, link piecewise
9801228692Sdes	  # or, if using GNU ld and skipped_export is not :, use a linker
9802228692Sdes	  # script.
9803141098Sdes
9804141098Sdes	  # Save the value of $output and $libobjs because we want to
9805141098Sdes	  # use them later.  If we have whole_archive_flag_spec, we
9806141098Sdes	  # want to use save_libobjs as it was before
9807141098Sdes	  # whole_archive_flag_spec was expanded, because we can't
9808141098Sdes	  # assume the linker understands whole_archive_flag_spec.
9809141098Sdes	  # This may have to be revisited, in case too many
9810141098Sdes	  # convenience libraries get linked in and end up exceeding
9811141098Sdes	  # the spec.
9812141098Sdes	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
9813141098Sdes	    save_libobjs=$libobjs
9814141098Sdes	  fi
9815141098Sdes	  save_output=$output
9816228692Sdes	  func_basename "$output"
9817228692Sdes	  output_la=$func_basename_result
9818141098Sdes
9819141098Sdes	  # Clear the reloadable object creation command queue and
9820141098Sdes	  # initialize k to one.
9821141098Sdes	  test_cmds=
9822141098Sdes	  concat_cmds=
9823141098Sdes	  objlist=
9824141098Sdes	  last_robj=
9825141098Sdes	  k=1
9826228692Sdes
9827348980Sdes	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
9828348980Sdes	    output=$output_objdir/$output_la.lnkscript
9829228692Sdes	    func_verbose "creating GNU ld script: $output"
9830228692Sdes	    echo 'INPUT (' > $output
9831228692Sdes	    for obj in $save_libobjs
9832228692Sdes	    do
9833228692Sdes	      func_to_tool_file "$obj"
9834228692Sdes	      $ECHO "$func_to_tool_file_result" >> $output
9835228692Sdes	    done
9836228692Sdes	    echo ')' >> $output
9837228692Sdes	    func_append delfiles " $output"
9838228692Sdes	    func_to_tool_file "$output"
9839228692Sdes	    output=$func_to_tool_file_result
9840348980Sdes	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
9841348980Sdes	    output=$output_objdir/$output_la.lnk
9842228692Sdes	    func_verbose "creating linker input file list: $output"
9843228692Sdes	    : > $output
9844228692Sdes	    set x $save_libobjs
9845228692Sdes	    shift
9846228692Sdes	    firstobj=
9847348980Sdes	    if test yes = "$compiler_needs_object"; then
9848228692Sdes	      firstobj="$1 "
9849228692Sdes	      shift
9850228692Sdes	    fi
9851228692Sdes	    for obj
9852228692Sdes	    do
9853228692Sdes	      func_to_tool_file "$obj"
9854228692Sdes	      $ECHO "$func_to_tool_file_result" >> $output
9855228692Sdes	    done
9856228692Sdes	    func_append delfiles " $output"
9857228692Sdes	    func_to_tool_file "$output"
9858228692Sdes	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
9859228692Sdes	  else
9860228692Sdes	    if test -n "$save_libobjs"; then
9861228692Sdes	      func_verbose "creating reloadable object files..."
9862348980Sdes	      output=$output_objdir/$output_la-$k.$objext
9863228692Sdes	      eval test_cmds=\"$reload_cmds\"
9864228692Sdes	      func_len " $test_cmds"
9865228692Sdes	      len0=$func_len_result
9866228692Sdes	      len=$len0
9867228692Sdes
9868228692Sdes	      # Loop over the list of objects to be linked.
9869228692Sdes	      for obj in $save_libobjs
9870228692Sdes	      do
9871228692Sdes		func_len " $obj"
9872228692Sdes		func_arith $len + $func_len_result
9873228692Sdes		len=$func_arith_result
9874348980Sdes		if test -z "$objlist" ||
9875228692Sdes		   test "$len" -lt "$max_cmd_len"; then
9876228692Sdes		  func_append objlist " $obj"
9877228692Sdes		else
9878228692Sdes		  # The command $test_cmds is almost too long, add a
9879228692Sdes		  # command to the queue.
9880348980Sdes		  if test 1 -eq "$k"; then
9881228692Sdes		    # The first file doesn't have a previous command to add.
9882228692Sdes		    reload_objs=$objlist
9883228692Sdes		    eval concat_cmds=\"$reload_cmds\"
9884228692Sdes		  else
9885228692Sdes		    # All subsequent reloadable object files will link in
9886228692Sdes		    # the last one created.
9887228692Sdes		    reload_objs="$objlist $last_robj"
9888228692Sdes		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
9889228692Sdes		  fi
9890348980Sdes		  last_robj=$output_objdir/$output_la-$k.$objext
9891228692Sdes		  func_arith $k + 1
9892228692Sdes		  k=$func_arith_result
9893348980Sdes		  output=$output_objdir/$output_la-$k.$objext
9894228692Sdes		  objlist=" $obj"
9895228692Sdes		  func_len " $last_robj"
9896228692Sdes		  func_arith $len0 + $func_len_result
9897228692Sdes		  len=$func_arith_result
9898228692Sdes		fi
9899228692Sdes	      done
9900228692Sdes	      # Handle the remaining objects by creating one last
9901228692Sdes	      # reloadable object file.  All subsequent reloadable object
9902228692Sdes	      # files will link in the last one created.
9903228692Sdes	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9904228692Sdes	      reload_objs="$objlist $last_robj"
9905348980Sdes	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
9906228692Sdes	      if test -n "$last_robj"; then
9907348980Sdes	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9908228692Sdes	      fi
9909228692Sdes	      func_append delfiles " $output"
9910228692Sdes
9911141098Sdes	    else
9912228692Sdes	      output=
9913228692Sdes	    fi
9914228692Sdes
9915348980Sdes	    ${skipped_export-false} && {
9916348980Sdes	      func_verbose "generating symbol list for '$libname.la'"
9917348980Sdes	      export_symbols=$output_objdir/$libname.exp
9918228692Sdes	      $opt_dry_run || $RM $export_symbols
9919228692Sdes	      libobjs=$output
9920228692Sdes	      # Append the command to create the export file.
9921228692Sdes	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9922228692Sdes	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
9923228692Sdes	      if test -n "$last_robj"; then
9924228692Sdes		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9925125647Sdes	      fi
9926348980Sdes	    }
9927141098Sdes
9928228692Sdes	    test -n "$save_libobjs" &&
9929228692Sdes	      func_verbose "creating a temporary reloadable object file: $output"
9930141098Sdes
9931228692Sdes	    # Loop through the commands generated above and execute them.
9932348980Sdes	    save_ifs=$IFS; IFS='~'
9933228692Sdes	    for cmd in $concat_cmds; do
9934348980Sdes	      IFS=$save_ifs
9935348980Sdes	      $opt_quiet || {
9936228692Sdes		  func_quote_for_expand "$cmd"
9937228692Sdes		  eval "func_echo $func_quote_for_expand_result"
9938228692Sdes	      }
9939228692Sdes	      $opt_dry_run || eval "$cmd" || {
9940228692Sdes		lt_exit=$?
9941141098Sdes
9942228692Sdes		# Restore the uninstalled library and exit
9943348980Sdes		if test relink = "$opt_mode"; then
9944228692Sdes		  ( cd "$output_objdir" && \
9945228692Sdes		    $RM "${realname}T" && \
9946228692Sdes		    $MV "${realname}U" "$realname" )
9947228692Sdes		fi
9948141098Sdes
9949228692Sdes		exit $lt_exit
9950228692Sdes	      }
9951228692Sdes	    done
9952348980Sdes	    IFS=$save_ifs
9953141098Sdes
9954228692Sdes	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
9955228692Sdes	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9956228692Sdes	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9957228692Sdes	    fi
9958228692Sdes	  fi
9959228692Sdes
9960348980Sdes          ${skipped_export-false} && {
9961228692Sdes	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
9962348980Sdes	      tmp_export_symbols=$export_symbols
9963348980Sdes	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9964228692Sdes	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9965228692Sdes	    fi
9966228692Sdes
9967228692Sdes	    if test -n "$orig_export_symbols"; then
9968228692Sdes	      # The given exports_symbols file has to be filtered, so filter it.
9969348980Sdes	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9970228692Sdes	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
9971348980Sdes	      # 's' commands, which not all seds can handle. GNU sed should be fine
9972228692Sdes	      # though. Also, the filter scales superlinearly with the number of
9973228692Sdes	      # global variables. join(1) would be nice here, but unfortunately
9974228692Sdes	      # isn't a blessed tool.
9975228692Sdes	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9976228692Sdes	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9977228692Sdes	      export_symbols=$output_objdir/$libname.def
9978228692Sdes	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9979228692Sdes	    fi
9980348980Sdes	  }
9981228692Sdes
9982141098Sdes	  libobjs=$output
9983141098Sdes	  # Restore the value of output.
9984141098Sdes	  output=$save_output
9985141098Sdes
9986141098Sdes	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
9987141098Sdes	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9988228692Sdes	    test "X$libobjs" = "X " && libobjs=
9989141098Sdes	  fi
9990141098Sdes	  # Expand the library linking commands again to reset the
9991141098Sdes	  # value of $libobjs for piecewise linking.
9992141098Sdes
9993141098Sdes	  # Do each of the archive commands.
9994348980Sdes	  if test yes = "$module" && test -n "$module_cmds"; then
9995141098Sdes	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9996141098Sdes	      cmds=$module_expsym_cmds
9997141098Sdes	    else
9998141098Sdes	      cmds=$module_cmds
9999141098Sdes	    fi
10000141098Sdes	  else
10001228692Sdes	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
10002228692Sdes	      cmds=$archive_expsym_cmds
10003228692Sdes	    else
10004228692Sdes	      cmds=$archive_cmds
10005141098Sdes	    fi
10006141098Sdes	  fi
10007228692Sdes	fi
10008141098Sdes
10009228692Sdes	if test -n "$delfiles"; then
10010228692Sdes	  # Append the command to remove temporary files to $cmds.
10011228692Sdes	  eval cmds=\"\$cmds~\$RM $delfiles\"
10012117610Sdes	fi
10013228692Sdes
10014228692Sdes	# Add any objects from preloaded convenience libraries
10015228692Sdes	if test -n "$dlprefiles"; then
10016348980Sdes	  gentop=$output_objdir/${outputname}x
10017228692Sdes	  func_append generated " $gentop"
10018228692Sdes
10019228692Sdes	  func_extract_archives $gentop $dlprefiles
10020228692Sdes	  func_append libobjs " $func_extract_archives_result"
10021228692Sdes	  test "X$libobjs" = "X " && libobjs=
10022228692Sdes	fi
10023228692Sdes
10024348980Sdes	save_ifs=$IFS; IFS='~'
10025117610Sdes	for cmd in $cmds; do
10026348980Sdes	  IFS=$sp$nl
10027141098Sdes	  eval cmd=\"$cmd\"
10028348980Sdes	  IFS=$save_ifs
10029348980Sdes	  $opt_quiet || {
10030228692Sdes	    func_quote_for_expand "$cmd"
10031228692Sdes	    eval "func_echo $func_quote_for_expand_result"
10032228692Sdes	  }
10033228692Sdes	  $opt_dry_run || eval "$cmd" || {
10034174832Sdes	    lt_exit=$?
10035174832Sdes
10036174832Sdes	    # Restore the uninstalled library and exit
10037348980Sdes	    if test relink = "$opt_mode"; then
10038228692Sdes	      ( cd "$output_objdir" && \
10039228692Sdes	        $RM "${realname}T" && \
10040228692Sdes		$MV "${realname}U" "$realname" )
10041174832Sdes	    fi
10042174832Sdes
10043174832Sdes	    exit $lt_exit
10044174832Sdes	  }
10045117610Sdes	done
10046348980Sdes	IFS=$save_ifs
10047117610Sdes
10048125647Sdes	# Restore the uninstalled library and exit
10049348980Sdes	if test relink = "$opt_mode"; then
10050228692Sdes	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
10051174832Sdes
10052174832Sdes	  if test -n "$convenience"; then
10053174832Sdes	    if test -z "$whole_archive_flag_spec"; then
10054228692Sdes	      func_show_eval '${RM}r "$gentop"'
10055174832Sdes	    fi
10056174832Sdes	  fi
10057174832Sdes
10058141098Sdes	  exit $EXIT_SUCCESS
10059125647Sdes	fi
10060125647Sdes
10061117610Sdes	# Create links to the real library.
10062117610Sdes	for linkname in $linknames; do
10063117610Sdes	  if test "$realname" != "$linkname"; then
10064228692Sdes	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
10065117610Sdes	  fi
10066117610Sdes	done
10067117610Sdes
10068117610Sdes	# If -module or -export-dynamic was specified, set the dlname.
10069348980Sdes	if test yes = "$module" || test yes = "$export_dynamic"; then
10070117610Sdes	  # On all known operating systems, these are identical.
10071348980Sdes	  dlname=$soname
10072117610Sdes	fi
10073117610Sdes      fi
10074117610Sdes      ;;
10075117610Sdes
10076125647Sdes    obj)
10077348980Sdes      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
10078348980Sdes	func_warning "'-dlopen' is ignored for objects"
10079117610Sdes      fi
10080117610Sdes
10081228692Sdes      case " $deplibs" in
10082228692Sdes      *\ -l* | *\ -L*)
10083348980Sdes	func_warning "'-l' and '-L' are ignored for objects" ;;
10084228692Sdes      esac
10085117610Sdes
10086228692Sdes      test -n "$rpath" && \
10087348980Sdes	func_warning "'-rpath' is ignored for objects"
10088117610Sdes
10089228692Sdes      test -n "$xrpath" && \
10090348980Sdes	func_warning "'-R' is ignored for objects"
10091117610Sdes
10092228692Sdes      test -n "$vinfo" && \
10093348980Sdes	func_warning "'-version-info' is ignored for objects"
10094117610Sdes
10095228692Sdes      test -n "$release" && \
10096348980Sdes	func_warning "'-release' is ignored for objects"
10097228692Sdes
10098125647Sdes      case $output in
10099117610Sdes      *.lo)
10100228692Sdes	test -n "$objs$old_deplibs" && \
10101348980Sdes	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
10102228692Sdes
10103228692Sdes	libobj=$output
10104228692Sdes	func_lo2o "$libobj"
10105228692Sdes	obj=$func_lo2o_result
10106117610Sdes	;;
10107117610Sdes      *)
10108117610Sdes	libobj=
10109348980Sdes	obj=$output
10110117610Sdes	;;
10111117610Sdes      esac
10112117610Sdes
10113117610Sdes      # Delete the old objects.
10114228692Sdes      $opt_dry_run || $RM $obj $libobj
10115117610Sdes
10116117610Sdes      # Objects from convenience libraries.  This assumes
10117117610Sdes      # single-version convenience libraries.  Whenever we create
10118117610Sdes      # different ones for PIC/non-PIC, this we'll have to duplicate
10119117610Sdes      # the extraction.
10120117610Sdes      reload_conv_objs=
10121117610Sdes      gentop=
10122348980Sdes      # if reload_cmds runs $LD directly, get rid of -Wl from
10123348980Sdes      # whole_archive_flag_spec and hope we can get by with turning comma
10124348980Sdes      # into space.
10125348980Sdes      case $reload_cmds in
10126348980Sdes        *\$LD[\ \$]*) wl= ;;
10127348980Sdes      esac
10128117610Sdes      if test -n "$convenience"; then
10129117610Sdes	if test -n "$whole_archive_flag_spec"; then
10130174832Sdes	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
10131348980Sdes	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
10132348980Sdes	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
10133117610Sdes	else
10134348980Sdes	  gentop=$output_objdir/${obj}x
10135228692Sdes	  func_append generated " $gentop"
10136117610Sdes
10137141098Sdes	  func_extract_archives $gentop $convenience
10138141098Sdes	  reload_conv_objs="$reload_objs $func_extract_archives_result"
10139117610Sdes	fi
10140117610Sdes      fi
10141117610Sdes
10142228692Sdes      # If we're not building shared, we need to use non_pic_objs
10143348980Sdes      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10144228692Sdes
10145117610Sdes      # Create the old-style object.
10146348980Sdes      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10147117610Sdes
10148348980Sdes      output=$obj
10149228692Sdes      func_execute_cmds "$reload_cmds" 'exit $?'
10150117610Sdes
10151117610Sdes      # Exit if we aren't doing a library object file.
10152117610Sdes      if test -z "$libobj"; then
10153117610Sdes	if test -n "$gentop"; then
10154228692Sdes	  func_show_eval '${RM}r "$gentop"'
10155117610Sdes	fi
10156117610Sdes
10157141098Sdes	exit $EXIT_SUCCESS
10158117610Sdes      fi
10159117610Sdes
10160348980Sdes      test yes = "$build_libtool_libs" || {
10161117610Sdes	if test -n "$gentop"; then
10162228692Sdes	  func_show_eval '${RM}r "$gentop"'
10163117610Sdes	fi
10164117610Sdes
10165117610Sdes	# Create an invalid libtool object if no PIC, so that we don't
10166117610Sdes	# accidentally link it into a program.
10167141098Sdes	# $show "echo timestamp > $libobj"
10168228692Sdes	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
10169141098Sdes	exit $EXIT_SUCCESS
10170348980Sdes      }
10171117610Sdes
10172348980Sdes      if test -n "$pic_flag" || test default != "$pic_mode"; then
10173117610Sdes	# Only do commands if we really have different PIC objects.
10174117610Sdes	reload_objs="$libobjs $reload_conv_objs"
10175348980Sdes	output=$libobj
10176228692Sdes	func_execute_cmds "$reload_cmds" 'exit $?'
10177117610Sdes      fi
10178117610Sdes
10179117610Sdes      if test -n "$gentop"; then
10180228692Sdes	func_show_eval '${RM}r "$gentop"'
10181117610Sdes      fi
10182117610Sdes
10183141098Sdes      exit $EXIT_SUCCESS
10184117610Sdes      ;;
10185117610Sdes
10186125647Sdes    prog)
10187125647Sdes      case $host in
10188228692Sdes	*cygwin*) func_stripname '' '.exe' "$output"
10189228692Sdes	          output=$func_stripname_result.exe;;
10190125647Sdes      esac
10191228692Sdes      test -n "$vinfo" && \
10192348980Sdes	func_warning "'-version-info' is ignored for programs"
10193117610Sdes
10194228692Sdes      test -n "$release" && \
10195348980Sdes	func_warning "'-release' is ignored for programs"
10196117610Sdes
10197348980Sdes      $preload \
10198348980Sdes	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
10199348980Sdes	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
10200125647Sdes
10201125647Sdes      case $host in
10202125647Sdes      *-*-rhapsody* | *-*-darwin1.[012])
10203125647Sdes	# On Rhapsody replace the C library is the System framework
10204228692Sdes	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
10205228692Sdes	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
10206125647Sdes	;;
10207125647Sdes      esac
10208125647Sdes
10209141098Sdes      case $host in
10210228692Sdes      *-*-darwin*)
10211228692Sdes	# Don't allow lazy linking, it breaks C++ global constructors
10212228692Sdes	# But is supposedly fixed on 10.4 or later (yay!).
10213348980Sdes	if test CXX = "$tagname"; then
10214228692Sdes	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10215228692Sdes	    10.[0123])
10216348980Sdes	      func_append compile_command " $wl-bind_at_load"
10217348980Sdes	      func_append finalize_command " $wl-bind_at_load"
10218228692Sdes	    ;;
10219228692Sdes	  esac
10220228692Sdes	fi
10221228692Sdes	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
10222228692Sdes	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10223228692Sdes	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10224228692Sdes	;;
10225141098Sdes      esac
10226141098Sdes
10227174832Sdes
10228174832Sdes      # move library search paths that coincide with paths to not yet
10229174832Sdes      # installed libraries to the beginning of the library search list
10230174832Sdes      new_libs=
10231174832Sdes      for path in $notinst_path; do
10232174832Sdes	case " $new_libs " in
10233174832Sdes	*" -L$path/$objdir "*) ;;
10234174832Sdes	*)
10235174832Sdes	  case " $compile_deplibs " in
10236174832Sdes	  *" -L$path/$objdir "*)
10237228692Sdes	    func_append new_libs " -L$path/$objdir" ;;
10238174832Sdes	  esac
10239174832Sdes	  ;;
10240174832Sdes	esac
10241174832Sdes      done
10242174832Sdes      for deplib in $compile_deplibs; do
10243174832Sdes	case $deplib in
10244174832Sdes	-L*)
10245174832Sdes	  case " $new_libs " in
10246174832Sdes	  *" $deplib "*) ;;
10247228692Sdes	  *) func_append new_libs " $deplib" ;;
10248174832Sdes	  esac
10249174832Sdes	  ;;
10250228692Sdes	*) func_append new_libs " $deplib" ;;
10251174832Sdes	esac
10252174832Sdes      done
10253348980Sdes      compile_deplibs=$new_libs
10254174832Sdes
10255174832Sdes
10256228692Sdes      func_append compile_command " $compile_deplibs"
10257228692Sdes      func_append finalize_command " $finalize_deplibs"
10258125647Sdes
10259117610Sdes      if test -n "$rpath$xrpath"; then
10260117610Sdes	# If the user specified any rpath flags, then add them.
10261117610Sdes	for libdir in $rpath $xrpath; do
10262117610Sdes	  # This is the magic to use -rpath.
10263117610Sdes	  case "$finalize_rpath " in
10264117610Sdes	  *" $libdir "*) ;;
10265228692Sdes	  *) func_append finalize_rpath " $libdir" ;;
10266117610Sdes	  esac
10267117610Sdes	done
10268117610Sdes      fi
10269117610Sdes
10270117610Sdes      # Now hardcode the library paths
10271117610Sdes      rpath=
10272117610Sdes      hardcode_libdirs=
10273117610Sdes      for libdir in $compile_rpath $finalize_rpath; do
10274117610Sdes	if test -n "$hardcode_libdir_flag_spec"; then
10275117610Sdes	  if test -n "$hardcode_libdir_separator"; then
10276117610Sdes	    if test -z "$hardcode_libdirs"; then
10277348980Sdes	      hardcode_libdirs=$libdir
10278117610Sdes	    else
10279117610Sdes	      # Just accumulate the unique libdirs.
10280125647Sdes	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10281117610Sdes	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10282117610Sdes		;;
10283117610Sdes	      *)
10284228692Sdes		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10285117610Sdes		;;
10286117610Sdes	      esac
10287117610Sdes	    fi
10288117610Sdes	  else
10289117610Sdes	    eval flag=\"$hardcode_libdir_flag_spec\"
10290228692Sdes	    func_append rpath " $flag"
10291117610Sdes	  fi
10292117610Sdes	elif test -n "$runpath_var"; then
10293117610Sdes	  case "$perm_rpath " in
10294117610Sdes	  *" $libdir "*) ;;
10295228692Sdes	  *) func_append perm_rpath " $libdir" ;;
10296117610Sdes	  esac
10297117610Sdes	fi
10298125647Sdes	case $host in
10299228692Sdes	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
10300348980Sdes	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
10301125647Sdes	  case :$dllsearchpath: in
10302125647Sdes	  *":$libdir:"*) ;;
10303228692Sdes	  ::) dllsearchpath=$libdir;;
10304228692Sdes	  *) func_append dllsearchpath ":$libdir";;
10305125647Sdes	  esac
10306174832Sdes	  case :$dllsearchpath: in
10307174832Sdes	  *":$testbindir:"*) ;;
10308228692Sdes	  ::) dllsearchpath=$testbindir;;
10309228692Sdes	  *) func_append dllsearchpath ":$testbindir";;
10310174832Sdes	  esac
10311125647Sdes	  ;;
10312125647Sdes	esac
10313117610Sdes      done
10314117610Sdes      # Substitute the hardcoded libdirs into the rpath.
10315117610Sdes      if test -n "$hardcode_libdir_separator" &&
10316117610Sdes	 test -n "$hardcode_libdirs"; then
10317348980Sdes	libdir=$hardcode_libdirs
10318117610Sdes	eval rpath=\" $hardcode_libdir_flag_spec\"
10319117610Sdes      fi
10320348980Sdes      compile_rpath=$rpath
10321117610Sdes
10322117610Sdes      rpath=
10323117610Sdes      hardcode_libdirs=
10324117610Sdes      for libdir in $finalize_rpath; do
10325117610Sdes	if test -n "$hardcode_libdir_flag_spec"; then
10326117610Sdes	  if test -n "$hardcode_libdir_separator"; then
10327117610Sdes	    if test -z "$hardcode_libdirs"; then
10328348980Sdes	      hardcode_libdirs=$libdir
10329117610Sdes	    else
10330117610Sdes	      # Just accumulate the unique libdirs.
10331125647Sdes	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10332117610Sdes	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10333117610Sdes		;;
10334117610Sdes	      *)
10335228692Sdes		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10336117610Sdes		;;
10337117610Sdes	      esac
10338117610Sdes	    fi
10339117610Sdes	  else
10340117610Sdes	    eval flag=\"$hardcode_libdir_flag_spec\"
10341228692Sdes	    func_append rpath " $flag"
10342117610Sdes	  fi
10343117610Sdes	elif test -n "$runpath_var"; then
10344117610Sdes	  case "$finalize_perm_rpath " in
10345117610Sdes	  *" $libdir "*) ;;
10346228692Sdes	  *) func_append finalize_perm_rpath " $libdir" ;;
10347117610Sdes	  esac
10348117610Sdes	fi
10349117610Sdes      done
10350117610Sdes      # Substitute the hardcoded libdirs into the rpath.
10351117610Sdes      if test -n "$hardcode_libdir_separator" &&
10352117610Sdes	 test -n "$hardcode_libdirs"; then
10353348980Sdes	libdir=$hardcode_libdirs
10354117610Sdes	eval rpath=\" $hardcode_libdir_flag_spec\"
10355117610Sdes      fi
10356348980Sdes      finalize_rpath=$rpath
10357117610Sdes
10358348980Sdes      if test -n "$libobjs" && test yes = "$build_old_libs"; then
10359117610Sdes	# Transform all the library objects into standard objects.
10360228692Sdes	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10361228692Sdes	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10362117610Sdes      fi
10363117610Sdes
10364348980Sdes      func_generate_dlsyms "$outputname" "@PROGRAM@" false
10365117610Sdes
10366228692Sdes      # template prelinking step
10367228692Sdes      if test -n "$prelink_cmds"; then
10368228692Sdes	func_execute_cmds "$prelink_cmds" 'exit $?'
10369117610Sdes      fi
10370117610Sdes
10371348980Sdes      wrappers_required=:
10372228692Sdes      case $host in
10373228692Sdes      *cegcc* | *mingw32ce*)
10374228692Sdes        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
10375348980Sdes        wrappers_required=false
10376228692Sdes        ;;
10377228692Sdes      *cygwin* | *mingw* )
10378348980Sdes        test yes = "$build_libtool_libs" || wrappers_required=false
10379228692Sdes        ;;
10380228692Sdes      *)
10381348980Sdes        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
10382348980Sdes          wrappers_required=false
10383228692Sdes        fi
10384228692Sdes        ;;
10385228692Sdes      esac
10386348980Sdes      $wrappers_required || {
10387117610Sdes	# Replace the output file specification.
10388228692Sdes	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10389348980Sdes	link_command=$compile_command$compile_rpath
10390117610Sdes
10391117610Sdes	# We have no uninstalled library dependencies, so finalize right now.
10392228692Sdes	exit_status=0
10393228692Sdes	func_show_eval "$link_command" 'exit_status=$?'
10394125647Sdes
10395228692Sdes	if test -n "$postlink_cmds"; then
10396228692Sdes	  func_to_tool_file "$output"
10397228692Sdes	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10398228692Sdes	  func_execute_cmds "$postlink_cmds" 'exit $?'
10399228692Sdes	fi
10400228692Sdes
10401117610Sdes	# Delete the generated files.
10402348980Sdes	if test -f "$output_objdir/${outputname}S.$objext"; then
10403348980Sdes	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
10404117610Sdes	fi
10405117610Sdes
10406174832Sdes	exit $exit_status
10407348980Sdes      }
10408117610Sdes
10409117610Sdes      if test -n "$compile_shlibpath$finalize_shlibpath"; then
10410117610Sdes	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
10411117610Sdes      fi
10412117610Sdes      if test -n "$finalize_shlibpath"; then
10413117610Sdes	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
10414117610Sdes      fi
10415117610Sdes
10416117610Sdes      compile_var=
10417117610Sdes      finalize_var=
10418117610Sdes      if test -n "$runpath_var"; then
10419117610Sdes	if test -n "$perm_rpath"; then
10420117610Sdes	  # We should set the runpath_var.
10421117610Sdes	  rpath=
10422117610Sdes	  for dir in $perm_rpath; do
10423228692Sdes	    func_append rpath "$dir:"
10424117610Sdes	  done
10425117610Sdes	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10426117610Sdes	fi
10427117610Sdes	if test -n "$finalize_perm_rpath"; then
10428117610Sdes	  # We should set the runpath_var.
10429117610Sdes	  rpath=
10430117610Sdes	  for dir in $finalize_perm_rpath; do
10431228692Sdes	    func_append rpath "$dir:"
10432117610Sdes	  done
10433117610Sdes	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
10434117610Sdes	fi
10435117610Sdes      fi
10436117610Sdes
10437348980Sdes      if test yes = "$no_install"; then
10438125647Sdes	# We don't need to create a wrapper script.
10439348980Sdes	link_command=$compile_var$compile_command$compile_rpath
10440125647Sdes	# Replace the output file specification.
10441228692Sdes	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10442125647Sdes	# Delete the old output file.
10443228692Sdes	$opt_dry_run || $RM $output
10444125647Sdes	# Link the executable and exit
10445228692Sdes	func_show_eval "$link_command" 'exit $?'
10446228692Sdes
10447228692Sdes	if test -n "$postlink_cmds"; then
10448228692Sdes	  func_to_tool_file "$output"
10449228692Sdes	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10450228692Sdes	  func_execute_cmds "$postlink_cmds" 'exit $?'
10451228692Sdes	fi
10452228692Sdes
10453141098Sdes	exit $EXIT_SUCCESS
10454125647Sdes      fi
10455125647Sdes
10456348980Sdes      case $hardcode_action,$fast_install in
10457348980Sdes        relink,*)
10458348980Sdes	  # Fast installation is not supported
10459348980Sdes	  link_command=$compile_var$compile_command$compile_rpath
10460348980Sdes	  relink_command=$finalize_var$finalize_command$finalize_rpath
10461125647Sdes
10462348980Sdes	  func_warning "this platform does not like uninstalled shared libraries"
10463348980Sdes	  func_warning "'$output' will be relinked during installation"
10464348980Sdes	  ;;
10465348980Sdes        *,yes)
10466348980Sdes	  link_command=$finalize_var$compile_command$finalize_rpath
10467348980Sdes	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
10468348980Sdes          ;;
10469348980Sdes	*,no)
10470348980Sdes	  link_command=$compile_var$compile_command$compile_rpath
10471348980Sdes	  relink_command=$finalize_var$finalize_command$finalize_rpath
10472348980Sdes          ;;
10473348980Sdes	*,needless)
10474348980Sdes	  link_command=$finalize_var$compile_command$finalize_rpath
10475348980Sdes	  relink_command=
10476348980Sdes          ;;
10477348980Sdes      esac
10478117610Sdes
10479117610Sdes      # Replace the output file specification.
10480228692Sdes      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10481125647Sdes
10482117610Sdes      # Delete the old output files.
10483228692Sdes      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10484117610Sdes
10485228692Sdes      func_show_eval "$link_command" 'exit $?'
10486117610Sdes
10487228692Sdes      if test -n "$postlink_cmds"; then
10488228692Sdes	func_to_tool_file "$output_objdir/$outputname"
10489228692Sdes	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'`
10490228692Sdes	func_execute_cmds "$postlink_cmds" 'exit $?'
10491228692Sdes      fi
10492228692Sdes
10493117610Sdes      # Now create the wrapper script.
10494228692Sdes      func_verbose "creating $output"
10495117610Sdes
10496117610Sdes      # Quote the relink command for shipping.
10497117610Sdes      if test -n "$relink_command"; then
10498125647Sdes	# Preserve any variables that may affect compiler behavior
10499125647Sdes	for var in $variables_saved_for_relink; do
10500125647Sdes	  if eval test -z \"\${$var+set}\"; then
10501228692Sdes	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10502125647Sdes	  elif eval var_value=\$$var; test -z "$var_value"; then
10503125647Sdes	    relink_command="$var=; export $var; $relink_command"
10504125647Sdes	  else
10505228692Sdes	    func_quote_for_eval "$var_value"
10506228692Sdes	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10507125647Sdes	  fi
10508125647Sdes	done
10509125647Sdes	relink_command="(cd `pwd`; $relink_command)"
10510228692Sdes	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10511117610Sdes      fi
10512117610Sdes
10513228692Sdes      # Only actually do things if not in dry run mode.
10514228692Sdes      $opt_dry_run || {
10515117610Sdes	# win32 will think the script is a binary if it has
10516117610Sdes	# a .exe suffix, so we strip it off here.
10517117610Sdes	case $output in
10518228692Sdes	  *.exe) func_stripname '' '.exe' "$output"
10519228692Sdes	         output=$func_stripname_result ;;
10520117610Sdes	esac
10521125647Sdes	# test for cygwin because mv fails w/o .exe extensions
10522125647Sdes	case $host in
10523141098Sdes	  *cygwin*)
10524141098Sdes	    exeext=.exe
10525228692Sdes	    func_stripname '' '.exe' "$outputname"
10526228692Sdes	    outputname=$func_stripname_result ;;
10527125647Sdes	  *) exeext= ;;
10528125647Sdes	esac
10529141098Sdes	case $host in
10530141098Sdes	  *cygwin* | *mingw* )
10531228692Sdes	    func_dirname_and_basename "$output" "" "."
10532228692Sdes	    output_name=$func_basename_result
10533228692Sdes	    output_path=$func_dirname_result
10534348980Sdes	    cwrappersource=$output_path/$objdir/lt-$output_name.c
10535348980Sdes	    cwrapper=$output_path/$output_name.exe
10536228692Sdes	    $RM $cwrappersource $cwrapper
10537228692Sdes	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
10538141098Sdes
10539228692Sdes	    func_emit_cwrapperexe_src > $cwrappersource
10540141098Sdes
10541228692Sdes	    # The wrapper executable is built using the $host compiler,
10542228692Sdes	    # because it contains $host paths and files. If cross-
10543228692Sdes	    # compiling, it, like the target executable, must be
10544228692Sdes	    # executed on the $host or under an emulation environment.
10545228692Sdes	    $opt_dry_run || {
10546228692Sdes	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
10547228692Sdes	      $STRIP $cwrapper
10548228692Sdes	    }
10549141098Sdes
10550228692Sdes	    # Now, create the wrapper script for func_source use:
10551228692Sdes	    func_ltwrapper_scriptname $cwrapper
10552228692Sdes	    $RM $func_ltwrapper_scriptname_result
10553228692Sdes	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
10554228692Sdes	    $opt_dry_run || {
10555228692Sdes	      # note: this script will not be executed, so do not chmod.
10556348980Sdes	      if test "x$build" = "x$host"; then
10557228692Sdes		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10558228692Sdes	      else
10559228692Sdes		func_emit_wrapper no > $func_ltwrapper_scriptname_result
10560228692Sdes	      fi
10561228692Sdes	    }
10562117610Sdes	  ;;
10563228692Sdes	  * )
10564228692Sdes	    $RM $output
10565228692Sdes	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10566117610Sdes
10567228692Sdes	    func_emit_wrapper no > $output
10568228692Sdes	    chmod +x $output
10569117610Sdes	  ;;
10570117610Sdes	esac
10571228692Sdes      }
10572141098Sdes      exit $EXIT_SUCCESS
10573117610Sdes      ;;
10574117610Sdes    esac
10575117610Sdes
10576117610Sdes    # See if we need to build an old-fashioned archive.
10577117610Sdes    for oldlib in $oldlibs; do
10578117610Sdes
10579348980Sdes      case $build_libtool_libs in
10580348980Sdes        convenience)
10581348980Sdes	  oldobjs="$libobjs_save $symfileobj"
10582348980Sdes	  addlibs=$convenience
10583117610Sdes	  build_libtool_libs=no
10584348980Sdes	  ;;
10585348980Sdes	module)
10586348980Sdes	  oldobjs=$libobjs_save
10587348980Sdes	  addlibs=$old_convenience
10588348980Sdes	  build_libtool_libs=no
10589348980Sdes          ;;
10590348980Sdes	*)
10591141098Sdes	  oldobjs="$old_deplibs $non_pic_objects"
10592348980Sdes	  $preload && test -f "$symfileobj" \
10593348980Sdes	    && func_append oldobjs " $symfileobj"
10594348980Sdes	  addlibs=$old_convenience
10595348980Sdes	  ;;
10596348980Sdes      esac
10597117610Sdes
10598117610Sdes      if test -n "$addlibs"; then
10599348980Sdes	gentop=$output_objdir/${outputname}x
10600228692Sdes	func_append generated " $gentop"
10601125647Sdes
10602141098Sdes	func_extract_archives $gentop $addlibs
10603228692Sdes	func_append oldobjs " $func_extract_archives_result"
10604117610Sdes      fi
10605117610Sdes
10606117610Sdes      # Do each command in the archive commands.
10607348980Sdes      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
10608228692Sdes	cmds=$old_archive_from_new_cmds
10609117610Sdes      else
10610228692Sdes
10611228692Sdes	# Add any objects from preloaded convenience libraries
10612228692Sdes	if test -n "$dlprefiles"; then
10613348980Sdes	  gentop=$output_objdir/${outputname}x
10614228692Sdes	  func_append generated " $gentop"
10615228692Sdes
10616228692Sdes	  func_extract_archives $gentop $dlprefiles
10617228692Sdes	  func_append oldobjs " $func_extract_archives_result"
10618228692Sdes	fi
10619228692Sdes
10620174832Sdes	# POSIX demands no paths to be encoded in archives.  We have
10621174832Sdes	# to avoid creating archives with duplicate basenames if we
10622174832Sdes	# might have to extract them afterwards, e.g., when creating a
10623174832Sdes	# static archive out of a convenience library, or when linking
10624174832Sdes	# the entirety of a libtool archive into another (currently
10625174832Sdes	# not supported by libtool).
10626174832Sdes	if (for obj in $oldobjs
10627174832Sdes	    do
10628228692Sdes	      func_basename "$obj"
10629228692Sdes	      $ECHO "$func_basename_result"
10630174832Sdes	    done | sort | sort -uc >/dev/null 2>&1); then
10631174832Sdes	  :
10632174832Sdes	else
10633228692Sdes	  echo "copying selected object files to avoid basename conflicts..."
10634348980Sdes	  gentop=$output_objdir/${outputname}x
10635228692Sdes	  func_append generated " $gentop"
10636228692Sdes	  func_mkdir_p "$gentop"
10637174832Sdes	  save_oldobjs=$oldobjs
10638174832Sdes	  oldobjs=
10639174832Sdes	  counter=1
10640174832Sdes	  for obj in $save_oldobjs
10641174832Sdes	  do
10642228692Sdes	    func_basename "$obj"
10643348980Sdes	    objbase=$func_basename_result
10644174832Sdes	    case " $oldobjs " in
10645174832Sdes	    " ") oldobjs=$obj ;;
10646174832Sdes	    *[\ /]"$objbase "*)
10647174832Sdes	      while :; do
10648174832Sdes		# Make sure we don't pick an alternate name that also
10649174832Sdes		# overlaps.
10650174832Sdes		newobj=lt$counter-$objbase
10651228692Sdes		func_arith $counter + 1
10652228692Sdes		counter=$func_arith_result
10653174832Sdes		case " $oldobjs " in
10654174832Sdes		*[\ /]"$newobj "*) ;;
10655174832Sdes		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
10656174832Sdes		esac
10657174832Sdes	      done
10658228692Sdes	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10659228692Sdes	      func_append oldobjs " $gentop/$newobj"
10660174832Sdes	      ;;
10661228692Sdes	    *) func_append oldobjs " $obj" ;;
10662174832Sdes	    esac
10663174832Sdes	  done
10664174832Sdes	fi
10665236109Sdes	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10666236109Sdes	tool_oldlib=$func_to_tool_file_result
10667141098Sdes	eval cmds=\"$old_archive_cmds\"
10668141098Sdes
10669228692Sdes	func_len " $cmds"
10670228692Sdes	len=$func_len_result
10671228692Sdes	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10672141098Sdes	  cmds=$old_archive_cmds
10673228692Sdes	elif test -n "$archiver_list_spec"; then
10674228692Sdes	  func_verbose "using command file archive linking..."
10675228692Sdes	  for obj in $oldobjs
10676228692Sdes	  do
10677228692Sdes	    func_to_tool_file "$obj"
10678228692Sdes	    $ECHO "$func_to_tool_file_result"
10679228692Sdes	  done > $output_objdir/$libname.libcmd
10680228692Sdes	  func_to_tool_file "$output_objdir/$libname.libcmd"
10681228692Sdes	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10682228692Sdes	  cmds=$old_archive_cmds
10683141098Sdes	else
10684141098Sdes	  # the command line is too long to link in one step, link in parts
10685228692Sdes	  func_verbose "using piecewise archive linking..."
10686141098Sdes	  save_RANLIB=$RANLIB
10687141098Sdes	  RANLIB=:
10688141098Sdes	  objlist=
10689141098Sdes	  concat_cmds=
10690141098Sdes	  save_oldobjs=$oldobjs
10691228692Sdes	  oldobjs=
10692141098Sdes	  # Is there a better way of finding the last object in the list?
10693141098Sdes	  for obj in $save_oldobjs
10694141098Sdes	  do
10695141098Sdes	    last_oldobj=$obj
10696141098Sdes	  done
10697228692Sdes	  eval test_cmds=\"$old_archive_cmds\"
10698228692Sdes	  func_len " $test_cmds"
10699228692Sdes	  len0=$func_len_result
10700228692Sdes	  len=$len0
10701141098Sdes	  for obj in $save_oldobjs
10702141098Sdes	  do
10703228692Sdes	    func_len " $obj"
10704228692Sdes	    func_arith $len + $func_len_result
10705228692Sdes	    len=$func_arith_result
10706228692Sdes	    func_append objlist " $obj"
10707228692Sdes	    if test "$len" -lt "$max_cmd_len"; then
10708141098Sdes	      :
10709117610Sdes	    else
10710141098Sdes	      # the above command should be used before it gets too long
10711141098Sdes	      oldobjs=$objlist
10712348980Sdes	      if test "$obj" = "$last_oldobj"; then
10713228692Sdes		RANLIB=$save_RANLIB
10714141098Sdes	      fi
10715141098Sdes	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10716348980Sdes	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
10717141098Sdes	      objlist=
10718228692Sdes	      len=$len0
10719117610Sdes	    fi
10720141098Sdes	  done
10721141098Sdes	  RANLIB=$save_RANLIB
10722141098Sdes	  oldobjs=$objlist
10723348980Sdes	  if test -z "$oldobjs"; then
10724141098Sdes	    eval cmds=\"\$concat_cmds\"
10725141098Sdes	  else
10726141098Sdes	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
10727117610Sdes	  fi
10728141098Sdes	fi
10729117610Sdes      fi
10730228692Sdes      func_execute_cmds "$cmds" 'exit $?'
10731117610Sdes    done
10732117610Sdes
10733228692Sdes    test -n "$generated" && \
10734228692Sdes      func_show_eval "${RM}r$generated"
10735117610Sdes
10736117610Sdes    # Now create the libtool archive.
10737125647Sdes    case $output in
10738117610Sdes    *.la)
10739117610Sdes      old_library=
10740348980Sdes      test yes = "$build_old_libs" && old_library=$libname.$libext
10741228692Sdes      func_verbose "creating $output"
10742117610Sdes
10743125647Sdes      # Preserve any variables that may affect compiler behavior
10744125647Sdes      for var in $variables_saved_for_relink; do
10745125647Sdes	if eval test -z \"\${$var+set}\"; then
10746228692Sdes	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10747125647Sdes	elif eval var_value=\$$var; test -z "$var_value"; then
10748125647Sdes	  relink_command="$var=; export $var; $relink_command"
10749125647Sdes	else
10750228692Sdes	  func_quote_for_eval "$var_value"
10751228692Sdes	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10752125647Sdes	fi
10753125647Sdes      done
10754125647Sdes      # Quote the link command for shipping.
10755348980Sdes      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
10756228692Sdes      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10757348980Sdes      if test yes = "$hardcode_automatic"; then
10758141098Sdes	relink_command=
10759141098Sdes      fi
10760117610Sdes
10761117610Sdes      # Only create the output if not a dry run.
10762228692Sdes      $opt_dry_run || {
10763117610Sdes	for installed in no yes; do
10764348980Sdes	  if test yes = "$installed"; then
10765117610Sdes	    if test -z "$install_libdir"; then
10766117610Sdes	      break
10767117610Sdes	    fi
10768348980Sdes	    output=$output_objdir/${outputname}i
10769125647Sdes	    # Replace all uninstalled libtool libraries with the installed ones
10770125647Sdes	    newdependency_libs=
10771125647Sdes	    for deplib in $dependency_libs; do
10772125647Sdes	      case $deplib in
10773125647Sdes	      *.la)
10774228692Sdes		func_basename "$deplib"
10775348980Sdes		name=$func_basename_result
10776236109Sdes		func_resolve_sysroot "$deplib"
10777348980Sdes		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
10778228692Sdes		test -z "$libdir" && \
10779348980Sdes		  func_fatal_error "'$deplib' is not a valid libtool archive"
10780228692Sdes		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10781125647Sdes		;;
10782228692Sdes	      -L*)
10783228692Sdes		func_stripname -L '' "$deplib"
10784228692Sdes		func_replace_sysroot "$func_stripname_result"
10785228692Sdes		func_append newdependency_libs " -L$func_replace_sysroot_result"
10786228692Sdes		;;
10787228692Sdes	      -R*)
10788228692Sdes		func_stripname -R '' "$deplib"
10789228692Sdes		func_replace_sysroot "$func_stripname_result"
10790228692Sdes		func_append newdependency_libs " -R$func_replace_sysroot_result"
10791228692Sdes		;;
10792228692Sdes	      *) func_append newdependency_libs " $deplib" ;;
10793125647Sdes	      esac
10794125647Sdes	    done
10795348980Sdes	    dependency_libs=$newdependency_libs
10796125647Sdes	    newdlfiles=
10797228692Sdes
10798125647Sdes	    for lib in $dlfiles; do
10799228692Sdes	      case $lib in
10800228692Sdes	      *.la)
10801228692Sdes	        func_basename "$lib"
10802348980Sdes		name=$func_basename_result
10803348980Sdes		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10804228692Sdes		test -z "$libdir" && \
10805348980Sdes		  func_fatal_error "'$lib' is not a valid libtool archive"
10806228692Sdes		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
10807228692Sdes		;;
10808228692Sdes	      *) func_append newdlfiles " $lib" ;;
10809228692Sdes	      esac
10810125647Sdes	    done
10811348980Sdes	    dlfiles=$newdlfiles
10812125647Sdes	    newdlprefiles=
10813125647Sdes	    for lib in $dlprefiles; do
10814228692Sdes	      case $lib in
10815228692Sdes	      *.la)
10816228692Sdes		# Only pass preopened files to the pseudo-archive (for
10817228692Sdes		# eventual linking with the app. that links it) if we
10818228692Sdes		# didn't already link the preopened objects directly into
10819228692Sdes		# the library:
10820228692Sdes		func_basename "$lib"
10821348980Sdes		name=$func_basename_result
10822348980Sdes		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10823228692Sdes		test -z "$libdir" && \
10824348980Sdes		  func_fatal_error "'$lib' is not a valid libtool archive"
10825228692Sdes		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
10826228692Sdes		;;
10827228692Sdes	      esac
10828125647Sdes	    done
10829348980Sdes	    dlprefiles=$newdlprefiles
10830141098Sdes	  else
10831141098Sdes	    newdlfiles=
10832141098Sdes	    for lib in $dlfiles; do
10833141098Sdes	      case $lib in
10834348980Sdes		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10835141098Sdes		*) abs=`pwd`"/$lib" ;;
10836141098Sdes	      esac
10837228692Sdes	      func_append newdlfiles " $abs"
10838141098Sdes	    done
10839348980Sdes	    dlfiles=$newdlfiles
10840141098Sdes	    newdlprefiles=
10841141098Sdes	    for lib in $dlprefiles; do
10842141098Sdes	      case $lib in
10843348980Sdes		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10844141098Sdes		*) abs=`pwd`"/$lib" ;;
10845141098Sdes	      esac
10846228692Sdes	      func_append newdlprefiles " $abs"
10847141098Sdes	    done
10848348980Sdes	    dlprefiles=$newdlprefiles
10849117610Sdes	  fi
10850228692Sdes	  $RM $output
10851125647Sdes	  # place dlname in correct position for cygwin
10852228692Sdes	  # In fact, it would be nice if we could use this code for all target
10853228692Sdes	  # systems that can't hard-code library paths into their executables
10854228692Sdes	  # and that have no shared library path variable independent of PATH,
10855228692Sdes	  # but it turns out we can't easily determine that from inspecting
10856228692Sdes	  # libtool variables, so we have to hard-code the OSs to which it
10857228692Sdes	  # applies here; at the moment, that means platforms that use the PE
10858228692Sdes	  # object format with DLL files.  See the long comment at the top of
10859228692Sdes	  # tests/bindir.at for full details.
10860125647Sdes	  tdlname=$dlname
10861125647Sdes	  case $host,$output,$installed,$module,$dlname in
10862228692Sdes	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10863228692Sdes	      # If a -bindir argument was supplied, place the dll there.
10864348980Sdes	      if test -n "$bindir"; then
10865228692Sdes		func_relative_path "$install_libdir" "$bindir"
10866348980Sdes		tdlname=$func_relative_path_result/$dlname
10867228692Sdes	      else
10868228692Sdes		# Otherwise fall back on heuristic.
10869228692Sdes		tdlname=../bin/$dlname
10870228692Sdes	      fi
10871228692Sdes	      ;;
10872125647Sdes	  esac
10873228692Sdes	  $ECHO > $output "\
10874117610Sdes# $outputname - a libtool library file
10875348980Sdes# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
10876117610Sdes#
10877117610Sdes# Please DO NOT delete this file!
10878117610Sdes# It is necessary for linking the library.
10879117610Sdes
10880117610Sdes# The name that we can dlopen(3).
10881125647Sdesdlname='$tdlname'
10882117610Sdes
10883117610Sdes# Names of this library.
10884117610Sdeslibrary_names='$library_names'
10885117610Sdes
10886117610Sdes# The name of the static archive.
10887117610Sdesold_library='$old_library'
10888117610Sdes
10889348980Sdes# Linker flags that cannot go in dependency_libs.
10890228692Sdesinherited_linker_flags='$new_inherited_linker_flags'
10891228692Sdes
10892117610Sdes# Libraries that this one depends upon.
10893117610Sdesdependency_libs='$dependency_libs'
10894117610Sdes
10895228692Sdes# Names of additional weak libraries provided by this library
10896228692Sdesweak_library_names='$weak_libs'
10897228692Sdes
10898117610Sdes# Version information for $libname.
10899117610Sdescurrent=$current
10900117610Sdesage=$age
10901117610Sdesrevision=$revision
10902117610Sdes
10903117610Sdes# Is this an already installed library?
10904117610Sdesinstalled=$installed
10905117610Sdes
10906141098Sdes# Should we warn about portability when linking against -modules?
10907141098Sdesshouldnotlink=$module
10908141098Sdes
10909125647Sdes# Files to dlopen/dlpreopen
10910125647Sdesdlopen='$dlfiles'
10911125647Sdesdlpreopen='$dlprefiles'
10912125647Sdes
10913117610Sdes# Directory that this library needs to be installed in:
10914125647Sdeslibdir='$install_libdir'"
10915348980Sdes	  if test no,yes = "$installed,$need_relink"; then
10916228692Sdes	    $ECHO >> $output "\
10917125647Sdesrelink_command=\"$relink_command\""
10918125647Sdes	  fi
10919117610Sdes	done
10920228692Sdes      }
10921117610Sdes
10922117610Sdes      # Do a symbolic link so that the libtool archive can be found in
10923117610Sdes      # LD_LIBRARY_PATH before the program is installed.
10924228692Sdes      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
10925117610Sdes      ;;
10926117610Sdes    esac
10927141098Sdes    exit $EXIT_SUCCESS
10928228692Sdes}
10929117610Sdes
10930348980Sdesif test link = "$opt_mode" || test relink = "$opt_mode"; then
10931348980Sdes  func_mode_link ${1+"$@"}
10932348980Sdesfi
10933117610Sdes
10934117610Sdes
10935228692Sdes# func_mode_uninstall arg...
10936228692Sdesfunc_mode_uninstall ()
10937228692Sdes{
10938348980Sdes    $debug_cmd
10939348980Sdes
10940348980Sdes    RM=$nonopt
10941117610Sdes    files=
10942348980Sdes    rmforce=false
10943125647Sdes    exit_status=0
10944117610Sdes
10945125647Sdes    # This variable tells wrapper scripts just to set variables rather
10946125647Sdes    # than running their programs.
10947348980Sdes    libtool_install_magic=$magic
10948125647Sdes
10949117610Sdes    for arg
10950117610Sdes    do
10951125647Sdes      case $arg in
10952348980Sdes      -f) func_append RM " $arg"; rmforce=: ;;
10953228692Sdes      -*) func_append RM " $arg" ;;
10954228692Sdes      *) func_append files " $arg" ;;
10955117610Sdes      esac
10956117610Sdes    done
10957117610Sdes
10958228692Sdes    test -z "$RM" && \
10959228692Sdes      func_fatal_help "you must specify an RM program"
10960117610Sdes
10961125647Sdes    rmdirs=
10962125647Sdes
10963117610Sdes    for file in $files; do
10964228692Sdes      func_dirname "$file" "" "."
10965348980Sdes      dir=$func_dirname_result
10966348980Sdes      if test . = "$dir"; then
10967348980Sdes	odir=$objdir
10968125647Sdes      else
10969348980Sdes	odir=$dir/$objdir
10970125647Sdes      fi
10971228692Sdes      func_basename "$file"
10972348980Sdes      name=$func_basename_result
10973348980Sdes      test uninstall = "$opt_mode" && odir=$dir
10974117610Sdes
10975228692Sdes      # Remember odir for removal later, being careful to avoid duplicates
10976348980Sdes      if test clean = "$opt_mode"; then
10977125647Sdes	case " $rmdirs " in
10978228692Sdes	  *" $odir "*) ;;
10979228692Sdes	  *) func_append rmdirs " $odir" ;;
10980125647Sdes	esac
10981125647Sdes      fi
10982125647Sdes
10983125647Sdes      # Don't error if the file doesn't exist and rm -f was used.
10984228692Sdes      if { test -L "$file"; } >/dev/null 2>&1 ||
10985228692Sdes	 { test -h "$file"; } >/dev/null 2>&1 ||
10986228692Sdes	 test -f "$file"; then
10987125647Sdes	:
10988125647Sdes      elif test -d "$file"; then
10989125647Sdes	exit_status=1
10990125647Sdes	continue
10991348980Sdes      elif $rmforce; then
10992125647Sdes	continue
10993125647Sdes      fi
10994125647Sdes
10995348980Sdes      rmfiles=$file
10996117610Sdes
10997125647Sdes      case $name in
10998117610Sdes      *.la)
10999117610Sdes	# Possibly a libtool archive, so verify it.
11000228692Sdes	if func_lalib_p "$file"; then
11001228692Sdes	  func_source $dir/$name
11002117610Sdes
11003117610Sdes	  # Delete the libtool libraries and symlinks.
11004117610Sdes	  for n in $library_names; do
11005228692Sdes	    func_append rmfiles " $odir/$n"
11006117610Sdes	  done
11007228692Sdes	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
11008117610Sdes
11009348980Sdes	  case $opt_mode in
11010174832Sdes	  clean)
11011228692Sdes	    case " $library_names " in
11012174832Sdes	    *" $dlname "*) ;;
11013228692Sdes	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
11014174832Sdes	    esac
11015228692Sdes	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
11016174832Sdes	    ;;
11017174832Sdes	  uninstall)
11018125647Sdes	    if test -n "$library_names"; then
11019125647Sdes	      # Do each command in the postuninstall commands.
11020348980Sdes	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
11021125647Sdes	    fi
11022117610Sdes
11023125647Sdes	    if test -n "$old_library"; then
11024125647Sdes	      # Do each command in the old_postuninstall commands.
11025348980Sdes	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
11026125647Sdes	    fi
11027125647Sdes	    # FIXME: should reinstall the best remaining shared library.
11028174832Sdes	    ;;
11029174832Sdes	  esac
11030117610Sdes	fi
11031117610Sdes	;;
11032117610Sdes
11033117610Sdes      *.lo)
11034141098Sdes	# Possibly a libtool object, so verify it.
11035228692Sdes	if func_lalib_p "$file"; then
11036141098Sdes
11037141098Sdes	  # Read the .lo file
11038228692Sdes	  func_source $dir/$name
11039141098Sdes
11040141098Sdes	  # Add PIC object to the list of files to remove.
11041348980Sdes	  if test -n "$pic_object" && test none != "$pic_object"; then
11042228692Sdes	    func_append rmfiles " $dir/$pic_object"
11043141098Sdes	  fi
11044141098Sdes
11045141098Sdes	  # Add non-PIC object to the list of files to remove.
11046348980Sdes	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11047228692Sdes	    func_append rmfiles " $dir/$non_pic_object"
11048141098Sdes	  fi
11049117610Sdes	fi
11050117610Sdes	;;
11051117610Sdes
11052117610Sdes      *)
11053348980Sdes	if test clean = "$opt_mode"; then
11054141098Sdes	  noexename=$name
11055141098Sdes	  case $file in
11056141098Sdes	  *.exe)
11057228692Sdes	    func_stripname '' '.exe' "$file"
11058228692Sdes	    file=$func_stripname_result
11059228692Sdes	    func_stripname '' '.exe' "$name"
11060228692Sdes	    noexename=$func_stripname_result
11061141098Sdes	    # $file with .exe has already been added to rmfiles,
11062141098Sdes	    # add $file without .exe
11063228692Sdes	    func_append rmfiles " $file"
11064141098Sdes	    ;;
11065141098Sdes	  esac
11066141098Sdes	  # Do a test to see if this is a libtool program.
11067228692Sdes	  if func_ltwrapper_p "$file"; then
11068228692Sdes	    if func_ltwrapper_executable_p "$file"; then
11069228692Sdes	      func_ltwrapper_scriptname "$file"
11070228692Sdes	      relink_command=
11071228692Sdes	      func_source $func_ltwrapper_scriptname_result
11072228692Sdes	      func_append rmfiles " $func_ltwrapper_scriptname_result"
11073228692Sdes	    else
11074228692Sdes	      relink_command=
11075228692Sdes	      func_source $dir/$noexename
11076228692Sdes	    fi
11077125647Sdes
11078141098Sdes	    # note $name still contains .exe if it was in $file originally
11079141098Sdes	    # as does the version of $file that was added into $rmfiles
11080348980Sdes	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
11081348980Sdes	    if test yes = "$fast_install" && test -n "$relink_command"; then
11082228692Sdes	      func_append rmfiles " $odir/lt-$name"
11083141098Sdes	    fi
11084348980Sdes	    if test "X$noexename" != "X$name"; then
11085348980Sdes	      func_append rmfiles " $odir/lt-$noexename.c"
11086141098Sdes	    fi
11087125647Sdes	  fi
11088125647Sdes	fi
11089117610Sdes	;;
11090117610Sdes      esac
11091228692Sdes      func_show_eval "$RM $rmfiles" 'exit_status=1'
11092117610Sdes    done
11093125647Sdes
11094348980Sdes    # Try to remove the $objdir's in the directories where we deleted files
11095125647Sdes    for dir in $rmdirs; do
11096125647Sdes      if test -d "$dir"; then
11097228692Sdes	func_show_eval "rmdir $dir >/dev/null 2>&1"
11098125647Sdes      fi
11099125647Sdes    done
11100125647Sdes
11101125647Sdes    exit $exit_status
11102228692Sdes}
11103117610Sdes
11104348980Sdesif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
11105348980Sdes  func_mode_uninstall ${1+"$@"}
11106348980Sdesfi
11107117610Sdes
11108228692Sdestest -z "$opt_mode" && {
11109348980Sdes  help=$generic_help
11110228692Sdes  func_fatal_help "you must specify a MODE"
11111228692Sdes}
11112117610Sdes
11113228692Sdestest -z "$exec_cmd" && \
11114348980Sdes  func_fatal_help "invalid operation mode '$opt_mode'"
11115228692Sdes
11116125647Sdesif test -n "$exec_cmd"; then
11117228692Sdes  eval exec "$exec_cmd"
11118141098Sdes  exit $EXIT_FAILURE
11119125647Sdesfi
11120125647Sdes
11121228692Sdesexit $exit_status
11122117610Sdes
11123117610Sdes
11124141098Sdes# The TAGs below are defined such that we never get into a situation
11125348980Sdes# where we disable both kinds of libraries.  Given conflicting
11126141098Sdes# choices, we go for a static library, that is the most portable,
11127141098Sdes# since we can't tell whether shared libraries were disabled because
11128141098Sdes# the user asked for that or because the platform doesn't support
11129141098Sdes# them.  This is particularly important on AIX, because we don't
11130141098Sdes# support having both static and shared libraries enabled at the same
11131141098Sdes# time on that platform, so we default to a shared-only configuration.
11132141098Sdes# If a disable-shared tag is given, we'll fallback to a static-only
11133141098Sdes# configuration.  But we'll never go from static-only to shared-only.
11134141098Sdes
11135141098Sdes# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
11136228692Sdesbuild_libtool_libs=no
11137228692Sdesbuild_old_libs=yes
11138141098Sdes# ### END LIBTOOL TAG CONFIG: disable-shared
11139141098Sdes
11140141098Sdes# ### BEGIN LIBTOOL TAG CONFIG: disable-static
11141228692Sdesbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11142141098Sdes# ### END LIBTOOL TAG CONFIG: disable-static
11143141098Sdes
11144117610Sdes# Local Variables:
11145117610Sdes# mode:shell-script
11146117610Sdes# sh-indentation:2
11147117610Sdes# End:
11148