1#*************************************************************************** 2# _ _ ____ _ 3# Project ___| | | | _ \| | 4# / __| | | | |_) | | 5# | (__| |_| | _ <| |___ 6# \___|\___/|_| \_\_____| 7# 8# Copyright (C) 1998 - 2021, 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#*************************************************************************** 22 23AC_DEFUN([CURL_WITH_RUSTLS], [ 24dnl ---------------------------------------------------- 25dnl check for rustls 26dnl ---------------------------------------------------- 27 28if test "x$OPT_RUSTLS" != xno; then 29 _cppflags=$CPPFLAGS 30 _ldflags=$LDFLAGS 31 ssl_msg= 32 33 if test X"$OPT_RUSTLS" != Xno; then 34 35 if test "$OPT_RUSTLS" = "yes"; then 36 OPT_RUSTLS="" 37 fi 38 39 if test -z "$OPT_RUSTLS" ; then 40 dnl check for lib first without setting any new path 41 42 AC_CHECK_LIB(crustls, rustls_client_session_read, 43 dnl libcrustls found, set the variable 44 [ 45 AC_DEFINE(USE_RUSTLS, 1, [if rustls is enabled]) 46 AC_SUBST(USE_RUSTLS, [1]) 47 RUSTLS_ENABLED=1 48 USE_RUSTLS="yes" 49 ssl_msg="rustls" 50 test rustls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes 51 ], [], -lpthread -ldl) 52 fi 53 54 addld="" 55 addlib="-lpthread" 56 addcflags="" 57 bearssllib="" 58 59 if test "x$USE_RUSTLS" != "xyes"; then 60 dnl add the path and test again 61 addld=-L$OPT_RUSTLS/lib$libsuff 62 addcflags=-I$OPT_RUSTLS/include 63 rustlslib=$OPT_RUSTLS/lib$libsuff 64 65 LDFLAGS="$LDFLAGS $addld" 66 if test "$addcflags" != "-I/usr/include"; then 67 CPPFLAGS="$CPPFLAGS $addcflags" 68 fi 69 70 AC_CHECK_LIB(crustls, rustls_connection_read, 71 [ 72 AC_DEFINE(USE_RUSTLS, 1, [if rustls is enabled]) 73 AC_SUBST(USE_RUSTLS, [1]) 74 RUSTLS_ENABLED=1 75 USE_RUSTLS="yes" 76 ssl_msg="rustls" 77 test rustls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes 78 ], 79 AC_MSG_ERROR([--with-rustls was specified but could not find rustls.]), 80 -lpthread -ldl) 81 fi 82 83 if test "x$USE_RUSTLS" = "xyes"; then 84 AC_MSG_NOTICE([detected rustls]) 85 check_for_ca_bundle=1 86 87 LIBS="-lcrustls -lpthread -ldl $LIBS" 88 89 if test -n "$rustlslib"; then 90 dnl when shared libs were found in a path that the run-time 91 dnl linker doesn't search through, we need to add it to 92 dnl CURL_LIBRARY_PATH to prevent further configure tests to fail 93 dnl due to this 94 if test "x$cross_compiling" != "xyes"; then 95 CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$rustlslib" 96 export CURL_LIBRARY_PATH 97 AC_MSG_NOTICE([Added $rustlslib to CURL_LIBRARY_PATH]) 98 fi 99 fi 100 fi 101 102 fi dnl rustls not disabled 103 104 test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg" 105fi 106]) 107