2 BEGIN { warn "Running ".__FILE__."\n" };
6 die "Config.pm:$@" if $@;
9 use File::Compare qw(compare);
10 use File::Copy qw(copy);
11 use File::Basename qw(fileparse);
12 my ($name, $dir) = fileparse($0);
13 $name =~ s#^(.*)\.PL$#../$1.SH#;
15 while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/)
21 $opt{CONFIG_H} ||= 'config.h';
22 $opt{CORE_DIR} ||= '../lib/CORE';
24 warn "Writing $opt{CONFIG_H}\n";
26 my $patchlevel = $opt{INST_VER};
27 $patchlevel =~ s|^[\\/]||;
28 $patchlevel =~ s|~VERSION~|$Config{version}|g;
29 $patchlevel ||= $Config{version};
30 $patchlevel = qq["$patchlevel"];
32 open(SH,"<$name") || die "Cannot open $name:$!";
37 ($term,$file,$pat) = /^\s*sed\s+<<(\S+)\s+>(\S+)\s+(.*)$/;
39 $file =~ s/^\$(\w+)$/$opt{$1}/g;
41 my $str = "sub munge\n{\n";
43 while ($pat =~ s/-e\s+'([^']*)'\s*//)
46 $e =~ s/\\([\(\)])/$1/g;
47 $e =~ s/\\(\d)/\$$1/g;
56 open(H,">$file.new") || die "Cannot open $file.new:$!";
57 #binmode H; # no CRs (which cause a spurious rebuild)
61 s/\$([\w_]+)/Config($1)/eg;
62 s/`([^\`]*)`/BackTick($1)/eg;
66 s#(.)/\*\*/#$1/ **/# if(/^\/\*/); #avoid "/*" inside comments
67 if (/^\s*#define\s+(PRIVLIB|SITELIB|VENDORLIB)_EXP/)
69 $_ = "#define ". $1 . "_EXP (win32_get_". lc($1) . "(PERL_VERSION_STRING, NULL))\t/**/\n";
71 # incpush() handles archlibs, so disable them
72 elsif (/^\s*#define\s+(ARCHLIB|SITEARCH|VENDORARCH)_EXP/)
74 $_ = "/*#define ". $1 . "_EXP \"\"\t/ **/\n";
82 chmod(0666,"$opt{CORE_DIR}/$opt{CONFIG_H}");
83 copy("$file.new","$opt{CORE_DIR}/$opt{CONFIG_H}") || die "Cannot copy:$!";
84 chmod(0444,"$opt{CORE_DIR}/$opt{CONFIG_H}");
86 if (compare("$file.new",$file))
88 warn "$file has changed\n";
91 rename("$file.new",$file);
104 my $val = $Config{$var};
105 $val = 'undef' unless defined $val;
113 if ($cmd =~ /^echo\s+(.*?)\s*\|\s+sed\s+'(.*)'\s*$/)
115 local ($data,$pat) = ($1,$2);
117 eval "\$data =~ $pat";
122 die "Cannot handle \`$cmd\`";