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_NATIVE_WINDOWS
41 dnl -------------------------------------------------
42 dnl Check if building a native Windows target
44 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
45 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
46 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
47 if test "$ac_cv_header_windows_h" = "no"; then
48 ac_cv_native_windows="no"
56 Not a native Windows build target.
60 ac_cv_native_windows="yes"
62 ac_cv_native_windows="no"
66 case "$ac_cv_native_windows" in
68 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
69 [Define to 1 if you are building a native Windows target.])
75 dnl CURL_CHECK_HEADER_WINSOCK
76 dnl -------------------------------------------------
77 dnl Check for compilable and valid winsock.h header
79 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
80 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
81 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
85 #ifndef WIN32_LEAN_AND_MEAN
86 #define WIN32_LEAN_AND_MEAN
92 HAVE_WINSOCK_H shall not be defined.
94 int dummy=WSACleanup();
98 ac_cv_header_winsock_h="yes"
100 ac_cv_header_winsock_h="no"
103 case "$ac_cv_header_winsock_h" in
105 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
106 [Define to 1 if you have the winsock.h header file.])
112 dnl CURL_CHECK_HEADER_WINSOCK2
113 dnl -------------------------------------------------
114 dnl Check for compilable and valid winsock2.h header
116 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
117 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
118 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
122 #ifndef WIN32_LEAN_AND_MEAN
123 #define WIN32_LEAN_AND_MEAN
126 #include <winsock2.h>
128 #if defined(__CYGWIN__) || defined(_WIN32_WCE)
129 HAVE_WINSOCK2_H shall not be defined.
131 int dummy=2*IPPROTO_ESP;
135 ac_cv_header_winsock2_h="yes"
137 ac_cv_header_winsock2_h="no"
140 case "$ac_cv_header_winsock2_h" in
142 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
143 [Define to 1 if you have the winsock2.h header file.])
149 dnl CURL_CHECK_HEADER_WS2TCPIP
150 dnl -------------------------------------------------
151 dnl Check for compilable and valid ws2tcpip.h header
153 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
154 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
155 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
159 #ifndef WIN32_LEAN_AND_MEAN
160 #define WIN32_LEAN_AND_MEAN
163 #include <winsock2.h>
164 #include <ws2tcpip.h>
166 #if defined(__CYGWIN__) || defined(_WIN32_WCE)
167 HAVE_WS2TCPIP_H shall not be defined.
169 int dummy=2*IP_PKTINFO;
173 ac_cv_header_ws2tcpip_h="yes"
175 ac_cv_header_ws2tcpip_h="no"
178 case "$ac_cv_header_ws2tcpip_h" in
180 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
181 [Define to 1 if you have the ws2tcpip.h header file.])
187 dnl CURL_CHECK_HEADER_MALLOC
188 dnl -------------------------------------------------
189 dnl Check for compilable and valid malloc.h header,
190 dnl and check if it is needed even with stdlib.h
192 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
193 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
198 void *p = malloc(10);
199 void *q = calloc(10,10);
204 ac_cv_header_malloc_h="yes"
206 ac_cv_header_malloc_h="no"
209 if test "$ac_cv_header_malloc_h" = "yes"; then
210 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
211 [Define to 1 if you have the malloc.h header file.])
217 void *p = malloc(10);
218 void *q = calloc(10,10);
223 curl_cv_need_header_malloc_h="no"
225 curl_cv_need_header_malloc_h="yes"
228 case "$curl_cv_need_header_malloc_h" in
230 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
231 [Define to 1 if you need the malloc.h header file even with stdlib.h])
238 dnl CURL_CHECK_TYPE_SOCKLEN_T
239 dnl -------------------------------------------------
240 dnl Check for existing socklen_t type, and provide
241 dnl an equivalent type if socklen_t not available
243 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
244 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
245 AC_CHECK_TYPE([socklen_t], ,[
246 AC_CACHE_CHECK([for socklen_t equivalent],
247 [curl_cv_socklen_t_equiv], [
248 curl_cv_socklen_t_equiv="unknown"
249 for arg2 in "struct sockaddr" void; do
250 for t in int size_t unsigned long "unsigned long"; do
254 #ifdef HAVE_WINDOWS_H
255 #ifndef WIN32_LEAN_AND_MEAN
256 #define WIN32_LEAN_AND_MEAN
259 #ifdef HAVE_WINSOCK2_H
260 #include <winsock2.h>
262 #ifdef HAVE_WINSOCK_H
267 #ifdef HAVE_SYS_TYPES_H
268 #include <sys/types.h>
270 #ifdef HAVE_SYS_SOCKET_H
271 #include <sys/socket.h>
274 int getpeername (int, $arg2 *, $t *);
277 getpeername(0,0,&len);
280 curl_cv_socklen_t_equiv="$t"
286 case "$curl_cv_socklen_t_equiv" in
288 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
291 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
292 [type to use in place of socklen_t if not defined])
297 #ifdef HAVE_WINDOWS_H
298 #ifndef WIN32_LEAN_AND_MEAN
299 #define WIN32_LEAN_AND_MEAN
302 #ifdef HAVE_WINSOCK2_H
303 #include <winsock2.h>
304 #ifdef HAVE_WS2TCPIP_H
305 #include <ws2tcpip.h>
309 #ifdef HAVE_SYS_TYPES_H
310 #include <sys/types.h>
312 #ifdef HAVE_SYS_SOCKET_H
313 #include <sys/socket.h>
320 dnl CURL_CHECK_FUNC_GETNAMEINFO
321 dnl -------------------------------------------------
322 dnl Test if the getnameinfo function is available,
323 dnl and check the types of five of its arguments.
324 dnl If the function succeeds HAVE_GETNAMEINFO will be
325 dnl defined, defining the types of the arguments in
326 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
327 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
328 dnl and also defining the type qualifier of first
329 dnl argument in GETNAMEINFO_QUAL_ARG1.
331 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
332 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
333 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
334 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
336 AC_MSG_CHECKING([for getnameinfo])
338 AC_LANG_FUNC_LINK_TRY([getnameinfo])
341 curl_cv_getnameinfo="yes"
344 curl_cv_getnameinfo="no"
347 if test "$curl_cv_getnameinfo" != "yes"; then
348 AC_MSG_CHECKING([deeper for getnameinfo])
354 curl_cv_getnameinfo="yes"
356 AC_MSG_RESULT([but still no])
357 curl_cv_getnameinfo="no"
361 if test "$curl_cv_getnameinfo" != "yes"; then
362 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
365 #ifdef HAVE_WINDOWS_H
366 #ifndef WIN32_LEAN_AND_MEAN
367 #define WIN32_LEAN_AND_MEAN
370 #ifdef HAVE_WINSOCK2_H
371 #include <winsock2.h>
372 #ifdef HAVE_WS2TCPIP_H
373 #include <ws2tcpip.h>
377 #ifdef HAVE_SYS_TYPES_H
378 #include <sys/types.h>
380 #ifdef HAVE_SYS_SOCKET_H
381 #include <sys/socket.h>
388 getnameinfo(0, 0, 0, 0, 0, 0, 0);
391 curl_cv_getnameinfo="yes"
393 AC_MSG_RESULT([but still no])
394 curl_cv_getnameinfo="no"
398 if test "$curl_cv_getnameinfo" = "yes"; then
399 AC_CACHE_CHECK([types of arguments for getnameinfo],
400 [curl_cv_func_getnameinfo_args], [
401 curl_cv_func_getnameinfo_args="unknown"
402 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
403 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
404 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
405 for gni_arg7 in 'int' 'unsigned int'; do
409 #ifdef HAVE_WINDOWS_H
410 #ifndef WIN32_LEAN_AND_MEAN
411 #define WIN32_LEAN_AND_MEAN
413 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
415 #define _WIN32_WINNT 0x0501
418 #ifdef HAVE_WINSOCK2_H
419 #include <winsock2.h>
420 #ifdef HAVE_WS2TCPIP_H
421 #include <ws2tcpip.h>
424 #define GNICALLCONV WSAAPI
426 #ifdef HAVE_SYS_TYPES_H
427 #include <sys/types.h>
429 #ifdef HAVE_SYS_SOCKET_H
430 #include <sys/socket.h>
437 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
443 $gni_arg46 hostlen=0;
444 $gni_arg46 servlen=0;
446 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
449 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
457 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
458 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
459 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
461 gni_prev_IFS=$IFS; IFS=','
462 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
466 gni_qual_type_arg1=$[1]
468 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
469 [Define to the type of arg 2 for getnameinfo.])
470 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
471 [Define to the type of args 4 and 6 for getnameinfo.])
472 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
473 [Define to the type of arg 7 for getnameinfo.])
477 case $prev_sh_opts in
485 case "$gni_qual_type_arg1" in
488 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
492 gni_type_arg1=$gni_qual_type_arg1
496 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
497 [Define to the type qualifier of arg 1 for getnameinfo.])
498 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
499 [Define to the type of arg 1 for getnameinfo.])
501 case $prev_sh_opts in
509 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
510 [Define to 1 if you have the getnameinfo function.])
511 ac_cv_func_getnameinfo="yes"
517 dnl TYPE_SOCKADDR_STORAGE
518 dnl -------------------------------------------------
519 dnl Check for struct sockaddr_storage. Most IPv6-enabled
520 dnl hosts have it, but AIX 4.3 is one known exception.
522 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
524 AC_CHECK_TYPE([struct sockaddr_storage],
525 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
526 [if struct sockaddr_storage is defined]), ,
529 #ifdef HAVE_WINDOWS_H
530 #ifndef WIN32_LEAN_AND_MEAN
531 #define WIN32_LEAN_AND_MEAN
534 #ifdef HAVE_WINSOCK2_H
535 #include <winsock2.h>
538 #ifdef HAVE_SYS_TYPES_H
539 #include <sys/types.h>
541 #ifdef HAVE_SYS_SOCKET_H
542 #include <sys/socket.h>
544 #ifdef HAVE_NETINET_IN_H
545 #include <netinet/in.h>
547 #ifdef HAVE_ARPA_INET_H
548 #include <arpa/inet.h>
555 dnl CURL_CHECK_NI_WITHSCOPEID
556 dnl -------------------------------------------------
557 dnl Check for working NI_WITHSCOPEID in getnameinfo()
559 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
560 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
561 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
562 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
563 netdb.h netinet/in.h arpa/inet.h)
565 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
566 [ac_cv_working_ni_withscopeid], [
572 #ifdef HAVE_SYS_TYPES_H
573 #include <sys/types.h>
575 #ifdef HAVE_SYS_SOCKET_H
576 #include <sys/socket.h>
581 #ifdef HAVE_NETINET_IN_H
582 #include <netinet/in.h>
584 #ifdef HAVE_ARPA_INET_H
585 #include <arpa/inet.h>
588 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
589 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
590 struct sockaddr_storage sa;
592 unsigned char sa[256];
594 char hostbuf[NI_MAXHOST];
596 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
597 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
598 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
599 int fd = socket(AF_INET6, SOCK_STREAM, 0);
602 return 1; /* Error creating socket */
604 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
606 perror("getsockname()");
607 return 2; /* Error retrieving socket name */
609 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
611 printf("rc = %s\n", gai_strerror(rc));
612 return 3; /* Error translating socket address */
614 return 0; /* Ok, NI_WITHSCOPEID works */
616 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
620 # Exit code == 0. Program worked.
621 ac_cv_working_ni_withscopeid="yes"
623 # Exit code != 0. Program failed.
624 ac_cv_working_ni_withscopeid="no"
626 # Program is not run when cross-compiling. So we assume
627 # NI_WITHSCOPEID will work if we are able to compile it.
630 #include <sys/types.h>
631 #include <sys/socket.h>
634 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
637 ac_cv_working_ni_withscopeid="yes"
639 ac_cv_working_ni_withscopeid="no"
640 ]) # AC_COMPILE_IFELSE
643 case "$ac_cv_working_ni_withscopeid" in
645 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
646 [Define to 1 if NI_WITHSCOPEID exists and works.])
652 dnl CURL_CHECK_FUNC_RECV
653 dnl -------------------------------------------------
654 dnl Test if the socket recv() function is available,
655 dnl and check its return type and the types of its
656 dnl arguments. If the function succeeds HAVE_RECV
657 dnl will be defined, defining the types of the arguments
658 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
659 dnl and RECV_TYPE_ARG4, defining the type of the function
660 dnl return value in RECV_TYPE_RETV.
662 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
663 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
664 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
665 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
667 AC_MSG_CHECKING([for recv])
670 #ifdef HAVE_WINDOWS_H
671 #ifndef WIN32_LEAN_AND_MEAN
672 #define WIN32_LEAN_AND_MEAN
675 #ifdef HAVE_WINSOCK2_H
676 #include <winsock2.h>
678 #ifdef HAVE_WINSOCK_H
683 #ifdef HAVE_SYS_TYPES_H
684 #include <sys/types.h>
686 #ifdef HAVE_SYS_SOCKET_H
687 #include <sys/socket.h>
700 if test "$curl_cv_recv" = "yes"; then
701 AC_CACHE_CHECK([types of args and return type for recv],
702 [curl_cv_func_recv_args], [
703 curl_cv_func_recv_args="unknown"
704 for recv_retv in 'int' 'ssize_t'; do
705 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
706 for recv_arg2 in 'char *' 'void *'; do
707 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
708 for recv_arg4 in 'int' 'unsigned int'; do
712 #ifdef HAVE_WINDOWS_H
713 #ifndef WIN32_LEAN_AND_MEAN
714 #define WIN32_LEAN_AND_MEAN
717 #ifdef HAVE_WINSOCK2_H
718 #include <winsock2.h>
720 #ifdef HAVE_WINSOCK_H
724 #define RECVCALLCONV PASCAL
726 #ifdef HAVE_SYS_TYPES_H
727 #include <sys/types.h>
729 #ifdef HAVE_SYS_SOCKET_H
730 #include <sys/socket.h>
734 extern $recv_retv RECVCALLCONV recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
740 $recv_retv res = recv(s, buf, len, flags);
743 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
752 if test "$curl_cv_func_recv_args" = "unknown"; then
753 AC_MSG_ERROR([Cannot find proper types to use for recv args])
755 recv_prev_IFS=$IFS; IFS=','
756 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
760 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
761 [Define to the type of arg 1 for recv.])
762 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
763 [Define to the type of arg 2 for recv.])
764 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
765 [Define to the type of arg 3 for recv.])
766 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
767 [Define to the type of arg 4 for recv.])
768 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
769 [Define to the function return type for recv.])
771 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
772 [Define to 1 if you have the recv function.])
773 ac_cv_func_recv="yes"
776 AC_MSG_ERROR([Unable to link function recv])
781 dnl CURL_CHECK_FUNC_SEND
782 dnl -------------------------------------------------
783 dnl Test if the socket send() function is available,
784 dnl and check its return type and the types of its
785 dnl arguments. If the function succeeds HAVE_SEND
786 dnl will be defined, defining the types of the arguments
787 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
788 dnl and SEND_TYPE_ARG4, defining the type of the function
789 dnl return value in SEND_TYPE_RETV, and also defining the
790 dnl type qualifier of second argument in SEND_QUAL_ARG2.
792 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
793 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
794 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
795 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
797 AC_MSG_CHECKING([for send])
800 #ifdef HAVE_WINDOWS_H
801 #ifndef WIN32_LEAN_AND_MEAN
802 #define WIN32_LEAN_AND_MEAN
805 #ifdef HAVE_WINSOCK2_H
806 #include <winsock2.h>
808 #ifdef HAVE_WINSOCK_H
813 #ifdef HAVE_SYS_TYPES_H
814 #include <sys/types.h>
816 #ifdef HAVE_SYS_SOCKET_H
817 #include <sys/socket.h>
830 if test "$curl_cv_send" = "yes"; then
831 AC_CACHE_CHECK([types of args and return type for send],
832 [curl_cv_func_send_args], [
833 curl_cv_func_send_args="unknown"
834 for send_retv in 'int' 'ssize_t'; do
835 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
836 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
837 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
838 for send_arg4 in 'int' 'unsigned int'; do
842 #ifdef HAVE_WINDOWS_H
843 #ifndef WIN32_LEAN_AND_MEAN
844 #define WIN32_LEAN_AND_MEAN
847 #ifdef HAVE_WINSOCK2_H
848 #include <winsock2.h>
850 #ifdef HAVE_WINSOCK_H
854 #define SENDCALLCONV PASCAL
856 #ifdef HAVE_SYS_TYPES_H
857 #include <sys/types.h>
859 #ifdef HAVE_SYS_SOCKET_H
860 #include <sys/socket.h>
864 extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
869 $send_retv res = send(s, 0, len, flags);
872 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
881 if test "$curl_cv_func_send_args" = "unknown"; then
882 AC_MSG_ERROR([Cannot find proper types to use for send args])
884 send_prev_IFS=$IFS; IFS=','
885 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
889 send_qual_type_arg2=$[2]
891 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
892 [Define to the type of arg 1 for send.])
893 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
894 [Define to the type of arg 3 for send.])
895 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
896 [Define to the type of arg 4 for send.])
897 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
898 [Define to the function return type for send.])
902 case $prev_sh_opts in
910 case "$send_qual_type_arg2" in
913 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
917 send_type_arg2=$send_qual_type_arg2
921 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
922 [Define to the type qualifier of arg 2 for send.])
923 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
924 [Define to the type of arg 2 for send.])
926 case $prev_sh_opts in
934 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
935 [Define to 1 if you have the send function.])
936 ac_cv_func_send="yes"
939 AC_MSG_ERROR([Unable to link function send])
944 dnl CURL_CHECK_MSG_NOSIGNAL
945 dnl -------------------------------------------------
946 dnl Check for MSG_NOSIGNAL
948 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
949 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
950 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
954 #ifdef HAVE_WINDOWS_H
955 #ifndef WIN32_LEAN_AND_MEAN
956 #define WIN32_LEAN_AND_MEAN
959 #ifdef HAVE_WINSOCK2_H
960 #include <winsock2.h>
962 #ifdef HAVE_WINSOCK_H
967 #ifdef HAVE_SYS_TYPES_H
968 #include <sys/types.h>
970 #ifdef HAVE_SYS_SOCKET_H
971 #include <sys/socket.h>
975 int flag=MSG_NOSIGNAL;
978 ac_cv_msg_nosignal="yes"
980 ac_cv_msg_nosignal="no"
983 case "$ac_cv_msg_nosignal" in
985 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
986 [Define to 1 if you have the MSG_NOSIGNAL flag.])
992 dnl CURL_CHECK_STRUCT_TIMEVAL
993 dnl -------------------------------------------------
994 dnl Check for timeval struct
996 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
997 AC_REQUIRE([AC_HEADER_TIME])dnl
998 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
999 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1000 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1001 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1005 #ifdef HAVE_WINDOWS_H
1006 #ifndef WIN32_LEAN_AND_MEAN
1007 #define WIN32_LEAN_AND_MEAN
1009 #include <windows.h>
1010 #ifdef HAVE_WINSOCK2_H
1011 #include <winsock2.h>
1013 #ifdef HAVE_WINSOCK_H
1014 #include <winsock.h>
1018 #ifdef HAVE_SYS_TYPES_H
1019 #include <sys/types.h>
1021 #ifdef HAVE_SYS_TIME_H
1022 #include <sys/time.h>
1023 #ifdef TIME_WITH_SYS_TIME
1037 ac_cv_struct_timeval="yes"
1039 ac_cv_struct_timeval="no"
1042 case "$ac_cv_struct_timeval" in
1044 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1045 [Define to 1 if you have the timeval struct.])
1051 dnl TYPE_SIG_ATOMIC_T
1052 dnl -------------------------------------------------
1053 dnl Check if the sig_atomic_t type is available, and
1054 dnl verify if it is already defined as volatile.
1056 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1057 AC_CHECK_HEADERS(signal.h)
1058 AC_CHECK_TYPE([sig_atomic_t],[
1059 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1060 [Define to 1 if sig_atomic_t is an available typedef.])
1062 #ifdef HAVE_SIGNAL_H
1066 case "$ac_cv_type_sig_atomic_t" in
1069 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1071 #ifdef HAVE_SIGNAL_H
1075 static volatile sig_atomic_t dummy = 0;
1078 ac_cv_sig_atomic_t_volatile="no"
1080 AC_MSG_RESULT([yes])
1081 ac_cv_sig_atomic_t_volatile="yes"
1084 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1085 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1086 [Define to 1 if sig_atomic_t is already defined as volatile.])
1093 dnl CURL_CHECK_NONBLOCKING_SOCKET
1094 dnl -------------------------------------------------
1095 dnl Check for how to set a socket to non-blocking state. There seems to exist
1096 dnl four known different ways, with the one used almost everywhere being POSIX
1097 dnl and XPG3, while the other different ways for different systems (old BSD,
1098 dnl Windows and Amiga).
1100 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1101 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1102 dnl to get caught in this script by using an excessive number of #ifdefs...
1104 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
1106 AC_MSG_CHECKING([non-blocking sockets style])
1109 /* headers for O_NONBLOCK test */
1110 #include <sys/types.h>
1114 /* try to compile O_NONBLOCK */
1116 #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1117 # if defined(__SVR4) || defined(__srv4__)
1118 # define PLATFORM_SOLARIS
1120 # define PLATFORM_SUNOS4
1123 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
1124 # define PLATFORM_AIX_V3
1127 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1128 #error "O_NONBLOCK does not work on this platform"
1131 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1133 dnl the O_NONBLOCK test was fine
1134 nonblock="O_NONBLOCK"
1135 AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
1137 dnl the code was bad, try a different program now, test 2
1140 /* headers for FIONBIO test */
1142 #include <stropts.h>
1144 /* FIONBIO source test (old-style unix) */
1146 int flags = ioctl(socket, FIONBIO, &flags);
1148 dnl FIONBIO test was good
1150 AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
1152 dnl FIONBIO test was also bad
1153 dnl the code was bad, try a different program now, test 3
1156 /* headers for ioctlsocket test (Windows) */
1158 #ifdef HAVE_WINDOWS_H
1159 #ifndef WIN32_LEAN_AND_MEAN
1160 #define WIN32_LEAN_AND_MEAN
1162 #include <windows.h>
1163 #ifdef HAVE_WINSOCK2_H
1164 #include <winsock2.h>
1166 #ifdef HAVE_WINSOCK_H
1167 #include <winsock.h>
1172 /* ioctlsocket source code */
1174 unsigned long flags = 0;
1175 sd = socket(0, 0, 0);
1176 ioctlsocket(sd, FIONBIO, &flags);
1178 dnl ioctlsocket test was good
1179 nonblock="ioctlsocket"
1180 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
1182 dnl ioctlsocket didnt compile!, go to test 4
1185 /* headers for IoctlSocket test (Amiga?) */
1186 #include <sys/ioctl.h>
1188 /* IoctlSocket source code */
1190 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1192 dnl ioctlsocket test was good
1193 nonblock="IoctlSocket"
1194 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
1196 dnl Ioctlsocket didnt compile, do test 5!
1198 /* headers for SO_NONBLOCK test (BeOS) */
1201 /* SO_NONBLOCK source code */
1204 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1206 dnl the SO_NONBLOCK test was good
1207 nonblock="SO_NONBLOCK"
1208 AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
1210 dnl test 5 didnt compile!
1212 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
1214 dnl end of fifth test
1217 dnl end of forth test
1220 dnl end of third test
1223 dnl end of second test
1226 dnl end of non-blocking try-compile test
1227 AC_MSG_RESULT($nonblock)
1229 if test "$nonblock" = "nada"; then
1230 AC_MSG_WARN([non-block sockets disabled])
1236 dnl -------------------------------------------------
1237 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1238 dnl and a few other things.
1239 AC_DEFUN([TYPE_IN_ADDR_T],
1241 AC_CHECK_TYPE([in_addr_t], ,[
1242 AC_MSG_CHECKING([for in_addr_t equivalent])
1243 AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
1245 curl_cv_in_addr_t_equiv=
1246 for t in "unsigned long" int size_t unsigned long; do
1249 #ifdef HAVE_WINDOWS_H
1250 #ifndef WIN32_LEAN_AND_MEAN
1251 #define WIN32_LEAN_AND_MEAN
1253 #include <windows.h>
1254 #ifdef HAVE_WINSOCK2_H
1255 #include <winsock2.h>
1257 #ifdef HAVE_WINSOCK_H
1258 #include <winsock.h>
1262 #ifdef HAVE_SYS_TYPES_H
1263 #include <sys/types.h>
1265 #ifdef HAVE_SYS_SOCKET_H
1266 #include <sys/socket.h>
1268 #ifdef HAVE_NETINET_IN_H
1269 #include <netinet/in.h>
1271 #ifdef HAVE_ARPA_INET_H
1272 #include <arpa/inet.h>
1276 $t data = inet_addr ("1.2.3.4");
1278 curl_cv_in_addr_t_equiv="$t"
1283 if test "x$curl_cv_in_addr_t_equiv" = x; then
1284 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1287 AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
1288 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1289 [type to use in place of in_addr_t if not defined])],
1292 #ifdef HAVE_WINDOWS_H
1293 #ifndef WIN32_LEAN_AND_MEAN
1294 #define WIN32_LEAN_AND_MEAN
1296 #include <windows.h>
1297 #ifdef HAVE_WINSOCK2_H
1298 #include <winsock2.h>
1300 #ifdef HAVE_WINSOCK_H
1301 #include <winsock.h>
1305 #ifdef HAVE_SYS_TYPES_H
1306 #include <sys/types.h>
1308 #ifdef HAVE_SYS_SOCKET_H
1309 #include <sys/socket.h>
1311 #ifdef HAVE_NETINET_IN_H
1312 #include <netinet/in.h>
1314 #ifdef HAVE_ARPA_INET_H
1315 #include <arpa/inet.h>
1318 ]) dnl AC_CHECK_TYPE
1321 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1322 dnl -------------------------------------------------
1323 dnl Check if monotonic clock_gettime is available.
1325 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1326 AC_REQUIRE([AC_HEADER_TIME])dnl
1327 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1328 AC_MSG_CHECKING([for monotonic clock_gettime])
1331 #ifdef HAVE_SYS_TYPES_H
1332 #include <sys/types.h>
1334 #ifdef HAVE_SYS_TIME_H
1335 #include <sys/time.h>
1336 #ifdef TIME_WITH_SYS_TIME
1346 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1349 AC_MSG_RESULT([yes])
1350 ac_cv_func_clock_gettime="yes"
1353 ac_cv_func_clock_gettime="no"
1355 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally
1356 dnl postponed until library linking checks for clock_gettime pass.
1359 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1360 dnl -------------------------------------------------
1361 dnl If monotonic clock_gettime is available then,
1362 dnl check and prepended to LIBS any needed libraries.
1364 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1365 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1367 if test "$ac_cv_func_clock_gettime" = "yes"; then
1369 AC_MSG_CHECKING([for clock_gettime in libraries])
1371 curl_cv_save_LIBS="$LIBS"
1372 curl_cv_gclk_LIBS="unknown"
1374 for x_xlibs in '' '-lrt' '-lposix4' ; do
1375 if test -z "$x_xlibs"; then
1376 LIBS="$curl_cv_save_LIBS"
1378 LIBS="$x_xlibs $curl_cv_save_LIBS"
1382 #ifdef HAVE_SYS_TYPES_H
1383 #include <sys/types.h>
1385 #ifdef HAVE_SYS_TIME_H
1386 #include <sys/time.h>
1387 #ifdef TIME_WITH_SYS_TIME
1397 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1400 curl_cv_gclk_LIBS="$x_xlibs"
1405 LIBS="$curl_cv_save_LIBS"
1407 case X-"$curl_cv_gclk_LIBS" in
1409 AC_MSG_RESULT([cannot find clock_gettime])
1410 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1411 ac_cv_func_clock_gettime="no"
1414 AC_MSG_RESULT([no additional lib required])
1415 ac_cv_func_clock_gettime="yes"
1418 if test -z "$curl_cv_save_LIBS"; then
1419 LIBS="$curl_cv_gclk_LIBS"
1421 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1423 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1424 ac_cv_func_clock_gettime="yes"
1428 case "$ac_cv_func_clock_gettime" in
1430 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1431 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1439 dnl **********************************************************************
1440 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
1442 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
1443 dnl sets the $ICC variable to "yes" or "no"
1444 dnl **********************************************************************
1445 AC_DEFUN([CURL_DETECT_ICC],
1448 AC_MSG_CHECKING([for icc in use])
1449 if test "$GCC" = "yes"; then
1450 dnl check if this is icc acting as gcc in disguise
1451 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
1452 dnl action if the text is found, this it has not been replaced by the
1455 dnl the text was not found, it was replaced by the cpp
1457 AC_MSG_RESULT([yes])
1461 if test "$ICC" = "no"; then
1467 dnl We create a function for detecting which compiler we use and then set as
1468 dnl pendantic compiler options as possible for that particular compiler. The
1469 dnl options are only used for debug-builds.
1471 dnl This is a copy of the original found in curl's configure script. Don't
1472 dnl modify this one, edit the one in curl and copy it back here when that one
1475 AC_DEFUN([CURL_CC_DEBUG_OPTS],
1477 if test "z$ICC" = "z"; then
1481 if test "$GCC" = "yes"; then
1483 dnl figure out gcc version!
1484 AC_MSG_CHECKING([gcc version])
1485 gccver=`$CC -dumpversion`
1486 num1=`echo $gccver | cut -d . -f1`
1487 num2=`echo $gccver | cut -d . -f2`
1488 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
1489 AC_MSG_RESULT($gccver)
1491 if test "$ICC" = "yes"; then
1492 dnl this is icc, not gcc.
1494 dnl ICC warnings we ignore:
1495 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
1496 dnl "invalid format string conversion"
1497 dnl * 279 warns on static conditions in while expressions
1498 dnl * 981 warns on "operands are evaluated in unspecified order"
1499 dnl * 1418 "external definition with no prior declaration"
1500 dnl * 1419 warns on "external declaration in primary source file"
1501 dnl which we know and do on purpose.
1503 WARN="-wd279,269,981,1418,1419"
1505 if test "$gccnum" -gt "600"; then
1506 dnl icc 6.0 and older doesn't have the -Wall flag
1510 dnl this is a set of options we believe *ALL* gcc versions support:
1511 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
1513 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
1515 if test "$gccnum" -ge "207"; then
1516 dnl gcc 2.7 or later
1517 WARN="$WARN -Wmissing-declarations"
1520 if test "$gccnum" -gt "295"; then
1521 dnl only if the compiler is newer than 2.95 since we got lots of
1522 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
1523 dnl gcc 2.95.4 on FreeBSD 4.9!
1524 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
1527 if test "$gccnum" -ge "296"; then
1528 dnl gcc 2.96 or later
1529 WARN="$WARN -Wfloat-equal"
1532 if test "$gccnum" -gt "296"; then
1533 dnl this option does not exist in 2.96
1534 WARN="$WARN -Wno-format-nonliteral"
1537 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1538 dnl on i686-Linux as it gives us heaps with false positives.
1539 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
1540 dnl over making it unusable for generic purposes. Let's not use it.
1542 if test "$gccnum" -ge "303"; then
1543 dnl gcc 3.3 and later
1544 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
1547 if test "$gccnum" -ge "304"; then
1548 # try these on gcc 3.4
1549 WARN="$WARN -Wdeclaration-after-statement"
1552 for flag in $CPPFLAGS; do
1555 dnl Include path, provide a -isystem option for the same dir
1556 dnl to prevent warnings in those dirs. The -isystem was not very
1557 dnl reliable on earlier gcc versions.
1558 add=`echo $flag | sed 's/^-I/-isystem /g'`
1566 CFLAGS="$CFLAGS $WARN"
1568 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
1572 AC_MSG_NOTICE([Added no extra compiler options])
1576 dnl strip off optimizer flags
1578 for flag in $CFLAGS; do
1581 dnl echo "cut off $flag"
1584 NEWFLAGS="$NEWFLAGS $flag"
1590 ]) dnl end of AC_DEFUN()
1593 dnl This macro determines if the specified struct exists in the specified file
1595 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1597 AC_DEFUN([CARES_CHECK_STRUCT], [
1598 AC_MSG_CHECKING([for struct $2])
1599 AC_TRY_COMPILE([$1],
1601 struct $2 struct_instance;
1602 ], ac_struct="yes", ac_found="no")
1603 if test "$ac_struct" = "yes" ; then
1612 dnl This macro determines if the specified constant exists in the specified file
1614 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
1616 AC_DEFUN([CARES_CHECK_CONSTANT], [
1617 AC_MSG_CHECKING([for $2])
1618 AC_EGREP_CPP(VARIABLEWASDEFINED,
1627 ], ac_constant="yes", ac_constant="no"
1629 if test "$ac_constant" = "yes" ; then
1639 dnl This macro determines how many parameters getservbyport_r takes
1640 AC_DEFUN([CARES_CHECK_GETSERVBYPORT_R], [
1641 AC_MSG_CHECKING([how many arguments getservbyport_r takes])
1643 [#include <netdb.h>],
1647 struct servent *p3, *p6;
1648 getservbyport_r(p1, p2, p3, p4, p5, &p6);
1649 ], ac_func_getservbyport_r=6,
1651 [#include <netdb.h>],
1656 getservbyport_r(p1, p2, p3, p4, p5);
1657 ], ac_func_getservbyport_r=5,
1659 [#include <netdb.h>],
1664 struct servent_data p4;
1665 getservbyport_r(p1, p2, p3, &p4);
1666 ], ac_func_getservbyport_r=4, ac_func_getservbyport_r=0
1670 if test $ac_func_getservbyport_r != "0" ; then
1671 AC_MSG_RESULT($ac_func_getservbyport_r)
1672 AC_DEFINE(HAVE_GETSERVBYPORT_R, 1, [Specifies whether getservbyport_r is present])
1673 AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $ac_func_getservbyport_r, [Specifies the number of arguments to
1675 if test $ac_func_getservbyport_r = "4" ; then
1676 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data), [Specifies the size of the buffer to pass to
1679 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096, [Specifies the size of the buffer to pass to getservbyport_r])
1682 AC_MSG_RESULT([not found])