From: Andreas Metzler Date: Mon, 19 Aug 2024 12:46:29 +0000 (+0200) Subject: Select whether to link/dlopen zlib configure time X-Git-Tag: 3.8.8~12^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b91c07d573bda12f99be284e6abb3f9459a78b99;p=thirdparty%2Fgnutls.git Select whether to link/dlopen zlib configure time Now requires pkg-conf for locating zlib. Signed-off-by: Andreas Metzler --- diff --git a/configure.ac b/configure.ac index 7406766550..68d7adb0c8 100644 --- a/configure.ac +++ b/configure.ac @@ -1096,44 +1096,53 @@ AC_CHECK_SIZEOF(unsigned long int, 4) AC_CHECK_SIZEOF(unsigned int, 4) AC_CHECK_SIZEOF(time_t, 4) -AC_ARG_WITH(zlib, AS_HELP_STRING([--without-zlib], - [disable zlib compression support]), - ac_zlib=$withval, ac_zlib=yes) -if test x$ac_zlib != xno; then - PKG_CHECK_EXISTS(zlib, ZLIB_HAS_PKGCONFIG=y, ZLIB_HAS_PKGCONFIG=n) - if test "$ZLIB_HAS_PKGCONFIG" = "y" ; then - PKG_CHECK_MODULES(ZLIB, [zlib]) - ac_zlib=yes - else - AC_LIB_HAVE_LINKFLAGS(z,, [#include ], [compress (0, 0, 0, 0);]) - if test x$ac_cv_libz != xyes; then +AC_ARG_WITH(zlib, + [AS_HELP_STRING([--with-zlib=yes/link/dlopen/no --without-zlib], + [customize/disable zlib compression support])], + ac_zlib=$withval, ac_zlib=yes zlib_optional=yes) +AS_CASE([$ac_zlib], + [yes], + [AM_COND_IF([ENABLE_DLOPEN], [ac_zlib=dlopen], [ac_zlib=link])], + [dlopen], + [AM_COND_IF([ENABLE_DLOPEN], [:],[AC_MSG_ERROR([[ +*** +*** Unable to dlopen ZLIB, try --with-zlib=link. +*** ]])])], + [link], [:], + [no], [:], + [AC_MSG_ERROR([[Unknown argument ${ac_zlib} for --with-zlib]])]) + + +AS_IF([test x$ac_zlib != xno], + [PKG_CHECK_MODULES([ZLIB],[zlib],, + [ac_zlib=no + AS_IF([test x$zlib_optional != xyes], + AC_MSG_ERROR([zlib requested but not available])) AC_MSG_WARN([[ *** *** ZLIB was not found. You will not be able to use ZLIB compression. *** ]]) - fi - ac_zlib=$ac_cv_libz - ZLIB_LIBS=$LIBZ - LIBZ_PC=$LIBZ - fi -fi + ])]) + if test x$ac_zlib != xno; then AC_DEFINE([HAVE_LIBZ], 1, [Define if ZLIB compression is enabled.]) need_ltlibdl=yes fi -AM_CONDITIONAL(HAVE_ZLIB, test "$ac_zlib" = "yes") -AC_SUBST(LIBZ_PC) +AM_CONDITIONAL(HAVE_ZLIB, test "$ac_zlib" != "no") -AS_IF([test "$ac_cv_dlopen_soname_works" = yes], [ +AM_CONDITIONAL([ZLIB_ENABLE_DLOPEN], [test "$ac_zlib" = dlopen]) +AS_IF([test "$ac_zlib" = dlopen], [ + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $ZLIB_CFLAGS" save_LIBS=$LIBS LIBS="$LIBS $ZLIB_LIBS" LIBGNUTLS_CHECK_SONAME([z], [AC_LANG_PROGRAM([ #include ],[ compress (0, 0, 0, 0);])]) - LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" ], - [test "$ZLIB_HAS_PKGCONFIG" = y && test "$ac_zlib" = yes], [ + [test "$ac_zlib" = link], [ if test "x$GNUTLS_REQUIRES_PRIVATE" = x; then GNUTLS_REQUIRES_PRIVATE="Requires.private: zlib" else diff --git a/lib/Makefile.am b/lib/Makefile.am index d932b585d4..7b7e69403c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -94,7 +94,7 @@ if HAVE_ZLIB COBJECTS += dlwrap/zlib.c dlwrap/zlibfuncs.h dlwrap/zlib.h AM_CPPFLAGS += $(ZLIB_CFLAGS) -if ENABLE_DLOPEN +if ZLIB_ENABLE_DLOPEN AM_CPPFLAGS += -DGNUTLS_ZLIB_ENABLE_DLOPEN=1 else thirdparty_libadd += $(ZLIB_LIBS) diff --git a/lib/gnutls.pc.in b/lib/gnutls.pc.in index eeb957cb72..7cdedda5d7 100644 --- a/lib/gnutls.pc.in +++ b/lib/gnutls.pc.in @@ -19,6 +19,6 @@ Description: Transport Security Layer implementation for the GNU system URL: https://www.gnutls.org/ Version: @VERSION@ Libs: -L${libdir} -lgnutls -Libs.private: @LIBZ_PC@ @LIBINTL@ @LIBSOCKET@ @INET_PTON_LIB@ @LIBPTHREAD@ @LIB_SELECT@ @TSS_LIBS@ @GMP_LIBS@ @LIBUNISTRING@ @LIBATOMIC_LIBS@ @GNUTLS_LIBS_PRIVATE@ +Libs.private: @LIBINTL@ @LIBSOCKET@ @INET_PTON_LIB@ @LIBPTHREAD@ @LIB_SELECT@ @TSS_LIBS@ @GMP_LIBS@ @LIBUNISTRING@ @LIBATOMIC_LIBS@ @GNUTLS_LIBS_PRIVATE@ @GNUTLS_REQUIRES_PRIVATE@ Cflags: -I${includedir}