haddock.mk 2.34 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
Ian Lynagh's avatar
Ian Lynagh committed
15 16 17

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

18 19 20
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
21 22 23 24
else
$$(error Already got a haddock file for $$($1_PACKAGE))
endif

25
haddock: $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)
26

Ian Lynagh's avatar
Ian Lynagh committed
27
ifeq "$$(HADDOCK_DOCS)" "YES"
28
$(call all-target,$1_$2_haddock,html_$1)
29
endif
Ian Lynagh's avatar
Ian Lynagh committed
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))
Ian Lynagh's avatar
Ian Lynagh committed
35 36

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

40
ifneq "$$(BINDIST)" "YES"
41 42 43 44 45 46 47 48 49 50 51 52 53
$$($$($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 $$$$@)/.
	"$$(GHC_CABAL_INPLACE)" hscolour $2 $1
	"$$(TOP)/$$(INPLACE_BIN)/haddock" \
	  --odir="$1/$2/doc/html/$$($1_PACKAGE)" \
	  --dump-interface=$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) \
	  --html \
	  --title="$$($1_PACKAGE)-$$($1_$2_VERSION)$$(if $$(strip $$($1_$2_SYNOPSIS)),: $$(strip $$($1_$2_SYNOPSIS)),)" \
	  --prologue="$1/$2/haddock-prologue.txt" \
	  $$(foreach pkg,$$($1_$2_DEPS),$$(if $$($$(pkg)_HADDOCK_FILE),--read-interface=../$$(pkg)$$(comma)$$($$(pkg)_HADDOCK_FILE))) \
	  $$(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
54

55 56 57
# Make the haddocking depend on the library .a file, to ensure
# that we wait until the library is fully build before we haddock it
$$($$($1_PACKAGE)_HADDOCK_FILE) : $$($1_$2_v_LIB)
58
endif
59

Ian Lynagh's avatar
Ian Lynagh committed
60 61 62 63
endif

endef