Commit | Line | Data |
---|---|---|
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 | |
7 | manaddsuffix = $(addsuffix $(1),$(addprefix $(srcdir)/,$(2))) | |
8 | ||
9 | # List only the names without the .*.txt extension here: | |
10 | MAN1_NAMES = \ | |
11 | lttng | |
12 | MAN3_NAMES = | |
13 | MAN8_NAMES = | |
14 | MAN1_NO_ASCIIDOC_NAMES = lttng-crash | |
15 | MAN3_NO_ASCIIDOC_NAMES = | |
16 | MAN8_NO_ASCIIDOC_NAMES = lttng-relayd lttng-sessiond | |
17 | ||
18 | # man pages destinations | |
19 | MAN1 = $(call manaddsuffix,.1,$(MAN1_NAMES)) | |
20 | MAN3 = $(call manaddsuffix,.3,$(MAN3_NAMES)) | |
21 | MAN8 = $(call manaddsuffix,.8,$(MAN8_NAMES)) | |
22 | MAN1_NO_ASCIIDOC = $(call manaddsuffix,.1,$(MAN1_NO_ASCIIDOC_NAMES)) | |
23 | MAN3_NO_ASCIIDOC = $(call manaddsuffix,.3,$(MAN3_NO_ASCIIDOC_NAMES)) | |
24 | MAN8_NO_ASCIIDOC = $(call manaddsuffix,.8,$(MAN8_NO_ASCIIDOC_NAMES)) | |
25 | MAN = $(MAN1) $(MAN3) $(MAN8) | |
26 | ||
27 | # those are always installed since they are written in troff | |
28 | dist_man1_MANS = $(MAN1_NO_ASCIIDOC) | |
29 | dist_man3_MANS = $(MAN3_NO_ASCIIDOC) | |
30 | dist_man8_MANS = $(MAN8_NO_ASCIIDOC) | |
31 | ||
32 | # only build man pages if it was enabled | |
33 | if BUILD_MAN_PAGES | |
34 | # dist + install | |
35 | dist_man1_MANS += $(MAN1) | |
36 | dist_man3_MANS += $(MAN3) | |
37 | dist_man8_MANS += $(MAN8) | |
38 | ||
39 | # AsciiDoc sources and outputs | |
40 | MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES)) | |
41 | MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES)) | |
42 | MAN8_TXT = $(call manaddsuffix,.8.txt,$(MAN8_NAMES)) | |
43 | MAN_TXT = $(MAN1_TXT) $(MAN3_TXT) $(MAN8_TXT) | |
44 | MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT)) | |
45 | ||
46 | # common AsciiDoc source files | |
47 | COMMON_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 | |
53 | ASCIIDOC_CONF = $(srcdir)/asciidoc.conf | |
54 | XSL_FILES = \ | |
55 | manpage.xsl \ | |
56 | manpage-base.xsl \ | |
57 | manpage-bold-literal.xsl \ | |
58 | manpage-ulinks.xsl | |
59 | XSL_SRC_FILES = $(addprefix $(srcdir)/xsl/,$(XSL_FILES)) | |
60 | ||
61 | # common dependencies | |
62 | COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT) | |
63 | ||
64 | # tools | |
65 | ADOC = $(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \ | |
66 | -a lttng_version=$(PACKAGE_VERSION) | |
67 | ADOC_DOCBOOK = $(ADOC) -b docbook | |
68 | XTO = $(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 | ||
89 | clean-local: | |
90 | rm -rf $(MAN_XML) | |
91 | rm -rf $(MAN) | |
92 | else | |
93 | if IN_GIT_REPO | |
94 | # we are in the Git repo: the man pages should be built for distribution | |
95 | dist-hook: | |
96 | @echo | |
97 | @echo 'Error: Please build the man pages before creating a tarball.' | |
98 | @echo | |
99 | @false | |
100 | else | |
101 | # we are in the tarball, hence the man pages are already built | |
102 | dist_man1_MANS += $(MAN1) | |
103 | dist_man3_MANS += $(MAN3) | |
104 | dist_man8_MANS += $(MAN8) | |
105 | endif # IN_GIT_REPO | |
106 | endif # BUILD_MAN_PAGES |