4133. [port] Update how various json libraries are handled.

[RT #39646]
This commit is contained in:
Mark Andrews
2015-06-05 10:16:24 +10:00
parent e545fce91b
commit 8a9bac8dec
6 changed files with 47 additions and 15 deletions

View File

@@ -1,3 +1,6 @@
4133. [port] Update how various json libraries are handled.
[RT #39646]
4132. [cleanup] dig: added +rd as a synonym for +recurse, 4132. [cleanup] dig: added +rd as a synonym for +recurse,
added +class as an unabbreviated alternative added +class as an unabbreviated alternative
to +cl. [RT #39686] to +cl. [RT #39686]

View File

@@ -20,6 +20,7 @@
#include <isc/buffer.h> #include <isc/buffer.h>
#include <isc/httpd.h> #include <isc/httpd.h>
#include <isc/json.h>
#include <isc/mem.h> #include <isc/mem.h>
#include <isc/once.h> #include <isc/once.h>
#include <isc/print.h> #include <isc/print.h>
@@ -42,10 +43,6 @@
#include <named/server.h> #include <named/server.h>
#include <named/statschannel.h> #include <named/statschannel.h>
#ifdef HAVE_JSON_H
#include <json/json.h>
#endif
#include "bind9.xsl.h" #include "bind9.xsl.h"
struct ns_statschannel { struct ns_statschannel {

View File

@@ -260,6 +260,9 @@ int sigwait(const unsigned int *set, int *sig);
/* Define if libjson was found */ /* Define if libjson was found */
#undef HAVE_JSON #undef HAVE_JSON
/* Define if json-c was found */
#undef HAVE_JSON_C
/* Define to 1 if you have the <kerberosv5/krb5.h> header file. */ /* Define to 1 if you have the <kerberosv5/krb5.h> header file. */
#undef HAVE_KERBEROSV5_KRB5_H #undef HAVE_KERBEROSV5_KRB5_H

17
configure vendored
View File

@@ -16599,6 +16599,7 @@ fi
have_libjson="" have_libjson=""
have_libjson_c=""
case "$use_libjson" in case "$use_libjson" in
no) no)
libjson_libs="" libjson_libs=""
@@ -16608,34 +16609,36 @@ case "$use_libjson" in
do do
if test -f "${d}/include/json/json.h" if test -f "${d}/include/json/json.h"
then then
libjson_cflags="-I ${d}/include/json"
if test ${d} != /usr if test ${d} != /usr
then then
libjson_cflags="-I ${d}/include"
LIBS="$LIBS -L${d}/lib" LIBS="$LIBS -L${d}/lib"
fi fi
have_libjson="yes" have_libjson="yes"
elif test -f "${d}/include/json-c/json.h" elif test -f "${d}/include/json-c/json.h"
then then
libjson_cflags="-I ${d}/include/json-c"
if test ${d} != /usr if test ${d} != /usr
then then
libjson_cflags="-I ${d}/include"
LIBS="$LIBS -L${d}/lib" LIBS="$LIBS -L${d}/lib"
fi fi
have_libjson="yes" have_libjson="yes"
have_libjson_c="yes"
fi fi
done done
;; ;;
*) *)
if test -f "${use_libjson}/include/json/json.h" if test -f "${use_libjson}/include/json/json.h"
then then
libjson_cflags="-I${use_libjson}/include/json" libjson_cflags="-I${use_libjson}/include"
LIBS="$LIBS -L${use_libjson}/lib" LIBS="$LIBS -L${use_libjson}/lib"
have_libjson="yes" have_libjson="yes"
elif test -f "${use_libjson}/include/json-c/json.h" elif test -f "${use_libjson}/include/json-c/json.h"
then then
libjson_cflags="-I${use_libjson}/include/json-c" libjson_cflags="-I${use_libjson}/include"
LIBS="$LIBS -L${use_libjson}/lib" LIBS="$LIBS -L${use_libjson}/lib"
have_libjson="yes" have_libjson="yes"
have_libjson_c="yes"
else else
as_fn_error $? "$use_libjson/include/json{,-c}/json.h not found." "$LINENO" 5 as_fn_error $? "$use_libjson/include/json{,-c}/json.h not found." "$LINENO" 5
fi fi
@@ -16719,6 +16722,12 @@ then
$as_echo "#define HAVE_JSON 1" >>confdefs.h $as_echo "#define HAVE_JSON 1" >>confdefs.h
if test "X${have_libjson_c}" = Xyes
then
$as_echo "#define HAVE_JSON_C 1" >>confdefs.h
fi
fi fi
# #

View File

@@ -2150,6 +2150,7 @@ AC_ARG_WITH(libjson,
use_libjson="$withval", use_libjson="auto") use_libjson="$withval", use_libjson="auto")
have_libjson="" have_libjson=""
have_libjson_c=""
case "$use_libjson" in case "$use_libjson" in
no) no)
libjson_libs="" libjson_libs=""
@@ -2159,34 +2160,36 @@ case "$use_libjson" in
do do
if test -f "${d}/include/json/json.h" if test -f "${d}/include/json/json.h"
then then
libjson_cflags="-I ${d}/include/json"
if test ${d} != /usr if test ${d} != /usr
then then
libjson_cflags="-I ${d}/include"
LIBS="$LIBS -L${d}/lib" LIBS="$LIBS -L${d}/lib"
fi fi
have_libjson="yes" have_libjson="yes"
elif test -f "${d}/include/json-c/json.h" elif test -f "${d}/include/json-c/json.h"
then then
libjson_cflags="-I ${d}/include/json-c"
if test ${d} != /usr if test ${d} != /usr
then then
libjson_cflags="-I ${d}/include"
LIBS="$LIBS -L${d}/lib" LIBS="$LIBS -L${d}/lib"
fi fi
have_libjson="yes" have_libjson="yes"
have_libjson_c="yes"
fi fi
done done
;; ;;
*) *)
if test -f "${use_libjson}/include/json/json.h" if test -f "${use_libjson}/include/json/json.h"
then then
libjson_cflags="-I${use_libjson}/include/json" libjson_cflags="-I${use_libjson}/include"
LIBS="$LIBS -L${use_libjson}/lib" LIBS="$LIBS -L${use_libjson}/lib"
have_libjson="yes" have_libjson="yes"
elif test -f "${use_libjson}/include/json-c/json.h" elif test -f "${use_libjson}/include/json-c/json.h"
then then
libjson_cflags="-I${use_libjson}/include/json-c" libjson_cflags="-I${use_libjson}/include"
LIBS="$LIBS -L${use_libjson}/lib" LIBS="$LIBS -L${use_libjson}/lib"
have_libjson="yes" have_libjson="yes"
have_libjson_c="yes"
else else
AC_MSG_ERROR([$use_libjson/include/json{,-c}/json.h not found.]) AC_MSG_ERROR([$use_libjson/include/json{,-c}/json.h not found.])
fi fi
@@ -2210,6 +2213,10 @@ if test "X${have_libjson}" != "X"
then then
CFLAGS="$CFLAGS $libjson_cflags" CFLAGS="$CFLAGS $libjson_cflags"
AC_DEFINE(HAVE_JSON, 1, [Define if libjson was found]) AC_DEFINE(HAVE_JSON, 1, [Define if libjson was found])
if test "X${have_libjson_c}" = Xyes
then
AC_DEFINE(HAVE_JSON_C, 1, [Define if json-c was found])
fi
fi fi
# #

View File

@@ -17,6 +17,7 @@
#ifndef ISC_JSON_H #ifndef ISC_JSON_H
#define ISC_JSON_H 1 #define ISC_JSON_H 1
#ifdef HAVE_JSON
/* /*
* This file is here mostly to make it easy to add additional libjson header * This file is here mostly to make it easy to add additional libjson header
* files as needed across all the users of this file. Rather than place * files as needed across all the users of this file. Rather than place
@@ -24,9 +25,21 @@
* the ifdef as well as adding the ability to add additional functions * the ifdef as well as adding the ability to add additional functions
* which may be useful. * which may be useful.
*/ */
#ifdef HAVE_JSON_C
#ifdef HAVE_JSON /*
#include <json.h> * We don't include <json-c/json.h> as the subsequent includes do not
* prefix the header file names with "json-c/" and using
* -I <prefix>/include/json-c results in too many filename collisions.
*/
#include <json-c/linkhash.h>
#include <json-c/json_util.h>
#include <json-c/json_object.h>
#include <json-c/json_tokener.h>
#include <json-c/json_object_iterator.h>
#include <json-c/json_c_version.h>
#else
#include <json/json.h>
#endif
#endif #endif
#define ISC_JSON_RENDERCONFIG 0x00000001 /* render config data */ #define ISC_JSON_RENDERCONFIG 0x00000001 /* render config data */