From 6b78a90d04df19f1de81649beff530601d75e1e6 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Wed, 16 May 2018 18:32:20 +0100
Subject: [PATCH] Only build GLib-based tests on amd64

This makes it a lot easier to satisfy the build-dependencies on OSs
where GLib is not fully multiarch, like Debian 8 'jessie' and
SteamOS 2 'brewmaster'.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 configure.ac   | 11 ++++++++++-
 debian/control |  3 ++-
 debian/rules   |  6 ++++++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9a1d0f8ae..47778bda0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,7 +68,16 @@ PKG_CHECK_MODULES([LIBELF], [libelf >= 0.152], [have_libelf=yes], [
     LIBELF_LIBS=-lelf
 ])
 
-PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])
+AC_ARG_WITH([glib],
+  [AS_HELP_STRING([--with-glib=yes/no],
+    [use GLib for better test coverage [default=yes]])],
+  [],
+  [with_glib=auto])
+AS_IF([test "$with_glib" != no],
+  [PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])],
+  [have_glib=no])
+AS_IF([test "$with_glib" = yes && test "$have_glib" = no],
+  [AC_MSG_ERROR([GLib required but not found])])
 AM_CONDITIONAL([HAVE_GLIB], [test "x$have_glib" = xyes])
 
 AC_ARG_ENABLE([host-prefix],
diff --git a/debian/control b/debian/control
index e3e48cb5a..9e1b3a197 100644
--- a/debian/control
+++ b/debian/control
@@ -13,7 +13,8 @@ Build-Depends:
  gtk-doc-tools,
  libelf-dev,
  libipc-run-perl,
- libglib2.0-dev,
+ libglib2.0-0 <!nocheck>,
+ libglib2.0-dev [amd64],
  libjpeg62-turbo <!nocheck> | libjpeg62 (>= 6b1) <!nocheck>,
  perl:any,
  xsltproc,
diff --git a/debian/rules b/debian/rules
index e70d30761..2e46a0e0d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,6 +11,12 @@ confflags = \
 	--libexecdir=\$${exec_prefix}/lib/libcapsule \
 	$(NULL)
 
+ifeq ($(DEB_HOST_ARCH),amd64)
+confflags += --with-glib
+else
+confflags += --without-glib
+endif
+
 override_dh_auto_configure:
 	dh_auto_configure -- $(confflags)
 
-- 
GitLab