Commit | Line | Data |
---|---|---|
9d16b343 MJ |
1 | # SPDX-License-Identifier: GPL-2.0-only |
2 | ||
6f6794a6 | 3 | # Man pages are only built if they are enabled at configure time. |
ceb84f55 PP |
4 | # |
5 | # They should always be built before creating a distribution tarball. | |
6 | ||
7 | # function which adds the source directory prefix and adds a given suffix | |
8 | manaddsuffix = $(addsuffix $(1),$(addprefix $(srcdir)/,$(2))) | |
9 | ||
10 | # List only the names without the .*.txt extension here: | |
11 | MAN1_NAMES = \ | |
ba50d967 | 12 | lttng \ |
7bf169bd | 13 | lttng-create \ |
9d4408b8 | 14 | lttng-destroy \ |
b3903b3a | 15 | lttng-set-session \ |
44f5039e | 16 | lttng-save \ |
30ec772c | 17 | lttng-load \ |
fb58d659 | 18 | lttng-start \ |
e85eccc8 | 19 | lttng-stop \ |
79e094df | 20 | lttng-version \ |
b4867b3b | 21 | lttng-view \ |
4bf0a332 | 22 | lttng-enable-channel \ |
2e4886b8 | 23 | lttng-disable-channel \ |
882108c6 | 24 | lttng-add-context \ |
89dbeff8 | 25 | lttng-list \ |
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 | 33 | lttng-crash \ |
eded6438 | 34 | lttng-metadata \ |
980bb5fd PP |
35 | lttng-regenerate \ |
36 | lttng-rotate \ | |
37 | lttng-enable-rotation \ | |
73b818e7 | 38 | lttng-disable-rotation \ |
a942557f | 39 | lttng-clear \ |
0de2479d | 40 | lttng-add-trigger \ |
b61776fb | 41 | lttng-remove-trigger \ |
0de2479d | 42 | lttng-list-triggers |
ceb84f55 | 43 | MAN3_NAMES = |
188419c4 | 44 | MAN7_NAMES = lttng-event-rule lttng-concepts |
f5595c32 | 45 | MAN8_NAMES = lttng-sessiond lttng-relayd |
aec4668a | 46 | MAN1_NO_ASCIIDOC_NAMES = |
23225252 | 47 | MAN3_NO_ASCIIDOC_NAMES = lttng-health-check |
484b2a0c | 48 | MAN7_NO_ASCIIDOC_NAMES = |
f5595c32 | 49 | MAN8_NO_ASCIIDOC_NAMES = |
ceb84f55 | 50 | |
ceb84f55 PP |
51 | # AsciiDoc sources and outputs |
52 | MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES)) | |
53 | MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES)) | |
484b2a0c | 54 | MAN7_TXT = $(call manaddsuffix,.7.txt,$(MAN7_NAMES)) |
ceb84f55 | 55 | MAN8_TXT = $(call manaddsuffix,.8.txt,$(MAN8_NAMES)) |
484b2a0c | 56 | MAN_TXT = $(MAN1_TXT) $(MAN3_TXT) $(MAN7_TXT) $(MAN8_TXT) |
ceb84f55 PP |
57 | MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT)) |
58 | ||
59 | # common AsciiDoc source files | |
60 | COMMON_TXT = \ | |
61 | $(srcdir)/common-footer.txt \ | |
83f27f71 | 62 | $(srcdir)/common-cmd-footer.txt \ |
ba50d967 | 63 | $(srcdir)/common-cmd-options-head.txt \ |
484b2a0c PP |
64 | $(srcdir)/common-cmd-help-options.txt \ |
65 | $(srcdir)/common-help-option.txt \ | |
188419c4 PP |
66 | $(srcdir)/common-intro.txt \ |
67 | $(srcdir)/common-daemon-cfg.txt | |
ceb84f55 PP |
68 | |
69 | # config | |
767ab8b2 | 70 | ASCIIDOC_CONF = $(srcdir)/asciidoc.conf |
c4ee4984 | 71 | ASCIIDOC_ATTRS_CONF = $(builddir)/asciidoc-attrs.conf |
360c4f63 | 72 | XSL_FILE = $(srcdir)/manpage.xsl |
ceb84f55 PP |
73 | |
74 | # common dependencies | |
fd3e1238 | 75 | COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT) |
ceb84f55 | 76 | |
a3eae3c9 PP |
77 | # man pages destinations |
78 | MAN1 = $(addsuffix .1,$(MAN1_NAMES)) | |
79 | MAN3 = $(addsuffix .3,$(MAN3_NAMES)) | |
484b2a0c | 80 | MAN7 = $(addsuffix .7,$(MAN7_NAMES)) |
a3eae3c9 PP |
81 | MAN8 = $(addsuffix .8,$(MAN8_NAMES)) |
82 | MAN1_NO_ASCIIDOC = $(addsuffix .1,$(MAN1_NO_ASCIIDOC_NAMES)) | |
83 | MAN3_NO_ASCIIDOC = $(addsuffix .3,$(MAN3_NO_ASCIIDOC_NAMES)) | |
484b2a0c | 84 | MAN7_NO_ASCIIDOC = $(addsuffix .7,$(MAN7_NO_ASCIIDOC_NAMES)) |
a3eae3c9 | 85 | MAN8_NO_ASCIIDOC = $(addsuffix .8,$(MAN8_NO_ASCIIDOC_NAMES)) |
484b2a0c | 86 | MAN = $(MAN1) $(MAN3) $(MAN7) $(MAN8) |
a3eae3c9 | 87 | |
4fc83d94 PP |
88 | # initially empty |
89 | CLEANFILES = | |
90 | ||
91 | if EMBED_HELP | |
98477e49 MJ |
92 | mantoh_verbose = $(mantoh_verbose_@AM_V@) |
93 | mantoh_verbose_ = $(mantoh_verbose_@AM_DEFAULT_V@) | |
94 | mantoh_verbose_0 = @echo " MANTOH " $@; | |
95 | ||
4fc83d94 PP |
96 | MAN1_H = $(addsuffix .1.h,$(MAN1_NAMES)) |
97 | MAN3_H = $(addsuffix .3.h,$(MAN3_NAMES)) | |
98 | MAN8_H = $(addsuffix .8.h,$(MAN8_NAMES)) | |
99 | MAN_H = $(MAN1_H) $(MAN3_H) $(MAN8_H) | |
100 | MAN_H_RECIPE = \ | |
98477e49 | 101 | $(mantoh_verbose_0)\ |
4fc83d94 PP |
102 | MANWIDTH=80 @MANPROG@ --encoding=UTF-8 --no-hyphenation --no-justification --local-file $< > $@ ; \ |
103 | $(SED) -i 's/\\/\\\\/g' $@ ; \ | |
104 | $(SED) -i 's/"/\\"/g' $@ ; \ | |
105 | $(SED) -i 's/^\(.*\)$$/"\1\\n"/' $@ | |
106 | ||
107 | %.1.h: %.1 | |
108 | $(MAN_H_RECIPE) | |
109 | ||
110 | %.3.h: %.3 | |
111 | $(MAN_H_RECIPE) | |
112 | ||
113 | %.8.h: %.8 | |
114 | $(MAN_H_RECIPE) | |
115 | ||
116 | all-local: $(MAN_H) | |
117 | ||
118 | CLEANFILES += $(MAN_H) | |
119 | endif # EMBED_HELP | |
120 | ||
a3eae3c9 PP |
121 | if MAN_PAGES_OPT |
122 | # at this point, we know the user asked to build the man pages | |
123 | if HAVE_ASCIIDOC_XMLTO | |
98477e49 MJ |
124 | |
125 | asciidoc_verbose = $(asciidoc_verbose_@AM_V@) | |
126 | asciidoc_verbose_ = $(asciidoc_verbose_@AM_DEFAULT_V@) | |
127 | asciidoc_verbose_0 = @echo " ASCIIDOC " $@; | |
128 | ||
129 | xmlto_verbose = $(xmlto_verbose_@AM_V@) | |
130 | xmlto_verbose_ = $(xmlto_verbose_@AM_DEFAULT_V@) | |
131 | xmlto_verbose_0 = @echo " XMLTO " $@; | |
132 | ||
ceb84f55 | 133 | # tools |
98477e49 | 134 | ADOC = $(asciidoc_verbose)$(ASCIIDOC) -f $(ASCIIDOC_CONF) -f $(ASCIIDOC_ATTRS_CONF) -d manpage |
ceb84f55 | 135 | ADOC_DOCBOOK = $(ADOC) -b docbook |
360c4f63 | 136 | XTO = $(xmlto_verbose)$(XMLTO) -m $(XSL_FILE) man |
ceb84f55 | 137 | |
fd3e1238 PP |
138 | # only add this dependency if we can build the man pages because it's |
139 | # a file generated by the configure script, so it's more recent than | |
140 | # the pregenerated man pages in a tarball | |
141 | COMMON_DEPS += $(ASCIIDOC_ATTRS_CONF) | |
142 | ||
ceb84f55 PP |
143 | # recipes |
144 | %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS) | |
145 | $(ADOC_DOCBOOK) -o $@ $< | |
146 | ||
360c4f63 | 147 | %.1: %.1.xml $(XSL_FILE) |
98477e49 | 148 | $(XTO) $< 2>/dev/null |
ceb84f55 PP |
149 | |
150 | %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS) | |
151 | $(ADOC_DOCBOOK) -o $@ $< | |
152 | ||
360c4f63 | 153 | %.3: %.3.xml $(XSL_FILE) |
98477e49 | 154 | $(XTO) $< 2>/dev/null |
ceb84f55 | 155 | |
484b2a0c PP |
156 | %.7.xml: $(srcdir)/%.7.txt $(COMMON_DEPS) |
157 | $(ADOC_DOCBOOK) -o $@ $< | |
158 | ||
159 | %.7: %.7.xml $(XSL_FILE) | |
160 | $(XTO) $< 2>/dev/null | |
161 | ||
ceb84f55 PP |
162 | %.8.xml: $(srcdir)/%.8.txt $(COMMON_DEPS) |
163 | $(ADOC_DOCBOOK) -o $@ $< | |
164 | ||
360c4f63 | 165 | %.8: %.8.xml $(XSL_FILE) |
98477e49 | 166 | $(XTO) $< 2>/dev/null |
ceb84f55 | 167 | |
a3eae3c9 | 168 | # only clean the generated files if we have the tools to generate them again |
4fc83d94 | 169 | CLEANFILES += $(MAN_XML) $(MAN) |
a3eae3c9 PP |
170 | else # HAVE_ASCIIDOC_XMLTO |
171 | # create man page targets used to stop the build if we want to | |
172 | # build the man pages, but we don't have the necessary tools to do so | |
173 | ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing." | |
174 | ERR_MSG += "Make sure both tools are installed and run the configure script again." | |
175 | ||
176 | %.1: $(srcdir)/%.1.txt $(COMMON_DEPS) | |
177 | @echo $(ERR_MSG) | |
178 | @false | |
179 | ||
180 | %.3: $(srcdir)/%.3.txt $(COMMON_DEPS) | |
181 | @echo $(ERR_MSG) | |
182 | @false | |
183 | ||
484b2a0c PP |
184 | %.7: $(srcdir)/%.7.txt $(COMMON_DEPS) |
185 | @echo $(ERR_MSG) | |
186 | @false | |
187 | ||
a3eae3c9 PP |
188 | %.8: $(srcdir)/%.8.txt $(COMMON_DEPS) |
189 | @echo $(ERR_MSG) | |
ceb84f55 | 190 | @false |
a3eae3c9 PP |
191 | endif # HAVE_ASCIIDOC_XMLTO |
192 | endif # MAN_PAGES_OPT | |
193 | ||
194 | # those are always installed since they are directly written in troff | |
195 | dist_man1_MANS = $(MAN1_NO_ASCIIDOC) | |
196 | dist_man3_MANS = $(MAN3_NO_ASCIIDOC) | |
484b2a0c | 197 | dist_man7_MANS = $(MAN7_NO_ASCIIDOC) |
a3eae3c9 PP |
198 | dist_man8_MANS = $(MAN8_NO_ASCIIDOC) |
199 | ||
200 | if MAN_PAGES_OPT | |
201 | # building man pages: we can install and distribute them | |
ceb84f55 PP |
202 | dist_man1_MANS += $(MAN1) |
203 | dist_man3_MANS += $(MAN3) | |
484b2a0c | 204 | dist_man7_MANS += $(MAN7) |
ceb84f55 | 205 | dist_man8_MANS += $(MAN8) |
a3eae3c9 PP |
206 | endif # MAN_PAGES_OPT |
207 | ||
2f1c0906 PP |
208 | if !MAN_PAGES_OPT |
209 | dist-hook: | |
210 | @echo "Error: Please enable the man pages before creating a distribution tarball." | |
211 | @false | |
212 | endif # !MAN_PAGES_OPT | |
213 | ||
a3eae3c9 | 214 | # always distribute the source files |
360c4f63 | 215 | EXTRA_DIST = $(MAN_TXT) $(COMMON_TXT) $(XSL_FILE) \ |
c4ee4984 | 216 | $(ASCIIDOC_CONF) $(ASCIIDOC_ATTRS_CONF).in |
4fc83d94 PP |
217 | |
218 | # keep generated man pages that can be considered intermediate files | |
484b2a0c | 219 | .PRECIOUS: %.1 %.3 %.7 %.8 |