curl-wolfssl.m4 5.5 KB

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