Build system improvements
[ghc-hetmet.git] / docs / man / ghc.mk
1
2 ifeq "$(BUILD_MAN)" ""
3 ifeq "$(strip $(XSLTPROC))" ""
4 BUILD_MAN = NO
5 else
6 BUILD_MAN = YES
7 endif
8 endif
9
10 # The commands which should be mentioned in the man page
11 MAN_GHC_COMMANDS = ghc ghci
12
13 # The man page we are generating
14 MAN_PAGE = ghc
15
16 # The manual section
17 MAN_SECTION = 1
18
19 MAN_PATH = docs/man/$(MAN_PAGE).$(MAN_SECTION)
20
21 ifneq "$(BINDIST)" "YES"
22 $(MAN_PATH): docs/man/flags.xsl docs/man/flags.xml
23         $(XSLTPROC) $(XSLTPROC_OPTS) $^ > $@
24 endif
25
26 # Insert the commands and the library directory into the man page
27 docs/man/flags.xsl: docs/man/gen_flags.xsl.sh
28         $(SHELL) $< "$(MAN_GHC_COMMANDS)" "$(libdir)" > $@
29
30 # Re-use the flags documentation from the user's guide by injecting some
31 # entities after the XML declaration to make it a stand-alone document.
32 docs/man/flags.xml: docs/users_guide/flags.xml
33         "$(RM)" $(RM_OPTS) $@
34         head -n 1 $< >> $@
35         echo "<!DOCTYPE sect1 [<!ENTITY ndash  \"-\"> \
36                                <!ENTITY ldquo  \"\`\"> \
37                                <!ENTITY rdquo  \"'\">]>" >> $@
38 # "sed 1d" == "tail -n +2", but Solaris apparently rejects the latter
39         sed 1d $< >> $@
40
41 ifeq "$(BUILD_MAN)" "YES"
42 ifeq "$(phase)" ""
43 $(eval $(call all-target,docs/man,$(MAN_PATH)))
44 endif
45
46 INSTALL_MANPAGES += $(MAN_PATH)
47
48 install: install_man
49
50 .PHONY: install_man
51 install_man: $(MAN_PATH)
52         $(call INSTALL_DIR,"$(DESTDIR)$(mandir)")
53         $(call INSTALL_DIR,"$(DESTDIR)$(mandir)/man$(MAN_SECTION)")
54         $(call INSTALL_MAN,$(INSTALL_OPTS),$(MAN_PATH),"$(DESTDIR)$(mandir)/man$(MAN_SECTION)")
55 endif
56
57 $(eval $(call clean-target,docs/man,,$(MAN_PATH) docs/man/flags.xsl docs/man/flags.xml))
58