4 [linux-modules@vger.kernel.org],
6 [http://git.kernel.org/?p=utils/kernel/kmod/kmod.git])
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])
13 AC_USE_SYSTEM_EXTENSIONS
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])
21 AS_IF([test "x$enable_static" = "xyes"], [AC_MSG_ERROR([--enable-static is not supported by kmod])])
22 AS_IF([test "x$enable_largefile" = "xno"], [AC_MSG_ERROR([--disable-largefile is not supported by kmod])])
24 module_compressions=""
25 module_signatures="legacy"
27 #####################################################################
28 # Program checks and configurations
29 #####################################################################
35 AC_PATH_PROG([XSLTPROC], [xsltproc])
39 #####################################################################
40 # Function and structure checks
41 #####################################################################
43 AC_CHECK_FUNCS_ONCE(__xstat)
44 AC_CHECK_FUNCS_ONCE([__secure_getenv secure_getenv])
45 AC_CHECK_FUNCS_ONCE([finit_module])
47 CC_CHECK_FUNC_BUILTIN([__builtin_clz])
48 CC_CHECK_FUNC_BUILTIN([__builtin_types_compatible_p])
49 CC_CHECK_FUNC_BUILTIN([__builtin_uaddl_overflow], [ ], [ ])
50 CC_CHECK_FUNC_BUILTIN([__builtin_uaddll_overflow], [ ], [ ])
52 # dietlibc doesn't have st.st_mtim struct member
53 AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
55 # musl 1.0 and bionic 4.4 don't have strndupa
56 AC_CHECK_DECLS_ONCE([strndupa])
58 # RHEL 5 and older do not have be32toh
59 AC_CHECK_DECLS_ONCE([be32toh])
61 # Check kernel headers
62 AC_CHECK_HEADERS_ONCE([linux/module.h])
64 AC_MSG_CHECKING([whether _Static_assert() is supported])
66 [AC_LANG_SOURCE([[_Static_assert(1, "Test");]])],
67 [AC_DEFINE([HAVE_STATIC_ASSERT], [1], [Define if _Static_assert() is available])
68 AC_MSG_RESULT([yes])],
69 [AC_MSG_RESULT([no])])
71 AC_MSG_CHECKING([whether _Noreturn is supported])
73 [AC_LANG_SOURCE([[#include <stdlib.h>
74 _Noreturn int foo(void) { exit(0); }]])],
75 [AC_DEFINE([HAVE_NORETURN], [1], [Define if _Noreturn is available])
76 AC_MSG_RESULT([yes])],
77 [AC_MSG_RESULT([no])])
80 #####################################################################
82 #####################################################################
84 AC_ARG_WITH([distconfdir], AS_HELP_STRING([--with-distconfdir=DIR], [directory to search for distribution configuration files]),
85 [], [with_distconfdir='${prefix}/lib'])
86 AC_SUBST([distconfdir], [$with_distconfdir])
88 AC_ARG_WITH([rootlibdir],
89 AS_HELP_STRING([--with-rootlibdir=DIR], [rootfs directory to install shared libraries]),
90 [], [with_rootlibdir=$libdir])
91 AC_SUBST([rootlibdir], [$with_rootlibdir])
93 # Ideally this would be $prefix/lib/modules but default to /lib/modules for compatibility with earlier versions
94 AC_ARG_WITH([module_directory],
95 AS_HELP_STRING([--with-module-directory=DIR], [directory in which to look for kernel modules - typically '/lib/modules' or '${prefix}/lib/modules']),
96 [], [with_module_directory=/lib/modules])
97 AC_SUBST([module_directory], [$with_module_directory])
99 # Check all directory arguments for consistency.
100 for ac_var in distconfdir rootlibdir module_directory
102 eval ac_val=\$$ac_var
103 # Remove trailing slashes.
106 ac_val=`expr "X$ac_val" : 'X\(.*@<:@^/@:>@\)' \| "X$ac_val" : 'X\(.*\)'`
107 eval $ac_var=\$ac_val;;
109 # Be sure to have absolute directory names.
111 @<:@\\/$@:>@* | ?:@<:@\\/@:>@* ) continue;;
113 as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
117 AS_HELP_STRING([--with-zstd], [handle Zstandard-compressed modules @<:@default=disabled@:>@]),
119 AS_IF([test "x$with_zstd" != "xno"], [
120 PKG_CHECK_MODULES([libzstd], [libzstd >= 1.4.4], [LIBS="$LIBS $libzstd_LIBS"])
121 AC_DEFINE([ENABLE_ZSTD], [1], [Enable Zstandard for modules.])
122 module_compressions="zstd $module_compressions"
124 AC_MSG_NOTICE([Zstandard support not requested])
126 CC_FEATURE_APPEND([with_features], [with_zstd], [ZSTD])
129 AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]),
131 AS_IF([test "x$with_xz" != "xno"], [
132 PKG_CHECK_MODULES([liblzma], [liblzma >= 4.99], [LIBS="$LIBS $liblzma_LIBS"])
133 AC_DEFINE([ENABLE_XZ], [1], [Enable Xz for modules.])
134 module_compressions="xz $module_compressions"
136 AC_MSG_NOTICE([Xz support not requested])
138 CC_FEATURE_APPEND([with_features], [with_xz], [XZ])
141 AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]),
143 AS_IF([test "x$with_zlib" != "xno"], [
144 PKG_CHECK_MODULES([zlib], [zlib], [LIBS="$LIBS $zlib_LIBS"])
145 AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.])
146 module_compressions="gzip $module_compressions"
148 AC_MSG_NOTICE([zlib support not requested])
150 CC_FEATURE_APPEND([with_features], [with_zlib], [ZLIB])
152 AC_ARG_WITH([openssl],
153 AS_HELP_STRING([--with-openssl], [handle PKCS7 signatures @<:@default=disabled@:>@]),
154 [], [with_openssl=no])
155 AS_IF([test "x$with_openssl" != "xno"], [
156 PKG_CHECK_MODULES([libcrypto], [libcrypto >= 1.1.0], [LIBS="$LIBS $libcrypto_LIBS"])
157 AC_DEFINE([ENABLE_OPENSSL], [1], [Enable openssl for modinfo.])
158 module_signatures="PKCS7 $module_signatures"
160 AC_MSG_NOTICE([openssl support not requested])
162 CC_FEATURE_APPEND([with_features], [with_openssl], [LIBCRYPTO])
164 AC_ARG_WITH([bashcompletiondir],
165 AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
167 [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
168 with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
170 with_bashcompletiondir=${datadir}/bash-completion/completions
172 AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
174 #####################################################################
176 #####################################################################
178 AC_ARG_ENABLE([experimental],
179 AS_HELP_STRING([--enable-experimental], [enable experimental tools and features. Do not enable it unless you know what you are doing. @<:@default=disabled@:>@]),
180 [], enable_experimental=no)
181 AM_CONDITIONAL([BUILD_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"])
182 AS_IF([test "x$enable_experimental" = "xyes"], [
183 AC_DEFINE(ENABLE_EXPERIMENTAL, [1], [Experimental features.])
185 CC_FEATURE_APPEND([with_features], [enable_experimental], [EXPERIMENTAL])
187 AC_ARG_ENABLE([tools],
188 AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
189 [], enable_tools=yes)
190 AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
192 AC_ARG_ENABLE([manpages],
193 AS_HELP_STRING([--disable-manpages], [disable manpages @<:@default=enabled@:>@]),
194 [], enable_manpages=yes)
195 AM_CONDITIONAL([BUILD_MANPAGES], [test "x$enable_manpages" = "xyes"])
197 AC_ARG_ENABLE([test-modules],
198 AS_HELP_STRING([--disable-test-modules], [disable building test modules during make check: cached modules will be used @<:@default=enabled@:>@]),
199 [], enable_test_modules=yes)
200 AM_CONDITIONAL([BUILD_MODULES], [test "x$enable_test_modules" = "xyes"])
202 AC_ARG_ENABLE([logging],
203 AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
204 [], enable_logging=yes)
205 AS_IF([test "x$enable_logging" = "xyes"], [
206 AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
209 AC_ARG_ENABLE([debug],
210 AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
211 [], [enable_debug=no])
212 AS_IF([test "x$enable_debug" = "xyes"], [
213 AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
216 AC_ARG_ENABLE([coverage],
217 AS_HELP_STRING([--enable-coverage], [enable test coverage @<:@default=disabled@:>@]),
218 [], [enable_coverage=no])
219 AS_IF([test "x$enable_coverage" = "xyes"], [
220 AC_CHECK_PROG(have_coverage, [lcov], [yes], [no])
221 AS_IF([test "x$have_coverage" = xno],[
222 AC_MSG_ERROR([*** lcov support requested but the program was not found])
224 lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
225 lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
226 AS_IF([test "$lcov_version_major" -lt 1 -o "$lcov_version_minor" -lt 10], [
227 AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
230 CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
236 AM_CONDITIONAL([ENABLE_COVERAGE], [test "x$enable_coverage" = "xyes"])
238 m4_ifdef([GTK_DOC_CHECK], [
239 GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
241 AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
243 #####################################################################
244 # Default CFLAGS and LDFLAGS
245 #####################################################################
247 CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
249 -DANOTHER_BRICK_IN_THE \
260 -Wmissing-include-dirs \
261 -Wformat-nonliteral \
262 -Wold-style-definition \
265 -Wdeclaration-after-statement \
267 -Wmissing-prototypes \
268 -Wstrict-prototypes \
270 -Wmissing-declarations \
274 -Wstrict-aliasing=3 \
277 -Wno-overlength-strings \
278 -Wno-unused-parameter \
279 -Wno-missing-field-initializers \
286 -fdiagnostics-show-option \
287 -fvisibility=hidden \
288 -ffunction-sections \
290 AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
293 CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
297 AC_SUBST([OUR_LDFLAGS], $with_ldflags)
299 AC_DEFINE_UNQUOTED(KMOD_FEATURES, ["$with_features"], [Features in this build])
301 #####################################################################
302 # Generate files from *.in
303 #####################################################################
305 AC_SUBST([module_compressions], $module_compressions)
306 AC_SUBST([module_signatures], $module_signatures)
311 libkmod/docs/Makefile
312 libkmod/docs/version.xml
318 #####################################################################
325 module_directory: ${module_directory}
327 sysconfdir: ${sysconfdir}
328 distconfdir: ${distconfdir}
330 rootlibdir: ${rootlibdir}
331 includedir: ${includedir}
333 Bash completions dir: ${with_bashcompletiondir}
336 cflags: ${with_cflags} ${CFLAGS}
337 ldflags: ${with_ldflags} ${LDFLAGS}
339 experimental features: ${enable_experimental}
340 tools: ${enable_tools}
341 logging: ${enable_logging}
342 compression: zstd=${with_zstd} xz=${with_xz} zlib=${with_zlib}
343 debug: ${enable_debug}
344 coverage: ${enable_coverage}
345 doc: ${enable_gtk_doc}
346 man: ${enable_manpages}
347 test-modules: ${enable_test_modules}
349 features: ${with_features}