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_WINLDAP
175 dnl -------------------------------------------------
176 dnl Check for compilable and valid winldap.h header
178 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
179 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
180 AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
184 #ifndef WIN32_LEAN_AND_MEAN
185 #define WIN32_LEAN_AND_MEAN
191 HAVE_WINLDAP_H shall not be defined.
193 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
194 ULONG res = ldap_unbind(ldp);
198 ac_cv_header_winldap_h="yes"
200 ac_cv_header_winldap_h="no"
203 case "$ac_cv_header_winldap_h" in
205 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
206 [Define to 1 if you have the winldap.h header file.])
212 dnl CURL_CHECK_HEADER_WINBER
213 dnl -------------------------------------------------
214 dnl Check for compilable and valid winber.h header
216 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
217 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
218 AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
222 #ifndef WIN32_LEAN_AND_MEAN
223 #define WIN32_LEAN_AND_MEAN
230 HAVE_WINBER_H shall not be defined.
233 BerElement *bep = ber_init(bvp);
238 ac_cv_header_winber_h="yes"
240 ac_cv_header_winber_h="no"
243 case "$ac_cv_header_winber_h" in
245 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
246 [Define to 1 if you have the winber.h header file.])
252 dnl CURL_CHECK_HEADER_MALLOC
253 dnl -------------------------------------------------
254 dnl Check for compilable and valid malloc.h header,
255 dnl and check if it is needed even with stdlib.h
257 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
258 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
263 void *p = malloc(10);
264 void *q = calloc(10,10);
269 ac_cv_header_malloc_h="yes"
271 ac_cv_header_malloc_h="no"
274 if test "$ac_cv_header_malloc_h" = "yes"; then
275 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
276 [Define to 1 if you have the malloc.h header file.])
282 void *p = malloc(10);
283 void *q = calloc(10,10);
288 curl_cv_need_header_malloc_h="no"
290 curl_cv_need_header_malloc_h="yes"
293 case "$curl_cv_need_header_malloc_h" in
295 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
296 [Define to 1 if you need the malloc.h header file even with stdlib.h])
303 dnl CURL_CHECK_TYPE_SOCKLEN_T
304 dnl -------------------------------------------------
305 dnl Check for existing socklen_t type, and provide
306 dnl an equivalent type if socklen_t not available
308 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
309 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
310 AC_CHECK_TYPE([socklen_t], ,[
311 AC_CACHE_CHECK([for socklen_t equivalent],
312 [curl_cv_socklen_t_equiv], [
313 curl_cv_socklen_t_equiv="unknown"
314 for arg2 in "struct sockaddr" void; do
315 for t in int size_t unsigned long "unsigned long"; do
319 #ifdef HAVE_WINDOWS_H
320 #ifndef WIN32_LEAN_AND_MEAN
321 #define WIN32_LEAN_AND_MEAN
324 #ifdef HAVE_WINSOCK2_H
325 #include <winsock2.h>
327 #ifdef HAVE_WINSOCK_H
332 #ifdef HAVE_SYS_TYPES_H
333 #include <sys/types.h>
335 #ifdef HAVE_SYS_SOCKET_H
336 #include <sys/socket.h>
339 int getpeername (int, $arg2 *, $t *);
342 getpeername(0,0,&len);
345 curl_cv_socklen_t_equiv="$t"
351 case "$curl_cv_socklen_t_equiv" in
353 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
356 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
357 [type to use in place of socklen_t if not defined])
362 #ifdef HAVE_WINDOWS_H
363 #ifndef WIN32_LEAN_AND_MEAN
364 #define WIN32_LEAN_AND_MEAN
367 #ifdef HAVE_WINSOCK2_H
368 #include <winsock2.h>
369 #ifdef HAVE_WS2TCPIP_H
370 #include <ws2tcpip.h>
374 #ifdef HAVE_SYS_TYPES_H
375 #include <sys/types.h>
377 #ifdef HAVE_SYS_SOCKET_H
378 #include <sys/socket.h>
385 dnl CURL_CHECK_FUNC_GETNAMEINFO
386 dnl -------------------------------------------------
387 dnl Test if the getnameinfo function is available,
388 dnl and check the types of five of its arguments.
389 dnl If the function succeeds HAVE_GETNAMEINFO will be
390 dnl defined, defining the types of the arguments in
391 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
392 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
393 dnl and also defining the type qualifier of first
394 dnl argument in GETNAMEINFO_QUAL_ARG1.
396 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
397 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
398 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
399 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
401 AC_MSG_CHECKING([for getnameinfo])
403 AC_LANG_FUNC_LINK_TRY([getnameinfo])
406 curl_cv_getnameinfo="yes"
409 curl_cv_getnameinfo="no"
412 if test "$curl_cv_getnameinfo" != "yes"; then
413 AC_MSG_CHECKING([deeper for getnameinfo])
419 curl_cv_getnameinfo="yes"
421 AC_MSG_RESULT([but still no])
422 curl_cv_getnameinfo="no"
426 if test "$curl_cv_getnameinfo" != "yes"; then
427 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
430 #ifdef HAVE_WINDOWS_H
431 #ifndef WIN32_LEAN_AND_MEAN
432 #define WIN32_LEAN_AND_MEAN
435 #ifdef HAVE_WINSOCK2_H
436 #include <winsock2.h>
437 #ifdef HAVE_WS2TCPIP_H
438 #include <ws2tcpip.h>
442 #ifdef HAVE_SYS_TYPES_H
443 #include <sys/types.h>
445 #ifdef HAVE_SYS_SOCKET_H
446 #include <sys/socket.h>
453 getnameinfo(0, 0, 0, 0, 0, 0, 0);
456 curl_cv_getnameinfo="yes"
458 AC_MSG_RESULT([but still no])
459 curl_cv_getnameinfo="no"
463 if test "$curl_cv_getnameinfo" = "yes"; then
464 AC_CACHE_CHECK([types of arguments for getnameinfo],
465 [curl_cv_func_getnameinfo_args], [
466 curl_cv_func_getnameinfo_args="unknown"
467 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
468 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
469 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
470 for gni_arg7 in 'int' 'unsigned int'; do
474 #ifdef HAVE_WINDOWS_H
475 #ifndef WIN32_LEAN_AND_MEAN
476 #define WIN32_LEAN_AND_MEAN
478 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
480 #define _WIN32_WINNT 0x0501
483 #ifdef HAVE_WINSOCK2_H
484 #include <winsock2.h>
485 #ifdef HAVE_WS2TCPIP_H
486 #include <ws2tcpip.h>
489 #define GNICALLCONV WSAAPI
491 #ifdef HAVE_SYS_TYPES_H
492 #include <sys/types.h>
494 #ifdef HAVE_SYS_SOCKET_H
495 #include <sys/socket.h>
502 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
508 $gni_arg46 hostlen=0;
509 $gni_arg46 servlen=0;
511 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
514 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
522 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
523 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
524 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
526 gni_prev_IFS=$IFS; IFS=','
527 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
531 gni_qual_type_arg1=$[1]
533 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
534 [Define to the type of arg 2 for getnameinfo.])
535 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
536 [Define to the type of args 4 and 6 for getnameinfo.])
537 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
538 [Define to the type of arg 7 for getnameinfo.])
542 case $prev_sh_opts in
550 case "$gni_qual_type_arg1" in
553 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
557 gni_type_arg1=$gni_qual_type_arg1
561 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
562 [Define to the type qualifier of arg 1 for getnameinfo.])
563 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
564 [Define to the type of arg 1 for getnameinfo.])
566 case $prev_sh_opts in
574 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
575 [Define to 1 if you have the getnameinfo function.])
576 ac_cv_func_getnameinfo="yes"
582 dnl TYPE_SOCKADDR_STORAGE
583 dnl -------------------------------------------------
584 dnl Check for struct sockaddr_storage. Most IPv6-enabled
585 dnl hosts have it, but AIX 4.3 is one known exception.
587 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
589 AC_CHECK_TYPE([struct sockaddr_storage],
590 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
591 [if struct sockaddr_storage is defined]), ,
594 #ifdef HAVE_WINDOWS_H
595 #ifndef WIN32_LEAN_AND_MEAN
596 #define WIN32_LEAN_AND_MEAN
599 #ifdef HAVE_WINSOCK2_H
600 #include <winsock2.h>
603 #ifdef HAVE_SYS_TYPES_H
604 #include <sys/types.h>
606 #ifdef HAVE_SYS_SOCKET_H
607 #include <sys/socket.h>
609 #ifdef HAVE_NETINET_IN_H
610 #include <netinet/in.h>
612 #ifdef HAVE_ARPA_INET_H
613 #include <arpa/inet.h>
620 dnl CURL_CHECK_NI_WITHSCOPEID
621 dnl -------------------------------------------------
622 dnl Check for working NI_WITHSCOPEID in getnameinfo()
624 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
625 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
626 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
627 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
628 netdb.h netinet/in.h arpa/inet.h)
630 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
631 [ac_cv_working_ni_withscopeid], [
637 #ifdef HAVE_SYS_TYPES_H
638 #include <sys/types.h>
640 #ifdef HAVE_SYS_SOCKET_H
641 #include <sys/socket.h>
646 #ifdef HAVE_NETINET_IN_H
647 #include <netinet/in.h>
649 #ifdef HAVE_ARPA_INET_H
650 #include <arpa/inet.h>
653 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
654 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
655 struct sockaddr_storage sa;
657 unsigned char sa[256];
659 char hostbuf[NI_MAXHOST];
661 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
662 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
663 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
664 int fd = socket(AF_INET6, SOCK_STREAM, 0);
667 return 1; /* Error creating socket */
669 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
671 perror("getsockname()");
672 return 2; /* Error retrieving socket name */
674 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
676 printf("rc = %s\n", gai_strerror(rc));
677 return 3; /* Error translating socket address */
679 return 0; /* Ok, NI_WITHSCOPEID works */
681 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
685 # Exit code == 0. Program worked.
686 ac_cv_working_ni_withscopeid="yes"
688 # Exit code != 0. Program failed.
689 ac_cv_working_ni_withscopeid="no"
691 # Program is not run when cross-compiling. So we assume
692 # NI_WITHSCOPEID will work if we are able to compile it.
695 #include <sys/types.h>
696 #include <sys/socket.h>
699 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
702 ac_cv_working_ni_withscopeid="yes"
704 ac_cv_working_ni_withscopeid="no"
705 ]) # AC_COMPILE_IFELSE
708 case "$ac_cv_working_ni_withscopeid" in
710 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
711 [Define to 1 if NI_WITHSCOPEID exists and works.])
717 dnl CURL_CHECK_FUNC_RECV
718 dnl -------------------------------------------------
719 dnl Test if the socket recv() function is available,
720 dnl and check its return type and the types of its
721 dnl arguments. If the function succeeds HAVE_RECV
722 dnl will be defined, defining the types of the arguments
723 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
724 dnl and RECV_TYPE_ARG4, defining the type of the function
725 dnl return value in RECV_TYPE_RETV.
727 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
728 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
729 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
730 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
732 AC_MSG_CHECKING([for recv])
735 #ifdef HAVE_WINDOWS_H
736 #ifndef WIN32_LEAN_AND_MEAN
737 #define WIN32_LEAN_AND_MEAN
740 #ifdef HAVE_WINSOCK2_H
741 #include <winsock2.h>
743 #ifdef HAVE_WINSOCK_H
748 #ifdef HAVE_SYS_TYPES_H
749 #include <sys/types.h>
751 #ifdef HAVE_SYS_SOCKET_H
752 #include <sys/socket.h>
765 if test "$curl_cv_recv" = "yes"; then
766 AC_CACHE_CHECK([types of args and return type for recv],
767 [curl_cv_func_recv_args], [
768 curl_cv_func_recv_args="unknown"
769 for recv_retv in 'int' 'ssize_t'; do
770 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
771 for recv_arg2 in 'char *' 'void *'; do
772 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
773 for recv_arg4 in 'int' 'unsigned int'; do
777 #ifdef HAVE_WINDOWS_H
778 #ifndef WIN32_LEAN_AND_MEAN
779 #define WIN32_LEAN_AND_MEAN
782 #ifdef HAVE_WINSOCK2_H
783 #include <winsock2.h>
785 #ifdef HAVE_WINSOCK_H
789 #define RECVCALLCONV PASCAL
791 #ifdef HAVE_SYS_TYPES_H
792 #include <sys/types.h>
794 #ifdef HAVE_SYS_SOCKET_H
795 #include <sys/socket.h>
799 extern $recv_retv RECVCALLCONV recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
805 $recv_retv res = recv(s, buf, len, flags);
808 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
817 if test "$curl_cv_func_recv_args" = "unknown"; then
818 AC_MSG_ERROR([Cannot find proper types to use for recv args])
820 recv_prev_IFS=$IFS; IFS=','
821 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
825 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
826 [Define to the type of arg 1 for recv.])
827 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
828 [Define to the type of arg 2 for recv.])
829 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
830 [Define to the type of arg 3 for recv.])
831 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
832 [Define to the type of arg 4 for recv.])
833 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
834 [Define to the function return type for recv.])
836 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
837 [Define to 1 if you have the recv function.])
838 ac_cv_func_recv="yes"
841 AC_MSG_ERROR([Unable to link function recv])
846 dnl CURL_CHECK_FUNC_SEND
847 dnl -------------------------------------------------
848 dnl Test if the socket send() function is available,
849 dnl and check its return type and the types of its
850 dnl arguments. If the function succeeds HAVE_SEND
851 dnl will be defined, defining the types of the arguments
852 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
853 dnl and SEND_TYPE_ARG4, defining the type of the function
854 dnl return value in SEND_TYPE_RETV, and also defining the
855 dnl type qualifier of second argument in SEND_QUAL_ARG2.
857 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
858 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
859 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
860 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
862 AC_MSG_CHECKING([for send])
865 #ifdef HAVE_WINDOWS_H
866 #ifndef WIN32_LEAN_AND_MEAN
867 #define WIN32_LEAN_AND_MEAN
870 #ifdef HAVE_WINSOCK2_H
871 #include <winsock2.h>
873 #ifdef HAVE_WINSOCK_H
878 #ifdef HAVE_SYS_TYPES_H
879 #include <sys/types.h>
881 #ifdef HAVE_SYS_SOCKET_H
882 #include <sys/socket.h>
895 if test "$curl_cv_send" = "yes"; then
896 AC_CACHE_CHECK([types of args and return type for send],
897 [curl_cv_func_send_args], [
898 curl_cv_func_send_args="unknown"
899 for send_retv in 'int' 'ssize_t'; do
900 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
901 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
902 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
903 for send_arg4 in 'int' 'unsigned int'; do
907 #ifdef HAVE_WINDOWS_H
908 #ifndef WIN32_LEAN_AND_MEAN
909 #define WIN32_LEAN_AND_MEAN
912 #ifdef HAVE_WINSOCK2_H
913 #include <winsock2.h>
915 #ifdef HAVE_WINSOCK_H
919 #define SENDCALLCONV PASCAL
921 #ifdef HAVE_SYS_TYPES_H
922 #include <sys/types.h>
924 #ifdef HAVE_SYS_SOCKET_H
925 #include <sys/socket.h>
929 extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
934 $send_retv res = send(s, 0, len, flags);
937 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
946 if test "$curl_cv_func_send_args" = "unknown"; then
947 AC_MSG_ERROR([Cannot find proper types to use for send args])
949 send_prev_IFS=$IFS; IFS=','
950 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
954 send_qual_type_arg2=$[2]
956 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
957 [Define to the type of arg 1 for send.])
958 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
959 [Define to the type of arg 3 for send.])
960 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
961 [Define to the type of arg 4 for send.])
962 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
963 [Define to the function return type for send.])
967 case $prev_sh_opts in
975 case "$send_qual_type_arg2" in
978 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
982 send_type_arg2=$send_qual_type_arg2
986 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
987 [Define to the type qualifier of arg 2 for send.])
988 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
989 [Define to the type of arg 2 for send.])
991 case $prev_sh_opts in
999 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1000 [Define to 1 if you have the send function.])
1001 ac_cv_func_send="yes"
1004 AC_MSG_ERROR([Unable to link function send])
1009 dnl CURL_CHECK_MSG_NOSIGNAL
1010 dnl -------------------------------------------------
1011 dnl Check for MSG_NOSIGNAL
1013 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1014 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1015 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1019 #ifdef HAVE_WINDOWS_H
1020 #ifndef WIN32_LEAN_AND_MEAN
1021 #define WIN32_LEAN_AND_MEAN
1023 #include <windows.h>
1024 #ifdef HAVE_WINSOCK2_H
1025 #include <winsock2.h>
1027 #ifdef HAVE_WINSOCK_H
1028 #include <winsock.h>
1032 #ifdef HAVE_SYS_TYPES_H
1033 #include <sys/types.h>
1035 #ifdef HAVE_SYS_SOCKET_H
1036 #include <sys/socket.h>
1040 int flag=MSG_NOSIGNAL;
1043 ac_cv_msg_nosignal="yes"
1045 ac_cv_msg_nosignal="no"
1048 case "$ac_cv_msg_nosignal" in
1050 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1051 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1057 dnl CURL_CHECK_STRUCT_TIMEVAL
1058 dnl -------------------------------------------------
1059 dnl Check for timeval struct
1061 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1062 AC_REQUIRE([AC_HEADER_TIME])dnl
1063 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1064 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1065 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1066 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1070 #ifdef HAVE_WINDOWS_H
1071 #ifndef WIN32_LEAN_AND_MEAN
1072 #define WIN32_LEAN_AND_MEAN
1074 #include <windows.h>
1075 #ifdef HAVE_WINSOCK2_H
1076 #include <winsock2.h>
1078 #ifdef HAVE_WINSOCK_H
1079 #include <winsock.h>
1083 #ifdef HAVE_SYS_TYPES_H
1084 #include <sys/types.h>
1086 #ifdef HAVE_SYS_TIME_H
1087 #include <sys/time.h>
1088 #ifdef TIME_WITH_SYS_TIME
1102 ac_cv_struct_timeval="yes"
1104 ac_cv_struct_timeval="no"
1107 case "$ac_cv_struct_timeval" in
1109 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1110 [Define to 1 if you have the timeval struct.])
1116 dnl TYPE_SIG_ATOMIC_T
1117 dnl -------------------------------------------------
1118 dnl Check if the sig_atomic_t type is available, and
1119 dnl verify if it is already defined as volatile.
1121 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1122 AC_CHECK_HEADERS(signal.h)
1123 AC_CHECK_TYPE([sig_atomic_t],[
1124 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1125 [Define to 1 if sig_atomic_t is an available typedef.])
1127 #ifdef HAVE_SIGNAL_H
1131 case "$ac_cv_type_sig_atomic_t" in
1134 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1136 #ifdef HAVE_SIGNAL_H
1140 static volatile sig_atomic_t dummy = 0;
1143 ac_cv_sig_atomic_t_volatile="no"
1145 AC_MSG_RESULT([yes])
1146 ac_cv_sig_atomic_t_volatile="yes"
1149 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1150 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1151 [Define to 1 if sig_atomic_t is already defined as volatile.])
1158 dnl CURL_CHECK_NONBLOCKING_SOCKET
1159 dnl -------------------------------------------------
1160 dnl Check for how to set a socket to non-blocking state. There seems to exist
1161 dnl four known different ways, with the one used almost everywhere being POSIX
1162 dnl and XPG3, while the other different ways for different systems (old BSD,
1163 dnl Windows and Amiga).
1165 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1166 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1167 dnl to get caught in this script by using an excessive number of #ifdefs...
1169 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
1171 AC_MSG_CHECKING([non-blocking sockets style])
1174 /* headers for O_NONBLOCK test */
1175 #include <sys/types.h>
1179 /* try to compile O_NONBLOCK */
1181 #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1182 # if defined(__SVR4) || defined(__srv4__)
1183 # define PLATFORM_SOLARIS
1185 # define PLATFORM_SUNOS4
1188 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
1189 # define PLATFORM_AIX_V3
1192 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1193 #error "O_NONBLOCK does not work on this platform"
1196 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1198 dnl the O_NONBLOCK test was fine
1199 nonblock="O_NONBLOCK"
1200 AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
1202 dnl the code was bad, try a different program now, test 2
1205 /* headers for FIONBIO test */
1207 #include <stropts.h>
1209 /* FIONBIO source test (old-style unix) */
1211 int flags = ioctl(socket, FIONBIO, &flags);
1213 dnl FIONBIO test was good
1215 AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
1217 dnl FIONBIO test was also bad
1218 dnl the code was bad, try a different program now, test 3
1221 /* headers for ioctlsocket test (Windows) */
1223 #ifdef HAVE_WINDOWS_H
1224 #ifndef WIN32_LEAN_AND_MEAN
1225 #define WIN32_LEAN_AND_MEAN
1227 #include <windows.h>
1228 #ifdef HAVE_WINSOCK2_H
1229 #include <winsock2.h>
1231 #ifdef HAVE_WINSOCK_H
1232 #include <winsock.h>
1237 /* ioctlsocket source code */
1239 unsigned long flags = 0;
1240 sd = socket(0, 0, 0);
1241 ioctlsocket(sd, FIONBIO, &flags);
1243 dnl ioctlsocket test was good
1244 nonblock="ioctlsocket"
1245 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
1247 dnl ioctlsocket didnt compile!, go to test 4
1250 /* headers for IoctlSocket test (Amiga?) */
1251 #include <sys/ioctl.h>
1253 /* IoctlSocket source code */
1255 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1257 dnl ioctlsocket test was good
1258 nonblock="IoctlSocket"
1259 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
1261 dnl Ioctlsocket didnt compile, do test 5!
1263 /* headers for SO_NONBLOCK test (BeOS) */
1266 /* SO_NONBLOCK source code */
1269 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1271 dnl the SO_NONBLOCK test was good
1272 nonblock="SO_NONBLOCK"
1273 AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
1275 dnl test 5 didnt compile!
1277 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
1279 dnl end of fifth test
1282 dnl end of forth test
1285 dnl end of third test
1288 dnl end of second test
1291 dnl end of non-blocking try-compile test
1292 AC_MSG_RESULT($nonblock)
1294 if test "$nonblock" = "nada"; then
1295 AC_MSG_WARN([non-block sockets disabled])
1301 dnl -------------------------------------------------
1302 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1303 dnl and a few other things.
1304 AC_DEFUN([TYPE_IN_ADDR_T],
1306 AC_CHECK_TYPE([in_addr_t], ,[
1307 AC_MSG_CHECKING([for in_addr_t equivalent])
1308 AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
1310 curl_cv_in_addr_t_equiv=
1311 for t in "unsigned long" int size_t unsigned long; do
1314 #ifdef HAVE_WINDOWS_H
1315 #ifndef WIN32_LEAN_AND_MEAN
1316 #define WIN32_LEAN_AND_MEAN
1318 #include <windows.h>
1319 #ifdef HAVE_WINSOCK2_H
1320 #include <winsock2.h>
1322 #ifdef HAVE_WINSOCK_H
1323 #include <winsock.h>
1327 #ifdef HAVE_SYS_TYPES_H
1328 #include <sys/types.h>
1330 #ifdef HAVE_SYS_SOCKET_H
1331 #include <sys/socket.h>
1333 #ifdef HAVE_NETINET_IN_H
1334 #include <netinet/in.h>
1336 #ifdef HAVE_ARPA_INET_H
1337 #include <arpa/inet.h>
1341 $t data = inet_addr ("1.2.3.4");
1343 curl_cv_in_addr_t_equiv="$t"
1348 if test "x$curl_cv_in_addr_t_equiv" = x; then
1349 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1352 AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
1353 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1354 [type to use in place of in_addr_t if not defined])],
1357 #ifdef HAVE_WINDOWS_H
1358 #ifndef WIN32_LEAN_AND_MEAN
1359 #define WIN32_LEAN_AND_MEAN
1361 #include <windows.h>
1362 #ifdef HAVE_WINSOCK2_H
1363 #include <winsock2.h>
1365 #ifdef HAVE_WINSOCK_H
1366 #include <winsock.h>
1370 #ifdef HAVE_SYS_TYPES_H
1371 #include <sys/types.h>
1373 #ifdef HAVE_SYS_SOCKET_H
1374 #include <sys/socket.h>
1376 #ifdef HAVE_NETINET_IN_H
1377 #include <netinet/in.h>
1379 #ifdef HAVE_ARPA_INET_H
1380 #include <arpa/inet.h>
1383 ]) dnl AC_CHECK_TYPE
1386 dnl ************************************************************
1387 dnl check for "localhost", if it doesn't exist, we can't do the
1388 dnl gethostbyname_r tests!
1391 AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[
1392 AC_MSG_CHECKING([if "localhost" resolves])
1395 #include <sys/types.h>
1401 h = gethostbyname("localhost");
1402 exit (h == NULL ? 1 : 0); }],[
1403 AC_MSG_RESULT(yes)],[
1405 AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
1411 dnl ************************************************************
1412 dnl check for working getaddrinfo() that works with AI_NUMERICHOST
1414 AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
1415 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
1418 #include <sys/types.h>
1419 #include <sys/socket.h>
1423 struct addrinfo hints, *ai;
1426 memset(&hints, 0, sizeof(hints));
1427 hints.ai_flags = AI_NUMERICHOST;
1428 hints.ai_family = AF_UNSPEC;
1429 hints.ai_socktype = SOCK_STREAM;
1430 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
1437 ac_cv_working_getaddrinfo="yes"
1439 ac_cv_working_getaddrinfo="no"
1441 ac_cv_working_getaddrinfo="yes"
1443 if test "$ac_cv_working_getaddrinfo" = "yes"; then
1444 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
1445 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
1448 AC_SUBST(IPV6_ENABLED)
1453 AC_DEFUN([CURL_CHECK_LOCALTIME_R],
1455 dnl check for localtime_r
1456 AC_CHECK_FUNCS(localtime_r,[
1457 AC_MSG_CHECKING(whether localtime_r is declared)
1458 AC_EGREP_CPP(localtime_r,[
1459 #include <time.h>],[
1460 AC_MSG_RESULT(yes)],[
1462 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
1463 AC_EGREP_CPP(localtime_r,[
1465 #include <time.h>],[
1466 AC_DEFINE(NEED_REENTRANT)
1467 AC_MSG_RESULT(yes)],
1468 AC_MSG_RESULT(no))])])
1472 dnl This function checks for strerror_r(). If it isn't found at first, it
1473 dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
1474 dnl in order to find this function.
1476 dnl If the function is found, it will then proceed to check how the function
1477 dnl actually works: glibc-style or POSIX-style.
1480 dnl char *strerror_r(int errnum, char *buf, size_t n);
1482 dnl What this one does is to return the error string (no surprises there),
1483 dnl but it doesn't usually copy anything into buf! The 'buf' and 'n'
1484 dnl parameters are only meant as an optional working area, in case strerror_r
1485 dnl needs it. A quick test on a few systems shows that it's generally not
1489 dnl int strerror_r(int errnum, char *buf, size_t n);
1491 AC_DEFUN([CURL_CHECK_STRERROR_R],
1493 AC_CHECK_FUNCS(strerror_r)
1495 if test "x$ac_cv_func_strerror_r" = "xyes"; then
1497 AC_MSG_CHECKING(whether strerror_r is declared)
1498 AC_EGREP_CPP(strerror_r,[
1499 #include <string.h>],[
1500 AC_MSG_RESULT(yes)],[
1502 AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
1503 AC_EGREP_CPP(strerror_r,[
1505 #include <string.h>],[
1506 CPPFLAGS="-D_REENTRANT $CPPFLAGS"
1507 AC_MSG_RESULT(yes)],
1509 AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
1510 ) dnl with _THREAD_SAFE
1511 ]) dnl plain cpp for it
1513 dnl determine if this strerror_r() is glibc or POSIX
1514 AC_MSG_CHECKING([for a glibc strerror_r API])
1520 char buffer[1024]; /* big enough to play with */
1522 strerror_r(EACCES, buffer, sizeof(buffer));
1523 /* this should've returned a string */
1524 if(!string || !string[0])
1529 GLIBC_STRERROR_R="1"
1530 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
1531 AC_MSG_RESULT([yes]),
1532 AC_MSG_RESULT([no]),
1534 dnl Use an inferior method of strerror_r detection while cross-compiling
1536 #include <features.h>
1541 dnl looks like glibc, so assume a glibc-style strerror_r()
1542 GLIBC_STRERROR_R="1"
1543 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
1544 AC_MSG_RESULT([yes]),
1545 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
1546 ) dnl while cross-compiling
1549 if test -z "$GLIBC_STRERROR_R"; then
1551 AC_MSG_CHECKING([for a POSIX strerror_r API])
1557 char buffer[1024]; /* big enough to play with */
1559 strerror_r(EACCES, buffer, sizeof(buffer));
1560 /* This should've returned zero, and written an error string in the
1562 if(!buffer[0] || error)
1567 AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
1568 AC_MSG_RESULT([yes]),
1569 AC_MSG_RESULT([no]) ,
1570 dnl cross-compiling!
1571 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
1574 fi dnl if not using glibc API
1576 fi dnl we have a strerror_r
1580 AC_DEFUN([CURL_CHECK_INET_NTOA_R],
1582 dnl determine if function definition for inet_ntoa_r exists.
1583 AC_CHECK_FUNCS(inet_ntoa_r,[
1584 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
1585 AC_EGREP_CPP(inet_ntoa_r,[
1586 #include <arpa/inet.h>],[
1587 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
1588 AC_MSG_RESULT(yes)],[
1590 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
1591 AC_EGREP_CPP(inet_ntoa_r,[
1593 #include <arpa/inet.h>],[
1594 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
1595 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT defined])
1596 AC_MSG_RESULT(yes)],
1597 AC_MSG_RESULT(no))])])
1600 AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R],
1602 dnl check for number of arguments to gethostbyaddr_r. it might take
1603 dnl either 5, 7, or 8 arguments.
1604 AC_CHECK_FUNCS(gethostbyaddr_r,[
1605 AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
1607 #include <sys/types.h>
1608 #include <netdb.h>],[
1613 struct hostent_data hdata;
1615 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
1617 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
1618 ac_cv_gethostbyaddr_args=5],[
1620 AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
1623 #include <sys/types.h>
1624 #include <netdb.h>],[
1629 struct hostent_data hdata;
1631 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
1633 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
1634 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
1635 ac_cv_gethostbyaddr_args=5],[
1637 AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
1639 #include <sys/types.h>
1640 #include <netdb.h>],[
1647 struct hostent * hp;
1649 hp = gethostbyaddr_r(address, length, type, &h,
1650 buffer, 8192, &h_errnop);],[
1652 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args] )
1653 ac_cv_gethostbyaddr_args=7],[
1655 AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
1657 #include <sys/types.h>
1658 #include <netdb.h>],[
1665 struct hostent * hp;
1668 rc = gethostbyaddr_r(address, length, type, &h,
1669 buffer, 8192, &hp, &h_errnop);],[
1671 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
1672 ac_cv_gethostbyaddr_args=8],[
1674 have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
1677 AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R],
1679 dnl check for number of arguments to gethostbyname_r. it might take
1680 dnl either 3, 5, or 6 arguments.
1681 AC_CHECK_FUNCS(gethostbyname_r,[
1682 AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
1685 #include <sys/types.h>
1688 #define NULL (void *)0
1691 gethostbyname_r(const char *, struct hostent *, struct hostent_data *);],[
1692 struct hostent_data data;
1693 gethostbyname_r(NULL, NULL, NULL);],[
1695 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
1696 ac_cv_gethostbyname_args=3],[
1698 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
1703 #include <sys/types.h>
1706 #define NULL (void *)0
1709 gethostbyname_r(const char *,struct hostent *, struct hostent_data *);],[
1710 struct hostent_data data;
1711 gethostbyname_r(NULL, NULL, NULL);],[
1713 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
1714 AC_DEFINE(NEED_REENTRANT, 1, [needs REENTRANT])
1715 ac_cv_gethostbyname_args=3],[
1717 AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
1719 #include <sys/types.h>
1722 #define NULL (void *)0
1725 gethostbyname_r(const char *, struct hostent *, char *, int, int *);],[
1726 gethostbyname_r(NULL, NULL, NULL, 0, NULL);],[
1728 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
1729 ac_cv_gethostbyname_args=5],[
1731 AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
1733 #include <sys/types.h>
1736 #define NULL (void *)0
1739 gethostbyname_r(const char *, struct hostent *, char *, size_t,
1740 struct hostent **, int *);],[
1741 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);],[
1743 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
1744 ac_cv_gethostbyname_args=6],[
1746 have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
1747 [ac_cv_gethostbyname_args=0])],
1748 [ac_cv_gethostbyname_args=0])],
1749 [ac_cv_gethostbyname_args=0])],
1750 [ac_cv_gethostbyname_args=0])])
1752 if test "$ac_cv_func_gethostbyname_r" = "yes"; then
1753 if test "$ac_cv_gethostbyname_args" = "0"; then
1754 dnl there's a gethostbyname_r() function, but we don't know how
1755 dnl many arguments it wants!
1756 AC_MSG_ERROR([couldn't figure out how to use gethostbyname_r()])
1762 dnl **********************************************************************
1763 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
1765 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
1766 dnl sets the $ICC variable to "yes" or "no"
1767 dnl **********************************************************************
1768 AC_DEFUN([CURL_DETECT_ICC],
1771 AC_MSG_CHECKING([for icc in use])
1772 if test "$GCC" = "yes"; then
1773 dnl check if this is icc acting as gcc in disguise
1774 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
1775 dnl action if the text is found, this it has not been replaced by the
1778 dnl the text was not found, it was replaced by the cpp
1780 AC_MSG_RESULT([yes])
1784 if test "$ICC" = "no"; then
1790 dnl We create a function for detecting which compiler we use and then set as
1791 dnl pendantic compiler options as possible for that particular compiler. The
1792 dnl options are only used for debug-builds.
1794 AC_DEFUN([CURL_CC_DEBUG_OPTS],
1796 if test "z$ICC" = "z"; then
1800 if test "$GCC" = "yes"; then
1802 dnl figure out gcc version!
1803 AC_MSG_CHECKING([gcc version])
1804 gccver=`$CC -dumpversion`
1805 num1=`echo $gccver | cut -d . -f1`
1806 num2=`echo $gccver | cut -d . -f2`
1807 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
1808 AC_MSG_RESULT($gccver)
1810 if test "$ICC" = "yes"; then
1811 dnl this is icc, not gcc.
1813 dnl ICC warnings we ignore:
1814 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
1815 dnl "invalid format string conversion"
1816 dnl * 279 warns on static conditions in while expressions
1817 dnl * 981 warns on "operands are evaluated in unspecified order"
1818 dnl * 1418 "external definition with no prior declaration"
1819 dnl * 1419 warns on "external declaration in primary source file"
1820 dnl which we know and do on purpose.
1822 WARN="-wd279,269,981,1418,1419"
1824 if test "$gccnum" -gt "600"; then
1825 dnl icc 6.0 and older doesn't have the -Wall flag
1829 dnl this is a set of options we believe *ALL* gcc versions support:
1830 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
1832 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
1834 if test "$gccnum" -ge "207"; then
1835 dnl gcc 2.7 or later
1836 WARN="$WARN -Wmissing-declarations"
1839 if test "$gccnum" -gt "295"; then
1840 dnl only if the compiler is newer than 2.95 since we got lots of
1841 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
1842 dnl gcc 2.95.4 on FreeBSD 4.9!
1843 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
1846 if test "$gccnum" -ge "296"; then
1847 dnl gcc 2.96 or later
1848 WARN="$WARN -Wfloat-equal"
1851 if test "$gccnum" -gt "296"; then
1852 dnl this option does not exist in 2.96
1853 WARN="$WARN -Wno-format-nonliteral"
1856 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1857 dnl on i686-Linux as it gives us heaps with false positives.
1858 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
1859 dnl over making it unusable for generic purposes. Let's not use it.
1861 if test "$gccnum" -ge "303"; then
1862 dnl gcc 3.3 and later
1863 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
1866 if test "$gccnum" -ge "304"; then
1867 # try these on gcc 3.4
1868 WARN="$WARN -Wdeclaration-after-statement"
1871 for flag in $CPPFLAGS; do
1874 dnl Include path, provide a -isystem option for the same dir
1875 dnl to prevent warnings in those dirs. The -isystem was not very
1876 dnl reliable on earlier gcc versions.
1877 add=`echo $flag | sed 's/^-I/-isystem /g'`
1885 CFLAGS="$CFLAGS $WARN"
1887 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
1891 AC_MSG_NOTICE([Added no extra compiler options])
1895 dnl strip off optimizer flags
1897 for flag in $CFLAGS; do
1900 dnl echo "cut off $flag"
1903 NEWFLAGS="$NEWFLAGS $flag"
1909 ]) dnl end of AC_DEFUN()
1911 # This is only a temporary fix. This macro is here to replace the broken one
1912 # delivered by the automake project (including the 1.9.6 release). As soon as
1913 # they ship a working version we SHOULD remove this work-around.
1915 AC_DEFUN([AM_MISSING_HAS_RUN],
1916 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
1917 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
1918 # Use eval to expand $SHELL
1919 if eval "$MISSING --run true"; then
1920 am_missing_run="$MISSING --run "
1923 AC_MSG_WARN([`missing' script is too old or missing])
1928 dnl CURL_VERIFY_RUNTIMELIBS
1929 dnl -------------------------------------------------
1930 dnl Verify that the shared libs found so far can be used when running
1931 dnl programs, since otherwise the situation will create odd configure errors
1932 dnl that are misleading people.
1934 dnl Make sure this test is run BEFORE the first test in the script that
1935 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
1936 dnl macro. It must also run AFTER all lib-checking macros are complete.
1938 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
1940 dnl this test is of course not sensible if we are cross-compiling!
1941 if test "x$cross_compiling" != xyes; then
1943 dnl just run a program to verify that the libs checked for previous to this
1944 dnl point also is available run-time!
1945 AC_MSG_CHECKING([run-time libs availability])
1952 AC_MSG_RESULT([fine]),
1953 AC_MSG_RESULT([failed])
1954 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
1957 dnl if this test fails, configure has already stopped
1962 dnl CURL_CHECK_VARIADIC_MACROS
1963 dnl -------------------------------------------------
1964 dnl Check compiler support of variadic macros
1966 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
1967 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
1968 [curl_cv_variadic_macros_c99], [
1971 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
1972 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
1973 int fun3(int arg1, int arg2, int arg3);
1974 int fun2(int arg1, int arg2);
1975 int fun3(int arg1, int arg2, int arg3)
1976 { return arg1 + arg2 + arg3; }
1977 int fun2(int arg1, int arg2)
1978 { return arg1 + arg2; }
1980 int res3 = c99_vmacro3(1, 2, 3);
1981 int res2 = c99_vmacro2(1, 2);
1984 curl_cv_variadic_macros_c99="yes"
1986 curl_cv_variadic_macros_c99="no"
1989 case "$curl_cv_variadic_macros_c99" in
1991 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
1992 [Define to 1 if compiler supports C99 variadic macro style.])
1995 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
1996 [curl_cv_variadic_macros_gcc], [
1999 #define gcc_vmacro3(first, args...) fun3(first, args)
2000 #define gcc_vmacro2(first, args...) fun2(first, args)
2001 int fun3(int arg1, int arg2, int arg3);
2002 int fun2(int arg1, int arg2);
2003 int fun3(int arg1, int arg2, int arg3)
2004 { return arg1 + arg2 + arg3; }
2005 int fun2(int arg1, int arg2)
2006 { return arg1 + arg2; }
2008 int res3 = gcc_vmacro3(1, 2, 3);
2009 int res2 = gcc_vmacro2(1, 2);
2012 curl_cv_variadic_macros_gcc="yes"
2014 curl_cv_variadic_macros_gcc="no"
2017 case "$curl_cv_variadic_macros_gcc" in
2019 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2020 [Define to 1 if compiler supports old gcc variadic macro style.])
2026 dnl CURL_CHECK_NATIVE_WINDOWS
2027 dnl -------------------------------------------------
2028 dnl Check if building a native Windows target
2030 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
2031 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
2032 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
2033 if test "$ac_cv_header_windows_h" = "no"; then
2034 ac_cv_native_windows="no"
2042 Not a native Windows build target.
2046 ac_cv_native_windows="yes"
2048 ac_cv_native_windows="no"
2052 case "$ac_cv_native_windows" in
2054 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
2055 [Define to 1 if you are building a native Windows target.])