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