8488de14842686d35c5628861aab929f01aecc8f
[ghc-hetmet.git] / rules / docbook.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
7 # To understand how the build system works and how to modify it, see
8 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13
14 # Build docbook docs
15
16 define docbook
17 $(call trace, docbook($1,$2))
18 # $1 = dir
19 # $2 = docname
20
21 $(call clean-target,$1,docbook,$1/$2 $1/$2.pdf $1/$2.ps)
22
23 # empty "all_$1" target just in case we're not building docs at all
24 $(call all-target,$1,)
25
26 .PHONY: html_$1
27
28 ifeq "$$(BUILD_DOCBOOK_HTML)" "YES"
29 $(call all-target,$1,html_$1)
30 INSTALL_HTML_DOC_DIRS += $1/$2
31 endif
32
33 html_$1 : $1/$2/index.html
34
35 ifneq "$$(BINDIST)" "YES"
36 $1/$2/index.html: $$($1_DOCBOOK_SOURCES)
37         "$$(RM)" $$(RM_OPTS_REC) $$(dir $$@)
38         "$$(XSLTPROC)" --stringparam base.dir $$(dir $$@) \
39                        --stringparam use.id.as.filename 1 \
40                        --stringparam html.stylesheet fptools.css \
41                        --nonet \
42                        $$(XSLTPROC_LABEL_OPTS) $$(XSLTPROC_OPTS) \
43                        $$(XSLTPROC_HTML_STYLESHEET) \
44                        $1/$2.xml
45         cp mk/fptools.css $$(dir $$@)
46 endif
47
48
49 .PHONY: ps_$1
50 ifeq "$$(BUILD_DOCBOOK_PS)" "YES"
51 $(call all-target,$1,ps_$1)
52 INSTALL_DOCS += $1/$2.ps
53 endif
54
55 ps_$1 : $1/$2.ps
56
57 ifneq "$$(BINDIST)" "YES"
58 $1/$2.ps: $$($1_DOCBOOK_SOURCES)
59         "$$(DBLATEX)" $$(DBLATEX_OPTS) $1/$2.xml --ps -o $$@
60         [ -f $$@ ]
61 endif
62
63 ifeq "$$(BUILD_DOCBOOK_PDF)" "YES"
64 $(call all-target,$1,pdf_$1)
65 INSTALL_DOCS += $1/$2.pdf
66 endif
67
68 .PHONY: pdf_$1
69 pdf_$1 : $1/$2.pdf
70
71 ifneq "$$(BINDIST)" "YES"
72 $1/$2.pdf: $$($1_DOCBOOK_SOURCES)
73         "$$(DBLATEX)" $$(DBLATEX_OPTS) $1/$2.xml --pdf -o $$@
74         [ -f $$@ ]
75 endif
76
77 endef
78