1 # SPDX-License-Identifier: LGPL-2.1-only
3 # Man pages are only built if they are enabled at configure time.
5 # They should always be built before creating a distribution tarball.
7 # Function which adds the source directory prefix and adds a given suffix:
8 manaddsuffix = $(addsuffix $(1),$(addprefix $(srcdir)/,$(2)))
10 # List only the names without the .*.txt extension here:
21 MAN3_TROFF = do_tracepoint.3 tracepoint.3 tracepoint_enabled.3
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))
29 # Common AsciiDoc source files:
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
37 # AsciiDoc configuration and XSL files:
38 ASCIIDOC_CONF = $(srcdir)/asciidoc.conf
39 XSL_FILE = $(srcdir)/manpage.xsl
41 # Common dependencies:
42 COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT)
44 # Man pages destinations:
45 MAN1 = $(addsuffix .1,$(MAN1_NAMES))
46 MAN3 = $(addsuffix .3,$(MAN3_NAMES))
50 # At this point, we know the user asked to build the man pages.
51 if HAVE_ASCIIDOC_XMLTO
53 asciidoc_verbose = $(asciidoc_verbose_@AM_V@)
54 asciidoc_verbose_ = $(asciidoc_verbose_@AM_DEFAULT_V@)
55 asciidoc_verbose_0 = @echo " ASCIIDOC " $@;
57 xmlto_verbose = $(xmlto_verbose_@AM_V@)
58 xmlto_verbose_ = $(xmlto_verbose_@AM_DEFAULT_V@)
59 xmlto_verbose_0 = @echo " XMLTO " $@;
62 ADOC = $(asciidoc_verbose)$(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \
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)"
68 ADOC_DOCBOOK = $(ADOC) -b docbook
69 XTO = $(xmlto_verbose)$(XMLTO) -m $(XSL_FILE) man
72 %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS)
73 $(ADOC_DOCBOOK) -o $@ $<
75 %.1: %.1.xml $(XSL_FILE)
78 %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS)
79 $(ADOC_DOCBOOK) -o $@ $<
81 %.3: %.3.xml $(XSL_FILE)
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."
92 %.1: $(srcdir)/%.1.txt $(COMMON_DEPS)
96 %.3: $(srcdir)/%.3.txt $(COMMON_DEPS)
99 endif # HAVE_ASCIIDOC_XMLTO
100 endif # MAN_PAGES_OPT
102 # Start with empty distributed/installed man pages:
108 # Building man pages: we can install and distribute them.
109 dist_man1_MANS += $(MAN1)
110 dist_man3_MANS += $(MAN3) $(MAN3_TROFF)
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
119 @echo "Error: Please enable the man pages before creating a distribution tarball."
121 endif # !MAN_PAGES_OPT
123 # Always distribute the source files.
124 EXTRA_DIST += $(MAN_TXT) $(COMMON_TXT) $(XSL_FILE) $(ASCIIDOC_CONF) README.md