This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove wince/ from checkcfgvar.pl, now that it is gone in 5.8.x too.
[perl5.git] / Porting / checkcfgvar.pl
CommitLineData
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
13use strict;
14
15my $MASTER_CFG = "config_h.SH";
16my %MASTER_CFG;
17
18my @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",
522c08cc
RGS
37 );
38
39sub read_file {
40 my ($fn, $sub) = @_;
41 if (open(my $fh, $fn)) {
42 local $_;
43 while (<$fh>) {
44 &$sub;
45 }
46 } else {
47 die "$0: Failed to open '$fn' for reading: $!\n";
48 }
49}
50
51sub config_h_SH_reader {
52 my $cfg = shift;
53 return sub {
2eacba2f 54 while (/[^\\]\$([a-z]\w+)/g) {
522c08cc
RGS
55 my $v = $1;
56 next if $v =~ /^(CONFIG_H|CONFIG_SH)$/;
57 $cfg->{$v}++;
58 }
59 }
60}
61
62read_file($MASTER_CFG,
63 config_h_SH_reader(\%MASTER_CFG));
64
65my %MANIFEST;
66
67read_file("MANIFEST",
68 sub {
69 $MANIFEST{$1}++ if /^(.+?)\t/;
70 });
71
72my @MASTER_CFG = sort keys %MASTER_CFG;
73
74sub check_cfg {
75 my ($fn, $cfg) = @_;
76 for my $v (@MASTER_CFG) {
77 print "$fn: missing '$v'\n" unless exists $cfg->{$v};
78 }
79}
80
81for my $cfg (@CFG) {
82 unless (exists $MANIFEST{$cfg}) {
83 print "[skipping not-expected '$cfg']\n";
84 next;
85 }
86 my %cfg;
87 read_file($cfg,
88 sub {
89 return if /^\#/ || /^\s*$/;
0ae3ae8f 90 if ($cfg eq 'configure.com') {
c526aa63 91 s/(\s*!.*|\s*)$//; # remove trailing comments or whitespace
0ae3ae8f
CB
92 return if ! /^\$\s+WC "(\w+)='(.*)'"$/;
93 }
522c08cc
RGS
94 # foo='bar'
95 # foo=bar
96 # $foo='bar' # VOS 5.8.x specialty
97 # $foo=bar # VOS 5.8.x specialty
98 if (/^\$?(\w+)='(.*)'$/) {
99 $cfg{$1}++;
100 }
101 elsif (/^\$?(\w+)=(.*)$/) {
102 $cfg{$1}++;
a0e39d89 103 }
b89d399a 104 elsif (/^\$\s+WC "(\w+)='(.*)'"$/) {
a0e39d89 105 $cfg{$1}++;
522c08cc
RGS
106 } else {
107 warn "$cfg:$.:$_";
108 }
109 });
fe817649
JH
110 if ($cfg eq 'configure.com') {
111 $cfg{startperl}++; # Cheat.
112 }
522c08cc
RGS
113 check_cfg($cfg, \%cfg);
114}