Source: jool
Version: 4.1.14-3
Tags: patch upstream
User: [email protected]
Usertags: ftcbfs

jool fails to cross build from source, because it builds its iptables 
extension for the build architecture. It's an autoconf/automake project, 
but the src/usr/iptables directory contains a bare Makefile. It is this 
hand-off where the toolchain is lost as automake expects each Makefile 
to be aware of the toolchain, but this one isn't.

I propose using the "-local" hook mechanism to run the submake 
explicitly and thus be able to pass the toolchain. This is implemented 
in the attached patch and it makes jool cross buildable. Please consider 
applying it and forwarding it upstream as it also helps other Linux 
distributions.

Helmut
--- jool-4.1.14.orig/configure.ac
+++ jool-4.1.14/configure.ac
@@ -44,9 +44,12 @@
 		[Include xtables dependency? @<:@default=yes@:>@]
 	)
 )
+XTABLES_SO_DIR=
 AS_IF([test "x$with_xtables" != "xno"], [
 	PKG_CHECK_MODULES(XTABLES, xtables)
+	XTABLES_SO_DIR=`$PKG_CONFIG xtables --variable xtlibdir`
 ])
+AC_SUBST([XTABLES_SO_DIR])
 AM_CONDITIONAL([XTABLES_ENABLED], [test "x$with_xtables" != "xno"])
 
 # Bash autocompletion option (https://www.swansontec.com/bash-completion.html):
--- jool-4.1.14.orig/src/usr/Makefile.am
+++ jool-4.1.14/src/usr/Makefile.am
@@ -1,5 +1,12 @@
 if XTABLES_ENABLED
-MAYBE_XTABLES = iptables
+all-local:
+	$(MAKE) -C iptables all CC='$(CC)' CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' XTABLES_CFLAGS='$(XTABLES_CFLAGS)' XTABLES_SO_DIR='$(XTABLES_SO_DIR)'
+clean-local:
+	$(MAKE) -C iptables clean
+install-exec-local:
+	$(MAKE) -C iptables install XTABLES_SO_DIR='$(XTABLES_SO_DIR)'
+uninstall-local:
+	$(MAKE) -C iptables uninstall XTABLES_SO_DIR='$(XTABLES_SO_DIR)'
 endif
 
-SUBDIRS = util nl argp siit nat64 $(MAYBE_XTABLES) joold
+SUBDIRS = util nl argp siit nat64 joold
--- jool-4.1.14.orig/src/usr/iptables/Makefile
+++ jool-4.1.14/src/usr/iptables/Makefile
@@ -20,7 +20,7 @@
 
 DEFAULT_CFLAGS  = -Wall -pedantic -std=gnu11 -O2
 DEFAULT_CFLAGS += -I../..
-DEFAULT_CFLAGS += $(shell pkg-config xtables --cflags)
+XTABLES_CFLAGS = $(shell pkg-config xtables --cflags)
 
 XTABLES_SO_DIR = $(shell pkg-config xtables --variable xtlibdir)
 
@@ -36,7 +36,7 @@
 lib%.so: lib%.o
 	${CC} -shared -fPIC ${LDFLAGS} -o $@ $^;
 lib%.o: lib%.c
-	${CC} ${DEFAULT_CFLAGS} ${CPPFLAGS} ${CFLAGS} -D_INIT=lib$*_init -fPIC -c -o $@ $<;
+	${CC} ${DEFAULT_CFLAGS} ${XTABLES_CFLAGS} ${CPPFLAGS} ${CFLAGS} -D_INIT=lib$*_init -fPIC -c -o $@ $<;
 clean distclean maintainer-clean:
 	rm -f *.so
 distdir:

Reply via email to