Detect and use devmapper udev support if available (disable by --disable-udev).
[platform/upstream/cryptsetup.git] / configure.in
1 AC_PREREQ(2.57)
2 AC_INIT(cryptsetup,1.1.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 AM_CONFIG_HEADER([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_GNU_SOURCE
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 AM_PROG_LIBTOOL
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_STRUCT_ST_RDEV
51 AC_SYS_LARGEFILE
52
53 AC_PROG_GCC_TRADITIONAL
54
55 dnl ==========================================================================
56
57 AM_GNU_GETTEXT([external],[need-ngettext])
58 AM_GNU_GETTEXT_VERSION([0.15])
59
60 dnl ==========================================================================
61
62 saved_LIBS=$LIBS
63 AC_CHECK_LIB(popt, poptConfigFileToString,,
64         [AC_MSG_ERROR([You need popt 1.7 or newer to compile.])])
65 AC_SUBST(POPT_LIBS, $LIBS)
66 LIBS=$saved_LIBS
67
68 dnl ==========================================================================
69
70 AC_ARG_ENABLE(shared-library,
71 [  --disable-shared-library
72                           disable building of shared cryptsetup library],,
73 enable_shared_library=yes)
74 AM_CONDITIONAL(STATIC_LIBRARY, test x$enable_shared_library = xno)
75
76 AC_ARG_ENABLE(selinux,
77 [  --disable-selinux       disable selinux support [[default=auto]]],[], [])
78
79 AC_ARG_ENABLE([udev],AS_HELP_STRING([--disable-udev],[disable udev support]),[], enable_udev=yes)
80
81 saved_LIBS=$LIBS
82 AC_CHECK_LIB(devmapper, dm_task_set_name,,[AC_MSG_ERROR('You need the device-mapper library')])
83 AC_CHECK_LIB(devmapper, dm_task_set_message,,
84         [AC_MSG_ERROR([The device-mapper library on your system is too old.])])
85
86 AC_CHECK_FUNCS([dm_task_set_cookie], [have_cookie=yes], [have_cookie=no])
87 if test "x$enable_udev" = xyes; then
88         if test "x$have_cookie" = xno; then
89                 AC_MSG_ERROR([The device-mapper library on your system has no udev support, consider --disable-udev.])
90         fi
91         AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
92 fi
93
94 DEVMAPPER_LIBS=$LIBS
95 LIBS=$saved_LIBS
96 if test "x$enable_selinux" != xno; then
97         AC_CHECK_LIB(sepol, sepol_bool_set)
98         AC_CHECK_LIB(selinux, is_selinux_enabled)
99         if test x$enable_static = xyes; then
100                 SELINUX_STATIC_LIBS=$LIBS
101                 # Check if we need -pthread with --enable-static and selinux
102                 saved_LIBS2=$LIBS
103                 LIBS="$LIBS -static"
104                 AC_SEARCH_LIBS([pthread_mutex_lock], [pthread],
105                         [test "$ac_cv_search_pthread_mutex_lock" = "none required" || LIB_PTHREAD=-lpthread])
106                 LIBS=$saved_LIBS2
107         fi
108 fi
109
110 LIBS=$saved_LIBS
111
112 DEVMAPPER_LIBS="$DEVMAPPER_LIBS $LIB_PTHREAD"
113 AC_SUBST([DEVMAPPER_LIBS])
114 AC_SUBST([SELINUX_STATIC_LIBS])
115 AC_SUBST([LIBCRYPTSETUP_VERSION])
116 AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
117
118 dnl ==========================================================================
119 AC_DEFUN([CS_DEFINE],
120         [AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
121 ])
122
123 AC_DEFUN([CS_STR_WITH], [AC_ARG_WITH([$1],
124         [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
125         [CS_DEFINE([$1], ["$withval"], [$2])],
126         [CS_DEFINE([$1], ["$3"], [$2])]
127 )])
128
129 AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
130         [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
131         [CS_DEFINE([$1], [$withval], [$2])],
132         [CS_DEFINE([$1], [$3], [$2])]
133 )])
134
135 CS_STR_WITH([plain-hash],   [password hashing function for plain mode], [ripemd160])
136 CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
137 CS_STR_WITH([plain-mode],   [cipher mode for plain mode], [cbc-essiv:sha256])
138 CS_NUM_WITH([plain-keybits],[key length in bits for plain mode], [256])
139
140 CS_STR_WITH([luks1-hash],   [hash function for LUKS1 header], [sha1])
141 CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes])
142 CS_STR_WITH([luks1-mode],   [cipher mode for LUKS1], [cbc-essiv:sha256])
143 CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
144
145 dnl ==========================================================================
146
147 AM_CONDITIONAL(STATIC_CRYPTSETUP, test x$enable_static = xyes)
148 AM_CONDITIONAL(DYNAMIC_CRYPTSETUP, test x$enable_static = xno)
149
150 dnl ==========================================================================
151
152 AC_OUTPUT([ Makefile
153 lib/Makefile
154 lib/libcryptsetup.pc
155 src/Makefile
156 po/Makefile.in
157 luks/Makefile
158 man/Makefile
159 tests/Makefile
160 ])