On 2024-08-19 Daiki Ueno <[email protected]> wrote:
> Andreas Metzler <[email protected]> writes:
> > On 2024-08-17 Daiki Ueno <[email protected]> wrote:
> >> Andreas Metzler <[email protected]> writes:
> >> > ./configure is quiet about whether dlopening librariers is supported,
> >> > would it make sense to a) add messages and perhaps b) provide a switch
> >> > to force use of linking instead?
[...]
> I would prefer to have the option per library, because some of the
> libraries are less likely to be available than the others (e.g.,
> tpm2-tss vs. zlib).
[...]
Hello,
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?
The global switch is obviously simpler.
cu Andreas
diff --git a/configure.ac b/configure.ac
index 47a7c7601b..627990eaa4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -975,10 +975,13 @@ AC_RUN_IFELSE(
[ac_cv_dlopen_soname_works=no],
[ac_cv_dlopen_soname_works=cross-compiling])
AM_CONDITIONAL([ENABLE_DLOPEN], [test "$ac_cv_dlopen_soname_works" = yes])
need_ltlibdl=no
+AS_IF([test "$ac_cv_dlopen_soname_works" = yes],
+ [AC_MSG_NOTICE([Can dlopen helper-libraries])],
+ [AC_MSG_NOTICE([Need to link against helper-libraries])])
AC_ARG_WITH(tpm2,
AS_HELP_STRING([--without-tpm2],
[Disable TPM2 support.]),
[with_tpm2=$withval], [with_tpm2=auto])
@@ -1091,48 +1094,79 @@ 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)
+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=try)
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
+ ac_zlib=found-${ac_zlib}
else
AC_LIB_HAVE_LINKFLAGS(z,, [#include <zlib.h>], [compress (0, 0, 0, 0);])
if test x$ac_cv_libz != xyes; then
AC_MSG_WARN([[
***
*** ZLIB was not found. You will not be able to use ZLIB compression.
*** ]])
+ ac_zlib=notfound-${ac_zlib}
+ else
+ ac_zlib=found-${ac_zlib}
fi
- ac_zlib=$ac_cv_libz
ZLIB_LIBS=$LIBZ
LIBZ_PC=$LIBZ
fi
fi
+AS_IF([test "$ac_zlib" = "notfound-yes" || test "$ac_zlib" = "notfound-link" || test "$ac_zlib" = "notfound-dlopen"],
+ AC_MSG_ERROR([zlib requested but not available]),
+ [test "$ac_zlib" = "found-dlopen" && test "$ac_cv_dlopen_soname_works" != "yes"],
+ AC_MSG_ERROR([dlopened zlib requested but dlopening not available]))
+
+case $ac_zlib in
+ no|notfound-try)
+ ac_zlib=no
+ ;;
+ found-link)
+ ac_zlib=link
+ ;;
+ found-dlopen)
+ ac_zlib=dlopen
+ ;;
+ found-try|found-yes)
+ if test "$ac_cv_dlopen_soname_works" = yes ; then
+ ac_zlib=dlopen
+ else
+ ac_zlib=link
+ fi
+ ;;
+ *)
+ AC_MSG_ERROR([autoconf coding error, should not be reached])
+ ;;
+esac
+
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 "$ZLIB_HAS_PKGCONFIG" = y && 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
diff --git a/configure.ac b/configure.ac
index 47a7c7601b..f8f04096b1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -953,33 +953,48 @@ 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")
-save_LIBS=$LIBS
-LIBS="$LIBS -lm"
-LIBGNUTLS_CHECK_SONAME([m], [AC_LANG_PROGRAM([
- #include <math.h>],[
- trunc (0);])])
-LIBS="$save_LIBS"
-CFLAGS="$save_CFLAGS"
-
-AC_RUN_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <dlfcn.h>
- #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=cross-compiling])
+AC_ARG_ENABLE([dlopen-libs],
+ [AS_HELP_STRING([--disable-dlopen-libs],
+ [link against instead of dlopening some helper-libraries])],
+ [ac_dlopen_libs=$enableval],
+ [ac_dlopen_libs=try])
+
+AS_IF([test "$ac_dlopen_libs" != "no"],
+ [save_LIBS=$LIBS
+ LIBS="$LIBS -lm"
+ LIBGNUTLS_CHECK_SONAME([m], [AC_LANG_PROGRAM([
+ #include <math.h>],[
+ trunc (0);])])
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <dlfcn.h>
+ #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=cross-compiling])],
+ [ac_cv_dlopen_soname_works=no])
AM_CONDITIONAL([ENABLE_DLOPEN], [test "$ac_cv_dlopen_soname_works" = yes])
need_ltlibdl=no
+AS_IF([test "$ac_cv_dlopen_soname_works" = yes],
+ AC_MSG_RESULT([will dlopen helper-libraries]),
+ [test "$ac_dlopen_libs" = "yes"],
+ AC_MSG_ERROR([--enable-dlopen-libs requested but not available]),
+ AC_MSG_RESULT([will link against instead of dlopening helper-libraries]))
+
+
AC_ARG_WITH(tpm2,
AS_HELP_STRING([--without-tpm2],
[Disable TPM2 support.]),
[with_tpm2=$withval], [with_tpm2=auto])
AS_IF([test "$with_tpm2" != no], [
_______________________________________________
Gnutls-help mailing list
[email protected]
http://lists.gnupg.org/mailman/listinfo/gnutls-help