]> git.ipfire.org Git - thirdparty/squid.git/blame - configure.ac
Discarded connections do not contribute to forward_max_tries (#1093)
[thirdparty/squid.git] / configure.ac
CommitLineData
bf95c10a 1## Copyright (C) 1996-2022 The Squid Software Foundation and contributors
5d2e6f19
AJ
2##
3## Squid software is distributed under GPLv2+ license and includes
4## contributions from numerous individuals and organizations.
5## Please see the COPYING and CONTRIBUTORS files for details.
6##
7
a8b7dd82 8AC_INIT([Squid Web Proxy],[6.0.0-VCS],[http://bugs.squid-cache.org/],[squid])
d966027f 9AC_PREREQ(2.61)
62979ab1 10AC_CONFIG_HEADERS([include/autoconf.h])
71b12d7c 11AC_CONFIG_AUX_DIR(cfgaux)
8d9ce05e 12AC_CONFIG_SRCDIR([src/main.cc])
3dc6f003 13AM_INIT_AUTOMAKE([tar-ustar nostdinc subdir-objects dist-xz])
c2720d44 14AC_REVISION($Revision$)dnl
a2794549 15AC_PREFIX_DEFAULT(/usr/local/squid)
246d7ffc 16AM_MAINTAINER_MODE
a2794549 17
5d2e6f19 18m4_include([acinclude/ax_with_prog.m4])
4ecf021b 19m4_include([acinclude/init.m4])
fa522425 20m4_include([acinclude/squid-util.m4])
6a56798f 21m4_include([acinclude/compiler-flags.m4])
0abb39dd 22m4_include([acinclude/os-deps.m4])
c8093f05 23m4_include([acinclude/krb5.m4])
3c586e38 24m4_include([acinclude/pam.m4])
2b448046 25m4_include([acinclude/pkg.m4])
acd207af 26m4_include([acinclude/tdb.m4])
91983da0 27m4_include([acinclude/lib-checks.m4])
ea1cf567 28m4_include([acinclude/ax_cxx_compile_stdcxx_11.m4])
a203dec7 29m4_include([acinclude/ax_cxx_0x_types.m4])
6a56798f 30
63e02610 31PRESET_CFLAGS="$CFLAGS"
a203dec7 32PRESET_CXXFLAGS="$CXXFLAGS"
63e02610 33PRESET_LDFLAGS="$LDFLAGS"
34
a2794549 35dnl Set default LDFLAGS
fcabe077 36if test "x$LDFLAGS" = "x" ; then
73862432 37 LDFLAGS="-g"
a2794549 38fi
39
aff48cc8 40# Check for GNU cc
a2794549 41AC_PROG_CC
e6c4cdd6 42AM_PROG_CC_C_O
29b8d8d6 43AC_PROG_CXX
62979ab1 44AC_LANG([C++])
88d50a22 45AC_CANONICAL_HOST
3e7b6055 46
c8640c9a
AJ
47# Clang 3.2 on some CPUs requires -march-native to detect correctly.
48# GCC 4.3+ can also produce faster executables when its used.
49# But building inside a virtual machine environment has been found to
50# cause random Illegal Instruction errors due to mis-detection of CPU.
51AC_ARG_ENABLE(arch-native,
52 AS_HELP_STRING([--disable-arch-native],[Some compilers offer CPU-specific
53 optimizations with the -march=native parameter.
54 This flag disables the optimization. The default is to
55 auto-detect compiler support and use where available.]), [
56 SQUID_YESNO([$enableval],
57 [Unrecognized argument to --disable-arch-native: $enableval])
58])
d8a4ba7c 59AC_MSG_NOTICE([CPU arch native optimization enabled: ${enable_arch_native:=auto}])
c8640c9a
AJ
60if test "x${enable_arch_native}" != "xno"; then
61 SQUID_CC_CHECK_ARGUMENT([squid_cv_check_marchnative],[-march=native])
62fi
e9d3951b
AJ
63
64# might be cross-compiling.
b2f0a375
AJ
65# NP: BUILDCXXFLAGS defined at the end of configure after CXXFLAGS fully known.
66AC_ARG_VAR([BUILDCXX],[path to compiler for building compile-time tools. e.g. cf_gen])
67if test "x$HOSTCXX" != "x" -a "x$BUILDCXX" = "x"; then
68 AC_MSG_WARN([Cross-compiling with HOSTCXX is deprecated. Uses BUILDCXX instead.])
69 BUILDCXX="$HOSTCXX"
70fi
71if test "x$BUILDCXX" = "x"; then
72 BUILDCXX="$CXX"
e9d3951b
AJ
73 if test "x$squid_cv_check_marchnative" = "xyes"; then
74 CXXFLAGS="$CXXFLAGS -march=native"
75 fi
76fi
b2f0a375 77AC_SUBST(BUILDCXX)
de051d9d 78
40503c27 79AC_MSG_CHECKING([simplified host os])
78a60bca 80simple_host_os=`echo $host_os|sed 's/[0-9].*//g;s/-.*//g'`
035a321e 81squid_host_os_version=`echo $host_os|tr -d "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-"`
6ca34f6f
HN
82if test -n "$squid_host_os_version"; then
83 squid_host_os="`echo $simple_host_os| sed s/$squid_host_os_version//g`"
84else
85 squid_host_os="$simple_host_os"
86fi
40503c27
FC
87AC_MSG_RESULT($squid_host_os (version $squid_host_os_version))
88# on windows squid_host_os is either mingw or cygwin, version is 32
89
b2b60232
FC
90# this needs to be before any test is run, to have more standard
91# functions available on some Unix sysems (e.g. Solaris)
92if test "x$squid_host_os" = "solaris" -a "x$GCC" != "x" ; then
93 AC_USE_SYSTEM_EXTENSIONS
94fi
95
8b082ed9
FC
96AC_MSG_CHECKING([compiler name-version])
97squid_cv_cc_name=`$CC --version | head -1 | cut -f1 -d" "`
98AS_CASE([$squid_cv_cc_name],
99 [gcc|clang],[squid_cv_cc_majversion=`$CC -dumpversion | cut -f1 -d.`],
100 [squid_cv_cc_majversion="unknown"]
101)
102squid_cv_cc_simplified="$squid_cv_cc_name-$squid_cv_cc_majversion"
103AC_MSG_RESULT($squid_cv_cc_simplified)
104
105# warning flags
106AS_IF([test "$squid_cv_cc_simplified" = "gcc-4"],[
107 AC_MSG_NOTICE([skipping -Wextra on $squid_cv_cc_simplified])
108],[
109 # -Werror must be first
110 SQUID_CC_ADD_CXXFLAG_IF_SUPPORTED([-Werror])
111 SQUID_CC_ADD_CXXFLAG_IF_SUPPORTED([-Wextra])
112 # -Wunused-private-field causes a huge number of false positives
113 # in unit tests. Disable that
114 SQUID_CC_ADD_CXXFLAG_IF_SUPPORTED([-Wno-unused-private-field])
115 # ...=2: This flexibility level allows GCC to "understand" our fallthrough
116 # comments. TODO: Switch to [[fallthrough]] attributes with C++17.
117 SQUID_CC_ADD_CXXFLAG_IF_SUPPORTED([-Wimplicit-fallthrough=2])
118 AS_IF([test "x$squid_cv_cc_implicit_fallthrough2" = "xno"], [
119 SQUID_CC_ADD_CXXFLAG_IF_SUPPORTED([-Wno-implicit-fallthrough])
120 ])
121])
79987b1a
AJ
122# If the user did not specify a C++ version.
123user_cxx=`echo "$PRESET_CXXFLAGS" | grep -o -E "\-std="`
124if test "x$user_cxx" = "x"; then
125 # Check for C++11 compiler support
126 AX_CXX_COMPILE_STDCXX_11([noext],[mandatory])
127fi
a203dec7 128
aff48cc8 129# test for programs
aff48cc8
FC
130AC_PROG_RANLIB
131AC_PROG_CPP
132AC_PROG_INSTALL
133AC_PROG_LN_S
134AC_PROG_EGREP
135
136AC_PATH_PROG(SH, sh, /bin/sh)
137AC_PATH_PROG(FALSE, false, /usr/bin/false)
138AC_PATH_PROG(TRUE, true, /usr/bin/true)
139AC_PATH_PROG(MV, mv, $FALSE)
140AC_PATH_PROG(MKDIR, mkdir, $FALSE)
141AC_PATH_PROG(LN, ln, cp)
142AC_PATH_PROG(CHMOD, chmod, $FALSE)
6d1c1ab1 143AC_PATH_PROG(TR, tr, $FALSE)
aff48cc8
FC
144AC_PATH_PROG(RM, rm, $FALSE)
145dnl Libtool 2.2.6 requires: rm -f
146RM="$RM -f"
147
d93bf055
AJ
148PKG_PROG_PKG_CONFIG
149
aff48cc8 150AC_PATH_PROG(PERL, perl, none)
fcabe077 151if test "x$ac_cv_path_PERL" = "xnone"; then
aff48cc8
FC
152 AC_MSG_FAILURE([Perl is required to compile Squid. Please install Perl and then re-run configure ])
153fi
07f370ee 154AC_PATH_PROG(POD2MAN, pod2man, $FALSE)
33d1abfe 155AM_CONDITIONAL(ENABLE_POD2MAN_DOC, test "x${ac_cv_path_POD2MAN}" != "x$FALSE")
aff48cc8 156
52c549d9
AJ
157dnl set $(AR) if not provided by the build environment
158if test "x$AR" = "x"; then
159 AC_PATH_PROG(AR, ar, $FALSE)
160fi
aff48cc8 161AR_R="$AR r"
aff48cc8
FC
162AC_SUBST(AR_R)
163
86b8d400
AJ
164AC_PATH_PROG(LINUXDOC, linuxdoc, $FALSE)
165AM_CONDITIONAL(ENABLE_RELEASE_DOCS, test "x${ac_cv_path_LINUXDOC}" != "x$FALSE")
166
cda5e747
AJ
167# pre-define DEFAULT_PREFIX, some modules need it.
168if test "${prefix}" = "NONE" ; then
169 squid_prefix=$ac_default_prefix
170else
171 squid_prefix=$prefix
172fi
173AC_DEFINE_UNQUOTED(DEFAULT_PREFIX,[$squid_prefix],[The install prefix])
174
0b45d157
FC
175AC_ARG_ENABLE(strict-error-checking,
176 AS_HELP_STRING([--disable-strict-error-checking],[By default squid is compiled
2d65bb9a 177 with all possible static compiler error-checks enabled.
cdb352bb
FC
178 This flag disables the behavior]), [
179 SQUID_YESNO([$enableval],
180 [Unrecognized argument to --disable-strict-error-checking: $enableval])
0b45d157 181])
cdb352bb 182AC_MSG_NOTICE([strict error checking enabled: ${enable_strict_error_checking:=yes}])
d1f95b42 183
4313559d 184# LT_INIT requires libtool v2, might as well state it loud
2663a9c8 185LT_PREREQ([2.2])
5a2409b7 186LT_INIT([dlopen])
2148ef58
AJ
187if ! test "${ac_top_build_prefix}" = "";
188then
189 # LTDL v3-v7 macros assume the autoconf 2.62 variable top_build_prefix is defined
190 # But from autoconf 2.64 its called ac_top_build_prefix and not automatically added to the Makefile
191 # This fixes Linux LTDLv3-v7, and BSD LTDL v2.2
192 top_build_prefix=${ac_top_build_prefix}
193 AC_SUBST(top_build_prefix)
194fi
bd9303f5 195LTDL_INIT
081863f3 196
d9a41469 197dnl LibTool environment is now prepared for setup. Check that it is usable and initialize.
081863f3 198LT_LIB_DLLOAD
3e7b6055
AR
199
200# Do we need these unconditionally for "make distcheck" to work?
201AC_SUBST(INCLTDL)
202AC_SUBST(LIBLTDL)
203
5a2409b7
AJ
204AC_MSG_CHECKING(whether to use loadable modules)
205AS_IF([test "x${enable_shared:=yes}" = "xyes"],[AC_DEFINE(USE_LOADABLE_MODULES,1,[Support Loadable Modules])])
206AM_CONDITIONAL(ENABLE_LOADABLE_MODULES, test "x${enable_shared:=yes}" = "xyes")
207AC_MSG_RESULT([$enable_shared])
208
07f370ee 209SQUID_CC_GUESS_VARIANT
fa6307ae 210SQUID_CC_GUESS_OPTIONS
f9d138eb 211
be0c7ff0
FC
212dnl find out the exe extension for this platform.
213dnl If it is not empty, use it for CGI as well.
a2794549 214AC_EXEEXT
215AC_OBJEXT
216
fcabe077
FC
217if test "x$EXEEXT" = "x" ; then
218 CGIEXT=".cgi"
a2794549 219else
fcabe077
FC
220 # automake automatically adds .exe when installing binaries
221 CGIEXT=""
a2794549 222fi
7aeb8001 223AC_SUBST(CGIEXT)
a2794549 224
a396d1f8 225AM_CONDITIONAL(ENABLE_WIN32SPECIFIC,[test "x$squid_host_os" = "xmingw"])
daf2ddfa 226AM_CONDITIONAL(ENABLE_WIN32_IPC,[test "x$squid_host_os" = "xmingw"])
fcabe077 227
b5467222
CT
228case "$squid_host_os" in
229mingw)
fcabe077
FC
230 AC_PATH_PROG(WIN32_PSAPI, psapi.dll, none)
231 CFLAGS="$CFLAGS -mthreads"
d66b42da 232 CXXFLAGS="$CXXFLAGS -mthreads -static-libgcc -static-libstdc++"
fcabe077
FC
233 if test "x$ac_cv_path_WIN32_PSAPI" = "xnone"; then
234 AC_MSG_NOTICE([PSAPI.DLL is recommended to run Squid on Windows NT Platform])
235 AC_MSG_NOTICE([Please see PSAPI.DLL section on doc/win32-relnotes.html.])
236 else
237 AC_DEFINE(HAVE_WIN32_PSAPI,1,[Define if you have PSAPI.DLL on Windows systems])
238 LIBS="$LIBS -lpsapi"
239 fi
240 MINGW_LIBS="-lmingwex"
241 AC_SUBST(MINGW_LIBS)
b5467222
CT
242 ;;
243freebsd)
244 # FreeBSD places local libraries and packages in /usr/local
245 CFLAGS="$CFLAGS -I/usr/local/include"
246 CXXFLAGS="$CXXFLAGS -I/usr/local/include"
247 LDFLAGS="$LDFLAGS -L/usr/local/lib -Wl,-R/usr/local/lib"
248 ;;
249*)
250 ;;
251esac
4b26fae9 252
f4aaf39c 253dnl Substitutions
6a9f6389 254AC_DEFINE_UNQUOTED(CONFIG_HOST_TYPE, "$host",[Host type from configure])
30a4f2a8 255
9603207d 256AC_DEFINE_UNQUOTED(SQUID_CONFIGURE_OPTIONS, "$ac_configure_args",
8075a4da 257 [configure command line used to configure Squid])
090089c4 258
5483d916 259CACHE_EFFECTIVE_USER="nobody"
260AC_ARG_WITH(default-user,
62979ab1 261 AS_HELP_STRING([--with-default-user=USER],[System user account for squid permissions. Default: nobody]),
5483d916 262 [ CACHE_EFFECTIVE_USER="$withval" ]
263)
264AC_SUBST(CACHE_EFFECTIVE_USER)
265
c8d2dc9b
AJ
266DEFAULT_LOG_DIR="$localstatedir/logs"
267AC_ARG_WITH(logdir,
73862432 268 AS_HELP_STRING([--with-logdir=PATH],
cdb352bb 269 [Default location for squid logs. default: PREFIX/var/logs]), [
73862432
FC
270case $withval in
271 yes|no)
272 AC_MSG_ERROR( --with-logdir requires a directory PATH. --with-logdir=PATH )
273 ;;
274 *)
275 DEFAULT_LOG_DIR="$withval"
276 ;;
277esac
c8d2dc9b
AJ
278 ]
279)
280AC_SUBST(DEFAULT_LOG_DIR)
281
2f36643c 282DEFAULT_PID_FILE="$localstatedir/run/@SERVICE_NAME@.pid"
a7f6af35 283AC_ARG_WITH(pidfile,
e0eb5853 284 AS_HELP_STRING([--with-pidfile=PATH],
cdb352bb 285 [Default location for squid pid file. Default: PREFIX/var/run/squid.pid]), [
73862432
FC
286case $withval in
287 yes|no)
288 AC_MSG_ERROR( --with-pidfile requires a file PATH. --with-pidfile=PATH )
289 ;;
290 *)
32f07882 291 DEFAULT_PID_FILE="$withval"
73862432
FC
292 ;;
293 esac
e0eb5853 294])
32f07882 295AC_SUBST(DEFAULT_PID_FILE)
a7f6af35 296
bf52b026
AJ
297DEFAULT_SWAP_DIR="$localstatedir/cache/squid"
298AC_ARG_WITH(swapdir,
299 AS_HELP_STRING([--with-swapdir=PATH],
300 [Default location for squid cache directories. Default: PREFIX/var/cache/squid]), [
301case $withval in
302 yes|no)
303 AC_MSG_ERROR( --with-swapdir requires a directory PATH. --with-swapdir=PATH )
304 ;;
305 *)
306 DEFAULT_SWAP_DIR="$withval"
307 ;;
308 esac
309])
310AC_SUBST(DEFAULT_SWAP_DIR)
311
30a4f2a8 312dnl Set Default CFLAGS
fcabe077 313if test "x$PRESET_CFLAGS" = "x"; then
f70e69c6 314 if test "$squid_cv_compiler" = "gcc"; then
fcabe077
FC
315 case "$host" in
316 *-sun-sunos*)
317 # sunos has too many warnings for this to be useful
fcabe077
FC
318 ;;
319 *)
320 CFLAGS="$squid_cv_cc_option_wall $CFLAGS"
321 ;;
322 esac
323 else
324 case "$host" in
325 *mips-sgi-irix6.*)
326 # suggested by Rafael Seidl <rafaels@cthulhu.engr.sgi.com>
327 CFLAGS="$squid_cv_cc_option_optimize -OPT:Olimit=0:space=OFF \
328 -woff 1009,1014,1110,1116,1183,1185,1188,1204,1230,1233,1355 \
329 -Wl,-woff,85,-woff,84,-woff,134 \
330 -nostdinc -I/usr/include -D_BSD_SIGNALS $CFLAGS"
331 CXXFLAGS="$squid_cv_cc_option_optimize -OPT:Olimit=0:space=OFF \
332 -woff 1009,1014,1110,1116,1183,1185,1188,1204,1230,1233,1355 \
333 -Wl,-woff,85,-woff,84,-woff,134 \
334 -nostdinc -I/usr/include -D_BSD_SIGNALS $CXXFLAGS"
335 ;;
30a4f2a8 336 *)
fcabe077
FC
337 ;;
338 esac
339 fi
30a4f2a8 340fi
341
8b082ed9
FC
342# useful warnings that may not be included in -Wall -Wextra
343SQUID_CC_ADD_CXXFLAG_IF_SUPPORTED([-Wpointer-arith])
344SQUID_CC_ADD_CXXFLAG_IF_SUPPORTED([-Wwrite-strings])
345SQUID_CC_ADD_CXXFLAG_IF_SUPPORTED([-Wcomments])
346SQUID_CC_ADD_CXXFLAG_IF_SUPPORTED([-Wshadow])
347SQUID_CC_ADD_CXXFLAG_IF_SUPPORTED([-Wmissing-declarations])
8f6df489 348SQUID_CC_ADD_CXXFLAG_IF_SUPPORTED([-Woverloaded-virtual])
07f370ee 349
05c9db69 350dnl CentOS (and RHEL) still define ntohs() using deprecated C++ features
629cb141 351SQUID_CC_REQUIRE_ARGUMENT([ac_cv_require_wno_deprecated_register],[-Werror -Wno-deprecated-register],[[#include <arpa/inet.h>]],[[int fox=ntohs(1);]])
05c9db69 352
cdb352bb 353if test "x$enable_strict_error_checking" != "xno"; then
fcabe077 354 SQUID_CFLAGS="$SQUID_CFLAGS $squid_cv_cc_option_werror"
59a09b98 355 SQUID_CXXFLAGS="$SQUID_CXXFLAGS $squid_cv_cxx_option_werror"
07f370ee
FC
356fi
357
0568bff2 358if test "x$ac_cv_require_wno_deprecated_register" = "xyes"; then
359 SQUID_CXXFLAGS="$SQUID_CXXFLAGS -Wno-deprecated-register"
360fi
361
e0eb5853
FC
362# squid_cv_cc_arg_pipe is set by SQUID_CC_GUESS_OPTIONS
363SQUID_CXXFLAGS="$SQUID_CXXFLAGS $squid_cv_cc_arg_pipe"
364SQUID_CFLAGS="$SQUID_CFLAGS $squid_cv_cc_arg_pipe"
2060fa9a 365
4fe75473
FC
366# possibly include some build info tag into squid -v
367SQUID_EMBED_BUILD_INFO
368
83079644 369AC_ARG_ENABLE(optimizations,
ffa3bad9 370 AS_HELP_STRING([--disable-optimizations],
be0c7ff0 371 [Do not compile Squid with compiler optimizations enabled.
a2f6a96c
FC
372 Optimization is good for production builds, but not
373 good for debugging. During development, use
374 --disable-optimizations to reduce compilation times
10185a38 375 and allow easier debugging.]), [
fcabe077
FC
376if test "x$enableval" = "xno" ; then
377 AC_MSG_NOTICE([Disabling compiler optimizations (-O flag)])
d0441961
CG
378 CFLAGS="`echo $CFLAGS | sed -e 's/-O[[0-9g]]*//'`"
379 CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-O[[0-9g]]*//'`"
fcabe077 380fi
83079644 381])
382
fa80a8ef 383AC_ARG_ENABLE(debug-cbdata,
8075a4da 384 AS_HELP_STRING([--enable-debug-cbdata],
9603207d 385 [Provide some debug information in cbdata]), [
50af7161
FC
386SQUID_YESNO([$enableval],
387 [unrecognized argument to --enable-debug-cbdata: $enableval])
fa80a8ef 388])
9a0a18de 389SQUID_DEFINE_BOOL(USE_CBDATA_DEBUG,${enable_debug_cbdata:=no},
50af7161
FC
390 [Enable support for cbdata debug information])
391AC_MSG_NOTICE([cbdata debugging enabled: $enable_debug_cbdata])
392
fa80a8ef 393
c9267250
AJ
394dnl Nasty hack to get autoconf 2.64 on Linux to run.
395dnl all other uses of RUN_IFELSE are wrapped inside CACHE_CHECK which breaks on 2.64
aff0e8fe 396AC_RUN_IFELSE([AC_LANG_SOURCE([[ int main(int argc, char **argv) { return 0; } ]])],[],[],[:])
c9267250 397
0d00c98b 398AH_TEMPLATE(XMALLOC_STATISTICS,[Define to have malloc statistics])
d9180414 399AC_ARG_ENABLE(xmalloc-statistics,
8075a4da
FC
400 AS_HELP_STRING([--enable-xmalloc-statistics],
401 [Show malloc statistics in status page]), [
4d1d2477
FC
402SQUID_YESNO([$enableval],
403 [unrecognized argument to --enable-xmalloc-statistics: $enableval])
e5f4e1b0 404])
4d1d2477
FC
405SQUID_DEFINE_BOOL(XMALLOC_STATISTICS,${enable_xmalloc_statistics:=no},
406 [Show malloc statistics in status page])
407AC_MSG_NOTICE([xmalloc stats display: $enable_xmalloc_statistics])
e5f4e1b0 408
8075a4da 409squid_opt_aufs_threads=""
f85c88f3 410AC_ARG_WITH(aufs-threads,
8075a4da 411 AS_HELP_STRING([--with-aufs-threads=N_THREADS],
9603207d 412 [Tune the number of worker threads for the aufs object store.]), [
8075a4da 413case $withval in
a3310b77 414 [[0-9]]*)
50fbcbd6 415 squid_opt_aufs_threads=$withval
a3310b77 416 ;;
417 *)
8b0d8e31 418 AC_MSG_ERROR(--with-aufs-threads expects a numeric argument)
a3310b77 419 ;;
420 esac
421])
fcabe077 422if test "x$squid_opt_aufs_threads" != "x"; then
50fbcbd6
FC
423 AC_MSG_NOTICE([With $squid_opt_aufs_threads aufs threads])
424 AC_DEFINE_UNQUOTED(AUFS_IO_THREADS,$squid_opt_aufs_threads,
8075a4da 425 [Defines how many threads aufs uses for I/O])
cd748f27 426fi
427
24531401
AJ
428## TODO check if this is necessary, LT_INIT does these checks
429SQUID_AUTO_LIB(dl,[dynamic linking],[LIBDL])
430if test "x$with_dl" != "xno"; then
431 CXXFLAGS="$LIBDL_CFLAGS $CXXFLAGS"
432 LDFLAGS="$LIBDL_PATH $LDFLAGS"
433 AC_CHECK_LIB(dl, dlopen)
8154dd82 434fi
f85c88f3 435
8636e7c1
EB
436AC_DEFUN([LIBATOMIC_CHECKER],[
437 AC_MSG_CHECKING(whether linking $1 -latomic works)
438 AC_LINK_IFELSE([
439 AC_LANG_SOURCE([[
440#include <atomic>
441#include <cstdint>
442 int
b98c6823
HS
443 main(int argc, char **) {
444 return (
445 std::atomic<uint8_t>(uint8_t(argc)).exchange(0) &&
446 std::atomic<uint64_t>{}.is_lock_free()
447 ) ? 0 : 1;
8636e7c1
EB
448 }
449 ]])],[
450 AC_MSG_RESULT(yes)
451 libatomic_checker_result="yes"],[
452 AC_MSG_RESULT(no)
453 libatomic_checker_result="no"
454])])
455
4b0f8912 456## check for atomics library before anything that might need it
16530552 457SQUID_STATE_SAVE(LIBATOMIC)
8636e7c1
EB
458LIBATOMIC_CHECKER(without)
459AS_IF([test "x$libatomic_checker_result" = "xno"],[
460 LIBS="$LIBS -latomic"
461 LIBATOMIC_CHECKER(with)
462 AS_IF([test "x$libatomic_checker_result" = "xyes"],[
463 ATOMICLIB="-latomic"],[
464 AC_MSG_ERROR([Required library libatomic not found.])
465])])
16530552 466SQUID_STATE_ROLLBACK(LIBATOMIC)
4b0f8912
AJ
467AC_SUBST(ATOMICLIB)
468
c975f532
DK
469AC_SEARCH_LIBS([shm_open], [rt])
470if test "x$ac_cv_search_shm_open" != "xno" ; then
471 AC_DEFINE(HAVE_SHM,1,[Support shared memory features])
472fi
473
d235bc84 474AC_MSG_CHECKING([for DiskIO modules to be enabled])
50fbcbd6 475squid_disk_module_candidates=""
8075a4da 476squid_opt_enable_diskio="auto" #values: no, yes, "auto"(=yes+detect modules)
2513178d 477AC_ARG_ENABLE(disk-io,
50fbcbd6
FC
478 AS_HELP_STRING([--enable-disk-io="list of modules"],
479 [Build support for the list of disk I/O modules.
480 Set without a value or omitted, all available modules will be built.
481 See src/DiskIO for a list of available modules, or
482 Programmers Guide section on DiskIO
9603207d 483 for details on how to build your custom disk module]), [
8075a4da 484case $enableval in
2513178d 485 yes)
fe9ddf62 486 ${TRUE}
50fbcbd6 487 #do nothing, "auto" is ok
507ca601 488 ;;
2513178d 489 no)
8075a4da 490 squid_opt_enable_diskio="no"
507ca601 491 ;;
2513178d 492 *)
8075a4da 493 squid_opt_enable_diskio="yes"
47d80734 494 squid_disk_module_candidates=" `echo $enableval| sed -e 's/,/ /g;s/ */ /g'` "
d235bc84 495 SQUID_CLEANUP_MODULES_LIST([squid_disk_module_candidates])
507ca601 496 ;;
2513178d 497 esac
50fbcbd6
FC
498])
499
d235bc84 500# if requested to autodetect, find out what we have
fcabe077 501if test "x$squid_opt_enable_diskio" = "xauto"; then
8075a4da 502 squid_opt_enable_diskio="yes"
50fbcbd6 503 SQUID_LOOK_FOR_MODULES([$srcdir/src/DiskIO],[squid_disk_module_candidates])
c975f532
DK
504 if test "x$ac_cv_search_shm_open" = "xno" ; then
505 # disable IpcIo
506 squid_disk_module_candidates=`echo $squid_disk_module_candidates|sed 's/IpcIo//'`
507 fi
50fbcbd6 508fi
d235bc84 509
47d80734 510AC_MSG_RESULT([${squid_disk_module_candidates:-none}])
dc299f29 511SQUID_CHECK_EXISTING_MODULES([$srcdir/src/DiskIO],[squid_disk_module_candidates])
0f658b5b 512SQUID_DEFINE_BOOL(USE_DISKIO,$squid_opt_enable_diskio,
50fbcbd6 513 [DiskIO modules are expected to be available.])
2513178d 514
dc299f29 515
40503c27 516
2513178d 517dnl Some autoconf.h defines we might enable later...
0b163dbb
FC
518AC_ARG_WITH(pthreads,AS_HELP_STRING([--without-pthreads],[Disable POSIX Threads]))
519AC_ARG_WITH(aio, AS_HELP_STRING([--without-aio],[Do not use POSIX AIO. Default: auto-detect]))
daf2ddfa 520ENABLE_WIN32_AIOPS=0
ffa3bad9
FC
521squid_opt_use_aio=
522squid_opt_use_diskthreads=
46577dd1 523AIOLIB=
2513178d
AJ
524
525dnl Setup the module paths etc.
2513178d
AJ
526DISK_LIBS=
527DISK_MODULES=
d9691f09
AJ
528AH_TEMPLATE(HAVE_DISKIO_MODULE_AIO, [Whether POSIX AIO Disk I/O module is built])
529AH_TEMPLATE(HAVE_DISKIO_MODULE_BLOCKING, [Whether Blocking Disk I/O module is built])
530AH_TEMPLATE(HAVE_DISKIO_MODULE_DISKDAEMON, [Whether DiskDaemon Disk I/O module is built])
23ee12fb 531AH_TEMPLATE(HAVE_DISKIO_MODULE_DISKTHREADS, [Whether DiskThreads Disk I/O module is built])
d9691f09
AJ
532AH_TEMPLATE(HAVE_DISKIO_MODULE_IPCIO, [Whether IpcIo Disk I/O module is built])
533AH_TEMPLATE(HAVE_DISKIO_MODULE_MMAPPED, [Whether Mmapped Disk I/O module is built])
50fbcbd6 534for module in $squid_disk_module_candidates none; do
d235bc84 535 # maybe not needed
fcabe077 536 if test "x$module" = "xnone"; then
507ca601 537 continue
2513178d 538 fi
fcabe077 539 if ! test -d "$srcdir/src/DiskIO/$module"; then
2513178d
AJ
540 AC_MSG_ERROR(disk-io $module does not exist)
541 fi
542 case "$module" in
d9691f09
AJ
543
544 AIO)
545 dnl Check for POSIX AIO availability
546 squid_opt_use_aio="yes"
547 AIOLIB=
548 if test "x$with_aio" != "xno"; then
549 have_aio_header=no
550 AC_CHECK_HEADERS(aio.h,[have_aio_header=yes])
551 dnl On some systems POSIX AIO functions are in librt
552 dnl On some systems POSIX AIO functions are in libaio
553 AC_CHECK_LIB(rt,aio_read,[AIOLIB="-lrt"],AC_CHECK_LIB(aio,aio_read,[AIOLIB="-laio"],[]))
554 dnl Enable AIO if the library and headers are found
555 if test "x$AIOLIB" != "x" && test "x$have_aio_header" = "xyes"; then
556 AC_MSG_NOTICE([Native POSIX AIO support detected.])
557 squid_opt_use_aio="yes"
558 else
559 dnl Windows does things differently. We provide wrappers.
560 dnl TODO: Windows really needs its own DiskIO module or its Overlaped IO
561 case "$squid_host_os" in
562 mingw)
563 squid_opt_use_aio="yes"
564 AC_MSG_NOTICE([Windows being built. Maybe-enable POSIX AIO.])
565 ;;
566 *)
567 AC_MSG_NOTICE([Native POSIX AIO support not detected. AIO automatically disabled.])
568 squid_opt_use_aio="no"
569 ;;
570 esac
571 fi
572 else
573 AC_MSG_NOTICE([POSIX AIO support manually disabled.])
574 squid_opt_use_aio="no"
575 fi
576 dnl Use the POSIX AIO pieces if we actually need them.
577 if test "x$squid_opt_use_aio" = "xyes" ; then
578 DISK_MODULES="$DISK_MODULES AIO"
d9691f09
AJ
579 AC_DEFINE([HAVE_DISKIO_MODULE_AIO],1,[POSIX AIO Disk I/O module is built])
580 case "$squid_host_os" in
581 mingw)
582 ENABLE_WIN32_AIO=1
583 AC_MSG_NOTICE([Replacing AIO DiskIO module with: Windows overlapped I/O support])
584 ;;
585 *)
586 AC_MSG_NOTICE([Enabling AIO DiskIO module])
587 ;;
588 esac
589 else
590 AC_MSG_NOTICE([AIO DiskIO Module disabled. Missing POSIX AIO support.])
fedd516f 591 squid_disk_module_candidates_AIO=no
d9691f09
AJ
592 fi
593 ;;
594
595 Blocking)
596 AC_MSG_NOTICE([Enabling Blocking DiskIO module])
597 DISK_MODULES="$DISK_MODULES Blocking"
d9691f09
AJ
598 AC_DEFINE([HAVE_DISKIO_MODULE_BLOCKING],1,[Blocking Disk I/O module is built])
599 ;;
600
2513178d 601 DiskDaemon)
1d3aafe4
FC
602 case "$squid_host_os" in
603 mingw)
604 AC_MSG_NOTICE(["DiskDaemon not supported on MinGW"])
fedd516f 605 squid_disk_module_candidates_DiskDaemon=no
1d3aafe4
FC
606 ;;
607 *)
608 AC_MSG_NOTICE([Enabling DiskDaemon DiskIO module])
1d3aafe4 609 DISK_MODULES="$DISK_MODULES DiskDaemon"
d9691f09 610 AC_DEFINE([HAVE_DISKIO_MODULE_DISKDAEMON],1,[DiskDaemon Disk I/O module is built])
1d3aafe4
FC
611 ;;
612 esac
507ca601 613 ;;
d9691f09 614
2513178d 615 DiskThreads)
507ca601
FC
616 squid_opt_use_diskthreads="yes"
617 LIBPTHREADS=
618 SQUID_STATE_SAVE([diskthreads_state],[SQUID_CFLAGS SQUID_CXXFLAGS])
619 if test "x$with_pthreads" != "xno"; then
620 dnl TODO: this needs to be extended to handle more systems and better
621 dnl REF: http://www.openldap.org/lists/openldap-bugs/200006/msg00070.html
622 dnl REF: http://autoconf-archive.cryp.to/acx_pthread.html
623 case "$squid_host_os" in
624 mingw)
daf2ddfa 625 ENABLE_WIN32_AIOPS=1
507ca601
FC
626 AC_MSG_NOTICE([Windows threads support automatically enabled])
627 ;;
628 freebsd)
2a76c9c4 629 if test `echo "$squid_host_os_version" | tr -d .` -lt 70 ; then
a0f82085
AJ
630 AC_MSG_NOTICE(pthread library requires FreeBSD 7 or later)
631 squid_opt_use_diskthreads="no"
632 else
633 SQUID_CFLAGS="$SQUID_CFLAGS -D_REENTRANT"
634 SQUID_CXXFLAGS="$SQUID_CXXFLAGS -D_REENTRANT"
635 if test "x$GCC" = "xyes" -a "x$PRESET_LDFLAGS" = "x" ; then
636 LDFLAGS="$LDFLAGS -pthread"
637 fi
507ca601
FC
638 fi
639 ;;
ec264296
SH
640 openbsd)
641 if test `echo "$squid_host_os_version" | tr -d .` -lt 52 ; then
642 AC_MSG_NOTICE(pthread library requires OpenBSD 5.2 or later)
643 squid_opt_use_diskthreads="no"
644 else
645 SQUID_CFLAGS="$SQUID_CFLAGS -D_REENTRANT"
646 SQUID_CXXFLAGS="$SQUID_CXXFLAGS -D_REENTRANT"
647 LDFLAGS="$LDFLAGS -lpthread"
648 fi
649 ;;
507ca601
FC
650 solaris)
651 if test "x$GCC" = "xyes" ; then
652 SQUID_CFLAGS="$SQUID_CFLAGS -D_REENTRANT -pthreads"
653 SQUID_CXXFLAGS="$SQUID_CXXFLAGS -D_REENTRANT -pthreads"
654 AC_CHECK_LIB(pthread, pthread_create ,[LIBPTHREADS="-lpthread"], [
655 AC_MSG_NOTICE(pthread library required but cannot be found.)
656 squid_opt_use_diskthreads="no"
657 ])
658 else
659 dnl test for -lpthread first. libc version is a stub apparently on Solaris.
660 SQUID_CFLAGS="$SQUID_CFLAGS -D_REENTRANT -lpthread"
661 SQUID_CXXFLAGS="$SQUID_CXXFLAGS -D_REENTRANT -lpthread"
662 AC_SEARCH_LIBS([pthread_create],[pthread thread],[
9603207d 663 LIBPTHREADS="" #in LIBS
507ca601
FC
664 ],[
665 AC_MSG_NOTICE(pthread library required but cannot be found.)
666 squid_opt_use_diskthreads="no"
667 ])
668 fi
669 ;;
670 *)
671 SQUID_CFLAGS="$SQUID_CFLAGS -D_REENTRANT"
672 SQUID_CXXFLAGS="$SQUID_CXXFLAGS -D_REENTRANT"
673 AC_CHECK_LIB(pthread, pthread_create ,[LIBPTHREADS="-lpthread"], [
40503c27
FC
674 AC_MSG_NOTICE(pthread library required but cannot be found.)
675 squid_opt_use_diskthreads="no"
676 ])
507ca601
FC
677 ;;
678 esac
679 else
680 AC_MSG_NOTICE([Native pthreads support manually disabled.])
681 squid_opt_use_diskthreads="no"
682 fi
683 if test "x$squid_opt_use_diskthreads" = "xyes" ; then
507ca601 684 AC_MSG_NOTICE([Enabling DiskThreads DiskIO module])
507ca601 685 DISK_MODULES="$DISK_MODULES DiskThreads"
d9691f09 686 AC_DEFINE([HAVE_DISKIO_MODULE_DISKTHREADS],1,[DiskThreads Disk I/O module is built])
507ca601 687 else
507ca601 688 AC_MSG_NOTICE([Native pthreads support disabled. DiskThreads module automaticaly disabled.])
0b163dbb 689 SQUID_STATE_ROLLBACK([diskthreads_state])
fedd516f 690 squid_disk_module_candidates_DiskThreads=no
507ca601
FC
691 fi
692 ;;
2513178d 693
d9691f09 694 IpcIo)
d9691f09 695 if test "x$ac_cv_search_shm_open" = "xno" ; then
fedd516f
AJ
696 AC_MSG_NOTICE([DiskIO IpcIo module requires shared memory support])
697 squid_disk_module_candidates_IpcIo=no
698 else
23ee12fb 699 AC_MSG_NOTICE([Enabling IpcIo DiskIO module])
fedd516f 700 DISK_MODULES="$DISK_MODULES IpcIo"
fedd516f 701 AC_DEFINE([HAVE_DISKIO_MODULE_IPCIO],1,[IpcIo Disk I/O module is built])
507ca601
FC
702 fi
703 ;;
2513178d 704
e2851fe7 705 Mmapped)
e2cbb70e
FC
706 dnl TODO: use availability of sys/mman.h and/or mmap to define
707 dnl OR support windows mmap functions
708 if test "x$squid_host_os" = "xmingw" ; then
709 AC_MSG_NOTICE([Mmapped DiskIO is not available on Mingw])
fedd516f 710 squid_disk_module_candidates_Mmapped=no
e2cbb70e
FC
711 else
712 AC_MSG_NOTICE([Enabling Mmapped DiskIO module])
e2cbb70e 713 DISK_MODULES="$DISK_MODULES Mmapped"
d9691f09 714 AC_DEFINE([HAVE_DISKIO_MODULE_MMAPPED],1,[Mmapped Disk I/O module is built])
e2cbb70e 715 fi
e2851fe7
AR
716 ;;
717
2513178d 718 *)
507ca601 719 AC_MSG_NOTICE([Enabling $module DiskIO module])
d9691f09 720 DISK_LIBS="$DISK_LIBS lib${module}.la"
507ca601 721 DISK_MODULES="$DISK_MODULES ${module}"
507ca601 722 ;;
2513178d
AJ
723 esac
724done
725AC_MSG_NOTICE([IO Modules built: $DISK_MODULES])
726AC_SUBST(DISK_MODULES)
727AC_SUBST(DISK_LIBS)
8aafbbc1 728AM_CONDITIONAL(ENABLE_DISKIO_AIO, test "x$squid_disk_module_candidates_AIO" = "xyes")
d9691f09 729AC_SUBST(AIOLIB)
8aafbbc1
AJ
730AM_CONDITIONAL(ENABLE_WIN32_AIO, test "x$squid_disk_module_candidates_AIO" = "xyes" -a "x$ENABLE_WIN32_AIO" = "x1")
731AM_CONDITIONAL(ENABLE_DISKIO_BLOCKING, test "x$squid_disk_module_candidates_Blocking" = "xyes")
732AM_CONDITIONAL(ENABLE_DISKIO_DISKDAEMON, test "x$squid_disk_module_candidates_DiskDaemon" = "xyes")
733AM_CONDITIONAL(ENABLE_DISKIO_DISKTHREADS, test "x$squid_disk_module_candidates_DiskThreads" = "xyes")
d9691f09 734AC_SUBST(LIBPTHREADS)
8aafbbc1
AJ
735AM_CONDITIONAL(ENABLE_WIN32_AIOPS, test "x$squid_disk_module_candidates_DiskThreads" = "xyes" -a "x$ENABLE_WIN32_AIOPS" = "x1")
736AM_CONDITIONAL(ENABLE_DISKIO_IPCIO, test "x$squid_disk_module_candidates_IpcIo" = "xyes")
737AM_CONDITIONAL(ENABLE_DISKIO_MMAPPED, test "x$squid_disk_module_candidates_Mmapped" = "xyes")
2513178d
AJ
738
739dnl Check what Storage formats are wanted.
740dnl This version will error out with a message saying why if a required DiskIO is missing.
dc299f29 741squid_opt_enable_storeio=auto
d235bc84
FC
742AC_ARG_ENABLE([storeio],
743 AS_HELP_STRING([--enable-storeio="list of modules"],
744 [Build support for the list of store I/O modules.
18cc92fb
FC
745 The default is only to build the "ufs" module.
746 See src/fs for a list of available modules, or
747 Programmers Guide section <not yet written>
507ca601
FC
748 for details on how to build your custom store module]), [
749case $enableval in
cd748f27 750 yes)
dc299f29 751 squid_opt_enable_storeio=auto
507ca601 752 ;;
cd748f27 753 no)
dc299f29 754 squid_opt_enable_storeio=no
507ca601 755 ;;
1c690e30 756 *)
dc299f29 757 squid_opt_enable_storeio=yes
507ca601 758 squid_storeio_module_candidates="`echo $enableval| sed -e 's/,/ /g;s/ */ /g'`"
80f756db 759 # ufs is really always needed as it has low-level routines
be0c7ff0 760 # if it is a dupe it will be cleaned-up later
80f756db 761 squid_storeio_module_candidates="$squid_storeio_module_candidates ufs"
507ca601 762 ;;
cd748f27 763 esac
cd748f27 764])
fcabe077 765if test "x$squid_opt_enable_storeio" = "xauto"; then
dc299f29 766 squid_opt_enable_storeio=yes
d235bc84
FC
767 AC_MSG_CHECKING([for available StoreIO modules])
768 SQUID_LOOK_FOR_MODULES([$srcdir/src/fs],[squid_storeio_module_candidates])
769 AC_MSG_RESULT([$squid_storeio_module_candidates])
770fi
771
dc299f29
FC
772SQUID_CLEANUP_MODULES_LIST([squid_storeio_module_candidates])
773SQUID_CHECK_EXISTING_MODULES([$srcdir/src/fs],[squid_storeio_module_candidates])
774AC_MSG_NOTICE([Store modules built: $squid_storeio_module_candidates])
775
776for fs in $squid_storeio_module_candidates none; do
507ca601 777 case "$fs" in
8154dd82 778 diskd)
507ca601 779 if test "x$squid_disk_module_candidates_Blocking" != "xyes" -a \
80f756db 780 "$squid_disk_module_candidates_DiskDaemon" != "yes" ; then
507ca601
FC
781 AC_MSG_ERROR([Storage diskd module requires DiskIO module: Blocking or DiskDaemon])
782 fi
783 ;;
8154dd82 784 aufs)
507ca601 785 if test "x$squid_disk_module_candidates_Blocking" != "xyes" -a \
80f756db 786 "$squid_disk_module_candidates_DiskThreads" != "yes" ; then
507ca601
FC
787 AC_MSG_ERROR([Storage module aufs requires DiskIO module: Blocking or DiskThreads])
788 fi
789 ;;
e2851fe7 790 rock)
b5b88fb5
MM
791 if test "x$squid_disk_module_candidates_IpcIo" != "xyes" -a \
792 "x$squid_disk_module_candidates_Blocking" != "xyes"; then
793 AC_MSG_ERROR([Storage module Rock requires DiskIO module: Blocking or IpcIo])
794 fi
795 squid_do_build_rock=true
796 ;;
d3b3ab85 797 ufs)
b5b88fb5
MM
798 if test "x$squid_disk_module_candidates_Blocking" != "xyes"; then
799 AC_MSG_ERROR([Storage module ufs requires DiskIO module: Blocking])
800 fi
801 squid_do_build_ufs=true
802 ;;
8154dd82 803 esac
a2794549 804done
23ee12fb 805
8aafbbc1
AJ
806AM_CONDITIONAL(ENABLE_FS_UFS, test "x$squid_do_build_ufs" = "xtrue")
807AM_CONDITIONAL(ENABLE_FS_ROCK, test "x$squid_do_build_rock" = "xtrue")
9d6186b1
FC
808dnl hack: need to define those even if not used in the build system to
809dnl make sure that global FS objects are linked to the squid binary.
7b5b7ba8
CT
810AH_TEMPLATE(HAVE_FS_UFS, "Define to 1 if ufs filesystem module is build")
811AH_TEMPLATE(HAVE_FS_AUFS, "Define to 1 if aufs filesystem module is build")
812AH_TEMPLATE(HAVE_FS_DISKD, "Define to 1 if diskd filesystem module is build")
e2851fe7 813AH_TEMPLATE(HAVE_FS_ROCK, "Define to 1 if rock filesystem module is build")
7b5b7ba8
CT
814
815
dc299f29 816dnl got final squid_storeio_module_candidates, build library lists
b66455ff
AR
817dnl This list will not be needed when each fs library has its own Makefile
818STORE_LIBS_TO_BUILD=
819dnl File system libraries to link executables with.
820dnl These are the same as STORE_LIBS_TO_BUILD, but with a path
821STORE_LIBS_TO_ADD=
dc299f29 822for fs in $squid_storeio_module_candidates; do
7b5b7ba8
CT
823 STORE_LIBS_TO_BUILD="$STORE_LIBS_TO_BUILD lib${fs}.la"
824 STORE_LIBS_TO_ADD="$STORE_LIBS_TO_ADD fs/lib${fs}.la"
6d1c1ab1
FC
825 SQUID_TOUPPER_VAR_CONTENTS([fs])
826 AC_DEFINE_UNQUOTED(HAVE_FS_${fs}, 1)
b66455ff
AR
827done
828
829AC_SUBST(STORE_LIBS_TO_BUILD)
830AC_SUBST(STORE_LIBS_TO_ADD)
082a5e7a 831AC_SUBST(STORE_TESTS)
a2794549 832
24a04df9
AJ
833
834dnl At lest one removal policy is always needed.
835dnl 'lru' removal policy is currently hard-coded by name for tests
836dnl so we must set it as default.
837REPL_POLICIES="lru"
d9180414 838AC_ARG_ENABLE(removal-policies,
56ffc413
FC
839 AS_HELP_STRING([--enable-removal-policies="list of policies"],
840 [Build support for the list of removal policies.
18cc92fb
FC
841 The default is only to build the "lru" module.
842 See src/repl for a list of available modules, or
843 Programmers Guide section 9.9 for details on how
507ca601
FC
844 to build your custom policy]), [
845case $enableval in
6a566b9c 846 yes)
5069fb38 847 SQUID_LOOK_FOR_MODULES([$srcdir/src/repl],[REPL_POLICIES])
507ca601 848 ;;
6a566b9c 849 no)
507ca601 850 ;;
1c690e30 851 *)
507ca601
FC
852 REPL_POLICIES="`echo $enableval| sed -e 's/,/ /g;s/ */ /g'`"
853 ;;
6a566b9c 854 esac
6a566b9c 855])
fcabe077 856if test "x$REPL_POLICIES" != "x" ; then
56ffc413 857 SQUID_CHECK_EXISTING_MODULES([$srcdir/src/repl],[REPL_POLICIES])
5069fb38 858 AC_MSG_NOTICE([Removal policies to build: $REPL_POLICIES])
1c690e30 859 REPL_OBJS="repl/lib`echo $REPL_POLICIES|sed -e 's% %.a repl/lib%g'`.a"
860 REPL_LIBS="`echo $REPL_OBJS|sed -e 's%repl/%%g'`"
861fi
6a566b9c 862AC_SUBST(REPL_POLICIES)
6a566b9c 863AC_SUBST(REPL_OBJS)
f71946fc 864AC_SUBST(REPL_LIBS)
6a566b9c 865
d1da2d1f 866AM_CONDITIONAL(ENABLE_PINGER, false)
e5f4e1b0 867AC_ARG_ENABLE(icmp,
62979ab1 868 AS_HELP_STRING([--enable-icmp],[Enable ICMP pinging and Network Measurement]),
fcabe077 869[ if test "x$enableval" = "xyes" ; then
eed82608 870 AC_MSG_NOTICE([ICMP enabled])
be0c7ff0 871 AC_DEFINE(USE_ICMP,1,[Define to use Squid ICMP and Network Measurement features (highly recommended!)])
d1da2d1f 872 AM_CONDITIONAL(ENABLE_PINGER, true)
e5f4e1b0 873 fi
874])
875
9a0a18de 876AM_CONDITIONAL(ENABLE_DELAY_POOLS, false)
d9180414 877AC_ARG_ENABLE(delay-pools,
62979ab1 878 AS_HELP_STRING([--enable-delay-pools],[Enable delay pools to limit bandwidth usage]),
fcabe077 879[ if test "x$enableval" = "xyes" ; then
eed82608 880 AC_MSG_NOTICE([Delay pools enabled])
9a0a18de 881 AC_DEFINE([USE_DELAY_POOLS],1,[Traffic management via "delay pools".])
ffe4ffd8 882 AM_CONDITIONAL(ENABLE_DELAY_POOLS, true)
e5f4e1b0 883 fi
884])
885
5fa840c3 886dnl disable generic/common adaptation support by default
5069fb38 887squid_opt_use_adaptation=no
5fa840c3 888
799b66d1
AJ
889squid_opt_use_esi=auto
890AH_TEMPLATE([USE_SQUID_ESI],[Define to enable the ESI processor])
43ae1d95 891AC_ARG_ENABLE(esi,
799b66d1
AJ
892 AS_HELP_STRING([--disable-esi],
893 [Disable ESI for accelerators. ESI requires expat or libxml2.
7eb77a5f 894 Enabling ESI will cause squid reverse proxies to be capable
5069fb38 895 of the Edge Acceleration Specification (www.esi.org).]),
799b66d1 896 [squid_opt_use_esi=$enableval],[])
88bfe098
AJ
897HAVE_LIBEXPAT=0
898EXPATLIB=
899HAVE_LIBXML2=0
900XMLLIB=
88bfe098 901
7eb77a5f 902# ESI support libraries: expat
24531401 903SQUID_AUTO_LIB(expat,[ESI expat],[LIBEXPAT])
799b66d1 904if test "x$squid_opt_use_esi" != "xno" -a "x$with_expat" != "xno" ; then
7eb77a5f
FC
905 AC_CHECK_LIB([expat], [main], [EXPATLIB="-lexpat"; HAVE_LIBEXPAT=1])
906 AC_CHECK_HEADERS([expat.h])
907 AC_DEFINE_UNQUOTED(HAVE_LIBEXPAT, $HAVE_LIBEXPAT, [Define to 1 if you have the expat library])
799b66d1
AJ
908 AS_IF(test "x$HAVE_LIBEXPAT" = "x1",[
909 squid_opt_use_esi=yes
910 ],[
911 AS_IF(test "x$with_expat" = "xyes",[
912 AC_MSG_ERROR([Required library expat not found.])
913 ],[
914 AC_MSG_NOTICE([Library expat not found.])
915 ])
916 ])
7eb77a5f 917fi
ad32c661 918
24531401
AJ
919# TODO: remove this 'lib' prefix to match coding standard
920SQUID_AUTO_LIB(libxml2,[ESI libxml2],[LIBXML2])
799b66d1 921if test "x$squid_opt_use_esi" != "xno" -a "x$with_libxml2" != "xno" ; then
8fa07024
FF
922 SQUID_STATE_SAVE([squid_libxml2_save])
923 PKG_CHECK_MODULES([LIBXML2],[libxml-2.0],[],[
924 AC_CHECK_LIB([xml2], [main], [LIBXML2_LIBS="$LIBXML2_LIBS -lxml2"])
925 dnl Find the main header and include path...
926 AC_CACHE_CHECK([location of libxml2 include files], [ac_cv_libxml2_include], [
927 AC_CHECK_HEADERS([libxml/parser.h], [], [
928 AC_MSG_NOTICE([Testing in /usr/include/libxml2])
929 SAVED_CPPFLAGS="$CPPFLAGS"
930 CPPFLAGS="-I/usr/include/libxml2 $CPPFLAGS"
0dc1a86a 931 unset ac_cv_header_libxml_parser_h
8fa07024
FF
932 AC_CHECK_HEADERS([libxml/parser.h], [LIBXML2_CFLAGS="$LIBXML2_CFLAGS -I/usr/include/libxml2"], [
933 AC_MSG_NOTICE([Testing in /usr/local/include/libxml2])
934 CPPFLAGS="-I/usr/local/include/libxml2 $SAVED_CPPFLAGS"
935 unset ac_cv_header_libxml_parser_h
936 AC_CHECK_HEADERS([libxml/parser.h], [LIBXML2_CFLAGS="$LIBXML2_CFLAGS -I/usr/local/include/libxml2"], [
937 AC_MSG_NOTICE([Failed to find libxml2 header file libxml/parser.h])
938 ])
0dc1a86a 939 ])
8fa07024 940 CPPFLAGS="$SAVED_CPPFLAGS"
7eb77a5f 941 ])
0dc1a86a
HN
942 ])
943 ])
8fa07024 944 CPPFLAGS="$CPPFLAGS $LIBXML2_CFLAGS"
0dc1a86a
HN
945 dnl Now that we know where to look find the headers...
946 AC_CHECK_HEADERS(libxml/parser.h libxml/HTMLparser.h libxml/HTMLtree.h)
8fa07024
FF
947 SQUID_STATE_ROLLBACK([squid_libxml2_save])
948
949 if test "x$LIBXML2_LIBS" != "x"; then
950 HAVE_LIBXML2=1
799b66d1 951 squid_opt_use_esi=yes
8fa07024
FF
952 SQUID_CXXFLAGS="$SQUID_CXXFLAGS $LIBXML2_CFLAGS"
953 CPPFLAGS="$CPPFLAGS $LIBXML2_CFLAGS"
954 XMLLIB="$LIBXML2_LIBS"
955 AC_DEFINE_UNQUOTED(HAVE_LIBXML2, $HAVE_LIBXML2, [Define to 1 if you have the libxml2 library])
956 elif test "x$with_libxml2" = "xyes"; then
957 AC_MSG_ERROR([Required library libxml2 not found])
958 else
959 AC_MSG_NOTICE([Library libxml2 not found.])
960 fi
43ae1d95 961fi
7eb77a5f 962
799b66d1
AJ
963AS_IF([test "x$squid_opt_use_esi" = "xyes"],[
964 AS_IF(test "x$HAVE_LIBXML2" = "x0" -a "x$HAVE_LIBEXPAT" = "x0",[
965 AC_MSG_ERROR([ESI processor requires libxml2 or libexpat])
966 ])
967 AC_MSG_NOTICE([Enabling ESI processor: $EXPATLIB $XMLLIB])
968 AC_DEFINE(USE_SQUID_ESI,1,[Compile the ESI processor])
969],[
970 AS_IF(test "x$squid_opt_use_esi" = "xno",[
971 AC_MSG_NOTICE([Disabling ESI processor.])
972 ],[
973 AC_MSG_NOTICE([Disabling ESI processor. libxml2 and libexpat not found.])
974 ])
975])
8aafbbc1 976AM_CONDITIONAL(ENABLE_ESI, test "x$squid_opt_use_esi" = "xyes")
799b66d1 977AM_CONDITIONAL(ENABLE_LIBEXPAT, test "x$HAVE_LIBEXPAT" = "x1")
88bfe098 978AC_SUBST(EXPATLIB)
799b66d1 979AM_CONDITIONAL(ENABLE_LIBXML2, test "x$HAVE_LIBXML2" = "x1")
88bfe098 980AC_SUBST(XMLLIB)
43ae1d95 981
8075a4da 982# icap argument handling
51952383 983AC_ARG_ENABLE(icap-client,
4f07726a
AJ
984 AS_HELP_STRING([--disable-icap-client],[Disable the ICAP client.]),[
985 SQUID_YESNO([$enableval],[Unrecognized argument to --disable-icap-client: $enableval])
986])
987SQUID_DEFINE_BOOL(ICAP_CLIENT,${enable_icap_client:=yes}, [Enable ICAP client features in Squid])
ebf76e07 988AS_IF(test "x$enable_icap_client" != "xno", squid_opt_use_adaptation="yes")
8aafbbc1 989AM_CONDITIONAL(ENABLE_ICAP_CLIENT, test "x$enable_icap_client" != "xno")
51952383 990
5069fb38 991squid_opt_use_ecap=1
3e7b6055
AR
992AC_MSG_CHECKING(whether to support eCAP)
993AC_ARG_ENABLE(ecap,
8075a4da
FC
994 AS_HELP_STRING([--enable-ecap],[support loadable content adaptation modules]), [
995 case "${enableval}" in
996 yes|no) squid_opt_use_ecap=$enableval ;;
997 *) AC_MSG_ERROR(bad value ${enableval} for --enable-ecap) ;;
998 esac
999AC_MSG_RESULT([$squid_opt_use_ecap, explicitly])
1000 ], [
5069fb38
FC
1001 squid_opt_use_ecap=no;
1002 AC_MSG_RESULT([$squid_opt_use_ecap, implicitly])
3e7b6055
AR
1003 ]
1004)
1005
1006dnl Perform configuration consistency checks for eCAP
cbc14831 1007if test "x$squid_opt_use_ecap" != "xno";
3e7b6055 1008then
cbc14831 1009 dnl eCAP support requires loadable modules, which are enabled by default
5a2409b7 1010 if test "x$enable_shared" != "xyes"
cbc14831 1011 then
5a2409b7 1012 AC_MSG_ERROR([eCAP support requires loadable modules. Please do not use --disable-shared with --enable-ecap.])
cbc14831 1013 fi
4cfba571 1014
cbc14831 1015 if test -n "$PKG_CONFIG"; then
6666da11 1016 dnl eCAP support requires libecap.
0a720258 1017 dnl This Squid supports libecap v1.0.x.
3e115aaf
AR
1018 dnl Use EXT_ prefix to distinguish external libecap (that we check for
1019 dnl here) from our own convenience ecap library in Makefiles.
0a720258 1020 PKG_CHECK_MODULES([EXT_LIBECAP],[libecap >= 1.0 libecap < 1.1])
cbc14831
AJ
1021 else
1022 AC_MSG_NOTICE([eCAP support requires pkg-config to verify the correct library version. Trouble may follow.])
1023 fi
3e7b6055 1024
ebf76e07
AJ
1025 SQUID_STATE_SAVE(squid_ecap_state)
1026 AC_MSG_CHECKING([whether -lecap will link])
a023fd8e
AJ
1027 CXXFLAGS="$CXXFLAGS $EXT_LIBECAP_CFLAGS"
1028 LIBS="$LIBS $EXT_LIBECAP_LIBS"
ebf76e07
AJ
1029 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <libecap/common/names.h>]],[[
1030 const libecap::Name test("test", libecap::Name::NextId());
1031 ]])],[
1032 AC_MSG_RESULT(yes)
5069fb38 1033 squid_opt_use_adaptation=yes
ebf76e07
AJ
1034 ],[
1035 AC_MSG_RESULT(no)
1036 AS_IF(
1037 test "x$squid_opt_use_ecap" = "xyes", AC_MSG_ERROR([eCAP library will not link.
1038 You may need to rebuild libecap using the same version of GCC as Squid.
1039 There have been breaking ABI changes in the libstdc++ STL with GCC 5.]),
1040
1041 [AC_MSG_NOTICE([eCAP library will not link.
1042 You may need to rebuild libecap using the same version of GCC as Squid.
1043 There have been breaking ABI changes in the libstdc++ STL with GCC 5.])
1044 squid_opt_use_ecap="no"
1045 ])
1046 ])
1047 SQUID_STATE_ROLLBACK(squid_ecap_state)
3e7b6055 1048fi
b65a2365 1049SQUID_DEFINE_BOOL(USE_ECAP,${squid_opt_use_ecap:=no},[Whether to use eCAP support])
8aafbbc1 1050AM_CONDITIONAL(ENABLE_ECAP, test "x$squid_opt_use_ecap" = "xyes")
3e7b6055 1051
5fa840c3 1052dnl enable adaptation if requested by specific adaptation mechanisms
8aafbbc1
AJ
1053ADAPTATION_LIBS=""
1054if test "x$squid_opt_use_adaptation" = "xyes"; then
5fa840c3 1055 ADAPTATION_LIBS="adaptation/libadaptation.la"
51952383 1056fi
8aafbbc1
AJ
1057SQUID_DEFINE_BOOL(USE_ADAPTATION,${squid_opt_use_adaptation:=no}, [common adaptation support])
1058AM_CONDITIONAL(ENABLE_ADAPTATION, test "x$squid_opt_use_adaptation" = "xyes")
5fa840c3 1059AC_SUBST(ADAPTATION_LIBS)
3e7b6055 1060
1d3aafe4 1061test "x$squid_host_os" = "xmingw" && enable_wccp=no
5069fb38 1062AC_ARG_ENABLE(wccp,
8075a4da 1063 AS_HELP_STRING([--disable-wccp],[Disable Web Cache Coordination Protocol]), [
1a6b111a 1064SQUID_YESNO([$enableval],[unrecognized argument to --disable-wccp: $enableval])
5069fb38 1065])
0067eb06 1066SQUID_DEFINE_BOOL(USE_WCCP, ${enable_wccp:=yes}, [Define to enable WCCP])
1a6b111a 1067AC_MSG_NOTICE([Web Cache Coordination Protocol enabled: $enable_wccp])
0b0cfcf2 1068
1d3aafe4 1069test "x$squid_host_os" = "xmingw" && enable_wccpv2=no
0b0cfcf2 1070AC_ARG_ENABLE(wccpv2,
1a6b111a 1071 AS_HELP_STRING([--disable-wccpv2],
9603207d 1072 [Disable Web Cache Coordination V2 Protocol]), [
1a6b111a
FC
1073SQUID_YESNO([$enableval],
1074 [unrecognized argument to --disable-wccpv2: $enableval])
0b0cfcf2 1075])
0067eb06 1076SQUID_DEFINE_BOOL(USE_WCCPv2,${enable_wccpv2:=yes},
1a6b111a
FC
1077 [Define to enable WCCP V2])
1078AC_MSG_NOTICE([Web Cache Coordination V2 Protocol enabled: $enable_wccpv2])
320e9f36 1079
d9180414 1080AC_ARG_ENABLE(kill-parent-hack,
9603207d 1081 AS_HELP_STRING([--enable-kill-parent-hack],[Kill parent on shutdown]), [
1a6b111a
FC
1082SQUID_YESNO([$enableval],
1083 [unrecognized argument to --enable-kill-parent-hack: $enableval])
e5f4e1b0 1084])
0067eb06 1085SQUID_DEFINE_BOOL(KILL_PARENT_OPT,${enable_kill_parent_hack:=no},
9603207d 1086 [A dangerous feature which causes Squid to kill its parent
1087 process (presumably the RunCache script) upon receipt
1a6b111a
FC
1088 of SIGTERM or SIGINT. Deprecated, Use with caution.])
1089AC_MSG_NOTICE([Kill parent on shutdown hack enabled: $enable_kill_parent_hack])
20ad76ab 1090
e5f4e1b0 1091AC_ARG_ENABLE(snmp,
1d87b6b3 1092 AS_HELP_STRING([--disable-snmp],[Disable SNMP monitoring support]), [
1a6b111a
FC
1093 SQUID_YESNO([$enableval],
1094 [unrecognized argument to --disable-snmp: $enableval])
87630341 1095])
0067eb06 1096SQUID_DEFINE_BOOL(SQUID_SNMP,${enable_snmp:=yes},
1a6b111a 1097 [Define to enable SNMP monitoring of Squid])
f738d783 1098AM_CONDITIONAL(ENABLE_SNMP, [test "x$enable_snmp" = "xyes"])
fcabe077 1099if test "x$enable_snmp" = "xyes"; then
4de1e2da 1100 SNMPLIB='../lib/snmplib/libsnmplib.la'
87630341 1101fi
1a6b111a 1102AC_MSG_NOTICE([SNMP support enabled: $enable_snmp])
e5f4e1b0 1103AC_SUBST(SNMPLIB)
e5f4e1b0 1104
d9180414 1105AC_ARG_ENABLE(cachemgr-hostname,
5069fb38
FC
1106 AS_HELP_STRING([--enable-cachemgr-hostname=hostname],
1107 [Make cachemgr.cgi default to this host.
1d87b6b3
FC
1108 If unspecified, uses the name of the build-host]), [
1109 case $enableval in
1110 yes)
1111 AC_DEFINE(CACHEMGR_HOSTNAME,[getfullhostname()],
1112 [If you are upset that the cachemgr.cgi form comes up with the hostname field blank, then define this to getfullhostname()])
1113 AC_MSG_NOTICE([Cachemgr default hostname == host where cachemgr runs])
1114 ;;
1115 no)
1116 : # Nothing to do..
1117 ;;
1118 *)
1119 AC_DEFINE_UNQUOTED(CACHEMGR_HOSTNAME,"${enableval}")
1120 AC_MSG_NOTICE([Cachemgr default hostname set to ${enableval}])
1121 ;;
1122 esac
e5f4e1b0 1123])
1124
ee0927b6 1125AC_ARG_ENABLE(eui,
1a6b111a 1126 AS_HELP_STRING([--disable-eui],
c8da66ba 1127 [Disable use of ARP / MAC/ EUI (ether address)]), [
1a6b111a
FC
1128SQUID_YESNO([$enableval],[--disable-eui expects no arguments])
1129])
fcabe077 1130if test "x${enable_eui:=yes}" = "xyes" ; then
195ec847
AJ
1131 SQUID_STATE_SAVE(LIBEUI)
1132 # GLIBC 2.30 deprecates sysctl.h. Test with the same flags that (may) break includes later.
1133 CFLAGS=$SQUID_CFLAGS
1134 CXXFLAGS=$SQUID_CXXFLAGS
507ca601 1135 case "$squid_host_os" in
a396d1f8 1136 linux|solaris|freebsd|openbsd|netbsd|cygwin)
507ca601
FC
1137 ${TRUE}
1138 ;;
a396d1f8 1139 mingw)
507ca601
FC
1140 EUILIB="-liphlpapi"
1141 ;;
1142 *)
1143 AC_MSG_WARN([EUI support probably will not work on host $host.])
1144 ;;
1145 esac
b966288b 1146 # iphlpapi.h check delayed after winsock2.h
507ca601 1147 AC_CHECK_HEADERS( \
32341684 1148 windows.h \
507ca601 1149 sys/sockio.h \
32341684
AJ
1150 sys/param.h,
1151 [], [], [[
1152#if HAVE_WINDOWS_H
1153include <windows.h>
54d47324 1154#endif
32341684 1155]]
507ca601 1156 )
29759678
FC
1157 AC_CHECK_HEADERS( \
1158 net/if_arp.h \
9603207d 1159 net/route.h,
29759678
FC
1160 [], [], [[
1161#include <sys/types.h>
1162#include <sys/socket.h>
1163]])
1164
43c1320a
AJ
1165 # OpenBSD, FreeBSD and NetBSD requires sys/param.h to be included before sysctl.h and net/if_dl.h
1166 AC_CHECK_HEADERS( \
1167 net/if_dl.h \
1168 sys/sysctl.h,
1169 [], [], [[
54d47324 1170#if HAVE_SYS_PARAM_H
29759678
FC
1171#include <sys/param.h>
1172#endif
1173 ]])
195ec847 1174 SQUID_STATE_ROLLBACK(LIBEUI)
a98c2da5 1175fi
2ef664d8 1176AC_SUBST(EUILIB)
1a6b111a 1177AC_MSG_NOTICE([EUI (MAC address) controls enabled: $enable_eui])
0067eb06 1178SQUID_DEFINE_BOOL(USE_SQUID_EUI,$enable_eui,
1a6b111a 1179 [Define this to include code which lets you use ethernet addresses. This code uses API initially defined in 4.4-BSD.])
8aafbbc1 1180AM_CONDITIONAL(ENABLE_EUI, [test "x$enable_eui" = "xyes" ])
1a6b111a 1181
e5f4e1b0 1182
74075210 1183AC_ARG_ENABLE(htcp,
47d80734 1184 AS_HELP_STRING([--disable-htcp],[Disable HTCP protocol support]), [
1a6b111a
FC
1185SQUID_YESNO([$enableval],
1186 [unrecognized argument to --disable-htcp: $enableval])
74075210 1187])
0f658b5b 1188SQUID_DEFINE_BOOL(USE_HTCP,${enable_htcp:=yes},
47d80734 1189 [Define this to include code for the Hypertext Cache Protocol (HTCP)])
fcabe077 1190AM_CONDITIONAL(ENABLE_HTCP, [test "x$enable_htcp" = "xyes"])
1a6b111a
FC
1191AC_MSG_NOTICE([HTCP support enabled: $enable_htcp])
1192
09cd7204 1193# Cryptograhic libraries
24531401 1194SQUID_AUTO_LIB(nettle,[Nettle crypto],[LIBNETTLE])
09cd7204 1195if test "x$with_nettle" != "xno" ; then
24531401 1196 CPPFLAGS="$LIBNETTLE_CFLAGS $CPPFLAGS"
09cd7204 1197 AC_CHECK_LIB(nettle, nettle_md5_init,[
24531401 1198 NETTLELIB="$LIBNETTLE_PATH -lnettle"
f9ef3ed8 1199 AC_CHECK_HEADERS(nettle/md5.h)
09cd7204 1200 ],[with_nettle=no])
f9ef3ed8 1201 if test "x$with_nettle" != "xno" ; then
1d11e9b3 1202 # Base64 uses the nettle 3.4 API
f9ef3ed8
AJ
1203 # which matters on 64-bit systems
1204 AC_CHECK_HEADERS(nettle/base64.h)
1d11e9b3 1205 AC_MSG_CHECKING([for Nettle 3.4 API compatibility])
f9ef3ed8
AJ
1206 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1207# include <cstddef>
1208# include <cstdint>
1209# include <nettle/base64.h>
1210 ]],[[
1d11e9b3 1211 char inData[10]; inData[0] = '\0';
f9ef3ed8
AJ
1212 size_t srcLen = 0;
1213 struct base64_decode_ctx ctx;
1214 base64_decode_init(&ctx);
1215 uint8_t outData[10];
1216 size_t dstLen = 0;
1217 if (!base64_decode_update(&ctx, &dstLen, outData, srcLen, inData) ||
1218 !base64_decode_final(&ctx)) {
1219 return 1;
1220 }
1221 ]])],[AC_MSG_RESULT(yes)
1d11e9b3 1222 AC_DEFINE(HAVE_NETTLE34_BASE64,1,[set to 1 if Nettle 3.4 API will link])
f9ef3ed8
AJ
1223 ],[AC_MSG_RESULT(no)])
1224 fi
a9dfcab8 1225fi
09cd7204
AJ
1226AC_MSG_NOTICE([Using Nettle cryptographic library: ${with_nettle:=yes}])
1227AC_SUBST(NETTLELIB)
a9dfcab8 1228
e59a64d7
AJ
1229dnl Check for libcrypt
1230CRYPTLIB=
1231dnl Some of our helpers use crypt(3) which may be in libc, or in
1232dnl libcrypt (eg FreeBSD)
1233AC_CHECK_LIB(crypt, crypt, [CRYPTLIB="-lcrypt"])
1234dnl Solaris10 provides MD5 natively through libmd5
1235AC_CHECK_LIB(md5, MD5Init, [CRYPTLIB="$CRYPTLIB -lmd5"])
1236AC_SUBST(CRYPTLIB)
1237
b4f805f6
AJ
1238SSLLIB=""
1239
24531401 1240SQUID_AUTO_LIB(gnutls,[GnuTLS crypto],[LIBGNUTLS])
b4f805f6
AJ
1241AH_TEMPLATE(USE_GNUTLS,[GnuTLS support is available])
1242if test "x$with_gnutls" != "xno"; then
7c760558 1243 SQUID_STATE_SAVE(squid_gnutls_state)
b4f805f6
AJ
1244
1245 # User may have provided a custom location for GnuTLS. Otherwise...
24531401 1246 CPPFLAGS="$LIBGNUTLS_CFLAGS $CPPFLAGS"
b4f805f6
AJ
1247 LIBS="$LIBS $LIBGNUTLS_PATH"
1248
1249 # auto-detect using pkg-config
516ec633 1250 PKG_CHECK_MODULES([LIBGNUTLS],[gnutls >= 3.4.0],[
7c760558
FC
1251 CPPFLAGS="$CPPFLAGS $LIBGNUTLS_CFLAGS"
1252 ],[
b4f805f6 1253 ## find the package without pkg-config
c113986e 1254 ## check that the library is actually new enough.
516ec633
AJ
1255 ## by testing for a 3.4.0+ function which we use
1256 AC_CHECK_LIB(gnutls,gnutls_pcert_export_x509,[LIBGNUTLS_LIBS="-lgnutls"])
b4f805f6 1257 ])
51e09c08 1258 AC_CHECK_HEADERS(gnutls/gnutls.h gnutls/x509.h gnutls/abstract.h)
b4f805f6
AJ
1259
1260 SQUID_STATE_ROLLBACK(squid_gnutls_state) #de-pollute LIBS
1261
1262 if test "x$with_gnutls" = "xyes" -a "x$LIBGNUTLS_LIBS" = "x"; then
1263 AC_MSG_ERROR([Required GnuTLS library not found])
1264 fi
1265 if test "x$LIBGNUTLS_LIBS" != "x" ; then
1266 CXXFLAGS="$LIBGNUTLS_CFLAGS $CXXFLAGS"
1267 SSLLIB="$LIBGNUTLS_PATH $LIBGNUTLS_LIBS $SSLLIB"
1268 AC_DEFINE(USE_GNUTLS,1,[GnuTLS support is available])
1269 else
1270 with_gnutls=no
1271 fi
1272fi
1273AC_MSG_NOTICE([GnuTLS library support: ${with_gnutls:=auto} ${LIBGNUTLS_PATH} ${LIBGNUTLS_LIBS}])
1274
3d4022fa 1275dnl User may specify OpenSSL is needed from a non-standard location
24531401 1276SQUID_OPTIONAL_LIB(openssl,[OpenSSL],[LIBOPENSSL])
cb4f4424 1277AH_TEMPLATE(USE_OPENSSL,[OpenSSL support is available])
c41db002
AJ
1278## OpenSSL is default disable due to licensing issues on some OS
1279if test "x$with_openssl" = "xyes"; then
24531401 1280 CPPFLAGS="$LIBOPENSSL_CFLAGS $CPPFLAGS"
c41db002 1281 AC_CHECK_HEADERS( \
24b30fdc 1282 openssl/asn1.h \
8693472e 1283 openssl/bio.h \
24b30fdc 1284 openssl/bn.h \
eacc1666 1285 openssl/crypto.h \
742236c7 1286 openssl/decoder.h \
24b30fdc 1287 openssl/dh.h \
c41db002 1288 openssl/err.h \
24b30fdc
EQ
1289 openssl/evp.h \
1290 openssl/lhash.h \
c41db002
AJ
1291 openssl/md5.h \
1292 openssl/opensslv.h \
24b30fdc 1293 openssl/rsa.h \
c41db002 1294 openssl/ssl.h \
24b30fdc 1295 openssl/x509.h \
c41db002
AJ
1296 openssl/x509v3.h \
1297 openssl/engine.h \
1298 openssl/txt_db.h \
1299 )
1300
e0b98074 1301 # User may have provided a custom location for OpenSSL. Otherwise...
84c3fc14
AJ
1302 SQUID_STATE_SAVE(squid_openssl_state)
1303 LIBS="$LIBS $LIBOPENSSL_PATH"
1304
1305 # auto-detect using pkg-config
1306 PKG_CHECK_MODULES([LIBOPENSSL],[openssl],,[
1307 ## For some OS pkg-config is broken or unavailable.
1308 ## Detect libraries the hard way.
1309
1310 # Windows MinGW has some special libraries ...
1311 if test "x$squid_host_os" = "xmingw" ; then
1312 LIBOPENSSL_LIBS='-lssleay32 -leay32 -lgdi32 $LIBOPENSSL_LIBS'
1313 AC_MSG_NOTICE([Windows OpenSSL library support: yes -lssleay32 -leay32 -lgdi32])
1314 fi
e0b98074 1315
84c3fc14
AJ
1316 AC_CHECK_LIB(crypto,[CRYPTO_new_ex_data],[LIBOPENSSL_LIBS="-lcrypto $LIBOPENSSL_LIBS"],[
1317 AC_MSG_ERROR([library 'crypto' is required for OpenSSL])
37a20074 1318 ],$LIBOPENSSL_LIBS)
403c4682 1319 AC_CHECK_LIB(ssl,[SSL_CTX_new],[LIBOPENSSL_LIBS="-lssl $LIBOPENSSL_LIBS"],[
84c3fc14 1320 AC_MSG_ERROR([library 'ssl' is required for OpenSSL])
37a20074 1321 ],$LIBOPENSSL_LIBS)
84c3fc14 1322 ])
e0b98074 1323
84c3fc14
AJ
1324 # This is a workaround for RedHat 9 brain damage..
1325 if test -d /usr/kerberos/include -a -f /usr/include/openssl/kssl.h; then
1326 AC_MSG_NOTICE([OpenSSL depends on Kerberos])
1327 LIBOPENSSL_LIBS="-L/usr/kerberos/lib $LIBOPENSSL_LIBS"
1328 CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
f11555e0 1329 fi
84c3fc14 1330 SQUID_STATE_ROLLBACK(squid_openssl_state) #de-pollute LIBS
1f7c9178 1331
e0b98074 1332 if test "x$LIBOPENSSL_LIBS" != "x"; then
c41db002 1333 CXXFLAGS="$LIBOPENSSL_CFLAGS $CXXFLAGS"
84c3fc14 1334 SSLLIB="$LIBOPENSSL_PATH $LIBOPENSSL_LIBS $SSLLIB"
cb4f4424 1335 AC_DEFINE(USE_OPENSSL,1,[OpenSSL support is available])
c41db002 1336
b8649ee4 1337 # check for API functions
17e98f24
AJ
1338 SQUID_CHECK_LIBCRYPTO_API
1339 SQUID_CHECK_LIBSSL_API
8d56fe55 1340 SQUID_CHECK_OPENSSL_TLS_METHODS
b8649ee4
CT
1341 SQUID_STATE_SAVE(check_SSL_CTX_get0_certificate)
1342 LIBS="$LIBS $SSLLIB"
1343 AC_CHECK_LIB(ssl, SSL_CTX_get0_certificate, [
1344 AC_DEFINE(HAVE_SSL_CTX_GET0_CERTIFICATE, 1, [SSL_CTX_get0_certificate is available])
1345 ], [
1346 missing_SSL_CTX_get0_certificate=yes
1347 ])
1348 SQUID_STATE_ROLLBACK(check_SSL_CTX_get0_certificate)
1349
c41db002 1350 # check for other specific broken implementations
b8649ee4
CT
1351 if test "x$missing_SSL_CTX_get0_certificate" = "xyes"; then
1352 SQUID_CHECK_OPENSSL_GETCERTIFICATE_WORKS
1353 fi
c41db002 1354 SQUID_CHECK_OPENSSL_CONST_SSL_METHOD
7d841344
AJ
1355 SQUID_CHECK_OPENSSL_CONST_CRYPTO_EX_DATA
1356 SQUID_CHECK_OPENSSL_CONST_SSL_SESSION_CB_ARG
70cfe22f 1357 SQUID_CHECK_OPENSSL_CONST_X509_GET0_SIGNATURE_ARGS
c41db002 1358 SQUID_CHECK_OPENSSL_TXTDB
1f7c9178 1359 fi
e0b98074
AJ
1360 if test "x$SSLLIB" = "x"; then
1361 AC_MSG_ERROR([Required OpenSSL library not found])
f11555e0 1362 fi
1f7c9178 1363fi
84c3fc14 1364AC_MSG_NOTICE([OpenSSL library support: ${with_openssl:=no} ${LIBOPENSSL_PATH} ${LIBOPENSSL_LIBS}])
c41db002 1365AM_CONDITIONAL(ENABLE_SSL,[ test "x$with_openssl" = "xyes" ])
1f7c9178 1366AC_SUBST(SSLLIB)
1367
1a22a39e 1368dnl User may specify MIT Kerberos is needed from a non-standard location
24531401 1369SQUID_AUTO_LIB(mit-krb5,[MIT Kerberos],[LIB_KRB5])
75f3c557 1370AH_TEMPLATE(USE_APPLE_KRB5,[Apple Kerberos support is available])
1a22a39e
MM
1371AH_TEMPLATE(USE_MIT_KRB5,[MIT Kerberos support is available])
1372AH_TEMPLATE(USE_SOLARIS_KRB5,[Solaris Kerberos support is available])
1373
75c5f82b
AJ
1374## find out if pkg-config or krb5-config will work
1375if test "x$with_mit_krb5" != "xno"; then
24531401
AJ
1376 CXXFLAGS="$LIB_KRB5_CFLAGS $CXXFLAGS"
1377 krb5confpath="$with_mit_krb5/bin"
1a22a39e 1378 # find installed libs via pkg-config or krb5-config
75c5f82b 1379 squid_pc_krb5_name=
7c664dbc
AJ
1380 PKG_CHECK_EXISTS(mit-krb5-gssapi mit-krb5, [squid_pc_krb5_name="mit-krb5-gssapi mit-krb5"],[
1381 PKG_CHECK_EXISTS(gssapi-krb5 krb5, [squid_pc_krb5_name="gssapi-krb5 krb5"])
1382 ])
75c5f82b 1383 if test "x$squid_pc_krb5_name" = "x" -a "$cross_compiling" = "no"; then
77f4953d 1384 # Look for krb5-config (unless cross-compiling)
c4b12583 1385 AC_PATH_PROG(krb5_config,krb5-config,no,$krb5confpath)
1a22a39e
MM
1386 if test "x$ac_cv_path_krb5_config" != "xno" ; then
1387 krb5confpath="`dirname $ac_cv_path_krb5_config`"
1388 ac_heimdal="`$ac_cv_path_krb5_config --version 2>/dev/null | grep -c -i heimdal`"
1389 ac_solaris="`$ac_cv_path_krb5_config --version 2>/dev/null | grep -c -i solaris`"
75f3c557 1390 ac_apple="`$ac_cv_path_krb5_config --vendor 2>/dev/null | grep -c -i apple`"
1a22a39e
MM
1391 if test $ac_solaris -gt 0 ; then
1392 with_solaris_krb5=yes
75c5f82b 1393 elif test $ac_apple -gt 0 ; then
75f3c557 1394 with_apple_krb5=yes
75c5f82b
AJ
1395 elif test $ac_heimdal -gt 0; then
1396 with_mit_krb5=no
1397 if test "x$with_mit_krb5" = "xyes"; then
1398 AC_MSG_ERROR([Could not find pkg-config or krb5-config for MIT Kerberos])
1399 fi
1a22a39e
MM
1400 fi
1401 else
75c5f82b
AJ
1402 if test "x$with_mit_krb5" = "xyes"; then
1403 AC_MSG_ERROR([Could not find krb5-config in path])
1404 else
1405 with_mit_krb5=no
1406 fi
1a22a39e
MM
1407 fi
1408 fi
1409fi
1410
ed3a42d0
AJ
1411# detect MIT Kerberos dependencies (except on Solaris)
1412if test "x$with_mit_krb5" != "xno" -a "x$with_solaris_krb5" != "xyes"; then
1a22a39e
MM
1413 SQUID_STATE_SAVE([squid_krb5_save])
1414 LIBS="$LIBS $LIB_KRB5_PATH"
1415
1416 # auto-detect using pkg-config
75c5f82b 1417 PKG_CHECK_MODULES([LIB_KRB5], $squid_pc_krb5_name,,[
77f4953d
AJ
1418 # look for krb5-config (unless cross-compiling)
1419 if test "$cross_compiling" = "no"; then
1420 if test "x$krb5confpath" = "x" ; then
1421 AC_PATH_PROG(krb5_config,krb5-config,no)
1422 if test "x$ac_cv_path_krb5_config" != "xno" ; then
1423 ac_krb5_config="$ac_cv_path_krb5_config"
1424 fi
1425 else
1426 ac_krb5_config="$krb5confpath/krb5-config"
1a22a39e 1427 fi
1a22a39e
MM
1428 fi
1429 if test "x$ac_krb5_config" != "x" && test -x "$ac_krb5_config"; then
1430 # Get libs, etc
1431 AC_MSG_NOTICE([Use krb5-config to get CXXFLAGS and LIBS])
1432 LIB_KRB5_CFLAGS="`$ac_krb5_config --cflags krb5 2>/dev/null`"
1433 LIB_KRB5_LIBS="`$ac_krb5_config --libs krb5 2>/dev/null`"
1434 LIB_KRB5_CFLAGS="`$ac_krb5_config --cflags gssapi 2>/dev/null` $LIB_KRB5_CFLAGS"
1435 LIB_KRB5_LIBS="`$ac_krb5_config --libs gssapi 2>/dev/null` $LIB_KRB5_LIBS"
1436 else
1437 ## For some OS pkg-config is broken or unavailable.
1438 ## Detect libraries the hard way.
1439
b2bdde72 1440 SQUID_STATE_SAVE([squid_mit_save])
ff78f3c3 1441 missing_required=
1a22a39e
MM
1442 AC_MSG_NOTICE([Try to find Kerberos libraries in given path])
1443 AC_CHECK_LIB(com_err, [main], [LIB_KRB5_LIBS="-lcom_err $LIB_KRB5_LIBS"],[
ff78f3c3
AJ
1444 AC_MSG_WARN([library 'com_err' is required for MIT Kerberos])
1445 missing_required=yes
1a22a39e 1446 ])
b2bdde72 1447 LIBS=$LIB_KRB5_LIBS
1a22a39e 1448 AC_CHECK_LIB(k5crypto, [main], [LIB_KRB5_LIBS="-lk5crypto $LIB_KRB5_LIBS"],[
ff78f3c3
AJ
1449 AC_MSG_WARN([library 'k5crypto' is required for MIT Kerberos])
1450 missing_required=yes
1a22a39e 1451 ])
b2bdde72 1452 LIBS=$LIB_KRB5_LIBS
1a22a39e 1453 AC_CHECK_LIB(krb5, [main], [LIB_KRB5_LIBS="-lkrb5 $LIB_KRB5_LIBS"],[
ff78f3c3
AJ
1454 AC_MSG_WARN([library 'krb5' is required for MIT Kerberos])
1455 missing_required=yes
1a22a39e 1456 ])
b2bdde72 1457 LIBS=$LIB_KRB5_LIBS
1a22a39e 1458 AC_CHECK_LIB(gssapi_krb5, [main], [LIB_KRB5_LIBS="-lgssapi_krb5 $LIB_KRB5_LIBS"],[
ff78f3c3
AJ
1459 AC_MSG_WARN([library 'gssapi_krb5' is required for MIT Kerberos])
1460 missing_required=yes
1a22a39e 1461 ])
b2bdde72 1462 SQUID_STATE_ROLLBACK([squid_mit_save])
ff78f3c3
AJ
1463 if test "x$missing_required" = "xyes"; then
1464 LIB_KRB5_LIBS=""
1465 fi
1a22a39e 1466 fi
1a22a39e
MM
1467 ])
1468
1469 if test "x$LIB_KRB5_LIBS" != "x"; then
75f3c557
MM
1470 if test "x$with_apple_krb5" = "xyes" ; then
1471 AC_DEFINE(USE_APPLE_KRB5,1,[Apple Kerberos support is available])
9603207d 1472 KRB5_FLAVOUR="Apple"
75f3c557
MM
1473 else
1474 AC_DEFINE(USE_MIT_KRB5,1,[MIT Kerberos support is available])
9603207d 1475 KRB5_FLAVOUR="MIT"
75f3c557 1476 fi
1a22a39e
MM
1477 KRB5LIBS="$LIB_KRB5_PATH $LIB_KRB5_LIBS $KRB5LIBS"
1478 KRB5INCS="$LIB_KRB5_CFLAGS"
9603207d 1479
1a22a39e
MM
1480 # check for other specific broken implementations
1481 CXXFLAGS="$CXXFLAGS $KRB5INCS"
1482 LIBS="$LIBS $KRB5LIBS"
1483
1484 AC_MSG_NOTICE([Try to find Kerberos headers in given path])
1485 AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h gssapi/gssapi_krb5.h)
1486 AC_CHECK_HEADERS(gssapi/gssapi_generic.h)
1487 AC_CHECK_HEADERS(krb5.h com_err.h et/com_err.h)
1488 AC_CHECK_HEADERS(profile.h)
1489
1a22a39e 1490 SQUID_CHECK_KRB5_FUNCS
1a22a39e 1491 fi
75c5f82b 1492 if test "x$with_mit_krb5" = "xyes" -a "x$KRB5LIBS" = "x"; then
1a22a39e 1493 AC_MSG_ERROR([Required Kerberos library not found])
75c5f82b
AJ
1494 elif test "x$KRB5LIBS" = "x"; then
1495 with_mit_krb5=no
1496 with_apple_krb5=no
1a22a39e 1497 fi
1a22a39e
MM
1498 SQUID_STATE_ROLLBACK([squid_krb5_save])
1499fi
1500
75c5f82b
AJ
1501# detect Solaris Kerberos dependencies
1502if test "x$with_solaris_krb5" = "xyes" -a "x$KRB5LIBS" = "x"; then
1a22a39e
MM
1503 SQUID_STATE_SAVE([squid_krb5_save])
1504 LIBS="$LIBS $LIB_KRB5_PATH"
1505
1506 # no pkg-config for solaris native Kerberos
77f4953d
AJ
1507 # look for krb5-config (unless cross-compiling)
1508 if test "$cross_compiling" = "no"; then
1509 if test "x$krb5confpath" = "x" ; then
1510 AC_PATH_PROG(krb5_config,krb5-config,no)
1511 if test "x$ac_cv_path_krb5_config" != "xno" ; then
1512 ac_krb5_config="$ac_cv_path_krb5_config"
1513 fi
1514 else
1515 ac_krb5_config="$krb5confpath/krb5-config"
1a22a39e 1516 fi
1a22a39e
MM
1517 fi
1518 if test "x$ac_krb5_config" != "x" && test -x "$ac_krb5_config"; then
1519 # Get libs, etc
1520 AC_MSG_NOTICE([Use krb5-config to get CXXFLAGS and LIBS])
1521 LIB_KRB5_CFLAGS="`$ac_krb5_config --cflags krb5 2>/dev/null`"
1522 LIB_KRB5_LIBS="`$ac_krb5_config --libs krb5 2>/dev/null`"
b2da83da
AJ
1523 # Solaris 10 Update 11 patches the krb5-config tool to produce stderr messages on stdout.
1524 SOLARIS_BROKEN_KRB5CONFIG_GSSAPI="`$ac_krb5_config --libs gssapi 2>/dev/null | grep "krb5-config"`"
1525 if test "x$SOLARIS_BROKEN_KRB5CONFIG_GSSAPI" = "x"; then
1526 LIB_KRB5_CFLAGS="`$ac_krb5_config --cflags gssapi 2>/dev/null` $LIB_KRB5_CFLAGS"
1527 LIB_KRB5_LIBS="`$ac_krb5_config --libs gssapi 2>/dev/null` $LIB_KRB5_LIBS"
1528 fi
1a22a39e
MM
1529 else
1530 ## For some OS pkg-config is broken or unavailable.
1531 ## Detect libraries the hard way.
1532
1533 CXXFLAGS="-I/usr/include/kerberosv5 $CXXFLAGS"
1534
b2bdde72 1535 SQUID_STATE_SAVE([squid_solaris_save])
ff78f3c3 1536 missing_required=
1a22a39e
MM
1537 AC_MSG_NOTICE([Try to find Kerberos libraries in given path])
1538 AC_CHECK_LIB(krb5, [main], [LIB_KRB5_LIBS="-lkrb5 $LIB_KRB5_LIBS"],[
ff78f3c3
AJ
1539 AC_MSG_WARN([library 'krb5' is required for Solaris Kerberos])
1540 missing_required=yes
1a22a39e 1541 ])
b2bdde72 1542 LIBS=$LIB_KRB5_LIBS
1a22a39e 1543 AC_CHECK_LIB(gss, [main], [LIB_KRB5_LIBS="-lgss $LIB_KRB5_LIBS"],[
ff78f3c3
AJ
1544 AC_MSG_WARN([library 'gss' is required for Solaris Kerberos])
1545 missing_required=yes
1a22a39e 1546 ])
b2bdde72 1547 SQUID_STATE_ROLLBACK([squid_solaris_save])
ff78f3c3
AJ
1548 if test "x$missing_required" = "xyes"; then
1549 LIB_KRB5_LIBS=""
1550 fi
1a22a39e
MM
1551 fi
1552
1553 if test "x$LIB_KRB5_LIBS" != "x"; then
1554 KRB5LIBS="$LIB_KRB5_PATH $LIB_KRB5_LIBS $KRB5LIBS"
1555 KRB5INCS="$LIB_KRB5_CFLAGS"
1556 AC_DEFINE(USE_SOLARIS_KRB5,1,[Solaris Kerberos support is available])
9603207d 1557 KRB5_FLAVOUR="Solaris"
1558
1a22a39e
MM
1559 # check for other specific broken implementations
1560 CXXFLAGS="$CXXFLAGS $KRB5INCS"
1561 LIBS="$LIBS $KRB5LIBS"
1562
1563 AC_MSG_NOTICE([Try to find Kerberos headers in given path])
1564 AC_CHECK_HEADERS(gssapi/gssapi.h gssapi/gssapi_ext.h)
1565 AC_CHECK_HEADERS(krb5.h com_err.h)
1566
1567 SQUID_CHECK_KRB5_SOLARIS_BROKEN_KRB5_H
1568 if test "x$squid_cv_broken_krb5_h" = "xyes"; then
1569 AC_DEFINE(HAVE_BROKEN_SOLARIS_KRB5_H, 1, [Define to 1 if Solaris krb5.h is broken for C++])
1570 AC_MSG_WARN([You have a broken Solaris <krb5.h> system include.])
1571 AC_MSG_WARN([Please see http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6837512])
1572 AC_MSG_WARN([If you need Kerberos support you will have to patch])
1573 AC_MSG_WARN([your system. See contrib/solaris/solaris-krb5-include.patch])
1574 fi
1a22a39e 1575 SQUID_CHECK_KRB5_FUNCS
1a22a39e 1576 fi
75c5f82b
AJ
1577 if test "x$with_mit_krb5" = "xyes" -a "x$KRB5LIBS" = "x"; then
1578 # Error only if Solaris flavour was detected while looking for required MIT Kerberos
1a22a39e 1579 AC_MSG_ERROR([Required Kerberos library not found])
75c5f82b
AJ
1580 elif test "x$KRB5LIBS" = "x"; then
1581 with_solaris_krb5=no
1582 with_mit_krb5=no
1a22a39e 1583 fi
1a22a39e
MM
1584 SQUID_STATE_ROLLBACK([squid_krb5_save])
1585fi
1586
75c5f82b 1587dnl User may specify Heimdal Kerberos is needed from a non-standard location
24531401 1588SQUID_AUTO_LIB(heimdal-krb5,[Heimdal Kerberos],[LIB_KRB5])
75c5f82b
AJ
1589AH_TEMPLATE(USE_HEIMDAL_KRB5,[Heimdal Kerberos support is available])
1590if test "x$with_heimdal_krb5" != "xno" -a "x$KRB5LIBS" = "x"; then
24531401
AJ
1591 CXXFLAGS="$LIB_KRB5_CFLAGS $CXXFLAGS"
1592 krb5confpath="$with_heimdal_krb5/bin"
75c5f82b
AJ
1593 # find installed libs via pkg-config or krb5-config
1594 PKG_CHECK_EXISTS(heimdal-krb5, [squid_pc_krb5_name="heimdal-krb5"])
1595 if test "x$squid_pc_krb5_name" = "x"; then
1596 PKG_CHECK_EXISTS(heimdal-gssapi, [squid_pc_krb5_name="heimdal-gssapi"])
1597 fi
297a2769 1598 if test "x$squid_pc_krb5_name" = "x" -a "$cross_compiling" = "no"; then
75c5f82b 1599 # Look for krb5-config (unless cross-compiling)
c4b12583 1600 AC_PATH_PROG(krb5_config,krb5-config,no,$krb5confpath)
75c5f82b
AJ
1601 if test "x$ac_cv_path_krb5_config" != "xno" ; then
1602 krb5confpath="`dirname $ac_cv_path_krb5_config`"
1603 ac_heimdal="`$ac_cv_path_krb5_config --version 2>/dev/null | grep -c -i heimdal`"
95ee97e7 1604 if test "x$with_heimdal_krb5" = "xyes" -a $ac_heimdal = 0; then
75c5f82b
AJ
1605 AC_MSG_ERROR([Could not find pkg-config or krb5-config for Heimdal Kerberos])
1606 fi
1607 else
1608 if test "x$with_heimdal_krb5" = "xyes"; then
1609 AC_MSG_ERROR([Could not find krb5-config in path])
1610 else
1611 AC_MSG_WARN([Could not find krb5-config in path])
1612 with_heimdal_krb5=no
1613 fi
1614 fi
1615 fi
1616fi
1617if test "x$with_heimdal_krb5" != "xno" -a "x$KRB5LIBS" = "x"; then
1a22a39e
MM
1618 SQUID_STATE_SAVE([squid_krb5_save])
1619 LIBS="$LIBS $LIB_KRB5_PATH"
1620
1621 # auto-detect using pkg-config
75c5f82b 1622 PKG_CHECK_MODULES([LIB_KRB5], $squid_pc_krb5_name,,[
77f4953d
AJ
1623 # look for krb5-config (unless cross-compiling)
1624 if test "$cross_compiling" = "no"; then
1625 if test "x$krb5confpath" = "x" ; then
1626 AC_PATH_PROG(krb5_config,krb5-config,no)
1627 if test "x$ac_cv_path_krb5_config" != "xno" ; then
1628 ac_krb5_config="$ac_cv_path_krb5_config"
1629 fi
1630 else
1631 ac_krb5_config="$krb5confpath/krb5-config"
1a22a39e 1632 fi
1a22a39e 1633 fi
75c5f82b 1634 if test "x$ac_krb5_config" != "x" -a -x "$ac_krb5_config"; then
1a22a39e
MM
1635 # Get libs, etc
1636 AC_MSG_NOTICE([Use krb5-config to get CXXFLAGS and LIBS])
1637 LIB_KRB5_CFLAGS="`$ac_krb5_config --cflags krb5 2>/dev/null`"
1638 LIB_KRB5_LIBS="`$ac_krb5_config --libs krb5 2>/dev/null`"
1639 LIB_KRB5_CFLAGS="`$ac_krb5_config --cflags gssapi 2>/dev/null` $LIB_KRB5_CFLAGS"
1640 LIB_KRB5_LIBS="`$ac_krb5_config --libs gssapi 2>/dev/null` $LIB_KRB5_LIBS"
1641 else
1642 ## For some OS pkg-config is broken or unavailable.
1643 ## Detect libraries the hard way.
b2bdde72 1644 SQUID_STATE_SAVE([squid_heimdal_save])
87a4a80f 1645 missing_required=
1a22a39e
MM
1646 AC_MSG_NOTICE([Try to find Kerberos libraries in given path])
1647 AC_CHECK_LIB(resolv, [main], [LIB_KRB5_LIBS="-lresolv $LIB_KRB5_LIBS"],[
87a4a80f
AJ
1648 AC_MSG_WARN([library 'resolv' is required for Heimdal Kerberos])
1649 missing_required=yes
1a22a39e 1650 ])
b2bdde72 1651 LIBS=$LIB_KRB5_LIBS
1a22a39e 1652 AC_CHECK_LIB(crypt, [main], [LIB_KRB5_LIBS="-lcrypt $LIB_KRB5_LIBS"],[
87a4a80f
AJ
1653 AC_MSG_WARN([library 'crypt' is required for Heimdal Kerberos])
1654 missing_required=yes
1a22a39e 1655 ])
b2bdde72 1656 LIBS=$LIB_KRB5_LIBS
1a22a39e 1657 AC_CHECK_LIB(roken, [main], [LIB_KRB5_LIBS="-lroken $LIB_KRB5_LIBS"],[
87a4a80f
AJ
1658 AC_MSG_WARN([library 'roken' is required for Heimdal Kerberos])
1659 missing_required=yes
1a22a39e 1660 ])
b2bdde72 1661 LIBS=$LIB_KRB5_LIBS
1a22a39e
MM
1662 AC_CHECK_LIB(heimbase, [main], [LIB_KRB5_LIBS="-lheimbase $LIB_KRB5_LIBS"],[
1663 AC_MSG_WARN([library 'heimbase' may be required for Heimdal Kerberos])
1664 ])
b2bdde72 1665 LIBS=$LIB_KRB5_LIBS
1a22a39e
MM
1666 AC_CHECK_LIB(wind, [main], [LIB_KRB5_LIBS="-lwind $LIB_KRB5_LIBS"],[
1667 AC_MSG_WARN([library 'wind' may be required for Heimdal Kerberos])
1668 ])
b2bdde72 1669 LIBS=$LIB_KRB5_LIBS
1a22a39e 1670 AC_CHECK_LIB(crypto, [main], [LIB_KRB5_LIBS="-lcrypto $LIB_KRB5_LIBS"],[
87a4a80f
AJ
1671 AC_MSG_WARN([library 'crypto' is required for Heimdal Kerberos])
1672 missing_required=yes
1a22a39e 1673 ])
b2bdde72 1674 LIBS=$LIB_KRB5_LIBS
1a22a39e 1675 AC_CHECK_LIB(com_err, [main], [LIB_KRB5_LIBS="-lcom_err $LIB_KRB5_LIBS"],[
87a4a80f
AJ
1676 AC_MSG_WARN([library 'com_err' is required for Heimdal Kerberos])
1677 missing_required=yes
1a22a39e 1678 ])
b2bdde72 1679 LIBS=$LIB_KRB5_LIBS
1a22a39e
MM
1680 AC_CHECK_LIB(hx509, [main], [LIB_KRB5_LIBS="-lhx509 $LIB_KRB5_LIBS"],[
1681 AC_MSG_WARN([library 'hx509' may be required for Heimdal Kerberos])
1682 ])
b2bdde72 1683 LIBS=$LIB_KRB5_LIBS
1a22a39e 1684 AC_CHECK_LIB(asn1, [main], [LIB_KRB5_LIBS="-lasn1 $LIB_KRB5_LIBS"],[
87a4a80f
AJ
1685 AC_MSG_WARN([library 'asn1' is required for Heimdal Kerberos])
1686 missing_required=yes
1a22a39e 1687 ])
b2bdde72 1688 LIBS=$LIB_KRB5_LIBS
1a22a39e 1689 AC_CHECK_LIB(krb5, [main], [LIB_KRB5_LIBS="-lkrb5 $LIB_KRB5_LIBS"],[
87a4a80f
AJ
1690 AC_MSG_WARN([library 'krb5' is required for Heimdal Kerberos])
1691 missing_required=yes
1a22a39e 1692 ])
b2bdde72 1693 LIBS=$LIB_KRB5_LIBS
1a22a39e
MM
1694 AC_CHECK_LIB(heimntlm, [main], [LIB_KRB5_LIBS="-lheimntlm $LIB_KRB5_LIBS"],[
1695 AC_MSG_WARN([library 'heimntlm' may be required for Heimdal Kerberos])
1696 ])
b2bdde72 1697 LIBS=$LIB_KRB5_LIBS
1a22a39e 1698 AC_CHECK_LIB(gssapi, [main], [LIB_KRB5_LIBS="-lgssapi $LIB_KRB5_LIBS"],[
87a4a80f
AJ
1699 AC_MSG_WARN([library 'gssapi' is required for Heimdal Kerberos])
1700 missing_required=yes
1a22a39e 1701 ])
b2bdde72 1702 SQUID_STATE_ROLLBACK([squid_heimdal_save])
87a4a80f
AJ
1703 if test "x$missing_required" = "xyes"; then
1704 LIB_KRB5_LIBS=""
1705 fi
1a22a39e 1706 fi
1a22a39e
MM
1707 ])
1708 if test "x$LIB_KRB5_LIBS" != "x"; then
1709 KRB5LIBS="$LIB_KRB5_PATH $LIB_KRB5_LIBS $KRB5LIBS"
1710 KRB5INCS="$LIB_KRB5_CFLAGS"
1711 AC_DEFINE(USE_HEIMDAL_KRB5,1,[Heimdal Kerberos support is available])
9603207d 1712 KRB5_FLAVOUR="Heimdal"
1713
1a22a39e
MM
1714 # check for other specific broken implementations
1715 CXXFLAGS="$CXXFLAGS $KRB5INCS"
1716 LIBS="$LIBS $KRB5LIBS"
1717
1718 AC_MSG_NOTICE([Try to find Kerberos headers in given path])
1719 AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h gssapi/gssapi_krb5.h)
1720 AC_CHECK_HEADERS(krb5.h com_err.h et/com_err.h)
1721
1722 SQUID_CHECK_KRB5_HEIMDAL_BROKEN_KRB5_H
1723 if test "x$squid_cv_broken_heimdal_krb5_h" = "xyes"; then
1724 AC_DEFINE(HAVE_BROKEN_HEIMDAL_KRB5_H, 1, [Define to 1 if Heimdal krb5.h is broken for C++])
1725 fi
1a22a39e 1726 SQUID_CHECK_KRB5_FUNCS
1a22a39e
MM
1727 fi
1728 if test "x$KRB5LIBS" = "x"; then
a4f19899 1729 if test "x$with_heimdal_krb5" = "xyes"; then
75c5f82b
AJ
1730 AC_MSG_ERROR([Required Heimdal Kerberos library not found])
1731 else
1732 AC_MSG_WARN([Heimdal Kerberos library not found])
1733 fi
1a22a39e 1734 fi
1a22a39e
MM
1735 SQUID_STATE_ROLLBACK([squid_krb5_save])
1736fi
1737
75c5f82b 1738dnl User may specify GNU gss is needed from a non-standard location
24531401 1739SQUID_AUTO_LIB(gnugss,[GNU gss],[LIB_KRB5])
75c5f82b
AJ
1740AH_TEMPLATE(USE_GNUGSS,[GNU gss support is available])
1741if test "x$with_gnugss" != "xno" -a "x$KRB5LIBS" = "x"; then
24531401
AJ
1742 CXXFLAGS="$LIB_KRB5_CFLAGS $CXXFLAGS"
1743 krb5confpath=
1a22a39e
MM
1744 SQUID_STATE_SAVE([squid_krb5_save])
1745 LIBS="$LIBS $LIB_KRB5_PATH"
1746
1747 # auto-detect using pkg-config
1748 PKG_CHECK_MODULES([LIB_KRB5],[gss],,[
1749 ## For some OS pkg-config is broken or unavailable.
1750 ## Detect libraries the hard way.
1751
1752 AC_MSG_NOTICE([Try to find Kerberos libraries in given path])
1753 AC_CHECK_LIB(gss, [main], [LIB_KRB5_LIBS="-lgss $LIB_KRB5_LIBS"],[
75c5f82b 1754 AC_MSG_WARN([library 'com_err' is required for GNU Kerberos])
1a22a39e 1755 ])
1a22a39e
MM
1756 ])
1757
1758 if test "x$LIB_KRB5_LIBS" != "x"; then
1759 KRB5LIBS="$LIB_KRB5_PATH $LIB_KRB5_LIBS $KRB5LIBS"
1760 KRB5INCS="$LIB_KRB5_CFLAGS"
1761 AC_DEFINE(USE_GNUGSS,1,[GNU Kerberos support is available])
9603207d 1762 KRB5_FLAVOUR="GNU GSS"
1a22a39e
MM
1763
1764 # check for other specific broken implementations
1765 CXXFLAGS="$CXXFLAGS $KRB5INCS"
1766 LIBS="$LIBS $KRB5LIBS"
1767
1768 AC_MSG_NOTICE([Try to find Kerbeors headers in given path])
1769 AC_CHECK_HEADERS(gss.h)
1770
1771 SQUID_CHECK_WORKING_GSSAPI
1772 SQUID_DEFINE_BOOL(HAVE_GSSAPI,$squid_cv_working_gssapi,[GSSAPI support])
1773
1774 SQUID_CHECK_SPNEGO_SUPPORT
1775 SQUID_DEFINE_BOOL(HAVE_SPNEGO,$squid_cv_have_spnego,[SPNEGO support])
1776
1777 SQUID_CHECK_WORKING_KRB5
1778 SQUID_DEFINE_BOOL(HAVE_KRB5,$squid_cv_working_krb5,[KRB5 support])
1a22a39e
MM
1779 fi
1780 if test "x$KRB5LIBS" = "x"; then
a4f19899 1781 if test "x$with_gnugss" = "xyes"; then
75c5f82b
AJ
1782 AC_MSG_ERROR([Required GNU GSS Kerberos library not found])
1783 else
1784 AC_MSG_WARN([GNU GSS Kerberos library not found])
1785 fi
1a22a39e 1786 fi
1a22a39e
MM
1787 SQUID_STATE_ROLLBACK([squid_krb5_save])
1788fi
75c5f82b
AJ
1789
1790if test "x$KRB5LIBS" != "x"; then
1a22a39e
MM
1791 with_krb5=yes
1792fi
1793AC_MSG_NOTICE([$KRB5_FLAVOUR Kerberos library support: ${with_krb5:=no} ${LIB_KRB5_PATH} ${LIB_KRB5_LIBS}])
1794AC_SUBST(KRB5INCS)
1795AC_SUBST(KRB5LIBS)
1a22a39e 1796
8aafbbc1 1797dnl On MinGW OpenLDAP is not available, so LDAP helpers can be linked
1a22a39e
MM
1798dnl only with Windows LDAP libraries using -lwldap32
1799case "$squid_host_os" in
1800 mingw)
1801 LDAPLIB="-lwldap32"
1802 LBERLIB=""
1803 ;;
1804 *)
1805 AC_CHECK_LIB(ldap, ldap_init, [LDAPLIB="-lldap"])
1806 dnl LDAP helpers need to know if -llber is needed or not
1807 AC_CHECK_LIB(lber, ber_init, [LBERLIB="-llber"])
1808 dnl if no ldap lib found check for mozilla version
1809 if test "x$ac_cv_lib_ldap_ldap_init" != x""yes; then
1810 oLIBS=$LIBS
1811 LIBS="$LIBPTHREADS"
1812 AC_CHECK_LIB(ldap60, ldap_init, [LDAPLIB="-lldap60"])
1813 LIBS="$LDAPLIB $LIBPTHREADS"
1814 AC_CHECK_LIB(prldap60, prldap_init, [LDAPLIB="-lprldap60 $LDAPLIB"])
1815 LIBS="$LDAPLIB $LIBPTHREADS"
1816 AC_CHECK_LIB(ssldap60, ldapssl_init, [LDAPLIB="-lssldap60 $LDAPLIB"])
1817 LIBS=$oLIBS
1818 fi
1819
1820 AC_CHECK_HEADERS(ldap.h lber.h)
1821 AC_CHECK_HEADERS(mozldap/ldap.h)
1822
1823 dnl
1824 dnl Check for LDAP_OPT_DEBUG_LEVEL
1825 dnl
1826 AC_MSG_CHECKING([for LDAP_OPT_DEBUG_LEVEL])
1827 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1828# include <ldap.h>
1829 ]],[[
1830 int i=LDAP_OPT_DEBUG_LEVEL
1831 ]])],
1832 [ AC_MSG_RESULT(yes) ],
1833 [ AC_MSG_RESULT(no) ])
1834
1835 dnl
1836 dnl Check for working ldap
1837 dnl
1838 oLIBS=$LIBS
1839 LIBS="$LDAPLIB $LBERLIB $LIBPTHREADS"
1840 AC_MSG_CHECKING([for working ldap])
1841 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1842# define LDAP_DEPRECATED 1
1843# if HAVE_LDAP_H
1844# include <ldap.h>
1845# elif HAVE_MOZLDAP_LDAP_H
1846# include <mozldap/ldap.h>
1847# endif
1848 int
1849 main(void)
1850 {
1851 char host[]="";
1852 int port;
1853
1854 ldap_init((const char *)&host, port);
1855
1856 return 0;
1857 }
9603207d 1858 ]])],
1859 [ AC_DEFINE(HAVE_LDAP, 1, [LDAP support])
1a22a39e
MM
1860 AC_MSG_RESULT(yes) ],
1861 [ AC_MSG_RESULT(no) ],
1862 [ AC_MSG_RESULT(cross-compiler cant tell) ])
1863 LIBS=$oLIBS
1864
1865 dnl
1866 dnl Check for ldap vendor
1867 dnl
1868 AC_MSG_CHECKING([for OpenLDAP])
1869 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1870# if HAVE_LDAP_H
1871# include <ldap.h>
1872# endif
1873# include <string.h>
1874 int
1875 main(void)
1876 {
1877 return strcmp(LDAP_VENDOR_NAME,"OpenLDAP");
1878 }
9603207d 1879 ]])],
1880 [ AC_DEFINE(HAVE_OPENLDAP, 1, [OpenLDAP support])
1a22a39e
MM
1881 AC_MSG_RESULT(yes) ],
1882 [ AC_MSG_RESULT(no) ],
1883 [ AC_MSG_RESULT(cross-compiler cant tell) ])
1884
1885 AC_MSG_CHECKING([for Sun LDAP SDK])
1886 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1887# if HAVE_LDAP_H
1888# include <ldap.h>
1889# endif
1890# include <string.h>
1891 int
1892 main(void)
1893 {
1894 return strcmp(LDAP_VENDOR_NAME,"Sun Microsystems Inc.");
1895 }
9603207d 1896 ]])],
1a22a39e
MM
1897 [ AC_DEFINE(HAVE_SUN_LDAP_SDK, 1, [Sun LDAP SDK support])
1898 AC_MSG_RESULT(yes) ],
1899 [ AC_MSG_RESULT(no) ],
1900 [ AC_MSG_RESULT(cross-compiler cant tell) ])
1901
1902 AC_MSG_CHECKING([for Mozilla LDAP SDK])
1903 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1904# if HAVE_LDAP_H
1905# include <ldap.h>
1906# elif HAVE_MOZLDAP_LDAP_H
1907# include <mozldap/ldap.h>
1908# endif
1909# include <string.h>
1910 int
1911 main(void)
1912 {
1913 return strcmp(LDAP_VENDOR_NAME,"mozilla.org");
1914 }
9603207d 1915 ]])],
1a22a39e
MM
1916 [ AC_DEFINE(HAVE_MOZILLA_LDAP_SDK, 1, [Mozilla LDAP SDK support])
1917 AC_MSG_RESULT(yes) ],
1918 [ AC_MSG_RESULT(no)],
1919 [ AC_MSG_RESULT(cross-compiler cant tell) ])
1920
1921 dnl
1922 dnl Check for LDAP_REBINDPROC_CALLBACK
1923 dnl
1924 AC_MSG_CHECKING([for LDAP_REBINDPROC_CALLBACK])
1925 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1926# if HAVE_LDAP_H
1927# include <ldap.h>
1928# elif HAVE_MOZLDAP_LDAP_H
1929# include <mozldap/ldap.h>
1930# endif
1931 ]],[[
1932 LDAP_REBINDPROC_CALLBACK ldap_rebind;
1933 ]])],
1934 [ AC_DEFINE(HAVE_LDAP_REBINDPROC_CALLBACK,1,[Define to 1 if you have LDAP_REBINDPROC_CALLBACK])
1935 AC_MSG_RESULT(yes) ],
1936 [ AC_MSG_RESULT(no) ])
1937
1938 dnl
1939 dnl Check for LDAP_REBIND_PROC
1940 dnl
1941 AC_MSG_CHECKING([for LDAP_REBIND_PROC])
1942 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1943# if HAVE_LDAP_H
1944# include <ldap.h>
1945# elif HAVE_MOZLDAP_LDAP_H
1946# include <mozldap/ldap.h>
1947# endif
1948 ]],[[
1949 LDAP_REBIND_PROC ldap_rebind;
1950 ]])],
1951 [ AC_DEFINE(HAVE_LDAP_REBIND_PROC,1,[Define to 1 if you have LDAP_REBIND_PROC])
1952 AC_MSG_RESULT(yes) ],
1953 [ AC_MSG_RESULT(no) ])
1954
1955 dnl
1956 dnl Check for LDAP_REBIND_FUNCTION
1957 dnl
1958 AC_MSG_CHECKING([for LDAP_REBIND_FUNCTION])
1959 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1960# define LDAP_REFERRALS
1961# if HAVE_LDAP_H
1962# include <ldap.h>
1963# elif HAVE_MOZLDAP_LDAP_H
1964# include <mozldap/ldap.h>
1965# endif
1966 ]],[[
1967 LDAP_REBIND_FUNCTION ldap_rebind;
1968 ]])],
1969 [ AC_DEFINE(HAVE_LDAP_REBIND_FUNCTION,1,[Define to 1 if you have LDAP_REBIND_FUNCTION])
1970 AC_MSG_RESULT(yes) ],
1971 [ AC_MSG_RESULT(no) ])
1972
1973 dnl
1974 dnl Check for LDAP_SCOPE_DEFAULT
1975 dnl
1976 AC_MSG_CHECKING([for LDAP_SCOPE_DEFAULT])
1977 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1978# if HAVE_LDAP_H
1979# include <ldap.h>
1980# elif HAVE_MOZLDAP_LDAP_H
1981# include <mozldap/ldap.h>
1982# endif
1983 ]],[[
1984 int i=LDAP_SCOPE_DEFAULT;
1985 ]])],
1986 [ AC_DEFINE(HAVE_LDAP_SCOPE_DEFAULT,1,[Define to 1 if you have LDAP_SCOPE_DEFAULT])
1987 AC_MSG_RESULT(yes) ],
1988 [ AC_MSG_RESULT(no) ])
1989
1990 dnl
1991 dnl Check for ldap_url_desc.lud_scheme
1992 dnl
1993 AC_CHECK_MEMBER(struct ldap_url_desc.lud_scheme,
1994 AC_DEFINE(HAVE_LDAP_URL_LUD_SCHEME,1,
1995 [Define to 1 if you have LDAPURLDesc.lud_scheme]),,[#include <ldap.h>])
1996
1997 dnl
1998 dnl Check for ldapssl_client_init
1999 dnl
2000 AC_CHECK_LIB(ldap,ldapssl_client_init,
2001 AC_DEFINE(HAVE_LDAPSSL_CLIENT_INIT,1,[Define to 1 if you have ldapssl_client_init]),)
2002
2003 dnl
2004 dnl Check for ldap_url_desc2str
2005 dnl
2006 AC_CHECK_LIB(ldap,ldap_url_desc2str,
2007 AC_DEFINE(HAVE_LDAP_URL_DESC2STR,1,[Define to 1 if you have ldap_url_desc2str]),)
2008
2009 dnl
2010 dnl Check for ldap_url_parse
2011 dnl
2012 AC_CHECK_LIB(ldap,ldap_url_parse,
2013 AC_DEFINE(HAVE_LDAP_URL_PARSE,1,[Define to 1 if you have ldap_url_parse]),)
2014
2015 dnl
2016 dnl Check for ldap_start_tls_s
2017 dnl
2018 AC_CHECK_LIB(ldap,ldap_start_tls_s,
2019 AC_DEFINE(HAVE_LDAP_START_TLS_S,1,[Define to 1 if you have ldap_start_tls_s]),)
2020 ;;
2021esac
2022
2023AC_SUBST(LDAPLIB)
2024AC_SUBST(LBERLIB)
2025
75a8daaf 2026SQUID_AUTO_LIB(systemd,[systemd API for start-up notification],[SYSTEMD])
6fa8c664
MM
2027AH_TEMPLATE(USE_SYSTEMD,[systemd support is available])
2028if test "x$with_systemd" != "xno" -a "x$squid_host_os" = "xlinux"; then
2029 SQUID_STATE_SAVE(squid_systemd_state)
2030
2031 # User may have provided a custom location for systemd. Otherwise...
2032 LIBS="$LIBS $SYSTEMD_PATH"
2033
2034 # auto-detect using pkg-config
2035 PKG_CHECK_MODULES(SYSTEMD,[libsystemd],,[
2036 # systemd < 209
2037 PKG_CHECK_MODULES(SYSTEMD,[libsystemd-daemon],,[:])
2038 ])
2039
2040 AC_CHECK_HEADERS(systemd/sd-daemon.h)
2041
2042 SQUID_STATE_ROLLBACK(squid_systemd_state) #de-pollute LIBS
2043
2044 if test "x$with_systemd" = "xyes" -a "x$SYSTEMD_LIBS" = "x"; then
2045 AC_MSG_ERROR([Required systemd library not found])
2046 fi
2047 if test "x$SYSTEMD_LIBS" != "x" ; then
2048 CXXFLAGS="$SYSTEMD_CFLAGS $CXXFLAGS"
75a8daaf 2049 LDFLAGS="$SYSTEMD_PATH $SYSTEMD_LIBS $LDFLAGS"
6fa8c664
MM
2050 AC_DEFINE(USE_SYSTEMD,1,[systemd support is available])
2051 else
2052 with_systemd=no
2053 fi
2054fi
2055AC_MSG_NOTICE([systemd library support: ${with_systemd:=auto} ${SYSTEMD_PATH} ${SYSTEMD_LIBS}])
2056
02749868 2057AC_ARG_ENABLE(forw-via-db,
47d80734
FC
2058 AS_HELP_STRING([--enable-forw-via-db],[Enable Forw/Via database]), [
2059 SQUID_YESNO([$enableval],[unrecognized argument to --enable-forw-via-db: $enableval])
02749868 2060])
21f6708d 2061SQUID_DEFINE_BOOL(USE_FORW_VIA_DB,${enable_forw_via_db:=no},
9676633b
FC
2062 [Enable Forw/Via database])
2063AC_MSG_NOTICE([Forw/Via database enabled: $enable_forw_via_db])
02749868 2064
6cfa8966 2065AC_ARG_ENABLE(cache-digests,
47d80734 2066 AS_HELP_STRING([--enable-cache-digests],
9676633b
FC
2067 [Use Cache Digests. See http://wiki.squid-cache.org/SquidFaq/CacheDigests]),
2068[
2069 SQUID_YESNO($enableval,
2070 [unrecognized argument to --enable-cache-digests: $enableval])
484f2ebc 2071])
0067eb06 2072SQUID_DEFINE_BOOL(USE_CACHE_DIGESTS,${enable_cache_digests:=no},
47d80734 2073 [Use Cache Digests for locating objects in neighbor caches.])
9676633b 2074AC_MSG_NOTICE([Cache Digests enabled: $enable_cache_digests])
47d80734 2075
484f2ebc 2076
9676633b
FC
2077################################
2078# check for netio plugin stuff #
2079################################
2080dnl order of these options handling is relevant in case the user
2081dnl supplies more than one --enable option. Options handled later
2082dnl override those handled earlier for io loop method manual override
2083AC_ARG_ENABLE(select,
2084 AS_HELP_STRING([--disable-select],[Disable select(2) support.]),
2085[
2086SQUID_YESNO($enableval,[--disable-select takes no extra argument])
39145d19
AJ
2087if test "x$enableval" = "xyes"; then
2088 if test "x$squid_host_os" = "xmingw"; then
2089 squid_opt_io_loop_engine="select_win32"
2090 else
2091 squid_opt_io_loop_engine="select"
2092 fi
2093fi
9676633b
FC
2094])
2095AC_MSG_NOTICE([enabling select syscall for net I/O: ${enable_select:=auto}])
cd748f27 2096
9bb83c8b 2097AC_ARG_ENABLE(poll,
62979ab1 2098 AS_HELP_STRING([--disable-poll],[Disable poll(2) support.]),
1b3db6d9 2099[
9676633b 2100SQUID_YESNO($enableval,[--disable-poll takes no extra argument])
fcabe077 2101test "x$enableval" = "xyes" && squid_opt_io_loop_engine="poll"
9bb83c8b 2102])
9676633b 2103AC_MSG_NOTICE([enabling poll syscall for net I/O: ${enable_poll:=auto}])
9bb83c8b 2104
1b3db6d9 2105AC_ARG_ENABLE(kqueue,
26d50fd2
AJ
2106 AS_HELP_STRING([--disable-kqueue],
2107 [Disable kqueue(2) support.]), [
9676633b 2108SQUID_YESNO($enableval,[--enable-kqueue takes no extra argument])
1b3db6d9 2109])
26d50fd2
AJ
2110if test "x${enable_kqueue:=auto}" != "xno" ; then
2111 AC_CHECK_HEADERS([sys/event.h],[],[
2112 if test "x${enable_kqueue}" = "xyes" ; then
2113 AC_MSG_ERROR([kqueue support requires sys/event.h header file.])
2114 fi
2115 ])
2116 AC_CHECK_FUNCS(kqueue,[],[
2117 if test "x${enable_kqueue}" = "xyes" ; then
2118 AC_MSG_ERROR([kqueue support missing in libc library.])
2119 fi
2120 ])
2121 if test "x$ac_cv_func_kqueue" = "xyes" -a "x$ac_cv_header_sys_event_h" = "xyes" ; then
2122 squid_opt_io_loop_engine="kqueue"
2123 else
2124 enable_kqueue="no"
2125 fi
9676633b 2126fi
26d50fd2 2127AC_MSG_NOTICE([enabling kqueue for net I/O: ${enable_kqueue:=auto}])
1b3db6d9 2128
a46d2c0e 2129dnl Enable epoll()
a46d2c0e 2130AC_ARG_ENABLE(epoll,
62979ab1 2131 AS_HELP_STRING([--disable-epoll],[Disable Linux epoll(2) support.]),
a46d2c0e 2132[
9676633b 2133SQUID_YESNO($enableval,[--disable-epoll takes no extra argument])
fcabe077 2134test "x$enableval" = "xyes" && squid_opt_io_loop_engine="epoll"
a46d2c0e 2135])
9676633b 2136AC_MSG_NOTICE([enabling epoll syscall for net I/O: ${enable_epoll:=auto}])
2ca8b332 2137
9676633b
FC
2138# auto-detect and verify epoll header and library present and working
2139# logic mapping and loop method selection are performed later
fcabe077 2140if test "x$enable_epoll" != "xno" ; then
2ca8b332 2141
9676633b
FC
2142 # check if libs are needed to support epoll
2143 # note: this code block seems quite generic. Could it be extracted
2144 # into a squid specific configure function?
af1e01a8 2145 SQUID_STATE_SAVE(squid_epoll_state)
9676633b 2146 AC_SEARCH_LIBS(epoll_ctl,[epoll])
fcabe077 2147 if test "x$ac_cv_search_epoll_ctl" = "xno" ; then
9676633b 2148 enable_epoll=no #disable. Needed code not found
fcabe077 2149 elif test "x$ac_cv_search_epoll_ctl" = "xnone required" ; then
9676633b
FC
2150 EPOLL_LIBS=""
2151 else
2152 EPOLL_LIBS=$ac_cv_search_epoll_ctl
2153 fi
2154 AC_SUBST(EPOLL_LIBS)
2155 SQUID_STATE_ROLLBACK(squid_epoll_state) #de-pollute LIBS
a46d2c0e 2156
9676633b 2157 # epoll requires sys/epoll.h
98d13964 2158 AC_CHECK_HEADERS([sys/epoll.h])
ad32c661
AJ
2159
2160 dnl Verify that epoll really works
dcac6885 2161 if test "x$ac_cv_search_epoll_ctl" != 'xno' ; then
af1e01a8 2162 SQUID_CHECK_EPOLL
ad32c661 2163 fi
2ca8b332 2164
fcabe077 2165 if test "x$enable_epoll" = "xyes" -a "x$squid_cv_epoll_works" = "xno" ; then
2ca8b332
AJ
2166 AC_MSG_ERROR([Epoll does not work. Force-enabling it is not going to help.])
2167 fi
ad32c661 2168fi
a46d2c0e 2169
a1ad2f9b
AJ
2170dnl Enable /dev/poll
2171AC_ARG_ENABLE(devpoll,
2172 AS_HELP_STRING([--disable-devpoll],[Disable Solaris /dev/poll support.]),
2173[
2174SQUID_YESNO($enableval,[--disable-devpoll takes no extra argument])
2175test "x$enableval" = "xyes" && squid_opt_io_loop_engine="devpoll"
2176])
2177AC_MSG_NOTICE([enabling /dev/poll for net I/O: ${enable_devpoll:=auto}])
2178
2179## auto-detect and verify devpoll header and library present and working
2180if test "x$enable_devpoll" != "xno"; then
2181
2182 # /dev/poll requires ioctl() and write()
2183 AC_CHECK_FUNCS(ioctl)
2184 AC_CHECK_FUNCS(write)
2185
2186 # /dev/poll requires sys/devpoll.h
2187 AC_CHECK_HEADERS([sys/devpoll.h],,[
2188 if test "x$enable_devpoll" = "xyes"; then
2189 AC_MSG_ERROR([--enable-devpoll specified but /dev/poll headers not found])
2190 fi
2191 enable_devpoll=no])
2192
2193 # Verify that /dev/poll really works
2194 if test "x$enable_devpoll" != 'xno' ; then
2195 SQUID_CHECK_DEVPOLL
2196 fi
2197
2198 if test "x$enable_devpoll" = "xyes" -a "x$squid_cv_devpoll_works" = "xno" ; then
2199 AC_MSG_ERROR([/dev/poll does not work. Force-enabling it is not going to help.])
2200 fi
2201fi
2202
9676633b 2203
72fd085a 2204AC_ARG_ENABLE(http-violations,
af1e01a8
FC
2205 AS_HELP_STRING([--disable-http-violations],
2206 [This allows you to remove code which is known to
47d80734 2207 violate the HTTP protocol specification.]), [
9676633b
FC
2208 SQUID_YESNO([$enableval],
2209 [unrecognized argument to --disable-http-violations: $enableval])
72fd085a 2210])
626096be 2211SQUID_DEFINE_BOOL(USE_HTTP_VIOLATIONS, ${enable_http_violations:=yes},
47d80734 2212 [Define to enable code which volates the HTTP standard specification])
9676633b 2213AC_MSG_NOTICE([HTTP violations support enabled: $enable_http_violations])
72fd085a 2214
47d80734 2215# IPFW Transparent Proxy
68075fad 2216AC_ARG_ENABLE(ipfw-transparent,
1d26e252
FC
2217 AS_HELP_STRING([--enable-ipfw-transparent],
2218 [Enable Transparent Proxy support for systems
47d80734 2219 using FreeBSD IPFW-style firewalling.]), [
1d26e252
FC
2220 SQUID_YESNO([$enableval],
2221 [unrecognized argument to --enable-ipfw-transparent: $enableval])
68075fad 2222])
0067eb06 2223SQUID_DEFINE_BOOL(IPFW_TRANSPARENT,${enable_ipfw_transparent:=no},
2277004e 2224 [Enable support for Transparent Proxy on systems using FreeBSD IPFW-style firewalling.])
1d26e252 2225AC_MSG_NOTICE([FreeBSD IPFW-based transparent proxying enabled: $enable_ipfw_transparent])
68075fad 2226
47d80734 2227# IP-Filter Transparent Proxy
5cafc1d6 2228AC_ARG_ENABLE(ipf-transparent,
2277004e 2229 AS_HELP_STRING([--enable-ipf-transparent],
1d26e252
FC
2230 [Enable Transparent Proxy support using IPFilter-style firewalling]), [
2231 SQUID_YESNO([$enableval],
2232 [unrecognized argument to --enable-ipf-transparent: $enableval])
5cafc1d6 2233])
be0c7ff0 2234#will be AC_DEFINEd later, after checking for appropriate infrastructure
4bd144d2
FC
2235#IPF currently broken. Default-disabled for now.
2236AC_MSG_NOTICE([IPF-based transparent proxying requested: ${enable_ipf_transparent:=no}])
5cafc1d6 2237
2b0dd4ac 2238dnl Enable PF Transparent Proxy
2239AC_ARG_ENABLE(pf-transparent,
2277004e 2240 AS_HELP_STRING([--enable-pf-transparent],
47d80734 2241 [Enable Transparent Proxy support for systems using PF network address redirection.]), [
1d26e252
FC
2242 SQUID_YESNO([$enableval],
2243 [unrecognized argument to --enable-pf-transparent: $enableval])
2b0dd4ac 2244])
be0c7ff0 2245#will be AC_DEFINEd later, after checking for appropriate infrastructure
b2192042
AJ
2246AC_MSG_NOTICE([PF-based transparent proxying requested: ${enable_pf_transparent:=no}])
2247
2248dnl Enable /dev/pf support for older PF Transparent Proxy systems (OpenBSD 4.x and older)
2249AC_ARG_WITH(nat-devpf,
2250 AS_HELP_STRING([--with-nat-devpf],
2251 [Enable /dev/pf support for NAT on older OpenBSD and FreeBSD kernels.]), [
2252 SQUID_YESNO([$enableval],
2253 [unrecognized argument to --with-nat-devpf: $enableval])
2254])
2255#will be AC_DEFINEd later, after checking for appropriate infrastructure
2256AC_MSG_NOTICE([NAT lookups via /dev/pf: ${with_nat_devpf:=no}])
2b0dd4ac 2257
4bd144d2 2258# Linux Netfilter Transparent Proxy
d852fbad 2259AC_ARG_ENABLE(linux-netfilter,
20ad76ab 2260 AS_HELP_STRING([--enable-linux-netfilter],
96f08e2d 2261 [Enable Transparent Proxy support for Linux (Netfilter)]), [
4bd144d2
FC
2262 SQUID_YESNO([$enableval],
2263 [unrecognized argument to --enable-linux-netfilter: $enableval])
d852fbad 2264])
4bd144d2 2265AC_MSG_NOTICE([Linux Netfilter support requested: ${enable_linux_netfilter:=auto}])
be0c7ff0 2266#will be AC_DEFINEd later, after checking for appropriate infrastructure
d852fbad 2267
425de4c8
AJ
2268
2269dnl Look for libnetfilter_conntrack options (needed for QOS netfilter marking)
24531401 2270SQUID_AUTO_LIB(netfilter-conntrack,[Netfilter conntrack],[LIBNETFILTER_CONNTRACK])
f4f6c2e0
AJ
2271AC_MSG_NOTICE([Linux Netfilter Conntrack support requested: ${with_netfilter_conntrack:=auto}])
2272if test "x$with_netfilter_conntrack" != "xno"; then
24531401
AJ
2273 LDFLAGS="$LIBNETFILTER_CONNTRACK_PATH $LDFLAGS"
2274 CPPFLAGS="$LIBNETFILTER_CONNTRACK_CFLAGS $CPPFLAGS"
f4f6c2e0
AJ
2275 AC_SEARCH_LIBS([nfct_query], [netfilter_conntrack],,[
2276 if test x"$with_netfilter_conntrack" = "xyes"; then
2277 AC_MSG_ERROR([--with-netfilter-conntrack specified but libnetfilter-conntrack library not found])
425de4c8 2278 fi
f4f6c2e0 2279 with_netfilter_conntrack=no])
425de4c8 2280 AC_CHECK_HEADERS([libnetfilter_conntrack/libnetfilter_conntrack.h \
f4f6c2e0
AJ
2281 libnetfilter_conntrack/libnetfilter_conntrack_tcp.h],,[
2282 if test x"$with_netfilter_conntrack" = "xyes"; then
2283 AC_MSG_ERROR([--with-netfilter-conntrack specified but libnetfilter-conntrack headers not found])
2284 fi
2285 with_netfilter_conntrack=no])
88a2a8c6
AJ
2286 # If nothing is broken; enable the libraries usage.
2287 if test "x$with_netfilter_conntrack" != "xno"; then
2288 with_netfilter_conntrack=yes
2289 fi
425de4c8
AJ
2290fi
2291
2292
bb7b5fd0 2293dnl Enable Large file support
2df6213e 2294buildmodel=""
2277004e 2295squid_opt_enable_large_files=no
2df6213e 2296
2297AC_ARG_WITH(large-files,
507ca601
FC
2298 AS_HELP_STRING([--with-large-files],[Enable support for large files (logs etc).]), [
2299 if test "x$withval" = "xyes"; then
2300 squid_opt_enable_large_files=yes
bb7b5fd0 2301 fi
2302])
2303
2df6213e 2304dnl UNIX Build environment
be0c7ff0 2305dnl AS_HELP_STRING is not suited here because it cannot to specify newlines
2df6213e 2306AC_ARG_WITH(build-environment,
507ca601 2307 AS_HELP_STRING([--with-build-environment=model],
9603207d 2308 [The build environment to use. Normally one of
507ca601
FC
2309 POSIX_V6_ILP32_OFF32 (32 bits),
2310 POSIX_V6_ILP32_OFFBIG (32 bits with large file support),
2311 POSIX_V6_LP64_OFF64 (64 bits),
2312 POSIX_V6_LPBIG_OFFBIG (large pointers and files),
2313 XBS5_ILP32_OFF32 i(legacy, 32 bits),
2314 XBS5_ILP32_OFFBIG (legacy, 32 bits with large file support),
2315 XBS5_LP64_OFF64 (legacy, 64 bits),
2316 XBS5_LPBIG_OFFBIG (legacy, large pointers and files)
2317 or default (The default for your OS)]), [
2318case "$withval" in
2df6213e 2319 yes|no)
507ca601
FC
2320 AC_MSG_FAILURE([--with-build-environment expects a build environment string as used by getconf])
2321 ;;
2df6213e 2322 *)
507ca601
FC
2323 buildmodel="$withval"
2324 ;;
2325esac
2df6213e 2326])
2327
228332d3
FC
2328#hack. Let's early-detect sizeof(long)
2329AC_CHECK_SIZEOF(long)
2330
fcabe077 2331if test "x$squid_opt_enable_large_files" = "xyes" -a "x$buildmodel" = "x"; then
2277004e
FC
2332 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
2333 if test "`getconf _$model 2>/dev/null || true`" = 1 || test "`getconf $model 2>/dev/null || true`" ; then
2334 buildmodel=$model
2335 break
2336 fi
2337 done
fcabe077 2338 if test "x$buildmodel" = "x"; then
2277004e
FC
2339 AC_MSG_WARN([No suitable build environment found for large files. Trying to use _FILE_OFFSET_BITS=64])
2340 fi
9b8002de 2341fi
0c0d381b 2342if test "x$buildmodel" = "xdefault" -o "x$buildmodel" = "x"; then
228332d3
FC
2343 # define _FILE_OFFSET_BITS if requested and needed
2344 if test "x$squid_opt_enable_large_files" = "xyes" -a $ac_cv_sizeof_long -le 4 ; then
507ca601
FC
2345 AC_MSG_NOTICE([Enabling -D_FILE_OFFSET_BITS=64])
2346 CFLAGS="-D_FILE_OFFSET_BITS=64 $CFLAGS"
2347 CXXFLAGS="-D_FILE_OFFSET_BITS=64 $CXXFLAGS"
2348 fi
2349else
2350 AC_MSG_NOTICE([Using $buildmodel build environment])
2351 if test "`getconf _$buildmodel 2>/dev/null || true`" = 1 || test "`getconf $buildmodel 2>/dev/null || true`" ; then
2352 : # All fine
2353 else
2354 AC_MSG_ERROR(Build environment $buildmodel not known to getconf.)
2355 fi
2356 CFLAGS="`getconf ${buildmodel}_CFLAGS` $CFLAGS"
2357 CXXFLAGS="`getconf ${buildmodel}_CFLAGS` $CXXFLAGS"
2358 LIBS="`getconf ${buildmodel}_LIBS` $LIBS"
2359 LDFLAGS="`getconf ${buildmodel}_LDFLAGS` $LDFLAGS"
941c31f3 2360 if test "x$squid_host_os" = "xsolaris" ; then
2277004e
FC
2361
2362# On Solaris getconf returns for CFLAGS -xarch=generic64, -Xa and -Usun options, and
2363# for LDFLAGS -xarch=generic64, but:
2364# "-Xa" is supported only by Sun cc, so we need to remove it when using gcc
2365# For gcc "-xarch=generic64" must be replaced with "-m64"
2366# The 'sun' define is needed by ipfilter includes, so we must remove "-Usun"
fcabe077 2367 if test "x$GCC" = "xyes"; then
2277004e
FC
2368 AC_MSG_NOTICE([Removing -Xa for gcc/g++ on $host])
2369 CFLAGS="`echo $CFLAGS | sed -e 's/-Xa//'`"
2370 CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-Xa//'`"
2371 AC_MSG_NOTICE([Replacing -xarch=generic64 with -m64 for gcc/g++ on $host])
2372 CFLAGS="`echo $CFLAGS | sed -e 's/-xarch=generic64/-m64/'`"
2373 CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-xarch=generic64/-m64/'`"
2374 LDFLAGS="`echo $LDFLAGS | sed -e 's/-xarch=generic64//'`"
2375 fi
2376 AC_MSG_NOTICE([Removing -Usun on $host])
2377 CFLAGS="`echo $CFLAGS | sed -e 's/-Usun//'`"
2378 CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-Usun//'`"
2379 fi
507ca601 2380fi
2df6213e 2381
3d674977 2382AC_ARG_ENABLE(follow-x-forwarded-for,
6ec005b5
FC
2383 AS_HELP_STRING([--enable-follow-x-forwarded-for],
2384 [Enable support for following the X-Forwarded-For
19b4777c
FC
2385 HTTP header to try to find the IP address of the
2386 original or indirect client when a request has
8075a4da 2387 been forwarded through other proxies.]), [
6ec005b5
FC
2388 SQUID_YESNO([$enableval],
2389 [unrecognized argument to --enable-follow-x-forwarded-for: $enableval])
8075a4da 2390])
6ec005b5 2391AC_MSG_NOTICE([Support for X-Forwarded-For enabled: ${enable_follow_x_forwarded_for:=yes}])
3a5af257 2392SQUID_DEFINE_BOOL(FOLLOW_X_FORWARDED_FOR,$enable_follow_x_forwarded_for,
47d80734 2393 [Enable following X-Forwarded-For headers])
3d674977 2394
3898f57f 2395AC_ARG_ENABLE(ident-lookups,
8075a4da 2396 AS_HELP_STRING([--disable-ident-lookups],
47d80734
FC
2397 [Remove code that supports performing Ident (RFC 931) lookups.]), [
2398 SQUID_YESNO([$enableval],[unrecognized argument to --disable-ident-lookups: $enableval])
8075a4da 2399])
6c5dc16a
FC
2400AC_MSG_NOTICE([Support for Ident lookups enabled: ${enable_ident_lookups:=yes}])
2401SQUID_DEFINE_BOOL(USE_IDENT,$enable_ident_lookups,[Support for Ident (RFC 931) lookups])
3898f57f 2402
9d798391 2403dnl Select Default hosts file location
2404AC_ARG_ENABLE(default-hostsfile,
8ea232f5
FC
2405 AS_HELP_STRING([--enable-default-hostsfile=path],
2406 [Select default location for hosts file.
75eaac6c
FC
2407 See hosts_file directive in squid.conf for details]), [
2408if test "x$enableval" != "xnone" -a "x$enableval" != "xno" ; then
2409 if test \! -f "$enableval"; then
2410 AC_MSG_WARN([Unable to find file $enableval. I hope you know what you are doing.])
20ad76ab 2411 fi
75eaac6c
FC
2412 squid_opt_default_hosts=$enableval
2413else
2414 squid_opt_default_hosts="none"
2415fi
2416])
2417AC_MSG_NOTICE([Default hosts file set to: ${squid_opt_default_hosts:=/etc/hosts}])
2418DEFAULT_HOSTS=$squid_opt_default_hosts
2419AC_SUBST(DEFAULT_HOSTS)
9d798391 2420
47d80734 2421# Select auth schemes modules to build
94439e4e 2422AC_ARG_ENABLE(auth,
26ffc057
FC
2423 AS_HELP_STRING([--enable-auth],
2424 [Build global support for authentication. The list of schemes
2425 and helpers to be enabled is defined elsewhere]), [
2426SQUID_YESNO([$enableval],
2427 [unrecognized argument to --enable-auth: $enableval])
94439e4e 2428])
26ffc057 2429AC_MSG_NOTICE([Authentication support enabled: ${enable_auth:=yes}])
2f1431ea
AJ
2430SQUID_DEFINE_BOOL(USE_AUTH,$enable_auth,[Enable support for authentication])
2431AM_CONDITIONAL(ENABLE_AUTH, test "x$enable_auth" != "xno")
26ffc057 2432AUTH_MODULES=""
dcbfe1a3 2433require_smblib="no"
26ffc057
FC
2434
2435AC_ARG_ENABLE(auth-basic,
2436 AS_HELP_STRING([--enable-auth-basic="list of helpers"],
2437 [Enable the basic authentication scheme, and build the specified helpers.
2438 Not providing an explicit list of helpers will attempt build of
2439 all possible helpers. Default is to do so.
2440 To disable the basic authentication scheme, use --disable-auth-basic.
d9655720 2441 To enable but build no helpers, specify "none".
03901cf8 2442 To see available helpers, see the src/auth/basic/ directory. ]),[
26ffc057
FC
2443#nothing to do really
2444])
03901cf8 2445m4_include([src/auth/basic/helpers.m4])
94439e4e 2446
12daeef6
AJ
2447AC_ARG_ENABLE(auth-digest,
2448 AS_HELP_STRING([--enable-auth-digest="list of helpers"],
2449 [Enable the Digest authentication scheme, and build the specified helpers.
26ffc057
FC
2450 Not providing an explicit list of helpers will attempt build of
2451 all possible helpers. Default is to do so.
12daeef6 2452 To disable the Digest authentication scheme, use --disable-auth-digest.
26ffc057 2453 To enable but build no helpers, specify "none".
d4d7f6dd 2454 To see available helpers, see the src/auth/digest/ directory. ]),[
12daeef6 2455#nothing to do, really
380f0a87 2456])
d4d7f6dd 2457m4_include([src/auth/digest/helpers.m4])
94439e4e 2458
26ffc057
FC
2459AC_ARG_ENABLE(auth-negotiate,
2460 AS_HELP_STRING([--enable-auth-negotiate="list of helpers"],
16c02b14 2461 [Enable the Negotiate authentication scheme, and build the specified
26ffc057
FC
2462 helpers.
2463 Not providing an explicit list of helpers will attempt build of
2464 all possible helpers. Default is to do so.
16c02b14 2465 To disable the Negotiate authentication scheme,
26ffc057
FC
2466 use --disable-auth-negotiate.
2467 To enable but build no helpers, specify "none".
16c02b14 2468 To see available helpers, see the src/auth/negotiate/ directory. ]),[
26ffc057 2469#nothing to do, really
6e785d85 2470])
16c02b14 2471m4_include([src/auth/negotiate/helpers.m4])
6e785d85 2472
12daeef6
AJ
2473AC_ARG_ENABLE(auth-ntlm,
2474 AS_HELP_STRING([--enable-auth-ntlm="list of helpers"],
2475 [Enable the NTLM authentication scheme, and build the specified helpers.
26ffc057
FC
2476 Not providing an explicit list of helpers will attempt build of
2477 all possible helpers. Default is to do so.
12daeef6 2478 To disable the NTLM authentication scheme, use --disable-auth-ntlm.
1a22a39e 2479 To enable but build no helpers, specify "none".
b817c20f 2480 To see available helpers, see the src/auth/ntlm/ directory. ]),[
1a22a39e 2481])
b817c20f 2482m4_include([src/auth/ntlm/helpers.m4])
c8093f05 2483
1a22a39e
MM
2484dnl Authentication libraries to build
2485dnl This list will not be needed when each auth library has its own Makefile
2486dnl this is to be placed AFTER each auth module's handler
2487AUTH_LIBS_TO_BUILD=
2488for module in $AUTH_MODULES; do
2489 AUTH_LIBS_TO_BUILD="$AUTH_LIBS_TO_BUILD ${module}/lib${module}.la"
2490done
2491AC_SUBST(AUTH_MODULES)
2492AC_SUBST(AUTH_LIBS_TO_BUILD)
dcbfe1a3 2493AM_CONDITIONAL(ENABLE_SMBLIB, test "x$require_smblib" = "xyes")
3d62cc61 2494
1a22a39e
MM
2495dnl Select logging daemon helpers to build
2496AC_ARG_ENABLE(log-daemon-helpers,
2497 AS_HELP_STRING([--enable-log-daemon-helpers="list of helpers"],
4d5dd85a 2498 [This option selects which logging daemon helpers to
1a22a39e 2499 build and install as part of the normal build process
4d5dd85a 2500 For a list of available helpers see the src/log/
1a22a39e
MM
2501 directory.]),[
2502#nothing to do, really
2503])
4d5dd85a 2504m4_include([src/log/helpers.m4])
9ca29d23 2505
c6588c68 2506AC_ARG_ENABLE(external-acl-helpers,
f2d9a578 2507 AS_HELP_STRING([--enable-external-acl-helpers="list of helpers"],
e046643f 2508 [Enable external_acl helpers support and the helpers themselves.
d9655720 2509 Default is to build all buildable helpers and enable support.
8ea232f5 2510 To disable support, use --disable-external-acl-helpers.
d9655720 2511 To build no helpers, specify "none".
e046643f 2512 To see available helpers, see the src/acl/external/
8ea232f5 2513 directory]), [
d9655720 2514#nothing to do, really
c6588c68 2515])
e046643f 2516m4_include([src/acl/external/helpers.m4])
d9655720 2517
fdbb3b19 2518dnl Select url_rewrite helpers to build
fdbb3b19 2519AC_ARG_ENABLE(url-rewrite-helpers,
081863f3 2520 AS_HELP_STRING([--enable-url-rewrite-helpers="list of helpers"],
fdbb3b19
AJ
2521 [This option selects which url_rewrite helpers to
2522 build and install as part of the normal build
8ea232f5
FC
2523 process. The default is to attempt the build of all possible
2524 helpers. Use --disable-url-rewrite-helpers to build none.
2525 For a list of available helpers see the
d6d6203a 2526 src/http/url_rewriters/ directory.]),[
fdbb3b19 2527])
d6d6203a 2528m4_include([src/http/url_rewriters/helpers.m4])
fdbb3b19 2529
a27cfbe0 2530dnl Select security helpers to build
8732ea9d
AJ
2531AC_ARG_ENABLE(security-cert-validators,
2532 AS_HELP_STRING([--enable-security-cert-validators="list of helpers"],
bbf79f12
AJ
2533 [This option selects which security certificate validator
2534 helpers to build and install as part of the normal build
a27cfbe0 2535 process. The default is to attempt the build of all possible
8732ea9d 2536 helpers. Use --disable-security-cert-validators to
bbf79f12
AJ
2537 build none. For a list of available helpers see the
2538 src/security/cert_validators/ directory.]),[
a27cfbe0 2539])
4d5dd85a 2540m4_include([src/security/cert_validators/helpers.m4])
a27cfbe0 2541
cb0b3d63
AJ
2542AC_ARG_ENABLE(security-cert-generators,
2543 AS_HELP_STRING([--enable-security-cert-generators="list of helpers"],
2544 [This option selects which security certificate validator
2545 helpers to build and install as part of the normal build
2546 process. The default is to attempt the build of all possible
2547 helpers. Use --disable-security-cert-genrators to
2548 build none. For a list of available helpers see the
2549 src/security/cert_generators/ directory.]),[
2550])
2551m4_include([src/security/cert_generators/helpers.m4])
2552
0d5ee502
AM
2553dnl Select storeid_rewrite helpers to build
2554AC_ARG_ENABLE(storeid-rewrite-helpers,
2555 AS_HELP_STRING([--enable-storeid-rewrite-helpers="list of helpers"],
2556 [This option selects which Store-ID rewrite helpers to
2557 build and install as part of the normal build
2558 process. The default is to attempt the build of all possible
2559 helpers. Use --disable-storeid-rewrite-helpers to build none.
2560 For a list of available helpers see the
0c1f8b9b 2561 src/store/id_rewriters/ directory.]),[
0d5ee502 2562])
0c1f8b9b 2563m4_include([src/store/id_rewriters/helpers.m4])
0d5ee502 2564
3a125142 2565AC_ARG_WITH(valgrind-debug,
0f705e3b
FC
2566 AS_HELP_STRING([--with-valgrind-debug],
2567 [Include debug instrumentation for use with valgrind]),
4e26f472
FC
2568[
2569 SQUID_YESNO([$withval],
2570 [unrecognized argument to --with-valgrind-debug: $withval])
fcabe077 2571 if test "x$withval" != "xno" ; then
4e26f472
FC
2572 AC_CHECK_HEADERS(valgrind/memcheck.h,[],[
2573 AC_MSG_ERROR([Valgrind support requested, needed headers not found.])
2574 ])
b4bab919 2575 fi
2576])
4e26f472
FC
2577SQUID_DEFINE_BOOL(WITH_VALGRIND,${with_valgrind_debug:=no},
2578 [Valgrind memory debugger support])
2579AC_MSG_NOTICE([Valgrind debug support enabled: $with_valgrind_debug])
b4bab919 2580
0e657244 2581dnl Enable WIN32 Service compile mode
2582AC_ARG_ENABLE(win32-service,
054a4caa 2583 AS_HELP_STRING([--enable-win32-service],
0f705e3b 2584 [Compile Squid as a WIN32 Service.
b284c470
FC
2585 Works only on MS-Windows platforms]), [
2586SQUID_YESNO([$enableval],
2587 [unrecognized argument to --enable-win32-service: $enableval])
0e657244 2588])
b284c470
FC
2589SQUID_DEFINE_BOOL(USE_WIN32_SERVICE,${enable_win32_service:=no},
2590 [Enable code supporting MS Windows service mode])
2591AC_MSG_NOTICE([MS Windows service mode enabled: $enable_win32_service])
0e657244 2592
b1485ff8 2593
29f22442 2594# Disable "unlinkd" code
fe0810ac 2595AC_ARG_ENABLE(unlinkd,
0a081cb0 2596 AS_HELP_STRING([--disable-unlinkd],[Do not use unlinkd]), [
0f705e3b
FC
2597SQUID_YESNO([$enableval],
2598 [unrecognized argument to --disable-unlinkd: $enableval])
fe0810ac 2599])
0f658b5b 2600SQUID_DEFINE_BOOL(USE_UNLINKD,${enable_unlinkd:=yes},
0f705e3b 2601 [Enable useage of unlinkd])
fcabe077 2602AM_CONDITIONAL(ENABLE_UNLINKD,test "x$enable_unlinkd" = "xyes")
fbc04c0a 2603AC_MSG_NOTICE([unlinkd enabled: $enable_unlinkd])
fe0810ac 2604
0f705e3b 2605# Enable backtraces on fatal errors
ce3d30fb 2606AC_ARG_ENABLE(stacktraces,
0f705e3b
FC
2607 AS_HELP_STRING([--enable-stacktraces],
2608 [Enable automatic call backtrace on fatal errors]), [
2609SQUID_YESNO([$enableval],
2610 [unrecognized argument to --enable-stacktraces: $enableval])
ce3d30fb 2611])
0f658b5b 2612SQUID_DEFINE_BOOL(PRINT_STACK_TRACE,${enable_stacktraces:=no},
0f705e3b 2613 [Print stack traces on fatal errors])
78614cd4 2614AC_MSG_NOTICE([Automatically print stack trace on fatal errors: $enable_stacktraces])
0a081cb0 2615
904676a2 2616# Enable X-Accelerator-Vary for Vary support within an accelerator setup
2092c67d 2617AC_ARG_ENABLE(x-accelerator-vary,
904676a2
FC
2618 AS_HELP_STRING([--enable-x-accelerator-vary],
2619 [Enable support for the X-Accelerator-Vary
e702812e
FC
2620 HTTP header. Can be used to indicate
2621 variance within an accelerator setup.
2622 Typically used together with other code
904676a2
FC
2623 that adds custom HTTP headers to the requests.]), [
2624SQUID_YESNO([$enableval],
2625 [unrecognized argument to --enable-x-accelerator-vary: $enableval])
f66a9ef4 2626])
0f658b5b 2627SQUID_DEFINE_BOOL(X_ACCELERATOR_VARY,${enable_x_accelerator_vary:=no},
904676a2 2628 [Enable support for the X-Accelerator-Vary HTTP header])
78614cd4 2629AC_MSG_NOTICE([X-Accelerator-Vary support enabled: $enable_x_accelerator_vary])
f66a9ef4 2630
24531401 2631SQUID_AUTO_LIB(cppunit,[cppunit test framework],[LIBCPPUNIT])
d93bf055 2632AS_IF([test "x$with_cppunit" != "xno"],[
24531401 2633 LIBCPPUNIT_LIBS="$LIBCPPUNIT_PATH -lcppunit"
d93bf055
AJ
2634 PKG_CHECK_MODULES([LIBCPPUNIT],[cppunit],[
2635 squid_cv_cppunit_version="`pkg-config cppunit --version`"
2636 AC_MSG_NOTICE([using system installed cppunit version $squid_cv_cppunit_version])
2637 AS_UNSET(squid_cv_cppunit_version)
2638
2639 SQUID_STATE_SAVE(squid_cppunit_state)
e77b66af
FC
2640 CXXFLAGS="${CXXFLAGS} ${LIBCPPUNIT_CFLAGS}"
2641 LIBS="${LIBS} ${LIBCPPUNIT_LIBS}"
d93bf055
AJ
2642 AC_CHECK_HEADERS(cppunit/extensions/HelperMacros.h)
2643 SQUID_STATE_ROLLBACK(squid_cppunit_state)
2644 ],[
2645 AC_MSG_WARN([cppunit does not appear to be installed. Squid does not require this, but code testing with 'make check' will fail.])
2646 ])
f5691f9c 2647])
f5691f9c 2648
090089c4 2649dnl Check for headers
2650AC_HEADER_DIRENT
2651AC_HEADER_STDC
db40ae20 2652
2653AC_CHECK_HEADERS( \
3680cc44
FC
2654 arpa/inet.h \
2655 arpa/nameser.h \
2656 assert.h \
2657 bstring.h \
3680cc44 2658 crypt.h \
3680cc44 2659 ctype.h \
ee4d4e85 2660 direct.h \
3680cc44
FC
2661 errno.h \
2662 execinfo.h \
2663 fcntl.h \
2664 fnmatch.h \
2665 getopt.h \
2666 glob.h \
2667 gnumalloc.h \
2668 grp.h \
3680cc44
FC
2669 ipl.h \
2670 lber.h \
2671 ldap.h \
2672 libc.h \
2673 limits.h \
2674 linux/posix_types.h \
2675 linux/types.h \
3680cc44 2676 malloc.h \
3680cc44
FC
2677 math.h \
2678 memory.h \
2679 mount.h \
2680 netdb.h \
2681 netinet/in.h \
2682 netinet/in_systm.h \
3680cc44 2683 netinet/tcp.h \
3680cc44
FC
2684 paths.h \
2685 poll.h \
321223fe 2686 priv.h \
3680cc44 2687 pwd.h \
c2afddd8 2688 regex.h \
3680cc44 2689 sched.h \
2ccf2eb2 2690 siginfo.h \
3680cc44 2691 signal.h \
3680cc44
FC
2692 stdarg.h \
2693 stddef.h \
3680cc44
FC
2694 stdio.h \
2695 stdlib.h \
3680cc44
FC
2696 string.h \
2697 strings.h \
2698 sys/bitypes.h \
3680cc44
FC
2699 sys/file.h \
2700 sys/ioctl.h \
d440d5a4 2701 sys/ipc.cc \
3680cc44
FC
2702 sys/param.h \
2703 sys/prctl.h \
321223fe 2704 sys/procctl.h \
3680cc44 2705 sys/md5.h \
c975f532 2706 sys/mman.h \
3680cc44
FC
2707 sys/msg.h \
2708 sys/resource.h \
2ccf2eb2 2709 sys/select.h \
d440d5a4 2710 sys/shm.h \
3680cc44
FC
2711 sys/socket.h \
2712 sys/stat.h \
3680cc44
FC
2713 syscall.h \
2714 sys/syscall.h \
2715 sys/time.h \
2716 sys/types.h \
2717 sys/uio.h \
2718 sys/un.h \
2719 sys/vfs.h \
2720 sys/wait.h \
2721 syslog.h \
2722 time.h \
2723 unistd.h \
2724 utime.h \
2725 varargs.h \
2726 byteswap.h \
2727 glib.h \
2728 stdint.h \
2729 inttypes.h \
cdb86165 2730 wchar.h
db40ae20 2731)
3c586e38 2732
ee80a919
AR
2733AC_CHECK_HEADERS( \
2734 linux/netfilter_ipv4.h \
2735 linux/netfilter_ipv6/ip6_tables.h \
fc68f6b1 2736,,,
dcd1dc78 2737SQUID_DEFAULT_INCLUDES
2738#if HAVE_LIMITS_H
2739#include <limits.h>
2740#endif
a74968c2
AJ
2741/* Netfilter ip(6)tables v1.4.0 has broken headers */
2742#if HAVE_NETINET_IN_H
2743#include <netinet/in.h>
2744#endif
dcd1dc78 2745)
2746
61beade2 2747dnl *BSD do not include the dependencies for all their net/ and netinet/ files
c92b4732 2748dnl We must include a few basic type headers for them to work.
d1e5191e 2749AC_CHECK_HEADERS( \
0c0d381b
FC
2750 net/if.h \
2751 netinet/if_ether.h\
2752 netinet/icmp6.h \
2753 netinet/in.h \
2754 netinet/ip.h \
2755 netinet/ip6.h \
0c0d381b
FC
2756 netinet/ip_icmp.h \
2757 netinet/ipl.h \
0c0d381b
FC
2758 net/pf/pfvar.h \
2759 net/pfvar.h \
2760 sys/mount.h\
2761 resolv.h \
d1e5191e
AJ
2762,,,
2763SQUID_BSDNET_INCLUDES)
5a3237b0 2764
aee0606f 2765AC_C_CONST
d57288d2 2766AC_C_BIGENDIAN
aee0606f 2767
6a9f6389 2768AC_STRUCT_TM
2769AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[
2770#if TM_IN_SYS_TIME
2771#if HAVE_SYS_TIME_H
2772#include <sys/time.h>
2773#endif
2774#elif HAVE_TIME_H
2775#include <time.h>
2776#endif
5c51415d 2777])
46c883ed 2778
08caf8c6 2779dnl Override rusage() detect on MinGW because is emulated in source code
78a60bca
AJ
2780case "$squid_host_os" in
2781 mingw)
08caf8c6 2782 AC_DEFINE(HAVE_STRUCT_RUSAGE)
2783 ac_cv_func_getrusage='yes'
eed82608 2784 AC_MSG_NOTICE([Using own rusage on Windows.])
08caf8c6 2785 ;;
9603207d 2786 *)
08caf8c6 2787 AC_CHECK_TYPE(struct rusage,AC_DEFINE(HAVE_STRUCT_RUSAGE,1,[The system provides struct rusage]),,[
8ff51bba 2788#if HAVE_SYS_TIME_H
2789#include <sys/time.h>
2790#endif
b54a6789 2791#if HAVE_SYS_RESOURCE_H
2792#include <sys/resource.h>
6a9f6389 2793#endif])
08caf8c6 2794 ;;
2795esac
b54a6789 2796
6a9f6389 2797AC_CHECK_MEMBERS([struct iphdr.ip_hl],,,[
2798#if HAVE_SYS_TYPES_H
2799#include <sys/types.h>
2800#endif
a025a745 2801#include <netinet/in.h>
2802#include <netinet/in_systm.h>
6ad85e8a 2803#include <netinet/ip.h>
b05490a8 2804#if defined (__linux__) || defined (__CYGWIN__)
6ad85e8a 2805#define ip_hl ihl
2806#endif
2807#ifndef __linux__
b05490a8 2808#ifndef __CYGWIN__
6ad85e8a 2809#define iphdr ip
b05490a8 2810#endif
6a9f6389 2811#endif])
a025a745 2812
090089c4 2813dnl Check for typedefs
77d6bd88 2814AC_CHECK_SIZEOF(void *)
090089c4 2815
41aa7d00
FC
2816# check for a bunch of types
2817AC_TYPE_INT8_T
2818AC_TYPE_UINT8_T
2819AC_TYPE_INT16_T
2820AC_TYPE_UINT16_T
2821AC_TYPE_INT32_T
2822AC_TYPE_UINT32_T
2823AC_TYPE_INT64_T
2824AC_TYPE_UINT64_T
2825AC_TYPE_PID_T
2826AC_TYPE_SIZE_T
2827AC_TYPE_SSIZE_T
2828AC_TYPE_OFF_T
2829AC_TYPE_UID_T
59a09b98 2830AC_CHECK_TYPE([bool])
41aa7d00
FC
2831#need the defines for PRId64
2832AC_CHECK_SIZEOF(int64_t)
2833AC_CHECK_SIZEOF(long)
fe1e5c91
AJ
2834#need the defines for PRIuSIZE
2835AC_CHECK_SIZEOF(size_t)
50f9c873
AR
2836#need the define for overflow checks
2837AC_CHECK_SIZEOF(off_t)
46e172d9 2838AC_CHECK_SIZEOF(size_t)
6a9f6389 2839
249b93df 2840dnl Some C++11 types we try to use
249b93df 2841AX_CXX_TYPE_UNIFORM_DISTRIBUTIONS
2fefc43c 2842SQUID_CXX_STD_UNDERLYING_TYPE
1dde4660 2843SQUID_CXX_STD_IS_TRIVIALLY_COPYABLE
a203dec7 2844
588e71df 2845dnl On Solaris 9 x86, gcc may includes a "fixed" set of old system include files
2846dnl that is incompatible with the updated Solaris header files.
2847dnl For this reason, we must check if pad128_t and upad128_t are defined.
2848AC_CHECK_TYPE(pad128_t,
2849 AC_DEFINE(HAVE_PAD128_T,1,[pad128_t is defined in system headers]),
2850 ,SQUID_DEFAULT_INCLUDES)
2851
2852AC_CHECK_TYPE(upad128_t,
2853 AC_DEFINE(HAVE_UPAD128_T,1,[upad128_t is defined in system headers]),
2854 ,SQUID_DEFAULT_INCLUDES)
2855
6a9f6389 2856AC_CHECK_TYPE(mode_t, AC_DEFINE(HAVE_MODE_T,1,[mode_t is defined by the system headers]),,SQUID_DEFAULT_INCLUDES)
2857AC_CHECK_TYPE(fd_mask, AC_DEFINE(HAVE_FD_MASK,1,[fd_mask is defined by the system headers]),,SQUID_DEFAULT_INCLUDES)
adcceb47 2858
6a9f6389 2859AC_CHECK_TYPE(socklen_t,AC_DEFINE(HAVE_SOCKLEN_T,1,[socklen_t is defined by the system headers]),,[
2860#include <sys/types.h>
6637e3a5 2861#include <sys/socket.h>
2862#if STDC_HEADERS
2863#include <stdlib.h>
2864#include <stddef.h>
6a9f6389 2865#endif])
6637e3a5 2866
cdb352bb
FC
2867AC_CHECK_TYPE(mtyp_t,AC_DEFINE(HAVE_MTYP_T,1,
2868 [mtyp_t is defined by the system headers]),,[#include <sys/types.h>
2869#include <sys/ipc.h>
2870#include <sys/msg.h>])
2871
f367e6af
AJ
2872AC_CHECK_TYPE(cpu_set_t,
2873 AC_DEFINE(HAVE_CPU_SET_T,1,[cpu_set_t is defined by the system headers]),,[
2874#if HAVE_SCHED_H
2875#include <sched.h>
2876#endif
2877])
2878
fe1e5c91
AJ
2879# check for compiler support of %zu printf macro
2880AH_TEMPLATE(PRIuSIZE,[Compiler supports %zu printf macro])
2881AC_MSG_CHECKING([for compiler %zu support])
2882AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2883#include <stdio.h>
2884 ]],[[size_t n=1;printf("%zu",n);]])],[
2885 AC_DEFINE(PRIuSIZE,"zu")
2886 AC_MSG_RESULT(yes)
2887 ],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])
2888
2889
cdb352bb
FC
2890dnl Check for special functions
2891AC_FUNC_ALLOCA
2892
2893
24531401
AJ
2894# TODO: remove this 'lib' prefix to match coding standard
2895SQUID_AUTO_LIB(libcap,[Linux capabilities],[LIBCAP])
45c41a07 2896if test "x$with_libcap" != "xno"; then
24531401
AJ
2897 CXXFLAGS="$LIBCAP_CFLAGS $CXXFLAGS"
2898 LDFLAGS="$LIBCAP_PATH $LDFLAGS"
b64b6030 2899 # cap_clear_flag is the most recent libcap function we require
45c41a07 2900 AC_CHECK_HEADERS(sys/capability.h)
b64b6030 2901 AC_CHECK_LIB(cap, cap_clear_flag)
45c41a07
FC
2902 SQUID_CHECK_FUNCTIONAL_LIBCAP2
2903
2904 # if it can't be supported..
35e2b2e5 2905 if test "x$ac_cv_header_sys_capability_h" = "xno" -o \
46f50de9 2906 "x$ac_cv_lib_cap_cap_clear_flag" = "xno"; then
45c41a07 2907 # and it was forced on: error
46f50de9 2908 if test "x$with_libcap" = "xyes" ; then
ff8d255b 2909 AC_MSG_ERROR([libcap forced enabled but not available or not usable, requires libcap-2.09 or later])
3fbda12c
FC
2910 else
2911 # with_libcap is "auto"; it can't be supported. Disable.
2912 with_libcap=no
b64b6030 2913 fi
45c41a07
FC
2914 else
2915 # header and lib are ok, we support
2916 with_libcap=yes
b64b6030 2917 fi
69367152 2918
b50f1b2b 2919fi
5b43d209 2920
45c41a07
FC
2921SQUID_DEFINE_BOOL(USE_LIBCAP,$with_libcap,
2922 [use libcap to set capabilities required for TPROXY])
2923AC_MSG_NOTICE([libcap support enabled: $with_libcap])
2924SQUID_DEFINE_BOOL(LIBCAP_BROKEN,${squid_cv_sys_capability_works:=no},
2925 [libcap2 headers are broken and clashing with glibc])
2926AC_MSG_NOTICE([libcap2 headers are ok: $squid_cv_sys_capability_works])
2927
b64b6030 2928
090089c4 2929dnl Check for needed libraries
54c95954 2930AC_SEARCH_LIBS([gethostbyname],[nsl resolv bind])
819656da
AJ
2931AC_SEARCH_LIBS([res_init],[resolv])
2932AC_SEARCH_LIBS([__res_search],[resolv])
54c95954
FC
2933AC_SEARCH_LIBS([bind],[socket])
2934AC_SEARCH_LIBS([opcom_stack_trace],[opcom_stack])
85cd85f3 2935AC_SEARCH_LIBS([yp_match], [nsl nss_nis nss_nisplus])
bfe8dedf 2936dnl Check for Winsock only on MinGW, on Cygwin we must use emulated BSD socket API
0c0d381b
FC
2937if test "x$squid_host_os" = "xmingw" ; then
2938 SQUID_CHECK_WINSOCK_LIB
32341684
AJ
2939 AC_CHECK_HEADERS( \
2940 windows.h \
2941 ws2tcpip.h \
b966288b 2942 iphlpapi.h ,,,[
2ff9dfaa
AJ
2943#if HAVE_WINSOCK2_H
2944#include <winsock2.h>
2945#endif
32341684
AJ
2946#if HAVE_WINDOWS_H
2947#include <windows.h>
2948#endif
2ff9dfaa
AJ
2949#if HAVE_WS2TCPIP_H
2950#include <ws2tcpip.h>
2951#endif
2952])
0c0d381b 2953fi
94d48591 2954
46f50de9
FC
2955# check that we have unix sockets
2956SQUID_CHECK_UNIX_SOCKET
2957SQUID_DEFINE_BOOL(HAVE_UNIXSOCKET,$squid_cv_unixsocket,[System supports unix sockets])
2958
2959AC_CHECK_LIB(gnumalloc, malloc)
2960if test "x$ac_cv_lib_gnumalloc_malloc" = "xyes"; then
ef7ece58 2961 AC_MSG_NOTICE([Disabling extended malloc functions when using bundled gnumalloc])
46f50de9
FC
2962 ac_cv_func_mallocblksize=no
2963 ac_cv_func_mallopt=no
2964else
2965 case "$squid_host_os" in
2966 solaris)
2967 AC_MSG_NOTICE([skipping libmalloc check for $host])
2968 ;;
2969 freebsd)
2970 AC_MSG_NOTICE([skipping libmalloc check for $host])
2971 ;;
2972 *)
9837567d 2973 # XXX: used later
46f50de9
FC
2974 AC_CHECK_LIB(malloc, main)
2975 ;;
cdb352bb
FC
2976 esac
2977fi
94d48591 2978
78a60bca
AJ
2979case "$squid_host_os" in
2980 mingw)
2981 AC_MSG_NOTICE([Use MSVCRT for math functions.])
2982 ;;
2983 *)
23d0a396 2984 dnl log() are only used in old C code for now.
78a60bca 2985 AC_LANG_PUSH([C])
78a60bca
AJ
2986 AC_SEARCH_LIBS([log],[m])
2987 AC_LANG_POP([C])
2988 ;;
08caf8c6 2989esac
090089c4 2990
f467f578
FC
2991dnl --with-maxfd present for compatibility with Squid-2.
2992dnl undocumented in ./configure --help to encourage using the Squid-3 directive
2993AC_ARG_WITH(maxfd,,
9603207d 2994[
f467f578
FC
2995 case ${withval} in
2996 [[0-9]]*)
2997 squid_filedescriptors_num=$withval
acea95af 2998 AC_MSG_NOTICE([forcing default of $squid_filedescriptors_num filedescriptors (user-forced)])
f467f578
FC
2999 ;;
3000 *)
3001 AC_MSG_ERROR(--with-maxfd expects a numeric argument)
3002 ;;
3003 esac
055421ee 3004])
001ad4cc 3005
f467f578
FC
3006AC_ARG_WITH(filedescriptors,
3007 AS_HELP_STRING([--with-filedescriptors=NUMBER],
3008 [Force squid to support NUMBER filedescriptors]),
9603207d 3009[
f467f578
FC
3010 case ${withval} in
3011 [[0-9]]*)
3012 squid_filedescriptors_num=$withval
acea95af 3013 AC_MSG_NOTICE([forcing default of $squid_filedescriptors_num filedescriptors (user-forced)])
f467f578
FC
3014 ;;
3015 *)
3016 AC_MSG_ERROR(--with-filedescriptors expects a numeric argument)
3017 ;;
3018 esac
001ad4cc 3019])
f467f578
FC
3020
3021SQUID_CHECK_DEFAULT_FD_SETSIZE
acea95af 3022SQUID_CHECK_MAXFD
001ad4cc 3023
f467f578 3024
001ad4cc
AJ
3025dnl Enable IPv6 support
3026AC_MSG_CHECKING([whether to enable IPv6])
001ad4cc 3027AC_ARG_ENABLE(ipv6,
af494bc8
FC
3028 AS_HELP_STRING([--disable-ipv6],[Disable IPv6 support. The default is to probe system capabilities on startup.]), [
3029SQUID_YESNO([$enableval],[unrecognized argument to --disable-ipv6: $enableval])
001ad4cc 3030])
7d927f1f
AJ
3031AC_MSG_RESULT(${enable_ipv6:=yes})
3032SQUID_DEFINE_BOOL(USE_IPV6,$enable_ipv6,[Enable support for IPv6 ])
001ad4cc 3033
7d927f1f 3034if test "x$enable_ipv6" = "xyes" ; then
af494bc8 3035 SQUID_CHECK_SIN6_LEN_IN_SAI
001ad4cc 3036fi
7d553ad9
AJ
3037SQUID_CHECK_SS_LEN_IN_SOCKADDR_STORAGE
3038SQUID_CHECK_SIN_LEN_IN_SOCKADDR_IN
001ad4cc 3039
77f675ad 3040dnl System-specific library modifications
3041dnl
057a3cf3 3042AH_TEMPLATE(GETTIMEOFDAY_NO_TZP,[If gettimeofday is known to take only one argument])
77f675ad 3043case "$host" in
fcabe077
FC
3044 i386-*-solaris2.*)
3045 if test "x$GCC" = "xyes"; then
3046 AC_MSG_NOTICE([Removing -O for gcc on $host])
d0441961 3047 CFLAGS="`echo $CFLAGS | sed -e 's/-O[[0-9g]]*//'`"
fcabe077
FC
3048 fi
3049 ;;
141eb4a6 3050
fcabe077
FC
3051 *-sgi-irix*)
3052 AC_MSG_NOTICE([Removing -lsocket for IRIX...])
3053 LIBS=`echo $LIBS | sed -e s/-lsocket//`
3054 AC_MSG_NOTICE([Removing -lnsl for IRIX...])
3055 LIBS=`echo $LIBS | sed -e s/-lnsl//`
3056 ac_cv_lib_nsl_main=no
fcabe077 3057 ;;
fcabe077 3058 *-ibm-aix*)
3e1ce596
KB
3059 SQUID_CC_REQUIRE_ARGUMENT([ac_cv_require_rtti],[-rtti],[[
3060#include <assert.h>
3061#ifndef NULL
3062#define NULL 0
3063#endif
3064class Foo{
3065public:virtual ~Foo(){}
3066};
3067class Bar:public Foo{
3068public:Bar():Foo(){}
3069};
3070 ]],[[
3071Foo * myFoo=new Bar();
3072Bar * myBar=dynamic_cast<Bar *>(myFoo);
3073assert(myBar != NULL);
3074 ]])
3075 if test "$ac_cv_require_rtti" = "yes"; then
3076 SQUID_CFLAGS="-rtti $SQUID_CFLAGS"
3077 SQUID_CXXFLAGS="-rtti $SQUID_CXXFLAGS"
fcabe077 3078 fi
3e1ce596
KB
3079
3080 AC_LANG_PUSH([C])
3081 SQUID_CC_REQUIRE_ARGUMENT([ac_cv_require_qcpluscmt],[-qcpluscmt],[[]],[[//c++ cmt]])
fcabe077 3082 AC_LANG_POP([C])
3e1ce596
KB
3083 if test "$ac_cv_require_qcpluscmt" = "yes"; then
3084 SQUID_CFLAGS="-qcpluscmt $SQUID_CFLAGS"
3085 fi
fcabe077 3086 ;;
3e1ce596 3087
fcabe077
FC
3088 [*-*-solaris2.[0-4]])
3089 AC_DEFINE(GETTIMEOFDAY_NO_TZP,1)
3090 ;;
3091 [*-sony-newsos[56]*])
3092 AC_DEFINE(GETTIMEOFDAY_NO_TZP,1)
3093 ;;
3094 esac
090089c4 3095
84cecfd2 3096dnl This has to be before AC_CHECK_FUNCS
3097# Disable poll() on certain platforms. Override by setting ac_cv_func_poll
3098# when running configure.
fcabe077
FC
3099if test "x$ac_cv_func_poll" = "x" ; then
3100 case "$host" in
3101 [*-hp-hpux*.*])
3102 # Duane Wessels
3103 AC_MSG_NOTICE([disabling poll for $host...])
3104 ac_cv_func_poll='no'
3105 ;;
3106 [*-linux-*])
3107 # Henrik Nordstrom (hno@squid-cache.org) 19980817
3108 # poll is problematic on Linux. We disable it
3109 # by default until Linux gets it right.
3110 rev=`uname -r | awk -F. '{printf "%03d%03d",$1,$2}'`
3111 if test $rev -lt 002002; then
3112 AC_MSG_NOTICE([disabling poll for $host < 2.2...])
3113 ac_cv_func_poll='no'
3114 fi
3115 ;;
3116 [powerpc-ibm-aix4.1.*])
3117 # Mike Laster (mlaster@metavillage.com) 19981021
3118 AC_MSG_NOTICE([disabling poll for $host...])
3119 ac_cv_func_poll='no'
3120 ;;
fcabe077 3121 esac
84cecfd2 3122fi
176d10ee 3123
6716b242 3124dnl Check for library functions
3125AC_CHECK_FUNCS(\
ce3d30fb 3126 backtrace_symbols_fd \
3a144521 3127 bcopy \
4de1e2da 3128 eui64_aton \
4ac29a5b 3129 fchmod \
6716b242 3130 getdtablesize \
8505e57b 3131 getpagesize \
230c091c 3132 getpass \
30a4f2a8 3133 getrusage \
9c1d8929 3134 getspnam \
379d5751 3135 gettimeofday \
52303a3d 3136 glob \
0f5efab0 3137 mallocblksize \
6716b242 3138 mallopt \
2ae6b9b0 3139 memcpy \
30a4f2a8 3140 memmove \
ee4d4e85 3141 memrchr \
dac27377 3142 memset \
b99a6dec 3143 mkstemp \
1812b6c7 3144 mktime \
88738790 3145 mstats \
84cecfd2 3146 poll \
62ae0622 3147 prctl \
321223fe 3148 procctl \
3a144521 3149 pthread_attr_setschedparam \
cd748f27 3150 pthread_attr_setscope \
3151 pthread_setschedparam \
42b51993 3152 pthread_sigmask \
c68e9c6b 3153 putenv \
c2afddd8
AJ
3154 regcomp \
3155 regexec \
3156 regfree \
819656da
AJ
3157 res_init \
3158 __res_init \
4915be3b 3159 rint \
96c2bb61
AR
3160 sched_getaffinity \
3161 sched_setaffinity \
3a144521 3162 select \
234967c9 3163 seteuid \
c415c128 3164 setgroups \
321223fe 3165 setpflags \
30a4f2a8 3166 setpgrp \
30a4f2a8 3167 setsid \
3168 sigaction \
11430c03 3169 snprintf \
1ccc0d40 3170 socketpair \
6716b242 3171 sysconf \
3172 syslog \
234967c9 3173 timegm \
28da5e0d 3174 vsnprintf \
6716b242 3175)
f5e5c4cf 3176dnl ... and some we provide local replacements for
3177AC_REPLACE_FUNCS(\
f5e5c4cf 3178 initgroups \
2ccf2eb2 3179 psignal \
f5e5c4cf 3180 strerror \
585cddda 3181 strtoll \
f5e5c4cf 3182 tempnam \
3183)
6716b242 3184
dfb96b6b 3185AC_CHECK_DECLS([getaddrinfo,getnameinfo,inet_ntop,inet_pton,InetNtopA,InetPtonA],,,[
55d7d5e9
AJ
3186/*
3187 * BSD requires sys/types.h, sys/socket.h, netinet/in.h, netdb.h, arpa/inet.h
3188 * Linux requires sys/types.h, sys/socket.h, arpa/inet.h
3189 * Windows requires sys/socket.h, winsock2.h, ws2tcpip.h
3190 */
3191#if HAVE_SYS_TYPES_H
3192#include <sys/types.h>
3193#endif
3194#if HAVE_NETINET_IN_H
3195#include <netinet/in.h>
3196#endif
3197#if HAVE_SYS_SOCKET_H
3198#include <sys/socket.h>
3199#endif
3200#if HAVE_NETDB_H
3201#include <netdb.h>
3202#endif
3203#if HAVE_ARPA_INET_H
3204#include <arpa/inet.h>
3205#endif
3206#if HAVE_WINSOCK2_H
3207#include <winsock2.h>
3208#endif
3209#if HAVE_WS2TCPIP_H
3210#include <ws2tcpip.h>
3211#endif
3212])
3213
9676633b
FC
3214# Magic which checks whether we are forcing a type of comm loop we
3215# are actually going to (ab)use.
3216# Mostly ripped from squid-commloops, thanks to adrian and benno
1b3db6d9 3217
fcabe077 3218if test "x$squid_opt_io_loop_engine" != "x"; then
8075a4da 3219 AC_MSG_NOTICE([choosing user-specified net I/O API $squid_opt_io_loop_engine])
fcabe077 3220elif test "x$enable_epoll" != "xno" -a "x$squid_cv_epoll_works" = "xyes" ; then
8075a4da 3221 squid_opt_io_loop_engine="epoll"
26d50fd2 3222elif test "x$enable_kqueue" != "xno" ; then
8075a4da 3223 squid_opt_io_loop_engine="kqueue"
a1ad2f9b
AJ
3224elif test "x$enable_devpoll" != "xno" ; then
3225 squid_opt_io_loop_engine="devpoll"
fcabe077 3226elif test "x$enable_poll" != "xno" -a "x$ac_cv_func_poll" = "xyes" ; then
8075a4da 3227 squid_opt_io_loop_engine="poll"
39145d19 3228elif test "x$enable_select" != "xno" -a "x$ac_cv_func_select" = "xyes"; then
8075a4da 3229 squid_opt_io_loop_engine="select"
39145d19
AJ
3230elif test "x$enable_select" != "xno" -a "x$squid_host_os" = "xmingw"; then
3231 squid_opt_io_loop_engine="select_win32"
1b3db6d9 3232else
a1ad2f9b 3233 AC_MSG_WARN([Eep! Cannot find epoll, kqueue, /dev/poll, poll or select!])
be0c7ff0 3234 AC_MSG_WARN([Will try select and hope for the best.])
8075a4da 3235 squid_opt_io_loop_engine="select"
1b3db6d9 3236fi
d474c7a6 3237
8075a4da 3238AC_MSG_NOTICE([Using ${squid_opt_io_loop_engine} for the IO loop.])
d474c7a6 3239
8aafbbc1
AJ
3240AM_CONDITIONAL(ENABLE_POLL, test "x$squid_opt_io_loop_engine" = "xpoll")
3241AM_CONDITIONAL(ENABLE_EPOLL, test "x$squid_opt_io_loop_engine" = "xepoll")
3242AM_CONDITIONAL(ENABLE_SELECT, test "x$squid_opt_io_loop_engine" = "xselect")
3243AM_CONDITIONAL(ENABLE_SELECT_WIN32, test "x$squid_opt_io_loop_engine" = "xselect_win32")
3244AM_CONDITIONAL(ENABLE_KQUEUE, test "x$squid_opt_io_loop_engine" = "xkqueue")
3245AM_CONDITIONAL(ENABLE_DEVPOLL, test "x$squid_opt_io_loop_engine" = "xdevpoll")
d474c7a6 3246
8075a4da 3247case $squid_opt_io_loop_engine in
0abb39dd 3248 epoll) AC_DEFINE(USE_EPOLL,1,[Use epoll() for the IO loop]) ;;
a1ad2f9b 3249 devpoll) AC_DEFINE(USE_DEVPOLL,1,[Use /dev/poll for the IO loop]) ;;
0abb39dd
FC
3250 poll) AC_DEFINE(USE_POLL,1,[Use poll() for the IO loop]) ;;
3251 kqueue) AC_DEFINE(USE_KQUEUE,1,[Use kqueue() for the IO loop]) ;;
3252 select_win32) AC_DEFINE(USE_SELECT_WIN32,1,[Use Winsock select() for the IO loop]) ;;
3253 select) AC_DEFINE(USE_SELECT,1,[Use select() for the IO loop]) ;;
d474c7a6 3254esac
1b3db6d9 3255
96c2bb61
AR
3256if test "x$ac_cv_func_sched_getaffinity" = "xyes" -a "x$ac_cv_func_sched_setaffinity" = "xyes" ; then
3257 AC_DEFINE(HAVE_CPU_AFFINITY,1,[Support setting CPU affinity for workers])
3258fi
3259
91983da0
FC
3260SQUID_CHECK_SETRESUID_WORKS
3261if test "x$squid_cv_resuid_works" = "xyes" ; then
be0c7ff0 3262 AC_DEFINE(HAVE_SETRESUID,1,[Yay! Another Linux brokenness. Knowing that setresuid() exists is not enough, because RedHat 5.0 declares setresuid() but does not implement it.])
5c51415d 3263fi
60939927 3264
2ff9dfaa 3265AC_CHECK_HEADERS(mswsock.h)
14c0d3ab
DK
3266AC_MSG_CHECKING([for constant CMSG_SPACE])
3267AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3268 #if HAVE_SYS_SOCKET_H
3269 #include <sys/socket.h>
3270 #endif
2ff9dfaa
AJ
3271 #if HAVE_MSWSOCK_H
3272 #include <mswsock.h>
3273 #endif
14c0d3ab
DK
3274
3275 int a[CMSG_SPACE(int)];
3276]])], [
3277 AC_MSG_RESULT(yes)
3278 AC_DEFINE(HAVE_CONSTANT_CMSG_SPACE, 1, [Define to 1 if CMSG_SPACE is constant])
3279], [
3280 AC_MSG_RESULT(no)
3281])
3282
ecd8516d 3283AC_CHECK_TYPE(struct cmsghdr,AC_DEFINE(HAVE_CMSGHDR,1,[The system provides struct cmsghdr]),,[
c72f8c2e
AJ
3284 #if HAVE_SYS_SOCKET_H
3285 #include <sys/socket.h>
3286 #endif
2ff9dfaa
AJ
3287 #if HAVE_MSWSOCK_H
3288 #include <mswsock.h>
3289 #endif
c72f8c2e
AJ
3290 #if HAVE_WINSOCK2_H
3291 #include <winsock2.h>
3292 #endif
3293])
3294
ecd8516d 3295AC_CHECK_TYPE(struct iovec,AC_DEFINE(HAVE_IOVEC,1,[The system provides struct iovec]),,[
c72f8c2e
AJ
3296 #if HAVE_SYS_SOCKET_H
3297 #include <sys/socket.h>
3298 #endif
3299 #if HAVE_WINSOCK2_H
3300 #include <winsock2.h>
3301 #endif
9ac84dcf
FC
3302 #if HAVE_SYS_UIO_H
3303 #include <sys/uio.h>
3304 #endif
c72f8c2e
AJ
3305])
3306
ecd8516d 3307AC_CHECK_TYPE(struct msghdr,AC_DEFINE(HAVE_MSGHDR,1,[The system provides struct msghdr]),,[
c72f8c2e
AJ
3308 #if HAVE_SYS_SOCKET_H
3309 #include <sys/socket.h>
3310 #endif
2ff9dfaa
AJ
3311 #if HAVE_MSWSOCK_H
3312 #include <mswsock.h>
3313 #endif
c72f8c2e
AJ
3314 #if HAVE_WINSOCK2_H
3315 #include <winsock2.h>
3316 #endif
3317])
3318
ecd8516d 3319AC_CHECK_TYPE(struct sockaddr_un,AC_DEFINE(HAVE_SOCKADDR_UN,1,[The system provides sockaddr_un]),,[
c72f8c2e
AJ
3320 #if HAVE_SYS_UN_H
3321 #include <sys/un.h>
3322 #endif
3323 #if HAVE_SYS_SOCKET_H
3324 #include <sys/socket.h>
3325 #endif
3326 #if HAVE_WINSOCK2_H
3327 #include <winsock2.h>
3328 #endif
3329])
3330
0abb39dd 3331SQUID_CHECK_FUNC_STRNSTR
cee08cbc 3332
5cafc1d6 3333dnl IP-Filter support requires ipf header files. These aren't
3334dnl installed by default, so we need to check for them
fcabe077 3335if test "x$enable_ipf_transparent" != "xno" ; then
d25bbe26 3336 SQUID_CHECK_BROKEN_SOLARIS_IPFILTER
20ad76ab 3337 AC_MSG_CHECKING(for availability of IP-Filter header files)
42b51993 3338 # hold on to your hats...
fcabe077
FC
3339 if test "x$ac_cv_header_ip_compat_h" = "xyes" -o \
3340 "x$ac_cv_header_ip_fil_compat_h" = "xyes" -o \
3341 "x$ac_cv_header_netinet_ip_compat_h" = "xyes" -o \
3342 "x$ac_cv_header_netinet_ip_fil_compat_h" = "xyes" ; then
42b51993 3343 have_ipfilter_compat_header="yes"
d25bbe26
AJ
3344 fi
3345 if test "x$have_ipfilter_compat_header" = "xyes" -a \
fcabe077
FC
3346 "x$ac_cv_header_ip_fil_h" = "xyes" -a \
3347 "x$ac_cv_header_ip_nat_h" = "xyes" ; then
1d26e252 3348 enable_ipf_transparent="yes"
fcabe077
FC
3349 elif test "x$have_ipfilter_compat_header" = "xyes" -a \
3350 "x$ac_cv_header_netinet_ip_fil_h" = "xyes" -a \
3351 "x$ac_cv_header_netinet_ip_nat_h" = "xyes" ; then
1d26e252 3352 enable_ipf_transparent="yes"
eb824054 3353 else
1d26e252 3354 enable_ipf_transparent="no"
5cafc1d6 3355 fi
3356 AC_MSG_RESULT($IPF_TRANSPARENT)
d25bbe26
AJ
3357
3358## On Solaris Ipfilter includes expect that SOLARIS2 is defined with the
3359## Solaris minor version (8, 9, 10, ...)
3360 if test "x$enable_ipf_transparent" = "xyes" -a "x$squid_host_os" = "xsolaris" ; then
3361 solrev=`uname -r | sh -c 'IFS=. read j n x; echo $n'`
3362 CFLAGS="-DSOLARIS2=$solrev $CFLAGS"
3363 CXXFLAGS="-DSOLARIS2=$solrev $CXXFLAGS"
3364 fi
3365
1d26e252
FC
3366fi
3367AC_MSG_NOTICE([IPF-based transparent proxying enabled: $enable_ipf_transparent])
0f658b5b 3368SQUID_DEFINE_BOOL(IPF_TRANSPARENT,$enable_ipf_transparent,
1d26e252
FC
3369 [Enable support for IPF-style transparent proxying])
3370
b2192042
AJ
3371dnl PF /dev/pf support requires a header file.
3372if test "x$with_nat_devpf" != "xno" ; then
fcabe077
FC
3373 if test "x$ac_cv_header_net_pfvar_h" = "xyes" -o \
3374 "x$ac_cv_header_net_pf_pfvar_h" = "xyes"; then
b2192042
AJ
3375 if test "x$with_nat_devpf" = "xauto" ; then
3376 with_nat_devpf="no"
fcabe077
FC
3377 fi
3378 else
b2192042
AJ
3379 if test "x$with_nat_devpf" = "xyes" ; then
3380 AC_MSG_ERROR([PF /dev/pf based NAT requested but needed header not found])
fcabe077 3381 fi
b2192042 3382 with_nat_devpf="no"
fcabe077 3383 fi
2b0dd4ac 3384fi
b2192042 3385SQUID_DEFINE_BOOL(PF_TRANSPARENT,${enable_pf_transparent:=no},
38ff0a40 3386 [Enable support for PF-style transparent proxying])
b2192042
AJ
3387SQUID_DEFINE_BOOL(USE_NAT_DEVPF,${with_nat_devpf:=no},
3388 [Enable support for /dev/pf NAT lookups])
2b0dd4ac 3389
fcabe077
FC
3390if test "x$enable_linux_netfilter" != "xno" ; then
3391 if test "x$ac_cv_header_linux_netfilter_ipv4_h" = "xyes"; then
3392 if test "x$enable_linux_netfilter" = "xauto" ; then
4bd144d2
FC
3393 enable_linux_netfilter=yes
3394 fi
3395 else
fcabe077 3396 if test "x$enable_linux_netfilter" = "xauto" ; then
4bd144d2 3397 enable_linux_netfilter=no
d852fbad 3398 else
4bd144d2 3399 AC_MSG_ERROR([Linux Netfilter support requested but needed headers not found])
d852fbad 3400 fi
4bd144d2 3401 fi
b50f1b2b 3402fi
0f658b5b 3403SQUID_DEFINE_BOOL(LINUX_NETFILTER,$enable_linux_netfilter,
969d4051 3404 [Enable support for Transparent Proxy on Linux via Netfilter])
20ad76ab 3405
b50f1b2b 3406dnl Netfilter TPROXY depends on libcap but the NAT parts can still work.
4bd144d2 3407AC_MSG_NOTICE([Support for Netfilter-based interception proxy requested: $enable_linux_netfilter])
fcabe077 3408if test "x$enable_linux_netfilter" = "xyes" -a "x$with_libcap" != "xyes" ; then
3b7a7630
AJ
3409 AC_MSG_WARN([Missing needed capabilities (libcap 2.09+) for TPROXY])
3410 AC_MSG_WARN([Linux Transparent Proxy (version 4+) support WILL NOT be enabled])
3411 AC_MSG_WARN([Reduced support to NAT Interception Proxy])
be0c7ff0 3412 # AC_DEFINEd later
96f08e2d 3413fi
11e8cfe3 3414if test "x$with_netfilter_conntrack" = "xyes" -a "x$with_libcap" != "xyes" ; then
3b7a7630 3415 AC_MSG_WARN([Missing needed capabilities (libcap 2.09+) for netfilter mark support])
11e8cfe3
AB
3416 AC_MSG_WARN([Linux netfilter marking support WILL NOT be enabled])
3417 with_netfilter_conntrack=no
3418fi
24531401 3419AC_MSG_NOTICE([Linux Netfilter Conntrack support enabled: ${with_netfilter_conntrack}])
11e8cfe3
AB
3420
3421
3422AC_ARG_ENABLE(zph-qos,
3423 AS_HELP_STRING([--enable-zph-qos],[Enable ZPH QOS support]), [
3424SQUID_YESNO([$enableval],
3425 [unrecognized argument to --enable-zph-qos: $enableval])
3426])
3427SQUID_DEFINE_BOOL(USE_QOS_TOS,${enable_zph_qos:=yes},
3428 [Enable Zero Penalty Hit QOS. When set, Squid will alter the
3429 TOS field of HIT responses to help policing network traffic])
3430AC_MSG_NOTICE([ZPH QOS enabled: $enable_zph_qos])
3431if test x"$enable_zph_qos" = "xyes" ; then
3432 AC_MSG_NOTICE([QOS netfilter mark preservation enabled: $with_netfilter_conntrack])
3433 SQUID_DEFINE_BOOL(USE_LIBNETFILTERCONNTRACK,${with_netfilter_conntrack:=no},
3434 [Enable support for QOS netfilter mark preservation])
3435fi
3436
c2afddd8
AJ
3437
3438AC_CHECK_LIB(regex, regexec, [REGEXLIB="-lregex"],[REGEXLIB=''])
3439AC_ARG_ENABLE(gnuregex,
3440 AS_HELP_STRING([--enable-gnuregex],
9603207d 3441 [Compile GNUregex. Unless you have reason to use
c2afddd8 3442 this option, you should not enable it.
9603207d 3443 This library file is usually only required on Windows and
3444 very old Unix boxes which do not have their own regex
c2afddd8
AJ
3445 library built in.]), [
3446SQUID_YESNO([$enableval],[unrecognized argument to --enable-gnuregex: $enableval])
3447])
c633a6b0 3448# force-enable on old solaris
c2afddd8
AJ
3449if test "x${enable_gnuregex:=auto}" = "xauto" ; then
3450 case "$host" in
3451 *-sun-solaris2.[[0-4]])
3452 enable_gnuregex="yes"
3453 ;;
c2afddd8
AJ
3454 esac
3455fi
3456
3457# try detecting if it is needed
3458if test "x$enable_gnuregex" = "xauto" ; then
3459 SQUID_CHECK_REGEX_WORKS
3460 if test "x$squid_cv_regex_works" = "xyes" ; then
3461 enable_gnuregex=no
3462 else
3463 enable_gnuregex=yes
3464 fi
3465fi
3466AC_MSG_CHECKING(if GNUregex needs to be compiled)
3467AC_MSG_RESULT($enable_gnuregex)
3468if test "x$enable_gnuregex" = "xyes"; then
3469 # for some reason (force-enable, test..) gnuregex was found as needed. Override any system lib
3470 REGEXLIB=""
3471fi
3472#if no reason was found to enable gnuregex, disable it
3473if test "x$enable_gnuregex" = "xauto" ; then
3474 enable_gnuregex=no
3475fi
3476SQUID_DEFINE_BOOL(USE_GNUREGEX,$enable_gnuregex,[Define if we should use GNU regex])
3477AC_SUBST(REGEXLIB)
3478
8e0acaf5
FC
3479SQUID_DETECT_UDP_SND_BUFSIZE
3480SQUID_DETECT_UDP_RECV_BUFSIZE
3481SQUID_DETECT_TCP_SND_BUFSIZE
3482SQUID_DETECT_TCP_RECV_BUFSIZE
6bf65235 3483
fa8be5b5 3484SQUID_CHECK_RECV_ARG_TYPE
5c3c56fa
FC
3485SQUID_CHECK_NEED_SYS_ERRLIST
3486SQUID_CHECK_MAXPATHLEN
cc192b50 3487
819656da
AJ
3488SQUID_CHECK_LIBRESOLV_DNS_TTL_HACK
3489SQUID_CHECK_RESOLVER_FIELDS
3490
615540cd 3491AC_CHECK_HEADERS(sys/statvfs.h)
fcabe077 3492if test "x$ac_cv_header_sys_statvfs_h" = "xyes" ; then
bb214e97 3493 SQUID_CHECK_WORKING_STATVFS
c68e9c6b 3494fi
615540cd
AJ
3495if test "x$ac_cv_func_statvfs" != "xyes" ; then
3496 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/vfs.h sys/statfs.h)
3497 AC_CHECK_FUNCS(statfs)
3498 SQUID_CHECK_F_FRSIZE_IN_STATFS
3499fi
c68e9c6b 3500
4eb85b7a 3501dnl Squid will not usually attempt to translate templates when building
461b8219 3502AC_ARG_ENABLE(translation,
4eb85b7a 3503 AS_HELP_STRING([--enable-translation],[Generate the localized error page templates and manuals.
9603207d 3504 Which can also be downloaded from http://www.squid-cache.org/Versions/langpack/.]), [
4eb85b7a
AJ
3505 SQUID_YESNO([$enableval],
3506 [unrecognized argument to --enable-translation: $enableval])
461b8219 3507])
4eb85b7a 3508if test "x${enable_translation:=no}" = "xyes" ; then
461b8219 3509 AX_WITH_PROG([PO2HTML],[po2html])
02259ff8 3510 AX_WITH_PROG([PO2TEXT],[po2txt])
461b8219
AJ
3511else
3512 PO2HTML="off"
02259ff8 3513 PO2TEXT="off"
461b8219
AJ
3514fi
3515AC_SUBST(PO2HTML)
02259ff8 3516AC_SUBST(PO2TEXT)
ee1a8ac2 3517
43000484
AJ
3518dnl Squid now has limited locale handling ...
3519dnl on error pages
3520AC_ARG_ENABLE(auto-locale,
62979ab1 3521 AS_HELP_STRING([--disable-auto-locale],[This prevents Squid providing localized error pages based on the
21d5413e 3522 clients request headers.
fb46b778
FC
3523 When disabled Squid requires explicit language configuration.]), [
3524SQUID_YESNO([$enableval],
3525 [unrecognized argument to --disable-auto-locale: $enableval])
8db7a54b 3526])
fb46b778
FC
3527AC_MSG_NOTICE([Multi-Language support enabled: ${enable_auto_locale:=yes}])
3528SQUID_DEFINE_BOOL(USE_ERR_LOCALES,$enable_auto_locale,
3529 [Use multi-language support on error pages])
3530
43000484 3531
090089c4 3532dnl Need the debugging version of malloc if available
3533XTRA_OBJS=''
fcabe077 3534if test "x$ac_cv_lib_malloc_main" = "xyes" ; then
090089c4 3535 if test -r /usr/lib/debug/malloc.o ; then
3536 XTRA_OBJS="$XTRA_OBJS /usr/lib/debug/malloc.o"
3537 fi
3538 if test -r /usr/lib/debug/mallocmap.o ; then
3539 XTRA_OBJS="$XTRA_OBJS /usr/lib/debug/mallocmap.o"
3540 fi
3541fi
3542AC_SUBST(XTRA_OBJS)
3543
fcabe077 3544if test "x$XTRA_LIBS" = "x"; then
38fea766 3545 XTRA_LIBS="$LIBS"
0f5a16f8 3546 dnl minor cleanup
3547 XTRA_LIBS=`echo $XTRA_LIBS | sed -e "s/ */ /g"`
38fea766 3548 LIBS=''
3549fi
090089c4 3550AC_SUBST(XTRA_LIBS)
3551
daed6927
FC
3552AC_SUBST(SQUID_CFLAGS)
3553AC_SUBST(SQUID_CXXFLAGS)
3554
b2f0a375
AJ
3555AC_ARG_VAR([BUILDCXXFLAGS],[C++ compiler flags for building compile-time tools. e.g. cf_gen])
3556if test "x$BUILDCXXFLAGS" = "x"; then
3557 # if we are NOT cross-compiling, use the default build flags for cf_gen and friends
3558 # otherwise rely on the user-provided value
3559 if test "x$squid_cv_check_marchnative" = "xyes"; then
3560 # always valid for the Build compiler.
b3080eec 3561 BUILDCXXFLAGS="-march=native"
b2f0a375
AJ
3562 fi
3563 BUILDCXXFLAGS="$BUILDCXXFLAGS $CXXFLAGS"
3564fi
3565AC_SUBST(BUILDCXXFLAGS)
3566
90b412dd
AJ
3567AC_MSG_NOTICE([BUILD LIBRARIES: $LIBS])
3568AC_MSG_NOTICE([BUILD EXTRA LIBRARIES: $XTRA_LIBS])
3569AC_MSG_NOTICE([BUILD OBJECTS: $OBJS])
3570AC_MSG_NOTICE([BUILD EXTRA OBJECTS: $XTRA_OBJS])
3571AC_MSG_NOTICE([BUILD C FLAGS: $CFLAGS])
3572AC_MSG_NOTICE([BUILD EXTRA C FLAGS: $SQUID_CFLAGS])
3573AC_MSG_NOTICE([BUILD C++ FLAGS: $CXXFLAGS])
3574AC_MSG_NOTICE([BUILD EXTRA C++ FLAGS: $SQUID_CXXFLAGS])
b2f0a375 3575AC_MSG_NOTICE([BUILD Tools C++ FLAGS: $BUILDCXXFLAGS])
daed6927 3576
090089c4 3577dnl Clean up after OSF/1 core dump bug
9603207d 3578rm -f core
090089c4 3579
7a03447c
AJ
3580AC_CONFIG_FILES([
3581 Makefile
3582 compat/Makefile
7a03447c 3583 contrib/Makefile
7a03447c
AJ
3584 doc/Makefile
3585 doc/manuals/Makefile
86b8d400 3586 doc/release-notes/Makefile
6b99776c 3587 errors/Makefile
6b99776c
AJ
3588 icons/Makefile
3589 lib/Makefile
3590 lib/libTrie/Makefile
3591 lib/libTrie/test/Makefile
3592 lib/ntlmauth/Makefile
6b99776c
AJ
3593 lib/rfcnb/Makefile
3594 lib/smblib/Makefile
3595 lib/snmplib/Makefile
3596 scripts/Makefile
3597 src/Makefile
3598 src/acl/Makefile
e046643f
AJ
3599 src/acl/external/Makefile
3600 src/acl/external/AD_group/Makefile
3601 src/acl/external/delayer/Makefile
3602 src/acl/external/eDirectory_userip/Makefile
3603 src/acl/external/file_userip/Makefile
3604 src/acl/external/kerberos_ldap_group/Makefile
4a544c9d 3605 src/acl/external/kerberos_sid_group/Makefile
e046643f
AJ
3606 src/acl/external/LDAP_group/Makefile
3607 src/acl/external/LM_group/Makefile
3608 src/acl/external/session/Makefile
3609 src/acl/external/SQL_session/Makefile
3610 src/acl/external/unix_group/Makefile
3611 src/acl/external/wbinfo_group/Makefile
3612 src/acl/external/time_quota/Makefile
6b99776c
AJ
3613 src/adaptation/Makefile
3614 src/adaptation/icap/Makefile
3615 src/adaptation/ecap/Makefile
3616 src/anyp/Makefile
3617 src/auth/Makefile
3618 src/auth/basic/Makefile
03901cf8
AJ
3619 src/auth/basic/DB/Makefile
3620 src/auth/basic/fake/Makefile
3621 src/auth/basic/getpwnam/Makefile
3622 src/auth/basic/LDAP/Makefile
3623 src/auth/basic/NCSA/Makefile
3624 src/auth/basic/NIS/Makefile
3625 src/auth/basic/PAM/Makefile
3626 src/auth/basic/POP3/Makefile
3627 src/auth/basic/RADIUS/Makefile
3628 src/auth/basic/SASL/Makefile
3629 src/auth/basic/SMB/Makefile
3630 src/auth/basic/SMB_LM/Makefile
3631 src/auth/basic/SSPI/Makefile
6b99776c 3632 src/auth/digest/Makefile
d4d7f6dd
AJ
3633 src/auth/digest/eDirectory/Makefile
3634 src/auth/digest/file/Makefile
3635 src/auth/digest/LDAP/Makefile
6b99776c 3636 src/auth/negotiate/Makefile
16c02b14
AJ
3637 src/auth/negotiate/kerberos/Makefile
3638 src/auth/negotiate/SSPI/Makefile
3639 src/auth/negotiate/wrapper/Makefile
6b99776c 3640 src/auth/ntlm/Makefile
b817c20f
AJ
3641 src/auth/ntlm/fake/Makefile
3642 src/auth/ntlm/SMB_LM/Makefile
3643 src/auth/ntlm/SSPI/Makefile
6b99776c
AJ
3644 src/base/Makefile
3645 src/clients/Makefile
3646 src/comm/Makefile
675b8408 3647 src/debug/Makefile
4a3b98d7 3648 src/dns/Makefile
13d8c08c 3649 src/DiskIO/Makefile
d9691f09
AJ
3650 src/DiskIO/AIO/Makefile
3651 src/DiskIO/Blocking/Makefile
3652 src/DiskIO/DiskDaemon/Makefile
3653 src/DiskIO/DiskThreads/Makefile
3654 src/DiskIO/IpcIo/Makefile
3655 src/DiskIO/Mmapped/Makefile
83b053a0 3656 src/error/Makefile
6b99776c
AJ
3657 src/esi/Makefile
3658 src/eui/Makefile
3659 src/format/Makefile
3660 src/fs/Makefile
3661 src/ftp/Makefile
3662 src/helper/Makefile
3663 src/http/Makefile
3664 src/http/one/Makefile
d6d6203a
AJ
3665 src/http/url_rewriters/Makefile
3666 src/http/url_rewriters/fake/Makefile
3667 src/http/url_rewriters/LFS/Makefile
6b99776c
AJ
3668 src/icmp/Makefile
3669 src/ident/Makefile
3670 src/ip/Makefile
3671 src/ipc/Makefile
3672 src/log/Makefile
4d5dd85a
AJ
3673 src/log/DB/Makefile
3674 src/log/file/Makefile
6b99776c
AJ
3675 src/mem/Makefile
3676 src/mgr/Makefile
3677 src/parser/Makefile
36c774f7 3678 src/proxyp/Makefile
6b99776c 3679 src/repl/Makefile
65e41a45 3680 src/sbuf/Makefile
7dcca85b 3681 src/security/Makefile
cb0b3d63
AJ
3682 src/security/cert_generators/Makefile
3683 src/security/cert_generators/file/Makefile
bbf79f12
AJ
3684 src/security/cert_validators/Makefile
3685 src/security/cert_validators/fake/Makefile
6b99776c
AJ
3686 src/servers/Makefile
3687 src/snmp/Makefile
3688 src/ssl/Makefile
2745fea5 3689 src/store/Makefile
0c1f8b9b
AJ
3690 src/store/id_rewriters/Makefile
3691 src/store/id_rewriters/file/Makefile
98cacedb 3692 src/time/Makefile
6b99776c 3693 test-suite/Makefile
94ab55b0 3694 tools/Makefile
3d276e1d 3695 tools/apparmor/Makefile
33d1abfe 3696 tools/helper-mux/Makefile
2ccf2eb2 3697 tools/purge/Makefile
a35a0ac7 3698 tools/squidclient/Makefile
422cb5da 3699 tools/systemd/Makefile
a35a0ac7 3700 tools/sysvinit/Makefile
53cbe3e4 3701])
43ae1d95 3702
3e7b6055 3703# must configure libltdl subdir unconditionally for "make distcheck" to work
081863f3 3704#AC_CONFIG_SUBDIRS(libltdl)
3e7b6055 3705
6a9f6389 3706AC_OUTPUT