Source: g2clib Version: 1.6.2-1 Tags: patch User: debian-cr...@lists.debian.org Usertags: ftcbfs
g2clib fails to cross build from source. A first issue is the use of the build architecture pkg-config. Making it substitutable via the standard variable PKG_CONFIG is the solution here. Next, it passes -m64 and -D__64BIT__ to the compiler. This happens to break the build for almost any architecture but amd64. Those flags should simply go away. In the linker stage, the makefile hard codes gcc rather than using CC, which fails again. Finally make install redoes all the compilation, so we also need to pass cross tools there. The attached patch fixes all of that. Please consider applying it. Helmut
diff --minimal -Nru g2clib-1.6.2/debian/changelog g2clib-1.6.2/debian/changelog --- g2clib-1.6.2/debian/changelog 2020-12-20 13:38:08.000000000 +0100 +++ g2clib-1.6.2/debian/changelog 2020-12-21 14:33:16.000000000 +0100 @@ -1,3 +1,14 @@ +g2clib (1.6.2-1.1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Fix FTCBFS: (Closes: #-1) + + cross.patch: Make pkg-config substitutable. + + cross.patch: Don't force -m64 nor -D__64BIT__ flags. + + cross.patch: Make gcc substitutable. + + Pass cross tools to make install + + -- Helmut Grohne <hel...@subdivi.de> Mon, 21 Dec 2020 14:33:16 +0100 + g2clib (1.6.2-1) unstable; urgency=medium * New upstream release diff --minimal -Nru g2clib-1.6.2/debian/patches/cross.patch g2clib-1.6.2/debian/patches/cross.patch --- g2clib-1.6.2/debian/patches/cross.patch 1970-01-01 01:00:00.000000000 +0100 +++ g2clib-1.6.2/debian/patches/cross.patch 2020-12-21 14:33:16.000000000 +0100 @@ -0,0 +1,44 @@ +--- g2clib-1.6.2.orig/makefile ++++ g2clib-1.6.2/makefile +@@ -1,4 +1,5 @@ + SHELL=/bin/sh ++PKG_CONFIG?=pkg-config + + # If you want to enable support for PNG or JPEG2000 encoding/decoding, + # you must specify -DUSE_PNG and/or -DUSE_JPEG2000 in the DEFS variable +@@ -18,7 +19,7 @@ + # + + #INC=-I/usrx/local/prod/packages/gnu/4.8.5/jasper/1.900.1/include +-INC=$(shell pkg-config --cflags libopenjp2) ++INC=$(shell $(PKG_CONFIG) --cflags libopenjp2) + + # + # This "C" source code contains many uses of the C++ +@@ -26,7 +27,7 @@ + # appropriate compiler flag to allow the use of "//" comment indicators. + # + +-CFLAGS:= -O3 -g -m64 $(INC) $(DEFS) -D__64BIT__ $(CFLAGS) ++CFLAGS:= -O3 -g $(INC) $(DEFS) $(CFLAGS) + + PIC:= -fPIC + +@@ -104,7 +105,7 @@ + clean: + rm -f *.o *.a *.so grib2c.pc lib* + +-LIBS= `pkg-config --libs libpng` -lopenjp2 -lm ++LIBS= `$(PKG_CONFIG) --libs libpng` -lopenjp2 -lm + OBJS:= gridtemplates.o \ + drstemplates.o \ + pdstemplates.o \ +@@ -155,7 +156,7 @@ + all: $(LIB) $(SHLIB) + + $(SHLIB): $(OBJS) +- gcc $(LDFLAGS) -Wl,-as-needed -shared -o $(SHLIB) -Wl,-soname,$(SONAME) $(OBJS) $(LIBS) ++ $(CC) $(LDFLAGS) -Wl,-as-needed -shared -o $(SHLIB) -Wl,-soname,$(SONAME) $(OBJS) $(LIBS) + + grib2c.pc: grib2c.pc.in + cat grib2c.pc.in | sed -e 's!@prefix@!${PREFIX}!' | sed -e 's!@libdir@!${LIBDIR}!' > grib2c.pc diff --minimal -Nru g2clib-1.6.2/debian/patches/series g2clib-1.6.2/debian/patches/series --- g2clib-1.6.2/debian/patches/series 2020-12-20 13:38:08.000000000 +0100 +++ g2clib-1.6.2/debian/patches/series 2020-12-21 14:32:53.000000000 +0100 @@ -4,3 +4,4 @@ harden.patch remove_jasper.patch 64bit_fix.patch +cross.patch diff --minimal -Nru g2clib-1.6.2/debian/rules g2clib-1.6.2/debian/rules --- g2clib-1.6.2/debian/rules 2020-12-20 13:38:08.000000000 +0100 +++ g2clib-1.6.2/debian/rules 2020-12-21 14:33:16.000000000 +0100 @@ -4,8 +4,10 @@ %: dh $@ --no-parallel +include /usr/share/dpkg/architecture.mk +include /usr/share/dpkg/buildtools.mk + DESTDIR:=$(CURDIR)/debian/tmp/ -DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) LIBDIR:=/usr/lib/$(DEB_HOST_MULTIARCH) #export DH_VERBOSE=1 @@ -15,7 +17,7 @@ dh_clean override_dh_auto_install: - $(MAKE) prefix=$(DESTDIR)/usr LIBDIR=$(DESTDIR)/$(LIBDIR) install + $(MAKE) prefix=$(DESTDIR)/usr LIBDIR=$(DESTDIR)/$(LIBDIR) CC=$(CC) PKG_CONFIG=$(PKG_CONFIG) install sed -i -e 's@libdir=$(DESTDIR)/@libdir=@g' $(DESTDIR)/$(LIBDIR)/pkgconfig/grib2c.pc # Strip build path mv $(DESTDIR)/$(LIBDIR)/./libg2c_v1.6.*.a $(DESTDIR)/$(LIBDIR)/libgrib2c.a dh_link -p libgrib2c-dev $(LIBDIR)/libgrib2c.so.0d $(LIBDIR)/libgrib2c.so