curl-wolfssl.m4 5.5 KB

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