Source: fio
Version: 3.12-2
Tags: patch
User: helm...@debian.org
Usertags: rebootstrap

fio fails to cross build from source, because it configures for the
build architecture. fio's configure is very different from autotools and
requires the user to export a variable called CROSS_COMPILE. Even then,
it uses the wrong pkg-config and runs compiled executables. The attached
patch makes fio cross buildable. Please consider applying it.

Helmut
diff --minimal -Nru fio-3.12/debian/changelog fio-3.12/debian/changelog
--- fio-3.12/debian/changelog   2019-01-21 09:29:38.000000000 +0100
+++ fio-3.12/debian/changelog   2019-05-25 14:14:03.000000000 +0200
@@ -1,3 +1,13 @@
+fio (3.12-2.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: (Closes: #-1)
+    + Export CROSS_COMPILE.
+    + cross.patch: Apply $CROSS_COMPILE to pkg-config and avoid running
+      compiled code.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Sat, 25 May 2019 14:14:03 +0200
+
 fio (3.12-2) unstable; urgency=medium
 
   * control: Depend on libglusterfs-dev instead of glusterfs-common
diff --minimal -Nru fio-3.12/debian/patches/cross.patch 
fio-3.12/debian/patches/cross.patch
--- fio-3.12/debian/patches/cross.patch 1970-01-01 01:00:00.000000000 +0100
+++ fio-3.12/debian/patches/cross.patch 2019-05-25 14:14:03.000000000 +0200
@@ -0,0 +1,42 @@
+--- fio-3.12.orig/configure
++++ fio-3.12/configure
+@@ -1336,31 +1336,30 @@
+   return GTK_CHECK_VERSION(2, 18, 0) ? 0 : 1; /* 0 on success */
+ }
+ EOF
+-GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
++GTK_CFLAGS=$(${cross_prefix}pkg-config --cflags gtk+-2.0 gthread-2.0)
+ ORG_LDFLAGS=$LDFLAGS
+ LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
+ if test "$?" != "0" ; then
+   echo "configure: gtk and gthread not found"
+   exit 1
+ fi
+-GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
++GTK_LIBS=$(${cross_prefix}pkg-config --libs gtk+-2.0 gthread-2.0)
+ if test "$?" != "0" ; then
+   echo "configure: gtk and gthread not found"
+   exit 1
+ fi
+-if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
+-  $TMPE
+-  if test "$?" = "0" ; then
++if ! ${cross_prefix}pkg-config --atleast-version 2.18.0 gtk+-2.0; then
++  echo "GTK found, but need version 2.18 or higher"
++  gfio="no"
++else
++  if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
+     gfio="yes"
+     GFIO_LIBS="$LIBS $GTK_LIBS"
+     CFLAGS="$CFLAGS $GTK_CFLAGS"
+   else
+-    echo "GTK found, but need version 2.18 or higher"
++    echo "Please install gtk and gdk libraries"
+     gfio="no"
+   fi
+-else
+-  echo "Please install gtk and gdk libraries"
+-  gfio="no"
+ fi
+ LDFLAGS=$ORG_LDFLAGS
+ fi
diff --minimal -Nru fio-3.12/debian/patches/series 
fio-3.12/debian/patches/series
--- fio-3.12/debian/patches/series      2018-11-28 18:09:19.000000000 +0100
+++ fio-3.12/debian/patches/series      2019-05-25 14:14:03.000000000 +0200
@@ -3,3 +3,4 @@
 fio2gnuplot-manpage
 configure-no-configlog
 genfio-interpreter
+cross.patch
diff --minimal -Nru fio-3.12/debian/rules fio-3.12/debian/rules
--- fio-3.12/debian/rules       2018-11-28 18:09:19.000000000 +0100
+++ fio-3.12/debian/rules       2019-05-25 14:14:03.000000000 +0200
@@ -9,12 +9,18 @@
 # Uncomment this to turn on verbose mode.
 #export DH_VERBOSE=1
 
+include /usr/share/dpkg/architecture.mk
+
 export DEB_LDFLAGS_MAINT_PREPEND := -Wl,-z,defs -Wl,--as-needed
 
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 
 export V = 1
 
+ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
+endif
+
 %:
        dh $@
 

Reply via email to