| xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 1 | #*************************************************************************** | 
 | 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 |  | 
 | 25 | AC_DEFUN([CURL_WITH_BEARSSL], [ | 
 | 26 | dnl ---------------------------------------------------- | 
 | 27 | dnl check for BearSSL | 
 | 28 | dnl ---------------------------------------------------- | 
 | 29 |  | 
 | 30 | if test "x$OPT_BEARSSL" != xno; then | 
 | 31 |   _cppflags=$CPPFLAGS | 
 | 32 |   _ldflags=$LDFLAGS | 
 | 33 |   ssl_msg= | 
 | 34 |  | 
 | 35 |   if test X"$OPT_BEARSSL" != Xno; then | 
 | 36 |  | 
 | 37 |     if test "$OPT_BEARSSL" = "yes"; then | 
 | 38 |       OPT_BEARSSL="" | 
 | 39 |     fi | 
 | 40 |  | 
 | 41 |     if test -z "$OPT_BEARSSL" ; then | 
 | 42 |       dnl check for lib first without setting any new path | 
 | 43 |  | 
 | 44 |       AC_CHECK_LIB(bearssl, br_ssl_client_init_full, | 
 | 45 |       dnl libbearssl found, set the variable | 
 | 46 |        [ | 
 | 47 |          AC_DEFINE(USE_BEARSSL, 1, [if BearSSL is enabled]) | 
 | 48 |          AC_SUBST(USE_BEARSSL, [1]) | 
 | 49 |          BEARSSL_ENABLED=1 | 
 | 50 |          USE_BEARSSL="yes" | 
 | 51 |          ssl_msg="BearSSL" | 
 | 52 | 	 test bearssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes | 
 | 53 |         ], [], -lbearssl) | 
 | 54 |     fi | 
 | 55 |  | 
 | 56 |     addld="" | 
 | 57 |     addlib="" | 
 | 58 |     addcflags="" | 
 | 59 |     bearssllib="" | 
 | 60 |  | 
 | 61 |     if test "x$USE_BEARSSL" != "xyes"; then | 
 | 62 |       dnl add the path and test again | 
 | 63 |       addld=-L$OPT_BEARSSL/lib$libsuff | 
 | 64 |       addcflags=-I$OPT_BEARSSL/include | 
 | 65 |       bearssllib=$OPT_BEARSSL/lib$libsuff | 
 | 66 |  | 
 | 67 |       LDFLAGS="$LDFLAGS $addld" | 
 | 68 |       if test "$addcflags" != "-I/usr/include"; then | 
 | 69 |          CPPFLAGS="$CPPFLAGS $addcflags" | 
 | 70 |       fi | 
 | 71 |  | 
 | 72 |       AC_CHECK_LIB(bearssl, br_ssl_client_init_full, | 
 | 73 |        [ | 
 | 74 |        AC_DEFINE(USE_BEARSSL, 1, [if BearSSL is enabled]) | 
 | 75 |        AC_SUBST(USE_BEARSSL, [1]) | 
 | 76 |        BEARSSL_ENABLED=1 | 
 | 77 |        USE_BEARSSL="yes" | 
 | 78 |        ssl_msg="BearSSL" | 
 | 79 |        test bearssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes | 
 | 80 |        ], | 
 | 81 |        [ | 
 | 82 |          CPPFLAGS=$_cppflags | 
 | 83 |          LDFLAGS=$_ldflags | 
 | 84 |        ], -lbearssl) | 
 | 85 |     fi | 
 | 86 |  | 
 | 87 |     if test "x$USE_BEARSSL" = "xyes"; then | 
 | 88 |       AC_MSG_NOTICE([detected BearSSL]) | 
 | 89 |       check_for_ca_bundle=1 | 
 | 90 |  | 
 | 91 |       LIBS="-lbearssl $LIBS" | 
 | 92 |  | 
 | 93 |       if test -n "$bearssllib"; then | 
 | 94 |         dnl when shared libs were found in a path that the run-time | 
 | 95 |         dnl linker doesn't search through, we need to add it to | 
 | 96 |         dnl CURL_LIBRARY_PATH to prevent further configure tests to fail | 
 | 97 |         dnl due to this | 
 | 98 |         if test "x$cross_compiling" != "xyes"; then | 
 | 99 |           CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$bearssllib" | 
 | 100 |           export CURL_LIBRARY_PATH | 
 | 101 |           AC_MSG_NOTICE([Added $bearssllib to CURL_LIBRARY_PATH]) | 
 | 102 |         fi | 
 | 103 |       fi | 
 | 104 |     fi | 
 | 105 |  | 
 | 106 |   fi dnl BearSSL not disabled | 
 | 107 |  | 
 | 108 |   test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg" | 
 | 109 | fi | 
 | 110 | ]) |