Build system improvements
[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 "$$(phase)" ""
29 ifeq "$$(BUILD_DOCBOOK_HTML)" "YES"
30 $(call all-target,$1,html_$1)
31 INSTALL_HTML_DOC_DIRS += $1/$2
32 endif
33 endif
34
35 html_$1 : $1/$2/index.html
36
37 ifneq "$$(BINDIST)" "YES"
38 $1/$2/index.html: $$($1_DOCBOOK_SOURCES)
39         "$$(RM)" $$(RM_OPTS_REC) $$(dir $$@)
40         "$$(XSLTPROC)" --stringparam base.dir $$(dir $$@) \
41                        --stringparam use.id.as.filename 1 \
42                        --stringparam html.stylesheet fptools.css \
43                        --nonet \
44                        $$(XSLTPROC_LABEL_OPTS) $$(XSLTPROC_OPTS) \
45                        $$(XSLTPROC_HTML_STYLESHEET) \
46                        $1/$2.xml
47         cp mk/fptools.css $$(dir $$@)
48 endif
49
50
51 .PHONY: ps_$1
52 ifeq "$$(phase)" ""
53 ifeq "$$(BUILD_DOCBOOK_PS)" "YES"
54 $(call all-target,$1,ps_$1)
55 INSTALL_DOCS += $1/$2.ps
56 endif
57 endif
58
59 ps_$1 : $1/$2.ps
60
61 ifneq "$$(BINDIST)" "YES"
62 $1/$2.ps: $$($1_DOCBOOK_SOURCES)
63         "$$(DBLATEX)" $$(DBLATEX_OPTS) $1/$2.xml --ps -o $$@
64         [ -f $$@ ]
65 endif
66
67 ifeq "$$(phase)" ""
68 ifeq "$$(BUILD_DOCBOOK_PDF)" "YES"
69 $(call all-target,$1,pdf_$1)
70 INSTALL_DOCS += $1/$2.pdf
71 endif
72 endif
73
74 .PHONY: pdf_$1
75 pdf_$1 : $1/$2.pdf
76
77 ifneq "$$(BINDIST)" "YES"
78 $1/$2.pdf: $$($1_DOCBOOK_SOURCES)
79         "$$(DBLATEX)" $$(DBLATEX_OPTS) $1/$2.xml --pdf -o $$@
80         [ -f $$@ ]
81 endif
82
83 endef
84