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