#!/usr/bin/perl use strict; use warnings; use File::Basename; use FindBin; my $p5_metaconfig_base = "$FindBin::Bin/../"; my @std_units = glob ("$p5_metaconfig_base/U/*.U"); my $PWD = "$p5_metaconfig_base/perl"; -d "U" and chdir "U"; my @perl_units = glob ("$PWD/U/*/*.U"); push (@perl_units, @std_units); # Get the list of config.sh symbols. Be sure this is up to date! # (I run the U/mksample script first to be sure.) open my $wanted, "< $PWD/Porting/config.sh" or die "$0: open $PWD/Wanted: $!\n"; my @WANTED = map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [ $_, lc $_ ] } <$wanted>; close $wanted; print <<'EOM'; !!!!!!! DO NOT EDIT THIS FILE !!!!!!! This file is built by metaconfig. This file contains a description of all the shell variables whose value is determined by the Configure script. Variables intended for use in C programs (e.g. I_UNISTD) are already described in config_h.SH. [`configpm' generates pod documentation for Config.pm from this file--please try to keep the formatting regular.] EOM my ($Loc, %expl, %file, %predef); foreach my $file (@perl_units) { open my $fh, "< $file" or die "$0: open $file: $!"; my $base = basename ($file); $Loc = $file, next if $base eq "Loc.U" and not defined $Loc; my @var; while (<$fh>) { if (m/^\?S:\w+[ \t:]/ .. m/^\?S:\.$/) { s/[ \t]+$//; if (m/^\?S:.$/) { my ($var) = ((shift @var) =~ /^(\w+)/); unless (exists $expl{$var}) { $expl{$var} = [ @var, "\n" ]; $file{$var} = $base; } @var = (); } else { s/^\?S://; # Remove leading ?S: markers. s/^\s+(?=.)/\t/; # Ensure all lines begin with tabs. push @var, $_; } } } close $fh or die "$0: close $file: $!"; } defined $Loc or die "$0: Couldn't locate Loc.U: $!"; open my $fh, "< $Loc" or die "$0: open $Loc: $!"; while (<$fh>) { m/^\?(\w+):\1$/ and ($expl{$1}, $file{$1}) = (1, "Loc.U"); } close $fh or die "$0: close $Loc: $!"; { local $/ = "\n\n"; for () { m/^(\w+)/; $predef{$1} = $_; } } for (@WANTED) { chomp; m/^#/ and next; # Skip comments m/^:/ and next; # Skip comments m/^$/ and next; # Skip empty sections my ($var, $val) = split /=/, $_, 2; if (exists $expl{$var}) { if ($file{$var} eq "Loc.U") { print "$var (Loc.U):\n"; if ($val eq "''") { # If we didn't have d_portable, this info might be # useful, but it still won't help with non-standard # stuff if perl is built on one system but installed # on others (this is common with Linux distributions, # for example). print <