doc: xmlto output to stdout on a verbose build
[lttng-ust.git] / doc / man / Makefile.am
1 # SPDX-License-Identifier: LGPL-2.1-only
2
3 # Man pages are only built if they are enabled at configure time.
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 = \
12 lttng-gen-tp
13 MAN3_NAMES = \
14 lttng-ust \
15 tracef \
16 tracelog \
17 lttng-ust-dl \
18 lttng-ust-cyg-profile
19
20 # Man page aliases (generated from other sources):
21 MAN3_ALIASES = vtracef.3 vtracelog.3
22
23 # troff man pages:
24 MAN3_TROFF = do_tracepoint.3 tracepoint.3 tracepoint_enabled.3
25
26 # AsciiDoc sources and outputs:
27 MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES))
28 MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES))
29 MAN_TXT = $(MAN1_TXT) $(MAN3_TXT) $(MAN8_TXT)
30 MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT))
31
32 # Common AsciiDoc source files:
33 COMMON_TXT = \
34 $(srcdir)/common-footer.txt \
35 $(srcdir)/common-authors.txt \
36 $(srcdir)/common-copyrights.txt \
37 $(srcdir)/log-levels.txt \
38 $(srcdir)/tracef-tracelog-limitations.txt
39
40 # AsciiDoc configuration and XSL files:
41 ASCIIDOC_CONF = $(srcdir)/asciidoc.conf
42 XSL_FILE = $(srcdir)/manpage.xsl
43
44 # Common dependencies:
45 COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT)
46
47 # Man pages destinations:
48 MAN1 = $(addsuffix .1,$(MAN1_NAMES))
49 MAN3 = $(addsuffix .3,$(MAN3_NAMES)) $(MAN3_ALIASES)
50 MAN = $(MAN1) $(MAN3)
51
52 if ENABLE_MAN_PAGES
53 # At this point, we know the user asked to build the man pages.
54 if HAVE_ASCIIDOC_XMLTO
55
56 asciidoc_verbose = $(asciidoc_verbose_@AM_V@)
57 asciidoc_verbose_ = $(asciidoc_verbose_@AM_DEFAULT_V@)
58 asciidoc_verbose_0 = @echo " ASCIIDOC " $@;
59
60 xmlto_verbose = $(xmlto_verbose_@AM_V@)
61 xmlto_verbose_ = $(xmlto_verbose_@AM_DEFAULT_V@)
62 xmlto_verbose_0 = @echo " XMLTO " $@;
63
64 xmlto_verbose_out = $(xmlto_verbose_out_@AM_V@)
65 xmlto_verbose_out_ = $(xmlto_verbose_out_@AM_DEFAULT_V@)
66 xmlto_verbose_out_0 = 2>/dev/null
67
68 # Tools to execute:
69 ADOC = $(asciidoc_verbose)$(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \
70 -a mansource="LTTng" \
71 -a manmanual="LTTng Manual" \
72 -a manversion="$(PACKAGE_VERSION)"
73
74 ADOC_DOCBOOK = $(ADOC) -b docbook
75 XTO = $(xmlto_verbose)$(XMLTO) -m $(XSL_FILE) man
76
77 # Recipes:
78 %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS)
79 $(ADOC_DOCBOOK) -o $@ $<
80
81 %.1: %.1.xml $(XSL_FILE)
82 $(XTO) $< $(xmlto_verbose_out)
83
84 %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS)
85 $(ADOC_DOCBOOK) -o $@ $<
86
87 # These pair of files are generated by a single invocation of xmlto, use an
88 # empty rule that depends on a fake intermediate file to track the dependencies
89 # without resorting to Group Targets which were only introduced in GNU Make 4.3.
90 tracef.3 vtracef.3: tracef.3.alias
91 @# Empty recipe to mark tracef.3 and vtracef.3 as rebuilt
92
93 tracelog.3 vtracelog.3: tracelog.3.alias
94 @# Empty recipe to mark tracelog.3 and vtracelog.3 as rebuilt
95
96 .INTERMEDIATE: tracef.3.alias tracelog.3.alias
97
98 tracef.3.alias: tracef.3.xml $(XSL_FILE)
99 $(XTO) $< $(xmlto_verbose_out)
100
101 tracelog.3.alias: tracelog.3.xml $(XSL_FILE)
102 $(XTO) $< $(xmlto_verbose_out)
103
104 %.3: %.3.xml $(XSL_FILE)
105 $(XTO) $< $(xmlto_verbose_out)
106
107 # Only clean the generated files if we have the tools to generate them again.
108 CLEANFILES = $(MAN_XML) $(MAN)
109 else # HAVE_ASCIIDOC_XMLTO
110 # Create man page targets used to stop the build if we want to
111 # build the man pages, but we don't have the necessary tools to do so.
112 ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing."
113 ERR_MSG += "Make sure both tools are installed and run the configure script again."
114
115 %.1: $(srcdir)/%.1.txt $(COMMON_DEPS)
116 @echo $(ERR_MSG)
117 @false
118
119 %.3: $(srcdir)/%.3.txt $(COMMON_DEPS)
120 @echo $(ERR_MSG)
121 @false
122 endif # HAVE_ASCIIDOC_XMLTO
123 endif # ENABLE_MAN_PAGES
124
125 # Start with empty distributed/installed man pages:
126 dist_man1_MANS =
127 dist_man3_MANS =
128 EXTRA_DIST =
129
130 if ENABLE_MAN_PAGES
131 # Building man pages: we can install and distribute them.
132 dist_man1_MANS += $(MAN1)
133 dist_man3_MANS += $(MAN3) $(MAN3_TROFF)
134 else # ENABLE_MAN_PAGES
135 # Those are not known by automake yet because dist_man3_MANS is empty
136 # at this point, so make sure they are distributed.
137 EXTRA_DIST += $(MAN3_TROFF)
138 endif # ENABLE_MAN_PAGES
139
140 if !ENABLE_MAN_PAGES
141 dist-hook:
142 @echo "Error: Please enable the man pages before creating a distribution tarball."
143 @false
144 endif # !ENABLE_MAN_PAGES
145
146 # Always distribute the source files.
147 EXTRA_DIST += $(MAN_TXT) $(COMMON_TXT) $(XSL_FILE) $(ASCIIDOC_CONF) README.md
This page took 0.031875 seconds and 4 git commands to generate.