Subject: | [Fwd: a small cross-compilation patch for makemaker] |
Date: | Sun, 26 Apr 2009 14:43:01 -0700 |
To: | via RT <bug-ExtUtils-MakeMaker [...] rt.cpan.org> |
From: | Michael G Schwern <schwern [...] pobox.com> |
Show quoted text
-------- Original Message --------
Subject: a small cross-compilation patch for makemaker
Date: Fri, 10 Oct 2008 15:28:24 +0200
From: Konovalov, Vadim (Vadim)** CTR ** <vkonovalov@alcatel-lucent.com>
To: <makemaker@perl.org>
Hi,
I would like to ask for the attached patch, which makes it possible to
implement cross-compilation in perl, to be applied.
Thanks in advance,
Vadim.
--
Reality is that which, when you stop believing in it, doesn't go away.
-- Phillip K. Dick
diff -ru bperl-orig/lib/ExtUtils/MM_Unix.pm perl-34456/lib/ExtUtils/MM_Unix.pm
--- bperl-orig/lib/ExtUtils/MM_Unix.pm 2008-09-29 13:14:49.000000000 +0400
+++ perl-34456/lib/ExtUtils/MM_Unix.pm 2008-10-05 20:01:57.000000000 +0400
@@ -146,7 +146,7 @@
$command -S $flags \$*.c
.c\$(OBJ_EXT):
- $command $flags \$*.c
+ $command $flags -o \$*\$(OBJ_EXT) \$*.c
.cpp\$(OBJ_EXT):
$command $flags \$*.cpp
@@ -2583,7 +2583,7 @@
my $newer_than_target = $Is{VMS} ? '$(MMS$SOURCE_LIST)' : '$?';
my $mpl_args = join " ", map qq["$_"], @ARGV;
- $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $mpl_args;
+ $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $mpl_args unless defined $Cross::platform;
# We take a very conservative approach here, but it's worth it.
# We move Makefile to Makefile.old here to avoid gnu make looping.
$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
@@ -2788,19 +2788,30 @@
my($self) = shift;
my(@m);
+ my $configsh = "config.sh";
my $make_config = $self->cd('$(PERL_SRC)', '$(MAKE) lib/Config.pm');
- push @m, sprintf <<'MAKE_FRAG', $make_config if $self->{PERL_SRC};
+ if (defined $Cross::platform) {
+ # in cross-compiling the dependant config.sh contains cross-identifier
+ # in its name, yet Config.pm is located in ./xlib/xxxx/
+ $make_config = $self->cd('$(PERL_SRC)', "\$(MAKE) xlib/$Cross::platform/Config.pm");
+ $configsh = "config-$Cross::platform.sh";
+ }
+
+ if ($self->{PERL_SRC}) {
+ push @m, "CONFIGSH = \$(PERL_SRC)/$configsh\n";
+ push @m, sprintf <<'MAKE_FRAG', $make_config;
# Check for unpropogated config.sh changes. Should never happen.
# We do NOT just update config.h because that is not sufficient.
# An out of date config.h is not fatal but complains loudly!
-$(PERL_INC)/config.h: $(PERL_SRC)/config.sh
- -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
+$(PERL_INC)/config.h: $(CONFIGSH)
+ -$(NOECHO) $(ECHO) "Warning: $(PERL_INC)/config.h out of date with $(CONFIGSH)"; false
-$(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
- $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
+$(PERL_ARCHLIB)/Config.pm: $(CONFIGSH)
+ $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(CONFIGSH)"
%s
MAKE_FRAG
+ }
return join "", @m unless $self->needs_linking;
@@ -3716,7 +3727,7 @@
'
.xs$(OBJ_EXT):
$(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
- $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
+ $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) -o $*$(OBJ_EXT) $*.c
';
}