our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
$VERSION = 1.0;
@ISA = qw(Exporter);
- @EXPORT = qw(&Init &Log &Fail &IsSet &Set &UnSet &Override &Get &Test &Include &Finish &FindFile &TryFindFile);
+ @EXPORT = qw(&Init &Log &Notice &Warn &Fail &IsSet &Set &UnSet &Append &Override &Get &Test &Include &Finish &FindFile &TryFindFile);
@EXPORT_OK = qw();
%EXPORT_TAGS = ();
}
print @_;
}
+sub Notice($) {
+ print @_ if $vars{"VERBOSE"};
+}
+
+sub Warn($) {
+ print "WARNING: ", @_;
+}
+
sub Fail($) {
- Log((shift @_) . "\n");
+ Log("ERROR: " . (shift @_) . "\n");
exit 1;
}
delete $vars{$x} unless $overriden{$x};
}
+sub Append($$) {
+ my ($x,$y) = @_;
+ Set($x, (IsSet($x) ? (Get($x) . " $y") : $y));
+}
+
sub Override($;$) {
my ($x,$y) = @_;
$y=1 unless defined $y;
sub Test($$$) {
my ($var,$msg,$sub) = @_;
- Log "$msg... ";
+ Log "$msg ... ";
if (!IsSet($var)) {
Set $var, &$sub();
}
if ($x =~ /^(\w+)=(.*)/) {
Override($1 => $2);
} elsif ($x =~ /^-(\w+)$/) {
- Override($1 => 1);
+ Override($1 => 0);
delete $vars{$1};
} elsif ($x =~ /^(\w+)$/) {
Override($1 => 1);
} else {
- print STDERR "Invalid option $_\n";
+ print STDERR "Invalid option $x\n";
exit 1;
}
}
sub Include($) {
my ($f) = @_;
$f = FindFile($f);
- Log "Loading configuration $f\n";
+ Notice "Loading configuration $f\n";
require $f;
}
-d "obj/lib" or mkdir("obj/lib", 0777) or Fail "Cannot create obj/lib directory: $!";
Log "done\n";
- Log "Generating autoconf.h... ";
+ Log "Generating autoconf.h ... ";
open X, ">obj/lib/autoconf.h" or Fail $!;
print X "/* Generated automatically by $0, please don't touch manually. */\n";
foreach my $x (sort keys %vars) {
close X;
Log "done\n";
- Log "Generating config.mk... ";
+ Log "Generating config.mk ... ";
open X, ">obj/config.mk" or Fail $!;
print X "# Generated automatically by $0, please don't touch manually.\n";
foreach my $x (sort keys %vars) {