1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2018, 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.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.
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 behaviour 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_WINSOCK
239 dnl -------------------------------------------------
240 dnl Check for compilable and valid winsock.h header
242 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
243 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
244 AC_CACHE_CHECK([for winsock.h], [curl_cv_header_winsock_h], [
248 #ifndef WIN32_LEAN_AND_MEAN
249 #define WIN32_LEAN_AND_MEAN
254 #if defined(__CYGWIN__) || defined(__CEGCC__)
255 HAVE_WINSOCK_H shall not be defined.
257 int dummy=WSACleanup();
261 curl_cv_header_winsock_h="yes"
263 curl_cv_header_winsock_h="no"
266 case "$curl_cv_header_winsock_h" in
268 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
269 [Define to 1 if you have the winsock.h header file.])
275 dnl CURL_CHECK_HEADER_WINSOCK2
276 dnl -------------------------------------------------
277 dnl Check for compilable and valid winsock2.h header
279 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
280 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
281 AC_CACHE_CHECK([for winsock2.h], [curl_cv_header_winsock2_h], [
285 #ifndef WIN32_LEAN_AND_MEAN
286 #define WIN32_LEAN_AND_MEAN
289 #include <winsock2.h>
291 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
292 HAVE_WINSOCK2_H shall not be defined.
294 int dummy=2*IPPROTO_ESP;
298 curl_cv_header_winsock2_h="yes"
300 curl_cv_header_winsock2_h="no"
303 case "$curl_cv_header_winsock2_h" in
305 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
306 [Define to 1 if you have the winsock2.h header file.])
312 dnl CURL_CHECK_HEADER_WS2TCPIP
313 dnl -------------------------------------------------
314 dnl Check for compilable and valid ws2tcpip.h header
316 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
317 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
318 AC_CACHE_CHECK([for ws2tcpip.h], [curl_cv_header_ws2tcpip_h], [
322 #ifndef WIN32_LEAN_AND_MEAN
323 #define WIN32_LEAN_AND_MEAN
326 #include <winsock2.h>
327 #include <ws2tcpip.h>
329 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
330 HAVE_WS2TCPIP_H shall not be defined.
332 int dummy=2*IP_PKTINFO;
336 curl_cv_header_ws2tcpip_h="yes"
338 curl_cv_header_ws2tcpip_h="no"
341 case "$curl_cv_header_ws2tcpip_h" in
343 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
344 [Define to 1 if you have the ws2tcpip.h header file.])
350 dnl CURL_CHECK_HEADER_WINLDAP
351 dnl -------------------------------------------------
352 dnl Check for compilable and valid winldap.h header
354 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
355 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
356 AC_CACHE_CHECK([for winldap.h], [curl_cv_header_winldap_h], [
360 #ifdef HAVE_WINDOWS_H
361 #ifndef WIN32_LEAN_AND_MEAN
362 #define WIN32_LEAN_AND_MEAN
368 #if defined(__CYGWIN__) || defined(__CEGCC__)
369 HAVE_WINLDAP_H shall not be defined.
371 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
372 ULONG res = ldap_unbind(ldp);
376 curl_cv_header_winldap_h="yes"
378 curl_cv_header_winldap_h="no"
381 case "$curl_cv_header_winldap_h" in
383 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
384 [Define to 1 if you have the winldap.h header file.])
390 dnl CURL_CHECK_HEADER_WINBER
391 dnl -------------------------------------------------
392 dnl Check for compilable and valid winber.h header
394 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
395 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
396 AC_CACHE_CHECK([for winber.h], [curl_cv_header_winber_h], [
400 #ifdef HAVE_WINDOWS_H
401 #ifndef WIN32_LEAN_AND_MEAN
402 #define WIN32_LEAN_AND_MEAN
409 #if defined(__CYGWIN__) || defined(__CEGCC__)
410 HAVE_WINBER_H shall not be defined.
413 BerElement *bep = ber_init(bvp);
418 curl_cv_header_winber_h="yes"
420 curl_cv_header_winber_h="no"
423 case "$curl_cv_header_winber_h" in
425 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
426 [Define to 1 if you have the winber.h header file.])
432 dnl CURL_CHECK_HEADER_LBER
433 dnl -------------------------------------------------
434 dnl Check for compilable and valid lber.h header,
435 dnl and check if it is needed even with ldap.h
437 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
438 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
439 AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
443 #ifdef HAVE_WINDOWS_H
444 #ifndef WIN32_LEAN_AND_MEAN
445 #define WIN32_LEAN_AND_MEAN
449 #ifdef HAVE_SYS_TYPES_H
450 #include <sys/types.h>
454 #define NULL (void *)0
458 BerValue *bvp = NULL;
459 BerElement *bep = ber_init(bvp);
463 curl_cv_header_lber_h="yes"
465 curl_cv_header_lber_h="no"
468 if test "$curl_cv_header_lber_h" = "yes"; then
469 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
470 [Define to 1 if you have the lber.h header file.])
475 #ifdef HAVE_WINDOWS_H
476 #ifndef WIN32_LEAN_AND_MEAN
477 #define WIN32_LEAN_AND_MEAN
481 #ifdef HAVE_SYS_TYPES_H
482 #include <sys/types.h>
486 #define NULL (void *)0
488 #ifndef LDAP_DEPRECATED
489 #define LDAP_DEPRECATED 1
493 BerValue *bvp = NULL;
494 BerElement *bep = ber_init(bvp);
498 curl_cv_need_header_lber_h="no"
500 curl_cv_need_header_lber_h="yes"
503 case "$curl_cv_need_header_lber_h" in
505 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
506 [Define to 1 if you need the lber.h header file even with ldap.h])
513 dnl CURL_CHECK_HEADER_LDAP
514 dnl -------------------------------------------------
515 dnl Check for compilable and valid ldap.h header
517 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
518 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
519 AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
523 #ifdef HAVE_WINDOWS_H
524 #ifndef WIN32_LEAN_AND_MEAN
525 #define WIN32_LEAN_AND_MEAN
529 #ifdef HAVE_SYS_TYPES_H
530 #include <sys/types.h>
533 #ifndef LDAP_DEPRECATED
534 #define LDAP_DEPRECATED 1
541 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
542 int res = ldap_unbind(ldp);
545 curl_cv_header_ldap_h="yes"
547 curl_cv_header_ldap_h="no"
550 case "$curl_cv_header_ldap_h" in
552 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
553 [Define to 1 if you have the ldap.h header file.])
559 dnl CURL_CHECK_HEADER_LDAP_SSL
560 dnl -------------------------------------------------
561 dnl Check for compilable and valid ldap_ssl.h header
563 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
564 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
565 AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
569 #ifdef HAVE_WINDOWS_H
570 #ifndef WIN32_LEAN_AND_MEAN
571 #define WIN32_LEAN_AND_MEAN
575 #ifdef HAVE_SYS_TYPES_H
576 #include <sys/types.h>
579 #ifndef LDAP_DEPRECATED
580 #define LDAP_DEPRECATED 1
588 #include <ldap_ssl.h>
590 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
593 curl_cv_header_ldap_ssl_h="yes"
595 curl_cv_header_ldap_ssl_h="no"
598 case "$curl_cv_header_ldap_ssl_h" in
600 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
601 [Define to 1 if you have the ldap_ssl.h header file.])
607 dnl CURL_CHECK_HEADER_LDAPSSL
608 dnl -------------------------------------------------
609 dnl Check for compilable and valid ldapssl.h header
611 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
612 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
613 AC_CACHE_CHECK([for ldapssl.h], [curl_cv_header_ldapssl_h], [
617 #ifdef HAVE_WINDOWS_H
618 #ifndef WIN32_LEAN_AND_MEAN
619 #define WIN32_LEAN_AND_MEAN
623 #ifdef HAVE_SYS_TYPES_H
624 #include <sys/types.h>
628 #define NULL (void *)0
630 #ifndef LDAP_DEPRECATED
631 #define LDAP_DEPRECATED 1
641 char *cert_label = NULL;
642 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
645 curl_cv_header_ldapssl_h="yes"
647 curl_cv_header_ldapssl_h="no"
650 case "$curl_cv_header_ldapssl_h" in
652 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
653 [Define to 1 if you have the ldapssl.h header file.])
659 dnl CURL_CHECK_LIBS_WINLDAP
660 dnl -------------------------------------------------
661 dnl Check for libraries needed for WINLDAP support,
662 dnl and prepended to LIBS any needed libraries.
663 dnl This macro can take an optional parameter with a
664 dnl white space separated list of libraries to check
665 dnl before the WINLDAP default ones.
667 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
668 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
670 AC_MSG_CHECKING([for WINLDAP libraries])
684 if test -z "$u_libs"; then
687 u_libs="$u_libs $l_lib"
692 curl_cv_save_LIBS="$LIBS"
693 curl_cv_ldap_LIBS="unknown"
695 for x_nlibs in '' "$u_libs" \
697 if test "$curl_cv_ldap_LIBS" = "unknown"; then
698 if test -z "$x_nlibs"; then
699 LIBS="$curl_cv_save_LIBS"
701 LIBS="$x_nlibs $curl_cv_save_LIBS"
706 #ifdef HAVE_WINDOWS_H
707 #ifndef WIN32_LEAN_AND_MEAN
708 #define WIN32_LEAN_AND_MEAN
711 #ifdef HAVE_WINLDAP_H
720 BerElement *bep = ber_init(bvp);
721 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
722 ULONG res = ldap_unbind(ldp);
726 curl_cv_ldap_LIBS="$x_nlibs"
731 LIBS="$curl_cv_save_LIBS"
733 case X-"$curl_cv_ldap_LIBS" in
735 AC_MSG_RESULT([cannot find WINLDAP libraries])
738 AC_MSG_RESULT([no additional lib required])
741 if test -z "$curl_cv_save_LIBS"; then
742 LIBS="$curl_cv_ldap_LIBS"
744 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
746 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
753 dnl CURL_CHECK_LIBS_LDAP
754 dnl -------------------------------------------------
755 dnl Check for libraries needed for LDAP support,
756 dnl and prepended to LIBS any needed libraries.
757 dnl This macro can take an optional parameter with a
758 dnl white space separated list of libraries to check
759 dnl before the default ones.
761 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
762 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
764 AC_MSG_CHECKING([for LDAP libraries])
778 if test -z "$u_libs"; then
781 u_libs="$u_libs $l_lib"
786 curl_cv_save_LIBS="$LIBS"
787 curl_cv_ldap_LIBS="unknown"
789 for x_nlibs in '' "$u_libs" \
793 '-lldapssl -lldapx -lldapsdk' \
794 '-lldapsdk -lldapx -lldapssl' ; do
795 if test "$curl_cv_ldap_LIBS" = "unknown"; then
796 if test -z "$x_nlibs"; then
797 LIBS="$curl_cv_save_LIBS"
799 LIBS="$x_nlibs $curl_cv_save_LIBS"
804 #ifdef HAVE_WINDOWS_H
805 #ifndef WIN32_LEAN_AND_MEAN
806 #define WIN32_LEAN_AND_MEAN
810 #ifdef HAVE_SYS_TYPES_H
811 #include <sys/types.h>
815 #define NULL (void *)0
817 #ifndef LDAP_DEPRECATED
818 #define LDAP_DEPRECATED 1
827 BerValue *bvp = NULL;
828 BerElement *bep = ber_init(bvp);
829 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
830 int res = ldap_unbind(ldp);
834 curl_cv_ldap_LIBS="$x_nlibs"
839 LIBS="$curl_cv_save_LIBS"
841 case X-"$curl_cv_ldap_LIBS" in
843 AC_MSG_RESULT([cannot find LDAP libraries])
846 AC_MSG_RESULT([no additional lib required])
849 if test -z "$curl_cv_save_LIBS"; then
850 LIBS="$curl_cv_ldap_LIBS"
852 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
854 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
861 dnl CURL_CHECK_HEADER_MALLOC
862 dnl -------------------------------------------------
863 dnl Check for compilable and valid malloc.h header,
864 dnl and check if it is needed even with stdlib.h
866 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
867 AC_CACHE_CHECK([for malloc.h], [curl_cv_header_malloc_h], [
872 void *p = malloc(10);
873 void *q = calloc(10,10);
878 curl_cv_header_malloc_h="yes"
880 curl_cv_header_malloc_h="no"
883 if test "$curl_cv_header_malloc_h" = "yes"; then
884 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
885 [Define to 1 if you have the malloc.h header file.])
891 void *p = malloc(10);
892 void *q = calloc(10,10);
897 curl_cv_need_header_malloc_h="no"
899 curl_cv_need_header_malloc_h="yes"
902 case "$curl_cv_need_header_malloc_h" in
904 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
905 [Define to 1 if you need the malloc.h header file even with stdlib.h])
912 dnl CURL_CHECK_HEADER_MEMORY
913 dnl -------------------------------------------------
914 dnl Check for compilable and valid memory.h header,
915 dnl and check if it is needed even with stdlib.h for
916 dnl memory related functions.
918 AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
919 AC_CACHE_CHECK([for memory.h], [curl_cv_header_memory_h], [
924 void *p = malloc(10);
925 void *q = calloc(10,10);
930 curl_cv_header_memory_h="yes"
932 curl_cv_header_memory_h="no"
935 if test "$curl_cv_header_memory_h" = "yes"; then
936 AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
937 [Define to 1 if you have the memory.h header file.])
943 void *p = malloc(10);
944 void *q = calloc(10,10);
949 curl_cv_need_header_memory_h="no"
951 curl_cv_need_header_memory_h="yes"
954 case "$curl_cv_need_header_memory_h" in
956 AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
957 [Define to 1 if you need the memory.h header file even with stdlib.h])
963 dnl TYPE_SOCKADDR_STORAGE
964 dnl -------------------------------------------------
965 dnl Check for struct sockaddr_storage. Most IPv6-enabled
966 dnl hosts have it, but AIX 4.3 is one known exception.
968 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
970 AC_CHECK_TYPE([struct sockaddr_storage],
971 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
972 [if struct sockaddr_storage is defined]), ,
975 #ifdef HAVE_WINDOWS_H
976 #ifndef WIN32_LEAN_AND_MEAN
977 #define WIN32_LEAN_AND_MEAN
980 #ifdef HAVE_WINSOCK2_H
981 #include <winsock2.h>
984 #ifdef HAVE_SYS_TYPES_H
985 #include <sys/types.h>
987 #ifdef HAVE_SYS_SOCKET_H
988 #include <sys/socket.h>
990 #ifdef HAVE_NETINET_IN_H
991 #include <netinet/in.h>
993 #ifdef HAVE_ARPA_INET_H
994 #include <arpa/inet.h>
1000 dnl CURL_CHECK_FUNC_RECV
1001 dnl -------------------------------------------------
1002 dnl Test if the socket recv() function is available,
1003 dnl and check its return type and the types of its
1004 dnl arguments. If the function succeeds HAVE_RECV
1005 dnl will be defined, defining the types of the arguments
1006 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1007 dnl and RECV_TYPE_ARG4, defining the type of the function
1008 dnl return value in RECV_TYPE_RETV.
1010 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1011 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1012 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1013 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1015 AC_MSG_CHECKING([for recv])
1019 #ifdef HAVE_WINDOWS_H
1020 #ifndef WIN32_LEAN_AND_MEAN
1021 #define WIN32_LEAN_AND_MEAN
1023 #include <windows.h>
1024 #ifdef HAVE_WINSOCK2_H
1025 #include <winsock2.h>
1027 #ifdef HAVE_WINSOCK_H
1028 #include <winsock.h>
1032 #ifdef HAVE_SYS_TYPES_H
1033 #include <sys/types.h>
1035 #ifdef HAVE_SYS_SOCKET_H
1036 #include <sys/socket.h>
1043 AC_MSG_RESULT([yes])
1050 if test "$curl_cv_recv" = "yes"; then
1051 AC_CACHE_CHECK([types of args and return type for recv],
1052 [curl_cv_func_recv_args], [
1053 curl_cv_func_recv_args="unknown"
1054 for recv_retv in 'int' 'ssize_t'; do
1055 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1056 for recv_arg2 in 'char *' 'void *'; do
1057 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1058 for recv_arg4 in 'int' 'unsigned int'; do
1059 if test "$curl_cv_func_recv_args" = "unknown"; then
1063 #ifdef HAVE_WINDOWS_H
1064 #ifndef WIN32_LEAN_AND_MEAN
1065 #define WIN32_LEAN_AND_MEAN
1067 #include <windows.h>
1068 #ifdef HAVE_WINSOCK2_H
1069 #include <winsock2.h>
1071 #ifdef HAVE_WINSOCK_H
1072 #include <winsock.h>
1075 #define RECVCALLCONV PASCAL
1077 #ifdef HAVE_SYS_TYPES_H
1078 #include <sys/types.h>
1080 #ifdef HAVE_SYS_SOCKET_H
1081 #include <sys/socket.h>
1083 #define RECVCALLCONV
1085 extern $recv_retv RECVCALLCONV
1087 __attribute__((overloadable))
1089 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1095 $recv_retv res = recv(s, buf, len, flags);
1098 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1107 if test "$curl_cv_func_recv_args" = "unknown"; then
1108 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1110 recv_prev_IFS=$IFS; IFS=','
1111 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1115 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1116 [Define to the type of arg 1 for recv.])
1117 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1118 [Define to the type of arg 2 for recv.])
1119 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1120 [Define to the type of arg 3 for recv.])
1121 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1122 [Define to the type of arg 4 for recv.])
1123 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1124 [Define to the function return type for recv.])
1126 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1127 [Define to 1 if you have the recv function.])
1128 curl_cv_func_recv="yes"
1131 AC_MSG_ERROR([Unable to link function recv])
1136 dnl CURL_CHECK_FUNC_SEND
1137 dnl -------------------------------------------------
1138 dnl Test if the socket send() function is available,
1139 dnl and check its return type and the types of its
1140 dnl arguments. If the function succeeds HAVE_SEND
1141 dnl will be defined, defining the types of the arguments
1142 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1143 dnl and SEND_TYPE_ARG4, defining the type of the function
1144 dnl return value in SEND_TYPE_RETV, and also defining the
1145 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1147 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1148 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1149 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1150 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1152 AC_MSG_CHECKING([for send])
1156 #ifdef HAVE_WINDOWS_H
1157 #ifndef WIN32_LEAN_AND_MEAN
1158 #define WIN32_LEAN_AND_MEAN
1160 #include <windows.h>
1161 #ifdef HAVE_WINSOCK2_H
1162 #include <winsock2.h>
1164 #ifdef HAVE_WINSOCK_H
1165 #include <winsock.h>
1169 #ifdef HAVE_SYS_TYPES_H
1170 #include <sys/types.h>
1172 #ifdef HAVE_SYS_SOCKET_H
1173 #include <sys/socket.h>
1180 AC_MSG_RESULT([yes])
1187 if test "$curl_cv_send" = "yes"; then
1188 AC_CACHE_CHECK([types of args and return type for send],
1189 [curl_cv_func_send_args], [
1190 curl_cv_func_send_args="unknown"
1191 for send_retv in 'int' 'ssize_t'; do
1192 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1193 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1194 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1195 for send_arg4 in 'int' 'unsigned int'; do
1196 if test "$curl_cv_func_send_args" = "unknown"; then
1200 #ifdef HAVE_WINDOWS_H
1201 #ifndef WIN32_LEAN_AND_MEAN
1202 #define WIN32_LEAN_AND_MEAN
1204 #include <windows.h>
1205 #ifdef HAVE_WINSOCK2_H
1206 #include <winsock2.h>
1208 #ifdef HAVE_WINSOCK_H
1209 #include <winsock.h>
1212 #define SENDCALLCONV PASCAL
1214 #ifdef HAVE_SYS_TYPES_H
1215 #include <sys/types.h>
1217 #ifdef HAVE_SYS_SOCKET_H
1218 #include <sys/socket.h>
1220 #define SENDCALLCONV
1222 extern $send_retv SENDCALLCONV
1224 __attribute__((overloadable))
1226 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1231 $send_retv res = send(s, 0, len, flags);
1234 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1243 if test "$curl_cv_func_send_args" = "unknown"; then
1244 AC_MSG_ERROR([Cannot find proper types to use for send args])
1246 send_prev_IFS=$IFS; IFS=','
1247 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1251 send_qual_type_arg2=$[2]
1253 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1254 [Define to the type of arg 1 for send.])
1255 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1256 [Define to the type of arg 3 for send.])
1257 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1258 [Define to the type of arg 4 for send.])
1259 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1260 [Define to the function return type for send.])
1264 case $prev_sh_opts in
1272 case "$send_qual_type_arg2" in
1274 send_qual_arg2=const
1275 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1279 send_type_arg2=$send_qual_type_arg2
1283 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1284 [Define to the type qualifier of arg 2 for send.])
1285 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1286 [Define to the type of arg 2 for send.])
1288 case $prev_sh_opts in
1296 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1297 [Define to 1 if you have the send function.])
1298 curl_cv_func_send="yes"
1301 AC_MSG_ERROR([Unable to link function send])
1305 dnl CURL_CHECK_MSG_NOSIGNAL
1306 dnl -------------------------------------------------
1307 dnl Check for MSG_NOSIGNAL
1309 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1310 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1311 AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
1315 #ifdef HAVE_WINDOWS_H
1316 #ifndef WIN32_LEAN_AND_MEAN
1317 #define WIN32_LEAN_AND_MEAN
1319 #include <windows.h>
1320 #ifdef HAVE_WINSOCK2_H
1321 #include <winsock2.h>
1323 #ifdef HAVE_WINSOCK_H
1324 #include <winsock.h>
1328 #ifdef HAVE_SYS_TYPES_H
1329 #include <sys/types.h>
1331 #ifdef HAVE_SYS_SOCKET_H
1332 #include <sys/socket.h>
1336 int flag=MSG_NOSIGNAL;
1339 curl_cv_msg_nosignal="yes"
1341 curl_cv_msg_nosignal="no"
1344 case "$curl_cv_msg_nosignal" in
1346 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1347 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1353 dnl CURL_CHECK_STRUCT_TIMEVAL
1354 dnl -------------------------------------------------
1355 dnl Check for timeval struct
1357 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1358 AC_REQUIRE([AC_HEADER_TIME])dnl
1359 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1360 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1361 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
1362 AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
1366 #ifdef HAVE_WINDOWS_H
1367 #ifndef WIN32_LEAN_AND_MEAN
1368 #define WIN32_LEAN_AND_MEAN
1370 #include <windows.h>
1371 #ifdef HAVE_WINSOCK2_H
1372 #include <winsock2.h>
1374 #ifdef HAVE_WINSOCK_H
1375 #include <winsock.h>
1379 #ifdef HAVE_SYS_TYPES_H
1380 #include <sys/types.h>
1382 #ifdef HAVE_SYS_TIME_H
1383 #include <sys/time.h>
1384 #ifdef TIME_WITH_SYS_TIME
1392 #ifdef HAVE_SYS_SOCKET_H
1393 #include <sys/socket.h>
1401 curl_cv_struct_timeval="yes"
1403 curl_cv_struct_timeval="no"
1406 case "$curl_cv_struct_timeval" in
1408 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1409 [Define to 1 if you have the timeval struct.])
1415 dnl TYPE_SIG_ATOMIC_T
1416 dnl -------------------------------------------------
1417 dnl Check if the sig_atomic_t type is available, and
1418 dnl verify if it is already defined as volatile.
1420 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1421 AC_CHECK_HEADERS(signal.h)
1422 AC_CHECK_TYPE([sig_atomic_t],[
1423 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1424 [Define to 1 if sig_atomic_t is an available typedef.])
1426 #ifdef HAVE_SIGNAL_H
1430 case "$ac_cv_type_sig_atomic_t" in
1433 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1436 #ifdef HAVE_SIGNAL_H
1440 static volatile sig_atomic_t dummy = 0;
1444 curl_cv_sig_atomic_t_volatile="no"
1446 AC_MSG_RESULT([yes])
1447 curl_cv_sig_atomic_t_volatile="yes"
1450 if test "$curl_cv_sig_atomic_t_volatile" = "yes"; then
1451 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1452 [Define to 1 if sig_atomic_t is already defined as volatile.])
1460 dnl -------------------------------------------------
1461 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1462 dnl and a few other things.
1464 AC_DEFUN([TYPE_IN_ADDR_T], [
1465 AC_CHECK_TYPE([in_addr_t], ,[
1466 dnl in_addr_t not available
1467 AC_CACHE_CHECK([for in_addr_t equivalent],
1468 [curl_cv_in_addr_t_equiv], [
1469 curl_cv_in_addr_t_equiv="unknown"
1470 for t in "unsigned long" int size_t unsigned long; do
1471 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1475 #ifdef HAVE_WINDOWS_H
1476 #ifndef WIN32_LEAN_AND_MEAN
1477 #define WIN32_LEAN_AND_MEAN
1479 #include <windows.h>
1480 #ifdef HAVE_WINSOCK2_H
1481 #include <winsock2.h>
1483 #ifdef HAVE_WINSOCK_H
1484 #include <winsock.h>
1488 #ifdef HAVE_SYS_TYPES_H
1489 #include <sys/types.h>
1491 #ifdef HAVE_SYS_SOCKET_H
1492 #include <sys/socket.h>
1494 #ifdef HAVE_NETINET_IN_H
1495 #include <netinet/in.h>
1497 #ifdef HAVE_ARPA_INET_H
1498 #include <arpa/inet.h>
1502 $t data = inet_addr ("1.2.3.4");
1505 curl_cv_in_addr_t_equiv="$t"
1510 case "$curl_cv_in_addr_t_equiv" in
1512 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1515 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1516 [Type to use in place of in_addr_t when system does not provide it.])
1521 #ifdef HAVE_WINDOWS_H
1522 #ifndef WIN32_LEAN_AND_MEAN
1523 #define WIN32_LEAN_AND_MEAN
1525 #include <windows.h>
1526 #ifdef HAVE_WINSOCK2_H
1527 #include <winsock2.h>
1529 #ifdef HAVE_WINSOCK_H
1530 #include <winsock.h>
1534 #ifdef HAVE_SYS_TYPES_H
1535 #include <sys/types.h>
1537 #ifdef HAVE_SYS_SOCKET_H
1538 #include <sys/socket.h>
1540 #ifdef HAVE_NETINET_IN_H
1541 #include <netinet/in.h>
1543 #ifdef HAVE_ARPA_INET_H
1544 #include <arpa/inet.h>
1551 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1552 dnl -------------------------------------------------
1553 dnl Check if monotonic clock_gettime is available.
1555 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1556 AC_REQUIRE([AC_HEADER_TIME])dnl
1557 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1558 AC_MSG_CHECKING([for monotonic clock_gettime])
1560 if test "x$dontwant_rt" = "xno" ; then
1563 #ifdef HAVE_SYS_TYPES_H
1564 #include <sys/types.h>
1566 #ifdef HAVE_SYS_TIME_H
1567 #include <sys/time.h>
1568 #ifdef TIME_WITH_SYS_TIME
1578 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1581 AC_MSG_RESULT([yes])
1582 curl_func_clock_gettime="yes"
1585 curl_func_clock_gettime="no"
1588 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1589 dnl until library linking and run-time checks for clock_gettime succeed.
1593 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1594 dnl -------------------------------------------------
1595 dnl If monotonic clock_gettime is available then,
1596 dnl check and prepended to LIBS any needed libraries.
1598 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1599 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1601 if test "$curl_func_clock_gettime" = "yes"; then
1603 AC_MSG_CHECKING([for clock_gettime in libraries])
1605 curl_cv_save_LIBS="$LIBS"
1606 curl_cv_gclk_LIBS="unknown"
1608 for x_xlibs in '' '-lrt' '-lposix4' ; do
1609 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1610 if test -z "$x_xlibs"; then
1611 LIBS="$curl_cv_save_LIBS"
1613 LIBS="$x_xlibs $curl_cv_save_LIBS"
1617 #ifdef HAVE_SYS_TYPES_H
1618 #include <sys/types.h>
1620 #ifdef HAVE_SYS_TIME_H
1621 #include <sys/time.h>
1622 #ifdef TIME_WITH_SYS_TIME
1632 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1635 curl_cv_gclk_LIBS="$x_xlibs"
1640 LIBS="$curl_cv_save_LIBS"
1642 case X-"$curl_cv_gclk_LIBS" in
1644 AC_MSG_RESULT([cannot find clock_gettime])
1645 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1646 curl_func_clock_gettime="no"
1649 AC_MSG_RESULT([no additional lib required])
1650 curl_func_clock_gettime="yes"
1653 if test -z "$curl_cv_save_LIBS"; then
1654 LIBS="$curl_cv_gclk_LIBS"
1656 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1658 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1659 curl_func_clock_gettime="yes"
1663 dnl only do runtime verification when not cross-compiling
1664 if test "x$cross_compiling" != "xyes" &&
1665 test "$curl_func_clock_gettime" = "yes"; then
1666 AC_MSG_CHECKING([if monotonic clock_gettime works])
1669 #ifdef HAVE_STDLIB_H
1672 #ifdef HAVE_SYS_TYPES_H
1673 #include <sys/types.h>
1675 #ifdef HAVE_SYS_TIME_H
1676 #include <sys/time.h>
1677 #ifdef TIME_WITH_SYS_TIME
1687 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1693 AC_MSG_RESULT([yes])
1696 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1697 curl_func_clock_gettime="no"
1698 LIBS="$curl_cv_save_LIBS"
1702 case "$curl_func_clock_gettime" in
1704 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1705 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1714 dnl CURL_CHECK_LIBS_CONNECT
1715 dnl -------------------------------------------------
1716 dnl Verify if network connect function is already available
1717 dnl using current libraries or if another one is required.
1719 AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
1720 AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1721 AC_MSG_CHECKING([for connect in libraries])
1722 tst_connect_save_LIBS="$LIBS"
1723 tst_connect_need_LIBS="unknown"
1724 for tst_lib in '' '-lsocket' ; do
1725 if test "$tst_connect_need_LIBS" = "unknown"; then
1726 LIBS="$tst_lib $tst_connect_save_LIBS"
1729 $curl_includes_winsock2
1730 #ifndef HAVE_WINDOWS_H
1731 int connect(int, void*, int);
1734 if(0 != connect(0, 0, 0))
1738 tst_connect_need_LIBS="$tst_lib"
1742 LIBS="$tst_connect_save_LIBS"
1744 case X-"$tst_connect_need_LIBS" in
1746 AC_MSG_RESULT([cannot find connect])
1747 AC_MSG_ERROR([cannot find connect function in libraries.])
1750 AC_MSG_RESULT([yes])
1753 AC_MSG_RESULT([$tst_connect_need_LIBS])
1754 LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
1760 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
1761 dnl -------------------------------------------------
1762 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
1763 dnl symbol that can be further used in custom template configuration
1764 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
1765 dnl argument for the description. Symbol definitions done with this
1766 dnl macro are intended to be exclusively used in handcrafted *.h.in
1767 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
1768 dnl prevents autoheader generation and insertion of symbol template
1769 dnl stub and definition into the first configuration header file. Do
1770 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
1771 dnl one serves different functional needs.
1773 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
1774 cat >>confdefs.h <<_EOF
1775 [@%:@define] $1 ifelse($#, 2, [$2], 1)
1779 dnl CURL_CONFIGURE_PULL_SYS_POLL
1780 dnl -------------------------------------------------
1781 dnl The need for the sys/poll.h inclusion arises mainly to properly
1782 dnl interface AIX systems which define macros 'events' and 'revents'.
1784 AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
1785 AC_REQUIRE([CURL_INCLUDES_POLL])dnl
1787 tst_poll_events_macro_defined="unknown"
1793 #if defined(events) || defined(revents)
1796 force compilation error
1800 tst_poll_events_macro_defined="yes"
1802 tst_poll_events_macro_defined="no"
1805 if test "$tst_poll_events_macro_defined" = "yes"; then
1806 if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
1807 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
1814 dnl CURL_CHECK_FUNC_SELECT
1815 dnl -------------------------------------------------
1816 dnl Test if the socket select() function is available,
1817 dnl and check its return type and the types of its
1818 dnl arguments. If the function succeeds HAVE_SELECT
1819 dnl will be defined, defining the types of the
1820 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
1821 dnl and SELECT_TYPE_ARG5, defining the type of the
1822 dnl function return value in SELECT_TYPE_RETV, and
1823 dnl also defining the type qualifier of fifth argument
1824 dnl in SELECT_QUAL_ARG5.
1826 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
1827 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
1828 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1830 AC_MSG_CHECKING([for select])
1834 #ifdef HAVE_WINDOWS_H
1835 #ifndef WIN32_LEAN_AND_MEAN
1836 #define WIN32_LEAN_AND_MEAN
1838 #include <windows.h>
1839 #ifdef HAVE_WINSOCK2_H
1840 #include <winsock2.h>
1842 #ifdef HAVE_WINSOCK_H
1843 #include <winsock.h>
1847 #ifdef HAVE_SYS_TYPES_H
1848 #include <sys/types.h>
1850 #ifdef HAVE_SYS_TIME_H
1851 #include <sys/time.h>
1852 #ifdef TIME_WITH_SYS_TIME
1860 #ifndef HAVE_WINDOWS_H
1861 #ifdef HAVE_SYS_SELECT_H
1862 #include <sys/select.h>
1864 #ifdef HAVE_SYS_SOCKET_H
1865 #include <sys/socket.h>
1869 select(0, 0, 0, 0, 0);
1872 AC_MSG_RESULT([yes])
1873 curl_cv_select="yes"
1879 if test "$curl_cv_select" = "yes"; then
1880 AC_CACHE_CHECK([types of args and return type for select],
1881 [curl_cv_func_select_args], [
1882 curl_cv_func_select_args="unknown"
1883 for sel_retv in 'int' 'ssize_t'; do
1884 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
1885 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
1886 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
1887 if test "$curl_cv_func_select_args" = "unknown"; then
1891 #ifdef HAVE_WINDOWS_H
1892 #ifndef WIN32_LEAN_AND_MEAN
1893 #define WIN32_LEAN_AND_MEAN
1895 #include <windows.h>
1896 #ifdef HAVE_WINSOCK2_H
1897 #include <winsock2.h>
1899 #ifdef HAVE_WINSOCK_H
1900 #include <winsock.h>
1903 #define SELECTCALLCONV PASCAL
1905 #ifdef HAVE_SYS_TYPES_H
1906 #include <sys/types.h>
1908 #ifdef HAVE_SYS_TIME_H
1909 #include <sys/time.h>
1910 #ifdef TIME_WITH_SYS_TIME
1918 #ifndef HAVE_WINDOWS_H
1919 #ifdef HAVE_SYS_SELECT_H
1920 #include <sys/select.h>
1922 #ifdef HAVE_SYS_SOCKET_H
1923 #include <sys/socket.h>
1925 #define SELECTCALLCONV
1927 #ifndef HAVE_STRUCT_TIMEVAL
1933 extern $sel_retv SELECTCALLCONV
1935 __attribute__((overloadable))
1947 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
1950 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
1958 if test "$curl_cv_func_select_args" = "unknown"; then
1959 AC_MSG_WARN([Cannot find proper types to use for select args])
1960 AC_MSG_WARN([HAVE_SELECT will not be defined])
1962 select_prev_IFS=$IFS; IFS=','
1963 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
1964 IFS=$select_prev_IFS
1967 sel_qual_type_arg5=$[3]
1969 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
1970 [Define to the type of arg 1 for select.])
1971 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
1972 [Define to the type of args 2, 3 and 4 for select.])
1973 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
1974 [Define to the function return type for select.])
1978 case $prev_sh_opts in
1986 case "$sel_qual_type_arg5" in
1989 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
1993 sel_type_arg5=$sel_qual_type_arg5
1997 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
1998 [Define to the type qualifier of arg 5 for select.])
1999 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2000 [Define to the type of arg 5 for select.])
2002 case $prev_sh_opts in
2010 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2011 [Define to 1 if you have the select function.])
2012 curl_cv_func_select="yes"
2018 dnl CURL_VERIFY_RUNTIMELIBS
2019 dnl -------------------------------------------------
2020 dnl Verify that the shared libs found so far can be used when running
2021 dnl programs, since otherwise the situation will create odd configure errors
2022 dnl that are misleading people.
2024 dnl Make sure this test is run BEFORE the first test in the script that
2025 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
2026 dnl macro. It must also run AFTER all lib-checking macros are complete.
2028 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
2030 dnl this test is of course not sensible if we are cross-compiling!
2031 if test "x$cross_compiling" != xyes; then
2033 dnl just run a program to verify that the libs checked for previous to this
2034 dnl point also is available run-time!
2035 AC_MSG_CHECKING([run-time libs availability])
2042 AC_MSG_RESULT([fine]),
2043 AC_MSG_RESULT([failed])
2044 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
2047 dnl if this test fails, configure has already stopped
2052 dnl CURL_CHECK_VARIADIC_MACROS
2053 dnl -------------------------------------------------
2054 dnl Check compiler support of variadic macros
2056 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
2057 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
2058 [curl_cv_variadic_macros_c99], [
2061 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
2062 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
2063 int fun3(int arg1, int arg2, int arg3);
2064 int fun2(int arg1, int arg2);
2065 int fun3(int arg1, int arg2, int arg3)
2066 { return arg1 + arg2 + arg3; }
2067 int fun2(int arg1, int arg2)
2068 { return arg1 + arg2; }
2070 int res3 = c99_vmacro3(1, 2, 3);
2071 int res2 = c99_vmacro2(1, 2);
2074 curl_cv_variadic_macros_c99="yes"
2076 curl_cv_variadic_macros_c99="no"
2079 case "$curl_cv_variadic_macros_c99" in
2081 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
2082 [Define to 1 if compiler supports C99 variadic macro style.])
2085 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
2086 [curl_cv_variadic_macros_gcc], [
2089 #define gcc_vmacro3(first, args...) fun3(first, args)
2090 #define gcc_vmacro2(first, args...) fun2(first, args)
2091 int fun3(int arg1, int arg2, int arg3);
2092 int fun2(int arg1, int arg2);
2093 int fun3(int arg1, int arg2, int arg3)
2094 { return arg1 + arg2 + arg3; }
2095 int fun2(int arg1, int arg2)
2096 { return arg1 + arg2; }
2098 int res3 = gcc_vmacro3(1, 2, 3);
2099 int res2 = gcc_vmacro2(1, 2);
2102 curl_cv_variadic_macros_gcc="yes"
2104 curl_cv_variadic_macros_gcc="no"
2107 case "$curl_cv_variadic_macros_gcc" in
2109 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2110 [Define to 1 if compiler supports old gcc variadic macro style.])
2116 dnl CURL_CHECK_CA_BUNDLE
2117 dnl -------------------------------------------------
2118 dnl Check if a default ca-bundle should be used
2120 dnl regarding the paths this will scan:
2121 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
2122 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
2123 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
2124 dnl /usr/local/share/certs/ca-root-nss.crt FreeBSD
2125 dnl /etc/ssl/cert.pem OpenBSD, FreeBSD (symlink)
2126 dnl /etc/ssl/certs/ (ca path) SUSE
2128 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
2130 AC_MSG_CHECKING([default CA cert bundle/path])
2132 AC_ARG_WITH(ca-bundle,
2133 AC_HELP_STRING([--with-ca-bundle=FILE],
2134 [Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
2135 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
2138 if test "x$want_ca" = "xyes"; then
2139 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
2142 [ want_ca="unset" ])
2143 AC_ARG_WITH(ca-path,
2144 AC_HELP_STRING([--with-ca-path=DIRECTORY],
2145 [Path to a directory containing CA certificates stored individually, with \
2146 their filenames in a hash format. This option can be used with OpenSSL, \
2147 GnuTLS and PolarSSL backends. Refer to OpenSSL c_rehash for details. \
2148 (example: /etc/certificates)])
2149 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
2151 want_capath="$withval"
2152 if test "x$want_capath" = "xyes"; then
2153 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
2156 [ want_capath="unset"])
2158 ca_warning=" (warning: certs not found)"
2159 capath_warning=" (warning: certs not found)"
2162 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
2163 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2166 capath="$want_capath"
2167 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
2168 dnl --with-ca-bundle given
2171 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2172 dnl --with-ca-path given
2173 if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1" -a "x$POLARSSL_ENABLED" != "x1"; then
2174 AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS or PolarSSL])
2176 capath="$want_capath"
2179 dnl first try autodetecting a CA bundle , then a CA path
2180 dnl both autodetections can be skipped by --without-ca-*
2183 if test "x$cross_compiling" != "xyes"; then
2184 dnl NOT cross-compiling and...
2185 dnl neither of the --with-ca-* options are provided
2186 if test "x$want_ca" = "xunset"; then
2187 dnl the path we previously would have installed the curl ca bundle
2188 dnl to, and thus we now check for an already existing cert in that
2189 dnl place in case we find no other
2190 if test "x$prefix" != xNONE; then
2191 cac="${prefix}/share/curl/curl-ca-bundle.crt"
2193 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
2196 for a in /etc/ssl/certs/ca-certificates.crt \
2197 /etc/pki/tls/certs/ca-bundle.crt \
2198 /usr/share/ssl/certs/ca-bundle.crt \
2199 /usr/local/share/certs/ca-root-nss.crt \
2202 if test -f "$a"; then
2208 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
2209 "x$OPENSSL_ENABLED" = "x1"; then
2210 check_capath="/etc/ssl/certs/"
2213 dnl no option given and cross-compiling
2214 AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
2218 if test "x$ca" = "xno" || test -f "$ca"; then
2222 if test "x$capath" != "xno"; then
2223 check_capath="$capath"
2226 if test ! -z "$check_capath"; then
2227 for a in "$check_capath"; do
2228 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
2229 if test "x$capath" = "xno"; then
2238 if test "x$capath" = "xno"; then
2242 if test "x$ca" != "xno"; then
2243 CURL_CA_BUNDLE='"'$ca'"'
2244 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
2245 AC_SUBST(CURL_CA_BUNDLE)
2246 AC_MSG_RESULT([$ca])
2248 if test "x$capath" != "xno"; then
2249 CURL_CA_PATH="\"$capath\""
2250 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
2251 AC_MSG_RESULT([$capath (capath)])
2253 if test "x$ca" = "xno" && test "x$capath" = "xno"; then
2257 AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
2258 AC_ARG_WITH(ca-fallback,
2259 AC_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
2260 AC_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
2262 if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
2263 AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
2266 [ with_ca_fallback="no"])
2267 AC_MSG_RESULT([$with_ca_fallback])
2268 if test "x$with_ca_fallback" = "xyes"; then
2269 if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
2270 AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
2272 AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
2276 dnl CURL_CHECK_WIN32_LARGEFILE
2277 dnl -------------------------------------------------
2278 dnl Check if curl's WIN32 large file will be used
2280 AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
2281 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
2282 AC_MSG_CHECKING([whether build target supports WIN32 file API])
2283 curl_win32_file_api="no"
2284 if test "$curl_cv_header_windows_h" = "yes"; then
2285 if test x"$enable_largefile" != "xno"; then
2289 #if !defined(_WIN32_WCE) && \
2290 (defined(__MINGW32__) || \
2291 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
2294 WIN32 large file API not supported.
2298 curl_win32_file_api="win32_large_files"
2301 if test "$curl_win32_file_api" = "no"; then
2305 #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
2308 WIN32 small file API not supported.
2312 curl_win32_file_api="win32_small_files"
2316 case "$curl_win32_file_api" in
2318 AC_MSG_RESULT([yes (large file enabled)])
2319 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
2320 [Define to 1 if you are building a Windows target with large file support.])
2323 AC_MSG_RESULT([yes (large file disabled)])
2324 AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
2325 [Define to 1 if you are building a Windows target without large file support.])
2333 dnl CURL_EXPORT_PCDIR ($pcdir)
2334 dnl ------------------------
2335 dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
2337 dnl we need this macro since pkg-config distinguishes among empty and unset
2338 dnl variable while checking PKG_CONFIG_LIBDIR
2341 AC_DEFUN([CURL_EXPORT_PCDIR], [
2342 if test -n "$1"; then
2343 PKG_CONFIG_LIBDIR="$1"
2344 export PKG_CONFIG_LIBDIR
2348 dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
2349 dnl ------------------------
2350 dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
2351 dnl path to it, or 'no' if not found/present.
2353 dnl If pkg-config is present, check that it has info about the $module or
2354 dnl return "no" anyway!
2356 dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
2359 AC_DEFUN([CURL_CHECK_PKGCONFIG], [
2360 if test -n "$PKG_CONFIG"; then
2361 PKGCONFIG="$PKG_CONFIG"
2363 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
2364 [$PATH:/usr/bin:/usr/local/bin])
2367 if test "x$PKGCONFIG" != "xno"; then
2368 AC_MSG_CHECKING([for $1 options with pkg-config])
2369 dnl ask pkg-config about $1
2370 itexists=`CURL_EXPORT_PCDIR([$2]) dnl
2371 $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
2373 if test -z "$itexists"; then
2374 dnl pkg-config does not have info about the given module! set the
2375 dnl variable to 'no'
2379 AC_MSG_RESULT([found])
2385 dnl CURL_GENERATE_CONFIGUREHELP_PM
2386 dnl -------------------------------------------------
2387 dnl Generate test harness configurehelp.pm module, defining and
2388 dnl initializing some perl variables with values which are known
2389 dnl when the configure script runs. For portability reasons, test
2390 dnl harness needs information on how to run the C preprocessor.
2392 AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
2393 AC_REQUIRE([AC_PROG_CPP])dnl
2394 tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
2395 if test -z "$tmp_cpp"; then
2398 cat >./tests/configurehelp.pm <<_EOF
2399 [@%:@] This is a generated file. Do not edit.
2401 package configurehelp;
2413 @ISA = qw(Exporter);
2419 \$Cpreprocessor = '$tmp_cpp';
2427 dnl Check if $cpp -P should be used for extract define values due to gcc 5
2428 dnl splitting up strings and defines between line outputs. gcc by default
2429 dnl (without -P) will show TEST EINVAL TEST as
2431 dnl # 13 "conftest.c"
2433 dnl # 13 "conftest.c" 3 4
2435 dnl # 13 "conftest.c"
2438 AC_DEFUN([CURL_CPP_P], [
2439 AC_MSG_CHECKING([if cpp -P is needed])
2440 AC_EGREP_CPP([TEST.*TEST], [
2443 ], [cpp=no], [cpp=yes])
2444 AC_MSG_RESULT([$cpp])
2446 dnl we need cpp -P so check if it works then
2447 if test "x$cpp" = "xyes"; then
2448 AC_MSG_CHECKING([if cpp -P works])
2449 OLDCPPFLAGS=$CPPFLAGS
2450 CPPFLAGS="$CPPFLAGS -P"
2451 AC_EGREP_CPP([TEST.*TEST], [
2454 ], [cpp_p=yes], [cpp_p=no])
2455 AC_MSG_RESULT([$cpp_p])
2457 if test "x$cpp_p" = "xno"; then
2458 AC_MSG_WARN([failed to figure out cpp -P alternative])
2465 dnl restore CPPFLAGS
2466 CPPFLAGS=$OLDCPPFLAGS
2476 dnl Check if -mmacosx-version-min, -miphoneos-version-min or any
2477 dnl similar are set manually, otherwise do. And set
2478 dnl -Werror=partial-availability.
2481 AC_DEFUN([CURL_MAC_CFLAGS], [
2490 AC_MSG_CHECKING([for good-to-use Mac CFLAGS])
2491 AC_MSG_RESULT([$tst_cflags]);
2493 if test "$tst_cflags" = "yes"; then
2494 AC_MSG_CHECKING([for *version-min in CFLAGS])
2496 if test -z "$(echo $CFLAGS | grep m.*os.*-version-min)"; then
2497 min="-mmacosx-version-min=10.8"
2498 CFLAGS="$CFLAGS $min"
2500 if test -z "$min"; then
2501 AC_MSG_RESULT([set by user])
2503 AC_MSG_RESULT([$min set])
2507 CFLAGS="$CFLAGS -Werror=partial-availability"
2508 AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
2509 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
2510 [AC_MSG_RESULT([yes])],
2511 [AC_MSG_RESULT([no])
2512 CFLAGS=$old_CFLAGS])
2518 dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
2520 dnl Check to see if the compiler supports __builtin_available. This built-in
2521 dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
2522 dnl the time this macro was written, the function was not yet documented. Its
2523 dnl purpose is to return true if the code is running under a certain OS version
2526 AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
2527 AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
2532 if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
2535 AC_MSG_RESULT([yes])
2536 AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
2537 [Define to 1 if you have the __builtin_available function.])