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 args 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_ERROR([Cannot find proper types to use for recv args])
720 recv_prev_IFS=$IFS; IFS=','
721 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
725 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
726 [Define to the type of arg 1 for recv.])
727 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
728 [Define to the type of arg 2 for recv.])
729 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
730 [Define to the type of arg 3 for recv.])
731 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
732 [Define to the type of arg 4 for recv.])
733 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
734 [Define to the function return type for recv.])
736 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
737 [Define to 1 if you have the recv function.])
738 ac_cv_func_recv="yes"
741 AC_MSG_ERROR([Unable to link function recv])
746 dnl CURL_CHECK_FUNC_SEND
747 dnl -------------------------------------------------
748 dnl Test if the socket send() function is available,
749 dnl and check its return type and the types of its
750 dnl arguments. If the function succeeds HAVE_SEND
751 dnl will be defined, defining the types of the arguments
752 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
753 dnl and SEND_TYPE_ARG4, defining the type of the function
754 dnl return value in SEND_TYPE_RETV, and also defining the
755 dnl type qualifier of second argument in SEND_QUAL_ARG2.
757 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
758 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
759 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
760 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
762 AC_MSG_CHECKING([for send])
765 #ifdef HAVE_WINDOWS_H
766 #ifndef WIN32_LEAN_AND_MEAN
767 #define WIN32_LEAN_AND_MEAN
770 #ifdef HAVE_WINSOCK2_H
771 #include <winsock2.h>
773 #ifdef HAVE_WINSOCK_H
778 #ifdef HAVE_SYS_TYPES_H
779 #include <sys/types.h>
781 #ifdef HAVE_SYS_SOCKET_H
782 #include <sys/socket.h>
795 if test "$curl_cv_send" = "yes"; then
796 AC_CACHE_CHECK([types of args and return type for send],
797 [curl_cv_func_send_args], [
798 curl_cv_func_send_args="unknown"
799 for send_retv in 'int' 'ssize_t'; do
800 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
801 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
802 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
803 for send_arg4 in 'int' 'unsigned int'; do
807 #ifdef HAVE_WINDOWS_H
808 #ifndef WIN32_LEAN_AND_MEAN
809 #define WIN32_LEAN_AND_MEAN
812 #ifdef HAVE_WINSOCK2_H
813 #include <winsock2.h>
815 #ifdef HAVE_WINSOCK_H
819 #define SENDCALLCONV PASCAL
821 #ifdef HAVE_SYS_TYPES_H
822 #include <sys/types.h>
824 #ifdef HAVE_SYS_SOCKET_H
825 #include <sys/socket.h>
829 extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
834 $send_retv res = send(s, 0, len, flags);
837 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
846 if test "$curl_cv_func_send_args" = "unknown"; then
847 AC_MSG_ERROR([Cannot find proper types to use for send args])
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"
904 AC_MSG_ERROR([Unable to link function send])
909 dnl CURL_CHECK_MSG_NOSIGNAL
910 dnl -------------------------------------------------
911 dnl Check for MSG_NOSIGNAL
913 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
914 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
915 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
919 #ifdef HAVE_WINDOWS_H
920 #ifndef WIN32_LEAN_AND_MEAN
921 #define WIN32_LEAN_AND_MEAN
924 #ifdef HAVE_WINSOCK2_H
925 #include <winsock2.h>
927 #ifdef HAVE_WINSOCK_H
932 #ifdef HAVE_SYS_TYPES_H
933 #include <sys/types.h>
935 #ifdef HAVE_SYS_SOCKET_H
936 #include <sys/socket.h>
940 int flag=MSG_NOSIGNAL;
943 ac_cv_msg_nosignal="yes"
945 ac_cv_msg_nosignal="no"
948 case "$ac_cv_msg_nosignal" in
950 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
951 [Define to 1 if you have the MSG_NOSIGNAL flag.])
957 dnl CURL_CHECK_STRUCT_TIMEVAL
958 dnl -------------------------------------------------
959 dnl Check for timeval struct
961 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
962 AC_REQUIRE([AC_HEADER_TIME])dnl
963 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
964 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
965 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
966 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
970 #ifdef HAVE_WINDOWS_H
971 #ifndef WIN32_LEAN_AND_MEAN
972 #define WIN32_LEAN_AND_MEAN
975 #ifdef HAVE_WINSOCK2_H
976 #include <winsock2.h>
978 #ifdef HAVE_WINSOCK_H
983 #ifdef HAVE_SYS_TYPES_H
984 #include <sys/types.h>
986 #ifdef HAVE_SYS_TIME_H
987 #include <sys/time.h>
988 #ifdef TIME_WITH_SYS_TIME
1002 ac_cv_struct_timeval="yes"
1004 ac_cv_struct_timeval="no"
1007 case "$ac_cv_struct_timeval" in
1009 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1010 [Define to 1 if you have the timeval struct.])
1016 dnl TYPE_SIG_ATOMIC_T
1017 dnl -------------------------------------------------
1018 dnl Check if the sig_atomic_t type is available, and
1019 dnl verify if it is already defined as volatile.
1021 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1022 AC_CHECK_HEADERS(signal.h)
1023 AC_CHECK_TYPE([sig_atomic_t],[
1024 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1025 [Define to 1 if sig_atomic_t is an available typedef.])
1027 #ifdef HAVE_SIGNAL_H
1031 case "$ac_cv_type_sig_atomic_t" in
1034 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1036 #ifdef HAVE_SIGNAL_H
1040 static volatile sig_atomic_t dummy = 0;
1043 ac_cv_sig_atomic_t_volatile="no"
1045 AC_MSG_RESULT([yes])
1046 ac_cv_sig_atomic_t_volatile="yes"
1049 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1050 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1051 [Define to 1 if sig_atomic_t is already defined as volatile.])
1058 dnl CURL_CHECK_NONBLOCKING_SOCKET
1059 dnl -------------------------------------------------
1060 dnl Check for how to set a socket to non-blocking state. There seems to exist
1061 dnl four known different ways, with the one used almost everywhere being POSIX
1062 dnl and XPG3, while the other different ways for different systems (old BSD,
1063 dnl Windows and Amiga).
1065 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1066 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1067 dnl to get caught in this script by using an excessive number of #ifdefs...
1069 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
1071 AC_MSG_CHECKING([non-blocking sockets style])
1074 /* headers for O_NONBLOCK test */
1075 #include <sys/types.h>
1079 /* try to compile O_NONBLOCK */
1081 #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1082 # if defined(__SVR4) || defined(__srv4__)
1083 # define PLATFORM_SOLARIS
1085 # define PLATFORM_SUNOS4
1088 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4)
1089 # define PLATFORM_AIX_V3
1092 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1093 #error "O_NONBLOCK does not work on this platform"
1096 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1098 dnl the O_NONBLOCK test was fine
1099 nonblock="O_NONBLOCK"
1100 AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
1102 dnl the code was bad, try a different program now, test 2
1105 /* headers for FIONBIO test */
1107 #include <stropts.h>
1109 /* FIONBIO source test (old-style unix) */
1111 int flags = ioctl(socket, FIONBIO, &flags);
1113 dnl FIONBIO test was good
1115 AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
1117 dnl FIONBIO test was also bad
1118 dnl the code was bad, try a different program now, test 3
1121 /* headers for ioctlsocket test (Windows) */
1123 #ifdef HAVE_WINDOWS_H
1124 #ifndef WIN32_LEAN_AND_MEAN
1125 #define WIN32_LEAN_AND_MEAN
1127 #include <windows.h>
1128 #ifdef HAVE_WINSOCK2_H
1129 #include <winsock2.h>
1131 #ifdef HAVE_WINSOCK_H
1132 #include <winsock.h>
1137 /* ioctlsocket source code */
1139 unsigned long flags = 0;
1140 sd = socket(0, 0, 0);
1141 ioctlsocket(sd, FIONBIO, &flags);
1143 dnl ioctlsocket test was good
1144 nonblock="ioctlsocket"
1145 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
1147 dnl ioctlsocket didnt compile!, go to test 4
1150 /* headers for IoctlSocket test (Amiga?) */
1151 #include <sys/ioctl.h>
1153 /* IoctlSocket source code */
1155 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1157 dnl ioctlsocket test was good
1158 nonblock="IoctlSocket"
1159 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
1161 dnl Ioctlsocket didnt compile, do test 5!
1163 /* headers for SO_NONBLOCK test (BeOS) */
1166 /* SO_NONBLOCK source code */
1169 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1171 dnl the SO_NONBLOCK test was good
1172 nonblock="SO_NONBLOCK"
1173 AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
1175 dnl test 5 didnt compile!
1177 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
1179 dnl end of fifth test
1182 dnl end of forth test
1185 dnl end of third test
1188 dnl end of second test
1191 dnl end of non-blocking try-compile test
1192 AC_MSG_RESULT($nonblock)
1194 if test "$nonblock" = "nada"; then
1195 AC_MSG_WARN([non-block sockets disabled])
1201 dnl -------------------------------------------------
1202 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1203 dnl and a few other things.
1204 AC_DEFUN([TYPE_IN_ADDR_T],
1206 AC_CHECK_TYPE([in_addr_t], ,[
1207 AC_MSG_CHECKING([for in_addr_t equivalent])
1208 AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
1210 curl_cv_in_addr_t_equiv=
1211 for t in "unsigned long" int size_t unsigned long; do
1214 #ifdef HAVE_WINDOWS_H
1215 #ifndef WIN32_LEAN_AND_MEAN
1216 #define WIN32_LEAN_AND_MEAN
1218 #include <windows.h>
1219 #ifdef HAVE_WINSOCK2_H
1220 #include <winsock2.h>
1222 #ifdef HAVE_WINSOCK_H
1223 #include <winsock.h>
1227 #ifdef HAVE_SYS_TYPES_H
1228 #include <sys/types.h>
1230 #ifdef HAVE_SYS_SOCKET_H
1231 #include <sys/socket.h>
1233 #ifdef HAVE_NETINET_IN_H
1234 #include <netinet/in.h>
1236 #ifdef HAVE_ARPA_INET_H
1237 #include <arpa/inet.h>
1241 $t data = inet_addr ("1.2.3.4");
1243 curl_cv_in_addr_t_equiv="$t"
1248 if test "x$curl_cv_in_addr_t_equiv" = x; then
1249 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1252 AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
1253 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1254 [type to use in place of in_addr_t if not defined])],
1257 #ifdef HAVE_WINDOWS_H
1258 #ifndef WIN32_LEAN_AND_MEAN
1259 #define WIN32_LEAN_AND_MEAN
1261 #include <windows.h>
1262 #ifdef HAVE_WINSOCK2_H
1263 #include <winsock2.h>
1265 #ifdef HAVE_WINSOCK_H
1266 #include <winsock.h>
1270 #ifdef HAVE_SYS_TYPES_H
1271 #include <sys/types.h>
1273 #ifdef HAVE_SYS_SOCKET_H
1274 #include <sys/socket.h>
1276 #ifdef HAVE_NETINET_IN_H
1277 #include <netinet/in.h>
1279 #ifdef HAVE_ARPA_INET_H
1280 #include <arpa/inet.h>
1283 ]) dnl AC_CHECK_TYPE
1287 dnl **********************************************************************
1288 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
1290 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
1291 dnl sets the $ICC variable to "yes" or "no"
1292 dnl **********************************************************************
1293 AC_DEFUN([CURL_DETECT_ICC],
1296 AC_MSG_CHECKING([for icc in use])
1297 if test "$GCC" = "yes"; then
1298 dnl check if this is icc acting as gcc in disguise
1299 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
1300 dnl action if the text is found, this it has not been replaced by the
1303 dnl the text was not found, it was replaced by the cpp
1305 AC_MSG_RESULT([yes])
1309 if test "$ICC" = "no"; then
1315 dnl We create a function for detecting which compiler we use and then set as
1316 dnl pendantic compiler options as possible for that particular compiler. The
1317 dnl options are only used for debug-builds.
1319 dnl This is a copy of the original found in curl's configure script. Don't
1320 dnl modify this one, edit the one in curl and copy it back here when that one
1323 AC_DEFUN([CURL_CC_DEBUG_OPTS],
1325 if test "z$ICC" = "z"; then
1329 if test "$GCC" = "yes"; then
1331 dnl figure out gcc version!
1332 AC_MSG_CHECKING([gcc version])
1333 gccver=`$CC -dumpversion`
1334 num1=`echo $gccver | cut -d . -f1`
1335 num2=`echo $gccver | cut -d . -f2`
1336 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
1337 AC_MSG_RESULT($gccver)
1339 if test "$ICC" = "yes"; then
1340 dnl this is icc, not gcc.
1342 dnl ICC warnings we ignore:
1343 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
1344 dnl "invalid format string conversion"
1345 dnl * 279 warns on static conditions in while expressions
1346 dnl * 981 warns on "operands are evaluated in unspecified order"
1347 dnl * 1418 "external definition with no prior declaration"
1348 dnl * 1419 warns on "external declaration in primary source file"
1349 dnl which we know and do on purpose.
1351 WARN="-wd279,269,981,1418,1419"
1353 if test "$gccnum" -eq "900"; then
1354 dnl icc 9.0 when compiling its generated code for its own FD_SET,
1355 dnl FD_ISSET, and FD_ZERO macros emits warnings #1469 and #593.
1356 dnl So for icc 9.0 we also ignore warnings #1469 and #593.
1357 dnl * 593 warns on "variable __d0 was set but never used"
1358 dnl * 1469 warns on "cc clobber ignored"
1360 WARN="$WARN,593,1469"
1363 if test "$gccnum" -gt "600"; then
1364 dnl icc 6.0 and older doesn't have the -Wall flag
1368 dnl this is a set of options we believe *ALL* gcc versions support:
1369 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
1371 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
1373 if test "$gccnum" -ge "207"; then
1374 dnl gcc 2.7 or later
1375 WARN="$WARN -Wmissing-declarations"
1378 if test "$gccnum" -gt "295"; then
1379 dnl only if the compiler is newer than 2.95 since we got lots of
1380 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
1381 dnl gcc 2.95.4 on FreeBSD 4.9!
1382 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare"
1385 if test "$gccnum" -ge "296"; then
1386 dnl gcc 2.96 or later
1387 WARN="$WARN -Wfloat-equal"
1390 if test "$gccnum" -gt "296"; then
1391 dnl this option does not exist in 2.96
1392 WARN="$WARN -Wno-format-nonliteral"
1395 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1396 dnl on i686-Linux as it gives us heaps with false positives.
1397 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
1398 dnl over making it unusable for generic purposes. Let's not use it.
1400 if test "$gccnum" -ge "303"; then
1401 dnl gcc 3.3 and later
1402 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
1405 if test "$gccnum" -ge "304"; then
1406 # try these on gcc 3.4
1407 WARN="$WARN -Wdeclaration-after-statement"
1410 for flag in $CPPFLAGS; do
1413 dnl Include path, provide a -isystem option for the same dir
1414 dnl to prevent warnings in those dirs. The -isystem was not very
1415 dnl reliable on earlier gcc versions.
1416 add=`echo $flag | sed 's/^-I/-isystem /g'`
1424 CFLAGS="$CFLAGS $WARN"
1426 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
1430 AC_MSG_NOTICE([Added no extra compiler options])
1434 dnl strip off optimizer flags
1436 for flag in $CFLAGS; do
1439 dnl echo "cut off $flag"
1442 NEWFLAGS="$NEWFLAGS $flag"
1448 ]) dnl end of AC_DEFUN()
1451 dnl This macro determines if the specified struct exists in the specified file
1453 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1455 AC_DEFUN([CARES_CHECK_STRUCT], [
1456 AC_MSG_CHECKING([for struct $2])
1457 AC_TRY_COMPILE([$1],
1459 struct $2 struct_instance;
1460 ], ac_struct="yes", ac_found="no")
1461 if test "$ac_struct" = "yes" ; then
1470 dnl This macro determines if the specified constant exists in the specified file
1472 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
1474 AC_DEFUN([CARES_CHECK_CONSTANT], [
1475 AC_MSG_CHECKING([for $2])
1476 AC_EGREP_CPP(VARIABLEWASDEFINED,
1485 ], ac_constant="yes", ac_constant="no"
1487 if test "$ac_constant" = "yes" ; then
1497 dnl This macro determines how many parameters getservbyport_r takes
1498 AC_DEFUN([CARES_CHECK_GETSERVBYPORT_R], [
1499 AC_MSG_CHECKING([how many arguments getservbyport_r takes])
1501 [#include <netdb.h>],
1505 struct servent *p3, *p6;
1506 getservbyport_r(p1, p2, p3, p4, p5, &p6);
1507 ], ac_func_getservbyport_r=6,
1509 [#include <netdb.h>],
1514 getservbyport_r(p1, p2, p3, p4, p5);
1515 ], ac_func_getservbyport_r=5,
1517 [#include <netdb.h>],
1522 struct servent_data p4;
1523 getservbyport_r(p1, p2, p3, &p4);
1524 ], ac_func_getservbyport_r=4, ac_func_getservbyport_r=0
1528 if test $ac_func_getservbyport_r != "0" ; then
1529 AC_MSG_RESULT($ac_func_getservbyport_r)
1530 AC_DEFINE(HAVE_GETSERVBYPORT_R, 1, [Specifies whether getservbyport_r is present])
1531 AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $ac_func_getservbyport_r, [Specifies the number of arguments to
1533 if test $ac_func_getservbyport_r = "4" ; then
1534 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data), [Specifies the size of the buffer to pass to
1537 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096, [Specifies the size of the buffer to pass to getservbyport_r])
1540 AC_MSG_RESULT([not found])