1.5. Makefiles

Included with docscm is a GNU Makefile fragment, Makefile.docbook, which provides rules for certain common Makefile productions. PDF, PostScript and HTML output can be produced from .xml files, which are automatically indexed. XML is produced from (the docscm dialect of) SXML using sxml2xml.

If DOCSCM_STYLESHEET is defined, it is used as the path to the DSSSL stylesheet to use when translating DocBook to Print or HTML formats. If DOCSCM_PARAMS is defined, the contents are put on the command-lines of docbook2pdf, docbook2ps, and/or docbook2html. This can be used to supply, for instance, -i a4paper to select A4 paper size.

To make use of Makefile.docbook in your own makefiles, GNU make's include command can be used along with docscm-config. The following example is the Makefile used to build this documentation:

    1: TARGET=docscm
    2: TARGET_INC=../extract-doc.xml ../sxml2xml.xml
    3: 
    4: # Use A4 rather than US Letter
    5: DOCSCM_PARAMS=-i a4paper
    6: 
    7: # Set this to override the DSSSL stylesheet used by Makefile.docbook.
    8: #DOCSCM_STYLESHEET=$(CURDIR)/my-stylesheet.dsl
    9: 
   10: all: $(TARGET).pdf
   11: 
   12: $(TARGET).xml: $(TARGET_INC)
   13: 
   14: # The index is precious - expensive to build, but intermediary.
   15: .SECONDARY: $(TARGET)-index.xml
   16: 
   17: clean:
   18:         rm -f $(TARGET_INC)
   19:         rm -f $(patsubst %.xml,%.sxml,$(TARGET_INC))
   20:         rm -f $(TARGET).xml $(TARGET).tex $(TARGET).out
   21:         rm -f $(TARGET)-index.xml
   22: 
   23: include $(shell docscm-config --makefile)