Source: wordgrinder
Version: 0.8-1
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

wordgrinder fails to cross build from source for multiple reasons. It
starts with wordgrinder running plain make without passing any cross
tools. That part is best solved by using dh_auto_build. Then, the
makefile runs a build.lua script that hard codes the build architecture
pkg-config. PKG_CONFIG support should be added to both Makefile and
build.lua. Beyond that, it strips with the build architecture strip. In
addition to breaking cross compilation, that approach also breaks
generation of -dbgsym packages as well as DEB_BUILD_OPTIONS=nostrip. It
is best to defer stripping to dh_strip and that happens to fix the cross
build aspect as well.

The attached patch fixes all of the issues mentioned above. However, it
does not make cross builds succeed as the test suite fails. Cross builds
do pass nocheck via DEB_BUILD_OPTIONS, but wordgrinder does not honour
that. So the next step is adding nocheck support.

Anyway, please consider applying the attached patch as an incremental
step and close this bug when doing so even without adding nocheck
support.

Helmut
diff --minimal -Nru wordgrinder-0.8/debian/changelog 
wordgrinder-0.8/debian/changelog
--- wordgrinder-0.8/debian/changelog    2020-10-16 21:22:20.000000000 +0200
+++ wordgrinder-0.8/debian/changelog    2021-11-17 11:31:26.000000000 +0100
@@ -1,3 +1,14 @@
+wordgrinder (0.8-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Improve cross building. (Closes: #-1)
+    + Let dh_auto_build pass cross tools to make.
+    + Makefile: forward PKG_CONFIG to build.lua.
+    + build.lua: use provided PKG_CONFIG.
+    + Defer stripping to dh_strip.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Wed, 17 Nov 2021 11:31:26 +0100
+
 wordgrinder (0.8-1) unstable; urgency=medium
 
   * New upstream release
diff --minimal -Nru wordgrinder-0.8/debian/patches/cross.patch 
wordgrinder-0.8/debian/patches/cross.patch
--- wordgrinder-0.8/debian/patches/cross.patch  1970-01-01 01:00:00.000000000 
+0100
+++ wordgrinder-0.8/debian/patches/cross.patch  2021-11-17 11:31:22.000000000 
+0100
@@ -0,0 +1,39 @@
+--- wordgrinder-0.8.orig/Makefile
++++ wordgrinder-0.8/Makefile
+@@ -17,6 +17,8 @@
+ # The compiler used for the native build (curses, X11)
+ CC ?= cc
+ 
++PKG_CONFIG ?= pkg-config
++
+ # Which ninja do you want to use?
+ ifeq ($(strip $(shell type ninja >/dev/null; echo $$?)),0)
+       NINJA ?= ninja
+@@ -160,6 +162,7 @@
+               BINDIR="$(BINDIR)" \
+               BUILDFILE="$@.tmp" \
+               CC="$(CC)" \
++              PKG_CONFIG="$(PKG_CONFIG)" \
+               CFLAGS="$(CFLAGS)" \
+               CURSES_PACKAGE="$(CURSES_PACKAGE)" \
+               DATE="$(DATE)" \
+--- wordgrinder-0.8.orig/build.lua
++++ wordgrinder-0.8/build.lua
+@@ -30,7 +30,7 @@
+     if package == "builtin" then
+         return true
+     end
+-    local r = os.execute("pkg-config "..package)
++    local r = os.execute(PKG_CONFIG.." "..package)
+     return (r == 0) or (r == true)
+ end
+ 
+@@ -75,7 +75,7 @@
+     end
+ 
+     local filename = os.tmpname()
+-    local e = os.execute("pkg-config "..kind.." "..package.." > "..filename)
++    local e = os.execute(PKG_CONFIG.." "..kind.." "..package.." > "..filename)
+     if (e ~= 0) and (e ~= true) then
+         error("required package "..package.." is not available")
+     end
diff --minimal -Nru wordgrinder-0.8/debian/patches/series 
wordgrinder-0.8/debian/patches/series
--- wordgrinder-0.8/debian/patches/series       2020-10-16 21:22:20.000000000 
+0200
+++ wordgrinder-0.8/debian/patches/series       2021-11-17 11:30:01.000000000 
+0100
@@ -1,2 +1,3 @@
 no-maths-library.patch
 no-freetype-library.patch
+cross.patch
diff --minimal -Nru wordgrinder-0.8/debian/rules wordgrinder-0.8/debian/rules
--- wordgrinder-0.8/debian/rules        2020-10-16 21:22:20.000000000 +0200
+++ wordgrinder-0.8/debian/rules        2021-11-17 11:31:26.000000000 +0100
@@ -20,7 +20,7 @@
        LUA_INTERPRETER=/usr/bin/lua5.3 \
        CFLAGS="$(CPPFLAGS) $(CFLAGS)" \
        LDFLAGS="$(LDFLAGS)" \
-       WANT_STRIPPED_BINARIES=yes
+       WANT_STRIPPED_BINARIES=no
 
 # Use hardening build flags.
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
@@ -30,7 +30,7 @@
 .PHONY: override_dh_auto_build
 override_dh_auto_build:
        dh_testdir
-       make all $(PACKAGE_VARS)
+       dh_auto_build -- all $(PACKAGE_VARS)
        
 .PHONY: override_dh_auto_test
 override_dh_auto_test:

Reply via email to