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