Re: How about some AC_MSG for dlopen?
Andreas Metzler <[email protected]> Wed, 21 Aug 2024 13:40:15 +0200
| Newsgroups | gmane.network.gnutls.general |
|---|---|
| Message-ID | <[email protected]> |
--QT3r1/DK4JWNm3e6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On 2024-08-21 Daiki Ueno <[email protected]> wrote: > Andreas Metzler <[email protected]> writes: [...] >> Per-library quadstate ends up being rather wordy, see attached example >> for handling zlib that way. I have thought about it but cannot see a >> substantial abbreviation potential ad_hoc, there are 8 cases to handle. >> - Do you want me follow-up, extending this approach to brotli/zstd/tpm? > Thanks. A couple of comments: [...] > - I would first normalize the argument for --with-*, something like: > AC_ARG_WITH(zstd, > AS_HELP_STRING([--without-zstd], [disable zstd compression support]), > with_zstd=$withval, with_zstd=yes) > AS_CASE([$with_zstd], > [yes], [AM_COND_IF([ENABLE_DLOPEN], [with_zstd=dlopen], [with_zstd=link])], > [dlopen], [AM_COND_IF([ENABLE_DLOPEN], [:], [AC_MSG_ERROR([[ > *** > *** Unable to dlopen ZSTD, try --with-zstd=link. > *** ]])])], > [link], [:], > [no], [:], > [AC_MSG_ERROR([[Unknown argument $with_zstd for --with-zstd]])]) > So afterwards $with_zstd should only be dlopen, link, or no. [...] Hello, Thanks for the handholding, that helped quite a bit. It is not quite that simple, I would expect ./configure --with-zstd to abort with an error if zstd support cannot be enabled, i.e. --with-zstd and not specifiying --with-zstd are not the same. cu Andreas -- `What a good friend you are to him, Dr. Maturin. His other friends are so grateful to you.' `I sew his ears on from time to time, sure' --QT3r1/DK4JWNm3e6 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="zlib-select-dlopen.v2.diff" diff --git a/configure.ac b/configure.ac index 47a7c7601b..4dd22b2362 100644 --- a/configure.ac +++ b/configure.ac @@ -953,10 +953,11 @@ fi AM_CONDITIONAL(P11KIT_0_23_11_API, $PKG_CONFIG --atleast-version=0.23.11 p11-kit-1) AM_CONDITIONAL(ENABLE_PKCS11, test "$with_p11_kit" != "no") +AC_MSG_CHECKING([whether we can dlopen helper-libraries]) save_LIBS=$LIBS LIBS="$LIBS -lm" LIBGNUTLS_CHECK_SONAME([m], [AC_LANG_PROGRAM([ #include <math.h>],[ trunc (0);])]) @@ -969,12 +970,14 @@ AC_RUN_IFELSE( #include <stdlib.h> ]], [[void *handle = dlopen("$M_LIBRARY_SONAME", RTLD_LAZY | RTLD_GLOBAL); return handle != NULL ? 0 : 1; ]])], - [ac_cv_dlopen_soname_works=yes], - [ac_cv_dlopen_soname_works=no], + [ac_cv_dlopen_soname_works=yes] + [AC_MSG_RESULT(yes)], + [ac_cv_dlopen_soname_works=no] + AC_MSG_RESULT([no]), [ac_cv_dlopen_soname_works=cross-compiling]) AM_CONDITIONAL([ENABLE_DLOPEN], [test "$ac_cv_dlopen_soname_works" = yes]) need_ltlibdl=no @@ -1091,48 +1094,56 @@ AC_SUBST(TROUSERS_LIB) # For minitasn1. 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 <zlib.h>], [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") +AM_CONDITIONAL(HAVE_ZLIB, test "$ac_zlib" != "no") AC_SUBST(LIBZ_PC) -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_LIBS=$LIBS LIBS="$LIBS $ZLIB_LIBS" LIBGNUTLS_CHECK_SONAME([z], [AC_LANG_PROGRAM([ #include <zlib.h>],[ compress (0, 0, 0, 0);])]) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" ], - [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 GNUTLS_REQUIRES_PRIVATE="$GNUTLS_REQUIRES_PRIVATE, zlib" fi diff --git a/lib/Makefile.am b/lib/Makefile.am index d932b585d4..7b7e69403c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -92,11 +92,11 @@ COBJECTS = range.c record.c compress.c debug.c cipher.c gthreads.h handshake-tls 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) endif endif --QT3r1/DK4JWNm3e6 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Gnutls-help mailing list [email protected] http://lists.gnupg.org/mailman/listinfo/gnutls-help --QT3r1/DK4JWNm3e6--