source: trunk/third/perl/win32/config_h.PL @ 14545

Revision 14545, 2.1 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r14544, which included commits to RCS files with non-trunk default branches.
Line 
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 }
14my $patchlevel = $opt{INST_VER};
15$patchlevel =~ s|^[\\/]||;
16$patchlevel =~ s|~VERSION~|$Config{version}|g;
17$patchlevel ||= $Config{version};
18$patchlevel = qq["$patchlevel"];
19
20open(SH,"<$name") || die "Cannot open $name:$!";
21while (<SH>)
22 {
23  last if /^sed/;
24 }
25($term,$file,$pat) = /^sed\s+<<(\S+)\s+>(\S+)\s+(.*)$/;
26
27my $str = "sub munge\n{\n";
28
29while ($pat =~ s/-e\s+'([^']*)'\s*//)
30 {
31  my $e = $1;
32  $e =~ s/\\([\(\)])/$1/g;
33  $e =~ s/\\(\d)/\$$1/g;
34  $str .= "$e;\n";
35 }
36$str .= "}\n";
37
38eval $str;
39
40die "$str:$@" if $@;
41
42open(H,">$file.new") || die "Cannot open $file.new:$!";
43binmode H;              # no CRs (which cause a spurious rebuild)
44while (<SH>)
45 {
46  last if /^$term$/o;
47  s/\$([\w_]+)/Config($1)/eg;
48  s/`([^\`]*)`/BackTick($1)/eg;
49  munge();
50  s/\\\$/\$/g;
51  s#/[ *\*]*\*/#/**/#;
52  if (/^\s*#define\s+(PRIVLIB|SITELIB|VENDORLIB)_EXP/)
53   {
54     $_ = "#define ". $1 . "_EXP (win32_get_". lc($1) . "($patchlevel))\t/**/\n";
55   }
56  # incpush() handles archlibs, so disable them
57  elsif (/^\s*#define\s+(ARCHLIB|SITEARCH|VENDORARCH)_EXP/)
58   {
59     $_ = "/*#define ". $1 . "_EXP \"\"\t/**/\n";
60   }
61  print H;
62 }
63close(H);
64close(SH);
65
66
67chmod(0666,"../lib/CORE/config.h");
68copy("$file.new","../lib/CORE/config.h") || die "Cannot copy:$!";
69chmod(0444,"../lib/CORE/config.h");
70
71if (!$OBJ && compare("$file.new",$file))
72 {
73  warn "$file has changed\n";
74  chmod(0666,$file);
75  unlink($file);
76  rename("$file.new",$file);
77  #chmod(0444,$file);
78  exit(1);
79 }
80else
81 {
82  unlink ("$file.new");
83  exit(0);
84 }
85
86sub Config
87{
88 my $var = shift;
89 my $val = $Config{$var};
90 $val = 'undef' unless defined $val;
91 $val =~ s/\\/\\\\/g;
92 return $val;
93}
94
95sub BackTick
96{
97 my $cmd = shift;
98 if ($cmd =~ /^echo\s+(.*?)\s*\|\s+sed\s+'(.*)'\s*$/)
99  {
100   local ($data,$pat) = ($1,$2);
101   $data =~ s/\s+/ /g;
102   eval "\$data =~ $pat";
103   return $data;
104  }
105 else
106  {
107   die "Cannot handle \`$cmd\`";
108  }
109 return $cmd;
110}
Note: See TracBrowser for help on using the repository browser.