23
26
# General Public License for more details.
25
28
# You should have received a copy of the GNU General Public License
26
# along with GNU Libtool; see the file COPYING. If not, a copy
27
# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28
# or obtained by writing to the Free Software Foundation, Inc.,
29
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
# along with this program. If not, see <http://www.gnu.org/licenses/>.
31
# Usage: $progname [OPTION]... [MODE-ARG]...
33
# Provide generalized library-building support services.
35
# --config show all configuration variables
36
# --debug enable verbose shell tracing
37
# -n, --dry-run display commands without modifying any files
38
# --features display basic configuration information and exit
39
# --mode=MODE use operation mode MODE
40
# --preserve-dup-deps don't remove duplicate dependency libraries
41
# --quiet, --silent don't print informational messages
42
# --no-quiet, --no-silent
43
# print informational messages (default)
44
# --no-warn don't display warning messages
45
# --tag=TAG use configuration variables from tag TAG
46
# -v, --verbose print more informational messages than default
47
# --no-verbose don't print the extra informational messages
48
# --version print version information
49
# -h, --help, --help-all print short, long, or detailed help message
51
# MODE must be one of the following:
53
# clean remove files from the build directory
54
# compile compile a source file into a libtool object
55
# execute automatically set library path, then run a program
56
# finish complete the installation of libtool libraries
57
# install install libraries or executables
58
# link create a library or an executable
59
# uninstall remove libraries from an installed directory
61
# MODE-ARGS vary depending on the MODE. When passed as first option,
62
# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63
# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
65
# When reporting a bug, please describe a test case to reproduce it and
66
# include the following information:
71
# compiler flags: $LTCFLAGS
72
# linker: $LD (gnu? $with_gnu_ld)
73
# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.11
74
# automake: $automake_version
75
# autoconf: $autoconf_version
77
# Report bugs to <bug-libtool@gnu.org>.
78
# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79
# General help using GNU software: <http://www.gnu.org/gethelp/>.
83
VERSION="2.4.2 Debian-2.4.2-1.11"
85
package_revision=1.3337
87
# Be Bourne compatible
88
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
34
VERSION="2.4.6 Debian-2.4.6-0.1"
35
package_revision=2.4.6
42
# Run './libtool --help' for help with using this script from the
46
## ------------------------------- ##
47
## User overridable command paths. ##
48
## ------------------------------- ##
50
# After configure completes, it has a better idea of some of the
51
# shell tools we need than the defaults used by the functions shared
52
# with bootstrap, so set those here where they can still be over-
53
# ridden by the user, but otherwise take precedence.
55
: ${AUTOCONF="autoconf"}
56
: ${AUTOMAKE="automake"}
59
## -------------------------- ##
60
## Source external libraries. ##
61
## -------------------------- ##
63
# Much of our low-level functionality needs to be sourced from external
64
# libraries, which are installed to $pkgauxdir.
66
# Set a version string for this script.
67
scriptversion=2015-01-20.17; # UTC
69
# General shell script boiler plate, and helper functions.
70
# Written by Gary V. Vaughan, 2004
72
# Copyright (C) 2004-2015 Free Software Foundation, Inc.
73
# This is free software; see the source for copying conditions. There is NO
74
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
76
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
78
# the Free Software Foundation; either version 3 of the License, or
79
# (at your option) any later version.
81
# As a special exception to the GNU General Public License, if you distribute
82
# this file as part of a program or library that is built using GNU Libtool,
83
# you may include this file under the same distribution terms that you use
84
# for the rest of that program.
86
# This program is distributed in the hope that it will be useful,
87
# but WITHOUT ANY WARRANTY; without even the implied warranty of
88
# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
89
# General Public License for more details.
91
# You should have received a copy of the GNU General Public License
92
# along with this program. If not, see <http://www.gnu.org/licenses/>.
94
# Please report bugs or propose patches to gary@gnu.org.
101
# Evaluate this file near the top of your script to gain access to
102
# the functions and variables defined here:
104
# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
106
# If you need to override any of the default environment variable
107
# settings, do that before evaluating this file.
110
## -------------------- ##
111
## Shell normalisation. ##
112
## -------------------- ##
114
# Some shells need a little help to be as Bourne compatible as possible.
115
# Before doing anything else, make sure all that help has been provided!
117
DUALCASE=1; export DUALCASE # for MKS sh
118
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
91
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
121
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
92
122
# is contrary to our usage. Disable this feature.
93
123
alias -g '${1+"$@"}'='"$@"'
94
124
setopt NO_GLOB_SUBST
96
case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
126
case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
98
BIN_SH=xpg4; export BIN_SH # for Tru64
99
DUALCASE=1; export DUALCASE # for MKS sh
101
# A function that is used when there is no print builtin or printf.
102
func_fallback_echo ()
104
eval 'cat <<_LTECHO_EOF
109
# NLS nuisances: We save the old values to restore during execute mode.
112
for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
129
# NLS nuisances: We save the old values in case they are required later.
132
for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
114
eval "if test \"\${$lt_var+set}\" = set; then
115
save_$lt_var=\$$lt_var
118
lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119
lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
134
eval "if test set = \"\${$_G_var+set}\"; then
135
save_$_G_var=\$$_G_var
138
_G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
139
_G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
124
export LANGUAGE LC_ALL
129
# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
130
# is ksh but when the shell is invoked as "sh" and the current value of
131
# the _XPG environment variable is not equal to 1 (one), the special
132
# positional parameter $0, within a function call, is the name of the
144
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
146
# Make sure IFS has a sensible default
152
# There are apparently some retarded systems that use ';' as a PATH separator!
153
if test "${PATH_SEPARATOR+set}" != set; then
155
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
156
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
163
## ------------------------- ##
164
## Locate command utilities. ##
165
## ------------------------- ##
168
# func_executable_p FILE
169
# ----------------------
170
# Check that FILE is an executable regular file.
173
test -f "$1" && test -x "$1"
177
# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
178
# --------------------------------------------
179
# Search for either a program that responds to --version with output
180
# containing "GNU", or else returned by CHECK_FUNC otherwise, by
181
# trying all the directories in PATH with each of the elements of
184
# CHECK_FUNC should accept the path to a candidate program, and
185
# set $func_check_prog_result if it truncates its output less than
186
# $_G_path_prog_max characters.
194
_G_path_prog_found=false
195
_G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
196
for _G_dir in $_G_PATH; do
198
test -z "$_G_dir" && _G_dir=.
199
for _G_prog_name in $_G_progs_list; do
200
for _exeext in '' .EXE; do
201
_G_path_prog=$_G_dir/$_G_prog_name$_exeext
202
func_executable_p "$_G_path_prog" || continue
203
case `"$_G_path_prog" --version 2>&1` in
204
*GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
205
*) $_G_check_func $_G_path_prog
206
func_path_progs_result=$func_check_prog_result
209
$_G_path_prog_found && break 3
214
test -z "$func_path_progs_result" && {
215
echo "no acceptable sed could be found in \$PATH" >&2
221
# We want to be able to use the functions in this file before configure
222
# has figured out where the best binaries are kept, which means we have
223
# to search for them ourselves - except when the results are already set
224
# where we skip the searches.
226
# Unless the user overrides by setting SED, search the path for either GNU
227
# sed, or the sed that truncates its output the least.
229
_G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
230
for _G_i in 1 2 3 4 5 6 7; do
231
_G_sed_script=$_G_sed_script$nl$_G_sed_script
233
echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
236
func_check_prog_sed ()
241
printf 0123456789 >conftest.in
244
cat conftest.in conftest.in >conftest.tmp
245
mv conftest.tmp conftest.in
246
cp conftest.in conftest.nl
247
echo '' >> conftest.nl
248
"$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
249
diff conftest.out conftest.nl >/dev/null 2>&1 || break
250
_G_count=`expr $_G_count + 1`
251
if test "$_G_count" -gt "$_G_path_prog_max"; then
252
# Best one so far, save it but keep looking for a better one
253
func_check_prog_result=$_G_path_prog
254
_G_path_prog_max=$_G_count
256
# 10*(2^10) chars as input seems more than enough
257
test 10 -lt "$_G_count" && break
259
rm -f conftest.in conftest.tmp conftest.nl conftest.out
262
func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
264
SED=$func_path_progs_result
268
# Unless the user overrides by setting GREP, search the path for either GNU
269
# grep, or the grep that truncates its output the least.
271
func_check_prog_grep ()
277
printf 0123456789 >conftest.in
280
cat conftest.in conftest.in >conftest.tmp
281
mv conftest.tmp conftest.in
282
cp conftest.in conftest.nl
283
echo 'GREP' >> conftest.nl
284
"$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
285
diff conftest.out conftest.nl >/dev/null 2>&1 || break
286
_G_count=`expr $_G_count + 1`
287
if test "$_G_count" -gt "$_G_path_prog_max"; then
288
# Best one so far, save it but keep looking for a better one
289
func_check_prog_result=$_G_path_prog
290
_G_path_prog_max=$_G_count
292
# 10*(2^10) chars as input seems more than enough
293
test 10 -lt "$_G_count" && break
295
rm -f conftest.in conftest.tmp conftest.nl conftest.out
298
func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
299
GREP=$func_path_progs_result
303
## ------------------------------- ##
304
## User overridable command paths. ##
305
## ------------------------------- ##
307
# All uppercase variable names are used for environment variables. These
308
# variables can be overridden by the user before calling a script that
309
# uses them if a suitable command of that name is not already available
310
# in the command search PATH.
139
test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
313
: ${ECHO="printf %s\n"}
314
: ${EGREP="$GREP -E"}
315
: ${FGREP="$GREP -F"}
141
318
: ${MKDIR="mkdir"}
144
321
: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
145
: ${Xsed="$SED -e 1s/^X//"}
324
## -------------------- ##
325
## Useful sed snippets. ##
326
## -------------------- ##
328
sed_dirname='s|/[^/]*$||'
329
sed_basename='s|^.*/||'
331
# Sed substitution that helps us do robust quoting. It backslashifies
332
# metacharacters that are still active within double-quoted strings.
333
sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
335
# Same as above, but do not quote variable references.
336
sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
338
# Sed substitution that turns a string into a regex matching for the
340
sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
342
# Sed substitution that converts a w32 file name or path
343
# that contains forward slashes, into one that contains
344
# (escaped) backslashes. A very naive implementation.
345
sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
347
# Re-'\' parameter expansions in output of sed_double_quote_subst that
348
# were '\'-ed in input to the same. If an odd number of '\' preceded a
349
# '$' in input to sed_double_quote_subst, that '$' was protected from
350
# expansion. Since each input '\' is now two '\'s, look for any number
351
# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
356
sed_double_backslash="\
359
s/^$_G_bs2$_G_dollar/$_G_bs&/
360
s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
364
## ----------------- ##
365
## Global variables. ##
366
## ----------------- ##
368
# Except for the global variables explicitly listed below, the following
369
# functions in the '^func_' namespace, and the '^require_' namespace
370
# variables initialised in the 'Resource management' section, sourcing
371
# this file will not pollute your global namespace with anything
372
# else. There's no portable way to scope variables in Bourne shell
373
# though, so actually running these functions will sometimes place
374
# results into a variable named after the function, and often use
375
# temporary variables in the '^_G_' namespace. If you are careful to
376
# avoid using those namespaces casually in your sourcing script, things
377
# should continue to work as you expect. And, of course, you can freely
378
# overwrite any of the functions or variables defined here before
379
# calling anything to customize them.
150
383
EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
151
384
EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
386
# Allow overriding, eg assuming that you follow the convention of
387
# putting '$debug_cmd' at the start of all your functions, you can get
388
# bash to show function call trace with:
390
# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
391
debug_cmd=${debug_cmd-":"}
394
# By convention, finish your script with:
398
# so that you can set exit_status to non-zero if you want to indicate
399
# something went wrong during execution without actually bailing out at
400
# the point of failure.
153
401
exit_status=$EXIT_SUCCESS
155
# Make sure IFS has a sensible default
160
dirname="s,/[^/]*$,,"
163
# func_dirname file append nondir_replacement
164
# Compute the dirname of FILE. If nonempty, add APPEND to the result,
165
# otherwise set result to NONDIR_REPLACEMENT.
168
func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
169
if test "X$func_dirname_result" = "X${1}"; then
170
func_dirname_result="${3}"
172
func_dirname_result="$func_dirname_result${2}"
174
} # func_dirname may be replaced by extended shell implementation
180
func_basename_result=`$ECHO "${1}" | $SED "$basename"`
181
} # func_basename may be replaced by extended shell implementation
184
# func_dirname_and_basename file append nondir_replacement
185
# perform func_basename and func_dirname in a single function
187
# dirname: Compute the dirname of FILE. If nonempty,
188
# add APPEND to the result, otherwise set result
189
# to NONDIR_REPLACEMENT.
190
# value returned in "$func_dirname_result"
191
# basename: Compute filename of FILE.
192
# value retuned in "$func_basename_result"
193
# Implementation must be kept synchronized with func_dirname
194
# and func_basename. For efficiency, we do not delegate to
195
# those functions but instead duplicate the functionality here.
196
func_dirname_and_basename ()
198
# Extract subdirectory from the argument.
199
func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
200
if test "X$func_dirname_result" = "X${1}"; then
201
func_dirname_result="${3}"
203
func_dirname_result="$func_dirname_result${2}"
205
func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
206
} # func_dirname_and_basename may be replaced by extended shell implementation
209
# func_stripname prefix suffix name
210
# strip PREFIX and SUFFIX off of NAME.
211
# PREFIX and SUFFIX must not contain globbing or regex special
212
# characters, hashes, percent signs, but SUFFIX may contain a leading
213
# dot (in which case that matches only a dot).
214
# func_strip_suffix prefix name
218
.*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
219
*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
221
} # func_stripname may be replaced by extended shell implementation
224
# These SED scripts presuppose an absolute path with a trailing slash.
225
pathcar='s,^/\([^/]*\).*$,\1,'
226
pathcdr='s,^/[^/]*,,'
227
removedotparts=':dotsl
231
collapseslashes='s@/\{1,\}@/@g'
232
finalslash='s,/*$,/,'
234
# func_normal_abspath PATH
235
# Remove doubled-up and trailing slashes, "." path components,
236
# and cancel out any ".." path components in PATH after making
237
# it an absolute path.
238
# value returned in "$func_normal_abspath_result"
239
func_normal_abspath ()
241
# Start from root dir and reassemble the path.
242
func_normal_abspath_result=
243
func_normal_abspath_tpath=$1
244
func_normal_abspath_altnamespace=
245
case $func_normal_abspath_tpath in
247
# Empty path, that just means $cwd.
248
func_stripname '' '/' "`pwd`"
249
func_normal_abspath_result=$func_stripname_result
252
# The next three entries are used to spot a run of precisely
253
# two leading slashes without using negated character classes;
254
# we take advantage of case's first-match behaviour.
256
# Unusual form of absolute path, do nothing.
259
# Not necessarily an ordinary path; POSIX reserves leading '//'
260
# and for example Cygwin uses it to access remote file shares
261
# over CIFS/SMB, so we conserve a leading double slash if found.
262
func_normal_abspath_altnamespace=/
265
# Absolute path, do nothing.
268
# Relative path, prepend $cwd.
269
func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
272
# Cancel out all the simple stuff to save iterations. We also want
273
# the path to end with a slash for ease of parsing, so make sure
274
# there is one (and only one) here.
275
func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
276
-e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
278
# Processed it all yet?
279
if test "$func_normal_abspath_tpath" = / ; then
280
# If we ascended to the root using ".." the result may be empty now.
281
if test -z "$func_normal_abspath_result" ; then
282
func_normal_abspath_result=/
286
func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
288
func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
290
# Figure out what to do with it
291
case $func_normal_abspath_tcomponent in
293
# Trailing empty path component, ignore it.
296
# Parent dir; strip last assembled component from result.
297
func_dirname "$func_normal_abspath_result"
298
func_normal_abspath_result=$func_dirname_result
301
# Actual path component, append it.
302
func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
306
# Restore leading double-slash if one was found on entry.
307
func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
310
# func_relative_path SRCDIR DSTDIR
311
# generates a relative path from SRCDIR to DSTDIR, with a trailing
312
# slash if non-empty, suitable for immediately appending a filename
313
# without needing to append a separator.
314
# value returned in "$func_relative_path_result"
315
func_relative_path ()
317
func_relative_path_result=
318
func_normal_abspath "$1"
319
func_relative_path_tlibdir=$func_normal_abspath_result
320
func_normal_abspath "$2"
321
func_relative_path_tbindir=$func_normal_abspath_result
323
# Ascend the tree starting from libdir
325
# check if we have found a prefix of bindir
326
case $func_relative_path_tbindir in
327
$func_relative_path_tlibdir)
328
# found an exact match
329
func_relative_path_tcancelled=
332
$func_relative_path_tlibdir*)
333
# found a matching prefix
334
func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
335
func_relative_path_tcancelled=$func_stripname_result
336
if test -z "$func_relative_path_result"; then
337
func_relative_path_result=.
342
func_dirname $func_relative_path_tlibdir
343
func_relative_path_tlibdir=${func_dirname_result}
344
if test "x$func_relative_path_tlibdir" = x ; then
345
# Have to descend all the way to the root!
346
func_relative_path_result=../$func_relative_path_result
347
func_relative_path_tcancelled=$func_relative_path_tbindir
350
func_relative_path_result=../$func_relative_path_result
355
# Now calculate path; take care to avoid doubling-up slashes.
356
func_stripname '' '/' "$func_relative_path_result"
357
func_relative_path_result=$func_stripname_result
358
func_stripname '/' '/' "$func_relative_path_tcancelled"
359
if test "x$func_stripname_result" != x ; then
360
func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
363
# Normalisation. If bindir is libdir, return empty string,
364
# else relative path ending with a slash; either way, target
365
# file name can be directly appended.
366
if test ! -z "$func_relative_path_result"; then
367
func_stripname './' '' "$func_relative_path_result/"
368
func_relative_path_result=$func_stripname_result
372
# The name of this program:
373
func_dirname_and_basename "$progpath"
374
progname=$func_basename_result
376
# Make sure we have an absolute path for reexecution:
403
# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
404
# is ksh but when the shell is invoked as "sh" and the current value of
405
# the _XPG environment variable is not equal to 1 (one), the special
406
# positional parameter $0, within a function call, is the name of the
410
# The name of this program.
411
progname=`$ECHO "$progpath" |$SED "$sed_basename"`
413
# Make sure we have an absolute progpath for reexecution:
377
414
case $progpath in
378
415
[\\/]*|[A-Za-z]:\\*) ;;
380
progdir=$func_dirname_result
417
progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
381
418
progdir=`cd "$progdir" && pwd`
382
progpath="$progdir/$progname"
419
progpath=$progdir/$progname
386
423
IFS=${PATH_SEPARATOR-:}
387
424
for progdir in $PATH; do
389
426
test -x "$progdir/$progname" && break
392
429
test -n "$progdir" || progdir=`pwd`
393
progpath="$progdir/$progname"
430
progpath=$progdir/$progname
397
# Sed substitution that helps us do robust quoting. It backslashifies
398
# metacharacters that are still active within double-quoted strings.
399
Xsed="${SED}"' -e 1s/^X//'
400
sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
402
# Same as above, but do not quote variable references.
403
double_quote_subst='s/\(["`\\]\)/\\\1/g'
405
# Sed substitution that turns a string into a regex matching for the
407
sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
409
# Sed substitution that converts a w32 file name or path
410
# which contains forward slashes, into one that contains
411
# (escaped) backslashes. A very naive implementation.
412
lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
414
# Re-`\' parameter expansions in output of double_quote_subst that were
415
# `\'-ed in input to the same. If an odd number of `\' preceded a '$'
416
# in input to double_quote_subst, that '$' was protected from expansion.
417
# Since each input `\' is now two `\'s, look for any number of runs of
418
# four `\'s followed by two `\'s and then a '$'. `\' that '$'.
423
sed_double_backslash="\
427
s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
435
## ----------------- ##
436
## Standard options. ##
437
## ----------------- ##
439
# The following options affect the operation of the functions defined
440
# below, and should be set appropriately depending on run-time para-
441
# meters passed on the command line.
431
443
opt_dry_run=false
434
445
opt_verbose=false
438
# Echo program name prefixed message, along with the current mode
439
# name if it has been set yet.
447
# Categories 'all' and 'none' are always available. Append any others
448
# you will pass as the first argument to func_warning from your own
452
# By default, display warnings according to 'opt_warning_types'. Set
453
# 'warning_func' to ':' to elide all warnings, or func_fatal_error to
454
# treat the next displayed warning as a fatal error.
455
warning_func=func_warn_and_continue
457
# Set to 'all' to display all warnings, 'none' to suppress all
458
# warnings, or a space delimited list of some subset of
459
# 'warning_categories' to display only the listed warnings.
460
opt_warning_types=all
463
## -------------------- ##
464
## Resource management. ##
465
## -------------------- ##
467
# This section contains definitions for functions that each ensure a
468
# particular resource (a file, or a non-empty configuration variable for
469
# example) is available, and if appropriate to extract default values
470
# from pertinent package files. Call them using their associated
471
# 'require_*' variable to ensure that they are executed, at most, once.
473
# It's entirely deliberate that calling these functions can set
474
# variables that don't obey the namespace limitations obeyed by the rest
475
# of this file, in order that that they be as useful as possible to
479
# require_term_colors
480
# -------------------
481
# Allow display of bold text on terminals that support it.
482
require_term_colors=func_require_term_colors
483
func_require_term_colors ()
488
# COLORTERM and USE_ANSI_COLORS environment variables take
489
# precedence, because most terminfo databases neglect to describe
490
# whether color sequences are supported.
491
test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
493
if test 1 = "$USE_ANSI_COLORS"; then
494
# Standard ANSI escape sequences
496
tc_bold='[1m'; tc_standout='[7m'
497
tc_red='[31m'; tc_green='[32m'
498
tc_blue='[34m'; tc_cyan='[36m'
500
# Otherwise trust the terminfo database after all.
501
test -n "`tput sgr0 2>/dev/null`" && {
503
test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
505
test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
506
test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
507
test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
508
test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
509
test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
514
require_term_colors=:
518
## ----------------- ##
519
## Function library. ##
520
## ----------------- ##
522
# This section contains a variety of useful functions to call in your
523
# scripts. Take note of the portable wrappers for features provided by
524
# some modern shells, which will fall back to slower equivalents on
525
# less featureful shells.
528
# func_append VAR VALUE
529
# ---------------------
530
# Append VALUE onto the existing contents of VAR.
532
# We should try to minimise forks, especially on Windows where they are
533
# unreasonably slow, so skip the feature probes when bash or zsh are
535
if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
536
: ${_G_HAVE_ARITH_OP="yes"}
537
: ${_G_HAVE_XSI_OPS="yes"}
538
# The += operator was introduced in bash 3.1
539
case $BASH_VERSION in
540
[12].* | 3.0 | 3.0*) ;;
542
: ${_G_HAVE_PLUSEQ_OP="yes"}
548
# Can be empty, in which case the shell is probed, "yes" if += is
549
# useable or anything else if it does not work.
550
test -z "$_G_HAVE_PLUSEQ_OP" \
551
&& (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
552
&& _G_HAVE_PLUSEQ_OP=yes
554
if test yes = "$_G_HAVE_PLUSEQ_OP"
556
# This is an XSI compatible shell, allowing a faster implementation...
564
# ...otherwise fall back to using expr, which is often a shell builtin.
574
# func_append_quoted VAR VALUE
575
# ----------------------------
576
# Quote VALUE and append to the end of shell variable VAR, separated
578
if test yes = "$_G_HAVE_PLUSEQ_OP"; then
579
eval 'func_append_quoted ()
583
func_quote_for_eval "$2"
584
eval "$1+=\\ \$func_quote_for_eval_result"
587
func_append_quoted ()
591
func_quote_for_eval "$2"
592
eval "$1=\$$1\\ \$func_quote_for_eval_result"
597
# func_append_uniq VAR VALUE
598
# --------------------------
599
# Append unique VALUE onto the existing contents of VAR, assuming
600
# entries are delimited by the first character of VALUE. For example:
602
# func_append_uniq options " --another-option option-argument"
604
# will only append to $options if " --another-option option-argument "
605
# is not already present somewhere in $options already (note spaces at
606
# each end implied by leading space in second argument).
611
eval _G_current_value='`$ECHO $'$1'`'
612
_G_delim=`expr "$2" : '\(.\)'`
614
case $_G_delim$_G_current_value$_G_delim in
616
*) func_append "$@" ;;
623
# Set func_arith_result to the result of evaluating TERMs.
624
test -z "$_G_HAVE_ARITH_OP" \
625
&& (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
626
&& _G_HAVE_ARITH_OP=yes
628
if test yes = "$_G_HAVE_ARITH_OP"; then
633
func_arith_result=$(( $* ))
640
func_arith_result=`expr "$@"`
647
# Set func_basename_result to FILE with everything up to and including
648
# the last / stripped.
649
if test yes = "$_G_HAVE_XSI_OPS"; then
650
# If this shell supports suffix pattern removal, then use it to avoid
651
# forking. Hide the definitions single quotes in case the shell chokes
652
# on unsupported syntax...
653
_b='func_basename_result=${1##*/}'
655
*/*) func_dirname_result=${1%/*}$2 ;;
656
* ) func_dirname_result=$3 ;;
660
# ...otherwise fall back to using sed.
661
_b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
662
_d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
663
if test "X$func_dirname_result" = "X$1"; then
664
func_dirname_result=$3
666
func_append func_dirname_result "$2"
670
eval 'func_basename ()
678
# func_dirname FILE APPEND NONDIR_REPLACEMENT
679
# -------------------------------------------
680
# Compute the dirname of FILE. If nonempty, add APPEND to the result,
681
# otherwise set result to NONDIR_REPLACEMENT.
682
eval 'func_dirname ()
690
# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
691
# --------------------------------------------------------
692
# Perform func_basename and func_dirname in a single function
694
# dirname: Compute the dirname of FILE. If nonempty,
695
# add APPEND to the result, otherwise set result
696
# to NONDIR_REPLACEMENT.
697
# value returned in "$func_dirname_result"
698
# basename: Compute filename of FILE.
699
# value retuned in "$func_basename_result"
700
# For efficiency, we do not delegate to the functions above but instead
701
# duplicate the functionality here.
702
eval 'func_dirname_and_basename ()
713
# Echo program name prefixed message.
442
$ECHO "$progname: ${opt_mode+$opt_mode: }$*"
445
# func_verbose arg...
446
# Echo program name prefixed message in verbose mode only.
449
$opt_verbose && func_echo ${1+"$@"}
451
# A bug in bash halts the script if the last line of a function
452
# fails when set -e is in force, so we need another command to
457
# func_echo_all arg...
722
for _G_line in $_G_message; do
724
$ECHO "$progname: $_G_line"
730
# func_echo_all ARG...
731
# --------------------
458
732
# Invoke $ECHO with all args, space-separated.
739
# func_echo_infix_1 INFIX ARG...
740
# ------------------------------
741
# Echo program name, followed by INFIX on the first line, with any
742
# additional lines not showing INFIX.
751
_G_prefix="$progname: $_G_infix: "
754
# Strip color escape sequences before counting printable length
755
for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
757
test -n "$_G_tc" && {
758
_G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
759
_G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
762
_G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
764
func_echo_infix_1_IFS=$IFS
766
for _G_line in $_G_message; do
767
IFS=$func_echo_infix_1_IFS
768
$ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
771
IFS=$func_echo_infix_1_IFS
465
777
# Echo program name prefixed message to standard error.
468
$ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
471
# func_warning arg...
472
# Echo program name prefixed warning message to standard error.
475
$opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
481
# func_fatal_error arg...
784
func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
788
# func_fatal_error ARG...
789
# -----------------------
482
790
# Echo program name prefixed message to standard error, and exit.
483
791
func_fatal_error ()
486
796
exit $EXIT_FAILURE
489
# func_fatal_help arg...
490
# Echo program name prefixed message to standard error, followed by
491
# a help hint, and exit.
495
func_fatal_error "$help"
497
help="Try \`$progname --help' for more information." ## default
500
# func_grep expression filename
800
# func_grep EXPRESSION FILENAME
801
# -----------------------------
501
802
# Check whether EXPRESSION matches any line of FILENAME, without output.
504
807
$GREP "$1" "$2" >/dev/null 2>&1
508
# func_mkdir_p directory-path
813
# Set func_len_result to the length of STRING. STRING may not
814
# start with a hyphen.
815
test -z "$_G_HAVE_XSI_OPS" \
817
test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
818
&& _G_HAVE_XSI_OPS=yes
820
if test yes = "$_G_HAVE_XSI_OPS"; then
825
func_len_result=${#1}
832
func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
837
# func_mkdir_p DIRECTORY-PATH
838
# ---------------------------
509
839
# Make sure the entire path to DIRECTORY-PATH is available.
512
my_directory_path="$1"
515
if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
517
# Protect directory names starting with `-'
518
case $my_directory_path in
519
-*) my_directory_path="./$my_directory_path" ;;
847
if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
849
# Protect directory names starting with '-'
850
case $_G_directory_path in
851
-*) _G_directory_path=./$_G_directory_path ;;
522
854
# While some portion of DIR does not yet exist...
523
while test ! -d "$my_directory_path"; do
855
while test ! -d "$_G_directory_path"; do
524
856
# ...make a list in topmost first order. Use a colon delimited
525
857
# list incase some portion of path contains whitespace.
526
my_dir_list="$my_directory_path:$my_dir_list"
858
_G_dir_list=$_G_directory_path:$_G_dir_list
528
860
# If the last portion added has no slash in it, the list is done
529
case $my_directory_path in */*) ;; *) break ;; esac
861
case $_G_directory_path in */*) ;; *) break ;; esac
531
863
# ...otherwise throw away the child directory and loop
532
my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
864
_G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
534
my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
866
_G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
536
save_mkdir_p_IFS="$IFS"; IFS=':'
537
for my_dir in $my_dir_list; do
538
IFS="$save_mkdir_p_IFS"
539
# mkdir can fail with a `File exist' error if two processes
868
func_mkdir_p_IFS=$IFS; IFS=:
869
for _G_dir in $_G_dir_list; do
870
IFS=$func_mkdir_p_IFS
871
# mkdir can fail with a 'File exist' error if two processes
540
872
# try to create one of the directories concurrently. Don't
541
873
# stop in that case!
542
$MKDIR "$my_dir" 2>/dev/null || :
874
$MKDIR "$_G_dir" 2>/dev/null || :
544
IFS="$save_mkdir_p_IFS"
876
IFS=$func_mkdir_p_IFS
546
878
# Bail out if we (or some other process) failed to create a directory.
547
test -d "$my_directory_path" || \
548
func_fatal_error "Failed to create \`$1'"
879
test -d "$_G_directory_path" || \
880
func_fatal_error "Failed to create '$1'"
553
# func_mktempdir [string]
885
# func_mktempdir [BASENAME]
886
# -------------------------
554
887
# Make a temporary directory that won't clash with other running
555
888
# libtool processes, and avoids race conditions if possible. If
556
# given, STRING is the basename for that directory.
889
# given, BASENAME is the basename for that directory.
557
890
func_mktempdir ()
559
my_template="${TMPDIR-/tmp}/${1-$progname}"
561
if test "$opt_dry_run" = ":"; then
894
_G_template=${TMPDIR-/tmp}/${1-$progname}
896
if test : = "$opt_dry_run"; then
562
897
# Return a directory name, but don't create it in dry-run mode
563
my_tmpdir="${my_template}-$$"
898
_G_tmpdir=$_G_template-$$
566
901
# If mktemp works, use that first and foremost
567
my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
902
_G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
569
if test ! -d "$my_tmpdir"; then
904
if test ! -d "$_G_tmpdir"; then
570
905
# Failing that, at least try and use $RANDOM to avoid a race
571
my_tmpdir="${my_template}-${RANDOM-0}$$"
906
_G_tmpdir=$_G_template-${RANDOM-0}$$
573
save_mktempdir_umask=`umask`
908
func_mktempdir_umask=`umask`
576
umask $save_mktempdir_umask
911
umask $func_mktempdir_umask
579
914
# If we're not in dry-run mode, bomb out on failure
580
test -d "$my_tmpdir" || \
581
func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
588
# func_quote_for_eval arg
589
# Aesthetically quote ARG to be evaled later.
590
# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
591
# is double-quoted, suitable for a subsequent eval, whereas
592
# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
593
# which are still active within double quotes backslashified.
915
test -d "$_G_tmpdir" || \
916
func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
923
# func_normal_abspath PATH
924
# ------------------------
925
# Remove doubled-up and trailing slashes, "." path components,
926
# and cancel out any ".." path components in PATH after making
927
# it an absolute path.
928
func_normal_abspath ()
932
# These SED scripts presuppose an absolute path with a trailing slash.
933
_G_pathcar='s|^/\([^/]*\).*$|\1|'
934
_G_pathcdr='s|^/[^/]*||'
935
_G_removedotparts=':dotsl
939
_G_collapseslashes='s|/\{1,\}|/|g'
940
_G_finalslash='s|/*$|/|'
942
# Start from root dir and reassemble the path.
943
func_normal_abspath_result=
944
func_normal_abspath_tpath=$1
945
func_normal_abspath_altnamespace=
946
case $func_normal_abspath_tpath in
948
# Empty path, that just means $cwd.
949
func_stripname '' '/' "`pwd`"
950
func_normal_abspath_result=$func_stripname_result
953
# The next three entries are used to spot a run of precisely
954
# two leading slashes without using negated character classes;
955
# we take advantage of case's first-match behaviour.
957
# Unusual form of absolute path, do nothing.
960
# Not necessarily an ordinary path; POSIX reserves leading '//'
961
# and for example Cygwin uses it to access remote file shares
962
# over CIFS/SMB, so we conserve a leading double slash if found.
963
func_normal_abspath_altnamespace=/
966
# Absolute path, do nothing.
969
# Relative path, prepend $cwd.
970
func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
974
# Cancel out all the simple stuff to save iterations. We also want
975
# the path to end with a slash for ease of parsing, so make sure
976
# there is one (and only one) here.
977
func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
978
-e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
980
# Processed it all yet?
981
if test / = "$func_normal_abspath_tpath"; then
982
# If we ascended to the root using ".." the result may be empty now.
983
if test -z "$func_normal_abspath_result"; then
984
func_normal_abspath_result=/
988
func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
990
func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
992
# Figure out what to do with it
993
case $func_normal_abspath_tcomponent in
995
# Trailing empty path component, ignore it.
998
# Parent dir; strip last assembled component from result.
999
func_dirname "$func_normal_abspath_result"
1000
func_normal_abspath_result=$func_dirname_result
1003
# Actual path component, append it.
1004
func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1008
# Restore leading double-slash if one was found on entry.
1009
func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1013
# func_notquiet ARG...
1014
# --------------------
1015
# Echo program name prefixed message only when not in quiet mode.
1020
$opt_quiet || func_echo ${1+"$@"}
1022
# A bug in bash halts the script if the last line of a function
1023
# fails when set -e is in force, so we need another command to
1029
# func_relative_path SRCDIR DSTDIR
1030
# --------------------------------
1031
# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1032
func_relative_path ()
1036
func_relative_path_result=
1037
func_normal_abspath "$1"
1038
func_relative_path_tlibdir=$func_normal_abspath_result
1039
func_normal_abspath "$2"
1040
func_relative_path_tbindir=$func_normal_abspath_result
1042
# Ascend the tree starting from libdir
1044
# check if we have found a prefix of bindir
1045
case $func_relative_path_tbindir in
1046
$func_relative_path_tlibdir)
1047
# found an exact match
1048
func_relative_path_tcancelled=
1051
$func_relative_path_tlibdir*)
1052
# found a matching prefix
1053
func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1054
func_relative_path_tcancelled=$func_stripname_result
1055
if test -z "$func_relative_path_result"; then
1056
func_relative_path_result=.
1061
func_dirname $func_relative_path_tlibdir
1062
func_relative_path_tlibdir=$func_dirname_result
1063
if test -z "$func_relative_path_tlibdir"; then
1064
# Have to descend all the way to the root!
1065
func_relative_path_result=../$func_relative_path_result
1066
func_relative_path_tcancelled=$func_relative_path_tbindir
1069
func_relative_path_result=../$func_relative_path_result
1074
# Now calculate path; take care to avoid doubling-up slashes.
1075
func_stripname '' '/' "$func_relative_path_result"
1076
func_relative_path_result=$func_stripname_result
1077
func_stripname '/' '/' "$func_relative_path_tcancelled"
1078
if test -n "$func_stripname_result"; then
1079
func_append func_relative_path_result "/$func_stripname_result"
1082
# Normalisation. If bindir is libdir, return '.' else relative path.
1083
if test -n "$func_relative_path_result"; then
1084
func_stripname './' '' "$func_relative_path_result"
1085
func_relative_path_result=$func_stripname_result
1088
test -n "$func_relative_path_result" || func_relative_path_result=.
1094
# func_quote_for_eval ARG...
1095
# --------------------------
1096
# Aesthetically quote ARGs to be evaled later.
1097
# This function returns two values:
1098
# i) func_quote_for_eval_result
1099
# double-quoted, suitable for a subsequent eval
1100
# ii) func_quote_for_eval_unquoted_result
1101
# has all characters that are still active within double
1102
# quotes backslashified.
594
1103
func_quote_for_eval ()
598
func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
600
func_quote_for_eval_unquoted_result="$1" ;;
603
case $func_quote_for_eval_unquoted_result in
604
# Double-quote args containing shell metacharacters to delay
605
# word splitting, command substitution and and variable
606
# expansion for a subsequent eval.
607
# Many Bourne shells cannot handle close brackets correctly
608
# in scan sets, so we specify it separately.
609
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
610
func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
613
func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
1107
func_quote_for_eval_unquoted_result=
1108
func_quote_for_eval_result=
1109
while test 0 -lt $#; do
1112
_G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
1114
_G_unquoted_arg=$1 ;;
1116
if test -n "$func_quote_for_eval_unquoted_result"; then
1117
func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1119
func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1122
case $_G_unquoted_arg in
1123
# Double-quote args containing shell metacharacters to delay
1124
# word splitting, command substitution and variable expansion
1125
# for a subsequent eval.
1126
# Many Bourne shells cannot handle close brackets correctly
1127
# in scan sets, so we specify it separately.
1128
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1129
_G_quoted_arg=\"$_G_unquoted_arg\"
1132
_G_quoted_arg=$_G_unquoted_arg
1136
if test -n "$func_quote_for_eval_result"; then
1137
func_append func_quote_for_eval_result " $_G_quoted_arg"
1139
func_append func_quote_for_eval_result "$_G_quoted_arg"
618
# func_quote_for_expand arg
1146
# func_quote_for_expand ARG
1147
# -------------------------
619
1148
# Aesthetically quote ARG to be evaled later; same as above,
620
1149
# but do not quote variable references.
621
1150
func_quote_for_expand ()
625
my_arg=`$ECHO "$1" | $SED \
626
-e "$double_quote_subst" -e "$sed_double_backslash"` ;;
1156
_G_arg=`$ECHO "$1" | $SED \
1157
-e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
632
1163
# Double-quote args containing shell metacharacters to delay
633
1164
# word splitting and command substitution for a subsequent eval.
634
1165
# Many Bourne shells cannot handle close brackets correctly
635
1166
# in scan sets, so we specify it separately.
636
1167
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
641
func_quote_for_expand_result="$my_arg"
1172
func_quote_for_expand_result=$_G_arg
645
# func_show_eval cmd [fail_exp]
646
# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
1176
# func_stripname PREFIX SUFFIX NAME
1177
# ---------------------------------
1178
# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1179
# PREFIX and SUFFIX must not contain globbing or regex special
1180
# characters, hashes, percent signs, but SUFFIX may contain a leading
1181
# dot (in which case that matches only a dot).
1182
if test yes = "$_G_HAVE_XSI_OPS"; then
1183
eval 'func_stripname ()
1187
# pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1188
# positional parameters, so assign one to ordinary variable first.
1189
func_stripname_result=$3
1190
func_stripname_result=${func_stripname_result#"$1"}
1191
func_stripname_result=${func_stripname_result%"$2"}
1199
.*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1200
*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1206
# func_show_eval CMD [FAIL_EXP]
1207
# -----------------------------
1208
# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
647
1209
# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
648
1210
# is given, then evaluate it.
649
1211
func_show_eval ()
654
${opt_silent-false} || {
655
func_quote_for_expand "$my_cmd"
656
eval "func_echo $func_quote_for_expand_result"
1216
_G_fail_exp=${2-':'}
1218
func_quote_for_expand "$_G_cmd"
1219
eval "func_notquiet $func_quote_for_expand_result"
1224
if test 0 -ne "$_G_status"; then
1225
eval "(exit $_G_status); $_G_fail_exp"
659
if ${opt_dry_run-false}; then :; else
662
if test "$my_status" -eq 0; then :; else
663
eval "(exit $my_status); $my_fail_exp"
669
# func_show_eval_locale cmd [fail_exp]
670
# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
1231
# func_show_eval_locale CMD [FAIL_EXP]
1232
# ------------------------------------
1233
# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
671
1234
# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
672
1235
# is given, then evaluate it. Use the saved locale for evaluation.
673
1236
func_show_eval_locale ()
678
${opt_silent-false} || {
679
func_quote_for_expand "$my_cmd"
1241
_G_fail_exp=${2-':'}
1244
func_quote_for_expand "$_G_cmd"
680
1245
eval "func_echo $func_quote_for_expand_result"
683
if ${opt_dry_run-false}; then :; else
684
eval "$lt_user_locale
687
eval "$lt_safe_locale"
688
if test "$my_status" -eq 0; then :; else
689
eval "(exit $my_status); $my_fail_exp"
1249
eval "$_G_user_locale
1252
eval "$_G_safe_locale"
1253
if test 0 -ne "$_G_status"; then
1254
eval "(exit $_G_status); $_G_fail_exp"
695
1262
# Turn $1 into a string suitable for a shell variable name.
696
1263
# Result is stored in $func_tr_sh_result. All characters
697
1264
# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
698
1265
# if $1 begins with a digit, a '_' is prepended as well.
702
[0-9]* | *[!a-zA-Z0-9_]*)
703
func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
713
# Echo version message to standard output and exit.
726
/^# '$PROGRAM' (GNU /,/# warranty; / {
729
s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
736
# Echo short help message to standard output and exit.
741
$SED -n '/^# Usage:/,/^# *.*--help/ {
744
s/\$progname/'$progname'/
748
$ECHO "run \`$progname --help | more' for full usage"
753
# Echo long help message to standard output and exit,
754
# unless 'noexit' is passed as argument.
1271
[0-9]* | *[!a-zA-Z0-9_]*)
1272
func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1275
func_tr_sh_result=$1
1281
# func_verbose ARG...
1282
# -------------------
1283
# Echo program name prefixed message in verbose mode only.
1288
$opt_verbose && func_echo "$*"
1294
# func_warn_and_continue ARG...
1295
# -----------------------------
1296
# Echo program name prefixed warning message to standard error.
1297
func_warn_and_continue ()
1301
$require_term_colors
1303
func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1307
# func_warning CATEGORY ARG...
1308
# ----------------------------
1309
# Echo program name prefixed warning message to standard error. Warning
1310
# messages can be filtered according to CATEGORY, where this function
1311
# elides messages where CATEGORY is not listed in the global variable
1312
# 'opt_warning_types'.
1317
# CATEGORY must be in the warning_categories list!
1318
case " $warning_categories " in
1320
*) func_internal_error "invalid warning category '$1'" ;;
1326
case " $opt_warning_types " in
1327
*" $_G_category "*) $warning_func ${1+"$@"} ;;
1332
# func_sort_ver VER1 VER2
1333
# -----------------------
1334
# 'sort -V' is not generally available.
1335
# Note this deviates from the version comparison in automake
1336
# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1337
# but this should suffice as we won't be specifying old
1338
# version formats or redundant trailing .0 in bootstrap.conf.
1339
# If we did want full compatibility then we should probably
1340
# use m4_version_compare from autoconf.
1345
printf '%s\n%s\n' "$1" "$2" \
1346
| 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
1349
# func_lt_ver PREV CURR
1350
# ---------------------
1351
# Return true if PREV and CURR are in the correct order according to
1352
# func_sort_ver, otherwise false. Use it like this:
1354
# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1359
test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1364
# mode: shell-script
1366
# eval: (add-hook 'before-save-hook 'time-stamp)
1367
# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1368
# time-stamp-time-zone: "UTC"
1372
# Set a version string for this script.
1373
scriptversion=2014-01-07.03; # UTC
1375
# A portable, pluggable option parser for Bourne shell.
1376
# Written by Gary V. Vaughan, 2010
1378
# Copyright (C) 2010-2015 Free Software Foundation, Inc.
1379
# This is free software; see the source for copying conditions. There is NO
1380
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1382
# This program is free software: you can redistribute it and/or modify
1383
# it under the terms of the GNU General Public License as published by
1384
# the Free Software Foundation, either version 3 of the License, or
1385
# (at your option) any later version.
1387
# This program is distributed in the hope that it will be useful,
1388
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1389
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1390
# GNU General Public License for more details.
1392
# You should have received a copy of the GNU General Public License
1393
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1395
# Please report bugs or propose patches to gary@gnu.org.
1402
# This file is a library for parsing options in your shell scripts along
1403
# with assorted other useful supporting features that you can make use
1406
# For the simplest scripts you might need only:
1409
# . relative/path/to/funclib.sh
1410
# . relative/path/to/options-parser
1412
# func_options ${1+"$@"}
1413
# eval set dummy "$func_options_result"; shift
1414
# ...rest of your script...
1416
# In order for the '--version' option to work, you will need to have a
1417
# suitably formatted comment like the one at the top of this file
1418
# starting with '# Written by ' and ending with '# warranty; '.
1420
# For '-h' and '--help' to work, you will also need a one line
1421
# description of your script's purpose in a comment directly above the
1422
# '# Written by ' line, like the one at the top of this file.
1424
# The default options also support '--debug', which will turn on shell
1425
# execution tracing (see the comment above debug_cmd below for another
1426
# use), and '--verbose' and the func_verbose function to allow your script
1427
# to display verbose messages only when your user has specified
1430
# After sourcing this file, you can plug processing for additional
1431
# options by amending the variables from the 'Configuration' section
1432
# below, and following the instructions in the 'Option parsing'
1433
# section further down.
1435
## -------------- ##
1436
## Configuration. ##
1437
## -------------- ##
1439
# You should override these variables in your script after sourcing this
1440
# file so that they reflect the customisations you have added to the
1443
# The usage line for option parsing errors and the start of '-h' and
1444
# '--help' output messages. You can embed shell variables for delayed
1445
# expansion at the time the message is displayed, but you will need to
1446
# quote other shell meta-characters carefully to prevent them being
1447
# expanded when the contents are evaled.
1448
usage='$progpath [OPTION]...'
1450
# Short help message in response to '-h' and '--help'. Add to this or
1451
# override it after sourcing this library to reflect the full set of
1452
# options your script accepts.
1454
--debug enable verbose shell tracing
1455
-W, --warnings=CATEGORY
1456
report the warnings falling in CATEGORY [all]
1457
-v, --verbose verbosely report processing
1458
--version print version information and exit
1459
-h, --help print short or long help message and exit
1462
# Additional text appended to 'usage_message' in response to '--help'.
1464
Warning categories include:
1465
'all' show all warnings
1466
'none' turn off all the warnings
1467
'error' warnings are treated as fatal errors"
1469
# Help message printed before fatal option parsing errors.
1470
fatal_help="Try '\$progname --help' for more information."
1474
## ------------------------- ##
1475
## Hook function management. ##
1476
## ------------------------- ##
1478
# This section contains functions for adding, removing, and running hooks
1479
# to the main code. A hook is just a named list of of function, that can
1480
# be run in order later on.
1482
# func_hookable FUNC_NAME
1483
# -----------------------
1484
# Declare that FUNC_NAME will run hooks added with
1485
# 'func_add_hook FUNC_NAME ...'.
1490
func_append hookable_fns " $1"
1494
# func_add_hook FUNC_NAME HOOK_FUNC
1495
# ---------------------------------
1496
# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
1497
# first have been declared "hookable" by a call to 'func_hookable'.
1502
case " $hookable_fns " in
1504
*) func_fatal_error "'$1' does not accept hook functions." ;;
1507
eval func_append ${1}_hooks '" $2"'
1511
# func_remove_hook FUNC_NAME HOOK_FUNC
1512
# ------------------------------------
1513
# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
1518
eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
1522
# func_run_hooks FUNC_NAME [ARG]...
1523
# ---------------------------------
1524
# Run all hook functions registered to FUNC_NAME.
1525
# It is assumed that the list of hook functions contains nothing more
1526
# than a whitespace-delimited list of legal shell function names, and
1527
# no effort is wasted trying to catch shell meta-characters or preserve
1533
case " $hookable_fns " in
1535
*) func_fatal_error "'$1' does not support hook funcions.n" ;;
1538
eval _G_hook_fns=\$$1_hooks; shift
1540
for _G_hook in $_G_hook_fns; do
1541
eval $_G_hook '"$@"'
1543
# store returned options list back into positional
1544
# parameters for next 'cmd' execution.
1545
eval _G_hook_result=\$${_G_hook}_result
1546
eval set dummy "$_G_hook_result"; shift
1549
func_quote_for_eval ${1+"$@"}
1550
func_run_hooks_result=$func_quote_for_eval_result
1555
## --------------- ##
1556
## Option parsing. ##
1557
## --------------- ##
1559
# In order to add your own option parsing hooks, you must accept the
1560
# full positional parameter list in your hook function, remove any
1561
# options that you action, and then pass back the remaining unprocessed
1562
# options in '<hooked_function_name>_result', escaped suitably for
1563
# 'eval'. Like this:
1565
# my_options_prep ()
1569
# # Extend the existing usage message.
1570
# usage_message=$usage_message'
1571
# -s, --silent don'\''t print informational messages
1574
# func_quote_for_eval ${1+"$@"}
1575
# my_options_prep_result=$func_quote_for_eval_result
1577
# func_add_hook func_options_prep my_options_prep
1580
# my_silent_option ()
1584
# # Note that for efficiency, we parse as many options as we can
1585
# # recognise in a loop before passing the remainder back to the
1586
# # caller on the first unrecognised argument we encounter.
1587
# while test $# -gt 0; do
1590
# --silent|-s) opt_silent=: ;;
1591
# # Separate non-argument short options:
1592
# -s*) func_split_short_opt "$_G_opt"
1593
# set dummy "$func_split_short_opt_name" \
1594
# "-$func_split_short_opt_arg" ${1+"$@"}
1597
# *) set dummy "$_G_opt" "$*"; shift; break ;;
1601
# func_quote_for_eval ${1+"$@"}
1602
# my_silent_option_result=$func_quote_for_eval_result
1604
# func_add_hook func_parse_options my_silent_option
1607
# my_option_validation ()
1611
# $opt_silent && $opt_verbose && func_fatal_help "\
1612
# '--silent' and '--verbose' options are mutually exclusive."
1614
# func_quote_for_eval ${1+"$@"}
1615
# my_option_validation_result=$func_quote_for_eval_result
1617
# func_add_hook func_validate_options my_option_validation
1619
# You'll alse need to manually amend $usage_message to reflect the extra
1620
# options you parse. It's preferable to append if you can, so that
1621
# multiple option parsing hooks can be added safely.
1624
# func_options [ARG]...
1625
# ---------------------
1626
# All the functions called inside func_options are hookable. See the
1627
# individual implementations for details.
1628
func_hookable func_options
1633
func_options_prep ${1+"$@"}
1634
eval func_parse_options \
1635
${func_options_prep_result+"$func_options_prep_result"}
1636
eval func_validate_options \
1637
${func_parse_options_result+"$func_parse_options_result"}
1639
eval func_run_hooks func_options \
1640
${func_validate_options_result+"$func_validate_options_result"}
1642
# save modified positional parameters for caller
1643
func_options_result=$func_run_hooks_result
1647
# func_options_prep [ARG]...
1648
# --------------------------
1649
# All initialisations required before starting the option parse loop.
1650
# Note that when calling hook functions, we pass through the list of
1651
# positional parameters. If a hook function modifies that list, and
1652
# needs to propogate that back to rest of this script, then the complete
1653
# modified list must be put in 'func_run_hooks_result' before
1655
func_hookable func_options_prep
1656
func_options_prep ()
1664
func_run_hooks func_options_prep ${1+"$@"}
1666
# save modified positional parameters for caller
1667
func_options_prep_result=$func_run_hooks_result
1671
# func_parse_options [ARG]...
1672
# ---------------------------
1673
# The main option parsing loop.
1674
func_hookable func_parse_options
1675
func_parse_options ()
1679
func_parse_options_result=
1681
# this just eases exit handling
1682
while test $# -gt 0; do
1683
# Defer to hook functions for initial option parsing, so they
1684
# get priority in the event of reusing an option name.
1685
func_run_hooks func_parse_options ${1+"$@"}
1687
# Adjust func_parse_options positional parameters to match
1688
eval set dummy "$func_run_hooks_result"; shift
1690
# Break out of the loop if we already parsed every option.
1691
test $# -gt 0 || break
1696
--debug|-x) debug_cmd='set -x'
1697
func_echo "enabling shell trace mode"
1701
--no-warnings|--no-warning|--no-warn)
1702
set dummy --warnings none ${1+"$@"}
1706
--warnings|--warning|-W)
1707
test $# = 0 && func_missing_arg $_G_opt && break
1708
case " $warning_categories $1" in
1710
# trailing space prevents matching last $1 above
1711
func_append_uniq opt_warning_types " $1"
1714
opt_warning_types=$warning_categories
1717
opt_warning_types=none
1721
opt_warning_types=$warning_categories
1722
warning_func=func_fatal_error
1726
"unsupported warning category: '$1'"
1732
--verbose|-v) opt_verbose=: ;;
1733
--version) func_version ;;
1734
-\?|-h) func_usage ;;
1735
--help) func_help ;;
1737
# Separate optargs to long options (plugins may need this):
1738
--*=*) func_split_equals "$_G_opt"
1739
set dummy "$func_split_equals_lhs" \
1740
"$func_split_equals_rhs" ${1+"$@"}
1744
# Separate optargs to short options:
1746
func_split_short_opt "$_G_opt"
1747
set dummy "$func_split_short_opt_name" \
1748
"$func_split_short_opt_arg" ${1+"$@"}
1752
# Separate non-argument short options:
1754
func_split_short_opt "$_G_opt"
1755
set dummy "$func_split_short_opt_name" \
1756
"-$func_split_short_opt_arg" ${1+"$@"}
1761
-*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
1762
*) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1766
# save modified positional parameters for caller
1767
func_quote_for_eval ${1+"$@"}
1768
func_parse_options_result=$func_quote_for_eval_result
1772
# func_validate_options [ARG]...
1773
# ------------------------------
1774
# Perform any sanity checks on option settings and/or unconsumed
1776
func_hookable func_validate_options
1777
func_validate_options ()
1781
# Display all warnings if -W was not given.
1782
test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1784
func_run_hooks func_validate_options ${1+"$@"}
1786
# Bail if the options were screwed!
1787
$exit_cmd $EXIT_FAILURE
1789
# save modified positional parameters for caller
1790
func_validate_options_result=$func_run_hooks_result
1795
## ----------------- ##
1796
## Helper functions. ##
1797
## ----------------- ##
1799
# This section contains the helper functions used by the rest of the
1800
# hookable option parser framework in ascii-betical order.
1803
# func_fatal_help ARG...
1804
# ----------------------
1805
# Echo program name prefixed message to standard error, followed by
1806
# a help hint, and exit.
1811
eval \$ECHO \""Usage: $usage"\"
1812
eval \$ECHO \""$fatal_help"\"
1813
func_error ${1+"$@"}
1820
# Echo long help message to standard output and exit.
759
$SED -n '/^# Usage:/,/# Report bugs to/ {
763
s*\$progname*'$progname'*
765
s*\$SHELL*'"$SHELL"'*
767
s*\$LTCFLAGS*'"$LTCFLAGS"'*
769
s/\$with_gnu_ld/'"$with_gnu_ld"'/
770
s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
771
s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
775
/^# .* home page:/b print
776
/^# General help using/b print
779
if test -z "$1"; then
1826
$ECHO "$long_help_message"
784
# func_missing_arg argname
1831
# func_missing_arg ARGNAME
1832
# ------------------------
785
1833
# Echo program name prefixed message to standard error and set global
787
1835
func_missing_arg ()
791
func_error "missing argument for $1."
1839
func_error "Missing argument for '$1'."
796
# func_split_short_opt shortopt
1844
# func_split_equals STRING
1845
# ------------------------
1846
# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
1847
# splitting STRING at the '=' sign.
1848
test -z "$_G_HAVE_XSI_OPS" \
1850
test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1851
&& _G_HAVE_XSI_OPS=yes
1853
if test yes = "$_G_HAVE_XSI_OPS"
1855
# This is an XSI compatible shell, allowing a faster implementation...
1856
eval 'func_split_equals ()
1860
func_split_equals_lhs=${1%%=*}
1861
func_split_equals_rhs=${1#*=}
1862
test "x$func_split_equals_lhs" = "x$1" \
1863
&& func_split_equals_rhs=
1866
# ...otherwise fall back to using expr, which is often a shell builtin.
1867
func_split_equals ()
1871
func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
1872
func_split_equals_rhs=
1873
test "x$func_split_equals_lhs" = "x$1" \
1874
|| func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
1876
fi #func_split_equals
1879
# func_split_short_opt SHORTOPT
1880
# -----------------------------
797
1881
# Set func_split_short_opt_name and func_split_short_opt_arg shell
798
1882
# variables after splitting SHORTOPT after the 2nd character.
799
func_split_short_opt ()
801
my_sed_short_opt='1s/^\(..\).*$/\1/;q'
802
my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
804
func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
805
func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
806
} # func_split_short_opt may be replaced by extended shell implementation
809
# func_split_long_opt longopt
810
# Set func_split_long_opt_name and func_split_long_opt_arg shell
811
# variables after splitting LONGOPT at the `=' sign.
812
func_split_long_opt ()
814
my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
815
my_sed_long_arg='1s/^--[^=]*=//'
817
func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
818
func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
819
} # func_split_long_opt may be replaced by extended shell implementation
827
magic="%%%MAGIC variable%%%"
828
magic_exe="%%%MAGIC EXE variable%%%"
833
lo2o="s/\\.lo\$/.${objext}/"
834
o2lo="s/\\.${objext}\$/.lo/"
838
# If this variable is set in any of the actions, the command in it
839
# will be execed at the end. This prevents here-documents from being
840
# left over by shells.
843
# func_append var value
844
# Append VALUE to the end of shell variable VAR.
847
eval "${1}=\$${1}\${2}"
848
} # func_append may be replaced by extended shell implementation
850
# func_append_quoted var value
851
# Quote VALUE and append to the end of shell variable VAR, separated
853
func_append_quoted ()
855
func_quote_for_eval "${2}"
856
eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
857
} # func_append_quoted may be replaced by extended shell implementation
860
# func_arith arithmetic-term...
863
func_arith_result=`expr "${@}"`
864
} # func_arith may be replaced by extended shell implementation
868
# STRING may not start with a hyphen.
871
func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
872
} # func_len may be replaced by extended shell implementation
878
func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
879
} # func_lo2o may be replaced by extended shell implementation
882
# func_xform libobj-or-source
885
func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
886
} # func_xform may be replaced by extended shell implementation
889
# func_fatal_configuration arg...
1883
if test yes = "$_G_HAVE_XSI_OPS"
1885
# This is an XSI compatible shell, allowing a faster implementation...
1886
eval 'func_split_short_opt ()
1890
func_split_short_opt_arg=${1#??}
1891
func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1894
# ...otherwise fall back to using expr, which is often a shell builtin.
1895
func_split_short_opt ()
1899
func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
1900
func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
1902
fi #func_split_short_opt
1907
# Echo short help message to standard output and exit.
1913
$ECHO "Run '$progname --help |${PAGER-more}' for full usage"
1918
# func_usage_message
1919
# ------------------
1920
# Echo short help message to standard output.
1921
func_usage_message ()
1925
eval \$ECHO \""Usage: $usage"\"
1932
/^Written by/q' < "$progpath"
1934
eval \$ECHO \""$usage_message"\"
1940
# Echo version message to standard output and exit.
1945
printf '%s\n' "$progname $scriptversion"
1955
/^# Written by /,/# warranty; / {
1958
s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
1965
/^warranty; /q' < "$progpath"
1972
# mode: shell-script
1974
# eval: (add-hook 'before-save-hook 'time-stamp)
1975
# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1976
# time-stamp-time-zone: "UTC"
1979
# Set a version string.
1980
scriptversion='(GNU libtool) 2.4.6'
1985
# Libtool also displays the current mode in messages, so override
1986
# funclib.sh func_echo with this custom definition.
1995
for _G_line in $_G_message; do
1997
$ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
2003
# func_warning ARG...
2004
# -------------------
2005
# Libtool warnings are not categorized, so override funclib.sh
2006
# func_warning with this simpler definition.
2011
$warning_func ${1+"$@"}
2015
## ---------------- ##
2016
## Options parsing. ##
2017
## ---------------- ##
2019
# Hook in the functions to make sure our own options are parsed during
2020
# the option parsing loop.
2022
usage='$progpath [OPTION]... [MODE-ARG]...'
2024
# Short help message in response to '-h'.
2025
usage_message="Options:
2026
--config show all configuration variables
2027
--debug enable verbose shell tracing
2028
-n, --dry-run display commands without modifying any files
2029
--features display basic configuration information and exit
2030
--mode=MODE use operation mode MODE
2031
--no-warnings equivalent to '-Wnone'
2032
--preserve-dup-deps don't remove duplicate dependency libraries
2033
--quiet, --silent don't print informational messages
2034
--tag=TAG use configuration variables from tag TAG
2035
-v, --verbose print more informational messages than default
2036
--version print version information
2037
-W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
2038
-h, --help, --help-all print short, long, or detailed help message
2041
# Additional text appended to 'usage_message' in response to '--help'.
2047
$ECHO "$long_help_message
2049
MODE must be one of the following:
2051
clean remove files from the build directory
2052
compile compile a source file into a libtool object
2053
execute automatically set library path, then run a program
2054
finish complete the installation of libtool libraries
2055
install install libraries or executables
2056
link create a library or an executable
2057
uninstall remove libraries from an installed directory
2059
MODE-ARGS vary depending on the MODE. When passed as first option,
2060
'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2061
Try '$progname --help --mode=MODE' for a more detailed description of MODE.
2063
When reporting a bug, please describe a test case to reproduce it and
2064
include the following information:
2069
compiler flags: $LTCFLAGS
2070
linker: $LD (gnu? $with_gnu_ld)
2071
version: $progname (GNU libtool) 2.4.6
2072
automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2073
autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2075
Report bugs to <bug-libtool@gnu.org>.
2076
GNU libtool home page: <http://www.gnu.org/s/libtool/>.
2077
General help using GNU software: <http://www.gnu.org/gethelp/>."
2082
# func_lo2o OBJECT-NAME
2083
# ---------------------
2084
# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2087
lo2o=s/\\.lo\$/.$objext/
2088
o2lo=s/\\.$objext\$/.lo/
2090
if test yes = "$_G_HAVE_XSI_OPS"; then
2094
*.lo) func_lo2o_result=${1%.lo}.$objext ;;
2095
* ) func_lo2o_result=$1 ;;
2099
# func_xform LIBOBJ-OR-SOURCE
2100
# ---------------------------
2101
# Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2102
# suffix to a '.lo' libtool-object suffix.
2105
func_xform_result=${1%.*}.lo
2108
# ...otherwise fall back to using sed.
2111
func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2116
func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2121
# func_fatal_configuration ARG...
2122
# -------------------------------
890
2123
# Echo program name prefixed message to standard error, followed by
891
2124
# a configuration failure hint, and exit.
892
2125
func_fatal_configuration ()
895
func_error "See the $PACKAGE documentation for more information."
896
func_fatal_error "Fatal configuration error."
2127
func__fatal_error ${1+"$@"} \
2128
"See the $PACKAGE documentation for more information." \
2129
"Fatal configuration error."
901
2135
# Display the configuration for all the tags in this script.