# -*- shell-script -*-
#
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
########################################################
### IMPORTANT NOTE: keep this file 'set -e' clean. ###
########################################################
# Do not source several times.
test ${am_test_lib_sourced-no} = yes && return 0
am_test_lib_sourced=yes
# A literal escape character. Used by test checking colored output.
esc=''
# This might be used in testcases checking distribution-related features.
# Test scripts are free to override this if they need to.
distdir=$me-1.0
## ---------------------- ##
## Environment cleanup. ##
## ---------------------- ##
# Temporarily disable this, since some shells (e.g., older version
# of Bash) can return a non-zero exit status upon the when a non-set
# variable is unset.
set +e
# Unset some make-related variables that may cause $MAKE to act like
# a recursively invoked sub-make. Any $MAKE invocation in a test is
# conceptually an independent invocation, not part of the main
# 'automake' build.
unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL
unset __MKLVL__ MAKE_JOBS_FIFO # For BSD make.
unset DMAKE_CHILD DMAKE_DEF_PRINTED DMAKE_MAX_JOBS # For Solaris dmake.
# Unset verbosity flag.
unset V
# Also unset variables that will let "make -e install" divert
# files into unwanted directories.
unset DESTDIR
unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
unset htmldir includedir infodir libdir libexecdir localedir mandir
unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
# Unset variables that might change the "make distcheck" behaviour.
unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS
# Used by install rules for info files.
unset AM_UPDATE_INFO_DIR
# The tests call "make -e" but we do not want $srcdir from the environment
# to override the definition from the Makefile.
unset srcdir
# Also unset variables that control our test driver. While not
# conceptually independent, they cause some changed semantics we
# need to control (and test for) in some of the tests to ensure
# backward-compatible behavior.
unset TESTS_ENVIRONMENT AM_TESTS_ENVIRONMENT
unset DISABLE_HARD_ERRORS
unset AM_COLOR_TESTS
unset TESTS
unset XFAIL_TESTS
unset TEST_LOGS
unset TEST_SUITE_LOG
unset RECHECK_LOGS
unset VERBOSE
for pfx in TEST_ SH_ TAP_ ''; do
unset ${pfx}LOG_COMPILER
unset ${pfx}LOG_COMPILE # Not a typo!
unset ${pfx}LOG_FLAGS
unset AM_${pfx}LOG_FLAGS
unset ${pfx}LOG_DRIVER
unset ${pfx}LOG_DRIVER_FLAGS
unset AM_${pfx}LOG_DRIVER_FLAGS
done
unset pfx
# Re-enable, it had been temporarily disabled above.
set -e
# cross_compiling
# ---------------
# Tell whether we are cross-compiling. This is especially useful to skip
# tests (or portions of them) that requires a native compiler.
cross_compiling ()
{
# Quoting from the autoconf manual:
# ... [$host_alias and $build both] default to the result of running
# config.guess, unless you specify either --build or --host. In
# this case, the default becomes the system type you specified.
# If you specify both, *and they're different*, configure enters
# cross compilation mode (so it doesn't run any tests that require
# execution).
test x"$host_alias" != x && test x"$build_alias" != x"$host_alias"
}
# is_blocked_signal SIGNAL-NUMBER
# --------------------------------
# Return success if the given signal number is blocked in the shell,
# return a non-zero exit status and print a proper diagnostic otherwise.
is_blocked_signal ()
{
# Use perl, since trying to do this portably in the shell can be
# very tricky, if not downright impossible. For reference, see:
# <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
if $PERL -w -e '
use strict;
use warnings FATAL => "all";
use POSIX;
my %oldsigaction = ();
sigaction('"$1"', 0, \%oldsigaction);
exit ($oldsigaction{"HANDLER"} eq "IGNORE" ? 0 : 77);
'; then
return 0
elif test $? -eq 77; then
return 1
else
fatal_ "couldn't determine whether signal $1 is blocked"
fi
}
# AUTOMAKE_run [-e STATUS] [-d DESCRIPTION] [--] [AUTOMAKE-ARGS...]
# -----------------------------------------------------------------
# Run automake with AUTOMAKE-ARGS, and fail if it doesn't exit with
# STATUS. Should be polymorphic for TAP and "plain" tests. The
# DESCRIPTION, when provided, is used for console reporting, only if
# the TAP protocol is in use in the current test script.
AUTOMAKE_run ()
{
am__desc=
am__exp_rc=0
while test $# -gt 0; do
case $1 in
-d) am__desc=$2; shift;;
-e) am__exp_rc=$2; shift;;
--) shift; break;;
# Don't fail on unknown option: assume they (and the rest of the
# command line) are to be passed verbatim to automake (so stop our
# own option parsing).
*) break;;
esac
shift
done
am__got_rc=0
$AUTOMAKE ${1+"$@"} >stdout 2>stderr || am__got_rc=$?
cat stderr >&2
cat stdout
if test $am_test_protocol = none; then
test $am__got_rc -eq $am__exp_rc || exit 1
return
fi
if test -z "$am__desc"; then
if test $am__got_rc -eq $am__exp_rc; then
am__desc="automake exited $am__got_rc"
else
am__desc="automake exited $am__got_rc, expecting $am__exp_rc"
fi
fi
command_ok_ "$am__desc" test $am__got_rc -eq $am__exp_rc
}
# AUTOMAKE_fails [-d DESCRIPTION] [OPTIONS...]
# --------------------------------------------
# Run automake with OPTIONS, and fail if doesn't exit with status 1.
# Should be polymorphic for TAP and "plain" tests. The DESCRIPTION,
# when provided, is used for console reporting, only if the TAP
# protocol is in use in the current test script.
AUTOMAKE_fails ()
{
AUTOMAKE_run -e 1 ${1+"$@"}
}
# extract_configure_help { --OPTION | VARIABLE-NAME } [FILES]
# -----------------------------------------------------------
# Use this to extract from the output of "./configure --help" (or similar)
# the description or help message associated to the given --OPTION or
# VARIABLE-NAME.
extract_configure_help ()
{
am__opt_re='' am__var_re=''
case $1 in
--*'=') am__opt_re="^ $1";;
--*'[=]') am__opt_re='^ '$(printf '%s\n' "$1" | sed 's/...$//')'\[=';;
--*) am__opt_re="^ $1( .*|$)";;
*) am__var_re="^ $1( .*|$)";;
esac
shift
if test x"$am__opt_re" != x; then
LC_ALL=C awk '
/'"$am__opt_re"'/ { print; do_print = 1; next; }
/^$/ { do_print = 0; next }
/^ --/ { do_print = 0; next }
(do_print == 1) { print }
' ${1+"$@"}
else
LC_ALL=C awk '
/'"$am__var_re"'/ { print; do_print = 1; next; }
/^$/ { do_print = 0; next }
/^ [A-Z][A-Z0-9_]* / { do_print = 0; next }
/^ [A-Z][A-Z0-9_]*$/ { do_print = 0; next }
(do_print == 1) { print }
' ${1+"$@"}
fi
}
# grep_configure_help { --OPTION | VARIABLE-NAME } REGEXP
# -------------------------------------------------------
# Grep the section of "./configure --help" output associated with either
# --OPTION or VARIABLE-NAME for the given *extended* regular expression.
grep_configure_help ()
{
./configure --help > am--all-help \
|| { cat am--all-help; exit 1; }
cat am--all-help
extract_configure_help "$1" am--all-help > am--