X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fperl%2FConfigure.pm;h=383639f9ea3fd1ffb61e47208b4b1184852a193a;hb=6c387c164c40f5f24efc45a6d2836e8ab45e3a04;hp=6900dbe3837e52b3bd973281f2dd1704e5b0c5f9;hpb=7d38b11b4908c9052151be2c4e54b8510c212b9f;p=libucw.git diff --git a/lib/perl/Configure.pm b/lib/perl/Configure.pm index 6900dbe3..383639f9 100644 --- a/lib/perl/Configure.pm +++ b/lib/perl/Configure.pm @@ -16,7 +16,7 @@ BEGIN { 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 = (); } @@ -28,8 +28,16 @@ sub Log($) { print @_; } +sub Notice($) { + print @_ if $vars{"VERBOSE"}; +} + +sub Warn($) { + print "WARNING: ", @_; +} + sub Fail($) { - Log((shift @_) . "\n"); + Log("ERROR: " . (shift @_) . "\n"); exit 1; } @@ -54,6 +62,11 @@ sub UnSet($) { 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; @@ -63,7 +76,7 @@ sub Override($;$) { sub Test($$$) { my ($var,$msg,$sub) = @_; - Log "$msg... "; + Log "$msg ... "; if (!IsSet($var)) { Set $var, &$sub(); } @@ -106,12 +119,12 @@ sub Init($$) { 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; } } @@ -125,7 +138,7 @@ sub Init($$) { sub Include($) { my ($f) = @_; $f = FindFile($f); - Log "Loading configuration $f\n"; + Notice "Loading configuration $f\n"; require $f; } @@ -148,7 +161,7 @@ sub Finish() { -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) { @@ -162,7 +175,7 @@ sub Finish() { 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) {