]> git.ipfire.org Git - thirdparty/kmod.git/blob - configure.ac
build: use dolt
[thirdparty/kmod.git] / configure.ac
1 AC_PREREQ(2.64)
2 AC_INIT([kmod],
3 [20],
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 DOLT
21
22 AS_IF([test "x$enable_static" = "xyes"], [AC_MSG_ERROR([--enable-static is not supported by kmod])])
23 AS_IF([test "x$enable_largefile" = "xno"], [AC_MSG_ERROR([--disable-largefile is not supported by kmod])])
24
25 #####################################################################
26 # Program checks and configurations
27 #####################################################################
28
29 AC_PROG_SED
30 AC_PROG_MKDIR_P
31 AC_PROG_LN_S
32 PKG_PROG_PKG_CONFIG
33 AC_PATH_PROG([XSLTPROC], [xsltproc])
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
96 AC_ARG_WITH([zlib],
97 AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]),
98 [], [with_zlib=no])
99 AS_IF([test "x$with_zlib" != "xno"], [
100 PKG_CHECK_MODULES([zlib], [zlib])
101 AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.])
102 ], [
103 AC_MSG_NOTICE([zlib support not requested])
104 ])
105
106 AC_ARG_WITH([bashcompletiondir],
107 AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
108 [],
109 [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
110 with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
111 ] , [
112 with_bashcompletiondir=${datadir}/bash-completion/completions
113 ])])
114 AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
115
116 #####################################################################
117 # --enable-
118 #####################################################################
119
120 AC_ARG_ENABLE([tools],
121 AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
122 [], enable_tools=yes)
123 AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
124
125 AC_ARG_ENABLE([manpages],
126 AS_HELP_STRING([--disable-manpages], [disable manpages @<:@default=enabled@:>@]),
127 [], enable_manpages=yes)
128 AM_CONDITIONAL([BUILD_MANPAGES], [test "x$enable_manpages" = "xyes"])
129
130 AC_ARG_ENABLE([logging],
131 AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
132 [], enable_logging=yes)
133 AS_IF([test "x$enable_logging" = "xyes"], [
134 AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
135 ])
136
137 AC_ARG_ENABLE([debug],
138 AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
139 [], [enable_debug=no])
140 AS_IF([test "x$enable_debug" = "xyes"], [
141 AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
142 ])
143
144 AC_ARG_ENABLE([python],
145 AS_HELP_STRING([--enable-python], [enable Python libkmod bindings @<:@default=disabled@:>@]),
146 [], [enable_python=no])
147 AS_IF([test "x$enable_python" = "xyes"], [
148 AM_PATH_PYTHON(,,[:])
149 AC_PATH_PROG([CYTHON], [cython], [:])
150
151 PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}],
152 [have_python=yes],
153 [PKG_CHECK_MODULES([PYTHON], [python],
154 [have_python=yes],
155 [have_python=no])])
156
157 AS_IF([test "x$have_python" = xno],
158 [AC_MSG_ERROR([*** python support requested but libraries not found])])
159 ])
160 AM_CONDITIONAL([BUILD_PYTHON], [test "x$enable_python" = "xyes"])
161
162 AC_ARG_ENABLE([coverage],
163 AS_HELP_STRING([--enable-coverage], [enable test coverage @<:@default=disabled@:>@]),
164 [], [enable_coverage=no])
165 AS_IF([test "x$enable_coverage" = "xyes"], [
166 AC_CHECK_PROG(have_coverage, [lcov], [yes], [no])
167 AS_IF([test "x$have_coverage" = xno],[
168 AC_MSG_ERROR([*** lcov support requested but the program was not found])
169 ], [
170 lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
171 lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
172 AS_IF([test "$lcov_version_major" -lt 1 -o "$lcov_version_minor" -lt 10], [
173 AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
174 ], [
175 have_coverage=yes
176 CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
177 -fprofile-arcs \
178 -ftest-coverage])
179 ])
180 ])
181 ])
182 AM_CONDITIONAL([ENABLE_COVERAGE], [test "x$enable_coverage" = "xyes"])
183
184 m4_ifdef([GTK_DOC_CHECK], [
185 GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
186 ], [
187 AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
188
189
190 #####################################################################
191 # Default CFLAGS and LDFLAGS
192 #####################################################################
193
194 CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
195 -pipe \
196 -DANOTHER_BRICK_IN_THE \
197 -Wall \
198 -W \
199 -Wextra \
200 -Wno-inline \
201 -Wvla \
202 -Wundef \
203 -Wformat=2 \
204 -Wlogical-op \
205 -Wsign-compare \
206 -Wformat-security \
207 -Wmissing-include-dirs \
208 -Wformat-nonliteral \
209 -Wold-style-definition \
210 -Wpointer-arith \
211 -Winit-self \
212 -Wdeclaration-after-statement \
213 -Wfloat-equal \
214 -Wmissing-prototypes \
215 -Wstrict-prototypes \
216 -Wredundant-decls \
217 -Wmissing-declarations \
218 -Wmissing-noreturn \
219 -Wshadow \
220 -Wendif-labels \
221 -Wstrict-aliasing=3 \
222 -Wwrite-strings \
223 -Wno-long-long \
224 -Wno-overlength-strings \
225 -Wno-unused-parameter \
226 -Wno-missing-field-initializers \
227 -Wno-unused-result \
228 -Wnested-externs \
229 -Wchar-subscripts \
230 -Wtype-limits \
231 -Wuninitialized \
232 -fno-common \
233 -fdiagnostics-show-option \
234 -fvisibility=hidden \
235 -ffunction-sections \
236 -fdata-sections])
237 AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
238
239
240 CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
241 -Wl,--as-needed \
242 -Wl,--no-undefined \
243 -Wl,--gc-sections])
244 AC_SUBST([OUR_LDFLAGS], $with_ldflags)
245
246 #####################################################################
247 # Generate files from *.in
248 #####################################################################
249
250 AC_CONFIG_FILES([
251 Makefile
252 man/Makefile
253 libkmod/docs/Makefile
254 libkmod/docs/version.xml
255 ])
256
257
258 #####################################################################
259
260 AC_OUTPUT
261 AC_MSG_RESULT([
262 $PACKAGE $VERSION
263 =======
264
265 prefix: ${prefix}
266 sysconfdir: ${sysconfdir}
267 libdir: ${libdir}
268 rootlibdir: ${rootlibdir}
269 includedir: ${includedir}
270 bindir: ${bindir}
271 Bash completions dir: ${with_bashcompletiondir}
272
273 compiler: ${CC}
274 cflags: ${with_cflags} ${CFLAGS}
275 ldflags: ${with_ldflags} ${LDFLAGS}
276
277 tools: ${enable_tools}
278 python bindings: ${enable_python}
279 logging: ${enable_logging}
280 compression: xz=${with_xz} zlib=${with_zlib}
281 debug: ${enable_debug}
282 coverage: ${enable_coverage}
283 doc: ${enable_gtk_doc}
284 man: ${enable_manpages}
285 ])