diff --git a/configure.ac b/configure.ac
index df5646c600f5aa2220cc22417bac6b6135d93e61..7b3a5c7090a42c399b96816139a1dc74ae58857a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,6 +24,23 @@ AC_PROG_INSTALL
 AC_PROG_CPP_WERROR
 AC_PROG_CC_C99
 
+#AC_ARG_ENABLE([ldns],
+#[ --enable-ldns Enable tests with ldns],
+#[case "${enableval}" in 
+#	yes) ldns=true ;;
+#	no) ldns=false ;;
+#])
+
+AC_ARG_ENABLE([ldns],
+     [  --enable-ldns    Enable tests with ldns],
+     [case "${enableval}" in
+       yes) AC_CHECK_LIB([ldns], [ldns_rr_list_pop_rrset]) ;;
+       no)  ldns=false ;;
+       *) AC_MSG_ERROR([bad value ${enableval} for --enable-ldns]) ;;
+     esac],[ldns=false])
+
+#AM_CONDITIONAL([ldns], [test x$ldns = xtrue])
+
 # Checks for libraries.
 # FIXME: Replace `main' with a function in `-lm':
 AC_CHECK_LIB([m], [pow])
@@ -31,7 +48,7 @@ AC_CHECK_LIB([pthread], [pthread_create])
 AC_CHECK_LIB([urcu], [rcu_read_lock])
 AC_CHECK_LIB([rt], [clock_gettime])
 AC_CHECK_LIB([crypto], [OpenSSL_add_all_digests])
-AC_CHECK_LIB([ldns], [ldns_rr_list_pop_rrset])
+#AC_CHECK_LIB([ldns], [ldns_rr_list_pop_rrset])
 
 # Checks for header files.
 AC_HEADER_RESOLV
diff --git a/src/Makefile.am b/src/Makefile.am
index 0db618371910c7a3a32c1e27ef05925f38f41e34..0571f4259f3f2940f9c9f13bdebc87c75949099a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,6 @@
 ACLOCAL_AMFLAGS = -I ../m4
 bin_PROGRAMS = knotc
-libexec_PROGRAMS = knot-zcompile unittests
+libexec_PROGRAMS = knot-zcompile unittests unittests-zcompile
 sbin_PROGRAMS = knotd
 
 # $(YACC) will generate header file
@@ -47,6 +47,17 @@ unittests_SOURCES =				\
 	tests/libtap/tap.c			\
 	tests/unittests_main.c
 
+unittests_zcompile_SOURCES =		\
+	zoneparser/parser-util.h		\
+	zoneparser/parser-descriptor.h		\
+	zoneparser/zparser.y			\
+	zoneparser/zlexer.l			\
+	zoneparser/zoneparser.c			\
+	zoneparser/parser-util.c		\
+	zoneparser/parser-descriptor.c		\
+	tests/libtap/tap.c			\
+	zoneparser/tests/unittests_zp_main.c	
+
 nodist_unittests_SOURCES =			\
 	tests/dnslib/parsed_data.rc		\
 	tests/dnslib/raw_data_queries.rc	\
diff --git a/src/common.h b/src/common.h
index 90bb60f1d941cea167009713791d749f86741c80..9db6fef56c5c46657d8c5c3cdaf38a68f89bcffb 100644
--- a/src/common.h
+++ b/src/common.h
@@ -101,7 +101,9 @@ do { \
 } while(0)
 
 //#define STAT_COMPILE
+#ifdef HAVE_LIBLDNS
 #define TEST_WITH_LDNS
+#endif
 
 #endif /* _KNOT_COMMON_H_ */