2 AC_INIT([cryptsetup],[2.3.7])
4 dnl library version from <major>.<minor>.<release>[-<suffix>]
5 LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
6 LIBCRYPTSETUP_VERSION_INFO=18:0:6
9 AC_CONFIG_SRCDIR(src/cryptsetup.c)
10 AC_CONFIG_MACRO_DIR([m4])
12 AC_CONFIG_HEADERS([config.h:config.h.in])
14 # We do not want to run test in parallel. Really.
15 # http://lists.gnu.org/archive/html/automake/2013-01/msg00060.html
17 # For old automake use this
18 #AM_INIT_AUTOMAKE(dist-xz subdir-objects)
19 AM_INIT_AUTOMAKE([dist-xz 1.12 serial-tests subdir-objects])
21 if test "x$prefix" = "xNONE"; then
24 AC_PREFIX_DEFAULT(/usr)
27 AC_USE_SYSTEM_EXTENSIONS
38 dnl ==========================================================================
39 dnl define PKG_CHECK_VAR for old pkg-config <= 0.28
40 m4_ifndef([AS_VAR_COPY],
41 [m4_define([AS_VAR_COPY],
42 [AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
44 m4_ifndef([PKG_CHECK_VAR], [
45 AC_DEFUN([PKG_CHECK_VAR],
46 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])
47 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])
49 _PKG_CONFIG([$1], [variable="][$3]["], [$2])
50 AS_VAR_COPY([$1], [pkg_cv_][$1])
52 AS_VAR_IF([$1], [""], [$5], [$4])
55 dnl ==========================================================================
60 AC_CHECK_HEADERS(fcntl.h malloc.h inttypes.h sys/ioctl.h sys/mman.h \
61 sys/sysmacros.h sys/statvfs.h ctype.h unistd.h locale.h byteswap.h endian.h stdint.h)
62 AC_CHECK_DECLS([O_CLOEXEC],,[AC_DEFINE([O_CLOEXEC],[0], [Defined to 0 if not provided])],
69 AC_CHECK_HEADERS(uuid/uuid.h,,[AC_MSG_ERROR([You need the uuid library.])])
70 AC_CHECK_HEADER(libdevmapper.h,,[AC_MSG_ERROR([You need the device-mapper library.])])
72 AC_ARG_ENABLE([keyring],
73 AS_HELP_STRING([--disable-keyring], [disable kernel keyring support and builtin kernel keyring token]),
74 [], [enable_keyring=yes])
75 if test "x$enable_keyring" = "xyes"; then
76 AC_CHECK_HEADERS(linux/keyctl.h,,[AC_MSG_ERROR([You need Linux kernel headers with kernel keyring service compiled.])])
78 dnl ==========================================================================
79 dnl check whether kernel is compiled with kernel keyring service syscalls
80 AC_CHECK_DECL(__NR_add_key,,[AC_MSG_ERROR([The kernel is missing add_key syscall.])], [#include <syscall.h>])
81 AC_CHECK_DECL(__NR_keyctl,,[AC_MSG_ERROR([The kernel is missing keyctl syscall.])], [#include <syscall.h>])
82 AC_CHECK_DECL(__NR_request_key,,[AC_MSG_ERROR([The kernel is missing request_key syscall.])], [#include <syscall.h>])
84 dnl ==========================================================================
85 dnl check that key_serial_t hasn't been adopted yet in stdlib
86 AC_CHECK_TYPES([key_serial_t], [], [], [
88 #ifdef HAVE_LINUX_KEYCTL_H
89 # include <linux/keyctl.h>
93 AC_DEFINE(KERNEL_KEYRING, 1, [Enable kernel keyring service support])
95 AM_CONDITIONAL(KERNEL_KEYRING, test "x$enable_keyring" = "xyes")
98 AC_CHECK_LIB(uuid, uuid_clear, ,[AC_MSG_ERROR([You need the uuid library.])])
99 AC_SUBST(UUID_LIBS, $LIBS)
102 AC_SEARCH_LIBS([clock_gettime],[rt posix4])
103 AC_CHECK_FUNCS([posix_memalign clock_gettime posix_fallocate explicit_bzero])
105 if test "x$enable_largefile" = "xno"; then
106 AC_MSG_ERROR([Building with --disable-largefile is not supported, it can cause data corruption.])
114 AC_PROG_GCC_TRADITIONAL
117 dnl ==========================================================================
119 AM_GNU_GETTEXT([external],[need-ngettext])
120 AM_GNU_GETTEXT_VERSION([0.18.3])
122 dnl ==========================================================================
125 AC_CHECK_LIB(popt, poptConfigFileToString,,
126 [AC_MSG_ERROR([You need popt 1.7 or newer to compile.])])
127 AC_SUBST(POPT_LIBS, $LIBS)
130 dnl ==========================================================================
132 AC_ARG_ENABLE([fips],
133 AS_HELP_STRING([--enable-fips], [enable FIPS mode restrictions]))
134 if test "x$enable_fips" = "xyes"; then
135 AC_DEFINE(ENABLE_FIPS, 1, [Enable FIPS mode restrictions])
137 if test "x$enable_static" = "xyes" -o "x$enable_static_cryptsetup" = "xyes" ; then
138 AC_MSG_ERROR([Static build is not compatible with FIPS.])
142 AC_DEFUN([NO_FIPS], [
143 if test "x$enable_fips" = "xyes"; then
144 AC_MSG_ERROR([This option is not compatible with FIPS.])
148 dnl LUKS2 online reencryption
149 AC_ARG_ENABLE([luks2-reencryption],
150 AS_HELP_STRING([--disable-luks2-reencryption], [disable LUKS2 online reencryption extension]),
151 [], [enable_luks2_reencryption=yes])
152 if test "x$enable_luks2_reencryption" = "xyes"; then
153 AC_DEFINE(USE_LUKS2_REENCRYPTION, 1, [Use LUKS2 online reencryption extension])
156 dnl ==========================================================================
157 dnl pwquality library (cryptsetup CLI only)
158 AC_ARG_ENABLE([pwquality],
159 AS_HELP_STRING([--enable-pwquality], [enable password quality checking using pwquality library]))
161 if test "x$enable_pwquality" = "xyes"; then
162 AC_DEFINE(ENABLE_PWQUALITY, 1, [Enable password quality checking using pwquality library])
163 PKG_CHECK_MODULES([PWQUALITY], [pwquality >= 1.0.0],,
164 AC_MSG_ERROR([You need pwquality library.]))
166 dnl FIXME: this is really hack for now
167 PWQUALITY_STATIC_LIBS="$PWQUALITY_LIBS -lcrack -lz"
170 dnl ==========================================================================
171 dnl passwdqc library (cryptsetup CLI only)
172 AC_ARG_ENABLE([passwdqc],
173 AS_HELP_STRING([--enable-passwdqc@<:@=CONFIG_PATH@:>@],
174 [enable password quality checking using passwdqc library (optionally with CONFIG_PATH)]))
176 case "$enable_passwdqc" in
177 ""|yes|no) use_passwdqc_config="" ;;
178 /*) use_passwdqc_config="$enable_passwdqc"; enable_passwdqc=yes ;;
179 *) AC_MSG_ERROR([Unrecognized --enable-passwdqc parameter.]) ;;
181 AC_DEFINE_UNQUOTED([PASSWDQC_CONFIG_FILE], ["$use_passwdqc_config"], [passwdqc library config file])
183 if test "x$enable_passwdqc" = "xyes"; then
184 AC_DEFINE(ENABLE_PASSWDQC, 1, [Enable password quality checking using passwdqc library])
187 AC_SEARCH_LIBS([passwdqc_check], [passwdqc])
188 case "$ac_cv_search_passwdqc_check" in
189 no) AC_MSG_ERROR([failed to find passwdqc_check]) ;;
190 -l*) PASSWDQC_LIBS="$ac_cv_search_passwdqc_check" ;;
193 AC_CHECK_FUNCS([passwdqc_params_free])
197 if test "x$enable_pwquality$enable_passwdqc" = "xyesyes"; then
198 AC_MSG_ERROR([--enable-pwquality and --enable-passwdqc are mutually incompatible.])
201 dnl ==========================================================================
202 dnl Crypto backend functions
204 AC_DEFUN([CONFIGURE_GCRYPT], [
205 if test "x$enable_fips" = "xyes"; then
206 GCRYPT_REQ_VERSION=1.4.5
208 GCRYPT_REQ_VERSION=1.1.42
211 dnl libgcrypt rejects to use pkgconfig, use AM_PATH_LIBGCRYPT from gcrypt-devel here.
212 dnl Do not require gcrypt-devel if other crypto backend is used.
213 m4_ifdef([AM_PATH_LIBGCRYPT],[
214 AC_ARG_ENABLE([gcrypt-pbkdf2],
215 dnl Check if we can use gcrypt PBKDF2 (1.6.0 supports empty password)
216 AS_HELP_STRING([--enable-gcrypt-pbkdf2], [force enable internal gcrypt PBKDF2]),
217 if test "x$enableval" = "xyes"; then
218 [use_internal_pbkdf2=0]
220 [use_internal_pbkdf2=1]
222 [AM_PATH_LIBGCRYPT([1.6.1], [use_internal_pbkdf2=0], [use_internal_pbkdf2=1])])
223 AM_PATH_LIBGCRYPT($GCRYPT_REQ_VERSION,,[AC_MSG_ERROR([You need the gcrypt library.])])],
224 AC_MSG_ERROR([Missing support for gcrypt: install gcrypt and regenerate configure.]))
226 AC_MSG_CHECKING([if internal cryptsetup PBKDF2 is compiled-in])
227 if test $use_internal_pbkdf2 = 0; then
234 AC_CHECK_DECLS([GCRY_CIPHER_MODE_XTS], [], [], [#include <gcrypt.h>])
236 if test "x$enable_static_cryptsetup" = "xyes"; then
238 LIBS="$saved_LIBS $LIBGCRYPT_LIBS -static"
239 AC_CHECK_LIB(gcrypt, gcry_check_version,,
240 AC_MSG_ERROR([Cannot find static gcrypt library.]),
242 LIBGCRYPT_STATIC_LIBS="$LIBGCRYPT_LIBS -lgpg-error"
246 CRYPTO_CFLAGS=$LIBGCRYPT_CFLAGS
247 CRYPTO_LIBS=$LIBGCRYPT_LIBS
248 CRYPTO_STATIC_LIBS=$LIBGCRYPT_STATIC_LIBS
250 AC_DEFINE_UNQUOTED(GCRYPT_REQ_VERSION, ["$GCRYPT_REQ_VERSION"], [Requested gcrypt version])
253 AC_DEFUN([CONFIGURE_OPENSSL], [
254 PKG_CHECK_MODULES([OPENSSL], [openssl1.1 >= 0.9.8],,
255 AC_MSG_ERROR([You need openssl library.]))
256 CRYPTO_CFLAGS=$OPENSSL_CFLAGS
257 CRYPTO_LIBS=$OPENSSL_LIBS
258 use_internal_pbkdf2=0
260 if test "x$enable_static_cryptsetup" = "xyes"; then
261 saved_PKG_CONFIG=$PKG_CONFIG
262 PKG_CONFIG="$PKG_CONFIG --static"
263 PKG_CHECK_MODULES([OPENSSL_STATIC], [openssl])
264 CRYPTO_STATIC_LIBS=$OPENSSL_STATIC_LIBS
265 PKG_CONFIG=$saved_PKG_CONFIG
269 AC_DEFUN([CONFIGURE_NSS], [
270 if test "x$enable_static_cryptsetup" = "xyes"; then
271 AC_MSG_ERROR([Static build of cryptsetup is not supported with NSS.])
274 AC_MSG_WARN([NSS backend does NOT provide backward compatibility (missing ripemd160 hash).])
276 PKG_CHECK_MODULES([NSS], [nss],,
277 AC_MSG_ERROR([You need nss library.]))
280 CFLAGS="$CFLAGS $NSS_CFLAGS"
281 AC_CHECK_DECLS([NSS_GetVersion], [], [], [#include <nss.h>])
284 CRYPTO_CFLAGS=$NSS_CFLAGS
285 CRYPTO_LIBS=$NSS_LIBS
286 use_internal_pbkdf2=1
290 AC_DEFUN([CONFIGURE_KERNEL], [
291 AC_CHECK_HEADERS(linux/if_alg.h,,
292 [AC_MSG_ERROR([You need Linux kernel headers with userspace crypto interface.])])
293 # AC_CHECK_DECLS([AF_ALG],,
294 # [AC_MSG_ERROR([You need Linux kernel with userspace crypto interface.])],
295 # [#include <sys/socket.h>])
296 use_internal_pbkdf2=1
300 AC_DEFUN([CONFIGURE_NETTLE], [
301 AC_CHECK_HEADERS(nettle/sha.h,,
302 [AC_MSG_ERROR([You need Nettle cryptographic library.])])
303 AC_CHECK_HEADERS(nettle/version.h)
306 AC_CHECK_LIB(nettle, nettle_pbkdf2_hmac_sha256,,
307 [AC_MSG_ERROR([You need Nettle library version 2.6 or more recent.])])
311 CRYPTO_STATIC_LIBS=$CRYPTO_LIBS
312 use_internal_pbkdf2=0
316 dnl ==========================================================================
319 AC_ARG_ENABLE([static-cryptsetup],
320 AS_HELP_STRING([--enable-static-cryptsetup], [enable build of static version of tools]))
321 if test "x$enable_static_cryptsetup" = "xyes"; then
322 if test "x$enable_static" = "xno"; then
323 AC_MSG_WARN([Requested static cryptsetup build, enabling static library.])
327 AM_CONDITIONAL(STATIC_TOOLS, test "x$enable_static_cryptsetup" = "xyes")
329 AC_ARG_ENABLE([cryptsetup],
330 AS_HELP_STRING([--disable-cryptsetup], [disable cryptsetup support]),
331 [], [enable_cryptsetup=yes])
332 AM_CONDITIONAL(CRYPTSETUP, test "x$enable_cryptsetup" = "xyes")
334 AC_ARG_ENABLE([veritysetup],
335 AS_HELP_STRING([--disable-veritysetup], [disable veritysetup support]),
336 [], [enable_veritysetup=yes])
337 AM_CONDITIONAL(VERITYSETUP, test "x$enable_veritysetup" = "xyes")
339 AC_ARG_ENABLE([cryptsetup-reencrypt],
340 AS_HELP_STRING([--disable-cryptsetup-reencrypt], [disable cryptsetup-reencrypt tool]),
341 [], [enable_cryptsetup_reencrypt=yes])
342 AM_CONDITIONAL(REENCRYPT, test "x$enable_cryptsetup_reencrypt" = "xyes")
344 AC_ARG_ENABLE([integritysetup],
345 AS_HELP_STRING([--disable-integritysetup], [disable integritysetup support]),
346 [], [enable_integritysetup=yes])
347 AM_CONDITIONAL(INTEGRITYSETUP, test "x$enable_integritysetup" = "xyes")
349 AC_ARG_ENABLE([selinux],
350 AS_HELP_STRING([--disable-selinux], [disable selinux support [default=auto]]),
351 [], [enable_selinux=yes])
353 AC_ARG_ENABLE([udev],
354 AS_HELP_STRING([--disable-udev], [disable udev support]),
355 [], [enable_udev=yes])
357 dnl Try to use pkg-config for devmapper, but fallback to old detection
358 PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.03],, [
359 AC_CHECK_LIB(devmapper, dm_task_set_name,,
360 [AC_MSG_ERROR([You need the device-mapper library.])])
361 AC_CHECK_LIB(devmapper, dm_task_set_message,,
362 [AC_MSG_ERROR([The device-mapper library on your system is too old.])])
367 LIBS="$LIBS $DEVMAPPER_LIBS"
368 AC_CHECK_DECLS([dm_task_secure_data], [], [], [#include <libdevmapper.h>])
369 AC_CHECK_DECLS([dm_task_retry_remove], [], [], [#include <libdevmapper.h>])
370 AC_CHECK_DECLS([dm_task_deferred_remove], [], [], [#include <libdevmapper.h>])
371 AC_CHECK_DECLS([dm_device_has_mounted_fs], [], [], [#include <libdevmapper.h>])
372 AC_CHECK_DECLS([dm_device_has_holders], [], [], [#include <libdevmapper.h>])
373 AC_CHECK_DECLS([dm_device_get_name], [], [], [#include <libdevmapper.h>])
374 AC_CHECK_DECLS([DM_DEVICE_GET_TARGET_VERSION], [], [], [#include <libdevmapper.h>])
375 AC_CHECK_DECLS([DM_UDEV_DISABLE_DISK_RULES_FLAG], [have_cookie=yes], [have_cookie=no], [#include <libdevmapper.h>])
376 if test "x$enable_udev" = xyes; then
377 if test "x$have_cookie" = xno; then
378 AC_MSG_WARN([The device-mapper library on your system has no udev support, udev support disabled.])
380 AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
385 dnl Check for JSON-C used in LUKS2
386 PKG_CHECK_MODULES([JSON_C], [json-c])
387 AC_CHECK_DECLS([json_object_object_add_ex], [], [], [#include <json-c/json.h>])
388 AC_CHECK_DECLS([json_object_deep_copy], [], [], [#include <json-c/json.h>])
390 dnl Crypto backend configuration.
391 AC_ARG_WITH([crypto_backend],
392 AS_HELP_STRING([--with-crypto_backend=BACKEND], [crypto backend (gcrypt/openssl/nss/kernel/nettle) [openssl]]),
393 [], [with_crypto_backend=openssl])
395 dnl Kernel crypto API backend needed for benchmark and tcrypt
396 AC_ARG_ENABLE([kernel_crypto],
397 AS_HELP_STRING([--disable-kernel_crypto], [disable kernel userspace crypto (no benchmark and tcrypt)]),
398 [], [enable_kernel_crypto=yes])
400 if test "x$enable_kernel_crypto" = "xyes"; then
401 AC_CHECK_HEADERS(linux/if_alg.h,,
402 [AC_MSG_ERROR([You need Linux kernel headers with userspace crypto interface. (Or use --disable-kernel_crypto.)])])
403 AC_DEFINE(ENABLE_AF_ALG, 1, [Enable using of kernel userspace crypto])
406 case $with_crypto_backend in
407 gcrypt) CONFIGURE_GCRYPT([]) ;;
408 openssl) CONFIGURE_OPENSSL([]) ;;
409 nss) CONFIGURE_NSS([]) ;;
410 kernel) CONFIGURE_KERNEL([]) ;;
411 nettle) CONFIGURE_NETTLE([]) ;;
412 *) AC_MSG_ERROR([Unknown crypto backend.]) ;;
414 AM_CONDITIONAL(CRYPTO_BACKEND_GCRYPT, test "$with_crypto_backend" = "gcrypt")
415 AM_CONDITIONAL(CRYPTO_BACKEND_OPENSSL, test "$with_crypto_backend" = "openssl")
416 AM_CONDITIONAL(CRYPTO_BACKEND_NSS, test "$with_crypto_backend" = "nss")
417 AM_CONDITIONAL(CRYPTO_BACKEND_KERNEL, test "$with_crypto_backend" = "kernel")
418 AM_CONDITIONAL(CRYPTO_BACKEND_NETTLE, test "$with_crypto_backend" = "nettle")
420 AM_CONDITIONAL(CRYPTO_INTERNAL_PBKDF2, test $use_internal_pbkdf2 = 1)
421 AC_DEFINE_UNQUOTED(USE_INTERNAL_PBKDF2, [$use_internal_pbkdf2], [Use internal PBKDF2])
423 dnl Argon2 implementation
424 AC_ARG_ENABLE([internal-argon2],
425 AS_HELP_STRING([--disable-internal-argon2], [disable internal implementation of Argon2 PBKDF]),
426 [], [enable_internal_argon2=yes])
428 AC_ARG_ENABLE([libargon2],
429 AS_HELP_STRING([--enable-libargon2], [enable external libargon2 (PHC) library (disables internal bundled version)]))
431 if test "x$enable_libargon2" = "xyes" ; then
432 AC_CHECK_HEADERS(argon2.h,,
433 [AC_MSG_ERROR([You need libargon2 development library installed.])])
434 AC_CHECK_DECL(Argon2_id,,[AC_MSG_ERROR([You need more recent Argon2 library with support for Argon2id.])], [#include <argon2.h>])
435 PKG_CHECK_MODULES([LIBARGON2], [libargon2],,[LIBARGON2_LIBS="-largon2"])
436 enable_internal_argon2=no
438 AC_MSG_WARN([Argon2 bundled (slow) reference implementation will be used, please consider to use system library with --enable-libargon2.])
440 AC_ARG_ENABLE([internal-sse-argon2],
441 AS_HELP_STRING([--enable-internal-sse-argon2], [enable internal SSE implementation of Argon2 PBKDF]))
443 if test "x$enable_internal_sse_argon2" = "xyes"; then
444 AC_MSG_CHECKING(if Argon2 SSE optimization can be used)
445 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
446 #include <emmintrin.h>
447 __m128i testfunc(__m128i *a, __m128i *b) {
448 return _mm_xor_si128(_mm_loadu_si128(a), _mm_loadu_si128(b));
450 ]])],,[enable_internal_sse_argon2=no])
451 AC_MSG_RESULT($enable_internal_sse_argon2)
455 if test "x$enable_internal_argon2" = "xyes"; then
456 AC_DEFINE(USE_INTERNAL_ARGON2, 1, [Use internal Argon2])
458 AM_CONDITIONAL(CRYPTO_INTERNAL_ARGON2, test "x$enable_internal_argon2" = "xyes")
459 AM_CONDITIONAL(CRYPTO_INTERNAL_SSE_ARGON2, test "x$enable_internal_sse_argon2" = "xyes")
461 dnl Link with blkid to check for other device types
462 AC_ARG_ENABLE([blkid],
463 AS_HELP_STRING([--disable-blkid], [disable use of blkid for device signature detection and wiping]),
464 [], [enable_blkid=yes])
466 if test "x$enable_blkid" = "xyes"; then
467 PKG_CHECK_MODULES([BLKID], [blkid],[AC_DEFINE([HAVE_BLKID], 1, [Define to 1 to use blkid for detection of disk signatures.])],[LIBBLKID_LIBS="-lblkid"])
469 AC_CHECK_HEADERS(blkid/blkid.h,,[AC_MSG_ERROR([You need blkid development library installed.])])
470 AC_CHECK_DECL([blkid_do_wipe],
471 [ AC_DEFINE([HAVE_BLKID_WIPE], 1, [Define to 1 to use blkid_do_wipe.])
472 enable_blkid_wipe=yes
474 [#include <blkid/blkid.h>])
475 AC_CHECK_DECL([blkid_probe_step_back],
476 [ AC_DEFINE([HAVE_BLKID_STEP_BACK], 1, [Define to 1 to use blkid_probe_step_back.])
477 enable_blkid_step_back=yes
479 [#include <blkid/blkid.h>])
480 AC_CHECK_DECLS([ blkid_reset_probe,
481 blkid_probe_set_device,
482 blkid_probe_filter_superblocks_type,
485 blkid_probe_lookup_value
487 [AC_MSG_ERROR([Can not compile with blkid support, disable it by --disable-blkid.])],
488 [#include <blkid/blkid.h>])
490 AM_CONDITIONAL(HAVE_BLKID, test "x$enable_blkid" = "xyes")
491 AM_CONDITIONAL(HAVE_BLKID_WIPE, test "x$enable_blkid_wipe" = "xyes")
492 AM_CONDITIONAL(HAVE_BLKID_STEP_BACK, test "x$enable_blkid_step_back" = "xyes")
494 dnl Magic for cryptsetup.static build.
495 if test "x$enable_static_cryptsetup" = "xyes"; then
496 saved_PKG_CONFIG=$PKG_CONFIG
497 PKG_CONFIG="$PKG_CONFIG --static"
499 LIBS="$saved_LIBS -static"
500 AC_CHECK_LIB(popt, poptGetContext,,
501 AC_MSG_ERROR([Cannot find static popt library.]))
503 dnl Try to detect needed device-mapper static libraries, try pkg-config first.
504 LIBS="$saved_LIBS -static"
505 PKG_CHECK_MODULES([DEVMAPPER_STATIC], [devmapper >= 1.02.27],,[
506 DEVMAPPER_STATIC_LIBS=$DEVMAPPER_LIBS
507 if test "x$enable_selinux" = "xyes"; then
508 AC_CHECK_LIB(sepol, sepol_bool_set)
509 AC_CHECK_LIB(selinux, is_selinux_enabled)
510 DEVMAPPER_STATIC_LIBS="$DEVMAPPER_STATIC_LIBS $LIBS"
513 LIBS="$saved_LIBS $DEVMAPPER_STATIC_LIBS"
514 AC_CHECK_LIB(devmapper, dm_task_set_uuid,,
515 AC_MSG_ERROR([Cannot link with static device-mapper library.]))
517 dnl Try to detect uuid static library.
518 LIBS="$saved_LIBS -static"
519 AC_CHECK_LIB(uuid, uuid_generate,,
520 AC_MSG_ERROR([Cannot find static uuid library.]))
523 PKG_CONFIG=$saved_PKG_CONFIG
526 AC_MSG_CHECKING([for systemd tmpfiles config directory])
527 PKG_CHECK_VAR([systemd_tmpfilesdir], [systemd], [tmpfilesdir], [], [systemd_tmpfilesdir=no])
528 AC_MSG_RESULT([$systemd_tmpfilesdir])
530 AC_SUBST([DEVMAPPER_LIBS])
531 AC_SUBST([DEVMAPPER_STATIC_LIBS])
533 AC_SUBST([PWQUALITY_LIBS])
534 AC_SUBST([PWQUALITY_STATIC_LIBS])
536 AC_SUBST([PASSWDQC_LIBS])
538 AC_SUBST([CRYPTO_CFLAGS])
539 AC_SUBST([CRYPTO_LIBS])
540 AC_SUBST([CRYPTO_STATIC_LIBS])
542 AC_SUBST([JSON_C_LIBS])
543 AC_SUBST([LIBARGON2_LIBS])
544 AC_SUBST([BLKID_LIBS])
546 AC_SUBST([LIBCRYPTSETUP_VERSION])
547 AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
549 dnl ==========================================================================
550 AC_ARG_ENABLE([dev-random],
551 AS_HELP_STRING([--enable-dev-random], [use /dev/random by default for key generation (otherwise use /dev/urandom)]))
552 if test "x$enable_dev_random" = "xyes"; then
553 default_rng=/dev/random
555 default_rng=/dev/urandom
557 AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])
559 dnl ==========================================================================
560 AC_DEFUN([CS_DEFINE],
561 [AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
564 AC_DEFUN([CS_STR_WITH], [AC_ARG_WITH([$1],
565 [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
566 [CS_DEFINE([$1], ["$withval"], [$2])],
567 [CS_DEFINE([$1], ["$3"], [$2])]
570 AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
571 [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
572 [CS_DEFINE([$1], [$withval], [$2])],
573 [CS_DEFINE([$1], [$3], [$2])]
576 AC_DEFUN([CS_ABSPATH], [
579 *) AC_MSG_ERROR([$2 argument must be an absolute path.]);;
583 dnl ==========================================================================
584 CS_STR_WITH([plain-hash], [password hashing function for plain mode], [ripemd160])
585 CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
586 CS_STR_WITH([plain-mode], [cipher mode for plain mode], [cbc-essiv:sha256])
587 CS_NUM_WITH([plain-keybits],[key length in bits for plain mode], [256])
589 CS_STR_WITH([luks1-hash], [hash function for LUKS1 header], [sha256])
590 CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes])
591 CS_STR_WITH([luks1-mode], [cipher mode for LUKS1], [xts-plain64])
592 CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
594 AC_ARG_ENABLE([luks_adjust_xts_keysize], AS_HELP_STRING([--disable-luks-adjust-xts-keysize],
595 [XTS mode requires two keys, double default LUKS keysize if needed]),
596 [], [enable_luks_adjust_xts_keysize=yes])
597 if test "x$enable_luks_adjust_xts_keysize" = "xyes"; then
598 AC_DEFINE(ENABLE_LUKS_ADJUST_XTS_KEYSIZE, 1, [XTS mode - double default LUKS keysize if needed])
601 CS_STR_WITH([luks2-pbkdf], [Default PBKDF algorithm (pbkdf2 or argon2i/argon2id) for LUKS2], [argon2i])
602 CS_NUM_WITH([luks1-iter-time], [PBKDF2 iteration time for LUKS1 (in ms)], [2000])
603 CS_NUM_WITH([luks2-iter-time], [Argon2 PBKDF iteration time for LUKS2 (in ms)], [2000])
604 CS_NUM_WITH([luks2-memory-kb], [Argon2 PBKDF memory cost for LUKS2 (in kB)], [1048576])
605 CS_NUM_WITH([luks2-parallel-threads],[Argon2 PBKDF max parallel cost for LUKS2 (if CPUs available)], [4])
607 CS_STR_WITH([luks2-keyslot-cipher], [fallback cipher for LUKS2 keyslot (if data encryption is incompatible)], [aes-xts-plain64])
608 CS_NUM_WITH([luks2-keyslot-keybits],[fallback key size for LUKS2 keyslot (if data encryption is incompatible)], [512])
610 CS_STR_WITH([loopaes-cipher], [cipher for loop-AES mode], [aes])
611 CS_NUM_WITH([loopaes-keybits],[key length in bits for loop-AES mode], [256])
613 CS_NUM_WITH([keyfile-size-maxkb],[maximum keyfile size (in KiB)], [8192])
614 CS_NUM_WITH([integrity-keyfile-size-maxkb],[maximum integritysetup keyfile size (in KiB)], [4])
615 CS_NUM_WITH([passphrase-size-max],[maximum passphrase size (in characters)], [512])
617 CS_STR_WITH([verity-hash], [hash function for verity mode], [sha256])
618 CS_NUM_WITH([verity-data-block], [data block size for verity mode], [4096])
619 CS_NUM_WITH([verity-hash-block], [hash block size for verity mode], [4096])
620 CS_NUM_WITH([verity-salt-size], [salt size for verity mode], [32])
621 CS_NUM_WITH([verity-fec-roots], [parity bytes for verity FEC], [2])
623 CS_STR_WITH([tmpfilesdir], [override default path to directory with systemd temporary files], [])
624 test -z "$with_tmpfilesdir" && with_tmpfilesdir=$systemd_tmpfilesdir
625 test "x$with_tmpfilesdir" = "xno" || {
626 CS_ABSPATH([${with_tmpfilesdir}],[with-tmpfilesdir])
627 DEFAULT_TMPFILESDIR=$with_tmpfilesdir
628 AC_SUBST(DEFAULT_TMPFILESDIR)
630 AM_CONDITIONAL(CRYPTSETUP_TMPFILE, test -n "$DEFAULT_TMPFILESDIR")
632 CS_STR_WITH([luks2-lock-path], [path to directory for LUKSv2 locks], [/run/cryptsetup])
633 test -z "$with_luks2_lock_path" && with_luks2_lock_path=/run/cryptsetup
634 CS_ABSPATH([${with_luks2_lock_path}],[with-luks2-lock-path])
635 DEFAULT_LUKS2_LOCK_PATH=$with_luks2_lock_path
636 AC_SUBST(DEFAULT_LUKS2_LOCK_PATH)
638 CS_NUM_WITH([luks2-lock-dir-perms], [default luks2 locking directory permissions], [0700])
639 test -z "$with_luks2_lock_dir_perms" && with_luks2_lock_dir_perms=0700
640 DEFAULT_LUKS2_LOCK_DIR_PERMS=$with_luks2_lock_dir_perms
641 AC_SUBST(DEFAULT_LUKS2_LOCK_DIR_PERMS)
643 dnl Override default LUKS format version (for cryptsetup or cryptsetup-reencrypt format actions only).
644 AC_ARG_WITH([default_luks_format],
645 AS_HELP_STRING([--with-default-luks-format=FORMAT], [default LUKS format version (LUKS1/LUKS2) [LUKS2]]),
646 [], [with_default_luks_format=LUKS2])
648 case $with_default_luks_format in
649 LUKS1) default_luks=CRYPT_LUKS1 ;;
650 LUKS2) default_luks=CRYPT_LUKS2 ;;
651 *) AC_MSG_ERROR([Unknown default LUKS format. Use LUKS1 or LUKS2 only.]) ;;
653 AC_DEFINE_UNQUOTED([DEFAULT_LUKS_FORMAT], [$default_luks], [default LUKS format version])
655 dnl ==========================================================================
657 AC_CONFIG_FILES([ Makefile
660 scripts/cryptsetup.conf