This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
new perldelta for 5.29.4
[perl5.git] / win32 / config_h.PL
index 6b7fbda..e755007 100644 (file)
@@ -26,7 +26,7 @@ $opt{CORE_DIR} ||= '../lib/CORE';
 
 warn "Writing $opt{CONFIG_H}\n";
 
-open(SH,"<$name") || die "Cannot open $name:$!";
+open(SH, "<", $name) || die "Cannot open $name:$!";
 while (<SH>)
  {
   last if /^\s*sed/;
@@ -50,7 +50,7 @@ eval $str;
 
 die "$str:$@" if $@;
 
-open(H,">$file.new") || die "Cannot open $file.new:$!";
+open(H, ">", "$file.new") || die "Cannot open $file.new:$!";
 binmode(H);
 while (<SH>)
  {
@@ -63,7 +63,12 @@ while (<SH>)
   s#(.)/\*\*/#$1/ **/# if(/^\/\*/); #avoid "/*" inside comments
   if (/^\s*#define\s+(PRIVLIB|SITELIB|VENDORLIB)_EXP/)
    {
-     $_ = "#define ". $1 . "_EXP (win32_get_". lc($1) . "(PERL_VERSION_STRING, NULL))\t/**/\n";
+     $_ = '#define '. $1 . '_EXP ('.(
+       $1 eq 'PRIVLIB' ? 'PerlEnv_lib_path' :
+       $1 eq 'SITELIB' ? 'PerlEnv_sitelib_path' :
+       $1 eq 'VENDORLIB' ? 'PerlEnv_vendorlib_path' :
+       die "unknown *LIB_EXP define \"$1\""
+       ). "(PERL_VERSION_STRING, NULL))\t/**/\n";
    }
   # incpush() handles archlibs, so disable them
   elsif (/^\s*#define\s+(ARCHLIB|SITEARCH|VENDORARCH)_EXP/)
@@ -79,23 +84,24 @@ while (<SH>)
 close(H);
 close(SH);
 
-
-chmod(0666,"$opt{CORE_DIR}/$opt{CONFIG_H}");
-copy("$file.new","$opt{CORE_DIR}/$opt{CONFIG_H}") || die "Cannot copy:$!";
-chmod(0444,"$opt{CORE_DIR}/$opt{CONFIG_H}");
+my $core_config_h = "$opt{CORE_DIR}/$opt{CONFIG_H}";
+if (compare("$file.new", $core_config_h)) {
+    mkdir $opt{CORE_DIR} unless -d $opt{CORE_DIR};
+    chmod(0666,$core_config_h);
+    copy("$file.new",$core_config_h) || die "Cannot copy:$!";
+    chmod(0444,$core_config_h);
+}
 
 if (compare("$file.new",$file))
  {
   warn "$file has changed\n";
   chmod(0666,$file);
   unlink($file);
-  rename("$file.new",$file);
-  exit(1);
+  rename("$file.new",$file) || die "Cannot rename:$!";
  }
 else
  {
   unlink ("$file.new");
-  exit(0);
  }
 
 sub Config