From: Rafael Garcia-Suarez Date: Fri, 23 Sep 2005 13:08:14 +0000 (+0000) Subject: Add Porting/checkcfgvar.pl by Jarkko X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=522c08cc9e4389a24a0837cf43aee02468b29a53;p=p5sagit%2Fp5-mst-13.2.git Add Porting/checkcfgvar.pl by Jarkko p4raw-id: //depot/perl@25579 --- diff --git a/MANIFEST b/MANIFEST index 58e7fb1..36f94d8 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2493,6 +2493,7 @@ Porting/apply Apply patches sent by mail Porting/check83.pl Check whether we are 8.3-friendly Porting/checkAUTHORS.pl Check that the AUTHORS file is complete Porting/checkcase.pl Check whether we are case-insensitive-fs-friendly +Porting/checkcfgvar.pl Check that config scripts define all symbols Porting/checkURL.pl Check whether we have working URLs Porting/checkVERSION.pl Check whether we have $VERSIONs Porting/cmpVERSION.pl Compare whether two trees have changed modules diff --git a/Porting/checkcfgvar.pl b/Porting/checkcfgvar.pl new file mode 100644 index 0000000..adf65a7 --- /dev/null +++ b/Porting/checkcfgvar.pl @@ -0,0 +1,100 @@ +#!/usr/bin/perl -w + +# +# Check that the various config.sh-clones have (at least) all the +# same symbols as the top-level config_h.SH so that the (potentially) +# needed symbols are not lagging after how Configure thinks the world +# is laid out. +# +# VMS is not handled here, due to their own rather elaborate DCL scripting. +# + +use strict; + +my $MASTER_CFG = "config_h.SH"; +my %MASTER_CFG; + +my @CFG = ( + # This list contains both 5.8.x and 5.9.x files, + # we check from MANIFEST whether they are expected to be present. + "Cross/config.sh-arm-linux", + "epoc/config.sh", + "NetWare/config.wc", + "symbian/config.sh", + "uconfig.sh", + "plan9/config_sh.sample", + "vos/config.alpha.def", + "vos/config.ga.def", + "win32/config.bc", + "win32/config.gc", + "win32/config.vc", + "wince/config.ce", + ); + +sub read_file { + my ($fn, $sub) = @_; + if (open(my $fh, $fn)) { + local $_; + while (<$fh>) { + &$sub; + } + } else { + die "$0: Failed to open '$fn' for reading: $!\n"; + } +} + +sub config_h_SH_reader { + my $cfg = shift; + return sub { + return if 1../^echo \"Extracting \$CONFIG_H/; + while (/[^\\]\$(\w+)/g) { + my $v = $1; + next if $v =~ /^(CONFIG_H|CONFIG_SH)$/; + $cfg->{$v}++; + } + } +} + +read_file($MASTER_CFG, + config_h_SH_reader(\%MASTER_CFG)); + +my %MANIFEST; + +read_file("MANIFEST", + sub { + $MANIFEST{$1}++ if /^(.+?)\t/; + }); + +my @MASTER_CFG = sort keys %MASTER_CFG; + +sub check_cfg { + my ($fn, $cfg) = @_; + for my $v (@MASTER_CFG) { + print "$fn: missing '$v'\n" unless exists $cfg->{$v}; + } +} + +for my $cfg (@CFG) { + unless (exists $MANIFEST{$cfg}) { + print "[skipping not-expected '$cfg']\n"; + next; + } + my %cfg; + read_file($cfg, + sub { + return if /^\#/ || /^\s*$/; + # foo='bar' + # foo=bar + # $foo='bar' # VOS 5.8.x specialty + # $foo=bar # VOS 5.8.x specialty + if (/^\$?(\w+)='(.*)'$/) { + $cfg{$1}++; + } + elsif (/^\$?(\w+)=(.*)$/) { + $cfg{$1}++; + } else { + warn "$cfg:$.:$_"; + } + }); + check_cfg($cfg, \%cfg); +}