summaryrefslogtreecommitdiff
path: root/make_ext.pl
diff options
context:
space:
mode:
authorBrian Fraser <fraserbn@gmail.com>2013-11-13 00:02:41 -0300
committerBrian Fraser <fraserbn@gmail.com>2014-01-22 13:08:22 -0300
commit4b22620880a7e86cd65571b97f365bf0e5736473 (patch)
treebddfc46fca024e16331991e52c969e40cd1b40f4 /make_ext.pl
parent3c32af271d49f3c027fd33194d2508a5bf362931 (diff)
downloadperl-4b22620880a7e86cd65571b97f365bf0e5736473.tar.gz
make_ext.pl: Phase out the use of Cross.pm
In the old cross-compilation model, lib/ for the target would end up in xlib/; What Cross.pm did back then was change @INC around a bit to have miniperl point to xlib; Additionally, it was used to identify cross-compilation builds, and in make_ext.pl to detect whenever a Makefile was from the host's build. There is no longer any need for the first, and the second is now a simple check for $Config{usecrosscompile}, it's still possible for the hosts' Makefiles to be there, particularly if the host was not compiled elsewhere using -Dmksymlinks, like in Windows when targetting WinCE. This commit changes make_ext.pl for cross-compiling builds to only delete Makefiles when their CC != $Config{cc}.
Diffstat (limited to 'make_ext.pl')
-rw-r--r--make_ext.pl65
1 files changed, 28 insertions, 37 deletions
diff --git a/make_ext.pl b/make_ext.pl
index c857130a15..98ed3cc6e1 100644
--- a/make_ext.pl
+++ b/make_ext.pl
@@ -1,8 +1,8 @@
#!./miniperl
use strict;
use warnings;
-use constant IS_CROSS => defined $::Cross::platform ? 1 : 0;
use Config;
+use constant IS_CROSS => defined $Config::Config{usecrosscompile} ? 1 : 0;
my $is_Win32 = $^O eq 'MSWin32';
my $is_VMS = $^O eq 'VMS';
@@ -310,31 +310,32 @@ sub build_extension {
}
}
}
- 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 (IS_CROSS) {
+ # If we're cross-compiling, it's possible that the host's
+ # Makefiles are around.
+ seek($mfh, 0, 0) or die "Cannot seek $makefile: $!";
+
+ my $cross_makefile;
+ while (<$mfh>) {
+ # XXX This might not be throughout enough.
+ # For example, it's possible to cause a false-positive
+ # if cross compiling on and for the Raspberry Pi,
+ # which is insane but plausible.
+ # False positives are really not troublesome, though;
+ # all they mean is that the module gets rebuilt.
+ if (/^CC = \Q$Config{cc}\E/) {
+ $cross_makefile = 1;
+ last;
+ }
+ }
+
+ if (!$cross_makefile) {
+ print "Deleting non-Cross makefile\n";
+ close $mfh or die "close $makefile: $!";
+ _unlink($makefile);
+ }
+ }
}
if (!-f $makefile) {
@@ -441,17 +442,7 @@ EOM
}
print "\nRunning Makefile.PL in $ext_dir\n";
- # Presumably this can be simplified
- my @cross;
- if (IS_CROSS) {
- # Inherited from win32/buildext.pl
- @cross = "-MCross=$::Cross::platform";
- } elsif ($opts{cross}) {
- # Inherited from make_ext.pl
- @cross = '-MCross';
- }
-
- my @args = ("-I$lib_dir", @cross, 'Makefile.PL');
+ my @args = ("-I$lib_dir", 'Makefile.PL');
if ($is_VMS) {
my $libd = VMS::Filespec::vmspath($lib_dir);
push @args, "INST_LIB=$libd", "INST_ARCHLIB=$libd";