blob: 5b484d6088db43de89f768c724ec41e976b07066 [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 Marchi18811d22013-08-22 10:44:08 -03003 [15],
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
Gustavo Sverzut Barbieri3d8226e2011-12-16 16:08:53 -020039
Lucas De Marchi3ef72082012-03-17 10:26:32 -030040
41#####################################################################
42# Function and structure checks
43#####################################################################
44
Lucas De Marchid005aeb2012-02-08 20:29:52 -020045AC_CHECK_FUNCS_ONCE(__xstat)
Cristian Rodríguez41a51c22013-02-11 15:07:52 -030046AC_CHECK_FUNCS_ONCE([__secure_getenv secure_getenv])
Lucas De Marchi55112d12013-04-09 04:16:57 -030047AC_CHECK_FUNCS_ONCE([finit_module])
Lucas De Marchid005aeb2012-02-08 20:29:52 -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
Kees Cook144d1822013-02-18 12:02:32 -080052# Check kernel headers
53AC_CHECK_HEADERS_ONCE([linux/module.h])
54
Thomas Petazzonidc8ed092013-09-06 15:27:04 +020055AC_MSG_CHECKING([whether _Static_assert() is supported])
56AC_COMPILE_IFELSE(
57 [AC_LANG_SOURCE([[_Static_assert(1, "Test");]])],
58 [AC_DEFINE([HAVE_STATIC_ASSERT], [1], [Define if _Static_assert() is available])
59 AC_MSG_RESULT([yes])],
60 [AC_MSG_RESULT([no])])
Lucas De Marchi3ef72082012-03-17 10:26:32 -030061
62#####################################################################
63# --with-
64#####################################################################
65
Kay Sieverse79bf832011-12-22 15:40:24 +010066AC_ARG_WITH([rootlibdir],
67 AS_HELP_STRING([--with-rootlibdir=DIR], [rootfs directory to install shared libraries]),
68 [], [with_rootlibdir=$libdir])
69AC_SUBST([rootlibdir], [$with_rootlibdir])
70
Jan Engelhardtb182f8f2011-12-24 14:58:30 +010071AC_ARG_WITH([xz],
72 AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]),
73 [], [with_xz=no])
74AS_IF([test "x$with_xz" != "xno"], [
75 PKG_CHECK_MODULES([liblzma], [liblzma >= 4.99])
76 AC_DEFINE([ENABLE_XZ], [1], [Enable Xz for modules.])
77], [
78 AC_MSG_NOTICE([Xz support not requested])
79])
80
Jan Engelhardt5a51a352011-12-24 04:45:42 +010081AC_ARG_WITH([zlib],
82 AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]),
83 [], [with_zlib=no])
84AS_IF([test "x$with_zlib" != "xno"], [
Jan Engelhardt7b3a74f2011-12-24 04:45:22 +010085 PKG_CHECK_MODULES([zlib], [zlib])
86 AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.])
Lucas De Marchicfb908b2011-12-23 12:03:19 -020087], [
88 AC_MSG_NOTICE([zlib support not requested])
Lucas De Marchicfb908b2011-12-23 12:03:19 -020089])
Gustavo Sverzut Barbieri3d8226e2011-12-16 16:08:53 -020090
Lucas De Marchi80cf2c82013-07-30 03:47:19 -030091AC_ARG_WITH([bashcompletiondir],
92 AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
93 [],
94 [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
95 with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
96 ] , [
97 with_bashcompletiondir=${datadir}/bash-completion/completions
98 ])])
99AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300100
101#####################################################################
102# --enable-
103#####################################################################
104
105AC_ARG_ENABLE([tools],
106 AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
107 [], enable_tools=yes)
108AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
109
Colin Walters86315522012-07-30 12:27:10 -0400110AC_ARG_ENABLE([manpages],
111 AS_HELP_STRING([--disable-manpages], [disable manpages @<:@default=enabled@:>@]),
112 [], enable_manpages=yes)
113AM_CONDITIONAL([BUILD_MANPAGES], [test "x$enable_manpages" = "xyes"])
Sami Kerola5c61b142012-10-22 18:40:02 +0100114AC_PATH_PROG([XSLTPROC], [xsltproc], [no])
Lucas De Marchicaaf4382012-10-23 10:45:10 -0200115AS_IF([test "x$XSLTPROC" = "xno" && test "x$enable_manpages" = "xyes"], [
Sami Kerola5c61b142012-10-22 18:40:02 +0100116 AC_MSG_ERROR([xsltproc command not found, try ./configure --disable-manpages])
Lucas De Marchicaaf4382012-10-23 10:45:10 -0200117])
Colin Walters86315522012-07-30 12:27:10 -0400118
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300119AC_ARG_ENABLE([logging],
120 AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
121 [], enable_logging=yes)
122AS_IF([test "x$enable_logging" = "xyes"], [
123 AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
124])
125
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200126AC_ARG_ENABLE([debug],
127 AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
128 [], [enable_debug=no])
129AS_IF([test "x$enable_debug" = "xyes"], [
130 AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
131])
132
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300133m4_ifdef([GTK_DOC_CHECK], [
134GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
135], [
136AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
137
138
139#####################################################################
140# Default CFLAGS and LDFLAGS
141#####################################################################
Lucas De Marchi6068aaa2012-01-17 12:10:42 -0200142
Lucas De Marchie48f3762012-03-17 15:12:44 -0300143CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
144 -pipe \
145 -DANOTHER_BRICK_IN_THE \
146 -Wall \
147 -W \
148 -Wextra \
149 -Wno-inline \
150 -Wvla \
151 -Wundef \
152 -Wformat=2 \
153 -Wlogical-op \
154 -Wsign-compare \
155 -Wformat-security \
156 -Wmissing-include-dirs \
157 -Wformat-nonliteral \
158 -Wold-style-definition \
159 -Wpointer-arith \
160 -Winit-self \
161 -Wdeclaration-after-statement \
162 -Wfloat-equal \
163 -Wmissing-prototypes \
164 -Wstrict-prototypes \
165 -Wredundant-decls \
166 -Wmissing-declarations \
167 -Wmissing-noreturn \
168 -Wshadow \
169 -Wendif-labels \
170 -Wstrict-aliasing=2 \
171 -Wwrite-strings \
172 -Wno-long-long \
173 -Wno-overlength-strings \
174 -Wno-unused-parameter \
175 -Wno-missing-field-initializers \
176 -Wno-unused-result \
177 -Wnested-externs \
178 -Wchar-subscripts \
179 -Wtype-limits \
180 -Wuninitialized \
181 -fno-common \
182 -fdiagnostics-show-option \
Lucas De Marchib3e0a072013-10-26 02:51:05 -0200183 -fdiagnostics-color=auto \
Lucas De Marchie48f3762012-03-17 15:12:44 -0300184 -fvisibility=hidden \
185 -ffunction-sections \
186 -fdata-sections])
187AC_SUBST([WARNINGFLAGS], $with_cflags)
Randy Witt1701b1b2012-03-16 01:01:18 -0400188
Gustavo Sverzut Barbieri822ce232011-12-10 22:26:40 -0200189
Lucas De Marchie48f3762012-03-17 15:12:44 -0300190CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
191 -Wl,--as-needed \
192 -Wl,--gc-sections])
193AC_SUBST([GCLDFLAGS], $with_ldflags)
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300194
195#####################################################################
196# Generate files from *.in
197#####################################################################
198
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200199AC_CONFIG_HEADERS(config.h)
200AC_CONFIG_FILES([
201 Makefile
Lucas De Marchi904b57d2012-01-12 11:48:21 -0200202 man/Makefile
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200203 libkmod/docs/Makefile
204 libkmod/docs/version.xml
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200205])
206
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300207
208#####################################################################
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200209
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200210AC_OUTPUT
211AC_MSG_RESULT([
212 $PACKAGE $VERSION
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300213 =======
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200214
215 prefix: ${prefix}
216 sysconfdir: ${sysconfdir}
217 libdir: ${libdir}
Kay Sieverse79bf832011-12-22 15:40:24 +0100218 rootlibdir: ${rootlibdir}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200219 includedir: ${includedir}
Lucas De Marchi7c41c2d2011-12-12 13:39:07 -0200220 bindir: ${bindir}
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300221 Bash completions dir: ${with_bashcompletiondir}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200222
223 compiler: ${CC}
Lucas De Marchie48f3762012-03-17 15:12:44 -0300224 cflags: ${with_cflags} ${CFLAGS}
225 ldflags: ${with_ldflags} ${LDFLAGS}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200226
Lucas De Marchi7c41c2d2011-12-12 13:39:07 -0200227 tools: ${enable_tools}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200228 logging: ${enable_logging}
Jan Engelhardtb182f8f2011-12-24 14:58:30 +0100229 compression: xz=${with_xz} zlib=${with_zlib}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200230 debug: ${enable_debug}
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200231 doc: ${enable_gtk_doc}
Lucas De Marchi382de852012-07-31 09:51:48 -0300232 man: ${enable_manpages}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200233])