configure.ac 23.5 KB
Newer Older
Milan Broz's avatar
Milan Broz committed
1
AC_PREREQ([2.67])
Milan Broz's avatar
Milan Broz committed
2
AC_INIT([cryptsetup],[2.0.3])
3 4 5

dnl library version from <major>.<minor>.<release>[-<suffix>]
LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
Milan Broz's avatar
Milan Broz committed
6
LIBCRYPTSETUP_VERSION_INFO=15:0:3
7

8
AM_SILENT_RULES([yes])
9
AC_CONFIG_SRCDIR(src/cryptsetup.c)
10
AC_CONFIG_MACRO_DIR([m4])
11

Milan Broz's avatar
Milan Broz committed
12
AC_CONFIG_HEADERS([config.h:config.h.in])
Milan Broz's avatar
Milan Broz committed
13 14 15 16 17

# We do not want to run test in parallel. Really.
# http://lists.gnu.org/archive/html/automake/2013-01/msg00060.html

# For old automake use this
Milan Broz's avatar
Milan Broz committed
18 19
#AM_INIT_AUTOMAKE(dist-xz subdir-objects)
AM_INIT_AUTOMAKE([dist-xz 1.12 serial-tests subdir-objects])
20 21 22 23 24 25 26

if test "x$prefix" = "xNONE"; then
	sysconfdir=/etc
fi
AC_PREFIX_DEFAULT(/usr)

AC_CANONICAL_HOST
Milan Broz's avatar
Milan Broz committed
27
AC_USE_SYSTEM_EXTENSIONS
28
AC_PROG_CC
29
AM_PROG_CC_C_O
30 31 32 33
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_ENABLE_STATIC(no)
Milan Broz's avatar
Milan Broz committed
34
LT_INIT
35
PKG_PROG_PKG_CONFIG
36

37 38
dnl ==========================================================================
dnl define PKG_CHECK_VAR for old pkg-config <= 0.28
39 40 41 42
m4_ifndef([AS_VAR_COPY],
[m4_define([AS_VAR_COPY],
[AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
])
43 44
m4_ifndef([PKG_CHECK_VAR], [
AC_DEFUN([PKG_CHECK_VAR],
45 46
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])
47 48 49 50

_PKG_CONFIG([$1], [variable="][$3]["], [$2])
AS_VAR_COPY([$1], [pkg_cv_][$1])

51 52
AS_VAR_IF([$1], [""], [$5], [$4])
])
53 54 55
])
dnl ==========================================================================

Milan Broz's avatar
Milan Broz committed
56 57
AC_C_RESTRICT

58 59 60
AC_HEADER_DIRENT
AC_HEADER_STDC
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

63 64
AC_CHECK_HEADERS(uuid/uuid.h,,[AC_MSG_ERROR([You need the uuid library.])])
AC_CHECK_HEADER(libdevmapper.h,,[AC_MSG_ERROR([You need the device-mapper library.])])
65

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
AC_ARG_ENABLE(keyring, AS_HELP_STRING([--disable-keyring],[disable kernel keyring support and builtin kernel keyring token]),[], [enable_keyring=yes])
if test "x$enable_keyring" = "xyes"; then
	AC_CHECK_HEADERS(linux/keyctl.h,,[AC_MSG_ERROR([You need Linux kernel headers with kernel keyring service compiled.])])

	dnl ==========================================================================
	dnl check whether kernel is compiled with kernel keyring service syscalls
	AC_CHECK_DECL(__NR_add_key,,[AC_MSG_ERROR([The kernel is missing add_key syscall.])], [#include <syscall.h>])
	AC_CHECK_DECL(__NR_keyctl,,[AC_MSG_ERROR([The kernel is missing keyctl syscall.])], [#include <syscall.h>])
	AC_CHECK_DECL(__NR_request_key,,[AC_MSG_ERROR([The kernel is missing request_key syscall.])], [#include <syscall.h>])

	dnl ==========================================================================
	dnl check that key_serial_t hasn't been adopted yet in stdlib
	AC_CHECK_TYPES([key_serial_t], [], [], [
	AC_INCLUDES_DEFAULT
	#ifdef HAVE_LINUX_KEYCTL_H
	# include <linux/keyctl.h>
	#endif
	])

	AC_DEFINE(KERNEL_KEYRING, 1, [Enable kernel keyring service support])
fi
AM_CONDITIONAL(KERNEL_KEYRING, test x$enable_keyring = xyes)

Milan Broz's avatar
Milan Broz committed
89
saved_LIBS=$LIBS
90
AC_CHECK_LIB(uuid, uuid_clear, ,[AC_MSG_ERROR([You need the uuid library.])])
Milan Broz's avatar
Milan Broz committed
91 92 93
AC_SUBST(UUID_LIBS, $LIBS)
LIBS=$saved_LIBS

94
AC_SEARCH_LIBS([clock_gettime],[rt posix4])
95
AC_CHECK_FUNCS([posix_memalign clock_gettime posix_fallocate])
96

97 98 99 100
if test "x$enable_largefile" = "xno" ; then
  AC_MSG_ERROR([Building with --disable-largefile is not supported, it can cause data corruption.])
fi

101 102 103 104
AC_C_CONST
AC_C_BIGENDIAN
AC_TYPE_OFF_T
AC_SYS_LARGEFILE
105
AC_FUNC_FSEEKO
106
AC_PROG_GCC_TRADITIONAL
107
AC_FUNC_STRERROR_R
108 109 110 111

dnl ==========================================================================

AM_GNU_GETTEXT([external],[need-ngettext])
Milan Broz's avatar
Milan Broz committed
112
AM_GNU_GETTEXT_VERSION([0.18.3])
113 114

dnl ==========================================================================
115

Milan Broz's avatar
Milan Broz committed
116
saved_LIBS=$LIBS
117
AC_CHECK_LIB(popt, poptConfigFileToString,,
Milan Broz's avatar
Milan Broz committed
118 119 120
	[AC_MSG_ERROR([You need popt 1.7 or newer to compile.])])
AC_SUBST(POPT_LIBS, $LIBS)
LIBS=$saved_LIBS
121

122
dnl ==========================================================================
123
dnl FIPS extensions (only for RHEL)
124 125 126 127 128 129
AC_ARG_ENABLE([fips], AS_HELP_STRING([--enable-fips],[enable FIPS mode restrictions]),
[with_fips=$enableval],
[with_fips=no])

if test "x$with_fips" = "xyes"; then
	AC_DEFINE(ENABLE_FIPS, 1, [Enable FIPS mode restrictions])
130 131 132 133

	if test "x$enable_static" = "xyes" -o "x$enable_static_cryptsetup" = "xyes" ; then
		AC_MSG_ERROR([Static build is not compatible with FIPS.])
	fi
134 135 136 137 138 139 140 141
fi

AC_DEFUN([NO_FIPS], [
	if test "x$with_fips" = "xyes"; then
		AC_MSG_ERROR([This option is not compatible with FIPS.])
	fi
])

142 143
dnl ==========================================================================
dnl pwquality library (cryptsetup CLI only)
144 145 146 147 148
AC_ARG_ENABLE([pwquality],
	      AS_HELP_STRING([--enable-pwquality],
			     [enable password quality checking using pwquality library]),
	      [with_pwquality=$enableval],
	      [with_pwquality=no])
149 150

if test "x$with_pwquality" = "xyes"; then
151
	AC_DEFINE(ENABLE_PWQUALITY, 1, [Enable password quality checking using pwquality library])
152 153 154
	PKG_CHECK_MODULES([PWQUALITY], [pwquality >= 1.0.0],,
		AC_MSG_ERROR([You need pwquality library.]))

155 156
	dnl FIXME: this is really hack for now
	PWQUALITY_STATIC_LIBS="$PWQUALITY_LIBS -lcrack -lz"
157 158
fi

159 160 161
dnl ==========================================================================
dnl passwdqc library (cryptsetup CLI only)
AC_ARG_ENABLE([passwdqc],
Milan Broz's avatar
Milan Broz committed
162 163
	      AS_HELP_STRING([--enable-passwdqc@<:@=CONFIG_PATH@:>@],
			     [enable password quality checking using passwdqc library (optionally with CONFIG_PATH)]),
164 165 166 167
	      [enable_passwdqc=$enableval],
	      [enable_passwdqc=no])

case "$enable_passwdqc" in
Milan Broz's avatar
Milan Broz committed
168 169
	yes|no) use_passwdqc_config="" ;;
	/*) use_passwdqc_config="$enable_passwdqc"; enable_passwdqc=yes ;;
170 171
	*) AC_MSG_ERROR([Unrecognized --enable-passwdqc parameter.]) ;;
esac
Milan Broz's avatar
Milan Broz committed
172
AC_DEFINE_UNQUOTED([PASSWDQC_CONFIG_FILE], ["$use_passwdqc_config"], [passwdqc library config file])
173 174 175 176 177 178 179 180 181 182 183

if test "x$enable_passwdqc" = "xyes"; then
	AC_DEFINE(ENABLE_PASSWDQC, 1, [Enable password quality checking using passwdqc library])

	PASSWDQC_LIBS="-lpasswdqc"
fi

if test "x$with_pwquality$enable_passwdqc" = "xyesyes"; then
	AC_MSG_ERROR([--enable-pwquality and --enable-passwdqc are mutually incompatible.])
fi

184 185 186 187
dnl ==========================================================================
dnl Crypto backend functions

AC_DEFUN([CONFIGURE_GCRYPT], [
188 189 190 191 192
	if test "x$with_fips" = "xyes"; then
		GCRYPT_REQ_VERSION=1.4.5
	else
		GCRYPT_REQ_VERSION=1.1.42
	fi
193
	dnl Check if we can use gcrypt PBKDF2 (1.6.0 supports empty password)
194
	AC_ARG_ENABLE([gcrypt-pbkdf2], AS_HELP_STRING([--enable-gcrypt-pbkdf2],[force enable internal gcrypt PBKDF2]),
195 196 197 198 199
		if test "x$enableval" = "xyes"; then
			[use_internal_pbkdf2=0]
		else
			[use_internal_pbkdf2=1]
		fi,
200
		[AM_PATH_LIBGCRYPT([1.6.1], [use_internal_pbkdf2=0], [use_internal_pbkdf2=1])])
201
	AM_PATH_LIBGCRYPT($GCRYPT_REQ_VERSION,,[AC_MSG_ERROR([You need the gcrypt library.])])
202

203
	AC_MSG_CHECKING([if internal cryptsetup PBKDF2 is compiled-in])
204 205
	if test $use_internal_pbkdf2 = 0; then
		AC_MSG_RESULT([no])
206 207
	else
		AC_MSG_RESULT([yes])
208 209 210
		NO_FIPS([])
	fi

211 212 213 214 215 216 217 218 219 220 221 222 223
	if test x$enable_static_cryptsetup = xyes; then
		saved_LIBS=$LIBS
		LIBS="$saved_LIBS $LIBGCRYPT_LIBS -static"
		AC_CHECK_LIB(gcrypt, gcry_check_version,,
			AC_MSG_ERROR([Cannot find static gcrypt library.]),
			[-lgpg-error])
		LIBGCRYPT_STATIC_LIBS="$LIBGCRYPT_LIBS -lgpg-error"
		LIBS=$saved_LIBS
        fi

	CRYPTO_CFLAGS=$LIBGCRYPT_CFLAGS
	CRYPTO_LIBS=$LIBGCRYPT_LIBS
	CRYPTO_STATIC_LIBS=$LIBGCRYPT_STATIC_LIBS
224 225

	AC_DEFINE_UNQUOTED(GCRYPT_REQ_VERSION, ["$GCRYPT_REQ_VERSION"], [Requested gcrypt version])
226 227 228 229
])

AC_DEFUN([CONFIGURE_OPENSSL], [
	PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8],,
230
		AC_MSG_ERROR([You need openssl library.]))
231 232
	CRYPTO_CFLAGS=$OPENSSL_CFLAGS
	CRYPTO_LIBS=$OPENSSL_LIBS
233
	use_internal_pbkdf2=0
234 235 236 237

	if test x$enable_static_cryptsetup = xyes; then
		saved_PKG_CONFIG=$PKG_CONFIG
		PKG_CONFIG="$PKG_CONFIG --static"
238 239
		PKG_CHECK_MODULES([OPENSSL_STATIC], [openssl])
		CRYPTO_STATIC_LIBS=$OPENSSL_STATIC_LIBS
240 241 242 243 244 245
		PKG_CONFIG=$saved_PKG_CONFIG
	fi
])

AC_DEFUN([CONFIGURE_NSS], [
	if test x$enable_static_cryptsetup = xyes; then
246
		AC_MSG_ERROR([Static build of cryptsetup is not supported with NSS.])
247 248
	fi

249 250
	AC_MSG_WARN([NSS backend does NOT provide backward compatibility (missing ripemd160 hash).])

251
	PKG_CHECK_MODULES([NSS], [nss],,
252
		AC_MSG_ERROR([You need nss library.]))
253 254 255 256 257 258

	saved_CFLAGS=$CFLAGS
	CFLAGS="$CFLAGS $NSS_CFLAGS"
	AC_CHECK_DECLS([NSS_GetVersion], [], [], [#include <nss.h>])
	CFLAGS=$saved_CFLAGS

259 260
	CRYPTO_CFLAGS=$NSS_CFLAGS
	CRYPTO_LIBS=$NSS_LIBS
261
	use_internal_pbkdf2=1
262
	NO_FIPS([])
263 264 265 266
])

AC_DEFUN([CONFIGURE_KERNEL], [
	AC_CHECK_HEADERS(linux/if_alg.h,,
267
		[AC_MSG_ERROR([You need Linux kernel headers with userspace crypto interface.])])
268
#	AC_CHECK_DECLS([AF_ALG],,
269
#		[AC_MSG_ERROR([You need Linux kernel with userspace crypto interface.])],
270
#		[#include <sys/socket.h>])
271
	use_internal_pbkdf2=1
272
	NO_FIPS([])
273 274
])

275 276
AC_DEFUN([CONFIGURE_NETTLE], [
	AC_CHECK_HEADERS(nettle/sha.h,,
277
		[AC_MSG_ERROR([You need Nettle cryptographic library.])])
278 279

	saved_LIBS=$LIBS
280 281
	AC_CHECK_LIB(nettle, nettle_pbkdf2_hmac_sha256,,
		[AC_MSG_ERROR([You need Nettle library version 2.6 or more recent.])])
282 283 284 285
	CRYPTO_LIBS=$LIBS
	LIBS=$saved_LIBS

	CRYPTO_STATIC_LIBS=$CRYPTO_LIBS
286
	use_internal_pbkdf2=0
287
	NO_FIPS([])
288 289
])

290
dnl ==========================================================================
291
saved_LIBS=$LIBS
292

293 294
AC_ARG_ENABLE([static-cryptsetup],
	AS_HELP_STRING([--enable-static-cryptsetup],
295
	[enable build of static version of tools]))
296
if test x$enable_static_cryptsetup = xyes; then
297 298 299 300
	if test x$enable_static = xno; then
		AC_MSG_WARN([Requested static cryptsetup build, enabling static library.])
		enable_static=yes
	fi
301
fi
Milan Broz's avatar
Milan Broz committed
302 303
AM_CONDITIONAL(STATIC_TOOLS, test x$enable_static_cryptsetup = xyes)

304 305 306 307 308
AC_ARG_ENABLE(cryptsetup,
	AS_HELP_STRING([--disable-cryptsetup],
	[disable cryptsetup support]),[], [enable_cryptsetup=yes])
AM_CONDITIONAL(CRYPTSETUP, test x$enable_cryptsetup = xyes)

Milan Broz's avatar
Milan Broz committed
309 310 311 312
AC_ARG_ENABLE(veritysetup,
	AS_HELP_STRING([--disable-veritysetup],
	[disable veritysetup support]),[], [enable_veritysetup=yes])
AM_CONDITIONAL(VERITYSETUP, test x$enable_veritysetup = xyes)
313

314
AC_ARG_ENABLE([cryptsetup-reencrypt],
315 316
	AS_HELP_STRING([--disable-cryptsetup-reencrypt],
	[disable cryptsetup-reencrypt tool]),[], [enable_cryptsetup_reencrypt=yes])
317 318
AM_CONDITIONAL(REENCRYPT, test x$enable_cryptsetup_reencrypt = xyes)

319 320 321 322 323
AC_ARG_ENABLE(integritysetup,
	AS_HELP_STRING([--disable-integritysetup],
	[disable integritysetup support]),[], [enable_integritysetup=yes])
AM_CONDITIONAL(INTEGRITYSETUP, test x$enable_integritysetup = xyes)

324
AC_ARG_ENABLE(selinux,
325 326
	AS_HELP_STRING([--disable-selinux],
	[disable selinux support [default=auto]]),[], [])
327

328 329 330
AC_ARG_ENABLE([udev],
	AS_HELP_STRING([--disable-udev],
	[disable udev support]),[], enable_udev=yes)
331

332
dnl Try to use pkg-config for devmapper, but fallback to old detection
333
PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.03],, [
334
	AC_CHECK_LIB(devmapper, dm_task_set_name,,
335
		[AC_MSG_ERROR([You need the device-mapper library.])])
336 337 338
	AC_CHECK_LIB(devmapper, dm_task_set_message,,
		[AC_MSG_ERROR([The device-mapper library on your system is too old.])])
	DEVMAPPER_LIBS=$LIBS
339 340
])
LIBS=$saved_LIBS
341

342
LIBS="$LIBS $DEVMAPPER_LIBS"
343
AC_CHECK_DECLS([dm_task_secure_data], [], [], [#include <libdevmapper.h>])
344
AC_CHECK_DECLS([dm_task_retry_remove], [], [], [#include <libdevmapper.h>])
345
AC_CHECK_DECLS([dm_task_deferred_remove], [], [], [#include <libdevmapper.h>])
346 347
AC_CHECK_DECLS([dm_device_has_mounted_fs], [], [], [#include <libdevmapper.h>])
AC_CHECK_DECLS([dm_device_has_holders], [], [], [#include <libdevmapper.h>])
348
AC_CHECK_DECLS([DM_UDEV_DISABLE_DISK_RULES_FLAG], [have_cookie=yes], [have_cookie=no], [#include <libdevmapper.h>])
349 350
if test "x$enable_udev" = xyes; then
	if test "x$have_cookie" = xno; then
351 352 353
		AC_MSG_WARN([The device-mapper library on your system has no udev support, udev support disabled.])
	else
		AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
354 355
	fi
fi
Milan Broz's avatar
Milan Broz committed
356
LIBS=$saved_LIBS
357

Milan Broz's avatar
Milan Broz committed
358 359 360
dnl Check for JSON-C used in LUKS2
PKG_CHECK_MODULES([JSON_C], [json-c])

361 362
dnl Crypto backend configuration.
AC_ARG_WITH([crypto_backend],
363
	AS_HELP_STRING([--with-crypto_backend=BACKEND], [crypto backend (gcrypt/openssl/nss/kernel/nettle) [gcrypt]]),
364 365
	[], with_crypto_backend=gcrypt
)
366 367 368 369 370 371 372 373 374 375 376 377 378

dnl Kernel crypto API backend needed for benchmark and tcrypt
AC_ARG_ENABLE([kernel_crypto], AS_HELP_STRING([--disable-kernel_crypto],
	[disable kernel userspace crypto (no benchmark and tcrypt)]),
	[with_kernel_crypto=$enableval],
	[with_kernel_crypto=yes])

if test "x$with_kernel_crypto" = "xyes"; then
	AC_CHECK_HEADERS(linux/if_alg.h,,
		[AC_MSG_ERROR([You need Linux kernel headers with userspace crypto interface. (Or use --disable-kernel_crypto.)])])
	AC_DEFINE(ENABLE_AF_ALG, 1, [Enable using of kernel userspace crypto])
fi

379 380 381 382 383
case $with_crypto_backend in
	gcrypt)  CONFIGURE_GCRYPT([]) ;;
	openssl) CONFIGURE_OPENSSL([]) ;;
	nss)     CONFIGURE_NSS([]) ;;
	kernel)  CONFIGURE_KERNEL([]) ;;
384
	nettle)  CONFIGURE_NETTLE([]) ;;
385 386 387 388 389 390
	*) AC_MSG_ERROR([Unknown crypto backend.]) ;;
esac
AM_CONDITIONAL(CRYPTO_BACKEND_GCRYPT,  test $with_crypto_backend = gcrypt)
AM_CONDITIONAL(CRYPTO_BACKEND_OPENSSL, test $with_crypto_backend = openssl)
AM_CONDITIONAL(CRYPTO_BACKEND_NSS,     test $with_crypto_backend = nss)
AM_CONDITIONAL(CRYPTO_BACKEND_KERNEL,  test $with_crypto_backend = kernel)
391
AM_CONDITIONAL(CRYPTO_BACKEND_NETTLE,  test $with_crypto_backend = nettle)
392

393 394 395
AM_CONDITIONAL(CRYPTO_INTERNAL_PBKDF2, test $use_internal_pbkdf2 = 1)
AC_DEFINE_UNQUOTED(USE_INTERNAL_PBKDF2, [$use_internal_pbkdf2], [Use internal PBKDF2])

396 397 398 399 400 401 402 403 404 405
dnl Argon2 implementation
AC_ARG_ENABLE(internal-argon2, AS_HELP_STRING([--disable-internal-argon2],
	[disable internal implementation of Argon2 PBKDF]),[], [enable_internal_argon2=yes])

AC_ARG_ENABLE([libargon2], AS_HELP_STRING([--enable-libargon2],
	[enable external libargon2 (PHC) library (disables internal bundled version) ]),[], [enable_libargon2=no])

if test x$enable_libargon2 = xyes ; then
	AC_CHECK_HEADERS(argon2.h,,
		[AC_MSG_ERROR([You need libargon2 development library installed.])])
406
	AC_CHECK_DECL(Argon2_id,,[AC_MSG_ERROR([You need more recent Argon2 library with support for Argon2id.])], [#include <argon2.h>])
407 408
	PKG_CHECK_MODULES([LIBARGON2], [libargon2],,[LIBARGON2_LIBS="-largon2"])
	enable_internal_argon2=no
409 410
else
	AC_MSG_WARN([Argon2 bundled (slow) reference implementation will be used, please consider to use system library with --enable-libargon2.])
411 412 413 414 415 416 417 418 419 420 421 422 423 424

	AC_ARG_ENABLE(internal-sse-argon2, AS_HELP_STRING([--enable-internal-sse-argon2],
		[enable internal SSE implementation of Argon2 PBKDF]),[], [enable_internal_sse_argon2=no])

	if test x$enable_internal_sse_argon2 = xyes ; then
		AC_MSG_CHECKING(if Argon2 SSE optimization can be used)
		AC_LINK_IFELSE([AC_LANG_PROGRAM([[
			#include <emmintrin.h>
			__m128i testfunc(__m128i *a, __m128i *b) {
			  return _mm_xor_si128(_mm_loadu_si128(a), _mm_loadu_si128(b));
			}
		]])],,[enable_internal_sse_argon2=no])
		AC_MSG_RESULT($enable_internal_sse_argon2)
	fi
425 426
fi

427 428 429 430
if test x$enable_internal_argon2 = xyes ; then
	AC_DEFINE(USE_INTERNAL_ARGON2, 1, [Use internal Argon2])
fi
AM_CONDITIONAL(CRYPTO_INTERNAL_ARGON2, test x$enable_internal_argon2 = xyes)
431
AM_CONDITIONAL(CRYPTO_INTERNAL_SSE_ARGON2, test x$enable_internal_sse_argon2 = xyes)
432

433 434 435 436 437 438 439 440
dnl Link with blkid to check for other device types
AC_ARG_ENABLE(blkid, AS_HELP_STRING([--disable-blkid],
	[disable use of blkid for device signature detection and wiping.]), [], [enable_blkid=yes])

if test x$enable_blkid = xyes ; then
	PKG_CHECK_MODULES([BLKID], [blkid],[AC_DEFINE([HAVE_BLKID], 1, [Define to 1 to use blkid for detection of disk signatures.])],[LIBBLKID_LIBS="-lblkid"])

	AC_CHECK_HEADERS(blkid/blkid.h,,[AC_MSG_ERROR([You need blkid development library installed.])])
441 442 443 444 445 446 447 448 449 450
	AC_CHECK_DECL([blkid_do_wipe],
		      [ AC_DEFINE([HAVE_BLKID_WIPE], 1, [Define to 1 to use blkid_do_wipe.])
			enable_blkid_wipe=yes
		      ],,
		      [#include <blkid/blkid.h>])
	AC_CHECK_DECL([blkid_probe_step_back],
		      [ AC_DEFINE([HAVE_BLKID_STEP_BACK], 1, [Define to 1 to use blkid_probe_step_back.])
			enable_blkid_step_back=yes
		      ],,
		      [#include <blkid/blkid.h>])
451 452 453 454 455 456 457 458 459 460 461
	AC_CHECK_DECLS([ blkid_reset_probe,
			 blkid_probe_set_device,
			 blkid_probe_filter_superblocks_type,
			 blkid_do_safeprobe,
			 blkid_do_probe,
			 blkid_probe_lookup_value
		       ],,
		       [AC_MSG_ERROR([Can not compile with blkid support, disable it by --disable-blkid.])],
		       [#include <blkid/blkid.h>])
fi
AM_CONDITIONAL(HAVE_BLKID, test x$enable_blkid = xyes)
462 463
AM_CONDITIONAL(HAVE_BLKID_WIPE, test x$enable_blkid_wipe = xyes)
AM_CONDITIONAL(HAVE_BLKID_STEP_BACK, test x$enable_blkid_step_back = xyes)
464

465
dnl Magic for cryptsetup.static build.
466
if test x$enable_static_cryptsetup = xyes; then
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
	saved_PKG_CONFIG=$PKG_CONFIG
	PKG_CONFIG="$PKG_CONFIG --static"

	LIBS="$saved_LIBS -static"
	AC_CHECK_LIB(popt, poptGetContext,,
		AC_MSG_ERROR([Cannot find static popt library.]))

	dnl Try to detect needed device-mapper static libraries, try pkg-config first.
	LIBS="$saved_LIBS -static"
	PKG_CHECK_MODULES([DEVMAPPER_STATIC], [devmapper >= 1.02.27],,[
		DEVMAPPER_STATIC_LIBS=$DEVMAPPER_LIBS
		if test "x$enable_selinux" != xno; then
			AC_CHECK_LIB(sepol, sepol_bool_set)
			AC_CHECK_LIB(selinux, is_selinux_enabled)
			DEVMAPPER_STATIC_LIBS="$DEVMAPPER_STATIC_LIBS $LIBS"
		fi
	])
	LIBS="$saved_LIBS $DEVMAPPER_STATIC_LIBS"
	AC_CHECK_LIB(devmapper, dm_task_set_uuid,,
		AC_MSG_ERROR([Cannot link with static device-mapper library.]))

488 489 490 491 492
	dnl Try to detect uuid static library.
	LIBS="$saved_LIBS -static"
	AC_CHECK_LIB(uuid, uuid_generate,,
		AC_MSG_ERROR([Cannot find static uuid library.]))

493 494 495
	LIBS=$saved_LIBS
	PKG_CONFIG=$saved_PKG_CONFIG
fi
496

497
AC_MSG_CHECKING([for systemd tmpfiles config directory])
498
PKG_CHECK_VAR([systemd_tmpfilesdir], [systemd], [tmpfilesdir], [], [systemd_tmpfilesdir=no])
499
AC_MSG_RESULT([$systemd_tmpfilesdir])
500

501
AC_SUBST([DEVMAPPER_LIBS])
502
AC_SUBST([DEVMAPPER_STATIC_LIBS])
503

504 505 506
AC_SUBST([PWQUALITY_LIBS])
AC_SUBST([PWQUALITY_STATIC_LIBS])

507 508
AC_SUBST([PASSWDQC_LIBS])

509 510 511 512
AC_SUBST([CRYPTO_CFLAGS])
AC_SUBST([CRYPTO_LIBS])
AC_SUBST([CRYPTO_STATIC_LIBS])

Milan Broz's avatar
Milan Broz committed
513
AC_SUBST([JSON_C_LIBS])
514
AC_SUBST([LIBARGON2_LIBS])
515
AC_SUBST([BLKID_LIBS])
Milan Broz's avatar
Milan Broz committed
516

517 518
AC_SUBST([LIBCRYPTSETUP_VERSION])
AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
519

520
dnl ==========================================================================
521 522 523 524 525 526 527
AC_ARG_ENABLE([dev-random],
	AS_HELP_STRING([--enable-dev-random], [use /dev/random by default for key generation (otherwise use /dev/urandom)]))
if test "x$enable_dev_random" = "xyes"; then
	default_rng=/dev/random
else
	default_rng=/dev/urandom
fi
528 529
AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])

530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
dnl ==========================================================================
AC_DEFUN([CS_DEFINE],
	[AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
])

AC_DEFUN([CS_STR_WITH], [AC_ARG_WITH([$1],
	[AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
	[CS_DEFINE([$1], ["$withval"], [$2])],
	[CS_DEFINE([$1], ["$3"], [$2])]
)])

AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
	[AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
	[CS_DEFINE([$1], [$withval], [$2])],
	[CS_DEFINE([$1], [$3], [$2])]
)])

547 548 549 550 551 552 553
AC_DEFUN([CS_ABSPATH], [
	case "$1" in
		/*) ;;
		*) AC_MSG_ERROR([$2 argument must be an absolute path.]);;
	esac
])

554 555 556 557 558 559
dnl ==========================================================================
dnl Python bindings
AC_ARG_ENABLE([python], AS_HELP_STRING([--enable-python],[enable Python bindings]),
[with_python=$enableval],
[with_python=no])

560 561 562 563
AC_ARG_WITH([python_version],
	AS_HELP_STRING([--with-python_version=VERSION], [required Python version [2.6]]),
	[PYTHON_VERSION=$withval], [PYTHON_VERSION=2.6])

564
if test "x$with_python" = "xyes"; then
565
	AM_PATH_PYTHON([$PYTHON_VERSION])
566

567 568 569
	AC_PATH_PROGS([PYTHON_CONFIG], [python${PYTHON_VERSION}-config python-config], [no])
	if test "${PYTHON_CONFIG}" = "no"; then
		AC_MSG_ERROR([cannot find python${PYTHON_VERSION}-config or python-config in PATH])
570 571
	fi

572 573 574
	AC_MSG_CHECKING(for python headers using $PYTHON_CONFIG --includes)
	PYTHON_INCLUDES=$($PYTHON_CONFIG --includes)
	AC_MSG_RESULT($PYTHON_INCLUDES)
575
	AC_SUBST(PYTHON_INCLUDES)
576

577 578 579
	AC_MSG_CHECKING(for python libraries using $PYTHON_CONFIG --libs)
	PYTHON_LIBS=$($PYTHON_CONFIG --libs)
	AC_MSG_RESULT($PYTHON_LIBS)
580
	AC_SUBST(PYTHON_LIBS)
581 582 583 584
fi
AM_CONDITIONAL([PYTHON_CRYPTSETUP], [test "x$with_python" = "xyes"])

dnl ==========================================================================
585 586 587 588 589
CS_STR_WITH([plain-hash],   [password hashing function for plain mode], [ripemd160])
CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
CS_STR_WITH([plain-mode],   [cipher mode for plain mode], [cbc-essiv:sha256])
CS_NUM_WITH([plain-keybits],[key length in bits for plain mode], [256])

590
CS_STR_WITH([luks1-hash],   [hash function for LUKS1 header], [sha256])
591
CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes])
592
CS_STR_WITH([luks1-mode],   [cipher mode for LUKS1], [xts-plain64])
593
CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
Milan Broz's avatar
Milan Broz committed
594 595 596

CS_STR_WITH([luks2-pbkdf],           [Default PBKDF algorithm (pbkdf2 or argon2i/argon2id) for LUKS2], [argon2i])
CS_NUM_WITH([luks1-iter-time],       [PBKDF2 iteration time for LUKS1 (in ms)], [2000])
597 598
CS_NUM_WITH([luks2-iter-time],       [Argon2 PBKDF iteration time for LUKS2 (in ms)], [2000])
CS_NUM_WITH([luks2-memory-kb],       [Argon2 PBKDF memory cost for LUKS2 (in kB)], [1048576])
Milan Broz's avatar
Milan Broz committed
599
CS_NUM_WITH([luks2-parallel-threads],[Argon2 PBKDF max parallel cost for LUKS2 (if CPUs available)], [4])
600

601 602
CS_STR_WITH([loopaes-cipher], [cipher for loop-AES mode], [aes])
CS_NUM_WITH([loopaes-keybits],[key length in bits for loop-AES mode], [256])
603

604 605
CS_NUM_WITH([keyfile-size-maxkb],[maximum keyfile size (in KiB)], [8192])
CS_NUM_WITH([passphrase-size-max],[maximum keyfile size (in characters)], [512])
606

Milan Broz's avatar
Milan Broz committed
607 608 609 610
CS_STR_WITH([verity-hash],       [hash function for verity mode], [sha256])
CS_NUM_WITH([verity-data-block], [data block size for verity mode], [4096])
CS_NUM_WITH([verity-hash-block], [hash block size for verity mode], [4096])
CS_NUM_WITH([verity-salt-size],  [salt size for verity mode], [32])
611
CS_NUM_WITH([verity-fec-roots],  [parity bytes for verity FEC], [2])
Milan Broz's avatar
Milan Broz committed
612

613
CS_STR_WITH([tmpfilesdir], [override default path to directory with systemd temporary files], [])
614
test -z "$with_tmpfilesdir" && with_tmpfilesdir=$systemd_tmpfilesdir
615
test "x$with_tmpfilesdir" = "xno" || {
616
	CS_ABSPATH([${with_tmpfilesdir}],[with-tmpfilesdir])
617 618 619 620 621
	DEFAULT_TMPFILESDIR=$with_tmpfilesdir
	AC_SUBST(DEFAULT_TMPFILESDIR)
}
AM_CONDITIONAL(CRYPTSETUP_TMPFILE, test -n "$DEFAULT_TMPFILESDIR")

622 623
CS_STR_WITH([luks2-lock-path], [path to directory for LUKSv2 locks], [/run/cryptsetup])
test -z "$with_luks2_lock_path" && with_luks2_lock_path=/run/cryptsetup
624
CS_ABSPATH([${with_luks2_lock_path}],[with-luks2-lock-path])
625 626 627 628 629 630 631 632
DEFAULT_LUKS2_LOCK_PATH=$with_luks2_lock_path
AC_SUBST(DEFAULT_LUKS2_LOCK_PATH)

CS_NUM_WITH([luks2-lock-dir-perms], [default luks2 locking directory permissions], [0700])
test -z "$with_luks2_lock_dir_perms" && with_luks2_lock_dir_perms=0700
DEFAULT_LUKS2_LOCK_DIR_PERMS=$with_luks2_lock_dir_perms
AC_SUBST(DEFAULT_LUKS2_LOCK_DIR_PERMS)

633 634 635 636 637 638 639 640 641 642 643 644 645
dnl Override default LUKS format version (for cryptsetup or cryptsetup-reencrypt format actions only).
AC_ARG_WITH([default_luks_format],
	AS_HELP_STRING([--with-default-luks-format=FORMAT], [default LUKS format version (LUKS1/LUKS2) [LUKS1]]),
	[], with_default_luks_format=LUKS1
)

case $with_default_luks_format in
	LUKS1) default_luks=CRYPT_LUKS1 ;;
	LUKS2) default_luks=CRYPT_LUKS2 ;;
	*) AC_MSG_ERROR([Unknown default LUKS format. Use LUKS1 or LUKS2 only.]) ;;
esac
AC_DEFINE_UNQUOTED([DEFAULT_LUKS_FORMAT], [$default_luks], [default LUKS format version])

646 647
dnl ==========================================================================

Milan Broz's avatar
Milan Broz committed
648
AC_CONFIG_FILES([ Makefile
Milan Broz's avatar
Milan Broz committed
649
lib/libcryptsetup.pc
650
po/Makefile.in
651
scripts/cryptsetup.conf
Milan Broz's avatar
Milan Broz committed
652
tests/Makefile
653
])
Milan Broz's avatar
Milan Broz committed
654
AC_OUTPUT