diff --git a/Makefile.am b/Makefile.am
index ba2ebc98f93ea0e759c78b7002becc1388b25682..0a7b92996195b295f37ae017cda013b954da9d32 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,2 +1,2 @@
-ACLOCAL_AMFLAGS = -Im4
+ACLOCAL_AMFLAGS = -I m4
 SUBDIRS = src
diff --git a/configure.ac b/configure.ac
index 9e9eafe2addc74782251a540f0c7b849211b4902..059968baa8dfd12e8c5eb63987a202a5afd6592c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,15 +2,19 @@
 
 AC_PREREQ([2.67])
 AC_INIT([knot], [0.2], [bug-me-knot@nic.cz])
-AM_INIT_AUTOMAKE([foreign -Wall -Werror])
+AM_INIT_AUTOMAKE([gnu -Wall -Werror])
 AC_CONFIG_SRCDIR([src/main.c])
 AC_CONFIG_HEADERS([src/config.h])
 AC_CONFIG_MACRO_DIR([m4])
 
+# Enable maintainer mode by default for development
+AM_MAINTAINER_MODE([enable])
+
 # Set compiler compatibility flags
 AC_PROG_CPP_WERROR
 AC_PROG_CC_STDC
 AC_PROG_CC_C99
+AC_USE_SYSTEM_EXTENSIONS([_GNU_SOURCE])
 
 # Initialize libtool
 LT_INIT
diff --git a/src/Makefile.am b/src/Makefile.am
index 1d0af0b11cbb27f183f3caa3f8c5babd3c98e356..9e144293b728b9cabc3c51cdd40d041c1843c776 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,11 +1,10 @@
-ACLOCAL_AMFLAGS = -I../m4
+ACLOCAL_AMFLAGS = -I ../m4
 bin_PROGRAMS = knotc
-libexec_PROGRAMS = knot-zoneparser
-sbin_PROGRAMS = knot
+libexec_PROGRAMS = knot-zoneparser unittests
+sbin_PROGRAMS = knotd
 
 # FIXME: Move header files to $(topdir)/include
 AM_CFLAGS =		\
-	-I.		\
 	-std=gnu99	\
 	-D_XOPEN_SOURCE=600 \
 	-D_GNU_SOURCE
@@ -15,7 +14,20 @@ AM_YFLAGS = -d
 
 LDADD = libknot.a @LIBOBJS@
 
-TESTS = unittest
+BUILT_SOURCES =					\
+	tests/dnslib/parsed_data.rc		\
+	tests/dnslib/raw_data_queries.rc	\
+	tests/dnslib/raw_data.rc		\
+	tests/dnslib/parsed_data_queries.rc
+
+CLEANFILES =					\
+	tests/dnslib/parsed_data.rc		\
+	tests/dnslib/raw_data_queries.rc	\
+	tests/dnslib/raw_data.rc		\
+	tests/dnslib/parsed_data_queries.rc	\
+	zparser.h				\
+	zparser.c				\
+	zlexer.c
 
 knotc_SOURCES =					\
 	ctl/knotc_main.c
@@ -23,28 +35,26 @@ knotc_SOURCES =					\
 knot_zoneparser_SOURCES =			\
 	zoneparser/zoneparser_main.c
 
-#unittests_SOURCES =				\
-#	tests/zonedb_tests.c			\
-#	tests/dnslib_tests.c			\
-#	tests/dthreads_tests.c			\
-#	tests/libtap/tap.c			\
-#	tests/da_tests.c			\
-#	tests/server_tests.c			\
-#	tests/slab_tests.c			\
-#	tests/template_tests.c			\
-#	tests/dnslib/dnslib_response_tests.c	\
-#	tests/dnslib/dnslib_zone_tests.c	\
-#	tests/dnslib/dnslib_rrsig_set_tests.c	\
-#	tests/dnslib/dnslib_rrset_tests.c	\
-#	tests/dnslib/dnslib_edns_tests.c	\
-#	tests/dnslib/dnslib_rdata_tests.c	\
-#	tests/dnslib/dnslib_node_tests.c	\
-#	tests/dnslib/dnslib_dname_tests.c	\
-#	tests/skiplist_tests.c			\
-#	tests/cuckoo_tests.c			\
-#	tests/unittests_main.c
-
-knot_SOURCES =					\
+unittests_SOURCES =				\
+	tests/zonedb_tests.c			\
+	tests/dnslib_tests.c			\
+	tests/dthreads_tests.c			\
+	tests/libtap/tap.c			\
+	tests/da_tests.c			\
+	tests/server_tests.c			\
+	tests/slab_tests.c			\
+	tests/template_tests.c			\
+	tests/skiplist_tests.c			\
+	tests/cuckoo_tests.c			\
+	tests/unittests_main.c
+
+nodist_unittests_SOURCES =			\
+	tests/dnslib/parsed_data.rc		\
+	tests/dnslib/raw_data_queries.rc	\
+	tests/dnslib/raw_data.rc		\
+	tests/dnslib/parsed_data_queries.rc
+
+knotd_SOURCES =					\
 	main.c
 
 noinst_LIBRARIES = libknot.a
@@ -127,10 +137,24 @@ libknot_a_SOURCES =				\
 	hash/universal-system.h			\
 	hash/cuckoo-hash-table.h		\
 	hash/hash-functions.h			\
-	config.h				\
 	other/print.h				\
 	other/log.h				\
 	other/debug.h
 
 libknot_a_LIBADD = @LIBOBJS@
 
+# automake complains on % rules:
+#   `%'-style pattern rules are a GNU make extension
+
+tests/dnslib/parsed_data.rc: tests/files/parsed_data
+	../resource.sh $< >$@
+
+tests/dnslib/parsed_data_queries.rc: tests/files/parsed_data_queries
+	../resource.sh $< >$@
+
+tests/dnslib/raw_data_queries.rc: tests/files/raw_data_queries
+	../resource.sh $< >$@
+
+tests/dnslib/raw_data.rc: tests/files/raw_data
+	../resource.sh $< >$@
+