curl-bearssl.m4 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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_BEARSSL], [
  25. dnl ----------------------------------------------------
  26. dnl check for BearSSL
  27. dnl ----------------------------------------------------
  28. if test "x$OPT_BEARSSL" != xno; then
  29. _cppflags=$CPPFLAGS
  30. _ldflags=$LDFLAGS
  31. _ldflagspc=$LDFLAGSPC
  32. ssl_msg=
  33. if test X"$OPT_BEARSSL" != Xno; then
  34. if test "$OPT_BEARSSL" = "yes"; then
  35. OPT_BEARSSL=""
  36. fi
  37. if test -z "$OPT_BEARSSL" ; then
  38. dnl check for lib first without setting any new path
  39. AC_CHECK_LIB(bearssl, br_ssl_client_init_full,
  40. dnl libbearssl found, set the variable
  41. [
  42. AC_DEFINE(USE_BEARSSL, 1, [if BearSSL is enabled])
  43. BEARSSL_ENABLED=1
  44. USE_BEARSSL="yes"
  45. ssl_msg="BearSSL"
  46. test bearssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
  47. ], [], -lbearssl)
  48. fi
  49. addld=""
  50. addlib=""
  51. addcflags=""
  52. bearssllib=""
  53. if test "x$USE_BEARSSL" != "xyes"; then
  54. dnl add the path and test again
  55. addld=-L$OPT_BEARSSL/lib$libsuff
  56. addcflags=-I$OPT_BEARSSL/include
  57. bearssllib=$OPT_BEARSSL/lib$libsuff
  58. LDFLAGS="$LDFLAGS $addld"
  59. LDFLAGSPC="$LDFLAGSPC $addld"
  60. if test "$addcflags" != "-I/usr/include"; then
  61. CPPFLAGS="$CPPFLAGS $addcflags"
  62. fi
  63. AC_CHECK_LIB(bearssl, br_ssl_client_init_full,
  64. [
  65. AC_DEFINE(USE_BEARSSL, 1, [if BearSSL is enabled])
  66. BEARSSL_ENABLED=1
  67. USE_BEARSSL="yes"
  68. ssl_msg="BearSSL"
  69. test bearssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
  70. ],
  71. [
  72. CPPFLAGS=$_cppflags
  73. LDFLAGS=$_ldflags
  74. LDFLAGSPC=$_ldflagspc
  75. ], -lbearssl)
  76. fi
  77. if test "x$USE_BEARSSL" = "xyes"; then
  78. AC_MSG_NOTICE([detected BearSSL])
  79. check_for_ca_bundle=1
  80. LIBS="-lbearssl $LIBS"
  81. if test -n "$bearssllib"; then
  82. dnl when shared libs were found in a path that the run-time
  83. dnl linker doesn't search through, we need to add it to
  84. dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
  85. dnl due to this
  86. if test "x$cross_compiling" != "xyes"; then
  87. CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$bearssllib"
  88. export CURL_LIBRARY_PATH
  89. AC_MSG_NOTICE([Added $bearssllib to CURL_LIBRARY_PATH])
  90. fi
  91. fi
  92. fi
  93. fi dnl BearSSL not disabled
  94. test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
  95. fi
  96. ])