1 ## Copyright (C) 1996-2017 The Squid Software Foundation and contributors
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.
8 dnl check that strnstr() works fine. On Macos X it can cause a buffer overrun
9 dnl sets squid_cv_func_strnstr to "yes" or "no", and defines HAVE_STRNSTR
10 AC_DEFUN([SQUID_CHECK_FUNC_STRNSTR],[
12 # Yay! This one is a MacOSX brokenness. Its not good enough
13 # to know that strnstr() exists, because MacOSX 10.4 have a bad
14 # copy that crashes with a buffer over-run!
15 AH_TEMPLATE(HAVE_STRNSTR,[MacOS brokenness: strnstr() can overrun on that system])
16 AC_CACHE_CHECK([if strnstr is well implemented], squid_cv_func_strnstr,
17 AC_RUN_IFELSE([AC_LANG_SOURCE([[
21 // we expect this to succeed, or crash on over-run.
22 // if it passes otherwise we may need a better check.
23 int main(int argc, char **argv)
26 char *str = malloc(size);
27 memset(str, 'x', size);
28 strnstr(str, "fubar", size);
31 ]])],[squid_cv_func_strnstr="yes"],[squid_cv_func_strnstr="no"],[:])
33 if test "$squid_cv_func_strnstr" = "yes" ; then
34 AC_DEFINE(HAVE_STRNSTR,1)
37 ]) dnl SQUID_CHECK_FUNC_STRNSTR
39 dnl check that va_copy is implemented and works
40 dnl sets squid_cv_func_va_copy and defines HAVE_VA_COPY
41 AC_DEFUN([SQUID_CHECK_FUNC_VACOPY],[
43 # check that the system provides a functional va_copy call
45 AH_TEMPLATE(HAVE_VA_COPY, [The system implements a functional va_copy() ])
46 AC_CACHE_CHECK(if va_copy is implemented, squid_cv_func_va_copy,
47 AC_RUN_IFELSE([AC_LANG_SOURCE([[
53 va_copy (args2, args1);
54 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
56 va_end (args1); va_end (args2);
59 int main(int argc, char **argv) { return f (0, 42); }
60 ]])],[squid_cv_func_va_copy="yes"],[squid_cv_func_va_copy="no"],[:])
62 if test "$squid_cv_func_va_copy" = "yes" ; then
63 AC_DEFINE(HAVE_VA_COPY, 1)
66 ]) dnl SQUID_CHECK_FUNC_VACOPY
68 dnl same sa SQUID_CHECK_FUNC_VACOPY, but checks __va_copy
69 dnl sets squid_cv_func___va_copy, and defines HAVE___VA_COPY
70 AC_DEFUN([SQUID_CHECK_FUNC___VACOPY],[
72 AH_TEMPLATE(HAVE___VA_COPY,[Some systems have __va_copy instead of va_copy])
73 AC_CACHE_CHECK(if __va_copy is implemented, squid_cv_func___va_copy,
74 AC_RUN_IFELSE([AC_LANG_SOURCE([[
80 __va_copy (args2, args1);
81 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
83 va_end (args1); va_end (args2);
86 int main(int argc, char **argv) { return f (0, 42); }
87 ]])],[squid_cv_func___va_copy="yes"],[squid_cv_func___va_copy="no"],[:])
89 if test "$squid_cv_func___va_copy" = "yes" ; then
90 AC_DEFINE(HAVE___VA_COPY, 1)
92 ]) dnl SQUID_CHECK_FUNC___VACOPY
95 dnl check that epoll actually works
96 dnl sets squid_cv_epoll_works to "yes" or "no"
97 AC_DEFUN([SQUID_CHECK_EPOLL],[
99 AC_CACHE_CHECK(if epoll works, squid_cv_epoll_works,
100 AC_RUN_IFELSE([AC_LANG_SOURCE([[
101 #include <sys/epoll.h>
104 int main(int argc, char **argv)
106 int fd = epoll_create(256);
108 perror("epoll_create:");
113 ]])],[squid_cv_epoll_works=yes],[squid_cv_epoll_works=no],[:]))
115 ]) dnl SQUID_CHECK_EPOLL
117 dnl check that /dev/poll actually works
118 dnl sets squid_cv_devpoll_works to "yes" or "no"
119 AC_DEFUN([SQUID_CHECK_DEVPOLL],[
121 AC_CACHE_CHECK(if /dev/poll works, squid_cv_devpoll_works,
122 AC_RUN_IFELSE([AC_LANG_SOURCE([[
123 #include <sys/devpoll.h>
127 int main(int argc, char **argv)
129 int fd = open("/dev/poll", O_RDWR);
131 perror("devpoll_create:");
136 ]])],[squid_cv_devpoll_works=yes],[squid_cv_devpoll_works=no],[:]))
138 ]) dnl SQUID_CHECK_DEVPOLL
141 dnl check that we have functional libcap2 headers
142 dnl sets squid_cv_sys_capability_works to "yes" or "no"
144 AC_DEFUN([SQUID_CHECK_FUNCTIONAL_LIBCAP2],[
145 AC_CACHE_CHECK([for operational libcap2 headers],
146 squid_cv_sys_capability_works,
147 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
150 #include <sys/capability.h>
155 [squid_cv_sys_capability_works=yes],
156 [squid_cv_sys_capability_works=no])
161 dnl From Samba. Thanks!
162 dnl check that we have Unix sockets. Sets squid_cv_unixsocket to either yes or no depending on the check
164 AC_DEFUN([SQUID_CHECK_UNIX_SOCKET],[
165 AC_CACHE_CHECK([for unix domain sockets],squid_cv_unixsocket, [
166 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
167 #include <sys/types.h>
170 #include <sys/socket.h>
171 #include <sys/un.h>]], [[
172 struct sockaddr_un sunaddr;
173 sunaddr.sun_family = AF_UNIX;
174 ]])],[squid_cv_unixsocket=yes],[squid_cv_unixsocket=no])])
178 dnl check the default FD_SETSIZE size.
179 dnl not cached, people are likely to tune this
180 dnl defines DEFAULT_FD_SETSIZE
182 AC_DEFUN([SQUID_CHECK_DEFAULT_FD_SETSIZE],[
183 AC_MSG_CHECKING(Default FD_SETSIZE value)
184 AC_RUN_IFELSE([AC_LANG_SOURCE([[
195 #include <sys/time.h>
197 #if HAVE_SYS_SELECT_H
198 #include <sys/select.h>
201 #include <sys/types.h>
204 #include <winsock2.h>
208 int main(int argc, char **argv) {
209 FILE *fp = fopen("conftestval", "w");
210 fprintf (fp, "%d\n", FD_SETSIZE);
213 ]])],[DEFAULT_FD_SETSIZE=`cat conftestval`],[DEFAULT_FD_SETSIZE=256],[DEFAULT_FD_SETSIZE=256])
214 AC_MSG_RESULT($DEFAULT_FD_SETSIZE)
215 AC_DEFINE_UNQUOTED(DEFAULT_FD_SETSIZE, $DEFAULT_FD_SETSIZE, [Default FD_SETSIZE value])
219 dnl checks the maximum number of filedescriptor we can open
220 dnl sets shell var squid_filedescriptors_num
222 AC_DEFUN([SQUID_CHECK_MAXFD],[
223 AC_CHECK_FUNCS(setrlimit)
224 AC_MSG_CHECKING(Maximum number of filedescriptors we can open)
225 dnl damn! FreeBSD pthreads break dup2().
226 SQUID_STATE_SAVE(maxfd)
228 i386-unknown-freebsd*)
229 if echo "$LDFLAGS" | grep -q pthread; then
230 LDFLAGS=`echo $LDFLAGS | sed -e "s/-pthread//"`
233 AC_RUN_IFELSE([AC_LANG_SOURCE([[
237 #include <sys/time.h> /* needed on FreeBSD */
238 #include <sys/param.h>
239 #include <sys/resource.h>
240 int main(int argc, char **argv) {
243 #if defined(__CYGWIN32__) || defined (__CYGWIN__)
244 /* getrlimit and sysconf returns bogous values on cygwin32.
245 * Number of fds is virtually unlimited in cygwin (sys/param.h)
246 * __CYGWIN32__ is deprecated.
252 #if defined(RLIMIT_NOFILE)
253 if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
254 perror("getrlimit: RLIMIT_NOFILE");
256 #if defined(__APPLE__)
257 /* asking for more than OPEN_MAX fails on Leopard */
258 rl.rlim_cur = (OPEN_MAX < rl.rlim_max ? OPEN_MAX : rl.rlim_max);
260 rl.rlim_cur = rl.rlim_max; /* set it to the max */
262 if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
263 perror("setrlimit: RLIMIT_NOFILE");
266 #elif defined(RLIMIT_OFILE)
267 if (getrlimit(RLIMIT_OFILE, &rl) < 0) {
268 perror("getrlimit: RLIMIT_OFILE");
270 rl.rlim_cur = rl.rlim_max; /* set it to the max */
271 if (setrlimit(RLIMIT_OFILE, &rl) < 0) {
272 perror("setrlimit: RLIMIT_OFILE");
275 #endif /* RLIMIT_NOFILE */
276 #endif /* HAVE_SETRLIMIT */
277 /* by starting at 2^14, we will never get higher
278 than 2^15 for squid_filedescriptors_num */
282 if (dup2(0, i) < 0) {
290 #endif /* IF !DEF CYGWIN */
291 fp = fopen("conftestval", "w");
292 fprintf (fp, "%d\n", i & ~0x3F);
295 ]])],[squid_filedescriptors_num=`cat conftestval`],[squid_filedescriptors_num=256],[squid_filedescriptors_num=256])
296 dnl Microsoft MSVCRT.DLL supports 2048 maximum FDs
299 squid_filedescriptors_num="2048"
302 AC_MSG_RESULT($squid_filedescriptors_num)
303 SQUID_STATE_ROLLBACK(maxfd)
305 if test `expr $squid_filedescriptors_num % 64` != 0; then
306 AC_MSG_WARN([$squid_filedescriptors_num is not an multiple of 64. This may cause issues on certain platforms.])
311 dnl Check whether this OS defines sin6_len as a member of sockaddr_in6 as a backup to ss_len
312 dnl defines HAVE_SIN6_LEN_IN_SAI
313 dnl TODO: move to AC_CHECK_MEMBER?
315 AC_DEFUN([SQUID_CHECK_SIN6_LEN_IN_SAI],[
316 AC_CACHE_CHECK([for sin6_len field in struct sockaddr_in6],
317 ac_cv_have_sin6_len_in_struct_sai, [
318 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
319 #include <sys/types.h>
320 #include <sys/socket.h>
321 #include <netinet/in.h>
322 ]], [[ struct sockaddr_in6 s; s.sin6_len = 1; ]])],[ ac_cv_have_sin6_len_in_struct_sai="yes" ],[ ac_cv_have_sin6_len_in_struct_sai="no"
325 SQUID_DEFINE_BOOL(HAVE_SIN6_LEN_IN_SAI,$ac_cv_have_sin6_len_in_struct_sai,
326 [Defined if struct sockaddr_in6 has sin6_len])
330 dnl Check whether this OS defines ss_len as a member of sockaddr_storage
331 dnl defines HAVE_SS_LEN_IN_SS
332 dnl TODO: move to AC_CHECK_MEMBER?
334 AC_DEFUN([SQUID_CHECK_SS_LEN_IN_SOCKADDR_STORAGE],[
335 AC_CACHE_CHECK([for ss_len field in struct sockaddr_storage],
336 ac_cv_have_ss_len_in_struct_ss, [
337 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
338 #include <sys/types.h>
339 #include <sys/socket.h>
340 #include <netinet/in.h>
341 ]], [[ struct sockaddr_storage s; s.ss_len = 1; ]])],[ ac_cv_have_ss_len_in_struct_ss="yes" ],[ ac_cv_have_ss_len_in_struct_ss="no"
344 SQUID_DEFINE_BOOL(HAVE_SS_LEN_IN_SS,$ac_cv_have_ss_len_in_struct_ss,
345 [Define if sockaddr_storage has field ss_len])
349 dnl Check whether this OS defines sin_len as a member of sockaddr_in as a backup to ss_len
350 dnl defines HAVE_SIN_LEN_IN_SAI
351 dnl TODO: move to AC_CHECK_MEMBER?
353 AC_DEFUN([SQUID_CHECK_SIN_LEN_IN_SOCKADDR_IN],[
354 AC_CACHE_CHECK([for sin_len field in struct sockaddr_in],
355 ac_cv_have_sin_len_in_struct_sai, [
356 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
357 #include <sys/types.h>
358 #include <sys/socket.h>
359 #include <netinet/in.h>
360 ]], [[ struct sockaddr_in s; s.sin_len = 1; ]])],[ ac_cv_have_sin_len_in_struct_sai="yes" ],[ ac_cv_have_sin_len_in_struct_sai="no"
363 SQUID_DEFINE_BOOL(HAVE_SIN_LEN_IN_SAI,$ac_cv_have_sin_len_in_struct_sai,[Define if sockaddr_in has field sin_len])
367 dnl detects default UDP buffer size
368 dnl not cached since people are likely to tune this
369 dnl defines SQUID_DETECT_UDP_SO_SNDBUF
371 AC_DEFUN([SQUID_DETECT_UDP_SND_BUFSIZE],[
372 AC_MSG_CHECKING(Default UDP send buffer size)
373 AC_RUN_IFELSE([AC_LANG_SOURCE([[
376 #include <sys/types.h>
377 #if HAVE_SYS_SOCKET_H
378 #include <sys/socket.h>
380 #if HAVE_NETINET_IN_H
381 #include <netinet/in.h>
384 #include <winsock2.h>
388 int main(int argc, char **argv)
392 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
395 WSAStartup(2, &wsaData);
397 socklen_t len=sizeof(socklen_t);
399 if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1;
400 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
401 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&val, &len) < 0) return 1;
404 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1;
406 if (val<=0) return 1;
407 fp = fopen("conftestval", "w");
408 fprintf (fp, "%d\n", val);
411 ]])],[SQUID_DETECT_UDP_SO_SNDBUF=`cat conftestval`],[SQUID_DETECT_UDP_SO_SNDBUF=16384],[SQUID_DETECT_UDP_SO_SNDBUF=16384])
412 AC_MSG_RESULT($SQUID_DETECT_UDP_SO_SNDBUF)
413 AC_DEFINE_UNQUOTED(SQUID_DETECT_UDP_SO_SNDBUF, $SQUID_DETECT_UDP_SO_SNDBUF,[UDP send buffer size])
417 dnl detects default UDP buffer size
418 dnl not cached since people are likely to tune this
419 dnl defines SQUID_DETECT_UDP_SO_RCVBUF
421 AC_DEFUN([SQUID_DETECT_UDP_RECV_BUFSIZE],[
422 AC_MSG_CHECKING(Default UDP receive buffer size)
423 AC_RUN_IFELSE([AC_LANG_SOURCE([[
426 #include <sys/types.h>
427 #if HAVE_SYS_SOCKET_H
428 #include <sys/socket.h>
430 #if HAVE_NETINET_IN_H
431 #include <netinet/in.h>
434 #include <winsock2.h>
438 int main(int argc, char **argv)
442 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
445 WSAStartup(2, &wsaData);
447 socklen_t len=sizeof(socklen_t);
449 if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1;
450 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
451 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) return 1;
454 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1;
456 if (val <= 0) return 1;
457 fp = fopen("conftestval", "w");
458 fprintf (fp, "%d\n", val);
461 ]])],[SQUID_DETECT_UDP_SO_RCVBUF=`cat conftestval`],[SQUID_DETECT_UDP_SO_RCVBUF=16384],[SQUID_DETECT_UDP_SO_RCVBUF=16384])
462 AC_MSG_RESULT($SQUID_DETECT_UDP_SO_RCVBUF)
463 AC_DEFINE_UNQUOTED(SQUID_DETECT_UDP_SO_RCVBUF, $SQUID_DETECT_UDP_SO_RCVBUF,[UDP receive buffer size])
467 dnl detects default TCP buffer size
468 dnl not cached since people are likely to tune this
469 dnl defines SQUID_TCP_SO_SNDBUF
471 AC_DEFUN([SQUID_DETECT_TCP_SND_BUFSIZE],[
472 AC_MSG_CHECKING(Default TCP send buffer size)
473 AC_RUN_IFELSE([AC_LANG_SOURCE([[
476 #include <sys/types.h>
477 #if HAVE_SYS_SOCKET_H
478 #include <sys/socket.h>
480 #if HAVE_NETINET_IN_H
481 #include <netinet/in.h>
484 #include <winsock2.h>
488 int main(int argc, char **argv)
492 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
495 WSAStartup(2, &wsaData);
497 socklen_t len=sizeof(socklen_t);
499 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return 1;
500 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
501 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&val, &len) < 0) return 1;
504 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1;
506 if (val <= 0) return 1;
507 fp = fopen("conftestval", "w");
508 fprintf (fp, "%d\n", val);
511 ]])],[SQUID_TCP_SO_SNDBUF=`cat conftestval`],[SQUID_TCP_SO_SNDBUF=16384],[SQUID_TCP_SO_SNDBUF=16384])
512 AC_MSG_RESULT($SQUID_TCP_SO_SNDBUF)
513 if test $SQUID_TCP_SO_SNDBUF -gt 32768; then
514 AC_MSG_NOTICE([Limiting send buffer size to 32K])
515 SQUID_TCP_SO_SNDBUF=32768
517 AC_DEFINE_UNQUOTED(SQUID_TCP_SO_SNDBUF, $SQUID_TCP_SO_SNDBUF,[TCP send buffer size])
521 dnl detects default TCP buffer size
522 dnl not cached since people are likely to tune this
523 dnl defines SQUID_TCP_SO_RECVBUF
525 AC_DEFUN([SQUID_DETECT_TCP_RECV_BUFSIZE],[
526 AC_MSG_CHECKING(Default TCP receive buffer size)
527 AC_RUN_IFELSE([AC_LANG_SOURCE([[
530 #include <sys/types.h>
531 #if HAVE_SYS_SOCKET_H
532 #include <sys/socket.h>
534 #if HAVE_NETINET_IN_H
535 #include <netinet/in.h>
538 #include <winsock2.h>
542 int main(int argc, char **argv)
546 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
549 WSAStartup(2, &wsaData);
551 socklen_t len=sizeof(socklen_t);
553 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return 1;
554 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
555 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) return 1;
558 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1;
560 if (val <= 0) return 1;
561 fp = fopen("conftestval", "w");
562 fprintf (fp, "%d\n", val);
565 ]])],[SQUID_TCP_SO_RCVBUF=`cat conftestval`],[SQUID_TCP_SO_RCVBUF=16384],[SQUID_TCP_SO_RCVBUF=16384])
566 AC_MSG_RESULT($SQUID_TCP_SO_RCVBUF)
567 if test $SQUID_TCP_SO_RCVBUF -gt 65535; then
568 AC_MSG_NOTICE([Limiting receive buffer size to 64K])
569 SQUID_TCP_SO_RCVBUF=65535
571 AC_DEFINE_UNQUOTED(SQUID_TCP_SO_RCVBUF, $SQUID_TCP_SO_RCVBUF,[TCP receive buffer size])
575 dnl check if we need to define sys_errlist as external
576 dnl defines NEED_SYS_ERRLIST
578 AC_DEFUN([SQUID_CHECK_NEED_SYS_ERRLIST],[
579 AC_CACHE_CHECK(if sys_errlist is already defined, ac_cv_needs_sys_errlist,
580 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[char *s = sys_errlist;]])],[ac_cv_needs_sys_errlist="no"],[ac_cv_needs_sys_errlist="yes"])
582 SQUID_DEFINE_BOOL(NEED_SYS_ERRLIST,$ac_cv_needs_sys_errlist,[If we need to declare sys_errlist as extern])
586 dnl check if MAXPATHLEN is defined in the system headers
587 dnl or define it ourselves
589 AC_DEFUN([SQUID_CHECK_MAXPATHLEN],[
590 AC_MSG_CHECKING(for system-provided MAXPATHLEN)
593 #include <sys/param.h>]], [[
594 int i = MAXPATHLEN;]])], [
595 AC_MSG_RESULT(yes)], [
597 AC_DEFINE(MAXPATHLEN,256,[If MAXPATHLEN has not been defined])])
601 dnl check that we have a working statvfs
602 dnl sets the ac_cv_func_statvfs shell variable and defines HAVE_STATVFS
604 AC_DEFUN([SQUID_CHECK_WORKING_STATVFS],[
605 AC_CACHE_CHECK(for working statvfs() interface,ac_cv_func_statvfs,[
606 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
609 #include <sys/types.h>
610 #include <sys/statvfs.h>
613 sfs.f_blocks = sfs.f_bfree = sfs.f_frsize =
614 sfs.f_files = sfs.f_ffree = 0;
615 statvfs("/tmp", &sfs);
616 ]])],[ac_cv_func_statvfs=yes],[ac_cv_func_statvfs=no])
618 SQUID_DEFINE_BOOL(HAVE_STATVFS,$ac_cv_func_statvfs,[set to 1 if our system has statvfs(), and if it actually works])
622 dnl Check whether this OS defines f_frsize as a member of struct statfs
623 AC_DEFUN([SQUID_CHECK_F_FRSIZE_IN_STATFS],[
624 AC_CACHE_CHECK([for f_frsize field in struct statfs],
625 ac_cv_have_f_frsize_in_struct_statfs, [
626 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
627 #if HAVE_SYS_STATFS_H
628 #include <sts/statfs.h>
630 #if HAVE_SYS_STATVFS_H
631 #include <sts/statvfs.h>
636 ]], [[ struct statfs s; s.f_frsize = 0; ]])],[ ac_cv_have_f_frsize_in_struct_statfs="yes" ],[ ac_cv_have_f_frsize_in_struct_statfs="no"
639 SQUID_DEFINE_BOOL(HAVE_F_FRSIZE_IN_STATFS,$ac_cv_have_f_frsize_in_struct_statfs,[Define if struct statfs has field f_frsize (Linux 2.6 or later)])
643 dnl check that we can use the libresolv _dns_ttl_ hack
644 dnl sets the ac_cv_libresolv_dns_ttl_hack shell variable and defines LIBRESOLV_DNS_TTL_HACK
646 AC_DEFUN([SQUID_CHECK_LIBRESOLV_DNS_TTL_HACK],[
647 AC_CACHE_CHECK(for libresolv _dns_ttl_ hack, ac_cv_libresolv_dns_ttl_hack, [
648 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int _dns_ttl_;]], [[return _dns_ttl_;]])],
649 [ac_cv_libresolv_dns_ttl_hack=yes],[ac_cv_libresolv_dns_ttl_hack=no]) ])
650 SQUID_DEFINE_BOOL(LIBRESOLV_DNS_TTL_HACK,$ac_cv_libresolv_dns_ttl_hack,
651 [libresolv.a has been hacked to export _dns_ttl_])
655 dnl checks for availability of some resolver fields
656 dnl sets ac_cv_have_res_ext_nsaddr_list shell variable
657 dnl defines _SQUID_RES_NSADDR6_COUNT _SQUID_RES_NSADDR6_LARRAY
658 dnl defines _SQUID_RES_NSADDR6_LPTR _SQUID_RES_NSADDR6_COUNT
659 dnl defines _SQUID_RES_NSADDR_LIST _SQUID_RES_NSADDR_COUNT
661 AC_DEFUN([SQUID_CHECK_RESOLVER_FIELDS],[
662 AC_CACHE_CHECK(for _res_ext.nsaddr_list, ac_cv_have_res_ext_nsaddr_list,
663 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
665 #include <sys/types.h>
667 #if HAVE_NETINET_IN_H
668 #include <netinet/in.h>
671 #include <arpa/inet.h>
673 #if HAVE_ARPA_NAMESER_H
674 #include <arpa/nameser.h>
680 [[_res_ext.nsaddr_list[[0]].s_addr;]])],[
681 ac_cv_have_res_ext_nsaddr_list="yes" ],[
682 ac_cv_have_res_ext_nsaddr_list="no"]))
683 if test "$ac_cv_have_res_ext_nsaddr_list" = "yes" ; then
684 AC_DEFINE(_SQUID_RES_NSADDR6_LARRAY,_res_ext.nsaddr_list,[If _res_ext structure has nsaddr_list member])
685 AC_DEFINE(_SQUID_RES_NSADDR6_COUNT,ns6count,[Nameserver Counter for IPv6 _res_ext])
688 if test "$_SQUID_RES_NSADDR6_LIST" = ""; then
689 AC_CACHE_CHECK(for _res._u._ext.nsaddrs, ac_cv_have_res_ext_nsaddrs,
690 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
692 #include <sys/types.h>
694 #if HAVE_NETINET_IN_H
695 #include <netinet/in.h>
698 #include <arpa/inet.h>
700 #if HAVE_ARPA_NAMESER_H
701 #include <arpa/nameser.h>
707 [[_res._u._ext.nsaddrs[[0]]->sin6_addr;]])],
708 [ac_cv_have_res_ext_nsaddrs="yes"],[ac_cv_have_res_ext_nsaddrs="no"]))
709 if test "$ac_cv_have_res_ext_nsaddrs" = "yes" ; then
710 AC_DEFINE(_SQUID_RES_NSADDR6_LPTR,_res._u._ext.nsaddrs,[If _res structure has _ext.nsaddrs member])
711 AC_DEFINE(_SQUID_RES_NSADDR6_COUNT,_res._u._ext.nscount6,[Nameserver Counter for IPv6 _res])
715 AC_CACHE_CHECK(for _res.nsaddr_list, ac_cv_have_res_nsaddr_list,
719 #include <sys/types.h>
721 #if HAVE_NETINET_IN_H
722 #include <netinet/in.h>
725 #include <arpa/inet.h>
727 #if HAVE_ARPA_NAMESER_H
728 #include <arpa/nameser.h>
733 ]], [[_res.nsaddr_list[[0]];]])],
734 [ac_cv_have_res_nsaddr_list="yes"],[ac_cv_have_res_nsaddr_list="no"]))
735 if test $ac_cv_have_res_nsaddr_list = "yes" ; then
736 AC_DEFINE(_SQUID_RES_NSADDR_LIST,_res.nsaddr_list,[If _res structure has nsaddr_list member])
737 AC_DEFINE(_SQUID_RES_NSADDR_COUNT,_res.nscount,[Nameserver counter for IPv4 _res])
740 if test "$_SQUID_RES_NSADDR_LIST" = ""; then
741 AC_CACHE_CHECK(for _res.ns_list, ac_cv_have_res_ns_list,
742 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
744 #include <sys/types.h>
746 #if HAVE_NETINET_IN_H
747 #include <netinet/in.h>
750 #include <arpa/inet.h>
752 #if HAVE_ARPA_NAMESER_H
753 #include <arpa/nameser.h>
759 [[_res.ns_list[[0]].addr;]])],
760 [ac_cv_have_res_ns_list="yes"],[ac_cv_have_res_ns_list="no"]))
761 if test $ac_cv_have_res_ns_list = "yes" ; then
762 AC_DEFINE(_SQUID_RES_NSADDR_LIST,_res.ns_list,[If _res structure has ns_list member])
763 AC_DEFINE(_SQUID_RES_NSADDR_COUNT,_res.nscount,[Nameserver counter for IPv4 _res])
769 dnl checks the winsock library to use (ws2_32 or wsock32)
770 dnl may set ac_cv_func_select as a side effect
771 AC_DEFUN([SQUID_CHECK_WINSOCK_LIB],[
772 AC_CHECK_HEADERS(winsock2.h winsock.h)
773 SQUID_STATE_SAVE(winsock)
774 SQUID_SEARCH_LIBS([squid_getprotobynumber],[ws2_32 wsock32],,,,[
776 #include <winsock2.h>
781 void squid_getprotobynumber(void) {
785 AC_MSG_CHECKING([for winsock library])
786 case "$ac_cv_search_squid_getprotobynumber" in
788 AC_MSG_RESULT([winsock library not found])
791 AC_MSG_RESULT([winsock library already in LIBS])
794 AC_MSG_RESULT([winsock2])
795 XTRA_LIBS="-lws2_32 $XTRA_LIBS"
796 ac_cv_func_select='yes'
799 AC_MSG_RESULT([winsock])
800 XTRA_LIBS="-lwsock32 $XTRA_LIBS"
801 ac_cv_func_select='yes'
804 SQUID_STATE_ROLLBACK(winsock)
807 dnl check that setresuid is properly implemented.
808 dnl sets squid_cv_resuid_works to "yes" or "no"
809 AC_DEFUN([SQUID_CHECK_SETRESUID_WORKS],[
810 AC_CACHE_CHECK(if setresuid is actually implemented, squid_cv_resuid_works,
822 int main(int argc, char **argv) {
823 if(setresuid(-1,-1,-1)) {
824 perror("setresuid:");
830 squid_cv_resuid_works="yes" ],[
831 squid_cv_resuid_works="no" ],[:])
835 dnl check that we have functional CPU clock access for the profiler
836 dnl sets squid_cv_profiler_works to "yes" or "no"
838 AC_DEFUN([SQUID_CHECK_FUNCTIONAL_CPU_PROFILER],[
839 AC_CACHE_CHECK([for operational CPU clock access],
840 squid_cv_cpu_profiler_works,
841 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
842 #if defined(__GNUC__) && ( defined(__i386) || defined(__i386__) )
844 #elif defined(__GNUC__) && ( defined(__x86_64) || defined(__x86_64__) )
846 #elif defined(__GNUC__) && defined(__alpha)
848 #elif defined(_M_IX86) && defined(_MSC_VER) /* x86 platform on Microsoft C Compiler ONLY */
851 #error This CPU is unsupported. No profiling available here.
854 squid_cv_cpu_profiler_works=yes],[
855 squid_cv_cpu_profiler_works=no])
859 dnl check whether recv takes a char* or void* as a second argument
860 AC_DEFUN([SQUID_CHECK_RECV_ARG_TYPE],[
861 AC_CACHE_CHECK([whether recv takes a pointer to void or char as second argument],
862 squid_cv_recv_second_arg_type, [
863 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
864 #include <sys/types.h>
865 #if HAVE_SYS_SOCKET_H
866 #include <sys/socket.h>
869 #include <winsock2.h>
873 int main (int argc, char ** argv) {
877 ]])],[squid_cv_recv_second_arg_type=void],
878 [squid_cv_recv_second_arg_type=char])
879 AC_MSG_RESULT($squid_cv_recv_second_arg_type*)
881 AC_DEFINE_UNQUOTED(RECV_ARG_TYPE,$squid_cv_recv_second_arg_type,
882 [Base type of the second argument to recv(2)])
886 dnl check whether Solaris has broken IPFilter headers (Solaris 10 at least does)
887 AC_DEFUN([SQUID_CHECK_BROKEN_SOLARIS_IPFILTER],[
888 if test "x$squid_cv_broken_ipfilter_minor_t" = "x"; then
889 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
890 # include <sys/types.h>
891 # include <sys/time.h>
892 # include <sys/ioccom.h>
893 # include <netinet/in.h>
895 # include <netinet/ip_compat.h>
896 # include <netinet/ip_fil.h>
897 # include <netinet/ip_nat.h>
900 squid_cv_broken_ipfilter_minor_t=0
902 ## on fail, test the hack
903 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
904 #define minor_t fubaar
905 # include <sys/types.h>
906 # include <sys/time.h>
907 # include <sys/ioccom.h>
908 # include <netinet/in.h>
910 # include <netinet/ip_compat.h>
911 # include <netinet/ip_fil.h>
912 # include <netinet/ip_nat.h>
915 squid_cv_broken_ipfilter_minor_t=1
917 AC_MSG_ERROR(unable to make IPFilter work with netinet/ headers)
922 AC_DEFINE_UNQUOTED(USE_SOLARIS_IPFILTER_MINOR_T_HACK,$squid_cv_broken_ipfilter_minor_t,
923 [Workaround IPFilter minor_t breakage])
925 ## check for IPFilter headers that require this hack
926 ## (but first netinet/in.h and sys/ioccom.h which they depend on)
934 netinet/ip_compat.h \
935 netinet/ip_fil_compat.h \
939 #if USE_SOLARIS_IPFILTER_MINOR_T_HACK
940 #define minor_t fubar
943 #include <sys/types.h>
946 #include <sys/time.h>
948 #if HAVE_NETINET_IN_H
949 #include <netinet/in.h>
951 #if HAVE_SYS_IOCCOM_H
952 #include <sys/ioccom.h>
954 #if USE_SOLARIS_IPFILTER_MINOR_T_HACK
958 #include <ip_compat.h>
959 #elif HAVE_NETINET_IP_COMPAT_H
960 #include <netinet/ip_compat.h>
964 #elif HAVE_NETINET_IP_FIL_H
965 #include <netinet/ip_fil.h>
967 #if !defined(IPFILTER_VERSION)
968 #define IPFILTER_VERSION 5000004