2 dnl AUTHOR: Squid Web Cache team
4 dnl SQUID Web Proxy Cache http://www.squid-cache.org/
5 dnl ----------------------------------------------------------
6 dnl Squid is the result of efforts by numerous individuals from
7 dnl the Internet community; see the CONTRIBUTORS file for full
8 dnl details. Many organizations have provided support for Squid's
9 dnl development; see the SPONSORS file for full details. Squid is
10 dnl Copyrighted (C) 2001 by the Regents of the University of
11 dnl California; see the COPYRIGHT file for full details. Squid
12 dnl incorporates software developed and/or copyrighted by other
13 dnl sources; see the CREDITS file for full details.
15 dnl This program is free software; you can redistribute it and/or modify
16 dnl it under the terms of the GNU General Public License as published by
17 dnl the Free Software Foundation; either version 2 of the License, or
18 dnl (at your option) any later version.
20 dnl This program is distributed in the hope that it will be useful,
21 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
22 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 dnl GNU General Public License for more details.
25 dnl You should have received a copy of the GNU General Public License
26 dnl along with this program; if not, write to the Free Software
27 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
30 dnl check that strnstr() works fine. On Macos X it can cause a buffer overrun
31 dnl sets squid_cv_func_strnstr to "yes" or "no", and defines HAVE_STRNSTR
32 AC_DEFUN([SQUID_CHECK_FUNC_STRNSTR],[
34 # Yay! This one is a MacOSX brokenness. Its not good enough
35 # to know that strnstr() exists, because MacOSX 10.4 have a bad
36 # copy that crashes with a buffer over-run!
37 AH_TEMPLATE(HAVE_STRNSTR,[MacOS brokenness: strnstr() can overrun on that system])
38 AC_CACHE_CHECK([if strnstr is well implemented], squid_cv_func_strnstr,
39 AC_RUN_IFELSE([AC_LANG_SOURCE([[
43 // we expect this to succeed, or crash on over-run.
44 // if it passes otherwise we may need a better check.
45 int main(int argc, char **argv)
48 char *str = malloc(size);
49 memset(str, 'x', size);
50 strnstr(str, "fubar", size);
53 ]])],[squid_cv_func_strnstr="yes"],[squid_cv_func_strnstr="no"],[:])
55 if test "$squid_cv_func_strnstr" = "yes" ; then
56 AC_DEFINE(HAVE_STRNSTR,1)
59 ]) dnl SQUID_CHECK_FUNC_STRNSTR
61 dnl check that va_copy is implemented and works
62 dnl sets squid_cv_func_va_copy and defines HAVE_VA_COPY
63 AC_DEFUN([SQUID_CHECK_FUNC_VACOPY],[
65 # check that the system provides a functional va_copy call
67 AH_TEMPLATE(HAVE_VA_COPY, [The system implements a functional va_copy() ])
68 AC_CACHE_CHECK(if va_copy is implemented, squid_cv_func_va_copy,
69 AC_RUN_IFELSE([AC_LANG_SOURCE([[
75 va_copy (args2, args1);
76 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
78 va_end (args1); va_end (args2);
81 int main(int argc, char **argv) { return f (0, 42); }
82 ]])],[squid_cv_func_va_copy="yes"],[squid_cv_func_va_copy="no"],[:])
84 if test "$squid_cv_func_va_copy" = "yes" ; then
85 AC_DEFINE(HAVE_VA_COPY, 1)
88 ]) dnl SQUID_CHECK_FUNC_VACOPY
90 dnl same sa SQUID_CHECK_FUNC_VACOPY, but checks __va_copy
91 dnl sets squid_cv_func___va_copy, and defines HAVE___VA_COPY
92 AC_DEFUN([SQUID_CHECK_FUNC___VACOPY],[
94 AH_TEMPLATE(HAVE___VA_COPY,[Some systems have __va_copy instead of va_copy])
95 AC_CACHE_CHECK(if __va_copy is implemented, squid_cv_func___va_copy,
96 AC_RUN_IFELSE([AC_LANG_SOURCE([[
100 va_list args1, args2;
102 __va_copy (args2, args1);
103 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
105 va_end (args1); va_end (args2);
108 int main(int argc, char **argv) { return f (0, 42); }
109 ]])],[squid_cv_func___va_copy="yes"],[squid_cv_func___va_copy="no"],[:])
111 if test "$squid_cv_func___va_copy" = "yes" ; then
112 AC_DEFINE(HAVE___VA_COPY, 1)
114 ]) dnl SQUID_CHECK_FUNC___VACOPY
117 dnl check that epoll actually works
118 dnl sets squid_cv_epoll_works to "yes" or "no"
119 AC_DEFUN([SQUID_CHECK_EPOLL],[
121 AC_CACHE_CHECK(if epoll works, squid_cv_epoll_works,
122 AC_RUN_IFELSE([AC_LANG_SOURCE([[
123 #include <sys/epoll.h>
126 int main(int argc, char **argv)
128 int fd = epoll_create(256);
130 perror("epoll_create:");
135 ]])],[squid_cv_epoll_works=yes],[squid_cv_epoll_works=no],[:]))
137 ]) dnl SQUID_CHECK_EPOLL
140 dnl check that we have functional libcap2 headers
141 dnl sets squid_cv_sys_capability_works to "yes" or "no"
143 AC_DEFUN([SQUID_CHECK_FUNCTIONAL_LIBCAP2],[
144 AC_CACHE_CHECK([for operational libcap2 headers],
145 squid_cv_sys_capability_works,
146 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
149 #include <sys/capability.h>
154 [squid_cv_sys_capability_works=yes],
155 [squid_cv_sys_capability_works=no])
160 dnl Ripped from Samba. Thanks!
161 dnl check that we have Unix sockets. Sets squid_cv_unixsocket to either yes or no depending on the check
163 AC_DEFUN([SQUID_CHECK_UNIX_SOCKET],[
164 AC_CACHE_CHECK([for unix domain sockets],squid_cv_unixsocket, [
165 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
166 #include <sys/types.h>
169 #include <sys/socket.h>
170 #include <sys/un.h>]], [[
171 struct sockaddr_un sunaddr;
172 sunaddr.sun_family = AF_UNIX;
173 ]])],[squid_cv_unixsocket=yes],[squid_cv_unixsocket=no])])
177 dnl checks that the system provides struct mallinfo and mallinfo.mxfast.
178 dnl AC_DEFINEs HAVE_STRUCT_MALLINFO and HAVE_STRUCT_MALLINFO_MXFAST if so
180 AC_DEFUN([SQUID_HAVE_STRUCT_MALLINFO],[
181 AC_CHECK_TYPE(struct mallinfo,AC_DEFINE(HAVE_STRUCT_MALLINFO,1,[The system provides struct mallinfo]),,[
183 #include <sys/types.h>
188 AC_CHECK_MEMBERS([struct mallinfo.mxfast],,,[
190 #include <sys/types.h>
197 dnl check the default FD_SETSIZE size.
198 dnl not cached, people are likely to tune this
199 dnl defines DEFAULT_FD_SETSIZE
201 AC_DEFUN([SQUID_CHECK_DEFAULT_FD_SETSIZE],[
202 AC_MSG_CHECKING(Default FD_SETSIZE value)
203 AC_RUN_IFELSE([AC_LANG_SOURCE([[
214 #include <sys/time.h>
216 #if HAVE_SYS_SELECT_H
217 #include <sys/select.h>
220 #include <sys/types.h>
226 #include <winsock2.h>
228 int main(int argc, char **argv) {
229 FILE *fp = fopen("conftestval", "w");
230 fprintf (fp, "%d\n", FD_SETSIZE);
233 ]])],[DEFAULT_FD_SETSIZE=`cat conftestval`],[DEFAULT_FD_SETSIZE=256],[DEFAULT_FD_SETSIZE=256])
234 AC_MSG_RESULT($DEFAULT_FD_SETSIZE)
235 AC_DEFINE_UNQUOTED(DEFAULT_FD_SETSIZE, $DEFAULT_FD_SETSIZE, [Default FD_SETSIZE value])
239 dnl checks the maximum number of filedescriptor we can open
240 dnl sets shell var squid_filedescriptors_num
242 AC_DEFUN([SQUID_CHECK_MAXFD],[
243 AC_MSG_CHECKING(Maximum number of filedescriptors we can open)
244 dnl damn! FreeBSD pthreads break dup2().
245 SQUID_STATE_SAVE(maxfd)
247 i386-unknown-freebsd*)
248 if echo "$LDFLAGS" | grep -q pthread; then
249 LDFLAGS=`echo $LDFLAGS | sed -e "s/-pthread//"`
252 AC_RUN_IFELSE([AC_LANG_SOURCE([[
256 #include <sys/time.h> /* needed on FreeBSD */
257 #include <sys/param.h>
258 #include <sys/resource.h>
259 int main(int argc, char **argv) {
262 #if defined(__CYGWIN32__) || defined (__CYGWIN__)
263 /* getrlimit and sysconf returns bogous values on cygwin32.
264 * Number of fds is virtually unlimited in cygwin (sys/param.h)
265 * __CYGWIN32__ is deprecated.
271 #if defined(RLIMIT_NOFILE)
272 if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
273 perror("getrlimit: RLIMIT_NOFILE");
275 #if defined(__APPLE__)
276 /* asking for more than OPEN_MAX fails on Leopard */
277 rl.rlim_cur = (OPEN_MAX < rl.rlim_max ? OPEN_MAX : rl.rlim_max);
279 rl.rlim_cur = rl.rlim_max; /* set it to the max */
281 if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
282 perror("setrlimit: RLIMIT_NOFILE");
285 #elif defined(RLIMIT_OFILE)
286 if (getrlimit(RLIMIT_OFILE, &rl) < 0) {
287 perror("getrlimit: RLIMIT_OFILE");
289 rl.rlim_cur = rl.rlim_max; /* set it to the max */
290 if (setrlimit(RLIMIT_OFILE, &rl) < 0) {
291 perror("setrlimit: RLIMIT_OFILE");
294 #endif /* RLIMIT_NOFILE */
295 #endif /* HAVE_SETRLIMIT */
296 /* by starting at 2^14, we will never get higher
297 than 2^15 for squid_filedescriptors_num */
301 if (dup2(0, i) < 0) {
309 #endif /* IF !DEF CYGWIN */
310 fp = fopen("conftestval", "w");
311 fprintf (fp, "%d\n", i & ~0x3F);
314 ]])],[squid_filedescriptors_num=`cat conftestval`],[squid_filedescriptors_num=256],[squid_filedescriptors_num=256])
315 dnl Microsoft MSVCRT.DLL supports 2048 maximum FDs
318 squid_filedescriptors_num="2048"
321 AC_MSG_RESULT($squid_filedescriptors_num)
322 SQUID_STATE_ROLLBACK(maxfd)
324 if test `expr $squid_filedescriptors_num % 64` != 0; then
325 AC_MSG_WARN([$squid_filedescriptors_num is not an multiple of 64. This may cause issues on certain platforms.])
330 dnl Check whether this OS defines sin6_len as a member of sockaddr_in6 as a backup to ss_len
331 dnl defines HAVE_SIN6_LEN_IN_SAI
332 dnl TODO: move to AC_CHECK_MEMBER?
334 AC_DEFUN([SQUID_CHECK_SIN6_LEN_IN_SAI],[
335 AC_CACHE_CHECK([for sin6_len field in struct sockaddr_in6],
336 ac_cv_have_sin6_len_in_struct_sai, [
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_in6 s; s.sin6_len = 1; ]])],[ ac_cv_have_sin6_len_in_struct_sai="yes" ],[ ac_cv_have_sin6_len_in_struct_sai="no"
344 SQUID_DEFINE_BOOL(HAVE_SIN6_LEN_IN_SAI,$ac_cv_have_sin6_len_in_struct_sai,
345 [Defined if struct sockaddr_in6 has sin6_len])
349 dnl Check whether this OS defines ss_len as a member of sockaddr_storage
350 dnl defines HAVE_SS_LEN_IN_SS
351 dnl TODO: move to AC_CHECK_MEMBER?
353 AC_DEFUN([SQUID_CHECK_SS_LEN_IN_SOCKADDR_STORAGE],[
354 AC_CACHE_CHECK([for ss_len field in struct sockaddr_storage],
355 ac_cv_have_ss_len_in_struct_ss, [
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_storage s; s.ss_len = 1; ]])],[ ac_cv_have_ss_len_in_struct_ss="yes" ],[ ac_cv_have_ss_len_in_struct_ss="no"
363 SQUID_DEFINE_BOOL(HAVE_SS_LEN_IN_SS,$ac_cv_have_ss_len_in_struct_ss,
364 [Define if sockaddr_storage has field ss_len])
368 dnl Check whether this OS defines sin_len as a member of sockaddr_in as a backup to ss_len
369 dnl defines HAVE_SIN_LEN_IN_SAI
370 dnl TODO: move to AC_CHECK_MEMBER?
372 AC_DEFUN([SQUID_CHECK_SIN_LEN_IN_SOCKADDR_IN],[
373 AC_CACHE_CHECK([for sin_len field in struct sockaddr_in],
374 ac_cv_have_sin_len_in_struct_sai, [
375 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
376 #include <sys/types.h>
377 #include <sys/socket.h>
378 #include <netinet/in.h>
379 ]], [[ 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"
382 SQUID_DEFINE_BOOL(HAVE_SIN_LEN_IN_SAI,$ac_cv_have_sin_len_in_struct_sai,[Define if sockaddr_in has field sin_len])
386 dnl detects default UDP buffer size
387 dnl not cached since people are likely to tune this
388 dnl defines SQUID_DETECT_UDP_SO_SNDBUF
390 AC_DEFUN([SQUID_DETECT_UDP_SND_BUFSIZE],[
391 AC_MSG_CHECKING(Default UDP send buffer size)
392 AC_RUN_IFELSE([AC_LANG_SOURCE([[
395 #include <sys/types.h>
396 #if HAVE_SYS_SOCKET_H
397 #include <sys/socket.h>
399 #if HAVE_NETINET_IN_H
400 #include <netinet/in.h>
406 #include <winsock2.h>
408 int main(int argc, char **argv)
412 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
415 WSAStartup(2, &wsaData);
417 socklen_t len=sizeof(socklen_t);
419 if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1;
420 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
421 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&val, &len) < 0) return 1;
424 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1;
426 if (val<=0) return 1;
427 fp = fopen("conftestval", "w");
428 fprintf (fp, "%d\n", val);
431 ]])],[SQUID_DETECT_UDP_SO_SNDBUF=`cat conftestval`],[SQUID_DETECT_UDP_SO_SNDBUF=16384],[SQUID_DETECT_UDP_SO_SNDBUF=16384])
432 AC_MSG_RESULT($SQUID_DETECT_UDP_SO_SNDBUF)
433 AC_DEFINE_UNQUOTED(SQUID_DETECT_UDP_SO_SNDBUF, $SQUID_DETECT_UDP_SO_SNDBUF,[UDP send buffer size])
437 dnl detects default UDP buffer size
438 dnl not cached since people are likely to tune this
439 dnl defines SQUID_DETECT_UDP_SO_RCVBUF
441 AC_DEFUN([SQUID_DETECT_UDP_RECV_BUFSIZE],[
442 AC_MSG_CHECKING(Default UDP receive buffer size)
443 AC_RUN_IFELSE([AC_LANG_SOURCE([[
446 #include <sys/types.h>
447 #if HAVE_SYS_SOCKET_H
448 #include <sys/socket.h>
450 #if HAVE_NETINET_IN_H
451 #include <netinet/in.h>
457 #include <winsock2.h>
459 int main(int argc, char **argv)
463 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
466 WSAStartup(2, &wsaData);
468 socklen_t len=sizeof(socklen_t);
470 if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1;
471 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
472 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) return 1;
475 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1;
477 if (val <= 0) return 1;
478 fp = fopen("conftestval", "w");
479 fprintf (fp, "%d\n", val);
482 ]])],[SQUID_DETECT_UDP_SO_RCVBUF=`cat conftestval`],[SQUID_DETECT_UDP_SO_RCVBUF=16384],[SQUID_DETECT_UDP_SO_RCVBUF=16384])
483 AC_MSG_RESULT($SQUID_DETECT_UDP_SO_RCVBUF)
484 AC_DEFINE_UNQUOTED(SQUID_DETECT_UDP_SO_RCVBUF, $SQUID_DETECT_UDP_SO_RCVBUF,[UDP receive buffer size])
488 dnl detects default TCP buffer size
489 dnl not cached since people are likely to tune this
490 dnl defines SQUID_TCP_SO_SNDBUF
492 AC_DEFUN([SQUID_DETECT_TCP_SND_BUFSIZE],[
493 AC_MSG_CHECKING(Default TCP send buffer size)
494 AC_RUN_IFELSE([AC_LANG_SOURCE([[
497 #include <sys/types.h>
498 #if HAVE_SYS_SOCKET_H
499 #include <sys/socket.h>
501 #if HAVE_NETINET_IN_H
502 #include <netinet/in.h>
508 #include <winsock2.h>
510 int main(int argc, char **argv)
514 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
517 WSAStartup(2, &wsaData);
519 socklen_t len=sizeof(socklen_t);
521 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return 1;
522 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
523 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&val, &len) < 0) return 1;
526 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1;
528 if (val <= 0) return 1;
529 fp = fopen("conftestval", "w");
530 fprintf (fp, "%d\n", val);
533 ]])],[SQUID_TCP_SO_SNDBUF=`cat conftestval`],[SQUID_TCP_SO_SNDBUF=16384],[SQUID_TCP_SO_SNDBUF=16384])
534 AC_MSG_RESULT($SQUID_TCP_SO_SNDBUF)
535 if test $SQUID_TCP_SO_SNDBUF -gt 32768; then
536 AC_MSG_NOTICE([Limiting send buffer size to 32K])
537 SQUID_TCP_SO_SNDBUF=32768
539 AC_DEFINE_UNQUOTED(SQUID_TCP_SO_SNDBUF, $SQUID_TCP_SO_SNDBUF,[TCP send buffer size])
543 dnl detects default TCP buffer size
544 dnl not cached since people are likely to tune this
545 dnl defines SQUID_TCP_SO_RECVBUF
547 AC_DEFUN([SQUID_DETECT_TCP_RECV_BUFSIZE],[
548 AC_MSG_CHECKING(Default TCP receive buffer size)
549 AC_RUN_IFELSE([AC_LANG_SOURCE([[
552 #include <sys/types.h>
553 #if HAVE_SYS_SOCKET_H
554 #include <sys/socket.h>
556 #if HAVE_NETINET_IN_H
557 #include <netinet/in.h>
563 #include <winsock2.h>
565 int main(int argc, char **argv)
569 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
572 WSAStartup(2, &wsaData);
574 socklen_t len=sizeof(socklen_t);
576 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return 1;
577 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
578 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) return 1;
581 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1;
583 if (val <= 0) return 1;
584 fp = fopen("conftestval", "w");
585 fprintf (fp, "%d\n", val);
588 ]])],[SQUID_TCP_SO_RCVBUF=`cat conftestval`],[SQUID_TCP_SO_RCVBUF=16384],[SQUID_TCP_SO_RCVBUF=16384])
589 AC_MSG_RESULT($SQUID_TCP_SO_RCVBUF)
590 if test $SQUID_TCP_SO_RCVBUF -gt 65535; then
591 AC_MSG_NOTICE([Limiting receive buffer size to 64K])
592 SQUID_TCP_SO_RCVBUF=65535
594 AC_DEFINE_UNQUOTED(SQUID_TCP_SO_RCVBUF, $SQUID_TCP_SO_RCVBUF,[TCP receive buffer size])
598 dnl check if we need to define sys_errlist as external
599 dnl defines NEED_SYS_ERRLIST
601 AC_DEFUN([SQUID_CHECK_NEED_SYS_ERRLIST],[
602 AC_CACHE_CHECK(if sys_errlist is already defined, ac_cv_needs_sys_errlist,
603 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"])
605 SQUID_DEFINE_BOOL(NEED_SYS_ERRLIST,$ac_cv_needs_sys_errlist,[If we need to declare sys_errlist as extern])
609 dnl check if MAXPATHLEN is defined in the system headers
610 dnl or define it ourselves
612 AC_DEFUN([SQUID_CHECK_MAXPATHLEN],[
613 AC_MSG_CHECKING(for system-provided MAXPATHLEN)
616 #include <sys/param.h>]], [[
617 int i = MAXPATHLEN;]])], [
618 AC_MSG_RESULT(yes)], [
620 AC_DEFINE(MAXPATHLEN,256,[If MAXPATHLEN has not been defined])])
624 dnl check that we have a working statvfs
625 dnl sets the ac_cv_func_statvfs shell variable and defines HAVE_STATVFS
627 AC_DEFUN([SQUID_CHECK_WORKING_STATVFS],[
628 AC_CACHE_CHECK(for working statvfs() interface,ac_cv_func_statvfs,[
629 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
632 #include <sys/types.h>
633 #include <sys/statvfs.h>
636 sfs.f_blocks = sfs.f_bfree = sfs.f_frsize =
637 sfs.f_files = sfs.f_ffree = 0;
638 statvfs("/tmp", &sfs);
639 ]])],[ac_cv_func_statvfs=yes],[ac_cv_func_statvfs=no])
641 SQUID_DEFINE_BOOL(HAVE_STATVFS,$ac_cv_func_statvfs,[set to 1 if our system has statvfs(), and if it actually works])
645 dnl check that we can use the libresolv _dns_ttl_ hack
646 dnl sets the ac_cv_libresolv_dns_ttl_hack shell variable and defines LIBRESOLV_DNS_TTL_HACK
648 AC_DEFUN([SQUID_CHECK_LIBRESOLV_DNS_TTL_HACK],[
649 AC_CACHE_CHECK(for libresolv _dns_ttl_ hack, ac_cv_libresolv_dns_ttl_hack, [
650 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int _dns_ttl_;]], [[return _dns_ttl_;]])],
651 [ac_cv_libresolv_dns_ttl_hack=yes],[ac_cv_libresolv_dns_ttl_hack=no]) ])
652 SQUID_DEFINE_BOOL(LIBRESOLV_DNS_TTL_HACK,$ac_cv_libresolv_dns_ttl_hack,
653 [libresolv.a has been hacked to export _dns_ttl_])
657 dnl checks for availability of some resolver fields
658 dnl sets ac_cv_have_res_ext_nsaddr_list shell variable
659 dnl defines _SQUID_RES_NSADDR6_COUNT _SQUID_RES_NSADDR6_LARRAY
660 dnl defines _SQUID_RES_NSADDR6_LPTR _SQUID_RES_NSADDR6_COUNT
661 dnl defines _SQUID_RES_NSADDR_LIST _SQUID_RES_NSADDR_COUNT
663 AC_DEFUN([SQUID_CHECK_RESOLVER_FIELDS],[
664 AC_CACHE_CHECK(for _res_ext.nsaddr_list, ac_cv_have_res_ext_nsaddr_list,
665 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
667 #include <sys/types.h>
669 #if HAVE_NETINET_IN_H
670 #include <netinet/in.h>
673 #include <arpa/inet.h>
675 #if HAVE_ARPA_NAMESER_H
676 #include <arpa/nameser.h>
682 [[_res_ext.nsaddr_list[[0]].s_addr;]])],[
683 ac_cv_have_res_ext_nsaddr_list="yes" ],[
684 ac_cv_have_res_ext_nsaddr_list="no"]))
685 if test "$ac_cv_have_res_ext_nsaddr_list" = "yes" ; then
686 AC_DEFINE(_SQUID_RES_NSADDR6_LARRAY,_res_ext.nsaddr_list,[If _res_ext structure has nsaddr_list member])
687 AC_DEFINE(_SQUID_RES_NSADDR6_COUNT,ns6count,[Nameserver Counter for IPv6 _res_ext])
690 if test "$_SQUID_RES_NSADDR6_LIST" = ""; then
691 AC_CACHE_CHECK(for _res._u._ext.nsaddrs, ac_cv_have_res_ext_nsaddrs,
692 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
694 #include <sys/types.h>
696 #if HAVE_NETINET_IN_H
697 #include <netinet/in.h>
700 #include <arpa/inet.h>
702 #if HAVE_ARPA_NAMESER_H
703 #include <arpa/nameser.h>
709 [[_res._u._ext.nsaddrs[[0]]->sin6_addr;]])],
710 [ac_cv_have_res_ext_nsaddrs="yes"],[ac_cv_have_res_ext_nsaddrs="no"]))
711 if test "$ac_cv_have_res_ext_nsaddrs" = "yes" ; then
712 AC_DEFINE(_SQUID_RES_NSADDR6_LPTR,_res._u._ext.nsaddrs,[If _res structure has _ext.nsaddrs member])
713 AC_DEFINE(_SQUID_RES_NSADDR6_COUNT,_res._u._ext.nscount6,[Nameserver Counter for IPv6 _res])
717 AC_CACHE_CHECK(for _res.nsaddr_list, ac_cv_have_res_nsaddr_list,
721 #include <sys/types.h>
723 #if HAVE_NETINET_IN_H
724 #include <netinet/in.h>
727 #include <arpa/inet.h>
729 #if HAVE_ARPA_NAMESER_H
730 #include <arpa/nameser.h>
735 ]], [[_res.nsaddr_list[[0]];]])],
736 [ac_cv_have_res_nsaddr_list="yes"],[ac_cv_have_res_nsaddr_list="no"]))
737 if test $ac_cv_have_res_nsaddr_list = "yes" ; then
738 AC_DEFINE(_SQUID_RES_NSADDR_LIST,_res.nsaddr_list,[If _res structure has nsaddr_list member])
739 AC_DEFINE(_SQUID_RES_NSADDR_COUNT,_res.nscount,[Nameserver counter for IPv4 _res])
742 if test "$_SQUID_RES_NSADDR_LIST" = ""; then
743 AC_CACHE_CHECK(for _res.ns_list, ac_cv_have_res_ns_list,
744 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
746 #include <sys/types.h>
748 #if HAVE_NETINET_IN_H
749 #include <netinet/in.h>
752 #include <arpa/inet.h>
754 #if HAVE_ARPA_NAMESER_H
755 #include <arpa/nameser.h>
761 [[_res.ns_list[[0]].addr;]])],
762 [ac_cv_have_res_ns_list="yes"],[ac_cv_have_res_ns_list="no"]))
763 if test $ac_cv_have_res_ns_list = "yes" ; then
764 AC_DEFINE(_SQUID_RES_NSADDR_LIST,_res.ns_list,[If _res structure has ns_list member])
765 AC_DEFINE(_SQUID_RES_NSADDR_COUNT,_res.nscount,[Nameserver counter for IPv4 _res])
771 dnl checks the winsock library to use (ws2_32 or wsock32)
772 dnl may set ac_cv_func_select as a side effect
773 AC_DEFUN([SQUID_CHECK_WINSOCK_LIB],[
774 SQUID_STATE_SAVE(winsock)
775 AC_SEARCH_LIBS([closesocket],[ws2_32 wsock32])
776 AC_MSG_CHECKING([for winsock library])
777 case "$ac_cv_search_closesocket" in
779 AC_MSG_RESULT([winsock library not found])
782 AC_MSG_RESULT([winsock library already in LIBS])
785 AC_MSG_RESULT([winsock2])
786 ac_cv_func_select='yes'
789 AC_MSG_RESULT([winsock])
790 ac_cv_func_select='yes'
793 AC_CHECK_HEADERS(winsock2.h winsock.h)
794 SQUID_STATE_ROLLBACK(winsock)
798 dnl check that setresuid is properly implemented.
799 dnl sets squid_cv_resuid_works to "yes" or "no"
800 AC_DEFUN([SQUID_CHECK_SETRESUID_WORKS],[
801 AC_CACHE_CHECK(if setresuid is actually implemented, squid_cv_resuid_works,
805 int main(int argc, char **argv) {
806 if(setresuid(-1,-1,-1)) {
807 perror("setresuid:");
813 squid_cv_resuid_works="yes" ],[
814 squid_cv_resuid_works="no" ],[:])