3 dnl CURL_CHECK_HEADERS_ONCE
4 dnl -------------------------------------------------
5 dnl Check for headers if check not already done.
7 AC_DEFUN(CURL_CHECK_HEADERS_ONCE, [
9 eval prev_check_res=\$ac_cv_header_$i
10 case "$prev_check_res" in
22 dnl CURL_CHECK_HEADER_WINDOWS
23 dnl -------------------------------------------------
24 dnl Check for compilable and valid windows.h header
26 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
27 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
31 #ifndef WIN32_LEAN_AND_MEAN
32 #define WIN32_LEAN_AND_MEAN
37 HAVE_WINDOWS_H shall not be defined.
43 ac_cv_header_windows_h="yes"
45 ac_cv_header_windows_h="no"
48 if test "x$ac_cv_header_windows_h" = "xyes"; then
49 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
50 [Define to 1 if you have the windows.h header file.])
51 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
52 [Define to avoid automatic inclusion of winsock.h])
57 dnl CURL_CHECK_HEADER_WINSOCK
58 dnl -------------------------------------------------
59 dnl Check for compilable and valid winsock.h header
61 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
62 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
63 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
67 #ifndef WIN32_LEAN_AND_MEAN
68 #define WIN32_LEAN_AND_MEAN
74 HAVE_WINSOCK_H shall not be defined.
76 int dummy=WSACleanup();
80 ac_cv_header_winsock_h="yes"
82 ac_cv_header_winsock_h="no"
85 if test "x$ac_cv_header_winsock_h" = "xyes"; then
86 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
87 [Define to 1 if you have the winsock.h header file.])
92 dnl CURL_CHECK_HEADER_WINSOCK2
93 dnl -------------------------------------------------
94 dnl Check for compilable and valid winsock2.h header
96 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
97 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
98 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
102 #ifndef WIN32_LEAN_AND_MEAN
103 #define WIN32_LEAN_AND_MEAN
106 #include <winsock2.h>
109 HAVE_WINSOCK2_H shall not be defined.
111 int dummy=2*IPPROTO_ESP;
115 ac_cv_header_winsock2_h="yes"
117 ac_cv_header_winsock2_h="no"
120 if test "x$ac_cv_header_winsock2_h" = "xyes"; then
121 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
122 [Define to 1 if you have the winsock2.h header file.])
127 dnl CURL_CHECK_HEADER_WS2TCPIP
128 dnl -------------------------------------------------
129 dnl Check for compilable and valid ws2tcpip.h header
131 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
132 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
133 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
137 #ifndef WIN32_LEAN_AND_MEAN
138 #define WIN32_LEAN_AND_MEAN
141 #include <winsock2.h>
142 #include <ws2tcpip.h>
145 HAVE_WS2TCPIP_H shall not be defined.
147 int dummy=2*IP_PKTINFO;
151 ac_cv_header_ws2tcpip_h="yes"
153 ac_cv_header_ws2tcpip_h="no"
156 if test "x$ac_cv_header_ws2tcpip_h" = "xyes"; then
157 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
158 [Define to 1 if you have the ws2tcpip.h header file.])
163 dnl CURL_CHECK_TYPE_SOCKLEN_T
164 dnl -------------------------------------------------
165 dnl Check for existing socklen_t type, and provide
166 dnl an equivalent type if socklen_t not available
168 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
169 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
170 AC_CHECK_TYPE([socklen_t], ,[
171 AC_CACHE_CHECK([for socklen_t equivalent],
172 [curl_cv_socklen_t_equiv], [
173 curl_cv_socklen_t_equiv="unknown"
174 for arg2 in "struct sockaddr" void; do
175 for t in int size_t unsigned long "unsigned long"; do
179 #ifdef HAVE_WINDOWS_H
180 #ifndef WIN32_LEAN_AND_MEAN
181 #define WIN32_LEAN_AND_MEAN
184 #ifdef HAVE_WINSOCK2_H
185 #include <winsock2.h>
187 #ifdef HAVE_WINSOCK_H
192 #ifdef HAVE_SYS_TYPES_H
193 #include <sys/types.h>
195 #ifdef HAVE_SYS_SOCKET_H
196 #include <sys/socket.h>
199 int getpeername (int, $arg2 *, $t *);
202 getpeername(0,0,&len);
205 curl_cv_socklen_t_equiv="$t"
211 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
212 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
214 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
215 [type to use in place of socklen_t if not defined])
219 #ifdef HAVE_WINDOWS_H
220 #ifndef WIN32_LEAN_AND_MEAN
221 #define WIN32_LEAN_AND_MEAN
224 #ifdef HAVE_WINSOCK2_H
225 #include <winsock2.h>
226 #ifdef HAVE_WS2TCPIP_H
227 #include <ws2tcpip.h>
231 #ifdef HAVE_SYS_TYPES_H
232 #include <sys/types.h>
234 #ifdef HAVE_SYS_SOCKET_H
235 #include <sys/socket.h>
242 dnl CURL_CHECK_FUNC_GETNAMEINFO
243 dnl -------------------------------------------------
244 dnl Test if the getnameinfo function is available,
245 dnl and check the types of five of its arguments.
246 dnl If the function succeeds HAVE_GETNAMEINFO will be
247 dnl defined, defining the types of the arguments in
248 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
249 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
250 dnl and also defining the type qualifier of first
251 dnl argument in GETNAMEINFO_QUAL_ARG1.
253 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
254 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
255 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
256 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
258 AC_MSG_CHECKING([for getnameinfo])
260 AC_LANG_FUNC_LINK_TRY([getnameinfo])
263 curl_cv_getnameinfo="yes"
266 curl_cv_getnameinfo="no"
269 if test "$curl_cv_getnameinfo" != "yes"; then
270 AC_MSG_CHECKING([deeper for getnameinfo])
276 curl_cv_getnameinfo="yes"
278 AC_MSG_RESULT([but still no])
279 curl_cv_getnameinfo="no"
283 if test "$curl_cv_getnameinfo" != "yes"; then
284 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
287 #ifdef HAVE_WINDOWS_H
288 #ifndef WIN32_LEAN_AND_MEAN
289 #define WIN32_LEAN_AND_MEAN
292 #ifdef HAVE_WINSOCK2_H
293 #include <winsock2.h>
294 #ifdef HAVE_WS2TCPIP_H
295 #include <ws2tcpip.h>
299 #ifdef HAVE_SYS_TYPES_H
300 #include <sys/types.h>
302 #ifdef HAVE_SYS_SOCKET_H
303 #include <sys/socket.h>
310 getnameinfo(0, 0, 0, 0, 0, 0, 0);
313 curl_cv_getnameinfo="yes"
315 AC_MSG_RESULT([but still no])
316 curl_cv_getnameinfo="no"
320 if test "$curl_cv_getnameinfo" = "yes"; then
321 AC_CACHE_CHECK([types of arguments for getnameinfo],
322 [curl_cv_func_getnameinfo_args], [
323 curl_cv_func_getnameinfo_args="unknown"
324 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
325 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
326 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
327 for gni_arg7 in 'int' 'unsigned int'; do
331 #ifdef HAVE_WINDOWS_H
332 #ifndef WIN32_LEAN_AND_MEAN
333 #define WIN32_LEAN_AND_MEAN
335 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
337 #define _WIN32_WINNT 0x0501
340 #ifdef HAVE_WINSOCK2_H
341 #include <winsock2.h>
342 #ifdef HAVE_WS2TCPIP_H
343 #include <ws2tcpip.h>
346 #define GNICALLCONV WSAAPI
348 #ifdef HAVE_SYS_TYPES_H
349 #include <sys/types.h>
351 #ifdef HAVE_SYS_SOCKET_H
352 #include <sys/socket.h>
359 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
365 $gni_arg46 hostlen=0;
366 $gni_arg46 servlen=0;
368 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
371 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
379 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
380 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
381 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
383 gni_prev_IFS=$IFS; IFS=','
384 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
388 gni_qual_type_arg1=$[1]
390 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
391 [Define to the type of arg 2 for getnameinfo.])
392 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
393 [Define to the type of args 4 and 6 for getnameinfo.])
394 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
395 [Define to the type of arg 7 for getnameinfo.])
399 case $prev_sh_opts in
407 case "$gni_qual_type_arg1" in
410 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
414 gni_type_arg1=$gni_qual_type_arg1
418 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
419 [Define to the type qualifier of arg 1 for getnameinfo.])
420 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
421 [Define to the type of arg 1 for getnameinfo.])
423 case $prev_sh_opts in
431 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
432 [Define to 1 if you have the getnameinfo function.])
433 ac_cv_func_getnameinfo="yes"
439 dnl TYPE_SOCKADDR_STORAGE
440 dnl -------------------------------------------------
441 dnl Check for struct sockaddr_storage. Most IPv6-enabled
442 dnl hosts have it, but AIX 4.3 is one known exception.
444 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
446 AC_CHECK_TYPE([struct sockaddr_storage],
447 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
448 [if struct sockaddr_storage is defined]), ,
451 #ifdef HAVE_WINDOWS_H
452 #ifndef WIN32_LEAN_AND_MEAN
453 #define WIN32_LEAN_AND_MEAN
456 #ifdef HAVE_WINSOCK2_H
457 #include <winsock2.h>
460 #ifdef HAVE_SYS_TYPES_H
461 #include <sys/types.h>
463 #ifdef HAVE_SYS_SOCKET_H
464 #include <sys/socket.h>
466 #ifdef HAVE_NETINET_IN_H
467 #include <netinet/in.h>
469 #ifdef HAVE_ARPA_INET_H
470 #include <arpa/inet.h>
477 dnl CURL_CHECK_NI_WITHSCOPEID
478 dnl -------------------------------------------------
479 dnl Check for working NI_WITHSCOPEID in getnameinfo()
481 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
482 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
483 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
484 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
485 netdb.h netinet/in.h arpa/inet.h)
487 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
488 [ac_cv_working_ni_withscopeid], [
494 #ifdef HAVE_SYS_TYPES_H
495 #include <sys/types.h>
497 #ifdef HAVE_SYS_SOCKET_H
498 #include <sys/socket.h>
503 #ifdef HAVE_NETINET_IN_H
504 #include <netinet/in.h>
506 #ifdef HAVE_ARPA_INET_H
507 #include <arpa/inet.h>
510 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
511 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
512 struct sockaddr_storage sa;
514 unsigned char sa[256];
516 char hostbuf[NI_MAXHOST];
518 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
519 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
520 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
521 int fd = socket(AF_INET6, SOCK_STREAM, 0);
524 return 1; /* Error creating socket */
526 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
528 perror("getsockname()");
529 return 2; /* Error retrieving socket name */
531 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
533 printf("rc = %s\n", gai_strerror(rc));
534 return 3; /* Error translating socket address */
536 return 0; /* Ok, NI_WITHSCOPEID works */
538 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
542 # Exit code == 0. Program worked.
543 ac_cv_working_ni_withscopeid="yes"
545 # Exit code != 0. Program failed.
546 ac_cv_working_ni_withscopeid="no"
548 # Program is not run when cross-compiling. So we assume
549 # NI_WITHSCOPEID will work if we are able to compile it.
552 #include <sys/types.h>
553 #include <sys/socket.h>
556 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
559 ac_cv_working_ni_withscopeid="yes"
561 ac_cv_working_ni_withscopeid="no"
562 ]) # AC_COMPILE_IFELSE
565 if test "x$ac_cv_working_ni_withscopeid" = "xyes"; then
566 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
567 [Define to 1 if NI_WITHSCOPEID exists and works.])
572 dnl CURL_CHECK_FUNC_RECV
573 dnl -------------------------------------------------
574 dnl Test if the socket recv() function is available,
575 dnl and check its return type and the types of its
576 dnl arguments. If the function succeeds HAVE_RECV
577 dnl will be defined, defining the types of the arguments
578 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
579 dnl and RECV_TYPE_ARG4, defining the type of the function
580 dnl return value in RECV_TYPE_RETV.
582 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
583 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
584 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
585 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
587 AC_MSG_CHECKING([for recv])
590 #ifdef HAVE_WINDOWS_H
591 #ifndef WIN32_LEAN_AND_MEAN
592 #define WIN32_LEAN_AND_MEAN
595 #ifdef HAVE_WINSOCK2_H
596 #include <winsock2.h>
598 #ifdef HAVE_WINSOCK_H
603 #ifdef HAVE_SYS_TYPES_H
604 #include <sys/types.h>
606 #ifdef HAVE_SYS_SOCKET_H
607 #include <sys/socket.h>
620 if test "$curl_cv_recv" = "yes"; then
621 AC_CACHE_CHECK([types of arguments and return type for recv],
622 [curl_cv_func_recv_args], [
623 curl_cv_func_recv_args="unknown"
624 for recv_retv in 'int' 'ssize_t'; do
625 for recv_arg1 in 'int' 'ssize_t'; do
626 for recv_arg2 in 'char *' 'void *'; do
627 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
628 for recv_arg4 in 'int' 'unsigned int'; do
632 #ifdef HAVE_WINDOWS_H
633 #ifndef WIN32_LEAN_AND_MEAN
634 #define WIN32_LEAN_AND_MEAN
637 #ifdef HAVE_WINSOCK2_H
638 #include <winsock2.h>
640 #ifdef HAVE_WINSOCK_H
645 #ifdef HAVE_SYS_TYPES_H
646 #include <sys/types.h>
648 #ifdef HAVE_SYS_SOCKET_H
649 #include <sys/socket.h>
652 extern $recv_retv recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
658 $recv_retv res = recv(s, buf, len, flags);
661 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
670 if test "$curl_cv_func_recv_args" = "unknown"; then
671 AC_MSG_WARN([Cannot find proper types to use for recv args])
672 AC_MSG_WARN([HAVE_RECV will not be defined])
674 recv_prev_IFS=$IFS; IFS=','
675 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
679 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
680 [Define to the type of arg 1 for recv.])
681 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
682 [Define to the type of arg 2 for recv.])
683 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
684 [Define to the type of arg 3 for recv.])
685 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
686 [Define to the type of arg 4 for recv.])
687 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
688 [Define to the function return type for recv.])
690 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
691 [Define to 1 if you have the recv function.])
692 ac_cv_func_recv="yes"
698 dnl CURL_CHECK_FUNC_SEND
699 dnl -------------------------------------------------
700 dnl Test if the socket send() function is available,
701 dnl and check its return type and the types of its
702 dnl arguments. If the function succeeds HAVE_SEND
703 dnl will be defined, defining the types of the arguments
704 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
705 dnl and SEND_TYPE_ARG4, defining the type of the function
706 dnl return value in SEND_TYPE_RETV, and also defining the
707 dnl type qualifier of second argument in SEND_QUAL_ARG2.
709 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
710 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
711 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
712 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
714 AC_MSG_CHECKING([for send])
717 #ifdef HAVE_WINDOWS_H
718 #ifndef WIN32_LEAN_AND_MEAN
719 #define WIN32_LEAN_AND_MEAN
722 #ifdef HAVE_WINSOCK2_H
723 #include <winsock2.h>
725 #ifdef HAVE_WINSOCK_H
730 #ifdef HAVE_SYS_TYPES_H
731 #include <sys/types.h>
733 #ifdef HAVE_SYS_SOCKET_H
734 #include <sys/socket.h>
747 if test "$curl_cv_send" = "yes"; then
748 AC_CACHE_CHECK([types of arguments and return type for send],
749 [curl_cv_func_send_args], [
750 curl_cv_func_send_args="unknown"
751 for send_retv in 'int' 'ssize_t'; do
752 for send_arg1 in 'int' 'ssize_t'; do
753 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
754 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
755 for send_arg4 in 'int' 'unsigned int'; do
759 #ifdef HAVE_WINDOWS_H
760 #ifndef WIN32_LEAN_AND_MEAN
761 #define WIN32_LEAN_AND_MEAN
764 #ifdef HAVE_WINSOCK2_H
765 #include <winsock2.h>
767 #ifdef HAVE_WINSOCK_H
772 #ifdef HAVE_SYS_TYPES_H
773 #include <sys/types.h>
775 #ifdef HAVE_SYS_SOCKET_H
776 #include <sys/socket.h>
779 extern $send_retv send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
784 $send_retv res = send(s, 0, len, flags);
787 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
796 if test "$curl_cv_func_send_args" = "unknown"; then
797 AC_MSG_WARN([Cannot find proper types to use for send args])
798 AC_MSG_WARN([HAVE_SEND will not be defined])
800 send_prev_IFS=$IFS; IFS=','
801 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
805 send_qual_type_arg2=$[2]
807 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
808 [Define to the type of arg 1 for send.])
809 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
810 [Define to the type of arg 3 for send.])
811 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
812 [Define to the type of arg 4 for send.])
813 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
814 [Define to the function return type for send.])
818 case $prev_sh_opts in
826 case "$send_qual_type_arg2" in
829 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
833 send_type_arg2=$send_qual_type_arg2
837 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
838 [Define to the type qualifier of arg 2 for send.])
839 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
840 [Define to the type of arg 2 for send.])
842 case $prev_sh_opts in
850 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
851 [Define to 1 if you have the send function.])
852 ac_cv_func_send="yes"
858 dnl CURL_CHECK_NONBLOCKING_SOCKET
859 dnl -------------------------------------------------
860 dnl Check for how to set a socket to non-blocking state. There seems to exist
861 dnl four known different ways, with the one used almost everywhere being POSIX
862 dnl and XPG3, while the other different ways for different systems (old BSD,
863 dnl Windows and Amiga).
865 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
866 dnl O_NONBLOCK define is found but does not work. This condition is attempted
867 dnl to get caught in this script by using an excessive number of #ifdefs...
869 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
871 AC_MSG_CHECKING([non-blocking sockets style])
874 /* headers for O_NONBLOCK test */
875 #include <sys/types.h>
879 /* try to compile O_NONBLOCK */
881 #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
882 # if defined(__SVR4) || defined(__srv4__)
883 # define PLATFORM_SOLARIS
885 # define PLATFORM_SUNOS4
888 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4)
889 # define PLATFORM_AIX_V3
892 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
893 #error "O_NONBLOCK does not work on this platform"
896 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
898 dnl the O_NONBLOCK test was fine
899 nonblock="O_NONBLOCK"
900 AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
902 dnl the code was bad, try a different program now, test 2
905 /* headers for FIONBIO test */
909 /* FIONBIO source test (old-style unix) */
911 int flags = ioctl(socket, FIONBIO, &flags);
913 dnl FIONBIO test was good
915 AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
917 dnl FIONBIO test was also bad
918 dnl the code was bad, try a different program now, test 3
921 /* headers for ioctlsocket test (Windows) */
923 #ifdef HAVE_WINDOWS_H
924 #ifndef WIN32_LEAN_AND_MEAN
925 #define WIN32_LEAN_AND_MEAN
928 #ifdef HAVE_WINSOCK2_H
929 #include <winsock2.h>
931 #ifdef HAVE_WINSOCK_H
937 /* ioctlsocket source code */
939 unsigned long flags = 0;
940 sd = socket(0, 0, 0);
941 ioctlsocket(sd, FIONBIO, &flags);
943 dnl ioctlsocket test was good
944 nonblock="ioctlsocket"
945 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
947 dnl ioctlsocket didnt compile!, go to test 4
950 /* headers for IoctlSocket test (Amiga?) */
951 #include <sys/ioctl.h>
953 /* IoctlSocket source code */
955 int flags = IoctlSocket(socket, FIONBIO, (long)1);
957 dnl ioctlsocket test was good
958 nonblock="IoctlSocket"
959 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
961 dnl Ioctlsocket didnt compile, do test 5!
963 /* headers for SO_NONBLOCK test (BeOS) */
966 /* SO_NONBLOCK source code */
969 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
971 dnl the SO_NONBLOCK test was good
972 nonblock="SO_NONBLOCK"
973 AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
975 dnl test 5 didnt compile!
977 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
979 dnl end of fifth test
982 dnl end of forth test
985 dnl end of third test
988 dnl end of second test
991 dnl end of non-blocking try-compile test
992 AC_MSG_RESULT($nonblock)
994 if test "$nonblock" = "nada"; then
995 AC_MSG_WARN([non-block sockets disabled])
1000 dnl TYPE_SOCKADDR_STORAGE
1001 dnl -------------------------------------------------
1002 dnl Check for struct sockaddr_storage. Most IPv6-enabled hosts have it, but
1003 dnl AIX 4.3 is one known exception.
1004 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1006 AC_CHECK_TYPE([struct sockaddr_storage],
1007 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1008 [if struct sockaddr_storage is defined]), ,
1011 #ifdef HAVE_WINDOWS_H
1012 #ifndef WIN32_LEAN_AND_MEAN
1013 #define WIN32_LEAN_AND_MEAN
1015 #include <windows.h>
1016 #ifdef HAVE_WINSOCK2_H
1017 #include <winsock2.h>
1020 #ifdef HAVE_SYS_TYPES_H
1021 #include <sys/types.h>
1023 #ifdef HAVE_SYS_SOCKET_H
1024 #include <sys/socket.h>
1026 #ifdef HAVE_NETINET_IN_H
1027 #include <netinet/in.h>
1029 #ifdef HAVE_ARPA_INET_H
1030 #include <arpa/inet.h>
1038 dnl -------------------------------------------------
1039 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1040 dnl and a few other things.
1041 AC_DEFUN([TYPE_IN_ADDR_T],
1043 AC_CHECK_TYPE([in_addr_t], ,[
1044 AC_MSG_CHECKING([for in_addr_t equivalent])
1045 AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
1047 curl_cv_in_addr_t_equiv=
1048 for t in "unsigned long" int size_t unsigned long; do
1051 #ifdef HAVE_WINDOWS_H
1052 #ifndef WIN32_LEAN_AND_MEAN
1053 #define WIN32_LEAN_AND_MEAN
1055 #include <windows.h>
1056 #ifdef HAVE_WINSOCK2_H
1057 #include <winsock2.h>
1059 #ifdef HAVE_WINSOCK_H
1060 #include <winsock.h>
1064 #ifdef HAVE_SYS_TYPES_H
1065 #include <sys/types.h>
1067 #ifdef HAVE_SYS_SOCKET_H
1068 #include <sys/socket.h>
1070 #ifdef HAVE_NETINET_IN_H
1071 #include <netinet/in.h>
1073 #ifdef HAVE_ARPA_INET_H
1074 #include <arpa/inet.h>
1078 $t data = inet_addr ("1.2.3.4");
1080 curl_cv_in_addr_t_equiv="$t"
1085 if test "x$curl_cv_in_addr_t_equiv" = x; then
1086 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1089 AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
1090 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1091 [type to use in place of in_addr_t if not defined])],
1094 #ifdef HAVE_WINDOWS_H
1095 #ifndef WIN32_LEAN_AND_MEAN
1096 #define WIN32_LEAN_AND_MEAN
1098 #include <windows.h>
1099 #ifdef HAVE_WINSOCK2_H
1100 #include <winsock2.h>
1102 #ifdef HAVE_WINSOCK_H
1103 #include <winsock.h>
1107 #ifdef HAVE_SYS_TYPES_H
1108 #include <sys/types.h>
1110 #ifdef HAVE_SYS_SOCKET_H
1111 #include <sys/socket.h>
1113 #ifdef HAVE_NETINET_IN_H
1114 #include <netinet/in.h>
1116 #ifdef HAVE_ARPA_INET_H
1117 #include <arpa/inet.h>
1121 ]) dnl AC_CHECK_TYPE
1125 dnl We create a function for detecting which compiler we use and then set as
1126 dnl pendantic compiler options as possible for that particular compiler. The
1127 dnl options are only used for debug-builds.
1129 dnl This is a copy of the original found in curl's configure script. Don't
1130 dnl modify this one, edit the one in curl and copy it back here when that one
1133 AC_DEFUN([CURL_CC_DEBUG_OPTS],
1135 if test "$GCC" = "yes"; then
1137 dnl figure out gcc version!
1138 AC_MSG_CHECKING([gcc version])
1139 gccver=`$CC -dumpversion`
1140 num1=`echo $gccver | cut -d . -f1`
1141 num2=`echo $gccver | cut -d . -f2`
1142 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
1143 AC_MSG_RESULT($gccver)
1145 AC_MSG_CHECKING([if this is icc in disguise])
1146 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
1147 dnl action if the text is found, this it has not been replaced by the
1150 AC_MSG_RESULT([no]),
1151 dnl the text was not found, it was replaced by the cpp
1153 AC_MSG_RESULT([yes])
1156 if test "$ICC" = "yes"; then
1157 dnl this is icc, not gcc.
1159 dnl ICC warnings we ignore:
1160 dnl * 279 warns on static conditions in while expressions
1161 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
1162 dnl "invalid format string conversion"
1166 if test "$gccnum" -gt "600"; then
1167 dnl icc 6.0 and older doesn't have the -Wall flag
1172 WARN="-W -Wall -Wwrite-strings -pedantic -Wno-long-long -Wundef -Wpointer-arith -Wnested-externs -Winline -Wmissing-declarations -Wmissing-prototypes -Wsign-compare"
1174 dnl -Wcast-align is a bit too annoying ;-)
1176 if test "$gccnum" -ge "296"; then
1177 dnl gcc 2.96 or later
1178 WARN="$WARN -Wfloat-equal"
1180 if test "$gccnum" -gt "296"; then
1181 dnl this option does not exist in 2.96
1182 WARN="$WARN -Wno-format-nonliteral"
1185 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1186 dnl on i686-Linux as it gives us heaps with false positives
1187 if test "$gccnum" -ge "303"; then
1188 dnl gcc 3.3 and later
1189 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
1193 for flag in $CPPFLAGS; do
1197 add=`echo $flag | sed 's/^-I/-isystem /g'`
1205 CFLAGS="$CFLAGS $WARN"
1209 dnl strip off optimizer flags
1211 for flag in $CFLAGS; do
1214 dnl echo "cut off $flag"
1217 NEWFLAGS="$NEWFLAGS $flag"
1223 ]) dnl end of AC_DEFUN()
1226 dnl This macro determines if the specified struct exists in the specified file
1228 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1230 AC_DEFUN([CARES_CHECK_STRUCT], [
1231 AC_MSG_CHECKING([for struct $2])
1232 AC_TRY_COMPILE([$1],
1234 struct $2 struct_instance;
1235 ], ac_struct="yes", ac_found="no")
1236 if test "$ac_struct" = "yes" ; then
1245 dnl This macro determines if the specified constant exists in the specified file
1247 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
1249 AC_DEFUN([CARES_CHECK_CONSTANT], [
1250 AC_MSG_CHECKING([for $2])
1251 AC_EGREP_CPP(VARIABLEWASDEFINED,
1260 ], ac_constant="yes", ac_constant="no"
1262 if test "$ac_constant" = "yes" ; then
1272 dnl This macro determines how many parameters getservbyport_r takes
1273 AC_DEFUN([CARES_CHECK_GETSERVBYPORT_R], [
1274 AC_MSG_CHECKING([how many arguments getservbyport_r takes])
1276 [#include <netdb.h>],
1280 struct servent *p3, *p6;
1281 getservbyport_r(p1, p2, p3, p4, p5, &p6);
1282 ], ac_func_getservbyport_r=6,
1284 [#include <netdb.h>],
1289 getservbyport_r(p1, p2, p3, p4, p5);
1290 ], ac_func_getservbyport_r=5,
1292 [#include <netdb.h>],
1297 struct servent_data p4;
1298 getservbyport_r(p1, p2, p3, &p4);
1299 ], ac_func_getservbyport_r=4, ac_func_getservbyport_r=0
1303 if test $ac_func_getservbyport_r != "0" ; then
1304 AC_MSG_RESULT($ac_func_getservbyport_r)
1305 AC_DEFINE(HAVE_GETSERVBYPORT_R, 1, [Specifies whether getservbyport_r is present])
1306 AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $ac_func_getservbyport_r, [Specifies the number of arguments to
1308 if test $ac_func_getservbyport_r = "4" ; then
1309 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data), [Specifies the size of the buffer to pass to
1312 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096, [Specifies the size of the buffer to pass to getservbyport_r])
1315 AC_MSG_RESULT([not found])
1319 # Prevent libtool for checking how to run C++ compiler and check for other
1320 # tools we don't want to use. We do this by m4-defining the _LT_AC_TAGCONFIG
1321 # variable to the code to run, as by default it uses a much more complicated
1322 # approach. The code below that is actually added seems to be used for cases
1323 # where configure has trouble figuring out what C compiler to use but where
1324 # the installed libtool has an idea.
1326 # This function is a re-implemented version of the Paolo Bonzini fix posted to
1327 # the c-ares mailing list by Bram Matthys on May 6 2006. My version removes
1328 # redundant code but also adds the LTCFLAGS check that wasn't in that patch.
1330 # Some code in this function was extracted from the generated configure script.
1332 # CARES_CLEAR_LIBTOOL_TAGS
1333 AC_DEFUN([CARES_CLEAR_LIBTOOL_TAGS],
1334 [m4_define([_LT_AC_TAGCONFIG], [
1335 if test -f "$ltmain"; then
1336 if test ! -f "${ofile}"; then
1337 AC_MSG_WARN([output file `$ofile' does not exist])
1340 if test -z "$LTCC"; then
1341 eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
1342 if test -z "$LTCC"; then
1343 AC_MSG_WARN([output file `$ofile' does not look like a libtool
1346 AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
1349 if test -z "$LTCFLAGS"; then
1350 eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"