Change GHC.hs to Packages.hs in Hadrian user-settings.md
[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 # https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture
9 # https://gitlab.haskell.org/ghc/ghc/wikis/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 # N.B. If we don't redirect latex output to /dev/null then we end up with literally
60 # 30% of the build output being warnings, even in a successful build. However,
61 # to make sure that we don't silence errors we allow each xelatex invocation
62 # besides the last to fail.
63
64 $1/$2.pdf: $1/conf.py $$($1_RST_SOURCES)
65 $(SPHINXBUILD) -b latex -d $1/.doctrees-pdf $(SPHINXOPTS) $1 $1/build-pdf/$2
66 cd $1/build-pdf/$2 ; xelatex -halt-on-error $2.tex 2>/dev/null >/dev/null || true
67 cd $1/build-pdf/$2 ; xelatex -halt-on-error $2.tex 2>/dev/null >/dev/null || true
68 cd $1/build-pdf/$2 ; xelatex -halt-on-error $2.tex 2>/dev/null >/dev/null || true
69 cd $1/build-pdf/$2 ; makeindex $2.idx
70 cd $1/build-pdf/$2 ; xelatex -halt-on-error $2.tex 2>/dev/null >/dev/null || true
71 cd $1/build-pdf/$2 ; xelatex -halt-on-error $2.tex
72 cp $1/build-pdf/$2/$2.pdf $1/$2.pdf
73 endif
74
75
76 $(call profEnd, sphinx($1,$2))
77 endef