Hello,
the subject says it all, m4 allows you to define and/or undefine macros,
so if one uses it e.g. in Makefiles, it is easy to alter the output.
However, m4 is a real pain to use, m4sugar is so much better. But
autom4te, the convenient m4sugar "frontend", doesn't accept these
options, which I would like to change. I can elaborate more on use cases
if you are interested, but as this change is minor and
backwards-compatible, I hope that there will not be much resistance in
accepting it :-)
The patch is attached.
There are, however, some things I am not sure about - namely caching and
freezing. I don't have insight into them, but I have suspicion that they
may interfere with the new define/undefine stuff.
diff --git a/bin/autom4te.in b/bin/autom4te.in
index 798013a..e5443e3 100644
--- a/bin/autom4te.in
+++ b/bin/autom4te.in
@@ -83,6 +83,10 @@ my @preselect = ('include',
# M4 include path.
my @include;
+# M4 define/undefine.
+my @define;
+my @undefine;
+
# Do we freeze?
my $freeze = 0;
@@ -176,6 +180,10 @@ Library directories:
-B, --prepend-include=DIR prepend directory DIR to search path
-I, --include=DIR append directory DIR to search path
+m4 arguments:
+ -D, --define=NAME[=VALUE] define NAME as having VALUE, or empty
+ -U, --undefine=NAME undefine NAME
+
Tracing:
-t, --trace=MACRO[:FORMAT] report the MACRO invocations
-p, --preselect=MACRO prepare to trace MACRO in a future run
@@ -345,6 +353,8 @@ sub parse_args ()
# Library directories:
"B|prepend-include=s" => \@prepend_include,
"I|include=s" => \@include,
+ "D|define=s" => \@define,
+ "U|undefine=s" => \@undefine,
# Tracing:
# Using a hash for traces is seducing. Unfortunately, upon '-t FOO',
@@ -465,6 +475,8 @@ sub handle_m4 ($@)
xsystem ("$m4 @M4_GNU@"
. join (' --include=', '', map { shell_quote ($_) } @include)
. ' --debug=aflq'
+ . join (' --define=', '', map { shell_quote ($_) } @define)
+ . join (' --undefine=', '', map { shell_quote ($_) } @undefine)
. (!exists $ENV{'AUTOM4TE_NO_FATAL'} ? ' --fatal-warning' : '')
. " @M4_DEBUGFILE@=" . shell_quote ("$tcache" . $req->id . "t")
. join (' --trace=', '', map { shell_quote ($_) } sort @macro)