• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#***************************************************************************
2#                                  _   _ ____  _
3#  Project                     ___| | | |  _ \| |
4#                             / __| | | | |_) | |
5#                            | (__| |_| |  _ <| |___
6#                             \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1998 - 2021, 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#***************************************************************************
22
23dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
24dnl -------------------------------------------------
25dnl Use the C preprocessor to find out if the given object-style symbol
26dnl is defined and get its expansion. This macro will not use default
27dnl includes even if no INCLUDES argument is given. This macro will run
28dnl silently when invoked with three arguments. If the expansion would
29dnl result in a set of double-quoted strings the returned expansion will
30dnl actually be a single double-quoted string concatenating all them.
31
32AC_DEFUN([CURL_CHECK_DEF], [
33  AC_REQUIRE([CURL_CPP_P])dnl
34  OLDCPPFLAGS=$CPPFLAGS
35  # CPPPFLAG comes from CURL_CPP_P
36  CPPFLAGS="$CPPFLAGS $CPPPFLAG"
37  AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
38  AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
39  if test -z "$SED"; then
40    AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
41  fi
42  if test -z "$GREP"; then
43    AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
44  fi
45  ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
46  tmp_exp=""
47  AC_PREPROC_IFELSE([
48    AC_LANG_SOURCE(
49ifelse($2,,,[$2])[[
50#ifdef $1
51CURL_DEF_TOKEN $1
52#endif
53    ]])
54  ],[
55    tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
56      "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
57      "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
58      "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
59    if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
60      tmp_exp=""
61    fi
62  ])
63  if test -z "$tmp_exp"; then
64    AS_VAR_SET(ac_HaveDef, no)
65    ifelse($3,,[AC_MSG_RESULT([no])])
66  else
67    AS_VAR_SET(ac_HaveDef, yes)
68    AS_VAR_SET(ac_Def, $tmp_exp)
69    ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
70  fi
71  AS_VAR_POPDEF([ac_Def])dnl
72  AS_VAR_POPDEF([ac_HaveDef])dnl
73  CPPFLAGS=$OLDCPPFLAGS
74])
75
76
77dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
78dnl -------------------------------------------------
79dnl Use the C compiler to find out only if the given symbol is defined
80dnl or not, this can not find out its expansion. This macro will not use
81dnl default includes even if no INCLUDES argument is given. This macro
82dnl will run silently when invoked with three arguments.
83
84AC_DEFUN([CURL_CHECK_DEF_CC], [
85  AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
86  ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
87  AC_COMPILE_IFELSE([
88    AC_LANG_SOURCE(
89ifelse($2,,,[$2])[[
90int main (void)
91{
92#ifdef $1
93  return 0;
94#else
95  force compilation error
96#endif
97}
98    ]])
99  ],[
100    tst_symbol_defined="yes"
101  ],[
102    tst_symbol_defined="no"
103  ])
104  if test "$tst_symbol_defined" = "yes"; then
105    AS_VAR_SET(ac_HaveDef, yes)
106    ifelse($3,,[AC_MSG_RESULT([yes])])
107  else
108    AS_VAR_SET(ac_HaveDef, no)
109    ifelse($3,,[AC_MSG_RESULT([no])])
110  fi
111  AS_VAR_POPDEF([ac_HaveDef])dnl
112])
113
114
115dnl CURL_CHECK_LIB_XNET
116dnl -------------------------------------------------
117dnl Verify if X/Open network library is required.
118
119AC_DEFUN([CURL_CHECK_LIB_XNET], [
120  AC_MSG_CHECKING([if X/Open network library is required])
121  tst_lib_xnet_required="no"
122  AC_COMPILE_IFELSE([
123    AC_LANG_SOURCE([[
124int main (void)
125{
126#if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
127  return 0;
128#elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
129  return 0;
130#else
131  force compilation error
132#endif
133}
134    ]])
135  ],[
136    tst_lib_xnet_required="yes"
137    LIBS="-lxnet $LIBS"
138  ])
139  AC_MSG_RESULT([$tst_lib_xnet_required])
140])
141
142
143dnl CURL_CHECK_AIX_ALL_SOURCE
144dnl -------------------------------------------------
145dnl Provides a replacement of traditional AC_AIX with
146dnl an uniform behavior across all autoconf versions,
147dnl and with our own placement rules.
148
149AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
150  AH_VERBATIM([_ALL_SOURCE],
151    [/* Define to 1 if OS is AIX. */
152#ifndef _ALL_SOURCE
153#  undef _ALL_SOURCE
154#endif])
155  AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
156  AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
157  AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
158  AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
159  AC_EGREP_CPP([yes_this_is_aix],[
160#ifdef _AIX
161   yes_this_is_aix
162#endif
163  ],[
164    AC_MSG_RESULT([yes])
165    AC_DEFINE(_ALL_SOURCE)
166  ],[
167    AC_MSG_RESULT([no])
168  ])
169])
170
171
172dnl CURL_CHECK_HEADER_WINDOWS
173dnl -------------------------------------------------
174dnl Check for compilable and valid windows.h header
175
176AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
177  AC_CACHE_CHECK([for windows.h], [curl_cv_header_windows_h], [
178    AC_COMPILE_IFELSE([
179      AC_LANG_PROGRAM([[
180#undef inline
181#ifndef WIN32_LEAN_AND_MEAN
182#define WIN32_LEAN_AND_MEAN
183#endif
184#include <windows.h>
185      ]],[[
186#if defined(__CYGWIN__) || defined(__CEGCC__)
187        HAVE_WINDOWS_H shall not be defined.
188#else
189        int dummy=2*WINVER;
190#endif
191      ]])
192    ],[
193      curl_cv_header_windows_h="yes"
194    ],[
195      curl_cv_header_windows_h="no"
196    ])
197  ])
198  case "$curl_cv_header_windows_h" in
199    yes)
200      AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
201        [Define to 1 if you have the windows.h header file.])
202      ;;
203  esac
204])
205
206
207dnl CURL_CHECK_NATIVE_WINDOWS
208dnl -------------------------------------------------
209dnl Check if building a native Windows target
210
211AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
212  AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
213  AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [
214    if test "$curl_cv_header_windows_h" = "no"; then
215      curl_cv_native_windows="no"
216    else
217      AC_COMPILE_IFELSE([
218        AC_LANG_PROGRAM([[
219        ]],[[
220#if defined(__MINGW32__) || defined(__MINGW32CE__) || \
221   (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
222          int dummy=1;
223#else
224          Not a native Windows build target.
225#endif
226        ]])
227      ],[
228        curl_cv_native_windows="yes"
229      ],[
230        curl_cv_native_windows="no"
231      ])
232    fi
233  ])
234  AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes)
235])
236
237
238dnl CURL_CHECK_HEADER_WINSOCK
239dnl -------------------------------------------------
240dnl Check for compilable and valid winsock.h header
241
242AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
243  AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
244  AC_CACHE_CHECK([for winsock.h], [curl_cv_header_winsock_h], [
245    AC_COMPILE_IFELSE([
246      AC_LANG_PROGRAM([[
247#undef inline
248#ifndef WIN32_LEAN_AND_MEAN
249#define WIN32_LEAN_AND_MEAN
250#endif
251#include <windows.h>
252#include <winsock.h>
253      ]],[[
254#if defined(__CYGWIN__) || defined(__CEGCC__)
255        HAVE_WINSOCK_H shall not be defined.
256#else
257        int dummy=WSACleanup();
258#endif
259      ]])
260    ],[
261      curl_cv_header_winsock_h="yes"
262    ],[
263      curl_cv_header_winsock_h="no"
264    ])
265  ])
266  case "$curl_cv_header_winsock_h" in
267    yes)
268      AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
269        [Define to 1 if you have the winsock.h header file.])
270      ;;
271  esac
272])
273
274
275dnl CURL_CHECK_HEADER_WINSOCK2
276dnl -------------------------------------------------
277dnl Check for compilable and valid winsock2.h header
278
279AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
280  AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
281  AC_CACHE_CHECK([for winsock2.h], [curl_cv_header_winsock2_h], [
282    AC_COMPILE_IFELSE([
283      AC_LANG_PROGRAM([[
284#undef inline
285#ifndef WIN32_LEAN_AND_MEAN
286#define WIN32_LEAN_AND_MEAN
287#endif
288#include <windows.h>
289#include <winsock2.h>
290      ]],[[
291#if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
292        HAVE_WINSOCK2_H shall not be defined.
293#else
294        int dummy=2*IPPROTO_ESP;
295#endif
296      ]])
297    ],[
298      curl_cv_header_winsock2_h="yes"
299    ],[
300      curl_cv_header_winsock2_h="no"
301    ])
302  ])
303  case "$curl_cv_header_winsock2_h" in
304    yes)
305      AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
306        [Define to 1 if you have the winsock2.h header file.])
307      ;;
308  esac
309])
310
311
312dnl CURL_CHECK_HEADER_WS2TCPIP
313dnl -------------------------------------------------
314dnl Check for compilable and valid ws2tcpip.h header
315
316AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
317  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
318  AC_CACHE_CHECK([for ws2tcpip.h], [curl_cv_header_ws2tcpip_h], [
319    AC_COMPILE_IFELSE([
320      AC_LANG_PROGRAM([[
321#undef inline
322#ifndef WIN32_LEAN_AND_MEAN
323#define WIN32_LEAN_AND_MEAN
324#endif
325#include <windows.h>
326#include <winsock2.h>
327#include <ws2tcpip.h>
328      ]],[[
329#if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
330        HAVE_WS2TCPIP_H shall not be defined.
331#else
332        int dummy=2*IP_PKTINFO;
333#endif
334      ]])
335    ],[
336      curl_cv_header_ws2tcpip_h="yes"
337    ],[
338      curl_cv_header_ws2tcpip_h="no"
339    ])
340  ])
341  case "$curl_cv_header_ws2tcpip_h" in
342    yes)
343      AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
344        [Define to 1 if you have the ws2tcpip.h header file.])
345      ;;
346  esac
347])
348
349
350dnl CURL_CHECK_HEADER_WINCRYPT
351dnl -------------------------------------------------
352dnl Check for compilable and valid wincrypt.h header
353
354AC_DEFUN([CURL_CHECK_HEADER_WINCRYPT], [
355  AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
356  AC_CACHE_CHECK([for wincrypt.h], [curl_cv_header_wincrypt_h], [
357    AC_COMPILE_IFELSE([
358      AC_LANG_PROGRAM([[
359#undef inline
360#ifndef WIN32_LEAN_AND_MEAN
361#define WIN32_LEAN_AND_MEAN
362#endif
363#include <windows.h>
364#include <wincrypt.h>
365      ]],[[
366        int dummy=2*PROV_RSA_FULL;
367      ]])
368    ],[
369      curl_cv_header_wincrypt_h="yes"
370    ],[
371      curl_cv_header_wincrypt_h="no"
372    ])
373  ])
374  case "$curl_cv_header_wincrypt_h" in
375    yes)
376      AC_DEFINE_UNQUOTED(HAVE_WINCRYPT_H, 1,
377        [Define to 1 if you have the wincrypt.h header file.])
378      ;;
379  esac
380])
381
382
383dnl CURL_CHECK_HEADER_WINLDAP
384dnl -------------------------------------------------
385dnl Check for compilable and valid winldap.h header
386
387AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
388  AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
389  AC_CACHE_CHECK([for winldap.h], [curl_cv_header_winldap_h], [
390    AC_COMPILE_IFELSE([
391      AC_LANG_PROGRAM([[
392#undef inline
393#ifdef HAVE_WINDOWS_H
394#ifndef WIN32_LEAN_AND_MEAN
395#define WIN32_LEAN_AND_MEAN
396#endif
397#include <windows.h>
398#endif
399#include <winldap.h>
400      ]],[[
401#if defined(__CYGWIN__) || defined(__CEGCC__)
402        HAVE_WINLDAP_H shall not be defined.
403#else
404        LDAP *ldp = ldap_init("dummy", LDAP_PORT);
405        ULONG res = ldap_unbind(ldp);
406#endif
407      ]])
408    ],[
409      curl_cv_header_winldap_h="yes"
410    ],[
411      curl_cv_header_winldap_h="no"
412    ])
413  ])
414  case "$curl_cv_header_winldap_h" in
415    yes)
416      AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
417        [Define to 1 if you have the winldap.h header file.])
418      ;;
419  esac
420])
421
422
423dnl CURL_CHECK_HEADER_WINBER
424dnl -------------------------------------------------
425dnl Check for compilable and valid winber.h header
426
427AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
428  AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
429  AC_CACHE_CHECK([for winber.h], [curl_cv_header_winber_h], [
430    AC_COMPILE_IFELSE([
431      AC_LANG_PROGRAM([[
432#undef inline
433#ifdef HAVE_WINDOWS_H
434#ifndef WIN32_LEAN_AND_MEAN
435#define WIN32_LEAN_AND_MEAN
436#endif
437#include <windows.h>
438#endif
439#include <winldap.h>
440#include <winber.h>
441      ]],[[
442#if defined(__CYGWIN__) || defined(__CEGCC__)
443        HAVE_WINBER_H shall not be defined.
444#else
445        BERVAL *bvp = NULL;
446        BerElement *bep = ber_init(bvp);
447        ber_free(bep, 1);
448#endif
449      ]])
450    ],[
451      curl_cv_header_winber_h="yes"
452    ],[
453      curl_cv_header_winber_h="no"
454    ])
455  ])
456  case "$curl_cv_header_winber_h" in
457    yes)
458      AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
459        [Define to 1 if you have the winber.h header file.])
460      ;;
461  esac
462])
463
464
465dnl CURL_CHECK_HEADER_LBER
466dnl -------------------------------------------------
467dnl Check for compilable and valid lber.h header,
468dnl and check if it is needed even with ldap.h
469
470AC_DEFUN([CURL_CHECK_HEADER_LBER], [
471  AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
472  AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
473    AC_COMPILE_IFELSE([
474      AC_LANG_PROGRAM([[
475#undef inline
476#ifdef HAVE_WINDOWS_H
477#ifndef WIN32_LEAN_AND_MEAN
478#define WIN32_LEAN_AND_MEAN
479#endif
480#include <windows.h>
481#else
482#ifdef HAVE_SYS_TYPES_H
483#include <sys/types.h>
484#endif
485#endif
486#ifndef NULL
487#define NULL (void *)0
488#endif
489#include <lber.h>
490      ]],[[
491        BerValue *bvp = NULL;
492        BerElement *bep = ber_init(bvp);
493        ber_free(bep, 1);
494      ]])
495    ],[
496      curl_cv_header_lber_h="yes"
497    ],[
498      curl_cv_header_lber_h="no"
499    ])
500  ])
501  if test "$curl_cv_header_lber_h" = "yes"; then
502    AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
503      [Define to 1 if you have the lber.h header file.])
504    #
505    AC_COMPILE_IFELSE([
506      AC_LANG_PROGRAM([[
507#undef inline
508#ifdef HAVE_WINDOWS_H
509#ifndef WIN32_LEAN_AND_MEAN
510#define WIN32_LEAN_AND_MEAN
511#endif
512#include <windows.h>
513#else
514#ifdef HAVE_SYS_TYPES_H
515#include <sys/types.h>
516#endif
517#endif
518#ifndef NULL
519#define NULL (void *)0
520#endif
521#ifndef LDAP_DEPRECATED
522#define LDAP_DEPRECATED 1
523#endif
524#include <ldap.h>
525      ]],[[
526        BerValue *bvp = NULL;
527        BerElement *bep = ber_init(bvp);
528        ber_free(bep, 1);
529      ]])
530    ],[
531      curl_cv_need_header_lber_h="no"
532    ],[
533      curl_cv_need_header_lber_h="yes"
534    ])
535    #
536    case "$curl_cv_need_header_lber_h" in
537      yes)
538        AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
539          [Define to 1 if you need the lber.h header file even with ldap.h])
540        ;;
541    esac
542  fi
543])
544
545
546dnl CURL_CHECK_HEADER_LDAP
547dnl -------------------------------------------------
548dnl Check for compilable and valid ldap.h header
549
550AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
551  AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
552  AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
553    AC_COMPILE_IFELSE([
554      AC_LANG_PROGRAM([[
555#undef inline
556#ifdef HAVE_WINDOWS_H
557#ifndef WIN32_LEAN_AND_MEAN
558#define WIN32_LEAN_AND_MEAN
559#endif
560#include <windows.h>
561#else
562#ifdef HAVE_SYS_TYPES_H
563#include <sys/types.h>
564#endif
565#endif
566#ifndef LDAP_DEPRECATED
567#define LDAP_DEPRECATED 1
568#endif
569#ifdef NEED_LBER_H
570#include <lber.h>
571#endif
572#include <ldap.h>
573      ]],[[
574        LDAP *ldp = ldap_init("dummy", LDAP_PORT);
575        int res = ldap_unbind(ldp);
576      ]])
577    ],[
578      curl_cv_header_ldap_h="yes"
579    ],[
580      curl_cv_header_ldap_h="no"
581    ])
582  ])
583  case "$curl_cv_header_ldap_h" in
584    yes)
585      AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
586        [Define to 1 if you have the ldap.h header file.])
587      ;;
588  esac
589])
590
591
592dnl CURL_CHECK_HEADER_LDAP_SSL
593dnl -------------------------------------------------
594dnl Check for compilable and valid ldap_ssl.h header
595
596AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
597  AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
598  AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
599    AC_COMPILE_IFELSE([
600      AC_LANG_PROGRAM([[
601#undef inline
602#ifdef HAVE_WINDOWS_H
603#ifndef WIN32_LEAN_AND_MEAN
604#define WIN32_LEAN_AND_MEAN
605#endif
606#include <windows.h>
607#else
608#ifdef HAVE_SYS_TYPES_H
609#include <sys/types.h>
610#endif
611#endif
612#ifndef LDAP_DEPRECATED
613#define LDAP_DEPRECATED 1
614#endif
615#ifdef NEED_LBER_H
616#include <lber.h>
617#endif
618#ifdef HAVE_LDAP_H
619#include <ldap.h>
620#endif
621#include <ldap_ssl.h>
622      ]],[[
623        LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
624      ]])
625    ],[
626      curl_cv_header_ldap_ssl_h="yes"
627    ],[
628      curl_cv_header_ldap_ssl_h="no"
629    ])
630  ])
631  case "$curl_cv_header_ldap_ssl_h" in
632    yes)
633      AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
634        [Define to 1 if you have the ldap_ssl.h header file.])
635      ;;
636  esac
637])
638
639
640dnl CURL_CHECK_HEADER_LDAPSSL
641dnl -------------------------------------------------
642dnl Check for compilable and valid ldapssl.h header
643
644AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
645  AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
646  AC_CACHE_CHECK([for ldapssl.h], [curl_cv_header_ldapssl_h], [
647    AC_COMPILE_IFELSE([
648      AC_LANG_PROGRAM([[
649#undef inline
650#ifdef HAVE_WINDOWS_H
651#ifndef WIN32_LEAN_AND_MEAN
652#define WIN32_LEAN_AND_MEAN
653#endif
654#include <windows.h>
655#else
656#ifdef HAVE_SYS_TYPES_H
657#include <sys/types.h>
658#endif
659#endif
660#ifndef NULL
661#define NULL (void *)0
662#endif
663#ifndef LDAP_DEPRECATED
664#define LDAP_DEPRECATED 1
665#endif
666#ifdef NEED_LBER_H
667#include <lber.h>
668#endif
669#ifdef HAVE_LDAP_H
670#include <ldap.h>
671#endif
672#include <ldapssl.h>
673      ]],[[
674        char *cert_label = NULL;
675        LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
676      ]])
677    ],[
678      curl_cv_header_ldapssl_h="yes"
679    ],[
680      curl_cv_header_ldapssl_h="no"
681    ])
682  ])
683  case "$curl_cv_header_ldapssl_h" in
684    yes)
685      AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
686        [Define to 1 if you have the ldapssl.h header file.])
687      ;;
688  esac
689])
690
691
692dnl CURL_CHECK_LIBS_WINLDAP
693dnl -------------------------------------------------
694dnl Check for libraries needed for WINLDAP support,
695dnl and prepended to LIBS any needed libraries.
696dnl This macro can take an optional parameter with a
697dnl whitespace separated list of libraries to check
698dnl before the WINLDAP default ones.
699
700AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
701  AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
702  #
703  AC_MSG_CHECKING([for WINLDAP libraries])
704  #
705  u_libs=""
706  #
707  ifelse($1,,,[
708    for x_lib in $1; do
709      case "$x_lib" in
710        -l*)
711          l_lib="$x_lib"
712          ;;
713        *)
714          l_lib="-l$x_lib"
715          ;;
716      esac
717      if test -z "$u_libs"; then
718        u_libs="$l_lib"
719      else
720        u_libs="$u_libs $l_lib"
721      fi
722    done
723  ])
724  #
725  curl_cv_save_LIBS="$LIBS"
726  curl_cv_ldap_LIBS="unknown"
727  #
728  for x_nlibs in '' "$u_libs" \
729    '-lwldap32' ; do
730    if test "$curl_cv_ldap_LIBS" = "unknown"; then
731      if test -z "$x_nlibs"; then
732        LIBS="$curl_cv_save_LIBS"
733      else
734        LIBS="$x_nlibs $curl_cv_save_LIBS"
735      fi
736      AC_LINK_IFELSE([
737        AC_LANG_PROGRAM([[
738#undef inline
739#ifdef HAVE_WINDOWS_H
740#ifndef WIN32_LEAN_AND_MEAN
741#define WIN32_LEAN_AND_MEAN
742#endif
743#include <windows.h>
744#ifdef HAVE_WINLDAP_H
745#include <winldap.h>
746#endif
747#ifdef HAVE_WINBER_H
748#include <winber.h>
749#endif
750#endif
751        ]],[[
752          BERVAL *bvp = NULL;
753          BerElement *bep = ber_init(bvp);
754          LDAP *ldp = ldap_init("dummy", LDAP_PORT);
755          ULONG res = ldap_unbind(ldp);
756          ber_free(bep, 1);
757        ]])
758      ],[
759        curl_cv_ldap_LIBS="$x_nlibs"
760      ])
761    fi
762  done
763  #
764  LIBS="$curl_cv_save_LIBS"
765  #
766  case X-"$curl_cv_ldap_LIBS" in
767    X-unknown)
768      AC_MSG_RESULT([cannot find WINLDAP libraries])
769      ;;
770    X-)
771      AC_MSG_RESULT([no additional lib required])
772      ;;
773    *)
774      if test -z "$curl_cv_save_LIBS"; then
775        LIBS="$curl_cv_ldap_LIBS"
776      else
777        LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
778      fi
779      AC_MSG_RESULT([$curl_cv_ldap_LIBS])
780      ;;
781  esac
782  #
783])
784
785
786dnl CURL_CHECK_LIBS_LDAP
787dnl -------------------------------------------------
788dnl Check for libraries needed for LDAP support,
789dnl and prepended to LIBS any needed libraries.
790dnl This macro can take an optional parameter with a
791dnl whitespace separated list of libraries to check
792dnl before the default ones.
793
794AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
795  AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
796  #
797  AC_MSG_CHECKING([for LDAP libraries])
798  #
799  u_libs=""
800  #
801  ifelse($1,,,[
802    for x_lib in $1; do
803      case "$x_lib" in
804        -l*)
805          l_lib="$x_lib"
806          ;;
807        *)
808          l_lib="-l$x_lib"
809          ;;
810      esac
811      if test -z "$u_libs"; then
812        u_libs="$l_lib"
813      else
814        u_libs="$u_libs $l_lib"
815      fi
816    done
817  ])
818  #
819  curl_cv_save_LIBS="$LIBS"
820  curl_cv_ldap_LIBS="unknown"
821  #
822  for x_nlibs in '' "$u_libs" \
823    '-lldap' \
824    '-lldap -llber' \
825    '-llber -lldap' \
826    '-lldapssl -lldapx -lldapsdk' \
827    '-lldapsdk -lldapx -lldapssl' \
828    '-lldap -llber -lssl -lcrypto' ; do
829
830    if test "$curl_cv_ldap_LIBS" = "unknown"; then
831      if test -z "$x_nlibs"; then
832        LIBS="$curl_cv_save_LIBS"
833      else
834        LIBS="$x_nlibs $curl_cv_save_LIBS"
835      fi
836      AC_LINK_IFELSE([
837        AC_LANG_PROGRAM([[
838#undef inline
839#ifdef HAVE_WINDOWS_H
840#ifndef WIN32_LEAN_AND_MEAN
841#define WIN32_LEAN_AND_MEAN
842#endif
843#include <windows.h>
844#else
845#ifdef HAVE_SYS_TYPES_H
846#include <sys/types.h>
847#endif
848#endif
849#ifndef NULL
850#define NULL (void *)0
851#endif
852#ifndef LDAP_DEPRECATED
853#define LDAP_DEPRECATED 1
854#endif
855#ifdef NEED_LBER_H
856#include <lber.h>
857#endif
858#ifdef HAVE_LDAP_H
859#include <ldap.h>
860#endif
861        ]],[[
862          BerValue *bvp = NULL;
863          BerElement *bep = ber_init(bvp);
864          LDAP *ldp = ldap_init("dummy", LDAP_PORT);
865          int res = ldap_unbind(ldp);
866          ber_free(bep, 1);
867        ]])
868      ],[
869        curl_cv_ldap_LIBS="$x_nlibs"
870      ])
871    fi
872  done
873  #
874  LIBS="$curl_cv_save_LIBS"
875  #
876  case X-"$curl_cv_ldap_LIBS" in
877    X-unknown)
878      AC_MSG_RESULT([cannot find LDAP libraries])
879      ;;
880    X-)
881      AC_MSG_RESULT([no additional lib required])
882      ;;
883    *)
884      if test -z "$curl_cv_save_LIBS"; then
885        LIBS="$curl_cv_ldap_LIBS"
886      else
887        LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
888      fi
889      AC_MSG_RESULT([$curl_cv_ldap_LIBS])
890      ;;
891  esac
892  #
893])
894
895
896dnl CURL_CHECK_HEADER_MALLOC
897dnl -------------------------------------------------
898dnl Check for compilable and valid malloc.h header,
899dnl and check if it is needed even with stdlib.h
900
901AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
902  AC_CACHE_CHECK([for malloc.h], [curl_cv_header_malloc_h], [
903    AC_COMPILE_IFELSE([
904      AC_LANG_PROGRAM([[
905#include <malloc.h>
906      ]],[[
907        void *p = malloc(10);
908        void *q = calloc(10,10);
909        free(p);
910        free(q);
911      ]])
912    ],[
913      curl_cv_header_malloc_h="yes"
914    ],[
915      curl_cv_header_malloc_h="no"
916    ])
917  ])
918  if test "$curl_cv_header_malloc_h" = "yes"; then
919    AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
920      [Define to 1 if you have the malloc.h header file.])
921    #
922    AC_COMPILE_IFELSE([
923      AC_LANG_PROGRAM([[
924#include <stdlib.h>
925      ]],[[
926        void *p = malloc(10);
927        void *q = calloc(10,10);
928        free(p);
929        free(q);
930      ]])
931    ],[
932      curl_cv_need_header_malloc_h="no"
933    ],[
934      curl_cv_need_header_malloc_h="yes"
935    ])
936    #
937    case "$curl_cv_need_header_malloc_h" in
938      yes)
939        AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
940          [Define to 1 if you need the malloc.h header file even with stdlib.h])
941        ;;
942    esac
943  fi
944])
945
946
947dnl CURL_CHECK_HEADER_MEMORY
948dnl -------------------------------------------------
949dnl Check for compilable and valid memory.h header,
950dnl and check if it is needed even with stdlib.h for
951dnl memory related functions.
952
953AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
954  AC_CACHE_CHECK([for memory.h], [curl_cv_header_memory_h], [
955    AC_COMPILE_IFELSE([
956      AC_LANG_PROGRAM([[
957#include <memory.h>
958      ]],[[
959        void *p = malloc(10);
960        void *q = calloc(10,10);
961        free(p);
962        free(q);
963      ]])
964    ],[
965      curl_cv_header_memory_h="yes"
966    ],[
967      curl_cv_header_memory_h="no"
968    ])
969  ])
970  if test "$curl_cv_header_memory_h" = "yes"; then
971    AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
972      [Define to 1 if you have the memory.h header file.])
973    #
974    AC_COMPILE_IFELSE([
975      AC_LANG_PROGRAM([[
976#include <stdlib.h>
977      ]],[[
978        void *p = malloc(10);
979        void *q = calloc(10,10);
980        free(p);
981        free(q);
982      ]])
983    ],[
984      curl_cv_need_header_memory_h="no"
985    ],[
986      curl_cv_need_header_memory_h="yes"
987    ])
988    #
989    case "$curl_cv_need_header_memory_h" in
990      yes)
991        AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
992          [Define to 1 if you need the memory.h header file even with stdlib.h])
993        ;;
994    esac
995  fi
996])
997
998dnl TYPE_SOCKADDR_STORAGE
999dnl -------------------------------------------------
1000dnl Check for struct sockaddr_storage. Most IPv6-enabled
1001dnl hosts have it, but AIX 4.3 is one known exception.
1002
1003AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1004[
1005   AC_CHECK_TYPE([struct sockaddr_storage],
1006        AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1007                  [if struct sockaddr_storage is defined]), ,
1008   [
1009#undef inline
1010#ifdef HAVE_WINDOWS_H
1011#ifndef WIN32_LEAN_AND_MEAN
1012#define WIN32_LEAN_AND_MEAN
1013#endif
1014#include <windows.h>
1015#ifdef HAVE_WINSOCK2_H
1016#include <winsock2.h>
1017#endif
1018#else
1019#ifdef HAVE_SYS_TYPES_H
1020#include <sys/types.h>
1021#endif
1022#ifdef HAVE_SYS_SOCKET_H
1023#include <sys/socket.h>
1024#endif
1025#ifdef HAVE_NETINET_IN_H
1026#include <netinet/in.h>
1027#endif
1028#ifdef HAVE_ARPA_INET_H
1029#include <arpa/inet.h>
1030#endif
1031#endif
1032   ])
1033])
1034
1035dnl CURL_CHECK_FUNC_RECV
1036dnl -------------------------------------------------
1037dnl Test if the socket recv() function is available,
1038dnl and check its return type and the types of its
1039dnl arguments. If the function succeeds HAVE_RECV
1040dnl will be defined, defining the types of the arguments
1041dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1042dnl and RECV_TYPE_ARG4, defining the type of the function
1043dnl return value in RECV_TYPE_RETV.
1044
1045AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1046  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1047  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1048  AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1049  #
1050  AC_MSG_CHECKING([for recv])
1051  AC_LINK_IFELSE([
1052    AC_LANG_PROGRAM([[
1053#undef inline
1054#ifdef HAVE_WINDOWS_H
1055#ifndef WIN32_LEAN_AND_MEAN
1056#define WIN32_LEAN_AND_MEAN
1057#endif
1058#include <windows.h>
1059#ifdef HAVE_WINSOCK2_H
1060#include <winsock2.h>
1061#else
1062#ifdef HAVE_WINSOCK_H
1063#include <winsock.h>
1064#endif
1065#endif
1066#else
1067#ifdef HAVE_PROTO_BSDSOCKET_H
1068#include <proto/bsdsocket.h>
1069struct Library *SocketBase = NULL;
1070#endif
1071#ifdef HAVE_SYS_TYPES_H
1072#include <sys/types.h>
1073#endif
1074#ifdef HAVE_SYS_SOCKET_H
1075#include <sys/socket.h>
1076#endif
1077#endif
1078    ]],[[
1079      recv(0, 0, 0, 0);
1080    ]])
1081  ],[
1082    AC_MSG_RESULT([yes])
1083    curl_cv_recv="yes"
1084  ],[
1085    AC_MSG_RESULT([no])
1086    curl_cv_recv="no"
1087  ])
1088  #
1089  if test "$curl_cv_recv" = "yes"; then
1090    AC_CACHE_CHECK([types of args and return type for recv],
1091      [curl_cv_func_recv_args], [
1092      curl_cv_func_recv_args="unknown"
1093      for recv_retv in 'int' 'ssize_t'; do
1094        for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1095          for recv_arg2 in 'char *' 'void *'; do
1096            for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1097              for recv_arg4 in 'int' 'unsigned int'; do
1098                if test "$curl_cv_func_recv_args" = "unknown"; then
1099                  AC_COMPILE_IFELSE([
1100                    AC_LANG_PROGRAM([[
1101#undef inline
1102#ifdef HAVE_WINDOWS_H
1103#ifndef WIN32_LEAN_AND_MEAN
1104#define WIN32_LEAN_AND_MEAN
1105#endif
1106#include <windows.h>
1107#ifdef HAVE_WINSOCK2_H
1108#include <winsock2.h>
1109#else
1110#ifdef HAVE_WINSOCK_H
1111#include <winsock.h>
1112#endif
1113#endif
1114#define RECVCALLCONV PASCAL
1115#else
1116#ifdef HAVE_PROTO_BSDSOCKET_H
1117#include <proto/bsdsocket.h>
1118struct Library *SocketBase = NULL;
1119#endif
1120#ifdef HAVE_SYS_TYPES_H
1121#include <sys/types.h>
1122#endif
1123#ifdef HAVE_SYS_SOCKET_H
1124#include <sys/socket.h>
1125#endif
1126#define RECVCALLCONV
1127#endif
1128#ifndef HAVE_PROTO_BSDSOCKET_H
1129                      extern $recv_retv RECVCALLCONV
1130                      recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1131#endif
1132                    ]],[[
1133                      $recv_arg1 s=0;
1134                      $recv_arg2 buf=0;
1135                      $recv_arg3 len=0;
1136                      $recv_arg4 flags=0;
1137                      $recv_retv res = recv(s, buf, len, flags);
1138                    ]])
1139                  ],[
1140                    curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1141                  ])
1142                fi
1143              done
1144            done
1145          done
1146        done
1147      done
1148    ]) # AC-CACHE-CHECK
1149    if test "$curl_cv_func_recv_args" = "unknown"; then
1150      AC_MSG_ERROR([Cannot find proper types to use for recv args])
1151    else
1152      recv_prev_IFS=$IFS; IFS=','
1153      set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1154      IFS=$recv_prev_IFS
1155      shift
1156      #
1157      AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1158        [Define to the type of arg 1 for recv.])
1159      AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1160        [Define to the type of arg 2 for recv.])
1161      AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1162        [Define to the type of arg 3 for recv.])
1163      AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1164        [Define to the type of arg 4 for recv.])
1165      AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1166        [Define to the function return type for recv.])
1167      #
1168      AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1169        [Define to 1 if you have the recv function.])
1170      curl_cv_func_recv="yes"
1171    fi
1172  else
1173    AC_MSG_ERROR([Unable to link function recv])
1174  fi
1175])
1176
1177
1178dnl CURL_CHECK_FUNC_SEND
1179dnl -------------------------------------------------
1180dnl Test if the socket send() function is available,
1181dnl and check its return type and the types of its
1182dnl arguments. If the function succeeds HAVE_SEND
1183dnl will be defined, defining the types of the arguments
1184dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1185dnl and SEND_TYPE_ARG4, defining the type of the function
1186dnl return value in SEND_TYPE_RETV, and also defining the
1187dnl type qualifier of second argument in SEND_QUAL_ARG2.
1188
1189AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1190  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1191  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1192  AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1193  #
1194  AC_MSG_CHECKING([for send])
1195  AC_LINK_IFELSE([
1196    AC_LANG_PROGRAM([[
1197#undef inline
1198#ifdef HAVE_WINDOWS_H
1199#ifndef WIN32_LEAN_AND_MEAN
1200#define WIN32_LEAN_AND_MEAN
1201#endif
1202#include <windows.h>
1203#ifdef HAVE_WINSOCK2_H
1204#include <winsock2.h>
1205#else
1206#ifdef HAVE_WINSOCK_H
1207#include <winsock.h>
1208#endif
1209#endif
1210#else
1211#ifdef HAVE_PROTO_BSDSOCKET_H
1212#include <proto/bsdsocket.h>
1213struct Library *SocketBase = NULL;
1214#endif
1215#ifdef HAVE_SYS_TYPES_H
1216#include <sys/types.h>
1217#endif
1218#ifdef HAVE_SYS_SOCKET_H
1219#include <sys/socket.h>
1220#endif
1221#endif
1222    ]],[[
1223      send(0, 0, 0, 0);
1224    ]])
1225  ],[
1226    AC_MSG_RESULT([yes])
1227    curl_cv_send="yes"
1228  ],[
1229    AC_MSG_RESULT([no])
1230    curl_cv_send="no"
1231  ])
1232  #
1233  if test "$curl_cv_send" = "yes"; then
1234    AC_CACHE_CHECK([types of args and return type for send],
1235      [curl_cv_func_send_args], [
1236      curl_cv_func_send_args="unknown"
1237      for send_retv in 'int' 'ssize_t'; do
1238        for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1239          for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1240            for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1241              for send_arg4 in 'int' 'unsigned int'; do
1242                if test "$curl_cv_func_send_args" = "unknown"; then
1243                  AC_COMPILE_IFELSE([
1244                    AC_LANG_PROGRAM([[
1245#undef inline
1246#ifdef HAVE_WINDOWS_H
1247#ifndef WIN32_LEAN_AND_MEAN
1248#define WIN32_LEAN_AND_MEAN
1249#endif
1250#include <windows.h>
1251#ifdef HAVE_WINSOCK2_H
1252#include <winsock2.h>
1253#else
1254#ifdef HAVE_WINSOCK_H
1255#include <winsock.h>
1256#endif
1257#endif
1258#define SENDCALLCONV PASCAL
1259#else
1260#ifdef HAVE_PROTO_BSDSOCKET_H
1261#include <proto/bsdsocket.h>
1262struct Library *SocketBase = NULL;
1263#endif
1264#ifdef HAVE_SYS_TYPES_H
1265#include <sys/types.h>
1266#endif
1267#ifdef HAVE_SYS_SOCKET_H
1268#include <sys/socket.h>
1269#endif
1270#define SENDCALLCONV
1271#endif
1272#ifndef HAVE_PROTO_BSDSOCKET_H
1273                      extern $send_retv SENDCALLCONV
1274                      send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1275#endif
1276                    ]],[[
1277                      $send_arg1 s=0;
1278                      $send_arg3 len=0;
1279                      $send_arg4 flags=0;
1280                      $send_retv res = send(s, 0, len, flags);
1281                    ]])
1282                  ],[
1283                    curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1284                  ])
1285                fi
1286              done
1287            done
1288          done
1289        done
1290      done
1291    ]) # AC-CACHE-CHECK
1292    if test "$curl_cv_func_send_args" = "unknown"; then
1293      AC_MSG_ERROR([Cannot find proper types to use for send args])
1294    else
1295      send_prev_IFS=$IFS; IFS=','
1296      set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1297      IFS=$send_prev_IFS
1298      shift
1299      #
1300      send_qual_type_arg2=$[2]
1301      #
1302      AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1303        [Define to the type of arg 1 for send.])
1304      AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1305        [Define to the type of arg 3 for send.])
1306      AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1307        [Define to the type of arg 4 for send.])
1308      AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1309        [Define to the function return type for send.])
1310      #
1311      prev_sh_opts=$-
1312      #
1313      case $prev_sh_opts in
1314        *f*)
1315          ;;
1316        *)
1317          set -f
1318          ;;
1319      esac
1320      #
1321      case "$send_qual_type_arg2" in
1322        const*)
1323          send_qual_arg2=const
1324          send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1325        ;;
1326        *)
1327          send_qual_arg2=
1328          send_type_arg2=$send_qual_type_arg2
1329        ;;
1330      esac
1331      #
1332      AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1333        [Define to the type qualifier of arg 2 for send.])
1334      AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1335        [Define to the type of arg 2 for send.])
1336      #
1337      case $prev_sh_opts in
1338        *f*)
1339          ;;
1340        *)
1341          set +f
1342          ;;
1343      esac
1344      #
1345      AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1346        [Define to 1 if you have the send function.])
1347      curl_cv_func_send="yes"
1348    fi
1349  else
1350    AC_MSG_ERROR([Unable to link function send])
1351  fi
1352])
1353
1354dnl CURL_CHECK_MSG_NOSIGNAL
1355dnl -------------------------------------------------
1356dnl Check for MSG_NOSIGNAL
1357
1358AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1359  AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1360  AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
1361    AC_COMPILE_IFELSE([
1362      AC_LANG_PROGRAM([[
1363#undef inline
1364#ifdef HAVE_WINDOWS_H
1365#ifndef WIN32_LEAN_AND_MEAN
1366#define WIN32_LEAN_AND_MEAN
1367#endif
1368#include <windows.h>
1369#ifdef HAVE_WINSOCK2_H
1370#include <winsock2.h>
1371#else
1372#ifdef HAVE_WINSOCK_H
1373#include <winsock.h>
1374#endif
1375#endif
1376#else
1377#ifdef HAVE_PROTO_BSDSOCKET_H
1378#include <proto/bsdsocket.h>
1379struct Library *SocketBase = NULL;
1380#endif
1381#ifdef HAVE_SYS_TYPES_H
1382#include <sys/types.h>
1383#endif
1384#ifdef HAVE_SYS_SOCKET_H
1385#include <sys/socket.h>
1386#endif
1387#endif
1388      ]],[[
1389        int flag=MSG_NOSIGNAL;
1390      ]])
1391    ],[
1392      curl_cv_msg_nosignal="yes"
1393    ],[
1394      curl_cv_msg_nosignal="no"
1395    ])
1396  ])
1397  case "$curl_cv_msg_nosignal" in
1398    yes)
1399      AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1400        [Define to 1 if you have the MSG_NOSIGNAL flag.])
1401      ;;
1402  esac
1403])
1404
1405
1406dnl CURL_CHECK_STRUCT_TIMEVAL
1407dnl -------------------------------------------------
1408dnl Check for timeval struct
1409
1410AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1411  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1412  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1413  AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h)
1414  AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
1415    AC_COMPILE_IFELSE([
1416      AC_LANG_PROGRAM([[
1417#undef inline
1418#ifdef HAVE_WINDOWS_H
1419#ifndef WIN32_LEAN_AND_MEAN
1420#define WIN32_LEAN_AND_MEAN
1421#endif
1422#include <windows.h>
1423#ifdef HAVE_WINSOCK2_H
1424#include <winsock2.h>
1425#else
1426#ifdef HAVE_WINSOCK_H
1427#include <winsock.h>
1428#endif
1429#endif
1430#endif
1431#ifdef HAVE_SYS_TYPES_H
1432#include <sys/types.h>
1433#endif
1434#ifdef HAVE_SYS_TIME_H
1435#include <sys/time.h>
1436#endif
1437#include <time.h>
1438#ifdef HAVE_SYS_SOCKET_H
1439#include <sys/socket.h>
1440#endif
1441      ]],[[
1442        struct timeval ts;
1443        ts.tv_sec  = 0;
1444        ts.tv_usec = 0;
1445      ]])
1446    ],[
1447      curl_cv_struct_timeval="yes"
1448    ],[
1449      curl_cv_struct_timeval="no"
1450    ])
1451  ])
1452  case "$curl_cv_struct_timeval" in
1453    yes)
1454      AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1455        [Define to 1 if you have the timeval struct.])
1456      ;;
1457  esac
1458])
1459
1460
1461dnl TYPE_SIG_ATOMIC_T
1462dnl -------------------------------------------------
1463dnl Check if the sig_atomic_t type is available, and
1464dnl verify if it is already defined as volatile.
1465
1466AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1467  AC_CHECK_HEADERS(signal.h)
1468  AC_CHECK_TYPE([sig_atomic_t],[
1469    AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1470      [Define to 1 if sig_atomic_t is an available typedef.])
1471  ], ,[
1472#ifdef HAVE_SIGNAL_H
1473#include <signal.h>
1474#endif
1475  ])
1476  case "$ac_cv_type_sig_atomic_t" in
1477    yes)
1478      #
1479      AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1480      AC_LINK_IFELSE([
1481        AC_LANG_PROGRAM([[
1482#ifdef HAVE_SIGNAL_H
1483#include <signal.h>
1484#endif
1485        ]],[[
1486          static volatile sig_atomic_t dummy = 0;
1487        ]])
1488      ],[
1489        AC_MSG_RESULT([no])
1490        curl_cv_sig_atomic_t_volatile="no"
1491      ],[
1492        AC_MSG_RESULT([yes])
1493        curl_cv_sig_atomic_t_volatile="yes"
1494      ])
1495      #
1496      if test "$curl_cv_sig_atomic_t_volatile" = "yes"; then
1497        AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1498          [Define to 1 if sig_atomic_t is already defined as volatile.])
1499      fi
1500      ;;
1501  esac
1502])
1503
1504
1505dnl TYPE_IN_ADDR_T
1506dnl -------------------------------------------------
1507dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1508dnl and a few other things.
1509
1510AC_DEFUN([TYPE_IN_ADDR_T], [
1511  AC_CHECK_TYPE([in_addr_t], ,[
1512    dnl in_addr_t not available
1513    AC_CACHE_CHECK([for in_addr_t equivalent],
1514      [curl_cv_in_addr_t_equiv], [
1515      curl_cv_in_addr_t_equiv="unknown"
1516      for t in "unsigned long" int size_t unsigned long; do
1517        if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1518          AC_LINK_IFELSE([
1519            AC_LANG_PROGRAM([[
1520#undef inline
1521#ifdef HAVE_WINDOWS_H
1522#ifndef WIN32_LEAN_AND_MEAN
1523#define WIN32_LEAN_AND_MEAN
1524#endif
1525#include <windows.h>
1526#ifdef HAVE_WINSOCK2_H
1527#include <winsock2.h>
1528#else
1529#ifdef HAVE_WINSOCK_H
1530#include <winsock.h>
1531#endif
1532#endif
1533#else
1534#ifdef HAVE_SYS_TYPES_H
1535#include <sys/types.h>
1536#endif
1537#ifdef HAVE_SYS_SOCKET_H
1538#include <sys/socket.h>
1539#endif
1540#ifdef HAVE_NETINET_IN_H
1541#include <netinet/in.h>
1542#endif
1543#ifdef HAVE_ARPA_INET_H
1544#include <arpa/inet.h>
1545#endif
1546#endif
1547            ]],[[
1548              $t data = inet_addr ("1.2.3.4");
1549            ]])
1550          ],[
1551            curl_cv_in_addr_t_equiv="$t"
1552          ])
1553        fi
1554      done
1555    ])
1556    case "$curl_cv_in_addr_t_equiv" in
1557      unknown)
1558        AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1559        ;;
1560      *)
1561        AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1562          [Type to use in place of in_addr_t when system does not provide it.])
1563        ;;
1564    esac
1565  ],[
1566#undef inline
1567#ifdef HAVE_WINDOWS_H
1568#ifndef WIN32_LEAN_AND_MEAN
1569#define WIN32_LEAN_AND_MEAN
1570#endif
1571#include <windows.h>
1572#ifdef HAVE_WINSOCK2_H
1573#include <winsock2.h>
1574#else
1575#ifdef HAVE_WINSOCK_H
1576#include <winsock.h>
1577#endif
1578#endif
1579#else
1580#ifdef HAVE_SYS_TYPES_H
1581#include <sys/types.h>
1582#endif
1583#ifdef HAVE_SYS_SOCKET_H
1584#include <sys/socket.h>
1585#endif
1586#ifdef HAVE_NETINET_IN_H
1587#include <netinet/in.h>
1588#endif
1589#ifdef HAVE_ARPA_INET_H
1590#include <arpa/inet.h>
1591#endif
1592#endif
1593  ])
1594])
1595
1596
1597dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1598dnl -------------------------------------------------
1599dnl Check if monotonic clock_gettime is available.
1600
1601AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1602  AC_CHECK_HEADERS(sys/types.h sys/time.h)
1603  AC_MSG_CHECKING([for monotonic clock_gettime])
1604  #
1605  if test "x$dontwant_rt" = "xno" ; then
1606    AC_COMPILE_IFELSE([
1607      AC_LANG_PROGRAM([[
1608#ifdef HAVE_SYS_TYPES_H
1609#include <sys/types.h>
1610#endif
1611#ifdef HAVE_SYS_TIME_H
1612#include <sys/time.h>
1613#endif
1614#include <time.h>
1615      ]],[[
1616        struct timespec ts;
1617        (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1618      ]])
1619    ],[
1620      AC_MSG_RESULT([yes])
1621      curl_func_clock_gettime="yes"
1622    ],[
1623      AC_MSG_RESULT([no])
1624      curl_func_clock_gettime="no"
1625    ])
1626  fi
1627  dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1628  dnl until library linking and run-time checks for clock_gettime succeed.
1629])
1630
1631
1632dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1633dnl -------------------------------------------------
1634dnl If monotonic clock_gettime is available then,
1635dnl check and prepended to LIBS any needed libraries.
1636
1637AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1638  AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1639  #
1640  if test "$curl_func_clock_gettime" = "yes"; then
1641    #
1642    AC_MSG_CHECKING([for clock_gettime in libraries])
1643    #
1644    curl_cv_save_LIBS="$LIBS"
1645    curl_cv_gclk_LIBS="unknown"
1646    #
1647    for x_xlibs in '' '-lrt' '-lposix4' ; do
1648      if test "$curl_cv_gclk_LIBS" = "unknown"; then
1649        if test -z "$x_xlibs"; then
1650          LIBS="$curl_cv_save_LIBS"
1651        else
1652          LIBS="$x_xlibs $curl_cv_save_LIBS"
1653        fi
1654        AC_LINK_IFELSE([
1655          AC_LANG_PROGRAM([[
1656#ifdef HAVE_SYS_TYPES_H
1657#include <sys/types.h>
1658#endif
1659#ifdef HAVE_SYS_TIME_H
1660#include <sys/time.h>
1661#endif
1662#include <time.h>
1663          ]],[[
1664            struct timespec ts;
1665            (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1666          ]])
1667        ],[
1668          curl_cv_gclk_LIBS="$x_xlibs"
1669        ])
1670      fi
1671    done
1672    #
1673    LIBS="$curl_cv_save_LIBS"
1674    #
1675    case X-"$curl_cv_gclk_LIBS" in
1676      X-unknown)
1677        AC_MSG_RESULT([cannot find clock_gettime])
1678        AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1679        curl_func_clock_gettime="no"
1680        ;;
1681      X-)
1682        AC_MSG_RESULT([no additional lib required])
1683        curl_func_clock_gettime="yes"
1684        ;;
1685      *)
1686        if test -z "$curl_cv_save_LIBS"; then
1687          LIBS="$curl_cv_gclk_LIBS"
1688        else
1689          LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1690        fi
1691        AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1692        curl_func_clock_gettime="yes"
1693        ;;
1694    esac
1695    #
1696    dnl only do runtime verification when not cross-compiling
1697    if test "x$cross_compiling" != "xyes" &&
1698      test "$curl_func_clock_gettime" = "yes"; then
1699      AC_MSG_CHECKING([if monotonic clock_gettime works])
1700      CURL_RUN_IFELSE([
1701        AC_LANG_PROGRAM([[
1702#ifdef HAVE_STDLIB_H
1703#include <stdlib.h>
1704#endif
1705#ifdef HAVE_SYS_TYPES_H
1706#include <sys/types.h>
1707#endif
1708#ifdef HAVE_SYS_TIME_H
1709#include <sys/time.h>
1710#endif
1711#include <time.h>
1712        ]],[[
1713          struct timespec ts;
1714          if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1715            exit(0);
1716          else
1717            exit(1);
1718        ]])
1719      ],[
1720        AC_MSG_RESULT([yes])
1721      ],[
1722        AC_MSG_RESULT([no])
1723        AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1724        curl_func_clock_gettime="no"
1725        LIBS="$curl_cv_save_LIBS"
1726      ])
1727    fi
1728    #
1729    case "$curl_func_clock_gettime" in
1730      yes)
1731        AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1732          [Define to 1 if you have the clock_gettime function and monotonic timer.])
1733        ;;
1734    esac
1735    #
1736  fi
1737  #
1738])
1739
1740
1741dnl CURL_CHECK_LIBS_CONNECT
1742dnl -------------------------------------------------
1743dnl Verify if network connect function is already available
1744dnl using current libraries or if another one is required.
1745
1746AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
1747  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1748  AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
1749  AC_MSG_CHECKING([for connect in libraries])
1750  tst_connect_save_LIBS="$LIBS"
1751  tst_connect_need_LIBS="unknown"
1752  for tst_lib in '' '-lsocket' ; do
1753    if test "$tst_connect_need_LIBS" = "unknown"; then
1754      LIBS="$tst_lib $tst_connect_save_LIBS"
1755      AC_LINK_IFELSE([
1756        AC_LANG_PROGRAM([[
1757          $curl_includes_winsock2
1758          $curl_includes_bsdsocket
1759          #if !defined(HAVE_WINDOWS_H) && !defined(HAVE_PROTO_BSDSOCKET_H)
1760            int connect(int, void*, int);
1761          #endif
1762        ]],[[
1763          if(0 != connect(0, 0, 0))
1764            return 1;
1765        ]])
1766      ],[
1767        tst_connect_need_LIBS="$tst_lib"
1768      ])
1769    fi
1770  done
1771  LIBS="$tst_connect_save_LIBS"
1772  #
1773  case X-"$tst_connect_need_LIBS" in
1774    X-unknown)
1775      AC_MSG_RESULT([cannot find connect])
1776      AC_MSG_ERROR([cannot find connect function in libraries.])
1777      ;;
1778    X-)
1779      AC_MSG_RESULT([yes])
1780      ;;
1781    *)
1782      AC_MSG_RESULT([$tst_connect_need_LIBS])
1783      LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
1784      ;;
1785  esac
1786])
1787
1788
1789dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
1790dnl -------------------------------------------------
1791dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
1792dnl symbol that can be further used in custom template configuration
1793dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
1794dnl argument for the description. Symbol definitions done with this
1795dnl macro are intended to be exclusively used in handcrafted *.h.in
1796dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
1797dnl prevents autoheader generation and insertion of symbol template
1798dnl stub and definition into the first configuration header file. Do
1799dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
1800dnl one serves different functional needs.
1801
1802AC_DEFUN([CURL_DEFINE_UNQUOTED], [
1803cat >>confdefs.h <<_EOF
1804[@%:@define] $1 ifelse($#, 2, [$2], 1)
1805_EOF
1806])
1807
1808dnl CURL_CONFIGURE_PULL_SYS_POLL
1809dnl -------------------------------------------------
1810dnl The need for the sys/poll.h inclusion arises mainly to properly
1811dnl interface AIX systems which define macros 'events' and 'revents'.
1812
1813AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
1814  AC_REQUIRE([CURL_INCLUDES_POLL])dnl
1815  #
1816  tst_poll_events_macro_defined="unknown"
1817  #
1818  AC_COMPILE_IFELSE([
1819    AC_LANG_PROGRAM([[
1820      $curl_includes_poll
1821    ]],[[
1822#if defined(events) || defined(revents)
1823      return 0;
1824#else
1825      force compilation error
1826#endif
1827    ]])
1828  ],[
1829    tst_poll_events_macro_defined="yes"
1830  ],[
1831    tst_poll_events_macro_defined="no"
1832  ])
1833  #
1834  if test "$tst_poll_events_macro_defined" = "yes"; then
1835    if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
1836      CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
1837    fi
1838  fi
1839  #
1840])
1841
1842
1843dnl CURL_CHECK_FUNC_SELECT
1844dnl -------------------------------------------------
1845dnl Test if the socket select() function is available,
1846dnl and check its return type and the types of its
1847dnl arguments. If the function succeeds HAVE_SELECT
1848dnl will be defined, defining the types of the
1849dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
1850dnl and SELECT_TYPE_ARG5, defining the type of the
1851dnl function return value in SELECT_TYPE_RETV, and
1852dnl also defining the type qualifier of fifth argument
1853dnl in SELECT_QUAL_ARG5.
1854
1855AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
1856  AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
1857  AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1858  #
1859  AC_MSG_CHECKING([for select])
1860  AC_LINK_IFELSE([
1861    AC_LANG_PROGRAM([[
1862#undef inline
1863#ifdef HAVE_WINDOWS_H
1864#ifndef WIN32_LEAN_AND_MEAN
1865#define WIN32_LEAN_AND_MEAN
1866#endif
1867#include <windows.h>
1868#ifdef HAVE_WINSOCK2_H
1869#include <winsock2.h>
1870#else
1871#ifdef HAVE_WINSOCK_H
1872#include <winsock.h>
1873#endif
1874#endif
1875#endif
1876#ifdef HAVE_SYS_TYPES_H
1877#include <sys/types.h>
1878#endif
1879#ifdef HAVE_SYS_TIME_H
1880#include <sys/time.h>
1881#endif
1882#include <time.h>
1883#ifndef HAVE_WINDOWS_H
1884#ifdef HAVE_SYS_SELECT_H
1885#include <sys/select.h>
1886#elif defined(HAVE_UNISTD_H)
1887#include <unistd.h>
1888#endif
1889#ifdef HAVE_SYS_SOCKET_H
1890#include <sys/socket.h>
1891#endif
1892#ifdef HAVE_PROTO_BSDSOCKET_H
1893#include <proto/bsdsocket.h>
1894struct Library *SocketBase = NULL;
1895#define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
1896#endif
1897#endif
1898    ]],[[
1899      select(0, 0, 0, 0, 0);
1900    ]])
1901  ],[
1902    AC_MSG_RESULT([yes])
1903    curl_cv_select="yes"
1904  ],[
1905    AC_MSG_RESULT([no])
1906    curl_cv_select="no"
1907  ])
1908  #
1909  if test "$curl_cv_select" = "yes"; then
1910    AC_CACHE_CHECK([types of args and return type for select],
1911      [curl_cv_func_select_args], [
1912      curl_cv_func_select_args="unknown"
1913      for sel_retv in 'int' 'ssize_t'; do
1914        for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
1915          for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
1916            for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
1917              if test "$curl_cv_func_select_args" = "unknown"; then
1918                AC_COMPILE_IFELSE([
1919                  AC_LANG_PROGRAM([[
1920#undef inline
1921#ifdef HAVE_WINDOWS_H
1922#ifndef WIN32_LEAN_AND_MEAN
1923#define WIN32_LEAN_AND_MEAN
1924#endif
1925#include <windows.h>
1926#ifdef HAVE_WINSOCK2_H
1927#include <winsock2.h>
1928#else
1929#ifdef HAVE_WINSOCK_H
1930#include <winsock.h>
1931#endif
1932#endif
1933#define SELECTCALLCONV PASCAL
1934#endif
1935#ifdef HAVE_SYS_TYPES_H
1936#include <sys/types.h>
1937#endif
1938#ifdef HAVE_SYS_TIME_H
1939#include <sys/time.h>
1940#endif
1941#include <time.h>
1942#ifndef HAVE_WINDOWS_H
1943#ifdef HAVE_SYS_SELECT_H
1944#include <sys/select.h>
1945#elif defined(HAVE_UNISTD_H)
1946#include <unistd.h>
1947#endif
1948#ifdef HAVE_SYS_SOCKET_H
1949#include <sys/socket.h>
1950#endif
1951#ifdef HAVE_PROTO_BSDSOCKET_H
1952#include <proto/bsdsocket.h>
1953struct Library *SocketBase = NULL;
1954#define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
1955#endif
1956#define SELECTCALLCONV
1957#endif
1958#ifndef HAVE_STRUCT_TIMEVAL
1959                    struct timeval {
1960                      long tv_sec;
1961                      long tv_usec;
1962                    };
1963#endif
1964#ifndef HAVE_PROTO_BSDSOCKET_H
1965                    extern $sel_retv SELECTCALLCONV
1966				select($sel_arg1,
1967					$sel_arg234,
1968					$sel_arg234,
1969					$sel_arg234,
1970					$sel_arg5);
1971#endif
1972                  ]],[[
1973                    $sel_arg1   nfds=0;
1974                    $sel_arg234 rfds=0;
1975                    $sel_arg234 wfds=0;
1976                    $sel_arg234 efds=0;
1977                    $sel_retv res = select(nfds, rfds, wfds, efds, 0);
1978                  ]])
1979                ],[
1980                  curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
1981                ])
1982              fi
1983            done
1984          done
1985        done
1986      done
1987    ]) # AC-CACHE-CHECK
1988    if test "$curl_cv_func_select_args" = "unknown"; then
1989      AC_MSG_WARN([Cannot find proper types to use for select args])
1990      AC_MSG_WARN([HAVE_SELECT will not be defined])
1991    else
1992      select_prev_IFS=$IFS; IFS=','
1993      set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
1994      IFS=$select_prev_IFS
1995      shift
1996      #
1997      sel_qual_type_arg5=$[3]
1998      #
1999      AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2000        [Define to the type of arg 1 for select.])
2001      AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2002        [Define to the type of args 2, 3 and 4 for select.])
2003      AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2004        [Define to the function return type for select.])
2005      #
2006      prev_sh_opts=$-
2007      #
2008      case $prev_sh_opts in
2009        *f*)
2010          ;;
2011        *)
2012          set -f
2013          ;;
2014      esac
2015      #
2016      case "$sel_qual_type_arg5" in
2017        const*)
2018          sel_qual_arg5=const
2019          sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2020        ;;
2021        *)
2022          sel_qual_arg5=
2023          sel_type_arg5=$sel_qual_type_arg5
2024        ;;
2025      esac
2026      #
2027      AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2028        [Define to the type qualifier of arg 5 for select.])
2029      AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2030        [Define to the type of arg 5 for select.])
2031      #
2032      case $prev_sh_opts in
2033        *f*)
2034          ;;
2035        *)
2036          set +f
2037          ;;
2038      esac
2039      #
2040      AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2041        [Define to 1 if you have the select function.])
2042      curl_cv_func_select="yes"
2043    fi
2044  fi
2045])
2046
2047
2048dnl CURL_VERIFY_RUNTIMELIBS
2049dnl -------------------------------------------------
2050dnl Verify that the shared libs found so far can be used when running
2051dnl programs, since otherwise the situation will create odd configure errors
2052dnl that are misleading people.
2053dnl
2054dnl Make sure this test is run BEFORE the first test in the script that
2055dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
2056dnl macro. It must also run AFTER all lib-checking macros are complete.
2057
2058AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
2059
2060  dnl this test is of course not sensible if we are cross-compiling!
2061  if test "x$cross_compiling" != xyes; then
2062
2063    dnl just run a program to verify that the libs checked for previous to this
2064    dnl point also is available run-time!
2065    AC_MSG_CHECKING([run-time libs availability])
2066    CURL_RUN_IFELSE([
2067int main()
2068{
2069  return 0;
2070}
2071],
2072    AC_MSG_RESULT([fine]),
2073    AC_MSG_RESULT([failed])
2074    AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
2075    )
2076
2077    dnl if this test fails, configure has already stopped
2078  fi
2079])
2080
2081
2082dnl CURL_CHECK_VARIADIC_MACROS
2083dnl -------------------------------------------------
2084dnl Check compiler support of variadic macros
2085
2086AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
2087  AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
2088    [curl_cv_variadic_macros_c99], [
2089    AC_COMPILE_IFELSE([
2090      AC_LANG_PROGRAM([[
2091#define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
2092#define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
2093        int fun3(int arg1, int arg2, int arg3);
2094        int fun2(int arg1, int arg2);
2095        int fun3(int arg1, int arg2, int arg3)
2096        { return arg1 + arg2 + arg3; }
2097        int fun2(int arg1, int arg2)
2098        { return arg1 + arg2; }
2099      ]],[[
2100        int res3 = c99_vmacro3(1, 2, 3);
2101        int res2 = c99_vmacro2(1, 2);
2102      ]])
2103    ],[
2104      curl_cv_variadic_macros_c99="yes"
2105    ],[
2106      curl_cv_variadic_macros_c99="no"
2107    ])
2108  ])
2109  case "$curl_cv_variadic_macros_c99" in
2110    yes)
2111      AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
2112        [Define to 1 if compiler supports C99 variadic macro style.])
2113      ;;
2114  esac
2115  AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
2116    [curl_cv_variadic_macros_gcc], [
2117    AC_COMPILE_IFELSE([
2118      AC_LANG_PROGRAM([[
2119#define gcc_vmacro3(first, args...) fun3(first, args)
2120#define gcc_vmacro2(first, args...) fun2(first, args)
2121        int fun3(int arg1, int arg2, int arg3);
2122        int fun2(int arg1, int arg2);
2123        int fun3(int arg1, int arg2, int arg3)
2124        { return arg1 + arg2 + arg3; }
2125        int fun2(int arg1, int arg2)
2126        { return arg1 + arg2; }
2127      ]],[[
2128        int res3 = gcc_vmacro3(1, 2, 3);
2129        int res2 = gcc_vmacro2(1, 2);
2130      ]])
2131    ],[
2132      curl_cv_variadic_macros_gcc="yes"
2133    ],[
2134      curl_cv_variadic_macros_gcc="no"
2135    ])
2136  ])
2137  case "$curl_cv_variadic_macros_gcc" in
2138    yes)
2139      AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2140        [Define to 1 if compiler supports old gcc variadic macro style.])
2141      ;;
2142  esac
2143])
2144
2145
2146dnl CURL_CHECK_CA_BUNDLE
2147dnl -------------------------------------------------
2148dnl Check if a default ca-bundle should be used
2149dnl
2150dnl regarding the paths this will scan:
2151dnl /etc/ssl/certs/ca-certificates.crt Debian systems
2152dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
2153dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
2154dnl /usr/local/share/certs/ca-root-nss.crt FreeBSD
2155dnl /etc/ssl/cert.pem OpenBSD, FreeBSD (symlink)
2156dnl /etc/ssl/certs/ (ca path) SUSE
2157
2158AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
2159
2160  AC_MSG_CHECKING([default CA cert bundle/path])
2161
2162  AC_ARG_WITH(ca-bundle,
2163AS_HELP_STRING([--with-ca-bundle=FILE],
2164[Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
2165AS_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
2166  [
2167    want_ca="$withval"
2168    if test "x$want_ca" = "xyes"; then
2169      AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
2170    fi
2171  ],
2172  [ want_ca="unset" ])
2173  AC_ARG_WITH(ca-path,
2174AS_HELP_STRING([--with-ca-path=DIRECTORY],
2175[Path to a directory containing CA certificates stored individually, with \
2176their filenames in a hash format. This option can be used with the OpenSSL, \
2177GnuTLS and mbedTLS backends. Refer to OpenSSL c_rehash for details. \
2178(example: /etc/certificates)])
2179AS_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
2180  [
2181    want_capath="$withval"
2182    if test "x$want_capath" = "xyes"; then
2183      AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
2184    fi
2185  ],
2186  [ want_capath="unset"])
2187
2188  ca_warning="   (warning: certs not found)"
2189  capath_warning="   (warning: certs not found)"
2190  check_capath=""
2191
2192  if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
2193          "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2194    dnl both given
2195    ca="$want_ca"
2196    capath="$want_capath"
2197  elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
2198    dnl --with-ca-bundle given
2199    ca="$want_ca"
2200    capath="no"
2201  elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2202    dnl --with-ca-path given
2203    if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1" -a "x$MBEDTLS_ENABLED" != "x1"; then
2204      AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS or mbedTLS])
2205    fi
2206    capath="$want_capath"
2207    ca="no"
2208  else
2209    dnl first try autodetecting a CA bundle , then a CA path
2210    dnl both autodetections can be skipped by --without-ca-*
2211    ca="no"
2212    capath="no"
2213    if test "x$cross_compiling" != "xyes"; then
2214      dnl NOT cross-compiling and...
2215      dnl neither of the --with-ca-* options are provided
2216      if test "x$want_ca" = "xunset"; then
2217        dnl the path we previously would have installed the curl ca bundle
2218        dnl to, and thus we now check for an already existing cert in that
2219        dnl place in case we find no other
2220        if test "x$prefix" != xNONE; then
2221          cac="${prefix}/share/curl/curl-ca-bundle.crt"
2222        else
2223          cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
2224        fi
2225
2226        for a in /etc/ssl/certs/ca-certificates.crt \
2227                 /etc/pki/tls/certs/ca-bundle.crt \
2228                 /usr/share/ssl/certs/ca-bundle.crt \
2229                 /usr/local/share/certs/ca-root-nss.crt \
2230                 /etc/ssl/cert.pem \
2231                 "$cac"; do
2232          if test -f "$a"; then
2233            ca="$a"
2234            break
2235          fi
2236        done
2237      fi
2238      if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
2239              "x$OPENSSL_ENABLED" = "x1"; then
2240        check_capath="/etc/ssl/certs/"
2241      fi
2242    else
2243      dnl no option given and cross-compiling
2244      AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
2245    fi
2246  fi
2247
2248  if test "x$ca" = "xno" || test -f "$ca"; then
2249    ca_warning=""
2250  fi
2251
2252  if test "x$capath" != "xno"; then
2253    check_capath="$capath"
2254  fi
2255
2256  if test ! -z "$check_capath"; then
2257    for a in "$check_capath"; do
2258      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
2259        if test "x$capath" = "xno"; then
2260          capath="$a"
2261        fi
2262        capath_warning=""
2263        break
2264      fi
2265    done
2266  fi
2267
2268  if test "x$capath" = "xno"; then
2269    capath_warning=""
2270  fi
2271
2272  if test "x$ca" != "xno"; then
2273    CURL_CA_BUNDLE='"'$ca'"'
2274    AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
2275    AC_SUBST(CURL_CA_BUNDLE)
2276    AC_MSG_RESULT([$ca])
2277  fi
2278  if test "x$capath" != "xno"; then
2279    CURL_CA_PATH="\"$capath\""
2280    AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
2281    AC_MSG_RESULT([$capath (capath)])
2282  fi
2283  if test "x$ca" = "xno" && test "x$capath" = "xno"; then
2284    AC_MSG_RESULT([no])
2285  fi
2286
2287  AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
2288  AC_ARG_WITH(ca-fallback,
2289AS_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
2290AS_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
2291  [
2292    if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
2293      AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
2294    fi
2295  ],
2296  [ with_ca_fallback="no"])
2297  AC_MSG_RESULT([$with_ca_fallback])
2298  if test "x$with_ca_fallback" = "xyes"; then
2299    if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
2300      AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
2301    fi
2302    AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
2303  fi
2304])
2305
2306dnl CURL_CHECK_WIN32_LARGEFILE
2307dnl -------------------------------------------------
2308dnl Check if curl's WIN32 large file will be used
2309
2310AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
2311  AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
2312  AC_MSG_CHECKING([whether build target supports WIN32 file API])
2313  curl_win32_file_api="no"
2314  if test "$curl_cv_header_windows_h" = "yes"; then
2315    if test x"$enable_largefile" != "xno"; then
2316      AC_COMPILE_IFELSE([
2317        AC_LANG_PROGRAM([[
2318        ]],[[
2319#if !defined(_WIN32_WCE) && \
2320    (defined(__MINGW32__) || \
2321    (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
2322          int dummy=1;
2323#else
2324          WIN32 large file API not supported.
2325#endif
2326        ]])
2327      ],[
2328        curl_win32_file_api="win32_large_files"
2329      ])
2330    fi
2331    if test "$curl_win32_file_api" = "no"; then
2332      AC_COMPILE_IFELSE([
2333        AC_LANG_PROGRAM([[
2334        ]],[[
2335#if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
2336          int dummy=1;
2337#else
2338          WIN32 small file API not supported.
2339#endif
2340        ]])
2341      ],[
2342        curl_win32_file_api="win32_small_files"
2343      ])
2344    fi
2345  fi
2346  case "$curl_win32_file_api" in
2347    win32_large_files)
2348      AC_MSG_RESULT([yes (large file enabled)])
2349      AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
2350        [Define to 1 if you are building a Windows target with large file support.])
2351      AC_SUBST(USE_WIN32_LARGE_FILES, [1])
2352      ;;
2353    win32_small_files)
2354      AC_MSG_RESULT([yes (large file disabled)])
2355      AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
2356        [Define to 1 if you are building a Windows target without large file support.])
2357      AC_SUBST(USE_WIN32_SMALL_FILES, [1])
2358      ;;
2359    *)
2360      AC_MSG_RESULT([no])
2361      ;;
2362  esac
2363])
2364
2365dnl CURL_CHECK_WIN32_CRYPTO
2366dnl -------------------------------------------------
2367dnl Check if curl's WIN32 crypto lib can be used
2368
2369AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [
2370  AC_REQUIRE([CURL_CHECK_HEADER_WINCRYPT])dnl
2371  AC_MSG_CHECKING([whether build target supports WIN32 crypto API])
2372  curl_win32_crypto_api="no"
2373  if test "$curl_cv_header_wincrypt_h" = "yes"; then
2374    AC_COMPILE_IFELSE([
2375      AC_LANG_PROGRAM([[
2376#undef inline
2377#ifndef WIN32_LEAN_AND_MEAN
2378#define WIN32_LEAN_AND_MEAN
2379#endif
2380#include <windows.h>
2381#include <wincrypt.h>
2382      ]],[[
2383        HCRYPTPROV hCryptProv;
2384        if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
2385                               CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
2386          CryptReleaseContext(hCryptProv, 0);
2387        }
2388      ]])
2389    ],[
2390      curl_win32_crypto_api="yes"
2391    ])
2392  fi
2393  case "$curl_win32_crypto_api" in
2394    yes)
2395      AC_MSG_RESULT([yes])
2396      AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1,
2397        [Define to 1 if you are building a Windows target with crypto API support.])
2398      AC_SUBST(USE_WIN32_CRYPTO, [1])
2399      ;;
2400    *)
2401      AC_MSG_RESULT([no])
2402      ;;
2403  esac
2404])
2405
2406dnl CURL_EXPORT_PCDIR ($pcdir)
2407dnl ------------------------
2408dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
2409dnl
2410dnl we need this macro since pkg-config distinguishes among empty and unset
2411dnl variable while checking PKG_CONFIG_LIBDIR
2412dnl
2413
2414AC_DEFUN([CURL_EXPORT_PCDIR], [
2415    if test -n "$1"; then
2416      PKG_CONFIG_LIBDIR="$1"
2417      export PKG_CONFIG_LIBDIR
2418    fi
2419])
2420
2421dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
2422dnl ------------------------
2423dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
2424dnl path to it, or 'no' if not found/present.
2425dnl
2426dnl If pkg-config is present, check that it has info about the $module or
2427dnl return "no" anyway!
2428dnl
2429dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
2430dnl
2431
2432AC_DEFUN([CURL_CHECK_PKGCONFIG], [
2433    if test -n "$PKG_CONFIG"; then
2434      PKGCONFIG="$PKG_CONFIG"
2435    else
2436      AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
2437        [$PATH:/usr/bin:/usr/local/bin])
2438    fi
2439
2440    if test "x$PKGCONFIG" != "xno"; then
2441      AC_MSG_CHECKING([for $1 options with pkg-config])
2442      dnl ask pkg-config about $1
2443      itexists=`CURL_EXPORT_PCDIR([$2]) dnl
2444        $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
2445
2446      if test -z "$itexists"; then
2447        dnl pkg-config does not have info about the given module! set the
2448        dnl variable to 'no'
2449        PKGCONFIG="no"
2450        AC_MSG_RESULT([no])
2451      else
2452        AC_MSG_RESULT([found])
2453      fi
2454    fi
2455])
2456
2457
2458dnl CURL_GENERATE_CONFIGUREHELP_PM
2459dnl -------------------------------------------------
2460dnl Generate test harness configurehelp.pm module, defining and
2461dnl initializing some perl variables with values which are known
2462dnl when the configure script runs. For portability reasons, test
2463dnl harness needs information on how to run the C preprocessor.
2464
2465AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
2466  AC_REQUIRE([AC_PROG_CPP])dnl
2467  tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
2468  if test -z "$tmp_cpp"; then
2469    tmp_cpp='cpp'
2470  fi
2471  cat >./tests/configurehelp.pm <<_EOF
2472[@%:@] This is a generated file.  Do not edit.
2473
2474package configurehelp;
2475
2476use strict;
2477use warnings;
2478use Exporter;
2479
2480use vars qw(
2481    @ISA
2482    @EXPORT_OK
2483    \$Cpreprocessor
2484    );
2485
2486@ISA = qw(Exporter);
2487
2488@EXPORT_OK = qw(
2489    \$Cpreprocessor
2490    );
2491
2492\$Cpreprocessor = '$tmp_cpp';
2493
24941;
2495_EOF
2496])
2497
2498dnl CURL_CPP_P
2499dnl
2500dnl Check if $cpp -P should be used for extract define values due to gcc 5
2501dnl splitting up strings and defines between line outputs. gcc by default
2502dnl (without -P) will show TEST EINVAL TEST as
2503dnl
2504dnl # 13 "conftest.c"
2505dnl TEST
2506dnl # 13 "conftest.c" 3 4
2507dnl     22
2508dnl # 13 "conftest.c"
2509dnl            TEST
2510
2511AC_DEFUN([CURL_CPP_P], [
2512  AC_MSG_CHECKING([if cpp -P is needed])
2513  AC_EGREP_CPP([TEST.*TEST], [
2514 #include <errno.h>
2515TEST EINVAL TEST
2516  ], [cpp=no], [cpp=yes])
2517  AC_MSG_RESULT([$cpp])
2518
2519  dnl we need cpp -P so check if it works then
2520  if test "x$cpp" = "xyes"; then
2521    AC_MSG_CHECKING([if cpp -P works])
2522    OLDCPPFLAGS=$CPPFLAGS
2523    CPPFLAGS="$CPPFLAGS -P"
2524    AC_EGREP_CPP([TEST.*TEST], [
2525 #include <errno.h>
2526TEST EINVAL TEST
2527    ], [cpp_p=yes], [cpp_p=no])
2528    AC_MSG_RESULT([$cpp_p])
2529
2530    if test "x$cpp_p" = "xno"; then
2531      AC_MSG_WARN([failed to figure out cpp -P alternative])
2532      # without -P
2533      CPPPFLAG=""
2534    else
2535      # with -P
2536      CPPPFLAG="-P"
2537    fi
2538    dnl restore CPPFLAGS
2539    CPPFLAGS=$OLDCPPFLAGS
2540  else
2541    # without -P
2542    CPPPFLAG=""
2543  fi
2544])
2545
2546
2547dnl CURL_DARWIN_CFLAGS
2548dnl
2549dnl Set -Werror=partial-availability to detect possible breaking code
2550dnl with very low deployment targets.
2551dnl
2552
2553AC_DEFUN([CURL_DARWIN_CFLAGS], [
2554
2555  tst_cflags="no"
2556  case $host_os in
2557    darwin*)
2558      tst_cflags="yes"
2559      ;;
2560  esac
2561
2562  AC_MSG_CHECKING([for good-to-use Darwin CFLAGS])
2563  AC_MSG_RESULT([$tst_cflags]);
2564
2565  if test "$tst_cflags" = "yes"; then
2566    old_CFLAGS=$CFLAGS
2567    CFLAGS="$CFLAGS -Werror=partial-availability"
2568    AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
2569    AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
2570      [AC_MSG_RESULT([yes])],
2571      [AC_MSG_RESULT([no])
2572      CFLAGS=$old_CFLAGS])
2573  fi
2574
2575])
2576
2577
2578dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
2579dnl
2580dnl Check to see if the compiler supports __builtin_available. This built-in
2581dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
2582dnl the time this macro was written, the function was not yet documented. Its
2583dnl purpose is to return true if the code is running under a certain OS version
2584dnl or later.
2585
2586AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
2587  AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
2588  AC_COMPILE_IFELSE([
2589    AC_LANG_PROGRAM([[
2590#include <stdlib.h>
2591    ]],[[
2592      if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
2593    ]])
2594  ],[
2595    AC_MSG_RESULT([yes])
2596    AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
2597        [Define to 1 if you have the __builtin_available function.])
2598  ],[
2599    AC_MSG_RESULT([no])
2600  ])
2601])
2602