Chapter 4. A suitable Makefile.am

Here is a suitable cut-down automake input file for the setup above :

XSLTPROC=xsltproc
XSLTPROC_FLAGS=@XSLTPROC_FLAGS@
XHTML_STYLESHEET=$(srcdir)/xsl/xhtml.xsl
CHUNK_XHTML_STYLESHEET=$(srcdir)/xsl/xhtml-chunk.xsl
XML_CATALOG_FILES=xsl/catalog.xml

htmldir = $(prefix)/share/doc/@PACKAGE@
dist_html_DATA = @PACKAGE@.html

if have_xsltproc

@PACKAGE@.html: ${top_srcdir}/doc/@PACKAGE@.xml
        XML_CATALOG_FILES=$(XML_CATALOG_FILES) $(XSLTPROC) $(XSLTPROC_FLAGS) -o $@ $(XHTML_STYLESHEET) $<

chunk: ${top_srcdir}/doc/@PACKAGE@.xml
        $(XSLTPROC) $(XSLTPROC_FLAGS) $(CHUNK_XHTML_STYLESHEET) $<

else

chunk:

@PACKAGE@.html:
        touch $@

endif

distclean-local:
        $(RM) -f xsl/catalog.xml

Clearly not the greatest Makefile ever, but you get the idea. The chunk target generates the chapter-per-file XHTML output. Note that we use XML_CATALOG_FILES in the environment to specify the catalog file to xsltproc. Later xsltproc versions allow you to specify more than one catalog in this variable, separated by spaces; but as it's not universal, we've used nextCatalog instead.