summaryrefslogtreecommitdiff
path: root/make_ext.pl
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2013-10-09 03:33:47 -0400
committerSteve Hay <steve.m.hay@googlemail.com>2013-10-21 17:27:58 +0100
commit27329181e393b988b7745c51463210b270f51c87 (patch)
tree19de20700825bb674713eeb07ccaffd9f2ef414a /make_ext.pl
parent9d176cd8dda1d6b2f98386843a92abe96e8a328e (diff)
downloadperl-27329181e393b988b7745c51463210b270f51c87.tar.gz
WinCE Makefile and make_ext.pl general and XS fixes
On a WinCE build. On the 2nd nmake run, using Makefile.ce, eventually calls the Extensions target which calls make_ext.pl. What happens is nmake for CE for each module is called on the Desktop per module makefile from the earlier Desktop build. Since the Desktop Perl already was built sucessfully, all rules/deps are met in the Desktop per module makefile, and nothing happens during the module building phase for a CE build. Previously I used external file management tools to delete the per module Makefiles before running Makefile.ce. *make_ext.pl - implement deleting and rebuilding the per module makefile on a Cross build - use constants for constant folding, there are opportunities for other variables to be converted to constants in the future - fix a bug from commit baff067e71 where unlink() on a file with an open handle ($mfh) didn't delete the file from disk and a new per module makefile would be not be built by make_ext.pl later since the per module makefile was still on disk. This was observed on Win32. Also harden the unlink code with a new _unlink sub that is fatal if the file is still on disk after unlink supposedly deleted it. - var $header and the quotemeta is because of an issue in Perl #119793 *Makefile.ce - bring the debugging symbol generation flags and optimization flags to be closer to a Dekstop VC Perl build - ICWD is obsolete as of commit f6b3c354c9 , remove it - MINIMOD is obsolete as of commit 7b4d95f74b , remove it - make a poisoned config.h so if there is a XS building mixup between a desktop and CE perl, the poisoned config.h for CE will stop the build gracefully - $(MINIPERL) has never been defined in Makefile.ce from day 1 (10 years) replace with $(HPERL) everywhere, this was causing things to not run silently since $(MINIPERL) was empty string. Use HPERL instead of MINIPERL to allow flexibility to use the full perl binary if necessery one day - better cleaning on root makefile clean target *win32/win32.h *win32/win32iop.h - silence alot of redefinition warnings which gave pages of warnings on each WinCE compliand *mg.c - win32_get_errno is only on WIN32 build not WINCE a "nmake -f Makefile.ce all" will now build the CE interp and all modules in 1 shot with no user intervention
Diffstat (limited to 'make_ext.pl')
-rw-r--r--make_ext.pl46
1 files changed, 43 insertions, 3 deletions
diff --git a/make_ext.pl b/make_ext.pl
index 6c2caf0302..55fa5aec87 100644
--- a/make_ext.pl
+++ b/make_ext.pl
@@ -1,6 +1,7 @@
#!./miniperl
use strict;
use warnings;
+use constant IS_CROSS => defined $::Cross::platform ? 1 : 0;
use Config;
my $is_Win32 = $^O eq 'MSWin32';
@@ -155,7 +156,7 @@ if ($is_Win32) {
unless (-f "$pl2bat.bat") {
my @args = ($perl, "-I$topdir\\lib", ("$pl2bat.pl") x 2);
print "@args\n";
- system(@args) unless defined $::Cross::platform;
+ system(@args) unless IS_CROSS;
}
print "In $build";
@@ -299,12 +300,43 @@ sub build_extension {
require ExtUtils::MM_Unix;
defined (my $newv = parse_version MM $vmod) or last;
if ($newv ne $oldv) {
- 1 while unlink $makefile
+ close $mfh or die "close $makefile: $!";
+ _unlink($makefile);
+ {
+ no warnings 'deprecated';
+ goto NO_MAKEFILE;
+ }
}
}
+ if(IS_CROSS){
+ seek($mfh, 0, 0) or die "Cannot seek $makefile: $!";
+ while (<$mfh>) {
+ #this is used to stop the while loop early for efficiency when
+ #the line is reached, and possibly match a cross build
+ my $header = quotemeta '# These definitions are from config.sh (via ';
+ if(/^$header.+?
+ (xlib[\/\\]
+ $::Cross::platform\Q\/Config.pm\E)?\)\./x) {
+ unless (defined $1){
+ print "Deleting non-Cross makefile\n";
+ close $mfh or die "close $makefile: $!";
+ _unlink($makefile);
+ {
+ no warnings 'deprecated';
+ goto NO_MAKEFILE;
+ }
+ } else { #have a cross makefile
+ goto CROSS_OK_MF;
+ }
+ }
+ } #catch breakage from future changes
+ die "non-standard makefile found in $mname";
+ CROSS_OK_MF:
+ }
}
if (!-f $makefile) {
+ NO_MAKEFILE:
if (!-f 'Makefile.PL') {
print "\nCreating Makefile.PL in $ext_dir for $mname\n";
my ($fromname, $key, $value);
@@ -408,7 +440,7 @@ EOM
# Presumably this can be simplified
my @cross;
- if (defined $::Cross::platform) {
+ if (IS_CROSS) {
# Inherited from win32/buildext.pl
@cross = "-MCross=$::Cross::platform";
} elsif ($opts{cross}) {
@@ -504,3 +536,11 @@ sub _quote_args {
} @{$args}
;
}
+
+#guarentee that a file is deleted or die, void _unlink($filename)
+#xxx replace with _unlink_or_rename from EU::Install?
+sub _unlink {
+ 1 while unlink $_[0];
+ my $err = $!;
+ die "Can't unlink $_[0]: $err" if -f $_[0];
+}