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_AIX_ALL_SOURCE
160 dnl -------------------------------------------------
161 dnl Provides a replacement of traditional AC_AIX with
162 dnl an uniform behaviour across all autoconf versions,
163 dnl and with our own placement rules.
165 AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
166 AH_VERBATIM([_ALL_SOURCE],
167 [/* Define to 1 if OS is AIX. */
171 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
172 AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
173 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
174 AC_EGREP_CPP([yes_this_is_aix],[
180 AC_DEFINE(_ALL_SOURCE)
187 dnl CURL_CHECK_HEADER_WINDOWS
188 dnl -------------------------------------------------
189 dnl Check for compilable and valid windows.h header
191 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
192 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
196 #ifndef WIN32_LEAN_AND_MEAN
197 #define WIN32_LEAN_AND_MEAN
201 #if defined(__CYGWIN__) || defined(__CEGCC__)
202 HAVE_WINDOWS_H shall not be defined.
208 ac_cv_header_windows_h="yes"
210 ac_cv_header_windows_h="no"
213 case "$ac_cv_header_windows_h" in
215 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
216 [Define to 1 if you have the windows.h header file.])
217 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
218 [Define to avoid automatic inclusion of winsock.h])
224 dnl CURL_CHECK_NATIVE_WINDOWS
225 dnl -------------------------------------------------
226 dnl Check if building a native Windows target
228 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
229 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
230 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
231 if test "$ac_cv_header_windows_h" = "no"; then
232 ac_cv_native_windows="no"
237 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
238 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
241 Not a native Windows build target.
245 ac_cv_native_windows="yes"
247 ac_cv_native_windows="no"
251 case "$ac_cv_native_windows" in
253 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
254 [Define to 1 if you are building a native Windows target.])
260 dnl CURL_CHECK_HEADER_WINSOCK
261 dnl -------------------------------------------------
262 dnl Check for compilable and valid winsock.h header
264 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
265 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
266 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
270 #ifndef WIN32_LEAN_AND_MEAN
271 #define WIN32_LEAN_AND_MEAN
276 #if defined(__CYGWIN__) || defined(__CEGCC__)
277 HAVE_WINSOCK_H shall not be defined.
279 int dummy=WSACleanup();
283 ac_cv_header_winsock_h="yes"
285 ac_cv_header_winsock_h="no"
288 case "$ac_cv_header_winsock_h" in
290 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
291 [Define to 1 if you have the winsock.h header file.])
297 dnl CURL_CHECK_HEADER_WINSOCK2
298 dnl -------------------------------------------------
299 dnl Check for compilable and valid winsock2.h header
301 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
302 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
303 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
307 #ifndef WIN32_LEAN_AND_MEAN
308 #define WIN32_LEAN_AND_MEAN
311 #include <winsock2.h>
313 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
314 HAVE_WINSOCK2_H shall not be defined.
316 int dummy=2*IPPROTO_ESP;
320 ac_cv_header_winsock2_h="yes"
322 ac_cv_header_winsock2_h="no"
325 case "$ac_cv_header_winsock2_h" in
327 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
328 [Define to 1 if you have the winsock2.h header file.])
334 dnl CURL_CHECK_HEADER_WS2TCPIP
335 dnl -------------------------------------------------
336 dnl Check for compilable and valid ws2tcpip.h header
338 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
339 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
340 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
344 #ifndef WIN32_LEAN_AND_MEAN
345 #define WIN32_LEAN_AND_MEAN
348 #include <winsock2.h>
349 #include <ws2tcpip.h>
351 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
352 HAVE_WS2TCPIP_H shall not be defined.
354 int dummy=2*IP_PKTINFO;
358 ac_cv_header_ws2tcpip_h="yes"
360 ac_cv_header_ws2tcpip_h="no"
363 case "$ac_cv_header_ws2tcpip_h" in
365 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
366 [Define to 1 if you have the ws2tcpip.h header file.])
372 dnl CURL_CHECK_HEADER_WINLDAP
373 dnl -------------------------------------------------
374 dnl Check for compilable and valid winldap.h header
376 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
377 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
378 AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
382 #ifdef HAVE_WINDOWS_H
383 #ifndef WIN32_LEAN_AND_MEAN
384 #define WIN32_LEAN_AND_MEAN
390 #if defined(__CYGWIN__) || defined(__CEGCC__)
391 HAVE_WINLDAP_H shall not be defined.
393 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
394 ULONG res = ldap_unbind(ldp);
398 ac_cv_header_winldap_h="yes"
400 ac_cv_header_winldap_h="no"
403 case "$ac_cv_header_winldap_h" in
405 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
406 [Define to 1 if you have the winldap.h header file.])
412 dnl CURL_CHECK_HEADER_WINBER
413 dnl -------------------------------------------------
414 dnl Check for compilable and valid winber.h header
416 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
417 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
418 AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
422 #ifdef HAVE_WINDOWS_H
423 #ifndef WIN32_LEAN_AND_MEAN
424 #define WIN32_LEAN_AND_MEAN
431 #if defined(__CYGWIN__) || defined(__CEGCC__)
432 HAVE_WINBER_H shall not be defined.
435 BerElement *bep = ber_init(bvp);
440 ac_cv_header_winber_h="yes"
442 ac_cv_header_winber_h="no"
445 case "$ac_cv_header_winber_h" in
447 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
448 [Define to 1 if you have the winber.h header file.])
454 dnl CURL_CHECK_HEADER_LBER
455 dnl -------------------------------------------------
456 dnl Check for compilable and valid lber.h header,
457 dnl and check if it is needed even with ldap.h
459 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
460 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
461 AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
465 #ifdef HAVE_WINDOWS_H
466 #ifndef WIN32_LEAN_AND_MEAN
467 #define WIN32_LEAN_AND_MEAN
471 #ifdef HAVE_SYS_TYPES_H
472 #include <sys/types.h>
476 #define NULL (void *)0
480 BerValue *bvp = NULL;
481 BerElement *bep = ber_init(bvp);
485 ac_cv_header_lber_h="yes"
487 ac_cv_header_lber_h="no"
490 if test "$ac_cv_header_lber_h" = "yes"; then
491 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
492 [Define to 1 if you have the lber.h header file.])
497 #ifdef HAVE_WINDOWS_H
498 #ifndef WIN32_LEAN_AND_MEAN
499 #define WIN32_LEAN_AND_MEAN
503 #ifdef HAVE_SYS_TYPES_H
504 #include <sys/types.h>
508 #define NULL (void *)0
510 #ifndef LDAP_DEPRECATED
511 #define LDAP_DEPRECATED 1
515 BerValue *bvp = NULL;
516 BerElement *bep = ber_init(bvp);
520 curl_cv_need_header_lber_h="no"
522 curl_cv_need_header_lber_h="yes"
525 case "$curl_cv_need_header_lber_h" in
527 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
528 [Define to 1 if you need the lber.h header file even with ldap.h])
535 dnl CURL_CHECK_HEADER_LDAP
536 dnl -------------------------------------------------
537 dnl Check for compilable and valid ldap.h header
539 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
540 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
541 AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
545 #ifdef HAVE_WINDOWS_H
546 #ifndef WIN32_LEAN_AND_MEAN
547 #define WIN32_LEAN_AND_MEAN
551 #ifdef HAVE_SYS_TYPES_H
552 #include <sys/types.h>
555 #ifndef LDAP_DEPRECATED
556 #define LDAP_DEPRECATED 1
563 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
564 int res = ldap_unbind(ldp);
567 ac_cv_header_ldap_h="yes"
569 ac_cv_header_ldap_h="no"
572 case "$ac_cv_header_ldap_h" in
574 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
575 [Define to 1 if you have the ldap.h header file.])
581 dnl CURL_CHECK_HEADER_LDAP_SSL
582 dnl -------------------------------------------------
583 dnl Check for compilable and valid ldap_ssl.h header
585 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
586 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
587 AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
591 #ifdef HAVE_WINDOWS_H
592 #ifndef WIN32_LEAN_AND_MEAN
593 #define WIN32_LEAN_AND_MEAN
597 #ifdef HAVE_SYS_TYPES_H
598 #include <sys/types.h>
601 #ifndef LDAP_DEPRECATED
602 #define LDAP_DEPRECATED 1
610 #include <ldap_ssl.h>
612 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
615 ac_cv_header_ldap_ssl_h="yes"
617 ac_cv_header_ldap_ssl_h="no"
620 case "$ac_cv_header_ldap_ssl_h" in
622 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
623 [Define to 1 if you have the ldap_ssl.h header file.])
629 dnl CURL_CHECK_HEADER_LDAPSSL
630 dnl -------------------------------------------------
631 dnl Check for compilable and valid ldapssl.h header
633 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
634 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
635 AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
639 #ifdef HAVE_WINDOWS_H
640 #ifndef WIN32_LEAN_AND_MEAN
641 #define WIN32_LEAN_AND_MEAN
645 #ifdef HAVE_SYS_TYPES_H
646 #include <sys/types.h>
650 #define NULL (void *)0
652 #ifndef LDAP_DEPRECATED
653 #define LDAP_DEPRECATED 1
663 char *cert_label = NULL;
664 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
667 ac_cv_header_ldapssl_h="yes"
669 ac_cv_header_ldapssl_h="no"
672 case "$ac_cv_header_ldapssl_h" in
674 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
675 [Define to 1 if you have the ldapssl.h header file.])
681 dnl CURL_CHECK_LIBS_WINLDAP
682 dnl -------------------------------------------------
683 dnl Check for libraries needed for WINLDAP support,
684 dnl and prepended to LIBS any needed libraries.
685 dnl This macro can take an optional parameter with a
686 dnl white space separated list of libraries to check
687 dnl before the WINLDAP default ones.
689 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
690 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
692 AC_MSG_CHECKING([for WINLDAP libraries])
706 if test -z "$u_libs"; then
709 u_libs="$u_libs $l_lib"
714 curl_cv_save_LIBS="$LIBS"
715 curl_cv_ldap_LIBS="unknown"
717 for x_nlibs in '' "$u_libs" \
719 if test "$curl_cv_ldap_LIBS" = "unknown"; then
720 if test -z "$x_nlibs"; then
721 LIBS="$curl_cv_save_LIBS"
723 LIBS="$x_nlibs $curl_cv_save_LIBS"
728 #ifdef HAVE_WINDOWS_H
729 #ifndef WIN32_LEAN_AND_MEAN
730 #define WIN32_LEAN_AND_MEAN
733 #ifdef HAVE_WINLDAP_H
742 BerElement *bep = ber_init(bvp);
743 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
744 ULONG res = ldap_unbind(ldp);
748 curl_cv_ldap_LIBS="$x_nlibs"
753 LIBS="$curl_cv_save_LIBS"
755 case X-"$curl_cv_ldap_LIBS" in
757 AC_MSG_RESULT([cannot find WINLDAP libraries])
760 AC_MSG_RESULT([no additional lib required])
763 if test -z "$curl_cv_save_LIBS"; then
764 LIBS="$curl_cv_ldap_LIBS"
766 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
768 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
775 dnl CURL_CHECK_LIBS_LDAP
776 dnl -------------------------------------------------
777 dnl Check for libraries needed for LDAP support,
778 dnl and prepended to LIBS any needed libraries.
779 dnl This macro can take an optional parameter with a
780 dnl white space separated list of libraries to check
781 dnl before the default ones.
783 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
784 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
786 AC_MSG_CHECKING([for LDAP libraries])
800 if test -z "$u_libs"; then
803 u_libs="$u_libs $l_lib"
808 curl_cv_save_LIBS="$LIBS"
809 curl_cv_ldap_LIBS="unknown"
811 for x_nlibs in '' "$u_libs" \
815 '-lldapssl -lldapx -lldapsdk' \
816 '-lldapsdk -lldapx -lldapssl' ; do
817 if test "$curl_cv_ldap_LIBS" = "unknown"; then
818 if test -z "$x_nlibs"; then
819 LIBS="$curl_cv_save_LIBS"
821 LIBS="$x_nlibs $curl_cv_save_LIBS"
826 #ifdef HAVE_WINDOWS_H
827 #ifndef WIN32_LEAN_AND_MEAN
828 #define WIN32_LEAN_AND_MEAN
832 #ifdef HAVE_SYS_TYPES_H
833 #include <sys/types.h>
837 #define NULL (void *)0
839 #ifndef LDAP_DEPRECATED
840 #define LDAP_DEPRECATED 1
849 BerValue *bvp = NULL;
850 BerElement *bep = ber_init(bvp);
851 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
852 int res = ldap_unbind(ldp);
856 curl_cv_ldap_LIBS="$x_nlibs"
861 LIBS="$curl_cv_save_LIBS"
863 case X-"$curl_cv_ldap_LIBS" in
865 AC_MSG_RESULT([cannot find LDAP libraries])
868 AC_MSG_RESULT([no additional lib required])
871 if test -z "$curl_cv_save_LIBS"; then
872 LIBS="$curl_cv_ldap_LIBS"
874 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
876 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
883 dnl CURL_CHECK_HEADER_MALLOC
884 dnl -------------------------------------------------
885 dnl Check for compilable and valid malloc.h header,
886 dnl and check if it is needed even with stdlib.h
888 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
889 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
894 void *p = malloc(10);
895 void *q = calloc(10,10);
900 ac_cv_header_malloc_h="yes"
902 ac_cv_header_malloc_h="no"
905 if test "$ac_cv_header_malloc_h" = "yes"; then
906 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
907 [Define to 1 if you have the malloc.h header file.])
913 void *p = malloc(10);
914 void *q = calloc(10,10);
919 curl_cv_need_header_malloc_h="no"
921 curl_cv_need_header_malloc_h="yes"
924 case "$curl_cv_need_header_malloc_h" in
926 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
927 [Define to 1 if you need the malloc.h header file even with stdlib.h])
934 dnl CURL_CHECK_HEADER_MEMORY
935 dnl -------------------------------------------------
936 dnl Check for compilable and valid memory.h header,
937 dnl and check if it is needed even with stdlib.h for
938 dnl memory related functions.
940 AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
941 AC_CACHE_CHECK([for memory.h], [ac_cv_header_memory_h], [
946 void *p = malloc(10);
947 void *q = calloc(10,10);
952 ac_cv_header_memory_h="yes"
954 ac_cv_header_memory_h="no"
957 if test "$ac_cv_header_memory_h" = "yes"; then
958 AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
959 [Define to 1 if you have the memory.h header file.])
965 void *p = malloc(10);
966 void *q = calloc(10,10);
971 curl_cv_need_header_memory_h="no"
973 curl_cv_need_header_memory_h="yes"
976 case "$curl_cv_need_header_memory_h" in
978 AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
979 [Define to 1 if you need the memory.h header file even with stdlib.h])
986 dnl CURL_CHECK_FUNC_GETNAMEINFO
987 dnl -------------------------------------------------
988 dnl Test if the getnameinfo function is available,
989 dnl and check the types of five of its arguments.
990 dnl If the function succeeds HAVE_GETNAMEINFO will be
991 dnl defined, defining the types of the arguments in
992 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
993 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
994 dnl and also defining the type qualifier of first
995 dnl argument in GETNAMEINFO_QUAL_ARG1.
997 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
998 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
999 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
1001 AC_MSG_CHECKING([for getnameinfo])
1003 AC_LANG_FUNC_LINK_TRY([getnameinfo])
1005 AC_MSG_RESULT([yes])
1006 curl_cv_getnameinfo="yes"
1009 curl_cv_getnameinfo="no"
1012 if test "$curl_cv_getnameinfo" != "yes"; then
1013 AC_MSG_CHECKING([deeper for getnameinfo])
1020 AC_MSG_RESULT([yes])
1021 curl_cv_getnameinfo="yes"
1023 AC_MSG_RESULT([but still no])
1024 curl_cv_getnameinfo="no"
1028 if test "$curl_cv_getnameinfo" != "yes"; then
1029 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
1033 #ifdef HAVE_WINDOWS_H
1034 #ifndef WIN32_LEAN_AND_MEAN
1035 #define WIN32_LEAN_AND_MEAN
1037 #include <windows.h>
1038 #ifdef HAVE_WINSOCK2_H
1039 #include <winsock2.h>
1040 #ifdef HAVE_WS2TCPIP_H
1041 #include <ws2tcpip.h>
1045 #ifdef HAVE_SYS_TYPES_H
1046 #include <sys/types.h>
1048 #ifdef HAVE_SYS_SOCKET_H
1049 #include <sys/socket.h>
1056 getnameinfo(0, 0, 0, 0, 0, 0, 0);
1059 AC_MSG_RESULT([yes])
1060 curl_cv_getnameinfo="yes"
1062 AC_MSG_RESULT([but still no])
1063 curl_cv_getnameinfo="no"
1067 if test "$curl_cv_getnameinfo" = "yes"; then
1068 AC_CACHE_CHECK([types of arguments for getnameinfo],
1069 [curl_cv_func_getnameinfo_args], [
1070 curl_cv_func_getnameinfo_args="unknown"
1071 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
1072 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
1073 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
1074 for gni_arg7 in 'int' 'unsigned int'; do
1075 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1079 #ifdef HAVE_WINDOWS_H
1080 #ifndef WIN32_LEAN_AND_MEAN
1081 #define WIN32_LEAN_AND_MEAN
1083 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
1085 #define _WIN32_WINNT 0x0501
1087 #include <windows.h>
1088 #ifdef HAVE_WINSOCK2_H
1089 #include <winsock2.h>
1090 #ifdef HAVE_WS2TCPIP_H
1091 #include <ws2tcpip.h>
1094 #define GNICALLCONV WSAAPI
1096 #ifdef HAVE_SYS_TYPES_H
1097 #include <sys/types.h>
1099 #ifdef HAVE_SYS_SOCKET_H
1100 #include <sys/socket.h>
1107 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
1113 $gni_arg46 hostlen=0;
1114 $gni_arg46 servlen=0;
1116 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
1119 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
1127 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1128 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
1129 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1131 gni_prev_IFS=$IFS; IFS=','
1132 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1136 gni_qual_type_arg1=$[1]
1138 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1139 [Define to the type of arg 2 for getnameinfo.])
1140 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1141 [Define to the type of args 4 and 6 for getnameinfo.])
1142 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1143 [Define to the type of arg 7 for getnameinfo.])
1147 case $prev_sh_opts in
1155 case "$gni_qual_type_arg1" in
1158 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1162 gni_type_arg1=$gni_qual_type_arg1
1166 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1167 [Define to the type qualifier of arg 1 for getnameinfo.])
1168 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1169 [Define to the type of arg 1 for getnameinfo.])
1171 case $prev_sh_opts in
1179 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1180 [Define to 1 if you have the getnameinfo function.])
1181 ac_cv_func_getnameinfo="yes"
1187 dnl TYPE_SOCKADDR_STORAGE
1188 dnl -------------------------------------------------
1189 dnl Check for struct sockaddr_storage. Most IPv6-enabled
1190 dnl hosts have it, but AIX 4.3 is one known exception.
1192 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1194 AC_CHECK_TYPE([struct sockaddr_storage],
1195 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1196 [if struct sockaddr_storage is defined]), ,
1199 #ifdef HAVE_WINDOWS_H
1200 #ifndef WIN32_LEAN_AND_MEAN
1201 #define WIN32_LEAN_AND_MEAN
1203 #include <windows.h>
1204 #ifdef HAVE_WINSOCK2_H
1205 #include <winsock2.h>
1208 #ifdef HAVE_SYS_TYPES_H
1209 #include <sys/types.h>
1211 #ifdef HAVE_SYS_SOCKET_H
1212 #include <sys/socket.h>
1214 #ifdef HAVE_NETINET_IN_H
1215 #include <netinet/in.h>
1217 #ifdef HAVE_ARPA_INET_H
1218 #include <arpa/inet.h>
1225 dnl CURL_CHECK_NI_WITHSCOPEID
1226 dnl -------------------------------------------------
1227 dnl Check for working NI_WITHSCOPEID in getnameinfo()
1229 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1230 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1231 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1232 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1233 netdb.h netinet/in.h arpa/inet.h)
1235 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
1236 [ac_cv_working_ni_withscopeid], [
1239 #ifdef HAVE_STDLIB_H
1245 #ifdef HAVE_SYS_TYPES_H
1246 #include <sys/types.h>
1248 #ifdef HAVE_SYS_SOCKET_H
1249 #include <sys/socket.h>
1254 #ifdef HAVE_NETINET_IN_H
1255 #include <netinet/in.h>
1257 #ifdef HAVE_ARPA_INET_H
1258 #include <arpa/inet.h>
1261 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1262 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1263 struct sockaddr_storage sa;
1265 unsigned char sa[256];
1267 char hostbuf[NI_MAXHOST];
1269 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1270 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1271 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1272 int fd = socket(AF_INET6, SOCK_STREAM, 0);
1275 return 1; /* Error creating socket */
1277 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1279 perror("getsockname()");
1280 return 2; /* Error retrieving socket name */
1282 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1284 printf("rc = %s\n", gai_strerror(rc));
1285 return 3; /* Error translating socket address */
1287 return 0; /* Ok, NI_WITHSCOPEID works */
1289 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1291 ]]) # AC-LANG-PROGRAM
1293 # Exit code == 0. Program worked.
1294 ac_cv_working_ni_withscopeid="yes"
1296 # Exit code != 0. Program failed.
1297 ac_cv_working_ni_withscopeid="no"
1299 # Program is not run when cross-compiling. So we assume
1300 # NI_WITHSCOPEID will work if we are able to compile it.
1303 #include <sys/types.h>
1304 #include <sys/socket.h>
1307 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1310 ac_cv_working_ni_withscopeid="yes"
1312 ac_cv_working_ni_withscopeid="no"
1313 ]) # AC-COMPILE-IFELSE
1316 case "$ac_cv_working_ni_withscopeid" in
1318 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1319 [Define to 1 if NI_WITHSCOPEID exists and works.])
1325 dnl CURL_CHECK_FUNC_RECV
1326 dnl -------------------------------------------------
1327 dnl Test if the socket recv() function is available,
1328 dnl and check its return type and the types of its
1329 dnl arguments. If the function succeeds HAVE_RECV
1330 dnl will be defined, defining the types of the arguments
1331 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1332 dnl and RECV_TYPE_ARG4, defining the type of the function
1333 dnl return value in RECV_TYPE_RETV.
1335 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1336 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1337 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1338 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1340 AC_MSG_CHECKING([for recv])
1344 #ifdef HAVE_WINDOWS_H
1345 #ifndef WIN32_LEAN_AND_MEAN
1346 #define WIN32_LEAN_AND_MEAN
1348 #include <windows.h>
1349 #ifdef HAVE_WINSOCK2_H
1350 #include <winsock2.h>
1352 #ifdef HAVE_WINSOCK_H
1353 #include <winsock.h>
1357 #ifdef HAVE_SYS_TYPES_H
1358 #include <sys/types.h>
1360 #ifdef HAVE_SYS_SOCKET_H
1361 #include <sys/socket.h>
1368 AC_MSG_RESULT([yes])
1375 if test "$curl_cv_recv" = "yes"; then
1376 AC_CACHE_CHECK([types of args and return type for recv],
1377 [curl_cv_func_recv_args], [
1378 curl_cv_func_recv_args="unknown"
1379 for recv_retv in 'int' 'ssize_t'; do
1380 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1381 for recv_arg2 in 'char *' 'void *'; do
1382 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1383 for recv_arg4 in 'int' 'unsigned int'; do
1384 if test "$curl_cv_func_recv_args" = "unknown"; then
1388 #ifdef HAVE_WINDOWS_H
1389 #ifndef WIN32_LEAN_AND_MEAN
1390 #define WIN32_LEAN_AND_MEAN
1392 #include <windows.h>
1393 #ifdef HAVE_WINSOCK2_H
1394 #include <winsock2.h>
1396 #ifdef HAVE_WINSOCK_H
1397 #include <winsock.h>
1400 #define RECVCALLCONV PASCAL
1402 #ifdef HAVE_SYS_TYPES_H
1403 #include <sys/types.h>
1405 #ifdef HAVE_SYS_SOCKET_H
1406 #include <sys/socket.h>
1408 #define RECVCALLCONV
1410 extern $recv_retv RECVCALLCONV
1411 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1417 $recv_retv res = recv(s, buf, len, flags);
1420 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1429 if test "$curl_cv_func_recv_args" = "unknown"; then
1430 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1432 recv_prev_IFS=$IFS; IFS=','
1433 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1437 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1438 [Define to the type of arg 1 for recv.])
1439 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1440 [Define to the type of arg 2 for recv.])
1441 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1442 [Define to the type of arg 3 for recv.])
1443 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1444 [Define to the type of arg 4 for recv.])
1445 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1446 [Define to the function return type for recv.])
1448 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1449 [Define to 1 if you have the recv function.])
1450 ac_cv_func_recv="yes"
1453 AC_MSG_ERROR([Unable to link function recv])
1458 dnl CURL_CHECK_FUNC_SEND
1459 dnl -------------------------------------------------
1460 dnl Test if the socket send() function is available,
1461 dnl and check its return type and the types of its
1462 dnl arguments. If the function succeeds HAVE_SEND
1463 dnl will be defined, defining the types of the arguments
1464 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1465 dnl and SEND_TYPE_ARG4, defining the type of the function
1466 dnl return value in SEND_TYPE_RETV, and also defining the
1467 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1469 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1470 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1471 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1472 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1474 AC_MSG_CHECKING([for send])
1478 #ifdef HAVE_WINDOWS_H
1479 #ifndef WIN32_LEAN_AND_MEAN
1480 #define WIN32_LEAN_AND_MEAN
1482 #include <windows.h>
1483 #ifdef HAVE_WINSOCK2_H
1484 #include <winsock2.h>
1486 #ifdef HAVE_WINSOCK_H
1487 #include <winsock.h>
1491 #ifdef HAVE_SYS_TYPES_H
1492 #include <sys/types.h>
1494 #ifdef HAVE_SYS_SOCKET_H
1495 #include <sys/socket.h>
1502 AC_MSG_RESULT([yes])
1509 if test "$curl_cv_send" = "yes"; then
1510 AC_CACHE_CHECK([types of args and return type for send],
1511 [curl_cv_func_send_args], [
1512 curl_cv_func_send_args="unknown"
1513 for send_retv in 'int' 'ssize_t'; do
1514 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1515 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1516 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1517 for send_arg4 in 'int' 'unsigned int'; do
1518 if test "$curl_cv_func_send_args" = "unknown"; then
1522 #ifdef HAVE_WINDOWS_H
1523 #ifndef WIN32_LEAN_AND_MEAN
1524 #define WIN32_LEAN_AND_MEAN
1526 #include <windows.h>
1527 #ifdef HAVE_WINSOCK2_H
1528 #include <winsock2.h>
1530 #ifdef HAVE_WINSOCK_H
1531 #include <winsock.h>
1534 #define SENDCALLCONV PASCAL
1536 #ifdef HAVE_SYS_TYPES_H
1537 #include <sys/types.h>
1539 #ifdef HAVE_SYS_SOCKET_H
1540 #include <sys/socket.h>
1542 #define SENDCALLCONV
1544 extern $send_retv SENDCALLCONV
1545 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1550 $send_retv res = send(s, 0, len, flags);
1553 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1562 if test "$curl_cv_func_send_args" = "unknown"; then
1563 AC_MSG_ERROR([Cannot find proper types to use for send args])
1565 send_prev_IFS=$IFS; IFS=','
1566 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1570 send_qual_type_arg2=$[2]
1572 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1573 [Define to the type of arg 1 for send.])
1574 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1575 [Define to the type of arg 3 for send.])
1576 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1577 [Define to the type of arg 4 for send.])
1578 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1579 [Define to the function return type for send.])
1583 case $prev_sh_opts in
1591 case "$send_qual_type_arg2" in
1593 send_qual_arg2=const
1594 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1598 send_type_arg2=$send_qual_type_arg2
1602 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1603 [Define to the type qualifier of arg 2 for send.])
1604 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1605 [Define to the type of arg 2 for send.])
1607 case $prev_sh_opts in
1615 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1616 [Define to 1 if you have the send function.])
1617 ac_cv_func_send="yes"
1620 AC_MSG_ERROR([Unable to link function send])
1625 dnl CURL_CHECK_FUNC_RECVFROM
1626 dnl -------------------------------------------------
1627 dnl Test if the socket recvfrom() function is available,
1628 dnl and check its return type and the types of its
1629 dnl arguments. If the function succeeds HAVE_RECVFROM
1630 dnl will be defined, defining the types of the arguments
1631 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1632 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1633 dnl function return value in RECVFROM_TYPE_RETV.
1634 dnl Notice that the types returned for pointer arguments
1635 dnl will actually be the type pointed by the pointer.
1637 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1638 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1639 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1640 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1642 AC_MSG_CHECKING([for recvfrom])
1646 #ifdef HAVE_WINDOWS_H
1647 #ifndef WIN32_LEAN_AND_MEAN
1648 #define WIN32_LEAN_AND_MEAN
1650 #include <windows.h>
1651 #ifdef HAVE_WINSOCK2_H
1652 #include <winsock2.h>
1654 #ifdef HAVE_WINSOCK_H
1655 #include <winsock.h>
1659 #ifdef HAVE_SYS_TYPES_H
1660 #include <sys/types.h>
1662 #ifdef HAVE_SYS_SOCKET_H
1663 #include <sys/socket.h>
1667 recvfrom(0, 0, 0, 0, 0, 0);
1670 AC_MSG_RESULT([yes])
1671 curl_cv_recvfrom="yes"
1674 curl_cv_recvfrom="no"
1677 if test "$curl_cv_recvfrom" = "yes"; then
1678 AC_CACHE_CHECK([types of args and return type for recvfrom],
1679 [curl_cv_func_recvfrom_args], [
1680 curl_cv_func_recvfrom_args="unknown"
1681 for recvfrom_retv in 'int' 'ssize_t'; do
1682 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1683 for recvfrom_arg2 in 'char *' 'void *'; do
1684 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1685 for recvfrom_arg4 in 'int' 'unsigned int'; do
1686 for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
1687 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1688 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1692 #ifdef HAVE_WINDOWS_H
1693 #ifndef WIN32_LEAN_AND_MEAN
1694 #define WIN32_LEAN_AND_MEAN
1696 #include <windows.h>
1697 #ifdef HAVE_WINSOCK2_H
1698 #include <winsock2.h>
1700 #ifdef HAVE_WINSOCK_H
1701 #include <winsock.h>
1704 #define RECVFROMCALLCONV PASCAL
1706 #ifdef HAVE_SYS_TYPES_H
1707 #include <sys/types.h>
1709 #ifdef HAVE_SYS_SOCKET_H
1710 #include <sys/socket.h>
1712 #define RECVFROMCALLCONV
1714 extern $recvfrom_retv RECVFROMCALLCONV
1715 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1716 $recvfrom_arg3, $recvfrom_arg4,
1717 $recvfrom_arg5, $recvfrom_arg6);
1720 $recvfrom_arg2 buf=0;
1721 $recvfrom_arg3 len=0;
1722 $recvfrom_arg4 flags=0;
1723 $recvfrom_arg5 addr=0;
1724 $recvfrom_arg6 addrlen=0;
1725 $recvfrom_retv res=0;
1726 res = recvfrom(s, buf, len, flags, addr, addrlen);
1729 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1740 # Nearly last minute change for this release starts here
1741 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1742 [Define to 1 if you have the recvfrom function.])
1743 ac_cv_func_recvfrom="yes"
1744 # Nearly last minute change for this release ends here
1745 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1746 AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
1748 recvfrom_prev_IFS=$IFS; IFS=','
1749 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1750 IFS=$recvfrom_prev_IFS
1753 recvfrom_ptrt_arg2=$[2]
1754 recvfrom_ptrt_arg5=$[5]
1755 recvfrom_ptrt_arg6=$[6]
1757 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1758 [Define to the type of arg 1 for recvfrom.])
1759 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1760 [Define to the type of arg 3 for recvfrom.])
1761 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1762 [Define to the type of arg 4 for recvfrom.])
1763 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1764 [Define to the function return type for recvfrom.])
1768 case $prev_sh_opts in
1776 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1777 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1778 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1780 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1781 [Define to the type pointed by arg 2 for recvfrom.])
1782 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1783 [Define to the type pointed by arg 5 for recvfrom.])
1784 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1785 [Define to the type pointed by arg 6 for recvfrom.])
1787 if test "$recvfrom_type_arg2" = "void"; then
1788 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1789 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1791 if test "$recvfrom_type_arg5" = "void"; then
1792 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1793 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1795 if test "$recvfrom_type_arg6" = "void"; then
1796 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1797 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1800 case $prev_sh_opts in
1808 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1809 [Define to 1 if you have the recvfrom function.])
1810 ac_cv_func_recvfrom="yes"
1813 AC_MSG_WARN([Unable to link function recvfrom])
1818 dnl CURL_CHECK_MSG_NOSIGNAL
1819 dnl -------------------------------------------------
1820 dnl Check for MSG_NOSIGNAL
1822 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1823 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1824 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1828 #ifdef HAVE_WINDOWS_H
1829 #ifndef WIN32_LEAN_AND_MEAN
1830 #define WIN32_LEAN_AND_MEAN
1832 #include <windows.h>
1833 #ifdef HAVE_WINSOCK2_H
1834 #include <winsock2.h>
1836 #ifdef HAVE_WINSOCK_H
1837 #include <winsock.h>
1841 #ifdef HAVE_SYS_TYPES_H
1842 #include <sys/types.h>
1844 #ifdef HAVE_SYS_SOCKET_H
1845 #include <sys/socket.h>
1849 int flag=MSG_NOSIGNAL;
1852 ac_cv_msg_nosignal="yes"
1854 ac_cv_msg_nosignal="no"
1857 case "$ac_cv_msg_nosignal" in
1859 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1860 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1866 dnl CURL_CHECK_STRUCT_TIMEVAL
1867 dnl -------------------------------------------------
1868 dnl Check for timeval struct
1870 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1871 AC_REQUIRE([AC_HEADER_TIME])dnl
1872 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1873 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1874 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1875 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1879 #ifdef HAVE_WINDOWS_H
1880 #ifndef WIN32_LEAN_AND_MEAN
1881 #define WIN32_LEAN_AND_MEAN
1883 #include <windows.h>
1884 #ifdef HAVE_WINSOCK2_H
1885 #include <winsock2.h>
1887 #ifdef HAVE_WINSOCK_H
1888 #include <winsock.h>
1892 #ifdef HAVE_SYS_TYPES_H
1893 #include <sys/types.h>
1895 #ifdef HAVE_SYS_TIME_H
1896 #include <sys/time.h>
1897 #ifdef TIME_WITH_SYS_TIME
1911 ac_cv_struct_timeval="yes"
1913 ac_cv_struct_timeval="no"
1916 case "$ac_cv_struct_timeval" in
1918 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1919 [Define to 1 if you have the timeval struct.])
1925 dnl TYPE_SIG_ATOMIC_T
1926 dnl -------------------------------------------------
1927 dnl Check if the sig_atomic_t type is available, and
1928 dnl verify if it is already defined as volatile.
1930 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1931 AC_CHECK_HEADERS(signal.h)
1932 AC_CHECK_TYPE([sig_atomic_t],[
1933 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1934 [Define to 1 if sig_atomic_t is an available typedef.])
1936 #ifdef HAVE_SIGNAL_H
1940 case "$ac_cv_type_sig_atomic_t" in
1943 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1946 #ifdef HAVE_SIGNAL_H
1950 static volatile sig_atomic_t dummy = 0;
1954 ac_cv_sig_atomic_t_volatile="no"
1956 AC_MSG_RESULT([yes])
1957 ac_cv_sig_atomic_t_volatile="yes"
1960 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1961 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1962 [Define to 1 if sig_atomic_t is already defined as volatile.])
1970 dnl -------------------------------------------------
1971 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1972 dnl and a few other things.
1974 AC_DEFUN([TYPE_IN_ADDR_T], [
1975 AC_CHECK_TYPE([in_addr_t], ,[
1976 dnl in_addr_t not available
1977 AC_CACHE_CHECK([for in_addr_t equivalent],
1978 [curl_cv_in_addr_t_equiv], [
1979 curl_cv_in_addr_t_equiv="unknown"
1980 for t in "unsigned long" int size_t unsigned long; do
1981 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1985 #ifdef HAVE_WINDOWS_H
1986 #ifndef WIN32_LEAN_AND_MEAN
1987 #define WIN32_LEAN_AND_MEAN
1989 #include <windows.h>
1990 #ifdef HAVE_WINSOCK2_H
1991 #include <winsock2.h>
1993 #ifdef HAVE_WINSOCK_H
1994 #include <winsock.h>
1998 #ifdef HAVE_SYS_TYPES_H
1999 #include <sys/types.h>
2001 #ifdef HAVE_SYS_SOCKET_H
2002 #include <sys/socket.h>
2004 #ifdef HAVE_NETINET_IN_H
2005 #include <netinet/in.h>
2007 #ifdef HAVE_ARPA_INET_H
2008 #include <arpa/inet.h>
2012 $t data = inet_addr ("1.2.3.4");
2015 curl_cv_in_addr_t_equiv="$t"
2020 case "$curl_cv_in_addr_t_equiv" in
2022 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
2025 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
2026 [Type to use in place of in_addr_t when system does not provide it.])
2031 #ifdef HAVE_WINDOWS_H
2032 #ifndef WIN32_LEAN_AND_MEAN
2033 #define WIN32_LEAN_AND_MEAN
2035 #include <windows.h>
2036 #ifdef HAVE_WINSOCK2_H
2037 #include <winsock2.h>
2039 #ifdef HAVE_WINSOCK_H
2040 #include <winsock.h>
2044 #ifdef HAVE_SYS_TYPES_H
2045 #include <sys/types.h>
2047 #ifdef HAVE_SYS_SOCKET_H
2048 #include <sys/socket.h>
2050 #ifdef HAVE_NETINET_IN_H
2051 #include <netinet/in.h>
2053 #ifdef HAVE_ARPA_INET_H
2054 #include <arpa/inet.h>
2061 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
2062 dnl -------------------------------------------------
2063 dnl Check if monotonic clock_gettime is available.
2065 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
2066 AC_REQUIRE([AC_HEADER_TIME])dnl
2067 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
2068 AC_MSG_CHECKING([for monotonic clock_gettime])
2071 #ifdef HAVE_SYS_TYPES_H
2072 #include <sys/types.h>
2074 #ifdef HAVE_SYS_TIME_H
2075 #include <sys/time.h>
2076 #ifdef TIME_WITH_SYS_TIME
2086 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2089 AC_MSG_RESULT([yes])
2090 ac_cv_func_clock_gettime="yes"
2093 ac_cv_func_clock_gettime="no"
2095 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
2096 dnl until library linking and run-time checks for clock_gettime succeed.
2100 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
2101 dnl -------------------------------------------------
2102 dnl If monotonic clock_gettime is available then,
2103 dnl check and prepended to LIBS any needed libraries.
2105 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
2106 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
2108 if test "$ac_cv_func_clock_gettime" = "yes"; then
2110 AC_MSG_CHECKING([for clock_gettime in libraries])
2112 curl_cv_save_LIBS="$LIBS"
2113 curl_cv_gclk_LIBS="unknown"
2115 for x_xlibs in '' '-lrt' '-lposix4' ; do
2116 if test "$curl_cv_gclk_LIBS" = "unknown"; then
2117 if test -z "$x_xlibs"; then
2118 LIBS="$curl_cv_save_LIBS"
2120 LIBS="$x_xlibs $curl_cv_save_LIBS"
2124 #ifdef HAVE_SYS_TYPES_H
2125 #include <sys/types.h>
2127 #ifdef HAVE_SYS_TIME_H
2128 #include <sys/time.h>
2129 #ifdef TIME_WITH_SYS_TIME
2139 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2142 curl_cv_gclk_LIBS="$x_xlibs"
2147 LIBS="$curl_cv_save_LIBS"
2149 case X-"$curl_cv_gclk_LIBS" in
2151 AC_MSG_RESULT([cannot find clock_gettime])
2152 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2153 ac_cv_func_clock_gettime="no"
2156 AC_MSG_RESULT([no additional lib required])
2157 ac_cv_func_clock_gettime="yes"
2160 if test -z "$curl_cv_save_LIBS"; then
2161 LIBS="$curl_cv_gclk_LIBS"
2163 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
2165 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
2166 ac_cv_func_clock_gettime="yes"
2170 dnl only do runtime verification when not cross-compiling
2171 if test "x$cross_compiling" != "xyes" &&
2172 test "$ac_cv_func_clock_gettime" = "yes"; then
2173 AC_MSG_CHECKING([if monotonic clock_gettime works])
2176 #ifdef HAVE_STDLIB_H
2179 #ifdef HAVE_SYS_TYPES_H
2180 #include <sys/types.h>
2182 #ifdef HAVE_SYS_TIME_H
2183 #include <sys/time.h>
2184 #ifdef TIME_WITH_SYS_TIME
2194 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
2200 AC_MSG_RESULT([yes])
2203 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2204 ac_cv_func_clock_gettime="no"
2205 LIBS="$curl_cv_save_LIBS"
2209 case "$ac_cv_func_clock_gettime" in
2211 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
2212 [Define to 1 if you have the clock_gettime function and monotonic timer.])
2221 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
2222 dnl -------------------------------------------------
2223 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
2224 dnl symbol that can be further used in custom template configuration
2225 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
2226 dnl argument for the description. Symbol definitions done with this
2227 dnl macro are intended to be exclusively used in handcrafted *.h.in
2228 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
2229 dnl prevents autoheader generation and insertion of symbol template
2230 dnl stub and definition into the first configuration header file. Do
2231 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
2232 dnl one serves different functional needs.
2234 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
2235 cat >>confdefs.h <<_EOF
2236 [@%:@define] $1 ifelse($#, 2, [$2], 1)
2241 dnl CURL_CONFIGURE_LONG
2242 dnl -------------------------------------------------
2243 dnl Find out the size of long as reported by sizeof() and define
2244 dnl CURL_SIZEOF_LONG as appropriate to be used in template file
2245 dnl include/curl/curlbuild.h.in to properly configure the library.
2246 dnl The size of long is a build time characteristic and as such
2247 dnl must be recorded in curlbuild.h
2249 AC_DEFUN([CURL_CONFIGURE_LONG], [
2250 if test -z "$ac_cv_sizeof_long" ||
2251 test "$ac_cv_sizeof_long" -eq "0"; then
2252 AC_MSG_ERROR([cannot find out size of long.])
2254 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
2258 dnl CURL_CONFIGURE_CURL_SOCKLEN_T
2259 dnl -------------------------------------------------
2260 dnl Find out suitable curl_socklen_t data type definition and size, making
2261 dnl appropriate definitions for template file include/curl/curlbuild.h.in
2262 dnl to properly configure and use the library.
2264 dnl The need for the curl_socklen_t definition arises mainly to properly
2265 dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
2266 dnl data type which is 32 or 64-Bit wide depending on the data model being
2267 dnl used, and that on the other hand is only actually used when interfacing
2268 dnl the X/Open sockets provided in the xnet library.
2270 AC_DEFUN([CURL_CONFIGURE_CURL_SOCKLEN_T], [
2271 AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
2272 AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
2273 AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
2275 AC_MSG_CHECKING([for curl_socklen_t data type])
2276 curl_typeof_curl_socklen_t="unknown"
2277 for arg1 in int SOCKET; do
2278 for arg2 in 'struct sockaddr' void; do
2279 for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
2280 if test "$curl_typeof_curl_socklen_t" = "unknown"; then
2283 $curl_includes_ws2tcpip
2284 $curl_includes_sys_socket
2285 $curl_preprocess_callconv
2286 extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
2289 if(0 != getpeername(0, 0, lenptr))
2293 curl_typeof_curl_socklen_t="$t"
2299 for t in socklen_t int; do
2300 if test "$curl_typeof_curl_socklen_t" = "void"; then
2303 $curl_includes_sys_socket
2304 typedef $t curl_socklen_t;
2306 curl_socklen_t dummy;
2309 curl_typeof_curl_socklen_t="$t"
2313 AC_MSG_RESULT([$curl_typeof_curl_socklen_t])
2314 if test "$curl_typeof_curl_socklen_t" = "void" ||
2315 test "$curl_typeof_curl_socklen_t" = "unknown"; then
2316 AC_MSG_ERROR([cannot find data type for curl_socklen_t.])
2319 AC_MSG_CHECKING([size of curl_socklen_t])
2320 curl_sizeof_curl_socklen_t="unknown"
2321 curl_pull_headers_socklen_t="unknown"
2322 if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
2323 tst_pull_header_checks='none ws2tcpip'
2326 tst_pull_header_checks='none systypes syssocket'
2327 tst_size_checks='4 8 2'
2329 for tst_size in $tst_size_checks; do
2330 for tst_pull_headers in $tst_pull_header_checks; do
2331 if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
2332 case $tst_pull_headers in
2334 tmp_includes="$curl_includes_ws2tcpip"
2337 tmp_includes="$curl_includes_sys_types"
2340 tmp_includes="$curl_includes_sys_socket"
2349 typedef $curl_typeof_curl_socklen_t curl_socklen_t;
2350 typedef char dummy_arr[sizeof(curl_socklen_t) == $tst_size ? 1 : -1];
2352 curl_socklen_t dummy;
2355 curl_sizeof_curl_socklen_t="$tst_size"
2356 curl_pull_headers_socklen_t="$tst_pull_headers"
2361 AC_MSG_RESULT([$curl_sizeof_curl_socklen_t])
2362 if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
2363 AC_MSG_ERROR([cannot find out size of curl_socklen_t.])
2366 case $curl_pull_headers_socklen_t in
2368 CURL_DEFINE_UNQUOTED([CURL_PULL_WS2TCPIP_H])
2371 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
2374 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
2375 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_SOCKET_H])
2378 CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_SOCKLEN_T], [$curl_typeof_curl_socklen_t])
2379 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_SOCKLEN_T], [$curl_sizeof_curl_socklen_t])
2383 dnl CURL_CHECK_FUNC_SELECT
2384 dnl -------------------------------------------------
2385 dnl Test if the socket select() function is available,
2386 dnl and check its return type and the types of its
2387 dnl arguments. If the function succeeds HAVE_SELECT
2388 dnl will be defined, defining the types of the
2389 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
2390 dnl and SELECT_TYPE_ARG5, defining the type of the
2391 dnl function return value in SELECT_TYPE_RETV, and
2392 dnl also defining the type qualifier of fifth argument
2393 dnl in SELECT_QUAL_ARG5.
2395 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
2396 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
2397 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
2399 AC_MSG_CHECKING([for select])
2403 #ifdef HAVE_WINDOWS_H
2404 #ifndef WIN32_LEAN_AND_MEAN
2405 #define WIN32_LEAN_AND_MEAN
2407 #include <windows.h>
2408 #ifdef HAVE_WINSOCK2_H
2409 #include <winsock2.h>
2411 #ifdef HAVE_WINSOCK_H
2412 #include <winsock.h>
2416 #ifdef HAVE_SYS_TYPES_H
2417 #include <sys/types.h>
2419 #ifdef HAVE_SYS_TIME_H
2420 #include <sys/time.h>
2421 #ifdef TIME_WITH_SYS_TIME
2429 #ifndef HAVE_WINDOWS_H
2430 #ifdef HAVE_SYS_SELECT_H
2431 #include <sys/select.h>
2433 #ifdef HAVE_SYS_SOCKET_H
2434 #include <sys/socket.h>
2438 select(0, 0, 0, 0, 0);
2441 AC_MSG_RESULT([yes])
2442 curl_cv_select="yes"
2448 if test "$curl_cv_select" = "yes"; then
2449 AC_CACHE_CHECK([types of args and return type for select],
2450 [curl_cv_func_select_args], [
2451 curl_cv_func_select_args="unknown"
2452 for sel_retv in 'int' 'ssize_t'; do
2453 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2454 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2455 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2456 if test "$curl_cv_func_select_args" = "unknown"; then
2460 #ifdef HAVE_WINDOWS_H
2461 #ifndef WIN32_LEAN_AND_MEAN
2462 #define WIN32_LEAN_AND_MEAN
2464 #include <windows.h>
2465 #ifdef HAVE_WINSOCK2_H
2466 #include <winsock2.h>
2468 #ifdef HAVE_WINSOCK_H
2469 #include <winsock.h>
2472 #define SELECTCALLCONV PASCAL
2474 #ifdef HAVE_SYS_TYPES_H
2475 #include <sys/types.h>
2477 #ifdef HAVE_SYS_TIME_H
2478 #include <sys/time.h>
2479 #ifdef TIME_WITH_SYS_TIME
2487 #ifndef HAVE_WINDOWS_H
2488 #ifdef HAVE_SYS_SELECT_H
2489 #include <sys/select.h>
2491 #ifdef HAVE_SYS_SOCKET_H
2492 #include <sys/socket.h>
2494 #define SELECTCALLCONV
2496 #ifndef HAVE_STRUCT_TIMEVAL
2502 extern $sel_retv SELECTCALLCONV select($sel_arg1,
2512 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2515 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2523 if test "$curl_cv_func_select_args" = "unknown"; then
2524 AC_MSG_WARN([Cannot find proper types to use for select args])
2525 AC_MSG_WARN([HAVE_SELECT will not be defined])
2527 select_prev_IFS=$IFS; IFS=','
2528 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2529 IFS=$select_prev_IFS
2532 sel_qual_type_arg5=$[3]
2534 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2535 [Define to the type of arg 1 for select.])
2536 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2537 [Define to the type of args 2, 3 and 4 for select.])
2538 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2539 [Define to the function return type for select.])
2543 case $prev_sh_opts in
2551 case "$sel_qual_type_arg5" in
2554 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2558 sel_type_arg5=$sel_qual_type_arg5
2562 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2563 [Define to the type qualifier of arg 5 for select.])
2564 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2565 [Define to the type of arg 5 for select.])
2567 case $prev_sh_opts in
2575 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2576 [Define to 1 if you have the select function.])
2577 ac_cv_func_select="yes"
2583 # This is only a temporary fix. This macro is here to replace the broken one
2584 # delivered by the automake project (including the 1.9.6 release). As soon as
2585 # they ship a working version we SHOULD remove this work-around.
2587 AC_DEFUN([AM_MISSING_HAS_RUN],
2588 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2589 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
2590 # Use eval to expand $SHELL
2591 if eval "$MISSING --run true"; then
2592 am_missing_run="$MISSING --run "
2595 AC_MSG_WARN([`missing' script is too old or missing])
2600 dnl CURL_VERIFY_RUNTIMELIBS
2601 dnl -------------------------------------------------
2602 dnl Verify that the shared libs found so far can be used when running
2603 dnl programs, since otherwise the situation will create odd configure errors
2604 dnl that are misleading people.
2606 dnl Make sure this test is run BEFORE the first test in the script that
2607 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
2608 dnl macro. It must also run AFTER all lib-checking macros are complete.
2610 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
2612 dnl this test is of course not sensible if we are cross-compiling!
2613 if test "x$cross_compiling" != xyes; then
2615 dnl just run a program to verify that the libs checked for previous to this
2616 dnl point also is available run-time!
2617 AC_MSG_CHECKING([run-time libs availability])
2624 AC_MSG_RESULT([fine]),
2625 AC_MSG_RESULT([failed])
2626 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
2629 dnl if this test fails, configure has already stopped
2634 dnl CURL_CHECK_VARIADIC_MACROS
2635 dnl -------------------------------------------------
2636 dnl Check compiler support of variadic macros
2638 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
2639 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
2640 [curl_cv_variadic_macros_c99], [
2643 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
2644 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
2645 int fun3(int arg1, int arg2, int arg3);
2646 int fun2(int arg1, int arg2);
2647 int fun3(int arg1, int arg2, int arg3)
2648 { return arg1 + arg2 + arg3; }
2649 int fun2(int arg1, int arg2)
2650 { return arg1 + arg2; }
2652 int res3 = c99_vmacro3(1, 2, 3);
2653 int res2 = c99_vmacro2(1, 2);
2656 curl_cv_variadic_macros_c99="yes"
2658 curl_cv_variadic_macros_c99="no"
2661 case "$curl_cv_variadic_macros_c99" in
2663 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
2664 [Define to 1 if compiler supports C99 variadic macro style.])
2667 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
2668 [curl_cv_variadic_macros_gcc], [
2671 #define gcc_vmacro3(first, args...) fun3(first, args)
2672 #define gcc_vmacro2(first, args...) fun2(first, 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 = gcc_vmacro3(1, 2, 3);
2681 int res2 = gcc_vmacro2(1, 2);
2684 curl_cv_variadic_macros_gcc="yes"
2686 curl_cv_variadic_macros_gcc="no"
2689 case "$curl_cv_variadic_macros_gcc" in
2691 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2692 [Define to 1 if compiler supports old gcc variadic macro style.])
2698 dnl CURL_CHECK_CA_BUNDLE
2699 dnl -------------------------------------------------
2700 dnl Check if a default ca-bundle should be used
2702 dnl regarding the paths this will scan:
2703 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
2704 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
2705 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
2706 dnl /usr/local/share/certs/ca-root.crt FreeBSD
2707 dnl /etc/ssl/cert.pem OpenBSD
2708 dnl /etc/ssl/certs/ (ca path) SUSE
2710 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
2712 AC_MSG_CHECKING([default CA cert bundle/path])
2714 AC_ARG_WITH(ca-bundle,
2715 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
2716 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
2719 if test "x$want_ca" = "xyes"; then
2720 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
2723 [ want_ca="unset" ])
2724 AC_ARG_WITH(ca-path,
2725 AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
2726 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
2728 want_capath="$withval"
2729 if test "x$want_capath" = "xyes"; then
2730 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
2733 [ want_capath="unset"])
2735 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
2736 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2738 AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
2739 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
2740 dnl --with-ca-bundle given
2743 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2744 dnl --with-ca-path given
2745 if test "x$OPENSSL_ENABLED" != "x1"; then
2746 AC_MSG_ERROR([--with-ca-path only works with openSSL])
2748 capath="$want_capath"
2751 dnl neither of --with-ca-* given
2752 dnl first try autodetecting a CA bundle , then a CA path
2753 dnl both autodetections can be skipped by --without-ca-*
2756 if test "x$want_ca" = "xunset"; then
2757 dnl the path we previously would have installed the curl ca bundle
2758 dnl to, and thus we now check for an already existing cert in that place
2759 dnl in case we find no other
2760 if test "x$prefix" != xNONE; then
2761 cac="${prefix}/share/curl/curl-ca-bundle.crt"
2763 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
2766 for a in /etc/ssl/certs/ca-certificates.crt \
2767 /etc/pki/tls/certs/ca-bundle.crt \
2768 /usr/share/ssl/certs/ca-bundle.crt \
2769 /usr/local/share/certs/ca-root.crt \
2772 if test -f "$a"; then
2778 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
2779 "x$OPENSSL_ENABLED" = "x1"; then
2780 for a in /etc/ssl/certs/; do
2781 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
2791 if test "x$ca" != "xno"; then
2792 CURL_CA_BUNDLE='"'$ca'"'
2793 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
2794 AC_SUBST(CURL_CA_BUNDLE)
2795 AC_MSG_RESULT([$ca])
2796 elif test "x$capath" != "xno"; then
2797 CURL_CA_PATH="\"$capath\""
2798 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
2799 AC_MSG_RESULT([$capath (capath)])
2806 dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
2807 dnl -------------------------------------------------
2808 dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
2810 AC_DEFUN([DO_CURL_OFF_T_CHECK], [
2811 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2812 if test "$curl_typeof_curl_off_t" = "unknown" && test ! -z "$1"; then
2816 case AS_TR_SH([$1]) in
2818 tmp_includes="$curl_includes_inttypes"
2819 tmp_source="char f@<:@@:>@ = PRId64;"
2823 tmp_includes="$curl_includes_inttypes"
2824 tmp_source="char f@<:@@:>@ = PRId32;"
2828 tmp_includes="$curl_includes_inttypes"
2829 tmp_source="char f@<:@@:>@ = PRId16;"
2836 typedef $1 curl_off_t;
2837 typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
2843 if test -z "$tmp_fmt"; then
2844 curl_typeof_curl_off_t="$1"
2845 curl_sizeof_curl_off_t="$2"
2847 CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
2848 AS_VAR_PUSHDEF([tmp_HaveFmtDef], [curl_cv_have_def_$tmp_fmt])dnl
2849 AS_VAR_PUSHDEF([tmp_FmtDef], [curl_cv_def_$tmp_fmt])dnl
2850 if test AS_VAR_GET(tmp_HaveFmtDef) = "yes"; then
2851 curl_format_curl_off_t=AS_VAR_GET(tmp_FmtDef)
2852 curl_typeof_curl_off_t="$1"
2853 curl_sizeof_curl_off_t="$2"
2855 AS_VAR_POPDEF([tmp_FmtDef])dnl
2856 AS_VAR_POPDEF([tmp_HaveFmtDef])dnl
2863 dnl DO_CURL_OFF_T_SUFFIX_CHECK (TYPE)
2864 dnl -------------------------------------------------
2865 dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
2867 AC_DEFUN([DO_CURL_OFF_T_SUFFIX_CHECK], [
2868 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2869 AC_MSG_CHECKING([constant suffix string for curl_off_t])
2871 curl_suffix_curl_off_t="unknown"
2872 curl_suffix_curl_off_tu="unknown"
2874 case AS_TR_SH([$1]) in
2875 long_long | __longlong | __longlong_t)
2885 tst_suffixes="LL:i64::"
2888 tst_suffixes="L:i32::"
2891 tst_suffixes="L:i16::"
2894 AC_MSG_ERROR([unexpected data type $1])
2898 old_IFS=$IFS; IFS=':'
2899 for tmp_ssuf in $tst_suffixes ; do
2901 if test "x$curl_suffix_curl_off_t" = "xunknown"; then
2904 tmp_usuf="u$tmp_ssuf"
2907 tmp_usuf="U$tmp_ssuf"
2915 $curl_includes_inttypes
2926 curl_suffix_curl_off_t="$tmp_ssuf"
2927 curl_suffix_curl_off_tu="$tmp_usuf"
2933 if test "x$curl_suffix_curl_off_t" = "xunknown"; then
2934 AC_MSG_ERROR([cannot find constant suffix string for curl_off_t.])
2936 AC_MSG_RESULT([$curl_suffix_curl_off_t])
2937 AC_MSG_CHECKING([constant suffix string for unsigned curl_off_t])
2938 AC_MSG_RESULT([$curl_suffix_curl_off_tu])
2944 dnl CURL_CONFIGURE_CURL_OFF_T
2945 dnl -------------------------------------------------
2946 dnl Find out suitable curl_off_t data type definition and associated
2947 dnl items, and make the appropriate definitions used in template file
2948 dnl include/curl/curlbuild.h.in to properly configure the library.
2950 AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
2951 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2953 AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
2954 AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
2955 AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
2957 if test -z "$SED"; then
2958 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
2961 AC_CHECK_SIZEOF(long)
2962 AC_CHECK_SIZEOF(void*)
2964 if test -z "$ac_cv_sizeof_long" ||
2965 test "$ac_cv_sizeof_long" -eq "0"; then
2966 AC_MSG_ERROR([cannot find out size of long.])
2968 if test -z "$ac_cv_sizeof_voidp" ||
2969 test "$ac_cv_sizeof_voidp" -eq "0"; then
2970 AC_MSG_ERROR([cannot find out size of void*.])
2977 if test "$ac_cv_sizeof_long" -eq "8" &&
2978 test "$ac_cv_sizeof_voidp" -ge "8"; then
2980 elif test "$ac_cv_sizeof_long" -eq "4" &&
2981 test "$ac_cv_sizeof_voidp" -ge "4"; then
2983 elif test "$ac_cv_sizeof_long" -eq "2" &&
2984 test "$ac_cv_sizeof_voidp" -ge "2"; then
2988 dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
2990 curl_typeof_curl_off_t="unknown"
2991 curl_sizeof_curl_off_t="unknown"
2992 curl_format_curl_off_t="unknown"
2993 curl_format_curl_off_tu="unknown"
2995 if test "$curl_typeof_curl_off_t" = "unknown"; then
2996 AC_MSG_CHECKING([for 64-bit curl_off_t data type])
3004 DO_CURL_OFF_T_CHECK([$t8], [8])
3006 AC_MSG_RESULT([$curl_typeof_curl_off_t])
3008 if test "$curl_typeof_curl_off_t" = "unknown"; then
3009 AC_MSG_CHECKING([for 32-bit curl_off_t data type])
3015 DO_CURL_OFF_T_CHECK([$t4], [4])
3017 AC_MSG_RESULT([$curl_typeof_curl_off_t])
3019 if test "$curl_typeof_curl_off_t" = "unknown"; then
3020 AC_MSG_CHECKING([for 16-bit curl_off_t data type])
3026 DO_CURL_OFF_T_CHECK([$t2], [2])
3028 AC_MSG_RESULT([$curl_typeof_curl_off_t])
3030 if test "$curl_typeof_curl_off_t" = "unknown"; then
3031 AC_MSG_ERROR([cannot find data type for curl_off_t.])
3034 AC_MSG_CHECKING([size of curl_off_t])
3035 AC_MSG_RESULT([$curl_sizeof_curl_off_t])
3037 AC_MSG_CHECKING([formatting string directive for curl_off_t])
3038 if test "$curl_format_curl_off_t" != "unknown"; then
3039 x_pull_headers="yes"
3040 curl_format_curl_off_t=`echo "$curl_format_curl_off_t" | "$SED" 's/[["]]//g'`
3041 curl_format_curl_off_tu=`echo "$curl_format_curl_off_t" | "$SED" 's/i$/u/'`
3042 curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/d$/u/'`
3043 curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/D$/U/'`
3046 case AS_TR_SH([$curl_typeof_curl_off_t]) in
3047 long_long | __longlong | __longlong_t)
3048 curl_format_curl_off_t="lld"
3049 curl_format_curl_off_tu="llu"
3052 curl_format_curl_off_t="ld"
3053 curl_format_curl_off_tu="lu"
3056 curl_format_curl_off_t="d"
3057 curl_format_curl_off_tu="u"
3060 curl_format_curl_off_t="I64d"
3061 curl_format_curl_off_tu="I64u"
3064 curl_format_curl_off_t="I32d"
3065 curl_format_curl_off_tu="I32u"
3068 curl_format_curl_off_t="I16d"
3069 curl_format_curl_off_tu="I16u"
3072 AC_MSG_ERROR([cannot find print format string for curl_off_t.])
3076 AC_MSG_RESULT(["$curl_format_curl_off_t"])
3078 AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
3079 AC_MSG_RESULT(["$curl_format_curl_off_tu"])
3081 DO_CURL_OFF_T_SUFFIX_CHECK([$curl_typeof_curl_off_t])
3083 if test "$x_pull_headers" = "yes"; then
3084 if test "x$ac_cv_header_sys_types_h" = "xyes"; then
3085 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
3087 if test "x$ac_cv_header_stdint_h" = "xyes"; then
3088 CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
3090 if test "x$ac_cv_header_inttypes_h" = "xyes"; then
3091 CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
3095 CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_OFF_T], [$curl_typeof_curl_off_t])
3096 CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_T], ["$curl_format_curl_off_t"])
3097 CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_TU], ["$curl_format_curl_off_tu"])
3098 CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$curl_format_curl_off_t"])
3099 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$curl_sizeof_curl_off_t])
3100 CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_T], [$curl_suffix_curl_off_t])
3101 CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_TU], [$curl_suffix_curl_off_tu])
3106 dnl CURL_CHECK_WIN32_LARGEFILE
3107 dnl -------------------------------------------------
3108 dnl Check if curl's WIN32 large file will be used
3110 AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
3111 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
3112 AC_MSG_CHECKING([whether build target supports WIN32 file API])
3113 curl_win32_file_api="no"
3114 if test "$ac_cv_header_windows_h" = "yes"; then
3115 if test x"$enable_largefile" != "xno"; then
3119 #if !defined(_WIN32_WCE) && \
3120 (defined(__MINGW32__) || \
3121 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
3124 WIN32 large file API not supported.
3128 curl_win32_file_api="win32_large_files"
3131 if test "$curl_win32_file_api" = "no"; then
3135 #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
3138 WIN32 small file API not supported.
3142 curl_win32_file_api="win32_small_files"
3146 case "$curl_win32_file_api" in
3148 AC_MSG_RESULT([yes (large file enabled)])
3149 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
3150 [Define to 1 if you are building a Windows target with large file support.])
3153 AC_MSG_RESULT([yes (large file disabled)])
3154 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
3155 [Define to 1 if you are building a Windows target without large file support.])
3163 dnl CURL_CHECK_PKGCONFIG ($module)
3164 dnl ------------------------
3165 dnl search for the pkg-config tool (if not cross-compiling). Set the PKGCONFIG
3166 dnl variable to hold the path to it, or 'no' if not found/present.
3168 dnl If pkg-config is present, check that it has info about the $module or return
3172 AC_DEFUN([CURL_CHECK_PKGCONFIG], [
3173 if test x$cross_compiling != xyes; then
3174 dnl only do pkg-config magic when not cross-compiling
3175 AC_PATH_PROG( PKGCONFIG, pkg-config, no, $PATH:/usr/bin:/usr/local/bin)
3177 if test x$PKGCONFIG != xno; then
3178 AC_MSG_CHECKING([for $1 options with pkg-config])
3179 dnl ask pkg-config about $1
3180 $PKGCONFIG --exists $1
3181 if test "$?" -ne "0"; then
3182 dnl pkg-config does not have info about the given module! set the
3183 dnl variable to 'no'
3187 AC_MSG_RESULT([found])