From: Arran Cudbard-Bell Date: Sat, 1 Dec 2012 16:19:56 +0000 (+0000) Subject: Check for JSON-C library as well X-Git-Tag: release_3_0_0_beta1~1458 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=975d2f2d2f88b95b3916237d6275f49447fc50c0;p=thirdparty%2Ffreeradius-server.git Check for JSON-C library as well --- diff --git a/src/modules/rlm_rest/config.h.in b/src/modules/rlm_rest/config.h.in index bafb1a7e884..66a2ca16fd3 100644 --- a/src/modules/rlm_rest/config.h.in +++ b/src/modules/rlm_rest/config.h.in @@ -3,6 +3,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H +/* Build with JSON support from json-c */ +#undef HAVE_JSON + /* Define to 1 if you have the header file. */ #undef HAVE_JSON_JSON_H diff --git a/src/modules/rlm_rest/configure b/src/modules/rlm_rest/configure index 8a5e6e42de0..101e1ba2fb3 100755 --- a/src/modules/rlm_rest/configure +++ b/src/modules/rlm_rest/configure @@ -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! diff --git a/src/modules/rlm_rest/configure.in b/src/modules/rlm_rest/configure.in index 1760c6b6f1a..c801a63a918 100644 --- a/src/modules/rlm_rest/configure.in +++ b/src/modules/rlm_rest/configure.in @@ -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! diff --git a/src/modules/rlm_rest/rest.c b/src/modules/rlm_rest/rest.c index d39b3e41cf2..5e6b495afae 100644 --- a/src/modules/rlm_rest/rest.c +++ b/src/modules/rlm_rest/rest.c @@ -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, diff --git a/src/modules/rlm_rest/rest.h b/src/modules/rlm_rest/rest.h index 7befe58285b..95f0932be63 100644 --- a/src/modules/rlm_rest/rest.h +++ b/src/modules/rlm_rest/rest.h @@ -28,12 +28,12 @@ RCSIDH(other_h, "$Id$") #include "config.h" #ifdef HAVE_JSON_JSONH -#define WITH_JSON +#define HAVE_JSON #endif #include -#ifdef WITH_JSON +#ifdef HAVE_JSON #include #endif