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