]>
Commit | Line | Data |
---|---|---|
0abb39dd FC |
1 | dnl |
2 | dnl AUTHOR: Squid Web Cache team | |
3 | dnl | |
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. | |
14 | dnl | |
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. | |
19 | dnl | |
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. | |
24 | dnl | |
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. | |
28 | ||
29 | ||
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],[ | |
33 | ||
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([[ | |
40 | #include <stdlib.h> | |
41 | #include <stdio.h> | |
42 | #include <string.h> | |
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) | |
46 | { | |
47 | int size = 20; | |
48 | char *str = malloc(size); | |
49 | memset(str, 'x', size); | |
50 | strnstr(str, "fubar", size); | |
51 | return 0; | |
52 | } | |
53 | ]])],[squid_cv_func_strnstr="yes"],[squid_cv_func_strnstr="no"],[]) | |
54 | ) | |
55 | if test "$squid_cv_func_strnstr" = "yes" ; then | |
56 | AC_DEFINE(HAVE_STRNSTR,1) | |
57 | fi | |
58 | ||
59 | ]) dnl SQUID_CHECK_FUNC_STRNSTR | |
60 | ||
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],[ | |
64 | ||
65 | # check that the system provides a functional va_copy call | |
66 | ||
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([[ | |
70 | #include <stdarg.h> | |
71 | #include <stdlib.h> | |
72 | int f (int i, ...) { | |
73 | va_list args1, args2; | |
74 | va_start (args1, i); | |
75 | va_copy (args2, args1); | |
76 | if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) | |
77 | return 1; | |
78 | va_end (args1); va_end (args2); | |
79 | return 0; | |
80 | } | |
81 | int main(int argc, char **argv) { return f (0, 42); } | |
82 | ]])],[squid_cv_func_va_copy="yes"],[squid_cv_func_va_copy="no"],[]) | |
83 | ) | |
84 | if test "$squid_cv_func_va_copy" = "yes" ; then | |
85 | AC_DEFINE(HAVE_VA_COPY, 1) | |
86 | fi | |
87 | ||
88 | ]) dnl SQUID_CHECK_FUNC_VACOPY | |
89 | ||
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],[ | |
93 | ||
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([[ | |
97 | #include <stdarg.h> | |
98 | #include <stdlib.h> | |
99 | int f (int i, ...) { | |
100 | va_list args1, args2; | |
101 | va_start (args1, i); | |
102 | __va_copy (args2, args1); | |
103 | if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) | |
104 | return 1; | |
105 | va_end (args1); va_end (args2); | |
106 | return 0; | |
107 | } | |
108 | int main(int argc, char **argv) { return f (0, 42); } | |
109 | ]])],[squid_cv_func___va_copy="yes"],[squid_cv_func___va_copy="no"],[]) | |
110 | ) | |
111 | if test "$squid_cv_func___va_copy" = "yes" ; then | |
112 | AC_DEFINE(HAVE___VA_COPY, 1) | |
113 | fi | |
114 | ]) dnl SQUID_CHECK_FUNC___VACOPY | |
20ad76ab FC |
115 | |
116 | ||
af1e01a8 FC |
117 | dnl check that epoll actually works |
118 | dnl sets squid_cv_epoll_works to "yes" or "no" | |
119 | AC_DEFUN([SQUID_CHECK_EPOLL],[ | |
120 | ||
121 | AC_CACHE_CHECK(if epoll works, squid_cv_epoll_works, | |
122 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
123 | #include <sys/epoll.h> | |
124 | #include <stdlib.h> | |
125 | #include <stdio.h> | |
126 | int main(int argc, char **argv) | |
127 | { | |
128 | int fd = epoll_create(256); | |
129 | if (fd < 0) { | |
130 | perror("epoll_create:"); | |
131 | return 1; | |
132 | } | |
133 | return 0; | |
134 | } | |
135 | ]])],[squid_cv_epoll_works=yes],[squid_cv_epoll_works=no],[])) | |
136 | ||
137 | ]) dnl SQUID_CHECK_EPOLL | |
45c41a07 | 138 | |
ef7ece58 | 139 | |
45c41a07 FC |
140 | dnl check that we have functional libcap2 headers |
141 | dnl sets squid_cv_sys_capability_works to "yes" or "no" | |
ef7ece58 | 142 | |
45c41a07 FC |
143 | AC_DEFUN([SQUID_CHECK_FUNCTIONAL_LIBCAP2],[ |
144 | AC_CACHE_CHECK([for operational libcap2 headers], | |
145 | squid_cv_sys_capability_works, | |
146 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | |
147 | #include <stdlib.h> | |
148 | #include <stddef.h> | |
149 | #include <sys/capability.h> | |
150 | ]], [[ | |
151 | capget(NULL, NULL); | |
152 | capset(NULL, NULL); | |
153 | ]])], | |
154 | [squid_cv_sys_capability_works=yes], | |
155 | [squid_cv_sys_capability_works=no]) | |
156 | ) | |
157 | ]) | |
158 | ||
46f50de9 FC |
159 | |
160 | dnl Ripped from Samba. Thanks! | |
161 | dnl check that we have Unix sockets. Sets squid_cv_unixsocket to either yes or no depending on the check | |
ef7ece58 | 162 | |
46f50de9 FC |
163 | AC_DEFUN([SQUID_CHECK_UNIX_SOCKET],[ |
164 | AC_CACHE_CHECK([for unix domain sockets],squid_cv_unixsocket, [ | |
165 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
166 | #include <sys/types.h> | |
167 | #include <stdlib.h> | |
168 | #include <stddef.h> | |
169 | #include <sys/socket.h> | |
170 | #include <sys/un.h>]], [[ | |
171 | struct sockaddr_un sunaddr; | |
172 | sunaddr.sun_family = AF_UNIX; | |
173 | ]])],[squid_cv_unixsocket=yes],[squid_cv_unixsocket=no])]) | |
174 | ]) | |
ef7ece58 FC |
175 | |
176 | ||
177 | dnl checks that the system provides struct mallinfo and mallinfo.mxfast. | |
178 | dnl AC_DEFINEs HAVE_STRUCT_MALLINFO and HAVE_STRUCT_MALLINFO_MXFAST if so | |
179 | ||
180 | AC_DEFUN([SQUID_HAVE_STRUCT_MALLINFO],[ | |
181 | AC_CHECK_TYPE(struct mallinfo,AC_DEFINE(HAVE_STRUCT_MALLINFO,1,[The system provides struct mallinfo]),,[ | |
182 | #if HAVE_SYS_TYPES_H | |
183 | #include <sys/types.h> | |
184 | #endif | |
185 | #if HAVE_MALLOC_H | |
186 | #include <malloc.h> | |
187 | #endif]) | |
188 | AC_CHECK_MEMBERS([struct mallinfo.mxfast],,,[ | |
189 | #if HAVE_SYS_TYPES_H | |
190 | #include <sys/types.h> | |
191 | #endif | |
192 | #if HAVE_MALLOC_H | |
193 | #include <malloc.h> | |
194 | #endif]) | |
195 | ]) | |
196 | ||
1ca3e305 FC |
197 | dnl check the default FD_SETSIZE size. |
198 | dnl not cached, people are likely to tune this | |
199 | dnl defines DEFAULT_FD_SETSIZE | |
200 | ||
201 | AC_DEFUN([SQUID_CHECK_DEFAULT_FD_SETSIZE],[ | |
202 | AC_MSG_CHECKING(Default FD_SETSIZE value) | |
203 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
204 | #if HAVE_STDIO_H | |
205 | #include <stdio.h> | |
206 | #endif | |
207 | #if HAVE_UNISTD_H | |
208 | #include <unistd.h> | |
209 | #endif | |
210 | #if HAVE_STDLIB_H | |
211 | #include <stdlib.h> | |
212 | #endif | |
213 | #if HAVE_SYS_TIME_H | |
214 | #include <sys/time.h> | |
215 | #endif | |
216 | #if HAVE_SYS_SELECT_H | |
217 | #include <sys/select.h> | |
218 | #endif | |
219 | #if HAVE_SYS_TYPES_H | |
220 | #include <sys/types.h> | |
221 | #endif | |
222 | #if HAVE_WINSOCK_H | |
223 | #include <winsock.h> | |
224 | #endif | |
225 | #if HAVE_WINSOCK2_H | |
226 | #include <winsock2.h> | |
227 | #endif | |
228 | int main(int argc, char **argv) { | |
229 | FILE *fp = fopen("conftestval", "w"); | |
230 | fprintf (fp, "%d\n", FD_SETSIZE); | |
231 | return 0; | |
232 | } | |
233 | ]])],[DEFAULT_FD_SETSIZE=`cat conftestval`],[DEFAULT_FD_SETSIZE=256],[DEFAULT_FD_SETSIZE=256]) | |
234 | AC_MSG_RESULT($DEFAULT_FD_SETSIZE) | |
235 | AC_DEFINE_UNQUOTED(DEFAULT_FD_SETSIZE, $DEFAULT_FD_SETSIZE, [Default FD_SETSIZE value]) | |
236 | ]) | |
f467f578 FC |
237 | |
238 | ||
239 | dnl checks the maximum number of filedescriptor we can open | |
240 | dnl sets shell var squid_filedescriptors_num | |
241 | ||
242 | AC_DEFUN([SQUID_CHECK_MAXFD],[ | |
243 | AC_MSG_CHECKING(Maximum number of filedescriptors we can open) | |
244 | dnl damn! FreeBSD pthreads break dup2(). | |
245 | SQUID_STATE_SAVE(maxfd) | |
246 | case $host in | |
247 | i386-unknown-freebsd*) | |
248 | if echo "$LDFLAGS" | grep -q pthread; then | |
249 | LDFLAGS=`echo $LDFLAGS | sed -e "s/-pthread//"` | |
250 | fi | |
251 | esac | |
252 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
253 | #include <stdio.h> | |
254 | #include <unistd.h> | |
255 | #include <stdlib.h> | |
256 | #include <sys/time.h> /* needed on FreeBSD */ | |
257 | #include <sys/param.h> | |
258 | #include <sys/resource.h> | |
259 | int main(int argc, char **argv) { | |
260 | FILE *fp; | |
261 | int i,j; | |
262 | #if defined(__CYGWIN32__) || defined (__CYGWIN__) | |
263 | /* getrlimit and sysconf returns bogous values on cygwin32. | |
264 | * Number of fds is virtually unlimited in cygwin (sys/param.h) | |
265 | * __CYGWIN32__ is deprecated. | |
266 | */ | |
267 | i = NOFILE; | |
268 | #else | |
269 | #if HAVE_SETRLIMIT | |
270 | struct rlimit rl; | |
271 | #if defined(RLIMIT_NOFILE) | |
272 | if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { | |
273 | perror("getrlimit: RLIMIT_NOFILE"); | |
274 | } else { | |
275 | #if defined(__APPLE__) | |
276 | /* asking for more than OPEN_MAX fails on Leopard */ | |
277 | rl.rlim_cur = (OPEN_MAX < rl.rlim_max ? OPEN_MAX : rl.rlim_max); | |
278 | #else | |
279 | rl.rlim_cur = rl.rlim_max; /* set it to the max */ | |
280 | #endif | |
281 | if (setrlimit(RLIMIT_NOFILE, &rl) < 0) { | |
282 | perror("setrlimit: RLIMIT_NOFILE"); | |
283 | } | |
284 | } | |
285 | #elif defined(RLIMIT_OFILE) | |
286 | if (getrlimit(RLIMIT_OFILE, &rl) < 0) { | |
287 | perror("getrlimit: RLIMIT_OFILE"); | |
288 | } else { | |
289 | rl.rlim_cur = rl.rlim_max; /* set it to the max */ | |
290 | if (setrlimit(RLIMIT_OFILE, &rl) < 0) { | |
291 | perror("setrlimit: RLIMIT_OFILE"); | |
292 | } | |
293 | } | |
294 | #endif /* RLIMIT_NOFILE */ | |
295 | #endif /* HAVE_SETRLIMIT */ | |
296 | /* by starting at 2^14, we will never get higher | |
297 | than 2^15 for squid_filedescriptors_num */ | |
298 | i = j = 1<<14; | |
299 | while (j) { | |
300 | j >>= 1; | |
301 | if (dup2(0, i) < 0) { | |
302 | i -= j; | |
303 | } else { | |
304 | close(i); | |
305 | i += j; | |
306 | } | |
307 | } | |
308 | i++; | |
309 | #endif /* IF !DEF CYGWIN */ | |
310 | fp = fopen("conftestval", "w"); | |
311 | fprintf (fp, "%d\n", i & ~0x3F); | |
312 | return 0; | |
313 | } | |
314 | ]])],[squid_filedescriptors_num=`cat conftestval`],[squid_filedescriptors_num=256],[squid_filedescriptors_num=256]) | |
315 | dnl Microsoft MSVCRT.DLL supports 2048 maximum FDs | |
316 | case "$host_os" in | |
317 | mingw|mingw32) | |
318 | squid_filedescriptors_num="2048" | |
319 | ;; | |
320 | esac | |
321 | AC_MSG_RESULT($squid_filedescriptors_num) | |
322 | SQUID_STATE_ROLLBACK(maxfd) | |
323 | ||
324 | if test `expr $squid_filedescriptors_num % 64` != 0; then | |
325 | AC_MSG_WARN([$squid_filedescriptors_num is not an multiple of 64. This may cause issues on certain platforms.]) | |
326 | fi | |
327 | ]) | |
af494bc8 FC |
328 | |
329 | ||
330 | dnl Check whether this OS defines sin6_len as a member of sockaddr_in6 as a backup to ss_len | |
331 | dnl defines HAVE_SIN6_LEN_IN_SAI | |
332 | dnl TODO: move to AC_CHECK_MEMBER? | |
333 | ||
334 | AC_DEFUN([SQUID_CHECK_SIN6_LEN_IN_SAI],[ | |
335 | AC_CACHE_CHECK([for sin6_len field in struct sockaddr_in6], | |
336 | ac_cv_have_sin6_len_in_struct_sai, [ | |
337 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
338 | #include <sys/types.h> | |
339 | #include <sys/socket.h> | |
340 | #include <netinet/in.h> | |
341 | ]], [[ struct sockaddr_in6 s; s.sin6_len = 1; ]])],[ ac_cv_have_sin6_len_in_struct_sai="yes" ],[ ac_cv_have_sin6_len_in_struct_sai="no" | |
342 | ]) | |
343 | ]) | |
344 | SQUID_DEFINE_BOOL(HAVE_SIN6_LEN_IN_SAI,$ac_cv_have_sin6_len_in_struct_sai, | |
345 | [Defined if struct sockaddr_in6 has sin6_len]) | |
346 | ]) | |
347 | ||
348 | ||
349 | dnl Check whether this OS defines ss_len as a member of sockaddr_storage | |
350 | dnl defines HAVE_SS_LEN_IN_SS | |
351 | dnl TODO: move to AC_CHECK_MEMBER? | |
352 | ||
353 | AC_DEFUN([SQUID_CHECK_SS_LEN_IN_SOCKADDR_STORAGE],[ | |
354 | AC_CACHE_CHECK([for ss_len field in struct sockaddr_storage], | |
355 | ac_cv_have_ss_len_in_struct_ss, [ | |
356 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
357 | #include <sys/types.h> | |
358 | #include <sys/socket.h> | |
359 | #include <netinet/in.h> | |
360 | ]], [[ struct sockaddr_storage s; s.ss_len = 1; ]])],[ ac_cv_have_ss_len_in_struct_ss="yes" ],[ ac_cv_have_ss_len_in_struct_ss="no" | |
361 | ]) | |
362 | ]) | |
363 | SQUID_DEFINE_BOOL(HAVE_SS_LEN_IN_SS,$ac_cv_have_ss_len_in_struct_ss, | |
364 | [Define if sockaddr_storage has field ss_len]) | |
365 | ]) | |
366 | ||
367 | ||
368 | dnl Check whether this OS defines sin_len as a member of sockaddr_in as a backup to ss_len | |
369 | dnl defines HAVE_SIN_LEN_IN_SAI | |
370 | dnl TODO: move to AC_CHECK_MEMBER? | |
371 | ||
372 | AC_DEFUN([SQUID_CHECK_SIN_LEN_IN_SOCKADDR_IN],[ | |
373 | AC_CACHE_CHECK([for sin_len field in struct sockaddr_in], | |
374 | ac_cv_have_sin_len_in_struct_sai, [ | |
375 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
376 | #include <sys/types.h> | |
377 | #include <sys/socket.h> | |
378 | #include <netinet/in.h> | |
379 | ]], [[ struct sockaddr_in s; s.sin_len = 1; ]])],[ ac_cv_have_sin_len_in_struct_sai="yes" ],[ ac_cv_have_sin_len_in_struct_sai="no" | |
380 | ]) | |
381 | ]) | |
382 | SQUID_DEFINE_BOOL(HAVE_SIN_LEN_IN_SAI,$ac_cv_have_sin_len_in_struct_sai,[Define if sockaddr_in has field sin_len]) | |
383 | ]) | |
8e0acaf5 FC |
384 | |
385 | ||
386 | dnl detects default UDP buffer size | |
387 | dnl not cached since people are likely to tune this | |
388 | dnl defines SQUID_DETECT_UDP_SO_SNDBUF | |
389 | ||
390 | AC_DEFUN([SQUID_DETECT_UDP_SND_BUFSIZE],[ | |
391 | AC_MSG_CHECKING(Default UDP send buffer size) | |
392 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
393 | #include <stdlib.h> | |
394 | #include <stdio.h> | |
395 | #include <sys/types.h> | |
396 | #if HAVE_SYS_SOCKET_H | |
397 | #include <sys/socket.h> | |
398 | #endif | |
399 | #if HAVE_NETINET_IN_H | |
400 | #include <netinet/in.h> | |
401 | #endif | |
402 | #if HAVE_WINSOCK_H | |
403 | #include <winsock.h> | |
404 | #endif | |
405 | #if HAVE_WINSOCK2_H | |
406 | #include <winsock2.h> | |
407 | #endif | |
408 | int main(int argc, char **argv) | |
409 | { | |
410 | FILE *fp; | |
411 | int fd,val=0; | |
412 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
413 | int len=sizeof(int); | |
414 | WSADATA wsaData; | |
415 | WSAStartup(2, &wsaData); | |
416 | #else | |
417 | socklen_t len=sizeof(socklen_t); | |
418 | #endif | |
419 | if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1; | |
420 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
421 | if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&val, &len) < 0) return 1; | |
422 | WSACleanup(); | |
423 | #else | |
424 | if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1; | |
425 | #endif | |
426 | if (val<=0) return 1; | |
427 | fp = fopen("conftestval", "w"); | |
428 | fprintf (fp, "%d\n", val); | |
429 | return 0; | |
430 | } | |
431 | ]])],[SQUID_DETECT_UDP_SO_SNDBUF=`cat conftestval`],[SQUID_DETECT_UDP_SO_SNDBUF=16384],[SQUID_DETECT_UDP_SO_SNDBUF=16384]) | |
432 | AC_MSG_RESULT($SQUID_DETECT_UDP_SO_SNDBUF) | |
433 | AC_DEFINE_UNQUOTED(SQUID_DETECT_UDP_SO_SNDBUF, $SQUID_DETECT_UDP_SO_SNDBUF,[UDP send buffer size]) | |
434 | ]) | |
435 | ||
436 | ||
437 | dnl detects default UDP buffer size | |
438 | dnl not cached since people are likely to tune this | |
439 | dnl defines SQUID_DETECT_UDP_SO_RCVBUF | |
440 | ||
441 | AC_DEFUN([SQUID_DETECT_UDP_RECV_BUFSIZE],[ | |
442 | AC_MSG_CHECKING(Default UDP receive buffer size) | |
443 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
444 | #include <stdlib.h> | |
445 | #include <stdio.h> | |
446 | #include <sys/types.h> | |
447 | #if HAVE_SYS_SOCKET_H | |
448 | #include <sys/socket.h> | |
449 | #endif | |
450 | #if HAVE_NETINET_IN_H | |
451 | #include <netinet/in.h> | |
452 | #endif | |
453 | #if HAVE_WINSOCK_H | |
454 | #include <winsock.h> | |
455 | #endif | |
456 | #if HAVE_WINSOCK2_H | |
457 | #include <winsock2.h> | |
458 | #endif | |
459 | int main(int argc, char **argv) | |
460 | { | |
461 | FILE *fp; | |
462 | int fd,val=0; | |
463 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
464 | int len=sizeof(int); | |
465 | WSADATA wsaData; | |
466 | WSAStartup(2, &wsaData); | |
467 | #else | |
468 | socklen_t len=sizeof(socklen_t); | |
469 | #endif | |
470 | if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1; | |
471 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
472 | if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) return 1; | |
473 | WSACleanup(); | |
474 | #else | |
475 | if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1; | |
476 | #endif | |
477 | if (val <= 0) return 1; | |
478 | fp = fopen("conftestval", "w"); | |
479 | fprintf (fp, "%d\n", val); | |
480 | return 0; | |
481 | } | |
482 | ]])],[SQUID_DETECT_UDP_SO_RCVBUF=`cat conftestval`],[SQUID_DETECT_UDP_SO_RCVBUF=16384],[SQUID_DETECT_UDP_SO_RCVBUF=16384]) | |
483 | AC_MSG_RESULT($SQUID_DETECT_UDP_SO_RCVBUF) | |
484 | AC_DEFINE_UNQUOTED(SQUID_DETECT_UDP_SO_RCVBUF, $SQUID_DETECT_UDP_SO_RCVBUF,[UDP receive buffer size]) | |
485 | ]) | |
486 | ||
487 | ||
488 | dnl detects default TCP buffer size | |
489 | dnl not cached since people are likely to tune this | |
490 | dnl defines SQUID_TCP_SO_SNDBUF | |
491 | ||
492 | AC_DEFUN([SQUID_DETECT_TCP_SND_BUFSIZE],[ | |
493 | AC_MSG_CHECKING(Default TCP send buffer size) | |
494 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
495 | #include <stdlib.h> | |
496 | #include <stdio.h> | |
497 | #include <sys/types.h> | |
498 | #if HAVE_SYS_SOCKET_H | |
499 | #include <sys/socket.h> | |
500 | #endif | |
501 | #if HAVE_NETINET_IN_H | |
502 | #include <netinet/in.h> | |
503 | #endif | |
504 | #if HAVE_WINSOCK_H | |
505 | #include <winsock.h> | |
506 | #endif | |
507 | #if HAVE_WINSOCK2_H | |
508 | #include <winsock2.h> | |
509 | #endif | |
510 | int main(int argc, char **argv) | |
511 | { | |
512 | FILE *fp; | |
513 | int fd,val=0; | |
514 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
515 | int len=sizeof(int); | |
516 | WSADATA wsaData; | |
517 | WSAStartup(2, &wsaData); | |
518 | #else | |
519 | socklen_t len=sizeof(socklen_t); | |
520 | #endif | |
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; | |
524 | WSACleanup(); | |
525 | #else | |
526 | if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1; | |
527 | #endif | |
528 | if (val <= 0) return 1; | |
529 | fp = fopen("conftestval", "w"); | |
530 | fprintf (fp, "%d\n", val); | |
531 | return 0; | |
532 | } | |
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 | |
538 | fi | |
539 | AC_DEFINE_UNQUOTED(SQUID_TCP_SO_SNDBUF, $SQUID_TCP_SO_SNDBUF,[TCP send buffer size]) | |
540 | ]) | |
541 | ||
542 | ||
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 | |
546 | ||
547 | AC_DEFUN([SQUID_DETECT_TCP_RECV_BUFSIZE],[ | |
548 | AC_MSG_CHECKING(Default TCP receive buffer size) | |
549 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | |
550 | #include <stdlib.h> | |
551 | #include <stdio.h> | |
552 | #include <sys/types.h> | |
553 | #if HAVE_SYS_SOCKET_H | |
554 | #include <sys/socket.h> | |
555 | #endif | |
556 | #if HAVE_NETINET_IN_H | |
557 | #include <netinet/in.h> | |
558 | #endif | |
559 | #if HAVE_WINSOCK_H | |
560 | #include <winsock.h> | |
561 | #endif | |
562 | #if HAVE_WINSOCK2_H | |
563 | #include <winsock2.h> | |
564 | #endif | |
565 | int main(int argc, char **argv) | |
566 | { | |
567 | FILE *fp; | |
568 | int fd,val=0; | |
569 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
570 | int len=sizeof(int); | |
571 | WSADATA wsaData; | |
572 | WSAStartup(2, &wsaData); | |
573 | #else | |
574 | socklen_t len=sizeof(socklen_t); | |
575 | #endif | |
576 | if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return 1; | |
577 | #if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__)) | |
578 | if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&val, &len) < 0) return 1; | |
579 | WSACleanup(); | |
580 | #else | |
581 | if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1; | |
582 | #endif | |
583 | if (val <= 0) return 1; | |
584 | fp = fopen("conftestval", "w"); | |
585 | fprintf (fp, "%d\n", val); | |
586 | return 0; | |
587 | } | |
588 | ]])],[SQUID_TCP_SO_RCVBUF=`cat conftestval`],[SQUID_TCP_SO_RCVBUF=16384],[SQUID_TCP_SO_RCVBUF=16384]) | |
589 | AC_MSG_RESULT($SQUID_TCP_SO_RCVBUF) | |
590 | if test $SQUID_TCP_SO_RCVBUF -gt 65535; then | |
591 | AC_MSG_NOTICE([Limiting receive buffer size to 64K]) | |
592 | SQUID_TCP_SO_RCVBUF=65535 | |
593 | fi | |
594 | AC_DEFINE_UNQUOTED(SQUID_TCP_SO_RCVBUF, $SQUID_TCP_SO_RCVBUF,[TCP receive buffer size]) | |
595 | ]) | |
5c3c56fa FC |
596 | |
597 | ||
598 | dnl check if we need to define sys_errlist as external | |
599 | dnl defines NEED_SYS_ERRLIST | |
600 | ||
601 | AC_DEFUN([SQUID_CHECK_NEED_SYS_ERRLIST],[ | |
602 | AC_CACHE_CHECK(if sys_errlist is already defined, ac_cv_needs_sys_errlist, | |
603 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[char *s = sys_errlist;]])],[ac_cv_needs_sys_errlist="no"],[ac_cv_needs_sys_errlist="yes"]) | |
604 | ) | |
605 | SQUID_DEFINE_BOOL(NEED_SYS_ERRLIST,$ac_cv_needs_sys_errlist,[If we need to declare sys_errlist as extern]) | |
606 | ]) | |
607 | ||
608 | ||
609 | dnl check if MAXPATHLEN is defined in the system headers | |
610 | dnl or define it ourselves | |
611 | ||
612 | AC_DEFUN([SQUID_CHECK_MAXPATHLEN],[ | |
bb214e97 | 613 | AC_MSG_CHECKING(for system-provided MAXPATHLEN) |
5c3c56fa FC |
614 | AC_LINK_IFELSE([ |
615 | AC_LANG_PROGRAM([[ | |
616 | #include <sys/param.h>]], [[ | |
617 | int i = MAXPATHLEN;]])], [ | |
618 | AC_MSG_RESULT(yes)], [ | |
619 | AC_MSG_RESULT(no) | |
620 | AC_DEFINE(MAXPATHLEN,256,[If MAXPATHLEN has not been defined])]) | |
621 | ]) | |
622 | ||
4e28d61e FC |
623 | |
624 | dnl check that we have a working statvfs | |
625 | dnl sets the ac_cv_func_statvfs shell variable and defines HAVE_STATVFS | |
626 | ||
bb214e97 FC |
627 | AC_DEFUN([SQUID_CHECK_WORKING_STATVFS],[ |
628 | AC_CACHE_CHECK(for working statvfs() interface,ac_cv_func_statvfs,[ | |
629 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
630 | #include <stdlib.h> | |
631 | #include <stdio.h> | |
632 | #include <sys/types.h> | |
633 | #include <sys/statvfs.h> | |
634 | ]], [[ | |
635 | struct statvfs sfs; | |
636 | sfs.f_blocks = sfs.f_bfree = sfs.f_frsize = | |
637 | sfs.f_files = sfs.f_ffree = 0; | |
638 | statvfs("/tmp", &sfs); | |
639 | ]])],[ac_cv_func_statvfs=yes],[ac_cv_func_statvfs=no]) | |
640 | ]) | |
641 | SQUID_DEFINE_BOOL(HAVE_STATVFS,$ac_cv_func_statvfs,[set to 1 if our system has statvfs(), and if it actually works]) | |
642 | ]) | |
4e28d61e FC |
643 | |
644 | ||
645 | dnl check that we can use the libresolv _dns_ttl_ hack | |
646 | dnl sets the ac_cv_libresolv_dns_ttl_hack shell variable and defines LIBRESOLV_DNS_TTL_HACK | |
647 | ||
648 | AC_DEFUN([SQUID_CHECK_LIBRESOLV_DNS_TTL_HACK],[ | |
649 | AC_CACHE_CHECK(for libresolv _dns_ttl_ hack, ac_cv_libresolv_dns_ttl_hack, [ | |
650 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int _dns_ttl_;]], [[return _dns_ttl_;]])], | |
651 | [ac_cv_libresolv_dns_ttl_hack=yes],[ac_cv_libresolv_dns_ttl_hack=no]) ]) | |
652 | SQUID_DEFINE_BOOL(LIBRESOLV_DNS_TTL_HACK,$ac_cv_libresolv_dns_ttl_hack, | |
653 | [libresolv.a has been hacked to export _dns_ttl_]) | |
654 | ]) | |
4d6c0a9c FC |
655 | |
656 | ||
657 | dnl checks for availability of some resolver fields | |
658 | dnl sets ac_cv_have_res_ext_nsaddr_list shell variable | |
659 | dnl defines _SQUID_RES_NSADDR6_COUNT _SQUID_RES_NSADDR6_LARRAY | |
660 | dnl defines _SQUID_RES_NSADDR6_LPTR _SQUID_RES_NSADDR6_COUNT | |
661 | dnl defines _SQUID_RES_NSADDR_LIST _SQUID_RES_NSADDR_COUNT | |
662 | ||
663 | AC_DEFUN([SQUID_CHECK_RESOLVER_FIELDS],[ | |
664 | AC_CACHE_CHECK(for _res_ext.nsaddr_list, ac_cv_have_res_ext_nsaddr_list, | |
665 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
666 | #if HAVE_SYS_TYPES_H | |
667 | #include <sys/types.h> | |
668 | #endif | |
669 | #if HAVE_NETINET_IN_H | |
670 | #include <netinet/in.h> | |
671 | #endif | |
672 | #if HAVE_ARPA_INET_H | |
673 | #include <arpa/inet.h> | |
674 | #endif | |
675 | #if HAVE_ARPA_NAMESER_H | |
676 | #include <arpa/nameser.h> | |
677 | #endif | |
678 | #if HAVE_RESOLV_H | |
679 | #include <resolv.h> | |
680 | #endif | |
681 | ]], | |
682 | [[_res_ext.nsaddr_list[[0]].s_addr;]])],[ | |
683 | ac_cv_have_res_ext_nsaddr_list="yes" ],[ | |
684 | ac_cv_have_res_ext_nsaddr_list="no"])) | |
685 | if test "$ac_cv_have_res_ext_nsaddr_list" = "yes" ; then | |
686 | AC_DEFINE(_SQUID_RES_NSADDR6_LARRAY,_res_ext.nsaddr_list,[If _res_ext structure has nsaddr_list member]) | |
687 | AC_DEFINE(_SQUID_RES_NSADDR6_COUNT,ns6count,[Nameserver Counter for IPv6 _res_ext]) | |
688 | fi | |
689 | ||
690 | if test "$_SQUID_RES_NSADDR6_LIST" = ""; then | |
691 | AC_CACHE_CHECK(for _res._u._ext.nsaddrs, ac_cv_have_res_ext_nsaddrs, | |
692 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
693 | #if HAVE_SYS_TYPES_H | |
694 | #include <sys/types.h> | |
695 | #endif | |
696 | #if HAVE_NETINET_IN_H | |
697 | #include <netinet/in.h> | |
698 | #endif | |
699 | #if HAVE_ARPA_INET_H | |
700 | #include <arpa/inet.h> | |
701 | #endif | |
702 | #if HAVE_ARPA_NAMESER_H | |
703 | #include <arpa/nameser.h> | |
704 | #endif | |
705 | #if HAVE_RESOLV_H | |
706 | #include <resolv.h> | |
707 | #endif | |
708 | ]], i | |
709 | [[_res._u._ext.nsaddrs[[0]]->sin6_addr;]])], | |
710 | [ac_cv_have_res_ext_nsaddrs="yes"],[ac_cv_have_res_ext_nsaddrs="no"])) | |
711 | if test "$ac_cv_have_res_ext_nsaddrs" = "yes" ; then | |
712 | AC_DEFINE(_SQUID_RES_NSADDR6_LPTR,_res._u._ext.nsaddrs,[If _res structure has _ext.nsaddrs member]) | |
713 | AC_DEFINE(_SQUID_RES_NSADDR6_COUNT,_res._u._ext.nscount6,[Nameserver Counter for IPv6 _res]) | |
714 | fi | |
715 | fi | |
716 | ||
717 | AC_CACHE_CHECK(for _res.nsaddr_list, ac_cv_have_res_nsaddr_list, | |
718 | AC_COMPILE_IFELSE([ | |
719 | AC_LANG_PROGRAM([[ | |
720 | #if HAVE_SYS_TYPES_H | |
721 | #include <sys/types.h> | |
722 | #endif | |
723 | #if HAVE_NETINET_IN_H | |
724 | #include <netinet/in.h> | |
725 | #endif | |
726 | #if HAVE_ARPA_INET_H | |
727 | #include <arpa/inet.h> | |
728 | #endif | |
729 | #if HAVE_ARPA_NAMESER_H | |
730 | #include <arpa/nameser.h> | |
731 | #endif | |
732 | #if HAVE_RESOLV_H | |
733 | #include <resolv.h> | |
734 | #endif | |
735 | ]], [[_res.nsaddr_list[[0]];]])], | |
736 | [ac_cv_have_res_nsaddr_list="yes"],[ac_cv_have_res_nsaddr_list="no"])) | |
737 | if test $ac_cv_have_res_nsaddr_list = "yes" ; then | |
738 | AC_DEFINE(_SQUID_RES_NSADDR_LIST,_res.nsaddr_list,[If _res structure has nsaddr_list member]) | |
739 | AC_DEFINE(_SQUID_RES_NSADDR_COUNT,_res.nscount,[Nameserver counter for IPv4 _res]) | |
740 | fi | |
741 | ||
742 | if test "$_SQUID_RES_NSADDR_LIST" = ""; then | |
743 | AC_CACHE_CHECK(for _res.ns_list, ac_cv_have_res_ns_list, | |
744 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
745 | #if HAVE_SYS_TYPES_H | |
746 | #include <sys/types.h> | |
747 | #endif | |
748 | #if HAVE_NETINET_IN_H | |
749 | #include <netinet/in.h> | |
750 | #endif | |
751 | #if HAVE_ARPA_INET_H | |
752 | #include <arpa/inet.h> | |
753 | #endif | |
754 | #if HAVE_ARPA_NAMESER_H | |
755 | #include <arpa/nameser.h> | |
756 | #endif | |
757 | #if HAVE_RESOLV_H | |
758 | #include <resolv.h> | |
759 | #endif | |
760 | ]], | |
761 | [[_res.ns_list[[0]].addr;]])], | |
762 | [ac_cv_have_res_ns_list="yes"],[ac_cv_have_res_ns_list="no"])) | |
763 | if test $ac_cv_have_res_ns_list = "yes" ; then | |
764 | AC_DEFINE(_SQUID_RES_NSADDR_LIST,_res.ns_list,[If _res structure has ns_list member]) | |
765 | AC_DEFINE(_SQUID_RES_NSADDR_COUNT,_res.nscount,[Nameserver counter for IPv4 _res]) | |
766 | fi | |
767 | fi | |
768 | ]) | |
769 | ||
770 | ||
0c0d381b FC |
771 | dnl checks the winsock library to use (ws2_32 or wsock32) |
772 | dnl may set ac_cv_func_select as a side effect | |
773 | AC_DEFUN([SQUID_CHECK_WINSOCK_LIB],[ | |
774 | SQUID_STATE_SAVE(winsock) | |
775 | AC_SEARCH_LIBS([closesocket],[ws2_32 wsock32]) | |
776 | AC_MSG_CHECKING([for winsock library]) | |
777 | case "$ac_cv_search_closesocket" in | |
778 | "no") | |
779 | AC_MSG_RESULT([winsock library not found]) | |
780 | ;; | |
781 | "none required") | |
782 | AC_MSG_RESULT([winsock library already in LIBS]) | |
783 | ;; | |
784 | "-lws2_32") | |
785 | AC_MSG_RESULT([winsock2]) | |
786 | ac_cv_func_select='yes' | |
787 | ;; | |
788 | "-lwsock32") | |
789 | AC_MSG_RESULT([winsock]) | |
790 | ac_cv_func_select='yes' | |
791 | ;; | |
792 | esac | |
793 | AC_CHECK_HEADERS(winsock2.h winsock.h) | |
794 | SQUID_STATE_ROLLBACK(winsock) | |
795 | ]) | |
91983da0 FC |
796 | |
797 | ||
798 | dnl check that setresuid is properly implemented. | |
799 | dnl sets squid_cv_resuid_works to "yes" or "no" | |
800 | AC_DEFUN([SQUID_CHECK_SETRESUID_WORKS],[ | |
801 | AC_CACHE_CHECK(if setresuid is actually implemented, squid_cv_resuid_works, | |
802 | AC_RUN_IFELSE([ | |
803 | AC_LANG_SOURCE([[ | |
804 | #include <stdlib.h> | |
805 | int main(int argc, char **argv) { | |
806 | if(setresuid(-1,-1,-1)) { | |
807 | perror("setresuid:"); | |
808 | return 1; | |
809 | } | |
810 | return 0; | |
811 | } | |
812 | ]])],[ | |
813 | squid_cv_resuid_works="yes" ],[ | |
814 | squid_cv_resuid_works="no" ],[]) | |
815 | ) | |
816 | ]) |