Imported Upstream version 7.86.0
[platform/upstream/curl.git] / acinclude.m4
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
9 #
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.
13 #
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.
17 #
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
20 #
21 # SPDX-License-Identifier: curl
22 #
23 #***************************************************************************
24
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.
33
34 AC_DEFUN([CURL_CHECK_DEF], [
35   AC_REQUIRE([CURL_CPP_P])dnl
36   OLDCPPFLAGS=$CPPFLAGS
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.])
43   fi
44   if test -z "$GREP"; then
45     AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
46   fi
47   ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
48   tmp_exp=""
49   AC_PREPROC_IFELSE([
50     AC_LANG_SOURCE(
51 ifelse($2,,,[$2])[[
52 #ifdef $1
53 CURL_DEF_TOKEN $1
54 #endif
55     ]])
56   ],[
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
62       tmp_exp=""
63     fi
64   ])
65   if test -z "$tmp_exp"; then
66     AS_VAR_SET(ac_HaveDef, no)
67     ifelse($3,,[AC_MSG_RESULT([no])])
68   else
69     AS_VAR_SET(ac_HaveDef, yes)
70     AS_VAR_SET(ac_Def, $tmp_exp)
71     ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
72   fi
73   AS_VAR_POPDEF([ac_Def])dnl
74   AS_VAR_POPDEF([ac_HaveDef])dnl
75   CPPFLAGS=$OLDCPPFLAGS
76 ])
77
78
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.
85
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])])
89   AC_COMPILE_IFELSE([
90     AC_LANG_SOURCE(
91 ifelse($2,,,[$2])[[
92 int main (void)
93 {
94 #ifdef $1
95   return 0;
96 #else
97   force compilation error
98 #endif
99 }
100     ]])
101   ],[
102     tst_symbol_defined="yes"
103   ],[
104     tst_symbol_defined="no"
105   ])
106   if test "$tst_symbol_defined" = "yes"; then
107     AS_VAR_SET(ac_HaveDef, yes)
108     ifelse($3,,[AC_MSG_RESULT([yes])])
109   else
110     AS_VAR_SET(ac_HaveDef, no)
111     ifelse($3,,[AC_MSG_RESULT([no])])
112   fi
113   AS_VAR_POPDEF([ac_HaveDef])dnl
114 ])
115
116
117 dnl CURL_CHECK_LIB_XNET
118 dnl -------------------------------------------------
119 dnl Verify if X/Open network library is required.
120
121 AC_DEFUN([CURL_CHECK_LIB_XNET], [
122   AC_MSG_CHECKING([if X/Open network library is required])
123   tst_lib_xnet_required="no"
124   AC_COMPILE_IFELSE([
125     AC_LANG_SOURCE([[
126 int main (void)
127 {
128 #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
129   return 0;
130 #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
131   return 0;
132 #else
133   force compilation error
134 #endif
135 }
136     ]])
137   ],[
138     tst_lib_xnet_required="yes"
139     LIBS="-lxnet $LIBS"
140   ])
141   AC_MSG_RESULT([$tst_lib_xnet_required])
142 ])
143
144
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.
150
151 AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
152   AH_VERBATIM([_ALL_SOURCE],
153     [/* Define to 1 if OS is AIX. */
154 #ifndef _ALL_SOURCE
155 #  undef _ALL_SOURCE
156 #endif])
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],[
162 #ifdef _AIX
163    yes_this_is_aix
164 #endif
165   ],[
166     AC_MSG_RESULT([yes])
167     AC_DEFINE(_ALL_SOURCE)
168   ],[
169     AC_MSG_RESULT([no])
170   ])
171 ])
172
173
174 dnl CURL_CHECK_HEADER_WINDOWS
175 dnl -------------------------------------------------
176 dnl Check for compilable and valid windows.h header
177
178 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
179   AC_CACHE_CHECK([for windows.h], [curl_cv_header_windows_h], [
180     AC_COMPILE_IFELSE([
181       AC_LANG_PROGRAM([[
182 #undef inline
183 #ifndef WIN32_LEAN_AND_MEAN
184 #define WIN32_LEAN_AND_MEAN
185 #endif
186 #include <windows.h>
187       ]],[[
188 #if defined(__CYGWIN__) || defined(__CEGCC__)
189         HAVE_WINDOWS_H shall not be defined.
190 #else
191         int dummy=2*WINVER;
192 #endif
193       ]])
194     ],[
195       curl_cv_header_windows_h="yes"
196     ],[
197       curl_cv_header_windows_h="no"
198     ])
199   ])
200   case "$curl_cv_header_windows_h" in
201     yes)
202       AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
203         [Define to 1 if you have the windows.h header file.])
204       ;;
205   esac
206 ])
207
208
209 dnl CURL_CHECK_NATIVE_WINDOWS
210 dnl -------------------------------------------------
211 dnl Check if building a native Windows target
212
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"
218     else
219       AC_COMPILE_IFELSE([
220         AC_LANG_PROGRAM([[
221         ]],[[
222 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
223    (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
224           int dummy=1;
225 #else
226           Not a native Windows build target.
227 #endif
228         ]])
229       ],[
230         curl_cv_native_windows="yes"
231       ],[
232         curl_cv_native_windows="no"
233       ])
234     fi
235   ])
236   AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes)
237 ])
238
239
240 dnl CURL_CHECK_HEADER_WINSOCK2
241 dnl -------------------------------------------------
242 dnl Check for compilable and valid winsock2.h header
243
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], [
247     AC_COMPILE_IFELSE([
248       AC_LANG_PROGRAM([[
249 #undef inline
250 #ifndef WIN32_LEAN_AND_MEAN
251 #define WIN32_LEAN_AND_MEAN
252 #endif
253 #include <windows.h>
254 #include <winsock2.h>
255       ]],[[
256 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
257         HAVE_WINSOCK2_H shall not be defined.
258 #else
259         int dummy=2*IPPROTO_ESP;
260 #endif
261       ]])
262     ],[
263       curl_cv_header_winsock2_h="yes"
264     ],[
265       curl_cv_header_winsock2_h="no"
266     ])
267   ])
268   case "$curl_cv_header_winsock2_h" in
269     yes)
270       AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
271         [Define to 1 if you have the winsock2.h header file.])
272       ;;
273   esac
274 ])
275
276
277 dnl CURL_CHECK_HEADER_WS2TCPIP
278 dnl -------------------------------------------------
279 dnl Check for compilable and valid ws2tcpip.h header
280
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], [
284     AC_COMPILE_IFELSE([
285       AC_LANG_PROGRAM([[
286 #undef inline
287 #ifndef WIN32_LEAN_AND_MEAN
288 #define WIN32_LEAN_AND_MEAN
289 #endif
290 #include <windows.h>
291 #include <winsock2.h>
292 #include <ws2tcpip.h>
293       ]],[[
294 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
295         HAVE_WS2TCPIP_H shall not be defined.
296 #else
297         int dummy=2*IP_PKTINFO;
298 #endif
299       ]])
300     ],[
301       curl_cv_header_ws2tcpip_h="yes"
302     ],[
303       curl_cv_header_ws2tcpip_h="no"
304     ])
305   ])
306   case "$curl_cv_header_ws2tcpip_h" in
307     yes)
308       AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
309         [Define to 1 if you have the ws2tcpip.h header file.])
310       ;;
311   esac
312 ])
313
314
315 dnl CURL_CHECK_HEADER_WINCRYPT
316 dnl -------------------------------------------------
317 dnl Check for compilable and valid wincrypt.h header
318
319 AC_DEFUN([CURL_CHECK_HEADER_WINCRYPT], [
320   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
321   AC_CACHE_CHECK([for wincrypt.h], [curl_cv_header_wincrypt_h], [
322     AC_COMPILE_IFELSE([
323       AC_LANG_PROGRAM([[
324 #undef inline
325 #ifndef WIN32_LEAN_AND_MEAN
326 #define WIN32_LEAN_AND_MEAN
327 #endif
328 #include <windows.h>
329 #include <wincrypt.h>
330       ]],[[
331         int dummy=2*PROV_RSA_FULL;
332       ]])
333     ],[
334       curl_cv_header_wincrypt_h="yes"
335     ],[
336       curl_cv_header_wincrypt_h="no"
337     ])
338   ])
339   case "$curl_cv_header_wincrypt_h" in
340     yes)
341       AC_DEFINE_UNQUOTED(HAVE_WINCRYPT_H, 1,
342         [Define to 1 if you have the wincrypt.h header file.])
343       ;;
344   esac
345 ])
346
347
348 dnl CURL_CHECK_HEADER_WINLDAP
349 dnl -------------------------------------------------
350 dnl Check for compilable and valid winldap.h header
351
352 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
353   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
354   AC_CACHE_CHECK([for winldap.h], [curl_cv_header_winldap_h], [
355     AC_COMPILE_IFELSE([
356       AC_LANG_PROGRAM([[
357 #undef inline
358 #ifdef HAVE_WINDOWS_H
359 #ifndef WIN32_LEAN_AND_MEAN
360 #define WIN32_LEAN_AND_MEAN
361 #endif
362 #include <windows.h>
363 #endif
364 #include <winldap.h>
365       ]],[[
366 #if defined(__CYGWIN__) || defined(__CEGCC__)
367         HAVE_WINLDAP_H shall not be defined.
368 #else
369         LDAP *ldp = ldap_init("dummy", LDAP_PORT);
370         ULONG res = ldap_unbind(ldp);
371 #endif
372       ]])
373     ],[
374       curl_cv_header_winldap_h="yes"
375     ],[
376       curl_cv_header_winldap_h="no"
377     ])
378   ])
379   case "$curl_cv_header_winldap_h" in
380     yes)
381       AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
382         [Define to 1 if you have the winldap.h header file.])
383       ;;
384   esac
385 ])
386
387
388 dnl CURL_CHECK_HEADER_LBER
389 dnl -------------------------------------------------
390 dnl Check for compilable and valid lber.h header,
391 dnl and check if it is needed even with ldap.h
392
393 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
394   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
395   AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
396     AC_COMPILE_IFELSE([
397       AC_LANG_PROGRAM([[
398 #undef inline
399 #ifdef HAVE_WINDOWS_H
400 #ifndef WIN32_LEAN_AND_MEAN
401 #define WIN32_LEAN_AND_MEAN
402 #endif
403 #include <windows.h>
404 #else
405 #ifdef HAVE_SYS_TYPES_H
406 #include <sys/types.h>
407 #endif
408 #endif
409 #ifndef NULL
410 #define NULL (void *)0
411 #endif
412 #include <lber.h>
413       ]],[[
414         BerValue *bvp = NULL;
415         BerElement *bep = ber_init(bvp);
416         ber_free(bep, 1);
417       ]])
418     ],[
419       curl_cv_header_lber_h="yes"
420     ],[
421       curl_cv_header_lber_h="no"
422     ])
423   ])
424   if test "$curl_cv_header_lber_h" = "yes"; then
425     AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
426       [Define to 1 if you have the lber.h header file.])
427     #
428     AC_COMPILE_IFELSE([
429       AC_LANG_PROGRAM([[
430 #undef inline
431 #ifdef HAVE_WINDOWS_H
432 #ifndef WIN32_LEAN_AND_MEAN
433 #define WIN32_LEAN_AND_MEAN
434 #endif
435 #include <windows.h>
436 #else
437 #ifdef HAVE_SYS_TYPES_H
438 #include <sys/types.h>
439 #endif
440 #endif
441 #ifndef NULL
442 #define NULL (void *)0
443 #endif
444 #ifndef LDAP_DEPRECATED
445 #define LDAP_DEPRECATED 1
446 #endif
447 #include <ldap.h>
448       ]],[[
449         BerValue *bvp = NULL;
450         BerElement *bep = ber_init(bvp);
451         ber_free(bep, 1);
452       ]])
453     ],[
454       curl_cv_need_header_lber_h="no"
455     ],[
456       curl_cv_need_header_lber_h="yes"
457     ])
458     #
459     case "$curl_cv_need_header_lber_h" in
460       yes)
461         AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
462           [Define to 1 if you need the lber.h header file even with ldap.h])
463         ;;
464     esac
465   fi
466 ])
467
468
469 dnl CURL_CHECK_HEADER_LDAP
470 dnl -------------------------------------------------
471 dnl Check for compilable and valid ldap.h header
472
473 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
474   AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
475   AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
476     AC_COMPILE_IFELSE([
477       AC_LANG_PROGRAM([[
478 #undef inline
479 #ifdef HAVE_WINDOWS_H
480 #ifndef WIN32_LEAN_AND_MEAN
481 #define WIN32_LEAN_AND_MEAN
482 #endif
483 #include <windows.h>
484 #else
485 #ifdef HAVE_SYS_TYPES_H
486 #include <sys/types.h>
487 #endif
488 #endif
489 #ifndef LDAP_DEPRECATED
490 #define LDAP_DEPRECATED 1
491 #endif
492 #ifdef NEED_LBER_H
493 #include <lber.h>
494 #endif
495 #include <ldap.h>
496       ]],[[
497         LDAP *ldp = ldap_init("dummy", LDAP_PORT);
498         int res = ldap_unbind(ldp);
499       ]])
500     ],[
501       curl_cv_header_ldap_h="yes"
502     ],[
503       curl_cv_header_ldap_h="no"
504     ])
505   ])
506   case "$curl_cv_header_ldap_h" in
507     yes)
508       AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
509         [Define to 1 if you have the ldap.h header file.])
510       ;;
511   esac
512 ])
513
514
515 dnl CURL_CHECK_HEADER_LDAP_SSL
516 dnl -------------------------------------------------
517 dnl Check for compilable and valid ldap_ssl.h header
518
519 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
520   AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
521   AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
522     AC_COMPILE_IFELSE([
523       AC_LANG_PROGRAM([[
524 #undef inline
525 #ifdef HAVE_WINDOWS_H
526 #ifndef WIN32_LEAN_AND_MEAN
527 #define WIN32_LEAN_AND_MEAN
528 #endif
529 #include <windows.h>
530 #else
531 #ifdef HAVE_SYS_TYPES_H
532 #include <sys/types.h>
533 #endif
534 #endif
535 #ifndef LDAP_DEPRECATED
536 #define LDAP_DEPRECATED 1
537 #endif
538 #ifdef NEED_LBER_H
539 #include <lber.h>
540 #endif
541 #ifdef HAVE_LDAP_H
542 #include <ldap.h>
543 #endif
544 #include <ldap_ssl.h>
545       ]],[[
546         LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
547       ]])
548     ],[
549       curl_cv_header_ldap_ssl_h="yes"
550     ],[
551       curl_cv_header_ldap_ssl_h="no"
552     ])
553   ])
554   case "$curl_cv_header_ldap_ssl_h" in
555     yes)
556       AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
557         [Define to 1 if you have the ldap_ssl.h header file.])
558       ;;
559   esac
560 ])
561
562
563 dnl CURL_CHECK_LIBS_WINLDAP
564 dnl -------------------------------------------------
565 dnl Check for libraries needed for WINLDAP support,
566 dnl and prepended to LIBS any needed libraries.
567 dnl This macro can take an optional parameter with a
568 dnl whitespace separated list of libraries to check
569 dnl before the WINLDAP default ones.
570
571 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
572   AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
573   #
574   AC_MSG_CHECKING([for WINLDAP libraries])
575   #
576   u_libs=""
577   #
578   ifelse($1,,,[
579     for x_lib in $1; do
580       case "$x_lib" in
581         -l*)
582           l_lib="$x_lib"
583           ;;
584         *)
585           l_lib="-l$x_lib"
586           ;;
587       esac
588       if test -z "$u_libs"; then
589         u_libs="$l_lib"
590       else
591         u_libs="$u_libs $l_lib"
592       fi
593     done
594   ])
595   #
596   curl_cv_save_LIBS="$LIBS"
597   curl_cv_ldap_LIBS="unknown"
598   #
599   for x_nlibs in '' "$u_libs" \
600     '-lwldap32' ; do
601     if test "$curl_cv_ldap_LIBS" = "unknown"; then
602       if test -z "$x_nlibs"; then
603         LIBS="$curl_cv_save_LIBS"
604       else
605         LIBS="$x_nlibs $curl_cv_save_LIBS"
606       fi
607       AC_LINK_IFELSE([
608         AC_LANG_PROGRAM([[
609 #undef inline
610 #ifdef HAVE_WINDOWS_H
611 #ifndef WIN32_LEAN_AND_MEAN
612 #define WIN32_LEAN_AND_MEAN
613 #endif
614 #include <windows.h>
615 #ifdef HAVE_WINLDAP_H
616 #include <winldap.h>
617 #endif
618 #ifdef HAVE_WINBER_H
619 #include <winber.h>
620 #endif
621 #endif
622         ]],[[
623           BERVAL *bvp = NULL;
624           BerElement *bep = ber_init(bvp);
625           LDAP *ldp = ldap_init("dummy", LDAP_PORT);
626           ULONG res = ldap_unbind(ldp);
627           ber_free(bep, 1);
628         ]])
629       ],[
630         curl_cv_ldap_LIBS="$x_nlibs"
631       ])
632     fi
633   done
634   #
635   LIBS="$curl_cv_save_LIBS"
636   #
637   case X-"$curl_cv_ldap_LIBS" in
638     X-unknown)
639       AC_MSG_RESULT([cannot find WINLDAP libraries])
640       ;;
641     X-)
642       AC_MSG_RESULT([no additional lib required])
643       ;;
644     *)
645       if test -z "$curl_cv_save_LIBS"; then
646         LIBS="$curl_cv_ldap_LIBS"
647       else
648         LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
649       fi
650       AC_MSG_RESULT([$curl_cv_ldap_LIBS])
651       ;;
652   esac
653   #
654 ])
655
656
657 dnl CURL_CHECK_LIBS_LDAP
658 dnl -------------------------------------------------
659 dnl Check for libraries needed for LDAP support,
660 dnl and prepended to LIBS any needed libraries.
661 dnl This macro can take an optional parameter with a
662 dnl whitespace separated list of libraries to check
663 dnl before the default ones.
664
665 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
666   AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
667   #
668   AC_MSG_CHECKING([for LDAP libraries])
669   #
670   u_libs=""
671   #
672   ifelse($1,,,[
673     for x_lib in $1; do
674       case "$x_lib" in
675         -l*)
676           l_lib="$x_lib"
677           ;;
678         *)
679           l_lib="-l$x_lib"
680           ;;
681       esac
682       if test -z "$u_libs"; then
683         u_libs="$l_lib"
684       else
685         u_libs="$u_libs $l_lib"
686       fi
687     done
688   ])
689   #
690   curl_cv_save_LIBS="$LIBS"
691   curl_cv_ldap_LIBS="unknown"
692   #
693   for x_nlibs in '' "$u_libs" \
694     '-lldap' \
695     '-lldap -llber' \
696     '-llber -lldap' \
697     '-lldapssl -lldapx -lldapsdk' \
698     '-lldapsdk -lldapx -lldapssl' \
699     '-lldap -llber -lssl -lcrypto' ; do
700
701     if test "$curl_cv_ldap_LIBS" = "unknown"; then
702       if test -z "$x_nlibs"; then
703         LIBS="$curl_cv_save_LIBS"
704       else
705         LIBS="$x_nlibs $curl_cv_save_LIBS"
706       fi
707       AC_LINK_IFELSE([
708         AC_LANG_PROGRAM([[
709 #undef inline
710 #ifdef HAVE_WINDOWS_H
711 #ifndef WIN32_LEAN_AND_MEAN
712 #define WIN32_LEAN_AND_MEAN
713 #endif
714 #include <windows.h>
715 #else
716 #ifdef HAVE_SYS_TYPES_H
717 #include <sys/types.h>
718 #endif
719 #endif
720 #ifndef NULL
721 #define NULL (void *)0
722 #endif
723 #ifndef LDAP_DEPRECATED
724 #define LDAP_DEPRECATED 1
725 #endif
726 #ifdef NEED_LBER_H
727 #include <lber.h>
728 #endif
729 #ifdef HAVE_LDAP_H
730 #include <ldap.h>
731 #endif
732         ]],[[
733           BerValue *bvp = NULL;
734           BerElement *bep = ber_init(bvp);
735           LDAP *ldp = ldap_init("dummy", LDAP_PORT);
736           int res = ldap_unbind(ldp);
737           ber_free(bep, 1);
738         ]])
739       ],[
740         curl_cv_ldap_LIBS="$x_nlibs"
741       ])
742     fi
743   done
744   #
745   LIBS="$curl_cv_save_LIBS"
746   #
747   case X-"$curl_cv_ldap_LIBS" in
748     X-unknown)
749       AC_MSG_RESULT([cannot find LDAP libraries])
750       ;;
751     X-)
752       AC_MSG_RESULT([no additional lib required])
753       ;;
754     *)
755       if test -z "$curl_cv_save_LIBS"; then
756         LIBS="$curl_cv_ldap_LIBS"
757       else
758         LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
759       fi
760       AC_MSG_RESULT([$curl_cv_ldap_LIBS])
761       ;;
762   esac
763   #
764 ])
765
766
767 dnl TYPE_SOCKADDR_STORAGE
768 dnl -------------------------------------------------
769 dnl Check for struct sockaddr_storage. Most IPv6-enabled
770 dnl hosts have it, but AIX 4.3 is one known exception.
771
772 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
773 [
774    AC_CHECK_TYPE([struct sockaddr_storage],
775         AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
776                   [if struct sockaddr_storage is defined]), ,
777    [
778 #undef inline
779 #ifdef HAVE_WINDOWS_H
780 #ifndef WIN32_LEAN_AND_MEAN
781 #define WIN32_LEAN_AND_MEAN
782 #endif
783 #include <windows.h>
784 #ifdef HAVE_WINSOCK2_H
785 #include <winsock2.h>
786 #endif
787 #else
788 #ifdef HAVE_SYS_TYPES_H
789 #include <sys/types.h>
790 #endif
791 #ifdef HAVE_SYS_SOCKET_H
792 #include <sys/socket.h>
793 #endif
794 #ifdef HAVE_NETINET_IN_H
795 #include <netinet/in.h>
796 #endif
797 #ifdef HAVE_ARPA_INET_H
798 #include <arpa/inet.h>
799 #endif
800 #endif
801    ])
802 ])
803
804 dnl CURL_CHECK_FUNC_RECV
805 dnl -------------------------------------------------
806 dnl Test if the socket recv() function is available,
807
808 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
809   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
810   AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
811   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
812   #
813   AC_MSG_CHECKING([for recv])
814   AC_LINK_IFELSE([
815     AC_LANG_PROGRAM([[
816 #undef inline
817 #ifdef HAVE_WINDOWS_H
818 #ifndef WIN32_LEAN_AND_MEAN
819 #define WIN32_LEAN_AND_MEAN
820 #endif
821 #include <windows.h>
822 #ifdef HAVE_WINSOCK2_H
823 #include <winsock2.h>
824 #endif
825 #else
826 $curl_includes_bsdsocket
827 #ifdef HAVE_SYS_TYPES_H
828 #include <sys/types.h>
829 #endif
830 #ifdef HAVE_SYS_SOCKET_H
831 #include <sys/socket.h>
832 #endif
833 #endif
834     ]],[[
835       recv(0, 0, 0, 0);
836     ]])
837   ],[
838     AC_MSG_RESULT([yes])
839     curl_cv_recv="yes"
840   ],[
841     AC_MSG_RESULT([no])
842     curl_cv_recv="no"
843   ])
844   #
845   if test "$curl_cv_recv" = "yes"; then
846       AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
847         [Define to 1 if you have the recv function.])
848       curl_cv_func_recv="yes"
849   else
850     AC_MSG_ERROR([Unable to link function recv])
851   fi
852 ])
853
854
855 dnl CURL_CHECK_FUNC_SEND
856 dnl -------------------------------------------------
857 dnl Test if the socket send() function is available,
858
859 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
860   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
861   AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
862   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
863   #
864   AC_MSG_CHECKING([for send])
865   AC_LINK_IFELSE([
866     AC_LANG_PROGRAM([[
867 #undef inline
868 #ifdef HAVE_WINDOWS_H
869 #ifndef WIN32_LEAN_AND_MEAN
870 #define WIN32_LEAN_AND_MEAN
871 #endif
872 #include <windows.h>
873 #ifdef HAVE_WINSOCK2_H
874 #include <winsock2.h>
875 #endif
876 #else
877 $curl_includes_bsdsocket
878 #ifdef HAVE_SYS_TYPES_H
879 #include <sys/types.h>
880 #endif
881 #ifdef HAVE_SYS_SOCKET_H
882 #include <sys/socket.h>
883 #endif
884 #endif
885     ]],[[
886       send(0, 0, 0, 0);
887     ]])
888   ],[
889     AC_MSG_RESULT([yes])
890     curl_cv_send="yes"
891   ],[
892     AC_MSG_RESULT([no])
893     curl_cv_send="no"
894   ])
895   #
896   if test "$curl_cv_send" = "yes"; then
897     AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
898       [Define to 1 if you have the send function.])
899     curl_cv_func_send="yes"
900   else
901     AC_MSG_ERROR([Unable to link function send])
902   fi
903 ])
904
905 dnl CURL_CHECK_MSG_NOSIGNAL
906 dnl -------------------------------------------------
907 dnl Check for MSG_NOSIGNAL
908
909 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
910   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
911   AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
912     AC_COMPILE_IFELSE([
913       AC_LANG_PROGRAM([[
914 #undef inline
915 #ifdef HAVE_WINDOWS_H
916 #ifndef WIN32_LEAN_AND_MEAN
917 #define WIN32_LEAN_AND_MEAN
918 #endif
919 #include <windows.h>
920 #ifdef HAVE_WINSOCK2_H
921 #include <winsock2.h>
922 #endif
923 #else
924 #ifdef HAVE_SYS_TYPES_H
925 #include <sys/types.h>
926 #endif
927 #ifdef HAVE_SYS_SOCKET_H
928 #include <sys/socket.h>
929 #endif
930 #endif
931       ]],[[
932         int flag=MSG_NOSIGNAL;
933       ]])
934     ],[
935       curl_cv_msg_nosignal="yes"
936     ],[
937       curl_cv_msg_nosignal="no"
938     ])
939   ])
940   case "$curl_cv_msg_nosignal" in
941     yes)
942       AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
943         [Define to 1 if you have the MSG_NOSIGNAL flag.])
944       ;;
945   esac
946 ])
947
948
949 dnl CURL_CHECK_STRUCT_TIMEVAL
950 dnl -------------------------------------------------
951 dnl Check for timeval struct
952
953 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
954   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
955   AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h)
956   AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
957     AC_COMPILE_IFELSE([
958       AC_LANG_PROGRAM([[
959 #undef inline
960 #ifdef HAVE_WINDOWS_H
961 #ifndef WIN32_LEAN_AND_MEAN
962 #define WIN32_LEAN_AND_MEAN
963 #endif
964 #include <windows.h>
965 #ifdef HAVE_WINSOCK2_H
966 #include <winsock2.h>
967 #endif
968 #endif
969 #ifdef HAVE_SYS_TYPES_H
970 #include <sys/types.h>
971 #endif
972 #ifdef HAVE_SYS_TIME_H
973 #include <sys/time.h>
974 #endif
975 #include <time.h>
976 #ifdef HAVE_SYS_SOCKET_H
977 #include <sys/socket.h>
978 #endif
979       ]],[[
980         struct timeval ts;
981         ts.tv_sec  = 0;
982         ts.tv_usec = 0;
983       ]])
984     ],[
985       curl_cv_struct_timeval="yes"
986     ],[
987       curl_cv_struct_timeval="no"
988     ])
989   ])
990   case "$curl_cv_struct_timeval" in
991     yes)
992       AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
993         [Define to 1 if you have the timeval struct.])
994       ;;
995   esac
996 ])
997
998
999 dnl TYPE_IN_ADDR_T
1000 dnl -------------------------------------------------
1001 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1002 dnl and a few other things.
1003
1004 AC_DEFUN([TYPE_IN_ADDR_T], [
1005   AC_CHECK_TYPE([in_addr_t], ,[
1006     dnl in_addr_t not available
1007     AC_CACHE_CHECK([for in_addr_t equivalent],
1008       [curl_cv_in_addr_t_equiv], [
1009       curl_cv_in_addr_t_equiv="unknown"
1010       for t in "unsigned long" int size_t unsigned long; do
1011         if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1012           AC_LINK_IFELSE([
1013             AC_LANG_PROGRAM([[
1014 #undef inline
1015 #ifdef HAVE_WINDOWS_H
1016 #ifndef WIN32_LEAN_AND_MEAN
1017 #define WIN32_LEAN_AND_MEAN
1018 #endif
1019 #include <windows.h>
1020 #ifdef HAVE_WINSOCK2_H
1021 #include <winsock2.h>
1022 #endif
1023 #else
1024 #ifdef HAVE_SYS_TYPES_H
1025 #include <sys/types.h>
1026 #endif
1027 #ifdef HAVE_SYS_SOCKET_H
1028 #include <sys/socket.h>
1029 #endif
1030 #ifdef HAVE_NETINET_IN_H
1031 #include <netinet/in.h>
1032 #endif
1033 #ifdef HAVE_ARPA_INET_H
1034 #include <arpa/inet.h>
1035 #endif
1036 #endif
1037             ]],[[
1038               $t data = inet_addr ("1.2.3.4");
1039             ]])
1040           ],[
1041             curl_cv_in_addr_t_equiv="$t"
1042           ])
1043         fi
1044       done
1045     ])
1046     case "$curl_cv_in_addr_t_equiv" in
1047       unknown)
1048         AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1049         ;;
1050       *)
1051         AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1052           [Type to use in place of in_addr_t when system does not provide it.])
1053         ;;
1054     esac
1055   ],[
1056 #undef inline
1057 #ifdef HAVE_WINDOWS_H
1058 #ifndef WIN32_LEAN_AND_MEAN
1059 #define WIN32_LEAN_AND_MEAN
1060 #endif
1061 #include <windows.h>
1062 #ifdef HAVE_WINSOCK2_H
1063 #include <winsock2.h>
1064 #endif
1065 #else
1066 #ifdef HAVE_SYS_TYPES_H
1067 #include <sys/types.h>
1068 #endif
1069 #ifdef HAVE_SYS_SOCKET_H
1070 #include <sys/socket.h>
1071 #endif
1072 #ifdef HAVE_NETINET_IN_H
1073 #include <netinet/in.h>
1074 #endif
1075 #ifdef HAVE_ARPA_INET_H
1076 #include <arpa/inet.h>
1077 #endif
1078 #endif
1079   ])
1080 ])
1081
1082
1083 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1084 dnl -------------------------------------------------
1085 dnl Check if monotonic clock_gettime is available.
1086
1087 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1088   AC_CHECK_HEADERS(sys/types.h sys/time.h)
1089   AC_MSG_CHECKING([for monotonic clock_gettime])
1090   #
1091   if test "x$dontwant_rt" = "xno" ; then
1092     AC_COMPILE_IFELSE([
1093       AC_LANG_PROGRAM([[
1094 #ifdef HAVE_SYS_TYPES_H
1095 #include <sys/types.h>
1096 #endif
1097 #ifdef HAVE_SYS_TIME_H
1098 #include <sys/time.h>
1099 #endif
1100 #include <time.h>
1101       ]],[[
1102         struct timespec ts;
1103         (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1104       ]])
1105     ],[
1106       AC_MSG_RESULT([yes])
1107       curl_func_clock_gettime="yes"
1108     ],[
1109       AC_MSG_RESULT([no])
1110       curl_func_clock_gettime="no"
1111     ])
1112   fi
1113   dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1114   dnl until library linking and run-time checks for clock_gettime succeed.
1115 ])
1116
1117
1118 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1119 dnl -------------------------------------------------
1120 dnl If monotonic clock_gettime is available then,
1121 dnl check and prepended to LIBS any needed libraries.
1122
1123 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1124   AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1125   #
1126   if test "$curl_func_clock_gettime" = "yes"; then
1127     #
1128     AC_MSG_CHECKING([for clock_gettime in libraries])
1129     #
1130     curl_cv_save_LIBS="$LIBS"
1131     curl_cv_gclk_LIBS="unknown"
1132     #
1133     for x_xlibs in '' '-lrt' '-lposix4' ; do
1134       if test "$curl_cv_gclk_LIBS" = "unknown"; then
1135         if test -z "$x_xlibs"; then
1136           LIBS="$curl_cv_save_LIBS"
1137         else
1138           LIBS="$x_xlibs $curl_cv_save_LIBS"
1139         fi
1140         AC_LINK_IFELSE([
1141           AC_LANG_PROGRAM([[
1142 #ifdef HAVE_SYS_TYPES_H
1143 #include <sys/types.h>
1144 #endif
1145 #ifdef HAVE_SYS_TIME_H
1146 #include <sys/time.h>
1147 #endif
1148 #include <time.h>
1149           ]],[[
1150             struct timespec ts;
1151             (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1152           ]])
1153         ],[
1154           curl_cv_gclk_LIBS="$x_xlibs"
1155         ])
1156       fi
1157     done
1158     #
1159     LIBS="$curl_cv_save_LIBS"
1160     #
1161     case X-"$curl_cv_gclk_LIBS" in
1162       X-unknown)
1163         AC_MSG_RESULT([cannot find clock_gettime])
1164         AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1165         curl_func_clock_gettime="no"
1166         ;;
1167       X-)
1168         AC_MSG_RESULT([no additional lib required])
1169         curl_func_clock_gettime="yes"
1170         ;;
1171       *)
1172         if test -z "$curl_cv_save_LIBS"; then
1173           LIBS="$curl_cv_gclk_LIBS"
1174         else
1175           LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1176         fi
1177         AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1178         curl_func_clock_gettime="yes"
1179         ;;
1180     esac
1181     #
1182     dnl only do runtime verification when not cross-compiling
1183     if test "x$cross_compiling" != "xyes" &&
1184       test "$curl_func_clock_gettime" = "yes"; then
1185       AC_MSG_CHECKING([if monotonic clock_gettime works])
1186       CURL_RUN_IFELSE([
1187         AC_LANG_PROGRAM([[
1188 #ifdef HAVE_STDLIB_H
1189 #include <stdlib.h>
1190 #endif
1191 #ifdef HAVE_SYS_TYPES_H
1192 #include <sys/types.h>
1193 #endif
1194 #ifdef HAVE_SYS_TIME_H
1195 #include <sys/time.h>
1196 #endif
1197 #include <time.h>
1198         ]],[[
1199           struct timespec ts;
1200           if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1201             exit(0);
1202           else
1203             exit(1);
1204         ]])
1205       ],[
1206         AC_MSG_RESULT([yes])
1207       ],[
1208         AC_MSG_RESULT([no])
1209         AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1210         curl_func_clock_gettime="no"
1211         LIBS="$curl_cv_save_LIBS"
1212       ])
1213     fi
1214     #
1215     case "$curl_func_clock_gettime" in
1216       yes)
1217         AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1218           [Define to 1 if you have the clock_gettime function and monotonic timer.])
1219         ;;
1220     esac
1221     #
1222   fi
1223   #
1224 ])
1225
1226
1227 dnl CURL_CHECK_LIBS_CONNECT
1228 dnl -------------------------------------------------
1229 dnl Verify if network connect function is already available
1230 dnl using current libraries or if another one is required.
1231
1232 AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
1233   AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1234   AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
1235   AC_MSG_CHECKING([for connect in libraries])
1236   tst_connect_save_LIBS="$LIBS"
1237   tst_connect_need_LIBS="unknown"
1238   for tst_lib in '' '-lsocket' ; do
1239     if test "$tst_connect_need_LIBS" = "unknown"; then
1240       LIBS="$tst_lib $tst_connect_save_LIBS"
1241       AC_LINK_IFELSE([
1242         AC_LANG_PROGRAM([[
1243           $curl_includes_winsock2
1244           $curl_includes_bsdsocket
1245           #if !defined(HAVE_WINDOWS_H) && !defined(HAVE_PROTO_BSDSOCKET_H)
1246             int connect(int, void*, int);
1247           #endif
1248         ]],[[
1249           if(0 != connect(0, 0, 0))
1250             return 1;
1251         ]])
1252       ],[
1253         tst_connect_need_LIBS="$tst_lib"
1254       ])
1255     fi
1256   done
1257   LIBS="$tst_connect_save_LIBS"
1258   #
1259   case X-"$tst_connect_need_LIBS" in
1260     X-unknown)
1261       AC_MSG_RESULT([cannot find connect])
1262       AC_MSG_ERROR([cannot find connect function in libraries.])
1263       ;;
1264     X-)
1265       AC_MSG_RESULT([yes])
1266       ;;
1267     *)
1268       AC_MSG_RESULT([$tst_connect_need_LIBS])
1269       LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
1270       ;;
1271   esac
1272 ])
1273
1274
1275 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
1276 dnl -------------------------------------------------
1277 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
1278 dnl symbol that can be further used in custom template configuration
1279 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
1280 dnl argument for the description. Symbol definitions done with this
1281 dnl macro are intended to be exclusively used in handcrafted *.h.in
1282 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
1283 dnl prevents autoheader generation and insertion of symbol template
1284 dnl stub and definition into the first configuration header file. Do
1285 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
1286 dnl one serves different functional needs.
1287
1288 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
1289 cat >>confdefs.h <<_EOF
1290 [@%:@define] $1 ifelse($#, 2, [$2], 1)
1291 _EOF
1292 ])
1293
1294 dnl CURL_CONFIGURE_PULL_SYS_POLL
1295 dnl -------------------------------------------------
1296 dnl The need for the sys/poll.h inclusion arises mainly to properly
1297 dnl interface AIX systems which define macros 'events' and 'revents'.
1298
1299 AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
1300   AC_REQUIRE([CURL_INCLUDES_POLL])dnl
1301   #
1302   tst_poll_events_macro_defined="unknown"
1303   #
1304   AC_COMPILE_IFELSE([
1305     AC_LANG_PROGRAM([[
1306       $curl_includes_poll
1307     ]],[[
1308 #if defined(events) || defined(revents)
1309       return 0;
1310 #else
1311       force compilation error
1312 #endif
1313     ]])
1314   ],[
1315     tst_poll_events_macro_defined="yes"
1316   ],[
1317     tst_poll_events_macro_defined="no"
1318   ])
1319   #
1320   if test "$tst_poll_events_macro_defined" = "yes"; then
1321     if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
1322       CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
1323     fi
1324   fi
1325   #
1326 ])
1327
1328
1329 dnl CURL_CHECK_FUNC_SELECT
1330 dnl -------------------------------------------------
1331 dnl Test if the socket select() function is available.
1332
1333 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
1334   AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
1335   AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
1336   AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1337   #
1338   AC_MSG_CHECKING([for select])
1339   AC_LINK_IFELSE([
1340     AC_LANG_PROGRAM([[
1341 #undef inline
1342 #ifdef HAVE_WINDOWS_H
1343 #ifndef WIN32_LEAN_AND_MEAN
1344 #define WIN32_LEAN_AND_MEAN
1345 #endif
1346 #include <windows.h>
1347 #ifdef HAVE_WINSOCK2_H
1348 #include <winsock2.h>
1349 #endif
1350 #endif
1351 #ifdef HAVE_SYS_TYPES_H
1352 #include <sys/types.h>
1353 #endif
1354 #ifdef HAVE_SYS_TIME_H
1355 #include <sys/time.h>
1356 #endif
1357 #include <time.h>
1358 #ifndef HAVE_WINDOWS_H
1359 #ifdef HAVE_SYS_SELECT_H
1360 #include <sys/select.h>
1361 #elif defined(HAVE_UNISTD_H)
1362 #include <unistd.h>
1363 #endif
1364 #ifdef HAVE_SYS_SOCKET_H
1365 #include <sys/socket.h>
1366 #endif
1367 $curl_includes_bsdsocket
1368 #endif
1369     ]],[[
1370       select(0, 0, 0, 0, 0);
1371     ]])
1372   ],[
1373     AC_MSG_RESULT([yes])
1374     curl_cv_select="yes"
1375   ],[
1376     AC_MSG_RESULT([no])
1377     curl_cv_select="no"
1378   ])
1379   #
1380   if test "$curl_cv_select" = "yes"; then
1381     AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
1382       [Define to 1 if you have the select function.])
1383     curl_cv_func_select="yes"
1384   fi
1385 ])
1386
1387
1388 dnl CURL_VERIFY_RUNTIMELIBS
1389 dnl -------------------------------------------------
1390 dnl Verify that the shared libs found so far can be used when running
1391 dnl programs, since otherwise the situation will create odd configure errors
1392 dnl that are misleading people.
1393 dnl
1394 dnl Make sure this test is run BEFORE the first test in the script that
1395 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
1396 dnl macro. It must also run AFTER all lib-checking macros are complete.
1397
1398 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
1399
1400   dnl this test is of course not sensible if we are cross-compiling!
1401   if test "x$cross_compiling" != xyes; then
1402
1403     dnl just run a program to verify that the libs checked for previous to this
1404     dnl point also is available run-time!
1405     AC_MSG_CHECKING([run-time libs availability])
1406     CURL_RUN_IFELSE([
1407 int main()
1408 {
1409   return 0;
1410 }
1411 ],
1412     AC_MSG_RESULT([fine]),
1413     AC_MSG_RESULT([failed])
1414     AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
1415     )
1416
1417     dnl if this test fails, configure has already stopped
1418   fi
1419 ])
1420
1421
1422 dnl CURL_CHECK_VARIADIC_MACROS
1423 dnl -------------------------------------------------
1424 dnl Check compiler support of variadic macros
1425
1426 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
1427   AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
1428     [curl_cv_variadic_macros_c99], [
1429     AC_COMPILE_IFELSE([
1430       AC_LANG_PROGRAM([[
1431 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
1432 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
1433         int fun3(int arg1, int arg2, int arg3);
1434         int fun2(int arg1, int arg2);
1435         int fun3(int arg1, int arg2, int arg3)
1436         { return arg1 + arg2 + arg3; }
1437         int fun2(int arg1, int arg2)
1438         { return arg1 + arg2; }
1439       ]],[[
1440         int res3 = c99_vmacro3(1, 2, 3);
1441         int res2 = c99_vmacro2(1, 2);
1442       ]])
1443     ],[
1444       curl_cv_variadic_macros_c99="yes"
1445     ],[
1446       curl_cv_variadic_macros_c99="no"
1447     ])
1448   ])
1449   case "$curl_cv_variadic_macros_c99" in
1450     yes)
1451       AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
1452         [Define to 1 if compiler supports C99 variadic macro style.])
1453       ;;
1454   esac
1455   AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
1456     [curl_cv_variadic_macros_gcc], [
1457     AC_COMPILE_IFELSE([
1458       AC_LANG_PROGRAM([[
1459 #define gcc_vmacro3(first, args...) fun3(first, args)
1460 #define gcc_vmacro2(first, args...) fun2(first, args)
1461         int fun3(int arg1, int arg2, int arg3);
1462         int fun2(int arg1, int arg2);
1463         int fun3(int arg1, int arg2, int arg3)
1464         { return arg1 + arg2 + arg3; }
1465         int fun2(int arg1, int arg2)
1466         { return arg1 + arg2; }
1467       ]],[[
1468         int res3 = gcc_vmacro3(1, 2, 3);
1469         int res2 = gcc_vmacro2(1, 2);
1470       ]])
1471     ],[
1472       curl_cv_variadic_macros_gcc="yes"
1473     ],[
1474       curl_cv_variadic_macros_gcc="no"
1475     ])
1476   ])
1477   case "$curl_cv_variadic_macros_gcc" in
1478     yes)
1479       AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
1480         [Define to 1 if compiler supports old gcc variadic macro style.])
1481       ;;
1482   esac
1483 ])
1484
1485
1486 dnl CURL_CHECK_CA_BUNDLE
1487 dnl -------------------------------------------------
1488 dnl Check if a default ca-bundle should be used
1489 dnl
1490 dnl regarding the paths this will scan:
1491 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
1492 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
1493 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
1494 dnl /usr/local/share/certs/ca-root-nss.crt FreeBSD, MidnightBSD
1495 dnl /etc/ssl/cert.pem OpenBSD, FreeBSD, MidnightBSD (symlink)
1496 dnl /etc/ssl/certs/ (ca path) SUSE
1497
1498 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
1499
1500   AC_MSG_CHECKING([default CA cert bundle/path])
1501
1502   AC_ARG_WITH(ca-bundle,
1503 AS_HELP_STRING([--with-ca-bundle=FILE],
1504 [Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
1505 AS_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
1506   [
1507     want_ca="$withval"
1508     if test "x$want_ca" = "xyes"; then
1509       AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
1510     fi
1511   ],
1512   [ want_ca="unset" ])
1513   AC_ARG_WITH(ca-path,
1514 AS_HELP_STRING([--with-ca-path=DIRECTORY],
1515 [Path to a directory containing CA certificates stored individually, with \
1516 their filenames in a hash format. This option can be used with the OpenSSL, \
1517 GnuTLS and mbedTLS backends. Refer to OpenSSL c_rehash for details. \
1518 (example: /etc/certificates)])
1519 AS_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
1520   [
1521     want_capath="$withval"
1522     if test "x$want_capath" = "xyes"; then
1523       AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
1524     fi
1525   ],
1526   [ want_capath="unset"])
1527
1528   ca_warning="   (warning: certs not found)"
1529   capath_warning="   (warning: certs not found)"
1530   check_capath=""
1531
1532   if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
1533           "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
1534     dnl both given
1535     ca="$want_ca"
1536     capath="$want_capath"
1537   elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
1538     dnl --with-ca-bundle given
1539     ca="$want_ca"
1540     capath="no"
1541   elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
1542     dnl --with-ca-path given
1543     if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1" -a "x$MBEDTLS_ENABLED" != "x1"; then
1544       AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS or mbedTLS])
1545     fi
1546     capath="$want_capath"
1547     ca="no"
1548   else
1549     dnl first try autodetecting a CA bundle , then a CA path
1550     dnl both autodetections can be skipped by --without-ca-*
1551     ca="no"
1552     capath="no"
1553     if test "x$cross_compiling" != "xyes"; then
1554       dnl NOT cross-compiling and...
1555       dnl neither of the --with-ca-* options are provided
1556       if test "x$want_ca" = "xunset"; then
1557         dnl the path we previously would have installed the curl ca bundle
1558         dnl to, and thus we now check for an already existing cert in that
1559         dnl place in case we find no other
1560         if test "x$prefix" != xNONE; then
1561           cac="${prefix}/share/curl/curl-ca-bundle.crt"
1562         else
1563           cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
1564         fi
1565
1566         for a in /etc/ssl/certs/ca-certificates.crt \
1567                  /etc/pki/tls/certs/ca-bundle.crt \
1568                  /usr/share/ssl/certs/ca-bundle.crt \
1569                  /usr/local/share/certs/ca-root-nss.crt \
1570                  /etc/ssl/cert.pem \
1571                  "$cac"; do
1572           if test -f "$a"; then
1573             ca="$a"
1574             break
1575           fi
1576         done
1577       fi
1578       if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
1579               "x$OPENSSL_ENABLED" = "x1"; then
1580         check_capath="/etc/ssl/certs/"
1581       fi
1582     else
1583       dnl no option given and cross-compiling
1584       AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
1585     fi
1586   fi
1587
1588   if test "x$ca" = "xno" || test -f "$ca"; then
1589     ca_warning=""
1590   fi
1591
1592   if test "x$capath" != "xno"; then
1593     check_capath="$capath"
1594   fi
1595
1596   if test ! -z "$check_capath"; then
1597     for a in "$check_capath"; do
1598       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
1599         if test "x$capath" = "xno"; then
1600           capath="$a"
1601         fi
1602         capath_warning=""
1603         break
1604       fi
1605     done
1606   fi
1607
1608   if test "x$capath" = "xno"; then
1609     capath_warning=""
1610   fi
1611
1612   if test "x$ca" != "xno"; then
1613     CURL_CA_BUNDLE='"'$ca'"'
1614     AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
1615     AC_SUBST(CURL_CA_BUNDLE)
1616     AC_MSG_RESULT([$ca])
1617   fi
1618   if test "x$capath" != "xno"; then
1619     CURL_CA_PATH="\"$capath\""
1620     AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
1621     AC_MSG_RESULT([$capath (capath)])
1622   fi
1623   if test "x$ca" = "xno" && test "x$capath" = "xno"; then
1624     AC_MSG_RESULT([no])
1625   fi
1626
1627   AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
1628   AC_ARG_WITH(ca-fallback,
1629 AS_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
1630 AS_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
1631   [
1632     if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
1633       AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
1634     fi
1635   ],
1636   [ with_ca_fallback="no"])
1637   AC_MSG_RESULT([$with_ca_fallback])
1638   if test "x$with_ca_fallback" = "xyes"; then
1639     if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
1640       AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
1641     fi
1642     AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
1643   fi
1644 ])
1645
1646 dnl CURL_CHECK_WIN32_LARGEFILE
1647 dnl -------------------------------------------------
1648 dnl Check if curl's WIN32 large file will be used
1649
1650 AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
1651   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
1652   AC_MSG_CHECKING([whether build target supports WIN32 file API])
1653   curl_win32_file_api="no"
1654   if test "$curl_cv_header_windows_h" = "yes"; then
1655     if test x"$enable_largefile" != "xno"; then
1656       AC_COMPILE_IFELSE([
1657         AC_LANG_PROGRAM([[
1658         ]],[[
1659 #if !defined(_WIN32_WCE) && \
1660     (defined(__MINGW32__) || \
1661     (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
1662           int dummy=1;
1663 #else
1664           WIN32 large file API not supported.
1665 #endif
1666         ]])
1667       ],[
1668         curl_win32_file_api="win32_large_files"
1669       ])
1670     fi
1671     if test "$curl_win32_file_api" = "no"; then
1672       AC_COMPILE_IFELSE([
1673         AC_LANG_PROGRAM([[
1674         ]],[[
1675 #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
1676           int dummy=1;
1677 #else
1678           WIN32 small file API not supported.
1679 #endif
1680         ]])
1681       ],[
1682         curl_win32_file_api="win32_small_files"
1683       ])
1684     fi
1685   fi
1686   case "$curl_win32_file_api" in
1687     win32_large_files)
1688       AC_MSG_RESULT([yes (large file enabled)])
1689       AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
1690         [Define to 1 if you are building a Windows target with large file support.])
1691       AC_SUBST(USE_WIN32_LARGE_FILES, [1])
1692       ;;
1693     win32_small_files)
1694       AC_MSG_RESULT([yes (large file disabled)])
1695       AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
1696         [Define to 1 if you are building a Windows target without large file support.])
1697       AC_SUBST(USE_WIN32_SMALL_FILES, [1])
1698       ;;
1699     *)
1700       AC_MSG_RESULT([no])
1701       ;;
1702   esac
1703 ])
1704
1705 dnl CURL_CHECK_WIN32_CRYPTO
1706 dnl -------------------------------------------------
1707 dnl Check if curl's WIN32 crypto lib can be used
1708
1709 AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [
1710   AC_REQUIRE([CURL_CHECK_HEADER_WINCRYPT])dnl
1711   AC_MSG_CHECKING([whether build target supports WIN32 crypto API])
1712   curl_win32_crypto_api="no"
1713   if test "$curl_cv_header_wincrypt_h" = "yes"; then
1714     AC_COMPILE_IFELSE([
1715       AC_LANG_PROGRAM([[
1716 #undef inline
1717 #ifndef WIN32_LEAN_AND_MEAN
1718 #define WIN32_LEAN_AND_MEAN
1719 #endif
1720 #include <windows.h>
1721 #include <wincrypt.h>
1722       ]],[[
1723         HCRYPTPROV hCryptProv;
1724         if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
1725                                CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
1726           CryptReleaseContext(hCryptProv, 0);
1727         }
1728       ]])
1729     ],[
1730       curl_win32_crypto_api="yes"
1731     ])
1732   fi
1733   case "$curl_win32_crypto_api" in
1734     yes)
1735       AC_MSG_RESULT([yes])
1736       AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1,
1737         [Define to 1 if you are building a Windows target with crypto API support.])
1738       AC_SUBST(USE_WIN32_CRYPTO, [1])
1739       ;;
1740     *)
1741       AC_MSG_RESULT([no])
1742       ;;
1743   esac
1744 ])
1745
1746 dnl CURL_EXPORT_PCDIR ($pcdir)
1747 dnl ------------------------
1748 dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
1749 dnl
1750 dnl we need this macro since pkg-config distinguishes among empty and unset
1751 dnl variable while checking PKG_CONFIG_LIBDIR
1752 dnl
1753
1754 AC_DEFUN([CURL_EXPORT_PCDIR], [
1755     if test -n "$1"; then
1756       PKG_CONFIG_LIBDIR="$1"
1757       export PKG_CONFIG_LIBDIR
1758     fi
1759 ])
1760
1761 dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
1762 dnl ------------------------
1763 dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
1764 dnl path to it, or 'no' if not found/present.
1765 dnl
1766 dnl If pkg-config is present, check that it has info about the $module or
1767 dnl return "no" anyway!
1768 dnl
1769 dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
1770 dnl
1771
1772 AC_DEFUN([CURL_CHECK_PKGCONFIG], [
1773     if test -n "$PKG_CONFIG"; then
1774       PKGCONFIG="$PKG_CONFIG"
1775     else
1776       AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
1777         [$PATH:/usr/bin:/usr/local/bin])
1778     fi
1779
1780     if test "x$PKGCONFIG" != "xno"; then
1781       AC_MSG_CHECKING([for $1 options with pkg-config])
1782       dnl ask pkg-config about $1
1783       itexists=`CURL_EXPORT_PCDIR([$2]) dnl
1784         $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
1785
1786       if test -z "$itexists"; then
1787         dnl pkg-config does not have info about the given module! set the
1788         dnl variable to 'no'
1789         PKGCONFIG="no"
1790         AC_MSG_RESULT([no])
1791       else
1792         AC_MSG_RESULT([found])
1793       fi
1794     fi
1795 ])
1796
1797
1798 dnl CURL_GENERATE_CONFIGUREHELP_PM
1799 dnl -------------------------------------------------
1800 dnl Generate test harness configurehelp.pm module, defining and
1801 dnl initializing some perl variables with values which are known
1802 dnl when the configure script runs. For portability reasons, test
1803 dnl harness needs information on how to run the C preprocessor.
1804
1805 AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
1806   AC_REQUIRE([AC_PROG_CPP])dnl
1807   tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
1808   if test -z "$tmp_cpp"; then
1809     tmp_cpp='cpp'
1810   fi
1811   cat >./tests/configurehelp.pm <<_EOF
1812 [@%:@] This is a generated file.  Do not edit.
1813
1814 package configurehelp;
1815
1816 use strict;
1817 use warnings;
1818 use Exporter;
1819
1820 use vars qw(
1821     @ISA
1822     @EXPORT_OK
1823     \$Cpreprocessor
1824     );
1825
1826 @ISA = qw(Exporter);
1827
1828 @EXPORT_OK = qw(
1829     \$Cpreprocessor
1830     );
1831
1832 \$Cpreprocessor = '$tmp_cpp';
1833
1834 1;
1835 _EOF
1836 ])
1837
1838 dnl CURL_CPP_P
1839 dnl
1840 dnl Check if $cpp -P should be used for extract define values due to gcc 5
1841 dnl splitting up strings and defines between line outputs. gcc by default
1842 dnl (without -P) will show TEST EINVAL TEST as
1843 dnl
1844 dnl # 13 "conftest.c"
1845 dnl TEST
1846 dnl # 13 "conftest.c" 3 4
1847 dnl     22
1848 dnl # 13 "conftest.c"
1849 dnl            TEST
1850
1851 AC_DEFUN([CURL_CPP_P], [
1852   AC_MSG_CHECKING([if cpp -P is needed])
1853   AC_EGREP_CPP([TEST.*TEST], [
1854  #include <errno.h>
1855 TEST EINVAL TEST
1856   ], [cpp=no], [cpp=yes])
1857   AC_MSG_RESULT([$cpp])
1858
1859   dnl we need cpp -P so check if it works then
1860   if test "x$cpp" = "xyes"; then
1861     AC_MSG_CHECKING([if cpp -P works])
1862     OLDCPPFLAGS=$CPPFLAGS
1863     CPPFLAGS="$CPPFLAGS -P"
1864     AC_EGREP_CPP([TEST.*TEST], [
1865  #include <errno.h>
1866 TEST EINVAL TEST
1867     ], [cpp_p=yes], [cpp_p=no])
1868     AC_MSG_RESULT([$cpp_p])
1869
1870     if test "x$cpp_p" = "xno"; then
1871       AC_MSG_WARN([failed to figure out cpp -P alternative])
1872       # without -P
1873       CPPPFLAG=""
1874     else
1875       # with -P
1876       CPPPFLAG="-P"
1877     fi
1878     dnl restore CPPFLAGS
1879     CPPFLAGS=$OLDCPPFLAGS
1880   else
1881     # without -P
1882     CPPPFLAG=""
1883   fi
1884 ])
1885
1886
1887 dnl CURL_DARWIN_CFLAGS
1888 dnl
1889 dnl Set -Werror=partial-availability to detect possible breaking code
1890 dnl with very low deployment targets.
1891 dnl
1892
1893 AC_DEFUN([CURL_DARWIN_CFLAGS], [
1894
1895   tst_cflags="no"
1896   case $host_os in
1897     darwin*)
1898       tst_cflags="yes"
1899       ;;
1900   esac
1901
1902   AC_MSG_CHECKING([for good-to-use Darwin CFLAGS])
1903   AC_MSG_RESULT([$tst_cflags]);
1904
1905   if test "$tst_cflags" = "yes"; then
1906     old_CFLAGS=$CFLAGS
1907     CFLAGS="$CFLAGS -Werror=partial-availability"
1908     AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
1909     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1910       [AC_MSG_RESULT([yes])],
1911       [AC_MSG_RESULT([no])
1912       CFLAGS=$old_CFLAGS])
1913   fi
1914
1915 ])
1916
1917
1918 dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
1919 dnl
1920 dnl Check to see if the compiler supports __builtin_available. This built-in
1921 dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
1922 dnl the time this macro was written, the function was not yet documented. Its
1923 dnl purpose is to return true if the code is running under a certain OS version
1924 dnl or later.
1925
1926 AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
1927   AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
1928   AC_COMPILE_IFELSE([
1929     AC_LANG_PROGRAM([[
1930 #include <stdlib.h>
1931     ]],[[
1932       if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
1933     ]])
1934   ],[
1935     AC_MSG_RESULT([yes])
1936     AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
1937         [Define to 1 if you have the __builtin_available function.])
1938   ],[
1939     AC_MSG_RESULT([no])
1940   ])
1941 ])