1#*************************************************************************** 2# _ _ ____ _ 3# Project ___| | | | _ \| | 4# / __| | | | |_) | | 5# | (__| |_| | _ <| |___ 6# \___|\___/|_| \_\_____| 7# 8# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 9# 10# This software is licensed as described in the file COPYING, which 11# you should have received as part of this distribution. The terms 12# are also available at https://curl.se/docs/copyright.html. 13# 14# You may opt to use, copy, modify, merge, publish, distribute and/or sell 15# copies of the Software, and permit persons to whom the Software is 16# furnished to do so, under the terms of the COPYING file. 17# 18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 19# KIND, either express or implied. 20# 21# SPDX-License-Identifier: curl 22# 23#*************************************************************************** 24 25dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT]) 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 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. 33 34AC_DEFUN([CURL_CHECK_DEF], [ 35 AC_REQUIRE([CURL_CPP_P])dnl 36 OLDCPPFLAGS=$CPPFLAGS 37 # CPPPFLAG comes from CURL_CPP_P 38 CPPFLAGS="$CPPFLAGS $CPPPFLAG" 39 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl 40 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl 41 if test -z "$SED"; then 42 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.]) 43 fi 44 if test -z "$GREP"; then 45 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.]) 46 fi 47 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])]) 48 tmp_exp="" 49 AC_PREPROC_IFELSE([ 50 AC_LANG_SOURCE( 51ifelse($2,,,[$2])[[ 52 #ifdef $1 53 CURL_DEF_TOKEN $1 54 #endif 55 ]]) 56 ],[ 57 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \ 58 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \ 59 "$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \ 60 "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null` 61 if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then 62 tmp_exp="" 63 fi 64 ]) 65 if test -z "$tmp_exp"; then 66 AS_VAR_SET(ac_HaveDef, no) 67 ifelse($3,,[AC_MSG_RESULT([no])]) 68 else 69 AS_VAR_SET(ac_HaveDef, yes) 70 AS_VAR_SET(ac_Def, $tmp_exp) 71 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])]) 72 fi 73 AS_VAR_POPDEF([ac_Def])dnl 74 AS_VAR_POPDEF([ac_HaveDef])dnl 75 CPPFLAGS=$OLDCPPFLAGS 76]) 77 78 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])[[ 92 int main(void) 93 { 94 #ifdef $1 95 return 0; 96 #else 97 #error 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 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([[ 126 int main(void) 127 { 128 #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600) 129 return 0; 130 #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED) 131 return 0; 132 #else 133 #error force compilation error 134 #endif 135 } 136 ]]) 137 ],[ 138 tst_lib_xnet_required="yes" 139 LIBS="-lxnet $LIBS" 140 ]) 141 AC_MSG_RESULT([$tst_lib_xnet_required]) 142]) 143 144 145dnl CURL_CHECK_AIX_ALL_SOURCE 146dnl ------------------------------------------------- 147dnl Provides a replacement of traditional AC_AIX with 148dnl an uniform behavior across all autoconf versions, 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 173dnl CURL_CHECK_NATIVE_WINDOWS 174dnl ------------------------------------------------- 175dnl Check if building a native Windows target 176 177AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [ 178 AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [ 179 AC_COMPILE_IFELSE([ 180 AC_LANG_PROGRAM([[ 181 ]],[[ 182 #ifdef _WIN32 183 int dummy=1; 184 #else 185 #error Not a native Windows build target. 186 #endif 187 ]]) 188 ],[ 189 curl_cv_native_windows="yes" 190 ],[ 191 curl_cv_native_windows="no" 192 ]) 193 ]) 194 AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes) 195]) 196 197 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], [ 204 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl 205 AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [ 206 AC_COMPILE_IFELSE([ 207 AC_LANG_PROGRAM([[ 208 #undef inline 209 #ifdef _WIN32 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 219 #ifndef NULL 220 #define NULL (void *)0 221 #endif 222 #include <lber.h> 223 ]],[[ 224 BerValue *bvp = NULL; 225 BerElement *bep = ber_init(bvp); 226 ber_free(bep, 1); 227 ]]) 228 ],[ 229 curl_cv_header_lber_h="yes" 230 ],[ 231 curl_cv_header_lber_h="no" 232 ]) 233 ]) 234 if test "$curl_cv_header_lber_h" = "yes"; then 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([ 239 AC_LANG_PROGRAM([[ 240 #undef inline 241 #ifdef _WIN32 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 251 #ifndef NULL 252 #define NULL (void *)0 253 #endif 254 #ifndef LDAP_DEPRECATED 255 #define LDAP_DEPRECATED 1 256 #endif 257 #include <ldap.h> 258 ]],[[ 259 BerValue *bvp = NULL; 260 BerElement *bep = ber_init(bvp); 261 ber_free(bep, 1); 262 ]]) 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 285 AC_CACHE_CHECK([for ldap.h], [curl_cv_header_ldap_h], [ 286 AC_COMPILE_IFELSE([ 287 AC_LANG_PROGRAM([[ 288 #undef inline 289 #ifdef _WIN32 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> 306 ]],[[ 307 LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT); 308 int res = ldap_unbind(ldp); 309 ]]) 310 ],[ 311 curl_cv_header_ldap_h="yes" 312 ],[ 313 curl_cv_header_ldap_h="no" 314 ]) 315 ]) 316 case "$curl_cv_header_ldap_h" in 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 331 AC_CACHE_CHECK([for ldap_ssl.h], [curl_cv_header_ldap_ssl_h], [ 332 AC_COMPILE_IFELSE([ 333 AC_LANG_PROGRAM([[ 334 #undef inline 335 #ifdef _WIN32 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> 355 ]],[[ 356 LDAP *ldp = ldapssl_init("0.0.0.0", LDAPS_PORT, 1); 357 ]]) 358 ],[ 359 curl_cv_header_ldap_ssl_h="yes" 360 ],[ 361 curl_cv_header_ldap_ssl_h="no" 362 ]) 363 ]) 364 case "$curl_cv_header_ldap_ssl_h" in 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 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 378dnl whitespace separated list of libraries to check 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 # 406 curl_cv_save_LIBS="$LIBS" 407 curl_cv_ldap_LIBS="unknown" 408 # 409 for x_nlibs in '' "$u_libs" \ 410 '-lwldap32' ; do 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([[ 419 #undef inline 420 #ifdef _WIN32 421 #ifndef WIN32_LEAN_AND_MEAN 422 #define WIN32_LEAN_AND_MEAN 423 #endif 424 #include <windows.h> 425 #include <winldap.h> 426 #ifdef HAVE_WINBER_H 427 #include <winber.h> 428 #endif 429 #endif 430 ]],[[ 431 BERVAL *bvp = NULL; 432 BerElement *bep = ber_init(bvp); 433 LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT); 434 ULONG res = ldap_unbind(ldp); 435 ber_free(bep, 1); 436 ]]) 437 ],[ 438 curl_cv_ldap_LIBS="$x_nlibs" 439 ]) 440 fi 441 done 442 # 443 LIBS="$curl_cv_save_LIBS" 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 465dnl CURL_CHECK_LIBS_LDAP 466dnl ------------------------------------------------- 467dnl Check for libraries needed for LDAP support, 468dnl and prepended to LIBS any needed libraries. 469dnl This macro can take an optional parameter with a 470dnl whitespace separated list of libraries to check 471dnl before the default ones. 472 473AC_DEFUN([CURL_CHECK_LIBS_LDAP], [ 474 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl 475 # 476 AC_MSG_CHECKING([for LDAP libraries]) 477 # 478 u_libs="" 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 ]) 497 # 498 curl_cv_save_LIBS="$LIBS" 499 curl_cv_ldap_LIBS="unknown" 500 # 501 for x_nlibs in '' "$u_libs" \ 502 '-lldap' \ 503 '-lldap -llber' \ 504 '-llber -lldap' \ 505 '-lldapssl -lldapx -lldapsdk' \ 506 '-lldapsdk -lldapx -lldapssl' \ 507 '-lldap -llber -lssl -lcrypto'; do 508 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([[ 517 #undef inline 518 #ifdef _WIN32 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 528 #ifndef NULL 529 #define NULL (void *)0 530 #endif 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> 539 #endif 540 ]],[[ 541 BerValue *bvp = NULL; 542 BerElement *bep = ber_init(bvp); 543 LDAP *ldp = ldap_init("0.0.0.0", LDAP_PORT); 544 int res = ldap_unbind(ldp); 545 ber_free(bep, 1); 546 ]]) 547 ],[ 548 curl_cv_ldap_LIBS="$x_nlibs" 549 ]) 550 fi 551 done 552 # 553 LIBS="$curl_cv_save_LIBS" 554 # 555 case X-"$curl_cv_ldap_LIBS" in 556 X-unknown) 557 AC_MSG_RESULT([cannot find LDAP libraries]) 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 LIBCURL_PC_REQUIRES_PRIVATE="ldap $LIBCURL_PC_REQUIRES_PRIVATE" 569 AC_MSG_RESULT([$curl_cv_ldap_LIBS]) 570 ;; 571 esac 572 # 573]) 574 575 576dnl TYPE_SOCKADDR_STORAGE 577dnl ------------------------------------------------- 578dnl Check for struct sockaddr_storage. Most IPv6-enabled 579dnl hosts have it, but AIX 4.3 is one known exception. 580 581AC_DEFUN([TYPE_SOCKADDR_STORAGE], 582[ 583 AC_CHECK_TYPE([struct sockaddr_storage], 584 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, 585 [if struct sockaddr_storage is defined]), , 586 [ 587 #undef inline 588 #ifdef _WIN32 589 #ifndef WIN32_LEAN_AND_MEAN 590 #define WIN32_LEAN_AND_MEAN 591 #endif 592 #include <winsock2.h> 593 #else 594 #ifdef HAVE_SYS_TYPES_H 595 #include <sys/types.h> 596 #endif 597 #ifdef HAVE_SYS_SOCKET_H 598 #include <sys/socket.h> 599 #endif 600 #ifdef HAVE_NETINET_IN_H 601 #include <netinet/in.h> 602 #endif 603 #ifdef HAVE_ARPA_INET_H 604 #include <arpa/inet.h> 605 #endif 606 #endif 607 ]) 608]) 609 610dnl CURL_CHECK_FUNC_RECV 611dnl ------------------------------------------------- 612dnl Test if the socket recv() function is available, 613 614AC_DEFUN([CURL_CHECK_FUNC_RECV], [ 615 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl 616 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl 617 AC_CHECK_HEADERS(sys/types.h sys/socket.h) 618 # 619 AC_MSG_CHECKING([for recv]) 620 AC_LINK_IFELSE([ 621 AC_LANG_PROGRAM([[ 622 #undef inline 623 #ifdef _WIN32 624 #ifndef WIN32_LEAN_AND_MEAN 625 #define WIN32_LEAN_AND_MEAN 626 #endif 627 #include <winsock2.h> 628 #else 629 $curl_includes_bsdsocket 630 #ifdef HAVE_SYS_TYPES_H 631 #include <sys/types.h> 632 #endif 633 #ifdef HAVE_SYS_SOCKET_H 634 #include <sys/socket.h> 635 #endif 636 #endif 637 ]],[[ 638 recv(0, 0, 0, 0); 639 ]]) 640 ],[ 641 AC_MSG_RESULT([yes]) 642 curl_cv_recv="yes" 643 ],[ 644 AC_MSG_RESULT([no]) 645 curl_cv_recv="no" 646 ]) 647 # 648 if test "$curl_cv_recv" = "yes"; then 649 AC_DEFINE_UNQUOTED(HAVE_RECV, 1, 650 [Define to 1 if you have the recv function.]) 651 curl_cv_func_recv="yes" 652 else 653 AC_MSG_ERROR([Unable to link function recv]) 654 fi 655]) 656 657 658dnl CURL_CHECK_FUNC_SEND 659dnl ------------------------------------------------- 660dnl Test if the socket send() function is available, 661 662AC_DEFUN([CURL_CHECK_FUNC_SEND], [ 663 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl 664 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl 665 AC_CHECK_HEADERS(sys/types.h sys/socket.h) 666 # 667 AC_MSG_CHECKING([for send]) 668 AC_LINK_IFELSE([ 669 AC_LANG_PROGRAM([[ 670 #undef inline 671 #ifdef _WIN32 672 #ifndef WIN32_LEAN_AND_MEAN 673 #define WIN32_LEAN_AND_MEAN 674 #endif 675 #include <winsock2.h> 676 #else 677 $curl_includes_bsdsocket 678 #ifdef HAVE_SYS_TYPES_H 679 #include <sys/types.h> 680 #endif 681 #ifdef HAVE_SYS_SOCKET_H 682 #include <sys/socket.h> 683 #endif 684 #endif 685 ]],[[ 686 send(0, 0, 0, 0); 687 ]]) 688 ],[ 689 AC_MSG_RESULT([yes]) 690 curl_cv_send="yes" 691 ],[ 692 AC_MSG_RESULT([no]) 693 curl_cv_send="no" 694 ]) 695 # 696 if test "$curl_cv_send" = "yes"; then 697 AC_DEFINE_UNQUOTED(HAVE_SEND, 1, 698 [Define to 1 if you have the send function.]) 699 curl_cv_func_send="yes" 700 else 701 AC_MSG_ERROR([Unable to link function send]) 702 fi 703]) 704 705dnl CURL_CHECK_MSG_NOSIGNAL 706dnl ------------------------------------------------- 707dnl Check for MSG_NOSIGNAL 708 709AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [ 710 AC_CHECK_HEADERS(sys/types.h sys/socket.h) 711 AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [ 712 AC_COMPILE_IFELSE([ 713 AC_LANG_PROGRAM([[ 714 #undef inline 715 #ifdef _WIN32 716 #ifndef WIN32_LEAN_AND_MEAN 717 #define WIN32_LEAN_AND_MEAN 718 #endif 719 #include <winsock2.h> 720 #else 721 #ifdef HAVE_SYS_TYPES_H 722 #include <sys/types.h> 723 #endif 724 #ifdef HAVE_SYS_SOCKET_H 725 #include <sys/socket.h> 726 #endif 727 #endif 728 ]],[[ 729 int flag=MSG_NOSIGNAL; 730 ]]) 731 ],[ 732 curl_cv_msg_nosignal="yes" 733 ],[ 734 curl_cv_msg_nosignal="no" 735 ]) 736 ]) 737 case "$curl_cv_msg_nosignal" in 738 yes) 739 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1, 740 [Define to 1 if you have the MSG_NOSIGNAL flag.]) 741 ;; 742 esac 743]) 744 745 746dnl CURL_CHECK_STRUCT_TIMEVAL 747dnl ------------------------------------------------- 748dnl Check for timeval struct 749 750AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [ 751 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl 752 AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h) 753 AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [ 754 AC_COMPILE_IFELSE([ 755 AC_LANG_PROGRAM([[ 756 #undef inline 757 #ifdef _WIN32 758 #ifndef WIN32_LEAN_AND_MEAN 759 #define WIN32_LEAN_AND_MEAN 760 #endif 761 #include <winsock2.h> 762 #endif 763 #ifdef HAVE_SYS_TYPES_H 764 #include <sys/types.h> 765 #endif 766 #ifdef HAVE_SYS_TIME_H 767 #include <sys/time.h> 768 #endif 769 #include <time.h> 770 #ifdef HAVE_SYS_SOCKET_H 771 #include <sys/socket.h> 772 #endif 773 ]],[[ 774 struct timeval ts; 775 ts.tv_sec = 0; 776 ts.tv_usec = 0; 777 ]]) 778 ],[ 779 curl_cv_struct_timeval="yes" 780 ],[ 781 curl_cv_struct_timeval="no" 782 ]) 783 ]) 784 case "$curl_cv_struct_timeval" in 785 yes) 786 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1, 787 [Define to 1 if you have the timeval struct.]) 788 ;; 789 esac 790]) 791 792 793dnl TYPE_IN_ADDR_T 794dnl ------------------------------------------------- 795dnl Check for in_addr_t: it is used to receive the return code of inet_addr() 796dnl and a few other things. 797 798AC_DEFUN([TYPE_IN_ADDR_T], [ 799 AC_CHECK_TYPE([in_addr_t], ,[ 800 dnl in_addr_t not available 801 AC_CACHE_CHECK([for in_addr_t equivalent], 802 [curl_cv_in_addr_t_equiv], [ 803 curl_cv_in_addr_t_equiv="unknown" 804 for t in "unsigned long" int size_t unsigned long; do 805 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then 806 AC_LINK_IFELSE([ 807 AC_LANG_PROGRAM([[ 808 #undef inline 809 #ifdef _WIN32 810 #ifndef WIN32_LEAN_AND_MEAN 811 #define WIN32_LEAN_AND_MEAN 812 #endif 813 #include <winsock2.h> 814 #else 815 #ifdef HAVE_SYS_TYPES_H 816 #include <sys/types.h> 817 #endif 818 #ifdef HAVE_SYS_SOCKET_H 819 #include <sys/socket.h> 820 #endif 821 #ifdef HAVE_NETINET_IN_H 822 #include <netinet/in.h> 823 #endif 824 #ifdef HAVE_ARPA_INET_H 825 #include <arpa/inet.h> 826 #endif 827 #endif 828 ]],[[ 829 $t data = inet_addr ("1.2.3.4"); 830 ]]) 831 ],[ 832 curl_cv_in_addr_t_equiv="$t" 833 ]) 834 fi 835 done 836 ]) 837 case "$curl_cv_in_addr_t_equiv" in 838 unknown) 839 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t]) 840 ;; 841 *) 842 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv, 843 [Type to use in place of in_addr_t when system does not provide it.]) 844 ;; 845 esac 846 ],[ 847 #undef inline 848 #ifdef _WIN32 849 #ifndef WIN32_LEAN_AND_MEAN 850 #define WIN32_LEAN_AND_MEAN 851 #endif 852 #include <winsock2.h> 853 #else 854 #ifdef HAVE_SYS_TYPES_H 855 #include <sys/types.h> 856 #endif 857 #ifdef HAVE_SYS_SOCKET_H 858 #include <sys/socket.h> 859 #endif 860 #ifdef HAVE_NETINET_IN_H 861 #include <netinet/in.h> 862 #endif 863 #ifdef HAVE_ARPA_INET_H 864 #include <arpa/inet.h> 865 #endif 866 #endif 867 ]) 868]) 869 870 871dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC 872dnl ------------------------------------------------- 873dnl Check if monotonic clock_gettime is available. 874 875AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [ 876 AC_CHECK_HEADERS(sys/types.h sys/time.h) 877 AC_MSG_CHECKING([for monotonic clock_gettime]) 878 # 879 if test "x$dontwant_rt" = "xno" ; then 880 AC_COMPILE_IFELSE([ 881 AC_LANG_PROGRAM([[ 882 #ifdef HAVE_SYS_TYPES_H 883 #include <sys/types.h> 884 #endif 885 #ifdef HAVE_SYS_TIME_H 886 #include <sys/time.h> 887 #endif 888 #include <time.h> 889 ]],[[ 890 struct timespec ts; 891 (void)clock_gettime(CLOCK_MONOTONIC, &ts); 892 ]]) 893 ],[ 894 AC_MSG_RESULT([yes]) 895 curl_func_clock_gettime="yes" 896 ],[ 897 AC_MSG_RESULT([no]) 898 curl_func_clock_gettime="no" 899 ]) 900 fi 901 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed 902 dnl until library linking and run-time checks for clock_gettime succeed. 903]) 904 905dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW 906dnl ------------------------------------------------- 907dnl Check if monotonic clock_gettime is available. 908 909AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW], [ 910 AC_CHECK_HEADERS(sys/types.h sys/time.h) 911 AC_MSG_CHECKING([for raw monotonic clock_gettime]) 912 # 913 if test "x$dontwant_rt" = "xno" ; then 914 AC_COMPILE_IFELSE([ 915 AC_LANG_PROGRAM([[ 916 #ifdef HAVE_SYS_TYPES_H 917 #include <sys/types.h> 918 #endif 919 #ifdef HAVE_SYS_TIME_H 920 #include <sys/time.h> 921 #endif 922 #include <time.h> 923 ]],[[ 924 struct timespec ts; 925 (void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts); 926 ]]) 927 ],[ 928 AC_MSG_RESULT([yes]) 929 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC_RAW, 1, 930 [Define to 1 if you have the clock_gettime function and raw monotonic timer.]) 931 ],[ 932 AC_MSG_RESULT([no]) 933 ]) 934 fi 935]) 936 937 938dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC 939dnl ------------------------------------------------- 940dnl If monotonic clock_gettime is available then, 941dnl check and prepended to LIBS any needed libraries. 942 943AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [ 944 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl 945 # 946 if test "$curl_func_clock_gettime" = "yes"; then 947 # 948 AC_MSG_CHECKING([for clock_gettime in libraries]) 949 # 950 curl_cv_save_LIBS="$LIBS" 951 curl_cv_gclk_LIBS="unknown" 952 # 953 for x_xlibs in '' '-lrt' '-lposix4' ; do 954 if test "$curl_cv_gclk_LIBS" = "unknown"; then 955 if test -z "$x_xlibs"; then 956 LIBS="$curl_cv_save_LIBS" 957 else 958 LIBS="$x_xlibs $curl_cv_save_LIBS" 959 fi 960 AC_LINK_IFELSE([ 961 AC_LANG_PROGRAM([[ 962 #ifdef HAVE_SYS_TYPES_H 963 #include <sys/types.h> 964 #endif 965 #ifdef HAVE_SYS_TIME_H 966 #include <sys/time.h> 967 #endif 968 #include <time.h> 969 ]],[[ 970 struct timespec ts; 971 (void)clock_gettime(CLOCK_MONOTONIC, &ts); 972 ]]) 973 ],[ 974 curl_cv_gclk_LIBS="$x_xlibs" 975 ]) 976 fi 977 done 978 # 979 LIBS="$curl_cv_save_LIBS" 980 # 981 case X-"$curl_cv_gclk_LIBS" in 982 X-unknown) 983 AC_MSG_RESULT([cannot find clock_gettime]) 984 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined]) 985 curl_func_clock_gettime="no" 986 ;; 987 X-) 988 AC_MSG_RESULT([no additional lib required]) 989 curl_func_clock_gettime="yes" 990 ;; 991 *) 992 if test -z "$curl_cv_save_LIBS"; then 993 LIBS="$curl_cv_gclk_LIBS" 994 else 995 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS" 996 fi 997 AC_MSG_RESULT([$curl_cv_gclk_LIBS]) 998 curl_func_clock_gettime="yes" 999 ;; 1000 esac 1001 # 1002 dnl only do runtime verification when not cross-compiling 1003 if test "x$cross_compiling" != "xyes" && 1004 test "$curl_func_clock_gettime" = "yes"; then 1005 AC_MSG_CHECKING([if monotonic clock_gettime works]) 1006 CURL_RUN_IFELSE([ 1007 AC_LANG_PROGRAM([[ 1008 #include <stdlib.h> 1009 #ifdef HAVE_SYS_TYPES_H 1010 #include <sys/types.h> 1011 #endif 1012 #ifdef HAVE_SYS_TIME_H 1013 #include <sys/time.h> 1014 #endif 1015 #include <time.h> 1016 ]],[[ 1017 struct timespec ts; 1018 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts)) 1019 exit(0); 1020 else 1021 exit(1); 1022 ]]) 1023 ],[ 1024 AC_MSG_RESULT([yes]) 1025 ],[ 1026 AC_MSG_RESULT([no]) 1027 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined]) 1028 curl_func_clock_gettime="no" 1029 LIBS="$curl_cv_save_LIBS" 1030 ]) 1031 fi 1032 # 1033 case "$curl_func_clock_gettime" in 1034 yes) 1035 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1, 1036 [Define to 1 if you have the clock_gettime function and monotonic timer.]) 1037 ;; 1038 esac 1039 # 1040 fi 1041 # 1042]) 1043 1044 1045dnl CURL_CHECK_LIBS_CONNECT 1046dnl ------------------------------------------------- 1047dnl Verify if network connect function is already available 1048dnl using current libraries or if another one is required. 1049 1050AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [ 1051 AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl 1052 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl 1053 AC_MSG_CHECKING([for connect in libraries]) 1054 tst_connect_save_LIBS="$LIBS" 1055 tst_connect_need_LIBS="unknown" 1056 for tst_lib in '' '-lsocket' ; do 1057 if test "$tst_connect_need_LIBS" = "unknown"; then 1058 LIBS="$tst_lib $tst_connect_save_LIBS" 1059 AC_LINK_IFELSE([ 1060 AC_LANG_PROGRAM([[ 1061 $curl_includes_winsock2 1062 $curl_includes_bsdsocket 1063 #if !defined(_WIN32) && !defined(HAVE_PROTO_BSDSOCKET_H) 1064 int connect(int, void*, int); 1065 #endif 1066 ]],[[ 1067 if(0 != connect(0, 0, 0)) 1068 return 1; 1069 ]]) 1070 ],[ 1071 tst_connect_need_LIBS="$tst_lib" 1072 ]) 1073 fi 1074 done 1075 LIBS="$tst_connect_save_LIBS" 1076 # 1077 case X-"$tst_connect_need_LIBS" in 1078 X-unknown) 1079 AC_MSG_RESULT([cannot find connect]) 1080 AC_MSG_ERROR([cannot find connect function in libraries.]) 1081 ;; 1082 X-) 1083 AC_MSG_RESULT([yes]) 1084 ;; 1085 *) 1086 AC_MSG_RESULT([$tst_connect_need_LIBS]) 1087 LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS" 1088 ;; 1089 esac 1090]) 1091 1092 1093dnl CURL_CHECK_FUNC_SELECT 1094dnl ------------------------------------------------- 1095dnl Test if the socket select() function is available. 1096 1097AC_DEFUN([CURL_CHECK_FUNC_SELECT], [ 1098 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl 1099 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl 1100 AC_CHECK_HEADERS(sys/select.h sys/socket.h) 1101 # 1102 AC_MSG_CHECKING([for select]) 1103 AC_LINK_IFELSE([ 1104 AC_LANG_PROGRAM([[ 1105 #undef inline 1106 #ifdef _WIN32 1107 #ifndef WIN32_LEAN_AND_MEAN 1108 #define WIN32_LEAN_AND_MEAN 1109 #endif 1110 #include <winsock2.h> 1111 #endif 1112 #ifdef HAVE_SYS_TYPES_H 1113 #include <sys/types.h> 1114 #endif 1115 #ifdef HAVE_SYS_TIME_H 1116 #include <sys/time.h> 1117 #endif 1118 #include <time.h> 1119 #ifndef _WIN32 1120 #ifdef HAVE_SYS_SELECT_H 1121 #include <sys/select.h> 1122 #elif defined(HAVE_UNISTD_H) 1123 #include <unistd.h> 1124 #endif 1125 #ifdef HAVE_SYS_SOCKET_H 1126 #include <sys/socket.h> 1127 #endif 1128 $curl_includes_bsdsocket 1129 #endif 1130 ]],[[ 1131 select(0, 0, 0, 0, 0); 1132 ]]) 1133 ],[ 1134 AC_MSG_RESULT([yes]) 1135 curl_cv_select="yes" 1136 ],[ 1137 AC_MSG_RESULT([no]) 1138 curl_cv_select="no" 1139 ]) 1140 # 1141 if test "$curl_cv_select" = "yes"; then 1142 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1, 1143 [Define to 1 if you have the select function.]) 1144 curl_cv_func_select="yes" 1145 fi 1146]) 1147 1148 1149dnl CURL_VERIFY_RUNTIMELIBS 1150dnl ------------------------------------------------- 1151dnl Verify that the shared libs found so far can be used when running 1152dnl programs, since otherwise the situation will create odd configure errors 1153dnl that are misleading people. 1154dnl 1155dnl Make sure this test is run BEFORE the first test in the script that 1156dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF 1157dnl macro. It must also run AFTER all lib-checking macros are complete. 1158 1159AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [ 1160 1161 dnl this test is of course not sensible if we are cross-compiling! 1162 if test "x$cross_compiling" != xyes; then 1163 1164 dnl just run a program to verify that the libs checked for previous to this 1165 dnl point also is available run-time! 1166 AC_MSG_CHECKING([run-time libs availability]) 1167 CURL_RUN_IFELSE([ 1168 int main() 1169 { 1170 return 0; 1171 } 1172 ], 1173 AC_MSG_RESULT([fine]), 1174 AC_MSG_RESULT([failed]) 1175 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS]) 1176 ) 1177 1178 dnl if this test fails, configure has already stopped 1179 fi 1180]) 1181 1182 1183dnl CURL_CHECK_CA_BUNDLE 1184dnl ------------------------------------------------- 1185dnl Check if a default ca-bundle should be used 1186dnl 1187dnl regarding the paths this will scan: 1188dnl /etc/ssl/certs/ca-certificates.crt Debian systems 1189dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva 1190dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat 1191dnl /usr/local/share/certs/ca-root-nss.crt MidnightBSD 1192dnl /etc/ssl/cert.pem OpenBSD, MidnightBSD (symlink) 1193dnl /etc/ssl/certs (CA path) SUSE, FreeBSD 1194 1195AC_DEFUN([CURL_CHECK_CA_BUNDLE], [ 1196 1197 AC_MSG_CHECKING([default CA cert bundle/path]) 1198 1199 AC_ARG_WITH(ca-bundle, 1200AS_HELP_STRING([--with-ca-bundle=FILE], 1201 [Absolute path to a file containing CA certificates (example: /etc/ca-bundle.crt)]) 1202AS_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]), 1203 [ 1204 want_ca="$withval" 1205 if test "x$want_ca" = "xyes"; then 1206 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle]) 1207 fi 1208 ], 1209 [ want_ca="unset" ]) 1210 AC_ARG_WITH(ca-path, 1211AS_HELP_STRING([--with-ca-path=DIRECTORY], 1212 [Absolute path to a directory containing CA certificates stored individually, with \ 1213their filenames in a hash format. This option can be used with the OpenSSL, \ 1214GnuTLS, mbedTLS and wolfSSL backends. Refer to OpenSSL c_rehash for details. \ 1215(example: /etc/certificates)]) 1216AS_HELP_STRING([--without-ca-path], [Don't use a default CA path]), 1217 [ 1218 want_capath="$withval" 1219 if test "x$want_capath" = "xyes"; then 1220 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory]) 1221 fi 1222 ], 1223 [ want_capath="unset"]) 1224 1225 ca_warning=" (warning: certs not found)" 1226 capath_warning=" (warning: certs not found)" 1227 check_capath="" 1228 1229 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \ 1230 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then 1231 dnl both given 1232 ca="$want_ca" 1233 capath="$want_capath" 1234 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then 1235 dnl --with-ca-bundle given 1236 ca="$want_ca" 1237 capath="no" 1238 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then 1239 dnl --with-ca-path given 1240 capath="$want_capath" 1241 ca="no" 1242 else 1243 dnl First try auto-detecting a CA bundle, then a CA path. 1244 dnl Both auto-detections can be skipped by --without-ca-* 1245 ca="no" 1246 capath="no" 1247 if test "x$cross_compiling" != "xyes" -a \ 1248 "x$curl_cv_native_windows" != "xyes"; then 1249 dnl NOT cross-compiling and... 1250 dnl neither of the --with-ca-* options are provided 1251 if test "x$want_ca" = "xunset"; then 1252 dnl the path we previously would have installed the curl CA bundle 1253 dnl to, and thus we now check for an already existing cert in that 1254 dnl place in case we find no other 1255 if test "x$prefix" != xNONE; then 1256 cac="${prefix}/share/curl/curl-ca-bundle.crt" 1257 else 1258 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt" 1259 fi 1260 1261 for a in /etc/ssl/certs/ca-certificates.crt \ 1262 /etc/pki/tls/certs/ca-bundle.crt \ 1263 /usr/share/ssl/certs/ca-bundle.crt \ 1264 /usr/local/share/certs/ca-root-nss.crt \ 1265 /etc/ssl/cert.pem \ 1266 "$cac"; do 1267 if test -f "$a"; then 1268 ca="$a" 1269 break 1270 fi 1271 done 1272 fi 1273 AC_MSG_NOTICE([want $want_capath ca $ca]) 1274 if test "x$want_capath" = "xunset"; then 1275 check_capath="/etc/ssl/certs" 1276 fi 1277 else 1278 dnl no option given and cross-compiling 1279 AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling]) 1280 fi 1281 fi 1282 1283 if test "x$ca" = "xno" || test -f "$ca"; then 1284 ca_warning="" 1285 fi 1286 1287 if test "x$capath" != "xno"; then 1288 check_capath="$capath" 1289 fi 1290 1291 if test ! -z "$check_capath"; then 1292 for a in "$check_capath"; do 1293 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 1294 if test "x$capath" = "xno"; then 1295 capath="$a" 1296 fi 1297 capath_warning="" 1298 break 1299 fi 1300 done 1301 fi 1302 1303 if test "x$capath" = "xno"; then 1304 capath_warning="" 1305 fi 1306 1307 if test "x$ca" != "xno"; then 1308 CURL_CA_BUNDLE="$ca" 1309 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle]) 1310 AC_SUBST(CURL_CA_BUNDLE) 1311 AC_MSG_RESULT([$ca]) 1312 fi 1313 if test "x$capath" != "xno"; then 1314 CURL_CA_PATH="\"$capath\"" 1315 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path]) 1316 AC_MSG_RESULT([$capath (capath)]) 1317 fi 1318 if test "x$ca" = "xno" && test "x$capath" = "xno"; then 1319 AC_MSG_RESULT([no]) 1320 fi 1321 1322 AC_MSG_CHECKING([whether to use built-in CA store of SSL library]) 1323 AC_ARG_WITH(ca-fallback, 1324AS_HELP_STRING([--with-ca-fallback], [Use the built-in CA store of the SSL library]) 1325AS_HELP_STRING([--without-ca-fallback], [Don't use the built-in CA store of the SSL library]), 1326 [ 1327 if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then 1328 AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter]) 1329 fi 1330 ], 1331 [ with_ca_fallback="no"]) 1332 AC_MSG_RESULT([$with_ca_fallback]) 1333 if test "x$with_ca_fallback" = "xyes"; then 1334 if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then 1335 AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS]) 1336 fi 1337 AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built-in CA store of SSL library]) 1338 fi 1339]) 1340 1341 1342dnl CURL_CHECK_CA_EMBED 1343dnl ------------------------------------------------- 1344dnl Check if a ca-bundle should be embedded 1345 1346AC_DEFUN([CURL_CHECK_CA_EMBED], [ 1347 1348 AC_MSG_CHECKING([CA cert bundle path to embed in the curl tool]) 1349 1350 AC_ARG_WITH(ca-embed, 1351AS_HELP_STRING([--with-ca-embed=FILE], 1352 [Absolute path to a file containing CA certificates to embed in the curl tool (example: /etc/ca-bundle.crt)]) 1353AS_HELP_STRING([--without-ca-embed], [Don't embed a default CA bundle in the curl tool]), 1354 [ 1355 want_ca_embed="$withval" 1356 if test "x$want_ca_embed" = "xyes"; then 1357 AC_MSG_ERROR([--with-ca-embed=FILE requires a path to the CA bundle]) 1358 fi 1359 ], 1360 [ want_ca_embed="unset" ]) 1361 1362 CURL_CA_EMBED='' 1363 if test "x$want_ca_embed" != "xno" -a "x$want_ca_embed" != "xunset" -a -f "$want_ca_embed"; then 1364 CURL_CA_EMBED="$want_ca_embed" 1365 AC_SUBST(CURL_CA_EMBED) 1366 AC_MSG_RESULT([$want_ca_embed]) 1367 else 1368 AC_MSG_RESULT([no]) 1369 fi 1370]) 1371 1372dnl CURL_CHECK_WIN32_LARGEFILE 1373dnl ------------------------------------------------- 1374dnl Check if curl's Win32 large file will be used 1375 1376AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [ 1377 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl 1378 AC_MSG_CHECKING([whether build target supports Win32 file API]) 1379 curl_win32_file_api="no" 1380 if test "$curl_cv_native_windows" = "yes"; then 1381 if test x"$enable_largefile" != "xno"; then 1382 AC_COMPILE_IFELSE([ 1383 AC_LANG_PROGRAM([[ 1384 ]],[[ 1385 #if !defined(_WIN32_WCE) && (defined(__MINGW32__) || defined(_MSC_VER)) 1386 int dummy=1; 1387 #else 1388 #error Win32 large file API not supported. 1389 #endif 1390 ]]) 1391 ],[ 1392 curl_win32_file_api="win32_large_files" 1393 ]) 1394 fi 1395 if test "$curl_win32_file_api" = "no"; then 1396 AC_COMPILE_IFELSE([ 1397 AC_LANG_PROGRAM([[ 1398 ]],[[ 1399 #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER) 1400 int dummy=1; 1401 #else 1402 #error Win32 small file API not supported. 1403 #endif 1404 ]]) 1405 ],[ 1406 curl_win32_file_api="win32_small_files" 1407 ]) 1408 fi 1409 fi 1410 case "$curl_win32_file_api" in 1411 win32_large_files) 1412 AC_MSG_RESULT([yes (large file enabled)]) 1413 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1, 1414 [Define to 1 if you are building a Windows target with large file support.]) 1415 AC_SUBST(USE_WIN32_LARGE_FILES, [1]) 1416 ;; 1417 win32_small_files) 1418 AC_MSG_RESULT([yes (large file disabled)]) 1419 AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1, 1420 [Define to 1 if you are building a Windows target without large file support.]) 1421 AC_SUBST(USE_WIN32_SMALL_FILES, [1]) 1422 ;; 1423 *) 1424 AC_MSG_RESULT([no]) 1425 ;; 1426 esac 1427]) 1428 1429dnl CURL_CHECK_WIN32_CRYPTO 1430dnl ------------------------------------------------- 1431dnl Check if curl's Win32 crypto lib can be used 1432 1433AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [ 1434 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl 1435 AC_MSG_CHECKING([whether build target supports Win32 crypto API]) 1436 curl_win32_crypto_api="no" 1437 if test "$curl_cv_native_windows" = "yes"; then 1438 AC_COMPILE_IFELSE([ 1439 AC_LANG_PROGRAM([[ 1440 #undef inline 1441 #ifndef WIN32_LEAN_AND_MEAN 1442 #define WIN32_LEAN_AND_MEAN 1443 #endif 1444 #include <windows.h> 1445 #include <wincrypt.h> 1446 ]],[[ 1447 HCRYPTPROV hCryptProv; 1448 if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 1449 CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { 1450 CryptReleaseContext(hCryptProv, 0); 1451 } 1452 ]]) 1453 ],[ 1454 curl_win32_crypto_api="yes" 1455 ]) 1456 fi 1457 case "$curl_win32_crypto_api" in 1458 yes) 1459 AC_MSG_RESULT([yes]) 1460 AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1, 1461 [Define to 1 if you are building a Windows target with crypto API support.]) 1462 AC_SUBST(USE_WIN32_CRYPTO, [1]) 1463 ;; 1464 *) 1465 AC_MSG_RESULT([no]) 1466 ;; 1467 esac 1468]) 1469 1470dnl CURL_EXPORT_PCDIR ($pcdir) 1471dnl ------------------------ 1472dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export 1473dnl 1474dnl we need this macro since pkg-config distinguishes among empty and unset 1475dnl variable while checking PKG_CONFIG_LIBDIR 1476dnl 1477 1478AC_DEFUN([CURL_EXPORT_PCDIR], [ 1479 if test -n "$1"; then 1480 PKG_CONFIG_LIBDIR="$1" 1481 export PKG_CONFIG_LIBDIR 1482 fi 1483]) 1484 1485dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir]) 1486dnl ------------------------ 1487dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the 1488dnl path to it, or 'no' if not found/present. 1489dnl 1490dnl If pkg-config is present, check that it has info about the $module or 1491dnl return "no" anyway! 1492dnl 1493dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir. 1494dnl 1495 1496AC_DEFUN([CURL_CHECK_PKGCONFIG], [ 1497 if test -n "$PKG_CONFIG"; then 1498 PKGCONFIG="$PKG_CONFIG" 1499 else 1500 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no], 1501 [$PATH:/usr/bin:/usr/local/bin]) 1502 fi 1503 1504 if test "x$PKGCONFIG" != "xno"; then 1505 AC_MSG_CHECKING([for $1 options with pkg-config]) 1506 dnl ask pkg-config about $1 1507 itexists=`CURL_EXPORT_PCDIR([$2]) dnl 1508 $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1` 1509 1510 if test -z "$itexists"; then 1511 dnl pkg-config does not have info about the given module! set the 1512 dnl variable to 'no' 1513 PKGCONFIG="no" 1514 AC_MSG_RESULT([no]) 1515 else 1516 AC_MSG_RESULT([found]) 1517 fi 1518 fi 1519]) 1520 1521 1522dnl CURL_PREPARE_CONFIGUREHELP_PM 1523dnl ------------------------------------------------- 1524dnl Prepare test harness configurehelp.pm module, defining and 1525dnl initializing some perl variables with values which are known 1526dnl when the configure script runs. For portability reasons, test 1527dnl harness needs information on how to run the C preprocessor. 1528 1529AC_DEFUN([CURL_PREPARE_CONFIGUREHELP_PM], [ 1530 AC_REQUIRE([AC_PROG_CPP])dnl 1531 tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null` 1532 if test -z "$tmp_cpp"; then 1533 tmp_cpp='cpp' 1534 fi 1535 AC_SUBST(CURL_CPP, $tmp_cpp) 1536]) 1537 1538 1539dnl CURL_PREPARE_BUILDINFO 1540dnl ------------------------------------------------- 1541dnl Save build info for test runner to pick up and log 1542 1543AC_DEFUN([CURL_PREPARE_BUILDINFO], [ 1544 curl_pflags="" 1545 case $host in 1546 *-apple-*) curl_pflags="${curl_pflags} APPLE";; 1547 esac 1548 if test "$curl_cv_native_windows" = 'yes'; then 1549 curl_pflags="${curl_pflags} WIN32" 1550 else 1551 case $host in 1552 *-*-*bsd*|*-*-aix*|*-*-hpux*|*-*-interix*|*-*-irix*|*-*-linux*|*-*-solaris*|*-*-sunos*|*-apple-*|*-*-cygwin*|*-*-msys*) 1553 curl_pflags="${curl_pflags} UNIX";; 1554 esac 1555 case $host in 1556 *-*-*bsd*) 1557 curl_pflags="${curl_pflags} BSD";; 1558 esac 1559 fi 1560 if test "$curl_cv_cygwin" = 'yes'; then 1561 curl_pflags="${curl_pflags} CYGWIN" 1562 fi 1563 case $host_os in 1564 msys*) curl_pflags="${curl_pflags} MSYS";; 1565 esac 1566 if test "x$compiler_id" = 'xGNU_C'; then 1567 curl_pflags="${curl_pflags} GCC" 1568 fi 1569 case $host_os in 1570 mingw*) curl_pflags="${curl_pflags} MINGW";; 1571 esac 1572 if test "x$cross_compiling" = 'xyes'; then 1573 curl_pflags="${curl_pflags} CROSS" 1574 fi 1575 squeeze curl_pflags 1576 curl_buildinfo=" 1577buildinfo.configure.tool: configure 1578buildinfo.configure.args: $ac_configure_args 1579buildinfo.host: $build 1580buildinfo.host.cpu: $build_cpu 1581buildinfo.host.os: $build_os 1582buildinfo.target: $host 1583buildinfo.target.cpu: $host_cpu 1584buildinfo.target.os: $host_os 1585buildinfo.target.flags: $curl_pflags 1586buildinfo.compiler: $compiler_id 1587buildinfo.compiler.version: $compiler_ver 1588buildinfo.sysroot: $lt_sysroot" 1589]) 1590 1591 1592dnl CURL_CPP_P 1593dnl 1594dnl Check if $cpp -P should be used for extract define values due to gcc 5 1595dnl splitting up strings and defines between line outputs. gcc by default 1596dnl (without -P) will show TEST EINVAL TEST as 1597dnl 1598dnl # 13 "conftest.c" 1599dnl TEST 1600dnl # 13 "conftest.c" 3 4 1601dnl 22 1602dnl # 13 "conftest.c" 1603dnl TEST 1604 1605AC_DEFUN([CURL_CPP_P], [ 1606 AC_MSG_CHECKING([if cpp -P is needed]) 1607 AC_EGREP_CPP([TEST.*TEST], [ 1608 #include <errno.h> 1609TEST EINVAL TEST 1610 ], [cpp=no], [cpp=yes]) 1611 AC_MSG_RESULT([$cpp]) 1612 1613 dnl we need cpp -P so check if it works then 1614 if test "x$cpp" = "xyes"; then 1615 AC_MSG_CHECKING([if cpp -P works]) 1616 OLDCPPFLAGS=$CPPFLAGS 1617 CPPFLAGS="$CPPFLAGS -P" 1618 AC_EGREP_CPP([TEST.*TEST], [ 1619 #include <errno.h> 1620TEST EINVAL TEST 1621 ], [cpp_p=yes], [cpp_p=no]) 1622 AC_MSG_RESULT([$cpp_p]) 1623 1624 if test "x$cpp_p" = "xno"; then 1625 AC_MSG_WARN([failed to figure out cpp -P alternative]) 1626 # without -P 1627 CPPPFLAG="" 1628 else 1629 # with -P 1630 CPPPFLAG="-P" 1631 fi 1632 dnl restore CPPFLAGS 1633 CPPFLAGS=$OLDCPPFLAGS 1634 else 1635 # without -P 1636 CPPPFLAG="" 1637 fi 1638]) 1639 1640 1641dnl CURL_DARWIN_CFLAGS 1642dnl 1643dnl Set -Werror=partial-availability to detect possible breaking code 1644dnl with very low deployment targets. 1645dnl 1646 1647AC_DEFUN([CURL_DARWIN_CFLAGS], [ 1648 1649 tst_cflags="no" 1650 case $host in 1651 *-apple-*) 1652 tst_cflags="yes" 1653 ;; 1654 esac 1655 1656 AC_MSG_CHECKING([for good-to-use Darwin CFLAGS]) 1657 AC_MSG_RESULT([$tst_cflags]); 1658 1659 if test "$tst_cflags" = "yes"; then 1660 old_CFLAGS=$CFLAGS 1661 CFLAGS="$CFLAGS -Werror=partial-availability" 1662 AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability]) 1663 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], 1664 [AC_MSG_RESULT([yes])], 1665 [AC_MSG_RESULT([no]) 1666 CFLAGS=$old_CFLAGS]) 1667 fi 1668 1669]) 1670 1671 1672dnl CURL_SUPPORTS_BUILTIN_AVAILABLE 1673dnl 1674dnl Check to see if the compiler supports __builtin_available. This built-in 1675dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at 1676dnl the time this macro was written, the function was not yet documented. Its 1677dnl purpose is to return true if the code is running under a certain OS version 1678dnl or later. 1679 1680AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [ 1681 AC_MSG_CHECKING([to see if the compiler supports __builtin_available()]) 1682 AC_COMPILE_IFELSE([ 1683 AC_LANG_PROGRAM([[ 1684 ]],[[ 1685 if(__builtin_available(macOS 10.12, iOS 5.0, *)) {} 1686 ]]) 1687 ],[ 1688 AC_MSG_RESULT([yes]) 1689 AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1, 1690 [Define to 1 if you have the __builtin_available function.]) 1691 ],[ 1692 AC_MSG_RESULT([no]) 1693 ]) 1694]) 1695