ltmain.sh revision 300bf1ae
1300bf1aeSmrg#! /bin/sh
2300bf1aeSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
3300bf1aeSmrg##               by inline-source v2014-01-03.01
46aec45a7Smrg
5300bf1aeSmrg# libtool (GNU libtool) 2.4.6
6300bf1aeSmrg# Provide generalized library-building support services.
76aec45a7Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
86aec45a7Smrg
9300bf1aeSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc.
106aec45a7Smrg# This is free software; see the source for copying conditions.  There is NO
116aec45a7Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
126aec45a7Smrg
136aec45a7Smrg# GNU Libtool is free software; you can redistribute it and/or modify
14ab47cfaaSmrg# it under the terms of the GNU General Public License as published by
15ab47cfaaSmrg# the Free Software Foundation; either version 2 of the License, or
16ab47cfaaSmrg# (at your option) any later version.
17ab47cfaaSmrg#
186aec45a7Smrg# As a special exception to the GNU General Public License,
196aec45a7Smrg# if you distribute this file as part of a program or library that
206aec45a7Smrg# is built using GNU Libtool, you may include this file under the
216aec45a7Smrg# same distribution terms that you use for the rest of that program.
226aec45a7Smrg#
236aec45a7Smrg# GNU Libtool is distributed in the hope that it will be useful, but
24ab47cfaaSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
25ab47cfaaSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26ab47cfaaSmrg# General Public License for more details.
27ab47cfaaSmrg#
28ab47cfaaSmrg# You should have received a copy of the GNU General Public License
29300bf1aeSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
305c42550eSmrg
31ab47cfaaSmrg
326aec45a7SmrgPROGRAM=libtool
33ab47cfaaSmrgPACKAGE=libtool
34300bf1aeSmrgVERSION=2.4.6
35300bf1aeSmrgpackage_revision=2.4.6
368697ee19Smrg
37300bf1aeSmrg
38300bf1aeSmrg## ------ ##
39300bf1aeSmrg## Usage. ##
40300bf1aeSmrg## ------ ##
41300bf1aeSmrg
42300bf1aeSmrg# Run './libtool --help' for help with using this script from the
43300bf1aeSmrg# command line.
44300bf1aeSmrg
45300bf1aeSmrg
46300bf1aeSmrg## ------------------------------- ##
47300bf1aeSmrg## User overridable command paths. ##
48300bf1aeSmrg## ------------------------------- ##
49300bf1aeSmrg
50300bf1aeSmrg# After configure completes, it has a better idea of some of the
51300bf1aeSmrg# shell tools we need than the defaults used by the functions shared
52300bf1aeSmrg# with bootstrap, so set those here where they can still be over-
53300bf1aeSmrg# ridden by the user, but otherwise take precedence.
54300bf1aeSmrg
55300bf1aeSmrg: ${AUTOCONF="autoconf"}
56300bf1aeSmrg: ${AUTOMAKE="automake"}
57300bf1aeSmrg
58300bf1aeSmrg
59300bf1aeSmrg## -------------------------- ##
60300bf1aeSmrg## Source external libraries. ##
61300bf1aeSmrg## -------------------------- ##
62300bf1aeSmrg
63300bf1aeSmrg# Much of our low-level functionality needs to be sourced from external
64300bf1aeSmrg# libraries, which are installed to $pkgauxdir.
65300bf1aeSmrg
66300bf1aeSmrg# Set a version string for this script.
67300bf1aeSmrgscriptversion=2015-01-20.17; # UTC
68300bf1aeSmrg
69300bf1aeSmrg# General shell script boiler plate, and helper functions.
70300bf1aeSmrg# Written by Gary V. Vaughan, 2004
71300bf1aeSmrg
72300bf1aeSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc.
73300bf1aeSmrg# This is free software; see the source for copying conditions.  There is NO
74300bf1aeSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
75300bf1aeSmrg
76300bf1aeSmrg# This program is free software; you can redistribute it and/or modify
77300bf1aeSmrg# it under the terms of the GNU General Public License as published by
78300bf1aeSmrg# the Free Software Foundation; either version 3 of the License, or
79300bf1aeSmrg# (at your option) any later version.
80300bf1aeSmrg
81300bf1aeSmrg# As a special exception to the GNU General Public License, if you distribute
82300bf1aeSmrg# this file as part of a program or library that is built using GNU Libtool,
83300bf1aeSmrg# you may include this file under the same distribution terms that you use
84300bf1aeSmrg# for the rest of that program.
85300bf1aeSmrg
86300bf1aeSmrg# This program is distributed in the hope that it will be useful,
87300bf1aeSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
88300bf1aeSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
89300bf1aeSmrg# General Public License for more details.
90300bf1aeSmrg
91300bf1aeSmrg# You should have received a copy of the GNU General Public License
92300bf1aeSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>.
93300bf1aeSmrg
94300bf1aeSmrg# Please report bugs or propose patches to gary@gnu.org.
95300bf1aeSmrg
96300bf1aeSmrg
97300bf1aeSmrg## ------ ##
98300bf1aeSmrg## Usage. ##
99300bf1aeSmrg## ------ ##
100300bf1aeSmrg
101300bf1aeSmrg# Evaluate this file near the top of your script to gain access to
102300bf1aeSmrg# the functions and variables defined here:
103300bf1aeSmrg#
104300bf1aeSmrg#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
105300bf1aeSmrg#
106300bf1aeSmrg# If you need to override any of the default environment variable
107300bf1aeSmrg# settings, do that before evaluating this file.
108300bf1aeSmrg
109300bf1aeSmrg
110300bf1aeSmrg## -------------------- ##
111300bf1aeSmrg## Shell normalisation. ##
112300bf1aeSmrg## -------------------- ##
113300bf1aeSmrg
114300bf1aeSmrg# Some shells need a little help to be as Bourne compatible as possible.
115300bf1aeSmrg# Before doing anything else, make sure all that help has been provided!
116300bf1aeSmrg
117300bf1aeSmrgDUALCASE=1; export DUALCASE # for MKS sh
118300bf1aeSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
1198697ee19Smrg  emulate sh
1208697ee19Smrg  NULLCMD=:
121300bf1aeSmrg  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
1228697ee19Smrg  # is contrary to our usage.  Disable this feature.
1238697ee19Smrg  alias -g '${1+"$@"}'='"$@"'
124ab47cfaaSmrg  setopt NO_GLOB_SUBST
1258697ee19Smrgelse
126300bf1aeSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
127ab47cfaaSmrgfi
1285c42550eSmrg
129300bf1aeSmrg# NLS nuisances: We save the old values in case they are required later.
130300bf1aeSmrg_G_user_locale=
131300bf1aeSmrg_G_safe_locale=
132300bf1aeSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1338697ee19Smrgdo
134300bf1aeSmrg  eval "if test set = \"\${$_G_var+set}\"; then
135300bf1aeSmrg          save_$_G_var=\$$_G_var
136300bf1aeSmrg          $_G_var=C
137300bf1aeSmrg	  export $_G_var
138300bf1aeSmrg	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
139300bf1aeSmrg	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
1408697ee19Smrg	fi"
1418697ee19Smrgdone
142ab47cfaaSmrg
143300bf1aeSmrg# CDPATH.
144300bf1aeSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1456aec45a7Smrg
146300bf1aeSmrg# Make sure IFS has a sensible default
147300bf1aeSmrgsp=' '
148300bf1aeSmrgnl='
149300bf1aeSmrg'
150300bf1aeSmrgIFS="$sp	$nl"
151300bf1aeSmrg
152300bf1aeSmrg# There are apparently some retarded systems that use ';' as a PATH separator!
153300bf1aeSmrgif test "${PATH_SEPARATOR+set}" != set; then
154300bf1aeSmrg  PATH_SEPARATOR=:
155300bf1aeSmrg  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
156300bf1aeSmrg    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
157300bf1aeSmrg      PATH_SEPARATOR=';'
158300bf1aeSmrg  }
159300bf1aeSmrgfi
1606aec45a7Smrg
1616aec45a7Smrg
1626aec45a7Smrg
163300bf1aeSmrg## ------------------------- ##
164300bf1aeSmrg## Locate command utilities. ##
165300bf1aeSmrg## ------------------------- ##
166300bf1aeSmrg
167300bf1aeSmrg
168300bf1aeSmrg# func_executable_p FILE
169300bf1aeSmrg# ----------------------
170300bf1aeSmrg# Check that FILE is an executable regular file.
171300bf1aeSmrgfunc_executable_p ()
172300bf1aeSmrg{
173300bf1aeSmrg    test -f "$1" && test -x "$1"
174300bf1aeSmrg}
175300bf1aeSmrg
176300bf1aeSmrg
177300bf1aeSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
178300bf1aeSmrg# --------------------------------------------
179300bf1aeSmrg# Search for either a program that responds to --version with output
180300bf1aeSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by
181300bf1aeSmrg# trying all the directories in PATH with each of the elements of
182300bf1aeSmrg# PROGS_LIST.
183300bf1aeSmrg#
184300bf1aeSmrg# CHECK_FUNC should accept the path to a candidate program, and
185300bf1aeSmrg# set $func_check_prog_result if it truncates its output less than
186300bf1aeSmrg# $_G_path_prog_max characters.
187300bf1aeSmrgfunc_path_progs ()
188300bf1aeSmrg{
189300bf1aeSmrg    _G_progs_list=$1
190300bf1aeSmrg    _G_check_func=$2
191300bf1aeSmrg    _G_PATH=${3-"$PATH"}
192300bf1aeSmrg
193300bf1aeSmrg    _G_path_prog_max=0
194300bf1aeSmrg    _G_path_prog_found=false
195300bf1aeSmrg    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
196300bf1aeSmrg    for _G_dir in $_G_PATH; do
197300bf1aeSmrg      IFS=$_G_save_IFS
198300bf1aeSmrg      test -z "$_G_dir" && _G_dir=.
199300bf1aeSmrg      for _G_prog_name in $_G_progs_list; do
200300bf1aeSmrg        for _exeext in '' .EXE; do
201300bf1aeSmrg          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
202300bf1aeSmrg          func_executable_p "$_G_path_prog" || continue
203300bf1aeSmrg          case `"$_G_path_prog" --version 2>&1` in
204300bf1aeSmrg            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
205300bf1aeSmrg            *)     $_G_check_func $_G_path_prog
206300bf1aeSmrg		   func_path_progs_result=$func_check_prog_result
207300bf1aeSmrg		   ;;
208300bf1aeSmrg          esac
209300bf1aeSmrg          $_G_path_prog_found && break 3
210300bf1aeSmrg        done
211300bf1aeSmrg      done
212300bf1aeSmrg    done
213300bf1aeSmrg    IFS=$_G_save_IFS
214300bf1aeSmrg    test -z "$func_path_progs_result" && {
215300bf1aeSmrg      echo "no acceptable sed could be found in \$PATH" >&2
216300bf1aeSmrg      exit 1
217300bf1aeSmrg    }
218300bf1aeSmrg}
219300bf1aeSmrg
220300bf1aeSmrg
221300bf1aeSmrg# We want to be able to use the functions in this file before configure
222300bf1aeSmrg# has figured out where the best binaries are kept, which means we have
223300bf1aeSmrg# to search for them ourselves - except when the results are already set
224300bf1aeSmrg# where we skip the searches.
225300bf1aeSmrg
226300bf1aeSmrg# Unless the user overrides by setting SED, search the path for either GNU
227300bf1aeSmrg# sed, or the sed that truncates its output the least.
228300bf1aeSmrgtest -z "$SED" && {
229300bf1aeSmrg  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
230300bf1aeSmrg  for _G_i in 1 2 3 4 5 6 7; do
231300bf1aeSmrg    _G_sed_script=$_G_sed_script$nl$_G_sed_script
232300bf1aeSmrg  done
233300bf1aeSmrg  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
234300bf1aeSmrg  _G_sed_script=
235300bf1aeSmrg
236300bf1aeSmrg  func_check_prog_sed ()
237300bf1aeSmrg  {
238300bf1aeSmrg    _G_path_prog=$1
239300bf1aeSmrg
240300bf1aeSmrg    _G_count=0
241300bf1aeSmrg    printf 0123456789 >conftest.in
242300bf1aeSmrg    while :
243300bf1aeSmrg    do
244300bf1aeSmrg      cat conftest.in conftest.in >conftest.tmp
245300bf1aeSmrg      mv conftest.tmp conftest.in
246300bf1aeSmrg      cp conftest.in conftest.nl
247300bf1aeSmrg      echo '' >> conftest.nl
248300bf1aeSmrg      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
249300bf1aeSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
250300bf1aeSmrg      _G_count=`expr $_G_count + 1`
251300bf1aeSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
252300bf1aeSmrg        # Best one so far, save it but keep looking for a better one
253300bf1aeSmrg        func_check_prog_result=$_G_path_prog
254300bf1aeSmrg        _G_path_prog_max=$_G_count
255300bf1aeSmrg      fi
256300bf1aeSmrg      # 10*(2^10) chars as input seems more than enough
257300bf1aeSmrg      test 10 -lt "$_G_count" && break
258300bf1aeSmrg    done
259300bf1aeSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
260300bf1aeSmrg  }
261300bf1aeSmrg
262300bf1aeSmrg  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
263300bf1aeSmrg  rm -f conftest.sed
264300bf1aeSmrg  SED=$func_path_progs_result
265300bf1aeSmrg}
266300bf1aeSmrg
267300bf1aeSmrg
268300bf1aeSmrg# Unless the user overrides by setting GREP, search the path for either GNU
269300bf1aeSmrg# grep, or the grep that truncates its output the least.
270300bf1aeSmrgtest -z "$GREP" && {
271300bf1aeSmrg  func_check_prog_grep ()
272300bf1aeSmrg  {
273300bf1aeSmrg    _G_path_prog=$1
274300bf1aeSmrg
275300bf1aeSmrg    _G_count=0
276300bf1aeSmrg    _G_path_prog_max=0
277300bf1aeSmrg    printf 0123456789 >conftest.in
278300bf1aeSmrg    while :
279300bf1aeSmrg    do
280300bf1aeSmrg      cat conftest.in conftest.in >conftest.tmp
281300bf1aeSmrg      mv conftest.tmp conftest.in
282300bf1aeSmrg      cp conftest.in conftest.nl
283300bf1aeSmrg      echo 'GREP' >> conftest.nl
284300bf1aeSmrg      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
285300bf1aeSmrg      diff conftest.out conftest.nl >/dev/null 2>&1 || break
286300bf1aeSmrg      _G_count=`expr $_G_count + 1`
287300bf1aeSmrg      if test "$_G_count" -gt "$_G_path_prog_max"; then
288300bf1aeSmrg        # Best one so far, save it but keep looking for a better one
289300bf1aeSmrg        func_check_prog_result=$_G_path_prog
290300bf1aeSmrg        _G_path_prog_max=$_G_count
291300bf1aeSmrg      fi
292300bf1aeSmrg      # 10*(2^10) chars as input seems more than enough
293300bf1aeSmrg      test 10 -lt "$_G_count" && break
294300bf1aeSmrg    done
295300bf1aeSmrg    rm -f conftest.in conftest.tmp conftest.nl conftest.out
296300bf1aeSmrg  }
297300bf1aeSmrg
298300bf1aeSmrg  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
299300bf1aeSmrg  GREP=$func_path_progs_result
300300bf1aeSmrg}
301300bf1aeSmrg
302300bf1aeSmrg
303300bf1aeSmrg## ------------------------------- ##
304300bf1aeSmrg## User overridable command paths. ##
305300bf1aeSmrg## ------------------------------- ##
306300bf1aeSmrg
307300bf1aeSmrg# All uppercase variable names are used for environment variables.  These
308300bf1aeSmrg# variables can be overridden by the user before calling a script that
309300bf1aeSmrg# uses them if a suitable command of that name is not already available
310300bf1aeSmrg# in the command search PATH.
3116aec45a7Smrg
3126aec45a7Smrg: ${CP="cp -f"}
313300bf1aeSmrg: ${ECHO="printf %s\n"}
314300bf1aeSmrg: ${EGREP="$GREP -E"}
315300bf1aeSmrg: ${FGREP="$GREP -F"}
316300bf1aeSmrg: ${LN_S="ln -s"}
3176aec45a7Smrg: ${MAKE="make"}
3186aec45a7Smrg: ${MKDIR="mkdir"}
3196aec45a7Smrg: ${MV="mv -f"}
3206aec45a7Smrg: ${RM="rm -f"}
3216aec45a7Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
322ab47cfaaSmrg
3236aec45a7Smrg
324300bf1aeSmrg## -------------------- ##
325300bf1aeSmrg## Useful sed snippets. ##
326300bf1aeSmrg## -------------------- ##
327aa9e3350Smrg
328300bf1aeSmrgsed_dirname='s|/[^/]*$||'
329300bf1aeSmrgsed_basename='s|^.*/||'
330aa9e3350Smrg
331300bf1aeSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
332300bf1aeSmrg# metacharacters that are still active within double-quoted strings.
333300bf1aeSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g'
334aa9e3350Smrg
335300bf1aeSmrg# Same as above, but do not quote variable references.
336300bf1aeSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
337aa9e3350Smrg
338300bf1aeSmrg# Sed substitution that turns a string into a regex matching for the
339300bf1aeSmrg# string literally.
340300bf1aeSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
341aa9e3350Smrg
342300bf1aeSmrg# Sed substitution that converts a w32 file name or path
343300bf1aeSmrg# that contains forward slashes, into one that contains
344300bf1aeSmrg# (escaped) backslashes.  A very naive implementation.
345300bf1aeSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
346300bf1aeSmrg
347300bf1aeSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that
348300bf1aeSmrg# were '\'-ed in input to the same.  If an odd number of '\' preceded a
349300bf1aeSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from
350300bf1aeSmrg# expansion.  Since each input '\' is now two '\'s, look for any number
351300bf1aeSmrg# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
352300bf1aeSmrg_G_bs='\\'
353300bf1aeSmrg_G_bs2='\\\\'
354300bf1aeSmrg_G_bs4='\\\\\\\\'
355300bf1aeSmrg_G_dollar='\$'
356300bf1aeSmrgsed_double_backslash="\
357300bf1aeSmrg  s/$_G_bs4/&\\
358300bf1aeSmrg/g
359300bf1aeSmrg  s/^$_G_bs2$_G_dollar/$_G_bs&/
360300bf1aeSmrg  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
361300bf1aeSmrg  s/\n//g"
362aa9e3350Smrg
3631473d951Smrg
364300bf1aeSmrg## ----------------- ##
365300bf1aeSmrg## Global variables. ##
366300bf1aeSmrg## ----------------- ##
3676aec45a7Smrg
368300bf1aeSmrg# Except for the global variables explicitly listed below, the following
369300bf1aeSmrg# functions in the '^func_' namespace, and the '^require_' namespace
370300bf1aeSmrg# variables initialised in the 'Resource management' section, sourcing
371300bf1aeSmrg# this file will not pollute your global namespace with anything
372300bf1aeSmrg# else. There's no portable way to scope variables in Bourne shell
373300bf1aeSmrg# though, so actually running these functions will sometimes place
374300bf1aeSmrg# results into a variable named after the function, and often use
375300bf1aeSmrg# temporary variables in the '^_G_' namespace. If you are careful to
376300bf1aeSmrg# avoid using those namespaces casually in your sourcing script, things
377300bf1aeSmrg# should continue to work as you expect. And, of course, you can freely
378300bf1aeSmrg# overwrite any of the functions or variables defined here before
379300bf1aeSmrg# calling anything to customize them.
3806aec45a7Smrg
381300bf1aeSmrgEXIT_SUCCESS=0
382300bf1aeSmrgEXIT_FAILURE=1
383300bf1aeSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
384300bf1aeSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
3856aec45a7Smrg
386300bf1aeSmrg# Allow overriding, eg assuming that you follow the convention of
387300bf1aeSmrg# putting '$debug_cmd' at the start of all your functions, you can get
388300bf1aeSmrg# bash to show function call trace with:
389300bf1aeSmrg#
390300bf1aeSmrg#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
391300bf1aeSmrgdebug_cmd=${debug_cmd-":"}
392300bf1aeSmrgexit_cmd=:
3936aec45a7Smrg
394300bf1aeSmrg# By convention, finish your script with:
395300bf1aeSmrg#
396300bf1aeSmrg#    exit $exit_status
397300bf1aeSmrg#
398300bf1aeSmrg# so that you can set exit_status to non-zero if you want to indicate
399300bf1aeSmrg# something went wrong during execution without actually bailing out at
400300bf1aeSmrg# the point of failure.
401300bf1aeSmrgexit_status=$EXIT_SUCCESS
4026aec45a7Smrg
403300bf1aeSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
404300bf1aeSmrg# is ksh but when the shell is invoked as "sh" and the current value of
405300bf1aeSmrg# the _XPG environment variable is not equal to 1 (one), the special
406300bf1aeSmrg# positional parameter $0, within a function call, is the name of the
407300bf1aeSmrg# function.
408300bf1aeSmrgprogpath=$0
4096aec45a7Smrg
410300bf1aeSmrg# The name of this program.
411300bf1aeSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"`
4126aec45a7Smrg
413300bf1aeSmrg# Make sure we have an absolute progpath for reexecution:
4146aec45a7Smrgcase $progpath in
4156aec45a7Smrg  [\\/]*|[A-Za-z]:\\*) ;;
4166aec45a7Smrg  *[\\/]*)
417300bf1aeSmrg     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
4186aec45a7Smrg     progdir=`cd "$progdir" && pwd`
419300bf1aeSmrg     progpath=$progdir/$progname
4206aec45a7Smrg     ;;
4216aec45a7Smrg  *)
422300bf1aeSmrg     _G_IFS=$IFS
423aa9e3350Smrg     IFS=${PATH_SEPARATOR-:}
4246aec45a7Smrg     for progdir in $PATH; do
425300bf1aeSmrg       IFS=$_G_IFS
4266aec45a7Smrg       test -x "$progdir/$progname" && break
4276aec45a7Smrg     done
428300bf1aeSmrg     IFS=$_G_IFS
4296aec45a7Smrg     test -n "$progdir" || progdir=`pwd`
430300bf1aeSmrg     progpath=$progdir/$progname
4316aec45a7Smrg     ;;
4326aec45a7Smrgesac
4336aec45a7Smrg
4346aec45a7Smrg
435300bf1aeSmrg## ----------------- ##
436300bf1aeSmrg## Standard options. ##
437300bf1aeSmrg## ----------------- ##
438aa9e3350Smrg
439300bf1aeSmrg# The following options affect the operation of the functions defined
440300bf1aeSmrg# below, and should be set appropriately depending on run-time para-
441300bf1aeSmrg# meters passed on the command line.
4426aec45a7Smrg
4436aec45a7Smrgopt_dry_run=false
4446aec45a7Smrgopt_quiet=false
4456aec45a7Smrgopt_verbose=false
4466aec45a7Smrg
447300bf1aeSmrg# Categories 'all' and 'none' are always available.  Append any others
448300bf1aeSmrg# you will pass as the first argument to func_warning from your own
449300bf1aeSmrg# code.
450300bf1aeSmrgwarning_categories=
4516aec45a7Smrg
452300bf1aeSmrg# By default, display warnings according to 'opt_warning_types'.  Set
453300bf1aeSmrg# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
454300bf1aeSmrg# treat the next displayed warning as a fatal error.
455300bf1aeSmrgwarning_func=func_warn_and_continue
4566aec45a7Smrg
457300bf1aeSmrg# Set to 'all' to display all warnings, 'none' to suppress all
458300bf1aeSmrg# warnings, or a space delimited list of some subset of
459300bf1aeSmrg# 'warning_categories' to display only the listed warnings.
460300bf1aeSmrgopt_warning_types=all
4616aec45a7Smrg
4626aec45a7Smrg
463300bf1aeSmrg## -------------------- ##
464300bf1aeSmrg## Resource management. ##
465300bf1aeSmrg## -------------------- ##
4666aec45a7Smrg
467300bf1aeSmrg# This section contains definitions for functions that each ensure a
468300bf1aeSmrg# particular resource (a file, or a non-empty configuration variable for
469300bf1aeSmrg# example) is available, and if appropriate to extract default values
470300bf1aeSmrg# from pertinent package files. Call them using their associated
471300bf1aeSmrg# 'require_*' variable to ensure that they are executed, at most, once.
472300bf1aeSmrg#
473300bf1aeSmrg# It's entirely deliberate that calling these functions can set
474300bf1aeSmrg# variables that don't obey the namespace limitations obeyed by the rest
475300bf1aeSmrg# of this file, in order that that they be as useful as possible to
476300bf1aeSmrg# callers.
4776aec45a7Smrg
4786aec45a7Smrg
479300bf1aeSmrg# require_term_colors
480300bf1aeSmrg# -------------------
481300bf1aeSmrg# Allow display of bold text on terminals that support it.
482300bf1aeSmrgrequire_term_colors=func_require_term_colors
483300bf1aeSmrgfunc_require_term_colors ()
4846aec45a7Smrg{
485300bf1aeSmrg    $debug_cmd
486300bf1aeSmrg
487300bf1aeSmrg    test -t 1 && {
488300bf1aeSmrg      # COLORTERM and USE_ANSI_COLORS environment variables take
489300bf1aeSmrg      # precedence, because most terminfo databases neglect to describe
490300bf1aeSmrg      # whether color sequences are supported.
491300bf1aeSmrg      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
492300bf1aeSmrg
493300bf1aeSmrg      if test 1 = "$USE_ANSI_COLORS"; then
494300bf1aeSmrg        # Standard ANSI escape sequences
495300bf1aeSmrg        tc_reset='[0m'
496300bf1aeSmrg        tc_bold='[1m';   tc_standout='[7m'
497300bf1aeSmrg        tc_red='[31m';   tc_green='[32m'
498300bf1aeSmrg        tc_blue='[34m';  tc_cyan='[36m'
499300bf1aeSmrg      else
500300bf1aeSmrg        # Otherwise trust the terminfo database after all.
501300bf1aeSmrg        test -n "`tput sgr0 2>/dev/null`" && {
502300bf1aeSmrg          tc_reset=`tput sgr0`
503300bf1aeSmrg          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
504300bf1aeSmrg          tc_standout=$tc_bold
505300bf1aeSmrg          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
506300bf1aeSmrg          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
507300bf1aeSmrg          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
508300bf1aeSmrg          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
509300bf1aeSmrg          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
510300bf1aeSmrg        }
511300bf1aeSmrg      fi
512300bf1aeSmrg    }
5136aec45a7Smrg
514300bf1aeSmrg    require_term_colors=:
5156aec45a7Smrg}
5166aec45a7Smrg
5176aec45a7Smrg
518300bf1aeSmrg## ----------------- ##
519300bf1aeSmrg## Function library. ##
520300bf1aeSmrg## ----------------- ##
521300bf1aeSmrg
522300bf1aeSmrg# This section contains a variety of useful functions to call in your
523300bf1aeSmrg# scripts. Take note of the portable wrappers for features provided by
524300bf1aeSmrg# some modern shells, which will fall back to slower equivalents on
525300bf1aeSmrg# less featureful shells.
526300bf1aeSmrg
527300bf1aeSmrg
528300bf1aeSmrg# func_append VAR VALUE
529300bf1aeSmrg# ---------------------
530300bf1aeSmrg# Append VALUE onto the existing contents of VAR.
531300bf1aeSmrg
532300bf1aeSmrg  # We should try to minimise forks, especially on Windows where they are
533300bf1aeSmrg  # unreasonably slow, so skip the feature probes when bash or zsh are
534300bf1aeSmrg  # being used:
535300bf1aeSmrg  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
536300bf1aeSmrg    : ${_G_HAVE_ARITH_OP="yes"}
537300bf1aeSmrg    : ${_G_HAVE_XSI_OPS="yes"}
538300bf1aeSmrg    # The += operator was introduced in bash 3.1
539300bf1aeSmrg    case $BASH_VERSION in
540300bf1aeSmrg      [12].* | 3.0 | 3.0*) ;;
541300bf1aeSmrg      *)
542300bf1aeSmrg        : ${_G_HAVE_PLUSEQ_OP="yes"}
543300bf1aeSmrg        ;;
544300bf1aeSmrg    esac
545300bf1aeSmrg  fi
546300bf1aeSmrg
547300bf1aeSmrg  # _G_HAVE_PLUSEQ_OP
548300bf1aeSmrg  # Can be empty, in which case the shell is probed, "yes" if += is
549300bf1aeSmrg  # useable or anything else if it does not work.
550300bf1aeSmrg  test -z "$_G_HAVE_PLUSEQ_OP" \
551300bf1aeSmrg    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
552300bf1aeSmrg    && _G_HAVE_PLUSEQ_OP=yes
553300bf1aeSmrg
554300bf1aeSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"
555300bf1aeSmrgthen
556300bf1aeSmrg  # This is an XSI compatible shell, allowing a faster implementation...
557300bf1aeSmrg  eval 'func_append ()
558300bf1aeSmrg  {
559300bf1aeSmrg    $debug_cmd
560300bf1aeSmrg
561300bf1aeSmrg    eval "$1+=\$2"
562300bf1aeSmrg  }'
563300bf1aeSmrgelse
564300bf1aeSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
565300bf1aeSmrg  func_append ()
566300bf1aeSmrg  {
567300bf1aeSmrg    $debug_cmd
568300bf1aeSmrg
569300bf1aeSmrg    eval "$1=\$$1\$2"
570300bf1aeSmrg  }
571300bf1aeSmrgfi
572300bf1aeSmrg
573300bf1aeSmrg
574300bf1aeSmrg# func_append_quoted VAR VALUE
575300bf1aeSmrg# ----------------------------
576300bf1aeSmrg# Quote VALUE and append to the end of shell variable VAR, separated
577300bf1aeSmrg# by a space.
578300bf1aeSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then
579300bf1aeSmrg  eval 'func_append_quoted ()
580300bf1aeSmrg  {
581300bf1aeSmrg    $debug_cmd
582300bf1aeSmrg
583300bf1aeSmrg    func_quote_for_eval "$2"
584300bf1aeSmrg    eval "$1+=\\ \$func_quote_for_eval_result"
585300bf1aeSmrg  }'
586300bf1aeSmrgelse
587300bf1aeSmrg  func_append_quoted ()
588300bf1aeSmrg  {
589300bf1aeSmrg    $debug_cmd
590300bf1aeSmrg
591300bf1aeSmrg    func_quote_for_eval "$2"
592300bf1aeSmrg    eval "$1=\$$1\\ \$func_quote_for_eval_result"
593300bf1aeSmrg  }
594300bf1aeSmrgfi
595300bf1aeSmrg
596300bf1aeSmrg
597300bf1aeSmrg# func_append_uniq VAR VALUE
598300bf1aeSmrg# --------------------------
599300bf1aeSmrg# Append unique VALUE onto the existing contents of VAR, assuming
600300bf1aeSmrg# entries are delimited by the first character of VALUE.  For example:
601300bf1aeSmrg#
602300bf1aeSmrg#   func_append_uniq options " --another-option option-argument"
603300bf1aeSmrg#
604300bf1aeSmrg# will only append to $options if " --another-option option-argument "
605300bf1aeSmrg# is not already present somewhere in $options already (note spaces at
606300bf1aeSmrg# each end implied by leading space in second argument).
607300bf1aeSmrgfunc_append_uniq ()
608300bf1aeSmrg{
609300bf1aeSmrg    $debug_cmd
610300bf1aeSmrg
611300bf1aeSmrg    eval _G_current_value='`$ECHO $'$1'`'
612300bf1aeSmrg    _G_delim=`expr "$2" : '\(.\)'`
613300bf1aeSmrg
614300bf1aeSmrg    case $_G_delim$_G_current_value$_G_delim in
615300bf1aeSmrg      *"$2$_G_delim"*) ;;
616300bf1aeSmrg      *) func_append "$@" ;;
617300bf1aeSmrg    esac
618300bf1aeSmrg}
619300bf1aeSmrg
620300bf1aeSmrg
621300bf1aeSmrg# func_arith TERM...
622300bf1aeSmrg# ------------------
623300bf1aeSmrg# Set func_arith_result to the result of evaluating TERMs.
624300bf1aeSmrg  test -z "$_G_HAVE_ARITH_OP" \
625300bf1aeSmrg    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
626300bf1aeSmrg    && _G_HAVE_ARITH_OP=yes
627300bf1aeSmrg
628300bf1aeSmrgif test yes = "$_G_HAVE_ARITH_OP"; then
629300bf1aeSmrg  eval 'func_arith ()
630300bf1aeSmrg  {
631300bf1aeSmrg    $debug_cmd
632300bf1aeSmrg
633300bf1aeSmrg    func_arith_result=$(( $* ))
634300bf1aeSmrg  }'
635300bf1aeSmrgelse
636300bf1aeSmrg  func_arith ()
637300bf1aeSmrg  {
638300bf1aeSmrg    $debug_cmd
639300bf1aeSmrg
640300bf1aeSmrg    func_arith_result=`expr "$@"`
641300bf1aeSmrg  }
642300bf1aeSmrgfi
643300bf1aeSmrg
644300bf1aeSmrg
645300bf1aeSmrg# func_basename FILE
646300bf1aeSmrg# ------------------
647300bf1aeSmrg# Set func_basename_result to FILE with everything up to and including
648300bf1aeSmrg# the last / stripped.
649300bf1aeSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
650300bf1aeSmrg  # If this shell supports suffix pattern removal, then use it to avoid
651300bf1aeSmrg  # forking. Hide the definitions single quotes in case the shell chokes
652300bf1aeSmrg  # on unsupported syntax...
653300bf1aeSmrg  _b='func_basename_result=${1##*/}'
654300bf1aeSmrg  _d='case $1 in
655300bf1aeSmrg        */*) func_dirname_result=${1%/*}$2 ;;
656300bf1aeSmrg        *  ) func_dirname_result=$3        ;;
657300bf1aeSmrg      esac'
658300bf1aeSmrg
659300bf1aeSmrgelse
660300bf1aeSmrg  # ...otherwise fall back to using sed.
661300bf1aeSmrg  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
662300bf1aeSmrg  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
663300bf1aeSmrg      if test "X$func_dirname_result" = "X$1"; then
664300bf1aeSmrg        func_dirname_result=$3
665300bf1aeSmrg      else
666300bf1aeSmrg        func_append func_dirname_result "$2"
667300bf1aeSmrg      fi'
668300bf1aeSmrgfi
669300bf1aeSmrg
670300bf1aeSmrgeval 'func_basename ()
671300bf1aeSmrg{
672300bf1aeSmrg    $debug_cmd
673300bf1aeSmrg
674300bf1aeSmrg    '"$_b"'
675300bf1aeSmrg}'
676300bf1aeSmrg
677300bf1aeSmrg
678300bf1aeSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT
679300bf1aeSmrg# -------------------------------------------
680300bf1aeSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
681300bf1aeSmrg# otherwise set result to NONDIR_REPLACEMENT.
682300bf1aeSmrgeval 'func_dirname ()
683300bf1aeSmrg{
684300bf1aeSmrg    $debug_cmd
685300bf1aeSmrg
686300bf1aeSmrg    '"$_d"'
687300bf1aeSmrg}'
688300bf1aeSmrg
689300bf1aeSmrg
690300bf1aeSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
691300bf1aeSmrg# --------------------------------------------------------
692300bf1aeSmrg# Perform func_basename and func_dirname in a single function
693300bf1aeSmrg# call:
694300bf1aeSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
695300bf1aeSmrg#             add APPEND to the result, otherwise set result
696300bf1aeSmrg#             to NONDIR_REPLACEMENT.
697300bf1aeSmrg#             value returned in "$func_dirname_result"
698300bf1aeSmrg#   basename: Compute filename of FILE.
699300bf1aeSmrg#             value retuned in "$func_basename_result"
700300bf1aeSmrg# For efficiency, we do not delegate to the functions above but instead
701300bf1aeSmrg# duplicate the functionality here.
702300bf1aeSmrgeval 'func_dirname_and_basename ()
703300bf1aeSmrg{
704300bf1aeSmrg    $debug_cmd
705300bf1aeSmrg
706300bf1aeSmrg    '"$_b"'
707300bf1aeSmrg    '"$_d"'
708300bf1aeSmrg}'
709300bf1aeSmrg
710300bf1aeSmrg
711300bf1aeSmrg# func_echo ARG...
712300bf1aeSmrg# ----------------
713300bf1aeSmrg# Echo program name prefixed message.
714300bf1aeSmrgfunc_echo ()
715300bf1aeSmrg{
716300bf1aeSmrg    $debug_cmd
717300bf1aeSmrg
718300bf1aeSmrg    _G_message=$*
719300bf1aeSmrg
720300bf1aeSmrg    func_echo_IFS=$IFS
721300bf1aeSmrg    IFS=$nl
722300bf1aeSmrg    for _G_line in $_G_message; do
723300bf1aeSmrg      IFS=$func_echo_IFS
724300bf1aeSmrg      $ECHO "$progname: $_G_line"
725300bf1aeSmrg    done
726300bf1aeSmrg    IFS=$func_echo_IFS
727300bf1aeSmrg}
728300bf1aeSmrg
729300bf1aeSmrg
730300bf1aeSmrg# func_echo_all ARG...
731300bf1aeSmrg# --------------------
732300bf1aeSmrg# Invoke $ECHO with all args, space-separated.
733300bf1aeSmrgfunc_echo_all ()
734300bf1aeSmrg{
735300bf1aeSmrg    $ECHO "$*"
736300bf1aeSmrg}
737300bf1aeSmrg
738300bf1aeSmrg
739300bf1aeSmrg# func_echo_infix_1 INFIX ARG...
740300bf1aeSmrg# ------------------------------
741300bf1aeSmrg# Echo program name, followed by INFIX on the first line, with any
742300bf1aeSmrg# additional lines not showing INFIX.
743300bf1aeSmrgfunc_echo_infix_1 ()
744300bf1aeSmrg{
745300bf1aeSmrg    $debug_cmd
746300bf1aeSmrg
747300bf1aeSmrg    $require_term_colors
748300bf1aeSmrg
749300bf1aeSmrg    _G_infix=$1; shift
750300bf1aeSmrg    _G_indent=$_G_infix
751300bf1aeSmrg    _G_prefix="$progname: $_G_infix: "
752300bf1aeSmrg    _G_message=$*
753300bf1aeSmrg
754300bf1aeSmrg    # Strip color escape sequences before counting printable length
755300bf1aeSmrg    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
756300bf1aeSmrg    do
757300bf1aeSmrg      test -n "$_G_tc" && {
758300bf1aeSmrg        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
759300bf1aeSmrg        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
760300bf1aeSmrg      }
761300bf1aeSmrg    done
762300bf1aeSmrg    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
763300bf1aeSmrg
764300bf1aeSmrg    func_echo_infix_1_IFS=$IFS
765300bf1aeSmrg    IFS=$nl
766300bf1aeSmrg    for _G_line in $_G_message; do
767300bf1aeSmrg      IFS=$func_echo_infix_1_IFS
768300bf1aeSmrg      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
769300bf1aeSmrg      _G_prefix=$_G_indent
770300bf1aeSmrg    done
771300bf1aeSmrg    IFS=$func_echo_infix_1_IFS
772300bf1aeSmrg}
773300bf1aeSmrg
774300bf1aeSmrg
775300bf1aeSmrg# func_error ARG...
776300bf1aeSmrg# -----------------
777300bf1aeSmrg# Echo program name prefixed message to standard error.
778300bf1aeSmrgfunc_error ()
779300bf1aeSmrg{
780300bf1aeSmrg    $debug_cmd
781300bf1aeSmrg
782300bf1aeSmrg    $require_term_colors
783300bf1aeSmrg
784300bf1aeSmrg    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
785300bf1aeSmrg}
786300bf1aeSmrg
787300bf1aeSmrg
788300bf1aeSmrg# func_fatal_error ARG...
789300bf1aeSmrg# -----------------------
790300bf1aeSmrg# Echo program name prefixed message to standard error, and exit.
791300bf1aeSmrgfunc_fatal_error ()
792300bf1aeSmrg{
793300bf1aeSmrg    $debug_cmd
794300bf1aeSmrg
795300bf1aeSmrg    func_error "$*"
796300bf1aeSmrg    exit $EXIT_FAILURE
797300bf1aeSmrg}
798300bf1aeSmrg
799300bf1aeSmrg
800300bf1aeSmrg# func_grep EXPRESSION FILENAME
801300bf1aeSmrg# -----------------------------
8026aec45a7Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
8036aec45a7Smrgfunc_grep ()
8046aec45a7Smrg{
805300bf1aeSmrg    $debug_cmd
806300bf1aeSmrg
8076aec45a7Smrg    $GREP "$1" "$2" >/dev/null 2>&1
8086aec45a7Smrg}
8096aec45a7Smrg
8106aec45a7Smrg
811300bf1aeSmrg# func_len STRING
812300bf1aeSmrg# ---------------
813300bf1aeSmrg# Set func_len_result to the length of STRING. STRING may not
814300bf1aeSmrg# start with a hyphen.
815300bf1aeSmrg  test -z "$_G_HAVE_XSI_OPS" \
816300bf1aeSmrg    && (eval 'x=a/b/c;
817300bf1aeSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
818300bf1aeSmrg    && _G_HAVE_XSI_OPS=yes
819300bf1aeSmrg
820300bf1aeSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
821300bf1aeSmrg  eval 'func_len ()
822300bf1aeSmrg  {
823300bf1aeSmrg    $debug_cmd
824300bf1aeSmrg
825300bf1aeSmrg    func_len_result=${#1}
826300bf1aeSmrg  }'
827300bf1aeSmrgelse
828300bf1aeSmrg  func_len ()
829300bf1aeSmrg  {
830300bf1aeSmrg    $debug_cmd
831300bf1aeSmrg
832300bf1aeSmrg    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
833300bf1aeSmrg  }
834300bf1aeSmrgfi
835300bf1aeSmrg
836300bf1aeSmrg
837300bf1aeSmrg# func_mkdir_p DIRECTORY-PATH
838300bf1aeSmrg# ---------------------------
8396aec45a7Smrg# Make sure the entire path to DIRECTORY-PATH is available.
8406aec45a7Smrgfunc_mkdir_p ()
8416aec45a7Smrg{
842300bf1aeSmrg    $debug_cmd
843300bf1aeSmrg
844300bf1aeSmrg    _G_directory_path=$1
845300bf1aeSmrg    _G_dir_list=
8466aec45a7Smrg
847300bf1aeSmrg    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
8486aec45a7Smrg
849300bf1aeSmrg      # Protect directory names starting with '-'
850300bf1aeSmrg      case $_G_directory_path in
851300bf1aeSmrg        -*) _G_directory_path=./$_G_directory_path ;;
8526aec45a7Smrg      esac
8536aec45a7Smrg
8546aec45a7Smrg      # While some portion of DIR does not yet exist...
855300bf1aeSmrg      while test ! -d "$_G_directory_path"; do
8566aec45a7Smrg        # ...make a list in topmost first order.  Use a colon delimited
8576aec45a7Smrg	# list incase some portion of path contains whitespace.
858300bf1aeSmrg        _G_dir_list=$_G_directory_path:$_G_dir_list
8596aec45a7Smrg
8606aec45a7Smrg        # If the last portion added has no slash in it, the list is done
861300bf1aeSmrg        case $_G_directory_path in */*) ;; *) break ;; esac
8626aec45a7Smrg
8636aec45a7Smrg        # ...otherwise throw away the child directory and loop
864300bf1aeSmrg        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
8656aec45a7Smrg      done
866300bf1aeSmrg      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
8676aec45a7Smrg
868300bf1aeSmrg      func_mkdir_p_IFS=$IFS; IFS=:
869300bf1aeSmrg      for _G_dir in $_G_dir_list; do
870300bf1aeSmrg	IFS=$func_mkdir_p_IFS
871300bf1aeSmrg        # mkdir can fail with a 'File exist' error if two processes
8726aec45a7Smrg        # try to create one of the directories concurrently.  Don't
8736aec45a7Smrg        # stop in that case!
874300bf1aeSmrg        $MKDIR "$_G_dir" 2>/dev/null || :
8756aec45a7Smrg      done
876300bf1aeSmrg      IFS=$func_mkdir_p_IFS
8776aec45a7Smrg
8786aec45a7Smrg      # Bail out if we (or some other process) failed to create a directory.
879300bf1aeSmrg      test -d "$_G_directory_path" || \
880300bf1aeSmrg        func_fatal_error "Failed to create '$1'"
8816aec45a7Smrg    fi
8826aec45a7Smrg}
883ab47cfaaSmrg
884ab47cfaaSmrg
885300bf1aeSmrg# func_mktempdir [BASENAME]
886300bf1aeSmrg# -------------------------
887ab47cfaaSmrg# Make a temporary directory that won't clash with other running
888ab47cfaaSmrg# libtool processes, and avoids race conditions if possible.  If
889300bf1aeSmrg# given, BASENAME is the basename for that directory.
890ab47cfaaSmrgfunc_mktempdir ()
891ab47cfaaSmrg{
892300bf1aeSmrg    $debug_cmd
893300bf1aeSmrg
894300bf1aeSmrg    _G_template=${TMPDIR-/tmp}/${1-$progname}
895ab47cfaaSmrg
896300bf1aeSmrg    if test : = "$opt_dry_run"; then
897ab47cfaaSmrg      # Return a directory name, but don't create it in dry-run mode
898300bf1aeSmrg      _G_tmpdir=$_G_template-$$
899ab47cfaaSmrg    else
900ab47cfaaSmrg
901ab47cfaaSmrg      # If mktemp works, use that first and foremost
902300bf1aeSmrg      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
903ab47cfaaSmrg
904300bf1aeSmrg      if test ! -d "$_G_tmpdir"; then
9056aec45a7Smrg        # Failing that, at least try and use $RANDOM to avoid a race
906300bf1aeSmrg        _G_tmpdir=$_G_template-${RANDOM-0}$$
907ab47cfaaSmrg
908300bf1aeSmrg        func_mktempdir_umask=`umask`
9096aec45a7Smrg        umask 0077
910300bf1aeSmrg        $MKDIR "$_G_tmpdir"
911300bf1aeSmrg        umask $func_mktempdir_umask
912ab47cfaaSmrg      fi
913ab47cfaaSmrg
914ab47cfaaSmrg      # If we're not in dry-run mode, bomb out on failure
915300bf1aeSmrg      test -d "$_G_tmpdir" || \
916300bf1aeSmrg        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
917ab47cfaaSmrg    fi
918ab47cfaaSmrg
919300bf1aeSmrg    $ECHO "$_G_tmpdir"
920ab47cfaaSmrg}
921ab47cfaaSmrg
922ab47cfaaSmrg
923300bf1aeSmrg# func_normal_abspath PATH
924300bf1aeSmrg# ------------------------
925300bf1aeSmrg# Remove doubled-up and trailing slashes, "." path components,
926300bf1aeSmrg# and cancel out any ".." path components in PATH after making
927300bf1aeSmrg# it an absolute path.
928300bf1aeSmrgfunc_normal_abspath ()
929ab47cfaaSmrg{
930300bf1aeSmrg    $debug_cmd
9316aec45a7Smrg
932300bf1aeSmrg    # These SED scripts presuppose an absolute path with a trailing slash.
933300bf1aeSmrg    _G_pathcar='s|^/\([^/]*\).*$|\1|'
934300bf1aeSmrg    _G_pathcdr='s|^/[^/]*||'
935300bf1aeSmrg    _G_removedotparts=':dotsl
936300bf1aeSmrg		s|/\./|/|g
937300bf1aeSmrg		t dotsl
938300bf1aeSmrg		s|/\.$|/|'
939300bf1aeSmrg    _G_collapseslashes='s|/\{1,\}|/|g'
940300bf1aeSmrg    _G_finalslash='s|/*$|/|'
941300bf1aeSmrg
942300bf1aeSmrg    # Start from root dir and reassemble the path.
943300bf1aeSmrg    func_normal_abspath_result=
944300bf1aeSmrg    func_normal_abspath_tpath=$1
945300bf1aeSmrg    func_normal_abspath_altnamespace=
946300bf1aeSmrg    case $func_normal_abspath_tpath in
947300bf1aeSmrg      "")
948300bf1aeSmrg        # Empty path, that just means $cwd.
949300bf1aeSmrg        func_stripname '' '/' "`pwd`"
950300bf1aeSmrg        func_normal_abspath_result=$func_stripname_result
951300bf1aeSmrg        return
952300bf1aeSmrg        ;;
953300bf1aeSmrg      # The next three entries are used to spot a run of precisely
954300bf1aeSmrg      # two leading slashes without using negated character classes;
955300bf1aeSmrg      # we take advantage of case's first-match behaviour.
956300bf1aeSmrg      ///*)
957300bf1aeSmrg        # Unusual form of absolute path, do nothing.
958300bf1aeSmrg        ;;
959300bf1aeSmrg      //*)
960300bf1aeSmrg        # Not necessarily an ordinary path; POSIX reserves leading '//'
961300bf1aeSmrg        # and for example Cygwin uses it to access remote file shares
962300bf1aeSmrg        # over CIFS/SMB, so we conserve a leading double slash if found.
963300bf1aeSmrg        func_normal_abspath_altnamespace=/
964300bf1aeSmrg        ;;
965300bf1aeSmrg      /*)
966300bf1aeSmrg        # Absolute path, do nothing.
9676aec45a7Smrg        ;;
9686aec45a7Smrg      *)
969300bf1aeSmrg        # Relative path, prepend $cwd.
970300bf1aeSmrg        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
971300bf1aeSmrg        ;;
972ab47cfaaSmrg    esac
973300bf1aeSmrg
974300bf1aeSmrg    # Cancel out all the simple stuff to save iterations.  We also want
975300bf1aeSmrg    # the path to end with a slash for ease of parsing, so make sure
976300bf1aeSmrg    # there is one (and only one) here.
977300bf1aeSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
978300bf1aeSmrg          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
979300bf1aeSmrg    while :; do
980300bf1aeSmrg      # Processed it all yet?
981300bf1aeSmrg      if test / = "$func_normal_abspath_tpath"; then
982300bf1aeSmrg        # If we ascended to the root using ".." the result may be empty now.
983300bf1aeSmrg        if test -z "$func_normal_abspath_result"; then
984300bf1aeSmrg          func_normal_abspath_result=/
985300bf1aeSmrg        fi
986300bf1aeSmrg        break
987300bf1aeSmrg      fi
988300bf1aeSmrg      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
989300bf1aeSmrg          -e "$_G_pathcar"`
990300bf1aeSmrg      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
991300bf1aeSmrg          -e "$_G_pathcdr"`
992300bf1aeSmrg      # Figure out what to do with it
993300bf1aeSmrg      case $func_normal_abspath_tcomponent in
994300bf1aeSmrg        "")
995300bf1aeSmrg          # Trailing empty path component, ignore it.
996300bf1aeSmrg          ;;
997300bf1aeSmrg        ..)
998300bf1aeSmrg          # Parent dir; strip last assembled component from result.
999300bf1aeSmrg          func_dirname "$func_normal_abspath_result"
1000300bf1aeSmrg          func_normal_abspath_result=$func_dirname_result
1001300bf1aeSmrg          ;;
1002300bf1aeSmrg        *)
1003300bf1aeSmrg          # Actual path component, append it.
1004300bf1aeSmrg          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1005300bf1aeSmrg          ;;
1006300bf1aeSmrg      esac
1007300bf1aeSmrg    done
1008300bf1aeSmrg    # Restore leading double-slash if one was found on entry.
1009300bf1aeSmrg    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1010300bf1aeSmrg}
1011300bf1aeSmrg
1012300bf1aeSmrg
1013300bf1aeSmrg# func_notquiet ARG...
1014300bf1aeSmrg# --------------------
1015300bf1aeSmrg# Echo program name prefixed message only when not in quiet mode.
1016300bf1aeSmrgfunc_notquiet ()
1017300bf1aeSmrg{
1018300bf1aeSmrg    $debug_cmd
1019300bf1aeSmrg
1020300bf1aeSmrg    $opt_quiet || func_echo ${1+"$@"}
1021300bf1aeSmrg
1022300bf1aeSmrg    # A bug in bash halts the script if the last line of a function
1023300bf1aeSmrg    # fails when set -e is in force, so we need another command to
1024300bf1aeSmrg    # work around that:
1025300bf1aeSmrg    :
1026300bf1aeSmrg}
1027300bf1aeSmrg
1028300bf1aeSmrg
1029300bf1aeSmrg# func_relative_path SRCDIR DSTDIR
1030300bf1aeSmrg# --------------------------------
1031300bf1aeSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1032300bf1aeSmrgfunc_relative_path ()
1033300bf1aeSmrg{
1034300bf1aeSmrg    $debug_cmd
1035300bf1aeSmrg
1036300bf1aeSmrg    func_relative_path_result=
1037300bf1aeSmrg    func_normal_abspath "$1"
1038300bf1aeSmrg    func_relative_path_tlibdir=$func_normal_abspath_result
1039300bf1aeSmrg    func_normal_abspath "$2"
1040300bf1aeSmrg    func_relative_path_tbindir=$func_normal_abspath_result
1041300bf1aeSmrg
1042300bf1aeSmrg    # Ascend the tree starting from libdir
1043300bf1aeSmrg    while :; do
1044300bf1aeSmrg      # check if we have found a prefix of bindir
1045300bf1aeSmrg      case $func_relative_path_tbindir in
1046300bf1aeSmrg        $func_relative_path_tlibdir)
1047300bf1aeSmrg          # found an exact match
1048300bf1aeSmrg          func_relative_path_tcancelled=
1049300bf1aeSmrg          break
1050300bf1aeSmrg          ;;
1051300bf1aeSmrg        $func_relative_path_tlibdir*)
1052300bf1aeSmrg          # found a matching prefix
1053300bf1aeSmrg          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1054300bf1aeSmrg          func_relative_path_tcancelled=$func_stripname_result
1055300bf1aeSmrg          if test -z "$func_relative_path_result"; then
1056300bf1aeSmrg            func_relative_path_result=.
1057300bf1aeSmrg          fi
1058300bf1aeSmrg          break
1059300bf1aeSmrg          ;;
1060300bf1aeSmrg        *)
1061300bf1aeSmrg          func_dirname $func_relative_path_tlibdir
1062300bf1aeSmrg          func_relative_path_tlibdir=$func_dirname_result
1063300bf1aeSmrg          if test -z "$func_relative_path_tlibdir"; then
1064300bf1aeSmrg            # Have to descend all the way to the root!
1065300bf1aeSmrg            func_relative_path_result=../$func_relative_path_result
1066300bf1aeSmrg            func_relative_path_tcancelled=$func_relative_path_tbindir
1067300bf1aeSmrg            break
1068300bf1aeSmrg          fi
1069300bf1aeSmrg          func_relative_path_result=../$func_relative_path_result
1070300bf1aeSmrg          ;;
1071300bf1aeSmrg      esac
1072300bf1aeSmrg    done
1073300bf1aeSmrg
1074300bf1aeSmrg    # Now calculate path; take care to avoid doubling-up slashes.
1075300bf1aeSmrg    func_stripname '' '/' "$func_relative_path_result"
1076300bf1aeSmrg    func_relative_path_result=$func_stripname_result
1077300bf1aeSmrg    func_stripname '/' '/' "$func_relative_path_tcancelled"
1078300bf1aeSmrg    if test -n "$func_stripname_result"; then
1079300bf1aeSmrg      func_append func_relative_path_result "/$func_stripname_result"
1080300bf1aeSmrg    fi
1081300bf1aeSmrg
1082300bf1aeSmrg    # Normalisation. If bindir is libdir, return '.' else relative path.
1083300bf1aeSmrg    if test -n "$func_relative_path_result"; then
1084300bf1aeSmrg      func_stripname './' '' "$func_relative_path_result"
1085300bf1aeSmrg      func_relative_path_result=$func_stripname_result
1086300bf1aeSmrg    fi
1087300bf1aeSmrg
1088300bf1aeSmrg    test -n "$func_relative_path_result" || func_relative_path_result=.
1089300bf1aeSmrg
1090300bf1aeSmrg    :
1091ab47cfaaSmrg}
1092ab47cfaaSmrg
1093ab47cfaaSmrg
1094300bf1aeSmrg# func_quote_for_eval ARG...
1095300bf1aeSmrg# --------------------------
1096300bf1aeSmrg# Aesthetically quote ARGs to be evaled later.
1097300bf1aeSmrg# This function returns two values:
1098300bf1aeSmrg#   i) func_quote_for_eval_result
1099300bf1aeSmrg#      double-quoted, suitable for a subsequent eval
1100300bf1aeSmrg#  ii) func_quote_for_eval_unquoted_result
1101300bf1aeSmrg#      has all characters that are still active within double
1102300bf1aeSmrg#      quotes backslashified.
1103300bf1aeSmrgfunc_quote_for_eval ()
1104300bf1aeSmrg{
1105300bf1aeSmrg    $debug_cmd
1106300bf1aeSmrg
1107300bf1aeSmrg    func_quote_for_eval_unquoted_result=
1108300bf1aeSmrg    func_quote_for_eval_result=
1109300bf1aeSmrg    while test 0 -lt $#; do
1110300bf1aeSmrg      case $1 in
1111300bf1aeSmrg        *[\\\`\"\$]*)
1112300bf1aeSmrg	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
1113300bf1aeSmrg        *)
1114300bf1aeSmrg          _G_unquoted_arg=$1 ;;
1115300bf1aeSmrg      esac
1116300bf1aeSmrg      if test -n "$func_quote_for_eval_unquoted_result"; then
1117300bf1aeSmrg	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1118300bf1aeSmrg      else
1119300bf1aeSmrg        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1120300bf1aeSmrg      fi
1121300bf1aeSmrg
1122300bf1aeSmrg      case $_G_unquoted_arg in
1123300bf1aeSmrg        # Double-quote args containing shell metacharacters to delay
1124300bf1aeSmrg        # word splitting, command substitution and variable expansion
1125300bf1aeSmrg        # for a subsequent eval.
1126300bf1aeSmrg        # Many Bourne shells cannot handle close brackets correctly
1127300bf1aeSmrg        # in scan sets, so we specify it separately.
1128300bf1aeSmrg        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1129300bf1aeSmrg          _G_quoted_arg=\"$_G_unquoted_arg\"
1130300bf1aeSmrg          ;;
1131300bf1aeSmrg        *)
1132300bf1aeSmrg          _G_quoted_arg=$_G_unquoted_arg
1133300bf1aeSmrg	  ;;
1134300bf1aeSmrg      esac
1135300bf1aeSmrg
1136300bf1aeSmrg      if test -n "$func_quote_for_eval_result"; then
1137300bf1aeSmrg	func_append func_quote_for_eval_result " $_G_quoted_arg"
1138300bf1aeSmrg      else
1139300bf1aeSmrg        func_append func_quote_for_eval_result "$_G_quoted_arg"
1140300bf1aeSmrg      fi
1141300bf1aeSmrg      shift
1142300bf1aeSmrg    done
1143300bf1aeSmrg}
1144300bf1aeSmrg
1145300bf1aeSmrg
1146300bf1aeSmrg# func_quote_for_expand ARG
1147300bf1aeSmrg# -------------------------
11486aec45a7Smrg# Aesthetically quote ARG to be evaled later; same as above,
11496aec45a7Smrg# but do not quote variable references.
11506aec45a7Smrgfunc_quote_for_expand ()
1151ab47cfaaSmrg{
1152300bf1aeSmrg    $debug_cmd
1153300bf1aeSmrg
11546aec45a7Smrg    case $1 in
11556aec45a7Smrg      *[\\\`\"]*)
1156300bf1aeSmrg	_G_arg=`$ECHO "$1" | $SED \
1157300bf1aeSmrg	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
1158ab47cfaaSmrg      *)
1159300bf1aeSmrg        _G_arg=$1 ;;
11606aec45a7Smrg    esac
11616aec45a7Smrg
1162300bf1aeSmrg    case $_G_arg in
11636aec45a7Smrg      # Double-quote args containing shell metacharacters to delay
11646aec45a7Smrg      # word splitting and command substitution for a subsequent eval.
11656aec45a7Smrg      # Many Bourne shells cannot handle close brackets correctly
11666aec45a7Smrg      # in scan sets, so we specify it separately.
11676aec45a7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1168300bf1aeSmrg        _G_arg=\"$_G_arg\"
11696aec45a7Smrg        ;;
11706aec45a7Smrg    esac
11716aec45a7Smrg
1172300bf1aeSmrg    func_quote_for_expand_result=$_G_arg
1173300bf1aeSmrg}
1174300bf1aeSmrg
1175300bf1aeSmrg
1176300bf1aeSmrg# func_stripname PREFIX SUFFIX NAME
1177300bf1aeSmrg# ---------------------------------
1178300bf1aeSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1179300bf1aeSmrg# PREFIX and SUFFIX must not contain globbing or regex special
1180300bf1aeSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
1181300bf1aeSmrg# dot (in which case that matches only a dot).
1182300bf1aeSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
1183300bf1aeSmrg  eval 'func_stripname ()
1184300bf1aeSmrg  {
1185300bf1aeSmrg    $debug_cmd
1186300bf1aeSmrg
1187300bf1aeSmrg    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1188300bf1aeSmrg    # positional parameters, so assign one to ordinary variable first.
1189300bf1aeSmrg    func_stripname_result=$3
1190300bf1aeSmrg    func_stripname_result=${func_stripname_result#"$1"}
1191300bf1aeSmrg    func_stripname_result=${func_stripname_result%"$2"}
1192300bf1aeSmrg  }'
1193300bf1aeSmrgelse
1194300bf1aeSmrg  func_stripname ()
1195300bf1aeSmrg  {
1196300bf1aeSmrg    $debug_cmd
1197300bf1aeSmrg
1198300bf1aeSmrg    case $2 in
1199300bf1aeSmrg      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1200300bf1aeSmrg      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1201300bf1aeSmrg    esac
1202300bf1aeSmrg  }
1203300bf1aeSmrgfi
1204300bf1aeSmrg
1205300bf1aeSmrg
1206300bf1aeSmrg# func_show_eval CMD [FAIL_EXP]
1207300bf1aeSmrg# -----------------------------
1208300bf1aeSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1209300bf1aeSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1210300bf1aeSmrg# is given, then evaluate it.
1211300bf1aeSmrgfunc_show_eval ()
1212300bf1aeSmrg{
1213300bf1aeSmrg    $debug_cmd
1214300bf1aeSmrg
1215300bf1aeSmrg    _G_cmd=$1
1216300bf1aeSmrg    _G_fail_exp=${2-':'}
1217300bf1aeSmrg
1218300bf1aeSmrg    func_quote_for_expand "$_G_cmd"
1219300bf1aeSmrg    eval "func_notquiet $func_quote_for_expand_result"
1220300bf1aeSmrg
1221300bf1aeSmrg    $opt_dry_run || {
1222300bf1aeSmrg      eval "$_G_cmd"
1223300bf1aeSmrg      _G_status=$?
1224300bf1aeSmrg      if test 0 -ne "$_G_status"; then
1225300bf1aeSmrg	eval "(exit $_G_status); $_G_fail_exp"
1226300bf1aeSmrg      fi
1227300bf1aeSmrg    }
1228300bf1aeSmrg}
1229300bf1aeSmrg
1230300bf1aeSmrg
1231300bf1aeSmrg# func_show_eval_locale CMD [FAIL_EXP]
1232300bf1aeSmrg# ------------------------------------
1233300bf1aeSmrg# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
1234300bf1aeSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
1235300bf1aeSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
1236300bf1aeSmrgfunc_show_eval_locale ()
1237300bf1aeSmrg{
1238300bf1aeSmrg    $debug_cmd
1239300bf1aeSmrg
1240300bf1aeSmrg    _G_cmd=$1
1241300bf1aeSmrg    _G_fail_exp=${2-':'}
1242300bf1aeSmrg
1243300bf1aeSmrg    $opt_quiet || {
1244300bf1aeSmrg      func_quote_for_expand "$_G_cmd"
1245300bf1aeSmrg      eval "func_echo $func_quote_for_expand_result"
1246300bf1aeSmrg    }
1247300bf1aeSmrg
1248300bf1aeSmrg    $opt_dry_run || {
1249300bf1aeSmrg      eval "$_G_user_locale
1250300bf1aeSmrg	    $_G_cmd"
1251300bf1aeSmrg      _G_status=$?
1252300bf1aeSmrg      eval "$_G_safe_locale"
1253300bf1aeSmrg      if test 0 -ne "$_G_status"; then
1254300bf1aeSmrg	eval "(exit $_G_status); $_G_fail_exp"
1255300bf1aeSmrg      fi
1256300bf1aeSmrg    }
1257300bf1aeSmrg}
1258300bf1aeSmrg
1259300bf1aeSmrg
1260300bf1aeSmrg# func_tr_sh
1261300bf1aeSmrg# ----------
1262300bf1aeSmrg# Turn $1 into a string suitable for a shell variable name.
1263300bf1aeSmrg# Result is stored in $func_tr_sh_result.  All characters
1264300bf1aeSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1265300bf1aeSmrg# if $1 begins with a digit, a '_' is prepended as well.
1266300bf1aeSmrgfunc_tr_sh ()
1267300bf1aeSmrg{
1268300bf1aeSmrg    $debug_cmd
1269300bf1aeSmrg
1270300bf1aeSmrg    case $1 in
1271300bf1aeSmrg    [0-9]* | *[!a-zA-Z0-9_]*)
1272300bf1aeSmrg      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1273300bf1aeSmrg      ;;
1274300bf1aeSmrg    * )
1275300bf1aeSmrg      func_tr_sh_result=$1
1276300bf1aeSmrg      ;;
1277300bf1aeSmrg    esac
1278300bf1aeSmrg}
1279300bf1aeSmrg
1280300bf1aeSmrg
1281300bf1aeSmrg# func_verbose ARG...
1282300bf1aeSmrg# -------------------
1283300bf1aeSmrg# Echo program name prefixed message in verbose mode only.
1284300bf1aeSmrgfunc_verbose ()
1285300bf1aeSmrg{
1286300bf1aeSmrg    $debug_cmd
1287300bf1aeSmrg
1288300bf1aeSmrg    $opt_verbose && func_echo "$*"
1289300bf1aeSmrg
1290300bf1aeSmrg    :
1291300bf1aeSmrg}
1292300bf1aeSmrg
1293300bf1aeSmrg
1294300bf1aeSmrg# func_warn_and_continue ARG...
1295300bf1aeSmrg# -----------------------------
1296300bf1aeSmrg# Echo program name prefixed warning message to standard error.
1297300bf1aeSmrgfunc_warn_and_continue ()
1298300bf1aeSmrg{
1299300bf1aeSmrg    $debug_cmd
1300300bf1aeSmrg
1301300bf1aeSmrg    $require_term_colors
1302300bf1aeSmrg
1303300bf1aeSmrg    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1304300bf1aeSmrg}
1305300bf1aeSmrg
1306300bf1aeSmrg
1307300bf1aeSmrg# func_warning CATEGORY ARG...
1308300bf1aeSmrg# ----------------------------
1309300bf1aeSmrg# Echo program name prefixed warning message to standard error. Warning
1310300bf1aeSmrg# messages can be filtered according to CATEGORY, where this function
1311300bf1aeSmrg# elides messages where CATEGORY is not listed in the global variable
1312300bf1aeSmrg# 'opt_warning_types'.
1313300bf1aeSmrgfunc_warning ()
1314300bf1aeSmrg{
1315300bf1aeSmrg    $debug_cmd
1316300bf1aeSmrg
1317300bf1aeSmrg    # CATEGORY must be in the warning_categories list!
1318300bf1aeSmrg    case " $warning_categories " in
1319300bf1aeSmrg      *" $1 "*) ;;
1320300bf1aeSmrg      *) func_internal_error "invalid warning category '$1'" ;;
1321300bf1aeSmrg    esac
1322300bf1aeSmrg
1323300bf1aeSmrg    _G_category=$1
1324300bf1aeSmrg    shift
1325300bf1aeSmrg
1326300bf1aeSmrg    case " $opt_warning_types " in
1327300bf1aeSmrg      *" $_G_category "*) $warning_func ${1+"$@"} ;;
1328300bf1aeSmrg    esac
1329ab47cfaaSmrg}
1330ab47cfaaSmrg
1331ab47cfaaSmrg
1332300bf1aeSmrg# func_sort_ver VER1 VER2
1333300bf1aeSmrg# -----------------------
1334300bf1aeSmrg# 'sort -V' is not generally available.
1335300bf1aeSmrg# Note this deviates from the version comparison in automake
1336300bf1aeSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1337300bf1aeSmrg# but this should suffice as we won't be specifying old
1338300bf1aeSmrg# version formats or redundant trailing .0 in bootstrap.conf.
1339300bf1aeSmrg# If we did want full compatibility then we should probably
1340300bf1aeSmrg# use m4_version_compare from autoconf.
1341300bf1aeSmrgfunc_sort_ver ()
1342300bf1aeSmrg{
1343300bf1aeSmrg    $debug_cmd
1344300bf1aeSmrg
1345300bf1aeSmrg    printf '%s\n%s\n' "$1" "$2" \
1346300bf1aeSmrg      | 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
1347300bf1aeSmrg}
1348300bf1aeSmrg
1349300bf1aeSmrg# func_lt_ver PREV CURR
1350300bf1aeSmrg# ---------------------
1351300bf1aeSmrg# Return true if PREV and CURR are in the correct order according to
1352300bf1aeSmrg# func_sort_ver, otherwise false.  Use it like this:
1353300bf1aeSmrg#
1354300bf1aeSmrg#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1355300bf1aeSmrgfunc_lt_ver ()
1356300bf1aeSmrg{
1357300bf1aeSmrg    $debug_cmd
1358300bf1aeSmrg
1359300bf1aeSmrg    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1360300bf1aeSmrg}
1361300bf1aeSmrg
1362300bf1aeSmrg
1363300bf1aeSmrg# Local variables:
1364300bf1aeSmrg# mode: shell-script
1365300bf1aeSmrg# sh-indentation: 2
1366300bf1aeSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1367300bf1aeSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1368300bf1aeSmrg# time-stamp-time-zone: "UTC"
1369300bf1aeSmrg# End:
1370300bf1aeSmrg#! /bin/sh
1371300bf1aeSmrg
1372300bf1aeSmrg# Set a version string for this script.
1373300bf1aeSmrgscriptversion=2014-01-07.03; # UTC
1374300bf1aeSmrg
1375300bf1aeSmrg# A portable, pluggable option parser for Bourne shell.
1376300bf1aeSmrg# Written by Gary V. Vaughan, 2010
1377300bf1aeSmrg
1378300bf1aeSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc.
1379300bf1aeSmrg# This is free software; see the source for copying conditions.  There is NO
1380300bf1aeSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1381300bf1aeSmrg
1382300bf1aeSmrg# This program is free software: you can redistribute it and/or modify
1383300bf1aeSmrg# it under the terms of the GNU General Public License as published by
1384300bf1aeSmrg# the Free Software Foundation, either version 3 of the License, or
1385300bf1aeSmrg# (at your option) any later version.
1386300bf1aeSmrg
1387300bf1aeSmrg# This program is distributed in the hope that it will be useful,
1388300bf1aeSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1389300bf1aeSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1390300bf1aeSmrg# GNU General Public License for more details.
1391300bf1aeSmrg
1392300bf1aeSmrg# You should have received a copy of the GNU General Public License
1393300bf1aeSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
1394300bf1aeSmrg
1395300bf1aeSmrg# Please report bugs or propose patches to gary@gnu.org.
1396300bf1aeSmrg
1397300bf1aeSmrg
1398300bf1aeSmrg## ------ ##
1399300bf1aeSmrg## Usage. ##
1400300bf1aeSmrg## ------ ##
1401300bf1aeSmrg
1402300bf1aeSmrg# This file is a library for parsing options in your shell scripts along
1403300bf1aeSmrg# with assorted other useful supporting features that you can make use
1404300bf1aeSmrg# of too.
1405300bf1aeSmrg#
1406300bf1aeSmrg# For the simplest scripts you might need only:
1407300bf1aeSmrg#
1408300bf1aeSmrg#   #!/bin/sh
1409300bf1aeSmrg#   . relative/path/to/funclib.sh
1410300bf1aeSmrg#   . relative/path/to/options-parser
1411300bf1aeSmrg#   scriptversion=1.0
1412300bf1aeSmrg#   func_options ${1+"$@"}
1413300bf1aeSmrg#   eval set dummy "$func_options_result"; shift
1414300bf1aeSmrg#   ...rest of your script...
1415300bf1aeSmrg#
1416300bf1aeSmrg# In order for the '--version' option to work, you will need to have a
1417300bf1aeSmrg# suitably formatted comment like the one at the top of this file
1418300bf1aeSmrg# starting with '# Written by ' and ending with '# warranty; '.
1419300bf1aeSmrg#
1420300bf1aeSmrg# For '-h' and '--help' to work, you will also need a one line
1421300bf1aeSmrg# description of your script's purpose in a comment directly above the
1422300bf1aeSmrg# '# Written by ' line, like the one at the top of this file.
1423300bf1aeSmrg#
1424300bf1aeSmrg# The default options also support '--debug', which will turn on shell
1425300bf1aeSmrg# execution tracing (see the comment above debug_cmd below for another
1426300bf1aeSmrg# use), and '--verbose' and the func_verbose function to allow your script
1427300bf1aeSmrg# to display verbose messages only when your user has specified
1428300bf1aeSmrg# '--verbose'.
1429300bf1aeSmrg#
1430300bf1aeSmrg# After sourcing this file, you can plug processing for additional
1431300bf1aeSmrg# options by amending the variables from the 'Configuration' section
1432300bf1aeSmrg# below, and following the instructions in the 'Option parsing'
1433300bf1aeSmrg# section further down.
1434300bf1aeSmrg
1435300bf1aeSmrg## -------------- ##
1436300bf1aeSmrg## Configuration. ##
1437300bf1aeSmrg## -------------- ##
1438300bf1aeSmrg
1439300bf1aeSmrg# You should override these variables in your script after sourcing this
1440300bf1aeSmrg# file so that they reflect the customisations you have added to the
1441300bf1aeSmrg# option parser.
1442300bf1aeSmrg
1443300bf1aeSmrg# The usage line for option parsing errors and the start of '-h' and
1444300bf1aeSmrg# '--help' output messages. You can embed shell variables for delayed
1445300bf1aeSmrg# expansion at the time the message is displayed, but you will need to
1446300bf1aeSmrg# quote other shell meta-characters carefully to prevent them being
1447300bf1aeSmrg# expanded when the contents are evaled.
1448300bf1aeSmrgusage='$progpath [OPTION]...'
1449300bf1aeSmrg
1450300bf1aeSmrg# Short help message in response to '-h' and '--help'.  Add to this or
1451300bf1aeSmrg# override it after sourcing this library to reflect the full set of
1452300bf1aeSmrg# options your script accepts.
1453300bf1aeSmrgusage_message="\
1454300bf1aeSmrg       --debug        enable verbose shell tracing
1455300bf1aeSmrg   -W, --warnings=CATEGORY
1456300bf1aeSmrg                      report the warnings falling in CATEGORY [all]
1457300bf1aeSmrg   -v, --verbose      verbosely report processing
1458300bf1aeSmrg       --version      print version information and exit
1459300bf1aeSmrg   -h, --help         print short or long help message and exit
1460300bf1aeSmrg"
1461300bf1aeSmrg
1462300bf1aeSmrg# Additional text appended to 'usage_message' in response to '--help'.
1463300bf1aeSmrglong_help_message="
1464300bf1aeSmrgWarning categories include:
1465300bf1aeSmrg       'all'          show all warnings
1466300bf1aeSmrg       'none'         turn off all the warnings
1467300bf1aeSmrg       'error'        warnings are treated as fatal errors"
1468300bf1aeSmrg
1469300bf1aeSmrg# Help message printed before fatal option parsing errors.
1470300bf1aeSmrgfatal_help="Try '\$progname --help' for more information."
1471300bf1aeSmrg
1472300bf1aeSmrg
1473300bf1aeSmrg
1474300bf1aeSmrg## ------------------------- ##
1475300bf1aeSmrg## Hook function management. ##
1476300bf1aeSmrg## ------------------------- ##
1477300bf1aeSmrg
1478300bf1aeSmrg# This section contains functions for adding, removing, and running hooks
1479300bf1aeSmrg# to the main code.  A hook is just a named list of of function, that can
1480300bf1aeSmrg# be run in order later on.
1481300bf1aeSmrg
1482300bf1aeSmrg# func_hookable FUNC_NAME
1483300bf1aeSmrg# -----------------------
1484300bf1aeSmrg# Declare that FUNC_NAME will run hooks added with
1485300bf1aeSmrg# 'func_add_hook FUNC_NAME ...'.
1486300bf1aeSmrgfunc_hookable ()
1487300bf1aeSmrg{
1488300bf1aeSmrg    $debug_cmd
1489300bf1aeSmrg
1490300bf1aeSmrg    func_append hookable_fns " $1"
1491300bf1aeSmrg}
1492300bf1aeSmrg
1493300bf1aeSmrg
1494300bf1aeSmrg# func_add_hook FUNC_NAME HOOK_FUNC
1495300bf1aeSmrg# ---------------------------------
1496300bf1aeSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
1497300bf1aeSmrg# first have been declared "hookable" by a call to 'func_hookable'.
1498300bf1aeSmrgfunc_add_hook ()
1499300bf1aeSmrg{
1500300bf1aeSmrg    $debug_cmd
1501300bf1aeSmrg
1502300bf1aeSmrg    case " $hookable_fns " in
1503300bf1aeSmrg      *" $1 "*) ;;
1504300bf1aeSmrg      *) func_fatal_error "'$1' does not accept hook functions." ;;
1505300bf1aeSmrg    esac
1506300bf1aeSmrg
1507300bf1aeSmrg    eval func_append ${1}_hooks '" $2"'
1508300bf1aeSmrg}
1509300bf1aeSmrg
1510300bf1aeSmrg
1511300bf1aeSmrg# func_remove_hook FUNC_NAME HOOK_FUNC
1512300bf1aeSmrg# ------------------------------------
1513300bf1aeSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
1514300bf1aeSmrgfunc_remove_hook ()
1515300bf1aeSmrg{
1516300bf1aeSmrg    $debug_cmd
1517300bf1aeSmrg
1518300bf1aeSmrg    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1519300bf1aeSmrg}
1520300bf1aeSmrg
1521300bf1aeSmrg
1522300bf1aeSmrg# func_run_hooks FUNC_NAME [ARG]...
1523300bf1aeSmrg# ---------------------------------
1524300bf1aeSmrg# Run all hook functions registered to FUNC_NAME.
1525300bf1aeSmrg# It is assumed that the list of hook functions contains nothing more
1526300bf1aeSmrg# than a whitespace-delimited list of legal shell function names, and
1527300bf1aeSmrg# no effort is wasted trying to catch shell meta-characters or preserve
1528300bf1aeSmrg# whitespace.
1529300bf1aeSmrgfunc_run_hooks ()
1530300bf1aeSmrg{
1531300bf1aeSmrg    $debug_cmd
1532300bf1aeSmrg
1533300bf1aeSmrg    case " $hookable_fns " in
1534300bf1aeSmrg      *" $1 "*) ;;
1535300bf1aeSmrg      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
1536300bf1aeSmrg    esac
1537300bf1aeSmrg
1538300bf1aeSmrg    eval _G_hook_fns=\$$1_hooks; shift
1539300bf1aeSmrg
1540300bf1aeSmrg    for _G_hook in $_G_hook_fns; do
1541300bf1aeSmrg      eval $_G_hook '"$@"'
1542300bf1aeSmrg
1543300bf1aeSmrg      # store returned options list back into positional
1544300bf1aeSmrg      # parameters for next 'cmd' execution.
1545300bf1aeSmrg      eval _G_hook_result=\$${_G_hook}_result
1546300bf1aeSmrg      eval set dummy "$_G_hook_result"; shift
1547300bf1aeSmrg    done
1548300bf1aeSmrg
1549300bf1aeSmrg    func_quote_for_eval ${1+"$@"}
1550300bf1aeSmrg    func_run_hooks_result=$func_quote_for_eval_result
1551300bf1aeSmrg}
1552300bf1aeSmrg
1553300bf1aeSmrg
1554300bf1aeSmrg
1555300bf1aeSmrg## --------------- ##
1556300bf1aeSmrg## Option parsing. ##
1557300bf1aeSmrg## --------------- ##
1558300bf1aeSmrg
1559300bf1aeSmrg# In order to add your own option parsing hooks, you must accept the
1560300bf1aeSmrg# full positional parameter list in your hook function, remove any
1561300bf1aeSmrg# options that you action, and then pass back the remaining unprocessed
1562300bf1aeSmrg# options in '<hooked_function_name>_result', escaped suitably for
1563300bf1aeSmrg# 'eval'.  Like this:
1564300bf1aeSmrg#
1565300bf1aeSmrg#    my_options_prep ()
1566300bf1aeSmrg#    {
1567300bf1aeSmrg#        $debug_cmd
1568300bf1aeSmrg#
1569300bf1aeSmrg#        # Extend the existing usage message.
1570300bf1aeSmrg#        usage_message=$usage_message'
1571300bf1aeSmrg#      -s, --silent       don'\''t print informational messages
1572300bf1aeSmrg#    '
1573300bf1aeSmrg#
1574300bf1aeSmrg#        func_quote_for_eval ${1+"$@"}
1575300bf1aeSmrg#        my_options_prep_result=$func_quote_for_eval_result
1576300bf1aeSmrg#    }
1577300bf1aeSmrg#    func_add_hook func_options_prep my_options_prep
1578300bf1aeSmrg#
1579300bf1aeSmrg#
1580300bf1aeSmrg#    my_silent_option ()
1581300bf1aeSmrg#    {
1582300bf1aeSmrg#        $debug_cmd
1583300bf1aeSmrg#
1584300bf1aeSmrg#        # Note that for efficiency, we parse as many options as we can
1585300bf1aeSmrg#        # recognise in a loop before passing the remainder back to the
1586300bf1aeSmrg#        # caller on the first unrecognised argument we encounter.
1587300bf1aeSmrg#        while test $# -gt 0; do
1588300bf1aeSmrg#          opt=$1; shift
1589300bf1aeSmrg#          case $opt in
1590300bf1aeSmrg#            --silent|-s) opt_silent=: ;;
1591300bf1aeSmrg#            # Separate non-argument short options:
1592300bf1aeSmrg#            -s*)         func_split_short_opt "$_G_opt"
1593300bf1aeSmrg#                         set dummy "$func_split_short_opt_name" \
1594300bf1aeSmrg#                             "-$func_split_short_opt_arg" ${1+"$@"}
1595300bf1aeSmrg#                         shift
1596300bf1aeSmrg#                         ;;
1597300bf1aeSmrg#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
1598300bf1aeSmrg#          esac
1599300bf1aeSmrg#        done
1600300bf1aeSmrg#
1601300bf1aeSmrg#        func_quote_for_eval ${1+"$@"}
1602300bf1aeSmrg#        my_silent_option_result=$func_quote_for_eval_result
1603300bf1aeSmrg#    }
1604300bf1aeSmrg#    func_add_hook func_parse_options my_silent_option
1605300bf1aeSmrg#
1606300bf1aeSmrg#
1607300bf1aeSmrg#    my_option_validation ()
1608300bf1aeSmrg#    {
1609300bf1aeSmrg#        $debug_cmd
1610300bf1aeSmrg#
1611300bf1aeSmrg#        $opt_silent && $opt_verbose && func_fatal_help "\
1612300bf1aeSmrg#    '--silent' and '--verbose' options are mutually exclusive."
1613300bf1aeSmrg#
1614300bf1aeSmrg#        func_quote_for_eval ${1+"$@"}
1615300bf1aeSmrg#        my_option_validation_result=$func_quote_for_eval_result
1616300bf1aeSmrg#    }
1617300bf1aeSmrg#    func_add_hook func_validate_options my_option_validation
1618300bf1aeSmrg#
1619300bf1aeSmrg# You'll alse need to manually amend $usage_message to reflect the extra
1620300bf1aeSmrg# options you parse.  It's preferable to append if you can, so that
1621300bf1aeSmrg# multiple option parsing hooks can be added safely.
1622300bf1aeSmrg
1623300bf1aeSmrg
1624300bf1aeSmrg# func_options [ARG]...
1625300bf1aeSmrg# ---------------------
1626300bf1aeSmrg# All the functions called inside func_options are hookable. See the
1627300bf1aeSmrg# individual implementations for details.
1628300bf1aeSmrgfunc_hookable func_options
1629300bf1aeSmrgfunc_options ()
1630ab47cfaaSmrg{
1631300bf1aeSmrg    $debug_cmd
16321473d951Smrg
1633300bf1aeSmrg    func_options_prep ${1+"$@"}
1634300bf1aeSmrg    eval func_parse_options \
1635300bf1aeSmrg        ${func_options_prep_result+"$func_options_prep_result"}
1636300bf1aeSmrg    eval func_validate_options \
1637300bf1aeSmrg        ${func_parse_options_result+"$func_parse_options_result"}
16386aec45a7Smrg
1639300bf1aeSmrg    eval func_run_hooks func_options \
1640300bf1aeSmrg        ${func_validate_options_result+"$func_validate_options_result"}
1641300bf1aeSmrg
1642300bf1aeSmrg    # save modified positional parameters for caller
1643300bf1aeSmrg    func_options_result=$func_run_hooks_result
1644ab47cfaaSmrg}
1645ab47cfaaSmrg
16466aec45a7Smrg
1647300bf1aeSmrg# func_options_prep [ARG]...
1648300bf1aeSmrg# --------------------------
1649300bf1aeSmrg# All initialisations required before starting the option parse loop.
1650300bf1aeSmrg# Note that when calling hook functions, we pass through the list of
1651300bf1aeSmrg# positional parameters.  If a hook function modifies that list, and
1652300bf1aeSmrg# needs to propogate that back to rest of this script, then the complete
1653300bf1aeSmrg# modified list must be put in 'func_run_hooks_result' before
1654300bf1aeSmrg# returning.
1655300bf1aeSmrgfunc_hookable func_options_prep
1656300bf1aeSmrgfunc_options_prep ()
1657ab47cfaaSmrg{
1658300bf1aeSmrg    $debug_cmd
1659ab47cfaaSmrg
1660300bf1aeSmrg    # Option defaults:
1661300bf1aeSmrg    opt_verbose=false
1662300bf1aeSmrg    opt_warning_types=
16631473d951Smrg
1664300bf1aeSmrg    func_run_hooks func_options_prep ${1+"$@"}
1665300bf1aeSmrg
1666300bf1aeSmrg    # save modified positional parameters for caller
1667300bf1aeSmrg    func_options_prep_result=$func_run_hooks_result
1668ab47cfaaSmrg}
1669ab47cfaaSmrg
1670300bf1aeSmrg
1671300bf1aeSmrg# func_parse_options [ARG]...
1672300bf1aeSmrg# ---------------------------
1673300bf1aeSmrg# The main option parsing loop.
1674300bf1aeSmrgfunc_hookable func_parse_options
1675300bf1aeSmrgfunc_parse_options ()
1676aa9e3350Smrg{
1677300bf1aeSmrg    $debug_cmd
1678300bf1aeSmrg
1679300bf1aeSmrg    func_parse_options_result=
1680300bf1aeSmrg
1681300bf1aeSmrg    # this just eases exit handling
1682300bf1aeSmrg    while test $# -gt 0; do
1683300bf1aeSmrg      # Defer to hook functions for initial option parsing, so they
1684300bf1aeSmrg      # get priority in the event of reusing an option name.
1685300bf1aeSmrg      func_run_hooks func_parse_options ${1+"$@"}
1686300bf1aeSmrg
1687300bf1aeSmrg      # Adjust func_parse_options positional parameters to match
1688300bf1aeSmrg      eval set dummy "$func_run_hooks_result"; shift
1689300bf1aeSmrg
1690300bf1aeSmrg      # Break out of the loop if we already parsed every option.
1691300bf1aeSmrg      test $# -gt 0 || break
1692300bf1aeSmrg
1693300bf1aeSmrg      _G_opt=$1
1694300bf1aeSmrg      shift
1695300bf1aeSmrg      case $_G_opt in
1696300bf1aeSmrg        --debug|-x)   debug_cmd='set -x'
1697300bf1aeSmrg                      func_echo "enabling shell trace mode"
1698300bf1aeSmrg                      $debug_cmd
1699300bf1aeSmrg                      ;;
1700300bf1aeSmrg
1701300bf1aeSmrg        --no-warnings|--no-warning|--no-warn)
1702300bf1aeSmrg                      set dummy --warnings none ${1+"$@"}
1703300bf1aeSmrg                      shift
1704300bf1aeSmrg		      ;;
1705300bf1aeSmrg
1706300bf1aeSmrg        --warnings|--warning|-W)
1707300bf1aeSmrg                      test $# = 0 && func_missing_arg $_G_opt && break
1708300bf1aeSmrg                      case " $warning_categories $1" in
1709300bf1aeSmrg                        *" $1 "*)
1710300bf1aeSmrg                          # trailing space prevents matching last $1 above
1711300bf1aeSmrg                          func_append_uniq opt_warning_types " $1"
1712300bf1aeSmrg                          ;;
1713300bf1aeSmrg                        *all)
1714300bf1aeSmrg                          opt_warning_types=$warning_categories
1715300bf1aeSmrg                          ;;
1716300bf1aeSmrg                        *none)
1717300bf1aeSmrg                          opt_warning_types=none
1718300bf1aeSmrg                          warning_func=:
1719300bf1aeSmrg                          ;;
1720300bf1aeSmrg                        *error)
1721300bf1aeSmrg                          opt_warning_types=$warning_categories
1722300bf1aeSmrg                          warning_func=func_fatal_error
1723300bf1aeSmrg                          ;;
1724300bf1aeSmrg                        *)
1725300bf1aeSmrg                          func_fatal_error \
1726300bf1aeSmrg                             "unsupported warning category: '$1'"
1727300bf1aeSmrg                          ;;
1728300bf1aeSmrg                      esac
1729300bf1aeSmrg                      shift
1730300bf1aeSmrg                      ;;
1731300bf1aeSmrg
1732300bf1aeSmrg        --verbose|-v) opt_verbose=: ;;
1733300bf1aeSmrg        --version)    func_version ;;
1734300bf1aeSmrg        -\?|-h)       func_usage ;;
1735300bf1aeSmrg        --help)       func_help ;;
1736300bf1aeSmrg
1737300bf1aeSmrg	# Separate optargs to long options (plugins may need this):
1738300bf1aeSmrg	--*=*)        func_split_equals "$_G_opt"
1739300bf1aeSmrg	              set dummy "$func_split_equals_lhs" \
1740300bf1aeSmrg                          "$func_split_equals_rhs" ${1+"$@"}
1741300bf1aeSmrg                      shift
1742300bf1aeSmrg                      ;;
1743300bf1aeSmrg
1744300bf1aeSmrg       # Separate optargs to short options:
1745300bf1aeSmrg        -W*)
1746300bf1aeSmrg                      func_split_short_opt "$_G_opt"
1747300bf1aeSmrg                      set dummy "$func_split_short_opt_name" \
1748300bf1aeSmrg                          "$func_split_short_opt_arg" ${1+"$@"}
1749300bf1aeSmrg                      shift
1750300bf1aeSmrg                      ;;
1751300bf1aeSmrg
1752300bf1aeSmrg        # Separate non-argument short options:
1753300bf1aeSmrg        -\?*|-h*|-v*|-x*)
1754300bf1aeSmrg                      func_split_short_opt "$_G_opt"
1755300bf1aeSmrg                      set dummy "$func_split_short_opt_name" \
1756300bf1aeSmrg                          "-$func_split_short_opt_arg" ${1+"$@"}
1757300bf1aeSmrg                      shift
1758300bf1aeSmrg                      ;;
1759300bf1aeSmrg
1760300bf1aeSmrg        --)           break ;;
1761300bf1aeSmrg        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
1762300bf1aeSmrg        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1763300bf1aeSmrg      esac
1764300bf1aeSmrg    done
1765300bf1aeSmrg
1766300bf1aeSmrg    # save modified positional parameters for caller
1767300bf1aeSmrg    func_quote_for_eval ${1+"$@"}
1768300bf1aeSmrg    func_parse_options_result=$func_quote_for_eval_result
1769aa9e3350Smrg}
1770aa9e3350Smrg
17711473d951Smrg
1772300bf1aeSmrg# func_validate_options [ARG]...
1773300bf1aeSmrg# ------------------------------
1774300bf1aeSmrg# Perform any sanity checks on option settings and/or unconsumed
1775300bf1aeSmrg# arguments.
1776300bf1aeSmrgfunc_hookable func_validate_options
1777300bf1aeSmrgfunc_validate_options ()
17786aec45a7Smrg{
1779300bf1aeSmrg    $debug_cmd
1780aa9e3350Smrg
1781300bf1aeSmrg    # Display all warnings if -W was not given.
1782300bf1aeSmrg    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1783300bf1aeSmrg
1784300bf1aeSmrg    func_run_hooks func_validate_options ${1+"$@"}
1785300bf1aeSmrg
1786300bf1aeSmrg    # Bail if the options were screwed!
1787300bf1aeSmrg    $exit_cmd $EXIT_FAILURE
1788300bf1aeSmrg
1789300bf1aeSmrg    # save modified positional parameters for caller
1790300bf1aeSmrg    func_validate_options_result=$func_run_hooks_result
17916aec45a7Smrg}
17921473d951Smrg
1793300bf1aeSmrg
1794300bf1aeSmrg
1795300bf1aeSmrg## ----------------- ##
1796300bf1aeSmrg## Helper functions. ##
1797300bf1aeSmrg## ----------------- ##
1798300bf1aeSmrg
1799300bf1aeSmrg# This section contains the helper functions used by the rest of the
1800300bf1aeSmrg# hookable option parser framework in ascii-betical order.
1801300bf1aeSmrg
1802300bf1aeSmrg
1803300bf1aeSmrg# func_fatal_help ARG...
1804300bf1aeSmrg# ----------------------
1805300bf1aeSmrg# Echo program name prefixed message to standard error, followed by
1806300bf1aeSmrg# a help hint, and exit.
1807300bf1aeSmrgfunc_fatal_help ()
18086aec45a7Smrg{
1809300bf1aeSmrg    $debug_cmd
1810aa9e3350Smrg
1811300bf1aeSmrg    eval \$ECHO \""Usage: $usage"\"
1812300bf1aeSmrg    eval \$ECHO \""$fatal_help"\"
1813300bf1aeSmrg    func_error ${1+"$@"}
1814300bf1aeSmrg    exit $EXIT_FAILURE
18156aec45a7Smrg}
1816ab47cfaaSmrg
1817300bf1aeSmrg
1818300bf1aeSmrg# func_help
1819300bf1aeSmrg# ---------
1820300bf1aeSmrg# Echo long help message to standard output and exit.
18216aec45a7Smrgfunc_help ()
18226aec45a7Smrg{
1823300bf1aeSmrg    $debug_cmd
1824300bf1aeSmrg
1825300bf1aeSmrg    func_usage_message
1826300bf1aeSmrg    $ECHO "$long_help_message"
1827300bf1aeSmrg    exit 0
18286aec45a7Smrg}
1829ab47cfaaSmrg
1830300bf1aeSmrg
1831300bf1aeSmrg# func_missing_arg ARGNAME
1832300bf1aeSmrg# ------------------------
18336aec45a7Smrg# Echo program name prefixed message to standard error and set global
18346aec45a7Smrg# exit_cmd.
18356aec45a7Smrgfunc_missing_arg ()
18366aec45a7Smrg{
1837300bf1aeSmrg    $debug_cmd
1838aa9e3350Smrg
1839300bf1aeSmrg    func_error "Missing argument for '$1'."
18406aec45a7Smrg    exit_cmd=exit
18416aec45a7Smrg}
1842ab47cfaaSmrg
18431473d951Smrg
1844300bf1aeSmrg# func_split_equals STRING
1845300bf1aeSmrg# ------------------------
1846300bf1aeSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
1847300bf1aeSmrg# splitting STRING at the '=' sign.
1848300bf1aeSmrgtest -z "$_G_HAVE_XSI_OPS" \
1849300bf1aeSmrg    && (eval 'x=a/b/c;
1850300bf1aeSmrg      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1851300bf1aeSmrg    && _G_HAVE_XSI_OPS=yes
1852300bf1aeSmrg
1853300bf1aeSmrgif test yes = "$_G_HAVE_XSI_OPS"
1854300bf1aeSmrgthen
1855300bf1aeSmrg  # This is an XSI compatible shell, allowing a faster implementation...
1856300bf1aeSmrg  eval 'func_split_equals ()
1857300bf1aeSmrg  {
1858300bf1aeSmrg      $debug_cmd
1859300bf1aeSmrg
1860300bf1aeSmrg      func_split_equals_lhs=${1%%=*}
1861300bf1aeSmrg      func_split_equals_rhs=${1#*=}
1862300bf1aeSmrg      test "x$func_split_equals_lhs" = "x$1" \
1863300bf1aeSmrg        && func_split_equals_rhs=
1864300bf1aeSmrg  }'
1865300bf1aeSmrgelse
1866300bf1aeSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
1867300bf1aeSmrg  func_split_equals ()
1868300bf1aeSmrg  {
1869300bf1aeSmrg      $debug_cmd
1870300bf1aeSmrg
1871300bf1aeSmrg      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
1872300bf1aeSmrg      func_split_equals_rhs=
1873300bf1aeSmrg      test "x$func_split_equals_lhs" = "x$1" \
1874300bf1aeSmrg        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
1875300bf1aeSmrg  }
1876300bf1aeSmrgfi #func_split_equals
1877300bf1aeSmrg
1878300bf1aeSmrg
1879300bf1aeSmrg# func_split_short_opt SHORTOPT
1880300bf1aeSmrg# -----------------------------
1881aa9e3350Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
1882aa9e3350Smrg# variables after splitting SHORTOPT after the 2nd character.
1883300bf1aeSmrgif test yes = "$_G_HAVE_XSI_OPS"
1884300bf1aeSmrgthen
1885300bf1aeSmrg  # This is an XSI compatible shell, allowing a faster implementation...
1886300bf1aeSmrg  eval 'func_split_short_opt ()
1887300bf1aeSmrg  {
1888300bf1aeSmrg      $debug_cmd
1889300bf1aeSmrg
1890300bf1aeSmrg      func_split_short_opt_arg=${1#??}
1891300bf1aeSmrg      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1892300bf1aeSmrg  }'
1893300bf1aeSmrgelse
1894300bf1aeSmrg  # ...otherwise fall back to using expr, which is often a shell builtin.
1895300bf1aeSmrg  func_split_short_opt ()
1896300bf1aeSmrg  {
1897300bf1aeSmrg      $debug_cmd
1898300bf1aeSmrg
1899300bf1aeSmrg      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
1900300bf1aeSmrg      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
1901300bf1aeSmrg  }
1902300bf1aeSmrgfi #func_split_short_opt
1903300bf1aeSmrg
1904300bf1aeSmrg
1905300bf1aeSmrg# func_usage
1906300bf1aeSmrg# ----------
1907300bf1aeSmrg# Echo short help message to standard output and exit.
1908300bf1aeSmrgfunc_usage ()
1909aa9e3350Smrg{
1910300bf1aeSmrg    $debug_cmd
1911aa9e3350Smrg
1912300bf1aeSmrg    func_usage_message
1913300bf1aeSmrg    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
1914300bf1aeSmrg    exit 0
1915300bf1aeSmrg}
1916aa9e3350Smrg
1917aa9e3350Smrg
1918300bf1aeSmrg# func_usage_message
1919300bf1aeSmrg# ------------------
1920300bf1aeSmrg# Echo short help message to standard output.
1921300bf1aeSmrgfunc_usage_message ()
1922aa9e3350Smrg{
1923300bf1aeSmrg    $debug_cmd
1924aa9e3350Smrg
1925300bf1aeSmrg    eval \$ECHO \""Usage: $usage"\"
1926300bf1aeSmrg    echo
1927300bf1aeSmrg    $SED -n 's|^# ||
1928300bf1aeSmrg        /^Written by/{
1929300bf1aeSmrg          x;p;x
1930300bf1aeSmrg        }
1931300bf1aeSmrg	h
1932300bf1aeSmrg	/^Written by/q' < "$progpath"
1933300bf1aeSmrg    echo
1934300bf1aeSmrg    eval \$ECHO \""$usage_message"\"
1935300bf1aeSmrg}
1936aa9e3350Smrg
1937ab47cfaaSmrg
1938300bf1aeSmrg# func_version
1939300bf1aeSmrg# ------------
1940300bf1aeSmrg# Echo version message to standard output and exit.
1941300bf1aeSmrgfunc_version ()
1942300bf1aeSmrg{
1943300bf1aeSmrg    $debug_cmd
19448697ee19Smrg
1945300bf1aeSmrg    printf '%s\n' "$progname $scriptversion"
1946300bf1aeSmrg    $SED -n '
1947300bf1aeSmrg        /(C)/!b go
1948300bf1aeSmrg        :more
1949300bf1aeSmrg        /\./!{
1950300bf1aeSmrg          N
1951300bf1aeSmrg          s|\n# | |
1952300bf1aeSmrg          b more
1953300bf1aeSmrg        }
1954300bf1aeSmrg        :go
1955300bf1aeSmrg        /^# Written by /,/# warranty; / {
1956300bf1aeSmrg          s|^# ||
1957300bf1aeSmrg          s|^# *$||
1958300bf1aeSmrg          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
1959300bf1aeSmrg          p
1960300bf1aeSmrg        }
1961300bf1aeSmrg        /^# Written by / {
1962300bf1aeSmrg          s|^# ||
1963300bf1aeSmrg          p
1964300bf1aeSmrg        }
1965300bf1aeSmrg        /^warranty; /q' < "$progpath"
19661473d951Smrg
1967300bf1aeSmrg    exit $?
1968300bf1aeSmrg}
1969ab47cfaaSmrg
19706aec45a7Smrg
1971300bf1aeSmrg# Local variables:
1972300bf1aeSmrg# mode: shell-script
1973300bf1aeSmrg# sh-indentation: 2
1974300bf1aeSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1975300bf1aeSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1976300bf1aeSmrg# time-stamp-time-zone: "UTC"
1977300bf1aeSmrg# End:
19786aec45a7Smrg
1979300bf1aeSmrg# Set a version string.
1980300bf1aeSmrgscriptversion='(GNU libtool) 2.4.6'
19816aec45a7Smrg
19826aec45a7Smrg
1983300bf1aeSmrg# func_echo ARG...
1984300bf1aeSmrg# ----------------
1985300bf1aeSmrg# Libtool also displays the current mode in messages, so override
1986300bf1aeSmrg# funclib.sh func_echo with this custom definition.
1987300bf1aeSmrgfunc_echo ()
1988aa9e3350Smrg{
1989300bf1aeSmrg    $debug_cmd
1990aa9e3350Smrg
1991300bf1aeSmrg    _G_message=$*
1992300bf1aeSmrg
1993300bf1aeSmrg    func_echo_IFS=$IFS
1994300bf1aeSmrg    IFS=$nl
1995300bf1aeSmrg    for _G_line in $_G_message; do
1996300bf1aeSmrg      IFS=$func_echo_IFS
1997300bf1aeSmrg      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
1998300bf1aeSmrg    done
1999300bf1aeSmrg    IFS=$func_echo_IFS
2000300bf1aeSmrg}
2001aa9e3350Smrg
2002aa9e3350Smrg
2003300bf1aeSmrg# func_warning ARG...
2004300bf1aeSmrg# -------------------
2005300bf1aeSmrg# Libtool warnings are not categorized, so override funclib.sh
2006300bf1aeSmrg# func_warning with this simpler definition.
2007300bf1aeSmrgfunc_warning ()
2008aa9e3350Smrg{
2009300bf1aeSmrg    $debug_cmd
2010300bf1aeSmrg
2011300bf1aeSmrg    $warning_func ${1+"$@"}
2012300bf1aeSmrg}
2013300bf1aeSmrg
2014aa9e3350Smrg
2015300bf1aeSmrg## ---------------- ##
2016300bf1aeSmrg## Options parsing. ##
2017300bf1aeSmrg## ---------------- ##
2018300bf1aeSmrg
2019300bf1aeSmrg# Hook in the functions to make sure our own options are parsed during
2020300bf1aeSmrg# the option parsing loop.
2021300bf1aeSmrg
2022300bf1aeSmrgusage='$progpath [OPTION]... [MODE-ARG]...'
2023300bf1aeSmrg
2024300bf1aeSmrg# Short help message in response to '-h'.
2025300bf1aeSmrgusage_message="Options:
2026300bf1aeSmrg       --config             show all configuration variables
2027300bf1aeSmrg       --debug              enable verbose shell tracing
2028300bf1aeSmrg   -n, --dry-run            display commands without modifying any files
2029300bf1aeSmrg       --features           display basic configuration information and exit
2030300bf1aeSmrg       --mode=MODE          use operation mode MODE
2031300bf1aeSmrg       --no-warnings        equivalent to '-Wnone'
2032300bf1aeSmrg       --preserve-dup-deps  don't remove duplicate dependency libraries
2033300bf1aeSmrg       --quiet, --silent    don't print informational messages
2034300bf1aeSmrg       --tag=TAG            use configuration variables from tag TAG
2035300bf1aeSmrg   -v, --verbose            print more informational messages than default
2036300bf1aeSmrg       --version            print version information
2037300bf1aeSmrg   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
2038300bf1aeSmrg   -h, --help, --help-all   print short, long, or detailed help message
2039300bf1aeSmrg"
2040aa9e3350Smrg
2041300bf1aeSmrg# Additional text appended to 'usage_message' in response to '--help'.
2042300bf1aeSmrgfunc_help ()
2043aa9e3350Smrg{
2044300bf1aeSmrg    $debug_cmd
2045300bf1aeSmrg
2046300bf1aeSmrg    func_usage_message
2047300bf1aeSmrg    $ECHO "$long_help_message
2048300bf1aeSmrg
2049300bf1aeSmrgMODE must be one of the following:
2050300bf1aeSmrg
2051300bf1aeSmrg       clean           remove files from the build directory
2052300bf1aeSmrg       compile         compile a source file into a libtool object
2053300bf1aeSmrg       execute         automatically set library path, then run a program
2054300bf1aeSmrg       finish          complete the installation of libtool libraries
2055300bf1aeSmrg       install         install libraries or executables
2056300bf1aeSmrg       link            create a library or an executable
2057300bf1aeSmrg       uninstall       remove libraries from an installed directory
2058300bf1aeSmrg
2059300bf1aeSmrgMODE-ARGS vary depending on the MODE.  When passed as first option,
2060300bf1aeSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2061300bf1aeSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE.
2062300bf1aeSmrg
2063300bf1aeSmrgWhen reporting a bug, please describe a test case to reproduce it and
2064300bf1aeSmrginclude the following information:
2065300bf1aeSmrg
2066300bf1aeSmrg       host-triplet:   $host
2067300bf1aeSmrg       shell:          $SHELL
2068300bf1aeSmrg       compiler:       $LTCC
2069300bf1aeSmrg       compiler flags: $LTCFLAGS
2070300bf1aeSmrg       linker:         $LD (gnu? $with_gnu_ld)
2071300bf1aeSmrg       version:        $progname (GNU libtool) 2.4.6
2072300bf1aeSmrg       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2073300bf1aeSmrg       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2074300bf1aeSmrg
2075300bf1aeSmrgReport bugs to <bug-libtool@gnu.org>.
2076300bf1aeSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>.
2077300bf1aeSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>."
2078300bf1aeSmrg    exit 0
2079300bf1aeSmrg}
2080aa9e3350Smrg
2081aa9e3350Smrg
2082300bf1aeSmrg# func_lo2o OBJECT-NAME
2083300bf1aeSmrg# ---------------------
2084300bf1aeSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2085300bf1aeSmrg# object suffix.
2086aa9e3350Smrg
2087300bf1aeSmrglo2o=s/\\.lo\$/.$objext/
2088300bf1aeSmrgo2lo=s/\\.$objext\$/.lo/
2089aa9e3350Smrg
2090300bf1aeSmrgif test yes = "$_G_HAVE_XSI_OPS"; then
2091300bf1aeSmrg  eval 'func_lo2o ()
2092300bf1aeSmrg  {
2093300bf1aeSmrg    case $1 in
2094300bf1aeSmrg      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
2095300bf1aeSmrg      *   ) func_lo2o_result=$1               ;;
2096300bf1aeSmrg    esac
2097300bf1aeSmrg  }'
2098300bf1aeSmrg
2099300bf1aeSmrg  # func_xform LIBOBJ-OR-SOURCE
2100300bf1aeSmrg  # ---------------------------
2101300bf1aeSmrg  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2102300bf1aeSmrg  # suffix to a '.lo' libtool-object suffix.
2103300bf1aeSmrg  eval 'func_xform ()
2104300bf1aeSmrg  {
2105300bf1aeSmrg    func_xform_result=${1%.*}.lo
2106300bf1aeSmrg  }'
2107300bf1aeSmrgelse
2108300bf1aeSmrg  # ...otherwise fall back to using sed.
2109300bf1aeSmrg  func_lo2o ()
2110300bf1aeSmrg  {
2111300bf1aeSmrg    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2112300bf1aeSmrg  }
2113300bf1aeSmrg
2114300bf1aeSmrg  func_xform ()
2115300bf1aeSmrg  {
2116300bf1aeSmrg    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2117300bf1aeSmrg  }
2118300bf1aeSmrgfi
2119aa9e3350Smrg
2120aa9e3350Smrg
2121300bf1aeSmrg# func_fatal_configuration ARG...
2122300bf1aeSmrg# -------------------------------
21236aec45a7Smrg# Echo program name prefixed message to standard error, followed by
21246aec45a7Smrg# a configuration failure hint, and exit.
21256aec45a7Smrgfunc_fatal_configuration ()
21266aec45a7Smrg{
2127300bf1aeSmrg    func__fatal_error ${1+"$@"} \
2128300bf1aeSmrg      "See the $PACKAGE documentation for more information." \
2129300bf1aeSmrg      "Fatal configuration error."
21306aec45a7Smrg}
21316aec45a7Smrg
21326aec45a7Smrg
21336aec45a7Smrg# func_config
2134300bf1aeSmrg# -----------
21356aec45a7Smrg# Display the configuration for all the tags in this script.
21366aec45a7Smrgfunc_config ()
21376aec45a7Smrg{
21386aec45a7Smrg    re_begincf='^# ### BEGIN LIBTOOL'
21396aec45a7Smrg    re_endcf='^# ### END LIBTOOL'
21406aec45a7Smrg
21416aec45a7Smrg    # Default configuration.
21426aec45a7Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
21436aec45a7Smrg
2144ab47cfaaSmrg    # Now print the configurations for the tags.
2145ab47cfaaSmrg    for tagname in $taglist; do
21466aec45a7Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2147ab47cfaaSmrg    done
21485c42550eSmrg
21496aec45a7Smrg    exit $?
21506aec45a7Smrg}
21515c42550eSmrg
2152300bf1aeSmrg
21536aec45a7Smrg# func_features
2154300bf1aeSmrg# -------------
21556aec45a7Smrg# Display the features supported by this script.
21566aec45a7Smrgfunc_features ()
21576aec45a7Smrg{
21586aec45a7Smrg    echo "host: $host"
2159300bf1aeSmrg    if test yes = "$build_libtool_libs"; then
21606aec45a7Smrg      echo "enable shared libraries"
2161ab47cfaaSmrg    else
21626aec45a7Smrg      echo "disable shared libraries"
2163ab47cfaaSmrg    fi
2164300bf1aeSmrg    if test yes = "$build_old_libs"; then
21656aec45a7Smrg      echo "enable static libraries"
2166ab47cfaaSmrg    else
21676aec45a7Smrg      echo "disable static libraries"
2168ab47cfaaSmrg    fi
21696aec45a7Smrg
2170ab47cfaaSmrg    exit $?
21716aec45a7Smrg}
2172ab47cfaaSmrg
2173300bf1aeSmrg
2174300bf1aeSmrg# func_enable_tag TAGNAME
2175300bf1aeSmrg# -----------------------
21766aec45a7Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
21776aec45a7Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
21786aec45a7Smrg# variable here.
21796aec45a7Smrgfunc_enable_tag ()
21806aec45a7Smrg{
2181300bf1aeSmrg    # Global variable:
2182300bf1aeSmrg    tagname=$1
2183ab47cfaaSmrg
2184300bf1aeSmrg    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
2185300bf1aeSmrg    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
2186300bf1aeSmrg    sed_extractcf=/$re_begincf/,/$re_endcf/p
21871473d951Smrg
2188300bf1aeSmrg    # Validate tagname.
2189300bf1aeSmrg    case $tagname in
2190300bf1aeSmrg      *[!-_A-Za-z0-9,/]*)
2191300bf1aeSmrg        func_fatal_error "invalid tag name: $tagname"
2192300bf1aeSmrg        ;;
2193300bf1aeSmrg    esac
2194ab47cfaaSmrg
2195300bf1aeSmrg    # Don't test for the "default" C tag, as we know it's
2196300bf1aeSmrg    # there but not specially marked.
2197300bf1aeSmrg    case $tagname in
2198300bf1aeSmrg        CC) ;;
21996aec45a7Smrg    *)
2200300bf1aeSmrg        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
2201300bf1aeSmrg	  taglist="$taglist $tagname"
2202300bf1aeSmrg
2203300bf1aeSmrg	  # Evaluate the configuration.  Be careful to quote the path
2204300bf1aeSmrg	  # and the sed script, to avoid splitting on whitespace, but
2205300bf1aeSmrg	  # also don't use non-portable quotes within backquotes within
2206300bf1aeSmrg	  # quotes we have to do it in 2 steps:
2207300bf1aeSmrg	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
2208300bf1aeSmrg	  eval "$extractedcf"
2209300bf1aeSmrg        else
2210300bf1aeSmrg	  func_error "ignoring unknown tag $tagname"
2211300bf1aeSmrg        fi
2212300bf1aeSmrg        ;;
2213300bf1aeSmrg    esac
22146aec45a7Smrg}
22156aec45a7Smrg
2216300bf1aeSmrg
2217aa9e3350Smrg# func_check_version_match
2218300bf1aeSmrg# ------------------------
2219aa9e3350Smrg# Ensure that we are using m4 macros, and libtool script from the same
2220aa9e3350Smrg# release of libtool.
2221aa9e3350Smrgfunc_check_version_match ()
22226aec45a7Smrg{
2223300bf1aeSmrg    if test "$package_revision" != "$macro_revision"; then
2224300bf1aeSmrg      if test "$VERSION" != "$macro_version"; then
2225300bf1aeSmrg        if test -z "$macro_version"; then
2226300bf1aeSmrg          cat >&2 <<_LT_EOF
2227aa9e3350Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2228aa9e3350Smrg$progname: definition of this LT_INIT comes from an older release.
2229aa9e3350Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2230aa9e3350Smrg$progname: and run autoconf again.
2231aa9e3350Smrg_LT_EOF
2232300bf1aeSmrg        else
2233300bf1aeSmrg          cat >&2 <<_LT_EOF
2234aa9e3350Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
2235aa9e3350Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2236aa9e3350Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2237aa9e3350Smrg$progname: and run autoconf again.
2238aa9e3350Smrg_LT_EOF
2239300bf1aeSmrg        fi
2240300bf1aeSmrg      else
2241300bf1aeSmrg        cat >&2 <<_LT_EOF
2242aa9e3350Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
2243aa9e3350Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
2244aa9e3350Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
2245aa9e3350Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
2246aa9e3350Smrg_LT_EOF
2247300bf1aeSmrg      fi
2248aa9e3350Smrg
2249300bf1aeSmrg      exit $EXIT_MISMATCH
2250300bf1aeSmrg    fi
2251aa9e3350Smrg}
2252aa9e3350Smrg
2253aa9e3350Smrg
2254300bf1aeSmrg# libtool_options_prep [ARG]...
2255300bf1aeSmrg# -----------------------------
2256300bf1aeSmrg# Preparation for options parsed by libtool.
2257300bf1aeSmrglibtool_options_prep ()
2258300bf1aeSmrg{
2259300bf1aeSmrg    $debug_mode
2260aa9e3350Smrg
2261300bf1aeSmrg    # Option defaults:
2262300bf1aeSmrg    opt_config=false
2263300bf1aeSmrg    opt_dlopen=
2264300bf1aeSmrg    opt_dry_run=false
2265300bf1aeSmrg    opt_help=false
2266300bf1aeSmrg    opt_mode=
2267300bf1aeSmrg    opt_preserve_dup_deps=false
2268300bf1aeSmrg    opt_quiet=false
2269aa9e3350Smrg
2270300bf1aeSmrg    nonopt=
2271300bf1aeSmrg    preserve_args=
2272aa9e3350Smrg
2273300bf1aeSmrg    # Shorthand for --mode=foo, only valid as the first argument
2274300bf1aeSmrg    case $1 in
2275300bf1aeSmrg    clean|clea|cle|cl)
2276300bf1aeSmrg      shift; set dummy --mode clean ${1+"$@"}; shift
2277300bf1aeSmrg      ;;
2278300bf1aeSmrg    compile|compil|compi|comp|com|co|c)
2279300bf1aeSmrg      shift; set dummy --mode compile ${1+"$@"}; shift
2280300bf1aeSmrg      ;;
2281300bf1aeSmrg    execute|execut|execu|exec|exe|ex|e)
2282300bf1aeSmrg      shift; set dummy --mode execute ${1+"$@"}; shift
2283300bf1aeSmrg      ;;
2284300bf1aeSmrg    finish|finis|fini|fin|fi|f)
2285300bf1aeSmrg      shift; set dummy --mode finish ${1+"$@"}; shift
2286300bf1aeSmrg      ;;
2287300bf1aeSmrg    install|instal|insta|inst|ins|in|i)
2288300bf1aeSmrg      shift; set dummy --mode install ${1+"$@"}; shift
2289300bf1aeSmrg      ;;
2290300bf1aeSmrg    link|lin|li|l)
2291300bf1aeSmrg      shift; set dummy --mode link ${1+"$@"}; shift
2292300bf1aeSmrg      ;;
2293300bf1aeSmrg    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
2294300bf1aeSmrg      shift; set dummy --mode uninstall ${1+"$@"}; shift
2295300bf1aeSmrg      ;;
2296300bf1aeSmrg    esac
2297300bf1aeSmrg
2298300bf1aeSmrg    # Pass back the list of options.
2299300bf1aeSmrg    func_quote_for_eval ${1+"$@"}
2300300bf1aeSmrg    libtool_options_prep_result=$func_quote_for_eval_result
2301300bf1aeSmrg}
2302300bf1aeSmrgfunc_add_hook func_options_prep libtool_options_prep
23035c42550eSmrg
2304ab47cfaaSmrg
2305300bf1aeSmrg# libtool_parse_options [ARG]...
2306300bf1aeSmrg# ---------------------------------
2307300bf1aeSmrg# Provide handling for libtool specific options.
2308300bf1aeSmrglibtool_parse_options ()
2309aa9e3350Smrg{
2310300bf1aeSmrg    $debug_cmd
23116aec45a7Smrg
2312300bf1aeSmrg    # Perform our own loop to consume as many options as possible in
2313300bf1aeSmrg    # each iteration.
2314300bf1aeSmrg    while test $# -gt 0; do
2315300bf1aeSmrg      _G_opt=$1
2316300bf1aeSmrg      shift
2317300bf1aeSmrg      case $_G_opt in
2318300bf1aeSmrg        --dry-run|--dryrun|-n)
2319300bf1aeSmrg                        opt_dry_run=:
2320300bf1aeSmrg                        ;;
2321300bf1aeSmrg
2322300bf1aeSmrg        --config)       func_config ;;
2323300bf1aeSmrg
2324300bf1aeSmrg        --dlopen|-dlopen)
2325300bf1aeSmrg                        opt_dlopen="${opt_dlopen+$opt_dlopen
2326300bf1aeSmrg}$1"
2327300bf1aeSmrg                        shift
2328300bf1aeSmrg                        ;;
2329300bf1aeSmrg
2330300bf1aeSmrg        --preserve-dup-deps)
2331300bf1aeSmrg                        opt_preserve_dup_deps=: ;;
2332300bf1aeSmrg
2333300bf1aeSmrg        --features)     func_features ;;
2334300bf1aeSmrg
2335300bf1aeSmrg        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
2336300bf1aeSmrg
2337300bf1aeSmrg        --help)         opt_help=: ;;
2338300bf1aeSmrg
2339300bf1aeSmrg        --help-all)     opt_help=': help-all' ;;
2340300bf1aeSmrg
2341300bf1aeSmrg        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
2342300bf1aeSmrg                        opt_mode=$1
2343300bf1aeSmrg                        case $1 in
2344300bf1aeSmrg                          # Valid mode arguments:
2345300bf1aeSmrg                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
2346300bf1aeSmrg
2347300bf1aeSmrg                          # Catch anything else as an error
2348300bf1aeSmrg                          *) func_error "invalid argument for $_G_opt"
2349300bf1aeSmrg                             exit_cmd=exit
2350300bf1aeSmrg                             break
2351300bf1aeSmrg                             ;;
2352300bf1aeSmrg                        esac
2353300bf1aeSmrg                        shift
2354300bf1aeSmrg                        ;;
2355300bf1aeSmrg
2356300bf1aeSmrg        --no-silent|--no-quiet)
2357300bf1aeSmrg                        opt_quiet=false
2358300bf1aeSmrg                        func_append preserve_args " $_G_opt"
2359300bf1aeSmrg                        ;;
2360300bf1aeSmrg
2361300bf1aeSmrg        --no-warnings|--no-warning|--no-warn)
2362300bf1aeSmrg                        opt_warning=false
2363300bf1aeSmrg                        func_append preserve_args " $_G_opt"
2364300bf1aeSmrg                        ;;
2365300bf1aeSmrg
2366300bf1aeSmrg        --no-verbose)
2367300bf1aeSmrg                        opt_verbose=false
2368300bf1aeSmrg                        func_append preserve_args " $_G_opt"
2369300bf1aeSmrg                        ;;
2370300bf1aeSmrg
2371300bf1aeSmrg        --silent|--quiet)
2372300bf1aeSmrg                        opt_quiet=:
2373300bf1aeSmrg                        opt_verbose=false
2374300bf1aeSmrg                        func_append preserve_args " $_G_opt"
2375300bf1aeSmrg                        ;;
2376300bf1aeSmrg
2377300bf1aeSmrg        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
2378300bf1aeSmrg                        opt_tag=$1
2379300bf1aeSmrg                        func_append preserve_args " $_G_opt $1"
2380300bf1aeSmrg                        func_enable_tag "$1"
2381300bf1aeSmrg                        shift
2382300bf1aeSmrg                        ;;
2383300bf1aeSmrg
2384300bf1aeSmrg        --verbose|-v)   opt_quiet=false
2385300bf1aeSmrg                        opt_verbose=:
2386300bf1aeSmrg                        func_append preserve_args " $_G_opt"
2387300bf1aeSmrg                        ;;
2388300bf1aeSmrg
2389300bf1aeSmrg	# An option not handled by this hook function:
2390300bf1aeSmrg        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
2391300bf1aeSmrg      esac
2392300bf1aeSmrg    done
2393aa9e3350Smrg
2394aa9e3350Smrg
2395300bf1aeSmrg    # save modified positional parameters for caller
2396300bf1aeSmrg    func_quote_for_eval ${1+"$@"}
2397300bf1aeSmrg    libtool_parse_options_result=$func_quote_for_eval_result
2398300bf1aeSmrg}
2399300bf1aeSmrgfunc_add_hook func_parse_options libtool_parse_options
24006aec45a7Smrg
24011473d951Smrg
24026aec45a7Smrg
2403300bf1aeSmrg# libtool_validate_options [ARG]...
2404300bf1aeSmrg# ---------------------------------
2405300bf1aeSmrg# Perform any sanity checks on option settings and/or unconsumed
2406300bf1aeSmrg# arguments.
2407300bf1aeSmrglibtool_validate_options ()
2408300bf1aeSmrg{
2409300bf1aeSmrg    # save first non-option argument
2410300bf1aeSmrg    if test 0 -lt $#; then
2411300bf1aeSmrg      nonopt=$1
2412300bf1aeSmrg      shift
24136aec45a7Smrg    fi
24146aec45a7Smrg
2415300bf1aeSmrg    # preserve --debug
2416300bf1aeSmrg    test : = "$debug_cmd" || func_append preserve_args " --debug"
24176aec45a7Smrg
2418300bf1aeSmrg    case $host in
2419300bf1aeSmrg      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
2420300bf1aeSmrg      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
2421300bf1aeSmrg      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
2422300bf1aeSmrg        # don't eliminate duplications in $postdeps and $predeps
2423300bf1aeSmrg        opt_duplicate_compiler_generated_deps=:
2424300bf1aeSmrg        ;;
2425300bf1aeSmrg      *)
2426300bf1aeSmrg        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
2427300bf1aeSmrg        ;;
2428300bf1aeSmrg    esac
24296aec45a7Smrg
2430300bf1aeSmrg    $opt_help || {
2431300bf1aeSmrg      # Sanity checks first:
2432300bf1aeSmrg      func_check_version_match
24336aec45a7Smrg
2434300bf1aeSmrg      test yes != "$build_libtool_libs" \
2435300bf1aeSmrg        && test yes != "$build_old_libs" \
2436300bf1aeSmrg        && func_fatal_configuration "not configured to build any kind of library"
24376aec45a7Smrg
2438300bf1aeSmrg      # Darwin sucks
2439300bf1aeSmrg      eval std_shrext=\"$shrext_cmds\"
2440300bf1aeSmrg
2441300bf1aeSmrg      # Only execute mode is allowed to have -dlopen flags.
2442300bf1aeSmrg      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
2443300bf1aeSmrg        func_error "unrecognized option '-dlopen'"
2444300bf1aeSmrg        $ECHO "$help" 1>&2
2445300bf1aeSmrg        exit $EXIT_FAILURE
2446300bf1aeSmrg      fi
2447300bf1aeSmrg
2448300bf1aeSmrg      # Change the help message to a mode-specific one.
2449300bf1aeSmrg      generic_help=$help
2450300bf1aeSmrg      help="Try '$progname --help --mode=$opt_mode' for more information."
2451300bf1aeSmrg    }
2452300bf1aeSmrg
2453300bf1aeSmrg    # Pass back the unparsed argument list
2454300bf1aeSmrg    func_quote_for_eval ${1+"$@"}
2455300bf1aeSmrg    libtool_validate_options_result=$func_quote_for_eval_result
2456aa9e3350Smrg}
2457300bf1aeSmrgfunc_add_hook func_validate_options libtool_validate_options
2458300bf1aeSmrg
24596aec45a7Smrg
2460300bf1aeSmrg# Process options as early as possible so that --help and --version
2461300bf1aeSmrg# can return quickly.
2462300bf1aeSmrgfunc_options ${1+"$@"}
2463300bf1aeSmrgeval set dummy "$func_options_result"; shift
24646aec45a7Smrg
2465ab47cfaaSmrg
2466ab47cfaaSmrg
2467aa9e3350Smrg## ----------- ##
2468aa9e3350Smrg##    Main.    ##
2469aa9e3350Smrg## ----------- ##
2470ab47cfaaSmrg
2471300bf1aeSmrgmagic='%%%MAGIC variable%%%'
2472300bf1aeSmrgmagic_exe='%%%MAGIC EXE variable%%%'
2473300bf1aeSmrg
2474300bf1aeSmrg# Global variables.
2475300bf1aeSmrgextracted_archives=
2476300bf1aeSmrgextracted_serial=0
2477300bf1aeSmrg
2478300bf1aeSmrg# If this variable is set in any of the actions, the command in it
2479300bf1aeSmrg# will be execed at the end.  This prevents here-documents from being
2480300bf1aeSmrg# left over by shells.
2481300bf1aeSmrgexec_cmd=
2482300bf1aeSmrg
2483300bf1aeSmrg
2484300bf1aeSmrg# A function that is used when there is no print builtin or printf.
2485300bf1aeSmrgfunc_fallback_echo ()
2486300bf1aeSmrg{
2487300bf1aeSmrg  eval 'cat <<_LTECHO_EOF
2488300bf1aeSmrg$1
2489300bf1aeSmrg_LTECHO_EOF'
2490300bf1aeSmrg}
2491300bf1aeSmrg
2492300bf1aeSmrg# func_generated_by_libtool
2493300bf1aeSmrg# True iff stdin has been generated by Libtool. This function is only
2494300bf1aeSmrg# a basic sanity check; it will hardly flush out determined imposters.
2495300bf1aeSmrgfunc_generated_by_libtool_p ()
2496300bf1aeSmrg{
2497300bf1aeSmrg  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
2498300bf1aeSmrg}
2499300bf1aeSmrg
25006aec45a7Smrg# func_lalib_p file
2501300bf1aeSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
25026aec45a7Smrg# This function is only a basic sanity check; it will hardly flush out
25036aec45a7Smrg# determined imposters.
25046aec45a7Smrgfunc_lalib_p ()
25056aec45a7Smrg{
25066aec45a7Smrg    test -f "$1" &&
2507300bf1aeSmrg      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
25086aec45a7Smrg}
2509ab47cfaaSmrg
25106aec45a7Smrg# func_lalib_unsafe_p file
2511300bf1aeSmrg# True iff FILE is a libtool '.la' library or '.lo' object file.
25126aec45a7Smrg# This function implements the same check as func_lalib_p without
25136aec45a7Smrg# resorting to external programs.  To this end, it redirects stdin and
25146aec45a7Smrg# closes it afterwards, without saving the original file descriptor.
25156aec45a7Smrg# As a safety measure, use it only where a negative result would be
2516300bf1aeSmrg# fatal anyway.  Works if 'file' does not exist.
25176aec45a7Smrgfunc_lalib_unsafe_p ()
25186aec45a7Smrg{
25196aec45a7Smrg    lalib_p=no
25206aec45a7Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
25216aec45a7Smrg	for lalib_p_l in 1 2 3 4
25226aec45a7Smrg	do
25236aec45a7Smrg	    read lalib_p_line
2524300bf1aeSmrg	    case $lalib_p_line in
25256aec45a7Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
25266aec45a7Smrg	    esac
25276aec45a7Smrg	done
25286aec45a7Smrg	exec 0<&5 5<&-
25296aec45a7Smrg    fi
2530300bf1aeSmrg    test yes = "$lalib_p"
25316aec45a7Smrg}
2532ab47cfaaSmrg
25336aec45a7Smrg# func_ltwrapper_script_p file
25346aec45a7Smrg# True iff FILE is a libtool wrapper script
25356aec45a7Smrg# This function is only a basic sanity check; it will hardly flush out
25366aec45a7Smrg# determined imposters.
25376aec45a7Smrgfunc_ltwrapper_script_p ()
25386aec45a7Smrg{
2539300bf1aeSmrg    test -f "$1" &&
2540300bf1aeSmrg      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
25416aec45a7Smrg}
2542ab47cfaaSmrg
25436aec45a7Smrg# func_ltwrapper_executable_p file
25446aec45a7Smrg# True iff FILE is a libtool wrapper executable
25456aec45a7Smrg# This function is only a basic sanity check; it will hardly flush out
25466aec45a7Smrg# determined imposters.
25476aec45a7Smrgfunc_ltwrapper_executable_p ()
25486aec45a7Smrg{
25496aec45a7Smrg    func_ltwrapper_exec_suffix=
25506aec45a7Smrg    case $1 in
25516aec45a7Smrg    *.exe) ;;
25526aec45a7Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
25536aec45a7Smrg    esac
25546aec45a7Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
25556aec45a7Smrg}
25566aec45a7Smrg
25576aec45a7Smrg# func_ltwrapper_scriptname file
25586aec45a7Smrg# Assumes file is an ltwrapper_executable
25596aec45a7Smrg# uses $file to determine the appropriate filename for a
25606aec45a7Smrg# temporary ltwrapper_script.
25616aec45a7Smrgfunc_ltwrapper_scriptname ()
25626aec45a7Smrg{
2563aa9e3350Smrg    func_dirname_and_basename "$1" "" "."
2564aa9e3350Smrg    func_stripname '' '.exe' "$func_basename_result"
2565300bf1aeSmrg    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
25666aec45a7Smrg}
25676aec45a7Smrg
25686aec45a7Smrg# func_ltwrapper_p file
25696aec45a7Smrg# True iff FILE is a libtool wrapper script or wrapper executable
25706aec45a7Smrg# This function is only a basic sanity check; it will hardly flush out
25716aec45a7Smrg# determined imposters.
25726aec45a7Smrgfunc_ltwrapper_p ()
25736aec45a7Smrg{
25746aec45a7Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
25756aec45a7Smrg}
25766aec45a7Smrg
25776aec45a7Smrg
25786aec45a7Smrg# func_execute_cmds commands fail_cmd
25796aec45a7Smrg# Execute tilde-delimited COMMANDS.
25806aec45a7Smrg# If FAIL_CMD is given, eval that upon failure.
25816aec45a7Smrg# FAIL_CMD may read-access the current command in variable CMD!
25826aec45a7Smrgfunc_execute_cmds ()
25836aec45a7Smrg{
2584300bf1aeSmrg    $debug_cmd
2585300bf1aeSmrg
25866aec45a7Smrg    save_ifs=$IFS; IFS='~'
25876aec45a7Smrg    for cmd in $1; do
2588300bf1aeSmrg      IFS=$sp$nl
25896aec45a7Smrg      eval cmd=\"$cmd\"
2590300bf1aeSmrg      IFS=$save_ifs
25916aec45a7Smrg      func_show_eval "$cmd" "${2-:}"
25926aec45a7Smrg    done
25936aec45a7Smrg    IFS=$save_ifs
25946aec45a7Smrg}
25956aec45a7Smrg
25966aec45a7Smrg
25976aec45a7Smrg# func_source file
25986aec45a7Smrg# Source FILE, adding directory component if necessary.
25996aec45a7Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
26006aec45a7Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
26016aec45a7Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
2602300bf1aeSmrg# 'FILE.' does not work on cygwin managed mounts.
26036aec45a7Smrgfunc_source ()
26046aec45a7Smrg{
2605300bf1aeSmrg    $debug_cmd
2606300bf1aeSmrg
26076aec45a7Smrg    case $1 in
26086aec45a7Smrg    */* | *\\*)	. "$1" ;;
26096aec45a7Smrg    *)		. "./$1" ;;
26106aec45a7Smrg    esac
26116aec45a7Smrg}
26126aec45a7Smrg
26136aec45a7Smrg
2614aa9e3350Smrg# func_resolve_sysroot PATH
2615aa9e3350Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
2616aa9e3350Smrg# func_resolve_sysroot_result
2617aa9e3350Smrgfunc_resolve_sysroot ()
2618aa9e3350Smrg{
2619aa9e3350Smrg  func_resolve_sysroot_result=$1
2620aa9e3350Smrg  case $func_resolve_sysroot_result in
2621aa9e3350Smrg  =*)
2622aa9e3350Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
2623aa9e3350Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2624aa9e3350Smrg    ;;
2625aa9e3350Smrg  esac
2626aa9e3350Smrg}
2627aa9e3350Smrg
2628aa9e3350Smrg# func_replace_sysroot PATH
2629aa9e3350Smrg# If PATH begins with the sysroot, replace it with = and
2630aa9e3350Smrg# store the result into func_replace_sysroot_result.
2631aa9e3350Smrgfunc_replace_sysroot ()
2632aa9e3350Smrg{
2633300bf1aeSmrg  case $lt_sysroot:$1 in
2634aa9e3350Smrg  ?*:"$lt_sysroot"*)
2635aa9e3350Smrg    func_stripname "$lt_sysroot" '' "$1"
2636300bf1aeSmrg    func_replace_sysroot_result='='$func_stripname_result
2637aa9e3350Smrg    ;;
2638aa9e3350Smrg  *)
2639aa9e3350Smrg    # Including no sysroot.
2640aa9e3350Smrg    func_replace_sysroot_result=$1
2641aa9e3350Smrg    ;;
2642aa9e3350Smrg  esac
2643aa9e3350Smrg}
2644aa9e3350Smrg
26456aec45a7Smrg# func_infer_tag arg
26466aec45a7Smrg# Infer tagged configuration to use if any are available and
26476aec45a7Smrg# if one wasn't chosen via the "--tag" command line option.
26486aec45a7Smrg# Only attempt this if the compiler in the base compile
26496aec45a7Smrg# command doesn't match the default compiler.
26506aec45a7Smrg# arg is usually of the form 'gcc ...'
26516aec45a7Smrgfunc_infer_tag ()
26526aec45a7Smrg{
2653300bf1aeSmrg    $debug_cmd
2654300bf1aeSmrg
26556aec45a7Smrg    if test -n "$available_tags" && test -z "$tagname"; then
26566aec45a7Smrg      CC_quoted=
26576aec45a7Smrg      for arg in $CC; do
2658aa9e3350Smrg	func_append_quoted CC_quoted "$arg"
26596aec45a7Smrg      done
26606aec45a7Smrg      CC_expanded=`func_echo_all $CC`
26616aec45a7Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
26626aec45a7Smrg      case $@ in
26636aec45a7Smrg      # Blanks in the command may have been stripped by the calling shell,
26646aec45a7Smrg      # but not from the CC environment variable when configure was run.
26656aec45a7Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
26666aec45a7Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
26676aec45a7Smrg      # Blanks at the start of $base_compile will cause this to fail
26686aec45a7Smrg      # if we don't check for them as well.
26696aec45a7Smrg      *)
26706aec45a7Smrg	for z in $available_tags; do
26716aec45a7Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
26726aec45a7Smrg	    # Evaluate the configuration.
2673300bf1aeSmrg	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
26746aec45a7Smrg	    CC_quoted=
26756aec45a7Smrg	    for arg in $CC; do
26766aec45a7Smrg	      # Double-quote args containing other shell metacharacters.
2677aa9e3350Smrg	      func_append_quoted CC_quoted "$arg"
26786aec45a7Smrg	    done
26796aec45a7Smrg	    CC_expanded=`func_echo_all $CC`
26806aec45a7Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
26816aec45a7Smrg	    case "$@ " in
26826aec45a7Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
26836aec45a7Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
26846aec45a7Smrg	      # The compiler in the base compile command matches
26856aec45a7Smrg	      # the one in the tagged configuration.
26866aec45a7Smrg	      # Assume this is the tagged configuration we want.
26876aec45a7Smrg	      tagname=$z
26886aec45a7Smrg	      break
26896aec45a7Smrg	      ;;
26906aec45a7Smrg	    esac
26916aec45a7Smrg	  fi
26926aec45a7Smrg	done
26936aec45a7Smrg	# If $tagname still isn't set, then no tagged configuration
26946aec45a7Smrg	# was found and let the user know that the "--tag" command
26956aec45a7Smrg	# line option must be used.
26966aec45a7Smrg	if test -z "$tagname"; then
26976aec45a7Smrg	  func_echo "unable to infer tagged configuration"
2698300bf1aeSmrg	  func_fatal_error "specify a tag with '--tag'"
26996aec45a7Smrg#	else
27006aec45a7Smrg#	  func_verbose "using $tagname tagged configuration"
27016aec45a7Smrg	fi
27026aec45a7Smrg	;;
27036aec45a7Smrg      esac
27046aec45a7Smrg    fi
27056aec45a7Smrg}
27066aec45a7Smrg
27076aec45a7Smrg
2708aa9e3350Smrg
2709aa9e3350Smrg# func_write_libtool_object output_name pic_name nonpic_name
2710aa9e3350Smrg# Create a libtool object file (analogous to a ".la" file),
2711aa9e3350Smrg# but don't create it if we're doing a dry run.
2712aa9e3350Smrgfunc_write_libtool_object ()
2713aa9e3350Smrg{
2714300bf1aeSmrg    write_libobj=$1
2715300bf1aeSmrg    if test yes = "$build_libtool_libs"; then
2716300bf1aeSmrg      write_lobj=\'$2\'
2717aa9e3350Smrg    else
2718aa9e3350Smrg      write_lobj=none
2719aa9e3350Smrg    fi
2720aa9e3350Smrg
2721300bf1aeSmrg    if test yes = "$build_old_libs"; then
2722300bf1aeSmrg      write_oldobj=\'$3\'
2723aa9e3350Smrg    else
2724aa9e3350Smrg      write_oldobj=none
2725aa9e3350Smrg    fi
2726aa9e3350Smrg
2727aa9e3350Smrg    $opt_dry_run || {
2728aa9e3350Smrg      cat >${write_libobj}T <<EOF
2729aa9e3350Smrg# $write_libobj - a libtool object file
2730300bf1aeSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2731aa9e3350Smrg#
2732aa9e3350Smrg# Please DO NOT delete this file!
2733aa9e3350Smrg# It is necessary for linking the library.
2734aa9e3350Smrg
2735aa9e3350Smrg# Name of the PIC object.
2736aa9e3350Smrgpic_object=$write_lobj
2737aa9e3350Smrg
2738aa9e3350Smrg# Name of the non-PIC object
2739aa9e3350Smrgnon_pic_object=$write_oldobj
2740aa9e3350Smrg
2741aa9e3350SmrgEOF
2742300bf1aeSmrg      $MV "${write_libobj}T" "$write_libobj"
2743aa9e3350Smrg    }
2744aa9e3350Smrg}
2745aa9e3350Smrg
2746aa9e3350Smrg
2747aa9e3350Smrg##################################################
2748aa9e3350Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2749aa9e3350Smrg##################################################
2750aa9e3350Smrg
2751aa9e3350Smrg# func_convert_core_file_wine_to_w32 ARG
2752aa9e3350Smrg# Helper function used by file name conversion functions when $build is *nix,
2753aa9e3350Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
2754aa9e3350Smrg# correctly configured wine environment available, with the winepath program
2755aa9e3350Smrg# in $build's $PATH.
2756aa9e3350Smrg#
2757aa9e3350Smrg# ARG is the $build file name to be converted to w32 format.
2758aa9e3350Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
2759aa9e3350Smrg# be empty on error (or when ARG is empty)
2760aa9e3350Smrgfunc_convert_core_file_wine_to_w32 ()
2761aa9e3350Smrg{
2762300bf1aeSmrg  $debug_cmd
2763300bf1aeSmrg
2764300bf1aeSmrg  func_convert_core_file_wine_to_w32_result=$1
2765aa9e3350Smrg  if test -n "$1"; then
2766aa9e3350Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
2767aa9e3350Smrg    # are forced to check the contents of stdout. On the other hand, if the
2768aa9e3350Smrg    # command is not found, the shell will set an exit code of 127 and print
2769aa9e3350Smrg    # *an error message* to stdout. So we must check for both error code of
2770aa9e3350Smrg    # zero AND non-empty stdout, which explains the odd construction:
2771aa9e3350Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
2772300bf1aeSmrg    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2773aa9e3350Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
2774300bf1aeSmrg        $SED -e "$sed_naive_backslashify"`
2775aa9e3350Smrg    else
2776aa9e3350Smrg      func_convert_core_file_wine_to_w32_result=
2777aa9e3350Smrg    fi
2778aa9e3350Smrg  fi
2779aa9e3350Smrg}
2780aa9e3350Smrg# end: func_convert_core_file_wine_to_w32
2781aa9e3350Smrg
2782aa9e3350Smrg
2783aa9e3350Smrg# func_convert_core_path_wine_to_w32 ARG
2784aa9e3350Smrg# Helper function used by path conversion functions when $build is *nix, and
2785aa9e3350Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2786aa9e3350Smrg# configured wine environment available, with the winepath program in $build's
2787aa9e3350Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
2788aa9e3350Smrg#
2789aa9e3350Smrg# ARG is path to be converted from $build format to win32.
2790aa9e3350Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
2791aa9e3350Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
2792aa9e3350Smrg# are convertible, then the result may be empty.
2793aa9e3350Smrgfunc_convert_core_path_wine_to_w32 ()
2794aa9e3350Smrg{
2795300bf1aeSmrg  $debug_cmd
2796300bf1aeSmrg
2797aa9e3350Smrg  # unfortunately, winepath doesn't convert paths, only file names
2798300bf1aeSmrg  func_convert_core_path_wine_to_w32_result=
2799aa9e3350Smrg  if test -n "$1"; then
2800aa9e3350Smrg    oldIFS=$IFS
2801aa9e3350Smrg    IFS=:
2802aa9e3350Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
2803aa9e3350Smrg      IFS=$oldIFS
2804aa9e3350Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
2805300bf1aeSmrg      if test -n "$func_convert_core_file_wine_to_w32_result"; then
2806aa9e3350Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
2807300bf1aeSmrg          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2808aa9e3350Smrg        else
2809aa9e3350Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2810aa9e3350Smrg        fi
2811aa9e3350Smrg      fi
2812aa9e3350Smrg    done
2813aa9e3350Smrg    IFS=$oldIFS
2814aa9e3350Smrg  fi
2815aa9e3350Smrg}
2816aa9e3350Smrg# end: func_convert_core_path_wine_to_w32
2817aa9e3350Smrg
2818aa9e3350Smrg
2819aa9e3350Smrg# func_cygpath ARGS...
2820aa9e3350Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2821aa9e3350Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2822aa9e3350Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2823aa9e3350Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
2824aa9e3350Smrg# file name or path is assumed to be in w32 format, as previously converted
2825aa9e3350Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
2826aa9e3350Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
2827aa9e3350Smrg# Cygwin format). Returns an empty string on error.
2828aa9e3350Smrg#
2829aa9e3350Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
2830aa9e3350Smrg# be converted.
2831aa9e3350Smrg#
2832aa9e3350Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2833aa9e3350Smrg# environment variable; do not put it in $PATH.
2834aa9e3350Smrgfunc_cygpath ()
2835aa9e3350Smrg{
2836300bf1aeSmrg  $debug_cmd
2837300bf1aeSmrg
2838aa9e3350Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2839aa9e3350Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2840aa9e3350Smrg    if test "$?" -ne 0; then
2841aa9e3350Smrg      # on failure, ensure result is empty
2842aa9e3350Smrg      func_cygpath_result=
2843aa9e3350Smrg    fi
2844aa9e3350Smrg  else
2845aa9e3350Smrg    func_cygpath_result=
2846300bf1aeSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2847aa9e3350Smrg  fi
2848aa9e3350Smrg}
2849aa9e3350Smrg#end: func_cygpath
2850aa9e3350Smrg
2851aa9e3350Smrg
2852aa9e3350Smrg# func_convert_core_msys_to_w32 ARG
2853aa9e3350Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
2854aa9e3350Smrg# result in func_convert_core_msys_to_w32_result.
2855aa9e3350Smrgfunc_convert_core_msys_to_w32 ()
2856aa9e3350Smrg{
2857300bf1aeSmrg  $debug_cmd
2858300bf1aeSmrg
2859aa9e3350Smrg  # awkward: cmd appends spaces to result
2860aa9e3350Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
2861300bf1aeSmrg    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2862aa9e3350Smrg}
2863aa9e3350Smrg#end: func_convert_core_msys_to_w32
2864aa9e3350Smrg
2865aa9e3350Smrg
2866aa9e3350Smrg# func_convert_file_check ARG1 ARG2
2867aa9e3350Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
2868aa9e3350Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
2869aa9e3350Smrg# func_to_host_file_result to ARG1).
2870aa9e3350Smrgfunc_convert_file_check ()
2871aa9e3350Smrg{
2872300bf1aeSmrg  $debug_cmd
2873300bf1aeSmrg
2874300bf1aeSmrg  if test -z "$2" && test -n "$1"; then
2875aa9e3350Smrg    func_error "Could not determine host file name corresponding to"
2876300bf1aeSmrg    func_error "  '$1'"
2877aa9e3350Smrg    func_error "Continuing, but uninstalled executables may not work."
2878aa9e3350Smrg    # Fallback:
2879300bf1aeSmrg    func_to_host_file_result=$1
2880aa9e3350Smrg  fi
2881aa9e3350Smrg}
2882aa9e3350Smrg# end func_convert_file_check
2883aa9e3350Smrg
2884aa9e3350Smrg
2885aa9e3350Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2886aa9e3350Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
2887aa9e3350Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2888aa9e3350Smrg# func_to_host_file_result to a simplistic fallback value (see below).
2889aa9e3350Smrgfunc_convert_path_check ()
2890aa9e3350Smrg{
2891300bf1aeSmrg  $debug_cmd
2892300bf1aeSmrg
2893aa9e3350Smrg  if test -z "$4" && test -n "$3"; then
2894aa9e3350Smrg    func_error "Could not determine the host path corresponding to"
2895300bf1aeSmrg    func_error "  '$3'"
2896aa9e3350Smrg    func_error "Continuing, but uninstalled executables may not work."
2897aa9e3350Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
2898aa9e3350Smrg    # should not be "improved".  See libtool.info.
2899aa9e3350Smrg    if test "x$1" != "x$2"; then
2900aa9e3350Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
2901aa9e3350Smrg      func_to_host_path_result=`echo "$3" |
2902aa9e3350Smrg        $SED -e "$lt_replace_pathsep_chars"`
2903aa9e3350Smrg    else
2904300bf1aeSmrg      func_to_host_path_result=$3
2905aa9e3350Smrg    fi
2906aa9e3350Smrg  fi
2907aa9e3350Smrg}
2908aa9e3350Smrg# end func_convert_path_check
2909aa9e3350Smrg
2910aa9e3350Smrg
2911aa9e3350Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2912aa9e3350Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2913aa9e3350Smrg# and appending REPL if ORIG matches BACKPAT.
2914aa9e3350Smrgfunc_convert_path_front_back_pathsep ()
2915aa9e3350Smrg{
2916300bf1aeSmrg  $debug_cmd
2917300bf1aeSmrg
2918aa9e3350Smrg  case $4 in
2919300bf1aeSmrg  $1 ) func_to_host_path_result=$3$func_to_host_path_result
2920aa9e3350Smrg    ;;
2921aa9e3350Smrg  esac
2922aa9e3350Smrg  case $4 in
2923aa9e3350Smrg  $2 ) func_append func_to_host_path_result "$3"
2924aa9e3350Smrg    ;;
2925aa9e3350Smrg  esac
2926aa9e3350Smrg}
2927aa9e3350Smrg# end func_convert_path_front_back_pathsep
2928aa9e3350Smrg
2929aa9e3350Smrg
2930aa9e3350Smrg##################################################
2931aa9e3350Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
2932aa9e3350Smrg##################################################
2933300bf1aeSmrg# invoked via '$to_host_file_cmd ARG'
2934aa9e3350Smrg#
2935aa9e3350Smrg# In each case, ARG is the path to be converted from $build to $host format.
2936aa9e3350Smrg# Result will be available in $func_to_host_file_result.
2937aa9e3350Smrg
2938aa9e3350Smrg
2939aa9e3350Smrg# func_to_host_file ARG
2940aa9e3350Smrg# Converts the file name ARG from $build format to $host format. Return result
2941aa9e3350Smrg# in func_to_host_file_result.
2942aa9e3350Smrgfunc_to_host_file ()
2943aa9e3350Smrg{
2944300bf1aeSmrg  $debug_cmd
2945300bf1aeSmrg
2946aa9e3350Smrg  $to_host_file_cmd "$1"
2947aa9e3350Smrg}
2948aa9e3350Smrg# end func_to_host_file
2949aa9e3350Smrg
2950aa9e3350Smrg
2951aa9e3350Smrg# func_to_tool_file ARG LAZY
2952aa9e3350Smrg# converts the file name ARG from $build format to toolchain format. Return
2953aa9e3350Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
2954aa9e3350Smrg# in (the comma separated) LAZY, no conversion takes place.
2955aa9e3350Smrgfunc_to_tool_file ()
2956aa9e3350Smrg{
2957300bf1aeSmrg  $debug_cmd
2958300bf1aeSmrg
2959aa9e3350Smrg  case ,$2, in
2960aa9e3350Smrg    *,"$to_tool_file_cmd",*)
2961aa9e3350Smrg      func_to_tool_file_result=$1
2962aa9e3350Smrg      ;;
2963aa9e3350Smrg    *)
2964aa9e3350Smrg      $to_tool_file_cmd "$1"
2965aa9e3350Smrg      func_to_tool_file_result=$func_to_host_file_result
2966aa9e3350Smrg      ;;
2967aa9e3350Smrg  esac
2968aa9e3350Smrg}
2969aa9e3350Smrg# end func_to_tool_file
2970aa9e3350Smrg
2971aa9e3350Smrg
2972aa9e3350Smrg# func_convert_file_noop ARG
2973aa9e3350Smrg# Copy ARG to func_to_host_file_result.
2974aa9e3350Smrgfunc_convert_file_noop ()
2975aa9e3350Smrg{
2976300bf1aeSmrg  func_to_host_file_result=$1
2977aa9e3350Smrg}
2978aa9e3350Smrg# end func_convert_file_noop
2979aa9e3350Smrg
2980aa9e3350Smrg
2981aa9e3350Smrg# func_convert_file_msys_to_w32 ARG
2982aa9e3350Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
2983aa9e3350Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
2984aa9e3350Smrg# func_to_host_file_result.
2985aa9e3350Smrgfunc_convert_file_msys_to_w32 ()
2986aa9e3350Smrg{
2987300bf1aeSmrg  $debug_cmd
2988300bf1aeSmrg
2989300bf1aeSmrg  func_to_host_file_result=$1
2990aa9e3350Smrg  if test -n "$1"; then
2991aa9e3350Smrg    func_convert_core_msys_to_w32 "$1"
2992300bf1aeSmrg    func_to_host_file_result=$func_convert_core_msys_to_w32_result
2993aa9e3350Smrg  fi
2994aa9e3350Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
2995aa9e3350Smrg}
2996aa9e3350Smrg# end func_convert_file_msys_to_w32
2997aa9e3350Smrg
2998aa9e3350Smrg
2999aa9e3350Smrg# func_convert_file_cygwin_to_w32 ARG
3000aa9e3350Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
3001aa9e3350Smrg# func_to_host_file_result.
3002aa9e3350Smrgfunc_convert_file_cygwin_to_w32 ()
3003aa9e3350Smrg{
3004300bf1aeSmrg  $debug_cmd
3005300bf1aeSmrg
3006300bf1aeSmrg  func_to_host_file_result=$1
3007aa9e3350Smrg  if test -n "$1"; then
3008aa9e3350Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
3009aa9e3350Smrg    # LT_CYGPATH in this case.
3010aa9e3350Smrg    func_to_host_file_result=`cygpath -m "$1"`
3011aa9e3350Smrg  fi
3012aa9e3350Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3013aa9e3350Smrg}
3014aa9e3350Smrg# end func_convert_file_cygwin_to_w32
3015aa9e3350Smrg
3016aa9e3350Smrg
3017aa9e3350Smrg# func_convert_file_nix_to_w32 ARG
3018aa9e3350Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
3019aa9e3350Smrg# and a working winepath. Returns result in func_to_host_file_result.
3020aa9e3350Smrgfunc_convert_file_nix_to_w32 ()
3021aa9e3350Smrg{
3022300bf1aeSmrg  $debug_cmd
3023300bf1aeSmrg
3024300bf1aeSmrg  func_to_host_file_result=$1
3025aa9e3350Smrg  if test -n "$1"; then
3026aa9e3350Smrg    func_convert_core_file_wine_to_w32 "$1"
3027300bf1aeSmrg    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
3028aa9e3350Smrg  fi
3029aa9e3350Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3030aa9e3350Smrg}
3031aa9e3350Smrg# end func_convert_file_nix_to_w32
3032aa9e3350Smrg
3033aa9e3350Smrg
3034aa9e3350Smrg# func_convert_file_msys_to_cygwin ARG
3035aa9e3350Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3036aa9e3350Smrg# Returns result in func_to_host_file_result.
3037aa9e3350Smrgfunc_convert_file_msys_to_cygwin ()
3038aa9e3350Smrg{
3039300bf1aeSmrg  $debug_cmd
3040300bf1aeSmrg
3041300bf1aeSmrg  func_to_host_file_result=$1
3042aa9e3350Smrg  if test -n "$1"; then
3043aa9e3350Smrg    func_convert_core_msys_to_w32 "$1"
3044aa9e3350Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
3045300bf1aeSmrg    func_to_host_file_result=$func_cygpath_result
3046aa9e3350Smrg  fi
3047aa9e3350Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3048aa9e3350Smrg}
3049aa9e3350Smrg# end func_convert_file_msys_to_cygwin
3050aa9e3350Smrg
3051aa9e3350Smrg
3052aa9e3350Smrg# func_convert_file_nix_to_cygwin ARG
3053aa9e3350Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
3054aa9e3350Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
3055aa9e3350Smrg# in func_to_host_file_result.
3056aa9e3350Smrgfunc_convert_file_nix_to_cygwin ()
3057aa9e3350Smrg{
3058300bf1aeSmrg  $debug_cmd
3059300bf1aeSmrg
3060300bf1aeSmrg  func_to_host_file_result=$1
3061aa9e3350Smrg  if test -n "$1"; then
3062aa9e3350Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
3063aa9e3350Smrg    func_convert_core_file_wine_to_w32 "$1"
3064aa9e3350Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
3065300bf1aeSmrg    func_to_host_file_result=$func_cygpath_result
3066aa9e3350Smrg  fi
3067aa9e3350Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
3068aa9e3350Smrg}
3069aa9e3350Smrg# end func_convert_file_nix_to_cygwin
3070aa9e3350Smrg
3071aa9e3350Smrg
3072aa9e3350Smrg#############################################
3073aa9e3350Smrg# $build to $host PATH CONVERSION FUNCTIONS #
3074aa9e3350Smrg#############################################
3075300bf1aeSmrg# invoked via '$to_host_path_cmd ARG'
3076aa9e3350Smrg#
3077aa9e3350Smrg# In each case, ARG is the path to be converted from $build to $host format.
3078aa9e3350Smrg# The result will be available in $func_to_host_path_result.
3079aa9e3350Smrg#
3080aa9e3350Smrg# Path separators are also converted from $build format to $host format.  If
3081aa9e3350Smrg# ARG begins or ends with a path separator character, it is preserved (but
3082aa9e3350Smrg# converted to $host format) on output.
3083aa9e3350Smrg#
3084aa9e3350Smrg# All path conversion functions are named using the following convention:
3085aa9e3350Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
3086aa9e3350Smrg#   path conversion function         : func_convert_path_X_to_Y ()
3087aa9e3350Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
3088aa9e3350Smrg# same.  If conversion functions are added for new $build/$host combinations,
3089aa9e3350Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
3090aa9e3350Smrg# will break.
3091aa9e3350Smrg
3092aa9e3350Smrg
3093aa9e3350Smrg# func_init_to_host_path_cmd
3094aa9e3350Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
3095aa9e3350Smrg# appropriate value, based on the value of $to_host_file_cmd.
3096aa9e3350Smrgto_host_path_cmd=
3097aa9e3350Smrgfunc_init_to_host_path_cmd ()
3098aa9e3350Smrg{
3099300bf1aeSmrg  $debug_cmd
3100300bf1aeSmrg
3101aa9e3350Smrg  if test -z "$to_host_path_cmd"; then
3102aa9e3350Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
3103300bf1aeSmrg    to_host_path_cmd=func_convert_path_$func_stripname_result
3104aa9e3350Smrg  fi
3105aa9e3350Smrg}
3106aa9e3350Smrg
3107aa9e3350Smrg
3108aa9e3350Smrg# func_to_host_path ARG
3109aa9e3350Smrg# Converts the path ARG from $build format to $host format. Return result
3110aa9e3350Smrg# in func_to_host_path_result.
3111aa9e3350Smrgfunc_to_host_path ()
3112aa9e3350Smrg{
3113300bf1aeSmrg  $debug_cmd
3114300bf1aeSmrg
3115aa9e3350Smrg  func_init_to_host_path_cmd
3116aa9e3350Smrg  $to_host_path_cmd "$1"
3117aa9e3350Smrg}
3118aa9e3350Smrg# end func_to_host_path
3119aa9e3350Smrg
3120aa9e3350Smrg
3121aa9e3350Smrg# func_convert_path_noop ARG
3122aa9e3350Smrg# Copy ARG to func_to_host_path_result.
3123aa9e3350Smrgfunc_convert_path_noop ()
3124aa9e3350Smrg{
3125300bf1aeSmrg  func_to_host_path_result=$1
3126aa9e3350Smrg}
3127aa9e3350Smrg# end func_convert_path_noop
3128aa9e3350Smrg
3129aa9e3350Smrg
3130aa9e3350Smrg# func_convert_path_msys_to_w32 ARG
3131aa9e3350Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3132aa9e3350Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
3133aa9e3350Smrg# func_to_host_path_result.
3134aa9e3350Smrgfunc_convert_path_msys_to_w32 ()
3135aa9e3350Smrg{
3136300bf1aeSmrg  $debug_cmd
3137300bf1aeSmrg
3138300bf1aeSmrg  func_to_host_path_result=$1
3139aa9e3350Smrg  if test -n "$1"; then
3140aa9e3350Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
3141aa9e3350Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3142aa9e3350Smrg    # and winepath ignores them completely.
3143aa9e3350Smrg    func_stripname : : "$1"
3144aa9e3350Smrg    func_to_host_path_tmp1=$func_stripname_result
3145aa9e3350Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3146300bf1aeSmrg    func_to_host_path_result=$func_convert_core_msys_to_w32_result
3147aa9e3350Smrg    func_convert_path_check : ";" \
3148aa9e3350Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3149aa9e3350Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3150aa9e3350Smrg  fi
3151aa9e3350Smrg}
3152aa9e3350Smrg# end func_convert_path_msys_to_w32
3153aa9e3350Smrg
3154aa9e3350Smrg
3155aa9e3350Smrg# func_convert_path_cygwin_to_w32 ARG
3156aa9e3350Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
3157aa9e3350Smrg# func_to_host_file_result.
3158aa9e3350Smrgfunc_convert_path_cygwin_to_w32 ()
3159aa9e3350Smrg{
3160300bf1aeSmrg  $debug_cmd
3161300bf1aeSmrg
3162300bf1aeSmrg  func_to_host_path_result=$1
3163aa9e3350Smrg  if test -n "$1"; then
3164aa9e3350Smrg    # See func_convert_path_msys_to_w32:
3165aa9e3350Smrg    func_stripname : : "$1"
3166aa9e3350Smrg    func_to_host_path_tmp1=$func_stripname_result
3167aa9e3350Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3168aa9e3350Smrg    func_convert_path_check : ";" \
3169aa9e3350Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3170aa9e3350Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3171aa9e3350Smrg  fi
3172aa9e3350Smrg}
3173aa9e3350Smrg# end func_convert_path_cygwin_to_w32
3174aa9e3350Smrg
3175aa9e3350Smrg
3176aa9e3350Smrg# func_convert_path_nix_to_w32 ARG
3177aa9e3350Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
3178aa9e3350Smrg# a working winepath.  Returns result in func_to_host_file_result.
3179aa9e3350Smrgfunc_convert_path_nix_to_w32 ()
31806aec45a7Smrg{
3181300bf1aeSmrg  $debug_cmd
3182300bf1aeSmrg
3183300bf1aeSmrg  func_to_host_path_result=$1
3184aa9e3350Smrg  if test -n "$1"; then
3185aa9e3350Smrg    # See func_convert_path_msys_to_w32:
3186aa9e3350Smrg    func_stripname : : "$1"
3187aa9e3350Smrg    func_to_host_path_tmp1=$func_stripname_result
3188aa9e3350Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3189300bf1aeSmrg    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3190aa9e3350Smrg    func_convert_path_check : ";" \
3191aa9e3350Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3192aa9e3350Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3193aa9e3350Smrg  fi
3194aa9e3350Smrg}
3195aa9e3350Smrg# end func_convert_path_nix_to_w32
31966aec45a7Smrg
31976aec45a7Smrg
3198aa9e3350Smrg# func_convert_path_msys_to_cygwin ARG
3199aa9e3350Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
3200aa9e3350Smrg# Returns result in func_to_host_file_result.
3201aa9e3350Smrgfunc_convert_path_msys_to_cygwin ()
3202aa9e3350Smrg{
3203300bf1aeSmrg  $debug_cmd
3204300bf1aeSmrg
3205300bf1aeSmrg  func_to_host_path_result=$1
3206aa9e3350Smrg  if test -n "$1"; then
3207aa9e3350Smrg    # See func_convert_path_msys_to_w32:
3208aa9e3350Smrg    func_stripname : : "$1"
3209aa9e3350Smrg    func_to_host_path_tmp1=$func_stripname_result
3210aa9e3350Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3211aa9e3350Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
3212300bf1aeSmrg    func_to_host_path_result=$func_cygpath_result
3213aa9e3350Smrg    func_convert_path_check : : \
3214aa9e3350Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3215aa9e3350Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3216aa9e3350Smrg  fi
3217aa9e3350Smrg}
3218aa9e3350Smrg# end func_convert_path_msys_to_cygwin
32196aec45a7Smrg
32206aec45a7Smrg
3221aa9e3350Smrg# func_convert_path_nix_to_cygwin ARG
3222aa9e3350Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
3223aa9e3350Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
3224aa9e3350Smrg# func_to_host_file_result.
3225aa9e3350Smrgfunc_convert_path_nix_to_cygwin ()
3226aa9e3350Smrg{
3227300bf1aeSmrg  $debug_cmd
3228300bf1aeSmrg
3229300bf1aeSmrg  func_to_host_path_result=$1
3230aa9e3350Smrg  if test -n "$1"; then
3231aa9e3350Smrg    # Remove leading and trailing path separator characters from
3232aa9e3350Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
3233aa9e3350Smrg    # into '.;' and ';.', and winepath ignores them completely.
3234aa9e3350Smrg    func_stripname : : "$1"
3235aa9e3350Smrg    func_to_host_path_tmp1=$func_stripname_result
3236aa9e3350Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3237aa9e3350Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
3238300bf1aeSmrg    func_to_host_path_result=$func_cygpath_result
3239aa9e3350Smrg    func_convert_path_check : : \
3240aa9e3350Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
3241aa9e3350Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3242aa9e3350Smrg  fi
32436aec45a7Smrg}
3244aa9e3350Smrg# end func_convert_path_nix_to_cygwin
3245aa9e3350Smrg
32466aec45a7Smrg
3247300bf1aeSmrg# func_dll_def_p FILE
3248300bf1aeSmrg# True iff FILE is a Windows DLL '.def' file.
3249300bf1aeSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4
3250300bf1aeSmrgfunc_dll_def_p ()
3251300bf1aeSmrg{
3252300bf1aeSmrg  $debug_cmd
3253300bf1aeSmrg
3254300bf1aeSmrg  func_dll_def_p_tmp=`$SED -n \
3255300bf1aeSmrg    -e 's/^[	 ]*//' \
3256300bf1aeSmrg    -e '/^\(;.*\)*$/d' \
3257300bf1aeSmrg    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
3258300bf1aeSmrg    -e q \
3259300bf1aeSmrg    "$1"`
3260300bf1aeSmrg  test DEF = "$func_dll_def_p_tmp"
3261300bf1aeSmrg}
3262300bf1aeSmrg
3263300bf1aeSmrg
32646aec45a7Smrg# func_mode_compile arg...
32656aec45a7Smrgfunc_mode_compile ()
32666aec45a7Smrg{
3267300bf1aeSmrg    $debug_cmd
3268300bf1aeSmrg
32696aec45a7Smrg    # Get the compilation command and the source file.
32706aec45a7Smrg    base_compile=
3271300bf1aeSmrg    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
32726aec45a7Smrg    suppress_opt=yes
32736aec45a7Smrg    suppress_output=
32746aec45a7Smrg    arg_mode=normal
32756aec45a7Smrg    libobj=
32766aec45a7Smrg    later=
32776aec45a7Smrg    pie_flag=
32786aec45a7Smrg
32796aec45a7Smrg    for arg
32806aec45a7Smrg    do
32816aec45a7Smrg      case $arg_mode in
32826aec45a7Smrg      arg  )
32836aec45a7Smrg	# do not "continue".  Instead, add this to base_compile
3284300bf1aeSmrg	lastarg=$arg
32856aec45a7Smrg	arg_mode=normal
32866aec45a7Smrg	;;
32876aec45a7Smrg
32886aec45a7Smrg      target )
3289300bf1aeSmrg	libobj=$arg
32906aec45a7Smrg	arg_mode=normal
32916aec45a7Smrg	continue
32926aec45a7Smrg	;;
32936aec45a7Smrg
32946aec45a7Smrg      normal )
32956aec45a7Smrg	# Accept any command-line options.
32966aec45a7Smrg	case $arg in
32976aec45a7Smrg	-o)
32986aec45a7Smrg	  test -n "$libobj" && \
3299300bf1aeSmrg	    func_fatal_error "you cannot specify '-o' more than once"
33006aec45a7Smrg	  arg_mode=target
33016aec45a7Smrg	  continue
33026aec45a7Smrg	  ;;
33036aec45a7Smrg
33046aec45a7Smrg	-pie | -fpie | -fPIE)
3305aa9e3350Smrg          func_append pie_flag " $arg"
33066aec45a7Smrg	  continue
33076aec45a7Smrg	  ;;
33086aec45a7Smrg
33096aec45a7Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
3310aa9e3350Smrg	  func_append later " $arg"
33116aec45a7Smrg	  continue
33126aec45a7Smrg	  ;;
33131473d951Smrg
33141473d951Smrg	-no-suppress)
3315ab47cfaaSmrg	  suppress_opt=no
3316ab47cfaaSmrg	  continue
3317ab47cfaaSmrg	  ;;
3318ab47cfaaSmrg
3319ab47cfaaSmrg	-Xcompiler)
3320ab47cfaaSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
3321ab47cfaaSmrg	  continue      #  The current "srcfile" will either be retained or
3322ab47cfaaSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
3323ab47cfaaSmrg
3324ab47cfaaSmrg	-Wc,*)
33256aec45a7Smrg	  func_stripname '-Wc,' '' "$arg"
33266aec45a7Smrg	  args=$func_stripname_result
3327ab47cfaaSmrg	  lastarg=
3328300bf1aeSmrg	  save_ifs=$IFS; IFS=,
33296aec45a7Smrg	  for arg in $args; do
3330300bf1aeSmrg	    IFS=$save_ifs
3331aa9e3350Smrg	    func_append_quoted lastarg "$arg"
3332ab47cfaaSmrg	  done
3333300bf1aeSmrg	  IFS=$save_ifs
33346aec45a7Smrg	  func_stripname ' ' '' "$lastarg"
33356aec45a7Smrg	  lastarg=$func_stripname_result
3336ab47cfaaSmrg
3337ab47cfaaSmrg	  # Add the arguments to base_compile.
3338aa9e3350Smrg	  func_append base_compile " $lastarg"
3339ab47cfaaSmrg	  continue
3340ab47cfaaSmrg	  ;;
3341ab47cfaaSmrg
33426aec45a7Smrg	*)
3343ab47cfaaSmrg	  # Accept the current argument as the source file.
3344ab47cfaaSmrg	  # The previous "srcfile" becomes the current argument.
3345ab47cfaaSmrg	  #
3346300bf1aeSmrg	  lastarg=$srcfile
3347300bf1aeSmrg	  srcfile=$arg
3348ab47cfaaSmrg	  ;;
3349ab47cfaaSmrg	esac  #  case $arg
3350ab47cfaaSmrg	;;
3351ab47cfaaSmrg      esac    #  case $arg_mode
3352ab47cfaaSmrg
3353ab47cfaaSmrg      # Aesthetically quote the previous argument.
3354aa9e3350Smrg      func_append_quoted base_compile "$lastarg"
3355ab47cfaaSmrg    done # for arg
3356ab47cfaaSmrg
3357ab47cfaaSmrg    case $arg_mode in
3358ab47cfaaSmrg    arg)
33596aec45a7Smrg      func_fatal_error "you must specify an argument for -Xcompile"
3360ab47cfaaSmrg      ;;
3361ab47cfaaSmrg    target)
3362300bf1aeSmrg      func_fatal_error "you must specify a target with '-o'"
3363ab47cfaaSmrg      ;;
3364ab47cfaaSmrg    *)
3365ab47cfaaSmrg      # Get the name of the library object.
33666aec45a7Smrg      test -z "$libobj" && {
33676aec45a7Smrg	func_basename "$srcfile"
3368300bf1aeSmrg	libobj=$func_basename_result
33696aec45a7Smrg      }
3370ab47cfaaSmrg      ;;
3371ab47cfaaSmrg    esac
3372ab47cfaaSmrg
3373ab47cfaaSmrg    # Recognize several different file suffixes.
3374ab47cfaaSmrg    # If the user specifies -o file.o, it is replaced with file.lo
3375ab47cfaaSmrg    case $libobj in
33766aec45a7Smrg    *.[cCFSifmso] | \
33776aec45a7Smrg    *.ada | *.adb | *.ads | *.asm | \
33786aec45a7Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3379aa9e3350Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
33806aec45a7Smrg      func_xform "$libobj"
33816aec45a7Smrg      libobj=$func_xform_result
33826aec45a7Smrg      ;;
3383ab47cfaaSmrg    esac
3384ab47cfaaSmrg
3385ab47cfaaSmrg    case $libobj in
33866aec45a7Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3387ab47cfaaSmrg    *)
3388300bf1aeSmrg      func_fatal_error "cannot determine name of library object from '$libobj'"
3389ab47cfaaSmrg      ;;
3390ab47cfaaSmrg    esac
3391ab47cfaaSmrg
3392ab47cfaaSmrg    func_infer_tag $base_compile
3393ab47cfaaSmrg
3394ab47cfaaSmrg    for arg in $later; do
3395ab47cfaaSmrg      case $arg in
33966aec45a7Smrg      -shared)
3397300bf1aeSmrg	test yes = "$build_libtool_libs" \
3398300bf1aeSmrg	  || func_fatal_configuration "cannot build a shared library"
33996aec45a7Smrg	build_old_libs=no
34006aec45a7Smrg	continue
34016aec45a7Smrg	;;
34026aec45a7Smrg
3403ab47cfaaSmrg      -static)
34046aec45a7Smrg	build_libtool_libs=no
3405ab47cfaaSmrg	build_old_libs=yes
3406ab47cfaaSmrg	continue
3407ab47cfaaSmrg	;;
3408ab47cfaaSmrg
3409ab47cfaaSmrg      -prefer-pic)
3410ab47cfaaSmrg	pic_mode=yes
3411ab47cfaaSmrg	continue
3412ab47cfaaSmrg	;;
3413ab47cfaaSmrg
3414ab47cfaaSmrg      -prefer-non-pic)
3415ab47cfaaSmrg	pic_mode=no
3416ab47cfaaSmrg	continue
3417ab47cfaaSmrg	;;
3418ab47cfaaSmrg      esac
3419ab47cfaaSmrg    done
3420ab47cfaaSmrg
34216aec45a7Smrg    func_quote_for_eval "$libobj"
34226aec45a7Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
34236aec45a7Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
3424300bf1aeSmrg      && func_warning "libobj name '$libobj' may not contain shell special characters."
34256aec45a7Smrg    func_dirname_and_basename "$obj" "/" ""
3426300bf1aeSmrg    objname=$func_basename_result
3427300bf1aeSmrg    xdir=$func_dirname_result
3428300bf1aeSmrg    lobj=$xdir$objdir/$objname
3429ab47cfaaSmrg
34306aec45a7Smrg    test -z "$base_compile" && \
34316aec45a7Smrg      func_fatal_help "you must specify a compilation command"
3432ab47cfaaSmrg
3433ab47cfaaSmrg    # Delete any leftover library objects.
3434300bf1aeSmrg    if test yes = "$build_old_libs"; then
3435ab47cfaaSmrg      removelist="$obj $lobj $libobj ${libobj}T"
3436ab47cfaaSmrg    else
3437ab47cfaaSmrg      removelist="$lobj $libobj ${libobj}T"
3438ab47cfaaSmrg    fi
3439ab47cfaaSmrg
3440ab47cfaaSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
3441ab47cfaaSmrg    case $host_os in
34426aec45a7Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
3443ab47cfaaSmrg      pic_mode=default
3444ab47cfaaSmrg      ;;
3445ab47cfaaSmrg    esac
3446300bf1aeSmrg    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3447ab47cfaaSmrg      # non-PIC code in shared libraries is not supported
3448ab47cfaaSmrg      pic_mode=default
3449ab47cfaaSmrg    fi
3450ab47cfaaSmrg
3451ab47cfaaSmrg    # Calculate the filename of the output object if compiler does
3452ab47cfaaSmrg    # not support -o with -c
3453300bf1aeSmrg    if test no = "$compiler_c_o"; then
3454300bf1aeSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
3455300bf1aeSmrg      lockfile=$output_obj.lock
3456ab47cfaaSmrg    else
3457ab47cfaaSmrg      output_obj=
3458ab47cfaaSmrg      need_locks=no
3459ab47cfaaSmrg      lockfile=
3460ab47cfaaSmrg    fi
3461ab47cfaaSmrg
3462ab47cfaaSmrg    # Lock this critical section if it is needed
3463ab47cfaaSmrg    # We use this script file to make the link, it avoids creating a new file
3464300bf1aeSmrg    if test yes = "$need_locks"; then
34656aec45a7Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
34666aec45a7Smrg	func_echo "Waiting for $lockfile to be removed"
3467ab47cfaaSmrg	sleep 2
3468ab47cfaaSmrg      done
3469300bf1aeSmrg    elif test warn = "$need_locks"; then
3470ab47cfaaSmrg      if test -f "$lockfile"; then
34716aec45a7Smrg	$ECHO "\
3472ab47cfaaSmrg*** ERROR, $lockfile exists and contains:
3473ab47cfaaSmrg`cat $lockfile 2>/dev/null`
3474ab47cfaaSmrg
3475ab47cfaaSmrgThis indicates that another process is trying to use the same
3476ab47cfaaSmrgtemporary object file, and libtool could not work around it because
3477300bf1aeSmrgyour compiler does not support '-c' and '-o' together.  If you
3478ab47cfaaSmrgrepeat this compilation, it may succeed, by chance, but you had better
3479ab47cfaaSmrgavoid parallel builds (make -j) in this platform, or get a better
3480ab47cfaaSmrgcompiler."
3481ab47cfaaSmrg
34826aec45a7Smrg	$opt_dry_run || $RM $removelist
3483ab47cfaaSmrg	exit $EXIT_FAILURE
3484ab47cfaaSmrg      fi
3485aa9e3350Smrg      func_append removelist " $output_obj"
34866aec45a7Smrg      $ECHO "$srcfile" > "$lockfile"
3487ab47cfaaSmrg    fi
3488ab47cfaaSmrg
34896aec45a7Smrg    $opt_dry_run || $RM $removelist
3490aa9e3350Smrg    func_append removelist " $lockfile"
34916aec45a7Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
34926aec45a7Smrg
3493aa9e3350Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3494aa9e3350Smrg    srcfile=$func_to_tool_file_result
34956aec45a7Smrg    func_quote_for_eval "$srcfile"
34966aec45a7Smrg    qsrcfile=$func_quote_for_eval_result
3497ab47cfaaSmrg
3498ab47cfaaSmrg    # Only build a PIC object if we are building libtool libraries.
3499300bf1aeSmrg    if test yes = "$build_libtool_libs"; then
3500ab47cfaaSmrg      # Without this assignment, base_compile gets emptied.
3501ab47cfaaSmrg      fbsd_hideous_sh_bug=$base_compile
3502ab47cfaaSmrg
3503300bf1aeSmrg      if test no != "$pic_mode"; then
3504ab47cfaaSmrg	command="$base_compile $qsrcfile $pic_flag"
3505ab47cfaaSmrg      else
3506ab47cfaaSmrg	# Don't build PIC code
3507ab47cfaaSmrg	command="$base_compile $qsrcfile"
3508ab47cfaaSmrg      fi
3509ab47cfaaSmrg
35106aec45a7Smrg      func_mkdir_p "$xdir$objdir"
3511ab47cfaaSmrg
3512ab47cfaaSmrg      if test -z "$output_obj"; then
3513ab47cfaaSmrg	# Place PIC objects in $objdir
3514aa9e3350Smrg	func_append command " -o $lobj"
3515ab47cfaaSmrg      fi
3516ab47cfaaSmrg
35176aec45a7Smrg      func_show_eval_locale "$command"	\
35186aec45a7Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3519ab47cfaaSmrg
3520300bf1aeSmrg      if test warn = "$need_locks" &&
3521ab47cfaaSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
35226aec45a7Smrg	$ECHO "\
3523ab47cfaaSmrg*** ERROR, $lockfile contains:
3524ab47cfaaSmrg`cat $lockfile 2>/dev/null`
3525ab47cfaaSmrg
3526ab47cfaaSmrgbut it should contain:
3527ab47cfaaSmrg$srcfile
3528ab47cfaaSmrg
3529ab47cfaaSmrgThis indicates that another process is trying to use the same
3530ab47cfaaSmrgtemporary object file, and libtool could not work around it because
3531300bf1aeSmrgyour compiler does not support '-c' and '-o' together.  If you
3532ab47cfaaSmrgrepeat this compilation, it may succeed, by chance, but you had better
3533ab47cfaaSmrgavoid parallel builds (make -j) in this platform, or get a better
3534ab47cfaaSmrgcompiler."
3535ab47cfaaSmrg
35366aec45a7Smrg	$opt_dry_run || $RM $removelist
3537ab47cfaaSmrg	exit $EXIT_FAILURE
3538ab47cfaaSmrg      fi
3539ab47cfaaSmrg
3540ab47cfaaSmrg      # Just move the object if needed, then go on to compile the next one
3541ab47cfaaSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
35426aec45a7Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
35436aec45a7Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3544ab47cfaaSmrg      fi
3545ab47cfaaSmrg
3546ab47cfaaSmrg      # Allow error messages only from the first compilation.
3547300bf1aeSmrg      if test yes = "$suppress_opt"; then
35486aec45a7Smrg	suppress_output=' >/dev/null 2>&1'
3549ab47cfaaSmrg      fi
3550ab47cfaaSmrg    fi
3551ab47cfaaSmrg
3552ab47cfaaSmrg    # Only build a position-dependent object if we build old libraries.
3553300bf1aeSmrg    if test yes = "$build_old_libs"; then
3554300bf1aeSmrg      if test yes != "$pic_mode"; then
3555ab47cfaaSmrg	# Don't build PIC code
35566aec45a7Smrg	command="$base_compile $qsrcfile$pie_flag"
3557ab47cfaaSmrg      else
3558ab47cfaaSmrg	command="$base_compile $qsrcfile $pic_flag"
3559ab47cfaaSmrg      fi
3560300bf1aeSmrg      if test yes = "$compiler_c_o"; then
3561aa9e3350Smrg	func_append command " -o $obj"
3562ab47cfaaSmrg      fi
3563ab47cfaaSmrg
3564ab47cfaaSmrg      # Suppress compiler output if we already did a PIC compilation.
3565aa9e3350Smrg      func_append command "$suppress_output"
35666aec45a7Smrg      func_show_eval_locale "$command" \
35676aec45a7Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3568ab47cfaaSmrg
3569300bf1aeSmrg      if test warn = "$need_locks" &&
3570ab47cfaaSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
35716aec45a7Smrg	$ECHO "\
3572ab47cfaaSmrg*** ERROR, $lockfile contains:
3573ab47cfaaSmrg`cat $lockfile 2>/dev/null`
3574ab47cfaaSmrg
3575ab47cfaaSmrgbut it should contain:
3576ab47cfaaSmrg$srcfile
3577ab47cfaaSmrg
3578ab47cfaaSmrgThis indicates that another process is trying to use the same
3579ab47cfaaSmrgtemporary object file, and libtool could not work around it because
3580300bf1aeSmrgyour compiler does not support '-c' and '-o' together.  If you
3581ab47cfaaSmrgrepeat this compilation, it may succeed, by chance, but you had better
3582ab47cfaaSmrgavoid parallel builds (make -j) in this platform, or get a better
3583ab47cfaaSmrgcompiler."
3584ab47cfaaSmrg
35856aec45a7Smrg	$opt_dry_run || $RM $removelist
3586ab47cfaaSmrg	exit $EXIT_FAILURE
3587ab47cfaaSmrg      fi
3588ab47cfaaSmrg
3589ab47cfaaSmrg      # Just move the object if needed
3590ab47cfaaSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
35916aec45a7Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
35926aec45a7Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3593ab47cfaaSmrg      fi
3594ab47cfaaSmrg    fi
3595ab47cfaaSmrg
35966aec45a7Smrg    $opt_dry_run || {
35976aec45a7Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3598ab47cfaaSmrg
35996aec45a7Smrg      # Unlock the critical section if it was locked
3600300bf1aeSmrg      if test no != "$need_locks"; then
36016aec45a7Smrg	removelist=$lockfile
36026aec45a7Smrg        $RM "$lockfile"
36036aec45a7Smrg      fi
36046aec45a7Smrg    }
3605ab47cfaaSmrg
3606ab47cfaaSmrg    exit $EXIT_SUCCESS
36076aec45a7Smrg}
3608ab47cfaaSmrg
36096aec45a7Smrg$opt_help || {
3610300bf1aeSmrg  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
36116aec45a7Smrg}
3612ab47cfaaSmrg
36136aec45a7Smrgfunc_mode_help ()
36146aec45a7Smrg{
36156aec45a7Smrg    # We need to display help for each of the modes.
3616aa9e3350Smrg    case $opt_mode in
36176aec45a7Smrg      "")
36186aec45a7Smrg        # Generic help is extracted from the usage comments
36196aec45a7Smrg        # at the start of this file.
36206aec45a7Smrg        func_help
36216aec45a7Smrg        ;;
3622ab47cfaaSmrg
36236aec45a7Smrg      clean)
36246aec45a7Smrg        $ECHO \
36256aec45a7Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3626ab47cfaaSmrg
36276aec45a7SmrgRemove files from the build directory.
3628ab47cfaaSmrg
36296aec45a7SmrgRM is the name of the program to use to delete files associated with each FILE
3630300bf1aeSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
36316aec45a7Smrgto RM.
3632ab47cfaaSmrg
36336aec45a7SmrgIf FILE is a libtool library, object or program, all the files associated
36346aec45a7Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
36356aec45a7Smrg        ;;
3636ab47cfaaSmrg
36376aec45a7Smrg      compile)
36386aec45a7Smrg      $ECHO \
36396aec45a7Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3640ab47cfaaSmrg
36416aec45a7SmrgCompile a source file into a libtool library object.
3642ab47cfaaSmrg
36436aec45a7SmrgThis mode accepts the following additional options:
3644ab47cfaaSmrg
36456aec45a7Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
36466aec45a7Smrg  -no-suppress      do not suppress compiler output for multiple passes
36476aec45a7Smrg  -prefer-pic       try to build PIC objects only
36486aec45a7Smrg  -prefer-non-pic   try to build non-PIC objects only
3649300bf1aeSmrg  -shared           do not build a '.o' file suitable for static linking
3650300bf1aeSmrg  -static           only build a '.o' file suitable for static linking
36516aec45a7Smrg  -Wc,FLAG          pass FLAG directly to the compiler
3652ab47cfaaSmrg
3653300bf1aeSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file
36546aec45a7Smrgfrom the given SOURCEFILE.
3655ab47cfaaSmrg
36566aec45a7SmrgThe output file name is determined by removing the directory component from
3657300bf1aeSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the
3658300bf1aeSmrglibrary object suffix, '.lo'."
36596aec45a7Smrg        ;;
3660ab47cfaaSmrg
36616aec45a7Smrg      execute)
36626aec45a7Smrg        $ECHO \
36636aec45a7Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3664ab47cfaaSmrg
36656aec45a7SmrgAutomatically set library path, then run a program.
3666ab47cfaaSmrg
36676aec45a7SmrgThis mode accepts the following additional options:
3668ab47cfaaSmrg
36696aec45a7Smrg  -dlopen FILE      add the directory containing FILE to the library path
3670ab47cfaaSmrg
3671300bf1aeSmrgThis mode sets the library path environment variable according to '-dlopen'
36726aec45a7Smrgflags.
3673ab47cfaaSmrg
36746aec45a7SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
36756aec45a7Smrginto their corresponding uninstalled binary, and any of their required library
36766aec45a7Smrgdirectories are added to the library path.
3677ab47cfaaSmrg
36786aec45a7SmrgThen, COMMAND is executed, with ARGS as arguments."
36796aec45a7Smrg        ;;
3680ab47cfaaSmrg
36816aec45a7Smrg      finish)
36826aec45a7Smrg        $ECHO \
36836aec45a7Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3684ab47cfaaSmrg
36856aec45a7SmrgComplete the installation of libtool libraries.
3686ab47cfaaSmrg
36876aec45a7SmrgEach LIBDIR is a directory that contains libtool libraries.
3688ab47cfaaSmrg
36896aec45a7SmrgThe commands that this mode executes may require superuser privileges.  Use
3690300bf1aeSmrgthe '--dry-run' option if you just want to see what would be executed."
36916aec45a7Smrg        ;;
3692ab47cfaaSmrg
36936aec45a7Smrg      install)
36946aec45a7Smrg        $ECHO \
36956aec45a7Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3696ab47cfaaSmrg
36976aec45a7SmrgInstall executables or libraries.
3698ab47cfaaSmrg
36996aec45a7SmrgINSTALL-COMMAND is the installation command.  The first component should be
3700300bf1aeSmrgeither the 'install' or 'cp' program.
3701ab47cfaaSmrg
37026aec45a7SmrgThe following components of INSTALL-COMMAND are treated specially:
3703ab47cfaaSmrg
37046aec45a7Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
3705ab47cfaaSmrg
37066aec45a7SmrgThe rest of the components are interpreted as arguments to that command (only
37076aec45a7SmrgBSD-compatible install options are recognized)."
37086aec45a7Smrg        ;;
3709ab47cfaaSmrg
37106aec45a7Smrg      link)
37116aec45a7Smrg        $ECHO \
37126aec45a7Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3713ab47cfaaSmrg
37146aec45a7SmrgLink object files or libraries together to form another library, or to
37156aec45a7Smrgcreate an executable program.
3716ab47cfaaSmrg
37176aec45a7SmrgLINK-COMMAND is a command using the C compiler that you would use to create
37186aec45a7Smrga program from several object files.
3719ab47cfaaSmrg
37206aec45a7SmrgThe following components of LINK-COMMAND are treated specially:
3721ab47cfaaSmrg
37226aec45a7Smrg  -all-static       do not do any dynamic linking at all
37236aec45a7Smrg  -avoid-version    do not add a version suffix if possible
37246aec45a7Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
37256aec45a7Smrg                    libraries must be found in the PATH setting at runtime)
3726300bf1aeSmrg  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
37276aec45a7Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
37286aec45a7Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
37296aec45a7Smrg  -export-symbols SYMFILE
37306aec45a7Smrg                    try to export only the symbols listed in SYMFILE
37316aec45a7Smrg  -export-symbols-regex REGEX
37326aec45a7Smrg                    try to export only the symbols matching REGEX
37336aec45a7Smrg  -LLIBDIR          search LIBDIR for required installed libraries
37346aec45a7Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
37356aec45a7Smrg  -module           build a library that can dlopened
37366aec45a7Smrg  -no-fast-install  disable the fast-install mode
37376aec45a7Smrg  -no-install       link a not-installable executable
37386aec45a7Smrg  -no-undefined     declare that a library does not refer to external symbols
37396aec45a7Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
3740300bf1aeSmrg  -objectlist FILE  use a list of object files found in FILE to specify objects
3741300bf1aeSmrg  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
37426aec45a7Smrg  -precious-files-regex REGEX
37436aec45a7Smrg                    don't remove output files matching REGEX
37446aec45a7Smrg  -release RELEASE  specify package release information
37456aec45a7Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
37466aec45a7Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
37476aec45a7Smrg  -shared           only do dynamic linking of libtool libraries
37486aec45a7Smrg  -shrext SUFFIX    override the standard shared library file extension
37496aec45a7Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
37506aec45a7Smrg  -static-libtool-libs
37516aec45a7Smrg                    do not do any dynamic linking of libtool libraries
37526aec45a7Smrg  -version-info CURRENT[:REVISION[:AGE]]
37536aec45a7Smrg                    specify library version info [each variable defaults to 0]
37546aec45a7Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
37556aec45a7Smrg  -Wc,FLAG
37566aec45a7Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
37576aec45a7Smrg  -Wl,FLAG
37586aec45a7Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
37596aec45a7Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
3760ab47cfaaSmrg
3761300bf1aeSmrgAll other options (arguments beginning with '-') are ignored.
3762ab47cfaaSmrg
3763300bf1aeSmrgEvery other argument is treated as a filename.  Files ending in '.la' are
37646aec45a7Smrgtreated as uninstalled libtool libraries, other files are standard or library
37656aec45a7Smrgobject files.
3766ab47cfaaSmrg
3767300bf1aeSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created,
3768300bf1aeSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is
37696aec45a7Smrgrequired, except when creating a convenience library.
3770ab47cfaaSmrg
3771300bf1aeSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
3772300bf1aeSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'.
3773ab47cfaaSmrg
3774300bf1aeSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
37756aec45a7Smrgis created, otherwise an executable program is created."
37766aec45a7Smrg        ;;
3777ab47cfaaSmrg
37786aec45a7Smrg      uninstall)
37796aec45a7Smrg        $ECHO \
37806aec45a7Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3781ab47cfaaSmrg
37826aec45a7SmrgRemove libraries from an installation directory.
3783ab47cfaaSmrg
37846aec45a7SmrgRM is the name of the program to use to delete files associated with each FILE
3785300bf1aeSmrg(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
37866aec45a7Smrgto RM.
3787ab47cfaaSmrg
37886aec45a7SmrgIf FILE is a libtool library, all the files associated with it are deleted.
37896aec45a7SmrgOtherwise, only FILE itself is deleted using RM."
37906aec45a7Smrg        ;;
3791ab47cfaaSmrg
37926aec45a7Smrg      *)
3793300bf1aeSmrg        func_fatal_help "invalid operation mode '$opt_mode'"
37946aec45a7Smrg        ;;
37956aec45a7Smrg    esac
3796ab47cfaaSmrg
37976aec45a7Smrg    echo
3798300bf1aeSmrg    $ECHO "Try '$progname --help' for more information about other modes."
37996aec45a7Smrg}
38001473d951Smrg
38016aec45a7Smrg# Now that we've collected a possible --mode arg, show help if necessary
38026aec45a7Smrgif $opt_help; then
3803300bf1aeSmrg  if test : = "$opt_help"; then
38046aec45a7Smrg    func_mode_help
38056aec45a7Smrg  else
38066aec45a7Smrg    {
38076aec45a7Smrg      func_help noexit
3808aa9e3350Smrg      for opt_mode in compile link execute install finish uninstall clean; do
38096aec45a7Smrg	func_mode_help
38106aec45a7Smrg      done
3811300bf1aeSmrg    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
38126aec45a7Smrg    {
38136aec45a7Smrg      func_help noexit
3814aa9e3350Smrg      for opt_mode in compile link execute install finish uninstall clean; do
38156aec45a7Smrg	echo
38166aec45a7Smrg	func_mode_help
38176aec45a7Smrg      done
38186aec45a7Smrg    } |
3819300bf1aeSmrg    $SED '1d
38206aec45a7Smrg      /^When reporting/,/^Report/{
38216aec45a7Smrg	H
38226aec45a7Smrg	d
38236aec45a7Smrg      }
38246aec45a7Smrg      $x
38256aec45a7Smrg      /information about other modes/d
38266aec45a7Smrg      /more detailed .*MODE/d
38276aec45a7Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
38286aec45a7Smrg  fi
38296aec45a7Smrg  exit $?
38306aec45a7Smrgfi
38311473d951Smrg
38321473d951Smrg
38336aec45a7Smrg# func_mode_execute arg...
38346aec45a7Smrgfunc_mode_execute ()
38356aec45a7Smrg{
3836300bf1aeSmrg    $debug_cmd
3837300bf1aeSmrg
38386aec45a7Smrg    # The first argument is the command name.
3839300bf1aeSmrg    cmd=$nonopt
38406aec45a7Smrg    test -z "$cmd" && \
38416aec45a7Smrg      func_fatal_help "you must specify a COMMAND"
38421473d951Smrg
38436aec45a7Smrg    # Handle -dlopen flags immediately.
3844aa9e3350Smrg    for file in $opt_dlopen; do
38456aec45a7Smrg      test -f "$file" \
3846300bf1aeSmrg	|| func_fatal_help "'$file' is not a file"
38471473d951Smrg
38486aec45a7Smrg      dir=
38496aec45a7Smrg      case $file in
38506aec45a7Smrg      *.la)
3851aa9e3350Smrg	func_resolve_sysroot "$file"
3852aa9e3350Smrg	file=$func_resolve_sysroot_result
3853aa9e3350Smrg
38546aec45a7Smrg	# Check to see that this really is a libtool archive.
38556aec45a7Smrg	func_lalib_unsafe_p "$file" \
3856300bf1aeSmrg	  || func_fatal_help "'$lib' is not a valid libtool archive"
38571473d951Smrg
38586aec45a7Smrg	# Read the libtool library.
38596aec45a7Smrg	dlname=
38606aec45a7Smrg	library_names=
38616aec45a7Smrg	func_source "$file"
38621473d951Smrg
38636aec45a7Smrg	# Skip this library if it cannot be dlopened.
38646aec45a7Smrg	if test -z "$dlname"; then
38656aec45a7Smrg	  # Warn if it was a shared library.
38666aec45a7Smrg	  test -n "$library_names" && \
3867300bf1aeSmrg	    func_warning "'$file' was not linked with '-export-dynamic'"
38686aec45a7Smrg	  continue
38696aec45a7Smrg	fi
38705c42550eSmrg
38716aec45a7Smrg	func_dirname "$file" "" "."
3872300bf1aeSmrg	dir=$func_dirname_result
38735c42550eSmrg
38746aec45a7Smrg	if test -f "$dir/$objdir/$dlname"; then
3875aa9e3350Smrg	  func_append dir "/$objdir"
38766aec45a7Smrg	else
38776aec45a7Smrg	  if test ! -f "$dir/$dlname"; then
3878300bf1aeSmrg	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
38796aec45a7Smrg	  fi
38806aec45a7Smrg	fi
38811473d951Smrg	;;
38825c42550eSmrg
38836aec45a7Smrg      *.lo)
38846aec45a7Smrg	# Just add the directory containing the .lo file.
38856aec45a7Smrg	func_dirname "$file" "" "."
3886300bf1aeSmrg	dir=$func_dirname_result
38871473d951Smrg	;;
38886aec45a7Smrg
38896aec45a7Smrg      *)
3890300bf1aeSmrg	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
38915c42550eSmrg	continue
3892ab47cfaaSmrg	;;
38936aec45a7Smrg      esac
3894ab47cfaaSmrg
38956aec45a7Smrg      # Get the absolute pathname.
38966aec45a7Smrg      absdir=`cd "$dir" && pwd`
3897300bf1aeSmrg      test -n "$absdir" && dir=$absdir
3898ab47cfaaSmrg
38996aec45a7Smrg      # Now add the directory to shlibpath_var.
39006aec45a7Smrg      if eval "test -z \"\$$shlibpath_var\""; then
39016aec45a7Smrg	eval "$shlibpath_var=\"\$dir\""
39026aec45a7Smrg      else
39036aec45a7Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
39046aec45a7Smrg      fi
39056aec45a7Smrg    done
3906ab47cfaaSmrg
39076aec45a7Smrg    # This variable tells wrapper scripts just to set shlibpath_var
39086aec45a7Smrg    # rather than running their programs.
3909300bf1aeSmrg    libtool_execute_magic=$magic
3910ab47cfaaSmrg
39116aec45a7Smrg    # Check if any of the arguments is a wrapper script.
39126aec45a7Smrg    args=
39136aec45a7Smrg    for file
39146aec45a7Smrg    do
39156aec45a7Smrg      case $file in
39166aec45a7Smrg      -* | *.la | *.lo ) ;;
39176aec45a7Smrg      *)
39186aec45a7Smrg	# Do a test to see if this is really a libtool program.
39196aec45a7Smrg	if func_ltwrapper_script_p "$file"; then
39206aec45a7Smrg	  func_source "$file"
39216aec45a7Smrg	  # Transform arg to wrapped name.
3922300bf1aeSmrg	  file=$progdir/$program
39236aec45a7Smrg	elif func_ltwrapper_executable_p "$file"; then
39246aec45a7Smrg	  func_ltwrapper_scriptname "$file"
39256aec45a7Smrg	  func_source "$func_ltwrapper_scriptname_result"
39266aec45a7Smrg	  # Transform arg to wrapped name.
3927300bf1aeSmrg	  file=$progdir/$program
39286aec45a7Smrg	fi
39295c42550eSmrg	;;
39306aec45a7Smrg      esac
39316aec45a7Smrg      # Quote arguments (to preserve shell metacharacters).
3932aa9e3350Smrg      func_append_quoted args "$file"
39336aec45a7Smrg    done
3934ab47cfaaSmrg
3935300bf1aeSmrg    if $opt_dry_run; then
3936300bf1aeSmrg      # Display what would be done.
3937300bf1aeSmrg      if test -n "$shlibpath_var"; then
3938300bf1aeSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
3939300bf1aeSmrg	echo "export $shlibpath_var"
3940300bf1aeSmrg      fi
3941300bf1aeSmrg      $ECHO "$cmd$args"
3942300bf1aeSmrg      exit $EXIT_SUCCESS
3943300bf1aeSmrg    else
39446aec45a7Smrg      if test -n "$shlibpath_var"; then
39456aec45a7Smrg	# Export the shlibpath_var.
39466aec45a7Smrg	eval "export $shlibpath_var"
39476aec45a7Smrg      fi
3948ab47cfaaSmrg
39496aec45a7Smrg      # Restore saved environment variables
39506aec45a7Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
39516aec45a7Smrg      do
39526aec45a7Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
39536aec45a7Smrg                $lt_var=\$save_$lt_var; export $lt_var
39546aec45a7Smrg	      else
39556aec45a7Smrg		$lt_unset $lt_var
39566aec45a7Smrg	      fi"
39576aec45a7Smrg      done
3958ab47cfaaSmrg
39596aec45a7Smrg      # Now prepare to actually exec the command.
3960300bf1aeSmrg      exec_cmd=\$cmd$args
39616aec45a7Smrg    fi
39626aec45a7Smrg}
39631473d951Smrg
3964300bf1aeSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"}
39651473d951Smrg
39661473d951Smrg
39676aec45a7Smrg# func_mode_finish arg...
39686aec45a7Smrgfunc_mode_finish ()
39696aec45a7Smrg{
3970300bf1aeSmrg    $debug_cmd
3971300bf1aeSmrg
3972aa9e3350Smrg    libs=
3973aa9e3350Smrg    libdirs=
39746aec45a7Smrg    admincmds=
39751473d951Smrg
3976aa9e3350Smrg    for opt in "$nonopt" ${1+"$@"}
3977aa9e3350Smrg    do
3978aa9e3350Smrg      if test -d "$opt"; then
3979aa9e3350Smrg	func_append libdirs " $opt"
3980aa9e3350Smrg
3981aa9e3350Smrg      elif test -f "$opt"; then
3982aa9e3350Smrg	if func_lalib_unsafe_p "$opt"; then
3983aa9e3350Smrg	  func_append libs " $opt"
3984aa9e3350Smrg	else
3985300bf1aeSmrg	  func_warning "'$opt' is not a valid libtool archive"
3986aa9e3350Smrg	fi
3987aa9e3350Smrg
3988aa9e3350Smrg      else
3989300bf1aeSmrg	func_fatal_error "invalid argument '$opt'"
3990aa9e3350Smrg      fi
3991aa9e3350Smrg    done
3992aa9e3350Smrg
3993aa9e3350Smrg    if test -n "$libs"; then
3994aa9e3350Smrg      if test -n "$lt_sysroot"; then
3995aa9e3350Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
3996aa9e3350Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
3997aa9e3350Smrg      else
3998aa9e3350Smrg        sysroot_cmd=
3999aa9e3350Smrg      fi
4000aa9e3350Smrg
4001aa9e3350Smrg      # Remove sysroot references
4002aa9e3350Smrg      if $opt_dry_run; then
4003aa9e3350Smrg        for lib in $libs; do
4004300bf1aeSmrg          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
4005aa9e3350Smrg        done
4006aa9e3350Smrg      else
4007aa9e3350Smrg        tmpdir=`func_mktempdir`
4008aa9e3350Smrg        for lib in $libs; do
4009300bf1aeSmrg	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
4010aa9e3350Smrg	    > $tmpdir/tmp-la
4011aa9e3350Smrg	  mv -f $tmpdir/tmp-la $lib
4012aa9e3350Smrg	done
4013aa9e3350Smrg        ${RM}r "$tmpdir"
4014aa9e3350Smrg      fi
4015aa9e3350Smrg    fi
40161473d951Smrg
4017aa9e3350Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
40186aec45a7Smrg      for libdir in $libdirs; do
40196aec45a7Smrg	if test -n "$finish_cmds"; then
40206aec45a7Smrg	  # Do each command in the finish commands.
40216aec45a7Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
40226aec45a7Smrg'"$cmd"'"'
40236aec45a7Smrg	fi
40246aec45a7Smrg	if test -n "$finish_eval"; then
40256aec45a7Smrg	  # Do the single finish_eval.
40266aec45a7Smrg	  eval cmds=\"$finish_eval\"
4027aa9e3350Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
40286aec45a7Smrg       $cmds"
40296aec45a7Smrg	fi
40306aec45a7Smrg      done
40316aec45a7Smrg    fi
40321473d951Smrg
40336aec45a7Smrg    # Exit here if they wanted silent mode.
4034300bf1aeSmrg    $opt_quiet && exit $EXIT_SUCCESS
40351473d951Smrg
4036aa9e3350Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
4037aa9e3350Smrg      echo "----------------------------------------------------------------------"
4038aa9e3350Smrg      echo "Libraries have been installed in:"
4039aa9e3350Smrg      for libdir in $libdirs; do
4040aa9e3350Smrg	$ECHO "   $libdir"
4041aa9e3350Smrg      done
4042aa9e3350Smrg      echo
4043aa9e3350Smrg      echo "If you ever happen to want to link against installed libraries"
4044aa9e3350Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
4045300bf1aeSmrg      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
4046aa9e3350Smrg      echo "flag during linking and do at least one of the following:"
4047aa9e3350Smrg      if test -n "$shlibpath_var"; then
4048300bf1aeSmrg	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
4049aa9e3350Smrg	echo "     during execution"
4050aa9e3350Smrg      fi
4051aa9e3350Smrg      if test -n "$runpath_var"; then
4052300bf1aeSmrg	echo "   - add LIBDIR to the '$runpath_var' environment variable"
4053aa9e3350Smrg	echo "     during linking"
4054aa9e3350Smrg      fi
4055aa9e3350Smrg      if test -n "$hardcode_libdir_flag_spec"; then
4056aa9e3350Smrg	libdir=LIBDIR
4057aa9e3350Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
40581473d951Smrg
4059300bf1aeSmrg	$ECHO "   - use the '$flag' linker flag"
4060aa9e3350Smrg      fi
4061aa9e3350Smrg      if test -n "$admincmds"; then
4062aa9e3350Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
4063aa9e3350Smrg      fi
4064aa9e3350Smrg      if test -f /etc/ld.so.conf; then
4065300bf1aeSmrg	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
4066aa9e3350Smrg      fi
4067aa9e3350Smrg      echo
40681473d951Smrg
4069aa9e3350Smrg      echo "See any operating system documentation about shared libraries for"
4070aa9e3350Smrg      case $host in
4071aa9e3350Smrg	solaris2.[6789]|solaris2.1[0-9])
4072aa9e3350Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
4073aa9e3350Smrg	  echo "pages."
4074aa9e3350Smrg	  ;;
4075aa9e3350Smrg	*)
4076aa9e3350Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
4077aa9e3350Smrg	  ;;
4078aa9e3350Smrg      esac
4079aa9e3350Smrg      echo "----------------------------------------------------------------------"
4080aa9e3350Smrg    fi
40816aec45a7Smrg    exit $EXIT_SUCCESS
40826aec45a7Smrg}
40831473d951Smrg
4084300bf1aeSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"}
40855c42550eSmrg
4086ab47cfaaSmrg
40876aec45a7Smrg# func_mode_install arg...
40886aec45a7Smrgfunc_mode_install ()
40896aec45a7Smrg{
4090300bf1aeSmrg    $debug_cmd
4091300bf1aeSmrg
40926aec45a7Smrg    # There may be an optional sh(1) argument at the beginning of
40936aec45a7Smrg    # install_prog (especially on Windows NT).
4094300bf1aeSmrg    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
40956aec45a7Smrg       # Allow the use of GNU shtool's install command.
4096300bf1aeSmrg       case $nonopt in *shtool*) :;; *) false;; esac
4097300bf1aeSmrg    then
40986aec45a7Smrg      # Aesthetically quote it.
40996aec45a7Smrg      func_quote_for_eval "$nonopt"
41006aec45a7Smrg      install_prog="$func_quote_for_eval_result "
41016aec45a7Smrg      arg=$1
41026aec45a7Smrg      shift
41036aec45a7Smrg    else
41046aec45a7Smrg      install_prog=
41056aec45a7Smrg      arg=$nonopt
41066aec45a7Smrg    fi
4107ab47cfaaSmrg
41086aec45a7Smrg    # The real first argument should be the name of the installation program.
41096aec45a7Smrg    # Aesthetically quote it.
41106aec45a7Smrg    func_quote_for_eval "$arg"
4111aa9e3350Smrg    func_append install_prog "$func_quote_for_eval_result"
41126aec45a7Smrg    install_shared_prog=$install_prog
41136aec45a7Smrg    case " $install_prog " in
41146aec45a7Smrg      *[\\\ /]cp\ *) install_cp=: ;;
41156aec45a7Smrg      *) install_cp=false ;;
41166aec45a7Smrg    esac
4117ab47cfaaSmrg
41186aec45a7Smrg    # We need to accept at least all the BSD install flags.
41196aec45a7Smrg    dest=
41206aec45a7Smrg    files=
41216aec45a7Smrg    opts=
41226aec45a7Smrg    prev=
41236aec45a7Smrg    install_type=
4124300bf1aeSmrg    isdir=false
41256aec45a7Smrg    stripme=
41266aec45a7Smrg    no_mode=:
41276aec45a7Smrg    for arg
41286aec45a7Smrg    do
41296aec45a7Smrg      arg2=
41306aec45a7Smrg      if test -n "$dest"; then
4131aa9e3350Smrg	func_append files " $dest"
41326aec45a7Smrg	dest=$arg
41335c42550eSmrg	continue
41346aec45a7Smrg      fi
4135ab47cfaaSmrg
41366aec45a7Smrg      case $arg in
4137300bf1aeSmrg      -d) isdir=: ;;
41386aec45a7Smrg      -f)
41396aec45a7Smrg	if $install_cp; then :; else
41406aec45a7Smrg	  prev=$arg
4141ab47cfaaSmrg	fi
41426aec45a7Smrg	;;
41436aec45a7Smrg      -g | -m | -o)
41446aec45a7Smrg	prev=$arg
41456aec45a7Smrg	;;
41466aec45a7Smrg      -s)
41476aec45a7Smrg	stripme=" -s"
41485c42550eSmrg	continue
41495c42550eSmrg	;;
41506aec45a7Smrg      -*)
41516aec45a7Smrg	;;
41525c42550eSmrg      *)
41536aec45a7Smrg	# If the previous option needed an argument, then skip it.
41546aec45a7Smrg	if test -n "$prev"; then
4155300bf1aeSmrg	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
41566aec45a7Smrg	    arg2=$install_override_mode
41576aec45a7Smrg	    no_mode=false
41586aec45a7Smrg	  fi
41596aec45a7Smrg	  prev=
41606aec45a7Smrg	else
41616aec45a7Smrg	  dest=$arg
41626aec45a7Smrg	  continue
41636aec45a7Smrg	fi
41641473d951Smrg	;;
41656aec45a7Smrg      esac
4166ab47cfaaSmrg
41676aec45a7Smrg      # Aesthetically quote the argument.
41686aec45a7Smrg      func_quote_for_eval "$arg"
4169aa9e3350Smrg      func_append install_prog " $func_quote_for_eval_result"
41706aec45a7Smrg      if test -n "$arg2"; then
41716aec45a7Smrg	func_quote_for_eval "$arg2"
41725c42550eSmrg      fi
4173aa9e3350Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
41746aec45a7Smrg    done
41751473d951Smrg
41766aec45a7Smrg    test -z "$install_prog" && \
41776aec45a7Smrg      func_fatal_help "you must specify an install program"
41781473d951Smrg
41796aec45a7Smrg    test -n "$prev" && \
4180300bf1aeSmrg      func_fatal_help "the '$prev' option requires an argument"
41811473d951Smrg
41826aec45a7Smrg    if test -n "$install_override_mode" && $no_mode; then
41836aec45a7Smrg      if $install_cp; then :; else
41846aec45a7Smrg	func_quote_for_eval "$install_override_mode"
4185aa9e3350Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
41866aec45a7Smrg      fi
41875c42550eSmrg    fi
41881473d951Smrg
41896aec45a7Smrg    if test -z "$files"; then
41906aec45a7Smrg      if test -z "$dest"; then
41916aec45a7Smrg	func_fatal_help "no file or destination specified"
41926aec45a7Smrg      else
41936aec45a7Smrg	func_fatal_help "you must specify a destination"
41941473d951Smrg      fi
41951473d951Smrg    fi
41961473d951Smrg
41976aec45a7Smrg    # Strip any trailing slash from the destination.
41986aec45a7Smrg    func_stripname '' '/' "$dest"
41996aec45a7Smrg    dest=$func_stripname_result
4200ab47cfaaSmrg
42016aec45a7Smrg    # Check to see that the destination is a directory.
4202300bf1aeSmrg    test -d "$dest" && isdir=:
4203300bf1aeSmrg    if $isdir; then
4204300bf1aeSmrg      destdir=$dest
42056aec45a7Smrg      destname=
42066aec45a7Smrg    else
42076aec45a7Smrg      func_dirname_and_basename "$dest" "" "."
4208300bf1aeSmrg      destdir=$func_dirname_result
4209300bf1aeSmrg      destname=$func_basename_result
42106aec45a7Smrg
42116aec45a7Smrg      # Not a directory, so check to see that there is only one file specified.
42126aec45a7Smrg      set dummy $files; shift
42136aec45a7Smrg      test "$#" -gt 1 && \
4214300bf1aeSmrg	func_fatal_help "'$dest' is not a directory"
42156aec45a7Smrg    fi
42166aec45a7Smrg    case $destdir in
42176aec45a7Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
42185c42550eSmrg    *)
42196aec45a7Smrg      for file in $files; do
42206aec45a7Smrg	case $file in
42216aec45a7Smrg	*.lo) ;;
42226aec45a7Smrg	*)
4223300bf1aeSmrg	  func_fatal_help "'$destdir' must be an absolute directory name"
42246aec45a7Smrg	  ;;
42256aec45a7Smrg	esac
42266aec45a7Smrg      done
42275c42550eSmrg      ;;
42285c42550eSmrg    esac
4229ab47cfaaSmrg
42306aec45a7Smrg    # This variable tells wrapper scripts just to set variables rather
42316aec45a7Smrg    # than running their programs.
4232300bf1aeSmrg    libtool_install_magic=$magic
4233ab47cfaaSmrg
42346aec45a7Smrg    staticlibs=
42356aec45a7Smrg    future_libdirs=
42366aec45a7Smrg    current_libdirs=
42376aec45a7Smrg    for file in $files; do
4238ab47cfaaSmrg
42396aec45a7Smrg      # Do each installation.
42406aec45a7Smrg      case $file in
42416aec45a7Smrg      *.$libext)
42426aec45a7Smrg	# Do the static libraries later.
4243aa9e3350Smrg	func_append staticlibs " $file"
42446aec45a7Smrg	;;
42456aec45a7Smrg
42466aec45a7Smrg      *.la)
4247aa9e3350Smrg	func_resolve_sysroot "$file"
4248aa9e3350Smrg	file=$func_resolve_sysroot_result
4249aa9e3350Smrg
42506aec45a7Smrg	# Check to see that this really is a libtool archive.
42516aec45a7Smrg	func_lalib_unsafe_p "$file" \
4252300bf1aeSmrg	  || func_fatal_help "'$file' is not a valid libtool archive"
42536aec45a7Smrg
42546aec45a7Smrg	library_names=
42556aec45a7Smrg	old_library=
42566aec45a7Smrg	relink_command=
42576aec45a7Smrg	func_source "$file"
42586aec45a7Smrg
42596aec45a7Smrg	# Add the libdir to current_libdirs if it is the destination.
42606aec45a7Smrg	if test "X$destdir" = "X$libdir"; then
42616aec45a7Smrg	  case "$current_libdirs " in
42626aec45a7Smrg	  *" $libdir "*) ;;
4263aa9e3350Smrg	  *) func_append current_libdirs " $libdir" ;;
42641473d951Smrg	  esac
42656aec45a7Smrg	else
42666aec45a7Smrg	  # Note the libdir as a future libdir.
42676aec45a7Smrg	  case "$future_libdirs " in
42686aec45a7Smrg	  *" $libdir "*) ;;
4269aa9e3350Smrg	  *) func_append future_libdirs " $libdir" ;;
42706aec45a7Smrg	  esac
42716aec45a7Smrg	fi
4272ab47cfaaSmrg
42736aec45a7Smrg	func_dirname "$file" "/" ""
4274300bf1aeSmrg	dir=$func_dirname_result
4275aa9e3350Smrg	func_append dir "$objdir"
42766aec45a7Smrg
42776aec45a7Smrg	if test -n "$relink_command"; then
42786aec45a7Smrg	  # Determine the prefix the user has applied to our future dir.
42796aec45a7Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
42806aec45a7Smrg
42816aec45a7Smrg	  # Don't allow the user to place us outside of our expected
42826aec45a7Smrg	  # location b/c this prevents finding dependent libraries that
42836aec45a7Smrg	  # are installed to the same prefix.
42846aec45a7Smrg	  # At present, this check doesn't affect windows .dll's that
42856aec45a7Smrg	  # are installed into $libdir/../bin (currently, that works fine)
42866aec45a7Smrg	  # but it's something to keep an eye on.
42876aec45a7Smrg	  test "$inst_prefix_dir" = "$destdir" && \
4288300bf1aeSmrg	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
42896aec45a7Smrg
42906aec45a7Smrg	  if test -n "$inst_prefix_dir"; then
42916aec45a7Smrg	    # Stick the inst_prefix_dir data into the link command.
42926aec45a7Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
42936aec45a7Smrg	  else
42946aec45a7Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
42956aec45a7Smrg	  fi
42966aec45a7Smrg
4297300bf1aeSmrg	  func_warning "relinking '$file'"
42986aec45a7Smrg	  func_show_eval "$relink_command" \
4299300bf1aeSmrg	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
43006aec45a7Smrg	fi
43016aec45a7Smrg
43026aec45a7Smrg	# See the names of the shared library.
43036aec45a7Smrg	set dummy $library_names; shift
43046aec45a7Smrg	if test -n "$1"; then
4305300bf1aeSmrg	  realname=$1
43066aec45a7Smrg	  shift
43076aec45a7Smrg
4308300bf1aeSmrg	  srcname=$realname
4309300bf1aeSmrg	  test -n "$relink_command" && srcname=${realname}T
43106aec45a7Smrg
43116aec45a7Smrg	  # Install the shared library and build the symlinks.
43126aec45a7Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
43136aec45a7Smrg	      'exit $?'
4314300bf1aeSmrg	  tstripme=$stripme
43156aec45a7Smrg	  case $host_os in
43166aec45a7Smrg	  cygwin* | mingw* | pw32* | cegcc*)
43176aec45a7Smrg	    case $realname in
43186aec45a7Smrg	    *.dll.a)
4319300bf1aeSmrg	      tstripme=
4320300bf1aeSmrg	      ;;
4321300bf1aeSmrg	    esac
4322300bf1aeSmrg	    ;;
4323300bf1aeSmrg	  os2*)
4324300bf1aeSmrg	    case $realname in
4325300bf1aeSmrg	    *_dll.a)
4326300bf1aeSmrg	      tstripme=
43276aec45a7Smrg	      ;;
43286aec45a7Smrg	    esac
43291473d951Smrg	    ;;
43301473d951Smrg	  esac
43316aec45a7Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
43326aec45a7Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
43336aec45a7Smrg	  fi
43346aec45a7Smrg
43356aec45a7Smrg	  if test "$#" -gt 0; then
43366aec45a7Smrg	    # Delete the old symlinks, and create new ones.
4337300bf1aeSmrg	    # Try 'ln -sf' first, because the 'ln' binary might depend on
43386aec45a7Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
43396aec45a7Smrg	    # so we also need to try rm && ln -s.
43406aec45a7Smrg	    for linkname
43416aec45a7Smrg	    do
43426aec45a7Smrg	      test "$linkname" != "$realname" \
43436aec45a7Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
43446aec45a7Smrg	    done
43456aec45a7Smrg	  fi
43466aec45a7Smrg
43476aec45a7Smrg	  # Do each command in the postinstall commands.
4348300bf1aeSmrg	  lib=$destdir/$realname
43496aec45a7Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
43506aec45a7Smrg	fi
43516aec45a7Smrg
43526aec45a7Smrg	# Install the pseudo-library for information purposes.
43536aec45a7Smrg	func_basename "$file"
4354300bf1aeSmrg	name=$func_basename_result
4355300bf1aeSmrg	instname=$dir/${name}i
43566aec45a7Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
43576aec45a7Smrg
43586aec45a7Smrg	# Maybe install the static library, too.
4359aa9e3350Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
43601473d951Smrg	;;
43616aec45a7Smrg
43626aec45a7Smrg      *.lo)
43636aec45a7Smrg	# Install (i.e. copy) a libtool object.
43646aec45a7Smrg
43656aec45a7Smrg	# Figure out destination file name, if it wasn't already specified.
43666aec45a7Smrg	if test -n "$destname"; then
4367300bf1aeSmrg	  destfile=$destdir/$destname
43686aec45a7Smrg	else
43696aec45a7Smrg	  func_basename "$file"
4370300bf1aeSmrg	  destfile=$func_basename_result
4371300bf1aeSmrg	  destfile=$destdir/$destfile
43726aec45a7Smrg	fi
43736aec45a7Smrg
43746aec45a7Smrg	# Deduce the name of the destination old-style object file.
43756aec45a7Smrg	case $destfile in
43766aec45a7Smrg	*.lo)
43776aec45a7Smrg	  func_lo2o "$destfile"
43786aec45a7Smrg	  staticdest=$func_lo2o_result
43795c42550eSmrg	  ;;
43806aec45a7Smrg	*.$objext)
4381300bf1aeSmrg	  staticdest=$destfile
43826aec45a7Smrg	  destfile=
43835c42550eSmrg	  ;;
43846aec45a7Smrg	*)
4385300bf1aeSmrg	  func_fatal_help "cannot copy a libtool object to '$destfile'"
43865c42550eSmrg	  ;;
43876aec45a7Smrg	esac
43886aec45a7Smrg
43896aec45a7Smrg	# Install the libtool object if requested.
43906aec45a7Smrg	test -n "$destfile" && \
43916aec45a7Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
43926aec45a7Smrg
43936aec45a7Smrg	# Install the old object if enabled.
4394300bf1aeSmrg	if test yes = "$build_old_libs"; then
43956aec45a7Smrg	  # Deduce the name of the old-style object file.
43966aec45a7Smrg	  func_lo2o "$file"
43976aec45a7Smrg	  staticobj=$func_lo2o_result
43986aec45a7Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
43995c42550eSmrg	fi
44006aec45a7Smrg	exit $EXIT_SUCCESS
44016aec45a7Smrg	;;
4402ab47cfaaSmrg
44036aec45a7Smrg      *)
44046aec45a7Smrg	# Figure out destination file name, if it wasn't already specified.
44056aec45a7Smrg	if test -n "$destname"; then
4406300bf1aeSmrg	  destfile=$destdir/$destname
44075c42550eSmrg	else
44086aec45a7Smrg	  func_basename "$file"
4409300bf1aeSmrg	  destfile=$func_basename_result
4410300bf1aeSmrg	  destfile=$destdir/$destfile
44115c42550eSmrg	fi
4412ab47cfaaSmrg
44136aec45a7Smrg	# If the file is missing, and there is a .exe on the end, strip it
44146aec45a7Smrg	# because it is most likely a libtool script we actually want to
44156aec45a7Smrg	# install
4416300bf1aeSmrg	stripped_ext=
44176aec45a7Smrg	case $file in
44186aec45a7Smrg	  *.exe)
44196aec45a7Smrg	    if test ! -f "$file"; then
44206aec45a7Smrg	      func_stripname '' '.exe' "$file"
44216aec45a7Smrg	      file=$func_stripname_result
4422300bf1aeSmrg	      stripped_ext=.exe
44236aec45a7Smrg	    fi
44246aec45a7Smrg	    ;;
44256aec45a7Smrg	esac
4426ab47cfaaSmrg
44276aec45a7Smrg	# Do a test to see if this is really a libtool program.
44286aec45a7Smrg	case $host in
44296aec45a7Smrg	*cygwin* | *mingw*)
44306aec45a7Smrg	    if func_ltwrapper_executable_p "$file"; then
44316aec45a7Smrg	      func_ltwrapper_scriptname "$file"
44326aec45a7Smrg	      wrapper=$func_ltwrapper_scriptname_result
44336aec45a7Smrg	    else
44346aec45a7Smrg	      func_stripname '' '.exe' "$file"
44356aec45a7Smrg	      wrapper=$func_stripname_result
44366aec45a7Smrg	    fi
44376aec45a7Smrg	    ;;
44386aec45a7Smrg	*)
44396aec45a7Smrg	    wrapper=$file
44406aec45a7Smrg	    ;;
44416aec45a7Smrg	esac
44426aec45a7Smrg	if func_ltwrapper_script_p "$wrapper"; then
44436aec45a7Smrg	  notinst_deplibs=
44446aec45a7Smrg	  relink_command=
4445ab47cfaaSmrg
44466aec45a7Smrg	  func_source "$wrapper"
4447ab47cfaaSmrg
44486aec45a7Smrg	  # Check the variables that should have been set.
44496aec45a7Smrg	  test -z "$generated_by_libtool_version" && \
4450300bf1aeSmrg	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
4451ab47cfaaSmrg
4452300bf1aeSmrg	  finalize=:
44536aec45a7Smrg	  for lib in $notinst_deplibs; do
44546aec45a7Smrg	    # Check to see that each library is installed.
44556aec45a7Smrg	    libdir=
44566aec45a7Smrg	    if test -f "$lib"; then
44576aec45a7Smrg	      func_source "$lib"
44585c42550eSmrg	    fi
4459300bf1aeSmrg	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
44606aec45a7Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
4461300bf1aeSmrg	      func_warning "'$lib' has not been installed in '$libdir'"
4462300bf1aeSmrg	      finalize=false
44636aec45a7Smrg	    fi
44646aec45a7Smrg	  done
4465ab47cfaaSmrg
44666aec45a7Smrg	  relink_command=
44676aec45a7Smrg	  func_source "$wrapper"
4468ab47cfaaSmrg
44696aec45a7Smrg	  outputname=
4470300bf1aeSmrg	  if test no = "$fast_install" && test -n "$relink_command"; then
44716aec45a7Smrg	    $opt_dry_run || {
4472300bf1aeSmrg	      if $finalize; then
44736aec45a7Smrg	        tmpdir=`func_mktempdir`
44746aec45a7Smrg		func_basename "$file$stripped_ext"
4475300bf1aeSmrg		file=$func_basename_result
4476300bf1aeSmrg	        outputname=$tmpdir/$file
44776aec45a7Smrg	        # Replace the output file specification.
44786aec45a7Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
44796aec45a7Smrg
4480300bf1aeSmrg	        $opt_quiet || {
44816aec45a7Smrg	          func_quote_for_expand "$relink_command"
44826aec45a7Smrg		  eval "func_echo $func_quote_for_expand_result"
44836aec45a7Smrg	        }
44846aec45a7Smrg	        if eval "$relink_command"; then :
44856aec45a7Smrg	          else
4486300bf1aeSmrg		  func_error "error: relink '$file' with the above command before installing it"
44876aec45a7Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
44886aec45a7Smrg		  continue
44896aec45a7Smrg	        fi
4490300bf1aeSmrg	        file=$outputname
44916aec45a7Smrg	      else
4492300bf1aeSmrg	        func_warning "cannot relink '$file'"
44936aec45a7Smrg	      fi
44946aec45a7Smrg	    }
44955c42550eSmrg	  else
44966aec45a7Smrg	    # Install the binary that we compiled earlier.
44976aec45a7Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
44985c42550eSmrg	  fi
44996aec45a7Smrg	fi
4500ab47cfaaSmrg
45016aec45a7Smrg	# remove .exe since cygwin /usr/bin/install will append another
45026aec45a7Smrg	# one anyway
45036aec45a7Smrg	case $install_prog,$host in
45046aec45a7Smrg	*/usr/bin/install*,*cygwin*)
45056aec45a7Smrg	  case $file:$destfile in
45066aec45a7Smrg	  *.exe:*.exe)
45076aec45a7Smrg	    # this is ok
45086aec45a7Smrg	    ;;
45096aec45a7Smrg	  *.exe:*)
45106aec45a7Smrg	    destfile=$destfile.exe
45116aec45a7Smrg	    ;;
45126aec45a7Smrg	  *:*.exe)
45136aec45a7Smrg	    func_stripname '' '.exe' "$destfile"
45146aec45a7Smrg	    destfile=$func_stripname_result
45156aec45a7Smrg	    ;;
45166aec45a7Smrg	  esac
45175c42550eSmrg	  ;;
45185c42550eSmrg	esac
45196aec45a7Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
45206aec45a7Smrg	$opt_dry_run || if test -n "$outputname"; then
45216aec45a7Smrg	  ${RM}r "$tmpdir"
45226aec45a7Smrg	fi
45236aec45a7Smrg	;;
45246aec45a7Smrg      esac
45256aec45a7Smrg    done
4526ab47cfaaSmrg
45276aec45a7Smrg    for file in $staticlibs; do
45286aec45a7Smrg      func_basename "$file"
4529300bf1aeSmrg      name=$func_basename_result
45306aec45a7Smrg
45316aec45a7Smrg      # Set up the ranlib parameters.
4532300bf1aeSmrg      oldlib=$destdir/$name
4533aa9e3350Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4534aa9e3350Smrg      tool_oldlib=$func_to_tool_file_result
45356aec45a7Smrg
45366aec45a7Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
45376aec45a7Smrg
45386aec45a7Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
4539aa9e3350Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
45406aec45a7Smrg      fi
45416aec45a7Smrg
45426aec45a7Smrg      # Do each command in the postinstall commands.
45436aec45a7Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
45446aec45a7Smrg    done
45456aec45a7Smrg
45466aec45a7Smrg    test -n "$future_libdirs" && \
4547300bf1aeSmrg      func_warning "remember to run '$progname --finish$future_libdirs'"
45486aec45a7Smrg
45496aec45a7Smrg    if test -n "$current_libdirs"; then
45506aec45a7Smrg      # Maybe just do a dry run.
45516aec45a7Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
4552300bf1aeSmrg      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
45536aec45a7Smrg    else
45546aec45a7Smrg      exit $EXIT_SUCCESS
45556aec45a7Smrg    fi
45566aec45a7Smrg}
45576aec45a7Smrg
4558300bf1aeSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"}
45596aec45a7Smrg
45606aec45a7Smrg
45616aec45a7Smrg# func_generate_dlsyms outputname originator pic_p
45626aec45a7Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
45636aec45a7Smrg# a dlpreopen symbol table.
45646aec45a7Smrgfunc_generate_dlsyms ()
45656aec45a7Smrg{
4566300bf1aeSmrg    $debug_cmd
4567300bf1aeSmrg
4568300bf1aeSmrg    my_outputname=$1
4569300bf1aeSmrg    my_originator=$2
4570300bf1aeSmrg    my_pic_p=${3-false}
4571300bf1aeSmrg    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
45726aec45a7Smrg    my_dlsyms=
45736aec45a7Smrg
4574300bf1aeSmrg    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
45756aec45a7Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
4576300bf1aeSmrg	my_dlsyms=${my_outputname}S.c
45776aec45a7Smrg      else
45786aec45a7Smrg	func_error "not configured to extract global symbols from dlpreopened files"
45796aec45a7Smrg      fi
45806aec45a7Smrg    fi
45816aec45a7Smrg
45826aec45a7Smrg    if test -n "$my_dlsyms"; then
45836aec45a7Smrg      case $my_dlsyms in
45846aec45a7Smrg      "") ;;
45856aec45a7Smrg      *.c)
45866aec45a7Smrg	# Discover the nlist of each of the dlfiles.
4587300bf1aeSmrg	nlist=$output_objdir/$my_outputname.nm
45886aec45a7Smrg
45896aec45a7Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
45906aec45a7Smrg
45916aec45a7Smrg	# Parse the name list into a source file.
45926aec45a7Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
45936aec45a7Smrg
45946aec45a7Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
4595300bf1aeSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
4596300bf1aeSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
45976aec45a7Smrg
45986aec45a7Smrg#ifdef __cplusplus
45996aec45a7Smrgextern \"C\" {
46006aec45a7Smrg#endif
46016aec45a7Smrg
4602300bf1aeSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
46036aec45a7Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
46046aec45a7Smrg#endif
46056aec45a7Smrg
4606aa9e3350Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
4607300bf1aeSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
4608300bf1aeSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime
4609aa9e3350Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
4610aa9e3350Smrg# define LT_DLSYM_CONST
4611300bf1aeSmrg#elif defined __osf__
4612aa9e3350Smrg/* This system does not cope well with relocations in const data.  */
4613aa9e3350Smrg# define LT_DLSYM_CONST
4614aa9e3350Smrg#else
4615aa9e3350Smrg# define LT_DLSYM_CONST const
4616aa9e3350Smrg#endif
4617aa9e3350Smrg
4618300bf1aeSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
4619300bf1aeSmrg
46206aec45a7Smrg/* External symbol declarations for the compiler. */\
46216aec45a7Smrg"
46226aec45a7Smrg
4623300bf1aeSmrg	if test yes = "$dlself"; then
4624300bf1aeSmrg	  func_verbose "generating symbol list for '$output'"
46256aec45a7Smrg
46266aec45a7Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
46276aec45a7Smrg
46286aec45a7Smrg	  # Add our own program objects to the symbol list.
46296aec45a7Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
46306aec45a7Smrg	  for progfile in $progfiles; do
4631aa9e3350Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
4632300bf1aeSmrg	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4633aa9e3350Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
46346aec45a7Smrg	  done
46356aec45a7Smrg
46366aec45a7Smrg	  if test -n "$exclude_expsyms"; then
46376aec45a7Smrg	    $opt_dry_run || {
46386aec45a7Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
46396aec45a7Smrg	      eval '$MV "$nlist"T "$nlist"'
46406aec45a7Smrg	    }
46415c42550eSmrg	  fi
46426aec45a7Smrg
46436aec45a7Smrg	  if test -n "$export_symbols_regex"; then
46446aec45a7Smrg	    $opt_dry_run || {
46456aec45a7Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
46466aec45a7Smrg	      eval '$MV "$nlist"T "$nlist"'
46476aec45a7Smrg	    }
46486aec45a7Smrg	  fi
46496aec45a7Smrg
46506aec45a7Smrg	  # Prepare the list of exported symbols
46516aec45a7Smrg	  if test -z "$export_symbols"; then
4652300bf1aeSmrg	    export_symbols=$output_objdir/$outputname.exp
46536aec45a7Smrg	    $opt_dry_run || {
46546aec45a7Smrg	      $RM $export_symbols
4655300bf1aeSmrg	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
46566aec45a7Smrg	      case $host in
46576aec45a7Smrg	      *cygwin* | *mingw* | *cegcc* )
46586aec45a7Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
46596aec45a7Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
46606aec45a7Smrg	        ;;
46616aec45a7Smrg	      esac
46626aec45a7Smrg	    }
46635c42550eSmrg	  else
46646aec45a7Smrg	    $opt_dry_run || {
4665300bf1aeSmrg	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
46666aec45a7Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
46676aec45a7Smrg	      eval '$MV "$nlist"T "$nlist"'
46686aec45a7Smrg	      case $host in
46696aec45a7Smrg	        *cygwin* | *mingw* | *cegcc* )
46706aec45a7Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
46716aec45a7Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
46726aec45a7Smrg	          ;;
46736aec45a7Smrg	      esac
46746aec45a7Smrg	    }
46755c42550eSmrg	  fi
46766aec45a7Smrg	fi
4677ab47cfaaSmrg
46786aec45a7Smrg	for dlprefile in $dlprefiles; do
4679300bf1aeSmrg	  func_verbose "extracting global C symbols from '$dlprefile'"
46806aec45a7Smrg	  func_basename "$dlprefile"
4681300bf1aeSmrg	  name=$func_basename_result
4682aa9e3350Smrg          case $host in
4683aa9e3350Smrg	    *cygwin* | *mingw* | *cegcc* )
4684aa9e3350Smrg	      # if an import library, we need to obtain dlname
4685aa9e3350Smrg	      if func_win32_import_lib_p "$dlprefile"; then
4686aa9e3350Smrg	        func_tr_sh "$dlprefile"
4687aa9e3350Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
4688300bf1aeSmrg	        dlprefile_dlbasename=
4689aa9e3350Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4690aa9e3350Smrg	          # Use subshell, to avoid clobbering current variable values
4691aa9e3350Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
4692300bf1aeSmrg	          if test -n "$dlprefile_dlname"; then
4693aa9e3350Smrg	            func_basename "$dlprefile_dlname"
4694300bf1aeSmrg	            dlprefile_dlbasename=$func_basename_result
4695aa9e3350Smrg	          else
4696aa9e3350Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
4697aa9e3350Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
4698aa9e3350Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
4699aa9e3350Smrg	          fi
4700aa9e3350Smrg	        fi
4701aa9e3350Smrg	        $opt_dry_run || {
4702300bf1aeSmrg	          if test -n "$dlprefile_dlbasename"; then
4703aa9e3350Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4704aa9e3350Smrg	          else
4705aa9e3350Smrg	            func_warning "Could not compute DLL name from $name"
4706aa9e3350Smrg	            eval '$ECHO ": $name " >> "$nlist"'
4707aa9e3350Smrg	          fi
4708aa9e3350Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4709aa9e3350Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4710aa9e3350Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4711aa9e3350Smrg	        }
4712aa9e3350Smrg	      else # not an import lib
4713aa9e3350Smrg	        $opt_dry_run || {
4714aa9e3350Smrg	          eval '$ECHO ": $name " >> "$nlist"'
4715aa9e3350Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4716aa9e3350Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4717aa9e3350Smrg	        }
4718aa9e3350Smrg	      fi
4719aa9e3350Smrg	    ;;
4720aa9e3350Smrg	    *)
4721aa9e3350Smrg	      $opt_dry_run || {
4722aa9e3350Smrg	        eval '$ECHO ": $name " >> "$nlist"'
4723aa9e3350Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4724aa9e3350Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4725aa9e3350Smrg	      }
4726aa9e3350Smrg	    ;;
4727aa9e3350Smrg          esac
47286aec45a7Smrg	done
47296aec45a7Smrg
47306aec45a7Smrg	$opt_dry_run || {
47316aec45a7Smrg	  # Make sure we have at least an empty file.
47326aec45a7Smrg	  test -f "$nlist" || : > "$nlist"
47336aec45a7Smrg
47346aec45a7Smrg	  if test -n "$exclude_expsyms"; then
47356aec45a7Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
47366aec45a7Smrg	    $MV "$nlist"T "$nlist"
47375c42550eSmrg	  fi
47386aec45a7Smrg
47396aec45a7Smrg	  # Try sorting and uniquifying the output.
47406aec45a7Smrg	  if $GREP -v "^: " < "$nlist" |
47416aec45a7Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
47426aec45a7Smrg		sort -k 3
47436aec45a7Smrg	      else
47446aec45a7Smrg		sort +2
47456aec45a7Smrg	      fi |
47466aec45a7Smrg	      uniq > "$nlist"S; then
47476aec45a7Smrg	    :
47485c42550eSmrg	  else
47496aec45a7Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
47505c42550eSmrg	  fi
4751ab47cfaaSmrg
47526aec45a7Smrg	  if test -f "$nlist"S; then
47536aec45a7Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
47545c42550eSmrg	  else
47556aec45a7Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
47565c42550eSmrg	  fi
4757ab47cfaaSmrg
4758300bf1aeSmrg	  func_show_eval '$RM "${nlist}I"'
4759300bf1aeSmrg	  if test -n "$global_symbol_to_import"; then
4760300bf1aeSmrg	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
4761300bf1aeSmrg	  fi
4762300bf1aeSmrg
47636aec45a7Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
4764ab47cfaaSmrg
47656aec45a7Smrg/* The mapping between symbol names and symbols.  */
47666aec45a7Smrgtypedef struct {
47676aec45a7Smrg  const char *name;
47686aec45a7Smrg  void *address;
47696aec45a7Smrg} lt_dlsymlist;
4770aa9e3350Smrgextern LT_DLSYM_CONST lt_dlsymlist
4771300bf1aeSmrglt_${my_prefix}_LTX_preloaded_symbols[];\
4772300bf1aeSmrg"
4773300bf1aeSmrg
4774300bf1aeSmrg	  if test -s "$nlist"I; then
4775300bf1aeSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
4776300bf1aeSmrgstatic void lt_syminit(void)
4777300bf1aeSmrg{
4778300bf1aeSmrg  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
4779300bf1aeSmrg  for (; symbol->name; ++symbol)
4780300bf1aeSmrg    {"
4781300bf1aeSmrg	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
4782300bf1aeSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
4783300bf1aeSmrg    }
4784300bf1aeSmrg}"
4785300bf1aeSmrg	  fi
4786300bf1aeSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
4787aa9e3350SmrgLT_DLSYM_CONST lt_dlsymlist
47886aec45a7Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
4789300bf1aeSmrg{ {\"$my_originator\", (void *) 0},"
4790300bf1aeSmrg
4791300bf1aeSmrg	  if test -s "$nlist"I; then
4792300bf1aeSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
4793300bf1aeSmrg  {\"@INIT@\", (void *) &lt_syminit},"
4794300bf1aeSmrg	  fi
4795ab47cfaaSmrg
47966aec45a7Smrg	  case $need_lib_prefix in
47976aec45a7Smrg	  no)
47986aec45a7Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
47996aec45a7Smrg	    ;;
48006aec45a7Smrg	  *)
48016aec45a7Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
48026aec45a7Smrg	    ;;
48036aec45a7Smrg	  esac
48046aec45a7Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
48056aec45a7Smrg  {0, (void *) 0}
48066aec45a7Smrg};
48071473d951Smrg
48086aec45a7Smrg/* This works around a problem in FreeBSD linker */
48096aec45a7Smrg#ifdef FREEBSD_WORKAROUND
48106aec45a7Smrgstatic const void *lt_preloaded_setup() {
48116aec45a7Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
48126aec45a7Smrg}
48136aec45a7Smrg#endif
4814ab47cfaaSmrg
48156aec45a7Smrg#ifdef __cplusplus
48166aec45a7Smrg}
48176aec45a7Smrg#endif\
48186aec45a7Smrg"
48196aec45a7Smrg	} # !$opt_dry_run
48201473d951Smrg
48216aec45a7Smrg	pic_flag_for_symtable=
48226aec45a7Smrg	case "$compile_command " in
48236aec45a7Smrg	*" -static "*) ;;
48246aec45a7Smrg	*)
48256aec45a7Smrg	  case $host in
48266aec45a7Smrg	  # compiling the symbol table file with pic_flag works around
48276aec45a7Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
48286aec45a7Smrg	  # linked before any other PIC object.  But we must not use
48296aec45a7Smrg	  # pic_flag when linking with -static.  The problem exists in
48306aec45a7Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4831aa9e3350Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
48326aec45a7Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
48336aec45a7Smrg	  *-*-hpux*)
48346aec45a7Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
48356aec45a7Smrg	  *)
4836300bf1aeSmrg	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
48376aec45a7Smrg	    ;;
48386aec45a7Smrg	  esac
48396aec45a7Smrg	  ;;
48406aec45a7Smrg	esac
48416aec45a7Smrg	symtab_cflags=
48426aec45a7Smrg	for arg in $LTCFLAGS; do
48436aec45a7Smrg	  case $arg in
48446aec45a7Smrg	  -pie | -fpie | -fPIE) ;;
4845aa9e3350Smrg	  *) func_append symtab_cflags " $arg" ;;
48466aec45a7Smrg	  esac
48476aec45a7Smrg	done
4848ab47cfaaSmrg
48496aec45a7Smrg	# Now compile the dynamic symbol file.
48506aec45a7Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
4851ab47cfaaSmrg
48526aec45a7Smrg	# Clean up the generated files.
4853300bf1aeSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
48541473d951Smrg
48556aec45a7Smrg	# Transform the symbol file into the correct name.
4856300bf1aeSmrg	symfileobj=$output_objdir/${my_outputname}S.$objext
48576aec45a7Smrg	case $host in
48586aec45a7Smrg	*cygwin* | *mingw* | *cegcc* )
48596aec45a7Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
48606aec45a7Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
48616aec45a7Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
48626aec45a7Smrg	  else
48636aec45a7Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
48646aec45a7Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
48656aec45a7Smrg	  fi
48666aec45a7Smrg	  ;;
48676aec45a7Smrg	*)
48686aec45a7Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
48696aec45a7Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
48706aec45a7Smrg	  ;;
48716aec45a7Smrg	esac
48726aec45a7Smrg	;;
48736aec45a7Smrg      *)
4874300bf1aeSmrg	func_fatal_error "unknown suffix for '$my_dlsyms'"
48756aec45a7Smrg	;;
48766aec45a7Smrg      esac
48776aec45a7Smrg    else
48786aec45a7Smrg      # We keep going just in case the user didn't refer to
48796aec45a7Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
48806aec45a7Smrg      # really was required.
48811473d951Smrg
48826aec45a7Smrg      # Nullify the symbol file.
48836aec45a7Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
48846aec45a7Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
48856aec45a7Smrg    fi
48866aec45a7Smrg}
48871473d951Smrg
4888300bf1aeSmrg# func_cygming_gnu_implib_p ARG
4889300bf1aeSmrg# This predicate returns with zero status (TRUE) if
4890300bf1aeSmrg# ARG is a GNU/binutils-style import library. Returns
4891300bf1aeSmrg# with nonzero status (FALSE) otherwise.
4892300bf1aeSmrgfunc_cygming_gnu_implib_p ()
4893300bf1aeSmrg{
4894300bf1aeSmrg  $debug_cmd
4895300bf1aeSmrg
4896300bf1aeSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
4897300bf1aeSmrg  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)$'`
4898300bf1aeSmrg  test -n "$func_cygming_gnu_implib_tmp"
4899300bf1aeSmrg}
4900300bf1aeSmrg
4901300bf1aeSmrg# func_cygming_ms_implib_p ARG
4902300bf1aeSmrg# This predicate returns with zero status (TRUE) if
4903300bf1aeSmrg# ARG is an MS-style import library. Returns
4904300bf1aeSmrg# with nonzero status (FALSE) otherwise.
4905300bf1aeSmrgfunc_cygming_ms_implib_p ()
4906300bf1aeSmrg{
4907300bf1aeSmrg  $debug_cmd
4908300bf1aeSmrg
4909300bf1aeSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
4910300bf1aeSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
4911300bf1aeSmrg  test -n "$func_cygming_ms_implib_tmp"
4912300bf1aeSmrg}
4913300bf1aeSmrg
49146aec45a7Smrg# func_win32_libid arg
49156aec45a7Smrg# return the library type of file 'arg'
49166aec45a7Smrg#
49176aec45a7Smrg# Need a lot of goo to handle *both* DLLs and import libs
49186aec45a7Smrg# Has to be a shell function in order to 'eat' the argument
49196aec45a7Smrg# that is supplied when $file_magic_command is called.
49206aec45a7Smrg# Despite the name, also deal with 64 bit binaries.
49216aec45a7Smrgfunc_win32_libid ()
49226aec45a7Smrg{
4923300bf1aeSmrg  $debug_cmd
4924300bf1aeSmrg
4925300bf1aeSmrg  win32_libid_type=unknown
49266aec45a7Smrg  win32_fileres=`file -L $1 2>/dev/null`
49276aec45a7Smrg  case $win32_fileres in
49286aec45a7Smrg  *ar\ archive\ import\ library*) # definitely import
49296aec45a7Smrg    win32_libid_type="x86 archive import"
49306aec45a7Smrg    ;;
49316aec45a7Smrg  *ar\ archive*) # could be an import, or static
49326aec45a7Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
49336aec45a7Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
49346aec45a7Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
4935300bf1aeSmrg      case $nm_interface in
4936300bf1aeSmrg      "MS dumpbin")
4937300bf1aeSmrg	if func_cygming_ms_implib_p "$1" ||
4938300bf1aeSmrg	   func_cygming_gnu_implib_p "$1"
4939300bf1aeSmrg	then
4940300bf1aeSmrg	  win32_nmres=import
4941300bf1aeSmrg	else
4942300bf1aeSmrg	  win32_nmres=
4943300bf1aeSmrg	fi
4944300bf1aeSmrg	;;
4945300bf1aeSmrg      *)
4946300bf1aeSmrg	func_to_tool_file "$1" func_convert_file_msys_to_w32
4947300bf1aeSmrg	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
4948300bf1aeSmrg	  $SED -n -e '
49496aec45a7Smrg	    1,100{
49506aec45a7Smrg		/ I /{
4951300bf1aeSmrg		    s|.*|import|
49526aec45a7Smrg		    p
49536aec45a7Smrg		    q
49546aec45a7Smrg		}
49556aec45a7Smrg	    }'`
4956300bf1aeSmrg	;;
4957300bf1aeSmrg      esac
49586aec45a7Smrg      case $win32_nmres in
49596aec45a7Smrg      import*)  win32_libid_type="x86 archive import";;
49606aec45a7Smrg      *)        win32_libid_type="x86 archive static";;
49616aec45a7Smrg      esac
49626aec45a7Smrg    fi
49636aec45a7Smrg    ;;
49646aec45a7Smrg  *DLL*)
49656aec45a7Smrg    win32_libid_type="x86 DLL"
49666aec45a7Smrg    ;;
49676aec45a7Smrg  *executable*) # but shell scripts are "executable" too...
49686aec45a7Smrg    case $win32_fileres in
49696aec45a7Smrg    *MS\ Windows\ PE\ Intel*)
49706aec45a7Smrg      win32_libid_type="x86 DLL"
49716aec45a7Smrg      ;;
49726aec45a7Smrg    esac
49736aec45a7Smrg    ;;
49746aec45a7Smrg  esac
49756aec45a7Smrg  $ECHO "$win32_libid_type"
49766aec45a7Smrg}
49771473d951Smrg
4978aa9e3350Smrg# func_cygming_dll_for_implib ARG
4979aa9e3350Smrg#
4980aa9e3350Smrg# Platform-specific function to extract the
4981aa9e3350Smrg# name of the DLL associated with the specified
4982aa9e3350Smrg# import library ARG.
4983aa9e3350Smrg# Invoked by eval'ing the libtool variable
4984aa9e3350Smrg#    $sharedlib_from_linklib_cmd
4985aa9e3350Smrg# Result is available in the variable
4986aa9e3350Smrg#    $sharedlib_from_linklib_result
4987aa9e3350Smrgfunc_cygming_dll_for_implib ()
4988aa9e3350Smrg{
4989300bf1aeSmrg  $debug_cmd
4990300bf1aeSmrg
4991aa9e3350Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
4992aa9e3350Smrg}
4993aa9e3350Smrg
4994aa9e3350Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
4995aa9e3350Smrg#
4996aa9e3350Smrg# The is the core of a fallback implementation of a
4997aa9e3350Smrg# platform-specific function to extract the name of the
4998aa9e3350Smrg# DLL associated with the specified import library LIBNAME.
4999aa9e3350Smrg#
5000aa9e3350Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
5001aa9e3350Smrg# on the platform and compiler that created the implib.
5002aa9e3350Smrg#
5003aa9e3350Smrg# Echos the name of the DLL associated with the
5004aa9e3350Smrg# specified import library.
5005aa9e3350Smrgfunc_cygming_dll_for_implib_fallback_core ()
5006aa9e3350Smrg{
5007300bf1aeSmrg  $debug_cmd
5008300bf1aeSmrg
5009aa9e3350Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
5010aa9e3350Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
5011aa9e3350Smrg    $SED '/^Contents of section '"$match_literal"':/{
5012aa9e3350Smrg      # Place marker at beginning of archive member dllname section
5013aa9e3350Smrg      s/.*/====MARK====/
5014aa9e3350Smrg      p
5015aa9e3350Smrg      d
5016aa9e3350Smrg    }
5017aa9e3350Smrg    # These lines can sometimes be longer than 43 characters, but
5018aa9e3350Smrg    # are always uninteresting
5019aa9e3350Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
5020aa9e3350Smrg    /^In archive [^:]*:/d
5021aa9e3350Smrg    # Ensure marker is printed
5022aa9e3350Smrg    /^====MARK====/p
5023aa9e3350Smrg    # Remove all lines with less than 43 characters
5024aa9e3350Smrg    /^.\{43\}/!d
5025aa9e3350Smrg    # From remaining lines, remove first 43 characters
5026aa9e3350Smrg    s/^.\{43\}//' |
5027aa9e3350Smrg    $SED -n '
5028aa9e3350Smrg      # Join marker and all lines until next marker into a single line
5029aa9e3350Smrg      /^====MARK====/ b para
5030aa9e3350Smrg      H
5031aa9e3350Smrg      $ b para
5032aa9e3350Smrg      b
5033aa9e3350Smrg      :para
5034aa9e3350Smrg      x
5035aa9e3350Smrg      s/\n//g
5036aa9e3350Smrg      # Remove the marker
5037aa9e3350Smrg      s/^====MARK====//
5038aa9e3350Smrg      # Remove trailing dots and whitespace
5039aa9e3350Smrg      s/[\. \t]*$//
5040aa9e3350Smrg      # Print
5041aa9e3350Smrg      /./p' |
5042aa9e3350Smrg    # we now have a list, one entry per line, of the stringified
5043aa9e3350Smrg    # contents of the appropriate section of all members of the
5044300bf1aeSmrg    # archive that possess that section. Heuristic: eliminate
5045300bf1aeSmrg    # all those that have a first or second character that is
5046aa9e3350Smrg    # a '.' (that is, objdump's representation of an unprintable
5047aa9e3350Smrg    # character.) This should work for all archives with less than
5048aa9e3350Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
5049aa9e3350Smrg    # begins with a literal '.' or a single character followed by
5050aa9e3350Smrg    # a '.'.
5051aa9e3350Smrg    #
5052aa9e3350Smrg    # Of those that remain, print the first one.
5053aa9e3350Smrg    $SED -e '/^\./d;/^.\./d;q'
5054aa9e3350Smrg}
5055aa9e3350Smrg
5056aa9e3350Smrg# func_cygming_dll_for_implib_fallback ARG
5057aa9e3350Smrg# Platform-specific function to extract the
5058aa9e3350Smrg# name of the DLL associated with the specified
5059aa9e3350Smrg# import library ARG.
5060aa9e3350Smrg#
5061aa9e3350Smrg# This fallback implementation is for use when $DLLTOOL
5062aa9e3350Smrg# does not support the --identify-strict option.
5063aa9e3350Smrg# Invoked by eval'ing the libtool variable
5064aa9e3350Smrg#    $sharedlib_from_linklib_cmd
5065aa9e3350Smrg# Result is available in the variable
5066aa9e3350Smrg#    $sharedlib_from_linklib_result
5067aa9e3350Smrgfunc_cygming_dll_for_implib_fallback ()
5068aa9e3350Smrg{
5069300bf1aeSmrg  $debug_cmd
5070300bf1aeSmrg
5071300bf1aeSmrg  if func_cygming_gnu_implib_p "$1"; then
5072aa9e3350Smrg    # binutils import library
5073aa9e3350Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
5074300bf1aeSmrg  elif func_cygming_ms_implib_p "$1"; then
5075aa9e3350Smrg    # ms-generated import library
5076aa9e3350Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
5077aa9e3350Smrg  else
5078aa9e3350Smrg    # unknown
5079300bf1aeSmrg    sharedlib_from_linklib_result=
5080aa9e3350Smrg  fi
5081aa9e3350Smrg}
5082ab47cfaaSmrg
5083ab47cfaaSmrg
50846aec45a7Smrg# func_extract_an_archive dir oldlib
50856aec45a7Smrgfunc_extract_an_archive ()
50866aec45a7Smrg{
5087300bf1aeSmrg    $debug_cmd
5088300bf1aeSmrg
5089300bf1aeSmrg    f_ex_an_ar_dir=$1; shift
5090300bf1aeSmrg    f_ex_an_ar_oldlib=$1
5091300bf1aeSmrg    if test yes = "$lock_old_archive_extraction"; then
50926aec45a7Smrg      lockfile=$f_ex_an_ar_oldlib.lock
50936aec45a7Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
50946aec45a7Smrg	func_echo "Waiting for $lockfile to be removed"
50956aec45a7Smrg	sleep 2
50966aec45a7Smrg      done
50976aec45a7Smrg    fi
50986aec45a7Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
50996aec45a7Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
5100300bf1aeSmrg    if test yes = "$lock_old_archive_extraction"; then
51016aec45a7Smrg      $opt_dry_run || rm -f "$lockfile"
51026aec45a7Smrg    fi
51036aec45a7Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
51046aec45a7Smrg     :
51056aec45a7Smrg    else
51066aec45a7Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
51076aec45a7Smrg    fi
51086aec45a7Smrg}
51091473d951Smrg
51101473d951Smrg
51116aec45a7Smrg# func_extract_archives gentop oldlib ...
51126aec45a7Smrgfunc_extract_archives ()
51136aec45a7Smrg{
5114300bf1aeSmrg    $debug_cmd
5115300bf1aeSmrg
5116300bf1aeSmrg    my_gentop=$1; shift
51176aec45a7Smrg    my_oldlibs=${1+"$@"}
5118300bf1aeSmrg    my_oldobjs=
5119300bf1aeSmrg    my_xlib=
5120300bf1aeSmrg    my_xabs=
5121300bf1aeSmrg    my_xdir=
51221473d951Smrg
51236aec45a7Smrg    for my_xlib in $my_oldlibs; do
51246aec45a7Smrg      # Extract the objects.
51256aec45a7Smrg      case $my_xlib in
5126300bf1aeSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
51276aec45a7Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
51286aec45a7Smrg      esac
51296aec45a7Smrg      func_basename "$my_xlib"
5130300bf1aeSmrg      my_xlib=$func_basename_result
51316aec45a7Smrg      my_xlib_u=$my_xlib
51326aec45a7Smrg      while :; do
51336aec45a7Smrg        case " $extracted_archives " in
51346aec45a7Smrg	*" $my_xlib_u "*)
51356aec45a7Smrg	  func_arith $extracted_serial + 1
51366aec45a7Smrg	  extracted_serial=$func_arith_result
51376aec45a7Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
51386aec45a7Smrg	*) break ;;
51396aec45a7Smrg	esac
51406aec45a7Smrg      done
51416aec45a7Smrg      extracted_archives="$extracted_archives $my_xlib_u"
5142300bf1aeSmrg      my_xdir=$my_gentop/$my_xlib_u
51431473d951Smrg
51446aec45a7Smrg      func_mkdir_p "$my_xdir"
51456aec45a7Smrg
51466aec45a7Smrg      case $host in
51476aec45a7Smrg      *-darwin*)
51486aec45a7Smrg	func_verbose "Extracting $my_xabs"
51496aec45a7Smrg	# Do not bother doing anything if just a dry run
51506aec45a7Smrg	$opt_dry_run || {
51516aec45a7Smrg	  darwin_orig_dir=`pwd`
51526aec45a7Smrg	  cd $my_xdir || exit $?
51536aec45a7Smrg	  darwin_archive=$my_xabs
51546aec45a7Smrg	  darwin_curdir=`pwd`
5155300bf1aeSmrg	  func_basename "$darwin_archive"
5156300bf1aeSmrg	  darwin_base_archive=$func_basename_result
51576aec45a7Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
51586aec45a7Smrg	  if test -n "$darwin_arches"; then
51596aec45a7Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
51606aec45a7Smrg	    darwin_arch=
51616aec45a7Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
5162300bf1aeSmrg	    for darwin_arch in  $darwin_arches; do
5163300bf1aeSmrg	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
5164300bf1aeSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
5165300bf1aeSmrg	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
5166300bf1aeSmrg	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
51676aec45a7Smrg	      cd "$darwin_curdir"
5168300bf1aeSmrg	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
51696aec45a7Smrg	    done # $darwin_arches
51706aec45a7Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
5171300bf1aeSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
51726aec45a7Smrg	    darwin_file=
51736aec45a7Smrg	    darwin_files=
51746aec45a7Smrg	    for darwin_file in $darwin_filelist; do
51756aec45a7Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
51766aec45a7Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
51776aec45a7Smrg	    done # $darwin_filelist
51786aec45a7Smrg	    $RM -rf unfat-$$
51796aec45a7Smrg	    cd "$darwin_orig_dir"
51805c42550eSmrg	  else
51816aec45a7Smrg	    cd $darwin_orig_dir
51826aec45a7Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
51836aec45a7Smrg	  fi # $darwin_arches
51846aec45a7Smrg	} # !$opt_dry_run
51856aec45a7Smrg	;;
51866aec45a7Smrg      *)
51876aec45a7Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
51886aec45a7Smrg	;;
51896aec45a7Smrg      esac
51906aec45a7Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
51916aec45a7Smrg    done
5192ab47cfaaSmrg
5193300bf1aeSmrg    func_extract_archives_result=$my_oldobjs
51946aec45a7Smrg}
5195ab47cfaaSmrg
51961473d951Smrg
51976aec45a7Smrg# func_emit_wrapper [arg=no]
51986aec45a7Smrg#
51996aec45a7Smrg# Emit a libtool wrapper script on stdout.
52006aec45a7Smrg# Don't directly open a file because we may want to
52016aec45a7Smrg# incorporate the script contents within a cygwin/mingw
52026aec45a7Smrg# wrapper executable.  Must ONLY be called from within
52036aec45a7Smrg# func_mode_link because it depends on a number of variables
52046aec45a7Smrg# set therein.
52056aec45a7Smrg#
52066aec45a7Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
52076aec45a7Smrg# variable will take.  If 'yes', then the emitted script
5208300bf1aeSmrg# will assume that the directory where it is stored is
52096aec45a7Smrg# the $objdir directory.  This is a cygwin/mingw-specific
52106aec45a7Smrg# behavior.
52116aec45a7Smrgfunc_emit_wrapper ()
52126aec45a7Smrg{
52136aec45a7Smrg	func_emit_wrapper_arg1=${1-no}
52145c42550eSmrg
52156aec45a7Smrg	$ECHO "\
52166aec45a7Smrg#! $SHELL
52171473d951Smrg
52186aec45a7Smrg# $output - temporary wrapper script for $objdir/$outputname
5219300bf1aeSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
52206aec45a7Smrg#
52216aec45a7Smrg# The $output program cannot be directly executed until all the libtool
52226aec45a7Smrg# libraries that it depends on are installed.
52236aec45a7Smrg#
52246aec45a7Smrg# This wrapper script should never be moved out of the build directory.
52256aec45a7Smrg# If it is, it will not operate correctly.
5226ab47cfaaSmrg
52276aec45a7Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
52286aec45a7Smrg# metacharacters that are still active within double-quoted strings.
52296aec45a7Smrgsed_quote_subst='$sed_quote_subst'
5230ab47cfaaSmrg
52316aec45a7Smrg# Be Bourne compatible
52326aec45a7Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
52336aec45a7Smrg  emulate sh
52346aec45a7Smrg  NULLCMD=:
52356aec45a7Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
52366aec45a7Smrg  # is contrary to our usage.  Disable this feature.
52376aec45a7Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
52386aec45a7Smrg  setopt NO_GLOB_SUBST
52396aec45a7Smrgelse
52406aec45a7Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
52416aec45a7Smrgfi
52426aec45a7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
52436aec45a7SmrgDUALCASE=1; export DUALCASE # for MKS sh
5244ab47cfaaSmrg
52456aec45a7Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
52466aec45a7Smrg# if CDPATH is set.
52476aec45a7Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5248ab47cfaaSmrg
52496aec45a7Smrgrelink_command=\"$relink_command\"
5250ab47cfaaSmrg
52516aec45a7Smrg# This environment variable determines our operation mode.
52526aec45a7Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
52536aec45a7Smrg  # install mode needs the following variables:
52546aec45a7Smrg  generated_by_libtool_version='$macro_version'
52556aec45a7Smrg  notinst_deplibs='$notinst_deplibs'
52566aec45a7Smrgelse
52576aec45a7Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
52586aec45a7Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
52596aec45a7Smrg    file=\"\$0\""
5260ab47cfaaSmrg
52616aec45a7Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
52626aec45a7Smrg    $ECHO "\
5263ab47cfaaSmrg
52646aec45a7Smrg# A function that is used when there is no print builtin or printf.
52656aec45a7Smrgfunc_fallback_echo ()
52666aec45a7Smrg{
52676aec45a7Smrg  eval 'cat <<_LTECHO_EOF
52686aec45a7Smrg\$1
52696aec45a7Smrg_LTECHO_EOF'
52706aec45a7Smrg}
52716aec45a7Smrg    ECHO=\"$qECHO\"
52726aec45a7Smrg  fi
52736aec45a7Smrg
52746aec45a7Smrg# Very basic option parsing. These options are (a) specific to
52756aec45a7Smrg# the libtool wrapper, (b) are identical between the wrapper
5276300bf1aeSmrg# /script/ and the wrapper /executable/ that is used only on
52776aec45a7Smrg# windows platforms, and (c) all begin with the string "--lt-"
5278300bf1aeSmrg# (application programs are unlikely to have options that match
52796aec45a7Smrg# this pattern).
52806aec45a7Smrg#
52816aec45a7Smrg# There are only two supported options: --lt-debug and
52826aec45a7Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
52836aec45a7Smrg#
52846aec45a7Smrg# The first argument to this parsing function should be the
52856aec45a7Smrg# script's $0 value, followed by "$@".
52866aec45a7Smrglt_option_debug=
52876aec45a7Smrgfunc_parse_lt_options ()
52886aec45a7Smrg{
52896aec45a7Smrg  lt_script_arg0=\$0
52906aec45a7Smrg  shift
52916aec45a7Smrg  for lt_opt
52926aec45a7Smrg  do
52936aec45a7Smrg    case \"\$lt_opt\" in
52946aec45a7Smrg    --lt-debug) lt_option_debug=1 ;;
52956aec45a7Smrg    --lt-dump-script)
52966aec45a7Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
52976aec45a7Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
52986aec45a7Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
52996aec45a7Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
53006aec45a7Smrg        exit 0
53016aec45a7Smrg      ;;
53026aec45a7Smrg    --lt-*)
53036aec45a7Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
53046aec45a7Smrg        exit 1
53055c42550eSmrg      ;;
53066aec45a7Smrg    esac
53076aec45a7Smrg  done
5308ab47cfaaSmrg
53096aec45a7Smrg  # Print the debug banner immediately:
53106aec45a7Smrg  if test -n \"\$lt_option_debug\"; then
5311300bf1aeSmrg    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
53126aec45a7Smrg  fi
53136aec45a7Smrg}
5314ab47cfaaSmrg
53156aec45a7Smrg# Used when --lt-debug. Prints its arguments to stdout
53166aec45a7Smrg# (redirection is the responsibility of the caller)
53176aec45a7Smrgfunc_lt_dump_args ()
53186aec45a7Smrg{
53196aec45a7Smrg  lt_dump_args_N=1;
53206aec45a7Smrg  for lt_arg
53216aec45a7Smrg  do
5322300bf1aeSmrg    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
53236aec45a7Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
53246aec45a7Smrg  done
53256aec45a7Smrg}
5326ab47cfaaSmrg
53276aec45a7Smrg# Core function for launching the target application
53286aec45a7Smrgfunc_exec_program_core ()
53296aec45a7Smrg{
53306aec45a7Smrg"
53316aec45a7Smrg  case $host in
53326aec45a7Smrg  # Backslashes separate directories on plain windows
53336aec45a7Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
53346aec45a7Smrg    $ECHO "\
53356aec45a7Smrg      if test -n \"\$lt_option_debug\"; then
5336300bf1aeSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
53376aec45a7Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
53385c42550eSmrg      fi
53396aec45a7Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
53406aec45a7Smrg"
53416aec45a7Smrg    ;;
5342ab47cfaaSmrg
53436aec45a7Smrg  *)
53446aec45a7Smrg    $ECHO "\
53456aec45a7Smrg      if test -n \"\$lt_option_debug\"; then
5346300bf1aeSmrg        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
53476aec45a7Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
53485c42550eSmrg      fi
53496aec45a7Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
53506aec45a7Smrg"
53516aec45a7Smrg    ;;
53526aec45a7Smrg  esac
53536aec45a7Smrg  $ECHO "\
53546aec45a7Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
53556aec45a7Smrg      exit 1
53566aec45a7Smrg}
5357ab47cfaaSmrg
53586aec45a7Smrg# A function to encapsulate launching the target application
53596aec45a7Smrg# Strips options in the --lt-* namespace from \$@ and
53606aec45a7Smrg# launches target application with the remaining arguments.
53616aec45a7Smrgfunc_exec_program ()
53626aec45a7Smrg{
5363aa9e3350Smrg  case \" \$* \" in
5364aa9e3350Smrg  *\\ --lt-*)
5365aa9e3350Smrg    for lt_wr_arg
5366aa9e3350Smrg    do
5367aa9e3350Smrg      case \$lt_wr_arg in
5368aa9e3350Smrg      --lt-*) ;;
5369aa9e3350Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5370aa9e3350Smrg      esac
5371aa9e3350Smrg      shift
5372aa9e3350Smrg    done ;;
5373aa9e3350Smrg  esac
53746aec45a7Smrg  func_exec_program_core \${1+\"\$@\"}
53756aec45a7Smrg}
5376ab47cfaaSmrg
53776aec45a7Smrg  # Parse options
53786aec45a7Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5379ab47cfaaSmrg
53806aec45a7Smrg  # Find the directory that this script lives in.
53816aec45a7Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
53826aec45a7Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5383ab47cfaaSmrg
53846aec45a7Smrg  # Follow symbolic links until we get to the real thisdir.
53856aec45a7Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
53866aec45a7Smrg  while test -n \"\$file\"; do
53876aec45a7Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5388ab47cfaaSmrg
53896aec45a7Smrg    # If there was a directory component, then change thisdir.
53906aec45a7Smrg    if test \"x\$destdir\" != \"x\$file\"; then
53916aec45a7Smrg      case \"\$destdir\" in
53926aec45a7Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
53936aec45a7Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
53946aec45a7Smrg      esac
53956aec45a7Smrg    fi
5396ab47cfaaSmrg
53976aec45a7Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
53986aec45a7Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
53996aec45a7Smrg  done
5400ab47cfaaSmrg
54016aec45a7Smrg  # Usually 'no', except on cygwin/mingw when embedded into
54026aec45a7Smrg  # the cwrapper.
54036aec45a7Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
54046aec45a7Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
54056aec45a7Smrg    # special case for '.'
54066aec45a7Smrg    if test \"\$thisdir\" = \".\"; then
54076aec45a7Smrg      thisdir=\`pwd\`
54086aec45a7Smrg    fi
54096aec45a7Smrg    # remove .libs from thisdir
54106aec45a7Smrg    case \"\$thisdir\" in
54116aec45a7Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
54126aec45a7Smrg    $objdir )   thisdir=. ;;
54136aec45a7Smrg    esac
54146aec45a7Smrg  fi
5415ab47cfaaSmrg
54166aec45a7Smrg  # Try to get the absolute directory name.
54176aec45a7Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
54186aec45a7Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
54196aec45a7Smrg"
5420ab47cfaaSmrg
5421300bf1aeSmrg	if test yes = "$fast_install"; then
54226aec45a7Smrg	  $ECHO "\
54236aec45a7Smrg  program=lt-'$outputname'$exeext
54246aec45a7Smrg  progdir=\"\$thisdir/$objdir\"
5425ab47cfaaSmrg
54266aec45a7Smrg  if test ! -f \"\$progdir/\$program\" ||
5427300bf1aeSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
54286aec45a7Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5429ab47cfaaSmrg
54306aec45a7Smrg    file=\"\$\$-\$program\"
5431ab47cfaaSmrg
54326aec45a7Smrg    if test ! -d \"\$progdir\"; then
54336aec45a7Smrg      $MKDIR \"\$progdir\"
54346aec45a7Smrg    else
54356aec45a7Smrg      $RM \"\$progdir/\$file\"
54366aec45a7Smrg    fi"
5437ab47cfaaSmrg
54386aec45a7Smrg	  $ECHO "\
5439ab47cfaaSmrg
54406aec45a7Smrg    # relink executable if necessary
54416aec45a7Smrg    if test -n \"\$relink_command\"; then
54426aec45a7Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
54436aec45a7Smrg      else
5444300bf1aeSmrg	\$ECHO \"\$relink_command_output\" >&2
54456aec45a7Smrg	$RM \"\$progdir/\$file\"
54466aec45a7Smrg	exit 1
54476aec45a7Smrg      fi
54486aec45a7Smrg    fi
5449ab47cfaaSmrg
54506aec45a7Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
54516aec45a7Smrg    { $RM \"\$progdir/\$program\";
54526aec45a7Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
54536aec45a7Smrg    $RM \"\$progdir/\$file\"
54546aec45a7Smrg  fi"
54556aec45a7Smrg	else
54566aec45a7Smrg	  $ECHO "\
54576aec45a7Smrg  program='$outputname'
54586aec45a7Smrg  progdir=\"\$thisdir/$objdir\"
54596aec45a7Smrg"
54606aec45a7Smrg	fi
5461ab47cfaaSmrg
54626aec45a7Smrg	$ECHO "\
5463ab47cfaaSmrg
54646aec45a7Smrg  if test -f \"\$progdir/\$program\"; then"
5465ab47cfaaSmrg
5466aa9e3350Smrg	# fixup the dll searchpath if we need to.
5467aa9e3350Smrg	#
5468aa9e3350Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
5469aa9e3350Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
5470aa9e3350Smrg	# libraries must come first.
5471aa9e3350Smrg	if test -n "$dllsearchpath"; then
5472aa9e3350Smrg	  $ECHO "\
5473aa9e3350Smrg    # Add the dll search path components to the executable PATH
5474aa9e3350Smrg    PATH=$dllsearchpath:\$PATH
5475aa9e3350Smrg"
5476aa9e3350Smrg	fi
5477aa9e3350Smrg
54786aec45a7Smrg	# Export our shlibpath_var if we have one.
5479300bf1aeSmrg	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
54806aec45a7Smrg	  $ECHO "\
54816aec45a7Smrg    # Add our own library path to $shlibpath_var
54826aec45a7Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5483ab47cfaaSmrg
54846aec45a7Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
54856aec45a7Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
54866aec45a7Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5487ab47cfaaSmrg
54886aec45a7Smrg    export $shlibpath_var
54896aec45a7Smrg"
54906aec45a7Smrg	fi
54911473d951Smrg
54926aec45a7Smrg	$ECHO "\
54936aec45a7Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
54946aec45a7Smrg      # Run the actual program with our arguments.
54956aec45a7Smrg      func_exec_program \${1+\"\$@\"}
54966aec45a7Smrg    fi
54976aec45a7Smrg  else
54986aec45a7Smrg    # The program doesn't exist.
5499300bf1aeSmrg    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
55006aec45a7Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
55016aec45a7Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
55026aec45a7Smrg    exit 1
55036aec45a7Smrg  fi
55046aec45a7Smrgfi\
55056aec45a7Smrg"
55066aec45a7Smrg}
55071473d951Smrg
55081473d951Smrg
55096aec45a7Smrg# func_emit_cwrapperexe_src
55106aec45a7Smrg# emit the source code for a wrapper executable on stdout
55116aec45a7Smrg# Must ONLY be called from within func_mode_link because
55126aec45a7Smrg# it depends on a number of variable set therein.
55136aec45a7Smrgfunc_emit_cwrapperexe_src ()
55146aec45a7Smrg{
55156aec45a7Smrg	cat <<EOF
5516ab47cfaaSmrg
55176aec45a7Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5518300bf1aeSmrg   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5519ab47cfaaSmrg
55206aec45a7Smrg   The $output program cannot be directly executed until all the libtool
55216aec45a7Smrg   libraries that it depends on are installed.
5522ab47cfaaSmrg
55236aec45a7Smrg   This wrapper executable should never be moved out of the build directory.
55246aec45a7Smrg   If it is, it will not operate correctly.
55256aec45a7Smrg*/
55266aec45a7SmrgEOF
55276aec45a7Smrg	    cat <<"EOF"
55286aec45a7Smrg#ifdef _MSC_VER
55296aec45a7Smrg# define _CRT_SECURE_NO_DEPRECATE 1
55306aec45a7Smrg#endif
55316aec45a7Smrg#include <stdio.h>
55326aec45a7Smrg#include <stdlib.h>
55336aec45a7Smrg#ifdef _MSC_VER
55346aec45a7Smrg# include <direct.h>
55356aec45a7Smrg# include <process.h>
55366aec45a7Smrg# include <io.h>
55376aec45a7Smrg#else
55386aec45a7Smrg# include <unistd.h>
55396aec45a7Smrg# include <stdint.h>
55406aec45a7Smrg# ifdef __CYGWIN__
55416aec45a7Smrg#  include <io.h>
55426aec45a7Smrg# endif
55436aec45a7Smrg#endif
55446aec45a7Smrg#include <malloc.h>
55456aec45a7Smrg#include <stdarg.h>
55466aec45a7Smrg#include <assert.h>
55476aec45a7Smrg#include <string.h>
55486aec45a7Smrg#include <ctype.h>
55496aec45a7Smrg#include <errno.h>
55506aec45a7Smrg#include <fcntl.h>
55516aec45a7Smrg#include <sys/stat.h>
5552ab47cfaaSmrg
5553300bf1aeSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5554300bf1aeSmrg
55556aec45a7Smrg/* declarations of non-ANSI functions */
5556300bf1aeSmrg#if defined __MINGW32__
55576aec45a7Smrg# ifdef __STRICT_ANSI__
55586aec45a7Smrgint _putenv (const char *);
55596aec45a7Smrg# endif
5560300bf1aeSmrg#elif defined __CYGWIN__
55616aec45a7Smrg# ifdef __STRICT_ANSI__
55626aec45a7Smrgchar *realpath (const char *, char *);
55636aec45a7Smrgint putenv (char *);
55646aec45a7Smrgint setenv (const char *, const char *, int);
55656aec45a7Smrg# endif
5566300bf1aeSmrg/* #elif defined other_platform || defined ... */
55676aec45a7Smrg#endif
5568ab47cfaaSmrg
55696aec45a7Smrg/* portability defines, excluding path handling macros */
5570300bf1aeSmrg#if defined _MSC_VER
55716aec45a7Smrg# define setmode _setmode
55726aec45a7Smrg# define stat    _stat
55736aec45a7Smrg# define chmod   _chmod
55746aec45a7Smrg# define getcwd  _getcwd
55756aec45a7Smrg# define putenv  _putenv
55766aec45a7Smrg# define S_IXUSR _S_IEXEC
5577300bf1aeSmrg#elif defined __MINGW32__
55786aec45a7Smrg# define setmode _setmode
55796aec45a7Smrg# define stat    _stat
55806aec45a7Smrg# define chmod   _chmod
55816aec45a7Smrg# define getcwd  _getcwd
55826aec45a7Smrg# define putenv  _putenv
5583300bf1aeSmrg#elif defined __CYGWIN__
55846aec45a7Smrg# define HAVE_SETENV
55856aec45a7Smrg# define FOPEN_WB "wb"
5586300bf1aeSmrg/* #elif defined other platforms ... */
55876aec45a7Smrg#endif
5588ab47cfaaSmrg
5589300bf1aeSmrg#if defined PATH_MAX
55906aec45a7Smrg# define LT_PATHMAX PATH_MAX
5591300bf1aeSmrg#elif defined MAXPATHLEN
55926aec45a7Smrg# define LT_PATHMAX MAXPATHLEN
55936aec45a7Smrg#else
55946aec45a7Smrg# define LT_PATHMAX 1024
55956aec45a7Smrg#endif
5596ab47cfaaSmrg
55976aec45a7Smrg#ifndef S_IXOTH
55986aec45a7Smrg# define S_IXOTH 0
55996aec45a7Smrg#endif
56006aec45a7Smrg#ifndef S_IXGRP
56016aec45a7Smrg# define S_IXGRP 0
56026aec45a7Smrg#endif
5603ab47cfaaSmrg
56046aec45a7Smrg/* path handling portability macros */
56056aec45a7Smrg#ifndef DIR_SEPARATOR
56066aec45a7Smrg# define DIR_SEPARATOR '/'
56076aec45a7Smrg# define PATH_SEPARATOR ':'
56086aec45a7Smrg#endif
5609ab47cfaaSmrg
5610300bf1aeSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
5611300bf1aeSmrg  defined __OS2__
56126aec45a7Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
56136aec45a7Smrg# define FOPEN_WB "wb"
56146aec45a7Smrg# ifndef DIR_SEPARATOR_2
56156aec45a7Smrg#  define DIR_SEPARATOR_2 '\\'
56166aec45a7Smrg# endif
56176aec45a7Smrg# ifndef PATH_SEPARATOR_2
56186aec45a7Smrg#  define PATH_SEPARATOR_2 ';'
56196aec45a7Smrg# endif
56206aec45a7Smrg#endif
5621ab47cfaaSmrg
56226aec45a7Smrg#ifndef DIR_SEPARATOR_2
56236aec45a7Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
56246aec45a7Smrg#else /* DIR_SEPARATOR_2 */
56256aec45a7Smrg# define IS_DIR_SEPARATOR(ch) \
56266aec45a7Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
56276aec45a7Smrg#endif /* DIR_SEPARATOR_2 */
5628ab47cfaaSmrg
56296aec45a7Smrg#ifndef PATH_SEPARATOR_2
56306aec45a7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
56316aec45a7Smrg#else /* PATH_SEPARATOR_2 */
56326aec45a7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
56336aec45a7Smrg#endif /* PATH_SEPARATOR_2 */
56346aec45a7Smrg
56356aec45a7Smrg#ifndef FOPEN_WB
56366aec45a7Smrg# define FOPEN_WB "w"
56376aec45a7Smrg#endif
56386aec45a7Smrg#ifndef _O_BINARY
56396aec45a7Smrg# define _O_BINARY 0
56406aec45a7Smrg#endif
56416aec45a7Smrg
56426aec45a7Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
56436aec45a7Smrg#define XFREE(stale) do { \
5644300bf1aeSmrg  if (stale) { free (stale); stale = 0; } \
56456aec45a7Smrg} while (0)
56466aec45a7Smrg
5647300bf1aeSmrg#if defined LT_DEBUGWRAPPER
56486aec45a7Smrgstatic int lt_debug = 1;
56496aec45a7Smrg#else
56506aec45a7Smrgstatic int lt_debug = 0;
56516aec45a7Smrg#endif
56526aec45a7Smrg
56536aec45a7Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
56546aec45a7Smrg
56556aec45a7Smrgvoid *xmalloc (size_t num);
56566aec45a7Smrgchar *xstrdup (const char *string);
56576aec45a7Smrgconst char *base_name (const char *name);
56586aec45a7Smrgchar *find_executable (const char *wrapper);
56596aec45a7Smrgchar *chase_symlinks (const char *pathspec);
56606aec45a7Smrgint make_executable (const char *path);
56616aec45a7Smrgint check_executable (const char *path);
56626aec45a7Smrgchar *strendzap (char *str, const char *pat);
56636aec45a7Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
56646aec45a7Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
56656aec45a7Smrgstatic const char *nonnull (const char *s);
56666aec45a7Smrgstatic const char *nonempty (const char *s);
56676aec45a7Smrgvoid lt_setenv (const char *name, const char *value);
56686aec45a7Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
56696aec45a7Smrgvoid lt_update_exe_path (const char *name, const char *value);
56706aec45a7Smrgvoid lt_update_lib_path (const char *name, const char *value);
56716aec45a7Smrgchar **prepare_spawn (char **argv);
56726aec45a7Smrgvoid lt_dump_script (FILE *f);
56736aec45a7SmrgEOF
56746aec45a7Smrg
56756aec45a7Smrg	    cat <<EOF
5676300bf1aeSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
5677300bf1aeSmrg# define externally_visible volatile
5678300bf1aeSmrg#else
5679300bf1aeSmrg# define externally_visible __attribute__((externally_visible)) volatile
5680300bf1aeSmrg#endif
5681300bf1aeSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe";
56826aec45a7Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
56836aec45a7SmrgEOF
56846aec45a7Smrg
5685300bf1aeSmrg	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5686aa9e3350Smrg              func_to_host_path "$temp_rpath"
56876aec45a7Smrg	      cat <<EOF
5688aa9e3350Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
56895c42550eSmrgEOF
56905c42550eSmrg	    else
56916aec45a7Smrg	      cat <<"EOF"
56926aec45a7Smrgconst char * LIB_PATH_VALUE   = "";
56936aec45a7SmrgEOF
56945c42550eSmrg	    fi
56956aec45a7Smrg
56966aec45a7Smrg	    if test -n "$dllsearchpath"; then
5697aa9e3350Smrg              func_to_host_path "$dllsearchpath:"
56986aec45a7Smrg	      cat <<EOF
56996aec45a7Smrgconst char * EXE_PATH_VARNAME = "PATH";
5700aa9e3350Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
57016aec45a7SmrgEOF
57025c42550eSmrg	    else
57036aec45a7Smrg	      cat <<"EOF"
57046aec45a7Smrgconst char * EXE_PATH_VARNAME = "";
57056aec45a7Smrgconst char * EXE_PATH_VALUE   = "";
57066aec45a7SmrgEOF
57075c42550eSmrg	    fi
57086aec45a7Smrg
5709300bf1aeSmrg	    if test yes = "$fast_install"; then
57106aec45a7Smrg	      cat <<EOF
57116aec45a7Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
57126aec45a7SmrgEOF
57135c42550eSmrg	    else
57146aec45a7Smrg	      cat <<EOF
57156aec45a7Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
57166aec45a7SmrgEOF
57175c42550eSmrg	    fi
5718ab47cfaaSmrg
5719ab47cfaaSmrg
57206aec45a7Smrg	    cat <<"EOF"
5721ab47cfaaSmrg
57226aec45a7Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
5723ab47cfaaSmrg
57246aec45a7Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
57256aec45a7Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
57266aec45a7Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
5727ab47cfaaSmrg
57286aec45a7Smrgint
57296aec45a7Smrgmain (int argc, char *argv[])
57306aec45a7Smrg{
57316aec45a7Smrg  char **newargz;
57326aec45a7Smrg  int  newargc;
57336aec45a7Smrg  char *tmp_pathspec;
57346aec45a7Smrg  char *actual_cwrapper_path;
57356aec45a7Smrg  char *actual_cwrapper_name;
57366aec45a7Smrg  char *target_name;
57376aec45a7Smrg  char *lt_argv_zero;
5738300bf1aeSmrg  int rval = 127;
5739ab47cfaaSmrg
57406aec45a7Smrg  int i;
5741ab47cfaaSmrg
57426aec45a7Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
5743300bf1aeSmrg  newargz = XMALLOC (char *, (size_t) argc + 1);
5744ab47cfaaSmrg
57456aec45a7Smrg  /* very simple arg parsing; don't want to rely on getopt
57466aec45a7Smrg   * also, copy all non cwrapper options to newargz, except
57476aec45a7Smrg   * argz[0], which is handled differently
57486aec45a7Smrg   */
57496aec45a7Smrg  newargc=0;
57506aec45a7Smrg  for (i = 1; i < argc; i++)
57516aec45a7Smrg    {
5752300bf1aeSmrg      if (STREQ (argv[i], dumpscript_opt))
57536aec45a7Smrg	{
57546aec45a7SmrgEOF
5755300bf1aeSmrg	    case $host in
57566aec45a7Smrg	      *mingw* | *cygwin* )
57576aec45a7Smrg		# make stdout use "unix" line endings
57586aec45a7Smrg		echo "          setmode(1,_O_BINARY);"
57596aec45a7Smrg		;;
57605c42550eSmrg	      esac
5761ab47cfaaSmrg
57626aec45a7Smrg	    cat <<"EOF"
57636aec45a7Smrg	  lt_dump_script (stdout);
57646aec45a7Smrg	  return 0;
57656aec45a7Smrg	}
5766300bf1aeSmrg      if (STREQ (argv[i], debug_opt))
57676aec45a7Smrg	{
57686aec45a7Smrg          lt_debug = 1;
57696aec45a7Smrg          continue;
57706aec45a7Smrg	}
5771300bf1aeSmrg      if (STREQ (argv[i], ltwrapper_option_prefix))
57726aec45a7Smrg        {
57736aec45a7Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
57746aec45a7Smrg             namespace, but it is not one of the ones we know about and
57756aec45a7Smrg             have already dealt with, above (inluding dump-script), then
57766aec45a7Smrg             report an error. Otherwise, targets might begin to believe
57776aec45a7Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
57786aec45a7Smrg             namespace. The first time any user complains about this, we'll
57796aec45a7Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
57806aec45a7Smrg             or a configure.ac-settable value.
57816aec45a7Smrg           */
57826aec45a7Smrg          lt_fatal (__FILE__, __LINE__,
57836aec45a7Smrg		    "unrecognized %s option: '%s'",
57846aec45a7Smrg                    ltwrapper_option_prefix, argv[i]);
57856aec45a7Smrg        }
57866aec45a7Smrg      /* otherwise ... */
57876aec45a7Smrg      newargz[++newargc] = xstrdup (argv[i]);
57886aec45a7Smrg    }
57896aec45a7Smrg  newargz[++newargc] = NULL;
5790ab47cfaaSmrg
57916aec45a7SmrgEOF
57926aec45a7Smrg	    cat <<EOF
57936aec45a7Smrg  /* The GNU banner must be the first non-error debug message */
5794300bf1aeSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
57956aec45a7SmrgEOF
57966aec45a7Smrg	    cat <<"EOF"
57976aec45a7Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
57986aec45a7Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
57996aec45a7Smrg
58006aec45a7Smrg  tmp_pathspec = find_executable (argv[0]);
58016aec45a7Smrg  if (tmp_pathspec == NULL)
58026aec45a7Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
58036aec45a7Smrg  lt_debugprintf (__FILE__, __LINE__,
58046aec45a7Smrg                  "(main) found exe (before symlink chase) at: %s\n",
58056aec45a7Smrg		  tmp_pathspec);
58066aec45a7Smrg
58076aec45a7Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
58086aec45a7Smrg  lt_debugprintf (__FILE__, __LINE__,
58096aec45a7Smrg                  "(main) found exe (after symlink chase) at: %s\n",
58106aec45a7Smrg		  actual_cwrapper_path);
58116aec45a7Smrg  XFREE (tmp_pathspec);
58126aec45a7Smrg
58136aec45a7Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
58146aec45a7Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
58156aec45a7Smrg
58166aec45a7Smrg  /* wrapper name transforms */
58176aec45a7Smrg  strendzap (actual_cwrapper_name, ".exe");
58186aec45a7Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
58196aec45a7Smrg  XFREE (actual_cwrapper_name);
58206aec45a7Smrg  actual_cwrapper_name = tmp_pathspec;
58216aec45a7Smrg  tmp_pathspec = 0;
58226aec45a7Smrg
58236aec45a7Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
58246aec45a7Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
58256aec45a7Smrg  strendzap (target_name, ".exe");
58266aec45a7Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
58276aec45a7Smrg  XFREE (target_name);
58286aec45a7Smrg  target_name = tmp_pathspec;
58296aec45a7Smrg  tmp_pathspec = 0;
58306aec45a7Smrg
58316aec45a7Smrg  lt_debugprintf (__FILE__, __LINE__,
58326aec45a7Smrg		  "(main) libtool target name: %s\n",
58336aec45a7Smrg		  target_name);
58346aec45a7SmrgEOF
5835ab47cfaaSmrg
58366aec45a7Smrg	    cat <<EOF
58376aec45a7Smrg  newargz[0] =
58386aec45a7Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
58396aec45a7Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
58406aec45a7Smrg  strcpy (newargz[0], actual_cwrapper_path);
58416aec45a7Smrg  strcat (newargz[0], "$objdir");
58426aec45a7Smrg  strcat (newargz[0], "/");
58436aec45a7SmrgEOF
5844ab47cfaaSmrg
58456aec45a7Smrg	    cat <<"EOF"
58466aec45a7Smrg  /* stop here, and copy so we don't have to do this twice */
58476aec45a7Smrg  tmp_pathspec = xstrdup (newargz[0]);
5848ab47cfaaSmrg
58496aec45a7Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
58506aec45a7Smrg  strcat (newargz[0], actual_cwrapper_name);
5851ab47cfaaSmrg
58526aec45a7Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
58536aec45a7Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
58546aec45a7Smrg  XFREE (tmp_pathspec);
58556aec45a7Smrg  tmp_pathspec = NULL;
58566aec45a7SmrgEOF
5857ab47cfaaSmrg
58586aec45a7Smrg	    case $host_os in
58596aec45a7Smrg	      mingw*)
58606aec45a7Smrg	    cat <<"EOF"
58616aec45a7Smrg  {
58626aec45a7Smrg    char* p;
58636aec45a7Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
58646aec45a7Smrg      {
58656aec45a7Smrg	*p = '/';
58666aec45a7Smrg      }
58676aec45a7Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
58686aec45a7Smrg      {
58696aec45a7Smrg	*p = '/';
58706aec45a7Smrg      }
58716aec45a7Smrg  }
58726aec45a7SmrgEOF
58736aec45a7Smrg	    ;;
58746aec45a7Smrg	    esac
5875ab47cfaaSmrg
58766aec45a7Smrg	    cat <<"EOF"
58776aec45a7Smrg  XFREE (target_name);
58786aec45a7Smrg  XFREE (actual_cwrapper_path);
58796aec45a7Smrg  XFREE (actual_cwrapper_name);
5880ab47cfaaSmrg
58816aec45a7Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
58826aec45a7Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
5883aa9e3350Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
5884aa9e3350Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5885aa9e3350Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
5886aa9e3350Smrg     libraries must come first. */
58876aec45a7Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5888aa9e3350Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
5889ab47cfaaSmrg
58906aec45a7Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
58916aec45a7Smrg		  nonnull (lt_argv_zero));
58926aec45a7Smrg  for (i = 0; i < newargc; i++)
58936aec45a7Smrg    {
58946aec45a7Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
58956aec45a7Smrg		      i, nonnull (newargz[i]));
58966aec45a7Smrg    }
5897ab47cfaaSmrg
58986aec45a7SmrgEOF
5899ab47cfaaSmrg
59006aec45a7Smrg	    case $host_os in
59016aec45a7Smrg	      mingw*)
59026aec45a7Smrg		cat <<"EOF"
59036aec45a7Smrg  /* execv doesn't actually work on mingw as expected on unix */
59046aec45a7Smrg  newargz = prepare_spawn (newargz);
5905300bf1aeSmrg  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
59066aec45a7Smrg  if (rval == -1)
59076aec45a7Smrg    {
59086aec45a7Smrg      /* failed to start process */
59096aec45a7Smrg      lt_debugprintf (__FILE__, __LINE__,
59106aec45a7Smrg		      "(main) failed to launch target \"%s\": %s\n",
59116aec45a7Smrg		      lt_argv_zero, nonnull (strerror (errno)));
59126aec45a7Smrg      return 127;
59136aec45a7Smrg    }
59146aec45a7Smrg  return rval;
59156aec45a7SmrgEOF
59166aec45a7Smrg		;;
59176aec45a7Smrg	      *)
59186aec45a7Smrg		cat <<"EOF"
59196aec45a7Smrg  execv (lt_argv_zero, newargz);
59206aec45a7Smrg  return rval; /* =127, but avoids unused variable warning */
59216aec45a7SmrgEOF
59226aec45a7Smrg		;;
59236aec45a7Smrg	    esac
5924ab47cfaaSmrg
59256aec45a7Smrg	    cat <<"EOF"
59266aec45a7Smrg}
5927ab47cfaaSmrg
59286aec45a7Smrgvoid *
59296aec45a7Smrgxmalloc (size_t num)
59306aec45a7Smrg{
59316aec45a7Smrg  void *p = (void *) malloc (num);
59326aec45a7Smrg  if (!p)
59336aec45a7Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
5934ab47cfaaSmrg
59356aec45a7Smrg  return p;
59366aec45a7Smrg}
5937ab47cfaaSmrg
59386aec45a7Smrgchar *
59396aec45a7Smrgxstrdup (const char *string)
59406aec45a7Smrg{
59416aec45a7Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
59426aec45a7Smrg			  string) : NULL;
59436aec45a7Smrg}
5944ab47cfaaSmrg
59456aec45a7Smrgconst char *
59466aec45a7Smrgbase_name (const char *name)
59476aec45a7Smrg{
59486aec45a7Smrg  const char *base;
5949ab47cfaaSmrg
5950300bf1aeSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
59516aec45a7Smrg  /* Skip over the disk name in MSDOS pathnames. */
59526aec45a7Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
59536aec45a7Smrg    name += 2;
59546aec45a7Smrg#endif
5955ab47cfaaSmrg
59566aec45a7Smrg  for (base = name; *name; name++)
59576aec45a7Smrg    if (IS_DIR_SEPARATOR (*name))
59586aec45a7Smrg      base = name + 1;
59596aec45a7Smrg  return base;
59606aec45a7Smrg}
5961ab47cfaaSmrg
59626aec45a7Smrgint
59636aec45a7Smrgcheck_executable (const char *path)
59646aec45a7Smrg{
59656aec45a7Smrg  struct stat st;
5966ab47cfaaSmrg
59676aec45a7Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
59686aec45a7Smrg                  nonempty (path));
59696aec45a7Smrg  if ((!path) || (!*path))
59706aec45a7Smrg    return 0;
5971ab47cfaaSmrg
59726aec45a7Smrg  if ((stat (path, &st) >= 0)
59736aec45a7Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
59746aec45a7Smrg    return 1;
59756aec45a7Smrg  else
59766aec45a7Smrg    return 0;
59776aec45a7Smrg}
5978ab47cfaaSmrg
59796aec45a7Smrgint
59806aec45a7Smrgmake_executable (const char *path)
59816aec45a7Smrg{
59826aec45a7Smrg  int rval = 0;
59836aec45a7Smrg  struct stat st;
59845c42550eSmrg
59856aec45a7Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
59866aec45a7Smrg                  nonempty (path));
59876aec45a7Smrg  if ((!path) || (!*path))
59886aec45a7Smrg    return 0;
59895c42550eSmrg
59906aec45a7Smrg  if (stat (path, &st) >= 0)
59916aec45a7Smrg    {
59926aec45a7Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
59936aec45a7Smrg    }
59946aec45a7Smrg  return rval;
59956aec45a7Smrg}
59965c42550eSmrg
59976aec45a7Smrg/* Searches for the full path of the wrapper.  Returns
59986aec45a7Smrg   newly allocated full path name if found, NULL otherwise
59996aec45a7Smrg   Does not chase symlinks, even on platforms that support them.
60006aec45a7Smrg*/
60016aec45a7Smrgchar *
60026aec45a7Smrgfind_executable (const char *wrapper)
60036aec45a7Smrg{
60046aec45a7Smrg  int has_slash = 0;
60056aec45a7Smrg  const char *p;
60066aec45a7Smrg  const char *p_next;
60076aec45a7Smrg  /* static buffer for getcwd */
60086aec45a7Smrg  char tmp[LT_PATHMAX + 1];
6009300bf1aeSmrg  size_t tmp_len;
60106aec45a7Smrg  char *concat_name;
60115c42550eSmrg
60126aec45a7Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
60136aec45a7Smrg                  nonempty (wrapper));
60145c42550eSmrg
60156aec45a7Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
60166aec45a7Smrg    return NULL;
6017ab47cfaaSmrg
60186aec45a7Smrg  /* Absolute path? */
6019300bf1aeSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
60206aec45a7Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
60216aec45a7Smrg    {
60226aec45a7Smrg      concat_name = xstrdup (wrapper);
60236aec45a7Smrg      if (check_executable (concat_name))
60246aec45a7Smrg	return concat_name;
60256aec45a7Smrg      XFREE (concat_name);
60266aec45a7Smrg    }
60276aec45a7Smrg  else
60286aec45a7Smrg    {
60296aec45a7Smrg#endif
60306aec45a7Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
60316aec45a7Smrg	{
60326aec45a7Smrg	  concat_name = xstrdup (wrapper);
60336aec45a7Smrg	  if (check_executable (concat_name))
60346aec45a7Smrg	    return concat_name;
60356aec45a7Smrg	  XFREE (concat_name);
60366aec45a7Smrg	}
6037300bf1aeSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM
60386aec45a7Smrg    }
60396aec45a7Smrg#endif
6040ab47cfaaSmrg
60416aec45a7Smrg  for (p = wrapper; *p; p++)
60426aec45a7Smrg    if (*p == '/')
60436aec45a7Smrg      {
60446aec45a7Smrg	has_slash = 1;
60456aec45a7Smrg	break;
60466aec45a7Smrg      }
60476aec45a7Smrg  if (!has_slash)
60486aec45a7Smrg    {
60496aec45a7Smrg      /* no slashes; search PATH */
60506aec45a7Smrg      const char *path = getenv ("PATH");
60516aec45a7Smrg      if (path != NULL)
60526aec45a7Smrg	{
60536aec45a7Smrg	  for (p = path; *p; p = p_next)
60546aec45a7Smrg	    {
60556aec45a7Smrg	      const char *q;
60566aec45a7Smrg	      size_t p_len;
60576aec45a7Smrg	      for (q = p; *q; q++)
60586aec45a7Smrg		if (IS_PATH_SEPARATOR (*q))
60596aec45a7Smrg		  break;
6060300bf1aeSmrg	      p_len = (size_t) (q - p);
60616aec45a7Smrg	      p_next = (*q == '\0' ? q : q + 1);
60626aec45a7Smrg	      if (p_len == 0)
60636aec45a7Smrg		{
60646aec45a7Smrg		  /* empty path: current directory */
60656aec45a7Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
60666aec45a7Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
60676aec45a7Smrg                              nonnull (strerror (errno)));
60686aec45a7Smrg		  tmp_len = strlen (tmp);
60696aec45a7Smrg		  concat_name =
60706aec45a7Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
60716aec45a7Smrg		  memcpy (concat_name, tmp, tmp_len);
60726aec45a7Smrg		  concat_name[tmp_len] = '/';
60736aec45a7Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
60746aec45a7Smrg		}
60756aec45a7Smrg	      else
60766aec45a7Smrg		{
60776aec45a7Smrg		  concat_name =
60786aec45a7Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
60796aec45a7Smrg		  memcpy (concat_name, p, p_len);
60806aec45a7Smrg		  concat_name[p_len] = '/';
60816aec45a7Smrg		  strcpy (concat_name + p_len + 1, wrapper);
60826aec45a7Smrg		}
60836aec45a7Smrg	      if (check_executable (concat_name))
60846aec45a7Smrg		return concat_name;
60856aec45a7Smrg	      XFREE (concat_name);
60866aec45a7Smrg	    }
60876aec45a7Smrg	}
60886aec45a7Smrg      /* not found in PATH; assume curdir */
60896aec45a7Smrg    }
60906aec45a7Smrg  /* Relative path | not found in path: prepend cwd */
60916aec45a7Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
60926aec45a7Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
60936aec45a7Smrg              nonnull (strerror (errno)));
60946aec45a7Smrg  tmp_len = strlen (tmp);
60956aec45a7Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
60966aec45a7Smrg  memcpy (concat_name, tmp, tmp_len);
60976aec45a7Smrg  concat_name[tmp_len] = '/';
60986aec45a7Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
6099ab47cfaaSmrg
61006aec45a7Smrg  if (check_executable (concat_name))
61016aec45a7Smrg    return concat_name;
61026aec45a7Smrg  XFREE (concat_name);
61036aec45a7Smrg  return NULL;
61046aec45a7Smrg}
61055c42550eSmrg
61066aec45a7Smrgchar *
61076aec45a7Smrgchase_symlinks (const char *pathspec)
61086aec45a7Smrg{
61096aec45a7Smrg#ifndef S_ISLNK
61106aec45a7Smrg  return xstrdup (pathspec);
61116aec45a7Smrg#else
61126aec45a7Smrg  char buf[LT_PATHMAX];
61136aec45a7Smrg  struct stat s;
61146aec45a7Smrg  char *tmp_pathspec = xstrdup (pathspec);
61156aec45a7Smrg  char *p;
61166aec45a7Smrg  int has_symlinks = 0;
61176aec45a7Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
61186aec45a7Smrg    {
61196aec45a7Smrg      lt_debugprintf (__FILE__, __LINE__,
61206aec45a7Smrg		      "checking path component for symlinks: %s\n",
61216aec45a7Smrg		      tmp_pathspec);
61226aec45a7Smrg      if (lstat (tmp_pathspec, &s) == 0)
61236aec45a7Smrg	{
61246aec45a7Smrg	  if (S_ISLNK (s.st_mode) != 0)
61256aec45a7Smrg	    {
61266aec45a7Smrg	      has_symlinks = 1;
61276aec45a7Smrg	      break;
61286aec45a7Smrg	    }
61295c42550eSmrg
61306aec45a7Smrg	  /* search backwards for last DIR_SEPARATOR */
61316aec45a7Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
61326aec45a7Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
61336aec45a7Smrg	    p--;
61346aec45a7Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
61356aec45a7Smrg	    {
61366aec45a7Smrg	      /* no more DIR_SEPARATORS left */
61376aec45a7Smrg	      break;
61386aec45a7Smrg	    }
61396aec45a7Smrg	  *p = '\0';
61406aec45a7Smrg	}
61416aec45a7Smrg      else
61426aec45a7Smrg	{
61436aec45a7Smrg	  lt_fatal (__FILE__, __LINE__,
61446aec45a7Smrg		    "error accessing file \"%s\": %s",
61456aec45a7Smrg		    tmp_pathspec, nonnull (strerror (errno)));
61466aec45a7Smrg	}
61476aec45a7Smrg    }
61486aec45a7Smrg  XFREE (tmp_pathspec);
61495c42550eSmrg
61506aec45a7Smrg  if (!has_symlinks)
61516aec45a7Smrg    {
61526aec45a7Smrg      return xstrdup (pathspec);
61536aec45a7Smrg    }
61545c42550eSmrg
61556aec45a7Smrg  tmp_pathspec = realpath (pathspec, buf);
61566aec45a7Smrg  if (tmp_pathspec == 0)
61576aec45a7Smrg    {
61586aec45a7Smrg      lt_fatal (__FILE__, __LINE__,
61596aec45a7Smrg		"could not follow symlinks for %s", pathspec);
61606aec45a7Smrg    }
61616aec45a7Smrg  return xstrdup (tmp_pathspec);
61626aec45a7Smrg#endif
61636aec45a7Smrg}
6164ab47cfaaSmrg
61656aec45a7Smrgchar *
61666aec45a7Smrgstrendzap (char *str, const char *pat)
61676aec45a7Smrg{
61686aec45a7Smrg  size_t len, patlen;
6169ab47cfaaSmrg
61706aec45a7Smrg  assert (str != NULL);
61716aec45a7Smrg  assert (pat != NULL);
6172ab47cfaaSmrg
61736aec45a7Smrg  len = strlen (str);
61746aec45a7Smrg  patlen = strlen (pat);
6175ab47cfaaSmrg
61766aec45a7Smrg  if (patlen <= len)
61776aec45a7Smrg    {
61786aec45a7Smrg      str += len - patlen;
6179300bf1aeSmrg      if (STREQ (str, pat))
61806aec45a7Smrg	*str = '\0';
61816aec45a7Smrg    }
61826aec45a7Smrg  return str;
61836aec45a7Smrg}
6184ab47cfaaSmrg
61856aec45a7Smrgvoid
61866aec45a7Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
61876aec45a7Smrg{
61886aec45a7Smrg  va_list args;
61896aec45a7Smrg  if (lt_debug)
61906aec45a7Smrg    {
61916aec45a7Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
61926aec45a7Smrg      va_start (args, fmt);
61936aec45a7Smrg      (void) vfprintf (stderr, fmt, args);
61946aec45a7Smrg      va_end (args);
61956aec45a7Smrg    }
61966aec45a7Smrg}
6197ab47cfaaSmrg
61986aec45a7Smrgstatic void
61996aec45a7Smrglt_error_core (int exit_status, const char *file,
62006aec45a7Smrg	       int line, const char *mode,
62016aec45a7Smrg	       const char *message, va_list ap)
62026aec45a7Smrg{
62036aec45a7Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
62046aec45a7Smrg  vfprintf (stderr, message, ap);
62056aec45a7Smrg  fprintf (stderr, ".\n");
6206ab47cfaaSmrg
62076aec45a7Smrg  if (exit_status >= 0)
62086aec45a7Smrg    exit (exit_status);
62096aec45a7Smrg}
6210ab47cfaaSmrg
62116aec45a7Smrgvoid
62126aec45a7Smrglt_fatal (const char *file, int line, const char *message, ...)
62136aec45a7Smrg{
62146aec45a7Smrg  va_list ap;
62156aec45a7Smrg  va_start (ap, message);
62166aec45a7Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
62176aec45a7Smrg  va_end (ap);
62186aec45a7Smrg}
6219ab47cfaaSmrg
62206aec45a7Smrgstatic const char *
62216aec45a7Smrgnonnull (const char *s)
62226aec45a7Smrg{
62236aec45a7Smrg  return s ? s : "(null)";
62246aec45a7Smrg}
6225ab47cfaaSmrg
62266aec45a7Smrgstatic const char *
62276aec45a7Smrgnonempty (const char *s)
62286aec45a7Smrg{
62296aec45a7Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
62306aec45a7Smrg}
6231ab47cfaaSmrg
62326aec45a7Smrgvoid
62336aec45a7Smrglt_setenv (const char *name, const char *value)
62346aec45a7Smrg{
62356aec45a7Smrg  lt_debugprintf (__FILE__, __LINE__,
62366aec45a7Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
62376aec45a7Smrg                  nonnull (name), nonnull (value));
62386aec45a7Smrg  {
62396aec45a7Smrg#ifdef HAVE_SETENV
62406aec45a7Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
62416aec45a7Smrg    char *str = xstrdup (value);
62426aec45a7Smrg    setenv (name, str, 1);
62436aec45a7Smrg#else
6244300bf1aeSmrg    size_t len = strlen (name) + 1 + strlen (value) + 1;
62456aec45a7Smrg    char *str = XMALLOC (char, len);
62466aec45a7Smrg    sprintf (str, "%s=%s", name, value);
62476aec45a7Smrg    if (putenv (str) != EXIT_SUCCESS)
62486aec45a7Smrg      {
62496aec45a7Smrg        XFREE (str);
62506aec45a7Smrg      }
62516aec45a7Smrg#endif
62526aec45a7Smrg  }
62536aec45a7Smrg}
6254ab47cfaaSmrg
62556aec45a7Smrgchar *
62566aec45a7Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
62576aec45a7Smrg{
62586aec45a7Smrg  char *new_value;
62596aec45a7Smrg  if (orig_value && *orig_value)
62606aec45a7Smrg    {
6261300bf1aeSmrg      size_t orig_value_len = strlen (orig_value);
6262300bf1aeSmrg      size_t add_len = strlen (add);
62636aec45a7Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
62646aec45a7Smrg      if (to_end)
62656aec45a7Smrg        {
62666aec45a7Smrg          strcpy (new_value, orig_value);
62676aec45a7Smrg          strcpy (new_value + orig_value_len, add);
62686aec45a7Smrg        }
62696aec45a7Smrg      else
62706aec45a7Smrg        {
62716aec45a7Smrg          strcpy (new_value, add);
62726aec45a7Smrg          strcpy (new_value + add_len, orig_value);
62736aec45a7Smrg        }
62746aec45a7Smrg    }
62756aec45a7Smrg  else
62766aec45a7Smrg    {
62776aec45a7Smrg      new_value = xstrdup (add);
62786aec45a7Smrg    }
62796aec45a7Smrg  return new_value;
62806aec45a7Smrg}
6281ab47cfaaSmrg
62826aec45a7Smrgvoid
62836aec45a7Smrglt_update_exe_path (const char *name, const char *value)
62846aec45a7Smrg{
62856aec45a7Smrg  lt_debugprintf (__FILE__, __LINE__,
62866aec45a7Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
62876aec45a7Smrg                  nonnull (name), nonnull (value));
6288ab47cfaaSmrg
62896aec45a7Smrg  if (name && *name && value && *value)
62906aec45a7Smrg    {
62916aec45a7Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
62926aec45a7Smrg      /* some systems can't cope with a ':'-terminated path #' */
6293300bf1aeSmrg      size_t len = strlen (new_value);
6294300bf1aeSmrg      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
62956aec45a7Smrg        {
6296300bf1aeSmrg          new_value[--len] = '\0';
62976aec45a7Smrg        }
62986aec45a7Smrg      lt_setenv (name, new_value);
62996aec45a7Smrg      XFREE (new_value);
63006aec45a7Smrg    }
63016aec45a7Smrg}
6302ab47cfaaSmrg
63036aec45a7Smrgvoid
63046aec45a7Smrglt_update_lib_path (const char *name, const char *value)
63056aec45a7Smrg{
63066aec45a7Smrg  lt_debugprintf (__FILE__, __LINE__,
63076aec45a7Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
63086aec45a7Smrg                  nonnull (name), nonnull (value));
6309ab47cfaaSmrg
63106aec45a7Smrg  if (name && *name && value && *value)
63116aec45a7Smrg    {
63126aec45a7Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
63136aec45a7Smrg      lt_setenv (name, new_value);
63146aec45a7Smrg      XFREE (new_value);
63156aec45a7Smrg    }
63166aec45a7Smrg}
6317ab47cfaaSmrg
63186aec45a7SmrgEOF
63196aec45a7Smrg	    case $host_os in
63206aec45a7Smrg	      mingw*)
63216aec45a7Smrg		cat <<"EOF"
63226aec45a7Smrg
63236aec45a7Smrg/* Prepares an argument vector before calling spawn().
63246aec45a7Smrg   Note that spawn() does not by itself call the command interpreter
63256aec45a7Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
63266aec45a7Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
63276aec45a7Smrg         GetVersionEx(&v);
63286aec45a7Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
63296aec45a7Smrg      }) ? "cmd.exe" : "command.com").
63306aec45a7Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
63316aec45a7Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
63326aec45a7Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
63336aec45a7Smrg   special way:
63346aec45a7Smrg   - Space and tab are interpreted as delimiters. They are not treated as
63356aec45a7Smrg     delimiters if they are surrounded by double quotes: "...".
63366aec45a7Smrg   - Unescaped double quotes are removed from the input. Their only effect is
63376aec45a7Smrg     that within double quotes, space and tab are treated like normal
63386aec45a7Smrg     characters.
63396aec45a7Smrg   - Backslashes not followed by double quotes are not special.
63406aec45a7Smrg   - But 2*n+1 backslashes followed by a double quote become
63416aec45a7Smrg     n backslashes followed by a double quote (n >= 0):
63426aec45a7Smrg       \" -> "
63436aec45a7Smrg       \\\" -> \"
63446aec45a7Smrg       \\\\\" -> \\"
63456aec45a7Smrg */
63466aec45a7Smrg#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"
63476aec45a7Smrg#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"
63486aec45a7Smrgchar **
63496aec45a7Smrgprepare_spawn (char **argv)
63506aec45a7Smrg{
63516aec45a7Smrg  size_t argc;
63526aec45a7Smrg  char **new_argv;
63536aec45a7Smrg  size_t i;
6354ab47cfaaSmrg
63556aec45a7Smrg  /* Count number of arguments.  */
63566aec45a7Smrg  for (argc = 0; argv[argc] != NULL; argc++)
63576aec45a7Smrg    ;
6358ab47cfaaSmrg
63596aec45a7Smrg  /* Allocate new argument vector.  */
63606aec45a7Smrg  new_argv = XMALLOC (char *, argc + 1);
6361ab47cfaaSmrg
63626aec45a7Smrg  /* Put quoted arguments into the new argument vector.  */
63636aec45a7Smrg  for (i = 0; i < argc; i++)
63646aec45a7Smrg    {
63656aec45a7Smrg      const char *string = argv[i];
63666aec45a7Smrg
63676aec45a7Smrg      if (string[0] == '\0')
63686aec45a7Smrg	new_argv[i] = xstrdup ("\"\"");
63696aec45a7Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
63706aec45a7Smrg	{
63716aec45a7Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
63726aec45a7Smrg	  size_t length;
63736aec45a7Smrg	  unsigned int backslashes;
63746aec45a7Smrg	  const char *s;
63756aec45a7Smrg	  char *quoted_string;
63766aec45a7Smrg	  char *p;
63776aec45a7Smrg
63786aec45a7Smrg	  length = 0;
63796aec45a7Smrg	  backslashes = 0;
63806aec45a7Smrg	  if (quote_around)
63816aec45a7Smrg	    length++;
63826aec45a7Smrg	  for (s = string; *s != '\0'; s++)
63836aec45a7Smrg	    {
63846aec45a7Smrg	      char c = *s;
63856aec45a7Smrg	      if (c == '"')
63866aec45a7Smrg		length += backslashes + 1;
63876aec45a7Smrg	      length++;
63886aec45a7Smrg	      if (c == '\\')
63896aec45a7Smrg		backslashes++;
63906aec45a7Smrg	      else
63916aec45a7Smrg		backslashes = 0;
63926aec45a7Smrg	    }
63936aec45a7Smrg	  if (quote_around)
63946aec45a7Smrg	    length += backslashes + 1;
63956aec45a7Smrg
63966aec45a7Smrg	  quoted_string = XMALLOC (char, length + 1);
63976aec45a7Smrg
63986aec45a7Smrg	  p = quoted_string;
63996aec45a7Smrg	  backslashes = 0;
64006aec45a7Smrg	  if (quote_around)
64016aec45a7Smrg	    *p++ = '"';
64026aec45a7Smrg	  for (s = string; *s != '\0'; s++)
64036aec45a7Smrg	    {
64046aec45a7Smrg	      char c = *s;
64056aec45a7Smrg	      if (c == '"')
64066aec45a7Smrg		{
64076aec45a7Smrg		  unsigned int j;
64086aec45a7Smrg		  for (j = backslashes + 1; j > 0; j--)
64096aec45a7Smrg		    *p++ = '\\';
64106aec45a7Smrg		}
64116aec45a7Smrg	      *p++ = c;
64126aec45a7Smrg	      if (c == '\\')
64136aec45a7Smrg		backslashes++;
64146aec45a7Smrg	      else
64156aec45a7Smrg		backslashes = 0;
64166aec45a7Smrg	    }
64176aec45a7Smrg	  if (quote_around)
64186aec45a7Smrg	    {
64196aec45a7Smrg	      unsigned int j;
64206aec45a7Smrg	      for (j = backslashes; j > 0; j--)
64216aec45a7Smrg		*p++ = '\\';
64226aec45a7Smrg	      *p++ = '"';
64236aec45a7Smrg	    }
64246aec45a7Smrg	  *p = '\0';
6425ab47cfaaSmrg
64266aec45a7Smrg	  new_argv[i] = quoted_string;
64276aec45a7Smrg	}
64286aec45a7Smrg      else
64296aec45a7Smrg	new_argv[i] = (char *) string;
64306aec45a7Smrg    }
64316aec45a7Smrg  new_argv[argc] = NULL;
6432ab47cfaaSmrg
64336aec45a7Smrg  return new_argv;
64346aec45a7Smrg}
64356aec45a7SmrgEOF
64365c42550eSmrg		;;
64376aec45a7Smrg	    esac
6438ab47cfaaSmrg
64396aec45a7Smrg            cat <<"EOF"
64406aec45a7Smrgvoid lt_dump_script (FILE* f)
64416aec45a7Smrg{
64426aec45a7SmrgEOF
64436aec45a7Smrg	    func_emit_wrapper yes |
6444aa9e3350Smrg	      $SED -n -e '
6445aa9e3350Smrgs/^\(.\{79\}\)\(..*\)/\1\
6446aa9e3350Smrg\2/
6447aa9e3350Smrgh
6448aa9e3350Smrgs/\([\\"]\)/\\\1/g
6449aa9e3350Smrgs/$/\\n/
6450aa9e3350Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
6451aa9e3350Smrgg
6452aa9e3350SmrgD'
64536aec45a7Smrg            cat <<"EOF"
64546aec45a7Smrg}
64556aec45a7SmrgEOF
64566aec45a7Smrg}
64576aec45a7Smrg# end: func_emit_cwrapperexe_src
6458ab47cfaaSmrg
64596aec45a7Smrg# func_win32_import_lib_p ARG
64606aec45a7Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
64616aec45a7Smrgfunc_win32_import_lib_p ()
64626aec45a7Smrg{
6463300bf1aeSmrg    $debug_cmd
6464300bf1aeSmrg
64656aec45a7Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
64666aec45a7Smrg    *import*) : ;;
64676aec45a7Smrg    *) false ;;
64686aec45a7Smrg    esac
64696aec45a7Smrg}
6470ab47cfaaSmrg
6471300bf1aeSmrg# func_suncc_cstd_abi
6472300bf1aeSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
6473300bf1aeSmrg# Several compiler flags select an ABI that is incompatible with the
6474300bf1aeSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS.
6475300bf1aeSmrgfunc_suncc_cstd_abi ()
6476300bf1aeSmrg{
6477300bf1aeSmrg    $debug_cmd
6478300bf1aeSmrg
6479300bf1aeSmrg    case " $compile_command " in
6480300bf1aeSmrg    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
6481300bf1aeSmrg      suncc_use_cstd_abi=no
6482300bf1aeSmrg      ;;
6483300bf1aeSmrg    *)
6484300bf1aeSmrg      suncc_use_cstd_abi=yes
6485300bf1aeSmrg      ;;
6486300bf1aeSmrg    esac
6487300bf1aeSmrg}
6488300bf1aeSmrg
64896aec45a7Smrg# func_mode_link arg...
64906aec45a7Smrgfunc_mode_link ()
64916aec45a7Smrg{
6492300bf1aeSmrg    $debug_cmd
6493300bf1aeSmrg
64946aec45a7Smrg    case $host in
64956aec45a7Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
64966aec45a7Smrg      # It is impossible to link a dll without this setting, and
64976aec45a7Smrg      # we shouldn't force the makefile maintainer to figure out
6498300bf1aeSmrg      # what system we are compiling for in order to pass an extra
64996aec45a7Smrg      # flag for every libtool invocation.
65006aec45a7Smrg      # allow_undefined=no
6501ab47cfaaSmrg
65026aec45a7Smrg      # FIXME: Unfortunately, there are problems with the above when trying
6503300bf1aeSmrg      # to make a dll that has undefined symbols, in which case not
65046aec45a7Smrg      # even a static library is built.  For now, we need to specify
65056aec45a7Smrg      # -no-undefined on the libtool link line when we can be certain
65066aec45a7Smrg      # that all symbols are satisfied, otherwise we get a static library.
65076aec45a7Smrg      allow_undefined=yes
65086aec45a7Smrg      ;;
65096aec45a7Smrg    *)
65106aec45a7Smrg      allow_undefined=yes
65116aec45a7Smrg      ;;
65126aec45a7Smrg    esac
65136aec45a7Smrg    libtool_args=$nonopt
65146aec45a7Smrg    base_compile="$nonopt $@"
65156aec45a7Smrg    compile_command=$nonopt
65166aec45a7Smrg    finalize_command=$nonopt
6517ab47cfaaSmrg
65186aec45a7Smrg    compile_rpath=
65196aec45a7Smrg    finalize_rpath=
65206aec45a7Smrg    compile_shlibpath=
65216aec45a7Smrg    finalize_shlibpath=
65226aec45a7Smrg    convenience=
65236aec45a7Smrg    old_convenience=
65246aec45a7Smrg    deplibs=
65256aec45a7Smrg    old_deplibs=
65266aec45a7Smrg    compiler_flags=
65276aec45a7Smrg    linker_flags=
65286aec45a7Smrg    dllsearchpath=
65296aec45a7Smrg    lib_search_path=`pwd`
65306aec45a7Smrg    inst_prefix_dir=
65316aec45a7Smrg    new_inherited_linker_flags=
6532ab47cfaaSmrg
65336aec45a7Smrg    avoid_version=no
65346aec45a7Smrg    bindir=
65356aec45a7Smrg    dlfiles=
65366aec45a7Smrg    dlprefiles=
65376aec45a7Smrg    dlself=no
65386aec45a7Smrg    export_dynamic=no
65396aec45a7Smrg    export_symbols=
65406aec45a7Smrg    export_symbols_regex=
65416aec45a7Smrg    generated=
65426aec45a7Smrg    libobjs=
65436aec45a7Smrg    ltlibs=
65446aec45a7Smrg    module=no
65456aec45a7Smrg    no_install=no
65466aec45a7Smrg    objs=
6547300bf1aeSmrg    os2dllname=
65486aec45a7Smrg    non_pic_objects=
65496aec45a7Smrg    precious_files_regex=
65506aec45a7Smrg    prefer_static_libs=no
6551300bf1aeSmrg    preload=false
65526aec45a7Smrg    prev=
65536aec45a7Smrg    prevarg=
65546aec45a7Smrg    release=
65556aec45a7Smrg    rpath=
65566aec45a7Smrg    xrpath=
65576aec45a7Smrg    perm_rpath=
65586aec45a7Smrg    temp_rpath=
65596aec45a7Smrg    thread_safe=no
65606aec45a7Smrg    vinfo=
65616aec45a7Smrg    vinfo_number=no
65626aec45a7Smrg    weak_libs=
6563300bf1aeSmrg    single_module=$wl-single_module
65646aec45a7Smrg    func_infer_tag $base_compile
6565ab47cfaaSmrg
65666aec45a7Smrg    # We need to know -static, to get the right output filenames.
65676aec45a7Smrg    for arg
65686aec45a7Smrg    do
65696aec45a7Smrg      case $arg in
65706aec45a7Smrg      -shared)
6571300bf1aeSmrg	test yes != "$build_libtool_libs" \
6572300bf1aeSmrg	  && func_fatal_configuration "cannot build a shared library"
65736aec45a7Smrg	build_old_libs=no
65746aec45a7Smrg	break
65756aec45a7Smrg	;;
65766aec45a7Smrg      -all-static | -static | -static-libtool-libs)
65776aec45a7Smrg	case $arg in
65786aec45a7Smrg	-all-static)
6579300bf1aeSmrg	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
65806aec45a7Smrg	    func_warning "complete static linking is impossible in this configuration"
65816aec45a7Smrg	  fi
65826aec45a7Smrg	  if test -n "$link_static_flag"; then
65836aec45a7Smrg	    dlopen_self=$dlopen_self_static
65846aec45a7Smrg	  fi
65856aec45a7Smrg	  prefer_static_libs=yes
65866aec45a7Smrg	  ;;
65876aec45a7Smrg	-static)
65886aec45a7Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
65896aec45a7Smrg	    dlopen_self=$dlopen_self_static
65906aec45a7Smrg	  fi
65916aec45a7Smrg	  prefer_static_libs=built
65926aec45a7Smrg	  ;;
65936aec45a7Smrg	-static-libtool-libs)
65946aec45a7Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
65956aec45a7Smrg	    dlopen_self=$dlopen_self_static
65966aec45a7Smrg	  fi
65976aec45a7Smrg	  prefer_static_libs=yes
65986aec45a7Smrg	  ;;
65996aec45a7Smrg	esac
66006aec45a7Smrg	build_libtool_libs=no
66016aec45a7Smrg	build_old_libs=yes
66026aec45a7Smrg	break
66036aec45a7Smrg	;;
66046aec45a7Smrg      esac
66056aec45a7Smrg    done
6606ab47cfaaSmrg
66076aec45a7Smrg    # See if our shared archives depend on static archives.
66086aec45a7Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6609ab47cfaaSmrg
66106aec45a7Smrg    # Go through the arguments, transforming them on the way.
66116aec45a7Smrg    while test "$#" -gt 0; do
6612300bf1aeSmrg      arg=$1
66136aec45a7Smrg      shift
66146aec45a7Smrg      func_quote_for_eval "$arg"
66156aec45a7Smrg      qarg=$func_quote_for_eval_unquoted_result
66166aec45a7Smrg      func_append libtool_args " $func_quote_for_eval_result"
6617ab47cfaaSmrg
66186aec45a7Smrg      # If the previous option needs an argument, assign it.
66196aec45a7Smrg      if test -n "$prev"; then
66206aec45a7Smrg	case $prev in
66216aec45a7Smrg	output)
66226aec45a7Smrg	  func_append compile_command " @OUTPUT@"
66236aec45a7Smrg	  func_append finalize_command " @OUTPUT@"
66246aec45a7Smrg	  ;;
66256aec45a7Smrg	esac
6626ab47cfaaSmrg
66276aec45a7Smrg	case $prev in
66286aec45a7Smrg	bindir)
6629300bf1aeSmrg	  bindir=$arg
66306aec45a7Smrg	  prev=
66316aec45a7Smrg	  continue
66326aec45a7Smrg	  ;;
66336aec45a7Smrg	dlfiles|dlprefiles)
6634300bf1aeSmrg	  $preload || {
66356aec45a7Smrg	    # Add the symbol object into the linking commands.
66366aec45a7Smrg	    func_append compile_command " @SYMFILE@"
66376aec45a7Smrg	    func_append finalize_command " @SYMFILE@"
6638300bf1aeSmrg	    preload=:
6639300bf1aeSmrg	  }
66406aec45a7Smrg	  case $arg in
66416aec45a7Smrg	  *.la | *.lo) ;;  # We handle these cases below.
66426aec45a7Smrg	  force)
6643300bf1aeSmrg	    if test no = "$dlself"; then
66446aec45a7Smrg	      dlself=needless
66456aec45a7Smrg	      export_dynamic=yes
66465c42550eSmrg	    fi
66476aec45a7Smrg	    prev=
66486aec45a7Smrg	    continue
66496aec45a7Smrg	    ;;
66506aec45a7Smrg	  self)
6651300bf1aeSmrg	    if test dlprefiles = "$prev"; then
66526aec45a7Smrg	      dlself=yes
6653300bf1aeSmrg	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
66546aec45a7Smrg	      dlself=yes
66555c42550eSmrg	    else
66566aec45a7Smrg	      dlself=needless
66576aec45a7Smrg	      export_dynamic=yes
66585c42550eSmrg	    fi
66596aec45a7Smrg	    prev=
66606aec45a7Smrg	    continue
66616aec45a7Smrg	    ;;
66626aec45a7Smrg	  *)
6663300bf1aeSmrg	    if test dlfiles = "$prev"; then
6664aa9e3350Smrg	      func_append dlfiles " $arg"
66655c42550eSmrg	    else
6666aa9e3350Smrg	      func_append dlprefiles " $arg"
66675c42550eSmrg	    fi
66686aec45a7Smrg	    prev=
66696aec45a7Smrg	    continue
66706aec45a7Smrg	    ;;
66716aec45a7Smrg	  esac
66726aec45a7Smrg	  ;;
66736aec45a7Smrg	expsyms)
6674300bf1aeSmrg	  export_symbols=$arg
66756aec45a7Smrg	  test -f "$arg" \
6676300bf1aeSmrg	    || func_fatal_error "symbol file '$arg' does not exist"
66776aec45a7Smrg	  prev=
66786aec45a7Smrg	  continue
66796aec45a7Smrg	  ;;
66806aec45a7Smrg	expsyms_regex)
6681300bf1aeSmrg	  export_symbols_regex=$arg
66826aec45a7Smrg	  prev=
66836aec45a7Smrg	  continue
66846aec45a7Smrg	  ;;
66856aec45a7Smrg	framework)
66865c42550eSmrg	  case $host in
66876aec45a7Smrg	    *-*-darwin*)
66886aec45a7Smrg	      case "$deplibs " in
66896aec45a7Smrg		*" $qarg.ltframework "*) ;;
6690aa9e3350Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
66916aec45a7Smrg		   ;;
66926aec45a7Smrg	      esac
66936aec45a7Smrg	      ;;
66945c42550eSmrg	  esac
66956aec45a7Smrg	  prev=
66966aec45a7Smrg	  continue
66975c42550eSmrg	  ;;
66986aec45a7Smrg	inst_prefix)
6699300bf1aeSmrg	  inst_prefix_dir=$arg
6700300bf1aeSmrg	  prev=
6701300bf1aeSmrg	  continue
6702300bf1aeSmrg	  ;;
6703300bf1aeSmrg	mllvm)
6704300bf1aeSmrg	  # Clang does not use LLVM to link, so we can simply discard any
6705300bf1aeSmrg	  # '-mllvm $arg' options when doing the link step.
67066aec45a7Smrg	  prev=
67076aec45a7Smrg	  continue
67085c42550eSmrg	  ;;
67096aec45a7Smrg	objectlist)
67106aec45a7Smrg	  if test -f "$arg"; then
67116aec45a7Smrg	    save_arg=$arg
67126aec45a7Smrg	    moreargs=
67136aec45a7Smrg	    for fil in `cat "$save_arg"`
67146aec45a7Smrg	    do
6715aa9e3350Smrg#	      func_append moreargs " $fil"
67166aec45a7Smrg	      arg=$fil
67176aec45a7Smrg	      # A libtool-controlled object.
6718ab47cfaaSmrg
67196aec45a7Smrg	      # Check to see that this really is a libtool object.
67206aec45a7Smrg	      if func_lalib_unsafe_p "$arg"; then
67216aec45a7Smrg		pic_object=
67226aec45a7Smrg		non_pic_object=
6723ab47cfaaSmrg
67246aec45a7Smrg		# Read the .lo file
67256aec45a7Smrg		func_source "$arg"
6726ab47cfaaSmrg
67276aec45a7Smrg		if test -z "$pic_object" ||
67286aec45a7Smrg		   test -z "$non_pic_object" ||
6729300bf1aeSmrg		   test none = "$pic_object" &&
6730300bf1aeSmrg		   test none = "$non_pic_object"; then
6731300bf1aeSmrg		  func_fatal_error "cannot find name of object for '$arg'"
67326aec45a7Smrg		fi
6733ab47cfaaSmrg
67346aec45a7Smrg		# Extract subdirectory from the argument.
67356aec45a7Smrg		func_dirname "$arg" "/" ""
6736300bf1aeSmrg		xdir=$func_dirname_result
6737ab47cfaaSmrg
6738300bf1aeSmrg		if test none != "$pic_object"; then
67396aec45a7Smrg		  # Prepend the subdirectory the object is found in.
6740300bf1aeSmrg		  pic_object=$xdir$pic_object
6741ab47cfaaSmrg
6742300bf1aeSmrg		  if test dlfiles = "$prev"; then
6743300bf1aeSmrg		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6744aa9e3350Smrg		      func_append dlfiles " $pic_object"
67456aec45a7Smrg		      prev=
67466aec45a7Smrg		      continue
67476aec45a7Smrg		    else
67486aec45a7Smrg		      # If libtool objects are unsupported, then we need to preload.
67496aec45a7Smrg		      prev=dlprefiles
67506aec45a7Smrg		    fi
67516aec45a7Smrg		  fi
67528697ee19Smrg
67536aec45a7Smrg		  # CHECK ME:  I think I busted this.  -Ossama
6754300bf1aeSmrg		  if test dlprefiles = "$prev"; then
67556aec45a7Smrg		    # Preload the old-style object.
6756aa9e3350Smrg		    func_append dlprefiles " $pic_object"
67576aec45a7Smrg		    prev=
67586aec45a7Smrg		  fi
6759ab47cfaaSmrg
67606aec45a7Smrg		  # A PIC object.
67616aec45a7Smrg		  func_append libobjs " $pic_object"
6762300bf1aeSmrg		  arg=$pic_object
67636aec45a7Smrg		fi
67641473d951Smrg
67656aec45a7Smrg		# Non-PIC object.
6766300bf1aeSmrg		if test none != "$non_pic_object"; then
67676aec45a7Smrg		  # Prepend the subdirectory the object is found in.
6768300bf1aeSmrg		  non_pic_object=$xdir$non_pic_object
67691473d951Smrg
67706aec45a7Smrg		  # A standard non-PIC object
67716aec45a7Smrg		  func_append non_pic_objects " $non_pic_object"
6772300bf1aeSmrg		  if test -z "$pic_object" || test none = "$pic_object"; then
6773300bf1aeSmrg		    arg=$non_pic_object
67746aec45a7Smrg		  fi
67756aec45a7Smrg		else
67766aec45a7Smrg		  # If the PIC object exists, use it instead.
67776aec45a7Smrg		  # $xdir was prepended to $pic_object above.
6778300bf1aeSmrg		  non_pic_object=$pic_object
67796aec45a7Smrg		  func_append non_pic_objects " $non_pic_object"
67806aec45a7Smrg		fi
67816aec45a7Smrg	      else
67826aec45a7Smrg		# Only an error if not doing a dry-run.
67836aec45a7Smrg		if $opt_dry_run; then
67846aec45a7Smrg		  # Extract subdirectory from the argument.
67856aec45a7Smrg		  func_dirname "$arg" "/" ""
6786300bf1aeSmrg		  xdir=$func_dirname_result
67876aec45a7Smrg
67886aec45a7Smrg		  func_lo2o "$arg"
67896aec45a7Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
67906aec45a7Smrg		  non_pic_object=$xdir$func_lo2o_result
67916aec45a7Smrg		  func_append libobjs " $pic_object"
67926aec45a7Smrg		  func_append non_pic_objects " $non_pic_object"
67936aec45a7Smrg	        else
6794300bf1aeSmrg		  func_fatal_error "'$arg' is not a valid libtool object"
67956aec45a7Smrg		fi
67966aec45a7Smrg	      fi
67976aec45a7Smrg	    done
67985c42550eSmrg	  else
6799300bf1aeSmrg	    func_fatal_error "link input file '$arg' does not exist"
68005c42550eSmrg	  fi
68016aec45a7Smrg	  arg=$save_arg
68026aec45a7Smrg	  prev=
68036aec45a7Smrg	  continue
68046aec45a7Smrg	  ;;
6805300bf1aeSmrg	os2dllname)
6806300bf1aeSmrg	  os2dllname=$arg
6807300bf1aeSmrg	  prev=
6808300bf1aeSmrg	  continue
6809300bf1aeSmrg	  ;;
68106aec45a7Smrg	precious_regex)
6811300bf1aeSmrg	  precious_files_regex=$arg
68126aec45a7Smrg	  prev=
68136aec45a7Smrg	  continue
68146aec45a7Smrg	  ;;
68156aec45a7Smrg	release)
6816300bf1aeSmrg	  release=-$arg
68176aec45a7Smrg	  prev=
68186aec45a7Smrg	  continue
68196aec45a7Smrg	  ;;
68206aec45a7Smrg	rpath | xrpath)
68216aec45a7Smrg	  # We need an absolute path.
68226aec45a7Smrg	  case $arg in
68236aec45a7Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
68246aec45a7Smrg	  *)
68256aec45a7Smrg	    func_fatal_error "only absolute run-paths are allowed"
68266aec45a7Smrg	    ;;
68276aec45a7Smrg	  esac
6828300bf1aeSmrg	  if test rpath = "$prev"; then
68296aec45a7Smrg	    case "$rpath " in
68306aec45a7Smrg	    *" $arg "*) ;;
6831aa9e3350Smrg	    *) func_append rpath " $arg" ;;
68326aec45a7Smrg	    esac
68335c42550eSmrg	  else
68346aec45a7Smrg	    case "$xrpath " in
68356aec45a7Smrg	    *" $arg "*) ;;
6836aa9e3350Smrg	    *) func_append xrpath " $arg" ;;
68376aec45a7Smrg	    esac
68385c42550eSmrg	  fi
68396aec45a7Smrg	  prev=
68406aec45a7Smrg	  continue
68416aec45a7Smrg	  ;;
68426aec45a7Smrg	shrext)
6843300bf1aeSmrg	  shrext_cmds=$arg
68446aec45a7Smrg	  prev=
68456aec45a7Smrg	  continue
68466aec45a7Smrg	  ;;
68476aec45a7Smrg	weak)
6848aa9e3350Smrg	  func_append weak_libs " $arg"
68496aec45a7Smrg	  prev=
68506aec45a7Smrg	  continue
68516aec45a7Smrg	  ;;
68526aec45a7Smrg	xcclinker)
6853aa9e3350Smrg	  func_append linker_flags " $qarg"
6854aa9e3350Smrg	  func_append compiler_flags " $qarg"
68556aec45a7Smrg	  prev=
68566aec45a7Smrg	  func_append compile_command " $qarg"
68576aec45a7Smrg	  func_append finalize_command " $qarg"
68586aec45a7Smrg	  continue
68596aec45a7Smrg	  ;;
68606aec45a7Smrg	xcompiler)
6861aa9e3350Smrg	  func_append compiler_flags " $qarg"
68626aec45a7Smrg	  prev=
68636aec45a7Smrg	  func_append compile_command " $qarg"
68646aec45a7Smrg	  func_append finalize_command " $qarg"
68656aec45a7Smrg	  continue
68666aec45a7Smrg	  ;;
68676aec45a7Smrg	xlinker)
6868aa9e3350Smrg	  func_append linker_flags " $qarg"
6869aa9e3350Smrg	  func_append compiler_flags " $wl$qarg"
68706aec45a7Smrg	  prev=
68716aec45a7Smrg	  func_append compile_command " $wl$qarg"
68726aec45a7Smrg	  func_append finalize_command " $wl$qarg"
68736aec45a7Smrg	  continue
68746aec45a7Smrg	  ;;
68756aec45a7Smrg	*)
68766aec45a7Smrg	  eval "$prev=\"\$arg\""
68776aec45a7Smrg	  prev=
68786aec45a7Smrg	  continue
68796aec45a7Smrg	  ;;
68801473d951Smrg	esac
68816aec45a7Smrg      fi # test -n "$prev"
68821473d951Smrg
6883300bf1aeSmrg      prevarg=$arg
68841473d951Smrg
68856aec45a7Smrg      case $arg in
68866aec45a7Smrg      -all-static)
68876aec45a7Smrg	if test -n "$link_static_flag"; then
68886aec45a7Smrg	  # See comment for -static flag below, for more details.
68896aec45a7Smrg	  func_append compile_command " $link_static_flag"
68906aec45a7Smrg	  func_append finalize_command " $link_static_flag"
68916aec45a7Smrg	fi
68926aec45a7Smrg	continue
68936aec45a7Smrg	;;
68941473d951Smrg
68956aec45a7Smrg      -allow-undefined)
68966aec45a7Smrg	# FIXME: remove this flag sometime in the future.
6897300bf1aeSmrg	func_fatal_error "'-allow-undefined' must not be used because it is the default"
68986aec45a7Smrg	;;
68991473d951Smrg
69006aec45a7Smrg      -avoid-version)
69016aec45a7Smrg	avoid_version=yes
69026aec45a7Smrg	continue
69036aec45a7Smrg	;;
69041473d951Smrg
69056aec45a7Smrg      -bindir)
69066aec45a7Smrg	prev=bindir
69076aec45a7Smrg	continue
69086aec45a7Smrg	;;
69091473d951Smrg
69106aec45a7Smrg      -dlopen)
69116aec45a7Smrg	prev=dlfiles
69126aec45a7Smrg	continue
69136aec45a7Smrg	;;
69141473d951Smrg
69156aec45a7Smrg      -dlpreopen)
69166aec45a7Smrg	prev=dlprefiles
69176aec45a7Smrg	continue
69186aec45a7Smrg	;;
69191473d951Smrg
69206aec45a7Smrg      -export-dynamic)
69216aec45a7Smrg	export_dynamic=yes
69226aec45a7Smrg	continue
69236aec45a7Smrg	;;
69241473d951Smrg
69256aec45a7Smrg      -export-symbols | -export-symbols-regex)
69266aec45a7Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
69276aec45a7Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
69286aec45a7Smrg	fi
6929300bf1aeSmrg	if test X-export-symbols = "X$arg"; then
69306aec45a7Smrg	  prev=expsyms
69316aec45a7Smrg	else
69326aec45a7Smrg	  prev=expsyms_regex
69336aec45a7Smrg	fi
69346aec45a7Smrg	continue
69356aec45a7Smrg	;;
69361473d951Smrg
69376aec45a7Smrg      -framework)
69386aec45a7Smrg	prev=framework
69396aec45a7Smrg	continue
69406aec45a7Smrg	;;
69411473d951Smrg
69426aec45a7Smrg      -inst-prefix-dir)
69436aec45a7Smrg	prev=inst_prefix
69446aec45a7Smrg	continue
69456aec45a7Smrg	;;
69461473d951Smrg
69476aec45a7Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
69486aec45a7Smrg      # so, if we see these flags be careful not to treat them like -L
69496aec45a7Smrg      -L[A-Z][A-Z]*:*)
69506aec45a7Smrg	case $with_gcc/$host in
69516aec45a7Smrg	no/*-*-irix* | /*-*-irix*)
69526aec45a7Smrg	  func_append compile_command " $arg"
69536aec45a7Smrg	  func_append finalize_command " $arg"
69546aec45a7Smrg	  ;;
69556aec45a7Smrg	esac
69566aec45a7Smrg	continue
69576aec45a7Smrg	;;
69581473d951Smrg
69596aec45a7Smrg      -L*)
6960aa9e3350Smrg	func_stripname "-L" '' "$arg"
6961aa9e3350Smrg	if test -z "$func_stripname_result"; then
69626aec45a7Smrg	  if test "$#" -gt 0; then
6963300bf1aeSmrg	    func_fatal_error "require no space between '-L' and '$1'"
69646aec45a7Smrg	  else
6965300bf1aeSmrg	    func_fatal_error "need path for '-L' option"
69666aec45a7Smrg	  fi
69676aec45a7Smrg	fi
6968aa9e3350Smrg	func_resolve_sysroot "$func_stripname_result"
6969aa9e3350Smrg	dir=$func_resolve_sysroot_result
69706aec45a7Smrg	# We need an absolute path.
69716aec45a7Smrg	case $dir in
69726aec45a7Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
69736aec45a7Smrg	*)
69746aec45a7Smrg	  absdir=`cd "$dir" && pwd`
69756aec45a7Smrg	  test -z "$absdir" && \
6976300bf1aeSmrg	    func_fatal_error "cannot determine absolute directory name of '$dir'"
6977300bf1aeSmrg	  dir=$absdir
69786aec45a7Smrg	  ;;
69796aec45a7Smrg	esac
69806aec45a7Smrg	case "$deplibs " in
6981aa9e3350Smrg	*" -L$dir "* | *" $arg "*)
6982aa9e3350Smrg	  # Will only happen for absolute or sysroot arguments
6983aa9e3350Smrg	  ;;
69846aec45a7Smrg	*)
6985aa9e3350Smrg	  # Preserve sysroot, but never include relative directories
6986aa9e3350Smrg	  case $dir in
6987aa9e3350Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
6988aa9e3350Smrg	    *) func_append deplibs " -L$dir" ;;
6989aa9e3350Smrg	  esac
6990aa9e3350Smrg	  func_append lib_search_path " $dir"
69916aec45a7Smrg	  ;;
69926aec45a7Smrg	esac
69936aec45a7Smrg	case $host in
69946aec45a7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
69956aec45a7Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
69966aec45a7Smrg	  case :$dllsearchpath: in
69976aec45a7Smrg	  *":$dir:"*) ;;
69986aec45a7Smrg	  ::) dllsearchpath=$dir;;
6999aa9e3350Smrg	  *) func_append dllsearchpath ":$dir";;
70006aec45a7Smrg	  esac
70016aec45a7Smrg	  case :$dllsearchpath: in
70026aec45a7Smrg	  *":$testbindir:"*) ;;
70036aec45a7Smrg	  ::) dllsearchpath=$testbindir;;
7004aa9e3350Smrg	  *) func_append dllsearchpath ":$testbindir";;
70056aec45a7Smrg	  esac
70066aec45a7Smrg	  ;;
70076aec45a7Smrg	esac
70086aec45a7Smrg	continue
70096aec45a7Smrg	;;
70101473d951Smrg
70116aec45a7Smrg      -l*)
7012300bf1aeSmrg	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
70136aec45a7Smrg	  case $host in
70146aec45a7Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
70156aec45a7Smrg	    # These systems don't actually have a C or math library (as such)
70166aec45a7Smrg	    continue
70176aec45a7Smrg	    ;;
70186aec45a7Smrg	  *-*-os2*)
70196aec45a7Smrg	    # These systems don't actually have a C library (as such)
7020300bf1aeSmrg	    test X-lc = "X$arg" && continue
70216aec45a7Smrg	    ;;
7022300bf1aeSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
70236aec45a7Smrg	    # Do not include libc due to us having libc/libc_r.
7024300bf1aeSmrg	    test X-lc = "X$arg" && continue
70256aec45a7Smrg	    ;;
70266aec45a7Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
70276aec45a7Smrg	    # Rhapsody C and math libraries are in the System framework
7028aa9e3350Smrg	    func_append deplibs " System.ltframework"
70296aec45a7Smrg	    continue
70306aec45a7Smrg	    ;;
70316aec45a7Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
70326aec45a7Smrg	    # Causes problems with __ctype
7033300bf1aeSmrg	    test X-lc = "X$arg" && continue
70346aec45a7Smrg	    ;;
70356aec45a7Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
70366aec45a7Smrg	    # Compiler inserts libc in the correct place for threads to work
7037300bf1aeSmrg	    test X-lc = "X$arg" && continue
70386aec45a7Smrg	    ;;
70396aec45a7Smrg	  esac
7040300bf1aeSmrg	elif test X-lc_r = "X$arg"; then
70416aec45a7Smrg	 case $host in
7042300bf1aeSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
70436aec45a7Smrg	   # Do not include libc_r directly, use -pthread flag.
70446aec45a7Smrg	   continue
70456aec45a7Smrg	   ;;
70466aec45a7Smrg	 esac
70476aec45a7Smrg	fi
7048aa9e3350Smrg	func_append deplibs " $arg"
70496aec45a7Smrg	continue
70506aec45a7Smrg	;;
70511473d951Smrg
7052300bf1aeSmrg      -mllvm)
7053300bf1aeSmrg	prev=mllvm
7054300bf1aeSmrg	continue
7055300bf1aeSmrg	;;
7056300bf1aeSmrg
70576aec45a7Smrg      -module)
70586aec45a7Smrg	module=yes
70596aec45a7Smrg	continue
70606aec45a7Smrg	;;
70611473d951Smrg
70626aec45a7Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
70636aec45a7Smrg      # classes, name mangling, and exception handling.
70646aec45a7Smrg      # Darwin uses the -arch flag to determine output architecture.
7065aa9e3350Smrg      -model|-arch|-isysroot|--sysroot)
7066aa9e3350Smrg	func_append compiler_flags " $arg"
70676aec45a7Smrg	func_append compile_command " $arg"
70686aec45a7Smrg	func_append finalize_command " $arg"
70696aec45a7Smrg	prev=xcompiler
70706aec45a7Smrg	continue
70716aec45a7Smrg	;;
70721473d951Smrg
7073aa9e3350Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7074aa9e3350Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7075aa9e3350Smrg	func_append compiler_flags " $arg"
70766aec45a7Smrg	func_append compile_command " $arg"
70776aec45a7Smrg	func_append finalize_command " $arg"
70786aec45a7Smrg	case "$new_inherited_linker_flags " in
70796aec45a7Smrg	    *" $arg "*) ;;
7080aa9e3350Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
70816aec45a7Smrg	esac
70826aec45a7Smrg	continue
70836aec45a7Smrg	;;
70841473d951Smrg
70856aec45a7Smrg      -multi_module)
7086300bf1aeSmrg	single_module=$wl-multi_module
70876aec45a7Smrg	continue
70886aec45a7Smrg	;;
70891473d951Smrg
70906aec45a7Smrg      -no-fast-install)
70916aec45a7Smrg	fast_install=no
70926aec45a7Smrg	continue
70936aec45a7Smrg	;;
70941473d951Smrg
70956aec45a7Smrg      -no-install)
70966aec45a7Smrg	case $host in
70976aec45a7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
70986aec45a7Smrg	  # The PATH hackery in wrapper scripts is required on Windows
70996aec45a7Smrg	  # and Darwin in order for the loader to find any dlls it needs.
7100300bf1aeSmrg	  func_warning "'-no-install' is ignored for $host"
7101300bf1aeSmrg	  func_warning "assuming '-no-fast-install' instead"
71026aec45a7Smrg	  fast_install=no
71036aec45a7Smrg	  ;;
71046aec45a7Smrg	*) no_install=yes ;;
71056aec45a7Smrg	esac
71066aec45a7Smrg	continue
71076aec45a7Smrg	;;
71081473d951Smrg
71096aec45a7Smrg      -no-undefined)
71106aec45a7Smrg	allow_undefined=no
71116aec45a7Smrg	continue
71126aec45a7Smrg	;;
71131473d951Smrg
71146aec45a7Smrg      -objectlist)
71156aec45a7Smrg	prev=objectlist
71166aec45a7Smrg	continue
71176aec45a7Smrg	;;
71181473d951Smrg
7119300bf1aeSmrg      -os2dllname)
7120300bf1aeSmrg	prev=os2dllname
7121300bf1aeSmrg	continue
7122300bf1aeSmrg	;;
7123300bf1aeSmrg
71246aec45a7Smrg      -o) prev=output ;;
71251473d951Smrg
71266aec45a7Smrg      -precious-files-regex)
71276aec45a7Smrg	prev=precious_regex
71286aec45a7Smrg	continue
71296aec45a7Smrg	;;
71301473d951Smrg
71316aec45a7Smrg      -release)
71326aec45a7Smrg	prev=release
71336aec45a7Smrg	continue
71346aec45a7Smrg	;;
71351473d951Smrg
71366aec45a7Smrg      -rpath)
71376aec45a7Smrg	prev=rpath
71386aec45a7Smrg	continue
71396aec45a7Smrg	;;
71401473d951Smrg
71416aec45a7Smrg      -R)
71426aec45a7Smrg	prev=xrpath
71436aec45a7Smrg	continue
71446aec45a7Smrg	;;
71451473d951Smrg
71466aec45a7Smrg      -R*)
71476aec45a7Smrg	func_stripname '-R' '' "$arg"
71486aec45a7Smrg	dir=$func_stripname_result
71496aec45a7Smrg	# We need an absolute path.
71506aec45a7Smrg	case $dir in
71516aec45a7Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
7152aa9e3350Smrg	=*)
7153aa9e3350Smrg	  func_stripname '=' '' "$dir"
7154aa9e3350Smrg	  dir=$lt_sysroot$func_stripname_result
7155aa9e3350Smrg	  ;;
71566aec45a7Smrg	*)
71576aec45a7Smrg	  func_fatal_error "only absolute run-paths are allowed"
71586aec45a7Smrg	  ;;
71596aec45a7Smrg	esac
71606aec45a7Smrg	case "$xrpath " in
71616aec45a7Smrg	*" $dir "*) ;;
7162aa9e3350Smrg	*) func_append xrpath " $dir" ;;
71636aec45a7Smrg	esac
71646aec45a7Smrg	continue
71656aec45a7Smrg	;;
71661473d951Smrg
71676aec45a7Smrg      -shared)
71686aec45a7Smrg	# The effects of -shared are defined in a previous loop.
71696aec45a7Smrg	continue
71706aec45a7Smrg	;;
71711473d951Smrg
71726aec45a7Smrg      -shrext)
71736aec45a7Smrg	prev=shrext
71746aec45a7Smrg	continue
71756aec45a7Smrg	;;
71761473d951Smrg
71776aec45a7Smrg      -static | -static-libtool-libs)
71786aec45a7Smrg	# The effects of -static are defined in a previous loop.
71796aec45a7Smrg	# We used to do the same as -all-static on platforms that
71806aec45a7Smrg	# didn't have a PIC flag, but the assumption that the effects
71816aec45a7Smrg	# would be equivalent was wrong.  It would break on at least
71826aec45a7Smrg	# Digital Unix and AIX.
71836aec45a7Smrg	continue
71846aec45a7Smrg	;;
71851473d951Smrg
71866aec45a7Smrg      -thread-safe)
71876aec45a7Smrg	thread_safe=yes
71886aec45a7Smrg	continue
71896aec45a7Smrg	;;
71901473d951Smrg
71916aec45a7Smrg      -version-info)
71926aec45a7Smrg	prev=vinfo
71936aec45a7Smrg	continue
71946aec45a7Smrg	;;
71951473d951Smrg
71966aec45a7Smrg      -version-number)
71976aec45a7Smrg	prev=vinfo
71986aec45a7Smrg	vinfo_number=yes
71996aec45a7Smrg	continue
72006aec45a7Smrg	;;
7201ab47cfaaSmrg
72026aec45a7Smrg      -weak)
72036aec45a7Smrg        prev=weak
72046aec45a7Smrg	continue
72056aec45a7Smrg	;;
72065c42550eSmrg
72076aec45a7Smrg      -Wc,*)
72086aec45a7Smrg	func_stripname '-Wc,' '' "$arg"
72096aec45a7Smrg	args=$func_stripname_result
72106aec45a7Smrg	arg=
7211300bf1aeSmrg	save_ifs=$IFS; IFS=,
72126aec45a7Smrg	for flag in $args; do
7213300bf1aeSmrg	  IFS=$save_ifs
72146aec45a7Smrg          func_quote_for_eval "$flag"
7215aa9e3350Smrg	  func_append arg " $func_quote_for_eval_result"
7216aa9e3350Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
72176aec45a7Smrg	done
7218300bf1aeSmrg	IFS=$save_ifs
72196aec45a7Smrg	func_stripname ' ' '' "$arg"
72206aec45a7Smrg	arg=$func_stripname_result
72216aec45a7Smrg	;;
72225c42550eSmrg
72236aec45a7Smrg      -Wl,*)
72246aec45a7Smrg	func_stripname '-Wl,' '' "$arg"
72256aec45a7Smrg	args=$func_stripname_result
72266aec45a7Smrg	arg=
7227300bf1aeSmrg	save_ifs=$IFS; IFS=,
72286aec45a7Smrg	for flag in $args; do
7229300bf1aeSmrg	  IFS=$save_ifs
72306aec45a7Smrg          func_quote_for_eval "$flag"
7231aa9e3350Smrg	  func_append arg " $wl$func_quote_for_eval_result"
7232aa9e3350Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
7233aa9e3350Smrg	  func_append linker_flags " $func_quote_for_eval_result"
72346aec45a7Smrg	done
7235300bf1aeSmrg	IFS=$save_ifs
72366aec45a7Smrg	func_stripname ' ' '' "$arg"
72376aec45a7Smrg	arg=$func_stripname_result
72386aec45a7Smrg	;;
72395c42550eSmrg
72406aec45a7Smrg      -Xcompiler)
72416aec45a7Smrg	prev=xcompiler
72426aec45a7Smrg	continue
72436aec45a7Smrg	;;
72445c42550eSmrg
72456aec45a7Smrg      -Xlinker)
72466aec45a7Smrg	prev=xlinker
72476aec45a7Smrg	continue
72486aec45a7Smrg	;;
72495c42550eSmrg
72506aec45a7Smrg      -XCClinker)
72516aec45a7Smrg	prev=xcclinker
72526aec45a7Smrg	continue
72536aec45a7Smrg	;;
72545c42550eSmrg
72556aec45a7Smrg      # -msg_* for osf cc
72566aec45a7Smrg      -msg_*)
72576aec45a7Smrg	func_quote_for_eval "$arg"
7258300bf1aeSmrg	arg=$func_quote_for_eval_result
72596aec45a7Smrg	;;
72605c42550eSmrg
72616aec45a7Smrg      # Flags to be passed through unchanged, with rationale:
72626aec45a7Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
72636aec45a7Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
72646aec45a7Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
72656aec45a7Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
72666aec45a7Smrg      # -q*                  compiler args for the IBM compiler
72676aec45a7Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
72686aec45a7Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
72696aec45a7Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
7270300bf1aeSmrg      # -fstack-protector*   stack protector flags for GCC
72716aec45a7Smrg      # @file                GCC response files
72726aec45a7Smrg      # -tp=*                Portland pgcc target processor selection
7273aa9e3350Smrg      # --sysroot=*          for sysroot support
7274300bf1aeSmrg      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
7275300bf1aeSmrg      # -stdlib=*            select c++ std lib with clang
72766aec45a7Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7277aa9e3350Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
7278300bf1aeSmrg      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
72796aec45a7Smrg        func_quote_for_eval "$arg"
7280300bf1aeSmrg	arg=$func_quote_for_eval_result
72816aec45a7Smrg        func_append compile_command " $arg"
72826aec45a7Smrg        func_append finalize_command " $arg"
7283aa9e3350Smrg        func_append compiler_flags " $arg"
72846aec45a7Smrg        continue
72856aec45a7Smrg        ;;
72865c42550eSmrg
7287300bf1aeSmrg      -Z*)
7288300bf1aeSmrg        if test os2 = "`expr $host : '.*\(os2\)'`"; then
7289300bf1aeSmrg          # OS/2 uses -Zxxx to specify OS/2-specific options
7290300bf1aeSmrg	  compiler_flags="$compiler_flags $arg"
7291300bf1aeSmrg	  func_append compile_command " $arg"
7292300bf1aeSmrg	  func_append finalize_command " $arg"
7293300bf1aeSmrg	  case $arg in
7294300bf1aeSmrg	  -Zlinker | -Zstack)
7295300bf1aeSmrg	    prev=xcompiler
7296300bf1aeSmrg	    ;;
7297300bf1aeSmrg	  esac
7298300bf1aeSmrg	  continue
7299300bf1aeSmrg        else
7300300bf1aeSmrg	  # Otherwise treat like 'Some other compiler flag' below
7301300bf1aeSmrg	  func_quote_for_eval "$arg"
7302300bf1aeSmrg	  arg=$func_quote_for_eval_result
7303300bf1aeSmrg        fi
7304300bf1aeSmrg	;;
7305300bf1aeSmrg
73066aec45a7Smrg      # Some other compiler flag.
73076aec45a7Smrg      -* | +*)
73086aec45a7Smrg        func_quote_for_eval "$arg"
7309300bf1aeSmrg	arg=$func_quote_for_eval_result
73106aec45a7Smrg	;;
73115c42550eSmrg
73126aec45a7Smrg      *.$objext)
73136aec45a7Smrg	# A standard object.
7314aa9e3350Smrg	func_append objs " $arg"
73156aec45a7Smrg	;;
73165c42550eSmrg
73176aec45a7Smrg      *.lo)
73186aec45a7Smrg	# A libtool-controlled object.
73195c42550eSmrg
73206aec45a7Smrg	# Check to see that this really is a libtool object.
73216aec45a7Smrg	if func_lalib_unsafe_p "$arg"; then
73226aec45a7Smrg	  pic_object=
73236aec45a7Smrg	  non_pic_object=
73245c42550eSmrg
73256aec45a7Smrg	  # Read the .lo file
73266aec45a7Smrg	  func_source "$arg"
73275c42550eSmrg
73286aec45a7Smrg	  if test -z "$pic_object" ||
73296aec45a7Smrg	     test -z "$non_pic_object" ||
7330300bf1aeSmrg	     test none = "$pic_object" &&
7331300bf1aeSmrg	     test none = "$non_pic_object"; then
7332300bf1aeSmrg	    func_fatal_error "cannot find name of object for '$arg'"
73336aec45a7Smrg	  fi
73345c42550eSmrg
73356aec45a7Smrg	  # Extract subdirectory from the argument.
73366aec45a7Smrg	  func_dirname "$arg" "/" ""
7337300bf1aeSmrg	  xdir=$func_dirname_result
73385c42550eSmrg
7339300bf1aeSmrg	  test none = "$pic_object" || {
73406aec45a7Smrg	    # Prepend the subdirectory the object is found in.
7341300bf1aeSmrg	    pic_object=$xdir$pic_object
73425c42550eSmrg
7343300bf1aeSmrg	    if test dlfiles = "$prev"; then
7344300bf1aeSmrg	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7345aa9e3350Smrg		func_append dlfiles " $pic_object"
73466aec45a7Smrg		prev=
73476aec45a7Smrg		continue
73486aec45a7Smrg	      else
73496aec45a7Smrg		# If libtool objects are unsupported, then we need to preload.
73506aec45a7Smrg		prev=dlprefiles
73516aec45a7Smrg	      fi
73526aec45a7Smrg	    fi
73536aec45a7Smrg
73546aec45a7Smrg	    # CHECK ME:  I think I busted this.  -Ossama
7355300bf1aeSmrg	    if test dlprefiles = "$prev"; then
73566aec45a7Smrg	      # Preload the old-style object.
7357aa9e3350Smrg	      func_append dlprefiles " $pic_object"
73586aec45a7Smrg	      prev=
73596aec45a7Smrg	    fi
73606aec45a7Smrg
73616aec45a7Smrg	    # A PIC object.
73626aec45a7Smrg	    func_append libobjs " $pic_object"
7363300bf1aeSmrg	    arg=$pic_object
7364300bf1aeSmrg	  }
73656aec45a7Smrg
73666aec45a7Smrg	  # Non-PIC object.
7367300bf1aeSmrg	  if test none != "$non_pic_object"; then
73686aec45a7Smrg	    # Prepend the subdirectory the object is found in.
7369300bf1aeSmrg	    non_pic_object=$xdir$non_pic_object
73706aec45a7Smrg
73716aec45a7Smrg	    # A standard non-PIC object
73726aec45a7Smrg	    func_append non_pic_objects " $non_pic_object"
7373300bf1aeSmrg	    if test -z "$pic_object" || test none = "$pic_object"; then
7374300bf1aeSmrg	      arg=$non_pic_object
73756aec45a7Smrg	    fi
73766aec45a7Smrg	  else
73776aec45a7Smrg	    # If the PIC object exists, use it instead.
73786aec45a7Smrg	    # $xdir was prepended to $pic_object above.
7379300bf1aeSmrg	    non_pic_object=$pic_object
73806aec45a7Smrg	    func_append non_pic_objects " $non_pic_object"
73816aec45a7Smrg	  fi
73826aec45a7Smrg	else
73836aec45a7Smrg	  # Only an error if not doing a dry-run.
73846aec45a7Smrg	  if $opt_dry_run; then
73856aec45a7Smrg	    # Extract subdirectory from the argument.
73866aec45a7Smrg	    func_dirname "$arg" "/" ""
7387300bf1aeSmrg	    xdir=$func_dirname_result
73886aec45a7Smrg
73896aec45a7Smrg	    func_lo2o "$arg"
73906aec45a7Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
73916aec45a7Smrg	    non_pic_object=$xdir$func_lo2o_result
73926aec45a7Smrg	    func_append libobjs " $pic_object"
73936aec45a7Smrg	    func_append non_pic_objects " $non_pic_object"
73946aec45a7Smrg	  else
7395300bf1aeSmrg	    func_fatal_error "'$arg' is not a valid libtool object"
73966aec45a7Smrg	  fi
73976aec45a7Smrg	fi
73986aec45a7Smrg	;;
73996aec45a7Smrg
74006aec45a7Smrg      *.$libext)
74016aec45a7Smrg	# An archive.
7402aa9e3350Smrg	func_append deplibs " $arg"
7403aa9e3350Smrg	func_append old_deplibs " $arg"
74046aec45a7Smrg	continue
74056aec45a7Smrg	;;
74066aec45a7Smrg
74076aec45a7Smrg      *.la)
74086aec45a7Smrg	# A libtool-controlled library.
74096aec45a7Smrg
7410aa9e3350Smrg	func_resolve_sysroot "$arg"
7411300bf1aeSmrg	if test dlfiles = "$prev"; then
74126aec45a7Smrg	  # This library was specified with -dlopen.
7413aa9e3350Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
74146aec45a7Smrg	  prev=
7415300bf1aeSmrg	elif test dlprefiles = "$prev"; then
74166aec45a7Smrg	  # The library was specified with -dlpreopen.
7417aa9e3350Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
74186aec45a7Smrg	  prev=
74196aec45a7Smrg	else
7420aa9e3350Smrg	  func_append deplibs " $func_resolve_sysroot_result"
74216aec45a7Smrg	fi
74226aec45a7Smrg	continue
74236aec45a7Smrg	;;
74246aec45a7Smrg
74256aec45a7Smrg      # Some other compiler argument.
74266aec45a7Smrg      *)
74276aec45a7Smrg	# Unknown arguments in both finalize_command and compile_command need
74286aec45a7Smrg	# to be aesthetically quoted because they are evaled later.
74296aec45a7Smrg	func_quote_for_eval "$arg"
7430300bf1aeSmrg	arg=$func_quote_for_eval_result
74316aec45a7Smrg	;;
74326aec45a7Smrg      esac # arg
74336aec45a7Smrg
74346aec45a7Smrg      # Now actually substitute the argument into the commands.
74356aec45a7Smrg      if test -n "$arg"; then
74366aec45a7Smrg	func_append compile_command " $arg"
74376aec45a7Smrg	func_append finalize_command " $arg"
74386aec45a7Smrg      fi
74396aec45a7Smrg    done # argument parsing loop
74406aec45a7Smrg
74416aec45a7Smrg    test -n "$prev" && \
7442300bf1aeSmrg      func_fatal_help "the '$prevarg' option requires an argument"
74436aec45a7Smrg
7444300bf1aeSmrg    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
74456aec45a7Smrg      eval arg=\"$export_dynamic_flag_spec\"
74466aec45a7Smrg      func_append compile_command " $arg"
74476aec45a7Smrg      func_append finalize_command " $arg"
74486aec45a7Smrg    fi
74496aec45a7Smrg
74506aec45a7Smrg    oldlibs=
74516aec45a7Smrg    # calculate the name of the file, without its directory
74526aec45a7Smrg    func_basename "$output"
7453300bf1aeSmrg    outputname=$func_basename_result
7454300bf1aeSmrg    libobjs_save=$libobjs
74556aec45a7Smrg
74566aec45a7Smrg    if test -n "$shlibpath_var"; then
74576aec45a7Smrg      # get the directories listed in $shlibpath_var
7458300bf1aeSmrg      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
74595c42550eSmrg    else
74606aec45a7Smrg      shlib_search_path=
74615c42550eSmrg    fi
74626aec45a7Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
74636aec45a7Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7464ab47cfaaSmrg
7465300bf1aeSmrg    # Definition is injected by LT_CONFIG during libtool generation.
7466300bf1aeSmrg    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
7467300bf1aeSmrg
74686aec45a7Smrg    func_dirname "$output" "/" ""
7469300bf1aeSmrg    output_objdir=$func_dirname_result$objdir
7470aa9e3350Smrg    func_to_tool_file "$output_objdir/"
7471aa9e3350Smrg    tool_output_objdir=$func_to_tool_file_result
74726aec45a7Smrg    # Create the object directory.
74736aec45a7Smrg    func_mkdir_p "$output_objdir"
7474ab47cfaaSmrg
74756aec45a7Smrg    # Determine the type of output
74766aec45a7Smrg    case $output in
74776aec45a7Smrg    "")
74786aec45a7Smrg      func_fatal_help "you must specify an output file"
74796aec45a7Smrg      ;;
74806aec45a7Smrg    *.$libext) linkmode=oldlib ;;
74816aec45a7Smrg    *.lo | *.$objext) linkmode=obj ;;
74826aec45a7Smrg    *.la) linkmode=lib ;;
74836aec45a7Smrg    *) linkmode=prog ;; # Anything else should be a program.
74846aec45a7Smrg    esac
74856aec45a7Smrg
74866aec45a7Smrg    specialdeplibs=
74876aec45a7Smrg
74886aec45a7Smrg    libs=
74896aec45a7Smrg    # Find all interdependent deplibs by searching for libraries
74906aec45a7Smrg    # that are linked more than once (e.g. -la -lb -la)
74916aec45a7Smrg    for deplib in $deplibs; do
7492300bf1aeSmrg      if $opt_preserve_dup_deps; then
74936aec45a7Smrg	case "$libs " in
7494aa9e3350Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
74956aec45a7Smrg	esac
74966aec45a7Smrg      fi
7497aa9e3350Smrg      func_append libs " $deplib"
74986aec45a7Smrg    done
74996aec45a7Smrg
7500300bf1aeSmrg    if test lib = "$linkmode"; then
75016aec45a7Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
75026aec45a7Smrg
75036aec45a7Smrg      # Compute libraries that are listed more than once in $predeps
75046aec45a7Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
75056aec45a7Smrg      # not to be eliminated).
75066aec45a7Smrg      pre_post_deps=
75076aec45a7Smrg      if $opt_duplicate_compiler_generated_deps; then
75086aec45a7Smrg	for pre_post_dep in $predeps $postdeps; do
75096aec45a7Smrg	  case "$pre_post_deps " in
7510aa9e3350Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
75116aec45a7Smrg	  esac
7512aa9e3350Smrg	  func_append pre_post_deps " $pre_post_dep"
75136aec45a7Smrg	done
75146aec45a7Smrg      fi
75156aec45a7Smrg      pre_post_deps=
75166aec45a7Smrg    fi
75176aec45a7Smrg
75186aec45a7Smrg    deplibs=
75196aec45a7Smrg    newdependency_libs=
75206aec45a7Smrg    newlib_search_path=
75216aec45a7Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
75226aec45a7Smrg    notinst_deplibs= # not-installed libtool libraries
75236aec45a7Smrg    notinst_path= # paths that contain not-installed libtool libraries
75246aec45a7Smrg
75256aec45a7Smrg    case $linkmode in
75266aec45a7Smrg    lib)
75276aec45a7Smrg	passes="conv dlpreopen link"
75286aec45a7Smrg	for file in $dlfiles $dlprefiles; do
75296aec45a7Smrg	  case $file in
75306aec45a7Smrg	  *.la) ;;
75316aec45a7Smrg	  *)
7532300bf1aeSmrg	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
75336aec45a7Smrg	    ;;
75346aec45a7Smrg	  esac
75356aec45a7Smrg	done
75366aec45a7Smrg	;;
75376aec45a7Smrg    prog)
75386aec45a7Smrg	compile_deplibs=
75396aec45a7Smrg	finalize_deplibs=
7540300bf1aeSmrg	alldeplibs=false
75416aec45a7Smrg	newdlfiles=
75426aec45a7Smrg	newdlprefiles=
75436aec45a7Smrg	passes="conv scan dlopen dlpreopen link"
75446aec45a7Smrg	;;
75456aec45a7Smrg    *)  passes="conv"
75466aec45a7Smrg	;;
75476aec45a7Smrg    esac
75486aec45a7Smrg
75496aec45a7Smrg    for pass in $passes; do
75506aec45a7Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
75516aec45a7Smrg      # so that -L comes before libs that need it for instance...
7552300bf1aeSmrg      if test lib,link = "$linkmode,$pass"; then
75536aec45a7Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
75546aec45a7Smrg	##        order, and fix it there properly
75556aec45a7Smrg        tmp_deplibs=
75566aec45a7Smrg	for deplib in $deplibs; do
75576aec45a7Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
75586aec45a7Smrg	done
7559300bf1aeSmrg	deplibs=$tmp_deplibs
75606aec45a7Smrg      fi
75616aec45a7Smrg
7562300bf1aeSmrg      if test lib,link = "$linkmode,$pass" ||
7563300bf1aeSmrg	 test prog,scan = "$linkmode,$pass"; then
7564300bf1aeSmrg	libs=$deplibs
75656aec45a7Smrg	deplibs=
75666aec45a7Smrg      fi
7567300bf1aeSmrg      if test prog = "$linkmode"; then
75686aec45a7Smrg	case $pass in
7569300bf1aeSmrg	dlopen) libs=$dlfiles ;;
7570300bf1aeSmrg	dlpreopen) libs=$dlprefiles ;;
7571300bf1aeSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
75726aec45a7Smrg	esac
75736aec45a7Smrg      fi
7574300bf1aeSmrg      if test lib,dlpreopen = "$linkmode,$pass"; then
75756aec45a7Smrg	# Collect and forward deplibs of preopened libtool libs
75766aec45a7Smrg	for lib in $dlprefiles; do
75776aec45a7Smrg	  # Ignore non-libtool-libs
75786aec45a7Smrg	  dependency_libs=
7579aa9e3350Smrg	  func_resolve_sysroot "$lib"
75806aec45a7Smrg	  case $lib in
7581aa9e3350Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
75826aec45a7Smrg	  esac
75836aec45a7Smrg
75846aec45a7Smrg	  # Collect preopened libtool deplibs, except any this library
75856aec45a7Smrg	  # has declared as weak libs
75866aec45a7Smrg	  for deplib in $dependency_libs; do
75876aec45a7Smrg	    func_basename "$deplib"
75886aec45a7Smrg            deplib_base=$func_basename_result
75896aec45a7Smrg	    case " $weak_libs " in
75906aec45a7Smrg	    *" $deplib_base "*) ;;
7591aa9e3350Smrg	    *) func_append deplibs " $deplib" ;;
75926aec45a7Smrg	    esac
75936aec45a7Smrg	  done
75946aec45a7Smrg	done
7595300bf1aeSmrg	libs=$dlprefiles
75966aec45a7Smrg      fi
7597300bf1aeSmrg      if test dlopen = "$pass"; then
75986aec45a7Smrg	# Collect dlpreopened libraries
7599300bf1aeSmrg	save_deplibs=$deplibs
76006aec45a7Smrg	deplibs=
76016aec45a7Smrg      fi
76026aec45a7Smrg
76036aec45a7Smrg      for deplib in $libs; do
76046aec45a7Smrg	lib=
7605300bf1aeSmrg	found=false
76066aec45a7Smrg	case $deplib in
7607aa9e3350Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7608aa9e3350Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7609300bf1aeSmrg	  if test prog,link = "$linkmode,$pass"; then
76106aec45a7Smrg	    compile_deplibs="$deplib $compile_deplibs"
76116aec45a7Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
76126aec45a7Smrg	  else
7613aa9e3350Smrg	    func_append compiler_flags " $deplib"
7614300bf1aeSmrg	    if test lib = "$linkmode"; then
76156aec45a7Smrg		case "$new_inherited_linker_flags " in
76166aec45a7Smrg		    *" $deplib "*) ;;
7617aa9e3350Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
76186aec45a7Smrg		esac
76196aec45a7Smrg	    fi
76206aec45a7Smrg	  fi
76216aec45a7Smrg	  continue
76226aec45a7Smrg	  ;;
76236aec45a7Smrg	-l*)
7624300bf1aeSmrg	  if test lib != "$linkmode" && test prog != "$linkmode"; then
7625300bf1aeSmrg	    func_warning "'-l' is ignored for archives/objects"
76266aec45a7Smrg	    continue
76276aec45a7Smrg	  fi
76286aec45a7Smrg	  func_stripname '-l' '' "$deplib"
76296aec45a7Smrg	  name=$func_stripname_result
7630300bf1aeSmrg	  if test lib = "$linkmode"; then
76316aec45a7Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
76326aec45a7Smrg	  else
76336aec45a7Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
76346aec45a7Smrg	  fi
76356aec45a7Smrg	  for searchdir in $searchdirs; do
76366aec45a7Smrg	    for search_ext in .la $std_shrext .so .a; do
76376aec45a7Smrg	      # Search the libtool library
7638300bf1aeSmrg	      lib=$searchdir/lib$name$search_ext
76396aec45a7Smrg	      if test -f "$lib"; then
7640300bf1aeSmrg		if test .la = "$search_ext"; then
7641300bf1aeSmrg		  found=:
76426aec45a7Smrg		else
7643300bf1aeSmrg		  found=false
76446aec45a7Smrg		fi
76456aec45a7Smrg		break 2
76466aec45a7Smrg	      fi
76476aec45a7Smrg	    done
76486aec45a7Smrg	  done
7649300bf1aeSmrg	  if $found; then
7650300bf1aeSmrg	    # deplib is a libtool library
76516aec45a7Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
76526aec45a7Smrg	    # We need to do some special things here, and not later.
7653300bf1aeSmrg	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
76546aec45a7Smrg	      case " $predeps $postdeps " in
76556aec45a7Smrg	      *" $deplib "*)
76566aec45a7Smrg		if func_lalib_p "$lib"; then
76576aec45a7Smrg		  library_names=
76586aec45a7Smrg		  old_library=
76596aec45a7Smrg		  func_source "$lib"
76606aec45a7Smrg		  for l in $old_library $library_names; do
7661300bf1aeSmrg		    ll=$l
76626aec45a7Smrg		  done
7663300bf1aeSmrg		  if test "X$ll" = "X$old_library"; then # only static version available
7664300bf1aeSmrg		    found=false
76656aec45a7Smrg		    func_dirname "$lib" "" "."
7666300bf1aeSmrg		    ladir=$func_dirname_result
76676aec45a7Smrg		    lib=$ladir/$old_library
7668300bf1aeSmrg		    if test prog,link = "$linkmode,$pass"; then
76696aec45a7Smrg		      compile_deplibs="$deplib $compile_deplibs"
76706aec45a7Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
76716aec45a7Smrg		    else
76726aec45a7Smrg		      deplibs="$deplib $deplibs"
7673300bf1aeSmrg		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
76746aec45a7Smrg		    fi
76756aec45a7Smrg		    continue
76766aec45a7Smrg		  fi
76776aec45a7Smrg		fi
76786aec45a7Smrg		;;
76796aec45a7Smrg	      *) ;;
76806aec45a7Smrg	      esac
76816aec45a7Smrg	    fi
7682300bf1aeSmrg	  else
7683300bf1aeSmrg	    # deplib doesn't seem to be a libtool library
7684300bf1aeSmrg	    if test prog,link = "$linkmode,$pass"; then
7685300bf1aeSmrg	      compile_deplibs="$deplib $compile_deplibs"
7686300bf1aeSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
7687300bf1aeSmrg	    else
7688300bf1aeSmrg	      deplibs="$deplib $deplibs"
7689300bf1aeSmrg	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7690300bf1aeSmrg	    fi
7691300bf1aeSmrg	    continue
76926aec45a7Smrg	  fi
76936aec45a7Smrg	  ;; # -l
76946aec45a7Smrg	*.ltframework)
7695300bf1aeSmrg	  if test prog,link = "$linkmode,$pass"; then
76966aec45a7Smrg	    compile_deplibs="$deplib $compile_deplibs"
76976aec45a7Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
76986aec45a7Smrg	  else
76996aec45a7Smrg	    deplibs="$deplib $deplibs"
7700300bf1aeSmrg	    if test lib = "$linkmode"; then
77016aec45a7Smrg		case "$new_inherited_linker_flags " in
77026aec45a7Smrg		    *" $deplib "*) ;;
7703aa9e3350Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
77046aec45a7Smrg		esac
77056aec45a7Smrg	    fi
77066aec45a7Smrg	  fi
77076aec45a7Smrg	  continue
77086aec45a7Smrg	  ;;
77096aec45a7Smrg	-L*)
77106aec45a7Smrg	  case $linkmode in
77116aec45a7Smrg	  lib)
77126aec45a7Smrg	    deplibs="$deplib $deplibs"
7713300bf1aeSmrg	    test conv = "$pass" && continue
77146aec45a7Smrg	    newdependency_libs="$deplib $newdependency_libs"
77156aec45a7Smrg	    func_stripname '-L' '' "$deplib"
7716aa9e3350Smrg	    func_resolve_sysroot "$func_stripname_result"
7717aa9e3350Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
77186aec45a7Smrg	    ;;
77196aec45a7Smrg	  prog)
7720300bf1aeSmrg	    if test conv = "$pass"; then
77216aec45a7Smrg	      deplibs="$deplib $deplibs"
77226aec45a7Smrg	      continue
77236aec45a7Smrg	    fi
7724300bf1aeSmrg	    if test scan = "$pass"; then
77256aec45a7Smrg	      deplibs="$deplib $deplibs"
77266aec45a7Smrg	    else
77276aec45a7Smrg	      compile_deplibs="$deplib $compile_deplibs"
77286aec45a7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
77296aec45a7Smrg	    fi
77306aec45a7Smrg	    func_stripname '-L' '' "$deplib"
7731aa9e3350Smrg	    func_resolve_sysroot "$func_stripname_result"
7732aa9e3350Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
77336aec45a7Smrg	    ;;
77346aec45a7Smrg	  *)
7735300bf1aeSmrg	    func_warning "'-L' is ignored for archives/objects"
77366aec45a7Smrg	    ;;
77376aec45a7Smrg	  esac # linkmode
77386aec45a7Smrg	  continue
77396aec45a7Smrg	  ;; # -L
77406aec45a7Smrg	-R*)
7741300bf1aeSmrg	  if test link = "$pass"; then
77426aec45a7Smrg	    func_stripname '-R' '' "$deplib"
7743aa9e3350Smrg	    func_resolve_sysroot "$func_stripname_result"
7744aa9e3350Smrg	    dir=$func_resolve_sysroot_result
77456aec45a7Smrg	    # Make sure the xrpath contains only unique directories.
77466aec45a7Smrg	    case "$xrpath " in
77476aec45a7Smrg	    *" $dir "*) ;;
7748aa9e3350Smrg	    *) func_append xrpath " $dir" ;;
77496aec45a7Smrg	    esac
77506aec45a7Smrg	  fi
77516aec45a7Smrg	  deplibs="$deplib $deplibs"
77526aec45a7Smrg	  continue
77536aec45a7Smrg	  ;;
7754aa9e3350Smrg	*.la)
7755aa9e3350Smrg	  func_resolve_sysroot "$deplib"
7756aa9e3350Smrg	  lib=$func_resolve_sysroot_result
7757aa9e3350Smrg	  ;;
77586aec45a7Smrg	*.$libext)
7759300bf1aeSmrg	  if test conv = "$pass"; then
77606aec45a7Smrg	    deplibs="$deplib $deplibs"
77616aec45a7Smrg	    continue
77626aec45a7Smrg	  fi
77636aec45a7Smrg	  case $linkmode in
77646aec45a7Smrg	  lib)
77656aec45a7Smrg	    # Linking convenience modules into shared libraries is allowed,
77666aec45a7Smrg	    # but linking other static libraries is non-portable.
77676aec45a7Smrg	    case " $dlpreconveniencelibs " in
77686aec45a7Smrg	    *" $deplib "*) ;;
77696aec45a7Smrg	    *)
7770300bf1aeSmrg	      valid_a_lib=false
77716aec45a7Smrg	      case $deplibs_check_method in
77726aec45a7Smrg		match_pattern*)
77736aec45a7Smrg		  set dummy $deplibs_check_method; shift
77746aec45a7Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
77756aec45a7Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
77766aec45a7Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
7777300bf1aeSmrg		    valid_a_lib=:
77786aec45a7Smrg		  fi
77796aec45a7Smrg		;;
77806aec45a7Smrg		pass_all)
7781300bf1aeSmrg		  valid_a_lib=:
77826aec45a7Smrg		;;
77836aec45a7Smrg	      esac
7784300bf1aeSmrg	      if $valid_a_lib; then
7785300bf1aeSmrg		echo
7786300bf1aeSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
7787300bf1aeSmrg		$ECHO "*** static library $deplib is not portable!"
7788300bf1aeSmrg		deplibs="$deplib $deplibs"
7789300bf1aeSmrg	      else
77906aec45a7Smrg		echo
77916aec45a7Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
77926aec45a7Smrg		echo "*** I have the capability to make that library automatically link in when"
77936aec45a7Smrg		echo "*** you link to this library.  But I can only do this if you have a"
77946aec45a7Smrg		echo "*** shared version of the library, which you do not appear to have"
77956aec45a7Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
77966aec45a7Smrg		echo "*** that it is just a static archive that I should not use here."
77976aec45a7Smrg	      fi
77986aec45a7Smrg	      ;;
77996aec45a7Smrg	    esac
78006aec45a7Smrg	    continue
78016aec45a7Smrg	    ;;
78026aec45a7Smrg	  prog)
7803300bf1aeSmrg	    if test link != "$pass"; then
78046aec45a7Smrg	      deplibs="$deplib $deplibs"
78056aec45a7Smrg	    else
78066aec45a7Smrg	      compile_deplibs="$deplib $compile_deplibs"
78076aec45a7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
78086aec45a7Smrg	    fi
78096aec45a7Smrg	    continue
78106aec45a7Smrg	    ;;
78116aec45a7Smrg	  esac # linkmode
78126aec45a7Smrg	  ;; # *.$libext
78136aec45a7Smrg	*.lo | *.$objext)
7814300bf1aeSmrg	  if test conv = "$pass"; then
78156aec45a7Smrg	    deplibs="$deplib $deplibs"
7816300bf1aeSmrg	  elif test prog = "$linkmode"; then
7817300bf1aeSmrg	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
78186aec45a7Smrg	      # If there is no dlopen support or we're linking statically,
78196aec45a7Smrg	      # we need to preload.
7820aa9e3350Smrg	      func_append newdlprefiles " $deplib"
78216aec45a7Smrg	      compile_deplibs="$deplib $compile_deplibs"
78226aec45a7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
78236aec45a7Smrg	    else
7824aa9e3350Smrg	      func_append newdlfiles " $deplib"
78256aec45a7Smrg	    fi
78266aec45a7Smrg	  fi
78276aec45a7Smrg	  continue
78286aec45a7Smrg	  ;;
78296aec45a7Smrg	%DEPLIBS%)
7830300bf1aeSmrg	  alldeplibs=:
78316aec45a7Smrg	  continue
78326aec45a7Smrg	  ;;
78336aec45a7Smrg	esac # case $deplib
78346aec45a7Smrg
7835300bf1aeSmrg	$found || test -f "$lib" \
7836300bf1aeSmrg	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
78376aec45a7Smrg
78386aec45a7Smrg	# Check to see that this really is a libtool archive.
78396aec45a7Smrg	func_lalib_unsafe_p "$lib" \
7840300bf1aeSmrg	  || func_fatal_error "'$lib' is not a valid libtool archive"
78416aec45a7Smrg
78426aec45a7Smrg	func_dirname "$lib" "" "."
7843300bf1aeSmrg	ladir=$func_dirname_result
78446aec45a7Smrg
78456aec45a7Smrg	dlname=
78466aec45a7Smrg	dlopen=
78476aec45a7Smrg	dlpreopen=
78486aec45a7Smrg	libdir=
78496aec45a7Smrg	library_names=
78506aec45a7Smrg	old_library=
78516aec45a7Smrg	inherited_linker_flags=
78526aec45a7Smrg	# If the library was installed with an old release of libtool,
78536aec45a7Smrg	# it will not redefine variables installed, or shouldnotlink
78546aec45a7Smrg	installed=yes
78556aec45a7Smrg	shouldnotlink=no
78566aec45a7Smrg	avoidtemprpath=
78576aec45a7Smrg
78586aec45a7Smrg
78596aec45a7Smrg	# Read the .la file
78606aec45a7Smrg	func_source "$lib"
78616aec45a7Smrg
78626aec45a7Smrg	# Convert "-framework foo" to "foo.ltframework"
78636aec45a7Smrg	if test -n "$inherited_linker_flags"; then
78646aec45a7Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
78656aec45a7Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
78666aec45a7Smrg	    case " $new_inherited_linker_flags " in
78676aec45a7Smrg	      *" $tmp_inherited_linker_flag "*) ;;
7868aa9e3350Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
78696aec45a7Smrg	    esac
78706aec45a7Smrg	  done
78716aec45a7Smrg	fi
78726aec45a7Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7873300bf1aeSmrg	if test lib,link = "$linkmode,$pass" ||
7874300bf1aeSmrg	   test prog,scan = "$linkmode,$pass" ||
7875300bf1aeSmrg	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7876aa9e3350Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
7877aa9e3350Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
78786aec45a7Smrg	fi
78796aec45a7Smrg
7880300bf1aeSmrg	if test conv = "$pass"; then
78816aec45a7Smrg	  # Only check for convenience libraries
78826aec45a7Smrg	  deplibs="$lib $deplibs"
78836aec45a7Smrg	  if test -z "$libdir"; then
78846aec45a7Smrg	    if test -z "$old_library"; then
7885300bf1aeSmrg	      func_fatal_error "cannot find name of link library for '$lib'"
78866aec45a7Smrg	    fi
78876aec45a7Smrg	    # It is a libtool convenience library, so add in its objects.
7888aa9e3350Smrg	    func_append convenience " $ladir/$objdir/$old_library"
7889aa9e3350Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
7890300bf1aeSmrg	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
7891300bf1aeSmrg	    func_fatal_error "'$lib' is not a convenience library"
78926aec45a7Smrg	  fi
7893300bf1aeSmrg	  tmp_libs=
7894300bf1aeSmrg	  for deplib in $dependency_libs; do
7895300bf1aeSmrg	    deplibs="$deplib $deplibs"
7896300bf1aeSmrg	    if $opt_preserve_dup_deps; then
7897300bf1aeSmrg	      case "$tmp_libs " in
7898300bf1aeSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7899300bf1aeSmrg	      esac
7900300bf1aeSmrg	    fi
7901300bf1aeSmrg	    func_append tmp_libs " $deplib"
7902300bf1aeSmrg	  done
79036aec45a7Smrg	  continue
79046aec45a7Smrg	fi # $pass = conv
79056aec45a7Smrg
79066aec45a7Smrg
79076aec45a7Smrg	# Get the name of the library we link against.
79086aec45a7Smrg	linklib=
7909aa9e3350Smrg	if test -n "$old_library" &&
7910300bf1aeSmrg	   { test yes = "$prefer_static_libs" ||
7911300bf1aeSmrg	     test built,no = "$prefer_static_libs,$installed"; }; then
7912aa9e3350Smrg	  linklib=$old_library
7913aa9e3350Smrg	else
7914aa9e3350Smrg	  for l in $old_library $library_names; do
7915300bf1aeSmrg	    linklib=$l
7916aa9e3350Smrg	  done
7917aa9e3350Smrg	fi
79186aec45a7Smrg	if test -z "$linklib"; then
7919300bf1aeSmrg	  func_fatal_error "cannot find name of link library for '$lib'"
79206aec45a7Smrg	fi
79216aec45a7Smrg
79226aec45a7Smrg	# This library was specified with -dlopen.
7923300bf1aeSmrg	if test dlopen = "$pass"; then
7924300bf1aeSmrg	  test -z "$libdir" \
7925300bf1aeSmrg	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
79266aec45a7Smrg	  if test -z "$dlname" ||
7927300bf1aeSmrg	     test yes != "$dlopen_support" ||
7928300bf1aeSmrg	     test no = "$build_libtool_libs"
7929300bf1aeSmrg	  then
79306aec45a7Smrg	    # If there is no dlname, no dlopen support or we're linking
79316aec45a7Smrg	    # statically, we need to preload.  We also need to preload any
79326aec45a7Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
79336aec45a7Smrg	    # bomb out in the load deplibs phase.
7934aa9e3350Smrg	    func_append dlprefiles " $lib $dependency_libs"
79356aec45a7Smrg	  else
7936aa9e3350Smrg	    func_append newdlfiles " $lib"
79376aec45a7Smrg	  fi
79386aec45a7Smrg	  continue
79396aec45a7Smrg	fi # $pass = dlopen
79406aec45a7Smrg
79416aec45a7Smrg	# We need an absolute path.
79426aec45a7Smrg	case $ladir in
7943300bf1aeSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
79446aec45a7Smrg	*)
79456aec45a7Smrg	  abs_ladir=`cd "$ladir" && pwd`
79466aec45a7Smrg	  if test -z "$abs_ladir"; then
7947300bf1aeSmrg	    func_warning "cannot determine absolute directory name of '$ladir'"
79486aec45a7Smrg	    func_warning "passing it literally to the linker, although it might fail"
7949300bf1aeSmrg	    abs_ladir=$ladir
79506aec45a7Smrg	  fi
79516aec45a7Smrg	  ;;
79526aec45a7Smrg	esac
79536aec45a7Smrg	func_basename "$lib"
7954300bf1aeSmrg	laname=$func_basename_result
79556aec45a7Smrg
79566aec45a7Smrg	# Find the relevant object directory and library name.
7957300bf1aeSmrg	if test yes = "$installed"; then
7958aa9e3350Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7959300bf1aeSmrg	    func_warning "library '$lib' was moved."
7960300bf1aeSmrg	    dir=$ladir
7961300bf1aeSmrg	    absdir=$abs_ladir
7962300bf1aeSmrg	    libdir=$abs_ladir
79636aec45a7Smrg	  else
7964300bf1aeSmrg	    dir=$lt_sysroot$libdir
7965300bf1aeSmrg	    absdir=$lt_sysroot$libdir
79666aec45a7Smrg	  fi
7967300bf1aeSmrg	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
79686aec45a7Smrg	else
79696aec45a7Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7970300bf1aeSmrg	    dir=$ladir
7971300bf1aeSmrg	    absdir=$abs_ladir
79726aec45a7Smrg	    # Remove this search path later
7973aa9e3350Smrg	    func_append notinst_path " $abs_ladir"
79746aec45a7Smrg	  else
7975300bf1aeSmrg	    dir=$ladir/$objdir
7976300bf1aeSmrg	    absdir=$abs_ladir/$objdir
79776aec45a7Smrg	    # Remove this search path later
7978aa9e3350Smrg	    func_append notinst_path " $abs_ladir"
79796aec45a7Smrg	  fi
79806aec45a7Smrg	fi # $installed = yes
79816aec45a7Smrg	func_stripname 'lib' '.la' "$laname"
79826aec45a7Smrg	name=$func_stripname_result
79836aec45a7Smrg
79846aec45a7Smrg	# This library was specified with -dlpreopen.
7985300bf1aeSmrg	if test dlpreopen = "$pass"; then
7986300bf1aeSmrg	  if test -z "$libdir" && test prog = "$linkmode"; then
7987300bf1aeSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
79886aec45a7Smrg	  fi
7989300bf1aeSmrg	  case $host in
7990aa9e3350Smrg	    # special handling for platforms with PE-DLLs.
7991aa9e3350Smrg	    *cygwin* | *mingw* | *cegcc* )
7992aa9e3350Smrg	      # Linker will automatically link against shared library if both
7993aa9e3350Smrg	      # static and shared are present.  Therefore, ensure we extract
7994aa9e3350Smrg	      # symbols from the import library if a shared library is present
7995aa9e3350Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
7996aa9e3350Smrg	      # this by putting the import library name into $newdlprefiles.
7997aa9e3350Smrg	      # We recover the dlopen module name by 'saving' the la file
7998aa9e3350Smrg	      # name in a special purpose variable, and (later) extracting the
7999aa9e3350Smrg	      # dlname from the la file.
8000aa9e3350Smrg	      if test -n "$dlname"; then
8001aa9e3350Smrg	        func_tr_sh "$dir/$linklib"
8002aa9e3350Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
8003aa9e3350Smrg	        func_append newdlprefiles " $dir/$linklib"
8004aa9e3350Smrg	      else
8005aa9e3350Smrg	        func_append newdlprefiles " $dir/$old_library"
8006aa9e3350Smrg	        # Keep a list of preopened convenience libraries to check
8007aa9e3350Smrg	        # that they are being used correctly in the link pass.
8008aa9e3350Smrg	        test -z "$libdir" && \
8009aa9e3350Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8010aa9e3350Smrg	      fi
8011aa9e3350Smrg	    ;;
8012aa9e3350Smrg	    * )
8013aa9e3350Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
8014aa9e3350Smrg	      # are required to link).
8015aa9e3350Smrg	      if test -n "$old_library"; then
8016aa9e3350Smrg	        func_append newdlprefiles " $dir/$old_library"
8017aa9e3350Smrg	        # Keep a list of preopened convenience libraries to check
8018aa9e3350Smrg	        # that they are being used correctly in the link pass.
8019aa9e3350Smrg	        test -z "$libdir" && \
8020aa9e3350Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
8021aa9e3350Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
8022aa9e3350Smrg	      elif test -n "$dlname"; then
8023aa9e3350Smrg	        func_append newdlprefiles " $dir/$dlname"
8024aa9e3350Smrg	      else
8025aa9e3350Smrg	        func_append newdlprefiles " $dir/$linklib"
8026aa9e3350Smrg	      fi
8027aa9e3350Smrg	    ;;
8028aa9e3350Smrg	  esac
80296aec45a7Smrg	fi # $pass = dlpreopen
80306aec45a7Smrg
80316aec45a7Smrg	if test -z "$libdir"; then
80326aec45a7Smrg	  # Link the convenience library
8033300bf1aeSmrg	  if test lib = "$linkmode"; then
80346aec45a7Smrg	    deplibs="$dir/$old_library $deplibs"
8035300bf1aeSmrg	  elif test prog,link = "$linkmode,$pass"; then
80366aec45a7Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
80376aec45a7Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
80386aec45a7Smrg	  else
80396aec45a7Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
80406aec45a7Smrg	  fi
80416aec45a7Smrg	  continue
80426aec45a7Smrg	fi
80436aec45a7Smrg
80446aec45a7Smrg
8045300bf1aeSmrg	if test prog = "$linkmode" && test link != "$pass"; then
8046aa9e3350Smrg	  func_append newlib_search_path " $ladir"
80476aec45a7Smrg	  deplibs="$lib $deplibs"
80486aec45a7Smrg
8049300bf1aeSmrg	  linkalldeplibs=false
8050300bf1aeSmrg	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
8051300bf1aeSmrg	     test no = "$build_libtool_libs"; then
8052300bf1aeSmrg	    linkalldeplibs=:
80536aec45a7Smrg	  fi
80546aec45a7Smrg
80556aec45a7Smrg	  tmp_libs=
80566aec45a7Smrg	  for deplib in $dependency_libs; do
80576aec45a7Smrg	    case $deplib in
80586aec45a7Smrg	    -L*) func_stripname '-L' '' "$deplib"
8059aa9e3350Smrg	         func_resolve_sysroot "$func_stripname_result"
8060aa9e3350Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
80616aec45a7Smrg		 ;;
80626aec45a7Smrg	    esac
80636aec45a7Smrg	    # Need to link against all dependency_libs?
8064300bf1aeSmrg	    if $linkalldeplibs; then
80656aec45a7Smrg	      deplibs="$deplib $deplibs"
80666aec45a7Smrg	    else
80676aec45a7Smrg	      # Need to hardcode shared library paths
80686aec45a7Smrg	      # or/and link against static libraries
80696aec45a7Smrg	      newdependency_libs="$deplib $newdependency_libs"
80706aec45a7Smrg	    fi
8071300bf1aeSmrg	    if $opt_preserve_dup_deps; then
80726aec45a7Smrg	      case "$tmp_libs " in
8073aa9e3350Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
80746aec45a7Smrg	      esac
80756aec45a7Smrg	    fi
8076aa9e3350Smrg	    func_append tmp_libs " $deplib"
80776aec45a7Smrg	  done # for deplib
80786aec45a7Smrg	  continue
80796aec45a7Smrg	fi # $linkmode = prog...
80806aec45a7Smrg
8081300bf1aeSmrg	if test prog,link = "$linkmode,$pass"; then
80826aec45a7Smrg	  if test -n "$library_names" &&
8083300bf1aeSmrg	     { { test no = "$prefer_static_libs" ||
8084300bf1aeSmrg	         test built,yes = "$prefer_static_libs,$installed"; } ||
80856aec45a7Smrg	       test -z "$old_library"; }; then
80866aec45a7Smrg	    # We need to hardcode the library path
8087300bf1aeSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
80886aec45a7Smrg	      # Make sure the rpath contains only unique directories.
8089300bf1aeSmrg	      case $temp_rpath: in
80906aec45a7Smrg	      *"$absdir:"*) ;;
8091aa9e3350Smrg	      *) func_append temp_rpath "$absdir:" ;;
80926aec45a7Smrg	      esac
80936aec45a7Smrg	    fi
80946aec45a7Smrg
80956aec45a7Smrg	    # Hardcode the library path.
80966aec45a7Smrg	    # Skip directories that are in the system default run-time
80976aec45a7Smrg	    # search path.
80986aec45a7Smrg	    case " $sys_lib_dlsearch_path " in
80996aec45a7Smrg	    *" $absdir "*) ;;
81006aec45a7Smrg	    *)
81016aec45a7Smrg	      case "$compile_rpath " in
81026aec45a7Smrg	      *" $absdir "*) ;;
8103aa9e3350Smrg	      *) func_append compile_rpath " $absdir" ;;
81046aec45a7Smrg	      esac
81056aec45a7Smrg	      ;;
81066aec45a7Smrg	    esac
81076aec45a7Smrg	    case " $sys_lib_dlsearch_path " in
81086aec45a7Smrg	    *" $libdir "*) ;;
81096aec45a7Smrg	    *)
81106aec45a7Smrg	      case "$finalize_rpath " in
81116aec45a7Smrg	      *" $libdir "*) ;;
8112aa9e3350Smrg	      *) func_append finalize_rpath " $libdir" ;;
81136aec45a7Smrg	      esac
81146aec45a7Smrg	      ;;
81156aec45a7Smrg	    esac
81166aec45a7Smrg	  fi # $linkmode,$pass = prog,link...
81176aec45a7Smrg
8118300bf1aeSmrg	  if $alldeplibs &&
8119300bf1aeSmrg	     { test pass_all = "$deplibs_check_method" ||
8120300bf1aeSmrg	       { test yes = "$build_libtool_libs" &&
81216aec45a7Smrg		 test -n "$library_names"; }; }; then
81226aec45a7Smrg	    # We only need to search for static libraries
81236aec45a7Smrg	    continue
81246aec45a7Smrg	  fi
81256aec45a7Smrg	fi
81266aec45a7Smrg
81276aec45a7Smrg	link_static=no # Whether the deplib will be linked statically
81286aec45a7Smrg	use_static_libs=$prefer_static_libs
8129300bf1aeSmrg	if test built = "$use_static_libs" && test yes = "$installed"; then
81306aec45a7Smrg	  use_static_libs=no
81316aec45a7Smrg	fi
81326aec45a7Smrg	if test -n "$library_names" &&
8133300bf1aeSmrg	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
81346aec45a7Smrg	  case $host in
8135300bf1aeSmrg	  *cygwin* | *mingw* | *cegcc* | *os2*)
81366aec45a7Smrg	      # No point in relinking DLLs because paths are not encoded
8137aa9e3350Smrg	      func_append notinst_deplibs " $lib"
81386aec45a7Smrg	      need_relink=no
81396aec45a7Smrg	    ;;
81406aec45a7Smrg	  *)
8141300bf1aeSmrg	    if test no = "$installed"; then
8142aa9e3350Smrg	      func_append notinst_deplibs " $lib"
81436aec45a7Smrg	      need_relink=yes
81446aec45a7Smrg	    fi
81456aec45a7Smrg	    ;;
81466aec45a7Smrg	  esac
81476aec45a7Smrg	  # This is a shared library
81486aec45a7Smrg
81496aec45a7Smrg	  # Warn about portability, can't link against -module's on some
81506aec45a7Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
8151300bf1aeSmrg	  dlopenmodule=
81526aec45a7Smrg	  for dlpremoduletest in $dlprefiles; do
81536aec45a7Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
8154300bf1aeSmrg	      dlopenmodule=$dlpremoduletest
81556aec45a7Smrg	      break
81566aec45a7Smrg	    fi
81576aec45a7Smrg	  done
8158300bf1aeSmrg	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
81596aec45a7Smrg	    echo
8160300bf1aeSmrg	    if test prog = "$linkmode"; then
81616aec45a7Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
81626aec45a7Smrg	    else
81636aec45a7Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
81646aec45a7Smrg	    fi
81656aec45a7Smrg	    $ECHO "*** $linklib is not portable!"
81666aec45a7Smrg	  fi
8167300bf1aeSmrg	  if test lib = "$linkmode" &&
8168300bf1aeSmrg	     test yes = "$hardcode_into_libs"; then
81696aec45a7Smrg	    # Hardcode the library path.
81706aec45a7Smrg	    # Skip directories that are in the system default run-time
81716aec45a7Smrg	    # search path.
81726aec45a7Smrg	    case " $sys_lib_dlsearch_path " in
81736aec45a7Smrg	    *" $absdir "*) ;;
81746aec45a7Smrg	    *)
81756aec45a7Smrg	      case "$compile_rpath " in
81766aec45a7Smrg	      *" $absdir "*) ;;
8177aa9e3350Smrg	      *) func_append compile_rpath " $absdir" ;;
81786aec45a7Smrg	      esac
81796aec45a7Smrg	      ;;
81806aec45a7Smrg	    esac
81816aec45a7Smrg	    case " $sys_lib_dlsearch_path " in
81826aec45a7Smrg	    *" $libdir "*) ;;
81836aec45a7Smrg	    *)
81846aec45a7Smrg	      case "$finalize_rpath " in
81856aec45a7Smrg	      *" $libdir "*) ;;
8186aa9e3350Smrg	      *) func_append finalize_rpath " $libdir" ;;
81876aec45a7Smrg	      esac
81886aec45a7Smrg	      ;;
81896aec45a7Smrg	    esac
81906aec45a7Smrg	  fi
81916aec45a7Smrg
81926aec45a7Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
81936aec45a7Smrg	    # figure out the soname
81946aec45a7Smrg	    set dummy $library_names
81956aec45a7Smrg	    shift
8196300bf1aeSmrg	    realname=$1
81976aec45a7Smrg	    shift
81986aec45a7Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
81996aec45a7Smrg	    # use dlname if we got it. it's perfectly good, no?
82006aec45a7Smrg	    if test -n "$dlname"; then
8201300bf1aeSmrg	      soname=$dlname
82026aec45a7Smrg	    elif test -n "$soname_spec"; then
82036aec45a7Smrg	      # bleh windows
82046aec45a7Smrg	      case $host in
8205300bf1aeSmrg	      *cygwin* | mingw* | *cegcc* | *os2*)
82066aec45a7Smrg	        func_arith $current - $age
82076aec45a7Smrg		major=$func_arith_result
8208300bf1aeSmrg		versuffix=-$major
82096aec45a7Smrg		;;
82106aec45a7Smrg	      esac
82116aec45a7Smrg	      eval soname=\"$soname_spec\"
82126aec45a7Smrg	    else
8213300bf1aeSmrg	      soname=$realname
82146aec45a7Smrg	    fi
82156aec45a7Smrg
82166aec45a7Smrg	    # Make a new name for the extract_expsyms_cmds to use
8217300bf1aeSmrg	    soroot=$soname
82186aec45a7Smrg	    func_basename "$soroot"
8219300bf1aeSmrg	    soname=$func_basename_result
82206aec45a7Smrg	    func_stripname 'lib' '.dll' "$soname"
82216aec45a7Smrg	    newlib=libimp-$func_stripname_result.a
82226aec45a7Smrg
82236aec45a7Smrg	    # If the library has no export list, then create one now
82246aec45a7Smrg	    if test -f "$output_objdir/$soname-def"; then :
82256aec45a7Smrg	    else
8226300bf1aeSmrg	      func_verbose "extracting exported symbol list from '$soname'"
82276aec45a7Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
82286aec45a7Smrg	    fi
82296aec45a7Smrg
82306aec45a7Smrg	    # Create $newlib
82316aec45a7Smrg	    if test -f "$output_objdir/$newlib"; then :; else
8232300bf1aeSmrg	      func_verbose "generating import library for '$soname'"
82336aec45a7Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
82346aec45a7Smrg	    fi
82356aec45a7Smrg	    # make sure the library variables are pointing to the new library
82366aec45a7Smrg	    dir=$output_objdir
82376aec45a7Smrg	    linklib=$newlib
82386aec45a7Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
82396aec45a7Smrg
8240300bf1aeSmrg	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
82416aec45a7Smrg	    add_shlibpath=
82426aec45a7Smrg	    add_dir=
82436aec45a7Smrg	    add=
82446aec45a7Smrg	    lib_linked=yes
82456aec45a7Smrg	    case $hardcode_action in
82466aec45a7Smrg	    immediate | unsupported)
8247300bf1aeSmrg	      if test no = "$hardcode_direct"; then
8248300bf1aeSmrg		add=$dir/$linklib
82496aec45a7Smrg		case $host in
8250300bf1aeSmrg		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
8251300bf1aeSmrg		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
82526aec45a7Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
8253300bf1aeSmrg		    *-*-unixware7*) add_dir=-L$dir ;;
82546aec45a7Smrg		  *-*-darwin* )
8255300bf1aeSmrg		    # if the lib is a (non-dlopened) module then we cannot
82566aec45a7Smrg		    # link against it, someone is ignoring the earlier warnings
82576aec45a7Smrg		    if /usr/bin/file -L $add 2> /dev/null |
8258300bf1aeSmrg			 $GREP ": [^:]* bundle" >/dev/null; then
82596aec45a7Smrg		      if test "X$dlopenmodule" != "X$lib"; then
82606aec45a7Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
8261300bf1aeSmrg			if test -z "$old_library"; then
82626aec45a7Smrg			  echo
82636aec45a7Smrg			  echo "*** And there doesn't seem to be a static archive available"
82646aec45a7Smrg			  echo "*** The link will probably fail, sorry"
82656aec45a7Smrg			else
8266300bf1aeSmrg			  add=$dir/$old_library
82676aec45a7Smrg			fi
82686aec45a7Smrg		      elif test -n "$old_library"; then
8269300bf1aeSmrg			add=$dir/$old_library
82706aec45a7Smrg		      fi
82716aec45a7Smrg		    fi
82726aec45a7Smrg		esac
8273300bf1aeSmrg	      elif test no = "$hardcode_minus_L"; then
82746aec45a7Smrg		case $host in
8275300bf1aeSmrg		*-*-sunos*) add_shlibpath=$dir ;;
82766aec45a7Smrg		esac
8277300bf1aeSmrg		add_dir=-L$dir
8278300bf1aeSmrg		add=-l$name
8279300bf1aeSmrg	      elif test no = "$hardcode_shlibpath_var"; then
8280300bf1aeSmrg		add_shlibpath=$dir
8281300bf1aeSmrg		add=-l$name
82826aec45a7Smrg	      else
82836aec45a7Smrg		lib_linked=no
82846aec45a7Smrg	      fi
82856aec45a7Smrg	      ;;
82866aec45a7Smrg	    relink)
8287300bf1aeSmrg	      if test yes = "$hardcode_direct" &&
8288300bf1aeSmrg	         test no = "$hardcode_direct_absolute"; then
8289300bf1aeSmrg		add=$dir/$linklib
8290300bf1aeSmrg	      elif test yes = "$hardcode_minus_L"; then
8291300bf1aeSmrg		add_dir=-L$absdir
82926aec45a7Smrg		# Try looking first in the location we're being installed to.
82936aec45a7Smrg		if test -n "$inst_prefix_dir"; then
82946aec45a7Smrg		  case $libdir in
82956aec45a7Smrg		    [\\/]*)
8296aa9e3350Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
82976aec45a7Smrg		      ;;
82986aec45a7Smrg		  esac
82996aec45a7Smrg		fi
8300300bf1aeSmrg		add=-l$name
8301300bf1aeSmrg	      elif test yes = "$hardcode_shlibpath_var"; then
8302300bf1aeSmrg		add_shlibpath=$dir
8303300bf1aeSmrg		add=-l$name
83046aec45a7Smrg	      else
83056aec45a7Smrg		lib_linked=no
83066aec45a7Smrg	      fi
83076aec45a7Smrg	      ;;
83086aec45a7Smrg	    *) lib_linked=no ;;
83096aec45a7Smrg	    esac
83106aec45a7Smrg
8311300bf1aeSmrg	    if test yes != "$lib_linked"; then
83126aec45a7Smrg	      func_fatal_configuration "unsupported hardcode properties"
83136aec45a7Smrg	    fi
83146aec45a7Smrg
83156aec45a7Smrg	    if test -n "$add_shlibpath"; then
83166aec45a7Smrg	      case :$compile_shlibpath: in
83176aec45a7Smrg	      *":$add_shlibpath:"*) ;;
8318aa9e3350Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
83196aec45a7Smrg	      esac
83206aec45a7Smrg	    fi
8321300bf1aeSmrg	    if test prog = "$linkmode"; then
83226aec45a7Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
83236aec45a7Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
83246aec45a7Smrg	    else
83256aec45a7Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
83266aec45a7Smrg	      test -n "$add" && deplibs="$add $deplibs"
8327300bf1aeSmrg	      if test yes != "$hardcode_direct" &&
8328300bf1aeSmrg		 test yes != "$hardcode_minus_L" &&
8329300bf1aeSmrg		 test yes = "$hardcode_shlibpath_var"; then
83306aec45a7Smrg		case :$finalize_shlibpath: in
83316aec45a7Smrg		*":$libdir:"*) ;;
8332aa9e3350Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
83336aec45a7Smrg		esac
83346aec45a7Smrg	      fi
83356aec45a7Smrg	    fi
83366aec45a7Smrg	  fi
83376aec45a7Smrg
8338300bf1aeSmrg	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
83396aec45a7Smrg	    add_shlibpath=
83406aec45a7Smrg	    add_dir=
83416aec45a7Smrg	    add=
83426aec45a7Smrg	    # Finalize command for both is simple: just hardcode it.
8343300bf1aeSmrg	    if test yes = "$hardcode_direct" &&
8344300bf1aeSmrg	       test no = "$hardcode_direct_absolute"; then
8345300bf1aeSmrg	      add=$libdir/$linklib
8346300bf1aeSmrg	    elif test yes = "$hardcode_minus_L"; then
8347300bf1aeSmrg	      add_dir=-L$libdir
8348300bf1aeSmrg	      add=-l$name
8349300bf1aeSmrg	    elif test yes = "$hardcode_shlibpath_var"; then
83506aec45a7Smrg	      case :$finalize_shlibpath: in
83516aec45a7Smrg	      *":$libdir:"*) ;;
8352aa9e3350Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
83536aec45a7Smrg	      esac
8354300bf1aeSmrg	      add=-l$name
8355300bf1aeSmrg	    elif test yes = "$hardcode_automatic"; then
83566aec45a7Smrg	      if test -n "$inst_prefix_dir" &&
8357300bf1aeSmrg		 test -f "$inst_prefix_dir$libdir/$linklib"; then
8358300bf1aeSmrg		add=$inst_prefix_dir$libdir/$linklib
83596aec45a7Smrg	      else
8360300bf1aeSmrg		add=$libdir/$linklib
83616aec45a7Smrg	      fi
83626aec45a7Smrg	    else
83636aec45a7Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
8364300bf1aeSmrg	      add_dir=-L$libdir
83656aec45a7Smrg	      # Try looking first in the location we're being installed to.
83666aec45a7Smrg	      if test -n "$inst_prefix_dir"; then
83676aec45a7Smrg		case $libdir in
83686aec45a7Smrg		  [\\/]*)
8369aa9e3350Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
83706aec45a7Smrg		    ;;
83716aec45a7Smrg		esac
83726aec45a7Smrg	      fi
8373300bf1aeSmrg	      add=-l$name
83746aec45a7Smrg	    fi
83756aec45a7Smrg
8376300bf1aeSmrg	    if test prog = "$linkmode"; then
83776aec45a7Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
83786aec45a7Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
83796aec45a7Smrg	    else
83806aec45a7Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
83816aec45a7Smrg	      test -n "$add" && deplibs="$add $deplibs"
83826aec45a7Smrg	    fi
83836aec45a7Smrg	  fi
8384300bf1aeSmrg	elif test prog = "$linkmode"; then
83856aec45a7Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
83866aec45a7Smrg	  # is not unsupported.  This is valid on all known static and
83876aec45a7Smrg	  # shared platforms.
8388300bf1aeSmrg	  if test unsupported != "$hardcode_direct"; then
8389300bf1aeSmrg	    test -n "$old_library" && linklib=$old_library
83906aec45a7Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
83916aec45a7Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
83926aec45a7Smrg	  else
83936aec45a7Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
83946aec45a7Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
83956aec45a7Smrg	  fi
8396300bf1aeSmrg	elif test yes = "$build_libtool_libs"; then
83976aec45a7Smrg	  # Not a shared library
8398300bf1aeSmrg	  if test pass_all != "$deplibs_check_method"; then
83996aec45a7Smrg	    # We're trying link a shared library against a static one
84006aec45a7Smrg	    # but the system doesn't support it.
84016aec45a7Smrg
84026aec45a7Smrg	    # Just print a warning and add the library to dependency_libs so
84036aec45a7Smrg	    # that the program can be linked against the static library.
84046aec45a7Smrg	    echo
8405300bf1aeSmrg	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
84066aec45a7Smrg	    echo "*** I have the capability to make that library automatically link in when"
84076aec45a7Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
84086aec45a7Smrg	    echo "*** shared version of the library, which you do not appear to have."
8409300bf1aeSmrg	    if test yes = "$module"; then
84106aec45a7Smrg	      echo "*** But as you try to build a module library, libtool will still create "
84116aec45a7Smrg	      echo "*** a static module, that should work as long as the dlopening application"
84126aec45a7Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
84136aec45a7Smrg	      if test -z "$global_symbol_pipe"; then
84146aec45a7Smrg		echo
84156aec45a7Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
8416300bf1aeSmrg		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
84176aec45a7Smrg		echo "*** not find such a program.  So, this module is probably useless."
8418300bf1aeSmrg		echo "*** 'nm' from GNU binutils and a full rebuild may help."
84196aec45a7Smrg	      fi
8420300bf1aeSmrg	      if test no = "$build_old_libs"; then
84216aec45a7Smrg		build_libtool_libs=module
84226aec45a7Smrg		build_old_libs=yes
84236aec45a7Smrg	      else
84246aec45a7Smrg		build_libtool_libs=no
84256aec45a7Smrg	      fi
84266aec45a7Smrg	    fi
84276aec45a7Smrg	  else
84286aec45a7Smrg	    deplibs="$dir/$old_library $deplibs"
84296aec45a7Smrg	    link_static=yes
84306aec45a7Smrg	  fi
84316aec45a7Smrg	fi # link shared/static library?
84326aec45a7Smrg
8433300bf1aeSmrg	if test lib = "$linkmode"; then
84346aec45a7Smrg	  if test -n "$dependency_libs" &&
8435300bf1aeSmrg	     { test yes != "$hardcode_into_libs" ||
8436300bf1aeSmrg	       test yes = "$build_old_libs" ||
8437300bf1aeSmrg	       test yes = "$link_static"; }; then
84386aec45a7Smrg	    # Extract -R from dependency_libs
84396aec45a7Smrg	    temp_deplibs=
84406aec45a7Smrg	    for libdir in $dependency_libs; do
84416aec45a7Smrg	      case $libdir in
84426aec45a7Smrg	      -R*) func_stripname '-R' '' "$libdir"
84436aec45a7Smrg	           temp_xrpath=$func_stripname_result
84446aec45a7Smrg		   case " $xrpath " in
84456aec45a7Smrg		   *" $temp_xrpath "*) ;;
8446aa9e3350Smrg		   *) func_append xrpath " $temp_xrpath";;
84476aec45a7Smrg		   esac;;
8448aa9e3350Smrg	      *) func_append temp_deplibs " $libdir";;
84496aec45a7Smrg	      esac
84506aec45a7Smrg	    done
8451300bf1aeSmrg	    dependency_libs=$temp_deplibs
84526aec45a7Smrg	  fi
84536aec45a7Smrg
8454aa9e3350Smrg	  func_append newlib_search_path " $absdir"
84556aec45a7Smrg	  # Link against this library
8456300bf1aeSmrg	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
84576aec45a7Smrg	  # ... and its dependency_libs
84586aec45a7Smrg	  tmp_libs=
84596aec45a7Smrg	  for deplib in $dependency_libs; do
84606aec45a7Smrg	    newdependency_libs="$deplib $newdependency_libs"
8461aa9e3350Smrg	    case $deplib in
8462aa9e3350Smrg              -L*) func_stripname '-L' '' "$deplib"
8463aa9e3350Smrg                   func_resolve_sysroot "$func_stripname_result";;
8464aa9e3350Smrg              *) func_resolve_sysroot "$deplib" ;;
8465aa9e3350Smrg            esac
8466300bf1aeSmrg	    if $opt_preserve_dup_deps; then
84676aec45a7Smrg	      case "$tmp_libs " in
8468aa9e3350Smrg	      *" $func_resolve_sysroot_result "*)
8469aa9e3350Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
84706aec45a7Smrg	      esac
84716aec45a7Smrg	    fi
8472aa9e3350Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
84736aec45a7Smrg	  done
84746aec45a7Smrg
8475300bf1aeSmrg	  if test no != "$link_all_deplibs"; then
84766aec45a7Smrg	    # Add the search paths of all dependency libraries
84776aec45a7Smrg	    for deplib in $dependency_libs; do
84786aec45a7Smrg	      path=
84796aec45a7Smrg	      case $deplib in
8480300bf1aeSmrg	      -L*) path=$deplib ;;
84816aec45a7Smrg	      *.la)
8482aa9e3350Smrg	        func_resolve_sysroot "$deplib"
8483aa9e3350Smrg	        deplib=$func_resolve_sysroot_result
84846aec45a7Smrg	        func_dirname "$deplib" "" "."
8485aa9e3350Smrg		dir=$func_dirname_result
84866aec45a7Smrg		# We need an absolute path.
84876aec45a7Smrg		case $dir in
8488300bf1aeSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
84896aec45a7Smrg		*)
84906aec45a7Smrg		  absdir=`cd "$dir" && pwd`
84916aec45a7Smrg		  if test -z "$absdir"; then
8492300bf1aeSmrg		    func_warning "cannot determine absolute directory name of '$dir'"
8493300bf1aeSmrg		    absdir=$dir
84946aec45a7Smrg		  fi
84956aec45a7Smrg		  ;;
84966aec45a7Smrg		esac
84976aec45a7Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
84986aec45a7Smrg		case $host in
84996aec45a7Smrg		*-*-darwin*)
85006aec45a7Smrg		  depdepl=
8501300bf1aeSmrg		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
8502300bf1aeSmrg		  if test -n "$deplibrary_names"; then
8503300bf1aeSmrg		    for tmp in $deplibrary_names; do
85046aec45a7Smrg		      depdepl=$tmp
85056aec45a7Smrg		    done
8506300bf1aeSmrg		    if test -f "$absdir/$objdir/$depdepl"; then
8507300bf1aeSmrg		      depdepl=$absdir/$objdir/$depdepl
8508300bf1aeSmrg		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
85096aec45a7Smrg                      if test -z "$darwin_install_name"; then
8510300bf1aeSmrg                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
85116aec45a7Smrg                      fi
8512300bf1aeSmrg		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
8513300bf1aeSmrg		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
85146aec45a7Smrg		      path=
85156aec45a7Smrg		    fi
85166aec45a7Smrg		  fi
85176aec45a7Smrg		  ;;
85186aec45a7Smrg		*)
8519300bf1aeSmrg		  path=-L$absdir/$objdir
85206aec45a7Smrg		  ;;
85216aec45a7Smrg		esac
85226aec45a7Smrg		else
8523300bf1aeSmrg		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
85246aec45a7Smrg		  test -z "$libdir" && \
8525300bf1aeSmrg		    func_fatal_error "'$deplib' is not a valid libtool archive"
85266aec45a7Smrg		  test "$absdir" != "$libdir" && \
8527300bf1aeSmrg		    func_warning "'$deplib' seems to be moved"
85286aec45a7Smrg
8529300bf1aeSmrg		  path=-L$absdir
85306aec45a7Smrg		fi
85316aec45a7Smrg		;;
85326aec45a7Smrg	      esac
85336aec45a7Smrg	      case " $deplibs " in
85346aec45a7Smrg	      *" $path "*) ;;
85356aec45a7Smrg	      *) deplibs="$path $deplibs" ;;
85366aec45a7Smrg	      esac
85376aec45a7Smrg	    done
85386aec45a7Smrg	  fi # link_all_deplibs != no
85396aec45a7Smrg	fi # linkmode = lib
85406aec45a7Smrg      done # for deplib in $libs
8541300bf1aeSmrg      if test link = "$pass"; then
8542300bf1aeSmrg	if test prog = "$linkmode"; then
85436aec45a7Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
85446aec45a7Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
85456aec45a7Smrg	else
85466aec45a7Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
85476aec45a7Smrg	fi
85486aec45a7Smrg      fi
8549300bf1aeSmrg      dependency_libs=$newdependency_libs
8550300bf1aeSmrg      if test dlpreopen = "$pass"; then
85516aec45a7Smrg	# Link the dlpreopened libraries before other libraries
85526aec45a7Smrg	for deplib in $save_deplibs; do
85536aec45a7Smrg	  deplibs="$deplib $deplibs"
85546aec45a7Smrg	done
85556aec45a7Smrg      fi
8556300bf1aeSmrg      if test dlopen != "$pass"; then
8557300bf1aeSmrg	test conv = "$pass" || {
85586aec45a7Smrg	  # Make sure lib_search_path contains only unique directories.
85596aec45a7Smrg	  lib_search_path=
85606aec45a7Smrg	  for dir in $newlib_search_path; do
85616aec45a7Smrg	    case "$lib_search_path " in
85626aec45a7Smrg	    *" $dir "*) ;;
8563aa9e3350Smrg	    *) func_append lib_search_path " $dir" ;;
85646aec45a7Smrg	    esac
85656aec45a7Smrg	  done
85666aec45a7Smrg	  newlib_search_path=
8567300bf1aeSmrg	}
85686aec45a7Smrg
8569300bf1aeSmrg	if test prog,link = "$linkmode,$pass"; then
85706aec45a7Smrg	  vars="compile_deplibs finalize_deplibs"
8571300bf1aeSmrg	else
8572300bf1aeSmrg	  vars=deplibs
85736aec45a7Smrg	fi
85746aec45a7Smrg	for var in $vars dependency_libs; do
85756aec45a7Smrg	  # Add libraries to $var in reverse order
85766aec45a7Smrg	  eval tmp_libs=\"\$$var\"
85776aec45a7Smrg	  new_libs=
85786aec45a7Smrg	  for deplib in $tmp_libs; do
85796aec45a7Smrg	    # FIXME: Pedantically, this is the right thing to do, so
85806aec45a7Smrg	    #        that some nasty dependency loop isn't accidentally
85816aec45a7Smrg	    #        broken:
85826aec45a7Smrg	    #new_libs="$deplib $new_libs"
85836aec45a7Smrg	    # Pragmatically, this seems to cause very few problems in
85846aec45a7Smrg	    # practice:
85856aec45a7Smrg	    case $deplib in
85866aec45a7Smrg	    -L*) new_libs="$deplib $new_libs" ;;
85876aec45a7Smrg	    -R*) ;;
85886aec45a7Smrg	    *)
85896aec45a7Smrg	      # And here is the reason: when a library appears more
85906aec45a7Smrg	      # than once as an explicit dependence of a library, or
85916aec45a7Smrg	      # is implicitly linked in more than once by the
85926aec45a7Smrg	      # compiler, it is considered special, and multiple
85936aec45a7Smrg	      # occurrences thereof are not removed.  Compare this
85946aec45a7Smrg	      # with having the same library being listed as a
85956aec45a7Smrg	      # dependency of multiple other libraries: in this case,
85966aec45a7Smrg	      # we know (pedantically, we assume) the library does not
85976aec45a7Smrg	      # need to be listed more than once, so we keep only the
85986aec45a7Smrg	      # last copy.  This is not always right, but it is rare
85996aec45a7Smrg	      # enough that we require users that really mean to play
86006aec45a7Smrg	      # such unportable linking tricks to link the library
86016aec45a7Smrg	      # using -Wl,-lname, so that libtool does not consider it
86026aec45a7Smrg	      # for duplicate removal.
86036aec45a7Smrg	      case " $specialdeplibs " in
86046aec45a7Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
86056aec45a7Smrg	      *)
86066aec45a7Smrg		case " $new_libs " in
86076aec45a7Smrg		*" $deplib "*) ;;
86086aec45a7Smrg		*) new_libs="$deplib $new_libs" ;;
86096aec45a7Smrg		esac
86106aec45a7Smrg		;;
86116aec45a7Smrg	      esac
86126aec45a7Smrg	      ;;
86136aec45a7Smrg	    esac
86146aec45a7Smrg	  done
86156aec45a7Smrg	  tmp_libs=
86166aec45a7Smrg	  for deplib in $new_libs; do
86176aec45a7Smrg	    case $deplib in
86186aec45a7Smrg	    -L*)
86196aec45a7Smrg	      case " $tmp_libs " in
86206aec45a7Smrg	      *" $deplib "*) ;;
8621aa9e3350Smrg	      *) func_append tmp_libs " $deplib" ;;
86226aec45a7Smrg	      esac
86236aec45a7Smrg	      ;;
8624aa9e3350Smrg	    *) func_append tmp_libs " $deplib" ;;
86256aec45a7Smrg	    esac
86266aec45a7Smrg	  done
86276aec45a7Smrg	  eval $var=\"$tmp_libs\"
86286aec45a7Smrg	done # for var
86296aec45a7Smrg      fi
8630300bf1aeSmrg
8631300bf1aeSmrg      # Add Sun CC postdeps if required:
8632300bf1aeSmrg      test CXX = "$tagname" && {
8633300bf1aeSmrg        case $host_os in
8634300bf1aeSmrg        linux*)
8635300bf1aeSmrg          case `$CC -V 2>&1 | sed 5q` in
8636300bf1aeSmrg          *Sun\ C*) # Sun C++ 5.9
8637300bf1aeSmrg            func_suncc_cstd_abi
8638300bf1aeSmrg
8639300bf1aeSmrg            if test no != "$suncc_use_cstd_abi"; then
8640300bf1aeSmrg              func_append postdeps ' -library=Cstd -library=Crun'
8641300bf1aeSmrg            fi
8642300bf1aeSmrg            ;;
8643300bf1aeSmrg          esac
8644300bf1aeSmrg          ;;
8645300bf1aeSmrg
8646300bf1aeSmrg        solaris*)
8647300bf1aeSmrg          func_cc_basename "$CC"
8648300bf1aeSmrg          case $func_cc_basename_result in
8649300bf1aeSmrg          CC* | sunCC*)
8650300bf1aeSmrg            func_suncc_cstd_abi
8651300bf1aeSmrg
8652300bf1aeSmrg            if test no != "$suncc_use_cstd_abi"; then
8653300bf1aeSmrg              func_append postdeps ' -library=Cstd -library=Crun'
8654300bf1aeSmrg            fi
8655300bf1aeSmrg            ;;
8656300bf1aeSmrg          esac
8657300bf1aeSmrg          ;;
8658300bf1aeSmrg        esac
8659300bf1aeSmrg      }
8660300bf1aeSmrg
86616aec45a7Smrg      # Last step: remove runtime libs from dependency_libs
86626aec45a7Smrg      # (they stay in deplibs)
86636aec45a7Smrg      tmp_libs=
8664300bf1aeSmrg      for i in $dependency_libs; do
86656aec45a7Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
86666aec45a7Smrg	*" $i "*)
8667300bf1aeSmrg	  i=
86686aec45a7Smrg	  ;;
86696aec45a7Smrg	esac
8670300bf1aeSmrg	if test -n "$i"; then
8671aa9e3350Smrg	  func_append tmp_libs " $i"
86726aec45a7Smrg	fi
86736aec45a7Smrg      done
86746aec45a7Smrg      dependency_libs=$tmp_libs
86756aec45a7Smrg    done # for pass
8676300bf1aeSmrg    if test prog = "$linkmode"; then
8677300bf1aeSmrg      dlfiles=$newdlfiles
86786aec45a7Smrg    fi
8679300bf1aeSmrg    if test prog = "$linkmode" || test lib = "$linkmode"; then
8680300bf1aeSmrg      dlprefiles=$newdlprefiles
86816aec45a7Smrg    fi
86826aec45a7Smrg
86836aec45a7Smrg    case $linkmode in
86846aec45a7Smrg    oldlib)
8685300bf1aeSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
8686300bf1aeSmrg	func_warning "'-dlopen' is ignored for archives"
86876aec45a7Smrg      fi
86886aec45a7Smrg
86896aec45a7Smrg      case " $deplibs" in
86906aec45a7Smrg      *\ -l* | *\ -L*)
8691300bf1aeSmrg	func_warning "'-l' and '-L' are ignored for archives" ;;
86926aec45a7Smrg      esac
86936aec45a7Smrg
86946aec45a7Smrg      test -n "$rpath" && \
8695300bf1aeSmrg	func_warning "'-rpath' is ignored for archives"
86966aec45a7Smrg
86976aec45a7Smrg      test -n "$xrpath" && \
8698300bf1aeSmrg	func_warning "'-R' is ignored for archives"
86996aec45a7Smrg
87006aec45a7Smrg      test -n "$vinfo" && \
8701300bf1aeSmrg	func_warning "'-version-info/-version-number' is ignored for archives"
87026aec45a7Smrg
87036aec45a7Smrg      test -n "$release" && \
8704300bf1aeSmrg	func_warning "'-release' is ignored for archives"
87056aec45a7Smrg
87066aec45a7Smrg      test -n "$export_symbols$export_symbols_regex" && \
8707300bf1aeSmrg	func_warning "'-export-symbols' is ignored for archives"
87086aec45a7Smrg
87096aec45a7Smrg      # Now set the variables for building old libraries.
87106aec45a7Smrg      build_libtool_libs=no
8711300bf1aeSmrg      oldlibs=$output
8712aa9e3350Smrg      func_append objs "$old_deplibs"
87136aec45a7Smrg      ;;
87146aec45a7Smrg
87156aec45a7Smrg    lib)
8716300bf1aeSmrg      # Make sure we only generate libraries of the form 'libNAME.la'.
87176aec45a7Smrg      case $outputname in
87186aec45a7Smrg      lib*)
87196aec45a7Smrg	func_stripname 'lib' '.la' "$outputname"
87206aec45a7Smrg	name=$func_stripname_result
87216aec45a7Smrg	eval shared_ext=\"$shrext_cmds\"
87226aec45a7Smrg	eval libname=\"$libname_spec\"
87236aec45a7Smrg	;;
87246aec45a7Smrg      *)
8725300bf1aeSmrg	test no = "$module" \
8726300bf1aeSmrg	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
87276aec45a7Smrg
8728300bf1aeSmrg	if test no != "$need_lib_prefix"; then
87296aec45a7Smrg	  # Add the "lib" prefix for modules if required
87306aec45a7Smrg	  func_stripname '' '.la' "$outputname"
87316aec45a7Smrg	  name=$func_stripname_result
87326aec45a7Smrg	  eval shared_ext=\"$shrext_cmds\"
87336aec45a7Smrg	  eval libname=\"$libname_spec\"
87346aec45a7Smrg	else
87356aec45a7Smrg	  func_stripname '' '.la' "$outputname"
87366aec45a7Smrg	  libname=$func_stripname_result
87376aec45a7Smrg	fi
87386aec45a7Smrg	;;
87396aec45a7Smrg      esac
87406aec45a7Smrg
87416aec45a7Smrg      if test -n "$objs"; then
8742300bf1aeSmrg	if test pass_all != "$deplibs_check_method"; then
8743300bf1aeSmrg	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
87446aec45a7Smrg	else
87456aec45a7Smrg	  echo
87466aec45a7Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
87476aec45a7Smrg	  $ECHO "*** objects $objs is not portable!"
8748aa9e3350Smrg	  func_append libobjs " $objs"
87496aec45a7Smrg	fi
87506aec45a7Smrg      fi
87516aec45a7Smrg
8752300bf1aeSmrg      test no = "$dlself" \
8753300bf1aeSmrg	|| func_warning "'-dlopen self' is ignored for libtool libraries"
87546aec45a7Smrg
87556aec45a7Smrg      set dummy $rpath
87566aec45a7Smrg      shift
8757300bf1aeSmrg      test 1 -lt "$#" \
8758300bf1aeSmrg	&& func_warning "ignoring multiple '-rpath's for a libtool library"
87596aec45a7Smrg
8760300bf1aeSmrg      install_libdir=$1
87616aec45a7Smrg
87626aec45a7Smrg      oldlibs=
87636aec45a7Smrg      if test -z "$rpath"; then
8764300bf1aeSmrg	if test yes = "$build_libtool_libs"; then
87656aec45a7Smrg	  # Building a libtool convenience library.
8766300bf1aeSmrg	  # Some compilers have problems with a '.al' extension so
87676aec45a7Smrg	  # convenience libraries should have the same extension an
87686aec45a7Smrg	  # archive normally would.
87696aec45a7Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
87706aec45a7Smrg	  build_libtool_libs=convenience
87716aec45a7Smrg	  build_old_libs=yes
87726aec45a7Smrg	fi
87736aec45a7Smrg
87746aec45a7Smrg	test -n "$vinfo" && \
8775300bf1aeSmrg	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
87766aec45a7Smrg
87776aec45a7Smrg	test -n "$release" && \
8778300bf1aeSmrg	  func_warning "'-release' is ignored for convenience libraries"
87796aec45a7Smrg      else
87806aec45a7Smrg
87816aec45a7Smrg	# Parse the version information argument.
8782300bf1aeSmrg	save_ifs=$IFS; IFS=:
87836aec45a7Smrg	set dummy $vinfo 0 0 0
87846aec45a7Smrg	shift
8785300bf1aeSmrg	IFS=$save_ifs
87866aec45a7Smrg
87876aec45a7Smrg	test -n "$7" && \
8788300bf1aeSmrg	  func_fatal_help "too many parameters to '-version-info'"
87896aec45a7Smrg
87906aec45a7Smrg	# convert absolute version numbers to libtool ages
87916aec45a7Smrg	# this retains compatibility with .la files and attempts
87926aec45a7Smrg	# to make the code below a bit more comprehensible
87936aec45a7Smrg
87946aec45a7Smrg	case $vinfo_number in
87956aec45a7Smrg	yes)
8796300bf1aeSmrg	  number_major=$1
8797300bf1aeSmrg	  number_minor=$2
8798300bf1aeSmrg	  number_revision=$3
87996aec45a7Smrg	  #
88006aec45a7Smrg	  # There are really only two kinds -- those that
88016aec45a7Smrg	  # use the current revision as the major version
88026aec45a7Smrg	  # and those that subtract age and use age as
88036aec45a7Smrg	  # a minor version.  But, then there is irix
8804300bf1aeSmrg	  # that has an extra 1 added just for fun
88056aec45a7Smrg	  #
88066aec45a7Smrg	  case $version_type in
8807aa9e3350Smrg	  # correct linux to gnu/linux during the next big refactor
8808300bf1aeSmrg	  darwin|freebsd-elf|linux|osf|windows|none)
88096aec45a7Smrg	    func_arith $number_major + $number_minor
88106aec45a7Smrg	    current=$func_arith_result
8811300bf1aeSmrg	    age=$number_minor
8812300bf1aeSmrg	    revision=$number_revision
88136aec45a7Smrg	    ;;
8814300bf1aeSmrg	  freebsd-aout|qnx|sunos)
8815300bf1aeSmrg	    current=$number_major
8816300bf1aeSmrg	    revision=$number_minor
8817300bf1aeSmrg	    age=0
88186aec45a7Smrg	    ;;
88196aec45a7Smrg	  irix|nonstopux)
88206aec45a7Smrg	    func_arith $number_major + $number_minor
88216aec45a7Smrg	    current=$func_arith_result
8822300bf1aeSmrg	    age=$number_minor
8823300bf1aeSmrg	    revision=$number_minor
88246aec45a7Smrg	    lt_irix_increment=no
88256aec45a7Smrg	    ;;
88266aec45a7Smrg	  esac
88276aec45a7Smrg	  ;;
88286aec45a7Smrg	no)
8829300bf1aeSmrg	  current=$1
8830300bf1aeSmrg	  revision=$2
8831300bf1aeSmrg	  age=$3
88326aec45a7Smrg	  ;;
88336aec45a7Smrg	esac
88346aec45a7Smrg
88356aec45a7Smrg	# Check that each of the things are valid numbers.
88366aec45a7Smrg	case $current in
88376aec45a7Smrg	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]) ;;
88386aec45a7Smrg	*)
8839300bf1aeSmrg	  func_error "CURRENT '$current' must be a nonnegative integer"
8840300bf1aeSmrg	  func_fatal_error "'$vinfo' is not valid version information"
88416aec45a7Smrg	  ;;
88426aec45a7Smrg	esac
88436aec45a7Smrg
88446aec45a7Smrg	case $revision in
88456aec45a7Smrg	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]) ;;
88466aec45a7Smrg	*)
8847300bf1aeSmrg	  func_error "REVISION '$revision' must be a nonnegative integer"
8848300bf1aeSmrg	  func_fatal_error "'$vinfo' is not valid version information"
88496aec45a7Smrg	  ;;
88506aec45a7Smrg	esac
88516aec45a7Smrg
88526aec45a7Smrg	case $age in
88536aec45a7Smrg	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]) ;;
88546aec45a7Smrg	*)
8855300bf1aeSmrg	  func_error "AGE '$age' must be a nonnegative integer"
8856300bf1aeSmrg	  func_fatal_error "'$vinfo' is not valid version information"
88576aec45a7Smrg	  ;;
88586aec45a7Smrg	esac
88596aec45a7Smrg
88606aec45a7Smrg	if test "$age" -gt "$current"; then
8861300bf1aeSmrg	  func_error "AGE '$age' is greater than the current interface number '$current'"
8862300bf1aeSmrg	  func_fatal_error "'$vinfo' is not valid version information"
88636aec45a7Smrg	fi
88646aec45a7Smrg
88656aec45a7Smrg	# Calculate the version variables.
88666aec45a7Smrg	major=
88676aec45a7Smrg	versuffix=
88686aec45a7Smrg	verstring=
88696aec45a7Smrg	case $version_type in
88706aec45a7Smrg	none) ;;
88716aec45a7Smrg
88726aec45a7Smrg	darwin)
88736aec45a7Smrg	  # Like Linux, but with the current version available in
88746aec45a7Smrg	  # verstring for coding it into the library header
88756aec45a7Smrg	  func_arith $current - $age
88766aec45a7Smrg	  major=.$func_arith_result
8877300bf1aeSmrg	  versuffix=$major.$age.$revision
88786aec45a7Smrg	  # Darwin ld doesn't like 0 for these options...
88796aec45a7Smrg	  func_arith $current + 1
88806aec45a7Smrg	  minor_current=$func_arith_result
8881300bf1aeSmrg	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
88826aec45a7Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8883300bf1aeSmrg          # On Darwin other compilers
8884300bf1aeSmrg          case $CC in
8885300bf1aeSmrg              nagfor*)
8886300bf1aeSmrg                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8887300bf1aeSmrg                  ;;
8888300bf1aeSmrg              *)
8889300bf1aeSmrg                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8890300bf1aeSmrg                  ;;
8891300bf1aeSmrg          esac
88926aec45a7Smrg	  ;;
88936aec45a7Smrg
88946aec45a7Smrg	freebsd-aout)
8895300bf1aeSmrg	  major=.$current
8896300bf1aeSmrg	  versuffix=.$current.$revision
88976aec45a7Smrg	  ;;
88986aec45a7Smrg
88996aec45a7Smrg	freebsd-elf)
8900300bf1aeSmrg	  func_arith $current - $age
8901300bf1aeSmrg	  major=.$func_arith_result
8902300bf1aeSmrg	  versuffix=$major.$age.$revision
89036aec45a7Smrg	  ;;
89046aec45a7Smrg
89056aec45a7Smrg	irix | nonstopux)
8906300bf1aeSmrg	  if test no = "$lt_irix_increment"; then
89076aec45a7Smrg	    func_arith $current - $age
89086aec45a7Smrg	  else
89096aec45a7Smrg	    func_arith $current - $age + 1
89106aec45a7Smrg	  fi
89116aec45a7Smrg	  major=$func_arith_result
89126aec45a7Smrg
89136aec45a7Smrg	  case $version_type in
89146aec45a7Smrg	    nonstopux) verstring_prefix=nonstopux ;;
89156aec45a7Smrg	    *)         verstring_prefix=sgi ;;
89166aec45a7Smrg	  esac
8917300bf1aeSmrg	  verstring=$verstring_prefix$major.$revision
89186aec45a7Smrg
89196aec45a7Smrg	  # Add in all the interfaces that we are compatible with.
89206aec45a7Smrg	  loop=$revision
8921300bf1aeSmrg	  while test 0 -ne "$loop"; do
89226aec45a7Smrg	    func_arith $revision - $loop
89236aec45a7Smrg	    iface=$func_arith_result
89246aec45a7Smrg	    func_arith $loop - 1
89256aec45a7Smrg	    loop=$func_arith_result
8926300bf1aeSmrg	    verstring=$verstring_prefix$major.$iface:$verstring
89276aec45a7Smrg	  done
89286aec45a7Smrg
8929300bf1aeSmrg	  # Before this point, $major must not contain '.'.
89306aec45a7Smrg	  major=.$major
8931300bf1aeSmrg	  versuffix=$major.$revision
89326aec45a7Smrg	  ;;
89336aec45a7Smrg
8934aa9e3350Smrg	linux) # correct to gnu/linux during the next big refactor
89356aec45a7Smrg	  func_arith $current - $age
89366aec45a7Smrg	  major=.$func_arith_result
8937300bf1aeSmrg	  versuffix=$major.$age.$revision
89386aec45a7Smrg	  ;;
89396aec45a7Smrg
89406aec45a7Smrg	osf)
89416aec45a7Smrg	  func_arith $current - $age
89426aec45a7Smrg	  major=.$func_arith_result
8943300bf1aeSmrg	  versuffix=.$current.$age.$revision
8944300bf1aeSmrg	  verstring=$current.$age.$revision
89456aec45a7Smrg
89466aec45a7Smrg	  # Add in all the interfaces that we are compatible with.
89476aec45a7Smrg	  loop=$age
8948300bf1aeSmrg	  while test 0 -ne "$loop"; do
89496aec45a7Smrg	    func_arith $current - $loop
89506aec45a7Smrg	    iface=$func_arith_result
89516aec45a7Smrg	    func_arith $loop - 1
89526aec45a7Smrg	    loop=$func_arith_result
8953300bf1aeSmrg	    verstring=$verstring:$iface.0
89546aec45a7Smrg	  done
89556aec45a7Smrg
89566aec45a7Smrg	  # Make executables depend on our current version.
8957300bf1aeSmrg	  func_append verstring ":$current.0"
89586aec45a7Smrg	  ;;
89596aec45a7Smrg
89606aec45a7Smrg	qnx)
8961300bf1aeSmrg	  major=.$current
8962300bf1aeSmrg	  versuffix=.$current
8963300bf1aeSmrg	  ;;
8964300bf1aeSmrg
8965300bf1aeSmrg	sco)
8966300bf1aeSmrg	  major=.$current
8967300bf1aeSmrg	  versuffix=.$current
89686aec45a7Smrg	  ;;
89696aec45a7Smrg
89706aec45a7Smrg	sunos)
8971300bf1aeSmrg	  major=.$current
8972300bf1aeSmrg	  versuffix=.$current.$revision
89736aec45a7Smrg	  ;;
89746aec45a7Smrg
89756aec45a7Smrg	windows)
89766aec45a7Smrg	  # Use '-' rather than '.', since we only want one
8977300bf1aeSmrg	  # extension on DOS 8.3 file systems.
89786aec45a7Smrg	  func_arith $current - $age
89796aec45a7Smrg	  major=$func_arith_result
8980300bf1aeSmrg	  versuffix=-$major
89816aec45a7Smrg	  ;;
89826aec45a7Smrg
89836aec45a7Smrg	*)
8984300bf1aeSmrg	  func_fatal_configuration "unknown library version type '$version_type'"
89856aec45a7Smrg	  ;;
89866aec45a7Smrg	esac
89876aec45a7Smrg
89886aec45a7Smrg	# Clear the version info if we defaulted, and they specified a release.
89896aec45a7Smrg	if test -z "$vinfo" && test -n "$release"; then
89906aec45a7Smrg	  major=
89916aec45a7Smrg	  case $version_type in
89926aec45a7Smrg	  darwin)
89936aec45a7Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
89946aec45a7Smrg	    # problems, so we reset it completely
89956aec45a7Smrg	    verstring=
89966aec45a7Smrg	    ;;
89976aec45a7Smrg	  *)
8998300bf1aeSmrg	    verstring=0.0
89996aec45a7Smrg	    ;;
90006aec45a7Smrg	  esac
9001300bf1aeSmrg	  if test no = "$need_version"; then
90026aec45a7Smrg	    versuffix=
90036aec45a7Smrg	  else
9004300bf1aeSmrg	    versuffix=.0.0
90056aec45a7Smrg	  fi
90066aec45a7Smrg	fi
90076aec45a7Smrg
90086aec45a7Smrg	# Remove version info from name if versioning should be avoided
9009300bf1aeSmrg	if test yes,no = "$avoid_version,$need_version"; then
90106aec45a7Smrg	  major=
90116aec45a7Smrg	  versuffix=
9012300bf1aeSmrg	  verstring=
90136aec45a7Smrg	fi
90146aec45a7Smrg
90156aec45a7Smrg	# Check to see if the archive will have undefined symbols.
9016300bf1aeSmrg	if test yes = "$allow_undefined"; then
9017300bf1aeSmrg	  if test unsupported = "$allow_undefined_flag"; then
9018300bf1aeSmrg	    if test yes = "$build_old_libs"; then
9019300bf1aeSmrg	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
9020300bf1aeSmrg	      build_libtool_libs=no
9021300bf1aeSmrg	    else
9022300bf1aeSmrg	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
9023300bf1aeSmrg	    fi
90246aec45a7Smrg	  fi
90256aec45a7Smrg	else
90266aec45a7Smrg	  # Don't allow undefined symbols.
9027300bf1aeSmrg	  allow_undefined_flag=$no_undefined_flag
90286aec45a7Smrg	fi
90296aec45a7Smrg
90306aec45a7Smrg      fi
90316aec45a7Smrg
9032300bf1aeSmrg      func_generate_dlsyms "$libname" "$libname" :
9033aa9e3350Smrg      func_append libobjs " $symfileobj"
9034300bf1aeSmrg      test " " = "$libobjs" && libobjs=
90356aec45a7Smrg
9036300bf1aeSmrg      if test relink != "$opt_mode"; then
90376aec45a7Smrg	# Remove our outputs, but don't remove object files since they
90386aec45a7Smrg	# may have been created when compiling PIC objects.
90396aec45a7Smrg	removelist=
90406aec45a7Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
90416aec45a7Smrg	for p in $tempremovelist; do
90426aec45a7Smrg	  case $p in
90436aec45a7Smrg	    *.$objext | *.gcno)
90446aec45a7Smrg	       ;;
9045300bf1aeSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
9046300bf1aeSmrg	       if test -n "$precious_files_regex"; then
90476aec45a7Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
90486aec45a7Smrg		 then
90496aec45a7Smrg		   continue
90506aec45a7Smrg		 fi
90516aec45a7Smrg	       fi
9052aa9e3350Smrg	       func_append removelist " $p"
90536aec45a7Smrg	       ;;
90546aec45a7Smrg	    *) ;;
90556aec45a7Smrg	  esac
90566aec45a7Smrg	done
90576aec45a7Smrg	test -n "$removelist" && \
90586aec45a7Smrg	  func_show_eval "${RM}r \$removelist"
90596aec45a7Smrg      fi
90606aec45a7Smrg
90616aec45a7Smrg      # Now set the variables for building old libraries.
9062300bf1aeSmrg      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
9063aa9e3350Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
90646aec45a7Smrg
90656aec45a7Smrg	# Transform .lo files to .o files.
9066300bf1aeSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
90676aec45a7Smrg      fi
90686aec45a7Smrg
90696aec45a7Smrg      # Eliminate all temporary directories.
90706aec45a7Smrg      #for path in $notinst_path; do
90716aec45a7Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
90726aec45a7Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
90736aec45a7Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
90746aec45a7Smrg      #done
90756aec45a7Smrg
90766aec45a7Smrg      if test -n "$xrpath"; then
90776aec45a7Smrg	# If the user specified any rpath flags, then add them.
90786aec45a7Smrg	temp_xrpath=
90796aec45a7Smrg	for libdir in $xrpath; do
9080aa9e3350Smrg	  func_replace_sysroot "$libdir"
9081aa9e3350Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
90826aec45a7Smrg	  case "$finalize_rpath " in
90836aec45a7Smrg	  *" $libdir "*) ;;
9084aa9e3350Smrg	  *) func_append finalize_rpath " $libdir" ;;
90856aec45a7Smrg	  esac
90866aec45a7Smrg	done
9087300bf1aeSmrg	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
90886aec45a7Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
90896aec45a7Smrg	fi
90906aec45a7Smrg      fi
90916aec45a7Smrg
90926aec45a7Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
9093300bf1aeSmrg      old_dlfiles=$dlfiles
90946aec45a7Smrg      dlfiles=
90956aec45a7Smrg      for lib in $old_dlfiles; do
90966aec45a7Smrg	case " $dlprefiles $dlfiles " in
90976aec45a7Smrg	*" $lib "*) ;;
9098aa9e3350Smrg	*) func_append dlfiles " $lib" ;;
90996aec45a7Smrg	esac
91006aec45a7Smrg      done
91016aec45a7Smrg
91026aec45a7Smrg      # Make sure dlprefiles contains only unique files
9103300bf1aeSmrg      old_dlprefiles=$dlprefiles
91046aec45a7Smrg      dlprefiles=
91056aec45a7Smrg      for lib in $old_dlprefiles; do
91066aec45a7Smrg	case "$dlprefiles " in
91076aec45a7Smrg	*" $lib "*) ;;
9108aa9e3350Smrg	*) func_append dlprefiles " $lib" ;;
91096aec45a7Smrg	esac
91106aec45a7Smrg      done
91116aec45a7Smrg
9112300bf1aeSmrg      if test yes = "$build_libtool_libs"; then
91136aec45a7Smrg	if test -n "$rpath"; then
91146aec45a7Smrg	  case $host in
91156aec45a7Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
91166aec45a7Smrg	    # these systems don't actually have a c library (as such)!
91176aec45a7Smrg	    ;;
91186aec45a7Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
91196aec45a7Smrg	    # Rhapsody C library is in the System framework
9120aa9e3350Smrg	    func_append deplibs " System.ltframework"
91216aec45a7Smrg	    ;;
91226aec45a7Smrg	  *-*-netbsd*)
91236aec45a7Smrg	    # Don't link with libc until the a.out ld.so is fixed.
91246aec45a7Smrg	    ;;
91256aec45a7Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
91266aec45a7Smrg	    # Do not include libc due to us having libc/libc_r.
91276aec45a7Smrg	    ;;
91286aec45a7Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
91296aec45a7Smrg	    # Causes problems with __ctype
91306aec45a7Smrg	    ;;
91316aec45a7Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
91326aec45a7Smrg	    # Compiler inserts libc in the correct place for threads to work
91336aec45a7Smrg	    ;;
91346aec45a7Smrg	  *)
91356aec45a7Smrg	    # Add libc to deplibs on all other systems if necessary.
9136300bf1aeSmrg	    if test yes = "$build_libtool_need_lc"; then
9137aa9e3350Smrg	      func_append deplibs " -lc"
91386aec45a7Smrg	    fi
91396aec45a7Smrg	    ;;
91406aec45a7Smrg	  esac
91416aec45a7Smrg	fi
91426aec45a7Smrg
91436aec45a7Smrg	# Transform deplibs into only deplibs that can be linked in shared.
91446aec45a7Smrg	name_save=$name
91456aec45a7Smrg	libname_save=$libname
91466aec45a7Smrg	release_save=$release
91476aec45a7Smrg	versuffix_save=$versuffix
91486aec45a7Smrg	major_save=$major
91496aec45a7Smrg	# I'm not sure if I'm treating the release correctly.  I think
91506aec45a7Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
91516aec45a7Smrg	# add it in twice.  Is that correct?
9152300bf1aeSmrg	release=
9153300bf1aeSmrg	versuffix=
9154300bf1aeSmrg	major=
91556aec45a7Smrg	newdeplibs=
91566aec45a7Smrg	droppeddeps=no
91576aec45a7Smrg	case $deplibs_check_method in
91586aec45a7Smrg	pass_all)
91596aec45a7Smrg	  # Don't check for shared/static.  Everything works.
91606aec45a7Smrg	  # This might be a little naive.  We might want to check
91616aec45a7Smrg	  # whether the library exists or not.  But this is on
91626aec45a7Smrg	  # osf3 & osf4 and I'm not really sure... Just
91636aec45a7Smrg	  # implementing what was already the behavior.
91646aec45a7Smrg	  newdeplibs=$deplibs
91656aec45a7Smrg	  ;;
91666aec45a7Smrg	test_compile)
91676aec45a7Smrg	  # This code stresses the "libraries are programs" paradigm to its
91686aec45a7Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
91696aec45a7Smrg	  # against the deplibs as a proxy for the library.  Then we can check
91706aec45a7Smrg	  # whether they linked in statically or dynamically with ldd.
91716aec45a7Smrg	  $opt_dry_run || $RM conftest.c
91726aec45a7Smrg	  cat > conftest.c <<EOF
91736aec45a7Smrg	  int main() { return 0; }
91746aec45a7SmrgEOF
91756aec45a7Smrg	  $opt_dry_run || $RM conftest
91766aec45a7Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
91776aec45a7Smrg	    ldd_output=`ldd conftest`
91786aec45a7Smrg	    for i in $deplibs; do
91796aec45a7Smrg	      case $i in
91806aec45a7Smrg	      -l*)
91816aec45a7Smrg		func_stripname -l '' "$i"
91826aec45a7Smrg		name=$func_stripname_result
9183300bf1aeSmrg		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
91846aec45a7Smrg		  case " $predeps $postdeps " in
91856aec45a7Smrg		  *" $i "*)
9186aa9e3350Smrg		    func_append newdeplibs " $i"
9187300bf1aeSmrg		    i=
91886aec45a7Smrg		    ;;
91896aec45a7Smrg		  esac
91906aec45a7Smrg		fi
9191300bf1aeSmrg		if test -n "$i"; then
91926aec45a7Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
91936aec45a7Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
91946aec45a7Smrg		  set dummy $deplib_matches; shift
91956aec45a7Smrg		  deplib_match=$1
9196300bf1aeSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9197aa9e3350Smrg		    func_append newdeplibs " $i"
91986aec45a7Smrg		  else
91996aec45a7Smrg		    droppeddeps=yes
92006aec45a7Smrg		    echo
92016aec45a7Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
92026aec45a7Smrg		    echo "*** I have the capability to make that library automatically link in when"
92036aec45a7Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
92046aec45a7Smrg		    echo "*** shared version of the library, which I believe you do not have"
92056aec45a7Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
92066aec45a7Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
92076aec45a7Smrg		  fi
92086aec45a7Smrg		fi
92096aec45a7Smrg		;;
92106aec45a7Smrg	      *)
9211aa9e3350Smrg		func_append newdeplibs " $i"
92126aec45a7Smrg		;;
92136aec45a7Smrg	      esac
92146aec45a7Smrg	    done
92156aec45a7Smrg	  else
92166aec45a7Smrg	    # Error occurred in the first compile.  Let's try to salvage
92176aec45a7Smrg	    # the situation: Compile a separate program for each library.
92186aec45a7Smrg	    for i in $deplibs; do
92196aec45a7Smrg	      case $i in
92206aec45a7Smrg	      -l*)
92216aec45a7Smrg		func_stripname -l '' "$i"
92226aec45a7Smrg		name=$func_stripname_result
92236aec45a7Smrg		$opt_dry_run || $RM conftest
92246aec45a7Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
92256aec45a7Smrg		  ldd_output=`ldd conftest`
9226300bf1aeSmrg		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
92276aec45a7Smrg		    case " $predeps $postdeps " in
92286aec45a7Smrg		    *" $i "*)
9229aa9e3350Smrg		      func_append newdeplibs " $i"
9230300bf1aeSmrg		      i=
92316aec45a7Smrg		      ;;
92326aec45a7Smrg		    esac
92336aec45a7Smrg		  fi
9234300bf1aeSmrg		  if test -n "$i"; then
92356aec45a7Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
92366aec45a7Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
92376aec45a7Smrg		    set dummy $deplib_matches; shift
92386aec45a7Smrg		    deplib_match=$1
9239300bf1aeSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9240aa9e3350Smrg		      func_append newdeplibs " $i"
92416aec45a7Smrg		    else
92426aec45a7Smrg		      droppeddeps=yes
92436aec45a7Smrg		      echo
92446aec45a7Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
92456aec45a7Smrg		      echo "*** I have the capability to make that library automatically link in when"
92466aec45a7Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
92476aec45a7Smrg		      echo "*** shared version of the library, which you do not appear to have"
92486aec45a7Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
92496aec45a7Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
92506aec45a7Smrg		    fi
92516aec45a7Smrg		  fi
92526aec45a7Smrg		else
92536aec45a7Smrg		  droppeddeps=yes
92546aec45a7Smrg		  echo
92556aec45a7Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
92566aec45a7Smrg		  echo "*** make it link in!  You will probably need to install it or some"
92576aec45a7Smrg		  echo "*** library that it depends on before this library will be fully"
92586aec45a7Smrg		  echo "*** functional.  Installing it before continuing would be even better."
92596aec45a7Smrg		fi
92606aec45a7Smrg		;;
92616aec45a7Smrg	      *)
9262aa9e3350Smrg		func_append newdeplibs " $i"
92636aec45a7Smrg		;;
92646aec45a7Smrg	      esac
92656aec45a7Smrg	    done
92666aec45a7Smrg	  fi
92676aec45a7Smrg	  ;;
92686aec45a7Smrg	file_magic*)
92696aec45a7Smrg	  set dummy $deplibs_check_method; shift
92706aec45a7Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
92716aec45a7Smrg	  for a_deplib in $deplibs; do
92726aec45a7Smrg	    case $a_deplib in
92736aec45a7Smrg	    -l*)
92746aec45a7Smrg	      func_stripname -l '' "$a_deplib"
92756aec45a7Smrg	      name=$func_stripname_result
9276300bf1aeSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
92776aec45a7Smrg		case " $predeps $postdeps " in
92786aec45a7Smrg		*" $a_deplib "*)
9279aa9e3350Smrg		  func_append newdeplibs " $a_deplib"
9280300bf1aeSmrg		  a_deplib=
92816aec45a7Smrg		  ;;
92826aec45a7Smrg		esac
92836aec45a7Smrg	      fi
9284300bf1aeSmrg	      if test -n "$a_deplib"; then
92856aec45a7Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
9286aa9e3350Smrg		if test -n "$file_magic_glob"; then
9287aa9e3350Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9288aa9e3350Smrg		else
9289aa9e3350Smrg		  libnameglob=$libname
9290aa9e3350Smrg		fi
9291300bf1aeSmrg		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
92926aec45a7Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9293300bf1aeSmrg		  if test yes = "$want_nocaseglob"; then
9294aa9e3350Smrg		    shopt -s nocaseglob
9295aa9e3350Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9296aa9e3350Smrg		    $nocaseglob
9297aa9e3350Smrg		  else
9298aa9e3350Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9299aa9e3350Smrg		  fi
93006aec45a7Smrg		  for potent_lib in $potential_libs; do
93016aec45a7Smrg		      # Follow soft links.
93026aec45a7Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
93036aec45a7Smrg			 $GREP " -> " >/dev/null; then
93046aec45a7Smrg			continue
93056aec45a7Smrg		      fi
93066aec45a7Smrg		      # The statement above tries to avoid entering an
93076aec45a7Smrg		      # endless loop below, in case of cyclic links.
93086aec45a7Smrg		      # We might still enter an endless loop, since a link
93096aec45a7Smrg		      # loop can be closed while we follow links,
93106aec45a7Smrg		      # but so what?
9311300bf1aeSmrg		      potlib=$potent_lib
93126aec45a7Smrg		      while test -h "$potlib" 2>/dev/null; do
9313300bf1aeSmrg			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
93146aec45a7Smrg			case $potliblink in
9315300bf1aeSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
9316300bf1aeSmrg			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
93176aec45a7Smrg			esac
93186aec45a7Smrg		      done
93196aec45a7Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
93206aec45a7Smrg			 $SED -e 10q |
93216aec45a7Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
9322aa9e3350Smrg			func_append newdeplibs " $a_deplib"
9323300bf1aeSmrg			a_deplib=
93246aec45a7Smrg			break 2
93256aec45a7Smrg		      fi
93266aec45a7Smrg		  done
93276aec45a7Smrg		done
93286aec45a7Smrg	      fi
9329300bf1aeSmrg	      if test -n "$a_deplib"; then
93306aec45a7Smrg		droppeddeps=yes
93316aec45a7Smrg		echo
93326aec45a7Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
93336aec45a7Smrg		echo "*** I have the capability to make that library automatically link in when"
93346aec45a7Smrg		echo "*** you link to this library.  But I can only do this if you have a"
93356aec45a7Smrg		echo "*** shared version of the library, which you do not appear to have"
93366aec45a7Smrg		echo "*** because I did check the linker path looking for a file starting"
9337300bf1aeSmrg		if test -z "$potlib"; then
93386aec45a7Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
93396aec45a7Smrg		else
93406aec45a7Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
93416aec45a7Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
93426aec45a7Smrg		fi
93436aec45a7Smrg	      fi
93446aec45a7Smrg	      ;;
93456aec45a7Smrg	    *)
93466aec45a7Smrg	      # Add a -L argument.
9347aa9e3350Smrg	      func_append newdeplibs " $a_deplib"
93486aec45a7Smrg	      ;;
93496aec45a7Smrg	    esac
93506aec45a7Smrg	  done # Gone through all deplibs.
93516aec45a7Smrg	  ;;
93526aec45a7Smrg	match_pattern*)
93536aec45a7Smrg	  set dummy $deplibs_check_method; shift
93546aec45a7Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
93556aec45a7Smrg	  for a_deplib in $deplibs; do
93566aec45a7Smrg	    case $a_deplib in
93576aec45a7Smrg	    -l*)
93586aec45a7Smrg	      func_stripname -l '' "$a_deplib"
93596aec45a7Smrg	      name=$func_stripname_result
9360300bf1aeSmrg	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
93616aec45a7Smrg		case " $predeps $postdeps " in
93626aec45a7Smrg		*" $a_deplib "*)
9363aa9e3350Smrg		  func_append newdeplibs " $a_deplib"
9364300bf1aeSmrg		  a_deplib=
93656aec45a7Smrg		  ;;
93666aec45a7Smrg		esac
93676aec45a7Smrg	      fi
9368300bf1aeSmrg	      if test -n "$a_deplib"; then
93696aec45a7Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
93706aec45a7Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
93716aec45a7Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
93726aec45a7Smrg		  for potent_lib in $potential_libs; do
9373300bf1aeSmrg		    potlib=$potent_lib # see symlink-check above in file_magic test
93746aec45a7Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
93756aec45a7Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
9376aa9e3350Smrg		      func_append newdeplibs " $a_deplib"
9377300bf1aeSmrg		      a_deplib=
93786aec45a7Smrg		      break 2
93796aec45a7Smrg		    fi
93806aec45a7Smrg		  done
93816aec45a7Smrg		done
93826aec45a7Smrg	      fi
9383300bf1aeSmrg	      if test -n "$a_deplib"; then
93846aec45a7Smrg		droppeddeps=yes
93856aec45a7Smrg		echo
93866aec45a7Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
93876aec45a7Smrg		echo "*** I have the capability to make that library automatically link in when"
93886aec45a7Smrg		echo "*** you link to this library.  But I can only do this if you have a"
93896aec45a7Smrg		echo "*** shared version of the library, which you do not appear to have"
93906aec45a7Smrg		echo "*** because I did check the linker path looking for a file starting"
9391300bf1aeSmrg		if test -z "$potlib"; then
93926aec45a7Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
93936aec45a7Smrg		else
93946aec45a7Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
93956aec45a7Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
93966aec45a7Smrg		fi
93976aec45a7Smrg	      fi
93986aec45a7Smrg	      ;;
93996aec45a7Smrg	    *)
94006aec45a7Smrg	      # Add a -L argument.
9401aa9e3350Smrg	      func_append newdeplibs " $a_deplib"
94026aec45a7Smrg	      ;;
94036aec45a7Smrg	    esac
94046aec45a7Smrg	  done # Gone through all deplibs.
94056aec45a7Smrg	  ;;
94066aec45a7Smrg	none | unknown | *)
9407300bf1aeSmrg	  newdeplibs=
94086aec45a7Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
9409300bf1aeSmrg	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9410300bf1aeSmrg	    for i in $predeps $postdeps; do
94116aec45a7Smrg	      # can't use Xsed below, because $i might contain '/'
9412300bf1aeSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
94136aec45a7Smrg	    done
94146aec45a7Smrg	  fi
94156aec45a7Smrg	  case $tmp_deplibs in
94166aec45a7Smrg	  *[!\	\ ]*)
94176aec45a7Smrg	    echo
9418300bf1aeSmrg	    if test none = "$deplibs_check_method"; then
94196aec45a7Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
94206aec45a7Smrg	    else
94216aec45a7Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
94226aec45a7Smrg	    fi
94236aec45a7Smrg	    echo "*** All declared inter-library dependencies are being dropped."
94246aec45a7Smrg	    droppeddeps=yes
94256aec45a7Smrg	    ;;
94266aec45a7Smrg	  esac
94276aec45a7Smrg	  ;;
94286aec45a7Smrg	esac
94296aec45a7Smrg	versuffix=$versuffix_save
94306aec45a7Smrg	major=$major_save
94316aec45a7Smrg	release=$release_save
94326aec45a7Smrg	libname=$libname_save
94336aec45a7Smrg	name=$name_save
94346aec45a7Smrg
94356aec45a7Smrg	case $host in
94366aec45a7Smrg	*-*-rhapsody* | *-*-darwin1.[012])
94376aec45a7Smrg	  # On Rhapsody replace the C library with the System framework
94386aec45a7Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
94396aec45a7Smrg	  ;;
94406aec45a7Smrg	esac
94416aec45a7Smrg
9442300bf1aeSmrg	if test yes = "$droppeddeps"; then
9443300bf1aeSmrg	  if test yes = "$module"; then
94446aec45a7Smrg	    echo
94456aec45a7Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
94466aec45a7Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
94476aec45a7Smrg	    echo "*** a static module, that should work as long as the dlopening"
94486aec45a7Smrg	    echo "*** application is linked with the -dlopen flag."
94496aec45a7Smrg	    if test -z "$global_symbol_pipe"; then
94506aec45a7Smrg	      echo
94516aec45a7Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
9452300bf1aeSmrg	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
94536aec45a7Smrg	      echo "*** not find such a program.  So, this module is probably useless."
9454300bf1aeSmrg	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
94556aec45a7Smrg	    fi
9456300bf1aeSmrg	    if test no = "$build_old_libs"; then
9457300bf1aeSmrg	      oldlibs=$output_objdir/$libname.$libext
94586aec45a7Smrg	      build_libtool_libs=module
94596aec45a7Smrg	      build_old_libs=yes
94606aec45a7Smrg	    else
94616aec45a7Smrg	      build_libtool_libs=no
94626aec45a7Smrg	    fi
94636aec45a7Smrg	  else
94646aec45a7Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
94656aec45a7Smrg	    echo "*** automatically added whenever a program is linked with this library"
94666aec45a7Smrg	    echo "*** or is declared to -dlopen it."
94676aec45a7Smrg
9468300bf1aeSmrg	    if test no = "$allow_undefined"; then
94696aec45a7Smrg	      echo
94706aec45a7Smrg	      echo "*** Since this library must not contain undefined symbols,"
94716aec45a7Smrg	      echo "*** because either the platform does not support them or"
94726aec45a7Smrg	      echo "*** it was explicitly requested with -no-undefined,"
94736aec45a7Smrg	      echo "*** libtool will only create a static version of it."
9474300bf1aeSmrg	      if test no = "$build_old_libs"; then
9475300bf1aeSmrg		oldlibs=$output_objdir/$libname.$libext
94766aec45a7Smrg		build_libtool_libs=module
94776aec45a7Smrg		build_old_libs=yes
94786aec45a7Smrg	      else
94796aec45a7Smrg		build_libtool_libs=no
94806aec45a7Smrg	      fi
94816aec45a7Smrg	    fi
94826aec45a7Smrg	  fi
94836aec45a7Smrg	fi
94846aec45a7Smrg	# Done checking deplibs!
94856aec45a7Smrg	deplibs=$newdeplibs
94866aec45a7Smrg      fi
94876aec45a7Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
94886aec45a7Smrg      case $host in
94896aec45a7Smrg	*-*-darwin*)
94906aec45a7Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
94916aec45a7Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
94926aec45a7Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
94936aec45a7Smrg	  ;;
94946aec45a7Smrg      esac
94956aec45a7Smrg
94966aec45a7Smrg      # move library search paths that coincide with paths to not yet
94976aec45a7Smrg      # installed libraries to the beginning of the library search list
94986aec45a7Smrg      new_libs=
94996aec45a7Smrg      for path in $notinst_path; do
95006aec45a7Smrg	case " $new_libs " in
95016aec45a7Smrg	*" -L$path/$objdir "*) ;;
95026aec45a7Smrg	*)
95036aec45a7Smrg	  case " $deplibs " in
95046aec45a7Smrg	  *" -L$path/$objdir "*)
9505aa9e3350Smrg	    func_append new_libs " -L$path/$objdir" ;;
95066aec45a7Smrg	  esac
95076aec45a7Smrg	  ;;
95086aec45a7Smrg	esac
95096aec45a7Smrg      done
95106aec45a7Smrg      for deplib in $deplibs; do
95116aec45a7Smrg	case $deplib in
95126aec45a7Smrg	-L*)
95136aec45a7Smrg	  case " $new_libs " in
95146aec45a7Smrg	  *" $deplib "*) ;;
9515aa9e3350Smrg	  *) func_append new_libs " $deplib" ;;
95166aec45a7Smrg	  esac
95176aec45a7Smrg	  ;;
9518aa9e3350Smrg	*) func_append new_libs " $deplib" ;;
95196aec45a7Smrg	esac
95206aec45a7Smrg      done
9521300bf1aeSmrg      deplibs=$new_libs
95226aec45a7Smrg
95236aec45a7Smrg      # All the library-specific variables (install_libdir is set above).
95246aec45a7Smrg      library_names=
95256aec45a7Smrg      old_library=
95266aec45a7Smrg      dlname=
95276aec45a7Smrg
95286aec45a7Smrg      # Test again, we may have decided not to build it any more
9529300bf1aeSmrg      if test yes = "$build_libtool_libs"; then
9530300bf1aeSmrg	# Remove $wl instances when linking with ld.
9531aa9e3350Smrg	# FIXME: should test the right _cmds variable.
9532aa9e3350Smrg	case $archive_cmds in
9533aa9e3350Smrg	  *\$LD\ *) wl= ;;
9534aa9e3350Smrg        esac
9535300bf1aeSmrg	if test yes = "$hardcode_into_libs"; then
95366aec45a7Smrg	  # Hardcode the library paths
95376aec45a7Smrg	  hardcode_libdirs=
95386aec45a7Smrg	  dep_rpath=
9539300bf1aeSmrg	  rpath=$finalize_rpath
9540300bf1aeSmrg	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
95416aec45a7Smrg	  for libdir in $rpath; do
95426aec45a7Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
95436aec45a7Smrg	      if test -n "$hardcode_libdir_separator"; then
9544aa9e3350Smrg		func_replace_sysroot "$libdir"
9545aa9e3350Smrg		libdir=$func_replace_sysroot_result
95466aec45a7Smrg		if test -z "$hardcode_libdirs"; then
9547300bf1aeSmrg		  hardcode_libdirs=$libdir
95486aec45a7Smrg		else
95496aec45a7Smrg		  # Just accumulate the unique libdirs.
95506aec45a7Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
95516aec45a7Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
95526aec45a7Smrg		    ;;
95536aec45a7Smrg		  *)
9554aa9e3350Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
95556aec45a7Smrg		    ;;
95566aec45a7Smrg		  esac
95576aec45a7Smrg		fi
95586aec45a7Smrg	      else
95596aec45a7Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
9560aa9e3350Smrg		func_append dep_rpath " $flag"
95616aec45a7Smrg	      fi
95626aec45a7Smrg	    elif test -n "$runpath_var"; then
95636aec45a7Smrg	      case "$perm_rpath " in
95646aec45a7Smrg	      *" $libdir "*) ;;
9565aa9e3350Smrg	      *) func_append perm_rpath " $libdir" ;;
95666aec45a7Smrg	      esac
95676aec45a7Smrg	    fi
95686aec45a7Smrg	  done
95696aec45a7Smrg	  # Substitute the hardcoded libdirs into the rpath.
95706aec45a7Smrg	  if test -n "$hardcode_libdir_separator" &&
95716aec45a7Smrg	     test -n "$hardcode_libdirs"; then
9572300bf1aeSmrg	    libdir=$hardcode_libdirs
9573aa9e3350Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
95746aec45a7Smrg	  fi
95756aec45a7Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
95766aec45a7Smrg	    # We should set the runpath_var.
95776aec45a7Smrg	    rpath=
95786aec45a7Smrg	    for dir in $perm_rpath; do
9579aa9e3350Smrg	      func_append rpath "$dir:"
95806aec45a7Smrg	    done
95816aec45a7Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
95826aec45a7Smrg	  fi
95836aec45a7Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
95846aec45a7Smrg	fi
9585ab47cfaaSmrg
9586300bf1aeSmrg	shlibpath=$finalize_shlibpath
9587300bf1aeSmrg	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
95886aec45a7Smrg	if test -n "$shlibpath"; then
95896aec45a7Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
95906aec45a7Smrg	fi
9591ab47cfaaSmrg
95926aec45a7Smrg	# Get the real and link names of the library.
95936aec45a7Smrg	eval shared_ext=\"$shrext_cmds\"
95946aec45a7Smrg	eval library_names=\"$library_names_spec\"
95956aec45a7Smrg	set dummy $library_names
95966aec45a7Smrg	shift
9597300bf1aeSmrg	realname=$1
95986aec45a7Smrg	shift
9599ab47cfaaSmrg
96006aec45a7Smrg	if test -n "$soname_spec"; then
96016aec45a7Smrg	  eval soname=\"$soname_spec\"
96026aec45a7Smrg	else
9603300bf1aeSmrg	  soname=$realname
96046aec45a7Smrg	fi
96056aec45a7Smrg	if test -z "$dlname"; then
96066aec45a7Smrg	  dlname=$soname
96076aec45a7Smrg	fi
9608ab47cfaaSmrg
9609300bf1aeSmrg	lib=$output_objdir/$realname
96106aec45a7Smrg	linknames=
96116aec45a7Smrg	for link
96126aec45a7Smrg	do
9613aa9e3350Smrg	  func_append linknames " $link"
96146aec45a7Smrg	done
9615ab47cfaaSmrg
96166aec45a7Smrg	# Use standard objects if they are pic
96176aec45a7Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
96186aec45a7Smrg	test "X$libobjs" = "X " && libobjs=
9619ab47cfaaSmrg
96206aec45a7Smrg	delfiles=
96216aec45a7Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
96226aec45a7Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
9623300bf1aeSmrg	  export_symbols=$output_objdir/$libname.uexp
9624aa9e3350Smrg	  func_append delfiles " $export_symbols"
96256aec45a7Smrg	fi
9626ab47cfaaSmrg
96276aec45a7Smrg	orig_export_symbols=
96286aec45a7Smrg	case $host_os in
96296aec45a7Smrg	cygwin* | mingw* | cegcc*)
96306aec45a7Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
96316aec45a7Smrg	    # exporting using user supplied symfile
9632300bf1aeSmrg	    func_dll_def_p "$export_symbols" || {
96336aec45a7Smrg	      # and it's NOT already a .def file. Must figure out
96346aec45a7Smrg	      # which of the given symbols are data symbols and tag
96356aec45a7Smrg	      # them as such. So, trigger use of export_symbols_cmds.
96366aec45a7Smrg	      # export_symbols gets reassigned inside the "prepare
96376aec45a7Smrg	      # the list of exported symbols" if statement, so the
96386aec45a7Smrg	      # include_expsyms logic still works.
9639300bf1aeSmrg	      orig_export_symbols=$export_symbols
96406aec45a7Smrg	      export_symbols=
96416aec45a7Smrg	      always_export_symbols=yes
9642300bf1aeSmrg	    }
96436aec45a7Smrg	  fi
96446aec45a7Smrg	  ;;
96456aec45a7Smrg	esac
9646ab47cfaaSmrg
96476aec45a7Smrg	# Prepare the list of exported symbols
96486aec45a7Smrg	if test -z "$export_symbols"; then
9649300bf1aeSmrg	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
9650300bf1aeSmrg	    func_verbose "generating symbol list for '$libname.la'"
9651300bf1aeSmrg	    export_symbols=$output_objdir/$libname.exp
96526aec45a7Smrg	    $opt_dry_run || $RM $export_symbols
96536aec45a7Smrg	    cmds=$export_symbols_cmds
9654300bf1aeSmrg	    save_ifs=$IFS; IFS='~'
9655aa9e3350Smrg	    for cmd1 in $cmds; do
9656300bf1aeSmrg	      IFS=$save_ifs
9657aa9e3350Smrg	      # Take the normal branch if the nm_file_list_spec branch
9658aa9e3350Smrg	      # doesn't work or if tool conversion is not needed.
9659aa9e3350Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
9660aa9e3350Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9661aa9e3350Smrg		  try_normal_branch=yes
9662aa9e3350Smrg		  eval cmd=\"$cmd1\"
9663aa9e3350Smrg		  func_len " $cmd"
9664aa9e3350Smrg		  len=$func_len_result
9665aa9e3350Smrg		  ;;
9666aa9e3350Smrg		*)
9667aa9e3350Smrg		  try_normal_branch=no
9668aa9e3350Smrg		  ;;
9669aa9e3350Smrg	      esac
9670300bf1aeSmrg	      if test yes = "$try_normal_branch" \
9671aa9e3350Smrg		 && { test "$len" -lt "$max_cmd_len" \
9672aa9e3350Smrg		      || test "$max_cmd_len" -le -1; }
9673aa9e3350Smrg	      then
9674aa9e3350Smrg		func_show_eval "$cmd" 'exit $?'
9675aa9e3350Smrg		skipped_export=false
9676aa9e3350Smrg	      elif test -n "$nm_file_list_spec"; then
9677aa9e3350Smrg		func_basename "$output"
9678aa9e3350Smrg		output_la=$func_basename_result
9679aa9e3350Smrg		save_libobjs=$libobjs
9680aa9e3350Smrg		save_output=$output
9681300bf1aeSmrg		output=$output_objdir/$output_la.nm
9682aa9e3350Smrg		func_to_tool_file "$output"
9683aa9e3350Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
9684aa9e3350Smrg		func_append delfiles " $output"
9685aa9e3350Smrg		func_verbose "creating $NM input file list: $output"
9686aa9e3350Smrg		for obj in $save_libobjs; do
9687aa9e3350Smrg		  func_to_tool_file "$obj"
9688aa9e3350Smrg		  $ECHO "$func_to_tool_file_result"
9689aa9e3350Smrg		done > "$output"
9690aa9e3350Smrg		eval cmd=\"$cmd1\"
96916aec45a7Smrg		func_show_eval "$cmd" 'exit $?'
9692aa9e3350Smrg		output=$save_output
9693aa9e3350Smrg		libobjs=$save_libobjs
96946aec45a7Smrg		skipped_export=false
96956aec45a7Smrg	      else
96966aec45a7Smrg		# The command line is too long to execute in one step.
96976aec45a7Smrg		func_verbose "using reloadable object file for export list..."
96986aec45a7Smrg		skipped_export=:
96996aec45a7Smrg		# Break out early, otherwise skipped_export may be
97006aec45a7Smrg		# set to false by a later but shorter cmd.
97016aec45a7Smrg		break
97026aec45a7Smrg	      fi
97036aec45a7Smrg	    done
9704300bf1aeSmrg	    IFS=$save_ifs
9705300bf1aeSmrg	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
97066aec45a7Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
97076aec45a7Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
97086aec45a7Smrg	    fi
97096aec45a7Smrg	  fi
97106aec45a7Smrg	fi
9711ab47cfaaSmrg
97126aec45a7Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
9713300bf1aeSmrg	  tmp_export_symbols=$export_symbols
9714300bf1aeSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
97156aec45a7Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
97166aec45a7Smrg	fi
9717ab47cfaaSmrg
9718300bf1aeSmrg	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
97196aec45a7Smrg	  # The given exports_symbols file has to be filtered, so filter it.
9720300bf1aeSmrg	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
97216aec45a7Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
9722300bf1aeSmrg	  # 's' commands, which not all seds can handle. GNU sed should be fine
97236aec45a7Smrg	  # though. Also, the filter scales superlinearly with the number of
97246aec45a7Smrg	  # global variables. join(1) would be nice here, but unfortunately
97256aec45a7Smrg	  # isn't a blessed tool.
97266aec45a7Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9727aa9e3350Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
97286aec45a7Smrg	  export_symbols=$output_objdir/$libname.def
97296aec45a7Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
97301473d951Smrg	fi
9731ab47cfaaSmrg
97326aec45a7Smrg	tmp_deplibs=
97336aec45a7Smrg	for test_deplib in $deplibs; do
97346aec45a7Smrg	  case " $convenience " in
97356aec45a7Smrg	  *" $test_deplib "*) ;;
97366aec45a7Smrg	  *)
9737aa9e3350Smrg	    func_append tmp_deplibs " $test_deplib"
97386aec45a7Smrg	    ;;
97396aec45a7Smrg	  esac
97406aec45a7Smrg	done
9741300bf1aeSmrg	deplibs=$tmp_deplibs
9742ab47cfaaSmrg
97436aec45a7Smrg	if test -n "$convenience"; then
97446aec45a7Smrg	  if test -n "$whole_archive_flag_spec" &&
9745300bf1aeSmrg	    test yes = "$compiler_needs_object" &&
97466aec45a7Smrg	    test -z "$libobjs"; then
97476aec45a7Smrg	    # extract the archives, so we have objects to list.
97486aec45a7Smrg	    # TODO: could optimize this to just extract one archive.
97496aec45a7Smrg	    whole_archive_flag_spec=
97506aec45a7Smrg	  fi
97516aec45a7Smrg	  if test -n "$whole_archive_flag_spec"; then
97526aec45a7Smrg	    save_libobjs=$libobjs
97536aec45a7Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
97546aec45a7Smrg	    test "X$libobjs" = "X " && libobjs=
97556aec45a7Smrg	  else
9756300bf1aeSmrg	    gentop=$output_objdir/${outputname}x
9757aa9e3350Smrg	    func_append generated " $gentop"
9758ab47cfaaSmrg
97596aec45a7Smrg	    func_extract_archives $gentop $convenience
9760aa9e3350Smrg	    func_append libobjs " $func_extract_archives_result"
97616aec45a7Smrg	    test "X$libobjs" = "X " && libobjs=
97626aec45a7Smrg	  fi
97636aec45a7Smrg	fi
9764ab47cfaaSmrg
9765300bf1aeSmrg	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
97666aec45a7Smrg	  eval flag=\"$thread_safe_flag_spec\"
9767aa9e3350Smrg	  func_append linker_flags " $flag"
97686aec45a7Smrg	fi
9769ab47cfaaSmrg
97706aec45a7Smrg	# Make a backup of the uninstalled library when relinking
9771300bf1aeSmrg	if test relink = "$opt_mode"; then
97726aec45a7Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
97735c42550eSmrg	fi
9774ab47cfaaSmrg
97756aec45a7Smrg	# Do each of the archive commands.
9776300bf1aeSmrg	if test yes = "$module" && test -n "$module_cmds"; then
97776aec45a7Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
97786aec45a7Smrg	    eval test_cmds=\"$module_expsym_cmds\"
97796aec45a7Smrg	    cmds=$module_expsym_cmds
97806aec45a7Smrg	  else
97816aec45a7Smrg	    eval test_cmds=\"$module_cmds\"
97826aec45a7Smrg	    cmds=$module_cmds
97836aec45a7Smrg	  fi
97846aec45a7Smrg	else
97856aec45a7Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
97866aec45a7Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
97876aec45a7Smrg	    cmds=$archive_expsym_cmds
97886aec45a7Smrg	  else
97896aec45a7Smrg	    eval test_cmds=\"$archive_cmds\"
97906aec45a7Smrg	    cmds=$archive_cmds
97916aec45a7Smrg	  fi
97925c42550eSmrg	fi
9793ab47cfaaSmrg
9794300bf1aeSmrg	if test : != "$skipped_export" &&
97956aec45a7Smrg	   func_len " $test_cmds" &&
97966aec45a7Smrg	   len=$func_len_result &&
97976aec45a7Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
97986aec45a7Smrg	  :
97996aec45a7Smrg	else
98006aec45a7Smrg	  # The command line is too long to link in one step, link piecewise
98016aec45a7Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
98026aec45a7Smrg	  # script.
9803ab47cfaaSmrg
98046aec45a7Smrg	  # Save the value of $output and $libobjs because we want to
98056aec45a7Smrg	  # use them later.  If we have whole_archive_flag_spec, we
98066aec45a7Smrg	  # want to use save_libobjs as it was before
98076aec45a7Smrg	  # whole_archive_flag_spec was expanded, because we can't
98086aec45a7Smrg	  # assume the linker understands whole_archive_flag_spec.
98096aec45a7Smrg	  # This may have to be revisited, in case too many
98106aec45a7Smrg	  # convenience libraries get linked in and end up exceeding
98116aec45a7Smrg	  # the spec.
98126aec45a7Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
98136aec45a7Smrg	    save_libobjs=$libobjs
98146aec45a7Smrg	  fi
98156aec45a7Smrg	  save_output=$output
98166aec45a7Smrg	  func_basename "$output"
98176aec45a7Smrg	  output_la=$func_basename_result
98181473d951Smrg
98196aec45a7Smrg	  # Clear the reloadable object creation command queue and
98206aec45a7Smrg	  # initialize k to one.
98216aec45a7Smrg	  test_cmds=
98226aec45a7Smrg	  concat_cmds=
98236aec45a7Smrg	  objlist=
98246aec45a7Smrg	  last_robj=
98256aec45a7Smrg	  k=1
9826ab47cfaaSmrg
9827300bf1aeSmrg	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
9828300bf1aeSmrg	    output=$output_objdir/$output_la.lnkscript
98296aec45a7Smrg	    func_verbose "creating GNU ld script: $output"
98306aec45a7Smrg	    echo 'INPUT (' > $output
98316aec45a7Smrg	    for obj in $save_libobjs
98326aec45a7Smrg	    do
9833aa9e3350Smrg	      func_to_tool_file "$obj"
9834aa9e3350Smrg	      $ECHO "$func_to_tool_file_result" >> $output
98356aec45a7Smrg	    done
98366aec45a7Smrg	    echo ')' >> $output
9837aa9e3350Smrg	    func_append delfiles " $output"
9838aa9e3350Smrg	    func_to_tool_file "$output"
9839aa9e3350Smrg	    output=$func_to_tool_file_result
9840300bf1aeSmrg	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
9841300bf1aeSmrg	    output=$output_objdir/$output_la.lnk
98426aec45a7Smrg	    func_verbose "creating linker input file list: $output"
98436aec45a7Smrg	    : > $output
98446aec45a7Smrg	    set x $save_libobjs
98456aec45a7Smrg	    shift
98466aec45a7Smrg	    firstobj=
9847300bf1aeSmrg	    if test yes = "$compiler_needs_object"; then
98486aec45a7Smrg	      firstobj="$1 "
98496aec45a7Smrg	      shift
98506aec45a7Smrg	    fi
98516aec45a7Smrg	    for obj
98526aec45a7Smrg	    do
9853aa9e3350Smrg	      func_to_tool_file "$obj"
9854aa9e3350Smrg	      $ECHO "$func_to_tool_file_result" >> $output
98556aec45a7Smrg	    done
9856aa9e3350Smrg	    func_append delfiles " $output"
9857aa9e3350Smrg	    func_to_tool_file "$output"
9858aa9e3350Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
98596aec45a7Smrg	  else
98606aec45a7Smrg	    if test -n "$save_libobjs"; then
98616aec45a7Smrg	      func_verbose "creating reloadable object files..."
9862300bf1aeSmrg	      output=$output_objdir/$output_la-$k.$objext
98636aec45a7Smrg	      eval test_cmds=\"$reload_cmds\"
98646aec45a7Smrg	      func_len " $test_cmds"
98656aec45a7Smrg	      len0=$func_len_result
98666aec45a7Smrg	      len=$len0
98676aec45a7Smrg
98686aec45a7Smrg	      # Loop over the list of objects to be linked.
98696aec45a7Smrg	      for obj in $save_libobjs
98706aec45a7Smrg	      do
98716aec45a7Smrg		func_len " $obj"
98726aec45a7Smrg		func_arith $len + $func_len_result
98736aec45a7Smrg		len=$func_arith_result
9874300bf1aeSmrg		if test -z "$objlist" ||
98756aec45a7Smrg		   test "$len" -lt "$max_cmd_len"; then
98766aec45a7Smrg		  func_append objlist " $obj"
98776aec45a7Smrg		else
98786aec45a7Smrg		  # The command $test_cmds is almost too long, add a
98796aec45a7Smrg		  # command to the queue.
9880300bf1aeSmrg		  if test 1 -eq "$k"; then
98816aec45a7Smrg		    # The first file doesn't have a previous command to add.
98826aec45a7Smrg		    reload_objs=$objlist
98836aec45a7Smrg		    eval concat_cmds=\"$reload_cmds\"
98846aec45a7Smrg		  else
98856aec45a7Smrg		    # All subsequent reloadable object files will link in
98866aec45a7Smrg		    # the last one created.
98876aec45a7Smrg		    reload_objs="$objlist $last_robj"
98886aec45a7Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
98896aec45a7Smrg		  fi
9890300bf1aeSmrg		  last_robj=$output_objdir/$output_la-$k.$objext
98916aec45a7Smrg		  func_arith $k + 1
98926aec45a7Smrg		  k=$func_arith_result
9893300bf1aeSmrg		  output=$output_objdir/$output_la-$k.$objext
98946aec45a7Smrg		  objlist=" $obj"
98956aec45a7Smrg		  func_len " $last_robj"
98966aec45a7Smrg		  func_arith $len0 + $func_len_result
98976aec45a7Smrg		  len=$func_arith_result
98986aec45a7Smrg		fi
98996aec45a7Smrg	      done
99006aec45a7Smrg	      # Handle the remaining objects by creating one last
99016aec45a7Smrg	      # reloadable object file.  All subsequent reloadable object
99026aec45a7Smrg	      # files will link in the last one created.
99036aec45a7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
99046aec45a7Smrg	      reload_objs="$objlist $last_robj"
9905300bf1aeSmrg	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
99066aec45a7Smrg	      if test -n "$last_robj"; then
9907300bf1aeSmrg	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
99086aec45a7Smrg	      fi
9909aa9e3350Smrg	      func_append delfiles " $output"
99106aec45a7Smrg
99116aec45a7Smrg	    else
99126aec45a7Smrg	      output=
99136aec45a7Smrg	    fi
9914ab47cfaaSmrg
9915300bf1aeSmrg	    ${skipped_export-false} && {
9916300bf1aeSmrg	      func_verbose "generating symbol list for '$libname.la'"
9917300bf1aeSmrg	      export_symbols=$output_objdir/$libname.exp
99186aec45a7Smrg	      $opt_dry_run || $RM $export_symbols
99196aec45a7Smrg	      libobjs=$output
99206aec45a7Smrg	      # Append the command to create the export file.
99216aec45a7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
99226aec45a7Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
99236aec45a7Smrg	      if test -n "$last_robj"; then
99246aec45a7Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
99256aec45a7Smrg	      fi
9926300bf1aeSmrg	    }
9927ab47cfaaSmrg
99286aec45a7Smrg	    test -n "$save_libobjs" &&
99296aec45a7Smrg	      func_verbose "creating a temporary reloadable object file: $output"
9930ab47cfaaSmrg
99316aec45a7Smrg	    # Loop through the commands generated above and execute them.
9932300bf1aeSmrg	    save_ifs=$IFS; IFS='~'
99336aec45a7Smrg	    for cmd in $concat_cmds; do
9934300bf1aeSmrg	      IFS=$save_ifs
9935300bf1aeSmrg	      $opt_quiet || {
99366aec45a7Smrg		  func_quote_for_expand "$cmd"
99376aec45a7Smrg		  eval "func_echo $func_quote_for_expand_result"
99386aec45a7Smrg	      }
99396aec45a7Smrg	      $opt_dry_run || eval "$cmd" || {
99406aec45a7Smrg		lt_exit=$?
99416aec45a7Smrg
99426aec45a7Smrg		# Restore the uninstalled library and exit
9943300bf1aeSmrg		if test relink = "$opt_mode"; then
99446aec45a7Smrg		  ( cd "$output_objdir" && \
99456aec45a7Smrg		    $RM "${realname}T" && \
99466aec45a7Smrg		    $MV "${realname}U" "$realname" )
99476aec45a7Smrg		fi
9948ab47cfaaSmrg
99496aec45a7Smrg		exit $lt_exit
99506aec45a7Smrg	      }
99516aec45a7Smrg	    done
9952300bf1aeSmrg	    IFS=$save_ifs
9953ab47cfaaSmrg
99546aec45a7Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
99556aec45a7Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
99566aec45a7Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
99571473d951Smrg	    fi
99581473d951Smrg	  fi
9959ab47cfaaSmrg
9960300bf1aeSmrg          ${skipped_export-false} && {
99616aec45a7Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
9962300bf1aeSmrg	      tmp_export_symbols=$export_symbols
9963300bf1aeSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
99646aec45a7Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
99656aec45a7Smrg	    fi
9966ab47cfaaSmrg
99676aec45a7Smrg	    if test -n "$orig_export_symbols"; then
99686aec45a7Smrg	      # The given exports_symbols file has to be filtered, so filter it.
9969300bf1aeSmrg	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
99706aec45a7Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
9971300bf1aeSmrg	      # 's' commands, which not all seds can handle. GNU sed should be fine
99726aec45a7Smrg	      # though. Also, the filter scales superlinearly with the number of
99736aec45a7Smrg	      # global variables. join(1) would be nice here, but unfortunately
99746aec45a7Smrg	      # isn't a blessed tool.
99756aec45a7Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9976aa9e3350Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
99776aec45a7Smrg	      export_symbols=$output_objdir/$libname.def
99786aec45a7Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
99796aec45a7Smrg	    fi
9980300bf1aeSmrg	  }
99811473d951Smrg
99826aec45a7Smrg	  libobjs=$output
99836aec45a7Smrg	  # Restore the value of output.
99846aec45a7Smrg	  output=$save_output
99855c42550eSmrg
99866aec45a7Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
99876aec45a7Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
99886aec45a7Smrg	    test "X$libobjs" = "X " && libobjs=
99896aec45a7Smrg	  fi
99906aec45a7Smrg	  # Expand the library linking commands again to reset the
99916aec45a7Smrg	  # value of $libobjs for piecewise linking.
99926aec45a7Smrg
99936aec45a7Smrg	  # Do each of the archive commands.
9994300bf1aeSmrg	  if test yes = "$module" && test -n "$module_cmds"; then
99956aec45a7Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
99966aec45a7Smrg	      cmds=$module_expsym_cmds
9997ab47cfaaSmrg	    else
99986aec45a7Smrg	      cmds=$module_cmds
9999ab47cfaaSmrg	    fi
10000ab47cfaaSmrg	  else
100016aec45a7Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
100026aec45a7Smrg	      cmds=$archive_expsym_cmds
100036aec45a7Smrg	    else
100046aec45a7Smrg	      cmds=$archive_cmds
100056aec45a7Smrg	    fi
10006ab47cfaaSmrg	  fi
10007ab47cfaaSmrg	fi
10008ab47cfaaSmrg
100096aec45a7Smrg	if test -n "$delfiles"; then
100106aec45a7Smrg	  # Append the command to remove temporary files to $cmds.
100116aec45a7Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
100126aec45a7Smrg	fi
10013ab47cfaaSmrg
100146aec45a7Smrg	# Add any objects from preloaded convenience libraries
100156aec45a7Smrg	if test -n "$dlprefiles"; then
10016300bf1aeSmrg	  gentop=$output_objdir/${outputname}x
10017aa9e3350Smrg	  func_append generated " $gentop"
10018ab47cfaaSmrg
100196aec45a7Smrg	  func_extract_archives $gentop $dlprefiles
10020aa9e3350Smrg	  func_append libobjs " $func_extract_archives_result"
100216aec45a7Smrg	  test "X$libobjs" = "X " && libobjs=
100221473d951Smrg	fi
10023ab47cfaaSmrg
10024300bf1aeSmrg	save_ifs=$IFS; IFS='~'
100256aec45a7Smrg	for cmd in $cmds; do
10026300bf1aeSmrg	  IFS=$sp$nl
100276aec45a7Smrg	  eval cmd=\"$cmd\"
10028300bf1aeSmrg	  IFS=$save_ifs
10029300bf1aeSmrg	  $opt_quiet || {
100306aec45a7Smrg	    func_quote_for_expand "$cmd"
100316aec45a7Smrg	    eval "func_echo $func_quote_for_expand_result"
100326aec45a7Smrg	  }
100336aec45a7Smrg	  $opt_dry_run || eval "$cmd" || {
100346aec45a7Smrg	    lt_exit=$?
10035ab47cfaaSmrg
100366aec45a7Smrg	    # Restore the uninstalled library and exit
10037300bf1aeSmrg	    if test relink = "$opt_mode"; then
100386aec45a7Smrg	      ( cd "$output_objdir" && \
100396aec45a7Smrg	        $RM "${realname}T" && \
100406aec45a7Smrg		$MV "${realname}U" "$realname" )
100415c42550eSmrg	    fi
10042ab47cfaaSmrg
100436aec45a7Smrg	    exit $lt_exit
100446aec45a7Smrg	  }
100456aec45a7Smrg	done
10046300bf1aeSmrg	IFS=$save_ifs
10047ab47cfaaSmrg
100486aec45a7Smrg	# Restore the uninstalled library and exit
10049300bf1aeSmrg	if test relink = "$opt_mode"; then
100506aec45a7Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
10051ab47cfaaSmrg
100526aec45a7Smrg	  if test -n "$convenience"; then
100536aec45a7Smrg	    if test -z "$whole_archive_flag_spec"; then
100546aec45a7Smrg	      func_show_eval '${RM}r "$gentop"'
100556aec45a7Smrg	    fi
100566aec45a7Smrg	  fi
10057ab47cfaaSmrg
100586aec45a7Smrg	  exit $EXIT_SUCCESS
100596aec45a7Smrg	fi
100601473d951Smrg
100616aec45a7Smrg	# Create links to the real library.
100626aec45a7Smrg	for linkname in $linknames; do
100636aec45a7Smrg	  if test "$realname" != "$linkname"; then
100646aec45a7Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
100656aec45a7Smrg	  fi
100666aec45a7Smrg	done
100671473d951Smrg
100686aec45a7Smrg	# If -module or -export-dynamic was specified, set the dlname.
10069300bf1aeSmrg	if test yes = "$module" || test yes = "$export_dynamic"; then
100706aec45a7Smrg	  # On all known operating systems, these are identical.
10071300bf1aeSmrg	  dlname=$soname
100726aec45a7Smrg	fi
100736aec45a7Smrg      fi
100746aec45a7Smrg      ;;
100751473d951Smrg
100766aec45a7Smrg    obj)
10077300bf1aeSmrg      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
10078300bf1aeSmrg	func_warning "'-dlopen' is ignored for objects"
100796aec45a7Smrg      fi
100801473d951Smrg
100816aec45a7Smrg      case " $deplibs" in
100826aec45a7Smrg      *\ -l* | *\ -L*)
10083300bf1aeSmrg	func_warning "'-l' and '-L' are ignored for objects" ;;
100846aec45a7Smrg      esac
100851473d951Smrg
100866aec45a7Smrg      test -n "$rpath" && \
10087300bf1aeSmrg	func_warning "'-rpath' is ignored for objects"
100881473d951Smrg
100896aec45a7Smrg      test -n "$xrpath" && \
10090300bf1aeSmrg	func_warning "'-R' is ignored for objects"
100916aec45a7Smrg
100926aec45a7Smrg      test -n "$vinfo" && \
10093300bf1aeSmrg	func_warning "'-version-info' is ignored for objects"
10094ab47cfaaSmrg
100956aec45a7Smrg      test -n "$release" && \
10096300bf1aeSmrg	func_warning "'-release' is ignored for objects"
100975c42550eSmrg
100986aec45a7Smrg      case $output in
100996aec45a7Smrg      *.lo)
101006aec45a7Smrg	test -n "$objs$old_deplibs" && \
10101300bf1aeSmrg	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
101026aec45a7Smrg
101036aec45a7Smrg	libobj=$output
101046aec45a7Smrg	func_lo2o "$libobj"
101056aec45a7Smrg	obj=$func_lo2o_result
101066aec45a7Smrg	;;
101076aec45a7Smrg      *)
101086aec45a7Smrg	libobj=
10109300bf1aeSmrg	obj=$output
101105c42550eSmrg	;;
101111473d951Smrg      esac
10112ab47cfaaSmrg
101136aec45a7Smrg      # Delete the old objects.
101146aec45a7Smrg      $opt_dry_run || $RM $obj $libobj
10115ab47cfaaSmrg
101166aec45a7Smrg      # Objects from convenience libraries.  This assumes
101176aec45a7Smrg      # single-version convenience libraries.  Whenever we create
101186aec45a7Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
101196aec45a7Smrg      # the extraction.
101206aec45a7Smrg      reload_conv_objs=
101216aec45a7Smrg      gentop=
10122300bf1aeSmrg      # if reload_cmds runs $LD directly, get rid of -Wl from
10123300bf1aeSmrg      # whole_archive_flag_spec and hope we can get by with turning comma
10124300bf1aeSmrg      # into space.
10125300bf1aeSmrg      case $reload_cmds in
10126300bf1aeSmrg        *\$LD[\ \$]*) wl= ;;
10127300bf1aeSmrg      esac
101286aec45a7Smrg      if test -n "$convenience"; then
101296aec45a7Smrg	if test -n "$whole_archive_flag_spec"; then
101306aec45a7Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
10131300bf1aeSmrg	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
10132300bf1aeSmrg	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
101335c42550eSmrg	else
10134300bf1aeSmrg	  gentop=$output_objdir/${obj}x
10135aa9e3350Smrg	  func_append generated " $gentop"
101366aec45a7Smrg
101376aec45a7Smrg	  func_extract_archives $gentop $convenience
101386aec45a7Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
101395c42550eSmrg	fi
101406aec45a7Smrg      fi
10141ab47cfaaSmrg
10142aa9e3350Smrg      # If we're not building shared, we need to use non_pic_objs
10143300bf1aeSmrg      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
10144aa9e3350Smrg
101456aec45a7Smrg      # Create the old-style object.
10146300bf1aeSmrg      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
10147ab47cfaaSmrg
10148300bf1aeSmrg      output=$obj
101496aec45a7Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
10150ab47cfaaSmrg
101516aec45a7Smrg      # Exit if we aren't doing a library object file.
101526aec45a7Smrg      if test -z "$libobj"; then
101536aec45a7Smrg	if test -n "$gentop"; then
101546aec45a7Smrg	  func_show_eval '${RM}r "$gentop"'
101556aec45a7Smrg	fi
101565c42550eSmrg
101576aec45a7Smrg	exit $EXIT_SUCCESS
101585c42550eSmrg      fi
101595c42550eSmrg
10160300bf1aeSmrg      test yes = "$build_libtool_libs" || {
101616aec45a7Smrg	if test -n "$gentop"; then
101626aec45a7Smrg	  func_show_eval '${RM}r "$gentop"'
101636aec45a7Smrg	fi
101645c42550eSmrg
101656aec45a7Smrg	# Create an invalid libtool object if no PIC, so that we don't
101666aec45a7Smrg	# accidentally link it into a program.
101676aec45a7Smrg	# $show "echo timestamp > $libobj"
101686aec45a7Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
101696aec45a7Smrg	exit $EXIT_SUCCESS
10170300bf1aeSmrg      }
101715c42550eSmrg
10172300bf1aeSmrg      if test -n "$pic_flag" || test default != "$pic_mode"; then
101736aec45a7Smrg	# Only do commands if we really have different PIC objects.
101746aec45a7Smrg	reload_objs="$libobjs $reload_conv_objs"
10175300bf1aeSmrg	output=$libobj
101766aec45a7Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
101775c42550eSmrg      fi
101786aec45a7Smrg
101796aec45a7Smrg      if test -n "$gentop"; then
101806aec45a7Smrg	func_show_eval '${RM}r "$gentop"'
101816aec45a7Smrg      fi
101826aec45a7Smrg
101836aec45a7Smrg      exit $EXIT_SUCCESS
101845c42550eSmrg      ;;
10185ab47cfaaSmrg
101866aec45a7Smrg    prog)
101876aec45a7Smrg      case $host in
101886aec45a7Smrg	*cygwin*) func_stripname '' '.exe' "$output"
101896aec45a7Smrg	          output=$func_stripname_result.exe;;
101906aec45a7Smrg      esac
101916aec45a7Smrg      test -n "$vinfo" && \
10192300bf1aeSmrg	func_warning "'-version-info' is ignored for programs"
10193ab47cfaaSmrg
101946aec45a7Smrg      test -n "$release" && \
10195300bf1aeSmrg	func_warning "'-release' is ignored for programs"
10196ab47cfaaSmrg
10197300bf1aeSmrg      $preload \
10198300bf1aeSmrg	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
10199300bf1aeSmrg	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
102006aec45a7Smrg
102016aec45a7Smrg      case $host in
102026aec45a7Smrg      *-*-rhapsody* | *-*-darwin1.[012])
102036aec45a7Smrg	# On Rhapsody replace the C library is the System framework
102046aec45a7Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
102056aec45a7Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
102065c42550eSmrg	;;
102076aec45a7Smrg      esac
102085c42550eSmrg
102096aec45a7Smrg      case $host in
102106aec45a7Smrg      *-*-darwin*)
102116aec45a7Smrg	# Don't allow lazy linking, it breaks C++ global constructors
102126aec45a7Smrg	# But is supposedly fixed on 10.4 or later (yay!).
10213300bf1aeSmrg	if test CXX = "$tagname"; then
102146aec45a7Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
102156aec45a7Smrg	    10.[0123])
10216300bf1aeSmrg	      func_append compile_command " $wl-bind_at_load"
10217300bf1aeSmrg	      func_append finalize_command " $wl-bind_at_load"
102186aec45a7Smrg	    ;;
102196aec45a7Smrg	  esac
102205c42550eSmrg	fi
102216aec45a7Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
102226aec45a7Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
102236aec45a7Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
102246aec45a7Smrg	;;
102256aec45a7Smrg      esac
102265c42550eSmrg
102275c42550eSmrg
102286aec45a7Smrg      # move library search paths that coincide with paths to not yet
102296aec45a7Smrg      # installed libraries to the beginning of the library search list
102306aec45a7Smrg      new_libs=
102316aec45a7Smrg      for path in $notinst_path; do
102326aec45a7Smrg	case " $new_libs " in
102336aec45a7Smrg	*" -L$path/$objdir "*) ;;
102346aec45a7Smrg	*)
102356aec45a7Smrg	  case " $compile_deplibs " in
102366aec45a7Smrg	  *" -L$path/$objdir "*)
10237aa9e3350Smrg	    func_append new_libs " -L$path/$objdir" ;;
102381473d951Smrg	  esac
102396aec45a7Smrg	  ;;
102406aec45a7Smrg	esac
102416aec45a7Smrg      done
102426aec45a7Smrg      for deplib in $compile_deplibs; do
102436aec45a7Smrg	case $deplib in
102446aec45a7Smrg	-L*)
102456aec45a7Smrg	  case " $new_libs " in
102466aec45a7Smrg	  *" $deplib "*) ;;
10247aa9e3350Smrg	  *) func_append new_libs " $deplib" ;;
102481473d951Smrg	  esac
102496aec45a7Smrg	  ;;
10250aa9e3350Smrg	*) func_append new_libs " $deplib" ;;
102516aec45a7Smrg	esac
102526aec45a7Smrg      done
10253300bf1aeSmrg      compile_deplibs=$new_libs
10254ab47cfaaSmrg
102555c42550eSmrg
10256aa9e3350Smrg      func_append compile_command " $compile_deplibs"
10257aa9e3350Smrg      func_append finalize_command " $finalize_deplibs"
102585c42550eSmrg
102596aec45a7Smrg      if test -n "$rpath$xrpath"; then
102606aec45a7Smrg	# If the user specified any rpath flags, then add them.
102616aec45a7Smrg	for libdir in $rpath $xrpath; do
102626aec45a7Smrg	  # This is the magic to use -rpath.
102636aec45a7Smrg	  case "$finalize_rpath " in
102646aec45a7Smrg	  *" $libdir "*) ;;
10265aa9e3350Smrg	  *) func_append finalize_rpath " $libdir" ;;
102666aec45a7Smrg	  esac
102676aec45a7Smrg	done
102686aec45a7Smrg      fi
102695c42550eSmrg
102706aec45a7Smrg      # Now hardcode the library paths
102716aec45a7Smrg      rpath=
102726aec45a7Smrg      hardcode_libdirs=
102736aec45a7Smrg      for libdir in $compile_rpath $finalize_rpath; do
102746aec45a7Smrg	if test -n "$hardcode_libdir_flag_spec"; then
102756aec45a7Smrg	  if test -n "$hardcode_libdir_separator"; then
102766aec45a7Smrg	    if test -z "$hardcode_libdirs"; then
10277300bf1aeSmrg	      hardcode_libdirs=$libdir
102786aec45a7Smrg	    else
102796aec45a7Smrg	      # Just accumulate the unique libdirs.
102806aec45a7Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
102816aec45a7Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
102826aec45a7Smrg		;;
102836aec45a7Smrg	      *)
10284aa9e3350Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
102856aec45a7Smrg		;;
102866aec45a7Smrg	      esac
102876aec45a7Smrg	    fi
102885c42550eSmrg	  else
102896aec45a7Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10290aa9e3350Smrg	    func_append rpath " $flag"
102915c42550eSmrg	  fi
102926aec45a7Smrg	elif test -n "$runpath_var"; then
102936aec45a7Smrg	  case "$perm_rpath " in
102946aec45a7Smrg	  *" $libdir "*) ;;
10295aa9e3350Smrg	  *) func_append perm_rpath " $libdir" ;;
102966aec45a7Smrg	  esac
102976aec45a7Smrg	fi
102986aec45a7Smrg	case $host in
102996aec45a7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
10300300bf1aeSmrg	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
103016aec45a7Smrg	  case :$dllsearchpath: in
103026aec45a7Smrg	  *":$libdir:"*) ;;
103036aec45a7Smrg	  ::) dllsearchpath=$libdir;;
10304aa9e3350Smrg	  *) func_append dllsearchpath ":$libdir";;
103056aec45a7Smrg	  esac
103066aec45a7Smrg	  case :$dllsearchpath: in
103076aec45a7Smrg	  *":$testbindir:"*) ;;
103086aec45a7Smrg	  ::) dllsearchpath=$testbindir;;
10309aa9e3350Smrg	  *) func_append dllsearchpath ":$testbindir";;
103106aec45a7Smrg	  esac
103116aec45a7Smrg	  ;;
103126aec45a7Smrg	esac
103136aec45a7Smrg      done
103146aec45a7Smrg      # Substitute the hardcoded libdirs into the rpath.
103156aec45a7Smrg      if test -n "$hardcode_libdir_separator" &&
103166aec45a7Smrg	 test -n "$hardcode_libdirs"; then
10317300bf1aeSmrg	libdir=$hardcode_libdirs
103186aec45a7Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
103196aec45a7Smrg      fi
10320300bf1aeSmrg      compile_rpath=$rpath
103215c42550eSmrg
103226aec45a7Smrg      rpath=
103236aec45a7Smrg      hardcode_libdirs=
103246aec45a7Smrg      for libdir in $finalize_rpath; do
103256aec45a7Smrg	if test -n "$hardcode_libdir_flag_spec"; then
103266aec45a7Smrg	  if test -n "$hardcode_libdir_separator"; then
103276aec45a7Smrg	    if test -z "$hardcode_libdirs"; then
10328300bf1aeSmrg	      hardcode_libdirs=$libdir
103296aec45a7Smrg	    else
103306aec45a7Smrg	      # Just accumulate the unique libdirs.
103316aec45a7Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
103326aec45a7Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
103336aec45a7Smrg		;;
103346aec45a7Smrg	      *)
10335aa9e3350Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
103366aec45a7Smrg		;;
103376aec45a7Smrg	      esac
103386aec45a7Smrg	    fi
10339ab47cfaaSmrg	  else
103406aec45a7Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
10341aa9e3350Smrg	    func_append rpath " $flag"
10342ab47cfaaSmrg	  fi
103436aec45a7Smrg	elif test -n "$runpath_var"; then
103446aec45a7Smrg	  case "$finalize_perm_rpath " in
103456aec45a7Smrg	  *" $libdir "*) ;;
10346aa9e3350Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
103476aec45a7Smrg	  esac
10348ab47cfaaSmrg	fi
103496aec45a7Smrg      done
103506aec45a7Smrg      # Substitute the hardcoded libdirs into the rpath.
103516aec45a7Smrg      if test -n "$hardcode_libdir_separator" &&
103526aec45a7Smrg	 test -n "$hardcode_libdirs"; then
10353300bf1aeSmrg	libdir=$hardcode_libdirs
103546aec45a7Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
103556aec45a7Smrg      fi
10356300bf1aeSmrg      finalize_rpath=$rpath
10357ab47cfaaSmrg
10358300bf1aeSmrg      if test -n "$libobjs" && test yes = "$build_old_libs"; then
103596aec45a7Smrg	# Transform all the library objects into standard objects.
103606aec45a7Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
103616aec45a7Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
103626aec45a7Smrg      fi
10363ab47cfaaSmrg
10364300bf1aeSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" false
10365ab47cfaaSmrg
103666aec45a7Smrg      # template prelinking step
103676aec45a7Smrg      if test -n "$prelink_cmds"; then
103686aec45a7Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
103696aec45a7Smrg      fi
10370ab47cfaaSmrg
10371300bf1aeSmrg      wrappers_required=:
103726aec45a7Smrg      case $host in
103736aec45a7Smrg      *cegcc* | *mingw32ce*)
103746aec45a7Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
10375300bf1aeSmrg        wrappers_required=false
103766aec45a7Smrg        ;;
103776aec45a7Smrg      *cygwin* | *mingw* )
10378300bf1aeSmrg        test yes = "$build_libtool_libs" || wrappers_required=false
103796aec45a7Smrg        ;;
103806aec45a7Smrg      *)
10381300bf1aeSmrg        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
10382300bf1aeSmrg          wrappers_required=false
103836aec45a7Smrg        fi
103846aec45a7Smrg        ;;
103856aec45a7Smrg      esac
10386300bf1aeSmrg      $wrappers_required || {
103876aec45a7Smrg	# Replace the output file specification.
103886aec45a7Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10389300bf1aeSmrg	link_command=$compile_command$compile_rpath
10390ab47cfaaSmrg
103916aec45a7Smrg	# We have no uninstalled library dependencies, so finalize right now.
103926aec45a7Smrg	exit_status=0
103936aec45a7Smrg	func_show_eval "$link_command" 'exit_status=$?'
10394ab47cfaaSmrg
10395aa9e3350Smrg	if test -n "$postlink_cmds"; then
10396aa9e3350Smrg	  func_to_tool_file "$output"
10397aa9e3350Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10398aa9e3350Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10399aa9e3350Smrg	fi
10400aa9e3350Smrg
104016aec45a7Smrg	# Delete the generated files.
10402300bf1aeSmrg	if test -f "$output_objdir/${outputname}S.$objext"; then
10403300bf1aeSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
10404ab47cfaaSmrg	fi
10405ab47cfaaSmrg
104066aec45a7Smrg	exit $exit_status
10407300bf1aeSmrg      }
10408ab47cfaaSmrg
104096aec45a7Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
104106aec45a7Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
104116aec45a7Smrg      fi
104126aec45a7Smrg      if test -n "$finalize_shlibpath"; then
104136aec45a7Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
104146aec45a7Smrg      fi
104155c42550eSmrg
104166aec45a7Smrg      compile_var=
104176aec45a7Smrg      finalize_var=
104186aec45a7Smrg      if test -n "$runpath_var"; then
104196aec45a7Smrg	if test -n "$perm_rpath"; then
104206aec45a7Smrg	  # We should set the runpath_var.
104216aec45a7Smrg	  rpath=
104226aec45a7Smrg	  for dir in $perm_rpath; do
10423aa9e3350Smrg	    func_append rpath "$dir:"
104246aec45a7Smrg	  done
104256aec45a7Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10426ab47cfaaSmrg	fi
104276aec45a7Smrg	if test -n "$finalize_perm_rpath"; then
104286aec45a7Smrg	  # We should set the runpath_var.
104296aec45a7Smrg	  rpath=
104306aec45a7Smrg	  for dir in $finalize_perm_rpath; do
10431aa9e3350Smrg	    func_append rpath "$dir:"
104326aec45a7Smrg	  done
104336aec45a7Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
10434ab47cfaaSmrg	fi
104356aec45a7Smrg      fi
10436ab47cfaaSmrg
10437300bf1aeSmrg      if test yes = "$no_install"; then
104386aec45a7Smrg	# We don't need to create a wrapper script.
10439300bf1aeSmrg	link_command=$compile_var$compile_command$compile_rpath
104406aec45a7Smrg	# Replace the output file specification.
104416aec45a7Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
104426aec45a7Smrg	# Delete the old output file.
104436aec45a7Smrg	$opt_dry_run || $RM $output
104446aec45a7Smrg	# Link the executable and exit
104456aec45a7Smrg	func_show_eval "$link_command" 'exit $?'
10446aa9e3350Smrg
10447aa9e3350Smrg	if test -n "$postlink_cmds"; then
10448aa9e3350Smrg	  func_to_tool_file "$output"
10449aa9e3350Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10450aa9e3350Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
10451aa9e3350Smrg	fi
10452aa9e3350Smrg
104535c42550eSmrg	exit $EXIT_SUCCESS
104546aec45a7Smrg      fi
104551473d951Smrg
10456300bf1aeSmrg      case $hardcode_action,$fast_install in
10457300bf1aeSmrg        relink,*)
10458300bf1aeSmrg	  # Fast installation is not supported
10459300bf1aeSmrg	  link_command=$compile_var$compile_command$compile_rpath
10460300bf1aeSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
104616aec45a7Smrg
10462300bf1aeSmrg	  func_warning "this platform does not like uninstalled shared libraries"
10463300bf1aeSmrg	  func_warning "'$output' will be relinked during installation"
10464300bf1aeSmrg	  ;;
10465300bf1aeSmrg        *,yes)
10466300bf1aeSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
10467300bf1aeSmrg	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
10468300bf1aeSmrg          ;;
10469300bf1aeSmrg	*,no)
10470300bf1aeSmrg	  link_command=$compile_var$compile_command$compile_rpath
10471300bf1aeSmrg	  relink_command=$finalize_var$finalize_command$finalize_rpath
10472300bf1aeSmrg          ;;
10473300bf1aeSmrg	*,needless)
10474300bf1aeSmrg	  link_command=$finalize_var$compile_command$finalize_rpath
10475300bf1aeSmrg	  relink_command=
10476300bf1aeSmrg          ;;
10477300bf1aeSmrg      esac
10478ab47cfaaSmrg
104796aec45a7Smrg      # Replace the output file specification.
104806aec45a7Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10481ab47cfaaSmrg
104826aec45a7Smrg      # Delete the old output files.
104836aec45a7Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10484ab47cfaaSmrg
104856aec45a7Smrg      func_show_eval "$link_command" 'exit $?'
104865c42550eSmrg
10487aa9e3350Smrg      if test -n "$postlink_cmds"; then
10488aa9e3350Smrg	func_to_tool_file "$output_objdir/$outputname"
10489aa9e3350Smrg	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'`
10490aa9e3350Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
10491aa9e3350Smrg      fi
10492aa9e3350Smrg
104936aec45a7Smrg      # Now create the wrapper script.
104946aec45a7Smrg      func_verbose "creating $output"
104955c42550eSmrg
104966aec45a7Smrg      # Quote the relink command for shipping.
104976aec45a7Smrg      if test -n "$relink_command"; then
104986aec45a7Smrg	# Preserve any variables that may affect compiler behavior
104996aec45a7Smrg	for var in $variables_saved_for_relink; do
105006aec45a7Smrg	  if eval test -z \"\${$var+set}\"; then
105016aec45a7Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
105026aec45a7Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
105036aec45a7Smrg	    relink_command="$var=; export $var; $relink_command"
10504ab47cfaaSmrg	  else
105056aec45a7Smrg	    func_quote_for_eval "$var_value"
105066aec45a7Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10507ab47cfaaSmrg	  fi
105086aec45a7Smrg	done
105096aec45a7Smrg	relink_command="(cd `pwd`; $relink_command)"
105106aec45a7Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
105116aec45a7Smrg      fi
105121473d951Smrg
105136aec45a7Smrg      # Only actually do things if not in dry run mode.
105146aec45a7Smrg      $opt_dry_run || {
105156aec45a7Smrg	# win32 will think the script is a binary if it has
105166aec45a7Smrg	# a .exe suffix, so we strip it off here.
105176aec45a7Smrg	case $output in
105186aec45a7Smrg	  *.exe) func_stripname '' '.exe' "$output"
105196aec45a7Smrg	         output=$func_stripname_result ;;
105206aec45a7Smrg	esac
105216aec45a7Smrg	# test for cygwin because mv fails w/o .exe extensions
105226aec45a7Smrg	case $host in
105236aec45a7Smrg	  *cygwin*)
105246aec45a7Smrg	    exeext=.exe
105256aec45a7Smrg	    func_stripname '' '.exe' "$outputname"
105266aec45a7Smrg	    outputname=$func_stripname_result ;;
105276aec45a7Smrg	  *) exeext= ;;
10528ab47cfaaSmrg	esac
105296aec45a7Smrg	case $host in
105306aec45a7Smrg	  *cygwin* | *mingw* )
105316aec45a7Smrg	    func_dirname_and_basename "$output" "" "."
105326aec45a7Smrg	    output_name=$func_basename_result
105336aec45a7Smrg	    output_path=$func_dirname_result
10534300bf1aeSmrg	    cwrappersource=$output_path/$objdir/lt-$output_name.c
10535300bf1aeSmrg	    cwrapper=$output_path/$output_name.exe
105366aec45a7Smrg	    $RM $cwrappersource $cwrapper
105376aec45a7Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
105386aec45a7Smrg
105396aec45a7Smrg	    func_emit_cwrapperexe_src > $cwrappersource
105406aec45a7Smrg
105416aec45a7Smrg	    # The wrapper executable is built using the $host compiler,
105426aec45a7Smrg	    # because it contains $host paths and files. If cross-
105436aec45a7Smrg	    # compiling, it, like the target executable, must be
105446aec45a7Smrg	    # executed on the $host or under an emulation environment.
105456aec45a7Smrg	    $opt_dry_run || {
105466aec45a7Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
105476aec45a7Smrg	      $STRIP $cwrapper
105486aec45a7Smrg	    }
10549ab47cfaaSmrg
105506aec45a7Smrg	    # Now, create the wrapper script for func_source use:
105516aec45a7Smrg	    func_ltwrapper_scriptname $cwrapper
105526aec45a7Smrg	    $RM $func_ltwrapper_scriptname_result
105536aec45a7Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
105546aec45a7Smrg	    $opt_dry_run || {
105556aec45a7Smrg	      # note: this script will not be executed, so do not chmod.
10556300bf1aeSmrg	      if test "x$build" = "x$host"; then
105576aec45a7Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
105586aec45a7Smrg	      else
105596aec45a7Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
105606aec45a7Smrg	      fi
105616aec45a7Smrg	    }
105626aec45a7Smrg	  ;;
105636aec45a7Smrg	  * )
105646aec45a7Smrg	    $RM $output
105656aec45a7Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10566ab47cfaaSmrg
105676aec45a7Smrg	    func_emit_wrapper no > $output
105686aec45a7Smrg	    chmod +x $output
105696aec45a7Smrg	  ;;
105706aec45a7Smrg	esac
105716aec45a7Smrg      }
105726aec45a7Smrg      exit $EXIT_SUCCESS
105736aec45a7Smrg      ;;
105746aec45a7Smrg    esac
10575ab47cfaaSmrg
105766aec45a7Smrg    # See if we need to build an old-fashioned archive.
105776aec45a7Smrg    for oldlib in $oldlibs; do
10578ab47cfaaSmrg
10579300bf1aeSmrg      case $build_libtool_libs in
10580300bf1aeSmrg        convenience)
10581300bf1aeSmrg	  oldobjs="$libobjs_save $symfileobj"
10582300bf1aeSmrg	  addlibs=$convenience
105836aec45a7Smrg	  build_libtool_libs=no
10584300bf1aeSmrg	  ;;
10585300bf1aeSmrg	module)
10586300bf1aeSmrg	  oldobjs=$libobjs_save
10587300bf1aeSmrg	  addlibs=$old_convenience
10588300bf1aeSmrg	  build_libtool_libs=no
10589300bf1aeSmrg          ;;
10590300bf1aeSmrg	*)
105916aec45a7Smrg	  oldobjs="$old_deplibs $non_pic_objects"
10592300bf1aeSmrg	  $preload && test -f "$symfileobj" \
10593300bf1aeSmrg	    && func_append oldobjs " $symfileobj"
10594300bf1aeSmrg	  addlibs=$old_convenience
10595300bf1aeSmrg	  ;;
10596300bf1aeSmrg      esac
10597ab47cfaaSmrg
105986aec45a7Smrg      if test -n "$addlibs"; then
10599300bf1aeSmrg	gentop=$output_objdir/${outputname}x
10600aa9e3350Smrg	func_append generated " $gentop"
10601ab47cfaaSmrg
106026aec45a7Smrg	func_extract_archives $gentop $addlibs
10603aa9e3350Smrg	func_append oldobjs " $func_extract_archives_result"
106046aec45a7Smrg      fi
10605ab47cfaaSmrg
106066aec45a7Smrg      # Do each command in the archive commands.
10607300bf1aeSmrg      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
106086aec45a7Smrg	cmds=$old_archive_from_new_cmds
106096aec45a7Smrg      else
10610ab47cfaaSmrg
106116aec45a7Smrg	# Add any objects from preloaded convenience libraries
106126aec45a7Smrg	if test -n "$dlprefiles"; then
10613300bf1aeSmrg	  gentop=$output_objdir/${outputname}x
10614aa9e3350Smrg	  func_append generated " $gentop"
10615ab47cfaaSmrg
106166aec45a7Smrg	  func_extract_archives $gentop $dlprefiles
10617aa9e3350Smrg	  func_append oldobjs " $func_extract_archives_result"
106186aec45a7Smrg	fi
10619ab47cfaaSmrg
106206aec45a7Smrg	# POSIX demands no paths to be encoded in archives.  We have
106216aec45a7Smrg	# to avoid creating archives with duplicate basenames if we
106226aec45a7Smrg	# might have to extract them afterwards, e.g., when creating a
106236aec45a7Smrg	# static archive out of a convenience library, or when linking
106246aec45a7Smrg	# the entirety of a libtool archive into another (currently
106256aec45a7Smrg	# not supported by libtool).
106266aec45a7Smrg	if (for obj in $oldobjs
106276aec45a7Smrg	    do
106286aec45a7Smrg	      func_basename "$obj"
106296aec45a7Smrg	      $ECHO "$func_basename_result"
106306aec45a7Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
106316aec45a7Smrg	  :
106326aec45a7Smrg	else
106336aec45a7Smrg	  echo "copying selected object files to avoid basename conflicts..."
10634300bf1aeSmrg	  gentop=$output_objdir/${outputname}x
10635aa9e3350Smrg	  func_append generated " $gentop"
106366aec45a7Smrg	  func_mkdir_p "$gentop"
106376aec45a7Smrg	  save_oldobjs=$oldobjs
106386aec45a7Smrg	  oldobjs=
106396aec45a7Smrg	  counter=1
106406aec45a7Smrg	  for obj in $save_oldobjs
106416aec45a7Smrg	  do
106426aec45a7Smrg	    func_basename "$obj"
10643300bf1aeSmrg	    objbase=$func_basename_result
106446aec45a7Smrg	    case " $oldobjs " in
106456aec45a7Smrg	    " ") oldobjs=$obj ;;
106466aec45a7Smrg	    *[\ /]"$objbase "*)
106476aec45a7Smrg	      while :; do
106486aec45a7Smrg		# Make sure we don't pick an alternate name that also
106496aec45a7Smrg		# overlaps.
106506aec45a7Smrg		newobj=lt$counter-$objbase
106516aec45a7Smrg		func_arith $counter + 1
106526aec45a7Smrg		counter=$func_arith_result
106536aec45a7Smrg		case " $oldobjs " in
106546aec45a7Smrg		*[\ /]"$newobj "*) ;;
106556aec45a7Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
106566aec45a7Smrg		esac
106576aec45a7Smrg	      done
106586aec45a7Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10659aa9e3350Smrg	      func_append oldobjs " $gentop/$newobj"
106606aec45a7Smrg	      ;;
10661aa9e3350Smrg	    *) func_append oldobjs " $obj" ;;
106626aec45a7Smrg	    esac
10663ab47cfaaSmrg	  done
106641473d951Smrg	fi
10665aa9e3350Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10666aa9e3350Smrg	tool_oldlib=$func_to_tool_file_result
106676aec45a7Smrg	eval cmds=\"$old_archive_cmds\"
106685c42550eSmrg
106696aec45a7Smrg	func_len " $cmds"
106706aec45a7Smrg	len=$func_len_result
106716aec45a7Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
106726aec45a7Smrg	  cmds=$old_archive_cmds
10673aa9e3350Smrg	elif test -n "$archiver_list_spec"; then
10674aa9e3350Smrg	  func_verbose "using command file archive linking..."
10675aa9e3350Smrg	  for obj in $oldobjs
10676aa9e3350Smrg	  do
10677aa9e3350Smrg	    func_to_tool_file "$obj"
10678aa9e3350Smrg	    $ECHO "$func_to_tool_file_result"
10679aa9e3350Smrg	  done > $output_objdir/$libname.libcmd
10680aa9e3350Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
10681aa9e3350Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10682aa9e3350Smrg	  cmds=$old_archive_cmds
106836aec45a7Smrg	else
106846aec45a7Smrg	  # the command line is too long to link in one step, link in parts
106856aec45a7Smrg	  func_verbose "using piecewise archive linking..."
106866aec45a7Smrg	  save_RANLIB=$RANLIB
106876aec45a7Smrg	  RANLIB=:
106886aec45a7Smrg	  objlist=
106896aec45a7Smrg	  concat_cmds=
106906aec45a7Smrg	  save_oldobjs=$oldobjs
106916aec45a7Smrg	  oldobjs=
106926aec45a7Smrg	  # Is there a better way of finding the last object in the list?
106936aec45a7Smrg	  for obj in $save_oldobjs
106946aec45a7Smrg	  do
106956aec45a7Smrg	    last_oldobj=$obj
106966aec45a7Smrg	  done
106976aec45a7Smrg	  eval test_cmds=\"$old_archive_cmds\"
106986aec45a7Smrg	  func_len " $test_cmds"
106996aec45a7Smrg	  len0=$func_len_result
107006aec45a7Smrg	  len=$len0
107016aec45a7Smrg	  for obj in $save_oldobjs
107026aec45a7Smrg	  do
107036aec45a7Smrg	    func_len " $obj"
107046aec45a7Smrg	    func_arith $len + $func_len_result
107056aec45a7Smrg	    len=$func_arith_result
107066aec45a7Smrg	    func_append objlist " $obj"
107076aec45a7Smrg	    if test "$len" -lt "$max_cmd_len"; then
107086aec45a7Smrg	      :
107096aec45a7Smrg	    else
107106aec45a7Smrg	      # the above command should be used before it gets too long
107116aec45a7Smrg	      oldobjs=$objlist
10712300bf1aeSmrg	      if test "$obj" = "$last_oldobj"; then
107136aec45a7Smrg		RANLIB=$save_RANLIB
107146aec45a7Smrg	      fi
107156aec45a7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10716300bf1aeSmrg	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
107176aec45a7Smrg	      objlist=
107186aec45a7Smrg	      len=$len0
107196aec45a7Smrg	    fi
107206aec45a7Smrg	  done
107216aec45a7Smrg	  RANLIB=$save_RANLIB
107226aec45a7Smrg	  oldobjs=$objlist
10723300bf1aeSmrg	  if test -z "$oldobjs"; then
107246aec45a7Smrg	    eval cmds=\"\$concat_cmds\"
107256aec45a7Smrg	  else
107266aec45a7Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
107276aec45a7Smrg	  fi
107286aec45a7Smrg	fi
107296aec45a7Smrg      fi
107306aec45a7Smrg      func_execute_cmds "$cmds" 'exit $?'
10731ab47cfaaSmrg    done
10732ab47cfaaSmrg
107336aec45a7Smrg    test -n "$generated" && \
107346aec45a7Smrg      func_show_eval "${RM}r$generated"
10735ab47cfaaSmrg
107366aec45a7Smrg    # Now create the libtool archive.
107376aec45a7Smrg    case $output in
107386aec45a7Smrg    *.la)
107396aec45a7Smrg      old_library=
10740300bf1aeSmrg      test yes = "$build_old_libs" && old_library=$libname.$libext
107416aec45a7Smrg      func_verbose "creating $output"
107421473d951Smrg
107436aec45a7Smrg      # Preserve any variables that may affect compiler behavior
107446aec45a7Smrg      for var in $variables_saved_for_relink; do
107456aec45a7Smrg	if eval test -z \"\${$var+set}\"; then
107466aec45a7Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
107476aec45a7Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
107486aec45a7Smrg	  relink_command="$var=; export $var; $relink_command"
107495c42550eSmrg	else
107506aec45a7Smrg	  func_quote_for_eval "$var_value"
107516aec45a7Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
107525c42550eSmrg	fi
107536aec45a7Smrg      done
107546aec45a7Smrg      # Quote the link command for shipping.
10755300bf1aeSmrg      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
107566aec45a7Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10757300bf1aeSmrg      if test yes = "$hardcode_automatic"; then
107586aec45a7Smrg	relink_command=
107596aec45a7Smrg      fi
10760ab47cfaaSmrg
107616aec45a7Smrg      # Only create the output if not a dry run.
107626aec45a7Smrg      $opt_dry_run || {
107636aec45a7Smrg	for installed in no yes; do
10764300bf1aeSmrg	  if test yes = "$installed"; then
107656aec45a7Smrg	    if test -z "$install_libdir"; then
107666aec45a7Smrg	      break
107676aec45a7Smrg	    fi
10768300bf1aeSmrg	    output=$output_objdir/${outputname}i
107696aec45a7Smrg	    # Replace all uninstalled libtool libraries with the installed ones
107706aec45a7Smrg	    newdependency_libs=
107716aec45a7Smrg	    for deplib in $dependency_libs; do
107726aec45a7Smrg	      case $deplib in
107736aec45a7Smrg	      *.la)
107746aec45a7Smrg		func_basename "$deplib"
10775300bf1aeSmrg		name=$func_basename_result
10776aa9e3350Smrg		func_resolve_sysroot "$deplib"
10777300bf1aeSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
107786aec45a7Smrg		test -z "$libdir" && \
10779300bf1aeSmrg		  func_fatal_error "'$deplib' is not a valid libtool archive"
10780aa9e3350Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10781aa9e3350Smrg		;;
10782aa9e3350Smrg	      -L*)
10783aa9e3350Smrg		func_stripname -L '' "$deplib"
10784aa9e3350Smrg		func_replace_sysroot "$func_stripname_result"
10785aa9e3350Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
10786aa9e3350Smrg		;;
10787aa9e3350Smrg	      -R*)
10788aa9e3350Smrg		func_stripname -R '' "$deplib"
10789aa9e3350Smrg		func_replace_sysroot "$func_stripname_result"
10790aa9e3350Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
107916aec45a7Smrg		;;
10792aa9e3350Smrg	      *) func_append newdependency_libs " $deplib" ;;
107936aec45a7Smrg	      esac
107946aec45a7Smrg	    done
10795300bf1aeSmrg	    dependency_libs=$newdependency_libs
107966aec45a7Smrg	    newdlfiles=
107976aec45a7Smrg
107986aec45a7Smrg	    for lib in $dlfiles; do
107996aec45a7Smrg	      case $lib in
108006aec45a7Smrg	      *.la)
108016aec45a7Smrg	        func_basename "$lib"
10802300bf1aeSmrg		name=$func_basename_result
10803300bf1aeSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
108046aec45a7Smrg		test -z "$libdir" && \
10805300bf1aeSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10806aa9e3350Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
108076aec45a7Smrg		;;
10808aa9e3350Smrg	      *) func_append newdlfiles " $lib" ;;
108096aec45a7Smrg	      esac
108106aec45a7Smrg	    done
10811300bf1aeSmrg	    dlfiles=$newdlfiles
108126aec45a7Smrg	    newdlprefiles=
108136aec45a7Smrg	    for lib in $dlprefiles; do
108146aec45a7Smrg	      case $lib in
108156aec45a7Smrg	      *.la)
108166aec45a7Smrg		# Only pass preopened files to the pseudo-archive (for
108176aec45a7Smrg		# eventual linking with the app. that links it) if we
108186aec45a7Smrg		# didn't already link the preopened objects directly into
108196aec45a7Smrg		# the library:
108206aec45a7Smrg		func_basename "$lib"
10821300bf1aeSmrg		name=$func_basename_result
10822300bf1aeSmrg		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
108236aec45a7Smrg		test -z "$libdir" && \
10824300bf1aeSmrg		  func_fatal_error "'$lib' is not a valid libtool archive"
10825aa9e3350Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
108266aec45a7Smrg		;;
108276aec45a7Smrg	      esac
108286aec45a7Smrg	    done
10829300bf1aeSmrg	    dlprefiles=$newdlprefiles
108306aec45a7Smrg	  else
108316aec45a7Smrg	    newdlfiles=
108326aec45a7Smrg	    for lib in $dlfiles; do
108336aec45a7Smrg	      case $lib in
10834300bf1aeSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
108356aec45a7Smrg		*) abs=`pwd`"/$lib" ;;
108366aec45a7Smrg	      esac
10837aa9e3350Smrg	      func_append newdlfiles " $abs"
108386aec45a7Smrg	    done
10839300bf1aeSmrg	    dlfiles=$newdlfiles
108406aec45a7Smrg	    newdlprefiles=
108416aec45a7Smrg	    for lib in $dlprefiles; do
108426aec45a7Smrg	      case $lib in
10843300bf1aeSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
108446aec45a7Smrg		*) abs=`pwd`"/$lib" ;;
108456aec45a7Smrg	      esac
10846aa9e3350Smrg	      func_append newdlprefiles " $abs"
108476aec45a7Smrg	    done
10848300bf1aeSmrg	    dlprefiles=$newdlprefiles
108496aec45a7Smrg	  fi
108506aec45a7Smrg	  $RM $output
108516aec45a7Smrg	  # place dlname in correct position for cygwin
108526aec45a7Smrg	  # In fact, it would be nice if we could use this code for all target
108536aec45a7Smrg	  # systems that can't hard-code library paths into their executables
108546aec45a7Smrg	  # and that have no shared library path variable independent of PATH,
108556aec45a7Smrg	  # but it turns out we can't easily determine that from inspecting
108566aec45a7Smrg	  # libtool variables, so we have to hard-code the OSs to which it
108576aec45a7Smrg	  # applies here; at the moment, that means platforms that use the PE
108586aec45a7Smrg	  # object format with DLL files.  See the long comment at the top of
108596aec45a7Smrg	  # tests/bindir.at for full details.
108606aec45a7Smrg	  tdlname=$dlname
108616aec45a7Smrg	  case $host,$output,$installed,$module,$dlname in
108626aec45a7Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
108636aec45a7Smrg	      # If a -bindir argument was supplied, place the dll there.
10864300bf1aeSmrg	      if test -n "$bindir"; then
108656aec45a7Smrg		func_relative_path "$install_libdir" "$bindir"
10866300bf1aeSmrg		tdlname=$func_relative_path_result/$dlname
108676aec45a7Smrg	      else
108686aec45a7Smrg		# Otherwise fall back on heuristic.
108696aec45a7Smrg		tdlname=../bin/$dlname
108706aec45a7Smrg	      fi
108716aec45a7Smrg	      ;;
108726aec45a7Smrg	  esac
108736aec45a7Smrg	  $ECHO > $output "\
108746aec45a7Smrg# $outputname - a libtool library file
10875300bf1aeSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
108766aec45a7Smrg#
108776aec45a7Smrg# Please DO NOT delete this file!
108786aec45a7Smrg# It is necessary for linking the library.
10879ab47cfaaSmrg
108806aec45a7Smrg# The name that we can dlopen(3).
108816aec45a7Smrgdlname='$tdlname'
10882ab47cfaaSmrg
108836aec45a7Smrg# Names of this library.
108846aec45a7Smrglibrary_names='$library_names'
10885ab47cfaaSmrg
108866aec45a7Smrg# The name of the static archive.
108876aec45a7Smrgold_library='$old_library'
10888ab47cfaaSmrg
10889300bf1aeSmrg# Linker flags that cannot go in dependency_libs.
108906aec45a7Smrginherited_linker_flags='$new_inherited_linker_flags'
10891ab47cfaaSmrg
108926aec45a7Smrg# Libraries that this one depends upon.
108936aec45a7Smrgdependency_libs='$dependency_libs'
10894ab47cfaaSmrg
108956aec45a7Smrg# Names of additional weak libraries provided by this library
108966aec45a7Smrgweak_library_names='$weak_libs'
10897ab47cfaaSmrg
108986aec45a7Smrg# Version information for $libname.
108996aec45a7Smrgcurrent=$current
109006aec45a7Smrgage=$age
109016aec45a7Smrgrevision=$revision
10902ab47cfaaSmrg
109036aec45a7Smrg# Is this an already installed library?
109046aec45a7Smrginstalled=$installed
10905ab47cfaaSmrg
109066aec45a7Smrg# Should we warn about portability when linking against -modules?
109076aec45a7Smrgshouldnotlink=$module
10908ab47cfaaSmrg
109096aec45a7Smrg# Files to dlopen/dlpreopen
109106aec45a7Smrgdlopen='$dlfiles'
109116aec45a7Smrgdlpreopen='$dlprefiles'
10912ab47cfaaSmrg
109136aec45a7Smrg# Directory that this library needs to be installed in:
109146aec45a7Smrglibdir='$install_libdir'"
10915300bf1aeSmrg	  if test no,yes = "$installed,$need_relink"; then
109166aec45a7Smrg	    $ECHO >> $output "\
109176aec45a7Smrgrelink_command=\"$relink_command\""
109186aec45a7Smrg	  fi
109196aec45a7Smrg	done
109206aec45a7Smrg      }
10921ab47cfaaSmrg
109226aec45a7Smrg      # Do a symbolic link so that the libtool archive can be found in
109236aec45a7Smrg      # LD_LIBRARY_PATH before the program is installed.
109246aec45a7Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
109256aec45a7Smrg      ;;
109266aec45a7Smrg    esac
109276aec45a7Smrg    exit $EXIT_SUCCESS
109286aec45a7Smrg}
109295c42550eSmrg
10930300bf1aeSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then
10931300bf1aeSmrg  func_mode_link ${1+"$@"}
10932300bf1aeSmrgfi
10933ab47cfaaSmrg
10934ab47cfaaSmrg
109356aec45a7Smrg# func_mode_uninstall arg...
109366aec45a7Smrgfunc_mode_uninstall ()
109376aec45a7Smrg{
10938300bf1aeSmrg    $debug_cmd
10939300bf1aeSmrg
10940300bf1aeSmrg    RM=$nonopt
10941ab47cfaaSmrg    files=
10942300bf1aeSmrg    rmforce=false
10943ab47cfaaSmrg    exit_status=0
10944ab47cfaaSmrg
10945ab47cfaaSmrg    # This variable tells wrapper scripts just to set variables rather
10946ab47cfaaSmrg    # than running their programs.
10947300bf1aeSmrg    libtool_install_magic=$magic
10948ab47cfaaSmrg
10949ab47cfaaSmrg    for arg
10950ab47cfaaSmrg    do
10951ab47cfaaSmrg      case $arg in
10952300bf1aeSmrg      -f) func_append RM " $arg"; rmforce=: ;;
10953aa9e3350Smrg      -*) func_append RM " $arg" ;;
10954aa9e3350Smrg      *) func_append files " $arg" ;;
10955ab47cfaaSmrg      esac
10956ab47cfaaSmrg    done
10957ab47cfaaSmrg
109586aec45a7Smrg    test -z "$RM" && \
109596aec45a7Smrg      func_fatal_help "you must specify an RM program"
10960ab47cfaaSmrg
10961ab47cfaaSmrg    rmdirs=
10962ab47cfaaSmrg
10963ab47cfaaSmrg    for file in $files; do
109646aec45a7Smrg      func_dirname "$file" "" "."
10965300bf1aeSmrg      dir=$func_dirname_result
10966300bf1aeSmrg      if test . = "$dir"; then
10967300bf1aeSmrg	odir=$objdir
10968ab47cfaaSmrg      else
10969300bf1aeSmrg	odir=$dir/$objdir
10970ab47cfaaSmrg      fi
109716aec45a7Smrg      func_basename "$file"
10972300bf1aeSmrg      name=$func_basename_result
10973300bf1aeSmrg      test uninstall = "$opt_mode" && odir=$dir
10974ab47cfaaSmrg
10975aa9e3350Smrg      # Remember odir for removal later, being careful to avoid duplicates
10976300bf1aeSmrg      if test clean = "$opt_mode"; then
10977ab47cfaaSmrg	case " $rmdirs " in
10978aa9e3350Smrg	  *" $odir "*) ;;
10979aa9e3350Smrg	  *) func_append rmdirs " $odir" ;;
10980ab47cfaaSmrg	esac
10981ab47cfaaSmrg      fi
10982ab47cfaaSmrg
10983ab47cfaaSmrg      # Don't error if the file doesn't exist and rm -f was used.
109846aec45a7Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
109856aec45a7Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
109866aec45a7Smrg	 test -f "$file"; then
10987ab47cfaaSmrg	:
10988ab47cfaaSmrg      elif test -d "$file"; then
10989ab47cfaaSmrg	exit_status=1
10990ab47cfaaSmrg	continue
10991300bf1aeSmrg      elif $rmforce; then
10992ab47cfaaSmrg	continue
10993ab47cfaaSmrg      fi
10994ab47cfaaSmrg
10995300bf1aeSmrg      rmfiles=$file
10996ab47cfaaSmrg
10997ab47cfaaSmrg      case $name in
10998ab47cfaaSmrg      *.la)
10999ab47cfaaSmrg	# Possibly a libtool archive, so verify it.
110006aec45a7Smrg	if func_lalib_p "$file"; then
110016aec45a7Smrg	  func_source $dir/$name
11002ab47cfaaSmrg
11003ab47cfaaSmrg	  # Delete the libtool libraries and symlinks.
11004ab47cfaaSmrg	  for n in $library_names; do
11005aa9e3350Smrg	    func_append rmfiles " $odir/$n"
11006ab47cfaaSmrg	  done
11007aa9e3350Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
11008ab47cfaaSmrg
11009300bf1aeSmrg	  case $opt_mode in
11010ab47cfaaSmrg	  clean)
11011aa9e3350Smrg	    case " $library_names " in
11012ab47cfaaSmrg	    *" $dlname "*) ;;
11013aa9e3350Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
11014ab47cfaaSmrg	    esac
11015aa9e3350Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
11016ab47cfaaSmrg	    ;;
11017ab47cfaaSmrg	  uninstall)
11018ab47cfaaSmrg	    if test -n "$library_names"; then
11019ab47cfaaSmrg	      # Do each command in the postuninstall commands.
11020300bf1aeSmrg	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
11021ab47cfaaSmrg	    fi
11022ab47cfaaSmrg
11023ab47cfaaSmrg	    if test -n "$old_library"; then
11024ab47cfaaSmrg	      # Do each command in the old_postuninstall commands.
11025300bf1aeSmrg	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
11026ab47cfaaSmrg	    fi
11027ab47cfaaSmrg	    # FIXME: should reinstall the best remaining shared library.
11028ab47cfaaSmrg	    ;;
11029ab47cfaaSmrg	  esac
11030ab47cfaaSmrg	fi
11031ab47cfaaSmrg	;;
11032ab47cfaaSmrg
11033ab47cfaaSmrg      *.lo)
11034ab47cfaaSmrg	# Possibly a libtool object, so verify it.
110356aec45a7Smrg	if func_lalib_p "$file"; then
11036ab47cfaaSmrg
11037ab47cfaaSmrg	  # Read the .lo file
110386aec45a7Smrg	  func_source $dir/$name
11039ab47cfaaSmrg
11040ab47cfaaSmrg	  # Add PIC object to the list of files to remove.
11041300bf1aeSmrg	  if test -n "$pic_object" && test none != "$pic_object"; then
11042aa9e3350Smrg	    func_append rmfiles " $dir/$pic_object"
11043ab47cfaaSmrg	  fi
11044ab47cfaaSmrg
11045ab47cfaaSmrg	  # Add non-PIC object to the list of files to remove.
11046300bf1aeSmrg	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
11047aa9e3350Smrg	    func_append rmfiles " $dir/$non_pic_object"
11048ab47cfaaSmrg	  fi
11049ab47cfaaSmrg	fi
11050ab47cfaaSmrg	;;
11051ab47cfaaSmrg
11052ab47cfaaSmrg      *)
11053300bf1aeSmrg	if test clean = "$opt_mode"; then
11054ab47cfaaSmrg	  noexename=$name
11055ab47cfaaSmrg	  case $file in
11056ab47cfaaSmrg	  *.exe)
110576aec45a7Smrg	    func_stripname '' '.exe' "$file"
110586aec45a7Smrg	    file=$func_stripname_result
110596aec45a7Smrg	    func_stripname '' '.exe' "$name"
110606aec45a7Smrg	    noexename=$func_stripname_result
11061ab47cfaaSmrg	    # $file with .exe has already been added to rmfiles,
11062ab47cfaaSmrg	    # add $file without .exe
11063aa9e3350Smrg	    func_append rmfiles " $file"
11064ab47cfaaSmrg	    ;;
11065ab47cfaaSmrg	  esac
11066ab47cfaaSmrg	  # Do a test to see if this is a libtool program.
110676aec45a7Smrg	  if func_ltwrapper_p "$file"; then
110686aec45a7Smrg	    if func_ltwrapper_executable_p "$file"; then
110696aec45a7Smrg	      func_ltwrapper_scriptname "$file"
110706aec45a7Smrg	      relink_command=
110716aec45a7Smrg	      func_source $func_ltwrapper_scriptname_result
11072aa9e3350Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
110736aec45a7Smrg	    else
110746aec45a7Smrg	      relink_command=
110756aec45a7Smrg	      func_source $dir/$noexename
110766aec45a7Smrg	    fi
11077ab47cfaaSmrg
11078ab47cfaaSmrg	    # note $name still contains .exe if it was in $file originally
11079ab47cfaaSmrg	    # as does the version of $file that was added into $rmfiles
11080300bf1aeSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
11081300bf1aeSmrg	    if test yes = "$fast_install" && test -n "$relink_command"; then
11082aa9e3350Smrg	      func_append rmfiles " $odir/lt-$name"
11083ab47cfaaSmrg	    fi
11084300bf1aeSmrg	    if test "X$noexename" != "X$name"; then
11085300bf1aeSmrg	      func_append rmfiles " $odir/lt-$noexename.c"
11086ab47cfaaSmrg	    fi
11087ab47cfaaSmrg	  fi
11088ab47cfaaSmrg	fi
11089ab47cfaaSmrg	;;
11090ab47cfaaSmrg      esac
110916aec45a7Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
11092ab47cfaaSmrg    done
11093ab47cfaaSmrg
11094300bf1aeSmrg    # Try to remove the $objdir's in the directories where we deleted files
11095ab47cfaaSmrg    for dir in $rmdirs; do
11096ab47cfaaSmrg      if test -d "$dir"; then
110976aec45a7Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
11098ab47cfaaSmrg      fi
11099ab47cfaaSmrg    done
11100ab47cfaaSmrg
11101ab47cfaaSmrg    exit $exit_status
111026aec45a7Smrg}
11103ab47cfaaSmrg
11104300bf1aeSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
11105300bf1aeSmrg  func_mode_uninstall ${1+"$@"}
11106300bf1aeSmrgfi
111071473d951Smrg
11108aa9e3350Smrgtest -z "$opt_mode" && {
11109300bf1aeSmrg  help=$generic_help
111106aec45a7Smrg  func_fatal_help "you must specify a MODE"
111116aec45a7Smrg}
111126aec45a7Smrg
111136aec45a7Smrgtest -z "$exec_cmd" && \
11114300bf1aeSmrg  func_fatal_help "invalid operation mode '$opt_mode'"
11115ab47cfaaSmrg
11116ab47cfaaSmrgif test -n "$exec_cmd"; then
111176aec45a7Smrg  eval exec "$exec_cmd"
11118ab47cfaaSmrg  exit $EXIT_FAILURE
11119ab47cfaaSmrgfi
11120ab47cfaaSmrg
111216aec45a7Smrgexit $exit_status
111225c42550eSmrg
11123ab47cfaaSmrg
11124ab47cfaaSmrg# The TAGs below are defined such that we never get into a situation
11125300bf1aeSmrg# where we disable both kinds of libraries.  Given conflicting
11126ab47cfaaSmrg# choices, we go for a static library, that is the most portable,
11127ab47cfaaSmrg# since we can't tell whether shared libraries were disabled because
11128ab47cfaaSmrg# the user asked for that or because the platform doesn't support
11129ab47cfaaSmrg# them.  This is particularly important on AIX, because we don't
11130ab47cfaaSmrg# support having both static and shared libraries enabled at the same
11131ab47cfaaSmrg# time on that platform, so we default to a shared-only configuration.
11132ab47cfaaSmrg# If a disable-shared tag is given, we'll fallback to a static-only
11133ab47cfaaSmrg# configuration.  But we'll never go from static-only to shared-only.
11134ab47cfaaSmrg
11135ab47cfaaSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
111366aec45a7Smrgbuild_libtool_libs=no
111376aec45a7Smrgbuild_old_libs=yes
11138ab47cfaaSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
11139ab47cfaaSmrg
11140ab47cfaaSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
111416aec45a7Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
11142ab47cfaaSmrg# ### END LIBTOOL TAG CONFIG: disable-static
11143ab47cfaaSmrg
11144ab47cfaaSmrg# Local Variables:
11145ab47cfaaSmrg# mode:shell-script
11146ab47cfaaSmrg# sh-indentation:2
11147ab47cfaaSmrg# End:
11148