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 |
a942557f | 43 | |
ceb84f55 | 44 | MAN3_NAMES = |
f5595c32 | 45 | MAN8_NAMES = lttng-sessiond lttng-relayd |
aec4668a | 46 | MAN1_NO_ASCIIDOC_NAMES = |
23225252 | 47 | MAN3_NO_ASCIIDOC_NAMES = lttng-health-check |
f5595c32 | 48 | MAN8_NO_ASCIIDOC_NAMES = |
ceb84f55 | 49 | |
ceb84f55 PP |
50 | # AsciiDoc sources and outputs |
51 | MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES)) | |
52 | MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES)) | |
53 | MAN8_TXT = $(call manaddsuffix,.8.txt,$(MAN8_NAMES)) | |
54 | MAN_TXT = $(MAN1_TXT) $(MAN3_TXT) $(MAN8_TXT) | |
55 | MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT)) | |
56 | ||
57 | # common AsciiDoc source files | |
58 | COMMON_TXT = \ | |
59 | $(srcdir)/common-footer.txt \ | |
83f27f71 | 60 | $(srcdir)/common-cmd-footer.txt \ |
ba50d967 PP |
61 | $(srcdir)/common-cmd-options-head.txt \ |
62 | $(srcdir)/common-cmd-help-options.txt | |
ceb84f55 PP |
63 | |
64 | # config | |
767ab8b2 | 65 | ASCIIDOC_CONF = $(srcdir)/asciidoc.conf |
c4ee4984 | 66 | ASCIIDOC_ATTRS_CONF = $(builddir)/asciidoc-attrs.conf |
360c4f63 | 67 | XSL_FILE = $(srcdir)/manpage.xsl |
ceb84f55 PP |
68 | |
69 | # common dependencies | |
fd3e1238 | 70 | COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT) |
ceb84f55 | 71 | |
a3eae3c9 PP |
72 | # man pages destinations |
73 | MAN1 = $(addsuffix .1,$(MAN1_NAMES)) | |
74 | MAN3 = $(addsuffix .3,$(MAN3_NAMES)) | |
75 | MAN8 = $(addsuffix .8,$(MAN8_NAMES)) | |
76 | MAN1_NO_ASCIIDOC = $(addsuffix .1,$(MAN1_NO_ASCIIDOC_NAMES)) | |
77 | MAN3_NO_ASCIIDOC = $(addsuffix .3,$(MAN3_NO_ASCIIDOC_NAMES)) | |
78 | MAN8_NO_ASCIIDOC = $(addsuffix .8,$(MAN8_NO_ASCIIDOC_NAMES)) | |
79 | MAN = $(MAN1) $(MAN3) $(MAN8) | |
80 | ||
4fc83d94 PP |
81 | # initially empty |
82 | CLEANFILES = | |
83 | ||
84 | if EMBED_HELP | |
98477e49 MJ |
85 | mantoh_verbose = $(mantoh_verbose_@AM_V@) |
86 | mantoh_verbose_ = $(mantoh_verbose_@AM_DEFAULT_V@) | |
87 | mantoh_verbose_0 = @echo " MANTOH " $@; | |
88 | ||
4fc83d94 PP |
89 | MAN1_H = $(addsuffix .1.h,$(MAN1_NAMES)) |
90 | MAN3_H = $(addsuffix .3.h,$(MAN3_NAMES)) | |
91 | MAN8_H = $(addsuffix .8.h,$(MAN8_NAMES)) | |
92 | MAN_H = $(MAN1_H) $(MAN3_H) $(MAN8_H) | |
93 | MAN_H_RECIPE = \ | |
98477e49 | 94 | $(mantoh_verbose_0)\ |
4fc83d94 PP |
95 | MANWIDTH=80 @MANPROG@ --encoding=UTF-8 --no-hyphenation --no-justification --local-file $< > $@ ; \ |
96 | $(SED) -i 's/\\/\\\\/g' $@ ; \ | |
97 | $(SED) -i 's/"/\\"/g' $@ ; \ | |
98 | $(SED) -i 's/^\(.*\)$$/"\1\\n"/' $@ | |
99 | ||
100 | %.1.h: %.1 | |
101 | $(MAN_H_RECIPE) | |
102 | ||
103 | %.3.h: %.3 | |
104 | $(MAN_H_RECIPE) | |
105 | ||
106 | %.8.h: %.8 | |
107 | $(MAN_H_RECIPE) | |
108 | ||
109 | all-local: $(MAN_H) | |
110 | ||
111 | CLEANFILES += $(MAN_H) | |
112 | endif # EMBED_HELP | |
113 | ||
a3eae3c9 PP |
114 | if MAN_PAGES_OPT |
115 | # at this point, we know the user asked to build the man pages | |
116 | if HAVE_ASCIIDOC_XMLTO | |
98477e49 MJ |
117 | |
118 | asciidoc_verbose = $(asciidoc_verbose_@AM_V@) | |
119 | asciidoc_verbose_ = $(asciidoc_verbose_@AM_DEFAULT_V@) | |
120 | asciidoc_verbose_0 = @echo " ASCIIDOC " $@; | |
121 | ||
122 | xmlto_verbose = $(xmlto_verbose_@AM_V@) | |
123 | xmlto_verbose_ = $(xmlto_verbose_@AM_DEFAULT_V@) | |
124 | xmlto_verbose_0 = @echo " XMLTO " $@; | |
125 | ||
ceb84f55 | 126 | # tools |
98477e49 | 127 | ADOC = $(asciidoc_verbose)$(ASCIIDOC) -f $(ASCIIDOC_CONF) -f $(ASCIIDOC_ATTRS_CONF) -d manpage |
ceb84f55 | 128 | ADOC_DOCBOOK = $(ADOC) -b docbook |
360c4f63 | 129 | XTO = $(xmlto_verbose)$(XMLTO) -m $(XSL_FILE) man |
ceb84f55 | 130 | |
fd3e1238 PP |
131 | # only add this dependency if we can build the man pages because it's |
132 | # a file generated by the configure script, so it's more recent than | |
133 | # the pregenerated man pages in a tarball | |
134 | COMMON_DEPS += $(ASCIIDOC_ATTRS_CONF) | |
135 | ||
ceb84f55 PP |
136 | # recipes |
137 | %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS) | |
138 | $(ADOC_DOCBOOK) -o $@ $< | |
139 | ||
360c4f63 | 140 | %.1: %.1.xml $(XSL_FILE) |
98477e49 | 141 | $(XTO) $< 2>/dev/null |
ceb84f55 PP |
142 | |
143 | %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS) | |
144 | $(ADOC_DOCBOOK) -o $@ $< | |
145 | ||
360c4f63 | 146 | %.3: %.3.xml $(XSL_FILE) |
98477e49 | 147 | $(XTO) $< 2>/dev/null |
ceb84f55 PP |
148 | |
149 | %.8.xml: $(srcdir)/%.8.txt $(COMMON_DEPS) | |
150 | $(ADOC_DOCBOOK) -o $@ $< | |
151 | ||
360c4f63 | 152 | %.8: %.8.xml $(XSL_FILE) |
98477e49 | 153 | $(XTO) $< 2>/dev/null |
ceb84f55 | 154 | |
a3eae3c9 | 155 | # only clean the generated files if we have the tools to generate them again |
4fc83d94 | 156 | CLEANFILES += $(MAN_XML) $(MAN) |
a3eae3c9 PP |
157 | else # HAVE_ASCIIDOC_XMLTO |
158 | # create man page targets used to stop the build if we want to | |
159 | # build the man pages, but we don't have the necessary tools to do so | |
160 | ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing." | |
161 | ERR_MSG += "Make sure both tools are installed and run the configure script again." | |
162 | ||
163 | %.1: $(srcdir)/%.1.txt $(COMMON_DEPS) | |
164 | @echo $(ERR_MSG) | |
165 | @false | |
166 | ||
167 | %.3: $(srcdir)/%.3.txt $(COMMON_DEPS) | |
168 | @echo $(ERR_MSG) | |
169 | @false | |
170 | ||
171 | %.8: $(srcdir)/%.8.txt $(COMMON_DEPS) | |
172 | @echo $(ERR_MSG) | |
ceb84f55 | 173 | @false |
a3eae3c9 PP |
174 | endif # HAVE_ASCIIDOC_XMLTO |
175 | endif # MAN_PAGES_OPT | |
176 | ||
177 | # those are always installed since they are directly written in troff | |
178 | dist_man1_MANS = $(MAN1_NO_ASCIIDOC) | |
179 | dist_man3_MANS = $(MAN3_NO_ASCIIDOC) | |
180 | dist_man8_MANS = $(MAN8_NO_ASCIIDOC) | |
181 | ||
182 | if MAN_PAGES_OPT | |
183 | # building man pages: we can install and distribute them | |
ceb84f55 PP |
184 | dist_man1_MANS += $(MAN1) |
185 | dist_man3_MANS += $(MAN3) | |
186 | dist_man8_MANS += $(MAN8) | |
a3eae3c9 PP |
187 | endif # MAN_PAGES_OPT |
188 | ||
2f1c0906 PP |
189 | if !MAN_PAGES_OPT |
190 | dist-hook: | |
191 | @echo "Error: Please enable the man pages before creating a distribution tarball." | |
192 | @false | |
193 | endif # !MAN_PAGES_OPT | |
194 | ||
a3eae3c9 | 195 | # always distribute the source files |
360c4f63 | 196 | EXTRA_DIST = $(MAN_TXT) $(COMMON_TXT) $(XSL_FILE) \ |
c4ee4984 | 197 | $(ASCIIDOC_CONF) $(ASCIIDOC_ATTRS_CONF).in |
4fc83d94 PP |
198 | |
199 | # keep generated man pages that can be considered intermediate files | |
200 | .PRECIOUS: %.1 %.3 %.8 |