Skip to contentSkip to conversation

patches for an autotooled version of 'nftables'.

PATCH In review Giorgio Dal Molin 2 participants 14 messages Jul 7, 2014 netfilter

lore
Share & tools
lore
#0 lore raw

cover patches for an autotooled version of 'nftables'.

From: root <[email protected]>

Hi,

I'm sending a couple of patches to add autotools support to the 'nftables' project.

I would like to have some feedback on it and eventually see the patches merged on the main 'nftables' repo.

The patches are based on the version 0.3 of nftable:

commit id: ae73759150652213029718ecfa3017fa28e879c1

upstream.

The whole changes are divided in different commits for the sake of clarity and documentation but it's not really possible to build any of the tree states in between, only the last 'autotool conversion: ...' state is usable.

Target of these patches is a sw package that is easier to configure, cross-compile, build in parallel also from a different build directory, and that supports creating release tar archives.

One of my tests was to create a release distribution from there:

# cd /tmp
# mkdir nft_build
# cd nft_build
# /tmp/nftable-0.3_autotooled/autogen.sh
# /tmp/nftable-0.3_autotooled/configure
# make distcheck

The 'distcheck' target tries to configure/build/locally-install the package and if it's all right it produces a tar archive with all that's needed for a release.

giorgio

Giorgio (5):
autotool conversion: use pkg-config to find 'libmnl', libnftnl' and

    'ncurses'.

autotool conversion: converted the subdir. 'src/' autotool conversion: Converted the support for the 'doc/' subdir. autotools conversion: commit the rest of the configure.ac changes. autotool conversion: updated the files .gitignore

root (2):
autotool conversion: autotools support for the subdir.
'files/nftables'.
autotools conversion: include the header 'config.h' in every C source
file.

 .gitignore                   |   19 +-
 autogen.sh                   |   10 +-
 configure.ac                 |  135 ++-
 doc/Makefile.am              |   12 +
 doc/Makefile.in              |   20 -
 files/nftables/Makefile.am   |   13 +
 files/nftables/bridge-filter |    2 +-
 files/nftables/inet-filter   |    2 +-
 files/nftables/ipv4-filter   |    2 +-
 files/nftables/ipv4-mangle   |    2 +-
 files/nftables/ipv4-nat      |    2 +-
 files/nftables/ipv6-filter   |    2 +-
 files/nftables/ipv6-mangle   |    2 +-
 files/nftables/ipv6-nat      |    2 +-
 m4/ax_lib_readlibe.m4        |  107 ++
 src/.gitignore               |    4 +-
 src/Makefile.am              |   45 +
 src/Makefile.in              |   31 -
 src/cli.c                    |    3 +
 src/ct.c                     |    3 +
 src/datatype.c               |    3 +
 src/erec.c                   |    3 +
 src/evaluate.c               |    3 +
 src/expression.c             |    3 +
 src/exthdr.c                 |    3 +
 src/gmputil.c                |    3 +
 src/main.c                   |    3 +
 src/meta.c                   |    3 +
 src/mnl.c                    |    3 +
 src/netlink.c                |    3 +
 src/netlink_delinearize.c    |    3 +
 src/netlink_linearize.c      |    3 +
 src/parser.y                 | 2251 ------------------------------------------
 src/payload.c                |    3 +
 src/proto.c                  |    3 +
 src/rbtree.c                 |    3 +
 src/rule.c                   |    3 +
 src/scanner.l                |    3 +-
 src/segtree.c                |    3 +
 src/statement.c              |    3 +
 src/utils.c                  |    3 +
 src/yacc_parser.y            | 2251 ++++++++++++++++++++++++++++++++++++++++++
 42 files changed, 2610 insertions(+), 2370 deletions(-)
 create mode 100644 doc/Makefile.am
 delete mode 100644 doc/Makefile.in
 create mode 100644 files/nftables/Makefile.am
 create mode 100644 m4/ax_lib_readlibe.m4
 create mode 100644 src/Makefile.am
 delete mode 100644 src/Makefile.in
 delete mode 100644 src/parser.y
 create mode 100644 src/yacc_parser.y
Signature · 1 line
2.0.1
#1 lore raw

PATCH 1/7 autotool conversion: autotools support for the subdir. 'files/nftables'.

From: root <[email protected]>

We added the marker @sbindir@ to the first line of the scripts so it can be replaced once the scripts are installed.

---
 files/nftables/Makefile.am   | 13 +++++++++++++
 files/nftables/bridge-filter |  2 +-
 files/nftables/inet-filter   |  2 +-
 files/nftables/ipv4-filter   |  2 +-
 files/nftables/ipv4-mangle   |  2 +-
 files/nftables/ipv4-nat      |  2 +-
 files/nftables/ipv6-filter   |  2 +-
 files/nftables/ipv6-mangle   |  2 +-
 files/nftables/ipv6-nat      |  2 +-
 9 files changed, 21 insertions(+), 8 deletions(-)
 create mode 100644 files/nftables/Makefile.am
files/nftables/Makefile.am new file +13 -0
new file mode 100644
index 0000000..32dced3
@@ -0,0 +1,13 @@
+
+pkgsysconfdir = ${sysconfdir}/nftables
+dist_pkgsysconf_DATA =	bridge-filter	\
+			inet-filter	\
+			ipv4-filter	\
+			ipv4-mangle	\
+			ipv4-nat	\
+			ipv6-filter	\
+			ipv6-mangle	\
+			ipv6-nat
+
+install-data-hook:
+	${SED} -i 's|@sbindir[@]|${sbindir}|g' ${DESTDIR}${pkgsysconfdir}/*
files/nftables/bridge-filter +1 -1
index 54779c4..2add455 100644
@@ -1,4 +1,4 @@
-#! nft -f
+#! @sbindir@nft -f
 
 table bridge filter {
 	chain input		{ type filter hook input priority -200; }
files/nftables/inet-filter +1 -1
index 9f3108f..f572db5 100644
@@ -1,4 +1,4 @@
-#! nft -f
+#! @sbindir@nft -f
 
 table inet filter {
 	chain input		{ type filter hook input priority 0; }
files/nftables/ipv4-filter +1 -1
index 3174e7a..a4ca7f2 100644
@@ -1,4 +1,4 @@
-#! nft -f
+#! @sbindir@nft -f
 
 table filter {
 	chain input		{ type filter hook input priority 0; }
files/nftables/ipv4-mangle +1 -1
index 27327d3..be564a5 100644
@@ -1,4 +1,4 @@
-#! nft -f
+#! @sbindir@nft -f
 
 table mangle {
 	chain output		{ type route hook output priority -150; }
files/nftables/ipv4-nat +1 -1
index 99d6951..01c6c3d 100644
@@ -1,4 +1,4 @@
-#! nft -f
+#! @sbindir@nft -f
 
 table nat {
 	chain prerouting	{ type nat hook prerouting priority -150; }
files/nftables/ipv6-filter +1 -1
index 98fce02..ce4d7de 100644
@@ -1,4 +1,4 @@
-#! nft -f
+#! @sbindir@nft -f
 
 table ip6 filter {
 	chain input		{ type filter hook input priority 0; }
files/nftables/ipv6-mangle +1 -1
index 7274353..fa32402 100644
@@ -1,4 +1,4 @@
-#! nft -f
+#! @sbindir@nft -f
 
 table ip6 mangle {
 	chain output		{ type route hook output priority -150; }
files/nftables/ipv6-nat +1 -1
index 33ecf9b..3f57c56 100644
@@ -1,4 +1,4 @@
-#! nft -f
+#! @sbindir@nft -f
 
 table ip6 nat {
 	chain prerouting	{ type nat hook prerouting priority -150; }
Signature · 1 line
2.0.1
#2 lore raw

PATCH 2/7 autotool conversion: use pkg-config to find 'libmnl', libnftnl' and 'ncurses'.

In reply to Giorgio Dal Molin

From: Giorgio <[email protected]>

Use pkg-config to find the compile and link flags for 'libnftnl' and 'libmnl'.

Use the special macro AX_LIB_READLINE to check for libreadline and its dependencies.

The macro is part of the 'autoconf-archive' project:

https://www.gnu.org/software/autoconf-archive/ax_lib_readline.html

---
 configure.ac          |  19 +++++----
 m4/ax_lib_readlibe.m4 | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am       |  45 +++++++++++++++++++++
 3 files changed, 163 insertions(+), 8 deletions(-)
 create mode 100644 m4/ax_lib_readlibe.m4
 create mode 100644 src/Makefile.am
configure.ac +11 -8
index 3a7647f..b31fe46 100644
@@ -62,17 +62,20 @@ then
 fi
 
 # Checks for libraries.
-AC_CHECK_LIB([mnl], [mnl_socket_open], ,
-	     AC_MSG_ERROR([No suitable version of libmnl found]))
 
-AC_CHECK_LIB([nftnl], [nft_rule_alloc], ,
-	     AC_MSG_ERROR([No suitable version of libnftnl found]))
+dnl Check for package libnftnl
+PKG_CHECK_MODULES(LIBMNL, [libmnl], , AC_MSG_ERROR([No suitable version of libmnl found]))
+AC_SUBST(LIBMNL_CFLAGS)
+AC_SUBST(LIBMNL_LIBS)
 
-AC_CHECK_LIB([gmp], [__gmpz_init], ,
-	     AC_MSG_ERROR([No suitable version of libgmp found]))
+dnl Check for package libnftnl
+PKG_CHECK_MODULES(LIBNFTNL, [libnftnl], , AC_MSG_ERROR([No suitable version of libnftnl found]))
+AC_SUBST(LIBNFTNL_CFLAGS)
+AC_SUBST(LIBNFTNL_LIBS)
 
-AC_CHECK_LIB([readline], [readline], ,
-	     AC_MSG_ERROR([No suitable version of libreadline found]))
+AC_CHECK_LIB([gmp], [__gmpz_init], , AC_MSG_ERROR([No suitable version of libgmp found]))
+
+AX_LIB_READLINE
 
 # Checks for header files.
 AC_HEADER_STDC
m4/ax_lib_readlibe.m4 new file +107 -0

107 lines not on this page · raw message

src/Makefile.am new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.0.1
#3 lore raw

Re: [PATCH 2/7] autotool conversion: use pkg-config to find 'libmnl', libnftnl' and 'ncurses'.

configure.ac then · line 69

Quoted 5 lines · Giorgio Dal Molin
configure.ac +4 -1
-	     AC_MSG_ERROR([No suitable version of libnftnl found]))
+dnl Check for package libnftnl
+PKG_CHECK_MODULES(LIBMNL, [libmnl], , AC_MSG_ERROR([No suitable version of libmnl found]))
+AC_SUBST(LIBMNL_CFLAGS)
+AC_SUBST(LIBMNL_LIBS)

Substing CFLAGS and LIBS is not needed; this is already included in PKG_CHECK_MODULES.

Quoted 5 lines
src/Makefile.am new file +2 -0
@@ -0,0 +1,45 @@
+sbin_PROGRAMS = nft
+

src/Makefile.am line 12

Quoted 10 lines
src/Makefile.am new file +10 -0
+nft_CFLAGS =	-fno-strict-aliasing							\
+		-Wall									\
+		-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations		\
+		-Wdeclaration-after-statement -Wsign-compare -Winit-self		\
+		-Wformat-nonliteral -Wformat-security -Wmissing-format-attribute	\
+		-Wcast-align -Wundef -Wbad-function-cast				\
+		-Waggregate-return -Wunused -Wwrite-strings				\
+		@LIBMNL_CFLAGS@ @LIBNFTNL_CFLAGS@
+
+nft_CPPFLAGS = -I${srcdir}/../include @DEBUG_CPPFLAGS@

As the pkg-config CFLAGS are really just CPPFLAGS, @LIBMNL_CFLAGS@ and @LIBNFTNL_CFLAGS@ should be put into nft_CPPFLAGS instead. In fact, you can just use ${LIBMNL_CFLAGS} and ${LIBNFTNL_CFLAGS} (same for _LIBS) instead, which ensures that you can override them at make time. Also, if nft_CPPFLAGS is not strictly necessary, use AM_CPPFLAGS (and AM_CFLAGS) instead.

See also the autotooling I had done earlier
and which you and me have talked about ;)

#4 lore raw

Aw: Re: [PATCH 2/7] autotool conversion: use pkg-config to find 'libmnl', libnftnl' and 'ncurses'.

----- Original Nachricht ----

Von:     Jan Engelhardt <[email protected]>
An:      Giorgio Dal Molin <[email protected]>
Datum:   07.07.2014 15:08
Betreff: Re: [PATCH 2/7] autotool conversion: use pkg-config to find 'libmnl',

libnftnl' and 'ncurses'.

Quoted 11 lines · Giorgio Dal Molin

configure.ac then

Quoted 3 lines
configure.ac +2 -1
-	     AC_MSG_ERROR([No suitable version of libnftnl found]))
+dnl Check for package libnftnl
+PKG_CHECK_MODULES(LIBMNL, [libmnl], , AC_MSG_ERROR([No suitable version of

libmnl found]))

configure.ac then · line 69

Quoted 2 lines
configure.ac +2 -0
+AC_SUBST(LIBMNL_CFLAGS)
+AC_SUBST(LIBMNL_LIBS)

Substing CFLAGS and LIBS is not needed; this is already included in PKG_CHECK_MODULES.

OK.

Quoted 24 lines
Quoted 6 lines
src/Makefile.am new file +2 -0
@@ -0,0 +1,45 @@
+sbin_PROGRAMS = nft
+

src/Makefile.am line 12

Quoted 10 lines
src/Makefile.am new file +10 -0
+nft_CFLAGS =	-fno-strict-aliasing							\
+		-Wall									\
+		-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations		\
+		-Wdeclaration-after-statement -Wsign-compare -Winit-self		\
+		-Wformat-nonliteral -Wformat-security -Wmissing-format-attribute	\
+		-Wcast-align -Wundef -Wbad-function-cast				\
+		-Waggregate-return -Wunused -Wwrite-strings				\
+		@LIBMNL_CFLAGS@ @LIBNFTNL_CFLAGS@
+
+nft_CPPFLAGS = -I${srcdir}/../include @DEBUG_CPPFLAGS@

As the pkg-config CFLAGS are really just CPPFLAGS, @LIBMNL_CFLAGS@ and @LIBNFTNL_CFLAGS@ should be put into nft_CPPFLAGS instead. In fact, you can just use ${LIBMNL_CFLAGS} and ${LIBNFTNL_CFLAGS} (same for _LIBS) instead, which ensures that you can override them at make time. Also, if nft_CPPFLAGS is not strictly necessary, use AM_CPPFLAGS (and AM_CFLAGS) instead.

Quoted 2 lines

See also the autotooling I had done earlier
and which you and me have talked about ;)

OK.

giorgio

#5 lore raw

PATCH 3/7 autotool conversion: converted the subdir. 'src/'

In reply to Giorgio Dal Molin

From: Giorgio <[email protected]>

Use specialized test macros to find 'yacc' and 'lex' in the configure.ac.

Renamed the file 'src/parser.y' to 'src/yacc_parser.y' to avoid having two header files with the same name, 'parser.h': one under 'src/', generated by 'yacc' from 'parser.y' and the other under 'include/'.

Added an %option line to 'src/scanner.l': this new %option directive lets us save a custom recipe in the 'src/Makefile.am'; it replaces the 'lex' command line option '--outfile=scanner.c'.
We don't have any explicit make recipe to call 'lex' on 'scanner.l' to generate 'scanner.c' and 'scanner.h' as in the old 'Makefile.rules'; listing the file 'scanner.l' in the variable 'nft_SOURCES' of 'src/Makefile.am' is now enough.

---
 configure.ac      |   13 +-
 src/Makefile.in   |   31 -
 src/parser.y      | 2251 -----------------------------------------------------
 src/scanner.l     |    3 +-
 src/yacc_parser.y | 2251 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 2255 insertions(+), 2294 deletions(-)
 delete mode 100644 src/Makefile.in
 delete mode 100644 src/parser.y
 create mode 100644 src/yacc_parser.y
configure.ac +2 -11
index b31fe46..7070cb8 100644
@@ -24,6 +24,8 @@ AC_PROG_CC
 AC_PROG_MKDIR_P
 AC_PROG_INSTALL
 AC_PROG_SED
+AC_PROG_YACC
+AM_PROG_LEX
 
 AC_CHECK_PROG(CONFIG_MAN1, [docbook2x-man], [y], [n])
 if test "$CONFIG_MAN1" == "y"
@@ -49,17 +51,6 @@ then
 	AC_MSG_WARN([dblatex not found, no PDF manpages will be built])
 fi
 
-AC_PATH_PROG(LEX, [flex])
-if test -z "$LEX"
-then
-	AC_MSG_ERROR([No suitable version of flex found])
-fi
-
-AC_PATH_PROG(YACC, [bison])
-if test -z "$YACC"
-then
-	AC_MSG_ERROR([No suitable version of bison found])
-fi
 
 # Checks for libraries.
 
src/Makefile.in deleted +0 -31
deleted file mode 100644
index 8ac2b46..0000000
@@ -1,31 +0,0 @@
-PROGRAMS		+= nft
-
-nft-destdir		:= @sbindir@
-
-nft-obj			+= main.o
-nft-obj			+= cli.o
-nft-obj			+= rule.o
-nft-obj			+= statement.o
-nft-obj			+= datatype.o
-nft-obj			+= expression.o
-nft-obj			+= evaluate.o
-nft-obj			+= proto.o
-nft-obj			+= payload.o
-nft-obj			+= exthdr.o
-nft-obj			+= meta.o
-nft-obj			+= ct.o
-nft-obj			+= netlink.o
-nft-obj			+= netlink_linearize.o
-nft-obj			+= netlink_delinearize.o
-nft-obj			+= segtree.o
-nft-obj			+= rbtree.o
-nft-obj			+= gmputil.o
-nft-obj			+= utils.o
-nft-obj			+= erec.o
-nft-obj			+= mnl.o
-
-nft-obj			+= parser.o
-nft-extra-clean-files	+= parser.c parser.h
-
-nft-obj			+= scanner.o
-nft-extra-clean-files	+= scanner.c scanner.h
src/parser.y deleted +0 -2251

2,251 lines not on this page · raw message

src/scanner.l +2 -1
index 73a1a3f..e6b8127 100644
@@ -20,7 +20,7 @@
 #include <erec.h>
 #include <rule.h>
 #include <parser.h>
-#include "parser.h"
+#include "yacc_parser.h"
 
 #define YY_NO_INPUT
 
@@ -178,6 +178,7 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 %option yylineno
 %option nodefault
 %option warn
+%option outfile="scanner.c"
 
 %%
 
src/yacc_parser.y new file +2251 -0

678 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.0.1

Part of the diff is not shown here. View the raw message.

#6 lore raw

PATCH 4/7 autotools conversion: include the header 'config.h' in every C source file.

In reply to Giorgio Dal Molin

From: root <[email protected]>

Added an #include <config.h> to all the C source files so that the results of the tests in the configure script are available to all the compilation units.

We could have added the include also to 'yacc_parser.y' and 'scanner.l' but we don't, because it is not strictly needed and to avoid to define the variable 'VERSION' two times.

---
 src/cli.c                 | 3 +++
 src/ct.c                  | 3 +++
 src/datatype.c            | 3 +++
 src/erec.c                | 3 +++
 src/evaluate.c            | 3 +++
 src/expression.c          | 3 +++
 src/exthdr.c              | 3 +++
 src/gmputil.c             | 3 +++
 src/main.c                | 3 +++
 src/meta.c                | 3 +++
 src/mnl.c                 | 3 +++
 src/netlink.c             | 3 +++
 src/netlink_delinearize.c | 3 +++
 src/netlink_linearize.c   | 3 +++
 src/payload.c             | 3 +++
 src/proto.c               | 3 +++
 src/rbtree.c              | 3 +++
 src/rule.c                | 3 +++
 src/segtree.c             | 3 +++
 src/statement.c           | 3 +++
 src/utils.c               | 3 +++
 21 files changed, 63 insertions(+)
src/cli.c +3 -0
index f748a0e..bf3caea 100644
@@ -11,6 +11,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stdlib.h>
 #include <stdio.h>
src/ct.c +3 -0
index 30639b2..98e7fec 100644
@@ -9,6 +9,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stddef.h>
 #include <stdlib.h>
src/datatype.c +3 -0
index 55af227..2d773f2 100644
@@ -7,6 +7,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stdlib.h>
 #include <string.h>
src/erec.c +3 -0
index 4930085..500691e 100644
@@ -7,6 +7,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stdio.h>
 #include <string.h>
src/evaluate.c +3 -0
index 2330bbb..e66e8a2 100644
@@ -7,6 +7,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stddef.h>
 #include <stdlib.h>
src/expression.c +3 -0
index fa14d99..b2a2f04 100644
@@ -7,6 +7,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stddef.h>
 #include <stdlib.h>
src/exthdr.c +3 -0
index a619ecc..9d73d07 100644
@@ -9,6 +9,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stddef.h>
 #include <stdlib.h>
src/gmputil.c +3 -0
index cb46445..38eafde 100644
@@ -7,6 +7,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stddef.h>
 #include <stdlib.h>
src/main.c +3 -0
index a446bc6..142e99c 100644
@@ -7,6 +7,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stdlib.h>
 #include <stddef.h>
src/meta.c +3 -0
index 80f88ff..d82c524 100644
@@ -9,6 +9,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stddef.h>
 #include <stdlib.h>
src/mnl.c +3 -0
index a816106..dd5f172 100644
@@ -7,6 +7,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <libmnl/libmnl.h>
 #include <libnftnl/common.h>
src/netlink.c +3 -0
index 2e7c572..a0d21f6 100644
@@ -8,6 +8,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <string.h>
 #include <fcntl.h>
src/netlink_delinearize.c +3 -0
index 5c6ca80..7c02138 100644
@@ -8,6 +8,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stdlib.h>
 #include <stdbool.h>
src/netlink_linearize.c +3 -0
index 5c1b46d..ae3eb2d 100644
@@ -8,6 +8,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <linux/netfilter/nf_tables.h>
 
src/payload.c +3 -0
index a1785a5..3d2a2ae 100644
@@ -9,6 +9,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stddef.h>
 #include <stdlib.h>
src/proto.c +3 -0
index 0a37a65..0179ddf 100644
@@ -8,6 +8,9 @@
  * published by the Free Software Foundation.
  *
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stddef.h>
 #include <stdlib.h>
src/rbtree.c +3 -0
index 325c012..8cb6dd8 100644
@@ -18,6 +18,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <rbtree.h>
 
src/rule.c +3 -0
index a7bc6f4..ecaaa2e 100644
@@ -7,6 +7,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stddef.h>
 #include <stdlib.h>
src/segtree.c +3 -0
index 1785f64..0258684 100644
@@ -7,6 +7,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stdlib.h>
 #include <inttypes.h>
src/statement.c +3 -0
index 2dd3f18..42fb37f 100644
@@ -7,6 +7,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stddef.h>
 #include <stdlib.h>
src/utils.c +3 -0
index 96ff419..f68ab57 100644
@@ -7,6 +7,9 @@
  *
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stddef.h>
 #include <stdlib.h>
Signature · 1 line
2.0.1
#7 lore raw

PATCH 5/7 autotool conversion: Converted the support for the 'doc/' subdir.

In reply to Giorgio Dal Molin

From: Giorgio <[email protected]>

To generate the nft.8 man page the configure script searches for the tools 'docbookx2-man' and 'db2x_docbook2man'; if at least one is found then the man page is generated. To force the system not to generate the man page use the option '--disable-man'.

To generate the pdf doc file the configure script searches for the tool 'dblatex'; if it is found then the pdf doc file is generated. To force the system not to generate the pdf doc file use the option '--disable-pdf'.

---
 configure.ac    | 73 +++++++++++++++++++++++++++++++++++++++------------------
 doc/Makefile.am | 12 ++++++++++
 doc/Makefile.in | 20 ----------------
 3 files changed, 62 insertions(+), 43 deletions(-)
 create mode 100644 doc/Makefile.am
 delete mode 100644 doc/Makefile.in
configure.ac +50 -23
index 7070cb8..18f6f51 100644
@@ -27,30 +27,57 @@ AC_PROG_SED
 AC_PROG_YACC
 AM_PROG_LEX
 
-AC_CHECK_PROG(CONFIG_MAN1, [docbook2x-man], [y], [n])
-if test "$CONFIG_MAN1" == "y"
-then
-	CONFIG_MAN=y
-	DB2MAN=docbook2x-man
-else
-	AC_CHECK_PROG(CONFIG_MAN2, [db2x_docbook2man], [y], [n])
-	if test "$CONFIG_MAN2" == "y"
-	then
-		CONFIG_MAN=y
-		DB2MAN=db2x_docbook2man
-	else
-		AC_MSG_WARN([docbookx2-man/db2x_docbook2man not found, no manpages will be built])
-	fi
-fi
-AC_SUBST(CONFIG_MAN)
-AC_SUBST(DB2MAN)
-
-AC_CHECK_PROG(CONFIG_PDF, dblatex, y, n)
-if test "$CONFIG_PDF" != "y"
-then
-	AC_MSG_WARN([dblatex not found, no PDF manpages will be built])
-fi
+AC_CHECK_PROG(DOCBOOK2X_MAN, [docbook2x-man], [found], [no])
+AC_CHECK_PROG(DB2X_DOCBOOK2MAN, [db2x_docbook2man], [found], [no])
+AS_CASE([$DOCBOOK2X_MAN],
+	[found],[
+		DB2MAN=docbook2x-man
+		NFT_8=nft.8
+		],
+	[AS_CASE([$DB2X_DOCBOOK2MAN],
+		[found],[
+			DB2MAN=db2x_docbook2man
+			NFT_8=nft.8
+			],
+		[AC_MSG_WARN([docbookx2-man/db2x_docbook2man not found, no manpages will be built])]
+	)]
+)
+
+AC_ARG_ENABLE([man], AS_HELP_STRING([--enable-man], [Enable generating the man page nft.8. Requires docbook2x-man or db2x_docbook2man.]))
+
+AC_MSG_CHECKING([whether to generate the man page])
+AS_CASE([${enable_man}],
+	[yes],[
+		AS_IF([test -z "$DB2MAN"],AC_MSG_ERROR([No tool found to generate the man page. Please install either docbook2x-man or db2x_docbook2man.]))
+		AC_MSG_RESULT(yes)
+	], [
+	NFT_8=""
+	AC_MSG_RESULT(no)
+	]
+)
 
+AC_SUBST(DB2MAN)
+AC_SUBST(NFT_8)
+
+AC_CHECK_PROG(DBLATEX, [dblatex], [found], [no])
+AS_CASE([$DBLATEX],
+	[found],[NFT_PDF=nft.pdf],
+	[AC_MSG_WARN([dblatex not found, no PDF manpages will be built])]
+)
+
+AC_MSG_CHECKING([whether to generate the pdf doc])
+AC_ARG_ENABLE([pdf], AS_HELP_STRING([--enable-pdf], [Enable generating the pdf doc file nft.pdf. Requires dblatex.]))
+AS_CASE([${enable_pdf}],
+	[yes],[
+		AS_IF([test -z "$DBLATEX"], AC_MSG_ERROR([No tool found to generate the pdf doc. Please install dblatex.]))
+		AC_MSG_RESULT(yes)
+	],[
+	NFT_PDF=""
+	AC_MSG_RESULT(no)
+	]
+)
+
+AC_SUBST(NFT_PDF)
 
 # Checks for libraries.
 
doc/Makefile.am new file +12 -0
new file mode 100644
index 0000000..6ea973a
@@ -0,0 +1,12 @@
+man_MANS = @NFT_8@
+pdf_DATA = @NFT_PDF@
+
+pdfdir=${docdir}/pdf
+
+nft.pdf: nft.xml
+	@echo -e "  PDF\t\t$@"
+	@dblatex -q -t pdf -o $@ $<
+
+nft.8: nft.xml
+	@echo -e "  MAN\t\t$@"
+	@$(DB2MAN) --xinclude $<
doc/Makefile.in deleted +0 -20
deleted file mode 100644
index 1ec856c..0000000
@@ -1,20 +0,0 @@
-mandocs-@CONFIG_MAN@	+= doc/nft.8
-pdfdocs-@CONFIG_PDF@	+= doc/nft.pdf
-
-all:		$(mandocs-y) $(pdfdocs-y)
-clean:
-		@echo -e "  CLEAN\t\tdoc"
-		$(RM) $(mandocs-y) $(pdfdocs-y)
-
-install:	$(mandocs-y) $(pdfdocs-y)
-		@echo -e "  INSTALL\tdoc"
-		if test -n "$(mandocs-y)"; then \
-			$(MKDIR_P) $(DESTDIR)/${mandir}/man8 ;\
-			$(INSTALL) -m 755 -p $(mandocs-y) \
-					$(DESTDIR)/${mandir}/man8/ ;\
-		fi
-		if test -n "$(pdfdocs-y)"; then \
-			$(MKDIR_P) $(DESTDIR)/${pdfdir} ;\
-			$(INSTALL) -m 755 -p $(pdfdocs-y) \
-					$(DESTDIR)/${pdfdir}/ ;\
-		fi
Signature · 1 line
2.0.1
#8 lore raw

Re: [PATCH 5/7] autotool conversion: Converted the support for the 'doc/' subdir.

Quoted 48 lines · Giorgio Dal Molin
configure.ac +38 -0
+		[AC_MSG_WARN([docbookx2-man/db2x_docbook2man not found, no manpages will be built])]
+	)]
+)
+
+AC_ARG_ENABLE([man], AS_HELP_STRING([--enable-man], [Enable generating the man page nft.8. Requires docbook2x-man or db2x_docbook2man.]))
+
+AC_MSG_CHECKING([whether to generate the man page])
+AS_CASE([${enable_man}],
+	[yes],[
+		AS_IF([test -z "$DB2MAN"],AC_MSG_ERROR([No tool found to generate the man page. Please install either docbook2x-man or db2x_docbook2man.]))
+		AC_MSG_RESULT(yes)
+	], [
+	NFT_8=""
+	AC_MSG_RESULT(no)
+	]
+)
 
+AC_SUBST(DB2MAN)
+AC_SUBST(NFT_8)
+
+AC_CHECK_PROG(DBLATEX, [dblatex], [found], [no])
+AS_CASE([$DBLATEX],
+	[found],[NFT_PDF=nft.pdf],
+	[AC_MSG_WARN([dblatex not found, no PDF manpages will be built])]
+)
+
+AC_MSG_CHECKING([whether to generate the pdf doc])
+AC_ARG_ENABLE([pdf], AS_HELP_STRING([--enable-pdf], [Enable generating the pdf doc file nft.pdf. Requires dblatex.]))
+AS_CASE([${enable_pdf}],
+	[yes],[
+		AS_IF([test -z "$DBLATEX"], AC_MSG_ERROR([No tool found to generate the pdf doc. Please install dblatex.]))
+		AC_MSG_RESULT(yes)
+	],[
+	NFT_PDF=""
+	AC_MSG_RESULT(no)
+	]
+)
+
+AC_SUBST(NFT_PDF)

# Checks for libraries.

doc/Makefile.am new file +0 -0
new file mode 100644
index 0000000..6ea973a

doc/Makefile.am line 8

Quoted 8 lines
doc/Makefile.am new file +8 -0
@@ -0,0 +1,12 @@
+man_MANS = @NFT_8@
+pdf_DATA = @NFT_PDF@
+
+pdfdir=${docdir}/pdf
+
+nft.pdf: nft.xml
+	@echo -e "  PDF\t\t$@"
+	@dblatex -q -t pdf -o $@ $<

automake already provided silencers that should be used in this case.

.xml.pdf:

	${AM_V_GEN}dblatex -q -t pdf -o $@ $<

.xml.8:

	${AM_V_GEN}${DB2MAN} --xinclude $<
#9 lore raw

Aw: Re: [PATCH 5/7] autotool conversion: Converted the support for the 'doc/' subdir.

----- Original Nachricht ----

Von:     Jan Engelhardt <[email protected]>
An:      Giorgio Dal Molin <[email protected]>
Datum:   07.07.2014 15:12
Betreff: Re: [PATCH 5/7] autotool conversion: Converted the support for the

'doc/' subdir.

Quoted 66 lines · Giorgio Dal Molin

Review

Quoted 1 line
(quoted diff) +1 -0
+		[AC_MSG_WARN([docbookx2-man/db2x_docbook2man not found, no manpages will

be built])]

configure.ac AC_PROG_SED

Quoted 4 lines
configure.ac +4 -0
+	)]
+)
+
+AC_ARG_ENABLE([man], AS_HELP_STRING([--enable-man], [Enable generating the

man page nft.8. Requires docbook2x-man or db2x_docbook2man.]))

configure.ac AC_PROG_SED

Quoted 5 lines
configure.ac +5 -0
+
+AC_MSG_CHECKING([whether to generate the man page])
+AS_CASE([${enable_man}],
+	[yes],[
+		AS_IF([test -z "$DB2MAN"],AC_MSG_ERROR([No tool found to generate the

man page. Please install either docbook2x-man or db2x_docbook2man.]))

Quoted 8 lines
configure.ac +7 -0
+		AC_MSG_RESULT(yes)
+	], [
+	NFT_8=""
+	AC_MSG_RESULT(no)
+	]
+)
 
+AC_SUBST(DB2MAN)

configure.ac AC_PROG_SED

Quoted 10 lines
configure.ac +10 -0
+AC_SUBST(NFT_8)
+
+AC_CHECK_PROG(DBLATEX, [dblatex], [found], [no])
+AS_CASE([$DBLATEX],
+	[found],[NFT_PDF=nft.pdf],
+	[AC_MSG_WARN([dblatex not found, no PDF manpages will be built])]
+)
+
+AC_MSG_CHECKING([whether to generate the pdf doc])
+AC_ARG_ENABLE([pdf], AS_HELP_STRING([--enable-pdf], [Enable generating the

pdf doc file nft.pdf. Requires dblatex.]))

configure.ac AC_PROG_SED

Quoted 3 lines
configure.ac +3 -0
+AS_CASE([${enable_pdf}],
+	[yes],[
+		AS_IF([test -z "$DBLATEX"], AC_MSG_ERROR([No tool found to generate the

pdf doc. Please install dblatex.]))

Quoted 17 lines
configure.ac +8 -0
+		AC_MSG_RESULT(yes)
+	],[
+	NFT_PDF=""
+	AC_MSG_RESULT(no)
+	]
+)
+
+AC_SUBST(NFT_PDF)

# Checks for libraries.

doc/Makefile.am new file +0 -0
new file mode 100644
index 0000000..6ea973a

doc/Makefile.am line 8

Quoted 8 lines
doc/Makefile.am new file +8 -0
@@ -0,0 +1,12 @@
+man_MANS = @NFT_8@
+pdf_DATA = @NFT_PDF@
+
+pdfdir=${docdir}/pdf
+
+nft.pdf: nft.xml
+	@echo -e "  PDF\t\t$@"
+	@dblatex -q -t pdf -o $@ $<

automake already provided silencers that should be used in this case.

Quoted 6 lines

.xml.pdf:

	${AM_V_GEN}dblatex -q -t pdf -o $@ $<

.xml.8:

	${AM_V_GEN}${DB2MAN} --xinclude $<

OK.

giorgio

#10 lore raw

PATCH 6/7 autotools conversion: commit the rest of the configure.ac changes.

In reply to Giorgio Dal Molin

From: Giorgio <[email protected]>

Mainly the handling of the option '--enable-debug' and the definition of the cpp variable DEFAULT_INCLUDE_PATH; the definition is written to the generated header 'config.h', included by all the 'src/*.c'.

Also updated the script 'autogen.sh' to support calling it from a build directory different from the package root.

---
 autogen.sh   | 10 ++++++++--
 configure.ac | 30 ++++++++++++++++++++++++------
 2 files changed, 32 insertions(+), 8 deletions(-)
autogen.sh +8 -2
index a62e737..ce6243c 100755
@@ -1,4 +1,10 @@
-#!/bin/bash
+#! /bin/sh
 
-autoreconf -fi;
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+autoreconf -fvi || exit 1
 rm -Rf autom4te*.cache config.h.in~
configure.ac +24 -6
index 18f6f51..f36f6ec 100644
@@ -5,7 +5,13 @@ AC_PREREQ(2.61)
 
 AC_COPYRIGHT([Copyright (c) 2008 Patrick McHardy <[email protected]>])
 AC_INIT([nftables], [0.3], [[email protected]])
+AM_INIT_AUTOMAKE([dist-bzip2 dist-xz])
+AM_MAINTAINER_MODE([disable])
+AM_SILENT_RULES([yes])
+AC_CONFIG_MACRO_DIR([m4])
+
 AC_DEFINE([RELEASE_NAME], ["Support Edward Snowden"], [Release name])
+AC_DEFINE_UNQUOTED([DEFAULT_INCLUDE_PATH],["$confdir"],[define DEFAULT_INCLUDE_PATH])
 
 AC_CONFIG_SRCDIR([src/rule.c])
 AC_CONFIG_HEADER([config.h])
@@ -14,10 +20,15 @@ AC_DEFINE([_GNU_SOURCE], [], [Enable various GNU extensions])
 AC_DEFINE([_STDC_FORMAT_MACROS], [], [printf-style format macros])
 
 AC_ARG_ENABLE([debug],
-	      AS_HELP_STRING([--enable-debug], [Enable debugging]),
-	      [CONFIG_DEBUG="$(echo $enableval | cut -b1)"],
-	      [CONFIG_DEBUG="y"])
-AC_SUBST([CONFIG_DEBUG])
+	      AS_HELP_STRING([--enable-debug], [Enable debugging]))
+
+AS_CASE([$enable_debug],
+	[yes],[
+	AC_DEFINE([DEBUG],1,[Debug enabled])
+	DEBUG_CPPFLAGS="-g -DDEBUG"
+	])
+
+AC_SUBST(DEBUG_CPPFLAGS)
 
 # Checks for programs.
 AC_PROG_CC
@@ -123,6 +134,13 @@ AC_TYPE_UINT64_T
 # Checks for library functions.
 AC_CHECK_FUNCS([memmove memset strchr strdup strerror strtoull])
 
-AC_CONFIG_FILES([Makefile Makefile.defs Makefile.rules])
-AC_CONFIG_FILES([src/Makefile doc/Makefile files/Makefile])
+AC_CONFIG_FILES([	Makefile				\
+			src/Makefile				\
+			doc/Makefile				\
+			files/Makefile				\
+			files/nftables/Makefile			\
+			include/Makefile			\
+			include/linux/Makefile			\
+			include/linux/netfilter/Makefile	\
+		])
 AC_OUTPUT
Signature · 1 line
2.0.1
#11 lore raw

Re: [PATCH 6/7] autotools conversion: commit the rest of the configure.ac changes.

configure.ac AC_DEFINE([_GNU_SOURCE], [], [Enable various GNU extensions]) · line 31

Quoted 8 lines · Giorgio Dal Molin
configure.ac +8 -0
+
+AS_CASE([$enable_debug],
+	[yes],[
+	AC_DEFINE([DEBUG],1,[Debug enabled])
+	DEBUG_CPPFLAGS="-g -DDEBUG"
+	])
+
+AC_SUBST(DEBUG_CPPFLAGS)

-g should not be in DEBUG_CPPFLAGS (but DEBUG_CFLAGS) because it's strictly speaking not a preprocessor flag.

#12 lore raw

Aw: Re: [PATCH 6/7] autotools conversion: commit the rest of the configure.ac changes.

----- Original Nachricht ----

Von:     Jan Engelhardt <[email protected]>
An:      Giorgio Dal Molin <[email protected]>
Datum:   07.07.2014 15:14
Betreff: Re: [PATCH 6/7] autotools conversion: commit the rest of the

configure.ac changes.

Quoted 13 lines · Giorgio Dal Molin

configure.ac AC_DEFINE([_GNU_SOURCE], [], [Enable various GNU extensions]) · line 31

Quoted 8 lines
configure.ac +8 -0
+
+AS_CASE([$enable_debug],
+	[yes],[
+	AC_DEFINE([DEBUG],1,[Debug enabled])
+	DEBUG_CPPFLAGS="-g -DDEBUG"
+	])
+
+AC_SUBST(DEBUG_CPPFLAGS)

-g should not be in DEBUG_CPPFLAGS (but DEBUG_CFLAGS) because it's strictly speaking not a preprocessor flag.

OK, I changed it; I define/subst now two variable: DEBUG_CFLAGS='-g' and DEBUG_CPPFLAGS='-DDEBUG'.

giorgio

#13 lore raw

PATCH 7/7 autotool conversion: updated the files .gitignore

In reply to Giorgio Dal Molin

From: Giorgio <[email protected]>

Tuned the file '.gitignore' and 'src/.gitignore' to filter out the auto generated files.

---
 .gitignore     | 19 ++++++++++++-------
 src/.gitignore |  4 ++--
 2 files changed, 14 insertions(+), 9 deletions(-)
.gitignore +12 -7
index d26b395..998760d 100644
@@ -1,18 +1,23 @@
-# Dependency and object files
-.*.d
-*.o
-
 # Generated by autoconf/configure
 Makefile
-Makefile.defs
-Makefile.rules
+Makefile.in
 config.h
 config.h.in
-config.h.in~
 config.log
 config.status
 configure
 autom4te.cache
+missing
+compile
+depcomp
+stamp-h1
+ylwrap
+aclocal.m4
+install-sh
+.deps
+*.o
+*~
+
 
 # Debian package build temporary files
 build-stamp
src/.gitignore +2 -2
index 23e6ae0..50ff292 100644
@@ -1,5 +1,5 @@
-parser.c
-parser.h
+yacc_parser.c
+yacc_parser.h
 scanner.c
 scanner.h
 nft
Signature · 1 line
2.0.1