[PATCH xserver 8/8] doc: refactor Makefile and xmlrules.in code for reusability
Gaetan Nadon
memsize at videotron.ca
Thu Nov 18 10:37:50 PST 2010
A different approach which requires less variables setting
and internal knowledge of the reused code.
Changing from "install" to "not install" is very easy now.
Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
---
doc/xml/Makefile.am | 11 +++--------
doc/xml/dtrace/Makefile.am | 16 +++++++---------
doc/xml/xmlrules-inst.in | 23 +++++++++++++++++++++++
doc/xml/xmlrules-noinst.in | 22 ++++++++++++++++++++++
doc/xml/xmlrules.in | 33 ++++++---------------------------
hw/dmx/doc/Makefile.am | 8 +++-----
hw/xfree86/doc/sgml/Makefile.am | 10 +++-------
7 files changed, 67 insertions(+), 56 deletions(-)
create mode 100644 doc/xml/xmlrules-inst.in
create mode 100644 doc/xml/xmlrules-noinst.in
diff --git a/doc/xml/Makefile.am b/doc/xml/Makefile.am
index ab3839b..6c8178a 100644
--- a/doc/xml/Makefile.am
+++ b/doc/xml/Makefile.am
@@ -22,14 +22,9 @@
#
SUBDIRS = dtrace
+doc_sources = Xserver-spec.xml
-XML_FILES = Xserver-spec.xml
-
-include $(top_srcdir)/doc/xml/xmlrules.in
-
+# Developer's documentation is not installed
if ENABLE_DEVEL_DOCS
-noinst_DATA = $(BUILT_DOC_FILES)
+include $(top_srcdir)/doc/xml/xmlrules-noinst.in
endif
-CLEANFILES = $(CLEAN_DOC_FILES)
-
-EXTRA_DIST = $(XML_FILES)
diff --git a/doc/xml/dtrace/Makefile.am b/doc/xml/dtrace/Makefile.am
index 10b4f04..fd5924e 100644
--- a/doc/xml/dtrace/Makefile.am
+++ b/doc/xml/dtrace/Makefile.am
@@ -21,18 +21,16 @@
# DEALINGS IN THE SOFTWARE.
#
-XML_FILES = Xserver-DTrace.xml
-
-include $(top_srcdir)/doc/xml/xmlrules.in
-
+doc_sources = Xserver-DTrace.xml
+
if ENABLE_DOCS
+
+# This user's documentation is installed only if tracing is available
if XSERVER_DTRACE
-doc_DATA = $(BUILT_DOC_FILES)
+include $(top_srcdir)/doc/xml/xmlrules-inst.in
else
-noinst_DATA = $(BUILT_DOC_FILES)
-endif
+include $(top_srcdir)/doc/xml/xmlrules-noinst.in
endif
-CLEANFILES = $(CLEAN_DOC_FILES)
+endif
-EXTRA_DIST = $(XML_FILES)
diff --git a/doc/xml/xmlrules-inst.in b/doc/xml/xmlrules-inst.in
new file mode 100644
index 0000000..9b90278
--- /dev/null
+++ b/doc/xml/xmlrules-inst.in
@@ -0,0 +1,23 @@
+
+# The doc_sources variable contains one or more DocBook/XML source file.
+# The generated documents will be installed in $(docdir),
+# The DocBook/XML files will always be included in the tarball
+
+dist_doc_DATA = $(doc_sources)
+
+if HAVE_XMLTO
+doc_DATA = $(doc_sources:.xml=.html)
+
+if HAVE_FOP
+doc_DATA += $(doc_sources:.xml=.pdf)
+endif
+
+if HAVE_XMLTO_TEXT
+doc_DATA += $(doc_sources:.xml=.txt)
+endif
+
+CLEANFILES = $(doc_DATA)
+include $(top_srcdir)/doc/xml/xmlrules.in
+
+endif HAVE_XMLTO
+
diff --git a/doc/xml/xmlrules-noinst.in b/doc/xml/xmlrules-noinst.in
new file mode 100644
index 0000000..0333652
--- /dev/null
+++ b/doc/xml/xmlrules-noinst.in
@@ -0,0 +1,22 @@
+
+# The doc_sources variable contains one or more DocBook/XML source file.
+# The generated documents will NOT be installed in $(docdir),
+# The DocBook/XML files will always be included in the tarball
+
+dist_noinst_DATA = $(doc_sources)
+
+if HAVE_XMLTO
+noinst_DATA = $(doc_sources:.xml=.html)
+
+if HAVE_FOP
+noinst_DATA += $(doc_sources:.xml=.pdf)
+endif
+
+if HAVE_XMLTO_TEXT
+noinst_DATA += $(doc_sources:.xml=.txt)
+endif
+
+CLEANFILES = $(noinst_DATA)
+include $(top_srcdir)/doc/xml/xmlrules.in
+
+endif HAVE_XMLTO
diff --git a/doc/xml/xmlrules.in b/doc/xml/xmlrules.in
index 2817d2c..cc1ce72 100644
--- a/doc/xml/xmlrules.in
+++ b/doc/xml/xmlrules.in
@@ -21,24 +21,15 @@
# DEALINGS IN THE SOFTWARE.
#
-# This file is included by Makefile.am in subdirectories that have
-# DocBook XML documentation files.
-#
-# No files are automatically distributed or installed by this subset of rules
-# Any files to be distributed or installed would be listed in the including
-# Makefile.am
-
-TXT_FILES = $(XML_FILES:%.xml=%.txt)
-HTML_FILES = $(XML_FILES:%.xml=%.html)
-PDF_FILES = $(XML_FILES:%.xml=%.pdf)
-
-BUILT_DOC_FILES =
-
-SUFFIXES = .xml .txt .html .pdf
+# This file provides pattern rules to generate html/pdf/txt from DocBook/XML
+# A stylesheet is used if xorg-sgml-doctools is installed
+# This file is included by xmlrules-inst.in for installable user's documentation
+# It is included by xmlrules-noinst for non installable developer's documentation
+# If the server version or release date changes, autogen && make
XML_ENT_DIR = $(abs_top_builddir)/doc/xml
+SUFFIXES = .xml .txt .html .pdf
-if HAVE_XMLTO
if HAVE_STYLESHEETS
XMLTO_FLAGS = \
-m $(XSL_STYLESHEET) \
@@ -46,23 +37,11 @@ XMLTO_FLAGS = \
--stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
endif
-if HAVE_XMLTO_TEXT
-BUILT_DOC_FILES += $(TXT_FILES)
%.txt: %.xml $(XML_ENT_DIR)/xserver.ent
$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) txt $<
-endif
-BUILT_DOC_FILES += $(HTML_FILES)
%.html: %.xml $(XML_ENT_DIR)/xserver.ent
$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) xhtml-nochunks $<
-if HAVE_FOP
-BUILT_DOC_FILES += $(PDF_FILES)
%.pdf: %.xml $(XML_ENT_DIR)/xserver.ent
$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop pdf $<
-endif
-
-endif HAVE_XMLTO
-
-CLEAN_DOC_FILES = $(TXT_FILES) $(HTML_FILES) $(PDF_FILES)
-
diff --git a/hw/dmx/doc/Makefile.am b/hw/dmx/doc/Makefile.am
index 3b22850..6dea366 100644
--- a/hw/dmx/doc/Makefile.am
+++ b/hw/dmx/doc/Makefile.am
@@ -19,14 +19,12 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-XML_FILES = dmx.xml scaled.xml
-
-include $(top_srcdir)/doc/xml/xmlrules.in
+doc_sources = dmx.xml scaled.xml
+# Developer's documentation is not installed
if ENABLE_DEVEL_DOCS
-noinst_DATA = $(BUILT_DOC_FILES)
+include $(top_srcdir)/doc/xml/xmlrules-noinst.in
endif
-CLEANFILES = $(CLEAN_DOC_FILES)
if HAVE_DOXYGEN
diff --git a/hw/xfree86/doc/sgml/Makefile.am b/hw/xfree86/doc/sgml/Makefile.am
index efed19d..10eca86 100644
--- a/hw/xfree86/doc/sgml/Makefile.am
+++ b/hw/xfree86/doc/sgml/Makefile.am
@@ -19,13 +19,9 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-XML_FILES = DESIGN.xml
-
-include $(top_srcdir)/doc/xml/xmlrules.in
+doc_sources = DESIGN.xml
+# Developer's documentation is not installed
if ENABLE_DEVEL_DOCS
-noinst_DATA = $(BUILT_DOC_FILES)
+include $(top_srcdir)/doc/xml/xmlrules-noinst.in
endif
-CLEANFILES = $(CLEAN_DOC_FILES)
-
-EXTRA_DIST = $(XML_FILES)
--
1.6.0.4
More information about the xorg-devel
mailing list