aaee84
From 0698eb93f6e618d2882ae2c8758c5fa87524bea6 Mon Sep 17 00:00:00 2001
aaee84
From: Petr Mensik <pemensik@redhat.com>
aaee84
Date: Tue, 23 Jul 2019 12:10:39 +0200
aaee84
Subject: [PATCH] Allow explicitly using json-c but not libjson
aaee84
aaee84
Separate detection of json support. Allows explicit use of json-c when
aaee84
jsoncpp package is found. Have to use --without-libjson --with-json-c.
aaee84
---
aaee84
 configure.ac | 52 +++++++++++++++++++++++++++++++++++++++++-----------
aaee84
 1 file changed, 41 insertions(+), 11 deletions(-)
aaee84
aaee84
diff --git a/configure.ac b/configure.ac
aaee84
index f7978e4..40b4f9f 100644
aaee84
--- a/configure.ac
aaee84
+++ b/configure.ac
aaee84
@@ -1331,7 +1331,6 @@ AC_ARG_WITH(libjson,
aaee84
 	    use_libjson="$withval", use_libjson="auto")
aaee84
 
aaee84
 have_libjson=""
aaee84
-have_libjson_c=""
aaee84
 case "$use_libjson" in
aaee84
 	no)
aaee84
 		libjson_libs=""
aaee84
@@ -1347,7 +1346,43 @@ case "$use_libjson" in
aaee84
 					LIBS="$LIBS -L${d}/lib"
aaee84
 				fi
aaee84
 				have_libjson="yes"
aaee84
-			elif test -f "${d}/include/json-c/json.h"
aaee84
+			fi
aaee84
+		done
aaee84
+		;;
aaee84
+	*)
aaee84
+		if test -f "${use_libjson}/include/json/json.h"
aaee84
+		then
aaee84
+			libjson_cflags="-I${use_libjson}/include"
aaee84
+			LIBS="$LIBS -L${use_libjson}/lib"
aaee84
+			have_libjson="yes"
aaee84
+		else
aaee84
+			AC_MSG_ERROR([$use_libjson/include/json/json.h not found.])
aaee84
+		fi
aaee84
+		;;
aaee84
+esac
aaee84
+
aaee84
+#
aaee84
+# was --with-json-c specified?
aaee84
+#
aaee84
+AC_ARG_WITH(json-c,
aaee84
+	    AS_HELP_STRING([--with-json-c[=PATH]],
aaee84
+			   [build with json-c library [yes|no|path]]),
aaee84
+	    use_json_c="$withval", use_json_c="$use_libjson")
aaee84
+
aaee84
+if test "X${have_libjson}" != "X"
aaee84
+then
aaee84
+	# Do not use if libjson were found
aaee84
+	use_json_c=no
aaee84
+fi
aaee84
+
aaee84
+have_libjson_c=""
aaee84
+case "$use_json_c" in
aaee84
+	no)
aaee84
+		;;
aaee84
+	auto|yes)
aaee84
+		for d in /usr /usr/local /opt/local
aaee84
+		do
aaee84
+			if test -f "${d}/include/json-c/json.h"
aaee84
 			then
aaee84
 				if test ${d} != /usr
aaee84
 				then
aaee84
@@ -1360,19 +1395,14 @@ case "$use_libjson" in
aaee84
 		done
aaee84
 		;;
aaee84
 	*)
aaee84
-		if test -f "${use_libjson}/include/json/json.h"
aaee84
-		then
aaee84
-			libjson_cflags="-I${use_libjson}/include"
aaee84
-			LIBS="$LIBS -L${use_libjson}/lib"
aaee84
-			have_libjson="yes"
aaee84
-		elif test -f "${use_libjson}/include/json-c/json.h"
aaee84
+		if test -f "${use_json_c}/include/json-c/json.h"
aaee84
 		then
aaee84
-			libjson_cflags="-I${use_libjson}/include"
aaee84
-			LIBS="$LIBS -L${use_libjson}/lib"
aaee84
+			libjson_cflags="-I${use_json_c}/include"
aaee84
+			LIBS="$LIBS -L${use_json_c}/lib"
aaee84
 			have_libjson="yes"
aaee84
 			have_libjson_c="yes"
aaee84
 		else
aaee84
-			AC_MSG_ERROR([$use_libjson/include/json{,-c}/json.h not found.])
aaee84
+			AC_MSG_ERROR([$use_json_c/include/json-c/json.h not found.])
aaee84
 		fi
aaee84
 		;;
aaee84
 esac
aaee84
-- 
aaee84
2.20.1
aaee84