3 use File::Compare qw(compare);
4 use File::Copy qw(copy);
5 my $OBJ = 1 if $Config{'ccflags'} =~ /PERL_OBJECT/i;
7 $name =~ s#^(.*)\.PL$#../$1.SH#;
9 while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/)
15 $opt{CONFIG_H} ||= 'config.h';
17 my $patchlevel = $opt{INST_VER};
18 $patchlevel =~ s|^[\\/]||;
19 $patchlevel =~ s|~VERSION~|$Config{version}|g;
20 $patchlevel ||= $Config{version};
21 $patchlevel = qq["$patchlevel"];
23 open(SH,"<$name") || die "Cannot open $name:$!";
28 ($term,$file,$pat) = /^sed\s+<<(\S+)\s+>(\S+)\s+(.*)$/;
30 $file =~ s/^\$(\w+)$/$opt{$1}/g;
32 my $str = "sub munge\n{\n";
34 while ($pat =~ s/-e\s+'([^']*)'\s*//)
37 $e =~ s/\\([\(\)])/$1/g;
38 $e =~ s/\\(\d)/\$$1/g;
47 open(H,">$file.new") || die "Cannot open $file.new:$!";
48 #binmode H; # no CRs (which cause a spurious rebuild)
52 s/\$([\w_]+)/Config($1)/eg;
53 s/`([^\`]*)`/BackTick($1)/eg;
57 if (/^\s*#define\s+(PRIVLIB|SITELIB|VENDORLIB)_EXP/)
59 $_ = "#define ". $1 . "_EXP (win32_get_". lc($1) . "($patchlevel))\t/**/\n";
61 # incpush() handles archlibs, so disable them
62 elsif (/^\s*#define\s+(ARCHLIB|SITEARCH|VENDORARCH)_EXP/)
64 $_ = "/*#define ". $1 . "_EXP \"\"\t/**/\n";
72 chmod(0666,"../lib/CORE/config.h");
73 copy("$file.new","../lib/CORE/config.h") || die "Cannot copy:$!";
74 chmod(0444,"../lib/CORE/config.h");
76 if (!$OBJ && compare("$file.new",$file))
78 warn "$file has changed\n";
81 rename("$file.new",$file);
94 my $val = $Config{$var};
95 $val = 'undef' unless defined $val;
103 if ($cmd =~ /^echo\s+(.*?)\s*\|\s+sed\s+'(.*)'\s*$/)
105 local ($data,$pat) = ($1,$2);
107 eval "\$data =~ $pat";
112 die "Cannot handle \`$cmd\`";