]> git.ipfire.org Git - thirdparty/curl.git/blame - acinclude.m4
OS400: tidy-up
[thirdparty/curl.git] / acinclude.m4
CommitLineData
d551412a
DS
1#***************************************************************************
2# _ _ ____ _
3# Project ___| | | | _ \| |
4# / __| | | | |_) | |
5# | (__| |_| | _ <| |___
6# \___|\___/|_| \_\_____|
7#
2bc1d775 8# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
d551412a
DS
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
4d2f8006 12# are also available at https://curl.se/docs/copyright.html.
d551412a
DS
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#
ad9bc597
MM
21# SPDX-License-Identifier: curl
22#
b377e857 23#***************************************************************************
51581c03 24
9cef14df 25dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
2c61e9c7
YT
26dnl -------------------------------------------------
27dnl Use the C preprocessor to find out if the given object-style symbol
28dnl is defined and get its expansion. This macro will not use default
29dnl includes even if no INCLUDES argument is given. This macro will run
ddfa33be
YT
30dnl silently when invoked with three arguments. If the expansion would
31dnl result in a set of double-quoted strings the returned expansion will
32dnl actually be a single double-quoted string concatenating all them.
2c61e9c7
YT
33
34AC_DEFUN([CURL_CHECK_DEF], [
ecf95343
DS
35 AC_REQUIRE([CURL_CPP_P])dnl
36 OLDCPPFLAGS=$CPPFLAGS
46398941
CD
37 # CPPPFLAG comes from CURL_CPP_P
38 CPPFLAGS="$CPPFLAGS $CPPPFLAG"
2c61e9c7
YT
39 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
40 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
9b0110f5
YT
41 if test -z "$SED"; then
42 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
43 fi
44 if test -z "$GREP"; then
45 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
46 fi
2c61e9c7
YT
47 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
48 tmp_exp=""
49 AC_PREPROC_IFELSE([
50 AC_LANG_SOURCE(
51ifelse($2,,,[$2])[[
52#ifdef $1
53CURL_DEF_TOKEN $1
54#endif
55 ]])
56 ],[
57 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
58 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
a2d4a98d 59 "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
ddfa33be 60 "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
45941877 61 if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
2c61e9c7
YT
62 tmp_exp=""
63 fi
64 ])
65 if test -z "$tmp_exp"; then
46876997 66 AS_VAR_SET(ac_HaveDef, no)
2c61e9c7
YT
67 ifelse($3,,[AC_MSG_RESULT([no])])
68 else
46876997
YT
69 AS_VAR_SET(ac_HaveDef, yes)
70 AS_VAR_SET(ac_Def, $tmp_exp)
2c61e9c7
YT
71 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
72 fi
73 AS_VAR_POPDEF([ac_Def])dnl
74 AS_VAR_POPDEF([ac_HaveDef])dnl
ecf95343 75 CPPFLAGS=$OLDCPPFLAGS
2c61e9c7
YT
76])
77
78
8469db01
YT
79dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
80dnl -------------------------------------------------
81dnl Use the C compiler to find out only if the given symbol is defined
82dnl or not, this can not find out its expansion. This macro will not use
83dnl default includes even if no INCLUDES argument is given. This macro
84dnl will run silently when invoked with three arguments.
85
86AC_DEFUN([CURL_CHECK_DEF_CC], [
87 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
88 ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
89 AC_COMPILE_IFELSE([
90 AC_LANG_SOURCE(
91ifelse($2,,,[$2])[[
92int main (void)
93{
94#ifdef $1
95 return 0;
96#else
97 force compilation error
98#endif
99}
100 ]])
101 ],[
102 tst_symbol_defined="yes"
103 ],[
104 tst_symbol_defined="no"
105 ])
106 if test "$tst_symbol_defined" = "yes"; then
107 AS_VAR_SET(ac_HaveDef, yes)
108 ifelse($3,,[AC_MSG_RESULT([yes])])
109 else
110 AS_VAR_SET(ac_HaveDef, no)
111 ifelse($3,,[AC_MSG_RESULT([no])])
112 fi
113 AS_VAR_POPDEF([ac_HaveDef])dnl
114])
115
116
9b4253fe
YT
117dnl CURL_CHECK_LIB_XNET
118dnl -------------------------------------------------
119dnl Verify if X/Open network library is required.
120
121AC_DEFUN([CURL_CHECK_LIB_XNET], [
122 AC_MSG_CHECKING([if X/Open network library is required])
123 tst_lib_xnet_required="no"
124 AC_COMPILE_IFELSE([
125 AC_LANG_SOURCE([[
126int main (void)
127{
3ae470ee 128#if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
9b4253fe 129 return 0;
4dbc7850 130#elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
9b4253fe
YT
131 return 0;
132#else
133 force compilation error
134#endif
135}
136 ]])
137 ],[
138 tst_lib_xnet_required="yes"
068f7ae2 139 LIBS="-lxnet $LIBS"
9b4253fe
YT
140 ])
141 AC_MSG_RESULT([$tst_lib_xnet_required])
142])
143
144
b4fdccf8
YT
145dnl CURL_CHECK_AIX_ALL_SOURCE
146dnl -------------------------------------------------
147dnl Provides a replacement of traditional AC_AIX with
725ec470 148dnl an uniform behavior across all autoconf versions,
b4fdccf8
YT
149dnl and with our own placement rules.
150
151AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
152 AH_VERBATIM([_ALL_SOURCE],
153 [/* Define to 1 if OS is AIX. */
154#ifndef _ALL_SOURCE
155# undef _ALL_SOURCE
156#endif])
157 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
158 AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
159 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
160 AC_EGREP_CPP([yes_this_is_aix],[
161#ifdef _AIX
162 yes_this_is_aix
163#endif
164 ],[
165 AC_MSG_RESULT([yes])
166 AC_DEFINE(_ALL_SOURCE)
167 ],[
168 AC_MSG_RESULT([no])
169 ])
170])
171
172
5e06ec84
YT
173dnl CURL_CHECK_NATIVE_WINDOWS
174dnl -------------------------------------------------
175dnl Check if building a native Windows target
176
177AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
14c8b455 178 AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [
51581c03 179 AC_COMPILE_IFELSE([
862049c4 180 AC_LANG_PROGRAM([[
862049c4 181 ]],[[
c1bc090d
VS
182#ifdef _WIN32
183 int dummy=1;
bc2f0c7d 184#else
c1bc090d 185 Not a native Windows build target.
bc2f0c7d 186#endif
862049c4 187 ]])
51581c03 188 ],[
c1bc090d 189 curl_cv_native_windows="yes"
51581c03 190 ],[
c1bc090d 191 curl_cv_native_windows="no"
51581c03
YT
192 ])
193 ])
c1bc090d 194 AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes)
51581c03
YT
195])
196
197
a171f60b
YT
198dnl CURL_CHECK_HEADER_LBER
199dnl -------------------------------------------------
200dnl Check for compilable and valid lber.h header,
201dnl and check if it is needed even with ldap.h
202
203AC_DEFUN([CURL_CHECK_HEADER_LBER], [
c1bc090d 204 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
14c8b455 205 AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [
a171f60b 206 AC_COMPILE_IFELSE([
862049c4 207 AC_LANG_PROGRAM([[
a171f60b 208#undef inline
c1bc090d 209#ifdef _WIN32
a171f60b
YT
210#ifndef WIN32_LEAN_AND_MEAN
211#define WIN32_LEAN_AND_MEAN
212#endif
213#include <windows.h>
214#else
215#ifdef HAVE_SYS_TYPES_H
216#include <sys/types.h>
217#endif
218#endif
fbb5518a
YT
219#ifndef NULL
220#define NULL (void *)0
221#endif
a171f60b 222#include <lber.h>
862049c4 223 ]],[[
a171f60b
YT
224 BerValue *bvp = NULL;
225 BerElement *bep = ber_init(bvp);
226 ber_free(bep, 1);
862049c4 227 ]])
a171f60b 228 ],[
14c8b455 229 curl_cv_header_lber_h="yes"
a171f60b 230 ],[
14c8b455 231 curl_cv_header_lber_h="no"
a171f60b
YT
232 ])
233 ])
14c8b455 234 if test "$curl_cv_header_lber_h" = "yes"; then
a171f60b
YT
235 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
236 [Define to 1 if you have the lber.h header file.])
237 #
238 AC_COMPILE_IFELSE([
862049c4 239 AC_LANG_PROGRAM([[
a171f60b 240#undef inline
c1bc090d 241#ifdef _WIN32
a171f60b
YT
242#ifndef WIN32_LEAN_AND_MEAN
243#define WIN32_LEAN_AND_MEAN
244#endif
245#include <windows.h>
246#else
247#ifdef HAVE_SYS_TYPES_H
248#include <sys/types.h>
249#endif
250#endif
fbb5518a
YT
251#ifndef NULL
252#define NULL (void *)0
253#endif
a171f60b
YT
254#ifndef LDAP_DEPRECATED
255#define LDAP_DEPRECATED 1
256#endif
257#include <ldap.h>
862049c4 258 ]],[[
a171f60b
YT
259 BerValue *bvp = NULL;
260 BerElement *bep = ber_init(bvp);
261 ber_free(bep, 1);
862049c4 262 ]])
a171f60b
YT
263 ],[
264 curl_cv_need_header_lber_h="no"
265 ],[
266 curl_cv_need_header_lber_h="yes"
267 ])
268 #
269 case "$curl_cv_need_header_lber_h" in
270 yes)
271 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
272 [Define to 1 if you need the lber.h header file even with ldap.h])
273 ;;
274 esac
275 fi
276])
277
278
279dnl CURL_CHECK_HEADER_LDAP
280dnl -------------------------------------------------
281dnl Check for compilable and valid ldap.h header
282
283AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
284 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
14c8b455 285 AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [
a171f60b 286 AC_COMPILE_IFELSE([
862049c4 287 AC_LANG_PROGRAM([[
a171f60b 288#undef inline
c1bc090d 289#ifdef _WIN32
a171f60b
YT
290#ifndef WIN32_LEAN_AND_MEAN
291#define WIN32_LEAN_AND_MEAN
292#endif
293#include <windows.h>
294#else
295#ifdef HAVE_SYS_TYPES_H
296#include <sys/types.h>
297#endif
298#endif
299#ifndef LDAP_DEPRECATED
300#define LDAP_DEPRECATED 1
301#endif
302#ifdef NEED_LBER_H
303#include <lber.h>
304#endif
305#include <ldap.h>
862049c4 306 ]],[[
751e168d 307 LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
a171f60b 308 int res = ldap_unbind(ldp);
862049c4 309 ]])
a171f60b 310 ],[
14c8b455 311 curl_cv_header_ldap_h="yes"
a171f60b 312 ],[
14c8b455 313 curl_cv_header_ldap_h="no"
a171f60b
YT
314 ])
315 ])
14c8b455 316 case "$curl_cv_header_ldap_h" in
a171f60b
YT
317 yes)
318 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
319 [Define to 1 if you have the ldap.h header file.])
320 ;;
321 esac
322])
323
324
325dnl CURL_CHECK_HEADER_LDAP_SSL
326dnl -------------------------------------------------
327dnl Check for compilable and valid ldap_ssl.h header
328
329AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
330 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
14c8b455 331 AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [
a171f60b 332 AC_COMPILE_IFELSE([
862049c4 333 AC_LANG_PROGRAM([[
a171f60b 334#undef inline
c1bc090d 335#ifdef _WIN32
a171f60b
YT
336#ifndef WIN32_LEAN_AND_MEAN
337#define WIN32_LEAN_AND_MEAN
338#endif
339#include <windows.h>
340#else
341#ifdef HAVE_SYS_TYPES_H
342#include <sys/types.h>
343#endif
344#endif
345#ifndef LDAP_DEPRECATED
346#define LDAP_DEPRECATED 1
347#endif
348#ifdef NEED_LBER_H
349#include <lber.h>
350#endif
351#ifdef HAVE_LDAP_H
352#include <ldap.h>
353#endif
354#include <ldap_ssl.h>
862049c4 355 ]],[[
751e168d 356 LDAP *ldp = ldapssl_init("0.0.0.0", LDAPS_PORT, 1);
862049c4 357 ]])
a171f60b 358 ],[
14c8b455 359 curl_cv_header_ldap_ssl_h="yes"
a171f60b 360 ],[
14c8b455 361 curl_cv_header_ldap_ssl_h="no"
a171f60b
YT
362 ])
363 ])
14c8b455 364 case "$curl_cv_header_ldap_ssl_h" in
a171f60b
YT
365 yes)
366 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
367 [Define to 1 if you have the ldap_ssl.h header file.])
368 ;;
369 esac
370])
371
372
e8d3710a
YT
373dnl CURL_CHECK_LIBS_WINLDAP
374dnl -------------------------------------------------
375dnl Check for libraries needed for WINLDAP support,
376dnl and prepended to LIBS any needed libraries.
377dnl This macro can take an optional parameter with a
2aac895f 378dnl whitespace separated list of libraries to check
e8d3710a
YT
379dnl before the WINLDAP default ones.
380
381AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
382 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
383 #
384 AC_MSG_CHECKING([for WINLDAP libraries])
385 #
386 u_libs=""
387 #
388 ifelse($1,,,[
389 for x_lib in $1; do
390 case "$x_lib" in
391 -l*)
392 l_lib="$x_lib"
393 ;;
394 *)
395 l_lib="-l$x_lib"
396 ;;
397 esac
398 if test -z "$u_libs"; then
399 u_libs="$l_lib"
400 else
401 u_libs="$u_libs $l_lib"
402 fi
403 done
404 ])
405 #
edef367e 406 curl_cv_save_LIBS="$LIBS"
e8d3710a
YT
407 curl_cv_ldap_LIBS="unknown"
408 #
409 for x_nlibs in '' "$u_libs" \
410 '-lwldap32' ; do
24d41452
YT
411 if test "$curl_cv_ldap_LIBS" = "unknown"; then
412 if test -z "$x_nlibs"; then
413 LIBS="$curl_cv_save_LIBS"
414 else
415 LIBS="$x_nlibs $curl_cv_save_LIBS"
416 fi
417 AC_LINK_IFELSE([
418 AC_LANG_PROGRAM([[
e8d3710a 419#undef inline
c1bc090d 420#ifdef _WIN32
e8d3710a
YT
421#ifndef WIN32_LEAN_AND_MEAN
422#define WIN32_LEAN_AND_MEAN
423#endif
424#include <windows.h>
e8d3710a 425#include <winldap.h>
e8d3710a
YT
426#ifdef HAVE_WINBER_H
427#include <winber.h>
428#endif
429#endif
24d41452
YT
430 ]],[[
431 BERVAL *bvp = NULL;
432 BerElement *bep = ber_init(bvp);
751e168d 433 LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
24d41452
YT
434 ULONG res = ldap_unbind(ldp);
435 ber_free(bep, 1);
436 ]])
437 ],[
438 curl_cv_ldap_LIBS="$x_nlibs"
439 ])
440 fi
e8d3710a
YT
441 done
442 #
edef367e 443 LIBS="$curl_cv_save_LIBS"
e8d3710a
YT
444 #
445 case X-"$curl_cv_ldap_LIBS" in
446 X-unknown)
447 AC_MSG_RESULT([cannot find WINLDAP libraries])
448 ;;
449 X-)
450 AC_MSG_RESULT([no additional lib required])
451 ;;
452 *)
453 if test -z "$curl_cv_save_LIBS"; then
454 LIBS="$curl_cv_ldap_LIBS"
455 else
456 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
457 fi
458 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
459 ;;
460 esac
461 #
462])
463
464
4db954f8
YT
465dnl CURL_CHECK_LIBS_LDAP
466dnl -------------------------------------------------
467dnl Check for libraries needed for LDAP support,
468dnl and prepended to LIBS any needed libraries.
5360f883 469dnl This macro can take an optional parameter with a
2aac895f 470dnl whitespace separated list of libraries to check
5360f883 471dnl before the default ones.
4db954f8
YT
472
473AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
474 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
475 #
e8d3710a
YT
476 AC_MSG_CHECKING([for LDAP libraries])
477 #
5360f883 478 u_libs=""
420ea83e
YT
479 #
480 ifelse($1,,,[
481 for x_lib in $1; do
482 case "$x_lib" in
483 -l*)
484 l_lib="$x_lib"
485 ;;
486 *)
487 l_lib="-l$x_lib"
488 ;;
489 esac
490 if test -z "$u_libs"; then
491 u_libs="$l_lib"
492 else
493 u_libs="$u_libs $l_lib"
494 fi
495 done
496 ])
5360f883 497 #
edef367e 498 curl_cv_save_LIBS="$LIBS"
4db954f8
YT
499 curl_cv_ldap_LIBS="unknown"
500 #
e8d3710a 501 for x_nlibs in '' "$u_libs" \
5360f883 502 '-lldap' \
5360f883 503 '-lldap -llber' \
c5343848 504 '-llber -lldap' \
5360f883 505 '-lldapssl -lldapx -lldapsdk' \
66637b4d
MF
506 '-lldapsdk -lldapx -lldapssl' \
507 '-lldap -llber -lssl -lcrypto' ; do
508
24d41452
YT
509 if test "$curl_cv_ldap_LIBS" = "unknown"; then
510 if test -z "$x_nlibs"; then
511 LIBS="$curl_cv_save_LIBS"
512 else
513 LIBS="$x_nlibs $curl_cv_save_LIBS"
514 fi
515 AC_LINK_IFELSE([
516 AC_LANG_PROGRAM([[
4db954f8 517#undef inline
c1bc090d 518#ifdef _WIN32
4db954f8
YT
519#ifndef WIN32_LEAN_AND_MEAN
520#define WIN32_LEAN_AND_MEAN
521#endif
522#include <windows.h>
523#else
524#ifdef HAVE_SYS_TYPES_H
525#include <sys/types.h>
526#endif
527#endif
fbb5518a
YT
528#ifndef NULL
529#define NULL (void *)0
530#endif
4db954f8
YT
531#ifndef LDAP_DEPRECATED
532#define LDAP_DEPRECATED 1
533#endif
534#ifdef NEED_LBER_H
535#include <lber.h>
536#endif
537#ifdef HAVE_LDAP_H
538#include <ldap.h>
001a2d9b 539#endif
24d41452
YT
540 ]],[[
541 BerValue *bvp = NULL;
542 BerElement *bep = ber_init(bvp);
751e168d 543 LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT);
24d41452
YT
544 int res = ldap_unbind(ldp);
545 ber_free(bep, 1);
546 ]])
547 ],[
548 curl_cv_ldap_LIBS="$x_nlibs"
549 ])
550 fi
4db954f8
YT
551 done
552 #
edef367e 553 LIBS="$curl_cv_save_LIBS"
4db954f8
YT
554 #
555 case X-"$curl_cv_ldap_LIBS" in
556 X-unknown)
95446f69 557 AC_MSG_RESULT([cannot find LDAP libraries])
4db954f8
YT
558 ;;
559 X-)
560 AC_MSG_RESULT([no additional lib required])
561 ;;
562 *)
563 if test -z "$curl_cv_save_LIBS"; then
564 LIBS="$curl_cv_ldap_LIBS"
565 else
566 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
567 fi
568 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
569 ;;
570 esac
571 #
572])
573
574
bec19771
YT
575dnl TYPE_SOCKADDR_STORAGE
576dnl -------------------------------------------------
a07bc791 577dnl Check for struct sockaddr_storage. Most IPv6-enabled
bec19771
YT
578dnl hosts have it, but AIX 4.3 is one known exception.
579
580AC_DEFUN([TYPE_SOCKADDR_STORAGE],
581[
582 AC_CHECK_TYPE([struct sockaddr_storage],
583 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
584 [if struct sockaddr_storage is defined]), ,
585 [
586#undef inline
c1bc090d 587#ifdef _WIN32
bec19771
YT
588#ifndef WIN32_LEAN_AND_MEAN
589#define WIN32_LEAN_AND_MEAN
590#endif
bec19771 591#include <winsock2.h>
bec19771
YT
592#else
593#ifdef HAVE_SYS_TYPES_H
594#include <sys/types.h>
595#endif
596#ifdef HAVE_SYS_SOCKET_H
597#include <sys/socket.h>
598#endif
599#ifdef HAVE_NETINET_IN_H
600#include <netinet/in.h>
601#endif
602#ifdef HAVE_ARPA_INET_H
603#include <arpa/inet.h>
604#endif
605#endif
606 ])
607])
608
01fa02d0
YT
609dnl CURL_CHECK_FUNC_RECV
610dnl -------------------------------------------------
a07bc791 611dnl Test if the socket recv() function is available,
01fa02d0
YT
612
613AC_DEFUN([CURL_CHECK_FUNC_RECV], [
c1bc090d 614 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
c6631e82 615 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
8ef454dc 616 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
01fa02d0
YT
617 #
618 AC_MSG_CHECKING([for recv])
d70f3374 619 AC_LINK_IFELSE([
862049c4 620 AC_LANG_PROGRAM([[
a07bc791 621#undef inline
c1bc090d 622#ifdef _WIN32
bc2f0c7d
YT
623#ifndef WIN32_LEAN_AND_MEAN
624#define WIN32_LEAN_AND_MEAN
625#endif
bc2f0c7d 626#include <winsock2.h>
bc2f0c7d 627#else
c6631e82 628$curl_includes_bsdsocket
01fa02d0
YT
629#ifdef HAVE_SYS_TYPES_H
630#include <sys/types.h>
631#endif
632#ifdef HAVE_SYS_SOCKET_H
633#include <sys/socket.h>
bc2f0c7d 634#endif
01fa02d0 635#endif
862049c4 636 ]],[[
01fa02d0 637 recv(0, 0, 0, 0);
862049c4 638 ]])
d70f3374
YT
639 ],[
640 AC_MSG_RESULT([yes])
641 curl_cv_recv="yes"
642 ],[
643 AC_MSG_RESULT([no])
644 curl_cv_recv="no"
01fa02d0
YT
645 ])
646 #
647 if test "$curl_cv_recv" = "yes"; then
01fa02d0
YT
648 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
649 [Define to 1 if you have the recv function.])
d9f3b365 650 curl_cv_func_recv="yes"
7240acde
YT
651 else
652 AC_MSG_ERROR([Unable to link function recv])
01fa02d0 653 fi
2d15d84a 654])
01fa02d0
YT
655
656
657dnl CURL_CHECK_FUNC_SEND
658dnl -------------------------------------------------
a07bc791 659dnl Test if the socket send() function is available,
01fa02d0
YT
660
661AC_DEFUN([CURL_CHECK_FUNC_SEND], [
c1bc090d 662 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
c6631e82 663 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
8ef454dc 664 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
01fa02d0
YT
665 #
666 AC_MSG_CHECKING([for send])
d70f3374 667 AC_LINK_IFELSE([
862049c4 668 AC_LANG_PROGRAM([[
a07bc791 669#undef inline
c1bc090d 670#ifdef _WIN32
bc2f0c7d
YT
671#ifndef WIN32_LEAN_AND_MEAN
672#define WIN32_LEAN_AND_MEAN
673#endif
bc2f0c7d 674#include <winsock2.h>
bc2f0c7d 675#else
c6631e82 676$curl_includes_bsdsocket
01fa02d0
YT
677#ifdef HAVE_SYS_TYPES_H
678#include <sys/types.h>
679#endif
680#ifdef HAVE_SYS_SOCKET_H
681#include <sys/socket.h>
bc2f0c7d 682#endif
01fa02d0 683#endif
862049c4 684 ]],[[
01fa02d0 685 send(0, 0, 0, 0);
862049c4 686 ]])
d70f3374
YT
687 ],[
688 AC_MSG_RESULT([yes])
689 curl_cv_send="yes"
690 ],[
691 AC_MSG_RESULT([no])
692 curl_cv_send="no"
01fa02d0
YT
693 ])
694 #
695 if test "$curl_cv_send" = "yes"; then
eb33ccd5
DS
696 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
697 [Define to 1 if you have the send function.])
698 curl_cv_func_send="yes"
7240acde
YT
699 else
700 AC_MSG_ERROR([Unable to link function send])
01fa02d0 701 fi
2d15d84a 702])
01fa02d0 703
77b3bc23
YT
704dnl CURL_CHECK_MSG_NOSIGNAL
705dnl -------------------------------------------------
706dnl Check for MSG_NOSIGNAL
707
708AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
709 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
14c8b455 710 AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [
77b3bc23 711 AC_COMPILE_IFELSE([
862049c4 712 AC_LANG_PROGRAM([[
a07bc791 713#undef inline
c1bc090d 714#ifdef _WIN32
ae8a01ea
YT
715#ifndef WIN32_LEAN_AND_MEAN
716#define WIN32_LEAN_AND_MEAN
717#endif
ae8a01ea 718#include <winsock2.h>
ae8a01ea 719#else
77b3bc23
YT
720#ifdef HAVE_SYS_TYPES_H
721#include <sys/types.h>
722#endif
723#ifdef HAVE_SYS_SOCKET_H
724#include <sys/socket.h>
ae8a01ea 725#endif
77b3bc23 726#endif
862049c4 727 ]],[[
77b3bc23 728 int flag=MSG_NOSIGNAL;
862049c4 729 ]])
77b3bc23 730 ],[
14c8b455 731 curl_cv_msg_nosignal="yes"
77b3bc23 732 ],[
14c8b455 733 curl_cv_msg_nosignal="no"
77b3bc23
YT
734 ])
735 ])
14c8b455 736 case "$curl_cv_msg_nosignal" in
77b3bc23
YT
737 yes)
738 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
739 [Define to 1 if you have the MSG_NOSIGNAL flag.])
740 ;;
741 esac
2d15d84a 742])
77b3bc23
YT
743
744
32ac4ede
YT
745dnl CURL_CHECK_STRUCT_TIMEVAL
746dnl -------------------------------------------------
747dnl Check for timeval struct
748
749AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
c1bc090d 750 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
eaa1d732 751 AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h)
14c8b455 752 AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
32ac4ede 753 AC_COMPILE_IFELSE([
862049c4 754 AC_LANG_PROGRAM([[
a07bc791 755#undef inline
c1bc090d 756#ifdef _WIN32
32ac4ede
YT
757#ifndef WIN32_LEAN_AND_MEAN
758#define WIN32_LEAN_AND_MEAN
759#endif
32ac4ede 760#include <winsock2.h>
32ac4ede
YT
761#endif
762#ifdef HAVE_SYS_TYPES_H
763#include <sys/types.h>
764#endif
765#ifdef HAVE_SYS_TIME_H
766#include <sys/time.h>
32ac4ede 767#endif
32ac4ede 768#include <time.h>
61a96709
YT
769#ifdef HAVE_SYS_SOCKET_H
770#include <sys/socket.h>
32ac4ede 771#endif
862049c4 772 ]],[[
32ac4ede
YT
773 struct timeval ts;
774 ts.tv_sec = 0;
775 ts.tv_usec = 0;
862049c4 776 ]])
32ac4ede 777 ],[
14c8b455 778 curl_cv_struct_timeval="yes"
32ac4ede 779 ],[
14c8b455 780 curl_cv_struct_timeval="no"
32ac4ede
YT
781 ])
782 ])
14c8b455 783 case "$curl_cv_struct_timeval" in
32ac4ede
YT
784 yes)
785 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
786 [Define to 1 if you have the timeval struct.])
787 ;;
788 esac
2d15d84a 789])
73226415
YT
790
791
74ed5b5e
YT
792dnl TYPE_IN_ADDR_T
793dnl -------------------------------------------------
d09b4369 794dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
ef355196 795dnl and a few other things.
24d41452
YT
796
797AC_DEFUN([TYPE_IN_ADDR_T], [
798 AC_CHECK_TYPE([in_addr_t], ,[
799 dnl in_addr_t not available
800 AC_CACHE_CHECK([for in_addr_t equivalent],
801 [curl_cv_in_addr_t_equiv], [
802 curl_cv_in_addr_t_equiv="unknown"
803 for t in "unsigned long" int size_t unsigned long; do
804 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
805 AC_LINK_IFELSE([
806 AC_LANG_PROGRAM([[
74ed5b5e 807#undef inline
c1bc090d 808#ifdef _WIN32
74ed5b5e
YT
809#ifndef WIN32_LEAN_AND_MEAN
810#define WIN32_LEAN_AND_MEAN
811#endif
74ed5b5e 812#include <winsock2.h>
74ed5b5e
YT
813#else
814#ifdef HAVE_SYS_TYPES_H
815#include <sys/types.h>
816#endif
817#ifdef HAVE_SYS_SOCKET_H
818#include <sys/socket.h>
819#endif
820#ifdef HAVE_NETINET_IN_H
821#include <netinet/in.h>
822#endif
f4481685
YT
823#ifdef HAVE_ARPA_INET_H
824#include <arpa/inet.h>
825#endif
74ed5b5e 826#endif
24d41452
YT
827 ]],[[
828 $t data = inet_addr ("1.2.3.4");
829 ]])
830 ],[
831 curl_cv_in_addr_t_equiv="$t"
832 ])
833 fi
834 done
835 ])
836 case "$curl_cv_in_addr_t_equiv" in
837 unknown)
838 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
839 ;;
840 *)
841 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
842 [Type to use in place of in_addr_t when system does not provide it.])
843 ;;
844 esac
845 ],[
74ed5b5e 846#undef inline
c1bc090d 847#ifdef _WIN32
74ed5b5e
YT
848#ifndef WIN32_LEAN_AND_MEAN
849#define WIN32_LEAN_AND_MEAN
850#endif
74ed5b5e 851#include <winsock2.h>
74ed5b5e
YT
852#else
853#ifdef HAVE_SYS_TYPES_H
854#include <sys/types.h>
855#endif
856#ifdef HAVE_SYS_SOCKET_H
d2203896 857#include <sys/socket.h>
74ed5b5e
YT
858#endif
859#ifdef HAVE_NETINET_IN_H
860#include <netinet/in.h>
861#endif
f4481685
YT
862#ifdef HAVE_ARPA_INET_H
863#include <arpa/inet.h>
864#endif
74ed5b5e 865#endif
2d15d84a
YT
866 ])
867])
d09b4369 868
24d41452 869
ed80eb5b 870dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
b380dd03 871dnl -------------------------------------------------
ed80eb5b 872dnl Check if monotonic clock_gettime is available.
b380dd03 873
ed80eb5b 874AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
eaa1d732 875 AC_CHECK_HEADERS(sys/types.h sys/time.h)
97333deb 876 AC_MSG_CHECKING([for monotonic clock_gettime])
cee21eb6 877 #
905f493b 878 if test "x$dontwant_rt" = "xno" ; then
cee21eb6
MF
879 AC_COMPILE_IFELSE([
880 AC_LANG_PROGRAM([[
b380dd03
YT
881#ifdef HAVE_SYS_TYPES_H
882#include <sys/types.h>
883#endif
884#ifdef HAVE_SYS_TIME_H
885#include <sys/time.h>
b380dd03 886#endif
b380dd03 887#include <time.h>
cee21eb6
MF
888 ]],[[
889 struct timespec ts;
890 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
891 ]])
892 ],[
893 AC_MSG_RESULT([yes])
68c83b46 894 curl_func_clock_gettime="yes"
cee21eb6
MF
895 ],[
896 AC_MSG_RESULT([no])
68c83b46 897 curl_func_clock_gettime="no"
cee21eb6
MF
898 ])
899 fi
97333deb
YT
900 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
901 dnl until library linking and run-time checks for clock_gettime succeed.
2d15d84a 902])
ed80eb5b 903
c92b7228
DS
904dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW
905dnl -------------------------------------------------
906dnl Check if monotonic clock_gettime is available.
907
908AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW], [
909 AC_CHECK_HEADERS(sys/types.h sys/time.h)
910 AC_MSG_CHECKING([for raw monotonic clock_gettime])
911 #
912 if test "x$dontwant_rt" = "xno" ; then
913 AC_COMPILE_IFELSE([
914 AC_LANG_PROGRAM([[
915#ifdef HAVE_SYS_TYPES_H
916#include <sys/types.h>
917#endif
918#ifdef HAVE_SYS_TIME_H
919#include <sys/time.h>
920#endif
921#include <time.h>
922 ]],[[
923 struct timespec ts;
924 (void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
925 ]])
926 ],[
927 AC_MSG_RESULT([yes])
928 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC_RAW, 1,
929 [Define to 1 if you have the clock_gettime function and raw monotonic timer.])
930 ],[
931 AC_MSG_RESULT([no])
932 ])
933 fi
934])
935
24d41452 936
ed80eb5b
YT
937dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
938dnl -------------------------------------------------
939dnl If monotonic clock_gettime is available then,
940dnl check and prepended to LIBS any needed libraries.
941
942AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
943 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
b380dd03 944 #
68c83b46 945 if test "$curl_func_clock_gettime" = "yes"; then
ed80eb5b
YT
946 #
947 AC_MSG_CHECKING([for clock_gettime in libraries])
948 #
949 curl_cv_save_LIBS="$LIBS"
950 curl_cv_gclk_LIBS="unknown"
951 #
952 for x_xlibs in '' '-lrt' '-lposix4' ; do
24d41452
YT
953 if test "$curl_cv_gclk_LIBS" = "unknown"; then
954 if test -z "$x_xlibs"; then
955 LIBS="$curl_cv_save_LIBS"
956 else
957 LIBS="$x_xlibs $curl_cv_save_LIBS"
958 fi
959 AC_LINK_IFELSE([
960 AC_LANG_PROGRAM([[
ed80eb5b
YT
961#ifdef HAVE_SYS_TYPES_H
962#include <sys/types.h>
963#endif
964#ifdef HAVE_SYS_TIME_H
965#include <sys/time.h>
ed80eb5b 966#endif
ed80eb5b 967#include <time.h>
24d41452
YT
968 ]],[[
969 struct timespec ts;
970 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
971 ]])
972 ],[
973 curl_cv_gclk_LIBS="$x_xlibs"
974 ])
975 fi
ed80eb5b
YT
976 done
977 #
978 LIBS="$curl_cv_save_LIBS"
979 #
980 case X-"$curl_cv_gclk_LIBS" in
981 X-unknown)
982 AC_MSG_RESULT([cannot find clock_gettime])
983 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
68c83b46 984 curl_func_clock_gettime="no"
ed80eb5b
YT
985 ;;
986 X-)
987 AC_MSG_RESULT([no additional lib required])
68c83b46 988 curl_func_clock_gettime="yes"
ed80eb5b
YT
989 ;;
990 *)
991 if test -z "$curl_cv_save_LIBS"; then
992 LIBS="$curl_cv_gclk_LIBS"
993 else
994 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
995 fi
996 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
68c83b46 997 curl_func_clock_gettime="yes"
ed80eb5b
YT
998 ;;
999 esac
1000 #
1058e5fd
YT
1001 dnl only do runtime verification when not cross-compiling
1002 if test "x$cross_compiling" != "xyes" &&
68c83b46 1003 test "$curl_func_clock_gettime" = "yes"; then
1058e5fd 1004 AC_MSG_CHECKING([if monotonic clock_gettime works])
5616c1df 1005 CURL_RUN_IFELSE([
1058e5fd 1006 AC_LANG_PROGRAM([[
0abaf224 1007#include <stdlib.h>
1058e5fd
YT
1008#ifdef HAVE_SYS_TYPES_H
1009#include <sys/types.h>
1010#endif
1058e5fd
YT
1011#ifdef HAVE_SYS_TIME_H
1012#include <sys/time.h>
1058e5fd 1013#endif
1058e5fd 1014#include <time.h>
1058e5fd 1015 ]],[[
1058e5fd
YT
1016 struct timespec ts;
1017 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1018 exit(0);
97333deb
YT
1019 else
1020 exit(1);
1058e5fd
YT
1021 ]])
1022 ],[
1023 AC_MSG_RESULT([yes])
1024 ],[
1025 AC_MSG_RESULT([no])
1026 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
68c83b46 1027 curl_func_clock_gettime="no"
1058e5fd
YT
1028 LIBS="$curl_cv_save_LIBS"
1029 ])
1030 fi
1031 #
68c83b46 1032 case "$curl_func_clock_gettime" in
ed80eb5b
YT
1033 yes)
1034 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1035 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1036 ;;
1037 esac
1038 #
1039 fi
b380dd03 1040 #
2d15d84a 1041])
b380dd03 1042
9346e55d 1043
1ff4e900
YT
1044dnl CURL_CHECK_LIBS_CONNECT
1045dnl -------------------------------------------------
1046dnl Verify if network connect function is already available
1047dnl using current libraries or if another one is required.
1048
1049AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
e96a9190 1050 AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
1e853653 1051 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
1ff4e900
YT
1052 AC_MSG_CHECKING([for connect in libraries])
1053 tst_connect_save_LIBS="$LIBS"
1054 tst_connect_need_LIBS="unknown"
1055 for tst_lib in '' '-lsocket' ; do
1056 if test "$tst_connect_need_LIBS" = "unknown"; then
1057 LIBS="$tst_lib $tst_connect_save_LIBS"
1058 AC_LINK_IFELSE([
1059 AC_LANG_PROGRAM([[
e96a9190 1060 $curl_includes_winsock2
1e853653 1061 $curl_includes_bsdsocket
c1bc090d 1062 #if !defined(_WIN32) && !defined(HAVE_PROTO_BSDSOCKET_H)
e96a9190
YT
1063 int connect(int, void*, int);
1064 #endif
1ff4e900
YT
1065 ]],[[
1066 if(0 != connect(0, 0, 0))
1067 return 1;
1068 ]])
1069 ],[
1070 tst_connect_need_LIBS="$tst_lib"
1071 ])
1072 fi
1073 done
1074 LIBS="$tst_connect_save_LIBS"
1075 #
1076 case X-"$tst_connect_need_LIBS" in
1077 X-unknown)
1078 AC_MSG_RESULT([cannot find connect])
1079 AC_MSG_ERROR([cannot find connect function in libraries.])
1080 ;;
1081 X-)
1082 AC_MSG_RESULT([yes])
1083 ;;
1084 *)
1085 AC_MSG_RESULT([$tst_connect_need_LIBS])
1086 LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
1087 ;;
1088 esac
1089])
1090
1091
25648963
YT
1092dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
1093dnl -------------------------------------------------
1094dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
1095dnl symbol that can be further used in custom template configuration
1096dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
1097dnl argument for the description. Symbol definitions done with this
1098dnl macro are intended to be exclusively used in handcrafted *.h.in
1099dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
1100dnl prevents autoheader generation and insertion of symbol template
1101dnl stub and definition into the first configuration header file. Do
1102dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
1103dnl one serves different functional needs.
1104
1105AC_DEFUN([CURL_DEFINE_UNQUOTED], [
1106cat >>confdefs.h <<_EOF
1107[@%:@define] $1 ifelse($#, 2, [$2], 1)
1108_EOF
1109])
1110
665adcd4 1111
9346e55d
YT
1112dnl CURL_CHECK_FUNC_SELECT
1113dnl -------------------------------------------------
eb33ccd5 1114dnl Test if the socket select() function is available.
9346e55d
YT
1115
1116AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
1117 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
c6631e82 1118 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
9346e55d
YT
1119 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1120 #
1121 AC_MSG_CHECKING([for select])
d70f3374 1122 AC_LINK_IFELSE([
862049c4 1123 AC_LANG_PROGRAM([[
9346e55d 1124#undef inline
c1bc090d 1125#ifdef _WIN32
9346e55d
YT
1126#ifndef WIN32_LEAN_AND_MEAN
1127#define WIN32_LEAN_AND_MEAN
1128#endif
9346e55d 1129#include <winsock2.h>
9346e55d
YT
1130#endif
1131#ifdef HAVE_SYS_TYPES_H
1132#include <sys/types.h>
1133#endif
1134#ifdef HAVE_SYS_TIME_H
1135#include <sys/time.h>
9346e55d 1136#endif
9346e55d 1137#include <time.h>
c1bc090d 1138#ifndef _WIN32
9346e55d
YT
1139#ifdef HAVE_SYS_SELECT_H
1140#include <sys/select.h>
7a71965e
HS
1141#elif defined(HAVE_UNISTD_H)
1142#include <unistd.h>
9346e55d
YT
1143#endif
1144#ifdef HAVE_SYS_SOCKET_H
1145#include <sys/socket.h>
1146#endif
c6631e82 1147$curl_includes_bsdsocket
9346e55d 1148#endif
862049c4 1149 ]],[[
9346e55d 1150 select(0, 0, 0, 0, 0);
862049c4 1151 ]])
d70f3374
YT
1152 ],[
1153 AC_MSG_RESULT([yes])
1154 curl_cv_select="yes"
1155 ],[
1156 AC_MSG_RESULT([no])
1157 curl_cv_select="no"
9346e55d
YT
1158 ])
1159 #
1160 if test "$curl_cv_select" = "yes"; then
eb33ccd5
DS
1161 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
1162 [Define to 1 if you have the select function.])
1163 curl_cv_func_select="yes"
9346e55d 1164 fi
2d15d84a 1165])
9346e55d
YT
1166
1167
67e8d229
DS
1168dnl CURL_VERIFY_RUNTIMELIBS
1169dnl -------------------------------------------------
1170dnl Verify that the shared libs found so far can be used when running
1171dnl programs, since otherwise the situation will create odd configure errors
1172dnl that are misleading people.
1173dnl
1174dnl Make sure this test is run BEFORE the first test in the script that
1175dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
1176dnl macro. It must also run AFTER all lib-checking macros are complete.
1177
1178AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
1179
1180 dnl this test is of course not sensible if we are cross-compiling!
1181 if test "x$cross_compiling" != xyes; then
1182
1183 dnl just run a program to verify that the libs checked for previous to this
1184 dnl point also is available run-time!
1185 AC_MSG_CHECKING([run-time libs availability])
302d5374 1186 CURL_RUN_IFELSE([
d5c03510 1187int main()
67e8d229
DS
1188{
1189 return 0;
1190}
1191],
1192 AC_MSG_RESULT([fine]),
1193 AC_MSG_RESULT([failed])
1194 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
1195 )
1196
1197 dnl if this test fails, configure has already stopped
1198 fi
1199])
273b2b23
YT
1200
1201
fb23b857
DS
1202dnl CURL_CHECK_CA_BUNDLE
1203dnl -------------------------------------------------
1204dnl Check if a default ca-bundle should be used
1205dnl
1206dnl regarding the paths this will scan:
1207dnl /etc/ssl/certs/ca-certificates.crt Debian systems
1208dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
1209dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
4266dd96
MO
1210dnl /usr/local/share/certs/ca-root-nss.crt MidnightBSD
1211dnl /etc/ssl/cert.pem OpenBSD, MidnightBSD (symlink)
b8f6c3ca 1212dnl /etc/ssl/certs (CA path) SUSE, FreeBSD
fb23b857
DS
1213
1214AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
1215
86cbb232 1216 AC_MSG_CHECKING([default CA cert bundle/path])
fb23b857
DS
1217
1218 AC_ARG_WITH(ca-bundle,
a59f0461 1219AS_HELP_STRING([--with-ca-bundle=FILE],
3ae77f07 1220[Path to a file containing CA certificates (example: /etc/ca-bundle.crt)])
a59f0461 1221AS_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
fb23b857 1222 [
86cbb232
MM
1223 want_ca="$withval"
1224 if test "x$want_ca" = "xyes"; then
1225 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
fb23b857 1226 fi
86cbb232
MM
1227 ],
1228 [ want_ca="unset" ])
1229 AC_ARG_WITH(ca-path,
a59f0461 1230AS_HELP_STRING([--with-ca-path=DIRECTORY],
3ae77f07 1231[Path to a directory containing CA certificates stored individually, with \
52d302ed 1232their filenames in a hash format. This option can be used with the OpenSSL, \
849bd50c 1233GnuTLS, mbedTLS and wolfSSL backends. Refer to OpenSSL c_rehash for details. \
3ae77f07 1234(example: /etc/certificates)])
a59f0461 1235AS_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
86cbb232
MM
1236 [
1237 want_capath="$withval"
1238 if test "x$want_capath" = "xyes"; then
1239 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
1240 fi
1241 ],
1242 [ want_capath="unset"])
1243
3ae77f07
JS
1244 ca_warning=" (warning: certs not found)"
1245 capath_warning=" (warning: certs not found)"
1246 check_capath=""
1247
86cbb232
MM
1248 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
1249 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
1250 dnl both given
90314100
JO
1251 ca="$want_ca"
1252 capath="$want_capath"
86cbb232
MM
1253 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
1254 dnl --with-ca-bundle given
1255 ca="$want_ca"
1256 capath="no"
1257 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
1258 dnl --with-ca-path given
849bd50c
DS
1259 if test "x$OPENSSL_ENABLED" != "x1" -a \
1260 "x$GNUTLS_ENABLED" != "x1" -a \
1261 "x$MBEDTLS_ENABLED" != "x1" -a \
1262 "x$WOLFSSL_ENABLED" != "x1"; then
1263 AC_MSG_ERROR([--with-ca-path only works with OpenSSL, GnuTLS, mbedTLS or wolfSSL])
86cbb232
MM
1264 fi
1265 capath="$want_capath"
1266 ca="no"
073b03fa 1267 else
86cbb232
MM
1268 dnl first try autodetecting a CA bundle , then a CA path
1269 dnl both autodetections can be skipped by --without-ca-*
1270 ca="no"
1271 capath="no"
073b03fa
DS
1272 if test "x$cross_compiling" != "xyes"; then
1273 dnl NOT cross-compiling and...
1274 dnl neither of the --with-ca-* options are provided
1275 if test "x$want_ca" = "xunset"; then
1276 dnl the path we previously would have installed the curl ca bundle
1277 dnl to, and thus we now check for an already existing cert in that
1278 dnl place in case we find no other
1279 if test "x$prefix" != xNONE; then
1280 cac="${prefix}/share/curl/curl-ca-bundle.crt"
1281 else
1282 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
86cbb232 1283 fi
073b03fa
DS
1284
1285 for a in /etc/ssl/certs/ca-certificates.crt \
1286 /etc/pki/tls/certs/ca-bundle.crt \
1287 /usr/share/ssl/certs/ca-bundle.crt \
d61c8051 1288 /usr/local/share/certs/ca-root-nss.crt \
073b03fa
DS
1289 /etc/ssl/cert.pem \
1290 "$cac"; do
1291 if test -f "$a"; then
1292 ca="$a"
1293 break
1294 fi
1295 done
1296 fi
849bd50c
DS
1297 AC_MSG_NOTICE([want $want_capath ca $ca])
1298 if test "x$want_capath" = "xunset"; then
1299 if test "x$OPENSSL_ENABLED" = "x1" -o \
1300 "x$GNUTLS_ENABLED" = "x1" -o \
1301 "x$MBEDTLS_ENABLED" = "x1" -o \
1302 "x$WOLFSSL_ENABLED" = "x1"; then
b8f6c3ca 1303 check_capath="/etc/ssl/certs"
849bd50c 1304 fi
073b03fa
DS
1305 fi
1306 else
1307 dnl no option given and cross-compiling
1308 AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling])
86cbb232
MM
1309 fi
1310 fi
a07bc791 1311
3ae77f07
JS
1312 if test "x$ca" = "xno" || test -f "$ca"; then
1313 ca_warning=""
1314 fi
1315
1316 if test "x$capath" != "xno"; then
1317 check_capath="$capath"
1318 fi
1319
1320 if test ! -z "$check_capath"; then
1321 for a in "$check_capath"; do
1322 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
1323 if test "x$capath" = "xno"; then
1324 capath="$a"
1325 fi
1326 capath_warning=""
1327 break
1328 fi
1329 done
1330 fi
1331
1332 if test "x$capath" = "xno"; then
1333 capath_warning=""
1334 fi
1335
fb23b857
DS
1336 if test "x$ca" != "xno"; then
1337 CURL_CA_BUNDLE='"'$ca'"'
d13be06a 1338 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
c1a71ad1 1339 AC_SUBST(CURL_CA_BUNDLE)
86cbb232 1340 AC_MSG_RESULT([$ca])
90314100
JO
1341 fi
1342 if test "x$capath" != "xno"; then
86cbb232 1343 CURL_CA_PATH="\"$capath\""
d13be06a 1344 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
86cbb232 1345 AC_MSG_RESULT([$capath (capath)])
90314100 1346 fi
4335b86a 1347 if test "x$ca" = "xno" && test "x$capath" = "xno"; then
86cbb232 1348 AC_MSG_RESULT([no])
fb23b857 1349 fi
7b55279d
LN
1350
1351 AC_MSG_CHECKING([whether to use builtin CA store of SSL library])
1352 AC_ARG_WITH(ca-fallback,
a59f0461
DS
1353AS_HELP_STRING([--with-ca-fallback], [Use the built in CA store of the SSL library])
1354AS_HELP_STRING([--without-ca-fallback], [Don't use the built in CA store of the SSL library]),
7b55279d
LN
1355 [
1356 if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then
1357 AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter])
1358 fi
1359 ],
1360 [ with_ca_fallback="no"])
1361 AC_MSG_RESULT([$with_ca_fallback])
1362 if test "x$with_ca_fallback" = "xyes"; then
1363 if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then
1364 AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS])
1365 fi
1366 AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built in CA store of SSL library ])
1367 fi
fb23b857 1368])
9cef14df 1369
fef60d9d
YT
1370dnl CURL_CHECK_WIN32_LARGEFILE
1371dnl -------------------------------------------------
1372dnl Check if curl's WIN32 large file will be used
1373
1374AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
c1bc090d 1375 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
fef60d9d
YT
1376 AC_MSG_CHECKING([whether build target supports WIN32 file API])
1377 curl_win32_file_api="no"
c1bc090d 1378 if test "$curl_cv_native_windows" = "yes"; then
fef60d9d
YT
1379 if test x"$enable_largefile" != "xno"; then
1380 AC_COMPILE_IFELSE([
1381 AC_LANG_PROGRAM([[
1382 ]],[[
c1bc090d 1383#if !defined(_WIN32_WCE) && (defined(__MINGW32__) || defined(_MSC_VER))
fef60d9d
YT
1384 int dummy=1;
1385#else
1386 WIN32 large file API not supported.
1387#endif
1388 ]])
1389 ],[
1390 curl_win32_file_api="win32_large_files"
1391 ])
1392 fi
1393 if test "$curl_win32_file_api" = "no"; then
1394 AC_COMPILE_IFELSE([
1395 AC_LANG_PROGRAM([[
1396 ]],[[
1397#if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
1398 int dummy=1;
1399#else
1400 WIN32 small file API not supported.
1401#endif
1402 ]])
1403 ],[
1404 curl_win32_file_api="win32_small_files"
1405 ])
1406 fi
1407 fi
1408 case "$curl_win32_file_api" in
1409 win32_large_files)
1410 AC_MSG_RESULT([yes (large file enabled)])
1411 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
1412 [Define to 1 if you are building a Windows target with large file support.])
cc615f48 1413 AC_SUBST(USE_WIN32_LARGE_FILES, [1])
fef60d9d
YT
1414 ;;
1415 win32_small_files)
1416 AC_MSG_RESULT([yes (large file disabled)])
7fcbdd68 1417 AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1,
fef60d9d 1418 [Define to 1 if you are building a Windows target without large file support.])
cc615f48
MH
1419 AC_SUBST(USE_WIN32_SMALL_FILES, [1])
1420 ;;
1421 *)
1422 AC_MSG_RESULT([no])
1423 ;;
1424 esac
1425])
1426
1427dnl CURL_CHECK_WIN32_CRYPTO
1428dnl -------------------------------------------------
1429dnl Check if curl's WIN32 crypto lib can be used
1430
1431AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [
c1bc090d 1432 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
cc615f48
MH
1433 AC_MSG_CHECKING([whether build target supports WIN32 crypto API])
1434 curl_win32_crypto_api="no"
c1bc090d 1435 if test "$curl_cv_native_windows" = "yes"; then
cc615f48
MH
1436 AC_COMPILE_IFELSE([
1437 AC_LANG_PROGRAM([[
1438#undef inline
1439#ifndef WIN32_LEAN_AND_MEAN
1440#define WIN32_LEAN_AND_MEAN
1441#endif
1442#include <windows.h>
1443#include <wincrypt.h>
1444 ]],[[
1445 HCRYPTPROV hCryptProv;
1446 if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
1447 CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
1448 CryptReleaseContext(hCryptProv, 0);
1449 }
1450 ]])
1451 ],[
1452 curl_win32_crypto_api="yes"
1453 ])
1454 fi
1455 case "$curl_win32_crypto_api" in
1456 yes)
1457 AC_MSG_RESULT([yes])
1458 AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1,
1459 [Define to 1 if you are building a Windows target with crypto API support.])
1460 AC_SUBST(USE_WIN32_CRYPTO, [1])
fef60d9d
YT
1461 ;;
1462 *)
1463 AC_MSG_RESULT([no])
1464 ;;
1465 esac
304537c2 1466])
b9fdc0c2 1467
383bf1e4
KD
1468dnl CURL_EXPORT_PCDIR ($pcdir)
1469dnl ------------------------
1470dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export
1471dnl
1472dnl we need this macro since pkg-config distinguishes among empty and unset
1473dnl variable while checking PKG_CONFIG_LIBDIR
1474dnl
1475
1476AC_DEFUN([CURL_EXPORT_PCDIR], [
1477 if test -n "$1"; then
1478 PKG_CONFIG_LIBDIR="$1"
1479 export PKG_CONFIG_LIBDIR
1480 fi
1481])
1482
1483dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir])
b9fdc0c2 1484dnl ------------------------
c07a6f3f
CW
1485dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the
1486dnl path to it, or 'no' if not found/present.
b9fdc0c2 1487dnl
e47c9398
DS
1488dnl If pkg-config is present, check that it has info about the $module or
1489dnl return "no" anyway!
b9fdc0c2 1490dnl
383bf1e4
KD
1491dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir.
1492dnl
b9fdc0c2
DS
1493
1494AC_DEFUN([CURL_CHECK_PKGCONFIG], [
d9a1776b 1495 if test -n "$PKG_CONFIG"; then
72d99f2e 1496 PKGCONFIG="$PKG_CONFIG"
d9a1776b 1497 else
72d99f2e
JS
1498 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no],
1499 [$PATH:/usr/bin:/usr/local/bin])
1500 fi
1501
1502 if test "x$PKGCONFIG" != "xno"; then
b9fdc0c2
DS
1503 AC_MSG_CHECKING([for $1 options with pkg-config])
1504 dnl ask pkg-config about $1
383bf1e4
KD
1505 itexists=`CURL_EXPORT_PCDIR([$2]) dnl
1506 $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1`
1507
1508 if test -z "$itexists"; then
b9fdc0c2
DS
1509 dnl pkg-config does not have info about the given module! set the
1510 dnl variable to 'no'
1511 PKGCONFIG="no"
1512 AC_MSG_RESULT([no])
1513 else
1514 AC_MSG_RESULT([found])
1515 fi
1516 fi
b9fdc0c2 1517])
ef24ecde
YT
1518
1519
1520dnl CURL_GENERATE_CONFIGUREHELP_PM
1521dnl -------------------------------------------------
1522dnl Generate test harness configurehelp.pm module, defining and
1523dnl initializing some perl variables with values which are known
1524dnl when the configure script runs. For portability reasons, test
1525dnl harness needs information on how to run the C preprocessor.
1526
1527AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
1528 AC_REQUIRE([AC_PROG_CPP])dnl
1529 tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
1530 if test -z "$tmp_cpp"; then
1531 tmp_cpp='cpp'
1532 fi
1533 cat >./tests/configurehelp.pm <<_EOF
1534[@%:@] This is a generated file. Do not edit.
1535
1536package configurehelp;
1537
1538use strict;
1539use warnings;
1540use Exporter;
1541
1542use vars qw(
1543 @ISA
1544 @EXPORT_OK
1545 \$Cpreprocessor
1546 );
1547
1548@ISA = qw(Exporter);
1549
1550@EXPORT_OK = qw(
1551 \$Cpreprocessor
1552 );
1553
1554\$Cpreprocessor = '$tmp_cpp';
1555
15561;
1557_EOF
1558])
ecf95343
DS
1559
1560dnl CURL_CPP_P
1561dnl
1562dnl Check if $cpp -P should be used for extract define values due to gcc 5
1563dnl splitting up strings and defines between line outputs. gcc by default
1564dnl (without -P) will show TEST EINVAL TEST as
1565dnl
1566dnl # 13 "conftest.c"
1567dnl TEST
1568dnl # 13 "conftest.c" 3 4
1569dnl 22
1570dnl # 13 "conftest.c"
1571dnl TEST
1572
1573AC_DEFUN([CURL_CPP_P], [
1574 AC_MSG_CHECKING([if cpp -P is needed])
1575 AC_EGREP_CPP([TEST.*TEST], [
1576 #include <errno.h>
1577TEST EINVAL TEST
1578 ], [cpp=no], [cpp=yes])
1579 AC_MSG_RESULT([$cpp])
1580
1581 dnl we need cpp -P so check if it works then
1582 if test "x$cpp" = "xyes"; then
1583 AC_MSG_CHECKING([if cpp -P works])
1584 OLDCPPFLAGS=$CPPFLAGS
1585 CPPFLAGS="$CPPFLAGS -P"
1586 AC_EGREP_CPP([TEST.*TEST], [
1587 #include <errno.h>
1588TEST EINVAL TEST
1589 ], [cpp_p=yes], [cpp_p=no])
1590 AC_MSG_RESULT([$cpp_p])
1591
1592 if test "x$cpp_p" = "xno"; then
1593 AC_MSG_WARN([failed to figure out cpp -P alternative])
1594 # without -P
46398941 1595 CPPPFLAG=""
ecf95343
DS
1596 else
1597 # with -P
46398941 1598 CPPPFLAG="-P"
ecf95343
DS
1599 fi
1600 dnl restore CPPFLAGS
1601 CPPFLAGS=$OLDCPPFLAGS
46398941
CD
1602 else
1603 # without -P
1604 CPPPFLAG=""
ecf95343
DS
1605 fi
1606])
4f8d0b6f
DS
1607
1608
5d2c3844 1609dnl CURL_DARWIN_CFLAGS
4f8d0b6f 1610dnl
5d2c3844
MYN
1611dnl Set -Werror=partial-availability to detect possible breaking code
1612dnl with very low deployment targets.
4f8d0b6f
DS
1613dnl
1614
5d2c3844 1615AC_DEFUN([CURL_DARWIN_CFLAGS], [
4f8d0b6f
DS
1616
1617 tst_cflags="no"
1618 case $host_os in
1619 darwin*)
1620 tst_cflags="yes"
1621 ;;
1622 esac
1623
5d2c3844 1624 AC_MSG_CHECKING([for good-to-use Darwin CFLAGS])
4f8d0b6f
DS
1625 AC_MSG_RESULT([$tst_cflags]);
1626
1627 if test "$tst_cflags" = "yes"; then
6724242c 1628 old_CFLAGS=$CFLAGS
4f8d0b6f 1629 CFLAGS="$CFLAGS -Werror=partial-availability"
6724242c
DS
1630 AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability])
1631 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1632 [AC_MSG_RESULT([yes])],
1633 [AC_MSG_RESULT([no])
1634 CFLAGS=$old_CFLAGS])
4f8d0b6f
DS
1635 fi
1636
1637])
870d849d
NZ
1638
1639
1640dnl CURL_SUPPORTS_BUILTIN_AVAILABLE
1641dnl
1642dnl Check to see if the compiler supports __builtin_available. This built-in
1643dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at
1644dnl the time this macro was written, the function was not yet documented. Its
1645dnl purpose is to return true if the code is running under a certain OS version
1646dnl or later.
1647
1648AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [
1649 AC_MSG_CHECKING([to see if the compiler supports __builtin_available()])
1650 AC_COMPILE_IFELSE([
1651 AC_LANG_PROGRAM([[
1652#include <stdlib.h>
1653 ]],[[
1654 if (__builtin_available(macOS 10.8, iOS 5.0, *)) {}
1655 ]])
1656 ],[
1657 AC_MSG_RESULT([yes])
1658 AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1,
1659 [Define to 1 if you have the __builtin_available function.])
1660 ],[
1661 AC_MSG_RESULT([no])
1662 ])
1663])