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