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