]>
Commit | Line | Data |
---|---|---|
4ac4a490 | 1 | ## Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
5d2e6f19 AJ |
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 | ## | |
0abb39dd FC |
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 | } | |
aff0e8fe | 31 | ]])],[squid_cv_func_strnstr="yes"],[squid_cv_func_strnstr="no"],[:]) |
0abb39dd FC |
32 | ) |
33 | if test "$squid_cv_func_strnstr" = "yes" ; then | |
34 | AC_DEFINE(HAVE_STRNSTR,1) | |
35 | fi | |
36 | ||
37 | ]) dnl SQUID_CHECK_FUNC_STRNSTR | |
38 | ||
39 | dnl check that va_copy is implemented and works | |
40 | dnl sets squid_cv_func_va_copy and defines HAVE_VA_COPY | |
41 | AC_DEFUN([SQUID_CHECK_FUNC_VACOPY],[ | |
42 | ||
43 | # check that the system provides a functional va_copy call | |
44 | ||
45 | AH_TEMPLATE(HAVE_VA_COPY, [The system implements a functional va_copy() ]) | |
46 | AC_CACHE_CHECK(if va_copy is implemented, squid_cv_func_va_copy, | |
47 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
48 | #include <stdarg.h> | |
49 | #include <stdlib.h> | |
50 | int f (int i, ...) { | |
51 | va_list args1, args2; | |
52 | va_start (args1, i); | |
53 | va_copy (args2, args1); | |
54 | if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) | |
55 | return 1; | |
56 | va_end (args1); va_end (args2); | |
57 | return 0; | |
58 | } | |
59 | int main(int argc, char **argv) { return f (0, 42); } | |
aff0e8fe | 60 | ]])],[squid_cv_func_va_copy="yes"],[squid_cv_func_va_copy="no"],[:]) |
0abb39dd FC |
61 | ) |
62 | if test "$squid_cv_func_va_copy" = "yes" ; then | |
63 | AC_DEFINE(HAVE_VA_COPY, 1) | |
64 | fi | |
65 | ||
66 | ]) dnl SQUID_CHECK_FUNC_VACOPY | |
67 | ||
68 | dnl same sa SQUID_CHECK_FUNC_VACOPY, but checks __va_copy | |
69 | dnl sets squid_cv_func___va_copy, and defines HAVE___VA_COPY | |
70 | AC_DEFUN([SQUID_CHECK_FUNC___VACOPY],[ | |
71 | ||
72 | AH_TEMPLATE(HAVE___VA_COPY,[Some systems have __va_copy instead of va_copy]) | |
73 | AC_CACHE_CHECK(if __va_copy is implemented, squid_cv_func___va_copy, | |
74 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
75 | #include <stdarg.h> | |
76 | #include <stdlib.h> | |
77 | int f (int i, ...) { | |
78 | va_list args1, args2; | |
79 | va_start (args1, i); | |
80 | __va_copy (args2, args1); | |
81 | if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) | |
82 | return 1; | |
83 | va_end (args1); va_end (args2); | |
84 | return 0; | |
85 | } | |
86 | int main(int argc, char **argv) { return f (0, 42); } | |
aff0e8fe | 87 | ]])],[squid_cv_func___va_copy="yes"],[squid_cv_func___va_copy="no"],[:]) |
0abb39dd FC |
88 | ) |
89 | if test "$squid_cv_func___va_copy" = "yes" ; then | |
90 | AC_DEFINE(HAVE___VA_COPY, 1) | |
91 | fi | |
92 | ]) dnl SQUID_CHECK_FUNC___VACOPY | |
20ad76ab FC |
93 | |
94 | ||
af1e01a8 FC |
95 | dnl check that epoll actually works |
96 | dnl sets squid_cv_epoll_works to "yes" or "no" | |
97 | AC_DEFUN([SQUID_CHECK_EPOLL],[ | |
98 | ||
99 | AC_CACHE_CHECK(if epoll works, squid_cv_epoll_works, | |
100 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
101 | #include <sys/epoll.h> | |
102 | #include <stdlib.h> | |
103 | #include <stdio.h> | |
104 | int main(int argc, char **argv) | |
105 | { | |
106 | int fd = epoll_create(256); | |
107 | if (fd < 0) { | |
108 | perror("epoll_create:"); | |
109 | return 1; | |
110 | } | |
111 | return 0; | |
112 | } | |
aff0e8fe | 113 | ]])],[squid_cv_epoll_works=yes],[squid_cv_epoll_works=no],[:])) |
af1e01a8 FC |
114 | |
115 | ]) dnl SQUID_CHECK_EPOLL | |
45c41a07 | 116 | |
a1ad2f9b AJ |
117 | dnl check that /dev/poll actually works |
118 | dnl sets squid_cv_devpoll_works to "yes" or "no" | |
119 | AC_DEFUN([SQUID_CHECK_DEVPOLL],[ | |
120 | ||
121 | AC_CACHE_CHECK(if /dev/poll works, squid_cv_devpoll_works, | |
122 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
123 | #include <sys/devpoll.h> | |
124 | #include <fcntl.h> | |
125 | #include <stdlib.h> | |
126 | #include <stdio.h> | |
127 | int main(int argc, char **argv) | |
128 | { | |
129 | int fd = open("/dev/poll", O_RDWR); | |
130 | if (fd < 0) { | |
131 | perror("devpoll_create:"); | |
132 | return 1; | |
133 | } | |
134 | return 0; | |
135 | } | |
136 | ]])],[squid_cv_devpoll_works=yes],[squid_cv_devpoll_works=no],[:])) | |
137 | ||
138 | ]) dnl SQUID_CHECK_DEVPOLL | |
139 | ||
ef7ece58 | 140 | |
45c41a07 FC |
141 | dnl check that we have functional libcap2 headers |
142 | dnl sets squid_cv_sys_capability_works to "yes" or "no" | |
ef7ece58 | 143 | |
45c41a07 FC |
144 | AC_DEFUN([SQUID_CHECK_FUNCTIONAL_LIBCAP2],[ |
145 | AC_CACHE_CHECK([for operational libcap2 headers], | |
146 | squid_cv_sys_capability_works, | |
147 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | |
148 | #include <stdlib.h> | |
149 | #include <stddef.h> | |
150 | #include <sys/capability.h> | |
151 | ]], [[ | |
152 | capget(NULL, NULL); | |
153 | capset(NULL, NULL); | |
154 | ]])], | |
155 | [squid_cv_sys_capability_works=yes], | |
156 | [squid_cv_sys_capability_works=no]) | |
157 | ) | |
158 | ]) | |
159 | ||
46f50de9 | 160 | |
5d2e6f19 | 161 | dnl From Samba. Thanks! |
46f50de9 | 162 | dnl check that we have Unix sockets. Sets squid_cv_unixsocket to either yes or no depending on the check |
ef7ece58 | 163 | |
46f50de9 FC |
164 | AC_DEFUN([SQUID_CHECK_UNIX_SOCKET],[ |
165 | AC_CACHE_CHECK([for unix domain sockets],squid_cv_unixsocket, [ | |
166 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
167 | #include <sys/types.h> | |
168 | #include <stdlib.h> | |
169 | #include <stddef.h> | |
170 | #include <sys/socket.h> | |
171 | #include <sys/un.h>]], [[ | |
172 | struct sockaddr_un sunaddr; | |
173 | sunaddr.sun_family = AF_UNIX; | |
174 | ]])],[squid_cv_unixsocket=yes],[squid_cv_unixsocket=no])]) | |
175 | ]) | |
ef7ece58 FC |
176 | |
177 | ||
1ca3e305 FC |
178 | dnl check the default FD_SETSIZE size. |
179 | dnl not cached, people are likely to tune this | |
180 | dnl defines DEFAULT_FD_SETSIZE | |
181 | ||
182 | AC_DEFUN([SQUID_CHECK_DEFAULT_FD_SETSIZE],[ | |
183 | AC_MSG_CHECKING(Default FD_SETSIZE value) | |
184 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
185 | #if HAVE_STDIO_H | |
186 | #include <stdio.h> | |
187 | #endif | |
188 | #if HAVE_UNISTD_H | |
189 | #include <unistd.h> | |
190 | #endif | |
191 | #if HAVE_STDLIB_H | |
192 | #include <stdlib.h> | |
193 | #endif | |
194 | #if HAVE_SYS_TIME_H | |
195 | #include <sys/time.h> | |
196 | #endif | |
197 | #if HAVE_SYS_SELECT_H | |
198 | #include <sys/select.h> | |
199 | #endif | |
200 | #if HAVE_SYS_TYPES_H | |
201 | #include <sys/types.h> | |
202 | #endif | |
1ca3e305 FC |
203 | #if HAVE_WINSOCK2_H |
204 | #include <winsock2.h> | |
15d36271 FC |
205 | #elif HAVE_WINSOCK_H |
206 | #include <winsock.h> | |
1ca3e305 FC |
207 | #endif |
208 | int main(int argc, char **argv) { | |
209 | FILE *fp = fopen("conftestval", "w"); | |
210 | fprintf (fp, "%d\n", FD_SETSIZE); | |
211 | return 0; | |
212 | } | |
213 | ]])],[DEFAULT_FD_SETSIZE=`cat conftestval`],[DEFAULT_FD_SETSIZE=256],[DEFAULT_FD_SETSIZE=256]) | |
214 | AC_MSG_RESULT($DEFAULT_FD_SETSIZE) | |
215 | AC_DEFINE_UNQUOTED(DEFAULT_FD_SETSIZE, $DEFAULT_FD_SETSIZE, [Default FD_SETSIZE value]) | |
216 | ]) | |
f467f578 FC |
217 | |
218 | ||
219 | dnl checks the maximum number of filedescriptor we can open | |
220 | dnl sets shell var squid_filedescriptors_num | |
221 | ||
222 | AC_DEFUN([SQUID_CHECK_MAXFD],[ | |
0292eeb7 | 223 | AC_CHECK_FUNCS(setrlimit) |
f467f578 FC |
224 | AC_MSG_CHECKING(Maximum number of filedescriptors we can open) |
225 | dnl damn! FreeBSD pthreads break dup2(). | |
226 | SQUID_STATE_SAVE(maxfd) | |
227 | case $host in | |
228 | i386-unknown-freebsd*) | |
229 | if echo "$LDFLAGS" | grep -q pthread; then | |
230 | LDFLAGS=`echo $LDFLAGS | sed -e "s/-pthread//"` | |
231 | fi | |
232 | esac | |
233 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
234 | #include <stdio.h> | |
235 | #include <unistd.h> | |
236 | #include <stdlib.h> | |
237 | #include <sys/time.h> /* needed on FreeBSD */ | |
238 | #include <sys/param.h> | |
239 | #include <sys/resource.h> | |
240 | int main(int argc, char **argv) { | |
241 | FILE *fp; | |
242 | int i,j; | |
243 | #if defined(__CYGWIN32__) || defined (__CYGWIN__) | |
244 | /* getrlimit and sysconf returns bogous values on cygwin32. | |
245 | * Number of fds is virtually unlimited in cygwin (sys/param.h) | |
246 | * __CYGWIN32__ is deprecated. | |
247 | */ | |
248 | i = NOFILE; | |
249 | #else | |
250 | #if HAVE_SETRLIMIT | |
251 | struct rlimit rl; | |
252 | #if defined(RLIMIT_NOFILE) | |
253 | if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { | |
254 | perror("getrlimit: RLIMIT_NOFILE"); | |
255 | } else { | |
256 | #if defined(__APPLE__) | |
257 | /* asking for more than OPEN_MAX fails on Leopard */ | |
258 | rl.rlim_cur = (OPEN_MAX < rl.rlim_max ? OPEN_MAX : rl.rlim_max); | |
259 | #else | |
260 | rl.rlim_cur = rl.rlim_max; /* set it to the max */ | |
261 | #endif | |
262 | if (setrlimit(RLIMIT_NOFILE, &rl) < 0) { | |
263 | perror("setrlimit: RLIMIT_NOFILE"); | |
264 | } | |
265 | } | |
266 | #elif defined(RLIMIT_OFILE) | |
267 | if (getrlimit(RLIMIT_OFILE, &rl) < 0) { | |
268 | perror("getrlimit: RLIMIT_OFILE"); | |
269 | } else { | |
270 | rl.rlim_cur = rl.rlim_max; /* set it to the max */ | |
271 | if (setrlimit(RLIMIT_OFILE, &rl) < 0) { | |
272 | perror("setrlimit: RLIMIT_OFILE"); | |
273 | } | |
274 | } | |
275 | #endif /* RLIMIT_NOFILE */ | |
276 | #endif /* HAVE_SETRLIMIT */ | |
277 | /* by starting at 2^14, we will never get higher | |
278 | than 2^15 for squid_filedescriptors_num */ | |
279 | i = j = 1<<14; | |
280 | while (j) { | |
281 | j >>= 1; | |
282 | if (dup2(0, i) < 0) { | |
283 | i -= j; | |
284 | } else { | |
285 | close(i); | |
286 | i += j; | |
287 | } | |
288 | } | |
289 | i++; | |
290 | #endif /* IF !DEF CYGWIN */ | |
291 | fp = fopen("conftestval", "w"); | |
292 | fprintf (fp, "%d\n", i & ~0x3F); | |
293 | return 0; | |
294 | } | |
295 | ]])],[squid_filedescriptors_num=`cat conftestval`],[squid_filedescriptors_num=256],[squid_filedescriptors_num=256]) | |
296 | dnl Microsoft MSVCRT.DLL supports 2048 maximum FDs | |
297 | case "$host_os" in | |
298 | mingw|mingw32) | |
299 | squid_filedescriptors_num="2048" | |
300 | ;; | |
301 | esac | |
302 | AC_MSG_RESULT($squid_filedescriptors_num) | |
303 | SQUID_STATE_ROLLBACK(maxfd) | |
304 | ||
305 | if test `expr $squid_filedescriptors_num % 64` != 0; then | |
306 | AC_MSG_WARN([$squid_filedescriptors_num is not an multiple of 64. This may cause issues on certain platforms.]) | |
307 | fi | |
308 | ]) | |
af494bc8 FC |
309 | |
310 | ||
311 | dnl Check whether this OS defines sin6_len as a member of sockaddr_in6 as a backup to ss_len | |
312 | dnl defines HAVE_SIN6_LEN_IN_SAI | |
313 | dnl TODO: move to AC_CHECK_MEMBER? | |
314 | ||
315 | AC_DEFUN([SQUID_CHECK_SIN6_LEN_IN_SAI],[ | |
316 | AC_CACHE_CHECK([for sin6_len field in struct sockaddr_in6], | |
317 | ac_cv_have_sin6_len_in_struct_sai, [ | |
318 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
319 | #include <sys/types.h> | |
320 | #include <sys/socket.h> | |
321 | #include <netinet/in.h> | |
322 | ]], [[ struct sockaddr_in6 s; s.sin6_len = 1; ]])],[ ac_cv_have_sin6_len_in_struct_sai="yes" ],[ ac_cv_have_sin6_len_in_struct_sai="no" | |
323 | ]) | |
324 | ]) | |
325 | SQUID_DEFINE_BOOL(HAVE_SIN6_LEN_IN_SAI,$ac_cv_have_sin6_len_in_struct_sai, | |
326 | [Defined if struct sockaddr_in6 has sin6_len]) | |
327 | ]) | |
328 | ||
329 | ||
330 | dnl Check whether this OS defines ss_len as a member of sockaddr_storage | |
331 | dnl defines HAVE_SS_LEN_IN_SS | |
332 | dnl TODO: move to AC_CHECK_MEMBER? | |
333 | ||
334 | AC_DEFUN([SQUID_CHECK_SS_LEN_IN_SOCKADDR_STORAGE],[ | |
335 | AC_CACHE_CHECK([for ss_len field in struct sockaddr_storage], | |
336 | ac_cv_have_ss_len_in_struct_ss, [ | |
337 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
338 | #include <sys/types.h> | |
339 | #include <sys/socket.h> | |
340 | #include <netinet/in.h> | |
341 | ]], [[ struct sockaddr_storage s; s.ss_len = 1; ]])],[ ac_cv_have_ss_len_in_struct_ss="yes" ],[ ac_cv_have_ss_len_in_struct_ss="no" | |
342 | ]) | |
343 | ]) | |
344 | SQUID_DEFINE_BOOL(HAVE_SS_LEN_IN_SS,$ac_cv_have_ss_len_in_struct_ss, | |
345 | [Define if sockaddr_storage has field ss_len]) | |
346 | ]) | |
347 | ||
348 | ||
349 | dnl Check whether this OS defines sin_len as a member of sockaddr_in as a backup to ss_len | |
350 | dnl defines HAVE_SIN_LEN_IN_SAI | |
351 | dnl TODO: move to AC_CHECK_MEMBER? | |
352 | ||
353 | AC_DEFUN([SQUID_CHECK_SIN_LEN_IN_SOCKADDR_IN],[ | |
354 | AC_CACHE_CHECK([for sin_len field in struct sockaddr_in], | |
355 | ac_cv_have_sin_len_in_struct_sai, [ | |
356 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
357 | #include <sys/types.h> | |
358 | #include <sys/socket.h> | |
359 | #include <netinet/in.h> | |
360 | ]], [[ struct sockaddr_in s; s.sin_len = 1; ]])],[ ac_cv_have_sin_len_in_struct_sai="yes" ],[ ac_cv_have_sin_len_in_struct_sai="no" | |
361 | ]) | |
362 | ]) | |
363 | SQUID_DEFINE_BOOL(HAVE_SIN_LEN_IN_SAI,$ac_cv_have_sin_len_in_struct_sai,[Define if sockaddr_in has field sin_len]) | |
364 | ]) | |
8e0acaf5 FC |
365 | |
366 | ||
367 | dnl detects default UDP buffer size | |
368 | dnl not cached since people are likely to tune this | |
369 | dnl defines SQUID_DETECT_UDP_SO_SNDBUF | |
370 | ||
371 | AC_DEFUN([SQUID_DETECT_UDP_SND_BUFSIZE],[ | |
372 | AC_MSG_CHECKING(Default UDP send buffer size) | |
373 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
374 | #include <stdlib.h> | |
375 | #include <stdio.h> | |
376 | #include <sys/types.h> | |
377 | #if HAVE_SYS_SOCKET_H | |
378 | #include <sys/socket.h> | |
379 | #endif | |
380 | #if HAVE_NETINET_IN_H | |
381 | #include <netinet/in.h> | |
382 | #endif | |
8e0acaf5 FC |
383 | #if HAVE_WINSOCK2_H |
384 | #include <winsock2.h> | |
15d36271 FC |
385 | #elif HAVE_WINSOCK_H |
386 | #include <winsock.h> | |
8e0acaf5 FC |
387 | #endif |
388 | int main(int argc, char **argv) | |
389 | { | |
390 | FILE *fp; | |
391 | int fd,val=0; | |
392 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
393 | int len=sizeof(int); | |
394 | WSADATA wsaData; | |
395 | WSAStartup(2, &wsaData); | |
396 | #else | |
397 | socklen_t len=sizeof(socklen_t); | |
398 | #endif | |
399 | if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1; | |
400 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
401 | if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&val, &len) < 0) return 1; | |
402 | WSACleanup(); | |
403 | #else | |
404 | if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1; | |
405 | #endif | |
406 | if (val<=0) return 1; | |
407 | fp = fopen("conftestval", "w"); | |
408 | fprintf (fp, "%d\n", val); | |
409 | return 0; | |
410 | } | |
411 | ]])],[SQUID_DETECT_UDP_SO_SNDBUF=`cat conftestval`],[SQUID_DETECT_UDP_SO_SNDBUF=16384],[SQUID_DETECT_UDP_SO_SNDBUF=16384]) | |
412 | AC_MSG_RESULT($SQUID_DETECT_UDP_SO_SNDBUF) | |
413 | AC_DEFINE_UNQUOTED(SQUID_DETECT_UDP_SO_SNDBUF, $SQUID_DETECT_UDP_SO_SNDBUF,[UDP send buffer size]) | |
414 | ]) | |
415 | ||
416 | ||
417 | dnl detects default UDP buffer size | |
418 | dnl not cached since people are likely to tune this | |
419 | dnl defines SQUID_DETECT_UDP_SO_RCVBUF | |
420 | ||
421 | AC_DEFUN([SQUID_DETECT_UDP_RECV_BUFSIZE],[ | |
422 | AC_MSG_CHECKING(Default UDP receive buffer size) | |
423 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
424 | #include <stdlib.h> | |
425 | #include <stdio.h> | |
426 | #include <sys/types.h> | |
427 | #if HAVE_SYS_SOCKET_H | |
428 | #include <sys/socket.h> | |
429 | #endif | |
430 | #if HAVE_NETINET_IN_H | |
431 | #include <netinet/in.h> | |
432 | #endif | |
8e0acaf5 FC |
433 | #if HAVE_WINSOCK2_H |
434 | #include <winsock2.h> | |
15d36271 FC |
435 | #elif HAVE_WINSOCK_H |
436 | #include <winsock.h> | |
8e0acaf5 FC |
437 | #endif |
438 | int main(int argc, char **argv) | |
439 | { | |
440 | FILE *fp; | |
441 | int fd,val=0; | |
442 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
443 | int len=sizeof(int); | |
444 | WSADATA wsaData; | |
445 | WSAStartup(2, &wsaData); | |
446 | #else | |
447 | socklen_t len=sizeof(socklen_t); | |
448 | #endif | |
449 | if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1; | |
450 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
451 | if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) return 1; | |
452 | WSACleanup(); | |
453 | #else | |
454 | if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1; | |
455 | #endif | |
456 | if (val <= 0) return 1; | |
457 | fp = fopen("conftestval", "w"); | |
458 | fprintf (fp, "%d\n", val); | |
459 | return 0; | |
460 | } | |
461 | ]])],[SQUID_DETECT_UDP_SO_RCVBUF=`cat conftestval`],[SQUID_DETECT_UDP_SO_RCVBUF=16384],[SQUID_DETECT_UDP_SO_RCVBUF=16384]) | |
462 | AC_MSG_RESULT($SQUID_DETECT_UDP_SO_RCVBUF) | |
463 | AC_DEFINE_UNQUOTED(SQUID_DETECT_UDP_SO_RCVBUF, $SQUID_DETECT_UDP_SO_RCVBUF,[UDP receive buffer size]) | |
464 | ]) | |
465 | ||
466 | ||
467 | dnl detects default TCP buffer size | |
468 | dnl not cached since people are likely to tune this | |
469 | dnl defines SQUID_TCP_SO_SNDBUF | |
470 | ||
471 | AC_DEFUN([SQUID_DETECT_TCP_SND_BUFSIZE],[ | |
472 | AC_MSG_CHECKING(Default TCP send buffer size) | |
473 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
474 | #include <stdlib.h> | |
475 | #include <stdio.h> | |
476 | #include <sys/types.h> | |
477 | #if HAVE_SYS_SOCKET_H | |
478 | #include <sys/socket.h> | |
479 | #endif | |
480 | #if HAVE_NETINET_IN_H | |
481 | #include <netinet/in.h> | |
482 | #endif | |
8e0acaf5 FC |
483 | #if HAVE_WINSOCK2_H |
484 | #include <winsock2.h> | |
15d36271 FC |
485 | #elif HAVE_WINSOCK_H |
486 | #include <winsock.h> | |
8e0acaf5 FC |
487 | #endif |
488 | int main(int argc, char **argv) | |
489 | { | |
490 | FILE *fp; | |
491 | int fd,val=0; | |
492 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
493 | int len=sizeof(int); | |
494 | WSADATA wsaData; | |
495 | WSAStartup(2, &wsaData); | |
496 | #else | |
497 | socklen_t len=sizeof(socklen_t); | |
498 | #endif | |
499 | if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return 1; | |
500 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
501 | if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&val, &len) < 0) return 1; | |
502 | WSACleanup(); | |
503 | #else | |
504 | if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1; | |
505 | #endif | |
506 | if (val <= 0) return 1; | |
507 | fp = fopen("conftestval", "w"); | |
508 | fprintf (fp, "%d\n", val); | |
509 | return 0; | |
510 | } | |
511 | ]])],[SQUID_TCP_SO_SNDBUF=`cat conftestval`],[SQUID_TCP_SO_SNDBUF=16384],[SQUID_TCP_SO_SNDBUF=16384]) | |
512 | AC_MSG_RESULT($SQUID_TCP_SO_SNDBUF) | |
513 | if test $SQUID_TCP_SO_SNDBUF -gt 32768; then | |
514 | AC_MSG_NOTICE([Limiting send buffer size to 32K]) | |
515 | SQUID_TCP_SO_SNDBUF=32768 | |
516 | fi | |
517 | AC_DEFINE_UNQUOTED(SQUID_TCP_SO_SNDBUF, $SQUID_TCP_SO_SNDBUF,[TCP send buffer size]) | |
518 | ]) | |
519 | ||
520 | ||
521 | dnl detects default TCP buffer size | |
522 | dnl not cached since people are likely to tune this | |
523 | dnl defines SQUID_TCP_SO_RECVBUF | |
524 | ||
525 | AC_DEFUN([SQUID_DETECT_TCP_RECV_BUFSIZE],[ | |
526 | AC_MSG_CHECKING(Default TCP receive buffer size) | |
527 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
528 | #include <stdlib.h> | |
529 | #include <stdio.h> | |
530 | #include <sys/types.h> | |
531 | #if HAVE_SYS_SOCKET_H | |
532 | #include <sys/socket.h> | |
533 | #endif | |
534 | #if HAVE_NETINET_IN_H | |
535 | #include <netinet/in.h> | |
536 | #endif | |
8e0acaf5 FC |
537 | #if HAVE_WINSOCK2_H |
538 | #include <winsock2.h> | |
15d36271 FC |
539 | #elif HAVE_WINSOCK_H |
540 | #include <winsock.h> | |
8e0acaf5 FC |
541 | #endif |
542 | int main(int argc, char **argv) | |
543 | { | |
544 | FILE *fp; | |
545 | int fd,val=0; | |
546 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
547 | int len=sizeof(int); | |
548 | WSADATA wsaData; | |
549 | WSAStartup(2, &wsaData); | |
550 | #else | |
551 | socklen_t len=sizeof(socklen_t); | |
552 | #endif | |
553 | if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return 1; | |
554 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
555 | if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) return 1; | |
556 | WSACleanup(); | |
557 | #else | |
558 | if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1; | |
559 | #endif | |
560 | if (val <= 0) return 1; | |
561 | fp = fopen("conftestval", "w"); | |
562 | fprintf (fp, "%d\n", val); | |
563 | return 0; | |
564 | } | |
565 | ]])],[SQUID_TCP_SO_RCVBUF=`cat conftestval`],[SQUID_TCP_SO_RCVBUF=16384],[SQUID_TCP_SO_RCVBUF=16384]) | |
566 | AC_MSG_RESULT($SQUID_TCP_SO_RCVBUF) | |
567 | if test $SQUID_TCP_SO_RCVBUF -gt 65535; then | |
568 | AC_MSG_NOTICE([Limiting receive buffer size to 64K]) | |
569 | SQUID_TCP_SO_RCVBUF=65535 | |
570 | fi | |
571 | AC_DEFINE_UNQUOTED(SQUID_TCP_SO_RCVBUF, $SQUID_TCP_SO_RCVBUF,[TCP receive buffer size]) | |
572 | ]) | |
5c3c56fa FC |
573 | |
574 | ||
575 | dnl check if we need to define sys_errlist as external | |
576 | dnl defines NEED_SYS_ERRLIST | |
577 | ||
578 | AC_DEFUN([SQUID_CHECK_NEED_SYS_ERRLIST],[ | |
579 | AC_CACHE_CHECK(if sys_errlist is already defined, ac_cv_needs_sys_errlist, | |
580 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[char *s = sys_errlist;]])],[ac_cv_needs_sys_errlist="no"],[ac_cv_needs_sys_errlist="yes"]) | |
581 | ) | |
582 | SQUID_DEFINE_BOOL(NEED_SYS_ERRLIST,$ac_cv_needs_sys_errlist,[If we need to declare sys_errlist as extern]) | |
583 | ]) | |
584 | ||
585 | ||
586 | dnl check if MAXPATHLEN is defined in the system headers | |
587 | dnl or define it ourselves | |
588 | ||
589 | AC_DEFUN([SQUID_CHECK_MAXPATHLEN],[ | |
bb214e97 | 590 | AC_MSG_CHECKING(for system-provided MAXPATHLEN) |
5c3c56fa FC |
591 | AC_LINK_IFELSE([ |
592 | AC_LANG_PROGRAM([[ | |
593 | #include <sys/param.h>]], [[ | |
594 | int i = MAXPATHLEN;]])], [ | |
595 | AC_MSG_RESULT(yes)], [ | |
596 | AC_MSG_RESULT(no) | |
597 | AC_DEFINE(MAXPATHLEN,256,[If MAXPATHLEN has not been defined])]) | |
598 | ]) | |
599 | ||
4e28d61e FC |
600 | |
601 | dnl check that we have a working statvfs | |
602 | dnl sets the ac_cv_func_statvfs shell variable and defines HAVE_STATVFS | |
603 | ||
bb214e97 FC |
604 | AC_DEFUN([SQUID_CHECK_WORKING_STATVFS],[ |
605 | AC_CACHE_CHECK(for working statvfs() interface,ac_cv_func_statvfs,[ | |
606 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
607 | #include <stdlib.h> | |
608 | #include <stdio.h> | |
609 | #include <sys/types.h> | |
610 | #include <sys/statvfs.h> | |
611 | ]], [[ | |
612 | struct statvfs sfs; | |
613 | sfs.f_blocks = sfs.f_bfree = sfs.f_frsize = | |
614 | sfs.f_files = sfs.f_ffree = 0; | |
615 | statvfs("/tmp", &sfs); | |
616 | ]])],[ac_cv_func_statvfs=yes],[ac_cv_func_statvfs=no]) | |
617 | ]) | |
618 | SQUID_DEFINE_BOOL(HAVE_STATVFS,$ac_cv_func_statvfs,[set to 1 if our system has statvfs(), and if it actually works]) | |
619 | ]) | |
4e28d61e | 620 | |
819656da | 621 | |
615540cd AJ |
622 | dnl Check whether this OS defines f_frsize as a member of struct statfs |
623 | AC_DEFUN([SQUID_CHECK_F_FRSIZE_IN_STATFS],[ | |
624 | AC_CACHE_CHECK([for f_frsize field in struct statfs], | |
625 | ac_cv_have_f_frsize_in_struct_statfs, [ | |
626 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
627 | #if HAVE_SYS_STATFS_H | |
628 | #include <sts/statfs.h> | |
629 | #endif | |
630 | #if HAVE_SYS_STATVFS_H | |
631 | #include <sts/statvfs.h> | |
632 | #endif | |
633 | #if HAVE_SYS_VFS_H | |
634 | #include <sts/vfs.h> | |
635 | #endif | |
636 | ]], [[ struct statfs s; s.f_frsize = 0; ]])],[ ac_cv_have_f_frsize_in_struct_statfs="yes" ],[ ac_cv_have_f_frsize_in_struct_statfs="no" | |
637 | ]) | |
638 | ]) | |
639 | SQUID_DEFINE_BOOL(HAVE_F_FRSIZE_IN_STATFS,$ac_cv_have_f_frsize_in_struct_statfs,[Define if struct statfs has field f_frsize (Linux 2.6 or later)]) | |
640 | ]) | |
641 | ||
642 | ||
819656da AJ |
643 | dnl check that we can use the libresolv _dns_ttl_ hack |
644 | dnl sets the ac_cv_libresolv_dns_ttl_hack shell variable and defines LIBRESOLV_DNS_TTL_HACK | |
645 | ||
646 | AC_DEFUN([SQUID_CHECK_LIBRESOLV_DNS_TTL_HACK],[ | |
647 | AC_CACHE_CHECK(for libresolv _dns_ttl_ hack, ac_cv_libresolv_dns_ttl_hack, [ | |
648 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int _dns_ttl_;]], [[return _dns_ttl_;]])], | |
649 | [ac_cv_libresolv_dns_ttl_hack=yes],[ac_cv_libresolv_dns_ttl_hack=no]) ]) | |
650 | SQUID_DEFINE_BOOL(LIBRESOLV_DNS_TTL_HACK,$ac_cv_libresolv_dns_ttl_hack, | |
651 | [libresolv.a has been hacked to export _dns_ttl_]) | |
652 | ]) | |
653 | ||
654 | ||
655 | dnl checks for availability of some resolver fields | |
656 | dnl sets ac_cv_have_res_ext_nsaddr_list shell variable | |
657 | dnl defines _SQUID_RES_NSADDR6_COUNT _SQUID_RES_NSADDR6_LARRAY | |
658 | dnl defines _SQUID_RES_NSADDR6_LPTR _SQUID_RES_NSADDR6_COUNT | |
659 | dnl defines _SQUID_RES_NSADDR_LIST _SQUID_RES_NSADDR_COUNT | |
660 | ||
661 | AC_DEFUN([SQUID_CHECK_RESOLVER_FIELDS],[ | |
662 | AC_CACHE_CHECK(for _res_ext.nsaddr_list, ac_cv_have_res_ext_nsaddr_list, | |
663 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
664 | #if HAVE_SYS_TYPES_H | |
665 | #include <sys/types.h> | |
666 | #endif | |
667 | #if HAVE_NETINET_IN_H | |
668 | #include <netinet/in.h> | |
669 | #endif | |
670 | #if HAVE_ARPA_INET_H | |
671 | #include <arpa/inet.h> | |
672 | #endif | |
673 | #if HAVE_ARPA_NAMESER_H | |
674 | #include <arpa/nameser.h> | |
675 | #endif | |
676 | #if HAVE_RESOLV_H | |
677 | #include <resolv.h> | |
678 | #endif | |
679 | ]], | |
680 | [[_res_ext.nsaddr_list[[0]].s_addr;]])],[ | |
681 | ac_cv_have_res_ext_nsaddr_list="yes" ],[ | |
682 | ac_cv_have_res_ext_nsaddr_list="no"])) | |
683 | if test "$ac_cv_have_res_ext_nsaddr_list" = "yes" ; then | |
684 | AC_DEFINE(_SQUID_RES_NSADDR6_LARRAY,_res_ext.nsaddr_list,[If _res_ext structure has nsaddr_list member]) | |
685 | AC_DEFINE(_SQUID_RES_NSADDR6_COUNT,ns6count,[Nameserver Counter for IPv6 _res_ext]) | |
686 | fi | |
687 | ||
688 | if test "$_SQUID_RES_NSADDR6_LIST" = ""; then | |
689 | AC_CACHE_CHECK(for _res._u._ext.nsaddrs, ac_cv_have_res_ext_nsaddrs, | |
690 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
691 | #if HAVE_SYS_TYPES_H | |
692 | #include <sys/types.h> | |
693 | #endif | |
694 | #if HAVE_NETINET_IN_H | |
695 | #include <netinet/in.h> | |
696 | #endif | |
697 | #if HAVE_ARPA_INET_H | |
698 | #include <arpa/inet.h> | |
699 | #endif | |
700 | #if HAVE_ARPA_NAMESER_H | |
701 | #include <arpa/nameser.h> | |
702 | #endif | |
703 | #if HAVE_RESOLV_H | |
704 | #include <resolv.h> | |
705 | #endif | |
706 | ]], i | |
707 | [[_res._u._ext.nsaddrs[[0]]->sin6_addr;]])], | |
708 | [ac_cv_have_res_ext_nsaddrs="yes"],[ac_cv_have_res_ext_nsaddrs="no"])) | |
709 | if test "$ac_cv_have_res_ext_nsaddrs" = "yes" ; then | |
710 | AC_DEFINE(_SQUID_RES_NSADDR6_LPTR,_res._u._ext.nsaddrs,[If _res structure has _ext.nsaddrs member]) | |
711 | AC_DEFINE(_SQUID_RES_NSADDR6_COUNT,_res._u._ext.nscount6,[Nameserver Counter for IPv6 _res]) | |
712 | fi | |
713 | fi | |
714 | ||
715 | AC_CACHE_CHECK(for _res.nsaddr_list, ac_cv_have_res_nsaddr_list, | |
716 | AC_COMPILE_IFELSE([ | |
717 | AC_LANG_PROGRAM([[ | |
718 | #if HAVE_SYS_TYPES_H | |
719 | #include <sys/types.h> | |
720 | #endif | |
721 | #if HAVE_NETINET_IN_H | |
722 | #include <netinet/in.h> | |
723 | #endif | |
724 | #if HAVE_ARPA_INET_H | |
725 | #include <arpa/inet.h> | |
726 | #endif | |
727 | #if HAVE_ARPA_NAMESER_H | |
728 | #include <arpa/nameser.h> | |
729 | #endif | |
730 | #if HAVE_RESOLV_H | |
731 | #include <resolv.h> | |
732 | #endif | |
733 | ]], [[_res.nsaddr_list[[0]];]])], | |
734 | [ac_cv_have_res_nsaddr_list="yes"],[ac_cv_have_res_nsaddr_list="no"])) | |
735 | if test $ac_cv_have_res_nsaddr_list = "yes" ; then | |
736 | AC_DEFINE(_SQUID_RES_NSADDR_LIST,_res.nsaddr_list,[If _res structure has nsaddr_list member]) | |
737 | AC_DEFINE(_SQUID_RES_NSADDR_COUNT,_res.nscount,[Nameserver counter for IPv4 _res]) | |
738 | fi | |
739 | ||
740 | if test "$_SQUID_RES_NSADDR_LIST" = ""; then | |
741 | AC_CACHE_CHECK(for _res.ns_list, ac_cv_have_res_ns_list, | |
742 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
743 | #if HAVE_SYS_TYPES_H | |
744 | #include <sys/types.h> | |
745 | #endif | |
746 | #if HAVE_NETINET_IN_H | |
747 | #include <netinet/in.h> | |
748 | #endif | |
749 | #if HAVE_ARPA_INET_H | |
750 | #include <arpa/inet.h> | |
751 | #endif | |
752 | #if HAVE_ARPA_NAMESER_H | |
753 | #include <arpa/nameser.h> | |
754 | #endif | |
755 | #if HAVE_RESOLV_H | |
756 | #include <resolv.h> | |
757 | #endif | |
758 | ]], | |
759 | [[_res.ns_list[[0]].addr;]])], | |
760 | [ac_cv_have_res_ns_list="yes"],[ac_cv_have_res_ns_list="no"])) | |
761 | if test $ac_cv_have_res_ns_list = "yes" ; then | |
762 | AC_DEFINE(_SQUID_RES_NSADDR_LIST,_res.ns_list,[If _res structure has ns_list member]) | |
763 | AC_DEFINE(_SQUID_RES_NSADDR_COUNT,_res.nscount,[Nameserver counter for IPv4 _res]) | |
764 | fi | |
765 | fi | |
766 | ]) | |
767 | ||
768 | ||
0c0d381b FC |
769 | dnl checks the winsock library to use (ws2_32 or wsock32) |
770 | dnl may set ac_cv_func_select as a side effect | |
771 | AC_DEFUN([SQUID_CHECK_WINSOCK_LIB],[ | |
391f0bac | 772 | AC_CHECK_HEADERS(winsock2.h winsock.h) |
0c0d381b | 773 | SQUID_STATE_SAVE(winsock) |
391f0bac FC |
774 | SQUID_SEARCH_LIBS([squid_getprotobynumber],[ws2_32 wsock32],,,,[ |
775 | #if HAVE_WINSOCK2_H | |
776 | #include <winsock2.h> | |
777 | #elif HAVE_WINSOCK_H | |
778 | #include <winsock.h> | |
779 | #endif | |
780 | /* ugly hack. */ | |
781 | void squid_getprotobynumber(void) { | |
782 | getprotobynumber(1); | |
783 | } | |
784 | ]) | |
0c0d381b | 785 | AC_MSG_CHECKING([for winsock library]) |
391f0bac | 786 | case "$ac_cv_search_squid_getprotobynumber" in |
0c0d381b FC |
787 | "no") |
788 | AC_MSG_RESULT([winsock library not found]) | |
789 | ;; | |
790 | "none required") | |
791 | AC_MSG_RESULT([winsock library already in LIBS]) | |
792 | ;; | |
793 | "-lws2_32") | |
794 | AC_MSG_RESULT([winsock2]) | |
391f0bac | 795 | XTRA_LIBS="-lws2_32 $XTRA_LIBS" |
0c0d381b FC |
796 | ac_cv_func_select='yes' |
797 | ;; | |
798 | "-lwsock32") | |
799 | AC_MSG_RESULT([winsock]) | |
391f0bac | 800 | XTRA_LIBS="-lwsock32 $XTRA_LIBS" |
0c0d381b FC |
801 | ac_cv_func_select='yes' |
802 | ;; | |
803 | esac | |
0c0d381b FC |
804 | SQUID_STATE_ROLLBACK(winsock) |
805 | ]) | |
91983da0 | 806 | |
91983da0 FC |
807 | dnl check that setresuid is properly implemented. |
808 | dnl sets squid_cv_resuid_works to "yes" or "no" | |
809 | AC_DEFUN([SQUID_CHECK_SETRESUID_WORKS],[ | |
810 | AC_CACHE_CHECK(if setresuid is actually implemented, squid_cv_resuid_works, | |
811 | AC_RUN_IFELSE([ | |
812 | AC_LANG_SOURCE([[ | |
ad17d4bd | 813 | #if HAVE_STDLIB_H |
91983da0 | 814 | #include <stdlib.h> |
ad17d4bd OC |
815 | #endif |
816 | #if HAVE_STDIO_H | |
817 | #include <stdio.h> | |
818 | #endif | |
819 | #if HAVE_UNISTD_H | |
820 | #include <unistd.h> | |
821 | #endif | |
91983da0 FC |
822 | int main(int argc, char **argv) { |
823 | if(setresuid(-1,-1,-1)) { | |
824 | perror("setresuid:"); | |
825 | return 1; | |
826 | } | |
827 | return 0; | |
828 | } | |
829 | ]])],[ | |
830 | squid_cv_resuid_works="yes" ],[ | |
aff0e8fe | 831 | squid_cv_resuid_works="no" ],[:]) |
91983da0 FC |
832 | ) |
833 | ]) | |
5e44eea8 AJ |
834 | |
835 | dnl check that we have functional CPU clock access for the profiler | |
836 | dnl sets squid_cv_profiler_works to "yes" or "no" | |
837 | ||
838 | AC_DEFUN([SQUID_CHECK_FUNCTIONAL_CPU_PROFILER],[ | |
839 | AC_CACHE_CHECK([for operational CPU clock access], | |
840 | squid_cv_cpu_profiler_works, | |
841 | AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ | |
842 | #if defined(__GNUC__) && ( defined(__i386) || defined(__i386__) ) | |
843 | // okay | |
844 | #elif defined(__GNUC__) && ( defined(__x86_64) || defined(__x86_64__) ) | |
845 | // okay | |
846 | #elif defined(__GNUC__) && defined(__alpha) | |
847 | // okay | |
848 | #elif defined(_M_IX86) && defined(_MSC_VER) /* x86 platform on Microsoft C Compiler ONLY */ | |
849 | // okay | |
850 | #else | |
851 | #error This CPU is unsupported. No profiling available here. | |
852 | #endif | |
853 | ]])],[ | |
854 | squid_cv_cpu_profiler_works=yes],[ | |
855 | squid_cv_cpu_profiler_works=no]) | |
856 | ) | |
857 | ]) | |
391f0bac FC |
858 | |
859 | dnl check whether recv takes a char* or void* as a second argument | |
860 | AC_DEFUN([SQUID_CHECK_RECV_ARG_TYPE],[ | |
861 | AC_CACHE_CHECK([whether recv takes a pointer to void or char as second argument], | |
862 | squid_cv_recv_second_arg_type, [ | |
863 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
864 | #include <sys/types.h> | |
865 | #if HAVE_SYS_SOCKET_H | |
866 | #include <sys/socket.h> | |
867 | #endif | |
868 | #if HAVE_WINSOCK2_H | |
869 | #include <winsock2.h> | |
15d36271 | 870 | #elif HAVE_WINSOCK_H |
391f0bac FC |
871 | #include <winsock.h> |
872 | #endif | |
873 | int main (int argc, char ** argv) { | |
874 | void *buf; | |
875 | recv(0,buf,0,0); | |
876 | } | |
877 | ]])],[squid_cv_recv_second_arg_type=void], | |
878 | [squid_cv_recv_second_arg_type=char]) | |
879 | AC_MSG_RESULT($squid_cv_recv_second_arg_type*) | |
880 | ]) | |
881 | AC_DEFINE_UNQUOTED(RECV_ARG_TYPE,$squid_cv_recv_second_arg_type, | |
882 | [Base type of the second argument to recv(2)]) | |
883 | ]) | |
d25bbe26 AJ |
884 | |
885 | ||
886 | dnl check whether Solaris has broken IPFilter headers (Solaris 10 at least does) | |
887 | AC_DEFUN([SQUID_CHECK_BROKEN_SOLARIS_IPFILTER],[ | |
888 | if test "x$squid_cv_broken_ipfilter_minor_t" = "x"; then | |
889 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
890 | # include <sys/types.h> | |
4218a48c | 891 | # include <sys/time.h> |
d25bbe26 AJ |
892 | # include <sys/ioccom.h> |
893 | # include <netinet/in.h> | |
894 | ||
895 | # include <netinet/ip_compat.h> | |
896 | # include <netinet/ip_fil.h> | |
897 | # include <netinet/ip_nat.h> | |
898 | ]])],[ | |
899 | AC_MSG_RESULT(no) | |
900 | squid_cv_broken_ipfilter_minor_t=0 | |
901 | ],[ | |
902 | ## on fail, test the hack | |
903 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
904 | #define minor_t fubaar | |
905 | # include <sys/types.h> | |
4218a48c | 906 | # include <sys/time.h> |
d25bbe26 AJ |
907 | # include <sys/ioccom.h> |
908 | # include <netinet/in.h> | |
909 | #undef minor_t | |
910 | # include <netinet/ip_compat.h> | |
911 | # include <netinet/ip_fil.h> | |
912 | # include <netinet/ip_nat.h> | |
913 | ]])],[ | |
914 | AC_MSG_RESULT(yes) | |
915 | squid_cv_broken_ipfilter_minor_t=1 | |
916 | ],[ | |
4218a48c | 917 | AC_MSG_ERROR(unable to make IPFilter work with netinet/ headers) |
d25bbe26 AJ |
918 | ]) |
919 | ]) | |
920 | fi | |
921 | ||
922 | AC_DEFINE_UNQUOTED(USE_SOLARIS_IPFILTER_MINOR_T_HACK,$squid_cv_broken_ipfilter_minor_t, | |
923 | [Workaround IPFilter minor_t breakage]) | |
924 | ||
925 | ## check for IPFilter headers that require this hack | |
926 | ## (but first netinet/in.h and sys/ioccom.h which they depend on) | |
927 | AC_CHECK_HEADERS( \ | |
928 | netinet/in.h \ | |
929 | sys/ioccom.h \ | |
930 | ip_compat.h \ | |
931 | ip_fil_compat.h \ | |
932 | ip_fil.h \ | |
933 | ip_nat.h \ | |
934 | netinet/ip_compat.h \ | |
935 | netinet/ip_fil_compat.h \ | |
936 | netinet/ip_fil.h \ | |
937 | netinet/ip_nat.h \ | |
938 | ,,,[ | |
939 | #if USE_SOLARIS_IPFILTER_MINOR_T_HACK | |
940 | #define minor_t fubar | |
941 | #endif | |
942 | #if HAVE_SYS_TYPES_H | |
943 | #include <sys/types.h> | |
944 | #endif | |
4218a48c PW |
945 | #if HAVE_SYS_TIME_H |
946 | #include <sys/time.h> | |
947 | #endif | |
d25bbe26 AJ |
948 | #if HAVE_NETINET_IN_H |
949 | #include <netinet/in.h> | |
950 | #endif | |
951 | #if HAVE_SYS_IOCCOM_H | |
952 | #include <sys/ioccom.h> | |
953 | #endif | |
954 | #if USE_SOLARIS_IPFILTER_MINOR_T_HACK | |
955 | #undef minor_t | |
956 | #endif | |
957 | #if HAVE_IP_COMPAT_H | |
958 | #include <ip_compat.h> | |
959 | #elif HAVE_NETINET_IP_COMPAT_H | |
960 | #include <netinet/ip_compat.h> | |
961 | #endif | |
962 | #if HAVE_IP_FIL_H | |
963 | #include <ip_fil.h> | |
964 | #elif HAVE_NETINET_IP_FIL_H | |
965 | #include <netinet/ip_fil.h> | |
966 | #endif | |
967 | #if !defined(IPFILTER_VERSION) | |
968 | #define IPFILTER_VERSION 5000004 | |
969 | #endif | |
970 | ]) | |
971 | ]) |