]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Convert the configure.ac rules for zlib library to use pkg-config
authorOndřej Surý <ondrej@sury.org>
Wed, 31 Jul 2019 11:50:15 +0000 (13:50 +0200)
committerOndřej Surý <ondrej@sury.org>
Wed, 31 Jul 2019 12:54:40 +0000 (14:54 +0200)
bin/named/Makefile.in
bin/tests/system/conf.sh.in
bin/tests/system/conf.sh.win32
bin/tests/system/statschannel/tests.sh
config.h.in
configure
configure.ac
lib/isc/Makefile.in
make/rules.in

index 3b3a855cb019b73568bb5be3a089307dcf93781c..f66bc9a6e2ebf01a7dd02b2ab9384448cf0c3e2d 100644 (file)
@@ -50,7 +50,8 @@ CINCLUDES =   -I${srcdir}/include -I${srcdir}/unix/include -I. \
                ${OPENSSL_CFLAGS} \
                ${JSON_C_CFLAGS} \
                ${LIBXML2_CFLAGS} \
-               ${MAXMINDDB_CFLAGS}
+               ${MAXMINDDB_CFLAGS} \
+               ${ZLIB_CFLAGS}
 
 CDEFINES =      @CONTRIB_DLZ@
 
@@ -59,8 +60,8 @@ CWARNINGS =
 DNSLIBS =      ../../lib/dns/libdns.@A@ ${MAXMINDDB_LIBS} @DNS_CRYPTO_LIBS@
 ISCCFGLIBS =   ../../lib/isccfg/libisccfg.@A@
 ISCCCLIBS =    ../../lib/isccc/libisccc.@A@
-ISCLIBS =      ../../lib/isc/libisc.@A@ ${OPENSSL_LIBS} ${JSON_C_LIBS} ${LIBXML2_LIBS}
-ISCNOSYMLIBS = ../../lib/isc/libisc-nosymtbl.@A@ ${OPENSSL_LIBS} ${JSON_C_LIBS} ${LIBXML2_LIBS}
+ISCLIBS =      ../../lib/isc/libisc.@A@ ${OPENSSL_LIBS} ${JSON_C_LIBS} ${LIBXML2_LIBS} ${ZLIB_LIBS}
+ISCNOSYMLIBS = ../../lib/isc/libisc-nosymtbl.@A@ ${OPENSSL_LIBS} ${JSON_C_LIBS} ${LIBXML2_LIBS} ${ZLIB_LIBS}
 BIND9LIBS =    ../../lib/bind9/libbind9.@A@
 NSLIBS =       ../../lib/ns/libns.@A@
 
index eaf81182396e5a7ac2475144bac7787411ee1f31..4cdad2a4703ec1e863074c36628cb9f75b66af20 100644 (file)
@@ -120,5 +120,6 @@ JSON_C_LIBS="@JSON_C_LIBS@"
 HAVEJSONSTATS=${JSON_C_LIBS:+1}
 MAXMINDDB_LIBS="@MAXMINDDB_LIBS@"
 HAVEGEOIP2=${MAXMINDDB_LIBS:+1}
-ZLIB=@ZLIB@
+ZLIB_LIBS="@ZLIB_LIBS@"
+HAVEZLIB=${ZLIB_LIBS:+1}
 NZD=@NZD_TOOLS@
index 4fae13759667e408c8234771710f71962c291f5a..98d69f8ca12d7b2ff939399126938478a13705df 100644 (file)
@@ -120,7 +120,7 @@ PYTHON=@PYTHON@
 #
 HAVEXMLSTATS=@XMLSTATS@
 HAVEJSONSTATS=@JSONSTATS@
-ZLIB=@ZLIB@
+HAVEZLIB=@ZLIB@
 NZD=@NZD_TOOLS@
 
 # The rest is shared between Windows and Unices
index a0147ec455eb67050e5fd21db8db1b2525605638..509a402df339e4c78da8b6cc627104f21bfc069f 100644 (file)
@@ -263,7 +263,7 @@ n=`expr $n + 1`
 
 ret=0
 echo_i "checking if compressed output is really compressed ($n)"
-if [ "$ZLIB" ];
+if [ "$HAVEZLIB" ];
 then
     REGSIZE=`cat regular.headers | \
        grep -i Content-Length | sed -e "s/.*: \([0-9]*\).*/\1/"`
index 180dd00b7406b623fa147584bcc83a33e036c7a0..91508e5d91404e927856903f058d0bee2f01d5a1 100644 (file)
 /* Define to 1 if you have the `usleep' function. */
 #undef HAVE_USLEEP
 
-/* Define if zlib was found */
+/* Use zlib library */
 #undef HAVE_ZLIB
 
 /* define if __atomic builtins are not available */
index 15168c12cd7ffbcb240c495cb9ce1f7f18a6da86..61f25216dd01a6a8cb683b76926dfa2e03f4479c 100755 (executable)
--- a/configure
+++ b/configure
@@ -725,7 +725,8 @@ purify_path
 MKDEPPROG
 MKDEPCFLAGS
 MKDEPCC
-ZLIB
+ZLIB_LIBS
+ZLIB_CFLAGS
 JSON_C_LIBS
 JSON_C_CFLAGS
 LIBXML2_LIBS
@@ -975,6 +976,8 @@ LIBXML2_CFLAGS
 LIBXML2_LIBS
 JSON_C_CFLAGS
 JSON_C_LIBS
+ZLIB_CFLAGS
+ZLIB_LIBS
 LIBIDN2_CFLAGS
 LIBIDN2_LIBS
 CMOCKA_CFLAGS
@@ -1671,7 +1674,7 @@ Optional Packages:
   --with-libjson          deprecated, use --with-json-c
   --with-json-c           build with json-c library [yes|no|detect] (default
                           is detect)
-  --with-zlib=PATH        build with zlib for HTTP compression [default=yes]
+  --with-zlib             build with zlib for HTTP compression [default=yes]
   --with-purify=PATH      use Rational purify
   --with-gperftools-profiler
                           use gperftools CPU profiler
@@ -1737,6 +1740,8 @@ Some influential environment variables:
   JSON_C_CFLAGS
               C compiler flags for JSON_C, overriding pkg-config
   JSON_C_LIBS linker flags for JSON_C, overriding pkg-config
+  ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config
+  ZLIB_LIBS   linker flags for ZLIB, overriding pkg-config
   LIBIDN2_CFLAGS
               C compiler flags for LIBIDN2, overriding pkg-config
   LIBIDN2_LIBS
 
 
 
-#
-# was --with-zlib specified?
-#
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlib library" >&5
-$as_echo_n "checking for zlib library... " >&6; }
 
 # Check whether --with-zlib was given.
 if test "${with_zlib+set}" = set; then :
-  withval=$with_zlib; with_zlib="$withval"
+  withval=$with_zlib;
 else
   with_zlib="auto"
 fi
 
 
-have_zlib=""
-case "$with_zlib" in
-       no)
-               zlib_libs=""
-               ;;
-       auto|yes)
-               for d in /usr /usr/local /opt/local
-               do
-                       if test -f "${d}/include/zlib.h"
-                       then
-                               if test ${d} != /usr
-                               then
-                                       zlib_cflags="-I ${d}/include"
-                                       LIBS="$LIBS -L${d}/lib"
-                               fi
-                               have_zlib="yes"
-                       fi
-               done
-               ;;
-       *)
-               if test -f "${with_zlib}/include/zlib.h"
-               then
-                       zlib_cflags="-I${with_zlib}/include"
-                       LIBS="$LIBS -L${with_zlib}/lib"
-                       have_zlib="yes"
-               else
-                       as_fn_error $? "$with_zlib/include/zlib.h not found." "$LINENO" 5
-               fi
-               ;;
-esac
+case $with_zlib in #(
+  no) :
+     ;; #(
+  auto) :
 
-if test "X${have_zlib}" != "X"
-then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing deflate" >&5
-$as_echo_n "checking for library containing deflate... " >&6; }
-if ${ac_cv_search_deflate+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlib" >&5
+$as_echo_n "checking for zlib... " >&6; }
 
-/* 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 deflate ();
-int
-main ()
-{
-return deflate ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' z; 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_deflate=$ac_res
+if test -n "$ZLIB_CFLAGS"; then
+    pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "zlib") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "zlib" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if ${ac_cv_search_deflate+:} false; then :
-  break
+ else
+    pkg_failed=untried
 fi
-done
-if ${ac_cv_search_deflate+:} false; then :
-
+if test -n "$ZLIB_LIBS"; then
+    pkg_cv_ZLIB_LIBS="$ZLIB_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "zlib") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "zlib" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
 else
-  ac_cv_search_deflate=no
+  pkg_failed=yes
 fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
+ else
+    pkg_failed=untried
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_deflate" >&5
-$as_echo "$ac_cv_search_deflate" >&6; }
-ac_res=$ac_cv_search_deflate
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
+
+
+if test $pkg_failed = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
 else
-  as_fn_error $? "found zlib include but not library." "$LINENO" 5
-                       have_zlib=""
+        _pkg_short_errors_supported=no
 fi
+        if test $_pkg_short_errors_supported = yes; then
+               ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "zlib" 2>&1`
+        else
+               ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "zlib" 2>&1`
+        fi
+       # Put the nasty error message in config.log where it belongs
+       echo "$ZLIB_PKG_ERRORS" >&5
 
-elif test "X$with_zlib" = Xyes
-then
-       as_fn_error $? "include/zlib.h not found." "$LINENO" 5
-else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+       :
+elif test $pkg_failed = untried; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
+       :
+else
+       ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS
+       ZLIB_LIBS=$pkg_cv_ZLIB_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_ZLIB 1" >>confdefs.h
+
+fi ;; #(
+  yes) :
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlib" >&5
+$as_echo_n "checking for zlib... " >&6; }
+
+if test -n "$ZLIB_CFLAGS"; then
+    pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "zlib") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "zlib" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$ZLIB_LIBS"; then
+    pkg_cv_ZLIB_LIBS="$ZLIB_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "zlib") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "zlib" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
 fi
 
-ZLIB=
-if test "X${have_zlib}" != "X"
-then
-       CFLAGS="$CFLAGS $zlib_cflags"
 
-$as_echo "#define HAVE_ZLIB 1" >>confdefs.h
 
-       ZLIB=1
+if test $pkg_failed = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+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
+               ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "zlib" 2>&1`
+        else
+               ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "zlib" 2>&1`
+        fi
+       # Put the nasty error message in config.log where it belongs
+       echo "$ZLIB_PKG_ERRORS" >&5
+
+       as_fn_error $? "Package requirements (zlib) were not met:
+
+$ZLIB_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
 
+Alternatively, you may set the environment variables ZLIB_CFLAGS
+and ZLIB_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
+$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 ZLIB_CFLAGS
+and ZLIB_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.
 
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.
+See \`config.log' for more details" "$LINENO" 5; }
+else
+       ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS
+       ZLIB_LIBS=$pkg_cv_ZLIB_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_ZLIB 1" >>confdefs.h
+
+fi ;; #(
+  *) :
+    as_fn_error $? "Specifying zlib installation path is not supported, adjust PKG_CONFIG_PATH instead" "$LINENO" 5 ;;
+esac
 
 #
 # In solaris 10, SMF can manage named service
index 9a0a37abb27815e92f567681e030b0563ae1c1d3..fd1a57e4a06584dcafdcc43d08d3121ef7d2d35f 100644 (file)
@@ -1281,69 +1281,20 @@ AS_CASE([$with_json_c],
 AC_SUBST([JSON_C_CFLAGS])
 AC_SUBST([JSON_C_LIBS])
 
-#
-# was --with-zlib specified?
-#
-AC_MSG_CHECKING(for zlib library)
-AC_ARG_WITH(zlib,
-           AS_HELP_STRING([--with-zlib[=PATH]],
-                          [build with zlib for HTTP compression
-                               [default=yes]]),
-           with_zlib="$withval", with_zlib="auto")
-
-have_zlib=""
-case "$with_zlib" in
-       no)
-               zlib_libs=""
-               ;;
-       auto|yes)
-               for d in /usr /usr/local /opt/local
-               do
-                       if test -f "${d}/include/zlib.h"
-                       then
-                               if test ${d} != /usr
-                               then
-                                       zlib_cflags="-I ${d}/include"
-                                       LIBS="$LIBS -L${d}/lib"
-                               fi
-                               have_zlib="yes"
-                       fi
-               done
-               ;;
-       *)
-               if test -f "${with_zlib}/include/zlib.h"
-               then
-                       zlib_cflags="-I${with_zlib}/include"
-                       LIBS="$LIBS -L${with_zlib}/lib"
-                       have_zlib="yes"
-               else
-                       AC_MSG_ERROR([$with_zlib/include/zlib.h not found.])
-               fi
-               ;;
-esac
-
-if test "X${have_zlib}" != "X"
-then
-       AC_MSG_RESULT(yes)
-       AC_SEARCH_LIBS([deflate], [z], [],
-                      [AC_MSG_ERROR([found zlib include but not library.])
-                       have_zlib=""])
-elif test "X$with_zlib" = Xyes
-then
-       AC_MSG_ERROR([include/zlib.h not found.])
-else
-       AC_MSG_RESULT(no)
-fi
-
-ZLIB=
-if test "X${have_zlib}" != "X"
-then
-       CFLAGS="$CFLAGS $zlib_cflags"
-       AC_DEFINE(HAVE_ZLIB, 1, [Define if zlib was found])
-       ZLIB=1
-fi
-AC_SUBST(ZLIB)
-
+AC_ARG_WITH([zlib],
+           [AS_HELP_STRING([--with-zlib],
+                           [build with zlib for HTTP compression
+                            [default=yes]])],
+          [], with_zlib="auto")
+
+AS_CASE([$with_zlib],
+       [no],[],
+       [auto],[PKG_CHECK_MODULES([ZLIB], [zlib],
+                                 [AC_DEFINE([HAVE_ZLIB], [1], [Use zlib library])],
+                                 [:])],
+       [yes],[PKG_CHECK_MODULES([ZLIB], [zlib],
+                                [AC_DEFINE([HAVE_ZLIB], [1], [Use zlib library])])],
+       [AC_MSG_ERROR([Specifying zlib installation path is not supported, adjust PKG_CONFIG_PATH instead])])
 
 #
 # In solaris 10, SMF can manage named service
index ddd44e3ef69ebf7cae8e58e793c3ca147d7a8486..ae7ca482bf4926ad638ad8374b967c38ed69d913 100644 (file)
@@ -23,7 +23,8 @@ CINCLUDES =   -I${srcdir}/unix/include \
                -I${srcdir}/include ${DNS_INCLUDES} \
                ${OPENSSL_CFLAGS} \
                ${JSON_C_CFLAGS} \
-               ${LIBXML2_CFLAGS}
+               ${LIBXML2_CFLAGS} \
+               ${ZLIB_CFLAGS}
 CDEFINES =
 CWARNINGS =
 
index 97d3e57fd1a35bac1a20b136dab3a825c8c75293..e1d17cd8ba8cd1a1169515d432520b9dcf977ac1 100644 (file)
@@ -132,6 +132,9 @@ LIBXML2_LIBS = @LIBXML2_LIBS@
 MAXMINDDB_CFLAGS = @MAXMINDDB_CFLAGS@
 MAXMINDDB_LIBS = @MAXMINDDB_LIBS@
 
+ZLIB_CFLAGS = @ZLIB_CFLAGS@
+ZLIB_LIBS = @ZLIB_LIBS@
+
 .SUFFIXES:
 .SUFFIXES: .c .@O@