From 77350bd98ce38adde4fe3f80cd73f07fd414db58 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Sat, 25 Jul 2009 06:00:38 -0600 Subject: [PATCH] Let autoheader see through m4 macros in AC_DEFINE. * lib/autoconf/general.m4 (AC_DEFINE_TRACE): Expand macro before tracing its name. * lib/autoconf/autoheader.m4 (AH_VERBATIM, AH_TEMPLATE): Likewise, for using the macro in a template file. * tests/tools.at (autoheader and macros): New test. * NEWS: Mention this. Reported by Bruno Haible. Signed-off-by: Eric Blake --- ChangeLog | 9 +++++++++ NEWS | 3 +++ lib/autoconf/autoheader.m4 | 4 ++-- lib/autoconf/general.m4 | 2 +- tests/tools.at | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b990803..5daef4db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2009-07-25 Eric Blake + Let autoheader see through m4 macros in AC_DEFINE. + * lib/autoconf/general.m4 (AC_DEFINE_TRACE): Expand macro before + tracing its name. + * lib/autoconf/autoheader.m4 (AH_VERBATIM, AH_TEMPLATE): Likewise, + for using the macro in a template file. + * tests/tools.at (autoheader and macros): New test. + * NEWS: Mention this. + Reported by Bruno Haible. + Improve NEWS wording. * NEWS: Use more accurate statement. Suggestedy by Ralf Wildenhues. diff --git a/NEWS b/NEWS index d3662cd0..3830fc0b 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,9 @@ GNU Autoconf NEWS - User visible changes. ** The following documented autoconf macros are new: AC_ERLANG_SUBST_ERTS_VER +** The autoheader tool now understands m4 macro arguments passed to + AC_DEFINE and AC_DEFINE_UNQUOTED. + ** Ensure AT_CHECK can support commands that include a # given with proper m4 quoting. For shell comments, this is a new feature; for non-shell comments, this fixes a regression introduced in 2.63b. diff --git a/lib/autoconf/autoheader.m4 b/lib/autoconf/autoheader.m4 index 8e109cca..99723f23 100644 --- a/lib/autoconf/autoheader.m4 +++ b/lib/autoconf/autoheader.m4 @@ -68,7 +68,7 @@ m4_define([AH_OUTPUT], []) # Quote for Perl '' strings, which are those used by Autoheader. m4_define([AH_VERBATIM], [AS_LITERAL_IF([$1], - [AH_OUTPUT([$1], AS_ESCAPE([[$2]], [\']))])]) + [AH_OUTPUT(_m4_expand([$1]), AS_ESCAPE([[$2]], [\']))])]) # AH_TEMPLATE(KEY, DESCRIPTION) @@ -78,7 +78,7 @@ m4_define([AH_VERBATIM], m4_define([AH_TEMPLATE], [AH_VERBATIM([$1], m4_text_wrap([$2 */], [ ], [/* ])[ -#undef $1])]) +@%:@undef ]_m4_expand([$1]))]) # AH_TOP(TEXT) diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index e3b69d02..f030c26b 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -2075,7 +2075,7 @@ AS_IDENTIFIER_IF([$1], [], # This macro is a wrapper around AC_DEFINE_TRACE_LITERAL which filters # out non literal symbols. CPP-SYMBOL must not include any parameters. m4_define([AC_DEFINE_TRACE], -[AS_LITERAL_IF([$1], [AC_DEFINE_TRACE_LITERAL([$1])])]) +[AS_LITERAL_IF([$1], [AC_DEFINE_TRACE_LITERAL(_m4_expand([$1]))])]) # AC_DEFINE(VARIABLE, [VALUE], [DESCRIPTION]) diff --git a/tests/tools.at b/tests/tools.at index 529eb93d..e54ed699 100644 --- a/tests/tools.at +++ b/tests/tools.at @@ -717,6 +717,42 @@ The Dog in a h@t. AT_CLEANUP +# autoheader should see through m4 macros, just like autoconf +# http://lists.gnu.org/archive/html/bug-autoconf/2009-06/msg00000.html +AT_SETUP([autoheader and macros]) + +AT_DATA([configure.ac], +[[AC_INIT +AC_CONFIG_HEADER([config.h]) +m4_define([PETER], [SIMSALABIM]) +m4_define([PAUL], [OPENSESAME]) +AC_DEFINE([PETER], [10], [Peter's public info]) +AC_DEFINE_UNQUOTED([PAUL], [`expr 4 + 6`], [Paul's public info]) +AC_OUTPUT +]]) + +AT_CHECK_AUTOCONF +AT_CHECK_AUTOHEADER +AT_CHECK([grep -c SIMSALABIM configure config.h.in], [0], +[[configure:1 +config.h.in:1 +]]) +AT_CHECK([grep -c OPENSESAME configure config.h.in], [0], +[[configure:1 +config.h.in:1 +]]) +AT_CHECK([grep -c PETER configure config.h.in], [1], +[[configure:0 +config.h.in:0 +]]) +AT_CHECK([grep -c PAUL configure config.h.in], [1], +[[configure:0 +config.h.in:0 +]]) + +AT_CLEANUP + + ## ------------ ## -- 2.47.2