curl-nss.m4 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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_NSS], [
  25. if test "x$OPT_NSS" != xno; then
  26. ssl_msg=
  27. if test X"$OPT_NSS" != Xno; then
  28. addld=""
  29. addlib=""
  30. addcflags=""
  31. nssprefix=""
  32. version=""
  33. if test "x$OPT_NSS" = "xyes"; then
  34. CURL_CHECK_PKGCONFIG(nss)
  35. if test "$PKGCONFIG" != "no" ; then
  36. addlib=`$PKGCONFIG --libs nss`
  37. addcflags=`$PKGCONFIG --cflags nss`
  38. version=`$PKGCONFIG --modversion nss`
  39. nssprefix=`$PKGCONFIG --variable=prefix nss`
  40. else
  41. dnl Without pkg-config, we check for nss-config
  42. check=`nss-config --version 2>/dev/null`
  43. if test -n "$check"; then
  44. addlib=`nss-config --libs`
  45. addcflags=`nss-config --cflags`
  46. version=`nss-config --version`
  47. nssprefix=`nss-config --prefix`
  48. else
  49. addlib="-lnss3"
  50. addcflags=""
  51. version="unknown"
  52. fi
  53. fi
  54. else
  55. NSS_PCDIR="$OPT_NSS/lib/pkgconfig"
  56. if test -f "$NSS_PCDIR/nss.pc"; then
  57. CURL_CHECK_PKGCONFIG(nss, [$NSS_PCDIR])
  58. if test "$PKGCONFIG" != "no" ; then
  59. addld=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --libs-only-L nss`
  60. addlib=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --libs-only-l nss`
  61. addcflags=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --cflags nss`
  62. version=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --modversion nss`
  63. nssprefix=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --variable=prefix nss`
  64. fi
  65. fi
  66. fi
  67. if test -z "$addlib"; then
  68. # Without pkg-config, we'll kludge in some defaults
  69. AC_MSG_WARN([Using hard-wired libraries and compilation flags for NSS.])
  70. addld="-L$OPT_NSS/lib"
  71. addlib="-lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4"
  72. addcflags="-I$OPT_NSS/include"
  73. version="unknown"
  74. nssprefix=$OPT_NSS
  75. fi
  76. CLEANLDFLAGS="$LDFLAGS"
  77. CLEANLIBS="$LIBS"
  78. CLEANCPPFLAGS="$CPPFLAGS"
  79. LDFLAGS="$addld $LDFLAGS"
  80. LIBS="$addlib $LIBS"
  81. if test "$addcflags" != "-I/usr/include"; then
  82. CPPFLAGS="$CPPFLAGS $addcflags"
  83. fi
  84. dnl The function SSL_VersionRangeSet() is needed to enable TLS > 1.0
  85. AC_CHECK_LIB(nss3, SSL_VersionRangeSet,
  86. [
  87. AC_DEFINE(USE_NSS, 1, [if NSS is enabled])
  88. AC_SUBST(USE_NSS, [1])
  89. USE_NSS="yes"
  90. NSS_ENABLED=1
  91. ssl_msg="NSS"
  92. test nss != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
  93. ],
  94. [
  95. LDFLAGS="$CLEANLDFLAGS"
  96. LIBS="$CLEANLIBS"
  97. CPPFLAGS="$CLEANCPPFLAGS"
  98. ])
  99. if test "x$USE_NSS" = "xyes"; then
  100. AC_MSG_NOTICE([detected NSS version $version])
  101. dnl PK11_CreateManagedGenericObject() was introduced in NSS 3.34 because
  102. dnl PK11_DestroyGenericObject() does not release resources allocated by
  103. dnl PK11_CreateGenericObject() early enough.
  104. AC_CHECK_FUNC(PK11_CreateManagedGenericObject,
  105. [
  106. AC_DEFINE(HAVE_PK11_CREATEMANAGEDGENERICOBJECT, 1,
  107. [if you have the PK11_CreateManagedGenericObject function])
  108. ])
  109. dnl needed when linking the curl tool without USE_EXPLICIT_LIB_DEPS
  110. NSS_LIBS=$addlib
  111. AC_SUBST([NSS_LIBS])
  112. dnl when shared libs were found in a path that the run-time
  113. dnl linker doesn't search through, we need to add it to
  114. dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
  115. dnl due to this
  116. if test "x$cross_compiling" != "xyes"; then
  117. CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$nssprefix/lib$libsuff"
  118. export CURL_LIBRARY_PATH
  119. AC_MSG_NOTICE([Added $nssprefix/lib$libsuff to CURL_LIBRARY_PATH])
  120. fi
  121. fi dnl NSS found
  122. fi dnl NSS not disabled
  123. test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
  124. fi
  125. ])