diff --git a/CHANGES b/CHANGES index d51199b117..33888a2f87 100644 --- a/CHANGES +++ b/CHANGES @@ -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, added +class as an unabbreviated alternative to +cl. [RT #39686] diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index 4e5d31fd34..2b4ffbb88b 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -42,10 +43,6 @@ #include #include -#ifdef HAVE_JSON_H -#include -#endif - #include "bind9.xsl.h" struct ns_statschannel { diff --git a/config.h.in b/config.h.in index 3f35e2e1f3..594518851c 100644 --- a/config.h.in +++ b/config.h.in @@ -260,6 +260,9 @@ int sigwait(const unsigned int *set, int *sig); /* Define if libjson was found */ #undef HAVE_JSON +/* Define if json-c was found */ +#undef HAVE_JSON_C + /* Define to 1 if you have the header file. */ #undef HAVE_KERBEROSV5_KRB5_H diff --git a/configure b/configure index 3c8132d316..75cf58444d 100755 --- a/configure +++ b/configure @@ -16599,6 +16599,7 @@ fi have_libjson="" +have_libjson_c="" case "$use_libjson" in no) libjson_libs="" @@ -16608,34 +16609,36 @@ case "$use_libjson" in do if test -f "${d}/include/json/json.h" then - libjson_cflags="-I ${d}/include/json" if test ${d} != /usr then + libjson_cflags="-I ${d}/include" LIBS="$LIBS -L${d}/lib" fi have_libjson="yes" elif test -f "${d}/include/json-c/json.h" then - libjson_cflags="-I ${d}/include/json-c" if test ${d} != /usr then + libjson_cflags="-I ${d}/include" LIBS="$LIBS -L${d}/lib" fi have_libjson="yes" + have_libjson_c="yes" fi done ;; *) if test -f "${use_libjson}/include/json/json.h" then - libjson_cflags="-I${use_libjson}/include/json" + libjson_cflags="-I${use_libjson}/include" LIBS="$LIBS -L${use_libjson}/lib" have_libjson="yes" elif test -f "${use_libjson}/include/json-c/json.h" then - libjson_cflags="-I${use_libjson}/include/json-c" + libjson_cflags="-I${use_libjson}/include" LIBS="$LIBS -L${use_libjson}/lib" have_libjson="yes" + have_libjson_c="yes" else as_fn_error $? "$use_libjson/include/json{,-c}/json.h not found." "$LINENO" 5 fi @@ -16719,6 +16722,12 @@ then $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 # diff --git a/configure.in b/configure.in index 95ad0e2a01..f6393ab39e 100644 --- a/configure.in +++ b/configure.in @@ -2150,6 +2150,7 @@ AC_ARG_WITH(libjson, use_libjson="$withval", use_libjson="auto") have_libjson="" +have_libjson_c="" case "$use_libjson" in no) libjson_libs="" @@ -2159,34 +2160,36 @@ case "$use_libjson" in do if test -f "${d}/include/json/json.h" then - libjson_cflags="-I ${d}/include/json" if test ${d} != /usr then + libjson_cflags="-I ${d}/include" LIBS="$LIBS -L${d}/lib" fi have_libjson="yes" elif test -f "${d}/include/json-c/json.h" then - libjson_cflags="-I ${d}/include/json-c" if test ${d} != /usr then + libjson_cflags="-I ${d}/include" LIBS="$LIBS -L${d}/lib" fi have_libjson="yes" + have_libjson_c="yes" fi done ;; *) if test -f "${use_libjson}/include/json/json.h" then - libjson_cflags="-I${use_libjson}/include/json" + libjson_cflags="-I${use_libjson}/include" LIBS="$LIBS -L${use_libjson}/lib" have_libjson="yes" elif test -f "${use_libjson}/include/json-c/json.h" then - libjson_cflags="-I${use_libjson}/include/json-c" + libjson_cflags="-I${use_libjson}/include" LIBS="$LIBS -L${use_libjson}/lib" have_libjson="yes" + have_libjson_c="yes" else AC_MSG_ERROR([$use_libjson/include/json{,-c}/json.h not found.]) fi @@ -2210,6 +2213,10 @@ if test "X${have_libjson}" != "X" then CFLAGS="$CFLAGS $libjson_cflags" 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 # diff --git a/lib/isc/include/isc/json.h b/lib/isc/include/isc/json.h index 69ac4ffa18..2d779fd1ae 100644 --- a/lib/isc/include/isc/json.h +++ b/lib/isc/include/isc/json.h @@ -17,6 +17,7 @@ #ifndef ISC_JSON_H #define ISC_JSON_H 1 +#ifdef HAVE_JSON /* * 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 @@ -24,9 +25,21 @@ * the ifdef as well as adding the ability to add additional functions * which may be useful. */ - -#ifdef HAVE_JSON -#include +#ifdef HAVE_JSON_C +/* + * We don't include as the subsequent includes do not + * prefix the header file names with "json-c/" and using + * -I /include/json-c results in too many filename collisions. + */ +#include +#include +#include +#include +#include +#include +#else +#include +#endif #endif #define ISC_JSON_RENDERCONFIG 0x00000001 /* render config data */