Source: jgmenu
Version: 4.5.0-1
Tags: patch
User: [email protected]
Usertags: ftcbfs

jgmenu fails to cross build from source. Its buildsystem basically has
no clue about cross building and just uses build architecture build
tools. Its configure script quickly fails on locating dependencies.

Generally, we want the buildsystem to use tools prefixed with the host
architecture. Additionally, the presence of a configure script usually
means that configure figures out all the tooling to use. This configure
does neither.

I am proposing a relatively minimal patch (which is still impressive in
size). It'll add a --pkg-config option to configure. Unlike the common
approach, I'm asking debhelper to pass cross tools to make despite the
presence of configure by forcing it back to the makefile buildsystem. To
achieve success, all uses of pkg-config both in configure and the
Makefiles must become substitutable.

This patch makes jgmenu cross buildable. A better approach would be for
configure to not just check for dependencies using pkg-config, but
actually extract the compiler flags and linker flags and store those in
Makefile.inc. Then, the makefiles would never invoke pkg-config nor need
to know its name. That approach felt too invasive to me though.

Helmut
diff -Nru jgmenu-4.5.0/debian/changelog jgmenu-4.5.0/debian/changelog
--- jgmenu-4.5.0/debian/changelog       2025-01-03 20:36:14.000000000 +0100
+++ jgmenu-4.5.0/debian/changelog       2025-12-19 10:03:43.000000000 +0100
@@ -1,3 +1,13 @@
+jgmenu (4.5.0-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: (Closes: #-1)
+    + Patch upstream buildsystem to make pkg-config substitutable.
+    + Pass cross tools to make.
+  * Honour DEB_BUILD_OPTIONS=terse and build verbosely by default.
+
+ -- Helmut Grohne <[email protected]>  Fri, 19 Dec 2025 10:03:43 +0100
+
 jgmenu (4.5.0-1) unstable; urgency=medium
 
   * New upstream release.
diff -Nru jgmenu-4.5.0/debian/patches/cross.patch 
jgmenu-4.5.0/debian/patches/cross.patch
--- jgmenu-4.5.0/debian/patches/cross.patch     1970-01-01 01:00:00.000000000 
+0100
+++ jgmenu-4.5.0/debian/patches/cross.patch     2025-12-19 10:03:43.000000000 
+0100
@@ -0,0 +1,132 @@
+Index: jgmenu-4.5.0/configure
+===================================================================
+--- jgmenu-4.5.0.orig/configure
++++ jgmenu-4.5.0/configure
+@@ -3,6 +3,7 @@
+ config_mk="config.mk"
+ enable_asan=f
+ prefix="/usr/local"
++pkg_config=pkg-config
+ with_xfce4_panel_applet=f
+ with_gtktheme=f
+ with_lx=f
+@@ -20,6 +21,7 @@ Produce a config.mk file to be sourced b
+ --dev, -d                  Same as --all, but also with ASAN and prefix=\$HOME
+ --enable-asan              Enable address sanitizer (only during development)
+ --disable-svg              Disable SVG icon support
++--pkg-config=<path>        Specify the name of the pkg-config executable
+ --prefix=<dir>             Install architecture-independent files in \$prefix
+                            (e.g. --prefix=\$HOME')
+ --libdir=<dir>             Specify libdir (\$prefix/lib by default)
+@@ -45,12 +47,12 @@ check_bin () {
+ }
+ 
+ check_lib () {
+-      pkg-config "$*" >/dev/null 2>&1
++      "$pkg_config" "$*" >/dev/null 2>&1
+       print_ok_fail $? $*
+ }
+ 
+ check_core_dependencies () {
+-      for b in "pkg-config" "xml2-config"; do
++      for b in "$pkg_config" "xml2-config"; do
+               check_bin "$b"
+       done
+       for l in "x11" "xrandr" "cairo" "pango" "pangocairo" "glib-2.0"; do
+@@ -104,6 +106,8 @@ main () {
+               opt=${arg%%=*}
+               var=${arg#*=}
+               case "$opt" in
++              --pkg-config)
++                      pkg_config="$var" ;;
+               --prefix)
+                       prefix="$var" ;;
+               --libdir)
+Index: jgmenu-4.5.0/Makefile
+===================================================================
+--- jgmenu-4.5.0.orig/Makefile
++++ jgmenu-4.5.0/Makefile
+@@ -13,18 +13,18 @@ VER      = $(shell ./scripts/version-gen
+ -include config.mk
+ include Makefile.inc
+ 
+-jgmenu:         CFLAGS += `pkg-config cairo pango pangocairo $(RSVG_LIB) 
--cflags` $(RSVG_FLAGS)
++jgmenu:         CFLAGS += `$(PKG_CONFIG) cairo pango pangocairo $(RSVG_LIB) 
--cflags` $(RSVG_FLAGS)
+ jgmenu-ob:      CFLAGS += `xml2-config --cflags`
+ jgmenu-obtheme: CFLAGS += `xml2-config --cflags`
+-jgmenu-config:  CFLAGS += `pkg-config --cflags glib-2.0`
+-jgmenu-apps:    CFLAGS += `pkg-config --cflags glib-2.0`
++jgmenu-config:  CFLAGS += `$(PKG_CONFIG) --cflags glib-2.0`
++jgmenu-apps:    CFLAGS += `$(PKG_CONFIG) --cflags glib-2.0`
+ 
+-jgmenu:         LIBS   += `pkg-config x11 xrandr cairo pango pangocairo 
$(RSVG_LIB) --libs` $(RSVG_FLAGS)
++jgmenu:         LIBS   += `$(PKG_CONFIG) x11 xrandr cairo pango pangocairo 
$(RSVG_LIB) --libs` $(RSVG_FLAGS)
+ jgmenu:         LIBS   += -pthread -lpng
+ jgmenu-ob:      LIBS   += `xml2-config --libs`
+ jgmenu-obtheme: LIBS   += `xml2-config --libs`
+-jgmenu-config:  LIBS   += `pkg-config --libs glib-2.0`
+-jgmenu-apps:    LIBS   += `pkg-config --libs glib-2.0`
++jgmenu-config:  LIBS   += `$(PKG_CONFIG) --libs glib-2.0`
++jgmenu-apps:    LIBS   += `$(PKG_CONFIG) --libs glib-2.0`
+ 
+ LDFLAGS += $(LIBS)
+ 
+Index: jgmenu-4.5.0/Makefile.inc
+===================================================================
+--- jgmenu-4.5.0.orig/Makefile.inc
++++ jgmenu-4.5.0/Makefile.inc
+@@ -1,3 +1,4 @@
++PKG_CONFIG ?= pkg-config
+ RM      ?= rm -f
+ prefix  ?= /usr/local
+ bindir  ?= $(prefix)/bin
+Index: jgmenu-4.5.0/contrib/lx/Makefile
+===================================================================
+--- jgmenu-4.5.0.orig/contrib/lx/Makefile
++++ jgmenu-4.5.0/contrib/lx/Makefile
+@@ -1,8 +1,8 @@
+ -include ../../config.mk
+ include ../../Makefile.inc
+ 
+-CFLAGS  += `pkg-config --cflags glib-2.0 libmenu-cache`
+-LDFLAGS += `pkg-config --libs glib-2.0 libmenu-cache`
++CFLAGS  += `$(PKG_CONFIG) --cflags glib-2.0 libmenu-cache`
++LDFLAGS += `$(PKG_CONFIG) --libs glib-2.0 libmenu-cache`
+ 
+ path = ../../src/
+ src  = util.c sbuf.c xdgdirs.c argv-buf.c back.c fmt.c
+Index: jgmenu-4.5.0/contrib/xfce4-panel/Makefile
+===================================================================
+--- jgmenu-4.5.0.orig/contrib/xfce4-panel/Makefile
++++ jgmenu-4.5.0/contrib/xfce4-panel/Makefile
+@@ -1,14 +1,14 @@
+ -include ../../config.mk
+ include ../../Makefile.inc
+ 
+-libdir    ?= `pkg-config --variable=libdir libxfce4panel-2.0`
++libdir    ?= `$(PKG_CONFIG) --variable=libdir libxfce4panel-2.0`
+ LIBDIR     = $(DESTDIR)$(libdir)/xfce4/panel/plugins
+ PLUGIN_DIR = $(DESTDIR)$(prefix)/share/xfce4/panel/plugins
+ 
+ CFLAGS  += -Wno-strict-prototypes -Wno-declaration-after-statement
+ CFLAGS  += -s -shared -fPIC
+-CFLAGS  += `pkg-config --cflags libxfce4panel-2.0`
+-LDFLAGS += `pkg-config --libs   libxfce4panel-2.0`
++CFLAGS  += `$(PKG_CONFIG) --cflags libxfce4panel-2.0`
++LDFLAGS += `$(PKG_CONFIG) --libs   libxfce4panel-2.0`
+ 
+ xfce4-panel: libjgmenu.so
+ 
+Index: jgmenu-4.5.0/tests/helper/Makefile
+===================================================================
+--- jgmenu-4.5.0.orig/tests/helper/Makefile
++++ jgmenu-4.5.0/tests/helper/Makefile
+@@ -28,7 +28,7 @@ test-sbuf: test-sbuf.c $(src)sbuf.c $(ut
+       $(CC) $(CFLAGS) -o $@ $^ -I$(src) $(LDFLAGS)
+ 
+ test-xpm: test-xpm.c $(src)xpm-loader.c $(util)
+-      $(CC) $(CFLAGS) -o $@ $^ -I$(src) $(LDFLAGS) `pkg-config cairo --cflags 
--libs`
++      $(CC) $(CFLAGS) -o $@ $^ -I$(src) $(LDFLAGS) `$(PKG_CONFIG) cairo 
--cflags --libs`
+ 
+ test-dirs: test-dirs.c $(src)dirs.c $(src)xdgdirs.c $(src)argv-buf.c 
$(src)compat.c $(src)lang.c $(util)
+       $(CC) $(CFLAGS) -o $@ $^ -I$(src) $(LDFLAGS)
diff -Nru jgmenu-4.5.0/debian/patches/series jgmenu-4.5.0/debian/patches/series
--- jgmenu-4.5.0/debian/patches/series  1970-01-01 01:00:00.000000000 +0100
+++ jgmenu-4.5.0/debian/patches/series  2025-12-19 10:00:52.000000000 +0100
@@ -0,0 +1 @@
+cross.patch
diff -Nru jgmenu-4.5.0/debian/rules jgmenu-4.5.0/debian/rules
--- jgmenu-4.5.0/debian/rules   2021-03-28 18:28:51.000000000 +0200
+++ jgmenu-4.5.0/debian/rules   2025-12-19 10:03:43.000000000 +0100
@@ -1,5 +1,6 @@
 #!/usr/bin/make -f
 
+include /usr/share/dpkg/buildtools.mk
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 DPKG_EXPORT_BUILDFLAGS = 1
 include /usr/share/dpkg/buildflags.mk
@@ -9,13 +10,14 @@
 
 override_dh_auto_configure:
        dh_auto_configure -- \
+               --pkg-config=$(PKG_CONFIG) \
                --prefix=/usr \
                --with-lx \
                --with-xfce4-panel-applet \
                --with-gtktheme
 
 override_dh_auto_build:
-       dh_auto_build -- CONTRIB_DIRS="xfce4-panel gtktheme lx"
+       dh_auto_build --buildsystem=makefile -- CONTRIB_DIRS="xfce4-panel 
gtktheme lx" $(if $(filter terse,$(DEB_BUILD_OPTIONS)),,VERBOSE=1)
 
 override_dh_auto_install:
        dh_auto_install -- prefix=/usr CONTRIB_DIRS="xfce4-panel gtktheme lx"

Reply via email to