implement zlib module loading.
[platform/upstream/kmod.git] / configure.ac
1 AC_PREREQ(2.60)
2 AC_INIT([kmod],
3         [1],
4         [linux-modules@vger.kernel.org],
5         [kmod],
6         [http://git.profusion.mobi/cgit.cgi/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 tar-pax dist-bzip2 subdir-objects])
11 AC_PROG_CC_STDC
12 AC_USE_SYSTEM_EXTENSIONS
13 AC_SYS_LARGEFILE
14 AC_CONFIG_MACRO_DIR([m4])
15 m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
16 AM_SILENT_RULES([yes])
17 LT_INIT([disable-static pic-only])
18 AC_PREFIX_DEFAULT([/usr])
19
20 AC_PROG_CC
21 AC_PROG_CC_C99
22 AC_C_TYPEOF
23 AM_PROG_CC_C_O
24 AC_PROG_GCC_TRADITIONAL
25
26 required_private_libs=""
27
28 AC_ARG_ENABLE([tools],
29         AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]),
30         [], enable_tools=yes)
31 AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
32
33 AC_ARG_ENABLE([logging],
34         AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
35         [], enable_logging=yes)
36 AS_IF([test "x$enable_logging" = "xyes"], [
37         AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
38 ])
39
40 AC_ARG_ENABLE([zlib],
41         AS_HELP_STRING([--enable-zlib], [handle gzipped modules (options: static or dynamic) @<:@default=disabled@:>@]),
42         [], enable_zlib=no)
43 if test "x$enable_zlib" = "xyes" -o "x$enable_zlib" = "xstatic"; then
44         enable_zlib="static"
45         zlib_libs="-Wl,-Bstatic -lz -Wl,-Bdynamic"
46         SAVE_LIBS="${LIBS}"
47         LIBS="${LIBS} ${zlib_libs}"
48         AC_MSG_CHECKING([if static zlib exists])
49         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
50                 #include <zlib.h>
51         ]], [[
52                 gzFile f = gzopen("/tmp", "rb");
53         ]])],
54         [have_zlib=yes], [have_zlib=no])
55         LIBS="${SAVE_LIBS}"
56         AC_MSG_RESULT([$have_zlib])
57         if test "x$have_zlib" != "xyes"; then
58                 zlib_libs=""
59                 AC_MSG_ERROR([static zlib is not present])
60         fi
61 elif test "x$enable_zlib" = "xdynamic"; then
62         AC_CHECK_LIB([z], [gzopen],
63                 [
64                         zlib_libs="-lz"
65                         required_private_libs="${required_private_libs} ${zlib_libs}"
66                 ],
67                 [AC_MSG_ERROR([dynamic zlib is not present])])
68 else
69         AC_MSG_NOTICE([zlib support not requested])
70         zlib_libs=""
71 fi
72 if test "x$zlib_libs" != "x"; then
73         AC_DEFINE(ENABLE_ZLIB, [1], [Enable zlib for modules.])
74 fi
75 AC_SUBST(zlib_libs)
76
77 AC_ARG_ENABLE([debug],
78         AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
79         [], [enable_debug=no])
80 AS_IF([test "x$enable_debug" = "xyes"], [
81         AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
82 ])
83
84 CC_CHECK_CFLAGS_APPEND([ \
85                         -pipe \
86                         -Wall \
87                         -W \
88                         -Wextra \
89                         -Wno-inline \
90                         -Wvla \
91                         -Wundef \
92                         -Wformat=2 \
93                         -Wlogical-op \
94                         -Wsign-compare \
95                         -Wformat-security \
96                         -Wmissing-include-dirs \
97                         -Wformat-nonliteral \
98                         -Wold-style-definition \
99                         -Wpointer-arith \
100                         -Winit-self \
101                         -Wdeclaration-after-statement \
102                         -Wfloat-equal \
103                         -Wmissing-prototypes \
104                         -Wstrict-prototypes \
105                         -Wredundant-decls \
106                         -Wmissing-declarations \
107                         -Wmissing-noreturn \
108                         -Wshadow \
109                         -Wendif-labels \
110                         -Wcast-align \
111                         -Wstrict-aliasing=2 \
112                         -Wwrite-strings \
113                         -Wno-long-long \
114                         -Wno-overlength-strings \
115                         -Wno-unused-parameter \
116                         -Wno-missing-field-initializers \
117                         -Wno-unused-result \
118                         -Wnested-externs \
119                         -Wchar-subscripts \
120                         -Wtype-limits \
121                         -Wuninitialized \
122                         -Wp,-D_FORTIFY_SOURCE=2 \
123                         -ffast-math \
124                         -fno-common \
125                         -fdiagnostics-show-option \
126                         -fno-strict-aliasing \
127                         -fvisibility=hidden \
128                         -ffunction-sections \
129                         -fdata-sections \
130                         -Wl,--as-needed \
131                         -Wl,--gc-sections])
132
133
134 AC_SUBST(required_private_libs)
135
136 AC_CONFIG_HEADERS(config.h)
137 AC_CONFIG_FILES([
138         Makefile
139         libkmod/libkmod.pc
140 ])
141
142 AC_OUTPUT
143 AC_MSG_RESULT([
144         $PACKAGE $VERSION
145         ========
146
147         prefix:                 ${prefix}
148         sysconfdir:             ${sysconfdir}
149         libdir:                 ${libdir}
150         includedir:             ${includedir}
151         bindir:                 ${bindir}
152
153         compiler:               ${CC}
154         cflags:                 ${CFLAGS}
155         ldflags:                ${LDFLAGS}
156
157         tools:                  ${enable_tools}
158         logging:                ${enable_logging}
159         zlib:                   ${enable_zlib}
160         debug:                  ${enable_debug}
161 ])