3 dnl CURL_CHECK_HEADERS_ONCE
4 dnl -------------------------------------------------
5 dnl Check for headers if check not already done.
7 AC_DEFUN([CURL_CHECK_HEADERS_ONCE], [
10 u_hdr=`echo "$f_hdr" | sed 'y/\.\/-/___/'`
11 eval prev_check_res=\$ac_cv_header_$u_hdr
12 case "$prev_check_res" in
16 AC_CHECK_HEADERS($f_hdr)
23 dnl CURL_CHECK_HEADER_WINDOWS
24 dnl -------------------------------------------------
25 dnl Check for compilable and valid windows.h header
27 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
28 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
32 #ifndef WIN32_LEAN_AND_MEAN
33 #define WIN32_LEAN_AND_MEAN
38 HAVE_WINDOWS_H shall not be defined.
44 ac_cv_header_windows_h="yes"
46 ac_cv_header_windows_h="no"
49 if test "x$ac_cv_header_windows_h" = "xyes"; then
50 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
51 [Define to 1 if you have the windows.h header file.])
52 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
53 [Define to avoid automatic inclusion of winsock.h])
58 dnl CURL_CHECK_HEADER_WINSOCK
59 dnl -------------------------------------------------
60 dnl Check for compilable and valid winsock.h header
62 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
63 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
64 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
68 #ifndef WIN32_LEAN_AND_MEAN
69 #define WIN32_LEAN_AND_MEAN
75 HAVE_WINSOCK_H shall not be defined.
77 int dummy=WSACleanup();
81 ac_cv_header_winsock_h="yes"
83 ac_cv_header_winsock_h="no"
86 if test "x$ac_cv_header_winsock_h" = "xyes"; then
87 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
88 [Define to 1 if you have the winsock.h header file.])
93 dnl CURL_CHECK_HEADER_WINSOCK2
94 dnl -------------------------------------------------
95 dnl Check for compilable and valid winsock2.h header
97 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
98 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
99 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
103 #ifndef WIN32_LEAN_AND_MEAN
104 #define WIN32_LEAN_AND_MEAN
107 #include <winsock2.h>
110 HAVE_WINSOCK2_H shall not be defined.
112 int dummy=2*IPPROTO_ESP;
116 ac_cv_header_winsock2_h="yes"
118 ac_cv_header_winsock2_h="no"
121 if test "x$ac_cv_header_winsock2_h" = "xyes"; then
122 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
123 [Define to 1 if you have the winsock2.h header file.])
128 dnl CURL_CHECK_HEADER_WS2TCPIP
129 dnl -------------------------------------------------
130 dnl Check for compilable and valid ws2tcpip.h header
132 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
133 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
134 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
138 #ifndef WIN32_LEAN_AND_MEAN
139 #define WIN32_LEAN_AND_MEAN
142 #include <winsock2.h>
143 #include <ws2tcpip.h>
146 HAVE_WS2TCPIP_H shall not be defined.
148 int dummy=2*IP_PKTINFO;
152 ac_cv_header_ws2tcpip_h="yes"
154 ac_cv_header_ws2tcpip_h="no"
157 if test "x$ac_cv_header_ws2tcpip_h" = "xyes"; then
158 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
159 [Define to 1 if you have the ws2tcpip.h header file.])
164 dnl CURL_CHECK_TYPE_SOCKLEN_T
165 dnl -------------------------------------------------
166 dnl Check for existing socklen_t type, and provide
167 dnl an equivalent type if socklen_t not available
169 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
170 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
171 AC_CHECK_TYPE([socklen_t], ,[
172 AC_CACHE_CHECK([for socklen_t equivalent],
173 [curl_cv_socklen_t_equiv], [
174 curl_cv_socklen_t_equiv="unknown"
175 for arg2 in "struct sockaddr" void; do
176 for t in int size_t unsigned long "unsigned long"; do
180 #ifdef HAVE_WINDOWS_H
181 #ifndef WIN32_LEAN_AND_MEAN
182 #define WIN32_LEAN_AND_MEAN
185 #ifdef HAVE_WINSOCK2_H
186 #include <winsock2.h>
188 #ifdef HAVE_WINSOCK_H
193 #ifdef HAVE_SYS_TYPES_H
194 #include <sys/types.h>
196 #ifdef HAVE_SYS_SOCKET_H
197 #include <sys/socket.h>
200 int getpeername (int, $arg2 *, $t *);
203 getpeername(0,0,&len);
206 curl_cv_socklen_t_equiv="$t"
212 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
213 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
215 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
216 [type to use in place of socklen_t if not defined])
220 #ifdef HAVE_WINDOWS_H
221 #ifndef WIN32_LEAN_AND_MEAN
222 #define WIN32_LEAN_AND_MEAN
225 #ifdef HAVE_WINSOCK2_H
226 #include <winsock2.h>
227 #ifdef HAVE_WS2TCPIP_H
228 #include <ws2tcpip.h>
232 #ifdef HAVE_SYS_TYPES_H
233 #include <sys/types.h>
235 #ifdef HAVE_SYS_SOCKET_H
236 #include <sys/socket.h>
243 dnl CURL_CHECK_FUNC_GETNAMEINFO
244 dnl -------------------------------------------------
245 dnl Test if the getnameinfo function is available,
246 dnl and check the types of five of its arguments.
247 dnl If the function succeeds HAVE_GETNAMEINFO will be
248 dnl defined, defining the types of the arguments in
249 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
250 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
251 dnl and also defining the type qualifier of first
252 dnl argument in GETNAMEINFO_QUAL_ARG1.
254 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
255 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
256 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
257 CURL_CHECK_HEADERS_ONCE(sys/types.h sys/socket.h netdb.h)
259 AC_MSG_CHECKING([for getnameinfo])
261 AC_LANG_FUNC_LINK_TRY([getnameinfo])
264 curl_cv_getnameinfo="yes"
267 curl_cv_getnameinfo="no"
270 if test "$curl_cv_getnameinfo" != "yes"; then
271 AC_MSG_CHECKING([deeper for getnameinfo])
277 curl_cv_getnameinfo="yes"
279 AC_MSG_RESULT([but still no])
280 curl_cv_getnameinfo="no"
284 if test "$curl_cv_getnameinfo" != "yes"; then
285 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
288 #ifdef HAVE_WINDOWS_H
289 #ifndef WIN32_LEAN_AND_MEAN
290 #define WIN32_LEAN_AND_MEAN
293 #ifdef HAVE_WINSOCK2_H
294 #include <winsock2.h>
295 #ifdef HAVE_WS2TCPIP_H
296 #include <ws2tcpip.h>
300 #ifdef HAVE_SYS_TYPES_H
301 #include <sys/types.h>
303 #ifdef HAVE_SYS_SOCKET_H
304 #include <sys/socket.h>
311 getnameinfo(0, 0, 0, 0, 0, 0, 0);
314 curl_cv_getnameinfo="yes"
316 AC_MSG_RESULT([but still no])
317 curl_cv_getnameinfo="no"
321 if test "$curl_cv_getnameinfo" = "yes"; then
322 AC_CACHE_CHECK([types of arguments for getnameinfo],
323 [curl_cv_func_getnameinfo_args], [
324 curl_cv_func_getnameinfo_args="unknown"
325 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
326 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
327 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
328 for gni_arg7 in 'int' 'unsigned int'; do
332 #ifdef HAVE_WINDOWS_H
333 #ifndef WIN32_LEAN_AND_MEAN
334 #define WIN32_LEAN_AND_MEAN
336 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
338 #define _WIN32_WINNT 0x0501
341 #ifdef HAVE_WINSOCK2_H
342 #include <winsock2.h>
343 #ifdef HAVE_WS2TCPIP_H
344 #include <ws2tcpip.h>
347 #define GNICALLCONV WSAAPI
349 #ifdef HAVE_SYS_TYPES_H
350 #include <sys/types.h>
352 #ifdef HAVE_SYS_SOCKET_H
353 #include <sys/socket.h>
360 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
366 $gni_arg46 hostlen=0;
367 $gni_arg46 servlen=0;
369 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
372 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
380 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
381 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
382 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
384 gni_prev_IFS=$IFS; IFS=','
385 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
389 gni_qual_type_arg1=$[1]
391 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
392 [Define to the type of arg 2 for getnameinfo.])
393 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
394 [Define to the type of args 4 and 6 for getnameinfo.])
395 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
396 [Define to the type of arg 7 for getnameinfo.])
400 case $prev_sh_opts in
408 case "$gni_qual_type_arg1" in
411 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
415 gni_type_arg1=$gni_qual_type_arg1
419 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
420 [Define to the type qualifier of arg 1 for getnameinfo.])
421 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
422 [Define to the type of arg 1 for getnameinfo.])
424 case $prev_sh_opts in
432 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
433 [Define to 1 if you have the getnameinfo function.])
434 ac_cv_func_getnameinfo="yes"
440 dnl TYPE_SOCKADDR_STORAGE
441 dnl -------------------------------------------------
442 dnl Check for struct sockaddr_storage. Most IPv6-enabled
443 dnl hosts have it, but AIX 4.3 is one known exception.
445 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
447 AC_CHECK_TYPE([struct sockaddr_storage],
448 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
449 [if struct sockaddr_storage is defined]), ,
452 #ifdef HAVE_WINDOWS_H
453 #ifndef WIN32_LEAN_AND_MEAN
454 #define WIN32_LEAN_AND_MEAN
457 #ifdef HAVE_WINSOCK2_H
458 #include <winsock2.h>
461 #ifdef HAVE_SYS_TYPES_H
462 #include <sys/types.h>
464 #ifdef HAVE_SYS_SOCKET_H
465 #include <sys/socket.h>
467 #ifdef HAVE_NETINET_IN_H
468 #include <netinet/in.h>
470 #ifdef HAVE_ARPA_INET_H
471 #include <arpa/inet.h>
478 dnl CURL_CHECK_NI_WITHSCOPEID
479 dnl -------------------------------------------------
480 dnl Check for working NI_WITHSCOPEID in getnameinfo()
482 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
483 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
484 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
485 CURL_CHECK_HEADERS_ONCE(stdio.h sys/types.h sys/socket.h \
486 netdb.h netinet/in.h arpa/inet.h)
488 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
489 [ac_cv_working_ni_withscopeid], [
495 #ifdef HAVE_SYS_TYPES_H
496 #include <sys/types.h>
498 #ifdef HAVE_SYS_SOCKET_H
499 #include <sys/socket.h>
504 #ifdef HAVE_NETINET_IN_H
505 #include <netinet/in.h>
507 #ifdef HAVE_ARPA_INET_H
508 #include <arpa/inet.h>
511 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
512 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
513 struct sockaddr_storage sa;
515 unsigned char sa[256];
517 char hostbuf[NI_MAXHOST];
519 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
520 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
521 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
522 int fd = socket(AF_INET6, SOCK_STREAM, 0);
525 return 1; /* Error creating socket */
527 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
529 perror("getsockname()");
530 return 2; /* Error retrieving socket name */
532 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
534 printf("rc = %s\n", gai_strerror(rc));
535 return 3; /* Error translating socket address */
537 return 0; /* Ok, NI_WITHSCOPEID works */
539 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
543 # Exit code == 0. Program worked.
544 ac_cv_working_ni_withscopeid="yes"
546 # Exit code != 0. Program failed.
547 ac_cv_working_ni_withscopeid="no"
549 # Program is not run when cross-compiling. So we assume
550 # NI_WITHSCOPEID will work if we are able to compile it.
553 #include <sys/types.h>
554 #include <sys/socket.h>
557 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
560 ac_cv_working_ni_withscopeid="yes"
562 ac_cv_working_ni_withscopeid="no"
563 ]) # AC_COMPILE_IFELSE
566 if test "x$ac_cv_working_ni_withscopeid" = "xyes"; then
567 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
568 [Define to 1 if NI_WITHSCOPEID exists and works.])
573 dnl CURL_CHECK_FUNC_RECV
574 dnl -------------------------------------------------
575 dnl Test if the socket recv() function is available,
576 dnl and check its return type and the types of its
577 dnl arguments. If the function succeeds HAVE_RECV
578 dnl will be defined, defining the types of the arguments
579 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
580 dnl and RECV_TYPE_ARG4, defining the type of the function
581 dnl return value in RECV_TYPE_RETV.
583 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
584 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
585 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
586 CURL_CHECK_HEADERS_ONCE(sys/types.h sys/socket.h)
588 AC_MSG_CHECKING([for recv])
591 #ifdef HAVE_WINDOWS_H
592 #ifndef WIN32_LEAN_AND_MEAN
593 #define WIN32_LEAN_AND_MEAN
596 #ifdef HAVE_WINSOCK2_H
597 #include <winsock2.h>
599 #ifdef HAVE_WINSOCK_H
604 #ifdef HAVE_SYS_TYPES_H
605 #include <sys/types.h>
607 #ifdef HAVE_SYS_SOCKET_H
608 #include <sys/socket.h>
621 if test "$curl_cv_recv" = "yes"; then
622 AC_CACHE_CHECK([types of arguments and return type for recv],
623 [curl_cv_func_recv_args], [
624 curl_cv_func_recv_args="unknown"
625 for recv_retv in 'int' 'ssize_t'; do
626 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
627 for recv_arg2 in 'char *' 'void *'; do
628 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
629 for recv_arg4 in 'int' 'unsigned int'; do
633 #ifdef HAVE_WINDOWS_H
634 #ifndef WIN32_LEAN_AND_MEAN
635 #define WIN32_LEAN_AND_MEAN
638 #ifdef HAVE_WINSOCK2_H
639 #include <winsock2.h>
641 #ifdef HAVE_WINSOCK_H
645 #define RECVCALLCONV PASCAL
647 #ifdef HAVE_SYS_TYPES_H
648 #include <sys/types.h>
650 #ifdef HAVE_SYS_SOCKET_H
651 #include <sys/socket.h>
655 extern $recv_retv RECVCALLCONV recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
661 $recv_retv res = recv(s, buf, len, flags);
664 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
673 if test "$curl_cv_func_recv_args" = "unknown"; then
674 AC_MSG_WARN([Cannot find proper types to use for recv args])
675 AC_MSG_WARN([HAVE_RECV will not be defined])
677 recv_prev_IFS=$IFS; IFS=','
678 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
682 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
683 [Define to the type of arg 1 for recv.])
684 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
685 [Define to the type of arg 2 for recv.])
686 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
687 [Define to the type of arg 3 for recv.])
688 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
689 [Define to the type of arg 4 for recv.])
690 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
691 [Define to the function return type for recv.])
693 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
694 [Define to 1 if you have the recv function.])
695 ac_cv_func_recv="yes"
701 dnl CURL_CHECK_FUNC_SEND
702 dnl -------------------------------------------------
703 dnl Test if the socket send() function is available,
704 dnl and check its return type and the types of its
705 dnl arguments. If the function succeeds HAVE_SEND
706 dnl will be defined, defining the types of the arguments
707 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
708 dnl and SEND_TYPE_ARG4, defining the type of the function
709 dnl return value in SEND_TYPE_RETV, and also defining the
710 dnl type qualifier of second argument in SEND_QUAL_ARG2.
712 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
713 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
714 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
715 CURL_CHECK_HEADERS_ONCE(sys/types.h sys/socket.h)
717 AC_MSG_CHECKING([for send])
720 #ifdef HAVE_WINDOWS_H
721 #ifndef WIN32_LEAN_AND_MEAN
722 #define WIN32_LEAN_AND_MEAN
725 #ifdef HAVE_WINSOCK2_H
726 #include <winsock2.h>
728 #ifdef HAVE_WINSOCK_H
733 #ifdef HAVE_SYS_TYPES_H
734 #include <sys/types.h>
736 #ifdef HAVE_SYS_SOCKET_H
737 #include <sys/socket.h>
750 if test "$curl_cv_send" = "yes"; then
751 AC_CACHE_CHECK([types of arguments and return type for send],
752 [curl_cv_func_send_args], [
753 curl_cv_func_send_args="unknown"
754 for send_retv in 'int' 'ssize_t'; do
755 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
756 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
757 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
758 for send_arg4 in 'int' 'unsigned int'; do
762 #ifdef HAVE_WINDOWS_H
763 #ifndef WIN32_LEAN_AND_MEAN
764 #define WIN32_LEAN_AND_MEAN
767 #ifdef HAVE_WINSOCK2_H
768 #include <winsock2.h>
770 #ifdef HAVE_WINSOCK_H
774 #define SENDCALLCONV PASCAL
776 #ifdef HAVE_SYS_TYPES_H
777 #include <sys/types.h>
779 #ifdef HAVE_SYS_SOCKET_H
780 #include <sys/socket.h>
784 extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
789 $send_retv res = send(s, 0, len, flags);
792 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
801 if test "$curl_cv_func_send_args" = "unknown"; then
802 AC_MSG_WARN([Cannot find proper types to use for send args])
803 AC_MSG_WARN([HAVE_SEND will not be defined])
805 send_prev_IFS=$IFS; IFS=','
806 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
810 send_qual_type_arg2=$[2]
812 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
813 [Define to the type of arg 1 for send.])
814 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
815 [Define to the type of arg 3 for send.])
816 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
817 [Define to the type of arg 4 for send.])
818 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
819 [Define to the function return type for send.])
823 case $prev_sh_opts in
831 case "$send_qual_type_arg2" in
834 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
838 send_type_arg2=$send_qual_type_arg2
842 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
843 [Define to the type qualifier of arg 2 for send.])
844 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
845 [Define to the type of arg 2 for send.])
847 case $prev_sh_opts in
855 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
856 [Define to 1 if you have the send function.])
857 ac_cv_func_send="yes"
863 dnl CURL_CHECK_NONBLOCKING_SOCKET
864 dnl -------------------------------------------------
865 dnl Check for how to set a socket to non-blocking state. There seems to exist
866 dnl four known different ways, with the one used almost everywhere being POSIX
867 dnl and XPG3, while the other different ways for different systems (old BSD,
868 dnl Windows and Amiga).
870 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
871 dnl O_NONBLOCK define is found but does not work. This condition is attempted
872 dnl to get caught in this script by using an excessive number of #ifdefs...
874 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
876 AC_MSG_CHECKING([non-blocking sockets style])
879 /* headers for O_NONBLOCK test */
880 #include <sys/types.h>
884 /* try to compile O_NONBLOCK */
886 #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
887 # if defined(__SVR4) || defined(__srv4__)
888 # define PLATFORM_SOLARIS
890 # define PLATFORM_SUNOS4
893 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4)
894 # define PLATFORM_AIX_V3
897 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
898 #error "O_NONBLOCK does not work on this platform"
901 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
903 dnl the O_NONBLOCK test was fine
904 nonblock="O_NONBLOCK"
905 AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
907 dnl the code was bad, try a different program now, test 2
910 /* headers for FIONBIO test */
914 /* FIONBIO source test (old-style unix) */
916 int flags = ioctl(socket, FIONBIO, &flags);
918 dnl FIONBIO test was good
920 AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
922 dnl FIONBIO test was also bad
923 dnl the code was bad, try a different program now, test 3
926 /* headers for ioctlsocket test (Windows) */
928 #ifdef HAVE_WINDOWS_H
929 #ifndef WIN32_LEAN_AND_MEAN
930 #define WIN32_LEAN_AND_MEAN
933 #ifdef HAVE_WINSOCK2_H
934 #include <winsock2.h>
936 #ifdef HAVE_WINSOCK_H
942 /* ioctlsocket source code */
944 unsigned long flags = 0;
945 sd = socket(0, 0, 0);
946 ioctlsocket(sd, FIONBIO, &flags);
948 dnl ioctlsocket test was good
949 nonblock="ioctlsocket"
950 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
952 dnl ioctlsocket didnt compile!, go to test 4
955 /* headers for IoctlSocket test (Amiga?) */
956 #include <sys/ioctl.h>
958 /* IoctlSocket source code */
960 int flags = IoctlSocket(socket, FIONBIO, (long)1);
962 dnl ioctlsocket test was good
963 nonblock="IoctlSocket"
964 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
966 dnl Ioctlsocket didnt compile, do test 5!
968 /* headers for SO_NONBLOCK test (BeOS) */
971 /* SO_NONBLOCK source code */
974 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
976 dnl the SO_NONBLOCK test was good
977 nonblock="SO_NONBLOCK"
978 AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
980 dnl test 5 didnt compile!
982 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
984 dnl end of fifth test
987 dnl end of forth test
990 dnl end of third test
993 dnl end of second test
996 dnl end of non-blocking try-compile test
997 AC_MSG_RESULT($nonblock)
999 if test "$nonblock" = "nada"; then
1000 AC_MSG_WARN([non-block sockets disabled])
1005 dnl TYPE_SOCKADDR_STORAGE
1006 dnl -------------------------------------------------
1007 dnl Check for struct sockaddr_storage. Most IPv6-enabled hosts have it, but
1008 dnl AIX 4.3 is one known exception.
1009 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1011 AC_CHECK_TYPE([struct sockaddr_storage],
1012 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1013 [if struct sockaddr_storage is defined]), ,
1016 #ifdef HAVE_WINDOWS_H
1017 #ifndef WIN32_LEAN_AND_MEAN
1018 #define WIN32_LEAN_AND_MEAN
1020 #include <windows.h>
1021 #ifdef HAVE_WINSOCK2_H
1022 #include <winsock2.h>
1025 #ifdef HAVE_SYS_TYPES_H
1026 #include <sys/types.h>
1028 #ifdef HAVE_SYS_SOCKET_H
1029 #include <sys/socket.h>
1031 #ifdef HAVE_NETINET_IN_H
1032 #include <netinet/in.h>
1034 #ifdef HAVE_ARPA_INET_H
1035 #include <arpa/inet.h>
1043 dnl -------------------------------------------------
1044 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1045 dnl and a few other things.
1046 AC_DEFUN([TYPE_IN_ADDR_T],
1048 AC_CHECK_TYPE([in_addr_t], ,[
1049 AC_MSG_CHECKING([for in_addr_t equivalent])
1050 AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
1052 curl_cv_in_addr_t_equiv=
1053 for t in "unsigned long" int size_t unsigned long; do
1056 #ifdef HAVE_WINDOWS_H
1057 #ifndef WIN32_LEAN_AND_MEAN
1058 #define WIN32_LEAN_AND_MEAN
1060 #include <windows.h>
1061 #ifdef HAVE_WINSOCK2_H
1062 #include <winsock2.h>
1064 #ifdef HAVE_WINSOCK_H
1065 #include <winsock.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>
1083 $t data = inet_addr ("1.2.3.4");
1085 curl_cv_in_addr_t_equiv="$t"
1090 if test "x$curl_cv_in_addr_t_equiv" = x; then
1091 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1094 AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
1095 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1096 [type to use in place of in_addr_t if not defined])],
1099 #ifdef HAVE_WINDOWS_H
1100 #ifndef WIN32_LEAN_AND_MEAN
1101 #define WIN32_LEAN_AND_MEAN
1103 #include <windows.h>
1104 #ifdef HAVE_WINSOCK2_H
1105 #include <winsock2.h>
1107 #ifdef HAVE_WINSOCK_H
1108 #include <winsock.h>
1112 #ifdef HAVE_SYS_TYPES_H
1113 #include <sys/types.h>
1115 #ifdef HAVE_SYS_SOCKET_H
1116 #include <sys/socket.h>
1118 #ifdef HAVE_NETINET_IN_H
1119 #include <netinet/in.h>
1121 #ifdef HAVE_ARPA_INET_H
1122 #include <arpa/inet.h>
1126 ]) dnl AC_CHECK_TYPE
1130 dnl We create a function for detecting which compiler we use and then set as
1131 dnl pendantic compiler options as possible for that particular compiler. The
1132 dnl options are only used for debug-builds.
1134 dnl This is a copy of the original found in curl's configure script. Don't
1135 dnl modify this one, edit the one in curl and copy it back here when that one
1138 AC_DEFUN([CURL_CC_DEBUG_OPTS],
1140 if test "$GCC" = "yes"; then
1142 dnl figure out gcc version!
1143 AC_MSG_CHECKING([gcc version])
1144 gccver=`$CC -dumpversion`
1145 num1=`echo $gccver | cut -d . -f1`
1146 num2=`echo $gccver | cut -d . -f2`
1147 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
1148 AC_MSG_RESULT($gccver)
1150 AC_MSG_CHECKING([if this is icc in disguise])
1151 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
1152 dnl action if the text is found, this it has not been replaced by the
1155 AC_MSG_RESULT([no]),
1156 dnl the text was not found, it was replaced by the cpp
1158 AC_MSG_RESULT([yes])
1161 if test "$ICC" = "yes"; then
1162 dnl this is icc, not gcc.
1164 dnl ICC warnings we ignore:
1165 dnl * 279 warns on static conditions in while expressions
1166 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
1167 dnl "invalid format string conversion"
1171 if test "$gccnum" -gt "600"; then
1172 dnl icc 6.0 and older doesn't have the -Wall flag
1177 WARN="-W -Wall -Wwrite-strings -pedantic -Wno-long-long -Wundef -Wpointer-arith -Wnested-externs -Winline -Wmissing-declarations -Wmissing-prototypes -Wsign-compare"
1179 dnl -Wcast-align is a bit too annoying ;-)
1181 if test "$gccnum" -ge "296"; then
1182 dnl gcc 2.96 or later
1183 WARN="$WARN -Wfloat-equal"
1185 if test "$gccnum" -gt "296"; then
1186 dnl this option does not exist in 2.96
1187 WARN="$WARN -Wno-format-nonliteral"
1190 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1191 dnl on i686-Linux as it gives us heaps with false positives
1192 if test "$gccnum" -ge "303"; then
1193 dnl gcc 3.3 and later
1194 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
1198 for flag in $CPPFLAGS; do
1202 add=`echo $flag | sed 's/^-I/-isystem /g'`
1210 CFLAGS="$CFLAGS $WARN"
1214 dnl strip off optimizer flags
1216 for flag in $CFLAGS; do
1219 dnl echo "cut off $flag"
1222 NEWFLAGS="$NEWFLAGS $flag"
1228 ]) dnl end of AC_DEFUN()
1231 dnl This macro determines if the specified struct exists in the specified file
1233 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1235 AC_DEFUN([CARES_CHECK_STRUCT], [
1236 AC_MSG_CHECKING([for struct $2])
1237 AC_TRY_COMPILE([$1],
1239 struct $2 struct_instance;
1240 ], ac_struct="yes", ac_found="no")
1241 if test "$ac_struct" = "yes" ; then
1250 dnl This macro determines if the specified constant exists in the specified file
1252 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
1254 AC_DEFUN([CARES_CHECK_CONSTANT], [
1255 AC_MSG_CHECKING([for $2])
1256 AC_EGREP_CPP(VARIABLEWASDEFINED,
1265 ], ac_constant="yes", ac_constant="no"
1267 if test "$ac_constant" = "yes" ; then
1277 dnl This macro determines how many parameters getservbyport_r takes
1278 AC_DEFUN([CARES_CHECK_GETSERVBYPORT_R], [
1279 AC_MSG_CHECKING([how many arguments getservbyport_r takes])
1281 [#include <netdb.h>],
1285 struct servent *p3, *p6;
1286 getservbyport_r(p1, p2, p3, p4, p5, &p6);
1287 ], ac_func_getservbyport_r=6,
1289 [#include <netdb.h>],
1294 getservbyport_r(p1, p2, p3, p4, p5);
1295 ], ac_func_getservbyport_r=5,
1297 [#include <netdb.h>],
1302 struct servent_data p4;
1303 getservbyport_r(p1, p2, p3, &p4);
1304 ], ac_func_getservbyport_r=4, ac_func_getservbyport_r=0
1308 if test $ac_func_getservbyport_r != "0" ; then
1309 AC_MSG_RESULT($ac_func_getservbyport_r)
1310 AC_DEFINE(HAVE_GETSERVBYPORT_R, 1, [Specifies whether getservbyport_r is present])
1311 AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $ac_func_getservbyport_r, [Specifies the number of arguments to
1313 if test $ac_func_getservbyport_r = "4" ; then
1314 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data), [Specifies the size of the buffer to pass to
1317 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096, [Specifies the size of the buffer to pass to getservbyport_r])
1320 AC_MSG_RESULT([not found])
1324 # Prevent libtool for checking how to run C++ compiler and check for other
1325 # tools we don't want to use. We do this by m4-defining the _LT_AC_TAGCONFIG
1326 # variable to the code to run, as by default it uses a much more complicated
1327 # approach. The code below that is actually added seems to be used for cases
1328 # where configure has trouble figuring out what C compiler to use but where
1329 # the installed libtool has an idea.
1331 # This function is a re-implemented version of the Paolo Bonzini fix posted to
1332 # the c-ares mailing list by Bram Matthys on May 6 2006. My version removes
1333 # redundant code but also adds the LTCFLAGS check that wasn't in that patch.
1335 # Some code in this function was extracted from the generated configure script.
1337 # CARES_CLEAR_LIBTOOL_TAGS
1338 AC_DEFUN([CARES_CLEAR_LIBTOOL_TAGS],
1339 [m4_define([_LT_AC_TAGCONFIG], [
1340 if test -f "$ltmain"; then
1341 if test ! -f "${ofile}"; then
1342 AC_MSG_WARN([output file `$ofile' does not exist])
1345 if test -z "$LTCC"; then
1346 eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
1347 if test -z "$LTCC"; then
1348 AC_MSG_WARN([output file `$ofile' does not look like a libtool
1351 AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
1354 if test -z "$LTCFLAGS"; then
1355 eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"