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_COMPILER_HALT_ON_ERROR
26 dnl -------------------------------------------------
27 dnl Verifies if the compiler actually halts after the
28 dnl compilation phase without generating any object
29 dnl code file, when the source compiles with errors.
31 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
32 AC_MSG_CHECKING([if compiler halts on compilation errors])
36 force compilation error
40 AC_MSG_ERROR([compiler does not halt on compilation errors.])
47 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
48 dnl -------------------------------------------------
49 dnl Verifies if the compiler actually halts after the
50 dnl compilation phase without generating any object
51 dnl code file, when the source code tries to define a
52 dnl type for a constant array with negative dimension.
54 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
55 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
56 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
59 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
65 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
72 dnl CURL_CHECK_DEF(SYMBOL, [INCLUDES], [SILENT])
73 dnl -------------------------------------------------
74 dnl Use the C preprocessor to find out if the given object-style symbol
75 dnl is defined and get its expansion. This macro will not use default
76 dnl includes even if no INCLUDES argument is given. This macro will run
77 dnl silently when invoked with three arguments.
79 AC_DEFUN([CURL_CHECK_DEF], [
80 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
81 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
82 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
92 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
93 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
94 "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
95 "$SED" 'q' 2>/dev/null`
96 if test "$tmp_exp" = "$1"; then
100 if test -z "$tmp_exp"; then
101 AS_VAR_SET([ac_HaveDef], [no])
102 ifelse($3,,[AC_MSG_RESULT([no])])
104 AS_VAR_SET([ac_HaveDef], [yes])
105 AS_VAR_SET([ac_Def], [$tmp_exp])
106 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
108 AS_VAR_POPDEF([ac_Def])dnl
109 AS_VAR_POPDEF([ac_HaveDef])dnl
113 dnl CURL_CHECK_HEADER_WINDOWS
114 dnl -------------------------------------------------
115 dnl Check for compilable and valid windows.h header
117 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
118 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
122 #ifndef WIN32_LEAN_AND_MEAN
123 #define WIN32_LEAN_AND_MEAN
127 #if defined(__CYGWIN__) || defined(__CEGCC__)
128 HAVE_WINDOWS_H shall not be defined.
134 ac_cv_header_windows_h="yes"
136 ac_cv_header_windows_h="no"
139 case "$ac_cv_header_windows_h" in
141 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
142 [Define to 1 if you have the windows.h header file.])
143 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
144 [Define to avoid automatic inclusion of winsock.h])
150 dnl CURL_CHECK_NATIVE_WINDOWS
151 dnl -------------------------------------------------
152 dnl Check if building a native Windows target
154 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
155 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
156 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
157 if test "$ac_cv_header_windows_h" = "no"; then
158 ac_cv_native_windows="no"
163 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
164 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
167 Not a native Windows build target.
171 ac_cv_native_windows="yes"
173 ac_cv_native_windows="no"
177 case "$ac_cv_native_windows" in
179 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
180 [Define to 1 if you are building a native Windows target.])
186 dnl CURL_CHECK_HEADER_WINSOCK
187 dnl -------------------------------------------------
188 dnl Check for compilable and valid winsock.h header
190 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
191 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
192 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
196 #ifndef WIN32_LEAN_AND_MEAN
197 #define WIN32_LEAN_AND_MEAN
202 #if defined(__CYGWIN__) || defined(__CEGCC__)
203 HAVE_WINSOCK_H shall not be defined.
205 int dummy=WSACleanup();
209 ac_cv_header_winsock_h="yes"
211 ac_cv_header_winsock_h="no"
214 case "$ac_cv_header_winsock_h" in
216 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
217 [Define to 1 if you have the winsock.h header file.])
223 dnl CURL_CHECK_HEADER_WINSOCK2
224 dnl -------------------------------------------------
225 dnl Check for compilable and valid winsock2.h header
227 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
228 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
229 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
233 #ifndef WIN32_LEAN_AND_MEAN
234 #define WIN32_LEAN_AND_MEAN
237 #include <winsock2.h>
239 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
240 HAVE_WINSOCK2_H shall not be defined.
242 int dummy=2*IPPROTO_ESP;
246 ac_cv_header_winsock2_h="yes"
248 ac_cv_header_winsock2_h="no"
251 case "$ac_cv_header_winsock2_h" in
253 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
254 [Define to 1 if you have the winsock2.h header file.])
260 dnl CURL_CHECK_HEADER_WS2TCPIP
261 dnl -------------------------------------------------
262 dnl Check for compilable and valid ws2tcpip.h header
264 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
265 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
266 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
270 #ifndef WIN32_LEAN_AND_MEAN
271 #define WIN32_LEAN_AND_MEAN
274 #include <winsock2.h>
275 #include <ws2tcpip.h>
277 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
278 HAVE_WS2TCPIP_H shall not be defined.
280 int dummy=2*IP_PKTINFO;
284 ac_cv_header_ws2tcpip_h="yes"
286 ac_cv_header_ws2tcpip_h="no"
289 case "$ac_cv_header_ws2tcpip_h" in
291 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
292 [Define to 1 if you have the ws2tcpip.h header file.])
298 dnl CURL_CHECK_HEADER_WINLDAP
299 dnl -------------------------------------------------
300 dnl Check for compilable and valid winldap.h header
302 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
303 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
304 AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
308 #ifdef HAVE_WINDOWS_H
309 #ifndef WIN32_LEAN_AND_MEAN
310 #define WIN32_LEAN_AND_MEAN
316 #if defined(__CYGWIN__) || defined(__CEGCC__)
317 HAVE_WINLDAP_H shall not be defined.
319 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
320 ULONG res = ldap_unbind(ldp);
324 ac_cv_header_winldap_h="yes"
326 ac_cv_header_winldap_h="no"
329 case "$ac_cv_header_winldap_h" in
331 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
332 [Define to 1 if you have the winldap.h header file.])
338 dnl CURL_CHECK_HEADER_WINBER
339 dnl -------------------------------------------------
340 dnl Check for compilable and valid winber.h header
342 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
343 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
344 AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
348 #ifdef HAVE_WINDOWS_H
349 #ifndef WIN32_LEAN_AND_MEAN
350 #define WIN32_LEAN_AND_MEAN
357 #if defined(__CYGWIN__) || defined(__CEGCC__)
358 HAVE_WINBER_H shall not be defined.
361 BerElement *bep = ber_init(bvp);
366 ac_cv_header_winber_h="yes"
368 ac_cv_header_winber_h="no"
371 case "$ac_cv_header_winber_h" in
373 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
374 [Define to 1 if you have the winber.h header file.])
380 dnl CURL_CHECK_HEADER_LBER
381 dnl -------------------------------------------------
382 dnl Check for compilable and valid lber.h header,
383 dnl and check if it is needed even with ldap.h
385 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
386 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
387 AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
391 #ifdef HAVE_WINDOWS_H
392 #ifndef WIN32_LEAN_AND_MEAN
393 #define WIN32_LEAN_AND_MEAN
397 #ifdef HAVE_SYS_TYPES_H
398 #include <sys/types.h>
402 #define NULL (void *)0
406 BerValue *bvp = NULL;
407 BerElement *bep = ber_init(bvp);
411 ac_cv_header_lber_h="yes"
413 ac_cv_header_lber_h="no"
416 if test "$ac_cv_header_lber_h" = "yes"; then
417 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
418 [Define to 1 if you have the lber.h header file.])
423 #ifdef HAVE_WINDOWS_H
424 #ifndef WIN32_LEAN_AND_MEAN
425 #define WIN32_LEAN_AND_MEAN
429 #ifdef HAVE_SYS_TYPES_H
430 #include <sys/types.h>
434 #define NULL (void *)0
436 #ifndef LDAP_DEPRECATED
437 #define LDAP_DEPRECATED 1
441 BerValue *bvp = NULL;
442 BerElement *bep = ber_init(bvp);
446 curl_cv_need_header_lber_h="no"
448 curl_cv_need_header_lber_h="yes"
451 case "$curl_cv_need_header_lber_h" in
453 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
454 [Define to 1 if you need the lber.h header file even with ldap.h])
461 dnl CURL_CHECK_HEADER_LDAP
462 dnl -------------------------------------------------
463 dnl Check for compilable and valid ldap.h header
465 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
466 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
467 AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
471 #ifdef HAVE_WINDOWS_H
472 #ifndef WIN32_LEAN_AND_MEAN
473 #define WIN32_LEAN_AND_MEAN
477 #ifdef HAVE_SYS_TYPES_H
478 #include <sys/types.h>
481 #ifndef LDAP_DEPRECATED
482 #define LDAP_DEPRECATED 1
489 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
490 int res = ldap_unbind(ldp);
493 ac_cv_header_ldap_h="yes"
495 ac_cv_header_ldap_h="no"
498 case "$ac_cv_header_ldap_h" in
500 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
501 [Define to 1 if you have the ldap.h header file.])
507 dnl CURL_CHECK_HEADER_LDAP_SSL
508 dnl -------------------------------------------------
509 dnl Check for compilable and valid ldap_ssl.h header
511 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
512 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
513 AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
517 #ifdef HAVE_WINDOWS_H
518 #ifndef WIN32_LEAN_AND_MEAN
519 #define WIN32_LEAN_AND_MEAN
523 #ifdef HAVE_SYS_TYPES_H
524 #include <sys/types.h>
527 #ifndef LDAP_DEPRECATED
528 #define LDAP_DEPRECATED 1
536 #include <ldap_ssl.h>
538 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
541 ac_cv_header_ldap_ssl_h="yes"
543 ac_cv_header_ldap_ssl_h="no"
546 case "$ac_cv_header_ldap_ssl_h" in
548 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
549 [Define to 1 if you have the ldap_ssl.h header file.])
555 dnl CURL_CHECK_HEADER_LDAPSSL
556 dnl -------------------------------------------------
557 dnl Check for compilable and valid ldapssl.h header
559 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
560 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
561 AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
565 #ifdef HAVE_WINDOWS_H
566 #ifndef WIN32_LEAN_AND_MEAN
567 #define WIN32_LEAN_AND_MEAN
571 #ifdef HAVE_SYS_TYPES_H
572 #include <sys/types.h>
576 #define NULL (void *)0
578 #ifndef LDAP_DEPRECATED
579 #define LDAP_DEPRECATED 1
589 char *cert_label = NULL;
590 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
593 ac_cv_header_ldapssl_h="yes"
595 ac_cv_header_ldapssl_h="no"
598 case "$ac_cv_header_ldapssl_h" in
600 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
601 [Define to 1 if you have the ldapssl.h header file.])
607 dnl CURL_CHECK_LIBS_WINLDAP
608 dnl -------------------------------------------------
609 dnl Check for libraries needed for WINLDAP support,
610 dnl and prepended to LIBS any needed libraries.
611 dnl This macro can take an optional parameter with a
612 dnl white space separated list of libraries to check
613 dnl before the WINLDAP default ones.
615 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
616 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
618 AC_MSG_CHECKING([for WINLDAP libraries])
632 if test -z "$u_libs"; then
635 u_libs="$u_libs $l_lib"
640 curl_cv_save_LIBS="$LIBS"
641 curl_cv_ldap_LIBS="unknown"
643 for x_nlibs in '' "$u_libs" \
645 if test "$curl_cv_ldap_LIBS" = "unknown"; then
646 if test -z "$x_nlibs"; then
647 LIBS="$curl_cv_save_LIBS"
649 LIBS="$x_nlibs $curl_cv_save_LIBS"
654 #ifdef HAVE_WINDOWS_H
655 #ifndef WIN32_LEAN_AND_MEAN
656 #define WIN32_LEAN_AND_MEAN
659 #ifdef HAVE_WINLDAP_H
668 BerElement *bep = ber_init(bvp);
669 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
670 ULONG res = ldap_unbind(ldp);
674 curl_cv_ldap_LIBS="$x_nlibs"
679 LIBS="$curl_cv_save_LIBS"
681 case X-"$curl_cv_ldap_LIBS" in
683 AC_MSG_RESULT([cannot find WINLDAP libraries])
686 AC_MSG_RESULT([no additional lib required])
689 if test -z "$curl_cv_save_LIBS"; then
690 LIBS="$curl_cv_ldap_LIBS"
692 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
694 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
701 dnl CURL_CHECK_LIBS_LDAP
702 dnl -------------------------------------------------
703 dnl Check for libraries needed for LDAP support,
704 dnl and prepended to LIBS any needed libraries.
705 dnl This macro can take an optional parameter with a
706 dnl white space separated list of libraries to check
707 dnl before the default ones.
709 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
710 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
712 AC_MSG_CHECKING([for LDAP libraries])
726 if test -z "$u_libs"; then
729 u_libs="$u_libs $l_lib"
734 curl_cv_save_LIBS="$LIBS"
735 curl_cv_ldap_LIBS="unknown"
737 for x_nlibs in '' "$u_libs" \
741 '-lldapssl -lldapx -lldapsdk' \
742 '-lldapsdk -lldapx -lldapssl' ; do
743 if test "$curl_cv_ldap_LIBS" = "unknown"; then
744 if test -z "$x_nlibs"; then
745 LIBS="$curl_cv_save_LIBS"
747 LIBS="$x_nlibs $curl_cv_save_LIBS"
752 #ifdef HAVE_WINDOWS_H
753 #ifndef WIN32_LEAN_AND_MEAN
754 #define WIN32_LEAN_AND_MEAN
758 #ifdef HAVE_SYS_TYPES_H
759 #include <sys/types.h>
763 #define NULL (void *)0
765 #ifndef LDAP_DEPRECATED
766 #define LDAP_DEPRECATED 1
775 BerValue *bvp = NULL;
776 BerElement *bep = ber_init(bvp);
777 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
778 int res = ldap_unbind(ldp);
782 curl_cv_ldap_LIBS="$x_nlibs"
787 LIBS="$curl_cv_save_LIBS"
789 case X-"$curl_cv_ldap_LIBS" in
791 AC_MSG_RESULT([cannot find LDAP libraries])
794 AC_MSG_RESULT([no additional lib required])
797 if test -z "$curl_cv_save_LIBS"; then
798 LIBS="$curl_cv_ldap_LIBS"
800 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
802 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
809 dnl CURL_CHECK_HEADER_MALLOC
810 dnl -------------------------------------------------
811 dnl Check for compilable and valid malloc.h header,
812 dnl and check if it is needed even with stdlib.h
814 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
815 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
820 void *p = malloc(10);
821 void *q = calloc(10,10);
826 ac_cv_header_malloc_h="yes"
828 ac_cv_header_malloc_h="no"
831 if test "$ac_cv_header_malloc_h" = "yes"; then
832 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
833 [Define to 1 if you have the malloc.h header file.])
839 void *p = malloc(10);
840 void *q = calloc(10,10);
845 curl_cv_need_header_malloc_h="no"
847 curl_cv_need_header_malloc_h="yes"
850 case "$curl_cv_need_header_malloc_h" in
852 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
853 [Define to 1 if you need the malloc.h header file even with stdlib.h])
860 dnl CURL_CHECK_TYPE_SOCKLEN_T
861 dnl -------------------------------------------------
862 dnl Check for existing socklen_t type, and provide
863 dnl an equivalent type if socklen_t not available
865 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
866 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
867 AC_CHECK_TYPE([socklen_t], ,[
868 dnl socklen_t not available
869 AC_CACHE_CHECK([for socklen_t equivalent],
870 [curl_cv_socklen_t_equiv], [
871 curl_cv_socklen_t_equiv="unknown"
872 for arg1 in 'int' 'SOCKET'; do
873 for arg2 in "struct sockaddr" void; do
874 for t in int size_t unsigned long "unsigned long"; do
875 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
879 #ifdef HAVE_WINDOWS_H
880 #ifndef WIN32_LEAN_AND_MEAN
881 #define WIN32_LEAN_AND_MEAN
884 #ifdef HAVE_WINSOCK2_H
885 #include <winsock2.h>
887 #ifdef HAVE_WINSOCK_H
891 #define GETPEERNCALLCONV PASCAL
893 #ifdef HAVE_SYS_TYPES_H
894 #include <sys/types.h>
896 #ifdef HAVE_SYS_SOCKET_H
897 #include <sys/socket.h>
899 #define GETPEERNCALLCONV
901 extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
904 getpeername(0,0,&len);
907 curl_cv_socklen_t_equiv="$t"
914 case "$curl_cv_socklen_t_equiv" in
916 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
919 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
920 [Type to use in place of socklen_t when system does not provide it.])
925 #ifdef HAVE_WINDOWS_H
926 #ifndef WIN32_LEAN_AND_MEAN
927 #define WIN32_LEAN_AND_MEAN
930 #ifdef HAVE_WINSOCK2_H
931 #include <winsock2.h>
932 #ifdef HAVE_WS2TCPIP_H
933 #include <ws2tcpip.h>
937 #ifdef HAVE_SYS_TYPES_H
938 #include <sys/types.h>
940 #ifdef HAVE_SYS_SOCKET_H
941 #include <sys/socket.h>
948 dnl CURL_CHECK_FUNC_GETNAMEINFO
949 dnl -------------------------------------------------
950 dnl Test if the getnameinfo function is available,
951 dnl and check the types of five of its arguments.
952 dnl If the function succeeds HAVE_GETNAMEINFO will be
953 dnl defined, defining the types of the arguments in
954 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
955 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
956 dnl and also defining the type qualifier of first
957 dnl argument in GETNAMEINFO_QUAL_ARG1.
959 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
960 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
961 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
962 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
964 AC_MSG_CHECKING([for getnameinfo])
966 AC_LANG_FUNC_LINK_TRY([getnameinfo])
969 curl_cv_getnameinfo="yes"
972 curl_cv_getnameinfo="no"
975 if test "$curl_cv_getnameinfo" != "yes"; then
976 AC_MSG_CHECKING([deeper for getnameinfo])
984 curl_cv_getnameinfo="yes"
986 AC_MSG_RESULT([but still no])
987 curl_cv_getnameinfo="no"
991 if test "$curl_cv_getnameinfo" != "yes"; then
992 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
996 #ifdef HAVE_WINDOWS_H
997 #ifndef WIN32_LEAN_AND_MEAN
998 #define WIN32_LEAN_AND_MEAN
1000 #include <windows.h>
1001 #ifdef HAVE_WINSOCK2_H
1002 #include <winsock2.h>
1003 #ifdef HAVE_WS2TCPIP_H
1004 #include <ws2tcpip.h>
1008 #ifdef HAVE_SYS_TYPES_H
1009 #include <sys/types.h>
1011 #ifdef HAVE_SYS_SOCKET_H
1012 #include <sys/socket.h>
1019 getnameinfo(0, 0, 0, 0, 0, 0, 0);
1022 AC_MSG_RESULT([yes])
1023 curl_cv_getnameinfo="yes"
1025 AC_MSG_RESULT([but still no])
1026 curl_cv_getnameinfo="no"
1030 if test "$curl_cv_getnameinfo" = "yes"; then
1031 AC_CACHE_CHECK([types of arguments for getnameinfo],
1032 [curl_cv_func_getnameinfo_args], [
1033 curl_cv_func_getnameinfo_args="unknown"
1034 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
1035 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
1036 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
1037 for gni_arg7 in 'int' 'unsigned int'; do
1038 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1042 #ifdef HAVE_WINDOWS_H
1043 #ifndef WIN32_LEAN_AND_MEAN
1044 #define WIN32_LEAN_AND_MEAN
1046 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
1048 #define _WIN32_WINNT 0x0501
1050 #include <windows.h>
1051 #ifdef HAVE_WINSOCK2_H
1052 #include <winsock2.h>
1053 #ifdef HAVE_WS2TCPIP_H
1054 #include <ws2tcpip.h>
1057 #define GNICALLCONV WSAAPI
1059 #ifdef HAVE_SYS_TYPES_H
1060 #include <sys/types.h>
1062 #ifdef HAVE_SYS_SOCKET_H
1063 #include <sys/socket.h>
1070 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
1076 $gni_arg46 hostlen=0;
1077 $gni_arg46 servlen=0;
1079 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
1082 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
1090 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1091 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
1092 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1094 gni_prev_IFS=$IFS; IFS=','
1095 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1099 gni_qual_type_arg1=$[1]
1101 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1102 [Define to the type of arg 2 for getnameinfo.])
1103 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1104 [Define to the type of args 4 and 6 for getnameinfo.])
1105 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1106 [Define to the type of arg 7 for getnameinfo.])
1110 case $prev_sh_opts in
1118 case "$gni_qual_type_arg1" in
1121 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1125 gni_type_arg1=$gni_qual_type_arg1
1129 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1130 [Define to the type qualifier of arg 1 for getnameinfo.])
1131 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1132 [Define to the type of arg 1 for getnameinfo.])
1134 case $prev_sh_opts in
1142 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1143 [Define to 1 if you have the getnameinfo function.])
1144 ac_cv_func_getnameinfo="yes"
1150 dnl TYPE_SOCKADDR_STORAGE
1151 dnl -------------------------------------------------
1152 dnl Check for struct sockaddr_storage. Most IPv6-enabled
1153 dnl hosts have it, but AIX 4.3 is one known exception.
1155 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1157 AC_CHECK_TYPE([struct sockaddr_storage],
1158 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1159 [if struct sockaddr_storage is defined]), ,
1162 #ifdef HAVE_WINDOWS_H
1163 #ifndef WIN32_LEAN_AND_MEAN
1164 #define WIN32_LEAN_AND_MEAN
1166 #include <windows.h>
1167 #ifdef HAVE_WINSOCK2_H
1168 #include <winsock2.h>
1171 #ifdef HAVE_SYS_TYPES_H
1172 #include <sys/types.h>
1174 #ifdef HAVE_SYS_SOCKET_H
1175 #include <sys/socket.h>
1177 #ifdef HAVE_NETINET_IN_H
1178 #include <netinet/in.h>
1180 #ifdef HAVE_ARPA_INET_H
1181 #include <arpa/inet.h>
1188 dnl CURL_CHECK_NI_WITHSCOPEID
1189 dnl -------------------------------------------------
1190 dnl Check for working NI_WITHSCOPEID in getnameinfo()
1192 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1193 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1194 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1195 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1196 netdb.h netinet/in.h arpa/inet.h)
1198 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
1199 [ac_cv_working_ni_withscopeid], [
1205 #ifdef HAVE_SYS_TYPES_H
1206 #include <sys/types.h>
1208 #ifdef HAVE_SYS_SOCKET_H
1209 #include <sys/socket.h>
1214 #ifdef HAVE_NETINET_IN_H
1215 #include <netinet/in.h>
1217 #ifdef HAVE_ARPA_INET_H
1218 #include <arpa/inet.h>
1221 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1222 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1223 struct sockaddr_storage sa;
1225 unsigned char sa[256];
1227 char hostbuf[NI_MAXHOST];
1229 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1230 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1231 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1232 int fd = socket(AF_INET6, SOCK_STREAM, 0);
1235 return 1; /* Error creating socket */
1237 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1239 perror("getsockname()");
1240 return 2; /* Error retrieving socket name */
1242 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1244 printf("rc = %s\n", gai_strerror(rc));
1245 return 3; /* Error translating socket address */
1247 return 0; /* Ok, NI_WITHSCOPEID works */
1249 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1251 ]]) # AC_LANG_PROGRAM
1253 # Exit code == 0. Program worked.
1254 ac_cv_working_ni_withscopeid="yes"
1256 # Exit code != 0. Program failed.
1257 ac_cv_working_ni_withscopeid="no"
1259 # Program is not run when cross-compiling. So we assume
1260 # NI_WITHSCOPEID will work if we are able to compile it.
1263 #include <sys/types.h>
1264 #include <sys/socket.h>
1267 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1270 ac_cv_working_ni_withscopeid="yes"
1272 ac_cv_working_ni_withscopeid="no"
1273 ]) # AC_COMPILE_IFELSE
1276 case "$ac_cv_working_ni_withscopeid" in
1278 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1279 [Define to 1 if NI_WITHSCOPEID exists and works.])
1285 dnl CURL_CHECK_FUNC_RECV
1286 dnl -------------------------------------------------
1287 dnl Test if the socket recv() function is available,
1288 dnl and check its return type and the types of its
1289 dnl arguments. If the function succeeds HAVE_RECV
1290 dnl will be defined, defining the types of the arguments
1291 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1292 dnl and RECV_TYPE_ARG4, defining the type of the function
1293 dnl return value in RECV_TYPE_RETV.
1295 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1296 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1297 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1298 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1300 AC_MSG_CHECKING([for recv])
1304 #ifdef HAVE_WINDOWS_H
1305 #ifndef WIN32_LEAN_AND_MEAN
1306 #define WIN32_LEAN_AND_MEAN
1308 #include <windows.h>
1309 #ifdef HAVE_WINSOCK2_H
1310 #include <winsock2.h>
1312 #ifdef HAVE_WINSOCK_H
1313 #include <winsock.h>
1317 #ifdef HAVE_SYS_TYPES_H
1318 #include <sys/types.h>
1320 #ifdef HAVE_SYS_SOCKET_H
1321 #include <sys/socket.h>
1328 AC_MSG_RESULT([yes])
1335 if test "$curl_cv_recv" = "yes"; then
1336 AC_CACHE_CHECK([types of args and return type for recv],
1337 [curl_cv_func_recv_args], [
1338 curl_cv_func_recv_args="unknown"
1339 for recv_retv in 'int' 'ssize_t'; do
1340 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1341 for recv_arg2 in 'char *' 'void *'; do
1342 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1343 for recv_arg4 in 'int' 'unsigned int'; do
1344 if test "$curl_cv_func_recv_args" = "unknown"; then
1348 #ifdef HAVE_WINDOWS_H
1349 #ifndef WIN32_LEAN_AND_MEAN
1350 #define WIN32_LEAN_AND_MEAN
1352 #include <windows.h>
1353 #ifdef HAVE_WINSOCK2_H
1354 #include <winsock2.h>
1356 #ifdef HAVE_WINSOCK_H
1357 #include <winsock.h>
1360 #define RECVCALLCONV PASCAL
1362 #ifdef HAVE_SYS_TYPES_H
1363 #include <sys/types.h>
1365 #ifdef HAVE_SYS_SOCKET_H
1366 #include <sys/socket.h>
1368 #define RECVCALLCONV
1370 extern $recv_retv RECVCALLCONV
1371 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1377 $recv_retv res = recv(s, buf, len, flags);
1380 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1389 if test "$curl_cv_func_recv_args" = "unknown"; then
1390 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1392 recv_prev_IFS=$IFS; IFS=','
1393 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1397 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1398 [Define to the type of arg 1 for recv.])
1399 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1400 [Define to the type of arg 2 for recv.])
1401 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1402 [Define to the type of arg 3 for recv.])
1403 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1404 [Define to the type of arg 4 for recv.])
1405 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1406 [Define to the function return type for recv.])
1408 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1409 [Define to 1 if you have the recv function.])
1410 ac_cv_func_recv="yes"
1413 AC_MSG_ERROR([Unable to link function recv])
1418 dnl CURL_CHECK_FUNC_SEND
1419 dnl -------------------------------------------------
1420 dnl Test if the socket send() function is available,
1421 dnl and check its return type and the types of its
1422 dnl arguments. If the function succeeds HAVE_SEND
1423 dnl will be defined, defining the types of the arguments
1424 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1425 dnl and SEND_TYPE_ARG4, defining the type of the function
1426 dnl return value in SEND_TYPE_RETV, and also defining the
1427 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1429 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1430 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1431 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1432 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1434 AC_MSG_CHECKING([for send])
1438 #ifdef HAVE_WINDOWS_H
1439 #ifndef WIN32_LEAN_AND_MEAN
1440 #define WIN32_LEAN_AND_MEAN
1442 #include <windows.h>
1443 #ifdef HAVE_WINSOCK2_H
1444 #include <winsock2.h>
1446 #ifdef HAVE_WINSOCK_H
1447 #include <winsock.h>
1451 #ifdef HAVE_SYS_TYPES_H
1452 #include <sys/types.h>
1454 #ifdef HAVE_SYS_SOCKET_H
1455 #include <sys/socket.h>
1462 AC_MSG_RESULT([yes])
1469 if test "$curl_cv_send" = "yes"; then
1470 AC_CACHE_CHECK([types of args and return type for send],
1471 [curl_cv_func_send_args], [
1472 curl_cv_func_send_args="unknown"
1473 for send_retv in 'int' 'ssize_t'; do
1474 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1475 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1476 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1477 for send_arg4 in 'int' 'unsigned int'; do
1478 if test "$curl_cv_func_send_args" = "unknown"; then
1482 #ifdef HAVE_WINDOWS_H
1483 #ifndef WIN32_LEAN_AND_MEAN
1484 #define WIN32_LEAN_AND_MEAN
1486 #include <windows.h>
1487 #ifdef HAVE_WINSOCK2_H
1488 #include <winsock2.h>
1490 #ifdef HAVE_WINSOCK_H
1491 #include <winsock.h>
1494 #define SENDCALLCONV PASCAL
1496 #ifdef HAVE_SYS_TYPES_H
1497 #include <sys/types.h>
1499 #ifdef HAVE_SYS_SOCKET_H
1500 #include <sys/socket.h>
1502 #define SENDCALLCONV
1504 extern $send_retv SENDCALLCONV
1505 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1510 $send_retv res = send(s, 0, len, flags);
1513 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1522 if test "$curl_cv_func_send_args" = "unknown"; then
1523 AC_MSG_ERROR([Cannot find proper types to use for send args])
1525 send_prev_IFS=$IFS; IFS=','
1526 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1530 send_qual_type_arg2=$[2]
1532 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1533 [Define to the type of arg 1 for send.])
1534 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1535 [Define to the type of arg 3 for send.])
1536 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1537 [Define to the type of arg 4 for send.])
1538 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1539 [Define to the function return type for send.])
1543 case $prev_sh_opts in
1551 case "$send_qual_type_arg2" in
1553 send_qual_arg2=const
1554 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1558 send_type_arg2=$send_qual_type_arg2
1562 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1563 [Define to the type qualifier of arg 2 for send.])
1564 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1565 [Define to the type of arg 2 for send.])
1567 case $prev_sh_opts in
1575 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1576 [Define to 1 if you have the send function.])
1577 ac_cv_func_send="yes"
1580 AC_MSG_ERROR([Unable to link function send])
1585 dnl CURL_CHECK_MSG_NOSIGNAL
1586 dnl -------------------------------------------------
1587 dnl Check for MSG_NOSIGNAL
1589 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1590 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1591 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1595 #ifdef HAVE_WINDOWS_H
1596 #ifndef WIN32_LEAN_AND_MEAN
1597 #define WIN32_LEAN_AND_MEAN
1599 #include <windows.h>
1600 #ifdef HAVE_WINSOCK2_H
1601 #include <winsock2.h>
1603 #ifdef HAVE_WINSOCK_H
1604 #include <winsock.h>
1608 #ifdef HAVE_SYS_TYPES_H
1609 #include <sys/types.h>
1611 #ifdef HAVE_SYS_SOCKET_H
1612 #include <sys/socket.h>
1616 int flag=MSG_NOSIGNAL;
1619 ac_cv_msg_nosignal="yes"
1621 ac_cv_msg_nosignal="no"
1624 case "$ac_cv_msg_nosignal" in
1626 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1627 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1633 dnl CURL_CHECK_STRUCT_TIMEVAL
1634 dnl -------------------------------------------------
1635 dnl Check for timeval struct
1637 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1638 AC_REQUIRE([AC_HEADER_TIME])dnl
1639 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1640 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1641 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1642 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1646 #ifdef HAVE_WINDOWS_H
1647 #ifndef WIN32_LEAN_AND_MEAN
1648 #define WIN32_LEAN_AND_MEAN
1650 #include <windows.h>
1651 #ifdef HAVE_WINSOCK2_H
1652 #include <winsock2.h>
1654 #ifdef HAVE_WINSOCK_H
1655 #include <winsock.h>
1659 #ifdef HAVE_SYS_TYPES_H
1660 #include <sys/types.h>
1662 #ifdef HAVE_SYS_TIME_H
1663 #include <sys/time.h>
1664 #ifdef TIME_WITH_SYS_TIME
1678 ac_cv_struct_timeval="yes"
1680 ac_cv_struct_timeval="no"
1683 case "$ac_cv_struct_timeval" in
1685 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1686 [Define to 1 if you have the timeval struct.])
1692 dnl TYPE_SIG_ATOMIC_T
1693 dnl -------------------------------------------------
1694 dnl Check if the sig_atomic_t type is available, and
1695 dnl verify if it is already defined as volatile.
1697 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1698 AC_CHECK_HEADERS(signal.h)
1699 AC_CHECK_TYPE([sig_atomic_t],[
1700 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1701 [Define to 1 if sig_atomic_t is an available typedef.])
1703 #ifdef HAVE_SIGNAL_H
1707 case "$ac_cv_type_sig_atomic_t" in
1710 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1713 #ifdef HAVE_SIGNAL_H
1717 static volatile sig_atomic_t dummy = 0;
1721 ac_cv_sig_atomic_t_volatile="no"
1723 AC_MSG_RESULT([yes])
1724 ac_cv_sig_atomic_t_volatile="yes"
1727 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1728 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1729 [Define to 1 if sig_atomic_t is already defined as volatile.])
1736 dnl CURL_CHECK_NONBLOCKING_SOCKET
1737 dnl -------------------------------------------------
1738 dnl Check for how to set a socket to non-blocking state. There seems to exist
1739 dnl four known different ways, with the one used almost everywhere being POSIX
1740 dnl and XPG3, while the other different ways for different systems (old BSD,
1741 dnl Windows and Amiga).
1743 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1744 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1745 dnl to get caught in this script by using an excessive number of #ifdefs...
1747 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
1748 AC_MSG_CHECKING([non-blocking sockets style])
1753 /* headers for O_NONBLOCK test */
1754 #include <sys/types.h>
1758 #if defined(sun) || defined(__sun__) || \
1759 defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1760 # if defined(__SVR4) || defined(__srv4__)
1761 # define PLATFORM_SOLARIS
1763 # define PLATFORM_SUNOS4
1766 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
1767 # define PLATFORM_AIX_V3
1770 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1771 #error "O_NONBLOCK does not work on this platform"
1774 /* O_NONBLOCK source test */
1776 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1779 dnl the O_NONBLOCK test was fine
1780 nonblock="O_NONBLOCK"
1781 AC_DEFINE(HAVE_O_NONBLOCK, 1,
1782 [use O_NONBLOCK for non-blocking sockets])
1785 if test "$nonblock" = "unknown"; then
1788 /* headers for FIONBIO test */
1790 #include <stropts.h>
1792 /* FIONBIO source test (old-style unix) */
1794 int flags = ioctl(socket, FIONBIO, &flags);
1797 dnl FIONBIO test was good
1799 AC_DEFINE(HAVE_FIONBIO, 1,
1800 [use FIONBIO for non-blocking sockets])
1804 if test "$nonblock" = "unknown"; then
1807 /* headers for ioctlsocket test (Windows) */
1809 #ifdef HAVE_WINDOWS_H
1810 #ifndef WIN32_LEAN_AND_MEAN
1811 #define WIN32_LEAN_AND_MEAN
1813 #include <windows.h>
1814 #ifdef HAVE_WINSOCK2_H
1815 #include <winsock2.h>
1817 #ifdef HAVE_WINSOCK_H
1818 #include <winsock.h>
1823 /* ioctlsocket source code (Windows) */
1825 unsigned long flags = 0;
1826 sd = socket(0, 0, 0);
1827 ioctlsocket(sd, FIONBIO, &flags);
1830 dnl ioctlsocket test was good
1831 nonblock="ioctlsocket"
1832 AC_DEFINE(HAVE_IOCTLSOCKET, 1,
1833 [use ioctlsocket() for non-blocking sockets])
1837 if test "$nonblock" = "unknown"; then
1840 /* headers for IoctlSocket test (Amiga?) */
1841 #include <sys/ioctl.h>
1843 /* IoctlSocket source code (Amiga?) */
1845 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1848 dnl Ioctlsocket test was good
1849 nonblock="IoctlSocket"
1850 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
1851 [use Ioctlsocket() for non-blocking sockets])
1855 if test "$nonblock" = "unknown"; then
1858 /* headers for SO_NONBLOCK test (BeOS) */
1861 /* SO_NONBLOCK source code (BeOS) */
1864 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1867 dnl the SO_NONBLOCK test was good
1868 nonblock="SO_NONBLOCK"
1869 AC_DEFINE(HAVE_SO_NONBLOCK, 1,
1870 [use SO_NONBLOCK for non-blocking sockets])
1874 AC_MSG_RESULT($nonblock)
1876 if test "$nonblock" = "unknown"; then
1877 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
1878 [disabled non-blocking sockets])
1879 AC_MSG_WARN([non-block sockets disabled])
1885 dnl -------------------------------------------------
1886 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1887 dnl and a few other things.
1889 AC_DEFUN([TYPE_IN_ADDR_T], [
1890 AC_CHECK_TYPE([in_addr_t], ,[
1891 dnl in_addr_t not available
1892 AC_CACHE_CHECK([for in_addr_t equivalent],
1893 [curl_cv_in_addr_t_equiv], [
1894 curl_cv_in_addr_t_equiv="unknown"
1895 for t in "unsigned long" int size_t unsigned long; do
1896 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1900 #ifdef HAVE_WINDOWS_H
1901 #ifndef WIN32_LEAN_AND_MEAN
1902 #define WIN32_LEAN_AND_MEAN
1904 #include <windows.h>
1905 #ifdef HAVE_WINSOCK2_H
1906 #include <winsock2.h>
1908 #ifdef HAVE_WINSOCK_H
1909 #include <winsock.h>
1913 #ifdef HAVE_SYS_TYPES_H
1914 #include <sys/types.h>
1916 #ifdef HAVE_SYS_SOCKET_H
1917 #include <sys/socket.h>
1919 #ifdef HAVE_NETINET_IN_H
1920 #include <netinet/in.h>
1922 #ifdef HAVE_ARPA_INET_H
1923 #include <arpa/inet.h>
1927 $t data = inet_addr ("1.2.3.4");
1930 curl_cv_in_addr_t_equiv="$t"
1935 case "$curl_cv_in_addr_t_equiv" in
1937 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1940 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1941 [Type to use in place of in_addr_t when system does not provide it.])
1946 #ifdef HAVE_WINDOWS_H
1947 #ifndef WIN32_LEAN_AND_MEAN
1948 #define WIN32_LEAN_AND_MEAN
1950 #include <windows.h>
1951 #ifdef HAVE_WINSOCK2_H
1952 #include <winsock2.h>
1954 #ifdef HAVE_WINSOCK_H
1955 #include <winsock.h>
1959 #ifdef HAVE_SYS_TYPES_H
1960 #include <sys/types.h>
1962 #ifdef HAVE_SYS_SOCKET_H
1963 #include <sys/socket.h>
1965 #ifdef HAVE_NETINET_IN_H
1966 #include <netinet/in.h>
1968 #ifdef HAVE_ARPA_INET_H
1969 #include <arpa/inet.h>
1972 ]) dnl AC_CHECK_TYPE
1976 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1977 dnl -------------------------------------------------
1978 dnl Check if monotonic clock_gettime is available.
1980 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1981 AC_REQUIRE([AC_HEADER_TIME])dnl
1982 AC_CHECK_HEADERS(sys/types.h unistd.h sys/time.h time.h)
1983 AC_MSG_CHECKING([for monotonic clock_gettime])
1986 #ifdef HAVE_SYS_TYPES_H
1987 #include <sys/types.h>
1989 #ifdef HAVE_UNISTD_H
1992 #ifdef HAVE_SYS_TIME_H
1993 #include <sys/time.h>
1994 #ifdef TIME_WITH_SYS_TIME
2003 #if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK > 0)
2004 dnl The monotonic clock will not be used unless the feature test macro is
2005 dnl defined with a value greater than zero indicating _always_ supported.
2007 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2009 HAVE_CLOCK_GETTIME_MONOTONIC shall not be defined.
2013 AC_MSG_RESULT([yes])
2014 ac_cv_func_clock_gettime="yes"
2017 ac_cv_func_clock_gettime="no"
2019 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally
2020 dnl postponed until library linking checks for clock_gettime pass.
2024 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
2025 dnl -------------------------------------------------
2026 dnl If monotonic clock_gettime is available then,
2027 dnl check and prepended to LIBS any needed libraries.
2029 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
2030 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
2032 if test "$ac_cv_func_clock_gettime" = "yes"; then
2034 AC_MSG_CHECKING([for clock_gettime in libraries])
2036 curl_cv_save_LIBS="$LIBS"
2037 curl_cv_gclk_LIBS="unknown"
2039 for x_xlibs in '' '-lrt' '-lposix4' ; do
2040 if test "$curl_cv_gclk_LIBS" = "unknown"; then
2041 if test -z "$x_xlibs"; then
2042 LIBS="$curl_cv_save_LIBS"
2044 LIBS="$x_xlibs $curl_cv_save_LIBS"
2048 #ifdef HAVE_SYS_TYPES_H
2049 #include <sys/types.h>
2051 #ifdef HAVE_UNISTD_H
2054 #ifdef HAVE_SYS_TIME_H
2055 #include <sys/time.h>
2056 #ifdef TIME_WITH_SYS_TIME
2066 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2069 curl_cv_gclk_LIBS="$x_xlibs"
2074 LIBS="$curl_cv_save_LIBS"
2076 case X-"$curl_cv_gclk_LIBS" in
2078 AC_MSG_RESULT([cannot find clock_gettime])
2079 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2080 ac_cv_func_clock_gettime="no"
2083 AC_MSG_RESULT([no additional lib required])
2084 ac_cv_func_clock_gettime="yes"
2087 if test -z "$curl_cv_save_LIBS"; then
2088 LIBS="$curl_cv_gclk_LIBS"
2090 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
2092 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
2093 ac_cv_func_clock_gettime="yes"
2097 dnl only do runtime verification when not cross-compiling
2098 if test "x$cross_compiling" != "xyes" &&
2099 test "$ac_cv_func_clock_gettime" = "yes"; then
2100 AC_MSG_CHECKING([if monotonic clock_gettime works])
2103 #ifdef HAVE_SYS_TYPES_H
2104 #include <sys/types.h>
2106 #ifdef HAVE_UNISTD_H
2109 #ifdef HAVE_SYS_TIME_H
2110 #include <sys/time.h>
2111 #ifdef TIME_WITH_SYS_TIME
2120 #if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK > 0)
2122 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
2128 AC_MSG_RESULT([yes])
2131 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2132 ac_cv_func_clock_gettime="no"
2133 LIBS="$curl_cv_save_LIBS"
2137 case "$ac_cv_func_clock_gettime" in
2139 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
2140 [Define to 1 if you have the clock_gettime function and monotonic timer.])
2149 dnl CURL_CHECK_FUNC_SELECT
2150 dnl -------------------------------------------------
2151 dnl Test if the socket select() function is available,
2152 dnl and check its return type and the types of its
2153 dnl arguments. If the function succeeds HAVE_SELECT
2154 dnl will be defined, defining the types of the
2155 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
2156 dnl and SELECT_TYPE_ARG5, defining the type of the
2157 dnl function return value in SELECT_TYPE_RETV, and
2158 dnl also defining the type qualifier of fifth argument
2159 dnl in SELECT_QUAL_ARG5.
2161 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
2162 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
2163 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
2165 AC_MSG_CHECKING([for select])
2169 #ifdef HAVE_WINDOWS_H
2170 #ifndef WIN32_LEAN_AND_MEAN
2171 #define WIN32_LEAN_AND_MEAN
2173 #include <windows.h>
2174 #ifdef HAVE_WINSOCK2_H
2175 #include <winsock2.h>
2177 #ifdef HAVE_WINSOCK_H
2178 #include <winsock.h>
2182 #ifdef HAVE_SYS_TYPES_H
2183 #include <sys/types.h>
2185 #ifdef HAVE_SYS_TIME_H
2186 #include <sys/time.h>
2187 #ifdef TIME_WITH_SYS_TIME
2195 #ifndef HAVE_WINDOWS_H
2196 #ifdef HAVE_SYS_SELECT_H
2197 #include <sys/select.h>
2199 #ifdef HAVE_SYS_SOCKET_H
2200 #include <sys/socket.h>
2204 select(0, 0, 0, 0, 0);
2207 AC_MSG_RESULT([yes])
2208 curl_cv_select="yes"
2214 if test "$curl_cv_select" = "yes"; then
2215 AC_CACHE_CHECK([types of args and return type for select],
2216 [curl_cv_func_select_args], [
2217 curl_cv_func_select_args="unknown"
2218 for sel_retv in 'int' 'ssize_t'; do
2219 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2220 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2221 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2222 if test "$curl_cv_func_select_args" = "unknown"; then
2226 #ifdef HAVE_WINDOWS_H
2227 #ifndef WIN32_LEAN_AND_MEAN
2228 #define WIN32_LEAN_AND_MEAN
2230 #include <windows.h>
2231 #ifdef HAVE_WINSOCK2_H
2232 #include <winsock2.h>
2234 #ifdef HAVE_WINSOCK_H
2235 #include <winsock.h>
2238 #define SELECTCALLCONV PASCAL
2240 #ifdef HAVE_SYS_TYPES_H
2241 #include <sys/types.h>
2243 #ifdef HAVE_SYS_TIME_H
2244 #include <sys/time.h>
2245 #ifdef TIME_WITH_SYS_TIME
2253 #ifndef HAVE_WINDOWS_H
2254 #ifdef HAVE_SYS_SELECT_H
2255 #include <sys/select.h>
2257 #ifdef HAVE_SYS_SOCKET_H
2258 #include <sys/socket.h>
2260 #define SELECTCALLCONV
2262 #ifndef HAVE_STRUCT_TIMEVAL
2268 extern $sel_retv SELECTCALLCONV select($sel_arg1,
2278 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2281 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2289 if test "$curl_cv_func_select_args" = "unknown"; then
2290 AC_MSG_WARN([Cannot find proper types to use for select args])
2291 AC_MSG_WARN([HAVE_SELECT will not be defined])
2293 select_prev_IFS=$IFS; IFS=','
2294 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2295 IFS=$select_prev_IFS
2298 sel_qual_type_arg5=$[3]
2300 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2301 [Define to the type of arg 1 for select.])
2302 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2303 [Define to the type of args 2, 3 and 4 for select.])
2304 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2305 [Define to the function return type for select.])
2309 case $prev_sh_opts in
2317 case "$sel_qual_type_arg5" in
2320 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2324 sel_type_arg5=$sel_qual_type_arg5
2328 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2329 [Define to the type qualifier of arg 5 for select.])
2330 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2331 [Define to the type of arg 5 for select.])
2333 case $prev_sh_opts in
2341 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2342 [Define to 1 if you have the select function.])
2343 ac_cv_func_select="yes"
2349 dnl ************************************************************
2350 dnl check for "localhost", if it doesn't exist, we can't do the
2351 dnl gethostbyname_r tests!
2354 AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[
2355 AC_MSG_CHECKING([if "localhost" resolves])
2358 #include <sys/types.h>
2361 #define NULL (void *)0
2367 h = gethostbyname("localhost");
2368 exit (h == NULL ? 1 : 0); }],[
2369 AC_MSG_RESULT(yes)],[
2371 AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
2377 dnl ************************************************************
2378 dnl check for working getaddrinfo() that works with AI_NUMERICHOST
2380 AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
2381 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
2384 #include <sys/types.h>
2385 #include <sys/socket.h>
2389 struct addrinfo hints, *ai;
2392 memset(&hints, 0, sizeof(hints));
2393 hints.ai_flags = AI_NUMERICHOST;
2394 hints.ai_family = AF_UNSPEC;
2395 hints.ai_socktype = SOCK_STREAM;
2396 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
2403 ac_cv_working_getaddrinfo="yes"
2405 ac_cv_working_getaddrinfo="no"
2407 ac_cv_working_getaddrinfo="yes"
2409 if test "$ac_cv_working_getaddrinfo" = "yes"; then
2410 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
2411 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
2414 AC_SUBST(IPV6_ENABLED)
2419 AC_DEFUN([CURL_CHECK_LOCALTIME_R],
2421 dnl check for localtime_r
2422 AC_CHECK_FUNCS(localtime_r,[
2423 AC_MSG_CHECKING(whether localtime_r is declared)
2424 AC_EGREP_CPP(localtime_r,[
2425 #include <time.h>],[
2426 AC_MSG_RESULT(yes)],[
2428 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
2429 AC_EGREP_CPP(localtime_r,[
2431 #include <time.h>],[
2432 AC_DEFINE(NEED_REENTRANT)
2433 AC_MSG_RESULT(yes)],
2434 AC_MSG_RESULT(no))])])
2438 dnl This function checks for strerror_r(). If it isn't found at first, it
2439 dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
2440 dnl in order to find this function.
2442 dnl If the function is found, it will then proceed to check how the function
2443 dnl actually works: glibc-style or POSIX-style.
2446 dnl char *strerror_r(int errnum, char *buf, size_t n);
2448 dnl What this one does is to return the error string (no surprises there),
2449 dnl but it doesn't usually copy anything into buf! The 'buf' and 'n'
2450 dnl parameters are only meant as an optional working area, in case strerror_r
2451 dnl needs it. A quick test on a few systems shows that it's generally not
2455 dnl int strerror_r(int errnum, char *buf, size_t n);
2457 AC_DEFUN([CURL_CHECK_STRERROR_R],
2459 AC_CHECK_FUNCS(strerror_r)
2461 if test "x$ac_cv_func_strerror_r" = "xyes"; then
2463 AC_MSG_CHECKING(whether strerror_r is declared)
2464 AC_EGREP_CPP(strerror_r,[
2465 #include <string.h>],[
2466 AC_MSG_RESULT(yes)],[
2468 AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
2469 AC_EGREP_CPP(strerror_r,[
2471 #include <string.h>],[
2472 CPPFLAGS="-D_REENTRANT $CPPFLAGS"
2473 AC_MSG_RESULT(yes)],
2475 AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
2476 ) dnl with _THREAD_SAFE
2477 ]) dnl plain cpp for it
2479 dnl determine if this strerror_r() is glibc or POSIX
2480 AC_MSG_CHECKING([for a glibc strerror_r API])
2486 char buffer[1024]; /* big enough to play with */
2488 strerror_r(EACCES, buffer, sizeof(buffer));
2489 /* this should've returned a string */
2490 if(!string || !string[0])
2495 GLIBC_STRERROR_R="1"
2496 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2497 AC_MSG_RESULT([yes]),
2498 AC_MSG_RESULT([no]),
2500 dnl Use an inferior method of strerror_r detection while cross-compiling
2502 #include <features.h>
2507 dnl looks like glibc, so assume a glibc-style strerror_r()
2508 GLIBC_STRERROR_R="1"
2509 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2510 AC_MSG_RESULT([yes]),
2511 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2512 ) dnl while cross-compiling
2515 if test -z "$GLIBC_STRERROR_R"; then
2517 AC_MSG_CHECKING([for a POSIX strerror_r API])
2523 char buffer[1024]; /* big enough to play with */
2525 strerror_r(EACCES, buffer, sizeof(buffer));
2526 /* This should've returned zero, and written an error string in the
2528 if(!buffer[0] || error)
2533 AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
2534 AC_MSG_RESULT([yes]),
2535 AC_MSG_RESULT([no]) ,
2536 dnl cross-compiling!
2537 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2540 fi dnl if not using glibc API
2542 fi dnl we have a strerror_r
2546 AC_DEFUN([CURL_CHECK_INET_NTOA_R],
2548 dnl determine if function definition for inet_ntoa_r exists.
2549 AC_CHECK_FUNCS(inet_ntoa_r,[
2550 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
2551 AC_EGREP_CPP(inet_ntoa_r,[
2552 #include <arpa/inet.h>],[
2553 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2554 AC_MSG_RESULT(yes)],[
2556 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
2557 AC_EGREP_CPP(inet_ntoa_r,[
2559 #include <arpa/inet.h>],[
2560 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2561 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT defined])
2562 AC_MSG_RESULT(yes)],
2563 AC_MSG_RESULT(no))])])
2567 dnl CURL_CHECK_GETHOSTBYADDR_R
2568 dnl -------------------------------------------------
2569 dnl check number of arguments for gethostbyaddr_r, it
2570 dnl might take either 5, 7, or 8 arguments.
2572 AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R], [
2574 AC_MSG_CHECKING([for gethostbyaddr_r])
2576 AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
2578 AC_MSG_RESULT([yes])
2579 tmp_cv_gethostbyaddr_r="yes"
2582 tmp_cv_gethostbyaddr_r="no"
2585 if test "$tmp_cv_gethostbyaddr_r" != "yes"; then
2586 AC_MSG_CHECKING([deeper for gethostbyaddr_r])
2593 AC_MSG_RESULT([yes])
2594 tmp_cv_gethostbyaddr_r="yes"
2596 AC_MSG_RESULT([but still no])
2597 tmp_cv_gethostbyaddr_r="no"
2601 if test "$tmp_cv_gethostbyaddr_r" = "yes"; then
2603 ac_cv_gethostbyaddr_r_args="unknown"
2605 AC_MSG_CHECKING([if gethostbyaddr_r takes 5 arguments])
2608 #include <sys/types.h>
2615 struct hostent_data hdata;
2617 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2620 AC_MSG_RESULT([yes])
2621 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2622 ac_cv_gethostbyaddr_r_args="5"
2627 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2628 AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 5 arguments])
2632 #include <sys/types.h>
2639 struct hostent_data hdata;
2641 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2644 AC_MSG_RESULT([yes])
2645 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2646 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
2647 ac_cv_gethostbyaddr_r_args="5"
2653 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2654 AC_MSG_CHECKING([if gethostbyaddr_r takes 7 arguments])
2657 #include <sys/types.h>
2666 struct hostent * hp;
2667 hp = gethostbyaddr_r(address, length, type, &h,
2668 buffer, 8192, &h_errnop);
2671 AC_MSG_RESULT([yes])
2672 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2673 ac_cv_gethostbyaddr_r_args="7"
2679 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2680 AC_MSG_CHECKING([if gethostbyaddr_r takes 8 arguments])
2683 #include <sys/types.h>
2692 struct hostent * hp;
2694 rc = gethostbyaddr_r(address, length, type, &h,
2695 buffer, 8192, &hp, &h_errnop);
2698 AC_MSG_RESULT([yes])
2699 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
2700 ac_cv_gethostbyaddr_r_args="8"
2706 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2707 AC_MSG_WARN([Cannot find out how to use gethostbyaddr_r])
2708 AC_MSG_WARN([HAVE_GETHOSTBYADDR_R will not be defined])
2709 ac_cv_func_gethostbyaddr_r="no"
2711 AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
2712 [Define to 1 if you have the gethostbyaddr_r function.])
2713 ac_cv_func_gethostbyaddr_r="yes"
2717 ac_cv_func_gethostbyaddr_r="no"
2722 dnl CURL_CHECK_GETHOSTBYNAME_R
2723 dnl -------------------------------------------------
2724 dnl check number of arguments for gethostbyname_r, it
2725 dnl might take either 3, 5, or 6 arguments.
2727 AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R], [
2729 AC_MSG_CHECKING([for gethostbyname_r])
2731 AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
2733 AC_MSG_RESULT([yes])
2734 tmp_cv_gethostbyname_r="yes"
2737 tmp_cv_gethostbyname_r="no"
2740 if test "$tmp_cv_gethostbyname_r" != "yes"; then
2741 AC_MSG_CHECKING([deeper for gethostbyname_r])
2748 AC_MSG_RESULT([yes])
2749 tmp_cv_gethostbyname_r="yes"
2751 AC_MSG_RESULT([but still no])
2752 tmp_cv_gethostbyname_r="no"
2756 if test "$tmp_cv_gethostbyname_r" = "yes"; then
2758 ac_cv_gethostbyname_r_args="unknown"
2760 AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
2764 #include <sys/types.h>
2767 #define NULL (void *)0
2769 gethostbyname_r(const char *, struct hostent *,
2770 struct hostent_data *);
2772 struct hostent_data data;
2773 gethostbyname_r(NULL, NULL, NULL);
2776 AC_MSG_RESULT([yes])
2777 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2778 ac_cv_gethostbyname_r_args="3"
2783 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2784 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
2789 #include <sys/types.h>
2792 #define NULL (void *)0
2794 gethostbyname_r(const char *, struct hostent *,
2795 struct hostent_data *);
2797 struct hostent_data data;
2798 gethostbyname_r(NULL, NULL, NULL);
2801 AC_MSG_RESULT([yes])
2802 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2803 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
2804 ac_cv_gethostbyname_r_args="3"
2810 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2811 AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
2814 #include <sys/types.h>
2817 #define NULL (void *)0
2819 gethostbyname_r(const char *, struct hostent *,
2820 char *, int, int *);
2822 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
2825 AC_MSG_RESULT([yes])
2826 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
2827 ac_cv_gethostbyname_r_args="5"
2833 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2834 AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
2837 #include <sys/types.h>
2840 #define NULL (void *)0
2842 gethostbyname_r(const char *, struct hostent *,
2843 char *, size_t, struct hostent **, int *);
2845 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
2848 AC_MSG_RESULT([yes])
2849 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
2850 ac_cv_gethostbyname_r_args="6"
2856 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2857 AC_MSG_WARN([Cannot find out how to use gethostbyname_r])
2858 AC_MSG_WARN([HAVE_GETHOSTBYNAME_R will not be defined])
2859 ac_cv_func_gethostbyname_r="no"
2861 AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
2862 [Define to 1 if you have the gethostbyname_r function.])
2863 ac_cv_func_gethostbyname_r="yes"
2867 ac_cv_func_gethostbyname_r="no"
2872 dnl **********************************************************************
2873 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
2875 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
2876 dnl sets the $ICC variable to "yes" or "no"
2877 dnl **********************************************************************
2878 AC_DEFUN([CURL_DETECT_ICC],
2881 AC_MSG_CHECKING([for icc in use])
2882 if test "$GCC" = "yes"; then
2883 dnl check if this is icc acting as gcc in disguise
2884 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
2885 dnl action if the text is found, this it has not been replaced by the
2888 dnl the text was not found, it was replaced by the cpp
2890 AC_MSG_RESULT([yes])
2894 if test "$ICC" = "no"; then
2900 dnl We create a function for detecting which compiler we use and then set as
2901 dnl pendantic compiler options as possible for that particular compiler. The
2902 dnl options are only used for debug-builds.
2904 AC_DEFUN([CURL_CC_DEBUG_OPTS],
2906 if test "z$ICC" = "z"; then
2910 if test "$GCC" = "yes"; then
2912 dnl figure out gcc version!
2913 AC_MSG_CHECKING([gcc version])
2914 gccver=`$CC -dumpversion`
2915 num1=`echo $gccver | cut -d . -f1`
2916 num2=`echo $gccver | cut -d . -f2`
2917 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
2918 AC_MSG_RESULT($gccver)
2920 if test "$ICC" = "yes"; then
2921 dnl this is icc, not gcc.
2923 dnl ICC warnings we ignore:
2924 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
2925 dnl "invalid format string conversion"
2926 dnl * 279 warns on static conditions in while expressions
2927 dnl * 981 warns on "operands are evaluated in unspecified order"
2928 dnl * 1418 "external definition with no prior declaration"
2929 dnl * 1419 warns on "external declaration in primary source file"
2930 dnl which we know and do on purpose.
2932 WARN="-wd279,269,981,1418,1419"
2934 if test "$gccnum" -gt "600"; then
2935 dnl icc 6.0 and older doesn't have the -Wall flag
2939 dnl this is a set of options we believe *ALL* gcc versions support:
2940 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
2942 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
2944 if test "$gccnum" -ge "207"; then
2945 dnl gcc 2.7 or later
2946 WARN="$WARN -Wmissing-declarations"
2949 if test "$gccnum" -gt "295"; then
2950 dnl only if the compiler is newer than 2.95 since we got lots of
2951 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
2952 dnl gcc 2.95.4 on FreeBSD 4.9!
2953 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
2956 if test "$gccnum" -ge "296"; then
2957 dnl gcc 2.96 or later
2958 WARN="$WARN -Wfloat-equal"
2961 if test "$gccnum" -gt "296"; then
2962 dnl this option does not exist in 2.96
2963 WARN="$WARN -Wno-format-nonliteral"
2966 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
2967 dnl on i686-Linux as it gives us heaps with false positives.
2968 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
2969 dnl over making it unusable for generic purposes. Let's not use it.
2971 if test "$gccnum" -ge "303"; then
2972 dnl gcc 3.3 and later
2973 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
2976 if test "$gccnum" -ge "304"; then
2977 # try these on gcc 3.4
2978 WARN="$WARN -Wdeclaration-after-statement"
2981 for flag in $CPPFLAGS; do
2984 dnl Include path, provide a -isystem option for the same dir
2985 dnl to prevent warnings in those dirs. The -isystem was not very
2986 dnl reliable on earlier gcc versions.
2987 add=`echo $flag | sed 's/^-I/-isystem /g'`
2995 CFLAGS="$CFLAGS $WARN"
2997 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
3001 AC_MSG_NOTICE([Added no extra compiler options])
3005 dnl strip off optimizer flags
3007 for flag in $CFLAGS; do
3010 dnl echo "cut off $flag"
3013 NEWFLAGS="$NEWFLAGS $flag"
3019 ]) dnl end of AC_DEFUN()
3021 # This is only a temporary fix. This macro is here to replace the broken one
3022 # delivered by the automake project (including the 1.9.6 release). As soon as
3023 # they ship a working version we SHOULD remove this work-around.
3025 AC_DEFUN([AM_MISSING_HAS_RUN],
3026 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
3027 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
3028 # Use eval to expand $SHELL
3029 if eval "$MISSING --run true"; then
3030 am_missing_run="$MISSING --run "
3033 AC_MSG_WARN([`missing' script is too old or missing])
3038 dnl CURL_VERIFY_RUNTIMELIBS
3039 dnl -------------------------------------------------
3040 dnl Verify that the shared libs found so far can be used when running
3041 dnl programs, since otherwise the situation will create odd configure errors
3042 dnl that are misleading people.
3044 dnl Make sure this test is run BEFORE the first test in the script that
3045 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
3046 dnl macro. It must also run AFTER all lib-checking macros are complete.
3048 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
3050 dnl this test is of course not sensible if we are cross-compiling!
3051 if test "x$cross_compiling" != xyes; then
3053 dnl just run a program to verify that the libs checked for previous to this
3054 dnl point also is available run-time!
3055 AC_MSG_CHECKING([run-time libs availability])
3062 AC_MSG_RESULT([fine]),
3063 AC_MSG_RESULT([failed])
3064 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
3067 dnl if this test fails, configure has already stopped
3072 dnl CURL_CHECK_VARIADIC_MACROS
3073 dnl -------------------------------------------------
3074 dnl Check compiler support of variadic macros
3076 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
3077 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
3078 [curl_cv_variadic_macros_c99], [
3081 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
3082 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
3083 int fun3(int arg1, int arg2, int arg3);
3084 int fun2(int arg1, int arg2);
3085 int fun3(int arg1, int arg2, int arg3)
3086 { return arg1 + arg2 + arg3; }
3087 int fun2(int arg1, int arg2)
3088 { return arg1 + arg2; }
3090 int res3 = c99_vmacro3(1, 2, 3);
3091 int res2 = c99_vmacro2(1, 2);
3094 curl_cv_variadic_macros_c99="yes"
3096 curl_cv_variadic_macros_c99="no"
3099 case "$curl_cv_variadic_macros_c99" in
3101 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
3102 [Define to 1 if compiler supports C99 variadic macro style.])
3105 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
3106 [curl_cv_variadic_macros_gcc], [
3109 #define gcc_vmacro3(first, args...) fun3(first, args)
3110 #define gcc_vmacro2(first, args...) fun2(first, args)
3111 int fun3(int arg1, int arg2, int arg3);
3112 int fun2(int arg1, int arg2);
3113 int fun3(int arg1, int arg2, int arg3)
3114 { return arg1 + arg2 + arg3; }
3115 int fun2(int arg1, int arg2)
3116 { return arg1 + arg2; }
3118 int res3 = gcc_vmacro3(1, 2, 3);
3119 int res2 = gcc_vmacro2(1, 2);
3122 curl_cv_variadic_macros_gcc="yes"
3124 curl_cv_variadic_macros_gcc="no"
3127 case "$curl_cv_variadic_macros_gcc" in
3129 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
3130 [Define to 1 if compiler supports old gcc variadic macro style.])
3136 dnl CURL_CHECK_CA_BUNDLE
3137 dnl -------------------------------------------------
3138 dnl Check if a default ca-bundle should be used
3140 dnl regarding the paths this will scan:
3141 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
3142 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
3143 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
3144 dnl /etc/ssl/certs/ (ca path) SUSE
3146 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
3148 AC_MSG_CHECKING([default CA cert bundle/path])
3150 AC_ARG_WITH(ca-bundle,
3151 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
3152 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
3155 if test "x$want_ca" = "xyes"; then
3156 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
3159 [ want_ca="unset" ])
3160 AC_ARG_WITH(ca-path,
3161 AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
3162 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
3164 want_capath="$withval"
3165 if test "x$want_capath" = "xyes"; then
3166 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
3169 [ want_capath="unset"])
3171 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
3172 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
3174 AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
3175 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
3176 dnl --with-ca-bundle given
3179 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
3180 dnl --with-ca-path given
3181 if test "x$OPENSSL_ENABLED" != "x1"; then
3182 AC_MSG_ERROR([--with-ca-path only works with openSSL])
3184 capath="$want_capath"
3187 dnl neither of --with-ca-* given
3188 dnl first try autodetecting a CA bundle , then a CA path
3189 dnl both autodetections can be skipped by --without-ca-*
3192 if test "x$want_ca" = "xunset"; then
3193 dnl the path we previously would have installed the curl ca bundle
3194 dnl to, and thus we now check for an already existing cert in that place
3195 dnl in case we find no other
3196 if test "x$prefix" != xNONE; then
3197 cac="${prefix}/share/curl/curl-ca-bundle.crt"
3199 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
3202 for a in /etc/ssl/certs/ca-certificates.crt \
3203 /etc/pki/tls/certs/ca-bundle.crt \
3204 /usr/share/ssl/certs/ca-bundle.crt \
3206 if test -f "$a"; then
3212 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
3213 "x$OPENSSL_ENABLED" = "x1"; then
3214 for a in /etc/ssl/certs/; do
3215 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
3225 if test "x$ca" != "xno"; then
3226 CURL_CA_BUNDLE='"'$ca'"'
3227 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
3228 AC_SUBST(CURL_CA_BUNDLE)
3229 AC_MSG_RESULT([$ca])
3230 elif test "x$capath" != "xno"; then
3231 CURL_CA_PATH="\"$capath\""
3232 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
3233 AC_MSG_RESULT([$capath (capath)])