blob: 6fd8235aad21a9db625ad1b991bb2078d18175b9 [file] [log] [blame]
xf.li6c8fc1e2023-08-12 00:11:09 -07001#***************************************************************************
2# _ _ ____ _
3# Project ___| | | | _ \| |
4# / __| | | | |_) | |
5# | (__| |_| | _ <| |___
6# \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1998 - 2022, 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 if test -z "$OPT_RUSTLS" ; then
42 dnl check for lib first without setting any new path
43
44 AC_CHECK_LIB(rustls, rustls_client_session_read,
45 dnl librustls found, set the variable
46 [
47 AC_DEFINE(USE_RUSTLS, 1, [if rustls is enabled])
48 AC_SUBST(USE_RUSTLS, [1])
49 RUSTLS_ENABLED=1
50 USE_RUSTLS="yes"
51 ssl_msg="rustls"
52 test rustls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
53 ], [], -lpthread -ldl -lm)
54 fi
55
56 if test "x$USE_RUSTLS" != "xyes"; then
57 dnl add the path and test again
58 addld=-L$OPT_RUSTLS/lib$libsuff
59 addcflags=-I$OPT_RUSTLS/include
60 rustlslib=$OPT_RUSTLS/lib$libsuff
61
62 LDFLAGS="$LDFLAGS $addld"
63 if test "$addcflags" != "-I/usr/include"; then
64 CPPFLAGS="$CPPFLAGS $addcflags"
65 fi
66
67 AC_CHECK_LIB(rustls, rustls_connection_read,
68 [
69 AC_DEFINE(USE_RUSTLS, 1, [if rustls is enabled])
70 AC_SUBST(USE_RUSTLS, [1])
71 RUSTLS_ENABLED=1
72 USE_RUSTLS="yes"
73 ssl_msg="rustls"
74 test rustls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
75 ],
76 AC_MSG_ERROR([--with-rustls was specified but could not find rustls.]),
77 -lpthread -ldl -lm)
78 fi
79
80 if test "x$USE_RUSTLS" = "xyes"; then
81 AC_MSG_NOTICE([detected rustls])
82 check_for_ca_bundle=1
83
84 LIBS="-lrustls -lpthread -ldl -lm $LIBS"
85
86 if test -n "$rustlslib"; then
87 dnl when shared libs were found in a path that the run-time
88 dnl linker doesn't search through, we need to add it to
89 dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
90 dnl due to this
91 if test "x$cross_compiling" != "xyes"; then
92 CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$rustlslib"
93 export CURL_LIBRARY_PATH
94 AC_MSG_NOTICE([Added $rustlslib to CURL_LIBRARY_PATH])
95 fi
96 fi
97 fi
98
99 fi dnl rustls not disabled
100
101 test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
102fi
103])