From effdeaccbd2a5f65d41d3b906de420c2fc532e10 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Tue, 14 Jan 2025 19:27:13 +0100
Subject: Switch the dependency to json-glib as optional.

---
 configure.ac           | 20 ++++++++++++++++++--
 src/common/Makefile.am | 14 +++++++++++++-
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 23e4e9b..2ff719a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -593,6 +593,16 @@ AC_SUBST(LIBHS_LIBS)
 
 #--- Checks for json-glib-1.0
 
+AM_CONDITIONAL([BUILD_JSONGLIB_SUPPORT], [test "x$enable_jsonglib_support" = "xyes"])
+
+if test "x$BUILD_JSONGLIB_SUPPORT_TRUE" = "x"; then
+   # json-glib support is available and enabled
+   CPPFLAGS="$CPPFLAGS -DINCLUDE_JSONGLIB_SUPPORT"
+fi
+
+curl
+
+
 PKG_CHECK_MODULES(LIBJSONGLIB,json-glib-1.0 >= 1.6.6,[libjsonglib_found=yes],[libjsonglib_found=no])
 
 if test "$libjsonglib_found" = "yes"; then
@@ -601,8 +611,14 @@ else
    libjsonglib_version='-'
 fi
 
-AC_SUBST(LIBJSONGLIB_CFLAGS)
-AC_SUBST(LIBJSONGLIB_LIBS)
+if test "x$enable_json_glib_support" = "xyes"; then
+
+   AC_SUBST(LIBJSONGLIB_CFLAGS)
+   AC_SUBST(LIBJSONGLIB_LIBS)
+
+   true # empty if/then body not allowed
+
+fi
 
 
 #--- Checks for Python
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 687cb63..d09b661 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -58,7 +58,6 @@ libcommon4_la_SOURCES =						\
 	extstr.h extstr.c						\
 	fnv1a.h fnv1a.c							\
 	io.h io.c								\
-	json.h json.c							\
 	leb128.h leb128.c						\
 	macros.h								\
 	packed.h packed.c						\
@@ -75,6 +74,13 @@ libcommon4_la_SOURCES +=					\
 
 endif
 
+if BUILD_JSONGLIB_SUPPORT
+
+libcommon4_la_SOURCES +=					\
+	json.h json.c
+
+endif
+
 libcommon4_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBSSL_CFLAGS) $(LIBJSONGLIB_CFLAGS)
 
 if BUILD_CURL_SUPPORT
@@ -83,6 +89,12 @@ libcommon4_la_CFLAGS += $(LIBCURL_CFLAGS)
 
 endif
 
+if BUILD_JSONGLIB_SUPPORT
+
+libcommon4_la_CFLAGS += $(LIBJSONGLIB_CFLAGS)
+
+endif
+
 
 devdir = $(includedir)/chrysalide/$(subdir:src/%=core/%)
 
-- 
cgit v0.11.2-87-g4458