5407397817da29a3b2cf425b40d43d92ae6fdeda
[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 $(eval $(call all-target,docs/man,$(MAN_PATH)))
43
44 INSTALL_MANPAGES += $(MAN_PATH)
45
46 install: install_man
47
48 .PHONY: install_man
49 install_man: $(MAN_PATH)
50         $(call INSTALL_DIR,"$(DESTDIR)$(mandir)")
51         $(call INSTALL_DIR,"$(DESTDIR)$(mandir)/man$(MAN_SECTION)")
52         $(call INSTALL_MAN,$(INSTALL_OPTS),$(MAN_PATH),"$(DESTDIR)$(mandir)/man$(MAN_SECTION)")
53 endif
54
55 $(eval $(call clean-target,docs/man,,$(MAN_PATH) docs/man/flags.xsl docs/man/flags.xml))
56