Only build/install the man page if XSLTPROC is defined
[ghc.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 tail -n +2 $< >> $@
37
38 endif
39
40 install-docs:: $(MAN_PAGE).$(MAN_SECTION)
41 $(INSTALL_DIR) $(DESTDIR)$(mandir)
42 $(INSTALL_DIR) $(DESTDIR)$(mandir)/man$(MAN_SECTION)
43 $(INSTALL_MAN) $(INSTALL_OPTS) $(MAN_PAGE).$(MAN_SECTION) $(DESTDIR)$(mandir)/man$(MAN_SECTION)
44
45 endif
46
47 binary-dist:: $(MAN_PAGE).$(MAN_SECTION)
48 $(MKDIRHIER) $(BIN_DIST_DIR)/docs/man
49 cp Makefile $(BIN_DIST_DIR)/docs/man/
50 ifneq "$(strip $(XSLTPROC))" ""
51 cp $(MAN_PAGE).$(MAN_SECTION) $(BIN_DIST_DIR)/docs/man/
52 endif
53
54 include $(TOP)/mk/target.mk