blob: f83eed5405473c458f84999d25052e8de339a533 [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 Marchid9c71752015-03-01 14:43:09 -03003 [20],
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 Marchida6c0d22015-03-05 13:03:35 -030020DOLT
Lucas De Marchiecd40ee2011-11-21 12:35:15 -020021
Lucas De Marchifae77512015-02-27 16:19:44 -030022AS_IF([test "x$enable_static" = "xyes"], [AC_MSG_ERROR([--enable-static is not supported by kmod])])
23AS_IF([test "x$enable_largefile" = "xno"], [AC_MSG_ERROR([--disable-largefile is not supported by kmod])])
Lucas De Marchib7016152013-06-06 11:43:19 -030024
Lucas De Marchi3ef72082012-03-17 10:26:32 -030025#####################################################################
26# Program checks and configurations
27#####################################################################
28
Kay Sievers9faa7b32011-12-21 11:48:07 -020029AC_PROG_SED
30AC_PROG_MKDIR_P
Lucas De Marchi481ad142015-02-26 02:56:04 -030031AC_PROG_LN_S
Jan Engelhardt7b3a74f2011-12-24 04:45:22 +010032PKG_PROG_PKG_CONFIG
Lucas De Marchibccb4b22014-02-24 10:52:58 -030033AC_PATH_PROG([XSLTPROC], [xsltproc])
Gustavo Sverzut Barbieri3d8226e2011-12-16 16:08:53 -020034
Lucas De Marchi481ad142015-02-26 02:56:04 -030035AC_PROG_CC_C99
Lucas De Marchi3ef72082012-03-17 10:26:32 -030036
37#####################################################################
38# Function and structure checks
39#####################################################################
40
Lucas De Marchid005aeb2012-02-08 20:29:52 -020041AC_CHECK_FUNCS_ONCE(__xstat)
Cristian Rodríguez41a51c22013-02-11 15:07:52 -030042AC_CHECK_FUNCS_ONCE([__secure_getenv secure_getenv])
Lucas De Marchi55112d12013-04-09 04:16:57 -030043AC_CHECK_FUNCS_ONCE([finit_module])
Lucas De Marchid005aeb2012-02-08 20:29:52 -020044
Lucas De Marchie6307202015-02-10 00:45:11 -020045CC_CHECK_FUNC_BUILTIN([__builtin_clz])
46CC_CHECK_FUNC_BUILTIN([__builtin_types_compatible_p])
Lucas De Marchiaac5f452015-02-10 10:41:47 -020047CC_CHECK_FUNC_BUILTIN([__builtin_uaddl_overflow], [ ], [ ])
48CC_CHECK_FUNC_BUILTIN([__builtin_uaddll_overflow], [ ], [ ])
Lucas De Marchie6307202015-02-10 00:45:11 -020049
Lucas De Marchi3ef72082012-03-17 10:26:32 -030050# dietlibc doesn't have st.st_mtim struct member
51AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
52
Lucas De Marchi04c09562014-04-04 08:19:00 -030053# musl 1.0 and bionic 4.4 don't have strndupa
54AC_CHECK_DECLS_ONCE([strndupa])
55
Randy MacLeod9b34db12014-09-29 21:18:04 +020056# RHEL 5 and older do not have be32toh
57AC_CHECK_DECLS_ONCE([be32toh])
58
Kees Cook144d1822013-02-18 12:02:32 -080059# Check kernel headers
60AC_CHECK_HEADERS_ONCE([linux/module.h])
61
Thomas Petazzonidc8ed092013-09-06 15:27:04 +020062AC_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])])
Lucas De Marchi3ef72082012-03-17 10:26:32 -030068
Lucas De Marchi16a62c72015-02-26 13:02:04 -030069AC_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
Lucas De Marchi3ef72082012-03-17 10:26:32 -030077#####################################################################
78# --with-
79#####################################################################
80
Kay Sieverse79bf832011-12-22 15:40:24 +010081AC_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
Jan Engelhardtb182f8f2011-12-24 14:58:30 +010086AC_ARG_WITH([xz],
87 AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]),
88 [], [with_xz=no])
89AS_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
Jan Engelhardt5a51a352011-12-24 04:45:42 +010096AC_ARG_WITH([zlib],
97 AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]),
98 [], [with_zlib=no])
99AS_IF([test "x$with_zlib" != "xno"], [
Jan Engelhardt7b3a74f2011-12-24 04:45:22 +0100100 PKG_CHECK_MODULES([zlib], [zlib])
101 AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.])
Lucas De Marchicfb908b2011-12-23 12:03:19 -0200102], [
103 AC_MSG_NOTICE([zlib support not requested])
Lucas De Marchicfb908b2011-12-23 12:03:19 -0200104])
Gustavo Sverzut Barbieri3d8226e2011-12-16 16:08:53 -0200105
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300106AC_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 ])])
114AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300115
116#####################################################################
117# --enable-
118#####################################################################
119
Lucas De Marchi013e8552015-06-06 23:26:31 -0300120AC_ARG_ENABLE([experimental],
121 AS_HELP_STRING([--enable-experimental], [enable experimental tools and features. Do not enable it unless you know what you are doing. @<:@default=disabled@:>@]),
122 [], enable_experimental=no)
123AM_CONDITIONAL([BUILD_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"])
124AS_IF([test "x$enable_experimental" = "xyes"], [
125 AC_DEFINE(ENABLE_EXPERIMENTAL, [1], [Experimental features.])
126])
127
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300128AC_ARG_ENABLE([tools],
129 AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
130 [], enable_tools=yes)
131AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
132
Colin Walters86315522012-07-30 12:27:10 -0400133AC_ARG_ENABLE([manpages],
134 AS_HELP_STRING([--disable-manpages], [disable manpages @<:@default=enabled@:>@]),
135 [], enable_manpages=yes)
136AM_CONDITIONAL([BUILD_MANPAGES], [test "x$enable_manpages" = "xyes"])
137
Lucas De Marchi23603f12015-05-31 15:38:47 -0300138AC_ARG_ENABLE([test-modules],
139 AS_HELP_STRING([--disable-test-modules], [disable building test modules during make check: cached modules will be used @<:@default=enabled@:>@]),
140 [], enable_test_modules=yes)
141AM_CONDITIONAL([BUILD_MODULES], [test "x$enable_test_modules" = "xyes"])
142
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300143AC_ARG_ENABLE([logging],
144 AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
145 [], enable_logging=yes)
146AS_IF([test "x$enable_logging" = "xyes"], [
147 AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
148])
149
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200150AC_ARG_ENABLE([debug],
151 AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
152 [], [enable_debug=no])
153AS_IF([test "x$enable_debug" = "xyes"], [
154 AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
155])
156
Lucas De Marchi3a33a7a2014-03-24 08:27:19 -0300157AC_ARG_ENABLE([python],
158 AS_HELP_STRING([--enable-python], [enable Python libkmod bindings @<:@default=disabled@:>@]),
159 [], [enable_python=no])
160AS_IF([test "x$enable_python" = "xyes"], [
161 AM_PATH_PYTHON(,,[:])
162 AC_PATH_PROG([CYTHON], [cython], [:])
163
164 PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}],
165 [have_python=yes],
166 [PKG_CHECK_MODULES([PYTHON], [python],
167 [have_python=yes],
168 [have_python=no])])
169
170 AS_IF([test "x$have_python" = xno],
171 [AC_MSG_ERROR([*** python support requested but libraries not found])])
172])
173AM_CONDITIONAL([BUILD_PYTHON], [test "x$enable_python" = "xyes"])
174
Lucas De Marchie9b0d1b2015-01-07 19:17:15 -0200175AC_ARG_ENABLE([coverage],
176 AS_HELP_STRING([--enable-coverage], [enable test coverage @<:@default=disabled@:>@]),
177 [], [enable_coverage=no])
178AS_IF([test "x$enable_coverage" = "xyes"], [
179 AC_CHECK_PROG(have_coverage, [lcov], [yes], [no])
180 AS_IF([test "x$have_coverage" = xno],[
181 AC_MSG_ERROR([*** lcov support requested but the program was not found])
182 ], [
183 lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
184 lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
185 AS_IF([test "$lcov_version_major" -lt 1 -o "$lcov_version_minor" -lt 10], [
186 AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
187 ], [
188 have_coverage=yes
189 CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
190 -fprofile-arcs \
191 -ftest-coverage])
192 ])
193 ])
194])
195AM_CONDITIONAL([ENABLE_COVERAGE], [test "x$enable_coverage" = "xyes"])
196
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300197m4_ifdef([GTK_DOC_CHECK], [
198GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
199], [
200AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
201
202
203#####################################################################
204# Default CFLAGS and LDFLAGS
205#####################################################################
Lucas De Marchi6068aaa2012-01-17 12:10:42 -0200206
Lucas De Marchie48f3762012-03-17 15:12:44 -0300207CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
208 -pipe \
209 -DANOTHER_BRICK_IN_THE \
210 -Wall \
211 -W \
212 -Wextra \
213 -Wno-inline \
214 -Wvla \
215 -Wundef \
216 -Wformat=2 \
217 -Wlogical-op \
218 -Wsign-compare \
219 -Wformat-security \
220 -Wmissing-include-dirs \
221 -Wformat-nonliteral \
222 -Wold-style-definition \
223 -Wpointer-arith \
224 -Winit-self \
225 -Wdeclaration-after-statement \
226 -Wfloat-equal \
227 -Wmissing-prototypes \
228 -Wstrict-prototypes \
229 -Wredundant-decls \
230 -Wmissing-declarations \
231 -Wmissing-noreturn \
232 -Wshadow \
233 -Wendif-labels \
Lucas De Marchidb621532014-03-24 23:50:24 -0300234 -Wstrict-aliasing=3 \
Lucas De Marchie48f3762012-03-17 15:12:44 -0300235 -Wwrite-strings \
236 -Wno-long-long \
237 -Wno-overlength-strings \
238 -Wno-unused-parameter \
239 -Wno-missing-field-initializers \
240 -Wno-unused-result \
241 -Wnested-externs \
242 -Wchar-subscripts \
243 -Wtype-limits \
244 -Wuninitialized \
245 -fno-common \
246 -fdiagnostics-show-option \
247 -fvisibility=hidden \
248 -ffunction-sections \
249 -fdata-sections])
Lucas De Marchi27bcc912015-01-25 23:28:46 -0200250AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
Gustavo Sverzut Barbieri822ce232011-12-10 22:26:40 -0200251
Lucas De Marchic677bf22015-01-26 19:07:12 -0200252
Lucas De Marchie48f3762012-03-17 15:12:44 -0300253CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
254 -Wl,--as-needed \
Lucas De Marchia5f799a2015-01-25 23:29:50 -0200255 -Wl,--no-undefined \
Lucas De Marchie48f3762012-03-17 15:12:44 -0300256 -Wl,--gc-sections])
Lucas De Marchi84aaaed2015-01-02 16:32:03 -0200257AC_SUBST([OUR_LDFLAGS], $with_ldflags)
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300258
259#####################################################################
260# Generate files from *.in
261#####################################################################
262
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200263AC_CONFIG_FILES([
264 Makefile
Lucas De Marchi904b57d2012-01-12 11:48:21 -0200265 man/Makefile
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200266 libkmod/docs/Makefile
267 libkmod/docs/version.xml
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200268])
269
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300270
271#####################################################################
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200272
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200273AC_OUTPUT
274AC_MSG_RESULT([
275 $PACKAGE $VERSION
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300276 =======
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200277
278 prefix: ${prefix}
279 sysconfdir: ${sysconfdir}
280 libdir: ${libdir}
Kay Sieverse79bf832011-12-22 15:40:24 +0100281 rootlibdir: ${rootlibdir}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200282 includedir: ${includedir}
Lucas De Marchi7c41c2d2011-12-12 13:39:07 -0200283 bindir: ${bindir}
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300284 Bash completions dir: ${with_bashcompletiondir}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200285
286 compiler: ${CC}
Lucas De Marchie48f3762012-03-17 15:12:44 -0300287 cflags: ${with_cflags} ${CFLAGS}
288 ldflags: ${with_ldflags} ${LDFLAGS}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200289
Lucas De Marchi013e8552015-06-06 23:26:31 -0300290 experimental features: ${enable_experimental}
Lucas De Marchi7c41c2d2011-12-12 13:39:07 -0200291 tools: ${enable_tools}
Lucas De Marchi3a33a7a2014-03-24 08:27:19 -0300292 python bindings: ${enable_python}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200293 logging: ${enable_logging}
Jan Engelhardtb182f8f2011-12-24 14:58:30 +0100294 compression: xz=${with_xz} zlib=${with_zlib}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200295 debug: ${enable_debug}
Lucas De Marchie9b0d1b2015-01-07 19:17:15 -0200296 coverage: ${enable_coverage}
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200297 doc: ${enable_gtk_doc}
Lucas De Marchi382de852012-07-31 09:51:48 -0300298 man: ${enable_manpages}
Lucas De Marchi23603f12015-05-31 15:38:47 -0300299 test-modules: ${enable_test_modules}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200300])