diff --git a/Makefile.am b/Makefile.am
index a89a793372b8958b16170f1068478fd5f07bde3c..7ba6efbb258e792adaac69173394c7a6a3064b09 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,9 +16,7 @@ if ENABLE_TESTS
 SUBDIRS += tests
 endif
 
-if HAVE_DOXYGEN
 SUBDIRS += doc
-endif
 
 ACLOCAL_AMFLAGS = -I m4
 
diff --git a/configure.ac b/configure.ac
index d874050107a77c347bbddb6dafe072e03d1b8edd..5a42550556115b2df192e61e67ec5991fec5fb4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -210,10 +210,6 @@ AM_COND_IF(ENABLE_PROXY_CLIENT, [CPPFLAGS+=" -DOPENDHT_PROXY_CLIENT"], [])
 AM_COND_IF(ENABLE_PUSH_NOTIFICATIONS, [CPPFLAGS+=" -DOPENDHT_PUSH_NOTIFICATIONS"], [])
 AM_COND_IF(ENABLE_PROXY_SERVER_IDENTITY, [CPPFLAGS+=" -DOPENDHT_PROXY_SERVER_IDENTITY"], [])
 
-AM_COND_IF([HAVE_DOXYGEN], [
-  AC_CONFIG_FILES([doc/Doxyfile doc/Makefile])
-])
-
 dnl Configure setup.py if we build the python module
 AM_COND_IF([USE_CYTHON], [
     AC_SUBST(CURRENT_SOURCE_DIR, ".")
@@ -227,5 +223,7 @@ AC_CONFIG_FILES([Makefile
                  src/Makefile
                  tools/Makefile
                  tests/Makefile
+                 doc/Makefile
+                 doc/Doxyfile
                  opendht.pc])
 AC_OUTPUT
diff --git a/doc/Makefile.am b/doc/Makefile.am
index ab00293b61d544db2b9e17e32c996fbf79540795..0ac8f911904559be3b89b88e6ec3e14e48c10e44 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,7 +1,10 @@
 dist_man1_MANS = dhtnode.1
 
+noinst_HEADERS = \
+	Doxyfile
+
 if HAVE_DOXYGEN
-doxyfile.stamp:
+doxyfile.stamp: Doxyfile
 	$(DOXYGEN) Doxyfile
 	echo stamp > doxyfile.stamp