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
131 sub bincompat_options {
132 return sort split ' ', (Internals::V())[0];
135 sub non_bincompat_options {
136 return sort split ' ', (Internals::V())[1];
140 return (Internals::V())[2]
144 my (undef, undef, undef, @patches) = Internals::V();
149 my ($bincompat, $non_bincompat, $date, @patches) = Internals::V();
151 my $opts = join ' ', sort split ' ', "$bincompat $non_bincompat";
153 # wrap at 76 columns.
155 $opts =~ s/(?=.{53})(.{1,53}) /$1\n /mg;
157 print Config::myconfig();
159 print "\nCharacteristics of this PERLSHR image: \n";
161 print "\nCharacteristics of this binary (from libperl): \n";
164 print " Compile-time options: $opts\n";
167 print " Locally applied patches:\n";
168 print "\t$_\n" foreach @patches;
171 print " Built under $^O\n";
173 print " $date\n" if defined $date;
175 my @env = map { "$_=\"$ENV{$_}\"" } sort grep {/^PERL/} keys %ENV;
176 push @env, "CYGWIN=\"$ENV{CYGWIN}\"" if $^O eq 'cygwin';
180 print " $_\n" foreach @env;
183 print " $_\n" foreach @INC;
188 my $export_funcs = <<'EOT';
189 my %Export_Cache = (myconfig => 1,
190 config_sh => 1, config_vars => 1, config_re => 1,
191 bincompat_options => 1, non_bincompat_options => 1,
192 compile_date => 1, local_patches => 1);
195 my %export_ok = eval $export_funcs or die;
197 $config_txt .= sprintf << 'EOT', $export_funcs;
198 # This file was created by configpm when Perl was built. Any changes
199 # made to this file will be lost the next time perl is built.
201 # for a description of the variables, please have a look at the
202 # Glossary file, as written in the Porting folder, or use the url:
203 # http://perl5.git.perl.org/perl.git/blob/HEAD:/Porting/Glossary
207 # use warnings; Pulls in Carp
208 # use vars pulls in Carp
210 # Skip @Config::EXPORT because it only contains %%Config, which we special
211 # case below as it's not a function. @Config::EXPORT won't change in the
212 # lifetime of Perl 5.
214 @Config::EXPORT = qw(%%Config);
215 @Config::EXPORT_OK = keys %%Export_Cache;
217 # Need to stub all the functions to make code such as print Config::config_sh
222 $config_txt .= "sub $_;\n" foreach sort keys %export_ok;
224 my $myver = sprintf "%vd", $^V;
226 $config_txt .= sprintf <<'ENDOFBEG', ($myver) x 3;
229 # Define our own import method to avoid pulling in the full Exporter:
232 @_ = @Config::EXPORT unless @_;
234 my @funcs = grep $_ ne '%%Config', @_;
235 my $export_Config = @funcs < @_ ? 1 : 0;
238 my $callpkg = caller(0);
239 foreach my $func (@funcs) {
240 die qq{"$func" is not exported by the Config module\n}
241 unless $Export_Cache{$func};
242 *{$callpkg.'::'.$func} = \&{$func};
245 *{"$callpkg\::Config"} = \%%Config if $export_Config;
249 die "Perl lib version (%s) doesn't match executable '$0' version ($])"
253 or die "Perl lib version (%s) doesn't match executable '$0' version (" .
254 sprintf("v%%vd",$^V) . ")";
268 open(CONFIG_SH, $Config_SH) || die "Can't open $Config_SH: $!";
269 while (<CONFIG_SH>) {
270 next if m:^#!/bin/sh:;
272 # Catch PERL_CONFIG_SH=true and PERL_VERSION=n line from Configure.
273 s/^(\w+)=(true|\d+)\s*$/$1='$2'\n/ or m/^(\w+)='(.*)'$/;
274 my($k, $v) = ($1, $2);
276 # grandfather PATCHLEVEL and SUBVERSION and CONFIG
278 if ($k eq 'PERL_VERSION') {
279 push @v_others, "PATCHLEVEL='$v'\n";
281 elsif ($k eq 'PERL_SUBVERSION') {
282 push @v_others, "SUBVERSION='$v'\n";
284 elsif ($k eq 'PERL_CONFIG_SH') {
285 push @v_others, "CONFIG='$v'\n";
289 # We can delimit things in config.sh with either ' or ".
290 unless ($in_v or m/^(\w+)=(['"])(.*\n)/){
291 push(@non_v, "#$_"); # not a name='value' line
299 ($name,$val) = ($1,$3);
301 $in_v = $val !~ /$quote\n/;
304 s,/,::,g if $Extensions{$name};
306 $val =~ s/$quote\n?\z//;
308 my $line = "$name=$quote$val$quote\n";
309 push(@v_others, $line);
310 $seen_quotes{$quote}++;
315 # This is somewhat grim, but I want the code for parsing config.sh here and
316 # now so that I can expand $Config{ivsize} and $Config{ivtype}
318 my $fetch_string = <<'EOT';
320 # Search for it in the big string
322 my($self, $key) = @_;
326 if ($seen_quotes{'"'}) {
327 # We need the full ' and " code
329 $fetch_string .= <<'EOT';
330 return undef unless my ($quote_type, $value) = $Config_SH_expanded =~ /\n$key=(['"])(.*?)\1\n/s;
332 # If we had a double-quote, we'd better eval it so escape
333 # sequences and such can be interpolated. Since the incoming
334 # value is supposed to follow shell rules and not perl rules,
335 # we escape any perl variable markers
337 # Historically, since " 'support' was added in change 1409, the
338 # interpolation was done before the undef. Stick to this arguably buggy
339 # behaviour as we're refactoring.
340 if ($quote_type eq '"') {
341 $value =~ s/\$/\\\$/g;
342 $value =~ s/\@/\\\@/g;
343 eval "\$value = \"$value\"";
346 # So we can say "if $Config{'foo'}".
347 $self->{$key} = $value eq 'undef' ? undef : $value; # cache it
352 # We only have ' delimted.
354 $fetch_string .= <<'EOT';
355 return undef unless $Config_SH_expanded =~ /\n$key=\'(.*?)\'\n/s;
356 # So we can say "if $Config{'foo'}".
357 $self->{$key} = $1 eq 'undef' ? undef : $1;
366 # Calculation for the keys for byteorder
367 # This is somewhat grim, but I need to run fetch_string here.
368 our $Config_SH_expanded = join "\n", '', @v_others;
370 my $t = fetch_string ({}, 'ivtype');
371 my $s = fetch_string ({}, 'ivsize');
373 # byteorder does exist on its own but we overlay a virtual
374 # dynamically recomputed value.
376 # However, ivtype and ivsize will not vary for sane fat binaries
378 my $f = $t eq 'long' ? 'L!' : $s == 8 ? 'Q': 'I';
381 if ($s == 4 || $s == 8) {
382 my $list = join ',', reverse(2..$s);
384 $byteorder_code = <<"EOT";
387 foreach my \$c ($list) { \$i |= ord(\$c); \$i <<= 8 }
389 our \$byteorder = join('', unpack('$format', pack('$f', \$i)));
392 $byteorder_code = "our \$byteorder = '?'x$s;\n";
397 if (fetch_string({},'userelocatableinc')) {
398 foreach my $what (qw(prefixexp
447 installvendorhtml1dir
448 installvendorhtml3dir
454 push @need_relocation, $what if fetch_string({}, $what) =~ m!^\.\.\./!;
459 @need_relocation{@need_relocation} = @need_relocation;
461 # This can have .../ anywhere:
462 if (fetch_string({}, 'otherlibdirs') =~ m!\.\.\./!) {
463 $need_relocation{otherlibdirs} = 'otherlibdirs';
466 my $relocation_code = <<'EOT';
470 return $libdir unless $libdir =~ s!^\.\.\./!!;
472 if ($prefix =~ s!/[^/]*$!!) {
473 while ($libdir =~ m!^\.\./!) {
474 # Loop while $libdir starts "../" and $prefix still has a trailing
476 last unless $prefix =~ s!/([^/]+)$!!;
477 # but bail out if the directory we picked off the end of $prefix is .
479 if ($1 eq '.' or $1 eq '..') {
480 # Undo! This should be rare, hence code it this way rather than a
481 # check each time before the s!!! above.
482 $prefix = "$prefix/$1";
485 # Remove that leading ../ and loop again
486 substr ($libdir, 0, 3, '');
488 $libdir = "$prefix/$libdir";
494 if (%need_relocation) {
495 my $relocations_in_common;
496 # otherlibdirs only features in the hash
497 foreach (keys %need_relocation) {
498 $relocations_in_common++ if $Common{$_};
500 if ($relocations_in_common) {
501 $config_txt .= $relocation_code;
503 $heavy_txt .= $relocation_code;
507 $heavy_txt .= join('', @non_v) . "\n";
509 # copy config summary format from the myconfig.SH script
510 $heavy_txt .= "our \$summary = <<'!END!';\n";
511 open(MYCONFIG,"<myconfig.SH") || die "open myconfig.SH failed: $!";
512 1 while defined($_ = <MYCONFIG>) && !/^Summary of/;
513 do { $heavy_txt .= $_ } until !defined($_ = <MYCONFIG>) || /^\s*$/;
516 $heavy_txt .= "\n!END!\n" . <<'EOT';
517 my $summary_expanded;
520 return $summary_expanded if $summary_expanded;
521 ($summary_expanded = $summary) =~ s{\$(\w+)}
524 if ($1 eq 'git_ancestor_line') {
525 if ($Config::Config{git_ancestor}) {
526 $c= "\n Ancestor: $Config::Config{git_ancestor}";
531 $c = $Config::Config{$1};
533 defined($c) ? $c : 'undef'
542 $heavy_txt .= join('', sort @v_others) . "!END!\n";
544 # Only need the dynamic byteorder code in Config.pm if 'byteorder' is one of
546 if ($Common{byteorder}) {
547 $config_txt .= $byteorder_code;
549 $heavy_txt .= $byteorder_code;
552 if (@need_relocation) {
553 $heavy_txt .= 'foreach my $what (qw(' . join (' ', @need_relocation) .
555 s/^($what=)(['"])(.*?)\2/$1 . $2 . relocate_inc($3) . $2/me;
558 # Currently it only makes sense to do the ... relocation on Unix, so there's
559 # no need to emulate the "which separator for this platform" logic in perl.c -
560 # ':' will always be applicable
561 if ($need_relocation{otherlibdirs}) {
562 $heavy_txt .= << 'EOT';
563 s{^(otherlibdirs=)(['"])(.*?)\2}
564 {$1 . $2 . join ':', map {relocate_inc($_)} split ':', $3 . $2}me;
569 $heavy_txt .= <<'EOT';
570 s/(byteorder=)(['"]).*?\2/$1$2$Config::byteorder$2/m;
572 my $config_sh_len = length $_;
574 our $Config_SH_expanded = "\n$_" . << 'EOVIRTUAL';
577 foreach my $prefix (qw(ccflags ldflags)) {
578 my $value = fetch_string ({}, $prefix);
579 my $withlargefiles = fetch_string ({}, $prefix . "_uselargefiles");
580 if (defined $withlargefiles) {
581 $value =~ s/\Q$withlargefiles\E\b//;
582 $heavy_txt .= "${prefix}_nolargefiles='$value'\n";
586 foreach my $prefix (qw(libs libswanted)) {
587 my $value = fetch_string ({}, $prefix);
588 my $withlf = fetch_string ({}, 'libswanted_uselargefiles');
589 next unless defined $withlf;
591 = split(' ', fetch_string ({}, 'libswanted_uselargefiles'));
594 @lflibswanted{@lflibswanted} = ();
595 if ($prefix eq 'libs') {
596 my @libs = grep { /^-l(.+)/ &&
597 not exists $lflibswanted{$1} }
598 split(' ', fetch_string ({}, 'libs'));
599 $value = join(' ', @libs);
601 my @libswanted = grep { not exists $lflibswanted{$_} }
602 split(' ', fetch_string ({}, 'libswanted'));
603 $value = join(' ', @libswanted);
606 $heavy_txt .= "${prefix}_nolargefiles='$value'\n";
609 $heavy_txt .= "EOVIRTUAL\n";
611 $heavy_txt .= <<'ENDOFGIT';
613 # do not have hairy conniptions if this isnt available
614 require 'Config_git.pl';
615 $Config_SH_expanded .= $Config::Git_Data;
617 } or warn "Warning: failed to load Config_git.pl, something strange about this perl...\n";
620 $heavy_txt .= $fetch_string;
622 $config_txt .= <<'ENDOFEND';
625 my($self, $key) = @_;
627 # check for cached value (which may be undef so we use exists not defined)
628 return $self->{$key} if exists $self->{$key};
630 return $self->fetch_string($key);
634 $heavy_txt .= <<'ENDOFEND';
640 substr($Config_SH_expanded, 1, index($Config_SH_expanded, '=') - 1 );
645 if ($seen_quotes{'"'}) {
646 $heavy_txt .= <<'ENDOFEND';
647 # Find out how the current key's quoted so we can skip to its end.
648 my $quote = substr($Config_SH_expanded,
649 index($Config_SH_expanded, "=", $prevpos)+1, 1);
650 my $pos = index($Config_SH_expanded, qq($quote\n), $prevpos) + 2;
653 # Just ' quotes, so it's much easier.
654 $heavy_txt .= <<'ENDOFEND';
655 my $pos = index($Config_SH_expanded, qq('\n), $prevpos) + 2;
658 $heavy_txt .= <<'ENDOFEND';
659 my $len = index($Config_SH_expanded, "=", $pos) - $pos;
661 $len > 0 ? substr($Config_SH_expanded, $pos, $len) : undef;
665 return 1 if exists($_[0]->{$_[1]});
667 return(index($Config_SH_expanded, "\n$_[1]='") != -1
669 if ($seen_quotes{'"'}) {
670 $heavy_txt .= <<'ENDOFEND';
671 or index($Config_SH_expanded, "\n$_[1]=\"") != -1
674 $heavy_txt .= <<'ENDOFEND';
678 sub STORE { die "\%Config::Config is read-only\n" }
684 substr $Config_SH_expanded, 1, $config_sh_len;
689 return map { chomp; $_ } grep eval{ /^(?:$re)=/ }, split /^/,
694 # implements -V:cfgvar option (see perlrun -V:)
696 # find optional leading, trailing colons; and query-spec
697 my ($notag,$qry,$lncont) = m/^(:)?(.*?)(:)?$/; # flags fore and aft,
698 # map colon-flags to print decorations
699 my $prfx = $notag ? '': "$qry="; # tag-prefix for print
700 my $lnend = $lncont ? ' ' : ";\n"; # line ending for print
702 # all config-vars are by definition \w only, any \W means regex
704 my @matches = config_re($qry);
705 print map "$_$lnend", @matches ? @matches : "$qry: not found" if !$notag;
706 print map { s/\w+=//; "$_$lnend" } @matches ? @matches : "$qry: not found" if $notag;
708 my $v = (exists $Config::Config{$qry}) ? $Config::Config{$qry}
710 $v = 'undef' unless defined $v;
711 print "${prfx}'${v}'$lnend";
716 # Called by the real AUTOLOAD
719 goto \&$Config::AUTOLOAD;
726 $config_txt .= <<'ENDOFSET';
729 my ($value, $v) = $Config_SH_expanded =~ m/^used_aout='(.*)'\s*$/m;
730 for (split ' ', $value) {
731 ($v) = $Config_SH_expanded =~ m/^aout_$_='(.*)'\s*$/m;
732 $preconfig{$_} = $v eq 'undef' ? undef : $v;
735 $preconfig{d_fork} = undef unless $OS2::can_fork; # Some funny cases can't
736 sub TIEHASH { bless {%preconfig} }
738 # Extract the name of the DLL from the makefile to avoid duplication
739 my ($f) = grep -r, qw(GNUMakefile Makefile);
741 if (open my $fh, '<', $f) {
743 $dll = $1, last if /^PERL_DLL_BASE\s*=\s*(\S*)\s*$/;
746 $config_txt .= <<ENDOFSET if $dll;
747 \$preconfig{dll_name} = '$dll';
750 $config_txt .= <<'ENDOFSET';
757 foreach my $key (keys %Common) {
758 my $value = fetch_string ({}, $key);
759 # Is it safe on the LHS of => ?
760 my $qkey = $key =~ /^[A-Za-z_][A-Za-z0-9_]*$/ ? $key : "'$key'";
761 if (defined $value) {
762 # Quote things for a '' string
763 $value =~ s!\\!\\\\!g;
766 if ($key eq 'otherlibdirs') {
767 $value = "join (':', map {relocate_inc(\$_)} split (':', $value))";
768 } elsif ($need_relocation{$key}) {
769 $value = "relocate_inc($value)";
774 $Common{$key} = "$qkey => $value";
777 if ($Common{byteorder}) {
778 $Common{byteorder} = 'byteorder => $byteorder';
780 my $fast_config = join '', map { " $_,\n" } sort values %Common;
782 # Sanity check needed to stop an infite loop if Config_heavy.pl fails to define
783 # &launcher for some reason (eg it got truncated)
784 $config_txt .= sprintf <<'ENDOFTIE', $fast_config;
789 require 'Config_heavy.pl';
790 goto \&launcher unless $Config::AUTOLOAD =~ /launcher$/;
791 die "&Config::AUTOLOAD failed on $Config::AUTOLOAD";
794 # tie returns the object, so the value returned to require will be true.
795 tie %%Config, 'Config', {
800 open(CONFIG_POD, ">$Config_POD") or die "Can't open $Config_POD: $!";
801 print CONFIG_POD <<'ENDOFTAIL';
804 Config - access Perl configuration information
809 if ($Config{usethreads}) {
810 print "has thread support\n"
813 use Config qw(myconfig config_sh config_vars config_re);
821 config_vars(qw(osname archname));
826 The Config module contains all the information that was available to
827 the C<Configure> program at Perl build time (over 900 values).
829 Shell variables from the F<config.sh> file (written by Configure) are
830 stored in the readonly-variable C<%Config>, indexed by their names.
832 Values stored in config.sh as 'undef' are returned as undefined
833 values. The perl C<exists> function can be used to check if a
834 named variable exists.
836 For a description of the variables, please have a look at the
837 Glossary file, as written in the Porting folder, or use the url:
838 http://perl5.git.perl.org/perl.git/blob/HEAD:/Porting/Glossary
844 Returns a textual summary of the major perl configuration values.
845 See also C<-V> in L<perlrun/Switches>.
849 Returns the entire perl configuration information in the form of the
850 original config.sh shell variable assignment script.
852 =item config_re($regex)
854 Like config_sh() but returns, as a list, only the config entries who's
855 names match the $regex.
857 =item config_vars(@names)
859 Prints to STDOUT the values of the named configuration variable. Each is
860 printed on a separate line in the form:
864 Names which are unknown are output as C<name='UNKNOWN';>.
865 See also C<-V:name> in L<perlrun/Switches>.
867 =item bincompat_options()
869 Returns a list of C pre-processor options used when compiling this F<perl>
870 binary, which affect its binary compatibility with extensions.
871 C<bincompat_options()> and C<non_bincompat_options()> are shown together in
872 the output of C<perl -V> as I<Compile-time options>.
874 =item non_bincompat_options()
876 Returns a list of C pre-processor options used when compiling this F<perl>
877 binary, which do not affect binary compatibility with extensions.
881 Returns the compile date (as a string), equivalent to what is shown by
884 =item local_patches()
886 Returns a list of the names of locally applied patches, equivalent to what
887 is shown by C<perl -V>.
893 Here's a more sophisticated example of using %Config:
900 unless($Config{sig_name} && $Config{sig_num}) {
903 my @names = split ' ', $Config{sig_name};
904 @sig_num{@names} = split ' ', $Config{sig_num};
906 $sig_name[$sig_num{$_}] ||= $_;
910 print "signal #17 = $sig_name[17]\n";
911 if ($sig_num{ALRM}) {
912 print "SIGALRM is $sig_num{ALRM}\n";
917 Because this information is not stored within the perl executable
918 itself it is possible (but unlikely) that the information does not
919 relate to the actual perl binary which is being used to access it.
921 The Config module is installed into the architecture and version
922 specific library directory ($Config{installarchlib}) and it checks the
923 perl version number when loaded.
925 The values stored in config.sh may be either single-quoted or
926 double-quoted. Double-quoted strings are handy for those cases where you
927 need to include escape sequences in the strings. To avoid runtime variable
928 interpolation, any C<$> and C<@> characters are replaced by C<\$> and
929 C<\@>, respectively. This isn't foolproof, of course, so don't embed C<\$>
930 or C<\@> in double-quoted strings unless you're willing to deal with the
931 consequences. (The slashes will end up escaped and the C<$> or C<@> will
932 trigger variable interpolation)
936 Most C<Config> variables are determined by the C<Configure> script
937 on platforms supported by it (which is most UNIX platforms). Some
938 platforms have custom-made C<Config> variables, and may thus not have
939 some of the variables described below, or may have extraneous variables
940 specific to that particular port. See the port specific documentation
947 if ($Opts{glossary}) {
948 open(GLOS, "<$Glossary") or die "Can't open $Glossary: $!";
955 if (s/\A(\w*)\s+\(([\w.]+)\):\s*\n(\t?)/=item C<$1>\n\nFrom F<$2>:\n\n/m) {
956 my $c = substr $1, 0, 1;
957 unless ($seen{$c}++) {
958 print CONFIG_POD <<EOF if $text;
964 print CONFIG_POD <<EOF;
975 elsif (!$text || !/\A\t/) {
976 warn "Expected a Configure variable header",
977 ($text ? " or another paragraph of description" : () );
979 s/n't/n\00t/g; # leave can't, won't etc untouched
980 s/^\t\s+(.*)/\n$1/gm; # Indented lines ===> new paragraph
981 s/^(?<!\n\n)\t(.*)/$1/gm; # Not indented lines ===> text
982 s{([\'\"])(?=[^\'\"\s]*[./][^\'\"\s]*\1)([^\'\"\s]+)\1}(F<$2>)g; # '.o'
983 s{([\'\"])([^\'\"\s]+)\1}(C<$2>)g; # "date" command
984 s{\'([A-Za-z_\- *=/]+)\'}(C<$1>)g; # 'ln -s'
986 (?<! [\w./<\'\"] ) # Only standalone file names
987 (?! e \. g \. ) # Not e.g.
988 (?! \. \. \. ) # Not ...
990 (?! read/ ) # Not read/write
991 (?! etc\. ) # Not etc.
994 \$ ? # Allow leading $
995 [\w./]* [./] [\w./]* # Require . or / inside
997 (?<! \. (?= [\s)] ) ) # Do not include trailing dot
998 (?! [\w/] ) # Include all of it
1000 (F<$1>)xg; # /usr/local
1001 s/((?<=\s)~\w*)/F<$1>/g; # ~name
1002 s/(?<![.<\'\"])\b([A-Z_]{2,})\b(?![\'\"])/C<$1>/g; # UNISTD
1003 s/(?<![.<\'\"])\b(?!the\b)(\w+)\s+macro\b/C<$1> macro/g; # FILE_cnt macro
1004 s/n[\0]t/n't/g; # undo can't, won't damage
1007 if ($Opts{glossary}) {
1008 <GLOS>; # Skip the "DO NOT EDIT"
1009 <GLOS>; # Skip the preamble
1016 print CONFIG_POD <<'ENDOFTAIL';
1022 Information on the git commit from which the current perl binary was compiled
1023 can be found in the variable C<$Config::Git_Data>. The variable is a
1024 structured string that looks something like this:
1026 git_commit_id='ea0c2dbd5f5ac6845ecc7ec6696415bf8e27bd52'
1027 git_describe='GitLive-blead-1076-gea0c2db'
1028 git_branch='smartmatch'
1029 git_uncommitted_changes=''
1030 git_commit_id_title='Commit id:'
1031 git_commit_date='2009-05-09 17:47:31 +0200'
1033 Its format is not guaranteed not to change over time.
1037 This module contains a good example of how to use tie to implement a
1038 cache and an example of how to make a tied variable readonly to those
1045 close(GLOS) if $Opts{glossary};
1047 print "written $Config_POD\n";
1049 my $orig_config_txt = "";
1050 my $orig_heavy_txt = "";
1054 $orig_config_txt = <$fh> if open $fh, "<", $Config_PM;
1055 $orig_heavy_txt = <$fh> if open $fh, "<", $Config_heavy;
1058 if ($orig_config_txt ne $config_txt or $orig_heavy_txt ne $heavy_txt) {
1059 open CONFIG, ">", $Config_PM or die "Can't open $Config_PM: $!\n";
1060 open CONFIG_HEAVY, ">", $Config_heavy or die "Can't open $Config_heavy: $!\n";
1061 print CONFIG $config_txt;
1062 print CONFIG_HEAVY $heavy_txt;
1063 close(CONFIG_HEAVY);
1065 print "updated $Config_PM\n";
1066 print "updated $Config_heavy\n";
1070 # Now create Cross.pm if needed
1072 open CROSS, ">lib/Cross.pm" or die "Can not open >lib/Cross.pm: $!";
1073 my $cross = <<'EOS';
1074 # typical invocation:
1075 # perl -MCross Makefile.PL
1076 # perl -MCross=wince -V:cc
1080 my ($package,$platform) = @_;
1081 unless (defined $platform) {
1082 # if $platform is not specified, then use last one when
1083 # 'configpm; was invoked with --cross option
1084 $platform = '***replace-marker***';
1086 @INC = map {/\blib\b/?(do{local $_=$_;s/\blib\b/xlib\/$platform/;$_},$_):($_)} @INC;
1087 $::Cross::platform = $platform;
1092 $cross =~ s/\*\*\*replace-marker\*\*\*/$Opts{cross}/g;
1095 print "written lib/Cross.pm\n";
1096 unshift(@INC,"xlib/$Opts{cross}");
1099 # Now do some simple tests on the Config.pm file we have created
1100 unshift(@INC,'lib');
1101 unshift(@INC,'xlib/symbian') if $Opts{cross};
1103 require $Config_heavy;
1106 die "$0: $Config_PM not valid"
1107 unless $Config{'PERL_CONFIG_SH'} eq 'true';
1109 die "$0: error processing $Config_PM"
1110 if defined($Config{'an impossible name'})
1111 or $Config{'PERL_CONFIG_SH'} ne 'true' # test cache
1114 die "$0: error processing $Config_PM"
1115 if eval '$Config{"cc"} = 1'
1116 or eval 'delete $Config{"cc"}'
1121 # Popularity of various entries in %Config, based on a large build and test
1122 # run of code in the Fotango build system:
1140 inc_version_list: 783
1143 usevendorprefix: 642
1164 installsiteman1dir: 489
1165 installsiteman3dir: 489
1166 installvendorman1dir: 489
1167 installvendorman3dir: 489
1171 installsitearch: 344
1176 installprefixexp: 336
1179 installvendorarch: 336
1180 installvendorbin: 336
1181 installvendorlib: 336