[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Allow inspecting AC_PREPROC_IFELSE output in true branch.

From: Ralf Wildenhues
Subject: Allow inspecting AC_PREPROC_IFELSE output in true branch.
Date: Mon, 19 Jul 2010 19:43:37 +0200
User-agent: Mutt/1.5.20 (2010-04-22)

The AC_EGREP_CPP macro already allows to test preprocessor output, but
this addition can be helpful if you want to answer two questions with
only one run of the preprocessor.  Also, it is in line with
AC_COMPILE_IFELSE and AC_LINK_IFELSE allowing inspection of output in
the if-true branch.

Another future compatibility reason is that AC_EGREP_CPP is more or less
tied to the C/C++ preprocessor, and I'm thinking about adding general
support for having another preprocessor for another language (you guess
which ;-), which AC_PREPROC_IFELSE could easily support via _AC_LANG.

Note that we on purpose do not make any guarantees for the
action-if-false branch, even if that currently seems to work: it could
be possible that the code is rewritten later to produce an error state
even before the file is created.

IMHO the most dangerous bit of this patch is that I'm unsure why
AC_EGREP_CPP (aka AC_PROGRAM_EGREP earlier) was introduced in the first
place, if there was some portability issue formerly that prevented an


    Allow inspecting AC_PREPROC_IFELSE output in true branch.
    * lib/autoconf/general.m4 (_AC_PREPROC_IFELSE_BODY): Redirect
    preprocessor output to conftest.i rather than /dev/null.
    (_AC_PREPROC_IFELSE): Remove conftest.i in the postprocessing.
    * tests/ (Order of user actions and cleanup): Extend
    test in the ACTION-IF-TRUE branch.
    * doc/autoconf.texi (Running the Preprocessor): Document new
    * NEWS: Update.

diff --git a/NEWS b/NEWS
index 0d72608..0faea46 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,9 @@ GNU Autoconf NEWS - User visible changes.
 ** New macros AC_FC_LINE_LENGTH to accept long Fortran source code lines
    and AC_FC_MODULE_EXTENSION to compute the Fortran module extension.
+** AC_PREPROC_IFELSE now keeps the preprocessed output in the conftest.i
+   file for inspection by the commands in the ACTION-IF-TRUE argument.
 * Major changes in Autoconf 2.66 (2010-07-02) [stable]
   Released by Eric Blake, based on git versions 2.65.*.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index fc247a4..f495487 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -8915,7 +8915,8 @@ This macro uses @code{CPPFLAGS}, but not @code{CFLAGS}, 
 It is customary to report unexpected failures with
address@hidden  If needed, @var{action-if-true} can further access
+the preprocessed output in the file @file{conftest.i}.
 @end defmac
 For instance:
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index fc4905b..5706d69 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2461,7 +2461,7 @@ AC_DEFUN([AC_RUN_LOG],
 # Shell function body for _AC_PREPROC_IFELSE.
 [  AS_LINENO_PUSH([$[]1])
-  AS_IF([_AC_DO_STDERR([$ac_cpp conftest.$ac_ext]) >/dev/null && {
+  AS_IF([_AC_DO_STDERR([$ac_cpp conftest.$ac_ext]) > conftest.i && {
         test -z 
         test ! -s conftest.err
@@ -2486,7 +2486,7 @@ AC_DEFUN([_AC_PREPROC_IFELSE],
 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])]dnl
 [AS_IF([ac_fn_[]_AC_LANG_ABBREV[]_try_cpp "$LINENO"], [$2], [$3])
-rm -f conftest.err[]m4_ifval([$1], [ conftest.$ac_ext])[]dnl
+rm -f conftest.err conftest.i[]m4_ifval([$1], [ conftest.$ac_ext])[]dnl
diff --git a/tests/ b/tests/
index b26d810..1d40820 100644
--- a/tests/
+++ b/tests/
@@ -295,7 +295,7 @@ AT_DATA([],
-                 [test -f conftest.err || AS_EXIT([1])],
+                 [{ test -f conftest.err && grep ok conftest.i; } || 
 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([#define 12 34 /*], [])],

reply via email to

[Prev in Thread] Current Thread [Next in Thread]