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