6 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
7 # 2002, 2003, 2004, 2005, 2006, 2007 Larry Wall and others.
10 # Regenerate the files
17 # from the contents of the static files
22 # and from the contents of the Configure-generated file
27 # It will only update Config.pm and Config_heavy.pl if the contents of
28 # either file would be different. Note that *both* files are updated in
29 # this case, since for example an extension makefile that has a dependency
30 # on Config.pm should trigger even if only Config_heavy.pl has changed.
33 return $_[0]=~s/^#(?: )?//mgr;
36 sub usage { die uncomment <<EOF }
37 # usage: $0 [ options ]
38 # --no-glossary don't include Porting/Glossary in lib/Config.pod
39 # --chdir=dir change directory before writing files
43 our (%Config, $Config_SH_expanded);
45 my $how_many_common = 22;
47 # commonly used names to precache (and hence lookup fastest)
50 while ($how_many_common--) {
53 /^(\S+):\s*(\d+)$/ or die "Malformed line '$_'";
57 # Post 37589e1eefb1bd62 DynaLoader defaults to reading these at runtime.
58 # Ideally we're redo the data below, but Fotango's build system made it
59 # wonderfully easy to instrument, and no longer exists.
60 $Common{$_} = $_ foreach qw(dlext so);
62 # names of things which may need to have slashes changed to double-colons
63 my %Extensions = map {($_,$_)}
64 qw(dynamic_ext static_ext extensions known_extensions);
66 # The plan is that this information is used by ExtUtils::MakeMaker to generate
67 # Makefile dependencies, rather than hardcoding a list, which has become out
68 # of date. However, currently, MM_Unix.pm and MM_VMS.pm have *different* lists,
69 # *and* descrip_mms.template doesn't actually install all the headers.
70 # The "Unix" list seems to (attempt to) avoid the generated headers, which I'm
71 # not sure is the right thing to do. Also, not certain whether it would be
72 # easier to parse MANIFEST to get these (adding config.h, and potentially
73 # removing others), but for now, stick to a hard coded list.
75 # Could use a map to add ".h", but I suspect that it's easier to use literals,
76 # so that anyone using grep will find them
77 # This is the list from MM_VMS, plus pad.h, parser.h, utf8.h
78 # which it installs. It *doesn't* install perliol.h - FIXME.
79 my @header_files = qw(EXTERN.h INTERN.h XSUB.h av.h config.h cop.h cv.h
80 embed.h embedvar.h form.h gv.h handy.h hv.h hv_func.h intrpvar.h
81 iperlsys.h keywords.h mg.h nostdio.h op.h opcode.h
82 pad.h parser.h patchlevel.h perl.h perlio.h perlsdio.h
83 perlvars.h perly.h pp.h pp_proto.h proto.h
84 regcomp.h regexp.h regnodes.h scope.h sv.h thread.h utf8.h
88 $^O eq 'VMS' ? 'vmsish.h' : qw(dosish.h perliol.h time64.h unixish.h);
90 my $header_files = ' return qw(' . join(' ', sort @header_files) . ');';
91 $header_files =~ s/(?=.{64}) # If line is still overlength
92 (.{1,64})\ # Split at the last convenient space
95 # allowed opts as well as specifies default and initial values
97 'glossary' => 1, # --no-glossary - no glossary file inclusion,
99 'chdir' => '', # --chdir=dir - change directory before writing files
103 # user specified options
106 (map {/^--([\-_\w]+)=(.*)$/} @ARGV),
107 # --opt --no-opt --noopt
108 (map {/^no-?(.*)$/i?($1=>0):($_=>1)} map {/^--([\-_\w]+)$/} @ARGV),
111 my %opts = (%Allowed_Opts, %given_opts);
113 for my $opt (grep {!exists $Allowed_Opts{$_}} keys %given_opts) {
114 warn "option '$opt' is not recognized";
117 @ARGV = grep {!/^--/} @ARGV;
126 chdir $Opts{chdir} or die "$0: could not chdir $Opts{chdir}: $!"
129 my ($Config_SH, $Config_PM, $Config_heavy, $Config_POD);
130 my $Glossary = 'Porting/Glossary';
132 $Config_PM = "lib/Config.pm";
133 $Config_POD = "lib/Config.pod";
134 $Config_SH = "config.sh";
136 ($Config_heavy = $Config_PM) =~ s/\.pm$/_heavy.pl/;
137 die "Can't automatically determine name for Config_heavy.pl from '$Config_PM'"
138 if $Config_heavy eq $Config_PM;
143 my $export_funcs = uncomment <<'EOT';
144 # my %Export_Cache = (myconfig => 1, config_sh => 1, config_vars => 1,
145 # config_re => 1, compile_date => 1, local_patches => 1,
146 # bincompat_options => 1, non_bincompat_options => 1,
147 # header_files => 1);
150 my %export_ok = eval $export_funcs or die;
152 $config_txt .= sprintf uncomment << 'EOT', $], $export_funcs;
153 # # This file was created by configpm when Perl was built. Any changes
154 # # made to this file will be lost the next time perl is built.
156 # # for a description of the variables, please have a look at the
157 # # Glossary file, as written in the Porting folder, or use the url:
158 # # https://github.com/Perl/perl5/blob/blead/Porting/Glossary
163 # our ( %%Config, $VERSION );
167 # # Skip @Config::EXPORT because it only contains %%Config, which we special
168 # # case below as it's not a function. @Config::EXPORT won't change in the
169 # # lifetime of Perl 5.
171 # @Config::EXPORT = qw(%%Config);
172 # @Config::EXPORT_OK = keys %%Export_Cache;
174 # # Need to stub all the functions to make code such as print Config::config_sh
179 $config_txt .= "sub $_;\n" foreach sort keys %export_ok;
181 my $myver = sprintf "%vd", $^V;
183 $config_txt .= sprintf uncomment <<'ENDOFBEG', ($myver) x 3;
185 # # Define our own import method to avoid pulling in the full Exporter:
188 # @_ = @Config::EXPORT unless @_;
190 # my @funcs = grep $_ ne '%%Config', @_;
191 # my $export_Config = @funcs < @_ ? 1 : 0;
194 # my $callpkg = caller(0);
195 # foreach my $func (@funcs) {
196 # die qq{"$func" is not exported by the Config module\n}
197 # unless $Export_Cache{$func};
198 # *{$callpkg.'::'.$func} = \&{$func};
201 # *{"$callpkg\::Config"} = \%%Config if $export_Config;
205 # die "$0: Perl lib version (%s) doesn't match executable '$^X' version ($])"
209 # or die sprintf "%%s: Perl lib version (%s) doesn't match executable '$^X' version (%%vd)", $0, $^V;
220 # These variables were set in older versions of Perl, but are no longer needed
221 # by the core. However, some CPAN modules may rely on them; in particular, Tk
222 # (at least up to version 804.034) fails to build without them. We force them
223 # to be emitted to Config_heavy.pl for backcompat with such modules (and we may
224 # find that this set needs to be extended in future). See RT#132347.
225 my @v_forced = map "$_\n", split /\n+/, uncomment <<'EOT';
237 open(CONFIG_SH, '<', $Config_SH) || die "Can't open $Config_SH: $!";
238 while (<CONFIG_SH>) {
239 next if m:^#!/bin/sh:;
241 # Catch PERL_CONFIG_SH=true and PERL_VERSION=n line from Configure.
242 s/^(\w+)=(true|\d+)\s*$/$1='$2'\n/ or m/^(\w+)='(.*)'$/;
243 my($k, $v) = ($1, $2);
245 # grandfather PATCHLEVEL and SUBVERSION and CONFIG
247 if ($k eq 'PERL_VERSION') {
248 push @v_others, "PATCHLEVEL='$v'\n";
250 elsif ($k eq 'PERL_SUBVERSION') {
251 push @v_others, "SUBVERSION='$v'\n";
253 elsif ($k eq 'PERL_CONFIG_SH') {
254 push @v_others, "CONFIG='$v'\n";
258 # We can delimit things in config.sh with either ' or ".
259 unless ($in_v or m/^(\w+)=(['"])(.*\n)/){
260 push(@non_v, "#$_"); # not a name='value' line
268 ($name,$val) = ($1,$3);
270 $val =~ s{^(['"]?+).*\bccache\s+}{$1};
273 $in_v = $val !~ /$quote\n/;
276 s,/,::,g if $Extensions{$name};
278 $val =~ s/$quote\n?\z//;
280 my $line = "$name=$quote$val$quote\n";
281 push(@v_others, $line);
282 $seen_quotes{$quote}++;
287 # This is somewhat grim, but I want the code for parsing config.sh here and
288 # now so that I can expand $Config{ivsize} and $Config{ivtype}
290 my $fetch_string = uncomment <<'EOT';
292 # # Search for it in the big string
294 # my($self, $key) = @_;
298 if ($seen_quotes{'"'}) {
299 # We need the full ' and " code
301 $fetch_string .= uncomment <<'EOT';
302 # return undef unless my ($quote_type, $value) = $Config_SH_expanded =~ /\n$key=(['"])(.*?)\1\n/s;
304 # # If we had a double-quote, we'd better eval it so escape
305 # # sequences and such can be interpolated. Since the incoming
306 # # value is supposed to follow shell rules and not perl rules,
307 # # we escape any perl variable markers
309 # # Historically, since " 'support' was added in change 1409, the
310 # # interpolation was done before the undef. Stick to this arguably buggy
311 # # behaviour as we're refactoring.
312 # if ($quote_type eq '"') {
313 # $value =~ s/\$/\\\$/g;
314 # $value =~ s/\@/\\\@/g;
315 # eval "\$value = \"$value\"";
318 # # So we can say "if $Config{'foo'}".
319 # $self->{$key} = $value eq 'undef' ? undef : $value; # cache it
324 # We only have ' delimited.
326 $fetch_string .= uncomment <<'EOT';
327 # return undef unless $Config_SH_expanded =~ /\n$key=\'(.*?)\'\n/s;
328 # # So we can say "if $Config{'foo'}".
329 # $self->{$key} = $1 eq 'undef' ? undef : $1;
338 # Calculation for the keys for byteorder
339 # This is somewhat grim, but I need to run fetch_string here.
340 $Config_SH_expanded = join "\n", '', @v_others;
342 my $t = fetch_string ({}, 'ivtype');
343 my $s = fetch_string ({}, 'ivsize');
345 # byteorder does exist on its own but we overlay a virtual
346 # dynamically recomputed value.
348 # However, ivtype and ivsize will not vary for sane fat binaries
350 my $f = $t eq 'long' ? 'L!' : $s == 8 ? 'Q': 'I';
353 if ($s == 4 || $s == 8) {
354 my $list = join ',', reverse(1..$s-1);
356 $byteorder_code = <<"EOT";
359 foreach my \$c ($list) { \$i <<= 8; \$i |= ord(\$c); }
360 our \$byteorder = join('', unpack('$format', pack('$f', \$i)));
363 $byteorder_code = "our \$byteorder = '?'x$s;\n";
368 if (fetch_string({},'userelocatableinc')) {
369 foreach my $what (qw(prefixexp
418 installvendorhtml1dir
419 installvendorhtml3dir
425 push @need_relocation, $what if fetch_string({}, $what) =~ m!^\.\.\./!;
430 @need_relocation{@need_relocation} = @need_relocation;
432 # This can have .../ anywhere:
433 if (fetch_string({}, 'otherlibdirs') =~ m!\.\.\./!) {
434 $need_relocation{otherlibdirs} = 'otherlibdirs';
437 my $relocation_code = uncomment <<'EOT';
440 # my $libdir = shift;
441 # return $libdir unless $libdir =~ s!^\.\.\./!!;
443 # if ($prefix =~ s!/[^/]*$!!) {
444 # while ($libdir =~ m!^\.\./!) {
445 # # Loop while $libdir starts "../" and $prefix still has a trailing
447 # last unless $prefix =~ s!/([^/]+)$!!;
448 # # but bail out if the directory we picked off the end of $prefix is .
450 # if ($1 eq '.' or $1 eq '..') {
451 # # Undo! This should be rare, hence code it this way rather than a
452 # # check each time before the s!!! above.
453 # $prefix = "$prefix/$1";
456 # # Remove that leading ../ and loop again
457 # substr ($libdir, 0, 3, '');
459 # $libdir = "$prefix/$libdir";
465 my $osname = fetch_string({}, 'osname');
466 my $from = $osname eq 'VMS' ? 'PERLSHR image' : 'binary (from libperl)';
467 my $env_cygwin = $osname eq 'cygwin'
468 ? 'push @env, "CYGWIN=\"$ENV{CYGWIN}\"" if $ENV{CYGWIN};' . "\n" : "";
470 $heavy_txt .= sprintf uncomment <<'ENDOFBEG', $osname, $osname, $from, $osname, $env_cygwin;
471 # # This file was created by configpm when Perl was built. Any changes
472 # # made to this file will be lost the next time perl is built.
479 # sub bincompat_options {
480 # return split ' ', (Internals::V())[0];
483 # sub non_bincompat_options {
484 # return split ' ', (Internals::V())[1];
488 # return (Internals::V())[2]
491 # sub local_patches {
492 # my (undef, undef, undef, @patches) = Internals::V();
497 # die "Perl lib was built for '%s' but is being run on '$^O'"
498 # unless "%s" eq $^O;
500 # my ($bincompat, $non_bincompat, $date, @patches) = Internals::V();
502 # my @opts = sort split ' ', "$bincompat $non_bincompat";
504 # print Config::myconfig();
505 # print "\nCharacteristics of this %s: \n";
507 # print " Compile-time options:\n";
508 # print " $_\n" for @opts;
511 # print " Locally applied patches:\n";
512 # print " $_\n" foreach @patches;
515 # print " Built under %s\n";
517 # print " $date\n" if defined $date;
519 # my @env = map { "$_=\"$ENV{$_}\"" } sort grep {/^PERL/} keys %%ENV;
522 # print " \%%ENV:\n";
523 # print " $_\n" foreach @env;
526 # print " $_\n" foreach @INC;
532 $heavy_txt .= $header_files . "\n}\n\n";
534 if (%need_relocation) {
535 my $relocations_in_common;
536 # otherlibdirs only features in the hash
537 foreach (keys %need_relocation) {
538 $relocations_in_common++ if $Common{$_};
540 if ($relocations_in_common) {
541 $config_txt .= $relocation_code;
543 $heavy_txt .= $relocation_code;
547 $heavy_txt .= join('', @non_v) . "\n";
549 # copy config summary format from the myconfig.SH script
550 $heavy_txt .= "our \$summary = <<'!END!';\n";
551 open(MYCONFIG,'<','myconfig.SH') || die "open myconfig.SH failed: $!";
552 1 while defined($_ = <MYCONFIG>) && !/^Summary of/;
553 do { $heavy_txt .= $_ } until !defined($_ = <MYCONFIG>) || /^\s*$/;
556 $heavy_txt .= "\n!END!\n" . uncomment <<'EOT';
557 # my $summary_expanded;
560 # return $summary_expanded if $summary_expanded;
561 # ($summary_expanded = $summary) =~ s{\$(\w+)}
564 # if ($1 eq 'git_ancestor_line') {
565 # if ($Config::Config{git_ancestor}) {
566 # $c= "\n Ancestor: $Config::Config{git_ancestor}";
571 # $c = $Config::Config{$1};
573 # defined($c) ? $c : 'undef'
581 #proper lexicographical order of the keys
583 my @v_define = ( "taint_support=''\n",
584 "taint_disabled=''\n" );
585 $heavy_txt .= join('',
587 sort {$a->[0] cmp $b->[0] }
588 grep { !$seen_var{ $_->[0] }++ }
590 /^([^=]+)/ ? [ $1, $_ ]
591 : [ $_, $_ ] # shouldnt happen
592 } (@v_others, @v_forced, @v_define)
595 # Only need the dynamic byteorder code in Config.pm if 'byteorder' is one of
597 if ($Common{byteorder}) {
598 $config_txt .= $byteorder_code;
600 $heavy_txt .= $byteorder_code;
603 $heavy_txt .= uncomment <<'EOT';
604 # s/(byteorder=)(['"]).*?\2/$1$2$Config::byteorder$2/m;
608 $heavy_txt .= uncomment <<'EOF_TAINT_INIT';
610 # # We have to set this up late as Win32 does not build miniperl
611 # # with the same defines and CC flags as it builds perl itself.
612 # my $defines = join " ", (Internals::V)[0,1];
614 # $defines =~ /\b(SILENT_NO_TAINT_SUPPORT)\b/ ||
615 # $defines =~ /\b(NO_TAINT_SUPPORT)\b/
618 # my $taint_disabled = ($which eq "SILENT_NO_TAINT_SUPPORT")
619 # ? "silent" : "define";
620 # s/^(taint_disabled=['"])(["'])/$1$taint_disabled$2/m;
623 # my $taint_support = 'define';
624 # s/^(taint_support=['"])(["'])/$1$taint_support$2/m;
629 if (@need_relocation) {
630 $heavy_txt .= 'foreach my $what (qw(' . join (' ', @need_relocation) .
631 ")) {\n" . uncomment <<'EOT';
632 # s/^($what=)(['"])(.*?)\2/$1 . $2 . relocate_inc($3) . $2/me;
635 # Currently it only makes sense to do the ... relocation on Unix, so there's
636 # no need to emulate the "which separator for this platform" logic in perl.c -
637 # ':' will always be applicable
638 if ($need_relocation{otherlibdirs}) {
639 $heavy_txt .= uncomment << 'EOT';
640 # s{^(otherlibdirs=)(['"])(.*?)\2}
641 # {$1 . $2 . join ':', map {relocate_inc($_)} split ':', $3 . $2}me;
646 $heavy_txt .= uncomment <<'EOT';
647 # my $config_sh_len = length $_;
649 # our $Config_SH_expanded = "\n$_" . << 'EOVIRTUAL';
652 foreach my $prefix (qw(ccflags ldflags)) {
653 my $value = fetch_string ({}, $prefix);
654 my $withlargefiles = fetch_string ({}, $prefix . "_uselargefiles");
655 if (defined $withlargefiles) {
656 $value =~ s/\Q$withlargefiles\E\b//;
657 $heavy_txt .= "${prefix}_nolargefiles='$value'\n";
661 foreach my $prefix (qw(libs libswanted)) {
662 my $value = fetch_string ({}, $prefix);
663 my $withlf = fetch_string ({}, 'libswanted_uselargefiles');
664 next unless defined $withlf;
666 = split(' ', fetch_string ({}, 'libswanted_uselargefiles'));
669 @lflibswanted{@lflibswanted} = ();
670 if ($prefix eq 'libs') {
671 my @libs = grep { /^-l(.+)/ &&
672 not exists $lflibswanted{$1} }
673 split(' ', fetch_string ({}, 'libs'));
674 $value = join(' ', @libs);
676 my @libswanted = grep { not exists $lflibswanted{$_} }
677 split(' ', fetch_string ({}, 'libswanted'));
678 $value = join(' ', @libswanted);
681 $heavy_txt .= "${prefix}_nolargefiles='$value'\n";
684 if (open(my $fh, '<', 'cflags')) {
688 if (/^warn="(.+)"$/) {
690 } elsif (/^stdflags="(.+)"$/) {
694 if (defined $ccwarnflags) {
695 $heavy_txt .= "ccwarnflags='$ccwarnflags'\n";
697 if (defined $ccstdflags) {
698 $heavy_txt .= "ccstdflags='$ccstdflags'\n";
702 $heavy_txt .= "EOVIRTUAL\n";
704 $heavy_txt .= uncomment <<'ENDOFGIT';
706 # # do not have hairy conniptions if this isnt available
707 # require 'Config_git.pl';
708 # $Config_SH_expanded .= $Config::Git_Data;
710 # } or warn "Warning: failed to load Config_git.pl, something strange about this perl...\n";
713 $heavy_txt .= $fetch_string;
715 $config_txt .= uncomment <<'ENDOFEND';
718 # my($self, $key) = @_;
720 # # check for cached value (which may be undef so we use exists not defined)
721 # return exists $self->{$key} ? $self->{$key} : $self->fetch_string($key);
726 $heavy_txt .= uncomment <<'ENDOFEND';
732 # substr($Config_SH_expanded, 1, index($Config_SH_expanded, '=') - 1 );
737 if ($seen_quotes{'"'}) {
738 $heavy_txt .= uncomment <<'ENDOFEND';
739 # # Find out how the current key's quoted so we can skip to its end.
740 # my $quote = substr($Config_SH_expanded,
741 # index($Config_SH_expanded, "=", $prevpos)+1, 1);
742 # my $pos = index($Config_SH_expanded, qq($quote\n), $prevpos) + 2;
745 # Just ' quotes, so it's much easier.
746 $heavy_txt .= uncomment <<'ENDOFEND';
747 # my $pos = index($Config_SH_expanded, qq('\n), $prevpos) + 2;
750 $heavy_txt .= uncomment <<'ENDOFEND';
751 # my $len = index($Config_SH_expanded, "=", $pos) - $pos;
753 # $len > 0 ? substr($Config_SH_expanded, $pos, $len) : undef;
757 # return 1 if exists($_[0]->{$_[1]});
759 # return(index($Config_SH_expanded, "\n$_[1]='") != -1
761 if ($seen_quotes{'"'}) {
762 $heavy_txt .= uncomment <<'ENDOFEND';
763 # or index($Config_SH_expanded, "\n$_[1]=\"") != -1
766 $heavy_txt .= uncomment <<'ENDOFEND';
770 # sub STORE { die "\%Config::Config is read-only\n" }
771 # *DELETE = *CLEAR = \*STORE; # Typeglob aliasing uses less space
774 # substr $Config_SH_expanded, 1, $config_sh_len;
779 # return map { chomp; $_ } grep eval{ /^(?:$re)=/ }, split /^/,
780 # $Config_SH_expanded;
784 # # implements -V:cfgvar option (see perlrun -V:)
786 # # find optional leading, trailing colons; and query-spec
787 # my ($notag,$qry,$lncont) = m/^(:)?(.*?)(:)?$/; # flags fore and aft,
788 # # map colon-flags to print decorations
789 # my $prfx = $notag ? '': "$qry="; # tag-prefix for print
790 # my $lnend = $lncont ? ' ' : ";\n"; # line ending for print
792 # # all config-vars are by definition \w only, any \W means regex
793 # if ($qry =~ /\W/) {
794 # my @matches = config_re($qry);
795 # print map "$_$lnend", @matches ? @matches : "$qry: not found" if !$notag;
796 # print map { s/\w+=//; "$_$lnend" } @matches ? @matches : "$qry: not found" if $notag;
798 # my $v = (exists $Config::Config{$qry}) ? $Config::Config{$qry}
800 # $v = 'undef' unless defined $v;
801 # print "${prfx}'${v}'$lnend";
806 # # Called by the real AUTOLOAD
809 # goto \&$Config::AUTOLOAD;
816 $config_txt .= uncomment <<'ENDOFSET';
818 # if ($OS2::is_aout) {
819 # my ($value, $v) = $Config_SH_expanded =~ m/^used_aout='(.*)'\s*$/m;
820 # for (split ' ', $value) {
821 # ($v) = $Config_SH_expanded =~ m/^aout_$_='(.*)'\s*$/m;
822 # $preconfig{$_} = $v eq 'undef' ? undef : $v;
825 # $preconfig{d_fork} = undef unless $OS2::can_fork; # Some funny cases can't
826 # sub TIEHASH { bless {%preconfig} }
828 # Extract the name of the DLL from the makefile to avoid duplication
829 my ($f) = grep -r, qw(GNUMakefile Makefile);
831 if (open my $fh, '<', $f) {
833 $dll = $1, last if /^PERL_DLL_BASE\s*=\s*(\S*)\s*$/;
836 $config_txt .= uncomment <<ENDOFSET if $dll;
837 # \$preconfig{dll_name} = '$dll';
840 $config_txt .= uncomment <<'ENDOFSET';
842 # bless $_[1], $_[0];
847 foreach my $key (keys %Common) {
848 my $value = fetch_string ({}, $key);
849 # Is it safe on the LHS of => ?
850 my $qkey = $key =~ /^[A-Za-z_][A-Za-z0-9_]*$/ ? $key : "'$key'";
851 if (defined $value) {
852 # Quote things for a '' string
853 $value =~ s!\\!\\\\!g;
856 if ($key eq 'otherlibdirs') {
857 $value = "join (':', map {relocate_inc(\$_)} split (':', $value))";
858 } elsif ($need_relocation{$key}) {
859 $value = "relocate_inc($value)";
864 $Common{$key} = "$qkey => $value";
867 if ($Common{byteorder}) {
868 $Common{byteorder} = 'byteorder => $byteorder';
870 my $fast_config = join '', map { " $_,\n" } sort values %Common;
872 # Sanity check needed to stop an infinite loop if Config_heavy.pl fails to
873 # define &launcher for some reason (eg it got truncated)
874 $config_txt .= sprintf uncomment <<'ENDOFTIE', $fast_config;
879 # require 'Config_heavy.pl';
880 # goto \&launcher unless $Config::AUTOLOAD =~ /launcher$/;
881 # die "&Config::AUTOLOAD failed on $Config::AUTOLOAD";
884 # # tie returns the object, so the value returned to require will be true.
885 # tie %%Config, 'Config', {
890 open(CONFIG_POD, '>:raw', $Config_POD) or die "Can't open $Config_POD: $!";
891 print CONFIG_POD uncomment <<'ENDOFTAIL';
894 # =for comment Generated by configpm. Any changes made here will be lost!
896 # Config - access Perl configuration information
901 # if ($Config{usethreads}) {
902 # print "has thread support\n"
905 # use Config qw(myconfig config_sh config_vars config_re);
913 # config_vars(qw(osname archname));
918 # The Config module contains all the information that was available to
919 # the F<Configure> program at Perl build time (over 900 values).
921 # Shell variables from the F<config.sh> file (written by Configure) are
922 # stored in the readonly-variable C<%Config>, indexed by their names.
924 # Values stored in config.sh as 'undef' are returned as undefined
925 # values. The perl C<exists> function can be used to check if a
926 # named variable exists.
928 # For a description of the variables, please have a look at the
929 # Glossary file, as written in the Porting folder, or use the url:
930 # https://github.com/Perl/perl5/blob/blead/Porting/Glossary
936 # Returns a textual summary of the major perl configuration values.
937 # See also C<-V> in L<perlrun/Command Switches>.
941 # Returns the entire perl configuration information in the form of the
942 # original config.sh shell variable assignment script.
944 # =item config_re($regex)
946 # Like config_sh() but returns, as a list, only the config entries who's
947 # names match the $regex.
949 # =item config_vars(@names)
951 # Prints to STDOUT the values of the named configuration variable. Each is
952 # printed on a separate line in the form:
956 # Names which are unknown are output as C<name='UNKNOWN';>.
957 # See also C<-V:name> in L<perlrun/Command Switches>.
959 # =item bincompat_options()
961 # Returns a list of C pre-processor options used when compiling this F<perl>
962 # binary, which affect its binary compatibility with extensions.
963 # C<bincompat_options()> and C<non_bincompat_options()> are shown together in
964 # the output of C<perl -V> as I<Compile-time options>.
966 # =item non_bincompat_options()
968 # Returns a list of C pre-processor options used when compiling this F<perl>
969 # binary, which do not affect binary compatibility with extensions.
971 # =item compile_date()
973 # Returns the compile date (as a string), equivalent to what is shown by
976 # =item local_patches()
978 # Returns a list of the names of locally applied patches, equivalent to what
979 # is shown by C<perl -V>.
981 # =item header_files()
983 # Returns a list of the header files that should be used as dependencies for
984 # XS code, for this version of Perl on this platform.
990 # Here's a more sophisticated example of using %Config:
997 # unless($Config{sig_name} && $Config{sig_num}) {
1000 # my @names = split ' ', $Config{sig_name};
1001 # @sig_num{@names} = split ' ', $Config{sig_num};
1002 # foreach (@names) {
1003 # $sig_name[$sig_num{$_}] ||= $_;
1007 # print "signal #17 = $sig_name[17]\n";
1008 # if ($sig_num{ALRM}) {
1009 # print "SIGALRM is $sig_num{ALRM}\n";
1014 # Because this information is not stored within the perl executable
1015 # itself it is possible (but unlikely) that the information does not
1016 # relate to the actual perl binary which is being used to access it.
1018 # The Config module is installed into the architecture and version
1019 # specific library directory ($Config{installarchlib}) and it checks the
1020 # perl version number when loaded.
1022 # The values stored in config.sh may be either single-quoted or
1023 # double-quoted. Double-quoted strings are handy for those cases where you
1024 # need to include escape sequences in the strings. To avoid runtime variable
1025 # interpolation, any C<$> and C<@> characters are replaced by C<\$> and
1026 # C<\@>, respectively. This isn't foolproof, of course, so don't embed C<\$>
1027 # or C<\@> in double-quoted strings unless you're willing to deal with the
1028 # consequences. (The slashes will end up escaped and the C<$> or C<@> will
1029 # trigger variable interpolation)
1033 # Most C<Config> variables are determined by the C<Configure> script
1034 # on platforms supported by it (which is most UNIX platforms). Some
1035 # platforms have custom-made C<Config> variables, and may thus not have
1036 # some of the variables described below, or may have extraneous variables
1037 # specific to that particular port. See the port specific documentation
1044 if ($Opts{glossary}) {
1045 open(GLOS, '<', $Glossary) or die "Can't open $Glossary: $!";
1057 if (s/\A(\w*)\s+\(([\w.]+)\):\s*\n(\t?)/=item C<$1>\n\nFrom F<$2>:\n\n/m) {
1059 $fc = substr $item, 0, 1;
1061 elsif (!$item || !/\A\t/) {
1062 warn "Expected a Configure variable header",
1063 ($text ? " or another paragraph of description" : () ),
1064 ", instead we got:\n$_";
1067 s/n't/n\00t/g; # leave can't, won't etc untouched
1068 s/^\t\s+(.*)/\n$1/gm; # Indented lines ===> new paragraph
1069 s/^(?<!\n\n)\t(.*)/$1/gm; # Not indented lines ===> text
1070 s{([\'\"])(?=[^\'\"\s]*[./][^\'\"\s]*\1)([^\'\"\s]+)\1}(F<$2>)g; # '.o'
1071 s{([\'\"])([^\'\"\s]+)\1}(C<$2>)g; # "date" command
1072 s{\'([A-Za-z_\- *=/]+)\'}(C<$1>)g; # 'ln -s'
1074 (?<! [\w./<\'\"\$] ) # Only standalone file names
1075 (?! e \. g \. ) # Not e.g.
1076 (?! \. \. \. ) # Not ...
1077 (?! \d ) # Not 5.004
1078 (?! read/ ) # Not read/write
1079 (?! etc\. ) # Not etc.
1082 \$ ? # Allow leading $
1083 [\w./]* [./] [\w./]* # Require . or / inside
1085 (?<! \. (?= [\s)] ) ) # Do not include trailing dot
1086 (?! [\w/] ) # Include all of it
1088 (F<$1>)xg; # /usr/local
1089 s/((?<=\s)~\w*)/F<$1>/g; # ~name
1090 s/(?<![.<\'\"])\b([A-Z_]{2,})\b(?![\'\"])/C<$1>/g; # UNISTD
1091 s/(?<![.<\'\"])\b(?!the\b)(\w+)\s+macro\b/C<$1> macro/g; # FILE_cnt macro
1092 s/n[\0]t/n't/g; # undo can't, won't damage
1093 $glossary{$fc}{$item} .= $_;
1096 if ($Opts{glossary}) {
1097 <GLOS>; # Skip the "DO NOT EDIT"
1098 <GLOS>; # Skip the preamble
1103 die "Errors encountered while processing $Glossary. ",
1104 "Header lines are expected to be of the form:\n",
1106 "Maybe there is a malformed header?\n",
1111 $glossary{t}{taint_support} //= uncomment <<EOF_TEXT;
1112 # =item C<taint_support>
1114 # From define: C<SILENT_NO_TAINT_SUPPORT> or C<NO_TAINT_SUPPORT>
1116 # If this perl is compiled with support for taint mode this variable will
1117 # be set to 'define', if it is not it will be set to the empty string.
1118 # Either of the above defines will result in it being empty. This property
1119 # was added in version 5.37.11. See also L</taint_disabled>.
1123 $glossary{t}{taint_disabled} //= uncomment <<EOF_TEXT;
1124 # =item C<taint_disabled>
1126 # From define: C<SILENT_NO_TAINT_SUPPORT> or C<NO_TAINT_SUPPORT>
1128 # If this perl is compiled with support for taint mode this variable will
1129 # be set to the empty string, if it was compiled with
1130 # C<SILENT_NO_TAINT_SUPPORT> defined then it will be set to be "silent",
1131 # and if it was compiled with C<NO_TAINT_SUPPORT> defined it will be
1132 # 'define'. Either of the above defines will results in it being a true
1133 # value. This property was added in 5.37.11. See also L</taint_support>.
1137 if ($Opts{glossary}) {
1138 foreach my $fc (sort keys %glossary) {
1139 print CONFIG_POD "=head2 $fc\n\n=over 4\n\n";
1140 foreach my $item (sort keys %{$glossary{$fc}}) {
1141 print CONFIG_POD $glossary{$fc}{$item};
1143 print CONFIG_POD "=back\n\n";
1147 print CONFIG_POD uncomment <<'ENDOFTAIL';
1151 # Information on the git commit from which the current perl binary was compiled
1152 # can be found in the variable C<$Config::Git_Data>. The variable is a
1153 # structured string that looks something like this:
1155 # git_commit_id='ea0c2dbd5f5ac6845ecc7ec6696415bf8e27bd52'
1156 # git_describe='GitLive-blead-1076-gea0c2db'
1157 # git_branch='smartmatch'
1158 # git_uncommitted_changes=''
1159 # git_commit_id_title='Commit id:'
1160 # git_commit_date='2009-05-09 17:47:31 +0200'
1162 # Its format is not guaranteed not to change over time.
1166 # This module contains a good example of how to use tie to implement a
1167 # cache and an example of how to make a tied variable readonly to those
1174 close(GLOS) if $Opts{glossary};
1176 print "written $Config_POD\n";
1178 my $orig_config_txt = "";
1179 my $orig_heavy_txt = "";
1183 $orig_config_txt = <$fh> if open $fh, "<", $Config_PM;
1184 $orig_heavy_txt = <$fh> if open $fh, "<", $Config_heavy;
1187 if ($orig_config_txt ne $config_txt or $orig_heavy_txt ne $heavy_txt) {
1188 open CONFIG, ">", $Config_PM or die "Can't open $Config_PM: $!\n";
1189 open CONFIG_HEAVY, ">", $Config_heavy or die "Can't open $Config_heavy: $!\n";
1190 print CONFIG $config_txt;
1191 print CONFIG_HEAVY $heavy_txt;
1192 close(CONFIG_HEAVY);
1194 print "updated $Config_PM\n";
1195 print "updated $Config_heavy\n";
1198 # Now do some simple tests on the Config.pm file we have created
1199 unshift(@INC,'lib');
1201 require $Config_heavy;
1204 die "$0: $Config_PM not valid"
1205 unless $Config{'PERL_CONFIG_SH'} eq 'true';
1207 die "$0: error processing $Config_PM"
1208 if defined($Config{'an impossible name'})
1209 or $Config{'PERL_CONFIG_SH'} ne 'true' # test cache
1212 die "$0: error processing $Config_PM"
1213 if eval '$Config{"cc"} = 1'
1214 or eval 'delete $Config{"cc"}'
1219 # Popularity of various entries in %Config, based on a large build and test
1220 # run of code in the Fotango build system:
1238 inc_version_list: 783
1241 usevendorprefix: 642
1262 installsiteman1dir: 489
1263 installsiteman3dir: 489
1264 installvendorman1dir: 489
1265 installvendorman3dir: 489
1269 installsitearch: 344
1274 installprefixexp: 336
1277 installvendorarch: 336
1278 installvendorbin: 336
1279 installvendorlib: 336