emit a helpful message if you say 'make html' and BUILD_DOCBOOK_HTML=NO
[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 # $1 = dir
18 # $2 = docname
19
20 $(call clean-target,$1,docbook,$1/$2 $1/$2.pdf $1/$2.ps)
21
22 # empty "all_$1" target just in case we're not building docs at all
23 $(call all-target,$1,)
24
25 .PHONY: html_$1
26
27 ifeq "$$(BUILD_DOCBOOK_HTML)" "YES"
28 $(call all-target,$1,html_$1)
29
30 html_$1 : $1/$2/index.html
31
32 $1/$2/index.html: $$($1_DOCBOOK_SOURCES)
33         "$$(RM)" $$(RM_OPTS) -r $$(dir $$@)
34         "$$(XSLTPROC)" --stringparam base.dir $$(dir $$@) \
35                        --stringparam use.id.as.filename 1 \
36                        --stringparam html.stylesheet fptools.css \
37                        $$(XSLTPROC_LABEL_OPTS) $$(XSLTPROC_OPTS) \
38                        $$(DIR_DOCBOOK_XSL)/html/chunk.xsl $1/$2.xml
39         cp mk/fptools.css $$(dir $$@)
40 else
41 html_$1 :
42         @echo "*** HTML documentation is disabled; BUILD_DOCBOOK_HTML = NO"
43         @exit 1
44 endif
45
46 .PHONY: ps_$1
47 ifeq "$$(BUILD_DOCBOOK_PS)" "YES"
48 $(call all-target,$1,ps_$1)
49
50 ps_$1 : $1/$2.ps
51
52 $1/$2.ps: $$($1_DOCBOOK_SOURCES)
53         "$$(DBLATEX)" $$(DBLATEX_OPTS) $1/$2.xml --ps -o $$@
54 else
55 ps_$1 :
56         @echo "*** PS documentation is disabled; BUILD_DOCBOOK_PS = NO"
57         @exit 1
58 endif
59
60 ifeq "$$(BUILD_DOCBOOK_PDF)" "YES"
61 $(call all-target,$1,pdf_$1)
62
63 .PHONY: pdf_$1
64 pdf_$1 : $1/$2.pdf
65
66 $1/$2.pdf: $$($1_DOCBOOK_SOURCES)
67         "$$(DBLATEX)" $$(DBLATEX_OPTS) $1/$2.xml --pdf -o $$@
68 else
69 pdf_$1 :
70         @echo "*** PDF documentation is disabled; BUILD_DOCBOOK_PDF = NO"
71         @exit 1
72 endif
73
74 endef
75