[svnbook commit] r1783 - trunk/src/tools

maxb svnbook-dev at red-bean.com
Tue Nov 1 08:50:58 CST 2005


Author: maxb
Date: Tue Nov  1 08:50:56 2005
New Revision: 1783

Added:
   trunk/src/tools/Makefile.base-rules
      - copied, changed from r1782, trunk/src/tools/Makefile.base
   trunk/src/tools/Makefile.base-vars
      - copied, changed from r1782, trunk/src/tools/Makefile.base
Modified:
   trunk/src/tools/Makefile.base
Log:
Tweak the book buildsystem so that it is actually designed to be reusable.

* tools/Makefile.base: Send most of the content of this file to the two new
    files added in this commit.
* tools/Makefile.base-vars, tools/Makefile.base-rules: New. Tweaked to add the
    capability to build books which don't have any image files.


Modified: trunk/src/tools/Makefile.base
==============================================================================
--- trunk/src/tools/Makefile.base	(original)
+++ trunk/src/tools/Makefile.base	Tue Nov  1 08:50:56 2005
@@ -1,146 +1,10 @@
-# This is a base Makefile fragment, which is expected to be included by the
+# This is a Makefile fragment, which is expected to be included by the
 # locale-specific Makefiles located at ../LOCALE_CODE/Makefile .  As a result,
-# all relative paths contained within are relative to the LOCALE_CODE
+# the relative paths contained within are relative to the LOCALE_CODE
 # directory, and *not* to the tools directory, where this file itself resides.
 
-# Paths which you may wish to customize:
-XSLTPROC = xsltproc
-XMLLINT = xmllint
-INSTALL_DIR = $(DESTDIR)/usr/share/doc/subversion
-INSTALL = install
-SVNVERSION = svnversion
-
-# You should not normally need to edit anything below here.
-SHELL = /bin/sh
-
+include ../tools/Makefile.base-vars
 NAME = book
 DIR = book
-TOOLS_DIR = ../tools
-OUTNAME = svn-$(NAME)
-
-HTML_CHUNK_DIR = $(DIR)/html-chunk
-HTML_TARGET = $(DIR)/$(OUTNAME).html
-# In the HTML chunk build, index.html is created last, so serves as an 
-# acceptable timestamp file for the entire multi-file output.
-HTML_CHUNK_TARGET = $(HTML_CHUNK_DIR)/index.html
-PDF_TARGET = $(DIR)/$(OUTNAME).pdf
-PS_TARGET = $(DIR)/$(OUTNAME).ps
-FO_TARGET = $(DIR)/$(OUTNAME).fo
-XML_SOURCE = $(DIR)/$(NAME).xml
-VERSION_SOURCE = $(DIR)/version.xml
-ALL_SOURCE = $(DIR)/*.xml
 IMAGES = $(DIR)/images/*.png
-STYLESHEET = $(DIR)/styles.css
-INSTALL_SUBDIR = $(INSTALL_DIR)/$(NAME)
-
-ENSURE_XSL = if ! test -e "$(TOOLS_DIR)/xsl"; \
-	     then $(TOOLS_DIR)/bin/find-xsl.py; fi
-
-# Customization hooks for xsltproc options
-HTML_XSLTPROC_OPTS = 
-FO_XSLTPROC_OPTS =
-# FO example: --stringparam page.height 9in --stringparam page.width 6.4in
-
-# Uncomment the following line if you'd like to print on A4 paper
-# FO_XSLTPROC_OPTS = --stringparam paper.type A4
-
-# Override in locale-specific Makefile to localize the word in the 
-# auto-generated version file.
-L10N_REVISION = Revision
-
-# Grouping targets
-all: all-book
-all-book: book-html book-html-chunk book-pdf book-ps
-all-html: book-html book-html-chunk
-all-pdf: book-pdf
-all-ps: book-ps
-
-install: install-book
-install-book: install-book-html install-book-html-chunk \
-	      install-book-pdf install-book-ps
-
-clean: book-clean
-
-# Build targets
-$(VERSION_SOURCE): book-version
-
-book-version:
-	@if $(SVNVERSION) . > /dev/null; then \
-	  echo '<!ENTITY svn.version "$(L10N_REVISION) '`$(SVNVERSION) .`'">' \
-	    > $(VERSION_SOURCE).tmp; \
-	else \
-	  echo '<!ENTITY svn.version "">' > $(VERSION_SOURCE).tmp; \
-	fi
-	@if cmp -s $(VERSION_SOURCE) $(VERSION_SOURCE).tmp; then \
-	  rm $(VERSION_SOURCE).tmp; \
-	else \
-	  mv $(VERSION_SOURCE).tmp $(VERSION_SOURCE); \
-	fi
-
-book-html: $(HTML_TARGET)
-$(HTML_TARGET): $(ALL_SOURCE) $(VERSION_SOURCE) $(STYLESHEET) $(IMAGES)
-	$(ENSURE_XSL)
-	$(XSLTPROC) $(HTML_XSLTPROC_OPTS) --output $(HTML_TARGET) \
-	  $(TOOLS_DIR)/html-stylesheet.xsl $(XML_SOURCE)
-
-# The trailing slash on the xsltproc --output option is essential to
-# output pages into the directory
-book-html-chunk: $(HTML_CHUNK_TARGET)
-$(HTML_CHUNK_TARGET): $(ALL_SOURCE) $(VERSION_SOURCE) $(STYLESHEET) $(IMAGES)
-	mkdir -p $(HTML_CHUNK_DIR)
-	mkdir -p $(HTML_CHUNK_DIR)/images
-	$(ENSURE_XSL)
-	$(XSLTPROC) $(HTML_XSLTPROC_OPTS) \
-           --output $(HTML_CHUNK_DIR)/ \
-	   $(TOOLS_DIR)/chunk-stylesheet.xsl $(XML_SOURCE)
-	cp $(STYLESHEET) $(HTML_CHUNK_DIR)
-	cp $(IMAGES) $(HTML_CHUNK_DIR)/images
-
-$(FO_TARGET): $(ALL_SOURCE) $(VERSION_SOURCE) $(IMAGES)
-	$(ENSURE_XSL)
-	$(XSLTPROC) $(FO_XSLTPROC_OPTS) --output $(FO_TARGET) \
-	  $(TOOLS_DIR)/fo-stylesheet.xsl $(XML_SOURCE)
-
-book-pdf: $(PDF_TARGET)
-$(PDF_TARGET): $(FO_TARGET) $(IMAGES)
-	$(TOOLS_DIR)/bin/run-fop.sh . -fo $(FO_TARGET) \
-	  -pdf $(PDF_TARGET)
-
-book-ps: $(PS_TARGET)
-$(PS_TARGET): $(FO_TARGET) $(IMAGES)
-	$(TOOLS_DIR)/bin/run-fop.sh . -fo $(FO_TARGET) \
-	  -ps $(PS_TARGET)
-
-# Install targets
-$(INSTALL_SUBDIR):
-	$(INSTALL) -d $(INSTALL_SUBDIR)
-
-install-book-html: $(HTML_TARGET) $(INSTALL_SUBDIR)
-	$(INSTALL) -d $(INSTALL_SUBDIR)/images
-	$(INSTALL) $(HTML_TARGET) $(INSTALL_SUBDIR)
-	$(INSTALL) $(STYLESHEET) $(INSTALL_SUBDIR)
-	$(INSTALL) $(IMAGES) $(INSTALL_SUBDIR)/images
-
-install-book-html-chunk: $(HTML_CHUNK_TARGET) $(INSTALL_SUBDIR)
-	$(INSTALL) -d $(INSTALL_SUBDIR)/images
-	$(INSTALL) $(HTML_CHUNK_DIR)/*.html $(INSTALL_SUBDIR)
-	$(INSTALL) $(STYLESHEET) $(INSTALL_SUBDIR)
-	$(INSTALL) $(IMAGES) $(INSTALL_SUBDIR)/images
-
-install-book-pdf: $(PDF_TARGET) $(INSTALL_SUBDIR)
-	$(INSTALL) $(PDF_TARGET) $(INSTALL_SUBDIR)
-
-install-book-ps: $(PS_TARGET) $(INSTALL_SUBDIR)
-	$(INSTALL) $(PS_TARGET) $(INSTALL_SUBDIR)
-
-# Clean targets
-book-clean:
-	rm -f $(VERSION_SOURCE)
-	rm -f $(HTML_TARGET) $(FO_TARGET)
-	rm -rf $(HTML_CHUNK_DIR)
-	rm -f $(PDF_TARGET) $(PS_TARGET) 
-
-# Utility targets
-valid: $(VERSION_SOURCE)
-	$(XMLLINT) --noout --nonet --valid $(XML_SOURCE)
-
+include ../tools/Makefile.base-rules

Copied: trunk/src/tools/Makefile.base-rules (from r1782, trunk/src/tools/Makefile.base)
==============================================================================
--- trunk/src/tools/Makefile.base	(original)
+++ trunk/src/tools/Makefile.base-rules	Tue Nov  1 08:50:56 2005
@@ -1,52 +1,4 @@
-# This is a base Makefile fragment, which is expected to be included by the
-# locale-specific Makefiles located at ../LOCALE_CODE/Makefile .  As a result,
-# all relative paths contained within are relative to the LOCALE_CODE
-# directory, and *not* to the tools directory, where this file itself resides.
-
-# Paths which you may wish to customize:
-XSLTPROC = xsltproc
-XMLLINT = xmllint
-INSTALL_DIR = $(DESTDIR)/usr/share/doc/subversion
-INSTALL = install
-SVNVERSION = svnversion
-
-# You should not normally need to edit anything below here.
-SHELL = /bin/sh
-
-NAME = book
-DIR = book
-TOOLS_DIR = ../tools
-OUTNAME = svn-$(NAME)
-
-HTML_CHUNK_DIR = $(DIR)/html-chunk
-HTML_TARGET = $(DIR)/$(OUTNAME).html
-# In the HTML chunk build, index.html is created last, so serves as an 
-# acceptable timestamp file for the entire multi-file output.
-HTML_CHUNK_TARGET = $(HTML_CHUNK_DIR)/index.html
-PDF_TARGET = $(DIR)/$(OUTNAME).pdf
-PS_TARGET = $(DIR)/$(OUTNAME).ps
-FO_TARGET = $(DIR)/$(OUTNAME).fo
-XML_SOURCE = $(DIR)/$(NAME).xml
-VERSION_SOURCE = $(DIR)/version.xml
-ALL_SOURCE = $(DIR)/*.xml
-IMAGES = $(DIR)/images/*.png
-STYLESHEET = $(DIR)/styles.css
-INSTALL_SUBDIR = $(INSTALL_DIR)/$(NAME)
-
-ENSURE_XSL = if ! test -e "$(TOOLS_DIR)/xsl"; \
-	     then $(TOOLS_DIR)/bin/find-xsl.py; fi
-
-# Customization hooks for xsltproc options
-HTML_XSLTPROC_OPTS = 
-FO_XSLTPROC_OPTS =
-# FO example: --stringparam page.height 9in --stringparam page.width 6.4in
-
-# Uncomment the following line if you'd like to print on A4 paper
-# FO_XSLTPROC_OPTS = --stringparam paper.type A4
-
-# Override in locale-specific Makefile to localize the word in the 
-# auto-generated version file.
-L10N_REVISION = Revision
+# See comment in ./Makefile.base-vars
 
 # Grouping targets
 all: all-book
@@ -94,7 +46,7 @@
            --output $(HTML_CHUNK_DIR)/ \
 	   $(TOOLS_DIR)/chunk-stylesheet.xsl $(XML_SOURCE)
 	cp $(STYLESHEET) $(HTML_CHUNK_DIR)
-	cp $(IMAGES) $(HTML_CHUNK_DIR)/images
+	$(IFIMAGES) cp $(IMAGES) $(HTML_CHUNK_DIR)/images $(ENDIF)
 
 $(FO_TARGET): $(ALL_SOURCE) $(VERSION_SOURCE) $(IMAGES)
 	$(ENSURE_XSL)
@@ -119,13 +71,13 @@
 	$(INSTALL) -d $(INSTALL_SUBDIR)/images
 	$(INSTALL) $(HTML_TARGET) $(INSTALL_SUBDIR)
 	$(INSTALL) $(STYLESHEET) $(INSTALL_SUBDIR)
-	$(INSTALL) $(IMAGES) $(INSTALL_SUBDIR)/images
+	$(IFIMAGES) $(INSTALL) $(IMAGES) $(INSTALL_SUBDIR)/images $(ENDIF)
 
 install-book-html-chunk: $(HTML_CHUNK_TARGET) $(INSTALL_SUBDIR)
 	$(INSTALL) -d $(INSTALL_SUBDIR)/images
 	$(INSTALL) $(HTML_CHUNK_DIR)/*.html $(INSTALL_SUBDIR)
 	$(INSTALL) $(STYLESHEET) $(INSTALL_SUBDIR)
-	$(INSTALL) $(IMAGES) $(INSTALL_SUBDIR)/images
+	$(IFIMAGES) $(INSTALL) $(IMAGES) $(INSTALL_SUBDIR)/images $(ENDIF)
 
 install-book-pdf: $(PDF_TARGET) $(INSTALL_SUBDIR)
 	$(INSTALL) $(PDF_TARGET) $(INSTALL_SUBDIR)

Copied: trunk/src/tools/Makefile.base-vars (from r1782, trunk/src/tools/Makefile.base)
==============================================================================
--- trunk/src/tools/Makefile.base	(original)
+++ trunk/src/tools/Makefile.base-vars	Tue Nov  1 08:50:56 2005
@@ -1,7 +1,25 @@
-# This is a base Makefile fragment, which is expected to be included by the
-# locale-specific Makefiles located at ../LOCALE_CODE/Makefile .  As a result,
-# all relative paths contained within are relative to the LOCALE_CODE
-# directory, and *not* to the tools directory, where this file itself resides.
+# This file -  Makefile.base-vars - together with the file Makefile.base-rules,
+# make up a reusable buildsystem for DocBook XML books.
+# The split into two files is required because of the nature of Make variables:
+# In the case of variables used in commands, expansion occurs when the commands
+# are executed, so values can be overridden by defining a new value after the
+# rule definition - BUT in the case of variables used to specify targets and
+# sources, expansion occurs when Make parses the rule.  Therefore, any override
+# must take place BEFORE the rule definition.  Since this Makefile fragment
+# wishes to both provide defaults and allow overriding of target and source
+# file names, it is necessary to place the default variable definitions in
+# one file, and the rules in another, so that overrides may be specified
+# after the defaults, but before the rules - like this:
+#
+#   include ../tools/Makefile.base-vars
+#   NAME = my-book
+#   DIR = my-book-dir
+#   include ../tools/Makefile.base-rules
+#
+# Note that this is a Makefile fragment intended for inclusion.  As a result,
+# all relative paths contained within are relative to including Makefile's
+# directory, not to this fragment's directory.  The TOOLS_DIR and DIR variables
+# should be overridden if necessary to ensure proper paths are used.
 
 # Paths which you may wish to customize:
 XSLTPROC = xsltproc
@@ -13,8 +31,9 @@
 # You should not normally need to edit anything below here.
 SHELL = /bin/sh
 
-NAME = book
-DIR = book
+NAME = OVERRIDE_ME_WITH_THE_SHORT_FILESYSTEM_NAME_OF_YOUR_BOOK
+DIR = .
+IMAGES =
 TOOLS_DIR = ../tools
 OUTNAME = svn-$(NAME)
 
@@ -29,12 +48,13 @@
 XML_SOURCE = $(DIR)/$(NAME).xml
 VERSION_SOURCE = $(DIR)/version.xml
 ALL_SOURCE = $(DIR)/*.xml
-IMAGES = $(DIR)/images/*.png
 STYLESHEET = $(DIR)/styles.css
 INSTALL_SUBDIR = $(INSTALL_DIR)/$(NAME)
 
 ENSURE_XSL = if ! test -e "$(TOOLS_DIR)/xsl"; \
 	     then $(TOOLS_DIR)/bin/find-xsl.py; fi
+IFIMAGES = if test -n "$(IMAGES)"; then
+ENDIF = ; fi
 
 # Customization hooks for xsltproc options
 HTML_XSLTPROC_OPTS = 
@@ -47,100 +67,3 @@
 # Override in locale-specific Makefile to localize the word in the 
 # auto-generated version file.
 L10N_REVISION = Revision
-
-# Grouping targets
-all: all-book
-all-book: book-html book-html-chunk book-pdf book-ps
-all-html: book-html book-html-chunk
-all-pdf: book-pdf
-all-ps: book-ps
-
-install: install-book
-install-book: install-book-html install-book-html-chunk \
-	      install-book-pdf install-book-ps
-
-clean: book-clean
-
-# Build targets
-$(VERSION_SOURCE): book-version
-
-book-version:
-	@if $(SVNVERSION) . > /dev/null; then \
-	  echo '<!ENTITY svn.version "$(L10N_REVISION) '`$(SVNVERSION) .`'">' \
-	    > $(VERSION_SOURCE).tmp; \
-	else \
-	  echo '<!ENTITY svn.version "">' > $(VERSION_SOURCE).tmp; \
-	fi
-	@if cmp -s $(VERSION_SOURCE) $(VERSION_SOURCE).tmp; then \
-	  rm $(VERSION_SOURCE).tmp; \
-	else \
-	  mv $(VERSION_SOURCE).tmp $(VERSION_SOURCE); \
-	fi
-
-book-html: $(HTML_TARGET)
-$(HTML_TARGET): $(ALL_SOURCE) $(VERSION_SOURCE) $(STYLESHEET) $(IMAGES)
-	$(ENSURE_XSL)
-	$(XSLTPROC) $(HTML_XSLTPROC_OPTS) --output $(HTML_TARGET) \
-	  $(TOOLS_DIR)/html-stylesheet.xsl $(XML_SOURCE)
-
-# The trailing slash on the xsltproc --output option is essential to
-# output pages into the directory
-book-html-chunk: $(HTML_CHUNK_TARGET)
-$(HTML_CHUNK_TARGET): $(ALL_SOURCE) $(VERSION_SOURCE) $(STYLESHEET) $(IMAGES)
-	mkdir -p $(HTML_CHUNK_DIR)
-	mkdir -p $(HTML_CHUNK_DIR)/images
-	$(ENSURE_XSL)
-	$(XSLTPROC) $(HTML_XSLTPROC_OPTS) \
-           --output $(HTML_CHUNK_DIR)/ \
-	   $(TOOLS_DIR)/chunk-stylesheet.xsl $(XML_SOURCE)
-	cp $(STYLESHEET) $(HTML_CHUNK_DIR)
-	cp $(IMAGES) $(HTML_CHUNK_DIR)/images
-
-$(FO_TARGET): $(ALL_SOURCE) $(VERSION_SOURCE) $(IMAGES)
-	$(ENSURE_XSL)
-	$(XSLTPROC) $(FO_XSLTPROC_OPTS) --output $(FO_TARGET) \
-	  $(TOOLS_DIR)/fo-stylesheet.xsl $(XML_SOURCE)
-
-book-pdf: $(PDF_TARGET)
-$(PDF_TARGET): $(FO_TARGET) $(IMAGES)
-	$(TOOLS_DIR)/bin/run-fop.sh . -fo $(FO_TARGET) \
-	  -pdf $(PDF_TARGET)
-
-book-ps: $(PS_TARGET)
-$(PS_TARGET): $(FO_TARGET) $(IMAGES)
-	$(TOOLS_DIR)/bin/run-fop.sh . -fo $(FO_TARGET) \
-	  -ps $(PS_TARGET)
-
-# Install targets
-$(INSTALL_SUBDIR):
-	$(INSTALL) -d $(INSTALL_SUBDIR)
-
-install-book-html: $(HTML_TARGET) $(INSTALL_SUBDIR)
-	$(INSTALL) -d $(INSTALL_SUBDIR)/images
-	$(INSTALL) $(HTML_TARGET) $(INSTALL_SUBDIR)
-	$(INSTALL) $(STYLESHEET) $(INSTALL_SUBDIR)
-	$(INSTALL) $(IMAGES) $(INSTALL_SUBDIR)/images
-
-install-book-html-chunk: $(HTML_CHUNK_TARGET) $(INSTALL_SUBDIR)
-	$(INSTALL) -d $(INSTALL_SUBDIR)/images
-	$(INSTALL) $(HTML_CHUNK_DIR)/*.html $(INSTALL_SUBDIR)
-	$(INSTALL) $(STYLESHEET) $(INSTALL_SUBDIR)
-	$(INSTALL) $(IMAGES) $(INSTALL_SUBDIR)/images
-
-install-book-pdf: $(PDF_TARGET) $(INSTALL_SUBDIR)
-	$(INSTALL) $(PDF_TARGET) $(INSTALL_SUBDIR)
-
-install-book-ps: $(PS_TARGET) $(INSTALL_SUBDIR)
-	$(INSTALL) $(PS_TARGET) $(INSTALL_SUBDIR)
-
-# Clean targets
-book-clean:
-	rm -f $(VERSION_SOURCE)
-	rm -f $(HTML_TARGET) $(FO_TARGET)
-	rm -rf $(HTML_CHUNK_DIR)
-	rm -f $(PDF_TARGET) $(PS_TARGET) 
-
-# Utility targets
-valid: $(VERSION_SOURCE)
-	$(XMLLINT) --noout --nonet --valid $(XML_SOURCE)
-



More information about the svnbook-dev mailing list