Fixed the build error for riscv64 arch using gcc 13
[platform/upstream/cryptsetup.git] / configure.ac
1 AC_PREREQ([2.67])
2 AC_INIT([cryptsetup],[2.3.7])
3
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
7
8 AM_SILENT_RULES([yes])
9 AC_CONFIG_SRCDIR(src/cryptsetup.c)
10 AC_CONFIG_MACRO_DIR([m4])
11
12 AC_CONFIG_HEADERS([config.h:config.h.in])
13
14 # We do not want to run test in parallel. Really.
15 # http://lists.gnu.org/archive/html/automake/2013-01/msg00060.html
16
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])
20
21 if test "x$prefix" = "xNONE"; then
22         sysconfdir=/etc
23 fi
24 AC_PREFIX_DEFAULT(/usr)
25
26 AC_CANONICAL_HOST
27 AC_USE_SYSTEM_EXTENSIONS
28 AC_PROG_CC
29 AM_PROG_CC_C_O
30 AC_PROG_CPP
31 AC_PROG_INSTALL
32 AC_PROG_MAKE_SET
33 AC_ENABLE_STATIC(no)
34 LT_INIT
35 PKG_PROG_PKG_CONFIG
36 AM_ICONV
37
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])])
43 ])
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])
48
49 _PKG_CONFIG([$1], [variable="][$3]["], [$2])
50 AS_VAR_COPY([$1], [pkg_cv_][$1])
51
52 AS_VAR_IF([$1], [""], [$5], [$4])
53 ])
54 ])
55 dnl ==========================================================================
56
57 AC_C_RESTRICT
58
59 AC_HEADER_DIRENT
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])],
63 [[
64 #ifdef HAVE_FCNTL_H
65 # include <fcntl.h>
66 #endif
67 ]])
68
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.])])
71
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.])])
77
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>])
83
84         dnl ==========================================================================
85         dnl check that key_serial_t hasn't been adopted yet in stdlib
86         AC_CHECK_TYPES([key_serial_t], [], [], [
87         AC_INCLUDES_DEFAULT
88         #ifdef HAVE_LINUX_KEYCTL_H
89         # include <linux/keyctl.h>
90         #endif
91         ])
92
93         AC_DEFINE(KERNEL_KEYRING, 1, [Enable kernel keyring service support])
94 fi
95 AM_CONDITIONAL(KERNEL_KEYRING, test "x$enable_keyring" = "xyes")
96
97 saved_LIBS=$LIBS
98 AC_CHECK_LIB(uuid, uuid_clear, ,[AC_MSG_ERROR([You need the uuid library.])])
99 AC_SUBST(UUID_LIBS, $LIBS)
100 LIBS=$saved_LIBS
101
102 AC_SEARCH_LIBS([clock_gettime],[rt posix4])
103 AC_CHECK_FUNCS([posix_memalign clock_gettime posix_fallocate explicit_bzero])
104
105 if test "x$enable_largefile" = "xno"; then
106   AC_MSG_ERROR([Building with --disable-largefile is not supported, it can cause data corruption.])
107 fi
108
109 AC_C_CONST
110 AC_C_BIGENDIAN
111 AC_TYPE_OFF_T
112 AC_SYS_LARGEFILE
113 AC_FUNC_FSEEKO
114 AC_PROG_GCC_TRADITIONAL
115 AC_FUNC_STRERROR_R
116
117 dnl ==========================================================================
118
119 AM_GNU_GETTEXT([external],[need-ngettext])
120 AM_GNU_GETTEXT_VERSION([0.18.3])
121
122 dnl ==========================================================================
123
124 saved_LIBS=$LIBS
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)
128 LIBS=$saved_LIBS
129
130 dnl ==========================================================================
131 dnl FIPS extensions
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])
136
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.])
139         fi
140 fi
141
142 AC_DEFUN([NO_FIPS], [
143         if test "x$enable_fips" = "xyes"; then
144                 AC_MSG_ERROR([This option is not compatible with FIPS.])
145         fi
146 ])
147
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])
154 fi
155
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]))
160
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.]))
165
166         dnl FIXME: this is really hack for now
167         PWQUALITY_STATIC_LIBS="$PWQUALITY_LIBS -lcrack -lz"
168 fi
169
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)]))
175
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.]) ;;
180 esac
181 AC_DEFINE_UNQUOTED([PASSWDQC_CONFIG_FILE], ["$use_passwdqc_config"], [passwdqc library config file])
182
183 if test "x$enable_passwdqc" = "xyes"; then
184         AC_DEFINE(ENABLE_PASSWDQC, 1, [Enable password quality checking using passwdqc library])
185
186         saved_LIBS="$LIBS"
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" ;;
191                 *) PASSWDQC_LIBS= ;;
192         esac
193         AC_CHECK_FUNCS([passwdqc_params_free])
194         LIBS="$saved_LIBS"
195 fi
196
197 if test "x$enable_pwquality$enable_passwdqc" = "xyesyes"; then
198         AC_MSG_ERROR([--enable-pwquality and --enable-passwdqc are mutually incompatible.])
199 fi
200
201 dnl ==========================================================================
202 dnl Crypto backend functions
203
204 AC_DEFUN([CONFIGURE_GCRYPT], [
205         if test "x$enable_fips" = "xyes"; then
206                 GCRYPT_REQ_VERSION=1.4.5
207         else
208                 GCRYPT_REQ_VERSION=1.1.42
209         fi
210
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]
219                 else
220                         [use_internal_pbkdf2=1]
221                 fi,
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.]))
225
226         AC_MSG_CHECKING([if internal cryptsetup PBKDF2 is compiled-in])
227         if test $use_internal_pbkdf2 = 0; then
228                 AC_MSG_RESULT([no])
229         else
230                 AC_MSG_RESULT([yes])
231                 NO_FIPS([])
232         fi
233
234         AC_CHECK_DECLS([GCRY_CIPHER_MODE_XTS], [], [], [#include <gcrypt.h>])
235
236         if test "x$enable_static_cryptsetup" = "xyes"; then
237                 saved_LIBS=$LIBS
238                 LIBS="$saved_LIBS $LIBGCRYPT_LIBS -static"
239                 AC_CHECK_LIB(gcrypt, gcry_check_version,,
240                         AC_MSG_ERROR([Cannot find static gcrypt library.]),
241                         [-lgpg-error])
242                 LIBGCRYPT_STATIC_LIBS="$LIBGCRYPT_LIBS -lgpg-error"
243                 LIBS=$saved_LIBS
244         fi
245
246         CRYPTO_CFLAGS=$LIBGCRYPT_CFLAGS
247         CRYPTO_LIBS=$LIBGCRYPT_LIBS
248         CRYPTO_STATIC_LIBS=$LIBGCRYPT_STATIC_LIBS
249
250         AC_DEFINE_UNQUOTED(GCRYPT_REQ_VERSION, ["$GCRYPT_REQ_VERSION"], [Requested gcrypt version])
251 ])
252
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
259
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
266         fi
267 ])
268
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.])
272         fi
273
274         AC_MSG_WARN([NSS backend does NOT provide backward compatibility (missing ripemd160 hash).])
275
276         PKG_CHECK_MODULES([NSS], [nss],,
277                 AC_MSG_ERROR([You need nss library.]))
278
279         saved_CFLAGS=$CFLAGS
280         CFLAGS="$CFLAGS $NSS_CFLAGS"
281         AC_CHECK_DECLS([NSS_GetVersion], [], [], [#include <nss.h>])
282         CFLAGS=$saved_CFLAGS
283
284         CRYPTO_CFLAGS=$NSS_CFLAGS
285         CRYPTO_LIBS=$NSS_LIBS
286         use_internal_pbkdf2=1
287         NO_FIPS([])
288 ])
289
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
297         NO_FIPS([])
298 ])
299
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)
304
305         saved_LIBS=$LIBS
306         AC_CHECK_LIB(nettle, nettle_pbkdf2_hmac_sha256,,
307                 [AC_MSG_ERROR([You need Nettle library version 2.6 or more recent.])])
308         CRYPTO_LIBS=$LIBS
309         LIBS=$saved_LIBS
310
311         CRYPTO_STATIC_LIBS=$CRYPTO_LIBS
312         use_internal_pbkdf2=0
313         NO_FIPS([])
314 ])
315
316 dnl ==========================================================================
317 saved_LIBS=$LIBS
318
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.])
324                 enable_static=yes
325         fi
326 fi
327 AM_CONDITIONAL(STATIC_TOOLS, test "x$enable_static_cryptsetup" = "xyes")
328
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")
333
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")
338
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")
343
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")
348
349 AC_ARG_ENABLE([selinux],
350         AS_HELP_STRING([--disable-selinux], [disable selinux support [default=auto]]),
351         [], [enable_selinux=yes])
352
353 AC_ARG_ENABLE([udev],
354         AS_HELP_STRING([--disable-udev], [disable udev support]),
355         [], [enable_udev=yes])
356
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.])])
363         DEVMAPPER_LIBS=$LIBS
364 ])
365 LIBS=$saved_LIBS
366
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.])
379         else
380                 AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
381         fi
382 fi
383 LIBS=$saved_LIBS
384
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>])
389
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])
394
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])
399
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])
404 fi
405
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.]) ;;
413 esac
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")
419
420 AM_CONDITIONAL(CRYPTO_INTERNAL_PBKDF2, test $use_internal_pbkdf2 = 1)
421 AC_DEFINE_UNQUOTED(USE_INTERNAL_PBKDF2, [$use_internal_pbkdf2], [Use internal PBKDF2])
422
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])
427
428 AC_ARG_ENABLE([libargon2],
429         AS_HELP_STRING([--enable-libargon2], [enable external libargon2 (PHC) library (disables internal bundled version)]))
430
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
437 else
438         AC_MSG_WARN([Argon2 bundled (slow) reference implementation will be used, please consider to use system library with --enable-libargon2.])
439
440         AC_ARG_ENABLE([internal-sse-argon2],
441                 AS_HELP_STRING([--enable-internal-sse-argon2], [enable internal SSE implementation of Argon2 PBKDF]))
442
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));
449                         }
450                 ]])],,[enable_internal_sse_argon2=no])
451                 AC_MSG_RESULT($enable_internal_sse_argon2)
452         fi
453 fi
454
455 if test "x$enable_internal_argon2" = "xyes"; then
456         AC_DEFINE(USE_INTERNAL_ARGON2, 1, [Use internal Argon2])
457 fi
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")
460
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])
465
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"])
468
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
473                       ],,
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
478                       ],,
479                       [#include <blkid/blkid.h>])
480         AC_CHECK_DECLS([ blkid_reset_probe,
481                          blkid_probe_set_device,
482                          blkid_probe_filter_superblocks_type,
483                          blkid_do_safeprobe,
484                          blkid_do_probe,
485                          blkid_probe_lookup_value
486                        ],,
487                        [AC_MSG_ERROR([Can not compile with blkid support, disable it by --disable-blkid.])],
488                        [#include <blkid/blkid.h>])
489 fi
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")
493
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"
498
499         LIBS="$saved_LIBS -static"
500         AC_CHECK_LIB(popt, poptGetContext,,
501                 AC_MSG_ERROR([Cannot find static popt library.]))
502
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"
511                 fi
512         ])
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.]))
516
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.]))
521
522         LIBS=$saved_LIBS
523         PKG_CONFIG=$saved_PKG_CONFIG
524 fi
525
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])
529
530 AC_SUBST([DEVMAPPER_LIBS])
531 AC_SUBST([DEVMAPPER_STATIC_LIBS])
532
533 AC_SUBST([PWQUALITY_LIBS])
534 AC_SUBST([PWQUALITY_STATIC_LIBS])
535
536 AC_SUBST([PASSWDQC_LIBS])
537
538 AC_SUBST([CRYPTO_CFLAGS])
539 AC_SUBST([CRYPTO_LIBS])
540 AC_SUBST([CRYPTO_STATIC_LIBS])
541
542 AC_SUBST([JSON_C_LIBS])
543 AC_SUBST([LIBARGON2_LIBS])
544 AC_SUBST([BLKID_LIBS])
545
546 AC_SUBST([LIBCRYPTSETUP_VERSION])
547 AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
548
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
554 else
555         default_rng=/dev/urandom
556 fi
557 AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])
558
559 dnl ==========================================================================
560 AC_DEFUN([CS_DEFINE],
561         [AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
562 ])
563
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])]
568 )])
569
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])]
574 )])
575
576 AC_DEFUN([CS_ABSPATH], [
577         case "$1" in
578                 /*) ;;
579                 *) AC_MSG_ERROR([$2 argument must be an absolute path.]);;
580         esac
581 ])
582
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])
588
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])
593
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])
599 fi
600
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])
606
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])
609
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])
612
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])
616
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])
622
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)
629 }
630 AM_CONDITIONAL(CRYPTSETUP_TMPFILE, test -n "$DEFAULT_TMPFILESDIR")
631
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)
637
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)
642
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])
647
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.]) ;;
652 esac
653 AC_DEFINE_UNQUOTED([DEFAULT_LUKS_FORMAT], [$default_luks], [default LUKS format version])
654
655 dnl ==========================================================================
656
657 AC_CONFIG_FILES([ Makefile
658 lib/libcryptsetup.pc
659 po/Makefile.in
660 scripts/cryptsetup.conf
661 tests/Makefile
662 ])
663 AC_OUTPUT