doc/man: add common OPTIONS head for command man pages
[lttng-tools.git] / doc / man / Makefile.am
CommitLineData
ceb84f55
PP
1# Man pages are only built if the --enable-build-man-pages option was passed
2# to the configure script.
3#
4# They should always be built before creating a distribution tarball.
5
6# function which adds the source directory prefix and adds a given suffix
7manaddsuffix = $(addsuffix $(1),$(addprefix $(srcdir)/,$(2)))
8
9# List only the names without the .*.txt extension here:
10MAN1_NAMES = \
11 lttng
12MAN3_NAMES =
13MAN8_NAMES =
14MAN1_NO_ASCIIDOC_NAMES = lttng-crash
15MAN3_NO_ASCIIDOC_NAMES =
16MAN8_NO_ASCIIDOC_NAMES = lttng-relayd lttng-sessiond
17
18# man pages destinations
19MAN1 = $(call manaddsuffix,.1,$(MAN1_NAMES))
20MAN3 = $(call manaddsuffix,.3,$(MAN3_NAMES))
21MAN8 = $(call manaddsuffix,.8,$(MAN8_NAMES))
22MAN1_NO_ASCIIDOC = $(call manaddsuffix,.1,$(MAN1_NO_ASCIIDOC_NAMES))
23MAN3_NO_ASCIIDOC = $(call manaddsuffix,.3,$(MAN3_NO_ASCIIDOC_NAMES))
24MAN8_NO_ASCIIDOC = $(call manaddsuffix,.8,$(MAN8_NO_ASCIIDOC_NAMES))
25MAN = $(MAN1) $(MAN3) $(MAN8)
26
27# those are always installed since they are written in troff
28dist_man1_MANS = $(MAN1_NO_ASCIIDOC)
29dist_man3_MANS = $(MAN3_NO_ASCIIDOC)
30dist_man8_MANS = $(MAN8_NO_ASCIIDOC)
31
32# only build man pages if it was enabled
33if BUILD_MAN_PAGES
34# dist + install
35dist_man1_MANS += $(MAN1)
36dist_man3_MANS += $(MAN3)
37dist_man8_MANS += $(MAN8)
38
39# AsciiDoc sources and outputs
40MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES))
41MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES))
42MAN8_TXT = $(call manaddsuffix,.8.txt,$(MAN8_NAMES))
43MAN_TXT = $(MAN1_TXT) $(MAN3_TXT) $(MAN8_TXT)
44MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT))
45
46# common AsciiDoc source files
47COMMON_TXT = \
48 $(srcdir)/common-footer.txt \
83f27f71
PP
49 $(srcdir)/common-cmd-footer.txt \
50 $(srcdir)/common-cmd-options-head.txt
ceb84f55
PP
51
52# config
53ASCIIDOC_CONF = $(srcdir)/asciidoc.conf
54XSL_FILES = \
55 manpage.xsl \
56 manpage-base.xsl \
57 manpage-bold-literal.xsl \
58 manpage-ulinks.xsl
59XSL_SRC_FILES = $(addprefix $(srcdir)/xsl/,$(XSL_FILES))
60
61# common dependencies
62COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT)
63
64# tools
65ADOC = $(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \
66 -a lttng_version=$(PACKAGE_VERSION)
67ADOC_DOCBOOK = $(ADOC) -b docbook
68XTO = $(XMLTO) -m $(firstword $(XSL_SRC_FILES)) man
69
70# recipes
71%.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS)
72 $(ADOC_DOCBOOK) -o $@ $<
73
74%.1: %.1.xml $(XSL_SRC_FILES)
75 $(XTO) $<
76
77%.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS)
78 $(ADOC_DOCBOOK) -o $@ $<
79
80%.3: %.3.xml $(XSL_SRC_FILES)
81 $(XTO) $<
82
83%.8.xml: $(srcdir)/%.8.txt $(COMMON_DEPS)
84 $(ADOC_DOCBOOK) -o $@ $<
85
86%.8: %.8.xml $(XSL_SRC_FILES)
87 $(XTO) $<
88
89clean-local:
90 rm -rf $(MAN_XML)
91 rm -rf $(MAN)
92else
93if IN_GIT_REPO
94# we are in the Git repo: the man pages should be built for distribution
95dist-hook:
96 @echo
97 @echo 'Error: Please build the man pages before creating a tarball.'
98 @echo
99 @false
100else
101# we are in the tarball, hence the man pages are already built
102dist_man1_MANS += $(MAN1)
103dist_man3_MANS += $(MAN3)
104dist_man8_MANS += $(MAN8)
105endif # IN_GIT_REPO
106endif # BUILD_MAN_PAGES
This page took 0.038703 seconds and 5 git commands to generate.