1 ## Copyright (C) 1996-2023 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 AS_IF([test "x$squid_cv_func_strnstr" = "xyes"],[AC_DEFINE(HAVE_STRNSTR,1)])
34 ]) dnl SQUID_CHECK_FUNC_STRNSTR
36 dnl check that epoll actually works
37 dnl sets squid_cv_epoll_works to "yes" or "no"
38 AC_DEFUN([SQUID_CHECK_EPOLL],[
40 AC_CACHE_CHECK(if epoll works, squid_cv_epoll_works,
41 AC_RUN_IFELSE([AC_LANG_SOURCE([[
42 #include <sys/epoll.h>
45 int main(int argc, char **argv)
47 int fd = epoll_create(256);
49 perror("epoll_create:");
54 ]])],[squid_cv_epoll_works=yes],[squid_cv_epoll_works=no],[:]))
56 ]) dnl SQUID_CHECK_EPOLL
58 dnl check that /dev/poll actually works
59 dnl sets squid_cv_devpoll_works to "yes" or "no"
60 AC_DEFUN([SQUID_CHECK_DEVPOLL],[
62 AC_CACHE_CHECK(if /dev/poll works, squid_cv_devpoll_works,
63 AC_RUN_IFELSE([AC_LANG_SOURCE([[
64 #include <sys/devpoll.h>
68 int main(int argc, char **argv)
70 int fd = open("/dev/poll", O_RDWR);
72 perror("devpoll_create:");
77 ]])],[squid_cv_devpoll_works=yes],[squid_cv_devpoll_works=no],[:]))
79 ]) dnl SQUID_CHECK_DEVPOLL
82 dnl check that we have functional libcap2 headers
83 dnl sets squid_cv_sys_capability_works to "yes" or "no"
84 AC_DEFUN([SQUID_CHECK_FUNCTIONAL_LIBCAP2],[
85 AC_CHECK_HEADERS([sys/capability.h])
86 AC_CACHE_CHECK([for operational libcap2 headers],
87 squid_cv_sys_capability_works,
88 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
91 #include <sys/capability.h>
96 [squid_cv_sys_capability_works=yes],
97 [squid_cv_sys_capability_works=no])
102 dnl From Samba. Thanks!
103 dnl check that we have Unix sockets. Sets squid_cv_unixsocket to either yes or no depending on the check
105 AC_DEFUN([SQUID_CHECK_UNIX_SOCKET],[
106 AC_CACHE_CHECK([for unix domain sockets],squid_cv_unixsocket, [
107 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
108 #include <sys/types.h>
111 #include <sys/socket.h>
112 #include <sys/un.h>]], [[
113 struct sockaddr_un sunaddr;
114 sunaddr.sun_family = AF_UNIX;
115 ]])],[squid_cv_unixsocket=yes],[squid_cv_unixsocket=no])])
119 dnl check the default FD_SETSIZE size.
120 dnl not cached, people are likely to tune this
121 dnl defines DEFAULT_FD_SETSIZE
123 AC_DEFUN([SQUID_CHECK_DEFAULT_FD_SETSIZE],[
124 AC_MSG_CHECKING(Default FD_SETSIZE value)
125 AC_RUN_IFELSE([AC_LANG_SOURCE([[
136 #include <sys/time.h>
138 #if HAVE_SYS_SELECT_H
139 #include <sys/select.h>
142 #include <sys/types.h>
145 #include <winsock2.h>
147 int main(int argc, char **argv) {
148 FILE *fp = fopen("conftestval", "w");
149 fprintf (fp, "%d\n", FD_SETSIZE);
152 ]])],[DEFAULT_FD_SETSIZE=`cat conftestval`],[DEFAULT_FD_SETSIZE=256],[DEFAULT_FD_SETSIZE=256])
153 AC_MSG_RESULT($DEFAULT_FD_SETSIZE)
154 AC_DEFINE_UNQUOTED(DEFAULT_FD_SETSIZE, $DEFAULT_FD_SETSIZE, [Default FD_SETSIZE value])
158 dnl checks the maximum number of filedescriptor we can open
159 dnl sets shell var squid_filedescriptors_num
161 AC_DEFUN([SQUID_CHECK_MAXFD],[
162 AC_CHECK_FUNCS(getrlimit setrlimit)
163 AC_MSG_CHECKING(Maximum number of filedescriptors we can open)
164 SQUID_STATE_SAVE(maxfd)
165 dnl FreeBSD pthreads break dup2().
166 AS_CASE([$host_os],[freebsd],[ LDFLAGS=`echo $LDFLAGS | sed -e "s/-pthread//"` ])
167 AC_RUN_IFELSE([AC_LANG_SOURCE([[
171 #include <sys/time.h> /* needed on FreeBSD */
172 #include <sys/param.h>
173 #include <sys/resource.h>
174 int main(int argc, char **argv) {
177 #if defined(__CYGWIN32__) || defined (__CYGWIN__)
178 /* getrlimit and sysconf returns bogous values on cygwin32.
179 * Number of fds is virtually unlimited in cygwin (sys/param.h)
180 * __CYGWIN32__ is deprecated.
184 #if HAVE_GETRLIMIT && HAVE_SETRLIMIT
186 #if defined(RLIMIT_NOFILE)
187 if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
188 perror("getrlimit: RLIMIT_NOFILE");
190 #if defined(__APPLE__)
191 /* asking for more than OPEN_MAX fails on Leopard */
192 rl.rlim_cur = (OPEN_MAX < rl.rlim_max ? OPEN_MAX : rl.rlim_max);
194 rl.rlim_cur = rl.rlim_max; /* set it to the max */
196 if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
197 perror("setrlimit: RLIMIT_NOFILE");
200 #elif defined(RLIMIT_OFILE)
201 if (getrlimit(RLIMIT_OFILE, &rl) < 0) {
202 perror("getrlimit: RLIMIT_OFILE");
204 rl.rlim_cur = rl.rlim_max; /* set it to the max */
205 if (setrlimit(RLIMIT_OFILE, &rl) < 0) {
206 perror("setrlimit: RLIMIT_OFILE");
209 #endif /* RLIMIT_NOFILE */
210 #endif /* HAVE_SETRLIMIT */
211 /* by starting at 2^14, we will never get higher
212 than 2^15 for squid_filedescriptors_num */
216 if (dup2(0, i) < 0) {
224 #endif /* IF !DEF CYGWIN */
225 fp = fopen("conftestval", "w");
226 fprintf (fp, "%d\n", i & ~0x3F);
229 ]])],[squid_filedescriptors_limit=`cat conftestval`],[],[:])
230 dnl Microsoft MSVCRT.DLL supports 2048 maximum FDs
231 AS_CASE(["$host_os"],[mingw|mingw32],[squid_filedescriptors_limit="2048"])
232 AC_MSG_RESULT($squid_filedescriptors_limit)
233 AS_IF([test "x$squid_filedescriptors_num" = "x"],[
234 AS_IF([test "x$squid_filedescriptors_limit" != "x"],[
235 squid_filedescriptors_num=$squid_filedescriptors_limit
237 AC_MSG_NOTICE([Unable to detect filedescriptor limits. Assuming 256 is okay.])
238 squid_filedescriptors_num=256
241 SQUID_STATE_ROLLBACK(maxfd)
243 AC_MSG_NOTICE([Default number of filedescriptors: $squid_filedescriptors_num])
245 AS_IF([ test `expr $squid_filedescriptors_num % 64` != 0 ],[
246 AC_MSG_WARN([$squid_filedescriptors_num is not an multiple of 64. This may cause issues on certain platforms.])
249 AS_IF([ test "$squid_filedescriptors_num" -lt 512 ],[
250 AC_MSG_WARN([$squid_filedescriptors_num may not be enough filedescriptors if your])
251 AC_MSG_WARN([cache will be very busy. Please see the FAQ page])
252 AC_MSG_WARN([http://wiki.squid-cache.org/SquidFaq/TroubleShooting])
253 AC_MSG_WARN([on how to increase your filedescriptor limit])
255 AC_DEFINE_UNQUOTED(SQUID_MAXFD,$squid_filedescriptors_num,[Maximum number of open filedescriptors])
259 dnl Check whether this OS defines sin6_len as a member of sockaddr_in6 as a backup to ss_len
260 dnl defines HAVE_SIN6_LEN_IN_SAI
261 dnl TODO: move to AC_CHECK_MEMBER?
263 AC_DEFUN([SQUID_CHECK_SIN6_LEN_IN_SAI],[
264 AC_CACHE_CHECK([for sin6_len field in struct sockaddr_in6],
265 ac_cv_have_sin6_len_in_struct_sai, [
266 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
267 #include <sys/types.h>
268 #include <sys/socket.h>
269 #include <netinet/in.h>
270 ]], [[ 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"
273 SQUID_DEFINE_BOOL(HAVE_SIN6_LEN_IN_SAI,$ac_cv_have_sin6_len_in_struct_sai,
274 [Defined if struct sockaddr_in6 has sin6_len])
278 dnl Check whether this OS defines ss_len as a member of sockaddr_storage
279 dnl defines HAVE_SS_LEN_IN_SS
280 dnl TODO: move to AC_CHECK_MEMBER?
282 AC_DEFUN([SQUID_CHECK_SS_LEN_IN_SOCKADDR_STORAGE],[
283 AC_CACHE_CHECK([for ss_len field in struct sockaddr_storage],
284 ac_cv_have_ss_len_in_struct_ss, [
285 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
286 #include <sys/types.h>
287 #include <sys/socket.h>
288 #include <netinet/in.h>
289 ]], [[ 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"
292 SQUID_DEFINE_BOOL(HAVE_SS_LEN_IN_SS,$ac_cv_have_ss_len_in_struct_ss,
293 [Define if sockaddr_storage has field ss_len])
297 dnl Check whether this OS defines sin_len as a member of sockaddr_in as a backup to ss_len
298 dnl defines HAVE_SIN_LEN_IN_SAI
299 dnl TODO: move to AC_CHECK_MEMBER?
301 AC_DEFUN([SQUID_CHECK_SIN_LEN_IN_SOCKADDR_IN],[
302 AC_CACHE_CHECK([for sin_len field in struct sockaddr_in],
303 ac_cv_have_sin_len_in_struct_sai, [
304 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
305 #include <sys/types.h>
306 #include <sys/socket.h>
307 #include <netinet/in.h>
308 ]], [[ 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"
311 SQUID_DEFINE_BOOL(HAVE_SIN_LEN_IN_SAI,$ac_cv_have_sin_len_in_struct_sai,[Define if sockaddr_in has field sin_len])
315 dnl detects default UDP buffer size
316 dnl not cached since people are likely to tune this
317 dnl defines SQUID_DETECT_UDP_SO_SNDBUF
319 AC_DEFUN([SQUID_DETECT_UDP_SND_BUFSIZE],[
320 AC_MSG_CHECKING(Default UDP send buffer size)
321 AC_RUN_IFELSE([AC_LANG_SOURCE([[
324 #include <sys/types.h>
325 #if HAVE_SYS_SOCKET_H
326 #include <sys/socket.h>
328 #if HAVE_NETINET_IN_H
329 #include <netinet/in.h>
332 #include <winsock2.h>
334 int main(int argc, char **argv)
338 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
341 WSAStartup(2, &wsaData);
343 socklen_t len=sizeof(socklen_t);
345 if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1;
346 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
347 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&val, &len) < 0) return 1;
350 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1;
352 if (val<=0) return 1;
353 fp = fopen("conftestval", "w");
354 fprintf (fp, "%d\n", val);
357 ]])],[SQUID_DETECT_UDP_SO_SNDBUF=`cat conftestval`],[SQUID_DETECT_UDP_SO_SNDBUF=16384],[SQUID_DETECT_UDP_SO_SNDBUF=16384])
358 AC_MSG_RESULT($SQUID_DETECT_UDP_SO_SNDBUF)
359 AC_DEFINE_UNQUOTED(SQUID_DETECT_UDP_SO_SNDBUF, $SQUID_DETECT_UDP_SO_SNDBUF,[UDP send buffer size])
363 dnl detects default UDP buffer size
364 dnl not cached since people are likely to tune this
365 dnl defines SQUID_DETECT_UDP_SO_RCVBUF
367 AC_DEFUN([SQUID_DETECT_UDP_RECV_BUFSIZE],[
368 AC_MSG_CHECKING(Default UDP receive buffer size)
369 AC_RUN_IFELSE([AC_LANG_SOURCE([[
372 #include <sys/types.h>
373 #if HAVE_SYS_SOCKET_H
374 #include <sys/socket.h>
376 #if HAVE_NETINET_IN_H
377 #include <netinet/in.h>
380 #include <winsock2.h>
382 int main(int argc, char **argv)
386 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
389 WSAStartup(2, &wsaData);
391 socklen_t len=sizeof(socklen_t);
393 if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1;
394 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
395 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) return 1;
398 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1;
400 if (val <= 0) return 1;
401 fp = fopen("conftestval", "w");
402 fprintf (fp, "%d\n", val);
405 ]])],[SQUID_DETECT_UDP_SO_RCVBUF=`cat conftestval`],[SQUID_DETECT_UDP_SO_RCVBUF=16384],[SQUID_DETECT_UDP_SO_RCVBUF=16384])
406 AC_MSG_RESULT($SQUID_DETECT_UDP_SO_RCVBUF)
407 AC_DEFINE_UNQUOTED(SQUID_DETECT_UDP_SO_RCVBUF, $SQUID_DETECT_UDP_SO_RCVBUF,[UDP receive buffer size])
411 dnl detects default TCP buffer size
412 dnl not cached since people are likely to tune this
413 dnl defines SQUID_TCP_SO_SNDBUF
415 AC_DEFUN([SQUID_DETECT_TCP_SND_BUFSIZE],[
416 AC_MSG_CHECKING(Default TCP send buffer size)
417 AC_RUN_IFELSE([AC_LANG_SOURCE([[
420 #include <sys/types.h>
421 #if HAVE_SYS_SOCKET_H
422 #include <sys/socket.h>
424 #if HAVE_NETINET_IN_H
425 #include <netinet/in.h>
428 #include <winsock2.h>
430 int main(int argc, char **argv)
434 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
437 WSAStartup(2, &wsaData);
439 socklen_t len=sizeof(socklen_t);
441 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return 1;
442 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
443 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&val, &len) < 0) return 1;
446 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1;
448 if (val <= 0) return 1;
449 fp = fopen("conftestval", "w");
450 fprintf (fp, "%d\n", val);
453 ]])],[SQUID_TCP_SO_SNDBUF=`cat conftestval`],[SQUID_TCP_SO_SNDBUF=16384],[SQUID_TCP_SO_SNDBUF=16384])
454 AC_MSG_RESULT($SQUID_TCP_SO_SNDBUF)
455 AS_IF([test $SQUID_TCP_SO_SNDBUF -gt 32768],[
456 AC_MSG_NOTICE([Limiting send buffer size to 32K])
457 SQUID_TCP_SO_SNDBUF=32768
459 AC_DEFINE_UNQUOTED(SQUID_TCP_SO_SNDBUF, $SQUID_TCP_SO_SNDBUF,[TCP send buffer size])
463 dnl detects default TCP buffer size
464 dnl not cached since people are likely to tune this
465 dnl defines SQUID_TCP_SO_RECVBUF
467 AC_DEFUN([SQUID_DETECT_TCP_RECV_BUFSIZE],[
468 AC_MSG_CHECKING(Default TCP receive buffer size)
469 AC_RUN_IFELSE([AC_LANG_SOURCE([[
472 #include <sys/types.h>
473 #if HAVE_SYS_SOCKET_H
474 #include <sys/socket.h>
476 #if HAVE_NETINET_IN_H
477 #include <netinet/in.h>
480 #include <winsock2.h>
482 int main(int argc, char **argv)
486 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
489 WSAStartup(2, &wsaData);
491 socklen_t len=sizeof(socklen_t);
493 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return 1;
494 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
495 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) return 1;
498 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1;
500 if (val <= 0) return 1;
501 fp = fopen("conftestval", "w");
502 fprintf (fp, "%d\n", val);
505 ]])],[SQUID_TCP_SO_RCVBUF=`cat conftestval`],[SQUID_TCP_SO_RCVBUF=16384],[SQUID_TCP_SO_RCVBUF=16384])
506 AC_MSG_RESULT($SQUID_TCP_SO_RCVBUF)
507 AS_IF([test $SQUID_TCP_SO_RCVBUF -gt 65535],[
508 AC_MSG_NOTICE([Limiting receive buffer size to 64K])
509 SQUID_TCP_SO_RCVBUF=65535
511 AC_DEFINE_UNQUOTED(SQUID_TCP_SO_RCVBUF, $SQUID_TCP_SO_RCVBUF, [TCP receive buffer size])
515 dnl check if we need to define sys_errlist as external
516 dnl defines NEED_SYS_ERRLIST
518 AC_DEFUN([SQUID_CHECK_NEED_SYS_ERRLIST],[
519 AC_CACHE_CHECK(if sys_errlist is already defined, ac_cv_needs_sys_errlist,
520 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"])
522 SQUID_DEFINE_BOOL(NEED_SYS_ERRLIST,$ac_cv_needs_sys_errlist,[If we need to declare sys_errlist as extern])
526 dnl check if MAXPATHLEN is defined in the system headers
527 dnl or define it ourselves
529 AC_DEFUN([SQUID_CHECK_MAXPATHLEN],[
530 AC_MSG_CHECKING(for system-provided MAXPATHLEN)
533 #include <sys/param.h>]], [[
534 int i = MAXPATHLEN;]])], [
535 AC_MSG_RESULT(yes)], [
537 AC_DEFINE(MAXPATHLEN,256,[If MAXPATHLEN has not been defined])])
541 dnl check that we have a working statvfs
542 dnl sets the ac_cv_func_statvfs shell variable and defines HAVE_STATVFS
544 AC_DEFUN([SQUID_CHECK_WORKING_STATVFS],[
545 AC_CACHE_CHECK(for working statvfs() interface,ac_cv_func_statvfs,[
546 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
549 #include <sys/types.h>
550 #include <sys/statvfs.h>
553 sfs.f_blocks = sfs.f_bfree = sfs.f_frsize =
554 sfs.f_files = sfs.f_ffree = 0;
555 statvfs("/tmp", &sfs);
556 ]])],[ac_cv_func_statvfs=yes],[ac_cv_func_statvfs=no])
558 SQUID_DEFINE_BOOL(HAVE_STATVFS,$ac_cv_func_statvfs,[set to 1 if our system has statvfs(), and if it actually works])
562 dnl Check whether this OS defines f_frsize as a member of struct statfs
563 AC_DEFUN([SQUID_CHECK_F_FRSIZE_IN_STATFS],[
564 AC_CACHE_CHECK([for f_frsize field in struct statfs],
565 ac_cv_have_f_frsize_in_struct_statfs, [
566 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
567 #if HAVE_SYS_STATFS_H
568 #include <sts/statfs.h>
570 #if HAVE_SYS_STATVFS_H
571 #include <sts/statvfs.h>
576 ]], [[ 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"
579 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)])
583 dnl check that we can use the libresolv _dns_ttl_ hack
584 dnl sets the ac_cv_libresolv_dns_ttl_hack shell variable and defines LIBRESOLV_DNS_TTL_HACK
586 AC_DEFUN([SQUID_CHECK_LIBRESOLV_DNS_TTL_HACK],[
587 AC_CACHE_CHECK(for libresolv _dns_ttl_ hack, ac_cv_libresolv_dns_ttl_hack, [
588 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int _dns_ttl_;]], [[return _dns_ttl_;]])],
589 [ac_cv_libresolv_dns_ttl_hack=yes],[ac_cv_libresolv_dns_ttl_hack=no]) ])
590 SQUID_DEFINE_BOOL(LIBRESOLV_DNS_TTL_HACK,$ac_cv_libresolv_dns_ttl_hack,
591 [libresolv.a has been hacked to export _dns_ttl_])
595 dnl checks for availability of some resolver fields
596 dnl sets ac_cv_have_res_ext_nsaddr_list shell variable
597 dnl defines _SQUID_RES_NSADDR6_COUNT _SQUID_RES_NSADDR6_LARRAY
598 dnl defines _SQUID_RES_NSADDR6_LPTR _SQUID_RES_NSADDR6_COUNT
599 dnl defines _SQUID_RES_NSADDR_LIST _SQUID_RES_NSADDR_COUNT
601 AC_DEFUN([SQUID_CHECK_RESOLVER_FIELDS],[
602 AC_CACHE_CHECK(for _res_ext.nsaddr_list, ac_cv_have_res_ext_nsaddr_list,
603 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
605 #include <sys/types.h>
607 #if HAVE_NETINET_IN_H
608 #include <netinet/in.h>
611 #include <arpa/inet.h>
613 #if HAVE_ARPA_NAMESER_H
614 #include <arpa/nameser.h>
620 [[_res_ext.nsaddr_list[[0]].s_addr;]])],[
621 ac_cv_have_res_ext_nsaddr_list="yes" ],[
622 ac_cv_have_res_ext_nsaddr_list="no"]))
623 AS_IF([test "x$ac_cv_have_res_ext_nsaddr_list" = "xyes"],[
624 AC_DEFINE(_SQUID_RES_NSADDR6_LARRAY,_res_ext.nsaddr_list,[If _res_ext structure has nsaddr_list member])
625 AC_DEFINE(_SQUID_RES_NSADDR6_COUNT,ns6count,[Nameserver Counter for IPv6 _res_ext])
628 AS_IF([test "x$_SQUID_RES_NSADDR6_LIST" = "x"],[
629 AC_CACHE_CHECK(for _res._u._ext.nsaddrs, ac_cv_have_res_ext_nsaddrs,
630 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
632 #include <sys/types.h>
634 #if HAVE_NETINET_IN_H
635 #include <netinet/in.h>
638 #include <arpa/inet.h>
640 #if HAVE_ARPA_NAMESER_H
641 #include <arpa/nameser.h>
647 [[_res._u._ext.nsaddrs[[0]]->sin6_addr;]])],
648 [ac_cv_have_res_ext_nsaddrs="yes"],[ac_cv_have_res_ext_nsaddrs="no"]))
649 AS_IF([test "x$ac_cv_have_res_ext_nsaddrs" = "xyes"],[
650 AC_DEFINE(_SQUID_RES_NSADDR6_LPTR,_res._u._ext.nsaddrs,[If _res structure has _ext.nsaddrs member])
651 AC_DEFINE(_SQUID_RES_NSADDR6_COUNT,_res._u._ext.nscount6,[Nameserver Counter for IPv6 _res])
655 AC_CACHE_CHECK(for _res.nsaddr_list, ac_cv_have_res_nsaddr_list,
659 #include <sys/types.h>
661 #if HAVE_NETINET_IN_H
662 #include <netinet/in.h>
665 #include <arpa/inet.h>
667 #if HAVE_ARPA_NAMESER_H
668 #include <arpa/nameser.h>
673 ]], [[_res.nsaddr_list[[0]];]])],
674 [ac_cv_have_res_nsaddr_list="yes"],[ac_cv_have_res_nsaddr_list="no"]))
675 AS_IF([test "x$ac_cv_have_res_nsaddr_list" = "xyes"],[
676 AC_DEFINE(_SQUID_RES_NSADDR_LIST,_res.nsaddr_list,[If _res structure has nsaddr_list member])
677 AC_DEFINE(_SQUID_RES_NSADDR_COUNT,_res.nscount,[Nameserver counter for IPv4 _res])
680 AS_IF([test "x$_SQUID_RES_NSADDR_LIST" = "x"],[
681 AC_CACHE_CHECK(for _res.ns_list, ac_cv_have_res_ns_list,
682 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
684 #include <sys/types.h>
686 #if HAVE_NETINET_IN_H
687 #include <netinet/in.h>
690 #include <arpa/inet.h>
692 #if HAVE_ARPA_NAMESER_H
693 #include <arpa/nameser.h>
698 ]],[[_res.ns_list[[0]].addr;]])],
699 [ac_cv_have_res_ns_list="yes"],[ac_cv_have_res_ns_list="no"]))
700 AS_IF([test "x$ac_cv_have_res_ns_list" = "xyes"],[
701 AC_DEFINE(_SQUID_RES_NSADDR_LIST,_res.ns_list,[If _res structure has ns_list member])
702 AC_DEFINE(_SQUID_RES_NSADDR_COUNT,_res.nscount,[Nameserver counter for IPv4 _res])
708 dnl checks whether to use the ws2_32 library
709 dnl may set ac_cv_func_select as a side effect
710 AC_DEFUN([SQUID_CHECK_WINSOCK_LIB],[
711 AC_CHECK_HEADERS(winsock2.h)
712 SQUID_STATE_SAVE(winsock)
713 SQUID_SEARCH_LIBS([squid_getprotobynumber],[ws2_32],,,,[
715 #include <winsock2.h>
718 void squid_getprotobynumber(void) {
722 AC_MSG_CHECKING([for winsock library])
723 AS_CASE(["$ac_cv_search_squid_getprotobynumber"],
724 ["no"],[AC_MSG_RESULT([winsock library not found])],
725 ["none required"],[AC_MSG_RESULT([winsock library already in LIBS])],
727 AC_MSG_RESULT([winsock2])
728 XTRA_LIBS="-lws2_32 $XTRA_LIBS"
729 ac_cv_func_select="yes"
732 SQUID_STATE_ROLLBACK(winsock)
735 dnl check that setresuid is properly implemented.
736 dnl sets squid_cv_resuid_works to "yes" or "no"
737 AC_DEFUN([SQUID_CHECK_SETRESUID_WORKS],[
738 AC_CACHE_CHECK(if setresuid is actually implemented, squid_cv_resuid_works,
739 AC_RUN_IFELSE([AC_LANG_SOURCE([[
749 int main(int argc, char **argv) {
750 if(setresuid(-1,-1,-1)) {
751 perror("setresuid:");
756 ]])],[squid_cv_resuid_works="yes"],[squid_cv_resuid_works="no"],[:])
760 dnl check whether Solaris has broken IPFilter headers (Solaris 10 at least does)
761 AC_DEFUN([SQUID_CHECK_BROKEN_SOLARIS_IPFILTER],[
762 AS_IF([test "x$squid_cv_broken_ipfilter_minor_t" = "x"],[
763 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
764 # include <sys/types.h>
765 # include <sys/time.h>
766 # include <sys/ioccom.h>
767 # include <netinet/in.h>
769 # include <netinet/ip_compat.h>
770 # include <netinet/ip_fil.h>
771 # include <netinet/ip_nat.h>
774 squid_cv_broken_ipfilter_minor_t=0
776 ## on fail, test the hack
777 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
778 #define minor_t fubaar
779 # include <sys/types.h>
780 # include <sys/time.h>
781 # include <sys/ioccom.h>
782 # include <netinet/in.h>
784 # include <netinet/ip_compat.h>
785 # include <netinet/ip_fil.h>
786 # include <netinet/ip_nat.h>
789 squid_cv_broken_ipfilter_minor_t=1
791 AC_MSG_ERROR(unable to make IPFilter work with netinet/ headers)
796 AC_DEFINE_UNQUOTED(USE_SOLARIS_IPFILTER_MINOR_T_HACK,$squid_cv_broken_ipfilter_minor_t,
797 [Workaround IPFilter minor_t breakage])
799 ## check for IPFilter headers that require this hack
800 ## (but first netinet/in.h and sys/ioccom.h which they depend on)
808 netinet/ip_compat.h \
809 netinet/ip_fil_compat.h \
813 #if USE_SOLARIS_IPFILTER_MINOR_T_HACK
814 #define minor_t fubar
817 #include <sys/types.h>
820 #include <sys/time.h>
822 #if HAVE_NETINET_IN_H
823 #include <netinet/in.h>
825 #if HAVE_SYS_IOCCOM_H
826 #include <sys/ioccom.h>
828 #if USE_SOLARIS_IPFILTER_MINOR_T_HACK
832 #include <ip_compat.h>
833 #elif HAVE_NETINET_IP_COMPAT_H
834 #include <netinet/ip_compat.h>
838 #elif HAVE_NETINET_IP_FIL_H
839 #include <netinet/ip_fil.h>
841 #if !defined(IPFILTER_VERSION)
842 #define IPFILTER_VERSION 5000004
846 ## Solaris 10+ backported IPv6 NAT to their IPFilter v4.1 instead of using v5
848 struct natlookup.nl_inipaddr.in6,
849 struct natlookup.nl_realipaddr.in6],,,[
850 #if USE_SOLARIS_IPFILTER_MINOR_T_HACK
851 #define minor_t fubar
854 #include <sys/param.h>
857 #include <sys/types.h>
860 #include <sys/time.h>
862 #if HAVE_NETINET_IN_H
863 #include <netinet/in.h>
865 #if HAVE_SYS_IOCCOM_H
866 #include <sys/ioccom.h>
868 #if USE_SOLARIS_IPFILTER_MINOR_T_HACK
872 #include <ip_compat.h>
873 #elif HAVE_NETINET_IP_COMPAT_H
874 #include <netinet/ip_compat.h>
878 #elif HAVE_NETINET_IP_FIL_H
879 #include <netinet/ip_fil.h>
883 #elif HAVE_NETINET_IP_NAT_H
884 #include <netinet/ip_nat.h>