1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at http://curl.haxx.se/docs/copyright.html.
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
22 ###########################################################################
25 dnl CURL_CHECK_HEADER_WINDOWS
26 dnl -------------------------------------------------
27 dnl Check for compilable and valid windows.h header
29 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
30 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
34 #ifndef WIN32_LEAN_AND_MEAN
35 #define WIN32_LEAN_AND_MEAN
40 HAVE_WINDOWS_H shall not be defined.
46 ac_cv_header_windows_h="yes"
48 ac_cv_header_windows_h="no"
51 case "$ac_cv_header_windows_h" in
53 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
54 [Define to 1 if you have the windows.h header file.])
55 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
56 [Define to avoid automatic inclusion of winsock.h])
62 dnl CURL_CHECK_HEADER_WINSOCK
63 dnl -------------------------------------------------
64 dnl Check for compilable and valid winsock.h header
66 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
67 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
68 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
72 #ifndef WIN32_LEAN_AND_MEAN
73 #define WIN32_LEAN_AND_MEAN
79 HAVE_WINSOCK_H shall not be defined.
81 int dummy=WSACleanup();
85 ac_cv_header_winsock_h="yes"
87 ac_cv_header_winsock_h="no"
90 case "$ac_cv_header_winsock_h" in
92 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
93 [Define to 1 if you have the winsock.h header file.])
99 dnl CURL_CHECK_HEADER_WINSOCK2
100 dnl -------------------------------------------------
101 dnl Check for compilable and valid winsock2.h header
103 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
104 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
105 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
109 #ifndef WIN32_LEAN_AND_MEAN
110 #define WIN32_LEAN_AND_MEAN
113 #include <winsock2.h>
116 HAVE_WINSOCK2_H shall not be defined.
118 int dummy=2*IPPROTO_ESP;
122 ac_cv_header_winsock2_h="yes"
124 ac_cv_header_winsock2_h="no"
127 case "$ac_cv_header_winsock2_h" in
129 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
130 [Define to 1 if you have the winsock2.h header file.])
136 dnl CURL_CHECK_HEADER_WS2TCPIP
137 dnl -------------------------------------------------
138 dnl Check for compilable and valid ws2tcpip.h header
140 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
141 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
142 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
146 #ifndef WIN32_LEAN_AND_MEAN
147 #define WIN32_LEAN_AND_MEAN
150 #include <winsock2.h>
151 #include <ws2tcpip.h>
154 HAVE_WS2TCPIP_H shall not be defined.
156 int dummy=2*IP_PKTINFO;
160 ac_cv_header_ws2tcpip_h="yes"
162 ac_cv_header_ws2tcpip_h="no"
165 case "$ac_cv_header_ws2tcpip_h" in
167 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
168 [Define to 1 if you have the ws2tcpip.h header file.])
174 dnl CURL_CHECK_HEADER_WINLDAP
175 dnl -------------------------------------------------
176 dnl Check for compilable and valid winldap.h header
178 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
179 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
180 AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
184 #ifdef HAVE_WINDOWS_H
185 #ifndef WIN32_LEAN_AND_MEAN
186 #define WIN32_LEAN_AND_MEAN
193 HAVE_WINLDAP_H shall not be defined.
195 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
196 ULONG res = ldap_unbind(ldp);
200 ac_cv_header_winldap_h="yes"
202 ac_cv_header_winldap_h="no"
205 case "$ac_cv_header_winldap_h" in
207 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
208 [Define to 1 if you have the winldap.h header file.])
214 dnl CURL_CHECK_HEADER_WINBER
215 dnl -------------------------------------------------
216 dnl Check for compilable and valid winber.h header
218 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
219 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
220 AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
224 #ifdef HAVE_WINDOWS_H
225 #ifndef WIN32_LEAN_AND_MEAN
226 #define WIN32_LEAN_AND_MEAN
234 HAVE_WINBER_H shall not be defined.
237 BerElement *bep = ber_init(bvp);
242 ac_cv_header_winber_h="yes"
244 ac_cv_header_winber_h="no"
247 case "$ac_cv_header_winber_h" in
249 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
250 [Define to 1 if you have the winber.h header file.])
256 dnl CURL_CHECK_HEADER_LBER
257 dnl -------------------------------------------------
258 dnl Check for compilable and valid lber.h header,
259 dnl and check if it is needed even with ldap.h
261 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
262 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
263 AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
267 #ifdef HAVE_WINDOWS_H
268 #ifndef WIN32_LEAN_AND_MEAN
269 #define WIN32_LEAN_AND_MEAN
273 #ifdef HAVE_SYS_TYPES_H
274 #include <sys/types.h>
278 #define NULL (void *)0
282 BerValue *bvp = NULL;
283 BerElement *bep = ber_init(bvp);
287 ac_cv_header_lber_h="yes"
289 ac_cv_header_lber_h="no"
292 if test "$ac_cv_header_lber_h" = "yes"; then
293 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
294 [Define to 1 if you have the lber.h header file.])
299 #ifdef HAVE_WINDOWS_H
300 #ifndef WIN32_LEAN_AND_MEAN
301 #define WIN32_LEAN_AND_MEAN
305 #ifdef HAVE_SYS_TYPES_H
306 #include <sys/types.h>
310 #define NULL (void *)0
312 #ifndef LDAP_DEPRECATED
313 #define LDAP_DEPRECATED 1
317 BerValue *bvp = NULL;
318 BerElement *bep = ber_init(bvp);
322 curl_cv_need_header_lber_h="no"
324 curl_cv_need_header_lber_h="yes"
327 case "$curl_cv_need_header_lber_h" in
329 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
330 [Define to 1 if you need the lber.h header file even with ldap.h])
337 dnl CURL_CHECK_HEADER_LDAP
338 dnl -------------------------------------------------
339 dnl Check for compilable and valid ldap.h header
341 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
342 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
343 AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
347 #ifdef HAVE_WINDOWS_H
348 #ifndef WIN32_LEAN_AND_MEAN
349 #define WIN32_LEAN_AND_MEAN
353 #ifdef HAVE_SYS_TYPES_H
354 #include <sys/types.h>
357 #ifndef LDAP_DEPRECATED
358 #define LDAP_DEPRECATED 1
365 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
366 int res = ldap_unbind(ldp);
369 ac_cv_header_ldap_h="yes"
371 ac_cv_header_ldap_h="no"
374 case "$ac_cv_header_ldap_h" in
376 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
377 [Define to 1 if you have the ldap.h header file.])
383 dnl CURL_CHECK_HEADER_LDAP_SSL
384 dnl -------------------------------------------------
385 dnl Check for compilable and valid ldap_ssl.h header
387 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
388 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
389 AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
393 #ifdef HAVE_WINDOWS_H
394 #ifndef WIN32_LEAN_AND_MEAN
395 #define WIN32_LEAN_AND_MEAN
399 #ifdef HAVE_SYS_TYPES_H
400 #include <sys/types.h>
403 #ifndef LDAP_DEPRECATED
404 #define LDAP_DEPRECATED 1
412 #include <ldap_ssl.h>
414 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
417 ac_cv_header_ldap_ssl_h="yes"
419 ac_cv_header_ldap_ssl_h="no"
422 case "$ac_cv_header_ldap_ssl_h" in
424 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
425 [Define to 1 if you have the ldap_ssl.h header file.])
431 dnl CURL_CHECK_HEADER_LDAPSSL
432 dnl -------------------------------------------------
433 dnl Check for compilable and valid ldapssl.h header
435 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
436 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
437 AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
441 #ifdef HAVE_WINDOWS_H
442 #ifndef WIN32_LEAN_AND_MEAN
443 #define WIN32_LEAN_AND_MEAN
447 #ifdef HAVE_SYS_TYPES_H
448 #include <sys/types.h>
452 #define NULL (void *)0
454 #ifndef LDAP_DEPRECATED
455 #define LDAP_DEPRECATED 1
465 char *cert_label = NULL;
466 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
469 ac_cv_header_ldapssl_h="yes"
471 ac_cv_header_ldapssl_h="no"
474 case "$ac_cv_header_ldapssl_h" in
476 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
477 [Define to 1 if you have the ldapssl.h header file.])
483 dnl CURL_CHECK_LIBS_LDAP
484 dnl -------------------------------------------------
485 dnl Check for libraries needed for LDAP support,
486 dnl and prepended to LIBS any needed libraries.
488 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
489 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
491 AC_MSG_CHECKING([for LDAP libraries])
493 curl_cv_save_LIBS=$LIBS
494 curl_cv_ldap_LIBS="unknown"
496 for x_nlibs in '' '-lldap' '-llber -lldap' '-lldap -llber'; do
497 if test -z "$x_nlibs"; then
498 LIBS="$curl_cv_save_LIBS"
500 LIBS="$x_nlibs $curl_cv_save_LIBS"
505 #ifdef HAVE_WINDOWS_H
506 #ifndef WIN32_LEAN_AND_MEAN
507 #define WIN32_LEAN_AND_MEAN
511 #ifdef HAVE_SYS_TYPES_H
512 #include <sys/types.h>
516 #define NULL (void *)0
518 #ifndef LDAP_DEPRECATED
519 #define LDAP_DEPRECATED 1
528 BerValue *bvp = NULL;
529 BerElement *bep = ber_init(bvp);
530 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
531 int res = ldap_unbind(ldp);
535 curl_cv_ldap_LIBS="$x_nlibs"
540 LIBS=$curl_cv_save_LIBS
542 case X-"$curl_cv_ldap_LIBS" in
544 AC_MSG_RESULT([cannot find LDAP libraries])
547 AC_MSG_RESULT([no additional lib required])
550 if test -z "$curl_cv_save_LIBS"; then
551 LIBS="$curl_cv_ldap_LIBS"
553 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
555 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
562 dnl CURL_CHECK_HEADER_MALLOC
563 dnl -------------------------------------------------
564 dnl Check for compilable and valid malloc.h header,
565 dnl and check if it is needed even with stdlib.h
567 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
568 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
573 void *p = malloc(10);
574 void *q = calloc(10,10);
579 ac_cv_header_malloc_h="yes"
581 ac_cv_header_malloc_h="no"
584 if test "$ac_cv_header_malloc_h" = "yes"; then
585 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
586 [Define to 1 if you have the malloc.h header file.])
592 void *p = malloc(10);
593 void *q = calloc(10,10);
598 curl_cv_need_header_malloc_h="no"
600 curl_cv_need_header_malloc_h="yes"
603 case "$curl_cv_need_header_malloc_h" in
605 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
606 [Define to 1 if you need the malloc.h header file even with stdlib.h])
613 dnl CURL_CHECK_TYPE_SOCKLEN_T
614 dnl -------------------------------------------------
615 dnl Check for existing socklen_t type, and provide
616 dnl an equivalent type if socklen_t not available
618 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
619 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
620 AC_CHECK_TYPE([socklen_t], ,[
621 AC_CACHE_CHECK([for socklen_t equivalent],
622 [curl_cv_socklen_t_equiv], [
623 curl_cv_socklen_t_equiv="unknown"
624 for arg2 in "struct sockaddr" void; do
625 for t in int size_t unsigned long "unsigned long"; do
629 #ifdef HAVE_WINDOWS_H
630 #ifndef WIN32_LEAN_AND_MEAN
631 #define WIN32_LEAN_AND_MEAN
634 #ifdef HAVE_WINSOCK2_H
635 #include <winsock2.h>
637 #ifdef HAVE_WINSOCK_H
642 #ifdef HAVE_SYS_TYPES_H
643 #include <sys/types.h>
645 #ifdef HAVE_SYS_SOCKET_H
646 #include <sys/socket.h>
649 int getpeername (int, $arg2 *, $t *);
652 getpeername(0,0,&len);
655 curl_cv_socklen_t_equiv="$t"
661 case "$curl_cv_socklen_t_equiv" in
663 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
666 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
667 [type to use in place of socklen_t if not defined])
672 #ifdef HAVE_WINDOWS_H
673 #ifndef WIN32_LEAN_AND_MEAN
674 #define WIN32_LEAN_AND_MEAN
677 #ifdef HAVE_WINSOCK2_H
678 #include <winsock2.h>
679 #ifdef HAVE_WS2TCPIP_H
680 #include <ws2tcpip.h>
684 #ifdef HAVE_SYS_TYPES_H
685 #include <sys/types.h>
687 #ifdef HAVE_SYS_SOCKET_H
688 #include <sys/socket.h>
695 dnl CURL_CHECK_FUNC_GETNAMEINFO
696 dnl -------------------------------------------------
697 dnl Test if the getnameinfo function is available,
698 dnl and check the types of five of its arguments.
699 dnl If the function succeeds HAVE_GETNAMEINFO will be
700 dnl defined, defining the types of the arguments in
701 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
702 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
703 dnl and also defining the type qualifier of first
704 dnl argument in GETNAMEINFO_QUAL_ARG1.
706 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
707 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
708 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
709 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
711 AC_MSG_CHECKING([for getnameinfo])
713 AC_LANG_FUNC_LINK_TRY([getnameinfo])
716 curl_cv_getnameinfo="yes"
719 curl_cv_getnameinfo="no"
722 if test "$curl_cv_getnameinfo" != "yes"; then
723 AC_MSG_CHECKING([deeper for getnameinfo])
729 curl_cv_getnameinfo="yes"
731 AC_MSG_RESULT([but still no])
732 curl_cv_getnameinfo="no"
736 if test "$curl_cv_getnameinfo" != "yes"; then
737 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
740 #ifdef HAVE_WINDOWS_H
741 #ifndef WIN32_LEAN_AND_MEAN
742 #define WIN32_LEAN_AND_MEAN
745 #ifdef HAVE_WINSOCK2_H
746 #include <winsock2.h>
747 #ifdef HAVE_WS2TCPIP_H
748 #include <ws2tcpip.h>
752 #ifdef HAVE_SYS_TYPES_H
753 #include <sys/types.h>
755 #ifdef HAVE_SYS_SOCKET_H
756 #include <sys/socket.h>
763 getnameinfo(0, 0, 0, 0, 0, 0, 0);
766 curl_cv_getnameinfo="yes"
768 AC_MSG_RESULT([but still no])
769 curl_cv_getnameinfo="no"
773 if test "$curl_cv_getnameinfo" = "yes"; then
774 AC_CACHE_CHECK([types of arguments for getnameinfo],
775 [curl_cv_func_getnameinfo_args], [
776 curl_cv_func_getnameinfo_args="unknown"
777 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
778 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
779 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
780 for gni_arg7 in 'int' 'unsigned int'; do
784 #ifdef HAVE_WINDOWS_H
785 #ifndef WIN32_LEAN_AND_MEAN
786 #define WIN32_LEAN_AND_MEAN
788 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
790 #define _WIN32_WINNT 0x0501
793 #ifdef HAVE_WINSOCK2_H
794 #include <winsock2.h>
795 #ifdef HAVE_WS2TCPIP_H
796 #include <ws2tcpip.h>
799 #define GNICALLCONV WSAAPI
801 #ifdef HAVE_SYS_TYPES_H
802 #include <sys/types.h>
804 #ifdef HAVE_SYS_SOCKET_H
805 #include <sys/socket.h>
812 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
818 $gni_arg46 hostlen=0;
819 $gni_arg46 servlen=0;
821 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
824 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
832 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
833 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
834 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
836 gni_prev_IFS=$IFS; IFS=','
837 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
841 gni_qual_type_arg1=$[1]
843 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
844 [Define to the type of arg 2 for getnameinfo.])
845 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
846 [Define to the type of args 4 and 6 for getnameinfo.])
847 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
848 [Define to the type of arg 7 for getnameinfo.])
852 case $prev_sh_opts in
860 case "$gni_qual_type_arg1" in
863 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
867 gni_type_arg1=$gni_qual_type_arg1
871 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
872 [Define to the type qualifier of arg 1 for getnameinfo.])
873 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
874 [Define to the type of arg 1 for getnameinfo.])
876 case $prev_sh_opts in
884 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
885 [Define to 1 if you have the getnameinfo function.])
886 ac_cv_func_getnameinfo="yes"
892 dnl TYPE_SOCKADDR_STORAGE
893 dnl -------------------------------------------------
894 dnl Check for struct sockaddr_storage. Most IPv6-enabled
895 dnl hosts have it, but AIX 4.3 is one known exception.
897 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
899 AC_CHECK_TYPE([struct sockaddr_storage],
900 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
901 [if struct sockaddr_storage is defined]), ,
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>
913 #ifdef HAVE_SYS_TYPES_H
914 #include <sys/types.h>
916 #ifdef HAVE_SYS_SOCKET_H
917 #include <sys/socket.h>
919 #ifdef HAVE_NETINET_IN_H
920 #include <netinet/in.h>
922 #ifdef HAVE_ARPA_INET_H
923 #include <arpa/inet.h>
930 dnl CURL_CHECK_NI_WITHSCOPEID
931 dnl -------------------------------------------------
932 dnl Check for working NI_WITHSCOPEID in getnameinfo()
934 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
935 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
936 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
937 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
938 netdb.h netinet/in.h arpa/inet.h)
940 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
941 [ac_cv_working_ni_withscopeid], [
947 #ifdef HAVE_SYS_TYPES_H
948 #include <sys/types.h>
950 #ifdef HAVE_SYS_SOCKET_H
951 #include <sys/socket.h>
956 #ifdef HAVE_NETINET_IN_H
957 #include <netinet/in.h>
959 #ifdef HAVE_ARPA_INET_H
960 #include <arpa/inet.h>
963 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
964 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
965 struct sockaddr_storage sa;
967 unsigned char sa[256];
969 char hostbuf[NI_MAXHOST];
971 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
972 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
973 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
974 int fd = socket(AF_INET6, SOCK_STREAM, 0);
977 return 1; /* Error creating socket */
979 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
981 perror("getsockname()");
982 return 2; /* Error retrieving socket name */
984 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
986 printf("rc = %s\n", gai_strerror(rc));
987 return 3; /* Error translating socket address */
989 return 0; /* Ok, NI_WITHSCOPEID works */
991 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
995 # Exit code == 0. Program worked.
996 ac_cv_working_ni_withscopeid="yes"
998 # Exit code != 0. Program failed.
999 ac_cv_working_ni_withscopeid="no"
1001 # Program is not run when cross-compiling. So we assume
1002 # NI_WITHSCOPEID will work if we are able to compile it.
1005 #include <sys/types.h>
1006 #include <sys/socket.h>
1009 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1012 ac_cv_working_ni_withscopeid="yes"
1014 ac_cv_working_ni_withscopeid="no"
1015 ]) # AC_COMPILE_IFELSE
1018 case "$ac_cv_working_ni_withscopeid" in
1020 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1021 [Define to 1 if NI_WITHSCOPEID exists and works.])
1027 dnl CURL_CHECK_FUNC_RECV
1028 dnl -------------------------------------------------
1029 dnl Test if the socket recv() function is available,
1030 dnl and check its return type and the types of its
1031 dnl arguments. If the function succeeds HAVE_RECV
1032 dnl will be defined, defining the types of the arguments
1033 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1034 dnl and RECV_TYPE_ARG4, defining the type of the function
1035 dnl return value in RECV_TYPE_RETV.
1037 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1038 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1039 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1040 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1042 AC_MSG_CHECKING([for recv])
1045 #ifdef HAVE_WINDOWS_H
1046 #ifndef WIN32_LEAN_AND_MEAN
1047 #define WIN32_LEAN_AND_MEAN
1049 #include <windows.h>
1050 #ifdef HAVE_WINSOCK2_H
1051 #include <winsock2.h>
1053 #ifdef HAVE_WINSOCK_H
1054 #include <winsock.h>
1058 #ifdef HAVE_SYS_TYPES_H
1059 #include <sys/types.h>
1061 #ifdef HAVE_SYS_SOCKET_H
1062 #include <sys/socket.h>
1068 AC_MSG_RESULT([yes])
1075 if test "$curl_cv_recv" = "yes"; then
1076 AC_CACHE_CHECK([types of args and return type for recv],
1077 [curl_cv_func_recv_args], [
1078 curl_cv_func_recv_args="unknown"
1079 for recv_retv in 'int' 'ssize_t'; do
1080 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1081 for recv_arg2 in 'char *' 'void *'; do
1082 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1083 for recv_arg4 in 'int' 'unsigned int'; do
1087 #ifdef HAVE_WINDOWS_H
1088 #ifndef WIN32_LEAN_AND_MEAN
1089 #define WIN32_LEAN_AND_MEAN
1091 #include <windows.h>
1092 #ifdef HAVE_WINSOCK2_H
1093 #include <winsock2.h>
1095 #ifdef HAVE_WINSOCK_H
1096 #include <winsock.h>
1099 #define RECVCALLCONV PASCAL
1101 #ifdef HAVE_SYS_TYPES_H
1102 #include <sys/types.h>
1104 #ifdef HAVE_SYS_SOCKET_H
1105 #include <sys/socket.h>
1107 #define RECVCALLCONV
1109 extern $recv_retv RECVCALLCONV recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1115 $recv_retv res = recv(s, buf, len, flags);
1118 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1127 if test "$curl_cv_func_recv_args" = "unknown"; then
1128 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1130 recv_prev_IFS=$IFS; IFS=','
1131 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1135 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1136 [Define to the type of arg 1 for recv.])
1137 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1138 [Define to the type of arg 2 for recv.])
1139 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1140 [Define to the type of arg 3 for recv.])
1141 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1142 [Define to the type of arg 4 for recv.])
1143 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1144 [Define to the function return type for recv.])
1146 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1147 [Define to 1 if you have the recv function.])
1148 ac_cv_func_recv="yes"
1151 AC_MSG_ERROR([Unable to link function recv])
1156 dnl CURL_CHECK_FUNC_SEND
1157 dnl -------------------------------------------------
1158 dnl Test if the socket send() function is available,
1159 dnl and check its return type and the types of its
1160 dnl arguments. If the function succeeds HAVE_SEND
1161 dnl will be defined, defining the types of the arguments
1162 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1163 dnl and SEND_TYPE_ARG4, defining the type of the function
1164 dnl return value in SEND_TYPE_RETV, and also defining the
1165 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1167 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1168 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1169 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1170 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1172 AC_MSG_CHECKING([for send])
1175 #ifdef HAVE_WINDOWS_H
1176 #ifndef WIN32_LEAN_AND_MEAN
1177 #define WIN32_LEAN_AND_MEAN
1179 #include <windows.h>
1180 #ifdef HAVE_WINSOCK2_H
1181 #include <winsock2.h>
1183 #ifdef HAVE_WINSOCK_H
1184 #include <winsock.h>
1188 #ifdef HAVE_SYS_TYPES_H
1189 #include <sys/types.h>
1191 #ifdef HAVE_SYS_SOCKET_H
1192 #include <sys/socket.h>
1198 AC_MSG_RESULT([yes])
1205 if test "$curl_cv_send" = "yes"; then
1206 AC_CACHE_CHECK([types of args and return type for send],
1207 [curl_cv_func_send_args], [
1208 curl_cv_func_send_args="unknown"
1209 for send_retv in 'int' 'ssize_t'; do
1210 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1211 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1212 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1213 for send_arg4 in 'int' 'unsigned int'; do
1217 #ifdef HAVE_WINDOWS_H
1218 #ifndef WIN32_LEAN_AND_MEAN
1219 #define WIN32_LEAN_AND_MEAN
1221 #include <windows.h>
1222 #ifdef HAVE_WINSOCK2_H
1223 #include <winsock2.h>
1225 #ifdef HAVE_WINSOCK_H
1226 #include <winsock.h>
1229 #define SENDCALLCONV PASCAL
1231 #ifdef HAVE_SYS_TYPES_H
1232 #include <sys/types.h>
1234 #ifdef HAVE_SYS_SOCKET_H
1235 #include <sys/socket.h>
1237 #define SENDCALLCONV
1239 extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1244 $send_retv res = send(s, 0, len, flags);
1247 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1256 if test "$curl_cv_func_send_args" = "unknown"; then
1257 AC_MSG_ERROR([Cannot find proper types to use for send args])
1259 send_prev_IFS=$IFS; IFS=','
1260 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1264 send_qual_type_arg2=$[2]
1266 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1267 [Define to the type of arg 1 for send.])
1268 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1269 [Define to the type of arg 3 for send.])
1270 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1271 [Define to the type of arg 4 for send.])
1272 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1273 [Define to the function return type for send.])
1277 case $prev_sh_opts in
1285 case "$send_qual_type_arg2" in
1287 send_qual_arg2=const
1288 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1292 send_type_arg2=$send_qual_type_arg2
1296 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1297 [Define to the type qualifier of arg 2 for send.])
1298 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1299 [Define to the type of arg 2 for send.])
1301 case $prev_sh_opts in
1309 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1310 [Define to 1 if you have the send function.])
1311 ac_cv_func_send="yes"
1314 AC_MSG_ERROR([Unable to link function send])
1319 dnl CURL_CHECK_MSG_NOSIGNAL
1320 dnl -------------------------------------------------
1321 dnl Check for MSG_NOSIGNAL
1323 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1324 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1325 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1329 #ifdef HAVE_WINDOWS_H
1330 #ifndef WIN32_LEAN_AND_MEAN
1331 #define WIN32_LEAN_AND_MEAN
1333 #include <windows.h>
1334 #ifdef HAVE_WINSOCK2_H
1335 #include <winsock2.h>
1337 #ifdef HAVE_WINSOCK_H
1338 #include <winsock.h>
1342 #ifdef HAVE_SYS_TYPES_H
1343 #include <sys/types.h>
1345 #ifdef HAVE_SYS_SOCKET_H
1346 #include <sys/socket.h>
1350 int flag=MSG_NOSIGNAL;
1353 ac_cv_msg_nosignal="yes"
1355 ac_cv_msg_nosignal="no"
1358 case "$ac_cv_msg_nosignal" in
1360 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1361 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1367 dnl CURL_CHECK_STRUCT_TIMEVAL
1368 dnl -------------------------------------------------
1369 dnl Check for timeval struct
1371 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1372 AC_REQUIRE([AC_HEADER_TIME])dnl
1373 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1374 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1375 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1376 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1380 #ifdef HAVE_WINDOWS_H
1381 #ifndef WIN32_LEAN_AND_MEAN
1382 #define WIN32_LEAN_AND_MEAN
1384 #include <windows.h>
1385 #ifdef HAVE_WINSOCK2_H
1386 #include <winsock2.h>
1388 #ifdef HAVE_WINSOCK_H
1389 #include <winsock.h>
1393 #ifdef HAVE_SYS_TYPES_H
1394 #include <sys/types.h>
1396 #ifdef HAVE_SYS_TIME_H
1397 #include <sys/time.h>
1398 #ifdef TIME_WITH_SYS_TIME
1412 ac_cv_struct_timeval="yes"
1414 ac_cv_struct_timeval="no"
1417 case "$ac_cv_struct_timeval" in
1419 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1420 [Define to 1 if you have the timeval struct.])
1426 dnl TYPE_SIG_ATOMIC_T
1427 dnl -------------------------------------------------
1428 dnl Check if the sig_atomic_t type is available, and
1429 dnl verify if it is already defined as volatile.
1431 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1432 AC_CHECK_HEADERS(signal.h)
1433 AC_CHECK_TYPE([sig_atomic_t],[
1434 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1435 [Define to 1 if sig_atomic_t is an available typedef.])
1437 #ifdef HAVE_SIGNAL_H
1441 case "$ac_cv_type_sig_atomic_t" in
1444 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1446 #ifdef HAVE_SIGNAL_H
1450 static volatile sig_atomic_t dummy = 0;
1453 ac_cv_sig_atomic_t_volatile="no"
1455 AC_MSG_RESULT([yes])
1456 ac_cv_sig_atomic_t_volatile="yes"
1459 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1460 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1461 [Define to 1 if sig_atomic_t is already defined as volatile.])
1468 dnl CURL_CHECK_NONBLOCKING_SOCKET
1469 dnl -------------------------------------------------
1470 dnl Check for how to set a socket to non-blocking state. There seems to exist
1471 dnl four known different ways, with the one used almost everywhere being POSIX
1472 dnl and XPG3, while the other different ways for different systems (old BSD,
1473 dnl Windows and Amiga).
1475 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1476 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1477 dnl to get caught in this script by using an excessive number of #ifdefs...
1479 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
1481 AC_MSG_CHECKING([non-blocking sockets style])
1484 /* headers for O_NONBLOCK test */
1485 #include <sys/types.h>
1489 /* try to compile O_NONBLOCK */
1491 #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1492 # if defined(__SVR4) || defined(__srv4__)
1493 # define PLATFORM_SOLARIS
1495 # define PLATFORM_SUNOS4
1498 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
1499 # define PLATFORM_AIX_V3
1502 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1503 #error "O_NONBLOCK does not work on this platform"
1506 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1508 dnl the O_NONBLOCK test was fine
1509 nonblock="O_NONBLOCK"
1510 AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
1512 dnl the code was bad, try a different program now, test 2
1515 /* headers for FIONBIO test */
1517 #include <stropts.h>
1519 /* FIONBIO source test (old-style unix) */
1521 int flags = ioctl(socket, FIONBIO, &flags);
1523 dnl FIONBIO test was good
1525 AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
1527 dnl FIONBIO test was also bad
1528 dnl the code was bad, try a different program now, test 3
1531 /* headers for ioctlsocket test (Windows) */
1533 #ifdef HAVE_WINDOWS_H
1534 #ifndef WIN32_LEAN_AND_MEAN
1535 #define WIN32_LEAN_AND_MEAN
1537 #include <windows.h>
1538 #ifdef HAVE_WINSOCK2_H
1539 #include <winsock2.h>
1541 #ifdef HAVE_WINSOCK_H
1542 #include <winsock.h>
1547 /* ioctlsocket source code */
1549 unsigned long flags = 0;
1550 sd = socket(0, 0, 0);
1551 ioctlsocket(sd, FIONBIO, &flags);
1553 dnl ioctlsocket test was good
1554 nonblock="ioctlsocket"
1555 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
1557 dnl ioctlsocket didnt compile!, go to test 4
1560 /* headers for IoctlSocket test (Amiga?) */
1561 #include <sys/ioctl.h>
1563 /* IoctlSocket source code */
1565 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1567 dnl ioctlsocket test was good
1568 nonblock="IoctlSocket"
1569 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
1571 dnl Ioctlsocket didnt compile, do test 5!
1573 /* headers for SO_NONBLOCK test (BeOS) */
1576 /* SO_NONBLOCK source code */
1579 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1581 dnl the SO_NONBLOCK test was good
1582 nonblock="SO_NONBLOCK"
1583 AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
1585 dnl test 5 didnt compile!
1587 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
1589 dnl end of fifth test
1592 dnl end of forth test
1595 dnl end of third test
1598 dnl end of second test
1601 dnl end of non-blocking try-compile test
1602 AC_MSG_RESULT($nonblock)
1604 if test "$nonblock" = "nada"; then
1605 AC_MSG_WARN([non-block sockets disabled])
1611 dnl -------------------------------------------------
1612 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1613 dnl and a few other things.
1614 AC_DEFUN([TYPE_IN_ADDR_T],
1616 AC_CHECK_TYPE([in_addr_t], ,[
1617 AC_MSG_CHECKING([for in_addr_t equivalent])
1618 AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
1620 curl_cv_in_addr_t_equiv=
1621 for t in "unsigned long" int size_t unsigned long; do
1624 #ifdef HAVE_WINDOWS_H
1625 #ifndef WIN32_LEAN_AND_MEAN
1626 #define WIN32_LEAN_AND_MEAN
1628 #include <windows.h>
1629 #ifdef HAVE_WINSOCK2_H
1630 #include <winsock2.h>
1632 #ifdef HAVE_WINSOCK_H
1633 #include <winsock.h>
1637 #ifdef HAVE_SYS_TYPES_H
1638 #include <sys/types.h>
1640 #ifdef HAVE_SYS_SOCKET_H
1641 #include <sys/socket.h>
1643 #ifdef HAVE_NETINET_IN_H
1644 #include <netinet/in.h>
1646 #ifdef HAVE_ARPA_INET_H
1647 #include <arpa/inet.h>
1651 $t data = inet_addr ("1.2.3.4");
1653 curl_cv_in_addr_t_equiv="$t"
1658 if test "x$curl_cv_in_addr_t_equiv" = x; then
1659 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1662 AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
1663 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1664 [type to use in place of in_addr_t if not defined])],
1667 #ifdef HAVE_WINDOWS_H
1668 #ifndef WIN32_LEAN_AND_MEAN
1669 #define WIN32_LEAN_AND_MEAN
1671 #include <windows.h>
1672 #ifdef HAVE_WINSOCK2_H
1673 #include <winsock2.h>
1675 #ifdef HAVE_WINSOCK_H
1676 #include <winsock.h>
1680 #ifdef HAVE_SYS_TYPES_H
1681 #include <sys/types.h>
1683 #ifdef HAVE_SYS_SOCKET_H
1684 #include <sys/socket.h>
1686 #ifdef HAVE_NETINET_IN_H
1687 #include <netinet/in.h>
1689 #ifdef HAVE_ARPA_INET_H
1690 #include <arpa/inet.h>
1693 ]) dnl AC_CHECK_TYPE
1696 dnl ************************************************************
1697 dnl check for "localhost", if it doesn't exist, we can't do the
1698 dnl gethostbyname_r tests!
1701 AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[
1702 AC_MSG_CHECKING([if "localhost" resolves])
1705 #include <sys/types.h>
1708 #define NULL (void *)0
1714 h = gethostbyname("localhost");
1715 exit (h == NULL ? 1 : 0); }],[
1716 AC_MSG_RESULT(yes)],[
1718 AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
1724 dnl ************************************************************
1725 dnl check for working getaddrinfo() that works with AI_NUMERICHOST
1727 AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
1728 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
1731 #include <sys/types.h>
1732 #include <sys/socket.h>
1736 struct addrinfo hints, *ai;
1739 memset(&hints, 0, sizeof(hints));
1740 hints.ai_flags = AI_NUMERICHOST;
1741 hints.ai_family = AF_UNSPEC;
1742 hints.ai_socktype = SOCK_STREAM;
1743 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
1750 ac_cv_working_getaddrinfo="yes"
1752 ac_cv_working_getaddrinfo="no"
1754 ac_cv_working_getaddrinfo="yes"
1756 if test "$ac_cv_working_getaddrinfo" = "yes"; then
1757 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
1758 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
1761 AC_SUBST(IPV6_ENABLED)
1766 AC_DEFUN([CURL_CHECK_LOCALTIME_R],
1768 dnl check for localtime_r
1769 AC_CHECK_FUNCS(localtime_r,[
1770 AC_MSG_CHECKING(whether localtime_r is declared)
1771 AC_EGREP_CPP(localtime_r,[
1772 #include <time.h>],[
1773 AC_MSG_RESULT(yes)],[
1775 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
1776 AC_EGREP_CPP(localtime_r,[
1778 #include <time.h>],[
1779 AC_DEFINE(NEED_REENTRANT)
1780 AC_MSG_RESULT(yes)],
1781 AC_MSG_RESULT(no))])])
1785 dnl This function checks for strerror_r(). If it isn't found at first, it
1786 dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
1787 dnl in order to find this function.
1789 dnl If the function is found, it will then proceed to check how the function
1790 dnl actually works: glibc-style or POSIX-style.
1793 dnl char *strerror_r(int errnum, char *buf, size_t n);
1795 dnl What this one does is to return the error string (no surprises there),
1796 dnl but it doesn't usually copy anything into buf! The 'buf' and 'n'
1797 dnl parameters are only meant as an optional working area, in case strerror_r
1798 dnl needs it. A quick test on a few systems shows that it's generally not
1802 dnl int strerror_r(int errnum, char *buf, size_t n);
1804 AC_DEFUN([CURL_CHECK_STRERROR_R],
1806 AC_CHECK_FUNCS(strerror_r)
1808 if test "x$ac_cv_func_strerror_r" = "xyes"; then
1810 AC_MSG_CHECKING(whether strerror_r is declared)
1811 AC_EGREP_CPP(strerror_r,[
1812 #include <string.h>],[
1813 AC_MSG_RESULT(yes)],[
1815 AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
1816 AC_EGREP_CPP(strerror_r,[
1818 #include <string.h>],[
1819 CPPFLAGS="-D_REENTRANT $CPPFLAGS"
1820 AC_MSG_RESULT(yes)],
1822 AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
1823 ) dnl with _THREAD_SAFE
1824 ]) dnl plain cpp for it
1826 dnl determine if this strerror_r() is glibc or POSIX
1827 AC_MSG_CHECKING([for a glibc strerror_r API])
1833 char buffer[1024]; /* big enough to play with */
1835 strerror_r(EACCES, buffer, sizeof(buffer));
1836 /* this should've returned a string */
1837 if(!string || !string[0])
1842 GLIBC_STRERROR_R="1"
1843 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
1844 AC_MSG_RESULT([yes]),
1845 AC_MSG_RESULT([no]),
1847 dnl Use an inferior method of strerror_r detection while cross-compiling
1849 #include <features.h>
1854 dnl looks like glibc, so assume a glibc-style strerror_r()
1855 GLIBC_STRERROR_R="1"
1856 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
1857 AC_MSG_RESULT([yes]),
1858 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
1859 ) dnl while cross-compiling
1862 if test -z "$GLIBC_STRERROR_R"; then
1864 AC_MSG_CHECKING([for a POSIX strerror_r API])
1870 char buffer[1024]; /* big enough to play with */
1872 strerror_r(EACCES, buffer, sizeof(buffer));
1873 /* This should've returned zero, and written an error string in the
1875 if(!buffer[0] || error)
1880 AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
1881 AC_MSG_RESULT([yes]),
1882 AC_MSG_RESULT([no]) ,
1883 dnl cross-compiling!
1884 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
1887 fi dnl if not using glibc API
1889 fi dnl we have a strerror_r
1893 AC_DEFUN([CURL_CHECK_INET_NTOA_R],
1895 dnl determine if function definition for inet_ntoa_r exists.
1896 AC_CHECK_FUNCS(inet_ntoa_r,[
1897 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
1898 AC_EGREP_CPP(inet_ntoa_r,[
1899 #include <arpa/inet.h>],[
1900 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
1901 AC_MSG_RESULT(yes)],[
1903 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
1904 AC_EGREP_CPP(inet_ntoa_r,[
1906 #include <arpa/inet.h>],[
1907 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
1908 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT defined])
1909 AC_MSG_RESULT(yes)],
1910 AC_MSG_RESULT(no))])])
1913 AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R],
1915 dnl check for number of arguments to gethostbyaddr_r. it might take
1916 dnl either 5, 7, or 8 arguments.
1917 AC_CHECK_FUNCS(gethostbyaddr_r,[
1918 AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
1920 #include <sys/types.h>
1921 #include <netdb.h>],[
1926 struct hostent_data hdata;
1928 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
1930 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
1931 ac_cv_gethostbyaddr_args=5],[
1933 AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
1936 #include <sys/types.h>
1937 #include <netdb.h>],[
1942 struct hostent_data hdata;
1944 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
1946 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
1947 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
1948 ac_cv_gethostbyaddr_args=5],[
1950 AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
1952 #include <sys/types.h>
1953 #include <netdb.h>],[
1960 struct hostent * hp;
1962 hp = gethostbyaddr_r(address, length, type, &h,
1963 buffer, 8192, &h_errnop);],[
1965 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args] )
1966 ac_cv_gethostbyaddr_args=7],[
1968 AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
1970 #include <sys/types.h>
1971 #include <netdb.h>],[
1978 struct hostent * hp;
1981 rc = gethostbyaddr_r(address, length, type, &h,
1982 buffer, 8192, &hp, &h_errnop);],[
1984 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
1985 ac_cv_gethostbyaddr_args=8],[
1987 have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
1990 AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R],
1992 dnl check for number of arguments to gethostbyname_r. it might take
1993 dnl either 3, 5, or 6 arguments.
1994 AC_CHECK_FUNCS(gethostbyname_r,[
1995 AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
1998 #include <sys/types.h>
2001 #define NULL (void *)0
2004 gethostbyname_r(const char *, struct hostent *, struct hostent_data *);],[
2005 struct hostent_data data;
2006 gethostbyname_r(NULL, NULL, NULL);],[
2008 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2009 ac_cv_gethostbyname_args=3],[
2011 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
2016 #include <sys/types.h>
2019 #define NULL (void *)0
2022 gethostbyname_r(const char *,struct hostent *, struct hostent_data *);],[
2023 struct hostent_data data;
2024 gethostbyname_r(NULL, NULL, NULL);],[
2026 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
2027 AC_DEFINE(NEED_REENTRANT, 1, [needs REENTRANT])
2028 ac_cv_gethostbyname_args=3],[
2030 AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
2032 #include <sys/types.h>
2035 #define NULL (void *)0
2038 gethostbyname_r(const char *, struct hostent *, char *, int, int *);],[
2039 gethostbyname_r(NULL, NULL, NULL, 0, NULL);],[
2041 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
2042 ac_cv_gethostbyname_args=5],[
2044 AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
2046 #include <sys/types.h>
2049 #define NULL (void *)0
2052 gethostbyname_r(const char *, struct hostent *, char *, size_t,
2053 struct hostent **, int *);],[
2054 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);],[
2056 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
2057 ac_cv_gethostbyname_args=6],[
2059 have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
2060 [ac_cv_gethostbyname_args=0])],
2061 [ac_cv_gethostbyname_args=0])],
2062 [ac_cv_gethostbyname_args=0])],
2063 [ac_cv_gethostbyname_args=0])])
2065 if test "$ac_cv_func_gethostbyname_r" = "yes"; then
2066 if test "$ac_cv_gethostbyname_args" = "0"; then
2067 dnl there's a gethostbyname_r() function, but we don't know how
2068 dnl many arguments it wants!
2069 AC_MSG_ERROR([couldn't figure out how to use gethostbyname_r()])
2075 dnl **********************************************************************
2076 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
2078 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
2079 dnl sets the $ICC variable to "yes" or "no"
2080 dnl **********************************************************************
2081 AC_DEFUN([CURL_DETECT_ICC],
2084 AC_MSG_CHECKING([for icc in use])
2085 if test "$GCC" = "yes"; then
2086 dnl check if this is icc acting as gcc in disguise
2087 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
2088 dnl action if the text is found, this it has not been replaced by the
2091 dnl the text was not found, it was replaced by the cpp
2093 AC_MSG_RESULT([yes])
2097 if test "$ICC" = "no"; then
2103 dnl We create a function for detecting which compiler we use and then set as
2104 dnl pendantic compiler options as possible for that particular compiler. The
2105 dnl options are only used for debug-builds.
2107 AC_DEFUN([CURL_CC_DEBUG_OPTS],
2109 if test "z$ICC" = "z"; then
2113 if test "$GCC" = "yes"; then
2115 dnl figure out gcc version!
2116 AC_MSG_CHECKING([gcc version])
2117 gccver=`$CC -dumpversion`
2118 num1=`echo $gccver | cut -d . -f1`
2119 num2=`echo $gccver | cut -d . -f2`
2120 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
2121 AC_MSG_RESULT($gccver)
2123 if test "$ICC" = "yes"; then
2124 dnl this is icc, not gcc.
2126 dnl ICC warnings we ignore:
2127 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
2128 dnl "invalid format string conversion"
2129 dnl * 279 warns on static conditions in while expressions
2130 dnl * 981 warns on "operands are evaluated in unspecified order"
2131 dnl * 1418 "external definition with no prior declaration"
2132 dnl * 1419 warns on "external declaration in primary source file"
2133 dnl which we know and do on purpose.
2135 WARN="-wd279,269,981,1418,1419"
2137 if test "$gccnum" -gt "600"; then
2138 dnl icc 6.0 and older doesn't have the -Wall flag
2142 dnl this is a set of options we believe *ALL* gcc versions support:
2143 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
2145 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
2147 if test "$gccnum" -ge "207"; then
2148 dnl gcc 2.7 or later
2149 WARN="$WARN -Wmissing-declarations"
2152 if test "$gccnum" -gt "295"; then
2153 dnl only if the compiler is newer than 2.95 since we got lots of
2154 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
2155 dnl gcc 2.95.4 on FreeBSD 4.9!
2156 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
2159 if test "$gccnum" -ge "296"; then
2160 dnl gcc 2.96 or later
2161 WARN="$WARN -Wfloat-equal"
2164 if test "$gccnum" -gt "296"; then
2165 dnl this option does not exist in 2.96
2166 WARN="$WARN -Wno-format-nonliteral"
2169 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
2170 dnl on i686-Linux as it gives us heaps with false positives.
2171 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
2172 dnl over making it unusable for generic purposes. Let's not use it.
2174 if test "$gccnum" -ge "303"; then
2175 dnl gcc 3.3 and later
2176 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
2179 if test "$gccnum" -ge "304"; then
2180 # try these on gcc 3.4
2181 WARN="$WARN -Wdeclaration-after-statement"
2184 for flag in $CPPFLAGS; do
2187 dnl Include path, provide a -isystem option for the same dir
2188 dnl to prevent warnings in those dirs. The -isystem was not very
2189 dnl reliable on earlier gcc versions.
2190 add=`echo $flag | sed 's/^-I/-isystem /g'`
2198 CFLAGS="$CFLAGS $WARN"
2200 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
2204 AC_MSG_NOTICE([Added no extra compiler options])
2208 dnl strip off optimizer flags
2210 for flag in $CFLAGS; do
2213 dnl echo "cut off $flag"
2216 NEWFLAGS="$NEWFLAGS $flag"
2222 ]) dnl end of AC_DEFUN()
2224 # This is only a temporary fix. This macro is here to replace the broken one
2225 # delivered by the automake project (including the 1.9.6 release). As soon as
2226 # they ship a working version we SHOULD remove this work-around.
2228 AC_DEFUN([AM_MISSING_HAS_RUN],
2229 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2230 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
2231 # Use eval to expand $SHELL
2232 if eval "$MISSING --run true"; then
2233 am_missing_run="$MISSING --run "
2236 AC_MSG_WARN([`missing' script is too old or missing])
2241 dnl CURL_VERIFY_RUNTIMELIBS
2242 dnl -------------------------------------------------
2243 dnl Verify that the shared libs found so far can be used when running
2244 dnl programs, since otherwise the situation will create odd configure errors
2245 dnl that are misleading people.
2247 dnl Make sure this test is run BEFORE the first test in the script that
2248 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
2249 dnl macro. It must also run AFTER all lib-checking macros are complete.
2251 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
2253 dnl this test is of course not sensible if we are cross-compiling!
2254 if test "x$cross_compiling" != xyes; then
2256 dnl just run a program to verify that the libs checked for previous to this
2257 dnl point also is available run-time!
2258 AC_MSG_CHECKING([run-time libs availability])
2265 AC_MSG_RESULT([fine]),
2266 AC_MSG_RESULT([failed])
2267 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
2270 dnl if this test fails, configure has already stopped
2275 dnl CURL_CHECK_VARIADIC_MACROS
2276 dnl -------------------------------------------------
2277 dnl Check compiler support of variadic macros
2279 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
2280 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
2281 [curl_cv_variadic_macros_c99], [
2284 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
2285 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
2286 int fun3(int arg1, int arg2, int arg3);
2287 int fun2(int arg1, int arg2);
2288 int fun3(int arg1, int arg2, int arg3)
2289 { return arg1 + arg2 + arg3; }
2290 int fun2(int arg1, int arg2)
2291 { return arg1 + arg2; }
2293 int res3 = c99_vmacro3(1, 2, 3);
2294 int res2 = c99_vmacro2(1, 2);
2297 curl_cv_variadic_macros_c99="yes"
2299 curl_cv_variadic_macros_c99="no"
2302 case "$curl_cv_variadic_macros_c99" in
2304 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
2305 [Define to 1 if compiler supports C99 variadic macro style.])
2308 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
2309 [curl_cv_variadic_macros_gcc], [
2312 #define gcc_vmacro3(first, args...) fun3(first, args)
2313 #define gcc_vmacro2(first, args...) fun2(first, args)
2314 int fun3(int arg1, int arg2, int arg3);
2315 int fun2(int arg1, int arg2);
2316 int fun3(int arg1, int arg2, int arg3)
2317 { return arg1 + arg2 + arg3; }
2318 int fun2(int arg1, int arg2)
2319 { return arg1 + arg2; }
2321 int res3 = gcc_vmacro3(1, 2, 3);
2322 int res2 = gcc_vmacro2(1, 2);
2325 curl_cv_variadic_macros_gcc="yes"
2327 curl_cv_variadic_macros_gcc="no"
2330 case "$curl_cv_variadic_macros_gcc" in
2332 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2333 [Define to 1 if compiler supports old gcc variadic macro style.])
2339 dnl CURL_CHECK_NATIVE_WINDOWS
2340 dnl -------------------------------------------------
2341 dnl Check if building a native Windows target
2343 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
2344 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
2345 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
2346 if test "$ac_cv_header_windows_h" = "no"; then
2347 ac_cv_native_windows="no"
2355 Not a native Windows build target.
2359 ac_cv_native_windows="yes"
2361 ac_cv_native_windows="no"
2365 case "$ac_cv_native_windows" in
2367 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
2368 [Define to 1 if you are building a native Windows target.])