]> git.ipfire.org Git - thirdparty/kmod.git/blob - configure.ac
kmod 26
[thirdparty/kmod.git] / configure.ac
1 AC_PREREQ(2.64)
2 AC_INIT([kmod],
3 [26],
4 [linux-modules@vger.kernel.org],
5 [kmod],
6 [http://git.kernel.org/?p=utils/kernel/kmod/kmod.git])
7
8 AC_CONFIG_SRCDIR([libkmod/libkmod.c])
9 AC_CONFIG_MACRO_DIR([m4])
10 AC_CONFIG_HEADERS(config.h)
11 AC_CONFIG_AUX_DIR([build-aux])
12
13 AC_USE_SYSTEM_EXTENSIONS
14 AC_SYS_LARGEFILE
15 AC_PREFIX_DEFAULT([/usr])
16 AM_MAINTAINER_MODE([enable])
17 AM_INIT_AUTOMAKE([check-news foreign 1.11 silent-rules tar-pax no-dist-gzip dist-xz subdir-objects color-tests parallel-tests])
18 AM_SILENT_RULES([yes])
19 LT_INIT([disable-static pic-only])
20 DOLT
21
22 AS_IF([test "x$enable_static" = "xyes"], [AC_MSG_ERROR([--enable-static is not supported by kmod])])
23 AS_IF([test "x$enable_largefile" = "xno"], [AC_MSG_ERROR([--disable-largefile is not supported by kmod])])
24
25 #####################################################################
26 # Program checks and configurations
27 #####################################################################
28
29 AC_PROG_SED
30 AC_PROG_MKDIR_P
31 AC_PROG_LN_S
32 PKG_PROG_PKG_CONFIG
33 AC_PATH_PROG([XSLTPROC], [xsltproc])
34 AC_PATH_PROG([MKOSI], [mkosi])
35
36 AC_PROG_CC_C99
37
38 #####################################################################
39 # Function and structure checks
40 #####################################################################
41
42 AC_CHECK_FUNCS_ONCE(__xstat)
43 AC_CHECK_FUNCS_ONCE([__secure_getenv secure_getenv])
44 AC_CHECK_FUNCS_ONCE([finit_module])
45
46 CC_CHECK_FUNC_BUILTIN([__builtin_clz])
47 CC_CHECK_FUNC_BUILTIN([__builtin_types_compatible_p])
48 CC_CHECK_FUNC_BUILTIN([__builtin_uaddl_overflow], [ ], [ ])
49 CC_CHECK_FUNC_BUILTIN([__builtin_uaddll_overflow], [ ], [ ])
50
51 # dietlibc doesn't have st.st_mtim struct member
52 AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
53
54 # musl 1.0 and bionic 4.4 don't have strndupa
55 AC_CHECK_DECLS_ONCE([strndupa])
56
57 # RHEL 5 and older do not have be32toh
58 AC_CHECK_DECLS_ONCE([be32toh])
59
60 # Check kernel headers
61 AC_CHECK_HEADERS_ONCE([linux/module.h])
62
63 AC_MSG_CHECKING([whether _Static_assert() is supported])
64 AC_COMPILE_IFELSE(
65 [AC_LANG_SOURCE([[_Static_assert(1, "Test");]])],
66 [AC_DEFINE([HAVE_STATIC_ASSERT], [1], [Define if _Static_assert() is available])
67 AC_MSG_RESULT([yes])],
68 [AC_MSG_RESULT([no])])
69
70 AC_MSG_CHECKING([whether _Noreturn is supported])
71 AC_COMPILE_IFELSE(
72 [AC_LANG_SOURCE([[_Noreturn int foo(void) { exit(0); }]])],
73 [AC_DEFINE([HAVE_NORETURN], [1], [Define if _Noreturn is available])
74 AC_MSG_RESULT([yes])],
75 [AC_MSG_RESULT([no])])
76
77
78 #####################################################################
79 # --with-
80 #####################################################################
81
82 AC_ARG_WITH([rootlibdir],
83 AS_HELP_STRING([--with-rootlibdir=DIR], [rootfs directory to install shared libraries]),
84 [], [with_rootlibdir=$libdir])
85 AC_SUBST([rootlibdir], [$with_rootlibdir])
86
87 AC_ARG_WITH([xz],
88 AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]),
89 [], [with_xz=no])
90 AS_IF([test "x$with_xz" != "xno"], [
91 PKG_CHECK_MODULES([liblzma], [liblzma >= 4.99])
92 AC_DEFINE([ENABLE_XZ], [1], [Enable Xz for modules.])
93 ], [
94 AC_MSG_NOTICE([Xz support not requested])
95 ])
96 CC_FEATURE_APPEND([with_features], [with_xz], [XZ])
97
98 AC_ARG_WITH([zlib],
99 AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]),
100 [], [with_zlib=no])
101 AS_IF([test "x$with_zlib" != "xno"], [
102 PKG_CHECK_MODULES([zlib], [zlib])
103 AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.])
104 ], [
105 AC_MSG_NOTICE([zlib support not requested])
106 ])
107 CC_FEATURE_APPEND([with_features], [with_zlib], [ZLIB])
108
109 AC_ARG_WITH([openssl],
110 AS_HELP_STRING([--with-openssl], [handle PKCS7 signatures @<:@default=disabled@:>@]),
111 [], [with_openssl=no])
112 AS_IF([test "x$with_openssl" != "xno"], [
113 PKG_CHECK_MODULES([openssl], [openssl >= 1.1.0])
114 AC_DEFINE([ENABLE_OPENSSL], [1], [Enable openssl for modinfo.])
115 ], [
116 AC_MSG_NOTICE([openssl support not requested])
117 ])
118 CC_FEATURE_APPEND([with_features], [with_openssl], [OPENSSL])
119
120 AC_ARG_WITH([bashcompletiondir],
121 AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
122 [],
123 [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
124 with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
125 ] , [
126 with_bashcompletiondir=${datadir}/bash-completion/completions
127 ])])
128 AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
129
130 #####################################################################
131 # --enable-
132 #####################################################################
133
134 AC_ARG_ENABLE([experimental],
135 AS_HELP_STRING([--enable-experimental], [enable experimental tools and features. Do not enable it unless you know what you are doing. @<:@default=disabled@:>@]),
136 [], enable_experimental=no)
137 AM_CONDITIONAL([BUILD_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"])
138 AS_IF([test "x$enable_experimental" = "xyes"], [
139 AC_DEFINE(ENABLE_EXPERIMENTAL, [1], [Experimental features.])
140 ])
141 CC_FEATURE_APPEND([with_features], [enable_experimental], [EXPERIMENTAL])
142
143 AC_ARG_ENABLE([tools],
144 AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
145 [], enable_tools=yes)
146 AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
147
148 AC_ARG_ENABLE([manpages],
149 AS_HELP_STRING([--disable-manpages], [disable manpages @<:@default=enabled@:>@]),
150 [], enable_manpages=yes)
151 AM_CONDITIONAL([BUILD_MANPAGES], [test "x$enable_manpages" = "xyes"])
152
153 AC_ARG_ENABLE([test-modules],
154 AS_HELP_STRING([--disable-test-modules], [disable building test modules during make check: cached modules will be used @<:@default=enabled@:>@]),
155 [], enable_test_modules=yes)
156 AM_CONDITIONAL([BUILD_MODULES], [test "x$enable_test_modules" = "xyes"])
157
158 AC_ARG_ENABLE([logging],
159 AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
160 [], enable_logging=yes)
161 AS_IF([test "x$enable_logging" = "xyes"], [
162 AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
163 ])
164
165 AC_ARG_ENABLE([debug],
166 AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
167 [], [enable_debug=no])
168 AS_IF([test "x$enable_debug" = "xyes"], [
169 AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
170 ])
171
172 AC_ARG_ENABLE([python],
173 AS_HELP_STRING([--enable-python], [enable Python libkmod bindings @<:@default=disabled@:>@]),
174 [], [enable_python=no])
175 AS_IF([test "x$enable_python" = "xyes"], [
176 AM_PATH_PYTHON(,,[:])
177 AC_PATH_PROG([CYTHON], [cython], [:])
178
179 PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}],
180 [have_python=yes],
181 [PKG_CHECK_MODULES([PYTHON], [python],
182 [have_python=yes],
183 [have_python=no])])
184
185 AS_IF([test "x$have_python" = xno],
186 [AC_MSG_ERROR([*** python support requested but libraries not found])])
187 ])
188 AM_CONDITIONAL([BUILD_PYTHON], [test "x$enable_python" = "xyes"])
189
190 AC_ARG_ENABLE([coverage],
191 AS_HELP_STRING([--enable-coverage], [enable test coverage @<:@default=disabled@:>@]),
192 [], [enable_coverage=no])
193 AS_IF([test "x$enable_coverage" = "xyes"], [
194 AC_CHECK_PROG(have_coverage, [lcov], [yes], [no])
195 AS_IF([test "x$have_coverage" = xno],[
196 AC_MSG_ERROR([*** lcov support requested but the program was not found])
197 ], [
198 lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
199 lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
200 AS_IF([test "$lcov_version_major" -lt 1 -o "$lcov_version_minor" -lt 10], [
201 AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
202 ], [
203 have_coverage=yes
204 CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
205 -fprofile-arcs \
206 -ftest-coverage])
207 ])
208 ])
209 ])
210 AM_CONDITIONAL([ENABLE_COVERAGE], [test "x$enable_coverage" = "xyes"])
211
212 m4_ifdef([GTK_DOC_CHECK], [
213 GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
214 ], [
215 AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
216
217
218 #####################################################################
219 # Default CFLAGS and LDFLAGS
220 #####################################################################
221
222 CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
223 -pipe \
224 -DANOTHER_BRICK_IN_THE \
225 -Wall \
226 -W \
227 -Wextra \
228 -Wno-inline \
229 -Wvla \
230 -Wundef \
231 -Wformat=2 \
232 -Wlogical-op \
233 -Wsign-compare \
234 -Wformat-security \
235 -Wmissing-include-dirs \
236 -Wformat-nonliteral \
237 -Wold-style-definition \
238 -Wpointer-arith \
239 -Winit-self \
240 -Wdeclaration-after-statement \
241 -Wfloat-equal \
242 -Wmissing-prototypes \
243 -Wstrict-prototypes \
244 -Wredundant-decls \
245 -Wmissing-declarations \
246 -Wmissing-noreturn \
247 -Wshadow \
248 -Wendif-labels \
249 -Wstrict-aliasing=3 \
250 -Wwrite-strings \
251 -Wno-long-long \
252 -Wno-overlength-strings \
253 -Wno-unused-parameter \
254 -Wno-missing-field-initializers \
255 -Wno-unused-result \
256 -Wnested-externs \
257 -Wchar-subscripts \
258 -Wtype-limits \
259 -Wuninitialized \
260 -fno-common \
261 -fdiagnostics-show-option \
262 -fvisibility=hidden \
263 -ffunction-sections \
264 -fdata-sections])
265 AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
266
267
268 CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
269 -Wl,--as-needed \
270 -Wl,--no-undefined \
271 -Wl,--gc-sections])
272 AC_SUBST([OUR_LDFLAGS], $with_ldflags)
273
274 AC_DEFINE_UNQUOTED(KMOD_FEATURES, ["$with_features"], [Features in this build])
275
276 #####################################################################
277 # Generate files from *.in
278 #####################################################################
279
280 AC_CONFIG_FILES([
281 Makefile
282 man/Makefile
283 libkmod/docs/Makefile
284 libkmod/docs/version.xml
285 ])
286
287
288 #####################################################################
289
290 AC_OUTPUT
291 AC_MSG_RESULT([
292 $PACKAGE $VERSION
293 =======
294
295 prefix: ${prefix}
296 sysconfdir: ${sysconfdir}
297 libdir: ${libdir}
298 rootlibdir: ${rootlibdir}
299 includedir: ${includedir}
300 bindir: ${bindir}
301 Bash completions dir: ${with_bashcompletiondir}
302
303 compiler: ${CC}
304 cflags: ${with_cflags} ${CFLAGS}
305 ldflags: ${with_ldflags} ${LDFLAGS}
306
307 experimental features: ${enable_experimental}
308 tools: ${enable_tools}
309 python bindings: ${enable_python}
310 logging: ${enable_logging}
311 compression: xz=${with_xz} zlib=${with_zlib}
312 debug: ${enable_debug}
313 coverage: ${enable_coverage}
314 doc: ${enable_gtk_doc}
315 man: ${enable_manpages}
316 test-modules: ${enable_test_modules}
317
318 features: ${with_features}
319 ])