1 # Man pages are only built if they are enabled at configure time.
3 # They should always be built before creating a distribution tarball.
5 # function which adds the source directory prefix and adds a given suffix
6 manaddsuffix = $(addsuffix $(1),$(addprefix $(srcdir)/,$(2)))
8 # List only the names without the .*.txt extension here:
20 lttng-enable-channel \
21 lttng-disable-channel \
35 MAN8_NAMES = lttng-sessiond lttng-relayd
36 MAN1_NO_ASCIIDOC_NAMES =
37 MAN3_NO_ASCIIDOC_NAMES = lttng-health-check
38 MAN8_NO_ASCIIDOC_NAMES =
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))
47 # common AsciiDoc source files
49 $(srcdir)/common-footer.txt \
50 $(srcdir)/common-cmd-footer.txt \
51 $(srcdir)/common-cmd-options-head.txt \
52 $(srcdir)/common-cmd-help-options.txt
55 ASCIIDOC_CONF = $(srcdir)/asciidoc.conf
56 ASCIIDOC_ATTRS_CONF = $(builddir)/asciidoc-attrs.conf
57 XSL_FILE = $(srcdir)/manpage.xsl
60 COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT)
62 # man pages destinations
63 MAN1 = $(addsuffix .1,$(MAN1_NAMES))
64 MAN3 = $(addsuffix .3,$(MAN3_NAMES))
65 MAN8 = $(addsuffix .8,$(MAN8_NAMES))
66 MAN1_NO_ASCIIDOC = $(addsuffix .1,$(MAN1_NO_ASCIIDOC_NAMES))
67 MAN3_NO_ASCIIDOC = $(addsuffix .3,$(MAN3_NO_ASCIIDOC_NAMES))
68 MAN8_NO_ASCIIDOC = $(addsuffix .8,$(MAN8_NO_ASCIIDOC_NAMES))
69 MAN = $(MAN1) $(MAN3) $(MAN8)
75 mantoh_verbose = $(mantoh_verbose_@AM_V@)
76 mantoh_verbose_ = $(mantoh_verbose_@AM_DEFAULT_V@)
77 mantoh_verbose_0 = @echo " MANTOH " $@;
79 MAN1_H = $(addsuffix .1.h,$(MAN1_NAMES))
80 MAN3_H = $(addsuffix .3.h,$(MAN3_NAMES))
81 MAN8_H = $(addsuffix .8.h,$(MAN8_NAMES))
82 MAN_H = $(MAN1_H) $(MAN3_H) $(MAN8_H)
85 MANWIDTH=80 @MANPROG@ --encoding=UTF-8 --no-hyphenation --no-justification --local-file $< > $@ ; \
86 $(SED) -i 's/\\/\\\\/g' $@ ; \
87 $(SED) -i 's/"/\\"/g' $@ ; \
88 $(SED) -i 's/^\(.*\)$$/"\1\\n"/' $@
101 CLEANFILES += $(MAN_H)
105 # at this point, we know the user asked to build the man pages
106 if HAVE_ASCIIDOC_XMLTO
108 asciidoc_verbose = $(asciidoc_verbose_@AM_V@)
109 asciidoc_verbose_ = $(asciidoc_verbose_@AM_DEFAULT_V@)
110 asciidoc_verbose_0 = @echo " ASCIIDOC " $@;
112 xmlto_verbose = $(xmlto_verbose_@AM_V@)
113 xmlto_verbose_ = $(xmlto_verbose_@AM_DEFAULT_V@)
114 xmlto_verbose_0 = @echo " XMLTO " $@;
117 ADOC = $(asciidoc_verbose)$(ASCIIDOC) -f $(ASCIIDOC_CONF) -f $(ASCIIDOC_ATTRS_CONF) -d manpage
118 ADOC_DOCBOOK = $(ADOC) -b docbook
119 XTO = $(xmlto_verbose)$(XMLTO) -m $(XSL_FILE) man
121 # only add this dependency if we can build the man pages because it's
122 # a file generated by the configure script, so it's more recent than
123 # the pregenerated man pages in a tarball
124 COMMON_DEPS += $(ASCIIDOC_ATTRS_CONF)
127 %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS)
128 $(ADOC_DOCBOOK) -o $@ $<
130 %.1: %.1.xml $(XSL_FILE)
131 $(XTO) $< 2>/dev/null
133 %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS)
134 $(ADOC_DOCBOOK) -o $@ $<
136 %.3: %.3.xml $(XSL_FILE)
137 $(XTO) $< 2>/dev/null
139 %.8.xml: $(srcdir)/%.8.txt $(COMMON_DEPS)
140 $(ADOC_DOCBOOK) -o $@ $<
142 %.8: %.8.xml $(XSL_FILE)
143 $(XTO) $< 2>/dev/null
145 # only clean the generated files if we have the tools to generate them again
146 CLEANFILES += $(MAN_XML) $(MAN)
147 else # HAVE_ASCIIDOC_XMLTO
148 # create man page targets used to stop the build if we want to
149 # build the man pages, but we don't have the necessary tools to do so
150 ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing."
151 ERR_MSG += "Make sure both tools are installed and run the configure script again."
153 %.1: $(srcdir)/%.1.txt $(COMMON_DEPS)
157 %.3: $(srcdir)/%.3.txt $(COMMON_DEPS)
161 %.8: $(srcdir)/%.8.txt $(COMMON_DEPS)
164 endif # HAVE_ASCIIDOC_XMLTO
165 endif # MAN_PAGES_OPT
167 # those are always installed since they are directly written in troff
168 dist_man1_MANS = $(MAN1_NO_ASCIIDOC)
169 dist_man3_MANS = $(MAN3_NO_ASCIIDOC)
170 dist_man8_MANS = $(MAN8_NO_ASCIIDOC)
173 # building man pages: we can install and distribute them
174 dist_man1_MANS += $(MAN1)
175 dist_man3_MANS += $(MAN3)
176 dist_man8_MANS += $(MAN8)
177 endif # MAN_PAGES_OPT
181 @echo "Error: Please enable the man pages before creating a distribution tarball."
183 endif # !MAN_PAGES_OPT
185 # always distribute the source files
186 EXTRA_DIST = $(MAN_TXT) $(COMMON_TXT) $(XSL_FILE) \
187 $(ASCIIDOC_CONF) $(ASCIIDOC_ATTRS_CONF).in
189 # keep generated man pages that can be considered intermediate files
190 .PRECIOUS: %.1 %.3 %.8