haddock.mk 2.95 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
# -----------------------------------------------------------------------------
#
# (c) 2009 The University of Glasgow
#
# This file is part of the GHC build system.
#
# To understand how the build system works and how to modify it, see
#      http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
#      http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
#
# -----------------------------------------------------------------------------

Ian Lynagh's avatar
Ian Lynagh committed
13

Simon Marlow's avatar
Simon Marlow committed
14
define haddock  # args: $1 = dir,  $2 = distdir
15
$(call trace, haddock($1,$2))
16
$(call profStart, haddock($1,$2))
Ian Lynagh's avatar
Ian Lynagh committed
17 18 19

ifneq "$$($1_$2_DO_HADDOCK)" "NO"

20 21 22
ifeq "$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)" ""
$$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE = $1/$2/doc/html/$$($1_PACKAGE)/$$($1_PACKAGE).haddock
ALL_HADDOCK_FILES += $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)
Ian Lynagh's avatar
Ian Lynagh committed
23 24 25 26
else
$$(error Already got a haddock file for $$($1_PACKAGE))
endif

27
haddock: html_$1
28

Ian Lynagh's avatar
Ian Lynagh committed
29
ifeq "$$(HADDOCK_DOCS)" "YES"
30
$(call all-target,$1_$2_haddock,html_$1)
31
endif
Ian Lynagh's avatar
Ian Lynagh committed
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_v_LIB))
Ian Lynagh's avatar
Ian Lynagh committed
37 38

ifeq "$$(HSCOLOUR_SRCS)" "YES"
39
$1_$2_HADDOCK_FLAGS += --source-module=src/%{MODULE/./-}.html --source-entity=src/%{MODULE/./-}.html\#%{NAME}
Ian Lynagh's avatar
Ian Lynagh committed
40 41
endif

42
ifneq "$$(BINDIST)" "YES"
43
$$($$($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 $$$$@)/.
Simon Marlow's avatar
Simon Marlow committed
44
ifeq "$$(HSCOLOUR_SRCS)" "YES"
45
	"$$(GHC_CABAL_INPLACE)" hscolour $2 $1
Simon Marlow's avatar
Simon Marlow committed
46
endif
47 48
	"$$(TOP)/$$(INPLACE_BIN)/haddock" \
	  --odir="$1/$2/doc/html/$$($1_PACKAGE)" \
49
	  --no-tmp-comp-dir \
50 51
	  --dump-interface=$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) \
	  --html \
52
	  --hoogle \
53 54
	  --title="$$($1_PACKAGE)-$$($1_$2_VERSION)$$(if $$(strip $$($1_$2_SYNOPSIS)),: $$(strip $$($1_$2_SYNOPSIS)),)" \
	  --prologue="$1/$2/haddock-prologue.txt" \
55
	  $$(foreach mod,$$($1_$2_HIDDEN_MODULES),--hide=$$(mod)) \
56
	  $$(foreach pkg,$$($1_$2_DEPS),$$(if $$($$(pkg)_HADDOCK_FILE),--read-interface=../$$(pkg)$$(comma)../$$(pkg)/src/%{MODULE/./-}.html\#%{NAME}$$(comma)$$($$(pkg)_HADDOCK_FILE))) \
57 58 59 60
	  $$(foreach opt,$$($1_$2_v_ALL_HC_OPTS),--optghc=$$(opt)) \
	  $$($1_$2_HADDOCK_FLAGS) $$($1_$2_HADDOCK_OPTS) \
	  $$($1_$2_HS_SRCS) \
	  $$($1_$2_EXTRA_HADDOCK_SRCS)
Ian Lynagh's avatar
Ian Lynagh committed
61

62 63 64 65 66 67
# --no-tmp-comp-dir above is important: it saves a few minutes in a
# validate.  This flag lets Haddock use the pre-compiled object files
# for the package rather than rebuilding the modules of the package in
# a temporary directory.  Haddock needs to build the package when it
# uses the Template Haskell or Annotations extensions, for example.

68
# Make the haddocking depend on the library .a file, to ensure
Ian Lynagh's avatar
Ian Lynagh committed
69
# that we wait until the library is fully built before we haddock it
70
$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) : $$($1_$2_v_LIB)
71
endif
72

Ian Lynagh's avatar
Ian Lynagh committed
73 74
endif

75
$(call profEnd, haddock($1,$2))
Ian Lynagh's avatar
Ian Lynagh committed
76 77
endef