diff --git a/DEVNOTES b/DEVNOTES
index 862f23933c8e6ee7ae9433095cee00db49a8d3de..83714ff011e5d85177951b6e289b930c43ec084d 100644
--- a/DEVNOTES
+++ b/DEVNOTES
@@ -6,4 +6,5 @@ Configuring for development
 
 sh autogen.sh && \
 ./configure --enable-maintainer-mode \
-  --prefix=/usr/local --sysconfdir=/etc --localstatedir=/var
+  --prefix=/usr/local --sysconfdir=/etc --localstatedir=/var \
+  --enable-rapi
diff --git a/Makefile.am b/Makefile.am
index 1156730d4b97290529c8d5cf931a67189e71146a..33e5666735aac18fb3f658020227ffc3a730ff61 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,6 +11,7 @@ abs_top_srcdir = @abs_top_srcdir@
 
 ACLOCAL_AMFLAGS = -I autotools
 DOCBOOK_WRAPPER = $(top_srcdir)/autotools/docbook-wrapper
+BUILD_RAPI_RESOURCE_DOC = $(top_srcdir)/doc/build-rapi-resources-doc
 REPLACE_VARS_SED = autotools/replace_vars.sed
 
 hypervisordir = $(pkgpythondir)/hypervisor
@@ -41,6 +42,7 @@ CLEANFILES = \
 	doc/*.html \
 	doc/*.in \
 	doc/*.pdf \
+	doc/rapi-resources.sgml \
 	doc/examples/ganeti.initd \
 	doc/examples/ganeti.cron \
 	lib/*.py[co] \
@@ -223,10 +225,8 @@ doc/%.html: doc/%.in $(DOCBOOK_WRAPPER)
 
 doc/rapi.pdf doc/rapi.html: doc/rapi-resources.sgml
 
-doc/rapi-resources.sgml: doc/build-rapi-resources-doc lib/rapi/resources.py
-	PYTHONPATH=.:$(top_builddir) $< > $@ || rm -f $@
-
-.INTERMEDIATE: doc/rapi-resources.sgml
+doc/rapi-resources.sgml: $(BUILD_RAPI_RESOURCE_DOC) lib/rapi/resources.py
+	PYTHONPATH=.:$(top_builddir) $(BUILD_RAPI_RESOURCE_DOC) > $@ || rm -f $@
 
 man/%.7: man/%.in man/footer.sgml $(DOCBOOK_WRAPPER)
 	$(DOCBOOK_WRAPPER) $< $@
@@ -236,7 +236,7 @@ man/%.8: man/%.in man/footer.sgml $(DOCBOOK_WRAPPER)
 
 man/footer.sgml $(TESTS): srclinks
 
-$(TESTS) doc/build-rapi-resources-doc: ganeti lib/_autoconf.py
+$(TESTS) $(BUILD_RAPI_RESOURCE_DOC): ganeti lib/_autoconf.py
 
 lib/_autoconf.py: Makefile stamp-directories
 	set -e; \
@@ -269,6 +269,10 @@ $(REPLACE_VARS_SED): Makefile stamp-directories
 	  echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
 	  echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
 	  echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
+	  echo '/@INCLUDE_RAPI_RESOURCES@/ {'; \
+	  echo '  r $(abs_top_builddir)/doc/rapi-resources.sgml'; \
+	  echo '  d'; \
+	  echo '}'; \
 	} > $@
 
 # We need to create symlinks because "make distcheck" will not install Python
diff --git a/doc/rapi.sgml b/doc/rapi.sgml
index 51bf56e4fa36f5579b76f13e54d41bda88236b50..12e7e556bee9457b5c23536031bf438863af518d 100644
--- a/doc/rapi.sgml
+++ b/doc/rapi.sgml
@@ -2,7 +2,6 @@
 <!ENTITY JsonLink "http://www.json.org/">
 <!ENTITY WikipediaRESTLink
   "http://en.wikipedia.org/wiki/Representational_State_Transfer">
-<!ENTITY IncludeResources SYSTEM "doc/rapi-resources.sgml">
 ]>
 <article class="specification">
 <articleinfo>
@@ -88,7 +87,7 @@ xmlreq.send(null);</screen>
 
 <sect1>
   <title>Resources</title>
-  &IncludeResources;
+  @INCLUDE_RAPI_RESOURCES@
 </sect1>
 
 </article>