From 8433816fae0e04baf1cb3f53e87ad7ed52210915 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Sun, 19 May 2013 16:01:41 +0000 Subject: [PATCH] added support of json-c --- config.h.in | 3 ++ configure | 90 +++++++++++++++++++++++++++++++++++++++++++++++--- configure.ac | 15 +++++++-- po/Makefile.in | 6 ++-- src/lib/psensor_json.h | 6 ++++ src/server/sysinfo.c | 6 ++++ 6 files changed, 116 insertions(+), 10 deletions(-) diff --git a/config.h.in b/config.h.in index a422e98..bc474b5 100644 --- a/config.h.in +++ b/config.h.in @@ -52,6 +52,9 @@ /* Use JSON */ #undef HAVE_JSON +/* Use JSON0 */ +#undef HAVE_JSON_0 + /* libatiadl is available */ #undef HAVE_LIBATIADL diff --git a/configure b/configure index f1112a1..5753ed0 100755 --- a/configure +++ b/configure @@ -8203,6 +8203,83 @@ if test -n "$JSON_CFLAGS"; then pkg_cv_JSON_CFLAGS="$JSON_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"json-c\""; } >&5 + ($PKG_CONFIG --exists --print-errors "json-c") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_JSON_CFLAGS=`$PKG_CONFIG --cflags "json-c" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$JSON_LIBS"; then + pkg_cv_JSON_LIBS="$JSON_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"json-c\""; } >&5 + ($PKG_CONFIG --exists --print-errors "json-c") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_JSON_LIBS=`$PKG_CONFIG --libs "json-c" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + JSON_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "json-c" 2>&1` + else + JSON_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "json-c" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$JSON_PKG_ERRORS" >&5 + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"json-c missing\"" >&5 +$as_echo "$as_me: WARNING: \"json-c missing\"" >&2;} +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"json-c missing\"" >&5 +$as_echo "$as_me: WARNING: \"json-c missing\"" >&2;} +else + JSON_CFLAGS=$pkg_cv_JSON_CFLAGS + JSON_LIBS=$pkg_cv_JSON_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_JSON 1" >>confdefs.h + +fi + +if test "JSON_LIBS" == ""; then + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for JSON" >&5 +$as_echo_n "checking for JSON... " >&6; } + +if test -n "$JSON_CFLAGS"; then + pkg_cv_JSON_CFLAGS="$JSON_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"json\""; } >&5 ($PKG_CONFIG --exists --print-errors "json") 2>&5 ac_status=$? @@ -8253,13 +8330,13 @@ fi # Put the nasty error message in config.log where it belongs echo "$JSON_PKG_ERRORS" >&5 - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"Remote monitoring disabled" >&5 -$as_echo "$as_me: WARNING: \"Remote monitoring disabled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"json0 missing\"" >&5 +$as_echo "$as_me: WARNING: \"json0 missing\"" >&2;} elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"Remote monitoring disabled" >&5 -$as_echo "$as_me: WARNING: \"Remote monitoring disabled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"json0 missing\"" >&5 +$as_echo "$as_me: WARNING: \"json0 missing\"" >&2;} else JSON_CFLAGS=$pkg_cv_JSON_CFLAGS JSON_LIBS=$pkg_cv_JSON_LIBS @@ -8268,7 +8345,12 @@ $as_echo "yes" >&6; } $as_echo "#define HAVE_JSON 1" >>confdefs.h + +$as_echo "#define HAVE_JSON_0 1" >>confdefs.h + fi +fi + if test -n "$JSON_LIBS"; then JSON_TRUE= JSON_FALSE='#' diff --git a/configure.ac b/configure.ac index 213ff7c..b9292c7 100644 --- a/configure.ac +++ b/configure.ac @@ -141,9 +141,18 @@ AC_SUBST(CURL_LIBS) # Check JSON, needed for remote monitoring JSON_LIBS= PKG_CHECK_MODULES(JSON, - json, - [AC_DEFINE([HAVE_JSON],[1],[Use JSON])], - [AC_MSG_WARN("Remote monitoring disabled, json missing")]) + json-c, + [AC_DEFINE([HAVE_JSON],[1],[Use JSON])], + [AC_MSG_WARN("json-c missing")]) + +if test "JSON_LIBS" == ""; then +PKG_CHECK_MODULES(JSON, + json, + [AC_DEFINE([HAVE_JSON],[1],[Use JSON]) + AC_DEFINE([HAVE_JSON_0],[1],[Use JSON0])], + [AC_MSG_WARN("json0 missing")]) +fi + AM_CONDITIONAL(JSON, test -n "$JSON_LIBS") AC_SUBST(JSON_CFLAGS) AC_SUBST(JSON_LIBS) diff --git a/po/Makefile.in b/po/Makefile.in index ccdb387..090283d 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -34,12 +34,12 @@ INSTALL_DATA = ${INSTALL} -m 644 # We use $(mkdir_p). # In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as # "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions, -# ${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/psensor/trunk/install-sh does not start with $(SHELL), so we add it. +# ${SHELL} /home/jporsini/work/wpitchoune.net/svnpub/psensor/trunk/install-sh does not start with $(SHELL), so we add it. # In automake >= 1.10, /bin/mkdir -p is derived from ${MKDIR_P}, which is defined # either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake # versions, $(mkinstalldirs) and $(install_sh) are unused. -mkinstalldirs = $(SHELL) ${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/psensor/trunk/install-sh -d -install_sh = $(SHELL) ${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/psensor/trunk/install-sh +mkinstalldirs = $(SHELL) ${SHELL} /home/jporsini/work/wpitchoune.net/svnpub/psensor/trunk/install-sh -d +install_sh = $(SHELL) ${SHELL} /home/jporsini/work/wpitchoune.net/svnpub/psensor/trunk/install-sh MKDIR_P = /bin/mkdir -p mkdir_p = /bin/mkdir -p diff --git a/src/lib/psensor_json.h b/src/lib/psensor_json.h index 94d1471..31ceb00 100644 --- a/src/lib/psensor_json.h +++ b/src/lib/psensor_json.h @@ -19,7 +19,13 @@ #ifndef _PSENSOR_PSENSOR_JSON_H_ #define _PSENSOR_PSENSOR_JSON_H_ +#include "config.h" + +#ifdef HAVE_JSON_0 #include +#else +#include +#endif #include "psensor.h" diff --git a/src/server/sysinfo.c b/src/server/sysinfo.c index 7ac5d6b..81d793e 100644 --- a/src/server/sysinfo.c +++ b/src/server/sysinfo.c @@ -21,7 +21,13 @@ #include #include +#include "config.h" + +#ifdef HAVE_JSON_0 #include +#else +#include +#endif #include "sysinfo.h" -- 2.7.4