3 $config_pm = $ARGV[0] || 'lib/Config.pm';
6 # list names to put first (and hence lookup fastest)
7 @fast = qw(osname osvers so libpth archlib
8 sharpbang startsh shsharp
9 dynamic_ext static_ext extensions dl_src
10 sig_name ccflags cppflags intsize);
12 # names of things which may need to have slashes changed to double-colons
13 @extensions = qw(dynamic_ext static_ext extensions known_extensions);
16 open CONFIG, ">$config_pm" or die "Can't open $config_pm: $!\n";
17 $myver = sprintf("%.3f", $]);
18 print CONFIG <<"ENDOFBEG";
22 \@EXPORT = qw(%Config);
24 \$] == $myver or die sprintf
25 "Perl lib version ($myver) doesn't match executable version (%.3f)\\n", \$];
27 # This file was created by configpm when Perl was built. Any changes
28 # made to this file will be lost the next time perl is built.
33 @extensions{@extensions} = @extensions;
39 next if m:^#!/bin/sh:;
40 # Catch CONFIG=true and PATCHLEVEL=n line from Configure.
41 s/^(\w+)=(true|\d+)\s*$/$1='$2'\n/;
42 unless (m/^(\w+)='(.*)'\s*$/){
43 push(@non_v, "#$_"); # not a name='value' line
47 if ($extensions{$name}) { s,/,::,g }
48 if (!$fast{$name}){ push(@v_others, $_); next; }
52 foreach(@non_v){ print CONFIG $_ }
55 "\$config_sh=<<'!END!OF!CONFIG!';\n",
56 join("", @v_fast, sort @v_others),
57 "!END!OF!CONFIG!\n\n";
60 print CONFIG <<'ENDOFEND';
63 sub TIEHASH { bless {} }
65 # check for cached value (which maybe undef so we use exists not defined)
66 return $_[0]->{$_[1]} if (exists $_[0]->{$_[1]});
68 my($value); # search for the item in the big $config_sh string
69 return undef unless (($value) = $config_sh =~ m/^$_[1]='(.*)'\s*$/m);
71 $value = undef if $value eq 'undef'; # So we can say "if $Config{'foo'}".
72 $_[0]->{$_[1]} = $value; # cache it
79 ($key) = $config_sh =~ m/^(.*)=/;
86 $pos = index( $config_sh, "\n", $pos) + 1;
88 $len = index( $config_sh, "=", $pos) - $pos;
89 $len > 0 ? substr( $config_sh, $pos, $len) : undef;
93 exists($_[0]->{$_[1]}) or $config_sh =~ m/^$_[1]=/m;
96 sub readonly { die "\%Config::Config is read-only\n" }
102 Summary of my $package (patchlevel $PATCHLEVEL) configuration:
104 osname=$osname, osver=$osvers, archname=$archname
108 cc='$cc', optimize='$optimize'
112 stdchar='$stdchar', d_stdstdio=$d_stdstdio, usevfork=$usevfork
113 voidflags=$voidflags, castflags=$castflags, d_casti32=$d_casti32, d_castneg=$d_castneg
114 intsize=$intsize, alignbytes=$alignbytes, usemymalloc=$usemymalloc, randbits=$randbits
121 dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun
122 cccdlflags='$cccdlflags', ccdlflags='$ccdlflags', lddlflags='$lddlflags'
125 $output =~ s/\$(\w+)/$Config{$1}/ge;
129 sub STORE { &readonly }
130 sub DELETE{ &readonly }
131 sub CLEAR { &readonly }
139 # Now do some simple tests on the Config.pm file we have created
144 die "$0: $config_pm not valid"
145 unless $Config{'CONFIG'} eq 'true';
147 die "$0: error processing $config_pm"
148 if defined($Config{'an impossible name'})
149 or $Config{'CONFIG'} ne 'true' # test cache
152 die "$0: error processing $config_pm"
153 if eval '$Config{"cc"} = 1'
154 or eval 'delete $Config{"cc"}'