From 2b632a232fba8f6cbb0a971acc426d26d85a1144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 31 Jul 2019 13:50:15 +0200 Subject: [PATCH] Convert the configure.ac rules for zlib library to use pkg-config --- bin/named/Makefile.in | 7 +- bin/tests/system/conf.sh.in | 3 +- bin/tests/system/conf.sh.win32 | 2 +- bin/tests/system/statschannel/tests.sh | 2 +- config.h.in | 2 +- configure | 271 +++++++++++++++---------- configure.ac | 75 ++----- lib/isc/Makefile.in | 3 +- make/rules.in | 3 + 9 files changed, 193 insertions(+), 175 deletions(-) diff --git a/bin/named/Makefile.in b/bin/named/Makefile.in index 3b3a855cb0..f66bc9a6e2 100644 --- a/bin/named/Makefile.in +++ b/bin/named/Makefile.in @@ -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@ diff --git a/bin/tests/system/conf.sh.in b/bin/tests/system/conf.sh.in index eaf8118239..4cdad2a470 100644 --- a/bin/tests/system/conf.sh.in +++ b/bin/tests/system/conf.sh.in @@ -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@ diff --git a/bin/tests/system/conf.sh.win32 b/bin/tests/system/conf.sh.win32 index 4fae137596..98d69f8ca1 100644 --- a/bin/tests/system/conf.sh.win32 +++ b/bin/tests/system/conf.sh.win32 @@ -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 diff --git a/bin/tests/system/statschannel/tests.sh b/bin/tests/system/statschannel/tests.sh index a0147ec455..509a402df3 100644 --- a/bin/tests/system/statschannel/tests.sh +++ b/bin/tests/system/statschannel/tests.sh @@ -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/"` diff --git a/config.h.in b/config.h.in index 180dd00b74..91508e5d91 100644 --- a/config.h.in +++ b/config.h.in @@ -456,7 +456,7 @@ /* 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 */ diff --git a/configure b/configure index 15168c12cd..61f25216dd 100755 --- 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 @@ -17898,134 +17903,190 @@ esac -# -# 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 +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 - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end 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 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 + 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 -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" - -else - as_fn_error $? "found zlib include but not library." "$LINENO" 5 - have_zlib="" + else + pkg_failed=untried fi -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 + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } -fi -ZLIB= -if test "X${have_zlib}" != "X" -then - CFLAGS="$CFLAGS $zlib_cflags" +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 + + : +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 - ZLIB=1 +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 +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 . +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 # diff --git a/configure.ac b/configure.ac index 9a0a37abb2..fd1a57e4a0 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/lib/isc/Makefile.in b/lib/isc/Makefile.in index ddd44e3ef6..ae7ca482bf 100644 --- a/lib/isc/Makefile.in +++ b/lib/isc/Makefile.in @@ -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 = diff --git a/make/rules.in b/make/rules.in index 97d3e57fd1..e1d17cd8ba 100644 --- a/make/rules.in +++ b/make/rules.in @@ -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@