1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at https://curl.se/docs/copyright.html.
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
21 # SPDX-License-Identifier: curl
23 #***************************************************************************
25 dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
26 dnl -------------------------------------------------
27 dnl Use the C preprocessor to find out if the given object-style symbol
28 dnl is defined and get its expansion. This macro will not use default
29 dnl includes even if no INCLUDES argument is given. This macro will run
30 dnl silently when invoked with three arguments. If the expansion would
31 dnl result in a set of double-quoted strings the returned expansion will
32 dnl actually be a single double-quoted string concatenating all them.
34 AC_DEFUN([CURL_CHECK_DEF], [
35 AC_REQUIRE([CURL_CPP_P])dnl
37 # CPPPFLAG comes from CURL_CPP_P
38 CPPFLAGS="$CPPFLAGS $CPPPFLAG"
39 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
40 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
41 if test -z "$SED"; then
42 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
44 if test -z "$GREP"; then
45 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
47 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
57 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
58 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
59 "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
60 "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
61 if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
65 if test -z "$tmp_exp"; then
66 AS_VAR_SET(ac_HaveDef, no)
67 ifelse($3,,[AC_MSG_RESULT([no])])
69 AS_VAR_SET(ac_HaveDef, yes)
70 AS_VAR_SET(ac_Def, $tmp_exp)
71 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
73 AS_VAR_POPDEF([ac_Def])dnl
74 AS_VAR_POPDEF([ac_HaveDef])dnl
79 dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
80 dnl -------------------------------------------------
81 dnl Use the C compiler to find out only if the given symbol is defined
82 dnl or not, this can not find out its expansion. This macro will not use
83 dnl default includes even if no INCLUDES argument is given. This macro
84 dnl will run silently when invoked with three arguments.
86 AC_DEFUN([CURL_CHECK_DEF_CC], [
87 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
88 ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
97 force compilation error
102 tst_symbol_defined="yes"
104 tst_symbol_defined="no"
106 if test "$tst_symbol_defined" = "yes"; then
107 AS_VAR_SET(ac_HaveDef, yes)
108 ifelse($3,,[AC_MSG_RESULT([yes])])
110 AS_VAR_SET(ac_HaveDef, no)
111 ifelse($3,,[AC_MSG_RESULT([no])])
113 AS_VAR_POPDEF([ac_HaveDef])dnl
117 dnl CURL_CHECK_LIB_XNET
118 dnl -------------------------------------------------
119 dnl Verify if X/Open network library is required.
121 AC_DEFUN([CURL_CHECK_LIB_XNET], [
122 AC_MSG_CHECKING([if X/Open network library is required])
123 tst_lib_xnet_required="no"
128 #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
130 #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
133 force compilation error
138 tst_lib_xnet_required="yes"
141 AC_MSG_RESULT([$tst_lib_xnet_required])
145 dnl CURL_CHECK_AIX_ALL_SOURCE
146 dnl -------------------------------------------------
147 dnl Provides a replacement of traditional AC_AIX with
148 dnl an uniform behavior across all autoconf versions,
149 dnl and with our own placement rules.
151 AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
152 AH_VERBATIM([_ALL_SOURCE],
153 [/* Define to 1 if OS is AIX. */
157 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
158 AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
159 AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
160 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
161 AC_EGREP_CPP([yes_this_is_aix],[
167 AC_DEFINE(_ALL_SOURCE)
174 dnl CURL_CHECK_HEADER_WINDOWS
175 dnl -------------------------------------------------
176 dnl Check for compilable and valid windows.h header
178 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
179 AC_CACHE_CHECK([for windows.h], [curl_cv_header_windows_h], [
183 #ifndef WIN32_LEAN_AND_MEAN
184 #define WIN32_LEAN_AND_MEAN
188 #if defined(__CYGWIN__) || defined(__CEGCC__)
189 HAVE_WINDOWS_H shall not be defined.
195 curl_cv_header_windows_h="yes"
197 curl_cv_header_windows_h="no"
200 case "$curl_cv_header_windows_h" in
202 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
203 [Define to 1 if you have the windows.h header file.])
209 dnl CURL_CHECK_NATIVE_WINDOWS
210 dnl -------------------------------------------------
211 dnl Check if building a native Windows target
213 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
214 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
215 AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [
216 if test "$curl_cv_header_windows_h" = "no"; then
217 curl_cv_native_windows="no"
222 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
223 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
226 Not a native Windows build target.
230 curl_cv_native_windows="yes"
232 curl_cv_native_windows="no"
236 AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes)
240 dnl CURL_CHECK_HEADER_WINSOCK2
241 dnl -------------------------------------------------
242 dnl Check for compilable and valid winsock2.h header
244 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
245 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
246 AC_CACHE_CHECK([for winsock2.h], [curl_cv_header_winsock2_h], [
250 #ifndef WIN32_LEAN_AND_MEAN
251 #define WIN32_LEAN_AND_MEAN
254 #include <winsock2.h>
256 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
257 HAVE_WINSOCK2_H shall not be defined.
259 int dummy=2*IPPROTO_ESP;
263 curl_cv_header_winsock2_h="yes"
265 curl_cv_header_winsock2_h="no"
268 case "$curl_cv_header_winsock2_h" in
270 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
271 [Define to 1 if you have the winsock2.h header file.])
277 dnl CURL_CHECK_HEADER_WS2TCPIP
278 dnl -------------------------------------------------
279 dnl Check for compilable and valid ws2tcpip.h header
281 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
282 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
283 AC_CACHE_CHECK([for ws2tcpip.h], [curl_cv_header_ws2tcpip_h], [
287 #ifndef WIN32_LEAN_AND_MEAN
288 #define WIN32_LEAN_AND_MEAN
291 #include <winsock2.h>
292 #include <ws2tcpip.h>
294 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
295 HAVE_WS2TCPIP_H shall not be defined.
297 int dummy=2*IP_PKTINFO;
301 curl_cv_header_ws2tcpip_h="yes"
303 curl_cv_header_ws2tcpip_h="no"
306 case "$curl_cv_header_ws2tcpip_h" in
308 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
309 [Define to 1 if you have the ws2tcpip.h header file.])
315 dnl CURL_CHECK_HEADER_LBER
316 dnl -------------------------------------------------
317 dnl Check for compilable and valid lber.h header,
318 dnl and check if it is needed even with ldap.h
320 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
321 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
322 AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
326 #ifdef HAVE_WINDOWS_H
327 #ifndef WIN32_LEAN_AND_MEAN
328 #define WIN32_LEAN_AND_MEAN
332 #ifdef HAVE_SYS_TYPES_H
333 #include <sys/types.h>
337 #define NULL (void *)0
341 BerValue *bvp = NULL;
342 BerElement *bep = ber_init(bvp);
346 curl_cv_header_lber_h="yes"
348 curl_cv_header_lber_h="no"
351 if test "$curl_cv_header_lber_h" = "yes"; then
352 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
353 [Define to 1 if you have the lber.h header file.])
358 #ifdef HAVE_WINDOWS_H
359 #ifndef WIN32_LEAN_AND_MEAN
360 #define WIN32_LEAN_AND_MEAN
364 #ifdef HAVE_SYS_TYPES_H
365 #include <sys/types.h>
369 #define NULL (void *)0
371 #ifndef LDAP_DEPRECATED
372 #define LDAP_DEPRECATED 1
376 BerValue *bvp = NULL;
377 BerElement *bep = ber_init(bvp);
381 curl_cv_need_header_lber_h="no"
383 curl_cv_need_header_lber_h="yes"
386 case "$curl_cv_need_header_lber_h" in
388 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
389 [Define to 1 if you need the lber.h header file even with ldap.h])
396 dnl CURL_CHECK_HEADER_LDAP
397 dnl -------------------------------------------------
398 dnl Check for compilable and valid ldap.h header
400 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
401 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
402 AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
406 #ifdef HAVE_WINDOWS_H
407 #ifndef WIN32_LEAN_AND_MEAN
408 #define WIN32_LEAN_AND_MEAN
412 #ifdef HAVE_SYS_TYPES_H
413 #include <sys/types.h>
416 #ifndef LDAP_DEPRECATED
417 #define LDAP_DEPRECATED 1
424 LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
425 int res = ldap_unbind(ldp);
428 curl_cv_header_ldap_h="yes"
430 curl_cv_header_ldap_h="no"
433 case "$curl_cv_header_ldap_h" in
435 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
436 [Define to 1 if you have the ldap.h header file.])
442 dnl CURL_CHECK_HEADER_LDAP_SSL
443 dnl -------------------------------------------------
444 dnl Check for compilable and valid ldap_ssl.h header
446 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
447 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
448 AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
452 #ifdef HAVE_WINDOWS_H
453 #ifndef WIN32_LEAN_AND_MEAN
454 #define WIN32_LEAN_AND_MEAN
458 #ifdef HAVE_SYS_TYPES_H
459 #include <sys/types.h>
462 #ifndef LDAP_DEPRECATED
463 #define LDAP_DEPRECATED 1
471 #include <ldap_ssl.h>
473 LDAP *ldp = ldapssl_init("0.0.0.0", LDAPS_PORT, 1);
476 curl_cv_header_ldap_ssl_h="yes"
478 curl_cv_header_ldap_ssl_h="no"
481 case "$curl_cv_header_ldap_ssl_h" in
483 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
484 [Define to 1 if you have the ldap_ssl.h header file.])
490 dnl CURL_CHECK_LIBS_WINLDAP
491 dnl -------------------------------------------------
492 dnl Check for libraries needed for WINLDAP support,
493 dnl and prepended to LIBS any needed libraries.
494 dnl This macro can take an optional parameter with a
495 dnl whitespace separated list of libraries to check
496 dnl before the WINLDAP default ones.
498 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
499 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
501 AC_MSG_CHECKING([for WINLDAP libraries])
515 if test -z "$u_libs"; then
518 u_libs="$u_libs $l_lib"
523 curl_cv_save_LIBS="$LIBS"
524 curl_cv_ldap_LIBS="unknown"
526 for x_nlibs in '' "$u_libs" \
528 if test "$curl_cv_ldap_LIBS" = "unknown"; then
529 if test -z "$x_nlibs"; then
530 LIBS="$curl_cv_save_LIBS"
532 LIBS="$x_nlibs $curl_cv_save_LIBS"
537 #ifdef HAVE_WINDOWS_H
538 #ifndef WIN32_LEAN_AND_MEAN
539 #define WIN32_LEAN_AND_MEAN
549 BerElement *bep = ber_init(bvp);
550 LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
551 ULONG res = ldap_unbind(ldp);
555 curl_cv_ldap_LIBS="$x_nlibs"
560 LIBS="$curl_cv_save_LIBS"
562 case X-"$curl_cv_ldap_LIBS" in
564 AC_MSG_RESULT([cannot find WINLDAP libraries])
567 AC_MSG_RESULT([no additional lib required])
570 if test -z "$curl_cv_save_LIBS"; then
571 LIBS="$curl_cv_ldap_LIBS"
573 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
575 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
582 dnl CURL_CHECK_LIBS_LDAP
583 dnl -------------------------------------------------
584 dnl Check for libraries needed for LDAP support,
585 dnl and prepended to LIBS any needed libraries.
586 dnl This macro can take an optional parameter with a
587 dnl whitespace separated list of libraries to check
588 dnl before the default ones.
590 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
591 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
593 AC_MSG_CHECKING([for LDAP libraries])
607 if test -z "$u_libs"; then
610 u_libs="$u_libs $l_lib"
615 curl_cv_save_LIBS="$LIBS"
616 curl_cv_ldap_LIBS="unknown"
618 for x_nlibs in '' "$u_libs" \
622 '-lldapssl -lldapx -lldapsdk' \
623 '-lldapsdk -lldapx -lldapssl' \
624 '-lldap -llber -lssl -lcrypto' ; do
626 if test "$curl_cv_ldap_LIBS" = "unknown"; then
627 if test -z "$x_nlibs"; then
628 LIBS="$curl_cv_save_LIBS"
630 LIBS="$x_nlibs $curl_cv_save_LIBS"
635 #ifdef HAVE_WINDOWS_H
636 #ifndef WIN32_LEAN_AND_MEAN
637 #define WIN32_LEAN_AND_MEAN
641 #ifdef HAVE_SYS_TYPES_H
642 #include <sys/types.h>
646 #define NULL (void *)0
648 #ifndef LDAP_DEPRECATED
649 #define LDAP_DEPRECATED 1
658 BerValue *bvp = NULL;
659 BerElement *bep = ber_init(bvp);
660 LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
661 int res = ldap_unbind(ldp);
665 curl_cv_ldap_LIBS="$x_nlibs"
670 LIBS="$curl_cv_save_LIBS"
672 case X-"$curl_cv_ldap_LIBS" in
674 AC_MSG_RESULT([cannot find LDAP libraries])
677 AC_MSG_RESULT([no additional lib required])
680 if test -z "$curl_cv_save_LIBS"; then
681 LIBS="$curl_cv_ldap_LIBS"
683 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
685 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
692 dnl TYPE_SOCKADDR_STORAGE
693 dnl -------------------------------------------------
694 dnl Check for struct sockaddr_storage. Most IPv6-enabled
695 dnl hosts have it, but AIX 4.3 is one known exception.
697 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
699 AC_CHECK_TYPE([struct sockaddr_storage],
700 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
701 [if struct sockaddr_storage is defined]), ,
704 #ifdef HAVE_WINDOWS_H
705 #ifndef WIN32_LEAN_AND_MEAN
706 #define WIN32_LEAN_AND_MEAN
708 #ifdef HAVE_WINSOCK2_H
709 #include <winsock2.h>
713 #ifdef HAVE_SYS_TYPES_H
714 #include <sys/types.h>
716 #ifdef HAVE_SYS_SOCKET_H
717 #include <sys/socket.h>
719 #ifdef HAVE_NETINET_IN_H
720 #include <netinet/in.h>
722 #ifdef HAVE_ARPA_INET_H
723 #include <arpa/inet.h>
729 dnl CURL_CHECK_FUNC_RECV
730 dnl -------------------------------------------------
731 dnl Test if the socket recv() function is available,
733 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
734 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
735 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
736 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
738 AC_MSG_CHECKING([for recv])
742 #ifdef HAVE_WINDOWS_H
743 #ifndef WIN32_LEAN_AND_MEAN
744 #define WIN32_LEAN_AND_MEAN
746 #ifdef HAVE_WINSOCK2_H
747 #include <winsock2.h>
751 $curl_includes_bsdsocket
752 #ifdef HAVE_SYS_TYPES_H
753 #include <sys/types.h>
755 #ifdef HAVE_SYS_SOCKET_H
756 #include <sys/socket.h>
770 if test "$curl_cv_recv" = "yes"; then
771 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
772 [Define to 1 if you have the recv function.])
773 curl_cv_func_recv="yes"
775 AC_MSG_ERROR([Unable to link function recv])
780 dnl CURL_CHECK_FUNC_SEND
781 dnl -------------------------------------------------
782 dnl Test if the socket send() function is available,
784 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
785 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
786 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
787 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
789 AC_MSG_CHECKING([for send])
793 #ifdef HAVE_WINDOWS_H
794 #ifndef WIN32_LEAN_AND_MEAN
795 #define WIN32_LEAN_AND_MEAN
797 #ifdef HAVE_WINSOCK2_H
798 #include <winsock2.h>
802 $curl_includes_bsdsocket
803 #ifdef HAVE_SYS_TYPES_H
804 #include <sys/types.h>
806 #ifdef HAVE_SYS_SOCKET_H
807 #include <sys/socket.h>
821 if test "$curl_cv_send" = "yes"; then
822 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
823 [Define to 1 if you have the send function.])
824 curl_cv_func_send="yes"
826 AC_MSG_ERROR([Unable to link function send])
830 dnl CURL_CHECK_MSG_NOSIGNAL
831 dnl -------------------------------------------------
832 dnl Check for MSG_NOSIGNAL
834 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
835 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
836 AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
840 #ifdef HAVE_WINDOWS_H
841 #ifndef WIN32_LEAN_AND_MEAN
842 #define WIN32_LEAN_AND_MEAN
844 #ifdef HAVE_WINSOCK2_H
845 #include <winsock2.h>
849 #ifdef HAVE_SYS_TYPES_H
850 #include <sys/types.h>
852 #ifdef HAVE_SYS_SOCKET_H
853 #include <sys/socket.h>
857 int flag=MSG_NOSIGNAL;
860 curl_cv_msg_nosignal="yes"
862 curl_cv_msg_nosignal="no"
865 case "$curl_cv_msg_nosignal" in
867 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
868 [Define to 1 if you have the MSG_NOSIGNAL flag.])
874 dnl CURL_CHECK_STRUCT_TIMEVAL
875 dnl -------------------------------------------------
876 dnl Check for timeval struct
878 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
879 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
880 AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h)
881 AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
885 #ifdef HAVE_WINDOWS_H
886 #ifndef WIN32_LEAN_AND_MEAN
887 #define WIN32_LEAN_AND_MEAN
889 #ifdef HAVE_WINSOCK2_H
890 #include <winsock2.h>
894 #ifdef HAVE_SYS_TYPES_H
895 #include <sys/types.h>
897 #ifdef HAVE_SYS_TIME_H
898 #include <sys/time.h>
901 #ifdef HAVE_SYS_SOCKET_H
902 #include <sys/socket.h>
910 curl_cv_struct_timeval="yes"
912 curl_cv_struct_timeval="no"
915 case "$curl_cv_struct_timeval" in
917 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
918 [Define to 1 if you have the timeval struct.])
925 dnl -------------------------------------------------
926 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
927 dnl and a few other things.
929 AC_DEFUN([TYPE_IN_ADDR_T], [
930 AC_CHECK_TYPE([in_addr_t], ,[
931 dnl in_addr_t not available
932 AC_CACHE_CHECK([for in_addr_t equivalent],
933 [curl_cv_in_addr_t_equiv], [
934 curl_cv_in_addr_t_equiv="unknown"
935 for t in "unsigned long" int size_t unsigned long; do
936 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
940 #ifdef HAVE_WINDOWS_H
941 #ifndef WIN32_LEAN_AND_MEAN
942 #define WIN32_LEAN_AND_MEAN
944 #ifdef HAVE_WINSOCK2_H
945 #include <winsock2.h>
949 #ifdef HAVE_SYS_TYPES_H
950 #include <sys/types.h>
952 #ifdef HAVE_SYS_SOCKET_H
953 #include <sys/socket.h>
955 #ifdef HAVE_NETINET_IN_H
956 #include <netinet/in.h>
958 #ifdef HAVE_ARPA_INET_H
959 #include <arpa/inet.h>
963 $t data = inet_addr ("1.2.3.4");
966 curl_cv_in_addr_t_equiv="$t"
971 case "$curl_cv_in_addr_t_equiv" in
973 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
976 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
977 [Type to use in place of in_addr_t when system does not provide it.])
982 #ifdef HAVE_WINDOWS_H
983 #ifndef WIN32_LEAN_AND_MEAN
984 #define WIN32_LEAN_AND_MEAN
986 #ifdef HAVE_WINSOCK2_H
987 #include <winsock2.h>
991 #ifdef HAVE_SYS_TYPES_H
992 #include <sys/types.h>
994 #ifdef HAVE_SYS_SOCKET_H
995 #include <sys/socket.h>
997 #ifdef HAVE_NETINET_IN_H
998 #include <netinet/in.h>
1000 #ifdef HAVE_ARPA_INET_H
1001 #include <arpa/inet.h>
1008 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1009 dnl -------------------------------------------------
1010 dnl Check if monotonic clock_gettime is available.
1012 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1013 AC_CHECK_HEADERS(sys/types.h sys/time.h)
1014 AC_MSG_CHECKING([for monotonic clock_gettime])
1016 if test "x$dontwant_rt" = "xno" ; then
1019 #ifdef HAVE_SYS_TYPES_H
1020 #include <sys/types.h>
1022 #ifdef HAVE_SYS_TIME_H
1023 #include <sys/time.h>
1028 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1031 AC_MSG_RESULT([yes])
1032 curl_func_clock_gettime="yes"
1035 curl_func_clock_gettime="no"
1038 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1039 dnl until library linking and run-time checks for clock_gettime succeed.
1042 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW
1043 dnl -------------------------------------------------
1044 dnl Check if monotonic clock_gettime is available.
1046 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW], [
1047 AC_CHECK_HEADERS(sys/types.h sys/time.h)
1048 AC_MSG_CHECKING([for raw monotonic clock_gettime])
1050 if test "x$dontwant_rt" = "xno" ; then
1053 #ifdef HAVE_SYS_TYPES_H
1054 #include <sys/types.h>
1056 #ifdef HAVE_SYS_TIME_H
1057 #include <sys/time.h>
1062 (void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
1065 AC_MSG_RESULT([yes])
1066 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC_RAW, 1,
1067 [Define to 1 if you have the clock_gettime function and raw monotonic timer.])
1075 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1076 dnl -------------------------------------------------
1077 dnl If monotonic clock_gettime is available then,
1078 dnl check and prepended to LIBS any needed libraries.
1080 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1081 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1083 if test "$curl_func_clock_gettime" = "yes"; then
1085 AC_MSG_CHECKING([for clock_gettime in libraries])
1087 curl_cv_save_LIBS="$LIBS"
1088 curl_cv_gclk_LIBS="unknown"
1090 for x_xlibs in '' '-lrt' '-lposix4' ; do
1091 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1092 if test -z "$x_xlibs"; then
1093 LIBS="$curl_cv_save_LIBS"
1095 LIBS="$x_xlibs $curl_cv_save_LIBS"
1099 #ifdef HAVE_SYS_TYPES_H
1100 #include <sys/types.h>
1102 #ifdef HAVE_SYS_TIME_H
1103 #include <sys/time.h>
1108 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1111 curl_cv_gclk_LIBS="$x_xlibs"
1116 LIBS="$curl_cv_save_LIBS"
1118 case X-"$curl_cv_gclk_LIBS" in
1120 AC_MSG_RESULT([cannot find clock_gettime])
1121 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1122 curl_func_clock_gettime="no"
1125 AC_MSG_RESULT([no additional lib required])
1126 curl_func_clock_gettime="yes"
1129 if test -z "$curl_cv_save_LIBS"; then
1130 LIBS="$curl_cv_gclk_LIBS"
1132 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1134 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1135 curl_func_clock_gettime="yes"
1139 dnl only do runtime verification when not cross-compiling
1140 if test "x$cross_compiling" != "xyes" &&
1141 test "$curl_func_clock_gettime" = "yes"; then
1142 AC_MSG_CHECKING([if monotonic clock_gettime works])
1146 #ifdef HAVE_SYS_TYPES_H
1147 #include <sys/types.h>
1149 #ifdef HAVE_SYS_TIME_H
1150 #include <sys/time.h>
1155 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1161 AC_MSG_RESULT([yes])
1164 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1165 curl_func_clock_gettime="no"
1166 LIBS="$curl_cv_save_LIBS"
1170 case "$curl_func_clock_gettime" in
1172 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1173 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1182 dnl CURL_CHECK_LIBS_CONNECT
1183 dnl -------------------------------------------------
1184 dnl Verify if network connect function is already available
1185 dnl using current libraries or if another one is required.
1187 AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
1188 AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1189 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
1190 AC_MSG_CHECKING([for connect in libraries])
1191 tst_connect_save_LIBS="$LIBS"
1192 tst_connect_need_LIBS="unknown"
1193 for tst_lib in '' '-lsocket' ; do
1194 if test "$tst_connect_need_LIBS" = "unknown"; then
1195 LIBS="$tst_lib $tst_connect_save_LIBS"
1198 $curl_includes_winsock2
1199 $curl_includes_bsdsocket
1200 #if !defined(HAVE_WINDOWS_H) && !defined(HAVE_PROTO_BSDSOCKET_H)
1201 int connect(int, void*, int);
1204 if(0 != connect(0, 0, 0))
1208 tst_connect_need_LIBS="$tst_lib"
1212 LIBS="$tst_connect_save_LIBS"
1214 case X-"$tst_connect_need_LIBS" in
1216 AC_MSG_RESULT([cannot find connect])
1217 AC_MSG_ERROR([cannot find connect function in libraries.])
1220 AC_MSG_RESULT([yes])
1223 AC_MSG_RESULT([$tst_connect_need_LIBS])
1224 LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
1230 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
1231 dnl -------------------------------------------------
1232 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
1233 dnl symbol that can be further used in custom template configuration
1234 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
1235 dnl argument for the description. Symbol definitions done with this
1236 dnl macro are intended to be exclusively used in handcrafted *.h.in
1237 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
1238 dnl prevents autoheader generation and insertion of symbol template
1239 dnl stub and definition into the first configuration header file. Do
1240 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
1241 dnl one serves different functional needs.
1243 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
1244 cat >>confdefs.h <<_EOF
1245 [@%:@define] $1 ifelse($#, 2, [$2], 1)
1249 dnl CURL_CONFIGURE_PULL_SYS_POLL
1250 dnl -------------------------------------------------
1251 dnl The need for the sys/poll.h inclusion arises mainly to properly
1252 dnl interface AIX systems which define macros 'events' and 'revents'.
1254 AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
1255 AC_REQUIRE([CURL_INCLUDES_POLL])dnl
1257 tst_poll_events_macro_defined="unknown"
1263 #if defined(events) || defined(revents)
1266 force compilation error
1270 tst_poll_events_macro_defined="yes"
1272 tst_poll_events_macro_defined="no"
1275 if test "$tst_poll_events_macro_defined" = "yes"; then
1276 if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
1277 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
1284 dnl CURL_CHECK_FUNC_SELECT
1285 dnl -------------------------------------------------
1286 dnl Test if the socket select() function is available.
1288 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
1289 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
1290 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
1291 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1293 AC_MSG_CHECKING([for select])
1297 #ifdef HAVE_WINDOWS_H
1298 #ifndef WIN32_LEAN_AND_MEAN
1299 #define WIN32_LEAN_AND_MEAN
1301 #ifdef HAVE_WINSOCK2_H
1302 #include <winsock2.h>
1304 #include <windows.h>
1306 #ifdef HAVE_SYS_TYPES_H
1307 #include <sys/types.h>
1309 #ifdef HAVE_SYS_TIME_H
1310 #include <sys/time.h>
1313 #ifndef HAVE_WINDOWS_H
1314 #ifdef HAVE_SYS_SELECT_H
1315 #include <sys/select.h>
1316 #elif defined(HAVE_UNISTD_H)
1319 #ifdef HAVE_SYS_SOCKET_H
1320 #include <sys/socket.h>
1322 $curl_includes_bsdsocket
1325 select(0, 0, 0, 0, 0);
1328 AC_MSG_RESULT([yes])
1329 curl_cv_select="yes"
1335 if test "$curl_cv_select" = "yes"; then
1336 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
1337 [Define to 1 if you have the select function.])
1338 curl_cv_func_select="yes"
1343 dnl CURL_VERIFY_RUNTIMELIBS
1344 dnl -------------------------------------------------
1345 dnl Verify that the shared libs found so far can be used when running
1346 dnl programs, since otherwise the situation will create odd configure errors
1347 dnl that are misleading people.
1349 dnl Make sure this test is run BEFORE the first test in the script that
1350 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
1351 dnl macro. It must also run AFTER all lib-checking macros are complete.
1353 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
1355 dnl this test is of course not sensible if we are cross-compiling!
1356 if test "x$cross_compiling" != xyes; then
1358 dnl just run a program to verify that the libs checked for previous to this
1359 dnl point also is available run-time!
1360 AC_MSG_CHECKING([run-time libs availability])
1367 AC_MSG_RESULT([fine]),
1368 AC_MSG_RESULT([failed])
1369 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
1372 dnl if this test fails, configure has already stopped
1377 dnl CURL_CHECK_CA_BUNDLE
1378 dnl -------------------------------------------------
1379 dnl Check if a default ca-bundle should be used
1381 dnl regarding the paths this will scan:
1382 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
1383 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
1384 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
1385 dnl /usr/local/share/certs/ca-root-nss.crt MidnightBSD
1386 dnl /etc/ssl/cert.pem OpenBSD, MidnightBSD (symlink)
1387 dnl /etc/ssl/certs (CA path) SUSE, FreeBSD
1389 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
1391 AC_MSG_CHECKING([default CA cert bundle/path])
1393 AC_ARG_WITH(ca-bundle,
1394 AS_HELP_STRING([--with-ca-bundle=FILE],
1395 [Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
1396 AS_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
1399 if test "x$want_ca" = "xyes"; then
1400 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
1403 [ want_ca="unset" ])
1404 AC_ARG_WITH(ca-path,
1405 AS_HELP_STRING([--with-ca-path=DIRECTORY],
1406 [Path to a directory containing CA certificates stored individually, with \
1407 their filenames in a hash format. This option can be used with the OpenSSL, \
1408 GnuTLS, mbedTLS and wolfSSL backends. Refer to OpenSSL c_rehash for details. \
1409 (example: /etc/certificates)])
1410 AS_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
1412 want_capath="$withval"
1413 if test "x$want_capath" = "xyes"; then
1414 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
1417 [ want_capath="unset"])
1419 ca_warning=" (warning: certs not found)"
1420 capath_warning=" (warning: certs not found)"
1423 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
1424 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
1427 capath="$want_capath"
1428 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
1429 dnl --with-ca-bundle given
1432 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
1433 dnl --with-ca-path given
1434 if test "x$OPENSSL_ENABLED" != "x1" -a \
1435 "x$GNUTLS_ENABLED" != "x1" -a \
1436 "x$MBEDTLS_ENABLED" != "x1" -a \
1437 "x$WOLFSSL_ENABLED" != "x1"; then
1438 AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS, mbedTLS or wolfSSL])
1440 capath="$want_capath"
1443 dnl first try autodetecting a CA bundle , then a CA path
1444 dnl both autodetections can be skipped by --without-ca-*
1447 if test "x$cross_compiling" != "xyes"; then
1448 dnl NOT cross-compiling and...
1449 dnl neither of the --with-ca-* options are provided
1450 if test "x$want_ca" = "xunset"; then
1451 dnl the path we previously would have installed the curl ca bundle
1452 dnl to, and thus we now check for an already existing cert in that
1453 dnl place in case we find no other
1454 if test "x$prefix" != xNONE; then
1455 cac="${prefix}/share/curl/curl-ca-bundle.crt"
1457 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
1460 for a in /etc/ssl/certs/ca-certificates.crt \
1461 /etc/pki/tls/certs/ca-bundle.crt \
1462 /usr/share/ssl/certs/ca-bundle.crt \
1463 /usr/local/share/certs/ca-root-nss.crt \
1466 if test -f "$a"; then
1472 AC_MSG_NOTICE([want $want_capath ca $ca])
1473 if test "x$want_capath" = "xunset"; then
1474 if test "x$OPENSSL_ENABLED" = "x1" -o \
1475 "x$GNUTLS_ENABLED" = "x1" -o \
1476 "x$MBEDTLS_ENABLED" = "x1" -o \
1477 "x$WOLFSSL_ENABLED" = "x1"; then
1478 check_capath="/etc/ssl/certs"
1482 dnl no option given and cross-compiling
1483 AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
1487 if test "x$ca" = "xno" || test -f "$ca"; then
1491 if test "x$capath" != "xno"; then
1492 check_capath="$capath"
1495 if test ! -z "$check_capath"; then
1496 for a in "$check_capath"; do
1497 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
1498 if test "x$capath" = "xno"; then
1507 if test "x$capath" = "xno"; then
1511 if test "x$ca" != "xno"; then
1512 CURL_CA_BUNDLE='"'$ca'"'
1513 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
1514 AC_SUBST(CURL_CA_BUNDLE)
1515 AC_MSG_RESULT([$ca])
1517 if test "x$capath" != "xno"; then
1518 CURL_CA_PATH="\"$capath\""
1519 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
1520 AC_MSG_RESULT([$capath (capath)])
1522 if test "x$ca" = "xno" && test "x$capath" = "xno"; then
1526 AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
1527 AC_ARG_WITH(ca-fallback,
1528 AS_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
1529 AS_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
1531 if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
1532 AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
1535 [ with_ca_fallback="no"])
1536 AC_MSG_RESULT([$with_ca_fallback])
1537 if test "x$with_ca_fallback" = "xyes"; then
1538 if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
1539 AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
1541 AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
1545 dnl CURL_CHECK_WIN32_LARGEFILE
1546 dnl -------------------------------------------------
1547 dnl Check if curl's WIN32 large file will be used
1549 AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
1550 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
1551 AC_MSG_CHECKING([whether build target supports WIN32 file API])
1552 curl_win32_file_api="no"
1553 if test "$curl_cv_header_windows_h" = "yes"; then
1554 if test x"$enable_largefile" != "xno"; then
1558 #if !defined(_WIN32_WCE) && \
1559 (defined(__MINGW32__) || \
1560 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
1563 WIN32 large file API not supported.
1567 curl_win32_file_api="win32_large_files"
1570 if test "$curl_win32_file_api" = "no"; then
1574 #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
1577 WIN32 small file API not supported.
1581 curl_win32_file_api="win32_small_files"
1585 case "$curl_win32_file_api" in
1587 AC_MSG_RESULT([yes (large file enabled)])
1588 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
1589 [Define to 1 if you are building a Windows target with large file support.])
1590 AC_SUBST(USE_WIN32_LARGE_FILES, [1])
1593 AC_MSG_RESULT([yes (large file disabled)])
1594 AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
1595 [Define to 1 if you are building a Windows target without large file support.])
1596 AC_SUBST(USE_WIN32_SMALL_FILES, [1])
1604 dnl CURL_CHECK_WIN32_CRYPTO
1605 dnl -------------------------------------------------
1606 dnl Check if curl's WIN32 crypto lib can be used
1608 AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [
1609 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
1610 AC_MSG_CHECKING([whether build target supports WIN32 crypto API])
1611 curl_win32_crypto_api="no"
1612 if test "$curl_cv_header_windows_h" = "yes"; then
1616 #ifndef WIN32_LEAN_AND_MEAN
1617 #define WIN32_LEAN_AND_MEAN
1619 #include <windows.h>
1620 #include <wincrypt.h>
1622 HCRYPTPROV hCryptProv;
1623 if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
1624 CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
1625 CryptReleaseContext(hCryptProv, 0);
1629 curl_win32_crypto_api="yes"
1632 case "$curl_win32_crypto_api" in
1634 AC_MSG_RESULT([yes])
1635 AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1,
1636 [Define to 1 if you are building a Windows target with crypto API support.])
1637 AC_SUBST(USE_WIN32_CRYPTO, [1])
1645 dnl CURL_EXPORT_PCDIR ($pcdir)
1646 dnl ------------------------
1647 dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
1649 dnl we need this macro since pkg-config distinguishes among empty and unset
1650 dnl variable while checking PKG_CONFIG_LIBDIR
1653 AC_DEFUN([CURL_EXPORT_PCDIR], [
1654 if test -n "$1"; then
1655 PKG_CONFIG_LIBDIR="$1"
1656 export PKG_CONFIG_LIBDIR
1660 dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
1661 dnl ------------------------
1662 dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
1663 dnl path to it, or 'no' if not found/present.
1665 dnl If pkg-config is present, check that it has info about the $module or
1666 dnl return "no" anyway!
1668 dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
1671 AC_DEFUN([CURL_CHECK_PKGCONFIG], [
1672 if test -n "$PKG_CONFIG"; then
1673 PKGCONFIG="$PKG_CONFIG"
1675 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
1676 [$PATH:/usr/bin:/usr/local/bin])
1679 if test "x$PKGCONFIG" != "xno"; then
1680 AC_MSG_CHECKING([for $1 options with pkg-config])
1681 dnl ask pkg-config about $1
1682 itexists=`CURL_EXPORT_PCDIR([$2]) dnl
1683 $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
1685 if test -z "$itexists"; then
1686 dnl pkg-config does not have info about the given module! set the
1687 dnl variable to 'no'
1691 AC_MSG_RESULT([found])
1697 dnl CURL_GENERATE_CONFIGUREHELP_PM
1698 dnl -------------------------------------------------
1699 dnl Generate test harness configurehelp.pm module, defining and
1700 dnl initializing some perl variables with values which are known
1701 dnl when the configure script runs. For portability reasons, test
1702 dnl harness needs information on how to run the C preprocessor.
1704 AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
1705 AC_REQUIRE([AC_PROG_CPP])dnl
1706 tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
1707 if test -z "$tmp_cpp"; then
1710 cat >./tests/configurehelp.pm <<_EOF
1711 [@%:@] This is a generated file. Do not edit.
1713 package configurehelp;
1725 @ISA = qw(Exporter);
1731 \$Cpreprocessor = '$tmp_cpp';
1739 dnl Check if $cpp -P should be used for extract define values due to gcc 5
1740 dnl splitting up strings and defines between line outputs. gcc by default
1741 dnl (without -P) will show TEST EINVAL TEST as
1743 dnl # 13 "conftest.c"
1745 dnl # 13 "conftest.c" 3 4
1747 dnl # 13 "conftest.c"
1750 AC_DEFUN([CURL_CPP_P], [
1751 AC_MSG_CHECKING([if cpp -P is needed])
1752 AC_EGREP_CPP([TEST.*TEST], [
1755 ], [cpp=no], [cpp=yes])
1756 AC_MSG_RESULT([$cpp])
1758 dnl we need cpp -P so check if it works then
1759 if test "x$cpp" = "xyes"; then
1760 AC_MSG_CHECKING([if cpp -P works])
1761 OLDCPPFLAGS=$CPPFLAGS
1762 CPPFLAGS="$CPPFLAGS -P"
1763 AC_EGREP_CPP([TEST.*TEST], [
1766 ], [cpp_p=yes], [cpp_p=no])
1767 AC_MSG_RESULT([$cpp_p])
1769 if test "x$cpp_p" = "xno"; then
1770 AC_MSG_WARN([failed to figure out cpp -P alternative])
1777 dnl restore CPPFLAGS
1778 CPPFLAGS=$OLDCPPFLAGS
1786 dnl CURL_DARWIN_CFLAGS
1788 dnl Set -Werror=partial-availability to detect possible breaking code
1789 dnl with very low deployment targets.
1792 AC_DEFUN([CURL_DARWIN_CFLAGS], [
1801 AC_MSG_CHECKING([for good-to-use Darwin CFLAGS])
1802 AC_MSG_RESULT([$tst_cflags]);
1804 if test "$tst_cflags" = "yes"; then
1806 CFLAGS="$CFLAGS -Werror=partial-availability"
1807 AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
1808 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1809 [AC_MSG_RESULT([yes])],
1810 [AC_MSG_RESULT([no])
1811 CFLAGS=$old_CFLAGS])
1817 dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
1819 dnl Check to see if the compiler supports __builtin_available. This built-in
1820 dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
1821 dnl the time this macro was written, the function was not yet documented. Its
1822 dnl purpose is to return true if the code is running under a certain OS version
1825 AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
1826 AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
1831 if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
1834 AC_MSG_RESULT([yes])
1835 AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
1836 [Define to 1 if you have the __builtin_available function.])