64c208c638da694383dd7ce82785dec9d5a992b3
[plcapi.git] / doc / Makefile
1 #
2 # (Re)builds API documentation
3 #
4 # Mark Huang <mlhuang@cs.princeton.edu>
5 # Copyright (C) 2006 The Trustees of Princeton University
6 #
7 # $Id$
8 #
9
10 all: PLCAPI.html
11
12 # XML - as opposed to SGML - requires an identifier - see 
13 # http://www.docbook.org/tdg/en/html/appb.html
14 # and, openjade opens http connections when using the official URL 
15 # as an identifier; this is slow, and sometimes fails and breaks the build
16
17 # locating locally installed docbook43 dtd - fedora-specific
18 remote-docbook-43 = http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd
19 local-docbook-43 = $(wildcard /usr/share/sgml/docbook/xml-dtd-4.3-*/docbookx.dtd)
20 docbook-43=$(if $(local-docbook-43),$(local-docbook-43),$(remote-docbook-43))
21
22 PLCAPI.xml: PLCAPI.xml.in
23         $(if $(local-docbook-43), \
24         echo Using locally installed DTD $(local-docbook-43), \
25         echo WARNING - could not locate local DTD - using remote $(remote-docbook-43))
26         sed -e "s:@DOCBOOK-43@:$(docbook-43):" $< > $@
27
28 .PLCAPI.xml.valid: Methods.xml
29
30 API_SOURCES = ../PLC/__init__.py ../PLC/Methods/__init__.py
31
32 Methods.xml: DocBook.py DocBookLocal.py $(API_SOURCES)
33         PYTHONPATH=.. ./DocBookLocal.py > $@
34
35 #
36 # Documentation
37 #
38
39 # Validate the XML
40 .%.xml.valid: %.xml
41         xmllint --valid --output $@ $<
42
43 # Remove the temporary output file after compilation
44 .SECONDARY: .%.xml.valid
45
46 # Compile it into other formats
47 FORMATS := dvi html man ps pdf rtf tex texi txt
48
49 DOCBOOK2FLAGS := -V biblio-number=1
50
51 define docbook2
52 %.$(1): %.xml .%.xml.valid
53         docbook2$(1) --nochunks $$(DOCBOOK2FLAGS) $$<
54 endef
55
56 $(foreach format,$(FORMATS),$(eval $(call docbook2,$(format))))
57
58 clean:
59         rm -f $(patsubst %,*.%,$(FORMATS)) .*.xml.valid Methods.xml
60
61 .PHONY: clean all