3 dnl CURL_CHECK_HEADER_WINDOWS
4 dnl -------------------------------------------------
5 dnl Check for compilable and valid windows.h header
7 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
8 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
12 #ifndef WIN32_LEAN_AND_MEAN
13 #define WIN32_LEAN_AND_MEAN
18 HAVE_WINDOWS_H shall not be defined.
24 ac_cv_header_windows_h="yes"
26 ac_cv_header_windows_h="no"
29 case "$ac_cv_header_windows_h" in
31 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
32 [Define to 1 if you have the windows.h header file.])
33 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
34 [Define to avoid automatic inclusion of winsock.h])
40 dnl CURL_CHECK_HEADER_WINSOCK
41 dnl -------------------------------------------------
42 dnl Check for compilable and valid winsock.h header
44 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
45 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
46 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
50 #ifndef WIN32_LEAN_AND_MEAN
51 #define WIN32_LEAN_AND_MEAN
57 HAVE_WINSOCK_H shall not be defined.
59 int dummy=WSACleanup();
63 ac_cv_header_winsock_h="yes"
65 ac_cv_header_winsock_h="no"
68 case "$ac_cv_header_winsock_h" in
70 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
71 [Define to 1 if you have the winsock.h header file.])
77 dnl CURL_CHECK_HEADER_WINSOCK2
78 dnl -------------------------------------------------
79 dnl Check for compilable and valid winsock2.h header
81 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
82 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
83 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
87 #ifndef WIN32_LEAN_AND_MEAN
88 #define WIN32_LEAN_AND_MEAN
94 HAVE_WINSOCK2_H shall not be defined.
96 int dummy=2*IPPROTO_ESP;
100 ac_cv_header_winsock2_h="yes"
102 ac_cv_header_winsock2_h="no"
105 case "$ac_cv_header_winsock2_h" in
107 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
108 [Define to 1 if you have the winsock2.h header file.])
114 dnl CURL_CHECK_HEADER_WS2TCPIP
115 dnl -------------------------------------------------
116 dnl Check for compilable and valid ws2tcpip.h header
118 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
119 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
120 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
124 #ifndef WIN32_LEAN_AND_MEAN
125 #define WIN32_LEAN_AND_MEAN
128 #include <winsock2.h>
129 #include <ws2tcpip.h>
132 HAVE_WS2TCPIP_H shall not be defined.
134 int dummy=2*IP_PKTINFO;
138 ac_cv_header_ws2tcpip_h="yes"
140 ac_cv_header_ws2tcpip_h="no"
143 case "$ac_cv_header_ws2tcpip_h" in
145 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
146 [Define to 1 if you have the ws2tcpip.h header file.])
152 dnl CURL_CHECK_HEADER_MALLOC
153 dnl -------------------------------------------------
154 dnl Check for compilable and valid malloc.h header,
155 dnl and check if it is needed even with stdlib.h
157 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
158 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
163 void *p = malloc(10);
164 void *q = calloc(10,10);
169 ac_cv_header_malloc_h="yes"
171 ac_cv_header_malloc_h="no"
174 if test "$ac_cv_header_malloc_h" = "yes"; then
175 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
176 [Define to 1 if you have the malloc.h header file.])
182 void *p = malloc(10);
183 void *q = calloc(10,10);
188 curl_cv_need_header_malloc_h="no"
190 curl_cv_need_header_malloc_h="yes"
193 case "$curl_cv_need_header_malloc_h" in
195 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
196 [Define to 1 if you need the malloc.h header file even with stdlib.h])
203 dnl CURL_CHECK_TYPE_SOCKLEN_T
204 dnl -------------------------------------------------
205 dnl Check for existing socklen_t type, and provide
206 dnl an equivalent type if socklen_t not available
208 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
209 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
210 AC_CHECK_TYPE([socklen_t], ,[
211 AC_CACHE_CHECK([for socklen_t equivalent],
212 [curl_cv_socklen_t_equiv], [
213 curl_cv_socklen_t_equiv="unknown"
214 for arg2 in "struct sockaddr" void; do
215 for t in int size_t unsigned long "unsigned long"; do
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>
227 #ifdef HAVE_WINSOCK_H
232 #ifdef HAVE_SYS_TYPES_H
233 #include <sys/types.h>
235 #ifdef HAVE_SYS_SOCKET_H
236 #include <sys/socket.h>
239 int getpeername (int, $arg2 *, $t *);
242 getpeername(0,0,&len);
245 curl_cv_socklen_t_equiv="$t"
251 case "$curl_cv_socklen_t_equiv" in
253 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
256 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
257 [type to use in place of socklen_t if not defined])
262 #ifdef HAVE_WINDOWS_H
263 #ifndef WIN32_LEAN_AND_MEAN
264 #define WIN32_LEAN_AND_MEAN
267 #ifdef HAVE_WINSOCK2_H
268 #include <winsock2.h>
269 #ifdef HAVE_WS2TCPIP_H
270 #include <ws2tcpip.h>
274 #ifdef HAVE_SYS_TYPES_H
275 #include <sys/types.h>
277 #ifdef HAVE_SYS_SOCKET_H
278 #include <sys/socket.h>
285 dnl CURL_CHECK_FUNC_GETNAMEINFO
286 dnl -------------------------------------------------
287 dnl Test if the getnameinfo function is available,
288 dnl and check the types of five of its arguments.
289 dnl If the function succeeds HAVE_GETNAMEINFO will be
290 dnl defined, defining the types of the arguments in
291 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
292 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
293 dnl and also defining the type qualifier of first
294 dnl argument in GETNAMEINFO_QUAL_ARG1.
296 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
297 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
298 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
299 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
301 AC_MSG_CHECKING([for getnameinfo])
303 AC_LANG_FUNC_LINK_TRY([getnameinfo])
306 curl_cv_getnameinfo="yes"
309 curl_cv_getnameinfo="no"
312 if test "$curl_cv_getnameinfo" != "yes"; then
313 AC_MSG_CHECKING([deeper for getnameinfo])
319 curl_cv_getnameinfo="yes"
321 AC_MSG_RESULT([but still no])
322 curl_cv_getnameinfo="no"
326 if test "$curl_cv_getnameinfo" != "yes"; then
327 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
330 #ifdef HAVE_WINDOWS_H
331 #ifndef WIN32_LEAN_AND_MEAN
332 #define WIN32_LEAN_AND_MEAN
335 #ifdef HAVE_WINSOCK2_H
336 #include <winsock2.h>
337 #ifdef HAVE_WS2TCPIP_H
338 #include <ws2tcpip.h>
342 #ifdef HAVE_SYS_TYPES_H
343 #include <sys/types.h>
345 #ifdef HAVE_SYS_SOCKET_H
346 #include <sys/socket.h>
353 getnameinfo(0, 0, 0, 0, 0, 0, 0);
356 curl_cv_getnameinfo="yes"
358 AC_MSG_RESULT([but still no])
359 curl_cv_getnameinfo="no"
363 if test "$curl_cv_getnameinfo" = "yes"; then
364 AC_CACHE_CHECK([types of arguments for getnameinfo],
365 [curl_cv_func_getnameinfo_args], [
366 curl_cv_func_getnameinfo_args="unknown"
367 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
368 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
369 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
370 for gni_arg7 in 'int' 'unsigned int'; do
374 #ifdef HAVE_WINDOWS_H
375 #ifndef WIN32_LEAN_AND_MEAN
376 #define WIN32_LEAN_AND_MEAN
378 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
380 #define _WIN32_WINNT 0x0501
383 #ifdef HAVE_WINSOCK2_H
384 #include <winsock2.h>
385 #ifdef HAVE_WS2TCPIP_H
386 #include <ws2tcpip.h>
389 #define GNICALLCONV WSAAPI
391 #ifdef HAVE_SYS_TYPES_H
392 #include <sys/types.h>
394 #ifdef HAVE_SYS_SOCKET_H
395 #include <sys/socket.h>
402 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
408 $gni_arg46 hostlen=0;
409 $gni_arg46 servlen=0;
411 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
414 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
422 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
423 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
424 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
426 gni_prev_IFS=$IFS; IFS=','
427 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
431 gni_qual_type_arg1=$[1]
433 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
434 [Define to the type of arg 2 for getnameinfo.])
435 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
436 [Define to the type of args 4 and 6 for getnameinfo.])
437 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
438 [Define to the type of arg 7 for getnameinfo.])
442 case $prev_sh_opts in
450 case "$gni_qual_type_arg1" in
453 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
457 gni_type_arg1=$gni_qual_type_arg1
461 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
462 [Define to the type qualifier of arg 1 for getnameinfo.])
463 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
464 [Define to the type of arg 1 for getnameinfo.])
466 case $prev_sh_opts in
474 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
475 [Define to 1 if you have the getnameinfo function.])
476 ac_cv_func_getnameinfo="yes"
482 dnl TYPE_SOCKADDR_STORAGE
483 dnl -------------------------------------------------
484 dnl Check for struct sockaddr_storage. Most IPv6-enabled
485 dnl hosts have it, but AIX 4.3 is one known exception.
487 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
489 AC_CHECK_TYPE([struct sockaddr_storage],
490 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
491 [if struct sockaddr_storage is defined]), ,
494 #ifdef HAVE_WINDOWS_H
495 #ifndef WIN32_LEAN_AND_MEAN
496 #define WIN32_LEAN_AND_MEAN
499 #ifdef HAVE_WINSOCK2_H
500 #include <winsock2.h>
503 #ifdef HAVE_SYS_TYPES_H
504 #include <sys/types.h>
506 #ifdef HAVE_SYS_SOCKET_H
507 #include <sys/socket.h>
509 #ifdef HAVE_NETINET_IN_H
510 #include <netinet/in.h>
512 #ifdef HAVE_ARPA_INET_H
513 #include <arpa/inet.h>
520 dnl CURL_CHECK_NI_WITHSCOPEID
521 dnl -------------------------------------------------
522 dnl Check for working NI_WITHSCOPEID in getnameinfo()
524 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
525 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
526 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
527 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
528 netdb.h netinet/in.h arpa/inet.h)
530 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
531 [ac_cv_working_ni_withscopeid], [
537 #ifdef HAVE_SYS_TYPES_H
538 #include <sys/types.h>
540 #ifdef HAVE_SYS_SOCKET_H
541 #include <sys/socket.h>
546 #ifdef HAVE_NETINET_IN_H
547 #include <netinet/in.h>
549 #ifdef HAVE_ARPA_INET_H
550 #include <arpa/inet.h>
553 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
554 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
555 struct sockaddr_storage sa;
557 unsigned char sa[256];
559 char hostbuf[NI_MAXHOST];
561 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
562 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
563 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
564 int fd = socket(AF_INET6, SOCK_STREAM, 0);
567 return 1; /* Error creating socket */
569 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
571 perror("getsockname()");
572 return 2; /* Error retrieving socket name */
574 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
576 printf("rc = %s\n", gai_strerror(rc));
577 return 3; /* Error translating socket address */
579 return 0; /* Ok, NI_WITHSCOPEID works */
581 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
585 # Exit code == 0. Program worked.
586 ac_cv_working_ni_withscopeid="yes"
588 # Exit code != 0. Program failed.
589 ac_cv_working_ni_withscopeid="no"
591 # Program is not run when cross-compiling. So we assume
592 # NI_WITHSCOPEID will work if we are able to compile it.
595 #include <sys/types.h>
596 #include <sys/socket.h>
599 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
602 ac_cv_working_ni_withscopeid="yes"
604 ac_cv_working_ni_withscopeid="no"
605 ]) # AC_COMPILE_IFELSE
608 case "$ac_cv_working_ni_withscopeid" in
610 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
611 [Define to 1 if NI_WITHSCOPEID exists and works.])
617 dnl CURL_CHECK_FUNC_RECV
618 dnl -------------------------------------------------
619 dnl Test if the socket recv() function is available,
620 dnl and check its return type and the types of its
621 dnl arguments. If the function succeeds HAVE_RECV
622 dnl will be defined, defining the types of the arguments
623 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
624 dnl and RECV_TYPE_ARG4, defining the type of the function
625 dnl return value in RECV_TYPE_RETV.
627 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
628 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
629 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
630 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
632 AC_MSG_CHECKING([for recv])
635 #ifdef HAVE_WINDOWS_H
636 #ifndef WIN32_LEAN_AND_MEAN
637 #define WIN32_LEAN_AND_MEAN
640 #ifdef HAVE_WINSOCK2_H
641 #include <winsock2.h>
643 #ifdef HAVE_WINSOCK_H
648 #ifdef HAVE_SYS_TYPES_H
649 #include <sys/types.h>
651 #ifdef HAVE_SYS_SOCKET_H
652 #include <sys/socket.h>
665 if test "$curl_cv_recv" = "yes"; then
666 AC_CACHE_CHECK([types of arguments and return type for recv],
667 [curl_cv_func_recv_args], [
668 curl_cv_func_recv_args="unknown"
669 for recv_retv in 'int' 'ssize_t'; do
670 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
671 for recv_arg2 in 'char *' 'void *'; do
672 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
673 for recv_arg4 in 'int' 'unsigned int'; do
677 #ifdef HAVE_WINDOWS_H
678 #ifndef WIN32_LEAN_AND_MEAN
679 #define WIN32_LEAN_AND_MEAN
682 #ifdef HAVE_WINSOCK2_H
683 #include <winsock2.h>
685 #ifdef HAVE_WINSOCK_H
689 #define RECVCALLCONV PASCAL
691 #ifdef HAVE_SYS_TYPES_H
692 #include <sys/types.h>
694 #ifdef HAVE_SYS_SOCKET_H
695 #include <sys/socket.h>
699 extern $recv_retv RECVCALLCONV recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
705 $recv_retv res = recv(s, buf, len, flags);
708 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
717 if test "$curl_cv_func_recv_args" = "unknown"; then
718 AC_MSG_WARN([Cannot find proper types to use for recv args])
719 AC_MSG_WARN([HAVE_RECV will not be defined])
721 recv_prev_IFS=$IFS; IFS=','
722 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
726 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
727 [Define to the type of arg 1 for recv.])
728 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
729 [Define to the type of arg 2 for recv.])
730 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
731 [Define to the type of arg 3 for recv.])
732 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
733 [Define to the type of arg 4 for recv.])
734 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
735 [Define to the function return type for recv.])
737 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
738 [Define to 1 if you have the recv function.])
739 ac_cv_func_recv="yes"
745 dnl CURL_CHECK_FUNC_SEND
746 dnl -------------------------------------------------
747 dnl Test if the socket send() function is available,
748 dnl and check its return type and the types of its
749 dnl arguments. If the function succeeds HAVE_SEND
750 dnl will be defined, defining the types of the arguments
751 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
752 dnl and SEND_TYPE_ARG4, defining the type of the function
753 dnl return value in SEND_TYPE_RETV, and also defining the
754 dnl type qualifier of second argument in SEND_QUAL_ARG2.
756 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
757 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
758 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
759 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
761 AC_MSG_CHECKING([for send])
764 #ifdef HAVE_WINDOWS_H
765 #ifndef WIN32_LEAN_AND_MEAN
766 #define WIN32_LEAN_AND_MEAN
769 #ifdef HAVE_WINSOCK2_H
770 #include <winsock2.h>
772 #ifdef HAVE_WINSOCK_H
777 #ifdef HAVE_SYS_TYPES_H
778 #include <sys/types.h>
780 #ifdef HAVE_SYS_SOCKET_H
781 #include <sys/socket.h>
794 if test "$curl_cv_send" = "yes"; then
795 AC_CACHE_CHECK([types of arguments and return type for send],
796 [curl_cv_func_send_args], [
797 curl_cv_func_send_args="unknown"
798 for send_retv in 'int' 'ssize_t'; do
799 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
800 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
801 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
802 for send_arg4 in 'int' 'unsigned int'; do
806 #ifdef HAVE_WINDOWS_H
807 #ifndef WIN32_LEAN_AND_MEAN
808 #define WIN32_LEAN_AND_MEAN
811 #ifdef HAVE_WINSOCK2_H
812 #include <winsock2.h>
814 #ifdef HAVE_WINSOCK_H
818 #define SENDCALLCONV PASCAL
820 #ifdef HAVE_SYS_TYPES_H
821 #include <sys/types.h>
823 #ifdef HAVE_SYS_SOCKET_H
824 #include <sys/socket.h>
828 extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
833 $send_retv res = send(s, 0, len, flags);
836 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
845 if test "$curl_cv_func_send_args" = "unknown"; then
846 AC_MSG_WARN([Cannot find proper types to use for send args])
847 AC_MSG_WARN([HAVE_SEND will not be defined])
849 send_prev_IFS=$IFS; IFS=','
850 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
854 send_qual_type_arg2=$[2]
856 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
857 [Define to the type of arg 1 for send.])
858 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
859 [Define to the type of arg 3 for send.])
860 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
861 [Define to the type of arg 4 for send.])
862 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
863 [Define to the function return type for send.])
867 case $prev_sh_opts in
875 case "$send_qual_type_arg2" in
878 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
882 send_type_arg2=$send_qual_type_arg2
886 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
887 [Define to the type qualifier of arg 2 for send.])
888 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
889 [Define to the type of arg 2 for send.])
891 case $prev_sh_opts in
899 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
900 [Define to 1 if you have the send function.])
901 ac_cv_func_send="yes"
907 dnl CURL_CHECK_NONBLOCKING_SOCKET
908 dnl -------------------------------------------------
909 dnl Check for how to set a socket to non-blocking state. There seems to exist
910 dnl four known different ways, with the one used almost everywhere being POSIX
911 dnl and XPG3, while the other different ways for different systems (old BSD,
912 dnl Windows and Amiga).
914 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
915 dnl O_NONBLOCK define is found but does not work. This condition is attempted
916 dnl to get caught in this script by using an excessive number of #ifdefs...
918 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
920 AC_MSG_CHECKING([non-blocking sockets style])
923 /* headers for O_NONBLOCK test */
924 #include <sys/types.h>
928 /* try to compile O_NONBLOCK */
930 #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
931 # if defined(__SVR4) || defined(__srv4__)
932 # define PLATFORM_SOLARIS
934 # define PLATFORM_SUNOS4
937 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4)
938 # define PLATFORM_AIX_V3
941 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
942 #error "O_NONBLOCK does not work on this platform"
945 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
947 dnl the O_NONBLOCK test was fine
948 nonblock="O_NONBLOCK"
949 AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
951 dnl the code was bad, try a different program now, test 2
954 /* headers for FIONBIO test */
958 /* FIONBIO source test (old-style unix) */
960 int flags = ioctl(socket, FIONBIO, &flags);
962 dnl FIONBIO test was good
964 AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
966 dnl FIONBIO test was also bad
967 dnl the code was bad, try a different program now, test 3
970 /* headers for ioctlsocket test (Windows) */
972 #ifdef HAVE_WINDOWS_H
973 #ifndef WIN32_LEAN_AND_MEAN
974 #define WIN32_LEAN_AND_MEAN
977 #ifdef HAVE_WINSOCK2_H
978 #include <winsock2.h>
980 #ifdef HAVE_WINSOCK_H
986 /* ioctlsocket source code */
988 unsigned long flags = 0;
989 sd = socket(0, 0, 0);
990 ioctlsocket(sd, FIONBIO, &flags);
992 dnl ioctlsocket test was good
993 nonblock="ioctlsocket"
994 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
996 dnl ioctlsocket didnt compile!, go to test 4
999 /* headers for IoctlSocket test (Amiga?) */
1000 #include <sys/ioctl.h>
1002 /* IoctlSocket source code */
1004 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1006 dnl ioctlsocket test was good
1007 nonblock="IoctlSocket"
1008 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
1010 dnl Ioctlsocket didnt compile, do test 5!
1012 /* headers for SO_NONBLOCK test (BeOS) */
1015 /* SO_NONBLOCK source code */
1018 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1020 dnl the SO_NONBLOCK test was good
1021 nonblock="SO_NONBLOCK"
1022 AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
1024 dnl test 5 didnt compile!
1026 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
1028 dnl end of fifth test
1031 dnl end of forth test
1034 dnl end of third test
1037 dnl end of second test
1040 dnl end of non-blocking try-compile test
1041 AC_MSG_RESULT($nonblock)
1043 if test "$nonblock" = "nada"; then
1044 AC_MSG_WARN([non-block sockets disabled])
1049 dnl TYPE_SOCKADDR_STORAGE
1050 dnl -------------------------------------------------
1051 dnl Check for struct sockaddr_storage. Most IPv6-enabled hosts have it, but
1052 dnl AIX 4.3 is one known exception.
1053 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1055 AC_CHECK_TYPE([struct sockaddr_storage],
1056 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1057 [if struct sockaddr_storage is defined]), ,
1060 #ifdef HAVE_WINDOWS_H
1061 #ifndef WIN32_LEAN_AND_MEAN
1062 #define WIN32_LEAN_AND_MEAN
1064 #include <windows.h>
1065 #ifdef HAVE_WINSOCK2_H
1066 #include <winsock2.h>
1069 #ifdef HAVE_SYS_TYPES_H
1070 #include <sys/types.h>
1072 #ifdef HAVE_SYS_SOCKET_H
1073 #include <sys/socket.h>
1075 #ifdef HAVE_NETINET_IN_H
1076 #include <netinet/in.h>
1078 #ifdef HAVE_ARPA_INET_H
1079 #include <arpa/inet.h>
1087 dnl -------------------------------------------------
1088 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1089 dnl and a few other things.
1090 AC_DEFUN([TYPE_IN_ADDR_T],
1092 AC_CHECK_TYPE([in_addr_t], ,[
1093 AC_MSG_CHECKING([for in_addr_t equivalent])
1094 AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
1096 curl_cv_in_addr_t_equiv=
1097 for t in "unsigned long" int size_t unsigned long; do
1100 #ifdef HAVE_WINDOWS_H
1101 #ifndef WIN32_LEAN_AND_MEAN
1102 #define WIN32_LEAN_AND_MEAN
1104 #include <windows.h>
1105 #ifdef HAVE_WINSOCK2_H
1106 #include <winsock2.h>
1108 #ifdef HAVE_WINSOCK_H
1109 #include <winsock.h>
1113 #ifdef HAVE_SYS_TYPES_H
1114 #include <sys/types.h>
1116 #ifdef HAVE_SYS_SOCKET_H
1117 #include <sys/socket.h>
1119 #ifdef HAVE_NETINET_IN_H
1120 #include <netinet/in.h>
1122 #ifdef HAVE_ARPA_INET_H
1123 #include <arpa/inet.h>
1127 $t data = inet_addr ("1.2.3.4");
1129 curl_cv_in_addr_t_equiv="$t"
1134 if test "x$curl_cv_in_addr_t_equiv" = x; then
1135 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1138 AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
1139 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1140 [type to use in place of in_addr_t if not defined])],
1143 #ifdef HAVE_WINDOWS_H
1144 #ifndef WIN32_LEAN_AND_MEAN
1145 #define WIN32_LEAN_AND_MEAN
1147 #include <windows.h>
1148 #ifdef HAVE_WINSOCK2_H
1149 #include <winsock2.h>
1151 #ifdef HAVE_WINSOCK_H
1152 #include <winsock.h>
1156 #ifdef HAVE_SYS_TYPES_H
1157 #include <sys/types.h>
1159 #ifdef HAVE_SYS_SOCKET_H
1160 #include <sys/socket.h>
1162 #ifdef HAVE_NETINET_IN_H
1163 #include <netinet/in.h>
1165 #ifdef HAVE_ARPA_INET_H
1166 #include <arpa/inet.h>
1170 ]) dnl AC_CHECK_TYPE
1174 dnl We create a function for detecting which compiler we use and then set as
1175 dnl pendantic compiler options as possible for that particular compiler. The
1176 dnl options are only used for debug-builds.
1178 dnl This is a copy of the original found in curl's configure script. Don't
1179 dnl modify this one, edit the one in curl and copy it back here when that one
1182 AC_DEFUN([CURL_CC_DEBUG_OPTS],
1184 if test "$GCC" = "yes"; then
1186 dnl figure out gcc version!
1187 AC_MSG_CHECKING([gcc version])
1188 gccver=`$CC -dumpversion`
1189 num1=`echo $gccver | cut -d . -f1`
1190 num2=`echo $gccver | cut -d . -f2`
1191 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
1192 AC_MSG_RESULT($gccver)
1194 AC_MSG_CHECKING([if this is icc in disguise])
1195 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
1196 dnl action if the text is found, this it has not been replaced by the
1199 AC_MSG_RESULT([no]),
1200 dnl the text was not found, it was replaced by the cpp
1202 AC_MSG_RESULT([yes])
1205 if test "$ICC" = "yes"; then
1206 dnl this is icc, not gcc.
1208 dnl ICC warnings we ignore:
1209 dnl * 279 warns on static conditions in while expressions
1210 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
1211 dnl "invalid format string conversion"
1215 if test "$gccnum" -gt "600"; then
1216 dnl icc 6.0 and older doesn't have the -Wall flag
1221 WARN="-W -Wall -Wwrite-strings -pedantic -Wno-long-long -Wundef -Wpointer-arith -Wnested-externs -Winline -Wmissing-declarations -Wmissing-prototypes -Wsign-compare"
1223 dnl -Wcast-align is a bit too annoying ;-)
1225 if test "$gccnum" -ge "296"; then
1226 dnl gcc 2.96 or later
1227 WARN="$WARN -Wfloat-equal"
1229 if test "$gccnum" -gt "296"; then
1230 dnl this option does not exist in 2.96
1231 WARN="$WARN -Wno-format-nonliteral"
1234 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1235 dnl on i686-Linux as it gives us heaps with false positives
1236 if test "$gccnum" -ge "303"; then
1237 dnl gcc 3.3 and later
1238 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
1242 for flag in $CPPFLAGS; do
1246 add=`echo $flag | sed 's/^-I/-isystem /g'`
1254 CFLAGS="$CFLAGS $WARN"
1258 dnl strip off optimizer flags
1260 for flag in $CFLAGS; do
1263 dnl echo "cut off $flag"
1266 NEWFLAGS="$NEWFLAGS $flag"
1272 ]) dnl end of AC_DEFUN()
1275 dnl This macro determines if the specified struct exists in the specified file
1277 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1279 AC_DEFUN([CARES_CHECK_STRUCT], [
1280 AC_MSG_CHECKING([for struct $2])
1281 AC_TRY_COMPILE([$1],
1283 struct $2 struct_instance;
1284 ], ac_struct="yes", ac_found="no")
1285 if test "$ac_struct" = "yes" ; then
1294 dnl This macro determines if the specified constant exists in the specified file
1296 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
1298 AC_DEFUN([CARES_CHECK_CONSTANT], [
1299 AC_MSG_CHECKING([for $2])
1300 AC_EGREP_CPP(VARIABLEWASDEFINED,
1309 ], ac_constant="yes", ac_constant="no"
1311 if test "$ac_constant" = "yes" ; then
1321 dnl This macro determines how many parameters getservbyport_r takes
1322 AC_DEFUN([CARES_CHECK_GETSERVBYPORT_R], [
1323 AC_MSG_CHECKING([how many arguments getservbyport_r takes])
1325 [#include <netdb.h>],
1329 struct servent *p3, *p6;
1330 getservbyport_r(p1, p2, p3, p4, p5, &p6);
1331 ], ac_func_getservbyport_r=6,
1333 [#include <netdb.h>],
1338 getservbyport_r(p1, p2, p3, p4, p5);
1339 ], ac_func_getservbyport_r=5,
1341 [#include <netdb.h>],
1346 struct servent_data p4;
1347 getservbyport_r(p1, p2, p3, &p4);
1348 ], ac_func_getservbyport_r=4, ac_func_getservbyport_r=0
1352 if test $ac_func_getservbyport_r != "0" ; then
1353 AC_MSG_RESULT($ac_func_getservbyport_r)
1354 AC_DEFINE(HAVE_GETSERVBYPORT_R, 1, [Specifies whether getservbyport_r is present])
1355 AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $ac_func_getservbyport_r, [Specifies the number of arguments to
1357 if test $ac_func_getservbyport_r = "4" ; then
1358 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data), [Specifies the size of the buffer to pass to
1361 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096, [Specifies the size of the buffer to pass to getservbyport_r])
1364 AC_MSG_RESULT([not found])
1368 # Prevent libtool for checking how to run C++ compiler and check for other
1369 # tools we don't want to use. We do this by m4-defining the _LT_AC_TAGCONFIG
1370 # variable to the code to run, as by default it uses a much more complicated
1371 # approach. The code below that is actually added seems to be used for cases
1372 # where configure has trouble figuring out what C compiler to use but where
1373 # the installed libtool has an idea.
1375 # This function is a re-implemented version of the Paolo Bonzini fix posted to
1376 # the c-ares mailing list by Bram Matthys on May 6 2006. My version removes
1377 # redundant code but also adds the LTCFLAGS check that wasn't in that patch.
1379 # Some code in this function was extracted from the generated configure script.
1381 # CARES_CLEAR_LIBTOOL_TAGS
1382 AC_DEFUN([CARES_CLEAR_LIBTOOL_TAGS],
1383 [m4_define([_LT_AC_TAGCONFIG], [
1384 if test -f "$ltmain"; then
1385 if test ! -f "${ofile}"; then
1386 AC_MSG_WARN([output file `$ofile' does not exist])
1389 if test -z "$LTCC"; then
1390 eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
1391 if test -z "$LTCC"; then
1392 AC_MSG_WARN([output file `$ofile' does not look like a libtool
1395 AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
1398 if test -z "$LTCFLAGS"; then
1399 eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"