xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame^] | 1 | #*************************************************************************** |
| 2 | # _ _ ____ _ |
| 3 | # Project ___| | | | _ \| | |
| 4 | # / __| | | | |_) | | |
| 5 | # | (__| |_| | _ <| |___ |
| 6 | # \___|\___/|_| \_\_____| |
| 7 | # |
| 8 | # Copyright (C) 1998 - 2022, 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 | |
| 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 aren't 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 | test wolfssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes |
| 111 | ], |
| 112 | [ |
| 113 | AC_MSG_RESULT(no) |
| 114 | CPPFLAGS=$_cppflags |
| 115 | LDFLAGS=$_ldflags |
| 116 | wolfssllibpath="" |
| 117 | ]) |
| 118 | LIBS="$my_ac_save_LIBS" |
| 119 | fi |
| 120 | |
| 121 | if test "x$USE_WOLFSSL" = "xyes"; then |
| 122 | AC_MSG_NOTICE([detected wolfSSL]) |
| 123 | check_for_ca_bundle=1 |
| 124 | |
| 125 | dnl wolfssl/ctaocrypt/types.h needs SIZEOF_LONG_LONG defined! |
| 126 | CURL_SIZEOF(long long) |
| 127 | |
| 128 | LIBS="$addlib -lm $LIBS" |
| 129 | |
| 130 | dnl WolfSSL needs configure --enable-opensslextra to have *get_peer* |
| 131 | dnl DES* is needed for NTLM support and lives in the OpenSSL compatibility |
| 132 | dnl layer |
| 133 | AC_CHECK_FUNCS(wolfSSL_get_peer_certificate \ |
| 134 | wolfSSL_UseALPN ) |
| 135 | |
| 136 | dnl if this symbol is present, we want the include path to include the |
| 137 | dnl OpenSSL API root as well |
| 138 | AC_CHECK_FUNC(wolfSSL_DES_ecb_encrypt, |
| 139 | [ |
| 140 | AC_DEFINE(HAVE_WOLFSSL_DES_ECB_ENCRYPT, 1, |
| 141 | [if you have wolfSSL_DES_ecb_encrypt]) |
| 142 | WOLFSSL_NTLM=1 |
| 143 | ] |
| 144 | ) |
| 145 | |
| 146 | if test -n "$wolfssllibpath"; then |
| 147 | dnl when shared libs were found in a path that the run-time |
| 148 | dnl linker doesn't search through, we need to add it to |
| 149 | dnl CURL_LIBRARY_PATH to prevent further configure tests to fail |
| 150 | dnl due to this |
| 151 | if test "x$cross_compiling" != "xyes"; then |
| 152 | CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$wolfssllibpath" |
| 153 | export CURL_LIBRARY_PATH |
| 154 | AC_MSG_NOTICE([Added $wolfssllibpath to CURL_LIBRARY_PATH]) |
| 155 | fi |
| 156 | fi |
| 157 | else |
| 158 | AC_MSG_ERROR([--with-wolfssl but wolfSSL was not found or doesn't work]) |
| 159 | fi |
| 160 | |
| 161 | fi dnl wolfSSL not disabled |
| 162 | |
| 163 | test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg" |
| 164 | fi |
| 165 | |
| 166 | ]) |