]> git.ipfire.org Git - thirdparty/kmod.git/blame - configure.ac
libkmod, depmod, modprobe: Make directory for kernel modules configurable
[thirdparty/kmod.git] / configure.ac
CommitLineData
481ad145 1AC_PREREQ(2.64)
cb48c9b2 2AC_INIT([kmod],
aff617ea 3 [31],
e17cc3af 4 [linux-modules@vger.kernel.org],
cb48c9b2 5 [kmod],
bb05bc8a 6 [http://git.kernel.org/?p=utils/kernel/kmod/kmod.git])
586fc304
LDM
7
8AC_CONFIG_SRCDIR([libkmod/libkmod.c])
481ad145
LDM
9AC_CONFIG_MACRO_DIR([m4])
10AC_CONFIG_HEADERS(config.h)
ecd40ee4 11AC_CONFIG_AUX_DIR([build-aux])
481ad145 12
ecd40ee4
LDM
13AC_USE_SYSTEM_EXTENSIONS
14AC_SYS_LARGEFILE
ecd40ee4 15AC_PREFIX_DEFAULT([/usr])
f5cc26c7 16AM_MAINTAINER_MODE([enable])
481ad145
LDM
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])
ecd40ee4 20
fae77516
LDM
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])])
b7016153 23
ecef7c13
MS
24module_compressions=""
25module_signatures="legacy"
26
3ef7208e
LDM
27#####################################################################
28# Program checks and configurations
29#####################################################################
30
9faa7b37
KS
31AC_PROG_SED
32AC_PROG_MKDIR_P
481ad145 33AC_PROG_LN_S
7b3a74fc 34PKG_PROG_PKG_CONFIG
bccb4b25 35AC_PATH_PROG([XSLTPROC], [xsltproc])
8d9c7e37 36AC_PATH_PROG([MKOSI], [mkosi])
3d8226ed 37
481ad145 38AC_PROG_CC_C99
3ef7208e
LDM
39
40#####################################################################
41# Function and structure checks
42#####################################################################
43
d005aeb7 44AC_CHECK_FUNCS_ONCE(__xstat)
41a51c2a 45AC_CHECK_FUNCS_ONCE([__secure_getenv secure_getenv])
55112d19 46AC_CHECK_FUNCS_ONCE([finit_module])
d005aeb7 47
e6307200
LDM
48CC_CHECK_FUNC_BUILTIN([__builtin_clz])
49CC_CHECK_FUNC_BUILTIN([__builtin_types_compatible_p])
aac5f451
LDM
50CC_CHECK_FUNC_BUILTIN([__builtin_uaddl_overflow], [ ], [ ])
51CC_CHECK_FUNC_BUILTIN([__builtin_uaddll_overflow], [ ], [ ])
e6307200 52
3ef7208e
LDM
53# dietlibc doesn't have st.st_mtim struct member
54AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
55
04c0956e
LDM
56# musl 1.0 and bionic 4.4 don't have strndupa
57AC_CHECK_DECLS_ONCE([strndupa])
58
9b34db1a
RM
59# RHEL 5 and older do not have be32toh
60AC_CHECK_DECLS_ONCE([be32toh])
61
144d1826
KC
62# Check kernel headers
63AC_CHECK_HEADERS_ONCE([linux/module.h])
64
dc8ed09f
TP
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])])
3ef7208e 71
16a62c7a
LDM
72AC_MSG_CHECKING([whether _Noreturn is supported])
73AC_COMPILE_IFELSE(
035e6667
FW
74 [AC_LANG_SOURCE([[#include <stdlib.h>
75 _Noreturn int foo(void) { exit(0); }]])],
16a62c7a
LDM
76 [AC_DEFINE([HAVE_NORETURN], [1], [Define if _Noreturn is available])
77 AC_MSG_RESULT([yes])],
78 [AC_MSG_RESULT([no])])
79
80
3ef7208e
LDM
81#####################################################################
82# --with-
83#####################################################################
84
8463809f
MS
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
e79bf83b
KS
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
9d1fb317
MS
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
3821e197
TM
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"], [
3d1bd339 104 PKG_CHECK_MODULES([libzstd], [libzstd >= 1.4.4], [LIBS="$LIBS $libzstd_LIBS"])
3821e197 105 AC_DEFINE([ENABLE_ZSTD], [1], [Enable Zstandard for modules.])
ecef7c13 106 module_compressions="zstd $module_compressions"
3821e197
TM
107], [
108 AC_MSG_NOTICE([Zstandard support not requested])
109])
110CC_FEATURE_APPEND([with_features], [with_zstd], [ZSTD])
111
b182f8fb
JE
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"], [
3d1bd339 116 PKG_CHECK_MODULES([liblzma], [liblzma >= 4.99], [LIBS="$LIBS $liblzma_LIBS"])
b182f8fb 117 AC_DEFINE([ENABLE_XZ], [1], [Enable Xz for modules.])
ecef7c13 118 module_compressions="xz $module_compressions"
b182f8fb
JE
119], [
120 AC_MSG_NOTICE([Xz support not requested])
121])
4671e03e 122CC_FEATURE_APPEND([with_features], [with_xz], [XZ])
b182f8fb 123
5a51a357
JE
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"], [
3d1bd339 128 PKG_CHECK_MODULES([zlib], [zlib], [LIBS="$LIBS $zlib_LIBS"])
7b3a74fc 129 AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.])
ecef7c13 130 module_compressions="gzip $module_compressions"
cfb908bf
LDM
131], [
132 AC_MSG_NOTICE([zlib support not requested])
cfb908bf 133])
4671e03e 134CC_FEATURE_APPEND([with_features], [with_zlib], [ZLIB])
3d8226ed 135
391b4714
YK
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"], [
3d1bd339 140 PKG_CHECK_MODULES([libcrypto], [libcrypto >= 1.1.0], [LIBS="$LIBS $libcrypto_LIBS"])
391b4714 141 AC_DEFINE([ENABLE_OPENSSL], [1], [Enable openssl for modinfo.])
ecef7c13 142 module_signatures="PKCS7 $module_signatures"
391b4714
YK
143], [
144 AC_MSG_NOTICE([openssl support not requested])
145])
8e266b9e 146CC_FEATURE_APPEND([with_features], [with_openssl], [LIBCRYPTO])
391b4714 147
80cf2c8f
LDM
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])
3ef7208e
LDM
157
158#####################################################################
159# --enable-
160#####################################################################
161
013e8550
LDM
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])
4671e03e 169CC_FEATURE_APPEND([with_features], [enable_experimental], [EXPERIMENTAL])
013e8550 170
3ef7208e
LDM
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
8631552d
CW
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
23603f1f
LDM
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
3ef7208e
LDM
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
ecd40ee4
LDM
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
3a33a7a5
LDM
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
e9b0d1b4
LDM
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
3ef7208e
LDM
240m4_ifdef([GTK_DOC_CHECK], [
241GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
242], [
243AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
244
3ef7208e
LDM
245#####################################################################
246# Default CFLAGS and LDFLAGS
247#####################################################################
6068aaae 248
e48f3765
LDM
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 \
db62153e 276 -Wstrict-aliasing=3 \
e48f3765
LDM
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])
27bcc911 292AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
e48f3765 293
c677bf2c 294
e48f3765
LDM
295CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
296 -Wl,--as-needed \
a5f799af 297 -Wl,--no-undefined \
e48f3765 298 -Wl,--gc-sections])
84aaaedf 299AC_SUBST([OUR_LDFLAGS], $with_ldflags)
3ef7208e 300
4671e03e
LDM
301AC_DEFINE_UNQUOTED(KMOD_FEATURES, ["$with_features"], [Features in this build])
302
3ef7208e
LDM
303#####################################################################
304# Generate files from *.in
305#####################################################################
306
ecef7c13
MS
307AC_SUBST([module_compressions], $module_compressions)
308AC_SUBST([module_signatures], $module_signatures)
309
ecd40ee4
LDM
310AC_CONFIG_FILES([
311 Makefile
904b57d0 312 man/Makefile
646b83b8
LDM
313 libkmod/docs/Makefile
314 libkmod/docs/version.xml
e4c1a5b2
EV
315 libkmod/libkmod.pc
316 libkmod/python/kmod/version.py
ecef7c13 317 tools/kmod.pc
ecd40ee4
LDM
318])
319
3ef7208e
LDM
320
321#####################################################################
646b83b8 322
ecd40ee4
LDM
323AC_OUTPUT
324AC_MSG_RESULT([
325 $PACKAGE $VERSION
80cf2c8f 326 =======
ecd40ee4 327
9d1fb317 328 module_directory: ${module_directory}
ecd40ee4
LDM
329 prefix: ${prefix}
330 sysconfdir: ${sysconfdir}
8463809f 331 distconfdir: ${distconfdir}
ecd40ee4 332 libdir: ${libdir}
e79bf83b 333 rootlibdir: ${rootlibdir}
ecd40ee4 334 includedir: ${includedir}
7c41c2dd 335 bindir: ${bindir}
80cf2c8f 336 Bash completions dir: ${with_bashcompletiondir}
ecd40ee4
LDM
337
338 compiler: ${CC}
e48f3765
LDM
339 cflags: ${with_cflags} ${CFLAGS}
340 ldflags: ${with_ldflags} ${LDFLAGS}
ecd40ee4 341
013e8550 342 experimental features: ${enable_experimental}
7c41c2dd 343 tools: ${enable_tools}
3a33a7a5 344 python bindings: ${enable_python}
ecd40ee4 345 logging: ${enable_logging}
3821e197 346 compression: zstd=${with_zstd} xz=${with_xz} zlib=${with_zlib}
ecd40ee4 347 debug: ${enable_debug}
e9b0d1b4 348 coverage: ${enable_coverage}
646b83b8 349 doc: ${enable_gtk_doc}
382de85c 350 man: ${enable_manpages}
23603f1f 351 test-modules: ${enable_test_modules}
4671e03e
LDM
352
353 features: ${with_features}
ecd40ee4 354])