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] [--default=value]\n";
28 "help|?" => sub { usage (0); },
31 "default=s" => \$default,
34 require 'regen/regen_lib.pl' if $opt_r;
36 my $MASTER_CFG = "config_h.SH";
37 # Inclusive bounds on the main part of the file, $section == 1 below:
38 my $first = qr/^Author=/;
42 # we check from MANIFEST whether they are expected to be present.
43 # We can't base our check on $], because that's the version of the
44 # perl that we are running, not the version of the source tree.
45 "Cross/config.sh-arm-linux",
51 "plan9/config_sh.sample",
54 "win32/config.gc64nox",
65 open my $fh, '<', $MASTER_CFG;
67 while (/[^\\]\$([a-z]\w+)/g) {
69 next if $v =~ /^(CONFIG_H|CONFIG_SH)$/;
74 @MASTER_CFG = sort keys %seen;
80 open my $fh, '<', 'MANIFEST';
82 $MANIFEST{$1}++ if /^(.+?)\t/;
87 for my $cfg (sort @CFG) {
88 unless (exists $MANIFEST{$cfg}) {
89 print STDERR "[skipping not-expected '$cfg']\n";
96 open my $fh, '<', $cfg;
98 if ($cfg eq 'configure.com') {
99 ++$cfg{startperl}; # Cheat.
102 next if /^\#/ || /^\s*$/ || /^\:/;
103 s/(\s*!.*|\s*)$//; # remove trailing comments or whitespace
104 ++$cfg{$1} if /^\$\s+WC "(\w+)='(?:.*)'"$/;
109 die "$cfg:$.:section=$section:$_" unless $section == 0;
112 push @{$lines[$section]}, $_;
113 next if /^\#/ || /^\s*$/ || /^\:/;
115 die "$cfg:$.:section=$section:$_" unless $section == 1;
120 # (optionally with a trailing comment)
121 if (/^(\w+)=(?:'.*'|[^'].*)(?: #.*)?$/) {
131 if ($cfg ne 'configure.com') {
132 if (join("", @{$lines[1]}) ne join("", sort @{$lines[1]})) {
135 @{$lines[1]} = sort @{$lines[1]};
140 print "$cfg: unsorted\n";
144 for my $v (@MASTER_CFG) {
145 exists $cfg{$v} and next;
146 if (defined $default && $cfg ne 'configure.com') {
147 push @{$lines[1]}, "$v='$default'\n";
150 # print the name once, for the first problem we encounter.
151 print "$cfg\n" unless $problems++;
154 print "$cfg: missing '$v'\n";
157 if ($problems && $opt_r) {
158 @{$lines[1]} = sort @{$lines[1]};
159 my $fh = open_new($cfg);
160 print $fh @{$_} foreach @lines;
161 close_and_rename($fh);