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__)
78 Not a native Windows build target.
82 ac_cv_native_windows="yes"
84 ac_cv_native_windows="no"
88 case "$ac_cv_native_windows" in
90 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
91 [Define to 1 if you are building a native Windows target.])
97 dnl CURL_CHECK_HEADER_WINSOCK
98 dnl -------------------------------------------------
99 dnl Check for compilable and valid winsock.h header
101 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
102 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
103 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
107 #ifndef WIN32_LEAN_AND_MEAN
108 #define WIN32_LEAN_AND_MEAN
113 #if defined(__CYGWIN__) || defined(__CEGCC__)
114 HAVE_WINSOCK_H shall not be defined.
116 int dummy=WSACleanup();
120 ac_cv_header_winsock_h="yes"
122 ac_cv_header_winsock_h="no"
125 case "$ac_cv_header_winsock_h" in
127 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
128 [Define to 1 if you have the winsock.h header file.])
134 dnl CURL_CHECK_HEADER_WINSOCK2
135 dnl -------------------------------------------------
136 dnl Check for compilable and valid winsock2.h header
138 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
139 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
140 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
144 #ifndef WIN32_LEAN_AND_MEAN
145 #define WIN32_LEAN_AND_MEAN
148 #include <winsock2.h>
150 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
151 HAVE_WINSOCK2_H shall not be defined.
153 int dummy=2*IPPROTO_ESP;
157 ac_cv_header_winsock2_h="yes"
159 ac_cv_header_winsock2_h="no"
162 case "$ac_cv_header_winsock2_h" in
164 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
165 [Define to 1 if you have the winsock2.h header file.])
171 dnl CURL_CHECK_HEADER_WS2TCPIP
172 dnl -------------------------------------------------
173 dnl Check for compilable and valid ws2tcpip.h header
175 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
176 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
177 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
181 #ifndef WIN32_LEAN_AND_MEAN
182 #define WIN32_LEAN_AND_MEAN
185 #include <winsock2.h>
186 #include <ws2tcpip.h>
188 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
189 HAVE_WS2TCPIP_H shall not be defined.
191 int dummy=2*IP_PKTINFO;
195 ac_cv_header_ws2tcpip_h="yes"
197 ac_cv_header_ws2tcpip_h="no"
200 case "$ac_cv_header_ws2tcpip_h" in
202 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
203 [Define to 1 if you have the ws2tcpip.h header file.])
209 dnl CURL_CHECK_HEADER_WINLDAP
210 dnl -------------------------------------------------
211 dnl Check for compilable and valid winldap.h header
213 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
214 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
215 AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
219 #ifdef HAVE_WINDOWS_H
220 #ifndef WIN32_LEAN_AND_MEAN
221 #define WIN32_LEAN_AND_MEAN
227 #if defined(__CYGWIN__) || defined(__CEGCC__)
228 HAVE_WINLDAP_H shall not be defined.
230 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
231 ULONG res = ldap_unbind(ldp);
235 ac_cv_header_winldap_h="yes"
237 ac_cv_header_winldap_h="no"
240 case "$ac_cv_header_winldap_h" in
242 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
243 [Define to 1 if you have the winldap.h header file.])
249 dnl CURL_CHECK_HEADER_WINBER
250 dnl -------------------------------------------------
251 dnl Check for compilable and valid winber.h header
253 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
254 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
255 AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
259 #ifdef HAVE_WINDOWS_H
260 #ifndef WIN32_LEAN_AND_MEAN
261 #define WIN32_LEAN_AND_MEAN
268 #if defined(__CYGWIN__) || defined(__CEGCC__)
269 HAVE_WINBER_H shall not be defined.
272 BerElement *bep = ber_init(bvp);
277 ac_cv_header_winber_h="yes"
279 ac_cv_header_winber_h="no"
282 case "$ac_cv_header_winber_h" in
284 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
285 [Define to 1 if you have the winber.h header file.])
291 dnl CURL_CHECK_HEADER_LBER
292 dnl -------------------------------------------------
293 dnl Check for compilable and valid lber.h header,
294 dnl and check if it is needed even with ldap.h
296 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
297 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
298 AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
302 #ifdef HAVE_WINDOWS_H
303 #ifndef WIN32_LEAN_AND_MEAN
304 #define WIN32_LEAN_AND_MEAN
308 #ifdef HAVE_SYS_TYPES_H
309 #include <sys/types.h>
313 #define NULL (void *)0
317 BerValue *bvp = NULL;
318 BerElement *bep = ber_init(bvp);
322 ac_cv_header_lber_h="yes"
324 ac_cv_header_lber_h="no"
327 if test "$ac_cv_header_lber_h" = "yes"; then
328 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
329 [Define to 1 if you have the lber.h header file.])
334 #ifdef HAVE_WINDOWS_H
335 #ifndef WIN32_LEAN_AND_MEAN
336 #define WIN32_LEAN_AND_MEAN
340 #ifdef HAVE_SYS_TYPES_H
341 #include <sys/types.h>
345 #define NULL (void *)0
347 #ifndef LDAP_DEPRECATED
348 #define LDAP_DEPRECATED 1
352 BerValue *bvp = NULL;
353 BerElement *bep = ber_init(bvp);
357 curl_cv_need_header_lber_h="no"
359 curl_cv_need_header_lber_h="yes"
362 case "$curl_cv_need_header_lber_h" in
364 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
365 [Define to 1 if you need the lber.h header file even with ldap.h])
372 dnl CURL_CHECK_HEADER_LDAP
373 dnl -------------------------------------------------
374 dnl Check for compilable and valid ldap.h header
376 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
377 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
378 AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
382 #ifdef HAVE_WINDOWS_H
383 #ifndef WIN32_LEAN_AND_MEAN
384 #define WIN32_LEAN_AND_MEAN
388 #ifdef HAVE_SYS_TYPES_H
389 #include <sys/types.h>
392 #ifndef LDAP_DEPRECATED
393 #define LDAP_DEPRECATED 1
400 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
401 int res = ldap_unbind(ldp);
404 ac_cv_header_ldap_h="yes"
406 ac_cv_header_ldap_h="no"
409 case "$ac_cv_header_ldap_h" in
411 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
412 [Define to 1 if you have the ldap.h header file.])
418 dnl CURL_CHECK_HEADER_LDAP_SSL
419 dnl -------------------------------------------------
420 dnl Check for compilable and valid ldap_ssl.h header
422 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
423 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
424 AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
428 #ifdef HAVE_WINDOWS_H
429 #ifndef WIN32_LEAN_AND_MEAN
430 #define WIN32_LEAN_AND_MEAN
434 #ifdef HAVE_SYS_TYPES_H
435 #include <sys/types.h>
438 #ifndef LDAP_DEPRECATED
439 #define LDAP_DEPRECATED 1
447 #include <ldap_ssl.h>
449 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
452 ac_cv_header_ldap_ssl_h="yes"
454 ac_cv_header_ldap_ssl_h="no"
457 case "$ac_cv_header_ldap_ssl_h" in
459 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
460 [Define to 1 if you have the ldap_ssl.h header file.])
466 dnl CURL_CHECK_HEADER_LDAPSSL
467 dnl -------------------------------------------------
468 dnl Check for compilable and valid ldapssl.h header
470 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
471 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
472 AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
476 #ifdef HAVE_WINDOWS_H
477 #ifndef WIN32_LEAN_AND_MEAN
478 #define WIN32_LEAN_AND_MEAN
482 #ifdef HAVE_SYS_TYPES_H
483 #include <sys/types.h>
487 #define NULL (void *)0
489 #ifndef LDAP_DEPRECATED
490 #define LDAP_DEPRECATED 1
500 char *cert_label = NULL;
501 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
504 ac_cv_header_ldapssl_h="yes"
506 ac_cv_header_ldapssl_h="no"
509 case "$ac_cv_header_ldapssl_h" in
511 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
512 [Define to 1 if you have the ldapssl.h header file.])
518 dnl CURL_CHECK_LIBS_WINLDAP
519 dnl -------------------------------------------------
520 dnl Check for libraries needed for WINLDAP support,
521 dnl and prepended to LIBS any needed libraries.
522 dnl This macro can take an optional parameter with a
523 dnl white space separated list of libraries to check
524 dnl before the WINLDAP default ones.
526 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
527 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
529 AC_MSG_CHECKING([for WINLDAP libraries])
543 if test -z "$u_libs"; then
546 u_libs="$u_libs $l_lib"
551 curl_cv_save_LIBS="$LIBS"
552 curl_cv_ldap_LIBS="unknown"
554 for x_nlibs in '' "$u_libs" \
556 if test -z "$x_nlibs"; then
557 LIBS="$curl_cv_save_LIBS"
559 LIBS="$x_nlibs $curl_cv_save_LIBS"
564 #ifdef HAVE_WINDOWS_H
565 #ifndef WIN32_LEAN_AND_MEAN
566 #define WIN32_LEAN_AND_MEAN
569 #ifdef HAVE_WINLDAP_H
578 BerElement *bep = ber_init(bvp);
579 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
580 ULONG res = ldap_unbind(ldp);
584 curl_cv_ldap_LIBS="$x_nlibs"
589 LIBS="$curl_cv_save_LIBS"
591 case X-"$curl_cv_ldap_LIBS" in
593 AC_MSG_RESULT([cannot find WINLDAP libraries])
596 AC_MSG_RESULT([no additional lib required])
599 if test -z "$curl_cv_save_LIBS"; then
600 LIBS="$curl_cv_ldap_LIBS"
602 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
604 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
611 dnl CURL_CHECK_LIBS_LDAP
612 dnl -------------------------------------------------
613 dnl Check for libraries needed for LDAP support,
614 dnl and prepended to LIBS any needed libraries.
615 dnl This macro can take an optional parameter with a
616 dnl white space separated list of libraries to check
617 dnl before the default ones.
619 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
620 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
622 AC_MSG_CHECKING([for LDAP libraries])
636 if test -z "$u_libs"; then
639 u_libs="$u_libs $l_lib"
644 curl_cv_save_LIBS="$LIBS"
645 curl_cv_ldap_LIBS="unknown"
647 for x_nlibs in '' "$u_libs" \
651 '-lldapssl -lldapx -lldapsdk' \
652 '-lldapsdk -lldapx -lldapssl' ; do
653 if test -z "$x_nlibs"; then
654 LIBS="$curl_cv_save_LIBS"
656 LIBS="$x_nlibs $curl_cv_save_LIBS"
661 #ifdef HAVE_WINDOWS_H
662 #ifndef WIN32_LEAN_AND_MEAN
663 #define WIN32_LEAN_AND_MEAN
667 #ifdef HAVE_SYS_TYPES_H
668 #include <sys/types.h>
672 #define NULL (void *)0
674 #ifndef LDAP_DEPRECATED
675 #define LDAP_DEPRECATED 1
684 BerValue *bvp = NULL;
685 BerElement *bep = ber_init(bvp);
686 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
687 int res = ldap_unbind(ldp);
691 curl_cv_ldap_LIBS="$x_nlibs"
696 LIBS="$curl_cv_save_LIBS"
698 case X-"$curl_cv_ldap_LIBS" in
700 AC_MSG_RESULT([cannot find LDAP libraries])
703 AC_MSG_RESULT([no additional lib required])
706 if test -z "$curl_cv_save_LIBS"; then
707 LIBS="$curl_cv_ldap_LIBS"
709 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
711 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
718 dnl CURL_CHECK_HEADER_MALLOC
719 dnl -------------------------------------------------
720 dnl Check for compilable and valid malloc.h header,
721 dnl and check if it is needed even with stdlib.h
723 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
724 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
729 void *p = malloc(10);
730 void *q = calloc(10,10);
735 ac_cv_header_malloc_h="yes"
737 ac_cv_header_malloc_h="no"
740 if test "$ac_cv_header_malloc_h" = "yes"; then
741 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
742 [Define to 1 if you have the malloc.h header file.])
748 void *p = malloc(10);
749 void *q = calloc(10,10);
754 curl_cv_need_header_malloc_h="no"
756 curl_cv_need_header_malloc_h="yes"
759 case "$curl_cv_need_header_malloc_h" in
761 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
762 [Define to 1 if you need the malloc.h header file even with stdlib.h])
769 dnl CURL_CHECK_TYPE_SOCKLEN_T
770 dnl -------------------------------------------------
771 dnl Check for existing socklen_t type, and provide
772 dnl an equivalent type if socklen_t not available
774 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
775 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
776 AC_CHECK_TYPE([socklen_t], [
777 dnl socklen_t is available
778 AC_DEFINE_UNQUOTED(HAVE_SOCKLEN_T, 1,
779 [Define to 1 if socklen_t is available or a equivalent is defined.])
781 dnl socklen_t not available
782 AC_CACHE_CHECK([for socklen_t equivalent],
783 [curl_cv_socklen_t_equiv], [
784 curl_cv_socklen_t_equiv="unknown"
785 for arg1 in 'int' 'SOCKET'; do
786 for arg2 in "struct sockaddr" void; do
787 for t in int size_t unsigned long "unsigned long"; do
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 if not defined])
833 AC_DEFINE_UNQUOTED(HAVE_SOCKLEN_T, 1,
834 [Define to 1 if socklen_t is available or a equivalent is defined.])
839 #ifdef HAVE_WINDOWS_H
840 #ifndef WIN32_LEAN_AND_MEAN
841 #define WIN32_LEAN_AND_MEAN
844 #ifdef HAVE_WINSOCK2_H
845 #include <winsock2.h>
846 #ifdef HAVE_WS2TCPIP_H
847 #include <ws2tcpip.h>
851 #ifdef HAVE_SYS_TYPES_H
852 #include <sys/types.h>
854 #ifdef HAVE_SYS_SOCKET_H
855 #include <sys/socket.h>
862 dnl CURL_CHECK_FUNC_GETNAMEINFO
863 dnl -------------------------------------------------
864 dnl Test if the getnameinfo function is available,
865 dnl and check the types of five of its arguments.
866 dnl If the function succeeds HAVE_GETNAMEINFO will be
867 dnl defined, defining the types of the arguments in
868 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
869 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
870 dnl and also defining the type qualifier of first
871 dnl argument in GETNAMEINFO_QUAL_ARG1.
873 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
874 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
875 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
876 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
878 AC_MSG_CHECKING([for getnameinfo])
880 AC_LANG_FUNC_LINK_TRY([getnameinfo])
883 curl_cv_getnameinfo="yes"
886 curl_cv_getnameinfo="no"
889 if test "$curl_cv_getnameinfo" != "yes"; then
890 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])
907 #ifdef HAVE_WINDOWS_H
908 #ifndef WIN32_LEAN_AND_MEAN
909 #define WIN32_LEAN_AND_MEAN
912 #ifdef HAVE_WINSOCK2_H
913 #include <winsock2.h>
914 #ifdef HAVE_WS2TCPIP_H
915 #include <ws2tcpip.h>
919 #ifdef HAVE_SYS_TYPES_H
920 #include <sys/types.h>
922 #ifdef HAVE_SYS_SOCKET_H
923 #include <sys/socket.h>
930 getnameinfo(0, 0, 0, 0, 0, 0, 0);
933 curl_cv_getnameinfo="yes"
935 AC_MSG_RESULT([but still no])
936 curl_cv_getnameinfo="no"
940 if test "$curl_cv_getnameinfo" = "yes"; then
941 AC_CACHE_CHECK([types of arguments for getnameinfo],
942 [curl_cv_func_getnameinfo_args], [
943 curl_cv_func_getnameinfo_args="unknown"
944 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
945 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
946 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
947 for gni_arg7 in 'int' 'unsigned int'; do
951 #ifdef HAVE_WINDOWS_H
952 #ifndef WIN32_LEAN_AND_MEAN
953 #define WIN32_LEAN_AND_MEAN
955 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
957 #define _WIN32_WINNT 0x0501
960 #ifdef HAVE_WINSOCK2_H
961 #include <winsock2.h>
962 #ifdef HAVE_WS2TCPIP_H
963 #include <ws2tcpip.h>
966 #define GNICALLCONV WSAAPI
968 #ifdef HAVE_SYS_TYPES_H
969 #include <sys/types.h>
971 #ifdef HAVE_SYS_SOCKET_H
972 #include <sys/socket.h>
979 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
985 $gni_arg46 hostlen=0;
986 $gni_arg46 servlen=0;
988 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
991 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
999 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1000 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
1001 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1003 gni_prev_IFS=$IFS; IFS=','
1004 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1008 gni_qual_type_arg1=$[1]
1010 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1011 [Define to the type of arg 2 for getnameinfo.])
1012 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1013 [Define to the type of args 4 and 6 for getnameinfo.])
1014 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1015 [Define to the type of arg 7 for getnameinfo.])
1019 case $prev_sh_opts in
1027 case "$gni_qual_type_arg1" in
1030 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1034 gni_type_arg1=$gni_qual_type_arg1
1038 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1039 [Define to the type qualifier of arg 1 for getnameinfo.])
1040 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1041 [Define to the type of arg 1 for getnameinfo.])
1043 case $prev_sh_opts in
1051 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1052 [Define to 1 if you have the getnameinfo function.])
1053 ac_cv_func_getnameinfo="yes"
1059 dnl TYPE_SOCKADDR_STORAGE
1060 dnl -------------------------------------------------
1061 dnl Check for struct sockaddr_storage. Most IPv6-enabled
1062 dnl hosts have it, but AIX 4.3 is one known exception.
1064 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1066 AC_CHECK_TYPE([struct sockaddr_storage],
1067 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1068 [if struct sockaddr_storage is defined]), ,
1071 #ifdef HAVE_WINDOWS_H
1072 #ifndef WIN32_LEAN_AND_MEAN
1073 #define WIN32_LEAN_AND_MEAN
1075 #include <windows.h>
1076 #ifdef HAVE_WINSOCK2_H
1077 #include <winsock2.h>
1080 #ifdef HAVE_SYS_TYPES_H
1081 #include <sys/types.h>
1083 #ifdef HAVE_SYS_SOCKET_H
1084 #include <sys/socket.h>
1086 #ifdef HAVE_NETINET_IN_H
1087 #include <netinet/in.h>
1089 #ifdef HAVE_ARPA_INET_H
1090 #include <arpa/inet.h>
1097 dnl CURL_CHECK_NI_WITHSCOPEID
1098 dnl -------------------------------------------------
1099 dnl Check for working NI_WITHSCOPEID in getnameinfo()
1101 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1102 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1103 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1104 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1105 netdb.h netinet/in.h arpa/inet.h)
1107 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
1108 [ac_cv_working_ni_withscopeid], [
1114 #ifdef HAVE_SYS_TYPES_H
1115 #include <sys/types.h>
1117 #ifdef HAVE_SYS_SOCKET_H
1118 #include <sys/socket.h>
1123 #ifdef HAVE_NETINET_IN_H
1124 #include <netinet/in.h>
1126 #ifdef HAVE_ARPA_INET_H
1127 #include <arpa/inet.h>
1130 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1131 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1132 struct sockaddr_storage sa;
1134 unsigned char sa[256];
1136 char hostbuf[NI_MAXHOST];
1138 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1139 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1140 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1141 int fd = socket(AF_INET6, SOCK_STREAM, 0);
1144 return 1; /* Error creating socket */
1146 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1148 perror("getsockname()");
1149 return 2; /* Error retrieving socket name */
1151 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1153 printf("rc = %s\n", gai_strerror(rc));
1154 return 3; /* Error translating socket address */
1156 return 0; /* Ok, NI_WITHSCOPEID works */
1158 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1160 ]) # AC_LANG_PROGRAM
1162 # Exit code == 0. Program worked.
1163 ac_cv_working_ni_withscopeid="yes"
1165 # Exit code != 0. Program failed.
1166 ac_cv_working_ni_withscopeid="no"
1168 # Program is not run when cross-compiling. So we assume
1169 # NI_WITHSCOPEID will work if we are able to compile it.
1172 #include <sys/types.h>
1173 #include <sys/socket.h>
1176 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1179 ac_cv_working_ni_withscopeid="yes"
1181 ac_cv_working_ni_withscopeid="no"
1182 ]) # AC_COMPILE_IFELSE
1185 case "$ac_cv_working_ni_withscopeid" in
1187 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1188 [Define to 1 if NI_WITHSCOPEID exists and works.])
1194 dnl CURL_CHECK_FUNC_RECV
1195 dnl -------------------------------------------------
1196 dnl Test if the socket recv() function is available,
1197 dnl and check its return type and the types of its
1198 dnl arguments. If the function succeeds HAVE_RECV
1199 dnl will be defined, defining the types of the arguments
1200 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1201 dnl and RECV_TYPE_ARG4, defining the type of the function
1202 dnl return value in RECV_TYPE_RETV.
1204 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1205 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1206 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1207 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1209 AC_MSG_CHECKING([for recv])
1212 #ifdef HAVE_WINDOWS_H
1213 #ifndef WIN32_LEAN_AND_MEAN
1214 #define WIN32_LEAN_AND_MEAN
1216 #include <windows.h>
1217 #ifdef HAVE_WINSOCK2_H
1218 #include <winsock2.h>
1220 #ifdef HAVE_WINSOCK_H
1221 #include <winsock.h>
1225 #ifdef HAVE_SYS_TYPES_H
1226 #include <sys/types.h>
1228 #ifdef HAVE_SYS_SOCKET_H
1229 #include <sys/socket.h>
1235 AC_MSG_RESULT([yes])
1242 if test "$curl_cv_recv" = "yes"; then
1243 AC_CACHE_CHECK([types of args and return type for recv],
1244 [curl_cv_func_recv_args], [
1245 curl_cv_func_recv_args="unknown"
1246 for recv_retv in 'int' 'ssize_t'; do
1247 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1248 for recv_arg2 in 'char *' 'void *'; do
1249 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1250 for recv_arg4 in 'int' 'unsigned int'; do
1254 #ifdef HAVE_WINDOWS_H
1255 #ifndef WIN32_LEAN_AND_MEAN
1256 #define WIN32_LEAN_AND_MEAN
1258 #include <windows.h>
1259 #ifdef HAVE_WINSOCK2_H
1260 #include <winsock2.h>
1262 #ifdef HAVE_WINSOCK_H
1263 #include <winsock.h>
1266 #define RECVCALLCONV PASCAL
1268 #ifdef HAVE_SYS_TYPES_H
1269 #include <sys/types.h>
1271 #ifdef HAVE_SYS_SOCKET_H
1272 #include <sys/socket.h>
1274 #define RECVCALLCONV
1276 extern $recv_retv RECVCALLCONV recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1282 $recv_retv res = recv(s, buf, len, flags);
1285 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1294 if test "$curl_cv_func_recv_args" = "unknown"; then
1295 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1297 recv_prev_IFS=$IFS; IFS=','
1298 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1302 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1303 [Define to the type of arg 1 for recv.])
1304 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1305 [Define to the type of arg 2 for recv.])
1306 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1307 [Define to the type of arg 3 for recv.])
1308 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1309 [Define to the type of arg 4 for recv.])
1310 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1311 [Define to the function return type for recv.])
1313 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1314 [Define to 1 if you have the recv function.])
1315 ac_cv_func_recv="yes"
1318 AC_MSG_ERROR([Unable to link function recv])
1323 dnl CURL_CHECK_FUNC_SEND
1324 dnl -------------------------------------------------
1325 dnl Test if the socket send() function is available,
1326 dnl and check its return type and the types of its
1327 dnl arguments. If the function succeeds HAVE_SEND
1328 dnl will be defined, defining the types of the arguments
1329 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1330 dnl and SEND_TYPE_ARG4, defining the type of the function
1331 dnl return value in SEND_TYPE_RETV, and also defining the
1332 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1334 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1335 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1336 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1337 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1339 AC_MSG_CHECKING([for send])
1342 #ifdef HAVE_WINDOWS_H
1343 #ifndef WIN32_LEAN_AND_MEAN
1344 #define WIN32_LEAN_AND_MEAN
1346 #include <windows.h>
1347 #ifdef HAVE_WINSOCK2_H
1348 #include <winsock2.h>
1350 #ifdef HAVE_WINSOCK_H
1351 #include <winsock.h>
1355 #ifdef HAVE_SYS_TYPES_H
1356 #include <sys/types.h>
1358 #ifdef HAVE_SYS_SOCKET_H
1359 #include <sys/socket.h>
1365 AC_MSG_RESULT([yes])
1372 if test "$curl_cv_send" = "yes"; then
1373 AC_CACHE_CHECK([types of args and return type for send],
1374 [curl_cv_func_send_args], [
1375 curl_cv_func_send_args="unknown"
1376 for send_retv in 'int' 'ssize_t'; do
1377 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1378 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1379 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1380 for send_arg4 in 'int' 'unsigned int'; do
1384 #ifdef HAVE_WINDOWS_H
1385 #ifndef WIN32_LEAN_AND_MEAN
1386 #define WIN32_LEAN_AND_MEAN
1388 #include <windows.h>
1389 #ifdef HAVE_WINSOCK2_H
1390 #include <winsock2.h>
1392 #ifdef HAVE_WINSOCK_H
1393 #include <winsock.h>
1396 #define SENDCALLCONV PASCAL
1398 #ifdef HAVE_SYS_TYPES_H
1399 #include <sys/types.h>
1401 #ifdef HAVE_SYS_SOCKET_H
1402 #include <sys/socket.h>
1404 #define SENDCALLCONV
1406 extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1411 $send_retv res = send(s, 0, len, flags);
1414 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1423 if test "$curl_cv_func_send_args" = "unknown"; then
1424 AC_MSG_ERROR([Cannot find proper types to use for send args])
1426 send_prev_IFS=$IFS; IFS=','
1427 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1431 send_qual_type_arg2=$[2]
1433 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1434 [Define to the type of arg 1 for send.])
1435 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1436 [Define to the type of arg 3 for send.])
1437 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1438 [Define to the type of arg 4 for send.])
1439 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1440 [Define to the function return type for send.])
1444 case $prev_sh_opts in
1452 case "$send_qual_type_arg2" in
1454 send_qual_arg2=const
1455 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1459 send_type_arg2=$send_qual_type_arg2
1463 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1464 [Define to the type qualifier of arg 2 for send.])
1465 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1466 [Define to the type of arg 2 for send.])
1468 case $prev_sh_opts in
1476 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1477 [Define to 1 if you have the send function.])
1478 ac_cv_func_send="yes"
1481 AC_MSG_ERROR([Unable to link function send])
1486 dnl CURL_CHECK_MSG_NOSIGNAL
1487 dnl -------------------------------------------------
1488 dnl Check for MSG_NOSIGNAL
1490 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1491 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1492 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1496 #ifdef HAVE_WINDOWS_H
1497 #ifndef WIN32_LEAN_AND_MEAN
1498 #define WIN32_LEAN_AND_MEAN
1500 #include <windows.h>
1501 #ifdef HAVE_WINSOCK2_H
1502 #include <winsock2.h>
1504 #ifdef HAVE_WINSOCK_H
1505 #include <winsock.h>
1509 #ifdef HAVE_SYS_TYPES_H
1510 #include <sys/types.h>
1512 #ifdef HAVE_SYS_SOCKET_H
1513 #include <sys/socket.h>
1517 int flag=MSG_NOSIGNAL;
1520 ac_cv_msg_nosignal="yes"
1522 ac_cv_msg_nosignal="no"
1525 case "$ac_cv_msg_nosignal" in
1527 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1528 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1534 dnl CURL_CHECK_STRUCT_TIMEVAL
1535 dnl -------------------------------------------------
1536 dnl Check for timeval struct
1538 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1539 AC_REQUIRE([AC_HEADER_TIME])dnl
1540 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1541 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1542 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1543 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1547 #ifdef HAVE_WINDOWS_H
1548 #ifndef WIN32_LEAN_AND_MEAN
1549 #define WIN32_LEAN_AND_MEAN
1551 #include <windows.h>
1552 #ifdef HAVE_WINSOCK2_H
1553 #include <winsock2.h>
1555 #ifdef HAVE_WINSOCK_H
1556 #include <winsock.h>
1560 #ifdef HAVE_SYS_TYPES_H
1561 #include <sys/types.h>
1563 #ifdef HAVE_SYS_TIME_H
1564 #include <sys/time.h>
1565 #ifdef TIME_WITH_SYS_TIME
1579 ac_cv_struct_timeval="yes"
1581 ac_cv_struct_timeval="no"
1584 case "$ac_cv_struct_timeval" in
1586 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1587 [Define to 1 if you have the timeval struct.])
1593 dnl TYPE_SIG_ATOMIC_T
1594 dnl -------------------------------------------------
1595 dnl Check if the sig_atomic_t type is available, and
1596 dnl verify if it is already defined as volatile.
1598 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1599 AC_CHECK_HEADERS(signal.h)
1600 AC_CHECK_TYPE([sig_atomic_t],[
1601 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1602 [Define to 1 if sig_atomic_t is an available typedef.])
1604 #ifdef HAVE_SIGNAL_H
1608 case "$ac_cv_type_sig_atomic_t" in
1611 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1613 #ifdef HAVE_SIGNAL_H
1617 static volatile sig_atomic_t dummy = 0;
1620 ac_cv_sig_atomic_t_volatile="no"
1622 AC_MSG_RESULT([yes])
1623 ac_cv_sig_atomic_t_volatile="yes"
1626 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1627 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1628 [Define to 1 if sig_atomic_t is already defined as volatile.])
1635 dnl CURL_CHECK_NONBLOCKING_SOCKET
1636 dnl -------------------------------------------------
1637 dnl Check for how to set a socket to non-blocking state. There seems to exist
1638 dnl four known different ways, with the one used almost everywhere being POSIX
1639 dnl and XPG3, while the other different ways for different systems (old BSD,
1640 dnl Windows and Amiga).
1642 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1643 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1644 dnl to get caught in this script by using an excessive number of #ifdefs...
1646 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
1648 AC_MSG_CHECKING([non-blocking sockets style])
1651 /* headers for O_NONBLOCK test */
1652 #include <sys/types.h>
1656 /* try to compile O_NONBLOCK */
1658 #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1659 # if defined(__SVR4) || defined(__srv4__)
1660 # define PLATFORM_SOLARIS
1662 # define PLATFORM_SUNOS4
1665 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
1666 # define PLATFORM_AIX_V3
1669 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1670 #error "O_NONBLOCK does not work on this platform"
1673 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1675 dnl the O_NONBLOCK test was fine
1676 nonblock="O_NONBLOCK"
1677 AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
1679 dnl the code was bad, try a different program now, test 2
1682 /* headers for FIONBIO test */
1684 #include <stropts.h>
1686 /* FIONBIO source test (old-style unix) */
1688 int flags = ioctl(socket, FIONBIO, &flags);
1690 dnl FIONBIO test was good
1692 AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
1694 dnl FIONBIO test was also bad
1695 dnl the code was bad, try a different program now, test 3
1698 /* headers for ioctlsocket test (Windows) */
1700 #ifdef HAVE_WINDOWS_H
1701 #ifndef WIN32_LEAN_AND_MEAN
1702 #define WIN32_LEAN_AND_MEAN
1704 #include <windows.h>
1705 #ifdef HAVE_WINSOCK2_H
1706 #include <winsock2.h>
1708 #ifdef HAVE_WINSOCK_H
1709 #include <winsock.h>
1714 /* ioctlsocket source code */
1716 unsigned long flags = 0;
1717 sd = socket(0, 0, 0);
1718 ioctlsocket(sd, FIONBIO, &flags);
1720 dnl ioctlsocket test was good
1721 nonblock="ioctlsocket"
1722 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
1724 dnl ioctlsocket didnt compile!, go to test 4
1727 /* headers for IoctlSocket test (Amiga?) */
1728 #include <sys/ioctl.h>
1730 /* IoctlSocket source code */
1732 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1734 dnl ioctlsocket test was good
1735 nonblock="IoctlSocket"
1736 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
1738 dnl Ioctlsocket didnt compile, do test 5!
1740 /* headers for SO_NONBLOCK test (BeOS) */
1743 /* SO_NONBLOCK source code */
1746 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1748 dnl the SO_NONBLOCK test was good
1749 nonblock="SO_NONBLOCK"
1750 AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
1752 dnl test 5 didnt compile!
1754 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
1756 dnl end of fifth test
1759 dnl end of forth test
1762 dnl end of third test
1765 dnl end of second test
1768 dnl end of non-blocking try-compile test
1769 AC_MSG_RESULT($nonblock)
1771 if test "$nonblock" = "nada"; then
1772 AC_MSG_WARN([non-block sockets disabled])
1778 dnl -------------------------------------------------
1779 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1780 dnl and a few other things.
1781 AC_DEFUN([TYPE_IN_ADDR_T],
1783 AC_CHECK_TYPE([in_addr_t], ,[
1784 AC_MSG_CHECKING([for in_addr_t equivalent])
1785 AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
1787 curl_cv_in_addr_t_equiv=
1788 for t in "unsigned long" int size_t unsigned long; do
1791 #ifdef HAVE_WINDOWS_H
1792 #ifndef WIN32_LEAN_AND_MEAN
1793 #define WIN32_LEAN_AND_MEAN
1795 #include <windows.h>
1796 #ifdef HAVE_WINSOCK2_H
1797 #include <winsock2.h>
1799 #ifdef HAVE_WINSOCK_H
1800 #include <winsock.h>
1804 #ifdef HAVE_SYS_TYPES_H
1805 #include <sys/types.h>
1807 #ifdef HAVE_SYS_SOCKET_H
1808 #include <sys/socket.h>
1810 #ifdef HAVE_NETINET_IN_H
1811 #include <netinet/in.h>
1813 #ifdef HAVE_ARPA_INET_H
1814 #include <arpa/inet.h>
1818 $t data = inet_addr ("1.2.3.4");
1820 curl_cv_in_addr_t_equiv="$t"
1825 if test "x$curl_cv_in_addr_t_equiv" = x; then
1826 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1829 AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
1830 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1831 [type to use in place of in_addr_t if not defined])],
1834 #ifdef HAVE_WINDOWS_H
1835 #ifndef WIN32_LEAN_AND_MEAN
1836 #define WIN32_LEAN_AND_MEAN
1838 #include <windows.h>
1839 #ifdef HAVE_WINSOCK2_H
1840 #include <winsock2.h>
1842 #ifdef HAVE_WINSOCK_H
1843 #include <winsock.h>
1847 #ifdef HAVE_SYS_TYPES_H
1848 #include <sys/types.h>
1850 #ifdef HAVE_SYS_SOCKET_H
1851 #include <sys/socket.h>
1853 #ifdef HAVE_NETINET_IN_H
1854 #include <netinet/in.h>
1856 #ifdef HAVE_ARPA_INET_H
1857 #include <arpa/inet.h>
1860 ]) dnl AC_CHECK_TYPE
1863 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1864 dnl -------------------------------------------------
1865 dnl Check if monotonic clock_gettime is available.
1867 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1868 AC_REQUIRE([AC_HEADER_TIME])dnl
1869 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1870 AC_MSG_CHECKING([for monotonic clock_gettime])
1873 #ifdef HAVE_SYS_TYPES_H
1874 #include <sys/types.h>
1876 #ifdef HAVE_SYS_TIME_H
1877 #include <sys/time.h>
1878 #ifdef TIME_WITH_SYS_TIME
1888 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1891 AC_MSG_RESULT([yes])
1892 ac_cv_func_clock_gettime="yes"
1895 ac_cv_func_clock_gettime="no"
1897 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally
1898 dnl postponed until library linking checks for clock_gettime pass.
1901 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1902 dnl -------------------------------------------------
1903 dnl If monotonic clock_gettime is available then,
1904 dnl check and prepended to LIBS any needed libraries.
1906 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1907 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1909 if test "$ac_cv_func_clock_gettime" = "yes"; then
1911 AC_MSG_CHECKING([for clock_gettime in libraries])
1913 curl_cv_save_LIBS="$LIBS"
1914 curl_cv_gclk_LIBS="unknown"
1916 for x_xlibs in '' '-lrt' '-lposix4' ; do
1917 if test -z "$x_xlibs"; then
1918 LIBS="$curl_cv_save_LIBS"
1920 LIBS="$x_xlibs $curl_cv_save_LIBS"
1924 #ifdef HAVE_SYS_TYPES_H
1925 #include <sys/types.h>
1927 #ifdef HAVE_SYS_TIME_H
1928 #include <sys/time.h>
1929 #ifdef TIME_WITH_SYS_TIME
1939 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1942 curl_cv_gclk_LIBS="$x_xlibs"
1947 LIBS="$curl_cv_save_LIBS"
1949 case X-"$curl_cv_gclk_LIBS" in
1951 AC_MSG_RESULT([cannot find clock_gettime])
1952 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1953 ac_cv_func_clock_gettime="no"
1956 AC_MSG_RESULT([no additional lib required])
1957 ac_cv_func_clock_gettime="yes"
1960 if test -z "$curl_cv_save_LIBS"; then
1961 LIBS="$curl_cv_gclk_LIBS"
1963 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1965 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1966 ac_cv_func_clock_gettime="yes"
1970 case "$ac_cv_func_clock_gettime" in
1972 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1973 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1982 dnl CURL_CHECK_FUNC_SELECT
1983 dnl -------------------------------------------------
1984 dnl Test if the socket select() function is available,
1985 dnl and check its return type and the types of its
1986 dnl arguments. If the function succeeds HAVE_SELECT
1987 dnl will be defined, defining the types of the
1988 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
1989 dnl and SELECT_TYPE_ARG5, defining the type of the
1990 dnl function return value in SELECT_TYPE_RETV, and
1991 dnl also defining the type qualifier of fifth argument
1992 dnl in SELECT_QUAL_ARG5.
1994 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
1995 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
1996 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1998 AC_MSG_CHECKING([for select])
2001 #ifdef HAVE_WINDOWS_H
2002 #ifndef WIN32_LEAN_AND_MEAN
2003 #define WIN32_LEAN_AND_MEAN
2005 #include <windows.h>
2006 #ifdef HAVE_WINSOCK2_H
2007 #include <winsock2.h>
2009 #ifdef HAVE_WINSOCK_H
2010 #include <winsock.h>
2014 #ifdef HAVE_SYS_TYPES_H
2015 #include <sys/types.h>
2017 #ifdef HAVE_SYS_TIME_H
2018 #include <sys/time.h>
2019 #ifdef TIME_WITH_SYS_TIME
2027 #ifndef HAVE_WINDOWS_H
2028 #ifdef HAVE_SYS_SELECT_H
2029 #include <sys/select.h>
2031 #ifdef HAVE_SYS_SOCKET_H
2032 #include <sys/socket.h>
2036 select(0, 0, 0, 0, 0);
2038 AC_MSG_RESULT([yes])
2039 curl_cv_select="yes"
2045 if test "$curl_cv_select" = "yes"; then
2046 AC_CACHE_CHECK([types of args and return type for select],
2047 [curl_cv_func_select_args], [
2048 curl_cv_func_select_args="unknown"
2049 for sel_retv in 'int' 'ssize_t'; do
2050 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2051 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2052 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2056 #ifdef HAVE_WINDOWS_H
2057 #ifndef WIN32_LEAN_AND_MEAN
2058 #define WIN32_LEAN_AND_MEAN
2060 #include <windows.h>
2061 #ifdef HAVE_WINSOCK2_H
2062 #include <winsock2.h>
2064 #ifdef HAVE_WINSOCK_H
2065 #include <winsock.h>
2068 #define SELECTCALLCONV PASCAL
2070 #ifdef HAVE_SYS_TYPES_H
2071 #include <sys/types.h>
2073 #ifdef HAVE_SYS_TIME_H
2074 #include <sys/time.h>
2075 #ifdef TIME_WITH_SYS_TIME
2083 #ifndef HAVE_WINDOWS_H
2084 #ifdef HAVE_SYS_SELECT_H
2085 #include <sys/select.h>
2087 #ifdef HAVE_SYS_SOCKET_H
2088 #include <sys/socket.h>
2090 #define SELECTCALLCONV
2092 #ifndef HAVE_STRUCT_TIMEVAL
2098 extern $sel_retv SELECTCALLCONV select($sel_arg1,
2108 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2111 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2119 if test "$curl_cv_func_select_args" = "unknown"; then
2120 AC_MSG_WARN([Cannot find proper types to use for select args])
2121 AC_MSG_WARN([HAVE_SELECT will not be defined])
2123 select_prev_IFS=$IFS; IFS=','
2124 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2125 IFS=$select_prev_IFS
2128 sel_qual_type_arg5=$[3]
2130 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2131 [Define to the type of arg 1 for select.])
2132 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2133 [Define to the type of args 2, 3 and 4 for select.])
2134 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2135 [Define to the function return type for select.])
2139 case $prev_sh_opts in
2147 case "$sel_qual_type_arg5" in
2150 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2154 sel_type_arg5=$sel_qual_type_arg5
2158 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2159 [Define to the type qualifier of arg 5 for select.])
2160 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2161 [Define to the type of arg 5 for select.])
2163 case $prev_sh_opts in
2171 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2172 [Define to 1 if you have the select function.])
2173 ac_cv_func_select="yes"
2179 dnl ************************************************************
2180 dnl check for "localhost", if it doesn't exist, we can't do the
2181 dnl gethostbyname_r tests!
2184 AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[
2185 AC_MSG_CHECKING([if "localhost" resolves])
2188 #include <sys/types.h>
2191 #define NULL (void *)0
2197 h = gethostbyname("localhost");
2198 exit (h == NULL ? 1 : 0); }],[
2199 AC_MSG_RESULT(yes)],[
2201 AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
2207 dnl ************************************************************
2208 dnl check for working getaddrinfo() that works with AI_NUMERICHOST
2210 AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
2211 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
2214 #include <sys/types.h>
2215 #include <sys/socket.h>
2219 struct addrinfo hints, *ai;
2222 memset(&hints, 0, sizeof(hints));
2223 hints.ai_flags = AI_NUMERICHOST;
2224 hints.ai_family = AF_UNSPEC;
2225 hints.ai_socktype = SOCK_STREAM;
2226 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
2233 ac_cv_working_getaddrinfo="yes"
2235 ac_cv_working_getaddrinfo="no"
2237 ac_cv_working_getaddrinfo="yes"
2239 if test "$ac_cv_working_getaddrinfo" = "yes"; then
2240 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
2241 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
2244 AC_SUBST(IPV6_ENABLED)
2249 AC_DEFUN([CURL_CHECK_LOCALTIME_R],
2251 dnl check for localtime_r
2252 AC_CHECK_FUNCS(localtime_r,[
2253 AC_MSG_CHECKING(whether localtime_r is declared)
2254 AC_EGREP_CPP(localtime_r,[
2255 #include <time.h>],[
2256 AC_MSG_RESULT(yes)],[
2258 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
2259 AC_EGREP_CPP(localtime_r,[
2261 #include <time.h>],[
2262 AC_DEFINE(NEED_REENTRANT)
2263 AC_MSG_RESULT(yes)],
2264 AC_MSG_RESULT(no))])])
2268 dnl This function checks for strerror_r(). If it isn't found at first, it
2269 dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
2270 dnl in order to find this function.
2272 dnl If the function is found, it will then proceed to check how the function
2273 dnl actually works: glibc-style or POSIX-style.
2276 dnl char *strerror_r(int errnum, char *buf, size_t n);
2278 dnl What this one does is to return the error string (no surprises there),
2279 dnl but it doesn't usually copy anything into buf! The 'buf' and 'n'
2280 dnl parameters are only meant as an optional working area, in case strerror_r
2281 dnl needs it. A quick test on a few systems shows that it's generally not
2285 dnl int strerror_r(int errnum, char *buf, size_t n);
2287 AC_DEFUN([CURL_CHECK_STRERROR_R],
2289 AC_CHECK_FUNCS(strerror_r)
2291 if test "x$ac_cv_func_strerror_r" = "xyes"; then
2293 AC_MSG_CHECKING(whether strerror_r is declared)
2294 AC_EGREP_CPP(strerror_r,[
2295 #include <string.h>],[
2296 AC_MSG_RESULT(yes)],[
2298 AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
2299 AC_EGREP_CPP(strerror_r,[
2301 #include <string.h>],[
2302 CPPFLAGS="-D_REENTRANT $CPPFLAGS"
2303 AC_MSG_RESULT(yes)],
2305 AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
2306 ) dnl with _THREAD_SAFE
2307 ]) dnl plain cpp for it
2309 dnl determine if this strerror_r() is glibc or POSIX
2310 AC_MSG_CHECKING([for a glibc strerror_r API])
2316 char buffer[1024]; /* big enough to play with */
2318 strerror_r(EACCES, buffer, sizeof(buffer));
2319 /* this should've returned a string */
2320 if(!string || !string[0])
2325 GLIBC_STRERROR_R="1"
2326 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2327 AC_MSG_RESULT([yes]),
2328 AC_MSG_RESULT([no]),
2330 dnl Use an inferior method of strerror_r detection while cross-compiling
2332 #include <features.h>
2337 dnl looks like glibc, so assume a glibc-style strerror_r()
2338 GLIBC_STRERROR_R="1"
2339 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2340 AC_MSG_RESULT([yes]),
2341 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2342 ) dnl while cross-compiling
2345 if test -z "$GLIBC_STRERROR_R"; then
2347 AC_MSG_CHECKING([for a POSIX strerror_r API])
2353 char buffer[1024]; /* big enough to play with */
2355 strerror_r(EACCES, buffer, sizeof(buffer));
2356 /* This should've returned zero, and written an error string in the
2358 if(!buffer[0] || error)
2363 AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
2364 AC_MSG_RESULT([yes]),
2365 AC_MSG_RESULT([no]) ,
2366 dnl cross-compiling!
2367 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2370 fi dnl if not using glibc API
2372 fi dnl we have a strerror_r
2376 AC_DEFUN([CURL_CHECK_INET_NTOA_R],
2378 dnl determine if function definition for inet_ntoa_r exists.
2379 AC_CHECK_FUNCS(inet_ntoa_r,[
2380 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
2381 AC_EGREP_CPP(inet_ntoa_r,[
2382 #include <arpa/inet.h>],[
2383 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2384 AC_MSG_RESULT(yes)],[
2386 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
2387 AC_EGREP_CPP(inet_ntoa_r,[
2389 #include <arpa/inet.h>],[
2390 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2391 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT defined])
2392 AC_MSG_RESULT(yes)],
2393 AC_MSG_RESULT(no))])])
2396 AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R],
2398 dnl check for number of arguments to gethostbyaddr_r. it might take
2399 dnl either 5, 7, or 8 arguments.
2400 AC_CHECK_FUNCS(gethostbyaddr_r,[
2401 AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
2403 #include <sys/types.h>
2404 #include <netdb.h>],[
2409 struct hostent_data hdata;
2411 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
2413 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2414 ac_cv_gethostbyaddr_args=5],[
2416 AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
2419 #include <sys/types.h>
2420 #include <netdb.h>],[
2425 struct hostent_data hdata;
2427 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
2429 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2430 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
2431 ac_cv_gethostbyaddr_args=5],[
2433 AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
2435 #include <sys/types.h>
2436 #include <netdb.h>],[
2443 struct hostent * hp;
2445 hp = gethostbyaddr_r(address, length, type, &h,
2446 buffer, 8192, &h_errnop);],[
2448 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args] )
2449 ac_cv_gethostbyaddr_args=7],[
2451 AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
2453 #include <sys/types.h>
2454 #include <netdb.h>],[
2461 struct hostent * hp;
2464 rc = gethostbyaddr_r(address, length, type, &h,
2465 buffer, 8192, &hp, &h_errnop);],[
2467 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
2468 ac_cv_gethostbyaddr_args=8],[
2470 have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
2473 AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R],
2475 dnl check for number of arguments to gethostbyname_r. it might take
2476 dnl either 3, 5, or 6 arguments.
2477 AC_CHECK_FUNCS(gethostbyname_r,[
2478 AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
2481 #include <sys/types.h>
2484 #define NULL (void *)0
2487 gethostbyname_r(const char *, struct hostent *, struct hostent_data *);],[
2488 struct hostent_data data;
2489 gethostbyname_r(NULL, NULL, NULL);],[
2491 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2492 ac_cv_gethostbyname_args=3],[
2494 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
2499 #include <sys/types.h>
2502 #define NULL (void *)0
2505 gethostbyname_r(const char *,struct hostent *, struct hostent_data *);],[
2506 struct hostent_data data;
2507 gethostbyname_r(NULL, NULL, NULL);],[
2509 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2510 AC_DEFINE(NEED_REENTRANT, 1, [needs REENTRANT])
2511 ac_cv_gethostbyname_args=3],[
2513 AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
2515 #include <sys/types.h>
2518 #define NULL (void *)0
2521 gethostbyname_r(const char *, struct hostent *, char *, int, int *);],[
2522 gethostbyname_r(NULL, NULL, NULL, 0, NULL);],[
2524 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
2525 ac_cv_gethostbyname_args=5],[
2527 AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
2529 #include <sys/types.h>
2532 #define NULL (void *)0
2535 gethostbyname_r(const char *, struct hostent *, char *, size_t,
2536 struct hostent **, int *);],[
2537 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);],[
2539 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
2540 ac_cv_gethostbyname_args=6],[
2542 have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
2543 [ac_cv_gethostbyname_args=0])],
2544 [ac_cv_gethostbyname_args=0])],
2545 [ac_cv_gethostbyname_args=0])],
2546 [ac_cv_gethostbyname_args=0])])
2548 if test "$ac_cv_func_gethostbyname_r" = "yes"; then
2549 if test "$ac_cv_gethostbyname_args" = "0"; then
2550 dnl there's a gethostbyname_r() function, but we don't know how
2551 dnl many arguments it wants!
2552 AC_MSG_ERROR([couldn't figure out how to use gethostbyname_r()])
2558 dnl **********************************************************************
2559 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
2561 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
2562 dnl sets the $ICC variable to "yes" or "no"
2563 dnl **********************************************************************
2564 AC_DEFUN([CURL_DETECT_ICC],
2567 AC_MSG_CHECKING([for icc in use])
2568 if test "$GCC" = "yes"; then
2569 dnl check if this is icc acting as gcc in disguise
2570 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
2571 dnl action if the text is found, this it has not been replaced by the
2574 dnl the text was not found, it was replaced by the cpp
2576 AC_MSG_RESULT([yes])
2580 if test "$ICC" = "no"; then
2586 dnl We create a function for detecting which compiler we use and then set as
2587 dnl pendantic compiler options as possible for that particular compiler. The
2588 dnl options are only used for debug-builds.
2590 AC_DEFUN([CURL_CC_DEBUG_OPTS],
2592 if test "z$ICC" = "z"; then
2596 if test "$GCC" = "yes"; then
2598 dnl figure out gcc version!
2599 AC_MSG_CHECKING([gcc version])
2600 gccver=`$CC -dumpversion`
2601 num1=`echo $gccver | cut -d . -f1`
2602 num2=`echo $gccver | cut -d . -f2`
2603 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
2604 AC_MSG_RESULT($gccver)
2606 if test "$ICC" = "yes"; then
2607 dnl this is icc, not gcc.
2609 dnl ICC warnings we ignore:
2610 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
2611 dnl "invalid format string conversion"
2612 dnl * 279 warns on static conditions in while expressions
2613 dnl * 981 warns on "operands are evaluated in unspecified order"
2614 dnl * 1418 "external definition with no prior declaration"
2615 dnl * 1419 warns on "external declaration in primary source file"
2616 dnl which we know and do on purpose.
2618 WARN="-wd279,269,981,1418,1419"
2620 if test "$gccnum" -gt "600"; then
2621 dnl icc 6.0 and older doesn't have the -Wall flag
2625 dnl this is a set of options we believe *ALL* gcc versions support:
2626 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
2628 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
2630 if test "$gccnum" -ge "207"; then
2631 dnl gcc 2.7 or later
2632 WARN="$WARN -Wmissing-declarations"
2635 if test "$gccnum" -gt "295"; then
2636 dnl only if the compiler is newer than 2.95 since we got lots of
2637 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
2638 dnl gcc 2.95.4 on FreeBSD 4.9!
2639 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
2642 if test "$gccnum" -ge "296"; then
2643 dnl gcc 2.96 or later
2644 WARN="$WARN -Wfloat-equal"
2647 if test "$gccnum" -gt "296"; then
2648 dnl this option does not exist in 2.96
2649 WARN="$WARN -Wno-format-nonliteral"
2652 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
2653 dnl on i686-Linux as it gives us heaps with false positives.
2654 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
2655 dnl over making it unusable for generic purposes. Let's not use it.
2657 if test "$gccnum" -ge "303"; then
2658 dnl gcc 3.3 and later
2659 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
2662 if test "$gccnum" -ge "304"; then
2663 # try these on gcc 3.4
2664 WARN="$WARN -Wdeclaration-after-statement"
2667 for flag in $CPPFLAGS; do
2670 dnl Include path, provide a -isystem option for the same dir
2671 dnl to prevent warnings in those dirs. The -isystem was not very
2672 dnl reliable on earlier gcc versions.
2673 add=`echo $flag | sed 's/^-I/-isystem /g'`
2681 CFLAGS="$CFLAGS $WARN"
2683 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
2687 AC_MSG_NOTICE([Added no extra compiler options])
2691 dnl strip off optimizer flags
2693 for flag in $CFLAGS; do
2696 dnl echo "cut off $flag"
2699 NEWFLAGS="$NEWFLAGS $flag"
2705 ]) dnl end of AC_DEFUN()
2707 # This is only a temporary fix. This macro is here to replace the broken one
2708 # delivered by the automake project (including the 1.9.6 release). As soon as
2709 # they ship a working version we SHOULD remove this work-around.
2711 AC_DEFUN([AM_MISSING_HAS_RUN],
2712 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2713 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
2714 # Use eval to expand $SHELL
2715 if eval "$MISSING --run true"; then
2716 am_missing_run="$MISSING --run "
2719 AC_MSG_WARN([`missing' script is too old or missing])
2724 dnl CURL_VERIFY_RUNTIMELIBS
2725 dnl -------------------------------------------------
2726 dnl Verify that the shared libs found so far can be used when running
2727 dnl programs, since otherwise the situation will create odd configure errors
2728 dnl that are misleading people.
2730 dnl Make sure this test is run BEFORE the first test in the script that
2731 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
2732 dnl macro. It must also run AFTER all lib-checking macros are complete.
2734 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
2736 dnl this test is of course not sensible if we are cross-compiling!
2737 if test "x$cross_compiling" != xyes; then
2739 dnl just run a program to verify that the libs checked for previous to this
2740 dnl point also is available run-time!
2741 AC_MSG_CHECKING([run-time libs availability])
2748 AC_MSG_RESULT([fine]),
2749 AC_MSG_RESULT([failed])
2750 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
2753 dnl if this test fails, configure has already stopped
2758 dnl CURL_CHECK_VARIADIC_MACROS
2759 dnl -------------------------------------------------
2760 dnl Check compiler support of variadic macros
2762 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
2763 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
2764 [curl_cv_variadic_macros_c99], [
2767 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
2768 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
2769 int fun3(int arg1, int arg2, int arg3);
2770 int fun2(int arg1, int arg2);
2771 int fun3(int arg1, int arg2, int arg3)
2772 { return arg1 + arg2 + arg3; }
2773 int fun2(int arg1, int arg2)
2774 { return arg1 + arg2; }
2776 int res3 = c99_vmacro3(1, 2, 3);
2777 int res2 = c99_vmacro2(1, 2);
2780 curl_cv_variadic_macros_c99="yes"
2782 curl_cv_variadic_macros_c99="no"
2785 case "$curl_cv_variadic_macros_c99" in
2787 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
2788 [Define to 1 if compiler supports C99 variadic macro style.])
2791 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
2792 [curl_cv_variadic_macros_gcc], [
2795 #define gcc_vmacro3(first, args...) fun3(first, args)
2796 #define gcc_vmacro2(first, args...) fun2(first, args)
2797 int fun3(int arg1, int arg2, int arg3);
2798 int fun2(int arg1, int arg2);
2799 int fun3(int arg1, int arg2, int arg3)
2800 { return arg1 + arg2 + arg3; }
2801 int fun2(int arg1, int arg2)
2802 { return arg1 + arg2; }
2804 int res3 = gcc_vmacro3(1, 2, 3);
2805 int res2 = gcc_vmacro2(1, 2);
2808 curl_cv_variadic_macros_gcc="yes"
2810 curl_cv_variadic_macros_gcc="no"
2813 case "$curl_cv_variadic_macros_gcc" in
2815 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2816 [Define to 1 if compiler supports old gcc variadic macro style.])
2822 dnl CURL_CHECK_CA_BUNDLE
2823 dnl -------------------------------------------------
2824 dnl Check if a default ca-bundle should be used
2826 dnl regarding the paths this will scan:
2827 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
2828 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
2829 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
2830 dnl /etc/ssl/certs/ (ca path) SUSE
2832 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
2834 AC_MSG_CHECKING([default CA cert bundle/path])
2836 AC_ARG_WITH(ca-bundle,
2837 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
2838 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
2841 if test "x$want_ca" = "xyes"; then
2842 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
2845 [ want_ca="unset" ])
2846 AC_ARG_WITH(ca-path,
2847 AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
2848 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
2850 want_capath="$withval"
2851 if test "x$want_capath" = "xyes"; then
2852 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
2855 [ want_capath="unset"])
2857 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
2858 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2860 AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
2861 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
2862 dnl --with-ca-bundle given
2865 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2866 dnl --with-ca-path given
2867 if test "x$OPENSSL_ENABLED" != "x1"; then
2868 AC_MSG_ERROR([--with-ca-path only works with openSSL])
2870 capath="$want_capath"
2873 dnl neither of --with-ca-* given
2874 dnl first try autodetecting a CA bundle , then a CA path
2875 dnl both autodetections can be skipped by --without-ca-*
2878 if test "x$want_ca" = "xunset"; then
2879 dnl the path we previously would have installed the curl ca bundle
2880 dnl to, and thus we now check for an already existing cert in that place
2881 dnl in case we find no other
2882 if test "x$prefix" != xNONE; then
2883 cac="${prefix}/share/curl/curl-ca-bundle.crt"
2885 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
2888 for a in /etc/ssl/certs/ca-certificates.crt \
2889 /etc/pki/tls/certs/ca-bundle.crt \
2890 /usr/share/ssl/certs/ca-bundle.crt \
2892 if test -f "$a"; then
2898 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
2899 "x$OPENSSL_ENABLED" = "x1"; then
2900 for a in /etc/ssl/certs/; do
2901 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
2911 if test "x$ca" != "xno"; then
2912 CURL_CA_BUNDLE='"'$ca'"'
2913 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
2914 AC_MSG_RESULT([$ca])
2915 elif test "x$capath" != "xno"; then
2916 CURL_CA_PATH="\"$capath\""
2917 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
2918 AC_MSG_RESULT([$capath (capath)])