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";
30 "help|?" => sub { usage (0); },
33 "default=s" => \$default,
37 $default and $default =~ s/^'(.*)'$/$1/; # Will be quoted on generation
39 require './regen/regen_lib.pl' if $opt_r;
41 my $MASTER_CFG = "config_h.SH";
42 # Inclusive bounds on the main part of the file, $section == 1 below:
43 my $first = qr/^Author=/;
47 # we check from MANIFEST whether they are expected to be present.
48 # We can't base our check on $], because that's the version of the
49 # perl that we are running, not the version of the source tree.
50 "Cross/config.sh-arm-linux",
51 "Cross/config.sh-arm-linux-n770",
55 "plan9/config_sh.sample",
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 printf "1..%d\n", 2 * @CFG if $tap;
89 for my $cfg (sort @CFG) {
90 unless (exists $MANIFEST{$cfg}) {
91 print STDERR "[skipping not-expected '$cfg']\n";
98 open my $fh, '<', $cfg;
100 if ($cfg eq 'configure.com') {
101 ++$cfg{startperl}; # Cheat.
104 next if /^\#/ || /^\s*$/ || /^\:/;
105 s/(\s*!.*|\s*)$//; # remove trailing comments or whitespace
106 ++$cfg{$1} if /^\$\s+WC "(\w+)='(?:.*)'"$/;
111 die "$cfg:$.:section=$section:$_" unless $section == 0;
114 push @{$lines[$section]}, $_;
115 next if /^\#/ || /^\s*$/ || /^\:/;
117 die "$cfg:$.:section=$section:$_" unless $section == 1;
122 # (optionally with a trailing comment)
123 if (/^(\w+)=(?:'.*'|[^'].*)(?: #.*)?$/) {
134 if ($cfg eq 'configure.com') {
135 print "ok $test # skip $cfg doesn't need to be sorted\n"
137 } elsif (join("", @{$lines[1]}) eq join("", sort @{$lines[1]})) {
138 print "ok $test - $cfg sorted\n"
141 print "not ok $test - $cfg is not sorted\n";
142 } elsif ($opt_r || $opt_l) {
143 # A reference to an empty array is true, hence this flags the
144 # file for later attention by --regen and --list, even if
145 # nothing is missing. Actual sort and output are done later.
148 print "$cfg: unsorted\n"
151 for my $v (@MASTER_CFG) {
152 # This only creates a reference in $missing if something is missing:
153 push @$missing, $v unless exists $cfg{$v};
159 print "not ok $test - $cfg missing keys @$missing\n";
161 # print the name once, however many problems
163 } elsif ($opt_r && $cfg ne 'configure.com') {
164 if (defined $default) {
165 push @{$lines[1]}, map {"$_='$default'\n"} @$missing;
167 print "$cfg: missing '$_', use --default to add it\n"
171 @{$lines[1]} = sort @{$lines[1]};
172 my $fh = open_new($cfg);
173 print $fh @{$_} foreach @lines;
174 close_and_rename($fh);
176 print "$cfg: missing '$_'\n" foreach @$missing;
179 print "ok $test - $cfg has no missing keys\n";