]> the.earth.li Git - onak.git/blob - m4/ax_lib_nettle.m4
Add libnettle autoconf checks for SHA224, SHA384 & SHA512.
[onak.git] / m4 / ax_lib_nettle.m4
1 # ===========================================================================
2 #       http://www.gnu.org/software/autoconf-archive/ax_lib_nettle.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 #   AX_LIB_NETTLE([yes|no|auto])
8 #
9 # DESCRIPTION
10 #
11 #   Searches for the 'nettle' library with the --with... option.
12 #
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
16 #   MD5 SHA1 SHA256.
17 #
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.
21 #
22 #   See also AX_LIB_BEECRYPT, AX_LIB_CRYPTO, and AX_LIB_GCRYPT.
23 #
24 # LICENSE
25 #
26 #   Copyright (c) 2009 Fabien Coelho <autoconf.archive@coelho.net>
27 #
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
31 #   warranty.
32
33 #serial 7
34
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]))
39 ])
40
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
48   ],[
49     AC_MSG_RESULT([$1])
50     ax_with_nettle=$1
51   ])
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])
56         HAVE_NETTLE=1
57         AC_SUBST([NETTLE_LIBS],[-lnettle])
58         # ciphers
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])
67         # digests
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([SHA224],[sha224_digest])
73         AX_CHECK_NETTLE_ALGO([SHA256],[sha256_digest])
74         AX_CHECK_NETTLE_ALGO([SHA384],[sha384_digest])
75         AX_CHECK_NETTLE_ALGO([SHA512],[sha512_digest])
76       ])
77     ])
78     # complain only if explicitely required
79     if test "$ax_with_nettle" = "yes" -a "x$HAVE_NETTLE" = "x" ; then
80         AC_MSG_ERROR([cannot configure required nettle library])
81     fi
82   fi
83 ])