-AC_PREREQ(2.57)
-AC_INIT(cryptsetup,1.1.3)
+AC_PREREQ([2.67])
+AC_INIT([cryptsetup],[1.2.0])
dnl library version from <major>.<minor>.<release>[-<suffix>]
LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
-LIBCRYPTSETUP_VERSION_INFO=1:0:0
+LIBCRYPTSETUP_VERSION_INFO=2:0:1
AC_CONFIG_SRCDIR(src/cryptsetup.c)
AC_CONFIG_MACRO_DIR([m4])
-AM_CONFIG_HEADER([config.h:config.h.in])
+AC_CONFIG_HEADERS([config.h:config.h.in])
AM_INIT_AUTOMAKE(dist-bzip2)
if test "x$prefix" = "xNONE"; then
AC_PREFIX_DEFAULT(/usr)
AC_CANONICAL_HOST
-AC_GNU_SOURCE
+AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_ENABLE_STATIC(no)
-AM_PROG_LIBTOOL
+LT_INIT
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_SUBST(UUID_LIBS, $LIBS)
LIBS=$saved_LIBS
-
-AM_PATH_LIBGCRYPT(1.1.42,,[AC_MSG_ERROR('You need the gcrypt library')])
-
AC_CHECK_FUNCS([posix_memalign])
AC_C_CONST
AC_C_BIGENDIAN
AC_TYPE_OFF_T
-AC_STRUCT_ST_RDEV
AC_SYS_LARGEFILE
AC_PROG_GCC_TRADITIONAL
LIBS=$saved_LIBS
dnl ==========================================================================
+dnl Crypto backend functions
+
+AC_DEFUN([CONFIGURE_GCRYPT], [
+ AM_PATH_LIBGCRYPT(1.1.42,,[AC_MSG_ERROR('You need the gcrypt library')])
+
+ 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
+])
+
+AC_DEFUN([CONFIGURE_OPENSSL], [
+ PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8],,
+ AC_MSG_ERROR('You need openssl library'))
+ CRYPTO_CFLAGS=$OPENSSL_CFLAGS
+ CRYPTO_LIBS=$OPENSSL_LIBS
+
+ if test x$enable_static_cryptsetup = xyes; then
+ saved_PKG_CONFIG=$PKG_CONFIG
+ PKG_CONFIG="$PKG_CONFIG --static"
+ PKG_CHECK_MODULES([OPENSSL], [openssl])
+ CRYPTO_STATIC_LIBS=$OPENSSL_LIBS
+ PKG_CONFIG=$saved_PKG_CONFIG
+ fi
+])
+
+AC_DEFUN([CONFIGURE_NSS], [
+ if test x$enable_static_cryptsetup = xyes; then
+ AC_MSG_ERROR([Static build of cryptsetup is not supported with NSS.]),
+ fi
+
+ AC_MSG_WARN([NSS backend does NOT provide backward compatibility (missing ripemd160 hash).])
+
+ PKG_CHECK_MODULES([NSS], [nss],,
+ AC_MSG_ERROR('You need nss library'))
+ CRYPTO_CFLAGS=$NSS_CFLAGS
+ CRYPTO_LIBS=$NSS_LIBS
+])
+
+AC_DEFUN([CONFIGURE_KERNEL], [
+ AC_CHECK_HEADERS(linux/if_alg.h,,
+ [AC_MSG_ERROR('You need Linux kernel with userspace crypto interface.')])
+# AC_CHECK_DECLS([AF_ALG],,
+# [AC_MSG_ERROR('You need Linux kernel with userspace crypto interface.')],
+# [#include <sys/socket.h>])
+
+])
+
+dnl ==========================================================================
saved_LIBS=$LIBS
-AC_ARG_ENABLE(shared-library,
-[ --disable-shared-library
- disable building of shared cryptsetup library],,
-enable_shared_library=yes)
-AM_CONDITIONAL(STATIC_LIBRARY, test x$enable_shared_library = xno)
+AC_ARG_ENABLE([static-cryptsetup],
+ AS_HELP_STRING([--enable-static-cryptsetup],
+ [enable build of static cryptsetup binary]))
+if test x$enable_static_cryptsetup = xyes; then
+ if test x$enable_static = xno; then
+ AC_MSG_WARN([Requested static cryptsetup build, enabling static library.])
+ enable_static=yes
+ fi
+fi
+AM_CONDITIONAL(STATIC_CRYPTSETUP, test x$enable_static_cryptsetup = xyes)
AC_ARG_ENABLE(selinux,
-[ --disable-selinux disable selinux support [[default=auto]]],[], [])
+ AS_HELP_STRING([--disable-selinux],
+ [disable selinux support [default=auto]]),[], [])
-AC_ARG_ENABLE([udev],AS_HELP_STRING([--disable-udev],[disable udev support]),[], enable_udev=yes)
+AC_ARG_ENABLE([udev],
+ AS_HELP_STRING([--disable-udev],
+ [disable udev support]),[], enable_udev=yes)
dnl Try to use pkg-config for devmapper, but fallback to old detection
PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.03],, [
fi
LIBS=$saved_LIBS
+dnl Crypto backend configuration.
+AC_ARG_WITH([crypto_backend],
+ AS_HELP_STRING([--with-crypto_backend=BACKEND], [crypto backend (gcrypt/openssl/nss/kernel) [gcrypt]]),
+ [], with_crypto_backend=gcrypt
+)
+case $with_crypto_backend in
+ gcrypt) CONFIGURE_GCRYPT([]) ;;
+ openssl) CONFIGURE_OPENSSL([]) ;;
+ nss) CONFIGURE_NSS([]) ;;
+ kernel) CONFIGURE_KERNEL([]) ;;
+ *) 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)
+
dnl Magic for cryptsetup.static build.
-if test x$enable_static = xyes; then
+if test x$enable_static_cryptsetup = xyes; then
saved_PKG_CONFIG=$PKG_CONFIG
PKG_CONFIG="$PKG_CONFIG --static"
- 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 -static"
AC_CHECK_LIB(popt, poptGetContext,,
AC_MSG_ERROR([Cannot find static popt library.]))
AC_SUBST([DEVMAPPER_LIBS])
AC_SUBST([DEVMAPPER_STATIC_LIBS])
-AC_SUBST([LIBGCRYPT_STATIC_LIBS])
+
+AC_SUBST([CRYPTO_CFLAGS])
+AC_SUBST([CRYPTO_LIBS])
+AC_SUBST([CRYPTO_STATIC_LIBS])
+
AC_SUBST([LIBCRYPTSETUP_VERSION])
AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
dnl ==========================================================================
+AC_ARG_ENABLE([dev-random], AS_HELP_STRING([--enable-dev-random],
+[use blocking /dev/random by default for key generator (otherwise use /dev/urandom)]),
+[default_rng=/dev/random], [default_rng=/dev/urandom])
+AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])
+
+dnl ==========================================================================
AC_DEFUN([CS_DEFINE],
[AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
])
CS_STR_WITH([luks1-mode], [cipher mode for LUKS1], [cbc-essiv:sha256])
CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
-dnl ==========================================================================
-
-AM_CONDITIONAL(STATIC_CRYPTSETUP, test x$enable_static = xyes)
-AM_CONDITIONAL(DYNAMIC_CRYPTSETUP, test x$enable_static = xno)
dnl ==========================================================================
-AC_OUTPUT([ Makefile
+AC_CONFIG_FILES([ Makefile
lib/Makefile
lib/libcryptsetup.pc
+lib/crypto_backend/Makefile
+lib/luks1/Makefile
+lib/loopaes/Makefile
src/Makefile
po/Makefile.in
-luks/Makefile
man/Makefile
tests/Makefile
])
+AC_OUTPUT