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 | ||
20 | # troff man pages: | |
21 | MAN3_TROFF = do_tracepoint.3 tracepoint.3 tracepoint_enabled.3 | |
22 | ||
23 | # AsciiDoc sources and outputs: | |
24 | MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES)) | |
25 | MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES)) | |
26 | MAN_TXT = $(MAN1_TXT) $(MAN3_TXT) $(MAN8_TXT) | |
27 | MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT)) | |
28 | ||
29 | # Common AsciiDoc source files: | |
30 | COMMON_TXT = \ | |
31 | $(srcdir)/common-footer.txt \ | |
32 | $(srcdir)/common-authors.txt \ | |
33 | $(srcdir)/common-copyrights.txt \ | |
34 | $(srcdir)/log-levels.txt \ | |
35 | $(srcdir)/tracef-tracelog-limitations.txt | |
36 | ||
37 | # AsciiDoc configuration and XSL files: | |
38 | ASCIIDOC_CONF = $(srcdir)/asciidoc.conf | |
6bf962a4 | 39 | XSL_FILE = $(srcdir)/manpage.xsl |
4ddbd0b7 PP |
40 | |
41 | # Common dependencies: | |
42 | COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT) | |
43 | ||
44 | # Man pages destinations: | |
45 | MAN1 = $(addsuffix .1,$(MAN1_NAMES)) | |
46 | MAN3 = $(addsuffix .3,$(MAN3_NAMES)) | |
47 | MAN = $(MAN1) $(MAN3) | |
48 | ||
49 | if MAN_PAGES_OPT | |
50 | # At this point, we know the user asked to build the man pages. | |
51 | if HAVE_ASCIIDOC_XMLTO | |
e02d8dc3 MJ |
52 | |
53 | asciidoc_verbose = $(asciidoc_verbose_@AM_V@) | |
54 | asciidoc_verbose_ = $(asciidoc_verbose_@AM_DEFAULT_V@) | |
55 | asciidoc_verbose_0 = @echo " ASCIIDOC " $@; | |
56 | ||
57 | xmlto_verbose = $(xmlto_verbose_@AM_V@) | |
58 | xmlto_verbose_ = $(xmlto_verbose_@AM_DEFAULT_V@) | |
59 | xmlto_verbose_0 = @echo " XMLTO " $@; | |
60 | ||
4ddbd0b7 | 61 | # Tools to execute: |
e02d8dc3 | 62 | ADOC = $(asciidoc_verbose)$(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \ |
82f9bfc0 SM |
63 | -a lttng_ust_register_timeout="@LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS@" \ |
64 | -a mansource="LTTng" \ | |
65 | -a manmanual="LTTng Manual" \ | |
66 | -a manversion="$(PACKAGE_VERSION)" | |
6f97f9c2 | 67 | |
4ddbd0b7 | 68 | ADOC_DOCBOOK = $(ADOC) -b docbook |
e02d8dc3 | 69 | XTO = $(xmlto_verbose)$(XMLTO) -m $(XSL_FILE) man |
4ddbd0b7 PP |
70 | |
71 | # Recipes: | |
72 | %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS) | |
73 | $(ADOC_DOCBOOK) -o $@ $< | |
74 | ||
6bf962a4 | 75 | %.1: %.1.xml $(XSL_FILE) |
e02d8dc3 | 76 | $(XTO) $< 2>/dev/null |
4ddbd0b7 PP |
77 | |
78 | %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS) | |
79 | $(ADOC_DOCBOOK) -o $@ $< | |
80 | ||
6bf962a4 | 81 | %.3: %.3.xml $(XSL_FILE) |
e02d8dc3 | 82 | $(XTO) $< 2>/dev/null |
4ddbd0b7 PP |
83 | |
84 | # Only clean the generated files if we have the tools to generate them again. | |
85 | CLEANFILES = $(MAN_XML) $(MAN) | |
86 | else # HAVE_ASCIIDOC_XMLTO | |
87 | # Create man page targets used to stop the build if we want to | |
88 | # build the man pages, but we don't have the necessary tools to do so. | |
89 | ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing." | |
90 | ERR_MSG += "Make sure both tools are installed and run the configure script again." | |
91 | ||
92 | %.1: $(srcdir)/%.1.txt $(COMMON_DEPS) | |
93 | @echo $(ERR_MSG) | |
94 | @false | |
95 | ||
96 | %.3: $(srcdir)/%.3.txt $(COMMON_DEPS) | |
97 | @echo $(ERR_MSG) | |
98 | @false | |
99 | endif # HAVE_ASCIIDOC_XMLTO | |
100 | endif # MAN_PAGES_OPT | |
101 | ||
102 | # Start with empty distributed/installed man pages: | |
103 | dist_man1_MANS = | |
104 | dist_man3_MANS = | |
105 | EXTRA_DIST = | |
106 | ||
107 | if MAN_PAGES_OPT | |
108 | # Building man pages: we can install and distribute them. | |
109 | dist_man1_MANS += $(MAN1) | |
110 | dist_man3_MANS += $(MAN3) $(MAN3_TROFF) | |
111 | else # MAN_PAGES_OPT | |
112 | # Those are not known by automake yet because dist_man3_MANS is empty | |
113 | # at this point, so make sure they are distributed. | |
114 | EXTRA_DIST += $(MAN3_TROFF) | |
115 | endif # MAN_PAGES_OPT | |
116 | ||
117 | if !MAN_PAGES_OPT | |
118 | dist-hook: | |
119 | @echo "Error: Please enable the man pages before creating a distribution tarball." | |
120 | @false | |
121 | endif # !MAN_PAGES_OPT | |
122 | ||
123 | # Always distribute the source files. | |
e6e508c9 | 124 | EXTRA_DIST += $(MAN_TXT) $(COMMON_TXT) $(XSL_FILE) $(ASCIIDOC_CONF) README.md |