curl-wolfssl.m4 5.8 KB

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