Fold testsuite.git into ghc.git (re #8545)
[ghc.git] / rules / haddock.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 define haddock # args: $1 = dir, $2 = distdir
15 $(call trace, haddock($1,$2))
16 $(call profStart, haddock($1,$2))
17
18 ifeq "$$($1_$2_DO_HADDOCK)" "YES"
19
20 ifeq "$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)" ""
21 $$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE = $1/$2/doc/html/$$($1_PACKAGE)/$$($1_PACKAGE).haddock
22 ALL_HADDOCK_FILES += $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)
23 else
24 $$(error Already got a haddock file for $$($1_PACKAGE))
25 endif
26
27 haddock: html_$1
28
29 ifeq "$$(HADDOCK_DOCS)" "YES"
30 $(call all-target,$1_$2_haddock,html_$1)
31 endif
32
33 .PHONY: html_$1
34 html_$1 : $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)
35
36 $$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_DEPS = $$(foreach n,$$($1_$2_DEPS),$$($$n_HADDOCK_FILE) $$($$n_dist-install_$$(HADDOCK_WAY)_LIB))
37
38 ifeq "$$(HSCOLOUR_SRCS)" "YES"
39 $1_$2_HADDOCK_FLAGS += --source-module=src/%{MODULE/./-}.html --source-entity=src/%{MODULE/./-}.html\#%{NAME}
40 endif
41
42 ifneq "$$(BINDIST)" "YES"
43 # We need the quadruple dollars for the dependencies, as it isn't
44 # guaranteed that we are processing the packages in dependency order,
45 # so we don't want to expand it yet.
46 $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) : $$$$(haddock_INPLACE) $$$$(ghc-cabal_INPLACE) $$($1_$2_HS_SRCS) $$$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_DEPS) | $$$$(dir $$$$@)/.
47 ifeq "$$(HSCOLOUR_SRCS)" "YES"
48 "$$(ghc-cabal_INPLACE)" hscolour $1 $2
49 endif
50 "$$(TOP)/$$(INPLACE_BIN)/haddock" \
51 --odir="$1/$2/doc/html/$$($1_PACKAGE)" \
52 --no-tmp-comp-dir \
53 --dump-interface=$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) \
54 --html \
55 --hoogle \
56 --title="$$($1_PACKAGE)-$$($1_$2_VERSION)$$(if $$(strip $$($1_$2_SYNOPSIS)),: $$(strip $$($1_$2_SYNOPSIS)),)" \
57 --prologue="$1/$2/haddock-prologue.txt" \
58 $$(foreach mod,$$($1_$2_HIDDEN_MODULES),--hide=$$(mod)) \
59 $$(foreach pkg,$$($1_$2_DEPS),$$(if $$($$(pkg)_HADDOCK_FILE),--read-interface=../$$(pkg)$$(comma)../$$(pkg)/src/%{MODULE/./-}.html\#%{NAME}$$(comma)$$($$(pkg)_HADDOCK_FILE))) \
60 $$(foreach opt,$$($1_$2_$$(HADDOCK_WAY)_ALL_HC_OPTS),--optghc=$$(opt)) \
61 $$($1_$2_HADDOCK_FLAGS) $$($1_$2_HADDOCK_OPTS) \
62 $$($1_$2_HS_SRCS) \
63 $$($1_$2_EXTRA_HADDOCK_SRCS) \
64 +RTS -t$$@.t --machine-readable
65
66 # --no-tmp-comp-dir above is important: it saves a few minutes in a
67 # validate. This flag lets Haddock use the pre-compiled object files
68 # for the package rather than rebuilding the modules of the package in
69 # a temporary directory. Haddock needs to build the package when it
70 # uses the Template Haskell or Annotations extensions, for example.
71
72 # Make the haddocking depend on the library .a file, to ensure
73 # that we wait until the library is fully built before we haddock it
74 $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) : $$($1_$2_$$(HADDOCK_WAY)_LIB)
75 endif
76
77 endif
78
79 $(call profEnd, haddock($1,$2))
80 endef
81