X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=build%2Fgenconf;h=30e8896c3a58901e5085880ed6628d0e5600665d;hb=09e7fe5641b94148d998a1b620bf694f353cb17b;hp=ac9755f4aaa7b28b2495b82baf111cc3d06a30dc;hpb=c6b2cc1263543e7b84a247c965d21f87c3b8feaf;p=libucw.git diff --git a/build/genconf b/build/genconf index ac9755f4..30e8896c 100755 --- a/build/genconf +++ b/build/genconf @@ -10,12 +10,19 @@ use warnings; open CF, $ARGV[2] or die "Unable to open $ARGV[2]"; my %options = (); my %vars = (); +sub opt { + my ($k,$v) = @_; + $vars{$k} = $v; + $options{$k} = 1 if ($k =~ /^CONFIG_/); +} +foreach my $k (keys %ENV) { + opt($k, $ENV{$k}); +} while () { chomp; if (my ($k,$v) = /^(\w+)=(.*)/) { $v =~ s/\s+$//; - $vars{$k} = $v; - $options{$k} = 1 if ($k =~ /^CONFIG_/); + opt($k, $v); } } close CF; @@ -59,10 +66,13 @@ while () { die "Piped command '$cmd' failed" if $?; print OUT `$1`; } else { - sub repl ($) { + sub repl($); + sub repl($) { my $v = shift @_; exists $vars{$v} or die "Cannot substitute $v: variable not set"; - return $vars{$v}; + my $x = $vars{$v}; + while ($x =~ s/\$\((\w+)\)/repl($1)/ge) { } + return $x; } s/@(\w+)@/repl($1)/ge; print OUT;