5 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
6 # 2002, 2003, 2004, 2005, 2006, 2007 Larry Wall and others.
14 # lib/Cross.pm (optionally)
17 # from the contents of the static files
22 # and from the contents of the Configure-generated file
26 # Note that output directory is xlib/[cross-name]/ for cross-compiling
28 # It will only update Config.pm and Config_heavy.pl if the contents of
29 # either file would be different. Note that *both* files are updated in
30 # this case, since for example an extension makefile that has a dependency
31 # on Config.pm should trigger even if only Config_heavy.pl has changed.
33 sub usage { die <<EOF }
35 --cross=PLATFORM cross-compile for a different platform
36 --no-glossary don't include Porting/Glossary in lib/Config.pod
37 --chdir=dir change directory before writing files
41 use vars qw(%Config $Config_SH_expanded);
43 my $how_many_common = 22;
45 # commonly used names to precache (and hence lookup fastest)
48 while ($how_many_common--) {
51 /^(\S+):\s*(\d+)$/ or die "Malformed line '$_'";
55 # Post 37589e1eefb1bd62 DynaLoader defaults to reading these at runtime.
56 # Ideally we're redo the data below, but Fotango's build system made it
57 # wonderfully easy to instrument, and no longer exists.
58 $Common{$_} = $_ foreach qw(dlext so);
60 # names of things which may need to have slashes changed to double-colons
61 my %Extensions = map {($_,$_)}
62 qw(dynamic_ext static_ext extensions known_extensions);
64 # allowed opts as well as specifies default and initial values
66 'cross' => '', # --cross=PLATFORM - crosscompiling for PLATFORM
67 'glossary' => 1, # --no-glossary - no glossary file inclusion,
69 'chdir' => '', # --chdir=dir - change directory before writing files
73 # user specified options
76 (map {/^--([\-_\w]+)=(.*)$/} @ARGV),
77 # --opt --no-opt --noopt
78 (map {/^no-?(.*)$/i?($1=>0):($_=>1)} map {/^--([\-_\w]+)$/} @ARGV),
81 my %opts = (%Allowed_Opts, %given_opts);
83 for my $opt (grep {!exists $Allowed_Opts{$_}} keys %given_opts) {
84 warn "option '$opt' is not recognized";
87 @ARGV = grep {!/^--/} @ARGV;
96 chdir $Opts{chdir} or die "$0: could not chdir $Opts{chdir}: $!"
99 my ($Config_SH, $Config_PM, $Config_heavy, $Config_POD);
100 my $Glossary = 'Porting/Glossary';
103 # creating cross-platform config file
105 mkdir "xlib/$Opts{cross}";
106 $Config_PM = "xlib/$Opts{cross}/Config.pm";
107 $Config_POD = "xlib/$Opts{cross}/Config.pod";
108 $Config_SH = "Cross/config-$Opts{cross}.sh";
111 $Config_PM = "lib/Config.pm";
112 $Config_POD = "lib/Config.pod";
113 $Config_SH = "config.sh";
115 ($Config_heavy = $Config_PM) =~ s/\.pm$/_heavy.pl/;
116 die "Can't automatically determine name for Config_heavy.pl from '$Config_PM'"
117 if $Config_heavy eq $Config_PM;
122 $heavy_txt .= <<'ENDOFBEG';
123 # This file was created by configpm when Perl was built. Any changes
124 # made to this file will be lost the next time perl is built.
128 # use warnings; Pulls in Carp
129 # use vars pulls in Carp
132 my ($bincompat, $non_bincompat, $date, @patches) = Internals::V();
134 my $opts = join ' ', sort split ' ', "$bincompat $non_bincompat";
136 # wrap at 76 columns.
138 $opts =~ s/(?=.{53})(.{1,53}) /$1\n /mg;
140 print Config::myconfig();
142 print "\nCharacteristics of this PERLSHR image: \n";
144 print "\nCharacteristics of this binary (from libperl): \n";
147 print " Compile-time options: $opts\n";
150 print " Locally applied patches:\n";
151 print "\t$_\n" foreach @patches;
154 print " Built under $^O\n";
156 print " $date\n" if defined $date;
158 my @env = map { "$_=\"$ENV{$_}\"" } sort grep {/^PERL/} keys %ENV;
159 push @env, "CYGWIN=\"$ENV{CYGWIN}\"" if $^O eq 'cygwin';
163 print " $_\n" foreach @env;
166 print " $_\n" foreach @INC;
171 my $export_funcs = <<'EOT';
172 my %Export_Cache = (myconfig => 1,
173 config_sh => 1, config_vars => 1, config_re => 1);
176 my %export_ok = eval $export_funcs or die;
178 $config_txt .= sprintf << 'EOT', $export_funcs;
179 # This file was created by configpm when Perl was built. Any changes
180 # made to this file will be lost the next time perl is built.
182 # for a description of the variables, please have a look at the
183 # Glossary file, as written in the Porting folder, or use the url:
184 # http://perl5.git.perl.org/perl.git/blob/HEAD:/Porting/Glossary
188 # use warnings; Pulls in Carp
189 # use vars pulls in Carp
191 # Skip @Config::EXPORT because it only contains %%Config, which we special
192 # case below as it's not a function. @Config::EXPORT won't change in the
193 # lifetime of Perl 5.
195 @Config::EXPORT = qw(%%Config);
196 @Config::EXPORT_OK = keys %%Export_Cache;
198 # Need to stub all the functions to make code such as print Config::config_sh
203 $config_txt .= "sub $_;\n" foreach sort keys %export_ok;
205 my $myver = sprintf "%vd", $^V;
207 $config_txt .= sprintf <<'ENDOFBEG', ($myver) x 3;
210 # Define our own import method to avoid pulling in the full Exporter:
213 @_ = @Config::EXPORT unless @_;
215 my @funcs = grep $_ ne '%%Config', @_;
216 my $export_Config = @funcs < @_ ? 1 : 0;
219 my $callpkg = caller(0);
220 foreach my $func (@funcs) {
221 die qq{"$func" is not exported by the Config module\n}
222 unless $Export_Cache{$func};
223 *{$callpkg.'::'.$func} = \&{$func};
226 *{"$callpkg\::Config"} = \%%Config if $export_Config;
230 die "Perl lib version (%s) doesn't match executable '$0' version ($])"
234 or die "Perl lib version (%s) doesn't match executable '$0' version (" .
235 sprintf("v%%vd",$^V) . ")";
249 open(CONFIG_SH, $Config_SH) || die "Can't open $Config_SH: $!";
250 while (<CONFIG_SH>) {
251 next if m:^#!/bin/sh:;
253 # Catch PERL_CONFIG_SH=true and PERL_VERSION=n line from Configure.
254 s/^(\w+)=(true|\d+)\s*$/$1='$2'\n/ or m/^(\w+)='(.*)'$/;
255 my($k, $v) = ($1, $2);
257 # grandfather PATCHLEVEL and SUBVERSION and CONFIG
259 if ($k eq 'PERL_VERSION') {
260 push @v_others, "PATCHLEVEL='$v'\n";
262 elsif ($k eq 'PERL_SUBVERSION') {
263 push @v_others, "SUBVERSION='$v'\n";
265 elsif ($k eq 'PERL_CONFIG_SH') {
266 push @v_others, "CONFIG='$v'\n";
270 # We can delimit things in config.sh with either ' or ".
271 unless ($in_v or m/^(\w+)=(['"])(.*\n)/){
272 push(@non_v, "#$_"); # not a name='value' line
280 ($name,$val) = ($1,$3);
282 $in_v = $val !~ /$quote\n/;
285 s,/,::,g if $Extensions{$name};
287 $val =~ s/$quote\n?\z//;
289 my $line = "$name=$quote$val$quote\n";
290 push(@v_others, $line);
291 $seen_quotes{$quote}++;
296 # This is somewhat grim, but I want the code for parsing config.sh here and
297 # now so that I can expand $Config{ivsize} and $Config{ivtype}
299 my $fetch_string = <<'EOT';
301 # Search for it in the big string
303 my($self, $key) = @_;
307 if ($seen_quotes{'"'}) {
308 # We need the full ' and " code
310 $fetch_string .= <<'EOT';
311 return undef unless my ($quote_type, $value) = $Config_SH_expanded =~ /\n$key=(['"])(.*?)\1\n/s;
313 # If we had a double-quote, we'd better eval it so escape
314 # sequences and such can be interpolated. Since the incoming
315 # value is supposed to follow shell rules and not perl rules,
316 # we escape any perl variable markers
318 # Historically, since " 'support' was added in change 1409, the
319 # interpolation was done before the undef. Stick to this arguably buggy
320 # behaviour as we're refactoring.
321 if ($quote_type eq '"') {
322 $value =~ s/\$/\\\$/g;
323 $value =~ s/\@/\\\@/g;
324 eval "\$value = \"$value\"";
327 # So we can say "if $Config{'foo'}".
328 $self->{$key} = $value eq 'undef' ? undef : $value; # cache it
333 # We only have ' delimted.
335 $fetch_string .= <<'EOT';
336 return undef unless $Config_SH_expanded =~ /\n$key=\'(.*?)\'\n/s;
337 # So we can say "if $Config{'foo'}".
338 $self->{$key} = $1 eq 'undef' ? undef : $1;
347 # Calculation for the keys for byteorder
348 # This is somewhat grim, but I need to run fetch_string here.
349 our $Config_SH_expanded = join "\n", '', @v_others;
351 my $t = fetch_string ({}, 'ivtype');
352 my $s = fetch_string ({}, 'ivsize');
354 # byteorder does exist on its own but we overlay a virtual
355 # dynamically recomputed value.
357 # However, ivtype and ivsize will not vary for sane fat binaries
359 my $f = $t eq 'long' ? 'L!' : $s == 8 ? 'Q': 'I';
362 if ($s == 4 || $s == 8) {
363 my $list = join ',', reverse(2..$s);
365 $byteorder_code = <<"EOT";
368 foreach my \$c ($list) { \$i |= ord(\$c); \$i <<= 8 }
370 our \$byteorder = join('', unpack('$format', pack('$f', \$i)));
373 $byteorder_code = "our \$byteorder = '?'x$s;\n";
378 if (fetch_string({},'userelocatableinc')) {
379 foreach my $what (qw(prefixexp
428 installvendorhtml1dir
429 installvendorhtml3dir
435 push @need_relocation, $what if fetch_string({}, $what) =~ m!^\.\.\./!;
440 @need_relocation{@need_relocation} = @need_relocation;
442 # This can have .../ anywhere:
443 if (fetch_string({}, 'otherlibdirs') =~ m!\.\.\./!) {
444 $need_relocation{otherlibdirs} = 'otherlibdirs';
447 my $relocation_code = <<'EOT';
451 return $libdir unless $libdir =~ s!^\.\.\./!!;
453 if ($prefix =~ s!/[^/]*$!!) {
454 while ($libdir =~ m!^\.\./!) {
455 # Loop while $libdir starts "../" and $prefix still has a trailing
457 last unless $prefix =~ s!/([^/]+)$!!;
458 # but bail out if the directory we picked off the end of $prefix is .
460 if ($1 eq '.' or $1 eq '..') {
461 # Undo! This should be rare, hence code it this way rather than a
462 # check each time before the s!!! above.
463 $prefix = "$prefix/$1";
466 # Remove that leading ../ and loop again
467 substr ($libdir, 0, 3, '');
469 $libdir = "$prefix/$libdir";
475 if (%need_relocation) {
476 my $relocations_in_common;
477 # otherlibdirs only features in the hash
478 foreach (keys %need_relocation) {
479 $relocations_in_common++ if $Common{$_};
481 if ($relocations_in_common) {
482 $config_txt .= $relocation_code;
484 $heavy_txt .= $relocation_code;
488 $heavy_txt .= join('', @non_v) . "\n";
490 # copy config summary format from the myconfig.SH script
491 $heavy_txt .= "our \$summary = <<'!END!';\n";
492 open(MYCONFIG,"<myconfig.SH") || die "open myconfig.SH failed: $!";
493 1 while defined($_ = <MYCONFIG>) && !/^Summary of/;
494 do { $heavy_txt .= $_ } until !defined($_ = <MYCONFIG>) || /^\s*$/;
497 $heavy_txt .= "\n!END!\n" . <<'EOT';
498 my $summary_expanded;
501 return $summary_expanded if $summary_expanded;
502 ($summary_expanded = $summary) =~ s{\$(\w+)}
505 if ($1 eq 'git_ancestor_line') {
506 if ($Config::Config{git_ancestor}) {
507 $c= "\n Ancestor: $Config::Config{git_ancestor}";
512 $c = $Config::Config{$1};
514 defined($c) ? $c : 'undef'
523 $heavy_txt .= join('', sort @v_others) . "!END!\n";
525 # Only need the dynamic byteorder code in Config.pm if 'byteorder' is one of
527 if ($Common{byteorder}) {
528 $config_txt .= $byteorder_code;
530 $heavy_txt .= $byteorder_code;
533 if (@need_relocation) {
534 $heavy_txt .= 'foreach my $what (qw(' . join (' ', @need_relocation) .
536 s/^($what=)(['"])(.*?)\2/$1 . $2 . relocate_inc($3) . $2/me;
539 # Currently it only makes sense to do the ... relocation on Unix, so there's
540 # no need to emulate the "which separator for this platform" logic in perl.c -
541 # ':' will always be applicable
542 if ($need_relocation{otherlibdirs}) {
543 $heavy_txt .= << 'EOT';
544 s{^(otherlibdirs=)(['"])(.*?)\2}
545 {$1 . $2 . join ':', map {relocate_inc($_)} split ':', $3 . $2}me;
550 $heavy_txt .= <<'EOT';
551 s/(byteorder=)(['"]).*?\2/$1$2$Config::byteorder$2/m;
553 my $config_sh_len = length $_;
555 our $Config_SH_expanded = "\n$_" . << 'EOVIRTUAL';
558 foreach my $prefix (qw(ccflags ldflags)) {
559 my $value = fetch_string ({}, $prefix);
560 my $withlargefiles = fetch_string ({}, $prefix . "_uselargefiles");
561 if (defined $withlargefiles) {
562 $value =~ s/\Q$withlargefiles\E\b//;
563 $heavy_txt .= "${prefix}_nolargefiles='$value'\n";
567 foreach my $prefix (qw(libs libswanted)) {
568 my $value = fetch_string ({}, $prefix);
569 my $withlf = fetch_string ({}, 'libswanted_uselargefiles');
570 next unless defined $withlf;
572 = split(' ', fetch_string ({}, 'libswanted_uselargefiles'));
575 @lflibswanted{@lflibswanted} = ();
576 if ($prefix eq 'libs') {
577 my @libs = grep { /^-l(.+)/ &&
578 not exists $lflibswanted{$1} }
579 split(' ', fetch_string ({}, 'libs'));
580 $value = join(' ', @libs);
582 my @libswanted = grep { not exists $lflibswanted{$_} }
583 split(' ', fetch_string ({}, 'libswanted'));
584 $value = join(' ', @libswanted);
587 $heavy_txt .= "${prefix}_nolargefiles='$value'\n";
590 $heavy_txt .= "EOVIRTUAL\n";
592 $heavy_txt .= <<'ENDOFGIT';
594 # do not have hairy conniptions if this isnt available
595 require 'Config_git.pl';
596 $Config_SH_expanded .= $Config::Git_Data;
598 } or warn "Warning: failed to load Config_git.pl, something strange about this perl...\n";
601 $heavy_txt .= $fetch_string;
603 $config_txt .= <<'ENDOFEND';
606 my($self, $key) = @_;
608 # check for cached value (which may be undef so we use exists not defined)
609 return $self->{$key} if exists $self->{$key};
611 return $self->fetch_string($key);
615 $heavy_txt .= <<'ENDOFEND';
621 substr($Config_SH_expanded, 1, index($Config_SH_expanded, '=') - 1 );
626 if ($seen_quotes{'"'}) {
627 $heavy_txt .= <<'ENDOFEND';
628 # Find out how the current key's quoted so we can skip to its end.
629 my $quote = substr($Config_SH_expanded,
630 index($Config_SH_expanded, "=", $prevpos)+1, 1);
631 my $pos = index($Config_SH_expanded, qq($quote\n), $prevpos) + 2;
634 # Just ' quotes, so it's much easier.
635 $heavy_txt .= <<'ENDOFEND';
636 my $pos = index($Config_SH_expanded, qq('\n), $prevpos) + 2;
639 $heavy_txt .= <<'ENDOFEND';
640 my $len = index($Config_SH_expanded, "=", $pos) - $pos;
642 $len > 0 ? substr($Config_SH_expanded, $pos, $len) : undef;
646 return 1 if exists($_[0]->{$_[1]});
648 return(index($Config_SH_expanded, "\n$_[1]='") != -1
650 if ($seen_quotes{'"'}) {
651 $heavy_txt .= <<'ENDOFEND';
652 or index($Config_SH_expanded, "\n$_[1]=\"") != -1
655 $heavy_txt .= <<'ENDOFEND';
659 sub STORE { die "\%Config::Config is read-only\n" }
665 substr $Config_SH_expanded, 1, $config_sh_len;
670 return map { chomp; $_ } grep eval{ /^(?:$re)=/ }, split /^/,
675 # implements -V:cfgvar option (see perlrun -V:)
677 # find optional leading, trailing colons; and query-spec
678 my ($notag,$qry,$lncont) = m/^(:)?(.*?)(:)?$/; # flags fore and aft,
679 # map colon-flags to print decorations
680 my $prfx = $notag ? '': "$qry="; # tag-prefix for print
681 my $lnend = $lncont ? ' ' : ";\n"; # line ending for print
683 # all config-vars are by definition \w only, any \W means regex
685 my @matches = config_re($qry);
686 print map "$_$lnend", @matches ? @matches : "$qry: not found" if !$notag;
687 print map { s/\w+=//; "$_$lnend" } @matches ? @matches : "$qry: not found" if $notag;
689 my $v = (exists $Config::Config{$qry}) ? $Config::Config{$qry}
691 $v = 'undef' unless defined $v;
692 print "${prfx}'${v}'$lnend";
697 # Called by the real AUTOLOAD
700 goto \&$Config::AUTOLOAD;
707 $config_txt .= <<'ENDOFSET';
710 my ($value, $v) = $Config_SH_expanded =~ m/^used_aout='(.*)'\s*$/m;
711 for (split ' ', $value) {
712 ($v) = $Config_SH_expanded =~ m/^aout_$_='(.*)'\s*$/m;
713 $preconfig{$_} = $v eq 'undef' ? undef : $v;
716 $preconfig{d_fork} = undef unless $OS2::can_fork; # Some funny cases can't
717 sub TIEHASH { bless {%preconfig} }
719 # Extract the name of the DLL from the makefile to avoid duplication
720 my ($f) = grep -r, qw(GNUMakefile Makefile);
722 if (open my $fh, '<', $f) {
724 $dll = $1, last if /^PERL_DLL_BASE\s*=\s*(\S*)\s*$/;
727 $config_txt .= <<ENDOFSET if $dll;
728 \$preconfig{dll_name} = '$dll';
731 $config_txt .= <<'ENDOFSET';
738 foreach my $key (keys %Common) {
739 my $value = fetch_string ({}, $key);
740 # Is it safe on the LHS of => ?
741 my $qkey = $key =~ /^[A-Za-z_][A-Za-z0-9_]*$/ ? $key : "'$key'";
742 if (defined $value) {
743 # Quote things for a '' string
744 $value =~ s!\\!\\\\!g;
747 if ($key eq 'otherlibdirs') {
748 $value = "join (':', map {relocate_inc(\$_)} split (':', $value))";
749 } elsif ($need_relocation{$key}) {
750 $value = "relocate_inc($value)";
755 $Common{$key} = "$qkey => $value";
758 if ($Common{byteorder}) {
759 $Common{byteorder} = 'byteorder => $byteorder';
761 my $fast_config = join '', map { " $_,\n" } sort values %Common;
763 # Sanity check needed to stop an infite loop if Config_heavy.pl fails to define
764 # &launcher for some reason (eg it got truncated)
765 $config_txt .= sprintf <<'ENDOFTIE', $fast_config;
770 require 'Config_heavy.pl';
771 goto \&launcher unless $Config::AUTOLOAD =~ /launcher$/;
772 die "&Config::AUTOLOAD failed on $Config::AUTOLOAD";
775 # tie returns the object, so the value returned to require will be true.
776 tie %%Config, 'Config', {
781 open(CONFIG_POD, ">$Config_POD") or die "Can't open $Config_POD: $!";
782 print CONFIG_POD <<'ENDOFTAIL';
785 Config - access Perl configuration information
790 if ($Config{usethreads}) {
791 print "has thread support\n"
794 use Config qw(myconfig config_sh config_vars config_re);
802 config_vars(qw(osname archname));
807 The Config module contains all the information that was available to
808 the C<Configure> program at Perl build time (over 900 values).
810 Shell variables from the F<config.sh> file (written by Configure) are
811 stored in the readonly-variable C<%Config>, indexed by their names.
813 Values stored in config.sh as 'undef' are returned as undefined
814 values. The perl C<exists> function can be used to check if a
815 named variable exists.
817 For a description of the variables, please have a look at the
818 Glossary file, as written in the Porting folder, or use the url:
819 http://perl5.git.perl.org/perl.git/blob/HEAD:/Porting/Glossary
825 Returns a textual summary of the major perl configuration values.
826 See also C<-V> in L<perlrun/Switches>.
830 Returns the entire perl configuration information in the form of the
831 original config.sh shell variable assignment script.
833 =item config_re($regex)
835 Like config_sh() but returns, as a list, only the config entries who's
836 names match the $regex.
838 =item config_vars(@names)
840 Prints to STDOUT the values of the named configuration variable. Each is
841 printed on a separate line in the form:
845 Names which are unknown are output as C<name='UNKNOWN';>.
846 See also C<-V:name> in L<perlrun/Switches>.
852 Here's a more sophisticated example of using %Config:
859 unless($Config{sig_name} && $Config{sig_num}) {
862 my @names = split ' ', $Config{sig_name};
863 @sig_num{@names} = split ' ', $Config{sig_num};
865 $sig_name[$sig_num{$_}] ||= $_;
869 print "signal #17 = $sig_name[17]\n";
870 if ($sig_num{ALRM}) {
871 print "SIGALRM is $sig_num{ALRM}\n";
876 Because this information is not stored within the perl executable
877 itself it is possible (but unlikely) that the information does not
878 relate to the actual perl binary which is being used to access it.
880 The Config module is installed into the architecture and version
881 specific library directory ($Config{installarchlib}) and it checks the
882 perl version number when loaded.
884 The values stored in config.sh may be either single-quoted or
885 double-quoted. Double-quoted strings are handy for those cases where you
886 need to include escape sequences in the strings. To avoid runtime variable
887 interpolation, any C<$> and C<@> characters are replaced by C<\$> and
888 C<\@>, respectively. This isn't foolproof, of course, so don't embed C<\$>
889 or C<\@> in double-quoted strings unless you're willing to deal with the
890 consequences. (The slashes will end up escaped and the C<$> or C<@> will
891 trigger variable interpolation)
895 Most C<Config> variables are determined by the C<Configure> script
896 on platforms supported by it (which is most UNIX platforms). Some
897 platforms have custom-made C<Config> variables, and may thus not have
898 some of the variables described below, or may have extraneous variables
899 specific to that particular port. See the port specific documentation
906 if ($Opts{glossary}) {
907 open(GLOS, "<$Glossary") or die "Can't open $Glossary: $!";
914 if (s/\A(\w*)\s+\(([\w.]+)\):\s*\n(\t?)/=item C<$1>\n\nFrom F<$2>:\n\n/m) {
915 my $c = substr $1, 0, 1;
916 unless ($seen{$c}++) {
917 print CONFIG_POD <<EOF if $text;
923 print CONFIG_POD <<EOF;
934 elsif (!$text || !/\A\t/) {
935 warn "Expected a Configure variable header",
936 ($text ? " or another paragraph of description" : () );
938 s/n't/n\00t/g; # leave can't, won't etc untouched
939 s/^\t\s+(.*)/\n$1/gm; # Indented lines ===> new paragraph
940 s/^(?<!\n\n)\t(.*)/$1/gm; # Not indented lines ===> text
941 s{([\'\"])(?=[^\'\"\s]*[./][^\'\"\s]*\1)([^\'\"\s]+)\1}(F<$2>)g; # '.o'
942 s{([\'\"])([^\'\"\s]+)\1}(C<$2>)g; # "date" command
943 s{\'([A-Za-z_\- *=/]+)\'}(C<$1>)g; # 'ln -s'
945 (?<! [\w./<\'\"] ) # Only standalone file names
946 (?! e \. g \. ) # Not e.g.
947 (?! \. \. \. ) # Not ...
949 (?! read/ ) # Not read/write
950 (?! etc\. ) # Not etc.
953 \$ ? # Allow leading $
954 [\w./]* [./] [\w./]* # Require . or / inside
956 (?<! \. (?= [\s)] ) ) # Do not include trailing dot
957 (?! [\w/] ) # Include all of it
959 (F<$1>)xg; # /usr/local
960 s/((?<=\s)~\w*)/F<$1>/g; # ~name
961 s/(?<![.<\'\"])\b([A-Z_]{2,})\b(?![\'\"])/C<$1>/g; # UNISTD
962 s/(?<![.<\'\"])\b(?!the\b)(\w+)\s+macro\b/C<$1> macro/g; # FILE_cnt macro
963 s/n[\0]t/n't/g; # undo can't, won't damage
966 if ($Opts{glossary}) {
967 <GLOS>; # Skip the "DO NOT EDIT"
968 <GLOS>; # Skip the preamble
975 print CONFIG_POD <<'ENDOFTAIL';
981 Information on the git commit from which the current perl binary was compiled
982 can be found in the variable C<$Config::Git_Data>. The variable is a
983 structured string that looks something like this:
985 git_commit_id='ea0c2dbd5f5ac6845ecc7ec6696415bf8e27bd52'
986 git_describe='GitLive-blead-1076-gea0c2db'
987 git_branch='smartmatch'
988 git_uncommitted_changes=''
989 git_commit_id_title='Commit id:'
990 git_commit_date='2009-05-09 17:47:31 +0200'
992 Its format is not guaranteed not to change over time.
996 This module contains a good example of how to use tie to implement a
997 cache and an example of how to make a tied variable readonly to those
1004 close(GLOS) if $Opts{glossary};
1006 print "written $Config_POD\n";
1008 my $orig_config_txt = "";
1009 my $orig_heavy_txt = "";
1013 $orig_config_txt = <$fh> if open $fh, "<", $Config_PM;
1014 $orig_heavy_txt = <$fh> if open $fh, "<", $Config_heavy;
1017 if ($orig_config_txt ne $config_txt or $orig_heavy_txt ne $heavy_txt) {
1018 open CONFIG, ">", $Config_PM or die "Can't open $Config_PM: $!\n";
1019 open CONFIG_HEAVY, ">", $Config_heavy or die "Can't open $Config_heavy: $!\n";
1020 print CONFIG $config_txt;
1021 print CONFIG_HEAVY $heavy_txt;
1022 close(CONFIG_HEAVY);
1024 print "updated $Config_PM\n";
1025 print "updated $Config_heavy\n";
1029 # Now create Cross.pm if needed
1031 open CROSS, ">lib/Cross.pm" or die "Can not open >lib/Cross.pm: $!";
1032 my $cross = <<'EOS';
1033 # typical invocation:
1034 # perl -MCross Makefile.PL
1035 # perl -MCross=wince -V:cc
1039 my ($package,$platform) = @_;
1040 unless (defined $platform) {
1041 # if $platform is not specified, then use last one when
1042 # 'configpm; was invoked with --cross option
1043 $platform = '***replace-marker***';
1045 @INC = map {/\blib\b/?(do{local $_=$_;s/\blib\b/xlib\/$platform/;$_},$_):($_)} @INC;
1046 $::Cross::platform = $platform;
1051 $cross =~ s/\*\*\*replace-marker\*\*\*/$Opts{cross}/g;
1054 print "written lib/Cross.pm\n";
1055 unshift(@INC,"xlib/$Opts{cross}");
1058 # Now do some simple tests on the Config.pm file we have created
1059 unshift(@INC,'lib');
1060 unshift(@INC,'xlib/symbian') if $Opts{cross};
1062 require $Config_heavy;
1065 die "$0: $Config_PM not valid"
1066 unless $Config{'PERL_CONFIG_SH'} eq 'true';
1068 die "$0: error processing $Config_PM"
1069 if defined($Config{'an impossible name'})
1070 or $Config{'PERL_CONFIG_SH'} ne 'true' # test cache
1073 die "$0: error processing $Config_PM"
1074 if eval '$Config{"cc"} = 1'
1075 or eval 'delete $Config{"cc"}'
1080 # Popularity of various entries in %Config, based on a large build and test
1081 # run of code in the Fotango build system:
1099 inc_version_list: 783
1102 usevendorprefix: 642
1123 installsiteman1dir: 489
1124 installsiteman3dir: 489
1125 installvendorman1dir: 489
1126 installvendorman3dir: 489
1130 installsitearch: 344
1135 installprefixexp: 336
1138 installvendorarch: 336
1139 installvendorbin: 336
1140 installvendorlib: 336