]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] check for -ljson-c as well as -ljson
authorEvan Hunt <each@isc.org>
Tue, 9 Jul 2013 23:43:59 +0000 (16:43 -0700)
committerEvan Hunt <each@isc.org>
Tue, 9 Jul 2013 23:43:59 +0000 (16:43 -0700)
3512. [port] Check whether to use -ljson or -ljson-c. [RT #34115]

CHANGES
configure
configure.in
lib/isc/include/isc/json.h

diff --git a/CHANGES b/CHANGES
index 3096bc5de52e32d11d73c4beb312544468d9172a..ce50611698b23d7da7d62180537f964187b8af6b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+3512.  [port]          Check whether to use -ljson or -ljson-c. [RT #34115]
+
 3611.  [bug]           Improved resistance to a theoretical authentication
                        attack based on differential timing.  [RT #33939]
 
index 01c27ea13914997a2a6bd9ae51ab7ea1d4302b41..47806e6aa394d99dedfffb389fb921743ce8a620 100755 (executable)
--- a/configure
+++ b/configure
@@ -16023,6 +16023,7 @@ else
 fi
 
 
+have_libjson=
 case "$use_libjson" in
        no)
                libjson_libs=""
@@ -16030,37 +16031,108 @@ case "$use_libjson" in
        auto|yes)
                if test -f "/usr/include/json/json.h"
                 then
-                       libjson_libs="-ljson"
                        libjson_cflags="-I /usr/include/json"
-                else
-                       libjson_libs=""
+                       have_libjson="yes"
+                elif test -f "/usr/include/json-c/json.h"
+                then
+                       libjson_cflags="-I /usr/include/json-c"
+                       have_libjson="yes"
                 fi
                ;;
        *)
                if test -f "${use_libjson}/include/json/json.h"
                 then
-                       libjson_libs="-L${use_libjson}/lib -ljson"
                        libjson_cflags="-I${use_libjson}/include/json"
-                else
-                       as_fn_error $? "$use_libjson/include/json.h not found." "$LINENO" 5
+                       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"
+                       LIBS="$LIBS -L${use_libjson}/lib"
+                       have_libjson="yes"
+               else
+                       as_fn_error $? "$use_libjson/include/json{,-c}/json.h not found." "$LINENO" 5
                fi
                ;;
 esac
 
-if test "X${libjson_libs}" != "X"
+if test "%${have_libjson}" != "X"
 then
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-       CFLAGS="$CFLAGS $libjson_cflags"
-       LIBS="$LIBS $libjson_libs"
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing json_object_new_int" >&5
+$as_echo_n "checking for library containing json_object_new_int... " >&6; }
+if ${ac_cv_search_json_object_new_int+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-$as_echo "#define HAVE_JSON 1" >>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_new_int ();
+int
+main ()
+{
+return json_object_new_int ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' json json-c; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_json_object_new_int=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_json_object_new_int+:} false; then :
+  break
+fi
+done
+if ${ac_cv_search_json_object_new_int+:} false; then :
+
+else
+  ac_cv_search_json_object_new_int=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_json_object_new_int" >&5
+$as_echo "$ac_cv_search_json_object_new_int" >&6; }
+ac_res=$ac_cv_search_json_object_new_int
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: found libjson include but not library." >&5
+$as_echo "$as_me: WARNING: found libjson include but not library." >&2;}
+                       have_libjson=""
+fi
 
 else
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
+if test "X${have_libjson}" != "X"
+then
+       CFLAGS="$CFLAGS $libjson_cflags"
+
+$as_echo "#define HAVE_JSON 1" >>confdefs.h
+
+fi
+
 #
 # In solaris 10, SMF can manage named service
 #
index 4fa6fc68cddc0a7cfda81cd7f7103e25d01bf2e8..5ddbd4c95388614eee8bba9dd3f5466ca0c4e8b3 100644 (file)
@@ -1501,6 +1501,7 @@ AC_ARG_WITH(libjson,
 [  --with-libjson[=PATH]     Build with libjson0 library [yes|no|path]],
     use_libjson="$withval", use_libjson="auto")
 
+have_libjson=
 case "$use_libjson" in
        no)
                libjson_libs=""
@@ -1508,33 +1509,47 @@ case "$use_libjson" in
        auto|yes)
                if test -f "/usr/include/json/json.h"
                 then
-                       libjson_libs="-ljson"
                        libjson_cflags="-I /usr/include/json"
-                else
-                       libjson_libs=""
+                       have_libjson="yes"
+                elif test -f "/usr/include/json-c/json.h"
+                then
+                       libjson_cflags="-I /usr/include/json-c"
+                       have_libjson="yes"
                 fi
                ;;
        *)
                if test -f "${use_libjson}/include/json/json.h"
                 then
-                       libjson_libs="-L${use_libjson}/lib -ljson"
                        libjson_cflags="-I${use_libjson}/include/json"
-                else
-                       AC_MSG_ERROR([$use_libjson/include/json.h not found.])
+                       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"
+                       LIBS="$LIBS -L${use_libjson}/lib"
+                       have_libjson="yes"
+               else
+                       AC_MSG_ERROR([$use_libjson/include/json{,-c}/json.h not found.])
                fi
                ;;
 esac
 
-if test "X${libjson_libs}" != "X"
+if test "%${have_libjson}" != "X"
 then
        AC_MSG_RESULT(yes)
-       CFLAGS="$CFLAGS $libjson_cflags"
-       LIBS="$LIBS $libjson_libs"
-       AC_DEFINE(HAVE_JSON, 1, [Define if libjson was found])
+       AC_SEARCH_LIBS([json_object_new_int], [json json-c], [],
+                      [AC_MSG_WARN([found libjson include but not library.])
+                       have_libjson=""])
 else
        AC_MSG_RESULT(no)
 fi
 
+if test "X${have_libjson}" != "X"
+then
+       CFLAGS="$CFLAGS $libjson_cflags"
+       AC_DEFINE(HAVE_JSON, 1, [Define if libjson was found])
+fi
+
 #
 # In solaris 10, SMF can manage named service
 #
index e3c875f8e2bf8b1a7a9aafbff1ac8a73512b913d..69ac4ffa18ac99786faa28b27379e7a535000265 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 #ifdef HAVE_JSON
-#include <json/json.h>
+#include <json.h>
 #endif
 
 #define ISC_JSON_RENDERCONFIG          0x00000001 /* render config data */