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
139 dnl check that /dev/poll actually works
140 dnl sets squid_cv_devpoll_works to "yes" or "no"
141 AC_DEFUN([SQUID_CHECK_DEVPOLL],[
143 AC_CACHE_CHECK(if /dev/poll works, squid_cv_devpoll_works,
144 AC_RUN_IFELSE([AC_LANG_SOURCE([[
145 #include <sys/devpoll.h>
149 int main(int argc, char **argv)
151 int fd = open("/dev/poll", O_RDWR);
153 perror("devpoll_create:");
158 ]])],[squid_cv_devpoll_works=yes],[squid_cv_devpoll_works=no],[:]))
160 ]) dnl SQUID_CHECK_DEVPOLL
163 dnl check that we have functional libcap2 headers
164 dnl sets squid_cv_sys_capability_works to "yes" or "no"
166 AC_DEFUN([SQUID_CHECK_FUNCTIONAL_LIBCAP2],[
167 AC_CACHE_CHECK([for operational libcap2 headers],
168 squid_cv_sys_capability_works,
169 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
172 #include <sys/capability.h>
177 [squid_cv_sys_capability_works=yes],
178 [squid_cv_sys_capability_works=no])
183 dnl Ripped from Samba. Thanks!
184 dnl check that we have Unix sockets. Sets squid_cv_unixsocket to either yes or no depending on the check
186 AC_DEFUN([SQUID_CHECK_UNIX_SOCKET],[
187 AC_CACHE_CHECK([for unix domain sockets],squid_cv_unixsocket, [
188 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
189 #include <sys/types.h>
192 #include <sys/socket.h>
193 #include <sys/un.h>]], [[
194 struct sockaddr_un sunaddr;
195 sunaddr.sun_family = AF_UNIX;
196 ]])],[squid_cv_unixsocket=yes],[squid_cv_unixsocket=no])])
200 dnl check the default FD_SETSIZE size.
201 dnl not cached, people are likely to tune this
202 dnl defines DEFAULT_FD_SETSIZE
204 AC_DEFUN([SQUID_CHECK_DEFAULT_FD_SETSIZE],[
205 AC_MSG_CHECKING(Default FD_SETSIZE value)
206 AC_RUN_IFELSE([AC_LANG_SOURCE([[
217 #include <sys/time.h>
219 #if HAVE_SYS_SELECT_H
220 #include <sys/select.h>
223 #include <sys/types.h>
226 #include <winsock2.h>
230 int main(int argc, char **argv) {
231 FILE *fp = fopen("conftestval", "w");
232 fprintf (fp, "%d\n", FD_SETSIZE);
235 ]])],[DEFAULT_FD_SETSIZE=`cat conftestval`],[DEFAULT_FD_SETSIZE=256],[DEFAULT_FD_SETSIZE=256])
236 AC_MSG_RESULT($DEFAULT_FD_SETSIZE)
237 AC_DEFINE_UNQUOTED(DEFAULT_FD_SETSIZE, $DEFAULT_FD_SETSIZE, [Default FD_SETSIZE value])
241 dnl checks the maximum number of filedescriptor we can open
242 dnl sets shell var squid_filedescriptors_num
244 AC_DEFUN([SQUID_CHECK_MAXFD],[
245 AC_CHECK_FUNCS(setrlimit)
246 AC_MSG_CHECKING(Maximum number of filedescriptors we can open)
247 dnl damn! FreeBSD pthreads break dup2().
248 SQUID_STATE_SAVE(maxfd)
250 i386-unknown-freebsd*)
251 if echo "$LDFLAGS" | grep -q pthread; then
252 LDFLAGS=`echo $LDFLAGS | sed -e "s/-pthread//"`
255 AC_RUN_IFELSE([AC_LANG_SOURCE([[
259 #include <sys/time.h> /* needed on FreeBSD */
260 #include <sys/param.h>
261 #include <sys/resource.h>
262 int main(int argc, char **argv) {
265 #if defined(__CYGWIN32__) || defined (__CYGWIN__)
266 /* getrlimit and sysconf returns bogous values on cygwin32.
267 * Number of fds is virtually unlimited in cygwin (sys/param.h)
268 * __CYGWIN32__ is deprecated.
274 #if defined(RLIMIT_NOFILE)
275 if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
276 perror("getrlimit: RLIMIT_NOFILE");
278 #if defined(__APPLE__)
279 /* asking for more than OPEN_MAX fails on Leopard */
280 rl.rlim_cur = (OPEN_MAX < rl.rlim_max ? OPEN_MAX : rl.rlim_max);
282 rl.rlim_cur = rl.rlim_max; /* set it to the max */
284 if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
285 perror("setrlimit: RLIMIT_NOFILE");
288 #elif defined(RLIMIT_OFILE)
289 if (getrlimit(RLIMIT_OFILE, &rl) < 0) {
290 perror("getrlimit: RLIMIT_OFILE");
292 rl.rlim_cur = rl.rlim_max; /* set it to the max */
293 if (setrlimit(RLIMIT_OFILE, &rl) < 0) {
294 perror("setrlimit: RLIMIT_OFILE");
297 #endif /* RLIMIT_NOFILE */
298 #endif /* HAVE_SETRLIMIT */
299 /* by starting at 2^14, we will never get higher
300 than 2^15 for squid_filedescriptors_num */
304 if (dup2(0, i) < 0) {
312 #endif /* IF !DEF CYGWIN */
313 fp = fopen("conftestval", "w");
314 fprintf (fp, "%d\n", i & ~0x3F);
317 ]])],[squid_filedescriptors_num=`cat conftestval`],[squid_filedescriptors_num=256],[squid_filedescriptors_num=256])
318 dnl Microsoft MSVCRT.DLL supports 2048 maximum FDs
321 squid_filedescriptors_num="2048"
324 AC_MSG_RESULT($squid_filedescriptors_num)
325 SQUID_STATE_ROLLBACK(maxfd)
327 if test `expr $squid_filedescriptors_num % 64` != 0; then
328 AC_MSG_WARN([$squid_filedescriptors_num is not an multiple of 64. This may cause issues on certain platforms.])
333 dnl Check whether this OS defines sin6_len as a member of sockaddr_in6 as a backup to ss_len
334 dnl defines HAVE_SIN6_LEN_IN_SAI
335 dnl TODO: move to AC_CHECK_MEMBER?
337 AC_DEFUN([SQUID_CHECK_SIN6_LEN_IN_SAI],[
338 AC_CACHE_CHECK([for sin6_len field in struct sockaddr_in6],
339 ac_cv_have_sin6_len_in_struct_sai, [
340 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
341 #include <sys/types.h>
342 #include <sys/socket.h>
343 #include <netinet/in.h>
344 ]], [[ 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"
347 SQUID_DEFINE_BOOL(HAVE_SIN6_LEN_IN_SAI,$ac_cv_have_sin6_len_in_struct_sai,
348 [Defined if struct sockaddr_in6 has sin6_len])
352 dnl Check whether this OS defines ss_len as a member of sockaddr_storage
353 dnl defines HAVE_SS_LEN_IN_SS
354 dnl TODO: move to AC_CHECK_MEMBER?
356 AC_DEFUN([SQUID_CHECK_SS_LEN_IN_SOCKADDR_STORAGE],[
357 AC_CACHE_CHECK([for ss_len field in struct sockaddr_storage],
358 ac_cv_have_ss_len_in_struct_ss, [
359 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
360 #include <sys/types.h>
361 #include <sys/socket.h>
362 #include <netinet/in.h>
363 ]], [[ 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"
366 SQUID_DEFINE_BOOL(HAVE_SS_LEN_IN_SS,$ac_cv_have_ss_len_in_struct_ss,
367 [Define if sockaddr_storage has field ss_len])
371 dnl Check whether this OS defines sin_len as a member of sockaddr_in as a backup to ss_len
372 dnl defines HAVE_SIN_LEN_IN_SAI
373 dnl TODO: move to AC_CHECK_MEMBER?
375 AC_DEFUN([SQUID_CHECK_SIN_LEN_IN_SOCKADDR_IN],[
376 AC_CACHE_CHECK([for sin_len field in struct sockaddr_in],
377 ac_cv_have_sin_len_in_struct_sai, [
378 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
379 #include <sys/types.h>
380 #include <sys/socket.h>
381 #include <netinet/in.h>
382 ]], [[ 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"
385 SQUID_DEFINE_BOOL(HAVE_SIN_LEN_IN_SAI,$ac_cv_have_sin_len_in_struct_sai,[Define if sockaddr_in has field sin_len])
389 dnl detects default UDP buffer size
390 dnl not cached since people are likely to tune this
391 dnl defines SQUID_DETECT_UDP_SO_SNDBUF
393 AC_DEFUN([SQUID_DETECT_UDP_SND_BUFSIZE],[
394 AC_MSG_CHECKING(Default UDP send buffer size)
395 AC_RUN_IFELSE([AC_LANG_SOURCE([[
398 #include <sys/types.h>
399 #if HAVE_SYS_SOCKET_H
400 #include <sys/socket.h>
402 #if HAVE_NETINET_IN_H
403 #include <netinet/in.h>
406 #include <winsock2.h>
410 int main(int argc, char **argv)
414 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
417 WSAStartup(2, &wsaData);
419 socklen_t len=sizeof(socklen_t);
421 if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1;
422 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
423 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&val, &len) < 0) return 1;
426 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1;
428 if (val<=0) return 1;
429 fp = fopen("conftestval", "w");
430 fprintf (fp, "%d\n", val);
433 ]])],[SQUID_DETECT_UDP_SO_SNDBUF=`cat conftestval`],[SQUID_DETECT_UDP_SO_SNDBUF=16384],[SQUID_DETECT_UDP_SO_SNDBUF=16384])
434 AC_MSG_RESULT($SQUID_DETECT_UDP_SO_SNDBUF)
435 AC_DEFINE_UNQUOTED(SQUID_DETECT_UDP_SO_SNDBUF, $SQUID_DETECT_UDP_SO_SNDBUF,[UDP send buffer size])
439 dnl detects default UDP buffer size
440 dnl not cached since people are likely to tune this
441 dnl defines SQUID_DETECT_UDP_SO_RCVBUF
443 AC_DEFUN([SQUID_DETECT_UDP_RECV_BUFSIZE],[
444 AC_MSG_CHECKING(Default UDP receive buffer size)
445 AC_RUN_IFELSE([AC_LANG_SOURCE([[
448 #include <sys/types.h>
449 #if HAVE_SYS_SOCKET_H
450 #include <sys/socket.h>
452 #if HAVE_NETINET_IN_H
453 #include <netinet/in.h>
456 #include <winsock2.h>
460 int main(int argc, char **argv)
464 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
467 WSAStartup(2, &wsaData);
469 socklen_t len=sizeof(socklen_t);
471 if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1;
472 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
473 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) return 1;
476 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1;
478 if (val <= 0) return 1;
479 fp = fopen("conftestval", "w");
480 fprintf (fp, "%d\n", val);
483 ]])],[SQUID_DETECT_UDP_SO_RCVBUF=`cat conftestval`],[SQUID_DETECT_UDP_SO_RCVBUF=16384],[SQUID_DETECT_UDP_SO_RCVBUF=16384])
484 AC_MSG_RESULT($SQUID_DETECT_UDP_SO_RCVBUF)
485 AC_DEFINE_UNQUOTED(SQUID_DETECT_UDP_SO_RCVBUF, $SQUID_DETECT_UDP_SO_RCVBUF,[UDP receive buffer size])
489 dnl detects default TCP buffer size
490 dnl not cached since people are likely to tune this
491 dnl defines SQUID_TCP_SO_SNDBUF
493 AC_DEFUN([SQUID_DETECT_TCP_SND_BUFSIZE],[
494 AC_MSG_CHECKING(Default TCP send buffer size)
495 AC_RUN_IFELSE([AC_LANG_SOURCE([[
498 #include <sys/types.h>
499 #if HAVE_SYS_SOCKET_H
500 #include <sys/socket.h>
502 #if HAVE_NETINET_IN_H
503 #include <netinet/in.h>
506 #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>
560 #include <winsock2.h>
564 int main(int argc, char **argv)
568 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
571 WSAStartup(2, &wsaData);
573 socklen_t len=sizeof(socklen_t);
575 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return 1;
576 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
577 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) return 1;
580 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1;
582 if (val <= 0) return 1;
583 fp = fopen("conftestval", "w");
584 fprintf (fp, "%d\n", val);
587 ]])],[SQUID_TCP_SO_RCVBUF=`cat conftestval`],[SQUID_TCP_SO_RCVBUF=16384],[SQUID_TCP_SO_RCVBUF=16384])
588 AC_MSG_RESULT($SQUID_TCP_SO_RCVBUF)
589 if test $SQUID_TCP_SO_RCVBUF -gt 65535; then
590 AC_MSG_NOTICE([Limiting receive buffer size to 64K])
591 SQUID_TCP_SO_RCVBUF=65535
593 AC_DEFINE_UNQUOTED(SQUID_TCP_SO_RCVBUF, $SQUID_TCP_SO_RCVBUF,[TCP receive buffer size])
597 dnl check if we need to define sys_errlist as external
598 dnl defines NEED_SYS_ERRLIST
600 AC_DEFUN([SQUID_CHECK_NEED_SYS_ERRLIST],[
601 AC_CACHE_CHECK(if sys_errlist is already defined, ac_cv_needs_sys_errlist,
602 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"])
604 SQUID_DEFINE_BOOL(NEED_SYS_ERRLIST,$ac_cv_needs_sys_errlist,[If we need to declare sys_errlist as extern])
608 dnl check if MAXPATHLEN is defined in the system headers
609 dnl or define it ourselves
611 AC_DEFUN([SQUID_CHECK_MAXPATHLEN],[
612 AC_MSG_CHECKING(for system-provided MAXPATHLEN)
615 #include <sys/param.h>]], [[
616 int i = MAXPATHLEN;]])], [
617 AC_MSG_RESULT(yes)], [
619 AC_DEFINE(MAXPATHLEN,256,[If MAXPATHLEN has not been defined])])
623 dnl check that we have a working statvfs
624 dnl sets the ac_cv_func_statvfs shell variable and defines HAVE_STATVFS
626 AC_DEFUN([SQUID_CHECK_WORKING_STATVFS],[
627 AC_CACHE_CHECK(for working statvfs() interface,ac_cv_func_statvfs,[
628 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
631 #include <sys/types.h>
632 #include <sys/statvfs.h>
635 sfs.f_blocks = sfs.f_bfree = sfs.f_frsize =
636 sfs.f_files = sfs.f_ffree = 0;
637 statvfs("/tmp", &sfs);
638 ]])],[ac_cv_func_statvfs=yes],[ac_cv_func_statvfs=no])
640 SQUID_DEFINE_BOOL(HAVE_STATVFS,$ac_cv_func_statvfs,[set to 1 if our system has statvfs(), and if it actually works])
644 dnl check that we can use the libresolv _dns_ttl_ hack
645 dnl sets the ac_cv_libresolv_dns_ttl_hack shell variable and defines LIBRESOLV_DNS_TTL_HACK
647 AC_DEFUN([SQUID_CHECK_LIBRESOLV_DNS_TTL_HACK],[
648 AC_CACHE_CHECK(for libresolv _dns_ttl_ hack, ac_cv_libresolv_dns_ttl_hack, [
649 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int _dns_ttl_;]], [[return _dns_ttl_;]])],
650 [ac_cv_libresolv_dns_ttl_hack=yes],[ac_cv_libresolv_dns_ttl_hack=no]) ])
651 SQUID_DEFINE_BOOL(LIBRESOLV_DNS_TTL_HACK,$ac_cv_libresolv_dns_ttl_hack,
652 [libresolv.a has been hacked to export _dns_ttl_])
656 dnl checks for availability of some resolver fields
657 dnl sets ac_cv_have_res_ext_nsaddr_list shell variable
658 dnl defines _SQUID_RES_NSADDR6_COUNT _SQUID_RES_NSADDR6_LARRAY
659 dnl defines _SQUID_RES_NSADDR6_LPTR _SQUID_RES_NSADDR6_COUNT
660 dnl defines _SQUID_RES_NSADDR_LIST _SQUID_RES_NSADDR_COUNT
662 AC_DEFUN([SQUID_CHECK_RESOLVER_FIELDS],[
663 AC_CACHE_CHECK(for _res_ext.nsaddr_list, ac_cv_have_res_ext_nsaddr_list,
664 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
666 #include <sys/types.h>
668 #if HAVE_NETINET_IN_H
669 #include <netinet/in.h>
672 #include <arpa/inet.h>
674 #if HAVE_ARPA_NAMESER_H
675 #include <arpa/nameser.h>
681 [[_res_ext.nsaddr_list[[0]].s_addr;]])],[
682 ac_cv_have_res_ext_nsaddr_list="yes" ],[
683 ac_cv_have_res_ext_nsaddr_list="no"]))
684 if test "$ac_cv_have_res_ext_nsaddr_list" = "yes" ; then
685 AC_DEFINE(_SQUID_RES_NSADDR6_LARRAY,_res_ext.nsaddr_list,[If _res_ext structure has nsaddr_list member])
686 AC_DEFINE(_SQUID_RES_NSADDR6_COUNT,ns6count,[Nameserver Counter for IPv6 _res_ext])
689 if test "$_SQUID_RES_NSADDR6_LIST" = ""; then
690 AC_CACHE_CHECK(for _res._u._ext.nsaddrs, ac_cv_have_res_ext_nsaddrs,
691 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
693 #include <sys/types.h>
695 #if HAVE_NETINET_IN_H
696 #include <netinet/in.h>
699 #include <arpa/inet.h>
701 #if HAVE_ARPA_NAMESER_H
702 #include <arpa/nameser.h>
708 [[_res._u._ext.nsaddrs[[0]]->sin6_addr;]])],
709 [ac_cv_have_res_ext_nsaddrs="yes"],[ac_cv_have_res_ext_nsaddrs="no"]))
710 if test "$ac_cv_have_res_ext_nsaddrs" = "yes" ; then
711 AC_DEFINE(_SQUID_RES_NSADDR6_LPTR,_res._u._ext.nsaddrs,[If _res structure has _ext.nsaddrs member])
712 AC_DEFINE(_SQUID_RES_NSADDR6_COUNT,_res._u._ext.nscount6,[Nameserver Counter for IPv6 _res])
716 AC_CACHE_CHECK(for _res.nsaddr_list, ac_cv_have_res_nsaddr_list,
720 #include <sys/types.h>
722 #if HAVE_NETINET_IN_H
723 #include <netinet/in.h>
726 #include <arpa/inet.h>
728 #if HAVE_ARPA_NAMESER_H
729 #include <arpa/nameser.h>
734 ]], [[_res.nsaddr_list[[0]];]])],
735 [ac_cv_have_res_nsaddr_list="yes"],[ac_cv_have_res_nsaddr_list="no"]))
736 if test $ac_cv_have_res_nsaddr_list = "yes" ; then
737 AC_DEFINE(_SQUID_RES_NSADDR_LIST,_res.nsaddr_list,[If _res structure has nsaddr_list member])
738 AC_DEFINE(_SQUID_RES_NSADDR_COUNT,_res.nscount,[Nameserver counter for IPv4 _res])
741 if test "$_SQUID_RES_NSADDR_LIST" = ""; then
742 AC_CACHE_CHECK(for _res.ns_list, ac_cv_have_res_ns_list,
743 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
745 #include <sys/types.h>
747 #if HAVE_NETINET_IN_H
748 #include <netinet/in.h>
751 #include <arpa/inet.h>
753 #if HAVE_ARPA_NAMESER_H
754 #include <arpa/nameser.h>
760 [[_res.ns_list[[0]].addr;]])],
761 [ac_cv_have_res_ns_list="yes"],[ac_cv_have_res_ns_list="no"]))
762 if test $ac_cv_have_res_ns_list = "yes" ; then
763 AC_DEFINE(_SQUID_RES_NSADDR_LIST,_res.ns_list,[If _res structure has ns_list member])
764 AC_DEFINE(_SQUID_RES_NSADDR_COUNT,_res.nscount,[Nameserver counter for IPv4 _res])
770 dnl checks the winsock library to use (ws2_32 or wsock32)
771 dnl may set ac_cv_func_select as a side effect
772 AC_DEFUN([SQUID_CHECK_WINSOCK_LIB],[
773 AC_CHECK_HEADERS(winsock2.h winsock.h)
774 SQUID_STATE_SAVE(winsock)
775 SQUID_SEARCH_LIBS([squid_getprotobynumber],[ws2_32 wsock32],,,,[
777 #include <winsock2.h>
782 void squid_getprotobynumber(void) {
786 AC_MSG_CHECKING([for winsock library])
787 case "$ac_cv_search_squid_getprotobynumber" in
789 AC_MSG_RESULT([winsock library not found])
792 AC_MSG_RESULT([winsock library already in LIBS])
795 AC_MSG_RESULT([winsock2])
796 XTRA_LIBS="-lws2_32 $XTRA_LIBS"
797 ac_cv_func_select='yes'
800 AC_MSG_RESULT([winsock])
801 XTRA_LIBS="-lwsock32 $XTRA_LIBS"
802 ac_cv_func_select='yes'
805 SQUID_STATE_ROLLBACK(winsock)
808 dnl check that setresuid is properly implemented.
809 dnl sets squid_cv_resuid_works to "yes" or "no"
810 AC_DEFUN([SQUID_CHECK_SETRESUID_WORKS],[
811 AC_CACHE_CHECK(if setresuid is actually implemented, squid_cv_resuid_works,
823 int main(int argc, char **argv) {
824 if(setresuid(-1,-1,-1)) {
825 perror("setresuid:");
831 squid_cv_resuid_works="yes" ],[
832 squid_cv_resuid_works="no" ],[:])
836 dnl check that we have functional CPU clock access for the profiler
837 dnl sets squid_cv_profiler_works to "yes" or "no"
839 AC_DEFUN([SQUID_CHECK_FUNCTIONAL_CPU_PROFILER],[
840 AC_CACHE_CHECK([for operational CPU clock access],
841 squid_cv_cpu_profiler_works,
842 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
843 #if defined(__GNUC__) && ( defined(__i386) || defined(__i386__) )
845 #elif defined(__GNUC__) && ( defined(__x86_64) || defined(__x86_64__) )
847 #elif defined(__GNUC__) && defined(__alpha)
849 #elif defined(_M_IX86) && defined(_MSC_VER) /* x86 platform on Microsoft C Compiler ONLY */
852 #error This CPU is unsupported. No profiling available here.
855 squid_cv_cpu_profiler_works=yes],[
856 squid_cv_cpu_profiler_works=no])
860 dnl check whether recv takes a char* or void* as a second argument
861 AC_DEFUN([SQUID_CHECK_RECV_ARG_TYPE],[
862 AC_CACHE_CHECK([whether recv takes a pointer to void or char as second argument],
863 squid_cv_recv_second_arg_type, [
864 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
865 #include <sys/types.h>
866 #if HAVE_SYS_SOCKET_H
867 #include <sys/socket.h>
870 #include <winsock2.h>
874 int main (int argc, char ** argv) {
878 ]])],[squid_cv_recv_second_arg_type=void],
879 [squid_cv_recv_second_arg_type=char])
880 AC_MSG_RESULT($squid_cv_recv_second_arg_type*)
882 AC_DEFINE_UNQUOTED(RECV_ARG_TYPE,$squid_cv_recv_second_arg_type,
883 [Base type of the second argument to recv(2)])