1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at http://curl.haxx.se/docs/copyright.html.
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
22 #***************************************************************************
25 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
26 dnl -------------------------------------------------
27 dnl Verifies if the compiler actually halts after the
28 dnl compilation phase without generating any object
29 dnl code file, when the source compiles with errors.
31 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
32 AC_MSG_CHECKING([if compiler halts on compilation errors])
36 force compilation error
40 AC_MSG_ERROR([compiler does not halt on compilation errors.])
47 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
48 dnl -------------------------------------------------
49 dnl Verifies if the compiler actually halts after the
50 dnl compilation phase without generating any object
51 dnl code file, when the source code tries to define a
52 dnl type for a constant array with negative dimension.
54 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
55 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
56 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
59 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
65 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
72 dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
73 dnl -------------------------------------------------
74 dnl Use the C preprocessor to find out if the given object-style symbol
75 dnl is defined and get its expansion. This macro will not use default
76 dnl includes even if no INCLUDES argument is given. This macro will run
77 dnl silently when invoked with three arguments. If the expansion would
78 dnl result in a set of double-quoted strings the returned expansion will
79 dnl actually be a single double-quoted string concatenating all them.
81 AC_DEFUN([CURL_CHECK_DEF], [
82 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
83 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
84 if test -z "$SED"; then
85 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
87 if test -z "$GREP"; then
88 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
90 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
100 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
101 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
102 "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
103 "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
104 if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
108 if test -z "$tmp_exp"; then
109 AS_VAR_SET(ac_HaveDef, no)
110 ifelse($3,,[AC_MSG_RESULT([no])])
112 AS_VAR_SET(ac_HaveDef, yes)
113 AS_VAR_SET(ac_Def, $tmp_exp)
114 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
116 AS_VAR_POPDEF([ac_Def])dnl
117 AS_VAR_POPDEF([ac_HaveDef])dnl
121 dnl CURL_SETUP_VARS_ALPHA_SETS
122 dnl -------------------------------------------------
123 dnl Set up variables with sets of several letters.
125 AC_DEFUN([CURL_SETUP_VARS_ALPHA_SETS], [
126 curl_cv_letters='abcdefghijklmnopqrstuvwxyz'
127 curl_cv_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
128 curl_cv_Letters=$curl_cv_letters$curl_cv_LETTERS
129 curl_cv_digits='0123456789'
130 curl_cv_alnum=$curl_cv_Letters$curl_cv_digits
134 dnl CURL_CHECK_DEF_INTXX_C (INTXX_C, [INCLUDES])
135 dnl -------------------------------------------------
136 dnl Use the C preprocessor to find out if the given INTXX_C function-style
137 dnl macro is defined and get the suffix part of its expansion. This macro
138 dnl will not use default includes even if no INCLUDES argument is given.
140 AC_DEFUN([CURL_CHECK_DEF_INTXX_C], [
141 AC_REQUIRE([CURL_SETUP_VARS_ALPHA_SETS])dnl
142 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
143 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
144 if test -z "$SED"; then
145 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
147 if test -z "$GREP"; then
148 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
159 tmp_suf=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
160 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
161 "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
162 "$SED" 's/.*'$1'//' 2>/dev/null | \
163 "$SED" 's/[[^'$curl_cv_alnum']]//g' 2>/dev/null`
164 if test -z "$tmp_suf"; then
168 if test -z "$tmp_suf"; then
169 AS_VAR_SET(ac_HaveDef, no)
171 AS_VAR_SET(ac_HaveDef, yes)
172 AS_VAR_SET(ac_Def, $tmp_suf)
174 AS_VAR_POPDEF([ac_Def])dnl
175 AS_VAR_POPDEF([ac_HaveDef])dnl
179 dnl CURL_CHECK_AIX_ALL_SOURCE
180 dnl -------------------------------------------------
181 dnl Provides a replacement of traditional AC_AIX with
182 dnl an uniform behaviour across all autoconf versions,
183 dnl and with our own placement rules.
185 AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
186 AH_VERBATIM([_ALL_SOURCE],
187 [/* Define to 1 if OS is AIX. */
191 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
192 AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
193 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
194 AC_EGREP_CPP([yes_this_is_aix],[
200 AC_DEFINE(_ALL_SOURCE)
207 dnl CURL_CHECK_HEADER_WINDOWS
208 dnl -------------------------------------------------
209 dnl Check for compilable and valid windows.h header
211 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
212 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
216 #ifndef WIN32_LEAN_AND_MEAN
217 #define WIN32_LEAN_AND_MEAN
221 #if defined(__CYGWIN__) || defined(__CEGCC__)
222 HAVE_WINDOWS_H shall not be defined.
228 ac_cv_header_windows_h="yes"
230 ac_cv_header_windows_h="no"
233 case "$ac_cv_header_windows_h" in
235 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
236 [Define to 1 if you have the windows.h header file.])
237 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
238 [Define to avoid automatic inclusion of winsock.h])
244 dnl CURL_CHECK_NATIVE_WINDOWS
245 dnl -------------------------------------------------
246 dnl Check if building a native Windows target
248 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
249 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
250 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
251 if test "$ac_cv_header_windows_h" = "no"; then
252 ac_cv_native_windows="no"
257 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
258 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
261 Not a native Windows build target.
265 ac_cv_native_windows="yes"
267 ac_cv_native_windows="no"
271 case "$ac_cv_native_windows" in
273 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
274 [Define to 1 if you are building a native Windows target.])
280 dnl CURL_CHECK_HEADER_WINSOCK
281 dnl -------------------------------------------------
282 dnl Check for compilable and valid winsock.h header
284 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
285 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
286 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
290 #ifndef WIN32_LEAN_AND_MEAN
291 #define WIN32_LEAN_AND_MEAN
296 #if defined(__CYGWIN__) || defined(__CEGCC__)
297 HAVE_WINSOCK_H shall not be defined.
299 int dummy=WSACleanup();
303 ac_cv_header_winsock_h="yes"
305 ac_cv_header_winsock_h="no"
308 case "$ac_cv_header_winsock_h" in
310 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
311 [Define to 1 if you have the winsock.h header file.])
317 dnl CURL_CHECK_HEADER_WINSOCK2
318 dnl -------------------------------------------------
319 dnl Check for compilable and valid winsock2.h header
321 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
322 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
323 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
327 #ifndef WIN32_LEAN_AND_MEAN
328 #define WIN32_LEAN_AND_MEAN
331 #include <winsock2.h>
333 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
334 HAVE_WINSOCK2_H shall not be defined.
336 int dummy=2*IPPROTO_ESP;
340 ac_cv_header_winsock2_h="yes"
342 ac_cv_header_winsock2_h="no"
345 case "$ac_cv_header_winsock2_h" in
347 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
348 [Define to 1 if you have the winsock2.h header file.])
354 dnl CURL_CHECK_HEADER_WS2TCPIP
355 dnl -------------------------------------------------
356 dnl Check for compilable and valid ws2tcpip.h header
358 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
359 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
360 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
364 #ifndef WIN32_LEAN_AND_MEAN
365 #define WIN32_LEAN_AND_MEAN
368 #include <winsock2.h>
369 #include <ws2tcpip.h>
371 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
372 HAVE_WS2TCPIP_H shall not be defined.
374 int dummy=2*IP_PKTINFO;
378 ac_cv_header_ws2tcpip_h="yes"
380 ac_cv_header_ws2tcpip_h="no"
383 case "$ac_cv_header_ws2tcpip_h" in
385 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
386 [Define to 1 if you have the ws2tcpip.h header file.])
392 dnl CURL_CHECK_HEADER_WINLDAP
393 dnl -------------------------------------------------
394 dnl Check for compilable and valid winldap.h header
396 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
397 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
398 AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
402 #ifdef HAVE_WINDOWS_H
403 #ifndef WIN32_LEAN_AND_MEAN
404 #define WIN32_LEAN_AND_MEAN
410 #if defined(__CYGWIN__) || defined(__CEGCC__)
411 HAVE_WINLDAP_H shall not be defined.
413 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
414 ULONG res = ldap_unbind(ldp);
418 ac_cv_header_winldap_h="yes"
420 ac_cv_header_winldap_h="no"
423 case "$ac_cv_header_winldap_h" in
425 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
426 [Define to 1 if you have the winldap.h header file.])
432 dnl CURL_CHECK_HEADER_WINBER
433 dnl -------------------------------------------------
434 dnl Check for compilable and valid winber.h header
436 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
437 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
438 AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
442 #ifdef HAVE_WINDOWS_H
443 #ifndef WIN32_LEAN_AND_MEAN
444 #define WIN32_LEAN_AND_MEAN
451 #if defined(__CYGWIN__) || defined(__CEGCC__)
452 HAVE_WINBER_H shall not be defined.
455 BerElement *bep = ber_init(bvp);
460 ac_cv_header_winber_h="yes"
462 ac_cv_header_winber_h="no"
465 case "$ac_cv_header_winber_h" in
467 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
468 [Define to 1 if you have the winber.h header file.])
474 dnl CURL_CHECK_HEADER_LBER
475 dnl -------------------------------------------------
476 dnl Check for compilable and valid lber.h header,
477 dnl and check if it is needed even with ldap.h
479 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
480 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
481 AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
485 #ifdef HAVE_WINDOWS_H
486 #ifndef WIN32_LEAN_AND_MEAN
487 #define WIN32_LEAN_AND_MEAN
491 #ifdef HAVE_SYS_TYPES_H
492 #include <sys/types.h>
496 #define NULL (void *)0
500 BerValue *bvp = NULL;
501 BerElement *bep = ber_init(bvp);
505 ac_cv_header_lber_h="yes"
507 ac_cv_header_lber_h="no"
510 if test "$ac_cv_header_lber_h" = "yes"; then
511 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
512 [Define to 1 if you have the lber.h header file.])
517 #ifdef HAVE_WINDOWS_H
518 #ifndef WIN32_LEAN_AND_MEAN
519 #define WIN32_LEAN_AND_MEAN
523 #ifdef HAVE_SYS_TYPES_H
524 #include <sys/types.h>
528 #define NULL (void *)0
530 #ifndef LDAP_DEPRECATED
531 #define LDAP_DEPRECATED 1
535 BerValue *bvp = NULL;
536 BerElement *bep = ber_init(bvp);
540 curl_cv_need_header_lber_h="no"
542 curl_cv_need_header_lber_h="yes"
545 case "$curl_cv_need_header_lber_h" in
547 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
548 [Define to 1 if you need the lber.h header file even with ldap.h])
555 dnl CURL_CHECK_HEADER_LDAP
556 dnl -------------------------------------------------
557 dnl Check for compilable and valid ldap.h header
559 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
560 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
561 AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
565 #ifdef HAVE_WINDOWS_H
566 #ifndef WIN32_LEAN_AND_MEAN
567 #define WIN32_LEAN_AND_MEAN
571 #ifdef HAVE_SYS_TYPES_H
572 #include <sys/types.h>
575 #ifndef LDAP_DEPRECATED
576 #define LDAP_DEPRECATED 1
583 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
584 int res = ldap_unbind(ldp);
587 ac_cv_header_ldap_h="yes"
589 ac_cv_header_ldap_h="no"
592 case "$ac_cv_header_ldap_h" in
594 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
595 [Define to 1 if you have the ldap.h header file.])
601 dnl CURL_CHECK_HEADER_LDAP_SSL
602 dnl -------------------------------------------------
603 dnl Check for compilable and valid ldap_ssl.h header
605 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
606 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
607 AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
611 #ifdef HAVE_WINDOWS_H
612 #ifndef WIN32_LEAN_AND_MEAN
613 #define WIN32_LEAN_AND_MEAN
617 #ifdef HAVE_SYS_TYPES_H
618 #include <sys/types.h>
621 #ifndef LDAP_DEPRECATED
622 #define LDAP_DEPRECATED 1
630 #include <ldap_ssl.h>
632 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
635 ac_cv_header_ldap_ssl_h="yes"
637 ac_cv_header_ldap_ssl_h="no"
640 case "$ac_cv_header_ldap_ssl_h" in
642 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
643 [Define to 1 if you have the ldap_ssl.h header file.])
649 dnl CURL_CHECK_HEADER_LDAPSSL
650 dnl -------------------------------------------------
651 dnl Check for compilable and valid ldapssl.h header
653 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
654 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
655 AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
659 #ifdef HAVE_WINDOWS_H
660 #ifndef WIN32_LEAN_AND_MEAN
661 #define WIN32_LEAN_AND_MEAN
665 #ifdef HAVE_SYS_TYPES_H
666 #include <sys/types.h>
670 #define NULL (void *)0
672 #ifndef LDAP_DEPRECATED
673 #define LDAP_DEPRECATED 1
683 char *cert_label = NULL;
684 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
687 ac_cv_header_ldapssl_h="yes"
689 ac_cv_header_ldapssl_h="no"
692 case "$ac_cv_header_ldapssl_h" in
694 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
695 [Define to 1 if you have the ldapssl.h header file.])
701 dnl CURL_CHECK_LIBS_WINLDAP
702 dnl -------------------------------------------------
703 dnl Check for libraries needed for WINLDAP support,
704 dnl and prepended to LIBS any needed libraries.
705 dnl This macro can take an optional parameter with a
706 dnl white space separated list of libraries to check
707 dnl before the WINLDAP default ones.
709 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
710 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
712 AC_MSG_CHECKING([for WINLDAP libraries])
726 if test -z "$u_libs"; then
729 u_libs="$u_libs $l_lib"
734 curl_cv_save_LIBS="$LIBS"
735 curl_cv_ldap_LIBS="unknown"
737 for x_nlibs in '' "$u_libs" \
739 if test "$curl_cv_ldap_LIBS" = "unknown"; then
740 if test -z "$x_nlibs"; then
741 LIBS="$curl_cv_save_LIBS"
743 LIBS="$x_nlibs $curl_cv_save_LIBS"
748 #ifdef HAVE_WINDOWS_H
749 #ifndef WIN32_LEAN_AND_MEAN
750 #define WIN32_LEAN_AND_MEAN
753 #ifdef HAVE_WINLDAP_H
762 BerElement *bep = ber_init(bvp);
763 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
764 ULONG res = ldap_unbind(ldp);
768 curl_cv_ldap_LIBS="$x_nlibs"
773 LIBS="$curl_cv_save_LIBS"
775 case X-"$curl_cv_ldap_LIBS" in
777 AC_MSG_RESULT([cannot find WINLDAP libraries])
780 AC_MSG_RESULT([no additional lib required])
783 if test -z "$curl_cv_save_LIBS"; then
784 LIBS="$curl_cv_ldap_LIBS"
786 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
788 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
795 dnl CURL_CHECK_LIBS_LDAP
796 dnl -------------------------------------------------
797 dnl Check for libraries needed for LDAP support,
798 dnl and prepended to LIBS any needed libraries.
799 dnl This macro can take an optional parameter with a
800 dnl white space separated list of libraries to check
801 dnl before the default ones.
803 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
804 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
806 AC_MSG_CHECKING([for LDAP libraries])
820 if test -z "$u_libs"; then
823 u_libs="$u_libs $l_lib"
828 curl_cv_save_LIBS="$LIBS"
829 curl_cv_ldap_LIBS="unknown"
831 for x_nlibs in '' "$u_libs" \
835 '-lldapssl -lldapx -lldapsdk' \
836 '-lldapsdk -lldapx -lldapssl' ; do
837 if test "$curl_cv_ldap_LIBS" = "unknown"; then
838 if test -z "$x_nlibs"; then
839 LIBS="$curl_cv_save_LIBS"
841 LIBS="$x_nlibs $curl_cv_save_LIBS"
846 #ifdef HAVE_WINDOWS_H
847 #ifndef WIN32_LEAN_AND_MEAN
848 #define WIN32_LEAN_AND_MEAN
852 #ifdef HAVE_SYS_TYPES_H
853 #include <sys/types.h>
857 #define NULL (void *)0
859 #ifndef LDAP_DEPRECATED
860 #define LDAP_DEPRECATED 1
869 BerValue *bvp = NULL;
870 BerElement *bep = ber_init(bvp);
871 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
872 int res = ldap_unbind(ldp);
876 curl_cv_ldap_LIBS="$x_nlibs"
881 LIBS="$curl_cv_save_LIBS"
883 case X-"$curl_cv_ldap_LIBS" in
885 AC_MSG_RESULT([cannot find LDAP libraries])
888 AC_MSG_RESULT([no additional lib required])
891 if test -z "$curl_cv_save_LIBS"; then
892 LIBS="$curl_cv_ldap_LIBS"
894 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
896 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
903 dnl CURL_CHECK_HEADER_MALLOC
904 dnl -------------------------------------------------
905 dnl Check for compilable and valid malloc.h header,
906 dnl and check if it is needed even with stdlib.h
908 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
909 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
914 void *p = malloc(10);
915 void *q = calloc(10,10);
920 ac_cv_header_malloc_h="yes"
922 ac_cv_header_malloc_h="no"
925 if test "$ac_cv_header_malloc_h" = "yes"; then
926 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
927 [Define to 1 if you have the malloc.h header file.])
933 void *p = malloc(10);
934 void *q = calloc(10,10);
939 curl_cv_need_header_malloc_h="no"
941 curl_cv_need_header_malloc_h="yes"
944 case "$curl_cv_need_header_malloc_h" in
946 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
947 [Define to 1 if you need the malloc.h header file even with stdlib.h])
954 dnl CURL_CHECK_TYPE_SOCKLEN_T
955 dnl -------------------------------------------------
956 dnl Check for existing socklen_t type, and provide
957 dnl an equivalent type if socklen_t not available
959 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
960 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
961 AC_CHECK_TYPE([socklen_t], ,[
962 dnl socklen_t not available
963 AC_CACHE_CHECK([for socklen_t equivalent],
964 [curl_cv_socklen_t_equiv], [
965 curl_cv_socklen_t_equiv="unknown"
966 for arg1 in 'int' 'SOCKET'; do
967 for arg2 in "struct sockaddr" void; do
968 for t in int size_t unsigned long "unsigned long"; do
969 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
973 #ifdef HAVE_WINDOWS_H
974 #ifndef WIN32_LEAN_AND_MEAN
975 #define WIN32_LEAN_AND_MEAN
978 #ifdef HAVE_WINSOCK2_H
979 #include <winsock2.h>
981 #ifdef HAVE_WINSOCK_H
985 #define GETPEERNCALLCONV PASCAL
987 #ifdef HAVE_SYS_TYPES_H
988 #include <sys/types.h>
990 #ifdef HAVE_SYS_SOCKET_H
991 #include <sys/socket.h>
993 #define GETPEERNCALLCONV
995 extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
998 getpeername(0,0,&len);
1001 curl_cv_socklen_t_equiv="$t"
1008 case "$curl_cv_socklen_t_equiv" in
1010 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
1013 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
1014 [Type to use in place of socklen_t when system does not provide it.])
1019 #ifdef HAVE_WINDOWS_H
1020 #ifndef WIN32_LEAN_AND_MEAN
1021 #define WIN32_LEAN_AND_MEAN
1023 #include <windows.h>
1024 #ifdef HAVE_WINSOCK2_H
1025 #include <winsock2.h>
1026 #ifdef HAVE_WS2TCPIP_H
1027 #include <ws2tcpip.h>
1031 #ifdef HAVE_SYS_TYPES_H
1032 #include <sys/types.h>
1034 #ifdef HAVE_SYS_SOCKET_H
1035 #include <sys/socket.h>
1042 dnl CURL_CHECK_FUNC_GETNAMEINFO
1043 dnl -------------------------------------------------
1044 dnl Test if the getnameinfo function is available,
1045 dnl and check the types of five of its arguments.
1046 dnl If the function succeeds HAVE_GETNAMEINFO will be
1047 dnl defined, defining the types of the arguments in
1048 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
1049 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
1050 dnl and also defining the type qualifier of first
1051 dnl argument in GETNAMEINFO_QUAL_ARG1.
1053 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
1054 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
1055 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
1056 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
1058 AC_MSG_CHECKING([for getnameinfo])
1060 AC_LANG_FUNC_LINK_TRY([getnameinfo])
1062 AC_MSG_RESULT([yes])
1063 curl_cv_getnameinfo="yes"
1066 curl_cv_getnameinfo="no"
1069 if test "$curl_cv_getnameinfo" != "yes"; then
1070 AC_MSG_CHECKING([deeper for getnameinfo])
1077 AC_MSG_RESULT([yes])
1078 curl_cv_getnameinfo="yes"
1080 AC_MSG_RESULT([but still no])
1081 curl_cv_getnameinfo="no"
1085 if test "$curl_cv_getnameinfo" != "yes"; then
1086 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
1090 #ifdef HAVE_WINDOWS_H
1091 #ifndef WIN32_LEAN_AND_MEAN
1092 #define WIN32_LEAN_AND_MEAN
1094 #include <windows.h>
1095 #ifdef HAVE_WINSOCK2_H
1096 #include <winsock2.h>
1097 #ifdef HAVE_WS2TCPIP_H
1098 #include <ws2tcpip.h>
1102 #ifdef HAVE_SYS_TYPES_H
1103 #include <sys/types.h>
1105 #ifdef HAVE_SYS_SOCKET_H
1106 #include <sys/socket.h>
1113 getnameinfo(0, 0, 0, 0, 0, 0, 0);
1116 AC_MSG_RESULT([yes])
1117 curl_cv_getnameinfo="yes"
1119 AC_MSG_RESULT([but still no])
1120 curl_cv_getnameinfo="no"
1124 if test "$curl_cv_getnameinfo" = "yes"; then
1125 AC_CACHE_CHECK([types of arguments for getnameinfo],
1126 [curl_cv_func_getnameinfo_args], [
1127 curl_cv_func_getnameinfo_args="unknown"
1128 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
1129 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
1130 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
1131 for gni_arg7 in 'int' 'unsigned int'; do
1132 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1136 #ifdef HAVE_WINDOWS_H
1137 #ifndef WIN32_LEAN_AND_MEAN
1138 #define WIN32_LEAN_AND_MEAN
1140 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
1142 #define _WIN32_WINNT 0x0501
1144 #include <windows.h>
1145 #ifdef HAVE_WINSOCK2_H
1146 #include <winsock2.h>
1147 #ifdef HAVE_WS2TCPIP_H
1148 #include <ws2tcpip.h>
1151 #define GNICALLCONV WSAAPI
1153 #ifdef HAVE_SYS_TYPES_H
1154 #include <sys/types.h>
1156 #ifdef HAVE_SYS_SOCKET_H
1157 #include <sys/socket.h>
1164 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
1170 $gni_arg46 hostlen=0;
1171 $gni_arg46 servlen=0;
1173 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
1176 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
1184 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1185 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
1186 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1188 gni_prev_IFS=$IFS; IFS=','
1189 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1193 gni_qual_type_arg1=$[1]
1195 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1196 [Define to the type of arg 2 for getnameinfo.])
1197 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1198 [Define to the type of args 4 and 6 for getnameinfo.])
1199 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1200 [Define to the type of arg 7 for getnameinfo.])
1204 case $prev_sh_opts in
1212 case "$gni_qual_type_arg1" in
1215 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1219 gni_type_arg1=$gni_qual_type_arg1
1223 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1224 [Define to the type qualifier of arg 1 for getnameinfo.])
1225 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1226 [Define to the type of arg 1 for getnameinfo.])
1228 case $prev_sh_opts in
1236 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1237 [Define to 1 if you have the getnameinfo function.])
1238 ac_cv_func_getnameinfo="yes"
1244 dnl TYPE_SOCKADDR_STORAGE
1245 dnl -------------------------------------------------
1246 dnl Check for struct sockaddr_storage. Most IPv6-enabled
1247 dnl hosts have it, but AIX 4.3 is one known exception.
1249 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1251 AC_CHECK_TYPE([struct sockaddr_storage],
1252 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1253 [if struct sockaddr_storage is defined]), ,
1256 #ifdef HAVE_WINDOWS_H
1257 #ifndef WIN32_LEAN_AND_MEAN
1258 #define WIN32_LEAN_AND_MEAN
1260 #include <windows.h>
1261 #ifdef HAVE_WINSOCK2_H
1262 #include <winsock2.h>
1265 #ifdef HAVE_SYS_TYPES_H
1266 #include <sys/types.h>
1268 #ifdef HAVE_SYS_SOCKET_H
1269 #include <sys/socket.h>
1271 #ifdef HAVE_NETINET_IN_H
1272 #include <netinet/in.h>
1274 #ifdef HAVE_ARPA_INET_H
1275 #include <arpa/inet.h>
1282 dnl CURL_CHECK_NI_WITHSCOPEID
1283 dnl -------------------------------------------------
1284 dnl Check for working NI_WITHSCOPEID in getnameinfo()
1286 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1287 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1288 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1289 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1290 netdb.h netinet/in.h arpa/inet.h)
1292 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
1293 [ac_cv_working_ni_withscopeid], [
1299 #ifdef HAVE_SYS_TYPES_H
1300 #include <sys/types.h>
1302 #ifdef HAVE_SYS_SOCKET_H
1303 #include <sys/socket.h>
1308 #ifdef HAVE_NETINET_IN_H
1309 #include <netinet/in.h>
1311 #ifdef HAVE_ARPA_INET_H
1312 #include <arpa/inet.h>
1315 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1316 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1317 struct sockaddr_storage sa;
1319 unsigned char sa[256];
1321 char hostbuf[NI_MAXHOST];
1323 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1324 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1325 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1326 int fd = socket(AF_INET6, SOCK_STREAM, 0);
1329 return 1; /* Error creating socket */
1331 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1333 perror("getsockname()");
1334 return 2; /* Error retrieving socket name */
1336 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1338 printf("rc = %s\n", gai_strerror(rc));
1339 return 3; /* Error translating socket address */
1341 return 0; /* Ok, NI_WITHSCOPEID works */
1343 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1345 ]]) # AC-LANG-PROGRAM
1347 # Exit code == 0. Program worked.
1348 ac_cv_working_ni_withscopeid="yes"
1350 # Exit code != 0. Program failed.
1351 ac_cv_working_ni_withscopeid="no"
1353 # Program is not run when cross-compiling. So we assume
1354 # NI_WITHSCOPEID will work if we are able to compile it.
1357 #include <sys/types.h>
1358 #include <sys/socket.h>
1361 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1364 ac_cv_working_ni_withscopeid="yes"
1366 ac_cv_working_ni_withscopeid="no"
1367 ]) # AC-COMPILE-IFELSE
1370 case "$ac_cv_working_ni_withscopeid" in
1372 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1373 [Define to 1 if NI_WITHSCOPEID exists and works.])
1379 dnl CURL_CHECK_FUNC_RECV
1380 dnl -------------------------------------------------
1381 dnl Test if the socket recv() function is available,
1382 dnl and check its return type and the types of its
1383 dnl arguments. If the function succeeds HAVE_RECV
1384 dnl will be defined, defining the types of the arguments
1385 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1386 dnl and RECV_TYPE_ARG4, defining the type of the function
1387 dnl return value in RECV_TYPE_RETV.
1389 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1390 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1391 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1392 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1394 AC_MSG_CHECKING([for recv])
1398 #ifdef HAVE_WINDOWS_H
1399 #ifndef WIN32_LEAN_AND_MEAN
1400 #define WIN32_LEAN_AND_MEAN
1402 #include <windows.h>
1403 #ifdef HAVE_WINSOCK2_H
1404 #include <winsock2.h>
1406 #ifdef HAVE_WINSOCK_H
1407 #include <winsock.h>
1411 #ifdef HAVE_SYS_TYPES_H
1412 #include <sys/types.h>
1414 #ifdef HAVE_SYS_SOCKET_H
1415 #include <sys/socket.h>
1422 AC_MSG_RESULT([yes])
1429 if test "$curl_cv_recv" = "yes"; then
1430 AC_CACHE_CHECK([types of args and return type for recv],
1431 [curl_cv_func_recv_args], [
1432 curl_cv_func_recv_args="unknown"
1433 for recv_retv in 'int' 'ssize_t'; do
1434 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1435 for recv_arg2 in 'char *' 'void *'; do
1436 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1437 for recv_arg4 in 'int' 'unsigned int'; do
1438 if test "$curl_cv_func_recv_args" = "unknown"; then
1442 #ifdef HAVE_WINDOWS_H
1443 #ifndef WIN32_LEAN_AND_MEAN
1444 #define WIN32_LEAN_AND_MEAN
1446 #include <windows.h>
1447 #ifdef HAVE_WINSOCK2_H
1448 #include <winsock2.h>
1450 #ifdef HAVE_WINSOCK_H
1451 #include <winsock.h>
1454 #define RECVCALLCONV PASCAL
1456 #ifdef HAVE_SYS_TYPES_H
1457 #include <sys/types.h>
1459 #ifdef HAVE_SYS_SOCKET_H
1460 #include <sys/socket.h>
1462 #define RECVCALLCONV
1464 extern $recv_retv RECVCALLCONV
1465 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1471 $recv_retv res = recv(s, buf, len, flags);
1474 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1483 if test "$curl_cv_func_recv_args" = "unknown"; then
1484 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1486 recv_prev_IFS=$IFS; IFS=','
1487 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1491 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1492 [Define to the type of arg 1 for recv.])
1493 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1494 [Define to the type of arg 2 for recv.])
1495 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1496 [Define to the type of arg 3 for recv.])
1497 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1498 [Define to the type of arg 4 for recv.])
1499 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1500 [Define to the function return type for recv.])
1502 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1503 [Define to 1 if you have the recv function.])
1504 ac_cv_func_recv="yes"
1507 AC_MSG_ERROR([Unable to link function recv])
1512 dnl CURL_CHECK_FUNC_SEND
1513 dnl -------------------------------------------------
1514 dnl Test if the socket send() function is available,
1515 dnl and check its return type and the types of its
1516 dnl arguments. If the function succeeds HAVE_SEND
1517 dnl will be defined, defining the types of the arguments
1518 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1519 dnl and SEND_TYPE_ARG4, defining the type of the function
1520 dnl return value in SEND_TYPE_RETV, and also defining the
1521 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1523 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1524 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1525 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1526 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1528 AC_MSG_CHECKING([for send])
1532 #ifdef HAVE_WINDOWS_H
1533 #ifndef WIN32_LEAN_AND_MEAN
1534 #define WIN32_LEAN_AND_MEAN
1536 #include <windows.h>
1537 #ifdef HAVE_WINSOCK2_H
1538 #include <winsock2.h>
1540 #ifdef HAVE_WINSOCK_H
1541 #include <winsock.h>
1545 #ifdef HAVE_SYS_TYPES_H
1546 #include <sys/types.h>
1548 #ifdef HAVE_SYS_SOCKET_H
1549 #include <sys/socket.h>
1556 AC_MSG_RESULT([yes])
1563 if test "$curl_cv_send" = "yes"; then
1564 AC_CACHE_CHECK([types of args and return type for send],
1565 [curl_cv_func_send_args], [
1566 curl_cv_func_send_args="unknown"
1567 for send_retv in 'int' 'ssize_t'; do
1568 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1569 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1570 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1571 for send_arg4 in 'int' 'unsigned int'; do
1572 if test "$curl_cv_func_send_args" = "unknown"; then
1576 #ifdef HAVE_WINDOWS_H
1577 #ifndef WIN32_LEAN_AND_MEAN
1578 #define WIN32_LEAN_AND_MEAN
1580 #include <windows.h>
1581 #ifdef HAVE_WINSOCK2_H
1582 #include <winsock2.h>
1584 #ifdef HAVE_WINSOCK_H
1585 #include <winsock.h>
1588 #define SENDCALLCONV PASCAL
1590 #ifdef HAVE_SYS_TYPES_H
1591 #include <sys/types.h>
1593 #ifdef HAVE_SYS_SOCKET_H
1594 #include <sys/socket.h>
1596 #define SENDCALLCONV
1598 extern $send_retv SENDCALLCONV
1599 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1604 $send_retv res = send(s, 0, len, flags);
1607 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1616 if test "$curl_cv_func_send_args" = "unknown"; then
1617 AC_MSG_ERROR([Cannot find proper types to use for send args])
1619 send_prev_IFS=$IFS; IFS=','
1620 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1624 send_qual_type_arg2=$[2]
1626 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1627 [Define to the type of arg 1 for send.])
1628 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1629 [Define to the type of arg 3 for send.])
1630 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1631 [Define to the type of arg 4 for send.])
1632 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1633 [Define to the function return type for send.])
1637 case $prev_sh_opts in
1645 case "$send_qual_type_arg2" in
1647 send_qual_arg2=const
1648 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1652 send_type_arg2=$send_qual_type_arg2
1656 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1657 [Define to the type qualifier of arg 2 for send.])
1658 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1659 [Define to the type of arg 2 for send.])
1661 case $prev_sh_opts in
1669 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1670 [Define to 1 if you have the send function.])
1671 ac_cv_func_send="yes"
1674 AC_MSG_ERROR([Unable to link function send])
1679 dnl CURL_CHECK_FUNC_RECVFROM
1680 dnl -------------------------------------------------
1681 dnl Test if the socket recvfrom() function is available,
1682 dnl and check its return type and the types of its
1683 dnl arguments. If the function succeeds HAVE_RECVFROM
1684 dnl will be defined, defining the types of the arguments
1685 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1686 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1687 dnl function return value in RECVFROM_TYPE_RETV.
1688 dnl Notice that the types returned for pointer arguments
1689 dnl will actually be the type pointed by the pointer.
1691 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1692 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1693 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1694 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1696 AC_MSG_CHECKING([for recvfrom])
1700 #ifdef HAVE_WINDOWS_H
1701 #ifndef WIN32_LEAN_AND_MEAN
1702 #define WIN32_LEAN_AND_MEAN
1704 #include <windows.h>
1705 #ifdef HAVE_WINSOCK2_H
1706 #include <winsock2.h>
1708 #ifdef HAVE_WINSOCK_H
1709 #include <winsock.h>
1713 #ifdef HAVE_SYS_TYPES_H
1714 #include <sys/types.h>
1716 #ifdef HAVE_SYS_SOCKET_H
1717 #include <sys/socket.h>
1721 recvfrom(0, 0, 0, 0, 0, 0);
1724 AC_MSG_RESULT([yes])
1725 curl_cv_recvfrom="yes"
1728 curl_cv_recvfrom="no"
1731 if test "$curl_cv_recvfrom" = "yes"; then
1732 AC_CACHE_CHECK([types of args and return type for recvfrom],
1733 [curl_cv_func_recvfrom_args], [
1734 curl_cv_func_recvfrom_args="unknown"
1735 for recvfrom_retv in 'int' 'ssize_t'; do
1736 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1737 for recvfrom_arg2 in 'char *' 'void *'; do
1738 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1739 for recvfrom_arg4 in 'int' 'unsigned int'; do
1740 for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
1741 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1742 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1746 #ifdef HAVE_WINDOWS_H
1747 #ifndef WIN32_LEAN_AND_MEAN
1748 #define WIN32_LEAN_AND_MEAN
1750 #include <windows.h>
1751 #ifdef HAVE_WINSOCK2_H
1752 #include <winsock2.h>
1754 #ifdef HAVE_WINSOCK_H
1755 #include <winsock.h>
1758 #define RECVFROMCALLCONV PASCAL
1760 #ifdef HAVE_SYS_TYPES_H
1761 #include <sys/types.h>
1763 #ifdef HAVE_SYS_SOCKET_H
1764 #include <sys/socket.h>
1766 #define RECVFROMCALLCONV
1768 extern $recvfrom_retv RECVFROMCALLCONV
1769 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1770 $recvfrom_arg3, $recvfrom_arg4,
1771 $recvfrom_arg5, $recvfrom_arg6);
1774 $recvfrom_arg2 buf=0;
1775 $recvfrom_arg3 len=0;
1776 $recvfrom_arg4 flags=0;
1777 $recvfrom_arg5 addr=0;
1778 $recvfrom_arg6 addrlen=0;
1779 $recvfrom_retv res=0;
1780 res = recvfrom(s, buf, len, flags, addr, addrlen);
1783 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1794 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1795 AC_MSG_ERROR([Cannot find proper types to use for recvfrom args])
1797 recvfrom_prev_IFS=$IFS; IFS=','
1798 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1799 IFS=$recvfrom_prev_IFS
1802 recvfrom_ptrt_arg2=$[2]
1803 recvfrom_ptrt_arg5=$[5]
1804 recvfrom_ptrt_arg6=$[6]
1806 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1807 [Define to the type of arg 1 for recvfrom.])
1808 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1809 [Define to the type of arg 3 for recvfrom.])
1810 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1811 [Define to the type of arg 4 for recvfrom.])
1812 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1813 [Define to the function return type for recvfrom.])
1817 case $prev_sh_opts in
1825 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1826 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1827 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1829 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1830 [Define to the type pointed by arg 2 for recvfrom.])
1831 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1832 [Define to the type pointed by arg 5 for recvfrom.])
1833 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1834 [Define to the type pointed by arg 6 for recvfrom.])
1836 if test "$recvfrom_type_arg2" = "void"; then
1837 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1838 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1840 if test "$recvfrom_type_arg5" = "void"; then
1841 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1842 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1844 if test "$recvfrom_type_arg6" = "void"; then
1845 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1846 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1849 case $prev_sh_opts in
1857 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1858 [Define to 1 if you have the recvfrom function.])
1859 ac_cv_func_recvfrom="yes"
1862 AC_MSG_ERROR([Unable to link function recvfrom])
1867 dnl CURL_CHECK_MSG_NOSIGNAL
1868 dnl -------------------------------------------------
1869 dnl Check for MSG_NOSIGNAL
1871 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1872 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1873 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1877 #ifdef HAVE_WINDOWS_H
1878 #ifndef WIN32_LEAN_AND_MEAN
1879 #define WIN32_LEAN_AND_MEAN
1881 #include <windows.h>
1882 #ifdef HAVE_WINSOCK2_H
1883 #include <winsock2.h>
1885 #ifdef HAVE_WINSOCK_H
1886 #include <winsock.h>
1890 #ifdef HAVE_SYS_TYPES_H
1891 #include <sys/types.h>
1893 #ifdef HAVE_SYS_SOCKET_H
1894 #include <sys/socket.h>
1898 int flag=MSG_NOSIGNAL;
1901 ac_cv_msg_nosignal="yes"
1903 ac_cv_msg_nosignal="no"
1906 case "$ac_cv_msg_nosignal" in
1908 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1909 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1915 dnl CURL_CHECK_STRUCT_TIMEVAL
1916 dnl -------------------------------------------------
1917 dnl Check for timeval struct
1919 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1920 AC_REQUIRE([AC_HEADER_TIME])dnl
1921 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1922 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1923 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1924 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1928 #ifdef HAVE_WINDOWS_H
1929 #ifndef WIN32_LEAN_AND_MEAN
1930 #define WIN32_LEAN_AND_MEAN
1932 #include <windows.h>
1933 #ifdef HAVE_WINSOCK2_H
1934 #include <winsock2.h>
1936 #ifdef HAVE_WINSOCK_H
1937 #include <winsock.h>
1941 #ifdef HAVE_SYS_TYPES_H
1942 #include <sys/types.h>
1944 #ifdef HAVE_SYS_TIME_H
1945 #include <sys/time.h>
1946 #ifdef TIME_WITH_SYS_TIME
1960 ac_cv_struct_timeval="yes"
1962 ac_cv_struct_timeval="no"
1965 case "$ac_cv_struct_timeval" in
1967 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1968 [Define to 1 if you have the timeval struct.])
1974 dnl TYPE_SIG_ATOMIC_T
1975 dnl -------------------------------------------------
1976 dnl Check if the sig_atomic_t type is available, and
1977 dnl verify if it is already defined as volatile.
1979 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1980 AC_CHECK_HEADERS(signal.h)
1981 AC_CHECK_TYPE([sig_atomic_t],[
1982 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1983 [Define to 1 if sig_atomic_t is an available typedef.])
1985 #ifdef HAVE_SIGNAL_H
1989 case "$ac_cv_type_sig_atomic_t" in
1992 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1995 #ifdef HAVE_SIGNAL_H
1999 static volatile sig_atomic_t dummy = 0;
2003 ac_cv_sig_atomic_t_volatile="no"
2005 AC_MSG_RESULT([yes])
2006 ac_cv_sig_atomic_t_volatile="yes"
2009 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
2010 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
2011 [Define to 1 if sig_atomic_t is already defined as volatile.])
2018 dnl CURL_CHECK_NONBLOCKING_SOCKET
2019 dnl -------------------------------------------------
2020 dnl Check for how to set a socket to non-blocking state. There seems to exist
2021 dnl four known different ways, with the one used almost everywhere being POSIX
2022 dnl and XPG3, while the other different ways for different systems (old BSD,
2023 dnl Windows and Amiga).
2025 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
2026 dnl O_NONBLOCK define is found but does not work. This condition is attempted
2027 dnl to get caught in this script by using an excessive number of #ifdefs...
2029 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
2030 AC_MSG_CHECKING([non-blocking sockets style])
2035 /* headers for O_NONBLOCK test */
2036 #include <sys/types.h>
2040 #if defined(sun) || defined(__sun__) || \
2041 defined(__SUNPRO_C) || defined(__SUNPRO_CC)
2042 # if defined(__SVR4) || defined(__srv4__)
2043 # define PLATFORM_SOLARIS
2045 # define PLATFORM_SUNOS4
2048 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
2049 # define PLATFORM_AIX_V3
2052 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
2053 #error "O_NONBLOCK does not work on this platform"
2056 /* O_NONBLOCK source test */
2058 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
2061 dnl the O_NONBLOCK test was fine
2062 nonblock="O_NONBLOCK"
2063 AC_DEFINE(HAVE_O_NONBLOCK, 1,
2064 [use O_NONBLOCK for non-blocking sockets])
2067 if test "$nonblock" = "unknown"; then
2070 /* headers for FIONBIO test */
2072 #include <stropts.h>
2074 /* FIONBIO source test (old-style unix) */
2076 int flags = ioctl(socket, FIONBIO, &flags);
2079 dnl FIONBIO test was good
2081 AC_DEFINE(HAVE_FIONBIO, 1,
2082 [use FIONBIO for non-blocking sockets])
2086 if test "$nonblock" = "unknown"; then
2089 /* headers for ioctlsocket test (Windows) */
2091 #ifdef HAVE_WINDOWS_H
2092 #ifndef WIN32_LEAN_AND_MEAN
2093 #define WIN32_LEAN_AND_MEAN
2095 #include <windows.h>
2096 #ifdef HAVE_WINSOCK2_H
2097 #include <winsock2.h>
2099 #ifdef HAVE_WINSOCK_H
2100 #include <winsock.h>
2105 /* ioctlsocket source code (Windows) */
2107 unsigned long flags = 0;
2108 sd = socket(0, 0, 0);
2109 ioctlsocket(sd, FIONBIO, &flags);
2112 dnl ioctlsocket test was good
2113 nonblock="ioctlsocket"
2114 AC_DEFINE(HAVE_IOCTLSOCKET, 1,
2115 [use ioctlsocket() for non-blocking sockets])
2119 if test "$nonblock" = "unknown"; then
2122 /* headers for IoctlSocket test (Amiga?) */
2123 #include <sys/ioctl.h>
2125 /* IoctlSocket source code (Amiga?) */
2127 int flags = IoctlSocket(socket, FIONBIO, (long)1);
2130 dnl Ioctlsocket test was good
2131 nonblock="IoctlSocket"
2132 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
2133 [use Ioctlsocket() for non-blocking sockets])
2137 if test "$nonblock" = "unknown"; then
2140 /* headers for SO_NONBLOCK test (BeOS) */
2143 /* SO_NONBLOCK source code (BeOS) */
2146 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
2149 dnl the SO_NONBLOCK test was good
2150 nonblock="SO_NONBLOCK"
2151 AC_DEFINE(HAVE_SO_NONBLOCK, 1,
2152 [use SO_NONBLOCK for non-blocking sockets])
2156 AC_MSG_RESULT($nonblock)
2158 if test "$nonblock" = "unknown"; then
2159 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
2160 [disabled non-blocking sockets])
2161 AC_MSG_WARN([non-block sockets disabled])
2167 dnl -------------------------------------------------
2168 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
2169 dnl and a few other things.
2171 AC_DEFUN([TYPE_IN_ADDR_T], [
2172 AC_CHECK_TYPE([in_addr_t], ,[
2173 dnl in_addr_t not available
2174 AC_CACHE_CHECK([for in_addr_t equivalent],
2175 [curl_cv_in_addr_t_equiv], [
2176 curl_cv_in_addr_t_equiv="unknown"
2177 for t in "unsigned long" int size_t unsigned long; do
2178 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
2182 #ifdef HAVE_WINDOWS_H
2183 #ifndef WIN32_LEAN_AND_MEAN
2184 #define WIN32_LEAN_AND_MEAN
2186 #include <windows.h>
2187 #ifdef HAVE_WINSOCK2_H
2188 #include <winsock2.h>
2190 #ifdef HAVE_WINSOCK_H
2191 #include <winsock.h>
2195 #ifdef HAVE_SYS_TYPES_H
2196 #include <sys/types.h>
2198 #ifdef HAVE_SYS_SOCKET_H
2199 #include <sys/socket.h>
2201 #ifdef HAVE_NETINET_IN_H
2202 #include <netinet/in.h>
2204 #ifdef HAVE_ARPA_INET_H
2205 #include <arpa/inet.h>
2209 $t data = inet_addr ("1.2.3.4");
2212 curl_cv_in_addr_t_equiv="$t"
2217 case "$curl_cv_in_addr_t_equiv" in
2219 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
2222 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
2223 [Type to use in place of in_addr_t when system does not provide it.])
2228 #ifdef HAVE_WINDOWS_H
2229 #ifndef WIN32_LEAN_AND_MEAN
2230 #define WIN32_LEAN_AND_MEAN
2232 #include <windows.h>
2233 #ifdef HAVE_WINSOCK2_H
2234 #include <winsock2.h>
2236 #ifdef HAVE_WINSOCK_H
2237 #include <winsock.h>
2241 #ifdef HAVE_SYS_TYPES_H
2242 #include <sys/types.h>
2244 #ifdef HAVE_SYS_SOCKET_H
2245 #include <sys/socket.h>
2247 #ifdef HAVE_NETINET_IN_H
2248 #include <netinet/in.h>
2250 #ifdef HAVE_ARPA_INET_H
2251 #include <arpa/inet.h>
2258 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
2259 dnl -------------------------------------------------
2260 dnl Check if monotonic clock_gettime is available.
2262 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
2263 AC_REQUIRE([AC_HEADER_TIME])dnl
2264 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
2265 AC_MSG_CHECKING([for monotonic clock_gettime])
2268 #ifdef HAVE_SYS_TYPES_H
2269 #include <sys/types.h>
2271 #ifdef HAVE_SYS_TIME_H
2272 #include <sys/time.h>
2273 #ifdef TIME_WITH_SYS_TIME
2283 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2286 AC_MSG_RESULT([yes])
2287 ac_cv_func_clock_gettime="yes"
2290 ac_cv_func_clock_gettime="no"
2292 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
2293 dnl until library linking and run-time checks for clock_gettime succeed.
2297 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
2298 dnl -------------------------------------------------
2299 dnl If monotonic clock_gettime is available then,
2300 dnl check and prepended to LIBS any needed libraries.
2302 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
2303 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
2305 if test "$ac_cv_func_clock_gettime" = "yes"; then
2307 AC_MSG_CHECKING([for clock_gettime in libraries])
2309 curl_cv_save_LIBS="$LIBS"
2310 curl_cv_gclk_LIBS="unknown"
2312 for x_xlibs in '' '-lrt' '-lposix4' ; do
2313 if test "$curl_cv_gclk_LIBS" = "unknown"; then
2314 if test -z "$x_xlibs"; then
2315 LIBS="$curl_cv_save_LIBS"
2317 LIBS="$x_xlibs $curl_cv_save_LIBS"
2321 #ifdef HAVE_SYS_TYPES_H
2322 #include <sys/types.h>
2324 #ifdef HAVE_SYS_TIME_H
2325 #include <sys/time.h>
2326 #ifdef TIME_WITH_SYS_TIME
2336 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2339 curl_cv_gclk_LIBS="$x_xlibs"
2344 LIBS="$curl_cv_save_LIBS"
2346 case X-"$curl_cv_gclk_LIBS" in
2348 AC_MSG_RESULT([cannot find clock_gettime])
2349 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2350 ac_cv_func_clock_gettime="no"
2353 AC_MSG_RESULT([no additional lib required])
2354 ac_cv_func_clock_gettime="yes"
2357 if test -z "$curl_cv_save_LIBS"; then
2358 LIBS="$curl_cv_gclk_LIBS"
2360 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
2362 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
2363 ac_cv_func_clock_gettime="yes"
2367 dnl only do runtime verification when not cross-compiling
2368 if test "x$cross_compiling" != "xyes" &&
2369 test "$ac_cv_func_clock_gettime" = "yes"; then
2370 AC_MSG_CHECKING([if monotonic clock_gettime works])
2373 #ifdef HAVE_SYS_TYPES_H
2374 #include <sys/types.h>
2376 #ifdef HAVE_SYS_TIME_H
2377 #include <sys/time.h>
2378 #ifdef TIME_WITH_SYS_TIME
2388 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
2394 AC_MSG_RESULT([yes])
2397 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2398 ac_cv_func_clock_gettime="no"
2399 LIBS="$curl_cv_save_LIBS"
2403 case "$ac_cv_func_clock_gettime" in
2405 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
2406 [Define to 1 if you have the clock_gettime function and monotonic timer.])
2415 dnl CURL_CHECK_FUNC_SELECT
2416 dnl -------------------------------------------------
2417 dnl Test if the socket select() function is available,
2418 dnl and check its return type and the types of its
2419 dnl arguments. If the function succeeds HAVE_SELECT
2420 dnl will be defined, defining the types of the
2421 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
2422 dnl and SELECT_TYPE_ARG5, defining the type of the
2423 dnl function return value in SELECT_TYPE_RETV, and
2424 dnl also defining the type qualifier of fifth argument
2425 dnl in SELECT_QUAL_ARG5.
2427 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
2428 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
2429 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
2431 AC_MSG_CHECKING([for select])
2435 #ifdef HAVE_WINDOWS_H
2436 #ifndef WIN32_LEAN_AND_MEAN
2437 #define WIN32_LEAN_AND_MEAN
2439 #include <windows.h>
2440 #ifdef HAVE_WINSOCK2_H
2441 #include <winsock2.h>
2443 #ifdef HAVE_WINSOCK_H
2444 #include <winsock.h>
2448 #ifdef HAVE_SYS_TYPES_H
2449 #include <sys/types.h>
2451 #ifdef HAVE_SYS_TIME_H
2452 #include <sys/time.h>
2453 #ifdef TIME_WITH_SYS_TIME
2461 #ifndef HAVE_WINDOWS_H
2462 #ifdef HAVE_SYS_SELECT_H
2463 #include <sys/select.h>
2465 #ifdef HAVE_SYS_SOCKET_H
2466 #include <sys/socket.h>
2470 select(0, 0, 0, 0, 0);
2473 AC_MSG_RESULT([yes])
2474 curl_cv_select="yes"
2480 if test "$curl_cv_select" = "yes"; then
2481 AC_CACHE_CHECK([types of args and return type for select],
2482 [curl_cv_func_select_args], [
2483 curl_cv_func_select_args="unknown"
2484 for sel_retv in 'int' 'ssize_t'; do
2485 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2486 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2487 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2488 if test "$curl_cv_func_select_args" = "unknown"; then
2492 #ifdef HAVE_WINDOWS_H
2493 #ifndef WIN32_LEAN_AND_MEAN
2494 #define WIN32_LEAN_AND_MEAN
2496 #include <windows.h>
2497 #ifdef HAVE_WINSOCK2_H
2498 #include <winsock2.h>
2500 #ifdef HAVE_WINSOCK_H
2501 #include <winsock.h>
2504 #define SELECTCALLCONV PASCAL
2506 #ifdef HAVE_SYS_TYPES_H
2507 #include <sys/types.h>
2509 #ifdef HAVE_SYS_TIME_H
2510 #include <sys/time.h>
2511 #ifdef TIME_WITH_SYS_TIME
2519 #ifndef HAVE_WINDOWS_H
2520 #ifdef HAVE_SYS_SELECT_H
2521 #include <sys/select.h>
2523 #ifdef HAVE_SYS_SOCKET_H
2524 #include <sys/socket.h>
2526 #define SELECTCALLCONV
2528 #ifndef HAVE_STRUCT_TIMEVAL
2534 extern $sel_retv SELECTCALLCONV select($sel_arg1,
2544 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2547 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2555 if test "$curl_cv_func_select_args" = "unknown"; then
2556 AC_MSG_WARN([Cannot find proper types to use for select args])
2557 AC_MSG_WARN([HAVE_SELECT will not be defined])
2559 select_prev_IFS=$IFS; IFS=','
2560 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2561 IFS=$select_prev_IFS
2564 sel_qual_type_arg5=$[3]
2566 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2567 [Define to the type of arg 1 for select.])
2568 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2569 [Define to the type of args 2, 3 and 4 for select.])
2570 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2571 [Define to the function return type for select.])
2575 case $prev_sh_opts in
2583 case "$sel_qual_type_arg5" in
2586 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2590 sel_type_arg5=$sel_qual_type_arg5
2594 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2595 [Define to the type qualifier of arg 5 for select.])
2596 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2597 [Define to the type of arg 5 for select.])
2599 case $prev_sh_opts in
2607 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2608 [Define to 1 if you have the select function.])
2609 ac_cv_func_select="yes"
2615 dnl ************************************************************
2616 dnl check for working getaddrinfo() that works with AI_NUMERICHOST
2618 AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
2619 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
2622 #include <sys/types.h>
2623 #include <sys/socket.h>
2627 struct addrinfo hints, *ai;
2630 memset(&hints, 0, sizeof(hints));
2631 hints.ai_flags = AI_NUMERICHOST;
2632 hints.ai_family = AF_UNSPEC;
2633 hints.ai_socktype = SOCK_STREAM;
2634 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
2641 ac_cv_working_getaddrinfo="yes"
2643 ac_cv_working_getaddrinfo="no"
2645 ac_cv_working_getaddrinfo="yes"
2647 if test "$ac_cv_working_getaddrinfo" = "yes"; then
2648 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
2649 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
2652 AC_SUBST(IPV6_ENABLED)
2657 AC_DEFUN([CURL_CHECK_LOCALTIME_R],
2659 dnl check for localtime_r
2660 AC_CHECK_FUNCS(localtime_r,[
2661 AC_MSG_CHECKING(whether localtime_r is declared)
2662 AC_EGREP_CPP(localtime_r,[
2664 #include <time.h>],[
2665 AC_MSG_RESULT(yes)],[
2667 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
2668 AC_EGREP_CPP(localtime_r,[
2671 #include <time.h>],[
2672 AC_MSG_RESULT(yes)],
2673 AC_MSG_RESULT(no))])])
2677 dnl This function checks for strerror_r(). If it isn't found at first, it
2678 dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
2679 dnl in order to find this function.
2681 dnl If the function is found, it will then proceed to check how the function
2682 dnl actually works: glibc-style or POSIX-style.
2685 dnl char *strerror_r(int errnum, char *buf, size_t n);
2687 dnl What this one does is to return the error string (no surprises there),
2688 dnl but it doesn't usually copy anything into buf! The 'buf' and 'n'
2689 dnl parameters are only meant as an optional working area, in case strerror_r
2690 dnl needs it. A quick test on a few systems shows that it's generally not
2694 dnl int strerror_r(int errnum, char *buf, size_t n);
2696 AC_DEFUN([CURL_CHECK_STRERROR_R],
2698 AC_CHECK_FUNCS(strerror_r)
2700 if test "x$ac_cv_func_strerror_r" = "xyes"; then
2702 AC_MSG_CHECKING(whether strerror_r is declared)
2703 AC_EGREP_CPP(strerror_r,[
2705 #include <string.h>],[
2706 AC_MSG_RESULT(yes)],[
2708 AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
2709 AC_EGREP_CPP(strerror_r,[
2712 #include <string.h>],[
2713 AC_MSG_RESULT(yes)],
2715 AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
2716 ) dnl with _THREAD_SAFE
2717 ]) dnl plain cpp for it
2719 dnl determine if this strerror_r() is glibc or POSIX
2720 AC_MSG_CHECKING([for a glibc strerror_r API])
2726 char buffer[1024]; /* big enough to play with */
2728 strerror_r(EACCES, buffer, sizeof(buffer));
2729 /* this should've returned a string */
2730 if(!string || !string[0])
2735 GLIBC_STRERROR_R="1"
2736 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2737 AC_MSG_RESULT([yes]),
2738 AC_MSG_RESULT([no]),
2740 dnl Use an inferior method of strerror_r detection while cross-compiling
2742 #include <features.h>
2747 dnl looks like glibc, so assume a glibc-style strerror_r()
2748 GLIBC_STRERROR_R="1"
2749 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2750 AC_MSG_RESULT([yes]),
2751 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2752 ) dnl while cross-compiling
2755 if test -z "$GLIBC_STRERROR_R"; then
2757 AC_MSG_CHECKING([for a POSIX strerror_r API])
2763 char buffer[1024]; /* big enough to play with */
2765 strerror_r(EACCES, buffer, sizeof(buffer));
2766 /* This should've returned zero, and written an error string in the
2768 if(!buffer[0] || error)
2773 AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
2774 AC_MSG_RESULT([yes]),
2775 AC_MSG_RESULT([no]) ,
2776 dnl cross-compiling!
2777 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2780 fi dnl if not using glibc API
2782 fi dnl we have a strerror_r
2786 AC_DEFUN([CURL_CHECK_INET_NTOA_R],
2788 dnl determine if function definition for inet_ntoa_r exists.
2789 AC_CHECK_FUNCS(inet_ntoa_r,[
2790 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
2791 AC_EGREP_CPP(inet_ntoa_r,[
2793 #include <arpa/inet.h>],[
2794 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2795 AC_MSG_RESULT(yes)],[
2797 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
2798 AC_EGREP_CPP(inet_ntoa_r,[
2801 #include <arpa/inet.h>],[
2802 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2803 AC_MSG_RESULT(yes)],
2804 AC_MSG_RESULT(no))])])
2808 dnl CURL_CHECK_GETHOSTBYADDR_R
2809 dnl -------------------------------------------------
2810 dnl check number of arguments for gethostbyaddr_r, it
2811 dnl might take either 5, 7, or 8 arguments.
2813 AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R], [
2815 AC_MSG_CHECKING([for gethostbyaddr_r])
2817 AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
2819 AC_MSG_RESULT([yes])
2820 tmp_cv_gethostbyaddr_r="yes"
2823 tmp_cv_gethostbyaddr_r="no"
2826 if test "$tmp_cv_gethostbyaddr_r" != "yes"; then
2827 AC_MSG_CHECKING([deeper for gethostbyaddr_r])
2834 AC_MSG_RESULT([yes])
2835 tmp_cv_gethostbyaddr_r="yes"
2837 AC_MSG_RESULT([but still no])
2838 tmp_cv_gethostbyaddr_r="no"
2842 if test "$tmp_cv_gethostbyaddr_r" = "yes"; then
2844 ac_cv_gethostbyaddr_r_args="unknown"
2846 AC_MSG_CHECKING([if gethostbyaddr_r takes 5 arguments])
2850 #include <sys/types.h>
2857 struct hostent_data hdata;
2859 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2862 AC_MSG_RESULT([yes])
2863 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2864 ac_cv_gethostbyaddr_r_args="5"
2869 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2870 AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 5 arguments])
2875 #include <sys/types.h>
2882 struct hostent_data hdata;
2884 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2887 AC_MSG_RESULT([yes])
2888 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2889 ac_cv_gethostbyaddr_r_args="5"
2895 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2896 AC_MSG_CHECKING([if gethostbyaddr_r takes 7 arguments])
2900 #include <sys/types.h>
2909 struct hostent * hp;
2910 hp = gethostbyaddr_r(address, length, type, &h,
2911 buffer, 8192, &h_errnop);
2914 AC_MSG_RESULT([yes])
2915 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2916 ac_cv_gethostbyaddr_r_args="7"
2922 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2923 AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 7 arguments])
2928 #include <sys/types.h>
2937 struct hostent * hp;
2938 hp = gethostbyaddr_r(address, length, type, &h,
2939 buffer, 8192, &h_errnop);
2942 AC_MSG_RESULT([yes])
2943 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2944 ac_cv_gethostbyaddr_r_args="7"
2950 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2951 AC_MSG_CHECKING([if gethostbyaddr_r takes 8 arguments])
2955 #include <sys/types.h>
2964 struct hostent * hp;
2966 rc = gethostbyaddr_r(address, length, type, &h,
2967 buffer, 8192, &hp, &h_errnop);
2970 AC_MSG_RESULT([yes])
2971 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
2972 ac_cv_gethostbyaddr_r_args="8"
2978 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2979 AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 8 arguments])
2984 #include <sys/types.h>
2993 struct hostent * hp;
2995 rc = gethostbyaddr_r(address, length, type, &h,
2996 buffer, 8192, &hp, &h_errnop);
2999 AC_MSG_RESULT([yes])
3000 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
3001 ac_cv_gethostbyaddr_r_args="8"
3007 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
3008 AC_MSG_WARN([Cannot find out how to use gethostbyaddr_r])
3009 AC_MSG_WARN([HAVE_GETHOSTBYADDR_R will not be defined])
3010 ac_cv_func_gethostbyaddr_r="no"
3012 AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
3013 [Define to 1 if you have the gethostbyaddr_r function.])
3014 ac_cv_func_gethostbyaddr_r="yes"
3018 ac_cv_func_gethostbyaddr_r="no"
3023 dnl CURL_CHECK_GETHOSTBYNAME_R
3024 dnl -------------------------------------------------
3025 dnl check number of arguments for gethostbyname_r, it
3026 dnl might take either 3, 5, or 6 arguments.
3028 AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R], [
3030 AC_MSG_CHECKING([for gethostbyname_r])
3032 AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
3034 AC_MSG_RESULT([yes])
3035 tmp_cv_gethostbyname_r="yes"
3038 tmp_cv_gethostbyname_r="no"
3041 if test "$tmp_cv_gethostbyname_r" != "yes"; then
3042 AC_MSG_CHECKING([deeper for gethostbyname_r])
3049 AC_MSG_RESULT([yes])
3050 tmp_cv_gethostbyname_r="yes"
3052 AC_MSG_RESULT([but still no])
3053 tmp_cv_gethostbyname_r="no"
3057 if test "$tmp_cv_gethostbyname_r" = "yes"; then
3059 ac_cv_gethostbyname_r_args="unknown"
3061 AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
3066 #include <sys/types.h>
3069 #define NULL (void *)0
3071 gethostbyname_r(const char *, struct hostent *,
3072 struct hostent_data *);
3074 struct hostent_data data;
3075 gethostbyname_r(NULL, NULL, NULL);
3078 AC_MSG_RESULT([yes])
3079 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
3080 ac_cv_gethostbyname_r_args="3"
3085 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3086 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
3092 #include <sys/types.h>
3095 #define NULL (void *)0
3097 gethostbyname_r(const char *, struct hostent *,
3098 struct hostent_data *);
3100 struct hostent_data data;
3101 gethostbyname_r(NULL, NULL, NULL);
3104 AC_MSG_RESULT([yes])
3105 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
3106 ac_cv_gethostbyname_r_args="3"
3112 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3113 AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
3117 #include <sys/types.h>
3120 #define NULL (void *)0
3122 gethostbyname_r(const char *, struct hostent *,
3123 char *, int, int *);
3125 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
3128 AC_MSG_RESULT([yes])
3129 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
3130 ac_cv_gethostbyname_r_args="5"
3136 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3137 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 5 arguments])
3142 #include <sys/types.h>
3145 #define NULL (void *)0
3147 gethostbyname_r(const char *, struct hostent *,
3148 char *, int, int *);
3150 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
3153 AC_MSG_RESULT([yes])
3154 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
3155 ac_cv_gethostbyname_r_args="5"
3161 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3162 AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
3166 #include <sys/types.h>
3169 #define NULL (void *)0
3171 gethostbyname_r(const char *, struct hostent *,
3172 char *, size_t, struct hostent **, int *);
3174 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
3177 AC_MSG_RESULT([yes])
3178 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
3179 ac_cv_gethostbyname_r_args="6"
3185 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3186 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 6 arguments])
3191 #include <sys/types.h>
3194 #define NULL (void *)0
3196 gethostbyname_r(const char *, struct hostent *,
3197 char *, size_t, struct hostent **, int *);
3199 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
3202 AC_MSG_RESULT([yes])
3203 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
3204 ac_cv_gethostbyname_r_args="6"
3210 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3211 AC_MSG_WARN([Cannot find out how to use gethostbyname_r])
3212 AC_MSG_WARN([HAVE_GETHOSTBYNAME_R will not be defined])
3213 ac_cv_func_gethostbyname_r="no"
3215 AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
3216 [Define to 1 if you have the gethostbyname_r function.])
3217 ac_cv_func_gethostbyname_r="yes"
3221 ac_cv_func_gethostbyname_r="no"
3226 dnl **********************************************************************
3227 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
3229 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
3230 dnl sets the $ICC variable to "yes" or "no"
3231 dnl **********************************************************************
3232 AC_DEFUN([CURL_DETECT_ICC],
3235 AC_MSG_CHECKING([for icc in use])
3236 if test "$GCC" = "yes"; then
3237 dnl check if this is icc acting as gcc in disguise
3238 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
3239 dnl action if the text is found, this it has not been replaced by the
3242 dnl the text was not found, it was replaced by the cpp
3244 AC_MSG_RESULT([yes])
3248 if test "$ICC" = "no"; then
3254 dnl We create a function for detecting which compiler we use and then set as
3255 dnl pendantic compiler options as possible for that particular compiler. The
3256 dnl options are only used for debug-builds.
3258 AC_DEFUN([CURL_CC_DEBUG_OPTS],
3260 if test "z$ICC" = "z"; then
3264 if test "$GCC" = "yes"; then
3266 dnl figure out gcc version!
3267 AC_MSG_CHECKING([gcc version])
3268 gccver=`$CC -dumpversion`
3269 num1=`echo $gccver | cut -d . -f1`
3270 num2=`echo $gccver | cut -d . -f2`
3271 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
3272 AC_MSG_RESULT($gccver)
3274 if test "$ICC" = "yes"; then
3275 dnl this is icc, not gcc.
3277 dnl ICC warnings we ignore:
3278 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
3279 dnl "invalid format string conversion"
3280 dnl * 279 warns on static conditions in while expressions
3281 dnl * 981 warns on "operands are evaluated in unspecified order"
3282 dnl * 1418 "external definition with no prior declaration"
3283 dnl * 1419 warns on "external declaration in primary source file"
3284 dnl which we know and do on purpose.
3286 WARN="-wd279,269,981,1418,1419"
3288 if test "$gccnum" -gt "600"; then
3289 dnl icc 6.0 and older doesn't have the -Wall flag
3293 dnl this is a set of options we believe *ALL* gcc versions support:
3294 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
3296 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
3298 if test "$gccnum" -ge "207"; then
3299 dnl gcc 2.7 or later
3300 WARN="$WARN -Wmissing-declarations"
3303 if test "$gccnum" -gt "295"; then
3304 dnl only if the compiler is newer than 2.95 since we got lots of
3305 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
3306 dnl gcc 2.95.4 on FreeBSD 4.9!
3307 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
3310 if test "$gccnum" -ge "296"; then
3311 dnl gcc 2.96 or later
3312 WARN="$WARN -Wfloat-equal"
3315 if test "$gccnum" -gt "296"; then
3316 dnl this option does not exist in 2.96
3317 WARN="$WARN -Wno-format-nonliteral"
3320 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
3321 dnl on i686-Linux as it gives us heaps with false positives.
3322 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
3323 dnl over making it unusable for generic purposes. Let's not use it.
3325 if test "$gccnum" -ge "303"; then
3326 dnl gcc 3.3 and later
3327 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
3330 if test "$gccnum" -ge "304"; then
3331 # try these on gcc 3.4
3332 WARN="$WARN -Wdeclaration-after-statement"
3335 for flag in $CPPFLAGS; do
3338 dnl Include path, provide a -isystem option for the same dir
3339 dnl to prevent warnings in those dirs. The -isystem was not very
3340 dnl reliable on earlier gcc versions.
3341 add=`echo $flag | sed 's/^-I/-isystem /g'`
3349 CFLAGS="$CFLAGS $WARN"
3351 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
3355 AC_MSG_NOTICE([Added no extra compiler options])
3359 dnl strip off optimizer flags
3361 for flag in $CFLAGS; do
3364 dnl echo "cut off $flag"
3367 NEWFLAGS="$NEWFLAGS $flag"
3377 # This is only a temporary fix. This macro is here to replace the broken one
3378 # delivered by the automake project (including the 1.9.6 release). As soon as
3379 # they ship a working version we SHOULD remove this work-around.
3381 AC_DEFUN([AM_MISSING_HAS_RUN],
3382 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
3383 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
3384 # Use eval to expand $SHELL
3385 if eval "$MISSING --run true"; then
3386 am_missing_run="$MISSING --run "
3389 AC_MSG_WARN([`missing' script is too old or missing])
3394 dnl CURL_VERIFY_RUNTIMELIBS
3395 dnl -------------------------------------------------
3396 dnl Verify that the shared libs found so far can be used when running
3397 dnl programs, since otherwise the situation will create odd configure errors
3398 dnl that are misleading people.
3400 dnl Make sure this test is run BEFORE the first test in the script that
3401 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
3402 dnl macro. It must also run AFTER all lib-checking macros are complete.
3404 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
3406 dnl this test is of course not sensible if we are cross-compiling!
3407 if test "x$cross_compiling" != xyes; then
3409 dnl just run a program to verify that the libs checked for previous to this
3410 dnl point also is available run-time!
3411 AC_MSG_CHECKING([run-time libs availability])
3418 AC_MSG_RESULT([fine]),
3419 AC_MSG_RESULT([failed])
3420 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
3423 dnl if this test fails, configure has already stopped
3428 dnl CURL_CHECK_VARIADIC_MACROS
3429 dnl -------------------------------------------------
3430 dnl Check compiler support of variadic macros
3432 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
3433 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
3434 [curl_cv_variadic_macros_c99], [
3437 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
3438 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
3439 int fun3(int arg1, int arg2, int arg3);
3440 int fun2(int arg1, int arg2);
3441 int fun3(int arg1, int arg2, int arg3)
3442 { return arg1 + arg2 + arg3; }
3443 int fun2(int arg1, int arg2)
3444 { return arg1 + arg2; }
3446 int res3 = c99_vmacro3(1, 2, 3);
3447 int res2 = c99_vmacro2(1, 2);
3450 curl_cv_variadic_macros_c99="yes"
3452 curl_cv_variadic_macros_c99="no"
3455 case "$curl_cv_variadic_macros_c99" in
3457 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
3458 [Define to 1 if compiler supports C99 variadic macro style.])
3461 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
3462 [curl_cv_variadic_macros_gcc], [
3465 #define gcc_vmacro3(first, args...) fun3(first, args)
3466 #define gcc_vmacro2(first, args...) fun2(first, args)
3467 int fun3(int arg1, int arg2, int arg3);
3468 int fun2(int arg1, int arg2);
3469 int fun3(int arg1, int arg2, int arg3)
3470 { return arg1 + arg2 + arg3; }
3471 int fun2(int arg1, int arg2)
3472 { return arg1 + arg2; }
3474 int res3 = gcc_vmacro3(1, 2, 3);
3475 int res2 = gcc_vmacro2(1, 2);
3478 curl_cv_variadic_macros_gcc="yes"
3480 curl_cv_variadic_macros_gcc="no"
3483 case "$curl_cv_variadic_macros_gcc" in
3485 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
3486 [Define to 1 if compiler supports old gcc variadic macro style.])
3492 dnl CURL_CHECK_CA_BUNDLE
3493 dnl -------------------------------------------------
3494 dnl Check if a default ca-bundle should be used
3496 dnl regarding the paths this will scan:
3497 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
3498 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
3499 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
3500 dnl /etc/ssl/certs/ (ca path) SUSE
3502 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
3504 AC_MSG_CHECKING([default CA cert bundle/path])
3506 AC_ARG_WITH(ca-bundle,
3507 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
3508 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
3511 if test "x$want_ca" = "xyes"; then
3512 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
3515 [ want_ca="unset" ])
3516 AC_ARG_WITH(ca-path,
3517 AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
3518 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
3520 want_capath="$withval"
3521 if test "x$want_capath" = "xyes"; then
3522 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
3525 [ want_capath="unset"])
3527 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
3528 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
3530 AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
3531 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
3532 dnl --with-ca-bundle given
3535 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
3536 dnl --with-ca-path given
3537 if test "x$OPENSSL_ENABLED" != "x1"; then
3538 AC_MSG_ERROR([--with-ca-path only works with openSSL])
3540 capath="$want_capath"
3543 dnl neither of --with-ca-* given
3544 dnl first try autodetecting a CA bundle , then a CA path
3545 dnl both autodetections can be skipped by --without-ca-*
3548 if test "x$want_ca" = "xunset"; then
3549 dnl the path we previously would have installed the curl ca bundle
3550 dnl to, and thus we now check for an already existing cert in that place
3551 dnl in case we find no other
3552 if test "x$prefix" != xNONE; then
3553 cac="${prefix}/share/curl/curl-ca-bundle.crt"
3555 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
3558 for a in /etc/ssl/certs/ca-certificates.crt \
3559 /etc/pki/tls/certs/ca-bundle.crt \
3560 /usr/share/ssl/certs/ca-bundle.crt \
3562 if test -f "$a"; then
3568 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
3569 "x$OPENSSL_ENABLED" = "x1"; then
3570 for a in /etc/ssl/certs/; do
3571 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
3581 if test "x$ca" != "xno"; then
3582 CURL_CA_BUNDLE='"'$ca'"'
3583 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
3584 AC_SUBST(CURL_CA_BUNDLE)
3585 AC_MSG_RESULT([$ca])
3586 elif test "x$capath" != "xno"; then
3587 CURL_CA_PATH="\"$capath\""
3588 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
3589 AC_MSG_RESULT([$capath (capath)])
3596 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
3597 dnl -------------------------------------------------
3598 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
3599 dnl symbol that can be further used in custom template configuration
3600 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
3601 dnl argument for the description. Symbol definitions done with this
3602 dnl macro are intended to be exclusively used in handcrafted *.h.in
3603 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
3604 dnl prevents autoheader generation and insertion of symbol template
3605 dnl stub and definition into the first configuration header file. Do
3606 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
3607 dnl one serves different functional needs.
3609 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
3610 cat >>confdefs.h <<_EOF
3611 [@%:@define] $1 ifelse($#, 2, [$2], 1)
3616 dnl CURL_INCLUDES_INTTYPES
3617 dnl -------------------------------------------------
3618 dnl Set up variable with list of headers that must be
3619 dnl included when inttypes.h is to be included.
3621 AC_DEFUN([CURL_INCLUDES_INTTYPES], [
3622 curl_includes_inttypes="\
3623 /* includes start */
3624 #ifdef HAVE_SYS_TYPES_H
3625 # include <sys/types.h>
3627 #ifdef HAVE_STDINT_H
3628 # include <stdint.h>
3630 #ifdef HAVE_INTTYPES_H
3631 # include <inttypes.h>
3635 sys/types.h stdint.h inttypes.h,
3636 [], [], [$curl_includes_inttypes])
3640 dnl CURL_CONFIGURE_LONG
3641 dnl -------------------------------------------------
3642 dnl Find out the size of long as reported by sizeof() and define
3643 dnl CURL_SIZEOF_LONG as appropriate to be used in template file
3644 dnl include/curl/curlbuild.h.in to properly configure the library.
3645 dnl The size of long is a build time characteristic and as such
3646 dnl must be recorded in curlbuild.h
3648 AC_DEFUN([CURL_CONFIGURE_LONG], [
3649 if test -z "$ac_cv_sizeof_long" ||
3650 test "$ac_cv_sizeof_long" -eq "0"; then
3651 AC_MSG_ERROR([cannot find out size of long.])
3653 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
3657 dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
3658 dnl -------------------------------------------------
3659 dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
3661 AC_DEFUN([DO_CURL_OFF_T_CHECK], [
3662 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
3663 if test "$x_typeof" = "unknown" && test ! -z "$1"; then
3668 case AS_TR_SH([$1]) in
3670 tmp_includes="$curl_includes_inttypes"
3671 tmp_source="char f@<:@@:>@ = PRId64;"
3676 tmp_includes="$curl_includes_inttypes"
3677 tmp_source="char f@<:@@:>@ = PRId32;"
3682 tmp_includes="$curl_includes_inttypes"
3683 tmp_source="char f@<:@@:>@ = PRId16;"
3691 typedef $1 curl_off_t;
3692 typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
3698 if test -z "$tmp_fmt"; then
3702 CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
3703 CURL_CHECK_DEF_INTXX_C([$tmp_intxx], [$curl_includes_inttypes])
3704 AS_VAR_PUSHDEF([tmp_HaveFmtDef], [curl_cv_have_def_$tmp_fmt])dnl
3705 AS_VAR_PUSHDEF([tmp_FmtDef], [curl_cv_def_$tmp_fmt])dnl
3706 AS_VAR_PUSHDEF([tmp_HaveSufDef], [curl_cv_have_def_$tmp_intxx])dnl
3707 AS_VAR_PUSHDEF([tmp_SufDef], [curl_cv_def_$tmp_intxx])dnl
3708 if test AS_VAR_GET(tmp_HaveFmtDef) = "yes" &&
3709 test AS_VAR_GET(tmp_HaveSufDef) = "yes"; then
3710 x_format=AS_VAR_GET(tmp_FmtDef)
3711 x_suffix=AS_VAR_GET(tmp_SufDef)
3715 AS_VAR_POPDEF([tmp_SufDef])dnl
3716 AS_VAR_POPDEF([tmp_HaveSufDef])dnl
3717 AS_VAR_POPDEF([tmp_FmtDef])dnl
3718 AS_VAR_POPDEF([tmp_HaveFmtDef])dnl
3725 dnl CURL_CONFIGURE_CURL_OFF_T
3726 dnl -------------------------------------------------
3727 dnl Find out suitable curl_off_t data type definition and associated
3728 dnl items, and make the appropriate definitions used in template file
3729 dnl include/curl/curlbuild.h.in to properly configure the library.
3731 AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
3732 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
3734 AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
3735 AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
3736 AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
3738 if test -z "$SED"; then
3739 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
3742 AC_CHECK_SIZEOF(long)
3743 AC_CHECK_SIZEOF(void*)
3745 if test -z "$ac_cv_sizeof_long" ||
3746 test "$ac_cv_sizeof_long" -eq "0"; then
3747 AC_MSG_ERROR([cannot find out size of long.])
3749 if test -z "$ac_cv_sizeof_voidp" ||
3750 test "$ac_cv_sizeof_voidp" -eq "0"; then
3751 AC_MSG_ERROR([cannot find out size of void*.])
3758 if test "$ac_cv_sizeof_long" -eq "8" &&
3759 test "$ac_cv_sizeof_voidp" -ge "8"; then
3761 elif test "$ac_cv_sizeof_long" -eq "4" &&
3762 test "$ac_cv_sizeof_voidp" -ge "4"; then
3764 elif test "$ac_cv_sizeof_long" -eq "2" &&
3765 test "$ac_cv_sizeof_voidp" -ge "2"; then
3769 dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
3778 if test "$x_typeof" = "unknown"; then
3779 AC_MSG_CHECKING([for 64-bit curl_off_t data type])
3787 DO_CURL_OFF_T_CHECK([$t8], [8])
3789 AC_MSG_RESULT([$x_typeof])
3791 if test "$x_typeof" = "unknown"; then
3792 AC_MSG_CHECKING([for 32-bit curl_off_t data type])
3798 DO_CURL_OFF_T_CHECK([$t4], [4])
3800 AC_MSG_RESULT([$x_typeof])
3802 if test "$x_typeof" = "unknown"; then
3803 AC_MSG_CHECKING([for 16-bit curl_off_t data type])
3809 DO_CURL_OFF_T_CHECK([$t2], [2])
3811 AC_MSG_RESULT([$x_typeof])
3813 if test "$x_typeof" = "unknown"; then
3814 AC_MSG_ERROR([cannot find data type for curl_off_t.])
3817 AC_MSG_CHECKING([size of curl_off_t])
3818 AC_MSG_RESULT([$x_sizeof])
3820 AC_MSG_CHECKING([formatting string directive for curl_off_t])
3821 if test "$x_format" != "unknown"; then
3822 x_pull_headers="yes"
3823 x_format=`echo "$x_format" | "$SED" 's/[["]]//g'`
3824 u_format=`echo "$x_format" | "$SED" 's/i$/u/'`
3825 u_format=`echo "$u_format" | "$SED" 's/d$/u/'`
3826 u_format=`echo "$u_format" | "$SED" 's/D$/U/'`
3827 u_suffix=`echo "$x_suffix" | "$SED" 's/^/U/'`
3830 case AS_TR_SH([$x_typeof]) in
3831 long_long | __longlong | __longlong_t)
3868 AC_MSG_ERROR([cannot find print format string for curl_off_t.])
3872 AC_MSG_RESULT(["$x_format"])
3874 AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
3875 AC_MSG_RESULT(["$u_format"])
3876 AC_MSG_CHECKING([constant suffix string for curl_off_t])
3877 AC_MSG_RESULT([$x_suffix])
3878 AC_MSG_CHECKING([constant suffix string for unsigned curl_off_t])
3879 AC_MSG_RESULT([$u_suffix])
3881 if test "$x_pull_headers" = "yes"; then
3882 if test "x$ac_cv_header_sys_types_h" = "xyes"; then
3883 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
3885 if test "x$ac_cv_header_stdint_h" = "xyes"; then
3886 CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
3888 if test "x$ac_cv_header_inttypes_h" = "xyes"; then
3889 CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
3893 CURL_DEFINE_UNQUOTED([CURL_OFF_T], [$x_typeof])
3894 CURL_DEFINE_UNQUOTED([CURL_FMT_OFF_T], ["$x_format"])
3895 CURL_DEFINE_UNQUOTED([CURL_FMT_OFF_TU], ["$u_format"])
3896 CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$x_format"])
3897 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$x_sizeof])
3898 CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_T], [$x_suffix])
3899 CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_TU], [$u_suffix])