1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2021, 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 https://curl.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.
21 #***************************************************************************
23 dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
24 dnl -------------------------------------------------
25 dnl Use the C preprocessor to find out if the given object-style symbol
26 dnl is defined and get its expansion. This macro will not use default
27 dnl includes even if no INCLUDES argument is given. This macro will run
28 dnl silently when invoked with three arguments. If the expansion would
29 dnl result in a set of double-quoted strings the returned expansion will
30 dnl actually be a single double-quoted string concatenating all them.
32 AC_DEFUN([CURL_CHECK_DEF], [
33 AC_REQUIRE([CURL_CPP_P])dnl
35 # CPPPFLAG comes from CURL_CPP_P
36 CPPFLAGS="$CPPFLAGS $CPPPFLAG"
37 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
38 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
39 if test -z "$SED"; then
40 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
42 if test -z "$GREP"; then
43 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
45 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
55 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
56 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
57 "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
58 "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
59 if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
63 if test -z "$tmp_exp"; then
64 AS_VAR_SET(ac_HaveDef, no)
65 ifelse($3,,[AC_MSG_RESULT([no])])
67 AS_VAR_SET(ac_HaveDef, yes)
68 AS_VAR_SET(ac_Def, $tmp_exp)
69 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
71 AS_VAR_POPDEF([ac_Def])dnl
72 AS_VAR_POPDEF([ac_HaveDef])dnl
77 dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
78 dnl -------------------------------------------------
79 dnl Use the C compiler to find out only if the given symbol is defined
80 dnl or not, this can not find out its expansion. This macro will not use
81 dnl default includes even if no INCLUDES argument is given. This macro
82 dnl will run silently when invoked with three arguments.
84 AC_DEFUN([CURL_CHECK_DEF_CC], [
85 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
86 ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
95 force compilation error
100 tst_symbol_defined="yes"
102 tst_symbol_defined="no"
104 if test "$tst_symbol_defined" = "yes"; then
105 AS_VAR_SET(ac_HaveDef, yes)
106 ifelse($3,,[AC_MSG_RESULT([yes])])
108 AS_VAR_SET(ac_HaveDef, no)
109 ifelse($3,,[AC_MSG_RESULT([no])])
111 AS_VAR_POPDEF([ac_HaveDef])dnl
115 dnl CURL_CHECK_LIB_XNET
116 dnl -------------------------------------------------
117 dnl Verify if X/Open network library is required.
119 AC_DEFUN([CURL_CHECK_LIB_XNET], [
120 AC_MSG_CHECKING([if X/Open network library is required])
121 tst_lib_xnet_required="no"
126 #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
128 #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
131 force compilation error
136 tst_lib_xnet_required="yes"
139 AC_MSG_RESULT([$tst_lib_xnet_required])
143 dnl CURL_CHECK_AIX_ALL_SOURCE
144 dnl -------------------------------------------------
145 dnl Provides a replacement of traditional AC_AIX with
146 dnl an uniform behavior across all autoconf versions,
147 dnl and with our own placement rules.
149 AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
150 AH_VERBATIM([_ALL_SOURCE],
151 [/* Define to 1 if OS is AIX. */
155 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
156 AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
157 AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
158 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
159 AC_EGREP_CPP([yes_this_is_aix],[
165 AC_DEFINE(_ALL_SOURCE)
172 dnl CURL_CHECK_HEADER_WINDOWS
173 dnl -------------------------------------------------
174 dnl Check for compilable and valid windows.h header
176 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
177 AC_CACHE_CHECK([for windows.h], [curl_cv_header_windows_h], [
181 #ifndef WIN32_LEAN_AND_MEAN
182 #define WIN32_LEAN_AND_MEAN
186 #if defined(__CYGWIN__) || defined(__CEGCC__)
187 HAVE_WINDOWS_H shall not be defined.
193 curl_cv_header_windows_h="yes"
195 curl_cv_header_windows_h="no"
198 case "$curl_cv_header_windows_h" in
200 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
201 [Define to 1 if you have the windows.h header file.])
207 dnl CURL_CHECK_NATIVE_WINDOWS
208 dnl -------------------------------------------------
209 dnl Check if building a native Windows target
211 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
212 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
213 AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [
214 if test "$curl_cv_header_windows_h" = "no"; then
215 curl_cv_native_windows="no"
220 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
221 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
224 Not a native Windows build target.
228 curl_cv_native_windows="yes"
230 curl_cv_native_windows="no"
234 AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes)
238 dnl CURL_CHECK_HEADER_WINSOCK2
239 dnl -------------------------------------------------
240 dnl Check for compilable and valid winsock2.h header
242 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
243 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
244 AC_CACHE_CHECK([for winsock2.h], [curl_cv_header_winsock2_h], [
248 #ifndef WIN32_LEAN_AND_MEAN
249 #define WIN32_LEAN_AND_MEAN
252 #include <winsock2.h>
254 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
255 HAVE_WINSOCK2_H shall not be defined.
257 int dummy=2*IPPROTO_ESP;
261 curl_cv_header_winsock2_h="yes"
263 curl_cv_header_winsock2_h="no"
266 case "$curl_cv_header_winsock2_h" in
268 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
269 [Define to 1 if you have the winsock2.h header file.])
275 dnl CURL_CHECK_HEADER_WS2TCPIP
276 dnl -------------------------------------------------
277 dnl Check for compilable and valid ws2tcpip.h header
279 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
280 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
281 AC_CACHE_CHECK([for ws2tcpip.h], [curl_cv_header_ws2tcpip_h], [
285 #ifndef WIN32_LEAN_AND_MEAN
286 #define WIN32_LEAN_AND_MEAN
289 #include <winsock2.h>
290 #include <ws2tcpip.h>
292 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
293 HAVE_WS2TCPIP_H shall not be defined.
295 int dummy=2*IP_PKTINFO;
299 curl_cv_header_ws2tcpip_h="yes"
301 curl_cv_header_ws2tcpip_h="no"
304 case "$curl_cv_header_ws2tcpip_h" in
306 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
307 [Define to 1 if you have the ws2tcpip.h header file.])
313 dnl CURL_CHECK_HEADER_WINCRYPT
314 dnl -------------------------------------------------
315 dnl Check for compilable and valid wincrypt.h header
317 AC_DEFUN([CURL_CHECK_HEADER_WINCRYPT], [
318 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
319 AC_CACHE_CHECK([for wincrypt.h], [curl_cv_header_wincrypt_h], [
323 #ifndef WIN32_LEAN_AND_MEAN
324 #define WIN32_LEAN_AND_MEAN
327 #include <wincrypt.h>
329 int dummy=2*PROV_RSA_FULL;
332 curl_cv_header_wincrypt_h="yes"
334 curl_cv_header_wincrypt_h="no"
337 case "$curl_cv_header_wincrypt_h" in
339 AC_DEFINE_UNQUOTED(HAVE_WINCRYPT_H, 1,
340 [Define to 1 if you have the wincrypt.h header file.])
346 dnl CURL_CHECK_HEADER_WINLDAP
347 dnl -------------------------------------------------
348 dnl Check for compilable and valid winldap.h header
350 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
351 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
352 AC_CACHE_CHECK([for winldap.h], [curl_cv_header_winldap_h], [
356 #ifdef HAVE_WINDOWS_H
357 #ifndef WIN32_LEAN_AND_MEAN
358 #define WIN32_LEAN_AND_MEAN
364 #if defined(__CYGWIN__) || defined(__CEGCC__)
365 HAVE_WINLDAP_H shall not be defined.
367 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
368 ULONG res = ldap_unbind(ldp);
372 curl_cv_header_winldap_h="yes"
374 curl_cv_header_winldap_h="no"
377 case "$curl_cv_header_winldap_h" in
379 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
380 [Define to 1 if you have the winldap.h header file.])
386 dnl CURL_CHECK_HEADER_WINBER
387 dnl -------------------------------------------------
388 dnl Check for compilable and valid winber.h header
390 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
391 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
392 AC_CACHE_CHECK([for winber.h], [curl_cv_header_winber_h], [
396 #ifdef HAVE_WINDOWS_H
397 #ifndef WIN32_LEAN_AND_MEAN
398 #define WIN32_LEAN_AND_MEAN
405 #if defined(__CYGWIN__) || defined(__CEGCC__)
406 HAVE_WINBER_H shall not be defined.
409 BerElement *bep = ber_init(bvp);
414 curl_cv_header_winber_h="yes"
416 curl_cv_header_winber_h="no"
419 case "$curl_cv_header_winber_h" in
421 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
422 [Define to 1 if you have the winber.h header file.])
428 dnl CURL_CHECK_HEADER_LBER
429 dnl -------------------------------------------------
430 dnl Check for compilable and valid lber.h header,
431 dnl and check if it is needed even with ldap.h
433 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
434 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
435 AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
439 #ifdef HAVE_WINDOWS_H
440 #ifndef WIN32_LEAN_AND_MEAN
441 #define WIN32_LEAN_AND_MEAN
445 #ifdef HAVE_SYS_TYPES_H
446 #include <sys/types.h>
450 #define NULL (void *)0
454 BerValue *bvp = NULL;
455 BerElement *bep = ber_init(bvp);
459 curl_cv_header_lber_h="yes"
461 curl_cv_header_lber_h="no"
464 if test "$curl_cv_header_lber_h" = "yes"; then
465 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
466 [Define to 1 if you have the lber.h header file.])
471 #ifdef HAVE_WINDOWS_H
472 #ifndef WIN32_LEAN_AND_MEAN
473 #define WIN32_LEAN_AND_MEAN
477 #ifdef HAVE_SYS_TYPES_H
478 #include <sys/types.h>
482 #define NULL (void *)0
484 #ifndef LDAP_DEPRECATED
485 #define LDAP_DEPRECATED 1
489 BerValue *bvp = NULL;
490 BerElement *bep = ber_init(bvp);
494 curl_cv_need_header_lber_h="no"
496 curl_cv_need_header_lber_h="yes"
499 case "$curl_cv_need_header_lber_h" in
501 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
502 [Define to 1 if you need the lber.h header file even with ldap.h])
509 dnl CURL_CHECK_HEADER_LDAP
510 dnl -------------------------------------------------
511 dnl Check for compilable and valid ldap.h header
513 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
514 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
515 AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
519 #ifdef HAVE_WINDOWS_H
520 #ifndef WIN32_LEAN_AND_MEAN
521 #define WIN32_LEAN_AND_MEAN
525 #ifdef HAVE_SYS_TYPES_H
526 #include <sys/types.h>
529 #ifndef LDAP_DEPRECATED
530 #define LDAP_DEPRECATED 1
537 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
538 int res = ldap_unbind(ldp);
541 curl_cv_header_ldap_h="yes"
543 curl_cv_header_ldap_h="no"
546 case "$curl_cv_header_ldap_h" in
548 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
549 [Define to 1 if you have the ldap.h header file.])
555 dnl CURL_CHECK_HEADER_LDAP_SSL
556 dnl -------------------------------------------------
557 dnl Check for compilable and valid ldap_ssl.h header
559 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
560 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
561 AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
565 #ifdef HAVE_WINDOWS_H
566 #ifndef WIN32_LEAN_AND_MEAN
567 #define WIN32_LEAN_AND_MEAN
571 #ifdef HAVE_SYS_TYPES_H
572 #include <sys/types.h>
575 #ifndef LDAP_DEPRECATED
576 #define LDAP_DEPRECATED 1
584 #include <ldap_ssl.h>
586 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
589 curl_cv_header_ldap_ssl_h="yes"
591 curl_cv_header_ldap_ssl_h="no"
594 case "$curl_cv_header_ldap_ssl_h" in
596 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
597 [Define to 1 if you have the ldap_ssl.h header file.])
603 dnl CURL_CHECK_HEADER_LDAPSSL
604 dnl -------------------------------------------------
605 dnl Check for compilable and valid ldapssl.h header
607 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
608 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
609 AC_CACHE_CHECK([for ldapssl.h], [curl_cv_header_ldapssl_h], [
613 #ifdef HAVE_WINDOWS_H
614 #ifndef WIN32_LEAN_AND_MEAN
615 #define WIN32_LEAN_AND_MEAN
619 #ifdef HAVE_SYS_TYPES_H
620 #include <sys/types.h>
624 #define NULL (void *)0
626 #ifndef LDAP_DEPRECATED
627 #define LDAP_DEPRECATED 1
637 char *cert_label = NULL;
638 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
641 curl_cv_header_ldapssl_h="yes"
643 curl_cv_header_ldapssl_h="no"
646 case "$curl_cv_header_ldapssl_h" in
648 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
649 [Define to 1 if you have the ldapssl.h header file.])
655 dnl CURL_CHECK_LIBS_WINLDAP
656 dnl -------------------------------------------------
657 dnl Check for libraries needed for WINLDAP support,
658 dnl and prepended to LIBS any needed libraries.
659 dnl This macro can take an optional parameter with a
660 dnl whitespace separated list of libraries to check
661 dnl before the WINLDAP default ones.
663 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
664 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
666 AC_MSG_CHECKING([for WINLDAP libraries])
680 if test -z "$u_libs"; then
683 u_libs="$u_libs $l_lib"
688 curl_cv_save_LIBS="$LIBS"
689 curl_cv_ldap_LIBS="unknown"
691 for x_nlibs in '' "$u_libs" \
693 if test "$curl_cv_ldap_LIBS" = "unknown"; then
694 if test -z "$x_nlibs"; then
695 LIBS="$curl_cv_save_LIBS"
697 LIBS="$x_nlibs $curl_cv_save_LIBS"
702 #ifdef HAVE_WINDOWS_H
703 #ifndef WIN32_LEAN_AND_MEAN
704 #define WIN32_LEAN_AND_MEAN
707 #ifdef HAVE_WINLDAP_H
716 BerElement *bep = ber_init(bvp);
717 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
718 ULONG res = ldap_unbind(ldp);
722 curl_cv_ldap_LIBS="$x_nlibs"
727 LIBS="$curl_cv_save_LIBS"
729 case X-"$curl_cv_ldap_LIBS" in
731 AC_MSG_RESULT([cannot find WINLDAP libraries])
734 AC_MSG_RESULT([no additional lib required])
737 if test -z "$curl_cv_save_LIBS"; then
738 LIBS="$curl_cv_ldap_LIBS"
740 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
742 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
749 dnl CURL_CHECK_LIBS_LDAP
750 dnl -------------------------------------------------
751 dnl Check for libraries needed for LDAP support,
752 dnl and prepended to LIBS any needed libraries.
753 dnl This macro can take an optional parameter with a
754 dnl whitespace separated list of libraries to check
755 dnl before the default ones.
757 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
758 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
760 AC_MSG_CHECKING([for LDAP libraries])
774 if test -z "$u_libs"; then
777 u_libs="$u_libs $l_lib"
782 curl_cv_save_LIBS="$LIBS"
783 curl_cv_ldap_LIBS="unknown"
785 for x_nlibs in '' "$u_libs" \
789 '-lldapssl -lldapx -lldapsdk' \
790 '-lldapsdk -lldapx -lldapssl' \
791 '-lldap -llber -lssl -lcrypto' ; do
793 if test "$curl_cv_ldap_LIBS" = "unknown"; then
794 if test -z "$x_nlibs"; then
795 LIBS="$curl_cv_save_LIBS"
797 LIBS="$x_nlibs $curl_cv_save_LIBS"
802 #ifdef HAVE_WINDOWS_H
803 #ifndef WIN32_LEAN_AND_MEAN
804 #define WIN32_LEAN_AND_MEAN
808 #ifdef HAVE_SYS_TYPES_H
809 #include <sys/types.h>
813 #define NULL (void *)0
815 #ifndef LDAP_DEPRECATED
816 #define LDAP_DEPRECATED 1
825 BerValue *bvp = NULL;
826 BerElement *bep = ber_init(bvp);
827 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
828 int res = ldap_unbind(ldp);
832 curl_cv_ldap_LIBS="$x_nlibs"
837 LIBS="$curl_cv_save_LIBS"
839 case X-"$curl_cv_ldap_LIBS" in
841 AC_MSG_RESULT([cannot find LDAP libraries])
844 AC_MSG_RESULT([no additional lib required])
847 if test -z "$curl_cv_save_LIBS"; then
848 LIBS="$curl_cv_ldap_LIBS"
850 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
852 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
859 dnl CURL_CHECK_HEADER_MALLOC
860 dnl -------------------------------------------------
861 dnl Check for compilable and valid malloc.h header,
862 dnl and check if it is needed even with stdlib.h
864 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
865 AC_CACHE_CHECK([for malloc.h], [curl_cv_header_malloc_h], [
870 void *p = malloc(10);
871 void *q = calloc(10,10);
876 curl_cv_header_malloc_h="yes"
878 curl_cv_header_malloc_h="no"
881 if test "$curl_cv_header_malloc_h" = "yes"; then
882 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
883 [Define to 1 if you have the malloc.h header file.])
889 void *p = malloc(10);
890 void *q = calloc(10,10);
895 curl_cv_need_header_malloc_h="no"
897 curl_cv_need_header_malloc_h="yes"
900 case "$curl_cv_need_header_malloc_h" in
902 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
903 [Define to 1 if you need the malloc.h header file even with stdlib.h])
910 dnl CURL_CHECK_HEADER_MEMORY
911 dnl -------------------------------------------------
912 dnl Check for compilable and valid memory.h header,
913 dnl and check if it is needed even with stdlib.h for
914 dnl memory related functions.
916 AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
917 AC_CACHE_CHECK([for memory.h], [curl_cv_header_memory_h], [
922 void *p = malloc(10);
923 void *q = calloc(10,10);
928 curl_cv_header_memory_h="yes"
930 curl_cv_header_memory_h="no"
933 if test "$curl_cv_header_memory_h" = "yes"; then
934 AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
935 [Define to 1 if you have the memory.h header file.])
941 void *p = malloc(10);
942 void *q = calloc(10,10);
947 curl_cv_need_header_memory_h="no"
949 curl_cv_need_header_memory_h="yes"
952 case "$curl_cv_need_header_memory_h" in
954 AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
955 [Define to 1 if you need the memory.h header file even with stdlib.h])
961 dnl TYPE_SOCKADDR_STORAGE
962 dnl -------------------------------------------------
963 dnl Check for struct sockaddr_storage. Most IPv6-enabled
964 dnl hosts have it, but AIX 4.3 is one known exception.
966 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
968 AC_CHECK_TYPE([struct sockaddr_storage],
969 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
970 [if struct sockaddr_storage is defined]), ,
973 #ifdef HAVE_WINDOWS_H
974 #ifndef WIN32_LEAN_AND_MEAN
975 #define WIN32_LEAN_AND_MEAN
978 #ifdef HAVE_WINSOCK2_H
979 #include <winsock2.h>
982 #ifdef HAVE_SYS_TYPES_H
983 #include <sys/types.h>
985 #ifdef HAVE_SYS_SOCKET_H
986 #include <sys/socket.h>
988 #ifdef HAVE_NETINET_IN_H
989 #include <netinet/in.h>
991 #ifdef HAVE_ARPA_INET_H
992 #include <arpa/inet.h>
998 dnl CURL_CHECK_FUNC_RECV
999 dnl -------------------------------------------------
1000 dnl Test if the socket recv() function is available,
1001 dnl and check its return type and the types of its
1002 dnl arguments. If the function succeeds HAVE_RECV
1003 dnl will be defined, defining the types of the arguments
1004 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1005 dnl and RECV_TYPE_ARG4, defining the type of the function
1006 dnl return value in RECV_TYPE_RETV.
1008 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1009 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1010 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1012 AC_MSG_CHECKING([for recv])
1016 #ifdef HAVE_WINDOWS_H
1017 #ifndef WIN32_LEAN_AND_MEAN
1018 #define WIN32_LEAN_AND_MEAN
1020 #include <windows.h>
1021 #ifdef HAVE_WINSOCK2_H
1022 #include <winsock2.h>
1025 #ifdef HAVE_PROTO_BSDSOCKET_H
1026 #include <proto/bsdsocket.h>
1027 struct Library *SocketBase = NULL;
1029 #ifdef HAVE_SYS_TYPES_H
1030 #include <sys/types.h>
1032 #ifdef HAVE_SYS_SOCKET_H
1033 #include <sys/socket.h>
1040 AC_MSG_RESULT([yes])
1047 if test "$curl_cv_recv" = "yes"; then
1048 AC_CACHE_CHECK([types of args and return type for recv],
1049 [curl_cv_func_recv_args], [
1050 curl_cv_func_recv_args="unknown"
1051 for recv_retv in 'int' 'ssize_t'; do
1052 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1053 for recv_arg2 in 'char *' 'void *'; do
1054 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1055 for recv_arg4 in 'int' 'unsigned int'; do
1056 if test "$curl_cv_func_recv_args" = "unknown"; then
1060 #ifdef HAVE_WINDOWS_H
1061 #ifndef WIN32_LEAN_AND_MEAN
1062 #define WIN32_LEAN_AND_MEAN
1064 #include <windows.h>
1065 #ifdef HAVE_WINSOCK2_H
1066 #include <winsock2.h>
1068 #define RECVCALLCONV PASCAL
1070 #ifdef HAVE_PROTO_BSDSOCKET_H
1071 #include <proto/bsdsocket.h>
1072 struct Library *SocketBase = NULL;
1074 #ifdef HAVE_SYS_TYPES_H
1075 #include <sys/types.h>
1077 #ifdef HAVE_SYS_SOCKET_H
1078 #include <sys/socket.h>
1080 #define RECVCALLCONV
1082 #ifndef HAVE_PROTO_BSDSOCKET_H
1083 extern $recv_retv RECVCALLCONV
1084 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1091 $recv_retv res = recv(s, buf, len, flags);
1094 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1103 if test "$curl_cv_func_recv_args" = "unknown"; then
1104 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1106 recv_prev_IFS=$IFS; IFS=','
1107 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1111 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1112 [Define to the type of arg 1 for recv.])
1113 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1114 [Define to the type of arg 2 for recv.])
1115 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1116 [Define to the type of arg 3 for recv.])
1117 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1118 [Define to the type of arg 4 for recv.])
1119 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1120 [Define to the function return type for recv.])
1122 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1123 [Define to 1 if you have the recv function.])
1124 curl_cv_func_recv="yes"
1127 AC_MSG_ERROR([Unable to link function recv])
1132 dnl CURL_CHECK_FUNC_SEND
1133 dnl -------------------------------------------------
1134 dnl Test if the socket send() function is available,
1135 dnl and check its return type and the types of its
1136 dnl arguments. If the function succeeds HAVE_SEND
1137 dnl will be defined, defining the types of the arguments
1138 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1139 dnl and SEND_TYPE_ARG4, defining the type of the function
1140 dnl return value in SEND_TYPE_RETV, and also defining the
1141 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1143 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1144 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1145 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1147 AC_MSG_CHECKING([for send])
1151 #ifdef HAVE_WINDOWS_H
1152 #ifndef WIN32_LEAN_AND_MEAN
1153 #define WIN32_LEAN_AND_MEAN
1155 #include <windows.h>
1156 #ifdef HAVE_WINSOCK2_H
1157 #include <winsock2.h>
1160 #ifdef HAVE_PROTO_BSDSOCKET_H
1161 #include <proto/bsdsocket.h>
1162 struct Library *SocketBase = NULL;
1164 #ifdef HAVE_SYS_TYPES_H
1165 #include <sys/types.h>
1167 #ifdef HAVE_SYS_SOCKET_H
1168 #include <sys/socket.h>
1175 AC_MSG_RESULT([yes])
1182 if test "$curl_cv_send" = "yes"; then
1183 AC_CACHE_CHECK([types of args and return type for send],
1184 [curl_cv_func_send_args], [
1185 curl_cv_func_send_args="unknown"
1186 for send_retv in 'int' 'ssize_t'; do
1187 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1188 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1189 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1190 for send_arg4 in 'int' 'unsigned int'; do
1191 if test "$curl_cv_func_send_args" = "unknown"; then
1195 #ifdef HAVE_WINDOWS_H
1196 #ifndef WIN32_LEAN_AND_MEAN
1197 #define WIN32_LEAN_AND_MEAN
1199 #include <windows.h>
1200 #ifdef HAVE_WINSOCK2_H
1201 #include <winsock2.h>
1203 #define SENDCALLCONV PASCAL
1205 #ifdef HAVE_PROTO_BSDSOCKET_H
1206 #include <proto/bsdsocket.h>
1207 struct Library *SocketBase = NULL;
1209 #ifdef HAVE_SYS_TYPES_H
1210 #include <sys/types.h>
1212 #ifdef HAVE_SYS_SOCKET_H
1213 #include <sys/socket.h>
1215 #define SENDCALLCONV
1217 #ifndef HAVE_PROTO_BSDSOCKET_H
1218 extern $send_retv SENDCALLCONV
1219 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1225 $send_retv res = send(s, 0, len, flags);
1228 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1237 if test "$curl_cv_func_send_args" = "unknown"; then
1238 AC_MSG_ERROR([Cannot find proper types to use for send args])
1240 send_prev_IFS=$IFS; IFS=','
1241 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1245 send_qual_type_arg2=$[2]
1247 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1248 [Define to the type of arg 1 for send.])
1249 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1250 [Define to the type of arg 3 for send.])
1251 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1252 [Define to the type of arg 4 for send.])
1253 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1254 [Define to the function return type for send.])
1258 case $prev_sh_opts in
1266 case "$send_qual_type_arg2" in
1268 send_qual_arg2=const
1269 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1273 send_type_arg2=$send_qual_type_arg2
1277 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1278 [Define to the type qualifier of arg 2 for send.])
1279 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1280 [Define to the type of arg 2 for send.])
1282 case $prev_sh_opts in
1290 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1291 [Define to 1 if you have the send function.])
1292 curl_cv_func_send="yes"
1295 AC_MSG_ERROR([Unable to link function send])
1299 dnl CURL_CHECK_MSG_NOSIGNAL
1300 dnl -------------------------------------------------
1301 dnl Check for MSG_NOSIGNAL
1303 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1304 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1305 AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
1309 #ifdef HAVE_WINDOWS_H
1310 #ifndef WIN32_LEAN_AND_MEAN
1311 #define WIN32_LEAN_AND_MEAN
1313 #include <windows.h>
1314 #ifdef HAVE_WINSOCK2_H
1315 #include <winsock2.h>
1318 #ifdef HAVE_PROTO_BSDSOCKET_H
1319 #include <proto/bsdsocket.h>
1320 struct Library *SocketBase = NULL;
1322 #ifdef HAVE_SYS_TYPES_H
1323 #include <sys/types.h>
1325 #ifdef HAVE_SYS_SOCKET_H
1326 #include <sys/socket.h>
1330 int flag=MSG_NOSIGNAL;
1333 curl_cv_msg_nosignal="yes"
1335 curl_cv_msg_nosignal="no"
1338 case "$curl_cv_msg_nosignal" in
1340 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1341 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1347 dnl CURL_CHECK_STRUCT_TIMEVAL
1348 dnl -------------------------------------------------
1349 dnl Check for timeval struct
1351 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1352 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1353 AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h)
1354 AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
1358 #ifdef HAVE_WINDOWS_H
1359 #ifndef WIN32_LEAN_AND_MEAN
1360 #define WIN32_LEAN_AND_MEAN
1362 #include <windows.h>
1363 #ifdef HAVE_WINSOCK2_H
1364 #include <winsock2.h>
1367 #ifdef HAVE_SYS_TYPES_H
1368 #include <sys/types.h>
1370 #ifdef HAVE_SYS_TIME_H
1371 #include <sys/time.h>
1374 #ifdef HAVE_SYS_SOCKET_H
1375 #include <sys/socket.h>
1383 curl_cv_struct_timeval="yes"
1385 curl_cv_struct_timeval="no"
1388 case "$curl_cv_struct_timeval" in
1390 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1391 [Define to 1 if you have the timeval struct.])
1398 dnl -------------------------------------------------
1399 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1400 dnl and a few other things.
1402 AC_DEFUN([TYPE_IN_ADDR_T], [
1403 AC_CHECK_TYPE([in_addr_t], ,[
1404 dnl in_addr_t not available
1405 AC_CACHE_CHECK([for in_addr_t equivalent],
1406 [curl_cv_in_addr_t_equiv], [
1407 curl_cv_in_addr_t_equiv="unknown"
1408 for t in "unsigned long" int size_t unsigned long; do
1409 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1413 #ifdef HAVE_WINDOWS_H
1414 #ifndef WIN32_LEAN_AND_MEAN
1415 #define WIN32_LEAN_AND_MEAN
1417 #include <windows.h>
1418 #ifdef HAVE_WINSOCK2_H
1419 #include <winsock2.h>
1422 #ifdef HAVE_SYS_TYPES_H
1423 #include <sys/types.h>
1425 #ifdef HAVE_SYS_SOCKET_H
1426 #include <sys/socket.h>
1428 #ifdef HAVE_NETINET_IN_H
1429 #include <netinet/in.h>
1431 #ifdef HAVE_ARPA_INET_H
1432 #include <arpa/inet.h>
1436 $t data = inet_addr ("1.2.3.4");
1439 curl_cv_in_addr_t_equiv="$t"
1444 case "$curl_cv_in_addr_t_equiv" in
1446 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1449 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1450 [Type to use in place of in_addr_t when system does not provide it.])
1455 #ifdef HAVE_WINDOWS_H
1456 #ifndef WIN32_LEAN_AND_MEAN
1457 #define WIN32_LEAN_AND_MEAN
1459 #include <windows.h>
1460 #ifdef HAVE_WINSOCK2_H
1461 #include <winsock2.h>
1464 #ifdef HAVE_SYS_TYPES_H
1465 #include <sys/types.h>
1467 #ifdef HAVE_SYS_SOCKET_H
1468 #include <sys/socket.h>
1470 #ifdef HAVE_NETINET_IN_H
1471 #include <netinet/in.h>
1473 #ifdef HAVE_ARPA_INET_H
1474 #include <arpa/inet.h>
1481 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1482 dnl -------------------------------------------------
1483 dnl Check if monotonic clock_gettime is available.
1485 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1486 AC_CHECK_HEADERS(sys/types.h sys/time.h)
1487 AC_MSG_CHECKING([for monotonic clock_gettime])
1489 if test "x$dontwant_rt" = "xno" ; then
1492 #ifdef HAVE_SYS_TYPES_H
1493 #include <sys/types.h>
1495 #ifdef HAVE_SYS_TIME_H
1496 #include <sys/time.h>
1501 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1504 AC_MSG_RESULT([yes])
1505 curl_func_clock_gettime="yes"
1508 curl_func_clock_gettime="no"
1511 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1512 dnl until library linking and run-time checks for clock_gettime succeed.
1516 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1517 dnl -------------------------------------------------
1518 dnl If monotonic clock_gettime is available then,
1519 dnl check and prepended to LIBS any needed libraries.
1521 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1522 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1524 if test "$curl_func_clock_gettime" = "yes"; then
1526 AC_MSG_CHECKING([for clock_gettime in libraries])
1528 curl_cv_save_LIBS="$LIBS"
1529 curl_cv_gclk_LIBS="unknown"
1531 for x_xlibs in '' '-lrt' '-lposix4' ; do
1532 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1533 if test -z "$x_xlibs"; then
1534 LIBS="$curl_cv_save_LIBS"
1536 LIBS="$x_xlibs $curl_cv_save_LIBS"
1540 #ifdef HAVE_SYS_TYPES_H
1541 #include <sys/types.h>
1543 #ifdef HAVE_SYS_TIME_H
1544 #include <sys/time.h>
1549 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1552 curl_cv_gclk_LIBS="$x_xlibs"
1557 LIBS="$curl_cv_save_LIBS"
1559 case X-"$curl_cv_gclk_LIBS" in
1561 AC_MSG_RESULT([cannot find clock_gettime])
1562 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1563 curl_func_clock_gettime="no"
1566 AC_MSG_RESULT([no additional lib required])
1567 curl_func_clock_gettime="yes"
1570 if test -z "$curl_cv_save_LIBS"; then
1571 LIBS="$curl_cv_gclk_LIBS"
1573 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1575 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1576 curl_func_clock_gettime="yes"
1580 dnl only do runtime verification when not cross-compiling
1581 if test "x$cross_compiling" != "xyes" &&
1582 test "$curl_func_clock_gettime" = "yes"; then
1583 AC_MSG_CHECKING([if monotonic clock_gettime works])
1586 #ifdef HAVE_STDLIB_H
1589 #ifdef HAVE_SYS_TYPES_H
1590 #include <sys/types.h>
1592 #ifdef HAVE_SYS_TIME_H
1593 #include <sys/time.h>
1598 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1604 AC_MSG_RESULT([yes])
1607 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1608 curl_func_clock_gettime="no"
1609 LIBS="$curl_cv_save_LIBS"
1613 case "$curl_func_clock_gettime" in
1615 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1616 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1625 dnl CURL_CHECK_LIBS_CONNECT
1626 dnl -------------------------------------------------
1627 dnl Verify if network connect function is already available
1628 dnl using current libraries or if another one is required.
1630 AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
1631 AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1632 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
1633 AC_MSG_CHECKING([for connect in libraries])
1634 tst_connect_save_LIBS="$LIBS"
1635 tst_connect_need_LIBS="unknown"
1636 for tst_lib in '' '-lsocket' ; do
1637 if test "$tst_connect_need_LIBS" = "unknown"; then
1638 LIBS="$tst_lib $tst_connect_save_LIBS"
1641 $curl_includes_winsock2
1642 $curl_includes_bsdsocket
1643 #if !defined(HAVE_WINDOWS_H) && !defined(HAVE_PROTO_BSDSOCKET_H)
1644 int connect(int, void*, int);
1647 if(0 != connect(0, 0, 0))
1651 tst_connect_need_LIBS="$tst_lib"
1655 LIBS="$tst_connect_save_LIBS"
1657 case X-"$tst_connect_need_LIBS" in
1659 AC_MSG_RESULT([cannot find connect])
1660 AC_MSG_ERROR([cannot find connect function in libraries.])
1663 AC_MSG_RESULT([yes])
1666 AC_MSG_RESULT([$tst_connect_need_LIBS])
1667 LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
1673 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
1674 dnl -------------------------------------------------
1675 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
1676 dnl symbol that can be further used in custom template configuration
1677 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
1678 dnl argument for the description. Symbol definitions done with this
1679 dnl macro are intended to be exclusively used in handcrafted *.h.in
1680 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
1681 dnl prevents autoheader generation and insertion of symbol template
1682 dnl stub and definition into the first configuration header file. Do
1683 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
1684 dnl one serves different functional needs.
1686 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
1687 cat >>confdefs.h <<_EOF
1688 [@%:@define] $1 ifelse($#, 2, [$2], 1)
1692 dnl CURL_CONFIGURE_PULL_SYS_POLL
1693 dnl -------------------------------------------------
1694 dnl The need for the sys/poll.h inclusion arises mainly to properly
1695 dnl interface AIX systems which define macros 'events' and 'revents'.
1697 AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
1698 AC_REQUIRE([CURL_INCLUDES_POLL])dnl
1700 tst_poll_events_macro_defined="unknown"
1706 #if defined(events) || defined(revents)
1709 force compilation error
1713 tst_poll_events_macro_defined="yes"
1715 tst_poll_events_macro_defined="no"
1718 if test "$tst_poll_events_macro_defined" = "yes"; then
1719 if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
1720 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
1727 dnl CURL_CHECK_FUNC_SELECT
1728 dnl -------------------------------------------------
1729 dnl Test if the socket select() function is available,
1730 dnl and check its return type and the types of its
1731 dnl arguments. If the function succeeds HAVE_SELECT
1732 dnl will be defined, defining the types of the
1733 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
1734 dnl and SELECT_TYPE_ARG5, defining the type of the
1735 dnl function return value in SELECT_TYPE_RETV, and
1736 dnl also defining the type qualifier of fifth argument
1737 dnl in SELECT_QUAL_ARG5.
1739 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
1740 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
1741 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1743 AC_MSG_CHECKING([for select])
1747 #ifdef HAVE_WINDOWS_H
1748 #ifndef WIN32_LEAN_AND_MEAN
1749 #define WIN32_LEAN_AND_MEAN
1751 #include <windows.h>
1752 #ifdef HAVE_WINSOCK2_H
1753 #include <winsock2.h>
1756 #ifdef HAVE_SYS_TYPES_H
1757 #include <sys/types.h>
1759 #ifdef HAVE_SYS_TIME_H
1760 #include <sys/time.h>
1763 #ifndef HAVE_WINDOWS_H
1764 #ifdef HAVE_SYS_SELECT_H
1765 #include <sys/select.h>
1766 #elif defined(HAVE_UNISTD_H)
1769 #ifdef HAVE_SYS_SOCKET_H
1770 #include <sys/socket.h>
1772 #ifdef HAVE_PROTO_BSDSOCKET_H
1773 #include <proto/bsdsocket.h>
1774 struct Library *SocketBase = NULL;
1775 #define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
1779 select(0, 0, 0, 0, 0);
1782 AC_MSG_RESULT([yes])
1783 curl_cv_select="yes"
1789 if test "$curl_cv_select" = "yes"; then
1790 AC_CACHE_CHECK([types of args and return type for select],
1791 [curl_cv_func_select_args], [
1792 curl_cv_func_select_args="unknown"
1793 for sel_retv in 'int' 'ssize_t'; do
1794 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
1795 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
1796 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
1797 if test "$curl_cv_func_select_args" = "unknown"; then
1801 #ifdef HAVE_WINDOWS_H
1802 #ifndef WIN32_LEAN_AND_MEAN
1803 #define WIN32_LEAN_AND_MEAN
1805 #include <windows.h>
1806 #ifdef HAVE_WINSOCK2_H
1807 #include <winsock2.h>
1809 #define SELECTCALLCONV PASCAL
1811 #ifdef HAVE_SYS_TYPES_H
1812 #include <sys/types.h>
1814 #ifdef HAVE_SYS_TIME_H
1815 #include <sys/time.h>
1818 #ifndef HAVE_WINDOWS_H
1819 #ifdef HAVE_SYS_SELECT_H
1820 #include <sys/select.h>
1821 #elif defined(HAVE_UNISTD_H)
1824 #ifdef HAVE_SYS_SOCKET_H
1825 #include <sys/socket.h>
1827 #ifdef HAVE_PROTO_BSDSOCKET_H
1828 #include <proto/bsdsocket.h>
1829 struct Library *SocketBase = NULL;
1830 #define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
1832 #define SELECTCALLCONV
1834 #ifndef HAVE_STRUCT_TIMEVAL
1840 #ifndef HAVE_PROTO_BSDSOCKET_H
1841 extern $sel_retv SELECTCALLCONV
1853 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
1856 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
1864 if test "$curl_cv_func_select_args" = "unknown"; then
1865 AC_MSG_WARN([Cannot find proper types to use for select args])
1866 AC_MSG_WARN([HAVE_SELECT will not be defined])
1868 select_prev_IFS=$IFS; IFS=','
1869 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
1870 IFS=$select_prev_IFS
1873 sel_qual_type_arg5=$[3]
1875 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
1876 [Define to the type of arg 1 for select.])
1877 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
1878 [Define to the type of args 2, 3 and 4 for select.])
1879 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
1880 [Define to the function return type for select.])
1884 case $prev_sh_opts in
1892 case "$sel_qual_type_arg5" in
1895 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
1899 sel_type_arg5=$sel_qual_type_arg5
1903 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
1904 [Define to the type qualifier of arg 5 for select.])
1905 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
1906 [Define to the type of arg 5 for select.])
1908 case $prev_sh_opts in
1916 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
1917 [Define to 1 if you have the select function.])
1918 curl_cv_func_select="yes"
1924 dnl CURL_VERIFY_RUNTIMELIBS
1925 dnl -------------------------------------------------
1926 dnl Verify that the shared libs found so far can be used when running
1927 dnl programs, since otherwise the situation will create odd configure errors
1928 dnl that are misleading people.
1930 dnl Make sure this test is run BEFORE the first test in the script that
1931 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
1932 dnl macro. It must also run AFTER all lib-checking macros are complete.
1934 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
1936 dnl this test is of course not sensible if we are cross-compiling!
1937 if test "x$cross_compiling" != xyes; then
1939 dnl just run a program to verify that the libs checked for previous to this
1940 dnl point also is available run-time!
1941 AC_MSG_CHECKING([run-time libs availability])
1948 AC_MSG_RESULT([fine]),
1949 AC_MSG_RESULT([failed])
1950 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
1953 dnl if this test fails, configure has already stopped
1958 dnl CURL_CHECK_VARIADIC_MACROS
1959 dnl -------------------------------------------------
1960 dnl Check compiler support of variadic macros
1962 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
1963 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
1964 [curl_cv_variadic_macros_c99], [
1967 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
1968 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
1969 int fun3(int arg1, int arg2, int arg3);
1970 int fun2(int arg1, int arg2);
1971 int fun3(int arg1, int arg2, int arg3)
1972 { return arg1 + arg2 + arg3; }
1973 int fun2(int arg1, int arg2)
1974 { return arg1 + arg2; }
1976 int res3 = c99_vmacro3(1, 2, 3);
1977 int res2 = c99_vmacro2(1, 2);
1980 curl_cv_variadic_macros_c99="yes"
1982 curl_cv_variadic_macros_c99="no"
1985 case "$curl_cv_variadic_macros_c99" in
1987 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
1988 [Define to 1 if compiler supports C99 variadic macro style.])
1991 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
1992 [curl_cv_variadic_macros_gcc], [
1995 #define gcc_vmacro3(first, args...) fun3(first, args)
1996 #define gcc_vmacro2(first, args...) fun2(first, args)
1997 int fun3(int arg1, int arg2, int arg3);
1998 int fun2(int arg1, int arg2);
1999 int fun3(int arg1, int arg2, int arg3)
2000 { return arg1 + arg2 + arg3; }
2001 int fun2(int arg1, int arg2)
2002 { return arg1 + arg2; }
2004 int res3 = gcc_vmacro3(1, 2, 3);
2005 int res2 = gcc_vmacro2(1, 2);
2008 curl_cv_variadic_macros_gcc="yes"
2010 curl_cv_variadic_macros_gcc="no"
2013 case "$curl_cv_variadic_macros_gcc" in
2015 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2016 [Define to 1 if compiler supports old gcc variadic macro style.])
2022 dnl CURL_CHECK_CA_BUNDLE
2023 dnl -------------------------------------------------
2024 dnl Check if a default ca-bundle should be used
2026 dnl regarding the paths this will scan:
2027 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
2028 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
2029 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
2030 dnl /usr/local/share/certs/ca-root-nss.crt FreeBSD, MidnightBSD
2031 dnl /etc/ssl/cert.pem OpenBSD, FreeBSD, MidnightBSD (symlink)
2032 dnl /etc/ssl/certs/ (ca path) SUSE
2034 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
2036 AC_MSG_CHECKING([default CA cert bundle/path])
2038 AC_ARG_WITH(ca-bundle,
2039 AS_HELP_STRING([--with-ca-bundle=FILE],
2040 [Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
2041 AS_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
2044 if test "x$want_ca" = "xyes"; then
2045 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
2048 [ want_ca="unset" ])
2049 AC_ARG_WITH(ca-path,
2050 AS_HELP_STRING([--with-ca-path=DIRECTORY],
2051 [Path to a directory containing CA certificates stored individually, with \
2052 their filenames in a hash format. This option can be used with the OpenSSL, \
2053 GnuTLS and mbedTLS backends. Refer to OpenSSL c_rehash for details. \
2054 (example: /etc/certificates)])
2055 AS_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
2057 want_capath="$withval"
2058 if test "x$want_capath" = "xyes"; then
2059 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
2062 [ want_capath="unset"])
2064 ca_warning=" (warning: certs not found)"
2065 capath_warning=" (warning: certs not found)"
2068 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
2069 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2072 capath="$want_capath"
2073 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
2074 dnl --with-ca-bundle given
2077 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2078 dnl --with-ca-path given
2079 if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1" -a "x$MBEDTLS_ENABLED" != "x1"; then
2080 AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS or mbedTLS])
2082 capath="$want_capath"
2085 dnl first try autodetecting a CA bundle , then a CA path
2086 dnl both autodetections can be skipped by --without-ca-*
2089 if test "x$cross_compiling" != "xyes"; then
2090 dnl NOT cross-compiling and...
2091 dnl neither of the --with-ca-* options are provided
2092 if test "x$want_ca" = "xunset"; then
2093 dnl the path we previously would have installed the curl ca bundle
2094 dnl to, and thus we now check for an already existing cert in that
2095 dnl place in case we find no other
2096 if test "x$prefix" != xNONE; then
2097 cac="${prefix}/share/curl/curl-ca-bundle.crt"
2099 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
2102 for a in /etc/ssl/certs/ca-certificates.crt \
2103 /etc/pki/tls/certs/ca-bundle.crt \
2104 /usr/share/ssl/certs/ca-bundle.crt \
2105 /usr/local/share/certs/ca-root-nss.crt \
2108 if test -f "$a"; then
2114 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
2115 "x$OPENSSL_ENABLED" = "x1"; then
2116 check_capath="/etc/ssl/certs/"
2119 dnl no option given and cross-compiling
2120 AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
2124 if test "x$ca" = "xno" || test -f "$ca"; then
2128 if test "x$capath" != "xno"; then
2129 check_capath="$capath"
2132 if test ! -z "$check_capath"; then
2133 for a in "$check_capath"; do
2134 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
2135 if test "x$capath" = "xno"; then
2144 if test "x$capath" = "xno"; then
2148 if test "x$ca" != "xno"; then
2149 CURL_CA_BUNDLE='"'$ca'"'
2150 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
2151 AC_SUBST(CURL_CA_BUNDLE)
2152 AC_MSG_RESULT([$ca])
2154 if test "x$capath" != "xno"; then
2155 CURL_CA_PATH="\"$capath\""
2156 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
2157 AC_MSG_RESULT([$capath (capath)])
2159 if test "x$ca" = "xno" && test "x$capath" = "xno"; then
2163 AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
2164 AC_ARG_WITH(ca-fallback,
2165 AS_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
2166 AS_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
2168 if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
2169 AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
2172 [ with_ca_fallback="no"])
2173 AC_MSG_RESULT([$with_ca_fallback])
2174 if test "x$with_ca_fallback" = "xyes"; then
2175 if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
2176 AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
2178 AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
2182 dnl CURL_CHECK_WIN32_LARGEFILE
2183 dnl -------------------------------------------------
2184 dnl Check if curl's WIN32 large file will be used
2186 AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
2187 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
2188 AC_MSG_CHECKING([whether build target supports WIN32 file API])
2189 curl_win32_file_api="no"
2190 if test "$curl_cv_header_windows_h" = "yes"; then
2191 if test x"$enable_largefile" != "xno"; then
2195 #if !defined(_WIN32_WCE) && \
2196 (defined(__MINGW32__) || \
2197 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
2200 WIN32 large file API not supported.
2204 curl_win32_file_api="win32_large_files"
2207 if test "$curl_win32_file_api" = "no"; then
2211 #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
2214 WIN32 small file API not supported.
2218 curl_win32_file_api="win32_small_files"
2222 case "$curl_win32_file_api" in
2224 AC_MSG_RESULT([yes (large file enabled)])
2225 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
2226 [Define to 1 if you are building a Windows target with large file support.])
2227 AC_SUBST(USE_WIN32_LARGE_FILES, [1])
2230 AC_MSG_RESULT([yes (large file disabled)])
2231 AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
2232 [Define to 1 if you are building a Windows target without large file support.])
2233 AC_SUBST(USE_WIN32_SMALL_FILES, [1])
2241 dnl CURL_CHECK_WIN32_CRYPTO
2242 dnl -------------------------------------------------
2243 dnl Check if curl's WIN32 crypto lib can be used
2245 AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [
2246 AC_REQUIRE([CURL_CHECK_HEADER_WINCRYPT])dnl
2247 AC_MSG_CHECKING([whether build target supports WIN32 crypto API])
2248 curl_win32_crypto_api="no"
2249 if test "$curl_cv_header_wincrypt_h" = "yes"; then
2253 #ifndef WIN32_LEAN_AND_MEAN
2254 #define WIN32_LEAN_AND_MEAN
2256 #include <windows.h>
2257 #include <wincrypt.h>
2259 HCRYPTPROV hCryptProv;
2260 if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
2261 CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
2262 CryptReleaseContext(hCryptProv, 0);
2266 curl_win32_crypto_api="yes"
2269 case "$curl_win32_crypto_api" in
2271 AC_MSG_RESULT([yes])
2272 AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1,
2273 [Define to 1 if you are building a Windows target with crypto API support.])
2274 AC_SUBST(USE_WIN32_CRYPTO, [1])
2282 dnl CURL_EXPORT_PCDIR ($pcdir)
2283 dnl ------------------------
2284 dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
2286 dnl we need this macro since pkg-config distinguishes among empty and unset
2287 dnl variable while checking PKG_CONFIG_LIBDIR
2290 AC_DEFUN([CURL_EXPORT_PCDIR], [
2291 if test -n "$1"; then
2292 PKG_CONFIG_LIBDIR="$1"
2293 export PKG_CONFIG_LIBDIR
2297 dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
2298 dnl ------------------------
2299 dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
2300 dnl path to it, or 'no' if not found/present.
2302 dnl If pkg-config is present, check that it has info about the $module or
2303 dnl return "no" anyway!
2305 dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
2308 AC_DEFUN([CURL_CHECK_PKGCONFIG], [
2309 if test -n "$PKG_CONFIG"; then
2310 PKGCONFIG="$PKG_CONFIG"
2312 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
2313 [$PATH:/usr/bin:/usr/local/bin])
2316 if test "x$PKGCONFIG" != "xno"; then
2317 AC_MSG_CHECKING([for $1 options with pkg-config])
2318 dnl ask pkg-config about $1
2319 itexists=`CURL_EXPORT_PCDIR([$2]) dnl
2320 $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
2322 if test -z "$itexists"; then
2323 dnl pkg-config does not have info about the given module! set the
2324 dnl variable to 'no'
2328 AC_MSG_RESULT([found])
2334 dnl CURL_GENERATE_CONFIGUREHELP_PM
2335 dnl -------------------------------------------------
2336 dnl Generate test harness configurehelp.pm module, defining and
2337 dnl initializing some perl variables with values which are known
2338 dnl when the configure script runs. For portability reasons, test
2339 dnl harness needs information on how to run the C preprocessor.
2341 AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
2342 AC_REQUIRE([AC_PROG_CPP])dnl
2343 tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
2344 if test -z "$tmp_cpp"; then
2347 cat >./tests/configurehelp.pm <<_EOF
2348 [@%:@] This is a generated file. Do not edit.
2350 package configurehelp;
2362 @ISA = qw(Exporter);
2368 \$Cpreprocessor = '$tmp_cpp';
2376 dnl Check if $cpp -P should be used for extract define values due to gcc 5
2377 dnl splitting up strings and defines between line outputs. gcc by default
2378 dnl (without -P) will show TEST EINVAL TEST as
2380 dnl # 13 "conftest.c"
2382 dnl # 13 "conftest.c" 3 4
2384 dnl # 13 "conftest.c"
2387 AC_DEFUN([CURL_CPP_P], [
2388 AC_MSG_CHECKING([if cpp -P is needed])
2389 AC_EGREP_CPP([TEST.*TEST], [
2392 ], [cpp=no], [cpp=yes])
2393 AC_MSG_RESULT([$cpp])
2395 dnl we need cpp -P so check if it works then
2396 if test "x$cpp" = "xyes"; then
2397 AC_MSG_CHECKING([if cpp -P works])
2398 OLDCPPFLAGS=$CPPFLAGS
2399 CPPFLAGS="$CPPFLAGS -P"
2400 AC_EGREP_CPP([TEST.*TEST], [
2403 ], [cpp_p=yes], [cpp_p=no])
2404 AC_MSG_RESULT([$cpp_p])
2406 if test "x$cpp_p" = "xno"; then
2407 AC_MSG_WARN([failed to figure out cpp -P alternative])
2414 dnl restore CPPFLAGS
2415 CPPFLAGS=$OLDCPPFLAGS
2423 dnl CURL_DARWIN_CFLAGS
2425 dnl Set -Werror=partial-availability to detect possible breaking code
2426 dnl with very low deployment targets.
2429 AC_DEFUN([CURL_DARWIN_CFLAGS], [
2438 AC_MSG_CHECKING([for good-to-use Darwin CFLAGS])
2439 AC_MSG_RESULT([$tst_cflags]);
2441 if test "$tst_cflags" = "yes"; then
2443 CFLAGS="$CFLAGS -Werror=partial-availability"
2444 AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
2445 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
2446 [AC_MSG_RESULT([yes])],
2447 [AC_MSG_RESULT([no])
2448 CFLAGS=$old_CFLAGS])
2454 dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
2456 dnl Check to see if the compiler supports __builtin_available. This built-in
2457 dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
2458 dnl the time this macro was written, the function was not yet documented. Its
2459 dnl purpose is to return true if the code is running under a certain OS version
2462 AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
2463 AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
2468 if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
2471 AC_MSG_RESULT([yes])
2472 AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
2473 [Define to 1 if you have the __builtin_available function.])