haddock.mk 4.07 KB
Newer Older
1 2 3 4 5 6 7
# -----------------------------------------------------------------------------
#
# (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
8 9
#      http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
#      http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
10 11 12
#
# -----------------------------------------------------------------------------

13
ifneq "$(BINDIST)" "YES"
14 15 16 17
HADDOCK_VER := $(shell grep "^version:" utils/haddock/haddock.cabal | sed "s/version: *//")
HADDOCK_MAJOR_VER := $(shell echo $(HADDOCK_VER) | sed 's/\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)/\1/')
HADDOCK_MINOR_VER := $(shell echo $(HADDOCK_VER) | sed 's/\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)/\2/')
HADDOCK_PATCH_VER := $(shell echo $(HADDOCK_VER) | sed 's/\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)/\3/')
18
HADDOCK_VERSION_STRING := $(shell echo $$(($(HADDOCK_MAJOR_VER) * 1000 + $(HADDOCK_MINOR_VER) * 10 + $(HADDOCK_PATCH_VER))))
19
endif
Ian Lynagh's avatar
Ian Lynagh committed
20

Simon Marlow's avatar
Simon Marlow committed
21
define haddock  # args: $1 = dir,  $2 = distdir
22
$(call trace, haddock($1,$2))
23
$(call profStart, haddock($1,$2))
Ian Lynagh's avatar
Ian Lynagh committed
24

25
ifeq "$$($1_$2_DO_HADDOCK)" "YES"
Ian Lynagh's avatar
Ian Lynagh committed
26

27 28 29
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
30 31 32 33
else
$$(error Already got a haddock file for $$($1_PACKAGE))
endif

34
haddock: html_$1
35

Ian Lynagh's avatar
Ian Lynagh committed
36
ifeq "$$(HADDOCK_DOCS)" "YES"
37
$(call all-target,$1_$2_haddock,html_$1)
38
endif
Ian Lynagh's avatar
Ian Lynagh committed
39

40
.PHONY: html_$1
41
html_$1 : $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)
42

43
$$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_DEPS = $$(foreach n,$$($1_$2_DEPS),$$($$n_HADDOCK_FILE) $$($$n_dist-install_$$(HADDOCK_WAY)_LIB))
Ian Lynagh's avatar
Ian Lynagh committed
44

45 46 47
# We don't pass -dcore-lint to haddock because it caused a performance regression in #13789
$1_$2_HADDOCK_GHC_OPTS = $$(foreach opt, $$(filter-out -dcore-lint,$$($1_$2_$$(HADDOCK_WAY)_ALL_HC_OPTS)),--optghc=$$(opt))

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

52
ifneq "$$(BINDIST)" "YES"
53

54 55 56
# We need the quadruple dollars for the dependencies, as it isn't
# guaranteed that we are processing the packages in dependency order,
# so we don't want to expand it yet.
57
$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) : $$$$(haddock_INPLACE) $$$$(ghc-cabal_INPLACE) $$($1_$2_HS_SRCS) $$$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_DEPS) | $$$$(dir $$$$@)/.
Simon Marlow's avatar
Simon Marlow committed
58
ifeq "$$(HSCOLOUR_SRCS)" "YES"
ian@well-typed.com's avatar
ian@well-typed.com committed
59
	"$$(ghc-cabal_INPLACE)" hscolour $1 $2
Simon Marlow's avatar
Simon Marlow committed
60
endif
61
	"$$(TOP)/$$(INPLACE_BIN)/haddock" \
62 63 64 65 66 67
		--verbosity=0 \
		--odir="$1/$2/doc/html/$$($1_PACKAGE)" \
		--no-tmp-comp-dir \
		--dump-interface=$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) \
		--html \
		--hoogle \
Ben Gamari's avatar
Ben Gamari committed
68
		--quickjump \
69 70 71 72 73 74 75 76 77 78 79
		--title="$$($1_PACKAGE)-$$($1_$2_VERSION)$$(if $$(strip $$($1_$2_SYNOPSIS)),: $$(strip $$($1_$2_SYNOPSIS)),)" \
		--prologue="$1/$2/haddock-prologue.txt" \
		--optghc="-D__HADDOCK_VERSION__=$$(HADDOCK_VERSION_STRING)" \
		$$(foreach mod,$$($1_$2_HIDDEN_MODULES),--hide=$$(mod)) \
		$$(foreach pkg,$$($1_$2_DEPS),$$(if $$($$(pkg)_HADDOCK_FILE),--read-interface=../$$(pkg)$$(comma)../$$(pkg)/src/%{MODULE/./-}.html\#%{NAME}$$(comma)$$($$(pkg)_HADDOCK_FILE))) \
		$$($1_$2_HADDOCK_GHC_OPTS) \
		$$($1_$2_HADDOCK_FLAGS) $$($1_$2_HADDOCK_OPTS) \
		$$($1_$2_HS_SRCS) \
		$$($1_$2_EXTRA_HADDOCK_SRCS) \
		$$(EXTRA_HADDOCK_OPTS) \
		+RTS -t"$1/$2/haddock.t" --machine-readable
Ian Lynagh's avatar
Ian Lynagh committed
80

81 82 83 84 85 86
# --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.

87
# Make the haddocking depend on the library .a file, to ensure
Ian Lynagh's avatar
Ian Lynagh committed
88
# that we wait until the library is fully built before we haddock it
89
$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) : $$($1_$2_$$(HADDOCK_WAY)_LIB)
90
endif
91

92
endif # $1_$2_DO_HADDOCK
Ian Lynagh's avatar
Ian Lynagh committed
93

94
$(call profEnd, haddock($1,$2))
Ian Lynagh's avatar
Ian Lynagh committed
95
endef