Set devel version.
[platform/upstream/cryptsetup.git] / configure.ac
1 AC_PREREQ([2.67])
2 AC_INIT([cryptsetup],[1.6.2-git])
3
4 dnl library version from <major>.<minor>.<release>[-<suffix>]
5 LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
6 LIBCRYPTSETUP_VERSION_INFO=9:0:5
7 dnl library file name for FIPS selfcheck
8 LIBCRYPTSETUP_VERSION_FIPS="libcryptsetup.so.4"
9
10 AC_CONFIG_SRCDIR(src/cryptsetup.c)
11 AC_CONFIG_MACRO_DIR([m4])
12
13 AC_CONFIG_HEADERS([config.h:config.h.in])
14 AM_INIT_AUTOMAKE(dist-bzip2)
15
16 if test "x$prefix" = "xNONE"; then
17         sysconfdir=/etc
18 fi
19 AC_PREFIX_DEFAULT(/usr)
20
21 AC_CANONICAL_HOST
22 AC_USE_SYSTEM_EXTENSIONS
23 AC_PROG_CC
24 AM_PROG_CC_C_O
25 AC_PROG_CPP
26 AC_PROG_INSTALL
27 AC_PROG_MAKE_SET
28 AC_ENABLE_STATIC(no)
29 LT_INIT
30 PKG_PROG_PKG_CONFIG
31
32 AC_HEADER_DIRENT
33 AC_HEADER_STDC
34 AC_CHECK_HEADERS(fcntl.h malloc.h inttypes.h sys/ioctl.h sys/mman.h \
35         ctype.h unistd.h locale.h)
36
37 AC_CHECK_HEADERS(uuid/uuid.h,,[AC_MSG_ERROR([You need the uuid library.])])
38 AC_CHECK_HEADER(libdevmapper.h,,[AC_MSG_ERROR([You need the device-mapper library.])])
39
40 saved_LIBS=$LIBS
41 AC_CHECK_LIB(uuid, uuid_clear, ,[AC_MSG_ERROR([You need the uuid library.])])
42 AC_SUBST(UUID_LIBS, $LIBS)
43 LIBS=$saved_LIBS
44
45 AC_CHECK_FUNCS([posix_memalign])
46
47 AC_C_CONST
48 AC_C_BIGENDIAN
49 AC_TYPE_OFF_T
50 AC_SYS_LARGEFILE
51
52 AC_PROG_GCC_TRADITIONAL
53
54 dnl ==========================================================================
55
56 AM_GNU_GETTEXT([external],[need-ngettext])
57 AM_GNU_GETTEXT_VERSION([0.15])
58
59 dnl ==========================================================================
60
61 saved_LIBS=$LIBS
62 AC_CHECK_LIB(popt, poptConfigFileToString,,
63         [AC_MSG_ERROR([You need popt 1.7 or newer to compile.])])
64 AC_SUBST(POPT_LIBS, $LIBS)
65 LIBS=$saved_LIBS
66
67 dnl ==========================================================================
68 dnl FIPS extensions
69 AC_ARG_ENABLE([fips], AS_HELP_STRING([--enable-fips],[enable FIPS mode restrictions]),
70 [with_fips=$enableval],
71 [with_fips=no])
72
73 if test "x$with_fips" = "xyes"; then
74         AC_DEFINE(ENABLE_FIPS, 1, [Enable FIPS mode restrictions])
75         AC_DEFINE_UNQUOTED(LIBCRYPTSETUP_VERSION_FIPS, ["$LIBCRYPTSETUP_VERSION_FIPS"],
76                 [library file name for FIPS selfcheck])
77
78         if test "x$enable_static" = "xyes" -o "x$enable_static_cryptsetup" = "xyes" ; then
79                 AC_MSG_ERROR([Static build is not compatible with FIPS.])
80         fi
81
82         saved_LIBS=$LIBS
83         AC_CHECK_LIB(fipscheck, FIPSCHECK_verify, ,[AC_MSG_ERROR([You need the fipscheck library.])])
84         AC_SUBST(FIPSCHECK_LIBS, $LIBS)
85         LIBS=$saved_LIBS
86
87 fi
88
89 AC_DEFUN([NO_FIPS], [
90         if test "x$with_fips" = "xyes"; then
91                 AC_MSG_ERROR([This option is not compatible with FIPS.])
92         fi
93 ])
94
95 dnl ==========================================================================
96 dnl pwquality library (cryptsetup CLI only)
97 AC_ARG_ENABLE([pwquality], AS_HELP_STRING([--enable-pwquality],[enable password quality checking]),
98 [with_pwquality=$enableval],
99 [with_pwquality=no])
100
101 if test "x$with_pwquality" = "xyes"; then
102         AC_DEFINE(ENABLE_PWQUALITY, 1, [Enable password quality checking])
103         PKG_CHECK_MODULES([PWQUALITY], [pwquality >= 1.0.0],,
104                 AC_MSG_ERROR([You need pwquality library.]))
105
106         dnl FIXME: this is really hack for now
107         PWQUALITY_STATIC_LIBS="$PWQUALITY_LIBS -lcrack -lz"
108 fi
109
110 dnl ==========================================================================
111 dnl Crypto backend functions
112
113 AC_DEFUN([CONFIGURE_GCRYPT], [
114         if test "x$with_fips" = "xyes"; then
115                 GCRYPT_REQ_VERSION=1.4.5
116         else
117                 GCRYPT_REQ_VERSION=1.1.42
118         fi
119         dnl Check if we can use gcrypt PBKDF2 (1.6.0 supports empty password)
120         AC_ARG_ENABLE([gcrypt-pbkdf2], AS_HELP_STRING([--enable-gcrypt-pbkdf2],[force enable internal gcrypt PBKDF2]),
121                 [use_internal_pbkdf2=0],
122                 [AM_PATH_LIBGCRYPT([1.6.0], [use_internal_pbkdf2=0], [use_internal_pbkdf2=1])])
123         AM_PATH_LIBGCRYPT($GCRYPT_REQ_VERSION,,[AC_MSG_ERROR([You need the gcrypt library.])])
124
125         if test x$enable_static_cryptsetup = xyes; then
126                 saved_LIBS=$LIBS
127                 LIBS="$saved_LIBS $LIBGCRYPT_LIBS -static"
128                 AC_CHECK_LIB(gcrypt, gcry_check_version,,
129                         AC_MSG_ERROR([Cannot find static gcrypt library.]),
130                         [-lgpg-error])
131                 LIBGCRYPT_STATIC_LIBS="$LIBGCRYPT_LIBS -lgpg-error"
132                 LIBS=$saved_LIBS
133         fi
134
135         CRYPTO_CFLAGS=$LIBGCRYPT_CFLAGS
136         CRYPTO_LIBS=$LIBGCRYPT_LIBS
137         CRYPTO_STATIC_LIBS=$LIBGCRYPT_STATIC_LIBS
138
139         AC_DEFINE_UNQUOTED(GCRYPT_REQ_VERSION, ["$GCRYPT_REQ_VERSION"], [Requested gcrypt version])
140 ])
141
142 AC_DEFUN([CONFIGURE_OPENSSL], [
143         PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8],,
144                 AC_MSG_ERROR([You need openssl library.]))
145         CRYPTO_CFLAGS=$OPENSSL_CFLAGS
146         CRYPTO_LIBS=$OPENSSL_LIBS
147         use_internal_pbkdf2=0
148
149         if test x$enable_static_cryptsetup = xyes; then
150                 saved_PKG_CONFIG=$PKG_CONFIG
151                 PKG_CONFIG="$PKG_CONFIG --static"
152                 PKG_CHECK_MODULES([OPENSSL], [openssl])
153                 CRYPTO_STATIC_LIBS=$OPENSSL_LIBS
154                 PKG_CONFIG=$saved_PKG_CONFIG
155         fi
156         NO_FIPS([])
157 ])
158
159 AC_DEFUN([CONFIGURE_NSS], [
160         if test x$enable_static_cryptsetup = xyes; then
161                 AC_MSG_ERROR([Static build of cryptsetup is not supported with NSS.])
162         fi
163
164         AC_MSG_WARN([NSS backend does NOT provide backward compatibility (missing ripemd160 hash).])
165
166         PKG_CHECK_MODULES([NSS], [nss],,
167                 AC_MSG_ERROR([You need nss library.]))
168
169         saved_CFLAGS=$CFLAGS
170         CFLAGS="$CFLAGS $NSS_CFLAGS"
171         AC_CHECK_DECLS([NSS_GetVersion], [], [], [#include <nss.h>])
172         CFLAGS=$saved_CFLAGS
173
174         CRYPTO_CFLAGS=$NSS_CFLAGS
175         CRYPTO_LIBS=$NSS_LIBS
176         use_internal_pbkdf2=1
177         NO_FIPS([])
178 ])
179
180 AC_DEFUN([CONFIGURE_KERNEL], [
181         AC_CHECK_HEADERS(linux/if_alg.h,,
182                 [AC_MSG_ERROR([You need Linux kernel headers with userspace crypto interface.])])
183 #       AC_CHECK_DECLS([AF_ALG],,
184 #               [AC_MSG_ERROR([You need Linux kernel with userspace crypto interface.])],
185 #               [#include <sys/socket.h>])
186         use_internal_pbkdf2=1
187         NO_FIPS([])
188 ])
189
190 AC_DEFUN([CONFIGURE_NETTLE], [
191         AC_CHECK_HEADERS(nettle/sha.h,,
192                 [AC_MSG_ERROR([You need Nettle cryptographic library.])])
193
194         saved_LIBS=$LIBS
195         AC_CHECK_LIB(nettle, nettle_ripemd160_init,,
196                 [AC_MSG_ERROR([You need Nettle library version 2.4 or more recent.])])
197         CRYPTO_LIBS=$LIBS
198         LIBS=$saved_LIBS
199
200         CRYPTO_STATIC_LIBS=$CRYPTO_LIBS
201         use_internal_pbkdf2=1
202         NO_FIPS([])
203 ])
204
205 dnl ==========================================================================
206 saved_LIBS=$LIBS
207
208 AC_ARG_ENABLE([static-cryptsetup],
209         AS_HELP_STRING([--enable-static-cryptsetup],
210         [enable build of static cryptsetup binary]))
211 if test x$enable_static_cryptsetup = xyes; then
212         if test x$enable_static = xno; then
213                 AC_MSG_WARN([Requested static cryptsetup build, enabling static library.])
214                 enable_static=yes
215         fi
216 fi
217 AM_CONDITIONAL(STATIC_TOOLS, test x$enable_static_cryptsetup = xyes)
218
219 AC_ARG_ENABLE(veritysetup,
220         AS_HELP_STRING([--disable-veritysetup],
221         [disable veritysetup support]),[], [enable_veritysetup=yes])
222 AM_CONDITIONAL(VERITYSETUP, test x$enable_veritysetup = xyes)
223
224 AC_ARG_ENABLE([cryptsetup-reencrypt],
225         AS_HELP_STRING([--enable-cryptsetup-reencrypt],
226         [enable cryptsetup-reencrypt tool]))
227 AM_CONDITIONAL(REENCRYPT, test x$enable_cryptsetup_reencrypt = xyes)
228
229 AC_ARG_ENABLE(selinux,
230         AS_HELP_STRING([--disable-selinux],
231         [disable selinux support [default=auto]]),[], [])
232
233 AC_ARG_ENABLE([udev],
234         AS_HELP_STRING([--disable-udev],
235         [disable udev support]),[], enable_udev=yes)
236
237 dnl Try to use pkg-config for devmapper, but fallback to old detection
238 PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.03],, [
239         AC_CHECK_LIB(devmapper, dm_task_set_name,,
240                 [AC_MSG_ERROR([You need the device-mapper library.])])
241         AC_CHECK_LIB(devmapper, dm_task_set_message,,
242                 [AC_MSG_ERROR([The device-mapper library on your system is too old.])])
243         DEVMAPPER_LIBS=$LIBS
244 ])
245 LIBS=$saved_LIBS
246
247 LIBS="$LIBS $DEVMAPPER_LIBS"
248 AC_CHECK_DECLS([dm_task_secure_data], [], [], [#include <libdevmapper.h>])
249 AC_CHECK_DECLS([dm_task_retry_remove], [], [], [#include <libdevmapper.h>])
250 AC_CHECK_DECLS([DM_UDEV_DISABLE_DISK_RULES_FLAG], [have_cookie=yes], [have_cookie=no], [#include <libdevmapper.h>])
251 if test "x$enable_udev" = xyes; then
252         if test "x$have_cookie" = xno; then
253                 AC_MSG_WARN([The device-mapper library on your system has no udev support, udev support disabled.])
254         else
255                 AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
256         fi
257 fi
258 LIBS=$saved_LIBS
259
260 dnl Crypto backend configuration.
261 AC_ARG_WITH([crypto_backend],
262         AS_HELP_STRING([--with-crypto_backend=BACKEND], [crypto backend (gcrypt/openssl/nss/kernel/nettle) [gcrypt]]),
263         [], with_crypto_backend=gcrypt
264 )
265
266 dnl Kernel crypto API backend needed for benchmark and tcrypt
267 AC_ARG_ENABLE([kernel_crypto], AS_HELP_STRING([--disable-kernel_crypto],
268         [disable kernel userspace crypto (no benchmark and tcrypt)]),
269         [with_kernel_crypto=$enableval],
270         [with_kernel_crypto=yes])
271
272 if test "x$with_kernel_crypto" = "xyes"; then
273         AC_CHECK_HEADERS(linux/if_alg.h,,
274                 [AC_MSG_ERROR([You need Linux kernel headers with userspace crypto interface. (Or use --disable-kernel_crypto.)])])
275         AC_DEFINE(ENABLE_AF_ALG, 1, [Enable using of kernel userspace crypto])
276 fi
277
278 case $with_crypto_backend in
279         gcrypt)  CONFIGURE_GCRYPT([]) ;;
280         openssl) CONFIGURE_OPENSSL([]) ;;
281         nss)     CONFIGURE_NSS([]) ;;
282         kernel)  CONFIGURE_KERNEL([]) ;;
283         nettle)  CONFIGURE_NETTLE([]) ;;
284         *) AC_MSG_ERROR([Unknown crypto backend.]) ;;
285 esac
286 AM_CONDITIONAL(CRYPTO_BACKEND_GCRYPT,  test $with_crypto_backend = gcrypt)
287 AM_CONDITIONAL(CRYPTO_BACKEND_OPENSSL, test $with_crypto_backend = openssl)
288 AM_CONDITIONAL(CRYPTO_BACKEND_NSS,     test $with_crypto_backend = nss)
289 AM_CONDITIONAL(CRYPTO_BACKEND_KERNEL,  test $with_crypto_backend = kernel)
290 AM_CONDITIONAL(CRYPTO_BACKEND_NETTLE,  test $with_crypto_backend = nettle)
291
292 AM_CONDITIONAL(CRYPTO_INTERNAL_PBKDF2, test $use_internal_pbkdf2 = 1)
293 AC_DEFINE_UNQUOTED(USE_INTERNAL_PBKDF2, [$use_internal_pbkdf2], [Use internal PBKDF2])
294
295 dnl Magic for cryptsetup.static build.
296 if test x$enable_static_cryptsetup = xyes; then
297         saved_PKG_CONFIG=$PKG_CONFIG
298         PKG_CONFIG="$PKG_CONFIG --static"
299
300         LIBS="$saved_LIBS -static"
301         AC_CHECK_LIB(popt, poptGetContext,,
302                 AC_MSG_ERROR([Cannot find static popt library.]))
303
304         dnl Try to detect needed device-mapper static libraries, try pkg-config first.
305         LIBS="$saved_LIBS -static"
306         PKG_CHECK_MODULES([DEVMAPPER_STATIC], [devmapper >= 1.02.27],,[
307                 DEVMAPPER_STATIC_LIBS=$DEVMAPPER_LIBS
308                 if test "x$enable_selinux" != xno; then
309                         AC_CHECK_LIB(sepol, sepol_bool_set)
310                         AC_CHECK_LIB(selinux, is_selinux_enabled)
311                         DEVMAPPER_STATIC_LIBS="$DEVMAPPER_STATIC_LIBS $LIBS"
312                 fi
313         ])
314         LIBS="$saved_LIBS $DEVMAPPER_STATIC_LIBS"
315         AC_CHECK_LIB(devmapper, dm_task_set_uuid,,
316                 AC_MSG_ERROR([Cannot link with static device-mapper library.]))
317
318         dnl Try to detect uuid static library.
319         LIBS="$saved_LIBS -static"
320         AC_CHECK_LIB(uuid, uuid_generate,,
321                 AC_MSG_ERROR([Cannot find static uuid library.]))
322
323         LIBS=$saved_LIBS
324         PKG_CONFIG=$saved_PKG_CONFIG
325 fi
326
327 AC_SUBST([DEVMAPPER_LIBS])
328 AC_SUBST([DEVMAPPER_STATIC_LIBS])
329
330 AC_SUBST([PWQUALITY_LIBS])
331 AC_SUBST([PWQUALITY_STATIC_LIBS])
332
333 AC_SUBST([CRYPTO_CFLAGS])
334 AC_SUBST([CRYPTO_LIBS])
335 AC_SUBST([CRYPTO_STATIC_LIBS])
336
337 AC_SUBST([LIBCRYPTSETUP_VERSION])
338 AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
339 AC_SUBST([LIBCRYPTSETUP_VERSION_FIPS])
340
341 dnl ==========================================================================
342 AC_ARG_ENABLE([dev-random], AS_HELP_STRING([--enable-dev-random],
343 [use blocking /dev/random by default for key generator (otherwise use /dev/urandom)]),
344 [default_rng=/dev/random], [default_rng=/dev/urandom])
345 AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])
346
347 dnl ==========================================================================
348 AC_DEFUN([CS_DEFINE],
349         [AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
350 ])
351
352 AC_DEFUN([CS_STR_WITH], [AC_ARG_WITH([$1],
353         [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
354         [CS_DEFINE([$1], ["$withval"], [$2])],
355         [CS_DEFINE([$1], ["$3"], [$2])]
356 )])
357
358 AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
359         [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
360         [CS_DEFINE([$1], [$withval], [$2])],
361         [CS_DEFINE([$1], [$3], [$2])]
362 )])
363
364 dnl ==========================================================================
365 dnl Python bindings
366 AC_ARG_ENABLE([python], AS_HELP_STRING([--enable-python],[enable Python bindings]),
367 [with_python=$enableval],
368 [with_python=no])
369
370 if test "x$with_python" = "xyes"; then
371         AM_PATH_PYTHON([2.4])
372
373         if ! test -x "$PYTHON-config" ; then
374             AC_MSG_ERROR([Cannot find python development packages to build bindings])
375         fi
376
377         PYTHON_INCLUDES=$($PYTHON-config --includes)
378         AC_SUBST(PYTHON_INCLUDES)
379 fi
380 AM_CONDITIONAL([PYTHON_CRYPTSETUP], [test "x$with_python" = "xyes"])
381
382 dnl ==========================================================================
383 CS_STR_WITH([plain-hash],   [password hashing function for plain mode], [ripemd160])
384 CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
385 CS_STR_WITH([plain-mode],   [cipher mode for plain mode], [cbc-essiv:sha256])
386 CS_NUM_WITH([plain-keybits],[key length in bits for plain mode], [256])
387
388 CS_STR_WITH([luks1-hash],   [hash function for LUKS1 header], [sha1])
389 CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes])
390 CS_STR_WITH([luks1-mode],   [cipher mode for LUKS1], [xts-plain64])
391 CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
392 CS_NUM_WITH([luks1-iter-time],[PBKDF2 iteration time for LUKS1 (in ms)], [1000])
393
394 CS_STR_WITH([loopaes-cipher], [cipher for loop-AES mode], [aes])
395 CS_NUM_WITH([loopaes-keybits],[key length in bits for loop-AES mode], [256])
396
397 CS_NUM_WITH([keyfile-size-maxkb],[maximum keyfile size (in KiB)], [8192])
398 CS_NUM_WITH([passphrase-size-max],[maximum keyfile size (in characters)], [512])
399
400 CS_STR_WITH([verity-hash],       [hash function for verity mode], [sha256])
401 CS_NUM_WITH([verity-data-block], [data block size for verity mode], [4096])
402 CS_NUM_WITH([verity-hash-block], [hash block size for verity mode], [4096])
403 CS_NUM_WITH([verity-salt-size],  [salt size for verity mode], [32])
404
405 dnl ==========================================================================
406
407 AC_CONFIG_FILES([ Makefile
408 lib/Makefile
409 lib/libcryptsetup.pc
410 lib/crypto_backend/Makefile
411 lib/luks1/Makefile
412 lib/loopaes/Makefile
413 lib/verity/Makefile
414 lib/tcrypt/Makefile
415 src/Makefile
416 po/Makefile.in
417 man/Makefile
418 tests/Makefile
419 python/Makefile
420 ])
421 AC_OUTPUT