This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Support for __builtin_expect and __builtin_choose_expr
[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#
9# VMS is not handled here, due to their own rather elaborate DCL scripting.
10#
11
12use strict;
13
14my $MASTER_CFG = "config_h.SH";
15my %MASTER_CFG;
16
17my @CFG = (
18 # This list contains both 5.8.x and 5.9.x files,
19 # we check from MANIFEST whether they are expected to be present.
20 "Cross/config.sh-arm-linux",
21 "epoc/config.sh",
22 "NetWare/config.wc",
23 "symbian/config.sh",
24 "uconfig.sh",
25 "plan9/config_sh.sample",
26 "vos/config.alpha.def",
27 "vos/config.ga.def",
28 "win32/config.bc",
29 "win32/config.gc",
30 "win32/config.vc",
6ab0e26e 31 "win32/config.vc64",
522c08cc
RGS
32 "wince/config.ce",
33 );
34
35sub read_file {
36 my ($fn, $sub) = @_;
37 if (open(my $fh, $fn)) {
38 local $_;
39 while (<$fh>) {
40 &$sub;
41 }
42 } else {
43 die "$0: Failed to open '$fn' for reading: $!\n";
44 }
45}
46
47sub config_h_SH_reader {
48 my $cfg = shift;
49 return sub {
50 return if 1../^echo \"Extracting \$CONFIG_H/;
51 while (/[^\\]\$(\w+)/g) {
52 my $v = $1;
53 next if $v =~ /^(CONFIG_H|CONFIG_SH)$/;
54 $cfg->{$v}++;
55 }
56 }
57}
58
59read_file($MASTER_CFG,
60 config_h_SH_reader(\%MASTER_CFG));
61
62my %MANIFEST;
63
64read_file("MANIFEST",
65 sub {
66 $MANIFEST{$1}++ if /^(.+?)\t/;
67 });
68
69my @MASTER_CFG = sort keys %MASTER_CFG;
70
71sub check_cfg {
72 my ($fn, $cfg) = @_;
73 for my $v (@MASTER_CFG) {
74 print "$fn: missing '$v'\n" unless exists $cfg->{$v};
75 }
76}
77
78for my $cfg (@CFG) {
79 unless (exists $MANIFEST{$cfg}) {
80 print "[skipping not-expected '$cfg']\n";
81 next;
82 }
83 my %cfg;
84 read_file($cfg,
85 sub {
86 return if /^\#/ || /^\s*$/;
87 # foo='bar'
88 # foo=bar
89 # $foo='bar' # VOS 5.8.x specialty
90 # $foo=bar # VOS 5.8.x specialty
91 if (/^\$?(\w+)='(.*)'$/) {
92 $cfg{$1}++;
93 }
94 elsif (/^\$?(\w+)=(.*)$/) {
95 $cfg{$1}++;
96 } else {
97 warn "$cfg:$.:$_";
98 }
99 });
100 check_cfg($cfg, \%cfg);
101}