# -*- shell-script -*-
#
# Copyright (C) 1996-2013 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. ##
## ---------------------- ##
# 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 might influence "make install".
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 influence "make distcheck".
unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS
# Used by install rules for info files.
unset AM_UPDATE_INFO_DIR
# We don't want to use the $srcdir value exported by the test driver.
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
# 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
}
# single_quote STRING
# -------------------
# Single-quote STRING for the shell, also dealing with embedded single
# quotes. Place the result in the '$am_result', that is thus to be
# considered public.
single_quote ()
{
am_result=$1
case $am_result in
*\'*) am_result=$(printf '%s\n' "$*" | sed -e "s/'/'\\\\''/g");;
esac
am_result="'$am_result'"
}
# append_single_quoted VARIABLE STRING
# ------------------------------------
append_single_quoted ()
{
am__var=$1; shift
single_quote "$1" # Sets 'am_result'.
eval "${am__var}=\${$am__var:+\"\${$am__var} \"}\$am_result"
unset am__var am_result
}
# is_valid_varname STRING
# -----------------------
# Tell whether STRING is a valid name for a shell variable. Return 0
# if yes, return 1 if not.
is_valid_varname ()
{
# FIXME: is the below truly portable even for LC_COLLATE != "C" ?
case $1 in
[0-9]*) return 1;;
*[!a-zA-Z0-9_]*) return 1;;
esac
return 0
}
# run_make [-e STATUS] [-O] [-E] [-M] [--] [VAR=VAL ...] [MAKE-ARGS...]
# ---------------------------------------------------------------------
#
# Run $MAKE with the given command-line, and fail if it doesn't exit with
# STATUS (default: 0). If STATUS is "FAIL", then any exit status > 0 is
# acceptable. If STATUS is "IGNORE", any exit value is acceptable.
#
# Other options:
#
# -O save the standard output from make on disk, in a regular file
# named 'stdout'.
#
# -E save the standard error from make on disk, in a regular file
# named 'stderr'.
#
# -M save both the standard output and standard error from make on
# disk, in a regular file named 'output'. This option supersedes
# both the '-O' and '-E' options.
#
# This function also handle command-line override of variable definition
# in a smart way, using AM_MAKEFLAGS if a non-GNU make implementation
# is in use.
#
run_make ()
{
am__make_redirect_stdout=no
am__make_redirect_stderr=no
am__make_redirect_stdall=no
am__make_flags=
am__make_rc_exp=0
# Follow-up code might want to analyse this, so mark is as
# publicly accessible (no double undesrscore).
am_make_rc=0
# Parse options for this function.
while test $# -gt 0; do
case $1 in
-e) am__make_rc_exp=$2; shift;;
-O) am__make_redirect_stdout=yes;;
-E) am__make_redirect_stderr=yes;;
-M) am__make_redirect_stdall=yes;;
--) shift; break;;
*) break;;
esac
shift
done
# Use append mode here to avoid dropping output. See automake bug#11413
if using_gmake; then
# We can trust GNU make to correctly pass macro definitions given
# on the command line down to sub-make invocations, and this allow
# us to have a vary simple implementation: delegate all the work
# to GNU make.
:
else
# We have to explicitly parse arguments passed to make. Not 100%
# safe w.r.t. options like '-I' that can have an argument, but
# should be good enough for our usages so far.
for am__x
do
case $am__x in
*=*)
am__maybe_var=${am__x%%=*}
am__maybe_val=${am__x#*=}
am__maybe_def="${am__maybe_var}=${am__maybe_val}"
# Some variables should be portably overridable from the command
# line, even when using non-GNU make.
case $am__maybe_var in
V|\
DESTDIR|\
SHELL|\
VERBOSE|\
DISABLE_HARD_ERRORS|\
DISTCHECK_CONFIGURE_FLAGS)
;;
*)
if is_valid_varname "$am__maybe_var"; then
append_single_quoted am__make_flags "$am__maybe_def"