2
0

curl-wolfssl.m4 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. 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 aren't 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. test wolfssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
  99. ],
  100. [
  101. AC_MSG_RESULT(no)
  102. CPPFLAGS=$_cppflags
  103. LDFLAGS=$_ldflags
  104. wolfssllibpath=""
  105. ])
  106. LIBS="$my_ac_save_LIBS"
  107. fi
  108. if test "x$USE_WOLFSSL" = "xyes"; then
  109. AC_MSG_NOTICE([detected wolfSSL])
  110. check_for_ca_bundle=1
  111. dnl wolfssl/ctaocrypt/types.h needs SIZEOF_LONG_LONG defined!
  112. CURL_SIZEOF(long long)
  113. LIBS="$addlib -lm $LIBS"
  114. dnl WolfSSL needs configure --enable-opensslextra to have *get_peer*
  115. dnl DES* is needed for NTLM support and lives in the OpenSSL compatibility
  116. dnl layer
  117. AC_CHECK_FUNCS(wolfSSL_get_peer_certificate \
  118. wolfSSL_UseALPN )
  119. dnl if this symbol is present, we want the include path to include the
  120. dnl OpenSSL API root as well
  121. AC_CHECK_FUNC(wolfSSL_DES_ecb_encrypt,
  122. [
  123. AC_DEFINE(HAVE_WOLFSSL_DES_ECB_ENCRYPT, 1,
  124. [if you have wolfSSL_DES_ecb_encrypt])
  125. WOLFSSL_NTLM=1
  126. ]
  127. )
  128. if test -n "$wolfssllibpath"; then
  129. dnl when shared libs were found in a path that the run-time
  130. dnl linker doesn't search through, we need to add it to
  131. dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
  132. dnl due to this
  133. if test "x$cross_compiling" != "xyes"; then
  134. CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$wolfssllibpath"
  135. export CURL_LIBRARY_PATH
  136. AC_MSG_NOTICE([Added $wolfssllibpath to CURL_LIBRARY_PATH])
  137. fi
  138. fi
  139. else
  140. AC_MSG_ERROR([--with-wolfssl but wolfSSL was not found or doesn't work])
  141. fi
  142. fi dnl wolfSSL not disabled
  143. test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
  144. fi
  145. ])