## ---------------------------------------- ##
-
-# AT_TEST_MACRO(NAME-OF-THE-MACRO, [MACRO-USE], [ADDITIONAL-CMDS])
-# ----------------------------------------------------------------
+# _AT_CHECK_AC_MACRO(AC-BODY)
+# ---------------------------
# Create a minimalist configure.in running the macro named
# NAME-OF-THE-MACRO, check that autoconf runs on that script,
# and that the shell runs correctly the configure.
# TOP_SRCDIR is needed to set the auxdir (some macros need `install-sh',
# `config.guess' etc.).
-AT_DEFINE(AT_TEST_MACRO,
-[AT_SETUP([$1])
-
-dnl Produce the configure.in
-AT_DATA(configure.in,
+AT_DEFINE([_AT_CHECK_AC_MACRO],
+[dnl Produce the configure.in
+AT_DATA([configure.in],
[AC_INIT
AC_CONFIG_AUX_DIR($top_srcdir)
AC_CONFIG_HEADER(config.h:config.hin)
AC_ENV_SAVE(expout)
-ifelse([$2],,[$1], [$2])
+$1
AC_ENV_SAVE(env-after)
AC_OUTPUT
])
dnl Maybe some day we could be more precise and filter out warnings.
dnl The problem is that currently some warnings are spread on several
dnl lines, so grepping -v warning is not enough.
-AT_CHECK([../autoconf --autoconf-dir .. -l $at_srcdir], 0,, ignore)
-AT_CHECK([../autoheader --autoconf-dir .. -l $at_srcdir], 0,, ignore)
+AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 0,, ignore)
+AT_CHECK([autoheader --autoconf-dir .. -l $at_srcdir], 0,, ignore)
AT_CHECK([top_srcdir=$top_srcdir ./configure], 0, ignore, ignore)
test -n "$at_verbose" && echo "--- config.log" && cat config.log
if test -f env-after; then
AT_CHECK([cat env-after], 0, expout)
fi
+])# _AT_CHECK_AC_MACRO
+
+
+# AT_TEST_MACRO(NAME-OF-THE-MACRO, [MACRO-USE], [ADDITIONAL-CMDS])
+# ----------------------------------------------------------------
+# Create a minimalist configure.in running the macro named
+# NAME-OF-THE-MACRO, check that autoconf runs on that script,
+# and that the shell runs correctly the configure.
+# TOP_SRCDIR is needed to set the auxdir (some macros need `install-sh',
+# `config.guess' etc.).
+AT_DEFINE([AT_TEST_MACRO],
+[AT_SETUP([$1])
+
+_AT_CHECK_AC_MACRO([ifelse([$2],,[$1], [$2])])
$3
AT_CLEANUP(configure config.status config.log config.cache config.hin config.h env-after)dnl
-])dnl AT_TEST_MACRO
+])# AT_TEST_MACRO
# but those of automatically checked features (STDC_HEADERS etc.).
# AT_CHECK_HEADER is a better name, but too close from AC_CHECK_HEADER.
AT_DEFINE(AT_CHECK_DEFINES,
-[AT_CHECK([fgrep '#' config.h | grep -v 'STDC_HEADERS'],, [$1])])
+[AT_CHECK([[fgrep '#' config.h | grep -v 'STDC_HEADERS']],, [$1])])
divert(0)dnl
esac]])
+## ------------- ##
+## AC_PROG_CPP. ##
+## ------------- ##
+
+
+# It's Ok for strict preprocessors to produce warnings.
+
+AT_SETUP([AC_PROG_CPP with warnings])
+
+AT_DATA([mycpp],
+[[#! /bin/sh
+${1+"$@"}
+err_code=$?
+echo noise >&2
+exit $err_code
+]])
+
+chmod +x mycpp
+
+_AT_CHECK_AC_MACRO(
+[AC_PROG_CPP
+# If the preprocessor is not strict, just ignore
+test "x$ac_c_preproc_warn_flag" = xyes && exit 77
+CPP="./mycpp $CPP"
+AC_CHECK_HEADERS(stdio.h autoconf_io.h)])
+
+AT_CHECK_DEFINES(
+[/* #undef HAVE_AUTOCONF_IO_H */
+#define HAVE_STDIO_H 1
+])
+
+AT_CLEANUP(configure config.status config.log config.cache config.hin config.h env-after)dnl
+
+
+# Non-strict preprocessors work if they produce no warnings.
+
+AT_SETUP([AC_PROG_CPP without warnings])
+
+AT_DATA([mycpp],
+[[#! /bin/sh
+/lib/cpp ${1+"$@"}
+exit 0
+]])
+
+chmod +x mycpp
+
+_AT_CHECK_AC_MACRO(
+[# Ignore if /lib/cpp doesn't work
+/lib/cpp </dev/null >/dev/null 2>&1 || exit 77
+CPP=./mycpp
+AC_PROG_CPP
+test "x$ac_c_preproc_warn_flag" != xyes && exit 1
+AC_CHECK_HEADERS(stdio.h autoconf_io.h)])
+
+AT_CHECK_DEFINES(
+[/* #undef HAVE_AUTOCONF_IO_H */
+#define HAVE_STDIO_H 1
+])
+
+AT_CLEANUP(configure config.status config.log config.cache config.hin config.h env-after)dnl
+
+
+
## ------------- ##