[collectd] [PATCH 1/2] configure: detect libjson

Sage Weil sage at inktank.com
Sat Jan 19 02:17:18 CET 2013


Originally from Yves Mettier <ymettier at free.fr>.

Signed-off-by: Sage Weil <sage at inktank.com>
---
 configure.in |   62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/configure.in b/configure.in
index 402c4d4..6d92bef 100644
--- a/configure.in
+++ b/configure.in
@@ -4212,6 +4212,67 @@ then
 fi
 # }}}
 
+# --with-libjson {{{
+AC_ARG_WITH(libjson, [AS_HELP_STRING([--with-libjson@<:@=PREFIX@:>@], [Path to libjson.])],
+[
+ if test "x$withval" = "xyes"
+ then
+	 with_libjson="yes"
+	 LIBJSON_CPPFLAGS="$LIBJSON_CPPFLAGS -I$withval/include"
+	 LIBJSON_LDFLAGS="$LIBJSON_LDFLAGS -L$withval/lib"
+ else if test "x$withval" = "xno"
+ then
+	 with_libjson="no"
+ else
+	 with_libjson="yes"
+	 LIBJSON_CPPFLAGS="$LIBJSON_CPPFLAGS -I$withval/include"
+	 LIBJSON_LDFLAGS="$LIBJSON_LDFLAGS -L$withval/lib"
+ fi; fi
+],
+[with_libjson="yes"])
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+
+CPPFLAGS="$CPPFLAGS $LIBJSON_CPPFLAGS"
+LDFLAGS="$LDFLAGS $LIBJSON_LDFLAGS"
+
+if test "x$with_libjson" = "xyes"
+then
+	if test "x$LIBJSON_CPPFLAGS" != "x"
+	then
+		AC_MSG_NOTICE([libjson CPPFLAGS: $LIBJSON_CPPFLAGS])
+	fi
+	AC_CHECK_HEADERS(json/json.h,
+	[with_libjson="yes"],
+	[with_libjson="no (json.h not found)"])
+fi
+if test "x$with_libjson" = "xyes"
+then
+	if test "x$LIBJSON_LDFLAGS" != "x"
+	then
+		AC_MSG_NOTICE([libjson LDFLAGS: $LIBJSON_LDFLAGS])
+	fi
+	AC_CHECK_LIB(json, json_object_new_object,
+	[with_libjson="yes"],
+	[with_libjson="no (symbol 'json_object_new_object' not found)"])
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
+if test "x$with_libjson" = "xyes"
+then
+	BUILD_WITH_LIBJSON_CPPFLAGS="$LIBJSON_CPPFLAGS"
+	BUILD_WITH_LIBJSON_LDFLAGS="$LIBJSON_LDFLAGS"
+	BUILD_WITH_LIBJSON_LIBS="-ljson"
+	AC_SUBST(BUILD_WITH_LIBJSON_CPPFLAGS)
+	AC_SUBST(BUILD_WITH_LIBJSON_LDFLAGS)
+	AC_SUBST(BUILD_WITH_LIBJSON_LIBS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBJSON, test "x$with_libjson" = "xyes")
+# }}}
+
 # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
 with_libxml2="no (pkg-config isn't available)"
 with_libxml2_cflags=""
@@ -5147,6 +5208,7 @@ Configuration:
     libgcrypt . . . . . . $with_libgcrypt
     libiokit  . . . . . . $with_libiokit
     libiptc . . . . . . . $with_libiptc
+    libjson . . . . . . . $with_libjson
     libjvm  . . . . . . . $with_java
     libkstat  . . . . . . $with_kstat
     libkvm  . . . . . . . $with_libkvm
-- 
1.7.9




More information about the collectd mailing list