GHC new build system megapatch
[ghc-hetmet.git] / docs / man / Makefile
1 TOP = ../..
2 include $(TOP)/mk/boilerplate.mk
3
4 ifneq "$(strip $(XSLTPROC))" ""
5
6 # The commands which should be mentioned in the man page
7 GHC_COMMANDS = ghc ghci
8
9 # The man page we are generating
10 MAN_PAGE = ghc
11
12 # The manual section
13 MAN_SECTION = 1
14
15 CLEAN_FILES += $(MAN_PAGE).$(MAN_SECTION) flags.xsl flags.xml
16
17 ifneq "$(DOING_BIN_DIST)" "YES"
18
19 all:: $(MAN_PAGE).$(MAN_SECTION)
20
21 $(MAN_PAGE).$(MAN_SECTION): flags.xsl flags.xml
22         $(XSLTPROC) $(XSLTPROC_OPTS) flags.xsl flags.xml > $@
23
24 # Insert the commands and the library directory into the man page
25 flags.xsl: gen_flags.xsl.pl
26         $(PERL) gen_flags.xsl.pl "$(GHC_COMMANDS)" "$(libdir)" > $@
27
28 # Re-use the flags documentation from the user's guide by injecting some
29 # entities after the XML declaration to make it a stand-alone document.
30 flags.xml: ../users_guide/flags.xml
31         $(RM) $@
32         head -n 1 $< >> $@
33         echo "<!DOCTYPE sect1 [<!ENTITY ndash  \"-\"> \
34                                <!ENTITY ldquo  \"\`\"> \
35                                <!ENTITY rdquo  \"'\">]>" >> $@
36         # "sed 1d" == "tail -n +2", but Solaris apparently rejects the latter
37         sed 1d $< >> $@
38
39 endif
40
41 install-docs:: $(MAN_PAGE).$(MAN_SECTION)
42         $(INSTALL_DIR) $(DESTDIR)$(mandir)
43         $(INSTALL_DIR) $(DESTDIR)$(mandir)/man$(MAN_SECTION)
44         $(INSTALL_MAN) $(INSTALL_OPTS) $(MAN_PAGE).$(MAN_SECTION) $(DESTDIR)$(mandir)/man$(MAN_SECTION)
45
46 endif
47
48 include $(TOP)/mk/bindist.mk
49
50 include $(TOP)/mk/target.mk