Package: debhelper
Version: 9.20150628
Severity: wishlist
Tags: patch
User: [email protected]
Usertags: rebootstrap
I tried to cross build src:libical. It fails, because cmake selects "cc"
as its compiler. I saw very similar failures for src:attica,
src:automoc, src:charls, src:clucene-core, src:cutecom, src:ebook-tools,
src:game-music-emu, src:garmindev, src:gflags, src:grantlee,
src:graphite2, src:libbluedevil, src:libgooglepinyin, src:libmsn,
src:librabbitmq, src:libsoxr, src:lucene++, src:mppenc,
src:mysql-connector-c++, src:nmapsi4, src:pkg-kde-tools, src:prison,
src:q4wine, src:qimageblitz, src:qjson, src:qzion, src:read-edid,
src:rtl-sdr, src:smokegen, src:taglib, src:taglib-extras, src:thinkfan,
src:tinyxml2, src:v42lucp, src:wbxml2, src:wildmidi, src:x265, src:yagf,
src:yaml-cpp, and src:yaml-cpp0.3. So instead of fixing all of these
packages (and more), I'd like to fix this in debhelper.
I took src:libical as my example and developed a patch that makes it
cross build. The patch is attached and it basically adds lots of flags
to CMake. The flags one should set are explained at
http://www.cmake.org/Wiki/CMake_Cross_Compiling. The good thing is that
this patch actually makes src:libical build.
So I worked from this patch and tried to implement the same approach
into debhelper itself. The result is the other attached patch. Like the
autoconf.pm counterpart, it is only active when the build architecture
and the host architecture differ, so I do note expect any regressions
for native compilation. Yet, cross compilation never worked with CMake,
so I think it is safe to change the behaviour of the build system.
What do you think about the approach?
Helmut
diff -Nru libical-1.0/debian/changelog libical-1.0/debian/changelog
--- libical-1.0/debian/changelog 2015-01-03 14:58:53.000000000 +0100
+++ libical-1.0/debian/changelog 2015-08-02 16:39:10.000000000 +0200
@@ -1,3 +1,10 @@
+libical (1.0-1.4) UNRELEASED; urgency=medium
+
+ * Non-maintainer upload.
+ * Fix FTCBFS. (Closes: #-1)
+
+ -- Helmut Grohne <[email protected]> Sun, 02 Aug 2015 16:39:04 +0200
+
libical (1.0-1.3) unstable; urgency=medium
* Non-maintainer upload.
diff -Nru libical-1.0/debian/rules libical-1.0/debian/rules
--- libical-1.0/debian/rules 2015-01-03 14:58:53.000000000 +0100
+++ libical-1.0/debian/rules 2015-08-02 16:57:22.000000000 +0200
@@ -1,4 +1,34 @@
#!/usr/bin/make -f
+DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
+DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
+DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
+DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+ifeq ($(origin CC),default)
+CC=$(DEB_HOST_GNU_TYPE)-cc
+endif
+ifeq ($(origin CXX),default)
+CXX=$(DEB_HOST_GNU_TYPE)-c++
+endif
+ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH_OS))
+ifeq ($(DEB_HOST_ARCH_OS),linux)
+CMAKE_FLAGS += -DCMAKE_SYSTEM_NAME=Linux
+else
+ifeq ($(DEB_HOST_ARCH_OS),freebsd)
+CMAKE_FLAGS += -DCMAKE_SYSTEM_NAME=FreeBSD
+else
+ifeq ($(DEB_HOST_ARCH_OS),hurd)
+CMAKE_FLAGS += -DCMAKE_SYSTEM_NAME=GNU
+endif
+endif
+endif
+CMAKE_FLAGS += -DCMAKE_SYSTEM_PROCESSOR=$(DEB_HOST_GNU_CPU)
+CMAKE_FLAGS += -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX)
+endif
+
%:
dh $@ --buildsystem=cmake --parallel --list-missing
--dbg-package=libical-dbg
+
+override_dh_auto_configure:
+ dh_auto_configure -- $(CMAKE_FLAGS)
diff -Nru debhelper-9.20150628/Debian/Debhelper/Buildsystem/cmake.pm
debhelper-9.20150628+nmu1/Debian/Debhelper/Buildsystem/cmake.pm
--- debhelper-9.20150628/Debian/Debhelper/Buildsystem/cmake.pm 2015-05-15
18:20:39.000000000 +0200
+++ debhelper-9.20150628+nmu1/Debian/Debhelper/Buildsystem/cmake.pm
2015-08-02 17:26:43.000000000 +0200
@@ -7,7 +7,7 @@
package Debian::Debhelper::Buildsystem::cmake;
use strict;
-use Debian::Debhelper::Dh_Lib qw(compat);
+use Debian::Debhelper::Dh_Lib qw(compat dpkg_architecture_value);
use base 'Debian::Debhelper::Buildsystem::makefile';
sub DESCRIPTION {
@@ -45,6 +45,28 @@
push @flags, "-DCMAKE_VERBOSE_MAKEFILE=ON";
push @flags, "-DCMAKE_BUILD_TYPE=None";
+ if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE")
+ ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) {
+ if (dpkg_architecture_value("DEB_HOST_GNU_OS") eq "linux") {
+ push @flags, "-DCMAKE_SYSTEM_NAME=Linux";
+ } elsif (dpkg_architecture_value("DEB_HOST_GNU_OS") eq
"freebsd") {
+ push @flags, "-DCMAKE_SYSTEM_NAME=FreeBSD";
+ } elsif (dpkg_architecture_value("DEB_HOST_GNU_OS") eq "hurd") {
+ push @flags, "-DCMAKE_SYSTEM_NAME=GNU";
+ }
+ push @flags, "-DCMAKE_SYSTEM_PROCESSOR=" .
dpkg_architecture_value("DEB_HOST_GNU_CPU");
+ if ($ENV{CC}) {
+ push @flags, "-DCMAKE_C_COMPILER=" . $ENV{CC};
+ } else {
+ push @flags, "-DCMAKE_C_COMPILER=" .
dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-cc";
+ }
+ if ($ENV{CXX}) {
+ push @flags, "-DCMAKE_CXX_COMPILER=" . $ENV{CXX};
+ } else {
+ push @flags, "-DCMAKE_CXX_COMPILER=" .
dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-c++";
+ }
+ }
+
# CMake doesn't respect CPPFLAGS, see #653916.
if ($ENV{CPPFLAGS} && ! compat(8)) {
$ENV{CFLAGS} .= ' ' . $ENV{CPPFLAGS};
diff -Nru debhelper-9.20150628/debian/changelog
debhelper-9.20150628+nmu1/debian/changelog
--- debhelper-9.20150628/debian/changelog 2015-06-28 13:56:15.000000000
+0200
+++ debhelper-9.20150628+nmu1/debian/changelog 2015-08-02 17:10:43.000000000
+0200
@@ -1,3 +1,10 @@
+debhelper (9.20150628+nmu1) UNRELEASED; urgency=medium
+
+ * Non-maintainer upload.
+ * Support cross compilation in CMake buildsystem. (Closes: #-1)
+
+ -- Helmut Grohne <[email protected]> Sun, 02 Aug 2015 17:10:22 +0200
+
debhelper (9.20150628) unstable; urgency=medium
* Upload to unstable with ddebs support disabled by default.