3 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
4 dnl -------------------------------------------------
5 dnl Verifies if the compiler actually halts after the
6 dnl compilation phase without generating any object
7 dnl code file, when the source compiles with errors.
9 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
10 AC_MSG_CHECKING([if compiler halts on compilation errors])
14 force compilation error
18 AC_MSG_ERROR([compiler does not halt on compilation errors.])
25 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
26 dnl -------------------------------------------------
27 dnl Verifies if the compiler actually halts after the
28 dnl compilation phase without generating any object
29 dnl code file, when the source code tries to define a
30 dnl type for a constant array with negative dimension.
32 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
33 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
34 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
37 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
43 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
50 dnl CURL_CHECK_DEF(SYMBOL, [INCLUDES], [SILENT])
51 dnl -------------------------------------------------
52 dnl Use the C preprocessor to find out if the given object-style symbol
53 dnl is defined and get its expansion. This macro will not use default
54 dnl includes even if no INCLUDES argument is given. This macro will run
55 dnl silently when invoked with three arguments.
57 AC_DEFUN([CURL_CHECK_DEF], [
58 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
59 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
60 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
70 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
71 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
72 "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
73 "$SED" 'q' 2>/dev/null`
74 if test "$tmp_exp" = "$1"; then
78 if test -z "$tmp_exp"; then
79 AS_VAR_SET([ac_HaveDef], [no])
80 ifelse($3,,[AC_MSG_RESULT([no])])
82 AS_VAR_SET([ac_HaveDef], [yes])
83 AS_VAR_SET([ac_Def], [$tmp_exp])
84 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
86 AS_VAR_POPDEF([ac_Def])dnl
87 AS_VAR_POPDEF([ac_HaveDef])dnl
91 dnl CONFIGURE_WITH_REENTRANT
92 dnl -------------------------------------------------
93 dnl This macro ensures that configuration tests done
94 dnl after this will execute with preprocessor symbol
95 dnl _REENTRANT defined. This macro also ensures that
96 dnl the generated config file will equally define it.
98 AC_DEFUN([CONFIGURE_WITH_REENTRANT], [
99 AC_BEFORE([$0], [AC_PREPROC_IFELSE])dnl
100 AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
101 AC_BEFORE([$0], [AC_LINK_IFELSE])dnl
102 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
103 AH_VERBATIM([_REENTRANT],
104 [/* Define _REENTRANT if not already defined */
105 @%:@ifndef _REENTRANT
106 @%:@ define _REENTRANT
108 cat >>confdefs.h <<_ACEOF
109 [@%:@ifndef _REENTRANT
110 @%:@ define _REENTRANT
116 dnl CURL_CHECK_HEADER_WINDOWS
117 dnl -------------------------------------------------
118 dnl Check for compilable and valid windows.h header
120 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
121 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
125 #ifndef WIN32_LEAN_AND_MEAN
126 #define WIN32_LEAN_AND_MEAN
130 #if defined(__CYGWIN__) || defined(__CEGCC__)
131 HAVE_WINDOWS_H shall not be defined.
137 ac_cv_header_windows_h="yes"
139 ac_cv_header_windows_h="no"
142 case "$ac_cv_header_windows_h" in
144 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
145 [Define to 1 if you have the windows.h header file.])
146 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
147 [Define to avoid automatic inclusion of winsock.h])
153 dnl CURL_CHECK_NATIVE_WINDOWS
154 dnl -------------------------------------------------
155 dnl Check if building a native Windows target
157 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
158 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
159 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
160 if test "$ac_cv_header_windows_h" = "no"; then
161 ac_cv_native_windows="no"
166 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
167 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
170 Not a native Windows build target.
174 ac_cv_native_windows="yes"
176 ac_cv_native_windows="no"
180 case "$ac_cv_native_windows" in
182 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
183 [Define to 1 if you are building a native Windows target.])
189 dnl CURL_CHECK_HEADER_WINSOCK
190 dnl -------------------------------------------------
191 dnl Check for compilable and valid winsock.h header
193 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
194 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
195 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
199 #ifndef WIN32_LEAN_AND_MEAN
200 #define WIN32_LEAN_AND_MEAN
205 #if defined(__CYGWIN__) || defined(__CEGCC__)
206 HAVE_WINSOCK_H shall not be defined.
208 int dummy=WSACleanup();
212 ac_cv_header_winsock_h="yes"
214 ac_cv_header_winsock_h="no"
217 case "$ac_cv_header_winsock_h" in
219 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
220 [Define to 1 if you have the winsock.h header file.])
226 dnl CURL_CHECK_HEADER_WINSOCK2
227 dnl -------------------------------------------------
228 dnl Check for compilable and valid winsock2.h header
230 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
231 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
232 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
236 #ifndef WIN32_LEAN_AND_MEAN
237 #define WIN32_LEAN_AND_MEAN
240 #include <winsock2.h>
242 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
243 HAVE_WINSOCK2_H shall not be defined.
245 int dummy=2*IPPROTO_ESP;
249 ac_cv_header_winsock2_h="yes"
251 ac_cv_header_winsock2_h="no"
254 case "$ac_cv_header_winsock2_h" in
256 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
257 [Define to 1 if you have the winsock2.h header file.])
263 dnl CURL_CHECK_HEADER_WS2TCPIP
264 dnl -------------------------------------------------
265 dnl Check for compilable and valid ws2tcpip.h header
267 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
268 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
269 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
273 #ifndef WIN32_LEAN_AND_MEAN
274 #define WIN32_LEAN_AND_MEAN
277 #include <winsock2.h>
278 #include <ws2tcpip.h>
280 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
281 HAVE_WS2TCPIP_H shall not be defined.
283 int dummy=2*IP_PKTINFO;
287 ac_cv_header_ws2tcpip_h="yes"
289 ac_cv_header_ws2tcpip_h="no"
292 case "$ac_cv_header_ws2tcpip_h" in
294 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
295 [Define to 1 if you have the ws2tcpip.h header file.])
301 dnl CURL_CHECK_HEADER_MALLOC
302 dnl -------------------------------------------------
303 dnl Check for compilable and valid malloc.h header,
304 dnl and check if it is needed even with stdlib.h
306 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
307 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
312 void *p = malloc(10);
313 void *q = calloc(10,10);
318 ac_cv_header_malloc_h="yes"
320 ac_cv_header_malloc_h="no"
323 if test "$ac_cv_header_malloc_h" = "yes"; then
324 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
325 [Define to 1 if you have the malloc.h header file.])
331 void *p = malloc(10);
332 void *q = calloc(10,10);
337 curl_cv_need_header_malloc_h="no"
339 curl_cv_need_header_malloc_h="yes"
342 case "$curl_cv_need_header_malloc_h" in
344 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
345 [Define to 1 if you need the malloc.h header file even with stdlib.h])
352 dnl CURL_CHECK_TYPE_SOCKLEN_T
353 dnl -------------------------------------------------
354 dnl Check for existing socklen_t type, and provide
355 dnl an equivalent type if socklen_t not available
357 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
358 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
359 AC_CHECK_TYPE([socklen_t], ,[
360 dnl socklen_t not available
361 AC_CACHE_CHECK([for socklen_t equivalent],
362 [curl_cv_socklen_t_equiv], [
363 curl_cv_socklen_t_equiv="unknown"
364 for arg1 in 'int' 'SOCKET'; do
365 for arg2 in "struct sockaddr" void; do
366 for t in int size_t unsigned long "unsigned long"; do
367 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
371 #ifdef HAVE_WINDOWS_H
372 #ifndef WIN32_LEAN_AND_MEAN
373 #define WIN32_LEAN_AND_MEAN
376 #ifdef HAVE_WINSOCK2_H
377 #include <winsock2.h>
379 #ifdef HAVE_WINSOCK_H
383 #define GETPEERNCALLCONV PASCAL
385 #ifdef HAVE_SYS_TYPES_H
386 #include <sys/types.h>
388 #ifdef HAVE_SYS_SOCKET_H
389 #include <sys/socket.h>
391 #define GETPEERNCALLCONV
393 extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
396 getpeername(0,0,&len);
399 curl_cv_socklen_t_equiv="$t"
406 case "$curl_cv_socklen_t_equiv" in
408 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
411 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
412 [Type to use in place of socklen_t when system does not provide it.])
417 #ifdef HAVE_WINDOWS_H
418 #ifndef WIN32_LEAN_AND_MEAN
419 #define WIN32_LEAN_AND_MEAN
422 #ifdef HAVE_WINSOCK2_H
423 #include <winsock2.h>
424 #ifdef HAVE_WS2TCPIP_H
425 #include <ws2tcpip.h>
429 #ifdef HAVE_SYS_TYPES_H
430 #include <sys/types.h>
432 #ifdef HAVE_SYS_SOCKET_H
433 #include <sys/socket.h>
440 dnl CURL_CHECK_FUNC_GETNAMEINFO
441 dnl -------------------------------------------------
442 dnl Test if the getnameinfo function is available,
443 dnl and check the types of five of its arguments.
444 dnl If the function succeeds HAVE_GETNAMEINFO will be
445 dnl defined, defining the types of the arguments in
446 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
447 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
448 dnl and also defining the type qualifier of first
449 dnl argument in GETNAMEINFO_QUAL_ARG1.
451 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
452 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
453 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
454 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
456 AC_MSG_CHECKING([for getnameinfo])
458 AC_LANG_FUNC_LINK_TRY([getnameinfo])
461 curl_cv_getnameinfo="yes"
464 curl_cv_getnameinfo="no"
467 if test "$curl_cv_getnameinfo" != "yes"; then
468 AC_MSG_CHECKING([deeper for getnameinfo])
476 curl_cv_getnameinfo="yes"
478 AC_MSG_RESULT([but still no])
479 curl_cv_getnameinfo="no"
483 if test "$curl_cv_getnameinfo" != "yes"; then
484 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
488 #ifdef HAVE_WINDOWS_H
489 #ifndef WIN32_LEAN_AND_MEAN
490 #define WIN32_LEAN_AND_MEAN
493 #ifdef HAVE_WINSOCK2_H
494 #include <winsock2.h>
495 #ifdef HAVE_WS2TCPIP_H
496 #include <ws2tcpip.h>
500 #ifdef HAVE_SYS_TYPES_H
501 #include <sys/types.h>
503 #ifdef HAVE_SYS_SOCKET_H
504 #include <sys/socket.h>
511 getnameinfo(0, 0, 0, 0, 0, 0, 0);
515 curl_cv_getnameinfo="yes"
517 AC_MSG_RESULT([but still no])
518 curl_cv_getnameinfo="no"
522 if test "$curl_cv_getnameinfo" = "yes"; then
523 AC_CACHE_CHECK([types of arguments for getnameinfo],
524 [curl_cv_func_getnameinfo_args], [
525 curl_cv_func_getnameinfo_args="unknown"
526 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
527 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
528 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
529 for gni_arg7 in 'int' 'unsigned int'; do
530 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
534 #ifdef HAVE_WINDOWS_H
535 #ifndef WIN32_LEAN_AND_MEAN
536 #define WIN32_LEAN_AND_MEAN
538 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
540 #define _WIN32_WINNT 0x0501
543 #ifdef HAVE_WINSOCK2_H
544 #include <winsock2.h>
545 #ifdef HAVE_WS2TCPIP_H
546 #include <ws2tcpip.h>
549 #define GNICALLCONV WSAAPI
551 #ifdef HAVE_SYS_TYPES_H
552 #include <sys/types.h>
554 #ifdef HAVE_SYS_SOCKET_H
555 #include <sys/socket.h>
562 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
568 $gni_arg46 hostlen=0;
569 $gni_arg46 servlen=0;
571 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
574 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
582 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
583 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
584 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
586 gni_prev_IFS=$IFS; IFS=','
587 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
591 gni_qual_type_arg1=$[1]
593 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
594 [Define to the type of arg 2 for getnameinfo.])
595 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
596 [Define to the type of args 4 and 6 for getnameinfo.])
597 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
598 [Define to the type of arg 7 for getnameinfo.])
602 case $prev_sh_opts in
610 case "$gni_qual_type_arg1" in
613 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
617 gni_type_arg1=$gni_qual_type_arg1
621 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
622 [Define to the type qualifier of arg 1 for getnameinfo.])
623 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
624 [Define to the type of arg 1 for getnameinfo.])
626 case $prev_sh_opts in
634 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
635 [Define to 1 if you have the getnameinfo function.])
636 ac_cv_func_getnameinfo="yes"
642 dnl TYPE_SOCKADDR_STORAGE
643 dnl -------------------------------------------------
644 dnl Check for struct sockaddr_storage. Most IPv6-enabled
645 dnl hosts have it, but AIX 4.3 is one known exception.
647 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
649 AC_CHECK_TYPE([struct sockaddr_storage],
650 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
651 [if struct sockaddr_storage is defined]), ,
654 #ifdef HAVE_WINDOWS_H
655 #ifndef WIN32_LEAN_AND_MEAN
656 #define WIN32_LEAN_AND_MEAN
659 #ifdef HAVE_WINSOCK2_H
660 #include <winsock2.h>
663 #ifdef HAVE_SYS_TYPES_H
664 #include <sys/types.h>
666 #ifdef HAVE_SYS_SOCKET_H
667 #include <sys/socket.h>
669 #ifdef HAVE_NETINET_IN_H
670 #include <netinet/in.h>
672 #ifdef HAVE_ARPA_INET_H
673 #include <arpa/inet.h>
680 dnl CURL_CHECK_NI_WITHSCOPEID
681 dnl -------------------------------------------------
682 dnl Check for working NI_WITHSCOPEID in getnameinfo()
684 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
685 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
686 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
687 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
688 netdb.h netinet/in.h arpa/inet.h)
690 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
691 [ac_cv_working_ni_withscopeid], [
697 #ifdef HAVE_SYS_TYPES_H
698 #include <sys/types.h>
700 #ifdef HAVE_SYS_SOCKET_H
701 #include <sys/socket.h>
706 #ifdef HAVE_NETINET_IN_H
707 #include <netinet/in.h>
709 #ifdef HAVE_ARPA_INET_H
710 #include <arpa/inet.h>
713 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
714 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
715 struct sockaddr_storage sa;
717 unsigned char sa[256];
719 char hostbuf[NI_MAXHOST];
721 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
722 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
723 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
724 int fd = socket(AF_INET6, SOCK_STREAM, 0);
727 return 1; /* Error creating socket */
729 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
731 perror("getsockname()");
732 return 2; /* Error retrieving socket name */
734 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
736 printf("rc = %s\n", gai_strerror(rc));
737 return 3; /* Error translating socket address */
739 return 0; /* Ok, NI_WITHSCOPEID works */
741 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
743 ]]) # AC_LANG_PROGRAM
745 # Exit code == 0. Program worked.
746 ac_cv_working_ni_withscopeid="yes"
748 # Exit code != 0. Program failed.
749 ac_cv_working_ni_withscopeid="no"
751 # Program is not run when cross-compiling. So we assume
752 # NI_WITHSCOPEID will work if we are able to compile it.
755 #include <sys/types.h>
756 #include <sys/socket.h>
759 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
762 ac_cv_working_ni_withscopeid="yes"
764 ac_cv_working_ni_withscopeid="no"
765 ]) # AC_COMPILE_IFELSE
768 case "$ac_cv_working_ni_withscopeid" in
770 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
771 [Define to 1 if NI_WITHSCOPEID exists and works.])
777 dnl CURL_CHECK_FUNC_RECV
778 dnl -------------------------------------------------
779 dnl Test if the socket recv() function is available,
780 dnl and check its return type and the types of its
781 dnl arguments. If the function succeeds HAVE_RECV
782 dnl will be defined, defining the types of the arguments
783 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
784 dnl and RECV_TYPE_ARG4, defining the type of the function
785 dnl return value in RECV_TYPE_RETV.
787 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
788 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
789 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
790 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
792 AC_MSG_CHECKING([for recv])
796 #ifdef HAVE_WINDOWS_H
797 #ifndef WIN32_LEAN_AND_MEAN
798 #define WIN32_LEAN_AND_MEAN
801 #ifdef HAVE_WINSOCK2_H
802 #include <winsock2.h>
804 #ifdef HAVE_WINSOCK_H
809 #ifdef HAVE_SYS_TYPES_H
810 #include <sys/types.h>
812 #ifdef HAVE_SYS_SOCKET_H
813 #include <sys/socket.h>
827 if test "$curl_cv_recv" = "yes"; then
828 AC_CACHE_CHECK([types of args and return type for recv],
829 [curl_cv_func_recv_args], [
830 curl_cv_func_recv_args="unknown"
831 for recv_retv in 'int' 'ssize_t'; do
832 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
833 for recv_arg2 in 'char *' 'void *'; do
834 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
835 for recv_arg4 in 'int' 'unsigned int'; do
836 if test "$curl_cv_func_recv_args" = "unknown"; then
840 #ifdef HAVE_WINDOWS_H
841 #ifndef WIN32_LEAN_AND_MEAN
842 #define WIN32_LEAN_AND_MEAN
845 #ifdef HAVE_WINSOCK2_H
846 #include <winsock2.h>
848 #ifdef HAVE_WINSOCK_H
852 #define RECVCALLCONV PASCAL
854 #ifdef HAVE_SYS_TYPES_H
855 #include <sys/types.h>
857 #ifdef HAVE_SYS_SOCKET_H
858 #include <sys/socket.h>
862 extern $recv_retv RECVCALLCONV
863 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
869 $recv_retv res = recv(s, buf, len, flags);
872 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
881 if test "$curl_cv_func_recv_args" = "unknown"; then
882 AC_MSG_ERROR([Cannot find proper types to use for recv args])
884 recv_prev_IFS=$IFS; IFS=','
885 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
889 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
890 [Define to the type of arg 1 for recv.])
891 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
892 [Define to the type of arg 2 for recv.])
893 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
894 [Define to the type of arg 3 for recv.])
895 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
896 [Define to the type of arg 4 for recv.])
897 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
898 [Define to the function return type for recv.])
900 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
901 [Define to 1 if you have the recv function.])
902 ac_cv_func_recv="yes"
905 AC_MSG_ERROR([Unable to link function recv])
910 dnl CURL_CHECK_FUNC_SEND
911 dnl -------------------------------------------------
912 dnl Test if the socket send() function is available,
913 dnl and check its return type and the types of its
914 dnl arguments. If the function succeeds HAVE_SEND
915 dnl will be defined, defining the types of the arguments
916 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
917 dnl and SEND_TYPE_ARG4, defining the type of the function
918 dnl return value in SEND_TYPE_RETV, and also defining the
919 dnl type qualifier of second argument in SEND_QUAL_ARG2.
921 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
922 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
923 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
924 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
926 AC_MSG_CHECKING([for send])
930 #ifdef HAVE_WINDOWS_H
931 #ifndef WIN32_LEAN_AND_MEAN
932 #define WIN32_LEAN_AND_MEAN
935 #ifdef HAVE_WINSOCK2_H
936 #include <winsock2.h>
938 #ifdef HAVE_WINSOCK_H
943 #ifdef HAVE_SYS_TYPES_H
944 #include <sys/types.h>
946 #ifdef HAVE_SYS_SOCKET_H
947 #include <sys/socket.h>
961 if test "$curl_cv_send" = "yes"; then
962 AC_CACHE_CHECK([types of args and return type for send],
963 [curl_cv_func_send_args], [
964 curl_cv_func_send_args="unknown"
965 for send_retv in 'int' 'ssize_t'; do
966 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
967 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
968 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
969 for send_arg4 in 'int' 'unsigned int'; do
970 if test "$curl_cv_func_send_args" = "unknown"; then
974 #ifdef HAVE_WINDOWS_H
975 #ifndef WIN32_LEAN_AND_MEAN
976 #define WIN32_LEAN_AND_MEAN
979 #ifdef HAVE_WINSOCK2_H
980 #include <winsock2.h>
982 #ifdef HAVE_WINSOCK_H
986 #define SENDCALLCONV PASCAL
988 #ifdef HAVE_SYS_TYPES_H
989 #include <sys/types.h>
991 #ifdef HAVE_SYS_SOCKET_H
992 #include <sys/socket.h>
996 extern $send_retv SENDCALLCONV
997 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1002 $send_retv res = send(s, 0, len, flags);
1005 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1014 if test "$curl_cv_func_send_args" = "unknown"; then
1015 AC_MSG_ERROR([Cannot find proper types to use for send args])
1017 send_prev_IFS=$IFS; IFS=','
1018 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1022 send_qual_type_arg2=$[2]
1024 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1025 [Define to the type of arg 1 for send.])
1026 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1027 [Define to the type of arg 3 for send.])
1028 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1029 [Define to the type of arg 4 for send.])
1030 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1031 [Define to the function return type for send.])
1035 case $prev_sh_opts in
1043 case "$send_qual_type_arg2" in
1045 send_qual_arg2=const
1046 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1050 send_type_arg2=$send_qual_type_arg2
1054 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1055 [Define to the type qualifier of arg 2 for send.])
1056 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1057 [Define to the type of arg 2 for send.])
1059 case $prev_sh_opts in
1067 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1068 [Define to 1 if you have the send function.])
1069 ac_cv_func_send="yes"
1072 AC_MSG_ERROR([Unable to link function send])
1077 dnl CURL_CHECK_FUNC_RECVFROM
1078 dnl -------------------------------------------------
1079 dnl Test if the socket recvfrom() function is available,
1080 dnl and check its return type and the types of its
1081 dnl arguments. If the function succeeds HAVE_RECVFROM
1082 dnl will be defined, defining the types of the arguments
1083 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1084 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1085 dnl function return value in RECVFROM_TYPE_RETV.
1086 dnl Notice that the types returned for pointer arguments
1087 dnl will actually be the type pointed by the pointer.
1089 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1090 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1091 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1092 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1094 AC_MSG_CHECKING([for recvfrom])
1098 #ifdef HAVE_WINDOWS_H
1099 #ifndef WIN32_LEAN_AND_MEAN
1100 #define WIN32_LEAN_AND_MEAN
1102 #include <windows.h>
1103 #ifdef HAVE_WINSOCK2_H
1104 #include <winsock2.h>
1106 #ifdef HAVE_WINSOCK_H
1107 #include <winsock.h>
1111 #ifdef HAVE_SYS_TYPES_H
1112 #include <sys/types.h>
1114 #ifdef HAVE_SYS_SOCKET_H
1115 #include <sys/socket.h>
1119 recvfrom(0, 0, 0, 0, 0, 0);
1122 AC_MSG_RESULT([yes])
1123 curl_cv_recvfrom="yes"
1126 curl_cv_recvfrom="no"
1129 if test "$curl_cv_recvfrom" = "yes"; then
1130 AC_CACHE_CHECK([types of args and return type for recvfrom],
1131 [curl_cv_func_recvfrom_args], [
1132 curl_cv_func_recvfrom_args="unknown"
1133 for recvfrom_retv in 'int' 'ssize_t'; do
1134 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1135 for recvfrom_arg2 in 'char *' 'void *'; do
1136 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1137 for recvfrom_arg4 in 'int' 'unsigned int'; do
1138 for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
1139 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1140 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1144 #ifdef HAVE_WINDOWS_H
1145 #ifndef WIN32_LEAN_AND_MEAN
1146 #define WIN32_LEAN_AND_MEAN
1148 #include <windows.h>
1149 #ifdef HAVE_WINSOCK2_H
1150 #include <winsock2.h>
1152 #ifdef HAVE_WINSOCK_H
1153 #include <winsock.h>
1156 #define RECVFROMCALLCONV PASCAL
1158 #ifdef HAVE_SYS_TYPES_H
1159 #include <sys/types.h>
1161 #ifdef HAVE_SYS_SOCKET_H
1162 #include <sys/socket.h>
1164 #define RECVFROMCALLCONV
1166 extern $recvfrom_retv RECVFROMCALLCONV
1167 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1168 $recvfrom_arg3, $recvfrom_arg4,
1169 $recvfrom_arg5, $recvfrom_arg6);
1172 $recvfrom_arg2 buf=0;
1173 $recvfrom_arg3 len=0;
1174 $recvfrom_arg4 flags=0;
1175 $recvfrom_arg5 addr=0;
1176 $recvfrom_arg6 addrlen=0;
1177 $recvfrom_retv res=0;
1178 res = recvfrom(s, buf, len, flags, addr, addrlen);
1181 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1192 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1193 AC_MSG_ERROR([Cannot find proper types to use for recvfrom args])
1195 recvfrom_prev_IFS=$IFS; IFS=','
1196 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1197 IFS=$recvfrom_prev_IFS
1200 recvfrom_ptrt_arg2=$[2]
1201 recvfrom_ptrt_arg5=$[5]
1202 recvfrom_ptrt_arg6=$[6]
1204 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1205 [Define to the type of arg 1 for recvfrom.])
1206 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1207 [Define to the type of arg 3 for recvfrom.])
1208 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1209 [Define to the type of arg 4 for recvfrom.])
1210 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1211 [Define to the function return type for recvfrom.])
1215 case $prev_sh_opts in
1223 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1224 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1225 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1227 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1228 [Define to the type pointed by arg 2 for recvfrom.])
1229 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1230 [Define to the type pointed by arg 5 for recvfrom.])
1231 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1232 [Define to the type pointed by arg 6 for recvfrom.])
1234 if test "$recvfrom_type_arg2" = "void"; then
1235 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1236 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1238 if test "$recvfrom_type_arg5" = "void"; then
1239 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1240 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1242 if test "$recvfrom_type_arg6" = "void"; then
1243 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1244 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1247 case $prev_sh_opts in
1255 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1256 [Define to 1 if you have the recvfrom function.])
1257 ac_cv_func_recvfrom="yes"
1260 AC_MSG_ERROR([Unable to link function recvfrom])
1265 dnl CURL_CHECK_MSG_NOSIGNAL
1266 dnl -------------------------------------------------
1267 dnl Check for MSG_NOSIGNAL
1269 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1270 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1271 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1275 #ifdef HAVE_WINDOWS_H
1276 #ifndef WIN32_LEAN_AND_MEAN
1277 #define WIN32_LEAN_AND_MEAN
1279 #include <windows.h>
1280 #ifdef HAVE_WINSOCK2_H
1281 #include <winsock2.h>
1283 #ifdef HAVE_WINSOCK_H
1284 #include <winsock.h>
1288 #ifdef HAVE_SYS_TYPES_H
1289 #include <sys/types.h>
1291 #ifdef HAVE_SYS_SOCKET_H
1292 #include <sys/socket.h>
1296 int flag=MSG_NOSIGNAL;
1299 ac_cv_msg_nosignal="yes"
1301 ac_cv_msg_nosignal="no"
1304 case "$ac_cv_msg_nosignal" in
1306 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1307 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1313 dnl CURL_CHECK_STRUCT_TIMEVAL
1314 dnl -------------------------------------------------
1315 dnl Check for timeval struct
1317 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1318 AC_REQUIRE([AC_HEADER_TIME])dnl
1319 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1320 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1321 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1322 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1326 #ifdef HAVE_WINDOWS_H
1327 #ifndef WIN32_LEAN_AND_MEAN
1328 #define WIN32_LEAN_AND_MEAN
1330 #include <windows.h>
1331 #ifdef HAVE_WINSOCK2_H
1332 #include <winsock2.h>
1334 #ifdef HAVE_WINSOCK_H
1335 #include <winsock.h>
1339 #ifdef HAVE_SYS_TYPES_H
1340 #include <sys/types.h>
1342 #ifdef HAVE_SYS_TIME_H
1343 #include <sys/time.h>
1344 #ifdef TIME_WITH_SYS_TIME
1358 ac_cv_struct_timeval="yes"
1360 ac_cv_struct_timeval="no"
1363 case "$ac_cv_struct_timeval" in
1365 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1366 [Define to 1 if you have the timeval struct.])
1372 dnl TYPE_SIG_ATOMIC_T
1373 dnl -------------------------------------------------
1374 dnl Check if the sig_atomic_t type is available, and
1375 dnl verify if it is already defined as volatile.
1377 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1378 AC_CHECK_HEADERS(signal.h)
1379 AC_CHECK_TYPE([sig_atomic_t],[
1380 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1381 [Define to 1 if sig_atomic_t is an available typedef.])
1383 #ifdef HAVE_SIGNAL_H
1387 case "$ac_cv_type_sig_atomic_t" in
1390 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1393 #ifdef HAVE_SIGNAL_H
1397 static volatile sig_atomic_t dummy = 0;
1401 ac_cv_sig_atomic_t_volatile="no"
1403 AC_MSG_RESULT([yes])
1404 ac_cv_sig_atomic_t_volatile="yes"
1407 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1408 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1409 [Define to 1 if sig_atomic_t is already defined as volatile.])
1416 dnl CURL_CHECK_NONBLOCKING_SOCKET
1417 dnl -------------------------------------------------
1418 dnl Check for how to set a socket to non-blocking state. There seems to exist
1419 dnl four known different ways, with the one used almost everywhere being POSIX
1420 dnl and XPG3, while the other different ways for different systems (old BSD,
1421 dnl Windows and Amiga).
1423 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1424 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1425 dnl to get caught in this script by using an excessive number of #ifdefs...
1427 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
1428 AC_MSG_CHECKING([non-blocking sockets style])
1433 /* headers for O_NONBLOCK test */
1434 #include <sys/types.h>
1438 #if defined(sun) || defined(__sun__) || \
1439 defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1440 # if defined(__SVR4) || defined(__srv4__)
1441 # define PLATFORM_SOLARIS
1443 # define PLATFORM_SUNOS4
1446 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
1447 # define PLATFORM_AIX_V3
1450 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1451 #error "O_NONBLOCK does not work on this platform"
1454 /* O_NONBLOCK source test */
1456 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1459 dnl the O_NONBLOCK test was fine
1460 nonblock="O_NONBLOCK"
1461 AC_DEFINE(HAVE_O_NONBLOCK, 1,
1462 [use O_NONBLOCK for non-blocking sockets])
1465 if test "$nonblock" = "unknown"; then
1468 /* headers for FIONBIO test */
1470 #include <stropts.h>
1472 /* FIONBIO source test (old-style unix) */
1474 int flags = ioctl(socket, FIONBIO, &flags);
1477 dnl FIONBIO test was good
1479 AC_DEFINE(HAVE_FIONBIO, 1,
1480 [use FIONBIO for non-blocking sockets])
1484 if test "$nonblock" = "unknown"; then
1487 /* headers for ioctlsocket test (Windows) */
1489 #ifdef HAVE_WINDOWS_H
1490 #ifndef WIN32_LEAN_AND_MEAN
1491 #define WIN32_LEAN_AND_MEAN
1493 #include <windows.h>
1494 #ifdef HAVE_WINSOCK2_H
1495 #include <winsock2.h>
1497 #ifdef HAVE_WINSOCK_H
1498 #include <winsock.h>
1503 /* ioctlsocket source code (Windows) */
1505 unsigned long flags = 0;
1506 sd = socket(0, 0, 0);
1507 ioctlsocket(sd, FIONBIO, &flags);
1510 dnl ioctlsocket test was good
1511 nonblock="ioctlsocket"
1512 AC_DEFINE(HAVE_IOCTLSOCKET, 1,
1513 [use ioctlsocket() for non-blocking sockets])
1517 if test "$nonblock" = "unknown"; then
1520 /* headers for IoctlSocket test (Amiga?) */
1521 #include <sys/ioctl.h>
1523 /* IoctlSocket source code (Amiga?) */
1525 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1528 dnl Ioctlsocket test was good
1529 nonblock="IoctlSocket"
1530 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
1531 [use Ioctlsocket() for non-blocking sockets])
1535 if test "$nonblock" = "unknown"; then
1538 /* headers for SO_NONBLOCK test (BeOS) */
1541 /* SO_NONBLOCK source code (BeOS) */
1544 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1547 dnl the SO_NONBLOCK test was good
1548 nonblock="SO_NONBLOCK"
1549 AC_DEFINE(HAVE_SO_NONBLOCK, 1,
1550 [use SO_NONBLOCK for non-blocking sockets])
1554 AC_MSG_RESULT($nonblock)
1556 if test "$nonblock" = "unknown"; then
1557 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
1558 [disabled non-blocking sockets])
1559 AC_MSG_WARN([non-block sockets disabled])
1565 dnl -------------------------------------------------
1566 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1567 dnl and a few other things.
1569 AC_DEFUN([TYPE_IN_ADDR_T], [
1570 AC_CHECK_TYPE([in_addr_t], ,[
1571 dnl in_addr_t not available
1572 AC_CACHE_CHECK([for in_addr_t equivalent],
1573 [curl_cv_in_addr_t_equiv], [
1574 curl_cv_in_addr_t_equiv="unknown"
1575 for t in "unsigned long" int size_t unsigned long; do
1576 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1580 #ifdef HAVE_WINDOWS_H
1581 #ifndef WIN32_LEAN_AND_MEAN
1582 #define WIN32_LEAN_AND_MEAN
1584 #include <windows.h>
1585 #ifdef HAVE_WINSOCK2_H
1586 #include <winsock2.h>
1588 #ifdef HAVE_WINSOCK_H
1589 #include <winsock.h>
1593 #ifdef HAVE_SYS_TYPES_H
1594 #include <sys/types.h>
1596 #ifdef HAVE_SYS_SOCKET_H
1597 #include <sys/socket.h>
1599 #ifdef HAVE_NETINET_IN_H
1600 #include <netinet/in.h>
1602 #ifdef HAVE_ARPA_INET_H
1603 #include <arpa/inet.h>
1607 $t data = inet_addr ("1.2.3.4");
1610 curl_cv_in_addr_t_equiv="$t"
1615 case "$curl_cv_in_addr_t_equiv" in
1617 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1620 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1621 [Type to use in place of in_addr_t when system does not provide it.])
1626 #ifdef HAVE_WINDOWS_H
1627 #ifndef WIN32_LEAN_AND_MEAN
1628 #define WIN32_LEAN_AND_MEAN
1630 #include <windows.h>
1631 #ifdef HAVE_WINSOCK2_H
1632 #include <winsock2.h>
1634 #ifdef HAVE_WINSOCK_H
1635 #include <winsock.h>
1639 #ifdef HAVE_SYS_TYPES_H
1640 #include <sys/types.h>
1642 #ifdef HAVE_SYS_SOCKET_H
1643 #include <sys/socket.h>
1645 #ifdef HAVE_NETINET_IN_H
1646 #include <netinet/in.h>
1648 #ifdef HAVE_ARPA_INET_H
1649 #include <arpa/inet.h>
1652 ]) dnl AC_CHECK_TYPE
1656 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1657 dnl -------------------------------------------------
1658 dnl Check if monotonic clock_gettime is available.
1660 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1661 AC_REQUIRE([AC_HEADER_TIME])dnl
1662 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1663 AC_MSG_CHECKING([for monotonic clock_gettime])
1666 #ifdef HAVE_SYS_TYPES_H
1667 #include <sys/types.h>
1669 #ifdef HAVE_SYS_TIME_H
1670 #include <sys/time.h>
1671 #ifdef TIME_WITH_SYS_TIME
1681 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1684 AC_MSG_RESULT([yes])
1685 ac_cv_func_clock_gettime="yes"
1688 ac_cv_func_clock_gettime="no"
1690 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1691 dnl until library linking and run-time checks for clock_gettime succeed.
1695 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1696 dnl -------------------------------------------------
1697 dnl If monotonic clock_gettime is available then,
1698 dnl check and prepended to LIBS any needed libraries.
1700 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1701 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1703 if test "$ac_cv_func_clock_gettime" = "yes"; then
1705 AC_MSG_CHECKING([for clock_gettime in libraries])
1707 curl_cv_save_LIBS="$LIBS"
1708 curl_cv_gclk_LIBS="unknown"
1710 for x_xlibs in '' '-lrt' '-lposix4' ; do
1711 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1712 if test -z "$x_xlibs"; then
1713 LIBS="$curl_cv_save_LIBS"
1715 LIBS="$x_xlibs $curl_cv_save_LIBS"
1719 #ifdef HAVE_SYS_TYPES_H
1720 #include <sys/types.h>
1722 #ifdef HAVE_SYS_TIME_H
1723 #include <sys/time.h>
1724 #ifdef TIME_WITH_SYS_TIME
1734 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1737 curl_cv_gclk_LIBS="$x_xlibs"
1742 LIBS="$curl_cv_save_LIBS"
1744 case X-"$curl_cv_gclk_LIBS" in
1746 AC_MSG_RESULT([cannot find clock_gettime])
1747 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1748 ac_cv_func_clock_gettime="no"
1751 AC_MSG_RESULT([no additional lib required])
1752 ac_cv_func_clock_gettime="yes"
1755 if test -z "$curl_cv_save_LIBS"; then
1756 LIBS="$curl_cv_gclk_LIBS"
1758 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1760 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1761 ac_cv_func_clock_gettime="yes"
1765 dnl only do runtime verification when not cross-compiling
1766 if test "x$cross_compiling" != "xyes" &&
1767 test "$ac_cv_func_clock_gettime" = "yes"; then
1768 AC_MSG_CHECKING([if monotonic clock_gettime works])
1771 #ifdef HAVE_SYS_TYPES_H
1772 #include <sys/types.h>
1774 #ifdef HAVE_SYS_TIME_H
1775 #include <sys/time.h>
1776 #ifdef TIME_WITH_SYS_TIME
1786 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1792 AC_MSG_RESULT([yes])
1795 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1796 ac_cv_func_clock_gettime="no"
1797 LIBS="$curl_cv_save_LIBS"
1801 case "$ac_cv_func_clock_gettime" in
1803 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1804 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1813 dnl **********************************************************************
1814 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
1816 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
1817 dnl sets the $ICC variable to "yes" or "no"
1818 dnl **********************************************************************
1819 AC_DEFUN([CURL_DETECT_ICC],
1822 AC_MSG_CHECKING([for icc in use])
1823 if test "$GCC" = "yes"; then
1824 dnl check if this is icc acting as gcc in disguise
1825 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
1826 dnl action if the text is found, this it has not been replaced by the
1829 dnl the text was not found, it was replaced by the cpp
1831 AC_MSG_RESULT([yes])
1835 if test "$ICC" = "no"; then
1841 dnl We create a function for detecting which compiler we use and then set as
1842 dnl pendantic compiler options as possible for that particular compiler. The
1843 dnl options are only used for debug-builds.
1845 dnl This is a copy of the original found in curl's configure script. Don't
1846 dnl modify this one, edit the one in curl and copy it back here when that one
1849 AC_DEFUN([CURL_CC_DEBUG_OPTS],
1851 if test "z$ICC" = "z"; then
1855 if test "$GCC" = "yes"; then
1857 dnl figure out gcc version!
1858 AC_MSG_CHECKING([gcc version])
1859 gccver=`$CC -dumpversion`
1860 num1=`echo $gccver | cut -d . -f1`
1861 num2=`echo $gccver | cut -d . -f2`
1862 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
1863 AC_MSG_RESULT($gccver)
1865 if test "$ICC" = "yes"; then
1866 dnl this is icc, not gcc.
1868 dnl ICC warnings we ignore:
1869 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
1870 dnl "invalid format string conversion"
1871 dnl * 279 warns on static conditions in while expressions
1872 dnl * 981 warns on "operands are evaluated in unspecified order"
1873 dnl * 1418 "external definition with no prior declaration"
1874 dnl * 1419 warns on "external declaration in primary source file"
1875 dnl which we know and do on purpose.
1877 WARN="-wd279,269,981,1418,1419"
1879 if test "$gccnum" -gt "600"; then
1880 dnl icc 6.0 and older doesn't have the -Wall flag
1884 dnl this is a set of options we believe *ALL* gcc versions support:
1885 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
1887 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
1889 if test "$gccnum" -ge "207"; then
1890 dnl gcc 2.7 or later
1891 WARN="$WARN -Wmissing-declarations"
1894 if test "$gccnum" -gt "295"; then
1895 dnl only if the compiler is newer than 2.95 since we got lots of
1896 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
1897 dnl gcc 2.95.4 on FreeBSD 4.9!
1898 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
1901 if test "$gccnum" -ge "296"; then
1902 dnl gcc 2.96 or later
1903 WARN="$WARN -Wfloat-equal"
1906 if test "$gccnum" -gt "296"; then
1907 dnl this option does not exist in 2.96
1908 WARN="$WARN -Wno-format-nonliteral"
1911 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1912 dnl on i686-Linux as it gives us heaps with false positives.
1913 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
1914 dnl over making it unusable for generic purposes. Let's not use it.
1916 if test "$gccnum" -ge "303"; then
1917 dnl gcc 3.3 and later
1918 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
1921 if test "$gccnum" -ge "304"; then
1922 # try these on gcc 3.4
1923 WARN="$WARN -Wdeclaration-after-statement"
1926 for flag in $CPPFLAGS; do
1929 dnl Include path, provide a -isystem option for the same dir
1930 dnl to prevent warnings in those dirs. The -isystem was not very
1931 dnl reliable on earlier gcc versions.
1932 add=`echo $flag | sed 's/^-I/-isystem /g'`
1940 CFLAGS="$CFLAGS $WARN"
1942 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
1946 AC_MSG_NOTICE([Added no extra compiler options])
1950 dnl strip off optimizer flags
1952 for flag in $CFLAGS; do
1955 dnl echo "cut off $flag"
1958 NEWFLAGS="$NEWFLAGS $flag"
1964 ]) dnl end of AC_DEFUN()
1967 dnl This macro determines if the specified struct exists in the specified file
1969 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1971 AC_DEFUN([CARES_CHECK_STRUCT], [
1972 AC_MSG_CHECKING([for struct $2])
1973 AC_TRY_COMPILE([$1],
1975 struct $2 struct_instance;
1976 ], ac_struct="yes", ac_found="no")
1977 if test "$ac_struct" = "yes" ; then
1986 dnl This macro determines if the specified constant exists in the specified file
1988 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
1990 AC_DEFUN([CARES_CHECK_CONSTANT], [
1991 AC_MSG_CHECKING([for $2])
1992 AC_EGREP_CPP(VARIABLEWASDEFINED,
2001 ], ac_constant="yes", ac_constant="no"
2003 if test "$ac_constant" = "yes" ; then
2013 dnl CARES_CHECK_GETSERVBYPORT_R
2014 dnl -------------------------------------------------
2015 dnl Test if the getservbyport_r function is available,
2016 dnl and find out how many parameters it takes.
2018 AC_DEFUN([CARES_CHECK_GETSERVBYPORT_R], [
2019 AC_CHECK_HEADERS(sys/types.h netdb.h)
2021 AC_MSG_CHECKING([for getservbyport_r])
2023 AC_LANG_FUNC_LINK_TRY([getservbyport_r])
2025 AC_MSG_RESULT([yes])
2026 cares_cv_getservbyport_r="yes"
2029 cares_cv_getservbyport_r="no"
2032 if test "$cares_cv_getservbyport_r" != "yes"; then
2033 AC_MSG_CHECKING([deeper for getservbyport_r])
2040 AC_MSG_RESULT([yes])
2041 cares_cv_getservbyport_r="yes"
2043 AC_MSG_RESULT([but still no])
2044 cares_cv_getservbyport_r="no"
2048 if test "$cares_cv_getservbyport_r" = "yes"; then
2049 AC_MSG_CHECKING([how many arguments getservbyport_r takes])
2050 cares_cv_getservbyport_r_nargs="unknown"
2054 #ifdef HAVE_SYS_TYPES_H
2055 #include <sys/types.h>
2061 getservbyport_r(int, const char*, struct servent*,
2062 struct servent_data*);
2067 struct servent_data *p4;
2068 res = getservbyport_r(p1, p2, p3, p4);
2071 cares_cv_getservbyport_r_nargs="4"
2074 if test "$cares_cv_getservbyport_r_nargs" = "unknown"; then
2077 #ifdef HAVE_SYS_TYPES_H
2078 #include <sys/types.h>
2083 extern struct servent*
2084 getservbyport_r(int, const char*, struct servent*,
2089 struct servent *p3, res;
2090 res = getservbyport_r(p1, p2, p3, p4, p5);
2093 cares_cv_getservbyport_r_nargs="5"
2097 if test "$cares_cv_getservbyport_r_nargs" = "unknown"; then
2100 #ifdef HAVE_SYS_TYPES_H
2101 #include <sys/types.h>
2107 getservbyport_r(int, const char*, struct servent*,
2108 char*, size_t, struct servent**);
2113 struct servent *p3, *p6;
2114 res = getservbyport_r(p1, p2, p3, p4, p5, &p6);
2117 cares_cv_getservbyport_r_nargs="6"
2121 AC_MSG_RESULT([$cares_cv_getservbyport_r_nargs])
2123 if test "$cares_cv_getservbyport_r_nargs" = "unknown"; then
2124 AC_MSG_WARN([HAVE_GETSERVBYPORT_R will not be defined])
2126 AC_DEFINE(HAVE_GETSERVBYPORT_R, 1,
2127 [Specifies whether getservbyport_r is present])
2128 AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $cares_cv_getservbyport_r_nargs,
2129 [Specifies the number of arguments to getservbyport_r])
2130 if test "$cares_cv_getservbyport_r_nargs" = "4" ; then
2131 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
2132 [Specifies the size of the buffer to pass to getservbyport_r])
2134 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
2135 [Specifies the size of the buffer to pass to getservbyport_r])