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