• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  _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        QUIC_ENABLED=yes
112        test wolfssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
113      ],
114      [
115        AC_MSG_RESULT(no)
116        CPPFLAGS=$_cppflags
117        LDFLAGS=$_ldflags
118        LDFLAGSPC=$_ldflagspc
119        wolfssllibpath=""
120      ])
121      LIBS="$my_ac_save_LIBS"
122    fi
123
124    if test "x$USE_WOLFSSL" = "xyes"; then
125      AC_MSG_NOTICE([detected wolfSSL])
126      check_for_ca_bundle=1
127
128      dnl wolfssl/ctaocrypt/types.h needs SIZEOF_LONG_LONG defined!
129      CURL_SIZEOF(long long)
130
131      LIBS="$addlib -lm $LIBS"
132
133      dnl wolfSSL needs configure --enable-opensslextra to have *get_peer*
134      dnl DES* is needed for NTLM support and lives in the OpenSSL compatibility
135      dnl layer
136      AC_CHECK_FUNCS(wolfSSL_get_peer_certificate \
137                     wolfSSL_UseALPN )
138
139      dnl if this symbol is present, we want the include path to include the
140      dnl OpenSSL API root as well
141      AC_CHECK_FUNC(wolfSSL_DES_ecb_encrypt,
142        [
143          AC_DEFINE(HAVE_WOLFSSL_DES_ECB_ENCRYPT, 1,
144                    [if you have wolfSSL_DES_ecb_encrypt])
145          WOLFSSL_NTLM=1
146        ]
147        )
148
149      dnl if this symbol is present, we can make use of BIO filter chains
150      AC_CHECK_FUNC(wolfSSL_BIO_new,
151        [
152          AC_DEFINE(HAVE_WOLFSSL_BIO, 1,
153                    [if you have wolfSSL_BIO_new])
154          WOLFSSL_BIO=1
155        ]
156        )
157      dnl if this symbol is present, we have the full BIO feature set
158      AC_CHECK_FUNC(wolfSSL_BIO_set_shutdown,
159        [
160          AC_DEFINE(HAVE_WOLFSSL_FULL_BIO, 1,
161                    [if you have wolfSSL_BIO_set_shutdown])
162          WOLFSSL_FULL_BIO=1
163        ]
164        )
165
166      if test -n "$wolfssllibpath"; then
167        dnl when shared libs were found in a path that the run-time
168        dnl linker doesn't search through, we need to add it to
169        dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
170        dnl due to this
171        if test "x$cross_compiling" != "xyes"; then
172          CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$wolfssllibpath"
173          export CURL_LIBRARY_PATH
174          AC_MSG_NOTICE([Added $wolfssllibpath to CURL_LIBRARY_PATH])
175        fi
176      fi
177      LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE wolfssl"
178    else
179      AC_MSG_ERROR([--with-wolfssl but wolfSSL was not found or doesn't work])
180    fi
181
182  fi dnl wolfSSL not disabled
183
184  test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
185fi
186
187])
188