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 # names of things which may need to have slashes changed to double-colons
56 my %Extensions = map {($_,$_)}
57 qw(dynamic_ext static_ext extensions known_extensions);
59 # allowed opts as well as specifies default and initial values
61 'cross' => '', # --cross=PLATFORM - crosscompiling for PLATFORM
62 'glossary' => 1, # --no-glossary - no glossary file inclusion,
64 'chdir' => '', # --chdir=dir - change directory before writing files
68 # user specified options
71 (map {/^--([\-_\w]+)=(.*)$/} @ARGV),
72 # --opt --no-opt --noopt
73 (map {/^no-?(.*)$/i?($1=>0):($_=>1)} map {/^--([\-_\w]+)$/} @ARGV),
76 my %opts = (%Allowed_Opts, %given_opts);
78 for my $opt (grep {!exists $Allowed_Opts{$_}} keys %given_opts) {
79 warn "option '$opt' is not recognized";
82 @ARGV = grep {!/^--/} @ARGV;
91 chdir $Opts{chdir} or die "$0: could not chdir $Opts{chdir}: $!"
94 my ($Config_SH, $Config_PM, $Config_heavy, $Config_POD);
95 my $Glossary = 'Porting/Glossary';
98 # creating cross-platform config file
100 mkdir "xlib/$Opts{cross}";
101 $Config_PM = "xlib/$Opts{cross}/Config.pm";
102 $Config_POD = "xlib/$Opts{cross}/Config.pod";
103 $Config_SH = "Cross/config-$Opts{cross}.sh";
106 $Config_PM = "lib/Config.pm";
107 $Config_POD = "lib/Config.pod";
108 $Config_SH = "config.sh";
110 ($Config_heavy = $Config_PM) =~ s/\.pm$/_heavy.pl/;
111 die "Can't automatically determine name for Config_heavy.pl from '$Config_PM'"
112 if $Config_heavy eq $Config_PM;
117 $heavy_txt .= <<'ENDOFBEG';
118 # This file was created by configpm when Perl was built. Any changes
119 # made to this file will be lost the next time perl is built.
123 # use warnings; Pulls in Carp
124 # use vars pulls in Carp
127 my ($bincompat, $non_bincompat, $date, $osname, @patches) = Internals::V();
129 my $opts = join ' ', sort split ' ', "$bincompat $non_bincompat";
131 # wrap at 76 columns.
133 $opts =~ s/(?=.{53})(.{1,53}) /$1\n /mg;
135 print Config::myconfig();
137 print "\nCharacteristics of this PERLSHR image: \n";
139 print "\nCharacteristics of this binary (from libperl): \n";
142 print " Compile-time options: $opts\n";
145 print " Locally applied patches:\n";
146 print "\t$_\n" foreach @patches;
149 print " Built under $osname\n";
151 print " $date\n" if defined $date;
153 my @env = map { "$_=\"$ENV{$_}\"" } sort grep {/^PERL/} keys %ENV;
154 push @env, "CYGWIN=\"$ENV{CYGWIN}\"" if $^O eq 'cygwin';
158 print " $_\n" foreach @env;
161 print " $_\n" foreach @INC;
166 my $myver = sprintf "%vd", $^V;
168 $config_txt .= sprintf <<'ENDOFBEG', ($myver) x 3;
169 # This file was created by configpm when Perl was built. Any changes
170 # made to this file will be lost the next time perl is built.
172 # for a description of the variables, please have a look at the
173 # Glossary file, as written in the Porting folder, or use the url:
174 # http://perl5.git.perl.org/perl.git/blob/HEAD:/Porting/Glossary
178 # use warnings; Pulls in Carp
179 # use vars pulls in Carp
180 @Config::EXPORT = qw(%%Config);
181 @Config::EXPORT_OK = qw(myconfig config_sh config_vars config_re);
183 # Need to stub all the functions to make code such as print Config::config_sh
191 my %%Export_Cache = map {($_ => 1)} (@Config::EXPORT, @Config::EXPORT_OK);
195 # Define our own import method to avoid pulling in the full Exporter:
198 @_ = @Config::EXPORT unless @_;
200 my @funcs = grep $_ ne '%%Config', @_;
201 my $export_Config = @funcs < @_ ? 1 : 0;
204 my $callpkg = caller(0);
205 foreach my $func (@funcs) {
206 die sprintf qq{"%%s" is not exported by the %%s module\n},
207 $func, __PACKAGE__ unless $Export_Cache{$func};
208 *{$callpkg.'::'.$func} = \&{$func};
211 *{"$callpkg\::Config"} = \%%Config if $export_Config;
215 die "Perl lib version (%s) doesn't match executable version ($])"
219 or die "Perl lib version (%s) doesn't match executable version (" .
220 sprintf("v%%vd",$^V) . ")";
234 open(CONFIG_SH, $Config_SH) || die "Can't open $Config_SH: $!";
235 while (<CONFIG_SH>) {
236 next if m:^#!/bin/sh:;
238 # Catch PERL_CONFIG_SH=true and PERL_VERSION=n line from Configure.
239 s/^(\w+)=(true|\d+)\s*$/$1='$2'\n/ or m/^(\w+)='(.*)'$/;
240 my($k, $v) = ($1, $2);
242 # grandfather PATCHLEVEL and SUBVERSION and CONFIG
244 if ($k eq 'PERL_VERSION') {
245 push @v_others, "PATCHLEVEL='$v'\n";
247 elsif ($k eq 'PERL_SUBVERSION') {
248 push @v_others, "SUBVERSION='$v'\n";
250 elsif ($k eq 'PERL_CONFIG_SH') {
251 push @v_others, "CONFIG='$v'\n";
255 # We can delimit things in config.sh with either ' or ".
256 unless ($in_v or m/^(\w+)=(['"])(.*\n)/){
257 push(@non_v, "#$_"); # not a name='value' line
265 ($name,$val) = ($1,$3);
267 $in_v = $val !~ /$quote\n/;
270 s,/,::,g if $Extensions{$name};
272 $val =~ s/$quote\n?\z//;
274 my $line = "$name=$quote$val$quote\n";
275 push(@v_others, $line);
276 $seen_quotes{$quote}++;
281 # This is somewhat grim, but I want the code for parsing config.sh here and
282 # now so that I can expand $Config{ivsize} and $Config{ivtype}
284 my $fetch_string = <<'EOT';
286 # Search for it in the big string
288 my($self, $key) = @_;
292 if ($seen_quotes{'"'}) {
293 # We need the full ' and " code
294 $fetch_string .= <<'EOT';
295 my $quote_type = "'";
296 my $marker = "$key=";
298 # Check for the common case, ' delimited
299 my $start = index($Config_SH_expanded, "\n$marker$quote_type");
300 # If that failed, check for " delimited
303 $start = index($Config_SH_expanded, "\n$marker$quote_type");
307 $fetch_string .= <<'EOT';
308 # We only have ' delimted.
309 my $start = index($Config_SH_expanded, "\n$key=\'");
312 $fetch_string .= <<'EOT';
313 # Start can never be -1 now, as we've rigged the long string we're
314 # searching with an initial dummy newline.
315 return undef if $start == -1;
317 $start += length($key) + 3;
320 if (!$seen_quotes{'"'}) {
321 # Don't need the full ' and " code, or the eval expansion.
322 $fetch_string .= <<'EOT';
323 my $value = substr($Config_SH_expanded, $start,
324 index($Config_SH_expanded, "'\n", $start)
328 $fetch_string .= <<'EOT';
329 my $value = substr($Config_SH_expanded, $start,
330 index($Config_SH_expanded, "$quote_type\n", $start)
333 # If we had a double-quote, we'd better eval it so escape
334 # sequences and such can be interpolated. Since the incoming
335 # value is supposed to follow shell rules and not perl rules,
336 # we escape any perl variable markers
337 if ($quote_type eq '"') {
338 $value =~ s/\$/\\\$/g;
339 $value =~ s/\@/\\\@/g;
340 eval "\$value = \"$value\"";
344 $fetch_string .= <<'EOT';
345 # So we can say "if $Config{'foo'}".
346 $value = undef if $value eq 'undef';
347 $self->{$key} = $value; # cache it
354 # Calculation for the keys for byteorder
355 # This is somewhat grim, but I need to run fetch_string here.
356 our $Config_SH_expanded = join "\n", '', @v_others;
358 my $t = fetch_string ({}, 'ivtype');
359 my $s = fetch_string ({}, 'ivsize');
361 # byteorder does exist on its own but we overlay a virtual
362 # dynamically recomputed value.
364 # However, ivtype and ivsize will not vary for sane fat binaries
366 my $f = $t eq 'long' ? 'L!' : $s == 8 ? 'Q': 'I';
369 if ($s == 4 || $s == 8) {
370 my $list = join ',', reverse(2..$s);
372 $byteorder_code = <<"EOT";
375 foreach my \$c ($list) { \$i |= ord(\$c); \$i <<= 8 }
377 our \$byteorder = join('', unpack('$format', pack('$f', \$i)));
380 $byteorder_code = "our \$byteorder = '?'x$s;\n";
385 if (fetch_string({},'userelocatableinc')) {
386 foreach my $what (qw(prefixexp
435 installvendorhtml1dir
436 installvendorhtml3dir
442 push @need_relocation, $what if fetch_string({}, $what) =~ m!^\.\.\./!;
447 @need_relocation{@need_relocation} = @need_relocation;
449 # This can have .../ anywhere:
450 if (fetch_string({}, 'otherlibdirs') =~ m!\.\.\./!) {
451 $need_relocation{otherlibdirs} = 'otherlibdirs';
454 my $relocation_code = <<'EOT';
458 return $libdir unless $libdir =~ s!^\.\.\./!!;
460 if ($prefix =~ s!/[^/]*$!!) {
461 while ($libdir =~ m!^\.\./!) {
462 # Loop while $libdir starts "../" and $prefix still has a trailing
464 last unless $prefix =~ s!/([^/]+)$!!;
465 # but bail out if the directory we picked off the end of $prefix is .
467 if ($1 eq '.' or $1 eq '..') {
468 # Undo! This should be rare, hence code it this way rather than a
469 # check each time before the s!!! above.
470 $prefix = "$prefix/$1";
473 # Remove that leading ../ and loop again
474 substr ($libdir, 0, 3, '');
476 $libdir = "$prefix/$libdir";
482 if (%need_relocation) {
483 my $relocations_in_common;
484 # otherlibdirs only features in the hash
485 foreach (keys %need_relocation) {
486 $relocations_in_common++ if $Common{$_};
488 if ($relocations_in_common) {
489 $config_txt .= $relocation_code;
491 $heavy_txt .= $relocation_code;
495 $heavy_txt .= join('', @non_v) . "\n";
497 # copy config summary format from the myconfig.SH script
498 $heavy_txt .= "our \$summary = <<'!END!';\n";
499 open(MYCONFIG,"<myconfig.SH") || die "open myconfig.SH failed: $!";
500 1 while defined($_ = <MYCONFIG>) && !/^Summary of/;
501 do { $heavy_txt .= $_ } until !defined($_ = <MYCONFIG>) || /^\s*$/;
504 $heavy_txt .= "\n!END!\n" . <<'EOT';
505 my $summary_expanded;
508 return $summary_expanded if $summary_expanded;
509 ($summary_expanded = $summary) =~ s{\$(\w+)}
512 if ($1 eq 'git_ancestor_line') {
513 if ($Config::Config{git_ancestor}) {
514 $c= "\n Ancestor: $Config::Config{git_ancestor}";
519 $c = $Config::Config{$1};
521 defined($c) ? $c : 'undef'
530 $heavy_txt .= join('', sort @v_others) . "!END!\n";
532 # Only need the dynamic byteorder code in Config.pm if 'byteorder' is one of
534 if ($Common{byteorder}) {
535 $config_txt .= $byteorder_code;
537 $heavy_txt .= $byteorder_code;
540 if (@need_relocation) {
541 $heavy_txt .= 'foreach my $what (qw(' . join (' ', @need_relocation) .
543 s/^($what=)(['"])(.*?)\2/$1 . $2 . relocate_inc($3) . $2/me;
546 # Currently it only makes sense to do the ... relocation on Unix, so there's
547 # no need to emulate the "which separator for this platform" logic in perl.c -
548 # ':' will always be applicable
549 if ($need_relocation{otherlibdirs}) {
550 $heavy_txt .= << 'EOT';
551 s{^(otherlibdirs=)(['"])(.*?)\2}
552 {$1 . $2 . join ':', map {relocate_inc($_)} split ':', $3 . $2}me;
557 $heavy_txt .= <<'EOT';
558 s/(byteorder=)(['"]).*?\2/$1$2$Config::byteorder$2/m;
560 my $config_sh_len = length $_;
562 our $Config_SH_expanded = "\n$_" . << 'EOVIRTUAL';
565 foreach my $prefix (qw(ccflags ldflags)) {
566 my $value = fetch_string ({}, $prefix);
567 my $withlargefiles = fetch_string ({}, $prefix . "_uselargefiles");
568 if (defined $withlargefiles) {
569 $value =~ s/\Q$withlargefiles\E\b//;
570 $heavy_txt .= "${prefix}_nolargefiles='$value'\n";
574 foreach my $prefix (qw(libs libswanted)) {
575 my $value = fetch_string ({}, $prefix);
576 my $withlf = fetch_string ({}, 'libswanted_uselargefiles');
577 next unless defined $withlf;
579 = split(' ', fetch_string ({}, 'libswanted_uselargefiles'));
582 @lflibswanted{@lflibswanted} = ();
583 if ($prefix eq 'libs') {
584 my @libs = grep { /^-l(.+)/ &&
585 not exists $lflibswanted{$1} }
586 split(' ', fetch_string ({}, 'libs'));
587 $value = join(' ', @libs);
589 my @libswanted = grep { not exists $lflibswanted{$_} }
590 split(' ', fetch_string ({}, 'libswanted'));
591 $value = join(' ', @libswanted);
594 $heavy_txt .= "${prefix}_nolargefiles='$value'\n";
597 $heavy_txt .= "EOVIRTUAL\n";
599 $heavy_txt .= <<'ENDOFGIT';
601 # do not have hairy conniptions if this isnt available
602 require 'Config_git.pl';
603 $Config_SH_expanded .= $Config::Git_Data;
605 } or warn "Warning: failed to load Config_git.pl, something strange about this perl...\n";
608 $heavy_txt .= $fetch_string;
610 $config_txt .= <<'ENDOFEND';
613 my($self, $key) = @_;
615 # check for cached value (which may be undef so we use exists not defined)
616 return $self->{$key} if exists $self->{$key};
618 return $self->fetch_string($key);
622 $heavy_txt .= <<'ENDOFEND';
628 substr($Config_SH_expanded, 1, index($Config_SH_expanded, '=') - 1 );
633 if ($seen_quotes{'"'}) {
634 $heavy_txt .= <<'ENDOFEND';
635 # Find out how the current key's quoted so we can skip to its end.
636 my $quote = substr($Config_SH_expanded,
637 index($Config_SH_expanded, "=", $prevpos)+1, 1);
638 my $pos = index($Config_SH_expanded, qq($quote\n), $prevpos) + 2;
641 # Just ' quotes, so it's much easier.
642 $heavy_txt .= <<'ENDOFEND';
643 my $pos = index($Config_SH_expanded, qq('\n), $prevpos) + 2;
646 $heavy_txt .= <<'ENDOFEND';
647 my $len = index($Config_SH_expanded, "=", $pos) - $pos;
649 $len > 0 ? substr($Config_SH_expanded, $pos, $len) : undef;
653 return 1 if exists($_[0]->{$_[1]});
655 return(index($Config_SH_expanded, "\n$_[1]='") != -1
657 if ($seen_quotes{'"'}) {
658 $heavy_txt .= <<'ENDOFEND';
659 or index($Config_SH_expanded, "\n$_[1]=\"") != -1
662 $heavy_txt .= <<'ENDOFEND';
666 sub STORE { die "\%Config::Config is read-only\n" }
672 substr $Config_SH_expanded, 1, $config_sh_len;
677 return map { chomp; $_ } grep eval{ /^(?:$re)=/ }, split /^/,
682 # implements -V:cfgvar option (see perlrun -V:)
684 # find optional leading, trailing colons; and query-spec
685 my ($notag,$qry,$lncont) = m/^(:)?(.*?)(:)?$/; # flags fore and aft,
686 # map colon-flags to print decorations
687 my $prfx = $notag ? '': "$qry="; # tag-prefix for print
688 my $lnend = $lncont ? ' ' : ";\n"; # line ending for print
690 # all config-vars are by definition \w only, any \W means regex
692 my @matches = config_re($qry);
693 print map "$_$lnend", @matches ? @matches : "$qry: not found" if !$notag;
694 print map { s/\w+=//; "$_$lnend" } @matches ? @matches : "$qry: not found" if $notag;
696 my $v = (exists $Config::Config{$qry}) ? $Config::Config{$qry}
698 $v = 'undef' unless defined $v;
699 print "${prfx}'${v}'$lnend";
704 # Called by the real AUTOLOAD
707 goto \&$Config::AUTOLOAD;
714 $config_txt .= <<'ENDOFSET';
717 my ($value, $v) = $Config_SH_expanded =~ m/^used_aout='(.*)'\s*$/m;
718 for (split ' ', $value) {
719 ($v) = $Config_SH_expanded =~ m/^aout_$_='(.*)'\s*$/m;
720 $preconfig{$_} = $v eq 'undef' ? undef : $v;
723 $preconfig{d_fork} = undef unless $OS2::can_fork; # Some funny cases can't
724 sub TIEHASH { bless {%preconfig} }
726 # Extract the name of the DLL from the makefile to avoid duplication
727 my ($f) = grep -r, qw(GNUMakefile Makefile);
729 if (open my $fh, '<', $f) {
731 $dll = $1, last if /^PERL_DLL_BASE\s*=\s*(\S*)\s*$/;
734 $config_txt .= <<ENDOFSET if $dll;
735 \$preconfig{dll_name} = '$dll';
738 $config_txt .= <<'ENDOFSET';
745 foreach my $key (keys %Common) {
746 my $value = fetch_string ({}, $key);
747 # Is it safe on the LHS of => ?
748 my $qkey = $key =~ /^[A-Za-z_][A-Za-z0-9_]*$/ ? $key : "'$key'";
749 if (defined $value) {
750 # Quote things for a '' string
751 $value =~ s!\\!\\\\!g;
754 if ($key eq 'otherlibdirs') {
755 $value = "join (':', map {relocate_inc(\$_)} split (':', $value))";
756 } elsif ($need_relocation{$key}) {
757 $value = "relocate_inc($value)";
762 $Common{$key} = "$qkey => $value";
765 if ($Common{byteorder}) {
766 $Common{byteorder} = 'byteorder => $byteorder';
768 my $fast_config = join '', map { " $_,\n" } sort values %Common;
770 # Sanity check needed to stop an infite loop if Config_heavy.pl fails to define
771 # &launcher for some reason (eg it got truncated)
772 $config_txt .= sprintf <<'ENDOFTIE', $fast_config;
777 require 'Config_heavy.pl';
778 goto \&launcher unless $Config::AUTOLOAD =~ /launcher$/;
779 die "&Config::AUTOLOAD failed on $Config::AUTOLOAD";
782 # tie returns the object, so the value returned to require will be true.
783 tie %%Config, 'Config', {
788 open(CONFIG_POD, ">$Config_POD") or die "Can't open $Config_POD: $!";
789 print CONFIG_POD <<'ENDOFTAIL';
792 Config - access Perl configuration information
797 if ($Config{usethreads}) {
798 print "has thread support\n"
801 use Config qw(myconfig config_sh config_vars config_re);
809 config_vars(qw(osname archname));
814 The Config module contains all the information that was available to
815 the C<Configure> program at Perl build time (over 900 values).
817 Shell variables from the F<config.sh> file (written by Configure) are
818 stored in the readonly-variable C<%Config>, indexed by their names.
820 Values stored in config.sh as 'undef' are returned as undefined
821 values. The perl C<exists> function can be used to check if a
822 named variable exists.
824 For a description of the variables, please have a look at the
825 Glossary file, as written in the Porting folder, or use the url:
826 http://perl5.git.perl.org/perl.git/blob/HEAD:/Porting/Glossary
832 Returns a textual summary of the major perl configuration values.
833 See also C<-V> in L<perlrun/Switches>.
837 Returns the entire perl configuration information in the form of the
838 original config.sh shell variable assignment script.
840 =item config_re($regex)
842 Like config_sh() but returns, as a list, only the config entries who's
843 names match the $regex.
845 =item config_vars(@names)
847 Prints to STDOUT the values of the named configuration variable. Each is
848 printed on a separate line in the form:
852 Names which are unknown are output as C<name='UNKNOWN';>.
853 See also C<-V:name> in L<perlrun/Switches>.
859 Here's a more sophisticated example of using %Config:
866 unless($Config{sig_name} && $Config{sig_num}) {
869 my @names = split ' ', $Config{sig_name};
870 @sig_num{@names} = split ' ', $Config{sig_num};
872 $sig_name[$sig_num{$_}] ||= $_;
876 print "signal #17 = $sig_name[17]\n";
877 if ($sig_num{ALRM}) {
878 print "SIGALRM is $sig_num{ALRM}\n";
883 Because this information is not stored within the perl executable
884 itself it is possible (but unlikely) that the information does not
885 relate to the actual perl binary which is being used to access it.
887 The Config module is installed into the architecture and version
888 specific library directory ($Config{installarchlib}) and it checks the
889 perl version number when loaded.
891 The values stored in config.sh may be either single-quoted or
892 double-quoted. Double-quoted strings are handy for those cases where you
893 need to include escape sequences in the strings. To avoid runtime variable
894 interpolation, any C<$> and C<@> characters are replaced by C<\$> and
895 C<\@>, respectively. This isn't foolproof, of course, so don't embed C<\$>
896 or C<\@> in double-quoted strings unless you're willing to deal with the
897 consequences. (The slashes will end up escaped and the C<$> or C<@> will
898 trigger variable interpolation)
902 Most C<Config> variables are determined by the C<Configure> script
903 on platforms supported by it (which is most UNIX platforms). Some
904 platforms have custom-made C<Config> variables, and may thus not have
905 some of the variables described below, or may have extraneous variables
906 specific to that particular port. See the port specific documentation
913 if ($Opts{glossary}) {
914 open(GLOS, "<$Glossary") or die "Can't open $Glossary: $!";
921 if (s/\A(\w*)\s+\(([\w.]+)\):\s*\n(\t?)/=item C<$1>\n\nFrom F<$2>:\n\n/m) {
922 my $c = substr $1, 0, 1;
923 unless ($seen{$c}++) {
924 print CONFIG_POD <<EOF if $text;
930 print CONFIG_POD <<EOF;
941 elsif (!$text || !/\A\t/) {
942 warn "Expected a Configure variable header",
943 ($text ? " or another paragraph of description" : () );
945 s/n't/n\00t/g; # leave can't, won't etc untouched
946 s/^\t\s+(.*)/\n$1/gm; # Indented lines ===> new paragraph
947 s/^(?<!\n\n)\t(.*)/$1/gm; # Not indented lines ===> text
948 s{([\'\"])(?=[^\'\"\s]*[./][^\'\"\s]*\1)([^\'\"\s]+)\1}(F<$2>)g; # '.o'
949 s{([\'\"])([^\'\"\s]+)\1}(C<$2>)g; # "date" command
950 s{\'([A-Za-z_\- *=/]+)\'}(C<$1>)g; # 'ln -s'
952 (?<! [\w./<\'\"] ) # Only standalone file names
953 (?! e \. g \. ) # Not e.g.
954 (?! \. \. \. ) # Not ...
956 (?! read/ ) # Not read/write
957 (?! etc\. ) # Not etc.
960 \$ ? # Allow leading $
961 [\w./]* [./] [\w./]* # Require . or / inside
963 (?<! \. (?= [\s)] ) ) # Do not include trailing dot
964 (?! [\w/] ) # Include all of it
966 (F<$1>)xg; # /usr/local
967 s/((?<=\s)~\w*)/F<$1>/g; # ~name
968 s/(?<![.<\'\"])\b([A-Z_]{2,})\b(?![\'\"])/C<$1>/g; # UNISTD
969 s/(?<![.<\'\"])\b(?!the\b)(\w+)\s+macro\b/C<$1> macro/g; # FILE_cnt macro
970 s/n[\0]t/n't/g; # undo can't, won't damage
973 if ($Opts{glossary}) {
974 <GLOS>; # Skip the "DO NOT EDIT"
975 <GLOS>; # Skip the preamble
982 print CONFIG_POD <<'ENDOFTAIL';
988 Information on the git commit from which the current perl binary was compiled
989 can be found in the variable C<$Config::Git_Data>. The variable is a
990 structured string that looks something like this:
992 git_commit_id='ea0c2dbd5f5ac6845ecc7ec6696415bf8e27bd52'
993 git_describe='GitLive-blead-1076-gea0c2db'
994 git_branch='smartmatch'
995 git_uncommitted_changes=''
996 git_commit_id_title='Commit id:'
997 git_commit_date='2009-05-09 17:47:31 +0200'
999 Its format is not guaranteed not to change over time.
1003 This module contains a good example of how to use tie to implement a
1004 cache and an example of how to make a tied variable readonly to those
1011 close(GLOS) if $Opts{glossary};
1013 print "written $Config_POD\n";
1015 my $orig_config_txt = "";
1016 my $orig_heavy_txt = "";
1020 $orig_config_txt = <$fh> if open $fh, "<", $Config_PM;
1021 $orig_heavy_txt = <$fh> if open $fh, "<", $Config_heavy;
1024 if ($orig_config_txt ne $config_txt or $orig_heavy_txt ne $heavy_txt) {
1025 open CONFIG, ">", $Config_PM or die "Can't open $Config_PM: $!\n";
1026 open CONFIG_HEAVY, ">", $Config_heavy or die "Can't open $Config_heavy: $!\n";
1027 print CONFIG $config_txt;
1028 print CONFIG_HEAVY $heavy_txt;
1029 close(CONFIG_HEAVY);
1031 print "updated $Config_PM\n";
1032 print "updated $Config_heavy\n";
1036 # Now create Cross.pm if needed
1038 open CROSS, ">lib/Cross.pm" or die "Can not open >lib/Cross.pm: $!";
1039 my $cross = <<'EOS';
1040 # typical invocation:
1041 # perl -MCross Makefile.PL
1042 # perl -MCross=wince -V:cc
1046 my ($package,$platform) = @_;
1047 unless (defined $platform) {
1048 # if $platform is not specified, then use last one when
1049 # 'configpm; was invoked with --cross option
1050 $platform = '***replace-marker***';
1052 @INC = map {/\blib\b/?(do{local $_=$_;s/\blib\b/xlib\/$platform/;$_},$_):($_)} @INC;
1053 $::Cross::platform = $platform;
1058 $cross =~ s/\*\*\*replace-marker\*\*\*/$Opts{cross}/g;
1061 print "written lib/Cross.pm\n";
1062 unshift(@INC,"xlib/$Opts{cross}");
1065 # Now do some simple tests on the Config.pm file we have created
1066 unshift(@INC,'lib');
1067 unshift(@INC,'xlib/symbian') if $Opts{cross};
1069 require $Config_heavy;
1072 die "$0: $Config_PM not valid"
1073 unless $Config{'PERL_CONFIG_SH'} eq 'true';
1075 die "$0: error processing $Config_PM"
1076 if defined($Config{'an impossible name'})
1077 or $Config{'PERL_CONFIG_SH'} ne 'true' # test cache
1080 die "$0: error processing $Config_PM"
1081 if eval '$Config{"cc"} = 1'
1082 or eval 'delete $Config{"cc"}'
1087 # Popularity of various entries in %Config, based on a large build and test
1088 # run of code in the Fotango build system:
1106 inc_version_list: 783
1109 usevendorprefix: 642
1130 installsiteman1dir: 489
1131 installsiteman3dir: 489
1132 installvendorman1dir: 489
1133 installvendorman3dir: 489
1137 installsitearch: 344
1142 installprefixexp: 336
1145 installvendorarch: 336
1146 installvendorbin: 336
1147 installvendorlib: 336