Do dependency analysis when kind-checking type declarations
[ghc-hetmet.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://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 #      http://hackage.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
17 ifneq "$$($1_$2_DO_HADDOCK)" "NO"
18
19 ifeq "$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)" ""
20 $$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE = $1/$2/doc/html/$$($1_PACKAGE)/$$($1_PACKAGE).haddock
21 ALL_HADDOCK_FILES += $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)
22 else
23 $$(error Already got a haddock file for $$($1_PACKAGE))
24 endif
25
26 haddock: html_$1
27
28 ifeq "$$(HADDOCK_DOCS)" "YES"
29 $(call all-target,$1_$2_haddock,html_$1)
30 endif
31
32 .PHONY: html_$1
33 html_$1 : $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)
34
35 $$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_DEPS = $$(foreach n,$$($1_$2_DEPS),$$($$n_HADDOCK_FILE) $$($$n_dist-install_v_LIB))
36
37 ifeq "$$(HSCOLOUR_SRCS)" "YES"
38 $1_$2_HADDOCK_FLAGS += --source-module=src/%{MODULE/./-}.html --source-entity=src/%{MODULE/./-}.html\#%{NAME}
39 endif
40
41 ifneq "$$(BINDIST)" "YES"
42 $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) : $$(INPLACE_BIN)/haddock$$(exeext) $$(GHC_CABAL_INPLACE) $$($1_$2_HS_SRCS) $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_DEPS) | $$$$(dir $$$$@)/.
43 ifeq "$$(HSCOLOUR_SRCS)" "YES"
44         "$$(GHC_CABAL_INPLACE)" hscolour $2 $1
45 endif
46         "$$(TOP)/$$(INPLACE_BIN)/haddock" \
47           --odir="$1/$2/doc/html/$$($1_PACKAGE)" \
48           --no-tmp-comp-dir \
49           --dump-interface=$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) \
50           --html \
51           --hoogle \
52           --title="$$($1_PACKAGE)-$$($1_$2_VERSION)$$(if $$(strip $$($1_$2_SYNOPSIS)),: $$(strip $$($1_$2_SYNOPSIS)),)" \
53           --prologue="$1/$2/haddock-prologue.txt" \
54           $$(foreach mod,$$($1_$2_HIDDEN_MODULES),--hide=$$(mod)) \
55           $$(foreach pkg,$$($1_$2_DEPS),$$(if $$($$(pkg)_HADDOCK_FILE),--read-interface=../$$(pkg)$$(comma)../$$(pkg)/src/%{MODULE/./-}.html\#%{NAME}$$(comma)$$($$(pkg)_HADDOCK_FILE))) \
56           $$(foreach opt,$$($1_$2_v_ALL_HC_OPTS),--optghc=$$(opt)) \
57           $$($1_$2_HADDOCK_FLAGS) $$($1_$2_HADDOCK_OPTS) \
58           $$($1_$2_HS_SRCS) \
59           $$($1_$2_EXTRA_HADDOCK_SRCS)
60
61 # --no-tmp-comp-dir above is important: it saves a few minutes in a
62 # validate.  This flag lets Haddock use the pre-compiled object files
63 # for the package rather than rebuilding the modules of the package in
64 # a temporary directory.  Haddock needs to build the package when it
65 # uses the Template Haskell or Annotations extensions, for example.
66
67 # Make the haddocking depend on the library .a file, to ensure
68 # that we wait until the library is fully build before we haddock it
69 $$($$($1_PACKAGE)_HADDOCK_FILE) : $$($1_$2_v_LIB)
70 endif
71
72 endif
73
74 endef
75