acae162dc96cd5de4b84c1e4fac22332c1b0cfdd
[ipset] / configure.ac
1 dnl Boilerplate
2 AC_INIT([ipset], [6.10], [kadlec@blackhole.kfki.hu])
3 AC_CONFIG_AUX_DIR([build-aux])
4 AC_CANONICAL_HOST
5 AC_CONFIG_MACRO_DIR([m4])
6 AC_CONFIG_HEADER([config.h])
7 AM_INIT_AUTOMAKE([foreign subdir-objects])
8
9 dnl Shortcut: Linux supported alone
10 case "$host" in
11 *-*-linux*) ;;
12 *) AC_MSG_ERROR([Linux systems supported exclusively!]);;
13 esac
14
15 dnl Optionnally disable building the kernel module
16 AC_ARG_WITH([kmod],
17             AS_HELP_STRING([--with-kmod=yes/no],
18                            [Build the kernel module (default: yes)]),
19             [BUILDKMOD="$withval";],
20             [BUILDKMOD="yes";])
21 AM_CONDITIONAL(WITH_KMOD, test "$BUILDKMOD" == "yes")
22
23 dnl Additional arguments
24 dnl Kernel build directory or source tree
25 AC_ARG_WITH([kbuild],
26             AS_HELP_STRING([--with-kbuild=PATH],
27                            [Path to kernel build directory]),
28             [KBUILDDIR="$withval";])
29 AC_ARG_WITH([ksource],
30             AS_HELP_STRING([--with-ksource=PATH],
31                            [Path to kernel source directory, if not the same as the kernel build directory]),
32             [KSOURCEDIR="$withval";])
33 AM_CONDITIONAL(WITH_KBUILDDIR, test "$KBUILDDIR" != "")
34 AC_SUBST(KBUILDDIR)
35
36 if test "$BUILDKMOD" == "yes"
37 then
38 dnl Sigh: check kernel version dependencies
39 if test "$KBUILDDIR" != ""
40 then
41         kbuilddir="$KBUILDDIR"
42 else
43         kbuilddir="/lib/modules/`uname -r`/build"
44 fi
45
46 if test -n "$KSOURCEDIR"; then
47         ksourcedir="$KSOURCEDIR"
48 elif test -e "$kbuilddir/include/linux/netfilter/nfnetlink.h"; then
49         ksourcedir="$kbuilddir"
50 else
51         ksourcedir="/lib/modules/$(uname -r)/source"
52 fi
53 if test ! -e "$ksourcedir/include/linux/netfilter/nfnetlink.h"
54 then
55         AC_MSG_ERROR([Invalid kernel source directory $ksourcedir])
56 fi
57
58 if test ! -e "$kbuilddir/.config"
59 then
60         AC_MSG_ERROR([The kernel build directory $kbuilddir is not configured])
61 fi
62
63 AC_PROG_GREP
64
65 if test "X`$GREP 'NFNL_SUBSYS_IPSET' $ksourcedir/include/linux/netfilter/nfnetlink.h`" = "X"
66 then
67         AC_MSG_ERROR([The kernel source directory $ksourcedir is not patched with netlink.patch to support ipset])
68 fi
69 fi
70
71 dnl Maximal number of sets supported by the kernel, default 256
72 AC_ARG_WITH([maxsets],
73             AS_HELP_STRING([--with-maxsets=256],
74                            [Maximal numer of sets supported by the kernel]),
75             [MAXSETS="$withval";])
76 AM_CONDITIONAL(WITH_MAXSETS, test "$MAXSETS" != "")
77 AC_SUBST(MAXSETS)
78
79 dnl Verbose compiling
80 AC_ARG_ENABLE([verbose],
81               AS_HELP_STRING([--enable-verbose],
82                              [Enable verbose mode at compiling/linking.]),
83               [case "${enableval}" in
84                yes)     enable_verbose=yes ;;
85                no)      enable_verbose=no ;;
86                *) AC_MSG_ERROR([bad value ${enableval} for --enable-verbose]) ;;
87                esac], [enable_verbose=no])
88               
89 AM_CONDITIONAL([ENABLE_VERBOSE], [test "x$enable_verbose" = xyes])
90
91 dnl Enable debugging
92 AC_ARG_ENABLE([debug],
93               AS_HELP_STRING([--enable-debug],
94                              [Enable compiling with debug support.]),
95               [case "${enableval}" in
96                yes)     enable_verbose=yes ;;
97                no)      enable_verbose=no ;;
98                *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
99                esac], [enable_debug=no])
100               
101 AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = xyes])
102
103 dnl Checks for programs
104 : ${CFLAGS=""}
105
106 AC_PROG_CC
107 AM_PROG_CC_C_O
108 AC_PROG_LIBTOOL
109 AC_PROG_INSTALL
110 AC_PROG_LN_S
111
112 dnl Checks for libraries
113 PKG_CHECK_MODULES([libmnl], [libmnl >= 1])
114
115 dnl Checks for header files
116
117 dnl Checks for declarations
118 AC_CHECK_DECLS([NLA_F_NESTED, NLA_F_NET_BYTEORDER, NLA_TYPE_MASK],,
119                 [AC_MSG_ERROR([System kernel header files are older than 2.6.24, use CFLAGS for non-default location])],
120                 [#include <sys/socket.h>
121 #include <linux/netlink.h>])
122
123 dnl Checks for typedefs, structures
124 AC_CHECK_TYPES([union nf_inet_addr],,,[#include <linux/types.h>
125 #include <netinet/in.h>
126 #include <linux/netfilter.h>])
127
128 dnl Checks for  compiler characteristics.
129 dnl Check extra warning flags except
130 dnl     -Wconversion            -> we need it
131 dnl     -Wunreachable-code      -> fails with ntoh*
132 dnl     -Wpointer-arith         -> limbnl uses it
133 if test "x$enable_debug" = "xyes"
134 then
135 AX_CFLAGS_GCC_OPTION(-Waggregate-return)
136 AX_CFLAGS_GCC_OPTION(-Wbad-function-cast)
137 AX_CFLAGS_GCC_OPTION(-Wcast-align)
138 AX_CFLAGS_GCC_OPTION(-Wcast-qual)
139 AX_CFLAGS_GCC_OPTION(-Werror)
140 AX_CFLAGS_GCC_OPTION(-Wextra)
141 AX_CFLAGS_GCC_OPTION(-Wfloat-equal)
142 AX_CFLAGS_GCC_OPTION(-Wformat=2)
143 AX_CFLAGS_GCC_OPTION(-Winit-self)
144 AX_CFLAGS_GCC_OPTION(-Winline)
145 AX_CFLAGS_GCC_OPTION(-Wmissing-declarations)
146 AX_CFLAGS_GCC_OPTION(-Wmissing-format-attribute)
147 AX_CFLAGS_GCC_OPTION(-Wmissing-prototypes)
148 AX_CFLAGS_GCC_OPTION(-Wnested-externs)
149 AX_CFLAGS_GCC_OPTION(-Wno-missing-field-initializers)
150 AX_CFLAGS_GCC_OPTION(-Woverlength-strings)
151 AX_CFLAGS_GCC_OPTION(-Wpacked)
152 AX_CFLAGS_GCC_OPTION(-Wredundant-decls)
153 AX_CFLAGS_GCC_OPTION(-Wshadow)
154 AX_CFLAGS_GCC_OPTION(-Wsign-compare)
155 AX_CFLAGS_GCC_OPTION(-Wstrict-prototypes)
156 AX_CFLAGS_GCC_OPTION(-Wswitch-default)
157 AX_CFLAGS_GCC_OPTION(-Wundef)
158 AX_CFLAGS_GCC_OPTION(-Wunused)
159 AX_CFLAGS_GCC_OPTION(-Wwrite-strings)
160 fi
161 dnl Checks for library functions.
162
163 dnl Generate output
164 AC_CONFIG_FILES([Makefile include/libipset/Makefile lib/Makefile src/Makefile])
165 AC_OUTPUT