1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2017, 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])
964 dnl CURL_CHECK_FUNC_GETNAMEINFO
965 dnl -------------------------------------------------
966 dnl Test if the getnameinfo function is available,
967 dnl and check the types of five of its arguments.
968 dnl If the function succeeds HAVE_GETNAMEINFO will be
969 dnl defined, defining the types of the arguments in
970 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
971 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
972 dnl and also defining the type qualifier of first
973 dnl argument in GETNAMEINFO_QUAL_ARG1.
975 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
976 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
977 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
979 AC_MSG_CHECKING([for getnameinfo])
981 AC_LANG_FUNC_LINK_TRY([getnameinfo])
984 curl_cv_getnameinfo="yes"
987 curl_cv_getnameinfo="no"
990 if test "$curl_cv_getnameinfo" != "yes"; then
991 AC_MSG_CHECKING([deeper for getnameinfo])
999 curl_cv_getnameinfo="yes"
1001 AC_MSG_RESULT([but still no])
1002 curl_cv_getnameinfo="no"
1006 if test "$curl_cv_getnameinfo" != "yes"; then
1007 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
1011 #ifdef HAVE_WINDOWS_H
1012 #ifndef WIN32_LEAN_AND_MEAN
1013 #define WIN32_LEAN_AND_MEAN
1015 #include <windows.h>
1016 #ifdef HAVE_WINSOCK2_H
1017 #include <winsock2.h>
1018 #ifdef HAVE_WS2TCPIP_H
1019 #include <ws2tcpip.h>
1023 #ifdef HAVE_SYS_TYPES_H
1024 #include <sys/types.h>
1026 #ifdef HAVE_SYS_SOCKET_H
1027 #include <sys/socket.h>
1034 getnameinfo(0, 0, 0, 0, 0, 0, 0);
1037 AC_MSG_RESULT([yes])
1038 curl_cv_getnameinfo="yes"
1040 AC_MSG_RESULT([but still no])
1041 curl_cv_getnameinfo="no"
1045 if test "$curl_cv_getnameinfo" = "yes"; then
1046 AC_CACHE_CHECK([types of arguments for getnameinfo],
1047 [curl_cv_func_getnameinfo_args], [
1048 curl_cv_func_getnameinfo_args="unknown"
1049 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
1050 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
1051 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
1052 for gni_arg7 in 'int' 'unsigned int'; do
1053 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1057 #ifdef HAVE_WINDOWS_H
1058 #ifndef WIN32_LEAN_AND_MEAN
1059 #define WIN32_LEAN_AND_MEAN
1061 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
1063 #define _WIN32_WINNT 0x0501
1065 #include <windows.h>
1066 #ifdef HAVE_WINSOCK2_H
1067 #include <winsock2.h>
1068 #ifdef HAVE_WS2TCPIP_H
1069 #include <ws2tcpip.h>
1072 #define GNICALLCONV WSAAPI
1074 #ifdef HAVE_SYS_TYPES_H
1075 #include <sys/types.h>
1077 #ifdef HAVE_SYS_SOCKET_H
1078 #include <sys/socket.h>
1085 extern int GNICALLCONV
1087 __attribute__((overloadable))
1089 getnameinfo($gni_arg1, $gni_arg2,
1095 $gni_arg46 hostlen=0;
1096 $gni_arg46 servlen=0;
1098 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
1101 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
1109 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1110 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
1111 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1113 gni_prev_IFS=$IFS; IFS=','
1114 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1118 gni_qual_type_arg1=$[1]
1120 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1121 [Define to the type of arg 2 for getnameinfo.])
1122 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1123 [Define to the type of args 4 and 6 for getnameinfo.])
1124 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1125 [Define to the type of arg 7 for getnameinfo.])
1129 case $prev_sh_opts in
1137 case "$gni_qual_type_arg1" in
1140 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1144 gni_type_arg1=$gni_qual_type_arg1
1148 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1149 [Define to the type qualifier of arg 1 for getnameinfo.])
1150 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1151 [Define to the type of arg 1 for getnameinfo.])
1153 case $prev_sh_opts in
1161 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1162 [Define to 1 if you have the getnameinfo function.])
1163 curl_cv_func_getnameinfo="yes"
1169 dnl TYPE_SOCKADDR_STORAGE
1170 dnl -------------------------------------------------
1171 dnl Check for struct sockaddr_storage. Most IPv6-enabled
1172 dnl hosts have it, but AIX 4.3 is one known exception.
1174 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1176 AC_CHECK_TYPE([struct sockaddr_storage],
1177 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1178 [if struct sockaddr_storage is defined]), ,
1181 #ifdef HAVE_WINDOWS_H
1182 #ifndef WIN32_LEAN_AND_MEAN
1183 #define WIN32_LEAN_AND_MEAN
1185 #include <windows.h>
1186 #ifdef HAVE_WINSOCK2_H
1187 #include <winsock2.h>
1190 #ifdef HAVE_SYS_TYPES_H
1191 #include <sys/types.h>
1193 #ifdef HAVE_SYS_SOCKET_H
1194 #include <sys/socket.h>
1196 #ifdef HAVE_NETINET_IN_H
1197 #include <netinet/in.h>
1199 #ifdef HAVE_ARPA_INET_H
1200 #include <arpa/inet.h>
1207 dnl CURL_CHECK_NI_WITHSCOPEID
1208 dnl -------------------------------------------------
1209 dnl Check for working NI_WITHSCOPEID in getnameinfo()
1211 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1212 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1213 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1214 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1215 netdb.h netinet/in.h arpa/inet.h)
1217 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
1218 [curl_cv_working_ni_withscopeid], [
1221 #ifdef HAVE_STDLIB_H
1227 #ifdef HAVE_SYS_TYPES_H
1228 #include <sys/types.h>
1230 #ifdef HAVE_SYS_SOCKET_H
1231 #include <sys/socket.h>
1236 #ifdef HAVE_NETINET_IN_H
1237 #include <netinet/in.h>
1239 #ifdef HAVE_ARPA_INET_H
1240 #include <arpa/inet.h>
1243 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1244 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1245 struct sockaddr_storage sa;
1247 unsigned char sa[256];
1249 char hostbuf[NI_MAXHOST];
1251 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1252 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1253 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1254 int fd = socket(AF_INET6, SOCK_STREAM, 0);
1257 return 1; /* Error creating socket */
1259 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1261 perror("getsockname()");
1262 return 2; /* Error retrieving socket name */
1264 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1266 printf("rc = %s\n", gai_strerror(rc));
1267 return 3; /* Error translating socket address */
1269 return 0; /* Ok, NI_WITHSCOPEID works */
1271 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1273 ]]) # AC-LANG-PROGRAM
1275 # Exit code == 0. Program worked.
1276 curl_cv_working_ni_withscopeid="yes"
1278 # Exit code != 0. Program failed.
1279 curl_cv_working_ni_withscopeid="no"
1281 # Program is not run when cross-compiling. So we assume
1282 # NI_WITHSCOPEID will work if we are able to compile it.
1285 #include <sys/types.h>
1286 #include <sys/socket.h>
1289 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1292 curl_cv_working_ni_withscopeid="yes"
1294 curl_cv_working_ni_withscopeid="no"
1295 ]) # AC-COMPILE-IFELSE
1298 case "$curl_cv_working_ni_withscopeid" in
1300 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1301 [Define to 1 if NI_WITHSCOPEID exists and works.])
1307 dnl CURL_CHECK_FUNC_RECV
1308 dnl -------------------------------------------------
1309 dnl Test if the socket recv() function is available,
1310 dnl and check its return type and the types of its
1311 dnl arguments. If the function succeeds HAVE_RECV
1312 dnl will be defined, defining the types of the arguments
1313 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1314 dnl and RECV_TYPE_ARG4, defining the type of the function
1315 dnl return value in RECV_TYPE_RETV.
1317 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1318 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1319 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1320 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1322 AC_MSG_CHECKING([for recv])
1326 #ifdef HAVE_WINDOWS_H
1327 #ifndef WIN32_LEAN_AND_MEAN
1328 #define WIN32_LEAN_AND_MEAN
1330 #include <windows.h>
1331 #ifdef HAVE_WINSOCK2_H
1332 #include <winsock2.h>
1334 #ifdef HAVE_WINSOCK_H
1335 #include <winsock.h>
1339 #ifdef HAVE_SYS_TYPES_H
1340 #include <sys/types.h>
1342 #ifdef HAVE_SYS_SOCKET_H
1343 #include <sys/socket.h>
1350 AC_MSG_RESULT([yes])
1357 if test "$curl_cv_recv" = "yes"; then
1358 AC_CACHE_CHECK([types of args and return type for recv],
1359 [curl_cv_func_recv_args], [
1360 curl_cv_func_recv_args="unknown"
1361 for recv_retv in 'int' 'ssize_t'; do
1362 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1363 for recv_arg2 in 'char *' 'void *'; do
1364 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1365 for recv_arg4 in 'int' 'unsigned int'; do
1366 if test "$curl_cv_func_recv_args" = "unknown"; then
1370 #ifdef HAVE_WINDOWS_H
1371 #ifndef WIN32_LEAN_AND_MEAN
1372 #define WIN32_LEAN_AND_MEAN
1374 #include <windows.h>
1375 #ifdef HAVE_WINSOCK2_H
1376 #include <winsock2.h>
1378 #ifdef HAVE_WINSOCK_H
1379 #include <winsock.h>
1382 #define RECVCALLCONV PASCAL
1384 #ifdef HAVE_SYS_TYPES_H
1385 #include <sys/types.h>
1387 #ifdef HAVE_SYS_SOCKET_H
1388 #include <sys/socket.h>
1390 #define RECVCALLCONV
1392 extern $recv_retv RECVCALLCONV
1394 __attribute__((overloadable))
1396 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1402 $recv_retv res = recv(s, buf, len, flags);
1405 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1414 if test "$curl_cv_func_recv_args" = "unknown"; then
1415 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1417 recv_prev_IFS=$IFS; IFS=','
1418 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1422 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1423 [Define to the type of arg 1 for recv.])
1424 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1425 [Define to the type of arg 2 for recv.])
1426 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1427 [Define to the type of arg 3 for recv.])
1428 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1429 [Define to the type of arg 4 for recv.])
1430 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1431 [Define to the function return type for recv.])
1433 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1434 [Define to 1 if you have the recv function.])
1435 curl_cv_func_recv="yes"
1438 AC_MSG_ERROR([Unable to link function recv])
1443 dnl CURL_CHECK_FUNC_SEND
1444 dnl -------------------------------------------------
1445 dnl Test if the socket send() function is available,
1446 dnl and check its return type and the types of its
1447 dnl arguments. If the function succeeds HAVE_SEND
1448 dnl will be defined, defining the types of the arguments
1449 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1450 dnl and SEND_TYPE_ARG4, defining the type of the function
1451 dnl return value in SEND_TYPE_RETV, and also defining the
1452 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1454 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1455 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1456 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1457 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1459 AC_MSG_CHECKING([for send])
1463 #ifdef HAVE_WINDOWS_H
1464 #ifndef WIN32_LEAN_AND_MEAN
1465 #define WIN32_LEAN_AND_MEAN
1467 #include <windows.h>
1468 #ifdef HAVE_WINSOCK2_H
1469 #include <winsock2.h>
1471 #ifdef HAVE_WINSOCK_H
1472 #include <winsock.h>
1476 #ifdef HAVE_SYS_TYPES_H
1477 #include <sys/types.h>
1479 #ifdef HAVE_SYS_SOCKET_H
1480 #include <sys/socket.h>
1487 AC_MSG_RESULT([yes])
1494 if test "$curl_cv_send" = "yes"; then
1495 AC_CACHE_CHECK([types of args and return type for send],
1496 [curl_cv_func_send_args], [
1497 curl_cv_func_send_args="unknown"
1498 for send_retv in 'int' 'ssize_t'; do
1499 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1500 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1501 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1502 for send_arg4 in 'int' 'unsigned int'; do
1503 if test "$curl_cv_func_send_args" = "unknown"; then
1507 #ifdef HAVE_WINDOWS_H
1508 #ifndef WIN32_LEAN_AND_MEAN
1509 #define WIN32_LEAN_AND_MEAN
1511 #include <windows.h>
1512 #ifdef HAVE_WINSOCK2_H
1513 #include <winsock2.h>
1515 #ifdef HAVE_WINSOCK_H
1516 #include <winsock.h>
1519 #define SENDCALLCONV PASCAL
1521 #ifdef HAVE_SYS_TYPES_H
1522 #include <sys/types.h>
1524 #ifdef HAVE_SYS_SOCKET_H
1525 #include <sys/socket.h>
1527 #define SENDCALLCONV
1529 extern $send_retv SENDCALLCONV
1531 __attribute__((overloadable))
1533 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1538 $send_retv res = send(s, 0, len, flags);
1541 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1550 if test "$curl_cv_func_send_args" = "unknown"; then
1551 AC_MSG_ERROR([Cannot find proper types to use for send args])
1553 send_prev_IFS=$IFS; IFS=','
1554 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1558 send_qual_type_arg2=$[2]
1560 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1561 [Define to the type of arg 1 for send.])
1562 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1563 [Define to the type of arg 3 for send.])
1564 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1565 [Define to the type of arg 4 for send.])
1566 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1567 [Define to the function return type for send.])
1571 case $prev_sh_opts in
1579 case "$send_qual_type_arg2" in
1581 send_qual_arg2=const
1582 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1586 send_type_arg2=$send_qual_type_arg2
1590 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1591 [Define to the type qualifier of arg 2 for send.])
1592 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1593 [Define to the type of arg 2 for send.])
1595 case $prev_sh_opts in
1603 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1604 [Define to 1 if you have the send function.])
1605 curl_cv_func_send="yes"
1608 AC_MSG_ERROR([Unable to link function send])
1612 dnl CURL_CHECK_MSG_NOSIGNAL
1613 dnl -------------------------------------------------
1614 dnl Check for MSG_NOSIGNAL
1616 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1617 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1618 AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
1622 #ifdef HAVE_WINDOWS_H
1623 #ifndef WIN32_LEAN_AND_MEAN
1624 #define WIN32_LEAN_AND_MEAN
1626 #include <windows.h>
1627 #ifdef HAVE_WINSOCK2_H
1628 #include <winsock2.h>
1630 #ifdef HAVE_WINSOCK_H
1631 #include <winsock.h>
1635 #ifdef HAVE_SYS_TYPES_H
1636 #include <sys/types.h>
1638 #ifdef HAVE_SYS_SOCKET_H
1639 #include <sys/socket.h>
1643 int flag=MSG_NOSIGNAL;
1646 curl_cv_msg_nosignal="yes"
1648 curl_cv_msg_nosignal="no"
1651 case "$curl_cv_msg_nosignal" in
1653 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1654 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1660 dnl CURL_CHECK_STRUCT_TIMEVAL
1661 dnl -------------------------------------------------
1662 dnl Check for timeval struct
1664 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1665 AC_REQUIRE([AC_HEADER_TIME])dnl
1666 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1667 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1668 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
1669 AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
1673 #ifdef HAVE_WINDOWS_H
1674 #ifndef WIN32_LEAN_AND_MEAN
1675 #define WIN32_LEAN_AND_MEAN
1677 #include <windows.h>
1678 #ifdef HAVE_WINSOCK2_H
1679 #include <winsock2.h>
1681 #ifdef HAVE_WINSOCK_H
1682 #include <winsock.h>
1686 #ifdef HAVE_SYS_TYPES_H
1687 #include <sys/types.h>
1689 #ifdef HAVE_SYS_TIME_H
1690 #include <sys/time.h>
1691 #ifdef TIME_WITH_SYS_TIME
1699 #ifdef HAVE_SYS_SOCKET_H
1700 #include <sys/socket.h>
1708 curl_cv_struct_timeval="yes"
1710 curl_cv_struct_timeval="no"
1713 case "$curl_cv_struct_timeval" in
1715 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1716 [Define to 1 if you have the timeval struct.])
1722 dnl TYPE_SIG_ATOMIC_T
1723 dnl -------------------------------------------------
1724 dnl Check if the sig_atomic_t type is available, and
1725 dnl verify if it is already defined as volatile.
1727 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1728 AC_CHECK_HEADERS(signal.h)
1729 AC_CHECK_TYPE([sig_atomic_t],[
1730 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1731 [Define to 1 if sig_atomic_t is an available typedef.])
1733 #ifdef HAVE_SIGNAL_H
1737 case "$ac_cv_type_sig_atomic_t" in
1740 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1743 #ifdef HAVE_SIGNAL_H
1747 static volatile sig_atomic_t dummy = 0;
1751 curl_cv_sig_atomic_t_volatile="no"
1753 AC_MSG_RESULT([yes])
1754 curl_cv_sig_atomic_t_volatile="yes"
1757 if test "$curl_cv_sig_atomic_t_volatile" = "yes"; then
1758 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1759 [Define to 1 if sig_atomic_t is already defined as volatile.])
1767 dnl -------------------------------------------------
1768 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1769 dnl and a few other things.
1771 AC_DEFUN([TYPE_IN_ADDR_T], [
1772 AC_CHECK_TYPE([in_addr_t], ,[
1773 dnl in_addr_t not available
1774 AC_CACHE_CHECK([for in_addr_t equivalent],
1775 [curl_cv_in_addr_t_equiv], [
1776 curl_cv_in_addr_t_equiv="unknown"
1777 for t in "unsigned long" int size_t unsigned long; do
1778 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1782 #ifdef HAVE_WINDOWS_H
1783 #ifndef WIN32_LEAN_AND_MEAN
1784 #define WIN32_LEAN_AND_MEAN
1786 #include <windows.h>
1787 #ifdef HAVE_WINSOCK2_H
1788 #include <winsock2.h>
1790 #ifdef HAVE_WINSOCK_H
1791 #include <winsock.h>
1795 #ifdef HAVE_SYS_TYPES_H
1796 #include <sys/types.h>
1798 #ifdef HAVE_SYS_SOCKET_H
1799 #include <sys/socket.h>
1801 #ifdef HAVE_NETINET_IN_H
1802 #include <netinet/in.h>
1804 #ifdef HAVE_ARPA_INET_H
1805 #include <arpa/inet.h>
1809 $t data = inet_addr ("1.2.3.4");
1812 curl_cv_in_addr_t_equiv="$t"
1817 case "$curl_cv_in_addr_t_equiv" in
1819 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1822 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1823 [Type to use in place of in_addr_t when system does not provide it.])
1828 #ifdef HAVE_WINDOWS_H
1829 #ifndef WIN32_LEAN_AND_MEAN
1830 #define WIN32_LEAN_AND_MEAN
1832 #include <windows.h>
1833 #ifdef HAVE_WINSOCK2_H
1834 #include <winsock2.h>
1836 #ifdef HAVE_WINSOCK_H
1837 #include <winsock.h>
1841 #ifdef HAVE_SYS_TYPES_H
1842 #include <sys/types.h>
1844 #ifdef HAVE_SYS_SOCKET_H
1845 #include <sys/socket.h>
1847 #ifdef HAVE_NETINET_IN_H
1848 #include <netinet/in.h>
1850 #ifdef HAVE_ARPA_INET_H
1851 #include <arpa/inet.h>
1858 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1859 dnl -------------------------------------------------
1860 dnl Check if monotonic clock_gettime is available.
1862 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1863 AC_REQUIRE([AC_HEADER_TIME])dnl
1864 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1865 AC_MSG_CHECKING([for monotonic clock_gettime])
1867 if test "x$dontwant_rt" = "xno" ; then
1870 #ifdef HAVE_SYS_TYPES_H
1871 #include <sys/types.h>
1873 #ifdef HAVE_SYS_TIME_H
1874 #include <sys/time.h>
1875 #ifdef TIME_WITH_SYS_TIME
1885 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1888 AC_MSG_RESULT([yes])
1889 curl_func_clock_gettime="yes"
1892 curl_func_clock_gettime="no"
1895 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1896 dnl until library linking and run-time checks for clock_gettime succeed.
1900 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1901 dnl -------------------------------------------------
1902 dnl If monotonic clock_gettime is available then,
1903 dnl check and prepended to LIBS any needed libraries.
1905 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1906 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1908 if test "$curl_func_clock_gettime" = "yes"; then
1910 AC_MSG_CHECKING([for clock_gettime in libraries])
1912 curl_cv_save_LIBS="$LIBS"
1913 curl_cv_gclk_LIBS="unknown"
1915 for x_xlibs in '' '-lrt' '-lposix4' ; do
1916 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1917 if test -z "$x_xlibs"; then
1918 LIBS="$curl_cv_save_LIBS"
1920 LIBS="$x_xlibs $curl_cv_save_LIBS"
1924 #ifdef HAVE_SYS_TYPES_H
1925 #include <sys/types.h>
1927 #ifdef HAVE_SYS_TIME_H
1928 #include <sys/time.h>
1929 #ifdef TIME_WITH_SYS_TIME
1939 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1942 curl_cv_gclk_LIBS="$x_xlibs"
1947 LIBS="$curl_cv_save_LIBS"
1949 case X-"$curl_cv_gclk_LIBS" in
1951 AC_MSG_RESULT([cannot find clock_gettime])
1952 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1953 curl_func_clock_gettime="no"
1956 AC_MSG_RESULT([no additional lib required])
1957 curl_func_clock_gettime="yes"
1960 if test -z "$curl_cv_save_LIBS"; then
1961 LIBS="$curl_cv_gclk_LIBS"
1963 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1965 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1966 curl_func_clock_gettime="yes"
1970 dnl only do runtime verification when not cross-compiling
1971 if test "x$cross_compiling" != "xyes" &&
1972 test "$curl_func_clock_gettime" = "yes"; then
1973 AC_MSG_CHECKING([if monotonic clock_gettime works])
1976 #ifdef HAVE_STDLIB_H
1979 #ifdef HAVE_SYS_TYPES_H
1980 #include <sys/types.h>
1982 #ifdef HAVE_SYS_TIME_H
1983 #include <sys/time.h>
1984 #ifdef TIME_WITH_SYS_TIME
1994 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
2000 AC_MSG_RESULT([yes])
2003 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2004 curl_func_clock_gettime="no"
2005 LIBS="$curl_cv_save_LIBS"
2009 case "$curl_func_clock_gettime" in
2011 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
2012 [Define to 1 if you have the clock_gettime function and monotonic timer.])
2021 dnl CURL_CHECK_LIBS_CONNECT
2022 dnl -------------------------------------------------
2023 dnl Verify if network connect function is already available
2024 dnl using current libraries or if another one is required.
2026 AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
2027 AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
2028 AC_MSG_CHECKING([for connect in libraries])
2029 tst_connect_save_LIBS="$LIBS"
2030 tst_connect_need_LIBS="unknown"
2031 for tst_lib in '' '-lsocket' ; do
2032 if test "$tst_connect_need_LIBS" = "unknown"; then
2033 LIBS="$tst_lib $tst_connect_save_LIBS"
2036 $curl_includes_winsock2
2037 #ifndef HAVE_WINDOWS_H
2038 int connect(int, void*, int);
2041 if(0 != connect(0, 0, 0))
2045 tst_connect_need_LIBS="$tst_lib"
2049 LIBS="$tst_connect_save_LIBS"
2051 case X-"$tst_connect_need_LIBS" in
2053 AC_MSG_RESULT([cannot find connect])
2054 AC_MSG_ERROR([cannot find connect function in libraries.])
2057 AC_MSG_RESULT([yes])
2060 AC_MSG_RESULT([$tst_connect_need_LIBS])
2061 LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
2067 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
2068 dnl -------------------------------------------------
2069 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
2070 dnl symbol that can be further used in custom template configuration
2071 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
2072 dnl argument for the description. Symbol definitions done with this
2073 dnl macro are intended to be exclusively used in handcrafted *.h.in
2074 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
2075 dnl prevents autoheader generation and insertion of symbol template
2076 dnl stub and definition into the first configuration header file. Do
2077 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
2078 dnl one serves different functional needs.
2080 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
2081 cat >>confdefs.h <<_EOF
2082 [@%:@define] $1 ifelse($#, 2, [$2], 1)
2087 dnl CURL_CONFIGURE_CURL_SOCKLEN_T
2088 dnl -------------------------------------------------
2089 dnl The need for the curl_socklen_t definition arises mainly to properly
2090 dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
2091 dnl data type which is 32 or 64-Bit wide depending on the data model being
2092 dnl used, and that on the other hand is only actually used when interfacing
2093 dnl the X/Open sockets provided in the xnet library.
2095 AC_DEFUN([CURL_CONFIGURE_CURL_SOCKLEN_T], [
2096 AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
2097 AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
2098 AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
2100 AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
2102 AC_MSG_CHECKING([for curl_socklen_t data type])
2103 curl_typeof_curl_socklen_t="unknown"
2104 for arg1 in int SOCKET; do
2105 for arg2 in 'struct sockaddr' void; do
2106 for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
2107 if test "$curl_typeof_curl_socklen_t" = "unknown"; then
2110 $curl_includes_ws2tcpip
2111 $curl_includes_sys_socket
2112 $curl_preprocess_callconv
2113 extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
2116 if(0 != getpeername(0, 0, lenptr))
2120 curl_typeof_curl_socklen_t="$t"
2126 for t in socklen_t int; do
2127 if test "$curl_typeof_curl_socklen_t" = "void"; then
2130 $curl_includes_sys_socket
2131 typedef $t curl_socklen_t;
2133 curl_socklen_t dummy;
2136 curl_typeof_curl_socklen_t="$t"
2140 AC_MSG_RESULT([$curl_typeof_curl_socklen_t])
2141 if test "$curl_typeof_curl_socklen_t" = "void" ||
2142 test "$curl_typeof_curl_socklen_t" = "unknown"; then
2143 AC_MSG_ERROR([cannot find data type for curl_socklen_t.])
2146 AC_MSG_CHECKING([size of curl_socklen_t])
2147 curl_sizeof_curl_socklen_t="unknown"
2148 curl_pull_headers_socklen_t="unknown"
2149 if test "$curl_cv_header_ws2tcpip_h" = "yes"; then
2150 tst_pull_header_checks='none ws2tcpip'
2153 tst_pull_header_checks='none systypes syssocket'
2154 tst_size_checks='4 8 2'
2156 for tst_size in $tst_size_checks; do
2157 for tst_pull_headers in $tst_pull_header_checks; do
2158 if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
2159 case $tst_pull_headers in
2161 tmp_includes="$curl_includes_ws2tcpip"
2164 tmp_includes="$curl_includes_sys_types"
2167 tmp_includes="$curl_includes_sys_socket"
2176 typedef $curl_typeof_curl_socklen_t curl_socklen_t;
2177 typedef char dummy_arr[sizeof(curl_socklen_t) == $tst_size ? 1 : -1];
2179 curl_socklen_t dummy;
2182 curl_sizeof_curl_socklen_t="$tst_size"
2183 curl_pull_headers_socklen_t="$tst_pull_headers"
2188 AC_MSG_RESULT([$curl_sizeof_curl_socklen_t])
2189 if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
2190 AC_MSG_ERROR([cannot find out size of curl_socklen_t.])
2193 case $curl_pull_headers_socklen_t in
2195 CURL_DEFINE_UNQUOTED([CURL_PULL_WS2TCPIP_H])
2198 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
2201 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
2202 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_SOCKET_H])
2205 CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_SOCKLEN_T], [$curl_typeof_curl_socklen_t])
2206 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_SOCKLEN_T], [$curl_sizeof_curl_socklen_t])
2210 dnl CURL_CONFIGURE_PULL_SYS_POLL
2211 dnl -------------------------------------------------
2212 dnl The need for the sys/poll.h inclusion arises mainly to properly
2213 dnl interface AIX systems which define macros 'events' and 'revents'.
2215 AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
2216 AC_REQUIRE([CURL_INCLUDES_POLL])dnl
2218 tst_poll_events_macro_defined="unknown"
2224 #if defined(events) || defined(revents)
2227 force compilation error
2231 tst_poll_events_macro_defined="yes"
2233 tst_poll_events_macro_defined="no"
2236 if test "$tst_poll_events_macro_defined" = "yes"; then
2237 if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
2238 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
2245 dnl CURL_CHECK_FUNC_SELECT
2246 dnl -------------------------------------------------
2247 dnl Test if the socket select() function is available,
2248 dnl and check its return type and the types of its
2249 dnl arguments. If the function succeeds HAVE_SELECT
2250 dnl will be defined, defining the types of the
2251 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
2252 dnl and SELECT_TYPE_ARG5, defining the type of the
2253 dnl function return value in SELECT_TYPE_RETV, and
2254 dnl also defining the type qualifier of fifth argument
2255 dnl in SELECT_QUAL_ARG5.
2257 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
2258 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
2259 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
2261 AC_MSG_CHECKING([for select])
2265 #ifdef HAVE_WINDOWS_H
2266 #ifndef WIN32_LEAN_AND_MEAN
2267 #define WIN32_LEAN_AND_MEAN
2269 #include <windows.h>
2270 #ifdef HAVE_WINSOCK2_H
2271 #include <winsock2.h>
2273 #ifdef HAVE_WINSOCK_H
2274 #include <winsock.h>
2278 #ifdef HAVE_SYS_TYPES_H
2279 #include <sys/types.h>
2281 #ifdef HAVE_SYS_TIME_H
2282 #include <sys/time.h>
2283 #ifdef TIME_WITH_SYS_TIME
2291 #ifndef HAVE_WINDOWS_H
2292 #ifdef HAVE_SYS_SELECT_H
2293 #include <sys/select.h>
2295 #ifdef HAVE_SYS_SOCKET_H
2296 #include <sys/socket.h>
2300 select(0, 0, 0, 0, 0);
2303 AC_MSG_RESULT([yes])
2304 curl_cv_select="yes"
2310 if test "$curl_cv_select" = "yes"; then
2311 AC_CACHE_CHECK([types of args and return type for select],
2312 [curl_cv_func_select_args], [
2313 curl_cv_func_select_args="unknown"
2314 for sel_retv in 'int' 'ssize_t'; do
2315 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2316 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2317 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2318 if test "$curl_cv_func_select_args" = "unknown"; then
2322 #ifdef HAVE_WINDOWS_H
2323 #ifndef WIN32_LEAN_AND_MEAN
2324 #define WIN32_LEAN_AND_MEAN
2326 #include <windows.h>
2327 #ifdef HAVE_WINSOCK2_H
2328 #include <winsock2.h>
2330 #ifdef HAVE_WINSOCK_H
2331 #include <winsock.h>
2334 #define SELECTCALLCONV PASCAL
2336 #ifdef HAVE_SYS_TYPES_H
2337 #include <sys/types.h>
2339 #ifdef HAVE_SYS_TIME_H
2340 #include <sys/time.h>
2341 #ifdef TIME_WITH_SYS_TIME
2349 #ifndef HAVE_WINDOWS_H
2350 #ifdef HAVE_SYS_SELECT_H
2351 #include <sys/select.h>
2353 #ifdef HAVE_SYS_SOCKET_H
2354 #include <sys/socket.h>
2356 #define SELECTCALLCONV
2358 #ifndef HAVE_STRUCT_TIMEVAL
2364 extern $sel_retv SELECTCALLCONV
2366 __attribute__((overloadable))
2378 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2381 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2389 if test "$curl_cv_func_select_args" = "unknown"; then
2390 AC_MSG_WARN([Cannot find proper types to use for select args])
2391 AC_MSG_WARN([HAVE_SELECT will not be defined])
2393 select_prev_IFS=$IFS; IFS=','
2394 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2395 IFS=$select_prev_IFS
2398 sel_qual_type_arg5=$[3]
2400 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2401 [Define to the type of arg 1 for select.])
2402 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2403 [Define to the type of args 2, 3 and 4 for select.])
2404 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2405 [Define to the function return type for select.])
2409 case $prev_sh_opts in
2417 case "$sel_qual_type_arg5" in
2420 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2424 sel_type_arg5=$sel_qual_type_arg5
2428 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2429 [Define to the type qualifier of arg 5 for select.])
2430 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2431 [Define to the type of arg 5 for select.])
2433 case $prev_sh_opts in
2441 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2442 [Define to 1 if you have the select function.])
2443 curl_cv_func_select="yes"
2449 dnl CURL_VERIFY_RUNTIMELIBS
2450 dnl -------------------------------------------------
2451 dnl Verify that the shared libs found so far can be used when running
2452 dnl programs, since otherwise the situation will create odd configure errors
2453 dnl that are misleading people.
2455 dnl Make sure this test is run BEFORE the first test in the script that
2456 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
2457 dnl macro. It must also run AFTER all lib-checking macros are complete.
2459 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
2461 dnl this test is of course not sensible if we are cross-compiling!
2462 if test "x$cross_compiling" != xyes; then
2464 dnl just run a program to verify that the libs checked for previous to this
2465 dnl point also is available run-time!
2466 AC_MSG_CHECKING([run-time libs availability])
2473 AC_MSG_RESULT([fine]),
2474 AC_MSG_RESULT([failed])
2475 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
2478 dnl if this test fails, configure has already stopped
2483 dnl CURL_CHECK_VARIADIC_MACROS
2484 dnl -------------------------------------------------
2485 dnl Check compiler support of variadic macros
2487 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
2488 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
2489 [curl_cv_variadic_macros_c99], [
2492 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
2493 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
2494 int fun3(int arg1, int arg2, int arg3);
2495 int fun2(int arg1, int arg2);
2496 int fun3(int arg1, int arg2, int arg3)
2497 { return arg1 + arg2 + arg3; }
2498 int fun2(int arg1, int arg2)
2499 { return arg1 + arg2; }
2501 int res3 = c99_vmacro3(1, 2, 3);
2502 int res2 = c99_vmacro2(1, 2);
2505 curl_cv_variadic_macros_c99="yes"
2507 curl_cv_variadic_macros_c99="no"
2510 case "$curl_cv_variadic_macros_c99" in
2512 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
2513 [Define to 1 if compiler supports C99 variadic macro style.])
2516 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
2517 [curl_cv_variadic_macros_gcc], [
2520 #define gcc_vmacro3(first, args...) fun3(first, args)
2521 #define gcc_vmacro2(first, args...) fun2(first, args)
2522 int fun3(int arg1, int arg2, int arg3);
2523 int fun2(int arg1, int arg2);
2524 int fun3(int arg1, int arg2, int arg3)
2525 { return arg1 + arg2 + arg3; }
2526 int fun2(int arg1, int arg2)
2527 { return arg1 + arg2; }
2529 int res3 = gcc_vmacro3(1, 2, 3);
2530 int res2 = gcc_vmacro2(1, 2);
2533 curl_cv_variadic_macros_gcc="yes"
2535 curl_cv_variadic_macros_gcc="no"
2538 case "$curl_cv_variadic_macros_gcc" in
2540 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2541 [Define to 1 if compiler supports old gcc variadic macro style.])
2547 dnl CURL_CHECK_CA_BUNDLE
2548 dnl -------------------------------------------------
2549 dnl Check if a default ca-bundle should be used
2551 dnl regarding the paths this will scan:
2552 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
2553 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
2554 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
2555 dnl /usr/local/share/certs/ca-root-nss.crt FreeBSD
2556 dnl /etc/ssl/cert.pem OpenBSD, FreeBSD (symlink)
2557 dnl /etc/ssl/certs/ (ca path) SUSE
2559 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
2561 AC_MSG_CHECKING([default CA cert bundle/path])
2563 AC_ARG_WITH(ca-bundle,
2564 AC_HELP_STRING([--with-ca-bundle=FILE],
2565 [Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
2566 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
2569 if test "x$want_ca" = "xyes"; then
2570 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
2573 [ want_ca="unset" ])
2574 AC_ARG_WITH(ca-path,
2575 AC_HELP_STRING([--with-ca-path=DIRECTORY],
2576 [Path to a directory containing CA certificates stored individually, with \
2577 their filenames in a hash format. This option can be used with OpenSSL, \
2578 GnuTLS and PolarSSL backends. Refer to OpenSSL c_rehash for details. \
2579 (example: /etc/certificates)])
2580 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
2582 want_capath="$withval"
2583 if test "x$want_capath" = "xyes"; then
2584 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
2587 [ want_capath="unset"])
2589 ca_warning=" (warning: certs not found)"
2590 capath_warning=" (warning: certs not found)"
2593 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
2594 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2597 capath="$want_capath"
2598 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
2599 dnl --with-ca-bundle given
2602 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2603 dnl --with-ca-path given
2604 if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1" -a "x$POLARSSL_ENABLED" != "x1"; then
2605 AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS or PolarSSL])
2607 capath="$want_capath"
2610 dnl first try autodetecting a CA bundle , then a CA path
2611 dnl both autodetections can be skipped by --without-ca-*
2614 if test "x$cross_compiling" != "xyes"; then
2615 dnl NOT cross-compiling and...
2616 dnl neither of the --with-ca-* options are provided
2617 if test "x$want_ca" = "xunset"; then
2618 dnl the path we previously would have installed the curl ca bundle
2619 dnl to, and thus we now check for an already existing cert in that
2620 dnl place in case we find no other
2621 if test "x$prefix" != xNONE; then
2622 cac="${prefix}/share/curl/curl-ca-bundle.crt"
2624 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
2627 for a in /etc/ssl/certs/ca-certificates.crt \
2628 /etc/pki/tls/certs/ca-bundle.crt \
2629 /usr/share/ssl/certs/ca-bundle.crt \
2630 /usr/local/share/certs/ca-root-nss.crt \
2633 if test -f "$a"; then
2639 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
2640 "x$OPENSSL_ENABLED" = "x1"; then
2641 check_capath="/etc/ssl/certs/"
2644 dnl no option given and cross-compiling
2645 AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
2649 if test "x$ca" = "xno" || test -f "$ca"; then
2653 if test "x$capath" != "xno"; then
2654 check_capath="$capath"
2657 if test ! -z "$check_capath"; then
2658 for a in "$check_capath"; do
2659 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
2660 if test "x$capath" = "xno"; then
2669 if test "x$capath" = "xno"; then
2673 if test "x$ca" != "xno"; then
2674 CURL_CA_BUNDLE='"'$ca'"'
2675 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
2676 AC_SUBST(CURL_CA_BUNDLE)
2677 AC_MSG_RESULT([$ca])
2679 if test "x$capath" != "xno"; then
2680 CURL_CA_PATH="\"$capath\""
2681 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
2682 AC_MSG_RESULT([$capath (capath)])
2684 if test "x$ca" = "xno" && test "x$capath" = "xno"; then
2688 AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
2689 AC_ARG_WITH(ca-fallback,
2690 AC_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
2691 AC_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
2693 if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
2694 AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
2697 [ with_ca_fallback="no"])
2698 AC_MSG_RESULT([$with_ca_fallback])
2699 if test "x$with_ca_fallback" = "xyes"; then
2700 if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
2701 AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
2703 AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
2707 dnl CURL_CHECK_WIN32_LARGEFILE
2708 dnl -------------------------------------------------
2709 dnl Check if curl's WIN32 large file will be used
2711 AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
2712 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
2713 AC_MSG_CHECKING([whether build target supports WIN32 file API])
2714 curl_win32_file_api="no"
2715 if test "$curl_cv_header_windows_h" = "yes"; then
2716 if test x"$enable_largefile" != "xno"; then
2720 #if !defined(_WIN32_WCE) && \
2721 (defined(__MINGW32__) || \
2722 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
2725 WIN32 large file API not supported.
2729 curl_win32_file_api="win32_large_files"
2732 if test "$curl_win32_file_api" = "no"; then
2736 #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
2739 WIN32 small file API not supported.
2743 curl_win32_file_api="win32_small_files"
2747 case "$curl_win32_file_api" in
2749 AC_MSG_RESULT([yes (large file enabled)])
2750 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
2751 [Define to 1 if you are building a Windows target with large file support.])
2754 AC_MSG_RESULT([yes (large file disabled)])
2755 AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
2756 [Define to 1 if you are building a Windows target without large file support.])
2764 dnl CURL_EXPORT_PCDIR ($pcdir)
2765 dnl ------------------------
2766 dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
2768 dnl we need this macro since pkg-config distinguishes among empty and unset
2769 dnl variable while checking PKG_CONFIG_LIBDIR
2772 AC_DEFUN([CURL_EXPORT_PCDIR], [
2773 if test -n "$1"; then
2774 PKG_CONFIG_LIBDIR="$1"
2775 export PKG_CONFIG_LIBDIR
2779 dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
2780 dnl ------------------------
2781 dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
2782 dnl path to it, or 'no' if not found/present.
2784 dnl If pkg-config is present, check that it has info about the $module or
2785 dnl return "no" anyway!
2787 dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
2790 AC_DEFUN([CURL_CHECK_PKGCONFIG], [
2791 if test -n "$PKG_CONFIG"; then
2792 PKGCONFIG="$PKG_CONFIG"
2794 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
2795 [$PATH:/usr/bin:/usr/local/bin])
2798 if test "x$PKGCONFIG" != "xno"; then
2799 AC_MSG_CHECKING([for $1 options with pkg-config])
2800 dnl ask pkg-config about $1
2801 itexists=`CURL_EXPORT_PCDIR([$2]) dnl
2802 $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
2804 if test -z "$itexists"; then
2805 dnl pkg-config does not have info about the given module! set the
2806 dnl variable to 'no'
2810 AC_MSG_RESULT([found])
2816 dnl CURL_GENERATE_CONFIGUREHELP_PM
2817 dnl -------------------------------------------------
2818 dnl Generate test harness configurehelp.pm module, defining and
2819 dnl initializing some perl variables with values which are known
2820 dnl when the configure script runs. For portability reasons, test
2821 dnl harness needs information on how to run the C preprocessor.
2823 AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
2824 AC_REQUIRE([AC_PROG_CPP])dnl
2825 tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
2826 if test -z "$tmp_cpp"; then
2829 cat >./tests/configurehelp.pm <<_EOF
2830 [@%:@] This is a generated file. Do not edit.
2832 package configurehelp;
2844 @ISA = qw(Exporter);
2850 \$Cpreprocessor = '$tmp_cpp';
2858 dnl Check if $cpp -P should be used for extract define values due to gcc 5
2859 dnl splitting up strings and defines between line outputs. gcc by default
2860 dnl (without -P) will show TEST EINVAL TEST as
2862 dnl # 13 "conftest.c"
2864 dnl # 13 "conftest.c" 3 4
2866 dnl # 13 "conftest.c"
2869 AC_DEFUN([CURL_CPP_P], [
2870 AC_MSG_CHECKING([if cpp -P is needed])
2871 AC_EGREP_CPP([TEST.*TEST], [
2874 ], [cpp=no], [cpp=yes])
2875 AC_MSG_RESULT([$cpp])
2877 dnl we need cpp -P so check if it works then
2878 if test "x$cpp" = "xyes"; then
2879 AC_MSG_CHECKING([if cpp -P works])
2880 OLDCPPFLAGS=$CPPFLAGS
2881 CPPFLAGS="$CPPFLAGS -P"
2882 AC_EGREP_CPP([TEST.*TEST], [
2885 ], [cpp_p=yes], [cpp_p=no])
2886 AC_MSG_RESULT([$cpp_p])
2888 if test "x$cpp_p" = "xno"; then
2889 AC_MSG_WARN([failed to figure out cpp -P alternative])
2896 dnl restore CPPFLAGS
2897 CPPFLAGS=$OLDCPPFLAGS
2907 dnl Check if -mmacosx-version-min, -miphoneos-version-min or any
2908 dnl similar are set manually, otherwise do. And set
2909 dnl -Werror=partial-availability.
2912 AC_DEFUN([CURL_MAC_CFLAGS], [
2921 AC_MSG_CHECKING([for good-to-use Mac CFLAGS])
2922 AC_MSG_RESULT([$tst_cflags]);
2924 if test "$tst_cflags" = "yes"; then
2925 AC_MSG_CHECKING([for *version-min in CFLAGS])
2927 if test -z "$(echo $CFLAGS | grep m.*os.*-version-min)"; then
2928 min="-mmacosx-version-min=10.8"
2929 CFLAGS="$CFLAGS $min"
2931 if test -z "$min"; then
2932 AC_MSG_RESULT([set by user])
2934 AC_MSG_RESULT([$min set])
2938 CFLAGS="$CFLAGS -Werror=partial-availability"
2939 AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
2940 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
2941 [AC_MSG_RESULT([yes])],
2942 [AC_MSG_RESULT([no])
2943 CFLAGS=$old_CFLAGS])
2949 dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
2951 dnl Check to see if the compiler supports __builtin_available. This built-in
2952 dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
2953 dnl the time this macro was written, the function was not yet documented. Its
2954 dnl purpose is to return true if the code is running under a certain OS version
2957 AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
2958 AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
2963 if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
2966 AC_MSG_RESULT([yes])
2967 AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
2968 [Define to 1 if you have the __builtin_available function.])