2 AC_INIT([cryptsetup],[1.4.3-git])
4 dnl library version from <major>.<minor>.<release>[-<suffix>]
5 LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
6 LIBCRYPTSETUP_VERSION_INFO=5:0:1
8 AC_CONFIG_SRCDIR(src/cryptsetup.c)
9 AC_CONFIG_MACRO_DIR([m4])
11 AC_CONFIG_HEADERS([config.h:config.h.in])
12 AM_INIT_AUTOMAKE(dist-bzip2)
14 if test "x$prefix" = "xNONE"; then
17 AC_PREFIX_DEFAULT(/usr)
20 AC_USE_SYSTEM_EXTENSIONS
31 AC_CHECK_HEADERS(fcntl.h malloc.h inttypes.h sys/ioctl.h sys/mman.h \
32 ctype.h unistd.h locale.h)
34 AC_CHECK_HEADERS(uuid/uuid.h,,[AC_MSG_ERROR([You need the uuid library.])])
35 AC_CHECK_HEADER(libdevmapper.h,,[AC_MSG_ERROR([You need the device-mapper library.])])
38 AC_CHECK_LIB(uuid, uuid_clear, ,[AC_MSG_ERROR([You need the uuid library.])])
39 AC_SUBST(UUID_LIBS, $LIBS)
42 AC_CHECK_FUNCS([posix_memalign])
49 AC_PROG_GCC_TRADITIONAL
51 dnl ==========================================================================
53 AM_GNU_GETTEXT([external],[need-ngettext])
54 AM_GNU_GETTEXT_VERSION([0.15])
56 dnl ==========================================================================
59 AC_CHECK_LIB(popt, poptConfigFileToString,,
60 [AC_MSG_ERROR([You need popt 1.7 or newer to compile.])])
61 AC_SUBST(POPT_LIBS, $LIBS)
64 dnl ==========================================================================
66 AC_ARG_ENABLE([fips], AS_HELP_STRING([--enable-fips],[enable FIPS mode restrictions]),
67 [with_fips=$enableval],
70 if test "x$with_fips" = "xyes"; then
71 AC_DEFINE(ENABLE_FIPS, 1, [Enable FIPS mode restrictions])
73 if test "x$enable_static" = "xyes" -o "x$enable_static_cryptsetup" = "xyes" ; then
74 AC_MSG_ERROR([Static build is not compatible with FIPS.])
78 AC_CHECK_LIB(fipscheck, FIPSCHECK_verify, ,[AC_MSG_ERROR([You need the fipscheck library.])])
79 AC_SUBST(FIPSCHECK_LIBS, $LIBS)
85 if test "x$with_fips" = "xyes"; then
86 AC_MSG_ERROR([This option is not compatible with FIPS.])
90 dnl ==========================================================================
91 dnl Crypto backend functions
93 AC_DEFUN([CONFIGURE_GCRYPT], [
94 if test "x$with_fips" = "xyes"; then
95 GCRYPT_REQ_VERSION=1.4.5
97 GCRYPT_REQ_VERSION=1.1.42
99 AM_PATH_LIBGCRYPT($GCRYPT_REQ_VERSION,,[AC_MSG_ERROR([You need the gcrypt library.])])
101 if test x$enable_static_cryptsetup = xyes; then
103 LIBS="$saved_LIBS $LIBGCRYPT_LIBS -static"
104 AC_CHECK_LIB(gcrypt, gcry_check_version,,
105 AC_MSG_ERROR([Cannot find static gcrypt library.]),
107 LIBGCRYPT_STATIC_LIBS="$LIBGCRYPT_LIBS -lgpg-error"
111 CRYPTO_CFLAGS=$LIBGCRYPT_CFLAGS
112 CRYPTO_LIBS=$LIBGCRYPT_LIBS
113 CRYPTO_STATIC_LIBS=$LIBGCRYPT_STATIC_LIBS
115 AC_DEFINE_UNQUOTED(GCRYPT_REQ_VERSION, ["$GCRYPT_REQ_VERSION"], [Requested gcrypt version])
118 AC_DEFUN([CONFIGURE_OPENSSL], [
119 PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8],,
120 AC_MSG_ERROR([You need openssl library.]))
121 CRYPTO_CFLAGS=$OPENSSL_CFLAGS
122 CRYPTO_LIBS=$OPENSSL_LIBS
124 if test x$enable_static_cryptsetup = xyes; then
125 saved_PKG_CONFIG=$PKG_CONFIG
126 PKG_CONFIG="$PKG_CONFIG --static"
127 PKG_CHECK_MODULES([OPENSSL], [openssl])
128 CRYPTO_STATIC_LIBS=$OPENSSL_LIBS
129 PKG_CONFIG=$saved_PKG_CONFIG
134 AC_DEFUN([CONFIGURE_NSS], [
135 if test x$enable_static_cryptsetup = xyes; then
136 AC_MSG_ERROR([Static build of cryptsetup is not supported with NSS.])
139 AC_MSG_WARN([NSS backend does NOT provide backward compatibility (missing ripemd160 hash).])
141 PKG_CHECK_MODULES([NSS], [nss],,
142 AC_MSG_ERROR([You need nss library.]))
143 CRYPTO_CFLAGS=$NSS_CFLAGS
144 CRYPTO_LIBS=$NSS_LIBS
148 AC_DEFUN([CONFIGURE_KERNEL], [
149 AC_CHECK_HEADERS(linux/if_alg.h,,
150 [AC_MSG_ERROR([You need Linux kernel with userspace crypto interface.])])
151 # AC_CHECK_DECLS([AF_ALG],,
152 # [AC_MSG_ERROR([You need Linux kernel with userspace crypto interface.])],
153 # [#include <sys/socket.h>])
157 AC_DEFUN([CONFIGURE_NETTLE], [
158 AC_CHECK_HEADERS(nettle/sha.h,,
159 [AC_MSG_ERROR([You need Nettle cryptographic library.])])
162 AC_CHECK_LIB(nettle, nettle_ripemd160_init,,
163 [AC_MSG_ERROR([You need Nettle library version 2.4 or more recent.])])
167 CRYPTO_STATIC_LIBS=$CRYPTO_LIBS
171 dnl ==========================================================================
174 AC_ARG_ENABLE([static-cryptsetup],
175 AS_HELP_STRING([--enable-static-cryptsetup],
176 [enable build of static cryptsetup binary]))
177 if test x$enable_static_cryptsetup = xyes; then
178 if test x$enable_static = xno; then
179 AC_MSG_WARN([Requested static cryptsetup build, enabling static library.])
183 AM_CONDITIONAL(STATIC_CRYPTSETUP, test x$enable_static_cryptsetup = xyes)
185 AC_ARG_ENABLE(selinux,
186 AS_HELP_STRING([--disable-selinux],
187 [disable selinux support [default=auto]]),[], [])
189 AC_ARG_ENABLE([udev],
190 AS_HELP_STRING([--disable-udev],
191 [disable udev support]),[], enable_udev=yes)
193 dnl Try to use pkg-config for devmapper, but fallback to old detection
194 PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.03],, [
195 AC_CHECK_LIB(devmapper, dm_task_set_name,,
196 [AC_MSG_ERROR([You need the device-mapper library.])])
197 AC_CHECK_LIB(devmapper, dm_task_set_message,,
198 [AC_MSG_ERROR([The device-mapper library on your system is too old.])])
203 LIBS="$LIBS $DEVMAPPER_LIBS"
204 AC_CHECK_DECLS([dm_task_secure_data], [], [], [#include <libdevmapper.h>])
205 AC_CHECK_DECLS([dm_task_retry_remove], [], [], [#include <libdevmapper.h>])
206 AC_CHECK_DECLS([DM_UDEV_DISABLE_DISK_RULES_FLAG], [have_cookie=yes], [have_cookie=no], [#include <libdevmapper.h>])
207 if test "x$enable_udev" = xyes; then
208 if test "x$have_cookie" = xno; then
209 AC_MSG_WARN([The device-mapper library on your system has no udev support, udev support disabled.])
211 AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
216 dnl Crypto backend configuration.
217 AC_ARG_WITH([crypto_backend],
218 AS_HELP_STRING([--with-crypto_backend=BACKEND], [crypto backend (gcrypt/openssl/nss/kernel/nettle) [gcrypt]]),
219 [], with_crypto_backend=gcrypt
221 case $with_crypto_backend in
222 gcrypt) CONFIGURE_GCRYPT([]) ;;
223 openssl) CONFIGURE_OPENSSL([]) ;;
224 nss) CONFIGURE_NSS([]) ;;
225 kernel) CONFIGURE_KERNEL([]) ;;
226 nettle) CONFIGURE_NETTLE([]) ;;
227 *) AC_MSG_ERROR([Unknown crypto backend.]) ;;
229 AM_CONDITIONAL(CRYPTO_BACKEND_GCRYPT, test $with_crypto_backend = gcrypt)
230 AM_CONDITIONAL(CRYPTO_BACKEND_OPENSSL, test $with_crypto_backend = openssl)
231 AM_CONDITIONAL(CRYPTO_BACKEND_NSS, test $with_crypto_backend = nss)
232 AM_CONDITIONAL(CRYPTO_BACKEND_KERNEL, test $with_crypto_backend = kernel)
233 AM_CONDITIONAL(CRYPTO_BACKEND_NETTLE, test $with_crypto_backend = nettle)
235 dnl Magic for cryptsetup.static build.
236 if test x$enable_static_cryptsetup = xyes; then
237 saved_PKG_CONFIG=$PKG_CONFIG
238 PKG_CONFIG="$PKG_CONFIG --static"
240 LIBS="$saved_LIBS -static"
241 AC_CHECK_LIB(popt, poptGetContext,,
242 AC_MSG_ERROR([Cannot find static popt library.]))
244 dnl Try to detect needed device-mapper static libraries, try pkg-config first.
245 LIBS="$saved_LIBS -static"
246 PKG_CHECK_MODULES([DEVMAPPER_STATIC], [devmapper >= 1.02.27],,[
247 DEVMAPPER_STATIC_LIBS=$DEVMAPPER_LIBS
248 if test "x$enable_selinux" != xno; then
249 AC_CHECK_LIB(sepol, sepol_bool_set)
250 AC_CHECK_LIB(selinux, is_selinux_enabled)
251 DEVMAPPER_STATIC_LIBS="$DEVMAPPER_STATIC_LIBS $LIBS"
254 LIBS="$saved_LIBS $DEVMAPPER_STATIC_LIBS"
255 AC_CHECK_LIB(devmapper, dm_task_set_uuid,,
256 AC_MSG_ERROR([Cannot link with static device-mapper library.]))
258 dnl Try to detect uuid static library.
259 LIBS="$saved_LIBS -static"
260 AC_CHECK_LIB(uuid, uuid_generate,,
261 AC_MSG_ERROR([Cannot find static uuid library.]))
264 PKG_CONFIG=$saved_PKG_CONFIG
267 AC_SUBST([DEVMAPPER_LIBS])
268 AC_SUBST([DEVMAPPER_STATIC_LIBS])
270 AC_SUBST([CRYPTO_CFLAGS])
271 AC_SUBST([CRYPTO_LIBS])
272 AC_SUBST([CRYPTO_STATIC_LIBS])
274 AC_SUBST([LIBCRYPTSETUP_VERSION])
275 AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
277 dnl ==========================================================================
278 AC_ARG_ENABLE([dev-random], AS_HELP_STRING([--enable-dev-random],
279 [use blocking /dev/random by default for key generator (otherwise use /dev/urandom)]),
280 [default_rng=/dev/random], [default_rng=/dev/urandom])
281 AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])
283 dnl ==========================================================================
284 AC_DEFUN([CS_DEFINE],
285 [AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
288 AC_DEFUN([CS_STR_WITH], [AC_ARG_WITH([$1],
289 [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
290 [CS_DEFINE([$1], ["$withval"], [$2])],
291 [CS_DEFINE([$1], ["$3"], [$2])]
294 AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
295 [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
296 [CS_DEFINE([$1], [$withval], [$2])],
297 [CS_DEFINE([$1], [$3], [$2])]
300 dnl ==========================================================================
302 AC_ARG_ENABLE([python], AS_HELP_STRING([--enable-python],[enable Python bindings]),
303 [with_python=$enableval],
306 if test "x$with_python" = "xyes"; then
307 AM_PATH_PYTHON([2.4])
309 if ! test -x "$PYTHON-config" ; then
310 AC_MSG_ERROR([Cannot find python development packages to build bindings])
313 PYTHON_INCLUDES=$($PYTHON-config --includes)
314 AC_SUBST(PYTHON_INCLUDES)
316 AM_CONDITIONAL([PYTHON_CRYPTSETUP], [test "x$with_python" = "xyes"])
318 dnl ==========================================================================
319 CS_STR_WITH([plain-hash], [password hashing function for plain mode], [ripemd160])
320 CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
321 CS_STR_WITH([plain-mode], [cipher mode for plain mode], [cbc-essiv:sha256])
322 CS_NUM_WITH([plain-keybits],[key length in bits for plain mode], [256])
324 CS_STR_WITH([luks1-hash], [hash function for LUKS1 header], [sha1])
325 CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes])
326 CS_STR_WITH([luks1-mode], [cipher mode for LUKS1], [cbc-essiv:sha256])
327 CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
329 CS_STR_WITH([loopaes-cipher], [cipher for loop-AES mode], [aes])
330 CS_NUM_WITH([loopaes-keybits],[key length in bits for loop-AES mode], [256])
332 CS_NUM_WITH([keyfile-size-maxkb],[maximum keyfile size (in kilobytes)], [8192])
333 CS_NUM_WITH([passphrase-size-max],[maximum keyfile size (in kilobytes)], [512])
335 dnl ==========================================================================
337 AC_CONFIG_FILES([ Makefile
340 lib/crypto_backend/Makefile