summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2016-09-18 19:58:47 +0000
committerNiels Thykier <niels@thykier.net>2016-09-18 19:58:47 +0000
commit7ea67c9aace4692efd026c242cc4445881ec5df6 (patch)
treee039194cc21ccf58cc9a53de7d07b07e9a4c3eef
parent23149c7a7f834305df2dec3186a48cbe534b19db (diff)
downloaddebhelper-7ea67c9aace4692efd026c242cc4445881ec5df6.tar.gz
makefile.pm: Set CC+CXX to the host compilers when cross-building
Co-Author: Helmut Grohne <helmut@subdivi.de> Signed-off-by: Niels Thykier <niels@thykier.net>
-rw-r--r--Debian/Debhelper/Buildsystem/makefile.pm16
-rw-r--r--debian/changelog4
2 files changed, 19 insertions, 1 deletions
diff --git a/Debian/Debhelper/Buildsystem/makefile.pm b/Debian/Debhelper/Buildsystem/makefile.pm
index 7203349e..6ea8e39f 100644
--- a/Debian/Debhelper/Buildsystem/makefile.pm
+++ b/Debian/Debhelper/Buildsystem/makefile.pm
@@ -8,9 +8,14 @@ package Debian::Debhelper::Buildsystem::makefile;
use strict;
use warnings;
-use Debian::Debhelper::Dh_Lib qw(escape_shell clean_jobserver_makeflags);
+use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value escape_shell clean_jobserver_makeflags is_cross_compiling);
use parent qw(Debian::Debhelper::Buildsystem);
+my %DEB_DEFAULT_TOOLS = (
+ 'CC' => 'gcc',
+ 'CXX' => 'g++',
+);
+
# make makes things difficult by not providing a simple way to test
# whether a Makefile target exists. Using -n and checking for a nonzero
# exit status is not good enough, because even with -n, make will
@@ -127,6 +132,15 @@ sub check_auto_buildable {
sub build {
my $this=shift;
+ if (ref($this) eq 'Debian::Debhelper::Buildsystem::makefile' and is_cross_compiling()) {
+ while (my ($var, $tool) = each %DEB_DEFAULT_TOOLS) {
+ if ($ENV{$var}) {
+ unshift @_, $var . "=" . $ENV{$var};
+ } else {
+ unshift @_, $var . "=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-" . $tool;
+ }
+ }
+ }
$this->do_make(@_);
}
diff --git a/debian/changelog b/debian/changelog
index b4446c38..534a24b5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,10 @@ debhelper (10+unreleased) UNRELEASED; urgency=medium
* Apply patch from Helmut Grohne and Julian Andres Klode
to improve cross-building support in the cmake build
system. (Closes: #833789)
+ * Make the makefile.pm buildsystem (but not subclasses thereof)
+ pass the CC and CXX variables set to the host compilers when
+ cross-building. Thanks to Helmut Grohne for the idea and
+ the initial patch. (Closes: #836988)
-- Niels Thykier <niels@thykier.net> Wed, 14 Sep 2016 06:07:02 +0000