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