3 # Check that the various config.sh-clones have (at least) all the
4 # same symbols as the top-level config_h.SH so that the (potentially)
5 # needed symbols are not lagging after how Configure thinks the world
8 # VMS is probably not handled properly here, due to their own
9 # rather elaborate DCL scripting.
18 my $err = shift and select STDERR;
19 print "usage: $0 [--list] [--regen]\n";
27 "help|?" => sub { usage (0); },
32 require 'regen/regen_lib.pl' if $opt_r;
34 my $MASTER_CFG = "config_h.SH";
35 # Inclusive bounds on the main part of the file, $section == 1 below:
36 my $first = qr/^Author=/;
40 # we check from MANIFEST whether they are expected to be present.
41 # We can't base our check on $], because that's the version of the
42 # perl that we are running, not the version of the source tree.
43 "Cross/config.sh-arm-linux",
49 "plan9/config_sh.sample",
52 "win32/config.gc64nox",
63 open my $fh, '<', $MASTER_CFG;
65 while (/[^\\]\$([a-z]\w+)/g) {
67 next if $v =~ /^(CONFIG_H|CONFIG_SH)$/;
72 @MASTER_CFG = sort keys %seen;
78 open my $fh, '<', 'MANIFEST';
80 $MANIFEST{$1}++ if /^(.+?)\t/;
85 for my $cfg (sort @CFG) {
86 unless (exists $MANIFEST{$cfg}) {
87 print STDERR "[skipping not-expected '$cfg']\n";
94 open my $fh, '<', $cfg;
96 if ($cfg eq 'configure.com') {
97 ++$cfg{startperl}; # Cheat.
100 next if /^\#/ || /^\s*$/ || /^\:/;
101 s/(\s*!.*|\s*)$//; # remove trailing comments or whitespace
102 ++$cfg{$1} if /^\$\s+WC "(\w+)='(?:.*)'"$/;
107 die "$cfg:$.:section=$section:$_" unless $section == 0;
110 push @{$lines[$section]}, $_;
111 next if /^\#/ || /^\s*$/ || /^\:/;
113 die "$cfg:$.:section=$section:$_" unless $section == 1;
118 # (optionally with a trailing comment)
119 if (/^(\w+)=(?:'.*'|[^'].*)(?: #.*)?$/) {
129 if ($cfg ne 'configure.com') {
130 if (join("", @{$lines[1]}) ne join("", sort @{$lines[1]})) {
133 @{$lines[1]} = sort @{$lines[1]};
138 print "$cfg: unsorted\n";
142 for my $v (@MASTER_CFG) {
143 exists $cfg{$v} and next;
145 # print the name once, for the first problem we encounter.
146 print "$cfg\n" unless $problems++;
149 print "$cfg: missing '$v'\n";
152 if ($problems && $opt_r) {
153 my $fh = open_new($cfg);
154 print $fh @{$_} foreach @lines;
155 close_and_rename($fh);