466
538
# General Public License for more details.
468
540
# You should have received a copy of the GNU General Public License
469
# along with GNU Libtool; see the file COPYING. If not, a copy
470
# can be downloaded from http://www.gnu.org/licenses/gpl.html,
471
# or obtained by writing to the Free Software Foundation, Inc.,
472
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
541
# along with this program. If not, see <http://www.gnu.org/licenses/>.
474
# Usage: $progname [OPTION]... [MODE-ARG]...
476
# Provide generalized library-building support services.
478
# --config show all configuration variables
479
# --debug enable verbose shell tracing
480
# -n, --dry-run display commands without modifying any files
481
# --features display basic configuration information and exit
482
# --mode=MODE use operation mode MODE
483
# --preserve-dup-deps don't remove duplicate dependency libraries
484
# --quiet, --silent don't print informational messages
485
# --no-quiet, --no-silent
486
# print informational messages (default)
487
# --no-warn don't display warning messages
488
# --tag=TAG use configuration variables from tag TAG
489
# -v, --verbose print more informational messages than default
490
# --no-verbose don't print the extra informational messages
491
# --version print version information
492
# -h, --help, --help-all print short, long, or detailed help message
494
# MODE must be one of the following:
496
# clean remove files from the build directory
497
# compile compile a source file into a libtool object
498
# execute automatically set library path, then run a program
499
# finish complete the installation of libtool libraries
500
# install install libraries or executables
501
# link create a library or an executable
502
# uninstall remove libraries from an installed directory
504
# MODE-ARGS vary depending on the MODE. When passed as first option,
505
# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
506
# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
508
# When reporting a bug, please describe a test case to reproduce it and
509
# include the following information:
511
# host-triplet: $host
514
# compiler flags: $LTCFLAGS
515
# linker: $LD (gnu? $with_gnu_ld)
516
# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.11
517
# automake: $automake_version
518
# autoconf: $autoconf_version
520
# Report bugs to <bug-libtool@gnu.org>.
521
# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
522
# General help using GNU software: <http://www.gnu.org/gethelp/>.
526
VERSION="2.4.2 Debian-2.4.2-1.11"
528
package_revision=1.3337
530
# Be Bourne compatible
531
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
546
VERSION="2.4.6 Debian-2.4.6-0.1"
547
package_revision=2.4.6
554
# Run './libtool --help' for help with using this script from the
558
## ------------------------------- ##
559
## User overridable command paths. ##
560
## ------------------------------- ##
562
# After configure completes, it has a better idea of some of the
563
# shell tools we need than the defaults used by the functions shared
564
# with bootstrap, so set those here where they can still be over-
565
# ridden by the user, but otherwise take precedence.
567
: ${AUTOCONF="autoconf"}
568
: ${AUTOMAKE="automake"}
571
## -------------------------- ##
572
## Source external libraries. ##
573
## -------------------------- ##
575
# Much of our low-level functionality needs to be sourced from external
576
# libraries, which are installed to $pkgauxdir.
578
# Set a version string for this script.
579
scriptversion=2015-01-20.17; # UTC
581
# General shell script boiler plate, and helper functions.
582
# Written by Gary V. Vaughan, 2004
584
# Copyright (C) 2004-2015 Free Software Foundation, Inc.
585
# This is free software; see the source for copying conditions. There is NO
586
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
588
# This program is free software; you can redistribute it and/or modify
589
# it under the terms of the GNU General Public License as published by
590
# the Free Software Foundation; either version 3 of the License, or
591
# (at your option) any later version.
593
# As a special exception to the GNU General Public License, if you distribute
594
# this file as part of a program or library that is built using GNU Libtool,
595
# you may include this file under the same distribution terms that you use
596
# for the rest of that program.
598
# This program is distributed in the hope that it will be useful,
599
# but WITHOUT ANY WARRANTY; without even the implied warranty of
600
# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
601
# General Public License for more details.
603
# You should have received a copy of the GNU General Public License
604
# along with this program. If not, see <http://www.gnu.org/licenses/>.
606
# Please report bugs or propose patches to gary@gnu.org.
613
# Evaluate this file near the top of your script to gain access to
614
# the functions and variables defined here:
616
# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
618
# If you need to override any of the default environment variable
619
# settings, do that before evaluating this file.
622
## -------------------- ##
623
## Shell normalisation. ##
624
## -------------------- ##
626
# Some shells need a little help to be as Bourne compatible as possible.
627
# Before doing anything else, make sure all that help has been provided!
629
DUALCASE=1; export DUALCASE # for MKS sh
630
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
534
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
633
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
535
634
# is contrary to our usage. Disable this feature.
536
635
alias -g '${1+"$@"}'='"$@"'
537
636
setopt NO_GLOB_SUBST
539
case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
638
case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
541
BIN_SH=xpg4; export BIN_SH # for Tru64
542
DUALCASE=1; export DUALCASE # for MKS sh
544
# A function that is used when there is no print builtin or printf.
545
func_fallback_echo ()
547
eval 'cat <<_LTECHO_EOF
552
# NLS nuisances: We save the old values to restore during execute mode.
555
for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
641
# NLS nuisances: We save the old values in case they are required later.
644
for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
557
eval "if test \"\${$lt_var+set}\" = set; then
558
save_$lt_var=\$$lt_var
561
lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
562
lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
646
eval "if test set = \"\${$_G_var+set}\"; then
647
save_$_G_var=\$$_G_var
650
_G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
651
_G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
567
export LANGUAGE LC_ALL
572
# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
573
# is ksh but when the shell is invoked as "sh" and the current value of
574
# the _XPG environment variable is not equal to 1 (one), the special
575
# positional parameter $0, within a function call, is the name of the
656
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
658
# Make sure IFS has a sensible default
664
# There are apparently some retarded systems that use ';' as a PATH separator!
665
if test "${PATH_SEPARATOR+set}" != set; then
667
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
668
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
675
## ------------------------- ##
676
## Locate command utilities. ##
677
## ------------------------- ##
680
# func_executable_p FILE
681
# ----------------------
682
# Check that FILE is an executable regular file.
685
test -f "$1" && test -x "$1"
689
# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
690
# --------------------------------------------
691
# Search for either a program that responds to --version with output
692
# containing "GNU", or else returned by CHECK_FUNC otherwise, by
693
# trying all the directories in PATH with each of the elements of
696
# CHECK_FUNC should accept the path to a candidate program, and
697
# set $func_check_prog_result if it truncates its output less than
698
# $_G_path_prog_max characters.
706
_G_path_prog_found=false
707
_G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
708
for _G_dir in $_G_PATH; do
710
test -z "$_G_dir" && _G_dir=.
711
for _G_prog_name in $_G_progs_list; do
712
for _exeext in '' .EXE; do
713
_G_path_prog=$_G_dir/$_G_prog_name$_exeext
714
func_executable_p "$_G_path_prog" || continue
715
case `"$_G_path_prog" --version 2>&1` in
716
*GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
717
*) $_G_check_func $_G_path_prog
718
func_path_progs_result=$func_check_prog_result
721
$_G_path_prog_found && break 3
726
test -z "$func_path_progs_result" && {
727
echo "no acceptable sed could be found in \$PATH" >&2
733
# We want to be able to use the functions in this file before configure
734
# has figured out where the best binaries are kept, which means we have
735
# to search for them ourselves - except when the results are already set
736
# where we skip the searches.
738
# Unless the user overrides by setting SED, search the path for either GNU
739
# sed, or the sed that truncates its output the least.
741
_G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
742
for _G_i in 1 2 3 4 5 6 7; do
743
_G_sed_script=$_G_sed_script$nl$_G_sed_script
745
echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
748
func_check_prog_sed ()
753
printf 0123456789 >conftest.in
756
cat conftest.in conftest.in >conftest.tmp
757
mv conftest.tmp conftest.in
758
cp conftest.in conftest.nl
759
echo '' >> conftest.nl
760
"$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
761
diff conftest.out conftest.nl >/dev/null 2>&1 || break
762
_G_count=`expr $_G_count + 1`
763
if test "$_G_count" -gt "$_G_path_prog_max"; then
764
# Best one so far, save it but keep looking for a better one
765
func_check_prog_result=$_G_path_prog
766
_G_path_prog_max=$_G_count
768
# 10*(2^10) chars as input seems more than enough
769
test 10 -lt "$_G_count" && break
771
rm -f conftest.in conftest.tmp conftest.nl conftest.out
774
func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
776
SED=$func_path_progs_result
780
# Unless the user overrides by setting GREP, search the path for either GNU
781
# grep, or the grep that truncates its output the least.
783
func_check_prog_grep ()
789
printf 0123456789 >conftest.in
792
cat conftest.in conftest.in >conftest.tmp
793
mv conftest.tmp conftest.in
794
cp conftest.in conftest.nl
795
echo 'GREP' >> conftest.nl
796
"$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
797
diff conftest.out conftest.nl >/dev/null 2>&1 || break
798
_G_count=`expr $_G_count + 1`
799
if test "$_G_count" -gt "$_G_path_prog_max"; then
800
# Best one so far, save it but keep looking for a better one
801
func_check_prog_result=$_G_path_prog
802
_G_path_prog_max=$_G_count
804
# 10*(2^10) chars as input seems more than enough
805
test 10 -lt "$_G_count" && break
807
rm -f conftest.in conftest.tmp conftest.nl conftest.out
810
func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
811
GREP=$func_path_progs_result
815
## ------------------------------- ##
816
## User overridable command paths. ##
817
## ------------------------------- ##
819
# All uppercase variable names are used for environment variables. These
820
# variables can be overridden by the user before calling a script that
821
# uses them if a suitable command of that name is not already available
822
# in the command search PATH.
582
test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
825
: ${ECHO="printf %s\n"}
826
: ${EGREP="$GREP -E"}
827
: ${FGREP="$GREP -F"}
584
830
: ${MKDIR="mkdir"}
587
833
: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
588
: ${Xsed="$SED -e 1s/^X//"}
836
## -------------------- ##
837
## Useful sed snippets. ##
838
## -------------------- ##
840
sed_dirname='s|/[^/]*$||'
841
sed_basename='s|^.*/||'
843
# Sed substitution that helps us do robust quoting. It backslashifies
844
# metacharacters that are still active within double-quoted strings.
845
sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
847
# Same as above, but do not quote variable references.
848
sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
850
# Sed substitution that turns a string into a regex matching for the
852
sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
854
# Sed substitution that converts a w32 file name or path
855
# that contains forward slashes, into one that contains
856
# (escaped) backslashes. A very naive implementation.
857
sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
859
# Re-'\' parameter expansions in output of sed_double_quote_subst that
860
# were '\'-ed in input to the same. If an odd number of '\' preceded a
861
# '$' in input to sed_double_quote_subst, that '$' was protected from
862
# expansion. Since each input '\' is now two '\'s, look for any number
863
# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
868
sed_double_backslash="\
871
s/^$_G_bs2$_G_dollar/$_G_bs&/
872
s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
876
## ----------------- ##
877
## Global variables. ##
878
## ----------------- ##
880
# Except for the global variables explicitly listed below, the following
881
# functions in the '^func_' namespace, and the '^require_' namespace
882
# variables initialised in the 'Resource management' section, sourcing
883
# this file will not pollute your global namespace with anything
884
# else. There's no portable way to scope variables in Bourne shell
885
# though, so actually running these functions will sometimes place
886
# results into a variable named after the function, and often use
887
# temporary variables in the '^_G_' namespace. If you are careful to
888
# avoid using those namespaces casually in your sourcing script, things
889
# should continue to work as you expect. And, of course, you can freely
890
# overwrite any of the functions or variables defined here before
891
# calling anything to customize them.
593
895
EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
594
896
EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
898
# Allow overriding, eg assuming that you follow the convention of
899
# putting '$debug_cmd' at the start of all your functions, you can get
900
# bash to show function call trace with:
902
# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
903
debug_cmd=${debug_cmd-":"}
906
# By convention, finish your script with:
910
# so that you can set exit_status to non-zero if you want to indicate
911
# something went wrong during execution without actually bailing out at
912
# the point of failure.
596
913
exit_status=$EXIT_SUCCESS
598
# Make sure IFS has a sensible default
603
dirname="s,/[^/]*$,,"
606
# func_dirname file append nondir_replacement
607
# Compute the dirname of FILE. If nonempty, add APPEND to the result,
608
# otherwise set result to NONDIR_REPLACEMENT.
612
*/*) func_dirname_result="${1%/*}${2}" ;;
613
* ) func_dirname_result="${3}" ;;
615
} # Extended-shell func_dirname implementation
621
func_basename_result="${1##*/}"
622
} # Extended-shell func_basename implementation
625
# func_dirname_and_basename file append nondir_replacement
626
# perform func_basename and func_dirname in a single function
628
# dirname: Compute the dirname of FILE. If nonempty,
629
# add APPEND to the result, otherwise set result
630
# to NONDIR_REPLACEMENT.
631
# value returned in "$func_dirname_result"
632
# basename: Compute filename of FILE.
633
# value retuned in "$func_basename_result"
634
# Implementation must be kept synchronized with func_dirname
635
# and func_basename. For efficiency, we do not delegate to
636
# those functions but instead duplicate the functionality here.
637
func_dirname_and_basename ()
640
*/*) func_dirname_result="${1%/*}${2}" ;;
641
* ) func_dirname_result="${3}" ;;
643
func_basename_result="${1##*/}"
644
} # Extended-shell func_dirname_and_basename implementation
647
# func_stripname prefix suffix name
648
# strip PREFIX and SUFFIX off of NAME.
649
# PREFIX and SUFFIX must not contain globbing or regex special
650
# characters, hashes, percent signs, but SUFFIX may contain a leading
651
# dot (in which case that matches only a dot).
652
# func_strip_suffix prefix name
655
# pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
656
# positional parameters, so assign one to ordinary parameter first.
657
func_stripname_result=${3}
658
func_stripname_result=${func_stripname_result#"${1}"}
659
func_stripname_result=${func_stripname_result%"${2}"}
660
} # Extended-shell func_stripname implementation
663
# These SED scripts presuppose an absolute path with a trailing slash.
664
pathcar='s,^/\([^/]*\).*$,\1,'
665
pathcdr='s,^/[^/]*,,'
666
removedotparts=':dotsl
670
collapseslashes='s@/\{1,\}@/@g'
671
finalslash='s,/*$,/,'
673
# func_normal_abspath PATH
674
# Remove doubled-up and trailing slashes, "." path components,
675
# and cancel out any ".." path components in PATH after making
676
# it an absolute path.
677
# value returned in "$func_normal_abspath_result"
678
func_normal_abspath ()
680
# Start from root dir and reassemble the path.
681
func_normal_abspath_result=
682
func_normal_abspath_tpath=$1
683
func_normal_abspath_altnamespace=
684
case $func_normal_abspath_tpath in
686
# Empty path, that just means $cwd.
687
func_stripname '' '/' "`pwd`"
688
func_normal_abspath_result=$func_stripname_result
691
# The next three entries are used to spot a run of precisely
692
# two leading slashes without using negated character classes;
693
# we take advantage of case's first-match behaviour.
695
# Unusual form of absolute path, do nothing.
698
# Not necessarily an ordinary path; POSIX reserves leading '//'
699
# and for example Cygwin uses it to access remote file shares
700
# over CIFS/SMB, so we conserve a leading double slash if found.
701
func_normal_abspath_altnamespace=/
704
# Absolute path, do nothing.
707
# Relative path, prepend $cwd.
708
func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
711
# Cancel out all the simple stuff to save iterations. We also want
712
# the path to end with a slash for ease of parsing, so make sure
713
# there is one (and only one) here.
714
func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
715
-e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
717
# Processed it all yet?
718
if test "$func_normal_abspath_tpath" = / ; then
719
# If we ascended to the root using ".." the result may be empty now.
720
if test -z "$func_normal_abspath_result" ; then
721
func_normal_abspath_result=/
725
func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
727
func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
729
# Figure out what to do with it
730
case $func_normal_abspath_tcomponent in
732
# Trailing empty path component, ignore it.
735
# Parent dir; strip last assembled component from result.
736
func_dirname "$func_normal_abspath_result"
737
func_normal_abspath_result=$func_dirname_result
740
# Actual path component, append it.
741
func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
745
# Restore leading double-slash if one was found on entry.
746
func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
749
# func_relative_path SRCDIR DSTDIR
750
# generates a relative path from SRCDIR to DSTDIR, with a trailing
751
# slash if non-empty, suitable for immediately appending a filename
752
# without needing to append a separator.
753
# value returned in "$func_relative_path_result"
754
func_relative_path ()
756
func_relative_path_result=
757
func_normal_abspath "$1"
758
func_relative_path_tlibdir=$func_normal_abspath_result
759
func_normal_abspath "$2"
760
func_relative_path_tbindir=$func_normal_abspath_result
762
# Ascend the tree starting from libdir
764
# check if we have found a prefix of bindir
765
case $func_relative_path_tbindir in
766
$func_relative_path_tlibdir)
767
# found an exact match
768
func_relative_path_tcancelled=
771
$func_relative_path_tlibdir*)
772
# found a matching prefix
773
func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
774
func_relative_path_tcancelled=$func_stripname_result
775
if test -z "$func_relative_path_result"; then
776
func_relative_path_result=.
781
func_dirname $func_relative_path_tlibdir
782
func_relative_path_tlibdir=${func_dirname_result}
783
if test "x$func_relative_path_tlibdir" = x ; then
784
# Have to descend all the way to the root!
785
func_relative_path_result=../$func_relative_path_result
786
func_relative_path_tcancelled=$func_relative_path_tbindir
789
func_relative_path_result=../$func_relative_path_result
794
# Now calculate path; take care to avoid doubling-up slashes.
795
func_stripname '' '/' "$func_relative_path_result"
796
func_relative_path_result=$func_stripname_result
797
func_stripname '/' '/' "$func_relative_path_tcancelled"
798
if test "x$func_stripname_result" != x ; then
799
func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
802
# Normalisation. If bindir is libdir, return empty string,
803
# else relative path ending with a slash; either way, target
804
# file name can be directly appended.
805
if test ! -z "$func_relative_path_result"; then
806
func_stripname './' '' "$func_relative_path_result/"
807
func_relative_path_result=$func_stripname_result
811
# The name of this program:
812
func_dirname_and_basename "$progpath"
813
progname=$func_basename_result
815
# Make sure we have an absolute path for reexecution:
915
# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
916
# is ksh but when the shell is invoked as "sh" and the current value of
917
# the _XPG environment variable is not equal to 1 (one), the special
918
# positional parameter $0, within a function call, is the name of the
922
# The name of this program.
923
progname=`$ECHO "$progpath" |$SED "$sed_basename"`
925
# Make sure we have an absolute progpath for reexecution:
816
926
case $progpath in
817
927
[\\/]*|[A-Za-z]:\\*) ;;
819
progdir=$func_dirname_result
929
progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
820
930
progdir=`cd "$progdir" && pwd`
821
progpath="$progdir/$progname"
931
progpath=$progdir/$progname
825
935
IFS=${PATH_SEPARATOR-:}
826
936
for progdir in $PATH; do
828
938
test -x "$progdir/$progname" && break
831
941
test -n "$progdir" || progdir=`pwd`
832
progpath="$progdir/$progname"
942
progpath=$progdir/$progname
836
# Sed substitution that helps us do robust quoting. It backslashifies
837
# metacharacters that are still active within double-quoted strings.
838
Xsed="${SED}"' -e 1s/^X//'
839
sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
841
# Same as above, but do not quote variable references.
842
double_quote_subst='s/\(["`\\]\)/\\\1/g'
844
# Sed substitution that turns a string into a regex matching for the
846
sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
848
# Sed substitution that converts a w32 file name or path
849
# which contains forward slashes, into one that contains
850
# (escaped) backslashes. A very naive implementation.
851
lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
853
# Re-`\' parameter expansions in output of double_quote_subst that were
854
# `\'-ed in input to the same. If an odd number of `\' preceded a '$'
855
# in input to double_quote_subst, that '$' was protected from expansion.
856
# Since each input `\' is now two `\'s, look for any number of runs of
857
# four `\'s followed by two `\'s and then a '$'. `\' that '$'.
862
sed_double_backslash="\
866
s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
947
## ----------------- ##
948
## Standard options. ##
949
## ----------------- ##
951
# The following options affect the operation of the functions defined
952
# below, and should be set appropriately depending on run-time para-
953
# meters passed on the command line.
870
955
opt_dry_run=false
873
957
opt_verbose=false
877
# Echo program name prefixed message, along with the current mode
878
# name if it has been set yet.
959
# Categories 'all' and 'none' are always available. Append any others
960
# you will pass as the first argument to func_warning from your own
964
# By default, display warnings according to 'opt_warning_types'. Set
965
# 'warning_func' to ':' to elide all warnings, or func_fatal_error to
966
# treat the next displayed warning as a fatal error.
967
warning_func=func_warn_and_continue
969
# Set to 'all' to display all warnings, 'none' to suppress all
970
# warnings, or a space delimited list of some subset of
971
# 'warning_categories' to display only the listed warnings.
972
opt_warning_types=all
975
## -------------------- ##
976
## Resource management. ##
977
## -------------------- ##
979
# This section contains definitions for functions that each ensure a
980
# particular resource (a file, or a non-empty configuration variable for
981
# example) is available, and if appropriate to extract default values
982
# from pertinent package files. Call them using their associated
983
# 'require_*' variable to ensure that they are executed, at most, once.
985
# It's entirely deliberate that calling these functions can set
986
# variables that don't obey the namespace limitations obeyed by the rest
987
# of this file, in order that that they be as useful as possible to
991
# require_term_colors
992
# -------------------
993
# Allow display of bold text on terminals that support it.
994
require_term_colors=func_require_term_colors
995
func_require_term_colors ()
1000
# COLORTERM and USE_ANSI_COLORS environment variables take
1001
# precedence, because most terminfo databases neglect to describe
1002
# whether color sequences are supported.
1003
test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
1005
if test 1 = "$USE_ANSI_COLORS"; then
1006
# Standard ANSI escape sequences
1008
tc_bold='[1m'; tc_standout='[7m'
1009
tc_red='[31m'; tc_green='[32m'
1010
tc_blue='[34m'; tc_cyan='[36m'
1012
# Otherwise trust the terminfo database after all.
1013
test -n "`tput sgr0 2>/dev/null`" && {
1014
tc_reset=`tput sgr0`
1015
test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
1016
tc_standout=$tc_bold
1017
test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
1018
test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
1019
test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
1020
test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
1021
test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
1026
require_term_colors=:
1030
## ----------------- ##
1031
## Function library. ##
1032
## ----------------- ##
1034
# This section contains a variety of useful functions to call in your
1035
# scripts. Take note of the portable wrappers for features provided by
1036
# some modern shells, which will fall back to slower equivalents on
1037
# less featureful shells.
1040
# func_append VAR VALUE
1041
# ---------------------
1042
# Append VALUE onto the existing contents of VAR.
1044
# We should try to minimise forks, especially on Windows where they are
1045
# unreasonably slow, so skip the feature probes when bash or zsh are
1047
if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
1048
: ${_G_HAVE_ARITH_OP="yes"}
1049
: ${_G_HAVE_XSI_OPS="yes"}
1050
# The += operator was introduced in bash 3.1
1051
case $BASH_VERSION in
1052
[12].* | 3.0 | 3.0*) ;;
1054
: ${_G_HAVE_PLUSEQ_OP="yes"}
1060
# Can be empty, in which case the shell is probed, "yes" if += is
1061
# useable or anything else if it does not work.
1062
test -z "$_G_HAVE_PLUSEQ_OP" \
1063
&& (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
1064
&& _G_HAVE_PLUSEQ_OP=yes
1066
if test yes = "$_G_HAVE_PLUSEQ_OP"
1068
# This is an XSI compatible shell, allowing a faster implementation...
1069
eval 'func_append ()
1076
# ...otherwise fall back to using expr, which is often a shell builtin.
1086
# func_append_quoted VAR VALUE
1087
# ----------------------------
1088
# Quote VALUE and append to the end of shell variable VAR, separated
1090
if test yes = "$_G_HAVE_PLUSEQ_OP"; then
1091
eval 'func_append_quoted ()
1095
func_quote_for_eval "$2"
1096
eval "$1+=\\ \$func_quote_for_eval_result"
1099
func_append_quoted ()
1103
func_quote_for_eval "$2"
1104
eval "$1=\$$1\\ \$func_quote_for_eval_result"
1109
# func_append_uniq VAR VALUE
1110
# --------------------------
1111
# Append unique VALUE onto the existing contents of VAR, assuming
1112
# entries are delimited by the first character of VALUE. For example:
1114
# func_append_uniq options " --another-option option-argument"
1116
# will only append to $options if " --another-option option-argument "
1117
# is not already present somewhere in $options already (note spaces at
1118
# each end implied by leading space in second argument).
1123
eval _G_current_value='`$ECHO $'$1'`'
1124
_G_delim=`expr "$2" : '\(.\)'`
1126
case $_G_delim$_G_current_value$_G_delim in
1128
*) func_append "$@" ;;
1133
# func_arith TERM...
1134
# ------------------
1135
# Set func_arith_result to the result of evaluating TERMs.
1136
test -z "$_G_HAVE_ARITH_OP" \
1137
&& (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
1138
&& _G_HAVE_ARITH_OP=yes
1140
if test yes = "$_G_HAVE_ARITH_OP"; then
1145
func_arith_result=$(( $* ))
1152
func_arith_result=`expr "$@"`
1157
# func_basename FILE
1158
# ------------------
1159
# Set func_basename_result to FILE with everything up to and including
1160
# the last / stripped.
1161
if test yes = "$_G_HAVE_XSI_OPS"; then
1162
# If this shell supports suffix pattern removal, then use it to avoid
1163
# forking. Hide the definitions single quotes in case the shell chokes
1164
# on unsupported syntax...
1165
_b='func_basename_result=${1##*/}'
1167
*/*) func_dirname_result=${1%/*}$2 ;;
1168
* ) func_dirname_result=$3 ;;
1172
# ...otherwise fall back to using sed.
1173
_b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
1174
_d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
1175
if test "X$func_dirname_result" = "X$1"; then
1176
func_dirname_result=$3
1178
func_append func_dirname_result "$2"
1182
eval 'func_basename ()
1190
# func_dirname FILE APPEND NONDIR_REPLACEMENT
1191
# -------------------------------------------
1192
# Compute the dirname of FILE. If nonempty, add APPEND to the result,
1193
# otherwise set result to NONDIR_REPLACEMENT.
1194
eval 'func_dirname ()
1202
# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
1203
# --------------------------------------------------------
1204
# Perform func_basename and func_dirname in a single function
1206
# dirname: Compute the dirname of FILE. If nonempty,
1207
# add APPEND to the result, otherwise set result
1208
# to NONDIR_REPLACEMENT.
1209
# value returned in "$func_dirname_result"
1210
# basename: Compute filename of FILE.
1211
# value retuned in "$func_basename_result"
1212
# For efficiency, we do not delegate to the functions above but instead
1213
# duplicate the functionality here.
1214
eval 'func_dirname_and_basename ()
1225
# Echo program name prefixed message.
881
$ECHO "$progname: ${opt_mode+$opt_mode: }$*"
884
# func_verbose arg...
885
# Echo program name prefixed message in verbose mode only.
888
$opt_verbose && func_echo ${1+"$@"}
890
# A bug in bash halts the script if the last line of a function
891
# fails when set -e is in force, so we need another command to
896
# func_echo_all arg...
1234
for _G_line in $_G_message; do
1236
$ECHO "$progname: $_G_line"
1242
# func_echo_all ARG...
1243
# --------------------
897
1244
# Invoke $ECHO with all args, space-separated.
898
1245
func_echo_all ()
1251
# func_echo_infix_1 INFIX ARG...
1252
# ------------------------------
1253
# Echo program name, followed by INFIX on the first line, with any
1254
# additional lines not showing INFIX.
1255
func_echo_infix_1 ()
1259
$require_term_colors
1263
_G_prefix="$progname: $_G_infix: "
1266
# Strip color escape sequences before counting printable length
1267
for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
1269
test -n "$_G_tc" && {
1270
_G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
1271
_G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
1274
_G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
1276
func_echo_infix_1_IFS=$IFS
1278
for _G_line in $_G_message; do
1279
IFS=$func_echo_infix_1_IFS
1280
$ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
1281
_G_prefix=$_G_indent
1283
IFS=$func_echo_infix_1_IFS
904
1289
# Echo program name prefixed message to standard error.
907
$ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
910
# func_warning arg...
911
# Echo program name prefixed warning message to standard error.
914
$opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
920
# func_fatal_error arg...
1294
$require_term_colors
1296
func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
1300
# func_fatal_error ARG...
1301
# -----------------------
921
1302
# Echo program name prefixed message to standard error, and exit.
922
1303
func_fatal_error ()
925
1308
exit $EXIT_FAILURE
928
# func_fatal_help arg...
929
# Echo program name prefixed message to standard error, followed by
930
# a help hint, and exit.
934
func_fatal_error "$help"
936
help="Try \`$progname --help' for more information." ## default
939
# func_grep expression filename
1312
# func_grep EXPRESSION FILENAME
1313
# -----------------------------
940
1314
# Check whether EXPRESSION matches any line of FILENAME, without output.
943
1319
$GREP "$1" "$2" >/dev/null 2>&1
947
# func_mkdir_p directory-path
1325
# Set func_len_result to the length of STRING. STRING may not
1326
# start with a hyphen.
1327
test -z "$_G_HAVE_XSI_OPS" \
1329
test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1330
&& _G_HAVE_XSI_OPS=yes
1332
if test yes = "$_G_HAVE_XSI_OPS"; then
1337
func_len_result=${#1}
1344
func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
1349
# func_mkdir_p DIRECTORY-PATH
1350
# ---------------------------
948
1351
# Make sure the entire path to DIRECTORY-PATH is available.
951
my_directory_path="$1"
954
if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
956
# Protect directory names starting with `-'
957
case $my_directory_path in
958
-*) my_directory_path="./$my_directory_path" ;;
1356
_G_directory_path=$1
1359
if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
1361
# Protect directory names starting with '-'
1362
case $_G_directory_path in
1363
-*) _G_directory_path=./$_G_directory_path ;;
961
1366
# While some portion of DIR does not yet exist...
962
while test ! -d "$my_directory_path"; do
1367
while test ! -d "$_G_directory_path"; do
963
1368
# ...make a list in topmost first order. Use a colon delimited
964
1369
# list incase some portion of path contains whitespace.
965
my_dir_list="$my_directory_path:$my_dir_list"
1370
_G_dir_list=$_G_directory_path:$_G_dir_list
967
1372
# If the last portion added has no slash in it, the list is done
968
case $my_directory_path in */*) ;; *) break ;; esac
1373
case $_G_directory_path in */*) ;; *) break ;; esac
970
1375
# ...otherwise throw away the child directory and loop
971
my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
1376
_G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
973
my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
1378
_G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
975
save_mkdir_p_IFS="$IFS"; IFS=':'
976
for my_dir in $my_dir_list; do
977
IFS="$save_mkdir_p_IFS"
978
# mkdir can fail with a `File exist' error if two processes
1380
func_mkdir_p_IFS=$IFS; IFS=:
1381
for _G_dir in $_G_dir_list; do
1382
IFS=$func_mkdir_p_IFS
1383
# mkdir can fail with a 'File exist' error if two processes
979
1384
# try to create one of the directories concurrently. Don't
980
1385
# stop in that case!
981
$MKDIR "$my_dir" 2>/dev/null || :
1386
$MKDIR "$_G_dir" 2>/dev/null || :
983
IFS="$save_mkdir_p_IFS"
1388
IFS=$func_mkdir_p_IFS
985
1390
# Bail out if we (or some other process) failed to create a directory.
986
test -d "$my_directory_path" || \
987
func_fatal_error "Failed to create \`$1'"
1391
test -d "$_G_directory_path" || \
1392
func_fatal_error "Failed to create '$1'"
992
# func_mktempdir [string]
1397
# func_mktempdir [BASENAME]
1398
# -------------------------
993
1399
# Make a temporary directory that won't clash with other running
994
1400
# libtool processes, and avoids race conditions if possible. If
995
# given, STRING is the basename for that directory.
1401
# given, BASENAME is the basename for that directory.
996
1402
func_mktempdir ()
998
my_template="${TMPDIR-/tmp}/${1-$progname}"
1000
if test "$opt_dry_run" = ":"; then
1406
_G_template=${TMPDIR-/tmp}/${1-$progname}
1408
if test : = "$opt_dry_run"; then
1001
1409
# Return a directory name, but don't create it in dry-run mode
1002
my_tmpdir="${my_template}-$$"
1410
_G_tmpdir=$_G_template-$$
1005
1413
# If mktemp works, use that first and foremost
1006
my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
1414
_G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
1008
if test ! -d "$my_tmpdir"; then
1416
if test ! -d "$_G_tmpdir"; then
1009
1417
# Failing that, at least try and use $RANDOM to avoid a race
1010
my_tmpdir="${my_template}-${RANDOM-0}$$"
1418
_G_tmpdir=$_G_template-${RANDOM-0}$$
1012
save_mktempdir_umask=`umask`
1420
func_mktempdir_umask=`umask`
1015
umask $save_mktempdir_umask
1423
umask $func_mktempdir_umask
1018
1426
# If we're not in dry-run mode, bomb out on failure
1019
test -d "$my_tmpdir" || \
1020
func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
1027
# func_quote_for_eval arg
1028
# Aesthetically quote ARG to be evaled later.
1029
# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
1030
# is double-quoted, suitable for a subsequent eval, whereas
1031
# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
1032
# which are still active within double quotes backslashified.
1427
test -d "$_G_tmpdir" || \
1428
func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
1435
# func_normal_abspath PATH
1436
# ------------------------
1437
# Remove doubled-up and trailing slashes, "." path components,
1438
# and cancel out any ".." path components in PATH after making
1439
# it an absolute path.
1440
func_normal_abspath ()
1444
# These SED scripts presuppose an absolute path with a trailing slash.
1445
_G_pathcar='s|^/\([^/]*\).*$|\1|'
1446
_G_pathcdr='s|^/[^/]*||'
1447
_G_removedotparts=':dotsl
1451
_G_collapseslashes='s|/\{1,\}|/|g'
1452
_G_finalslash='s|/*$|/|'
1454
# Start from root dir and reassemble the path.
1455
func_normal_abspath_result=
1456
func_normal_abspath_tpath=$1
1457
func_normal_abspath_altnamespace=
1458
case $func_normal_abspath_tpath in
1460
# Empty path, that just means $cwd.
1461
func_stripname '' '/' "`pwd`"
1462
func_normal_abspath_result=$func_stripname_result
1465
# The next three entries are used to spot a run of precisely
1466
# two leading slashes without using negated character classes;
1467
# we take advantage of case's first-match behaviour.
1469
# Unusual form of absolute path, do nothing.
1472
# Not necessarily an ordinary path; POSIX reserves leading '//'
1473
# and for example Cygwin uses it to access remote file shares
1474
# over CIFS/SMB, so we conserve a leading double slash if found.
1475
func_normal_abspath_altnamespace=/
1478
# Absolute path, do nothing.
1481
# Relative path, prepend $cwd.
1482
func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
1486
# Cancel out all the simple stuff to save iterations. We also want
1487
# the path to end with a slash for ease of parsing, so make sure
1488
# there is one (and only one) here.
1489
func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
1490
-e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
1492
# Processed it all yet?
1493
if test / = "$func_normal_abspath_tpath"; then
1494
# If we ascended to the root using ".." the result may be empty now.
1495
if test -z "$func_normal_abspath_result"; then
1496
func_normal_abspath_result=/
1500
func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
1502
func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
1504
# Figure out what to do with it
1505
case $func_normal_abspath_tcomponent in
1507
# Trailing empty path component, ignore it.
1510
# Parent dir; strip last assembled component from result.
1511
func_dirname "$func_normal_abspath_result"
1512
func_normal_abspath_result=$func_dirname_result
1515
# Actual path component, append it.
1516
func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
1520
# Restore leading double-slash if one was found on entry.
1521
func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
1525
# func_notquiet ARG...
1526
# --------------------
1527
# Echo program name prefixed message only when not in quiet mode.
1532
$opt_quiet || func_echo ${1+"$@"}
1534
# A bug in bash halts the script if the last line of a function
1535
# fails when set -e is in force, so we need another command to
1541
# func_relative_path SRCDIR DSTDIR
1542
# --------------------------------
1543
# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1544
func_relative_path ()
1548
func_relative_path_result=
1549
func_normal_abspath "$1"
1550
func_relative_path_tlibdir=$func_normal_abspath_result
1551
func_normal_abspath "$2"
1552
func_relative_path_tbindir=$func_normal_abspath_result
1554
# Ascend the tree starting from libdir
1556
# check if we have found a prefix of bindir
1557
case $func_relative_path_tbindir in
1558
$func_relative_path_tlibdir)
1559
# found an exact match
1560
func_relative_path_tcancelled=
1563
$func_relative_path_tlibdir*)
1564
# found a matching prefix
1565
func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
1566
func_relative_path_tcancelled=$func_stripname_result
1567
if test -z "$func_relative_path_result"; then
1568
func_relative_path_result=.
1573
func_dirname $func_relative_path_tlibdir
1574
func_relative_path_tlibdir=$func_dirname_result
1575
if test -z "$func_relative_path_tlibdir"; then
1576
# Have to descend all the way to the root!
1577
func_relative_path_result=../$func_relative_path_result
1578
func_relative_path_tcancelled=$func_relative_path_tbindir
1581
func_relative_path_result=../$func_relative_path_result
1586
# Now calculate path; take care to avoid doubling-up slashes.
1587
func_stripname '' '/' "$func_relative_path_result"
1588
func_relative_path_result=$func_stripname_result
1589
func_stripname '/' '/' "$func_relative_path_tcancelled"
1590
if test -n "$func_stripname_result"; then
1591
func_append func_relative_path_result "/$func_stripname_result"
1594
# Normalisation. If bindir is libdir, return '.' else relative path.
1595
if test -n "$func_relative_path_result"; then
1596
func_stripname './' '' "$func_relative_path_result"
1597
func_relative_path_result=$func_stripname_result
1600
test -n "$func_relative_path_result" || func_relative_path_result=.
1606
# func_quote_for_eval ARG...
1607
# --------------------------
1608
# Aesthetically quote ARGs to be evaled later.
1609
# This function returns two values:
1610
# i) func_quote_for_eval_result
1611
# double-quoted, suitable for a subsequent eval
1612
# ii) func_quote_for_eval_unquoted_result
1613
# has all characters that are still active within double
1614
# quotes backslashified.
1033
1615
func_quote_for_eval ()
1037
func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
1039
func_quote_for_eval_unquoted_result="$1" ;;
1042
case $func_quote_for_eval_unquoted_result in
1043
# Double-quote args containing shell metacharacters to delay
1044
# word splitting, command substitution and and variable
1045
# expansion for a subsequent eval.
1046
# Many Bourne shells cannot handle close brackets correctly
1047
# in scan sets, so we specify it separately.
1048
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1049
func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
1052
func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
1619
func_quote_for_eval_unquoted_result=
1620
func_quote_for_eval_result=
1621
while test 0 -lt $#; do
1624
_G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
1626
_G_unquoted_arg=$1 ;;
1628
if test -n "$func_quote_for_eval_unquoted_result"; then
1629
func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1631
func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1634
case $_G_unquoted_arg in
1635
# Double-quote args containing shell metacharacters to delay
1636
# word splitting, command substitution and variable expansion
1637
# for a subsequent eval.
1638
# Many Bourne shells cannot handle close brackets correctly
1639
# in scan sets, so we specify it separately.
1640
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1641
_G_quoted_arg=\"$_G_unquoted_arg\"
1644
_G_quoted_arg=$_G_unquoted_arg
1648
if test -n "$func_quote_for_eval_result"; then
1649
func_append func_quote_for_eval_result " $_G_quoted_arg"
1651
func_append func_quote_for_eval_result "$_G_quoted_arg"
1057
# func_quote_for_expand arg
1658
# func_quote_for_expand ARG
1659
# -------------------------
1058
1660
# Aesthetically quote ARG to be evaled later; same as above,
1059
1661
# but do not quote variable references.
1060
1662
func_quote_for_expand ()
1064
my_arg=`$ECHO "$1" | $SED \
1065
-e "$double_quote_subst" -e "$sed_double_backslash"` ;;
1668
_G_arg=`$ECHO "$1" | $SED \
1669
-e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
1071
1675
# Double-quote args containing shell metacharacters to delay
1072
1676
# word splitting and command substitution for a subsequent eval.
1073
1677
# Many Bourne shells cannot handle close brackets correctly
1074
1678
# in scan sets, so we specify it separately.
1075
1679
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1076
my_arg="\"$my_arg\""
1080
func_quote_for_expand_result="$my_arg"
1684
func_quote_for_expand_result=$_G_arg
1084
# func_show_eval cmd [fail_exp]
1085
# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
1688
# func_stripname PREFIX SUFFIX NAME
1689
# ---------------------------------
1690
# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1691
# PREFIX and SUFFIX must not contain globbing or regex special
1692
# characters, hashes, percent signs, but SUFFIX may contain a leading
1693
# dot (in which case that matches only a dot).
1694
if test yes = "$_G_HAVE_XSI_OPS"; then
1695
eval 'func_stripname ()
1699
# pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1700
# positional parameters, so assign one to ordinary variable first.
1701
func_stripname_result=$3
1702
func_stripname_result=${func_stripname_result#"$1"}
1703
func_stripname_result=${func_stripname_result%"$2"}
1711
.*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1712
*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1718
# func_show_eval CMD [FAIL_EXP]
1719
# -----------------------------
1720
# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1086
1721
# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1087
1722
# is given, then evaluate it.
1088
1723
func_show_eval ()
1091
my_fail_exp="${2-:}"
1093
${opt_silent-false} || {
1094
func_quote_for_expand "$my_cmd"
1095
eval "func_echo $func_quote_for_expand_result"
1728
_G_fail_exp=${2-':'}
1730
func_quote_for_expand "$_G_cmd"
1731
eval "func_notquiet $func_quote_for_expand_result"
1736
if test 0 -ne "$_G_status"; then
1737
eval "(exit $_G_status); $_G_fail_exp"
1098
if ${opt_dry_run-false}; then :; else
1101
if test "$my_status" -eq 0; then :; else
1102
eval "(exit $my_status); $my_fail_exp"
1108
# func_show_eval_locale cmd [fail_exp]
1109
# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
1743
# func_show_eval_locale CMD [FAIL_EXP]
1744
# ------------------------------------
1745
# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1110
1746
# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1111
1747
# is given, then evaluate it. Use the saved locale for evaluation.
1112
1748
func_show_eval_locale ()
1115
my_fail_exp="${2-:}"
1117
${opt_silent-false} || {
1118
func_quote_for_expand "$my_cmd"
1753
_G_fail_exp=${2-':'}
1756
func_quote_for_expand "$_G_cmd"
1119
1757
eval "func_echo $func_quote_for_expand_result"
1122
if ${opt_dry_run-false}; then :; else
1123
eval "$lt_user_locale
1126
eval "$lt_safe_locale"
1127
if test "$my_status" -eq 0; then :; else
1128
eval "(exit $my_status); $my_fail_exp"
1761
eval "$_G_user_locale
1764
eval "$_G_safe_locale"
1765
if test 0 -ne "$_G_status"; then
1766
eval "(exit $_G_status); $_G_fail_exp"
1134
1774
# Turn $1 into a string suitable for a shell variable name.
1135
1775
# Result is stored in $func_tr_sh_result. All characters
1136
1776
# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1137
1777
# if $1 begins with a digit, a '_' is prepended as well.
1141
[0-9]* | *[!a-zA-Z0-9_]*)
1142
func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
1145
func_tr_sh_result=$1
1152
# Echo version message to standard output and exit.
1165
/^# '$PROGRAM' (GNU /,/# warranty; / {
1168
s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
1175
# Echo short help message to standard output and exit.
1180
$SED -n '/^# Usage:/,/^# *.*--help/ {
1183
s/\$progname/'$progname'/
1187
$ECHO "run \`$progname --help | more' for full usage"
1191
# func_help [NOEXIT]
1192
# Echo long help message to standard output and exit,
1193
# unless 'noexit' is passed as argument.
1783
[0-9]* | *[!a-zA-Z0-9_]*)
1784
func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1787
func_tr_sh_result=$1
1793
# func_verbose ARG...
1794
# -------------------
1795
# Echo program name prefixed message in verbose mode only.
1800
$opt_verbose && func_echo "$*"
1806
# func_warn_and_continue ARG...
1807
# -----------------------------
1808
# Echo program name prefixed warning message to standard error.
1809
func_warn_and_continue ()
1813
$require_term_colors
1815
func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1819
# func_warning CATEGORY ARG...
1820
# ----------------------------
1821
# Echo program name prefixed warning message to standard error. Warning
1822
# messages can be filtered according to CATEGORY, where this function
1823
# elides messages where CATEGORY is not listed in the global variable
1824
# 'opt_warning_types'.
1829
# CATEGORY must be in the warning_categories list!
1830
case " $warning_categories " in
1832
*) func_internal_error "invalid warning category '$1'" ;;
1838
case " $opt_warning_types " in
1839
*" $_G_category "*) $warning_func ${1+"$@"} ;;
1844
# func_sort_ver VER1 VER2
1845
# -----------------------
1846
# 'sort -V' is not generally available.
1847
# Note this deviates from the version comparison in automake
1848
# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1849
# but this should suffice as we won't be specifying old
1850
# version formats or redundant trailing .0 in bootstrap.conf.
1851
# If we did want full compatibility then we should probably
1852
# use m4_version_compare from autoconf.
1857
printf '%s\n%s\n' "$1" "$2" \
1858
| 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
1861
# func_lt_ver PREV CURR
1862
# ---------------------
1863
# Return true if PREV and CURR are in the correct order according to
1864
# func_sort_ver, otherwise false. Use it like this:
1866
# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
1871
test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1876
# mode: shell-script
1878
# eval: (add-hook 'before-save-hook 'time-stamp)
1879
# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1880
# time-stamp-time-zone: "UTC"
1884
# Set a version string for this script.
1885
scriptversion=2014-01-07.03; # UTC
1887
# A portable, pluggable option parser for Bourne shell.
1888
# Written by Gary V. Vaughan, 2010
1890
# Copyright (C) 2010-2015 Free Software Foundation, Inc.
1891
# This is free software; see the source for copying conditions. There is NO
1892
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1894
# This program is free software: you can redistribute it and/or modify
1895
# it under the terms of the GNU General Public License as published by
1896
# the Free Software Foundation, either version 3 of the License, or
1897
# (at your option) any later version.
1899
# This program is distributed in the hope that it will be useful,
1900
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1901
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1902
# GNU General Public License for more details.
1904
# You should have received a copy of the GNU General Public License
1905
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1907
# Please report bugs or propose patches to gary@gnu.org.
1914
# This file is a library for parsing options in your shell scripts along
1915
# with assorted other useful supporting features that you can make use
1918
# For the simplest scripts you might need only:
1921
# . relative/path/to/funclib.sh
1922
# . relative/path/to/options-parser
1924
# func_options ${1+"$@"}
1925
# eval set dummy "$func_options_result"; shift
1926
# ...rest of your script...
1928
# In order for the '--version' option to work, you will need to have a
1929
# suitably formatted comment like the one at the top of this file
1930
# starting with '# Written by ' and ending with '# warranty; '.
1932
# For '-h' and '--help' to work, you will also need a one line
1933
# description of your script's purpose in a comment directly above the
1934
# '# Written by ' line, like the one at the top of this file.
1936
# The default options also support '--debug', which will turn on shell
1937
# execution tracing (see the comment above debug_cmd below for another
1938
# use), and '--verbose' and the func_verbose function to allow your script
1939
# to display verbose messages only when your user has specified
1942
# After sourcing this file, you can plug processing for additional
1943
# options by amending the variables from the 'Configuration' section
1944
# below, and following the instructions in the 'Option parsing'
1945
# section further down.
1947
## -------------- ##
1948
## Configuration. ##
1949
## -------------- ##
1951
# You should override these variables in your script after sourcing this
1952
# file so that they reflect the customisations you have added to the
1955
# The usage line for option parsing errors and the start of '-h' and
1956
# '--help' output messages. You can embed shell variables for delayed
1957
# expansion at the time the message is displayed, but you will need to
1958
# quote other shell meta-characters carefully to prevent them being
1959
# expanded when the contents are evaled.
1960
usage='$progpath [OPTION]...'
1962
# Short help message in response to '-h' and '--help'. Add to this or
1963
# override it after sourcing this library to reflect the full set of
1964
# options your script accepts.
1966
--debug enable verbose shell tracing
1967
-W, --warnings=CATEGORY
1968
report the warnings falling in CATEGORY [all]
1969
-v, --verbose verbosely report processing
1970
--version print version information and exit
1971
-h, --help print short or long help message and exit
1974
# Additional text appended to 'usage_message' in response to '--help'.
1976
Warning categories include:
1977
'all' show all warnings
1978
'none' turn off all the warnings
1979
'error' warnings are treated as fatal errors"
1981
# Help message printed before fatal option parsing errors.
1982
fatal_help="Try '\$progname --help' for more information."
1986
## ------------------------- ##
1987
## Hook function management. ##
1988
## ------------------------- ##
1990
# This section contains functions for adding, removing, and running hooks
1991
# to the main code. A hook is just a named list of of function, that can
1992
# be run in order later on.
1994
# func_hookable FUNC_NAME
1995
# -----------------------
1996
# Declare that FUNC_NAME will run hooks added with
1997
# 'func_add_hook FUNC_NAME ...'.
2002
func_append hookable_fns " $1"
2006
# func_add_hook FUNC_NAME HOOK_FUNC
2007
# ---------------------------------
2008
# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
2009
# first have been declared "hookable" by a call to 'func_hookable'.
2014
case " $hookable_fns " in
2016
*) func_fatal_error "'$1' does not accept hook functions." ;;
2019
eval func_append ${1}_hooks '" $2"'
2023
# func_remove_hook FUNC_NAME HOOK_FUNC
2024
# ------------------------------------
2025
# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
2030
eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
2034
# func_run_hooks FUNC_NAME [ARG]...
2035
# ---------------------------------
2036
# Run all hook functions registered to FUNC_NAME.
2037
# It is assumed that the list of hook functions contains nothing more
2038
# than a whitespace-delimited list of legal shell function names, and
2039
# no effort is wasted trying to catch shell meta-characters or preserve
2045
case " $hookable_fns " in
2047
*) func_fatal_error "'$1' does not support hook funcions.n" ;;
2050
eval _G_hook_fns=\$$1_hooks; shift
2052
for _G_hook in $_G_hook_fns; do
2053
eval $_G_hook '"$@"'
2055
# store returned options list back into positional
2056
# parameters for next 'cmd' execution.
2057
eval _G_hook_result=\$${_G_hook}_result
2058
eval set dummy "$_G_hook_result"; shift
2061
func_quote_for_eval ${1+"$@"}
2062
func_run_hooks_result=$func_quote_for_eval_result
2067
## --------------- ##
2068
## Option parsing. ##
2069
## --------------- ##
2071
# In order to add your own option parsing hooks, you must accept the
2072
# full positional parameter list in your hook function, remove any
2073
# options that you action, and then pass back the remaining unprocessed
2074
# options in '<hooked_function_name>_result', escaped suitably for
2075
# 'eval'. Like this:
2077
# my_options_prep ()
2081
# # Extend the existing usage message.
2082
# usage_message=$usage_message'
2083
# -s, --silent don'\''t print informational messages
2086
# func_quote_for_eval ${1+"$@"}
2087
# my_options_prep_result=$func_quote_for_eval_result
2089
# func_add_hook func_options_prep my_options_prep
2092
# my_silent_option ()
2096
# # Note that for efficiency, we parse as many options as we can
2097
# # recognise in a loop before passing the remainder back to the
2098
# # caller on the first unrecognised argument we encounter.
2099
# while test $# -gt 0; do
2102
# --silent|-s) opt_silent=: ;;
2103
# # Separate non-argument short options:
2104
# -s*) func_split_short_opt "$_G_opt"
2105
# set dummy "$func_split_short_opt_name" \
2106
# "-$func_split_short_opt_arg" ${1+"$@"}
2109
# *) set dummy "$_G_opt" "$*"; shift; break ;;
2113
# func_quote_for_eval ${1+"$@"}
2114
# my_silent_option_result=$func_quote_for_eval_result
2116
# func_add_hook func_parse_options my_silent_option
2119
# my_option_validation ()
2123
# $opt_silent && $opt_verbose && func_fatal_help "\
2124
# '--silent' and '--verbose' options are mutually exclusive."
2126
# func_quote_for_eval ${1+"$@"}
2127
# my_option_validation_result=$func_quote_for_eval_result
2129
# func_add_hook func_validate_options my_option_validation
2131
# You'll alse need to manually amend $usage_message to reflect the extra
2132
# options you parse. It's preferable to append if you can, so that
2133
# multiple option parsing hooks can be added safely.
2136
# func_options [ARG]...
2137
# ---------------------
2138
# All the functions called inside func_options are hookable. See the
2139
# individual implementations for details.
2140
func_hookable func_options
2145
func_options_prep ${1+"$@"}
2146
eval func_parse_options \
2147
${func_options_prep_result+"$func_options_prep_result"}
2148
eval func_validate_options \
2149
${func_parse_options_result+"$func_parse_options_result"}
2151
eval func_run_hooks func_options \
2152
${func_validate_options_result+"$func_validate_options_result"}
2154
# save modified positional parameters for caller
2155
func_options_result=$func_run_hooks_result
2159
# func_options_prep [ARG]...
2160
# --------------------------
2161
# All initialisations required before starting the option parse loop.
2162
# Note that when calling hook functions, we pass through the list of
2163
# positional parameters. If a hook function modifies that list, and
2164
# needs to propogate that back to rest of this script, then the complete
2165
# modified list must be put in 'func_run_hooks_result' before
2167
func_hookable func_options_prep
2168
func_options_prep ()
2176
func_run_hooks func_options_prep ${1+"$@"}
2178
# save modified positional parameters for caller
2179
func_options_prep_result=$func_run_hooks_result
2183
# func_parse_options [ARG]...
2184
# ---------------------------
2185
# The main option parsing loop.
2186
func_hookable func_parse_options
2187
func_parse_options ()
2191
func_parse_options_result=
2193
# this just eases exit handling
2194
while test $# -gt 0; do
2195
# Defer to hook functions for initial option parsing, so they
2196
# get priority in the event of reusing an option name.
2197
func_run_hooks func_parse_options ${1+"$@"}
2199
# Adjust func_parse_options positional parameters to match
2200
eval set dummy "$func_run_hooks_result"; shift
2202
# Break out of the loop if we already parsed every option.
2203
test $# -gt 0 || break
2208
--debug|-x) debug_cmd='set -x'
2209
func_echo "enabling shell trace mode"
2213
--no-warnings|--no-warning|--no-warn)
2214
set dummy --warnings none ${1+"$@"}
2218
--warnings|--warning|-W)
2219
test $# = 0 && func_missing_arg $_G_opt && break
2220
case " $warning_categories $1" in
2222
# trailing space prevents matching last $1 above
2223
func_append_uniq opt_warning_types " $1"
2226
opt_warning_types=$warning_categories
2229
opt_warning_types=none
2233
opt_warning_types=$warning_categories
2234
warning_func=func_fatal_error
2238
"unsupported warning category: '$1'"
2244
--verbose|-v) opt_verbose=: ;;
2245
--version) func_version ;;
2246
-\?|-h) func_usage ;;
2247
--help) func_help ;;
2249
# Separate optargs to long options (plugins may need this):
2250
--*=*) func_split_equals "$_G_opt"
2251
set dummy "$func_split_equals_lhs" \
2252
"$func_split_equals_rhs" ${1+"$@"}
2256
# Separate optargs to short options:
2258
func_split_short_opt "$_G_opt"
2259
set dummy "$func_split_short_opt_name" \
2260
"$func_split_short_opt_arg" ${1+"$@"}
2264
# Separate non-argument short options:
2266
func_split_short_opt "$_G_opt"
2267
set dummy "$func_split_short_opt_name" \
2268
"-$func_split_short_opt_arg" ${1+"$@"}
2273
-*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
2274
*) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
2278
# save modified positional parameters for caller
2279
func_quote_for_eval ${1+"$@"}
2280
func_parse_options_result=$func_quote_for_eval_result
2284
# func_validate_options [ARG]...
2285
# ------------------------------
2286
# Perform any sanity checks on option settings and/or unconsumed
2288
func_hookable func_validate_options
2289
func_validate_options ()
2293
# Display all warnings if -W was not given.
2294
test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
2296
func_run_hooks func_validate_options ${1+"$@"}
2298
# Bail if the options were screwed!
2299
$exit_cmd $EXIT_FAILURE
2301
# save modified positional parameters for caller
2302
func_validate_options_result=$func_run_hooks_result
2307
## ----------------- ##
2308
## Helper functions. ##
2309
## ----------------- ##
2311
# This section contains the helper functions used by the rest of the
2312
# hookable option parser framework in ascii-betical order.
2315
# func_fatal_help ARG...
2316
# ----------------------
2317
# Echo program name prefixed message to standard error, followed by
2318
# a help hint, and exit.
2323
eval \$ECHO \""Usage: $usage"\"
2324
eval \$ECHO \""$fatal_help"\"
2325
func_error ${1+"$@"}
2332
# Echo long help message to standard output and exit.
1198
$SED -n '/^# Usage:/,/# Report bugs to/ {
1202
s*\$progname*'$progname'*
1204
s*\$SHELL*'"$SHELL"'*
1206
s*\$LTCFLAGS*'"$LTCFLAGS"'*
1208
s/\$with_gnu_ld/'"$with_gnu_ld"'/
1209
s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
1210
s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
1214
/^# .* home page:/b print
1215
/^# General help using/b print
1218
if test -z "$1"; then
2338
$ECHO "$long_help_message"
1223
# func_missing_arg argname
2343
# func_missing_arg ARGNAME
2344
# ------------------------
1224
2345
# Echo program name prefixed message to standard error and set global
1226
2347
func_missing_arg ()
1230
func_error "missing argument for $1."
2351
func_error "Missing argument for '$1'."
1235
# func_split_short_opt shortopt
2356
# func_split_equals STRING
2357
# ------------------------
2358
# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
2359
# splitting STRING at the '=' sign.
2360
test -z "$_G_HAVE_XSI_OPS" \
2362
test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
2363
&& _G_HAVE_XSI_OPS=yes
2365
if test yes = "$_G_HAVE_XSI_OPS"
2367
# This is an XSI compatible shell, allowing a faster implementation...
2368
eval 'func_split_equals ()
2372
func_split_equals_lhs=${1%%=*}
2373
func_split_equals_rhs=${1#*=}
2374
test "x$func_split_equals_lhs" = "x$1" \
2375
&& func_split_equals_rhs=
2378
# ...otherwise fall back to using expr, which is often a shell builtin.
2379
func_split_equals ()
2383
func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
2384
func_split_equals_rhs=
2385
test "x$func_split_equals_lhs" = "x$1" \
2386
|| func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
2388
fi #func_split_equals
2391
# func_split_short_opt SHORTOPT
2392
# -----------------------------
1236
2393
# Set func_split_short_opt_name and func_split_short_opt_arg shell
1237
2394
# variables after splitting SHORTOPT after the 2nd character.
1238
func_split_short_opt ()
1240
func_split_short_opt_arg=${1#??}
1241
func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1242
} # Extended-shell func_split_short_opt implementation
1245
# func_split_long_opt longopt
1246
# Set func_split_long_opt_name and func_split_long_opt_arg shell
1247
# variables after splitting LONGOPT at the `=' sign.
1248
func_split_long_opt ()
1250
func_split_long_opt_name=${1%%=*}
1251
func_split_long_opt_arg=${1#*=}
1252
} # Extended-shell func_split_long_opt implementation
1260
magic="%%%MAGIC variable%%%"
1261
magic_exe="%%%MAGIC EXE variable%%%"
1266
lo2o="s/\\.lo\$/.${objext}/"
1267
o2lo="s/\\.${objext}\$/.lo/"
1271
# If this variable is set in any of the actions, the command in it
1272
# will be execed at the end. This prevents here-documents from being
1273
# left over by shells.
1276
# func_append var value
1277
# Append VALUE to the end of shell variable VAR.
1281
} # Extended-shell func_append implementation
1283
# func_append_quoted var value
1284
# Quote VALUE and append to the end of shell variable VAR, separated
1286
func_append_quoted ()
1288
func_quote_for_eval "${2}"
1289
eval "${1}+=\\ \$func_quote_for_eval_result"
1290
} # Extended-shell func_append_quoted implementation
1293
# func_arith arithmetic-term...
1296
func_arith_result=$(( $* ))
1297
} # Extended-shell func_arith implementation
1301
# STRING may not start with a hyphen.
1304
func_len_result=${#1}
1305
} # Extended-shell func_len implementation
1312
*.lo) func_lo2o_result=${1%.lo}.${objext} ;;
1313
*) func_lo2o_result=${1} ;;
2395
if test yes = "$_G_HAVE_XSI_OPS"
2397
# This is an XSI compatible shell, allowing a faster implementation...
2398
eval 'func_split_short_opt ()
2402
func_split_short_opt_arg=${1#??}
2403
func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
2406
# ...otherwise fall back to using expr, which is often a shell builtin.
2407
func_split_short_opt ()
2411
func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
2412
func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
2414
fi #func_split_short_opt
2419
# Echo short help message to standard output and exit.
2425
$ECHO "Run '$progname --help |${PAGER-more}' for full usage"
2430
# func_usage_message
2431
# ------------------
2432
# Echo short help message to standard output.
2433
func_usage_message ()
2437
eval \$ECHO \""Usage: $usage"\"
2444
/^Written by/q' < "$progpath"
2446
eval \$ECHO \""$usage_message"\"
2452
# Echo version message to standard output and exit.
2457
printf '%s\n' "$progname $scriptversion"
2467
/^# Written by /,/# warranty; / {
2470
s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
2477
/^warranty; /q' < "$progpath"
2484
# mode: shell-script
2486
# eval: (add-hook 'before-save-hook 'time-stamp)
2487
# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
2488
# time-stamp-time-zone: "UTC"
2491
# Set a version string.
2492
scriptversion='(GNU libtool) 2.4.6'
2497
# Libtool also displays the current mode in messages, so override
2498
# funclib.sh func_echo with this custom definition.
2507
for _G_line in $_G_message; do
2509
$ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
2515
# func_warning ARG...
2516
# -------------------
2517
# Libtool warnings are not categorized, so override funclib.sh
2518
# func_warning with this simpler definition.
2523
$warning_func ${1+"$@"}
2527
## ---------------- ##
2528
## Options parsing. ##
2529
## ---------------- ##
2531
# Hook in the functions to make sure our own options are parsed during
2532
# the option parsing loop.
2534
usage='$progpath [OPTION]... [MODE-ARG]...'
2536
# Short help message in response to '-h'.
2537
usage_message="Options:
2538
--config show all configuration variables
2539
--debug enable verbose shell tracing
2540
-n, --dry-run display commands without modifying any files
2541
--features display basic configuration information and exit
2542
--mode=MODE use operation mode MODE
2543
--no-warnings equivalent to '-Wnone'
2544
--preserve-dup-deps don't remove duplicate dependency libraries
2545
--quiet, --silent don't print informational messages
2546
--tag=TAG use configuration variables from tag TAG
2547
-v, --verbose print more informational messages than default
2548
--version print version information
2549
-W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
2550
-h, --help, --help-all print short, long, or detailed help message
2553
# Additional text appended to 'usage_message' in response to '--help'.
2559
$ECHO "$long_help_message
2561
MODE must be one of the following:
2563
clean remove files from the build directory
2564
compile compile a source file into a libtool object
2565
execute automatically set library path, then run a program
2566
finish complete the installation of libtool libraries
2567
install install libraries or executables
2568
link create a library or an executable
2569
uninstall remove libraries from an installed directory
2571
MODE-ARGS vary depending on the MODE. When passed as first option,
2572
'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
2573
Try '$progname --help --mode=MODE' for a more detailed description of MODE.
2575
When reporting a bug, please describe a test case to reproduce it and
2576
include the following information:
2581
compiler flags: $LTCFLAGS
2582
linker: $LD (gnu? $with_gnu_ld)
2583
version: $progname (GNU libtool) 2.4.6
2584
automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
2585
autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
2587
Report bugs to <bug-libtool@gnu.org>.
2588
GNU libtool home page: <http://www.gnu.org/s/libtool/>.
2589
General help using GNU software: <http://www.gnu.org/gethelp/>."
2594
# func_lo2o OBJECT-NAME
2595
# ---------------------
2596
# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
2599
lo2o=s/\\.lo\$/.$objext/
2600
o2lo=s/\\.$objext\$/.lo/
2602
if test yes = "$_G_HAVE_XSI_OPS"; then
2606
*.lo) func_lo2o_result=${1%.lo}.$objext ;;
2607
* ) func_lo2o_result=$1 ;;
1315
} # Extended-shell func_lo2o implementation
1318
# func_xform libobj-or-source
2611
# func_xform LIBOBJ-OR-SOURCE
2612
# ---------------------------
2613
# Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2614
# suffix to a '.lo' libtool-object suffix.
1321
2617
func_xform_result=${1%.*}.lo
1322
} # Extended-shell func_xform implementation
1325
# func_fatal_configuration arg...
2620
# ...otherwise fall back to using sed.
2623
func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2628
func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2633
# func_fatal_configuration ARG...
2634
# -------------------------------
1326
2635
# Echo program name prefixed message to standard error, followed by
1327
2636
# a configuration failure hint, and exit.
1328
2637
func_fatal_configuration ()
1330
func_error ${1+"$@"}
1331
func_error "See the $PACKAGE documentation for more information."
1332
func_fatal_error "Fatal configuration error."
2639
func__fatal_error ${1+"$@"} \
2640
"See the $PACKAGE documentation for more information." \
2641
"Fatal configuration error."
1337
2647
# Display the configuration for all the tags in this script.