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+(.*)$/;
29 $file =~ s/^\$(\w+)$/$opt{$1}/g;
31 my $str = "sub munge\n{\n";
33 while ($pat =~ s/-e\s+'([^']*)'\s*//)
36 $e =~ s/\\([\(\)])/$1/g;
37 $e =~ s/\\(\d)/\$$1/g;
46 open(H,">$file.new") || die "Cannot open $file.new:$!";
47 binmode H; # no CRs (which cause a spurious rebuild)
51 s/\$([\w_]+)/Config($1)/eg;
52 s/`([^\`]*)`/BackTick($1)/eg;
56 if (/^\s*#define\s+(SITELIB|VENDORLIB)_EXP/)
58 $_ = "#define ". $1 . "_EXP (nw_get_". lc($1) . "($patchlevel))\t/**/\n";
60 # Added for NetWare and removed PRIVLIB from the above, the same thing might have
61 # to be done for other as well
62 elsif (/^\s*#define\s+(PRIVLIB)_EXP/)
64 $_ = "#define ". $1 . "_EXP (fnNwGetEnvironmentStr(\"PRIVLIB\", PRIVLIB))\t/**/\n";
66 # incpush() handles archlibs, so disable them
67 elsif (/^\s*#define\s+(ARCHLIB|SITEARCH|VENDORARCH)_EXP/)
69 $_ = "/*#define ". $1 . "_EXP \"\"\t/**/\n";
77 chmod(0666,"../lib/CORE/config.h");
78 copy("$file.new","../lib/CORE/config.h") || die "Cannot copy:$!";
79 chmod(0444,"../lib/CORE/config.h");
81 if (!$OBJ && compare("$file.new",$file))
83 warn "$file has changed\n";
86 rename("$file.new",$file);
99 my $val = $Config{$var};
100 $val = 'undef' unless defined $val;
108 if ($cmd =~ /^echo\s+(.*?)\s*\|\s+sed\s+'(.*)'\s*$/)
110 local ($data,$pat) = ($1,$2);
112 eval "\$data =~ $pat";
117 die "Cannot handle \`$cmd\`";