From b6ec8e85cc246c319647e2b6692aad0656e30585 Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Wed, 21 May 2014 16:14:26 +0300 Subject: [PATCH] common: cope with latest json-c include path changes. --- configure.ac | 19 +++++++++++++++++++ src/common/json.c | 1 - src/common/json.h | 16 +++++++++++++--- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index ab59774..e243a99 100644 --- a/configure.ac +++ b/configure.ac @@ -320,6 +320,25 @@ if test "$have_json" = "no"; then PKG_CHECK_MODULES(JSON, [json-c >= 0.11]) fi +AC_MSG_CHECKING([if json-c has headers under json-c include path]) +saved_CFLAGS="$CFLAGS" +saved_LIBS="$LIBS" +CFLAGS="${JSON_CFLAGS}" +LIBS="${JSON_LIBS}" +AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <../json-c/json.h>]], + [[return 0;]])], + [json_include_jsonc=yes], + [json_include_jsonc=no]) +AC_MSG_RESULT([$json_include_jsonc]) +CFLAGS="$saved_CFLAGS" +LIBS="$saved_LIBS" + +if test "$json_include_jsonc" = "yes"; then + AC_DEFINE([JSON_INCLUDE_PATH_JSONC], 1, [json headers under json-c ?]) +fi + AC_MSG_CHECKING([for json_tokener_get_error()]) saved_CFLAGS="$CFLAGS" saved_LIBS="$LIBS" diff --git a/src/common/json.c b/src/common/json.c index 675ced1..8c76756 100644 --- a/src/common/json.c +++ b/src/common/json.c @@ -30,7 +30,6 @@ #include #include #include -#include #include "murphy/config.h" #include diff --git a/src/common/json.h b/src/common/json.h index 10df654..c639c00 100644 --- a/src/common/json.h +++ b/src/common/json.h @@ -32,10 +32,20 @@ #include #include -#include -#include + +#include "murphy/config.h" + +#ifndef JSON_INCLUDE_PATH_JSONC +# include +# include +/* workaround for older broken json-c not exposing json_object_iter */ +# include +#else +# include +# include /* workaround for older broken json-c not exposing json_object_iter */ -#include +# include +#endif #include -- 2.7.4