configpm revision 1
0N/A# commonly used names to put first (and hence lookup fastest) 0N/A# names of things which may need to have slashes changed to double-colons 0N/A# allowed opts as well as specifies default and initial values 873N/A 'cross' => '', # --cross=PALTFORM - crosscompiling for PLATFORM 0N/A 'glossary' => 1, # --no-glossary - no glossary file inclusion, 673N/A # user specified options 0N/A # --opt --no-opt --noopt 1040N/A # creating cross-platform config file 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. 723N/A# Define our own import method to avoid pulling in the full Exporter: 0N/Adie "Perl lib version (%s) doesn't match executable version ($])" 0N/A or die "Perl lib version (%s) doesn't match executable version (" .
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# Search for it in the big string 0N/A # Check for the common case, ' delimited 0N/A # If that failed, check for " delimited 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 # 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 0N/A # So we can say "if $Config{'foo'}". 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+)='(.*)'$/; 0N/A # grandfather PATCHLEVEL and SUBVERSION and CONFIG 723N/A elsif ($k eq 'PERL_SUBVERSION') { 0N/A ($name,$val) = ($1,$3); 0N/A $in_v = $val !~ /$quote\n/; 723N/A s,/,::,g if $Extensions{$name}; 723N/A $val =~ s/$quote\n?\z//; 723N/A my $line = "$name=$quote$val$quote\n"; 0N/A if (!$Common{$name}){ 723N/A push(@v_others, $line); 0N/A push(@v_fast, $line); 0N/A $v_fast{$name} = "'$name' => $quote$val$quote"; 673N/Aprint CONFIG @non_v, "\n"; 673N/Aprint CONFIG "our \$summary : unique = <<'!END!';\n"; 723N/A1 while defined($_ = <MYCONFIG>) && !/^Summary of/; 673N/Ado { print CONFIG $_ } until !defined($_ = <MYCONFIG>) || /^\s*$/; 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/Aprint CONFIG "\n!END!\n", <<'EOT'; 0N/Amy $summary_expanded; 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/Aour $Config_SH : unique = <<'!END!'; 0N/Aprint CONFIG join("", @v_fast, sort @v_others); 0N/Aprint CONFIG "!END!\n", $fetch_string; 0N/A my($self, $key) = @_; 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 @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 $self->{$key} = $value; 0N/A my($self, $key) = @_; 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 $self->fetch_string($key); 0N/A return $self->{$key} if exists $self->{$key}; 1040N/A $self->fetch_virtual($key); 0N/A # Might not exist, in which undef is correct. 0N/A substr($Config_SH, 0, index($Config_SH, '=') ); 0N/A # Extract the name of the DLL from the makefile to avoid duplication 24N/A\$preconfig{dll_name} = '$dll'; 468N/A# Calculation for the keys for byteorder 468N/A# This is somewhat grim, but I need to run fetch_string here. 592N/A# byteorder does exist on its own but we overlay a virtual 592N/A# dynamically recomputed value. 593N/A# However, ivtype and ivsize will not vary for sane fat binaries 593N/Amy $f = $t eq 'long' ? 'L!' : $s == 8 ? 'Q': 'I'; 0N/A print "built by gcc\n"; 0N/Anames match the $regex. 0N/A=item config_vars(@names) 723N/APrints to STDOUT the values of the named configuration variable. Each is 0N/Aprinted on a separate line in the form: 0N/ANames which are unknown are output as C<name='UNKNOWN';>. 0N/Aconsequences. (The slashes will end up escaped and the C<$> or C<@> will 0N/Atrigger variable interpolation) 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/Aif ($Opts{glossary}) { 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; 0N/A print CONFIG_POD <<EOF; 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 (?<! [\w./<\'\"] ) # Only standalone file names 0N/A (?! \. \. \. ) # Not ... 0N/A (?! \d ) # Not 5.004 1040N/A [\w./]* [./] [\w./]* # Require . or / inside 1040N/A (?<! \. (?= [\s)] ) ) # Do not include trailing dot 1040N/A (?! [\w/] ) # Include all of it 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 <GLOS>; # Skip the preamble 1040N/Aprint CONFIG_POD <<'ENDOFTAIL'; 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 # perl -MCross=wince -V:cc # if $platform is not specified, then use last one when # 'configpm; was invoked with --cross option @INC = map {/\blib\b/?(do{local $_=$_;s/\blib\b/xlib\/$platform/;$_},$_):($_)} @INC; # Now do some simple tests on the Config.pm file we have created unless $Config{'PERL_CONFIG_SH'} eq 'true'; if defined($Config{'an impossible name'}) or $Config{'PERL_CONFIG_SH'} ne 'true' # test cache