quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

curl-mbedtls.m4 (3726B)


      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 
     25 dnl ----------------------------------------------------
     26 dnl check for mbedTLS
     27 dnl ----------------------------------------------------
     28 AC_DEFUN([CURL_WITH_MBEDTLS], [
     29 
     30 if test "x$OPT_MBEDTLS" != xno; then
     31   _cppflags=$CPPFLAGS
     32   _ldflags=$LDFLAGS
     33   _ldflagspc=$LDFLAGSPC
     34   ssl_msg=
     35 
     36   if test X"$OPT_MBEDTLS" != Xno; then
     37 
     38     if test "$OPT_MBEDTLS" = "yes"; then
     39       OPT_MBEDTLS=""
     40     fi
     41 
     42     if test -z "$OPT_MBEDTLS" ; then
     43       dnl check for lib first without setting any new path
     44 
     45       AC_CHECK_LIB(mbedtls, mbedtls_havege_init,
     46       dnl libmbedtls found, set the variable
     47       [
     48         AC_DEFINE(USE_MBEDTLS, 1, [if mbedTLS is enabled])
     49         MBEDTLS_ENABLED=1
     50         USE_MBEDTLS="yes"
     51         ssl_msg="mbedTLS"
     52         test mbedtls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
     53       ], [], -lmbedx509 -lmbedcrypto)
     54     fi
     55 
     56     addld=""
     57     addlib=""
     58     addcflags=""
     59     mbedtlslib=""
     60 
     61     if test "x$USE_MBEDTLS" != "xyes"; then
     62       dnl add the path and test again
     63       addld=-L$OPT_MBEDTLS/lib$libsuff
     64       addcflags=-I$OPT_MBEDTLS/include
     65       mbedtlslib=$OPT_MBEDTLS/lib$libsuff
     66 
     67       LDFLAGS="$LDFLAGS $addld"
     68       LDFLAGSPC="$LDFLAGSPC $addld"
     69       if test "$addcflags" != "-I/usr/include"; then
     70         CPPFLAGS="$CPPFLAGS $addcflags"
     71       fi
     72 
     73       AC_CHECK_LIB(mbedtls, mbedtls_ssl_init,
     74         [
     75         AC_DEFINE(USE_MBEDTLS, 1, [if mbedTLS is enabled])
     76         MBEDTLS_ENABLED=1
     77         USE_MBEDTLS="yes"
     78         ssl_msg="mbedTLS"
     79         test mbedtls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
     80         ],
     81         [
     82           CPPFLAGS=$_cppflags
     83           LDFLAGS=$_ldflags
     84           LDFLAGSPC=$_ldflagspc
     85         ], -lmbedx509 -lmbedcrypto)
     86     fi
     87 
     88     if test "x$USE_MBEDTLS" = "xyes"; then
     89       AC_MSG_NOTICE([detected mbedTLS])
     90       check_for_ca_bundle=1
     91 
     92       LIBS="-lmbedtls -lmbedx509 -lmbedcrypto $LIBS"
     93 
     94       if test -n "$mbedtlslib"; 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:$mbedtlslib"
    101           export CURL_LIBRARY_PATH
    102           AC_MSG_NOTICE([Added $mbedtlslib to CURL_LIBRARY_PATH])
    103         fi
    104       fi
    105       dnl FIXME: Enable when mbedTLS was detected via pkg-config
    106       if false; then
    107         LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE mbedtls mbedx509 mbedcrypto"
    108       fi
    109     fi
    110 
    111   fi dnl mbedTLS not disabled
    112 
    113   test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
    114 fi
    115 
    116 ])