From 081242d84f1490df5d3927fa787a65a89aa146df Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Fri, 11 Jul 2008 14:44:34 +0000
Subject: [PATCH] Fix rapi documentation

As a nice side-effect this also fixes "make distcheck".

The way used to include the generated rapi-resources.sgml file only
works if it's built in the same directory. That's not the case during
"make distcheck". The patch changes the sed script used for variables
to include the file using its absolute path.

Reviewed-by: iustinp
---
 DEVNOTES      |  3 ++-
 Makefile.am   | 14 +++++++++-----
 doc/rapi.sgml |  3 +--
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/DEVNOTES b/DEVNOTES
index 862f23933..83714ff01 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 1156730d4..33e566673 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 51bf56e4f..12e7e556b 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>
-- 
GitLab