mirror of
git://git.sv.gnu.org/autoconf
synced 2024-11-27 01:49:56 +08:00
1172 lines
39 KiB
Plaintext
1172 lines
39 KiB
Plaintext
# M4 macros used in building Autoconf test suites. -*- Autotest -*-
|
|
|
|
# Copyright (C) 2000-2017, 2020-2024 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 3 of the License, 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 <https://www.gnu.org/licenses/>.
|
|
|
|
m4_version_prereq([2.57])
|
|
|
|
# Used in many tests.
|
|
m4_pattern_allow([^AS_EXIT$])
|
|
m4_pattern_allow([^m4_(define|shift)$])
|
|
|
|
# Programs this package provides
|
|
AT_TESTED([autom4te autoconf autoheader autoupdate autoreconf ifnames])
|
|
|
|
|
|
# Enable colored test output.
|
|
AT_COLOR_TESTS
|
|
|
|
# Sanitize the environment used for tests.
|
|
AT_PREPARE_TESTS(
|
|
[# MAKEFLAGS should not be inherited from the parent environment.
|
|
AS_UNSET([MAKEFLAGS])
|
|
|
|
# We do not want to read any external config.site file.
|
|
# If CONFIG_SITE is not set, autoconf will look for config.site in
|
|
# $prefix/share and $prefix/etc.
|
|
AS_IF([test -e nonexistent],
|
|
[AS_ERROR([something named 'nonexistent' exists in the test directory])])
|
|
CONFIG_SITE=`pwd`/nonexistent/config.site
|
|
export CONFIG_SITE
|
|
|
|
# Ensure MAKE, AUTOMAKE, and ACLOCAL are set to useful values. Unlike
|
|
# the above, we *do* want to inherit these variables from the parent
|
|
# environment and/or our command line. Also, detect now whether
|
|
# automake and aclocal are unavailable or too old.
|
|
: "${MAKE=make}"
|
|
export MAKE
|
|
|
|
# Some old versions of automake, when used with newer Perl interpreters,
|
|
# will print a warning message about their own Perl code on every
|
|
# invocation, which breaks various tests' expectations for output.
|
|
# This also weeds out broken wrapper scripts; in the past some vendors
|
|
# have shipped an 'automake' that didn't work without user configuration.
|
|
: "${AUTOMAKE=automake}"
|
|
at_automake_version="`$AUTOMAKE --version 2>&1 || echo not found`"
|
|
at_automake_version_1="`AS_ECHO(["$at_automake_version"]) | sed 1q`"
|
|
AS_CASE([$at_automake_version_1],
|
|
[[*GNU*\)\ [1-9]\.[0-9]*]], [],
|
|
[AUTOMAKE=false])
|
|
export AUTOMAKE
|
|
|
|
# Used in the code below that decides delay intervals.
|
|
if test "$AUTOMAKE" = false
|
|
then
|
|
# If automake is unavailable, then whether it supports subsecond
|
|
# mtime is moot.
|
|
at_automake_subsecond_mtime=:
|
|
elif AS_ECHO(["$at_automake_version"]) |
|
|
grep 'Features: subsecond-mtime' > /dev/null 2>&1
|
|
then
|
|
at_automake_subsecond_mtime=:
|
|
else
|
|
at_automake_subsecond_mtime=false
|
|
fi
|
|
|
|
# The same Perl and wrapper issues exist with aclocal. Also, we
|
|
# require a version that understands --system-acdir and configure.ac.
|
|
: "${ACLOCAL=aclocal}"
|
|
at_aclocal_version="`$ACLOCAL --version 2>&1 || echo not found`"
|
|
at_aclocal_version_1="`AS_ECHO(["$at_aclocal_version"]) | sed 1q`"
|
|
AS_CASE([$at_aclocal_version_1],
|
|
[[*GNU*\)\ [1-9]\.[0-9]*]],
|
|
[mkdir at_scratch
|
|
(cd at_scratch &&
|
|
touch configure.ac &&
|
|
mkdir empty &&
|
|
$ACLOCAL --system-acdir=`pwd`/empty) || ACLOCAL=false
|
|
rm -rf at_scratch],
|
|
[ACLOCAL=false])
|
|
export ACLOCAL
|
|
|
|
# Prevent aclocal from reading third-party macros, in case they are buggy.
|
|
# (AM_INIT_AUTOMAKE will still be available via the default --automake-acdir.)
|
|
if test "$ACLOCAL" != false; then
|
|
test -d at_empty_dir || mkdir at_empty_dir
|
|
ACLOCAL="$ACLOCAL --system-acdir=`cd at_empty_dir && pwd`"
|
|
fi
|
|
|
|
# Determine how long we need to delay in between operations that might
|
|
# modify autom4te.cache. This depends on three factors: whether the
|
|
# 'sleep' utility supports fractional seconds in its argument; what
|
|
# the resolution of last-modification timestamps is on the file system
|
|
# hosting the build; and whether autom4te and automake can both make
|
|
# use of high-resolution file timestamps (this is not entirely under
|
|
# our control because it depends on the capabilities of the Perl
|
|
# installation).
|
|
#
|
|
# This series of tests mostly cribbed from automake/m4/sanity.m4.
|
|
# We cannot rely on the execution of that code inside autoconf's own
|
|
# configure script, because (depending on what version of automake was
|
|
# used to generate the configure script) it might not be there at all,
|
|
# or might be buggy. Also, even if it's present and correct, it didn't
|
|
# probe the autom4te we just built, which is the one we care about.
|
|
#
|
|
# The coarsest file system we know of is FAT, with a resolution
|
|
# of only two seconds, even with the most recent "exFAT" extensions.
|
|
# The finest (e.g. ext4 with large inodes, XFS, ZFS) is one
|
|
# nanosecond, matching clock_gettime. However, it is probably not
|
|
# possible to delay execution of a shell script for less than one
|
|
# millisecond, due to process creation overhead and scheduling
|
|
# granularity, so we don't check for anything finer than that.
|
|
|
|
# Default to the coarsest case.
|
|
at_ts_resolution=2
|
|
|
|
# Only try to go finer than 1s if sleep, autom4te, and automake (if present)
|
|
# can all handle it.
|
|
at_try_resolutions=1
|
|
if sleep 0.001 2>/dev/null &&
|
|
autom4te --version 2>&1 |
|
|
grep 'Features:.*subsecond-mtime' > /dev/null 2>&1 &&
|
|
$at_automake_subsecond_mtime
|
|
then
|
|
at_try_resolutions="0.001 0.01 0.1 $at_try_resolutions"
|
|
fi
|
|
|
|
# In order to catch current-generation FAT out, we must *modify* files
|
|
# that already exist; the *creation* timestamp is finer. Use names
|
|
# that make ls -t sort them differently when they have equal
|
|
# timestamps than when they have distinct timestamps, keeping
|
|
# in mind that ls -t prints the *newest* file first.
|
|
rm -f conftest.ts?
|
|
: > conftest.ts1
|
|
: > conftest.ts2
|
|
: > conftest.ts3
|
|
|
|
for at_try_res in $at_try_resolutions; do
|
|
# Any one fine-grained sleep might happen to cross the boundary
|
|
# between two values of a coarser actual resolution, but if we do
|
|
# two fine-grained sleeps in a row, at least one of them will fall
|
|
# entirely within a coarse interval.
|
|
echo alpha > conftest.ts1
|
|
sleep $at_try_res
|
|
echo beta > conftest.ts2
|
|
sleep $at_try_res
|
|
echo gamma > conftest.ts3
|
|
|
|
# We assume that 'ls -t' will make use of high-resolution
|
|
# timestamps if the operating system supports them at all.
|
|
set X `ls -t conftest.ts?`
|
|
if test "$[]2" = conftest.ts3 &&
|
|
test "$[]3" = conftest.ts2 &&
|
|
test "$[]4" = conftest.ts1; then
|
|
at_ts_resolution=$at_try_res
|
|
break
|
|
fi
|
|
done
|
|
rm -f conftest.ts?
|
|
|
|
# AT_TESTED doesn't support variables in its argument, particularly
|
|
# when they might contain the name of a program along with some
|
|
# arguments, or when they might evaluate to 'false'.
|
|
# Do this in a subshell to contain the effects of 'set'.
|
|
(status=0
|
|
AS_BOX([System supplied programs that we depend on.])
|
|
echo
|
|
for at_program in \
|
|
"r m4 $M4" \
|
|
"r perl $PERL" \
|
|
"r sh ${CONFIG_SHELL-$SHELL}" \
|
|
"r make $MAKE" \
|
|
"o automake $AUTOMAKE" \
|
|
"o aclocal $ACLOCAL"
|
|
do
|
|
# The first three words of $at_program are a code for whether
|
|
# it's required (r) or optional (o); the conventional name of the
|
|
# program (for error messages); and the name (possibly a pathname)
|
|
# we were told to use for it.
|
|
set dummy $at_program
|
|
at_required=$[]2
|
|
at_prog_name=$[]3
|
|
at_prog_use=$[]4
|
|
at_prog_use_=
|
|
|
|
AS_CASE(["$at_prog_use"],
|
|
[: | true | false], [],
|
|
[[[\\/]* | ?:[\\/]*]],
|
|
[test -f "$at_prog_use" && at_prog_use_=$at_prog_use],
|
|
[_AS_PATH_WALK([$PATH],
|
|
[if test -f "$as_dir$at_prog_use"; then
|
|
at_prog_use_=$as_dir$at_prog_use
|
|
break
|
|
fi])])
|
|
|
|
if test -n "$at_prog_use_"; then
|
|
{
|
|
AS_ECHO(["# $at_prog_name is $at_prog_use_"])
|
|
AS_ECHO(["$at_prog_use_ --version"])
|
|
"$at_prog_use_" --version </dev/null
|
|
} >&AS_MESSAGE_LOG_FD 2>&1
|
|
elif test $at_required = r; then
|
|
AS_ECHO(["*** Required program $at_prog_name is unavailable."])
|
|
status=1
|
|
else
|
|
AS_ECHO(["# $at_prog_name is unavailable"])
|
|
fi
|
|
echo
|
|
done
|
|
|
|
AS_ECHO(["$at_srcdir/AT_LINE: using ${at_ts_resolution}s as mtime resolution"])
|
|
echo
|
|
exit $status
|
|
) >&AS_MESSAGE_LOG_FD 2>&1
|
|
|
|
if test $? -ne 0; then
|
|
AS_ERROR([*** Some required programs were not found.])
|
|
fi
|
|
])
|
|
|
|
|
|
|
|
## ---------------- ##
|
|
## Utility macros. ##
|
|
## ---------------- ##
|
|
|
|
# AT_CMP(FILE-1, FILE-2)
|
|
# ----------------------
|
|
# Check FILE-1 and FILE-2 for equality, like 'cmp FILE-1 FILE-2'.
|
|
m4_define([AT_CMP],
|
|
[m4_ifval([$2],, [m4_fatal([AT_CMP takes two arguments.])])]dnl
|
|
[AT_CHECK([$at_diff "$1" "$2"])])
|
|
|
|
# AT_MTIME_DELAY
|
|
# --------------
|
|
# Wait for a short time, to ensure that files created before this
|
|
# command are considered to be older than files created afterward.
|
|
m4_define([AT_MTIME_DELAY],
|
|
[sleep $at_ts_resolution])
|
|
|
|
# AT_REQUIRE_AUTOMAKE
|
|
# -------------------
|
|
# Skip this test if automake is unavailable or too old.
|
|
m4_define([AT_REQUIRE_AUTOMAKE],
|
|
[AT_SKIP_IF([test "$AUTOMAKE" = false])])
|
|
|
|
# AT_REQUIRE_ACLOCAL
|
|
# ------------------
|
|
# Skip this test if aclocal is unavailable or too old.
|
|
m4_define([AT_REQUIRE_ACLOCAL],
|
|
[AT_SKIP_IF([test "$ACLOCAL" = false])])
|
|
|
|
# AT_SUPPRESS_ACLOCAL
|
|
# -------------------
|
|
# Prevent autoreconf from running aclocal, which might not be available.
|
|
# Use this instead of AT_REQUIRE_ACLOCAL in tests that run autoreconf
|
|
# but don't need aclocal to do anything.
|
|
m4_define([AT_SUPPRESS_ACLOCAL],
|
|
[AT_DATA([aclocal.m4])
|
|
ACLOCAL=true])
|
|
|
|
## ---------------- ##
|
|
## Testing syntax. ##
|
|
## ---------------- ##
|
|
|
|
# AT_CHECK_SHELL_SYNTAX(PROGRAM)
|
|
# ------------------------------
|
|
# If the shell handles '-n' well, use it to check the syntax of PROGRAM;
|
|
# otherwise, do nothing. ksh93 -n also spits outs loads of warnings
|
|
# about older constructs, but we don't care about the warnings.
|
|
m4_define([AT_CHECK_SHELL_SYNTAX],
|
|
[AT_SKIP_IF([test "$SHELL_N" = none])
|
|
AT_CHECK(["$SHELL_N" -n $1], [], [], [ignore])])
|
|
|
|
m4_define([AT_CHECK_PERL_SYNTAX],
|
|
[AT_CHECK([autom4te_perllibdir=$abs_top_srcdir/lib $PERL -c "$abs_top_builddir"/bin/$1],
|
|
0, [], [ignore])])
|
|
|
|
## ------------------ ##
|
|
## Testing autom4te. ##
|
|
## ------------------ ##
|
|
|
|
|
|
# AT_CHECK_M4(COMMAND, [EXIT-STATUS = 0], STDOUT, STDERR)
|
|
# -------------------------------------------------------
|
|
# If stderr is specified, normalize the observed stderr.
|
|
# This (using GNU M4 1.4.6)
|
|
#
|
|
# /usr/local/bin/m4:script.4s:1: cannot open `foo': No such file or directory
|
|
# autom4te: /usr/local/bin/m4 failed with exit status: 1
|
|
#
|
|
# or this (GNU M4 1.4.11)
|
|
#
|
|
# /usr/local/bin/m4:script.4s:1: include: cannot open `foo': No such file or directory
|
|
# autom4te: /usr/local/bin/m4 failed with exit status: 1
|
|
#
|
|
# or this (GNU M4 1.4 installed as gm4)
|
|
#
|
|
# script.4s:1: /usr/local/bin/gm4: Cannot open foo: No such file or directory
|
|
# autom4te: /usr/local/bin/gm4 failed with exit status: 1
|
|
#
|
|
# or this (GNU M4 1.4.13 installed as m4-1.4.13):
|
|
#
|
|
# /usr/bin/m4-1.4.13:script.4s:1: include: cannot open `foo': No such file or directory
|
|
# autom4te: /usr/bin/m4-1.4.13 failed with exit status: 1
|
|
#
|
|
# becomes
|
|
#
|
|
# m4:script.4s:1: cannot open 'foo': No such file or directory
|
|
# autom4te: m4 failed with exit status: 1
|
|
#
|
|
# Also, this
|
|
#
|
|
# configure.ac:6: warning: The macro 'AC_LANG_SAVE' is obsolete.
|
|
# configure.ac:6: You should run autoupdate.
|
|
# ../../lib/autoconf/lang.m4:125: AC_LANG_SAVE is expanded from...
|
|
# configure.ac:6: the top level
|
|
#
|
|
# becomes
|
|
#
|
|
# configure.ac:6: warning: The macro 'AC_LANG_SAVE' is obsolete.
|
|
# configure.ac:6: You should run autoupdate.
|
|
# lang.m4: AC_LANG_SAVE is expanded from...
|
|
# configure.ac:6: the top level
|
|
#
|
|
# We use the following sed patterns:
|
|
#
|
|
# (m4): ?(file): ?(line):
|
|
# or (file): ?(line): ?(m4):
|
|
# to m4:(file):(line):
|
|
#
|
|
# and
|
|
# m4:(file):(line): Cannot open foo:
|
|
# or m4:(file):(line): include: cannot open [`']foo':
|
|
# to m4:(file):(line): cannot open 'foo':
|
|
#
|
|
# and
|
|
# autom4te: [^ ]m4
|
|
# or autom4te: [^ ]m4.exe
|
|
# to autom4te: m4
|
|
#
|
|
# and
|
|
# (path)/(basename).m4: ?(line): (message)
|
|
# to (basename).m4: (message)
|
|
#
|
|
# Moreover, DJGPP error messages include the error code in brackets;
|
|
# remove the error code during normalization.
|
|
#
|
|
m4_define([AT_CHECK_M4],
|
|
[AT_CHECK([$1], [$2], [$3],
|
|
m4_case([$4], [], [], [ignore], [ignore], [stderr]))
|
|
m4_case([$4], [], [], [ignore], [],
|
|
[AT_CHECK([[mv stderr stderr-raw &&
|
|
sed 's/^[^:]*m4[-.ex0-9]*: *\([^:]*:\) *\([0-9][0-9]*: \)/m4:\1\2/
|
|
s/^\([^:]*:\) *\([0-9][0-9]*:\)[^:]*m4[-.ex0-9]*: /m4:\1\2 /
|
|
s/: include: [cC]\(annot open\)/: c\1/
|
|
s/: [cC]\(annot open \)[`'\'']*\([^'\'':]*\)'\''*:/: c\1'\''\2'\'':/
|
|
s/^autom4te: [^ ]*m4[.ex]* /autom4te: m4 /
|
|
s/^autom4te: error: [^ ]*m4[.ex]* /autom4te: error: m4 /
|
|
s!^.*/\([^/][^/]*\)\.m4: *[0-9][0-9]*: *!\1.m4: !
|
|
s!^.*/\([^/][^/]*\)\.m4: *[0-9][0-9]*: *[0-9][0-9]*: *!\1.m4: !
|
|
s/ (E[A-Z]*)$//
|
|
' stderr-raw >&2]], [0], [], [$4])])
|
|
])
|
|
|
|
# AT_CHECK_AUTOM4TE(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
|
|
# -----------------------------------------------------------
|
|
m4_define([AT_CHECK_AUTOM4TE],
|
|
[AT_CHECK_M4([autom4te $1], [$2], [$3], [$4])])
|
|
|
|
|
|
|
|
## ----------------- ##
|
|
## Testing M4sugar. ##
|
|
## ----------------- ##
|
|
|
|
|
|
# AT_DATA_M4SUGAR(FILE-NAME, CONTENTS)
|
|
# ------------------------------------
|
|
# Escape the invalid tokens with @&t@.
|
|
m4_define([AT_DATA_M4SUGAR],
|
|
[AT_DATA([$1],
|
|
[m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\)\(_\)\|\(d\)\(nl\)],
|
|
[\1\3\5@&t@\2\4\6])])])
|
|
|
|
|
|
# AT_CHECK_M4SUGAR(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
|
|
# ----------------------------------------------------------
|
|
m4_define([AT_CHECK_M4SUGAR],
|
|
[AT_KEYWORDS([m4sugar])
|
|
AT_CHECK_AUTOM4TE([--language=m4sugar script.4s -o script $1],
|
|
[$2], [$3], [$4])])
|
|
|
|
|
|
|
|
## -------------- ##
|
|
## Testing M4sh. ##
|
|
## -------------- ##
|
|
|
|
|
|
# AT_DATA_M4SH(FILE-NAME, CONTENTS)
|
|
# ---------------------------------
|
|
# Escape the invalid tokens with @&t@.
|
|
m4_define([AT_DATA_M4SH],
|
|
[AT_DATA([$1],
|
|
[m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\|AS\)\(_\)\|\(d\)\(nl\)],
|
|
[\1\3\5@&t@\2\4\6])])])
|
|
|
|
|
|
# AT_CHECK_M4SH(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
|
|
# -------------------------------------------------------
|
|
m4_define([AT_CHECK_M4SH],
|
|
[AT_CHECK_AUTOM4TE([--language=m4sh script.as -o script $1],
|
|
[$2], [$3], [$4])])
|
|
|
|
|
|
|
|
## ------------------ ##
|
|
## Testing Autoconf. ##
|
|
## ------------------ ##
|
|
|
|
|
|
# AT_DATA_AUTOCONF(FILE-NAME, CONTENTS)
|
|
# -------------------------------------
|
|
# Escape the invalid tokens with @&t@.
|
|
m4_define([AT_DATA_AUTOCONF],
|
|
[AT_DATA([$1],
|
|
[m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\|AS\|AC\)\(_\)\|\(d\)\(nl\)],
|
|
[\1\3\5@&t@\2\4\6])])])
|
|
|
|
|
|
|
|
# AT_CONFIGURE_AC(BODY)
|
|
# ---------------------
|
|
# Create a full configure.ac running BODY, with a config header set up,
|
|
# AC_OUTPUT, and environment checking hooks.
|
|
m4_define([AT_CONFIGURE_AC],
|
|
[AT_DATA([configure.ac],
|
|
[[AC_INIT
|
|
AC_CONFIG_HEADERS(config.h:config.hin)
|
|
AC_STATE_SAVE(before)]
|
|
$1
|
|
[AC_OUTPUT
|
|
AC_STATE_SAVE(after)
|
|
]])
|
|
cp "$abs_top_srcdir/build-aux/install-sh" \
|
|
"$abs_top_srcdir/build-aux/config.guess" \
|
|
"$abs_top_srcdir/build-aux/config.sub" .
|
|
cp "$abs_top_srcdir/tests/statesave.m4" aclocal.m4
|
|
])# AT_CONFIGURE_AC
|
|
|
|
|
|
# AT_CHECK_AUTOCONF(ARGS, [EXIT-STATUS = 0], STDOUT, STDERR)
|
|
# ----------------------------------------------------------
|
|
# We always use "--force", to prevent problems with timestamps if the testsuite
|
|
# were running too fast.
|
|
m4_define([AT_CHECK_AUTOCONF],
|
|
[AT_CHECK_M4([autoconf --force $1], [$2], [$3], [$4])
|
|
if test -s configure && test "$SHELL_N" != none; then
|
|
AT_CHECK_SHELL_SYNTAX([configure])
|
|
fi
|
|
])
|
|
|
|
|
|
# AT_CHECK_AUTOHEADER(ARGS, EXPECTED_TMPLS, [EXIT-STATUS = 0], STDOUT, STDERR)
|
|
# ----------------------------------------------------------------------------
|
|
# EXPECTED_TMPLS is a whitespace-separated list of template
|
|
# definitions that should appear in the generated config.hin.
|
|
# The stock definitions made by AC_INIT are also checked for.
|
|
# If EXPECTED_TMPLS is the single word 'ignore', or if the
|
|
# expected exit status is not 0, this test is skipped.
|
|
m4_define([AT_CHECK_AUTOHEADER],
|
|
[AT_CHECK_M4([autoheader $1], [$3], [$4], [$5])
|
|
m4_if(m4_strip([$2]), [ignore], [],
|
|
[m4_if(m4_default_nblank([$3], [0]), [0], [dnl
|
|
if test -f config.h.in
|
|
then config_h_in=config.h.in
|
|
elif test -f config.hin
|
|
then config_h_in=config.hin
|
|
else AT_FAIL_IF([: "Cannot find autoheader template file"])
|
|
fi
|
|
m4_set_add_all([ah_expected_tmpls],
|
|
[PACKAGE_BUGREPORT],
|
|
[PACKAGE_NAME],
|
|
[PACKAGE_STRING],
|
|
[PACKAGE_TARNAME],
|
|
[PACKAGE_URL],
|
|
[PACKAGE_VERSION])dnl
|
|
m4_map_args_w([$2],
|
|
[m4_set_add([ah_expected_tmpls],], [)])dnl
|
|
AT_DATA([expout.in],[m4_set_dump([ah_expected_tmpls],[
|
|
])
|
|
])
|
|
AT_CHECK([sort -o expout expout.in])
|
|
AT_CHECK([[sed -ne 's/^[ ]*#[ ]*undef[ ][ ]*//p' \
|
|
$config_h_in | sort]],
|
|
[0], [expout], [])
|
|
AS_UNSET([config_h_in])
|
|
])])])
|
|
|
|
|
|
# AT_CHECK_CONFIGURE(END-COMMAND,
|
|
# [EXIT-STATUS = 0],
|
|
# [STDOUT = IGNORE], STDERR)
|
|
# ---------------------------------------------
|
|
# 'abs_top_srcdir' is needed so that './configure' finds install-sh.
|
|
# Using --srcdir is more expensive.
|
|
m4_define([AT_CHECK_CONFIGURE],
|
|
[AT_CAPTURE_FILE([config.log])[]dnl
|
|
AT_CHECK([./configure $configure_options $1],
|
|
[$2],
|
|
m4_default([$3], [ignore]), [$4])])
|
|
|
|
|
|
# AT_CHECK_ENV
|
|
# ------------
|
|
# Check that the full configure run remained in its variable name space,
|
|
# and cleaned up tmp files.
|
|
#
|
|
# Perhaps grep -E is not supported, or perhaps it chokes on such a big regex.
|
|
# In this case just don't pay attention to the env. It would be great
|
|
# to keep the error message but we can't: that would break AT_CHECK.
|
|
#
|
|
# FreeBSD sh may intermingle the trace output from the egrep and grep
|
|
# commands in the pipe, so turn off tracing for these.
|
|
#
|
|
# Some tests might exit prematurely when they find a problem, in
|
|
# which case 'env-after' is probably missing. Don't check it then.
|
|
#
|
|
# Here are the variables 'configure' may modify during execution:
|
|
# - ^as_
|
|
# M4sh's shell name space.
|
|
# - ^ac_
|
|
# Autoconf's shell name space.
|
|
# - prefix and exec_prefix
|
|
# are kept undefined (NONE) until AC_OUTPUT which then sets them to
|
|
# '/usr/local' and '${prefix}' for make.
|
|
# - (host|build|target)(_(alias|cpu|vendor|os))?
|
|
# Set by AC_CANONICAL_(HOST|BUILD|TARGET).
|
|
# - cross_compiling
|
|
# Set by AC_INIT.
|
|
# - interpval
|
|
# Set by AC_SYS_INTERPRETER.
|
|
# - enableval, withval, enable_*, with_*
|
|
# Set by AC_ARG_ENABLE and AC_ARG_WITH.
|
|
# - CONFIG_STATUS and DEFS
|
|
# Set by AC_OUTPUT.
|
|
# - AC_SUBST'ed variables
|
|
# (FIXME: Generate a list of these automatically.)
|
|
# - _|@|.[*#?$].|argv|ARGC|LINENO|OLDPWD|PIPESTATUS|RANDOM|SECONDS
|
|
# |SHLVL|START_TIME|ToD|_AST_FEATURES
|
|
# Some variables some shells use and change.
|
|
# '.[*#?$].' catches '$#' etc. which are displayed like this:
|
|
# | '!'=18186
|
|
# | '#'=0
|
|
# | '$'=6908
|
|
#
|
|
m4_defun([AT_CHECK_ENV],
|
|
[m4_require([_AT_CHECK_ENV])]dnl
|
|
[AT_CHECK([ath_fn_check_env])])
|
|
|
|
m4_defun([_AT_CHECK_ENV],
|
|
[AT_TEST_HELPER_FN([check_env], [],
|
|
[Compare the directory and environment state both before and after a run,
|
|
and return non-zero status if they differ inappropriately.],
|
|
[# Compare directory listings.
|
|
test -f state-ls.before ||
|
|
AS_ERROR([state-ls.before not present])
|
|
test -f state-ls.after \
|
|
&& { $at_diff state-ls.before state-ls.after || return 1; }
|
|
# Compare variable space dumps.
|
|
if test -f state-env.before && test -f state-env.after; then
|
|
set +x
|
|
grep_failed=false
|
|
for act_file in state-env.before state-env.after
|
|
do
|
|
($EGREP -v '^(m4_join([|],
|
|
[a[cs]_.*],
|
|
[(exec_)?prefix|DEFS|CONFIG_STATUS],
|
|
[CC|CFLAGS|CPPFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|F77|FFLAGS|FLIBS|G77],
|
|
[ERL|ERLC|ERLCFLAGS|ERLANG_PATH_ERL|ERLANG_ROOT_DIR|ERLANG_LIB_DIR],
|
|
[ERLANG_LIB_DIR_.*|ERLANG_LIB_VER_.*|ERLANG_INSTALL_LIB_DIR],
|
|
[ERLANG_INSTALL_LIB_DIR_.*|ERLANG_ERTS_VER|OBJC|OBJCPP|OBJCFLAGS],
|
|
[OBJCXX|OBJCXXCPP|OBJCXXFLAGS],
|
|
[GOC|GOFLAGS],
|
|
[OPENMP_(C|CXX)FLAGS],
|
|
[LIBS|LIB@&t@OBJS|LTLIBOBJS|LDFLAGS],
|
|
[INSTALL(_(DATA|PROGRAM|SCRIPT))?],
|
|
[EXEEXT|OBJEXT],
|
|
[CYGWIN|EMXOS2|ISC|MINGW32|MINIX|MSYS|XENIX],
|
|
[X_(CFLAGS|(EXTRA_|PRE_)?LIBS)|x_(includes|libraries)|(have|no)_x],
|
|
[(host|build|target)(_(alias|cpu|vendor|os))?],
|
|
[cross_compiling|U],
|
|
[enableval|enable_.*|withval|with_.*],
|
|
[interpval|PATH_SEPARATOR],
|
|
[GFC|F77_DUMMY_MAIN|f77_(case|underscore)],
|
|
[FC(_DUMMY_MAIN|FLAGS|LIBS|FLAGS_[fF]|_MODEXT|_MODINC|_MODOUT|_DEFINE)?],
|
|
[ALLOCA|GETGROUPS_LIB|GETLOADAVG_LIBS|KMEM_GROUP|NEED_SETGID|POW_LIB],
|
|
[AWK|LEX|LEXLIB|LEX_OUTPUT_ROOT|LN_S|M4|MKDIR_P|AR|RANLIB|SET_MAKE|YACC],
|
|
[EGREP_TRADITIONAL],
|
|
[GREP|[EF]GREP|SED],
|
|
[[_@]|.[*@%:@?$].],
|
|
[argv|ARGC|LINENO|BASH_ARGC|BASH_ARGV|OLDPWD|PIPESTATUS|RANDOM],
|
|
[SECONDS|SHLVL|START_TIME|ToD|_AST_FEATURES]))=' \
|
|
$act_file ||
|
|
test $? -eq 1 || echo failed >&2
|
|
) 2>stderr-$act_file |
|
|
# There may be variables spread on several lines; remove latter lines.
|
|
$GREP '^m4_defn([m4_re_word])=' >clean-$act_file ||
|
|
test $? -eq 1 || grep_failed=:
|
|
test -s stderr-$act_file && grep_failed=:
|
|
done
|
|
$at_traceon
|
|
$grep_failed || $at_diff clean-state-env.before clean-state-env.after
|
|
fi
|
|
])])
|
|
|
|
|
|
# AT_CONFIG_CMP(VAR-FILE-A, VAR-FILE-B, [EXTRA-VARIANCE])
|
|
# -------------------------------------------------------
|
|
# Check the outcomes of two configure runs for equality by comparing dumps of
|
|
# their shell variables. VAR-FILE-A and VAR-FILE-B are two 'set'-style shell
|
|
# variable space dumps.
|
|
#
|
|
# We permit variance between runs in the following shell variables:
|
|
# - ^as_
|
|
# M4sh's shell name space.
|
|
# - ^ac_, excluding ^ac_cv_
|
|
# Autoconf's private shell name space.
|
|
# - Variables with unstable values in at least some shells:
|
|
# - OLDPWD [bash, zsh]
|
|
# - PPID [bash, zsh]
|
|
# - RANDOM [bash, zsh]
|
|
# - SECONDS [bash, zsh]
|
|
# - SHLVL [bash]
|
|
# - START_TIME [NetBSD sh]
|
|
# - ToD [NetBSD sh]
|
|
# - '$' [zsh]
|
|
# - argv [zsh]
|
|
# - ARGC [zsh]
|
|
# - BASH_ARGC [bash]
|
|
# - BASH_ARGV [bash]
|
|
# - LINENO [Posix]
|
|
# - _AST_FEATURES [ksh93]
|
|
# - Optionally, variables that are expected to vary in a particular test.
|
|
# This is controlled by the EXTRA-VARIANCE argument, which is a
|
|
# whitespace-separated sequence of tokens. Each token means to ignore
|
|
# one or more additional variables and/or rename some variables, as follows:
|
|
#
|
|
# cross: ignore cross_compiling
|
|
# cxx: ignore all of:
|
|
# - CC, CPP, CCC, CXX, CXXCPP, CFLAGS, CXXFLAGS, GCC, GXX
|
|
# - ac_cv_env_(any of the above)_(set|value)
|
|
# - ac_cv_(c|cxx)_compiler_gnu
|
|
# - ac_cv_(c|cxx)_undeclared_builtin_options
|
|
# - ac_cv_prog_c_*, ac_cv_prog_cxx_*
|
|
# - ac_cv_prog_(ac_ct_)?(CC|CXX|CPP|CXXCPP)
|
|
# + other ac_cv_c_* are renamed to ac_cv_cxx_*
|
|
# + OPENMP_CFLAGS is renamed to OPENMP_CXXFLAGS
|
|
# vary:NAME (where NAME is any identifier): ignore ac_cv_NAME
|
|
#
|
|
# Furthermore, it is okay for a non-cache variable initialized to empty in one
|
|
# run to be unset in another run. This happens when, for example, cache update
|
|
# code tries a number of values in LIBS and eventually restores LIBS to its
|
|
# original value. If LIBS was previously unset, it will have become set and
|
|
# empty. (OTOH, cache variables indicate the result of the test even if they
|
|
# are empty, so we have to be strict about them.)
|
|
#
|
|
# Lines that do not look like 'foo=bar' are probably latter lines of
|
|
# multiline values; trim them.
|
|
m4_define([AT_CONFIG_CMP],
|
|
[for act_file in $1 $2
|
|
do
|
|
$SED '/^ac_cv_/ b skip
|
|
/^m4_defn([m4_re_word])=./ !d
|
|
/^[[^=]]*='\'''\''$/ d
|
|
/^[[^=]]*=""$/ d
|
|
/^a[[cs]]_/ d
|
|
: skip
|
|
/^OLDPWD=/ d
|
|
/^PPID=/ d
|
|
/^RANDOM=/ d
|
|
/^SECONDS=/ d
|
|
/^SHLVL=/ d
|
|
/^START_TIME=/ d
|
|
/^ToD=/ d
|
|
/'\'\\\$\''=/ d
|
|
/^argv=/ d
|
|
/^ARGC=/ d
|
|
/^BASH_ARGC=/ d
|
|
/^BASH_ARGV=/ d
|
|
/^LINENO=/ d
|
|
/^_AST_FEATURES=/ d
|
|
m4_map_args_w([$3], [_AT_CONFIG_CMP_PRUNE(], [)])dnl
|
|
' < $act_file > at_config_vars-$act_file
|
|
done
|
|
AT_CMP([at_config_vars-$1], [at_config_vars-$2])[]dnl
|
|
])# AT_CONFIG_CMP
|
|
|
|
# _AT_CONFIG_CMP_PRUNE(TOKEN)
|
|
# ---------------------------
|
|
# Subroutine of AT_CONFIG_CMP which implements the extra-variance rules
|
|
# described above. Expands to additional sed commands to be inserted in
|
|
# the program above.
|
|
# Note for future readers: not all sed implementations allow alternations
|
|
# in regexes (e.g. /^ac_cv_env_CC_\(set\|value\)=/ would not be portable).
|
|
m4_define([_AT_CONFIG_CMP_PRUNE],
|
|
[m4_bmatch([$1],
|
|
[^cross$],
|
|
[ /^cross_compiling=/ d
|
|
],
|
|
[^cxx$],
|
|
[ /^CC=/ d
|
|
/^CPP=/ d
|
|
/^CCC=/ d
|
|
/^CXX=/ d
|
|
/^CXXCPP=/ d
|
|
/^CFLAGS=/ d
|
|
/^CXXFLAGS=/ d
|
|
/^GCC=/ d
|
|
/^GXX=/ d
|
|
/^ac_cv_env_CC_set=/ d
|
|
/^ac_cv_env_CC_value=/ d
|
|
/^ac_cv_env_CPP_set=/ d
|
|
/^ac_cv_env_CPP_value=/ d
|
|
/^ac_cv_env_CFLAGS_set=/ d
|
|
/^ac_cv_env_CFLAGS_value=/ d
|
|
/^ac_cv_env_GCC_set=/ d
|
|
/^ac_cv_env_GCC_value=/ d
|
|
/^ac_cv_env_CCC_set=/ d
|
|
/^ac_cv_env_CCC_value=/ d
|
|
/^ac_cv_env_CXX_set=/ d
|
|
/^ac_cv_env_CXX_value=/ d
|
|
/^ac_cv_env_CXXCPP_set=/ d
|
|
/^ac_cv_env_CXXCPP_value=/ d
|
|
/^ac_cv_env_CXXFLAGS_set=/ d
|
|
/^ac_cv_env_CXXFLAGS_value=/ d
|
|
/^ac_cv_env_GXX_set=/ d
|
|
/^ac_cv_env_GXX_value=/ d
|
|
/^ac_cv_prog_CC=/ d
|
|
/^ac_cv_prog_CXX=/ d
|
|
/^ac_cv_prog_CPP=/ d
|
|
/^ac_cv_prog_CXXCPP=/ d
|
|
/^ac_cv_prog_ac_ct_CC=/ d
|
|
/^ac_cv_prog_ac_ct_CXX=/ d
|
|
/^ac_cv_prog_ac_ct_CPP=/ d
|
|
/^ac_cv_prog_ac_ct_CXXCPP=/ d
|
|
/^ac_cv_c_compiler_gnu=/ d
|
|
/^ac_cv_cxx_compiler_gnu=/ d
|
|
/^ac_cv_c_undeclared_builtin_options=/ d
|
|
/^ac_cv_cxx_undeclared_builtin_options=/ d
|
|
/^ac_cv_prog_c_@<:@^=@:>@*=/ d
|
|
/^ac_cv_prog_cc_@<:@^=@:>@*=/ d
|
|
/^ac_cv_prog_cxx_@<:@^=@:>@*=/ d
|
|
s/^ac_cv_c_/ac_cv_cxx_/
|
|
s/^OPENMP_CFLAGS=/OPENMP_CXXFLAGS=/
|
|
],
|
|
[^vary:],
|
|
[ /^ac_cv_]m4_bpatsubsts([$1], [\<vary:], [])[=/ d
|
|
],
|
|
[m4_fatal([unrecognized AT_CONFIG_CMP variance token: "$1"])])])
|
|
|
|
|
|
# AT_DEFINES_CMP(CONFIG-H-A, CONFIG-H-B, [EXTRA-VARIANCE])
|
|
# --------------------------------------------------------
|
|
# Check the outcomes of two configure runs for equality by comparing the
|
|
# config.h headers they produced. Optionally, ignore changes to particular
|
|
# defines, under the control of the EXTRA-VARIANCE argument, which is a
|
|
# whitespace-separated sequence of tokens. Each token means to ignore
|
|
# one or more additional defines, as follows:
|
|
# vary:NAME (where NAME is any identifier): ignore #define/#undef NAME
|
|
m4_define([AT_DEFINES_CMP],
|
|
[m4_ifblank([$3], [AT_CMP([$1], [$2])],
|
|
[for act_file in $1 $2
|
|
do
|
|
$SED '
|
|
m4_map_args_w([$3], [_AT_DEFINES_CMP_PRUNE(], [)])
|
|
' < $act_file > at_defines-$act_file
|
|
done
|
|
AT_CMP([at_defines-$1], [at_defines-$2])[]dnl
|
|
])])# AT_DEFINES_CMP
|
|
|
|
|
|
# _AT_DEFINES_CMP_PRUNE(TOKEN)
|
|
# ---------------------------
|
|
# Subroutine of AT_DEFINES_CMP which implements the extra-variance rules
|
|
# described above. Expands to one or more sed commands.
|
|
# After quadrigraph replacement, each sed command group will be
|
|
# /#define macro_name[ (]/ d ;#)
|
|
# /#undef macro_name[ (]/ d ;#)
|
|
# AC_DEFINE never emits tabs or puts whitespace between '#' and
|
|
# 'define' or 'undef', so this is sufficient.
|
|
m4_define([_AT_DEFINES_CMP_PRUNE],
|
|
[m4_bmatch([$1],
|
|
[^vary:],
|
|
[ /@%:@define ]m4_bpatsubsts([$1], [\<vary:], [])[]dnl
|
|
[@<:@ @{:@@:>@/ d ;@%:@@:}@
|
|
/@%:@undef ]m4_bpatsubsts([$1], [\<vary:], [])[]dnl
|
|
[@<:@ @{:@@:>@/ d ;@%:@@:}@
|
|
],
|
|
[m4_fatal([unrecognized AT_DEFINES_CMP variance token: "$1"])])])
|
|
|
|
|
|
# AT_PRESERVE_CONFIG_STATUS(SUFFIX)
|
|
# ---------------------------------
|
|
# Copy the files 'state-env.after', 'config.h', 'config.log', and
|
|
# 'config.status' to names ending with SUFFIX, so they are not
|
|
# clobbered by a subsequent run of configure.
|
|
m4_define([AT_PRESERVE_CONFIG_STATUS],
|
|
[cp -f state-env.after state-env.$1
|
|
cp -f config.h config-h.$1
|
|
cp -f config.log config-log.$1
|
|
cp -f config.status config-status.$1
|
|
])
|
|
|
|
|
|
# AT_CHECK_DEFINES(CONTENT)
|
|
# -------------------------
|
|
# Verify that config.h, once stripped, is CONTENT.
|
|
# Stripping consists of keeping CPP lines (i.e. containing a hash),
|
|
# but those of automatically checked features (STDC_HEADERS etc.)
|
|
# and symbols (PACKAGE_...).
|
|
# AT_CHECK_HEADER is a better name, but too close from AC_CHECK_HEADER.
|
|
m4_define([AT_CHECK_DEFINES],
|
|
[AT_CHECK([[sed '/#/!d
|
|
/INTTYPES_H/d
|
|
/MEMORY_H/d
|
|
/PACKAGE_/d
|
|
/STDC_HEADERS/d
|
|
/STDINT_H/d
|
|
/STDIO_H/d
|
|
/STDLIB_H/d
|
|
/STRING_H/d
|
|
/STRINGS_H/d
|
|
/SYS_STAT_H/d
|
|
/SYS_TYPES_H/d
|
|
/UNISTD_H/d' config.h]],,
|
|
[$1])])
|
|
|
|
|
|
# AT_CHECK_AUTOUPDATE
|
|
# -------------------
|
|
m4_define([AT_CHECK_AUTOUPDATE],
|
|
[AT_CHECK([autoupdate $1], [$2], [$3], [$4])
|
|
])
|
|
|
|
|
|
# AT_CHECK_MAKE(MAKEARGS, DIRECTORY, EXIT-STATUS,
|
|
# [STDOUT = IGNORE], [STDERR = IGNORE])
|
|
# ---------------------------------------------------------------
|
|
# Run make in DIRECTORY (default '.'), passing MAKEARGS on the command
|
|
# line. EXIT-STATUS, STDOUT, and STDERR are as for AT_CHECK.
|
|
# The environment variable MAKE is honored if present.
|
|
# The environment variable MAKEFLAGS is *cleared*.
|
|
# If EXIT-STATUS is 1, an exit status of either 1 or 2 is considered
|
|
# an acceptable result, because there are situations where BSD make will
|
|
# exit with status 1 but GNU make will instead exit with status 2.
|
|
m4_define([AT_CHECK_MAKE],
|
|
[AT_CHECK(
|
|
m4_if(m4_default([$2], [.]), [.], [],
|
|
[cd "$2" && ])[$][MAKE]m4_ifnblank([$1],[ $1])[]m4_if([$3], [1], [[
|
|
dnl pacify editors that don't understand sh case: ((
|
|
case $? in 1|2) exit 1;; *) exit $?;; esac]]),
|
|
[$3],
|
|
m4_default([$4], [ignore]),
|
|
m4_default([$5], [ignore]))
|
|
])
|
|
|
|
|
|
# _AT_CHECK_AC_MACRO(AC-BODY, [PRE-TESTS], [AUTOCONF-FLAGS])
|
|
# ----------------------------------------------------------
|
|
# Create a minimalist configure.ac running the macro named
|
|
# NAME-OF-THE-MACRO, check that autoconf runs on that script,
|
|
# and that the generated configure script runs without error.
|
|
m4_define([_AT_CHECK_AC_MACRO],
|
|
[AT_CONFIGURE_AC([$1])
|
|
$2
|
|
AT_CHECK_AUTOCONF([$3])
|
|
AT_CHECK_AUTOHEADER([$3], [ignore])
|
|
AT_CHECK_CONFIGURE
|
|
AT_CHECK_ENV
|
|
])# _AT_CHECK_AC_MACRO
|
|
|
|
# AT_CHECK_CONFIGURE_AC(NAME, AC-BODY, [AUTOCONF-FLAGS],
|
|
# [PRE-TESTS], [POST-TESTS])
|
|
# -----------------------------------------------------
|
|
# Shorthand for a complete test "group" consisting of a single
|
|
# invocation of _AT_CHECK_AC_MACRO, possibly with some additional
|
|
# tests executed before and after.
|
|
m4_define([AT_CHECK_CONFIGURE_AC],
|
|
[AT_SETUP([$1])
|
|
_AT_CHECK_AC_MACRO([$2], [$4], [$3])
|
|
$5
|
|
AT_CLEANUP
|
|
])
|
|
|
|
# AT_CHECK_MACRO(MACRO, [MACRO-USE], [ADDITIONAL-CMDS],
|
|
# [AUTOCONF-FLAGS], [TEST-PARAMETERS], [PRETEST-CMDS])
|
|
# -----------------------------------------------------
|
|
# Create a minimalist configure.ac running the macro named MACRO
|
|
# (using the code in MACRO-USE if that argument is not empty,
|
|
# otherwise a bare invocation of MACRO with no arguments),
|
|
# check that autoconf runs on that script,
|
|
# and that the generated configure script runs without error.
|
|
# AUTOCONF-FLAGS are passed to all invocations of autoconf.
|
|
#
|
|
# We always generate two variants of the minimalist configure.ac,
|
|
# with and without forcing the script into cross-compilation mode
|
|
# before executing MACRO-USE. If a C++ compiler is available, we
|
|
# generate two more variants in which MACRO-USE is invoked while
|
|
# AC_LANG([C++]) is in effect; as before, one forces the script into
|
|
# cross-compilation mode and the other doesn't. All variants of the
|
|
# generated configure script are run twice, once with an empty cache,
|
|
# and once with a cache primed by the previous run.
|
|
#
|
|
# All four (or eight, if C++ is available) runs are expected to
|
|
# produce the same results, except for the value of 'cross_compiling'
|
|
# and differences due to running AC_PROG_CXX instead of AC_PROG_CC.
|
|
# (See AT_CONFIG_CMP for details.)
|
|
#
|
|
# If ADDITIONAL-CMDS are present, they are executed after the first
|
|
# pair of tests (with the C compiler, in native mode).
|
|
#
|
|
# If PRETEST-CMDS are present, they are executed immediately after
|
|
# AT_SETUP; use this if the test needs to be skipped conditionally,
|
|
# for example.
|
|
#
|
|
# If TEST-PARAMETERS are present, they should be a space-separated
|
|
# list of modifiers to how the test is carried out. Currently
|
|
# the following modifiers are defined:
|
|
#
|
|
# - 'no-cross': Don't test this macro in cross-compilation mode.
|
|
# This is for macros that use AC_RUN_IFELSE, and therefore, when
|
|
# cross-compiling, they either crash or give a 'best guess' answer
|
|
# that may be wrong.
|
|
#
|
|
# - 'cxx_cv_varies:NAME': The value of the cache variable ac_cv_NAME
|
|
# may legitimately vary between the C tests and the C++ tests.
|
|
#
|
|
# - 'cxx_define_varies:NAME' The value of the AC_DEFINEd macro NAME
|
|
# may legitimately vary between the C tests and the C++ tests.
|
|
m4_define([AT_CHECK_MACRO],
|
|
[AT_SETUP([$1])
|
|
m4_n([$6])dnl
|
|
|
|
# C compiler, native mode.
|
|
AT_CONFIGURE_AC([m4_default([$2], [$1])])
|
|
AT_CHECK_AUTOCONF([$4])
|
|
AT_CHECK_AUTOHEADER([$4], [ignore])
|
|
|
|
cp -f configure.ac configure-ac.c-native
|
|
cp -f configure configure.c-native
|
|
cp -f config.hin config-hin.c-native
|
|
|
|
AT_CHECK_CONFIGURE([-C])
|
|
AT_PRESERVE_CONFIG_STATUS([c-native-r1])
|
|
AT_CHECK_ENV
|
|
AT_CHECK_CONFIGURE([-C])
|
|
AT_PRESERVE_CONFIG_STATUS([c-native-r2])
|
|
AT_CHECK_ENV
|
|
|
|
AT_DEFINES_CMP([config-h.c-native-r1], [config-h.c-native-r2])
|
|
AT_CONFIG_CMP([state-env.c-native-r1], [state-env.c-native-r2])
|
|
|
|
m4_n([$3])dnl
|
|
m4_bmatch([$5], [\<no-cross\>], [], [dnl
|
|
|
|
# C compiler, cross-compilation mode.
|
|
rm -rf config.cache autom4te.cache
|
|
AT_CONFIGURE_AC(
|
|
[cross_compiling=yes
|
|
ac_tool_warned=yes
|
|
m4_default([$2], [$1])])
|
|
AT_CHECK_AUTOCONF([$4])
|
|
AT_CHECK_AUTOHEADER([$4], [ignore])
|
|
|
|
cp -f configure.ac configure-ac.c-cross
|
|
cp -f configure configure.c-cross
|
|
cp -f config.hin config-hin.c-cross
|
|
|
|
AT_CHECK_CONFIGURE([-C])
|
|
AT_PRESERVE_CONFIG_STATUS([c-cross-r1])
|
|
AT_CHECK_ENV
|
|
AT_DEFINES_CMP([config-h.c-native-r1], [config-h.c-cross-r1])
|
|
AT_CONFIG_CMP([state-env.c-native-r1], [state-env.c-cross-r1], [cross])
|
|
|
|
AT_CHECK_CONFIGURE([-C])
|
|
AT_PRESERVE_CONFIG_STATUS([c-cross-r2])
|
|
AT_CHECK_ENV
|
|
AT_DEFINES_CMP([config-h.c-native-r1], [config-h.c-cross-r2])
|
|
AT_CONFIG_CMP([state-env.c-native-r1], [state-env.c-cross-r2], [cross])
|
|
])dnl
|
|
|
|
# To save time, skip the C++-mode tests for any macro that did not
|
|
# transitively require AC_PROG_CC; it won't make any difference.
|
|
if grep '^CC=' state-env.c-native-r1 > /dev/null 2>&1; then
|
|
|
|
# C++ compiler, native mode.
|
|
rm -rf config.cache autom4te.cache
|
|
AT_CONFIGURE_AC(
|
|
[AC_LANG([C++])
|
|
m4_default([$2], [$1])])
|
|
|
|
# Autoconf may fail here because of an AC_LANG_ASSERT([C]); this
|
|
# means the macro is specific to C and should not be tested with the
|
|
# C++ compiler.
|
|
AT_CHECK_AUTOCONF([$4], [ignore], [ignore], [stderr])
|
|
if test -s stderr; then
|
|
AT_CHECK([grep 'error: AC_LANG_ASSERT: current language is not C' stderr],
|
|
[0], [ignore], [ignore])
|
|
else
|
|
AT_CHECK_AUTOHEADER([$4], [ignore])
|
|
|
|
cp -f configure.ac configure-ac.cxx-native
|
|
cp -f configure configure.cxx-native
|
|
cp -f config.hin config-hin.cxx-native
|
|
|
|
# If this configure pass fails with code 77, that means there is no
|
|
# C++ compiler available; don't mark the entire test group skipped,
|
|
# just skip the rest of the C++ testing.
|
|
AT_CHECK_CONFIGURE([-C;
|
|
status=$?
|
|
if test $status -eq 77; then
|
|
touch at-no-cxx
|
|
exit 0
|
|
else
|
|
exit $status
|
|
fi
|
|
])
|
|
if test ! -f at-no-cxx; then
|
|
AT_PRESERVE_CONFIG_STATUS([cxx-native-r1])
|
|
AT_CHECK_ENV
|
|
AT_DEFINES_CMP([config-h.c-native-r1], [config-h.cxx-native-r1],
|
|
_AT_FILTER_CXX_DEFINE_VARIES([$5]))
|
|
AT_CONFIG_CMP([state-env.c-native-r1], [state-env.cxx-native-r1],
|
|
[cxx ]_AT_FILTER_CXX_CV_VARIES([$5]))
|
|
|
|
AT_CHECK_CONFIGURE([-C])
|
|
AT_PRESERVE_CONFIG_STATUS([cxx-native-r2])
|
|
AT_CHECK_ENV
|
|
AT_DEFINES_CMP([config-h.cxx-native-r1], [config-h.cxx-native-r2])
|
|
AT_CONFIG_CMP([state-env.cxx-native-r1], [state-env.cxx-native-r2])
|
|
m4_bmatch([$5], [\<no-cross\>], [], [dnl
|
|
|
|
# Fourth run: C++ compiler, cross-compilation mode.
|
|
|
|
rm -rf config.cache autom4te.cache
|
|
AT_CONFIGURE_AC(
|
|
[cross_compiling=yes
|
|
ac_tool_warned=yes
|
|
AC_LANG([C++])
|
|
m4_default([$2], [$1])])
|
|
AT_CHECK_AUTOCONF([$4])
|
|
AT_CHECK_AUTOHEADER([$4], [ignore])
|
|
|
|
cp -f configure.ac configure-ac.cxx-cross
|
|
cp -f configure configure.cxx-cross
|
|
cp -f config.hin config-hin.cxx-cross
|
|
|
|
AT_CHECK_CONFIGURE([-C])
|
|
AT_PRESERVE_CONFIG_STATUS([cxx-cross-r1])
|
|
AT_CHECK_ENV
|
|
AT_DEFINES_CMP([config-h.cxx-native-r1], [config-h.cxx-cross-r1])
|
|
AT_CONFIG_CMP([state-env.cxx-native-r1], [state-env.cxx-cross-r1],
|
|
[cross])
|
|
|
|
AT_CHECK_CONFIGURE([-C])
|
|
AT_PRESERVE_CONFIG_STATUS([cxx-cross-r2])
|
|
AT_CHECK_ENV
|
|
AT_DEFINES_CMP([config-h.cxx-cross-r1], [config-h.cxx-cross-r2])
|
|
AT_CONFIG_CMP([state-env.cxx-cross-r1], [state-env.cxx-cross-r2])
|
|
])dnl
|
|
fi # C++ compiler available
|
|
fi # macro can be used with C++
|
|
fi # C++ makes a difference
|
|
|
|
AT_CLEANUP
|
|
])# AT_CHECK_MACRO
|
|
|
|
|
|
# _AT_FILTER_CXX_CV_VARIES(TEST-PARAMETERS)
|
|
# ---------------------------------------------
|
|
# Subroutine of AT_CHECK_MACRO that expands to a sequence of
|
|
# zero or more 'vary:NAME' tokens, one for each occurrence of
|
|
# 'cxx_cv_varies:NAME' in TEST-PARAMETERS.
|
|
m4_define([_AT_FILTER_CXX_CV_VARIES],
|
|
[m4_map_args_w([$1], [_AT_FILTER_CXX_CV_VARY(], [)], [ ])])
|
|
|
|
m4_define([_AT_FILTER_CXX_CV_VARY],
|
|
[m4_bmatch([$1], [^cxx_cv_varies:],
|
|
[m4_bpatsubsts([$1], [\<cxx_cv_varies:], [vary:])])])
|
|
|
|
|
|
# _AT_FILTER_CXX_DEFINE_VARIES(TEST-PARAMETERS)
|
|
# ---------------------------------------------
|
|
# Subroutine of AT_CHECK_MACRO that expands to a sequence of
|
|
# zero or more 'vary:NAME' tokens, one for each occurrence of
|
|
# 'cxx_define_varies:NAME' in TEST-PARAMETERS.
|
|
m4_define([_AT_FILTER_CXX_DEFINE_VARIES],
|
|
[m4_map_args_w([$1], [_AT_FILTER_CXX_DEFINE_VARY(], [)], [ ])])
|
|
|
|
m4_define([_AT_FILTER_CXX_DEFINE_VARY],
|
|
[m4_bmatch([$1], [^cxx_define_varies:],
|
|
[m4_bpatsubsts([$1], [\<cxx_define_varies:], [vary:])])])
|
|
|
|
|
|
# AT_CHECK_AU_MACRO(MACRO, [MACRO-USE], [ADDITIONAL-CMDS],
|
|
# [AUTOCONF-FLAGS], [TEST-PARAMETERS])
|
|
# ------------------------
|
|
# Do all the tests that AT_CHECK_MACRO(...) would do.
|
|
#
|
|
# In addition, run autoupdate on configure.ac; afterward, verify that
|
|
# MACRO no longer appears in configure.ac, autoconf runs on the
|
|
# updated script, the configure script still runs without error, and
|
|
# the result of configuration is unchanged.
|
|
#
|
|
# Before running autoupdate, check for a -Wobsolete warning naming
|
|
# MACRO from configure. After running autoupdate, *don't* check for
|
|
# the absence of -Wobsolete warnings, because many of autoupdate's
|
|
# edits leave the configure.ac author with some manual work to do, and
|
|
# indicate this by inserting an m4_warn message to be removed after
|
|
# the manual work is complete.
|
|
m4_define([AT_CHECK_AU_MACRO],
|
|
[AT_CHECK_MACRO([$1], [$2], [$3], [-Wno-obsolete $4], [$5])
|
|
|
|
AT_SETUP([autoupdating $1])
|
|
AT_KEYWORDS([autoupdate])
|
|
|
|
AT_CONFIGURE_AC([m4_default([$2], [$1])])
|
|
|
|
AT_CHECK_AUTOCONF([$4], 0, [], [stderr])
|
|
AT_CHECK([grep 'macro .$1. is obsolete' stderr], 0, [ignore], [ignore])
|
|
AT_CHECK_AUTOHEADER([-Wno-obsolete $4], [ignore])
|
|
AT_CHECK_CONFIGURE
|
|
AT_CHECK_ENV
|
|
AT_PRESERVE_CONFIG_STATUS([before-au])
|
|
|
|
rm config.hin
|
|
AT_CHECK_AUTOUPDATE([], 0, [], ignore)
|
|
AT_CHECK([grep '^$1$' configure.ac], 1)
|
|
|
|
AT_CHECK_AUTOCONF([-Wno-obsolete $4])
|
|
AT_CHECK_AUTOHEADER([-Wno-obsolete $4], [ignore])
|
|
AT_CHECK_CONFIGURE
|
|
AT_CHECK_ENV
|
|
AT_PRESERVE_CONFIG_STATUS([after-au])
|
|
|
|
AT_CMP([config-h.before-au], [config-h.after-au])
|
|
AT_CONFIG_CMP([state-env.before-au], [state-env.after-au])
|
|
|
|
AT_CLEANUP[]dnl
|
|
])# AT_CHECK_AU_MACRO
|
|
|
|
|
|
|
|
## ----------------------- ##
|
|
## Launch the test suite. ##
|
|
## ----------------------- ##
|
|
|
|
AT_INIT
|