2 AC_INIT([cryptsetup],[1.3.2-cvs])
4 dnl library version from <major>.<minor>.<release>[-<suffix>]
5 LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
6 LIBCRYPTSETUP_VERSION_INFO=3:0:2
8 AC_CONFIG_SRCDIR(src/cryptsetup.c)
9 AC_CONFIG_MACRO_DIR([m4])
11 AC_CONFIG_HEADERS([config.h:config.h.in])
12 AM_INIT_AUTOMAKE(dist-bzip2)
14 if test "x$prefix" = "xNONE"; then
17 AC_PREFIX_DEFAULT(/usr)
20 AC_USE_SYSTEM_EXTENSIONS
31 AC_CHECK_HEADERS(fcntl.h malloc.h inttypes.h sys/ioctl.h sys/mman.h \
32 ctype.h unistd.h locale.h)
34 AC_CHECK_HEADERS(uuid/uuid.h,,[AC_MSG_ERROR('You need the uuid library')])
35 AC_CHECK_HEADER(libdevmapper.h,,[AC_MSG_ERROR('You need the device-mapper library')])
38 AC_CHECK_LIB(uuid, uuid_clear, ,[AC_MSG_ERROR('You need the uuid library')])
39 AC_SUBST(UUID_LIBS, $LIBS)
42 AC_CHECK_FUNCS([posix_memalign])
49 AC_PROG_GCC_TRADITIONAL
51 dnl ==========================================================================
53 AM_GNU_GETTEXT([external],[need-ngettext])
54 AM_GNU_GETTEXT_VERSION([0.15])
56 dnl ==========================================================================
59 AC_CHECK_LIB(popt, poptConfigFileToString,,
60 [AC_MSG_ERROR([You need popt 1.7 or newer to compile.])])
61 AC_SUBST(POPT_LIBS, $LIBS)
64 dnl ==========================================================================
65 dnl Crypto backend functions
67 AC_DEFUN([CONFIGURE_GCRYPT], [
68 AM_PATH_LIBGCRYPT(1.1.42,,[AC_MSG_ERROR('You need the gcrypt library')])
70 if test x$enable_static_cryptsetup = xyes; then
72 LIBS="$saved_LIBS $LIBGCRYPT_LIBS -static"
73 AC_CHECK_LIB(gcrypt, gcry_check_version,,
74 AC_MSG_ERROR([Cannot find static gcrypt library.]),
76 LIBGCRYPT_STATIC_LIBS="$LIBGCRYPT_LIBS -lgpg-error"
80 CRYPTO_CFLAGS=$LIBGCRYPT_CFLAGS
81 CRYPTO_LIBS=$LIBGCRYPT_LIBS
82 CRYPTO_STATIC_LIBS=$LIBGCRYPT_STATIC_LIBS
85 AC_DEFUN([CONFIGURE_OPENSSL], [
86 PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8],,
87 AC_MSG_ERROR('You need openssl library'))
88 CRYPTO_CFLAGS=$OPENSSL_CFLAGS
89 CRYPTO_LIBS=$OPENSSL_LIBS
91 if test x$enable_static_cryptsetup = xyes; then
92 saved_PKG_CONFIG=$PKG_CONFIG
93 PKG_CONFIG="$PKG_CONFIG --static"
94 PKG_CHECK_MODULES([OPENSSL], [openssl])
95 CRYPTO_STATIC_LIBS=$OPENSSL_LIBS
96 PKG_CONFIG=$saved_PKG_CONFIG
100 AC_DEFUN([CONFIGURE_NSS], [
101 if test x$enable_static_cryptsetup = xyes; then
102 AC_MSG_ERROR([Static build of cryptsetup is not supported with NSS.]),
105 AC_MSG_WARN([NSS backend does NOT provide backward compatibility (missing ripemd160 hash).])
107 PKG_CHECK_MODULES([NSS], [nss],,
108 AC_MSG_ERROR('You need nss library'))
109 CRYPTO_CFLAGS=$NSS_CFLAGS
110 CRYPTO_LIBS=$NSS_LIBS
113 AC_DEFUN([CONFIGURE_KERNEL], [
114 AC_CHECK_HEADERS(linux/if_alg.h,,
115 [AC_MSG_ERROR('You need Linux kernel with userspace crypto interface.')])
116 # AC_CHECK_DECLS([AF_ALG],,
117 # [AC_MSG_ERROR('You need Linux kernel with userspace crypto interface.')],
118 # [#include <sys/socket.h>])
122 AC_DEFUN([CONFIGURE_NETTLE], [
123 AC_CHECK_HEADERS(nettle/sha.h,,
124 [AC_MSG_ERROR('You need Nettle cryptographic library.')])
127 AC_CHECK_LIB(nettle, nettle_sha512_init,,
128 [AC_MSG_ERROR('You need Nettle library version 2.1 or more recent.')])
132 AC_MSG_WARN([Nettle backend does NOT provide backward compatibility (missing ripemd160 hash).])
134 CRYPTO_STATIC_LIBS=$CRYPTO_LIBS
137 dnl ==========================================================================
140 AC_ARG_ENABLE([static-cryptsetup],
141 AS_HELP_STRING([--enable-static-cryptsetup],
142 [enable build of static cryptsetup binary]))
143 if test x$enable_static_cryptsetup = xyes; then
144 if test x$enable_static = xno; then
145 AC_MSG_WARN([Requested static cryptsetup build, enabling static library.])
149 AM_CONDITIONAL(STATIC_CRYPTSETUP, test x$enable_static_cryptsetup = xyes)
151 AC_ARG_ENABLE(selinux,
152 AS_HELP_STRING([--disable-selinux],
153 [disable selinux support [default=auto]]),[], [])
155 AC_ARG_ENABLE([udev],
156 AS_HELP_STRING([--disable-udev],
157 [disable udev support]),[], enable_udev=yes)
159 dnl Try to use pkg-config for devmapper, but fallback to old detection
160 PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.03],, [
161 AC_CHECK_LIB(devmapper, dm_task_set_name,,
162 [AC_MSG_ERROR([You need the device-mapper library.])])
163 AC_CHECK_LIB(devmapper, dm_task_set_message,,
164 [AC_MSG_ERROR([The device-mapper library on your system is too old.])])
169 LIBS="$LIBS $DEVMAPPER_LIBS"
170 AC_CHECK_DECLS([dm_task_secure_data], [], [], [#include <libdevmapper.h>])
171 AC_CHECK_DECLS([DM_UDEV_DISABLE_DISK_RULES_FLAG], [have_cookie=yes], [have_cookie=no], [#include <libdevmapper.h>])
172 if test "x$enable_udev" = xyes; then
173 if test "x$have_cookie" = xno; then
174 AC_MSG_WARN([The device-mapper library on your system has no udev support, udev support disabled.])
176 AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
181 dnl Crypto backend configuration.
182 AC_ARG_WITH([crypto_backend],
183 AS_HELP_STRING([--with-crypto_backend=BACKEND], [crypto backend (gcrypt/openssl/nss/kernel/nettle) [gcrypt]]),
184 [], with_crypto_backend=gcrypt
186 case $with_crypto_backend in
187 gcrypt) CONFIGURE_GCRYPT([]) ;;
188 openssl) CONFIGURE_OPENSSL([]) ;;
189 nss) CONFIGURE_NSS([]) ;;
190 kernel) CONFIGURE_KERNEL([]) ;;
191 nettle) CONFIGURE_NETTLE([]) ;;
192 *) AC_MSG_ERROR([Unknown crypto backend.]) ;;
194 AM_CONDITIONAL(CRYPTO_BACKEND_GCRYPT, test $with_crypto_backend = gcrypt)
195 AM_CONDITIONAL(CRYPTO_BACKEND_OPENSSL, test $with_crypto_backend = openssl)
196 AM_CONDITIONAL(CRYPTO_BACKEND_NSS, test $with_crypto_backend = nss)
197 AM_CONDITIONAL(CRYPTO_BACKEND_KERNEL, test $with_crypto_backend = kernel)
198 AM_CONDITIONAL(CRYPTO_BACKEND_NETTLE, test $with_crypto_backend = nettle)
200 dnl Magic for cryptsetup.static build.
201 if test x$enable_static_cryptsetup = xyes; then
202 saved_PKG_CONFIG=$PKG_CONFIG
203 PKG_CONFIG="$PKG_CONFIG --static"
205 LIBS="$saved_LIBS -static"
206 AC_CHECK_LIB(popt, poptGetContext,,
207 AC_MSG_ERROR([Cannot find static popt library.]))
209 dnl Try to detect needed device-mapper static libraries, try pkg-config first.
210 LIBS="$saved_LIBS -static"
211 PKG_CHECK_MODULES([DEVMAPPER_STATIC], [devmapper >= 1.02.27],,[
212 DEVMAPPER_STATIC_LIBS=$DEVMAPPER_LIBS
213 if test "x$enable_selinux" != xno; then
214 AC_CHECK_LIB(sepol, sepol_bool_set)
215 AC_CHECK_LIB(selinux, is_selinux_enabled)
216 DEVMAPPER_STATIC_LIBS="$DEVMAPPER_STATIC_LIBS $LIBS"
219 LIBS="$saved_LIBS $DEVMAPPER_STATIC_LIBS"
220 AC_CHECK_LIB(devmapper, dm_task_set_uuid,,
221 AC_MSG_ERROR([Cannot link with static device-mapper library.]))
224 PKG_CONFIG=$saved_PKG_CONFIG
227 AC_SUBST([DEVMAPPER_LIBS])
228 AC_SUBST([DEVMAPPER_STATIC_LIBS])
230 AC_SUBST([CRYPTO_CFLAGS])
231 AC_SUBST([CRYPTO_LIBS])
232 AC_SUBST([CRYPTO_STATIC_LIBS])
234 AC_SUBST([LIBCRYPTSETUP_VERSION])
235 AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
237 dnl ==========================================================================
238 AC_ARG_ENABLE([dev-random], AS_HELP_STRING([--enable-dev-random],
239 [use blocking /dev/random by default for key generator (otherwise use /dev/urandom)]),
240 [default_rng=/dev/random], [default_rng=/dev/urandom])
241 AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])
243 dnl ==========================================================================
244 AC_DEFUN([CS_DEFINE],
245 [AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
248 AC_DEFUN([CS_STR_WITH], [AC_ARG_WITH([$1],
249 [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
250 [CS_DEFINE([$1], ["$withval"], [$2])],
251 [CS_DEFINE([$1], ["$3"], [$2])]
254 AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
255 [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
256 [CS_DEFINE([$1], [$withval], [$2])],
257 [CS_DEFINE([$1], [$3], [$2])]
260 CS_STR_WITH([plain-hash], [password hashing function for plain mode], [ripemd160])
261 CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
262 CS_STR_WITH([plain-mode], [cipher mode for plain mode], [cbc-essiv:sha256])
263 CS_NUM_WITH([plain-keybits],[key length in bits for plain mode], [256])
265 CS_STR_WITH([luks1-hash], [hash function for LUKS1 header], [sha1])
266 CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes])
267 CS_STR_WITH([luks1-mode], [cipher mode for LUKS1], [cbc-essiv:sha256])
268 CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
270 CS_STR_WITH([loopaes-cipher], [cipher for loop-AES mode], [aes])
271 CS_NUM_WITH([loopaes-keybits],[key length in bits for loop-AES mode], [256])
273 CS_NUM_WITH([keyfile-size-maxkb],[maximum keyfile size (in kilobytes)], [8192])
274 CS_NUM_WITH([passphrase-size-max],[maximum keyfile size (in kilobytes)], [512])
276 dnl ==========================================================================
278 AC_CONFIG_FILES([ Makefile
281 lib/crypto_backend/Makefile