Omit unnecessary linker flags
[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://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13 ifneq "$(BINDIST)" "YES"
14 HADDOCK_VER := $(shell grep "^version:" utils/haddock/haddock.cabal | sed "s/version: *//")
15 HADDOCK_MAJOR_VER := $(shell echo $(HADDOCK_VER) | sed 's/\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)/\1/')
16 HADDOCK_MINOR_VER := $(shell echo $(HADDOCK_VER) | sed 's/\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)/\2/')
17 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
20
21 define haddock # args: $1 = dir, $2 = distdir
22 $(call trace, haddock($1,$2))
23 $(call profStart, haddock($1,$2))
24
25 ifeq "$$($1_$2_DO_HADDOCK)" "YES"
26
27 ifeq "$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)" ""
28 $$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE = $1/$2/doc/html/$$($1_PACKAGE)/$$($1_PACKAGE).haddock
29 ALL_HADDOCK_FILES += $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE)
30 else
31 $$(error Already got a haddock file for $$($1_PACKAGE))
32 endif
33
34 haddock: html_$1
35
36 ifeq "$$(HADDOCK_DOCS)" "YES"
37 $(call all-target,$1_$2_haddock,html_$1)
38 endif
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))
44
45 ifeq "$$(HSCOLOUR_SRCS)" "YES"
46 $1_$2_HADDOCK_FLAGS += --source-module=src/%{MODULE/./-}.html --source-entity=src/%{MODULE/./-}.html\#%{NAME}
47 endif
48
49 ifneq "$$(BINDIST)" "YES"
50
51 # We need the quadruple dollars for the dependencies, as it isn't
52 # guaranteed that we are processing the packages in dependency order,
53 # so we don't want to expand it yet.
54 $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) : $$$$(haddock_INPLACE) $$$$(ghc-cabal_INPLACE) $$($1_$2_HS_SRCS) $$$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_DEPS) | $$$$(dir $$$$@)/.
55 ifeq "$$(HSCOLOUR_SRCS)" "YES"
56 "$$(ghc-cabal_INPLACE)" hscolour $1 $2
57 endif
58 "$$(TOP)/$$(INPLACE_BIN)/haddock" \
59 --verbosity=0 \
60 --odir="$1/$2/doc/html/$$($1_PACKAGE)" \
61 --no-tmp-comp-dir \
62 --dump-interface=$$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) \
63 --html \
64 --hoogle \
65 --title="$$($1_PACKAGE)-$$($1_$2_VERSION)$$(if $$(strip $$($1_$2_SYNOPSIS)),: $$(strip $$($1_$2_SYNOPSIS)),)" \
66 --prologue="$1/$2/haddock-prologue.txt" \
67 --optghc="-D__HADDOCK_VERSION__=$$(HADDOCK_VERSION_STRING)" \
68 $$(foreach mod,$$($1_$2_HIDDEN_MODULES),--hide=$$(mod)) \
69 $$(foreach pkg,$$($1_$2_DEPS),$$(if $$($$(pkg)_HADDOCK_FILE),--read-interface=../$$(pkg)$$(comma)../$$(pkg)/src/%{MODULE/./-}.html\#%{NAME}$$(comma)$$($$(pkg)_HADDOCK_FILE))) \
70 $$(foreach opt,$$($1_$2_$$(HADDOCK_WAY)_ALL_HC_OPTS),--optghc=$$(opt)) \
71 $$($1_$2_HADDOCK_FLAGS) $$($1_$2_HADDOCK_OPTS) \
72 $$($1_$2_HS_SRCS) \
73 $$($1_$2_EXTRA_HADDOCK_SRCS) \
74 $$(EXTRA_HADDOCK_OPTS) \
75 +RTS -t"$1/$2/haddock.t" --machine-readable
76
77 # --no-tmp-comp-dir above is important: it saves a few minutes in a
78 # validate. This flag lets Haddock use the pre-compiled object files
79 # for the package rather than rebuilding the modules of the package in
80 # a temporary directory. Haddock needs to build the package when it
81 # uses the Template Haskell or Annotations extensions, for example.
82
83 # Make the haddocking depend on the library .a file, to ensure
84 # that we wait until the library is fully built before we haddock it
85 $$($$($1_PACKAGE)-$$($1_$2_VERSION)_HADDOCK_FILE) : $$($1_$2_$$(HADDOCK_WAY)_LIB)
86 endif
87
88 endif # $1_$2_DO_HADDOCK
89
90 $(call profEnd, haddock($1,$2))
91 endef
92