On 29/04/2013 7:56 p.m., Kinkie wrote:
To resolve this I propose changing the config.test files into small M4
scriptlets which can be included directly into configure at bootstrap time.
Devil's in the details.. m4 has no namespaces and scriptlets can leave
messes behind. Do you have any specific idea on how to do it? Unless
the inclusion is done with very unsofisticated tools.
Pros:
* we gain a huge amount of information from existing configure.ac tests
* we gain ability to run autoconf checks in the test scriptlets
* we can push test results back to the main configure.ac cache from the
scriptlets for faster overall process
Cons:
* we lose the ability to drop-in third party helpers and build as if they
were part of the Squid sources.
However I am not aware of any downstream distro packagers actually making
use of this ability so it should not be a big loss.
Opinions?
The current situation is crappy. Externally-supplied helpers should be
fully external, and shouldn't expect to be built as part of squid or
even in the squid sources.
So I fully +1 on the objective, and I'd like us to elaborate a bit
more on how to reach it.
The attached patch converts the basic auth helpers to the new system,
but only converts some of the helpers. So shows an example of how we can
retain the old ability even after the change (if we want to). Doing a
manual list like this is not too onerous, and we may be able to
auto-generate the if statement list if necessary.
Amos
=== modified file 'acinclude/squid-util.m4'
--- acinclude/squid-util.m4 2012-10-11 21:14:50 +0000
+++ acinclude/squid-util.m4 2013-04-29 14:13:17 +0000
@@ -249,3 +249,30 @@
[$4])
AS_VAR_POPDEF([ac_Search])dnl
])
+
+dnl Check for Cyrus SASL
+AC_DEFUN([SQUID_CHECK_SASL],[
+ squid_sasl_present="auto"
+ AC_CHECK_HEADERS(sasl/sasl.h sasl.h)
+ AC_CHECK_LIB(sasl2,sasl_errstring,[LIBSASL="-lsasl2"],[
+ AC_CHECK_LIB(sasl,sasl_errstring,[LIBSASL="-lsasl"], [
+ squid_sasl_present="no"
+ ])
+ ])
+ case "$squid_host_os" in
+ Darwin)
+ if test "$ac_cv_lib_sasl2_sasl_errstring" = "yes" ; then
+ AC_DEFINE(HAVE_SASL_DARWIN,1,[Define to 1 if Mac Darwin without
sasl.h])
+ echo "checking for MAC Darwin without sasl.h ... yes"
+ squid_sasl_present="yes"
+ else
+ echo "checking for MAC Darwin without sasl.h ... no"
+ squid_sasl_present="no"
+ fi
+ ;;
+ esac
+ if test "x$squid_sasl_present" != "yes"; then
+ AC_MSG_WARN(Neither SASL nor SASL2 found)
+ fi
+ AC_SUBST(LIBSASL)
+])
=== modified file 'configure.ac'
--- configure.ac 2013-04-16 02:21:47 +0000
+++ configure.ac 2013-04-29 15:47:56 +0000
@@ -1726,45 +1726,7 @@
To see available helpers, see the helpers/basic_auth directory. ]),[
#nothing to do really
])
-#not specified. Inherit global
-if test "x$enable_auth_basic" = "x"; then
- enable_auth_basic=$enable_auth
-fi
-#conflicts with global
-if test "x$enable_auth_basic" != "xno" -a "x$enable_auth" = "xno" ; then
- AC_MSG_ERROR([Basic auth requested but auth disabled])
-fi
-#define list of modules to build
-if test "x$enable_auth_basic" = "xyes" ; then
- SQUID_LOOK_FOR_MODULES([$srcdir/helpers/basic_auth],[enable_auth_basic])
-fi
-#handle the "none" special case
-if test "x$enable_auth_basic" = "xnone" ; then
- enable_auth_basic=""
-fi
-BASIC_AUTH_HELPERS=""
-#enable_auth_basic contains either "no" or the list of modules to be built
-enable_auth_basic="`echo $enable_auth_basic| sed -e 's/,/ /g;s/ */ /g'`"
-if test "x$enable_auth_basic" != "xno" ; then
- AUTH_MODULES="$AUTH_MODULES basic"
- AC_DEFINE([HAVE_AUTH_MODULE_BASIC],1,[Basic auth module is built])
- for helper in $enable_auth_basic
- do
- dir="$srcdir/helpers/basic_auth/$helper"
- if test -f "$dir/config.test" && sh "$dir/config.test" "$squid_host_os";
then
- BASIC_AUTH_HELPERS="$BASIC_AUTH_HELPERS $helper"
- # special case
- if test "x$helper" = "xSASL" ; then
- squid_require_sasl=yes
- fi
- elif test -d "$srcdir/helpers/basic_auth/$helper" ; then
- AC_MSG_NOTICE([Basic auth helper $helper ... found but cannot be built])
- fi
- done
-fi
-AC_MSG_NOTICE([Basic auth helpers to be built: $BASIC_AUTH_HELPERS])
-AM_CONDITIONAL(ENABLE_AUTH_BASIC, test "x$enable_auth_basic" != "xno")
-AC_SUBST(BASIC_AUTH_HELPERS)
+m4_include([helpers/basic_auth/modules.m4])
AC_ARG_ENABLE(auth-ntlm,
AS_HELP_STRING([--enable-auth-ntlm="list of helpers"],
@@ -2096,7 +2058,7 @@
EXTERNAL_ACL_HELPERS="$EXTERNAL_ACL_HELPERS $helper"
# special case
if test "x$helper" = "xkerberos_ldap_group" ; then
- squid_require_sasl=yes
+ SQUID_CHECK_SASL
fi
else
AC_MSG_NOTICE([external acl helper $helper ... found but cannot be
built])
@@ -2184,27 +2146,6 @@
AC_MSG_NOTICE([MS Windows service mode enabled: $enable_win32_service])
-# Check for Cyrus SASL
-if test "x$squid_require_sasl" = "xyes"; then
- AC_CHECK_HEADERS(sasl/sasl.h sasl.h)
- AC_CHECK_LIB(sasl2,sasl_errstring,[LIBSASL="-lsasl2"],[
- AC_CHECK_LIB(sasl,sasl_errstring,[LIBSASL="-lsasl"], [
- AC_MSG_ERROR(Neither SASL nor SASL2 found)
- ])
- ])
- case "$squid_host_os" in
- Darwin)
- if test "$ac_cv_lib_sasl2_sasl_errstring" = "yes" ; then
- AC_DEFINE(HAVE_SASL_DARWIN,1,[Define to 1 if Mac Darwin without
sasl.h])
- echo "checking for MAC Darwin without sasl.h ... yes"
- else
- echo "checking for MAC Darwin without sasl.h ... no"
- fi
- ;;
- esac
- AC_SUBST(LIBSASL)
-fi
-
# Disable "unlinkd" code
AC_ARG_ENABLE(unlinkd,
AS_HELP_STRING([--disable-unlinkd],[Do not use unlinkd]), [
=== renamed file 'helpers/basic_auth/DB/config.test' =>
'helpers/basic_auth/DB/required.m4'
--- helpers/basic_auth/DB/config.test 2010-03-31 15:59:21 +0000
+++ helpers/basic_auth/DB/required.m4 2013-04-29 15:37:09 +0000
@@ -1,7 +1,3 @@
-#!/bin/sh
-
-## Test: do we have perl to build the helper scripts?
-## Test: do we have pod2man to build the manual?
-perl --version >/dev/null && echo | pod2man >/dev/null
-
-exit $?
+if test "x$PERL" != "x" -a "x$POD2MAN" != "x"; then
+ BUILD_HELPER="DB"
+fi
=== renamed file 'helpers/basic_auth/LDAP/config.test' =>
'helpers/basic_auth/LDAP/required.m4'
--- helpers/basic_auth/LDAP/config.test 2013-04-16 13:06:01 +0000
+++ helpers/basic_auth/LDAP/required.m4 2013-04-29 15:37:35 +0000
@@ -1,8 +1,1 @@
-#!/bin/sh
-if [ -f /usr/include/ldap.h -o -f /usr/local/include/ldap.h ]; then
- exit 0
-fi
-if [ -f /usr/include/winldap.h ]; then
- exit 0
-fi
-exit 1
+AC_CHECK_HEADERS([ldap.h winldap.h],[BUILD_HELPER="LDAP"])
=== renamed file 'helpers/basic_auth/SASL/config.test' =>
'helpers/basic_auth/SASL/required.m4'
--- helpers/basic_auth/SASL/config.test 2013-04-16 13:06:01 +0000
+++ helpers/basic_auth/SASL/required.m4 2013-04-29 15:37:54 +0000
@@ -1,8 +1,6 @@
-#!/bin/sh
-if [ -f /usr/include/sasl.h -o -f /usr/local/include/sasl.h ]; then
- exit 0
-fi
-if [ -f /usr/include/sasl/sasl.h -o -f /usr/local/include/sasl/sasl.h ]; then
- exit 0
-fi
-exit 1
+SQUID_CHECK_SASL
+
+# on success, add to the built modules list
+if test "x$squid_check_sasl" = "xyes"; then
+ BUILD_HELPER="SASL"
+fi
=== renamed file 'helpers/basic_auth/fake/config.test' =>
'helpers/basic_auth/fake/required.m4'
--- helpers/basic_auth/fake/config.test 2010-07-12 14:45:17 +0000
+++ helpers/basic_auth/fake/required.m4 2013-04-29 15:42:52 +0000
@@ -1,2 +1,1 @@
-#!/bin/sh
-exit 0
+BUILD_HELPER="fake"
=== added file 'helpers/basic_auth/modules.m4'
--- helpers/basic_auth/modules.m4 1970-01-01 00:00:00 +0000
+++ helpers/basic_auth/modules.m4 2013-04-29 15:54:48 +0000
@@ -0,0 +1,68 @@
+# This file is supposed to run all the tests required to identify which
+# configured modules are able to be built in this environment
+
+# FIXME: de-duplicate $enable_auth_basic list containing double entries.
+
+#not specified. Inherit global
+if test "x$enable_auth_basic" = "x"; then
+ enable_auth_basic=$enable_auth
+fi
+#conflicts with global
+if test "x$enable_auth_basic" != "xno" -a "x$enable_auth" = "xno" ; then
+ AC_MSG_ERROR([Basic auth requested but auth disabled])
+fi
+#define list of modules to build
+if test "x$enable_auth_basic" = "xyes" ; then
+ SQUID_LOOK_FOR_MODULES([$srcdir/helpers/basic_auth],[enable_auth_basic])
+fi
+#handle the "none" special case
+if test "x$enable_auth_basic" = "xnone" ; then
+ enable_auth_basic=""
+fi
+
+BASIC_AUTH_HELPERS=""
+#enable_auth_basic contains either "no" or the list of modules to be built
+enable_auth_basic="`echo $enable_auth_basic| sed -e 's/,/ /g;s/ */ /g'`"
+if test "x$enable_auth_basic" != "xno" ; then
+ AUTH_MODULES="$AUTH_MODULES basic"
+ AC_DEFINE([HAVE_AUTH_MODULE_BASIC],1,[Basic auth module is built])
+ for helper in $enable_auth_basic
+ do
+ dir="$srcdir/helpers/basic_auth/$helper"
+
+ # modules converted to autoconf macros already
+ # NP: we only need this list because m4_include() does not accept
variables
+ if test "x$helper" = "xDB" ; then
+ m4_include([helpers/basic_auth/DB/required.m4])
+
+ elif test "x$helper" = "xfake" ; then
+ m4_include([helpers/basic_auth/fake/required.m4])
+
+ elif test "x$helper" = "xLDAP" ; then
+ m4_include([helpers/basic_auth/LDAP/required.m4])
+
+ elif test "x$helper" = "xSASL" ; then
+ m4_include([helpers/basic_auth/SASL/required.m4])
+
+# TODO others...
+
+ # modules not yet converted to autoconf macros (or third party drop-in's)
+ elif test -f "$dir/config.test" && sh "$dir/config.test"
"$squid_host_os"; then
+ BUILD_HELPER="$helper"
+ fi
+
+ if test -d "$srcdir/helpers/basic_auth/$helper"; then
+ if test "$BUILD_HELPER" != "$helper"; then
+ AC_MSG_NOTICE([Basic auth helper $helper ... found but cannot be
built])
+ else
+ BASIC_AUTH_HELPERS="$BASIC_AUTH_HELPERS $BUILD_HELPER"
+ fi
+ else
+ AC_MSG_ERROR([Basic auth helper $helper ... not found])
+ fi
+ done
+fi
+
+AC_MSG_NOTICE([Basic auth helpers to be built: $BASIC_AUTH_HELPERS])
+AM_CONDITIONAL(ENABLE_AUTH_BASIC, test "x$enable_auth_basic" != "xno")
+AC_SUBST(BASIC_AUTH_HELPERS)