[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#877357: debhelper: Make qmake buildsystem support cross building



Package: debhelper
Version: 10.9
Severity: wishlist
Tags: patch

Dear debhelper maintainers,

I am attaching two patches against Git master that should make packages
using qmake buildsystem cross-buildable (at least some of them).

The first patch sets the proper toolchain commands, the second one adds
a very basic qt.conf so that qmake searches for Qt headers in a proper
location. It was enough in my case, but we may extend it with other paths
later if needed.

--
Dmitry Shachnev
From bc931b90ae9181c63957c4038c64d94add6a9c0b Mon Sep 17 00:00:00 2001
From: Dmitry Shachnev <mitya57@gmail.com>
Date: Sat, 30 Sep 2017 23:38:29 +0300
Subject: [PATCH 1/2] qmake.pm: Add initial support for cross-building

---
 lib/Debian/Debhelper/Buildsystem/qmake.pm | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/Debian/Debhelper/Buildsystem/qmake.pm b/lib/Debian/Debhelper/Buildsystem/qmake.pm
index c39c2474..9618334f 100644
--- a/lib/Debian/Debhelper/Buildsystem/qmake.pm
+++ b/lib/Debian/Debhelper/Buildsystem/qmake.pm
@@ -8,7 +8,7 @@ package Debian::Debhelper::Buildsystem::qmake;
 
 use strict;
 use warnings;
-use Debian::Debhelper::Dh_Lib qw(error);
+use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value error is_cross_compiling);
 use parent qw(Debian::Debhelper::Buildsystem::makefile);
 
 our $qmake="qmake";
@@ -52,6 +52,10 @@ sub configure {
 
 	push @options, '-makefile';
 	push @options, '-nocache';
+	if (is_cross_compiling()) {
+		# Force generic mkspec to avoid -m32 / -m64 flags
+		push @options, ("-spec", "linux-g++");
+	}
 
 	if ($ENV{CFLAGS}) {
 		push @flags, "QMAKE_CFLAGS_RELEASE=$ENV{CFLAGS} $ENV{CPPFLAGS}";
@@ -68,6 +72,21 @@ sub configure {
 	push @flags, "QMAKE_STRIP=:";
 	push @flags, "PREFIX=/usr";
 
+	if (is_cross_compiling()) {
+		if ($ENV{CC}) {
+			push @flags, "QMAKE_CC=" . $ENV{CC};
+		} else {
+			push @flags, "QMAKE_CC=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-gcc";
+		}
+		if ($ENV{CXX}) {
+			push @flags, "QMAKE_CXX=" . $ENV{CXX};
+		} else {
+			push @flags, "QMAKE_CXX=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-g++";
+		}
+		push @flags, "QMAKE_LINK=\$(CXX)";
+		push @flags, "PKG_CONFIG=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-pkg-config";
+	}
+
 	$this->mkdir_builddir();
 	$this->doit_in_builddir($qmake, @options, @flags, @_);
 }
-- 
2.14.2

From 32c2f3ce473f40f8711c7a6ed2220d7fd51aeea0 Mon Sep 17 00:00:00 2001
From: Dmitry Shachnev <mitya57@gmail.com>
Date: Sat, 30 Sep 2017 23:55:31 +0300
Subject: [PATCH 2/2] qmake.pm: Use a custom qt.conf file for cross builds

---
 lib/Debian/Debhelper/Buildsystem/qmake.pm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/Debian/Debhelper/Buildsystem/qmake.pm b/lib/Debian/Debhelper/Buildsystem/qmake.pm
index 9618334f..c25206a8 100644
--- a/lib/Debian/Debhelper/Buildsystem/qmake.pm
+++ b/lib/Debian/Debhelper/Buildsystem/qmake.pm
@@ -8,6 +8,7 @@ package Debian::Debhelper::Buildsystem::qmake;
 
 use strict;
 use warnings;
+use File::Temp qw(tempfile);
 use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value error is_cross_compiling);
 use parent qw(Debian::Debhelper::Buildsystem::makefile);
 
@@ -55,6 +56,14 @@ sub configure {
 	if (is_cross_compiling()) {
 		# Force generic mkspec to avoid -m32 / -m64 flags
 		push @options, ("-spec", "linux-g++");
+
+		my ($fh, $filename) = tempfile("qt.XXXX", SUFFIX => ".conf", TMPDIR => 1, UNLINK => 1);
+		$fh->print("[Paths]\n");
+		$fh->print("Prefix=/usr\n");
+		$fh->print("HostData=lib/" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "/qt5\n");
+		$fh->print("Headers=include/" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "/qt5\n");
+		close $fh;
+		push @options, ("-qtconf", $filename);
 	}
 
 	if ($ENV{CFLAGS}) {
-- 
2.14.2

Attachment: signature.asc
Description: PGP signature


Reply to: