2 AC_INIT([cryptsetup],[1.6.2-git])
4 dnl library version from <major>.<minor>.<release>[-<suffix>]
5 LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
6 LIBCRYPTSETUP_VERSION_INFO=9:0:5
7 dnl library file name for FIPS selfcheck
8 LIBCRYPTSETUP_VERSION_FIPS="libcryptsetup.so.4"
10 AC_CONFIG_SRCDIR(src/cryptsetup.c)
11 AC_CONFIG_MACRO_DIR([m4])
13 AC_CONFIG_HEADERS([config.h:config.h.in])
15 # We do not want to run test in parallel. Really.
16 # http://lists.gnu.org/archive/html/automake/2013-01/msg00060.html
18 # For old automake use this
19 #AM_INIT_AUTOMAKE(dist-bzip2)
20 AM_INIT_AUTOMAKE([dist-bzip2 1.12 serial-tests])
22 if test "x$prefix" = "xNONE"; then
25 AC_PREFIX_DEFAULT(/usr)
28 AC_USE_SYSTEM_EXTENSIONS
40 AC_CHECK_HEADERS(fcntl.h malloc.h inttypes.h sys/ioctl.h sys/mman.h \
41 ctype.h unistd.h locale.h byteswap.h endian.h)
43 AC_CHECK_HEADERS(uuid/uuid.h,,[AC_MSG_ERROR([You need the uuid library.])])
44 AC_CHECK_HEADER(libdevmapper.h,,[AC_MSG_ERROR([You need the device-mapper library.])])
47 AC_CHECK_LIB(uuid, uuid_clear, ,[AC_MSG_ERROR([You need the uuid library.])])
48 AC_SUBST(UUID_LIBS, $LIBS)
51 AC_CHECK_FUNCS([posix_memalign])
53 if test "x$enable_largefile" = "xno" ; then
54 AC_MSG_ERROR([Building with --disable-largefile is not supported, it can cause data corruption.])
62 AC_PROG_GCC_TRADITIONAL
64 dnl ==========================================================================
66 AM_GNU_GETTEXT([external],[need-ngettext])
67 AM_GNU_GETTEXT_VERSION([0.15])
69 dnl ==========================================================================
72 AC_CHECK_LIB(popt, poptConfigFileToString,,
73 [AC_MSG_ERROR([You need popt 1.7 or newer to compile.])])
74 AC_SUBST(POPT_LIBS, $LIBS)
77 dnl ==========================================================================
79 AC_ARG_ENABLE([fips], AS_HELP_STRING([--enable-fips],[enable FIPS mode restrictions]),
80 [with_fips=$enableval],
83 if test "x$with_fips" = "xyes"; then
84 AC_DEFINE(ENABLE_FIPS, 1, [Enable FIPS mode restrictions])
85 AC_DEFINE_UNQUOTED(LIBCRYPTSETUP_VERSION_FIPS, ["$LIBCRYPTSETUP_VERSION_FIPS"],
86 [library file name for FIPS selfcheck])
88 if test "x$enable_static" = "xyes" -o "x$enable_static_cryptsetup" = "xyes" ; then
89 AC_MSG_ERROR([Static build is not compatible with FIPS.])
93 AC_CHECK_LIB(fipscheck, FIPSCHECK_verify, ,[AC_MSG_ERROR([You need the fipscheck library.])])
94 AC_SUBST(FIPSCHECK_LIBS, $LIBS)
100 if test "x$with_fips" = "xyes"; then
101 AC_MSG_ERROR([This option is not compatible with FIPS.])
105 dnl ==========================================================================
106 dnl pwquality library (cryptsetup CLI only)
107 AC_ARG_ENABLE([pwquality], AS_HELP_STRING([--enable-pwquality],[enable password quality checking]),
108 [with_pwquality=$enableval],
111 if test "x$with_pwquality" = "xyes"; then
112 AC_DEFINE(ENABLE_PWQUALITY, 1, [Enable password quality checking])
113 PKG_CHECK_MODULES([PWQUALITY], [pwquality >= 1.0.0],,
114 AC_MSG_ERROR([You need pwquality library.]))
116 dnl FIXME: this is really hack for now
117 PWQUALITY_STATIC_LIBS="$PWQUALITY_LIBS -lcrack -lz"
120 dnl ==========================================================================
121 dnl Crypto backend functions
123 AC_DEFUN([CONFIGURE_GCRYPT], [
124 if test "x$with_fips" = "xyes"; then
125 GCRYPT_REQ_VERSION=1.4.5
127 GCRYPT_REQ_VERSION=1.1.42
129 dnl Check if we can use gcrypt PBKDF2 (1.6.0 supports empty password)
130 AC_ARG_ENABLE([gcrypt-pbkdf2], AS_HELP_STRING([--enable-gcrypt-pbkdf2],[force enable internal gcrypt PBKDF2]),
131 [use_internal_pbkdf2=0],
132 [AM_PATH_LIBGCRYPT([1.6.0], [use_internal_pbkdf2=0], [use_internal_pbkdf2=1])])
133 AM_PATH_LIBGCRYPT($GCRYPT_REQ_VERSION,,[AC_MSG_ERROR([You need the gcrypt library.])])
135 if test x$enable_static_cryptsetup = xyes; then
137 LIBS="$saved_LIBS $LIBGCRYPT_LIBS -static"
138 AC_CHECK_LIB(gcrypt, gcry_check_version,,
139 AC_MSG_ERROR([Cannot find static gcrypt library.]),
141 LIBGCRYPT_STATIC_LIBS="$LIBGCRYPT_LIBS -lgpg-error"
145 CRYPTO_CFLAGS=$LIBGCRYPT_CFLAGS
146 CRYPTO_LIBS=$LIBGCRYPT_LIBS
147 CRYPTO_STATIC_LIBS=$LIBGCRYPT_STATIC_LIBS
149 AC_DEFINE_UNQUOTED(GCRYPT_REQ_VERSION, ["$GCRYPT_REQ_VERSION"], [Requested gcrypt version])
152 AC_DEFUN([CONFIGURE_OPENSSL], [
153 PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8],,
154 AC_MSG_ERROR([You need openssl library.]))
155 CRYPTO_CFLAGS=$OPENSSL_CFLAGS
156 CRYPTO_LIBS=$OPENSSL_LIBS
157 use_internal_pbkdf2=0
159 if test x$enable_static_cryptsetup = xyes; then
160 saved_PKG_CONFIG=$PKG_CONFIG
161 PKG_CONFIG="$PKG_CONFIG --static"
162 PKG_CHECK_MODULES([OPENSSL], [openssl])
163 CRYPTO_STATIC_LIBS=$OPENSSL_LIBS
164 PKG_CONFIG=$saved_PKG_CONFIG
169 AC_DEFUN([CONFIGURE_NSS], [
170 if test x$enable_static_cryptsetup = xyes; then
171 AC_MSG_ERROR([Static build of cryptsetup is not supported with NSS.])
174 AC_MSG_WARN([NSS backend does NOT provide backward compatibility (missing ripemd160 hash).])
176 PKG_CHECK_MODULES([NSS], [nss],,
177 AC_MSG_ERROR([You need nss library.]))
180 CFLAGS="$CFLAGS $NSS_CFLAGS"
181 AC_CHECK_DECLS([NSS_GetVersion], [], [], [#include <nss.h>])
184 CRYPTO_CFLAGS=$NSS_CFLAGS
185 CRYPTO_LIBS=$NSS_LIBS
186 use_internal_pbkdf2=1
190 AC_DEFUN([CONFIGURE_KERNEL], [
191 AC_CHECK_HEADERS(linux/if_alg.h,,
192 [AC_MSG_ERROR([You need Linux kernel headers with userspace crypto interface.])])
193 # AC_CHECK_DECLS([AF_ALG],,
194 # [AC_MSG_ERROR([You need Linux kernel with userspace crypto interface.])],
195 # [#include <sys/socket.h>])
196 use_internal_pbkdf2=1
200 AC_DEFUN([CONFIGURE_NETTLE], [
201 AC_CHECK_HEADERS(nettle/sha.h,,
202 [AC_MSG_ERROR([You need Nettle cryptographic library.])])
205 AC_CHECK_LIB(nettle, nettle_ripemd160_init,,
206 [AC_MSG_ERROR([You need Nettle library version 2.4 or more recent.])])
210 CRYPTO_STATIC_LIBS=$CRYPTO_LIBS
211 use_internal_pbkdf2=1
215 dnl ==========================================================================
218 AC_ARG_ENABLE([static-cryptsetup],
219 AS_HELP_STRING([--enable-static-cryptsetup],
220 [enable build of static cryptsetup binary]))
221 if test x$enable_static_cryptsetup = xyes; then
222 if test x$enable_static = xno; then
223 AC_MSG_WARN([Requested static cryptsetup build, enabling static library.])
227 AM_CONDITIONAL(STATIC_TOOLS, test x$enable_static_cryptsetup = xyes)
229 AC_ARG_ENABLE(veritysetup,
230 AS_HELP_STRING([--disable-veritysetup],
231 [disable veritysetup support]),[], [enable_veritysetup=yes])
232 AM_CONDITIONAL(VERITYSETUP, test x$enable_veritysetup = xyes)
234 AC_ARG_ENABLE([cryptsetup-reencrypt],
235 AS_HELP_STRING([--enable-cryptsetup-reencrypt],
236 [enable cryptsetup-reencrypt tool]))
237 AM_CONDITIONAL(REENCRYPT, test x$enable_cryptsetup_reencrypt = xyes)
239 AC_ARG_ENABLE(selinux,
240 AS_HELP_STRING([--disable-selinux],
241 [disable selinux support [default=auto]]),[], [])
243 AC_ARG_ENABLE([udev],
244 AS_HELP_STRING([--disable-udev],
245 [disable udev support]),[], enable_udev=yes)
247 dnl Try to use pkg-config for devmapper, but fallback to old detection
248 PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.03],, [
249 AC_CHECK_LIB(devmapper, dm_task_set_name,,
250 [AC_MSG_ERROR([You need the device-mapper library.])])
251 AC_CHECK_LIB(devmapper, dm_task_set_message,,
252 [AC_MSG_ERROR([The device-mapper library on your system is too old.])])
257 LIBS="$LIBS $DEVMAPPER_LIBS"
258 AC_CHECK_DECLS([dm_task_secure_data], [], [], [#include <libdevmapper.h>])
259 AC_CHECK_DECLS([dm_task_retry_remove], [], [], [#include <libdevmapper.h>])
260 AC_CHECK_DECLS([DM_UDEV_DISABLE_DISK_RULES_FLAG], [have_cookie=yes], [have_cookie=no], [#include <libdevmapper.h>])
261 if test "x$enable_udev" = xyes; then
262 if test "x$have_cookie" = xno; then
263 AC_MSG_WARN([The device-mapper library on your system has no udev support, udev support disabled.])
265 AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
270 dnl Crypto backend configuration.
271 AC_ARG_WITH([crypto_backend],
272 AS_HELP_STRING([--with-crypto_backend=BACKEND], [crypto backend (gcrypt/openssl/nss/kernel/nettle) [gcrypt]]),
273 [], with_crypto_backend=gcrypt
276 dnl Kernel crypto API backend needed for benchmark and tcrypt
277 AC_ARG_ENABLE([kernel_crypto], AS_HELP_STRING([--disable-kernel_crypto],
278 [disable kernel userspace crypto (no benchmark and tcrypt)]),
279 [with_kernel_crypto=$enableval],
280 [with_kernel_crypto=yes])
282 if test "x$with_kernel_crypto" = "xyes"; then
283 AC_CHECK_HEADERS(linux/if_alg.h,,
284 [AC_MSG_ERROR([You need Linux kernel headers with userspace crypto interface. (Or use --disable-kernel_crypto.)])])
285 AC_DEFINE(ENABLE_AF_ALG, 1, [Enable using of kernel userspace crypto])
288 case $with_crypto_backend in
289 gcrypt) CONFIGURE_GCRYPT([]) ;;
290 openssl) CONFIGURE_OPENSSL([]) ;;
291 nss) CONFIGURE_NSS([]) ;;
292 kernel) CONFIGURE_KERNEL([]) ;;
293 nettle) CONFIGURE_NETTLE([]) ;;
294 *) AC_MSG_ERROR([Unknown crypto backend.]) ;;
296 AM_CONDITIONAL(CRYPTO_BACKEND_GCRYPT, test $with_crypto_backend = gcrypt)
297 AM_CONDITIONAL(CRYPTO_BACKEND_OPENSSL, test $with_crypto_backend = openssl)
298 AM_CONDITIONAL(CRYPTO_BACKEND_NSS, test $with_crypto_backend = nss)
299 AM_CONDITIONAL(CRYPTO_BACKEND_KERNEL, test $with_crypto_backend = kernel)
300 AM_CONDITIONAL(CRYPTO_BACKEND_NETTLE, test $with_crypto_backend = nettle)
302 AM_CONDITIONAL(CRYPTO_INTERNAL_PBKDF2, test $use_internal_pbkdf2 = 1)
303 AC_DEFINE_UNQUOTED(USE_INTERNAL_PBKDF2, [$use_internal_pbkdf2], [Use internal PBKDF2])
305 dnl Magic for cryptsetup.static build.
306 if test x$enable_static_cryptsetup = xyes; then
307 saved_PKG_CONFIG=$PKG_CONFIG
308 PKG_CONFIG="$PKG_CONFIG --static"
310 LIBS="$saved_LIBS -static"
311 AC_CHECK_LIB(popt, poptGetContext,,
312 AC_MSG_ERROR([Cannot find static popt library.]))
314 dnl Try to detect needed device-mapper static libraries, try pkg-config first.
315 LIBS="$saved_LIBS -static"
316 PKG_CHECK_MODULES([DEVMAPPER_STATIC], [devmapper >= 1.02.27],,[
317 DEVMAPPER_STATIC_LIBS=$DEVMAPPER_LIBS
318 if test "x$enable_selinux" != xno; then
319 AC_CHECK_LIB(sepol, sepol_bool_set)
320 AC_CHECK_LIB(selinux, is_selinux_enabled)
321 DEVMAPPER_STATIC_LIBS="$DEVMAPPER_STATIC_LIBS $LIBS"
324 LIBS="$saved_LIBS $DEVMAPPER_STATIC_LIBS"
325 AC_CHECK_LIB(devmapper, dm_task_set_uuid,,
326 AC_MSG_ERROR([Cannot link with static device-mapper library.]))
328 dnl Try to detect uuid static library.
329 LIBS="$saved_LIBS -static"
330 AC_CHECK_LIB(uuid, uuid_generate,,
331 AC_MSG_ERROR([Cannot find static uuid library.]))
334 PKG_CONFIG=$saved_PKG_CONFIG
337 AC_SUBST([DEVMAPPER_LIBS])
338 AC_SUBST([DEVMAPPER_STATIC_LIBS])
340 AC_SUBST([PWQUALITY_LIBS])
341 AC_SUBST([PWQUALITY_STATIC_LIBS])
343 AC_SUBST([CRYPTO_CFLAGS])
344 AC_SUBST([CRYPTO_LIBS])
345 AC_SUBST([CRYPTO_STATIC_LIBS])
347 AC_SUBST([LIBCRYPTSETUP_VERSION])
348 AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
349 AC_SUBST([LIBCRYPTSETUP_VERSION_FIPS])
351 dnl ==========================================================================
352 AC_ARG_ENABLE([dev-random], AS_HELP_STRING([--enable-dev-random],
353 [use blocking /dev/random by default for key generator (otherwise use /dev/urandom)]),
354 [default_rng=/dev/random], [default_rng=/dev/urandom])
355 AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])
357 dnl ==========================================================================
358 AC_DEFUN([CS_DEFINE],
359 [AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
362 AC_DEFUN([CS_STR_WITH], [AC_ARG_WITH([$1],
363 [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
364 [CS_DEFINE([$1], ["$withval"], [$2])],
365 [CS_DEFINE([$1], ["$3"], [$2])]
368 AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
369 [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
370 [CS_DEFINE([$1], [$withval], [$2])],
371 [CS_DEFINE([$1], [$3], [$2])]
374 dnl ==========================================================================
376 AC_ARG_ENABLE([python], AS_HELP_STRING([--enable-python],[enable Python bindings]),
377 [with_python=$enableval],
380 if test "x$with_python" = "xyes"; then
381 AM_PATH_PYTHON([2.4])
383 if ! test -x "$PYTHON-config" ; then
384 AC_MSG_ERROR([Cannot find python development packages to build bindings])
387 PYTHON_INCLUDES=$($PYTHON-config --includes)
388 AC_SUBST(PYTHON_INCLUDES)
390 AM_CONDITIONAL([PYTHON_CRYPTSETUP], [test "x$with_python" = "xyes"])
392 dnl ==========================================================================
393 CS_STR_WITH([plain-hash], [password hashing function for plain mode], [ripemd160])
394 CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
395 CS_STR_WITH([plain-mode], [cipher mode for plain mode], [cbc-essiv:sha256])
396 CS_NUM_WITH([plain-keybits],[key length in bits for plain mode], [256])
398 CS_STR_WITH([luks1-hash], [hash function for LUKS1 header], [sha1])
399 CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes])
400 CS_STR_WITH([luks1-mode], [cipher mode for LUKS1], [xts-plain64])
401 CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
402 CS_NUM_WITH([luks1-iter-time],[PBKDF2 iteration time for LUKS1 (in ms)], [1000])
404 CS_STR_WITH([loopaes-cipher], [cipher for loop-AES mode], [aes])
405 CS_NUM_WITH([loopaes-keybits],[key length in bits for loop-AES mode], [256])
407 CS_NUM_WITH([keyfile-size-maxkb],[maximum keyfile size (in KiB)], [8192])
408 CS_NUM_WITH([passphrase-size-max],[maximum keyfile size (in characters)], [512])
410 CS_STR_WITH([verity-hash], [hash function for verity mode], [sha256])
411 CS_NUM_WITH([verity-data-block], [data block size for verity mode], [4096])
412 CS_NUM_WITH([verity-hash-block], [hash block size for verity mode], [4096])
413 CS_NUM_WITH([verity-salt-size], [salt size for verity mode], [32])
415 dnl ==========================================================================
417 AC_CONFIG_FILES([ Makefile
420 lib/crypto_backend/Makefile