Code

Build system: Improve detection of the iptc library.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Thu, 17 Sep 2009 06:44:07 +0000 (08:44 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Thu, 17 Sep 2009 06:44:07 +0000 (08:44 +0200)
When checking for the iptc headers and data types, the configure script
added the kernel directory to the CFLAGS. Later, when actually building
the iptables plugin, the CFLAGS were left untouched.

At least on Debian, the “real” kernel headers are not required – the
libc versions in /usr/include/linux are sufficient. The usage of
KERNEL_DIR has therefore been removed from the iptc checks.

In addition, an directory specified by “--with-libiptc=/path” is no
longer added to the global CFLAGS but rather to the iptables specific
CPPFLAGS.

Hopefully this resolved build problems on various platforms.

configure.in
src/Makefile.am

index 2471a2f15ce42c11b20d6146a69dba18aeba7872..9f26be3b8d5dbcbafafc10f62296e055dabbb561 100644 (file)
@@ -1434,8 +1434,8 @@ AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to l
                with_libiptc="yes"
        else if test "x$withval" != "xno" && test "x$withval" != "xyes"
        then
-               LDFLAGS="$LDFLAGS -L$withval/lib"
-               CPPFLAGS="$CPPFLAGS -I$withval/include"
+               LIBIPTC_CPPFLAGS="$LIBIPTC_CPPFLAGS -I$withval/include"
+               LIBIPTC_LDFLAGS="$LIBIPTC_LDFLAGS -L$withval/lib"
                with_libiptc="yes"
        else
                with_libiptc="$withval"
@@ -1473,8 +1473,8 @@ then
 fi
 if test "x$with_libiptc" = "xyes"
 then
-       SAVE_CFLAGS="$CFLAGS"
-       CFLAGS="$CFLAGS $KERNEL_CFLAGS"
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $LIBIPTC_CPPFLAGS"
 
        AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [],
        [
@@ -1485,18 +1485,12 @@ then
 #include "$srcdir/src/owniptc/ipt_kernel_headers.h"
        ])
 
-       CFLAGS="$SAVE_CFLAGS"
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
-AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes")
-if test "x$with_own_libiptc" = "xyes"
-then
-       AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
+       CPPFLAGS="$SAVE_CPPFLAGS"
 fi
 if test "x$with_libiptc" = "xyes"
 then
-       SAVE_CFLAGS="$CFLAGS"
-       CFLAGS="$CFLAGS $KERNEL_CFLAGS"
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $LIBIPTC_CPPFLAGS"
 
        AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [],
        [
@@ -1509,7 +1503,20 @@ then
 #endif
        ])
 
-       CFLAGS="$SAVE_CFLAGS"
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
+AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes")
+if test "x$with_libiptc" = "xyes"
+then
+       BUILD_WITH_LIBIPTC_CPPFLAGS="$LIBIPTC_CPPFLAGS"
+       BUILD_WITH_LIBIPTC_LDFLAGS="$LIBIPTC_LDFLAGS"
+       AC_SUBST(BUILD_WITH_LIBIPTC_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBIPTC_LDFLAGS)
+fi
+if test "x$with_own_libiptc" = "xyes"
+then
+       AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
 fi
 # }}}
 
index 42b97f8d48b94cabefe334b87e8a37293e09edf7..7b13029dae93a0f3d8735a8eef1e1c315ceea9c6 100644 (file)
@@ -356,7 +356,8 @@ endif # BUILD_PLUGIN_INTERFACE
 if BUILD_PLUGIN_IPTABLES
 pkglib_LTLIBRARIES += iptables.la
 iptables_la_SOURCES = iptables.c
-iptables_la_LDFLAGS = -module -avoid-version
+iptables_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBIPTC_CPPFLAGS)
+iptables_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_LIBIPTC_LDFLAGS)
 if BUILD_WITH_OWN_LIBIPTC
 iptables_la_LIBADD  = owniptc/libiptc.la
 iptables_la_DEPENDENCIES = owniptc/libiptc.la