X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=build-aux%2Fbuild_info.pl;fp=build-aux%2Fbuild_info.pl;h=a006b6da0173132028d3f024fe41d9441d6c81a7;hp=0000000000000000000000000000000000000000;hb=c794a7e82668a68b39461d267649d8b94cfe6fae;hpb=2456d9bc547aacc8ad387f441e81455cd9301fe7 diff --git a/build-aux/build_info.pl b/build-aux/build_info.pl new file mode 100755 index 00000000..a006b6da --- /dev/null +++ b/build-aux/build_info.pl @@ -0,0 +1,107 @@ +#!/usr/bin/perl + +# Generate build_info.c. + +# Copyright (C) 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; +use warnings; + +use FindBin qw($Bin); +use File::Spec (); + +my $file = shift @ARGV; + +{ + my $data = parse_config(); + output_code($data); +} + +sub parse_config +{ + my (%block, @defines, %feature); + + open(my $fh, '<', $file) or die "Cannot open $file: $!"; + my $cfg = do { local $/; <$fh> }; + close($fh); + + while ($cfg =~ /^\ *? (\w+) (?:\s+?)? (\w+?)? \s*$/gmx) { + $feature{$1} = $2 || '_MISSING'; + push @defines, $1; + } + while ($cfg =~ /^(\ *? \#\w+? \s+? (\w+) .+ \#\w+)/gmsx) { + $block{$2} = $1; + } + + my %data = ( + block => \%block, + defines => \@defines, + feature => \%feature, + ); + + return \%data; +} + +sub output_code +{ + my ($block, $defines, $feature) = + map $_[0]->{$_}, qw(block defines feature); + + print do { local $/; }, "\n"; + print <{$define}) { + push @output, <{$define}", +#else + "-$feature->{$define}", +#endif +EOC + } + else { + push @output, <{$define} +EOC + } + } + print join "\n", @output; + print <