diff mbox

[nft,5/5] build: autotools conversion

Message ID 1415298349-985-6-git-send-email-pablo@netfilter.org
State Accepted
Delegated to: Pablo Neira
Headers show

Commit Message

Pablo Neira Ayuso Nov. 6, 2014, 6:25 p.m. UTC
1) This removes former Makefiles and install-sh (which is now
   automagically imported via autoreconf).

 Makefile.defs.in
 Makefile.in
 Makefile.rules.in
 src/Makefile.in
 install-sh (now automagically imported via autoreconf).

2) CFLAGS are left the same, they are integrated into Make_global.am.

3) Add m4 directory to the tree which only contains the .gitignore
   file.

4) include <config.h> whenever required.

5) Minor adjustments to scanner.l and parser_bison.y to compile cleanly
   with autotools.

The doc/ and files/ conversion to automake will come in follow up
patches.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 .gitignore         |   10 +-
 Make_global.am     |   10 ++
 Makefile.am        |    5 +
 Makefile.defs.in   |   42 --------
 Makefile.in        |    5 -
 Makefile.rules.in  |   96 -------------------
 configure.ac       |   15 ++-
 install-sh         |  269 ----------------------------------------------------
 m4/.gitignore      |    2 +
 src/Makefile.am    |   41 ++++++++
 src/Makefile.in    |   33 -------
 src/cli.c          |    1 +
 src/erec.c         |    1 +
 src/parser_bison.y |    1 -
 src/scanner.l      |    1 +
 15 files changed, 81 insertions(+), 451 deletions(-)
 create mode 100644 Make_global.am
 create mode 100644 Makefile.am
 delete mode 100644 Makefile.defs.in
 delete mode 100644 Makefile.in
 delete mode 100644 Makefile.rules.in
 delete mode 100755 install-sh
 create mode 100644 m4/.gitignore
 create mode 100644 src/Makefile.am
 delete mode 100644 src/Makefile.in

Comments

Jan Engelhardt Nov. 6, 2014, 8:29 p.m. UTC | #1
On Thursday 2014-11-06 19:25, Pablo Neira Ayuso wrote:

>+AM_CPPFLAGS += -DDEFAULT_INCLUDE_PATH="\"${sysconfdir}\"" -D__USE_GNU

feature_test_macros(7) specifies _GNU_SOURCE rather than __USE_GNU.

>+AM_CFLAGS = -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 # -Wshadow			\
>+	    -Waggregate-return -Wunused -Wwrite-strings				\
>+	    ${LIBMNL_CFLAGS} ${LIBNFTNL_CFLAGS}

You have a # in there, which causes the remaining -W and -I from 
LIBMNL_CFLAGS to be absent from the compilation line.

LIBMNL_CFLAGS and LIBNFTNL_CFLAGS should be in AM_CPPFLAGS because
they are, well, cppflags. (It's a pkgconfig "bug").
This was properly done in the original autotools submissions.

>--- /dev/null
>+++ b/m4/.gitignore
>@@ -0,0 +1,2 @@
>+*
>+!.gitignore

The last entry is not needed, because .gitignore would already be 
unignored because it is tracked.

  /lt*.m4
  /libtool.m4

as in the original submission would ensure that no more files are 
ignored than absolutely necessary, so as to be aware of potential 
additional files popping up.

>--- a/src/scanner.l
>+++ b/src/scanner.l
>@@ -169,6 +169,7 @@ ip6addr		({v680}|{v67}|{v66}|{v65}|{v64}|{v63}|{v62}|{v61}|{v60})
> addrstring	({macaddr}|{ip4addr}|{ip6addr})
> 
> %option prefix="nft_"
>+%option outfile="lex.yy.c"
> %option reentrant
> %option noyywrap
> %option nounput

Why is this needed? The default output filename is already lex.yy.c
(and ylwrap will rename it anyway).

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Giorgio Dal Molin Nov. 7, 2014, 6:17 p.m. UTC | #2
On 11/06/2014 07:25 PM, Pablo Neira Ayuso wrote:

> diff --git a/Make_global.am b/Make_global.am
> new file mode 100644
> index 0000000..8ad0eb0
> --- /dev/null
> +++ b/Make_global.am
> @@ -0,0 +1,10 @@
> +AM_CPPFLAGS = -I$(top_srcdir)/include
> +AM_CPPFLAGS += -DDEFAULT_INCLUDE_PATH="\"${sysconfdir}\"" -D__USE_GNU
> +
> +AM_CFLAGS = -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 # -Wshadow			\
> +	    -Waggregate-return -Wunused -Wwrite-strings				\
> +	    ${LIBMNL_CFLAGS} ${LIBNFTNL_CFLAGS}

why do you need this new file? The #include in the main Makefile.am is
useless because you do not build anything there; the only right place to
have these definitions is under src/Makefile.am.

giorgio
diff mbox

Patch

diff --git a/.gitignore b/.gitignore
index d26b395..7247daf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,10 +2,13 @@ 
 .*.d
 *.o
 
-# Generated by autoconf/configure
+# Generated by autoconf/configure/automake
+*.m4
 Makefile
-Makefile.defs
-Makefile.rules
+Makefile.in
+src/Makefile.in
+src/.deps/
+stamp-h1
 config.h
 config.h.in
 config.h.in~
@@ -13,6 +16,7 @@  config.log
 config.status
 configure
 autom4te.cache
+build-aux/
 
 # Debian package build temporary files
 build-stamp
diff --git a/Make_global.am b/Make_global.am
new file mode 100644
index 0000000..8ad0eb0
--- /dev/null
+++ b/Make_global.am
@@ -0,0 +1,10 @@ 
+AM_CPPFLAGS = -I$(top_srcdir)/include
+AM_CPPFLAGS += -DDEFAULT_INCLUDE_PATH="\"${sysconfdir}\"" -D__USE_GNU
+
+AM_CFLAGS = -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 # -Wshadow			\
+	    -Waggregate-return -Wunused -Wwrite-strings				\
+	    ${LIBMNL_CFLAGS} ${LIBNFTNL_CFLAGS}
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..f48b08c
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,5 @@ 
+include Make_global.am
+
+ACLOCAL_AMFLAGS	= -I m4
+
+SUBDIRS		= src
diff --git a/Makefile.defs.in b/Makefile.defs.in
deleted file mode 100644
index b9b115f..0000000
--- a/Makefile.defs.in
+++ /dev/null
@@ -1,42 +0,0 @@ 
-DEBUG		= @CONFIG_DEBUG@
-CC		= @CC@
-CPP		= @CPP@
-LEX		= @LEX@
-YACC		= @YACC@
-MKDIR_P		= @MKDIR_P@
-INSTALL		= @INSTALL@
-SED		= @SED@
-DB2MAN		= @DB2MAN@
-
-PACKAGE_TARNAME	= @PACKAGE_TARNAME@
-
-prefix		= @prefix@
-exec_prefix	= @exec_prefix@
-sysconfdir	= @sysconfdir@
-datarootdir	= @datarootdir@
-mandir		= @mandir@
-docdir		= @docdir@
-pdfdir		= @pdfdir@
-confdir		= @sysconfdir@/nftables
-
-LDFLAGS		+= -lmnl -lnftnl
-LDFLAGS		+= @LIBS@
-
-CPPFLAGS	+= @CPPFLAGS@
-
-CFLAGS		+= @CFLAGS@ @DEFS@
-CFLAGS		+= -DDEFAULT_INCLUDE_PATH="\"$(confdir)\""
-CFLAGS		+= -include config.h
-CFLAGS		+= -Iinclude
-CFLAGS		+= -fno-strict-aliasing
-
-CFLAGS		+= -Wall
-CFLAGS		+= -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
-CFLAGS		+= -Wdeclaration-after-statement -Wsign-compare -Winit-self
-CFLAGS		+= -Wformat-nonliteral -Wformat-security -Wmissing-format-attribute
-CFLAGS		+= -Wcast-align -Wundef -Wbad-function-cast # -Wshadow
-CFLAGS		+= -Waggregate-return -Wunused -Wwrite-strings
-
-ifeq ($(DEBUG),y)
-CFLAGS		+= -g -DDEBUG
-endif
diff --git a/Makefile.in b/Makefile.in
deleted file mode 100644
index 5d42541..0000000
--- a/Makefile.in
+++ /dev/null
@@ -1,5 +0,0 @@ 
-SUBDIRS		+= src
-SUBDIRS		+= files
-SUBDIRS		+= doc
-
-include Makefile.rules
diff --git a/Makefile.rules.in b/Makefile.rules.in
deleted file mode 100644
index 6a00916..0000000
--- a/Makefile.rules.in
+++ /dev/null
@@ -1,96 +0,0 @@ 
-include Makefile.defs
-
-makedeps		+= $(SUBDIR)Makefile
-makedeps		+= Makefile
-makedeps		+= Makefile.defs
-makedeps		+= Makefile.rules
-
-configure:		configure.ac
-			sh autogen.sh
-
-%:			%.in	configure
-			sh configure
-
-%.o:			%.c	$(makedeps)
-			@echo -e "  CC\t\t$<"
-			$(CC) $(CFLAGS) -c -o $@ $<
-
-.%.d:			%.c	$(makedeps)
-			@echo -e "  DEP\t\t$<"
-			$(RM) $@
-			$(CC) -M $(CFLAGS) $< | sed 's,$(*F)\.o[ :]*,$*.o $@ : ,g' > $@
-
-%.c %.h:		%.y	$(makedeps)
-			@echo -e "  YACC\t\t$<"
-			$(YACC) $(YACCFLAGS) --defines=$*.h.tmp -o $@ $<
-			( \
-				echo "#ifndef __$(*F)_H"; \
-				echo "#define __$(*F)_H"; \
-				cat $*.h.tmp; \
-				echo "#endif /* __$(*F)_H */" \
-			) > $*.h
-			$(RM) $*.h.tmp
-
-%.c %.h:		%.l	$(makedeps)
-			@echo -e "  LEX\t\t$<"
-			$(LEX) -t --header-file=$(<:.l=.h) $< > $@
-
-%.8:			%.xml	$(makedeps)
-			@echo -e "  MAN\t\t$@"
-			(cd $(SUBDIR); $(DB2MAN) --xinclude ../$<)
-
-%.pdf:			%.xml	$(makedeps)
-			@echo -e "  PDF\t\t$@"
-			dblatex -q -t pdf -o $@ $<
-
-archive:
-			git archive --prefix=nftables-@PACKAGE_VERSION@/ HEAD | \
-				bzip2 -c > nftables-@PACKAGE_VERSION@.tar.bz2
-
-define program_template
-$(1)-obj		:= $$(patsubst %,$(SUBDIR)%,$$($(1)-obj))
-$(1)-extra-clean-files	:= $$(patsubst %,$(SUBDIR)%,$$($(1)-extra-clean-files))
-
-depfiles		:= $$(patsubst $(SUBDIR)%.o,$(SUBDIR).%.d,$$($(1)-obj))
-
-$(SUBDIR)$(1):		$$($(1)-extra-targets) $$($(1)-obj)
-			@echo -e "  LD\t\t$$@"
-			$$(CC) $$($(1)-obj) $$(LDFLAGS) -o $$@
-all_targets		+= $(SUBDIR)$(1)
-
-.PHONY:			$(1)-clean
-$(1)-clean:
-			@echo -e "  CLEAN\t\t$(1)"
-			$$(RM) $$($(1)-obj) $$(depfiles) $$($(1)-extra-clean-files) $(SUBDIR)$(1)
-clean_targets		+= $(1)-clean
-
-.PHONY:			$(1)-install
-$(1)-install:
-			@echo -e "  INSTALL\t$1"
-			$(MKDIR_P) $$(DESTDIR)/$$($(1)-destdir)
-			$(INSTALL) -m 755 -p \
-				$(SUBDIR)$(1) \
-				$$(DESTDIR)/$$($(1)-destdir)/$(1)
-install_targets		+= $(1)-install
-
-ifneq ($(MAKECMDGOALS),clean)
--include $$(depfiles)
-endif
-endef
-
-ifneq ($(SUBDIR),)
-include $(SUBDIR)/Makefile
-$(foreach prog,$(PROGRAMS),$(eval $(call program_template,$(prog))))
-endif
-
-.DEFAULT_GOAL		:= all
-
-.PHONY:			all clean install
-all:			$(SUBDIRS) $(all_targets)
-clean:			$(SUBDIRS) $(clean_targets)
-install:		all $(SUBDIRS) $(install_targets)
-
-.PHONY: $(SUBDIRS)
-$(SUBDIRS):
-			@echo -e "  SUBDIR\t$@/"
-			@$(MAKE) -s -f Makefile.rules $(MAKECMDGOALS) SUBDIR="$@/" SUBDIRS=""
diff --git a/configure.ac b/configure.ac
index ee9cf6c..15bb3e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,6 +7,15 @@  AC_COPYRIGHT([Copyright (c) 2008 Patrick McHardy <kaber@trash.net>])
 AC_INIT([nftables], [0.3], [netfilter-devel@vger.kernel.org])
 AC_DEFINE([RELEASE_NAME], ["Support Edward Snowden"], [Release name])
 
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CANONICAL_HOST
+AC_CONFIG_MACRO_DIR([m4])
+AM_INIT_AUTOMAKE([-Wall foreign subdir-objects
+        tar-pax no-dist-gzip dist-bzip2 1.6])
+
+dnl kernel style compile messages
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
 AC_CONFIG_SRCDIR([src/rule.c])
 AC_CONFIG_HEADER([config.h])
 
@@ -77,8 +86,10 @@  AC_ARG_WITH([cli], [AS_HELP_STRING([--without-cli],
 AS_IF([test "x$with_cli" != xno], [
 AC_CHECK_LIB([readline], [readline], ,
 	     AC_MSG_ERROR([No suitable version of libreadline found]))
+AC_DEFINE([HAVE_LIBREADLINE], [1], [])
 ])
 AC_SUBST(with_cli)
+AM_CONDITIONAL([BUILD_CLI], [test "x$with_cli" != xno])
 
 # Checks for header files.
 AC_HEADER_STDC
@@ -108,6 +119,6 @@  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])
+AC_CONFIG_FILES([src/Makefile])
 AC_OUTPUT
diff --git a/install-sh b/install-sh
deleted file mode 100755
index d4744f0..0000000
--- a/install-sh
+++ /dev/null
@@ -1,269 +0,0 @@ 
-#!/bin/sh
-#
-# install - install a program, script, or datafile
-#
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
-# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Except as contained in this notice, the name of the X Consortium shall not
-# be used in advertising or otherwise to promote the sale, use or other deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
-#
-#
-# FSF changes to this file are in the public domain.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.  It can only install one file at a time, a restriction
-# shared with many OS's install programs.
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
-    case $1 in
-	-c) instcmd="$cpprog"
-	    shift
-	    continue;;
-
-	-d) dir_arg=true
-	    shift
-	    continue;;
-
-	-m) chmodcmd="$chmodprog $2"
-	    shift
-	    shift
-	    continue;;
-
-	-o) chowncmd="$chownprog $2"
-	    shift
-	    shift
-	    continue;;
-
-	-g) chgrpcmd="$chgrpprog $2"
-	    shift
-	    shift
-	    continue;;
-
-	-s) stripcmd="$stripprog"
-	    shift
-	    continue;;
-
-	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
-	    shift
-	    continue;;
-
-	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
-	    shift
-	    continue;;
-
-	*)  if [ x"$src" = x ]
-	    then
-		src=$1
-	    else
-		# this colon is to work around a 386BSD /bin/sh bug
-		:
-		dst=$1
-	    fi
-	    shift
-	    continue;;
-    esac
-done
-
-if [ x"$src" = x ]
-then
-	echo "install:	no input file specified"
-	exit 1
-else
-	true
-fi
-
-if [ x"$dir_arg" != x ]; then
-	dst=$src
-	src=""
-	
-	if [ -d $dst ]; then
-		instcmd=:
-		chmodcmd=""
-	else
-		instcmd=mkdir
-	fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad 
-# if $src (and thus $dsttmp) contains '*'.
-
-	if [ -f $src -o -d $src ]
-	then
-		true
-	else
-		echo "install:  $src does not exist"
-		exit 1
-	fi
-	
-	if [ x"$dst" = x ]
-	then
-		echo "install:	no destination specified"
-		exit 1
-	else
-		true
-	fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
-	if [ -d $dst ]
-	then
-		dst="$dst"/`basename $src`
-	else
-		true
-	fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-#  this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS=' 	
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
-	pathcomp="${pathcomp}${1}"
-	shift
-
-	if [ ! -d "${pathcomp}" ] ;
-        then
-		$mkdirprog "${pathcomp}"
-	else
-		true
-	fi
-
-	pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
-	$doit $instcmd $dst &&
-
-	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
-	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
-	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
-	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
-	if [ x"$transformarg" = x ] 
-	then
-		dstfile=`basename $dst`
-	else
-		dstfile=`basename $dst $transformbasename | 
-			sed $transformarg`$transformbasename
-	fi
-
-# don't allow the sed command to completely eliminate the filename
-
-	if [ x"$dstfile" = x ] 
-	then
-		dstfile=`basename $dst`
-	else
-		true
-	fi
-
-# Make a temp file name in the proper directory.
-
-	dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
-	$doit $instcmd $src $dsttmp &&
-
-	trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing.  If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
-	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
-	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
-	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
-	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
-	$doit $rmcmd -f $dstdir/$dstfile &&
-	$doit $mvcmd $dsttmp $dstdir/$dstfile 
-
-fi &&
-
-
-exit 0
diff --git a/m4/.gitignore b/m4/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/m4/.gitignore
@@ -0,0 +1,2 @@ 
+*
+!.gitignore
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..8a6471a
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,41 @@ 
+include $(top_srcdir)/Make_global.am
+
+sbin_PROGRAMS = nft
+
+CLEANFILES = scanner.c parser_bison.c
+
+AM_YFLAGS = -d
+
+# yacc and lex generate dirty code
+parser_bison.o scanner.o: AM_CFLAGS += -Wno-missing-prototypes -Wno-missing-declarations -Wno-implicit-function-declaration -Wno-nested-externs -Wno-undef -Wno-redundant-decls
+
+BUILT_SOURCES = parser_bison.h
+
+nft_SOURCES =	main.c				\
+		rule.c				\
+		statement.c			\
+		datatype.c			\
+		expression.c			\
+		evaluate.c			\
+		proto.c				\
+		payload.c			\
+		exthdr.c			\
+		meta.c				\
+		ct.c				\
+		netlink.c			\
+		netlink_linearize.c		\
+		netlink_delinearize.c		\
+		segtree.c			\
+		rbtree.c			\
+		gmputil.c			\
+		utils.c				\
+		erec.c				\
+		mnl.c				\
+		scanner.l			\
+		parser_bison.y
+
+if BUILD_CLI
+nft_SOURCES +=	cli.c
+endif
+
+nft_LDADD	= ${LIBMNL_LIBS} ${LIBNFTNL_LIBS}
diff --git a/src/Makefile.in b/src/Makefile.in
deleted file mode 100644
index 0c080f6..0000000
--- a/src/Makefile.in
+++ /dev/null
@@ -1,33 +0,0 @@ 
-PROGRAMS		+= nft
-
-nft-destdir		:= @sbindir@
-
-nft-obj			+= main.o
-ifeq (@with_cli@,yes)
-nft-obj			+= cli.o
-endif
-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_bison.o
-nft-extra-clean-files	+= parser_bison.c parser_bison.h
-
-nft-obj			+= scanner.o
-nft-extra-clean-files	+= scanner.c scanner.h
diff --git a/src/cli.c b/src/cli.c
index 6f2847b..f3827b8 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -12,6 +12,7 @@ 
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
 
+#include <config.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
diff --git a/src/erec.c b/src/erec.c
index 4930085..82543e6 100644
--- a/src/erec.c
+++ b/src/erec.c
@@ -8,6 +8,7 @@ 
  * Development of this code funded by Astaro AG (http://www.astaro.com/)
  */
 
+#include <config.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 1c4046b..6099aca 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -33,7 +33,6 @@ 
 #include <erec.h>
 
 #include "parser_bison.h"
-#include "scanner.h"
 
 void parser_init(struct parser_state *state, struct list_head *msgs)
 {
diff --git a/src/scanner.l b/src/scanner.l
index e5f3a99..12af2d8 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -169,6 +169,7 @@  ip6addr		({v680}|{v67}|{v66}|{v65}|{v64}|{v63}|{v62}|{v61}|{v60})
 addrstring	({macaddr}|{ip4addr}|{ip6addr})
 
 %option prefix="nft_"
+%option outfile="lex.yy.c"
 %option reentrant
 %option noyywrap
 %option nounput