1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_lib_nettle.html
3 # ===========================================================================
7 # AX_LIB_NETTLE([yes|no|auto])
11 # Searches for the 'nettle' library with the --with... option.
13 # If found, define HAVE_NETTLE and macro NETTLE_LIBS. Also defines
14 # NETTLE_WITH_<algo> for the algorithms found available. Possible
15 # algorithms: AES ARCTWO BLOWFISH CAST128 DES DES3 SERPENT TWOFISH MD2 MD4
18 # The argument is used if no --with...-nettle option is set. Value "yes"
19 # requires the configuration by default. Value "no" does not require it by
20 # default. Value "auto" configures the library only if available.
22 # See also AX_LIB_BEECRYPT, AX_LIB_CRYPTO, and AX_LIB_GCRYPT.
26 # Copyright (c) 2009 Fabien Coelho <autoconf.archive@coelho.net>
28 # Copying and distribution of this file, with or without modification, are
29 # permitted in any medium without royalty provided the copyright notice
30 # and this notice are preserved. This file is offered as-is, without any
35 # AX_CHECK_NETTLE_ALGO([name],[function])
36 AC_DEFUN([AX_CHECK_NETTLE_ALGO],[
37 AC_CHECK_LIB([nettle], [nettle_$2],
38 AC_DEFINE([NETTLE_WITH_$1],[1],[Algorithm $1 in nettle library]))
41 # AX_LIB_NETTLE([yes|no|auto])
42 AC_DEFUN([AX_LIB_NETTLE],[
43 AC_MSG_CHECKING([whether nettle is enabled])
44 AC_ARG_WITH([nettle],[ --with-nettle require nettle library
45 --without-nettle disable nettle library],[
46 AC_MSG_RESULT([$withval])
47 ax_with_nettle=$withval
52 if test "$ax_with_nettle" = "yes" -o "$ax_with_nettle" = "auto" ; then
53 AC_CHECK_HEADERS([nettle/nettle-meta.h],[
54 AC_CHECK_LIB([nettle],[nettle_base64_encode_final],[
55 AC_DEFINE([HAVE_NETTLE],[1],[Nettle library is available])
57 AC_SUBST([NETTLE_LIBS],[-lnettle])
59 AX_CHECK_NETTLE_ALGO([AES],[aes_encrypt])
60 AX_CHECK_NETTLE_ALGO([ARCTWO],[arctwo_encrypt])
61 AX_CHECK_NETTLE_ALGO([BLOWFISH],[blowfish_encrypt])
62 AX_CHECK_NETTLE_ALGO([CAST128],[cast128_encrypt])
63 AX_CHECK_NETTLE_ALGO([DES],[des_encrypt])
64 AX_CHECK_NETTLE_ALGO([DES3],[des3_encrypt])
65 AX_CHECK_NETTLE_ALGO([SERPENT],[serpent_encrypt])
66 AX_CHECK_NETTLE_ALGO([TWOFISH],[twofish_encrypt])
68 AX_CHECK_NETTLE_ALGO([MD2],[md2_digest])
69 AX_CHECK_NETTLE_ALGO([MD4],[md4_digest])
70 AX_CHECK_NETTLE_ALGO([MD5],[md5_digest])
71 AX_CHECK_NETTLE_ALGO([SHA1],[sha1_digest])
72 AX_CHECK_NETTLE_ALGO([SHA256],[sha256_digest])
75 # complain only if explicitely required
76 if test "$ax_with_nettle" = "yes" -a "x$HAVE_NETTLE" = "x" ; then
77 AC_MSG_ERROR([cannot configure required nettle library])