Fix: standardize man pages building/installing
[lttng-tools.git] / doc / man / Makefile.am
CommitLineData
a3eae3c9
PP
1# Man pages are only built if the --enable-man-pages option was
2# passed to the configure script.
ceb84f55
PP
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 = \
ba50d967 11 lttng \
7bf169bd 12 lttng-create \
9d4408b8 13 lttng-destroy \
b3903b3a 14 lttng-set-session \
44f5039e 15 lttng-save \
30ec772c 16 lttng-load \
fb58d659 17 lttng-start \
e85eccc8 18 lttng-stop \
79e094df 19 lttng-version \
b4867b3b 20 lttng-view \
4bf0a332 21 lttng-enable-channel \
2e4886b8 22 lttng-disable-channel \
882108c6 23 lttng-add-context \
89dbeff8 24 lttng-list \
65226554 25 lttng-calibrate \
882443a6 26 lttng-track \
18d6fa61 27 lttng-untrack \
afaad15a 28 lttng-status \
12397c59 29 lttng-help \
e9b06e2b 30 lttng-snapshot \
290294e8 31 lttng-enable-event \
aec4668a 32 lttng-disable-event \
11533074
JG
33 lttng-crash \
34 lttng-metadata
ceb84f55 35MAN3_NAMES =
f5595c32 36MAN8_NAMES = lttng-sessiond lttng-relayd
aec4668a 37MAN1_NO_ASCIIDOC_NAMES =
23225252 38MAN3_NO_ASCIIDOC_NAMES = lttng-health-check
f5595c32 39MAN8_NO_ASCIIDOC_NAMES =
ceb84f55 40
ceb84f55
PP
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 \
83f27f71 51 $(srcdir)/common-cmd-footer.txt \
ba50d967
PP
52 $(srcdir)/common-cmd-options-head.txt \
53 $(srcdir)/common-cmd-help-options.txt
ceb84f55
PP
54
55# config
56ASCIIDOC_CONF = $(srcdir)/asciidoc.conf
57XSL_FILES = \
58 manpage.xsl \
41af7458 59 manpage-callouts.xsl \
ceb84f55 60 manpage-bold-literal.xsl \
4d7f0487 61 manpage-links.xsl
ceb84f55
PP
62XSL_SRC_FILES = $(addprefix $(srcdir)/xsl/,$(XSL_FILES))
63
64# common dependencies
65COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT)
66
a3eae3c9
PP
67# man pages destinations
68MAN1 = $(addsuffix .1,$(MAN1_NAMES))
69MAN3 = $(addsuffix .3,$(MAN3_NAMES))
70MAN8 = $(addsuffix .8,$(MAN8_NAMES))
71MAN1_NO_ASCIIDOC = $(addsuffix .1,$(MAN1_NO_ASCIIDOC_NAMES))
72MAN3_NO_ASCIIDOC = $(addsuffix .3,$(MAN3_NO_ASCIIDOC_NAMES))
73MAN8_NO_ASCIIDOC = $(addsuffix .8,$(MAN8_NO_ASCIIDOC_NAMES))
74MAN = $(MAN1) $(MAN3) $(MAN8)
75
76if MAN_PAGES_OPT
77# at this point, we know the user asked to build the man pages
78if HAVE_ASCIIDOC_XMLTO
ceb84f55
PP
79# tools
80ADOC = $(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \
a3eae3c9 81 -a lttng_version="$(PACKAGE_VERSION)"
ceb84f55
PP
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
a3eae3c9
PP
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)
ceb84f55 122 @false
a3eae3c9
PP
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
ceb84f55
PP
133dist_man1_MANS += $(MAN1)
134dist_man3_MANS += $(MAN3)
135dist_man8_MANS += $(MAN8)
a3eae3c9
PP
136endif # MAN_PAGES_OPT
137
138# always distribute the source files
139EXTRA_DIST = $(MAN_TXT) $(COMMON_TXT) $(XSL_SRC_FILES) $(ASCIIDOC_CONF)
This page took 0.030223 seconds and 5 git commands to generate.