aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
blob: c57cf464e43fb95ce2007e240a989c963205b3a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
AC_PREREQ([2.60])

m4_define([RELEASE], 2.1.2)

AC_INIT([mtd-utils], [RELEASE], [linux-mtd@lists.infradead.org], mtd-utils)

AC_ARG_ENABLE([unit-tests],
	[AS_HELP_STRING([--enable-unit-tests], [Compile unit test programs])],
	[case "${enableval}" in
	yes) AM_CONDITIONAL([UNIT_TESTS], [true]) ;;
	no)  AM_CONDITIONAL([UNIT_TESTS], [false]) ;;
	*) AC_MSG_ERROR([bad value ${enableval} for --enable-unit-tests]) ;;
	esac],
	[AM_CONDITIONAL([UNIT_TESTS], [false])])

AM_COND_IF([UNIT_TESTS], [: ${CFLAGS=""}], [])


AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign subdir-objects dist-bzip2])
AM_SILENT_RULES([yes])
AC_PROG_LIBTOOL
AC_DISABLE_STATIC
AC_PROG_CC
AC_PROG_INSTALL
AC_SYS_LARGEFILE

m4_ifndef([PKG_PROG_PKG_CONFIG],
  [m4_fatal([Could not locate the pkg-config autoconf
    macros. These are usually located in /usr/share/aclocal/pkg.m4.
    If your macros are in a different location, try setting the
    environment variable AL_OPTS="-I/other/macro/dir" before running
    ./autogen.sh or autoreconf again. Make sure pkg-config is installed.])])
PKG_PROG_PKG_CONFIG

## compiler warnings
UL_WARN_ADD([-Wall])
UL_WARN_ADD([-Wextra])
UL_WARN_ADD([-Wunused])
UL_WARN_ADD([-Wmissing-prototypes])
UL_WARN_ADD([-Wmissing-declarations])
UL_WARN_ADD([-Wwrite-strings])
UL_WARN_ADD([-Wjump-misses-init])
UL_WARN_ADD([-Wuninitialized])
UL_WARN_ADD([-Winit-self])
UL_WARN_ADD([-Wlogical-op])
UL_WARN_ADD([-Wunused-but-set-parameter])
UL_WARN_ADD([-Wunused-but-set-variable])
UL_WARN_ADD([-Wunused-parameter])
UL_WARN_ADD([-Wunused-result])
UL_WARN_ADD([-Wunused-variable])
UL_WARN_ADD([-Wduplicated-cond])
UL_WARN_ADD([-Wduplicated-branches])
UL_WARN_ADD([-Wrestrict])
UL_WARN_ADD([-Wnull-dereference])

UL_WARN_ADD([-Wno-shadow])
UL_WARN_ADD([-Wno-sign-compare])

AC_SUBST([WARN_CFLAGS])

###### handle configure switches, select dependencies ######

need_clock_gettime="no"
need_pthread="no"
need_uuid="no"
need_zlib="no"
need_lzo="no"
need_zstd="no"
need_xattr="no"
need_cmocka="no"
need_selinux="no"
need_openssl="no"

AM_COND_IF([UNIT_TESTS], [
	need_cmocka="yes"
])


AC_ARG_ENABLE([tests],
	[AS_HELP_STRING([--disable-tests], [Compile test programs])],
	[case "${enableval}" in
	yes) AM_CONDITIONAL([BUILD_TESTS], [true]) ;;
	no)  AM_CONDITIONAL([BUILD_TESTS], [false]) ;;
	*) AC_MSG_ERROR([bad value ${enableval} for --disable-tests]) ;;
	esac],
	[AM_CONDITIONAL([BUILD_TESTS], [true])])

AM_COND_IF([BUILD_TESTS], [
	need_clock_gettime="yes"
	need_pthread="yes"
])

AC_DEFINE_DIR(TESTBINDIR, libexecdir/mtd-utils,
	      [Path where test and debug programs will be installed])

AC_ARG_ENABLE([ubihealthd],
	[AS_HELP_STRING([--enable-ubihealthd], [Build the ubihealthd program])],
	[need_getrandom="${enableval}"],[need_getrandom="auto"])

AC_ARG_ENABLE([lsmtd],
	[AS_HELP_STRING([--disable-lsmtd], [Do not build the lsmtd program])],
	[case "${enableval}" in
	yes) AM_CONDITIONAL([BUILD_LSMTD], [true]) ;;
	no)  AM_CONDITIONAL([BUILD_LSMTD], [false]) ;;
	*) AC_MSG_ERROR([bad value ${enableval} for --disable-lsmtd]) ;;
	esac],
	[AM_CONDITIONAL([BUILD_LSMTD], [true])])

AC_ARG_WITH([jffs],
	[AS_HELP_STRING([--without-jffs], [Disable jffsX utilities])],
	[case "${withval}" in
	yes) AM_CONDITIONAL([BUILD_JFFSX], [true]) ;;
	no)  AM_CONDITIONAL([BUILD_JFFSX], [false]) ;;
	*) AC_MSG_ERROR([bad value ${withval} for --without-jffs]) ;;
	esac],
	[AM_CONDITIONAL([BUILD_JFFSX], [true])])

AC_ARG_WITH([ubifs],
	[AS_HELP_STRING([--without-ubifs], [Disable ubifs utilities])],
	[case "${withval}" in
	yes) AM_CONDITIONAL([BUILD_UBIFS], [true]) ;;
	no)  AM_CONDITIONAL([BUILD_UBIFS], [false]) ;;
	*) AC_MSG_ERROR([bad value ${withval} for --without-ubifs]) ;;
	esac],
	[AM_CONDITIONAL([BUILD_UBIFS], [true])])

AM_COND_IF([BUILD_UBIFS], [
	need_uuid="yes"
	need_xattr="yes"
	need_zlib="yes"
	need_lzo="yes"
	need_zstd="yes"
	need_openssl="yes"
	AS_VAR_IF([need_getrandom], [auto], [need_getrandom="yes"])
])

AM_COND_IF([BUILD_JFFSX], [
	need_xattr="yes"
	need_zlib="yes"
	need_lzo="yes"
])

AC_ARG_WITH([xattr],
	[AS_HELP_STRING([--without-xattr],
		[Disable support forextended file attributes])],
	[case "${withval}" in
	yes) ;;
	no) need_xattr="no" ;;
	*) AC_MSG_ERROR([bad value ${withval} for --without-xattr]) ;;
	esac])

AC_ARG_WITH([lzo],
	[AS_HELP_STRING([--without-lzo], [Disable support for LZO compression])],
	[case "${withval}" in
	yes) ;;
	no) need_lzo="no" ;;
	*) AC_MSG_ERROR([bad value ${withval} for --without-lzo]) ;;
	esac])

AC_ARG_WITH([zstd],
	[AS_HELP_STRING([--without-zstd], [Disable support for ZSTD compression])],
	[case "${withval}" in
	yes) ;;
	no) need_zstd="no" ;;
	*) AC_MSG_ERROR([bad value ${withval} for --without-zstd]) ;;
	esac])

AC_ARG_WITH([selinux],
	[AS_HELP_STRING([--with-selinux],
		[Enable support for selinux extended attributes])],
	[case "${withval}" in
	yes) need_selinux="yes";;
	no) ;;
	*) AC_MSG_ERROR([bad value ${withval} for --with-selinux]) ;;
	esac])

AC_ARG_WITH([crypto],
	[AS_HELP_STRING([--without-crypto],
		[Disable support for UBIFS crypto features])],
	[case "${withval}" in
	yes) ;;
	no) need_openssl="no";;
	*) AC_MSG_ERROR([bad value ${withval} for --without-crypto]) ;;
	esac])

##### search for dependencies #####

clock_gettime_missing="no"
pthread_missing="no"
uuid_missing="no"
zlib_missing="no"
lzo_missing="no"
zstd_missing="no"
xattr_missing="no"
cmocka_missing="no"
selinux_missing="no"
openssl_missing="no"
getrandom_missing="no"

if test "x$need_zlib" = "xyes"; then
	PKG_CHECK_MODULES(ZLIB, [zlib], [], [zlib_missing="yes"])
fi

if test "x$need_selinux" = "xyes"; then
	PKG_CHECK_MODULES(LIBSELINUX, [libselinux], [], [selinux_missing="yes"])
fi

if test "x$need_uuid" = "xyes"; then
	PKG_CHECK_MODULES(UUID, [uuid], [], [uuid_missing="yes"])
fi

if test "x$need_clock_gettime" = "xyes"; then
	AC_SEARCH_LIBS([clock_gettime], [rt posix4])
	AC_CHECK_FUNCS([clock_gettime], [], [clock_gettime_missing="yes"])
fi

if test "x$need_pthread" = "xyes"; then
	AX_PTHREAD([], [pthread_missing="yes"])
fi

if test "x$need_lzo" = "xyes"; then
	AC_ARG_VAR([LZO_CFLAGS], [C compiler flags for lzo])
	AC_ARG_VAR([LZO_LIBS], [linker flags for lzo])
	AC_CHECK_LIB([lzo2], [lzo1x_1_15_compress], [LZO_LIBS="-llzo2"],
		[AC_CHECK_LIB([lzo],[lzo1x_1_15_compress],[LZO_LIBS="-llzo"],
			[lzo_missing="yes"]
		)]
	)
fi

if test "x$need_zstd" = "xyes"; then
	PKG_CHECK_MODULES([ZSTD], [libzstd],, zstd_missing="yes")
fi

if test "x$need_xattr" = "xyes"; then
	AC_CHECK_HEADERS([sys/xattr.h], [], [xattr_missing="yes"])
	AC_CHECK_HEADERS([sys/acl.h], [], [xattr_missing="yes"])
fi

if test "x$need_selinux" = "xyes"; then
	AC_CHECK_HEADERS([selinux/selinux.h], [], [selinux_missing="yes"])
	AC_CHECK_HEADERS([selinux/label.h], [], [selinux_missing="yes"])
fi

if test "x$need_openssl" = "xyes"; then
	AC_CHECK_HEADER(openssl/rand.h)
	PKG_CHECK_MODULES(OPENSSL, [openssl], [], [openssl_missing="yes"])
fi

if test "x$need_getrandom" = "xyes"; then
	AC_CHECK_HEADERS([sys/random.h], [], [getrandom_missing="yes"])
fi

if test "x$need_cmocka" = "xyes"; then
	PKG_CHECK_MODULES(CMOCKA, [cmocka], [], [cmocka_missing="yes"])
fi

AC_CHECK_HEADERS([execinfo.h])

##### produce summary on dependencies #####

dep_missing="no"

if test "x$clock_gettime_missing" = "xyes"; then
	AC_MSG_WARN([cannot find clock_gettime function required for MTD tests])
	AC_MSG_NOTICE([building test programs can optionally be dissabled])
	dep_missing="yes"
fi

if test "x$pthread_missing" = "xyes"; then
	AC_MSG_WARN([cannot find pthread support required for test programs])
	AC_MSG_NOTICE([building test programs can optionally be dissabled])
	dep_missing="yes"
fi

if test "x$uuid_missing" = "xyes"; then
	AC_MSG_WARN([cannot find uuid library required for mkfs.ubifs])
	AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
	dep_missing="yes"
fi

if test "x$zlib_missing" = "xyes"; then
	AC_MSG_WARN([cannot find ZLIB library required for mkfs programs])
	AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
	AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.jffs2])
	dep_missing="yes"
fi

if test "x$lzo_missing" = "xyes"; then
	AC_MSG_WARN([cannot find LZO library required for mkfs programs])
	AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
	AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.jffs2])
	AC_MSG_NOTICE([mtd-utils can optionally be built without LZO support])
	dep_missing="yes"
fi

if test "x$zstd_missing" = "xyes"; then
	AC_MSG_WARN([cannot find ZSTD library required for mkfs program])
	AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
	AC_MSG_NOTICE([mtd-utils can optionally be built without ZSTD support])
	dep_missing="yes"
fi

if test "x$xattr_missing" = "xyes"; then
	AC_MSG_WARN([cannot find headers for extended attributes])
	AC_MSG_WARN([disabling XATTR support])
	need_xattr="no"
fi

if test "x$selinux_missing" = "xyes"; then
	AC_MSG_WARN([cannot find headers for selinux library])
	AC_MSG_WARN([disabling SELINUX support])
	need_selinux="no"
fi

if test "x$openssl_missing" = "xyes"; then
	AC_MSG_WARN([cannot find headers for OpenSSL library])
	AC_MSG_WARN([disabling OpenSSL support])
	need_openssl="no"
fi

if test "x$getrandom_missing" = "xyes"; then
	AC_MSG_WARN([cannot find headers for getrandom() function])
	AC_MSG_WARN([disabling UBIFS ubihealthd support])
	need_getrandom="no"
fi

if test "x$cmocka_missing" = "xyes"; then
	AC_MSG_WARN([cannot find CMocka library required for unit tests])
	AC_MSG_NOTICE([unit tests can optionally be disabled])
	dep_missing="yes"
fi

if test "x$dep_missing" = "xyes"; then
	AC_MSG_ERROR([missing one or more dependencies])
fi

##### generate output #####

AM_CONDITIONAL([WITHOUT_LZO], [test "x$need_lzo" != "xyes"])
AM_CONDITIONAL([WITHOUT_ZSTD], [test "x$need_zstd" != "xyes"])
AM_CONDITIONAL([WITHOUT_XATTR], [test "x$need_xattr" != "xyes"])
AM_CONDITIONAL([WITH_SELINUX], [test "x$need_selinux" == "xyes"])
AM_CONDITIONAL([WITH_CRYPTO], [test "x$need_openssl" == "xyes"])
AM_CONDITIONAL([WITH_GETRANDOM], [test "x$need_getrandom" == "xyes"])

AC_CHECK_SIZEOF([off_t])
AC_CHECK_SIZEOF([loff_t])

AC_CONFIG_HEADERS([include/config.h])

AC_CONFIG_FILES([tests/fs-tests/fs_help_all.sh
	tests/fs-tests/fs_run_all.sh
	tests/fs-tests/stress/fs_stress00.sh
	tests/fs-tests/stress/fs_stress01.sh
	tests/ubi-tests/runubitests.sh
	tests/ubi-tests/ubi-stress-test.sh])

AC_OUTPUT([Makefile])