2 BEGIN { warn "Running ".__FILE__."\n" };
5 require "../lib/Config.pm";
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';
22 warn "Writing $opt{CONFIG_H}\n";
24 my $patchlevel = $opt{INST_VER};
25 $patchlevel =~ s|^[\\/]||;
26 $patchlevel =~ s|~VERSION~|$Config{version}|g;
27 $patchlevel ||= $Config{version};
28 $patchlevel = qq["$patchlevel"];
30 open(SH,"<$name") || die "Cannot open $name:$!";
35 ($term,$file,$pat) = /^sed\s+<<(\S+)\s+>(\S+)\s+(.*)$/;
37 $file =~ s/^\$(\w+)$/$opt{$1}/g;
39 my $str = "sub munge\n{\n";
41 while ($pat =~ s/-e\s+'([^']*)'\s*//)
44 $e =~ s/\\([\(\)])/$1/g;
45 $e =~ s/\\(\d)/\$$1/g;
54 open(H,">$file.new") || die "Cannot open $file.new:$!";
55 #binmode H; # no CRs (which cause a spurious rebuild)
59 s/\$([\w_]+)/Config($1)/eg;
60 s/`([^\`]*)`/BackTick($1)/eg;
64 if (/^\s*#define\s+(PRIVLIB|SITELIB|VENDORLIB)_EXP/)
66 $_ = "#define ". $1 . "_EXP (win32_get_". lc($1) . "($patchlevel))\t/**/\n";
68 # incpush() handles archlibs, so disable them
69 elsif (/^\s*#define\s+(ARCHLIB|SITEARCH|VENDORARCH)_EXP/)
71 $_ = "/*#define ". $1 . "_EXP \"\"\t/**/\n";
79 chmod(0666,"../lib/CORE/config.h");
80 copy("$file.new","../lib/CORE/config.h") || die "Cannot copy:$!";
81 chmod(0444,"../lib/CORE/config.h");
83 if (compare("$file.new",$file))
85 warn "$file has changed\n";
88 rename("$file.new",$file);
101 my $val = $Config{$var};
102 $val = 'undef' unless defined $val;
110 if ($cmd =~ /^echo\s+(.*?)\s*\|\s+sed\s+'(.*)'\s*$/)
112 local ($data,$pat) = ($1,$2);
114 eval "\$data =~ $pat";
119 die "Cannot handle \`$cmd\`";