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 if test -z "$SED"; then
61 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
63 if test -z "$GREP"; then
64 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
66 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
76 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
77 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
78 "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
79 "$SED" 'q' 2>/dev/null`
80 if test "$tmp_exp" = "$1"; then
84 if test -z "$tmp_exp"; then
85 AS_VAR_SET([ac_HaveDef], [no])
86 ifelse($3,,[AC_MSG_RESULT([no])])
88 AS_VAR_SET([ac_HaveDef], [yes])
89 AS_VAR_SET([ac_Def], [$tmp_exp])
90 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
92 AS_VAR_POPDEF([ac_Def])dnl
93 AS_VAR_POPDEF([ac_HaveDef])dnl
97 dnl CURL_CHECK_HEADER_WINDOWS
98 dnl -------------------------------------------------
99 dnl Check for compilable and valid windows.h header
101 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
102 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
106 #ifndef WIN32_LEAN_AND_MEAN
107 #define WIN32_LEAN_AND_MEAN
111 #if defined(__CYGWIN__) || defined(__CEGCC__)
112 HAVE_WINDOWS_H shall not be defined.
118 ac_cv_header_windows_h="yes"
120 ac_cv_header_windows_h="no"
123 case "$ac_cv_header_windows_h" in
125 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
126 [Define to 1 if you have the windows.h header file.])
127 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
128 [Define to avoid automatic inclusion of winsock.h])
134 dnl CURL_CHECK_NATIVE_WINDOWS
135 dnl -------------------------------------------------
136 dnl Check if building a native Windows target
138 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
139 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
140 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
141 if test "$ac_cv_header_windows_h" = "no"; then
142 ac_cv_native_windows="no"
147 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
148 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
151 Not a native Windows build target.
155 ac_cv_native_windows="yes"
157 ac_cv_native_windows="no"
161 case "$ac_cv_native_windows" in
163 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
164 [Define to 1 if you are building a native Windows target.])
170 dnl CURL_CHECK_HEADER_WINSOCK
171 dnl -------------------------------------------------
172 dnl Check for compilable and valid winsock.h header
174 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
175 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
176 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
180 #ifndef WIN32_LEAN_AND_MEAN
181 #define WIN32_LEAN_AND_MEAN
186 #if defined(__CYGWIN__) || defined(__CEGCC__)
187 HAVE_WINSOCK_H shall not be defined.
189 int dummy=WSACleanup();
193 ac_cv_header_winsock_h="yes"
195 ac_cv_header_winsock_h="no"
198 case "$ac_cv_header_winsock_h" in
200 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
201 [Define to 1 if you have the winsock.h header file.])
207 dnl CURL_CHECK_HEADER_WINSOCK2
208 dnl -------------------------------------------------
209 dnl Check for compilable and valid winsock2.h header
211 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
212 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
213 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
217 #ifndef WIN32_LEAN_AND_MEAN
218 #define WIN32_LEAN_AND_MEAN
221 #include <winsock2.h>
223 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
224 HAVE_WINSOCK2_H shall not be defined.
226 int dummy=2*IPPROTO_ESP;
230 ac_cv_header_winsock2_h="yes"
232 ac_cv_header_winsock2_h="no"
235 case "$ac_cv_header_winsock2_h" in
237 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
238 [Define to 1 if you have the winsock2.h header file.])
244 dnl CURL_CHECK_HEADER_WS2TCPIP
245 dnl -------------------------------------------------
246 dnl Check for compilable and valid ws2tcpip.h header
248 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
249 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
250 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
254 #ifndef WIN32_LEAN_AND_MEAN
255 #define WIN32_LEAN_AND_MEAN
258 #include <winsock2.h>
259 #include <ws2tcpip.h>
261 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
262 HAVE_WS2TCPIP_H shall not be defined.
264 int dummy=2*IP_PKTINFO;
268 ac_cv_header_ws2tcpip_h="yes"
270 ac_cv_header_ws2tcpip_h="no"
273 case "$ac_cv_header_ws2tcpip_h" in
275 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
276 [Define to 1 if you have the ws2tcpip.h header file.])
282 dnl CURL_CHECK_HEADER_MALLOC
283 dnl -------------------------------------------------
284 dnl Check for compilable and valid malloc.h header,
285 dnl and check if it is needed even with stdlib.h
287 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
288 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
293 void *p = malloc(10);
294 void *q = calloc(10,10);
299 ac_cv_header_malloc_h="yes"
301 ac_cv_header_malloc_h="no"
304 if test "$ac_cv_header_malloc_h" = "yes"; then
305 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
306 [Define to 1 if you have the malloc.h header file.])
312 void *p = malloc(10);
313 void *q = calloc(10,10);
318 curl_cv_need_header_malloc_h="no"
320 curl_cv_need_header_malloc_h="yes"
323 case "$curl_cv_need_header_malloc_h" in
325 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
326 [Define to 1 if you need the malloc.h header file even with stdlib.h])
333 dnl CURL_CHECK_TYPE_SOCKLEN_T
334 dnl -------------------------------------------------
335 dnl Check for existing socklen_t type, and provide
336 dnl an equivalent type if socklen_t not available
338 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
339 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
340 AC_CHECK_TYPE([socklen_t], ,[
341 dnl socklen_t not available
342 AC_CACHE_CHECK([for socklen_t equivalent],
343 [curl_cv_socklen_t_equiv], [
344 curl_cv_socklen_t_equiv="unknown"
345 for arg1 in 'int' 'SOCKET'; do
346 for arg2 in "struct sockaddr" void; do
347 for t in int size_t unsigned long "unsigned long"; do
348 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
352 #ifdef HAVE_WINDOWS_H
353 #ifndef WIN32_LEAN_AND_MEAN
354 #define WIN32_LEAN_AND_MEAN
357 #ifdef HAVE_WINSOCK2_H
358 #include <winsock2.h>
360 #ifdef HAVE_WINSOCK_H
364 #define GETPEERNCALLCONV PASCAL
366 #ifdef HAVE_SYS_TYPES_H
367 #include <sys/types.h>
369 #ifdef HAVE_SYS_SOCKET_H
370 #include <sys/socket.h>
372 #define GETPEERNCALLCONV
374 extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
377 getpeername(0,0,&len);
380 curl_cv_socklen_t_equiv="$t"
387 case "$curl_cv_socklen_t_equiv" in
389 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
392 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
393 [Type to use in place of socklen_t when system does not provide it.])
398 #ifdef HAVE_WINDOWS_H
399 #ifndef WIN32_LEAN_AND_MEAN
400 #define WIN32_LEAN_AND_MEAN
403 #ifdef HAVE_WINSOCK2_H
404 #include <winsock2.h>
405 #ifdef HAVE_WS2TCPIP_H
406 #include <ws2tcpip.h>
410 #ifdef HAVE_SYS_TYPES_H
411 #include <sys/types.h>
413 #ifdef HAVE_SYS_SOCKET_H
414 #include <sys/socket.h>
421 dnl CURL_CHECK_FUNC_GETNAMEINFO
422 dnl -------------------------------------------------
423 dnl Test if the getnameinfo function is available,
424 dnl and check the types of five of its arguments.
425 dnl If the function succeeds HAVE_GETNAMEINFO will be
426 dnl defined, defining the types of the arguments in
427 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
428 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
429 dnl and also defining the type qualifier of first
430 dnl argument in GETNAMEINFO_QUAL_ARG1.
432 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
433 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
434 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
435 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
437 AC_MSG_CHECKING([for getnameinfo])
439 AC_LANG_FUNC_LINK_TRY([getnameinfo])
442 curl_cv_getnameinfo="yes"
445 curl_cv_getnameinfo="no"
448 if test "$curl_cv_getnameinfo" != "yes"; then
449 AC_MSG_CHECKING([deeper for getnameinfo])
457 curl_cv_getnameinfo="yes"
459 AC_MSG_RESULT([but still no])
460 curl_cv_getnameinfo="no"
464 if test "$curl_cv_getnameinfo" != "yes"; then
465 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
469 #ifdef HAVE_WINDOWS_H
470 #ifndef WIN32_LEAN_AND_MEAN
471 #define WIN32_LEAN_AND_MEAN
474 #ifdef HAVE_WINSOCK2_H
475 #include <winsock2.h>
476 #ifdef HAVE_WS2TCPIP_H
477 #include <ws2tcpip.h>
481 #ifdef HAVE_SYS_TYPES_H
482 #include <sys/types.h>
484 #ifdef HAVE_SYS_SOCKET_H
485 #include <sys/socket.h>
492 getnameinfo(0, 0, 0, 0, 0, 0, 0);
496 curl_cv_getnameinfo="yes"
498 AC_MSG_RESULT([but still no])
499 curl_cv_getnameinfo="no"
503 if test "$curl_cv_getnameinfo" = "yes"; then
504 AC_CACHE_CHECK([types of arguments for getnameinfo],
505 [curl_cv_func_getnameinfo_args], [
506 curl_cv_func_getnameinfo_args="unknown"
507 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
508 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
509 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
510 for gni_arg7 in 'int' 'unsigned int'; do
511 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
515 #ifdef HAVE_WINDOWS_H
516 #ifndef WIN32_LEAN_AND_MEAN
517 #define WIN32_LEAN_AND_MEAN
519 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
521 #define _WIN32_WINNT 0x0501
524 #ifdef HAVE_WINSOCK2_H
525 #include <winsock2.h>
526 #ifdef HAVE_WS2TCPIP_H
527 #include <ws2tcpip.h>
530 #define GNICALLCONV WSAAPI
532 #ifdef HAVE_SYS_TYPES_H
533 #include <sys/types.h>
535 #ifdef HAVE_SYS_SOCKET_H
536 #include <sys/socket.h>
543 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
549 $gni_arg46 hostlen=0;
550 $gni_arg46 servlen=0;
552 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
555 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
563 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
564 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
565 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
567 gni_prev_IFS=$IFS; IFS=','
568 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
572 gni_qual_type_arg1=$[1]
574 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
575 [Define to the type of arg 2 for getnameinfo.])
576 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
577 [Define to the type of args 4 and 6 for getnameinfo.])
578 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
579 [Define to the type of arg 7 for getnameinfo.])
583 case $prev_sh_opts in
591 case "$gni_qual_type_arg1" in
594 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
598 gni_type_arg1=$gni_qual_type_arg1
602 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
603 [Define to the type qualifier of arg 1 for getnameinfo.])
604 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
605 [Define to the type of arg 1 for getnameinfo.])
607 case $prev_sh_opts in
615 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
616 [Define to 1 if you have the getnameinfo function.])
617 ac_cv_func_getnameinfo="yes"
623 dnl TYPE_SOCKADDR_STORAGE
624 dnl -------------------------------------------------
625 dnl Check for struct sockaddr_storage. Most IPv6-enabled
626 dnl hosts have it, but AIX 4.3 is one known exception.
628 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
630 AC_CHECK_TYPE([struct sockaddr_storage],
631 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
632 [if struct sockaddr_storage is defined]), ,
635 #ifdef HAVE_WINDOWS_H
636 #ifndef WIN32_LEAN_AND_MEAN
637 #define WIN32_LEAN_AND_MEAN
640 #ifdef HAVE_WINSOCK2_H
641 #include <winsock2.h>
644 #ifdef HAVE_SYS_TYPES_H
645 #include <sys/types.h>
647 #ifdef HAVE_SYS_SOCKET_H
648 #include <sys/socket.h>
650 #ifdef HAVE_NETINET_IN_H
651 #include <netinet/in.h>
653 #ifdef HAVE_ARPA_INET_H
654 #include <arpa/inet.h>
661 dnl CURL_CHECK_NI_WITHSCOPEID
662 dnl -------------------------------------------------
663 dnl Check for working NI_WITHSCOPEID in getnameinfo()
665 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
666 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
667 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
668 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
669 netdb.h netinet/in.h arpa/inet.h)
671 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
672 [ac_cv_working_ni_withscopeid], [
678 #ifdef HAVE_SYS_TYPES_H
679 #include <sys/types.h>
681 #ifdef HAVE_SYS_SOCKET_H
682 #include <sys/socket.h>
687 #ifdef HAVE_NETINET_IN_H
688 #include <netinet/in.h>
690 #ifdef HAVE_ARPA_INET_H
691 #include <arpa/inet.h>
694 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
695 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
696 struct sockaddr_storage sa;
698 unsigned char sa[256];
700 char hostbuf[NI_MAXHOST];
702 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
703 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
704 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
705 int fd = socket(AF_INET6, SOCK_STREAM, 0);
708 return 1; /* Error creating socket */
710 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
712 perror("getsockname()");
713 return 2; /* Error retrieving socket name */
715 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
717 printf("rc = %s\n", gai_strerror(rc));
718 return 3; /* Error translating socket address */
720 return 0; /* Ok, NI_WITHSCOPEID works */
722 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
724 ]]) # AC_LANG_PROGRAM
726 # Exit code == 0. Program worked.
727 ac_cv_working_ni_withscopeid="yes"
729 # Exit code != 0. Program failed.
730 ac_cv_working_ni_withscopeid="no"
732 # Program is not run when cross-compiling. So we assume
733 # NI_WITHSCOPEID will work if we are able to compile it.
736 #include <sys/types.h>
737 #include <sys/socket.h>
740 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
743 ac_cv_working_ni_withscopeid="yes"
745 ac_cv_working_ni_withscopeid="no"
746 ]) # AC_COMPILE_IFELSE
749 case "$ac_cv_working_ni_withscopeid" in
751 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
752 [Define to 1 if NI_WITHSCOPEID exists and works.])
758 dnl CURL_CHECK_FUNC_RECV
759 dnl -------------------------------------------------
760 dnl Test if the socket recv() function is available,
761 dnl and check its return type and the types of its
762 dnl arguments. If the function succeeds HAVE_RECV
763 dnl will be defined, defining the types of the arguments
764 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
765 dnl and RECV_TYPE_ARG4, defining the type of the function
766 dnl return value in RECV_TYPE_RETV.
768 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
769 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
770 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
771 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
773 AC_MSG_CHECKING([for recv])
777 #ifdef HAVE_WINDOWS_H
778 #ifndef WIN32_LEAN_AND_MEAN
779 #define WIN32_LEAN_AND_MEAN
782 #ifdef HAVE_WINSOCK2_H
783 #include <winsock2.h>
785 #ifdef HAVE_WINSOCK_H
790 #ifdef HAVE_SYS_TYPES_H
791 #include <sys/types.h>
793 #ifdef HAVE_SYS_SOCKET_H
794 #include <sys/socket.h>
808 if test "$curl_cv_recv" = "yes"; then
809 AC_CACHE_CHECK([types of args and return type for recv],
810 [curl_cv_func_recv_args], [
811 curl_cv_func_recv_args="unknown"
812 for recv_retv in 'int' 'ssize_t'; do
813 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
814 for recv_arg2 in 'char *' 'void *'; do
815 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
816 for recv_arg4 in 'int' 'unsigned int'; do
817 if test "$curl_cv_func_recv_args" = "unknown"; then
821 #ifdef HAVE_WINDOWS_H
822 #ifndef WIN32_LEAN_AND_MEAN
823 #define WIN32_LEAN_AND_MEAN
826 #ifdef HAVE_WINSOCK2_H
827 #include <winsock2.h>
829 #ifdef HAVE_WINSOCK_H
833 #define RECVCALLCONV PASCAL
835 #ifdef HAVE_SYS_TYPES_H
836 #include <sys/types.h>
838 #ifdef HAVE_SYS_SOCKET_H
839 #include <sys/socket.h>
843 extern $recv_retv RECVCALLCONV
844 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
850 $recv_retv res = recv(s, buf, len, flags);
853 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
862 if test "$curl_cv_func_recv_args" = "unknown"; then
863 AC_MSG_ERROR([Cannot find proper types to use for recv args])
865 recv_prev_IFS=$IFS; IFS=','
866 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
870 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
871 [Define to the type of arg 1 for recv.])
872 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
873 [Define to the type of arg 2 for recv.])
874 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
875 [Define to the type of arg 3 for recv.])
876 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
877 [Define to the type of arg 4 for recv.])
878 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
879 [Define to the function return type for recv.])
881 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
882 [Define to 1 if you have the recv function.])
883 ac_cv_func_recv="yes"
886 AC_MSG_ERROR([Unable to link function recv])
891 dnl CURL_CHECK_FUNC_SEND
892 dnl -------------------------------------------------
893 dnl Test if the socket send() function is available,
894 dnl and check its return type and the types of its
895 dnl arguments. If the function succeeds HAVE_SEND
896 dnl will be defined, defining the types of the arguments
897 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
898 dnl and SEND_TYPE_ARG4, defining the type of the function
899 dnl return value in SEND_TYPE_RETV, and also defining the
900 dnl type qualifier of second argument in SEND_QUAL_ARG2.
902 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
903 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
904 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
905 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
907 AC_MSG_CHECKING([for send])
911 #ifdef HAVE_WINDOWS_H
912 #ifndef WIN32_LEAN_AND_MEAN
913 #define WIN32_LEAN_AND_MEAN
916 #ifdef HAVE_WINSOCK2_H
917 #include <winsock2.h>
919 #ifdef HAVE_WINSOCK_H
924 #ifdef HAVE_SYS_TYPES_H
925 #include <sys/types.h>
927 #ifdef HAVE_SYS_SOCKET_H
928 #include <sys/socket.h>
942 if test "$curl_cv_send" = "yes"; then
943 AC_CACHE_CHECK([types of args and return type for send],
944 [curl_cv_func_send_args], [
945 curl_cv_func_send_args="unknown"
946 for send_retv in 'int' 'ssize_t'; do
947 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
948 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
949 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
950 for send_arg4 in 'int' 'unsigned int'; do
951 if test "$curl_cv_func_send_args" = "unknown"; then
955 #ifdef HAVE_WINDOWS_H
956 #ifndef WIN32_LEAN_AND_MEAN
957 #define WIN32_LEAN_AND_MEAN
960 #ifdef HAVE_WINSOCK2_H
961 #include <winsock2.h>
963 #ifdef HAVE_WINSOCK_H
967 #define SENDCALLCONV PASCAL
969 #ifdef HAVE_SYS_TYPES_H
970 #include <sys/types.h>
972 #ifdef HAVE_SYS_SOCKET_H
973 #include <sys/socket.h>
977 extern $send_retv SENDCALLCONV
978 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
983 $send_retv res = send(s, 0, len, flags);
986 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
995 if test "$curl_cv_func_send_args" = "unknown"; then
996 AC_MSG_ERROR([Cannot find proper types to use for send args])
998 send_prev_IFS=$IFS; IFS=','
999 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1003 send_qual_type_arg2=$[2]
1005 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1006 [Define to the type of arg 1 for send.])
1007 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1008 [Define to the type of arg 3 for send.])
1009 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1010 [Define to the type of arg 4 for send.])
1011 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1012 [Define to the function return type for send.])
1016 case $prev_sh_opts in
1024 case "$send_qual_type_arg2" in
1026 send_qual_arg2=const
1027 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1031 send_type_arg2=$send_qual_type_arg2
1035 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1036 [Define to the type qualifier of arg 2 for send.])
1037 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1038 [Define to the type of arg 2 for send.])
1040 case $prev_sh_opts in
1048 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1049 [Define to 1 if you have the send function.])
1050 ac_cv_func_send="yes"
1053 AC_MSG_ERROR([Unable to link function send])
1058 dnl CURL_CHECK_FUNC_RECVFROM
1059 dnl -------------------------------------------------
1060 dnl Test if the socket recvfrom() function is available,
1061 dnl and check its return type and the types of its
1062 dnl arguments. If the function succeeds HAVE_RECVFROM
1063 dnl will be defined, defining the types of the arguments
1064 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1065 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1066 dnl function return value in RECVFROM_TYPE_RETV.
1067 dnl Notice that the types returned for pointer arguments
1068 dnl will actually be the type pointed by the pointer.
1070 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1071 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1072 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1073 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1075 AC_MSG_CHECKING([for recvfrom])
1079 #ifdef HAVE_WINDOWS_H
1080 #ifndef WIN32_LEAN_AND_MEAN
1081 #define WIN32_LEAN_AND_MEAN
1083 #include <windows.h>
1084 #ifdef HAVE_WINSOCK2_H
1085 #include <winsock2.h>
1087 #ifdef HAVE_WINSOCK_H
1088 #include <winsock.h>
1092 #ifdef HAVE_SYS_TYPES_H
1093 #include <sys/types.h>
1095 #ifdef HAVE_SYS_SOCKET_H
1096 #include <sys/socket.h>
1100 recvfrom(0, 0, 0, 0, 0, 0);
1103 AC_MSG_RESULT([yes])
1104 curl_cv_recvfrom="yes"
1107 curl_cv_recvfrom="no"
1110 if test "$curl_cv_recvfrom" = "yes"; then
1111 AC_CACHE_CHECK([types of args and return type for recvfrom],
1112 [curl_cv_func_recvfrom_args], [
1113 curl_cv_func_recvfrom_args="unknown"
1114 for recvfrom_retv in 'int' 'ssize_t'; do
1115 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1116 for recvfrom_arg2 in 'char *' 'void *'; do
1117 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1118 for recvfrom_arg4 in 'int' 'unsigned int'; do
1119 for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
1120 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1121 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1125 #ifdef HAVE_WINDOWS_H
1126 #ifndef WIN32_LEAN_AND_MEAN
1127 #define WIN32_LEAN_AND_MEAN
1129 #include <windows.h>
1130 #ifdef HAVE_WINSOCK2_H
1131 #include <winsock2.h>
1133 #ifdef HAVE_WINSOCK_H
1134 #include <winsock.h>
1137 #define RECVFROMCALLCONV PASCAL
1139 #ifdef HAVE_SYS_TYPES_H
1140 #include <sys/types.h>
1142 #ifdef HAVE_SYS_SOCKET_H
1143 #include <sys/socket.h>
1145 #define RECVFROMCALLCONV
1147 extern $recvfrom_retv RECVFROMCALLCONV
1148 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1149 $recvfrom_arg3, $recvfrom_arg4,
1150 $recvfrom_arg5, $recvfrom_arg6);
1153 $recvfrom_arg2 buf=0;
1154 $recvfrom_arg3 len=0;
1155 $recvfrom_arg4 flags=0;
1156 $recvfrom_arg5 addr=0;
1157 $recvfrom_arg6 addrlen=0;
1158 $recvfrom_retv res=0;
1159 res = recvfrom(s, buf, len, flags, addr, addrlen);
1162 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1173 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1174 AC_MSG_ERROR([Cannot find proper types to use for recvfrom args])
1176 recvfrom_prev_IFS=$IFS; IFS=','
1177 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1178 IFS=$recvfrom_prev_IFS
1181 recvfrom_ptrt_arg2=$[2]
1182 recvfrom_ptrt_arg5=$[5]
1183 recvfrom_ptrt_arg6=$[6]
1185 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1186 [Define to the type of arg 1 for recvfrom.])
1187 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1188 [Define to the type of arg 3 for recvfrom.])
1189 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1190 [Define to the type of arg 4 for recvfrom.])
1191 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1192 [Define to the function return type for recvfrom.])
1196 case $prev_sh_opts in
1204 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1205 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1206 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1208 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1209 [Define to the type pointed by arg 2 for recvfrom.])
1210 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1211 [Define to the type pointed by arg 5 for recvfrom.])
1212 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1213 [Define to the type pointed by arg 6 for recvfrom.])
1215 if test "$recvfrom_type_arg2" = "void"; then
1216 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1217 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1219 if test "$recvfrom_type_arg5" = "void"; then
1220 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1221 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1223 if test "$recvfrom_type_arg6" = "void"; then
1224 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1225 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1228 case $prev_sh_opts in
1236 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1237 [Define to 1 if you have the recvfrom function.])
1238 ac_cv_func_recvfrom="yes"
1241 AC_MSG_ERROR([Unable to link function recvfrom])
1246 dnl CURL_CHECK_MSG_NOSIGNAL
1247 dnl -------------------------------------------------
1248 dnl Check for MSG_NOSIGNAL
1250 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1251 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1252 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1256 #ifdef HAVE_WINDOWS_H
1257 #ifndef WIN32_LEAN_AND_MEAN
1258 #define WIN32_LEAN_AND_MEAN
1260 #include <windows.h>
1261 #ifdef HAVE_WINSOCK2_H
1262 #include <winsock2.h>
1264 #ifdef HAVE_WINSOCK_H
1265 #include <winsock.h>
1269 #ifdef HAVE_SYS_TYPES_H
1270 #include <sys/types.h>
1272 #ifdef HAVE_SYS_SOCKET_H
1273 #include <sys/socket.h>
1277 int flag=MSG_NOSIGNAL;
1280 ac_cv_msg_nosignal="yes"
1282 ac_cv_msg_nosignal="no"
1285 case "$ac_cv_msg_nosignal" in
1287 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1288 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1294 dnl CURL_CHECK_STRUCT_TIMEVAL
1295 dnl -------------------------------------------------
1296 dnl Check for timeval struct
1298 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1299 AC_REQUIRE([AC_HEADER_TIME])dnl
1300 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1301 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1302 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1303 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1307 #ifdef HAVE_WINDOWS_H
1308 #ifndef WIN32_LEAN_AND_MEAN
1309 #define WIN32_LEAN_AND_MEAN
1311 #include <windows.h>
1312 #ifdef HAVE_WINSOCK2_H
1313 #include <winsock2.h>
1315 #ifdef HAVE_WINSOCK_H
1316 #include <winsock.h>
1320 #ifdef HAVE_SYS_TYPES_H
1321 #include <sys/types.h>
1323 #ifdef HAVE_SYS_TIME_H
1324 #include <sys/time.h>
1325 #ifdef TIME_WITH_SYS_TIME
1339 ac_cv_struct_timeval="yes"
1341 ac_cv_struct_timeval="no"
1344 case "$ac_cv_struct_timeval" in
1346 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1347 [Define to 1 if you have the timeval struct.])
1353 dnl TYPE_SIG_ATOMIC_T
1354 dnl -------------------------------------------------
1355 dnl Check if the sig_atomic_t type is available, and
1356 dnl verify if it is already defined as volatile.
1358 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1359 AC_CHECK_HEADERS(signal.h)
1360 AC_CHECK_TYPE([sig_atomic_t],[
1361 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1362 [Define to 1 if sig_atomic_t is an available typedef.])
1364 #ifdef HAVE_SIGNAL_H
1368 case "$ac_cv_type_sig_atomic_t" in
1371 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1374 #ifdef HAVE_SIGNAL_H
1378 static volatile sig_atomic_t dummy = 0;
1382 ac_cv_sig_atomic_t_volatile="no"
1384 AC_MSG_RESULT([yes])
1385 ac_cv_sig_atomic_t_volatile="yes"
1388 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1389 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1390 [Define to 1 if sig_atomic_t is already defined as volatile.])
1397 dnl CURL_CHECK_NONBLOCKING_SOCKET
1398 dnl -------------------------------------------------
1399 dnl Check for how to set a socket to non-blocking state. There seems to exist
1400 dnl four known different ways, with the one used almost everywhere being POSIX
1401 dnl and XPG3, while the other different ways for different systems (old BSD,
1402 dnl Windows and Amiga).
1404 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1405 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1406 dnl to get caught in this script by using an excessive number of #ifdefs...
1408 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
1409 AC_MSG_CHECKING([non-blocking sockets style])
1414 /* headers for O_NONBLOCK test */
1415 #include <sys/types.h>
1419 #if defined(sun) || defined(__sun__) || \
1420 defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1421 # if defined(__SVR4) || defined(__srv4__)
1422 # define PLATFORM_SOLARIS
1424 # define PLATFORM_SUNOS4
1427 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
1428 # define PLATFORM_AIX_V3
1431 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1432 #error "O_NONBLOCK does not work on this platform"
1435 /* O_NONBLOCK source test */
1437 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1440 dnl the O_NONBLOCK test was fine
1441 nonblock="O_NONBLOCK"
1442 AC_DEFINE(HAVE_O_NONBLOCK, 1,
1443 [use O_NONBLOCK for non-blocking sockets])
1446 if test "$nonblock" = "unknown"; then
1449 /* headers for FIONBIO test */
1451 #include <stropts.h>
1453 /* FIONBIO source test (old-style unix) */
1455 int flags = ioctl(socket, FIONBIO, &flags);
1458 dnl FIONBIO test was good
1460 AC_DEFINE(HAVE_FIONBIO, 1,
1461 [use FIONBIO for non-blocking sockets])
1465 if test "$nonblock" = "unknown"; then
1468 /* headers for ioctlsocket test (Windows) */
1470 #ifdef HAVE_WINDOWS_H
1471 #ifndef WIN32_LEAN_AND_MEAN
1472 #define WIN32_LEAN_AND_MEAN
1474 #include <windows.h>
1475 #ifdef HAVE_WINSOCK2_H
1476 #include <winsock2.h>
1478 #ifdef HAVE_WINSOCK_H
1479 #include <winsock.h>
1484 /* ioctlsocket source code (Windows) */
1486 unsigned long flags = 0;
1487 sd = socket(0, 0, 0);
1488 ioctlsocket(sd, FIONBIO, &flags);
1491 dnl ioctlsocket test was good
1492 nonblock="ioctlsocket"
1493 AC_DEFINE(HAVE_IOCTLSOCKET, 1,
1494 [use ioctlsocket() for non-blocking sockets])
1498 if test "$nonblock" = "unknown"; then
1501 /* headers for IoctlSocket test (Amiga?) */
1502 #include <sys/ioctl.h>
1504 /* IoctlSocket source code (Amiga?) */
1506 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1509 dnl Ioctlsocket test was good
1510 nonblock="IoctlSocket"
1511 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
1512 [use Ioctlsocket() for non-blocking sockets])
1516 if test "$nonblock" = "unknown"; then
1519 /* headers for SO_NONBLOCK test (BeOS) */
1522 /* SO_NONBLOCK source code (BeOS) */
1525 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1528 dnl the SO_NONBLOCK test was good
1529 nonblock="SO_NONBLOCK"
1530 AC_DEFINE(HAVE_SO_NONBLOCK, 1,
1531 [use SO_NONBLOCK for non-blocking sockets])
1535 AC_MSG_RESULT($nonblock)
1537 if test "$nonblock" = "unknown"; then
1538 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
1539 [disabled non-blocking sockets])
1540 AC_MSG_WARN([non-block sockets disabled])
1546 dnl -------------------------------------------------
1547 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1548 dnl and a few other things.
1550 AC_DEFUN([TYPE_IN_ADDR_T], [
1551 AC_CHECK_TYPE([in_addr_t], ,[
1552 dnl in_addr_t not available
1553 AC_CACHE_CHECK([for in_addr_t equivalent],
1554 [curl_cv_in_addr_t_equiv], [
1555 curl_cv_in_addr_t_equiv="unknown"
1556 for t in "unsigned long" int size_t unsigned long; do
1557 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1561 #ifdef HAVE_WINDOWS_H
1562 #ifndef WIN32_LEAN_AND_MEAN
1563 #define WIN32_LEAN_AND_MEAN
1565 #include <windows.h>
1566 #ifdef HAVE_WINSOCK2_H
1567 #include <winsock2.h>
1569 #ifdef HAVE_WINSOCK_H
1570 #include <winsock.h>
1574 #ifdef HAVE_SYS_TYPES_H
1575 #include <sys/types.h>
1577 #ifdef HAVE_SYS_SOCKET_H
1578 #include <sys/socket.h>
1580 #ifdef HAVE_NETINET_IN_H
1581 #include <netinet/in.h>
1583 #ifdef HAVE_ARPA_INET_H
1584 #include <arpa/inet.h>
1588 $t data = inet_addr ("1.2.3.4");
1591 curl_cv_in_addr_t_equiv="$t"
1596 case "$curl_cv_in_addr_t_equiv" in
1598 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1601 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1602 [Type to use in place of in_addr_t when system does not provide it.])
1607 #ifdef HAVE_WINDOWS_H
1608 #ifndef WIN32_LEAN_AND_MEAN
1609 #define WIN32_LEAN_AND_MEAN
1611 #include <windows.h>
1612 #ifdef HAVE_WINSOCK2_H
1613 #include <winsock2.h>
1615 #ifdef HAVE_WINSOCK_H
1616 #include <winsock.h>
1620 #ifdef HAVE_SYS_TYPES_H
1621 #include <sys/types.h>
1623 #ifdef HAVE_SYS_SOCKET_H
1624 #include <sys/socket.h>
1626 #ifdef HAVE_NETINET_IN_H
1627 #include <netinet/in.h>
1629 #ifdef HAVE_ARPA_INET_H
1630 #include <arpa/inet.h>
1633 ]) dnl AC_CHECK_TYPE
1637 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1638 dnl -------------------------------------------------
1639 dnl Check if monotonic clock_gettime is available.
1641 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1642 AC_REQUIRE([AC_HEADER_TIME])dnl
1643 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1644 AC_MSG_CHECKING([for monotonic clock_gettime])
1647 #ifdef HAVE_SYS_TYPES_H
1648 #include <sys/types.h>
1650 #ifdef HAVE_SYS_TIME_H
1651 #include <sys/time.h>
1652 #ifdef TIME_WITH_SYS_TIME
1662 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1665 AC_MSG_RESULT([yes])
1666 ac_cv_func_clock_gettime="yes"
1669 ac_cv_func_clock_gettime="no"
1671 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1672 dnl until library linking and run-time checks for clock_gettime succeed.
1676 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1677 dnl -------------------------------------------------
1678 dnl If monotonic clock_gettime is available then,
1679 dnl check and prepended to LIBS any needed libraries.
1681 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1682 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1684 if test "$ac_cv_func_clock_gettime" = "yes"; then
1686 AC_MSG_CHECKING([for clock_gettime in libraries])
1688 curl_cv_save_LIBS="$LIBS"
1689 curl_cv_gclk_LIBS="unknown"
1691 for x_xlibs in '' '-lrt' '-lposix4' ; do
1692 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1693 if test -z "$x_xlibs"; then
1694 LIBS="$curl_cv_save_LIBS"
1696 LIBS="$x_xlibs $curl_cv_save_LIBS"
1700 #ifdef HAVE_SYS_TYPES_H
1701 #include <sys/types.h>
1703 #ifdef HAVE_SYS_TIME_H
1704 #include <sys/time.h>
1705 #ifdef TIME_WITH_SYS_TIME
1715 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1718 curl_cv_gclk_LIBS="$x_xlibs"
1723 LIBS="$curl_cv_save_LIBS"
1725 case X-"$curl_cv_gclk_LIBS" in
1727 AC_MSG_RESULT([cannot find clock_gettime])
1728 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1729 ac_cv_func_clock_gettime="no"
1732 AC_MSG_RESULT([no additional lib required])
1733 ac_cv_func_clock_gettime="yes"
1736 if test -z "$curl_cv_save_LIBS"; then
1737 LIBS="$curl_cv_gclk_LIBS"
1739 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1741 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1742 ac_cv_func_clock_gettime="yes"
1746 dnl only do runtime verification when not cross-compiling
1747 if test "x$cross_compiling" != "xyes" &&
1748 test "$ac_cv_func_clock_gettime" = "yes"; then
1749 AC_MSG_CHECKING([if monotonic clock_gettime works])
1752 #ifdef HAVE_SYS_TYPES_H
1753 #include <sys/types.h>
1755 #ifdef HAVE_SYS_TIME_H
1756 #include <sys/time.h>
1757 #ifdef TIME_WITH_SYS_TIME
1767 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1773 AC_MSG_RESULT([yes])
1776 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1777 ac_cv_func_clock_gettime="no"
1778 LIBS="$curl_cv_save_LIBS"
1782 case "$ac_cv_func_clock_gettime" in
1784 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1785 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1794 dnl **********************************************************************
1795 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
1797 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
1798 dnl sets the $ICC variable to "yes" or "no"
1799 dnl **********************************************************************
1800 AC_DEFUN([CURL_DETECT_ICC],
1803 AC_MSG_CHECKING([for icc in use])
1804 if test "$GCC" = "yes"; then
1805 dnl check if this is icc acting as gcc in disguise
1806 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
1807 dnl action if the text is found, this it has not been replaced by the
1810 dnl the text was not found, it was replaced by the cpp
1812 AC_MSG_RESULT([yes])
1816 if test "$ICC" = "no"; then
1822 dnl We create a function for detecting which compiler we use and then set as
1823 dnl pendantic compiler options as possible for that particular compiler. The
1824 dnl options are only used for debug-builds.
1826 dnl This is a copy of the original found in curl's configure script. Don't
1827 dnl modify this one, edit the one in curl and copy it back here when that one
1830 AC_DEFUN([CURL_CC_DEBUG_OPTS],
1832 if test "z$ICC" = "z"; then
1836 if test "$GCC" = "yes"; then
1838 dnl figure out gcc version!
1839 AC_MSG_CHECKING([gcc version])
1840 gccver=`$CC -dumpversion`
1841 num1=`echo $gccver | cut -d . -f1`
1842 num2=`echo $gccver | cut -d . -f2`
1843 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
1844 AC_MSG_RESULT($gccver)
1846 if test "$ICC" = "yes"; then
1847 dnl this is icc, not gcc.
1849 dnl ICC warnings we ignore:
1850 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
1851 dnl "invalid format string conversion"
1852 dnl * 279 warns on static conditions in while expressions
1853 dnl * 981 warns on "operands are evaluated in unspecified order"
1854 dnl * 1418 "external definition with no prior declaration"
1855 dnl * 1419 warns on "external declaration in primary source file"
1856 dnl which we know and do on purpose.
1858 WARN="-wd279,269,981,1418,1419"
1860 if test "$gccnum" -gt "600"; then
1861 dnl icc 6.0 and older doesn't have the -Wall flag
1865 dnl this is a set of options we believe *ALL* gcc versions support:
1866 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
1868 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
1870 if test "$gccnum" -ge "207"; then
1871 dnl gcc 2.7 or later
1872 WARN="$WARN -Wmissing-declarations"
1875 if test "$gccnum" -gt "295"; then
1876 dnl only if the compiler is newer than 2.95 since we got lots of
1877 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
1878 dnl gcc 2.95.4 on FreeBSD 4.9!
1879 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
1882 if test "$gccnum" -ge "296"; then
1883 dnl gcc 2.96 or later
1884 WARN="$WARN -Wfloat-equal"
1887 if test "$gccnum" -gt "296"; then
1888 dnl this option does not exist in 2.96
1889 WARN="$WARN -Wno-format-nonliteral"
1892 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1893 dnl on i686-Linux as it gives us heaps with false positives.
1894 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
1895 dnl over making it unusable for generic purposes. Let's not use it.
1897 if test "$gccnum" -ge "303"; then
1898 dnl gcc 3.3 and later
1899 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
1902 if test "$gccnum" -ge "304"; then
1903 # try these on gcc 3.4
1904 WARN="$WARN -Wdeclaration-after-statement"
1907 for flag in $CPPFLAGS; do
1910 dnl Include path, provide a -isystem option for the same dir
1911 dnl to prevent warnings in those dirs. The -isystem was not very
1912 dnl reliable on earlier gcc versions.
1913 add=`echo $flag | sed 's/^-I/-isystem /g'`
1921 CFLAGS="$CFLAGS $WARN"
1923 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
1927 AC_MSG_NOTICE([Added no extra compiler options])
1931 dnl strip off optimizer flags
1933 for flag in $CFLAGS; do
1936 dnl echo "cut off $flag"
1939 NEWFLAGS="$NEWFLAGS $flag"
1945 ]) dnl end of AC_DEFUN()
1948 dnl This macro determines if the specified struct exists in the specified file
1950 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1952 AC_DEFUN([CARES_CHECK_STRUCT], [
1953 AC_MSG_CHECKING([for struct $2])
1954 AC_TRY_COMPILE([$1],
1956 struct $2 struct_instance;
1957 ], ac_struct="yes", ac_found="no")
1958 if test "$ac_struct" = "yes" ; then
1967 dnl This macro determines if the specified constant exists in the specified file
1969 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
1971 AC_DEFUN([CARES_CHECK_CONSTANT], [
1972 AC_MSG_CHECKING([for $2])
1973 AC_EGREP_CPP(VARIABLEWASDEFINED,
1982 ], ac_constant="yes", ac_constant="no"
1984 if test "$ac_constant" = "yes" ; then
1994 dnl CARES_CHECK_GETSERVBYPORT_R
1995 dnl -------------------------------------------------
1996 dnl Test if the getservbyport_r function is available,
1997 dnl and find out how many parameters it takes.
1999 AC_DEFUN([CARES_CHECK_GETSERVBYPORT_R], [
2000 AC_CHECK_HEADERS(sys/types.h netdb.h)
2002 AC_MSG_CHECKING([for getservbyport_r])
2004 AC_LANG_FUNC_LINK_TRY([getservbyport_r])
2006 AC_MSG_RESULT([yes])
2007 cares_cv_getservbyport_r="yes"
2010 cares_cv_getservbyport_r="no"
2013 if test "$cares_cv_getservbyport_r" != "yes"; then
2014 AC_MSG_CHECKING([deeper for getservbyport_r])
2021 AC_MSG_RESULT([yes])
2022 cares_cv_getservbyport_r="yes"
2024 AC_MSG_RESULT([but still no])
2025 cares_cv_getservbyport_r="no"
2029 if test "$cares_cv_getservbyport_r" = "yes"; then
2030 AC_MSG_CHECKING([how many arguments getservbyport_r takes])
2031 cares_cv_getservbyport_r_nargs="unknown"
2035 #ifdef HAVE_SYS_TYPES_H
2036 #include <sys/types.h>
2042 getservbyport_r(int, const char*, struct servent*,
2043 char*, size_t, struct servent**);
2048 struct servent *p3, *p6;
2049 res = getservbyport_r(p1, p2, p3, p4, p5, &p6);
2052 cares_cv_getservbyport_r_nargs="6"
2055 if test "$cares_cv_getservbyport_r_nargs" = "unknown"; then
2058 #ifdef HAVE_SYS_TYPES_H
2059 #include <sys/types.h>
2064 extern struct servent*
2065 getservbyport_r(int, const char*, struct servent*,
2070 struct servent *p3, res;
2071 res = getservbyport_r(p1, p2, p3, p4, p5);
2074 cares_cv_getservbyport_r_nargs="5"
2078 if test "$cares_cv_getservbyport_r_nargs" = "unknown"; then
2081 #ifdef HAVE_SYS_TYPES_H
2082 #include <sys/types.h>
2088 getservbyport_r(int, const char*, struct servent*,
2089 struct servent_data*);
2094 struct servent_data *p4;
2095 res = getservbyport_r(p1, p2, p3, p4);
2098 cares_cv_getservbyport_r_nargs="4"
2102 AC_MSG_RESULT([$cares_cv_getservbyport_r_nargs])
2104 if test "$cares_cv_getservbyport_r_nargs" = "unknown"; then
2105 AC_MSG_WARN([HAVE_GETSERVBYPORT_R will not be defined])
2107 AC_DEFINE(HAVE_GETSERVBYPORT_R, 1,
2108 [Specifies whether getservbyport_r is present])
2109 AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $cares_cv_getservbyport_r_nargs,
2110 [Specifies the number of arguments to getservbyport_r])
2111 if test "$cares_cv_getservbyport_r_nargs" = "4" ; then
2112 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
2113 [Specifies the size of the buffer to pass to getservbyport_r])
2115 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
2116 [Specifies the size of the buffer to pass to getservbyport_r])
2123 dnl Tests done using 'aclocal -I m4' in buildconf and 'ACLOCAL_AMFLAGS = -I m4'
2124 dnl in top Makefile.am triggered a problem that prevented aclocal from running
2125 dnl successfully on SunOS 5.10 with GNU m4 1.4.5 and GNU Autoconf 2.61
2126 dnl We actually don't need all the bells and whistles that the above mechanism
2127 dnl provides. We only need to include our m4/reentrant.m4 file here.
2129 m4_include([m4/reentrant.m4])