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. If the expansion would
56 dnl result in a set of double-quoted strings the returned expansion will
57 dnl actually be a single double-quoted string concatenating all them.
59 AC_DEFUN([CURL_CHECK_DEF], [
60 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
61 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
62 if test -z "$SED"; then
63 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
65 if test -z "$GREP"; then
66 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
68 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
78 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
79 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
80 "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
81 "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
82 if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
86 if test -z "$tmp_exp"; then
87 AS_VAR_SET(ac_HaveDef, no)
88 ifelse($3,,[AC_MSG_RESULT([no])])
90 AS_VAR_SET(ac_HaveDef, yes)
91 AS_VAR_SET(ac_Def, $tmp_exp)
92 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
94 AS_VAR_POPDEF([ac_Def])dnl
95 AS_VAR_POPDEF([ac_HaveDef])dnl
99 dnl CARES_CHECK_AIX_ALL_SOURCE
100 dnl -------------------------------------------------
101 dnl Provides a replacement of traditional AC_AIX with
102 dnl an uniform behaviour across all autoconf versions,
103 dnl and with our own placement rules.
105 AC_DEFUN([CARES_CHECK_AIX_ALL_SOURCE], [
106 AH_VERBATIM([_ALL_SOURCE],
107 [/* Define to 1 if OS is AIX. */
111 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
112 AC_BEFORE([$0], [CARES_CONFIGURE_REENTRANT])dnl
113 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
114 AC_EGREP_CPP([yes_this_is_aix],[
120 AC_DEFINE(_ALL_SOURCE)
127 dnl CURL_CHECK_HEADER_WINDOWS
128 dnl -------------------------------------------------
129 dnl Check for compilable and valid windows.h header
131 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
132 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
136 #ifndef WIN32_LEAN_AND_MEAN
137 #define WIN32_LEAN_AND_MEAN
141 #if defined(__CYGWIN__) || defined(__CEGCC__)
142 HAVE_WINDOWS_H shall not be defined.
148 ac_cv_header_windows_h="yes"
150 ac_cv_header_windows_h="no"
153 case "$ac_cv_header_windows_h" in
155 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
156 [Define to 1 if you have the windows.h header file.])
157 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
158 [Define to avoid automatic inclusion of winsock.h])
164 dnl CURL_CHECK_NATIVE_WINDOWS
165 dnl -------------------------------------------------
166 dnl Check if building a native Windows target
168 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
169 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
170 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
171 if test "$ac_cv_header_windows_h" = "no"; then
172 ac_cv_native_windows="no"
177 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
178 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
181 Not a native Windows build target.
185 ac_cv_native_windows="yes"
187 ac_cv_native_windows="no"
191 case "$ac_cv_native_windows" in
193 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
194 [Define to 1 if you are building a native Windows target.])
200 dnl CURL_CHECK_HEADER_WINSOCK
201 dnl -------------------------------------------------
202 dnl Check for compilable and valid winsock.h header
204 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
205 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
206 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
210 #ifndef WIN32_LEAN_AND_MEAN
211 #define WIN32_LEAN_AND_MEAN
216 #if defined(__CYGWIN__) || defined(__CEGCC__)
217 HAVE_WINSOCK_H shall not be defined.
219 int dummy=WSACleanup();
223 ac_cv_header_winsock_h="yes"
225 ac_cv_header_winsock_h="no"
228 case "$ac_cv_header_winsock_h" in
230 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
231 [Define to 1 if you have the winsock.h header file.])
237 dnl CURL_CHECK_HEADER_WINSOCK2
238 dnl -------------------------------------------------
239 dnl Check for compilable and valid winsock2.h header
241 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
242 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
243 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
247 #ifndef WIN32_LEAN_AND_MEAN
248 #define WIN32_LEAN_AND_MEAN
251 #include <winsock2.h>
253 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
254 HAVE_WINSOCK2_H shall not be defined.
256 int dummy=2*IPPROTO_ESP;
260 ac_cv_header_winsock2_h="yes"
262 ac_cv_header_winsock2_h="no"
265 case "$ac_cv_header_winsock2_h" in
267 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
268 [Define to 1 if you have the winsock2.h header file.])
274 dnl CURL_CHECK_HEADER_WS2TCPIP
275 dnl -------------------------------------------------
276 dnl Check for compilable and valid ws2tcpip.h header
278 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
279 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
280 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
284 #ifndef WIN32_LEAN_AND_MEAN
285 #define WIN32_LEAN_AND_MEAN
288 #include <winsock2.h>
289 #include <ws2tcpip.h>
291 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
292 HAVE_WS2TCPIP_H shall not be defined.
294 int dummy=2*IP_PKTINFO;
298 ac_cv_header_ws2tcpip_h="yes"
300 ac_cv_header_ws2tcpip_h="no"
303 case "$ac_cv_header_ws2tcpip_h" in
305 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
306 [Define to 1 if you have the ws2tcpip.h header file.])
312 dnl CURL_CHECK_HEADER_MALLOC
313 dnl -------------------------------------------------
314 dnl Check for compilable and valid malloc.h header,
315 dnl and check if it is needed even with stdlib.h
317 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
318 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
323 void *p = malloc(10);
324 void *q = calloc(10,10);
329 ac_cv_header_malloc_h="yes"
331 ac_cv_header_malloc_h="no"
334 if test "$ac_cv_header_malloc_h" = "yes"; then
335 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
336 [Define to 1 if you have the malloc.h header file.])
342 void *p = malloc(10);
343 void *q = calloc(10,10);
348 curl_cv_need_header_malloc_h="no"
350 curl_cv_need_header_malloc_h="yes"
353 case "$curl_cv_need_header_malloc_h" in
355 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
356 [Define to 1 if you need the malloc.h header file even with stdlib.h])
363 dnl CURL_CHECK_TYPE_SOCKLEN_T
364 dnl -------------------------------------------------
365 dnl Check for existing socklen_t type, and provide
366 dnl an equivalent type if socklen_t not available
368 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
369 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
370 AC_CHECK_TYPE([socklen_t], ,[
371 dnl socklen_t not available
372 AC_CACHE_CHECK([for socklen_t equivalent],
373 [curl_cv_socklen_t_equiv], [
374 curl_cv_socklen_t_equiv="unknown"
375 for arg1 in 'int' 'SOCKET'; do
376 for arg2 in "struct sockaddr" void; do
377 for t in int size_t unsigned long "unsigned long"; do
378 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
382 #ifdef HAVE_WINDOWS_H
383 #ifndef WIN32_LEAN_AND_MEAN
384 #define WIN32_LEAN_AND_MEAN
387 #ifdef HAVE_WINSOCK2_H
388 #include <winsock2.h>
390 #ifdef HAVE_WINSOCK_H
394 #define GETPEERNCALLCONV PASCAL
396 #ifdef HAVE_SYS_TYPES_H
397 #include <sys/types.h>
399 #ifdef HAVE_SYS_SOCKET_H
400 #include <sys/socket.h>
402 #define GETPEERNCALLCONV
404 extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
407 getpeername(0,0,&len);
410 curl_cv_socklen_t_equiv="$t"
417 case "$curl_cv_socklen_t_equiv" in
419 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
422 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
423 [Type to use in place of socklen_t when system does not provide it.])
428 #ifdef HAVE_WINDOWS_H
429 #ifndef WIN32_LEAN_AND_MEAN
430 #define WIN32_LEAN_AND_MEAN
433 #ifdef HAVE_WINSOCK2_H
434 #include <winsock2.h>
435 #ifdef HAVE_WS2TCPIP_H
436 #include <ws2tcpip.h>
440 #ifdef HAVE_SYS_TYPES_H
441 #include <sys/types.h>
443 #ifdef HAVE_SYS_SOCKET_H
444 #include <sys/socket.h>
451 dnl CURL_CHECK_FUNC_GETNAMEINFO
452 dnl -------------------------------------------------
453 dnl Test if the getnameinfo function is available,
454 dnl and check the types of five of its arguments.
455 dnl If the function succeeds HAVE_GETNAMEINFO will be
456 dnl defined, defining the types of the arguments in
457 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
458 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
459 dnl and also defining the type qualifier of first
460 dnl argument in GETNAMEINFO_QUAL_ARG1.
462 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
463 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
464 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
465 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
467 AC_MSG_CHECKING([for getnameinfo])
469 AC_LANG_FUNC_LINK_TRY([getnameinfo])
472 curl_cv_getnameinfo="yes"
475 curl_cv_getnameinfo="no"
478 if test "$curl_cv_getnameinfo" != "yes"; then
479 AC_MSG_CHECKING([deeper for getnameinfo])
487 curl_cv_getnameinfo="yes"
489 AC_MSG_RESULT([but still no])
490 curl_cv_getnameinfo="no"
494 if test "$curl_cv_getnameinfo" != "yes"; then
495 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
499 #ifdef HAVE_WINDOWS_H
500 #ifndef WIN32_LEAN_AND_MEAN
501 #define WIN32_LEAN_AND_MEAN
504 #ifdef HAVE_WINSOCK2_H
505 #include <winsock2.h>
506 #ifdef HAVE_WS2TCPIP_H
507 #include <ws2tcpip.h>
511 #ifdef HAVE_SYS_TYPES_H
512 #include <sys/types.h>
514 #ifdef HAVE_SYS_SOCKET_H
515 #include <sys/socket.h>
522 getnameinfo(0, 0, 0, 0, 0, 0, 0);
526 curl_cv_getnameinfo="yes"
528 AC_MSG_RESULT([but still no])
529 curl_cv_getnameinfo="no"
533 if test "$curl_cv_getnameinfo" = "yes"; then
534 AC_CACHE_CHECK([types of arguments for getnameinfo],
535 [curl_cv_func_getnameinfo_args], [
536 curl_cv_func_getnameinfo_args="unknown"
537 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
538 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
539 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
540 for gni_arg7 in 'int' 'unsigned int'; do
541 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
545 #ifdef HAVE_WINDOWS_H
546 #ifndef WIN32_LEAN_AND_MEAN
547 #define WIN32_LEAN_AND_MEAN
549 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
551 #define _WIN32_WINNT 0x0501
554 #ifdef HAVE_WINSOCK2_H
555 #include <winsock2.h>
556 #ifdef HAVE_WS2TCPIP_H
557 #include <ws2tcpip.h>
560 #define GNICALLCONV WSAAPI
562 #ifdef HAVE_SYS_TYPES_H
563 #include <sys/types.h>
565 #ifdef HAVE_SYS_SOCKET_H
566 #include <sys/socket.h>
573 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
579 $gni_arg46 hostlen=0;
580 $gni_arg46 servlen=0;
582 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
585 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
593 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
594 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
595 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
597 gni_prev_IFS=$IFS; IFS=','
598 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
602 gni_qual_type_arg1=$[1]
604 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
605 [Define to the type of arg 2 for getnameinfo.])
606 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
607 [Define to the type of args 4 and 6 for getnameinfo.])
608 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
609 [Define to the type of arg 7 for getnameinfo.])
613 case $prev_sh_opts in
621 case "$gni_qual_type_arg1" in
624 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
628 gni_type_arg1=$gni_qual_type_arg1
632 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
633 [Define to the type qualifier of arg 1 for getnameinfo.])
634 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
635 [Define to the type of arg 1 for getnameinfo.])
637 case $prev_sh_opts in
645 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
646 [Define to 1 if you have the getnameinfo function.])
647 ac_cv_func_getnameinfo="yes"
653 dnl TYPE_SOCKADDR_STORAGE
654 dnl -------------------------------------------------
655 dnl Check for struct sockaddr_storage. Most IPv6-enabled
656 dnl hosts have it, but AIX 4.3 is one known exception.
658 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
660 AC_CHECK_TYPE([struct sockaddr_storage],
661 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
662 [if struct sockaddr_storage is defined]), ,
665 #ifdef HAVE_WINDOWS_H
666 #ifndef WIN32_LEAN_AND_MEAN
667 #define WIN32_LEAN_AND_MEAN
670 #ifdef HAVE_WINSOCK2_H
671 #include <winsock2.h>
674 #ifdef HAVE_SYS_TYPES_H
675 #include <sys/types.h>
677 #ifdef HAVE_SYS_SOCKET_H
678 #include <sys/socket.h>
680 #ifdef HAVE_NETINET_IN_H
681 #include <netinet/in.h>
683 #ifdef HAVE_ARPA_INET_H
684 #include <arpa/inet.h>
691 dnl CURL_CHECK_NI_WITHSCOPEID
692 dnl -------------------------------------------------
693 dnl Check for working NI_WITHSCOPEID in getnameinfo()
695 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
696 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
697 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
698 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
699 netdb.h netinet/in.h arpa/inet.h)
701 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
702 [ac_cv_working_ni_withscopeid], [
708 #ifdef HAVE_SYS_TYPES_H
709 #include <sys/types.h>
711 #ifdef HAVE_SYS_SOCKET_H
712 #include <sys/socket.h>
717 #ifdef HAVE_NETINET_IN_H
718 #include <netinet/in.h>
720 #ifdef HAVE_ARPA_INET_H
721 #include <arpa/inet.h>
724 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
725 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
726 struct sockaddr_storage sa;
728 unsigned char sa[256];
730 char hostbuf[NI_MAXHOST];
732 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
733 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
734 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
735 int fd = socket(AF_INET6, SOCK_STREAM, 0);
738 return 1; /* Error creating socket */
740 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
742 perror("getsockname()");
743 return 2; /* Error retrieving socket name */
745 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
747 printf("rc = %s\n", gai_strerror(rc));
748 return 3; /* Error translating socket address */
750 return 0; /* Ok, NI_WITHSCOPEID works */
752 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
754 ]]) # AC_LANG_PROGRAM
756 # Exit code == 0. Program worked.
757 ac_cv_working_ni_withscopeid="yes"
759 # Exit code != 0. Program failed.
760 ac_cv_working_ni_withscopeid="no"
762 # Program is not run when cross-compiling. So we assume
763 # NI_WITHSCOPEID will work if we are able to compile it.
766 #include <sys/types.h>
767 #include <sys/socket.h>
770 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
773 ac_cv_working_ni_withscopeid="yes"
775 ac_cv_working_ni_withscopeid="no"
776 ]) # AC_COMPILE_IFELSE
779 case "$ac_cv_working_ni_withscopeid" in
781 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
782 [Define to 1 if NI_WITHSCOPEID exists and works.])
788 dnl CURL_CHECK_FUNC_RECV
789 dnl -------------------------------------------------
790 dnl Test if the socket recv() function is available,
791 dnl and check its return type and the types of its
792 dnl arguments. If the function succeeds HAVE_RECV
793 dnl will be defined, defining the types of the arguments
794 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
795 dnl and RECV_TYPE_ARG4, defining the type of the function
796 dnl return value in RECV_TYPE_RETV.
798 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
799 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
800 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
801 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
803 AC_MSG_CHECKING([for recv])
807 #ifdef HAVE_WINDOWS_H
808 #ifndef WIN32_LEAN_AND_MEAN
809 #define WIN32_LEAN_AND_MEAN
812 #ifdef HAVE_WINSOCK2_H
813 #include <winsock2.h>
815 #ifdef HAVE_WINSOCK_H
820 #ifdef HAVE_SYS_TYPES_H
821 #include <sys/types.h>
823 #ifdef HAVE_SYS_SOCKET_H
824 #include <sys/socket.h>
838 if test "$curl_cv_recv" = "yes"; then
839 AC_CACHE_CHECK([types of args and return type for recv],
840 [curl_cv_func_recv_args], [
841 curl_cv_func_recv_args="unknown"
842 for recv_retv in 'int' 'ssize_t'; do
843 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
844 for recv_arg2 in 'char *' 'void *'; do
845 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
846 for recv_arg4 in 'int' 'unsigned int'; do
847 if test "$curl_cv_func_recv_args" = "unknown"; then
851 #ifdef HAVE_WINDOWS_H
852 #ifndef WIN32_LEAN_AND_MEAN
853 #define WIN32_LEAN_AND_MEAN
856 #ifdef HAVE_WINSOCK2_H
857 #include <winsock2.h>
859 #ifdef HAVE_WINSOCK_H
863 #define RECVCALLCONV PASCAL
865 #ifdef HAVE_SYS_TYPES_H
866 #include <sys/types.h>
868 #ifdef HAVE_SYS_SOCKET_H
869 #include <sys/socket.h>
873 extern $recv_retv RECVCALLCONV
874 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
880 $recv_retv res = recv(s, buf, len, flags);
883 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
892 if test "$curl_cv_func_recv_args" = "unknown"; then
893 AC_MSG_ERROR([Cannot find proper types to use for recv args])
895 recv_prev_IFS=$IFS; IFS=','
896 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
900 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
901 [Define to the type of arg 1 for recv.])
902 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
903 [Define to the type of arg 2 for recv.])
904 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
905 [Define to the type of arg 3 for recv.])
906 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
907 [Define to the type of arg 4 for recv.])
908 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
909 [Define to the function return type for recv.])
911 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
912 [Define to 1 if you have the recv function.])
913 ac_cv_func_recv="yes"
916 AC_MSG_ERROR([Unable to link function recv])
921 dnl CURL_CHECK_FUNC_SEND
922 dnl -------------------------------------------------
923 dnl Test if the socket send() function is available,
924 dnl and check its return type and the types of its
925 dnl arguments. If the function succeeds HAVE_SEND
926 dnl will be defined, defining the types of the arguments
927 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
928 dnl and SEND_TYPE_ARG4, defining the type of the function
929 dnl return value in SEND_TYPE_RETV, and also defining the
930 dnl type qualifier of second argument in SEND_QUAL_ARG2.
932 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
933 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
934 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
935 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
937 AC_MSG_CHECKING([for send])
941 #ifdef HAVE_WINDOWS_H
942 #ifndef WIN32_LEAN_AND_MEAN
943 #define WIN32_LEAN_AND_MEAN
946 #ifdef HAVE_WINSOCK2_H
947 #include <winsock2.h>
949 #ifdef HAVE_WINSOCK_H
954 #ifdef HAVE_SYS_TYPES_H
955 #include <sys/types.h>
957 #ifdef HAVE_SYS_SOCKET_H
958 #include <sys/socket.h>
972 if test "$curl_cv_send" = "yes"; then
973 AC_CACHE_CHECK([types of args and return type for send],
974 [curl_cv_func_send_args], [
975 curl_cv_func_send_args="unknown"
976 for send_retv in 'int' 'ssize_t'; do
977 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
978 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
979 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
980 for send_arg4 in 'int' 'unsigned int'; do
981 if test "$curl_cv_func_send_args" = "unknown"; then
985 #ifdef HAVE_WINDOWS_H
986 #ifndef WIN32_LEAN_AND_MEAN
987 #define WIN32_LEAN_AND_MEAN
990 #ifdef HAVE_WINSOCK2_H
991 #include <winsock2.h>
993 #ifdef HAVE_WINSOCK_H
997 #define SENDCALLCONV PASCAL
999 #ifdef HAVE_SYS_TYPES_H
1000 #include <sys/types.h>
1002 #ifdef HAVE_SYS_SOCKET_H
1003 #include <sys/socket.h>
1005 #define SENDCALLCONV
1007 extern $send_retv SENDCALLCONV
1008 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1013 $send_retv res = send(s, 0, len, flags);
1016 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1025 if test "$curl_cv_func_send_args" = "unknown"; then
1026 AC_MSG_ERROR([Cannot find proper types to use for send args])
1028 send_prev_IFS=$IFS; IFS=','
1029 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1033 send_qual_type_arg2=$[2]
1035 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1036 [Define to the type of arg 1 for send.])
1037 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1038 [Define to the type of arg 3 for send.])
1039 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1040 [Define to the type of arg 4 for send.])
1041 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1042 [Define to the function return type for send.])
1046 case $prev_sh_opts in
1054 case "$send_qual_type_arg2" in
1056 send_qual_arg2=const
1057 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1061 send_type_arg2=$send_qual_type_arg2
1065 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1066 [Define to the type qualifier of arg 2 for send.])
1067 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1068 [Define to the type of arg 2 for send.])
1070 case $prev_sh_opts in
1078 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1079 [Define to 1 if you have the send function.])
1080 ac_cv_func_send="yes"
1083 AC_MSG_ERROR([Unable to link function send])
1088 dnl CURL_CHECK_FUNC_RECVFROM
1089 dnl -------------------------------------------------
1090 dnl Test if the socket recvfrom() function is available,
1091 dnl and check its return type and the types of its
1092 dnl arguments. If the function succeeds HAVE_RECVFROM
1093 dnl will be defined, defining the types of the arguments
1094 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1095 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1096 dnl function return value in RECVFROM_TYPE_RETV.
1097 dnl Notice that the types returned for pointer arguments
1098 dnl will actually be the type pointed by the pointer.
1100 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1101 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1102 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1103 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1105 AC_MSG_CHECKING([for recvfrom])
1109 #ifdef HAVE_WINDOWS_H
1110 #ifndef WIN32_LEAN_AND_MEAN
1111 #define WIN32_LEAN_AND_MEAN
1113 #include <windows.h>
1114 #ifdef HAVE_WINSOCK2_H
1115 #include <winsock2.h>
1117 #ifdef HAVE_WINSOCK_H
1118 #include <winsock.h>
1122 #ifdef HAVE_SYS_TYPES_H
1123 #include <sys/types.h>
1125 #ifdef HAVE_SYS_SOCKET_H
1126 #include <sys/socket.h>
1130 recvfrom(0, 0, 0, 0, 0, 0);
1133 AC_MSG_RESULT([yes])
1134 curl_cv_recvfrom="yes"
1137 curl_cv_recvfrom="no"
1140 if test "$curl_cv_recvfrom" = "yes"; then
1141 AC_CACHE_CHECK([types of args and return type for recvfrom],
1142 [curl_cv_func_recvfrom_args], [
1143 curl_cv_func_recvfrom_args="unknown"
1144 for recvfrom_retv in 'int' 'ssize_t'; do
1145 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1146 for recvfrom_arg2 in 'char *' 'void *'; do
1147 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1148 for recvfrom_arg4 in 'int' 'unsigned int'; do
1149 for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
1150 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1151 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1155 #ifdef HAVE_WINDOWS_H
1156 #ifndef WIN32_LEAN_AND_MEAN
1157 #define WIN32_LEAN_AND_MEAN
1159 #include <windows.h>
1160 #ifdef HAVE_WINSOCK2_H
1161 #include <winsock2.h>
1163 #ifdef HAVE_WINSOCK_H
1164 #include <winsock.h>
1167 #define RECVFROMCALLCONV PASCAL
1169 #ifdef HAVE_SYS_TYPES_H
1170 #include <sys/types.h>
1172 #ifdef HAVE_SYS_SOCKET_H
1173 #include <sys/socket.h>
1175 #define RECVFROMCALLCONV
1177 extern $recvfrom_retv RECVFROMCALLCONV
1178 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1179 $recvfrom_arg3, $recvfrom_arg4,
1180 $recvfrom_arg5, $recvfrom_arg6);
1183 $recvfrom_arg2 buf=0;
1184 $recvfrom_arg3 len=0;
1185 $recvfrom_arg4 flags=0;
1186 $recvfrom_arg5 addr=0;
1187 $recvfrom_arg6 addrlen=0;
1188 $recvfrom_retv res=0;
1189 res = recvfrom(s, buf, len, flags, addr, addrlen);
1192 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1203 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1204 AC_MSG_ERROR([Cannot find proper types to use for recvfrom args])
1206 recvfrom_prev_IFS=$IFS; IFS=','
1207 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1208 IFS=$recvfrom_prev_IFS
1211 recvfrom_ptrt_arg2=$[2]
1212 recvfrom_ptrt_arg5=$[5]
1213 recvfrom_ptrt_arg6=$[6]
1215 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1216 [Define to the type of arg 1 for recvfrom.])
1217 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1218 [Define to the type of arg 3 for recvfrom.])
1219 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1220 [Define to the type of arg 4 for recvfrom.])
1221 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1222 [Define to the function return type for recvfrom.])
1226 case $prev_sh_opts in
1234 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1235 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1236 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1238 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1239 [Define to the type pointed by arg 2 for recvfrom.])
1240 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1241 [Define to the type pointed by arg 5 for recvfrom.])
1242 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1243 [Define to the type pointed by arg 6 for recvfrom.])
1245 if test "$recvfrom_type_arg2" = "void"; then
1246 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1247 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1249 if test "$recvfrom_type_arg5" = "void"; then
1250 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1251 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1253 if test "$recvfrom_type_arg6" = "void"; then
1254 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1255 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1258 case $prev_sh_opts in
1266 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1267 [Define to 1 if you have the recvfrom function.])
1268 ac_cv_func_recvfrom="yes"
1271 AC_MSG_ERROR([Unable to link function recvfrom])
1276 dnl CURL_CHECK_MSG_NOSIGNAL
1277 dnl -------------------------------------------------
1278 dnl Check for MSG_NOSIGNAL
1280 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1281 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1282 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1286 #ifdef HAVE_WINDOWS_H
1287 #ifndef WIN32_LEAN_AND_MEAN
1288 #define WIN32_LEAN_AND_MEAN
1290 #include <windows.h>
1291 #ifdef HAVE_WINSOCK2_H
1292 #include <winsock2.h>
1294 #ifdef HAVE_WINSOCK_H
1295 #include <winsock.h>
1299 #ifdef HAVE_SYS_TYPES_H
1300 #include <sys/types.h>
1302 #ifdef HAVE_SYS_SOCKET_H
1303 #include <sys/socket.h>
1307 int flag=MSG_NOSIGNAL;
1310 ac_cv_msg_nosignal="yes"
1312 ac_cv_msg_nosignal="no"
1315 case "$ac_cv_msg_nosignal" in
1317 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1318 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1324 dnl CURL_CHECK_STRUCT_TIMEVAL
1325 dnl -------------------------------------------------
1326 dnl Check for timeval struct
1328 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1329 AC_REQUIRE([AC_HEADER_TIME])dnl
1330 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1331 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1332 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1333 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1337 #ifdef HAVE_WINDOWS_H
1338 #ifndef WIN32_LEAN_AND_MEAN
1339 #define WIN32_LEAN_AND_MEAN
1341 #include <windows.h>
1342 #ifdef HAVE_WINSOCK2_H
1343 #include <winsock2.h>
1345 #ifdef HAVE_WINSOCK_H
1346 #include <winsock.h>
1350 #ifdef HAVE_SYS_TYPES_H
1351 #include <sys/types.h>
1353 #ifdef HAVE_SYS_TIME_H
1354 #include <sys/time.h>
1355 #ifdef TIME_WITH_SYS_TIME
1369 ac_cv_struct_timeval="yes"
1371 ac_cv_struct_timeval="no"
1374 case "$ac_cv_struct_timeval" in
1376 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1377 [Define to 1 if you have the timeval struct.])
1383 dnl TYPE_SIG_ATOMIC_T
1384 dnl -------------------------------------------------
1385 dnl Check if the sig_atomic_t type is available, and
1386 dnl verify if it is already defined as volatile.
1388 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1389 AC_CHECK_HEADERS(signal.h)
1390 AC_CHECK_TYPE([sig_atomic_t],[
1391 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1392 [Define to 1 if sig_atomic_t is an available typedef.])
1394 #ifdef HAVE_SIGNAL_H
1398 case "$ac_cv_type_sig_atomic_t" in
1401 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1404 #ifdef HAVE_SIGNAL_H
1408 static volatile sig_atomic_t dummy = 0;
1412 ac_cv_sig_atomic_t_volatile="no"
1414 AC_MSG_RESULT([yes])
1415 ac_cv_sig_atomic_t_volatile="yes"
1418 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1419 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1420 [Define to 1 if sig_atomic_t is already defined as volatile.])
1427 dnl CURL_CHECK_NONBLOCKING_SOCKET
1428 dnl -------------------------------------------------
1429 dnl Check for how to set a socket to non-blocking state. There seems to exist
1430 dnl four known different ways, with the one used almost everywhere being POSIX
1431 dnl and XPG3, while the other different ways for different systems (old BSD,
1432 dnl Windows and Amiga).
1434 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1435 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1436 dnl to get caught in this script by using an excessive number of #ifdefs...
1438 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
1439 AC_MSG_CHECKING([non-blocking sockets style])
1444 /* headers for O_NONBLOCK test */
1445 #include <sys/types.h>
1449 #if defined(sun) || defined(__sun__) || \
1450 defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1451 # if defined(__SVR4) || defined(__srv4__)
1452 # define PLATFORM_SOLARIS
1454 # define PLATFORM_SUNOS4
1457 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
1458 # define PLATFORM_AIX_V3
1461 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1462 #error "O_NONBLOCK does not work on this platform"
1465 /* O_NONBLOCK source test */
1467 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1470 dnl the O_NONBLOCK test was fine
1471 nonblock="O_NONBLOCK"
1472 AC_DEFINE(HAVE_O_NONBLOCK, 1,
1473 [use O_NONBLOCK for non-blocking sockets])
1476 if test "$nonblock" = "unknown"; then
1479 /* headers for FIONBIO test */
1481 #include <stropts.h>
1483 /* FIONBIO source test (old-style unix) */
1485 int flags = ioctl(socket, FIONBIO, &flags);
1488 dnl FIONBIO test was good
1490 AC_DEFINE(HAVE_FIONBIO, 1,
1491 [use FIONBIO for non-blocking sockets])
1495 if test "$nonblock" = "unknown"; then
1498 /* headers for ioctlsocket test (Windows) */
1500 #ifdef HAVE_WINDOWS_H
1501 #ifndef WIN32_LEAN_AND_MEAN
1502 #define WIN32_LEAN_AND_MEAN
1504 #include <windows.h>
1505 #ifdef HAVE_WINSOCK2_H
1506 #include <winsock2.h>
1508 #ifdef HAVE_WINSOCK_H
1509 #include <winsock.h>
1514 /* ioctlsocket source code (Windows) */
1516 unsigned long flags = 0;
1517 sd = socket(0, 0, 0);
1518 ioctlsocket(sd, FIONBIO, &flags);
1521 dnl ioctlsocket test was good
1522 nonblock="ioctlsocket"
1523 AC_DEFINE(HAVE_IOCTLSOCKET, 1,
1524 [use ioctlsocket() for non-blocking sockets])
1528 if test "$nonblock" = "unknown"; then
1531 /* headers for IoctlSocket test (Amiga?) */
1532 #include <sys/ioctl.h>
1534 /* IoctlSocket source code (Amiga?) */
1536 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1539 dnl Ioctlsocket test was good
1540 nonblock="IoctlSocket"
1541 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
1542 [use Ioctlsocket() for non-blocking sockets])
1546 if test "$nonblock" = "unknown"; then
1549 /* headers for SO_NONBLOCK test (BeOS) */
1552 /* SO_NONBLOCK source code (BeOS) */
1555 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1558 dnl the SO_NONBLOCK test was good
1559 nonblock="SO_NONBLOCK"
1560 AC_DEFINE(HAVE_SO_NONBLOCK, 1,
1561 [use SO_NONBLOCK for non-blocking sockets])
1565 AC_MSG_RESULT($nonblock)
1567 if test "$nonblock" = "unknown"; then
1568 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
1569 [disabled non-blocking sockets])
1570 AC_MSG_WARN([non-block sockets disabled])
1576 dnl -------------------------------------------------
1577 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1578 dnl and a few other things.
1580 AC_DEFUN([TYPE_IN_ADDR_T], [
1581 AC_CHECK_TYPE([in_addr_t], ,[
1582 dnl in_addr_t not available
1583 AC_CACHE_CHECK([for in_addr_t equivalent],
1584 [curl_cv_in_addr_t_equiv], [
1585 curl_cv_in_addr_t_equiv="unknown"
1586 for t in "unsigned long" int size_t unsigned long; do
1587 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1591 #ifdef HAVE_WINDOWS_H
1592 #ifndef WIN32_LEAN_AND_MEAN
1593 #define WIN32_LEAN_AND_MEAN
1595 #include <windows.h>
1596 #ifdef HAVE_WINSOCK2_H
1597 #include <winsock2.h>
1599 #ifdef HAVE_WINSOCK_H
1600 #include <winsock.h>
1604 #ifdef HAVE_SYS_TYPES_H
1605 #include <sys/types.h>
1607 #ifdef HAVE_SYS_SOCKET_H
1608 #include <sys/socket.h>
1610 #ifdef HAVE_NETINET_IN_H
1611 #include <netinet/in.h>
1613 #ifdef HAVE_ARPA_INET_H
1614 #include <arpa/inet.h>
1618 $t data = inet_addr ("1.2.3.4");
1621 curl_cv_in_addr_t_equiv="$t"
1626 case "$curl_cv_in_addr_t_equiv" in
1628 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1631 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1632 [Type to use in place of in_addr_t when system does not provide it.])
1637 #ifdef HAVE_WINDOWS_H
1638 #ifndef WIN32_LEAN_AND_MEAN
1639 #define WIN32_LEAN_AND_MEAN
1641 #include <windows.h>
1642 #ifdef HAVE_WINSOCK2_H
1643 #include <winsock2.h>
1645 #ifdef HAVE_WINSOCK_H
1646 #include <winsock.h>
1650 #ifdef HAVE_SYS_TYPES_H
1651 #include <sys/types.h>
1653 #ifdef HAVE_SYS_SOCKET_H
1654 #include <sys/socket.h>
1656 #ifdef HAVE_NETINET_IN_H
1657 #include <netinet/in.h>
1659 #ifdef HAVE_ARPA_INET_H
1660 #include <arpa/inet.h>
1663 ]) dnl AC_CHECK_TYPE
1667 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1668 dnl -------------------------------------------------
1669 dnl Check if monotonic clock_gettime is available.
1671 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1672 AC_REQUIRE([AC_HEADER_TIME])dnl
1673 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1674 AC_MSG_CHECKING([for monotonic clock_gettime])
1677 #ifdef HAVE_SYS_TYPES_H
1678 #include <sys/types.h>
1680 #ifdef HAVE_SYS_TIME_H
1681 #include <sys/time.h>
1682 #ifdef TIME_WITH_SYS_TIME
1692 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1695 AC_MSG_RESULT([yes])
1696 ac_cv_func_clock_gettime="yes"
1699 ac_cv_func_clock_gettime="no"
1701 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1702 dnl until library linking and run-time checks for clock_gettime succeed.
1706 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1707 dnl -------------------------------------------------
1708 dnl If monotonic clock_gettime is available then,
1709 dnl check and prepended to LIBS any needed libraries.
1711 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1712 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1714 if test "$ac_cv_func_clock_gettime" = "yes"; then
1716 AC_MSG_CHECKING([for clock_gettime in libraries])
1718 curl_cv_save_LIBS="$LIBS"
1719 curl_cv_gclk_LIBS="unknown"
1721 for x_xlibs in '' '-lrt' '-lposix4' ; do
1722 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1723 if test -z "$x_xlibs"; then
1724 LIBS="$curl_cv_save_LIBS"
1726 LIBS="$x_xlibs $curl_cv_save_LIBS"
1730 #ifdef HAVE_SYS_TYPES_H
1731 #include <sys/types.h>
1733 #ifdef HAVE_SYS_TIME_H
1734 #include <sys/time.h>
1735 #ifdef TIME_WITH_SYS_TIME
1745 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1748 curl_cv_gclk_LIBS="$x_xlibs"
1753 LIBS="$curl_cv_save_LIBS"
1755 case X-"$curl_cv_gclk_LIBS" in
1757 AC_MSG_RESULT([cannot find clock_gettime])
1758 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1759 ac_cv_func_clock_gettime="no"
1762 AC_MSG_RESULT([no additional lib required])
1763 ac_cv_func_clock_gettime="yes"
1766 if test -z "$curl_cv_save_LIBS"; then
1767 LIBS="$curl_cv_gclk_LIBS"
1769 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1771 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1772 ac_cv_func_clock_gettime="yes"
1776 dnl only do runtime verification when not cross-compiling
1777 if test "x$cross_compiling" != "xyes" &&
1778 test "$ac_cv_func_clock_gettime" = "yes"; then
1779 AC_MSG_CHECKING([if monotonic clock_gettime works])
1782 #ifdef HAVE_SYS_TYPES_H
1783 #include <sys/types.h>
1785 #ifdef HAVE_SYS_TIME_H
1786 #include <sys/time.h>
1787 #ifdef TIME_WITH_SYS_TIME
1797 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1803 AC_MSG_RESULT([yes])
1806 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1807 ac_cv_func_clock_gettime="no"
1808 LIBS="$curl_cv_save_LIBS"
1812 case "$ac_cv_func_clock_gettime" in
1814 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1815 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1824 dnl **********************************************************************
1825 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
1827 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
1828 dnl sets the $ICC variable to "yes" or "no"
1829 dnl **********************************************************************
1830 AC_DEFUN([CURL_DETECT_ICC],
1833 AC_MSG_CHECKING([for icc in use])
1834 if test "$GCC" = "yes"; then
1835 dnl check if this is icc acting as gcc in disguise
1836 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
1837 dnl action if the text is found, this it has not been replaced by the
1840 dnl the text was not found, it was replaced by the cpp
1842 AC_MSG_RESULT([yes])
1846 if test "$ICC" = "no"; then
1852 dnl We create a function for detecting which compiler we use and then set as
1853 dnl pendantic compiler options as possible for that particular compiler. The
1854 dnl options are only used for debug-builds.
1856 dnl This is a copy of the original found in curl's configure script. Don't
1857 dnl modify this one, edit the one in curl and copy it back here when that one
1860 AC_DEFUN([CURL_CC_DEBUG_OPTS],
1862 if test "z$ICC" = "z"; then
1866 if test "$GCC" = "yes"; then
1868 dnl figure out gcc version!
1869 AC_MSG_CHECKING([gcc version])
1870 gccver=`$CC -dumpversion`
1871 num1=`echo $gccver | cut -d . -f1`
1872 num2=`echo $gccver | cut -d . -f2`
1873 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
1874 AC_MSG_RESULT($gccver)
1876 if test "$ICC" = "yes"; then
1877 dnl this is icc, not gcc.
1879 dnl ICC warnings we ignore:
1880 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
1881 dnl "invalid format string conversion"
1882 dnl * 279 warns on static conditions in while expressions
1883 dnl * 981 warns on "operands are evaluated in unspecified order"
1884 dnl * 1418 "external definition with no prior declaration"
1885 dnl * 1419 warns on "external declaration in primary source file"
1886 dnl which we know and do on purpose.
1888 WARN="-wd279,269,981,1418,1419"
1890 if test "$gccnum" -gt "600"; then
1891 dnl icc 6.0 and older doesn't have the -Wall flag
1895 dnl this is a set of options we believe *ALL* gcc versions support:
1896 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
1898 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
1900 if test "$gccnum" -ge "207"; then
1901 dnl gcc 2.7 or later
1902 WARN="$WARN -Wmissing-declarations"
1905 if test "$gccnum" -gt "295"; then
1906 dnl only if the compiler is newer than 2.95 since we got lots of
1907 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
1908 dnl gcc 2.95.4 on FreeBSD 4.9!
1909 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
1912 if test "$gccnum" -ge "296"; then
1913 dnl gcc 2.96 or later
1914 WARN="$WARN -Wfloat-equal"
1917 if test "$gccnum" -gt "296"; then
1918 dnl this option does not exist in 2.96
1919 WARN="$WARN -Wno-format-nonliteral"
1922 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1923 dnl on i686-Linux as it gives us heaps with false positives.
1924 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
1925 dnl over making it unusable for generic purposes. Let's not use it.
1927 if test "$gccnum" -ge "303"; then
1928 dnl gcc 3.3 and later
1929 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
1932 if test "$gccnum" -ge "304"; then
1933 # try these on gcc 3.4
1934 WARN="$WARN -Wdeclaration-after-statement"
1937 for flag in $CPPFLAGS; do
1940 dnl Include path, provide a -isystem option for the same dir
1941 dnl to prevent warnings in those dirs. The -isystem was not very
1942 dnl reliable on earlier gcc versions.
1943 add=`echo $flag | sed 's/^-I/-isystem /g'`
1951 CFLAGS="$CFLAGS $WARN"
1953 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
1957 AC_MSG_NOTICE([Added no extra compiler options])
1961 dnl strip off optimizer flags
1963 for flag in $CFLAGS; do
1966 dnl echo "cut off $flag"
1969 NEWFLAGS="$NEWFLAGS $flag"
1975 ]) dnl end of AC_DEFUN()
1978 dnl This macro determines if the specified struct exists in the specified file
1980 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1982 AC_DEFUN([CARES_CHECK_STRUCT], [
1983 AC_MSG_CHECKING([for struct $2])
1984 AC_TRY_COMPILE([$1],
1986 struct $2 struct_instance;
1987 ], ac_struct="yes", ac_found="no")
1988 if test "$ac_struct" = "yes" ; then
1997 dnl This macro determines if the specified constant exists in the specified file
1999 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
2001 AC_DEFUN([CARES_CHECK_CONSTANT], [
2002 AC_MSG_CHECKING([for $2])
2003 AC_EGREP_CPP(VARIABLEWASDEFINED,
2012 ], ac_constant="yes", ac_constant="no"
2014 if test "$ac_constant" = "yes" ; then
2024 dnl CARES_CHECK_GETSERVBYPORT_R
2025 dnl -------------------------------------------------
2026 dnl Test if the getservbyport_r function is available,
2027 dnl and find out how many parameters it takes.
2029 AC_DEFUN([CARES_CHECK_GETSERVBYPORT_R], [
2030 AC_CHECK_HEADERS(sys/types.h netdb.h)
2032 AC_MSG_CHECKING([for getservbyport_r])
2034 AC_LANG_FUNC_LINK_TRY([getservbyport_r])
2036 AC_MSG_RESULT([yes])
2037 cares_cv_getservbyport_r="yes"
2040 cares_cv_getservbyport_r="no"
2043 if test "$cares_cv_getservbyport_r" != "yes"; then
2044 AC_MSG_CHECKING([deeper for getservbyport_r])
2051 AC_MSG_RESULT([yes])
2052 cares_cv_getservbyport_r="yes"
2054 AC_MSG_RESULT([but still no])
2055 cares_cv_getservbyport_r="no"
2059 if test "$cares_cv_getservbyport_r" = "yes"; then
2060 AC_MSG_CHECKING([how many arguments getservbyport_r takes])
2061 cares_cv_getservbyport_r_nargs="unknown"
2065 #ifdef HAVE_SYS_TYPES_H
2066 #include <sys/types.h>
2072 getservbyport_r(int, const char*, struct servent*,
2073 char*, size_t, struct servent**);
2078 struct servent *p3, *p6;
2079 res = getservbyport_r(p1, p2, p3, p4, p5, &p6);
2082 cares_cv_getservbyport_r_nargs="6"
2085 if test "$cares_cv_getservbyport_r_nargs" = "unknown"; then
2088 #ifdef HAVE_SYS_TYPES_H
2089 #include <sys/types.h>
2094 extern struct servent*
2095 getservbyport_r(int, const char*, struct servent*,
2100 struct servent *p3, res;
2101 res = getservbyport_r(p1, p2, p3, p4, p5);
2104 cares_cv_getservbyport_r_nargs="5"
2108 if test "$cares_cv_getservbyport_r_nargs" = "unknown"; then
2111 #ifdef HAVE_SYS_TYPES_H
2112 #include <sys/types.h>
2118 getservbyport_r(int, const char*, struct servent*,
2119 struct servent_data*);
2124 struct servent_data *p4;
2125 res = getservbyport_r(p1, p2, p3, p4);
2128 cares_cv_getservbyport_r_nargs="4"
2132 AC_MSG_RESULT([$cares_cv_getservbyport_r_nargs])
2134 if test "$cares_cv_getservbyport_r_nargs" = "unknown"; then
2135 AC_MSG_WARN([HAVE_GETSERVBYPORT_R will not be defined])
2137 AC_DEFINE(HAVE_GETSERVBYPORT_R, 1,
2138 [Specifies whether getservbyport_r is present])
2139 AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $cares_cv_getservbyport_r_nargs,
2140 [Specifies the number of arguments to getservbyport_r])
2141 if test "$cares_cv_getservbyport_r_nargs" = "4" ; then
2142 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
2143 [Specifies the size of the buffer to pass to getservbyport_r])
2145 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
2146 [Specifies the size of the buffer to pass to getservbyport_r])