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