Fix RNG comment.
[platform/upstream/cryptsetup.git] / configure.in
1 AC_PREREQ([2.67])
2 AC_INIT([cryptsetup],[1.2.0])
3
4 dnl library version from <major>.<minor>.<release>[-<suffix>]
5 LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
6 LIBCRYPTSETUP_VERSION_INFO=1: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
43 AM_PATH_LIBGCRYPT(1.1.42,,[AC_MSG_ERROR('You need the gcrypt library')])
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 saved_LIBS=$LIBS
69
70 AC_ARG_ENABLE([static-cryptsetup],
71         AS_HELP_STRING([--enable-static-cryptsetup],
72         [enable build of static cryptsetup binary]), [
73         if test x$enable_static = xno; then
74                 AC_MSG_WARN([Requested static cryptsetup build, enabling static library.])
75                 enable_static=yes
76         fi
77         enable_static_cryptsetup=yes])
78 AM_CONDITIONAL(STATIC_CRYPTSETUP, test x$enable_static_cryptsetup = xyes)
79
80 AC_ARG_ENABLE(selinux,
81         AS_HELP_STRING([--disable-selinux],
82         [disable selinux support [default=auto]]),[], [])
83
84 AC_ARG_ENABLE([udev],
85         AS_HELP_STRING([--disable-udev],
86         [disable udev support]),[], enable_udev=yes)
87
88 dnl Try to use pkg-config for devmapper, but fallback to old detection
89 PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.03],, [
90         AC_CHECK_LIB(devmapper, dm_task_set_name,,
91                 [AC_MSG_ERROR([You need the device-mapper library.])])
92         AC_CHECK_LIB(devmapper, dm_task_set_message,,
93                 [AC_MSG_ERROR([The device-mapper library on your system is too old.])])
94         DEVMAPPER_LIBS=$LIBS
95 ])
96 LIBS=$saved_LIBS
97
98 LIBS="$LIBS $DEVMAPPER_LIBS"
99 AC_CHECK_DECLS([DM_UDEV_DISABLE_DISK_RULES_FLAG], [have_cookie=yes], [have_cookie=no], [#include <libdevmapper.h>])
100 if test "x$enable_udev" = xyes; then
101         if test "x$have_cookie" = xno; then
102                 AC_MSG_WARN([The device-mapper library on your system has no udev support, udev support disabled.])
103         else
104                 AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
105         fi
106 fi
107 LIBS=$saved_LIBS
108
109 dnl Magic for cryptsetup.static build.
110 if test x$enable_static_cryptsetup = xyes; then
111         saved_PKG_CONFIG=$PKG_CONFIG
112         PKG_CONFIG="$PKG_CONFIG --static"
113
114         LIBS="$saved_LIBS $LIBGCRYPT_LIBS -static"
115         AC_CHECK_LIB(gcrypt, gcry_check_version,,
116                 AC_MSG_ERROR([Cannot find static gcrypt library.]),
117                 [-lgpg-error])
118         LIBGCRYPT_STATIC_LIBS="$LIBGCRYPT_LIBS -lgpg-error"
119
120         LIBS="$saved_LIBS -static"
121         AC_CHECK_LIB(popt, poptGetContext,,
122                 AC_MSG_ERROR([Cannot find static popt library.]))
123
124         dnl Try to detect needed device-mapper static libraries, try pkg-config first.
125         LIBS="$saved_LIBS -static"
126         PKG_CHECK_MODULES([DEVMAPPER_STATIC], [devmapper >= 1.02.27],,[
127                 DEVMAPPER_STATIC_LIBS=$DEVMAPPER_LIBS
128                 if test "x$enable_selinux" != xno; then
129                         AC_CHECK_LIB(sepol, sepol_bool_set)
130                         AC_CHECK_LIB(selinux, is_selinux_enabled)
131                         DEVMAPPER_STATIC_LIBS="$DEVMAPPER_STATIC_LIBS $LIBS"
132                 fi
133         ])
134         LIBS="$saved_LIBS $DEVMAPPER_STATIC_LIBS"
135         AC_CHECK_LIB(devmapper, dm_task_set_uuid,,
136                 AC_MSG_ERROR([Cannot link with static device-mapper library.]))
137
138         LIBS=$saved_LIBS
139         PKG_CONFIG=$saved_PKG_CONFIG
140 fi
141
142 AC_SUBST([DEVMAPPER_LIBS])
143 AC_SUBST([DEVMAPPER_STATIC_LIBS])
144 AC_SUBST([LIBGCRYPT_STATIC_LIBS])
145 AC_SUBST([LIBCRYPTSETUP_VERSION])
146 AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
147
148 dnl ==========================================================================
149 AC_ARG_ENABLE([dev-random], AS_HELP_STRING([--enable-dev-random],
150 [use blocking /dev/random by default for key generator (otherwise use /dev/urandom)]),
151 [default_rng=/dev/random], [default_rng=/dev/urandom])
152 AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])
153
154 dnl ==========================================================================
155 AC_DEFUN([CS_DEFINE],
156         [AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
157 ])
158
159 AC_DEFUN([CS_STR_WITH], [AC_ARG_WITH([$1],
160         [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
161         [CS_DEFINE([$1], ["$withval"], [$2])],
162         [CS_DEFINE([$1], ["$3"], [$2])]
163 )])
164
165 AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
166         [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
167         [CS_DEFINE([$1], [$withval], [$2])],
168         [CS_DEFINE([$1], [$3], [$2])]
169 )])
170
171 CS_STR_WITH([plain-hash],   [password hashing function for plain mode], [ripemd160])
172 CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
173 CS_STR_WITH([plain-mode],   [cipher mode for plain mode], [cbc-essiv:sha256])
174 CS_NUM_WITH([plain-keybits],[key length in bits for plain mode], [256])
175
176 CS_STR_WITH([luks1-hash],   [hash function for LUKS1 header], [sha1])
177 CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes])
178 CS_STR_WITH([luks1-mode],   [cipher mode for LUKS1], [cbc-essiv:sha256])
179 CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
180
181
182 dnl ==========================================================================
183
184 AC_CONFIG_FILES([ Makefile
185 lib/Makefile
186 lib/libcryptsetup.pc
187 lib/luks1/Makefile
188 src/Makefile
189 po/Makefile.in
190 man/Makefile
191 tests/Makefile
192 ])
193 AC_OUTPUT