Commit | Line | Data |
---|---|---|
e03d7c66 MJ |
1 | # SPDX-FileCopyrightText: 2023 EfficiOS, Inc |
2 | # | |
c0c0989a MJ |
3 | # SPDX-License-Identifier: LGPL-2.1-only |
4 | ||
4ddbd0b7 PP |
5 | # Man pages are only built if they are enabled at configure time. |
6 | # | |
7 | # They should always be built before creating a distribution tarball. | |
8 | ||
9 | # Function which adds the source directory prefix and adds a given suffix: | |
10 | manaddsuffix = $(addsuffix $(1),$(addprefix $(srcdir)/,$(2))) | |
11 | ||
12 | # List only the names without the .*.txt extension here: | |
13 | MAN1_NAMES = \ | |
14 | lttng-gen-tp | |
15 | MAN3_NAMES = \ | |
16 | lttng-ust \ | |
4ddbd0b7 | 17 | lttng-ust-dl \ |
5b1163c6 PP |
18 | lttng-ust-cyg-profile \ |
19 | lttng_ust_tracef \ | |
20 | lttng_ust_tracelog \ | |
21 | tracef \ | |
22 | tracelog | |
4ddbd0b7 | 23 | |
8cbeea02 | 24 | # Man page aliases (generated from other sources): |
7fce6bd5 | 25 | MAN3_ALIASES = lttng_ust_vtracef.3 lttng_ust_vtracelog.3 |
8cbeea02 | 26 | |
4ddbd0b7 | 27 | # troff man pages: |
5b1163c6 PP |
28 | MAN3_TROFF = \ |
29 | do_tracepoint.3 \ | |
30 | lttng_ust_do_tracepoint.3 \ | |
31 | lttng_ust_tracepoint.3 \ | |
32 | lttng_ust_tracepoint_enabled.3 \ | |
33 | tracepoint.3 \ | |
34 | tracepoint_enabled.3 | |
4ddbd0b7 PP |
35 | |
36 | # AsciiDoc sources and outputs: | |
37 | MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES)) | |
38 | MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES)) | |
39 | MAN_TXT = $(MAN1_TXT) $(MAN3_TXT) $(MAN8_TXT) | |
40 | MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT)) | |
41 | ||
42 | # Common AsciiDoc source files: | |
43 | COMMON_TXT = \ | |
44 | $(srcdir)/common-footer.txt \ | |
45 | $(srcdir)/common-authors.txt \ | |
46 | $(srcdir)/common-copyrights.txt \ | |
47 | $(srcdir)/log-levels.txt \ | |
48 | $(srcdir)/tracef-tracelog-limitations.txt | |
49 | ||
50 | # AsciiDoc configuration and XSL files: | |
51 | ASCIIDOC_CONF = $(srcdir)/asciidoc.conf | |
6bf962a4 | 52 | XSL_FILE = $(srcdir)/manpage.xsl |
4ddbd0b7 PP |
53 | |
54 | # Common dependencies: | |
55 | COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT) | |
56 | ||
57 | # Man pages destinations: | |
58 | MAN1 = $(addsuffix .1,$(MAN1_NAMES)) | |
8cbeea02 | 59 | MAN3 = $(addsuffix .3,$(MAN3_NAMES)) $(MAN3_ALIASES) |
4ddbd0b7 PP |
60 | MAN = $(MAN1) $(MAN3) |
61 | ||
41ad81d8 | 62 | if ENABLE_MAN_PAGES |
4ddbd0b7 PP |
63 | # At this point, we know the user asked to build the man pages. |
64 | if HAVE_ASCIIDOC_XMLTO | |
e02d8dc3 MJ |
65 | |
66 | asciidoc_verbose = $(asciidoc_verbose_@AM_V@) | |
67 | asciidoc_verbose_ = $(asciidoc_verbose_@AM_DEFAULT_V@) | |
68 | asciidoc_verbose_0 = @echo " ASCIIDOC " $@; | |
69 | ||
70 | xmlto_verbose = $(xmlto_verbose_@AM_V@) | |
71 | xmlto_verbose_ = $(xmlto_verbose_@AM_DEFAULT_V@) | |
72 | xmlto_verbose_0 = @echo " XMLTO " $@; | |
73 | ||
d8e38296 MJ |
74 | xmlto_verbose_out = $(xmlto_verbose_out_@AM_V@) |
75 | xmlto_verbose_out_ = $(xmlto_verbose_out_@AM_DEFAULT_V@) | |
76 | xmlto_verbose_out_0 = 2>/dev/null | |
77 | ||
4ddbd0b7 | 78 | # Tools to execute: |
5cc87292 | 79 | ADOC = $(asciidoc_verbose)$(ASCIIDOC) -v -f $(ASCIIDOC_CONF) -d manpage \ |
82f9bfc0 SM |
80 | -a mansource="LTTng" \ |
81 | -a manmanual="LTTng Manual" \ | |
5cc87292 KS |
82 | -a manversion="$(PACKAGE_VERSION)" \ |
83 | -a lttng_version="$(LTTNG_UST_MAJOR_VERSION).$(LTTNG_UST_MINOR_VERSION)" | |
6f97f9c2 | 84 | |
4ddbd0b7 | 85 | ADOC_DOCBOOK = $(ADOC) -b docbook |
5cc87292 | 86 | XTO = $(xmlto_verbose)$(XMLTO) -v -m $(XSL_FILE) man |
4ddbd0b7 PP |
87 | |
88 | # Recipes: | |
89 | %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS) | |
90 | $(ADOC_DOCBOOK) -o $@ $< | |
91 | ||
6bf962a4 | 92 | %.1: %.1.xml $(XSL_FILE) |
d8e38296 | 93 | $(XTO) $< $(xmlto_verbose_out) |
4ddbd0b7 PP |
94 | |
95 | %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS) | |
96 | $(ADOC_DOCBOOK) -o $@ $< | |
97 | ||
7fce6bd5 PP |
98 | # These pair of files are generated by a single invocation of xmlto, use |
99 | # an empty rule that depends on a fake intermediate file to track the | |
100 | # dependencies without resorting to Group Targets which were only | |
101 | # introduced in GNU Make 4.3. | |
5b1163c6 PP |
102 | lttng_ust_tracef.3 lttng_ust_vtracef.3: lttng_ust_tracef.3.alias |
103 | @# Empty recipe to mark lttng_ust_tracef.3 and lttng_ust_vtracef.3 as rebuilt | |
104 | ||
105 | lttng_ust_tracelog.3 lttng_ust_vtracelog.3: lttng_ust_tracelog.3.alias | |
106 | @# Empty recipe to mark lttng_ust_tracelog.3 and lttng_ust_vtracelog.3 as rebuilt | |
107 | ||
108 | ||
109 | .INTERMEDIATE: tracef.3.alias tracelog.3.alias lttng_ust_tracef.3.alias lttng_ust_tracelog.3.alias | |
02275a1d MJ |
110 | |
111 | tracef.3.alias: tracef.3.xml $(XSL_FILE) | |
d8e38296 | 112 | $(XTO) $< $(xmlto_verbose_out) |
8cbeea02 | 113 | |
02275a1d | 114 | tracelog.3.alias: tracelog.3.xml $(XSL_FILE) |
d8e38296 | 115 | $(XTO) $< $(xmlto_verbose_out) |
8cbeea02 | 116 | |
5b1163c6 PP |
117 | lttng_ust_tracef.3.alias: lttng_ust_tracef.3.xml $(XSL_FILE) |
118 | $(XTO) $< $(xmlto_verbose_out) | |
119 | ||
120 | lttng_ust_tracelog.3.alias: lttng_ust_tracelog.3.xml $(XSL_FILE) | |
121 | $(XTO) $< $(xmlto_verbose_out) | |
122 | ||
6bf962a4 | 123 | %.3: %.3.xml $(XSL_FILE) |
d8e38296 | 124 | $(XTO) $< $(xmlto_verbose_out) |
4ddbd0b7 PP |
125 | |
126 | # Only clean the generated files if we have the tools to generate them again. | |
127 | CLEANFILES = $(MAN_XML) $(MAN) | |
128 | else # HAVE_ASCIIDOC_XMLTO | |
129 | # Create man page targets used to stop the build if we want to | |
130 | # build the man pages, but we don't have the necessary tools to do so. | |
131 | ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing." | |
132 | ERR_MSG += "Make sure both tools are installed and run the configure script again." | |
133 | ||
134 | %.1: $(srcdir)/%.1.txt $(COMMON_DEPS) | |
135 | @echo $(ERR_MSG) | |
136 | @false | |
137 | ||
138 | %.3: $(srcdir)/%.3.txt $(COMMON_DEPS) | |
139 | @echo $(ERR_MSG) | |
140 | @false | |
141 | endif # HAVE_ASCIIDOC_XMLTO | |
41ad81d8 | 142 | endif # ENABLE_MAN_PAGES |
4ddbd0b7 PP |
143 | |
144 | # Start with empty distributed/installed man pages: | |
145 | dist_man1_MANS = | |
146 | dist_man3_MANS = | |
147 | EXTRA_DIST = | |
148 | ||
41ad81d8 | 149 | if ENABLE_MAN_PAGES |
4ddbd0b7 PP |
150 | # Building man pages: we can install and distribute them. |
151 | dist_man1_MANS += $(MAN1) | |
152 | dist_man3_MANS += $(MAN3) $(MAN3_TROFF) | |
41ad81d8 | 153 | else # ENABLE_MAN_PAGES |
4ddbd0b7 PP |
154 | # Those are not known by automake yet because dist_man3_MANS is empty |
155 | # at this point, so make sure they are distributed. | |
156 | EXTRA_DIST += $(MAN3_TROFF) | |
41ad81d8 | 157 | endif # ENABLE_MAN_PAGES |
4ddbd0b7 | 158 | |
41ad81d8 | 159 | if !ENABLE_MAN_PAGES |
4ddbd0b7 PP |
160 | dist-hook: |
161 | @echo "Error: Please enable the man pages before creating a distribution tarball." | |
162 | @false | |
41ad81d8 | 163 | endif # !ENABLE_MAN_PAGES |
4ddbd0b7 PP |
164 | |
165 | # Always distribute the source files. | |
e6e508c9 | 166 | EXTRA_DIST += $(MAN_TXT) $(COMMON_TXT) $(XSL_FILE) $(ASCIIDOC_CONF) README.md |