236 |
|
|
237 |
package Autom4te; |
package Autom4te; |
238 |
|
|
239 |
|
use Autom4te::ChannelDefs; |
240 |
|
use Autom4te::Channels; |
241 |
use Autom4te::FileUtils; |
use Autom4te::FileUtils; |
242 |
use Autom4te::General; |
use Autom4te::General; |
243 |
use File::Basename; |
use File::Basename; |
275 |
# `m4_pattern_allow' to check the output. |
# `m4_pattern_allow' to check the output. |
276 |
# |
# |
277 |
# FIXME: What about `sinclude'? |
# FIXME: What about `sinclude'? |
278 |
my @preselect = ('include', 'm4_pattern_allow', 'm4_pattern_forbid'); |
my @preselect = ('include', |
279 |
|
'm4_pattern_allow', 'm4_pattern_forbid', |
280 |
# List of warnings. |
'm4_warn'); |
|
my @warning; |
|
281 |
|
|
282 |
# M4 include path. |
# M4 include path. |
283 |
my @include; |
my @include; |
284 |
|
|
|
# 0 for EXIT_SUCCESS. |
|
|
my $exit_status = 0; |
|
|
|
|
285 |
# Do we freeze? |
# Do we freeze? |
286 |
my $freeze = 0; |
my $freeze = 0; |
287 |
|
|
354 |
|
|
355 |
# $HELP |
# $HELP |
356 |
# ----- |
# ----- |
357 |
$help = << "EOF"; |
$help = "Usage: $0 [OPTION] ... [FILES] |
|
Usage: $0 [OPTION] ... [FILES] |
|
358 |
|
|
359 |
Run GNU M4 on the FILES, avoiding useless runs. Output the traces if tracing, |
Run GNU M4 on the FILES, avoiding useless runs. Output the traces if tracing, |
360 |
the frozen file if freezing, otherwise the expansion of the FILES. |
the frozen file if freezing, otherwise the expansion of the FILES. |
388 |
\`M4sh\' create M4sh shell scripts |
\`M4sh\' create M4sh shell scripts |
389 |
\`M4sugar\' create M4sugar output |
\`M4sugar\' create M4sugar output |
390 |
|
|
391 |
Warning categories include: |
" . Autom4te::ChannelDefs::usage . " |
|
\`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 |
|
392 |
|
|
393 |
The environment variable \`WARNINGS\' is honored. |
The environment variable \`WARNINGS\' is honored. |
394 |
|
|
404 |
-F, --freeze produce an M4 frozen state file for FILES |
-F, --freeze produce an M4 frozen state file for FILES |
405 |
|
|
406 |
Report bugs to <bug-autoconf\@gnu.org>. |
Report bugs to <bug-autoconf\@gnu.org>. |
407 |
EOF |
"; |
408 |
|
|
409 |
# $VERSION |
# $VERSION |
410 |
# -------- |
# -------- |
530 |
# Process the arguments for real this time. |
# Process the arguments for real this time. |
531 |
my @trace; |
my @trace; |
532 |
my @prepend_include; |
my @prepend_include; |
533 |
|
parse_WARNINGS; |
534 |
getopt |
getopt |
535 |
( |
( |
536 |
# Operation modes: |
# Operation modes: |
537 |
"o|output=s" => \$output, |
"o|output=s" => \$output, |
538 |
"W|warnings=s" => \@warning, |
"W|warnings=s" => \&parse_warnings, |
539 |
"m|mode=s" => \$mode, |
"m|mode=s" => \$mode, |
540 |
"M|melt" => \$melt, |
"M|melt" => \$melt, |
541 |
|
|
647 |
{ |
{ |
648 |
my ($req, @macro) = @_; |
my ($req, @macro) = @_; |
649 |
|
|
|
# The warnings are the concatenation of 1. application's defaults, |
|
|
# 2. $WARNINGS, $3 command line options, in that order. |
|
|
# Set them in the order expected by the M4 macros: the converse. |
|
|
my $m4_warnings = |
|
|
lc join (',', reverse (split (',', ($ENV{'WARNINGS'} || '')), |
|
|
map { split /,/ } @warning)); |
|
|
|
|
650 |
# GNU m4 appends when using --error-output. |
# GNU m4 appends when using --error-output. |
651 |
unlink ($tcache . $req->id . "t"); |
unlink ($tcache . $req->id . "t"); |
652 |
|
|
658 |
# when we are interrupted (that leaves corrupted files). |
# when we are interrupted (that leaves corrupted files). |
659 |
xsystem ("$m4" |
xsystem ("$m4" |
660 |
. join (' --include=', '', @include) |
. join (' --include=', '', @include) |
|
. " --define=m4_warnings=$m4_warnings" |
|
661 |
. ' --debug=aflq' |
. ' --debug=aflq' |
662 |
. (!exists $ENV{'AUTOM4TE_NO_FATAL'} ? ' --fatal-warning' : '') |
. (!exists $ENV{'AUTOM4TE_NO_FATAL'} ? ' --fatal-warning' : '') |
663 |
. " --error-output=$tcache" . $req->id . "t" |
. " --error-output=$tcache" . $req->id . "t" |
788 |
# This is unsatisfying but... |
# This is unsatisfying but... |
789 |
my $prohibited = '\b(' . join ('|', keys %prohibited) . ')\b'; |
my $prohibited = '\b(' . join ('|', keys %prohibited) . ')\b'; |
790 |
my $file = new Autom4te::XFile ($ARGV[$#ARGV]); |
my $file = new Autom4te::XFile ($ARGV[$#ARGV]); |
791 |
$exit_status = 1; |
$exit_code = 1; |
792 |
|
|
793 |
while ($_ = $file->getline) |
while ($_ = $file->getline) |
794 |
{ |
{ |
1190 |
handle_m4 ($req, keys %{$req->macro}) |
handle_m4 ($req, keys %{$req->macro}) |
1191 |
if $force || ! $req->valid; |
if $force || ! $req->valid; |
1192 |
|
|
1193 |
|
# Issue the warnings each time autom4te was run. |
1194 |
|
handle_traces ($req, "$tmp/warnings", |
1195 |
|
('m4_warn' => "\$1::\$f:\$l::\$2\n\n")); |
1196 |
|
for (split (/\n{2,}/, contents ("$tmp/warnings"))) |
1197 |
|
{ |
1198 |
|
my ($cat, $loc, $msg) = split '::'; |
1199 |
|
msg $cat, $loc, "warning: $msg"; |
1200 |
|
} |
1201 |
|
|
1202 |
# Now output... |
# Now output... |
1203 |
if (%trace) |
if (%trace) |
1204 |
{ |
{ |
1217 |
if mtime ($output) < mtime ($ocache . $req->id); |
if mtime ($output) < mtime ($ocache . $req->id); |
1218 |
} |
} |
1219 |
|
|
1220 |
# If all went fine, the cache is valid. |
# If we ran up to here, the cache is valid. |
1221 |
$req->valid (1) |
$req->valid (1); |
|
if $exit_status == 0; |
|
|
|
|
1222 |
Request->save ($icache_file); |
Request->save ($icache_file); |
1223 |
|
|
1224 |
exit $exit_status; |
exit $exit_code; |
1225 |
|
|
1226 |
### Setup "GNU" style for perl-mode and cperl-mode. |
### Setup "GNU" style for perl-mode and cperl-mode. |
1227 |
## Local Variables: |
## Local Variables: |