]> git.ipfire.org Git - thirdparty/kmod.git/blame - configure.ac
kmod: configure.ac: In _Noreturn check, include <stdlib.h> for exit
[thirdparty/kmod.git] / configure.ac
CommitLineData
481ad145 1AC_PREREQ(2.64)
cb48c9b2 2AC_INIT([kmod],
5d46434a 3 [30],
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
e79bf83b
KS
82AC_ARG_WITH([rootlibdir],
83 AS_HELP_STRING([--with-rootlibdir=DIR], [rootfs directory to install shared libraries]),
84 [], [with_rootlibdir=$libdir])
85AC_SUBST([rootlibdir], [$with_rootlibdir])
86
3821e197
TM
87AC_ARG_WITH([zstd],
88 AS_HELP_STRING([--with-zstd], [handle Zstandard-compressed modules @<:@default=disabled@:>@]),
89 [], [with_zstd=no])
90AS_IF([test "x$with_zstd" != "xno"], [
91 PKG_CHECK_MODULES([libzstd], [libzstd >= 1.4.4])
92 AC_DEFINE([ENABLE_ZSTD], [1], [Enable Zstandard for modules.])
93], [
94 AC_MSG_NOTICE([Zstandard support not requested])
95])
96CC_FEATURE_APPEND([with_features], [with_zstd], [ZSTD])
97
b182f8fb
JE
98AC_ARG_WITH([xz],
99 AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]),
100 [], [with_xz=no])
101AS_IF([test "x$with_xz" != "xno"], [
102 PKG_CHECK_MODULES([liblzma], [liblzma >= 4.99])
103 AC_DEFINE([ENABLE_XZ], [1], [Enable Xz for modules.])
104], [
105 AC_MSG_NOTICE([Xz support not requested])
106])
4671e03e 107CC_FEATURE_APPEND([with_features], [with_xz], [XZ])
b182f8fb 108
5a51a357
JE
109AC_ARG_WITH([zlib],
110 AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]),
111 [], [with_zlib=no])
112AS_IF([test "x$with_zlib" != "xno"], [
7b3a74fc
JE
113 PKG_CHECK_MODULES([zlib], [zlib])
114 AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.])
cfb908bf
LDM
115], [
116 AC_MSG_NOTICE([zlib support not requested])
cfb908bf 117])
4671e03e 118CC_FEATURE_APPEND([with_features], [with_zlib], [ZLIB])
3d8226ed 119
391b4714
YK
120AC_ARG_WITH([openssl],
121 AS_HELP_STRING([--with-openssl], [handle PKCS7 signatures @<:@default=disabled@:>@]),
122 [], [with_openssl=no])
123AS_IF([test "x$with_openssl" != "xno"], [
8e266b9e 124 PKG_CHECK_MODULES([libcrypto], [libcrypto >= 1.1.0])
391b4714
YK
125 AC_DEFINE([ENABLE_OPENSSL], [1], [Enable openssl for modinfo.])
126], [
127 AC_MSG_NOTICE([openssl support not requested])
128])
8e266b9e 129CC_FEATURE_APPEND([with_features], [with_openssl], [LIBCRYPTO])
391b4714 130
80cf2c8f
LDM
131AC_ARG_WITH([bashcompletiondir],
132 AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
133 [],
134 [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
135 with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
136 ] , [
137 with_bashcompletiondir=${datadir}/bash-completion/completions
138 ])])
139AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
3ef7208e
LDM
140
141#####################################################################
142# --enable-
143#####################################################################
144
013e8550
LDM
145AC_ARG_ENABLE([experimental],
146 AS_HELP_STRING([--enable-experimental], [enable experimental tools and features. Do not enable it unless you know what you are doing. @<:@default=disabled@:>@]),
147 [], enable_experimental=no)
148AM_CONDITIONAL([BUILD_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"])
149AS_IF([test "x$enable_experimental" = "xyes"], [
150 AC_DEFINE(ENABLE_EXPERIMENTAL, [1], [Experimental features.])
151])
4671e03e 152CC_FEATURE_APPEND([with_features], [enable_experimental], [EXPERIMENTAL])
013e8550 153
3ef7208e
LDM
154AC_ARG_ENABLE([tools],
155 AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
156 [], enable_tools=yes)
157AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
158
8631552d
CW
159AC_ARG_ENABLE([manpages],
160 AS_HELP_STRING([--disable-manpages], [disable manpages @<:@default=enabled@:>@]),
161 [], enable_manpages=yes)
162AM_CONDITIONAL([BUILD_MANPAGES], [test "x$enable_manpages" = "xyes"])
163
23603f1f
LDM
164AC_ARG_ENABLE([test-modules],
165 AS_HELP_STRING([--disable-test-modules], [disable building test modules during make check: cached modules will be used @<:@default=enabled@:>@]),
166 [], enable_test_modules=yes)
167AM_CONDITIONAL([BUILD_MODULES], [test "x$enable_test_modules" = "xyes"])
168
3ef7208e
LDM
169AC_ARG_ENABLE([logging],
170 AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
171 [], enable_logging=yes)
172AS_IF([test "x$enable_logging" = "xyes"], [
173 AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
174])
175
ecd40ee4
LDM
176AC_ARG_ENABLE([debug],
177 AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
178 [], [enable_debug=no])
179AS_IF([test "x$enable_debug" = "xyes"], [
180 AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
181])
182
3a33a7a5
LDM
183AC_ARG_ENABLE([python],
184 AS_HELP_STRING([--enable-python], [enable Python libkmod bindings @<:@default=disabled@:>@]),
185 [], [enable_python=no])
186AS_IF([test "x$enable_python" = "xyes"], [
187 AM_PATH_PYTHON(,,[:])
188 AC_PATH_PROG([CYTHON], [cython], [:])
189
190 PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}],
191 [have_python=yes],
192 [PKG_CHECK_MODULES([PYTHON], [python],
193 [have_python=yes],
194 [have_python=no])])
195
196 AS_IF([test "x$have_python" = xno],
197 [AC_MSG_ERROR([*** python support requested but libraries not found])])
198])
199AM_CONDITIONAL([BUILD_PYTHON], [test "x$enable_python" = "xyes"])
200
e9b0d1b4
LDM
201AC_ARG_ENABLE([coverage],
202 AS_HELP_STRING([--enable-coverage], [enable test coverage @<:@default=disabled@:>@]),
203 [], [enable_coverage=no])
204AS_IF([test "x$enable_coverage" = "xyes"], [
205 AC_CHECK_PROG(have_coverage, [lcov], [yes], [no])
206 AS_IF([test "x$have_coverage" = xno],[
207 AC_MSG_ERROR([*** lcov support requested but the program was not found])
208 ], [
209 lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
210 lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
211 AS_IF([test "$lcov_version_major" -lt 1 -o "$lcov_version_minor" -lt 10], [
212 AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
213 ], [
214 have_coverage=yes
215 CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
216 -fprofile-arcs \
217 -ftest-coverage])
218 ])
219 ])
220])
221AM_CONDITIONAL([ENABLE_COVERAGE], [test "x$enable_coverage" = "xyes"])
222
3ef7208e
LDM
223m4_ifdef([GTK_DOC_CHECK], [
224GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
225], [
226AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
227
847247a4
MB
228# Some tests are skipped when sysconfdir != /etc.
229AM_CONDITIONAL([KMOD_SYSCONFDIR_NOT_ETC], [test "x$sysconfdir" != "x/etc"])
3ef7208e
LDM
230
231#####################################################################
232# Default CFLAGS and LDFLAGS
233#####################################################################
6068aaae 234
e48f3765
LDM
235CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
236 -pipe \
237 -DANOTHER_BRICK_IN_THE \
238 -Wall \
239 -W \
240 -Wextra \
241 -Wno-inline \
242 -Wvla \
243 -Wundef \
244 -Wformat=2 \
245 -Wlogical-op \
246 -Wsign-compare \
247 -Wformat-security \
248 -Wmissing-include-dirs \
249 -Wformat-nonliteral \
250 -Wold-style-definition \
251 -Wpointer-arith \
252 -Winit-self \
253 -Wdeclaration-after-statement \
254 -Wfloat-equal \
255 -Wmissing-prototypes \
256 -Wstrict-prototypes \
257 -Wredundant-decls \
258 -Wmissing-declarations \
259 -Wmissing-noreturn \
260 -Wshadow \
261 -Wendif-labels \
db62153e 262 -Wstrict-aliasing=3 \
e48f3765
LDM
263 -Wwrite-strings \
264 -Wno-long-long \
265 -Wno-overlength-strings \
266 -Wno-unused-parameter \
267 -Wno-missing-field-initializers \
268 -Wno-unused-result \
269 -Wnested-externs \
270 -Wchar-subscripts \
271 -Wtype-limits \
272 -Wuninitialized \
273 -fno-common \
274 -fdiagnostics-show-option \
275 -fvisibility=hidden \
276 -ffunction-sections \
277 -fdata-sections])
27bcc911 278AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
e48f3765 279
c677bf2c 280
e48f3765
LDM
281CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
282 -Wl,--as-needed \
a5f799af 283 -Wl,--no-undefined \
e48f3765 284 -Wl,--gc-sections])
84aaaedf 285AC_SUBST([OUR_LDFLAGS], $with_ldflags)
3ef7208e 286
4671e03e
LDM
287AC_DEFINE_UNQUOTED(KMOD_FEATURES, ["$with_features"], [Features in this build])
288
3ef7208e
LDM
289#####################################################################
290# Generate files from *.in
291#####################################################################
292
ecd40ee4
LDM
293AC_CONFIG_FILES([
294 Makefile
904b57d0 295 man/Makefile
646b83b8
LDM
296 libkmod/docs/Makefile
297 libkmod/docs/version.xml
ecd40ee4
LDM
298])
299
3ef7208e
LDM
300
301#####################################################################
646b83b8 302
ecd40ee4
LDM
303AC_OUTPUT
304AC_MSG_RESULT([
305 $PACKAGE $VERSION
80cf2c8f 306 =======
ecd40ee4
LDM
307
308 prefix: ${prefix}
309 sysconfdir: ${sysconfdir}
310 libdir: ${libdir}
e79bf83b 311 rootlibdir: ${rootlibdir}
ecd40ee4 312 includedir: ${includedir}
7c41c2dd 313 bindir: ${bindir}
80cf2c8f 314 Bash completions dir: ${with_bashcompletiondir}
ecd40ee4
LDM
315
316 compiler: ${CC}
e48f3765
LDM
317 cflags: ${with_cflags} ${CFLAGS}
318 ldflags: ${with_ldflags} ${LDFLAGS}
ecd40ee4 319
013e8550 320 experimental features: ${enable_experimental}
7c41c2dd 321 tools: ${enable_tools}
3a33a7a5 322 python bindings: ${enable_python}
ecd40ee4 323 logging: ${enable_logging}
3821e197 324 compression: zstd=${with_zstd} xz=${with_xz} zlib=${with_zlib}
ecd40ee4 325 debug: ${enable_debug}
e9b0d1b4 326 coverage: ${enable_coverage}
646b83b8 327 doc: ${enable_gtk_doc}
382de85c 328 man: ${enable_manpages}
23603f1f 329 test-modules: ${enable_test_modules}
4671e03e
LDM
330
331 features: ${with_features}
ecd40ee4 332])