diff --git a/configure.ac b/configure.ac
index 6618a74120edbd0c5f563731c17679d7253537ff..4e69e8bb70dc4d9eecdf5e01df823c865df66e9f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,8 +61,9 @@ AS_IF([test "x$YACC_BISON" != "xbison"],
 AC_PROG_INSTALL
 
 # Check for Ragel
-AC_PATH_PROG([RAGEL], [ragel], [echo !UNPROCESSED! ragel])
-
+AC_PATH_PROG([RAGEL], [ragel], [true])
+AM_CONDITIONAL([HAVE_RAGEL], test "$RAGEL" != "true")
+  
 # Set FSM type for Ragel
 AC_SUBST([FSM_TYPE], [-T0])
 AC_ARG_ENABLE([fastparser],
diff --git a/src/Makefile.am b/src/Makefile.am
index df0f7ef8b82dc04ffbb2845c6ac114749dfe15f4..370cb5855cda68d439d6e4251ffce2a034644a16 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,14 +20,22 @@ EXTRA_DIST =					\
 BUILT_SOURCES =					\
 	knot/conf/libknotd_la-cf-lex.c		\
 	knot/conf/libknotd_la-cf-parse.c	\
-	knot/conf/libknotd_la-cf-parse.h	\
-	zscanner/scanner.c
+	knot/conf/libknotd_la-cf-parse.h
 
 CLEANFILES =					\
 	knot/conf/libknotd_la-cf-lex.c		\
 	knot/conf/libknotd_la-cf-parse.c	\
 	knot/conf/libknotd_la-cf-parse.h
 
+if HAVE_RAGEL
+BUILT_SOURCES += zscanner/scanner.c
+CLEANFILES += zscanner/scanner.c
+
+zscanner/scanner.c: zscanner/scanner.rl zscanner/scanner_body.rl
+	$(RAGEL) $(FSM_TYPE) -s -o $@ $(srcdir)/zscanner/scanner.rl
+
+endif
+
 knotc_SOURCES =					\
 	knot/ctl/knotc_main.c
 
@@ -279,9 +287,6 @@ libknotd_la_SOURCES =				\
 	knot/zone/zone-load.c			\
 	knot/server/server.h
 
-zscanner/scanner.c: zscanner/scanner.rl zscanner/scanner_body.rl
-	$(RAGEL) $(FSM_TYPE) -s -o $@ $(srcdir)/zscanner/scanner.rl
-
 zscanner_tool_SOURCES =				\
 	zscanner/test/zscanner-tool.c		\
 	zscanner/test/tests.h			\