]> git.ipfire.org Git - thirdparty/kmod.git/blame - configure.ac
build: define to 0 if builtin is not available
[thirdparty/kmod.git] / configure.ac
CommitLineData
ecd40ee4 1AC_PREREQ(2.60)
cb48c9b2 2AC_INIT([kmod],
f9e2167b 3 [19],
e17cc3af 4 [linux-modules@vger.kernel.org],
cb48c9b2 5 [kmod],
bb05bc8a 6 [http://git.kernel.org/?p=utils/kernel/kmod/kmod.git])
586fc304
LDM
7
8AC_CONFIG_SRCDIR([libkmod/libkmod.c])
ecd40ee4 9AC_CONFIG_AUX_DIR([build-aux])
a597c8bb 10AM_INIT_AUTOMAKE([check-news foreign 1.11 silent-rules
8edd5bb2 11 tar-pax no-dist-gzip dist-xz subdir-objects color-tests parallel-tests])
ecd40ee4
LDM
12AC_PROG_CC_STDC
13AC_USE_SYSTEM_EXTENSIONS
14AC_SYS_LARGEFILE
15AC_CONFIG_MACRO_DIR([m4])
fe8bf3b0 16m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
ecd40ee4
LDM
17AM_SILENT_RULES([yes])
18LT_INIT([disable-static pic-only])
19AC_PREFIX_DEFAULT([/usr])
f5cc26c7 20AM_MAINTAINER_MODE([enable])
ecd40ee4 21
b7016153
LDM
22AS_IF([test "x$enable_static" = "xyes"],
23 [AC_MSG_ERROR([--enable-static is not supported by kmod])])
24
25
3ef7208e
LDM
26#####################################################################
27# Program checks and configurations
28#####################################################################
29
648a842b
LDM
30AC_PROG_CC
31AC_PROG_CC_C99
648a842b
LDM
32AM_PROG_CC_C_O
33AC_PROG_GCC_TRADITIONAL
708624a4 34AC_C_BIGENDIAN
648a842b 35
9faa7b37
KS
36AC_PROG_SED
37AC_PROG_MKDIR_P
7b3a74fc 38PKG_PROG_PKG_CONFIG
bccb4b25 39AC_PATH_PROG([XSLTPROC], [xsltproc])
3d8226ed 40
3ef7208e
LDM
41
42#####################################################################
43# Function and structure checks
44#####################################################################
45
d005aeb7 46AC_CHECK_FUNCS_ONCE(__xstat)
41a51c2a 47AC_CHECK_FUNCS_ONCE([__secure_getenv secure_getenv])
55112d19 48AC_CHECK_FUNCS_ONCE([finit_module])
d005aeb7 49
e6307200
LDM
50CC_CHECK_FUNC_BUILTIN([__builtin_clz])
51CC_CHECK_FUNC_BUILTIN([__builtin_types_compatible_p])
52
3ef7208e
LDM
53# dietlibc doesn't have st.st_mtim struct member
54AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
55
04c0956e
LDM
56# musl 1.0 and bionic 4.4 don't have strndupa
57AC_CHECK_DECLS_ONCE([strndupa])
58
9b34db1a
RM
59# RHEL 5 and older do not have be32toh
60AC_CHECK_DECLS_ONCE([be32toh])
61
144d1826
KC
62# Check kernel headers
63AC_CHECK_HEADERS_ONCE([linux/module.h])
64
dc8ed09f
TP
65AC_MSG_CHECKING([whether _Static_assert() is supported])
66AC_COMPILE_IFELSE(
67 [AC_LANG_SOURCE([[_Static_assert(1, "Test");]])],
68 [AC_DEFINE([HAVE_STATIC_ASSERT], [1], [Define if _Static_assert() is available])
69 AC_MSG_RESULT([yes])],
70 [AC_MSG_RESULT([no])])
3ef7208e
LDM
71
72#####################################################################
73# --with-
74#####################################################################
75
e79bf83b
KS
76AC_ARG_WITH([rootlibdir],
77 AS_HELP_STRING([--with-rootlibdir=DIR], [rootfs directory to install shared libraries]),
78 [], [with_rootlibdir=$libdir])
79AC_SUBST([rootlibdir], [$with_rootlibdir])
80
b182f8fb
JE
81AC_ARG_WITH([xz],
82 AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]),
83 [], [with_xz=no])
84AS_IF([test "x$with_xz" != "xno"], [
85 PKG_CHECK_MODULES([liblzma], [liblzma >= 4.99])
86 AC_DEFINE([ENABLE_XZ], [1], [Enable Xz for modules.])
87], [
88 AC_MSG_NOTICE([Xz support not requested])
89])
90
5a51a357
JE
91AC_ARG_WITH([zlib],
92 AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]),
93 [], [with_zlib=no])
94AS_IF([test "x$with_zlib" != "xno"], [
7b3a74fc
JE
95 PKG_CHECK_MODULES([zlib], [zlib])
96 AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.])
cfb908bf
LDM
97], [
98 AC_MSG_NOTICE([zlib support not requested])
cfb908bf 99])
3d8226ed 100
80cf2c8f
LDM
101AC_ARG_WITH([bashcompletiondir],
102 AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
103 [],
104 [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
105 with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
106 ] , [
107 with_bashcompletiondir=${datadir}/bash-completion/completions
108 ])])
109AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
3ef7208e
LDM
110
111#####################################################################
112# --enable-
113#####################################################################
114
115AC_ARG_ENABLE([tools],
116 AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
117 [], enable_tools=yes)
118AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
119
8631552d
CW
120AC_ARG_ENABLE([manpages],
121 AS_HELP_STRING([--disable-manpages], [disable manpages @<:@default=enabled@:>@]),
122 [], enable_manpages=yes)
123AM_CONDITIONAL([BUILD_MANPAGES], [test "x$enable_manpages" = "xyes"])
124
3ef7208e
LDM
125AC_ARG_ENABLE([logging],
126 AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
127 [], enable_logging=yes)
128AS_IF([test "x$enable_logging" = "xyes"], [
129 AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
130])
131
ecd40ee4
LDM
132AC_ARG_ENABLE([debug],
133 AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
134 [], [enable_debug=no])
135AS_IF([test "x$enable_debug" = "xyes"], [
136 AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
137])
138
3a33a7a5
LDM
139AC_ARG_ENABLE([python],
140 AS_HELP_STRING([--enable-python], [enable Python libkmod bindings @<:@default=disabled@:>@]),
141 [], [enable_python=no])
142AS_IF([test "x$enable_python" = "xyes"], [
143 AM_PATH_PYTHON(,,[:])
144 AC_PATH_PROG([CYTHON], [cython], [:])
145
146 PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}],
147 [have_python=yes],
148 [PKG_CHECK_MODULES([PYTHON], [python],
149 [have_python=yes],
150 [have_python=no])])
151
152 AS_IF([test "x$have_python" = xno],
153 [AC_MSG_ERROR([*** python support requested but libraries not found])])
154])
155AM_CONDITIONAL([BUILD_PYTHON], [test "x$enable_python" = "xyes"])
156
e9b0d1b4
LDM
157AC_ARG_ENABLE([coverage],
158 AS_HELP_STRING([--enable-coverage], [enable test coverage @<:@default=disabled@:>@]),
159 [], [enable_coverage=no])
160AS_IF([test "x$enable_coverage" = "xyes"], [
161 AC_CHECK_PROG(have_coverage, [lcov], [yes], [no])
162 AS_IF([test "x$have_coverage" = xno],[
163 AC_MSG_ERROR([*** lcov support requested but the program was not found])
164 ], [
165 lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
166 lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
167 AS_IF([test "$lcov_version_major" -lt 1 -o "$lcov_version_minor" -lt 10], [
168 AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
169 ], [
170 have_coverage=yes
171 CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
172 -fprofile-arcs \
173 -ftest-coverage])
174 ])
175 ])
176])
177AM_CONDITIONAL([ENABLE_COVERAGE], [test "x$enable_coverage" = "xyes"])
178
3ef7208e
LDM
179m4_ifdef([GTK_DOC_CHECK], [
180GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
181], [
182AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
183
184
185#####################################################################
186# Default CFLAGS and LDFLAGS
187#####################################################################
6068aaae 188
e48f3765
LDM
189CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
190 -pipe \
191 -DANOTHER_BRICK_IN_THE \
192 -Wall \
193 -W \
194 -Wextra \
195 -Wno-inline \
196 -Wvla \
197 -Wundef \
198 -Wformat=2 \
199 -Wlogical-op \
200 -Wsign-compare \
201 -Wformat-security \
202 -Wmissing-include-dirs \
203 -Wformat-nonliteral \
204 -Wold-style-definition \
205 -Wpointer-arith \
206 -Winit-self \
207 -Wdeclaration-after-statement \
208 -Wfloat-equal \
209 -Wmissing-prototypes \
210 -Wstrict-prototypes \
211 -Wredundant-decls \
212 -Wmissing-declarations \
213 -Wmissing-noreturn \
214 -Wshadow \
215 -Wendif-labels \
db62153e 216 -Wstrict-aliasing=3 \
e48f3765
LDM
217 -Wwrite-strings \
218 -Wno-long-long \
219 -Wno-overlength-strings \
220 -Wno-unused-parameter \
221 -Wno-missing-field-initializers \
222 -Wno-unused-result \
223 -Wnested-externs \
224 -Wchar-subscripts \
225 -Wtype-limits \
226 -Wuninitialized \
227 -fno-common \
228 -fdiagnostics-show-option \
229 -fvisibility=hidden \
230 -ffunction-sections \
231 -fdata-sections])
27bcc911 232AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
e48f3765 233
c677bf2c 234
e48f3765
LDM
235CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
236 -Wl,--as-needed \
a5f799af 237 -Wl,--no-undefined \
e48f3765 238 -Wl,--gc-sections])
84aaaedf 239AC_SUBST([OUR_LDFLAGS], $with_ldflags)
3ef7208e
LDM
240
241#####################################################################
242# Generate files from *.in
243#####################################################################
244
ecd40ee4
LDM
245AC_CONFIG_HEADERS(config.h)
246AC_CONFIG_FILES([
247 Makefile
904b57d0 248 man/Makefile
646b83b8
LDM
249 libkmod/docs/Makefile
250 libkmod/docs/version.xml
ecd40ee4
LDM
251])
252
3ef7208e
LDM
253
254#####################################################################
646b83b8 255
ecd40ee4
LDM
256AC_OUTPUT
257AC_MSG_RESULT([
258 $PACKAGE $VERSION
80cf2c8f 259 =======
ecd40ee4
LDM
260
261 prefix: ${prefix}
262 sysconfdir: ${sysconfdir}
263 libdir: ${libdir}
e79bf83b 264 rootlibdir: ${rootlibdir}
ecd40ee4 265 includedir: ${includedir}
7c41c2dd 266 bindir: ${bindir}
80cf2c8f 267 Bash completions dir: ${with_bashcompletiondir}
ecd40ee4
LDM
268
269 compiler: ${CC}
e48f3765
LDM
270 cflags: ${with_cflags} ${CFLAGS}
271 ldflags: ${with_ldflags} ${LDFLAGS}
ecd40ee4 272
7c41c2dd 273 tools: ${enable_tools}
3a33a7a5 274 python bindings: ${enable_python}
ecd40ee4 275 logging: ${enable_logging}
b182f8fb 276 compression: xz=${with_xz} zlib=${with_zlib}
ecd40ee4 277 debug: ${enable_debug}
e9b0d1b4 278 coverage: ${enable_coverage}
646b83b8 279 doc: ${enable_gtk_doc}
382de85c 280 man: ${enable_manpages}
ecd40ee4 281])