Skip to contentSkip to conversation

build system improvements

PATCH In review Eric Leblond 2 participants 10 messages Nov 3, 2012 netfilter

lore
Share & tools
lore
#0 lore raw

cover build system improvements

Hello,

Here's a small patchset containing some build system improvements. The first three patches add a flag to disable the build of some input plugins that depends on library. The last patch adds a message at the end of configure run to indicate what will be build.

Patchset statistic:

 configure.ac              |   66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 input/flow/Makefile.am    |    2 ++
 input/packet/Makefile.am  |    4 ++++
 input/sum/Makefile.am     |    4 ++--
 output/ulogd_output_XML.c |    7 ++++++-
 5 files changed, 75 insertions(+), 8 deletions(-)

BR,
--
Eric

#1 lore raw

PATCH 1/4 Add configure flag to disable NFACCT build

It is now possible to pass the --disable-nfacct flag to disable compilation of NFACCT input plugin. Doing this the build of ulogd is possible on system where nfacct is not available.

---
 configure.ac              |    8 +++++++-
 input/sum/Makefile.am     |    4 ++--
 output/ulogd_output_XML.c |    7 ++++++-
 3 files changed, 15 insertions(+), 4 deletions(-)
configure.ac +7 -1
index 0f21cf1..159cb0b 100644
@@ -44,9 +44,15 @@ AC_SUBST([regular_CFLAGS])
 dnl Check for the right nfnetlink version
 PKG_CHECK_MODULES([LIBNFNETLINK], [libnfnetlink >= 1.0.1])
 PKG_CHECK_MODULES([LIBMNL], [libmnl >= 1.0.3])
-PKG_CHECK_MODULES([LIBNETFILTER_ACCT], [libnetfilter_acct >= 1.0.1])
 PKG_CHECK_MODULES([LIBNETFILTER_CONNTRACK], [libnetfilter_conntrack >= 1.0.2])
 PKG_CHECK_MODULES([LIBNETFILTER_LOG], [libnetfilter_log >= 1.0.0])
+AC_ARG_ENABLE(nfacct,
+       AS_HELP_STRING([--enable-nfacct], [Enable nfacct module [default=yes]]),,[enable_nfacct=yes])
+AS_IF([test "x$enable_nfacct" = "xyes"], [
+    PKG_CHECK_MODULES([LIBNETFILTER_ACCT], [libnetfilter_acct >= 1.0.1])
+    AC_DEFINE([BUILD_NFACCT], [1], [Building nfacct module])
+])
+AM_CONDITIONAL([BUILD_NFACCT], [test "x$enable_nfacct" = "xyes"])
 
 CT_CHECK_POSTGRES_DB()
 AM_CONDITIONAL(HAVE_PGSQL, test "x$PQLIBPATH" != "x")
input/sum/Makefile.am +2 -2
index 33fa849..b6ddb4d 100644
@@ -1,8 +1,8 @@
 AM_CPPFLAGS = -I$(top_srcdir)/include $(LIBNETFILTER_ACCT_CFLAGS) $(LIBMNL_CFLAGS)
 AM_CFLAGS = ${regular_CFLAGS}
-
+if BUILD_NFACCT
 pkglib_LTLIBRARIES = ulogd_inpflow_NFACCT.la
-
 ulogd_inpflow_NFACCT_la_SOURCES = ulogd_inpflow_NFACCT.c
 ulogd_inpflow_NFACCT_la_LDFLAGS = -avoid-version -module
 ulogd_inpflow_NFACCT_la_LIBADD  = $(LIBMNL_LIBS) $(LIBNETFILTER_ACCT_LIBS)
+endif
output/ulogd_output_XML.c +6 -1
index e9c3974..616e6c0 100644
@@ -20,7 +20,10 @@
 
 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
 #include <libnetfilter_log/libnetfilter_log.h>
+#include "../config.h"
+#ifdef BUILD_NFACCT
 #include <libnetfilter_acct/libnetfilter_acct.h>
+#endif
 #include <ulogd/ulogd.h>
 #include <sys/param.h>
 #include <time.h>
@@ -118,6 +121,7 @@ xml_output_packet(struct ulogd_key *inp, char *buf, ssize_t size)
 static int
 xml_output_sum(struct ulogd_key *inp, char *buf, ssize_t size)
 {
+#ifdef BUILD_NFACCT
 	struct nfacct *nfacct = ikey_get_ptr(&inp[KEY_SUM]);
 	int tmp;
 
@@ -125,10 +129,11 @@ xml_output_sum(struct ulogd_key *inp, char *buf, ssize_t size)
 						 NFACCT_SNPRINTF_F_TIME);
 	if (tmp < 0 || tmp >= size)
 		return -1;
-
+#endif
 	return 0;
 }
 
+
 static int xml_output(struct ulogd_pluginstance *upi)
 {
 	struct ulogd_key *inp = upi->input.keys;
Signature · 1 line
1.7.10.4
#2 lore raw

Re: [PATCH 1/4] Add configure flag to disable NFACCT build

Quoted 30 lines · Eric Leblond
configure.ac +0 -0
index 0f21cf1..159cb0b 100644
@@ -44,9 +44,15 @@ AC_SUBST([regular_CFLAGS])

dnl Check for the right nfnetlink version PKG_CHECK_MODULES([LIBNFNETLINK], [libnfnetlink >= 1.0.1]) PKG_CHECK_MODULES([LIBMNL], [libmnl >= 1.0.3]) -PKG_CHECK_MODULES([LIBNETFILTER_ACCT], [libnetfilter_acct >= 1.0.1]) PKG_CHECK_MODULES([LIBNETFILTER_CONNTRACK], [libnetfilter_conntrack >= 1.0.2]) PKG_CHECK_MODULES([LIBNETFILTER_LOG], [libnetfilter_log >= 1.0.0])

configure.ac +7 -0
+AC_ARG_ENABLE(nfacct,
+       AS_HELP_STRING([--enable-nfacct], [Enable nfacct module [default=yes]]),,[enable_nfacct=yes])
+AS_IF([test "x$enable_nfacct" = "xyes"], [
+    PKG_CHECK_MODULES([LIBNETFILTER_ACCT], [libnetfilter_acct >= 1.0.1])
+    AC_DEFINE([BUILD_NFACCT], [1], [Building nfacct module])
+])
+AM_CONDITIONAL([BUILD_NFACCT], [test "x$enable_nfacct" = "xyes"])

CT_CHECK_POSTGRES_DB() AM_CONDITIONAL(HAVE_PGSQL, test "x$PQLIBPATH" != "x")

input/sum/Makefile.am +1 -1
index 33fa849..b6ddb4d 100644
@@ -1,8 +1,8 @@
 AM_CPPFLAGS = -I$(top_srcdir)/include $(LIBNETFILTER_ACCT_CFLAGS) $(LIBMNL_CFLAGS)
 AM_CFLAGS = ${regular_CFLAGS}
-
+if BUILD_NFACCT
Quoted 6 lines

pkglib_LTLIBRARIES = ulogd_inpflow_NFACCT.la
-
ulogd_inpflow_NFACCT_la_SOURCES = ulogd_inpflow_NFACCT.c ulogd_inpflow_NFACCT_la_LDFLAGS = -avoid-version -module ulogd_inpflow_NFACCT_la_LIBADD = $(LIBMNL_LIBS) $(LIBNETFILTER_ACCT_LIBS) +endif

As far as I remember, AM conditionals do not automatically become C macros. Can you check config.h?
So you will likely have to add the following line into the if..endif block:

AM_CPPFLAGS += -DBUILD_NFACCT

#3 lore raw

Re: [PATCH 1/4] Add configure flag to disable NFACCT build

Hi,

Quoted 34 lines · Jan Engelhardt
Quoted 31 lines · Eric Leblond
configure.ac +0 -0
index 0f21cf1..159cb0b 100644
@@ -44,9 +44,15 @@ AC_SUBST([regular_CFLAGS])

dnl Check for the right nfnetlink version PKG_CHECK_MODULES([LIBNFNETLINK], [libnfnetlink >= 1.0.1]) PKG_CHECK_MODULES([LIBMNL], [libmnl >= 1.0.3]) -PKG_CHECK_MODULES([LIBNETFILTER_ACCT], [libnetfilter_acct >= 1.0.1]) PKG_CHECK_MODULES([LIBNETFILTER_CONNTRACK], [libnetfilter_conntrack >= 1.0.2]) PKG_CHECK_MODULES([LIBNETFILTER_LOG], [libnetfilter_log >= 1.0.0])

configure.ac +7 -0
+AC_ARG_ENABLE(nfacct,
+       AS_HELP_STRING([--enable-nfacct], [Enable nfacct module [default=yes]]),,[enable_nfacct=yes])
+AS_IF([test "x$enable_nfacct" = "xyes"], [
+    PKG_CHECK_MODULES([LIBNETFILTER_ACCT], [libnetfilter_acct >= 1.0.1])
+    AC_DEFINE([BUILD_NFACCT], [1], [Building nfacct module])
+])
+AM_CONDITIONAL([BUILD_NFACCT], [test "x$enable_nfacct" = "xyes"])

CT_CHECK_POSTGRES_DB() AM_CONDITIONAL(HAVE_PGSQL, test "x$PQLIBPATH" != "x")

input/sum/Makefile.am +1 -1
index 33fa849..b6ddb4d 100644
@@ -1,8 +1,8 @@
 AM_CPPFLAGS = -I$(top_srcdir)/include $(LIBNETFILTER_ACCT_CFLAGS) $(LIBMNL_CFLAGS)
 AM_CFLAGS = ${regular_CFLAGS}
-
+if BUILD_NFACCT

pkglib_LTLIBRARIES = ulogd_inpflow_NFACCT.la

Quoted 8 lines
Quoted 5 lines

-
ulogd_inpflow_NFACCT_la_SOURCES = ulogd_inpflow_NFACCT.c ulogd_inpflow_NFACCT_la_LDFLAGS = -avoid-version -module ulogd_inpflow_NFACCT_la_LIBADD = $(LIBMNL_LIBS) $(LIBNETFILTER_ACCT_LIBS) +endif

As far as I remember, AM conditionals do not automatically become C macros. Can you check config.h?

Yeah, that's why I've added AC_DEFINE when the module is built.

BR,

Quoted 4 lines

So you will likely have to add the following line into the if..endif block:

AM_CPPFLAGS += -DBUILD_NFACCT

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Re: [PATCH 1/4] Add configure flag to disable NFACCT build

Quoted 10 lines · Eric Leblond
Quoted 8 lines

configure.ac AC_SUBST([regular_CFLAGS]) · line 55

Quoted 5 lines
configure.ac +5 -0
+AS_IF([test "x$enable_nfacct" = "xyes"], [
+    PKG_CHECK_MODULES([LIBNETFILTER_ACCT], [libnetfilter_acct >= 1.0.1])
+    AC_DEFINE([BUILD_NFACCT], [1], [Building nfacct module])
+])
+AM_CONDITIONAL([BUILD_NFACCT], [test "x$enable_nfacct" = "xyes"])

As far as I remember, AM conditionals do not automatically become C macros. Can you check config.h?

Yeah, that's why I've added AC_DEFINE when the module is built.

I completely missed that. Sorry for the noise.

#5 lore raw

PATCH 2/4 Add configure flag to disable NFCT build

In reply to Eric Leblond
---
 configure.ac           |    8 +++++++-
 input/flow/Makefile.am |    2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)
configure.ac +7 -1
index 159cb0b..5bb8644 100644
@@ -44,8 +44,14 @@ AC_SUBST([regular_CFLAGS])
 dnl Check for the right nfnetlink version
 PKG_CHECK_MODULES([LIBNFNETLINK], [libnfnetlink >= 1.0.1])
 PKG_CHECK_MODULES([LIBMNL], [libmnl >= 1.0.3])
-PKG_CHECK_MODULES([LIBNETFILTER_CONNTRACK], [libnetfilter_conntrack >= 1.0.2])
 PKG_CHECK_MODULES([LIBNETFILTER_LOG], [libnetfilter_log >= 1.0.0])
+AC_ARG_ENABLE(nfct,
+       AS_HELP_STRING([--enable-nfct], [Enable nfct module [default=yes]]),,[enable_nfct=yes])
+AS_IF([test "x$enable_nfct" = "xyes"], [
+    PKG_CHECK_MODULES([LIBNETFILTER_CONNTRACK], [libnetfilter_conntrack >= 1.0.2])
+    AC_DEFINE([BUILD_NFCT], [1], [Building nfct module])
+])
+AM_CONDITIONAL([BUILD_NFCT], [test "x$enable_nfct" = "xyes"])
 AC_ARG_ENABLE(nfacct,
        AS_HELP_STRING([--enable-nfacct], [Enable nfacct module [default=yes]]),,[enable_nfacct=yes])
 AS_IF([test "x$enable_nfacct" = "xyes"], [
input/flow/Makefile.am +2 -0
index 127caf6..36c34ca 100644
@@ -2,11 +2,13 @@
 AM_CPPFLAGS = -I$(top_srcdir)/include
 AM_CFLAGS = ${regular_CFLAGS}
 
+if BUILD_NFCT
 pkglib_LTLIBRARIES = ulogd_inpflow_NFCT.la # ulogd_inpflow_IPFIX.la
 
 ulogd_inpflow_NFCT_la_SOURCES = ulogd_inpflow_NFCT.c
 ulogd_inpflow_NFCT_la_LDFLAGS = -avoid-version -module $(LIBNETFILTER_CONNTRACK_LIBS)
 ulogd_inpflow_NFCT_la_CFLAGS = $(AM_CFLAGS) $(LIBNETFILTER_CONNTRACK_CFLAGS)
+endif
 
 #ulogd_inpflow_IPFIX_la_SOURCES = ulogd_inpflow_IPFIX.c
 #ulogd_inpflow_IPFIX_la_LDFLAGS = -avoid-version -module
Signature · 1 line
1.7.10.4
#6 lore raw

PATCH 3/4 Add configure flag to disable NFLOG build

In reply to Eric Leblond
---
 configure.ac             |    8 +++++++-
 input/packet/Makefile.am |    4 ++++
 2 files changed, 11 insertions(+), 1 deletion(-)
configure.ac +7 -1
index 5bb8644..930aef0 100644
@@ -44,7 +44,13 @@ AC_SUBST([regular_CFLAGS])
 dnl Check for the right nfnetlink version
 PKG_CHECK_MODULES([LIBNFNETLINK], [libnfnetlink >= 1.0.1])
 PKG_CHECK_MODULES([LIBMNL], [libmnl >= 1.0.3])
-PKG_CHECK_MODULES([LIBNETFILTER_LOG], [libnetfilter_log >= 1.0.0])
+AC_ARG_ENABLE(nflog,
+       AS_HELP_STRING([--enable-nflog], [Enable nflog module [default=yes]]),,[enable_nflog=yes])
+AS_IF([test "x$enable_nflog" = "xyes"], [
+    PKG_CHECK_MODULES([LIBNETFILTER_LOG], [libnetfilter_log >= 1.0.0])
+    AC_DEFINE([BUILD_NFLOG], [1], [Building nflog module])
+])
+AM_CONDITIONAL([BUILD_NFLOG], [test "x$enable_nflog" = "xyes"])
 AC_ARG_ENABLE(nfct,
        AS_HELP_STRING([--enable-nfct], [Enable nfct module [default=yes]]),,[enable_nfct=yes])
 AS_IF([test "x$enable_nfct" = "xyes"], [
input/packet/Makefile.am +4 -0
index 250543b..7d278d1 100644
@@ -2,12 +2,16 @@
 AM_CPPFLAGS = -I$(top_srcdir)/include
 AM_CFLAGS = ${regular_CFLAGS}
 
+if BUILD_NFLOG
 pkglib_LTLIBRARIES = ulogd_inppkt_NFLOG.la ulogd_inppkt_ULOG.la \
 			 ulogd_inppkt_UNIXSOCK.la
 
 ulogd_inppkt_NFLOG_la_SOURCES = ulogd_inppkt_NFLOG.c
 ulogd_inppkt_NFLOG_la_LDFLAGS = -avoid-version -module $(LIBNETFILTER_LOG_LIBS)
 ulogd_inppkt_NFLOG_la_CFLAGS = $(AM_CFLAGS) $(LIBNETFILTER_LOG_CFLAGS)
+else
+pkglib_LTLIBRARIES = ulogd_inppkt_ULOG.la ulogd_inppkt_UNIXSOCK.la
+endif
 
 ulogd_inppkt_ULOG_la_SOURCES = ulogd_inppkt_ULOG.c
 ulogd_inppkt_ULOG_la_LDFLAGS = -avoid-version -module
Signature · 1 line
1.7.10.4
#7 lore raw

Re: [PATCH 3/4] Add configure flag to disable NFLOG build

input/packet/Makefile.am line 14

Quoted 11 lines · Eric Leblond

+if BUILD_NFLOG
pkglib_LTLIBRARIES = ulogd_inppkt_NFLOG.la ulogd_inppkt_ULOG.la \
ulogd_inppkt_UNIXSOCK.la

ulogd_inppkt_NFLOG_la_SOURCES = ulogd_inppkt_NFLOG.c ulogd_inppkt_NFLOG_la_LDFLAGS = -avoid-version -module $(LIBNETFILTER_LOG_LIBS) ulogd_inppkt_NFLOG_la_CFLAGS = $(AM_CFLAGS) $(LIBNETFILTER_LOG_CFLAGS)

input/packet/Makefile.am +3 -0
+else
+pkglib_LTLIBRARIES = ulogd_inppkt_ULOG.la ulogd_inppkt_UNIXSOCK.la
+endif

You can use

pkglib_LTLIBRARIES = ulogd_inppkt_ULOG.la ulogd_inppkt_UNIXSOCK.la if BUILD_NFLOG
pkglib_LTLIBRARIES += ulogd_inppkt_NFLOG.la
...
endif

So that ulogd_inppkt_ULOG.la ulogd_inppkt_UNIXSOCK.la does not have to be listed twice.

#8 lore raw

Re: [PATCH 3/4] Add configure flag to disable NFLOG build

Hi,

Quoted 16 lines · Jan Engelhardt

input/packet/Makefile.am line 14

Quoted 11 lines · Eric Leblond

+if BUILD_NFLOG
pkglib_LTLIBRARIES = ulogd_inppkt_NFLOG.la ulogd_inppkt_ULOG.la \
ulogd_inppkt_UNIXSOCK.la

ulogd_inppkt_NFLOG_la_SOURCES = ulogd_inppkt_NFLOG.c ulogd_inppkt_NFLOG_la_LDFLAGS = -avoid-version -module $(LIBNETFILTER_LOG_LIBS) ulogd_inppkt_NFLOG_la_CFLAGS = $(AM_CFLAGS) $(LIBNETFILTER_LOG_CFLAGS)

input/packet/Makefile.am +3 -0
+else
+pkglib_LTLIBRARIES = ulogd_inppkt_ULOG.la ulogd_inppkt_UNIXSOCK.la
+endif

You can use

Quoted 8 lines

pkglib_LTLIBRARIES = ulogd_inppkt_ULOG.la ulogd_inppkt_UNIXSOCK.la if BUILD_NFLOG
pkglib_LTLIBRARIES += ulogd_inppkt_NFLOG.la
...
endif

So that ulogd_inppkt_ULOG.la ulogd_inppkt_UNIXSOCK.la does not have to be listed twice.

You're right that's a better construction.

BR,
--
Eric

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

PATCH 4/4 configure: display info about build plugins

In reply to Eric Leblond

This patch modifies configure to display the list of plugins that will be built.

---
 configure.ac |   42 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)
configure.ac +40 -2
index 930aef0..c70887d 100644
@@ -22,6 +22,11 @@ AC_SUBST([libdl_LIBS])
 AC_SEARCH_LIBS([pcap_close], [pcap], [libpcap_LIBS="-lpcap"; LIBS=""])
 AC_SUBST([libpcap_LIBS])
 AM_CONDITIONAL([HAVE_PCAP], [test -n "$libpcap_LIBS"])
+if test "x$libpcap_LIBS" != "x"; then
+	enable_pcap="yes"
+else
+	enable_pcap="no"
+fi
 
 dnl Checks for header files.
 AC_HEADER_DIRENT
@@ -68,17 +73,35 @@ AM_CONDITIONAL([BUILD_NFACCT], [test "x$enable_nfacct" = "xyes"])
 
 CT_CHECK_POSTGRES_DB()
 AM_CONDITIONAL(HAVE_PGSQL, test "x$PQLIBPATH" != "x")
+if test "x$PQLIBPATH" != "x"; then
+	enable_pgsql="yes"
+else
+	enable_pgsql="no"
+fi
 
 CT_CHECK_MYSQL_DB()
 AM_CONDITIONAL(HAVE_MYSQL, test "x$MYSQL_LIB" != "x")
+if test "x$MYSQL_LIB" != "x"; then
+	enable_mysql="yes"
+else
+	enable_mysql="no"
+fi
 
 PKG_CHECK_MODULES([libsqlite3], [sqlite3], [], [:])
 AM_CONDITIONAL([HAVE_SQLITE3], [test -n "$libsqlite3_LIBS"])
+if test "x$libsqlite3_LIBS" != "x"; then
+	enable_sqlite3="yes"
+else
+	enable_sqlite3="no"
+fi
 
 CT_CHECK_DBI()
 AM_CONDITIONAL(HAVE_DBI, test "x$DBI_LIB" != "x")
-
-
+if test "x$DBI_LIB" != "x"; then
+	enable_dbi="yes"
+else
+	enable_dbi="no"
+fi
 
 dnl AC_SUBST(DATABASE_DIR)
 dnl AC_SUBST(DATABASE_LIB)
@@ -102,3 +125,18 @@ AC_CONFIG_FILES(include/Makefile include/ulogd/Makefile include/libipulog/Makefi
 	  output/dbi/Makefile \
 	  src/Makefile Makefile Rules.make)
 AC_OUTPUT
+
+echo "
+Ulogd configuration:
+  Input plugins:
+    NFLOG plugin:			${enable_nflog}
+    NFCT plugin:			${enable_nfct}
+    NFACCT plugin:			${enable_nfacct}
+  Output plugins:
+    PCAP plugin:			${enable_pcap}
+    PGSQL plugin:			${enable_pgsql}
+    MySQL plugin:			${enable_mysql}
+    SQLITE3 plugin:			${enable_sqlite3}
+    DBI plugin:				${enable_dbi}
+"
+echo "You can now run 'make' and 'make install'"
Signature · 1 line
1.7.10.4