1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2008, 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
39 #if defined(__CYGWIN__) || defined(__CEGCC__)
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_NATIVE_WINDOWS
63 dnl -------------------------------------------------
64 dnl Check if building a native Windows target
66 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
67 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
68 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
69 if test "$ac_cv_header_windows_h" = "no"; then
70 ac_cv_native_windows="no"
75 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
76 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
79 Not a native Windows build target.
83 ac_cv_native_windows="yes"
85 ac_cv_native_windows="no"
89 case "$ac_cv_native_windows" in
91 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
92 [Define to 1 if you are building a native Windows target.])
98 dnl CURL_CHECK_HEADER_WINSOCK
99 dnl -------------------------------------------------
100 dnl Check for compilable and valid winsock.h header
102 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
103 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
104 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
108 #ifndef WIN32_LEAN_AND_MEAN
109 #define WIN32_LEAN_AND_MEAN
114 #if defined(__CYGWIN__) || defined(__CEGCC__)
115 HAVE_WINSOCK_H shall not be defined.
117 int dummy=WSACleanup();
121 ac_cv_header_winsock_h="yes"
123 ac_cv_header_winsock_h="no"
126 case "$ac_cv_header_winsock_h" in
128 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
129 [Define to 1 if you have the winsock.h header file.])
135 dnl CURL_CHECK_HEADER_WINSOCK2
136 dnl -------------------------------------------------
137 dnl Check for compilable and valid winsock2.h header
139 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
140 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
141 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
145 #ifndef WIN32_LEAN_AND_MEAN
146 #define WIN32_LEAN_AND_MEAN
149 #include <winsock2.h>
151 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
152 HAVE_WINSOCK2_H shall not be defined.
154 int dummy=2*IPPROTO_ESP;
158 ac_cv_header_winsock2_h="yes"
160 ac_cv_header_winsock2_h="no"
163 case "$ac_cv_header_winsock2_h" in
165 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
166 [Define to 1 if you have the winsock2.h header file.])
172 dnl CURL_CHECK_HEADER_WS2TCPIP
173 dnl -------------------------------------------------
174 dnl Check for compilable and valid ws2tcpip.h header
176 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
177 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
178 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
182 #ifndef WIN32_LEAN_AND_MEAN
183 #define WIN32_LEAN_AND_MEAN
186 #include <winsock2.h>
187 #include <ws2tcpip.h>
189 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
190 HAVE_WS2TCPIP_H shall not be defined.
192 int dummy=2*IP_PKTINFO;
196 ac_cv_header_ws2tcpip_h="yes"
198 ac_cv_header_ws2tcpip_h="no"
201 case "$ac_cv_header_ws2tcpip_h" in
203 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
204 [Define to 1 if you have the ws2tcpip.h header file.])
210 dnl CURL_CHECK_HEADER_WINLDAP
211 dnl -------------------------------------------------
212 dnl Check for compilable and valid winldap.h header
214 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
215 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
216 AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
220 #ifdef HAVE_WINDOWS_H
221 #ifndef WIN32_LEAN_AND_MEAN
222 #define WIN32_LEAN_AND_MEAN
228 #if defined(__CYGWIN__) || defined(__CEGCC__)
229 HAVE_WINLDAP_H shall not be defined.
231 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
232 ULONG res = ldap_unbind(ldp);
236 ac_cv_header_winldap_h="yes"
238 ac_cv_header_winldap_h="no"
241 case "$ac_cv_header_winldap_h" in
243 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
244 [Define to 1 if you have the winldap.h header file.])
250 dnl CURL_CHECK_HEADER_WINBER
251 dnl -------------------------------------------------
252 dnl Check for compilable and valid winber.h header
254 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
255 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
256 AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
260 #ifdef HAVE_WINDOWS_H
261 #ifndef WIN32_LEAN_AND_MEAN
262 #define WIN32_LEAN_AND_MEAN
269 #if defined(__CYGWIN__) || defined(__CEGCC__)
270 HAVE_WINBER_H shall not be defined.
273 BerElement *bep = ber_init(bvp);
278 ac_cv_header_winber_h="yes"
280 ac_cv_header_winber_h="no"
283 case "$ac_cv_header_winber_h" in
285 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
286 [Define to 1 if you have the winber.h header file.])
292 dnl CURL_CHECK_HEADER_LBER
293 dnl -------------------------------------------------
294 dnl Check for compilable and valid lber.h header,
295 dnl and check if it is needed even with ldap.h
297 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
298 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
299 AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
303 #ifdef HAVE_WINDOWS_H
304 #ifndef WIN32_LEAN_AND_MEAN
305 #define WIN32_LEAN_AND_MEAN
309 #ifdef HAVE_SYS_TYPES_H
310 #include <sys/types.h>
314 #define NULL (void *)0
318 BerValue *bvp = NULL;
319 BerElement *bep = ber_init(bvp);
323 ac_cv_header_lber_h="yes"
325 ac_cv_header_lber_h="no"
328 if test "$ac_cv_header_lber_h" = "yes"; then
329 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
330 [Define to 1 if you have the lber.h header file.])
335 #ifdef HAVE_WINDOWS_H
336 #ifndef WIN32_LEAN_AND_MEAN
337 #define WIN32_LEAN_AND_MEAN
341 #ifdef HAVE_SYS_TYPES_H
342 #include <sys/types.h>
346 #define NULL (void *)0
348 #ifndef LDAP_DEPRECATED
349 #define LDAP_DEPRECATED 1
353 BerValue *bvp = NULL;
354 BerElement *bep = ber_init(bvp);
358 curl_cv_need_header_lber_h="no"
360 curl_cv_need_header_lber_h="yes"
363 case "$curl_cv_need_header_lber_h" in
365 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
366 [Define to 1 if you need the lber.h header file even with ldap.h])
373 dnl CURL_CHECK_HEADER_LDAP
374 dnl -------------------------------------------------
375 dnl Check for compilable and valid ldap.h header
377 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
378 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
379 AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
383 #ifdef HAVE_WINDOWS_H
384 #ifndef WIN32_LEAN_AND_MEAN
385 #define WIN32_LEAN_AND_MEAN
389 #ifdef HAVE_SYS_TYPES_H
390 #include <sys/types.h>
393 #ifndef LDAP_DEPRECATED
394 #define LDAP_DEPRECATED 1
401 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
402 int res = ldap_unbind(ldp);
405 ac_cv_header_ldap_h="yes"
407 ac_cv_header_ldap_h="no"
410 case "$ac_cv_header_ldap_h" in
412 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
413 [Define to 1 if you have the ldap.h header file.])
419 dnl CURL_CHECK_HEADER_LDAP_SSL
420 dnl -------------------------------------------------
421 dnl Check for compilable and valid ldap_ssl.h header
423 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
424 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
425 AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
429 #ifdef HAVE_WINDOWS_H
430 #ifndef WIN32_LEAN_AND_MEAN
431 #define WIN32_LEAN_AND_MEAN
435 #ifdef HAVE_SYS_TYPES_H
436 #include <sys/types.h>
439 #ifndef LDAP_DEPRECATED
440 #define LDAP_DEPRECATED 1
448 #include <ldap_ssl.h>
450 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
453 ac_cv_header_ldap_ssl_h="yes"
455 ac_cv_header_ldap_ssl_h="no"
458 case "$ac_cv_header_ldap_ssl_h" in
460 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
461 [Define to 1 if you have the ldap_ssl.h header file.])
467 dnl CURL_CHECK_HEADER_LDAPSSL
468 dnl -------------------------------------------------
469 dnl Check for compilable and valid ldapssl.h header
471 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
472 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
473 AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
477 #ifdef HAVE_WINDOWS_H
478 #ifndef WIN32_LEAN_AND_MEAN
479 #define WIN32_LEAN_AND_MEAN
483 #ifdef HAVE_SYS_TYPES_H
484 #include <sys/types.h>
488 #define NULL (void *)0
490 #ifndef LDAP_DEPRECATED
491 #define LDAP_DEPRECATED 1
501 char *cert_label = NULL;
502 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
505 ac_cv_header_ldapssl_h="yes"
507 ac_cv_header_ldapssl_h="no"
510 case "$ac_cv_header_ldapssl_h" in
512 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
513 [Define to 1 if you have the ldapssl.h header file.])
519 dnl CURL_CHECK_LIBS_WINLDAP
520 dnl -------------------------------------------------
521 dnl Check for libraries needed for WINLDAP support,
522 dnl and prepended to LIBS any needed libraries.
523 dnl This macro can take an optional parameter with a
524 dnl white space separated list of libraries to check
525 dnl before the WINLDAP default ones.
527 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
528 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
530 AC_MSG_CHECKING([for WINLDAP libraries])
544 if test -z "$u_libs"; then
547 u_libs="$u_libs $l_lib"
552 curl_cv_save_LIBS="$LIBS"
553 curl_cv_ldap_LIBS="unknown"
555 for x_nlibs in '' "$u_libs" \
557 if test "$curl_cv_ldap_LIBS" = "unknown"; then
558 if test -z "$x_nlibs"; then
559 LIBS="$curl_cv_save_LIBS"
561 LIBS="$x_nlibs $curl_cv_save_LIBS"
566 #ifdef HAVE_WINDOWS_H
567 #ifndef WIN32_LEAN_AND_MEAN
568 #define WIN32_LEAN_AND_MEAN
571 #ifdef HAVE_WINLDAP_H
580 BerElement *bep = ber_init(bvp);
581 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
582 ULONG res = ldap_unbind(ldp);
586 curl_cv_ldap_LIBS="$x_nlibs"
591 LIBS="$curl_cv_save_LIBS"
593 case X-"$curl_cv_ldap_LIBS" in
595 AC_MSG_RESULT([cannot find WINLDAP libraries])
598 AC_MSG_RESULT([no additional lib required])
601 if test -z "$curl_cv_save_LIBS"; then
602 LIBS="$curl_cv_ldap_LIBS"
604 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
606 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
613 dnl CURL_CHECK_LIBS_LDAP
614 dnl -------------------------------------------------
615 dnl Check for libraries needed for LDAP support,
616 dnl and prepended to LIBS any needed libraries.
617 dnl This macro can take an optional parameter with a
618 dnl white space separated list of libraries to check
619 dnl before the default ones.
621 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
622 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
624 AC_MSG_CHECKING([for LDAP libraries])
638 if test -z "$u_libs"; then
641 u_libs="$u_libs $l_lib"
646 curl_cv_save_LIBS="$LIBS"
647 curl_cv_ldap_LIBS="unknown"
649 for x_nlibs in '' "$u_libs" \
653 '-lldapssl -lldapx -lldapsdk' \
654 '-lldapsdk -lldapx -lldapssl' ; do
655 if test "$curl_cv_ldap_LIBS" = "unknown"; then
656 if test -z "$x_nlibs"; then
657 LIBS="$curl_cv_save_LIBS"
659 LIBS="$x_nlibs $curl_cv_save_LIBS"
664 #ifdef HAVE_WINDOWS_H
665 #ifndef WIN32_LEAN_AND_MEAN
666 #define WIN32_LEAN_AND_MEAN
670 #ifdef HAVE_SYS_TYPES_H
671 #include <sys/types.h>
675 #define NULL (void *)0
677 #ifndef LDAP_DEPRECATED
678 #define LDAP_DEPRECATED 1
687 BerValue *bvp = NULL;
688 BerElement *bep = ber_init(bvp);
689 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
690 int res = ldap_unbind(ldp);
694 curl_cv_ldap_LIBS="$x_nlibs"
699 LIBS="$curl_cv_save_LIBS"
701 case X-"$curl_cv_ldap_LIBS" in
703 AC_MSG_RESULT([cannot find LDAP libraries])
706 AC_MSG_RESULT([no additional lib required])
709 if test -z "$curl_cv_save_LIBS"; then
710 LIBS="$curl_cv_ldap_LIBS"
712 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
714 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
721 dnl CURL_CHECK_HEADER_MALLOC
722 dnl -------------------------------------------------
723 dnl Check for compilable and valid malloc.h header,
724 dnl and check if it is needed even with stdlib.h
726 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
727 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
732 void *p = malloc(10);
733 void *q = calloc(10,10);
738 ac_cv_header_malloc_h="yes"
740 ac_cv_header_malloc_h="no"
743 if test "$ac_cv_header_malloc_h" = "yes"; then
744 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
745 [Define to 1 if you have the malloc.h header file.])
751 void *p = malloc(10);
752 void *q = calloc(10,10);
757 curl_cv_need_header_malloc_h="no"
759 curl_cv_need_header_malloc_h="yes"
762 case "$curl_cv_need_header_malloc_h" in
764 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
765 [Define to 1 if you need the malloc.h header file even with stdlib.h])
772 dnl CURL_CHECK_TYPE_SOCKLEN_T
773 dnl -------------------------------------------------
774 dnl Check for existing socklen_t type, and provide
775 dnl an equivalent type if socklen_t not available
777 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
778 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
779 AC_CHECK_TYPE([socklen_t], ,[
780 dnl socklen_t not available
781 AC_CACHE_CHECK([for socklen_t equivalent],
782 [curl_cv_socklen_t_equiv], [
783 curl_cv_socklen_t_equiv="unknown"
784 for arg1 in 'int' 'SOCKET'; do
785 for arg2 in "struct sockaddr" void; do
786 for t in int size_t unsigned long "unsigned long"; do
787 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
791 #ifdef HAVE_WINDOWS_H
792 #ifndef WIN32_LEAN_AND_MEAN
793 #define WIN32_LEAN_AND_MEAN
796 #ifdef HAVE_WINSOCK2_H
797 #include <winsock2.h>
799 #ifdef HAVE_WINSOCK_H
803 #define GETPEERNCALLCONV PASCAL
805 #ifdef HAVE_SYS_TYPES_H
806 #include <sys/types.h>
808 #ifdef HAVE_SYS_SOCKET_H
809 #include <sys/socket.h>
811 #define GETPEERNCALLCONV
813 extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
816 getpeername(0,0,&len);
819 curl_cv_socklen_t_equiv="$t"
826 case "$curl_cv_socklen_t_equiv" in
828 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
831 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
832 [Type to use in place of socklen_t when system does not provide it.])
837 #ifdef HAVE_WINDOWS_H
838 #ifndef WIN32_LEAN_AND_MEAN
839 #define WIN32_LEAN_AND_MEAN
842 #ifdef HAVE_WINSOCK2_H
843 #include <winsock2.h>
844 #ifdef HAVE_WS2TCPIP_H
845 #include <ws2tcpip.h>
849 #ifdef HAVE_SYS_TYPES_H
850 #include <sys/types.h>
852 #ifdef HAVE_SYS_SOCKET_H
853 #include <sys/socket.h>
860 dnl CURL_CHECK_FUNC_GETNAMEINFO
861 dnl -------------------------------------------------
862 dnl Test if the getnameinfo function is available,
863 dnl and check the types of five of its arguments.
864 dnl If the function succeeds HAVE_GETNAMEINFO will be
865 dnl defined, defining the types of the arguments in
866 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
867 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
868 dnl and also defining the type qualifier of first
869 dnl argument in GETNAMEINFO_QUAL_ARG1.
871 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
872 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
873 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
874 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
876 AC_MSG_CHECKING([for getnameinfo])
878 AC_LANG_FUNC_LINK_TRY([getnameinfo])
881 curl_cv_getnameinfo="yes"
884 curl_cv_getnameinfo="no"
887 if test "$curl_cv_getnameinfo" != "yes"; then
888 AC_MSG_CHECKING([deeper for getnameinfo])
896 curl_cv_getnameinfo="yes"
898 AC_MSG_RESULT([but still no])
899 curl_cv_getnameinfo="no"
903 if test "$curl_cv_getnameinfo" != "yes"; then
904 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
908 #ifdef HAVE_WINDOWS_H
909 #ifndef WIN32_LEAN_AND_MEAN
910 #define WIN32_LEAN_AND_MEAN
913 #ifdef HAVE_WINSOCK2_H
914 #include <winsock2.h>
915 #ifdef HAVE_WS2TCPIP_H
916 #include <ws2tcpip.h>
920 #ifdef HAVE_SYS_TYPES_H
921 #include <sys/types.h>
923 #ifdef HAVE_SYS_SOCKET_H
924 #include <sys/socket.h>
931 getnameinfo(0, 0, 0, 0, 0, 0, 0);
935 curl_cv_getnameinfo="yes"
937 AC_MSG_RESULT([but still no])
938 curl_cv_getnameinfo="no"
942 if test "$curl_cv_getnameinfo" = "yes"; then
943 AC_CACHE_CHECK([types of arguments for getnameinfo],
944 [curl_cv_func_getnameinfo_args], [
945 curl_cv_func_getnameinfo_args="unknown"
946 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
947 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
948 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
949 for gni_arg7 in 'int' 'unsigned int'; do
950 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
954 #ifdef HAVE_WINDOWS_H
955 #ifndef WIN32_LEAN_AND_MEAN
956 #define WIN32_LEAN_AND_MEAN
958 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
960 #define _WIN32_WINNT 0x0501
963 #ifdef HAVE_WINSOCK2_H
964 #include <winsock2.h>
965 #ifdef HAVE_WS2TCPIP_H
966 #include <ws2tcpip.h>
969 #define GNICALLCONV WSAAPI
971 #ifdef HAVE_SYS_TYPES_H
972 #include <sys/types.h>
974 #ifdef HAVE_SYS_SOCKET_H
975 #include <sys/socket.h>
982 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
988 $gni_arg46 hostlen=0;
989 $gni_arg46 servlen=0;
991 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
994 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
1002 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1003 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
1004 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1006 gni_prev_IFS=$IFS; IFS=','
1007 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1011 gni_qual_type_arg1=$[1]
1013 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1014 [Define to the type of arg 2 for getnameinfo.])
1015 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1016 [Define to the type of args 4 and 6 for getnameinfo.])
1017 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1018 [Define to the type of arg 7 for getnameinfo.])
1022 case $prev_sh_opts in
1030 case "$gni_qual_type_arg1" in
1033 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1037 gni_type_arg1=$gni_qual_type_arg1
1041 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1042 [Define to the type qualifier of arg 1 for getnameinfo.])
1043 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1044 [Define to the type of arg 1 for getnameinfo.])
1046 case $prev_sh_opts in
1054 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1055 [Define to 1 if you have the getnameinfo function.])
1056 ac_cv_func_getnameinfo="yes"
1062 dnl TYPE_SOCKADDR_STORAGE
1063 dnl -------------------------------------------------
1064 dnl Check for struct sockaddr_storage. Most IPv6-enabled
1065 dnl hosts have it, but AIX 4.3 is one known exception.
1067 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1069 AC_CHECK_TYPE([struct sockaddr_storage],
1070 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1071 [if struct sockaddr_storage is defined]), ,
1074 #ifdef HAVE_WINDOWS_H
1075 #ifndef WIN32_LEAN_AND_MEAN
1076 #define WIN32_LEAN_AND_MEAN
1078 #include <windows.h>
1079 #ifdef HAVE_WINSOCK2_H
1080 #include <winsock2.h>
1083 #ifdef HAVE_SYS_TYPES_H
1084 #include <sys/types.h>
1086 #ifdef HAVE_SYS_SOCKET_H
1087 #include <sys/socket.h>
1089 #ifdef HAVE_NETINET_IN_H
1090 #include <netinet/in.h>
1092 #ifdef HAVE_ARPA_INET_H
1093 #include <arpa/inet.h>
1100 dnl CURL_CHECK_NI_WITHSCOPEID
1101 dnl -------------------------------------------------
1102 dnl Check for working NI_WITHSCOPEID in getnameinfo()
1104 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1105 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1106 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1107 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1108 netdb.h netinet/in.h arpa/inet.h)
1110 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
1111 [ac_cv_working_ni_withscopeid], [
1117 #ifdef HAVE_SYS_TYPES_H
1118 #include <sys/types.h>
1120 #ifdef HAVE_SYS_SOCKET_H
1121 #include <sys/socket.h>
1126 #ifdef HAVE_NETINET_IN_H
1127 #include <netinet/in.h>
1129 #ifdef HAVE_ARPA_INET_H
1130 #include <arpa/inet.h>
1133 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1134 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1135 struct sockaddr_storage sa;
1137 unsigned char sa[256];
1139 char hostbuf[NI_MAXHOST];
1141 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1142 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1143 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1144 int fd = socket(AF_INET6, SOCK_STREAM, 0);
1147 return 1; /* Error creating socket */
1149 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1151 perror("getsockname()");
1152 return 2; /* Error retrieving socket name */
1154 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1156 printf("rc = %s\n", gai_strerror(rc));
1157 return 3; /* Error translating socket address */
1159 return 0; /* Ok, NI_WITHSCOPEID works */
1161 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1163 ]]) # AC_LANG_PROGRAM
1165 # Exit code == 0. Program worked.
1166 ac_cv_working_ni_withscopeid="yes"
1168 # Exit code != 0. Program failed.
1169 ac_cv_working_ni_withscopeid="no"
1171 # Program is not run when cross-compiling. So we assume
1172 # NI_WITHSCOPEID will work if we are able to compile it.
1175 #include <sys/types.h>
1176 #include <sys/socket.h>
1179 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1182 ac_cv_working_ni_withscopeid="yes"
1184 ac_cv_working_ni_withscopeid="no"
1185 ]) # AC_COMPILE_IFELSE
1188 case "$ac_cv_working_ni_withscopeid" in
1190 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1191 [Define to 1 if NI_WITHSCOPEID exists and works.])
1197 dnl CURL_CHECK_FUNC_RECV
1198 dnl -------------------------------------------------
1199 dnl Test if the socket recv() function is available,
1200 dnl and check its return type and the types of its
1201 dnl arguments. If the function succeeds HAVE_RECV
1202 dnl will be defined, defining the types of the arguments
1203 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1204 dnl and RECV_TYPE_ARG4, defining the type of the function
1205 dnl return value in RECV_TYPE_RETV.
1207 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1208 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1209 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1210 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1212 AC_MSG_CHECKING([for recv])
1216 #ifdef HAVE_WINDOWS_H
1217 #ifndef WIN32_LEAN_AND_MEAN
1218 #define WIN32_LEAN_AND_MEAN
1220 #include <windows.h>
1221 #ifdef HAVE_WINSOCK2_H
1222 #include <winsock2.h>
1224 #ifdef HAVE_WINSOCK_H
1225 #include <winsock.h>
1229 #ifdef HAVE_SYS_TYPES_H
1230 #include <sys/types.h>
1232 #ifdef HAVE_SYS_SOCKET_H
1233 #include <sys/socket.h>
1240 AC_MSG_RESULT([yes])
1247 if test "$curl_cv_recv" = "yes"; then
1248 AC_CACHE_CHECK([types of args and return type for recv],
1249 [curl_cv_func_recv_args], [
1250 curl_cv_func_recv_args="unknown"
1251 for recv_retv in 'int' 'ssize_t'; do
1252 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1253 for recv_arg2 in 'char *' 'void *'; do
1254 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1255 for recv_arg4 in 'int' 'unsigned int'; do
1256 if test "$curl_cv_func_recv_args" = "unknown"; then
1260 #ifdef HAVE_WINDOWS_H
1261 #ifndef WIN32_LEAN_AND_MEAN
1262 #define WIN32_LEAN_AND_MEAN
1264 #include <windows.h>
1265 #ifdef HAVE_WINSOCK2_H
1266 #include <winsock2.h>
1268 #ifdef HAVE_WINSOCK_H
1269 #include <winsock.h>
1272 #define RECVCALLCONV PASCAL
1274 #ifdef HAVE_SYS_TYPES_H
1275 #include <sys/types.h>
1277 #ifdef HAVE_SYS_SOCKET_H
1278 #include <sys/socket.h>
1280 #define RECVCALLCONV
1282 extern $recv_retv RECVCALLCONV
1283 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1289 $recv_retv res = recv(s, buf, len, flags);
1292 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1301 if test "$curl_cv_func_recv_args" = "unknown"; then
1302 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1304 recv_prev_IFS=$IFS; IFS=','
1305 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1309 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1310 [Define to the type of arg 1 for recv.])
1311 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1312 [Define to the type of arg 2 for recv.])
1313 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1314 [Define to the type of arg 3 for recv.])
1315 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1316 [Define to the type of arg 4 for recv.])
1317 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1318 [Define to the function return type for recv.])
1320 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1321 [Define to 1 if you have the recv function.])
1322 ac_cv_func_recv="yes"
1325 AC_MSG_ERROR([Unable to link function recv])
1330 dnl CURL_CHECK_FUNC_SEND
1331 dnl -------------------------------------------------
1332 dnl Test if the socket send() function is available,
1333 dnl and check its return type and the types of its
1334 dnl arguments. If the function succeeds HAVE_SEND
1335 dnl will be defined, defining the types of the arguments
1336 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1337 dnl and SEND_TYPE_ARG4, defining the type of the function
1338 dnl return value in SEND_TYPE_RETV, and also defining the
1339 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1341 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1342 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1343 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1344 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1346 AC_MSG_CHECKING([for send])
1350 #ifdef HAVE_WINDOWS_H
1351 #ifndef WIN32_LEAN_AND_MEAN
1352 #define WIN32_LEAN_AND_MEAN
1354 #include <windows.h>
1355 #ifdef HAVE_WINSOCK2_H
1356 #include <winsock2.h>
1358 #ifdef HAVE_WINSOCK_H
1359 #include <winsock.h>
1363 #ifdef HAVE_SYS_TYPES_H
1364 #include <sys/types.h>
1366 #ifdef HAVE_SYS_SOCKET_H
1367 #include <sys/socket.h>
1374 AC_MSG_RESULT([yes])
1381 if test "$curl_cv_send" = "yes"; then
1382 AC_CACHE_CHECK([types of args and return type for send],
1383 [curl_cv_func_send_args], [
1384 curl_cv_func_send_args="unknown"
1385 for send_retv in 'int' 'ssize_t'; do
1386 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1387 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1388 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1389 for send_arg4 in 'int' 'unsigned int'; do
1390 if test "$curl_cv_func_send_args" = "unknown"; then
1394 #ifdef HAVE_WINDOWS_H
1395 #ifndef WIN32_LEAN_AND_MEAN
1396 #define WIN32_LEAN_AND_MEAN
1398 #include <windows.h>
1399 #ifdef HAVE_WINSOCK2_H
1400 #include <winsock2.h>
1402 #ifdef HAVE_WINSOCK_H
1403 #include <winsock.h>
1406 #define SENDCALLCONV PASCAL
1408 #ifdef HAVE_SYS_TYPES_H
1409 #include <sys/types.h>
1411 #ifdef HAVE_SYS_SOCKET_H
1412 #include <sys/socket.h>
1414 #define SENDCALLCONV
1416 extern $send_retv SENDCALLCONV
1417 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1422 $send_retv res = send(s, 0, len, flags);
1425 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1434 if test "$curl_cv_func_send_args" = "unknown"; then
1435 AC_MSG_ERROR([Cannot find proper types to use for send args])
1437 send_prev_IFS=$IFS; IFS=','
1438 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1442 send_qual_type_arg2=$[2]
1444 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1445 [Define to the type of arg 1 for send.])
1446 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1447 [Define to the type of arg 3 for send.])
1448 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1449 [Define to the type of arg 4 for send.])
1450 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1451 [Define to the function return type for send.])
1455 case $prev_sh_opts in
1463 case "$send_qual_type_arg2" in
1465 send_qual_arg2=const
1466 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1470 send_type_arg2=$send_qual_type_arg2
1474 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1475 [Define to the type qualifier of arg 2 for send.])
1476 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1477 [Define to the type of arg 2 for send.])
1479 case $prev_sh_opts in
1487 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1488 [Define to 1 if you have the send function.])
1489 ac_cv_func_send="yes"
1492 AC_MSG_ERROR([Unable to link function send])
1497 dnl CURL_CHECK_MSG_NOSIGNAL
1498 dnl -------------------------------------------------
1499 dnl Check for MSG_NOSIGNAL
1501 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1502 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1503 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1507 #ifdef HAVE_WINDOWS_H
1508 #ifndef WIN32_LEAN_AND_MEAN
1509 #define WIN32_LEAN_AND_MEAN
1511 #include <windows.h>
1512 #ifdef HAVE_WINSOCK2_H
1513 #include <winsock2.h>
1515 #ifdef HAVE_WINSOCK_H
1516 #include <winsock.h>
1520 #ifdef HAVE_SYS_TYPES_H
1521 #include <sys/types.h>
1523 #ifdef HAVE_SYS_SOCKET_H
1524 #include <sys/socket.h>
1528 int flag=MSG_NOSIGNAL;
1531 ac_cv_msg_nosignal="yes"
1533 ac_cv_msg_nosignal="no"
1536 case "$ac_cv_msg_nosignal" in
1538 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1539 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1545 dnl CURL_CHECK_STRUCT_TIMEVAL
1546 dnl -------------------------------------------------
1547 dnl Check for timeval struct
1549 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1550 AC_REQUIRE([AC_HEADER_TIME])dnl
1551 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1552 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1553 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1554 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1558 #ifdef HAVE_WINDOWS_H
1559 #ifndef WIN32_LEAN_AND_MEAN
1560 #define WIN32_LEAN_AND_MEAN
1562 #include <windows.h>
1563 #ifdef HAVE_WINSOCK2_H
1564 #include <winsock2.h>
1566 #ifdef HAVE_WINSOCK_H
1567 #include <winsock.h>
1571 #ifdef HAVE_SYS_TYPES_H
1572 #include <sys/types.h>
1574 #ifdef HAVE_SYS_TIME_H
1575 #include <sys/time.h>
1576 #ifdef TIME_WITH_SYS_TIME
1590 ac_cv_struct_timeval="yes"
1592 ac_cv_struct_timeval="no"
1595 case "$ac_cv_struct_timeval" in
1597 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1598 [Define to 1 if you have the timeval struct.])
1604 dnl TYPE_SIG_ATOMIC_T
1605 dnl -------------------------------------------------
1606 dnl Check if the sig_atomic_t type is available, and
1607 dnl verify if it is already defined as volatile.
1609 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1610 AC_CHECK_HEADERS(signal.h)
1611 AC_CHECK_TYPE([sig_atomic_t],[
1612 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1613 [Define to 1 if sig_atomic_t is an available typedef.])
1615 #ifdef HAVE_SIGNAL_H
1619 case "$ac_cv_type_sig_atomic_t" in
1622 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1625 #ifdef HAVE_SIGNAL_H
1629 static volatile sig_atomic_t dummy = 0;
1633 ac_cv_sig_atomic_t_volatile="no"
1635 AC_MSG_RESULT([yes])
1636 ac_cv_sig_atomic_t_volatile="yes"
1639 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1640 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1641 [Define to 1 if sig_atomic_t is already defined as volatile.])
1648 dnl CURL_CHECK_NONBLOCKING_SOCKET
1649 dnl -------------------------------------------------
1650 dnl Check for how to set a socket to non-blocking state. There seems to exist
1651 dnl four known different ways, with the one used almost everywhere being POSIX
1652 dnl and XPG3, while the other different ways for different systems (old BSD,
1653 dnl Windows and Amiga).
1655 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1656 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1657 dnl to get caught in this script by using an excessive number of #ifdefs...
1659 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
1660 AC_MSG_CHECKING([non-blocking sockets style])
1665 /* headers for O_NONBLOCK test */
1666 #include <sys/types.h>
1670 #if defined(sun) || defined(__sun__) || \
1671 defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1672 # if defined(__SVR4) || defined(__srv4__)
1673 # define PLATFORM_SOLARIS
1675 # define PLATFORM_SUNOS4
1678 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
1679 # define PLATFORM_AIX_V3
1682 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1683 #error "O_NONBLOCK does not work on this platform"
1686 /* O_NONBLOCK source test */
1688 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1691 dnl the O_NONBLOCK test was fine
1692 nonblock="O_NONBLOCK"
1693 AC_DEFINE(HAVE_O_NONBLOCK, 1,
1694 [use O_NONBLOCK for non-blocking sockets])
1697 if test "$nonblock" = "unknown"; then
1700 /* headers for FIONBIO test */
1702 #include <stropts.h>
1704 /* FIONBIO source test (old-style unix) */
1706 int flags = ioctl(socket, FIONBIO, &flags);
1709 dnl FIONBIO test was good
1711 AC_DEFINE(HAVE_FIONBIO, 1,
1712 [use FIONBIO for non-blocking sockets])
1716 if test "$nonblock" = "unknown"; then
1719 /* headers for ioctlsocket test (Windows) */
1721 #ifdef HAVE_WINDOWS_H
1722 #ifndef WIN32_LEAN_AND_MEAN
1723 #define WIN32_LEAN_AND_MEAN
1725 #include <windows.h>
1726 #ifdef HAVE_WINSOCK2_H
1727 #include <winsock2.h>
1729 #ifdef HAVE_WINSOCK_H
1730 #include <winsock.h>
1735 /* ioctlsocket source code (Windows) */
1737 unsigned long flags = 0;
1738 sd = socket(0, 0, 0);
1739 ioctlsocket(sd, FIONBIO, &flags);
1742 dnl ioctlsocket test was good
1743 nonblock="ioctlsocket"
1744 AC_DEFINE(HAVE_IOCTLSOCKET, 1,
1745 [use ioctlsocket() for non-blocking sockets])
1749 if test "$nonblock" = "unknown"; then
1752 /* headers for IoctlSocket test (Amiga?) */
1753 #include <sys/ioctl.h>
1755 /* IoctlSocket source code (Amiga?) */
1757 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1760 dnl Ioctlsocket test was good
1761 nonblock="IoctlSocket"
1762 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
1763 [use Ioctlsocket() for non-blocking sockets])
1767 if test "$nonblock" = "unknown"; then
1770 /* headers for SO_NONBLOCK test (BeOS) */
1773 /* SO_NONBLOCK source code (BeOS) */
1776 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1779 dnl the SO_NONBLOCK test was good
1780 nonblock="SO_NONBLOCK"
1781 AC_DEFINE(HAVE_SO_NONBLOCK, 1,
1782 [use SO_NONBLOCK for non-blocking sockets])
1786 AC_MSG_RESULT($nonblock)
1788 if test "$nonblock" = "unknown"; then
1789 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
1790 [disabled non-blocking sockets])
1791 AC_MSG_WARN([non-block sockets disabled])
1797 dnl -------------------------------------------------
1798 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1799 dnl and a few other things.
1801 AC_DEFUN([TYPE_IN_ADDR_T], [
1802 AC_CHECK_TYPE([in_addr_t], ,[
1803 dnl in_addr_t not available
1804 AC_CACHE_CHECK([for in_addr_t equivalent],
1805 [curl_cv_in_addr_t_equiv], [
1806 curl_cv_in_addr_t_equiv="unknown"
1807 for t in "unsigned long" int size_t unsigned long; do
1808 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1812 #ifdef HAVE_WINDOWS_H
1813 #ifndef WIN32_LEAN_AND_MEAN
1814 #define WIN32_LEAN_AND_MEAN
1816 #include <windows.h>
1817 #ifdef HAVE_WINSOCK2_H
1818 #include <winsock2.h>
1820 #ifdef HAVE_WINSOCK_H
1821 #include <winsock.h>
1825 #ifdef HAVE_SYS_TYPES_H
1826 #include <sys/types.h>
1828 #ifdef HAVE_SYS_SOCKET_H
1829 #include <sys/socket.h>
1831 #ifdef HAVE_NETINET_IN_H
1832 #include <netinet/in.h>
1834 #ifdef HAVE_ARPA_INET_H
1835 #include <arpa/inet.h>
1839 $t data = inet_addr ("1.2.3.4");
1842 curl_cv_in_addr_t_equiv="$t"
1847 case "$curl_cv_in_addr_t_equiv" in
1849 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1852 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1853 [Type to use in place of in_addr_t when system does not provide it.])
1858 #ifdef HAVE_WINDOWS_H
1859 #ifndef WIN32_LEAN_AND_MEAN
1860 #define WIN32_LEAN_AND_MEAN
1862 #include <windows.h>
1863 #ifdef HAVE_WINSOCK2_H
1864 #include <winsock2.h>
1866 #ifdef HAVE_WINSOCK_H
1867 #include <winsock.h>
1871 #ifdef HAVE_SYS_TYPES_H
1872 #include <sys/types.h>
1874 #ifdef HAVE_SYS_SOCKET_H
1875 #include <sys/socket.h>
1877 #ifdef HAVE_NETINET_IN_H
1878 #include <netinet/in.h>
1880 #ifdef HAVE_ARPA_INET_H
1881 #include <arpa/inet.h>
1884 ]) dnl AC_CHECK_TYPE
1888 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1889 dnl -------------------------------------------------
1890 dnl Check if monotonic clock_gettime is available.
1892 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1893 AC_REQUIRE([AC_HEADER_TIME])dnl
1894 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1895 AC_MSG_CHECKING([for monotonic clock_gettime])
1898 #ifdef HAVE_SYS_TYPES_H
1899 #include <sys/types.h>
1901 #ifdef HAVE_SYS_TIME_H
1902 #include <sys/time.h>
1903 #ifdef TIME_WITH_SYS_TIME
1913 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1916 AC_MSG_RESULT([yes])
1917 ac_cv_func_clock_gettime="yes"
1920 ac_cv_func_clock_gettime="no"
1922 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally
1923 dnl postponed until library linking checks for clock_gettime pass.
1927 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1928 dnl -------------------------------------------------
1929 dnl If monotonic clock_gettime is available then,
1930 dnl check and prepended to LIBS any needed libraries.
1932 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1933 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1935 if test "$ac_cv_func_clock_gettime" = "yes"; then
1937 AC_MSG_CHECKING([for clock_gettime in libraries])
1939 curl_cv_save_LIBS="$LIBS"
1940 curl_cv_gclk_LIBS="unknown"
1942 for x_xlibs in '' '-lrt' '-lposix4' ; do
1943 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1944 if test -z "$x_xlibs"; then
1945 LIBS="$curl_cv_save_LIBS"
1947 LIBS="$x_xlibs $curl_cv_save_LIBS"
1951 #ifdef HAVE_SYS_TYPES_H
1952 #include <sys/types.h>
1954 #ifdef HAVE_SYS_TIME_H
1955 #include <sys/time.h>
1956 #ifdef TIME_WITH_SYS_TIME
1966 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1969 curl_cv_gclk_LIBS="$x_xlibs"
1974 LIBS="$curl_cv_save_LIBS"
1976 case X-"$curl_cv_gclk_LIBS" in
1978 AC_MSG_RESULT([cannot find clock_gettime])
1979 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1980 ac_cv_func_clock_gettime="no"
1983 AC_MSG_RESULT([no additional lib required])
1984 ac_cv_func_clock_gettime="yes"
1987 if test -z "$curl_cv_save_LIBS"; then
1988 LIBS="$curl_cv_gclk_LIBS"
1990 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1992 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1993 ac_cv_func_clock_gettime="yes"
1997 case "$ac_cv_func_clock_gettime" in
1999 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
2000 [Define to 1 if you have the clock_gettime function and monotonic timer.])
2009 dnl CURL_CHECK_FUNC_SELECT
2010 dnl -------------------------------------------------
2011 dnl Test if the socket select() function is available,
2012 dnl and check its return type and the types of its
2013 dnl arguments. If the function succeeds HAVE_SELECT
2014 dnl will be defined, defining the types of the
2015 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
2016 dnl and SELECT_TYPE_ARG5, defining the type of the
2017 dnl function return value in SELECT_TYPE_RETV, and
2018 dnl also defining the type qualifier of fifth argument
2019 dnl in SELECT_QUAL_ARG5.
2021 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
2022 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
2023 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
2025 AC_MSG_CHECKING([for select])
2029 #ifdef HAVE_WINDOWS_H
2030 #ifndef WIN32_LEAN_AND_MEAN
2031 #define WIN32_LEAN_AND_MEAN
2033 #include <windows.h>
2034 #ifdef HAVE_WINSOCK2_H
2035 #include <winsock2.h>
2037 #ifdef HAVE_WINSOCK_H
2038 #include <winsock.h>
2042 #ifdef HAVE_SYS_TYPES_H
2043 #include <sys/types.h>
2045 #ifdef HAVE_SYS_TIME_H
2046 #include <sys/time.h>
2047 #ifdef TIME_WITH_SYS_TIME
2055 #ifndef HAVE_WINDOWS_H
2056 #ifdef HAVE_SYS_SELECT_H
2057 #include <sys/select.h>
2059 #ifdef HAVE_SYS_SOCKET_H
2060 #include <sys/socket.h>
2064 select(0, 0, 0, 0, 0);
2067 AC_MSG_RESULT([yes])
2068 curl_cv_select="yes"
2074 if test "$curl_cv_select" = "yes"; then
2075 AC_CACHE_CHECK([types of args and return type for select],
2076 [curl_cv_func_select_args], [
2077 curl_cv_func_select_args="unknown"
2078 for sel_retv in 'int' 'ssize_t'; do
2079 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2080 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2081 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2082 if test "$curl_cv_func_select_args" = "unknown"; then
2086 #ifdef HAVE_WINDOWS_H
2087 #ifndef WIN32_LEAN_AND_MEAN
2088 #define WIN32_LEAN_AND_MEAN
2090 #include <windows.h>
2091 #ifdef HAVE_WINSOCK2_H
2092 #include <winsock2.h>
2094 #ifdef HAVE_WINSOCK_H
2095 #include <winsock.h>
2098 #define SELECTCALLCONV PASCAL
2100 #ifdef HAVE_SYS_TYPES_H
2101 #include <sys/types.h>
2103 #ifdef HAVE_SYS_TIME_H
2104 #include <sys/time.h>
2105 #ifdef TIME_WITH_SYS_TIME
2113 #ifndef HAVE_WINDOWS_H
2114 #ifdef HAVE_SYS_SELECT_H
2115 #include <sys/select.h>
2117 #ifdef HAVE_SYS_SOCKET_H
2118 #include <sys/socket.h>
2120 #define SELECTCALLCONV
2122 #ifndef HAVE_STRUCT_TIMEVAL
2128 extern $sel_retv SELECTCALLCONV select($sel_arg1,
2138 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2141 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2149 if test "$curl_cv_func_select_args" = "unknown"; then
2150 AC_MSG_WARN([Cannot find proper types to use for select args])
2151 AC_MSG_WARN([HAVE_SELECT will not be defined])
2153 select_prev_IFS=$IFS; IFS=','
2154 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2155 IFS=$select_prev_IFS
2158 sel_qual_type_arg5=$[3]
2160 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2161 [Define to the type of arg 1 for select.])
2162 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2163 [Define to the type of args 2, 3 and 4 for select.])
2164 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2165 [Define to the function return type for select.])
2169 case $prev_sh_opts in
2177 case "$sel_qual_type_arg5" in
2180 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2184 sel_type_arg5=$sel_qual_type_arg5
2188 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2189 [Define to the type qualifier of arg 5 for select.])
2190 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2191 [Define to the type of arg 5 for select.])
2193 case $prev_sh_opts in
2201 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2202 [Define to 1 if you have the select function.])
2203 ac_cv_func_select="yes"
2209 dnl ************************************************************
2210 dnl check for "localhost", if it doesn't exist, we can't do the
2211 dnl gethostbyname_r tests!
2214 AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[
2215 AC_MSG_CHECKING([if "localhost" resolves])
2218 #include <sys/types.h>
2221 #define NULL (void *)0
2227 h = gethostbyname("localhost");
2228 exit (h == NULL ? 1 : 0); }],[
2229 AC_MSG_RESULT(yes)],[
2231 AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
2237 dnl ************************************************************
2238 dnl check for working getaddrinfo() that works with AI_NUMERICHOST
2240 AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
2241 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
2244 #include <sys/types.h>
2245 #include <sys/socket.h>
2249 struct addrinfo hints, *ai;
2252 memset(&hints, 0, sizeof(hints));
2253 hints.ai_flags = AI_NUMERICHOST;
2254 hints.ai_family = AF_UNSPEC;
2255 hints.ai_socktype = SOCK_STREAM;
2256 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
2263 ac_cv_working_getaddrinfo="yes"
2265 ac_cv_working_getaddrinfo="no"
2267 ac_cv_working_getaddrinfo="yes"
2269 if test "$ac_cv_working_getaddrinfo" = "yes"; then
2270 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
2271 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
2274 AC_SUBST(IPV6_ENABLED)
2279 AC_DEFUN([CURL_CHECK_LOCALTIME_R],
2281 dnl check for localtime_r
2282 AC_CHECK_FUNCS(localtime_r,[
2283 AC_MSG_CHECKING(whether localtime_r is declared)
2284 AC_EGREP_CPP(localtime_r,[
2285 #include <time.h>],[
2286 AC_MSG_RESULT(yes)],[
2288 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
2289 AC_EGREP_CPP(localtime_r,[
2291 #include <time.h>],[
2292 AC_DEFINE(NEED_REENTRANT)
2293 AC_MSG_RESULT(yes)],
2294 AC_MSG_RESULT(no))])])
2298 dnl This function checks for strerror_r(). If it isn't found at first, it
2299 dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
2300 dnl in order to find this function.
2302 dnl If the function is found, it will then proceed to check how the function
2303 dnl actually works: glibc-style or POSIX-style.
2306 dnl char *strerror_r(int errnum, char *buf, size_t n);
2308 dnl What this one does is to return the error string (no surprises there),
2309 dnl but it doesn't usually copy anything into buf! The 'buf' and 'n'
2310 dnl parameters are only meant as an optional working area, in case strerror_r
2311 dnl needs it. A quick test on a few systems shows that it's generally not
2315 dnl int strerror_r(int errnum, char *buf, size_t n);
2317 AC_DEFUN([CURL_CHECK_STRERROR_R],
2319 AC_CHECK_FUNCS(strerror_r)
2321 if test "x$ac_cv_func_strerror_r" = "xyes"; then
2323 AC_MSG_CHECKING(whether strerror_r is declared)
2324 AC_EGREP_CPP(strerror_r,[
2325 #include <string.h>],[
2326 AC_MSG_RESULT(yes)],[
2328 AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
2329 AC_EGREP_CPP(strerror_r,[
2331 #include <string.h>],[
2332 CPPFLAGS="-D_REENTRANT $CPPFLAGS"
2333 AC_MSG_RESULT(yes)],
2335 AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
2336 ) dnl with _THREAD_SAFE
2337 ]) dnl plain cpp for it
2339 dnl determine if this strerror_r() is glibc or POSIX
2340 AC_MSG_CHECKING([for a glibc strerror_r API])
2346 char buffer[1024]; /* big enough to play with */
2348 strerror_r(EACCES, buffer, sizeof(buffer));
2349 /* this should've returned a string */
2350 if(!string || !string[0])
2355 GLIBC_STRERROR_R="1"
2356 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2357 AC_MSG_RESULT([yes]),
2358 AC_MSG_RESULT([no]),
2360 dnl Use an inferior method of strerror_r detection while cross-compiling
2362 #include <features.h>
2367 dnl looks like glibc, so assume a glibc-style strerror_r()
2368 GLIBC_STRERROR_R="1"
2369 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2370 AC_MSG_RESULT([yes]),
2371 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2372 ) dnl while cross-compiling
2375 if test -z "$GLIBC_STRERROR_R"; then
2377 AC_MSG_CHECKING([for a POSIX strerror_r API])
2383 char buffer[1024]; /* big enough to play with */
2385 strerror_r(EACCES, buffer, sizeof(buffer));
2386 /* This should've returned zero, and written an error string in the
2388 if(!buffer[0] || error)
2393 AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
2394 AC_MSG_RESULT([yes]),
2395 AC_MSG_RESULT([no]) ,
2396 dnl cross-compiling!
2397 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2400 fi dnl if not using glibc API
2402 fi dnl we have a strerror_r
2406 AC_DEFUN([CURL_CHECK_INET_NTOA_R],
2408 dnl determine if function definition for inet_ntoa_r exists.
2409 AC_CHECK_FUNCS(inet_ntoa_r,[
2410 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
2411 AC_EGREP_CPP(inet_ntoa_r,[
2412 #include <arpa/inet.h>],[
2413 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2414 AC_MSG_RESULT(yes)],[
2416 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
2417 AC_EGREP_CPP(inet_ntoa_r,[
2419 #include <arpa/inet.h>],[
2420 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2421 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT defined])
2422 AC_MSG_RESULT(yes)],
2423 AC_MSG_RESULT(no))])])
2427 dnl CURL_CHECK_GETHOSTBYADDR_R
2428 dnl -------------------------------------------------
2429 dnl check number of arguments for gethostbyaddr_r, it
2430 dnl might take either 5, 7, or 8 arguments.
2432 AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R], [
2434 AC_MSG_CHECKING([for gethostbyaddr_r])
2436 AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
2438 AC_MSG_RESULT([yes])
2439 tmp_cv_gethostbyaddr_r="yes"
2442 tmp_cv_gethostbyaddr_r="no"
2445 if test "$tmp_cv_gethostbyaddr_r" != "yes"; then
2446 AC_MSG_CHECKING([deeper for gethostbyaddr_r])
2453 AC_MSG_RESULT([yes])
2454 tmp_cv_gethostbyaddr_r="yes"
2456 AC_MSG_RESULT([but still no])
2457 tmp_cv_gethostbyaddr_r="no"
2461 if test "$tmp_cv_gethostbyaddr_r" = "yes"; then
2463 ac_cv_gethostbyaddr_r_args="unknown"
2465 AC_MSG_CHECKING([if gethostbyaddr_r takes 5 arguments])
2468 #include <sys/types.h>
2475 struct hostent_data hdata;
2477 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2480 AC_MSG_RESULT([yes])
2481 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2482 ac_cv_gethostbyaddr_r_args="5"
2487 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2488 AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 5 arguments])
2492 #include <sys/types.h>
2499 struct hostent_data hdata;
2501 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2504 AC_MSG_RESULT([yes])
2505 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2506 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
2507 ac_cv_gethostbyaddr_r_args="5"
2513 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2514 AC_MSG_CHECKING([if gethostbyaddr_r takes 7 arguments])
2517 #include <sys/types.h>
2526 struct hostent * hp;
2527 hp = gethostbyaddr_r(address, length, type, &h,
2528 buffer, 8192, &h_errnop);
2531 AC_MSG_RESULT([yes])
2532 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2533 ac_cv_gethostbyaddr_r_args="7"
2539 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2540 AC_MSG_CHECKING([if gethostbyaddr_r takes 8 arguments])
2543 #include <sys/types.h>
2552 struct hostent * hp;
2554 rc = gethostbyaddr_r(address, length, type, &h,
2555 buffer, 8192, &hp, &h_errnop);
2558 AC_MSG_RESULT([yes])
2559 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
2560 ac_cv_gethostbyaddr_r_args="8"
2566 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2567 AC_MSG_WARN([Cannot find out how to use gethostbyaddr_r])
2568 AC_MSG_WARN([HAVE_GETHOSTBYADDR_R will not be defined])
2569 ac_cv_func_gethostbyaddr_r="no"
2571 AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
2572 [Define to 1 if you have the gethostbyaddr_r function.])
2573 ac_cv_func_gethostbyaddr_r="yes"
2577 ac_cv_func_gethostbyaddr_r="no"
2582 dnl CURL_CHECK_GETHOSTBYNAME_R
2583 dnl -------------------------------------------------
2584 dnl check number of arguments for gethostbyname_r, it
2585 dnl might take either 3, 5, or 6 arguments.
2587 AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R], [
2589 AC_MSG_CHECKING([for gethostbyname_r])
2591 AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
2593 AC_MSG_RESULT([yes])
2594 tmp_cv_gethostbyname_r="yes"
2597 tmp_cv_gethostbyname_r="no"
2600 if test "$tmp_cv_gethostbyname_r" != "yes"; then
2601 AC_MSG_CHECKING([deeper for gethostbyname_r])
2608 AC_MSG_RESULT([yes])
2609 tmp_cv_gethostbyname_r="yes"
2611 AC_MSG_RESULT([but still no])
2612 tmp_cv_gethostbyname_r="no"
2616 if test "$tmp_cv_gethostbyname_r" = "yes"; then
2618 ac_cv_gethostbyname_r_args="unknown"
2620 AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
2624 #include <sys/types.h>
2627 #define NULL (void *)0
2629 gethostbyname_r(const char *, struct hostent *,
2630 struct hostent_data *);
2632 struct hostent_data data;
2633 gethostbyname_r(NULL, NULL, NULL);
2636 AC_MSG_RESULT([yes])
2637 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2638 ac_cv_gethostbyname_r_args="3"
2643 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2644 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
2649 #include <sys/types.h>
2652 #define NULL (void *)0
2654 gethostbyname_r(const char *, struct hostent *,
2655 struct hostent_data *);
2657 struct hostent_data data;
2658 gethostbyname_r(NULL, NULL, NULL);
2661 AC_MSG_RESULT([yes])
2662 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2663 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
2664 ac_cv_gethostbyname_r_args="3"
2670 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2671 AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
2674 #include <sys/types.h>
2677 #define NULL (void *)0
2679 gethostbyname_r(const char *, struct hostent *,
2680 char *, int, int *);
2682 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
2685 AC_MSG_RESULT([yes])
2686 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
2687 ac_cv_gethostbyname_r_args="5"
2693 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2694 AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
2697 #include <sys/types.h>
2700 #define NULL (void *)0
2702 gethostbyname_r(const char *, struct hostent *,
2703 char *, size_t, struct hostent **, int *);
2705 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
2708 AC_MSG_RESULT([yes])
2709 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
2710 ac_cv_gethostbyname_r_args="6"
2716 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2717 AC_MSG_WARN([Cannot find out how to use gethostbyname_r])
2718 AC_MSG_WARN([HAVE_GETHOSTBYNAME_R will not be defined])
2719 ac_cv_func_gethostbyname_r="no"
2721 AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
2722 [Define to 1 if you have the gethostbyname_r function.])
2723 ac_cv_func_gethostbyname_r="yes"
2727 ac_cv_func_gethostbyname_r="no"
2732 dnl **********************************************************************
2733 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
2735 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
2736 dnl sets the $ICC variable to "yes" or "no"
2737 dnl **********************************************************************
2738 AC_DEFUN([CURL_DETECT_ICC],
2741 AC_MSG_CHECKING([for icc in use])
2742 if test "$GCC" = "yes"; then
2743 dnl check if this is icc acting as gcc in disguise
2744 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
2745 dnl action if the text is found, this it has not been replaced by the
2748 dnl the text was not found, it was replaced by the cpp
2750 AC_MSG_RESULT([yes])
2754 if test "$ICC" = "no"; then
2760 dnl We create a function for detecting which compiler we use and then set as
2761 dnl pendantic compiler options as possible for that particular compiler. The
2762 dnl options are only used for debug-builds.
2764 AC_DEFUN([CURL_CC_DEBUG_OPTS],
2766 if test "z$ICC" = "z"; then
2770 if test "$GCC" = "yes"; then
2772 dnl figure out gcc version!
2773 AC_MSG_CHECKING([gcc version])
2774 gccver=`$CC -dumpversion`
2775 num1=`echo $gccver | cut -d . -f1`
2776 num2=`echo $gccver | cut -d . -f2`
2777 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
2778 AC_MSG_RESULT($gccver)
2780 if test "$ICC" = "yes"; then
2781 dnl this is icc, not gcc.
2783 dnl ICC warnings we ignore:
2784 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
2785 dnl "invalid format string conversion"
2786 dnl * 279 warns on static conditions in while expressions
2787 dnl * 981 warns on "operands are evaluated in unspecified order"
2788 dnl * 1418 "external definition with no prior declaration"
2789 dnl * 1419 warns on "external declaration in primary source file"
2790 dnl which we know and do on purpose.
2792 WARN="-wd279,269,981,1418,1419"
2794 if test "$gccnum" -gt "600"; then
2795 dnl icc 6.0 and older doesn't have the -Wall flag
2799 dnl this is a set of options we believe *ALL* gcc versions support:
2800 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
2802 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
2804 if test "$gccnum" -ge "207"; then
2805 dnl gcc 2.7 or later
2806 WARN="$WARN -Wmissing-declarations"
2809 if test "$gccnum" -gt "295"; then
2810 dnl only if the compiler is newer than 2.95 since we got lots of
2811 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
2812 dnl gcc 2.95.4 on FreeBSD 4.9!
2813 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
2816 if test "$gccnum" -ge "296"; then
2817 dnl gcc 2.96 or later
2818 WARN="$WARN -Wfloat-equal"
2821 if test "$gccnum" -gt "296"; then
2822 dnl this option does not exist in 2.96
2823 WARN="$WARN -Wno-format-nonliteral"
2826 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
2827 dnl on i686-Linux as it gives us heaps with false positives.
2828 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
2829 dnl over making it unusable for generic purposes. Let's not use it.
2831 if test "$gccnum" -ge "303"; then
2832 dnl gcc 3.3 and later
2833 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
2836 if test "$gccnum" -ge "304"; then
2837 # try these on gcc 3.4
2838 WARN="$WARN -Wdeclaration-after-statement"
2841 for flag in $CPPFLAGS; do
2844 dnl Include path, provide a -isystem option for the same dir
2845 dnl to prevent warnings in those dirs. The -isystem was not very
2846 dnl reliable on earlier gcc versions.
2847 add=`echo $flag | sed 's/^-I/-isystem /g'`
2855 CFLAGS="$CFLAGS $WARN"
2857 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
2861 AC_MSG_NOTICE([Added no extra compiler options])
2865 dnl strip off optimizer flags
2867 for flag in $CFLAGS; do
2870 dnl echo "cut off $flag"
2873 NEWFLAGS="$NEWFLAGS $flag"
2879 ]) dnl end of AC_DEFUN()
2881 # This is only a temporary fix. This macro is here to replace the broken one
2882 # delivered by the automake project (including the 1.9.6 release). As soon as
2883 # they ship a working version we SHOULD remove this work-around.
2885 AC_DEFUN([AM_MISSING_HAS_RUN],
2886 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2887 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
2888 # Use eval to expand $SHELL
2889 if eval "$MISSING --run true"; then
2890 am_missing_run="$MISSING --run "
2893 AC_MSG_WARN([`missing' script is too old or missing])
2898 dnl CURL_VERIFY_RUNTIMELIBS
2899 dnl -------------------------------------------------
2900 dnl Verify that the shared libs found so far can be used when running
2901 dnl programs, since otherwise the situation will create odd configure errors
2902 dnl that are misleading people.
2904 dnl Make sure this test is run BEFORE the first test in the script that
2905 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
2906 dnl macro. It must also run AFTER all lib-checking macros are complete.
2908 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
2910 dnl this test is of course not sensible if we are cross-compiling!
2911 if test "x$cross_compiling" != xyes; then
2913 dnl just run a program to verify that the libs checked for previous to this
2914 dnl point also is available run-time!
2915 AC_MSG_CHECKING([run-time libs availability])
2922 AC_MSG_RESULT([fine]),
2923 AC_MSG_RESULT([failed])
2924 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
2927 dnl if this test fails, configure has already stopped
2932 dnl CURL_CHECK_VARIADIC_MACROS
2933 dnl -------------------------------------------------
2934 dnl Check compiler support of variadic macros
2936 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
2937 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
2938 [curl_cv_variadic_macros_c99], [
2941 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
2942 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
2943 int fun3(int arg1, int arg2, int arg3);
2944 int fun2(int arg1, int arg2);
2945 int fun3(int arg1, int arg2, int arg3)
2946 { return arg1 + arg2 + arg3; }
2947 int fun2(int arg1, int arg2)
2948 { return arg1 + arg2; }
2950 int res3 = c99_vmacro3(1, 2, 3);
2951 int res2 = c99_vmacro2(1, 2);
2954 curl_cv_variadic_macros_c99="yes"
2956 curl_cv_variadic_macros_c99="no"
2959 case "$curl_cv_variadic_macros_c99" in
2961 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
2962 [Define to 1 if compiler supports C99 variadic macro style.])
2965 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
2966 [curl_cv_variadic_macros_gcc], [
2969 #define gcc_vmacro3(first, args...) fun3(first, args)
2970 #define gcc_vmacro2(first, args...) fun2(first, args)
2971 int fun3(int arg1, int arg2, int arg3);
2972 int fun2(int arg1, int arg2);
2973 int fun3(int arg1, int arg2, int arg3)
2974 { return arg1 + arg2 + arg3; }
2975 int fun2(int arg1, int arg2)
2976 { return arg1 + arg2; }
2978 int res3 = gcc_vmacro3(1, 2, 3);
2979 int res2 = gcc_vmacro2(1, 2);
2982 curl_cv_variadic_macros_gcc="yes"
2984 curl_cv_variadic_macros_gcc="no"
2987 case "$curl_cv_variadic_macros_gcc" in
2989 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2990 [Define to 1 if compiler supports old gcc variadic macro style.])
2996 dnl CURL_CHECK_CA_BUNDLE
2997 dnl -------------------------------------------------
2998 dnl Check if a default ca-bundle should be used
3000 dnl regarding the paths this will scan:
3001 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
3002 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
3003 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
3004 dnl /etc/ssl/certs/ (ca path) SUSE
3006 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
3008 AC_MSG_CHECKING([default CA cert bundle/path])
3010 AC_ARG_WITH(ca-bundle,
3011 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
3012 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
3015 if test "x$want_ca" = "xyes"; then
3016 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
3019 [ want_ca="unset" ])
3020 AC_ARG_WITH(ca-path,
3021 AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
3022 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
3024 want_capath="$withval"
3025 if test "x$want_capath" = "xyes"; then
3026 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
3029 [ want_capath="unset"])
3031 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
3032 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
3034 AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
3035 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
3036 dnl --with-ca-bundle given
3039 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
3040 dnl --with-ca-path given
3041 if test "x$OPENSSL_ENABLED" != "x1"; then
3042 AC_MSG_ERROR([--with-ca-path only works with openSSL])
3044 capath="$want_capath"
3047 dnl neither of --with-ca-* given
3048 dnl first try autodetecting a CA bundle , then a CA path
3049 dnl both autodetections can be skipped by --without-ca-*
3052 if test "x$want_ca" = "xunset"; then
3053 dnl the path we previously would have installed the curl ca bundle
3054 dnl to, and thus we now check for an already existing cert in that place
3055 dnl in case we find no other
3056 if test "x$prefix" != xNONE; then
3057 cac="${prefix}/share/curl/curl-ca-bundle.crt"
3059 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
3062 for a in /etc/ssl/certs/ca-certificates.crt \
3063 /etc/pki/tls/certs/ca-bundle.crt \
3064 /usr/share/ssl/certs/ca-bundle.crt \
3066 if test -f "$a"; then
3072 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
3073 "x$OPENSSL_ENABLED" = "x1"; then
3074 for a in /etc/ssl/certs/; do
3075 if test -d "$a" && ls "$a"/[[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]].0 >/dev/null 2>/dev/null; then
3085 if test "x$ca" != "xno"; then
3086 CURL_CA_BUNDLE='"'$ca'"'
3087 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
3088 AC_SUBST(CURL_CA_BUNDLE)
3089 AC_MSG_RESULT([$ca])
3090 elif test "x$capath" != "xno"; then
3091 CURL_CA_PATH="\"$capath\""
3092 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
3093 AC_MSG_RESULT([$capath (capath)])