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