blob: 54a52eaec9134c20262cb47f057384f81466f9fd [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 Marchi36c4bb92013-12-22 19:45:19 -02003 [16],
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 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
Kees Cook144d1822013-02-18 12:02:32 -080053# Check kernel headers
54AC_CHECK_HEADERS_ONCE([linux/module.h])
55
Thomas Petazzonidc8ed092013-09-06 15:27:04 +020056AC_MSG_CHECKING([whether _Static_assert() is supported])
57AC_COMPILE_IFELSE(
58 [AC_LANG_SOURCE([[_Static_assert(1, "Test");]])],
59 [AC_DEFINE([HAVE_STATIC_ASSERT], [1], [Define if _Static_assert() is available])
60 AC_MSG_RESULT([yes])],
61 [AC_MSG_RESULT([no])])
Lucas De Marchi3ef72082012-03-17 10:26:32 -030062
63#####################################################################
64# --with-
65#####################################################################
66
Kay Sieverse79bf832011-12-22 15:40:24 +010067AC_ARG_WITH([rootlibdir],
68 AS_HELP_STRING([--with-rootlibdir=DIR], [rootfs directory to install shared libraries]),
69 [], [with_rootlibdir=$libdir])
70AC_SUBST([rootlibdir], [$with_rootlibdir])
71
Jan Engelhardtb182f8f2011-12-24 14:58:30 +010072AC_ARG_WITH([xz],
73 AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]),
74 [], [with_xz=no])
75AS_IF([test "x$with_xz" != "xno"], [
76 PKG_CHECK_MODULES([liblzma], [liblzma >= 4.99])
77 AC_DEFINE([ENABLE_XZ], [1], [Enable Xz for modules.])
78], [
79 AC_MSG_NOTICE([Xz support not requested])
80])
81
Jan Engelhardt5a51a352011-12-24 04:45:42 +010082AC_ARG_WITH([zlib],
83 AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]),
84 [], [with_zlib=no])
85AS_IF([test "x$with_zlib" != "xno"], [
Jan Engelhardt7b3a74f2011-12-24 04:45:22 +010086 PKG_CHECK_MODULES([zlib], [zlib])
87 AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.])
Lucas De Marchicfb908b2011-12-23 12:03:19 -020088], [
89 AC_MSG_NOTICE([zlib support not requested])
Lucas De Marchicfb908b2011-12-23 12:03:19 -020090])
Gustavo Sverzut Barbieri3d8226e2011-12-16 16:08:53 -020091
Lucas De Marchi80cf2c82013-07-30 03:47:19 -030092AC_ARG_WITH([bashcompletiondir],
93 AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
94 [],
95 [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
96 with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
97 ] , [
98 with_bashcompletiondir=${datadir}/bash-completion/completions
99 ])])
100AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300101
102#####################################################################
103# --enable-
104#####################################################################
105
106AC_ARG_ENABLE([tools],
107 AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
108 [], enable_tools=yes)
109AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
110
Colin Walters86315522012-07-30 12:27:10 -0400111AC_ARG_ENABLE([manpages],
112 AS_HELP_STRING([--disable-manpages], [disable manpages @<:@default=enabled@:>@]),
113 [], enable_manpages=yes)
114AM_CONDITIONAL([BUILD_MANPAGES], [test "x$enable_manpages" = "xyes"])
Lucas De Marchibccb4b22014-02-24 10:52:58 -0300115AS_IF(["x$enable_manpages" != "xno"], ["have_manpages=yes"])
Colin Walters86315522012-07-30 12:27:10 -0400116
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300117AC_ARG_ENABLE([logging],
118 AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
119 [], enable_logging=yes)
120AS_IF([test "x$enable_logging" = "xyes"], [
121 AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
122])
123
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200124AC_ARG_ENABLE([debug],
125 AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
126 [], [enable_debug=no])
127AS_IF([test "x$enable_debug" = "xyes"], [
128 AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
129])
130
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300131m4_ifdef([GTK_DOC_CHECK], [
132GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
133], [
134AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
135
136
137#####################################################################
138# Default CFLAGS and LDFLAGS
139#####################################################################
Lucas De Marchi6068aaa2012-01-17 12:10:42 -0200140
Lucas De Marchie48f3762012-03-17 15:12:44 -0300141CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
142 -pipe \
143 -DANOTHER_BRICK_IN_THE \
144 -Wall \
145 -W \
146 -Wextra \
147 -Wno-inline \
148 -Wvla \
149 -Wundef \
150 -Wformat=2 \
151 -Wlogical-op \
152 -Wsign-compare \
153 -Wformat-security \
154 -Wmissing-include-dirs \
155 -Wformat-nonliteral \
156 -Wold-style-definition \
157 -Wpointer-arith \
158 -Winit-self \
159 -Wdeclaration-after-statement \
160 -Wfloat-equal \
161 -Wmissing-prototypes \
162 -Wstrict-prototypes \
163 -Wredundant-decls \
164 -Wmissing-declarations \
165 -Wmissing-noreturn \
166 -Wshadow \
167 -Wendif-labels \
168 -Wstrict-aliasing=2 \
169 -Wwrite-strings \
170 -Wno-long-long \
171 -Wno-overlength-strings \
172 -Wno-unused-parameter \
173 -Wno-missing-field-initializers \
174 -Wno-unused-result \
175 -Wnested-externs \
176 -Wchar-subscripts \
177 -Wtype-limits \
178 -Wuninitialized \
179 -fno-common \
180 -fdiagnostics-show-option \
Lucas De Marchib3e0a072013-10-26 02:51:05 -0200181 -fdiagnostics-color=auto \
Lucas De Marchie48f3762012-03-17 15:12:44 -0300182 -fvisibility=hidden \
183 -ffunction-sections \
184 -fdata-sections])
185AC_SUBST([WARNINGFLAGS], $with_cflags)
Randy Witt1701b1b2012-03-16 01:01:18 -0400186
Gustavo Sverzut Barbieri822ce232011-12-10 22:26:40 -0200187
Lucas De Marchie48f3762012-03-17 15:12:44 -0300188CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
189 -Wl,--as-needed \
190 -Wl,--gc-sections])
191AC_SUBST([GCLDFLAGS], $with_ldflags)
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300192
193#####################################################################
194# Generate files from *.in
195#####################################################################
196
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200197AC_CONFIG_HEADERS(config.h)
198AC_CONFIG_FILES([
199 Makefile
Lucas De Marchi904b57d2012-01-12 11:48:21 -0200200 man/Makefile
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200201 libkmod/docs/Makefile
202 libkmod/docs/version.xml
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200203])
204
Lucas De Marchi3ef72082012-03-17 10:26:32 -0300205
206#####################################################################
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200207
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200208AC_OUTPUT
209AC_MSG_RESULT([
210 $PACKAGE $VERSION
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300211 =======
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200212
213 prefix: ${prefix}
214 sysconfdir: ${sysconfdir}
215 libdir: ${libdir}
Kay Sieverse79bf832011-12-22 15:40:24 +0100216 rootlibdir: ${rootlibdir}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200217 includedir: ${includedir}
Lucas De Marchi7c41c2d2011-12-12 13:39:07 -0200218 bindir: ${bindir}
Lucas De Marchi80cf2c82013-07-30 03:47:19 -0300219 Bash completions dir: ${with_bashcompletiondir}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200220
221 compiler: ${CC}
Lucas De Marchie48f3762012-03-17 15:12:44 -0300222 cflags: ${with_cflags} ${CFLAGS}
223 ldflags: ${with_ldflags} ${LDFLAGS}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200224
Lucas De Marchi7c41c2d2011-12-12 13:39:07 -0200225 tools: ${enable_tools}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200226 logging: ${enable_logging}
Jan Engelhardtb182f8f2011-12-24 14:58:30 +0100227 compression: xz=${with_xz} zlib=${with_zlib}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200228 debug: ${enable_debug}
Lucas De Marchi646b83b2012-01-09 04:20:55 -0200229 doc: ${enable_gtk_doc}
Lucas De Marchi382de852012-07-31 09:51:48 -0300230 man: ${enable_manpages}
Lucas De Marchiecd40ee2011-11-21 12:35:15 -0200231])