added support of json-c
authorJean-Philippe Orsini <jeanfi@gmail.com>
Sun, 19 May 2013 16:01:41 +0000 (16:01 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Sun, 19 May 2013 16:01:41 +0000 (16:01 +0000)
config.h.in
configure
configure.ac
po/Makefile.in
src/lib/psensor_json.h
src/server/sysinfo.c

index a422e98..bc474b5 100644 (file)
@@ -52,6 +52,9 @@
 /* Use JSON */
 #undef HAVE_JSON
 
+/* Use JSON0 */
+#undef HAVE_JSON_0
+
 /* libatiadl is available */
 #undef HAVE_LIBATIADL
 
index f1112a1..5753ed0 100755 (executable)
--- 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='#'
index 213ff7c..b9292c7 100644 (file)
@@ -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)
index ccdb387..090283d 100644 (file)
@@ -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
 
index 94d1471..31ceb00 100644 (file)
 #ifndef _PSENSOR_PSENSOR_JSON_H_
 #define _PSENSOR_PSENSOR_JSON_H_
 
+#include "config.h"
+
+#ifdef HAVE_JSON_0
 #include <json/json.h>
+#else
+#include <json-c/json.h>
+#endif
 
 #include "psensor.h"
 
index 7ac5d6b..81d793e 100644 (file)
 #include <glibtop/netlist.h>
 #include <glibtop/netload.h>
 
+#include "config.h"
+
+#ifdef HAVE_JSON_0
 #include <json/json.h>
+#else
+#include <json-c/json.h>
+#endif
 
 #include "sysinfo.h"