Add Configure probes for nl_langinfo() and <langinfo.h>.
[p5sagit/p5-mst-13.2.git] / NetWare / config_h.PL
CommitLineData
2986a63f 1#
2use Config;
3use File::Compare qw(compare);
4use File::Copy qw(copy);
5my $OBJ = 1 if $Config{'ccflags'} =~ /PERL_OBJECT/i;
6my $name = $0;
7$name =~ s#^(.*)\.PL$#../$1.SH#;
8my %opt;
9while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/)
10 {
11 $opt{$1}=$2;
12 shift(@ARGV);
13 }
14
15 $opt{CONFIG_H} ||= 'config.h';
16
17my $patchlevel = $opt{INST_VER};
18$patchlevel =~ s|^[\\/]||;
19$patchlevel =~ s|~VERSION~|$Config{version}|g;
20$patchlevel ||= $Config{version};
21$patchlevel = qq["$patchlevel"];
22
23open(SH,"<$name") || die "Cannot open $name:$!";
24while (<SH>)
25 {
26 last if /^sed/;
27 }
28($term,$file,$pat) = /^sed\s+<<(\S+)\s+>(\S+)\s+(.*)$/;
29$file =~ s/^\$(\w+)$/$opt{$1}/g;
30
31my $str = "sub munge\n{\n";
32
33while ($pat =~ s/-e\s+'([^']*)'\s*//)
34 {
35 my $e = $1;
36 $e =~ s/\\([\(\)])/$1/g;
37 $e =~ s/\\(\d)/\$$1/g;
38 $str .= "$e;\n";
39 }
40$str .= "}\n";
41
42eval $str;
43
44die "$str:$@" if $@;
45
46open(H,">$file.new") || die "Cannot open $file.new:$!";
47binmode H; # no CRs (which cause a spurious rebuild)
48while (<SH>)
49 {
50 last if /^$term$/o;
51 s/\$([\w_]+)/Config($1)/eg;
52 s/`([^\`]*)`/BackTick($1)/eg;
53 munge();
54 s/\\\$/\$/g;
55 s#/[ *\*]*\*/#/**/#;
56 if (/^\s*#define\s+(SITELIB|VENDORLIB)_EXP/)
57 {
58 $_ = "#define ". $1 . "_EXP (nw_get_". lc($1) . "($patchlevel))\t/**/\n";
59 }
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/)
63 {
64 $_ = "#define ". $1 . "_EXP (fnNwGetEnvironmentStr(\"PRIVLIB\", PRIVLIB))\t/**/\n";
65 }
66 # incpush() handles archlibs, so disable them
67 elsif (/^\s*#define\s+(ARCHLIB|SITEARCH|VENDORARCH)_EXP/)
68 {
69 $_ = "/*#define ". $1 . "_EXP \"\"\t/**/\n";
70 }
71 print H;
72 }
73close(H);
74close(SH);
75
76
77chmod(0666,"../lib/CORE/config.h");
78copy("$file.new","../lib/CORE/config.h") || die "Cannot copy:$!";
79chmod(0444,"../lib/CORE/config.h");
80
81if (!$OBJ && compare("$file.new",$file))
82 {
83 warn "$file has changed\n";
84 chmod(0666,$file);
85 unlink($file);
86 rename("$file.new",$file);
87 #chmod(0444,$file);
88 exit(1);
89 }
90else
91 {
92 unlink ("$file.new");
93 exit(0);
94 }
95
96sub Config
97{
98 my $var = shift;
99 my $val = $Config{$var};
100 $val = 'undef' unless defined $val;
101 $val =~ s/\\/\\\\/g;
102 return $val;
103}
104
105sub BackTick
106{
107 my $cmd = shift;
108 if ($cmd =~ /^echo\s+(.*?)\s*\|\s+sed\s+'(.*)'\s*$/)
109 {
110 local ($data,$pat) = ($1,$2);
111 $data =~ s/\s+/ /g;
112 eval "\$data =~ $pat";
113 return $data;
114 }
115 else
116 {
117 die "Cannot handle \`$cmd\`";
118 }
119 return $cmd;
120}