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