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