2 BEGIN { warn "Running ".__FILE__."\n" };
6 die "Config.pm:$@" if $@;
9 use File::Compare qw(compare);
10 use File::Copy qw(copy);
12 $name =~ s#^(.*)\.PL$#../$1.SH#;
14 while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/)
20 $opt{CONFIG_H} ||= 'config.h';
21 $opt{CORE_DIR} ||= '../lib/CORE';
23 warn "Writing $opt{CONFIG_H}\n";
25 my $patchlevel = $opt{INST_VER};
26 $patchlevel =~ s|^[\\/]||;
27 $patchlevel =~ s|~VERSION~|$Config{version}|g;
28 $patchlevel ||= $Config{version};
29 $patchlevel = qq["$patchlevel"];
31 open(SH,"<$name") || die "Cannot open $name:$!";
36 ($term,$file,$pat) = /^sed\s+<<(\S+)\s+>(\S+)\s+(.*)$/;
38 $file =~ s/^\$(\w+)$/$opt{$1}/g;
40 my $str = "sub munge\n{\n";
42 while ($pat =~ s/-e\s+'([^']*)'\s*//)
45 $e =~ s/\\([\(\)])/$1/g;
46 $e =~ s/\\(\d)/\$$1/g;
55 open(H,">$file.new") || die "Cannot open $file.new:$!";
56 binmode H; # no CRs (which cause a spurious rebuild)
60 s/\$([\w_]+)/Config($1)/eg;
61 s/`([^\`]*)`/BackTick($1)/eg;
65 if (/^\s*#define\s+(PRIVLIB|SITELIB|VENDORLIB)_EXP/)
67 $_ = "#define ". $1 . "_EXP (win32_get_". lc($1) . "($patchlevel))\t/**/\n";
69 # incpush() handles archlibs, so disable them
70 elsif (/^\s*#define\s+(ARCHLIB|SITEARCH|VENDORARCH)_EXP/)
72 $_ = "/*#define ". $1 . "_EXP \"\"\t/**/\n";
80 chmod(0666,"$opt{CORE_DIR}/$opt{CONFIG_H}");
81 copy("$file.new","$opt{CORE_DIR}/$opt{CONFIG_H}") || die "Cannot copy:$!";
82 chmod(0444,"$opt{CORE_DIR}/$opt{CONFIG_H}");
84 if (compare("$file.new",$file))
86 warn "$file has changed\n";
89 rename("$file.new",$file);
102 my $val = $Config{$var};
103 $val = 'undef' unless defined $val;
111 if ($cmd =~ /^echo\s+(.*?)\s*\|\s+sed\s+'(.*)'\s*$/)
113 local ($data,$pat) = ($1,$2);
115 eval "\$data =~ $pat";
120 die "Cannot handle \`$cmd\`";