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