1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2009, 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_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
122 dnl -------------------------------------------------
123 dnl Use the C compiler to find out only if the given symbol is defined
124 dnl or not, this can not find out its expansion. This macro will not use
125 dnl default includes even if no INCLUDES argument is given. This macro
126 dnl will run silently when invoked with three arguments.
128 AC_DEFUN([CURL_CHECK_DEF_CC], [
129 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
130 ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
139 force compilation error
144 tst_symbol_defined="yes"
146 tst_symbol_defined="no"
148 if test "$tst_symbol_defined" = "yes"; then
149 AS_VAR_SET(ac_HaveDef, yes)
150 ifelse($3,,[AC_MSG_RESULT([yes])])
152 AS_VAR_SET(ac_HaveDef, no)
153 ifelse($3,,[AC_MSG_RESULT([no])])
155 AS_VAR_POPDEF([ac_HaveDef])dnl
159 dnl CURL_CHECK_LIB_XNET
160 dnl -------------------------------------------------
161 dnl Verify if X/Open network library is required.
163 AC_DEFUN([CURL_CHECK_LIB_XNET], [
164 AC_MSG_CHECKING([if X/Open network library is required])
165 tst_lib_xnet_required="no"
170 #if defined(__hpux) && defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE >= 600)
172 #if defined(__hpux) && defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)
175 force compilation error
180 tst_lib_xnet_required="yes"
183 AC_MSG_RESULT([$tst_lib_xnet_required])
187 dnl CURL_CHECK_AIX_ALL_SOURCE
188 dnl -------------------------------------------------
189 dnl Provides a replacement of traditional AC_AIX with
190 dnl an uniform behaviour across all autoconf versions,
191 dnl and with our own placement rules.
193 AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
194 AH_VERBATIM([_ALL_SOURCE],
195 [/* Define to 1 if OS is AIX. */
199 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
200 AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
201 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
202 AC_EGREP_CPP([yes_this_is_aix],[
208 AC_DEFINE(_ALL_SOURCE)
215 dnl CURL_CHECK_HEADER_WINDOWS
216 dnl -------------------------------------------------
217 dnl Check for compilable and valid windows.h header
219 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
220 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
224 #ifndef WIN32_LEAN_AND_MEAN
225 #define WIN32_LEAN_AND_MEAN
229 #if defined(__CYGWIN__) || defined(__CEGCC__)
230 HAVE_WINDOWS_H shall not be defined.
236 ac_cv_header_windows_h="yes"
238 ac_cv_header_windows_h="no"
241 case "$ac_cv_header_windows_h" in
243 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
244 [Define to 1 if you have the windows.h header file.])
245 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
246 [Define to avoid automatic inclusion of winsock.h])
252 dnl CURL_CHECK_NATIVE_WINDOWS
253 dnl -------------------------------------------------
254 dnl Check if building a native Windows target
256 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
257 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
258 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
259 if test "$ac_cv_header_windows_h" = "no"; then
260 ac_cv_native_windows="no"
265 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
266 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
269 Not a native Windows build target.
273 ac_cv_native_windows="yes"
275 ac_cv_native_windows="no"
279 case "$ac_cv_native_windows" in
281 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
282 [Define to 1 if you are building a native Windows target.])
288 dnl CURL_CHECK_HEADER_WINSOCK
289 dnl -------------------------------------------------
290 dnl Check for compilable and valid winsock.h header
292 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
293 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
294 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
298 #ifndef WIN32_LEAN_AND_MEAN
299 #define WIN32_LEAN_AND_MEAN
304 #if defined(__CYGWIN__) || defined(__CEGCC__)
305 HAVE_WINSOCK_H shall not be defined.
307 int dummy=WSACleanup();
311 ac_cv_header_winsock_h="yes"
313 ac_cv_header_winsock_h="no"
316 case "$ac_cv_header_winsock_h" in
318 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
319 [Define to 1 if you have the winsock.h header file.])
325 dnl CURL_CHECK_HEADER_WINSOCK2
326 dnl -------------------------------------------------
327 dnl Check for compilable and valid winsock2.h header
329 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
330 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
331 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
335 #ifndef WIN32_LEAN_AND_MEAN
336 #define WIN32_LEAN_AND_MEAN
339 #include <winsock2.h>
341 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
342 HAVE_WINSOCK2_H shall not be defined.
344 int dummy=2*IPPROTO_ESP;
348 ac_cv_header_winsock2_h="yes"
350 ac_cv_header_winsock2_h="no"
353 case "$ac_cv_header_winsock2_h" in
355 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
356 [Define to 1 if you have the winsock2.h header file.])
362 dnl CURL_CHECK_HEADER_WS2TCPIP
363 dnl -------------------------------------------------
364 dnl Check for compilable and valid ws2tcpip.h header
366 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
367 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
368 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
372 #ifndef WIN32_LEAN_AND_MEAN
373 #define WIN32_LEAN_AND_MEAN
376 #include <winsock2.h>
377 #include <ws2tcpip.h>
379 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
380 HAVE_WS2TCPIP_H shall not be defined.
382 int dummy=2*IP_PKTINFO;
386 ac_cv_header_ws2tcpip_h="yes"
388 ac_cv_header_ws2tcpip_h="no"
391 case "$ac_cv_header_ws2tcpip_h" in
393 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
394 [Define to 1 if you have the ws2tcpip.h header file.])
400 dnl CURL_CHECK_HEADER_WINLDAP
401 dnl -------------------------------------------------
402 dnl Check for compilable and valid winldap.h header
404 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
405 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
406 AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
410 #ifdef HAVE_WINDOWS_H
411 #ifndef WIN32_LEAN_AND_MEAN
412 #define WIN32_LEAN_AND_MEAN
418 #if defined(__CYGWIN__) || defined(__CEGCC__)
419 HAVE_WINLDAP_H shall not be defined.
421 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
422 ULONG res = ldap_unbind(ldp);
426 ac_cv_header_winldap_h="yes"
428 ac_cv_header_winldap_h="no"
431 case "$ac_cv_header_winldap_h" in
433 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
434 [Define to 1 if you have the winldap.h header file.])
440 dnl CURL_CHECK_HEADER_WINBER
441 dnl -------------------------------------------------
442 dnl Check for compilable and valid winber.h header
444 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
445 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
446 AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
450 #ifdef HAVE_WINDOWS_H
451 #ifndef WIN32_LEAN_AND_MEAN
452 #define WIN32_LEAN_AND_MEAN
459 #if defined(__CYGWIN__) || defined(__CEGCC__)
460 HAVE_WINBER_H shall not be defined.
463 BerElement *bep = ber_init(bvp);
468 ac_cv_header_winber_h="yes"
470 ac_cv_header_winber_h="no"
473 case "$ac_cv_header_winber_h" in
475 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
476 [Define to 1 if you have the winber.h header file.])
482 dnl CURL_CHECK_HEADER_LBER
483 dnl -------------------------------------------------
484 dnl Check for compilable and valid lber.h header,
485 dnl and check if it is needed even with ldap.h
487 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
488 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
489 AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
493 #ifdef HAVE_WINDOWS_H
494 #ifndef WIN32_LEAN_AND_MEAN
495 #define WIN32_LEAN_AND_MEAN
499 #ifdef HAVE_SYS_TYPES_H
500 #include <sys/types.h>
504 #define NULL (void *)0
508 BerValue *bvp = NULL;
509 BerElement *bep = ber_init(bvp);
513 ac_cv_header_lber_h="yes"
515 ac_cv_header_lber_h="no"
518 if test "$ac_cv_header_lber_h" = "yes"; then
519 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
520 [Define to 1 if you have the lber.h header file.])
525 #ifdef HAVE_WINDOWS_H
526 #ifndef WIN32_LEAN_AND_MEAN
527 #define WIN32_LEAN_AND_MEAN
531 #ifdef HAVE_SYS_TYPES_H
532 #include <sys/types.h>
536 #define NULL (void *)0
538 #ifndef LDAP_DEPRECATED
539 #define LDAP_DEPRECATED 1
543 BerValue *bvp = NULL;
544 BerElement *bep = ber_init(bvp);
548 curl_cv_need_header_lber_h="no"
550 curl_cv_need_header_lber_h="yes"
553 case "$curl_cv_need_header_lber_h" in
555 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
556 [Define to 1 if you need the lber.h header file even with ldap.h])
563 dnl CURL_CHECK_HEADER_LDAP
564 dnl -------------------------------------------------
565 dnl Check for compilable and valid ldap.h header
567 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
568 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
569 AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
573 #ifdef HAVE_WINDOWS_H
574 #ifndef WIN32_LEAN_AND_MEAN
575 #define WIN32_LEAN_AND_MEAN
579 #ifdef HAVE_SYS_TYPES_H
580 #include <sys/types.h>
583 #ifndef LDAP_DEPRECATED
584 #define LDAP_DEPRECATED 1
591 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
592 int res = ldap_unbind(ldp);
595 ac_cv_header_ldap_h="yes"
597 ac_cv_header_ldap_h="no"
600 case "$ac_cv_header_ldap_h" in
602 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
603 [Define to 1 if you have the ldap.h header file.])
609 dnl CURL_CHECK_HEADER_LDAP_SSL
610 dnl -------------------------------------------------
611 dnl Check for compilable and valid ldap_ssl.h header
613 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
614 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
615 AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
619 #ifdef HAVE_WINDOWS_H
620 #ifndef WIN32_LEAN_AND_MEAN
621 #define WIN32_LEAN_AND_MEAN
625 #ifdef HAVE_SYS_TYPES_H
626 #include <sys/types.h>
629 #ifndef LDAP_DEPRECATED
630 #define LDAP_DEPRECATED 1
638 #include <ldap_ssl.h>
640 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
643 ac_cv_header_ldap_ssl_h="yes"
645 ac_cv_header_ldap_ssl_h="no"
648 case "$ac_cv_header_ldap_ssl_h" in
650 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
651 [Define to 1 if you have the ldap_ssl.h header file.])
657 dnl CURL_CHECK_HEADER_LDAPSSL
658 dnl -------------------------------------------------
659 dnl Check for compilable and valid ldapssl.h header
661 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
662 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
663 AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
667 #ifdef HAVE_WINDOWS_H
668 #ifndef WIN32_LEAN_AND_MEAN
669 #define WIN32_LEAN_AND_MEAN
673 #ifdef HAVE_SYS_TYPES_H
674 #include <sys/types.h>
678 #define NULL (void *)0
680 #ifndef LDAP_DEPRECATED
681 #define LDAP_DEPRECATED 1
691 char *cert_label = NULL;
692 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
695 ac_cv_header_ldapssl_h="yes"
697 ac_cv_header_ldapssl_h="no"
700 case "$ac_cv_header_ldapssl_h" in
702 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
703 [Define to 1 if you have the ldapssl.h header file.])
709 dnl CURL_CHECK_LIBS_WINLDAP
710 dnl -------------------------------------------------
711 dnl Check for libraries needed for WINLDAP support,
712 dnl and prepended to LIBS any needed libraries.
713 dnl This macro can take an optional parameter with a
714 dnl white space separated list of libraries to check
715 dnl before the WINLDAP default ones.
717 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
718 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
720 AC_MSG_CHECKING([for WINLDAP libraries])
734 if test -z "$u_libs"; then
737 u_libs="$u_libs $l_lib"
742 curl_cv_save_LIBS="$LIBS"
743 curl_cv_ldap_LIBS="unknown"
745 for x_nlibs in '' "$u_libs" \
747 if test "$curl_cv_ldap_LIBS" = "unknown"; then
748 if test -z "$x_nlibs"; then
749 LIBS="$curl_cv_save_LIBS"
751 LIBS="$x_nlibs $curl_cv_save_LIBS"
756 #ifdef HAVE_WINDOWS_H
757 #ifndef WIN32_LEAN_AND_MEAN
758 #define WIN32_LEAN_AND_MEAN
761 #ifdef HAVE_WINLDAP_H
770 BerElement *bep = ber_init(bvp);
771 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
772 ULONG res = ldap_unbind(ldp);
776 curl_cv_ldap_LIBS="$x_nlibs"
781 LIBS="$curl_cv_save_LIBS"
783 case X-"$curl_cv_ldap_LIBS" in
785 AC_MSG_RESULT([cannot find WINLDAP libraries])
788 AC_MSG_RESULT([no additional lib required])
791 if test -z "$curl_cv_save_LIBS"; then
792 LIBS="$curl_cv_ldap_LIBS"
794 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
796 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
803 dnl CURL_CHECK_LIBS_LDAP
804 dnl -------------------------------------------------
805 dnl Check for libraries needed for LDAP support,
806 dnl and prepended to LIBS any needed libraries.
807 dnl This macro can take an optional parameter with a
808 dnl white space separated list of libraries to check
809 dnl before the default ones.
811 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
812 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
814 AC_MSG_CHECKING([for LDAP libraries])
828 if test -z "$u_libs"; then
831 u_libs="$u_libs $l_lib"
836 curl_cv_save_LIBS="$LIBS"
837 curl_cv_ldap_LIBS="unknown"
839 for x_nlibs in '' "$u_libs" \
843 '-lldapssl -lldapx -lldapsdk' \
844 '-lldapsdk -lldapx -lldapssl' ; do
845 if test "$curl_cv_ldap_LIBS" = "unknown"; then
846 if test -z "$x_nlibs"; then
847 LIBS="$curl_cv_save_LIBS"
849 LIBS="$x_nlibs $curl_cv_save_LIBS"
854 #ifdef HAVE_WINDOWS_H
855 #ifndef WIN32_LEAN_AND_MEAN
856 #define WIN32_LEAN_AND_MEAN
860 #ifdef HAVE_SYS_TYPES_H
861 #include <sys/types.h>
865 #define NULL (void *)0
867 #ifndef LDAP_DEPRECATED
868 #define LDAP_DEPRECATED 1
877 BerValue *bvp = NULL;
878 BerElement *bep = ber_init(bvp);
879 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
880 int res = ldap_unbind(ldp);
884 curl_cv_ldap_LIBS="$x_nlibs"
889 LIBS="$curl_cv_save_LIBS"
891 case X-"$curl_cv_ldap_LIBS" in
893 AC_MSG_RESULT([cannot find LDAP libraries])
896 AC_MSG_RESULT([no additional lib required])
899 if test -z "$curl_cv_save_LIBS"; then
900 LIBS="$curl_cv_ldap_LIBS"
902 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
904 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
911 dnl CURL_CHECK_HEADER_MALLOC
912 dnl -------------------------------------------------
913 dnl Check for compilable and valid malloc.h header,
914 dnl and check if it is needed even with stdlib.h
916 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
917 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
922 void *p = malloc(10);
923 void *q = calloc(10,10);
928 ac_cv_header_malloc_h="yes"
930 ac_cv_header_malloc_h="no"
933 if test "$ac_cv_header_malloc_h" = "yes"; then
934 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
935 [Define to 1 if you have the malloc.h header file.])
941 void *p = malloc(10);
942 void *q = calloc(10,10);
947 curl_cv_need_header_malloc_h="no"
949 curl_cv_need_header_malloc_h="yes"
952 case "$curl_cv_need_header_malloc_h" in
954 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
955 [Define to 1 if you need the malloc.h header file even with stdlib.h])
962 dnl CURL_CHECK_HEADER_MEMORY
963 dnl -------------------------------------------------
964 dnl Check for compilable and valid memory.h header,
965 dnl and check if it is needed even with stdlib.h for
966 dnl memory related functions.
968 AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
969 AC_CACHE_CHECK([for memory.h], [ac_cv_header_memory_h], [
974 void *p = malloc(10);
975 void *q = calloc(10,10);
980 ac_cv_header_memory_h="yes"
982 ac_cv_header_memory_h="no"
985 if test "$ac_cv_header_memory_h" = "yes"; then
986 AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
987 [Define to 1 if you have the memory.h header file.])
993 void *p = malloc(10);
994 void *q = calloc(10,10);
999 curl_cv_need_header_memory_h="no"
1001 curl_cv_need_header_memory_h="yes"
1004 case "$curl_cv_need_header_memory_h" in
1006 AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
1007 [Define to 1 if you need the memory.h header file even with stdlib.h])
1014 dnl CURL_CHECK_FUNC_GETNAMEINFO
1015 dnl -------------------------------------------------
1016 dnl Test if the getnameinfo function is available,
1017 dnl and check the types of five of its arguments.
1018 dnl If the function succeeds HAVE_GETNAMEINFO will be
1019 dnl defined, defining the types of the arguments in
1020 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
1021 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
1022 dnl and also defining the type qualifier of first
1023 dnl argument in GETNAMEINFO_QUAL_ARG1.
1025 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
1026 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
1027 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
1029 AC_MSG_CHECKING([for getnameinfo])
1031 AC_LANG_FUNC_LINK_TRY([getnameinfo])
1033 AC_MSG_RESULT([yes])
1034 curl_cv_getnameinfo="yes"
1037 curl_cv_getnameinfo="no"
1040 if test "$curl_cv_getnameinfo" != "yes"; then
1041 AC_MSG_CHECKING([deeper for getnameinfo])
1048 AC_MSG_RESULT([yes])
1049 curl_cv_getnameinfo="yes"
1051 AC_MSG_RESULT([but still no])
1052 curl_cv_getnameinfo="no"
1056 if test "$curl_cv_getnameinfo" != "yes"; then
1057 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
1061 #ifdef HAVE_WINDOWS_H
1062 #ifndef WIN32_LEAN_AND_MEAN
1063 #define WIN32_LEAN_AND_MEAN
1065 #include <windows.h>
1066 #ifdef HAVE_WINSOCK2_H
1067 #include <winsock2.h>
1068 #ifdef HAVE_WS2TCPIP_H
1069 #include <ws2tcpip.h>
1073 #ifdef HAVE_SYS_TYPES_H
1074 #include <sys/types.h>
1076 #ifdef HAVE_SYS_SOCKET_H
1077 #include <sys/socket.h>
1084 getnameinfo(0, 0, 0, 0, 0, 0, 0);
1087 AC_MSG_RESULT([yes])
1088 curl_cv_getnameinfo="yes"
1090 AC_MSG_RESULT([but still no])
1091 curl_cv_getnameinfo="no"
1095 if test "$curl_cv_getnameinfo" = "yes"; then
1096 AC_CACHE_CHECK([types of arguments for getnameinfo],
1097 [curl_cv_func_getnameinfo_args], [
1098 curl_cv_func_getnameinfo_args="unknown"
1099 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
1100 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
1101 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
1102 for gni_arg7 in 'int' 'unsigned int'; do
1103 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1107 #ifdef HAVE_WINDOWS_H
1108 #ifndef WIN32_LEAN_AND_MEAN
1109 #define WIN32_LEAN_AND_MEAN
1111 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
1113 #define _WIN32_WINNT 0x0501
1115 #include <windows.h>
1116 #ifdef HAVE_WINSOCK2_H
1117 #include <winsock2.h>
1118 #ifdef HAVE_WS2TCPIP_H
1119 #include <ws2tcpip.h>
1122 #define GNICALLCONV WSAAPI
1124 #ifdef HAVE_SYS_TYPES_H
1125 #include <sys/types.h>
1127 #ifdef HAVE_SYS_SOCKET_H
1128 #include <sys/socket.h>
1135 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
1141 $gni_arg46 hostlen=0;
1142 $gni_arg46 servlen=0;
1144 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
1147 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
1155 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1156 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
1157 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1159 gni_prev_IFS=$IFS; IFS=','
1160 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1164 gni_qual_type_arg1=$[1]
1166 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1167 [Define to the type of arg 2 for getnameinfo.])
1168 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1169 [Define to the type of args 4 and 6 for getnameinfo.])
1170 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1171 [Define to the type of arg 7 for getnameinfo.])
1175 case $prev_sh_opts in
1183 case "$gni_qual_type_arg1" in
1186 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1190 gni_type_arg1=$gni_qual_type_arg1
1194 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1195 [Define to the type qualifier of arg 1 for getnameinfo.])
1196 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1197 [Define to the type of arg 1 for getnameinfo.])
1199 case $prev_sh_opts in
1207 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1208 [Define to 1 if you have the getnameinfo function.])
1209 ac_cv_func_getnameinfo="yes"
1215 dnl TYPE_SOCKADDR_STORAGE
1216 dnl -------------------------------------------------
1217 dnl Check for struct sockaddr_storage. Most IPv6-enabled
1218 dnl hosts have it, but AIX 4.3 is one known exception.
1220 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1222 AC_CHECK_TYPE([struct sockaddr_storage],
1223 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1224 [if struct sockaddr_storage is defined]), ,
1227 #ifdef HAVE_WINDOWS_H
1228 #ifndef WIN32_LEAN_AND_MEAN
1229 #define WIN32_LEAN_AND_MEAN
1231 #include <windows.h>
1232 #ifdef HAVE_WINSOCK2_H
1233 #include <winsock2.h>
1236 #ifdef HAVE_SYS_TYPES_H
1237 #include <sys/types.h>
1239 #ifdef HAVE_SYS_SOCKET_H
1240 #include <sys/socket.h>
1242 #ifdef HAVE_NETINET_IN_H
1243 #include <netinet/in.h>
1245 #ifdef HAVE_ARPA_INET_H
1246 #include <arpa/inet.h>
1253 dnl CURL_CHECK_NI_WITHSCOPEID
1254 dnl -------------------------------------------------
1255 dnl Check for working NI_WITHSCOPEID in getnameinfo()
1257 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1258 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1259 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1260 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1261 netdb.h netinet/in.h arpa/inet.h)
1263 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
1264 [ac_cv_working_ni_withscopeid], [
1267 #ifdef HAVE_STDLIB_H
1273 #ifdef HAVE_SYS_TYPES_H
1274 #include <sys/types.h>
1276 #ifdef HAVE_SYS_SOCKET_H
1277 #include <sys/socket.h>
1282 #ifdef HAVE_NETINET_IN_H
1283 #include <netinet/in.h>
1285 #ifdef HAVE_ARPA_INET_H
1286 #include <arpa/inet.h>
1289 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1290 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1291 struct sockaddr_storage sa;
1293 unsigned char sa[256];
1295 char hostbuf[NI_MAXHOST];
1297 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1298 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1299 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1300 int fd = socket(AF_INET6, SOCK_STREAM, 0);
1303 return 1; /* Error creating socket */
1305 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1307 perror("getsockname()");
1308 return 2; /* Error retrieving socket name */
1310 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1312 printf("rc = %s\n", gai_strerror(rc));
1313 return 3; /* Error translating socket address */
1315 return 0; /* Ok, NI_WITHSCOPEID works */
1317 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1319 ]]) # AC-LANG-PROGRAM
1321 # Exit code == 0. Program worked.
1322 ac_cv_working_ni_withscopeid="yes"
1324 # Exit code != 0. Program failed.
1325 ac_cv_working_ni_withscopeid="no"
1327 # Program is not run when cross-compiling. So we assume
1328 # NI_WITHSCOPEID will work if we are able to compile it.
1331 #include <sys/types.h>
1332 #include <sys/socket.h>
1335 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1338 ac_cv_working_ni_withscopeid="yes"
1340 ac_cv_working_ni_withscopeid="no"
1341 ]) # AC-COMPILE-IFELSE
1344 case "$ac_cv_working_ni_withscopeid" in
1346 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1347 [Define to 1 if NI_WITHSCOPEID exists and works.])
1353 dnl CURL_CHECK_FUNC_RECV
1354 dnl -------------------------------------------------
1355 dnl Test if the socket recv() function is available,
1356 dnl and check its return type and the types of its
1357 dnl arguments. If the function succeeds HAVE_RECV
1358 dnl will be defined, defining the types of the arguments
1359 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1360 dnl and RECV_TYPE_ARG4, defining the type of the function
1361 dnl return value in RECV_TYPE_RETV.
1363 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1364 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1365 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1366 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1368 AC_MSG_CHECKING([for recv])
1372 #ifdef HAVE_WINDOWS_H
1373 #ifndef WIN32_LEAN_AND_MEAN
1374 #define WIN32_LEAN_AND_MEAN
1376 #include <windows.h>
1377 #ifdef HAVE_WINSOCK2_H
1378 #include <winsock2.h>
1380 #ifdef HAVE_WINSOCK_H
1381 #include <winsock.h>
1385 #ifdef HAVE_SYS_TYPES_H
1386 #include <sys/types.h>
1388 #ifdef HAVE_SYS_SOCKET_H
1389 #include <sys/socket.h>
1396 AC_MSG_RESULT([yes])
1403 if test "$curl_cv_recv" = "yes"; then
1404 AC_CACHE_CHECK([types of args and return type for recv],
1405 [curl_cv_func_recv_args], [
1406 curl_cv_func_recv_args="unknown"
1407 for recv_retv in 'int' 'ssize_t'; do
1408 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1409 for recv_arg2 in 'char *' 'void *'; do
1410 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1411 for recv_arg4 in 'int' 'unsigned int'; do
1412 if test "$curl_cv_func_recv_args" = "unknown"; then
1416 #ifdef HAVE_WINDOWS_H
1417 #ifndef WIN32_LEAN_AND_MEAN
1418 #define WIN32_LEAN_AND_MEAN
1420 #include <windows.h>
1421 #ifdef HAVE_WINSOCK2_H
1422 #include <winsock2.h>
1424 #ifdef HAVE_WINSOCK_H
1425 #include <winsock.h>
1428 #define RECVCALLCONV PASCAL
1430 #ifdef HAVE_SYS_TYPES_H
1431 #include <sys/types.h>
1433 #ifdef HAVE_SYS_SOCKET_H
1434 #include <sys/socket.h>
1436 #define RECVCALLCONV
1438 extern $recv_retv RECVCALLCONV
1439 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1445 $recv_retv res = recv(s, buf, len, flags);
1448 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1457 if test "$curl_cv_func_recv_args" = "unknown"; then
1458 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1460 recv_prev_IFS=$IFS; IFS=','
1461 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1465 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1466 [Define to the type of arg 1 for recv.])
1467 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1468 [Define to the type of arg 2 for recv.])
1469 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1470 [Define to the type of arg 3 for recv.])
1471 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1472 [Define to the type of arg 4 for recv.])
1473 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1474 [Define to the function return type for recv.])
1476 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1477 [Define to 1 if you have the recv function.])
1478 ac_cv_func_recv="yes"
1481 AC_MSG_ERROR([Unable to link function recv])
1486 dnl CURL_CHECK_FUNC_SEND
1487 dnl -------------------------------------------------
1488 dnl Test if the socket send() function is available,
1489 dnl and check its return type and the types of its
1490 dnl arguments. If the function succeeds HAVE_SEND
1491 dnl will be defined, defining the types of the arguments
1492 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1493 dnl and SEND_TYPE_ARG4, defining the type of the function
1494 dnl return value in SEND_TYPE_RETV, and also defining the
1495 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1497 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1498 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1499 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1500 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1502 AC_MSG_CHECKING([for send])
1506 #ifdef HAVE_WINDOWS_H
1507 #ifndef WIN32_LEAN_AND_MEAN
1508 #define WIN32_LEAN_AND_MEAN
1510 #include <windows.h>
1511 #ifdef HAVE_WINSOCK2_H
1512 #include <winsock2.h>
1514 #ifdef HAVE_WINSOCK_H
1515 #include <winsock.h>
1519 #ifdef HAVE_SYS_TYPES_H
1520 #include <sys/types.h>
1522 #ifdef HAVE_SYS_SOCKET_H
1523 #include <sys/socket.h>
1530 AC_MSG_RESULT([yes])
1537 if test "$curl_cv_send" = "yes"; then
1538 AC_CACHE_CHECK([types of args and return type for send],
1539 [curl_cv_func_send_args], [
1540 curl_cv_func_send_args="unknown"
1541 for send_retv in 'int' 'ssize_t'; do
1542 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1543 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1544 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1545 for send_arg4 in 'int' 'unsigned int'; do
1546 if test "$curl_cv_func_send_args" = "unknown"; then
1550 #ifdef HAVE_WINDOWS_H
1551 #ifndef WIN32_LEAN_AND_MEAN
1552 #define WIN32_LEAN_AND_MEAN
1554 #include <windows.h>
1555 #ifdef HAVE_WINSOCK2_H
1556 #include <winsock2.h>
1558 #ifdef HAVE_WINSOCK_H
1559 #include <winsock.h>
1562 #define SENDCALLCONV PASCAL
1564 #ifdef HAVE_SYS_TYPES_H
1565 #include <sys/types.h>
1567 #ifdef HAVE_SYS_SOCKET_H
1568 #include <sys/socket.h>
1570 #define SENDCALLCONV
1572 extern $send_retv SENDCALLCONV
1573 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1578 $send_retv res = send(s, 0, len, flags);
1581 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1590 if test "$curl_cv_func_send_args" = "unknown"; then
1591 AC_MSG_ERROR([Cannot find proper types to use for send args])
1593 send_prev_IFS=$IFS; IFS=','
1594 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1598 send_qual_type_arg2=$[2]
1600 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1601 [Define to the type of arg 1 for send.])
1602 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1603 [Define to the type of arg 3 for send.])
1604 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1605 [Define to the type of arg 4 for send.])
1606 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1607 [Define to the function return type for send.])
1611 case $prev_sh_opts in
1619 case "$send_qual_type_arg2" in
1621 send_qual_arg2=const
1622 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1626 send_type_arg2=$send_qual_type_arg2
1630 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1631 [Define to the type qualifier of arg 2 for send.])
1632 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1633 [Define to the type of arg 2 for send.])
1635 case $prev_sh_opts in
1643 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1644 [Define to 1 if you have the send function.])
1645 ac_cv_func_send="yes"
1648 AC_MSG_ERROR([Unable to link function send])
1653 dnl CURL_CHECK_FUNC_RECVFROM
1654 dnl -------------------------------------------------
1655 dnl Test if the socket recvfrom() function is available,
1656 dnl and check its return type and the types of its
1657 dnl arguments. If the function succeeds HAVE_RECVFROM
1658 dnl will be defined, defining the types of the arguments
1659 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1660 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1661 dnl function return value in RECVFROM_TYPE_RETV.
1662 dnl Notice that the types returned for pointer arguments
1663 dnl will actually be the type pointed by the pointer.
1665 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1666 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1667 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1668 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1670 AC_MSG_CHECKING([for recvfrom])
1674 #ifdef HAVE_WINDOWS_H
1675 #ifndef WIN32_LEAN_AND_MEAN
1676 #define WIN32_LEAN_AND_MEAN
1678 #include <windows.h>
1679 #ifdef HAVE_WINSOCK2_H
1680 #include <winsock2.h>
1682 #ifdef HAVE_WINSOCK_H
1683 #include <winsock.h>
1687 #ifdef HAVE_SYS_TYPES_H
1688 #include <sys/types.h>
1690 #ifdef HAVE_SYS_SOCKET_H
1691 #include <sys/socket.h>
1695 recvfrom(0, 0, 0, 0, 0, 0);
1698 AC_MSG_RESULT([yes])
1699 curl_cv_recvfrom="yes"
1702 curl_cv_recvfrom="no"
1705 if test "$curl_cv_recvfrom" = "yes"; then
1706 AC_CACHE_CHECK([types of args and return type for recvfrom],
1707 [curl_cv_func_recvfrom_args], [
1708 curl_cv_func_recvfrom_args="unknown"
1709 for recvfrom_retv in 'int' 'ssize_t'; do
1710 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1711 for recvfrom_arg2 in 'char *' 'void *'; do
1712 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1713 for recvfrom_arg4 in 'int' 'unsigned int'; do
1714 for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
1715 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1716 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1720 #ifdef HAVE_WINDOWS_H
1721 #ifndef WIN32_LEAN_AND_MEAN
1722 #define WIN32_LEAN_AND_MEAN
1724 #include <windows.h>
1725 #ifdef HAVE_WINSOCK2_H
1726 #include <winsock2.h>
1728 #ifdef HAVE_WINSOCK_H
1729 #include <winsock.h>
1732 #define RECVFROMCALLCONV PASCAL
1734 #ifdef HAVE_SYS_TYPES_H
1735 #include <sys/types.h>
1737 #ifdef HAVE_SYS_SOCKET_H
1738 #include <sys/socket.h>
1740 #define RECVFROMCALLCONV
1742 extern $recvfrom_retv RECVFROMCALLCONV
1743 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1744 $recvfrom_arg3, $recvfrom_arg4,
1745 $recvfrom_arg5, $recvfrom_arg6);
1748 $recvfrom_arg2 buf=0;
1749 $recvfrom_arg3 len=0;
1750 $recvfrom_arg4 flags=0;
1751 $recvfrom_arg5 addr=0;
1752 $recvfrom_arg6 addrlen=0;
1753 $recvfrom_retv res=0;
1754 res = recvfrom(s, buf, len, flags, addr, addrlen);
1757 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1768 # Nearly last minute change for this release starts here
1769 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1770 [Define to 1 if you have the recvfrom function.])
1771 ac_cv_func_recvfrom="yes"
1772 # Nearly last minute change for this release ends here
1773 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1774 AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
1776 recvfrom_prev_IFS=$IFS; IFS=','
1777 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1778 IFS=$recvfrom_prev_IFS
1781 recvfrom_ptrt_arg2=$[2]
1782 recvfrom_ptrt_arg5=$[5]
1783 recvfrom_ptrt_arg6=$[6]
1785 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1786 [Define to the type of arg 1 for recvfrom.])
1787 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1788 [Define to the type of arg 3 for recvfrom.])
1789 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1790 [Define to the type of arg 4 for recvfrom.])
1791 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1792 [Define to the function return type for recvfrom.])
1796 case $prev_sh_opts in
1804 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1805 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1806 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1808 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1809 [Define to the type pointed by arg 2 for recvfrom.])
1810 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1811 [Define to the type pointed by arg 5 for recvfrom.])
1812 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1813 [Define to the type pointed by arg 6 for recvfrom.])
1815 if test "$recvfrom_type_arg2" = "void"; then
1816 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1817 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1819 if test "$recvfrom_type_arg5" = "void"; then
1820 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1821 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1823 if test "$recvfrom_type_arg6" = "void"; then
1824 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1825 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1828 case $prev_sh_opts in
1836 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1837 [Define to 1 if you have the recvfrom function.])
1838 ac_cv_func_recvfrom="yes"
1841 AC_MSG_WARN([Unable to link function recvfrom])
1846 dnl CURL_CHECK_MSG_NOSIGNAL
1847 dnl -------------------------------------------------
1848 dnl Check for MSG_NOSIGNAL
1850 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1851 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1852 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1856 #ifdef HAVE_WINDOWS_H
1857 #ifndef WIN32_LEAN_AND_MEAN
1858 #define WIN32_LEAN_AND_MEAN
1860 #include <windows.h>
1861 #ifdef HAVE_WINSOCK2_H
1862 #include <winsock2.h>
1864 #ifdef HAVE_WINSOCK_H
1865 #include <winsock.h>
1869 #ifdef HAVE_SYS_TYPES_H
1870 #include <sys/types.h>
1872 #ifdef HAVE_SYS_SOCKET_H
1873 #include <sys/socket.h>
1877 int flag=MSG_NOSIGNAL;
1880 ac_cv_msg_nosignal="yes"
1882 ac_cv_msg_nosignal="no"
1885 case "$ac_cv_msg_nosignal" in
1887 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1888 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1894 dnl CURL_CHECK_STRUCT_TIMEVAL
1895 dnl -------------------------------------------------
1896 dnl Check for timeval struct
1898 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1899 AC_REQUIRE([AC_HEADER_TIME])dnl
1900 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1901 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1902 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1903 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1907 #ifdef HAVE_WINDOWS_H
1908 #ifndef WIN32_LEAN_AND_MEAN
1909 #define WIN32_LEAN_AND_MEAN
1911 #include <windows.h>
1912 #ifdef HAVE_WINSOCK2_H
1913 #include <winsock2.h>
1915 #ifdef HAVE_WINSOCK_H
1916 #include <winsock.h>
1920 #ifdef HAVE_SYS_TYPES_H
1921 #include <sys/types.h>
1923 #ifdef HAVE_SYS_TIME_H
1924 #include <sys/time.h>
1925 #ifdef TIME_WITH_SYS_TIME
1939 ac_cv_struct_timeval="yes"
1941 ac_cv_struct_timeval="no"
1944 case "$ac_cv_struct_timeval" in
1946 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1947 [Define to 1 if you have the timeval struct.])
1953 dnl TYPE_SIG_ATOMIC_T
1954 dnl -------------------------------------------------
1955 dnl Check if the sig_atomic_t type is available, and
1956 dnl verify if it is already defined as volatile.
1958 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1959 AC_CHECK_HEADERS(signal.h)
1960 AC_CHECK_TYPE([sig_atomic_t],[
1961 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1962 [Define to 1 if sig_atomic_t is an available typedef.])
1964 #ifdef HAVE_SIGNAL_H
1968 case "$ac_cv_type_sig_atomic_t" in
1971 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1974 #ifdef HAVE_SIGNAL_H
1978 static volatile sig_atomic_t dummy = 0;
1982 ac_cv_sig_atomic_t_volatile="no"
1984 AC_MSG_RESULT([yes])
1985 ac_cv_sig_atomic_t_volatile="yes"
1988 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1989 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1990 [Define to 1 if sig_atomic_t is already defined as volatile.])
1998 dnl -------------------------------------------------
1999 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
2000 dnl and a few other things.
2002 AC_DEFUN([TYPE_IN_ADDR_T], [
2003 AC_CHECK_TYPE([in_addr_t], ,[
2004 dnl in_addr_t not available
2005 AC_CACHE_CHECK([for in_addr_t equivalent],
2006 [curl_cv_in_addr_t_equiv], [
2007 curl_cv_in_addr_t_equiv="unknown"
2008 for t in "unsigned long" int size_t unsigned long; do
2009 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
2013 #ifdef HAVE_WINDOWS_H
2014 #ifndef WIN32_LEAN_AND_MEAN
2015 #define WIN32_LEAN_AND_MEAN
2017 #include <windows.h>
2018 #ifdef HAVE_WINSOCK2_H
2019 #include <winsock2.h>
2021 #ifdef HAVE_WINSOCK_H
2022 #include <winsock.h>
2026 #ifdef HAVE_SYS_TYPES_H
2027 #include <sys/types.h>
2029 #ifdef HAVE_SYS_SOCKET_H
2030 #include <sys/socket.h>
2032 #ifdef HAVE_NETINET_IN_H
2033 #include <netinet/in.h>
2035 #ifdef HAVE_ARPA_INET_H
2036 #include <arpa/inet.h>
2040 $t data = inet_addr ("1.2.3.4");
2043 curl_cv_in_addr_t_equiv="$t"
2048 case "$curl_cv_in_addr_t_equiv" in
2050 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
2053 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
2054 [Type to use in place of in_addr_t when system does not provide it.])
2059 #ifdef HAVE_WINDOWS_H
2060 #ifndef WIN32_LEAN_AND_MEAN
2061 #define WIN32_LEAN_AND_MEAN
2063 #include <windows.h>
2064 #ifdef HAVE_WINSOCK2_H
2065 #include <winsock2.h>
2067 #ifdef HAVE_WINSOCK_H
2068 #include <winsock.h>
2072 #ifdef HAVE_SYS_TYPES_H
2073 #include <sys/types.h>
2075 #ifdef HAVE_SYS_SOCKET_H
2076 #include <sys/socket.h>
2078 #ifdef HAVE_NETINET_IN_H
2079 #include <netinet/in.h>
2081 #ifdef HAVE_ARPA_INET_H
2082 #include <arpa/inet.h>
2089 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
2090 dnl -------------------------------------------------
2091 dnl Check if monotonic clock_gettime is available.
2093 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
2094 AC_REQUIRE([AC_HEADER_TIME])dnl
2095 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
2096 AC_MSG_CHECKING([for monotonic clock_gettime])
2099 #ifdef HAVE_SYS_TYPES_H
2100 #include <sys/types.h>
2102 #ifdef HAVE_SYS_TIME_H
2103 #include <sys/time.h>
2104 #ifdef TIME_WITH_SYS_TIME
2114 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2117 AC_MSG_RESULT([yes])
2118 ac_cv_func_clock_gettime="yes"
2121 ac_cv_func_clock_gettime="no"
2123 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
2124 dnl until library linking and run-time checks for clock_gettime succeed.
2128 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
2129 dnl -------------------------------------------------
2130 dnl If monotonic clock_gettime is available then,
2131 dnl check and prepended to LIBS any needed libraries.
2133 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
2134 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
2136 if test "$ac_cv_func_clock_gettime" = "yes"; then
2138 AC_MSG_CHECKING([for clock_gettime in libraries])
2140 curl_cv_save_LIBS="$LIBS"
2141 curl_cv_gclk_LIBS="unknown"
2143 for x_xlibs in '' '-lrt' '-lposix4' ; do
2144 if test "$curl_cv_gclk_LIBS" = "unknown"; then
2145 if test -z "$x_xlibs"; then
2146 LIBS="$curl_cv_save_LIBS"
2148 LIBS="$x_xlibs $curl_cv_save_LIBS"
2152 #ifdef HAVE_SYS_TYPES_H
2153 #include <sys/types.h>
2155 #ifdef HAVE_SYS_TIME_H
2156 #include <sys/time.h>
2157 #ifdef TIME_WITH_SYS_TIME
2167 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2170 curl_cv_gclk_LIBS="$x_xlibs"
2175 LIBS="$curl_cv_save_LIBS"
2177 case X-"$curl_cv_gclk_LIBS" in
2179 AC_MSG_RESULT([cannot find clock_gettime])
2180 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2181 ac_cv_func_clock_gettime="no"
2184 AC_MSG_RESULT([no additional lib required])
2185 ac_cv_func_clock_gettime="yes"
2188 if test -z "$curl_cv_save_LIBS"; then
2189 LIBS="$curl_cv_gclk_LIBS"
2191 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
2193 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
2194 ac_cv_func_clock_gettime="yes"
2198 dnl only do runtime verification when not cross-compiling
2199 if test "x$cross_compiling" != "xyes" &&
2200 test "$ac_cv_func_clock_gettime" = "yes"; then
2201 AC_MSG_CHECKING([if monotonic clock_gettime works])
2204 #ifdef HAVE_STDLIB_H
2207 #ifdef HAVE_SYS_TYPES_H
2208 #include <sys/types.h>
2210 #ifdef HAVE_SYS_TIME_H
2211 #include <sys/time.h>
2212 #ifdef TIME_WITH_SYS_TIME
2222 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
2228 AC_MSG_RESULT([yes])
2231 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2232 ac_cv_func_clock_gettime="no"
2233 LIBS="$curl_cv_save_LIBS"
2237 case "$ac_cv_func_clock_gettime" in
2239 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
2240 [Define to 1 if you have the clock_gettime function and monotonic timer.])
2249 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
2250 dnl -------------------------------------------------
2251 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
2252 dnl symbol that can be further used in custom template configuration
2253 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
2254 dnl argument for the description. Symbol definitions done with this
2255 dnl macro are intended to be exclusively used in handcrafted *.h.in
2256 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
2257 dnl prevents autoheader generation and insertion of symbol template
2258 dnl stub and definition into the first configuration header file. Do
2259 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
2260 dnl one serves different functional needs.
2262 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
2263 cat >>confdefs.h <<_EOF
2264 [@%:@define] $1 ifelse($#, 2, [$2], 1)
2269 dnl CURL_CONFIGURE_LONG
2270 dnl -------------------------------------------------
2271 dnl Find out the size of long as reported by sizeof() and define
2272 dnl CURL_SIZEOF_LONG as appropriate to be used in template file
2273 dnl include/curl/curlbuild.h.in to properly configure the library.
2274 dnl The size of long is a build time characteristic and as such
2275 dnl must be recorded in curlbuild.h
2277 AC_DEFUN([CURL_CONFIGURE_LONG], [
2278 if test -z "$ac_cv_sizeof_long" ||
2279 test "$ac_cv_sizeof_long" -eq "0"; then
2280 AC_MSG_ERROR([cannot find out size of long.])
2282 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
2286 dnl CURL_CONFIGURE_CURL_SOCKLEN_T
2287 dnl -------------------------------------------------
2288 dnl Find out suitable curl_socklen_t data type definition and size, making
2289 dnl appropriate definitions for template file include/curl/curlbuild.h.in
2290 dnl to properly configure and use the library.
2292 dnl The need for the curl_socklen_t definition arises mainly to properly
2293 dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
2294 dnl data type which is 32 or 64-Bit wide depending on the data model being
2295 dnl used, and that on the other hand is only actually used when interfacing
2296 dnl the X/Open sockets provided in the xnet library.
2298 AC_DEFUN([CURL_CONFIGURE_CURL_SOCKLEN_T], [
2299 AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
2300 AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
2301 AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
2303 AC_MSG_CHECKING([for curl_socklen_t data type])
2304 curl_typeof_curl_socklen_t="unknown"
2305 for arg1 in int SOCKET; do
2306 for arg2 in 'struct sockaddr' void; do
2307 for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
2308 if test "$curl_typeof_curl_socklen_t" = "unknown"; then
2311 $curl_includes_ws2tcpip
2312 $curl_includes_sys_socket
2313 $curl_preprocess_callconv
2314 extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
2317 if(0 != getpeername(0, 0, lenptr))
2321 curl_typeof_curl_socklen_t="$t"
2327 for t in socklen_t int; do
2328 if test "$curl_typeof_curl_socklen_t" = "void"; then
2331 $curl_includes_sys_socket
2332 typedef $t curl_socklen_t;
2334 curl_socklen_t dummy;
2337 curl_typeof_curl_socklen_t="$t"
2341 AC_MSG_RESULT([$curl_typeof_curl_socklen_t])
2342 if test "$curl_typeof_curl_socklen_t" = "void" ||
2343 test "$curl_typeof_curl_socklen_t" = "unknown"; then
2344 AC_MSG_ERROR([cannot find data type for curl_socklen_t.])
2347 AC_MSG_CHECKING([size of curl_socklen_t])
2348 curl_sizeof_curl_socklen_t="unknown"
2349 curl_pull_headers_socklen_t="unknown"
2350 if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
2351 tst_pull_header_checks='none ws2tcpip'
2354 tst_pull_header_checks='none systypes syssocket'
2355 tst_size_checks='4 8 2'
2357 for tst_size in $tst_size_checks; do
2358 for tst_pull_headers in $tst_pull_header_checks; do
2359 if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
2360 case $tst_pull_headers in
2362 tmp_includes="$curl_includes_ws2tcpip"
2365 tmp_includes="$curl_includes_sys_types"
2368 tmp_includes="$curl_includes_sys_socket"
2377 typedef $curl_typeof_curl_socklen_t curl_socklen_t;
2378 typedef char dummy_arr[sizeof(curl_socklen_t) == $tst_size ? 1 : -1];
2380 curl_socklen_t dummy;
2383 curl_sizeof_curl_socklen_t="$tst_size"
2384 curl_pull_headers_socklen_t="$tst_pull_headers"
2389 AC_MSG_RESULT([$curl_sizeof_curl_socklen_t])
2390 if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
2391 AC_MSG_ERROR([cannot find out size of curl_socklen_t.])
2394 case $curl_pull_headers_socklen_t in
2396 CURL_DEFINE_UNQUOTED([CURL_PULL_WS2TCPIP_H])
2399 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
2402 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
2403 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_SOCKET_H])
2406 CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_SOCKLEN_T], [$curl_typeof_curl_socklen_t])
2407 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_SOCKLEN_T], [$curl_sizeof_curl_socklen_t])
2411 dnl CURL_CHECK_FUNC_SELECT
2412 dnl -------------------------------------------------
2413 dnl Test if the socket select() function is available,
2414 dnl and check its return type and the types of its
2415 dnl arguments. If the function succeeds HAVE_SELECT
2416 dnl will be defined, defining the types of the
2417 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
2418 dnl and SELECT_TYPE_ARG5, defining the type of the
2419 dnl function return value in SELECT_TYPE_RETV, and
2420 dnl also defining the type qualifier of fifth argument
2421 dnl in SELECT_QUAL_ARG5.
2423 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
2424 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
2425 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
2427 AC_MSG_CHECKING([for select])
2431 #ifdef HAVE_WINDOWS_H
2432 #ifndef WIN32_LEAN_AND_MEAN
2433 #define WIN32_LEAN_AND_MEAN
2435 #include <windows.h>
2436 #ifdef HAVE_WINSOCK2_H
2437 #include <winsock2.h>
2439 #ifdef HAVE_WINSOCK_H
2440 #include <winsock.h>
2444 #ifdef HAVE_SYS_TYPES_H
2445 #include <sys/types.h>
2447 #ifdef HAVE_SYS_TIME_H
2448 #include <sys/time.h>
2449 #ifdef TIME_WITH_SYS_TIME
2457 #ifndef HAVE_WINDOWS_H
2458 #ifdef HAVE_SYS_SELECT_H
2459 #include <sys/select.h>
2461 #ifdef HAVE_SYS_SOCKET_H
2462 #include <sys/socket.h>
2466 select(0, 0, 0, 0, 0);
2469 AC_MSG_RESULT([yes])
2470 curl_cv_select="yes"
2476 if test "$curl_cv_select" = "yes"; then
2477 AC_CACHE_CHECK([types of args and return type for select],
2478 [curl_cv_func_select_args], [
2479 curl_cv_func_select_args="unknown"
2480 for sel_retv in 'int' 'ssize_t'; do
2481 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2482 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2483 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2484 if test "$curl_cv_func_select_args" = "unknown"; then
2488 #ifdef HAVE_WINDOWS_H
2489 #ifndef WIN32_LEAN_AND_MEAN
2490 #define WIN32_LEAN_AND_MEAN
2492 #include <windows.h>
2493 #ifdef HAVE_WINSOCK2_H
2494 #include <winsock2.h>
2496 #ifdef HAVE_WINSOCK_H
2497 #include <winsock.h>
2500 #define SELECTCALLCONV PASCAL
2502 #ifdef HAVE_SYS_TYPES_H
2503 #include <sys/types.h>
2505 #ifdef HAVE_SYS_TIME_H
2506 #include <sys/time.h>
2507 #ifdef TIME_WITH_SYS_TIME
2515 #ifndef HAVE_WINDOWS_H
2516 #ifdef HAVE_SYS_SELECT_H
2517 #include <sys/select.h>
2519 #ifdef HAVE_SYS_SOCKET_H
2520 #include <sys/socket.h>
2522 #define SELECTCALLCONV
2524 #ifndef HAVE_STRUCT_TIMEVAL
2530 extern $sel_retv SELECTCALLCONV select($sel_arg1,
2540 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2543 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2551 if test "$curl_cv_func_select_args" = "unknown"; then
2552 AC_MSG_WARN([Cannot find proper types to use for select args])
2553 AC_MSG_WARN([HAVE_SELECT will not be defined])
2555 select_prev_IFS=$IFS; IFS=','
2556 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2557 IFS=$select_prev_IFS
2560 sel_qual_type_arg5=$[3]
2562 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2563 [Define to the type of arg 1 for select.])
2564 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2565 [Define to the type of args 2, 3 and 4 for select.])
2566 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2567 [Define to the function return type for select.])
2571 case $prev_sh_opts in
2579 case "$sel_qual_type_arg5" in
2582 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2586 sel_type_arg5=$sel_qual_type_arg5
2590 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2591 [Define to the type qualifier of arg 5 for select.])
2592 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2593 [Define to the type of arg 5 for select.])
2595 case $prev_sh_opts in
2603 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2604 [Define to 1 if you have the select function.])
2605 ac_cv_func_select="yes"
2611 # This is only a temporary fix. This macro is here to replace the broken one
2612 # delivered by the automake project (including the 1.9.6 release). As soon as
2613 # they ship a working version we SHOULD remove this work-around.
2615 AC_DEFUN([AM_MISSING_HAS_RUN],
2616 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2617 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
2618 # Use eval to expand $SHELL
2619 if eval "$MISSING --run true"; then
2620 am_missing_run="$MISSING --run "
2623 AC_MSG_WARN([`missing' script is too old or missing])
2628 dnl CURL_VERIFY_RUNTIMELIBS
2629 dnl -------------------------------------------------
2630 dnl Verify that the shared libs found so far can be used when running
2631 dnl programs, since otherwise the situation will create odd configure errors
2632 dnl that are misleading people.
2634 dnl Make sure this test is run BEFORE the first test in the script that
2635 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
2636 dnl macro. It must also run AFTER all lib-checking macros are complete.
2638 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
2640 dnl this test is of course not sensible if we are cross-compiling!
2641 if test "x$cross_compiling" != xyes; then
2643 dnl just run a program to verify that the libs checked for previous to this
2644 dnl point also is available run-time!
2645 AC_MSG_CHECKING([run-time libs availability])
2652 AC_MSG_RESULT([fine]),
2653 AC_MSG_RESULT([failed])
2654 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
2657 dnl if this test fails, configure has already stopped
2662 dnl CURL_CHECK_VARIADIC_MACROS
2663 dnl -------------------------------------------------
2664 dnl Check compiler support of variadic macros
2666 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
2667 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
2668 [curl_cv_variadic_macros_c99], [
2671 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
2672 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
2673 int fun3(int arg1, int arg2, int arg3);
2674 int fun2(int arg1, int arg2);
2675 int fun3(int arg1, int arg2, int arg3)
2676 { return arg1 + arg2 + arg3; }
2677 int fun2(int arg1, int arg2)
2678 { return arg1 + arg2; }
2680 int res3 = c99_vmacro3(1, 2, 3);
2681 int res2 = c99_vmacro2(1, 2);
2684 curl_cv_variadic_macros_c99="yes"
2686 curl_cv_variadic_macros_c99="no"
2689 case "$curl_cv_variadic_macros_c99" in
2691 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
2692 [Define to 1 if compiler supports C99 variadic macro style.])
2695 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
2696 [curl_cv_variadic_macros_gcc], [
2699 #define gcc_vmacro3(first, args...) fun3(first, args)
2700 #define gcc_vmacro2(first, args...) fun2(first, args)
2701 int fun3(int arg1, int arg2, int arg3);
2702 int fun2(int arg1, int arg2);
2703 int fun3(int arg1, int arg2, int arg3)
2704 { return arg1 + arg2 + arg3; }
2705 int fun2(int arg1, int arg2)
2706 { return arg1 + arg2; }
2708 int res3 = gcc_vmacro3(1, 2, 3);
2709 int res2 = gcc_vmacro2(1, 2);
2712 curl_cv_variadic_macros_gcc="yes"
2714 curl_cv_variadic_macros_gcc="no"
2717 case "$curl_cv_variadic_macros_gcc" in
2719 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2720 [Define to 1 if compiler supports old gcc variadic macro style.])
2726 dnl CURL_CHECK_CA_BUNDLE
2727 dnl -------------------------------------------------
2728 dnl Check if a default ca-bundle should be used
2730 dnl regarding the paths this will scan:
2731 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
2732 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
2733 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
2734 dnl /usr/local/share/certs/ca-root.crt FreeBSD
2735 dnl /etc/ssl/cert.pem OpenBSD
2736 dnl /etc/ssl/certs/ (ca path) SUSE
2738 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
2740 AC_MSG_CHECKING([default CA cert bundle/path])
2742 AC_ARG_WITH(ca-bundle,
2743 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
2744 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
2747 if test "x$want_ca" = "xyes"; then
2748 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
2751 [ want_ca="unset" ])
2752 AC_ARG_WITH(ca-path,
2753 AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
2754 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
2756 want_capath="$withval"
2757 if test "x$want_capath" = "xyes"; then
2758 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
2761 [ want_capath="unset"])
2763 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
2764 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2766 AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
2767 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
2768 dnl --with-ca-bundle given
2771 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2772 dnl --with-ca-path given
2773 if test "x$OPENSSL_ENABLED" != "x1"; then
2774 AC_MSG_ERROR([--with-ca-path only works with openSSL])
2776 capath="$want_capath"
2779 dnl neither of --with-ca-* given
2780 dnl first try autodetecting a CA bundle , then a CA path
2781 dnl both autodetections can be skipped by --without-ca-*
2784 if test "x$want_ca" = "xunset"; then
2785 dnl the path we previously would have installed the curl ca bundle
2786 dnl to, and thus we now check for an already existing cert in that place
2787 dnl in case we find no other
2788 if test "x$prefix" != xNONE; then
2789 cac="${prefix}/share/curl/curl-ca-bundle.crt"
2791 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
2794 for a in /etc/ssl/certs/ca-certificates.crt \
2795 /etc/pki/tls/certs/ca-bundle.crt \
2796 /usr/share/ssl/certs/ca-bundle.crt \
2797 /usr/local/share/certs/ca-root.crt \
2800 if test -f "$a"; then
2806 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
2807 "x$OPENSSL_ENABLED" = "x1"; then
2808 for a in /etc/ssl/certs/; do
2809 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
2819 if test "x$ca" != "xno"; then
2820 CURL_CA_BUNDLE='"'$ca'"'
2821 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
2822 AC_SUBST(CURL_CA_BUNDLE)
2823 AC_MSG_RESULT([$ca])
2824 elif test "x$capath" != "xno"; then
2825 CURL_CA_PATH="\"$capath\""
2826 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
2827 AC_MSG_RESULT([$capath (capath)])
2834 dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
2835 dnl -------------------------------------------------
2836 dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
2838 AC_DEFUN([DO_CURL_OFF_T_CHECK], [
2839 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2840 if test "$curl_typeof_curl_off_t" = "unknown" && test ! -z "$1"; then
2844 case AS_TR_SH([$1]) in
2846 tmp_includes="$curl_includes_inttypes"
2847 tmp_source="char f@<:@@:>@ = PRId64;"
2851 tmp_includes="$curl_includes_inttypes"
2852 tmp_source="char f@<:@@:>@ = PRId32;"
2856 tmp_includes="$curl_includes_inttypes"
2857 tmp_source="char f@<:@@:>@ = PRId16;"
2864 typedef $1 curl_off_t;
2865 typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
2871 if test -z "$tmp_fmt"; then
2872 curl_typeof_curl_off_t="$1"
2873 curl_sizeof_curl_off_t="$2"
2875 CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
2876 AS_VAR_PUSHDEF([tmp_HaveFmtDef], [curl_cv_have_def_$tmp_fmt])dnl
2877 AS_VAR_PUSHDEF([tmp_FmtDef], [curl_cv_def_$tmp_fmt])dnl
2878 if test AS_VAR_GET(tmp_HaveFmtDef) = "yes"; then
2879 curl_format_curl_off_t=AS_VAR_GET(tmp_FmtDef)
2880 curl_typeof_curl_off_t="$1"
2881 curl_sizeof_curl_off_t="$2"
2883 AS_VAR_POPDEF([tmp_FmtDef])dnl
2884 AS_VAR_POPDEF([tmp_HaveFmtDef])dnl
2891 dnl DO_CURL_OFF_T_SUFFIX_CHECK (TYPE)
2892 dnl -------------------------------------------------
2893 dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
2895 AC_DEFUN([DO_CURL_OFF_T_SUFFIX_CHECK], [
2896 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2897 AC_MSG_CHECKING([constant suffix string for curl_off_t])
2899 curl_suffix_curl_off_t="unknown"
2900 curl_suffix_curl_off_tu="unknown"
2902 case AS_TR_SH([$1]) in
2903 long_long | __longlong | __longlong_t)
2913 tst_suffixes="LL:i64::"
2916 tst_suffixes="L:i32::"
2919 tst_suffixes="L:i16::"
2922 AC_MSG_ERROR([unexpected data type $1])
2926 old_IFS=$IFS; IFS=':'
2927 for tmp_ssuf in $tst_suffixes ; do
2929 if test "x$curl_suffix_curl_off_t" = "xunknown"; then
2932 tmp_usuf="u$tmp_ssuf"
2935 tmp_usuf="U$tmp_ssuf"
2943 $curl_includes_inttypes
2954 curl_suffix_curl_off_t="$tmp_ssuf"
2955 curl_suffix_curl_off_tu="$tmp_usuf"
2961 if test "x$curl_suffix_curl_off_t" = "xunknown"; then
2962 AC_MSG_ERROR([cannot find constant suffix string for curl_off_t.])
2964 AC_MSG_RESULT([$curl_suffix_curl_off_t])
2965 AC_MSG_CHECKING([constant suffix string for unsigned curl_off_t])
2966 AC_MSG_RESULT([$curl_suffix_curl_off_tu])
2972 dnl CURL_CONFIGURE_CURL_OFF_T
2973 dnl -------------------------------------------------
2974 dnl Find out suitable curl_off_t data type definition and associated
2975 dnl items, and make the appropriate definitions used in template file
2976 dnl include/curl/curlbuild.h.in to properly configure the library.
2978 AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
2979 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2981 AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
2982 AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
2983 AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
2985 if test -z "$SED"; then
2986 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
2989 AC_CHECK_SIZEOF(long)
2990 AC_CHECK_SIZEOF(void*)
2992 if test -z "$ac_cv_sizeof_long" ||
2993 test "$ac_cv_sizeof_long" -eq "0"; then
2994 AC_MSG_ERROR([cannot find out size of long.])
2996 if test -z "$ac_cv_sizeof_voidp" ||
2997 test "$ac_cv_sizeof_voidp" -eq "0"; then
2998 AC_MSG_ERROR([cannot find out size of void*.])
3005 if test "$ac_cv_sizeof_long" -eq "8" &&
3006 test "$ac_cv_sizeof_voidp" -ge "8"; then
3008 elif test "$ac_cv_sizeof_long" -eq "4" &&
3009 test "$ac_cv_sizeof_voidp" -ge "4"; then
3011 elif test "$ac_cv_sizeof_long" -eq "2" &&
3012 test "$ac_cv_sizeof_voidp" -ge "2"; then
3016 dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
3018 curl_typeof_curl_off_t="unknown"
3019 curl_sizeof_curl_off_t="unknown"
3020 curl_format_curl_off_t="unknown"
3021 curl_format_curl_off_tu="unknown"
3023 if test "$curl_typeof_curl_off_t" = "unknown"; then
3024 AC_MSG_CHECKING([for 64-bit curl_off_t data type])
3032 DO_CURL_OFF_T_CHECK([$t8], [8])
3034 AC_MSG_RESULT([$curl_typeof_curl_off_t])
3036 if test "$curl_typeof_curl_off_t" = "unknown"; then
3037 AC_MSG_CHECKING([for 32-bit curl_off_t data type])
3043 DO_CURL_OFF_T_CHECK([$t4], [4])
3045 AC_MSG_RESULT([$curl_typeof_curl_off_t])
3047 if test "$curl_typeof_curl_off_t" = "unknown"; then
3048 AC_MSG_CHECKING([for 16-bit curl_off_t data type])
3054 DO_CURL_OFF_T_CHECK([$t2], [2])
3056 AC_MSG_RESULT([$curl_typeof_curl_off_t])
3058 if test "$curl_typeof_curl_off_t" = "unknown"; then
3059 AC_MSG_ERROR([cannot find data type for curl_off_t.])
3062 AC_MSG_CHECKING([size of curl_off_t])
3063 AC_MSG_RESULT([$curl_sizeof_curl_off_t])
3065 AC_MSG_CHECKING([formatting string directive for curl_off_t])
3066 if test "$curl_format_curl_off_t" != "unknown"; then
3067 x_pull_headers="yes"
3068 curl_format_curl_off_t=`echo "$curl_format_curl_off_t" | "$SED" 's/[["]]//g'`
3069 curl_format_curl_off_tu=`echo "$curl_format_curl_off_t" | "$SED" 's/i$/u/'`
3070 curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/d$/u/'`
3071 curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/D$/U/'`
3074 case AS_TR_SH([$curl_typeof_curl_off_t]) in
3075 long_long | __longlong | __longlong_t)
3076 curl_format_curl_off_t="lld"
3077 curl_format_curl_off_tu="llu"
3080 curl_format_curl_off_t="ld"
3081 curl_format_curl_off_tu="lu"
3084 curl_format_curl_off_t="d"
3085 curl_format_curl_off_tu="u"
3088 curl_format_curl_off_t="I64d"
3089 curl_format_curl_off_tu="I64u"
3092 curl_format_curl_off_t="I32d"
3093 curl_format_curl_off_tu="I32u"
3096 curl_format_curl_off_t="I16d"
3097 curl_format_curl_off_tu="I16u"
3100 AC_MSG_ERROR([cannot find print format string for curl_off_t.])
3104 AC_MSG_RESULT(["$curl_format_curl_off_t"])
3106 AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
3107 AC_MSG_RESULT(["$curl_format_curl_off_tu"])
3109 DO_CURL_OFF_T_SUFFIX_CHECK([$curl_typeof_curl_off_t])
3111 if test "$x_pull_headers" = "yes"; then
3112 if test "x$ac_cv_header_sys_types_h" = "xyes"; then
3113 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
3115 if test "x$ac_cv_header_stdint_h" = "xyes"; then
3116 CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
3118 if test "x$ac_cv_header_inttypes_h" = "xyes"; then
3119 CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
3123 CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_OFF_T], [$curl_typeof_curl_off_t])
3124 CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_T], ["$curl_format_curl_off_t"])
3125 CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_TU], ["$curl_format_curl_off_tu"])
3126 CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$curl_format_curl_off_t"])
3127 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$curl_sizeof_curl_off_t])
3128 CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_T], [$curl_suffix_curl_off_t])
3129 CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_TU], [$curl_suffix_curl_off_tu])
3134 dnl CURL_CHECK_WIN32_LARGEFILE
3135 dnl -------------------------------------------------
3136 dnl Check if curl's WIN32 large file will be used
3138 AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
3139 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
3140 AC_MSG_CHECKING([whether build target supports WIN32 file API])
3141 curl_win32_file_api="no"
3142 if test "$ac_cv_header_windows_h" = "yes"; then
3143 if test x"$enable_largefile" != "xno"; then
3147 #if !defined(_WIN32_WCE) && \
3148 (defined(__MINGW32__) || \
3149 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
3152 WIN32 large file API not supported.
3156 curl_win32_file_api="win32_large_files"
3159 if test "$curl_win32_file_api" = "no"; then
3163 #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
3166 WIN32 small file API not supported.
3170 curl_win32_file_api="win32_small_files"
3174 case "$curl_win32_file_api" in
3176 AC_MSG_RESULT([yes (large file enabled)])
3177 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
3178 [Define to 1 if you are building a Windows target with large file support.])
3181 AC_MSG_RESULT([yes (large file disabled)])
3182 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
3183 [Define to 1 if you are building a Windows target without large file support.])
3191 dnl CURL_CHECK_PKGCONFIG ($module)
3192 dnl ------------------------
3193 dnl search for the pkg-config tool (if not cross-compiling). Set the PKGCONFIG
3194 dnl variable to hold the path to it, or 'no' if not found/present.
3196 dnl If pkg-config is present, check that it has info about the $module or return
3200 AC_DEFUN([CURL_CHECK_PKGCONFIG], [
3201 if test x$cross_compiling != xyes; then
3202 dnl only do pkg-config magic when not cross-compiling
3203 AC_PATH_PROG( PKGCONFIG, pkg-config, no, $PATH:/usr/bin:/usr/local/bin)
3205 if test x$PKGCONFIG != xno; then
3206 AC_MSG_CHECKING([for $1 options with pkg-config])
3207 dnl ask pkg-config about $1
3208 $PKGCONFIG --exists $1
3209 if test "$?" -ne "0"; then
3210 dnl pkg-config does not have info about the given module! set the
3211 dnl variable to 'no'
3215 AC_MSG_RESULT([found])