From: Amos Jeffries Date: Sun, 7 Apr 2024 11:34:49 +0000 (+0000) Subject: Have SQUID_CHECK_LIB_WORKS do state SAVE/RESTORE (#1774) X-Git-Tag: SQUID_7_0_1~149 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=597b7f1283f9aa602efd1d8edbcdae0f17f26b52;p=thirdparty%2Fsquid.git Have SQUID_CHECK_LIB_WORKS do state SAVE/RESTORE (#1774) Removing a lot of duplicated code and further simplifying library detection. --- diff --git a/acinclude/squid-util.m4 b/acinclude/squid-util.m4 index c71f975aac..4a33cce7f3 100644 --- a/acinclude/squid-util.m4 +++ b/acinclude/squid-util.m4 @@ -217,14 +217,19 @@ AC_DEFUN([SQUID_YESNO],[ dnl Check that a library is actually available, useable, dnl and where its pieces are (eg headers and hack macros) dnl Parameters for this macro are: -dnl 1) library name (without 'lib' prefix) -dnl 2) necessary library checks (to be executed by this macro unless the use of the library is disabled) -dnl These checks should set LIBFOO_LIBS automake variable (on success) -dnl and ensure that it is empty or unset (on failures). +dnl 1) library name without 'lib' prefix +dnl 2) necessary library checks to be executed by this macro +dnl - These checks are not run when library use is explicitly disabled. +dnl - These checks should set LIBFOO_LIBS automake variable on success +dnl and ensure that it is empty or unset on failures. +dnl - These checks may set or change LIBS and xxFLAGS variables as needed. +dnl This macro restores those variables afterward (see SQUID_STATE_SAVE for details). AC_DEFUN([SQUID_CHECK_LIB_WORKS],[ AH_TEMPLATE(m4_toupper(m4_translit([HAVE_LIB$1], [-+.], [___])),[Define as 1 to enable '$1' library support.]) AS_IF([m4_translit([test "x$with_$1" != "xno"], [-+.], [___])],[ + SQUID_STATE_SAVE(check_lib_works_state) $2 + SQUID_STATE_ROLLBACK(check_lib_works_state) AS_IF([! test -z m4_toupper(m4_translit(["$LIB$1_LIBS"], [-+.], [___]))],[ m4_toupper(m4_translit([CPPFLAGS="$LIB$1_CFLAGS $CPPFLAGS"], [-+.], [___])) m4_toupper(m4_translit([LIB$1_LIBS="$LIB$1_PATH $LIB$1_LIBS"], [-+.], [___])) diff --git a/configure.ac b/configure.ac index 26804fa2e5..f429725822 100644 --- a/configure.ac +++ b/configure.ac @@ -394,7 +394,6 @@ SQUID_AUTO_LIB(dl,[dynamic linking],[LIBDL]) SQUID_CHECK_LIB_WORKS(dl,[ LDFLAGS="$LIBDL_PATH $LDFLAGS" AC_CHECK_LIB(dl, dlopen,[LIBDL_LIBS="-ldl"]) - LIBS="$LIBDL_LIBS $LIBS" ]) AC_DEFUN([LIBATOMIC_CHECKER],[ @@ -432,7 +431,6 @@ AC_SUBST(ATOMICLIB) SQUID_AUTO_LIB(psapi,[Windows PSAPI.dll],[LIBPSAPI]) SQUID_CHECK_LIB_WORKS(psapi,[ - SQUID_STATE_SAVE(squid_psapi_state) CPPFLAGS="$LIBPSAPI_CFLAGS $CPPFLAGS" LIBS="$LIBPSAPI_PATH $LIBS" AC_CHECK_LIB([psapi],[K32GetProcessMemoryInfo],[ @@ -443,7 +441,6 @@ SQUID_CHECK_LIB_WORKS(psapi,[ #endif ]) ]) - SQUID_STATE_ROLLBACK(squid_psapi_state) ]) AC_SEARCH_LIBS([shm_open], [rt]) @@ -834,21 +831,17 @@ AC_MSG_NOTICE([Enable ESI processor: ${enable_esi:=no (auto)}]) # ESI support libraries: expat SQUID_AUTO_LIB(expat,[ESI expat library],[LIBEXPAT]) SQUID_CHECK_LIB_WORKS(expat,[ - SQUID_STATE_SAVE(squid_expat_state) PKG_CHECK_MODULES([LIBEXPAT],[expat],[:],[:]) CPPFLAGS="$LIBEXPAT_CFLAGS $CPPFLAGS" AC_CHECK_HEADERS(expat.h) - SQUID_STATE_ROLLBACK(squid_expat_state) ]) # ESI support libraries: xml2 SQUID_AUTO_LIB(xml2,[ESI xml2 library],[LIBXML2]) SQUID_CHECK_LIB_WORKS(xml2,[ - SQUID_STATE_SAVE([squid_libxml2_save]) PKG_CHECK_MODULES([LIBXML2],[libxml-2.0],[:],[:]) CPPFLAGS="$LIBXML2_CFLAGS $CPPFLAGS" AC_CHECK_HEADERS(libxml/parser.h libxml/HTMLparser.h libxml/HTMLtree.h) - SQUID_STATE_ROLLBACK([squid_libxml2_save]) ]) AS_IF([test "x$enable_esi" = "xyes" -a "x$LIBXML2_LIBS" = "x" -a "x$LIBEXPAT_LIBS" = "x"],[ @@ -1041,12 +1034,10 @@ AC_MSG_NOTICE([HTCP support enabled: $enable_htcp]) # Cryptograhic libraries SQUID_AUTO_LIB(nettle,[Nettle crypto],[LIBNETTLE]) SQUID_CHECK_LIB_WORKS(nettle,[ - SQUID_STATE_SAVE(squid_nettle_state) PKG_CHECK_MODULES([LIBNETTLE],[nettle >= 3.4],[ CPPFLAGS="$LIBNETTLE_CFLAGS $CPPFLAGS" AC_CHECK_HEADERS(nettle/base64.h nettle/md5.h) ],[:]) - SQUID_STATE_ROLLBACK(squid_nettle_state) ]) dnl Check for libcrypt @@ -1060,12 +1051,10 @@ AC_SUBST(CRYPTLIB) SQUID_AUTO_LIB(gnutls,[GnuTLS crypto],[LIBGNUTLS]) SQUID_CHECK_LIB_WORKS(gnutls,[ - SQUID_STATE_SAVE(squid_gnutls_state) PKG_CHECK_MODULES([LIBGNUTLS],[gnutls >= 3.4.0],[ CPPFLAGS="$LIBGNUTLS_CFLAGS $CPPFLAGS" AC_CHECK_HEADERS(gnutls/gnutls.h gnutls/x509.h gnutls/abstract.h) ],[:]) - SQUID_STATE_ROLLBACK(squid_gnutls_state) ]) SSLLIB="" @@ -1158,7 +1147,6 @@ SQUID_AUTO_LIB(mit-krb5,[MIT Kerberos],[LIB_KRB5]) AH_TEMPLATE(USE_APPLE_KRB5,[Apple Kerberos support is available]) AH_TEMPLATE(USE_SOLARIS_KRB5,[Solaris Kerberos support is available]) SQUID_CHECK_LIB_WORKS(mit-krb5,[ - SQUID_STATE_SAVE(squid_mit_krb5_save) AS_IF([test "x$squid_host_os" = "xsolaris"],[ # pkg-config not available for Solaris krb5 implementation SQUID_CHECK_SOLARIS_KRB5 @@ -1179,14 +1167,12 @@ SQUID_CHECK_LIB_WORKS(mit-krb5,[ SQUID_CHECK_KRB5_FUNCS ],[:]) ]) - SQUID_STATE_ROLLBACK(squid_mit_krb5_save) ]) # Kerberos support libraries: Heimdal SQUID_AUTO_LIB(heimdal-krb5,[Heimdal Kerberos],[LIBHEIMDAL_KRB5]) SQUID_CHECK_LIB_WORKS(heimdal-krb5,[ AS_IF([test "x$LIBMIT_KRB5_LIBS" = "x"],[ - SQUID_STATE_SAVE(squid_heimdal_krb5_save) PKG_CHECK_MODULES([LIBHEIMDAL_KRB5],[heimdal-krb5 heimdal-gssapi],[ CPPFLAGS="$LIBHEIMDAL_KRB5_CFLAGS $CPPFLAGS" AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h gssapi/gssapi_krb5.h) @@ -1196,7 +1182,6 @@ SQUID_CHECK_LIB_WORKS(heimdal-krb5,[ SQUID_CHECK_KRB5_HEIMDAL_BROKEN_KRB5_H SQUID_CHECK_KRB5_FUNCS ],[:]) - SQUID_STATE_ROLLBACK(squid_heimdal_krb5_save) ]) ]) @@ -1204,7 +1189,6 @@ SQUID_CHECK_LIB_WORKS(heimdal-krb5,[ SQUID_AUTO_LIB(gss,[GNU gss],[LIBGSS]) SQUID_CHECK_LIB_WORKS(gss,[ AS_IF([test "x$LIBMIT_KRB5_LIBS" = "x" -a "x$LIBHEIMDAL_KRB5_LIBS" = "x"],[ - SQUID_STATE_SAVE(squid_gss_save) PKG_CHECK_MODULES([LIBGSS],[gss],[ CPPFLAGS="$LIBGSS_CFLAGS $CPPFLAGS" AC_CHECK_HEADERS(gss.h) @@ -1216,13 +1200,11 @@ SQUID_CHECK_LIB_WORKS(gss,[ SQUID_CHECK_WORKING_KRB5 SQUID_DEFINE_BOOL(HAVE_KRB5,$squid_cv_working_krb5,[KRB5 support]) ],[:]) - SQUID_STATE_ROLLBACK(squid_gss_save) ]) ]) SQUID_AUTO_LIB(ldap,[LDAP],[LIBLDAP]) SQUID_CHECK_LIB_WORKS(ldap,[ - SQUID_STATE_SAVE(squid_ldap_state) PKG_CHECK_MODULES([LIBLDAP],[ldap],[:],[:]) AS_IF([test "$squid_host_os" = "mingw" -a "x$LIBLDAP_LIBS" = "x"],[ dnl On MinGW OpenLDAP is not available, try Windows LDAP libraries @@ -1233,27 +1215,22 @@ SQUID_CHECK_LIB_WORKS(ldap,[ AC_CHECK_HEADERS(ldap.h lber.h) AC_CHECK_HEADERS(mozldap/ldap.h) SQUID_CHECK_LDAP_API - SQUID_STATE_ROLLBACK(squid_ldap_state) ]) SQUID_AUTO_LIB(sasl,[Cyrus SASL],[LIBSASL]) SQUID_CHECK_LIB_WORKS([sasl],[ - SQUID_STATE_SAVE(sasl_state) PKG_CHECK_MODULES([LIBSASL],[libsasl2],[:],[:]) CPPFLAGS="$LIBSASL_CFLAGS $CPPFLAGS" LIBS="$LIBSASL_LIBS $LIBS" AC_CHECK_HEADERS([sasl/sasl.h sasl.h]) - SQUID_STATE_ROLLBACK(sasl_state) ]) SQUID_AUTO_LIB(systemd,[systemd API for start-up notification],[LIBSYSTEMD]) SQUID_CHECK_LIB_WORKS(systemd,[ - SQUID_STATE_SAVE(squid_systemd_state) LIBS="$LIBS $LIBSYSTEMD_PATH" PKG_CHECK_MODULES(LIBSYSTEMD,[libsystemd >= 209],[ AC_CHECK_HEADERS(systemd/sd-daemon.h) ],[:]) - SQUID_STATE_ROLLBACK(squid_systemd_state) ]) AC_ARG_ENABLE(forw-via-db, @@ -1443,7 +1420,6 @@ AC_MSG_NOTICE([Linux Netfilter support requested: ${enable_linux_netfilter:=auto dnl Look for libnetfilter_conntrack options (needed for QOS netfilter marking) SQUID_AUTO_LIB(netfilter-conntrack,[Netfilter conntrack],[LIBNETFILTER_CONNTRACK]) SQUID_CHECK_LIB_WORKS(netfilter-conntrack,[ - SQUID_STATE_SAVE(squid_netfilter_conntrack_state) PKG_CHECK_MODULES([LIBNETFILTER_CONNTRACK],[libnetfilter_conntrack],[:],[:]) CPPFLAGS="$LIBNETFILTER_CONNTRACK_CFLAGS $CPPFLAGS" LIBS="$LIBNETFILTER_CONNTRACK_PATH $LIBNETFILTER_CONNTRACK_LIBS $LIBS" @@ -1451,7 +1427,6 @@ SQUID_CHECK_LIB_WORKS(netfilter-conntrack,[ libnetfilter_conntrack/libnetfilter_conntrack.h \ libnetfilter_conntrack/libnetfilter_conntrack_tcp.h \ ]) - SQUID_STATE_ROLLBACK(squid_netfilter_conntrack_state) ]) dnl Enable Large file support @@ -1787,11 +1762,9 @@ SQUID_CHECK_LIB_WORKS(cppunit,[ AC_MSG_NOTICE([using system installed cppunit version $squid_cv_cppunit_version]) AS_UNSET(squid_cv_cppunit_version) - SQUID_STATE_SAVE(squid_cppunit_state) CXXFLAGS="${CXXFLAGS} ${LIBCPPUNIT_CFLAGS}" LIBS="${LIBS} ${LIBCPPUNIT_LIBS}" AC_CHECK_HEADERS(cppunit/extensions/HelperMacros.h) - SQUID_STATE_ROLLBACK(squid_cppunit_state) ],[ AC_MSG_WARN([cppunit does not appear to be installed. Squid does not require this, but code testing with 'make check' will fail.]) ]) @@ -2006,14 +1979,12 @@ AC_FUNC_ALLOCA SQUID_AUTO_LIB(cap,[Linux capabilities],[LIBCAP]) SQUID_CHECK_LIB_WORKS(cap,[ - SQUID_STATE_SAVE(squid_libcap_state) PKG_CHECK_MODULES([LIBCAP],[libcap >= 2.09],[:],[:]) CPPFLAGS="$LIBCAP_CFLAGS $CPPFLAGS" LIBS="$LIBCAP_PATH $LIBCAP_LIBS $LIBS" SQUID_CHECK_FUNCTIONAL_LIBCAP2 AC_MSG_NOTICE([libcap headers are ok: $squid_cv_sys_capability_works]) AS_IF([test "x$squid_cv_sys_capability_works" = "xno"],[LIBCAP_LIBS=""]) - SQUID_STATE_ROLLBACK(squid_libcap_state) ]) dnl Check for needed libraries