configpm revision 7c478bd95313f5f23a4c958a745db2134aa03244
#!./miniperl -w
# list names to put first (and hence lookup fastest)
);
# names of things which may need to have slashes changed to double-colons
use Exporter ();
# Define our own import method to avoid pulling in the full Exporter:
sub import {
my $pkg = shift;
local $Exporter::ExportLevel = 1;
return if @func == @_;
}
unless \$^V;
# This file was created by configpm when Perl was built. Any changes
# made to this file will be lost the next time perl is built.
@non_v=();
@v_fast=();
@v_others=();
$in_v = 0;
while (<>) {
# Catch CONFIGDOTSH=true and PERL_VERSION=n line from Configure.
s/^(\w+)=(true|\d+)\s*$/$1='$2'\n/;
my ($k,$v) = ($1,$2);
# grandfather PATCHLEVEL and SUBVERSION and CONFIG
if ($k) {
}
}
}
}
# We can delimit things in config.sh with either ' or ".
next;
}
$quote = $2;
if ($in_v) { $val .= $_; }
else { ($name,$val) = ($1,$3); }
$in_v = $val !~ /$quote\n/;
next if $in_v;
if ($extensions{$name}) { s,/,::,g }
if (!$fast{$name}){ push(@v_others, "$name=$quote$val"); next; }
push(@v_fast,"$name=$quote$val");
}
foreach(@non_v){ print CONFIG $_ }
print CONFIG "\n",
join("", @v_fast, sort @v_others),
"!END!\n\n";
# copy config summary format from the myconfig.SH script
open(MYCONFIG,"<myconfig.SH") || die "open myconfig.SH failed: $!";
1 while defined($_ = <MYCONFIG>) && !/^Summary of/;
do { print CONFIG $_ } until !defined($_ = <MYCONFIG>) || /^\s*$/;
close(MYCONFIG);
my $summary_expanded = 0;
sub myconfig {
return $summary if $summary_expanded;
$summary =~ s{\$(\w+)}
$summary_expanded = 1;
$summary;
}
EOT
# ----
sub FETCH {
# check for cached value (which may be undef so we use exists not defined)
return $_[0]->{$_[1]} if (exists $_[0]->{$_[1]});
# Search for it in the big string
my($value, $start, $marker, $quote_type);
$quote_type = "'";
# Virtual entries.
if ($_[1] eq 'byteorder') {
# byteorder does exist on its own but we overlay a virtual
# dynamically recomputed value.
my $t = $Config{ivtype};
my $s = $Config{ivsize};
my $f = $t eq 'long' ? 'L!' : $s == 8 ? 'Q': 'I';
if ($s == 4 || $s == 8) {
my $i = 0;
foreach my $c (reverse(2..$s)) { $i |= ord($c); $i <<= 8 }
$i |= ord(1);
$value = join('', unpack('a'x$s, pack($f, $i)));
} else {
$value = '?'x$s;
}
} elsif ($_[1] =~ /^((?:cc|ld)flags|libs(?:wanted)?)_nolargefiles/) {
# These are purely virtual, they do not exist, but need to
# be computed on demand for largefile-incapable extensions.
my $withlargefiles = $Config{$key};
if ($key =~ /^(?:cc|ld)flags_/) {
$value =~ s/\Q$withlargefiles\E\b//;
} elsif ($key =~ /^libs/) {
my @lflibswanted = split(' ', $Config{libswanted_uselargefiles});
if (@lflibswanted) {
my %lflibswanted;
@lflibswanted{@lflibswanted} = ();
if ($key =~ /^libs_/) {
my @libs = grep { /^-l(.+)/ &&
not exists $lflibswanted{$1} }
split(' ', $Config{libs});
$Config{libs} = join(' ', @libs);
} elsif ($key =~ /^libswanted_/) {
my @libswanted = grep { not exists $lflibswanted{$_} }
split(' ', $Config{libswanted});
$Config{libswanted} = join(' ', @libswanted);
}
}
}
} else {
# return undef unless (($value) = $config_sh =~ m/^$_[1]='(.*)'\s*$/m);
# Check for the common case, ' delimeted
# If that failed, check for " delimited
}
# It's the very first thing we found. Skip $start forward
# and figure out the quote mark after the =.
}
else {
}
$value = substr($config_sh, $start,
}
# If we had a double-quote, we'd better eval it so escape
# sequences and such can be interpolated. Since the incoming
# value is supposed to follow shell rules and not perl rules,
# we escape any perl variable markers
$value =~ s/\$/\\\$/g;
$value =~ s/\@/\\\@/g;
}
#$value = sprintf($value) if $quote_type eq '"';
# So we can say "if $Config{'foo'}".
$_[0]->{$_[1]} = $value; # cache it
return $value;
}
my $prevpos = 0;
sub FIRSTKEY {
$prevpos = 0;
# my($key) = $config_sh =~ m/^(.*?)=/;
# $key;
}
sub NEXTKEY {
# Find out how the current key's quoted so we can skip to its end.
}
sub EXISTS {
# exists($_[0]->{$_[1]}) or $config_sh =~ m/^$_[1]=/m;
}
sub config_sh {
}
sub config_re {
my $re = shift;
}
sub config_vars {
foreach(@_){
print "$_='$v';\n";
}
}
my %preconfig;
}
}
} else {
}
# avoid Config..Exporter..UNIVERSAL search for DESTROY then AUTOLOAD
sub DESTROY { }
1;
use Config;
print "built by gcc\n";
}
=over 4
=item config_vars(@names)
=back
Here's a more sophisticated example of using %Config:
use Config;
use strict;
my %sig_num;
my @sig_name;
unless($Config{sig_name} && $Config{sig_num}) {
die "No sigs?";
} else {
my @names = split ' ', $Config{sig_name};
@sig_num{@names} = split ' ', $Config{sig_num};
foreach (@names) {
$sig_name[$sig_num{$_}] ||= $_;
}
}
print "signal #17 = $sig_name[17]\n";
if ($sig_num{ALRM}) {
print "SIGALRM is $sig_num{ALRM}\n";
}
=head1 WARNING
Because this information is not stored within the perl executable
itself it is possible (but unlikely) that the information does not
relate to the actual perl binary which is being used to access it.
The Config module is installed into the architecture and version
specific library directory ($Config{installarchlib}) and it checks the
perl version number when loaded.
The values stored in config.sh may be either single-quoted or
double-quoted. Double-quoted strings are handy for those cases where you
need to include escape sequences in the strings. To avoid runtime variable
interpolation, any C<$> and C<@> characters are replaced by C<\$> and
$text = 0;
$/ = '';
sub process {
my $c = substr $1, 0, 1;
print CONFIG <<EOF if $text;
=back
EOF
print CONFIG <<EOF;
=head2 $c
=over
EOF
$text = 1;
}
s/^(?<!\n\n)\t(.*)/$1/gm; # Not indented lines ===> text
s{([\'\"])(?=[^\'\"\s]*[./][^\'\"\s]*\1)([^\'\"\s]+)\1}(F<$2>)g; # '.o'
s{([\'\"])([^\'\"\s]+)\1}(C<$2>)g; # "date" command
s{
(?<! [\w./<\'\"] ) # Only standalone file names
(?! e \. g \. ) # Not e.g.
(?! \. \. \. ) # Not ...
(?! \d ) # Not 5.004
( [\w./]* [./] [\w./]* ) # Require . or / inside
(?<! \. (?= \s ) ) # Do not include trailing dot
(?! [\w/] ) # Include all of it
}
s/((?<=\s)~\w*)/F<$1>/g; # ~name
s/(?<![.<\'\"])\b([A-Z_]{2,})\b(?![\'\"])/C<$1>/g; # UNISTD
s/(?<![.<\'\"])\b(?!the\b)(\w+)\s+macro\b/C<$1> macro/g; # FILE_cnt macro
s/n[\0]t/n't/g; # undo can't, won't damage
}
<GLOS>; # Skip the preamble
print CONFIG;
}
=back
=cut
# Now do some simple tests on the Config.pm file we have created
require $config_pm;
die "$0: $config_pm not valid"
die "$0: error processing $config_pm"
;
die "$0: error processing $config_pm"
if eval '$Config{"cc"} = 1'
or eval 'delete $Config{"cc"}'
;
exit 0;