From 9be904a70e6b7e6b3cc4e1b270bca02d14a4179b Mon Sep 17 00:00:00 2001
From: Jussi Kukkonen <jussi.kukkonen@intel.com>
Date: Mon, 5 Sep 2016 14:41:37 +0300
Subject: [PATCH] configure.ac: Allow explicit enabling of cunit tests

Add --with-cunit to make it easier to do reproducible builds. Default
is still to probe cunit and build opportunistically.

Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
Upstream-Status: Submitted [mailing list]

---
 configure.ac | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1341f51..bef46e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -168,6 +168,12 @@ AC_ARG_ENABLE(install-test-programs,
 		  [Install test programs (default: no)]),
 		  [INSTALL_TESTS=$enableval], [INSTALL_TESTS=no])
 
+AC_ARG_WITH([cunit],
+            [AS_HELP_STRING([--with-cunit],
+                            [Build tests that use cunit (default: auto)])],
+            [],
+            [with_cunit=auto])
+
 dnl ===========================================================================
 dnl check compiler flags
 AC_DEFUN([LIBDRM_CC_TRY_FLAG], [
@@ -416,7 +422,7 @@ else
 	AC_DEFINE(HAVE_RADEON, 0)
 fi
 
-if test "x$AMDGPU" != xno; then
+if test "x$with_cunit" != xno -a "x$AMDGPU" != xno; then
 	# Detect cunit library
 	PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no])
 	# If pkg-config does not find cunit, check it using AC_CHECK_LIB.  We
@@ -441,7 +447,11 @@ if test "x$AMDGPU" = xyes; then
 	AC_DEFINE(HAVE_AMDGPU, 1, [Have amdgpu support])
 
 	if test "x$have_cunit" = "xno"; then
-		AC_MSG_WARN([Could not find cunit library. Disabling amdgpu tests])
+		if test "x$with_cunit" = "xyes"; then
+			AC_MSG_ERROR([Could not find cunit library but --with-cunit was given])
+		elif test "x$with_cunit" = "xauto"; then
+			AC_MSG_WARN([Could not find cunit library. Disabling amdgpu tests])
+		fi
 	fi
 else
 	AC_DEFINE(HAVE_AMDGPU, 0)
