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_WOLFSSL], [ 26dnl ---------------------------------------------------- 27dnl check for wolfSSL 28dnl ---------------------------------------------------- 29 30case "$OPT_WOLFSSL" in 31 yes|no) 32 wolfpkg="" 33 ;; 34 *) 35 wolfpkg="$withval/lib/pkgconfig" 36 ;; 37esac 38 39if test "x$OPT_WOLFSSL" != xno; then 40 _cppflags=$CPPFLAGS 41 _ldflags=$LDFLAGS 42 43 ssl_msg= 44 45 if test X"$OPT_WOLFSSL" != Xno; then 46 47 if test "$OPT_WOLFSSL" = "yes"; then 48 OPT_WOLFSSL="" 49 fi 50 51 dnl try pkg-config magic 52 CURL_CHECK_PKGCONFIG(wolfssl, [$wolfpkg]) 53 AC_MSG_NOTICE([Check dir $wolfpkg]) 54 55 addld="" 56 addlib="" 57 addcflags="" 58 if test "$PKGCONFIG" != "no" ; then 59 addlib=`CURL_EXPORT_PCDIR([$wolfpkg]) 60 $PKGCONFIG --libs-only-l wolfssl` 61 addld=`CURL_EXPORT_PCDIR([$wolfpkg]) 62 $PKGCONFIG --libs-only-L wolfssl` 63 addcflags=`CURL_EXPORT_PCDIR([$wolfpkg]) 64 $PKGCONFIG --cflags-only-I wolfssl` 65 version=`CURL_EXPORT_PCDIR([$wolfpkg]) 66 $PKGCONFIG --modversion wolfssl` 67 wolfssllibpath=`echo $addld | $SED -e 's/^-L//'` 68 else 69 addlib=-lwolfssl 70 dnl use system defaults if user does not supply a path 71 if test -n "$OPT_WOLFSSL"; then 72 addld=-L$OPT_WOLFSSL/lib$libsuff 73 addcflags=-I$OPT_WOLFSSL/include 74 wolfssllibpath=$OPT_WOLFSSL/lib$libsuff 75 fi 76 fi 77 78 if test "x$USE_WOLFSSL" != "xyes"; then 79 80 LDFLAGS="$LDFLAGS $addld" 81 AC_MSG_NOTICE([Add $addld to LDFLAGS]) 82 if test "$addcflags" != "-I/usr/include"; then 83 CPPFLAGS="$CPPFLAGS $addcflags" 84 AC_MSG_NOTICE([Add $addcflags to CPPFLAGS]) 85 fi 86 87 my_ac_save_LIBS="$LIBS" 88 LIBS="$addlib $LIBS" 89 AC_MSG_NOTICE([Add $addlib to LIBS]) 90 91 AC_MSG_CHECKING([for wolfSSL_Init in -lwolfssl]) 92 AC_LINK_IFELSE([ 93 AC_LANG_PROGRAM([[ 94 /* These are not needed for detection and confuse wolfSSL. 95 They are set up properly later if it is detected. */ 96 #undef SIZEOF_LONG 97 #undef SIZEOF_LONG_LONG 98 #include <wolfssl/options.h> 99 #include <wolfssl/ssl.h> 100 ]],[[ 101 return wolfSSL_Init(); 102 ]]) 103 ],[ 104 AC_MSG_RESULT(yes) 105 AC_DEFINE(USE_WOLFSSL, 1, [if wolfSSL is enabled]) 106 AC_SUBST(USE_WOLFSSL, [1]) 107 WOLFSSL_ENABLED=1 108 USE_WOLFSSL="yes" 109 ssl_msg="wolfSSL" 110 QUIC_ENABLED=yes 111 test wolfssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes 112 ], 113 [ 114 AC_MSG_RESULT(no) 115 CPPFLAGS=$_cppflags 116 LDFLAGS=$_ldflags 117 wolfssllibpath="" 118 ]) 119 LIBS="$my_ac_save_LIBS" 120 fi 121 122 if test "x$USE_WOLFSSL" = "xyes"; then 123 AC_MSG_NOTICE([detected wolfSSL]) 124 check_for_ca_bundle=1 125 126 dnl wolfssl/ctaocrypt/types.h needs SIZEOF_LONG_LONG defined! 127 CURL_SIZEOF(long long) 128 129 LIBS="$addlib -lm $LIBS" 130 131 dnl wolfSSL needs configure --enable-opensslextra to have *get_peer* 132 dnl DES* is needed for NTLM support and lives in the OpenSSL compatibility 133 dnl layer 134 AC_CHECK_FUNCS(wolfSSL_get_peer_certificate \ 135 wolfSSL_UseALPN ) 136 137 dnl if this symbol is present, we want the include path to include the 138 dnl OpenSSL API root as well 139 AC_CHECK_FUNC(wolfSSL_DES_ecb_encrypt, 140 [ 141 AC_DEFINE(HAVE_WOLFSSL_DES_ECB_ENCRYPT, 1, 142 [if you have wolfSSL_DES_ecb_encrypt]) 143 WOLFSSL_NTLM=1 144 ] 145 ) 146 147 dnl if this symbol is present, we can make use of BIO filter chains 148 AC_CHECK_FUNC(wolfSSL_BIO_new, 149 [ 150 AC_DEFINE(HAVE_WOLFSSL_BIO, 1, 151 [if you have wolfSSL_BIO_new]) 152 WOLFSSL_BIO=1 153 ] 154 ) 155 dnl if this symbol is present, we have the full BIO feature set 156 AC_CHECK_FUNC(wolfSSL_BIO_set_shutdown, 157 [ 158 AC_DEFINE(HAVE_WOLFSSL_FULL_BIO, 1, 159 [if you have wolfSSL_BIO_set_shutdown]) 160 WOLFSSL_FULL_BIO=1 161 ] 162 ) 163 164 if test -n "$wolfssllibpath"; then 165 dnl when shared libs were found in a path that the run-time 166 dnl linker doesn't search through, we need to add it to 167 dnl CURL_LIBRARY_PATH to prevent further configure tests to fail 168 dnl due to this 169 if test "x$cross_compiling" != "xyes"; then 170 CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$wolfssllibpath" 171 export CURL_LIBRARY_PATH 172 AC_MSG_NOTICE([Added $wolfssllibpath to CURL_LIBRARY_PATH]) 173 fi 174 fi 175 LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE wolfssl" 176 else 177 AC_MSG_ERROR([--with-wolfssl but wolfSSL was not found or doesn't work]) 178 fi 179 180 fi dnl wolfSSL not disabled 181 182 test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg" 183fi 184 185]) 186