1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at http://curl.haxx.se/docs/copyright.html.
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
22 ###########################################################################
25 dnl CURL_CHECK_HEADER_WINDOWS
26 dnl -------------------------------------------------
27 dnl Check for compilable and valid windows.h header
29 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
30 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
34 #ifndef WIN32_LEAN_AND_MEAN
35 #define WIN32_LEAN_AND_MEAN
40 HAVE_WINDOWS_H shall not be defined.
46 ac_cv_header_windows_h="yes"
48 ac_cv_header_windows_h="no"
51 case "$ac_cv_header_windows_h" in
53 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
54 [Define to 1 if you have the windows.h header file.])
55 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
56 [Define to avoid automatic inclusion of winsock.h])
62 dnl CURL_CHECK_HEADER_WINSOCK
63 dnl -------------------------------------------------
64 dnl Check for compilable and valid winsock.h header
66 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
67 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
68 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
72 #ifndef WIN32_LEAN_AND_MEAN
73 #define WIN32_LEAN_AND_MEAN
79 HAVE_WINSOCK_H shall not be defined.
81 int dummy=WSACleanup();
85 ac_cv_header_winsock_h="yes"
87 ac_cv_header_winsock_h="no"
90 case "$ac_cv_header_winsock_h" in
92 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
93 [Define to 1 if you have the winsock.h header file.])
99 dnl CURL_CHECK_HEADER_WINSOCK2
100 dnl -------------------------------------------------
101 dnl Check for compilable and valid winsock2.h header
103 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
104 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
105 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
109 #ifndef WIN32_LEAN_AND_MEAN
110 #define WIN32_LEAN_AND_MEAN
113 #include <winsock2.h>
116 HAVE_WINSOCK2_H shall not be defined.
118 int dummy=2*IPPROTO_ESP;
122 ac_cv_header_winsock2_h="yes"
124 ac_cv_header_winsock2_h="no"
127 case "$ac_cv_header_winsock2_h" in
129 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
130 [Define to 1 if you have the winsock2.h header file.])
136 dnl CURL_CHECK_HEADER_WS2TCPIP
137 dnl -------------------------------------------------
138 dnl Check for compilable and valid ws2tcpip.h header
140 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
141 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
142 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
146 #ifndef WIN32_LEAN_AND_MEAN
147 #define WIN32_LEAN_AND_MEAN
150 #include <winsock2.h>
151 #include <ws2tcpip.h>
154 HAVE_WS2TCPIP_H shall not be defined.
156 int dummy=2*IP_PKTINFO;
160 ac_cv_header_ws2tcpip_h="yes"
162 ac_cv_header_ws2tcpip_h="no"
165 case "$ac_cv_header_ws2tcpip_h" in
167 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
168 [Define to 1 if you have the ws2tcpip.h header file.])
174 dnl CURL_CHECK_HEADER_MALLOC
175 dnl -------------------------------------------------
176 dnl Check for compilable and valid malloc.h header,
177 dnl and check if it is needed even with stdlib.h
179 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
180 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
185 void *p = malloc(10);
186 void *q = calloc(10,10);
191 ac_cv_header_malloc_h="yes"
193 ac_cv_header_malloc_h="no"
196 if test "$ac_cv_header_malloc_h" = "yes"; then
197 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
198 [Define to 1 if you have the malloc.h header file.])
204 void *p = malloc(10);
205 void *q = calloc(10,10);
210 curl_cv_need_header_malloc_h="no"
212 curl_cv_need_header_malloc_h="yes"
215 case "$curl_cv_need_header_malloc_h" in
217 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
218 [Define to 1 if you need the malloc.h header file even with stdlib.h])
225 dnl CURL_CHECK_TYPE_SOCKLEN_T
226 dnl -------------------------------------------------
227 dnl Check for existing socklen_t type, and provide
228 dnl an equivalent type if socklen_t not available
230 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
231 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
232 AC_CHECK_TYPE([socklen_t], ,[
233 AC_CACHE_CHECK([for socklen_t equivalent],
234 [curl_cv_socklen_t_equiv], [
235 curl_cv_socklen_t_equiv="unknown"
236 for arg2 in "struct sockaddr" void; do
237 for t in int size_t unsigned long "unsigned long"; do
241 #ifdef HAVE_WINDOWS_H
242 #ifndef WIN32_LEAN_AND_MEAN
243 #define WIN32_LEAN_AND_MEAN
246 #ifdef HAVE_WINSOCK2_H
247 #include <winsock2.h>
249 #ifdef HAVE_WINSOCK_H
254 #ifdef HAVE_SYS_TYPES_H
255 #include <sys/types.h>
257 #ifdef HAVE_SYS_SOCKET_H
258 #include <sys/socket.h>
261 int getpeername (int, $arg2 *, $t *);
264 getpeername(0,0,&len);
267 curl_cv_socklen_t_equiv="$t"
273 case "$curl_cv_socklen_t_equiv" in
275 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
278 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
279 [type to use in place of socklen_t if not defined])
284 #ifdef HAVE_WINDOWS_H
285 #ifndef WIN32_LEAN_AND_MEAN
286 #define WIN32_LEAN_AND_MEAN
289 #ifdef HAVE_WINSOCK2_H
290 #include <winsock2.h>
291 #ifdef HAVE_WS2TCPIP_H
292 #include <ws2tcpip.h>
296 #ifdef HAVE_SYS_TYPES_H
297 #include <sys/types.h>
299 #ifdef HAVE_SYS_SOCKET_H
300 #include <sys/socket.h>
307 dnl CURL_CHECK_FUNC_GETNAMEINFO
308 dnl -------------------------------------------------
309 dnl Test if the getnameinfo function is available,
310 dnl and check the types of five of its arguments.
311 dnl If the function succeeds HAVE_GETNAMEINFO will be
312 dnl defined, defining the types of the arguments in
313 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
314 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
315 dnl and also defining the type qualifier of first
316 dnl argument in GETNAMEINFO_QUAL_ARG1.
318 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
319 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
320 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
321 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
323 AC_MSG_CHECKING([for getnameinfo])
325 AC_LANG_FUNC_LINK_TRY([getnameinfo])
328 curl_cv_getnameinfo="yes"
331 curl_cv_getnameinfo="no"
334 if test "$curl_cv_getnameinfo" != "yes"; then
335 AC_MSG_CHECKING([deeper for getnameinfo])
341 curl_cv_getnameinfo="yes"
343 AC_MSG_RESULT([but still no])
344 curl_cv_getnameinfo="no"
348 if test "$curl_cv_getnameinfo" != "yes"; then
349 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
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>
359 #ifdef HAVE_WS2TCPIP_H
360 #include <ws2tcpip.h>
364 #ifdef HAVE_SYS_TYPES_H
365 #include <sys/types.h>
367 #ifdef HAVE_SYS_SOCKET_H
368 #include <sys/socket.h>
375 getnameinfo(0, 0, 0, 0, 0, 0, 0);
378 curl_cv_getnameinfo="yes"
380 AC_MSG_RESULT([but still no])
381 curl_cv_getnameinfo="no"
385 if test "$curl_cv_getnameinfo" = "yes"; then
386 AC_CACHE_CHECK([types of arguments for getnameinfo],
387 [curl_cv_func_getnameinfo_args], [
388 curl_cv_func_getnameinfo_args="unknown"
389 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
390 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
391 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
392 for gni_arg7 in 'int' 'unsigned int'; do
396 #ifdef HAVE_WINDOWS_H
397 #ifndef WIN32_LEAN_AND_MEAN
398 #define WIN32_LEAN_AND_MEAN
400 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
402 #define _WIN32_WINNT 0x0501
405 #ifdef HAVE_WINSOCK2_H
406 #include <winsock2.h>
407 #ifdef HAVE_WS2TCPIP_H
408 #include <ws2tcpip.h>
411 #define GNICALLCONV WSAAPI
413 #ifdef HAVE_SYS_TYPES_H
414 #include <sys/types.h>
416 #ifdef HAVE_SYS_SOCKET_H
417 #include <sys/socket.h>
424 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
430 $gni_arg46 hostlen=0;
431 $gni_arg46 servlen=0;
433 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
436 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
444 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
445 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
446 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
448 gni_prev_IFS=$IFS; IFS=','
449 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
453 gni_qual_type_arg1=$[1]
455 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
456 [Define to the type of arg 2 for getnameinfo.])
457 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
458 [Define to the type of args 4 and 6 for getnameinfo.])
459 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
460 [Define to the type of arg 7 for getnameinfo.])
464 case $prev_sh_opts in
472 case "$gni_qual_type_arg1" in
475 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
479 gni_type_arg1=$gni_qual_type_arg1
483 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
484 [Define to the type qualifier of arg 1 for getnameinfo.])
485 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
486 [Define to the type of arg 1 for getnameinfo.])
488 case $prev_sh_opts in
496 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
497 [Define to 1 if you have the getnameinfo function.])
498 ac_cv_func_getnameinfo="yes"
504 dnl TYPE_SOCKADDR_STORAGE
505 dnl -------------------------------------------------
506 dnl Check for struct sockaddr_storage. Most IPv6-enabled
507 dnl hosts have it, but AIX 4.3 is one known exception.
509 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
511 AC_CHECK_TYPE([struct sockaddr_storage],
512 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
513 [if struct sockaddr_storage is defined]), ,
516 #ifdef HAVE_WINDOWS_H
517 #ifndef WIN32_LEAN_AND_MEAN
518 #define WIN32_LEAN_AND_MEAN
521 #ifdef HAVE_WINSOCK2_H
522 #include <winsock2.h>
525 #ifdef HAVE_SYS_TYPES_H
526 #include <sys/types.h>
528 #ifdef HAVE_SYS_SOCKET_H
529 #include <sys/socket.h>
531 #ifdef HAVE_NETINET_IN_H
532 #include <netinet/in.h>
534 #ifdef HAVE_ARPA_INET_H
535 #include <arpa/inet.h>
542 dnl CURL_CHECK_NI_WITHSCOPEID
543 dnl -------------------------------------------------
544 dnl Check for working NI_WITHSCOPEID in getnameinfo()
546 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
547 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
548 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
549 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
550 netdb.h netinet/in.h arpa/inet.h)
552 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
553 [ac_cv_working_ni_withscopeid], [
559 #ifdef HAVE_SYS_TYPES_H
560 #include <sys/types.h>
562 #ifdef HAVE_SYS_SOCKET_H
563 #include <sys/socket.h>
568 #ifdef HAVE_NETINET_IN_H
569 #include <netinet/in.h>
571 #ifdef HAVE_ARPA_INET_H
572 #include <arpa/inet.h>
575 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
576 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
577 struct sockaddr_storage sa;
579 unsigned char sa[256];
581 char hostbuf[NI_MAXHOST];
583 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
584 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
585 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
586 int fd = socket(AF_INET6, SOCK_STREAM, 0);
589 return 1; /* Error creating socket */
591 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
593 perror("getsockname()");
594 return 2; /* Error retrieving socket name */
596 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
598 printf("rc = %s\n", gai_strerror(rc));
599 return 3; /* Error translating socket address */
601 return 0; /* Ok, NI_WITHSCOPEID works */
603 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
607 # Exit code == 0. Program worked.
608 ac_cv_working_ni_withscopeid="yes"
610 # Exit code != 0. Program failed.
611 ac_cv_working_ni_withscopeid="no"
613 # Program is not run when cross-compiling. So we assume
614 # NI_WITHSCOPEID will work if we are able to compile it.
617 #include <sys/types.h>
618 #include <sys/socket.h>
621 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
624 ac_cv_working_ni_withscopeid="yes"
626 ac_cv_working_ni_withscopeid="no"
627 ]) # AC_COMPILE_IFELSE
630 case "$ac_cv_working_ni_withscopeid" in
632 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
633 [Define to 1 if NI_WITHSCOPEID exists and works.])
639 dnl CURL_CHECK_FUNC_RECV
640 dnl -------------------------------------------------
641 dnl Test if the socket recv() function is available,
642 dnl and check its return type and the types of its
643 dnl arguments. If the function succeeds HAVE_RECV
644 dnl will be defined, defining the types of the arguments
645 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
646 dnl and RECV_TYPE_ARG4, defining the type of the function
647 dnl return value in RECV_TYPE_RETV.
649 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
650 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
651 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
652 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
654 AC_MSG_CHECKING([for recv])
657 #ifdef HAVE_WINDOWS_H
658 #ifndef WIN32_LEAN_AND_MEAN
659 #define WIN32_LEAN_AND_MEAN
662 #ifdef HAVE_WINSOCK2_H
663 #include <winsock2.h>
665 #ifdef HAVE_WINSOCK_H
670 #ifdef HAVE_SYS_TYPES_H
671 #include <sys/types.h>
673 #ifdef HAVE_SYS_SOCKET_H
674 #include <sys/socket.h>
687 if test "$curl_cv_recv" = "yes"; then
688 AC_CACHE_CHECK([types of args and return type for recv],
689 [curl_cv_func_recv_args], [
690 curl_cv_func_recv_args="unknown"
691 for recv_retv in 'int' 'ssize_t'; do
692 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
693 for recv_arg2 in 'char *' 'void *'; do
694 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
695 for recv_arg4 in 'int' 'unsigned int'; do
699 #ifdef HAVE_WINDOWS_H
700 #ifndef WIN32_LEAN_AND_MEAN
701 #define WIN32_LEAN_AND_MEAN
704 #ifdef HAVE_WINSOCK2_H
705 #include <winsock2.h>
707 #ifdef HAVE_WINSOCK_H
711 #define RECVCALLCONV PASCAL
713 #ifdef HAVE_SYS_TYPES_H
714 #include <sys/types.h>
716 #ifdef HAVE_SYS_SOCKET_H
717 #include <sys/socket.h>
721 extern $recv_retv RECVCALLCONV recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
727 $recv_retv res = recv(s, buf, len, flags);
730 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
739 if test "$curl_cv_func_recv_args" = "unknown"; then
740 AC_MSG_ERROR([Cannot find proper types to use for recv args])
742 recv_prev_IFS=$IFS; IFS=','
743 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
747 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
748 [Define to the type of arg 1 for recv.])
749 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
750 [Define to the type of arg 2 for recv.])
751 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
752 [Define to the type of arg 3 for recv.])
753 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
754 [Define to the type of arg 4 for recv.])
755 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
756 [Define to the function return type for recv.])
758 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
759 [Define to 1 if you have the recv function.])
760 ac_cv_func_recv="yes"
763 AC_MSG_ERROR([Unable to link function recv])
768 dnl CURL_CHECK_FUNC_SEND
769 dnl -------------------------------------------------
770 dnl Test if the socket send() function is available,
771 dnl and check its return type and the types of its
772 dnl arguments. If the function succeeds HAVE_SEND
773 dnl will be defined, defining the types of the arguments
774 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
775 dnl and SEND_TYPE_ARG4, defining the type of the function
776 dnl return value in SEND_TYPE_RETV, and also defining the
777 dnl type qualifier of second argument in SEND_QUAL_ARG2.
779 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
780 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
781 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
782 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
784 AC_MSG_CHECKING([for send])
787 #ifdef HAVE_WINDOWS_H
788 #ifndef WIN32_LEAN_AND_MEAN
789 #define WIN32_LEAN_AND_MEAN
792 #ifdef HAVE_WINSOCK2_H
793 #include <winsock2.h>
795 #ifdef HAVE_WINSOCK_H
800 #ifdef HAVE_SYS_TYPES_H
801 #include <sys/types.h>
803 #ifdef HAVE_SYS_SOCKET_H
804 #include <sys/socket.h>
817 if test "$curl_cv_send" = "yes"; then
818 AC_CACHE_CHECK([types of args and return type for send],
819 [curl_cv_func_send_args], [
820 curl_cv_func_send_args="unknown"
821 for send_retv in 'int' 'ssize_t'; do
822 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
823 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
824 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
825 for send_arg4 in 'int' 'unsigned int'; do
829 #ifdef HAVE_WINDOWS_H
830 #ifndef WIN32_LEAN_AND_MEAN
831 #define WIN32_LEAN_AND_MEAN
834 #ifdef HAVE_WINSOCK2_H
835 #include <winsock2.h>
837 #ifdef HAVE_WINSOCK_H
841 #define SENDCALLCONV PASCAL
843 #ifdef HAVE_SYS_TYPES_H
844 #include <sys/types.h>
846 #ifdef HAVE_SYS_SOCKET_H
847 #include <sys/socket.h>
851 extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
856 $send_retv res = send(s, 0, len, flags);
859 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
868 if test "$curl_cv_func_send_args" = "unknown"; then
869 AC_MSG_ERROR([Cannot find proper types to use for send args])
871 send_prev_IFS=$IFS; IFS=','
872 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
876 send_qual_type_arg2=$[2]
878 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
879 [Define to the type of arg 1 for send.])
880 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
881 [Define to the type of arg 3 for send.])
882 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
883 [Define to the type of arg 4 for send.])
884 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
885 [Define to the function return type for send.])
889 case $prev_sh_opts in
897 case "$send_qual_type_arg2" in
900 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
904 send_type_arg2=$send_qual_type_arg2
908 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
909 [Define to the type qualifier of arg 2 for send.])
910 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
911 [Define to the type of arg 2 for send.])
913 case $prev_sh_opts in
921 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
922 [Define to 1 if you have the send function.])
923 ac_cv_func_send="yes"
926 AC_MSG_ERROR([Unable to link function send])
931 dnl CURL_CHECK_MSG_NOSIGNAL
932 dnl -------------------------------------------------
933 dnl Check for MSG_NOSIGNAL
935 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
936 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
937 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
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>
962 int flag=MSG_NOSIGNAL;
965 ac_cv_msg_nosignal="yes"
967 ac_cv_msg_nosignal="no"
970 case "$ac_cv_msg_nosignal" in
972 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
973 [Define to 1 if you have the MSG_NOSIGNAL flag.])
979 dnl CURL_CHECK_STRUCT_TIMEVAL
980 dnl -------------------------------------------------
981 dnl Check for timeval struct
983 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
984 AC_REQUIRE([AC_HEADER_TIME])dnl
985 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
986 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
987 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
988 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
992 #ifdef HAVE_WINDOWS_H
993 #ifndef WIN32_LEAN_AND_MEAN
994 #define WIN32_LEAN_AND_MEAN
997 #ifdef HAVE_WINSOCK2_H
998 #include <winsock2.h>
1000 #ifdef HAVE_WINSOCK_H
1001 #include <winsock.h>
1005 #ifdef HAVE_SYS_TYPES_H
1006 #include <sys/types.h>
1008 #ifdef HAVE_SYS_TIME_H
1009 #include <sys/time.h>
1010 #ifdef TIME_WITH_SYS_TIME
1024 ac_cv_struct_timeval="yes"
1026 ac_cv_struct_timeval="no"
1029 case "$ac_cv_struct_timeval" in
1031 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1032 [Define to 1 if you have the timeval struct.])
1038 dnl TYPE_SIG_ATOMIC_T
1039 dnl -------------------------------------------------
1040 dnl Check if the sig_atomic_t type is available, and
1041 dnl verify if it is already defined as volatile.
1043 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1044 AC_CHECK_HEADERS(signal.h)
1045 AC_CHECK_TYPE([sig_atomic_t],[
1046 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1047 [Define to 1 if sig_atomic_t is an available typedef.])
1049 #ifdef HAVE_SIGNAL_H
1053 case "$ac_cv_type_sig_atomic_t" in
1056 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1058 #ifdef HAVE_SIGNAL_H
1062 static volatile sig_atomic_t dummy = 0;
1065 ac_cv_sig_atomic_t_volatile="no"
1067 AC_MSG_RESULT([yes])
1068 ac_cv_sig_atomic_t_volatile="yes"
1071 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1072 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1073 [Define to 1 if sig_atomic_t is already defined as volatile.])
1080 dnl CURL_CHECK_NONBLOCKING_SOCKET
1081 dnl -------------------------------------------------
1082 dnl Check for how to set a socket to non-blocking state. There seems to exist
1083 dnl four known different ways, with the one used almost everywhere being POSIX
1084 dnl and XPG3, while the other different ways for different systems (old BSD,
1085 dnl Windows and Amiga).
1087 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1088 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1089 dnl to get caught in this script by using an excessive number of #ifdefs...
1091 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
1093 AC_MSG_CHECKING([non-blocking sockets style])
1096 /* headers for O_NONBLOCK test */
1097 #include <sys/types.h>
1101 /* try to compile O_NONBLOCK */
1103 #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1104 # if defined(__SVR4) || defined(__srv4__)
1105 # define PLATFORM_SOLARIS
1107 # define PLATFORM_SUNOS4
1110 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4)
1111 # define PLATFORM_AIX_V3
1114 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1115 #error "O_NONBLOCK does not work on this platform"
1118 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1120 dnl the O_NONBLOCK test was fine
1121 nonblock="O_NONBLOCK"
1122 AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
1124 dnl the code was bad, try a different program now, test 2
1127 /* headers for FIONBIO test */
1129 #include <stropts.h>
1131 /* FIONBIO source test (old-style unix) */
1133 int flags = ioctl(socket, FIONBIO, &flags);
1135 dnl FIONBIO test was good
1137 AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
1139 dnl FIONBIO test was also bad
1140 dnl the code was bad, try a different program now, test 3
1143 /* headers for ioctlsocket test (Windows) */
1145 #ifdef HAVE_WINDOWS_H
1146 #ifndef WIN32_LEAN_AND_MEAN
1147 #define WIN32_LEAN_AND_MEAN
1149 #include <windows.h>
1150 #ifdef HAVE_WINSOCK2_H
1151 #include <winsock2.h>
1153 #ifdef HAVE_WINSOCK_H
1154 #include <winsock.h>
1159 /* ioctlsocket source code */
1161 unsigned long flags = 0;
1162 sd = socket(0, 0, 0);
1163 ioctlsocket(sd, FIONBIO, &flags);
1165 dnl ioctlsocket test was good
1166 nonblock="ioctlsocket"
1167 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
1169 dnl ioctlsocket didnt compile!, go to test 4
1172 /* headers for IoctlSocket test (Amiga?) */
1173 #include <sys/ioctl.h>
1175 /* IoctlSocket source code */
1177 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1179 dnl ioctlsocket test was good
1180 nonblock="IoctlSocket"
1181 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
1183 dnl Ioctlsocket didnt compile, do test 5!
1185 /* headers for SO_NONBLOCK test (BeOS) */
1188 /* SO_NONBLOCK source code */
1191 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1193 dnl the SO_NONBLOCK test was good
1194 nonblock="SO_NONBLOCK"
1195 AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
1197 dnl test 5 didnt compile!
1199 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
1201 dnl end of fifth test
1204 dnl end of forth test
1207 dnl end of third test
1210 dnl end of second test
1213 dnl end of non-blocking try-compile test
1214 AC_MSG_RESULT($nonblock)
1216 if test "$nonblock" = "nada"; then
1217 AC_MSG_WARN([non-block sockets disabled])
1223 dnl -------------------------------------------------
1224 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1225 dnl and a few other things.
1226 AC_DEFUN([TYPE_IN_ADDR_T],
1228 AC_CHECK_TYPE([in_addr_t], ,[
1229 AC_MSG_CHECKING([for in_addr_t equivalent])
1230 AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
1232 curl_cv_in_addr_t_equiv=
1233 for t in "unsigned long" int size_t unsigned long; do
1236 #ifdef HAVE_WINDOWS_H
1237 #ifndef WIN32_LEAN_AND_MEAN
1238 #define WIN32_LEAN_AND_MEAN
1240 #include <windows.h>
1241 #ifdef HAVE_WINSOCK2_H
1242 #include <winsock2.h>
1244 #ifdef HAVE_WINSOCK_H
1245 #include <winsock.h>
1249 #ifdef HAVE_SYS_TYPES_H
1250 #include <sys/types.h>
1252 #ifdef HAVE_SYS_SOCKET_H
1253 #include <sys/socket.h>
1255 #ifdef HAVE_NETINET_IN_H
1256 #include <netinet/in.h>
1258 #ifdef HAVE_ARPA_INET_H
1259 #include <arpa/inet.h>
1263 $t data = inet_addr ("1.2.3.4");
1265 curl_cv_in_addr_t_equiv="$t"
1270 if test "x$curl_cv_in_addr_t_equiv" = x; then
1271 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1274 AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
1275 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1276 [type to use in place of in_addr_t if not defined])],
1279 #ifdef HAVE_WINDOWS_H
1280 #ifndef WIN32_LEAN_AND_MEAN
1281 #define WIN32_LEAN_AND_MEAN
1283 #include <windows.h>
1284 #ifdef HAVE_WINSOCK2_H
1285 #include <winsock2.h>
1287 #ifdef HAVE_WINSOCK_H
1288 #include <winsock.h>
1292 #ifdef HAVE_SYS_TYPES_H
1293 #include <sys/types.h>
1295 #ifdef HAVE_SYS_SOCKET_H
1296 #include <sys/socket.h>
1298 #ifdef HAVE_NETINET_IN_H
1299 #include <netinet/in.h>
1301 #ifdef HAVE_ARPA_INET_H
1302 #include <arpa/inet.h>
1305 ]) dnl AC_CHECK_TYPE
1308 dnl ************************************************************
1309 dnl check for "localhost", if it doesn't exist, we can't do the
1310 dnl gethostbyname_r tests!
1313 AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[
1314 AC_MSG_CHECKING([if "localhost" resolves])
1317 #include <sys/types.h>
1323 h = gethostbyname("localhost");
1324 exit (h == NULL ? 1 : 0); }],[
1325 AC_MSG_RESULT(yes)],[
1327 AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
1333 dnl ************************************************************
1334 dnl check for working getaddrinfo() that works with AI_NUMERICHOST
1336 AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
1337 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
1340 #include <sys/types.h>
1341 #include <sys/socket.h>
1345 struct addrinfo hints, *ai;
1348 memset(&hints, 0, sizeof(hints));
1349 hints.ai_flags = AI_NUMERICHOST;
1350 hints.ai_family = AF_UNSPEC;
1351 hints.ai_socktype = SOCK_STREAM;
1352 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
1359 ac_cv_working_getaddrinfo="yes"
1361 ac_cv_working_getaddrinfo="no"
1363 ac_cv_working_getaddrinfo="yes"
1365 if test "$ac_cv_working_getaddrinfo" = "yes"; then
1366 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
1367 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
1370 AC_SUBST(IPV6_ENABLED)
1375 AC_DEFUN([CURL_CHECK_LOCALTIME_R],
1377 dnl check for localtime_r
1378 AC_CHECK_FUNCS(localtime_r,[
1379 AC_MSG_CHECKING(whether localtime_r is declared)
1380 AC_EGREP_CPP(localtime_r,[
1381 #include <time.h>],[
1382 AC_MSG_RESULT(yes)],[
1384 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
1385 AC_EGREP_CPP(localtime_r,[
1387 #include <time.h>],[
1388 AC_DEFINE(NEED_REENTRANT)
1389 AC_MSG_RESULT(yes)],
1390 AC_MSG_RESULT(no))])])
1394 dnl This function checks for strerror_r(). If it isn't found at first, it
1395 dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
1396 dnl in order to find this function.
1398 dnl If the function is found, it will then proceed to check how the function
1399 dnl actually works: glibc-style or POSIX-style.
1402 dnl char *strerror_r(int errnum, char *buf, size_t n);
1404 dnl What this one does is to return the error string (no surprises there),
1405 dnl but it doesn't usually copy anything into buf! The 'buf' and 'n'
1406 dnl parameters are only meant as an optional working area, in case strerror_r
1407 dnl needs it. A quick test on a few systems shows that it's generally not
1411 dnl int strerror_r(int errnum, char *buf, size_t n);
1413 AC_DEFUN([CURL_CHECK_STRERROR_R],
1415 AC_CHECK_FUNCS(strerror_r)
1417 if test "x$ac_cv_func_strerror_r" = "xyes"; then
1419 AC_MSG_CHECKING(whether strerror_r is declared)
1420 AC_EGREP_CPP(strerror_r,[
1421 #include <string.h>],[
1422 AC_MSG_RESULT(yes)],[
1424 AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
1425 AC_EGREP_CPP(strerror_r,[
1427 #include <string.h>],[
1428 CPPFLAGS="-D_REENTRANT $CPPFLAGS"
1429 AC_MSG_RESULT(yes)],
1431 AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
1432 ) dnl with _THREAD_SAFE
1433 ]) dnl plain cpp for it
1435 dnl determine if this strerror_r() is glibc or POSIX
1436 AC_MSG_CHECKING([for a glibc strerror_r API])
1442 char buffer[1024]; /* big enough to play with */
1444 strerror_r(EACCES, buffer, sizeof(buffer));
1445 /* this should've returned a string */
1446 if(!string || !string[0])
1451 GLIBC_STRERROR_R="1"
1452 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
1453 AC_MSG_RESULT([yes]),
1454 AC_MSG_RESULT([no]),
1456 dnl Use an inferior method of strerror_r detection while cross-compiling
1458 #include <features.h>
1463 dnl looks like glibc, so assume a glibc-style strerror_r()
1464 GLIBC_STRERROR_R="1"
1465 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
1466 AC_MSG_RESULT([yes]),
1467 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
1468 ) dnl while cross-compiling
1471 if test -z "$GLIBC_STRERROR_R"; then
1473 AC_MSG_CHECKING([for a POSIX strerror_r API])
1479 char buffer[1024]; /* big enough to play with */
1481 strerror_r(EACCES, buffer, sizeof(buffer));
1482 /* This should've returned zero, and written an error string in the
1484 if(!buffer[0] || error)
1489 AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
1490 AC_MSG_RESULT([yes]),
1491 AC_MSG_RESULT([no]) ,
1492 dnl cross-compiling!
1493 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
1496 fi dnl if not using glibc API
1498 fi dnl we have a strerror_r
1502 AC_DEFUN([CURL_CHECK_INET_NTOA_R],
1504 dnl determine if function definition for inet_ntoa_r exists.
1505 AC_CHECK_FUNCS(inet_ntoa_r,[
1506 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
1507 AC_EGREP_CPP(inet_ntoa_r,[
1508 #include <arpa/inet.h>],[
1509 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
1510 AC_MSG_RESULT(yes)],[
1512 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
1513 AC_EGREP_CPP(inet_ntoa_r,[
1515 #include <arpa/inet.h>],[
1516 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
1517 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT defined])
1518 AC_MSG_RESULT(yes)],
1519 AC_MSG_RESULT(no))])])
1522 AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R],
1524 dnl check for number of arguments to gethostbyaddr_r. it might take
1525 dnl either 5, 7, or 8 arguments.
1526 AC_CHECK_FUNCS(gethostbyaddr_r,[
1527 AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
1529 #include <sys/types.h>
1530 #include <netdb.h>],[
1535 struct hostent_data hdata;
1537 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
1539 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
1540 ac_cv_gethostbyaddr_args=5],[
1542 AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
1545 #include <sys/types.h>
1546 #include <netdb.h>],[
1551 struct hostent_data hdata;
1553 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
1555 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
1556 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
1557 ac_cv_gethostbyaddr_args=5],[
1559 AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
1561 #include <sys/types.h>
1562 #include <netdb.h>],[
1569 struct hostent * hp;
1571 hp = gethostbyaddr_r(address, length, type, &h,
1572 buffer, 8192, &h_errnop);],[
1574 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args] )
1575 ac_cv_gethostbyaddr_args=7],[
1577 AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
1579 #include <sys/types.h>
1580 #include <netdb.h>],[
1587 struct hostent * hp;
1590 rc = gethostbyaddr_r(address, length, type, &h,
1591 buffer, 8192, &hp, &h_errnop);],[
1593 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
1594 ac_cv_gethostbyaddr_args=8],[
1596 have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
1599 AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R],
1601 dnl check for number of arguments to gethostbyname_r. it might take
1602 dnl either 3, 5, or 6 arguments.
1603 AC_CHECK_FUNCS(gethostbyname_r,[
1604 AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
1607 #include <sys/types.h>
1610 #define NULL (void *)0
1613 gethostbyname_r(const char *, struct hostent *, struct hostent_data *);],[
1614 struct hostent_data data;
1615 gethostbyname_r(NULL, NULL, NULL);],[
1617 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
1618 ac_cv_gethostbyname_args=3],[
1620 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
1625 #include <sys/types.h>
1628 #define NULL (void *)0
1631 gethostbyname_r(const char *,struct hostent *, struct hostent_data *);],[
1632 struct hostent_data data;
1633 gethostbyname_r(NULL, NULL, NULL);],[
1635 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
1636 AC_DEFINE(NEED_REENTRANT, 1, [needs REENTRANT])
1637 ac_cv_gethostbyname_args=3],[
1639 AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
1641 #include <sys/types.h>
1644 #define NULL (void *)0
1647 gethostbyname_r(const char *, struct hostent *, char *, int, int *);],[
1648 gethostbyname_r(NULL, NULL, NULL, 0, NULL);],[
1650 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
1651 ac_cv_gethostbyname_args=5],[
1653 AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
1655 #include <sys/types.h>
1658 #define NULL (void *)0
1661 gethostbyname_r(const char *, struct hostent *, char *, size_t,
1662 struct hostent **, int *);],[
1663 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);],[
1665 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
1666 ac_cv_gethostbyname_args=6],[
1668 have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
1669 [ac_cv_gethostbyname_args=0])],
1670 [ac_cv_gethostbyname_args=0])],
1671 [ac_cv_gethostbyname_args=0])],
1672 [ac_cv_gethostbyname_args=0])])
1674 if test "$ac_cv_func_gethostbyname_r" = "yes"; then
1675 if test "$ac_cv_gethostbyname_args" = "0"; then
1676 dnl there's a gethostbyname_r() function, but we don't know how
1677 dnl many arguments it wants!
1678 AC_MSG_ERROR([couldn't figure out how to use gethostbyname_r()])
1684 dnl **********************************************************************
1685 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
1687 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
1688 dnl sets the $ICC variable to "yes" or "no"
1689 dnl **********************************************************************
1690 AC_DEFUN([CURL_DETECT_ICC],
1693 AC_MSG_CHECKING([for icc in use])
1694 if test "$GCC" = "yes"; then
1695 dnl check if this is icc acting as gcc in disguise
1696 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
1697 dnl action if the text is found, this it has not been replaced by the
1700 dnl the text was not found, it was replaced by the cpp
1702 AC_MSG_RESULT([yes])
1706 if test "$ICC" = "no"; then
1712 dnl We create a function for detecting which compiler we use and then set as
1713 dnl pendantic compiler options as possible for that particular compiler. The
1714 dnl options are only used for debug-builds.
1716 AC_DEFUN([CURL_CC_DEBUG_OPTS],
1718 if test "z$ICC" = "z"; then
1722 if test "$GCC" = "yes"; then
1724 dnl figure out gcc version!
1725 AC_MSG_CHECKING([gcc version])
1726 gccver=`$CC -dumpversion`
1727 num1=`echo $gccver | cut -d . -f1`
1728 num2=`echo $gccver | cut -d . -f2`
1729 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
1730 AC_MSG_RESULT($gccver)
1732 if test "$ICC" = "yes"; then
1733 dnl this is icc, not gcc.
1735 dnl ICC warnings we ignore:
1736 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
1737 dnl "invalid format string conversion"
1738 dnl * 279 warns on static conditions in while expressions
1739 dnl * 981 warns on "operands are evaluated in unspecified order"
1740 dnl * 1418 "external definition with no prior declaration"
1741 dnl * 1419 warns on "external declaration in primary source file"
1742 dnl which we know and do on purpose.
1744 WARN="-wd279,269,981,1418,1419"
1746 if test "$gccnum" -gt "600"; then
1747 dnl icc 6.0 and older doesn't have the -Wall flag
1751 dnl this is a set of options we believe *ALL* gcc versions support:
1752 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
1754 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
1756 if test "$gccnum" -ge "207"; then
1757 dnl gcc 2.7 or later
1758 WARN="$WARN -Wmissing-declarations"
1761 if test "$gccnum" -gt "295"; then
1762 dnl only if the compiler is newer than 2.95 since we got lots of
1763 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
1764 dnl gcc 2.95.4 on FreeBSD 4.9!
1765 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare"
1768 if test "$gccnum" -ge "296"; then
1769 dnl gcc 2.96 or later
1770 WARN="$WARN -Wfloat-equal"
1773 if test "$gccnum" -gt "296"; then
1774 dnl this option does not exist in 2.96
1775 WARN="$WARN -Wno-format-nonliteral"
1778 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1779 dnl on i686-Linux as it gives us heaps with false positives.
1780 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
1781 dnl over making it unusable for generic purposes. Let's not use it.
1783 if test "$gccnum" -ge "303"; then
1784 dnl gcc 3.3 and later
1785 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
1788 if test "$gccnum" -ge "304"; then
1789 # try these on gcc 3.4
1790 WARN="$WARN -Wdeclaration-after-statement"
1793 for flag in $CPPFLAGS; do
1796 dnl Include path, provide a -isystem option for the same dir
1797 dnl to prevent warnings in those dirs. The -isystem was not very
1798 dnl reliable on earlier gcc versions.
1799 add=`echo $flag | sed 's/^-I/-isystem /g'`
1807 CFLAGS="$CFLAGS $WARN"
1809 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
1813 AC_MSG_NOTICE([Added no extra compiler options])
1817 dnl strip off optimizer flags
1819 for flag in $CFLAGS; do
1822 dnl echo "cut off $flag"
1825 NEWFLAGS="$NEWFLAGS $flag"
1831 ]) dnl end of AC_DEFUN()
1834 dnl Determine the name of the library to pass to dlopen() based on the name
1835 dnl that would normally be given to AC_CHECK_LIB. The preprocessor symbol
1836 dnl given is set to the quoted library file name.
1837 dnl The standard dynamic library file name is first generated, based on the
1838 dnl current system type, then a search is performed for that file on the
1839 dnl standard dynamic library path. If it is a symbolic link, the destination
1840 dnl of the link is used as the file name, after stripping off any minor
1841 dnl version numbers. If a library file can't be found, a guess is made.
1842 dnl This macro assumes AC_PROG_LIBTOOL has been called and requires perl
1843 dnl to be available in the PATH, or $PERL to be set to its location.
1845 dnl CURL_DLLIB_NAME(VARIABLE, library_name)
1846 dnl e.g. CURL_DLLIB_NAME(LDAP_NAME, ldap) on a Linux system might result
1847 dnl in LDAP_NAME holding the string "libldap.so.2".
1849 AC_DEFUN([CURL_DLLIB_NAME],
1851 AC_MSG_CHECKING([name of dynamic library $2])
1852 dnl The shared library extension variable name changes from version to
1853 dnl version of libtool. Try a few names then just set one statically.
1854 test -z "$shared_ext" && eval shared_ext=\"$shrext_cmds\"
1855 test -z "$shared_ext" && shared_ext="$std_shrext"
1856 test -z "$shared_ext" && shared_ext="$shrext"
1857 test -z "$shared_ext" && shared_ext=".so"
1859 dnl Create the library link name of the correct form for this platform
1860 LIBNAME_LINK_SPEC=`echo "$library_names_spec" | $SED 's/^.* //'`
1861 DLGUESSLIB=`name=$2 eval echo "$libname_spec"`
1862 DLGUESSFILE=`libname="$DLGUESSLIB" release="" major="" versuffix="" eval echo "$LIBNAME_LINK_SPEC"`
1863 dnl Last resort in case libtool knows nothing about shared libs on this platform
1864 test -z "$DLGUESSFILE" && DLGUESSFILE="$DLGUESSLIB$shared_ext"
1866 dnl Synthesize a likely dynamic library name in case we can't find an actual one
1867 SO_NAME_SPEC="$soname_spec"
1868 dnl soname_spec undefined when identical to the 1st entry in library_names_spec
1869 test -z "$SO_NAME_SPEC" && SO_NAME_SPEC=`echo "$library_names_spec" | $SED 's/ .*$//'`
1870 DLGUESSSOFILE=`libname="$DLGUESSLIB" release="" major="" versuffix="" eval echo "$SO_NAME_SPEC"`
1871 dnl Last resort in case libtool knows nothing about shared libs on this platform
1872 test -z "$DLGUESSSOFILE" && DLGUESSSOFILE="$DLGUESSFILE"
1874 if test "$cross_compiling" = yes; then
1875 dnl Can't look at filesystem when cross-compiling
1876 AC_DEFINE_UNQUOTED($1, "$DLGUESSSOFILE", [$2 dynamic library file])
1877 AC_MSG_RESULT([$DLGUESSSOFILE (guess while cross-compiling)])
1881 if test "$sys_lib_dlsearch_path_spec" ; then
1882 dnl Search for the link library name and see what it points to.
1883 for direc in $sys_lib_dlsearch_path_spec ; do
1884 DLTRYFILE="$direc/$DLGUESSFILE"
1885 dnl Find where the symbolic link for this name points
1886 changequote(<<, >>)dnl
1888 DLFOUNDFILE=`${PERL:-perl} -e 'use File::Basename; (basename(readlink($ARGV[0])) =~ /^(.*[^\d]\.\d+)[\d\.]*$/ && print ${1}) || exit 1;' "$DLTRYFILE" 2>&5`
1890 changequote([, ])dnl
1891 if test "$?" -eq "0"; then
1892 dnl Found the file link
1898 if test -z "$DLFOUNDFILE" ; then
1899 dnl Couldn't find a link library, so guess at a name.
1900 DLFOUNDFILE="$DLGUESSSOFILE"
1903 AC_DEFINE_UNQUOTED($1, "$DLFOUNDFILE", [$2 dynamic library file])
1904 AC_MSG_RESULT($DLFOUNDFILE)
1908 # This is only a temporary fix. This macro is here to replace the broken one
1909 # delivered by the automake project (including the 1.9.6 release). As soon as
1910 # they ship a working version we SHOULD remove this work-around.
1912 AC_DEFUN([AM_MISSING_HAS_RUN],
1913 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
1914 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
1915 # Use eval to expand $SHELL
1916 if eval "$MISSING --run true"; then
1917 am_missing_run="$MISSING --run "
1920 AC_MSG_WARN([`missing' script is too old or missing])
1925 dnl CURL_VERIFY_RUNTIMELIBS
1926 dnl -------------------------------------------------
1927 dnl Verify that the shared libs found so far can be used when running
1928 dnl programs, since otherwise the situation will create odd configure errors
1929 dnl that are misleading people.
1931 dnl Make sure this test is run BEFORE the first test in the script that
1932 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
1933 dnl macro. It must also run AFTER all lib-checking macros are complete.
1935 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
1937 dnl this test is of course not sensible if we are cross-compiling!
1938 if test "x$cross_compiling" != xyes; then
1940 dnl just run a program to verify that the libs checked for previous to this
1941 dnl point also is available run-time!
1942 AC_MSG_CHECKING([run-time libs availability])
1949 AC_MSG_RESULT([fine]),
1950 AC_MSG_RESULT([failed])
1951 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
1954 dnl if this test fails, configure has already stopped
1959 dnl CURL_CHECK_VARIADIC_MACROS
1960 dnl -------------------------------------------------
1961 dnl Check compiler support of variadic macros
1963 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
1964 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
1965 [curl_cv_variadic_macros_c99], [
1968 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
1969 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
1970 int fun3(int arg1, int arg2, int arg3);
1971 int fun2(int arg1, int arg2);
1972 int fun3(int arg1, int arg2, int arg3)
1973 { return arg1 + arg2 + arg3; }
1974 int fun2(int arg1, int arg2)
1975 { return arg1 + arg2; }
1977 int res3 = c99_vmacro3(1, 2, 3);
1978 int res2 = c99_vmacro2(1, 2);
1981 curl_cv_variadic_macros_c99="yes"
1983 curl_cv_variadic_macros_c99="no"
1986 case "$curl_cv_variadic_macros_c99" in
1988 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
1989 [Define to 1 if compiler supports C99 variadic macro style.])
1992 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
1993 [curl_cv_variadic_macros_gcc], [
1996 #define gcc_vmacro3(first, args...) fun3(first, args)
1997 #define gcc_vmacro2(first, args...) fun2(first, args)
1998 int fun3(int arg1, int arg2, int arg3);
1999 int fun2(int arg1, int arg2);
2000 int fun3(int arg1, int arg2, int arg3)
2001 { return arg1 + arg2 + arg3; }
2002 int fun2(int arg1, int arg2)
2003 { return arg1 + arg2; }
2005 int res3 = gcc_vmacro3(1, 2, 3);
2006 int res2 = gcc_vmacro2(1, 2);
2009 curl_cv_variadic_macros_gcc="yes"
2011 curl_cv_variadic_macros_gcc="no"
2014 case "$curl_cv_variadic_macros_gcc" in
2016 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2017 [Define to 1 if compiler supports old gcc variadic macro style.])