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