aboutsummaryrefslogtreecommitdiffstats
path: root/docs/usermanual/Makefile
blob: 36ea5e20a7274cefaf173508705afb7c12a5880b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# XSL stylesheets downloaded from http://docbook.sourceforge.net/release/xsl/current/html/

topdir = .
manual = $(topdir)/usermanual.xml
# types = pdf txt rtf ps xhtml html man tex texi dvi
# types = pdf txt
types = $(xmltotypes) $(htmltypes) $(docbooktotypes)
xmltotypes = 
docbooktotypes = dvi pdf ps rtf tex texi txt
htmltypes = html xhtml
htmlxsl = $(if $(filter $@,$(foreach type,$(htmltypes),$(type)-nochunks)),docbook-utf8.xsl,chunk-utf8.xsl)
htmlcssfile = docbook.css
htmlcss = $(topdir)/html.css
# htmlcssfile =
# htmlcss =
cleanfiles = $(foreach i,$(types),$(topdir)/$(i))

ifdef DEBUG
define command
	$(1)
endef
else
define command
	@echo $(2) $(3) $(4)
	@$(1) 
endef
endif

all: $(types)

lint: $(manual) FORCE
	$(call command,xmllint --xinclude --postvalid --noout $(manual),XMLLINT $(manual))

$(types) $(foreach type,$(htmltypes),$(type)-nochunks): lint FORCE

$(foreach type,$(htmltypes),$(type)-nochunks): $(if $(htmlcss),$(htmlcss)) $(manual)
	@mkdir -p $@
ifdef htmlcss
	$(call command,install -m 0644 $(htmlcss) $@/$(htmlcssfile),CP $(htmlcss) $@/$(htmlcssfile))
endif
	$(call command,xsltproc --stringparam base.dir $@/ $(if $(htmlcssfile),--stringparam html.stylesheet $(htmlcssfile)) $(htmlxsl) $(manual) > $@/index.$(patsubst %-nochunks,%,$@),XSLTPROC $@ $(manual))

$(htmltypes): $(if $(htmlcss),$(htmlcss)) $(manual)
	@mkdir -p $@
ifdef htmlcss
	$(call command,install -m 0644 $(htmlcss) $@/$(htmlcssfile),CP $(htmlcss) $@/$(htmlcssfile))
endif
	$(call command,xsltproc --param use.id.as.filename 1 --stringparam base.dir $@/ $(if $(htmlcssfile),--stringparam html.stylesheet $(htmlcssfile)) $(htmlxsl) $(manual),XSLTPROC $@ $(manual))

$(xmltotypes): $(manual)
	$(call command,xmlto --extensions -o $(topdir)/$@ $@ $(manual),XMLTO $@ $(manual))

$(docbooktotypes): $(manual)
	$(call command,docbook2$@ $(manual),DOCBOOK2 $@ $(manual))

clean:
	rm -rf $(cleanfiles)

$(foreach i,$(types) $(foreach type,$(htmltypes),$(type)-nochunks),clean-$(i)):
	rm -rf $(patsubst clean-%,%,$@)

FORCE: