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