Commit | Line | Data |
---|---|---|
522c08cc RGS |
1 | #!/usr/bin/perl -w |
2 | ||
3 | # | |
4 | # Check that the various config.sh-clones have (at least) all the | |
5 | # same symbols as the top-level config_h.SH so that the (potentially) | |
6 | # needed symbols are not lagging after how Configure thinks the world | |
7 | # is laid out. | |
8 | # | |
a0e39d89 AT |
9 | # VMS is probably not handled properly here, due to their own |
10 | # rather elaborate DCL scripting. | |
522c08cc RGS |
11 | # |
12 | ||
13 | use strict; | |
14 | ||
15 | my $MASTER_CFG = "config_h.SH"; | |
16 | my %MASTER_CFG; | |
17 | ||
18 | my @CFG = ( | |
19 | # This list contains both 5.8.x and 5.9.x files, | |
20 | # we check from MANIFEST whether they are expected to be present. | |
bb0fc361 NC |
21 | # We can't base our check on $], because that's the version of the |
22 | # perl that we are running, not the version of the source tree. | |
522c08cc RGS |
23 | "Cross/config.sh-arm-linux", |
24 | "epoc/config.sh", | |
25 | "NetWare/config.wc", | |
26 | "symbian/config.sh", | |
27 | "uconfig.sh", | |
28 | "plan9/config_sh.sample", | |
29 | "vos/config.alpha.def", | |
30 | "vos/config.ga.def", | |
31 | "win32/config.bc", | |
32 | "win32/config.gc", | |
33 | "win32/config.vc", | |
6ab0e26e | 34 | "win32/config.vc64", |
26d21fa1 | 35 | "win32/config.ce", |
a0e39d89 | 36 | "configure.com", |
d73cfe96 | 37 | "Porting/config.sh", |
522c08cc RGS |
38 | ); |
39 | ||
40 | sub read_file { | |
41 | my ($fn, $sub) = @_; | |
42 | if (open(my $fh, $fn)) { | |
43 | local $_; | |
44 | while (<$fh>) { | |
45 | &$sub; | |
46 | } | |
47 | } else { | |
48 | die "$0: Failed to open '$fn' for reading: $!\n"; | |
49 | } | |
50 | } | |
51 | ||
52 | sub config_h_SH_reader { | |
53 | my $cfg = shift; | |
54 | return sub { | |
2eacba2f | 55 | while (/[^\\]\$([a-z]\w+)/g) { |
522c08cc RGS |
56 | my $v = $1; |
57 | next if $v =~ /^(CONFIG_H|CONFIG_SH)$/; | |
58 | $cfg->{$v}++; | |
59 | } | |
60 | } | |
61 | } | |
62 | ||
63 | read_file($MASTER_CFG, | |
64 | config_h_SH_reader(\%MASTER_CFG)); | |
65 | ||
66 | my %MANIFEST; | |
67 | ||
68 | read_file("MANIFEST", | |
69 | sub { | |
70 | $MANIFEST{$1}++ if /^(.+?)\t/; | |
71 | }); | |
72 | ||
73 | my @MASTER_CFG = sort keys %MASTER_CFG; | |
74 | ||
75 | sub check_cfg { | |
76 | my ($fn, $cfg) = @_; | |
77 | for my $v (@MASTER_CFG) { | |
78 | print "$fn: missing '$v'\n" unless exists $cfg->{$v}; | |
79 | } | |
80 | } | |
81 | ||
82 | for my $cfg (@CFG) { | |
83 | unless (exists $MANIFEST{$cfg}) { | |
a76803d0 | 84 | print STDERR "[skipping not-expected '$cfg']\n"; |
522c08cc RGS |
85 | next; |
86 | } | |
87 | my %cfg; | |
88 | read_file($cfg, | |
89 | sub { | |
d2aeed16 | 90 | return if /^\#/ || /^\s*$/ || /^\:/; |
0ae3ae8f | 91 | if ($cfg eq 'configure.com') { |
c526aa63 | 92 | s/(\s*!.*|\s*)$//; # remove trailing comments or whitespace |
0ae3ae8f CB |
93 | return if ! /^\$\s+WC "(\w+)='(.*)'"$/; |
94 | } | |
522c08cc RGS |
95 | # foo='bar' |
96 | # foo=bar | |
97 | # $foo='bar' # VOS 5.8.x specialty | |
98 | # $foo=bar # VOS 5.8.x specialty | |
99 | if (/^\$?(\w+)='(.*)'$/) { | |
100 | $cfg{$1}++; | |
101 | } | |
102 | elsif (/^\$?(\w+)=(.*)$/) { | |
103 | $cfg{$1}++; | |
a0e39d89 | 104 | } |
b89d399a | 105 | elsif (/^\$\s+WC "(\w+)='(.*)'"$/) { |
a0e39d89 | 106 | $cfg{$1}++; |
522c08cc RGS |
107 | } else { |
108 | warn "$cfg:$.:$_"; | |
109 | } | |
110 | }); | |
fe817649 JH |
111 | if ($cfg eq 'configure.com') { |
112 | $cfg{startperl}++; # Cheat. | |
113 | } | |
522c08cc RGS |
114 | check_cfg($cfg, \%cfg); |
115 | } |