xref: /freebsd/contrib/unbound/dnscrypt/dnscrypt.m4 (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1# dnscrypt.m4
2
3# dnsc_DNSCRYPT([action-if-true], [action-if-false])
4# --------------------------------------------------------------------------
5# Check for required dnscrypt libraries and add dnscrypt configure args.
6AC_DEFUN([dnsc_DNSCRYPT],
7[
8  AC_ARG_ENABLE([dnscrypt],
9    AS_HELP_STRING([--enable-dnscrypt],
10                   [Enable dnscrypt support (requires libsodium)]),
11    [opt_dnscrypt=$enableval], [opt_dnscrypt=no])
12
13  if test "x$opt_dnscrypt" != "xno"; then
14    AC_ARG_WITH([libsodium], AS_HELP_STRING([--with-libsodium=path],
15    	[Path where libsodium is installed, for dnscrypt]), [
16	CFLAGS="$CFLAGS -I$withval/include"
17	LDFLAGS="$LDFLAGS -L$withval/lib"
18    ])
19    AC_SEARCH_LIBS([sodium_init], [sodium], [],
20      AC_MSG_ERROR([The sodium library was not found. Please install sodium!]))
21    AC_SEARCH_LIBS([crypto_box_curve25519xchacha20poly1305_beforenm], [sodium],
22        [
23            AC_SUBST([ENABLE_DNSCRYPT_XCHACHA20], [1])
24            AC_DEFINE(
25                [USE_DNSCRYPT_XCHACHA20], [1],
26                [Define to 1 to enable dnscrypt with xchacha20 support])
27        ],
28        [
29            AC_SUBST([ENABLE_DNSCRYPT_XCHACHA20], [0])
30        ])
31    AC_SEARCH_LIBS([sodium_set_misuse_handler], [sodium],
32        [
33            AC_DEFINE(
34                [SODIUM_MISUSE_HANDLER], [1],
35                [Define to 1 if libsodium supports sodium_set_misuse_handler])
36        ],
37        [
38        ])
39    $1
40  else
41    AC_SUBST([ENABLE_DNSCRYPT_XCHACHA20], [0])
42    $2
43  fi
44])
45