Commit | Line | Data |
---|---|---|
c0c0989a MJ |
1 | # SPDX-License-Identifier: LGPL-2.1-only |
2 | ||
4ddbd0b7 PP |
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 | ||
8cbeea02 PP |
20 | # Man page aliases (generated from other sources): |
21 | MAN3_ALIASES = vtracef.3 vtracelog.3 | |
22 | ||
4ddbd0b7 PP |
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 | |
6bf962a4 | 42 | XSL_FILE = $(srcdir)/manpage.xsl |
4ddbd0b7 PP |
43 | |
44 | # Common dependencies: | |
45 | COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT) | |
46 | ||
47 | # Man pages destinations: | |
48 | MAN1 = $(addsuffix .1,$(MAN1_NAMES)) | |
8cbeea02 | 49 | MAN3 = $(addsuffix .3,$(MAN3_NAMES)) $(MAN3_ALIASES) |
4ddbd0b7 PP |
50 | MAN = $(MAN1) $(MAN3) |
51 | ||
52 | if MAN_PAGES_OPT | |
53 | # At this point, we know the user asked to build the man pages. | |
54 | if HAVE_ASCIIDOC_XMLTO | |
e02d8dc3 MJ |
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 | ||
4ddbd0b7 | 64 | # Tools to execute: |
e02d8dc3 | 65 | ADOC = $(asciidoc_verbose)$(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \ |
82f9bfc0 SM |
66 | -a lttng_ust_register_timeout="@LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS@" \ |
67 | -a mansource="LTTng" \ | |
68 | -a manmanual="LTTng Manual" \ | |
69 | -a manversion="$(PACKAGE_VERSION)" | |
6f97f9c2 | 70 | |
4ddbd0b7 | 71 | ADOC_DOCBOOK = $(ADOC) -b docbook |
e02d8dc3 | 72 | XTO = $(xmlto_verbose)$(XMLTO) -m $(XSL_FILE) man |
4ddbd0b7 PP |
73 | |
74 | # Recipes: | |
75 | %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS) | |
76 | $(ADOC_DOCBOOK) -o $@ $< | |
77 | ||
6bf962a4 | 78 | %.1: %.1.xml $(XSL_FILE) |
e02d8dc3 | 79 | $(XTO) $< 2>/dev/null |
4ddbd0b7 PP |
80 | |
81 | %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS) | |
82 | $(ADOC_DOCBOOK) -o $@ $< | |
83 | ||
8cbeea02 PP |
84 | tracef.3 vtracef.3 &: tracef.3.xml $(XSL_FILE) |
85 | $(XTO) $< 2>/dev/null | |
86 | ||
87 | tracelog.3 vtracelog.3 &: tracelog.3.xml $(XSL_FILE) | |
88 | $(XTO) $< 2>/dev/null | |
89 | ||
6bf962a4 | 90 | %.3: %.3.xml $(XSL_FILE) |
e02d8dc3 | 91 | $(XTO) $< 2>/dev/null |
4ddbd0b7 PP |
92 | |
93 | # Only clean the generated files if we have the tools to generate them again. | |
94 | CLEANFILES = $(MAN_XML) $(MAN) | |
95 | else # HAVE_ASCIIDOC_XMLTO | |
96 | # Create man page targets used to stop the build if we want to | |
97 | # build the man pages, but we don't have the necessary tools to do so. | |
98 | ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing." | |
99 | ERR_MSG += "Make sure both tools are installed and run the configure script again." | |
100 | ||
101 | %.1: $(srcdir)/%.1.txt $(COMMON_DEPS) | |
102 | @echo $(ERR_MSG) | |
103 | @false | |
104 | ||
105 | %.3: $(srcdir)/%.3.txt $(COMMON_DEPS) | |
106 | @echo $(ERR_MSG) | |
107 | @false | |
108 | endif # HAVE_ASCIIDOC_XMLTO | |
109 | endif # MAN_PAGES_OPT | |
110 | ||
111 | # Start with empty distributed/installed man pages: | |
112 | dist_man1_MANS = | |
113 | dist_man3_MANS = | |
114 | EXTRA_DIST = | |
115 | ||
116 | if MAN_PAGES_OPT | |
117 | # Building man pages: we can install and distribute them. | |
118 | dist_man1_MANS += $(MAN1) | |
119 | dist_man3_MANS += $(MAN3) $(MAN3_TROFF) | |
120 | else # MAN_PAGES_OPT | |
121 | # Those are not known by automake yet because dist_man3_MANS is empty | |
122 | # at this point, so make sure they are distributed. | |
123 | EXTRA_DIST += $(MAN3_TROFF) | |
124 | endif # MAN_PAGES_OPT | |
125 | ||
126 | if !MAN_PAGES_OPT | |
127 | dist-hook: | |
128 | @echo "Error: Please enable the man pages before creating a distribution tarball." | |
129 | @false | |
130 | endif # !MAN_PAGES_OPT | |
131 | ||
132 | # Always distribute the source files. | |
e6e508c9 | 133 | EXTRA_DIST += $(MAN_TXT) $(COMMON_TXT) $(XSL_FILE) $(ASCIIDOC_CONF) README.md |