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: |
e02d8dc3 | 79 | ADOC = $(asciidoc_verbose)$(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \ |
82f9bfc0 SM |
80 | -a mansource="LTTng" \ |
81 | -a manmanual="LTTng Manual" \ | |
82 | -a manversion="$(PACKAGE_VERSION)" | |
6f97f9c2 | 83 | |
4ddbd0b7 | 84 | ADOC_DOCBOOK = $(ADOC) -b docbook |
e02d8dc3 | 85 | XTO = $(xmlto_verbose)$(XMLTO) -m $(XSL_FILE) man |
4ddbd0b7 PP |
86 | |
87 | # Recipes: | |
88 | %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS) | |
89 | $(ADOC_DOCBOOK) -o $@ $< | |
90 | ||
6bf962a4 | 91 | %.1: %.1.xml $(XSL_FILE) |
d8e38296 | 92 | $(XTO) $< $(xmlto_verbose_out) |
4ddbd0b7 PP |
93 | |
94 | %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS) | |
95 | $(ADOC_DOCBOOK) -o $@ $< | |
96 | ||
7fce6bd5 PP |
97 | # These pair of files are generated by a single invocation of xmlto, use |
98 | # an empty rule that depends on a fake intermediate file to track the | |
99 | # dependencies without resorting to Group Targets which were only | |
100 | # introduced in GNU Make 4.3. | |
5b1163c6 PP |
101 | lttng_ust_tracef.3 lttng_ust_vtracef.3: lttng_ust_tracef.3.alias |
102 | @# Empty recipe to mark lttng_ust_tracef.3 and lttng_ust_vtracef.3 as rebuilt | |
103 | ||
104 | lttng_ust_tracelog.3 lttng_ust_vtracelog.3: lttng_ust_tracelog.3.alias | |
105 | @# Empty recipe to mark lttng_ust_tracelog.3 and lttng_ust_vtracelog.3 as rebuilt | |
106 | ||
107 | ||
108 | .INTERMEDIATE: tracef.3.alias tracelog.3.alias lttng_ust_tracef.3.alias lttng_ust_tracelog.3.alias | |
02275a1d MJ |
109 | |
110 | tracef.3.alias: tracef.3.xml $(XSL_FILE) | |
d8e38296 | 111 | $(XTO) $< $(xmlto_verbose_out) |
8cbeea02 | 112 | |
02275a1d | 113 | tracelog.3.alias: tracelog.3.xml $(XSL_FILE) |
d8e38296 | 114 | $(XTO) $< $(xmlto_verbose_out) |
8cbeea02 | 115 | |
5b1163c6 PP |
116 | lttng_ust_tracef.3.alias: lttng_ust_tracef.3.xml $(XSL_FILE) |
117 | $(XTO) $< $(xmlto_verbose_out) | |
118 | ||
119 | lttng_ust_tracelog.3.alias: lttng_ust_tracelog.3.xml $(XSL_FILE) | |
120 | $(XTO) $< $(xmlto_verbose_out) | |
121 | ||
6bf962a4 | 122 | %.3: %.3.xml $(XSL_FILE) |
d8e38296 | 123 | $(XTO) $< $(xmlto_verbose_out) |
4ddbd0b7 PP |
124 | |
125 | # Only clean the generated files if we have the tools to generate them again. | |
126 | CLEANFILES = $(MAN_XML) $(MAN) | |
127 | else # HAVE_ASCIIDOC_XMLTO | |
128 | # Create man page targets used to stop the build if we want to | |
129 | # build the man pages, but we don't have the necessary tools to do so. | |
130 | ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing." | |
131 | ERR_MSG += "Make sure both tools are installed and run the configure script again." | |
132 | ||
133 | %.1: $(srcdir)/%.1.txt $(COMMON_DEPS) | |
134 | @echo $(ERR_MSG) | |
135 | @false | |
136 | ||
137 | %.3: $(srcdir)/%.3.txt $(COMMON_DEPS) | |
138 | @echo $(ERR_MSG) | |
139 | @false | |
140 | endif # HAVE_ASCIIDOC_XMLTO | |
41ad81d8 | 141 | endif # ENABLE_MAN_PAGES |
4ddbd0b7 PP |
142 | |
143 | # Start with empty distributed/installed man pages: | |
144 | dist_man1_MANS = | |
145 | dist_man3_MANS = | |
146 | EXTRA_DIST = | |
147 | ||
41ad81d8 | 148 | if ENABLE_MAN_PAGES |
4ddbd0b7 PP |
149 | # Building man pages: we can install and distribute them. |
150 | dist_man1_MANS += $(MAN1) | |
151 | dist_man3_MANS += $(MAN3) $(MAN3_TROFF) | |
41ad81d8 | 152 | else # ENABLE_MAN_PAGES |
4ddbd0b7 PP |
153 | # Those are not known by automake yet because dist_man3_MANS is empty |
154 | # at this point, so make sure they are distributed. | |
155 | EXTRA_DIST += $(MAN3_TROFF) | |
41ad81d8 | 156 | endif # ENABLE_MAN_PAGES |
4ddbd0b7 | 157 | |
41ad81d8 | 158 | if !ENABLE_MAN_PAGES |
4ddbd0b7 PP |
159 | dist-hook: |
160 | @echo "Error: Please enable the man pages before creating a distribution tarball." | |
161 | @false | |
41ad81d8 | 162 | endif # !ENABLE_MAN_PAGES |
4ddbd0b7 PP |
163 | |
164 | # Always distribute the source files. | |
e6e508c9 | 165 | EXTRA_DIST += $(MAN_TXT) $(COMMON_TXT) $(XSL_FILE) $(ASCIIDOC_CONF) README.md |