summaryrefslogtreecommitdiffstats
path: root/m4/pdns_with_gnutls.m4
blob: b6ad100bbbd67199aba9b04c789031f6d66be3d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
AC_DEFUN([PDNS_WITH_GNUTLS], [
  AC_MSG_CHECKING([whether we will be linking in GnuTLS])
  HAVE_GNUTLS=0
  AC_ARG_WITH([gnutls],
    AS_HELP_STRING([--with-gnutls],[use GnuTLS @<:@default=auto@:>@]),
    [with_gnutls=$withval],
    [with_gnutls=auto],
  )
  AC_MSG_RESULT([$with_gnutls])

  AS_IF([test "x$with_gnutls" != "xno"], [
    AS_IF([test "x$with_gnutls" = "xyes" -o "x$with_gnutls" = "xauto"], [
      # we require gnutls_certificate_set_x509_key_file, added in 3.1.11
      PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.1.11], [
        [HAVE_GNUTLS=1]
        AC_DEFINE([HAVE_GNUTLS], [1], [Define to 1 if you have GnuTLS])
        save_CFLAGS=$CFLAGS
        save_LIBS=$LIBS
        CFLAGS="$GNUTLS_CFLAGS $CFLAGS"
        LIBS="$GNUTLS_LIBS $LIBS"
        AC_CHECK_FUNCS([gnutls_memset gnutls_session_set_verify_cert gnutls_session_get_verify_cert_status gnutls_alpn_set_protocols])
        CFLAGS=$save_CFLAGS
        LIBS=$save_LIBS

      ], [ : ])
    ])
  ])
  AM_CONDITIONAL([HAVE_GNUTLS], [test "x$GNUTLS_LIBS" != "x"])
  AS_IF([test "x$with_gnutls" = "xyes"], [
    AS_IF([test x"$GNUTLS_LIBS" = "x"], [
      AC_MSG_ERROR([GnuTLS requested but libraries were not found])
    ])
  ])
])