* bin/autom4te.in ($force): New.

(&parse_args, &print_usage): -f, --force is a new option.
(&handle_output): CPP directives might have spaces after `#'.
(&parse_args): The first file only can be frozen.
This commit is contained in:
Akim Demaille 2001-08-04 13:16:15 +00:00
parent 4ffd4212d6
commit 337c1e9594
3 changed files with 49 additions and 32 deletions

View File

@ -1,3 +1,10 @@
2001-08-04 Akim Demaille <akim@epita.fr>
* bin/autom4te.in ($force): New.
(&parse_args, &print_usage): -f, --force is a new option.
(&handle_output): CPP directives might have spaces after `#'.
(&parse_args): The first file only can be frozen.
2001-08-04 Akim Demaille <akim@epita.fr>
Don't let autom4te compute the `include' traces several times:

View File

@ -255,6 +255,9 @@ my @include;
# 0 for EXIT_SUCCESS.
my $exit_status = 0;
# If true, don't rely on the cache (but still update it).
my $force = 0;
# $M4.
my $m4 = $ENV{"M4"} || '@M4@';
# Some non-GNU m4's don't reject the --help option, so give them /dev/null.
@ -361,35 +364,36 @@ sub find_file ($)
# Display usage (--help).
sub print_usage ()
{
# Quotes are backslahed to help Emacs' font-lock-mode.
print <<EOF;
Usage: $0 [OPTION] ... [TEMPLATE-FILE]
Usage: $0 [OPTION] ... [FILES]
Generate a configuration script from a TEMPLATE-FILE if given, or
`configure.ac' if present, or else `configure.in'. Output is sent
to the standard output if TEMPLATE-FILE is given, else into
`configure'.
Run GNU M4 on the FILES, avoiding useless runs. If tracing, the output
consists of the traces only, otherwise output the expansion of the FILES.
The first of the FILES may be an M4 frozen file, but then must end in \`.m4f\'.
Operation modes:
-h, --help print this help, then exit
-V, --version print version number, then exit
-v, --verbose verbosely report processing
-d, --debug don't remove temporary files
-o, --output=FILE save output in FILE (stdout is the default)
-d, --debug don\'t remove temporary files
-o, --output=FILE save output in FILE (defaults to \`-\', stdout)
-f, --force don\'t rely on cached values
-W, --warnings=CATEGORY report the warnings falling in CATEGORY
Warning categories include:
`cross' cross compilation issues
`obsolete' obsolete constructs
`syntax' dubious syntactic constructs
`all' all the warnings
`no-CATEGORY' turn off the warnings on CATEGORY
`none' turn off all the warnings
`error' warnings are error
\`cross\' cross compilation issues
\`obsolete\' obsolete constructs
\`syntax\' dubious syntactic constructs
\`all\' all the warnings
\`no-CATEGORY\' turn off the warnings on CATEGORY
\`none\' turn off all the warnings
\`error\' warnings are error
The environment variable `WARNINGS' is honored.
The environment variable \`WARNINGS\' is honored.
Library directories:
-I, --include=DIR look in DIR. Several invocations accumulate
-I, --include=DIR look for FILES in DIR. Several invocations accumulate
Tracing:
-t, --trace=MACRO report the MACRO invocations
@ -397,7 +401,6 @@ Tracing:
Report bugs to <bug-autoconf\@gnu.org>.
EOF
# Help font-lock-mode find a closing back quote: `
exit 0;
}
@ -436,6 +439,7 @@ sub parse_args ()
"v|verbose" => \$verbose,
"d|debug" => \$debug,
"o|output=s" => \$output,
"f|force" => \$force,
"W|warnings=s" => \@warning,
# Library directories:
@ -471,6 +475,11 @@ Try `$me --help' for more information.\n"
map { $m4_builtin_alternate_name{$_} }
grep { exists $m4_builtin_alternate_name{$_} } @preselect);
# Only the first file can be frozen, but M4 doesn't complain if this
# constraint is not honored.
die "$me: the first file only can be frozen\n"
if grep { /\.m4f/ } @ARGV[1 .. $#ARGV];
# We don't want to depend upon m4's --include to find the top level
# files. Try to get a canonical name, as it's part of the key for caching.
for (my $i = 0; $i < $#ARGV; ++$i)
@ -487,8 +496,6 @@ sub handle_m4 ($@)
{
my ($req, @macro) = @_;
# Find the files. We don't want to depend upon m4's --include.
# *.m4f files have to be reloaded.
my $files;
foreach (@ARGV)
{
@ -588,7 +595,7 @@ sub handle_output ($)
# Don't complain in comments. Well, until we have something
# better, don't consider `#include' etc. are comments.
s/\#.*//
unless /^\#(if|include|endif|ifdef|ifndef|define)\b/;
unless /^\#\s*(if|include|endif|ifdef|ifndef|define)\b/;
foreach (split (/\W+/))
{
$prohibited{$_} = $oline
@ -937,14 +944,15 @@ if ($verbose)
print STDERR $req->marshall;
}
# We need to run M4 if (i) $REQ is invalid, or (ii) we are expanding
# (i.e., not tracing) and the output is older than the cache file
# (since the later is valid if it's older than the dependencies).
# STDOUT is pretty old.
# We need to run M4 if (i) the users wants it (--force), (ii) $REQ is
# invalid, or (iii) we are expanding (i.e., not tracing) and the
# output is older than the cache file (since the later is valid if
# it's older than the dependencies). STDOUT is pretty old.
my $output_mtime = mtime ($output);
handle_m4 ($req, keys %{$req->macro})
if (! $req->valid
if ($force
|| ! $req->valid
|| (! %trace && $output_mtime < mtime ("$me.cache/" . $req->cache)));

View File

@ -4,12 +4,11 @@
autom4te \- Generate files and scripts thanks to M4
.SH SYNOPSIS
.B autom4te
[\fIOPTION\fR] ... [\fITEMPLATE-FILE\fR]
[\fIOPTION\fR] ... [\fIFILES\fR]
.SH DESCRIPTION
Generate a configuration script from a TEMPLATE-FILE if given, or
`configure.ac' if present, or else `configure.in'. Output is sent
to the standard output if TEMPLATE-FILE is given, else into
`configure'.
Run GNU M4 on the FILES, avoiding useless runs. If tracing, the output
consists of the traces only, otherwise output the expansion of the FILES.
The first of the FILES may be an M4 frozen file, but then must end in `.m4f'.
.SS "Operation modes:"
.TP
\fB\-h\fR, \fB\-\-help\fR
@ -25,7 +24,10 @@ verbosely report processing
don't remove temporary files
.TP
\fB\-o\fR, \fB\-\-output\fR=\fIFILE\fR
save output in FILE (stdout is the default)
save output in FILE (defaults to `-', stdout)
.TP
\fB\-f\fR, \fB\-\-force\fR
don't rely on cached values
.TP
\fB\-W\fR, \fB\-\-warnings\fR=\fICATEGORY\fR
report the warnings falling in CATEGORY
@ -56,7 +58,7 @@ The environment variable `WARNINGS' is honored.
.SS "Library directories:"
.TP
\fB\-I\fR, \fB\-\-include\fR=\fIDIR\fR
look in DIR. Several invocations accumulate
look for FILES in DIR. Several invocations accumulate
.SS "Tracing:"
.TP
\fB\-t\fR, \fB\-\-trace\fR=\fIMACRO\fR