230 |
use Autom4te::XFile; |
use Autom4te::XFile; |
231 |
use strict; |
use strict; |
232 |
|
|
233 |
# Configuration file. |
# Data directory. |
234 |
my $datadir = $ENV{'AC_MACRODIR'} || '@datadir@'; |
my $datadir = $ENV{'AC_MACRODIR'} || '@datadir@'; |
|
my $autom4te_cfg = $ENV{'AUTOM4TE_CFG'} || "$datadir/autom4te.cfg"; |
|
235 |
|
|
236 |
# $LANGUAGE{LANGUAGE} -- Automatic options for LANGUAGE. |
# $LANGUAGE{LANGUAGE} -- Automatic options for LANGUAGE. |
237 |
my %language; |
my %language; |
246 |
|
|
247 |
# Names of the cache directory, cache directory index, trace cache |
# Names of the cache directory, cache directory index, trace cache |
248 |
# prefix, and output cache prefix. |
# prefix, and output cache prefix. |
249 |
my $cache = "autom4te.cache"; |
my $cache; |
250 |
my $icache = "$cache/requests"; |
my $icache; |
251 |
my $tcache = "$cache/traces."; |
my $tcache; |
252 |
my $ocache = "$cache/output."; |
my $ocache; |
253 |
|
|
254 |
# The macros to trace mapped to their format, as specified by the |
# The macros to trace mapped to their format, as specified by the |
255 |
# user. |
# user. |
367 |
-f, --force don\'t rely on cached values |
-f, --force don\'t rely on cached values |
368 |
-W, --warnings=CATEGORY report the warnings falling in CATEGORY |
-W, --warnings=CATEGORY report the warnings falling in CATEGORY |
369 |
-l, --language=LANG specify the set of M4 macros to use |
-l, --language=LANG specify the set of M4 macros to use |
370 |
|
-C, --cache=[DIRECTORY] preserve results for future runs in DIRECTORY |
371 |
-m, --mode=OCTAL change the non trace output file mode (0666) |
-m, --mode=OCTAL change the non trace output file mode (0666) |
372 |
-M, --melt don\'t use M4 frozen files |
-M, --melt don\'t use M4 frozen files |
373 |
|
|
443 |
} |
} |
444 |
|
|
445 |
|
|
446 |
# load_configuration () |
# load_configuration ($FILE) |
447 |
# --------------------- |
# -------------------------- |
448 |
# Load the configuration file. |
# Load the configuration $FILE. |
449 |
sub load_configuration () |
sub load_configuration ($) |
450 |
{ |
{ |
451 |
|
my ($file) = @_; |
452 |
use Text::ParseWords; |
use Text::ParseWords; |
453 |
|
|
454 |
my $cfg = new Autom4te::XFile ($autom4te_cfg); |
my $cfg = new Autom4te::XFile ($file); |
455 |
my $lang; |
my $lang; |
456 |
while ($_ = $cfg->getline) |
while ($_ = $cfg->getline) |
457 |
{ |
{ |
468 |
} |
} |
469 |
elsif ($type eq 'end-language:') |
elsif ($type eq 'end-language:') |
470 |
{ |
{ |
471 |
error "$autom4te_cfg:$.: end-language mismatch: $lang" |
error "$file:$.: end-language mismatch: $lang" |
472 |
if $lang ne lc $words[0]; |
if $lang ne lc $words[0]; |
473 |
} |
} |
474 |
elsif ($type eq 'args:') |
elsif ($type eq 'args:') |
477 |
} |
} |
478 |
else |
else |
479 |
{ |
{ |
480 |
error "$autom4te_cfg:$.: unknown directive: $type"; |
error "$file:$.: unknown directive: $type"; |
481 |
} |
} |
482 |
} |
} |
483 |
} |
} |
508 |
} |
} |
509 |
} while @language; |
} while @language; |
510 |
|
|
511 |
|
# --debug is useless: it is parsed below. |
512 |
|
if (exists $ENV{'AUTOM4TE_DEBUG'}) |
513 |
|
{ |
514 |
|
print STDERR "$me: concrete arguments:\n"; |
515 |
|
foreach my $arg (@ARGV) |
516 |
|
{ |
517 |
|
print STDERR "| $arg\n"; |
518 |
|
} |
519 |
|
} |
520 |
|
|
521 |
# Process the arguments for real this time. |
# Process the arguments for real this time. |
522 |
my @trace; |
my @trace; |
523 |
my @prepend_include; |
my @prepend_include; |
531 |
|
|
532 |
# Library directories: |
# Library directories: |
533 |
"B|prepend-include=s" => \@prepend_include, |
"B|prepend-include=s" => \@prepend_include, |
534 |
"I|include=s" => \@include, |
"I|include=s" => \@include, |
535 |
|
|
536 |
# Tracing: |
# Tracing: |
537 |
# Using a hash for traces is seducing. Unfortunately, upon `-t FOO', |
# Using a hash for traces is seducing. Unfortunately, upon `-t FOO', |
542 |
"p|preselect=s" => \@preselect, |
"p|preselect=s" => \@preselect, |
543 |
|
|
544 |
# Freezing. |
# Freezing. |
545 |
"F|freeze" => \$freeze, |
"F|freeze" => \$freeze, |
546 |
|
|
547 |
|
# Caching. |
548 |
|
"C|cache=s" => \$cache, |
549 |
); |
); |
550 |
|
|
551 |
error "too few arguments |
error "too few arguments |
562 |
$melt = 1 |
$melt = 1 |
563 |
if $freeze; |
if $freeze; |
564 |
|
|
565 |
|
# Names of the cache directory, cache directory index, trace cache |
566 |
|
# prefix, and output cache prefix. If the cache is not to be |
567 |
|
# preserved, default to a temporary directory (automatically removed |
568 |
|
# on exit). |
569 |
|
$cache = $tmp |
570 |
|
unless $cache; |
571 |
|
$icache = "$cache/requests"; |
572 |
|
$tcache = "$cache/traces."; |
573 |
|
$ocache = "$cache/output."; |
574 |
|
|
575 |
# Normalize the includes: the first occurrence is enough, several is |
# Normalize the includes: the first occurrence is enough, several is |
576 |
# a pain since it introduces a useless difference in the path which |
# a pain since it introduces a useless difference in the path which |
577 |
# invalidates the cache. And strip `.' which is implicit and always |
# invalidates the cache. And strip `.' which is implicit and always |
1134 |
## Main program. ## |
## Main program. ## |
1135 |
## -------------- ## |
## -------------- ## |
1136 |
|
|
1137 |
mktmpdir ('t4'); |
mktmpdir ('am4t'); |
1138 |
load_configuration; |
load_configuration ($ENV{'AUTOM4TE_CFG'} || "$datadir/autom4te.cfg"); |
1139 |
|
load_configuration ("$ENV{'HOME'}/.autom4te.cfg") |
1140 |
|
if -f "$ENV{'HOME'}/.autom4te.cfg"; |
1141 |
|
load_configuration (".autom4te.cfg") |
1142 |
|
if -f ".autom4te.cfg"; |
1143 |
parse_args; |
parse_args; |
1144 |
|
|
1145 |
# Freezing does not involve the cache. |
# Freezing does not involve the cache. |