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);
13 open CONFIG, ">$config_pm" or die "Can't open $config_pm: $!\n";
14 $myver = sprintf("%.3f", $]);
15 print CONFIG <<"ENDOFBEG";
19 \@EXPORT = qw(%Config);
21 \$] == $myver or die sprintf
22 "Perl lib version ($myver) doesn't match executable version (%.3f)\\n", \$];
24 # This file was created by configpm when Perl was built. Any changes
25 # made to this file will be lost the next time perl is built.
35 next if m:^#!/bin/sh:;
36 # Catch CONFIG=true and PATCHLEVEL=n line from Configure.
37 s/^(\w+)=(true|\d+)\s*$/$1='$2'\n/;
38 unless (m/^(\w+)='(.*)'\s*$/){
39 push(@non_v, "#$_"); # not a name='value' line
42 if (!$fast{$1}){ push(@v_others, $_); next; }
46 foreach(@non_v){ print CONFIG $_ }
49 "\$config_sh=<<'!END!OF!CONFIG!';\n",
50 join("", @v_fast, sort @v_others),
51 "!END!OF!CONFIG!\n\n";
54 print CONFIG <<'ENDOFEND';
57 sub TIEHASH { bless {} }
59 # check for cached value (which maybe undef so we use exists not defined)
60 return $_[0]->{$_[1]} if (exists $_[0]->{$_[1]});
62 my($value); # search for the item in the big $config_sh string
63 return undef unless (($value) = $config_sh =~ m/^$_[1]='(.*)'\s*$/m);
65 $value = undef if $value eq 'undef'; # So we can say "if $Config{'foo'}".
66 $_[0]->{$_[1]} = $value; # cache it
73 ($key) = $config_sh =~ m/^(.*)=/;
80 $pos = index( $config_sh, "\n", $pos) + 1;
82 $len = index( $config_sh, "=", $pos) - $pos;
83 $len > 0 ? substr( $config_sh, $pos, $len) : undef;
87 exists($_[0]->{$_[1]}) or $config_sh =~ m/^$_[1]=/m;
90 sub readonly { die "\%Config::Config is read-only\n" }
92 sub STORE { &readonly }
93 sub DELETE{ &readonly }
94 sub CLEAR { &readonly }
102 # Now do some simple tests on the Config.pm file we have created
107 die "$0: $config_pm not valid"
108 unless $Config{'CONFIG'} eq 'true';
110 die "$0: error processing $config_pm"
111 if defined($Config{'an impossible name'})
112 or $Config{'CONFIG'} ne 'true' # test cache
115 die "$0: error processing $config_pm"
116 if eval '$Config{"cc"} = 1'
117 or eval 'delete $Config{"cc"}'