blob: 92790dbff9d3c47bdf6a3f171897a2be097b21fe [file] [log] [blame]
Lucas De Marchi481ad142015-02-26 02:56:04 -03001AC_PREREQ(2.64)
Lucas De Marchicb48c9b2011-12-12 16:41:38 -02002AC_INIT([kmod],
Lucas De Marchif9e21672014-11-16 10:24:50 -02003 [19],
Lucas De Marchie17cc3a2011-12-16 04:11:25 -02004 [linux-modules@vger.kernel.org],
Lucas De Marchicb48c9b2011-12-12 16:41:38 -02005 [kmod],
Lucas De Marchibb05bc82012-02-24 01:58:20 -02006 [http://git.kernel.org/?p=utils/kernel/kmod/kmod.git])
Lucas De Marchi586fc302011-11-21 14:35:35 -02007
8AC_CONFIG_SRCDIR([libkmod/libkmod.c])
Lucas De Marchi481ad142015-02-26 02:56:04 -03009AC_CONFIG_MACRO_DIR([m4])
10AC_CONFIG_HEADERS(config.h)
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020011AC_CONFIG_AUX_DIR([build-aux])
Lucas De Marchi481ad142015-02-26 02:56:04 -030012
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020013AC_USE_SYSTEM_EXTENSIONS
14AC_SYS_LARGEFILE
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020015AC_PREFIX_DEFAULT([/usr])
Anders Olofssonf5cc26c2013-11-10 23:41:25 -020016AM_MAINTAINER_MODE([enable])
Lucas De Marchi481ad142015-02-26 02:56:04 -030017AM_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])
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020020
Lucas De Marchifae77512015-02-27 16:19:44 -030021AS_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])])
Lucas De Marchib7016152013-06-06 11:43:19 -030023
Lucas De Marchi3ef72082012-03-17 10:26:32 -030024#####################################################################
25# Program checks and configurations
26#####################################################################
27
Kay Sievers9faa7b32011-12-21 11:48:07 -020028AC_PROG_SED
29AC_PROG_MKDIR_P
Lucas De Marchi481ad142015-02-26 02:56:04 -030030AC_PROG_LN_S
Jan Engelhardt7b3a74f2011-12-24 04:45:22 +010031PKG_PROG_PKG_CONFIG
Lucas De Marchibccb4b22014-02-24 10:52:58 -030032AC_PATH_PROG([XSLTPROC], [xsltproc])
Gustavo Sverzut Barbieri3d8226e2011-12-16 16:08:53 -020033
Lucas De Marchi481ad142015-02-26 02:56:04 -030034AC_PROG_CC_C99
Lucas De Marchi3ef72082012-03-17 10:26:32 -030035
36#####################################################################
37# Function and structure checks
38#####################################################################
39
Lucas De Marchid005aeb2012-02-08 20:29:52 -020040AC_CHECK_FUNCS_ONCE(__xstat)
Cristian Rodríguez41a51c22013-02-11 15:07:52 -030041AC_CHECK_FUNCS_ONCE([__secure_getenv secure_getenv])
Lucas De Marchi55112d12013-04-09 04:16:57 -030042AC_CHECK_FUNCS_ONCE([finit_module])
Lucas De Marchid005aeb2012-02-08 20:29:52 -020043
Lucas De Marchie6307202015-02-10 00:45:11 -020044CC_CHECK_FUNC_BUILTIN([__builtin_clz])
45CC_CHECK_FUNC_BUILTIN([__builtin_types_compatible_p])
Lucas De Marchiaac5f452015-02-10 10:41:47 -020046CC_CHECK_FUNC_BUILTIN([__builtin_uaddl_overflow], [ ], [ ])
47CC_CHECK_FUNC_BUILTIN([__builtin_uaddll_overflow], [ ], [ ])
Lucas De Marchie6307202015-02-10 00:45:11 -020048
Lucas De Marchi3ef72082012-03-17 10:26:32 -030049# dietlibc doesn't have st.st_mtim struct member
50AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
51
Lucas De Marchi04c09562014-04-04 08:19:00 -030052# musl 1.0 and bionic 4.4 don't have strndupa
53AC_CHECK_DECLS_ONCE([strndupa])
54
Randy MacLeod9b34db12014-09-29 21:18:04 +020055# RHEL 5 and older do not have be32toh
56AC_CHECK_DECLS_ONCE([be32toh])
57
Kees Cook144d1822013-02-18 12:02:32 -080058# Check kernel headers
59AC_CHECK_HEADERS_ONCE([linux/module.h])
60
Thomas Petazzonidc8ed092013-09-06 15:27:04 +020061AC_MSG_CHECKING([whether _Static_assert() is supported])
62AC_COMPILE_IFELSE(
63 [AC_LANG_SOURCE([[_Static_assert(1, "Test");]])],
64 [AC_DEFINE([HAVE_STATIC_ASSERT], [1], [Define if _Static_assert() is available])
65 AC_MSG_RESULT([yes])],
66 [AC_MSG_RESULT([no])])
Lucas De Marchi3ef72082012-03-17 10:26:32 -030067
Lucas De Marchi16a62c72015-02-26 13:02:04 -030068AC_MSG_CHECKING([whether _Noreturn is supported])
69AC_COMPILE_IFELSE(
70 [AC_LANG_SOURCE([[_Noreturn int foo(void) { exit(0); }]])],
71 [AC_DEFINE([HAVE_NORETURN], [1], [Define if _Noreturn is available])
72 AC_MSG_RESULT([yes])],
73 [AC_MSG_RESULT([no])])
74
75
Lucas De Marchi3ef72082012-03-17 10:26:32 -030076#####################################################################
77# --with-
78#####################################################################
79
Kay Sieverse79bf832011-12-22 15:40:24 +010080AC_ARG_WITH([rootlibdir],
81 AS_HELP_STRING([--with-rootlibdir=DIR], [rootfs directory to install shared libraries]),
82 [], [with_rootlibdir=$libdir])
83AC_SUBST([rootlibdir], [$with_rootlibdir])
84
Jan Engelhardtb182f8f2011-12-24 14:58:30 +010085AC_ARG_WITH([xz],
86 AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]),
87 [], [with_xz=no])
88AS_IF([test "x$with_xz" != "xno"], [
89 PKG_CHECK_MODULES([liblzma], [liblzma >= 4.99])
90 AC_DEFINE([ENABLE_XZ], [1], [Enable Xz for modules.])
91], [
92 AC_MSG_NOTICE([Xz support not requested])
93])
94
Jan Engelhardt5a51a352011-12-24 04:45:42 +010095AC_ARG_WITH([zlib],
96 AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]),
97 [], [with_zlib=no])
98AS_IF([test "x$with_zlib" != "xno"], [
Jan Engelhardt7b3a74f2011-12-24 04:45:22 +010099 PKG_CHECK_MODULES([zlib], [zlib])
100 AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.])
Lucas De Marchicfb908b2011-12-23 12:03:19 -0200101], [
102 AC_MSG_NOTICE([zlib support not requested])
Lucas De Marchicfb908b2011-12-23 12:03:19 -0200103])
Gustavo Sverzut Barbieri3d8226e2011-12-16 16:08:53 -0200104
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300105AC_ARG_WITH([bashcompletiondir],
106 AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
107 [],
108 [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
109 with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
110 ] , [
111 with_bashcompletiondir=${datadir}/bash-completion/completions
112 ])])
113AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300114
115#####################################################################
116# --enable-
117#####################################################################
118
119AC_ARG_ENABLE([tools],
120 AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
121 [], enable_tools=yes)
122AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
123
Colin Walters86315522012-07-30 12:27:10 -0400124AC_ARG_ENABLE([manpages],
125 AS_HELP_STRING([--disable-manpages], [disable manpages @<:@default=enabled@:>@]),
126 [], enable_manpages=yes)
127AM_CONDITIONAL([BUILD_MANPAGES], [test "x$enable_manpages" = "xyes"])
128
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300129AC_ARG_ENABLE([logging],
130 AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
131 [], enable_logging=yes)
132AS_IF([test "x$enable_logging" = "xyes"], [
133 AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
134])
135
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200136AC_ARG_ENABLE([debug],
137 AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
138 [], [enable_debug=no])
139AS_IF([test "x$enable_debug" = "xyes"], [
140 AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
141])
142
Lucas De Marchi3a33a7a2014-03-24 08:27:19 -0300143AC_ARG_ENABLE([python],
144 AS_HELP_STRING([--enable-python], [enable Python libkmod bindings @<:@default=disabled@:>@]),
145 [], [enable_python=no])
146AS_IF([test "x$enable_python" = "xyes"], [
147 AM_PATH_PYTHON(,,[:])
148 AC_PATH_PROG([CYTHON], [cython], [:])
149
150 PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}],
151 [have_python=yes],
152 [PKG_CHECK_MODULES([PYTHON], [python],
153 [have_python=yes],
154 [have_python=no])])
155
156 AS_IF([test "x$have_python" = xno],
157 [AC_MSG_ERROR([*** python support requested but libraries not found])])
158])
159AM_CONDITIONAL([BUILD_PYTHON], [test "x$enable_python" = "xyes"])
160
Lucas De Marchie9b0d1b2015-01-07 19:17:15 -0200161AC_ARG_ENABLE([coverage],
162 AS_HELP_STRING([--enable-coverage], [enable test coverage @<:@default=disabled@:>@]),
163 [], [enable_coverage=no])
164AS_IF([test "x$enable_coverage" = "xyes"], [
165 AC_CHECK_PROG(have_coverage, [lcov], [yes], [no])
166 AS_IF([test "x$have_coverage" = xno],[
167 AC_MSG_ERROR([*** lcov support requested but the program was not found])
168 ], [
169 lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
170 lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
171 AS_IF([test "$lcov_version_major" -lt 1 -o "$lcov_version_minor" -lt 10], [
172 AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
173 ], [
174 have_coverage=yes
175 CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
176 -fprofile-arcs \
177 -ftest-coverage])
178 ])
179 ])
180])
181AM_CONDITIONAL([ENABLE_COVERAGE], [test "x$enable_coverage" = "xyes"])
182
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300183m4_ifdef([GTK_DOC_CHECK], [
184GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
185], [
186AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
187
188
189#####################################################################
190# Default CFLAGS and LDFLAGS
191#####################################################################
Lucas De Marchi6068aaa2012-01-17 12:10:42 -0200192
Lucas De Marchie48f3762012-03-17 15:12:44 -0300193CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
194 -pipe \
195 -DANOTHER_BRICK_IN_THE \
196 -Wall \
197 -W \
198 -Wextra \
199 -Wno-inline \
200 -Wvla \
201 -Wundef \
202 -Wformat=2 \
203 -Wlogical-op \
204 -Wsign-compare \
205 -Wformat-security \
206 -Wmissing-include-dirs \
207 -Wformat-nonliteral \
208 -Wold-style-definition \
209 -Wpointer-arith \
210 -Winit-self \
211 -Wdeclaration-after-statement \
212 -Wfloat-equal \
213 -Wmissing-prototypes \
214 -Wstrict-prototypes \
215 -Wredundant-decls \
216 -Wmissing-declarations \
217 -Wmissing-noreturn \
218 -Wshadow \
219 -Wendif-labels \
Lucas De Marchidb621532014-03-24 23:50:24 -0300220 -Wstrict-aliasing=3 \
Lucas De Marchie48f3762012-03-17 15:12:44 -0300221 -Wwrite-strings \
222 -Wno-long-long \
223 -Wno-overlength-strings \
224 -Wno-unused-parameter \
225 -Wno-missing-field-initializers \
226 -Wno-unused-result \
227 -Wnested-externs \
228 -Wchar-subscripts \
229 -Wtype-limits \
230 -Wuninitialized \
231 -fno-common \
232 -fdiagnostics-show-option \
233 -fvisibility=hidden \
234 -ffunction-sections \
235 -fdata-sections])
Lucas De Marchi27bcc912015-01-25 23:28:46 -0200236AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
Gustavo Sverzut Barbieri822ce232011-12-10 22:26:40 -0200237
Lucas De Marchic677bf22015-01-26 19:07:12 -0200238
Lucas De Marchie48f3762012-03-17 15:12:44 -0300239CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
240 -Wl,--as-needed \
Lucas De Marchia5f799a2015-01-25 23:29:50 -0200241 -Wl,--no-undefined \
Lucas De Marchie48f3762012-03-17 15:12:44 -0300242 -Wl,--gc-sections])
Lucas De Marchi84aaaed2015-01-02 16:32:03 -0200243AC_SUBST([OUR_LDFLAGS], $with_ldflags)
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300244
245#####################################################################
246# Generate files from *.in
247#####################################################################
248
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200249AC_CONFIG_FILES([
250 Makefile
Lucas De Marchi904b57d2012-01-12 11:48:21 -0200251 man/Makefile
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200252 libkmod/docs/Makefile
253 libkmod/docs/version.xml
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200254])
255
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300256
257#####################################################################
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200258
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200259AC_OUTPUT
260AC_MSG_RESULT([
261 $PACKAGE $VERSION
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300262 =======
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200263
264 prefix: ${prefix}
265 sysconfdir: ${sysconfdir}
266 libdir: ${libdir}
Kay Sieverse79bf832011-12-22 15:40:24 +0100267 rootlibdir: ${rootlibdir}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200268 includedir: ${includedir}
Lucas De Marchi7c41c2d2011-12-12 13:39:07 -0200269 bindir: ${bindir}
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300270 Bash completions dir: ${with_bashcompletiondir}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200271
272 compiler: ${CC}
Lucas De Marchie48f3762012-03-17 15:12:44 -0300273 cflags: ${with_cflags} ${CFLAGS}
274 ldflags: ${with_ldflags} ${LDFLAGS}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200275
Lucas De Marchi7c41c2d2011-12-12 13:39:07 -0200276 tools: ${enable_tools}
Lucas De Marchi3a33a7a2014-03-24 08:27:19 -0300277 python bindings: ${enable_python}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200278 logging: ${enable_logging}
Jan Engelhardtb182f8f2011-12-24 14:58:30 +0100279 compression: xz=${with_xz} zlib=${with_zlib}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200280 debug: ${enable_debug}
Lucas De Marchie9b0d1b2015-01-07 19:17:15 -0200281 coverage: ${enable_coverage}
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200282 doc: ${enable_gtk_doc}
Lucas De Marchi382de852012-07-31 09:51:48 -0300283 man: ${enable_manpages}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200284])