]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Check for JSON-C library as well
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 1 Dec 2012 16:19:56 +0000 (16:19 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 1 Dec 2012 16:19:56 +0000 (16:19 +0000)
src/modules/rlm_rest/config.h.in
src/modules/rlm_rest/configure
src/modules/rlm_rest/configure.in
src/modules/rlm_rest/rest.c
src/modules/rlm_rest/rest.h

index bafb1a7e884fd6f5b91a12c5709ad5a414896d6a..66a2ca16fd36d878ab0e340f15192da963693c63 100644 (file)
@@ -3,6 +3,9 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
+/* Build with JSON support from json-c */
+#undef HAVE_JSON
+
 /* Define to 1 if you have the <json/json.h> header file. */
 #undef HAVE_JSON_JSON_H
 
index 8a5e6e42de04ac264c8cbaf02689492cecd632ba..101e1ba2fb379cf07f69d0ef9a8c4a936281bf2e 100755 (executable)
@@ -3448,7 +3448,7 @@ _ACEOF
   unset _libcurl_with
 
 
-       if test x$libcurl_cv_lib_curl_usable != xyes; then
+       if test "x$libcurl_cv_lib_curl_usable" != "xyes"; then
                fail="$fail libcurl"
        else
                if test x$libcurl_protocol_HTTP != xyes; then
@@ -3461,6 +3461,7 @@ $as_echo "$as_me: WARNING: silently building without HTTPS support. requires: li
                fi
        fi
 
+       have_json=
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
 $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
@@ -3734,11 +3735,56 @@ fi
 done
 
 
-       if test "$ac_cv_header_json_json_h" != "yes"; then
+       if test "x$ac_cv_header_json_json_h" == "xyes"; then
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for json_object_init in -ljson-c" >&5
+$as_echo_n "checking for json_object_init in -ljson-c... " >&6; }
+if ${ac_cv_lib_json_c_json_object_init+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ljson-c  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char json_object_init ();
+int
+main ()
+{
+return json_object_init ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_json_c_json_object_init=yes
+else
+  ac_cv_lib_json_c_json_object_init=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_json_c_json_object_init" >&5
+$as_echo "$ac_cv_lib_json_c_json_object_init" >&6; }
+if test "x$ac_cv_lib_json_c_json_object_init" = xyes; then :
+  have_json="yes"
+fi
+
+       fi
+
+       if test "x$have_json" == "xyes"; then
+               rest_ldflags+=" -ljson-c"
+               $as_echo "#define HAVE_JSON 1" >>confdefs.h
+
+       else
                { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: silently building without JSON support. requires: json-c." >&5
 $as_echo "$as_me: WARNING: silently building without JSON support. requires: json-c." >&2;}
-       else
-               rest_ldflags+=-ljson-c
        fi
 
        targetname=rlm_rest     # keep this!  Don't change!
index 1760c6b6f1aee724e6e2b3d3c501b76331a04503..c801a63a9187aea7e9003317ac0cca30906e90b5 100644 (file)
@@ -16,7 +16,7 @@ if test x$with_[]modname != xno; then
        
        LIBCURL_CHECK_CONFIG
 
-       if test x$libcurl_cv_lib_curl_usable != xyes; then
+       if test "x$libcurl_cv_lib_curl_usable" != "xyes"; then
                fail="$fail libcurl"
        else    
                if test x$libcurl_protocol_HTTP != xyes; then
@@ -28,12 +28,18 @@ if test x$with_[]modname != xno; then
                fi
        fi
        
+       have_json=
        AC_CHECK_HEADERS(json/json.h)
        
-       if test "$ac_cv_header_json_json_h" != "yes"; then
-               AC_MSG_WARN([silently building without JSON support. requires: json-c.])
+       if test "x$ac_cv_header_json_json_h" == "xyes"; then
+               AC_CHECK_LIB([json-c], [json_object_init], [have_json="yes"], [])               
+       fi
+       
+       if test "x$have_json" == "xyes"; then
+               rest_ldflags+=" -ljson-c"
+               AC_DEFINE([HAVE_JSON],[1],[Build with JSON support from json-c])
        else
-               rest_ldflags+=-ljson-c
+               AC_MSG_WARN([silently building without JSON support. requires: json-c.])
        fi
 
        targetname=modname     # keep this!  Don't change!
index d39b3e41cf282ca8bd5995a052b5220d2544da25..5e6b495afae1ae5e163e2ba031d2229140f98f77 100644 (file)
@@ -47,7 +47,7 @@ const http_body_type_t http_body_type_supported[HTTP_BODY_NUM_ENTRIES] = {
        HTTP_BODY_UNSUPPORTED,  // HTTP_BODY_UNSUPPORTED
        HTTP_BODY_UNSUPPORTED,  // HTTP_BODY_INVALID
        HTTP_BODY_POST,         // HTTP_BODY_POST
-#ifdef WITH_JSON
+#ifdef HAVE_JSON
        HTTP_BODY_JSON,         // HTTP_BODY_JSON
 #else
        HTTP_BODY_UNAVAILABLE,
@@ -192,7 +192,7 @@ const FR_NAME_NUMBER http_content_type_table[] = {
  * @see json_pairmake
  * @see json_pairmake_leaf
  */
-#ifdef WITH_JSON
+#ifdef HAVE_JSON
 typedef struct json_flags {
        boolean do_xlat;        //!< If TRUE value will be expanded with xlat.
        boolean is_json;        //!< If TRUE value will be inserted as raw JSON
@@ -1165,7 +1165,7 @@ static int rest_decode_post(rlm_rest_t *instance,
  * @param[in] leaf object containing the VALUE_PAIR value.
  * @return The VALUE_PAIR just created, or NULL on error.
  */
-#ifdef WITH_JSON
+#ifdef HAVE_JSON
 static VALUE_PAIR *json_pairmake_leaf(rlm_rest_t *instance,
                                      UNUSED rlm_rest_section_t *section,
                                      REQUEST *request, const DICT_ATTR *da,
@@ -2165,7 +2165,7 @@ int rest_request_config(rlm_rest_t *instance, rlm_rest_section_t *section,
 
                        switch (type)
                        {
-#ifdef WITH_JSON
+#ifdef HAVE_JSON
                                case HTTP_BODY_JSON:
                                        rest_read_ctx_init(request,
                                                           &ctx->read, 1);
@@ -2280,7 +2280,7 @@ int rest_request_decode(rlm_rest_t *instance,
                                               handle, ctx->write.buffer,
                                               ctx->write.used);
                        break;
-#ifdef WITH_JSON
+#ifdef HAVE_JSON
                case HTTP_BODY_JSON:
                        ret = rest_decode_json(instance, section, request,
                                               handle, ctx->write.buffer,
index 7befe58285b9cba858e0077a141d9fbeae849cc6..95f0932be63bfccd7d0fd907997687b8b17a663c 100644 (file)
@@ -28,12 +28,12 @@ RCSIDH(other_h, "$Id$")
 #include "config.h"
 
 #ifdef HAVE_JSON_JSONH
-#define WITH_JSON
+#define HAVE_JSON
 #endif
 
 #include <curl/curl.h>
 
-#ifdef WITH_JSON
+#ifdef HAVE_JSON
 #include <json/json.h>
 #endif