To enable but build no helpers, specify "none".
       To see available helpers, see the helpers/ntlm_auth directory. ]),[
 ])
-if test "x$enable_auth_ntlm" = "x"; then
-    enable_auth_ntlm=$enable_auth
-fi
-#conflicts with global
-if test "x$enable_auth_ntlm" != "xno" -a "x$enable_auth" = "xno" ; then
-    AC_MSG_ERROR([NTLM auth requested but auth disabled])
-fi
-#define list of modules to build
-if test "x$enable_auth_ntlm" = "xyes" ; then
-    SQUID_LOOK_FOR_MODULES([$srcdir/helpers/ntlm_auth],[enable_auth_ntlm])
-fi
-#handle the "none" special case
-if test "x$enable_auth_ntlm" = "xnone" ; then
-    enable_auth_ntlm=""
-fi
-NTLM_AUTH_HELPERS=""
-enable_auth_ntlm="`echo $enable_auth_ntlm| sed -e 's/,/ /g;s/  */ /g'`"
-if test "x$enable_auth_ntlm" != "xno" ; then
-    AUTH_MODULES="$AUTH_MODULES ntlm"
-    AC_DEFINE([HAVE_AUTH_MODULE_NTLM],1,[NTLM auth module is built])
-    for helper in $enable_auth_ntlm ; do
-        dir="$srcdir/helpers/ntlm_auth/$helper"
-        if test -f "$dir/config.test" && sh "$dir/config.test" "$squid_host_os"; then
-            NTLM_AUTH_HELPERS="$NTLM_AUTH_HELPERS $helper"
-        elif test -d "$srcdir/helpers/ntlm_auth/$helper" ; then
-            AC_MSG_NOTICE([NTLM auth helper $helper ... found but cannot be built])
-        fi
-    done
-fi
-AC_MSG_NOTICE([NTLM auth helpers built: $NTLM_AUTH_HELPERS])
-AM_CONDITIONAL(ENABLE_AUTH_NTLM, test "x$enable_auth_ntlm" != "xno")
-AC_SUBST(NTLM_AUTH_HELPERS)
+m4_include([helpers/ntlm_auth/modules.m4])
 
 AC_ARG_ENABLE(auth-negotiate,
   AS_HELP_STRING([--enable-auth-negotiate="list of helpers"],
       To see available helpers, see the helpers/negotiate_auth directory. ]),[
 #nothing to do, really
 ])
-if test "x$enable_auth_negotiate" = "x"; then
-    enable_auth_negotiate=$enable_auth
-fi
-#conflicts with global
-if test "x$enable_auth_negotiate" != "xno" -a "x$enable_auth" = "xno" ; then
-    AC_MSG_ERROR([Negotiate auth requested but auth disabled])
-fi
-#define list of modules to build
-if test "x$enable_auth_negotiate" = "xyes" ; then
-    SQUID_LOOK_FOR_MODULES([$srcdir/helpers/negotiate_auth],[enable_auth_negotiate])
-fi
-#handle the "none" special case
-if test "x$enable_auth_negotiate" = "xnone" ; then
-    enable_auth_negotiate=""
-fi
-NEGOTIATE_AUTH_HELPERS=""
-enable_auth_negotiate="`echo $enable_auth_negotiate| sed -e 's/,/ /g;s/  */ /g'`"
-if test "x$enable_auth_negotiate" != "xno" ; then
-    AUTH_MODULES="$AUTH_MODULES negotiate"
-    AC_DEFINE([HAVE_AUTH_MODULE_NEGOTIATE],1,[Negotiate auth module is built])
-    for helper in $enable_auth_negotiate ; do
-        dir="$srcdir/helpers/negotiate_auth/$helper"
-        if test -f "$dir/config.test" && sh "$dir/config.test" "$squid_host_os"; then
-            NEGOTIATE_AUTH_HELPERS="$NEGOTIATE_AUTH_HELPERS $helper"
-        elif test -d "$srcdir/helpers/negotiate_auth/$helper" ; then
-            AC_MSG_NOTICE([Negotiate auth helper $helper ... found but cannot be built])
-        fi
-    done
-fi
-AC_MSG_NOTICE([Negotiate auth helpers built: $NEGOTIATE_AUTH_HELPERS])
-AM_CONDITIONAL(ENABLE_AUTH_NEGOTIATE, test "x$enable_auth_negotiate" != "xno")
-AC_SUBST(NEGOTIATE_AUTH_HELPERS)
+m4_include([helpers/negotiate_auth/modules.m4])
 
 AC_ARG_ENABLE(auth-digest,
   AS_HELP_STRING([--enable-auth-digest="list of helpers"],
       To see available helpers, see the helpers/digest_auth directory. ]),[
 #nothing to do, really
 ])
-if test "x$enable_auth_digest" = "x"; then
-    enable_auth_digest=$enable_auth
-fi
-#conflicts with global
-if test "x$enable_auth_digest" != "xno" -a "x$enable_auth" = "xno" ; then
-    AC_MSG_ERROR([Digest auth requested but auth disabled])
-fi
-#define list of modules to build
-if test "x$enable_auth_digest" = "xyes" ; then
-    SQUID_LOOK_FOR_MODULES([$srcdir/helpers/digest_auth],[enable_auth_digest])
-fi
-#handle the "none" special case
-if test "x$enable_auth_digest" = "xnone" ; then
-    enable_auth_digest=""
-fi
-DIGEST_AUTH_HELPERS=""
-enable_auth_digest="`echo $enable_auth_digest| sed -e 's/,/ /g;s/  */ /g'`"
-if test "x$enable_auth_digest" != "xno" ; then
-    AUTH_MODULES="$AUTH_MODULES digest"
-    AC_DEFINE([HAVE_AUTH_MODULE_DIGEST],1,[Digest auth module is built])
-    for helper in $enable_auth_digest ; do
-        dir="$srcdir/helpers/digest_auth/$helper"
-        if test -f "$dir/config.test" && sh "$dir/config.test" "$squid_host_os"; then
-            DIGEST_AUTH_HELPERS="$DIGEST_AUTH_HELPERS $helper"
-        elif test -d "$srcdir/helpers/digest_auth/$helper" ; then
-            AC_MSG_NOTICE([Digest auth helper $helper ... found but cannot be built])
-        fi
-    done
-fi
-AC_MSG_NOTICE([Digest auth helpers built: $DIGEST_AUTH_HELPERS])
-AM_CONDITIONAL(ENABLE_AUTH_DIGEST, test "x$enable_auth_digest" != "xno")
-AC_SUBST(DIGEST_AUTH_HELPERS)
+m4_include([helpers/digest_auth/modules.m4])
 
 dnl Authentication libraries to build
 dnl This list will not be needed when each auth library has its own Makefile
   *)   squid_opt_logdaemon_helpers="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`" ;;
   esac
 ])
-if test "x$squid_opt_logdaemon_helpers" = "xauto" ; then
-  squid_opt_logdaemon_helpers=""
-  SQUID_LOOK_FOR_MODULES([$srcdir/helpers/log_daemon],[squid_opt_logdaemon_helpers])
-fi
-for helper in $squid_opt_logdaemon_helpers ; do
-  dir="$srcdir/helpers/log_daemon/$helper"
-  if test -f "$dir/config.test" && sh "$dir/config.test" "$squid_host_os"; then
-    LOG_DAEMON_HELPERS="$LOG_DAEMON_HELPERS $helper"
-  elif test -d "$srcdir/helpers/log_daemon/$helper" ; then
-    AC_MSG_NOTICE([Log daemon helper $helper ... found but cannot be built])
-  fi
-done
-AC_MSG_NOTICE([Log daemon helpers built: $LOG_DAEMON_HELPERS])
-AC_SUBST(LOG_DAEMON_HELPERS)
+m4_include([helpers/log_daemon/modules.m4])
 
 dnl
 dnl Check Kerberos/GSSAPI/SPNEGO
                   directory]), [
 #nothing to do, really
 ])
-if test "x${enable_external_acl_helpers:=yes}" = "xyes" ;then
-  SQUID_LOOK_FOR_MODULES([$srcdir/helpers/external_acl],
-    [enable_external_acl_helpers])
-fi
-if test "x$enable_external_acl_helpers" = "xnone" ; then
-  enable_external_acl_helpers=""
-fi
-EXTERNAL_ACL_HELPERS=""
-enable_external_acl_helpers="`echo $enable_external_acl_helpers| sed -e 's/,/ /g;s/  */ /g'`"
-if test "x$enable_external_acl_helpers" != "xno" ; then
-  for helper in $enable_external_acl_helpers ; do
-    dir="$srcdir/helpers/external_acl/$helper"
-    if test -f "$dir/config.test" && sh "$dir/config.test" "$squid_host_os"; then
-      EXTERNAL_ACL_HELPERS="$EXTERNAL_ACL_HELPERS $helper"
-      # special case
-      if test "x$helper" = "xkerberos_ldap_group" ; then
-        SQUID_CHECK_SASL
-      fi
-    else
-      AC_MSG_NOTICE([external acl helper $helper ... found but cannot be built])
-    fi
-  done
-fi
-AC_MSG_NOTICE([External acl helpers built: $EXTERNAL_ACL_HELPERS])
-AC_SUBST(EXTERNAL_ACL_HELPERS)
-
-
+m4_include([helpers/external_acl/modules.m4])
 
 dnl Select url_rewrite helpers to build
 AC_ARG_ENABLE(url-rewrite-helpers,
                   For a list of available helpers see the
                   helpers/url_rewrite directory.]),[
 ])
-if test "x${enable_url_rewrite_helpers:=yes}" = "xyes" ; then
-    SQUID_LOOK_FOR_MODULES([$srcdir/helpers/url_rewrite],
-                           [enable_url_rewrite_helpers])
-fi
-enable_url_rewrite_helpers="`echo $enable_url_rewrite_helpers| sed -e 's/,/ /g;s/  */ /g'`"
-AC_MSG_NOTICE([URL rewrite helper candidates: $enable_url_rewrite_helpers])
-URL_REWRITE_HELPERS=""
-if test "x$enable_url_rewrite_helpers" != "xno" ; then
-  for helper in $enable_url_rewrite_helpers; do
-    dir="$srcdir/helpers/url_rewrite/$helper"
-    if test -f "$dir/config.test" && sh "$dir/config.test" "$squid_host_os"; then
-      URL_REWRITE_HELPERS="$URL_REWRITE_HELPERS $helper"
-    elif test -d "$srcdir/helpers/ntlm_auth/$helper" ; then
-      AC_MSG_NOTICE([URL rewrite helper $helper ... found but cannot be built])
-    else
-      AC_MSG_NOTICE([URL rewrite helper $helper ... not found])
-    fi
-  done
-fi
-AC_MSG_NOTICE([URL rewrite helpers built: $URL_REWRITE_HELPERS])
-AC_SUBST(URL_REWRITE_HELPERS)
-
+m4_include([helpers/url_rewrite/modules.m4])
 
 AC_ARG_WITH(valgrind-debug,
   AS_HELP_STRING([--with-valgrind-debug],
 
 #
-## TODO: This can be done far better I'm sure
+# The shell script helper require smbclient to be in the environment PATH.
+# We can install anyway, but warn if smbclient not found already
 #
-for prefix in /usr/local /opt /opt/samba /usr/local/samba /usr
-do
-    if [ -x ${prefix}/bin/smbclient ]; then
-        BUILD_HELPER="SMB"
-    fi
-done
-if test "x$BUILD_HELPER" = "x"; then
+AC_PATH_PROG(SMBCLIENT, smbclient)
+if test "x$SMBCLIENT" = "x"; then
   AC_MSG_WARN([Samba smbclient not found in default location. basic_smb_auth may not work on this machine])
 fi
 # allow script install anyway.
 
 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"
+    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
           BASIC_AUTH_HELPERS="$BASIC_AUTH_HELPERS $BUILD_HELPER"
         fi
       else
-          AC_MSG_ERROR([Basic auth helper $helper ... not found])
+        AC_MSG_ERROR([Basic auth helper $helper ... not found])
       fi
     done
 fi
 
        $(SSLLIB) \
        $(XTRA_LIBS)
 
-EXTRA_DIST = config.test
+EXTRA_DIST = required.m4
 
+++ /dev/null
-#!/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
 
--- /dev/null
+AC_CHECK_HEADERS([ldap.h winldap.h],[BUILD_HELPER="LDAP"])
 
        LDAP
 
 SUBDIRS= $(DIGEST_AUTH_HELPERS)
+
+EXTRA_DIST = modules.m4
 
        $(SSLLIB) \
        $(XTRA_LIBS)
 
-EXTRA_DIST = config.test
+EXTRA_DIST = required.m4
 
+++ /dev/null
-#!/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
 
--- /dev/null
+AC_CHECK_HEADERS([ldap.h winldap.h],[BUILD_HELPER="LDAP"])
 
        $(SSLLIB) \
        $(XTRA_LIBS)
 
-EXTRA_DIST = digest_file_auth.8 config.test
+EXTRA_DIST = digest_file_auth.8 required.m4
 
+++ /dev/null
-#!/bin/sh
-exit 0
 
--- /dev/null
+BUILD_HELPER="file"
 
--- /dev/null
+# 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_digest list containing double entries.
+
+#not specified. Inherit global
+if test "x$enable_auth_digest" = "x"; then
+    enable_auth_digest=$enable_auth
+fi
+#conflicts with global
+if test "x$enable_auth_digest" != "xno" -a "x$enable_auth" = "xno" ; then
+    AC_MSG_ERROR([Digest auth requested but auth disabled])
+fi
+#define list of modules to build
+if test "x$enable_auth_digest" = "xyes" ; then
+    SQUID_LOOK_FOR_MODULES([$srcdir/helpers/digest_auth],[enable_auth_digest])
+fi
+#handle the "none" special case
+if test "x$enable_auth_digest" = "xnone" ; then
+    enable_auth_digest=""
+fi
+
+DIGEST_AUTH_HELPERS=""
+enable_auth_digest="`echo $enable_auth_digest| sed -e 's/,/ /g;s/  */ /g'`"
+if test "x$enable_auth_digest" != "xno" ; then
+    AUTH_MODULES="$AUTH_MODULES digest"
+    AC_DEFINE([HAVE_AUTH_MODULE_DIGEST],1,[Digest auth module is built])
+    for helper in $enable_auth_digest; do
+      dir="$srcdir/helpers/digest_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" = "xLDAP" ; then
+        m4_include([helpers/digest_auth/LDAP/required.m4])
+
+      elif test "x$helper" = "xeDirectory" ; then
+        m4_include([helpers/digest_auth/eDirectory/required.m4])
+
+      elif test "x$helper" = "xfile" ; then
+        m4_include([helpers/digest_auth/file/required.m4])
+
+      # 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/digest_auth/$helper"; then
+        if test "$BUILD_HELPER" != "$helper"; then
+          AC_MSG_NOTICE([Digest auth helper $helper ... found but cannot be built])
+        else
+          DIGEST_AUTH_HELPERS="$DIGEST_AUTH_HELPERS $BUILD_HELPER"
+        fi
+      else
+        AC_MSG_ERROR([Digest auth helper $helper ... not found])
+      fi
+    done
+fi
+AC_MSG_NOTICE([Digest auth helpers to be built: $DIGEST_AUTH_HELPERS])
+AM_CONDITIONAL(ENABLE_AUTH_DIGEST, test "x$enable_auth_digest" != "xno")
+AC_SUBST(DIGEST_AUTH_HELPERS)
 
 # Currently activeds and adsiid libraries are not available on MinGW or Cygwin,
 # so the following library list is just a placeholder for future MinGW/Cygwin releases.
 # This helper can be compiled only using Microsoft Visual Studio.
+# TODO: test for these libraries in required.m4
 #
 LDADD = \
        $(COMPAT_LIB) \
        -ladsiid \
        $(XTRA_LIBS)
 
-EXTRA_DIST = config.test ext_ad_group_acl.8
+EXTRA_DIST = required.m4 ext_ad_group_acl.8
 
+++ /dev/null
-#!/bin/sh
-if [ -f /usr/include/w32api/dsrole.h ]; then
-  if grep -q DsRoleGetPrimaryDomainInformation /usr/include/w32api/dsrole.h; then
-         exit 0
-       fi
-fi
-if [ -f /usr/include/dsrole.h ]; then
-  if grep -q DsRoleGetPrimaryDomainInformation /usr/include/dsrole.h; then
-         exit 0
-  fi
-fi
-exit 1
 
--- /dev/null
+#
+## TODO: make a AC_COMPILE check instead
+#
+for hdr in w32api/dsrole.h dsrole.h; do
+  AC_EGREP_HEADER(/usr/include/$hdr,[DsRoleGetPrimaryDomainInformation],[BUILD_HELPER="AD_group"])
+done
 
 ext_ldap_group_acl_SOURCES     = ext_ldap_group_acl.cc
 
 man_MANS                       = ext_ldap_group_acl.8
-EXTRA_DIST                     = ext_ldap_group_acl.8 config.test
+EXTRA_DIST                     = ext_ldap_group_acl.8 required.m4
 
 LDADD = \
        $(top_builddir)/lib/libmiscencoding.la \
 
+++ /dev/null
-#!/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
 
--- /dev/null
+AC_CHECK_HEADERS([ldap.h winldap.h],[BUILD_HELPER="LDAP_group"])
 
 
 man_MANS = ext_lm_group_acl.8
 
-EXTRA_DIST = config.test ext_lm_group_acl.8
+EXTRA_DIST = required.m4 ext_lm_group_acl.8
 
+++ /dev/null
-#!/bin/sh
-#
-# Only build this helper on Windows
-#
-if test "$1" = "mingw"; then
-        exit 0
-fi
-if [ -f /usr/include/w32api/windows.h ]; then
-       exit 0
-fi
-if [ -f /usr/include/windows.h ]; then
-       exit 0
-fi
-exit 1
 
--- /dev/null
+#
+# Only build this helper on Windows
+#
+AC_CHECK_HEADERS([w32api/windows.h windows.h],[BUILD_HELPER="LM_group"])
 
 EXTRA_DIST= \
        ext_sql_session_acl.8 \
        ext_sql_session_acl.pl.in \
-       config.test
+       required.m4
 
 ext_sql_session_acl.8: ext_sql_session_acl
        pod2man ext_sql_session_acl ext_sql_session_acl.8
 
+++ /dev/null
-#!/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 $?
 
--- /dev/null
+if test "x$PERL" != "x" -a "x$POD2MAN" != "x"; then
+  BUILD_HELPER="SQL_session"
+fi
 
 
 man_MANS = ext_edirectory_userip_acl.8
 
-EXTRA_DIST = config.test ext_edirectory_userip_acl.8
+EXTRA_DIST = required.m4 ext_edirectory_userip_acl.8
 
+++ /dev/null
-#!/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
 
--- /dev/null
+AC_CHECK_HEADERS([ldap.h winldap.h],[BUILD_HELPER="eDirectory_userip"])
 
        example.conf \
        example-deny_all_but.conf \
        ext_file_userip_acl.8 \
-       config.test
+       required.m4
 
 LDADD = \
        $(top_builddir)/lib/libmiscencoding.la \
 
+++ /dev/null
-#!/bin/sh
-if [ -f /usr/include/sys/socket.h ]; then
-    exit 0
-fi
-exit 1
 
--- /dev/null
+AC_CHECK_HEADERS([sys/socket.h],[BUILD_HELPER="file_userip"])
 
 include $(top_srcdir)/src/Common.am
 
-EXTRA_DIST = README config.test cert_tool ext_kerberos_ldap_group_acl.8
+EXTRA_DIST = README required.m4 cert_tool ext_kerberos_ldap_group_acl.8
 SUBDIRS = 
 
 AM_CPPFLAGS = $(INCLUDES) -I$(srcdir)
 
+++ /dev/null
-#!/bin/sh
-# Don't build without gssapi.h
-if [ -f /usr/include/ldap.h -o -f /usr/local/include/ldap.h ]; then
-       # Won't link without SASL as well
-       if [ -f /usr/include/sasl.h -o -f /usr/include/sasl/sasl.h -o -f /usr/local/include/sasl.h -o -f /usr/local/include/sasl/sasl.h ]; then
-               if [ -f /usr/lib/libsasl.a -o -f /usr/lib/libsasl2.a ]; then
-                       exit 0
-               fi
-               if [ -f /usr/lib/libsasl.la -o -f /usr/lib/libsasl2.la ]; then
-                       exit 0
-               fi
-               if [ -f /usr/lib/libsasl.so -o -f /usr/lib/libsasl2.so ]; then
-                       exit 0
-               fi
-               if [ -f /usr/lib64/libsasl.so -o -f /usr/lib64/libsasl2.so ]; then
-                       exit 0
-               fi
-               if [ -f  /usr/local/lib/libsasl.so -o -f  /usr/local/lib/libsasl2.so ]; then
-                       exit 0
-               fi
-       fi
-fi
-exit 1
 
--- /dev/null
+AC_CHECK_HEADERS([ldap.h],[BUILD_HELPER="kerberos_ldap_group"])
+SQUID_CHECK_SASL
 
--- /dev/null
+# 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_external_acl_helpers list containing double entries.
+
+#define list of modules to build
+if test "x${enable_external_acl_helpers:=yes}" = "xyes" ;then
+  SQUID_LOOK_FOR_MODULES([$srcdir/helpers/external_acl],[enable_external_acl_helpers])
+fi
+if test "x$enable_external_acl_helpers" = "xnone" ; then
+  enable_external_acl_helpers=""
+fi
+EXTERNAL_ACL_HELPERS=""
+enable_external_acl_helpers="`echo $enable_external_acl_helpers| sed -e 's/,/ /g;s/  */ /g'`"
+if test "x$enable_external_acl_helpers" != "xno" ; then
+  for helper in $enable_external_acl_helpers ; do
+    dir="$srcdir/helpers/external_acl/$helper"
+
+      # modules converted to autoconf macros already
+      # NP: we only need this list because m4_include() does not accept variables
+      if test "x$helper" = "xAD_group" ; then
+        m4_include([helpers/external_acl/AD_group/required.m4])
+
+      elif test "x$helper" = "xLDAP_group" ; then
+        m4_include([helpers/external_acl/LDAP_group/required.m4])
+
+      elif test "x$helper" = "xLM_group" ; then
+        m4_include([helpers/external_acl/LM_group/required.m4])
+
+      elif test "x$helper" = "xSQL_session" ; then
+        m4_include([helpers/external_acl/SQL_session/required.m4])
+
+      elif test "x$helper" = "xeDirectory_userip" ; then
+        m4_include([helpers/external_acl/eDirectory_userip/required.m4])
+
+      elif test "x$helper" = "xfile_userip" ; then
+        m4_include([helpers/external_acl/file_userip/required.m4])
+
+      elif test "x$helper" = "xkerberos_ldap_group" ; then
+        m4_include([helpers/external_acl/kerberos_ldap_group/required.m4])
+
+      elif test "x$helper" = "xsession" ; then
+        m4_include([helpers/external_acl/session/required.m4])
+
+      elif test "x$helper" = "xtime_quota" ; then
+        m4_include([helpers/external_acl/time_quota/required.m4])
+
+      elif test "x$helper" = "xunix_group" ; then
+        m4_include([helpers/external_acl/unix_group/required.m4])
+
+      elif test "x$helper" = "xwbinfo_group" ; then
+        m4_include([helpers/external_acl/wbinfo_group/required.m4])
+
+      # 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/external_acl/$helper"; then
+        if test "$BUILD_HELPER" != "$helper"; then
+          AC_MSG_NOTICE([external acl helper $helper ... found but cannot be built])
+        else
+          EXTERNAL_ACL_HELPERS="$EXTERNAL_ACL_HELPERS $BUILD_HELPER"
+        fi
+      else
+        AC_MSG_ERROR([external acl helper $helper ... not found])
+      fi
+  done
+fi
+AC_MSG_NOTICE([External acl helpers to be built: $EXTERNAL_ACL_HELPERS])
+AC_SUBST(EXTERNAL_ACL_HELPERS)
 
 
 libexec_PROGRAMS               = ext_session_acl
 man_MANS                       = ext_session_acl.8
-EXTRA_DIST                     = ext_session_acl.8 config.test
+EXTRA_DIST                     = ext_session_acl.8 required.m4
 ext_session_acl_SOURCES                = ext_session_acl.cc
 
 LDADD = \
 
+++ /dev/null
-#!/bin/sh
-
-if [ -f /usr/include/db.h ] && grep db_env_create /usr/include/db.h; then
-    exit 0
-fi
-exit 1
 
--- /dev/null
+AC_EGREP_HEADER(/usr/include/db.h,db_env_create,[BUILD_HELPER="session"])
 
 
 libexec_PROGRAMS               = ext_time_quota_acl
 man_MANS                       = ext_time_quota_acl.8
-EXTRA_DIST                     = ext_time_quota_acl.8 config.test
+EXTRA_DIST                     = ext_time_quota_acl.8 required.m4
 ext_time_quota_acl_SOURCES     = ext_time_quota_acl.cc
 
 DEFS += -DDEFAULT_QUOTA_DB=\"$(localstatedir)/ext_time_quota.db\" 
 
+++ /dev/null
-#!/bin/sh
-
-# Actual intended test
-if [ -f /usr/include/db_185.h ]; then
-    exit 0
-fi
-if [ -f /usr/include/db.h ] && grep dbopen /usr/include/db.h; then
-    exit 0
-fi
-exit 1
 
--- /dev/null
+AC_CHECK_HEADERS([db_185.h],[BUILD_HELPER="time_quota"])
+AC_EGREP_HEADER(/usr/include/db.h,dbopen,[BUILD_HELPER="time_quota"])
 
 
 libexec_PROGRAMS               = ext_unix_group_acl
 man_MANS                       = ext_unix_group_acl.8
-EXTRA_DIST                     = ext_unix_group_acl.8 config.test
+EXTRA_DIST                     = ext_unix_group_acl.8 required.m4
 ext_unix_group_acl_SOURCES     = check_group.cc
 
 LDADD = \
 
+++ /dev/null
-#!/bin/sh
-if [ -f /usr/include/pwd.h ]; then
-       exit 0
-fi
-exit 1
 
--- /dev/null
+AC_CHECK_HEADERS([pwd.h],[BUILD_HELPER="unix_group"])
 
 include $(top_srcdir)/src/Common.am
 
 libexec_SCRIPTS = ext_wbinfo_group_acl
-EXTRA_DIST     = ext_wbinfo_group_acl.pl.in config.test
+EXTRA_DIST     = ext_wbinfo_group_acl.pl.in required.m4
 
 ext_wbinfo_group_acl: ext_wbinfo_group_acl.pl.in
        $(subst_perlshell)
 
+++ /dev/null
-#!/bin/sh
-samba_found="no"
-for sambaprefix in /usr/local /opt /opt/samba /usr/local/samba /usr
-do
-    if [ -x $sambaprefix/bin/wbinfo ]; then
-      samba_found="yes"
-    fi
-done
-if test "$samba_found" = "no"; then
-    echo "WARNING: Samba wbinfo not found in default location. ext_wbinfo_group_acl may not work on this machine"
-fi
-for perlprefix in /usr /usr/local /opt /opt/perl
-do
-    if [ -x $perlprefix/bin/perl ]; then
-        exit 0
-    fi
-done
-exit 1
 
--- /dev/null
+#
+# The shell script helper requires wbinfo to be in the environment PATH.
+# We can install anyway, but warn if the tool is missing
+#
+AC_PATH_PROG(WBINFO, wbinfo)
+if test "x$WBINFO" = "x"; then
+  AC_MSG_WARN([Samba wbinfo not found in default location. ext_wbinfo_group_acl may not work on this machine])
+fi
+
+# allow script install anyway when perl is present
+if test "x$PERL" != "x" -a "x$POD2MAN" != "x"; then
+  BUILD_HELPER="wbinfo_group"
+fi
 
 CLEANFILES += log_db_daemon log_db_daemon.8
 man_MANS = log_db_daemon.8
 EXTRA_DIST= \
-       config.test \
+       required.m4 \
        doc/views.sql \
        doc/date_day_column.sql \
        log_db_daemon.8 \
 
+++ /dev/null
-#!/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 $?
 
--- /dev/null
+if test "x$PERL" != "x" -a "x$POD2MAN" != "x"; then
+  BUILD_HELPER="DB"
+fi
 
        file
 
 SUBDIRS        = $(LOG_DAEMON_HELPERS)
+EXTRA_DIST = modules.m4
 
 log_file_daemon_LDADD = \
        -L$(top_builddir)/lib $(COMPAT_LIB) \
        $(XTRA_LIBS)
-EXTRA_DIST = config.test
+EXTRA_DIST = required.m4
 
+++ /dev/null
-#!/bin/sh
-exit 0
 
--- /dev/null
+BUILD_HELPER="file"
 
--- /dev/null
+# 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 $squid_opt_logdaemon_helpers list containing double entries.
+
+#define list of modules to build
+if test "x$squid_opt_logdaemon_helpers" = "xauto" ; then
+  squid_opt_logdaemon_helpers=""
+  SQUID_LOOK_FOR_MODULES([$srcdir/helpers/log_daemon],[squid_opt_logdaemon_helpers])
+fi
+
+LOG_DAEMON_HELPERS=""
+squid_opt_logdaemon_helpers="`echo $squid_opt_logdaemon_helpers| sed -e 's/,/ /g;s/  */ /g'`"
+if test "x$squid_opt_logdaemon_helpers" = "x"; then
+  for helper in $squid_opt_logdaemon_helpers ; do
+    dir="$srcdir/helpers/log_daemon/$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/log_daemon/DB/required.m4])
+
+    elif test "x$helper" = "xfile" ; then
+      m4_include([helpers/log_daemon/file/required.m4])
+
+    # 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/log_daemon/$helper"; then
+      if test "$BUILD_HELPER" != "$helper"; then
+        AC_MSG_NOTICE([Log daemon helper $helper ... found but cannot be built])
+      else
+       LOG_DAEMON_HELPERS="$LOG_DAEMON_HELPERS $BUILD_HELPER"
+      fi
+    else
+      AC_MSG_ERROR([Log daemon helper $helper ... not found])
+    fi
+  done
+fi
+AC_MSG_NOTICE([Log daemon helpers to be built: $LOG_DAEMON_HELPERS])
+AC_SUBST(LOG_DAEMON_HELPERS)
 
        -ladvapi32 \
        $(XTRA_LIBS)
 
-EXTRA_DIST = readme.txt config.test
+EXTRA_DIST = readme.txt required.m4
 
+++ /dev/null
-#!/bin/sh
-#
-# Only build this helper on Windows
-#
-if test "$1" = "mingw"; then
-        exit 0
-fi
-if [ -f /usr/include/w32api/windows.h ]; then
-       exit 0
-fi
-if [ -f /usr/include/windows.h ]; then
-       exit 0
-fi
-exit 1
 
--- /dev/null
+#
+# Only build this helper on Windows
+#
+AC_CHECK_HEADERS([w32api/windows.h windows.h],[BUILD_HELPER="SSPI"])
 
 include $(top_srcdir)/src/Common.am
 
-EXTRA_DIST = README COPYING config.test negotiate_kerberos_auth.8
+EXTRA_DIST = README COPYING required.m4 negotiate_kerberos_auth.8
 SUBDIRS = 
 
 libexec_PROGRAMS = negotiate_kerberos_auth negotiate_kerberos_auth_test
 
+++ /dev/null
-#!/bin/sh
-# Don't build without gssapi.h
-if test -f /usr/include/gssapi/gssapi.h || test -f  /usr/include/gssapi.h || test -f /usr/include/kerberosV/gssapi.h ; then
-       exit 0
-fi
-exit 1
 
--- /dev/null
+# FIXME: use other kerberos library checks from main configure.ac
+AC_CHECK_HEADERS([gssapi/gssapi.h gssapi.h kerberosV/gssapi.h],[BUILD_HELPER="kerberos"])
 
--- /dev/null
+# 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_negotiate list containing double entries.
+
+#not specified. Inherit global
+if test "x$enable_auth_negotiate" = "x"; then
+    enable_auth_negotiate=$enable_auth
+fi
+#conflicts with global
+if test "x$enable_auth_negotiate" != "xno" -a "x$enable_auth" = "xno" ; then
+    AC_MSG_ERROR([Negotiate auth requested but auth disabled])
+fi
+#define list of modules to build
+if test "x$enable_auth_negotiate" = "xyes" ; then
+    SQUID_LOOK_FOR_MODULES([$srcdir/helpers/negotiate_auth],[enable_auth_negotiate])
+fi
+#handle the "none" special case
+if test "x$enable_auth_negotiate" = "xnone" ; then
+    enable_auth_negotiate=""
+fi
+
+NEGOTIATE_AUTH_HELPERS=""
+enable_auth_negotiate="`echo $enable_auth_negotiate| sed -e 's/,/ /g;s/  */ /g'`"
+if test "x$enable_auth_negotiate" != "xno" ; then
+    AUTH_MODULES="$AUTH_MODULES negotiate"
+    AC_DEFINE([HAVE_AUTH_MODULE_NEGOTIATE],1,[Negotiate auth module is built])
+    for helper in $enable_auth_negotiate; do
+      dir="$srcdir/helpers/negotiate_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" = "xSSPI" ; then
+        m4_include([helpers/negotiate_auth/SSPI/required.m4])
+
+      elif test "x$helper" = "xkerberos" ; then
+        m4_include([helpers/negotiate_auth/kerberos/required.m4])
+
+      elif test "x$helper" = "xwrapper" ; then
+        m4_include([helpers/negotiate_auth/wrapper/required.m4])
+
+      # 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/negotiate_auth/$helper"; then
+        if test "$BUILD_HELPER" != "$helper"; then
+          AC_MSG_NOTICE([Negotiate auth helper $helper ... found but cannot be built])
+        else
+          NEGOTIATE_AUTH_HELPERS="$NEGOTIATE_AUTH_HELPERS $BUILD_HELPER"
+        fi
+      else
+        AC_MSG_ERROR([Negotiate auth helper $helper ... not found])
+      fi
+    done
+fi
+
+AC_MSG_NOTICE([Negotiate auth helpers to be built: $NEGOTIATE_AUTH_HELPERS])
+AM_CONDITIONAL(ENABLE_AUTH_NEGOTIATE, test "x$enable_auth_negotiate" != "xno")
+AC_SUBST(NEGOTIATE_AUTH_HELPERS)
 
 include $(top_srcdir)/src/Common.am
 
-EXTRA_DIST = config.test
+EXTRA_DIST = required.m4
 
 libexec_PROGRAMS = negotiate_wrapper_auth
 
 
+++ /dev/null
-#!/bin/sh
-exit 0
 
--- /dev/null
+BUILD_HELPER="wrapper"
 
 DIST_SUBDIRS   = fake smb_lm SSPI
 SUBDIRS                = $(NTLM_AUTH_HELPERS)
+EXTRA_DIST     = modules.m4
 
        -ladvapi32 \
        $(XTRA_LIBS)
 
-EXTRA_DIST = ntlm_sspi_auth.8 config.test
+EXTRA_DIST = ntlm_sspi_auth.8 required.m4
 
+++ /dev/null
-#!/bin/sh
-#
-# Only build this helper on Windows
-#
-if test "$1" = "mingw"; then
-        exit 0
-fi
-if [ -f /usr/include/w32api/windows.h ]; then
-       exit 0
-fi
-if [ -f /usr/include/windows.h ]; then
-       exit 0
-fi
-exit 1
 
--- /dev/null
+#
+# Only build this helper on Windows
+#
+AC_CHECK_HEADERS([w32api/windows.h windows.h],[BUILD_HELPER="SSPI"])
 
 ## ntlm_fake_auth.pl: ntlm_fake_auth.pl.in
 ##     $(subst_perlshell)
 
-EXTRA_DIST = config.test \
+EXTRA_DIST = required.m4 \
        ntlm_fake_auth.pl.in
 
+++ /dev/null
-#!/bin/sh
-exit 0
 
--- /dev/null
+BUILD_HELPER="fake"
 
--- /dev/null
+# 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_ntlm list containing double entries.
+
+#not specified. Inherit global
+if test "x$enable_auth_ntlm" = "x"; then
+    enable_auth_ntlm=$enable_auth
+fi
+#conflicts with global
+if test "x$enable_auth_ntlm" != "xno" -a "x$enable_auth" = "xno" ; then
+    AC_MSG_ERROR([NTLM auth requested but auth disabled])
+fi
+#define list of modules to build
+if test "x$enable_auth_ntlm" = "xyes" ; then
+    SQUID_LOOK_FOR_MODULES([$srcdir/helpers/ntlm_auth],[enable_auth_ntlm])
+fi
+#handle the "none" special case
+if test "x$enable_auth_ntlm" = "xnone" ; then
+    enable_auth_ntlm=""
+fi
+
+NTLM_AUTH_HELPERS=""
+#enable_auth_ntlm contains either "no" or the list of modules to be built
+enable_auth_ntlm="`echo $enable_auth_ntlm| sed -e 's/,/ /g;s/  */ /g'`"
+if test "x$enable_auth_ntlm" != "xno" ; then
+    AUTH_MODULES="$AUTH_MODULES ntlm"
+    AC_DEFINE([HAVE_AUTH_MODULE_NTLM],1,[NTLM auth module is built])
+    for helper in $enable_auth_ntlm; do
+      dir="$srcdir/helpers/ntlm_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" = "xfake" ; then
+        m4_include([helpers/ntlm_auth/fake/required.m4])
+
+      elif test "x$helper" = "xSSPI" ; then
+        m4_include([helpers/ntlm_auth/SSPI/required.m4])
+
+      elif test "x$helper" = "xsmb_lm" ; then
+        m4_include([helpers/ntlm_auth/smb_lm/required.m4])
+
+      # 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/ntlm_auth/$helper"; then
+        if test "$BUILD_HELPER" != "$helper"; then
+          AC_MSG_NOTICE([NTLM auth helper $helper ... found but cannot be built])
+        else
+          NTLM_AUTH_HELPERS="$NTLM_AUTH_HELPERS $BUILD_HELPER"
+        fi
+      else
+        AC_MSG_ERROR([NTLM auth helper $helper ... not found])
+      fi
+    done
+fi
+AC_MSG_NOTICE([NTLM auth helpers to be built: $NTLM_AUTH_HELPERS])
+AM_CONDITIONAL(ENABLE_AUTH_NTLM, test "x$enable_auth_ntlm" != "xno")
+AC_SUBST(NTLM_AUTH_HELPERS)
 
 
 INCLUDES += -I$(top_srcdir)/lib
 
-EXTRA_DIST = config.test
+EXTRA_DIST = required.m4
 
+++ /dev/null
-#!/bin/sh
-#
-# Don't build this helper on Windows
-#
-if test "$1" = "mingw"; then
-        exit 1
-fi
-if [ -f /usr/include/w32api/windows.h ]; then
-       exit 1
-fi
-if [ -f /usr/include/windows.h ]; then
-       exit 1
-fi
-exit 0
 
--- /dev/null
+#
+# DONT build this helper on Windows
+#
+# XXX: do we really need the mingw check?
+if test "$squid_host_os" != "mingw"; then
+  BUILD_HELPER="smb_lm"
+  AC_CHECK_HEADERS([w32api/windows.h windows.h],[BUILD_HELPER=""])
+fi
 
 
 libexec_SCRIPTS = url_fake_rewrite.sh
 
-EXTRA_DIST = url_fake_rewrite.sh config.test
+EXTRA_DIST = url_fake_rewrite.sh required.m4
 
+++ /dev/null
-#!/bin/sh
-exit 0
 
--- /dev/null
+BUILD_HELPER="fake"
 
--- /dev/null
+# 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_url_rewrite_helpers list containing double entries.
+
+#define list of modules to build
+if test "x${enable_url_rewrite_helpers:=yes}" = "xyes" ; then
+    SQUID_LOOK_FOR_MODULES([$srcdir/helpers/url_rewrite],[enable_url_rewrite_helpers])
+fi
+
+enable_url_rewrite_helpers="`echo $enable_url_rewrite_helpers| sed -e 's/,/ /g;s/  */ /g'`"
+AC_MSG_NOTICE([URL rewrite helper candidates: $enable_url_rewrite_helpers])
+URL_REWRITE_HELPERS=""
+if test "x$enable_url_rewrite_helpers" != "xno" ; then
+  for helper in $enable_url_rewrite_helpers; do
+    dir="$srcdir/helpers/url_rewrite/$helper"
+
+    # modules converted to autoconf macros already
+    # NP: we only need this list because m4_include() does not accept variables
+    if test "x$helper" = "xfake" ; then
+      m4_include([helpers/url_rewrite/fake/required.m4])
+
+    # 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/url_rewrite/$helper"; then
+      if test "$BUILD_HELPER" != "$helper"; then
+        AC_MSG_NOTICE([URL rewrite helper $helper ... found but cannot be built])
+      else
+        URL_REWRITE_HELPERS="$URL_REWRITE_HELPERS $BUILD_HELPER"
+      fi
+    else
+      AC_MSG_ERROR([URL rewrite helper $helper ... not found])
+    fi
+  done
+fi
+AC_MSG_NOTICE([URL rewrite helpers to be built: $URL_REWRITE_HELPERS])
+AC_SUBST(URL_REWRITE_HELPERS)