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