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