From af0dd163e5e9ea9de922aba0b71f76d8d921724f Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 17 Sep 2009 09:36:35 +0200 Subject: [PATCH] Build system: Further improve libiptc handling. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Only check for “iptc_handle_t” and “ip6tc_handle_t” if using a system-wide version of libiptc. If we use the shipped version, we *know* it provides these types. --- configure.in | 51 ++++++++++++++++++++++++--------------------------- src/iptables.c | 16 ++++++++++------ 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/configure.in b/configure.in index 9f26be3b..092fbd02 100644 --- a/configure.in +++ b/configure.in @@ -1449,16 +1449,21 @@ AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to l with_libiptc="no (Linux only)" fi ]) -if test "x$with_libiptc" = "xyes" && test "x$with_own_libiptc" = "xno" +SAVE_CPPFLAGS="$CPPFLAGS" +SAVE_LDFLAGS="$LDFLAGS" +CPPFLAGS="$CPPFLAGS $LIBIPTC_CPPFLAGS" +LDFLAGS="$LDFLAGS $LIBIPTC_LDFLAGS" +if test "x$with_libiptc" = "xyes" then - AC_CHECK_LIB(iptc, iptc_init, + AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [], [ - AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).]) + with_libiptc="no (Linux iptables headers not found)" + with_own_libiptc="no" ], [ - with_libiptc="yes" - with_own_libiptc="yes" +#include "$srcdir/src/owniptc/ipt_kernel_headers.h" ]) + fi if test "x$with_libiptc" = "xyes" && test "x$with_own_libiptc" = "xno" then @@ -1471,27 +1476,8 @@ then with_own_libiptc="yes" ]) fi -if test "x$with_libiptc" = "xyes" -then - SAVE_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $LIBIPTC_CPPFLAGS" - - AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [], - [ - with_libiptc="no (Linux iptables headers not found - check KERNEL_DIR)" - with_own_libiptc="no" - ], - [ -#include "$srcdir/src/owniptc/ipt_kernel_headers.h" - ]) - - CPPFLAGS="$SAVE_CPPFLAGS" -fi -if test "x$with_libiptc" = "xyes" +if test "x$with_libiptc" = "xyes" && test "x$with_own_libiptc" = "xno" then - SAVE_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $LIBIPTC_CPPFLAGS" - AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [], [ #if OWN_LIBIPTC @@ -1502,8 +1488,17 @@ then # include #endif ]) - - CPPFLAGS="$SAVE_CPPFLAGS" +fi +if test "x$with_libiptc" = "xyes" && test "x$with_own_libiptc" = "xno" +then + AC_CHECK_LIB(iptc, iptc_init, + [ + AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).]) + ], + [ + with_libiptc="yes" + with_own_libiptc="yes" + ]) fi AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes") AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes") @@ -1518,6 +1513,8 @@ if test "x$with_own_libiptc" = "xyes" then AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.]) fi +CPPFLAGS="$SAVE_CPPFLAGS" +LDFLAGS="$SAVE_LDFLAGS" # }}} # --with-java {{{ diff --git a/src/iptables.c b/src/iptables.c index 69cd39c4..aa53074a 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -34,10 +34,13 @@ #if OWN_LIBIPTC # include "owniptc/libiptc.h" # include "owniptc/libip6tc.h" -#else + +# define HAVE_IPTC_HANDLE_T 1 +# define HAVE_IP6TC_HANDLE_T 1 + +#else /* if !OWN_LIBIPTC */ # include # include -#endif /* * iptc_handle_t was available before libiptc was officially available as a @@ -51,12 +54,13 @@ * this is somewhat hacky, I didn't find better way to solve that :-/ * -tokkee */ -#ifndef HAVE_IPTC_HANDLE_T +# ifndef HAVE_IPTC_HANDLE_T typedef struct iptc_handle iptc_handle_t; -#endif -#ifndef HAVE_IP6TC_HANDLE_T +# endif +# ifndef HAVE_IP6TC_HANDLE_T typedef struct ip6tc_handle ip6tc_handle_t; -#endif +# endif +#endif /* !OWN_LIBIPTC */ /* * (Module-)Global variables -- 2.11.0