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 AC_MSG_RESULT([$curl_cv_ldap_LIBS]) 569 ;; 570 esac 571 # 572]) 573 574 575dnl TYPE_SOCKADDR_STORAGE 576dnl ------------------------------------------------- 577dnl Check for struct sockaddr_storage. Most IPv6-enabled 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 587 #ifdef _WIN32 588 #ifndef WIN32_LEAN_AND_MEAN 589 #define WIN32_LEAN_AND_MEAN 590 #endif 591 #include <winsock2.h> 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 609dnl CURL_CHECK_FUNC_RECV 610dnl ------------------------------------------------- 611dnl Test if the socket recv() function is available, 612 613AC_DEFUN([CURL_CHECK_FUNC_RECV], [ 614 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl 615 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl 616 AC_CHECK_HEADERS(sys/types.h sys/socket.h) 617 # 618 AC_MSG_CHECKING([for recv]) 619 AC_LINK_IFELSE([ 620 AC_LANG_PROGRAM([[ 621 #undef inline 622 #ifdef _WIN32 623 #ifndef WIN32_LEAN_AND_MEAN 624 #define WIN32_LEAN_AND_MEAN 625 #endif 626 #include <winsock2.h> 627 #else 628 $curl_includes_bsdsocket 629 #ifdef HAVE_SYS_TYPES_H 630 #include <sys/types.h> 631 #endif 632 #ifdef HAVE_SYS_SOCKET_H 633 #include <sys/socket.h> 634 #endif 635 #endif 636 ]],[[ 637 recv(0, 0, 0, 0); 638 ]]) 639 ],[ 640 AC_MSG_RESULT([yes]) 641 curl_cv_recv="yes" 642 ],[ 643 AC_MSG_RESULT([no]) 644 curl_cv_recv="no" 645 ]) 646 # 647 if test "$curl_cv_recv" = "yes"; then 648 AC_DEFINE_UNQUOTED(HAVE_RECV, 1, 649 [Define to 1 if you have the recv function.]) 650 curl_cv_func_recv="yes" 651 else 652 AC_MSG_ERROR([Unable to link function recv]) 653 fi 654]) 655 656 657dnl CURL_CHECK_FUNC_SEND 658dnl ------------------------------------------------- 659dnl Test if the socket send() function is available, 660 661AC_DEFUN([CURL_CHECK_FUNC_SEND], [ 662 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl 663 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl 664 AC_CHECK_HEADERS(sys/types.h sys/socket.h) 665 # 666 AC_MSG_CHECKING([for send]) 667 AC_LINK_IFELSE([ 668 AC_LANG_PROGRAM([[ 669 #undef inline 670 #ifdef _WIN32 671 #ifndef WIN32_LEAN_AND_MEAN 672 #define WIN32_LEAN_AND_MEAN 673 #endif 674 #include <winsock2.h> 675 #else 676 $curl_includes_bsdsocket 677 #ifdef HAVE_SYS_TYPES_H 678 #include <sys/types.h> 679 #endif 680 #ifdef HAVE_SYS_SOCKET_H 681 #include <sys/socket.h> 682 #endif 683 #endif 684 ]],[[ 685 send(0, 0, 0, 0); 686 ]]) 687 ],[ 688 AC_MSG_RESULT([yes]) 689 curl_cv_send="yes" 690 ],[ 691 AC_MSG_RESULT([no]) 692 curl_cv_send="no" 693 ]) 694 # 695 if test "$curl_cv_send" = "yes"; then 696 AC_DEFINE_UNQUOTED(HAVE_SEND, 1, 697 [Define to 1 if you have the send function.]) 698 curl_cv_func_send="yes" 699 else 700 AC_MSG_ERROR([Unable to link function send]) 701 fi 702]) 703 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) 710 AC_CACHE_CHECK([for MSG_NOSIGNAL], [curl_cv_msg_nosignal], [ 711 AC_COMPILE_IFELSE([ 712 AC_LANG_PROGRAM([[ 713 #undef inline 714 #ifdef _WIN32 715 #ifndef WIN32_LEAN_AND_MEAN 716 #define WIN32_LEAN_AND_MEAN 717 #endif 718 #include <winsock2.h> 719 #else 720 #ifdef HAVE_SYS_TYPES_H 721 #include <sys/types.h> 722 #endif 723 #ifdef HAVE_SYS_SOCKET_H 724 #include <sys/socket.h> 725 #endif 726 #endif 727 ]],[[ 728 int flag=MSG_NOSIGNAL; 729 ]]) 730 ],[ 731 curl_cv_msg_nosignal="yes" 732 ],[ 733 curl_cv_msg_nosignal="no" 734 ]) 735 ]) 736 case "$curl_cv_msg_nosignal" in 737 yes) 738 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1, 739 [Define to 1 if you have the MSG_NOSIGNAL flag.]) 740 ;; 741 esac 742]) 743 744 745dnl CURL_CHECK_STRUCT_TIMEVAL 746dnl ------------------------------------------------- 747dnl Check for timeval struct 748 749AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [ 750 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl 751 AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h) 752 AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [ 753 AC_COMPILE_IFELSE([ 754 AC_LANG_PROGRAM([[ 755 #undef inline 756 #ifdef _WIN32 757 #ifndef WIN32_LEAN_AND_MEAN 758 #define WIN32_LEAN_AND_MEAN 759 #endif 760 #include <winsock2.h> 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> 767 #endif 768 #include <time.h> 769 #ifdef HAVE_SYS_SOCKET_H 770 #include <sys/socket.h> 771 #endif 772 ]],[[ 773 struct timeval ts; 774 ts.tv_sec = 0; 775 ts.tv_usec = 0; 776 ]]) 777 ],[ 778 curl_cv_struct_timeval="yes" 779 ],[ 780 curl_cv_struct_timeval="no" 781 ]) 782 ]) 783 case "$curl_cv_struct_timeval" in 784 yes) 785 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1, 786 [Define to 1 if you have the timeval struct.]) 787 ;; 788 esac 789]) 790 791 792dnl TYPE_IN_ADDR_T 793dnl ------------------------------------------------- 794dnl Check for in_addr_t: it is used to receive the return code of inet_addr() 795dnl and a few other things. 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([[ 807 #undef inline 808 #ifdef _WIN32 809 #ifndef WIN32_LEAN_AND_MEAN 810 #define WIN32_LEAN_AND_MEAN 811 #endif 812 #include <winsock2.h> 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 823 #ifdef HAVE_ARPA_INET_H 824 #include <arpa/inet.h> 825 #endif 826 #endif 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 ],[ 846 #undef inline 847 #ifdef _WIN32 848 #ifndef WIN32_LEAN_AND_MEAN 849 #define WIN32_LEAN_AND_MEAN 850 #endif 851 #include <winsock2.h> 852 #else 853 #ifdef HAVE_SYS_TYPES_H 854 #include <sys/types.h> 855 #endif 856 #ifdef HAVE_SYS_SOCKET_H 857 #include <sys/socket.h> 858 #endif 859 #ifdef HAVE_NETINET_IN_H 860 #include <netinet/in.h> 861 #endif 862 #ifdef HAVE_ARPA_INET_H 863 #include <arpa/inet.h> 864 #endif 865 #endif 866 ]) 867]) 868 869 870dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC 871dnl ------------------------------------------------- 872dnl Check if monotonic clock_gettime is available. 873 874AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [ 875 AC_CHECK_HEADERS(sys/types.h sys/time.h) 876 AC_MSG_CHECKING([for monotonic clock_gettime]) 877 # 878 if test "x$dontwant_rt" = "xno" ; then 879 AC_COMPILE_IFELSE([ 880 AC_LANG_PROGRAM([[ 881 #ifdef HAVE_SYS_TYPES_H 882 #include <sys/types.h> 883 #endif 884 #ifdef HAVE_SYS_TIME_H 885 #include <sys/time.h> 886 #endif 887 #include <time.h> 888 ]],[[ 889 struct timespec ts; 890 (void)clock_gettime(CLOCK_MONOTONIC, &ts); 891 ]]) 892 ],[ 893 AC_MSG_RESULT([yes]) 894 curl_func_clock_gettime="yes" 895 ],[ 896 AC_MSG_RESULT([no]) 897 curl_func_clock_gettime="no" 898 ]) 899 fi 900 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed 901 dnl until library linking and run-time checks for clock_gettime succeed. 902]) 903 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 936 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 944 # 945 if test "$curl_func_clock_gettime" = "yes"; then 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 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([[ 961 #ifdef HAVE_SYS_TYPES_H 962 #include <sys/types.h> 963 #endif 964 #ifdef HAVE_SYS_TIME_H 965 #include <sys/time.h> 966 #endif 967 #include <time.h> 968 ]],[[ 969 struct timespec ts; 970 (void)clock_gettime(CLOCK_MONOTONIC, &ts); 971 ]]) 972 ],[ 973 curl_cv_gclk_LIBS="$x_xlibs" 974 ]) 975 fi 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]) 984 curl_func_clock_gettime="no" 985 ;; 986 X-) 987 AC_MSG_RESULT([no additional lib required]) 988 curl_func_clock_gettime="yes" 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]) 997 curl_func_clock_gettime="yes" 998 ;; 999 esac 1000 # 1001 dnl only do runtime verification when not cross-compiling 1002 if test "x$cross_compiling" != "xyes" && 1003 test "$curl_func_clock_gettime" = "yes"; then 1004 AC_MSG_CHECKING([if monotonic clock_gettime works]) 1005 CURL_RUN_IFELSE([ 1006 AC_LANG_PROGRAM([[ 1007 #include <stdlib.h> 1008 #ifdef HAVE_SYS_TYPES_H 1009 #include <sys/types.h> 1010 #endif 1011 #ifdef HAVE_SYS_TIME_H 1012 #include <sys/time.h> 1013 #endif 1014 #include <time.h> 1015 ]],[[ 1016 struct timespec ts; 1017 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts)) 1018 exit(0); 1019 else 1020 exit(1); 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]) 1027 curl_func_clock_gettime="no" 1028 LIBS="$curl_cv_save_LIBS" 1029 ]) 1030 fi 1031 # 1032 case "$curl_func_clock_gettime" in 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 1040 # 1041]) 1042 1043 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], [ 1050 AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl 1051 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl 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([[ 1060 $curl_includes_winsock2 1061 $curl_includes_bsdsocket 1062 #if !defined(_WIN32) && !defined(HAVE_PROTO_BSDSOCKET_H) 1063 int connect(int, void*, int); 1064 #endif 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 1092dnl CURL_CHECK_FUNC_SELECT 1093dnl ------------------------------------------------- 1094dnl Test if the socket select() function is available. 1095 1096AC_DEFUN([CURL_CHECK_FUNC_SELECT], [ 1097 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl 1098 AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl 1099 AC_CHECK_HEADERS(sys/select.h sys/socket.h) 1100 # 1101 AC_MSG_CHECKING([for select]) 1102 AC_LINK_IFELSE([ 1103 AC_LANG_PROGRAM([[ 1104 #undef inline 1105 #ifdef _WIN32 1106 #ifndef WIN32_LEAN_AND_MEAN 1107 #define WIN32_LEAN_AND_MEAN 1108 #endif 1109 #include <winsock2.h> 1110 #endif 1111 #ifdef HAVE_SYS_TYPES_H 1112 #include <sys/types.h> 1113 #endif 1114 #ifdef HAVE_SYS_TIME_H 1115 #include <sys/time.h> 1116 #endif 1117 #include <time.h> 1118 #ifndef _WIN32 1119 #ifdef HAVE_SYS_SELECT_H 1120 #include <sys/select.h> 1121 #elif defined(HAVE_UNISTD_H) 1122 #include <unistd.h> 1123 #endif 1124 #ifdef HAVE_SYS_SOCKET_H 1125 #include <sys/socket.h> 1126 #endif 1127 $curl_includes_bsdsocket 1128 #endif 1129 ]],[[ 1130 select(0, 0, 0, 0, 0); 1131 ]]) 1132 ],[ 1133 AC_MSG_RESULT([yes]) 1134 curl_cv_select="yes" 1135 ],[ 1136 AC_MSG_RESULT([no]) 1137 curl_cv_select="no" 1138 ]) 1139 # 1140 if test "$curl_cv_select" = "yes"; then 1141 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1, 1142 [Define to 1 if you have the select function.]) 1143 curl_cv_func_select="yes" 1144 fi 1145]) 1146 1147 1148dnl CURL_VERIFY_RUNTIMELIBS 1149dnl ------------------------------------------------- 1150dnl Verify that the shared libs found so far can be used when running 1151dnl programs, since otherwise the situation will create odd configure errors 1152dnl that are misleading people. 1153dnl 1154dnl Make sure this test is run BEFORE the first test in the script that 1155dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF 1156dnl macro. It must also run AFTER all lib-checking macros are complete. 1157 1158AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [ 1159 1160 dnl this test is of course not sensible if we are cross-compiling! 1161 if test "x$cross_compiling" != xyes; then 1162 1163 dnl just run a program to verify that the libs checked for previous to this 1164 dnl point also is available run-time! 1165 AC_MSG_CHECKING([run-time libs availability]) 1166 CURL_RUN_IFELSE([ 1167 int main() 1168 { 1169 return 0; 1170 } 1171 ], 1172 AC_MSG_RESULT([fine]), 1173 AC_MSG_RESULT([failed]) 1174 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS]) 1175 ) 1176 1177 dnl if this test fails, configure has already stopped 1178 fi 1179]) 1180 1181 1182dnl CURL_CHECK_CA_BUNDLE 1183dnl ------------------------------------------------- 1184dnl Check if a default ca-bundle should be used 1185dnl 1186dnl regarding the paths this will scan: 1187dnl /etc/ssl/certs/ca-certificates.crt Debian systems 1188dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva 1189dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat 1190dnl /usr/local/share/certs/ca-root-nss.crt MidnightBSD 1191dnl /etc/ssl/cert.pem OpenBSD, MidnightBSD (symlink) 1192dnl /etc/ssl/certs (CA path) SUSE, FreeBSD 1193 1194AC_DEFUN([CURL_CHECK_CA_BUNDLE], [ 1195 1196 AC_MSG_CHECKING([default CA cert bundle/path]) 1197 1198 AC_ARG_WITH(ca-bundle, 1199AS_HELP_STRING([--with-ca-bundle=FILE], 1200 [Absolute path to a file containing CA certificates (example: /etc/ca-bundle.crt)]) 1201AS_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]), 1202 [ 1203 want_ca="$withval" 1204 if test "x$want_ca" = "xyes"; then 1205 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle]) 1206 fi 1207 ], 1208 [ want_ca="unset" ]) 1209 AC_ARG_WITH(ca-path, 1210AS_HELP_STRING([--with-ca-path=DIRECTORY], 1211 [Absolute path to a directory containing CA certificates stored individually, with \ 1212their filenames in a hash format. This option can be used with the OpenSSL, \ 1213GnuTLS, mbedTLS and wolfSSL backends. Refer to OpenSSL c_rehash for details. \ 1214(example: /etc/certificates)]) 1215AS_HELP_STRING([--without-ca-path], [Don't use a default CA path]), 1216 [ 1217 want_capath="$withval" 1218 if test "x$want_capath" = "xyes"; then 1219 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory]) 1220 fi 1221 ], 1222 [ want_capath="unset"]) 1223 1224 ca_warning=" (warning: certs not found)" 1225 capath_warning=" (warning: certs not found)" 1226 check_capath="" 1227 1228 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \ 1229 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then 1230 dnl both given 1231 ca="$want_ca" 1232 capath="$want_capath" 1233 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then 1234 dnl --with-ca-bundle given 1235 ca="$want_ca" 1236 capath="no" 1237 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then 1238 dnl --with-ca-path given 1239 capath="$want_capath" 1240 ca="no" 1241 else 1242 dnl First try auto-detecting a CA bundle, then a CA path. 1243 dnl Both auto-detections can be skipped by --without-ca-* 1244 ca="no" 1245 capath="no" 1246 if test "x$cross_compiling" != "xyes" -a \ 1247 "x$curl_cv_native_windows" != "xyes"; then 1248 dnl NOT cross-compiling and... 1249 dnl neither of the --with-ca-* options are provided 1250 if test "x$want_ca" = "xunset"; then 1251 dnl the path we previously would have installed the curl CA bundle 1252 dnl to, and thus we now check for an already existing cert in that 1253 dnl place in case we find no other 1254 if test "x$prefix" != xNONE; then 1255 cac="${prefix}/share/curl/curl-ca-bundle.crt" 1256 else 1257 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt" 1258 fi 1259 1260 for a in /etc/ssl/certs/ca-certificates.crt \ 1261 /etc/pki/tls/certs/ca-bundle.crt \ 1262 /usr/share/ssl/certs/ca-bundle.crt \ 1263 /usr/local/share/certs/ca-root-nss.crt \ 1264 /etc/ssl/cert.pem \ 1265 "$cac"; do 1266 if test -f "$a"; then 1267 ca="$a" 1268 break 1269 fi 1270 done 1271 fi 1272 AC_MSG_NOTICE([want $want_capath ca $ca]) 1273 if test "x$want_capath" = "xunset"; then 1274 check_capath="/etc/ssl/certs" 1275 fi 1276 else 1277 dnl no option given and cross-compiling 1278 AC_MSG_WARN([skipped the ca-cert path detection when cross-compiling]) 1279 fi 1280 fi 1281 1282 if test "x$ca" = "xno" || test -f "$ca"; then 1283 ca_warning="" 1284 fi 1285 1286 if test "x$capath" != "xno"; then 1287 check_capath="$capath" 1288 fi 1289 1290 if test ! -z "$check_capath"; then 1291 for a in "$check_capath"; do 1292 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 1293 if test "x$capath" = "xno"; then 1294 capath="$a" 1295 fi 1296 capath_warning="" 1297 break 1298 fi 1299 done 1300 fi 1301 1302 if test "x$capath" = "xno"; then 1303 capath_warning="" 1304 fi 1305 1306 if test "x$ca" != "xno"; then 1307 CURL_CA_BUNDLE="$ca" 1308 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle]) 1309 AC_SUBST(CURL_CA_BUNDLE) 1310 AC_MSG_RESULT([$ca]) 1311 fi 1312 if test "x$capath" != "xno"; then 1313 CURL_CA_PATH="\"$capath\"" 1314 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path]) 1315 AC_MSG_RESULT([$capath (capath)]) 1316 fi 1317 if test "x$ca" = "xno" && test "x$capath" = "xno"; then 1318 AC_MSG_RESULT([no]) 1319 fi 1320 1321 AC_MSG_CHECKING([whether to use built-in CA store of SSL library]) 1322 AC_ARG_WITH(ca-fallback, 1323AS_HELP_STRING([--with-ca-fallback], [Use the built-in CA store of the SSL library]) 1324AS_HELP_STRING([--without-ca-fallback], [Don't use the built-in CA store of the SSL library]), 1325 [ 1326 if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then 1327 AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter]) 1328 fi 1329 ], 1330 [ with_ca_fallback="no"]) 1331 AC_MSG_RESULT([$with_ca_fallback]) 1332 if test "x$with_ca_fallback" = "xyes"; then 1333 if test "x$OPENSSL_ENABLED" != "x1" -a "x$GNUTLS_ENABLED" != "x1"; then 1334 AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL or GnuTLS]) 1335 fi 1336 AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use built-in CA store of SSL library]) 1337 fi 1338]) 1339 1340 1341dnl CURL_CHECK_CA_EMBED 1342dnl ------------------------------------------------- 1343dnl Check if a ca-bundle should be embedded 1344 1345AC_DEFUN([CURL_CHECK_CA_EMBED], [ 1346 1347 AC_MSG_CHECKING([CA cert bundle path to embed in the curl tool]) 1348 1349 AC_ARG_WITH(ca-embed, 1350AS_HELP_STRING([--with-ca-embed=FILE], 1351 [Absolute path to a file containing CA certificates to embed in the curl tool (example: /etc/ca-bundle.crt)]) 1352AS_HELP_STRING([--without-ca-embed], [Don't embed a default CA bundle in the curl tool]), 1353 [ 1354 want_ca_embed="$withval" 1355 if test "x$want_ca_embed" = "xyes"; then 1356 AC_MSG_ERROR([--with-ca-embed=FILE requires a path to the CA bundle]) 1357 fi 1358 ], 1359 [ want_ca_embed="unset" ]) 1360 1361 CURL_CA_EMBED='' 1362 if test "x$want_ca_embed" != "xno" -a "x$want_ca_embed" != "xunset" -a -f "$want_ca_embed"; then 1363 CURL_CA_EMBED="$want_ca_embed" 1364 AC_SUBST(CURL_CA_EMBED) 1365 AC_MSG_RESULT([$want_ca_embed]) 1366 else 1367 AC_MSG_RESULT([no]) 1368 fi 1369]) 1370 1371dnl CURL_CHECK_WIN32_LARGEFILE 1372dnl ------------------------------------------------- 1373dnl Check if curl's Win32 large file will be used 1374 1375AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [ 1376 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl 1377 AC_MSG_CHECKING([whether build target supports Win32 file API]) 1378 curl_win32_file_api="no" 1379 if test "$curl_cv_native_windows" = "yes"; then 1380 if test x"$enable_largefile" != "xno"; then 1381 AC_COMPILE_IFELSE([ 1382 AC_LANG_PROGRAM([[ 1383 ]],[[ 1384 #if !defined(_WIN32_WCE) && (defined(__MINGW32__) || defined(_MSC_VER)) 1385 int dummy=1; 1386 #else 1387 #error Win32 large file API not supported. 1388 #endif 1389 ]]) 1390 ],[ 1391 curl_win32_file_api="win32_large_files" 1392 ]) 1393 fi 1394 if test "$curl_win32_file_api" = "no"; then 1395 AC_COMPILE_IFELSE([ 1396 AC_LANG_PROGRAM([[ 1397 ]],[[ 1398 #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER) 1399 int dummy=1; 1400 #else 1401 #error Win32 small file API not supported. 1402 #endif 1403 ]]) 1404 ],[ 1405 curl_win32_file_api="win32_small_files" 1406 ]) 1407 fi 1408 fi 1409 case "$curl_win32_file_api" in 1410 win32_large_files) 1411 AC_MSG_RESULT([yes (large file enabled)]) 1412 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1, 1413 [Define to 1 if you are building a Windows target with large file support.]) 1414 AC_SUBST(USE_WIN32_LARGE_FILES, [1]) 1415 ;; 1416 win32_small_files) 1417 AC_MSG_RESULT([yes (large file disabled)]) 1418 AC_DEFINE_UNQUOTED(USE_WIN32_SMALL_FILES, 1, 1419 [Define to 1 if you are building a Windows target without large file support.]) 1420 AC_SUBST(USE_WIN32_SMALL_FILES, [1]) 1421 ;; 1422 *) 1423 AC_MSG_RESULT([no]) 1424 ;; 1425 esac 1426]) 1427 1428dnl CURL_CHECK_WIN32_CRYPTO 1429dnl ------------------------------------------------- 1430dnl Check if curl's Win32 crypto lib can be used 1431 1432AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [ 1433 AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl 1434 AC_MSG_CHECKING([whether build target supports Win32 crypto API]) 1435 curl_win32_crypto_api="no" 1436 if test "$curl_cv_native_windows" = "yes"; then 1437 AC_COMPILE_IFELSE([ 1438 AC_LANG_PROGRAM([[ 1439 #undef inline 1440 #ifndef WIN32_LEAN_AND_MEAN 1441 #define WIN32_LEAN_AND_MEAN 1442 #endif 1443 #include <windows.h> 1444 #include <wincrypt.h> 1445 ]],[[ 1446 HCRYPTPROV hCryptProv; 1447 if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 1448 CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { 1449 CryptReleaseContext(hCryptProv, 0); 1450 } 1451 ]]) 1452 ],[ 1453 curl_win32_crypto_api="yes" 1454 ]) 1455 fi 1456 case "$curl_win32_crypto_api" in 1457 yes) 1458 AC_MSG_RESULT([yes]) 1459 AC_DEFINE_UNQUOTED(USE_WIN32_CRYPTO, 1, 1460 [Define to 1 if you are building a Windows target with crypto API support.]) 1461 AC_SUBST(USE_WIN32_CRYPTO, [1]) 1462 ;; 1463 *) 1464 AC_MSG_RESULT([no]) 1465 ;; 1466 esac 1467]) 1468 1469dnl CURL_EXPORT_PCDIR ($pcdir) 1470dnl ------------------------ 1471dnl if $pcdir is not empty, set PKG_CONFIG_LIBDIR to $pcdir and export 1472dnl 1473dnl we need this macro since pkg-config distinguishes among empty and unset 1474dnl variable while checking PKG_CONFIG_LIBDIR 1475dnl 1476 1477AC_DEFUN([CURL_EXPORT_PCDIR], [ 1478 if test -n "$1"; then 1479 PKG_CONFIG_LIBDIR="$1" 1480 export PKG_CONFIG_LIBDIR 1481 fi 1482]) 1483 1484dnl CURL_CHECK_PKGCONFIG ($module, [$pcdir]) 1485dnl ------------------------ 1486dnl search for the pkg-config tool. Set the PKGCONFIG variable to hold the 1487dnl path to it, or 'no' if not found/present. 1488dnl 1489dnl If pkg-config is present, check that it has info about the $module or 1490dnl return "no" anyway! 1491dnl 1492dnl Optionally PKG_CONFIG_LIBDIR may be given as $pcdir. 1493dnl 1494 1495AC_DEFUN([CURL_CHECK_PKGCONFIG], [ 1496 if test -n "$PKG_CONFIG"; then 1497 PKGCONFIG="$PKG_CONFIG" 1498 else 1499 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no], 1500 [$PATH:/usr/bin:/usr/local/bin]) 1501 fi 1502 1503 if test "x$PKGCONFIG" != "xno"; then 1504 AC_MSG_CHECKING([for $1 options with pkg-config]) 1505 dnl ask pkg-config about $1 1506 itexists=`CURL_EXPORT_PCDIR([$2]) dnl 1507 $PKGCONFIG --exists $1 >/dev/null 2>&1 && echo 1` 1508 1509 if test -z "$itexists"; then 1510 dnl pkg-config does not have info about the given module! set the 1511 dnl variable to 'no' 1512 PKGCONFIG="no" 1513 AC_MSG_RESULT([no]) 1514 else 1515 AC_MSG_RESULT([found]) 1516 fi 1517 fi 1518]) 1519 1520 1521dnl CURL_PREPARE_CONFIGUREHELP_PM 1522dnl ------------------------------------------------- 1523dnl Prepare test harness configurehelp.pm module, defining and 1524dnl initializing some perl variables with values which are known 1525dnl when the configure script runs. For portability reasons, test 1526dnl harness needs information on how to run the C preprocessor. 1527 1528AC_DEFUN([CURL_PREPARE_CONFIGUREHELP_PM], [ 1529 AC_REQUIRE([AC_PROG_CPP])dnl 1530 tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null` 1531 if test -z "$tmp_cpp"; then 1532 tmp_cpp='cpp' 1533 fi 1534 AC_SUBST(CURL_CPP, $tmp_cpp) 1535]) 1536 1537 1538dnl CURL_PREPARE_BUILDINFO 1539dnl ------------------------------------------------- 1540dnl Save build info for test runner to pick up and log 1541 1542AC_DEFUN([CURL_PREPARE_BUILDINFO], [ 1543 curl_pflags="" 1544 case $host in 1545 *-apple-*) curl_pflags="${curl_pflags} APPLE";; 1546 esac 1547 if test "$curl_cv_native_windows" = 'yes'; then 1548 curl_pflags="${curl_pflags} WIN32" 1549 else 1550 case $host in 1551 *-*-*bsd*|*-*-aix*|*-*-hpux*|*-*-interix*|*-*-irix*|*-*-linux*|*-*-solaris*|*-*-sunos*|*-apple-*|*-*-cygwin*|*-*-msys*) 1552 curl_pflags="${curl_pflags} UNIX";; 1553 esac 1554 fi 1555 case $host_os in 1556 cygwin*|msys*) curl_pflags="${curl_pflags} CYGWIN";; 1557 esac 1558 case $host_os in 1559 msys*) curl_pflags="${curl_pflags} MSYS";; 1560 esac 1561 if test "x$compiler_id" = 'xGNU_C'; then 1562 curl_pflags="${curl_pflags} GCC" 1563 fi 1564 case $host_os in 1565 mingw*) curl_pflags="${curl_pflags} MINGW";; 1566 esac 1567 if test "x$cross_compiling" = 'xyes'; then 1568 curl_pflags="${curl_pflags} CROSS" 1569 fi 1570 squeeze curl_pflags 1571 curl_buildinfo=" 1572buildinfo.configure.tool: configure 1573buildinfo.configure.args: $ac_configure_args 1574buildinfo.host: $build 1575buildinfo.host.cpu: $build_cpu 1576buildinfo.host.os: $build_os 1577buildinfo.target: $host 1578buildinfo.target.cpu: $host_cpu 1579buildinfo.target.os: $host_os 1580buildinfo.target.flags: $curl_pflags 1581buildinfo.compiler: $compiler_id 1582buildinfo.compiler.version: $compiler_ver 1583buildinfo.sysroot: $lt_sysroot" 1584]) 1585 1586 1587dnl CURL_CPP_P 1588dnl 1589dnl Check if $cpp -P should be used for extract define values due to gcc 5 1590dnl splitting up strings and defines between line outputs. gcc by default 1591dnl (without -P) will show TEST EINVAL TEST as 1592dnl 1593dnl # 13 "conftest.c" 1594dnl TEST 1595dnl # 13 "conftest.c" 3 4 1596dnl 22 1597dnl # 13 "conftest.c" 1598dnl TEST 1599 1600AC_DEFUN([CURL_CPP_P], [ 1601 AC_MSG_CHECKING([if cpp -P is needed]) 1602 AC_EGREP_CPP([TEST.*TEST], [ 1603 #include <errno.h> 1604TEST EINVAL TEST 1605 ], [cpp=no], [cpp=yes]) 1606 AC_MSG_RESULT([$cpp]) 1607 1608 dnl we need cpp -P so check if it works then 1609 if test "x$cpp" = "xyes"; then 1610 AC_MSG_CHECKING([if cpp -P works]) 1611 OLDCPPFLAGS=$CPPFLAGS 1612 CPPFLAGS="$CPPFLAGS -P" 1613 AC_EGREP_CPP([TEST.*TEST], [ 1614 #include <errno.h> 1615TEST EINVAL TEST 1616 ], [cpp_p=yes], [cpp_p=no]) 1617 AC_MSG_RESULT([$cpp_p]) 1618 1619 if test "x$cpp_p" = "xno"; then 1620 AC_MSG_WARN([failed to figure out cpp -P alternative]) 1621 # without -P 1622 CPPPFLAG="" 1623 else 1624 # with -P 1625 CPPPFLAG="-P" 1626 fi 1627 dnl restore CPPFLAGS 1628 CPPFLAGS=$OLDCPPFLAGS 1629 else 1630 # without -P 1631 CPPPFLAG="" 1632 fi 1633]) 1634 1635 1636dnl CURL_DARWIN_CFLAGS 1637dnl 1638dnl Set -Werror=partial-availability to detect possible breaking code 1639dnl with very low deployment targets. 1640dnl 1641 1642AC_DEFUN([CURL_DARWIN_CFLAGS], [ 1643 1644 tst_cflags="no" 1645 case $host in 1646 *-apple-*) 1647 tst_cflags="yes" 1648 ;; 1649 esac 1650 1651 AC_MSG_CHECKING([for good-to-use Darwin CFLAGS]) 1652 AC_MSG_RESULT([$tst_cflags]); 1653 1654 if test "$tst_cflags" = "yes"; then 1655 old_CFLAGS=$CFLAGS 1656 CFLAGS="$CFLAGS -Werror=partial-availability" 1657 AC_MSG_CHECKING([whether $CC accepts -Werror=partial-availability]) 1658 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], 1659 [AC_MSG_RESULT([yes])], 1660 [AC_MSG_RESULT([no]) 1661 CFLAGS=$old_CFLAGS]) 1662 fi 1663 1664]) 1665 1666 1667dnl CURL_SUPPORTS_BUILTIN_AVAILABLE 1668dnl 1669dnl Check to see if the compiler supports __builtin_available. This built-in 1670dnl compiler function first appeared in Apple LLVM 9.0.0. It's so new that, at 1671dnl the time this macro was written, the function was not yet documented. Its 1672dnl purpose is to return true if the code is running under a certain OS version 1673dnl or later. 1674 1675AC_DEFUN([CURL_SUPPORTS_BUILTIN_AVAILABLE], [ 1676 AC_MSG_CHECKING([to see if the compiler supports __builtin_available()]) 1677 AC_COMPILE_IFELSE([ 1678 AC_LANG_PROGRAM([[ 1679 ]],[[ 1680 if(__builtin_available(macOS 10.12, iOS 5.0, *)) {} 1681 ]]) 1682 ],[ 1683 AC_MSG_RESULT([yes]) 1684 AC_DEFINE_UNQUOTED(HAVE_BUILTIN_AVAILABLE, 1, 1685 [Define to 1 if you have the __builtin_available function.]) 1686 ],[ 1687 AC_MSG_RESULT([no]) 1688 ]) 1689]) 1690