2
0

curl-wolfssl.m4 5.8 KB

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