Source: libf2c2
Version: 20130926-3
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

libf2c2 fails to cross build from source, because it does not pass cross
tools to make. The easiest way of fixing that - using dh_auto_build - is
insufficient here. debian/make_lib hard codes the build architecture C
compiler and makefile.u hard codes the build architecture ld. Both need
to be made substitutable. Since dh_auto_build does not pass an LD
variable, we must pass it explicitly. The attached patch makes libf2c2
cross buildable. Please consider applying it.

Helmut
diff -Nru libf2c2-20130926/debian/changelog libf2c2-20130926/debian/changelog
--- libf2c2-20130926/debian/changelog   2018-02-22 13:36:24.000000000 +0100
+++ libf2c2-20130926/debian/changelog   2020-07-06 11:12:17.000000000 +0200
@@ -1,3 +1,14 @@
+libf2c2 (20130926-3.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: (Closes: #-1)
+    + Let dh_auto_build pass cross tools to make.
+    + Make debian/make_lib use the passed cross compiler.
+    + Pass a cross ld from dpkg's buildtools.mk to make.
+    + cross.patch: Make ld substitutable in makefile.u.
+
+ -- Helmut Grohne <helmut.gro...@intenta.de>  Mon, 06 Jul 2020 11:12:17 +0200
+
 libf2c2 (20130926-3) unstable; urgency=medium
 
   * Team upload.
diff -Nru libf2c2-20130926/debian/make_lib libf2c2-20130926/debian/make_lib
--- libf2c2-20130926/debian/make_lib    2018-02-22 13:36:24.000000000 +0100
+++ libf2c2-20130926/debian/make_lib    2020-07-06 11:12:17.000000000 +0200
@@ -4,7 +4,7 @@
        $(MAKE) -f makefile.u CFLAGS="$(CFLAGS) $(GCCOPT) -fPIC \
         -I ../ -DNON_UNIX_STDIO -D$(INTSIZE)" 
 
-       gcc -shared -Wl,-soname,lib$(INTSIZE).so.2 $(LDFLAGS) \
+       $(CC) -shared -Wl,-soname,lib$(INTSIZE).so.2 $(LDFLAGS) \
                         -o lib$(INTSIZE).so.2.1 *.o -lc -lm
 
        ar r lib$(INTSIZE).a *.o
diff -Nru libf2c2-20130926/debian/patches/cross.patch 
libf2c2-20130926/debian/patches/cross.patch
--- libf2c2-20130926/debian/patches/cross.patch 1970-01-01 01:00:00.000000000 
+0100
+++ libf2c2-20130926/debian/patches/cross.patch 2020-07-06 11:12:17.000000000 
+0200
@@ -0,0 +1,20 @@
+Index: libf2c2-20130926/makefile.u
+===================================================================
+--- libf2c2-20130926.orig/makefile.u
++++ libf2c2-20130926/makefile.u
+@@ -14,13 +14,14 @@
+ 
+ .SUFFIXES: .c .o
+ CC = cc
++LD ?= ld
+ SHELL = /bin/sh
+ CFLAGS = -O
+ 
+ # compile, then strip unnecessary symbols
+ .c.o:
+       $(CC) -c -DSkip_f2c_Undefs $(CFLAGS) $*.c
+-      ld -r -x -o $*.xxx $*.o
++      $(LD) -r -x -o $*.xxx $*.o
+       mv $*.xxx $*.o
+ ## Under Solaris (and other systems that do not understand ld -x),
+ ## omit -x in the ld line above.
diff -Nru libf2c2-20130926/debian/patches/series 
libf2c2-20130926/debian/patches/series
--- libf2c2-20130926/debian/patches/series      2018-02-22 13:36:24.000000000 
+0100
+++ libf2c2-20130926/debian/patches/series      2020-07-06 11:12:17.000000000 
+0200
@@ -4,3 +4,4 @@
 0004-add-clapack-files.patch
 0005-format-security.patch
 0006-weak-MAIN__.patch
+cross.patch
diff -Nru libf2c2-20130926/debian/rules libf2c2-20130926/debian/rules
--- libf2c2-20130926/debian/rules       2018-02-22 13:36:24.000000000 +0100
+++ libf2c2-20130926/debian/rules       2020-07-06 11:12:17.000000000 +0200
@@ -11,7 +11,9 @@
 # prefix-dev=debian/libf2c2-dev
 # prefix=debian/libf2c2
 
-DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
+include /usr/share/dpkg/architecture.mk
+-include /usr/share/dpkg/buildtools.mk
+LD ?= ld
 
 dir=$(package)-$(version)
 file=$(package)_$(version)-$(debian)
@@ -30,16 +32,18 @@
    GCCOPT=$(GCCOP1)
 endif
 
+MAKE_LIB=dh_auto_build --buildsystem=makefile -- -f ./debian/make_lib 
'LD=$(LD)'
+
 override_dh_auto_build:
        if [ $(DEB_HOST_ARCH) = "i386" ] ;\
            then echo "Building for i386" ;\
         fi
 
 ## These take gcc options from GCCOPT 
-       $(MAKE) -f ./debian/make_lib INTSIZE=f2c GCCOPT="$(GCCOPT)"
+       $(MAKE_LIB) INTSIZE=f2c GCCOPT="$(GCCOPT)"
 ## Make sure everything rebuilt for -I2 lib
-       $(MAKE) -f ./debian/make_lib clean
-       $(MAKE) -f ./debian/make_lib INTSIZE=f2c_i2 GCCOPT="$(GCCOPT)"
+       $(MAKE_LIB) clean
+       $(MAKE_LIB) INTSIZE=f2c_i2 GCCOPT="$(GCCOPT)"
 
        ln -s libf2c.so.$(flibver) libf2c.so.$(flibmajorver)
        ln -s libf2c_i2.so.$(flibver) libf2c_i2.so.$(flibmajorver)

Reply via email to