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