3 dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
4 dnl -------------------------------------------------
5 dnl Use the C preprocessor to find out if the given object-style symbol
6 dnl is defined and get its expansion. This macro will not use default
7 dnl includes even if no INCLUDES argument is given. This macro will run
8 dnl silently when invoked with three arguments. If the expansion would
9 dnl result in a set of double-quoted strings the returned expansion will
10 dnl actually be a single double-quoted string concatenating all them.
12 AC_DEFUN([CURL_CHECK_DEF], [
13 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
14 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
15 if test -z "$SED"; then
16 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
18 if test -z "$GREP"; then
19 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
21 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
31 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
32 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
33 "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
34 "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
35 if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
39 if test -z "$tmp_exp"; then
40 AS_VAR_SET(ac_HaveDef, no)
41 ifelse($3,,[AC_MSG_RESULT([no])])
43 AS_VAR_SET(ac_HaveDef, yes)
44 AS_VAR_SET(ac_Def, $tmp_exp)
45 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
47 AS_VAR_POPDEF([ac_Def])dnl
48 AS_VAR_POPDEF([ac_HaveDef])dnl
52 dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
53 dnl -------------------------------------------------
54 dnl Use the C compiler to find out only if the given symbol is defined
55 dnl or not, this can not find out its expansion. This macro will not use
56 dnl default includes even if no INCLUDES argument is given. This macro
57 dnl will run silently when invoked with three arguments.
59 AC_DEFUN([CURL_CHECK_DEF_CC], [
60 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
61 ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
70 force compilation error
75 tst_symbol_defined="yes"
77 tst_symbol_defined="no"
79 if test "$tst_symbol_defined" = "yes"; then
80 AS_VAR_SET(ac_HaveDef, yes)
81 ifelse($3,,[AC_MSG_RESULT([yes])])
83 AS_VAR_SET(ac_HaveDef, no)
84 ifelse($3,,[AC_MSG_RESULT([no])])
86 AS_VAR_POPDEF([ac_HaveDef])dnl
90 dnl CARES_CHECK_LIB_XNET
91 dnl -------------------------------------------------
92 dnl Verify if X/Open network library is required.
94 AC_DEFUN([CARES_CHECK_LIB_XNET], [
95 AC_MSG_CHECKING([if X/Open network library is required])
96 tst_lib_xnet_required="no"
101 #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
103 #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
106 force compilation error
111 tst_lib_xnet_required="yes"
114 AC_MSG_RESULT([$tst_lib_xnet_required])
118 dnl CARES_CHECK_AIX_ALL_SOURCE
119 dnl -------------------------------------------------
120 dnl Provides a replacement of traditional AC_AIX with
121 dnl an uniform behaviour across all autoconf versions,
122 dnl and with our own placement rules.
124 AC_DEFUN([CARES_CHECK_AIX_ALL_SOURCE], [
125 AH_VERBATIM([_ALL_SOURCE],
126 [/* Define to 1 if OS is AIX. */
130 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
131 AC_BEFORE([$0], [CARES_CONFIGURE_REENTRANT])dnl
132 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
133 AC_EGREP_CPP([yes_this_is_aix],[
139 AC_DEFINE(_ALL_SOURCE)
146 dnl CURL_CHECK_HEADER_WINDOWS
147 dnl -------------------------------------------------
148 dnl Check for compilable and valid windows.h header
150 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
151 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
155 #ifndef WIN32_LEAN_AND_MEAN
156 #define WIN32_LEAN_AND_MEAN
160 #if defined(__CYGWIN__) || defined(__CEGCC__)
161 HAVE_WINDOWS_H shall not be defined.
167 ac_cv_header_windows_h="yes"
169 ac_cv_header_windows_h="no"
172 case "$ac_cv_header_windows_h" in
174 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
175 [Define to 1 if you have the windows.h header file.])
176 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
177 [Define to avoid automatic inclusion of winsock.h])
183 dnl CURL_CHECK_NATIVE_WINDOWS
184 dnl -------------------------------------------------
185 dnl Check if building a native Windows target
187 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
188 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
189 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
190 if test "$ac_cv_header_windows_h" = "no"; then
191 ac_cv_native_windows="no"
196 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
197 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
200 Not a native Windows build target.
204 ac_cv_native_windows="yes"
206 ac_cv_native_windows="no"
210 AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$ac_cv_native_windows" = xyes)
214 dnl CURL_CHECK_HEADER_WINSOCK
215 dnl -------------------------------------------------
216 dnl Check for compilable and valid winsock.h header
218 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
219 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
220 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
224 #ifndef WIN32_LEAN_AND_MEAN
225 #define WIN32_LEAN_AND_MEAN
230 #if defined(__CYGWIN__) || defined(__CEGCC__)
231 HAVE_WINSOCK_H shall not be defined.
233 int dummy=WSACleanup();
237 ac_cv_header_winsock_h="yes"
239 ac_cv_header_winsock_h="no"
242 case "$ac_cv_header_winsock_h" in
244 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
245 [Define to 1 if you have the winsock.h header file.])
251 dnl CURL_CHECK_HEADER_WINSOCK2
252 dnl -------------------------------------------------
253 dnl Check for compilable and valid winsock2.h header
255 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
256 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
257 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
261 #ifndef WIN32_LEAN_AND_MEAN
262 #define WIN32_LEAN_AND_MEAN
265 #include <winsock2.h>
267 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
268 HAVE_WINSOCK2_H shall not be defined.
270 int dummy=2*IPPROTO_ESP;
274 ac_cv_header_winsock2_h="yes"
276 ac_cv_header_winsock2_h="no"
279 case "$ac_cv_header_winsock2_h" in
281 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
282 [Define to 1 if you have the winsock2.h header file.])
288 dnl CURL_CHECK_HEADER_WS2TCPIP
289 dnl -------------------------------------------------
290 dnl Check for compilable and valid ws2tcpip.h header
292 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
293 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
294 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
298 #ifndef WIN32_LEAN_AND_MEAN
299 #define WIN32_LEAN_AND_MEAN
302 #include <winsock2.h>
303 #include <ws2tcpip.h>
305 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
306 HAVE_WS2TCPIP_H shall not be defined.
308 int dummy=2*IP_PKTINFO;
312 ac_cv_header_ws2tcpip_h="yes"
314 ac_cv_header_ws2tcpip_h="no"
317 case "$ac_cv_header_ws2tcpip_h" in
319 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
320 [Define to 1 if you have the ws2tcpip.h header file.])
326 dnl CURL_CHECK_HEADER_MALLOC
327 dnl -------------------------------------------------
328 dnl Check for compilable and valid malloc.h header,
329 dnl and check if it is needed even with stdlib.h
331 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
332 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
337 void *p = malloc(10);
338 void *q = calloc(10,10);
343 ac_cv_header_malloc_h="yes"
345 ac_cv_header_malloc_h="no"
348 if test "$ac_cv_header_malloc_h" = "yes"; then
349 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
350 [Define to 1 if you have the malloc.h header file.])
356 void *p = malloc(10);
357 void *q = calloc(10,10);
362 curl_cv_need_header_malloc_h="no"
364 curl_cv_need_header_malloc_h="yes"
367 case "$curl_cv_need_header_malloc_h" in
369 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
370 [Define to 1 if you need the malloc.h header file even with stdlib.h])
377 dnl CURL_CHECK_HEADER_MEMORY
378 dnl -------------------------------------------------
379 dnl Check for compilable and valid memory.h header,
380 dnl and check if it is needed even with stdlib.h for
381 dnl memory related functions.
383 AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
384 AC_CACHE_CHECK([for memory.h], [ac_cv_header_memory_h], [
389 void *p = malloc(10);
390 void *q = calloc(10,10);
395 ac_cv_header_memory_h="yes"
397 ac_cv_header_memory_h="no"
400 if test "$ac_cv_header_memory_h" = "yes"; then
401 AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
402 [Define to 1 if you have the memory.h header file.])
408 void *p = malloc(10);
409 void *q = calloc(10,10);
414 curl_cv_need_header_memory_h="no"
416 curl_cv_need_header_memory_h="yes"
419 case "$curl_cv_need_header_memory_h" in
421 AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
422 [Define to 1 if you need the memory.h header file even with stdlib.h])
429 dnl CURL_CHECK_FUNC_GETNAMEINFO
430 dnl -------------------------------------------------
431 dnl Test if the getnameinfo function is available,
432 dnl and check the types of five of its arguments.
433 dnl If the function succeeds HAVE_GETNAMEINFO will be
434 dnl defined, defining the types of the arguments in
435 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
436 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
437 dnl and also defining the type qualifier of first
438 dnl argument in GETNAMEINFO_QUAL_ARG1.
440 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
441 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
442 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
444 AC_MSG_CHECKING([for getnameinfo])
446 AC_LANG_FUNC_LINK_TRY([getnameinfo])
449 curl_cv_getnameinfo="yes"
452 curl_cv_getnameinfo="no"
455 if test "$curl_cv_getnameinfo" != "yes"; then
456 AC_MSG_CHECKING([deeper for getnameinfo])
464 curl_cv_getnameinfo="yes"
466 AC_MSG_RESULT([but still no])
467 curl_cv_getnameinfo="no"
471 if test "$curl_cv_getnameinfo" != "yes"; then
472 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
476 #ifdef HAVE_WINDOWS_H
477 #ifndef WIN32_LEAN_AND_MEAN
478 #define WIN32_LEAN_AND_MEAN
481 #ifdef HAVE_WINSOCK2_H
482 #include <winsock2.h>
483 #ifdef HAVE_WS2TCPIP_H
484 #include <ws2tcpip.h>
488 #ifdef HAVE_SYS_TYPES_H
489 #include <sys/types.h>
491 #ifdef HAVE_SYS_SOCKET_H
492 #include <sys/socket.h>
499 getnameinfo(0, 0, 0, 0, 0, 0, 0);
503 curl_cv_getnameinfo="yes"
505 AC_MSG_RESULT([but still no])
506 curl_cv_getnameinfo="no"
510 if test "$curl_cv_getnameinfo" = "yes"; then
511 AC_CACHE_CHECK([types of arguments for getnameinfo],
512 [curl_cv_func_getnameinfo_args], [
513 curl_cv_func_getnameinfo_args="unknown"
514 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
515 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
516 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
517 for gni_arg7 in 'int' 'unsigned int'; do
518 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
522 #ifdef HAVE_WINDOWS_H
523 #ifndef WIN32_LEAN_AND_MEAN
524 #define WIN32_LEAN_AND_MEAN
526 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
528 #define _WIN32_WINNT 0x0501
531 #ifdef HAVE_WINSOCK2_H
532 #include <winsock2.h>
533 #ifdef HAVE_WS2TCPIP_H
534 #include <ws2tcpip.h>
537 #define GNICALLCONV WSAAPI
539 #ifdef HAVE_SYS_TYPES_H
540 #include <sys/types.h>
542 #ifdef HAVE_SYS_SOCKET_H
543 #include <sys/socket.h>
550 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
556 $gni_arg46 hostlen=0;
557 $gni_arg46 servlen=0;
559 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
562 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
570 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
571 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
572 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
574 gni_prev_IFS=$IFS; IFS=','
575 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
579 gni_qual_type_arg1=$[1]
581 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
582 [Define to the type of arg 2 for getnameinfo.])
583 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
584 [Define to the type of args 4 and 6 for getnameinfo.])
585 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
586 [Define to the type of arg 7 for getnameinfo.])
590 case $prev_sh_opts in
598 case "$gni_qual_type_arg1" in
601 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
605 gni_type_arg1=$gni_qual_type_arg1
609 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
610 [Define to the type qualifier of arg 1 for getnameinfo.])
611 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
612 [Define to the type of arg 1 for getnameinfo.])
614 case $prev_sh_opts in
622 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
623 [Define to 1 if you have the getnameinfo function.])
624 ac_cv_func_getnameinfo="yes"
630 dnl TYPE_SOCKADDR_STORAGE
631 dnl -------------------------------------------------
632 dnl Check for struct sockaddr_storage. Most IPv6-enabled
633 dnl hosts have it, but AIX 4.3 is one known exception.
635 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
637 AC_CHECK_TYPE([struct sockaddr_storage],
638 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
639 [if struct sockaddr_storage is defined]), ,
642 #ifdef HAVE_WINDOWS_H
643 #ifndef WIN32_LEAN_AND_MEAN
644 #define WIN32_LEAN_AND_MEAN
647 #ifdef HAVE_WINSOCK2_H
648 #include <winsock2.h>
651 #ifdef HAVE_SYS_TYPES_H
652 #include <sys/types.h>
654 #ifdef HAVE_SYS_SOCKET_H
655 #include <sys/socket.h>
657 #ifdef HAVE_NETINET_IN_H
658 #include <netinet/in.h>
660 #ifdef HAVE_ARPA_INET_H
661 #include <arpa/inet.h>
668 dnl CURL_CHECK_NI_WITHSCOPEID
669 dnl -------------------------------------------------
670 dnl Check for working NI_WITHSCOPEID in getnameinfo()
672 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
673 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
674 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
675 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
676 netdb.h netinet/in.h arpa/inet.h)
678 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
679 [ac_cv_working_ni_withscopeid], [
688 #ifdef HAVE_SYS_TYPES_H
689 #include <sys/types.h>
691 #ifdef HAVE_SYS_SOCKET_H
692 #include <sys/socket.h>
697 #ifdef HAVE_NETINET_IN_H
698 #include <netinet/in.h>
700 #ifdef HAVE_ARPA_INET_H
701 #include <arpa/inet.h>
704 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
705 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
706 struct sockaddr_storage sa;
708 unsigned char sa[256];
710 char hostbuf[NI_MAXHOST];
712 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
713 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
714 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
715 int fd = socket(AF_INET6, SOCK_STREAM, 0);
718 return 1; /* Error creating socket */
720 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
722 perror("getsockname()");
723 return 2; /* Error retrieving socket name */
725 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
727 printf("rc = %s\n", gai_strerror(rc));
728 return 3; /* Error translating socket address */
730 return 0; /* Ok, NI_WITHSCOPEID works */
732 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
734 ]]) # AC-LANG-PROGRAM
736 # Exit code == 0. Program worked.
737 ac_cv_working_ni_withscopeid="yes"
739 # Exit code != 0. Program failed.
740 ac_cv_working_ni_withscopeid="no"
742 # Program is not run when cross-compiling. So we assume
743 # NI_WITHSCOPEID will work if we are able to compile it.
746 #include <sys/types.h>
747 #include <sys/socket.h>
750 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
753 ac_cv_working_ni_withscopeid="yes"
755 ac_cv_working_ni_withscopeid="no"
756 ]) # AC-COMPILE-IFELSE
759 case "$ac_cv_working_ni_withscopeid" in
761 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
762 [Define to 1 if NI_WITHSCOPEID exists and works.])
768 dnl CURL_CHECK_FUNC_RECV
769 dnl -------------------------------------------------
770 dnl Test if the socket recv() function is available,
771 dnl and check its return type and the types of its
772 dnl arguments. If the function succeeds HAVE_RECV
773 dnl will be defined, defining the types of the arguments
774 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
775 dnl and RECV_TYPE_ARG4, defining the type of the function
776 dnl return value in RECV_TYPE_RETV.
778 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
779 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
780 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
781 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
783 AC_MSG_CHECKING([for recv])
787 #ifdef HAVE_WINDOWS_H
788 #ifndef WIN32_LEAN_AND_MEAN
789 #define WIN32_LEAN_AND_MEAN
792 #ifdef HAVE_WINSOCK2_H
793 #include <winsock2.h>
795 #ifdef HAVE_WINSOCK_H
800 #ifdef HAVE_SYS_TYPES_H
801 #include <sys/types.h>
803 #ifdef HAVE_SYS_SOCKET_H
804 #include <sys/socket.h>
818 if test "$curl_cv_recv" = "yes"; then
819 AC_CACHE_CHECK([types of args and return type for recv],
820 [curl_cv_func_recv_args], [
821 curl_cv_func_recv_args="unknown"
822 for recv_retv in 'int' 'ssize_t'; do
823 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
824 for recv_arg2 in 'char *' 'void *'; do
825 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
826 for recv_arg4 in 'int' 'unsigned int'; do
827 if test "$curl_cv_func_recv_args" = "unknown"; then
831 #ifdef HAVE_WINDOWS_H
832 #ifndef WIN32_LEAN_AND_MEAN
833 #define WIN32_LEAN_AND_MEAN
836 #ifdef HAVE_WINSOCK2_H
837 #include <winsock2.h>
839 #ifdef HAVE_WINSOCK_H
843 #define RECVCALLCONV PASCAL
845 #ifdef HAVE_SYS_TYPES_H
846 #include <sys/types.h>
848 #ifdef HAVE_SYS_SOCKET_H
849 #include <sys/socket.h>
853 extern $recv_retv RECVCALLCONV
854 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
860 $recv_retv res = recv(s, buf, len, flags);
863 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
872 if test "$curl_cv_func_recv_args" = "unknown"; then
873 AC_MSG_ERROR([Cannot find proper types to use for recv args])
875 recv_prev_IFS=$IFS; IFS=','
876 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
880 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
881 [Define to the type of arg 1 for recv.])
882 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
883 [Define to the type of arg 2 for recv.])
884 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
885 [Define to the type of arg 3 for recv.])
886 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
887 [Define to the type of arg 4 for recv.])
888 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
889 [Define to the function return type for recv.])
891 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
892 [Define to 1 if you have the recv function.])
893 ac_cv_func_recv="yes"
896 AC_MSG_ERROR([Unable to link function recv])
901 dnl CURL_CHECK_FUNC_SEND
902 dnl -------------------------------------------------
903 dnl Test if the socket send() function is available,
904 dnl and check its return type and the types of its
905 dnl arguments. If the function succeeds HAVE_SEND
906 dnl will be defined, defining the types of the arguments
907 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
908 dnl and SEND_TYPE_ARG4, defining the type of the function
909 dnl return value in SEND_TYPE_RETV, and also defining the
910 dnl type qualifier of second argument in SEND_QUAL_ARG2.
912 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
913 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
914 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
915 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
917 AC_MSG_CHECKING([for send])
921 #ifdef HAVE_WINDOWS_H
922 #ifndef WIN32_LEAN_AND_MEAN
923 #define WIN32_LEAN_AND_MEAN
926 #ifdef HAVE_WINSOCK2_H
927 #include <winsock2.h>
929 #ifdef HAVE_WINSOCK_H
934 #ifdef HAVE_SYS_TYPES_H
935 #include <sys/types.h>
937 #ifdef HAVE_SYS_SOCKET_H
938 #include <sys/socket.h>
952 if test "$curl_cv_send" = "yes"; then
953 AC_CACHE_CHECK([types of args and return type for send],
954 [curl_cv_func_send_args], [
955 curl_cv_func_send_args="unknown"
956 for send_retv in 'int' 'ssize_t'; do
957 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
958 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
959 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
960 for send_arg4 in 'int' 'unsigned int'; do
961 if test "$curl_cv_func_send_args" = "unknown"; then
965 #ifdef HAVE_WINDOWS_H
966 #ifndef WIN32_LEAN_AND_MEAN
967 #define WIN32_LEAN_AND_MEAN
970 #ifdef HAVE_WINSOCK2_H
971 #include <winsock2.h>
973 #ifdef HAVE_WINSOCK_H
977 #define SENDCALLCONV PASCAL
979 #ifdef HAVE_SYS_TYPES_H
980 #include <sys/types.h>
982 #ifdef HAVE_SYS_SOCKET_H
983 #include <sys/socket.h>
987 extern $send_retv SENDCALLCONV
988 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
993 $send_retv res = send(s, 0, len, flags);
996 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1005 if test "$curl_cv_func_send_args" = "unknown"; then
1006 AC_MSG_ERROR([Cannot find proper types to use for send args])
1008 send_prev_IFS=$IFS; IFS=','
1009 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1013 send_qual_type_arg2=$[2]
1015 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1016 [Define to the type of arg 1 for send.])
1017 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1018 [Define to the type of arg 3 for send.])
1019 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1020 [Define to the type of arg 4 for send.])
1021 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1022 [Define to the function return type for send.])
1026 case $prev_sh_opts in
1034 case "$send_qual_type_arg2" in
1036 send_qual_arg2=const
1037 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1041 send_type_arg2=$send_qual_type_arg2
1045 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1046 [Define to the type qualifier of arg 2 for send.])
1047 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1048 [Define to the type of arg 2 for send.])
1050 case $prev_sh_opts in
1058 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1059 [Define to 1 if you have the send function.])
1060 ac_cv_func_send="yes"
1063 AC_MSG_ERROR([Unable to link function send])
1068 dnl CURL_CHECK_FUNC_RECVFROM
1069 dnl -------------------------------------------------
1070 dnl Test if the socket recvfrom() function is available,
1071 dnl and check its return type and the types of its
1072 dnl arguments. If the function succeeds HAVE_RECVFROM
1073 dnl will be defined, defining the types of the arguments
1074 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1075 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1076 dnl function return value in RECVFROM_TYPE_RETV.
1077 dnl Notice that the types returned for pointer arguments
1078 dnl will actually be the type pointed by the pointer.
1080 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1081 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1082 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1083 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1085 AC_MSG_CHECKING([for recvfrom])
1089 #ifdef HAVE_WINDOWS_H
1090 #ifndef WIN32_LEAN_AND_MEAN
1091 #define WIN32_LEAN_AND_MEAN
1093 #include <windows.h>
1094 #ifdef HAVE_WINSOCK2_H
1095 #include <winsock2.h>
1097 #ifdef HAVE_WINSOCK_H
1098 #include <winsock.h>
1102 #ifdef HAVE_SYS_TYPES_H
1103 #include <sys/types.h>
1105 #ifdef HAVE_SYS_SOCKET_H
1106 #include <sys/socket.h>
1110 recvfrom(0, 0, 0, 0, 0, 0);
1113 AC_MSG_RESULT([yes])
1114 curl_cv_recvfrom="yes"
1117 curl_cv_recvfrom="no"
1120 if test "$curl_cv_recvfrom" = "yes"; then
1121 AC_CACHE_CHECK([types of args and return type for recvfrom],
1122 [curl_cv_func_recvfrom_args], [
1123 curl_cv_func_recvfrom_args="unknown"
1124 for recvfrom_retv in 'int' 'ssize_t'; do
1125 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1126 for recvfrom_arg2 in 'char *' 'void *'; do
1127 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1128 for recvfrom_arg4 in 'int' 'unsigned int'; do
1129 for recvfrom_arg5 in 'struct sockaddr *' 'void *' 'const struct sockaddr *'; do
1130 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1131 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1135 #ifdef HAVE_WINDOWS_H
1136 #ifndef WIN32_LEAN_AND_MEAN
1137 #define WIN32_LEAN_AND_MEAN
1139 #include <windows.h>
1140 #ifdef HAVE_WINSOCK2_H
1141 #include <winsock2.h>
1143 #ifdef HAVE_WINSOCK_H
1144 #include <winsock.h>
1147 #define RECVFROMCALLCONV PASCAL
1149 #ifdef HAVE_SYS_TYPES_H
1150 #include <sys/types.h>
1152 #ifdef HAVE_SYS_SOCKET_H
1153 #include <sys/socket.h>
1155 #define RECVFROMCALLCONV
1157 extern $recvfrom_retv RECVFROMCALLCONV
1158 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1159 $recvfrom_arg3, $recvfrom_arg4,
1160 $recvfrom_arg5, $recvfrom_arg6);
1163 $recvfrom_arg2 buf=0;
1164 $recvfrom_arg3 len=0;
1165 $recvfrom_arg4 flags=0;
1166 $recvfrom_arg5 addr=0;
1167 $recvfrom_arg6 addrlen=0;
1168 $recvfrom_retv res=0;
1169 res = recvfrom(s, buf, len, flags, addr, addrlen);
1172 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1183 # Nearly last minute change for this release starts here
1184 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1185 [Define to 1 if you have the recvfrom function.])
1186 ac_cv_func_recvfrom="yes"
1187 # Nearly last minute change for this release ends here
1188 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1189 AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
1191 recvfrom_prev_IFS=$IFS; IFS=','
1192 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1193 IFS=$recvfrom_prev_IFS
1196 recvfrom_ptrt_arg2=$[2]
1197 recvfrom_qual_ptrt_arg5=$[5]
1198 recvfrom_ptrt_arg6=$[6]
1200 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1201 [Define to the type of arg 1 for recvfrom.])
1202 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1203 [Define to the type of arg 3 for recvfrom.])
1204 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1205 [Define to the type of arg 4 for recvfrom.])
1206 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1207 [Define to the function return type for recvfrom.])
1211 case $prev_sh_opts in
1219 case "$recvfrom_qual_ptrt_arg5" in
1221 recvfrom_qual_arg5=const
1222 recvfrom_ptrt_arg5=`echo $recvfrom_qual_ptrt_arg5 | sed 's/^const //'`
1226 recvfrom_ptrt_arg5=$recvfrom_qual_ptrt_arg5
1230 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1231 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1232 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1234 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1235 [Define to the type pointed by arg 2 for recvfrom.])
1236 AC_DEFINE_UNQUOTED(RECVFROM_QUAL_ARG5, $recvfrom_qual_arg5,
1237 [Define to the type qualifier pointed by arg 5 for recvfrom.])
1238 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1239 [Define to the type pointed by arg 5 for recvfrom.])
1240 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1241 [Define to the type pointed by arg 6 for recvfrom.])
1243 if test "$recvfrom_type_arg2" = "void"; then
1244 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1245 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1247 if test "$recvfrom_type_arg5" = "void"; then
1248 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1249 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1251 if test "$recvfrom_type_arg6" = "void"; then
1252 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1253 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1256 case $prev_sh_opts in
1264 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1265 [Define to 1 if you have the recvfrom function.])
1266 ac_cv_func_recvfrom="yes"
1269 AC_MSG_WARN([Unable to link function recvfrom])
1270 AC_MSG_WARN([Your system will be vulnerable to some forms of DNS cache poisoning])
1275 dnl CURL_CHECK_MSG_NOSIGNAL
1276 dnl -------------------------------------------------
1277 dnl Check for MSG_NOSIGNAL
1279 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1280 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1281 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1285 #ifdef HAVE_WINDOWS_H
1286 #ifndef WIN32_LEAN_AND_MEAN
1287 #define WIN32_LEAN_AND_MEAN
1289 #include <windows.h>
1290 #ifdef HAVE_WINSOCK2_H
1291 #include <winsock2.h>
1293 #ifdef HAVE_WINSOCK_H
1294 #include <winsock.h>
1298 #ifdef HAVE_SYS_TYPES_H
1299 #include <sys/types.h>
1301 #ifdef HAVE_SYS_SOCKET_H
1302 #include <sys/socket.h>
1306 int flag=MSG_NOSIGNAL;
1309 ac_cv_msg_nosignal="yes"
1311 ac_cv_msg_nosignal="no"
1314 case "$ac_cv_msg_nosignal" in
1316 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1317 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1323 dnl CURL_CHECK_STRUCT_TIMEVAL
1324 dnl -------------------------------------------------
1325 dnl Check for timeval struct
1327 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1328 AC_REQUIRE([AC_HEADER_TIME])dnl
1329 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1330 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1331 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
1332 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1336 #ifdef HAVE_WINDOWS_H
1337 #ifndef WIN32_LEAN_AND_MEAN
1338 #define WIN32_LEAN_AND_MEAN
1340 #include <windows.h>
1341 #ifdef HAVE_WINSOCK2_H
1342 #include <winsock2.h>
1344 #ifdef HAVE_WINSOCK_H
1345 #include <winsock.h>
1349 #ifdef HAVE_SYS_TYPES_H
1350 #include <sys/types.h>
1352 #ifdef HAVE_SYS_TIME_H
1353 #include <sys/time.h>
1354 #ifdef TIME_WITH_SYS_TIME
1362 #ifdef HAVE_SYS_SOCKET_H
1363 #include <sys/socket.h>
1371 ac_cv_struct_timeval="yes"
1373 ac_cv_struct_timeval="no"
1376 case "$ac_cv_struct_timeval" in
1378 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1379 [Define to 1 if you have the timeval struct.])
1385 dnl TYPE_SIG_ATOMIC_T
1386 dnl -------------------------------------------------
1387 dnl Check if the sig_atomic_t type is available, and
1388 dnl verify if it is already defined as volatile.
1390 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1391 AC_CHECK_HEADERS(signal.h)
1392 AC_CHECK_TYPE([sig_atomic_t],[
1393 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1394 [Define to 1 if sig_atomic_t is an available typedef.])
1396 #ifdef HAVE_SIGNAL_H
1400 case "$ac_cv_type_sig_atomic_t" in
1403 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1406 #ifdef HAVE_SIGNAL_H
1410 static volatile sig_atomic_t dummy = 0;
1414 ac_cv_sig_atomic_t_volatile="no"
1416 AC_MSG_RESULT([yes])
1417 ac_cv_sig_atomic_t_volatile="yes"
1420 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1421 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1422 [Define to 1 if sig_atomic_t is already defined as volatile.])
1430 dnl -------------------------------------------------
1431 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1432 dnl and a few other things.
1434 AC_DEFUN([TYPE_IN_ADDR_T], [
1435 AC_CHECK_TYPE([in_addr_t], ,[
1436 dnl in_addr_t not available
1437 AC_CACHE_CHECK([for in_addr_t equivalent],
1438 [curl_cv_in_addr_t_equiv], [
1439 curl_cv_in_addr_t_equiv="unknown"
1440 for t in "unsigned long" int size_t unsigned long; do
1441 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1445 #ifdef HAVE_WINDOWS_H
1446 #ifndef WIN32_LEAN_AND_MEAN
1447 #define WIN32_LEAN_AND_MEAN
1449 #include <windows.h>
1450 #ifdef HAVE_WINSOCK2_H
1451 #include <winsock2.h>
1453 #ifdef HAVE_WINSOCK_H
1454 #include <winsock.h>
1458 #ifdef HAVE_SYS_TYPES_H
1459 #include <sys/types.h>
1461 #ifdef HAVE_SYS_SOCKET_H
1462 #include <sys/socket.h>
1464 #ifdef HAVE_NETINET_IN_H
1465 #include <netinet/in.h>
1467 #ifdef HAVE_ARPA_INET_H
1468 #include <arpa/inet.h>
1472 $t data = inet_addr ("1.2.3.4");
1475 curl_cv_in_addr_t_equiv="$t"
1480 case "$curl_cv_in_addr_t_equiv" in
1482 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1485 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1486 [Type to use in place of in_addr_t when system does not provide it.])
1491 #ifdef HAVE_WINDOWS_H
1492 #ifndef WIN32_LEAN_AND_MEAN
1493 #define WIN32_LEAN_AND_MEAN
1495 #include <windows.h>
1496 #ifdef HAVE_WINSOCK2_H
1497 #include <winsock2.h>
1499 #ifdef HAVE_WINSOCK_H
1500 #include <winsock.h>
1504 #ifdef HAVE_SYS_TYPES_H
1505 #include <sys/types.h>
1507 #ifdef HAVE_SYS_SOCKET_H
1508 #include <sys/socket.h>
1510 #ifdef HAVE_NETINET_IN_H
1511 #include <netinet/in.h>
1513 #ifdef HAVE_ARPA_INET_H
1514 #include <arpa/inet.h>
1521 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1522 dnl -------------------------------------------------
1523 dnl Check if monotonic clock_gettime is available.
1525 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1526 AC_REQUIRE([AC_HEADER_TIME])dnl
1527 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1528 AC_MSG_CHECKING([for monotonic clock_gettime])
1531 #ifdef HAVE_SYS_TYPES_H
1532 #include <sys/types.h>
1534 #ifdef HAVE_SYS_TIME_H
1535 #include <sys/time.h>
1536 #ifdef TIME_WITH_SYS_TIME
1546 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1549 AC_MSG_RESULT([yes])
1550 ac_cv_func_clock_gettime="yes"
1553 ac_cv_func_clock_gettime="no"
1555 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1556 dnl until library linking and run-time checks for clock_gettime succeed.
1560 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1561 dnl -------------------------------------------------
1562 dnl If monotonic clock_gettime is available then,
1563 dnl check and prepended to LIBS any needed libraries.
1565 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1566 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1568 if test "$ac_cv_func_clock_gettime" = "yes"; then
1570 AC_MSG_CHECKING([for clock_gettime in libraries])
1572 curl_cv_save_LIBS="$LIBS"
1573 curl_cv_gclk_LIBS="unknown"
1575 for x_xlibs in '' '-lrt' '-lposix4' ; do
1576 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1577 if test -z "$x_xlibs"; then
1578 LIBS="$curl_cv_save_LIBS"
1580 LIBS="$x_xlibs $curl_cv_save_LIBS"
1584 #ifdef HAVE_SYS_TYPES_H
1585 #include <sys/types.h>
1587 #ifdef HAVE_SYS_TIME_H
1588 #include <sys/time.h>
1589 #ifdef TIME_WITH_SYS_TIME
1599 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1602 curl_cv_gclk_LIBS="$x_xlibs"
1607 LIBS="$curl_cv_save_LIBS"
1609 case X-"$curl_cv_gclk_LIBS" in
1611 AC_MSG_RESULT([cannot find clock_gettime])
1612 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1613 ac_cv_func_clock_gettime="no"
1616 AC_MSG_RESULT([no additional lib required])
1617 ac_cv_func_clock_gettime="yes"
1620 if test -z "$curl_cv_save_LIBS"; then
1621 LIBS="$curl_cv_gclk_LIBS"
1623 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1625 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1626 ac_cv_func_clock_gettime="yes"
1630 dnl only do runtime verification when not cross-compiling
1631 if test "x$cross_compiling" != "xyes" &&
1632 test "$ac_cv_func_clock_gettime" = "yes"; then
1633 AC_MSG_CHECKING([if monotonic clock_gettime works])
1636 #ifdef HAVE_STDLIB_H
1639 #ifdef HAVE_SYS_TYPES_H
1640 #include <sys/types.h>
1642 #ifdef HAVE_SYS_TIME_H
1643 #include <sys/time.h>
1644 #ifdef TIME_WITH_SYS_TIME
1654 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1660 AC_MSG_RESULT([yes])
1663 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1664 ac_cv_func_clock_gettime="no"
1665 LIBS="$curl_cv_save_LIBS"
1669 case "$ac_cv_func_clock_gettime" in
1671 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1672 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1681 dnl CARES_CHECK_LIBS_CONNECT
1682 dnl -------------------------------------------------
1683 dnl Verify if network connect function is already available
1684 dnl using current libraries or if another one is required.
1686 AC_DEFUN([CARES_CHECK_LIBS_CONNECT], [
1687 AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
1688 AC_MSG_CHECKING([for connect in libraries])
1689 tst_connect_save_LIBS="$LIBS"
1690 tst_connect_need_LIBS="unknown"
1691 for tst_lib in '' '-lsocket' ; do
1692 if test "$tst_connect_need_LIBS" = "unknown"; then
1693 LIBS="$tst_lib $tst_connect_save_LIBS"
1696 $cares_includes_winsock2
1697 #ifndef HAVE_WINDOWS_H
1698 int connect(int, void*, int);
1701 if(0 != connect(0, 0, 0))
1705 tst_connect_need_LIBS="$tst_lib"
1709 LIBS="$tst_connect_save_LIBS"
1711 case X-"$tst_connect_need_LIBS" in
1713 AC_MSG_RESULT([cannot find connect])
1714 AC_MSG_ERROR([cannot find connect function in libraries.])
1717 AC_MSG_RESULT([yes])
1720 AC_MSG_RESULT([$tst_connect_need_LIBS])
1721 LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
1727 dnl CARES_DEFINE_UNQUOTED (VARIABLE, [VALUE])
1728 dnl -------------------------------------------------
1729 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
1730 dnl symbol that can be further used in custom template configuration
1731 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
1732 dnl argument for the description. Symbol definitions done with this
1733 dnl macro are intended to be exclusively used in handcrafted *.h.in
1734 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
1735 dnl prevents autoheader generation and insertion of symbol template
1736 dnl stub and definition into the first configuration header file. Do
1737 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
1738 dnl one serves different functional needs.
1740 AC_DEFUN([CARES_DEFINE_UNQUOTED], [
1741 cat >>confdefs.h <<_EOF
1742 [@%:@define] $1 ifelse($#, 2, [$2], 1)
1747 dnl CARES_CONFIGURE_LONG
1748 dnl -------------------------------------------------
1749 dnl Find out the size of long as reported by sizeof() and define
1750 dnl CARES_SIZEOF_LONG as appropriate to be used in template file
1751 dnl ares_build.h.in to properly configure the library.
1752 dnl The size of long is a build time characteristic and as such
1753 dnl must be recorded in ares_build.h
1755 AC_DEFUN([CARES_CONFIGURE_LONG], [
1756 if test -z "$ac_cv_sizeof_long" ||
1757 test "$ac_cv_sizeof_long" -eq "0"; then
1758 AC_MSG_ERROR([cannot find out size of long.])
1760 CARES_DEFINE_UNQUOTED([CARES_SIZEOF_LONG], [$ac_cv_sizeof_long])
1764 dnl CARES_CONFIGURE_ARES_SOCKLEN_T
1765 dnl -------------------------------------------------
1766 dnl Find out suitable ares_socklen_t data type definition and size, making
1767 dnl appropriate definitions for template file ares_build.h.in
1768 dnl to properly configure and use the library.
1770 dnl The need for the ares_socklen_t definition arises mainly to properly
1771 dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
1772 dnl data type which is 32 or 64-Bit wide depending on the data model being
1773 dnl used, and that on the other hand is only actually used when interfacing
1774 dnl the X/Open sockets provided in the xnet library.
1776 AC_DEFUN([CARES_CONFIGURE_ARES_SOCKLEN_T], [
1777 AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
1778 AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
1779 AC_REQUIRE([CARES_PREPROCESS_CALLCONV])dnl
1781 AC_MSG_CHECKING([for ares_socklen_t data type])
1782 cares_typeof_ares_socklen_t="unknown"
1783 for arg1 in int SOCKET; do
1784 for arg2 in 'struct sockaddr' void; do
1785 for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
1786 if test "$cares_typeof_ares_socklen_t" = "unknown"; then
1789 $cares_includes_ws2tcpip
1790 $cares_includes_sys_socket
1791 $cares_preprocess_callconv
1792 extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
1795 if(0 != getpeername(0, 0, lenptr))
1799 cares_typeof_ares_socklen_t="$t"
1805 for t in socklen_t int; do
1806 if test "$cares_typeof_ares_socklen_t" = "void"; then
1809 $cares_includes_sys_socket
1810 typedef $t ares_socklen_t;
1812 ares_socklen_t dummy;
1815 cares_typeof_ares_socklen_t="$t"
1819 AC_MSG_RESULT([$cares_typeof_ares_socklen_t])
1820 if test "$cares_typeof_ares_socklen_t" = "void" ||
1821 test "$cares_typeof_ares_socklen_t" = "unknown"; then
1822 AC_MSG_ERROR([cannot find data type for ares_socklen_t.])
1825 AC_MSG_CHECKING([size of ares_socklen_t])
1826 cares_sizeof_ares_socklen_t="unknown"
1827 cares_pull_headers_socklen_t="unknown"
1828 if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
1829 tst_pull_header_checks='none ws2tcpip'
1832 tst_pull_header_checks='none systypes syssocket'
1833 tst_size_checks='4 8 2'
1835 for tst_size in $tst_size_checks; do
1836 for tst_pull_headers in $tst_pull_header_checks; do
1837 if test "$cares_sizeof_ares_socklen_t" = "unknown"; then
1838 case $tst_pull_headers in
1840 tmp_includes="$cares_includes_ws2tcpip"
1843 tmp_includes="$cares_includes_sys_types"
1846 tmp_includes="$cares_includes_sys_socket"
1855 typedef $cares_typeof_ares_socklen_t ares_socklen_t;
1856 typedef char dummy_arr[sizeof(ares_socklen_t) == $tst_size ? 1 : -1];
1858 ares_socklen_t dummy;
1861 cares_sizeof_ares_socklen_t="$tst_size"
1862 cares_pull_headers_socklen_t="$tst_pull_headers"
1867 AC_MSG_RESULT([$cares_sizeof_ares_socklen_t])
1868 if test "$cares_sizeof_ares_socklen_t" = "unknown"; then
1869 AC_MSG_ERROR([cannot find out size of ares_socklen_t.])
1872 case $cares_pull_headers_socklen_t in
1874 CARES_DEFINE_UNQUOTED([CARES_PULL_WS2TCPIP_H])
1877 CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_TYPES_H])
1880 CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_TYPES_H])
1881 CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_SOCKET_H])
1884 CARES_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SOCKLEN_T], [$cares_typeof_ares_socklen_t])
1885 CARES_DEFINE_UNQUOTED([CARES_SIZEOF_ARES_SOCKLEN_T], [$cares_sizeof_ares_socklen_t])
1889 dnl This macro determines if the specified struct exists in the specified file
1891 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1893 AC_DEFUN([CARES_CHECK_STRUCT], [
1894 AC_MSG_CHECKING([for struct $2])
1895 AC_TRY_COMPILE([$1],
1897 struct $2 struct_instance;
1898 ], ac_struct="yes", ac_found="no")
1899 if test "$ac_struct" = "yes" ; then
1908 dnl This macro determines if the specified constant exists in the specified file
1910 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
1912 AC_DEFUN([CARES_CHECK_CONSTANT], [
1913 AC_MSG_CHECKING([for $2])
1914 AC_EGREP_CPP(VARIABLEWASDEFINED,
1923 ], ac_constant="yes", ac_constant="no"
1925 if test "$ac_constant" = "yes" ; then