This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add d_builtin_choose_expr and d_builtin_expect to configure.com as
[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.
21 "Cross/config.sh-arm-linux",
22 "epoc/config.sh",
23 "NetWare/config.wc",
24 "symbian/config.sh",
25 "uconfig.sh",
26 "plan9/config_sh.sample",
27 "vos/config.alpha.def",
28 "vos/config.ga.def",
29 "win32/config.bc",
30 "win32/config.gc",
31 "win32/config.vc",
6ab0e26e 32 "win32/config.vc64",
522c08cc 33 "wince/config.ce",
a0e39d89 34 "configure.com",
522c08cc
RGS
35 );
36
37sub read_file {
38 my ($fn, $sub) = @_;
39 if (open(my $fh, $fn)) {
40 local $_;
41 while (<$fh>) {
42 &$sub;
43 }
44 } else {
45 die "$0: Failed to open '$fn' for reading: $!\n";
46 }
47}
48
49sub config_h_SH_reader {
50 my $cfg = shift;
51 return sub {
52 return if 1../^echo \"Extracting \$CONFIG_H/;
53 while (/[^\\]\$(\w+)/g) {
54 my $v = $1;
55 next if $v =~ /^(CONFIG_H|CONFIG_SH)$/;
56 $cfg->{$v}++;
57 }
58 }
59}
60
61read_file($MASTER_CFG,
62 config_h_SH_reader(\%MASTER_CFG));
63
64my %MANIFEST;
65
66read_file("MANIFEST",
67 sub {
68 $MANIFEST{$1}++ if /^(.+?)\t/;
69 });
70
71my @MASTER_CFG = sort keys %MASTER_CFG;
72
73sub check_cfg {
74 my ($fn, $cfg) = @_;
75 for my $v (@MASTER_CFG) {
76 print "$fn: missing '$v'\n" unless exists $cfg->{$v};
77 }
78}
79
80for my $cfg (@CFG) {
81 unless (exists $MANIFEST{$cfg}) {
82 print "[skipping not-expected '$cfg']\n";
83 next;
84 }
85 my %cfg;
86 read_file($cfg,
87 sub {
88 return if /^\#/ || /^\s*$/;
a0e39d89
AT
89 return if $cfg eq 'configure.com' &&
90 ! /^\$ WC "(\w+)='(.*)'"$/;
522c08cc
RGS
91 # foo='bar'
92 # foo=bar
93 # $foo='bar' # VOS 5.8.x specialty
94 # $foo=bar # VOS 5.8.x specialty
95 if (/^\$?(\w+)='(.*)'$/) {
96 $cfg{$1}++;
97 }
98 elsif (/^\$?(\w+)=(.*)$/) {
99 $cfg{$1}++;
a0e39d89
AT
100 }
101 elsif (/^\$ WC "(\w+)='(.*)'"$/) {
102 $cfg{$1}++;
522c08cc
RGS
103 } else {
104 warn "$cfg:$.:$_";
105 }
106 });
107 check_cfg($cfg, \%cfg);
108}