CircleCI: More cleanup
[ghc.git] / rules / sphinx.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://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13
14 # Build Sphinx documentation
15
16 # We are careful not to use the same directory the doctree files for the
17 # various Sphinx targets as make may run them in parallel (see #10950).
18
19 define sphinx
20 $(call trace, sphinx($1,$2))
21 $(call profStart, sphinx($1,$2))
22 # $1 = dir
23 # $2 = docname
24
25 $(eval $(call clean-target,$1,sphinx,$1/.doctrees-html/ $1/.doctrees-pdf/ $1/build-html/ $1/build-pdf/ $1/$2.pdf))
26
27 # empty "all_$1" target just in case we're not building docs at all
28 $(call all-target,$1,)
29
30 .PHONY: html_$1
31 ifeq "$$(phase)" "final"
32 ifeq "$$(BUILD_SPHINX_HTML)" "YES"
33 $(call all-target,$1,html_$1)
34 INSTALL_HTML_DOC_DIRS += $1/build-html/$2
35 endif
36 endif
37
38 html_$1 : $1/build-html/$2/index.html
39 html : html_$1
40
41 ifneq "$$(BINDIST)" "YES"
42 $1/build-html/$2/index.html: $1/conf.py $$($1_RST_SOURCES)
43 $(SPHINXBUILD) -b html -d $1/.doctrees-html $(SPHINXOPTS) $1 $1/build-html/$2
44 endif
45
46
47 .PHONY: pdf_$1
48 ifeq "$$(phase)" "final"
49 ifeq "$$(BUILD_SPHINX_PDF)" "YES"
50 $(call all-target,$1,pdf_$1)
51 INSTALL_DOCS += $1/$2.pdf
52 endif
53 endif
54
55 pdf_$1 : $1/$2.pdf
56 pdf : pdf_$1
57
58 ifneq "$$(BINDIST)" "YES"
59 $1/$2.pdf: $1/conf.py $$($1_RST_SOURCES)
60 $(SPHINXBUILD) -b latex -d $1/.doctrees-pdf $(SPHINXOPTS) $1 $1/build-pdf/$2
61 cd $1/build-pdf/$2 ; xelatex -halt-on-error $2.tex
62 cd $1/build-pdf/$2 ; xelatex -halt-on-error $2.tex
63 cd $1/build-pdf/$2 ; xelatex -halt-on-error $2.tex
64 cd $1/build-pdf/$2 ; makeindex $2.idx
65 cd $1/build-pdf/$2 ; xelatex -halt-on-error $2.tex
66 cd $1/build-pdf/$2 ; xelatex -halt-on-error $2.tex
67 cp $1/build-pdf/$2/$2.pdf $1/$2.pdf
68 endif
69
70
71 $(call profEnd, sphinx($1,$2))
72 endef