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 case "$ac_cv_native_windows" in
212 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
213 [Define to 1 if you are building a native Windows target.])
219 dnl CURL_CHECK_HEADER_WINSOCK
220 dnl -------------------------------------------------
221 dnl Check for compilable and valid winsock.h header
223 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
224 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
225 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
229 #ifndef WIN32_LEAN_AND_MEAN
230 #define WIN32_LEAN_AND_MEAN
235 #if defined(__CYGWIN__) || defined(__CEGCC__)
236 HAVE_WINSOCK_H shall not be defined.
238 int dummy=WSACleanup();
242 ac_cv_header_winsock_h="yes"
244 ac_cv_header_winsock_h="no"
247 case "$ac_cv_header_winsock_h" in
249 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
250 [Define to 1 if you have the winsock.h header file.])
256 dnl CURL_CHECK_HEADER_WINSOCK2
257 dnl -------------------------------------------------
258 dnl Check for compilable and valid winsock2.h header
260 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
261 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
262 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
266 #ifndef WIN32_LEAN_AND_MEAN
267 #define WIN32_LEAN_AND_MEAN
270 #include <winsock2.h>
272 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
273 HAVE_WINSOCK2_H shall not be defined.
275 int dummy=2*IPPROTO_ESP;
279 ac_cv_header_winsock2_h="yes"
281 ac_cv_header_winsock2_h="no"
284 case "$ac_cv_header_winsock2_h" in
286 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
287 [Define to 1 if you have the winsock2.h header file.])
293 dnl CURL_CHECK_HEADER_WS2TCPIP
294 dnl -------------------------------------------------
295 dnl Check for compilable and valid ws2tcpip.h header
297 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
298 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
299 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
303 #ifndef WIN32_LEAN_AND_MEAN
304 #define WIN32_LEAN_AND_MEAN
307 #include <winsock2.h>
308 #include <ws2tcpip.h>
310 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
311 HAVE_WS2TCPIP_H shall not be defined.
313 int dummy=2*IP_PKTINFO;
317 ac_cv_header_ws2tcpip_h="yes"
319 ac_cv_header_ws2tcpip_h="no"
322 case "$ac_cv_header_ws2tcpip_h" in
324 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
325 [Define to 1 if you have the ws2tcpip.h header file.])
331 dnl CURL_CHECK_HEADER_MALLOC
332 dnl -------------------------------------------------
333 dnl Check for compilable and valid malloc.h header,
334 dnl and check if it is needed even with stdlib.h
336 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
337 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
342 void *p = malloc(10);
343 void *q = calloc(10,10);
348 ac_cv_header_malloc_h="yes"
350 ac_cv_header_malloc_h="no"
353 if test "$ac_cv_header_malloc_h" = "yes"; then
354 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
355 [Define to 1 if you have the malloc.h header file.])
361 void *p = malloc(10);
362 void *q = calloc(10,10);
367 curl_cv_need_header_malloc_h="no"
369 curl_cv_need_header_malloc_h="yes"
372 case "$curl_cv_need_header_malloc_h" in
374 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
375 [Define to 1 if you need the malloc.h header file even with stdlib.h])
382 dnl CURL_CHECK_HEADER_MEMORY
383 dnl -------------------------------------------------
384 dnl Check for compilable and valid memory.h header,
385 dnl and check if it is needed even with stdlib.h for
386 dnl memory related functions.
388 AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
389 AC_CACHE_CHECK([for memory.h], [ac_cv_header_memory_h], [
394 void *p = malloc(10);
395 void *q = calloc(10,10);
400 ac_cv_header_memory_h="yes"
402 ac_cv_header_memory_h="no"
405 if test "$ac_cv_header_memory_h" = "yes"; then
406 AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
407 [Define to 1 if you have the memory.h header file.])
413 void *p = malloc(10);
414 void *q = calloc(10,10);
419 curl_cv_need_header_memory_h="no"
421 curl_cv_need_header_memory_h="yes"
424 case "$curl_cv_need_header_memory_h" in
426 AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
427 [Define to 1 if you need the memory.h header file even with stdlib.h])
434 dnl CURL_CHECK_FUNC_GETNAMEINFO
435 dnl -------------------------------------------------
436 dnl Test if the getnameinfo function is available,
437 dnl and check the types of five of its arguments.
438 dnl If the function succeeds HAVE_GETNAMEINFO will be
439 dnl defined, defining the types of the arguments in
440 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
441 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
442 dnl and also defining the type qualifier of first
443 dnl argument in GETNAMEINFO_QUAL_ARG1.
445 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
446 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
447 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
449 AC_MSG_CHECKING([for getnameinfo])
451 AC_LANG_FUNC_LINK_TRY([getnameinfo])
454 curl_cv_getnameinfo="yes"
457 curl_cv_getnameinfo="no"
460 if test "$curl_cv_getnameinfo" != "yes"; then
461 AC_MSG_CHECKING([deeper for getnameinfo])
469 curl_cv_getnameinfo="yes"
471 AC_MSG_RESULT([but still no])
472 curl_cv_getnameinfo="no"
476 if test "$curl_cv_getnameinfo" != "yes"; then
477 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
481 #ifdef HAVE_WINDOWS_H
482 #ifndef WIN32_LEAN_AND_MEAN
483 #define WIN32_LEAN_AND_MEAN
486 #ifdef HAVE_WINSOCK2_H
487 #include <winsock2.h>
488 #ifdef HAVE_WS2TCPIP_H
489 #include <ws2tcpip.h>
493 #ifdef HAVE_SYS_TYPES_H
494 #include <sys/types.h>
496 #ifdef HAVE_SYS_SOCKET_H
497 #include <sys/socket.h>
504 getnameinfo(0, 0, 0, 0, 0, 0, 0);
508 curl_cv_getnameinfo="yes"
510 AC_MSG_RESULT([but still no])
511 curl_cv_getnameinfo="no"
515 if test "$curl_cv_getnameinfo" = "yes"; then
516 AC_CACHE_CHECK([types of arguments for getnameinfo],
517 [curl_cv_func_getnameinfo_args], [
518 curl_cv_func_getnameinfo_args="unknown"
519 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
520 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
521 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
522 for gni_arg7 in 'int' 'unsigned int'; do
523 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
527 #ifdef HAVE_WINDOWS_H
528 #ifndef WIN32_LEAN_AND_MEAN
529 #define WIN32_LEAN_AND_MEAN
531 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
533 #define _WIN32_WINNT 0x0501
536 #ifdef HAVE_WINSOCK2_H
537 #include <winsock2.h>
538 #ifdef HAVE_WS2TCPIP_H
539 #include <ws2tcpip.h>
542 #define GNICALLCONV WSAAPI
544 #ifdef HAVE_SYS_TYPES_H
545 #include <sys/types.h>
547 #ifdef HAVE_SYS_SOCKET_H
548 #include <sys/socket.h>
555 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
561 $gni_arg46 hostlen=0;
562 $gni_arg46 servlen=0;
564 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
567 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
575 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
576 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
577 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
579 gni_prev_IFS=$IFS; IFS=','
580 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
584 gni_qual_type_arg1=$[1]
586 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
587 [Define to the type of arg 2 for getnameinfo.])
588 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
589 [Define to the type of args 4 and 6 for getnameinfo.])
590 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
591 [Define to the type of arg 7 for getnameinfo.])
595 case $prev_sh_opts in
603 case "$gni_qual_type_arg1" in
606 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
610 gni_type_arg1=$gni_qual_type_arg1
614 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
615 [Define to the type qualifier of arg 1 for getnameinfo.])
616 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
617 [Define to the type of arg 1 for getnameinfo.])
619 case $prev_sh_opts in
627 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
628 [Define to 1 if you have the getnameinfo function.])
629 ac_cv_func_getnameinfo="yes"
635 dnl TYPE_SOCKADDR_STORAGE
636 dnl -------------------------------------------------
637 dnl Check for struct sockaddr_storage. Most IPv6-enabled
638 dnl hosts have it, but AIX 4.3 is one known exception.
640 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
642 AC_CHECK_TYPE([struct sockaddr_storage],
643 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
644 [if struct sockaddr_storage is defined]), ,
647 #ifdef HAVE_WINDOWS_H
648 #ifndef WIN32_LEAN_AND_MEAN
649 #define WIN32_LEAN_AND_MEAN
652 #ifdef HAVE_WINSOCK2_H
653 #include <winsock2.h>
656 #ifdef HAVE_SYS_TYPES_H
657 #include <sys/types.h>
659 #ifdef HAVE_SYS_SOCKET_H
660 #include <sys/socket.h>
662 #ifdef HAVE_NETINET_IN_H
663 #include <netinet/in.h>
665 #ifdef HAVE_ARPA_INET_H
666 #include <arpa/inet.h>
673 dnl CURL_CHECK_NI_WITHSCOPEID
674 dnl -------------------------------------------------
675 dnl Check for working NI_WITHSCOPEID in getnameinfo()
677 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
678 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
679 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
680 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
681 netdb.h netinet/in.h arpa/inet.h)
683 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
684 [ac_cv_working_ni_withscopeid], [
693 #ifdef HAVE_SYS_TYPES_H
694 #include <sys/types.h>
696 #ifdef HAVE_SYS_SOCKET_H
697 #include <sys/socket.h>
702 #ifdef HAVE_NETINET_IN_H
703 #include <netinet/in.h>
705 #ifdef HAVE_ARPA_INET_H
706 #include <arpa/inet.h>
709 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
710 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
711 struct sockaddr_storage sa;
713 unsigned char sa[256];
715 char hostbuf[NI_MAXHOST];
717 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
718 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
719 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
720 int fd = socket(AF_INET6, SOCK_STREAM, 0);
723 return 1; /* Error creating socket */
725 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
727 perror("getsockname()");
728 return 2; /* Error retrieving socket name */
730 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
732 printf("rc = %s\n", gai_strerror(rc));
733 return 3; /* Error translating socket address */
735 return 0; /* Ok, NI_WITHSCOPEID works */
737 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
739 ]]) # AC-LANG-PROGRAM
741 # Exit code == 0. Program worked.
742 ac_cv_working_ni_withscopeid="yes"
744 # Exit code != 0. Program failed.
745 ac_cv_working_ni_withscopeid="no"
747 # Program is not run when cross-compiling. So we assume
748 # NI_WITHSCOPEID will work if we are able to compile it.
751 #include <sys/types.h>
752 #include <sys/socket.h>
755 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
758 ac_cv_working_ni_withscopeid="yes"
760 ac_cv_working_ni_withscopeid="no"
761 ]) # AC-COMPILE-IFELSE
764 case "$ac_cv_working_ni_withscopeid" in
766 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
767 [Define to 1 if NI_WITHSCOPEID exists and works.])
773 dnl CURL_CHECK_FUNC_RECV
774 dnl -------------------------------------------------
775 dnl Test if the socket recv() function is available,
776 dnl and check its return type and the types of its
777 dnl arguments. If the function succeeds HAVE_RECV
778 dnl will be defined, defining the types of the arguments
779 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
780 dnl and RECV_TYPE_ARG4, defining the type of the function
781 dnl return value in RECV_TYPE_RETV.
783 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
784 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
785 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
786 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
788 AC_MSG_CHECKING([for recv])
792 #ifdef HAVE_WINDOWS_H
793 #ifndef WIN32_LEAN_AND_MEAN
794 #define WIN32_LEAN_AND_MEAN
797 #ifdef HAVE_WINSOCK2_H
798 #include <winsock2.h>
800 #ifdef HAVE_WINSOCK_H
805 #ifdef HAVE_SYS_TYPES_H
806 #include <sys/types.h>
808 #ifdef HAVE_SYS_SOCKET_H
809 #include <sys/socket.h>
823 if test "$curl_cv_recv" = "yes"; then
824 AC_CACHE_CHECK([types of args and return type for recv],
825 [curl_cv_func_recv_args], [
826 curl_cv_func_recv_args="unknown"
827 for recv_retv in 'int' 'ssize_t'; do
828 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
829 for recv_arg2 in 'char *' 'void *'; do
830 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
831 for recv_arg4 in 'int' 'unsigned int'; do
832 if test "$curl_cv_func_recv_args" = "unknown"; then
836 #ifdef HAVE_WINDOWS_H
837 #ifndef WIN32_LEAN_AND_MEAN
838 #define WIN32_LEAN_AND_MEAN
841 #ifdef HAVE_WINSOCK2_H
842 #include <winsock2.h>
844 #ifdef HAVE_WINSOCK_H
848 #define RECVCALLCONV PASCAL
850 #ifdef HAVE_SYS_TYPES_H
851 #include <sys/types.h>
853 #ifdef HAVE_SYS_SOCKET_H
854 #include <sys/socket.h>
858 extern $recv_retv RECVCALLCONV
859 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
865 $recv_retv res = recv(s, buf, len, flags);
868 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
877 if test "$curl_cv_func_recv_args" = "unknown"; then
878 AC_MSG_ERROR([Cannot find proper types to use for recv args])
880 recv_prev_IFS=$IFS; IFS=','
881 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
885 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
886 [Define to the type of arg 1 for recv.])
887 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
888 [Define to the type of arg 2 for recv.])
889 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
890 [Define to the type of arg 3 for recv.])
891 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
892 [Define to the type of arg 4 for recv.])
893 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
894 [Define to the function return type for recv.])
896 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
897 [Define to 1 if you have the recv function.])
898 ac_cv_func_recv="yes"
901 AC_MSG_ERROR([Unable to link function recv])
906 dnl CURL_CHECK_FUNC_SEND
907 dnl -------------------------------------------------
908 dnl Test if the socket send() function is available,
909 dnl and check its return type and the types of its
910 dnl arguments. If the function succeeds HAVE_SEND
911 dnl will be defined, defining the types of the arguments
912 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
913 dnl and SEND_TYPE_ARG4, defining the type of the function
914 dnl return value in SEND_TYPE_RETV, and also defining the
915 dnl type qualifier of second argument in SEND_QUAL_ARG2.
917 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
918 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
919 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
920 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
922 AC_MSG_CHECKING([for send])
926 #ifdef HAVE_WINDOWS_H
927 #ifndef WIN32_LEAN_AND_MEAN
928 #define WIN32_LEAN_AND_MEAN
931 #ifdef HAVE_WINSOCK2_H
932 #include <winsock2.h>
934 #ifdef HAVE_WINSOCK_H
939 #ifdef HAVE_SYS_TYPES_H
940 #include <sys/types.h>
942 #ifdef HAVE_SYS_SOCKET_H
943 #include <sys/socket.h>
957 if test "$curl_cv_send" = "yes"; then
958 AC_CACHE_CHECK([types of args and return type for send],
959 [curl_cv_func_send_args], [
960 curl_cv_func_send_args="unknown"
961 for send_retv in 'int' 'ssize_t'; do
962 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
963 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
964 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
965 for send_arg4 in 'int' 'unsigned int'; do
966 if test "$curl_cv_func_send_args" = "unknown"; then
970 #ifdef HAVE_WINDOWS_H
971 #ifndef WIN32_LEAN_AND_MEAN
972 #define WIN32_LEAN_AND_MEAN
975 #ifdef HAVE_WINSOCK2_H
976 #include <winsock2.h>
978 #ifdef HAVE_WINSOCK_H
982 #define SENDCALLCONV PASCAL
984 #ifdef HAVE_SYS_TYPES_H
985 #include <sys/types.h>
987 #ifdef HAVE_SYS_SOCKET_H
988 #include <sys/socket.h>
992 extern $send_retv SENDCALLCONV
993 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
998 $send_retv res = send(s, 0, len, flags);
1001 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1010 if test "$curl_cv_func_send_args" = "unknown"; then
1011 AC_MSG_ERROR([Cannot find proper types to use for send args])
1013 send_prev_IFS=$IFS; IFS=','
1014 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1018 send_qual_type_arg2=$[2]
1020 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1021 [Define to the type of arg 1 for send.])
1022 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1023 [Define to the type of arg 3 for send.])
1024 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1025 [Define to the type of arg 4 for send.])
1026 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1027 [Define to the function return type for send.])
1031 case $prev_sh_opts in
1039 case "$send_qual_type_arg2" in
1041 send_qual_arg2=const
1042 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1046 send_type_arg2=$send_qual_type_arg2
1050 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1051 [Define to the type qualifier of arg 2 for send.])
1052 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1053 [Define to the type of arg 2 for send.])
1055 case $prev_sh_opts in
1063 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1064 [Define to 1 if you have the send function.])
1065 ac_cv_func_send="yes"
1068 AC_MSG_ERROR([Unable to link function send])
1073 dnl CURL_CHECK_FUNC_RECVFROM
1074 dnl -------------------------------------------------
1075 dnl Test if the socket recvfrom() function is available,
1076 dnl and check its return type and the types of its
1077 dnl arguments. If the function succeeds HAVE_RECVFROM
1078 dnl will be defined, defining the types of the arguments
1079 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1080 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1081 dnl function return value in RECVFROM_TYPE_RETV.
1082 dnl Notice that the types returned for pointer arguments
1083 dnl will actually be the type pointed by the pointer.
1085 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1086 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1087 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1088 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1090 AC_MSG_CHECKING([for recvfrom])
1094 #ifdef HAVE_WINDOWS_H
1095 #ifndef WIN32_LEAN_AND_MEAN
1096 #define WIN32_LEAN_AND_MEAN
1098 #include <windows.h>
1099 #ifdef HAVE_WINSOCK2_H
1100 #include <winsock2.h>
1102 #ifdef HAVE_WINSOCK_H
1103 #include <winsock.h>
1107 #ifdef HAVE_SYS_TYPES_H
1108 #include <sys/types.h>
1110 #ifdef HAVE_SYS_SOCKET_H
1111 #include <sys/socket.h>
1115 recvfrom(0, 0, 0, 0, 0, 0);
1118 AC_MSG_RESULT([yes])
1119 curl_cv_recvfrom="yes"
1122 curl_cv_recvfrom="no"
1125 if test "$curl_cv_recvfrom" = "yes"; then
1126 AC_CACHE_CHECK([types of args and return type for recvfrom],
1127 [curl_cv_func_recvfrom_args], [
1128 curl_cv_func_recvfrom_args="unknown"
1129 for recvfrom_retv in 'int' 'ssize_t'; do
1130 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1131 for recvfrom_arg2 in 'char *' 'void *'; do
1132 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1133 for recvfrom_arg4 in 'int' 'unsigned int'; do
1134 for recvfrom_arg5 in 'struct sockaddr *' 'void *' 'const struct sockaddr *'; do
1135 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1136 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1140 #ifdef HAVE_WINDOWS_H
1141 #ifndef WIN32_LEAN_AND_MEAN
1142 #define WIN32_LEAN_AND_MEAN
1144 #include <windows.h>
1145 #ifdef HAVE_WINSOCK2_H
1146 #include <winsock2.h>
1148 #ifdef HAVE_WINSOCK_H
1149 #include <winsock.h>
1152 #define RECVFROMCALLCONV PASCAL
1154 #ifdef HAVE_SYS_TYPES_H
1155 #include <sys/types.h>
1157 #ifdef HAVE_SYS_SOCKET_H
1158 #include <sys/socket.h>
1160 #define RECVFROMCALLCONV
1162 extern $recvfrom_retv RECVFROMCALLCONV
1163 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1164 $recvfrom_arg3, $recvfrom_arg4,
1165 $recvfrom_arg5, $recvfrom_arg6);
1168 $recvfrom_arg2 buf=0;
1169 $recvfrom_arg3 len=0;
1170 $recvfrom_arg4 flags=0;
1171 $recvfrom_arg5 addr=0;
1172 $recvfrom_arg6 addrlen=0;
1173 $recvfrom_retv res=0;
1174 res = recvfrom(s, buf, len, flags, addr, addrlen);
1177 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1188 # Nearly last minute change for this release starts here
1189 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1190 [Define to 1 if you have the recvfrom function.])
1191 ac_cv_func_recvfrom="yes"
1192 # Nearly last minute change for this release ends here
1193 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1194 AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
1196 recvfrom_prev_IFS=$IFS; IFS=','
1197 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1198 IFS=$recvfrom_prev_IFS
1201 recvfrom_ptrt_arg2=$[2]
1202 recvfrom_qual_ptrt_arg5=$[5]
1203 recvfrom_ptrt_arg6=$[6]
1205 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1206 [Define to the type of arg 1 for recvfrom.])
1207 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1208 [Define to the type of arg 3 for recvfrom.])
1209 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1210 [Define to the type of arg 4 for recvfrom.])
1211 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1212 [Define to the function return type for recvfrom.])
1216 case $prev_sh_opts in
1224 case "$recvfrom_qual_ptrt_arg5" in
1226 recvfrom_qual_arg5=const
1227 recvfrom_ptrt_arg5=`echo $recvfrom_qual_ptrt_arg5 | sed 's/^const //'`
1231 recvfrom_ptrt_arg5=$recvfrom_qual_ptrt_arg5
1235 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1236 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1237 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1239 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1240 [Define to the type pointed by arg 2 for recvfrom.])
1241 AC_DEFINE_UNQUOTED(RECVFROM_QUAL_ARG5, $recvfrom_qual_arg5,
1242 [Define to the type qualifier pointed by arg 5 for recvfrom.])
1243 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1244 [Define to the type pointed by arg 5 for recvfrom.])
1245 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1246 [Define to the type pointed by arg 6 for recvfrom.])
1248 if test "$recvfrom_type_arg2" = "void"; then
1249 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1250 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1252 if test "$recvfrom_type_arg5" = "void"; then
1253 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1254 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1256 if test "$recvfrom_type_arg6" = "void"; then
1257 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1258 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1261 case $prev_sh_opts in
1269 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1270 [Define to 1 if you have the recvfrom function.])
1271 ac_cv_func_recvfrom="yes"
1274 AC_MSG_WARN([Unable to link function recvfrom])
1275 AC_MSG_WARN([Your system will be vulnerable to some forms of DNS cache poisoning])
1280 dnl CURL_CHECK_MSG_NOSIGNAL
1281 dnl -------------------------------------------------
1282 dnl Check for MSG_NOSIGNAL
1284 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1285 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1286 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1290 #ifdef HAVE_WINDOWS_H
1291 #ifndef WIN32_LEAN_AND_MEAN
1292 #define WIN32_LEAN_AND_MEAN
1294 #include <windows.h>
1295 #ifdef HAVE_WINSOCK2_H
1296 #include <winsock2.h>
1298 #ifdef HAVE_WINSOCK_H
1299 #include <winsock.h>
1303 #ifdef HAVE_SYS_TYPES_H
1304 #include <sys/types.h>
1306 #ifdef HAVE_SYS_SOCKET_H
1307 #include <sys/socket.h>
1311 int flag=MSG_NOSIGNAL;
1314 ac_cv_msg_nosignal="yes"
1316 ac_cv_msg_nosignal="no"
1319 case "$ac_cv_msg_nosignal" in
1321 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1322 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1328 dnl CURL_CHECK_STRUCT_TIMEVAL
1329 dnl -------------------------------------------------
1330 dnl Check for timeval struct
1332 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1333 AC_REQUIRE([AC_HEADER_TIME])dnl
1334 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1335 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1336 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
1337 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1341 #ifdef HAVE_WINDOWS_H
1342 #ifndef WIN32_LEAN_AND_MEAN
1343 #define WIN32_LEAN_AND_MEAN
1345 #include <windows.h>
1346 #ifdef HAVE_WINSOCK2_H
1347 #include <winsock2.h>
1349 #ifdef HAVE_WINSOCK_H
1350 #include <winsock.h>
1354 #ifdef HAVE_SYS_TYPES_H
1355 #include <sys/types.h>
1357 #ifdef HAVE_SYS_TIME_H
1358 #include <sys/time.h>
1359 #ifdef TIME_WITH_SYS_TIME
1367 #ifdef HAVE_SYS_SOCKET_H
1368 #include <sys/socket.h>
1376 ac_cv_struct_timeval="yes"
1378 ac_cv_struct_timeval="no"
1381 case "$ac_cv_struct_timeval" in
1383 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1384 [Define to 1 if you have the timeval struct.])
1390 dnl TYPE_SIG_ATOMIC_T
1391 dnl -------------------------------------------------
1392 dnl Check if the sig_atomic_t type is available, and
1393 dnl verify if it is already defined as volatile.
1395 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1396 AC_CHECK_HEADERS(signal.h)
1397 AC_CHECK_TYPE([sig_atomic_t],[
1398 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1399 [Define to 1 if sig_atomic_t is an available typedef.])
1401 #ifdef HAVE_SIGNAL_H
1405 case "$ac_cv_type_sig_atomic_t" in
1408 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1411 #ifdef HAVE_SIGNAL_H
1415 static volatile sig_atomic_t dummy = 0;
1419 ac_cv_sig_atomic_t_volatile="no"
1421 AC_MSG_RESULT([yes])
1422 ac_cv_sig_atomic_t_volatile="yes"
1425 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1426 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1427 [Define to 1 if sig_atomic_t is already defined as volatile.])
1435 dnl -------------------------------------------------
1436 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1437 dnl and a few other things.
1439 AC_DEFUN([TYPE_IN_ADDR_T], [
1440 AC_CHECK_TYPE([in_addr_t], ,[
1441 dnl in_addr_t not available
1442 AC_CACHE_CHECK([for in_addr_t equivalent],
1443 [curl_cv_in_addr_t_equiv], [
1444 curl_cv_in_addr_t_equiv="unknown"
1445 for t in "unsigned long" int size_t unsigned long; do
1446 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1450 #ifdef HAVE_WINDOWS_H
1451 #ifndef WIN32_LEAN_AND_MEAN
1452 #define WIN32_LEAN_AND_MEAN
1454 #include <windows.h>
1455 #ifdef HAVE_WINSOCK2_H
1456 #include <winsock2.h>
1458 #ifdef HAVE_WINSOCK_H
1459 #include <winsock.h>
1463 #ifdef HAVE_SYS_TYPES_H
1464 #include <sys/types.h>
1466 #ifdef HAVE_SYS_SOCKET_H
1467 #include <sys/socket.h>
1469 #ifdef HAVE_NETINET_IN_H
1470 #include <netinet/in.h>
1472 #ifdef HAVE_ARPA_INET_H
1473 #include <arpa/inet.h>
1477 $t data = inet_addr ("1.2.3.4");
1480 curl_cv_in_addr_t_equiv="$t"
1485 case "$curl_cv_in_addr_t_equiv" in
1487 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1490 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1491 [Type to use in place of in_addr_t when system does not provide it.])
1496 #ifdef HAVE_WINDOWS_H
1497 #ifndef WIN32_LEAN_AND_MEAN
1498 #define WIN32_LEAN_AND_MEAN
1500 #include <windows.h>
1501 #ifdef HAVE_WINSOCK2_H
1502 #include <winsock2.h>
1504 #ifdef HAVE_WINSOCK_H
1505 #include <winsock.h>
1509 #ifdef HAVE_SYS_TYPES_H
1510 #include <sys/types.h>
1512 #ifdef HAVE_SYS_SOCKET_H
1513 #include <sys/socket.h>
1515 #ifdef HAVE_NETINET_IN_H
1516 #include <netinet/in.h>
1518 #ifdef HAVE_ARPA_INET_H
1519 #include <arpa/inet.h>
1526 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1527 dnl -------------------------------------------------
1528 dnl Check if monotonic clock_gettime is available.
1530 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1531 AC_REQUIRE([AC_HEADER_TIME])dnl
1532 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1533 AC_MSG_CHECKING([for monotonic clock_gettime])
1536 #ifdef HAVE_SYS_TYPES_H
1537 #include <sys/types.h>
1539 #ifdef HAVE_SYS_TIME_H
1540 #include <sys/time.h>
1541 #ifdef TIME_WITH_SYS_TIME
1551 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1554 AC_MSG_RESULT([yes])
1555 ac_cv_func_clock_gettime="yes"
1558 ac_cv_func_clock_gettime="no"
1560 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1561 dnl until library linking and run-time checks for clock_gettime succeed.
1565 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1566 dnl -------------------------------------------------
1567 dnl If monotonic clock_gettime is available then,
1568 dnl check and prepended to LIBS any needed libraries.
1570 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1571 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1573 if test "$ac_cv_func_clock_gettime" = "yes"; then
1575 AC_MSG_CHECKING([for clock_gettime in libraries])
1577 curl_cv_save_LIBS="$LIBS"
1578 curl_cv_gclk_LIBS="unknown"
1580 for x_xlibs in '' '-lrt' '-lposix4' ; do
1581 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1582 if test -z "$x_xlibs"; then
1583 LIBS="$curl_cv_save_LIBS"
1585 LIBS="$x_xlibs $curl_cv_save_LIBS"
1589 #ifdef HAVE_SYS_TYPES_H
1590 #include <sys/types.h>
1592 #ifdef HAVE_SYS_TIME_H
1593 #include <sys/time.h>
1594 #ifdef TIME_WITH_SYS_TIME
1604 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1607 curl_cv_gclk_LIBS="$x_xlibs"
1612 LIBS="$curl_cv_save_LIBS"
1614 case X-"$curl_cv_gclk_LIBS" in
1616 AC_MSG_RESULT([cannot find clock_gettime])
1617 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1618 ac_cv_func_clock_gettime="no"
1621 AC_MSG_RESULT([no additional lib required])
1622 ac_cv_func_clock_gettime="yes"
1625 if test -z "$curl_cv_save_LIBS"; then
1626 LIBS="$curl_cv_gclk_LIBS"
1628 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1630 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1631 ac_cv_func_clock_gettime="yes"
1635 dnl only do runtime verification when not cross-compiling
1636 if test "x$cross_compiling" != "xyes" &&
1637 test "$ac_cv_func_clock_gettime" = "yes"; then
1638 AC_MSG_CHECKING([if monotonic clock_gettime works])
1641 #ifdef HAVE_STDLIB_H
1644 #ifdef HAVE_SYS_TYPES_H
1645 #include <sys/types.h>
1647 #ifdef HAVE_SYS_TIME_H
1648 #include <sys/time.h>
1649 #ifdef TIME_WITH_SYS_TIME
1659 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1665 AC_MSG_RESULT([yes])
1668 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1669 ac_cv_func_clock_gettime="no"
1670 LIBS="$curl_cv_save_LIBS"
1674 case "$ac_cv_func_clock_gettime" in
1676 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1677 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1686 dnl CARES_CHECK_LIBS_CONNECT
1687 dnl -------------------------------------------------
1688 dnl Verify if network connect function is already available
1689 dnl using current libraries or if another one is required.
1691 AC_DEFUN([CARES_CHECK_LIBS_CONNECT], [
1692 AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
1693 AC_MSG_CHECKING([for connect in libraries])
1694 tst_connect_save_LIBS="$LIBS"
1695 tst_connect_need_LIBS="unknown"
1696 for tst_lib in '' '-lsocket' ; do
1697 if test "$tst_connect_need_LIBS" = "unknown"; then
1698 LIBS="$tst_lib $tst_connect_save_LIBS"
1701 $cares_includes_winsock2
1702 #ifndef HAVE_WINDOWS_H
1703 int connect(int, void*, int);
1706 if(0 != connect(0, 0, 0))
1710 tst_connect_need_LIBS="$tst_lib"
1714 LIBS="$tst_connect_save_LIBS"
1716 case X-"$tst_connect_need_LIBS" in
1718 AC_MSG_RESULT([cannot find connect])
1719 AC_MSG_ERROR([cannot find connect function in libraries.])
1722 AC_MSG_RESULT([yes])
1725 AC_MSG_RESULT([$tst_connect_need_LIBS])
1726 LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
1732 dnl CARES_DEFINE_UNQUOTED (VARIABLE, [VALUE])
1733 dnl -------------------------------------------------
1734 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
1735 dnl symbol that can be further used in custom template configuration
1736 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
1737 dnl argument for the description. Symbol definitions done with this
1738 dnl macro are intended to be exclusively used in handcrafted *.h.in
1739 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
1740 dnl prevents autoheader generation and insertion of symbol template
1741 dnl stub and definition into the first configuration header file. Do
1742 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
1743 dnl one serves different functional needs.
1745 AC_DEFUN([CARES_DEFINE_UNQUOTED], [
1746 cat >>confdefs.h <<_EOF
1747 [@%:@define] $1 ifelse($#, 2, [$2], 1)
1752 dnl CARES_CONFIGURE_LONG
1753 dnl -------------------------------------------------
1754 dnl Find out the size of long as reported by sizeof() and define
1755 dnl CARES_SIZEOF_LONG as appropriate to be used in template file
1756 dnl ares_build.h.in to properly configure the library.
1757 dnl The size of long is a build time characteristic and as such
1758 dnl must be recorded in ares_build.h
1760 AC_DEFUN([CARES_CONFIGURE_LONG], [
1761 if test -z "$ac_cv_sizeof_long" ||
1762 test "$ac_cv_sizeof_long" -eq "0"; then
1763 AC_MSG_ERROR([cannot find out size of long.])
1765 CARES_DEFINE_UNQUOTED([CARES_SIZEOF_LONG], [$ac_cv_sizeof_long])
1769 dnl CARES_CONFIGURE_ARES_SOCKLEN_T
1770 dnl -------------------------------------------------
1771 dnl Find out suitable ares_socklen_t data type definition and size, making
1772 dnl appropriate definitions for template file ares_build.h.in
1773 dnl to properly configure and use the library.
1775 dnl The need for the ares_socklen_t definition arises mainly to properly
1776 dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
1777 dnl data type which is 32 or 64-Bit wide depending on the data model being
1778 dnl used, and that on the other hand is only actually used when interfacing
1779 dnl the X/Open sockets provided in the xnet library.
1781 AC_DEFUN([CARES_CONFIGURE_ARES_SOCKLEN_T], [
1782 AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
1783 AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
1784 AC_REQUIRE([CARES_PREPROCESS_CALLCONV])dnl
1786 AC_MSG_CHECKING([for ares_socklen_t data type])
1787 cares_typeof_ares_socklen_t="unknown"
1788 for arg1 in int SOCKET; do
1789 for arg2 in 'struct sockaddr' void; do
1790 for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
1791 if test "$cares_typeof_ares_socklen_t" = "unknown"; then
1794 $cares_includes_ws2tcpip
1795 $cares_includes_sys_socket
1796 $cares_preprocess_callconv
1797 extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
1800 if(0 != getpeername(0, 0, lenptr))
1804 cares_typeof_ares_socklen_t="$t"
1810 for t in socklen_t int; do
1811 if test "$cares_typeof_ares_socklen_t" = "void"; then
1814 $cares_includes_sys_socket
1815 typedef $t ares_socklen_t;
1817 ares_socklen_t dummy;
1820 cares_typeof_ares_socklen_t="$t"
1824 AC_MSG_RESULT([$cares_typeof_ares_socklen_t])
1825 if test "$cares_typeof_ares_socklen_t" = "void" ||
1826 test "$cares_typeof_ares_socklen_t" = "unknown"; then
1827 AC_MSG_ERROR([cannot find data type for ares_socklen_t.])
1830 AC_MSG_CHECKING([size of ares_socklen_t])
1831 cares_sizeof_ares_socklen_t="unknown"
1832 cares_pull_headers_socklen_t="unknown"
1833 if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
1834 tst_pull_header_checks='none ws2tcpip'
1837 tst_pull_header_checks='none systypes syssocket'
1838 tst_size_checks='4 8 2'
1840 for tst_size in $tst_size_checks; do
1841 for tst_pull_headers in $tst_pull_header_checks; do
1842 if test "$cares_sizeof_ares_socklen_t" = "unknown"; then
1843 case $tst_pull_headers in
1845 tmp_includes="$cares_includes_ws2tcpip"
1848 tmp_includes="$cares_includes_sys_types"
1851 tmp_includes="$cares_includes_sys_socket"
1860 typedef $cares_typeof_ares_socklen_t ares_socklen_t;
1861 typedef char dummy_arr[sizeof(ares_socklen_t) == $tst_size ? 1 : -1];
1863 ares_socklen_t dummy;
1866 cares_sizeof_ares_socklen_t="$tst_size"
1867 cares_pull_headers_socklen_t="$tst_pull_headers"
1872 AC_MSG_RESULT([$cares_sizeof_ares_socklen_t])
1873 if test "$cares_sizeof_ares_socklen_t" = "unknown"; then
1874 AC_MSG_ERROR([cannot find out size of ares_socklen_t.])
1877 case $cares_pull_headers_socklen_t in
1879 CARES_DEFINE_UNQUOTED([CARES_PULL_WS2TCPIP_H])
1882 CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_TYPES_H])
1885 CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_TYPES_H])
1886 CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_SOCKET_H])
1889 CARES_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SOCKLEN_T], [$cares_typeof_ares_socklen_t])
1890 CARES_DEFINE_UNQUOTED([CARES_SIZEOF_ARES_SOCKLEN_T], [$cares_sizeof_ares_socklen_t])
1894 dnl This macro determines if the specified struct exists in the specified file
1896 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1898 AC_DEFUN([CARES_CHECK_STRUCT], [
1899 AC_MSG_CHECKING([for struct $2])
1900 AC_TRY_COMPILE([$1],
1902 struct $2 struct_instance;
1903 ], ac_struct="yes", ac_found="no")
1904 if test "$ac_struct" = "yes" ; then
1913 dnl This macro determines if the specified constant exists in the specified file
1915 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
1917 AC_DEFUN([CARES_CHECK_CONSTANT], [
1918 AC_MSG_CHECKING([for $2])
1919 AC_EGREP_CPP(VARIABLEWASDEFINED,
1928 ], ac_constant="yes", ac_constant="no"
1930 if test "$ac_constant" = "yes" ; then