1N/A#!./miniperl -w
1N/A
1N/A# commonly used names to put first (and hence lookup fastest)
1N/Amy %Common = map {($_,$_)}
1N/A qw(archname osname osvers prefix libs libpth
1N/A dynamic_ext static_ext dlsrc so
1N/A cc ccflags cppflags
1N/A privlibexp archlibexp installprivlib installarchlib
1N/A sharpbang startsh shsharp
1N/A );
1N/A
1N/A# names of things which may need to have slashes changed to double-colons
1N/Amy %Extensions = map {($_,$_)}
1N/A qw(dynamic_ext static_ext extensions known_extensions);
1N/A
1N/A# allowed opts as well as specifies default and initial values
1N/Amy %Allowed_Opts = (
1N/A 'cross' => '', # --cross=PALTFORM - crosscompiling for PLATFORM
1N/A 'glossary' => 1, # --no-glossary - no glossary file inclusion,
1N/A # for compactness
1N/A);
1N/A
1N/Asub opts {
1N/A # user specified options
1N/A my %given_opts = (
1N/A # --opt=smth
1N/A (map {/^--([\-_\w]+)=(.*)$/} @ARGV),
1N/A # --opt --no-opt --noopt
1N/A (map {/^no-?(.*)$/i?($1=>0):($_=>1)} map {/^--([\-_\w]+)$/} @ARGV),
1N/A );
1N/A
1N/A my %opts = (%Allowed_Opts, %given_opts);
1N/A
1N/A for my $opt (grep {!exists $Allowed_Opts{$_}} keys %given_opts) {
1N/A die "option '$opt' is not recognized";
1N/A }
1N/A @ARGV = grep {!/^--/} @ARGV;
1N/A
1N/A return %opts;
1N/A}
1N/A
1N/A
1N/Amy %Opts = opts();
1N/A
1N/Amy $Config_PM;
1N/Amy $Glossary = $ARGV[1] || 'Porting/Glossary';
1N/A
1N/Aif ($Opts{cross}) {
1N/A # creating cross-platform config file
1N/A mkdir "xlib";
1N/A mkdir "xlib/$Opts{cross}";
1N/A $Config_PM = $ARGV[0] || "xlib/$Opts{cross}/Config.pm";
1N/A}
1N/Aelse {
1N/A $Config_PM = $ARGV[0] || 'lib/Config.pm';
1N/A}
1N/A
1N/A
1N/Aopen CONFIG, ">$Config_PM" or die "Can't open $Config_PM: $!\n";
1N/A
1N/Amy $myver = sprintf "v%vd", $^V;
1N/A
1N/Aprintf CONFIG <<'ENDOFBEG', ($myver) x 3;
1N/A# This file was created by configpm when Perl was built. Any changes
1N/A# made to this file will be lost the next time perl is built.
1N/A
1N/Apackage Config;
1N/A@EXPORT = qw(%%Config);
1N/A@EXPORT_OK = qw(myconfig config_sh config_vars config_re);
1N/A
1N/Amy %%Export_Cache = map {($_ => 1)} (@EXPORT, @EXPORT_OK);
1N/A
1N/A# Define our own import method to avoid pulling in the full Exporter:
1N/Asub import {
1N/A my $pkg = shift;
1N/A @_ = @EXPORT unless @_;
1N/A
1N/A my @funcs = grep $_ ne '%%Config', @_;
1N/A my $export_Config = @funcs < @_ ? 1 : 0;
1N/A
1N/A my $callpkg = caller(0);
1N/A foreach my $func (@funcs) {
1N/A die sprintf qq{"%%s" is not exported by the %%s module\n},
1N/A $func, __PACKAGE__ unless $Export_Cache{$func};
1N/A *{$callpkg.'::'.$func} = \&{$func};
1N/A }
1N/A
1N/A *{"$callpkg\::Config"} = \%%Config if $export_Config;
1N/A return;
1N/A}
1N/A
1N/Adie "Perl lib version (%s) doesn't match executable version ($])"
1N/A unless $^V;
1N/A
1N/A$^V eq %s
1N/A or die "Perl lib version (%s) doesn't match executable version (" .
1N/A sprintf("v%%vd",$^V) . ")";
1N/A
1N/AENDOFBEG
1N/A
1N/A
1N/Amy @non_v = ();
1N/Amy @v_fast = ();
1N/Amy %v_fast = ();
1N/Amy @v_others = ();
1N/Amy $in_v = 0;
1N/Amy %Data = ();
1N/A
1N/A# This is somewhat grim, but I want the code for parsing config.sh here and
1N/A# now so that I can expand $Config{ivsize} and $Config{ivtype}
1N/A
1N/Amy $fetch_string = <<'EOT';
1N/A
1N/A# Search for it in the big string
1N/Asub fetch_string {
1N/A my($self, $key) = @_;
1N/A
1N/A my $quote_type = "'";
1N/A my $marker = "$key=";
1N/A
1N/A # Check for the common case, ' delimited
1N/A my $start = index($Config_SH, "\n$marker$quote_type");
1N/A # If that failed, check for " delimited
1N/A if ($start == -1) {
1N/A $quote_type = '"';
1N/A $start = index($Config_SH, "\n$marker$quote_type");
1N/A }
1N/A return undef if ( ($start == -1) && # in case it's first
1N/A (substr($Config_SH, 0, length($marker)) ne $marker) );
1N/A if ($start == -1) {
1N/A # It's the very first thing we found. Skip $start forward
1N/A # and figure out the quote mark after the =.
1N/A $start = length($marker) + 1;
1N/A $quote_type = substr($Config_SH, $start - 1, 1);
1N/A }
1N/A else {
1N/A $start += length($marker) + 2;
1N/A }
1N/A
1N/A my $value = substr($Config_SH, $start,
1N/A index($Config_SH, "$quote_type\n", $start) - $start);
1N/A
1N/A # If we had a double-quote, we'd better eval it so escape
1N/A # sequences and such can be interpolated. Since the incoming
1N/A # value is supposed to follow shell rules and not perl rules,
1N/A # we escape any perl variable markers
1N/A if ($quote_type eq '"') {
1N/A $value =~ s/\$/\\\$/g;
1N/A $value =~ s/\@/\\\@/g;
1N/A eval "\$value = \"$value\"";
1N/A }
1N/A
1N/A # So we can say "if $Config{'foo'}".
1N/A $value = undef if $value eq 'undef';
1N/A $self->{$key} = $value; # cache it
1N/A}
1N/AEOT
1N/A
1N/Aeval $fetch_string;
1N/Adie if $@;
1N/A
1N/Aopen(CONFIG_SH, 'config.sh') || die "Can't open config.sh: $!";
1N/Awhile (<CONFIG_SH>) {
1N/A next if m:^#!/bin/sh:;
1N/A
1N/A # Catch PERL_CONFIG_SH=true and PERL_VERSION=n line from Configure.
1N/A s/^(\w+)=(true|\d+)\s*$/$1='$2'\n/ or m/^(\w+)='(.*)'$/;
1N/A my($k, $v) = ($1, $2);
1N/A
1N/A # grandfather PATCHLEVEL and SUBVERSION and CONFIG
1N/A if ($k) {
1N/A if ($k eq 'PERL_VERSION') {
1N/A push @v_others, "PATCHLEVEL='$v'\n";
1N/A }
1N/A elsif ($k eq 'PERL_SUBVERSION') {
1N/A push @v_others, "SUBVERSION='$v'\n";
1N/A }
1N/A elsif ($k eq 'PERL_CONFIG_SH') {
1N/A push @v_others, "CONFIG='$v'\n";
1N/A }
1N/A }
1N/A
1N/A # We can delimit things in config.sh with either ' or ".
1N/A unless ($in_v or m/^(\w+)=(['"])(.*\n)/){
1N/A push(@non_v, "#$_"); # not a name='value' line
1N/A next;
1N/A }
1N/A $quote = $2;
1N/A if ($in_v) {
1N/A $val .= $_;
1N/A }
1N/A else {
1N/A ($name,$val) = ($1,$3);
1N/A }
1N/A $in_v = $val !~ /$quote\n/;
1N/A next if $in_v;
1N/A
1N/A s,/,::,g if $Extensions{$name};
1N/A
1N/A $val =~ s/$quote\n?\z//;
1N/A
1N/A my $line = "$name=$quote$val$quote\n";
1N/A if (!$Common{$name}){
1N/A push(@v_others, $line);
1N/A }
1N/A else {
1N/A push(@v_fast, $line);
1N/A $v_fast{$name} = "'$name' => $quote$val$quote";
1N/A }
1N/A}
1N/Aclose CONFIG_SH;
1N/A
1N/Aprint CONFIG @non_v, "\n";
1N/A
1N/A# copy config summary format from the myconfig.SH script
1N/Aprint CONFIG "our \$summary : unique = <<'!END!';\n";
1N/Aopen(MYCONFIG,"<myconfig.SH") || die "open myconfig.SH failed: $!";
1N/A1 while defined($_ = <MYCONFIG>) && !/^Summary of/;
1N/Ado { print CONFIG $_ } until !defined($_ = <MYCONFIG>) || /^\s*$/;
1N/Aclose(MYCONFIG);
1N/A
1N/A# NB. as $summary is unique, we need to copy it in a lexical variable
1N/A# before expanding it, because may have been made readonly if a perl
1N/A# interpreter has been cloned.
1N/A
1N/Aprint CONFIG "\n!END!\n", <<'EOT';
1N/Amy $summary_expanded;
1N/A
1N/Asub myconfig {
1N/A return $summary_expanded if $summary_expanded;
1N/A ($summary_expanded = $summary) =~ s{\$(\w+)}
1N/A { my $c = $Config{$1}; defined($c) ? $c : 'undef' }ge;
1N/A $summary_expanded;
1N/A}
1N/A
1N/Aour $Config_SH : unique = <<'!END!';
1N/AEOT
1N/A
1N/Aprint CONFIG join("", @v_fast, sort @v_others);
1N/A
1N/Aprint CONFIG "!END!\n", $fetch_string;
1N/A
1N/Aprint CONFIG <<'ENDOFEND';
1N/A
1N/Asub fetch_virtual {
1N/A my($self, $key) = @_;
1N/A
1N/A my $value;
1N/A
1N/A if ($key =~ /^((?:cc|ld)flags|libs(?:wanted)?)_nolargefiles/) {
1N/A # These are purely virtual, they do not exist, but need to
1N/A # be computed on demand for largefile-incapable extensions.
1N/A my $new_key = "${1}_uselargefiles";
1N/A $value = $Config{$1};
1N/A my $withlargefiles = $Config{$new_key};
1N/A if ($new_key =~ /^(?:cc|ld)flags_/) {
1N/A $value =~ s/\Q$withlargefiles\E\b//;
1N/A } elsif ($new_key =~ /^libs/) {
1N/A my @lflibswanted = split(' ', $Config{libswanted_uselargefiles});
1N/A if (@lflibswanted) {
1N/A my %lflibswanted;
1N/A @lflibswanted{@lflibswanted} = ();
1N/A if ($new_key =~ /^libs_/) {
1N/A my @libs = grep { /^-l(.+)/ &&
1N/A not exists $lflibswanted{$1} }
1N/A split(' ', $Config{libs});
1N/A $Config{libs} = join(' ', @libs);
1N/A } elsif ($new_key =~ /^libswanted_/) {
1N/A my @libswanted = grep { not exists $lflibswanted{$_} }
1N/A split(' ', $Config{libswanted});
1N/A $Config{libswanted} = join(' ', @libswanted);
1N/A }
1N/A }
1N/A }
1N/A }
1N/A
1N/A $self->{$key} = $value;
1N/A}
1N/A
1N/Asub FETCH {
1N/A my($self, $key) = @_;
1N/A
1N/A # check for cached value (which may be undef so we use exists not defined)
1N/A return $self->{$key} if exists $self->{$key};
1N/A
1N/A $self->fetch_string($key);
1N/A return $self->{$key} if exists $self->{$key};
1N/A $self->fetch_virtual($key);
1N/A
1N/A # Might not exist, in which undef is correct.
1N/A return $self->{$key};
1N/A}
1N/A
1N/Amy $prevpos = 0;
1N/A
1N/Asub FIRSTKEY {
1N/A $prevpos = 0;
1N/A substr($Config_SH, 0, index($Config_SH, '=') );
1N/A}
1N/A
1N/Asub NEXTKEY {
1N/A # Find out how the current key's quoted so we can skip to its end.
1N/A my $quote = substr($Config_SH, index($Config_SH, "=", $prevpos)+1, 1);
1N/A my $pos = index($Config_SH, qq($quote\n), $prevpos) + 2;
1N/A my $len = index($Config_SH, "=", $pos) - $pos;
1N/A $prevpos = $pos;
1N/A $len > 0 ? substr($Config_SH, $pos, $len) : undef;
1N/A}
1N/A
1N/Asub EXISTS {
1N/A return 1 if exists($_[0]->{$_[1]});
1N/A
1N/A return(index($Config_SH, "\n$_[1]='") != -1 or
1N/A substr($Config_SH, 0, length($_[1])+2) eq "$_[1]='" or
1N/A index($Config_SH, "\n$_[1]=\"") != -1 or
1N/A substr($Config_SH, 0, length($_[1])+2) eq "$_[1]=\"" or
1N/A $_[1] =~ /^(?:(?:cc|ld)flags|libs(?:wanted)?)_nolargefiles$/
1N/A );
1N/A}
1N/A
1N/Asub STORE { die "\%Config::Config is read-only\n" }
1N/A*DELETE = \&STORE;
1N/A*CLEAR = \&STORE;
1N/A
1N/A
1N/Asub config_sh {
1N/A $Config_SH
1N/A}
1N/A
1N/Asub config_re {
1N/A my $re = shift;
1N/A return map { chomp; $_ } grep /^$re=/, split /^/, $Config_SH;
1N/A}
1N/A
1N/Asub config_vars {
1N/A foreach (@_) {
1N/A if (/\W/) {
1N/A my @matches = config_re($_);
1N/A print map "$_\n", @matches ? @matches : "$_: not found";
1N/A } else {
1N/A my $v = (exists $Config{$_}) ? $Config{$_} : 'UNKNOWN';
1N/A $v = 'undef' unless defined $v;
1N/A print "$_='$v';\n";
1N/A }
1N/A }
1N/A}
1N/A
1N/AENDOFEND
1N/A
1N/Aif ($^O eq 'os2') {
1N/A print CONFIG <<'ENDOFSET';
1N/Amy %preconfig;
1N/Aif ($OS2::is_aout) {
1N/A my ($value, $v) = $Config_SH =~ m/^used_aout='(.*)'\s*$/m;
1N/A for (split ' ', $value) {
1N/A ($v) = $Config_SH =~ m/^aout_$_='(.*)'\s*$/m;
1N/A $preconfig{$_} = $v eq 'undef' ? undef : $v;
1N/A }
1N/A}
1N/A$preconfig{d_fork} = undef unless $OS2::can_fork; # Some funny cases can't
1N/Asub TIEHASH { bless {%preconfig} }
1N/AENDOFSET
1N/A # Extract the name of the DLL from the makefile to avoid duplication
1N/A my ($f) = grep -r, qw(GNUMakefile Makefile);
1N/A my $dll;
1N/A if (open my $fh, '<', $f) {
1N/A while (<$fh>) {
1N/A $dll = $1, last if /^PERL_DLL_BASE\s*=\s*(\S*)\s*$/;
1N/A }
1N/A }
1N/A print CONFIG <<ENDOFSET if $dll;
1N/A\$preconfig{dll_name} = '$dll';
1N/AENDOFSET
1N/A} else {
1N/A print CONFIG <<'ENDOFSET';
1N/Asub TIEHASH {
1N/A bless $_[1], $_[0];
1N/A}
1N/AENDOFSET
1N/A}
1N/A
1N/A
1N/A# Calculation for the keys for byteorder
1N/A# This is somewhat grim, but I need to run fetch_string here.
1N/Aour $Config_SH = join "\n", @v_fast, @v_others;
1N/A
1N/Amy $t = fetch_string ({}, 'ivtype');
1N/Amy $s = fetch_string ({}, 'ivsize');
1N/A
1N/A# byteorder does exist on its own but we overlay a virtual
1N/A# dynamically recomputed value.
1N/A
1N/A# However, ivtype and ivsize will not vary for sane fat binaries
1N/A
1N/Amy $f = $t eq 'long' ? 'L!' : $s == 8 ? 'Q': 'I';
1N/A
1N/Amy $byteorder_code;
1N/Aif ($s == 4 || $s == 8) {
1N/A my $list = join ',', reverse(2..$s);
1N/A my $format = 'a'x$s;
1N/A $byteorder_code = <<"EOT";
1N/Amy \$i = 0;
1N/Aforeach my \$c ($list) { \$i |= ord(\$c); \$i <<= 8 }
1N/A\$i |= ord(1);
1N/Amy \$value = join('', unpack('$format', pack('$f', \$i)));
1N/AEOT
1N/A} else {
1N/A $byteorder_code = "\$value = '?'x$s;\n";
1N/A}
1N/A
1N/Amy $fast_config = join '', map { " $_,\n" }
1N/A sort values (%v_fast), 'byteorder => $value' ;
1N/A
1N/Aprint CONFIG sprintf <<'ENDOFTIE', $byteorder_code, $fast_config;
1N/A
1N/A# avoid Config..Exporter..UNIVERSAL search for DESTROY then AUTOLOAD
1N/Asub DESTROY { }
1N/A
1N/A%s
1N/A
1N/Atie %%Config, 'Config', {
1N/A%s
1N/A};
1N/A
1N/A1;
1N/AENDOFTIE
1N/A
1N/A
1N/Aopen(CONFIG_POD, ">lib/Config.pod") or die "Can't open lib/Config.pod: $!";
1N/Aprint CONFIG_POD <<'ENDOFTAIL';
1N/A=head1 NAME
1N/A
1N/AConfig - access Perl configuration information
1N/A
1N/A=head1 SYNOPSIS
1N/A
1N/A use Config;
1N/A if ($Config{'cc'} =~ /gcc/) {
1N/A print "built by gcc\n";
1N/A }
1N/A
1N/A use Config qw(myconfig config_sh config_vars config_re);
1N/A
1N/A print myconfig();
1N/A
1N/A print config_sh();
1N/A
1N/A print config_re();
1N/A
1N/A config_vars(qw(osname archname));
1N/A
1N/A
1N/A=head1 DESCRIPTION
1N/A
1N/AThe Config module contains all the information that was available to
1N/Athe C<Configure> program at Perl build time (over 900 values).
1N/A
1N/AShell variables from the F<config.sh> file (written by Configure) are
1N/Astored in the readonly-variable C<%Config>, indexed by their names.
1N/A
1N/AValues stored in config.sh as 'undef' are returned as undefined
1N/Avalues. The perl C<exists> function can be used to check if a
1N/Anamed variable exists.
1N/A
1N/A=over 4
1N/A
1N/A=item myconfig()
1N/A
1N/AReturns a textual summary of the major perl configuration values.
1N/ASee also C<-V> in L<perlrun/Switches>.
1N/A
1N/A=item config_sh()
1N/A
1N/AReturns the entire perl configuration information in the form of the
1N/Aoriginal config.sh shell variable assignment script.
1N/A
1N/A=item config_re($regex)
1N/A
1N/ALike config_sh() but returns, as a list, only the config entries who's
1N/Anames match the $regex.
1N/A
1N/A=item config_vars(@names)
1N/A
1N/APrints to STDOUT the values of the named configuration variable. Each is
1N/Aprinted on a separate line in the form:
1N/A
1N/A name='value';
1N/A
1N/ANames which are unknown are output as C<name='UNKNOWN';>.
1N/ASee also C<-V:name> in L<perlrun/Switches>.
1N/A
1N/A=back
1N/A
1N/A=head1 EXAMPLE
1N/A
1N/AHere's a more sophisticated example of using %Config:
1N/A
1N/A use Config;
1N/A use strict;
1N/A
1N/A my %sig_num;
1N/A my @sig_name;
1N/A unless($Config{sig_name} && $Config{sig_num}) {
1N/A die "No sigs?";
1N/A } else {
1N/A my @names = split ' ', $Config{sig_name};
1N/A @sig_num{@names} = split ' ', $Config{sig_num};
1N/A foreach (@names) {
1N/A $sig_name[$sig_num{$_}] ||= $_;
1N/A }
1N/A }
1N/A
1N/A print "signal #17 = $sig_name[17]\n";
1N/A if ($sig_num{ALRM}) {
1N/A print "SIGALRM is $sig_num{ALRM}\n";
1N/A }
1N/A
1N/A=head1 WARNING
1N/A
1N/ABecause this information is not stored within the perl executable
1N/Aitself it is possible (but unlikely) that the information does not
1N/Arelate to the actual perl binary which is being used to access it.
1N/A
1N/AThe Config module is installed into the architecture and version
1N/Aspecific library directory ($Config{installarchlib}) and it checks the
1N/Aperl version number when loaded.
1N/A
1N/AThe values stored in config.sh may be either single-quoted or
1N/Adouble-quoted. Double-quoted strings are handy for those cases where you
1N/Aneed to include escape sequences in the strings. To avoid runtime variable
1N/Ainterpolation, any C<$> and C<@> characters are replaced by C<\$> and
1N/AC<\@>, respectively. This isn't foolproof, of course, so don't embed C<\$>
1N/Aor C<\@> in double-quoted strings unless you're willing to deal with the
1N/Aconsequences. (The slashes will end up escaped and the C<$> or C<@> will
1N/Atrigger variable interpolation)
1N/A
1N/A=head1 GLOSSARY
1N/A
1N/AMost C<Config> variables are determined by the C<Configure> script
1N/Aon platforms supported by it (which is most UNIX platforms). Some
1N/Aplatforms have custom-made C<Config> variables, and may thus not have
1N/Asome of the variables described below, or may have extraneous variables
1N/Aspecific to that particular port. See the port specific documentation
1N/Ain such cases.
1N/A
1N/AENDOFTAIL
1N/A
1N/Aif ($Opts{glossary}) {
1N/A open(GLOS, "<$Glossary") or die "Can't open $Glossary: $!";
1N/A}
1N/A%seen = ();
1N/A$text = 0;
1N/A$/ = '';
1N/A
1N/Asub process {
1N/A if (s/\A(\w*)\s+\(([\w.]+)\):\s*\n(\t?)/=item C<$1>\n\nFrom F<$2>:\n\n/m) {
1N/A my $c = substr $1, 0, 1;
1N/A unless ($seen{$c}++) {
1N/A print CONFIG_POD <<EOF if $text;
1N/A=back
1N/A
1N/AEOF
1N/A print CONFIG_POD <<EOF;
1N/A=head2 $c
1N/A
1N/A=over 4
1N/A
1N/AEOF
1N/A $text = 1;
1N/A }
1N/A }
1N/A elsif (!$text || !/\A\t/) {
1N/A warn "Expected a Configure variable header",
1N/A ($text ? " or another paragraph of description" : () );
1N/A }
1N/A s/n't/n\00t/g; # leave can't, won't etc untouched
1N/A s/^\t\s+(.*)/\n$1/gm; # Indented lines ===> new paragraph
1N/A s/^(?<!\n\n)\t(.*)/$1/gm; # Not indented lines ===> text
1N/A s{([\'\"])(?=[^\'\"\s]*[./][^\'\"\s]*\1)([^\'\"\s]+)\1}(F<$2>)g; # '.o'
1N/A s{([\'\"])([^\'\"\s]+)\1}(C<$2>)g; # "date" command
1N/A s{\'([A-Za-z_\- *=/]+)\'}(C<$1>)g; # 'ln -s'
1N/A s{
1N/A (?<! [\w./<\'\"] ) # Only standalone file names
1N/A (?! e \. g \. ) # Not e.g.
1N/A (?! \. \. \. ) # Not ...
1N/A (?! \d ) # Not 5.004
1N/A (?! read/ ) # Not read/write
1N/A (?! etc\. ) # Not etc.
1N/A (?! I/O ) # Not I/O
1N/A (
1N/A \$ ? # Allow leading $
1N/A [\w./]* [./] [\w./]* # Require . or / inside
1N/A )
1N/A (?<! \. (?= [\s)] ) ) # Do not include trailing dot
1N/A (?! [\w/] ) # Include all of it
1N/A }
1N/A (F<$1>)xg; # /usr/local
1N/A s/((?<=\s)~\w*)/F<$1>/g; # ~name
1N/A s/(?<![.<\'\"])\b([A-Z_]{2,})\b(?![\'\"])/C<$1>/g; # UNISTD
1N/A s/(?<![.<\'\"])\b(?!the\b)(\w+)\s+macro\b/C<$1> macro/g; # FILE_cnt macro
1N/A s/n[\0]t/n't/g; # undo can't, won't damage
1N/A}
1N/A
1N/Aif ($Opts{glossary}) {
1N/A <GLOS>; # Skip the "DO NOT EDIT"
1N/A <GLOS>; # Skip the preamble
1N/A while (<GLOS>) {
1N/A process;
1N/A print CONFIG_POD;
1N/A }
1N/A}
1N/A
1N/Aprint CONFIG_POD <<'ENDOFTAIL';
1N/A
1N/A=back
1N/A
1N/A=head1 NOTE
1N/A
1N/AThis module contains a good example of how to use tie to implement a
1N/Acache and an example of how to make a tied variable readonly to those
1N/Aoutside of it.
1N/A
1N/A=cut
1N/A
1N/AENDOFTAIL
1N/A
1N/Aclose(CONFIG);
1N/Aclose(GLOS);
1N/Aclose(CONFIG_POD);
1N/A
1N/A# Now create Cross.pm if needed
1N/Aif ($Opts{cross}) {
1N/A open CROSS, ">lib/Cross.pm" or die "Can not open >lib/Cross.pm: $!";
1N/A my $cross = <<'EOS';
1N/A# typical invocation:
1N/A# perl -MCross Makefile.PL
1N/A# perl -MCross=wince -V:cc
1N/Apackage Cross;
1N/A
1N/Asub import {
1N/A my ($package,$platform) = @_;
1N/A unless (defined $platform) {
1N/A # if $platform is not specified, then use last one when
1N/A # 'configpm; was invoked with --cross option
1N/A $platform = '***replace-marker***';
1N/A }
1N/A @INC = map {/\blib\b/?(do{local $_=$_;s/\blib\b/xlib\/$platform/;$_},$_):($_)} @INC;
1N/A $::Cross::platform = $platform;
1N/A}
1N/A
1N/A1;
1N/AEOS
1N/A $cross =~ s/\*\*\*replace-marker\*\*\*/$Opts{cross}/g;
1N/A print CROSS $cross;
1N/A close CROSS;
1N/A}
1N/A
1N/A# Now do some simple tests on the Config.pm file we have created
1N/Aunshift(@INC,'lib');
1N/Arequire $Config_PM;
1N/Aimport Config;
1N/A
1N/Adie "$0: $Config_PM not valid"
1N/A unless $Config{'PERL_CONFIG_SH'} eq 'true';
1N/A
1N/Adie "$0: error processing $Config_PM"
1N/A if defined($Config{'an impossible name'})
1N/A or $Config{'PERL_CONFIG_SH'} ne 'true' # test cache
1N/A ;
1N/A
1N/Adie "$0: error processing $Config_PM"
1N/A if eval '$Config{"cc"} = 1'
1N/A or eval 'delete $Config{"cc"}'
1N/A ;
1N/A
1N/A
1N/Aexit 0;