1*6236dae4SAndroid Build Coastguard Worker#*************************************************************************** 2*6236dae4SAndroid Build Coastguard Worker# _ _ ____ _ 3*6236dae4SAndroid Build Coastguard Worker# Project ___| | | | _ \| | 4*6236dae4SAndroid Build Coastguard Worker# / __| | | | |_) | | 5*6236dae4SAndroid Build Coastguard Worker# | (__| |_| | _ <| |___ 6*6236dae4SAndroid Build Coastguard Worker# \___|\___/|_| \_\_____| 7*6236dae4SAndroid Build Coastguard Worker# 8*6236dae4SAndroid Build Coastguard Worker# Copyright (C) Daniel Stenberg, <[email protected]>, et al. 9*6236dae4SAndroid Build Coastguard Worker# 10*6236dae4SAndroid Build Coastguard Worker# This software is licensed as described in the file COPYING, which 11*6236dae4SAndroid Build Coastguard Worker# you should have received as part of this distribution. The terms 12*6236dae4SAndroid Build Coastguard Worker# are also available at https://curl.se/docs/copyright.html. 13*6236dae4SAndroid Build Coastguard Worker# 14*6236dae4SAndroid Build Coastguard Worker# You may opt to use, copy, modify, merge, publish, distribute and/or sell 15*6236dae4SAndroid Build Coastguard Worker# copies of the Software, and permit persons to whom the Software is 16*6236dae4SAndroid Build Coastguard Worker# furnished to do so, under the terms of the COPYING file. 17*6236dae4SAndroid Build Coastguard Worker# 18*6236dae4SAndroid Build Coastguard Worker# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 19*6236dae4SAndroid Build Coastguard Worker# KIND, either express or implied. 20*6236dae4SAndroid Build Coastguard Worker# 21*6236dae4SAndroid Build Coastguard Worker# SPDX-License-Identifier: curl 22*6236dae4SAndroid Build Coastguard Worker# 23*6236dae4SAndroid Build Coastguard Worker#*************************************************************************** 24*6236dae4SAndroid Build Coastguard Worker 25*6236dae4SAndroid Build Coastguard WorkerAC_DEFUN([CURL_WITH_WOLFSSL], [ 26*6236dae4SAndroid Build Coastguard Workerdnl ---------------------------------------------------- 27*6236dae4SAndroid Build Coastguard Workerdnl check for wolfSSL 28*6236dae4SAndroid Build Coastguard Workerdnl ---------------------------------------------------- 29*6236dae4SAndroid Build Coastguard Worker 30*6236dae4SAndroid Build Coastguard Workercase "$OPT_WOLFSSL" in 31*6236dae4SAndroid Build Coastguard Worker yes|no) 32*6236dae4SAndroid Build Coastguard Worker wolfpkg="" 33*6236dae4SAndroid Build Coastguard Worker ;; 34*6236dae4SAndroid Build Coastguard Worker *) 35*6236dae4SAndroid Build Coastguard Worker wolfpkg="$withval/lib/pkgconfig" 36*6236dae4SAndroid Build Coastguard Worker ;; 37*6236dae4SAndroid Build Coastguard Workeresac 38*6236dae4SAndroid Build Coastguard Worker 39*6236dae4SAndroid Build Coastguard Workerif test "x$OPT_WOLFSSL" != xno; then 40*6236dae4SAndroid Build Coastguard Worker _cppflags=$CPPFLAGS 41*6236dae4SAndroid Build Coastguard Worker _ldflags=$LDFLAGS 42*6236dae4SAndroid Build Coastguard Worker 43*6236dae4SAndroid Build Coastguard Worker ssl_msg= 44*6236dae4SAndroid Build Coastguard Worker 45*6236dae4SAndroid Build Coastguard Worker if test X"$OPT_WOLFSSL" != Xno; then 46*6236dae4SAndroid Build Coastguard Worker 47*6236dae4SAndroid Build Coastguard Worker if test "$OPT_WOLFSSL" = "yes"; then 48*6236dae4SAndroid Build Coastguard Worker OPT_WOLFSSL="" 49*6236dae4SAndroid Build Coastguard Worker fi 50*6236dae4SAndroid Build Coastguard Worker 51*6236dae4SAndroid Build Coastguard Worker dnl try pkg-config magic 52*6236dae4SAndroid Build Coastguard Worker CURL_CHECK_PKGCONFIG(wolfssl, [$wolfpkg]) 53*6236dae4SAndroid Build Coastguard Worker AC_MSG_NOTICE([Check dir $wolfpkg]) 54*6236dae4SAndroid Build Coastguard Worker 55*6236dae4SAndroid Build Coastguard Worker addld="" 56*6236dae4SAndroid Build Coastguard Worker addlib="" 57*6236dae4SAndroid Build Coastguard Worker addcflags="" 58*6236dae4SAndroid Build Coastguard Worker if test "$PKGCONFIG" != "no" ; then 59*6236dae4SAndroid Build Coastguard Worker addlib=`CURL_EXPORT_PCDIR([$wolfpkg]) 60*6236dae4SAndroid Build Coastguard Worker $PKGCONFIG --libs-only-l wolfssl` 61*6236dae4SAndroid Build Coastguard Worker addld=`CURL_EXPORT_PCDIR([$wolfpkg]) 62*6236dae4SAndroid Build Coastguard Worker $PKGCONFIG --libs-only-L wolfssl` 63*6236dae4SAndroid Build Coastguard Worker addcflags=`CURL_EXPORT_PCDIR([$wolfpkg]) 64*6236dae4SAndroid Build Coastguard Worker $PKGCONFIG --cflags-only-I wolfssl` 65*6236dae4SAndroid Build Coastguard Worker version=`CURL_EXPORT_PCDIR([$wolfpkg]) 66*6236dae4SAndroid Build Coastguard Worker $PKGCONFIG --modversion wolfssl` 67*6236dae4SAndroid Build Coastguard Worker wolfssllibpath=`echo $addld | $SED -e 's/^-L//'` 68*6236dae4SAndroid Build Coastguard Worker else 69*6236dae4SAndroid Build Coastguard Worker addlib=-lwolfssl 70*6236dae4SAndroid Build Coastguard Worker dnl use system defaults if user does not supply a path 71*6236dae4SAndroid Build Coastguard Worker if test -n "$OPT_WOLFSSL"; then 72*6236dae4SAndroid Build Coastguard Worker addld=-L$OPT_WOLFSSL/lib$libsuff 73*6236dae4SAndroid Build Coastguard Worker addcflags=-I$OPT_WOLFSSL/include 74*6236dae4SAndroid Build Coastguard Worker wolfssllibpath=$OPT_WOLFSSL/lib$libsuff 75*6236dae4SAndroid Build Coastguard Worker fi 76*6236dae4SAndroid Build Coastguard Worker fi 77*6236dae4SAndroid Build Coastguard Worker 78*6236dae4SAndroid Build Coastguard Worker if test "x$USE_WOLFSSL" != "xyes"; then 79*6236dae4SAndroid Build Coastguard Worker 80*6236dae4SAndroid Build Coastguard Worker LDFLAGS="$LDFLAGS $addld" 81*6236dae4SAndroid Build Coastguard Worker AC_MSG_NOTICE([Add $addld to LDFLAGS]) 82*6236dae4SAndroid Build Coastguard Worker if test "$addcflags" != "-I/usr/include"; then 83*6236dae4SAndroid Build Coastguard Worker CPPFLAGS="$CPPFLAGS $addcflags" 84*6236dae4SAndroid Build Coastguard Worker AC_MSG_NOTICE([Add $addcflags to CPPFLAGS]) 85*6236dae4SAndroid Build Coastguard Worker fi 86*6236dae4SAndroid Build Coastguard Worker 87*6236dae4SAndroid Build Coastguard Worker my_ac_save_LIBS="$LIBS" 88*6236dae4SAndroid Build Coastguard Worker LIBS="$addlib $LIBS" 89*6236dae4SAndroid Build Coastguard Worker AC_MSG_NOTICE([Add $addlib to LIBS]) 90*6236dae4SAndroid Build Coastguard Worker 91*6236dae4SAndroid Build Coastguard Worker AC_MSG_CHECKING([for wolfSSL_Init in -lwolfssl]) 92*6236dae4SAndroid Build Coastguard Worker AC_LINK_IFELSE([ 93*6236dae4SAndroid Build Coastguard Worker AC_LANG_PROGRAM([[ 94*6236dae4SAndroid Build Coastguard Worker /* These are not needed for detection and confuse wolfSSL. 95*6236dae4SAndroid Build Coastguard Worker They are set up properly later if it is detected. */ 96*6236dae4SAndroid Build Coastguard Worker #undef SIZEOF_LONG 97*6236dae4SAndroid Build Coastguard Worker #undef SIZEOF_LONG_LONG 98*6236dae4SAndroid Build Coastguard Worker #include <wolfssl/options.h> 99*6236dae4SAndroid Build Coastguard Worker #include <wolfssl/ssl.h> 100*6236dae4SAndroid Build Coastguard Worker ]],[[ 101*6236dae4SAndroid Build Coastguard Worker return wolfSSL_Init(); 102*6236dae4SAndroid Build Coastguard Worker ]]) 103*6236dae4SAndroid Build Coastguard Worker ],[ 104*6236dae4SAndroid Build Coastguard Worker AC_MSG_RESULT(yes) 105*6236dae4SAndroid Build Coastguard Worker AC_DEFINE(USE_WOLFSSL, 1, [if wolfSSL is enabled]) 106*6236dae4SAndroid Build Coastguard Worker AC_SUBST(USE_WOLFSSL, [1]) 107*6236dae4SAndroid Build Coastguard Worker WOLFSSL_ENABLED=1 108*6236dae4SAndroid Build Coastguard Worker USE_WOLFSSL="yes" 109*6236dae4SAndroid Build Coastguard Worker ssl_msg="wolfSSL" 110*6236dae4SAndroid Build Coastguard Worker QUIC_ENABLED=yes 111*6236dae4SAndroid Build Coastguard Worker test wolfssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes 112*6236dae4SAndroid Build Coastguard Worker ], 113*6236dae4SAndroid Build Coastguard Worker [ 114*6236dae4SAndroid Build Coastguard Worker AC_MSG_RESULT(no) 115*6236dae4SAndroid Build Coastguard Worker CPPFLAGS=$_cppflags 116*6236dae4SAndroid Build Coastguard Worker LDFLAGS=$_ldflags 117*6236dae4SAndroid Build Coastguard Worker wolfssllibpath="" 118*6236dae4SAndroid Build Coastguard Worker ]) 119*6236dae4SAndroid Build Coastguard Worker LIBS="$my_ac_save_LIBS" 120*6236dae4SAndroid Build Coastguard Worker fi 121*6236dae4SAndroid Build Coastguard Worker 122*6236dae4SAndroid Build Coastguard Worker if test "x$USE_WOLFSSL" = "xyes"; then 123*6236dae4SAndroid Build Coastguard Worker AC_MSG_NOTICE([detected wolfSSL]) 124*6236dae4SAndroid Build Coastguard Worker check_for_ca_bundle=1 125*6236dae4SAndroid Build Coastguard Worker 126*6236dae4SAndroid Build Coastguard Worker dnl wolfssl/ctaocrypt/types.h needs SIZEOF_LONG_LONG defined! 127*6236dae4SAndroid Build Coastguard Worker CURL_SIZEOF(long long) 128*6236dae4SAndroid Build Coastguard Worker 129*6236dae4SAndroid Build Coastguard Worker LIBS="$addlib -lm $LIBS" 130*6236dae4SAndroid Build Coastguard Worker 131*6236dae4SAndroid Build Coastguard Worker dnl wolfSSL needs configure --enable-opensslextra to have *get_peer* 132*6236dae4SAndroid Build Coastguard Worker dnl DES* is needed for NTLM support and lives in the OpenSSL compatibility 133*6236dae4SAndroid Build Coastguard Worker dnl layer 134*6236dae4SAndroid Build Coastguard Worker AC_CHECK_FUNCS(wolfSSL_get_peer_certificate \ 135*6236dae4SAndroid Build Coastguard Worker wolfSSL_UseALPN ) 136*6236dae4SAndroid Build Coastguard Worker 137*6236dae4SAndroid Build Coastguard Worker dnl if this symbol is present, we want the include path to include the 138*6236dae4SAndroid Build Coastguard Worker dnl OpenSSL API root as well 139*6236dae4SAndroid Build Coastguard Worker AC_CHECK_FUNC(wolfSSL_DES_ecb_encrypt, 140*6236dae4SAndroid Build Coastguard Worker [ 141*6236dae4SAndroid Build Coastguard Worker AC_DEFINE(HAVE_WOLFSSL_DES_ECB_ENCRYPT, 1, 142*6236dae4SAndroid Build Coastguard Worker [if you have wolfSSL_DES_ecb_encrypt]) 143*6236dae4SAndroid Build Coastguard Worker WOLFSSL_NTLM=1 144*6236dae4SAndroid Build Coastguard Worker ] 145*6236dae4SAndroid Build Coastguard Worker ) 146*6236dae4SAndroid Build Coastguard Worker 147*6236dae4SAndroid Build Coastguard Worker dnl if this symbol is present, we can make use of BIO filter chains 148*6236dae4SAndroid Build Coastguard Worker AC_CHECK_FUNC(wolfSSL_BIO_new, 149*6236dae4SAndroid Build Coastguard Worker [ 150*6236dae4SAndroid Build Coastguard Worker AC_DEFINE(HAVE_WOLFSSL_BIO, 1, 151*6236dae4SAndroid Build Coastguard Worker [if you have wolfSSL_BIO_new]) 152*6236dae4SAndroid Build Coastguard Worker WOLFSSL_BIO=1 153*6236dae4SAndroid Build Coastguard Worker ] 154*6236dae4SAndroid Build Coastguard Worker ) 155*6236dae4SAndroid Build Coastguard Worker dnl if this symbol is present, we have the full BIO feature set 156*6236dae4SAndroid Build Coastguard Worker AC_CHECK_FUNC(wolfSSL_BIO_set_shutdown, 157*6236dae4SAndroid Build Coastguard Worker [ 158*6236dae4SAndroid Build Coastguard Worker AC_DEFINE(HAVE_WOLFSSL_FULL_BIO, 1, 159*6236dae4SAndroid Build Coastguard Worker [if you have wolfSSL_BIO_set_shutdown]) 160*6236dae4SAndroid Build Coastguard Worker WOLFSSL_FULL_BIO=1 161*6236dae4SAndroid Build Coastguard Worker ] 162*6236dae4SAndroid Build Coastguard Worker ) 163*6236dae4SAndroid Build Coastguard Worker 164*6236dae4SAndroid Build Coastguard Worker if test -n "$wolfssllibpath"; then 165*6236dae4SAndroid Build Coastguard Worker dnl when shared libs were found in a path that the run-time 166*6236dae4SAndroid Build Coastguard Worker dnl linker doesn't search through, we need to add it to 167*6236dae4SAndroid Build Coastguard Worker dnl CURL_LIBRARY_PATH to prevent further configure tests to fail 168*6236dae4SAndroid Build Coastguard Worker dnl due to this 169*6236dae4SAndroid Build Coastguard Worker if test "x$cross_compiling" != "xyes"; then 170*6236dae4SAndroid Build Coastguard Worker CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$wolfssllibpath" 171*6236dae4SAndroid Build Coastguard Worker export CURL_LIBRARY_PATH 172*6236dae4SAndroid Build Coastguard Worker AC_MSG_NOTICE([Added $wolfssllibpath to CURL_LIBRARY_PATH]) 173*6236dae4SAndroid Build Coastguard Worker fi 174*6236dae4SAndroid Build Coastguard Worker fi 175*6236dae4SAndroid Build Coastguard Worker LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE wolfssl" 176*6236dae4SAndroid Build Coastguard Worker else 177*6236dae4SAndroid Build Coastguard Worker AC_MSG_ERROR([--with-wolfssl but wolfSSL was not found or doesn't work]) 178*6236dae4SAndroid Build Coastguard Worker fi 179*6236dae4SAndroid Build Coastguard Worker 180*6236dae4SAndroid Build Coastguard Worker fi dnl wolfSSL not disabled 181*6236dae4SAndroid Build Coastguard Worker 182*6236dae4SAndroid Build Coastguard Worker test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg" 183*6236dae4SAndroid Build Coastguard Workerfi 184*6236dae4SAndroid Build Coastguard Worker 185*6236dae4SAndroid Build Coastguard Worker]) 186