]> git.ipfire.org Git - thirdparty/squid.git/blob - acinclude/os-deps.m4
Windows: Drop obsolete WinSock v1 library (#1384)
[thirdparty/squid.git] / acinclude / os-deps.m4
1 ## Copyright (C) 1996-2023 The Squid Software Foundation and contributors
2 ##
3 ## Squid software is distributed under GPLv2+ license and includes
4 ## contributions from numerous individuals and organizations.
5 ## Please see the COPYING and CONTRIBUTORS files for details.
6 ##
7
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],[
11
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([[
18 #include <stdlib.h>
19 #include <stdio.h>
20 #include <string.h>
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)
24 {
25 int size = 20;
26 char *str = malloc(size);
27 memset(str, 'x', size);
28 strnstr(str, "fubar", size);
29 return 0;
30 }
31 ]])],[squid_cv_func_strnstr="yes"],[squid_cv_func_strnstr="no"],[:])
32 )
33 AS_IF([test "x$squid_cv_func_strnstr" = "xyes"],[AC_DEFINE(HAVE_STRNSTR,1)])
34 ]) dnl SQUID_CHECK_FUNC_STRNSTR
35
36 dnl check that epoll actually works
37 dnl sets squid_cv_epoll_works to "yes" or "no"
38 AC_DEFUN([SQUID_CHECK_EPOLL],[
39
40 AC_CACHE_CHECK(if epoll works, squid_cv_epoll_works,
41 AC_RUN_IFELSE([AC_LANG_SOURCE([[
42 #include <sys/epoll.h>
43 #include <stdlib.h>
44 #include <stdio.h>
45 int main(int argc, char **argv)
46 {
47 int fd = epoll_create(256);
48 if (fd < 0) {
49 perror("epoll_create:");
50 return 1;
51 }
52 return 0;
53 }
54 ]])],[squid_cv_epoll_works=yes],[squid_cv_epoll_works=no],[:]))
55
56 ]) dnl SQUID_CHECK_EPOLL
57
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],[
61
62 AC_CACHE_CHECK(if /dev/poll works, squid_cv_devpoll_works,
63 AC_RUN_IFELSE([AC_LANG_SOURCE([[
64 #include <sys/devpoll.h>
65 #include <fcntl.h>
66 #include <stdlib.h>
67 #include <stdio.h>
68 int main(int argc, char **argv)
69 {
70 int fd = open("/dev/poll", O_RDWR);
71 if (fd < 0) {
72 perror("devpoll_create:");
73 return 1;
74 }
75 return 0;
76 }
77 ]])],[squid_cv_devpoll_works=yes],[squid_cv_devpoll_works=no],[:]))
78
79 ]) dnl SQUID_CHECK_DEVPOLL
80
81
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([[
89 #include <stdlib.h>
90 #include <stddef.h>
91 #include <sys/capability.h>
92 ]], [[
93 capget(NULL, NULL);
94 capset(NULL, NULL);
95 ]])],
96 [squid_cv_sys_capability_works=yes],
97 [squid_cv_sys_capability_works=no])
98 )
99 ])
100
101
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
104
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>
109 #include <stdlib.h>
110 #include <stddef.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])])
116 ])
117
118
119 dnl check the default FD_SETSIZE size.
120 dnl not cached, people are likely to tune this
121 dnl defines DEFAULT_FD_SETSIZE
122
123 AC_DEFUN([SQUID_CHECK_DEFAULT_FD_SETSIZE],[
124 AC_MSG_CHECKING(Default FD_SETSIZE value)
125 AC_RUN_IFELSE([AC_LANG_SOURCE([[
126 #if HAVE_STDIO_H
127 #include <stdio.h>
128 #endif
129 #if HAVE_UNISTD_H
130 #include <unistd.h>
131 #endif
132 #if HAVE_STDLIB_H
133 #include <stdlib.h>
134 #endif
135 #if HAVE_SYS_TIME_H
136 #include <sys/time.h>
137 #endif
138 #if HAVE_SYS_SELECT_H
139 #include <sys/select.h>
140 #endif
141 #if HAVE_SYS_TYPES_H
142 #include <sys/types.h>
143 #endif
144 #if HAVE_WINSOCK2_H
145 #include <winsock2.h>
146 #endif
147 int main(int argc, char **argv) {
148 FILE *fp = fopen("conftestval", "w");
149 fprintf (fp, "%d\n", FD_SETSIZE);
150 return 0;
151 }
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])
155 ])
156
157
158 dnl checks the maximum number of filedescriptor we can open
159 dnl sets shell var squid_filedescriptors_num
160
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([[
168 #include <stdio.h>
169 #include <unistd.h>
170 #include <stdlib.h>
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) {
175 FILE *fp;
176 int i,j;
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.
181 */
182 i = NOFILE;
183 #else
184 #if HAVE_GETRLIMIT && HAVE_SETRLIMIT
185 struct rlimit rl;
186 #if defined(RLIMIT_NOFILE)
187 if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
188 perror("getrlimit: RLIMIT_NOFILE");
189 } else {
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);
193 #else
194 rl.rlim_cur = rl.rlim_max; /* set it to the max */
195 #endif
196 if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
197 perror("setrlimit: RLIMIT_NOFILE");
198 }
199 }
200 #elif defined(RLIMIT_OFILE)
201 if (getrlimit(RLIMIT_OFILE, &rl) < 0) {
202 perror("getrlimit: RLIMIT_OFILE");
203 } else {
204 rl.rlim_cur = rl.rlim_max; /* set it to the max */
205 if (setrlimit(RLIMIT_OFILE, &rl) < 0) {
206 perror("setrlimit: RLIMIT_OFILE");
207 }
208 }
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 */
213 i = j = 1<<14;
214 while (j) {
215 j >>= 1;
216 if (dup2(0, i) < 0) {
217 i -= j;
218 } else {
219 close(i);
220 i += j;
221 }
222 }
223 i++;
224 #endif /* IF !DEF CYGWIN */
225 fp = fopen("conftestval", "w");
226 fprintf (fp, "%d\n", i & ~0x3F);
227 return 0;
228 }
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
236 ],[
237 AC_MSG_NOTICE([Unable to detect filedescriptor limits. Assuming 256 is okay.])
238 squid_filedescriptors_num=256
239 ])
240 ])
241 SQUID_STATE_ROLLBACK(maxfd)
242
243 AC_MSG_NOTICE([Default number of filedescriptors: $squid_filedescriptors_num])
244
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.])
247 ])
248
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])
254 ])
255 AC_DEFINE_UNQUOTED(SQUID_MAXFD,$squid_filedescriptors_num,[Maximum number of open filedescriptors])
256 ])
257
258
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?
262
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"
271 ])
272 ])
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])
275 ])
276
277
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?
281
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"
290 ])
291 ])
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])
294 ])
295
296
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?
300
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"
309 ])
310 ])
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])
312 ])
313
314
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
318
319 AC_DEFUN([SQUID_DETECT_UDP_SND_BUFSIZE],[
320 AC_MSG_CHECKING(Default UDP send buffer size)
321 AC_RUN_IFELSE([AC_LANG_SOURCE([[
322 #include <stdlib.h>
323 #include <stdio.h>
324 #include <sys/types.h>
325 #if HAVE_SYS_SOCKET_H
326 #include <sys/socket.h>
327 #endif
328 #if HAVE_NETINET_IN_H
329 #include <netinet/in.h>
330 #endif
331 #if HAVE_WINSOCK2_H
332 #include <winsock2.h>
333 #endif
334 int main(int argc, char **argv)
335 {
336 FILE *fp;
337 int fd,val=0;
338 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
339 int len=sizeof(int);
340 WSADATA wsaData;
341 WSAStartup(2, &wsaData);
342 #else
343 socklen_t len=sizeof(socklen_t);
344 #endif
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;
348 WSACleanup();
349 #else
350 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1;
351 #endif
352 if (val<=0) return 1;
353 fp = fopen("conftestval", "w");
354 fprintf (fp, "%d\n", val);
355 return 0;
356 }
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])
360 ])
361
362
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
366
367 AC_DEFUN([SQUID_DETECT_UDP_RECV_BUFSIZE],[
368 AC_MSG_CHECKING(Default UDP receive buffer size)
369 AC_RUN_IFELSE([AC_LANG_SOURCE([[
370 #include <stdlib.h>
371 #include <stdio.h>
372 #include <sys/types.h>
373 #if HAVE_SYS_SOCKET_H
374 #include <sys/socket.h>
375 #endif
376 #if HAVE_NETINET_IN_H
377 #include <netinet/in.h>
378 #endif
379 #if HAVE_WINSOCK2_H
380 #include <winsock2.h>
381 #endif
382 int main(int argc, char **argv)
383 {
384 FILE *fp;
385 int fd,val=0;
386 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
387 int len=sizeof(int);
388 WSADATA wsaData;
389 WSAStartup(2, &wsaData);
390 #else
391 socklen_t len=sizeof(socklen_t);
392 #endif
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;
396 WSACleanup();
397 #else
398 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1;
399 #endif
400 if (val <= 0) return 1;
401 fp = fopen("conftestval", "w");
402 fprintf (fp, "%d\n", val);
403 return 0;
404 }
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])
408 ])
409
410
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
414
415 AC_DEFUN([SQUID_DETECT_TCP_SND_BUFSIZE],[
416 AC_MSG_CHECKING(Default TCP send buffer size)
417 AC_RUN_IFELSE([AC_LANG_SOURCE([[
418 #include <stdlib.h>
419 #include <stdio.h>
420 #include <sys/types.h>
421 #if HAVE_SYS_SOCKET_H
422 #include <sys/socket.h>
423 #endif
424 #if HAVE_NETINET_IN_H
425 #include <netinet/in.h>
426 #endif
427 #if HAVE_WINSOCK2_H
428 #include <winsock2.h>
429 #endif
430 int main(int argc, char **argv)
431 {
432 FILE *fp;
433 int fd,val=0;
434 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
435 int len=sizeof(int);
436 WSADATA wsaData;
437 WSAStartup(2, &wsaData);
438 #else
439 socklen_t len=sizeof(socklen_t);
440 #endif
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;
444 WSACleanup();
445 #else
446 if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1;
447 #endif
448 if (val <= 0) return 1;
449 fp = fopen("conftestval", "w");
450 fprintf (fp, "%d\n", val);
451 return 0;
452 }
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
458 ])
459 AC_DEFINE_UNQUOTED(SQUID_TCP_SO_SNDBUF, $SQUID_TCP_SO_SNDBUF,[TCP send buffer size])
460 ])
461
462
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
466
467 AC_DEFUN([SQUID_DETECT_TCP_RECV_BUFSIZE],[
468 AC_MSG_CHECKING(Default TCP receive buffer size)
469 AC_RUN_IFELSE([AC_LANG_SOURCE([[
470 #include <stdlib.h>
471 #include <stdio.h>
472 #include <sys/types.h>
473 #if HAVE_SYS_SOCKET_H
474 #include <sys/socket.h>
475 #endif
476 #if HAVE_NETINET_IN_H
477 #include <netinet/in.h>
478 #endif
479 #if HAVE_WINSOCK2_H
480 #include <winsock2.h>
481 #endif
482 int main(int argc, char **argv)
483 {
484 FILE *fp;
485 int fd,val=0;
486 #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
487 int len=sizeof(int);
488 WSADATA wsaData;
489 WSAStartup(2, &wsaData);
490 #else
491 socklen_t len=sizeof(socklen_t);
492 #endif
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;
496 WSACleanup();
497 #else
498 if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1;
499 #endif
500 if (val <= 0) return 1;
501 fp = fopen("conftestval", "w");
502 fprintf (fp, "%d\n", val);
503 return 0;
504 }
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
510 ])
511 AC_DEFINE_UNQUOTED(SQUID_TCP_SO_RCVBUF, $SQUID_TCP_SO_RCVBUF, [TCP receive buffer size])
512 ])
513
514
515 dnl check if we need to define sys_errlist as external
516 dnl defines NEED_SYS_ERRLIST
517
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"])
521 )
522 SQUID_DEFINE_BOOL(NEED_SYS_ERRLIST,$ac_cv_needs_sys_errlist,[If we need to declare sys_errlist as extern])
523 ])
524
525
526 dnl check if MAXPATHLEN is defined in the system headers
527 dnl or define it ourselves
528
529 AC_DEFUN([SQUID_CHECK_MAXPATHLEN],[
530 AC_MSG_CHECKING(for system-provided MAXPATHLEN)
531 AC_LINK_IFELSE([
532 AC_LANG_PROGRAM([[
533 #include <sys/param.h>]], [[
534 int i = MAXPATHLEN;]])], [
535 AC_MSG_RESULT(yes)], [
536 AC_MSG_RESULT(no)
537 AC_DEFINE(MAXPATHLEN,256,[If MAXPATHLEN has not been defined])])
538 ])
539
540
541 dnl check that we have a working statvfs
542 dnl sets the ac_cv_func_statvfs shell variable and defines HAVE_STATVFS
543
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([[
547 #include <stdlib.h>
548 #include <stdio.h>
549 #include <sys/types.h>
550 #include <sys/statvfs.h>
551 ]], [[
552 struct statvfs sfs;
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])
557 ])
558 SQUID_DEFINE_BOOL(HAVE_STATVFS,$ac_cv_func_statvfs,[set to 1 if our system has statvfs(), and if it actually works])
559 ])
560
561
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>
569 #endif
570 #if HAVE_SYS_STATVFS_H
571 #include <sts/statvfs.h>
572 #endif
573 #if HAVE_SYS_VFS_H
574 #include <sts/vfs.h>
575 #endif
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"
577 ])
578 ])
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)])
580 ])
581
582
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
585
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_])
592 ])
593
594
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
600
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([[
604 #if HAVE_SYS_TYPES_H
605 #include <sys/types.h>
606 #endif
607 #if HAVE_NETINET_IN_H
608 #include <netinet/in.h>
609 #endif
610 #if HAVE_ARPA_INET_H
611 #include <arpa/inet.h>
612 #endif
613 #if HAVE_ARPA_NAMESER_H
614 #include <arpa/nameser.h>
615 #endif
616 #if HAVE_RESOLV_H
617 #include <resolv.h>
618 #endif
619 ]],
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])
626 ])
627
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([[
631 #if HAVE_SYS_TYPES_H
632 #include <sys/types.h>
633 #endif
634 #if HAVE_NETINET_IN_H
635 #include <netinet/in.h>
636 #endif
637 #if HAVE_ARPA_INET_H
638 #include <arpa/inet.h>
639 #endif
640 #if HAVE_ARPA_NAMESER_H
641 #include <arpa/nameser.h>
642 #endif
643 #if HAVE_RESOLV_H
644 #include <resolv.h>
645 #endif
646 ]], i
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])
652 ])
653 ])
654
655 AC_CACHE_CHECK(for _res.nsaddr_list, ac_cv_have_res_nsaddr_list,
656 AC_COMPILE_IFELSE([
657 AC_LANG_PROGRAM([[
658 #if HAVE_SYS_TYPES_H
659 #include <sys/types.h>
660 #endif
661 #if HAVE_NETINET_IN_H
662 #include <netinet/in.h>
663 #endif
664 #if HAVE_ARPA_INET_H
665 #include <arpa/inet.h>
666 #endif
667 #if HAVE_ARPA_NAMESER_H
668 #include <arpa/nameser.h>
669 #endif
670 #if HAVE_RESOLV_H
671 #include <resolv.h>
672 #endif
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])
678 ])
679
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([[
683 #if HAVE_SYS_TYPES_H
684 #include <sys/types.h>
685 #endif
686 #if HAVE_NETINET_IN_H
687 #include <netinet/in.h>
688 #endif
689 #if HAVE_ARPA_INET_H
690 #include <arpa/inet.h>
691 #endif
692 #if HAVE_ARPA_NAMESER_H
693 #include <arpa/nameser.h>
694 #endif
695 #if HAVE_RESOLV_H
696 #include <resolv.h>
697 #endif
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])
703 ])
704 ])
705 ])
706
707
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],,,,[
714 #if HAVE_WINSOCK2_H
715 #include <winsock2.h>
716 #endif
717 /* ugly hack. */
718 void squid_getprotobynumber(void) {
719 getprotobynumber(1);
720 }
721 ])
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])],
726 ["-lws2_32"],[
727 AC_MSG_RESULT([winsock2])
728 XTRA_LIBS="-lws2_32 $XTRA_LIBS"
729 ac_cv_func_select="yes"
730 ]
731 )
732 SQUID_STATE_ROLLBACK(winsock)
733 ])
734
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([[
740 #if HAVE_STDLIB_H
741 #include <stdlib.h>
742 #endif
743 #if HAVE_STDIO_H
744 #include <stdio.h>
745 #endif
746 #if HAVE_UNISTD_H
747 #include <unistd.h>
748 #endif
749 int main(int argc, char **argv) {
750 if(setresuid(-1,-1,-1)) {
751 perror("setresuid:");
752 return 1;
753 }
754 return 0;
755 }
756 ]])],[squid_cv_resuid_works="yes"],[squid_cv_resuid_works="no"],[:])
757 )
758 ])
759
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>
768
769 # include <netinet/ip_compat.h>
770 # include <netinet/ip_fil.h>
771 # include <netinet/ip_nat.h>
772 ]])],[
773 AC_MSG_RESULT(no)
774 squid_cv_broken_ipfilter_minor_t=0
775 ],[
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>
783 #undef minor_t
784 # include <netinet/ip_compat.h>
785 # include <netinet/ip_fil.h>
786 # include <netinet/ip_nat.h>
787 ]])],[
788 AC_MSG_RESULT(yes)
789 squid_cv_broken_ipfilter_minor_t=1
790 ],[
791 AC_MSG_ERROR(unable to make IPFilter work with netinet/ headers)
792 ])
793 ])
794 ])
795
796 AC_DEFINE_UNQUOTED(USE_SOLARIS_IPFILTER_MINOR_T_HACK,$squid_cv_broken_ipfilter_minor_t,
797 [Workaround IPFilter minor_t breakage])
798
799 ## check for IPFilter headers that require this hack
800 ## (but first netinet/in.h and sys/ioccom.h which they depend on)
801 AC_CHECK_HEADERS( \
802 netinet/in.h \
803 sys/ioccom.h \
804 ip_compat.h \
805 ip_fil_compat.h \
806 ip_fil.h \
807 ip_nat.h \
808 netinet/ip_compat.h \
809 netinet/ip_fil_compat.h \
810 netinet/ip_fil.h \
811 netinet/ip_nat.h \
812 ,,,[
813 #if USE_SOLARIS_IPFILTER_MINOR_T_HACK
814 #define minor_t fubar
815 #endif
816 #if HAVE_SYS_TYPES_H
817 #include <sys/types.h>
818 #endif
819 #if HAVE_SYS_TIME_H
820 #include <sys/time.h>
821 #endif
822 #if HAVE_NETINET_IN_H
823 #include <netinet/in.h>
824 #endif
825 #if HAVE_SYS_IOCCOM_H
826 #include <sys/ioccom.h>
827 #endif
828 #if USE_SOLARIS_IPFILTER_MINOR_T_HACK
829 #undef minor_t
830 #endif
831 #if HAVE_IP_COMPAT_H
832 #include <ip_compat.h>
833 #elif HAVE_NETINET_IP_COMPAT_H
834 #include <netinet/ip_compat.h>
835 #endif
836 #if HAVE_IP_FIL_H
837 #include <ip_fil.h>
838 #elif HAVE_NETINET_IP_FIL_H
839 #include <netinet/ip_fil.h>
840 #endif
841 #if !defined(IPFILTER_VERSION)
842 #define IPFILTER_VERSION 5000004
843 #endif
844 ])
845
846 ## Solaris 10+ backported IPv6 NAT to their IPFilter v4.1 instead of using v5
847 AC_CHECK_MEMBERS([
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
852 #endif
853 #if HAVE_SYS_PARAM_H
854 #include <sys/param.h>
855 #endif
856 #if HAVE_SYS_TYPES_H
857 #include <sys/types.h>
858 #endif
859 #if HAVE_SYS_TIME_H
860 #include <sys/time.h>
861 #endif
862 #if HAVE_NETINET_IN_H
863 #include <netinet/in.h>
864 #endif
865 #if HAVE_SYS_IOCCOM_H
866 #include <sys/ioccom.h>
867 #endif
868 #if USE_SOLARIS_IPFILTER_MINOR_T_HACK
869 #undef minor_t
870 #endif
871 #if HAVE_IP_COMPAT_H
872 #include <ip_compat.h>
873 #elif HAVE_NETINET_IP_COMPAT_H
874 #include <netinet/ip_compat.h>
875 #endif
876 #if HAVE_IP_FIL_H
877 #include <ip_fil.h>
878 #elif HAVE_NETINET_IP_FIL_H
879 #include <netinet/ip_fil.h>
880 #endif
881 #if HAVE_IP_NAT_H
882 #include <ip_nat.h>
883 #elif HAVE_NETINET_IP_NAT_H
884 #include <netinet/ip_nat.h>
885 #endif
886 ])
887
888 ])