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