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 not available
778 AC_CACHE_CHECK([for socklen_t equivalent],
779 [curl_cv_socklen_t_equiv], [
780 curl_cv_socklen_t_equiv="unknown"
781 for arg1 in 'int' 'SOCKET'; do
782 for arg2 in "struct sockaddr" void; do
783 for t in int size_t unsigned long "unsigned long"; do
787 #ifdef HAVE_WINDOWS_H
788 #ifndef WIN32_LEAN_AND_MEAN
789 #define WIN32_LEAN_AND_MEAN
792 #ifdef HAVE_WINSOCK2_H
793 #include <winsock2.h>
795 #ifdef HAVE_WINSOCK_H
799 #define GETPEERNCALLCONV PASCAL
801 #ifdef HAVE_SYS_TYPES_H
802 #include <sys/types.h>
804 #ifdef HAVE_SYS_SOCKET_H
805 #include <sys/socket.h>
807 #define GETPEERNCALLCONV
809 extern int GETPEERNCALLCONV getpeername ($arg1, $arg2 *, $t *);
812 getpeername(0,0,&len);
815 curl_cv_socklen_t_equiv="$t"
822 case "$curl_cv_socklen_t_equiv" in
824 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
827 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
828 [Type to use in place of socklen_t when system does not provide it.])
833 #ifdef HAVE_WINDOWS_H
834 #ifndef WIN32_LEAN_AND_MEAN
835 #define WIN32_LEAN_AND_MEAN
838 #ifdef HAVE_WINSOCK2_H
839 #include <winsock2.h>
840 #ifdef HAVE_WS2TCPIP_H
841 #include <ws2tcpip.h>
845 #ifdef HAVE_SYS_TYPES_H
846 #include <sys/types.h>
848 #ifdef HAVE_SYS_SOCKET_H
849 #include <sys/socket.h>
856 dnl CURL_CHECK_FUNC_GETNAMEINFO
857 dnl -------------------------------------------------
858 dnl Test if the getnameinfo function is available,
859 dnl and check the types of five of its arguments.
860 dnl If the function succeeds HAVE_GETNAMEINFO will be
861 dnl defined, defining the types of the arguments in
862 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
863 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
864 dnl and also defining the type qualifier of first
865 dnl argument in GETNAMEINFO_QUAL_ARG1.
867 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
868 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
869 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
870 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
872 AC_MSG_CHECKING([for getnameinfo])
874 AC_LANG_FUNC_LINK_TRY([getnameinfo])
877 curl_cv_getnameinfo="yes"
880 curl_cv_getnameinfo="no"
883 if test "$curl_cv_getnameinfo" != "yes"; then
884 AC_MSG_CHECKING([deeper for getnameinfo])
892 curl_cv_getnameinfo="yes"
894 AC_MSG_RESULT([but still no])
895 curl_cv_getnameinfo="no"
899 if test "$curl_cv_getnameinfo" != "yes"; then
900 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
904 #ifdef HAVE_WINDOWS_H
905 #ifndef WIN32_LEAN_AND_MEAN
906 #define WIN32_LEAN_AND_MEAN
909 #ifdef HAVE_WINSOCK2_H
910 #include <winsock2.h>
911 #ifdef HAVE_WS2TCPIP_H
912 #include <ws2tcpip.h>
916 #ifdef HAVE_SYS_TYPES_H
917 #include <sys/types.h>
919 #ifdef HAVE_SYS_SOCKET_H
920 #include <sys/socket.h>
927 getnameinfo(0, 0, 0, 0, 0, 0, 0);
931 curl_cv_getnameinfo="yes"
933 AC_MSG_RESULT([but still no])
934 curl_cv_getnameinfo="no"
938 if test "$curl_cv_getnameinfo" = "yes"; then
939 AC_CACHE_CHECK([types of arguments for getnameinfo],
940 [curl_cv_func_getnameinfo_args], [
941 curl_cv_func_getnameinfo_args="unknown"
942 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
943 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
944 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
945 for gni_arg7 in 'int' 'unsigned int'; do
949 #ifdef HAVE_WINDOWS_H
950 #ifndef WIN32_LEAN_AND_MEAN
951 #define WIN32_LEAN_AND_MEAN
953 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
955 #define _WIN32_WINNT 0x0501
958 #ifdef HAVE_WINSOCK2_H
959 #include <winsock2.h>
960 #ifdef HAVE_WS2TCPIP_H
961 #include <ws2tcpip.h>
964 #define GNICALLCONV WSAAPI
966 #ifdef HAVE_SYS_TYPES_H
967 #include <sys/types.h>
969 #ifdef HAVE_SYS_SOCKET_H
970 #include <sys/socket.h>
977 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
983 $gni_arg46 hostlen=0;
984 $gni_arg46 servlen=0;
986 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
989 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
997 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
998 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
999 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1001 gni_prev_IFS=$IFS; IFS=','
1002 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1006 gni_qual_type_arg1=$[1]
1008 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1009 [Define to the type of arg 2 for getnameinfo.])
1010 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1011 [Define to the type of args 4 and 6 for getnameinfo.])
1012 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1013 [Define to the type of arg 7 for getnameinfo.])
1017 case $prev_sh_opts in
1025 case "$gni_qual_type_arg1" in
1028 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1032 gni_type_arg1=$gni_qual_type_arg1
1036 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1037 [Define to the type qualifier of arg 1 for getnameinfo.])
1038 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1039 [Define to the type of arg 1 for getnameinfo.])
1041 case $prev_sh_opts in
1049 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1050 [Define to 1 if you have the getnameinfo function.])
1051 ac_cv_func_getnameinfo="yes"
1057 dnl TYPE_SOCKADDR_STORAGE
1058 dnl -------------------------------------------------
1059 dnl Check for struct sockaddr_storage. Most IPv6-enabled
1060 dnl hosts have it, but AIX 4.3 is one known exception.
1062 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1064 AC_CHECK_TYPE([struct sockaddr_storage],
1065 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1066 [if struct sockaddr_storage is defined]), ,
1069 #ifdef HAVE_WINDOWS_H
1070 #ifndef WIN32_LEAN_AND_MEAN
1071 #define WIN32_LEAN_AND_MEAN
1073 #include <windows.h>
1074 #ifdef HAVE_WINSOCK2_H
1075 #include <winsock2.h>
1078 #ifdef HAVE_SYS_TYPES_H
1079 #include <sys/types.h>
1081 #ifdef HAVE_SYS_SOCKET_H
1082 #include <sys/socket.h>
1084 #ifdef HAVE_NETINET_IN_H
1085 #include <netinet/in.h>
1087 #ifdef HAVE_ARPA_INET_H
1088 #include <arpa/inet.h>
1095 dnl CURL_CHECK_NI_WITHSCOPEID
1096 dnl -------------------------------------------------
1097 dnl Check for working NI_WITHSCOPEID in getnameinfo()
1099 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1100 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1101 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1102 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1103 netdb.h netinet/in.h arpa/inet.h)
1105 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
1106 [ac_cv_working_ni_withscopeid], [
1112 #ifdef HAVE_SYS_TYPES_H
1113 #include <sys/types.h>
1115 #ifdef HAVE_SYS_SOCKET_H
1116 #include <sys/socket.h>
1121 #ifdef HAVE_NETINET_IN_H
1122 #include <netinet/in.h>
1124 #ifdef HAVE_ARPA_INET_H
1125 #include <arpa/inet.h>
1128 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1129 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1130 struct sockaddr_storage sa;
1132 unsigned char sa[256];
1134 char hostbuf[NI_MAXHOST];
1136 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1137 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1138 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1139 int fd = socket(AF_INET6, SOCK_STREAM, 0);
1142 return 1; /* Error creating socket */
1144 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1146 perror("getsockname()");
1147 return 2; /* Error retrieving socket name */
1149 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1151 printf("rc = %s\n", gai_strerror(rc));
1152 return 3; /* Error translating socket address */
1154 return 0; /* Ok, NI_WITHSCOPEID works */
1156 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1158 ]]) # AC_LANG_PROGRAM
1160 # Exit code == 0. Program worked.
1161 ac_cv_working_ni_withscopeid="yes"
1163 # Exit code != 0. Program failed.
1164 ac_cv_working_ni_withscopeid="no"
1166 # Program is not run when cross-compiling. So we assume
1167 # NI_WITHSCOPEID will work if we are able to compile it.
1170 #include <sys/types.h>
1171 #include <sys/socket.h>
1174 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1177 ac_cv_working_ni_withscopeid="yes"
1179 ac_cv_working_ni_withscopeid="no"
1180 ]) # AC_COMPILE_IFELSE
1183 case "$ac_cv_working_ni_withscopeid" in
1185 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1186 [Define to 1 if NI_WITHSCOPEID exists and works.])
1192 dnl CURL_CHECK_FUNC_RECV
1193 dnl -------------------------------------------------
1194 dnl Test if the socket recv() function is available,
1195 dnl and check its return type and the types of its
1196 dnl arguments. If the function succeeds HAVE_RECV
1197 dnl will be defined, defining the types of the arguments
1198 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1199 dnl and RECV_TYPE_ARG4, defining the type of the function
1200 dnl return value in RECV_TYPE_RETV.
1202 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1203 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1204 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1205 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1207 AC_MSG_CHECKING([for recv])
1211 #ifdef HAVE_WINDOWS_H
1212 #ifndef WIN32_LEAN_AND_MEAN
1213 #define WIN32_LEAN_AND_MEAN
1215 #include <windows.h>
1216 #ifdef HAVE_WINSOCK2_H
1217 #include <winsock2.h>
1219 #ifdef HAVE_WINSOCK_H
1220 #include <winsock.h>
1224 #ifdef HAVE_SYS_TYPES_H
1225 #include <sys/types.h>
1227 #ifdef HAVE_SYS_SOCKET_H
1228 #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])
1343 #ifdef HAVE_WINDOWS_H
1344 #ifndef WIN32_LEAN_AND_MEAN
1345 #define WIN32_LEAN_AND_MEAN
1347 #include <windows.h>
1348 #ifdef HAVE_WINSOCK2_H
1349 #include <winsock2.h>
1351 #ifdef HAVE_WINSOCK_H
1352 #include <winsock.h>
1356 #ifdef HAVE_SYS_TYPES_H
1357 #include <sys/types.h>
1359 #ifdef HAVE_SYS_SOCKET_H
1360 #include <sys/socket.h>
1367 AC_MSG_RESULT([yes])
1374 if test "$curl_cv_send" = "yes"; then
1375 AC_CACHE_CHECK([types of args and return type for send],
1376 [curl_cv_func_send_args], [
1377 curl_cv_func_send_args="unknown"
1378 for send_retv in 'int' 'ssize_t'; do
1379 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1380 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1381 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1382 for send_arg4 in 'int' 'unsigned int'; do
1386 #ifdef HAVE_WINDOWS_H
1387 #ifndef WIN32_LEAN_AND_MEAN
1388 #define WIN32_LEAN_AND_MEAN
1390 #include <windows.h>
1391 #ifdef HAVE_WINSOCK2_H
1392 #include <winsock2.h>
1394 #ifdef HAVE_WINSOCK_H
1395 #include <winsock.h>
1398 #define SENDCALLCONV PASCAL
1400 #ifdef HAVE_SYS_TYPES_H
1401 #include <sys/types.h>
1403 #ifdef HAVE_SYS_SOCKET_H
1404 #include <sys/socket.h>
1406 #define SENDCALLCONV
1408 extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1413 $send_retv res = send(s, 0, len, flags);
1416 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1425 if test "$curl_cv_func_send_args" = "unknown"; then
1426 AC_MSG_ERROR([Cannot find proper types to use for send args])
1428 send_prev_IFS=$IFS; IFS=','
1429 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1433 send_qual_type_arg2=$[2]
1435 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1436 [Define to the type of arg 1 for send.])
1437 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1438 [Define to the type of arg 3 for send.])
1439 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1440 [Define to the type of arg 4 for send.])
1441 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1442 [Define to the function return type for send.])
1446 case $prev_sh_opts in
1454 case "$send_qual_type_arg2" in
1456 send_qual_arg2=const
1457 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1461 send_type_arg2=$send_qual_type_arg2
1465 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1466 [Define to the type qualifier of arg 2 for send.])
1467 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1468 [Define to the type of arg 2 for send.])
1470 case $prev_sh_opts in
1478 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1479 [Define to 1 if you have the send function.])
1480 ac_cv_func_send="yes"
1483 AC_MSG_ERROR([Unable to link function send])
1488 dnl CURL_CHECK_MSG_NOSIGNAL
1489 dnl -------------------------------------------------
1490 dnl Check for MSG_NOSIGNAL
1492 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1493 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1494 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1498 #ifdef HAVE_WINDOWS_H
1499 #ifndef WIN32_LEAN_AND_MEAN
1500 #define WIN32_LEAN_AND_MEAN
1502 #include <windows.h>
1503 #ifdef HAVE_WINSOCK2_H
1504 #include <winsock2.h>
1506 #ifdef HAVE_WINSOCK_H
1507 #include <winsock.h>
1511 #ifdef HAVE_SYS_TYPES_H
1512 #include <sys/types.h>
1514 #ifdef HAVE_SYS_SOCKET_H
1515 #include <sys/socket.h>
1519 int flag=MSG_NOSIGNAL;
1522 ac_cv_msg_nosignal="yes"
1524 ac_cv_msg_nosignal="no"
1527 case "$ac_cv_msg_nosignal" in
1529 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1530 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1536 dnl CURL_CHECK_STRUCT_TIMEVAL
1537 dnl -------------------------------------------------
1538 dnl Check for timeval struct
1540 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1541 AC_REQUIRE([AC_HEADER_TIME])dnl
1542 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1543 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1544 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1545 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1549 #ifdef HAVE_WINDOWS_H
1550 #ifndef WIN32_LEAN_AND_MEAN
1551 #define WIN32_LEAN_AND_MEAN
1553 #include <windows.h>
1554 #ifdef HAVE_WINSOCK2_H
1555 #include <winsock2.h>
1557 #ifdef HAVE_WINSOCK_H
1558 #include <winsock.h>
1562 #ifdef HAVE_SYS_TYPES_H
1563 #include <sys/types.h>
1565 #ifdef HAVE_SYS_TIME_H
1566 #include <sys/time.h>
1567 #ifdef TIME_WITH_SYS_TIME
1581 ac_cv_struct_timeval="yes"
1583 ac_cv_struct_timeval="no"
1586 case "$ac_cv_struct_timeval" in
1588 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1589 [Define to 1 if you have the timeval struct.])
1595 dnl TYPE_SIG_ATOMIC_T
1596 dnl -------------------------------------------------
1597 dnl Check if the sig_atomic_t type is available, and
1598 dnl verify if it is already defined as volatile.
1600 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1601 AC_CHECK_HEADERS(signal.h)
1602 AC_CHECK_TYPE([sig_atomic_t],[
1603 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1604 [Define to 1 if sig_atomic_t is an available typedef.])
1606 #ifdef HAVE_SIGNAL_H
1610 case "$ac_cv_type_sig_atomic_t" in
1613 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1616 #ifdef HAVE_SIGNAL_H
1620 static volatile sig_atomic_t dummy = 0;
1624 ac_cv_sig_atomic_t_volatile="no"
1626 AC_MSG_RESULT([yes])
1627 ac_cv_sig_atomic_t_volatile="yes"
1630 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1631 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1632 [Define to 1 if sig_atomic_t is already defined as volatile.])
1639 dnl CURL_CHECK_NONBLOCKING_SOCKET
1640 dnl -------------------------------------------------
1641 dnl Check for how to set a socket to non-blocking state. There seems to exist
1642 dnl four known different ways, with the one used almost everywhere being POSIX
1643 dnl and XPG3, while the other different ways for different systems (old BSD,
1644 dnl Windows and Amiga).
1646 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1647 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1648 dnl to get caught in this script by using an excessive number of #ifdefs...
1650 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
1651 AC_MSG_CHECKING([non-blocking sockets style])
1656 /* headers for O_NONBLOCK test */
1657 #include <sys/types.h>
1661 #if defined(sun) || defined(__sun__) || \
1662 defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1663 # if defined(__SVR4) || defined(__srv4__)
1664 # define PLATFORM_SOLARIS
1666 # define PLATFORM_SUNOS4
1669 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
1670 # define PLATFORM_AIX_V3
1673 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1674 #error "O_NONBLOCK does not work on this platform"
1677 /* O_NONBLOCK source test */
1679 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1682 dnl the O_NONBLOCK test was fine
1683 nonblock="O_NONBLOCK"
1684 AC_DEFINE(HAVE_O_NONBLOCK, 1,
1685 [use O_NONBLOCK for non-blocking sockets])
1688 if test "$nonblock" = "unknown"; then
1691 /* headers for FIONBIO test */
1693 #include <stropts.h>
1695 /* FIONBIO source test (old-style unix) */
1697 int flags = ioctl(socket, FIONBIO, &flags);
1700 dnl FIONBIO test was good
1702 AC_DEFINE(HAVE_FIONBIO, 1,
1703 [use FIONBIO for non-blocking sockets])
1707 if test "$nonblock" = "unknown"; then
1710 /* headers for ioctlsocket test (Windows) */
1712 #ifdef HAVE_WINDOWS_H
1713 #ifndef WIN32_LEAN_AND_MEAN
1714 #define WIN32_LEAN_AND_MEAN
1716 #include <windows.h>
1717 #ifdef HAVE_WINSOCK2_H
1718 #include <winsock2.h>
1720 #ifdef HAVE_WINSOCK_H
1721 #include <winsock.h>
1726 /* ioctlsocket source code (Windows) */
1728 unsigned long flags = 0;
1729 sd = socket(0, 0, 0);
1730 ioctlsocket(sd, FIONBIO, &flags);
1733 dnl ioctlsocket test was good
1734 nonblock="ioctlsocket"
1735 AC_DEFINE(HAVE_IOCTLSOCKET, 1,
1736 [use ioctlsocket() for non-blocking sockets])
1740 if test "$nonblock" = "unknown"; then
1743 /* headers for IoctlSocket test (Amiga?) */
1744 #include <sys/ioctl.h>
1746 /* IoctlSocket source code (Amiga?) */
1748 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1751 dnl Ioctlsocket test was good
1752 nonblock="IoctlSocket"
1753 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
1754 [use Ioctlsocket() for non-blocking sockets])
1758 if test "$nonblock" = "unknown"; then
1761 /* headers for SO_NONBLOCK test (BeOS) */
1764 /* SO_NONBLOCK source code (BeOS) */
1767 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1770 dnl the SO_NONBLOCK test was good
1771 nonblock="SO_NONBLOCK"
1772 AC_DEFINE(HAVE_SO_NONBLOCK, 1,
1773 [use SO_NONBLOCK for non-blocking sockets])
1777 AC_MSG_RESULT($nonblock)
1779 if test "$nonblock" = "unknown"; then
1780 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
1781 [disabled non-blocking sockets])
1782 AC_MSG_WARN([non-block sockets disabled])
1788 dnl -------------------------------------------------
1789 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1790 dnl and a few other things.
1791 AC_DEFUN([TYPE_IN_ADDR_T],
1793 AC_CHECK_TYPE([in_addr_t], ,[
1794 AC_MSG_CHECKING([for in_addr_t equivalent])
1795 AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
1797 curl_cv_in_addr_t_equiv=
1798 for t in "unsigned long" int size_t unsigned long; do
1802 #ifdef HAVE_WINDOWS_H
1803 #ifndef WIN32_LEAN_AND_MEAN
1804 #define WIN32_LEAN_AND_MEAN
1806 #include <windows.h>
1807 #ifdef HAVE_WINSOCK2_H
1808 #include <winsock2.h>
1810 #ifdef HAVE_WINSOCK_H
1811 #include <winsock.h>
1815 #ifdef HAVE_SYS_TYPES_H
1816 #include <sys/types.h>
1818 #ifdef HAVE_SYS_SOCKET_H
1819 #include <sys/socket.h>
1821 #ifdef HAVE_NETINET_IN_H
1822 #include <netinet/in.h>
1824 #ifdef HAVE_ARPA_INET_H
1825 #include <arpa/inet.h>
1829 $t data = inet_addr ("1.2.3.4");
1832 curl_cv_in_addr_t_equiv="$t"
1837 if test "x$curl_cv_in_addr_t_equiv" = x; then
1838 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1841 AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
1842 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1843 [type to use in place of in_addr_t if not defined])],
1846 #ifdef HAVE_WINDOWS_H
1847 #ifndef WIN32_LEAN_AND_MEAN
1848 #define WIN32_LEAN_AND_MEAN
1850 #include <windows.h>
1851 #ifdef HAVE_WINSOCK2_H
1852 #include <winsock2.h>
1854 #ifdef HAVE_WINSOCK_H
1855 #include <winsock.h>
1859 #ifdef HAVE_SYS_TYPES_H
1860 #include <sys/types.h>
1862 #ifdef HAVE_SYS_SOCKET_H
1863 #include <sys/socket.h>
1865 #ifdef HAVE_NETINET_IN_H
1866 #include <netinet/in.h>
1868 #ifdef HAVE_ARPA_INET_H
1869 #include <arpa/inet.h>
1872 ]) dnl AC_CHECK_TYPE
1875 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1876 dnl -------------------------------------------------
1877 dnl Check if monotonic clock_gettime is available.
1879 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1880 AC_REQUIRE([AC_HEADER_TIME])dnl
1881 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1882 AC_MSG_CHECKING([for monotonic clock_gettime])
1885 #ifdef HAVE_SYS_TYPES_H
1886 #include <sys/types.h>
1888 #ifdef HAVE_SYS_TIME_H
1889 #include <sys/time.h>
1890 #ifdef TIME_WITH_SYS_TIME
1900 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1903 AC_MSG_RESULT([yes])
1904 ac_cv_func_clock_gettime="yes"
1907 ac_cv_func_clock_gettime="no"
1909 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally
1910 dnl postponed until library linking checks for clock_gettime pass.
1913 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1914 dnl -------------------------------------------------
1915 dnl If monotonic clock_gettime is available then,
1916 dnl check and prepended to LIBS any needed libraries.
1918 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1919 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1921 if test "$ac_cv_func_clock_gettime" = "yes"; then
1923 AC_MSG_CHECKING([for clock_gettime in libraries])
1925 curl_cv_save_LIBS="$LIBS"
1926 curl_cv_gclk_LIBS="unknown"
1928 for x_xlibs in '' '-lrt' '-lposix4' ; do
1929 if test -z "$x_xlibs"; then
1930 LIBS="$curl_cv_save_LIBS"
1932 LIBS="$x_xlibs $curl_cv_save_LIBS"
1936 #ifdef HAVE_SYS_TYPES_H
1937 #include <sys/types.h>
1939 #ifdef HAVE_SYS_TIME_H
1940 #include <sys/time.h>
1941 #ifdef TIME_WITH_SYS_TIME
1951 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1954 curl_cv_gclk_LIBS="$x_xlibs"
1959 LIBS="$curl_cv_save_LIBS"
1961 case X-"$curl_cv_gclk_LIBS" in
1963 AC_MSG_RESULT([cannot find clock_gettime])
1964 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1965 ac_cv_func_clock_gettime="no"
1968 AC_MSG_RESULT([no additional lib required])
1969 ac_cv_func_clock_gettime="yes"
1972 if test -z "$curl_cv_save_LIBS"; then
1973 LIBS="$curl_cv_gclk_LIBS"
1975 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1977 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1978 ac_cv_func_clock_gettime="yes"
1982 case "$ac_cv_func_clock_gettime" in
1984 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1985 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1994 dnl CURL_CHECK_FUNC_SELECT
1995 dnl -------------------------------------------------
1996 dnl Test if the socket select() function is available,
1997 dnl and check its return type and the types of its
1998 dnl arguments. If the function succeeds HAVE_SELECT
1999 dnl will be defined, defining the types of the
2000 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
2001 dnl and SELECT_TYPE_ARG5, defining the type of the
2002 dnl function return value in SELECT_TYPE_RETV, and
2003 dnl also defining the type qualifier of fifth argument
2004 dnl in SELECT_QUAL_ARG5.
2006 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
2007 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
2008 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
2010 AC_MSG_CHECKING([for select])
2014 #ifdef HAVE_WINDOWS_H
2015 #ifndef WIN32_LEAN_AND_MEAN
2016 #define WIN32_LEAN_AND_MEAN
2018 #include <windows.h>
2019 #ifdef HAVE_WINSOCK2_H
2020 #include <winsock2.h>
2022 #ifdef HAVE_WINSOCK_H
2023 #include <winsock.h>
2027 #ifdef HAVE_SYS_TYPES_H
2028 #include <sys/types.h>
2030 #ifdef HAVE_SYS_TIME_H
2031 #include <sys/time.h>
2032 #ifdef TIME_WITH_SYS_TIME
2040 #ifndef HAVE_WINDOWS_H
2041 #ifdef HAVE_SYS_SELECT_H
2042 #include <sys/select.h>
2044 #ifdef HAVE_SYS_SOCKET_H
2045 #include <sys/socket.h>
2049 select(0, 0, 0, 0, 0);
2052 AC_MSG_RESULT([yes])
2053 curl_cv_select="yes"
2059 if test "$curl_cv_select" = "yes"; then
2060 AC_CACHE_CHECK([types of args and return type for select],
2061 [curl_cv_func_select_args], [
2062 curl_cv_func_select_args="unknown"
2063 for sel_retv in 'int' 'ssize_t'; do
2064 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2065 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2066 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2070 #ifdef HAVE_WINDOWS_H
2071 #ifndef WIN32_LEAN_AND_MEAN
2072 #define WIN32_LEAN_AND_MEAN
2074 #include <windows.h>
2075 #ifdef HAVE_WINSOCK2_H
2076 #include <winsock2.h>
2078 #ifdef HAVE_WINSOCK_H
2079 #include <winsock.h>
2082 #define SELECTCALLCONV PASCAL
2084 #ifdef HAVE_SYS_TYPES_H
2085 #include <sys/types.h>
2087 #ifdef HAVE_SYS_TIME_H
2088 #include <sys/time.h>
2089 #ifdef TIME_WITH_SYS_TIME
2097 #ifndef HAVE_WINDOWS_H
2098 #ifdef HAVE_SYS_SELECT_H
2099 #include <sys/select.h>
2101 #ifdef HAVE_SYS_SOCKET_H
2102 #include <sys/socket.h>
2104 #define SELECTCALLCONV
2106 #ifndef HAVE_STRUCT_TIMEVAL
2112 extern $sel_retv SELECTCALLCONV select($sel_arg1,
2122 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2125 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2133 if test "$curl_cv_func_select_args" = "unknown"; then
2134 AC_MSG_WARN([Cannot find proper types to use for select args])
2135 AC_MSG_WARN([HAVE_SELECT will not be defined])
2137 select_prev_IFS=$IFS; IFS=','
2138 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2139 IFS=$select_prev_IFS
2142 sel_qual_type_arg5=$[3]
2144 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2145 [Define to the type of arg 1 for select.])
2146 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2147 [Define to the type of args 2, 3 and 4 for select.])
2148 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2149 [Define to the function return type for select.])
2153 case $prev_sh_opts in
2161 case "$sel_qual_type_arg5" in
2164 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2168 sel_type_arg5=$sel_qual_type_arg5
2172 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2173 [Define to the type qualifier of arg 5 for select.])
2174 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2175 [Define to the type of arg 5 for select.])
2177 case $prev_sh_opts in
2185 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2186 [Define to 1 if you have the select function.])
2187 ac_cv_func_select="yes"
2193 dnl ************************************************************
2194 dnl check for "localhost", if it doesn't exist, we can't do the
2195 dnl gethostbyname_r tests!
2198 AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[
2199 AC_MSG_CHECKING([if "localhost" resolves])
2202 #include <sys/types.h>
2205 #define NULL (void *)0
2211 h = gethostbyname("localhost");
2212 exit (h == NULL ? 1 : 0); }],[
2213 AC_MSG_RESULT(yes)],[
2215 AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
2221 dnl ************************************************************
2222 dnl check for working getaddrinfo() that works with AI_NUMERICHOST
2224 AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
2225 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
2228 #include <sys/types.h>
2229 #include <sys/socket.h>
2233 struct addrinfo hints, *ai;
2236 memset(&hints, 0, sizeof(hints));
2237 hints.ai_flags = AI_NUMERICHOST;
2238 hints.ai_family = AF_UNSPEC;
2239 hints.ai_socktype = SOCK_STREAM;
2240 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
2247 ac_cv_working_getaddrinfo="yes"
2249 ac_cv_working_getaddrinfo="no"
2251 ac_cv_working_getaddrinfo="yes"
2253 if test "$ac_cv_working_getaddrinfo" = "yes"; then
2254 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
2255 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
2258 AC_SUBST(IPV6_ENABLED)
2263 AC_DEFUN([CURL_CHECK_LOCALTIME_R],
2265 dnl check for localtime_r
2266 AC_CHECK_FUNCS(localtime_r,[
2267 AC_MSG_CHECKING(whether localtime_r is declared)
2268 AC_EGREP_CPP(localtime_r,[
2269 #include <time.h>],[
2270 AC_MSG_RESULT(yes)],[
2272 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
2273 AC_EGREP_CPP(localtime_r,[
2275 #include <time.h>],[
2276 AC_DEFINE(NEED_REENTRANT)
2277 AC_MSG_RESULT(yes)],
2278 AC_MSG_RESULT(no))])])
2282 dnl This function checks for strerror_r(). If it isn't found at first, it
2283 dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
2284 dnl in order to find this function.
2286 dnl If the function is found, it will then proceed to check how the function
2287 dnl actually works: glibc-style or POSIX-style.
2290 dnl char *strerror_r(int errnum, char *buf, size_t n);
2292 dnl What this one does is to return the error string (no surprises there),
2293 dnl but it doesn't usually copy anything into buf! The 'buf' and 'n'
2294 dnl parameters are only meant as an optional working area, in case strerror_r
2295 dnl needs it. A quick test on a few systems shows that it's generally not
2299 dnl int strerror_r(int errnum, char *buf, size_t n);
2301 AC_DEFUN([CURL_CHECK_STRERROR_R],
2303 AC_CHECK_FUNCS(strerror_r)
2305 if test "x$ac_cv_func_strerror_r" = "xyes"; then
2307 AC_MSG_CHECKING(whether strerror_r is declared)
2308 AC_EGREP_CPP(strerror_r,[
2309 #include <string.h>],[
2310 AC_MSG_RESULT(yes)],[
2312 AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
2313 AC_EGREP_CPP(strerror_r,[
2315 #include <string.h>],[
2316 CPPFLAGS="-D_REENTRANT $CPPFLAGS"
2317 AC_MSG_RESULT(yes)],
2319 AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
2320 ) dnl with _THREAD_SAFE
2321 ]) dnl plain cpp for it
2323 dnl determine if this strerror_r() is glibc or POSIX
2324 AC_MSG_CHECKING([for a glibc strerror_r API])
2330 char buffer[1024]; /* big enough to play with */
2332 strerror_r(EACCES, buffer, sizeof(buffer));
2333 /* this should've returned a string */
2334 if(!string || !string[0])
2339 GLIBC_STRERROR_R="1"
2340 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2341 AC_MSG_RESULT([yes]),
2342 AC_MSG_RESULT([no]),
2344 dnl Use an inferior method of strerror_r detection while cross-compiling
2346 #include <features.h>
2351 dnl looks like glibc, so assume a glibc-style strerror_r()
2352 GLIBC_STRERROR_R="1"
2353 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2354 AC_MSG_RESULT([yes]),
2355 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2356 ) dnl while cross-compiling
2359 if test -z "$GLIBC_STRERROR_R"; then
2361 AC_MSG_CHECKING([for a POSIX strerror_r API])
2367 char buffer[1024]; /* big enough to play with */
2369 strerror_r(EACCES, buffer, sizeof(buffer));
2370 /* This should've returned zero, and written an error string in the
2372 if(!buffer[0] || error)
2377 AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
2378 AC_MSG_RESULT([yes]),
2379 AC_MSG_RESULT([no]) ,
2380 dnl cross-compiling!
2381 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2384 fi dnl if not using glibc API
2386 fi dnl we have a strerror_r
2390 AC_DEFUN([CURL_CHECK_INET_NTOA_R],
2392 dnl determine if function definition for inet_ntoa_r exists.
2393 AC_CHECK_FUNCS(inet_ntoa_r,[
2394 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
2395 AC_EGREP_CPP(inet_ntoa_r,[
2396 #include <arpa/inet.h>],[
2397 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2398 AC_MSG_RESULT(yes)],[
2400 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
2401 AC_EGREP_CPP(inet_ntoa_r,[
2403 #include <arpa/inet.h>],[
2404 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2405 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT defined])
2406 AC_MSG_RESULT(yes)],
2407 AC_MSG_RESULT(no))])])
2411 dnl CURL_CHECK_GETHOSTBYADDR_R
2412 dnl -------------------------------------------------
2413 dnl check number of arguments for gethostbyaddr_r, it
2414 dnl might take either 5, 7, or 8 arguments.
2416 AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R], [
2418 AC_MSG_CHECKING([for gethostbyaddr_r])
2420 AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
2422 AC_MSG_RESULT([yes])
2423 tmp_cv_gethostbyaddr_r="yes"
2426 tmp_cv_gethostbyaddr_r="no"
2429 if test "$tmp_cv_gethostbyaddr_r" != "yes"; then
2430 AC_MSG_CHECKING([deeper for gethostbyaddr_r])
2437 AC_MSG_RESULT([yes])
2438 tmp_cv_gethostbyaddr_r="yes"
2440 AC_MSG_RESULT([but still no])
2441 tmp_cv_gethostbyaddr_r="no"
2445 if test "$tmp_cv_gethostbyaddr_r" = "yes"; then
2447 ac_cv_gethostbyaddr_r_args="unknown"
2449 AC_MSG_CHECKING([if gethostbyaddr_r takes 5 arguments])
2452 #include <sys/types.h>
2459 struct hostent_data hdata;
2461 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2464 AC_MSG_RESULT([yes])
2465 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2466 ac_cv_gethostbyaddr_r_args="5"
2471 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2472 AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 5 arguments])
2476 #include <sys/types.h>
2483 struct hostent_data hdata;
2485 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2488 AC_MSG_RESULT([yes])
2489 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2490 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
2491 ac_cv_gethostbyaddr_r_args="5"
2497 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2498 AC_MSG_CHECKING([if gethostbyaddr_r takes 7 arguments])
2501 #include <sys/types.h>
2510 struct hostent * hp;
2511 hp = gethostbyaddr_r(address, length, type, &h,
2512 buffer, 8192, &h_errnop);
2515 AC_MSG_RESULT([yes])
2516 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2517 ac_cv_gethostbyaddr_r_args="7"
2523 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2524 AC_MSG_CHECKING([if gethostbyaddr_r takes 8 arguments])
2527 #include <sys/types.h>
2536 struct hostent * hp;
2538 rc = gethostbyaddr_r(address, length, type, &h,
2539 buffer, 8192, &hp, &h_errnop);
2542 AC_MSG_RESULT([yes])
2543 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
2544 ac_cv_gethostbyaddr_r_args="8"
2550 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2551 AC_MSG_WARN([Cannot find out how to use gethostbyaddr_r])
2552 AC_MSG_WARN([HAVE_GETHOSTBYADDR_R will not be defined])
2553 ac_cv_func_gethostbyaddr_r="no"
2555 AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
2556 [Define to 1 if you have the gethostbyaddr_r function.])
2557 ac_cv_func_gethostbyaddr_r="yes"
2561 ac_cv_func_gethostbyaddr_r="no"
2566 dnl CURL_CHECK_GETHOSTBYNAME_R
2567 dnl -------------------------------------------------
2568 dnl check number of arguments for gethostbyname_r, it
2569 dnl might take either 3, 5, or 6 arguments.
2571 AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R], [
2573 AC_MSG_CHECKING([for gethostbyname_r])
2575 AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
2577 AC_MSG_RESULT([yes])
2578 tmp_cv_gethostbyname_r="yes"
2581 tmp_cv_gethostbyname_r="no"
2584 if test "$tmp_cv_gethostbyname_r" != "yes"; then
2585 AC_MSG_CHECKING([deeper for gethostbyname_r])
2592 AC_MSG_RESULT([yes])
2593 tmp_cv_gethostbyname_r="yes"
2595 AC_MSG_RESULT([but still no])
2596 tmp_cv_gethostbyname_r="no"
2600 if test "$tmp_cv_gethostbyname_r" = "yes"; then
2602 ac_cv_gethostbyname_r_args="unknown"
2604 AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
2608 #include <sys/types.h>
2611 #define NULL (void *)0
2613 gethostbyname_r(const char *, struct hostent *,
2614 struct hostent_data *);
2616 struct hostent_data data;
2617 gethostbyname_r(NULL, NULL, NULL);
2620 AC_MSG_RESULT([yes])
2621 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2622 ac_cv_gethostbyname_r_args="3"
2627 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2628 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
2633 #include <sys/types.h>
2636 #define NULL (void *)0
2638 gethostbyname_r(const char *, struct hostent *,
2639 struct hostent_data *);
2641 struct hostent_data data;
2642 gethostbyname_r(NULL, NULL, NULL);
2645 AC_MSG_RESULT([yes])
2646 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2647 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
2648 ac_cv_gethostbyname_r_args="3"
2654 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2655 AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
2658 #include <sys/types.h>
2661 #define NULL (void *)0
2663 gethostbyname_r(const char *, struct hostent *,
2664 char *, int, int *);
2666 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
2669 AC_MSG_RESULT([yes])
2670 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
2671 ac_cv_gethostbyname_r_args="5"
2677 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2678 AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
2681 #include <sys/types.h>
2684 #define NULL (void *)0
2686 gethostbyname_r(const char *, struct hostent *,
2687 char *, size_t, struct hostent **, int *);
2689 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
2692 AC_MSG_RESULT([yes])
2693 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
2694 ac_cv_gethostbyname_r_args="6"
2700 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
2701 AC_MSG_WARN([Cannot find out how to use gethostbyname_r])
2702 AC_MSG_WARN([HAVE_GETHOSTBYNAME_R will not be defined])
2703 ac_cv_func_gethostbyname_r="no"
2705 AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
2706 [Define to 1 if you have the gethostbyname_r function.])
2707 ac_cv_func_gethostbyname_r="yes"
2711 ac_cv_func_gethostbyname_r="no"
2716 dnl **********************************************************************
2717 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
2719 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
2720 dnl sets the $ICC variable to "yes" or "no"
2721 dnl **********************************************************************
2722 AC_DEFUN([CURL_DETECT_ICC],
2725 AC_MSG_CHECKING([for icc in use])
2726 if test "$GCC" = "yes"; then
2727 dnl check if this is icc acting as gcc in disguise
2728 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
2729 dnl action if the text is found, this it has not been replaced by the
2732 dnl the text was not found, it was replaced by the cpp
2734 AC_MSG_RESULT([yes])
2738 if test "$ICC" = "no"; then
2744 dnl We create a function for detecting which compiler we use and then set as
2745 dnl pendantic compiler options as possible for that particular compiler. The
2746 dnl options are only used for debug-builds.
2748 AC_DEFUN([CURL_CC_DEBUG_OPTS],
2750 if test "z$ICC" = "z"; then
2754 if test "$GCC" = "yes"; then
2756 dnl figure out gcc version!
2757 AC_MSG_CHECKING([gcc version])
2758 gccver=`$CC -dumpversion`
2759 num1=`echo $gccver | cut -d . -f1`
2760 num2=`echo $gccver | cut -d . -f2`
2761 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
2762 AC_MSG_RESULT($gccver)
2764 if test "$ICC" = "yes"; then
2765 dnl this is icc, not gcc.
2767 dnl ICC warnings we ignore:
2768 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
2769 dnl "invalid format string conversion"
2770 dnl * 279 warns on static conditions in while expressions
2771 dnl * 981 warns on "operands are evaluated in unspecified order"
2772 dnl * 1418 "external definition with no prior declaration"
2773 dnl * 1419 warns on "external declaration in primary source file"
2774 dnl which we know and do on purpose.
2776 WARN="-wd279,269,981,1418,1419"
2778 if test "$gccnum" -gt "600"; then
2779 dnl icc 6.0 and older doesn't have the -Wall flag
2783 dnl this is a set of options we believe *ALL* gcc versions support:
2784 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
2786 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
2788 if test "$gccnum" -ge "207"; then
2789 dnl gcc 2.7 or later
2790 WARN="$WARN -Wmissing-declarations"
2793 if test "$gccnum" -gt "295"; then
2794 dnl only if the compiler is newer than 2.95 since we got lots of
2795 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
2796 dnl gcc 2.95.4 on FreeBSD 4.9!
2797 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
2800 if test "$gccnum" -ge "296"; then
2801 dnl gcc 2.96 or later
2802 WARN="$WARN -Wfloat-equal"
2805 if test "$gccnum" -gt "296"; then
2806 dnl this option does not exist in 2.96
2807 WARN="$WARN -Wno-format-nonliteral"
2810 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
2811 dnl on i686-Linux as it gives us heaps with false positives.
2812 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
2813 dnl over making it unusable for generic purposes. Let's not use it.
2815 if test "$gccnum" -ge "303"; then
2816 dnl gcc 3.3 and later
2817 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
2820 if test "$gccnum" -ge "304"; then
2821 # try these on gcc 3.4
2822 WARN="$WARN -Wdeclaration-after-statement"
2825 for flag in $CPPFLAGS; do
2828 dnl Include path, provide a -isystem option for the same dir
2829 dnl to prevent warnings in those dirs. The -isystem was not very
2830 dnl reliable on earlier gcc versions.
2831 add=`echo $flag | sed 's/^-I/-isystem /g'`
2839 CFLAGS="$CFLAGS $WARN"
2841 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
2845 AC_MSG_NOTICE([Added no extra compiler options])
2849 dnl strip off optimizer flags
2851 for flag in $CFLAGS; do
2854 dnl echo "cut off $flag"
2857 NEWFLAGS="$NEWFLAGS $flag"
2863 ]) dnl end of AC_DEFUN()
2865 # This is only a temporary fix. This macro is here to replace the broken one
2866 # delivered by the automake project (including the 1.9.6 release). As soon as
2867 # they ship a working version we SHOULD remove this work-around.
2869 AC_DEFUN([AM_MISSING_HAS_RUN],
2870 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2871 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
2872 # Use eval to expand $SHELL
2873 if eval "$MISSING --run true"; then
2874 am_missing_run="$MISSING --run "
2877 AC_MSG_WARN([`missing' script is too old or missing])
2882 dnl CURL_VERIFY_RUNTIMELIBS
2883 dnl -------------------------------------------------
2884 dnl Verify that the shared libs found so far can be used when running
2885 dnl programs, since otherwise the situation will create odd configure errors
2886 dnl that are misleading people.
2888 dnl Make sure this test is run BEFORE the first test in the script that
2889 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
2890 dnl macro. It must also run AFTER all lib-checking macros are complete.
2892 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
2894 dnl this test is of course not sensible if we are cross-compiling!
2895 if test "x$cross_compiling" != xyes; then
2897 dnl just run a program to verify that the libs checked for previous to this
2898 dnl point also is available run-time!
2899 AC_MSG_CHECKING([run-time libs availability])
2906 AC_MSG_RESULT([fine]),
2907 AC_MSG_RESULT([failed])
2908 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
2911 dnl if this test fails, configure has already stopped
2916 dnl CURL_CHECK_VARIADIC_MACROS
2917 dnl -------------------------------------------------
2918 dnl Check compiler support of variadic macros
2920 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
2921 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
2922 [curl_cv_variadic_macros_c99], [
2925 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
2926 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
2927 int fun3(int arg1, int arg2, int arg3);
2928 int fun2(int arg1, int arg2);
2929 int fun3(int arg1, int arg2, int arg3)
2930 { return arg1 + arg2 + arg3; }
2931 int fun2(int arg1, int arg2)
2932 { return arg1 + arg2; }
2934 int res3 = c99_vmacro3(1, 2, 3);
2935 int res2 = c99_vmacro2(1, 2);
2938 curl_cv_variadic_macros_c99="yes"
2940 curl_cv_variadic_macros_c99="no"
2943 case "$curl_cv_variadic_macros_c99" in
2945 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
2946 [Define to 1 if compiler supports C99 variadic macro style.])
2949 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
2950 [curl_cv_variadic_macros_gcc], [
2953 #define gcc_vmacro3(first, args...) fun3(first, args)
2954 #define gcc_vmacro2(first, args...) fun2(first, args)
2955 int fun3(int arg1, int arg2, int arg3);
2956 int fun2(int arg1, int arg2);
2957 int fun3(int arg1, int arg2, int arg3)
2958 { return arg1 + arg2 + arg3; }
2959 int fun2(int arg1, int arg2)
2960 { return arg1 + arg2; }
2962 int res3 = gcc_vmacro3(1, 2, 3);
2963 int res2 = gcc_vmacro2(1, 2);
2966 curl_cv_variadic_macros_gcc="yes"
2968 curl_cv_variadic_macros_gcc="no"
2971 case "$curl_cv_variadic_macros_gcc" in
2973 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2974 [Define to 1 if compiler supports old gcc variadic macro style.])
2980 dnl CURL_CHECK_CA_BUNDLE
2981 dnl -------------------------------------------------
2982 dnl Check if a default ca-bundle should be used
2984 dnl regarding the paths this will scan:
2985 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
2986 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
2987 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
2988 dnl /etc/ssl/certs/ (ca path) SUSE
2990 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
2992 AC_MSG_CHECKING([default CA cert bundle/path])
2994 AC_ARG_WITH(ca-bundle,
2995 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
2996 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
2999 if test "x$want_ca" = "xyes"; then
3000 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
3003 [ want_ca="unset" ])
3004 AC_ARG_WITH(ca-path,
3005 AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
3006 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
3008 want_capath="$withval"
3009 if test "x$want_capath" = "xyes"; then
3010 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
3013 [ want_capath="unset"])
3015 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
3016 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
3018 AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
3019 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
3020 dnl --with-ca-bundle given
3023 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
3024 dnl --with-ca-path given
3025 if test "x$OPENSSL_ENABLED" != "x1"; then
3026 AC_MSG_ERROR([--with-ca-path only works with openSSL])
3028 capath="$want_capath"
3031 dnl neither of --with-ca-* given
3032 dnl first try autodetecting a CA bundle , then a CA path
3033 dnl both autodetections can be skipped by --without-ca-*
3036 if test "x$want_ca" = "xunset"; then
3037 dnl the path we previously would have installed the curl ca bundle
3038 dnl to, and thus we now check for an already existing cert in that place
3039 dnl in case we find no other
3040 if test "x$prefix" != xNONE; then
3041 cac="${prefix}/share/curl/curl-ca-bundle.crt"
3043 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
3046 for a in /etc/ssl/certs/ca-certificates.crt \
3047 /etc/pki/tls/certs/ca-bundle.crt \
3048 /usr/share/ssl/certs/ca-bundle.crt \
3050 if test -f "$a"; then
3056 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
3057 "x$OPENSSL_ENABLED" = "x1"; then
3058 for a in /etc/ssl/certs/; do
3059 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
3069 if test "x$ca" != "xno"; then
3070 CURL_CA_BUNDLE='"'$ca'"'
3071 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
3072 AC_MSG_RESULT([$ca])
3073 elif test "x$capath" != "xno"; then
3074 CURL_CA_PATH="\"$capath\""
3075 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
3076 AC_MSG_RESULT([$capath (capath)])