Fix: Mark ASCIIDOC_ATTRS_CONF as a dependency of man page targets
[lttng-tools.git] / doc / man / Makefile.am
... / ...
CommitLineData
1# Man pages are only built if they are enabled at configure time.
2#
3# They should always be built before creating a distribution tarball.
4
5# function which adds the source directory prefix and adds a given suffix
6manaddsuffix = $(addsuffix $(1),$(addprefix $(srcdir)/,$(2)))
7
8# List only the names without the .*.txt extension here:
9MAN1_NAMES = \
10 lttng \
11 lttng-create \
12 lttng-destroy \
13 lttng-set-session \
14 lttng-save \
15 lttng-load \
16 lttng-start \
17 lttng-stop \
18 lttng-version \
19 lttng-view \
20 lttng-enable-channel \
21 lttng-disable-channel \
22 lttng-add-context \
23 lttng-list \
24 lttng-calibrate \
25 lttng-track \
26 lttng-untrack \
27 lttng-status \
28 lttng-help \
29 lttng-snapshot \
30 lttng-enable-event \
31 lttng-disable-event \
32 lttng-crash \
33 lttng-metadata \
34 lttng-regenerate
35MAN3_NAMES =
36MAN8_NAMES = lttng-sessiond lttng-relayd
37MAN1_NO_ASCIIDOC_NAMES =
38MAN3_NO_ASCIIDOC_NAMES = lttng-health-check
39MAN8_NO_ASCIIDOC_NAMES =
40
41# AsciiDoc sources and outputs
42MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES))
43MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES))
44MAN8_TXT = $(call manaddsuffix,.8.txt,$(MAN8_NAMES))
45MAN_TXT = $(MAN1_TXT) $(MAN3_TXT) $(MAN8_TXT)
46MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT))
47
48# common AsciiDoc source files
49COMMON_TXT = \
50 $(srcdir)/common-footer.txt \
51 $(srcdir)/common-cmd-footer.txt \
52 $(srcdir)/common-cmd-options-head.txt \
53 $(srcdir)/common-cmd-help-options.txt
54
55# config
56ASCIIDOC_CONF = $(srcdir)/asciidoc.conf
57ASCIIDOC_ATTRS_CONF = $(builddir)/asciidoc-attrs.conf
58XSL_FILES = \
59 manpage.xsl \
60 manpage-callouts.xsl \
61 manpage-bold-literal.xsl \
62 manpage-links.xsl
63XSL_SRC_FILES = $(addprefix $(srcdir)/xsl/,$(XSL_FILES))
64
65# common dependencies
66COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT) $(ASCIIDOC_ATTRS_CONF)
67
68# man pages destinations
69MAN1 = $(addsuffix .1,$(MAN1_NAMES))
70MAN3 = $(addsuffix .3,$(MAN3_NAMES))
71MAN8 = $(addsuffix .8,$(MAN8_NAMES))
72MAN1_NO_ASCIIDOC = $(addsuffix .1,$(MAN1_NO_ASCIIDOC_NAMES))
73MAN3_NO_ASCIIDOC = $(addsuffix .3,$(MAN3_NO_ASCIIDOC_NAMES))
74MAN8_NO_ASCIIDOC = $(addsuffix .8,$(MAN8_NO_ASCIIDOC_NAMES))
75MAN = $(MAN1) $(MAN3) $(MAN8)
76
77if MAN_PAGES_OPT
78# at this point, we know the user asked to build the man pages
79if HAVE_ASCIIDOC_XMLTO
80# tools
81ADOC = $(ASCIIDOC) -f $(ASCIIDOC_CONF) -f $(ASCIIDOC_ATTRS_CONF) -d manpage
82ADOC_DOCBOOK = $(ADOC) -b docbook
83XTO = $(XMLTO) -m $(firstword $(XSL_SRC_FILES)) man
84
85# recipes
86%.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS)
87 $(ADOC_DOCBOOK) -o $@ $<
88
89%.1: %.1.xml $(XSL_SRC_FILES)
90 $(XTO) $<
91
92%.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS)
93 $(ADOC_DOCBOOK) -o $@ $<
94
95%.3: %.3.xml $(XSL_SRC_FILES)
96 $(XTO) $<
97
98%.8.xml: $(srcdir)/%.8.txt $(COMMON_DEPS)
99 $(ADOC_DOCBOOK) -o $@ $<
100
101%.8: %.8.xml $(XSL_SRC_FILES)
102 $(XTO) $<
103
104# only clean the generated files if we have the tools to generate them again
105CLEANFILES = $(MAN_XML) $(MAN)
106else # HAVE_ASCIIDOC_XMLTO
107# create man page targets used to stop the build if we want to
108# build the man pages, but we don't have the necessary tools to do so
109ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing."
110ERR_MSG += "Make sure both tools are installed and run the configure script again."
111
112%.1: $(srcdir)/%.1.txt $(COMMON_DEPS)
113 @echo $(ERR_MSG)
114 @false
115
116%.3: $(srcdir)/%.3.txt $(COMMON_DEPS)
117 @echo $(ERR_MSG)
118 @false
119
120%.8: $(srcdir)/%.8.txt $(COMMON_DEPS)
121 @echo $(ERR_MSG)
122 @false
123endif # HAVE_ASCIIDOC_XMLTO
124endif # MAN_PAGES_OPT
125
126# those are always installed since they are directly written in troff
127dist_man1_MANS = $(MAN1_NO_ASCIIDOC)
128dist_man3_MANS = $(MAN3_NO_ASCIIDOC)
129dist_man8_MANS = $(MAN8_NO_ASCIIDOC)
130
131if MAN_PAGES_OPT
132# building man pages: we can install and distribute them
133dist_man1_MANS += $(MAN1)
134dist_man3_MANS += $(MAN3)
135dist_man8_MANS += $(MAN8)
136endif # MAN_PAGES_OPT
137
138if !MAN_PAGES_OPT
139dist-hook:
140 @echo "Error: Please enable the man pages before creating a distribution tarball."
141 @false
142endif # !MAN_PAGES_OPT
143
144# always distribute the source files
145EXTRA_DIST = $(MAN_TXT) $(COMMON_TXT) $(XSL_SRC_FILES) \
146 $(ASCIIDOC_CONF) $(ASCIIDOC_ATTRS_CONF).in
This page took 0.022383 seconds and 4 git commands to generate.