dnl
dnl  Configuration input file for Squid
dnl
dnl  $Id: configure.in,v 1.430.2.25 2010/03/14 21:40:46 hno Exp $
dnl
dnl
dnl
AC_INIT(Squid Web Proxy, 2.7.STABLE9-20110824, http://bugs.squid-cache.org/, squid)
AC_PREREQ(2.52)
AM_CONFIG_HEADER(include/autoconf.h)
AC_CONFIG_AUX_DIR(cfgaux)
AM_INIT_AUTOMAKE
AC_REVISION($Revision: 1.430.2.25 $)dnl
AC_PREFIX_DEFAULT(/usr/local/squid)
AM_MAINTAINER_MODE

PRESET_CFLAGS="$CFLAGS"
PRESET_LDFLAGS="$LDFLAGS"

dnl Set default LDFLAGS
if test -z "$LDFLAGS"; then
	LDFLAGS="-g"
fi

dnl Check for GNU cc
AC_PROG_CC
AM_PROG_CC_C_O
AC_CANONICAL_HOST


CRYPTLIB=''
REGEXLIB=''	# -lregex
LIBREGEX=''	# libregex.a

dnl Check for pkg-config
AC_PATH_PROG(PKGCONFIG, pkg-config, false)

dnl find out the exe extension for this platform. If it's not empty, use it for CGI's as well.
AC_EXEEXT
AC_OBJEXT

if test -z "$EXEEXT"; then
	CGIEXT=".cgi"
else
	# automake automatically adds .exe when installing binaries
	CGIEXT=""
fi
AC_SUBST(CGIEXT)

dnl this should be expanded to a list of platform sensible support requirements.
dnl (adding an option like --enable-cygwin-support doesn't make sense :]) - R Collins 2001
case "$host_os" in
mingw|mingw32|cygwin|cygwin32)
	AM_CONDITIONAL(ENABLE_WIN32SPECIFIC, true)
	;;
*)
	AM_CONDITIONAL(ENABLE_WIN32SPECIFIC, false)
	;;
esac

case "$host_os" in
mingw|mingw32)
        AM_CONDITIONAL(ENABLE_MINGW32SPECIFIC, true)
	AC_PATH_PROG(WIN32_PSAPI, psapi.dll, none)
	CFLAGS="$CFLAGS -mthreads"
	if test "$ac_cv_path_WIN32_PSAPI" = "none"; then
		echo "PSAPI.DLL is recommended to run Squid on Windows Platform"
		echo "Please see PSAPI.DLL section on doc/release-notes/release-2.6.html."
	else
		AC_DEFINE(HAVE_WIN32_PSAPI,1,[Define if you have PSAPI.DLL on Windows systems])
		LIBS="$LIBS -lpsapi"
	fi
	;;
*)
	AM_CONDITIONAL(ENABLE_MINGW32SPECIFIC, false)
	;;
esac

if test -z "$CACHE_HTTP_PORT"; then
	CACHE_HTTP_PORT="3128"
fi
if test -z "$CACHE_ICP_PORT"; then
	CACHE_ICP_PORT="3130"
fi

dnl Substitutions
AC_DEFINE_UNQUOTED(CACHE_HTTP_PORT, $CACHE_HTTP_PORT, [What default TCP port to use for HTTP listening?])
AC_SUBST(CACHE_HTTP_PORT)
AC_DEFINE_UNQUOTED(CACHE_ICP_PORT, $CACHE_ICP_PORT, [What default UDP port to use for ICP listening?])
AC_SUBST(CACHE_ICP_PORT)

AC_DEFINE_UNQUOTED(CONFIG_HOST_TYPE, "$host", [Host type from configure])

AC_DEFINE_UNQUOTED(SQUID_CONFIGURE_OPTIONS, "$ac_configure_args", [configure command line used to configure Squid])

dnl Gerben Wierda <Gerben_Wierda@RnA.nl>
case "$host" in
    mab-next-nextstep3)
	CC="$CC -arch m68k -arch i486 -arch hppa -arch sparc"
	;;
esac

dnl Set Default CFLAGS
if test -z "$PRESET_CFLAGS"; then
    if test "$GCC" = "yes"; then
	case "$host" in
	*-sun-sunos*)
	    # sunos has too many warnings for this to be useful
	    # motorola too
	    ;;
	*m88k*-openbsd*)
	    ;;
	*m88k*)
	    # Motorola cc/ld does not like -02 but is ok on -O
	    CFLAGS=`echo $CFLAGS | sed -e 's/-O[0-9]/-O/'`
	    ;;
	*)
	    CFLAGS="-Wall $CFLAGS"
	    ;;
	esac
    else
	case "$host" in
	*mips-sgi-irix6.*)
	    # suggested by Rafael Seidl <rafaels@cthulhu.engr.sgi.com>
	    CFLAGS="-O3 -OPT:Olimit=0:space=OFF \
		-woff 1009,1014,1110,1116,1185,1188,1204,1230,1233 \
		-Wl,-woff,85,-woff,84,-woff,134 \
		-nostdinc -I/usr/include -D_BSD_SIGNALS $CFLAGS"
	    ;;
	alpha-dec-osf4.*)
	    # Mogul says DEC compilers take both -g and -O2
	    CFLAGS=`echo $CFLAGS | sed -e 's/-g/-g3/'`
	    CFLAGS="-O2 $CFLAGS"
	    ;;
	*)
	    ;;
	esac
    fi
fi

dnl Set LDFLAGS
if test -z "$PRESET_LDFLAGS"; then
    if test "$GCC" = "yes"; then
	case "$host" in
	*mips-sgi-irix6.*)
	    # Silence Linker warnings 84, 85 and 134
	    LDFLAGS="-Wl,-woff,85 -Wl,-woff,84 -Wl,-woff,134 $LDFLAGS"
	    ;;
	*)
	    # nothing
	    ;;
	esac
    else
	case "$host" in
	*)
	    # nothing
	    ;;
	esac
    fi
fi

dnl Enable optional modules
AC_ARG_ENABLE(dlmalloc,
[  --enable-dlmalloc[=LIB] Compile & use the malloc package by Doug Lea],
[
 case "$enableval" in
 'yes')
    use_dlmalloc="yes"
    LIBDLMALLOC="libdlmalloc.a"
    LIB_MALLOC="-L../lib -ldlmalloc"
    echo "dlmalloc enabled"
    ;;
 'no')
    use_dlmalloc="no"
    echo "dlmalloc disabled"
    ;;
 *) use_dlmalloc="yes"
    LIB_MALLOC="$enableval"
    echo "dlmalloc enabled with $LIB_MALLOC"
 esac
])
if test "${use_dlmalloc-unset}" = unset; then
    case "$host" in
	i386-*-solaris2.*)
		echo "Enabling dlmalloc for $host"
		use_dlmalloc="yes"
		LIBDLMALLOC="libdlmalloc.a"
		LIB_MALLOC="-L../lib -ldlmalloc"
		;;
	*-sgi-irix*)
		echo "Enabling dlmalloc for $host"
		use_dlmalloc="yes"
		LIBDLMALLOC="libdlmalloc.a"
		LIB_MALLOC="-L../lib -ldlmalloc"
		;;
    esac
fi
if test "x$ac_cv_enabled_dlmalloc" = "xyes"; then
    # Ok. dlmalloc was enabled before, but state may be changed.
    # we have to test these again
    unset ac_cv_func_mallinfo
    unset ac_cv_func_mallocblksize
    unset ac_cv_func_free
    unset ac_cv_func_realloc
    unset ac_cv_func_memalign
    unset ac_cv_func_valloc
    unset ac_cv_func_pvalloc
    unset ac_cv_func_calloc
    unset ac_cv_func_cfree
    unset ac_cv_func_malloc_trim
    unset ac_cv_func_malloc_usable_size
    unset ac_cv_func_malloc_stats
    unset ac_cv_func_mallinfo
    unset ac_cv_func_mallopt
    unset ac_cv_lib_gnumalloc
    unset ac_cv_header_gnumalloc_h
    unset ac_cv_lib_malloc
    unset ac_cv_enabled_dlmalloc
fi
if test "$use_dlmalloc" = yes; then
    ac_cv_func_mallinfo="yes"
    ac_cv_func_mallocblksize="no"
    ac_cv_func_free="yes"
    ac_cv_func_realloc="yes"
    ac_cv_func_memalign="yes"
    ac_cv_func_valloc="yes"
    ac_cv_func_pvalloc="yes"
    ac_cv_func_calloc="yes"
    ac_cv_func_cfree="yes"
    ac_cv_func_malloc_trim="yes"
    ac_cv_func_malloc_usable_size="yes"
    ac_cv_func_malloc_stats="yes"
    ac_cv_func_mallopt="yes"
    ac_cv_lib_gnumalloc="no"
    ac_cv_header_gnumalloc_h="no"
    ac_cv_lib_malloc="no"
    ac_cv_enabled_dlmalloc="yes"
fi

AC_SUBST(LIBDLMALLOC)
AC_SUBST(LIB_MALLOC)

AC_ARG_ENABLE(gnuregex,
[  --enable-gnuregex       Compile GNUregex.  Unless you have reason to use this
			  option, you should not enable it.  This library file
			  is usually only required on Windows and very old
			  Unix boxes which do not have their own regex library
			  built in.],
[USE_GNUREGEX=$enableval])

dnl This is a developer only option.. developers know how to set defines
dnl
dnl AC_ARG_ENABLE(xmalloc-debug,
dnl [  --enable-xmalloc-debug  Do some simple malloc debugging],
dnl [ if test "$enableval" = "yes" ; then
dnl     echo "Malloc debugging enabled"
dnl     AC_DEFINE(XMALLOC_DEBUG, 1, [Define to do simple malloc debugging])
dnl   fi
dnl ])

dnl This is a developer only option.. developers know how to set defines
dnl
dnl AC_ARG_ENABLE(xmalloc-debug-trace,
dnl [  --enable-xmalloc-debug-trace
dnl                           Detailed trace of memory allocations],
dnl [ if test "$enableval" = "yes" ; then
dnl     echo "Malloc debug trace enabled"
dnl     AC_DEFINE(XMALLOC_TRACE, 1, [Define to have a detailed trace of memory allocations])
dnl     AC_DEFINE(XMALLOC_DEBUG, 1, [Define to do simple malloc debugging])
dnl   fi
dnl ])

AC_ARG_WITH(valgrind-debug,
[  --with-valgrind-debug   Include debug instrumentation for use with valgrind],
[ case $withval in
  yes)
	valgrind=1
	;;
  no)
	valgrind=
	;;
  *)
	CPPFLAGS="$CPPFLAGS -I${enableval}/include"
	valgrind=1
	;;
  esac
  if test $valgrind; then
	AC_DEFINE(WITH_VALGRIND, 1, [Valgrind memory debugger support])
	echo "Valgrind debug support enabled"
  fi
])

AC_ARG_ENABLE(mempool-debug,
[  --enable-mempool-debug  Include MemPool debug verifications])
if test "$enable_mempool_debug" = yes; then
	AC_DEFINE(DEBUG_MEMPOOL, 1, [MemPool debug verifications])
	echo "Mempool debug checks enabled"
fi

AC_ARG_ENABLE(xmalloc-statistics,
[  --enable-xmalloc-statistics
			  Show malloc statistics in status page],
[ if test "$enableval" = "yes" ; then
    echo "Malloc statistics enabled"
    AC_DEFINE(XMALLOC_STATISTICS, 1, [Define to have malloc statistics])
  fi
])

USE_CARP=1
AC_ARG_ENABLE(carp,
[  --disable-carp           Disable CARP support],
[ if test "$enableval" = "no" ; then
    echo "CARP disabled"
    USE_CARP=0
  fi
])      
if test $USE_CARP = 1; then
    AC_DEFINE(USE_CARP, 1, [Cache Array Routing Protocol])
fi

AC_ARG_ENABLE(async-io,
[  --enable-async-io[=N_THREADS]
			  Shorthand for
			  --with-aufs-threads=N_THREADS
			  --with-pthreads
			  --enable-storeio=ufs,aufs],
[ case $enableval in
  yes)
	with_pthreads="yes"
	STORE_MODULES="ufs aufs"
    ;;
  no)
    ;;
  *)
	aufs_io_threads=$enableval
	with_pthreads="yes"
	STORE_MODULES="ufs aufs"
    ;;
  esac
])

AC_ARG_WITH(aufs-threads,
[  --with-aufs-threads=N_THREADS
			  Tune the number of worker threads for the aufs object
			  store.],
[ case $withval in
  [[0-9]]*)
    aufs_io_threads=$withval
    ;;
  *)
    echo "ERROR: Invalid --with-aufs-threads argument"
    exit 1
    ;;
  esac
])
if test "$aufs_io_threads"; then
    echo "With $aufs_io_threads aufs threads"
    AC_DEFINE_UNQUOTED(AUFS_IO_THREADS, $aufs_io_threads, [Defines how many threads aufs uses for I/O])
fi

AC_ARG_WITH(pthreads,
[  --with-pthreads         Use POSIX Threads])
if test "$with_pthreads" = "yes"; then
    echo "With pthreads"
fi

AC_ARG_WITH(aio,
[  --with-aio              Use POSIX AIO])
if test "$with_aio" = "yes"; then
    echo "With aio"
fi

AC_ARG_WITH(dl,
[  --with-dl               Use dynamic linking])
if test "$with_dl" = "yes"; then
    echo "With dl"
fi

AC_ARG_ENABLE(storeio,
[  --enable-storeio="list of modules"
			  Build support for the list of store I/O modules.
			  The default is only to build the "ufs" module.
			  See src/fs for a list of available modules, or
			  Programmers Guide section <not yet written>
			  for details on how to build your custom store module],
[ case $enableval in
  yes)
	for module in $srcdir/src/fs/*; do
	    name="`basename $module`"
	    case $name in
	    CVS) # Ignore
		;;
	    *)
		if test -d $module; then
		    STORE_MODULES="$STORE_MODULES $name"
		fi
		;;
	    esac
	done
	;;
  no)
	;;
  *)	STORE_MODULES="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
	;;
  esac
],
[ if test -z "$STORE_MODULES"; then
    STORE_MODULES="ufs"
  fi
])
echo "Store modules built: $STORE_MODULES"
NEED_DISKD=0
USE_AIOPS_WIN32=0
NEED_COSSDUMP=0
STORE_OBJS="fs/lib`echo $STORE_MODULES|sed -e 's% %.a fs/lib%g'`.a"
AC_SUBST(STORE_OBJS)
STORE_LIBS="`echo $STORE_OBJS|sed -e 's%fs/%%g'`"
AC_SUBST(STORE_LIBS)
dnl some store implementations need additional stuff built like diskd_daemon
STORE_MODULE_SUBDIRS=
for fs in $STORE_MODULES none; do
    case "$fs" in
    diskd)
	NEED_DISKD=1
	;;
    aufs)
	if test -z "$with_pthreads"; then
            case "$host_os" in
            mingw|mingw32)
        	USE_AIOPS_WIN32=1
	        echo "aufs store used, Windows threads support automatically enabled"
                ;;
            *)
	        echo "aufs store used, pthreads support automatically enabled"
	        with_pthreads=yes
                ;;
            esac
	fi
	;;
    coss)
	NEED_COSSDUMP=1
	if test -z "$with_aio"; then
	    echo "coss store used, aio support automatically enabled"
	    with_aio=yes
	fi
	;;
    esac
done
AC_SUBST(STORE_MODULES)
AM_CONDITIONAL([NEED_DISKD], [test "$NEED_DISKD" = 1])
AM_CONDITIONAL([USE_AIOPS_WIN32], [test "$USE_AIOPS_WIN32" = 1])
AM_CONDITIONAL([NEED_COSSDUMP], [test "$NEED_COSSDUMP" = 1])

dnl --enable-heap-replacement compatibility option
AC_ARG_ENABLE(heap-replacement,
[  --enable-heap-replacement
			  Backwards compatibility option. Please use the
			  new --enable-removal-policies directive instead.],
[ if test "$enableval" = "yes" ; then
    echo "--enable-heap-replacement is obsolete. please use the new"
    echo "--enable-removal-policies directive instead"
    sleep 5
    REPL_POLICIES="heap"
  fi
])

AC_ARG_ENABLE(removal-policies,
[  --enable-removal-policies="list of policies"
			  Build support for the list of removal policies.
			  The default is only to build the "lru" module.
			  See src/repl for a list of available modules, or
			  Programmers Guide section 9.9 for details on how
			  to build your custom policy],
[ case $enableval in
  yes)
	for module in $srcdir/src/repl/*; do
	    name="`basename $module`"
	    case $name in
	    CVS) # Ignore
		;;
	    *)
		if test -d $module; then
		    REPL_POLICIES="$REPL_POLICIES $name"
		fi
		;;
	    esac
	done
	;;
  no)
	;;
  *)	REPL_POLICIES="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
	;;
  esac
],
[ if test -z "$REPL_POLICIES"; then
    REPL_POLICIES="lru"
  fi
])
echo "Removal policies built: $REPL_POLICIES"
AC_SUBST(REPL_POLICIES)
REPL_OBJS="repl/lib`echo $REPL_POLICIES|sed -e 's% %.a repl/lib%g'`.a"
AC_SUBST(REPL_OBJS)
REPL_LIBS="`echo $REPL_OBJS|sed -e 's%repl/%%g'`"
AC_SUBST(REPL_LIBS)

AM_CONDITIONAL(ENABLE_PINGER, false)
AC_ARG_ENABLE(icmp,
[  --enable-icmp           Enable ICMP pinging],
[ if test "$enableval" = "yes" ; then
    echo "ICMP enabled"
    AC_DEFINE(USE_ICMP, 1, [If you want to use Squid's ICMP features (highly recommended!) then
	define this.  When USE_ICMP is defined, Squid will send ICMP pings
	to origin server sites.  This information is used in numerous ways:
	- Sent in ICP replies so neighbor caches know how close
	  you are to the source.
	- For finding the closest instance of a URN.
	- With the 'test_reachability' option.  Squid will return
	  ICP_OP_MISS_NOFETCH for sites which it cannot ping.])
    AM_CONDITIONAL(ENABLE_PINGER, true)
  fi
])

AM_CONDITIONAL(USE_DELAY_POOLS, false)
AC_ARG_ENABLE(delay-pools,
[  --enable-delay-pools    Enable delay pools to limit bandwidth usage],
[ if test "$enableval" = "yes" ; then
    echo "Delay pools enabled"
    AC_DEFINE(DELAY_POOLS, 1, [Traffic management via "delay pools".])
    AM_CONDITIONAL(USE_DELAY_POOLS, true)
  fi
])

dnl This is a developer only option. Developers know how to set defines
dnl
dnl AC_ARG_ENABLE(mem-gen-trace,
dnl [  --enable-mem-gen-trace  Do trace of memory stuff],
dnl [ if test "$enableval" = "yes" ; then
dnl     echo "Memory trace (to file) enabled"
dnl     AC_DEFINE(MEM_GEN_TRACE, 1, [Define for log file trace of mem alloc/free])
dnl   fi    
dnl ])     

AC_ARG_ENABLE(useragent-log,
[  --enable-useragent-log  Enable logging of User-Agent header],
[ if test "$enableval" = "yes" ; then
    echo "User-Agent logging enabled"
    AC_DEFINE(USE_USERAGENT_LOG, 1, [If you want to log User-Agent request header values, define this.
	By default, they are written to useragent.log in the Squid log directory.])
  fi
])

AC_ARG_ENABLE(referer-log,
[  --enable-referer-log    Enable logging of Referer header],
[ if test "$enableval" = "yes" ; then
    echo "Referer logging enabled"
    AC_DEFINE(USE_REFERER_LOG, 1, [If you want to log Referer request header values, define this.
	By default, they are written to referer.log in the Squid log directory.])
  fi
])

USE_WCCP=1
AC_ARG_ENABLE(wccp,  
[  --disable-wccp          Disable Web Cache Coordination V1 Protocol],
[ if test "$enableval" = "no" ; then
    echo "Web Cache Coordination V1 Protocol disabled"
    USE_WCCP=0
  fi
])      
if test $USE_WCCP = 1; then
    AC_DEFINE(USE_WCCP, 1, [Define to enable WCCP])
fi

USE_WCCPv2=1
AC_ARG_ENABLE(wccpv2,
[  --disable-wccpv2        Disable Web Cache Coordination V2 Protocol],
[ if test "$enableval" = "no" ; then
    echo "Web Cache Coordination V2 Protocol disabled"
    USE_WCCPv2=0
  fi
])
if test $USE_WCCPv2 = 1; then
    AC_DEFINE(USE_WCCPv2, 1, [Define to enable WCCP V2])
fi


AC_ARG_ENABLE(kill-parent-hack,
[  --enable-kill-parent-hack
			  Kill parent on shutdown],
[ if test "$enableval" = "yes" ; then
    echo "Kill parent on shutdown"
    AC_DEFINE(KILL_PARENT_OPT, 1, [A dangerous feature which causes Squid to kill its parent process
	(presumably the RunCache script) upon receipt of SIGTERM or SIGINT.  Use with caution.])
  fi
])

AC_ARG_ENABLE(forward-log,
[  --enable-forward-log    Enable experimental forward_log directive],
[ if test "$enableval" = "yes" ; then
    echo "forward_log enabled"
    AC_DEFINE(WIP_FWD_LOG, 1, [Define to enable experimental forward_log directive])
  fi
])
 
AC_ARG_ENABLE(multicast-miss,
[  --enable-multicast-miss Enable experimental multicast notification of cachemisses],
[ if test "$enableval" = "yes" ; then
    echo "multicast of cache miss URLs enabled"
    AC_DEFINE(MULTICAST_MISS_STREAM, 1, [Define to enable experimental multicast of cache miss URLs])
  fi
])
 
AM_CONDITIONAL(USE_SNMP, false)
AC_ARG_ENABLE(snmp,
[  --enable-snmp           Enable SNMP monitoring],
[ if test "$enableval" = "yes" ; then
    echo "SNMP monitoring enabled"
    AC_DEFINE(SQUID_SNMP, 1, [Define to enable SNMP monitoring of Squid])
    SNMPLIB='../snmplib/libsnmp.a'
    AM_CONDITIONAL(USE_SNMP, true)
    SNMP_MAKEFILE=./snmplib/Makefile
    makesnmplib=snmplib
  fi
])
AC_SUBST(SNMPLIB)
AC_SUBST(makesnmplib)

AC_ARG_ENABLE(cachemgr-hostname,
[  --enable-cachemgr-hostname[=hostname]
			  Make cachemgr.cgi default to this host],
[  case $enableval in
   yes)
       AC_DEFINE(CACHEMGR_HOSTNAME, [getfullhostname()], [If you are upset that the cachemgr.cgi form comes up with the hostname
	field blank, then define this to getfullhostname()])
       echo "Cachemgr default hostname == host where cachemgr runs"
       ;;
   no)
       : # Nothing to do..
       ;;
   *)
       AC_DEFINE_UNQUOTED(CACHEMGR_HOSTNAME, "${enableval}", [If you are upset that the cachemgr.cgi form comes up with the hostname
	field blank, then define this to getfullhostname()])
       echo "Cachemgr default hostname set to ${enableval}"
       ;;
   esac
])

AC_ARG_ENABLE(arp-acl,
[  --enable-arp-acl        Enable use of ARP ACL lists (ether address)],
[  if test "$enableval" = "yes" ; then
     echo "ARP ACL lists enabled (ether address)"
     case "$host" in
	*-linux-*)
	    ;;
	*-solaris*)
	    ;;
	*-freebsd*)
	    ;;
	*-netbsd*)
	    ;;
	*-openbsd*)
	    ;;
	*-cygwin*)
	LIBS="$LIBS -liphlpapi"
	    ;;
	*-mingw*)
	LIBS="$LIBS -liphlpapi"
	    ;;
	*)
	    echo "WARNING: ARP ACL support probably won't work on $host."
	    sleep 10
	    ;;
     esac
     AC_DEFINE(USE_ARP_ACL, 1, [Define this to include code which lets you specify access control
	elements based on ethernet hardware addresses.  This code uses
	functions found in 4.4 BSD derviations (e.g. FreeBSD, ?).])
   fi
])

AM_CONDITIONAL(ENABLE_HTCP, false)
AC_ARG_ENABLE(htcp,
[  --enable-htcp           Enable HTCP protocol],
[ if test "$enableval" = "yes" ; then
    echo "HTCP enabled"
    AC_DEFINE(USE_HTCP, 1, [Define this to include code for the Hypertext Cache Protocol (HTCP)])
    AM_CONDITIONAL(ENABLE_HTCP, true)
  fi
])

dnl SSL is not enabled by default.
AM_CONDITIONAL(ENABLE_SSL, false)

SSLLIB=''
SSLFLAGS=''

dnl Default is to use OpenSSL when available
AC_ARG_ENABLE(ssl,
[  --enable-ssl            Enable ssl gatewaying support using OpenSSL],
[ if test "$enableval" != "no"; then
    echo "SSL gatewaying using OpenSSL enabled"
    AC_DEFINE(USE_SSL, 1, [Define this to include code for SSL encryption.])
    AM_CONDITIONAL(ENABLE_SSL, true)
    case "$host_os" in
    mingw|mingw32)
	SSLLIB='-lssleay32 -leay32 -lgdi32'
	;;
    *)
	SSLLIB='-lssl -lcrypto'
	;;
    esac
    USE_OPENSSL=1
  fi
])

USE_SQUID_MD5=0
AC_ARG_WITH(system-md5,
[  --without-system-md5    Disable the use of any system provided MD5
			  Implementation forcing fallback on the internal
			  implementation shipped with Squid],
[
  case "$enableval" in
  no)
	AC_DEFINE(USE_SQUID_MD5, 1, [Define this to force use of the internal MD5 implementation])
	;;
  esac
])

dnl User may specify OpenSSL is needed from a non-standard location
AC_ARG_WITH(openssl,
[  --with-openssl[=prefix]
			  Compile with the OpenSSL libraries. The path to
			  the OpenSSL development libraries and headers
			  installation can be specified if outside of the
			  system standard directories],
[ 
  case "$with_openssl" in
  yes)
    USE_OPENSSL=1
    ;;
  no)
    USE_OPENSSL=
    ;;
  *)
    PKG_CONFIG_PATH="$with_openssl/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
    export PKG_CONFIG_PATH
    SSLLIB="-L$with_openssl/lib -lssl -lcrypto"
    SSLFLAGS="-I$with_openssl/include"
    USE_OPENSSL=1
  esac
])

if test -n "$USE_OPENSSL"; then
  echo "Using OpenSSL MD5 implementation"
  AC_DEFINE(USE_OPENSSL, 1, [Define this to make use of the OpenSSL libraries for
	MD5 calculation rather than Squid's own MD5 implementation
	or if building with SSL encryption (USE_SSL)])
  if test -z "$SSLLIB"; then
    SSLLIB="-lcrypto" # for MD5 routines
  fi
  if $PKGCONFIG --exists openssl; then
    SSLLIB="`$PKGCONFIG --libs openssl`"
    SSLFLAGS="`$PKGCONFIG --cflags openssl`"
  fi
  CPPFLAGS="${SSLFLAGS} $CPPFLAGS"
fi
AC_SUBST(SSLLIB)


AC_ARG_ENABLE(forw-via-db,
[  --enable-forw-via-db    Enable Forw/Via database],
[ if test "$enableval" = "yes" ; then
    echo "FORW-VIA enabled"
    AC_DEFINE(FORW_VIA_DB, 1, [Enable Forw/Via database])
  fi
])

AC_ARG_ENABLE(cache-digests,
[  --enable-cache-digests  Use Cache Digests
			  see http://www.squid-cache.org/FAQ/FAQ-16.html],
[ if test "$enableval" = "yes" ; then
    echo "USE_CACHE_DIGESTS enabled"
    AC_DEFINE(USE_CACHE_DIGESTS, 1, [Use Cache Digests for locating objects in neighbor caches.  This
	code is still semi-experimental.])
  fi
])

dnl Select Default Error language
AC_ARG_ENABLE(default-err-language,
[  --enable-default-err-language=lang
			  Select default language for Error pages (see
			  errors directory) ],
[
    if test -d $srcdir/errors/$enableval; then
	ERR_DEFAULT_LANGUAGE=$enableval
    else
	echo "ERROR! Unknown language $enableval, see errors/ directory"
	exit 1
    fi
],[ERR_DEFAULT_LANGUAGE="English"])
AC_SUBST(ERR_DEFAULT_LANGUAGE)

dnl Select languages to be installed
AC_ARG_ENABLE(err-languages,
[  --enable-err-languages=\"lang1 lang2..\"
			  Select languages to be installed. (All will be
			  installed by default) ],
[
    for l in $enableval; do
	if test -d $srcdir/errors/$l; then :; else
	    echo "ERROR! Unknown language $$l, see errors/"
	    exit 1
	fi
    done
    ERR_LANGUAGES=$enableval
],[
    ERR_LANGUAGES=
    for l in $srcdir/errors/*; do
	if test -f $l/ERR_ACCESS_DENIED; then
	    ERR_LANGUAGES="$ERR_LANGUAGES `basename $l`"
	fi
    done
])
AC_SUBST(ERR_LANGUAGES)

dnl Size of COSS memory buffer
AC_ARG_WITH(coss-membuf-size,
[  --with-coss-membuf-size COSS membuf size (default 1048576 bytes) ],
[  if test "$with_coss_membuf_size"; then
      echo "Setting COSS membuf size to $with_coss_membuf_size bytes"
      AC_DEFINE_UNQUOTED(COSS_MEMBUF_SZ, $with_coss_membuf_size, [Define if you want to set the COSS membuf size])
   fi
])

dnl COSS I/O method
AC_ARG_ENABLE(coss-aio-ops,
[  --enable-coss-aio-ops   Enable COSS I/O with Posix AIO (default is aufs I/O) ])
if test "$enable_coss_aio_ops" = "yes"; then
      echo "Using Posix AIO method for COSS disk I/O"
      AC_DEFINE(USE_AUFSOPS, 0, [  Define this if you would like to use the aufs I/O method for
	   disk I/O instead of the POSIX AIO method.])
else
      AC_DEFINE(USE_AUFSOPS, 1, [  Define this if you would like to use the aufs I/O method for
	   disk I/O instead of the POSIX AIO method.])
fi

dnl Enable select()
AC_ARG_ENABLE(select,
[  --enable-select         Force the use of select support.
			  Normally configure automatically selects a better
			  alternative if available.
  --disable-select        Disable select support, causing configure to fail
			  if a better alternative is not available],

[
  case "$enableval" in
  yes)
    echo "Forcing select() to be enabled"
    SELECT_TYPE="select"
    ac_cv_func_select='yes'
    ;;
  no)
    echo "Forcing select() to be disabled"
    ac_cv_func_select='no'
    ;;
  esac
])

dnl Enable select()
AC_ARG_ENABLE(select-simple,
[  --enable-select-simple  Force the use of select support (POSIX).
			  Useful if your system only supports the bare minium
			  POSIX select requirements without fds_bits.],
[
  case "$enableval" in
  yes)
    echo "Forcing select() to be enabled in simple POSIX mode"
    SELECT_TYPE="select_simple"
    ac_cv_func_select='yes'
    ;;
  no)
    echo "Forcing select() to be disabled"
    ac_cv_func_select='no'
    ;;
  esac
])

dnl Enable poll()
AC_ARG_ENABLE(poll,
[  --enable-poll           Force the use of poll even if automatic checks
			  indicate poll may be broken on your plaform.
  --disable-poll          Disable the use of poll.],
[ 
  case "$enableval" in
  yes)
    echo "Forcing poll() to be enabled"
    SELECT_TYPE="poll"
    ac_cv_func_poll='yes'
    ;;
  no)
    echo "Forcing poll() to be disabled"
    ac_cv_func_poll='no'
    ;;
  esac
])

dnl Enable epoll()
AC_ARG_ENABLE(epoll,
[  --enable-epoll          Force the use of epoll even if automatic checks
			  indicate epoll may not be supported.
  --disable-epoll         Disable the use of epoll.],
[ 
  case "$enableval" in
  yes)
    echo "Forcing epoll() to be enabled"
    SELECT_TYPE="epoll"
    force_epoll='yes'
    ;;
  no)
    echo "Forcing epoll() to be disabled"
    ac_cv_func_epoll_ctl='no'
    ;;
  esac
])

dnl Enable kqueue
AC_ARG_ENABLE(kqueue,
[  --enable-kqueue         Force the use of kqueue even if automatic checks
			  indicate kqueue may not be supported.
  --disable-kqueue        Disable kqueue support. ],

[
  case "$enableval" in
  yes)
    echo "Forcing kqueue to be enabled"
    SELECT_TYPE="kqueue"
    ac_cv_func_kqueue='yes'
    ;;
  no)
    echo "Forcing kqueue to be disabled"
    ac_cv_func_kqueue='no'
    ;;
  esac
])

dnl Enable devpoll
AC_ARG_ENABLE(devpoll,
[  --enable-devpoll       Use Solaris /dev/poll instead of poll],
[
  case "$enableval" in
  yes)
    echo "Forcing devpoll to be enabled"
    SELECT_TYPE="devpoll"
    ;;
  no)
    echo "Forcing devpoll to be disabled"
    ;;
  esac
])


dnl Disable HTTP violations
HTTP_VIOLATIONS=1
AC_ARG_ENABLE(http-violations,
[  --disable-http-violations
			  This allows you to remove code which is known to
			  violate the HTTP protocol specification.],
[ if test "$enableval" = "no" ; then
    echo "Disabling HTTP Violations"
    HTTP_VIOLATIONS=0
  fi
])
if test $HTTP_VIOLATIONS = 1; then
    AC_DEFINE(HTTP_VIOLATIONS, 1, [By default (for now anyway) Squid includes options which allows the cache administrator to violate the HTTP protocol specification in terms of cache behaviour.  Setting this to '0' will disable such code.])
fi

dnl Enable IP-Filter Transparent Proxy
AC_ARG_ENABLE(ipf-transparent,
[  --enable-ipf-transparent
			  Enable Transparent Proxy support for systems
			  using IP-Filter network address redirection.],
[ if test "$enableval" = "yes" ; then
	echo "IP-Filter Transparent Proxy enabled"
	AC_DEFINE(IPF_TRANSPARENT, 1, [Enable support for Transparent Proxy on systems using IP-Filter
	address redirection. This provides "masquerading" support for non
	Linux system.])
	IPF_TRANSPARENT="yes"
	dnl On Solaris Ipfilter includes expect that SOLARIS2 is defined with the
	dnl Solaris minor version (8, 9, 10, ...)
	case "$host" in
	*-solaris*)
	    solrev=`uname -r | sh -c 'IFS=. read j n x; echo $n'`
	    CFLAGS="-DSOLARIS2=$solrev $CFLAGS" 
	    ;;
	*)
	    ;;
	esac

  fi
])

dnl Enable PF Transparent Proxy
AC_ARG_ENABLE(pf-transparent,
[  --enable-pf-transparent
			  Enable Transparent Proxy support for systems
			  using PF network address redirection.],
[ if test "$enableval" = "yes" ; then
	echo "PF Transparent Proxy enabled"
	AC_DEFINE(PF_TRANSPARENT, 1, [Enable support for Transparent Proxy on systems using PF address
	redirection. This provides "masquerading" support for OpenBSD.])
	PF_TRANSPARENT="yes"
  fi
])

dnl Enable Linux Netfilter Transparent Proxy
AC_ARG_ENABLE(linux-netfilter,
[  --enable-linux-netfilter
			  Enable Transparent Proxy support for Linux 2.4 and later],
[ if test "$enableval" = "yes" ; then
	echo "Linux-Netfilter Transparent Proxy enabled"
	AC_DEFINE(LINUX_NETFILTER, 1, [Enable support for Transparent Proxy on Linux 2.4 and later])
	LINUX_NETFILTER="yes"
  fi
])

dnl Enable Large file support
buildmodel=""
needlargefiles=

AC_ARG_WITH(large-files,
[  --with-large-files      Enable support for large files (logs etc).],
[ if test "$withval" = yes; then
	needlargefiles=1
  fi
])

AC_ARG_ENABLE(large-cache-files,
[  --enable-large-cache-files
			  Enable support for large cache files (>2GB).
			  WARNING: on-disk cache format is changed by this option],
[ if test "$enableval" = "yes" ; then
	echo "Large cache file support enabled"
	AC_DEFINE(LARGE_CACHE_FILES, 1, [Support large cache files > 2GB])
dnl	needlargefiles=1
  fi
])

dnl UNIX Build environment
AC_ARG_WITH(build-environment,
[  --with-build-environment=model
			  The build environment to use. Normally one of
			  POSIX_V6_ILP32_OFF32   32 bits
			  POSIX_V6_ILP32_OFFBIG  32 bits with large file support
			  POSIX_V6_LP64_OFF64    64 bits
			  POSIX_V6_LPBIG_OFFBIG  large pointers and files
			  XBS5_ILP32_OFF32       32 bits (legacy)
			  XBS5_ILP32_OFFBIG      32 bits with large file support (legacy)
			  XBS5_LP64_OFF64        64 bits (legacy)
			  XBS5_LPBIG_OFFBIG      large pointers and files (legacy)
			  default                The default for your OS],
[ case "$withval" in
  yes|no)
	echo "--with-build-environment expects a build environment string as used by getconf"
	exit 1
	;;
  *)
	buildmodel="$withval"
	;;
  esac
])

if test $needlargefiles && test -z "$buildmodel"; then
	for model in POSIX_V6_LPBIG_OFFBIG XBS5_LPBIG_OFFBIG POSIX_V6_LP64_OFF64 XBS5_LP64_OFF64 POSIX_V6_ILP32_OFFBIG XBS5_ILP32_OFFBIG; do
		if test "`getconf _$model 2>/dev/null || true`" = 1 || test "`getconf $model 2>/dev/null || true`" ; then
			buildmodel=$model
			break
		fi
	done
	if test -z "$buildmodel"; then
		echo "WARNING: No suitable build environment found for large files. Trying to use _FILE_OFFSET_BITS=64"
		sleep 1
	fi
fi
case "$buildmodel" in
"default"|"")
	if test $needlargefiles; then
		echo "Enabling -D_FILE_OFFSET_BITS=64 for large file support"
		CFLAGS="-D_FILE_OFFSET_BITS=64 $CFLAGS"
	fi
	;;
*)
	echo "Using $buildmodel build environment"
	if test "`getconf _$buildmodel 2>/dev/null || true`" = 1 || test "`getconf $buildmodel 2>/dev/null || true`" ; then
	    : # All fine
	else
	    echo "ERROR: Build environment $buildmodel not known to getconf."
	    exit 1
	fi
	CFLAGS="`getconf ${buildmodel}_CFLAGS` $CFLAGS"
	LIBS="`getconf ${buildmodel}_LIBS` $LIBS"
	LDFLAGS="`getconf ${buildmodel}_LDFLAGS` $LDFLAGS"
	case "$host" in
dnl
dnl On Solaris getconf returns for CFLAGS -xarch=generic64, -Xa and -Usun options, and
dnl for LDFLAGS -xarch=generic64, but:
dnl   "-Xa" is supported only by Sun cc, so we need to remove it when using gcc
dnl   For gcc "-xarch=generic64" must be replaced with "-m64"
dnl   The 'sun' define is needed by ipfilter includes, so we must remove "-Usun"
	    *-solaris*)
		if test "$GCC" = "yes"; then
		    echo "Removing -Xa for gcc on $host"
		    CFLAGS="`echo $CFLAGS | sed -e 's/-Xa//'`"
		    echo "Replacing -xarch=generic64 with -m64 for gcc on $host"
		    CFLAGS="`echo $CFLAGS | sed -e 's/-xarch=generic64/-m64/'`"
		    LDFLAGS="`echo $LDFLAGS | sed -e 's/-xarch=generic64//'`"
		fi
		echo "Removing -Usun on $host"
		CFLAGS="`echo $CFLAGS | sed -e 's/-Usun//'`"
		;;
dnl		
dnl On Irix 6.x getconf returns options valid only for the SGI MipsPRO compiler,
dnl so we must adjust something to avoid gcc errors.
dnl On Irix 6.x 32/64 bit we must replace "-n32" with "-mabi=n32" in CFLAGS and
dnl remove "-n32" from LDFLAGS
dnl On Irix 6.x 64 bit we must replace "-64" with "-mabi=64" in CFLAGS and remove
dnl "-64" from LDFLAGS
	    *-sgi-irix6.*)
		if test "$GCC" = "yes"; then
		    CFLAGS="`echo $CFLAGS | sed -e 's/-n32/-mabi=n32/'`"
		    LDFLAGS="`echo $LDFLAGS | sed -e 's/-n32//'`"
		    CFLAGS="`echo $CFLAGS | sed -e 's/-64/-mabi=64/'`"
		    LDFLAGS="`echo $LDFLAGS | sed -e 's/-64//'`"
		fi
		;;
	    *)
		;;
	esac
	;;
esac

dnl Enable Linux transparent proxy support
AC_ARG_ENABLE(linux-tproxy,
[  --enable-linux-tproxy
			  Enable real Transparent Proxy support for Netfilter TPROXY.],
[ if test "$enableval" = "yes" ; then
	echo "Linux Netfilter/TPROXY enabled"
	AC_DEFINE(LINUX_TPROXY, 1, [Enable real Transparent Proxy support for Netfilter TPROXY.])
	LINUX_TPROXY="yes"
        if test -z "$LINUX_NETFILTER"; then
	    echo "Linux-Netfilter Transparent Proxy automatically enabled"
	    LINUX_NETFILTER="yes"
	fi
  fi
])

AM_CONDITIONAL(MAKE_LEAKFINDER, false)
dnl Enable Leak Finding Functions
AC_ARG_ENABLE(leakfinder,
[  --enable-leakfinder
			  Enable Leak Finding code.  Enabling this alone
			  does nothing; you also have to modify the source
			  code to use the leak finding functions.  Probably
			  Useful for hackers only.],
[ if test "$enableval" = "yes" ; then
	echo "Leak-Finding enabled"
	AC_DEFINE(USE_LEAKFINDER, 1, [Enable code for assiting in finding memory leaks.  Hacker stuff only.])
	USE_LEAKFINDER="yes"
	AM_CONDITIONAL(MAKE_LEAKFINDER, true)
  fi
])

USE_IDENT=1
AC_ARG_ENABLE(ident-lookups,
[  --disable-ident-lookups
			  This allows you to remove code that performs
			  Ident (RFC 931) lookups.],
[ if test "$enableval" = "no" ; then
    echo "Disabling Ident Lookups"
    USE_IDENT=0
  fi
])
if test $USE_IDENT = 1; then
    AC_DEFINE(USE_IDENT, 1, [Compile in support for Ident (RFC 931) lookups?  Enabled by default.])
fi

AM_CONDITIONAL(USE_DNSSERVER, false)
use_dnsserver=
AC_ARG_ENABLE(internal-dns,
[  --disable-internal-dns  This prevents Squid from directly sending and
			  receiving DNS messages, and instead enables the
			  old external 'dnsserver' processes.],
[ if test "$enableval" = "no" ; then
    echo "Disabling Internal DNS queries"
    use_dnsserver="yes"
  fi
])
if test "$use_dnsserver" = "yes"; then
    AC_DEFINE(USE_DNSSERVERS, 1, [If --disable-internal-dns was given to configure, then we'll use
	the dnsserver processes instead.])
    AM_CONDITIONAL(USE_DNSSERVER, true)
    dnl Some platforms need -lresolv when using --disable-internal-dns
     case "$host" in
	*-solaris*)
        LIBS="$LIBS -lresolv"
	    ;;
	*-cygwin*)
        LIBS="$LIBS -lresolv"
        ;;
    esac
fi

AC_ARG_ENABLE(truncate,
[  --enable-truncate       This uses truncate() instead of unlink() when
			  removing cache files.  Truncate gives a little
			  performance improvement, but may cause problems
			  when used with async I/O.  Truncate uses more
			  filesystem inodes than unlink..],
[ if test "$enableval" = "yes" ; then
    echo "Enabling truncate instead of unlink"
    AC_DEFINE(USE_TRUNCATE, 1, [Do we want to use truncate(2) or unlink(2)?])
  fi
])

dnl Select Default hosts file location
AC_ARG_ENABLE(default-hostsfile,
[  --enable-default-hostsfile=path
			  Select default location for hosts file.
			  See hosts_file directive in squid.conf for details],
[
    if test "$enableval" != "none" ; then
	if test -f $enableval; then
	    OPT_DEFAULT_HOSTS=$enableval
	else
	    echo "Warning Unable to find $enableval"
	    sleep 5
	fi
    else
	OPT_DEFAULT_HOSTS="none"    
    fi
    echo "Default hosts file set to: $enableval"
],[OPT_DEFAULT_HOSTS="/etc/hosts"])
AC_SUBST(OPT_DEFAULT_HOSTS)


dnl Enable WIN32 Service compile mode
AC_ARG_ENABLE(win32-service,
[  --enable-win32-service  Compile Squid as a WIN32 Service
			  Works only on Windows NT and Windows 2000 Platforms.],
[ if test "$enableval" = "yes" ; then
    echo "Enabling WIN32 run service mode"
    AC_DEFINE(USE_WIN32_SERVICE,1,[Define Windows NT & Windows 2000 run service mode])
  fi
])

dnl Select auth schemes modules to build
AC_ARG_ENABLE(auth,
[  --enable-auth="list of auth scheme modules"
			  Build support for the list of authentication schemes.
			  The default is to build support for the Basic scheme.
			  See src/auth for a list of available modules, or
			  Programmers Guide section authentication schemes
			  for details on how to build your custom auth scheme
			  module],
[ case $enableval in
  yes)
	for module in $srcdir/src/auth/*; do
	    name="`basename $module`"
	    case $name in
	    CVS) # Ignore
		;;
	    *)
		if test -d $module; then
		    AUTH_MODULES="$AUTH_MODULES $name"
		fi
		;;
	    esac
	done
	;;
  no)
	;;
  *)    AUTH_MODULES="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
	;;
  esac
],
[ if test -z "$AUTH_MODULES"; then
    AUTH_MODULES="basic"
  fi
])
if test -z "$AUTH_MODULES"; then
    echo "Auth scheme modules built: None"
else
    echo "Auth scheme modules built: $AUTH_MODULES"
    AUTH_OBJS="auth/lib`echo $AUTH_MODULES|sed -e 's% %.a auth/lib%g'`.a"
    AUTH_LIBS="`echo $AUTH_OBJS|sed -e 's%auth/%%g'`"
fi
AC_SUBST(AUTH_MODULES)
AC_SUBST(AUTH_OBJS)
AC_SUBST(AUTH_LIBS)

AC_ARG_ENABLE(basic-auth-helpers,
[  --enable-basic-auth-helpers="list of helpers"
			  This option selects which basic scheme proxy_auth
			  helpers to build and install as part of the normal 
			  build process. For a list of available
			  helpers see the helpers/basic_auth directory.],
[ case "$enableval" in
  yes) 
    echo "ERROR: --enable-basic-auth-helpers requires an argument"
    exit 1
    ;;
  no)
    ;;
  *)
    BASIC_AUTH_HELPERS="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
  esac
])
if test -n "$BASIC_AUTH_HELPERS"; then
    for helper in $BASIC_AUTH_HELPERS; do
	if test -f $srcdir/helpers/basic_auth/$helper/Makefile.in; then
		if test "$helper" = "SASL"; then
			require_sasl=yes
		fi
	else
		echo "ERROR: Basic auth helper $helper does not exists"
		exit 1
	fi
    done
    echo "Basic auth helpers built: $BASIC_AUTH_HELPERS"
fi
AC_SUBST(BASIC_AUTH_HELPERS)

dnl Select ntlm auth helpers to build
NTLM_AUTH_HELPERS=
AC_ARG_ENABLE(ntlm-auth-helpers,
[  --enable-ntlm-auth-helpers="list of helpers"
			  This option selects which proxy_auth ntlm helpers
			  to build and install as part of the normal build 
			  process. For a list of available helpers see
			  the helpers/ntlm_auth directory.],
[ case "$enableval" in
  yes) 
    echo "ERROR: --enable-ntlm-auth-helpers requires an argument"
    exit 1
    ;;
  no)
    ;;
  *)
    NTLM_AUTH_HELPERS="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
  esac
])
if test -n "$NTLM_AUTH_HELPERS"; then
    for helper in $NTLM_AUTH_HELPERS; do
	if test -f $srcdir/helpers/ntlm_auth/$helper/Makefile.in; then
		:
	else
		echo "ERROR: NTLM auth helper $helper does not exists"
		exit 1
	fi
    done
    echo "NTLM auth helpers built: $NTLM_AUTH_HELPERS"
fi
AC_SUBST(NTLM_AUTH_HELPERS)

dnl Select digest auth scheme helpers to build
DIGEST_AUTH_HELPERS=
AC_ARG_ENABLE(digest-auth-helpers,
[  --enable-digest-auth-helpers="list of helpers"
			  This option selects which digest scheme proxy_auth
			  helpers to build and install as part of the normal
			  build process. For a list of available helpers see the
			  helpers/digest_auth directory.],
[ case "$enableval" in
  yes)
    echo "ERROR: --enable-digest-auth-helpers requires an argument"
    exit 1
    ;;
  no)
    ;;
  *)
    DIGEST_AUTH_HELPERS="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
  esac
])
if test -n "$DIGEST_AUTH_HELPERS"; then
    for helper in $DIGEST_AUTH_HELPERS; do
	if test -f $srcdir/helpers/digest_auth/$helper/Makefile.in; then
		:
	else
		echo "ERROR: digest auth helper $helper does not exists"
		exit 1
	fi
    done
    echo "Digest auth helpers built: $DIGEST_AUTH_HELPERS"
fi
AC_SUBST(DIGEST_AUTH_HELPERS)

dnl Select negotiate auth scheme helpers to build
NEGOTIATE_AUTH_HELPERS=
AC_ARG_ENABLE(negotiate-auth-helpers,
[  --enable-negotiate-auth-helpers="list of helpers"
			  This option selects which negotiate scheme authentication
			  helpers to build and install as part of the normal build
			  process. For a list of available helpers see the
			  helpers/negotiate_auth directory.],
[ case "$enableval" in
  yes)
    echo "ERROR: --enable-negotiate-auth-helpers requires an argument"
    exit 1
    ;;
  no)
    ;;
  *)
    NEGOTIATE_AUTH_HELPERS="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
  esac
])
if test -n "$NEGOTIATE_AUTH_HELPERS"; then
    for helper in $NEGOTIATE_AUTH_HELPERS; do
	if test -f $srcdir/helpers/negotiate_auth/$helper/Makefile.in; then
		:
	else
		echo "ERROR: negotiate auth helper $helper does not exists"
		exit 1
	fi
    done
    echo "Negotiate auth helpers built: $NEGOTIATE_AUTH_HELPERS"
fi
AC_SUBST(NEGOTIATE_AUTH_HELPERS)

dnl Enable "NTLM fail open"
AC_ARG_ENABLE(ntlm-fail-open,
[  --enable-ntlm-fail-open Enable NTLM fail open, where a helper that fails one of the
			  Authentication steps can allow squid to still authenticate
			  the user.],
[ if test "$enableval" = "yes" ; then
    AC_DEFINE(NTLM_FAIL_OPEN, 1, [Define if NTLM is allowed to fail gracefully when a helper has problems])
  fi
])

dnl Select external_acl helpers to build
EXTERNAL_ACL_HELPERS=
AC_ARG_ENABLE(external-acl-helpers,
[  --enable-external-acl-helpers="list of helpers"
			  This option selects which external_acl helpers to
			  build and install as part of the normal build
			  process. For a list of available helpers see the
			  helpers/external_acl directory.],
[ case "$enableval" in
  yes)
    echo "ERROR: --enable-external-acl-helpers requires an argument"
    exit 1
    ;;
  no)
    ;;
  *)
    EXTERNAL_ACL_HELPERS="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
  esac
])
if test -n "$EXTERNAL_ACL_HELPERS"; then
    for helper in $EXTERNAL_ACL_HELPERS; do
	if test -f $srcdir/helpers/external_acl/$helper/Makefile.in; then
		:
	else
		echo "ERROR: external acl helper $helper does not exists"
		exit 1
	fi
    done
    echo "External acl helpers built: $EXTERNAL_ACL_HELPERS"
fi
AC_SUBST(EXTERNAL_ACL_HELPERS)


dnl Check for Cyrus SASL
if test "$require_sasl" = "yes"; then
	AC_CHECK_HEADERS(sasl/sasl.h sasl.h)
	if test "$ac_cv_header_sasl_sasl_h" = "yes"; then
		echo "using SASL2"
		LIBSASL="-lsasl2"
	else
		if test "$ac_cv_header_sasl_h" = "yes"; then
			echo "using SASL"
			LIBSASL="-lsasl"
		else
			echo "ERROR: Neither SASL nor SASL2 found"
			exit 1
		fi
	fi
	AC_SUBST(LIBSASL)
fi

dnl Disable "unlinkd" code
AC_ARG_ENABLE(unlinkd,
[  --disable-unlinkd       Do not use unlinkd],
[ if test "$enableval" = "no" ; then
    use_unlinkd=no
  else
    use_unlinkd=yes
  fi
],[
    # Here we should probably use some magic depending on the selected
    # storage models
    use_unlinkd=yes
])
if test "$use_unlinkd" = "yes"; then
    echo "unlinkd enabled"
    AC_DEFINE(USE_UNLINKD, 1, [Define this if unlinkd is required
	(strongly recommended for ufs storage type)])
    AM_CONDITIONAL(ENABLE_UNLINKD, true)
else
    echo "unlinkd disabled"
    AM_CONDITIONAL(ENABLE_UNLINKD, false)
fi

dnl Enable backtraces on fatal errors
AC_ARG_ENABLE(stacktraces,
[  --enable-stacktraces    Enable automatic call backtrace on fatal errors],
[ if test "$enableval" = "yes" ; then
    echo "Enabling automatic stack backtraces on fatal errors"
    AC_DEFINE(PRINT_STACK_TRACE, 1, [Print stacktraces on fatal errors])
    if test "$GCC" = "yes"; then
	LDFLAGS="$LDFLAGS -rdynamic"
    fi
  fi
])

dnl Enable X-Accelerator-Vary for Vary support within an accelerator setup
AC_ARG_ENABLE(x_accelerator_vary,
[  --enable-x-accelerator-vary
			  Enable support for the X-Accelerator-Vary
			  HTTP header. Can be used to indicate
			  variance within an accelerator setup.
			  Typically used together with other code
			  that adds custom HTTP headers to the requests.],
[ if test "$enableval" = "yes" ; then
    echo "Enabling support for X-Accelerator-Vary"
    AC_DEFINE(X_ACCELERATOR_VARY, 1, [Enable support for the X-Accelerator-Vary HTTP header])
  fi
])

AC_ARG_ENABLE(follow-x-forwarded-for,
[  --enable-follow-x-forwarded-for
			  Enable support for following the X-Forwarded-For
			  HTTP header to try to find the IP address of the
			  original or indirect client when a request has
			  been forwarded through other proxies.],
[ if test "$enableval" = "yes" ; then
    echo "follow X-Forwarded-For enabled"
    AC_DEFINE(FOLLOW_X_FORWARDED_FOR, 1, [Enable following X-Forwarded-For headers])
    AC_SEARCH_LIBS(inet_aton, resolv) dnl some systems don't have this in libc
  fi
])

# Force some compilers to use ANSI features
#
case "$host" in
    alpha-dec-osf*)
	if test "$ac_cv_prog_CC" = "cc" ; then
		echo "adding '-std1' to cc args for $host"
		CC="cc -std1";
		ac_cv_prog_CC="$CC"
	fi
	;;
    *-hp-hpux*)
	if test "$ac_cv_prog_CC" = "cc" ; then
		echo "adding '-Ae' to cc args for $host"
		CC="cc -Ae";
		ac_cv_prog_CC="$CC"
	fi
	;;
esac

dnl Check for programs
AC_PROG_EGREP
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_LN_S
AC_PATH_PROG(SH, sh, /bin/sh)
AC_PATH_PROG(FALSE, false, /usr/bin/false)
AC_PATH_PROG(TRUE, true, /usr/bin/true)
AC_PATH_PROG(RM, rm, $FALSE)
AC_PATH_PROG(MV, mv, $FALSE)
AC_PATH_PROG(MKDIR, mkdir, $FALSE)
AC_PATH_PROG(LN, ln, cp)
AC_PATH_PROG(PERL, perl, none)
dnl automake handles this AC_PATH_PROG(MAKEDEPEND, makedepend, $TRUE)
AC_PATH_PROG(AR, ar, $FALSE)

if test "$ac_cv_path_PERL" = "none"; then
	echo "Perl is required to compile Squid"
	echo "Please install Perl and then re-run configure"
	exit 1
fi

case "$host" in
    *-hp-hpux*)
	echo "Disabling 'ranlib' for HP-UX..."
	RANLIB=":"
	;;
esac

dnl set $(AR)
AR_R="$AR r"
case "$host" in
	*-next-nextstep3)
		AR="libtool -o"
		;;
esac
AC_SUBST(AR_R)

dnl Check for headers
AC_HEADER_DIRENT
AC_HEADER_STDC

dnl Check for headers. sys/types.h and stddef.h and limits must be first (see below)
AC_CHECK_HEADERS(
	sys/types.h \
	stddef.h \
	limits.h \
	sys/param.h \
	sys/socket.h \
	netinet/in.h \
	stdio.h \
	stdlib.h \
	arpa/inet.h \
	arpa/nameser.h \
	assert.h \
	bstring.h \
	crypt.h \
	ctype.h \
	errno.h \
	execinfo.h \
	fcntl.h \
	fnmatch.h \
	getopt.h \
	glob.h \
	gnumalloc.h \
	grp.h \
	libc.h \
	linux/netfilter_ipv4.h \
	linux/netfilter_ipv4/ip_tproxy.h \
	malloc.h \
	math.h \
	memory.h \
	mount.h \
	net/if.h \
	net/pfvar.h \
	netdb.h \
	netinet/if_ether.h \
	netinet/tcp.h \
	openssl/err.h \
	openssl/md5.h \
	openssl/ssl.h \
	openssl/engine.h \
	paths.h \
	poll.h \
	pwd.h \
	regex.h \
	resolv.h \
	sched.h \
	signal.h \
	stdarg.h \
	string.h \
	strings.h \
	sys/bitypes.h \
	sys/file.h \
	sys/ioctl.h \
	sys/mount.h \
	md5.h \
	sys/md5.h \
	sys/msg.h \
	sys/prctl.h \
	sys/resource.h \
	sys/poll.h \
	sys/select.h \
	sys/stat.h \
	sys/statfs.h \
	sys/statvfs.h \
	syscall.h \
	sys/syscall.h \
	sys/time.h \
	sys/un.h \
	sys/vfs.h \
	sys/wait.h \
	sys/event.h \
	syslog.h \
	time.h \
	unistd.h \
	utime.h \
	varargs.h \
	byteswap.h \
	glib.h \
	stdint.h \
	inttypes.h \
	grp.h \
	nss_common.h \
	nss.h \
	db.h \
	db_185.h \
	aio.h \
	sys/capability.h \
,,,[
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_STDDEF_H
#include <stddef.h>
#endif
#if HAVE_LIMITS_H
#include <limits.h>
#endif
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_NET_IF_H
#include <net/if.h>
#endif
#if HAVE_NETINET_IF_ETHER_H
#include <netinet/if_ether.h>
#endif
])

dnl Check for IP-Filter headers. These are a bit nasty..
AC_CHECK_HEADERS( \
	ip_compat.h \
	ip_fil_compat.h \
	ip_fil.h \
	ip_nat.h \
	ipl.h \
	netinet/ip_compat.h \
	netinet/ip_fil_compat.h \
	netinet/ip_fil.h \
	netinet/ip_nat.h \
	netinet/ipl.h \
,,,[
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_STDDEF_H
#include <stddef.h>
#endif
#if HAVE_LIMITS_H
#include <limits.h>
#endif
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_NET_IF_H
#include <net/if.h>
#endif
#if HAVE_NETINET_IF_ETHER_H
#include <netinet/if_ether.h>
#endif
#if HAVE_IP_COMPAT_H
#include <ip_compat.h>
#elif HAVE_NETINET_IP_COMPAT_H
#include <netinet/ip_compat.h>
#endif
#if HAVE_IP_FIL_H
#include <ip_fil.h>
#elif HAVE_NETINET_IP_FIL_H
#include <netinet/ip_fil.h>
#endif
])

AC_C_CONST
AC_C_BIGENDIAN
AC_C_INLINE

AC_CACHE_CHECK(if ANSI prototypes work,ac_cv_have_ansi_prototypes, [
  AC_TRY_COMPILE([int foo(char *); int foo (char *bar) {return 1;}],
    [foo("bar")],
    ac_cv_have_ansi_prototypes="yes",
    ac_cv_have_ansi_prototypes="no")
])
if test $ac_cv_have_ansi_prototypes = "yes" ; then
  AC_DEFINE(HAVE_ANSI_PROTOTYPES, 1, [Define if your compiler supports prototyping])
fi

AC_CACHE_CHECK(for tm->tm_gmtoff,ac_cv_have_tm_gmoff, [
  AC_TRY_COMPILE([#include <time.h>
#include <sys/time.h>],
    [struct tm foo;
      foo.tm_gmtoff = 0;],
    ac_cv_have_tm_gmoff="yes",
    ac_cv_have_tm_gmoff="no")
])
if test $ac_cv_have_tm_gmoff = "yes" ; then
  AC_DEFINE(HAVE_TM_GMTOFF, 1, [Define if struct tm has tm_gmtoff member])
fi

AC_CACHE_CHECK(for struct mallinfo,ac_cv_have_struct_mallinfo, [
  AC_TRY_COMPILE([#include <sys/types.h>
#if HAVE_MALLOC_H
#include <malloc.h>
#endif],
    [struct mallinfo foo;
    foo.arena = 0;
    foo.ordblks = 0;
    foo.smblks = 0;
    foo.hblks = 0;
    foo.hblkhd = 0;
    foo.uordblks = 0;
    foo.fordblks = 0;
    foo.keepcost = 0;],
    ac_cv_have_struct_mallinfo="yes",
    ac_cv_have_struct_mallinfo="no")
])
if test $ac_cv_have_struct_mallinfo = "yes" ; then
  AC_DEFINE(HAVE_STRUCT_MALLINFO, 1, [we check for the existance of struct mallinfo])
fi

AC_CACHE_CHECK(for extended mallinfo,ac_cv_have_ext_mallinfo, [
  AC_TRY_COMPILE([#include <sys/types.h>
#include <malloc.h>],
    [struct mallinfo foo;
      foo.mxfast = 0;],
    ac_cv_have_ext_mallinfo="yes",
    ac_cv_have_ext_mallinfo="no")
])
if test $ac_cv_have_ext_mallinfo = "yes" ; then
  AC_DEFINE(HAVE_EXT_MALLINFO, 1, [Define if struct mallinfo has mxfast member])
fi

case "$host_os" in
  mingw|mingw32)
    AC_DEFINE(HAVE_STRUCT_RUSAGE)
    ac_cv_func_getrusage='yes'
    echo "Using own rusage on Windows."
    ;;
  *)      
    AC_CACHE_CHECK(for struct rusage,ac_cv_have_struct_rusage, [
      AC_TRY_COMPILE([
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#if HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif],
        [struct rusage R;],
        ac_cv_have_struct_rusage="yes",
        ac_cv_have_struct_rusage="no")
])
    if test $ac_cv_have_struct_rusage = "yes" ; then
      AC_DEFINE(HAVE_STRUCT_RUSAGE, 1, [Define if you have struct rusage])
    fi
    ;;
esac

AC_CACHE_CHECK(for ip->ip_hl, ac_cv_have_ip_hl, [
  AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#if defined (__linux__) || defined (__CYGWIN__)
#define ip_hl ihl
#endif
#ifndef __linux__
#ifndef __CYGWIN__
#define iphdr ip
#endif
#endif],
    [struct iphdr ip;
      ip.ip_hl= 0;],
    ac_cv_have_ip_hl="yes",
    ac_cv_have_ip_hl="no")
])
if test $ac_cv_have_ip_hl = "yes" ; then
  AC_DEFINE(HAVE_IP_HL, 1, [Define if struct ip has ip_hl member])
fi

dnl Check for typedefs
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF_SYSTYPE(int8_t)
AC_CHECK_SIZEOF_SYSTYPE(uint8_t)
AC_CHECK_SIZEOF_SYSTYPE(u_int8_t)
AC_CHECK_SIZEOF_SYSTYPE(int16_t)
AC_CHECK_SIZEOF_SYSTYPE(uint16_t)
AC_CHECK_SIZEOF_SYSTYPE(u_int16_t)
AC_CHECK_SIZEOF_SYSTYPE(int32_t)
AC_CHECK_SIZEOF_SYSTYPE(uint32_t)
AC_CHECK_SIZEOF_SYSTYPE(u_int32_t)
AC_CHECK_SIZEOF_SYSTYPE(int64_t)
AC_CHECK_SIZEOF_SYSTYPE(uint64_t)
AC_CHECK_SIZEOF_SYSTYPE(u_int64_t)
AC_CHECK_SIZEOF_SYSTYPE(__int64)

dnl int8_t
if test "x$ac_cv_sizeof_char" = "x1"; then
	AC_CHECK_SYSTYPE(int8_t,char)
fi
dnl u_int8_t
if test "x$ac_cv_sizeof_uint8_t" = "x1"; then
	AC_CHECK_SYSTYPE(u_int8_t,uint8_t)
elif test "x$ac_cv_sizeof_char" = "x1"; then
	AC_CHECK_SYSTYPE(u_int8_t,unsigned char)
fi
dnl uint8_t
if test "x$ac_cv_sizeof_u_int8_t" = "x1"; then
	AC_CHECK_SYSTYPE(uint8_t,u_int8_t)
elif test "x$ac_cv_sizeof_char" = "x1"; then
	AC_CHECK_SYSTYPE(uint8_t,unsigned char)
fi
dnl int16_t
if test "x$ac_cv_sizeof_short" = "x2"; then
	AC_CHECK_SYSTYPE(int16_t,short)
elif test "x$ac_cv_sizeof_int" = "x2"; then
	AC_CHECK_SYSTYPE(int16_t,int)
fi
dnl u_int16_t
if test "x$ac_cv_sizeof_uint16_t" = "x2"; then
	AC_CHECK_SYSTYPE(u_int16_t,uint16_t)
elif test "x$ac_cv_sizeof_short" = "x2"; then
	AC_CHECK_SYSTYPE(u_int16_t,unsigned short)
elif test "x$ac_cv_sizeof_int" = "x2"; then
	AC_CHECK_SYSTYPE(u_int16_t,unsigned int)
fi
dnl uint16_t
if test "x$ac_cv_sizeof_u_int16_t" = "x2"; then
	AC_CHECK_SYSTYPE(uint16_t,u_int16_t)
elif test "x$ac_cv_sizeof_short" = "x2"; then
	AC_CHECK_SYSTYPE(uint16_t,unsigned short)
elif test "x$ac_cv_sizeof_int" = "x2"; then
	AC_CHECK_SYSTYPE(uint16_t,unsigned int)
fi
dnl int32_t
if test "x$ac_cv_sizeof_int" = "x4"; then
	AC_CHECK_SYSTYPE(int32_t,int)
elif "x$ac_cv_sizeof_long" = "x4"; then
	AC_CHECK_SYSTYPE(int32_t,long)
fi
dnl u_int32_t
if test "x$ac_cv_sizeof_uint32_t" = "x4"; then
	AC_CHECK_SYSTYPE(u_int32_t,uint32_t)
elif test "x$ac_cv_sizeof_int" = "x4"; then
	AC_CHECK_SYSTYPE(u_int32_t,unsigned int)
elif test "x$ac_cv_sizeof_long" = "x4"; then
	AC_CHECK_SYSTYPE(u_int32_t,unsigned long)
fi
dnl uint32_t
if test "x$ac_cv_sizeof_u_int32_t" = "x4"; then
	AC_CHECK_SYSTYPE(uint32_t,u_int32_t)
elif test "x$ac_cv_sizeof_int" = "x4"; then
	AC_CHECK_SYSTYPE(uint32_t,unsigned int)
elif test "x$ac_cv_sizeof_long" = "x4"; then
	AC_CHECK_SYSTYPE(uint32_t,unsigned long)
fi
dnl int64_t
if test "x$ac_cv_sizeof_long" = "x8"; then
	AC_CHECK_SYSTYPE(int64_t,long)
elif test "x$ac_cv_sizeof_long_long" = "x8"; then
	AC_CHECK_SYSTYPE(int64_t,long long)
elif test "x$ac_cv_sizeof___int64" = "x8"; then
	AC_CHECK_SYSTYPE(int64_t,__int64)
fi
dnl u_int64_t
if test "x$ac_cv_sizeof_uint64_t" = "x8"; then
	AC_CHECK_SYSTYPE(u_int64_t,uint64_t)
elif test "x$ac_cv_sizeof_long" = "x8"; then
	AC_CHECK_SYSTYPE(u_int64_t,unsigned long)
elif test "x$ac_cv_sizeof_long_long" = "x8"; then
	AC_CHECK_SYSTYPE(u_int64_t,unsigned long long)
elif test "x$ac_cv_sizeof___int64" = "x8"; then
	AC_CHECK_SYSTYPE(u_int64_t,unsigned __int64)
fi
dnl uint64_t
if test "x$ac_cv_sizeof_u_int64_t" = "x8"; then
	AC_CHECK_SYSTYPE(uint64_t,u_int64_t)
elif test "x$ac_cv_sizeof_long" = "x8"; then
	AC_CHECK_SYSTYPE(uint64_t,unsigned long)
elif test "x$ac_cv_sizeof_long_long" = "x8"; then
	AC_CHECK_SYSTYPE(uint64_t,unsigned long long)
elif test "x$ac_cv_sizeof___int64" = "x8"; then
	AC_CHECK_SYSTYPE(uint64_t,unsigned __int64)
fi

AC_CHECK_SYSTYPE(pid_t, int)
AC_CHECK_SYSTYPE(size_t, unsigned int)
AC_CHECK_SYSTYPE(ssize_t, int)
AC_CHECK_SYSTYPE(off_t, int)
AC_CHECK_SYSTYPE(mode_t, unsigned short)
AC_CHECK_SYSTYPE(fd_mask, int)

AC_CHECK_SIZEOF_SYSTYPE(off_t, 4)
AC_CHECK_SIZEOF_SYSTYPE(size_t, 4)

dnl Check for special functions
AC_FUNC_ALLOCA


dnl Check for type in sys/socket.h
AC_CACHE_CHECK(for socklen_t, ac_cv_type_socklen_t, [
  AC_EGREP_CPP([socklen_t[^a-zA-Z_0-9]], [#include <sys/types.h>
#include <sys/socket.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif],
    ac_cv_type_socklen_t=yes,
    ac_cv_type_socklen_t=no)
])
if test $ac_cv_type_socklen_t = no; then
  AC_DEFINE(socklen_t, int, [This makes warnings go away.  If you have socklen_t defined in your
	/usr/include files, then this should remain undef'd.  Otherwise it
	should be defined to int.])
fi

dnl Check for mtyp_t in some headers
AC_CACHE_CHECK(for mtyp_t, ac_cv_type_mtyp_t, [
  AC_EGREP_CPP([mtyp_t[^a-zA-Z_0-9]], [#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>],
    ac_cv_type_mtyp_t=yes,
    ac_cv_type_mtyp_t=no)
])
if test $ac_cv_type_mtyp_t = no; then
  AC_DEFINE(mtyp_t, long, [message type for message queues])
 fi

use_libcap=auto
AC_ARG_WITH(libcap, AS_HELP_STRING([--without-libcap],[disable usage of Linux capabilities library to control privileges]),
[ if test "x$withval" = "xyes" ; then
    AC_MSG_RESULT(libcap forced enabled)
    use_libcap=yes
  else
    AC_MSG_RESULT(libcap forced disabled)
    use_libcap=no
  fi
])
if test "x$use_libcap" != "xno"; then
  # cap_clear_flag is the most recent libcap function we require
  AC_SEARCH_LIBS(cap_clear_flag, cap)
  AC_CHECK_FUNCS(cap_clear_flag)
  if test "x$ac_cv_func_cap_clear_flag" = xyes; then
    use_libcap=yes
  else
    if test "x$use_libcap" = "xyes"; then
      AC_MSG_ERROR([libcap forced enabled but not available or not usable, requires libcap-2.09 or later])
    fi
    use_libcap=no
  fi
fi
if test "x$use_libcap" = "xyes"; then
  AC_DEFINE(USE_LIBCAP, 1, [use libcap to set capabilities required for TPROXY])
  dnl Check for libcap headader breakage.
  AC_CHECK_HEADERS(sys/capability.h)
  AC_CACHE_CHECK([for operational libcap2 headers], squid_cv_sys_capability_works,
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdlib.h>
#include <stddef.h>
#include <sys/capability.h>
]], [[
capget(NULL, NULL);
capset(NULL, NULL);
                   ]])],[squid_cv_sys_capability_works=yes],[squid_cv_sys_capability_works=no])
  )
  if test x$squid_cv_sys_capability_works != xyes; then
    AC_DEFINE([LIBCAP_BROKEN],1,[if libcap2 headers are broken and clashing with glibc])
  fi
fi

# Check for needed libraries

AX_LIB_SOCKET_NSL

# yp_match is in libnsl on some systems, needed by helpers/basic_auth/YP
saved_LIBS="$LIBS"
AC_SEARCH_LIBS([yp_match], [nsl], [test "$ac_res" = "none required" || NIS_LIBS="$ac_res $NIS_LIBS";LIBS="$saved_LIBS"])
AC_SUBST(NIS_LIBS)

dnl Check for Winsock only on MinGW, on Cygwin we must use emulated BSD socket API
	case "$host_os" in
	mingw|mingw32)
	AC_MSG_CHECKING(for winsock)
	save_LIBS="$LIBS"
	for curlib in ws2_32 wsock32; do
		LIBS="$LIBS -l$curlib"
		AC_TRY_LINK([
				char __attribute__((stdcall)) socket(int,int,int);
				char __attribute__((stdcall)) select(int,int,int,int,int);
				char __attribute__((stdcall)) closesocket(int);
				char __attribute__((stdcall)) gethostname(int,int);
				],
				[
				socket(1,2,3);
				select(1,2,3,4,5);
				closesocket(1);
				gethostname(1,2);
				],
				have_winsock=yes, have_winsock=no)
	
		if test $have_winsock = yes; then
			ac_cv_func_select='yes'
			if test $curlib = ws2_32; then
				have_winsock=winsock2
			fi
			break
		fi
		LIBS="$save_LIBS"
	done
	AC_MSG_RESULT($have_winsock)
	if test $have_winsock = winsock2; then
	       AC_CHECK_HEADERS(winsock2.h)
	else
	       AC_CHECK_HEADERS(winsock.h)
	fi
	;;
esac

dnl Ripped from the Samba sources
AC_CACHE_CHECK([for unix domain sockets],squid_cv_unixsocket, [
    AC_TRY_COMPILE([
#include <sys/types.h>
#include <stdlib.h>
#include <stddef.h>
#include <sys/socket.h>
#include <sys/un.h>],
[
  struct sockaddr_un sunaddr; 
  sunaddr.sun_family = AF_UNIX;
],
	squid_cv_unixsocket=yes,squid_cv_unixsocket=no)])
if test x"$squid_cv_unixsocket" = x"yes"; then
   AC_DEFINE(HAVE_UNIXSOCKET, 1, [Do we have unix sockets? (required for the winbind ntlm helper])
fi
dnl end rip

if test "x$ac_cv_enabled_dlmalloc" = "xyes" ; then
  echo "skipping libmalloc check (--enable-dlmalloc specified)"
else
  dnl prefer gnumalloc if available
  AC_CHECK_LIB(gnumalloc, malloc)
  if test "$ac_cv_lib_gnumalloc_main" = "yes"; then
		echo "Disabling extended malloc functions when using gnumalloc"
		ac_cv_func_mallinfo=no
		ac_cv_func_mallocblksize=no
		ac_cv_func_mallopt=no
  else
		case "$host" in
			*-sun-solaris*)
			  echo "skipping libmalloc check for $host"
				;;
			i386-*-freebsd*)
			  echo "skipping libmalloc check for $host"
				;;
			*)
				dnl prefer libmalloc if available
				AC_CHECK_LIB(malloc, malloc)
				;;
		esac
  fi
fi

dnl no idea who requires libbsd, or what function to look for. Been around since day 0
dnl but not needed on any of our main platforms and may contain stuff we do not want
dnl as can be seen below where -lbsd is removed from many systems
dnl AC_CHECK_LIB(bsd, main)

dnl prefer separate regex library if available
AC_CHECK_LIB(regex, regcomp, [REGEXLIB="-lregex"])

case "$host_os" in
mingw|mingw32)
	dnl Is this special case really required, doesn't AC_CHECK_LIB work?
	echo "Use MSVCRT for math functions."
	;;
	*)
	AC_CHECK_LIB(m, rint)
	;;
esac

dnl Check for libcrypt
dnl Some of our helpers use crypt(3) which may be in libc, or in
dnl libcrypt (eg FreeBSD)
saved_LIBS="$LIBS"
AC_SEARCH_LIBS([crypt], [crypt], [test "$ac_res" = "none required" || CRYPTLIB="$ac_res $CRYPTLIB";LIBS="$saved_LIBS"])
AC_SUBST(CRYPTLIB)

dnl Solaris10 provides MD5 natively through libmd5
dnl FreeBSD provides MD5 natively through libmd
AC_SEARCH_LIBS([MD5Init], [md5 md])


dnl Check for libdl, used by auth_modules/PAM
if test "$with_dl" = "yes"; then
    AC_SEARCH_LIBS([dlopen], [dl])
fi

dnl Check for pthreads
dnl We use pthreads when doing ASYNC I/O
if test "$with_pthreads" = "yes"; then
    CFLAGS="$CFLAGS -D_REENTRANT"
    case "$host" in
    i386-unknown-freebsd*)
	if test "$GCC" = "yes" ; then
	    if test -z "$PRESET_LDFLAGS"; then
		LDFLAGS="$LDFLAGS -pthread"
	    fi
	fi
    ;;
    *-solaris2.*)
	if test "$GCC" = "yes" ; then
	    CFLAGS="$CFLAGS -pthreads"
	else
	    CFLAGS="$CFLAGS -mt"
	fi
    ;;
    esac
    AC_CHECK_LIB(pthread, pthread_create)
fi

dnl Check for librt
dnl We use AIO in the coss store
if test "$with_aio" = "yes"; then
    dnl On some systems POSIX AIO functions are in libaio
    AC_SEARCH_LIBS(aio_read, [rt aio])
fi

LIB_EPOLL=''
dnl Check for libepoll
saved_LIBS="$LIBS"
AC_SEARCH_LIBS([epoll_ctl], [epoll], [test "$ac_res" = "none required" || LIB_EPOLL="$ac_res $LIB_EPOLL";LIBS="$saved_LIBS"])
AC_SUBST(LIB_EPOLL)

dnl -lintl is needed on SCO version 3.2v4.2 for strftime()
dnl Robert Side <rside@aiinc.bc.ca>
dnl Mon, 18 Jan 1999 17:48:00 GMT
case "$host" in
	*-pc-sco3.2*)
		AC_SEARCH_LIBS(strftime, intl)
		;;
esac

dnl On MinGW OpenLDAP is not available, so LDAP helpers can be linked 
dnl only with Windows LDAP libraries using -lwldap32
case "$host_os" in
mingw|mingw32)
       LIB_LDAP="-lwldap32"
       ;;
*)
       LIB_LDAP="-lldap"
       dnl LDAP helpers need to know if -llber is needed or not
       dnl unfortunately there is no well defined function API to
       dnl look for so we use AC_CHECK_LIB and just check for some
       dnl C-library function.
       AC_CHECK_LIB(lber, open, [LIB_LDAP="${LIB_LDAP} -llber"])
       ;;
esac
AC_SUBST(LIB_LDAP)

dnl Check for libdb
DBLIB=
dnl 1.85
AC_CACHE_CHECK(if dbopen needs -ldb,ac_cv_dbopen_libdb, [
SAVED_LIBS="$LIBS"; LIBS="$LIBS -ldb"
  AC_TRY_LINK([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_LIMITS_H
#include <limits.h>
#endif
#if HAVE_DB_185_H
#include <db_185.h>
#elif HAVE_DB_H
#include <db.h>
#endif],
    [dbopen((void *)0L, 0, 0, DB_HASH, (void *)0L)],
    ac_cv_dbopen_libdb="yes",
    ac_cv_dbopen_libdb="no")
LIBS="$SAVED_LIBS"
])
if test $ac_cv_dbopen_libdb = yes; then
    LIB_DB="-ldb"
fi
AC_SUBST(LIB_DB)

dnl System-specific library modifications
dnl
case "$host" in
	i386-*-solaris2.*)
		if test "$GCC" = "yes"; then
			echo "Removing -O for gcc on $host"
			CFLAGS="`echo $CFLAGS | sed -e 's/-O[[0-9]]*//'`"
		fi
		;;
	*-sgi-irix*)
		echo "Removing -lsocket for IRIX..."
		LIBS=`echo $LIBS | sed -e s/-lsocket//`
		echo "Removing -lnsl for IRIX..."
		LIBS=`echo $LIBS | sed -e s/-lnsl//`
		ac_cv_lib_nsl_main=no
		echo "Removing -lbsd for IRIX..."
		LIBS=`echo $LIBS | sed -e s/-lbsd//`
		;;
dnl From: c0032033@ws.rz.tu-bs.de (Joerg Schumacher)
dnl Date: Thu, 17 Oct 1996 04:09:30 +0200
dnl Please change your configure script.  AIX doesn't need -lbsd.
	*-ibm-aix*)
		echo "Removing -lbsd for AIX..."
		LIBS=`echo $LIBS | sed -e s/-lbsd//`
		case "$host" in
dnl From: mlaster@metavillage.com (Mike Laster)
dnl AIX 4.1.4.x does not have header files for snprintf/vsnprintf
dnl So using the internal versions generates a load of warnings
dnl during compile.
			*-ibm-aix4*)
				echo "disabling snprintf/vsnprintf for $host"
				ac_cv_func_snprintf=no
				ac_cv_func_vsnprintf=no
			;;
		esac
		;;
	*m88k*-openbsd*)
		;;
	*m88k*)
		CFLAGS="$CFLAGS -D_SQUID_MOTOROLA_"
		AC_DEFINE(GETTIMEOFDAY_NO_TZP, 1, [If gettimeofday is known to take only one argument])
		;;
	[*-*-solaris2.[0-4]])
		AC_DEFINE(GETTIMEOFDAY_NO_TZP, 1, [If gettimeofday is known to take only one argument])
		;;
	[*-sony-newsos[56]*])
		AC_DEFINE(GETTIMEOFDAY_NO_TZP, 1, [If gettimeofday is known to take only one argument])
		;;
esac

# Remove optimization for GCC 2.95.[123]
# gcc -O[2] on *BSD and Linux (x86) causes pointers to magically become NULL
if test "$GCC" = "yes"; then
	GCCVER=`$CC -v 2>&1 | awk '$2 ==  "version" {print $3}'`
	case "$GCCVER" in
	[2.95.[123]])
		echo "Removing -O for gcc on $host with GCC $GCCVER"
		CFLAGS="`echo $CFLAGS | sed -e 's/-O[[0-9]]*//'`"
		;;
	esac
fi

# Recommended by Balint Nagy Endre <bne@CareNet.hu>
case "$host" in
	*-univel-sysv4.2MP)
		if test `uname -v` = "2.03"; then
			echo "disabling mallinfo for $host"
			ac_cv_func_mallinfo=no
		fi
		;;
esac

dnl This has to be before AC_CHECK_FUNCS
# Disable poll() on certain platforms. Override by setting ac_cv_func_poll
# when running configure.
if test -z "$ac_cv_func_poll"; then
	case "$host" in
		[alpha-dec-osf3.*])
			# John Kay (jkay@nlanr.net) 19970818
			echo "disabling poll for $host..."
			ac_cv_func_poll='no'
			;;
		[*-hp-hpux*.*])
			# Duane Wessels
			echo "disabling poll for $host..."
			ac_cv_func_poll='no'
			;;
		[*-linux-*])
			# Henrik Nordstrom (hno@squid-cache.org) 19980817
			# poll is problematic on Linux.  We disable it
			# by default until Linux gets it right.
			# See also bug #932
			rev=`uname -r | awk -F. '{printf "%03d%03d",$1,$2}'`
			if test $rev -lt 002004; then
			    echo "disabling poll for $host < 2.4..."
			    ac_cv_func_poll='no'
			fi
			;;
		[powerpc-ibm-aix4.1.*])
			# Mike Laster (mlaster@metavillage.com) 19981021
			echo "disabling poll for $host..."
			ac_cv_func_poll='no'
			;;
		[*-pc-sco3.2*])
			# Robert Side <rside@aiinc.bc.ca>
			# Mon, 18 Jan 1999 17:48:00 GMT
			echo "disabling poll for $host..."
			ac_cv_func_poll='no'
			;;
	esac
fi

dnl Override statfs detect on MinGW because is emulated in source code
case "$host_os" in
mingw|mingw32)
	ac_cv_func_statfs='yes'
	;;
esac

dnl Check for library functions
AC_CHECK_FUNCS(\
	bcopy \
	backtrace_symbols_fd \
	fchmod \
	getdtablesize \
	getpagesize \
	getpass \
	getrusage \
	getspnam \
	gettimeofday \
	glob \
	kqueue \
	lrand48 \
	mallinfo \
	mallocblksize \
	MD5Init \
	mallopt \
	memcpy \
	memmove \
	memset \
	mkstemp \
	mktime \
	mstats \
	poll \
	prctl \
	pthread_attr_setscope \
	pthread_setschedparam \
	pthread_attr_setschedparam \
	pthread_sigmask \
	putenv \
	random \
	regcomp \
	regexec \
	regfree \
	res_init \
	__res_init \
	rint \
	sbrk \
	select \
	seteuid \
	setgroups \
	setpgrp \
	setrlimit \
	getrlimit \
	setsid \
	sigaction \
	snprintf \
	socketpair \
	srand48 \
	srandom \
	statfs \
	strsep \
	strtoll \
	sysconf \
	syslog \
	timegm \
	vsnprintf \
)

SAVED_LIBS="$LIBS"
LIBS="$LIBS $LIB_EPOLL"
AC_CHECK_FUNCS(epoll_ctl)
LIBS="$SAVED_LIBS"

SAVED_LIBS="$LIBS"
LIBS="$LIBS $CRYPTLIB"
AC_CHECK_FUNCS(crypt)
LIBS="$SAVED_LIBS"

dnl Verify that epoll really works
if test $ac_cv_func_epoll_ctl = yes; then
  AC_CACHE_CHECK(if epoll works, ac_cv_epoll_works,
    AC_TRY_RUN([
#include <sys/epoll.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
    int fd = epoll_create(256);
    if (fd < 0) {
	perror("epoll_create:");
	exit(1);
    }
    exit(0);
}
    ], [ac_cv_epoll_works=yes], [ac_cv_epoll_works=no]))
  if test ac_cv_epoll_works = no && test ac_force_epoll = yes; then
	echo "Error - no epoll found";
	echo "Try running 'sh ./scripts/get_epoll-lib.sh'";
	echo "then run configure again";
	exit -1
  fi
fi

dnl Magic which checks whether we are forcing a type of comm loop we
dnl are actually going to (ab)use

dnl Actually do the define magic now
dnl mostly ripped from squid-commloops, thanks to adrian and benno

if test -n "$SELECT_TYPE"; then
	: # Nothing to do
elif test "$ac_cv_epoll_works" = "yes" ; then
	SELECT_TYPE="epoll"
elif test "$ac_cv_func_kqueue" = "yes" ; then
	SELECT_TYPE="kqueue"
elif test "$ac_cv_func_poll" = "yes" ; then
	SELECT_TYPE="poll"
elif test "$ac_cv_func_select" = "yes" ; then
	case "$host_os" in
	mingw|mingw32)
		SELECT_TYPE="select_win32"
		;;
	*)
		SELECT_TYPE="select"
		;;
	esac
else
	echo "Eep!  Can't find poll, epoll, kqueue or select!"
	echo "I'll try select and hope for the best."
	SELECT_TYPE="select"
fi

echo "Using ${SELECT_TYPE} for the IO loop."
AM_CONDITIONAL([USE_POLL], [test $SELECT_TYPE = poll])
AM_CONDITIONAL([USE_EPOLL], [test $SELECT_TYPE = epoll])
AM_CONDITIONAL([USE_SELECT], [test $SELECT_TYPE = select])
AM_CONDITIONAL([USE_SELECT_SIMPLE], [test $SELECT_TYPE = select_simple])
AM_CONDITIONAL([USE_SELECT_WIN32], [test $SELECT_TYPE = select_win32])
AM_CONDITIONAL([USE_KQUEUE], [test $SELECT_TYPE = kqueue])
AM_CONDITIONAL([USE_DEVPOLL], [test $SELECT_TYPE = devpoll])


dnl Hmm.. some OS:es (i.e. FreeBSD) can't handle large AF_UNIX dgram packets.
dnl Verify that at least 16K is supported, if not fall back on using
dnl IP dgram sockets for IPC.
AC_CACHE_CHECK(if AF_UNIX dgram sockets support large packets, ac_cv_af_unix_large_dgram,
  AC_TRY_RUN([
#include <sys/types.h>
#include <sys/socket.h>
#if HAVE_SYS_SELECT_H
#include <sys/select.h>
#else
#include <sys/time.h>
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

#define BUFSIZE 16384
  void consumer(int s, int p)
  {
      fd_set fds;
      char buf[[BUFSIZE]];
      int len;
      int nfds = p > s ? p + 1 : s + 1;
      int rc;
      FD_ZERO(&fds);
      FD_SET(s, &fds);
      FD_SET(p, &fds);
      rc = select(nfds, &fds, NULL, NULL, NULL);
      if (rc < 0)
	    exit(1);
      if (FD_ISSET(s, &fds))
	  len = recv(s, buf, sizeof(buf), 0);
  }

  void sender(int s, int p)
  {
      char buf[[BUFSIZE]];
      int len = sizeof(buf);
      int rc = send(s, buf, len, 0);
      if (rc < 0) {
	  perror("send");
	  exit(1);
      }
      if (rc != len) {
	  fprintf(stderr, "Short send %d of %d\n", rc, len);
	  exit(1);
      }
  }

  int main(int argc, char **argv)
  {
      int s[[2]];
      int p[[2]];
      pid_t pid;
      socketpair(AF_UNIX, SOCK_DGRAM, 0, s);
      pipe(p);
      pid = fork();
      if (pid < 0) {
	  perror("fork");
	  exit(0);
      }
      if (pid == 0) {
	  close(s[[0]]);
	  close(p[[0]]);
	  consumer(s[[1]],p[[1]]);
      } else {
	  close(s[[1]]);
	  close(p[[1]]);
	  sender(s[[0]],p[[0]]);
      }
      return 0;
  }
  ], ac_cv_af_unix_large_dgram="yes",ac_cv_af_unix_large_dgram="no")
)
if test "$ac_cv_af_unix_large_dgram" = "yes" ; then
    AC_DEFINE(SUPPORTS_LARGE_AF_UNIX_DGRAM, 1, [Supports large dgram sockets over AF_UNIX sockets])
fi

dnl Yay!  Another Linux brokenness.  Its not good enough
dnl to know that setresuid() exists, because RedHat 5.0 declares
dnl setresuid() but doesn't implement it.
dnl
AC_CACHE_CHECK(if setresuid is implemented, ac_cv_func_setresuid,
  AC_TRY_RUN([
#include <stdlib.h>
  int main() {
    if(setresuid(-1,-1,-1)) {
      perror("setresuid:");
      exit(1);
    }
    exit(0);
  }
  ],ac_cv_func_setresuid="yes",ac_cv_func_setresuid="no")
)
if test "$ac_cv_func_setresuid" = "yes" ; then
  AC_DEFINE(HAVE_SETRESUID, 1, [Yay! Another Linux brokenness.  Its not good enough to know that
	setresuid() exists, because RedHat 5.0 declare setresuid() but
	doesn't implement it.])
fi

AM_CONDITIONAL(NEED_OWN_SNPRINTF, false)
if test "$ac_cv_func_snprintf" = "no" || test "$ac_cv_func_vsnprintf" = "no" ; then
  AM_CONDITIONAL(NEED_OWN_SNPRINTF, true)
fi

AM_CONDITIONAL(NEED_OWN_STRSEP, false)
if test "$ac_cv_func_strsep" = "no" ; then
  AM_CONDITIONAL(NEED_OWN_STRSEP, true)
fi

dnl
dnl Test for va_copy
dnl
AC_CACHE_CHECK(if va_copy is implemented, ac_cv_func_va_copy,
  AC_TRY_RUN([
      #include <stdarg.h>
      void f (int i, ...) {
	 va_list args1, args2;
	 va_start (args1, i);
	 va_copy (args2, args1);
	 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
	    exit (1);
	 va_end (args1); va_end (args2);
      }
      int main() {
	 f (0, 42);
	 return 0;
      }
      ],ac_cv_func_va_copy="yes",ac_cv_func_va_copy="no")
)
if test "$ac_cv_func_va_copy" = "yes" ; then
  AC_DEFINE(HAVE_VA_COPY, 1, [Some systems dont have va_copy])
fi

dnl
dnl Some systems support __va_copy
dnl
AC_CACHE_CHECK(if __va_copy is implemented, ac_cv_func___va_copy,
  AC_TRY_RUN([
      #include <stdarg.h>
      void f (int i, ...) {
	 va_list args1, args2;
	 va_start (args1, i);
	 __va_copy (args2, args1);
	 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
	    exit (1);
	 va_end (args1); va_end (args2);
      }
      int main() {
	 f (0, 42);
	 return 0;
      }
      ],ac_cv_func___va_copy="yes",ac_cv_func___va_copy="no")
)
if test "$ac_cv_func___va_copy" = "yes" ; then
  AC_DEFINE(HAVE___VA_COPY, 1, [Some systems support __va_copy])
fi

dnl IP-Filter support requires ipf header files. These aren't
dnl installed by default, so we need to check for them
if test "$IPF_TRANSPARENT" ; then
    AC_MSG_CHECKING(if IP-Filter header files are installed)
    # hold on to your hats...
    if test "$ac_cv_header_ip_compat_h" = "yes" ||
	test "$ac_cv_header_ip_fil_compat_h" = "yes" ||
	test "$ac_cv_header_netinet_ip_compat_h" = "yes" ||
	test "$ac_cv_header_netinet_ip_fil_compat_h" = "yes" ; then
	have_ipfilter_compat_header="yes"
     fi
     if test "x$have_ipfilter_compat_header" = "xyes" &&
       test "$ac_cv_header_ip_fil_h" = "yes" &&
       test "$ac_cv_header_ip_nat_h" = "yes" ; then
	IPF_TRANSPARENT="yes"
	AC_DEFINE(IPF_TRANSPARENT, 1, [Enable support for Transparent Proxy on systems using IP-Filter
	address redirection. This provides "masquerading" support for non
	Linux system.])
    elif test "$have_ipfilter_compat_header" = "yes" &&
	 test "$ac_cv_header_netinet_ip_fil_h" = "yes" &&
	 test "$ac_cv_header_netinet_ip_nat_h" = "yes" ; then
	IPF_TRANSPARENT="yes"
	AC_DEFINE(IPF_TRANSPARENT, 1, [Enable support for Transparent Proxy on systems using IP-Filter
	address redirection. This provides "masquerading" support for non
	Linux system.])
    else
	IPF_TRANSPARENT="no"
	AC_DEFINE(IPF_TRANSPARENT, 0, [Enable support for Transparent Proxy on systems using IP-Filter
	address redirection. This provides "masquerading" support for non
	Linux system.])
    fi
    AC_MSG_RESULT($IPF_TRANSPARENT)
fi 
if test "$IPF_TRANSPARENT" = "no" ; then
    echo "WARNING: Cannot find necessary IP-Filter header files"
    echo "         Transparent Proxy support WILL NOT be enabled"
    sleep 10
fi

dnl PF support requires a header file.
if test "$PF_TRANSPARENT" ; then
    AC_MSG_CHECKING(if PF header file is installed)
    # hold on to your hats...
    if test "$ac_cv_header_net_pfvar_h" = "yes"; then
	PF_TRANSPARENT="yes"
	AC_DEFINE(PF_TRANSPARENT, 1, [Enable support for Transparent Proxy on systems using PF address
	redirection. This provides "masquerading" support for OpenBSD.])
    else
	PF_TRANSPARENT="no"
	AC_DEFINE(PF_TRANSPARENT, 0, [Enable support for Transparent Proxy on systems using PF address
	redirection. This provides "masquerading" support for OpenBSD.])
    fi
    AC_MSG_RESULT($PF_TRANSPARENT)
fi
if test "$PF_TRANSPARENT" = "no" ; then
    echo "WARNING: Cannot find necessary PF header file"
    echo "         Transparent Proxy support WILL NOT be enabled"
    sleep 10
fi

dnl Linux-Netfilter support requires Linux 2.4 or newer kernel header files.
dnl Shamelessly copied from above
if test "$LINUX_NETFILTER" = "yes"; then
    AC_MSG_CHECKING(if Linux 2.4 or newer kernel header files are installed)
    # hold on to your hats...
    if test "$ac_cv_header_linux_netfilter_ipv4_h" = "yes"; then
	LINUX_NETFILTER="yes"
	AC_DEFINE(LINUX_NETFILTER, 1, [Enable support for Transparent Proxy on Linux (Netfilter) systems])
    else
	LINUX_NETFILTER="no"
	AC_DEFINE(LINUX_NETFILTER, 0, [Enable support for Transparent Proxy on Linux (Netfilter) systems])
    fi
    AC_MSG_RESULT($LINUX_NETFILTER)
fi 
if test "$LINUX_NETFILTER" = "no" ; then
    echo "WARNING: Cannot find necessary Linux kernel header files"
    echo "         Linux Netfilter Transparent Proxy support WILL NOT be enabled"
    sleep 10
fi

dnl Linux Netfilter/TPROXY support requires some specific header files and libcap
dnl Shamelessly copied from shamelessly copied from above
if test "$LINUX_TPROXY"; then
    AC_MSG_CHECKING(if TPROXY header files are installed)
    # hold on to your hats...
    if test "$ac_cv_header_linux_netfilter_ipv4_ip_tproxy_h" = "yes" && test "$LINUX_NETFILTER" = "yes"; then
	LINUX_TPROXY="yes"
	AC_DEFINE(LINUX_TPROXY, 1, [Enable real Transparent Proxy support for Netfilter TPROXY.])
    else
	LINUX_TPROXY="no"
	AC_DEFINE(LINUX_TPROXY, 0, [Enable real Transparent Proxy support for Netfilter TPROXY.])
    fi
    AC_MSG_RESULT($LINUX_TPROXY)
    if test "$use_libcap" != "yes"; then
       AC_MSG_WARN([Missing needed capabilities (libcap or libcap2) for TPROXY])
       LINUX_TPROXY="no"
       sleep 10
    fi
fi
if test "$LINUX_TPROXY" = "no" && test "$LINUX_NETFILTER" = "yes"; then
    echo "WARNING: Cannot find TPROXY headers, you need to patch your kernel with the"
    echo "tproxy package from:"
    echo " - lynx http://www.balabit.com/downloads/files/tproxy/"
    sleep 10
fi

if test -z "$USE_GNUREGEX" ; then
    case "$host" in
    *-sun-solaris2.[[0-4]])
	  USE_GNUREGEX="yes"
	  ;;
    *-next-nextstep*)
	  USE_GNUREGEX="yes"
	  ;;
    esac
fi
AC_MSG_CHECKING(if GNUregex needs to be compiled)
if test -z "$USE_GNUREGEX"; then
if test "$ac_cv_func_regcomp" = "no" || test "$USE_GNUREGEX" = "yes" ; then
	USE_GNUREGEX="yes"
else
	AC_TRY_COMPILE([#include <sys/types.h>
#include <regex.h>],[regex_t t; regcomp(&t,"",0);],
		USE_GNUREGEX="no",
		USE_GNUREGEX="yes")
fi
fi
AC_MSG_RESULT($USE_GNUREGEX)
if test "$USE_GNUREGEX" = "yes"; then
	REGEXLIB="-lregex"
	LIBREGEX="libregex.a"
	AC_DEFINE(USE_GNUREGEX, 1, [Define if we should use GNU regex])
fi
AC_SUBST(REGEXLIB)
AC_SUBST(LIBREGEX)

AC_REPLACE_FUNCS(\
	drand48 \
	tempnam \
	strerror \
	initgroups
)

dnl Not cached since people are likely to tune this
AC_MSG_CHECKING(Default FD_SETSIZE value)
AC_TRY_RUN([
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#if HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_WINSOCK_H
#include <winsock.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
main() {
	FILE *fp = fopen("conftestval", "w");
	fprintf (fp, "%d\n", FD_SETSIZE);
	exit(0);
}
],
DEFAULT_FD_SETSIZE=`cat conftestval`,
DEFAULT_FD_SETSIZE=256,
DEFAULT_FD_SETSIZE=256)
AC_MSG_RESULT($DEFAULT_FD_SETSIZE)
AC_DEFINE_UNQUOTED(DEFAULT_FD_SETSIZE, $DEFAULT_FD_SETSIZE, [Default FD_SETSIZE value])

AC_ARG_WITH(maxfd,
[  --with-maxfd=N          Override maximum number of filedescriptors. Useful
			  if you build as another user who is not privileged
			  to use the number of filedescriptors you want the
			  resulting binary to support],
[ case $withval in
  [[0-9]]*)
    SQUID_MAXFD=$withval
    echo "Maximum filedescriptors set to $SQUID_MAXFD"
    ;;
  *)
    echo "ERROR: Invalid --with-maxfd argument"
    exit 1
    ;;
  esac
])
if test -z "$SQUID_MAXFD"; then

dnl Not cached since people are likely to tune this
AC_MSG_CHECKING(Maximum number of filedescriptors we can open)
dnl damn! FreeBSD's pthreads breaks dup2().
TLDFLAGS="$LDFLAGS"
case $host in
i386-unknown-freebsd*)
    if echo "$LDFLAGS" | grep -q pthread; then
	LDFLAGS=`echo $LDFLAGS | sed -e "s/-pthread//"`
    fi
esac
AC_TRY_RUN([
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>	/* needed on FreeBSD */
#include <sys/param.h>
#include <sys/resource.h>
main() {
	FILE *fp;
	int i,j;
#if defined(__CYGWIN32__) || defined (__CYGWIN__)
    /* getrlimit and sysconf returns bogous values on cygwin32.
     * Number of fds is virtually unlimited in cygwin (sys/param.h)
     * __CYGWIN32__ is deprecated.
     */
    i = NOFILE;
#else
#if HAVE_SETRLIMIT
    struct rlimit rl;
#if defined(RLIMIT_NOFILE)
    if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
	perror("getrlimit: RLIMIT_NOFILE");
    } else {
	rl.rlim_cur = rl.rlim_max;      /* set it to the max */
	if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
	    perror("setrlimit: RLIMIT_NOFILE");
	}
    }
#elif defined(RLIMIT_OFILE)
    if (getrlimit(RLIMIT_OFILE, &rl) < 0) {
	perror("getrlimit: RLIMIT_OFILE");
    } else {
	rl.rlim_cur = rl.rlim_max;      /* set it to the max */
	if (setrlimit(RLIMIT_OFILE, &rl) < 0) {
	    perror("setrlimit: RLIMIT_OFILE");
	}
    }
#endif /* RLIMIT_NOFILE */
#endif /* HAVE_SETRLIMIT */
	/* by starting at 2^14, we will never get higher
	than 2^15 for SQUID_MAXFD */
	i = j = 1<<14;
	while (j) {
		j >>= 1;
		if (dup2(0, i) < 0) { 
			i -= j;
		} else {
			close(i);
			i += j;
		}
	}
	i++;
#endif /* IF !DEF CYGWIN */
	fp = fopen("conftestval", "w");
	fprintf (fp, "%d\n", i & ~0x3F);
	exit(0);
}
],
SQUID_MAXFD=`cat conftestval`,
SQUID_MAXFD=256,
SQUID_MAXFD=256)
dnl Microsoft MSVCRT.DLL supports 2048 maximum FDs
case "$host_os" in
mingw|mingw32)
  SQUID_MAXFD="2048"
  ;;
esac
AC_MSG_RESULT($SQUID_MAXFD)
fi # --with-maxfd SQUID_MAXFD
AC_DEFINE_UNQUOTED(SQUID_MAXFD, $SQUID_MAXFD, [Maximum number of open filedescriptors])
if test "$SQUID_MAXFD" -lt 512 ; then
    echo "WARNING: $SQUID_MAXFD may not be enough filedescriptors if your"
    echo "         cache will be very busy.  Please see the FAQ page"
    echo "         http://www.squid-cache.org/FAQ/FAQ-11.html#filedescriptors"
    echo "         on how to increase your filedescriptor limit"
    sleep 10
fi
LDFLAGS="$TLDFLAGS"

dnl Not cached since people are likely to tune this
AC_MSG_CHECKING(Default UDP send buffer size)
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_WINSOCK_H
#include <winsock.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
main ()
{
	FILE *fp;
	int fd,val=0,len=sizeof(int);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSADATA wsaData;
	WSAStartup(2, &wsaData);
#endif
	if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) exit(1);
	if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) exit(1);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSACleanup();
#endif
	if (val<=0) exit(1);
	fp = fopen("conftestval", "w");
	fprintf (fp, "%d\n", val);
	exit(0);
}
],
SQUID_UDP_SO_SNDBUF=`cat conftestval`,
SQUID_UDP_SO_SNDBUF=16384,
SQUID_UDP_SO_SNDBUF=16384)
AC_MSG_RESULT($SQUID_UDP_SO_SNDBUF)
AC_DEFINE_UNQUOTED(SQUID_UDP_SO_SNDBUF, $SQUID_UDP_SO_SNDBUF, [UDP send buffer size])

dnl Not cached since people are likely to tune this
AC_MSG_CHECKING(Default UDP receive buffer size)
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_WINSOCK_H
#include <winsock.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
main ()
{
	FILE *fp;
	int fd,val=0,len=sizeof(int);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSADATA wsaData;
	WSAStartup(2, &wsaData);
#endif
	if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) exit(1);
	if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) exit(1);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSACleanup();
#endif
	if (val <= 0) exit(1);
	fp = fopen("conftestval", "w"); 
	fprintf (fp, "%d\n", val);
	exit(0);
}
],
SQUID_UDP_SO_RCVBUF=`cat conftestval`,
SQUID_UDP_SO_RCVBUF=16384,
SQUID_UDP_SO_RCVBUF=16384)
AC_MSG_RESULT($SQUID_UDP_SO_RCVBUF)
AC_DEFINE_UNQUOTED(SQUID_UDP_SO_RCVBUF, $SQUID_UDP_SO_RCVBUF, [UDP receive buffer size])

dnl Not cached since people are likely to tune this
AC_MSG_CHECKING(Default TCP send buffer size)
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_WINSOCK_H
#include <winsock.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
main ()
{
	FILE *fp;
	int fd,val=0,len=sizeof(int);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSADATA wsaData;
	WSAStartup(2, &wsaData);
#endif
	if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) exit(1);
	if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) exit(1);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSACleanup();
#endif
	if (val <= 0) exit(1);
	fp = fopen("conftestval", "w"); 
	fprintf (fp, "%d\n", val);
	exit(0);
}
],
SQUID_TCP_SO_SNDBUF=`cat conftestval`,
SQUID_TCP_SO_SNDBUF=16384,
SQUID_TCP_SO_SNDBUF=16384)
AC_MSG_RESULT($SQUID_TCP_SO_SNDBUF)
if test $SQUID_TCP_SO_SNDBUF -gt 32768; then
    echo "Limiting send buffer size to 32K"
    SQUID_TCP_SO_SNDBUF=32768
fi
AC_DEFINE_UNQUOTED(SQUID_TCP_SO_SNDBUF, $SQUID_TCP_SO_SNDBUF, [TCP send buffer size])

dnl Not cached since people are likely to tune this
AC_MSG_CHECKING(Default TCP receive buffer size)
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_WINSOCK_H
#include <winsock.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
main ()
{
	FILE *fp;
	int fd,val=0,len=sizeof(int);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSADATA wsaData;
	WSAStartup(2, &wsaData);
#endif
	if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) exit(1);
	if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) exit(1);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSACleanup();
#endif
	if (val <= 0) exit(1);
	fp = fopen("conftestval", "w"); 
	fprintf (fp, "%d\n", val);
	exit(0);
}
],
SQUID_TCP_SO_RCVBUF=`cat conftestval`,
SQUID_TCP_SO_RCVBUF=16384,
SQUID_TCP_SO_RCVBUF=16384)
AC_MSG_RESULT($SQUID_TCP_SO_RCVBUF)
if test $SQUID_TCP_SO_RCVBUF -gt 65535; then
    echo "Limiting receive buffer size to 64K"
    SQUID_TCP_SO_RCVBUF=65535
fi
AC_DEFINE_UNQUOTED(SQUID_TCP_SO_RCVBUF, $SQUID_TCP_SO_RCVBUF, [TCP receive buffer size])
AC_CACHE_CHECK(if sys_errlist is already defined, ac_cv_needs_sys_errlist,
  AC_TRY_COMPILE([#include <stdio.h>],[char *s = sys_errlist;],
    ac_cv_needs_sys_errlist="no",
    ac_cv_needs_sys_errlist="yes")
)
if test "$ac_cv_needs_sys_errlist" = "yes" ; then
  AC_DEFINE(NEED_SYS_ERRLIST, 1, [If we need to declare sys_errlist[] as external])
fi

AC_MSG_CHECKING(if inet_ntoa() actually works)
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
main ()
{
	FILE *fp;
	struct in_addr in;
	in.s_addr = inet_addr("1.2.3.4");
	fp = fopen("conftestval", "w"); 
	fprintf (fp, "%s\n", inet_ntoa(in));
	exit(0);
}
],
INET_NTOA_RESULT=`cat conftestval`,
INET_NTOA_RESULT="broken",
INET_NTOA_RESULT="broken")
if test "$INET_NTOA_RESULT" = "1.2.3.4" ; then
	AC_MSG_RESULT("yes")
else
	AC_MSG_RESULT("no")
	case "$host_os" in
	mingw|mingw32)
	    echo "Using Win32 resolver instead."
	    ;;
	    *)      
	    echo "Will use our own inet_ntoa()."
	    # autoconf-2.13 needs the lines below switched
#	    LIBOBJS="$LIBOBJS inet_ntoa.o"
	    AC_LIBOBJ(inet_ntoa)
#	    echo "WARNING: This looks bad, and probably prevents Squid from working."
#	    echo "         If you're on IRIX and using GCC 2.8, you probably need"
#	    echo "         to use the IRIX C compiler instead."
#	    sleep 10
	;;
	esac
fi

if test "$ac_cv_header_sys_statvfs_h" = "yes" ; then
AC_MSG_CHECKING(for working statvfs() interface)
AC_TRY_COMPILE([
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/statvfs.h>
],
[
struct statvfs sfs;
fsblkcnt_t blocks;
fsfilcnt_t files;
blocks = sfs.f_blocks = sfs.f_bfree = sfs.f_frsize = 0;
files = sfs.f_files = sfs.f_ffree = 0;
statvfs("/tmp", &sfs);
],
  ac_cv_func_statvfs=yes,
  ac_cv_func_statvfs=no)
AC_MSG_RESULT($ac_cv_func_statvfs)
if test "$ac_cv_func_statvfs" = "yes" ; then
  AC_DEFINE(HAVE_STATVFS, 1, [If your system has statvfs(), and if it actually works!])
fi
fi

AC_CACHE_CHECK(for _res.nsaddr_list, ac_cv_have_res_nsaddr_list,
AC_TRY_COMPILE([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#if HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#if HAVE_RESOLV_H
#include <resolv.h>
#endif
],
[_res.nsaddr_list[[0]];],
ac_cv_have_res_nsaddr_list="yes",
ac_cv_have_res_nsaddr_list="no"))
if test $ac_cv_have_res_nsaddr_list = "yes" ; then
  AC_DEFINE(HAVE_RES_NSADDR_LIST, 1, [If _res structure has nsaddr_list member])
fi

if test $ac_cv_have_res_nsaddr_list = "no" ; then
AC_CACHE_CHECK(for _res.ns_list, ac_cv_have_res_ns_list,
AC_TRY_COMPILE([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#if HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#if HAVE_RESOLV_H
#include <resolv.h>
#endif
],
[_res.ns_list[[0]].addr;],
ac_cv_have_res_ns_list="yes",
ac_cv_have_res_ns_list="no"))
if test $ac_cv_have_res_ns_list = "yes" ; then
  AC_DEFINE(HAVE_RES_NS_LIST, 1, [If _res structure has ns_list member])
fi
fi

dnl Need the debugging version of malloc if available
XTRA_OBJS=''
if test "$ac_cv_lib_malloc_main" = "yes" ; then
	if test -r /usr/lib/debug/malloc.o ; then
		XTRA_OBJS="$XTRA_OBJS /usr/lib/debug/malloc.o"
	fi
	if test -r /usr/lib/debug/mallocmap.o ; then
		XTRA_OBJS="$XTRA_OBJS /usr/lib/debug/mallocmap.o"
	fi
fi

AC_SUBST(XTRA_OBJS)

if test -z "$XTRA_LIBS"; then
	XTRA_LIBS="$LIBS"
	dnl minor cleanup
	XTRA_LIBS=`echo $XTRA_LIBS | sed -e "s/  */ /g"`
	LIBS=''
fi
AC_SUBST(XTRA_LIBS)

dnl Clean up after OSF/1 core dump bug
rm -f core 

dnl FS_MAKEFILES=""
dnl for fs in $STORE_MODULES none; do
dnl 	if test $fs != none; then
dnl	    FS_MAKEFILES="$FS_MAKEFILES ./src/fs/$fs/Makefile"
dnl 	fi
dnl done
dnl REPL_MAKEFILES=""
dnl for repl in $REPL_POLICIES none; do
dnl 	if test $repl != none; then
dnl 	    REPL_MAKEFILES="$REPL_MAKEFILES ./src/repl/$repl/Makefile"
dnl 	fi
dnl done

dnl This could actually be used to find all the Makefiles..
dnl One of Automake's limitations is that it needs to know all the created makefiles.
dnl AUTH_MAKEFILES=""
dnl for auth in `find $srcdir/src/auth -type d -print`; do
dnl 	if test -f $auth/Makefile.in; then
dnl	    dir=`echo $auth | sed -e "s|^$srcdir/||"`
dnl            AUTH_MAKEFILES="$AUTH_MAKEFILES ./$dir/Makefile"
dnl	fi
dnl done


AC_OUTPUT([\
	Makefile \
	lib/Makefile \
	scripts/Makefile \
	scripts/RunCache \
	src/Makefile \
	src/fs/Makefile \
	src/repl/Makefile \
	src/auth/Makefile \
	contrib/Makefile \
	snmplib/Makefile \
	icons/Makefile \
	errors/Makefile \
	doc/Makefile \
	helpers/Makefile \
	helpers/basic_auth/Makefile \
	helpers/basic_auth/LDAP/Makefile \
	helpers/basic_auth/MSNT/Makefile \
	helpers/basic_auth/NCSA/Makefile \
	helpers/basic_auth/PAM/Makefile \
	helpers/basic_auth/SMB/Makefile \
	helpers/basic_auth/YP/Makefile \
	helpers/basic_auth/getpwnam/Makefile \
	helpers/basic_auth/mswin_sspi/Makefile \
	helpers/basic_auth/multi-domain-NTLM/Makefile \
	helpers/basic_auth/SASL/Makefile \
	helpers/basic_auth/POP3/Makefile \
	helpers/basic_auth/DB/Makefile \
	helpers/basic_auth/squid_radius_auth/Makefile \
	helpers/digest_auth/Makefile \
	helpers/digest_auth/password/Makefile \
	helpers/digest_auth/ldap/Makefile \
	helpers/digest_auth/eDirectory/Makefile \
	helpers/ntlm_auth/Makefile \
	helpers/ntlm_auth/fakeauth/Makefile \
	helpers/ntlm_auth/mswin_sspi/Makefile \
	helpers/ntlm_auth/no_check/Makefile \
	helpers/ntlm_auth/SMB/Makefile \
	helpers/ntlm_auth/SMB/smbval/Makefile \
	helpers/negotiate_auth/Makefile \
	helpers/negotiate_auth/mswin_sspi/Makefile \
	helpers/negotiate_auth/squid_kerb_auth/Makefile \
	helpers/external_acl/Makefile \
	helpers/external_acl/ip_user/Makefile \
	helpers/external_acl/ldap_group/Makefile \
	helpers/external_acl/mswin_ad_group/Makefile \
	helpers/external_acl/mswin_lm_group/Makefile \
	helpers/external_acl/session/Makefile \
	helpers/external_acl/unix_group/Makefile \
	helpers/external_acl/wbinfo_group/Makefile \
	tools/Makefile \
])
