From: Jean-Philippe Orsini Date: Thu, 13 Feb 2014 23:25:26 +0000 (+0000) Subject: added support json and json-c X-Git-Tag: v1.3.0~56 X-Git-Url: https://git.wpitchoune.net/gitweb/?p=ppastats.git;a=commitdiff_plain;h=13c74f42e424a26dc783bb565cb96b8bd542cee8 added support json and json-c --- diff --git a/config.h.in b/config.h.in index 00b832a..9eca4e7 100644 --- a/config.h.in +++ b/config.h.in @@ -28,6 +28,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H +/* Use JSON */ +#undef HAVE_JSON + +/* Use JSON0 */ +#undef HAVE_JSON_0 + /* Use json_bool */ #undef HAVE_JSON_BOOL diff --git a/configure b/configure index d5310d9..47c6a96 100755 --- a/configure +++ b/configure @@ -628,6 +628,8 @@ am__EXEEXT_TRUE LTLIBOBJS LIBOBJS HELP2MAN +JSON_FALSE +JSON_TRUE JSON_LIBS JSON_CFLAGS CURL_LIBS @@ -6830,6 +6832,7 @@ fi # Checks JSON +JSON_LIBS= pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JSON" >&5 @@ -6839,12 +6842,12 @@ 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 + { { $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 " 2>/dev/null` + pkg_cv_JSON_CFLAGS=`$PKG_CONFIG --cflags "json-c" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -6856,12 +6859,12 @@ 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 \""; } >&5 - ($PKG_CONFIG --exists --print-errors "json ") 2>&5 + { { $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 " 2>/dev/null` + pkg_cv_JSON_LIBS=`$PKG_CONFIG --libs "json-c" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -6882,48 +6885,122 @@ 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 " 2>&1` + 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 " 2>&1` + 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_fn_error $? "Package requirements (json ) were not met: + { $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; } -$JSON_PKG_ERRORS +$as_echo "#define HAVE_JSON 1" >>confdefs.h -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. +fi -Alternatively, you may set the environment variables JSON_CFLAGS -and JSON_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +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=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_JSON_CFLAGS=`$PKG_CONFIG --cflags "json" 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\""; } >&5 + ($PKG_CONFIG --exists --print-errors "json") 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" 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; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. -Alternatively, you may set the environment variables JSON_CFLAGS -and JSON_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. +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" 2>&1` + else + JSON_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "json" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$JSON_PKG_ERRORS" >&5 -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5; } + { $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: \"json0 missing\"" >&5 +$as_echo "$as_me: WARNING: \"json0 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 + + +$as_echo "#define HAVE_JSON_0 1" >>confdefs.h + +fi +fi + + if test -n "$JSON_LIBS"; then + JSON_TRUE= + JSON_FALSE='#' +else + JSON_TRUE='#' + JSON_FALSE= fi + ac_fn_c_check_type "$LINENO" "json_bool" "ac_cv_type_json_bool" "#include " if test "x$ac_cv_type_json_bool" = xyes; then : @@ -7104,6 +7181,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${JSON_TRUE}" && test -z "${JSON_FALSE}"; then + as_fn_error $? "conditional \"JSON\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 diff --git a/configure.ac b/configure.ac index 9af918e..817d4ff 100644 --- a/configure.ac +++ b/configure.ac @@ -29,8 +29,22 @@ PKG_CHECK_MODULES(CURL, libcurl ) AC_SUBST(CURL_CFLAGS) AC_SUBST(CURL_LIBS) -# Checks JSON -PKG_CHECK_MODULES(JSON, json ) +# Checks JSON +JSON_LIBS= +PKG_CHECK_MODULES(JSON, + 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)