build-sys: use AS_IF autoconf macro
[platform/upstream/kmod.git] / configure.ac
1 AC_PREREQ(2.60)
2 AC_INIT([kmod],
3         [10],
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])
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
21 #####################################################################
22 # Program checks and configurations
23 #####################################################################
24
25 AC_PROG_CC
26 AC_PROG_CC_C99
27 AC_C_TYPEOF
28 AM_PROG_CC_C_O
29 AC_PROG_GCC_TRADITIONAL
30 AC_C_BIGENDIAN
31
32 AC_PROG_SED
33 AC_PROG_MKDIR_P
34 PKG_PROG_PKG_CONFIG
35
36
37 #####################################################################
38 # Function and structure checks
39 #####################################################################
40
41 AC_CHECK_FUNCS_ONCE(__xstat)
42
43 # dietlibc doesn't have st.st_mtim struct member
44 AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
45
46
47 #####################################################################
48 # --with-
49 #####################################################################
50
51 AC_ARG_WITH([rootlibdir],
52         AS_HELP_STRING([--with-rootlibdir=DIR], [rootfs directory to install shared libraries]),
53         [], [with_rootlibdir=$libdir])
54 AC_SUBST([rootlibdir], [$with_rootlibdir])
55
56 AC_ARG_WITH([xz],
57         AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]),
58         [], [with_xz=no])
59 AS_IF([test "x$with_xz" != "xno"], [
60         PKG_CHECK_MODULES([liblzma], [liblzma >= 4.99])
61         AC_DEFINE([ENABLE_XZ], [1], [Enable Xz for modules.])
62 ], [
63         AC_MSG_NOTICE([Xz support not requested])
64 ])
65
66 AC_ARG_WITH([zlib],
67         AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]),
68         [], [with_zlib=no])
69 AS_IF([test "x$with_zlib" != "xno"], [
70         PKG_CHECK_MODULES([zlib], [zlib])
71         AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.])
72 ], [
73         AC_MSG_NOTICE([zlib support not requested])
74 ])
75
76
77 #####################################################################
78 # --enable-
79 #####################################################################
80
81 AC_ARG_ENABLE([tools],
82         AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
83         [], enable_tools=yes)
84 AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
85
86 AC_ARG_ENABLE([manpages],
87         AS_HELP_STRING([--disable-manpages], [disable manpages @<:@default=enabled@:>@]),
88         [], enable_manpages=yes)
89 AM_CONDITIONAL([BUILD_MANPAGES], [test "x$enable_manpages" = "xyes"])
90 AC_PATH_PROG([XSLTPROC], [xsltproc], [no])
91 AS_IF([test "x$XSLTPROC" = "xno" && test "x$enable_manpages" = "xyes"], [
92         AC_MSG_ERROR([xsltproc command not found, try ./configure --disable-manpages])
93 ])
94
95 AC_ARG_ENABLE([logging],
96         AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
97         [], enable_logging=yes)
98 AS_IF([test "x$enable_logging" = "xyes"], [
99         AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
100 ])
101
102 AC_ARG_ENABLE([debug],
103         AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
104         [], [enable_debug=no])
105 AS_IF([test "x$enable_debug" = "xyes"], [
106         AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
107 ])
108
109 m4_ifdef([GTK_DOC_CHECK], [
110 GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
111 ], [
112 AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
113
114
115 #####################################################################
116 # Default CFLAGS and LDFLAGS
117 #####################################################################
118
119 CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
120                        -pipe \
121                        -DANOTHER_BRICK_IN_THE \
122                        -Wall \
123                        -W \
124                        -Wextra \
125                        -Wno-inline \
126                        -Wvla \
127                        -Wundef \
128                        -Wformat=2 \
129                        -Wlogical-op \
130                        -Wsign-compare \
131                        -Wformat-security \
132                        -Wmissing-include-dirs \
133                        -Wformat-nonliteral \
134                        -Wold-style-definition \
135                        -Wpointer-arith \
136                        -Winit-self \
137                        -Wdeclaration-after-statement \
138                        -Wfloat-equal \
139                        -Wmissing-prototypes \
140                        -Wstrict-prototypes \
141                        -Wredundant-decls \
142                        -Wmissing-declarations \
143                        -Wmissing-noreturn \
144                        -Wshadow \
145                        -Wendif-labels \
146                        -Wstrict-aliasing=2 \
147                        -Wwrite-strings \
148                        -Wno-long-long \
149                        -Wno-overlength-strings \
150                        -Wno-unused-parameter \
151                        -Wno-missing-field-initializers \
152                        -Wno-unused-result \
153                        -Wnested-externs \
154                        -Wchar-subscripts \
155                        -Wtype-limits \
156                        -Wuninitialized \
157                        -fno-common \
158                        -fdiagnostics-show-option \
159                        -fvisibility=hidden \
160                        -ffunction-sections \
161                        -fdata-sections])
162 AC_SUBST([WARNINGFLAGS], $with_cflags)
163
164
165 CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
166                        -Wl,--as-needed \
167                        -Wl,--gc-sections])
168 AC_SUBST([GCLDFLAGS], $with_ldflags)
169
170 #####################################################################
171 # Generate files from *.in
172 #####################################################################
173
174 AC_CONFIG_HEADERS(config.h)
175 AC_CONFIG_FILES([
176         Makefile
177         man/Makefile
178         libkmod/docs/Makefile
179         libkmod/docs/version.xml
180 ])
181
182
183 #####################################################################
184
185 AC_OUTPUT
186 AC_MSG_RESULT([
187         $PACKAGE $VERSION
188         ======
189
190         prefix:                 ${prefix}
191         sysconfdir:             ${sysconfdir}
192         libdir:                 ${libdir}
193         rootlibdir:             ${rootlibdir}
194         includedir:             ${includedir}
195         bindir:                 ${bindir}
196
197         compiler:               ${CC}
198         cflags:                 ${with_cflags} ${CFLAGS}
199         ldflags:                ${with_ldflags} ${LDFLAGS}
200
201         tools:                  ${enable_tools}
202         logging:                ${enable_logging}
203         compression:            xz=${with_xz}  zlib=${with_zlib}
204         debug:                  ${enable_debug}
205         doc:                    ${enable_gtk_doc}
206         man:                    ${enable_manpages}
207 ])