Few fixes
[tomato.git] / release / src-rt-6.x.4708 / router / ipset / configure.ac
blobd5e5bb91f9ab97691a5e3d5459e8594fd1333a8e
1 dnl Boilerplate
2 AC_INIT([ipset], [6.24], [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 tar-pax])
8 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
10 AC_ENABLE_STATIC
11 LT_INIT([dlopen])
13 dnl Shortcut: Linux supported alone
14 case "$host" in
15 *-*-linux* | *-*-uclinux*) ;;
16 *) AC_MSG_ERROR([Linux systems supported exclusively!]);;
17 esac
19 dnl Optionnally disable building the kernel module
20 AC_ARG_WITH([kmod],
21             AS_HELP_STRING([--with-kmod=yes/no],
22                            [Build the kernel module (default: yes)]),
23             [BUILDKMOD="$withval";],
24             [BUILDKMOD="yes";])
25 AM_CONDITIONAL(WITH_KMOD, test "$BUILDKMOD" == "yes")
27 dnl Additional arguments
28 dnl Kernel build directory or source tree
29 AC_ARG_WITH([kbuild],
30             AS_HELP_STRING([--with-kbuild=PATH],
31                            [Path to kernel build directory]),
32             [KBUILDDIR="$withval";])
33 AC_ARG_WITH([ksource],
34             AS_HELP_STRING([--with-ksource=PATH],
35                            [Path to kernel source directory, if not the same as the kernel build directory]),
36             [KSOURCEDIR="$withval";])
37 AM_CONDITIONAL(WITH_KBUILDDIR, test "$KBUILDDIR" != "")
38 AC_SUBST(KBUILDDIR)
40 if test "$BUILDKMOD" == "yes"
41 then
42 dnl Sigh: check kernel version dependencies
43 if test "$KBUILDDIR" != ""
44 then
45         kbuilddir="$KBUILDDIR"
46 else
47         kbuilddir="/lib/modules/`uname -r`/build"
50 if test -n "$KSOURCEDIR"; then
51         ksourcedir="$KSOURCEDIR"
52 elif test -e "$kbuilddir/include/linux/netfilter/nfnetlink.h"; then
53         ksourcedir="$kbuilddir"
54 else
55         ksourcedir="/lib/modules/$(uname -r)/source"
57 if test ! -e "$ksourcedir/include/linux/netfilter/nfnetlink.h"
58 then
59         AC_MSG_ERROR([Invalid kernel source directory $ksourcedir])
62 if test ! -e "$kbuilddir/.config"
63 then
64         AC_MSG_ERROR([The kernel build directory $kbuilddir is not configured])
67 AC_PROG_GREP
68 AC_PROG_AWK
70 if ! $GREP -q "NFNL_SUBSYS_IPSET" "$ksourcedir/include/linux/netfilter/nfnetlink.h" && \
71    ! $GREP -q "NFNL_SUBSYS_IPSET" "$ksourcedir/include/uapi/linux/netfilter/nfnetlink.h";
72 then
73         AC_MSG_ERROR([The kernel source directory $ksourcedir is not patched with netlink.patch to support ipset])
77 dnl Maximal number of sets supported by the kernel, default 256
78 AC_ARG_WITH([maxsets],
79             AS_HELP_STRING([--with-maxsets=256],
80                            [Maximal numer of sets supported by the kernel]),
81             [MAXSETS="$withval";])
82 AM_CONDITIONAL(WITH_MAXSETS, test "$MAXSETS" != "")
83 AC_SUBST(MAXSETS)
85 dnl Verbose compiling
86 AC_ARG_ENABLE([verbose],
87               AS_HELP_STRING([--enable-verbose],
88                              [Enable verbose mode at compiling/linking.]),
89               [case "${enableval}" in
90                yes)     enable_verbose=yes ;;
91                no)      enable_verbose=no ;;
92                *) AC_MSG_ERROR([bad value ${enableval} for --enable-verbose]) ;;
93                esac], [enable_verbose=no])
94               
95 AC_ARG_ENABLE([debug],
96         AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
97         [], [enable_debug=no])
98 AS_IF([test "x$enable_debug" = "xyes"], [
99         AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
101 AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = xyes])
103 dnl Enable type modules
104 AC_ARG_ENABLE([settype_modules],
105                   AS_HELP_STRING([--enable-settype-modules],
106                   [Enable set type modules support]),
107                   [enable_settype_modules="$enableval"],
108                   [enable_settype_modules="no"])
110 AC_ARG_WITH([settype_modules_list],
111                 AS_HELP_STRING([--with-settype-modules-list="mod1 mod2 ..."],
112                                [List of dynamic loading modules, ignored if settype-modules is disabled. It could be "all" to build all available settypes as modules]),
113                                [SETTYPE_MODLIST_RAW="$withval";])
115 SETTYPE_MODLIST=
116 if test "x$enable_settype_modules" = "xyes"; then
117         for mod in $SETTYPE_MODLIST_RAW; do
118                 if echo $mod | grep "all"; then
119                         m="${mod}"
120                 else
121                         if echo $mod | grep "ipset_"; then
122                                 m="${mod}.c"
123                         else
124                                 m="ipset_${mod}.c"
125                         fi
126                 fi
128                 SETTYPE_MODLIST="${SETTYPE_MODLIST} $m"
129         done
131         AC_MSG_RESULT([checking for configuration with dynamic loading modules... $SETTYPE_MODLIST_RAW])
133 AC_SUBST(SETTYPE_MODLIST)
135 AM_CONDITIONAL([ENABLE_SETTYPE_MODULES], [test "x$enable_settype_modules" = xyes])
137 AM_CONDITIONAL([ENABLE_STATIC], [test "x$enable_static" = xyes])
138 AM_CONDITIONAL([ENABLE_SHARED], [test "x$enable_shared" = xyes])
140 dnl Checks for programs
141 : ${CFLAGS=""}
143 AC_PROG_CC
144 AM_PROG_CC_C_O
145 AC_PROG_LIBTOOL
146 AC_PROG_INSTALL
147 AC_PROG_LN_S
149 dnl Checks for libraries
150 PKG_CHECK_MODULES([libmnl], [libmnl >= 1])
152 dnl Checks for header files
154 dnl Checks for declarations
155 AC_CHECK_DECLS([NLA_F_NESTED, NLA_F_NET_BYTEORDER, NLA_TYPE_MASK],,
156                 [AC_MSG_ERROR([System kernel header files are older than 2.6.24, use CFLAGS for non-default location])],
157                 [#include <sys/socket.h>
158 #include <linux/netlink.h>])
160 dnl Checks for typedefs, structures
161 AC_CHECK_TYPES([union nf_inet_addr],,,[#include <linux/types.h>
162 #include <netinet/in.h>
163 #include <linux/netfilter.h>])
165 dnl Checks for functions
166 AC_CHECK_FUNCS(gethostbyname2)
168 if test "$BUILDKMOD" == "yes"
169 then
170 dnl Check kernel incompatibilities... Ugly like hell
171 AC_MSG_CHECKING([kernel source for struct xt_action_param])
172 if test -f $ksourcedir/include/linux/netfilter/x_tables.h && \
173    $GREP -q 'struct xt_action_param' $ksourcedir/include/linux/netfilter/x_tables.h; then
174         AC_MSG_RESULT(yes)
175         AC_SUBST(HAVE_STRUCT_XT_ACTION_PARAM, define)
176 else
177         AC_MSG_RESULT(no)
178         AC_SUBST(HAVE_STRUCT_XT_ACTION_PARAM, undef)
181 AC_MSG_CHECKING([kernel source for vzalloc])
182 if test -f $ksourcedir/include/linux/vmalloc.h && \
183    $GREP -q 'vzalloc' $ksourcedir/include/linux/vmalloc.h; then
184         AC_MSG_RESULT(yes)
185         AC_SUBST(HAVE_VZALLOC, define)
186 else
187         AC_MSG_RESULT(no)
188         AC_SUBST(HAVE_VZALLOC, undef)
191 AC_MSG_CHECKING([kernel source for ether_addr_equal])
192 if test -f $ksourcedir/include/linux/etherdevice.h && \
193    $GREP -q 'ether_addr_equal' $ksourcedir/include/linux/etherdevice.h; then
194         AC_MSG_RESULT(yes)
195         AC_SUBST(HAVE_ETHER_ADDR_EQUAL, define)
196 else
197         AC_MSG_RESULT(no)
198         AC_SUBST(HAVE_ETHER_ADDR_EQUAL, undef)
201 AC_MSG_CHECKING([kernel source for nla_put_be16])
202 if test -f $ksourcedir/include/net/netlink.h && \
203    $GREP -q 'nla_put_be16' $ksourcedir/include/net/netlink.h; then
204         AC_MSG_RESULT(yes)
205         AC_SUBST(HAVE_NLA_PUT_BE16, define)
206 else
207         AC_MSG_RESULT(no)
208         AC_SUBST(HAVE_NLA_PUT_BE16, undef)
211 AC_MSG_CHECKING([kernel source for nla_put_be64])
212 if test -f $ksourcedir/include/net/netlink.h && \
213    $GREP -q 'nla_put_be64' $ksourcedir/include/net/netlink.h; then
214         AC_MSG_RESULT(yes)
215         AC_SUBST(HAVE_NLA_PUT_BE64, define)
216 else
217         AC_MSG_RESULT(no)
218         AC_SUBST(HAVE_NLA_PUT_BE64, undef)
221 AC_MSG_CHECKING([kernel source for portid in nl_info])
222 if test -f $ksourcedir/include/linux/netlink.h && \
223    $AWK '/^struct netlink_skb_parms/ {for(i=1; i<=5; i++) {getline; print}}' $ksourcedir/include/linux/netlink.h | $GREP -q 'portid;'; then
224         AC_MSG_RESULT(yes)
225         AC_SUBST(HAVE_NL_INFO_PORTID, define)
226 else
227         AC_MSG_RESULT(no)
228         AC_SUBST(HAVE_NL_INFO_PORTID, undef)
231 AC_MSG_CHECKING([kernel source for netlink_dump_start args])
232 if test -f $ksourcedir/include/linux/netlink.h && \
233    $AWK '/netlink_dump_start/ {for(i=1; i<=4; i++) {getline; print}}' $ksourcedir/include/linux/netlink.h | $GREP -q 'done.*;'; then
234         AC_MSG_RESULT(5 args)
235         AC_SUBST(HAVE_NETLINK_DUMP_START_ARGS, 5)
236 elif test -f $ksourcedir/include/linux/netlink.h && \
237    $AWK '/netlink_dump_start/ {for(i=1; i<=4; i++) {getline; print}}' $ksourcedir/include/linux/netlink.h | $GREP -q 'min_dump_alloc.*;'; then
238         AC_MSG_RESULT(6 args)
239         AC_SUBST(HAVE_NETLINK_DUMP_START_ARGS, 6)
240 else
241         AC_MSG_RESULT(4 args)
242         AC_SUBST(HAVE_NETLINK_DUMP_START_ARGS, 4)
245 AC_MSG_CHECKING([kernel source for ns_capable])
246 if test -f $ksourcedir/include/linux/capability.h && \
247    $GREP -q 'ns_capable' $ksourcedir/include/linux/capability.h; then
248         AC_MSG_RESULT(yes)
249         AC_SUBST(HAVE_NS_CAPABLE, define)
250 else
251         AC_MSG_RESULT(no)
252         AC_SUBST(HAVE_NS_CAPABLE, undef)
255 AC_MSG_CHECKING([kernel source for nfnl_lock per subsys])
256 if test -f $ksourcedir/include/linux/netfilter/nfnetlink.h && \
257    $GREP -q 'nfnl_lock.* subsys_id' $ksourcedir/include/linux/netfilter/nfnetlink.h; then
258         AC_MSG_RESULT(yes)
259         AC_SUBST(HAVE_NFNL_LOCK_SUBSYS, define)
260 else
261         AC_MSG_RESULT(no)
262         AC_SUBST(HAVE_NFNL_LOCK_SUBSYS, undef)
265 AC_MSG_CHECKING([kernel source for export.h])
266 if test -f $ksourcedir/include/linux/export.h; then
267         AC_MSG_RESULT(yes)
268         AC_SUBST(HAVE_EXPORT_H, define)
269 else
270         AC_MSG_RESULT(no)
271         AC_SUBST(HAVE_EXPORT_H, undef)
274 AC_MSG_CHECKING([kernel source for ipv6_skip_exthdr args])
275 if test -f $ksourcedir/include/net/ipv6.h && \
276    $AWK '/ipv6_skip_exthdr/ {getline; print}' $ksourcedir/include/net/ipv6.h | $GREP -q 'frag_offp'; then
277         AC_MSG_RESULT(4 args)
278         AC_SUBST(HAVE_IPV6_SKIP_EXTHDR_ARGS, 4)
279 else
280         AC_MSG_RESULT(3 args)
281         AC_SUBST(HAVE_IPV6_SKIP_EXTHDR_ARGS, 3)
284 AC_MSG_CHECKING([kernel source for bool checkentry function prototype])
285 if test -f $ksourcedir/include/linux/netfilter/x_tables.h && \
286    $GREP -q 'bool .\*checkentry.' $ksourcedir/include/linux/netfilter/x_tables.h; then
287         AC_MSG_RESULT(yes)
288         AC_SUBST(HAVE_CHECKENTRY_BOOL, define)
289 else
290         AC_MSG_RESULT(no)
291         AC_SUBST(HAVE_CHECKENTRY_BOOL, undef)
294 AC_MSG_CHECKING([kernel source for old struct xt_target_param])
295 if test -f $ksourcedir/include/linux/netfilter/x_tables.h && \
296    $GREP -q '^struct xt_target_param ' $ksourcedir/include/linux/netfilter/x_tables.h; then
297         AC_MSG_RESULT(yes)
298         AC_SUBST(HAVE_XT_TARGET_PARAM, define)
299 else
300         AC_MSG_RESULT(no)
301         AC_SUBST(HAVE_XT_TARGET_PARAM, undef)
304 AC_MSG_CHECKING([kernel source for id in struct pernet_operations])
305 if test -f $ksourcedir/include/net/net_namespace.h && \
306    $AWK '/struct pernet_operations/ {for(i=1; i<=6; i++) {getline; print}}' $ksourcedir/include/net/net_namespace.h | $GREP -q 'int \*id;'; then
307         AC_MSG_RESULT(yes)
308         AC_SUBST(HAVE_NET_OPS_ID, define)
309 else
310         AC_MSG_RESULT(no)
311         AC_SUBST(HAVE_NET_OPS_ID, undef)
314 AC_MSG_CHECKING([kernel source for user_ns in struct net])
315 if test -f $ksourcedir/include/net/net_namespace.h && \
316    $AWK '/^struct net \{/ {for(i=1; i<=20; i++) {getline; print}}' $ksourcedir/include/net/net_namespace.h | $GREP -q 'user_ns'; then
317         AC_MSG_RESULT(yes)
318         AC_SUBST(HAVE_USER_NS_IN_STRUCT_NET, define)
319 else
320         AC_MSG_RESULT(no)
321         AC_SUBST(HAVE_USER_NS_IN_STRUCT_NET, undef)
324 AC_MSG_CHECKING([kernel source for rbtree_postorder_for_each_entry_safe])
325 if test -f $ksourcedir/include/linux/rbtree.h && \
326    $GREP -q 'rbtree_postorder_for_each_entry_safe' $ksourcedir/include/linux/rbtree.h; then
327         AC_MSG_RESULT(yes)
328         AC_SUBST(HAVE_RBTREE_POSTORDER_FOR_EACH_ENTRY_SAFE, define)
329 else
330         AC_MSG_RESULT(no)
331         AC_SUBST(HAVE_RBTREE_POSTORDER_FOR_EACH_ENTRY_SAFE, undef)
334 AC_MSG_CHECKING([kernel source for kvfree])
335 if test -f $ksourcedir/include/linux/mm.h && \
336    $GREP -q 'kvfree' $ksourcedir/include/linux/mm.h; then
337         AC_MSG_RESULT(yes)
338         AC_SUBST(HAVE_KVFREE, define)
339 else
340         AC_MSG_RESULT(no)
341         AC_SUBST(HAVE_KVFREE, undef)
344 AC_MSG_CHECKING([kernel source for struct net in struct xt_mtchk_param])
345 if test -f $ksourcedir/include/linux/netfilter/x_tables.h && \
346    $AWK '/^struct xt_mtchk_param / {for(i=1; i<=5; i++) {getline; print}}' $ksourcedir/include/linux/netfilter/x_tables.h | \
347    $GREP -q 'struct net '; then
348         AC_MSG_RESULT(yes)
349         AC_SUBST(HAVE_XT_MTCHK_PARAM_STRUCT_NET, define)
350 else
351         AC_MSG_RESULT(no)
352         AC_SUBST(HAVE_XT_MTCHK_PARAM_STRUCT_NET, undef)
355 AC_MSG_CHECKING([kernel source for struct net in the change function of tcf_ematch_ops])
356 if test -f $ksourcedir/include/net/pkt_cls.h && \
357    $AWK '/^struct tcf_ematch_ops / {for(i=1; i<=5; i++) {getline; print}}' $ksourcedir/include/net/pkt_cls.h | \
358    $GREP -q '\*change..struct net \*net'; then
359         AC_MSG_RESULT(yes)
360         AC_SUBST(HAVE_TCF_EMATCH_OPS_CHANGE_ARG_NET, define)
361 else
362         AC_MSG_RESULT(no)
363         AC_SUBST(HAVE_TCF_EMATCH_OPS_CHANGE_ARG_NET, undef)
366 AC_MSG_CHECKING([kernel source for struct net in struct tcf_ematch])
367 if test -f $ksourcedir/include/net/pkt_cls.h && \
368    $AWK '/^struct tcf_ematch_ops / {for(i=1; i<=7; i++) {getline; print}}' $ksourcedir/include/net/pkt_cls.h | \
369    $GREP -q 'struct net'; then
370         AC_MSG_RESULT(yes)
371         AC_SUBST(HAVE_TCF_EMATCH_STRUCT_NET, define)
372 else
373         AC_MSG_RESULT(no)
374         AC_SUBST(HAVE_TCF_EMATCH_STRUCT_NET, undef)
377 AC_MSG_CHECKING([kernel source for struct net_generic])
378 if test -f $ksourcedir/include/net/netns/generic.h && \
379    $GREP -q 'struct net_generic' $ksourcedir/include/net/netns/generic.h; then
380         AC_MSG_RESULT(yes)
381 else
382         AC_MSG_RESULT(no)
383         AC_MSG_ERROR([Netns support is required in the Linux kernel tree])
387 dnl Checks for compiler characteristics.
388 dnl Check extra warning flags except
389 dnl     -Wconversion            -> we need it
390 dnl     -Wunreachable-code      -> fails with ntoh*
391 dnl     -Wpointer-arith         -> limbnl uses it
392 dnl     -Wsign-conversion       -> libmnl
393 if test "x$enable_debug" = "xyes"
394 then
395 AX_CFLAGS_GCC_OPTION(-Waggregate-return)
396 AX_CFLAGS_GCC_OPTION(-Wbad-function-cast)
397 AX_CFLAGS_GCC_OPTION(-Wcast-align)
398 AX_CFLAGS_GCC_OPTION(-Wcast-qual)
399 AX_CFLAGS_GCC_OPTION(-Werror)
400 AX_CFLAGS_GCC_OPTION(-Wextra)
401 AX_CFLAGS_GCC_OPTION(-Wfloat-equal)
402 AX_CFLAGS_GCC_OPTION(-Wformat=2)
403 AX_CFLAGS_GCC_OPTION(-Wjump-misses-init)
404 AX_CFLAGS_GCC_OPTION(-Winit-self)
405 AX_CFLAGS_GCC_OPTION(-Winline)
406 AX_CFLAGS_GCC_OPTION(-Wlogical-op)
407 AX_CFLAGS_GCC_OPTION(-Wmissing-declarations)
408 AX_CFLAGS_GCC_OPTION(-Wmissing-format-attribute)
409 AX_CFLAGS_GCC_OPTION(-Wmissing-prototypes)
410 AX_CFLAGS_GCC_OPTION(-Wnested-externs)
411 AX_CFLAGS_GCC_OPTION(-Wno-missing-field-initializers)
412 AX_CFLAGS_GCC_OPTION(-Wold-style-definition)
413 AX_CFLAGS_GCC_OPTION(-Woverlength-strings)
414 AX_CFLAGS_GCC_OPTION(-Wpacked)
415 AX_CFLAGS_GCC_OPTION(-Wredundant-decls)
416 AX_CFLAGS_GCC_OPTION(-Wrwrite-strings)
417 AX_CFLAGS_GCC_OPTION(-Wshadow)
418 AX_CFLAGS_GCC_OPTION(-Wsign-compare)
419 AX_CFLAGS_GCC_OPTION(-Wstrict-prototypes)
420 AX_CFLAGS_GCC_OPTION(-Wswitch-default)
421 AX_CFLAGS_GCC_OPTION(-Wundef)
422 AX_CFLAGS_GCC_OPTION(-Wuninitialized)
423 AX_CFLAGS_GCC_OPTION(-Wunused)
424 AX_CFLAGS_GCC_OPTION(-Wvla)
425 AX_CFLAGS_GCC_OPTION(-Wwrite-strings)
427 dnl Checks for library functions.
429 dnl Generate output
430 AC_CONFIG_FILES([Makefile include/libipset/Makefile
431         lib/Makefile lib/libipset.pc src/Makefile
432         kernel/include/linux/netfilter/ipset/ip_set_compat.h])
433 AC_OUTPUT
435 dnl Summary
436 AC_MSG_RESULT([])
437 AC_MSG_RESULT([$PACKAGE userspace tool configuration:])
438 if test "x$enable_settype_modules" != "xyes"; then
439         AC_MSG_RESULT([    Dynamic module loading: disabled])
440 else
441         AC_MSG_RESULT([    Dynamic module loading: enabled])
443 IPSET_ALL_MODULES="`ls ${srcdir}/lib/ipset_*.c|sed -e 's/^.*lib\///' -e 's/\.c$//'`"
444 AC_MSG_RESULT([    Static modules:])
445 if test "x$SETTYPE_MODLIST" = "x"; then
446         for mod in $IPSET_ALL_MODULES; do
447                 AC_MSG_RESULT([        ${mod}])
448         done
449         AC_MSG_RESULT([    Dynamic modules:])
450 elif echo $SETTYPE_MODLIST | grep "all" >/dev/null; then
451         AC_MSG_RESULT([    Dynamic modules:])
452         for mod in $IPSET_ALL_MODULES; do
453                 AC_MSG_RESULT([        ${mod}])
454         done
455 else
456         for mod in $IPSET_ALL_MODULES; do
457                 if echo $SETTYPE_MODLIST | grep $mod >/dev/null; then
458                         :
459                 else
460                         AC_MSG_RESULT([        ${mod}])
461                 fi
462         done
463         AC_MSG_RESULT([    Dynamic modules:])
464         for mod in $IPSET_ALL_MODULES; do
465                 if echo $SETTYPE_MODLIST | grep $mod >/dev/null; then
466                         AC_MSG_RESULT([        ${mod}])
467                 fi
468         done