fix for HSCOLOUR_SRCS=NO
[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://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
16 ifneq "$$($1_$2_DO_HADDOCK)" "NO"
17
18 ifeq "$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)" ""
19 $$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE = $1/$2/doc/html/$$($1_PACKAGE)/$$($1_PACKAGE).haddock
20 ALL_HADDOCK_FILES += $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)
21 else
22 $$(error Already got a haddock file for $$($1_PACKAGE))
23 endif
24
25 haddock: $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)
26
27 ifeq "$$(HADDOCK_DOCS)" "YES"
28 $(call all-target,$1_$2_haddock,html_$1)
29 endif
30
31 .PHONY: html_$1
32 html_$1 : $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)
33
34 $$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_DEPS = $$(foreach n,$$($1_$2_DEPS),$$($$n_HADDOCK_FILE))
35
36 ifeq "$$(HSCOLOUR_SRCS)" "YES"
37 $1_$2_HADDOCK_FLAGS += --source-module=src/%{MODULE/./-}.html --source-entity=src/%{MODULE/./-}.html#%{NAME}
38 endif
39
40 ifneq "$$(BINDIST)" "YES"
41 $$($$($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 $$$$@)/.
42 ifeq "$$(HSCOLOUR_SRCS)" "YES"
43 "$$(GHC_CABAL_INPLACE)" hscolour $2 $1
44 endif
45 "$$(TOP)/$$(INPLACE_BIN)/haddock" \
46 --odir="$1/$2/doc/html/$$($1_PACKAGE)" \
47 --dump-interface=$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) \
48 --html \
49 --title="$$($1_PACKAGE)-$$($1_$2_VERSION)$$(if $$(strip $$($1_$2_SYNOPSIS)),: $$(strip $$($1_$2_SYNOPSIS)),)" \
50 --prologue="$1/$2/haddock-prologue.txt" \
51 $$(foreach pkg,$$($1_$2_DEPS),$$(if $$($$(pkg)_HADDOCK_FILE),--read-interface=../$$(pkg)$$(comma)$$($$(pkg)_HADDOCK_FILE))) \
52 $$(foreach opt,$$($1_$2_v_ALL_HC_OPTS),--optghc=$$(opt)) \
53 $$($1_$2_HADDOCK_FLAGS) $$($1_$2_HADDOCK_OPTS) \
54 $$($1_$2_HS_SRCS) \
55 $$($1_$2_EXTRA_HADDOCK_SRCS)
56
57 # Make the haddocking depend on the library .a file, to ensure
58 # that we wait until the library is fully build before we haddock it
59 $$($$($1_PACKAGE)_HADDOCK_FILE) : $$($1_$2_v_LIB)
60 endif
61
62 endif
63
64 endef
65