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