blob: 30eb37f7f2146c9d9eace17b15ad0f47fbdd1b9e [file] [log] [blame]
Lucas De Marchiecd40ee2011-11-21 12:35:15 -02001AC_PREREQ(2.60)
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 Marchiecd40ee2011-11-21 12:35:15 -02009AC_CONFIG_AUX_DIR([build-aux])
Jan Engelhardta597c8b2011-12-20 16:28:27 +010010AM_INIT_AUTOMAKE([check-news foreign 1.11 silent-rules
Lucas De Marchi8edd5bb2013-04-09 11:59:33 -030011 tar-pax no-dist-gzip dist-xz subdir-objects color-tests parallel-tests])
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020012AC_PROG_CC_STDC
13AC_USE_SYSTEM_EXTENSIONS
14AC_SYS_LARGEFILE
15AC_CONFIG_MACRO_DIR([m4])
Luis Felipe Strano Moraesfe8bf3b2011-12-14 15:56:10 -020016m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020017AM_SILENT_RULES([yes])
18LT_INIT([disable-static pic-only])
19AC_PREFIX_DEFAULT([/usr])
Anders Olofssonf5cc26c2013-11-10 23:41:25 -020020AM_MAINTAINER_MODE([enable])
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020021
Lucas De Marchib7016152013-06-06 11:43:19 -030022AS_IF([test "x$enable_static" = "xyes"],
23 [AC_MSG_ERROR([--enable-static is not supported by kmod])])
24
25
Lucas De Marchi3ef72082012-03-17 10:26:32 -030026#####################################################################
27# Program checks and configurations
28#####################################################################
29
Lucas De Marchi648a8422011-11-22 17:46:19 -020030AC_PROG_CC
31AC_PROG_CC_C99
Lucas De Marchi648a8422011-11-22 17:46:19 -020032AM_PROG_CC_C_O
33AC_PROG_GCC_TRADITIONAL
Gustavo Sverzut Barbieri708624a2011-12-18 01:25:06 -020034AC_C_BIGENDIAN
Lucas De Marchi648a8422011-11-22 17:46:19 -020035
Kay Sievers9faa7b32011-12-21 11:48:07 -020036AC_PROG_SED
37AC_PROG_MKDIR_P
Jan Engelhardt7b3a74f2011-12-24 04:45:22 +010038PKG_PROG_PKG_CONFIG
Lucas De Marchibccb4b22014-02-24 10:52:58 -030039AC_PATH_PROG([XSLTPROC], [xsltproc])
Gustavo Sverzut Barbieri3d8226e2011-12-16 16:08:53 -020040
Lucas De Marchi3ef72082012-03-17 10:26:32 -030041
42#####################################################################
43# Function and structure checks
44#####################################################################
45
Lucas De Marchid005aeb2012-02-08 20:29:52 -020046AC_CHECK_FUNCS_ONCE(__xstat)
Cristian Rodríguez41a51c22013-02-11 15:07:52 -030047AC_CHECK_FUNCS_ONCE([__secure_getenv secure_getenv])
Lucas De Marchi55112d12013-04-09 04:16:57 -030048AC_CHECK_FUNCS_ONCE([finit_module])
Lucas De Marchid005aeb2012-02-08 20:29:52 -020049
Lucas De Marchie6307202015-02-10 00:45:11 -020050CC_CHECK_FUNC_BUILTIN([__builtin_clz])
51CC_CHECK_FUNC_BUILTIN([__builtin_types_compatible_p])
Lucas De Marchiaac5f452015-02-10 10:41:47 -020052CC_CHECK_FUNC_BUILTIN([__builtin_uaddl_overflow], [ ], [ ])
53CC_CHECK_FUNC_BUILTIN([__builtin_uaddll_overflow], [ ], [ ])
Lucas De Marchie6307202015-02-10 00:45:11 -020054
Lucas De Marchi3ef72082012-03-17 10:26:32 -030055# dietlibc doesn't have st.st_mtim struct member
56AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
57
Lucas De Marchi04c09562014-04-04 08:19:00 -030058# musl 1.0 and bionic 4.4 don't have strndupa
59AC_CHECK_DECLS_ONCE([strndupa])
60
Randy MacLeod9b34db12014-09-29 21:18:04 +020061# RHEL 5 and older do not have be32toh
62AC_CHECK_DECLS_ONCE([be32toh])
63
Kees Cook144d1822013-02-18 12:02:32 -080064# Check kernel headers
65AC_CHECK_HEADERS_ONCE([linux/module.h])
66
Thomas Petazzonidc8ed092013-09-06 15:27:04 +020067AC_MSG_CHECKING([whether _Static_assert() is supported])
68AC_COMPILE_IFELSE(
69 [AC_LANG_SOURCE([[_Static_assert(1, "Test");]])],
70 [AC_DEFINE([HAVE_STATIC_ASSERT], [1], [Define if _Static_assert() is available])
71 AC_MSG_RESULT([yes])],
72 [AC_MSG_RESULT([no])])
Lucas De Marchi3ef72082012-03-17 10:26:32 -030073
74#####################################################################
75# --with-
76#####################################################################
77
Kay Sieverse79bf832011-12-22 15:40:24 +010078AC_ARG_WITH([rootlibdir],
79 AS_HELP_STRING([--with-rootlibdir=DIR], [rootfs directory to install shared libraries]),
80 [], [with_rootlibdir=$libdir])
81AC_SUBST([rootlibdir], [$with_rootlibdir])
82
Jan Engelhardtb182f8f2011-12-24 14:58:30 +010083AC_ARG_WITH([xz],
84 AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]),
85 [], [with_xz=no])
86AS_IF([test "x$with_xz" != "xno"], [
87 PKG_CHECK_MODULES([liblzma], [liblzma >= 4.99])
88 AC_DEFINE([ENABLE_XZ], [1], [Enable Xz for modules.])
89], [
90 AC_MSG_NOTICE([Xz support not requested])
91])
92
Jan Engelhardt5a51a352011-12-24 04:45:42 +010093AC_ARG_WITH([zlib],
94 AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]),
95 [], [with_zlib=no])
96AS_IF([test "x$with_zlib" != "xno"], [
Jan Engelhardt7b3a74f2011-12-24 04:45:22 +010097 PKG_CHECK_MODULES([zlib], [zlib])
98 AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.])
Lucas De Marchicfb908b2011-12-23 12:03:19 -020099], [
100 AC_MSG_NOTICE([zlib support not requested])
Lucas De Marchicfb908b2011-12-23 12:03:19 -0200101])
Gustavo Sverzut Barbieri3d8226e2011-12-16 16:08:53 -0200102
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300103AC_ARG_WITH([bashcompletiondir],
104 AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
105 [],
106 [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
107 with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
108 ] , [
109 with_bashcompletiondir=${datadir}/bash-completion/completions
110 ])])
111AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300112
113#####################################################################
114# --enable-
115#####################################################################
116
117AC_ARG_ENABLE([tools],
118 AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
119 [], enable_tools=yes)
120AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
121
Colin Walters86315522012-07-30 12:27:10 -0400122AC_ARG_ENABLE([manpages],
123 AS_HELP_STRING([--disable-manpages], [disable manpages @<:@default=enabled@:>@]),
124 [], enable_manpages=yes)
125AM_CONDITIONAL([BUILD_MANPAGES], [test "x$enable_manpages" = "xyes"])
126
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300127AC_ARG_ENABLE([logging],
128 AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
129 [], enable_logging=yes)
130AS_IF([test "x$enable_logging" = "xyes"], [
131 AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
132])
133
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200134AC_ARG_ENABLE([debug],
135 AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
136 [], [enable_debug=no])
137AS_IF([test "x$enable_debug" = "xyes"], [
138 AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
139])
140
Lucas De Marchi3a33a7a2014-03-24 08:27:19 -0300141AC_ARG_ENABLE([python],
142 AS_HELP_STRING([--enable-python], [enable Python libkmod bindings @<:@default=disabled@:>@]),
143 [], [enable_python=no])
144AS_IF([test "x$enable_python" = "xyes"], [
145 AM_PATH_PYTHON(,,[:])
146 AC_PATH_PROG([CYTHON], [cython], [:])
147
148 PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}],
149 [have_python=yes],
150 [PKG_CHECK_MODULES([PYTHON], [python],
151 [have_python=yes],
152 [have_python=no])])
153
154 AS_IF([test "x$have_python" = xno],
155 [AC_MSG_ERROR([*** python support requested but libraries not found])])
156])
157AM_CONDITIONAL([BUILD_PYTHON], [test "x$enable_python" = "xyes"])
158
Lucas De Marchie9b0d1b2015-01-07 19:17:15 -0200159AC_ARG_ENABLE([coverage],
160 AS_HELP_STRING([--enable-coverage], [enable test coverage @<:@default=disabled@:>@]),
161 [], [enable_coverage=no])
162AS_IF([test "x$enable_coverage" = "xyes"], [
163 AC_CHECK_PROG(have_coverage, [lcov], [yes], [no])
164 AS_IF([test "x$have_coverage" = xno],[
165 AC_MSG_ERROR([*** lcov support requested but the program was not found])
166 ], [
167 lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
168 lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
169 AS_IF([test "$lcov_version_major" -lt 1 -o "$lcov_version_minor" -lt 10], [
170 AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
171 ], [
172 have_coverage=yes
173 CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
174 -fprofile-arcs \
175 -ftest-coverage])
176 ])
177 ])
178])
179AM_CONDITIONAL([ENABLE_COVERAGE], [test "x$enable_coverage" = "xyes"])
180
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300181m4_ifdef([GTK_DOC_CHECK], [
182GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
183], [
184AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
185
186
187#####################################################################
188# Default CFLAGS and LDFLAGS
189#####################################################################
Lucas De Marchi6068aaa2012-01-17 12:10:42 -0200190
Lucas De Marchie48f3762012-03-17 15:12:44 -0300191CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
192 -pipe \
193 -DANOTHER_BRICK_IN_THE \
194 -Wall \
195 -W \
196 -Wextra \
197 -Wno-inline \
198 -Wvla \
199 -Wundef \
200 -Wformat=2 \
201 -Wlogical-op \
202 -Wsign-compare \
203 -Wformat-security \
204 -Wmissing-include-dirs \
205 -Wformat-nonliteral \
206 -Wold-style-definition \
207 -Wpointer-arith \
208 -Winit-self \
209 -Wdeclaration-after-statement \
210 -Wfloat-equal \
211 -Wmissing-prototypes \
212 -Wstrict-prototypes \
213 -Wredundant-decls \
214 -Wmissing-declarations \
215 -Wmissing-noreturn \
216 -Wshadow \
217 -Wendif-labels \
Lucas De Marchidb621532014-03-24 23:50:24 -0300218 -Wstrict-aliasing=3 \
Lucas De Marchie48f3762012-03-17 15:12:44 -0300219 -Wwrite-strings \
220 -Wno-long-long \
221 -Wno-overlength-strings \
222 -Wno-unused-parameter \
223 -Wno-missing-field-initializers \
224 -Wno-unused-result \
225 -Wnested-externs \
226 -Wchar-subscripts \
227 -Wtype-limits \
228 -Wuninitialized \
229 -fno-common \
230 -fdiagnostics-show-option \
231 -fvisibility=hidden \
232 -ffunction-sections \
233 -fdata-sections])
Lucas De Marchi27bcc912015-01-25 23:28:46 -0200234AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
Gustavo Sverzut Barbieri822ce232011-12-10 22:26:40 -0200235
Lucas De Marchic677bf22015-01-26 19:07:12 -0200236
Lucas De Marchie48f3762012-03-17 15:12:44 -0300237CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
238 -Wl,--as-needed \
Lucas De Marchia5f799a2015-01-25 23:29:50 -0200239 -Wl,--no-undefined \
Lucas De Marchie48f3762012-03-17 15:12:44 -0300240 -Wl,--gc-sections])
Lucas De Marchi84aaaed2015-01-02 16:32:03 -0200241AC_SUBST([OUR_LDFLAGS], $with_ldflags)
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300242
243#####################################################################
244# Generate files from *.in
245#####################################################################
246
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200247AC_CONFIG_HEADERS(config.h)
248AC_CONFIG_FILES([
249 Makefile
Lucas De Marchi904b57d2012-01-12 11:48:21 -0200250 man/Makefile
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200251 libkmod/docs/Makefile
252 libkmod/docs/version.xml
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200253])
254
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300255
256#####################################################################
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200257
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200258AC_OUTPUT
259AC_MSG_RESULT([
260 $PACKAGE $VERSION
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300261 =======
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200262
263 prefix: ${prefix}
264 sysconfdir: ${sysconfdir}
265 libdir: ${libdir}
Kay Sieverse79bf832011-12-22 15:40:24 +0100266 rootlibdir: ${rootlibdir}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200267 includedir: ${includedir}
Lucas De Marchi7c41c2d2011-12-12 13:39:07 -0200268 bindir: ${bindir}
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300269 Bash completions dir: ${with_bashcompletiondir}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200270
271 compiler: ${CC}
Lucas De Marchie48f3762012-03-17 15:12:44 -0300272 cflags: ${with_cflags} ${CFLAGS}
273 ldflags: ${with_ldflags} ${LDFLAGS}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200274
Lucas De Marchi7c41c2d2011-12-12 13:39:07 -0200275 tools: ${enable_tools}
Lucas De Marchi3a33a7a2014-03-24 08:27:19 -0300276 python bindings: ${enable_python}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200277 logging: ${enable_logging}
Jan Engelhardtb182f8f2011-12-24 14:58:30 +0100278 compression: xz=${with_xz} zlib=${with_zlib}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200279 debug: ${enable_debug}
Lucas De Marchie9b0d1b2015-01-07 19:17:15 -0200280 coverage: ${enable_coverage}
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200281 doc: ${enable_gtk_doc}
Lucas De Marchi382de852012-07-31 09:51:48 -0300282 man: ${enable_manpages}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200283])