Version 1.4.0.
[platform/upstream/cryptsetup.git] / configure.in
1 AC_PREREQ([2.67])
2 AC_INIT([cryptsetup],[1.4.0])
3
4 dnl library version from <major>.<minor>.<release>[-<suffix>]
5 LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
6 LIBCRYPTSETUP_VERSION_INFO=4:0:0
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 Crypto backend functions
66
67 AC_DEFUN([CONFIGURE_GCRYPT], [
68         AM_PATH_LIBGCRYPT(1.1.42,,[AC_MSG_ERROR('You need the gcrypt library')])
69
70         if test x$enable_static_cryptsetup = xyes; then
71                 saved_LIBS=$LIBS
72                 LIBS="$saved_LIBS $LIBGCRYPT_LIBS -static"
73                 AC_CHECK_LIB(gcrypt, gcry_check_version,,
74                         AC_MSG_ERROR([Cannot find static gcrypt library.]),
75                         [-lgpg-error])
76                 LIBGCRYPT_STATIC_LIBS="$LIBGCRYPT_LIBS -lgpg-error"
77                 LIBS=$saved_LIBS
78         fi
79
80         CRYPTO_CFLAGS=$LIBGCRYPT_CFLAGS
81         CRYPTO_LIBS=$LIBGCRYPT_LIBS
82         CRYPTO_STATIC_LIBS=$LIBGCRYPT_STATIC_LIBS
83 ])
84
85 AC_DEFUN([CONFIGURE_OPENSSL], [
86         PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8],,
87                 AC_MSG_ERROR('You need openssl library'))
88         CRYPTO_CFLAGS=$OPENSSL_CFLAGS
89         CRYPTO_LIBS=$OPENSSL_LIBS
90
91         if test x$enable_static_cryptsetup = xyes; then
92                 saved_PKG_CONFIG=$PKG_CONFIG
93                 PKG_CONFIG="$PKG_CONFIG --static"
94                 PKG_CHECK_MODULES([OPENSSL], [openssl])
95                 CRYPTO_STATIC_LIBS=$OPENSSL_LIBS
96                 PKG_CONFIG=$saved_PKG_CONFIG
97         fi
98 ])
99
100 AC_DEFUN([CONFIGURE_NSS], [
101         if test x$enable_static_cryptsetup = xyes; then
102                 AC_MSG_ERROR([Static build of cryptsetup is not supported with NSS.]),
103         fi
104
105         AC_MSG_WARN([NSS backend does NOT provide backward compatibility (missing ripemd160 hash).])
106
107         PKG_CHECK_MODULES([NSS], [nss],,
108                 AC_MSG_ERROR('You need nss library'))
109         CRYPTO_CFLAGS=$NSS_CFLAGS
110         CRYPTO_LIBS=$NSS_LIBS
111 ])
112
113 AC_DEFUN([CONFIGURE_KERNEL], [
114         AC_CHECK_HEADERS(linux/if_alg.h,,
115                 [AC_MSG_ERROR('You need Linux kernel with userspace crypto interface.')])
116 #       AC_CHECK_DECLS([AF_ALG],,
117 #               [AC_MSG_ERROR('You need Linux kernel with userspace crypto interface.')],
118 #               [#include <sys/socket.h>])
119
120 ])
121
122 AC_DEFUN([CONFIGURE_NETTLE], [
123         AC_CHECK_HEADERS(nettle/sha.h,,
124                 [AC_MSG_ERROR('You need Nettle cryptographic library.')])
125
126         saved_LIBS=$LIBS
127         AC_CHECK_LIB(nettle, nettle_ripemd160_init,,
128                 [AC_MSG_ERROR('You need Nettle library version 2.4 or more recent.')])
129         CRYPTO_LIBS=$LIBS
130         LIBS=$saved_LIBS
131
132         CRYPTO_STATIC_LIBS=$CRYPTO_LIBS
133 ])
134
135 dnl ==========================================================================
136 saved_LIBS=$LIBS
137
138 AC_ARG_ENABLE([static-cryptsetup],
139         AS_HELP_STRING([--enable-static-cryptsetup],
140         [enable build of static cryptsetup binary]))
141 if test x$enable_static_cryptsetup = xyes; then
142         if test x$enable_static = xno; then
143                 AC_MSG_WARN([Requested static cryptsetup build, enabling static library.])
144                 enable_static=yes
145         fi
146 fi
147 AM_CONDITIONAL(STATIC_CRYPTSETUP, test x$enable_static_cryptsetup = xyes)
148
149 AC_ARG_ENABLE(selinux,
150         AS_HELP_STRING([--disable-selinux],
151         [disable selinux support [default=auto]]),[], [])
152
153 AC_ARG_ENABLE([udev],
154         AS_HELP_STRING([--disable-udev],
155         [disable udev support]),[], enable_udev=yes)
156
157 dnl Try to use pkg-config for devmapper, but fallback to old detection
158 PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.03],, [
159         AC_CHECK_LIB(devmapper, dm_task_set_name,,
160                 [AC_MSG_ERROR([You need the device-mapper library.])])
161         AC_CHECK_LIB(devmapper, dm_task_set_message,,
162                 [AC_MSG_ERROR([The device-mapper library on your system is too old.])])
163         DEVMAPPER_LIBS=$LIBS
164 ])
165 LIBS=$saved_LIBS
166
167 LIBS="$LIBS $DEVMAPPER_LIBS"
168 AC_CHECK_DECLS([dm_task_secure_data], [], [], [#include <libdevmapper.h>])
169 AC_CHECK_DECLS([DM_UDEV_DISABLE_DISK_RULES_FLAG], [have_cookie=yes], [have_cookie=no], [#include <libdevmapper.h>])
170 if test "x$enable_udev" = xyes; then
171         if test "x$have_cookie" = xno; then
172                 AC_MSG_WARN([The device-mapper library on your system has no udev support, udev support disabled.])
173         else
174                 AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
175         fi
176 fi
177 LIBS=$saved_LIBS
178
179 dnl Crypto backend configuration.
180 AC_ARG_WITH([crypto_backend],
181         AS_HELP_STRING([--with-crypto_backend=BACKEND], [crypto backend (gcrypt/openssl/nss/kernel/nettle) [gcrypt]]),
182         [], with_crypto_backend=gcrypt
183 )
184 case $with_crypto_backend in
185         gcrypt)  CONFIGURE_GCRYPT([]) ;;
186         openssl) CONFIGURE_OPENSSL([]) ;;
187         nss)     CONFIGURE_NSS([]) ;;
188         kernel)  CONFIGURE_KERNEL([]) ;;
189         nettle)  CONFIGURE_NETTLE([]) ;;
190         *) AC_MSG_ERROR([Unknown crypto backend.]) ;;
191 esac
192 AM_CONDITIONAL(CRYPTO_BACKEND_GCRYPT,  test $with_crypto_backend = gcrypt)
193 AM_CONDITIONAL(CRYPTO_BACKEND_OPENSSL, test $with_crypto_backend = openssl)
194 AM_CONDITIONAL(CRYPTO_BACKEND_NSS,     test $with_crypto_backend = nss)
195 AM_CONDITIONAL(CRYPTO_BACKEND_KERNEL,  test $with_crypto_backend = kernel)
196 AM_CONDITIONAL(CRYPTO_BACKEND_NETTLE,  test $with_crypto_backend = nettle)
197
198 dnl Magic for cryptsetup.static build.
199 if test x$enable_static_cryptsetup = xyes; then
200         saved_PKG_CONFIG=$PKG_CONFIG
201         PKG_CONFIG="$PKG_CONFIG --static"
202
203         LIBS="$saved_LIBS -static"
204         AC_CHECK_LIB(popt, poptGetContext,,
205                 AC_MSG_ERROR([Cannot find static popt library.]))
206
207         dnl Try to detect needed device-mapper static libraries, try pkg-config first.
208         LIBS="$saved_LIBS -static"
209         PKG_CHECK_MODULES([DEVMAPPER_STATIC], [devmapper >= 1.02.27],,[
210                 DEVMAPPER_STATIC_LIBS=$DEVMAPPER_LIBS
211                 if test "x$enable_selinux" != xno; then
212                         AC_CHECK_LIB(sepol, sepol_bool_set)
213                         AC_CHECK_LIB(selinux, is_selinux_enabled)
214                         DEVMAPPER_STATIC_LIBS="$DEVMAPPER_STATIC_LIBS $LIBS"
215                 fi
216         ])
217         LIBS="$saved_LIBS $DEVMAPPER_STATIC_LIBS"
218         AC_CHECK_LIB(devmapper, dm_task_set_uuid,,
219                 AC_MSG_ERROR([Cannot link with static device-mapper library.]))
220
221         dnl Try to detect uuid static library.
222         LIBS="$saved_LIBS -static"
223         AC_CHECK_LIB(uuid, uuid_generate,,
224                 AC_MSG_ERROR([Cannot find static uuid library.]))
225
226         LIBS=$saved_LIBS
227         PKG_CONFIG=$saved_PKG_CONFIG
228 fi
229
230 AC_SUBST([DEVMAPPER_LIBS])
231 AC_SUBST([DEVMAPPER_STATIC_LIBS])
232
233 AC_SUBST([CRYPTO_CFLAGS])
234 AC_SUBST([CRYPTO_LIBS])
235 AC_SUBST([CRYPTO_STATIC_LIBS])
236
237 AC_SUBST([LIBCRYPTSETUP_VERSION])
238 AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
239
240 dnl ==========================================================================
241 AC_ARG_ENABLE([dev-random], AS_HELP_STRING([--enable-dev-random],
242 [use blocking /dev/random by default for key generator (otherwise use /dev/urandom)]),
243 [default_rng=/dev/random], [default_rng=/dev/urandom])
244 AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])
245
246 dnl ==========================================================================
247 AC_DEFUN([CS_DEFINE],
248         [AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
249 ])
250
251 AC_DEFUN([CS_STR_WITH], [AC_ARG_WITH([$1],
252         [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
253         [CS_DEFINE([$1], ["$withval"], [$2])],
254         [CS_DEFINE([$1], ["$3"], [$2])]
255 )])
256
257 AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
258         [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
259         [CS_DEFINE([$1], [$withval], [$2])],
260         [CS_DEFINE([$1], [$3], [$2])]
261 )])
262
263 CS_STR_WITH([plain-hash],   [password hashing function for plain mode], [ripemd160])
264 CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
265 CS_STR_WITH([plain-mode],   [cipher mode for plain mode], [cbc-essiv:sha256])
266 CS_NUM_WITH([plain-keybits],[key length in bits for plain mode], [256])
267
268 CS_STR_WITH([luks1-hash],   [hash function for LUKS1 header], [sha1])
269 CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes])
270 CS_STR_WITH([luks1-mode],   [cipher mode for LUKS1], [cbc-essiv:sha256])
271 CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
272
273 CS_STR_WITH([loopaes-cipher], [cipher for loop-AES mode], [aes])
274 CS_NUM_WITH([loopaes-keybits],[key length in bits for loop-AES mode], [256])
275
276 CS_NUM_WITH([keyfile-size-maxkb],[maximum keyfile size (in kilobytes)], [8192])
277 CS_NUM_WITH([passphrase-size-max],[maximum keyfile size (in kilobytes)], [512])
278
279 dnl ==========================================================================
280
281 AC_CONFIG_FILES([ Makefile
282 lib/Makefile
283 lib/libcryptsetup.pc
284 lib/crypto_backend/Makefile
285 lib/luks1/Makefile
286 lib/loopaes/Makefile
287 src/Makefile
288 po/Makefile.in
289 man/Makefile
290 tests/Makefile
291 ])
292 AC_OUTPUT