| 1 | # SPDX-FileCopyrightText: 2023 EfficiOS, Inc |
| 2 | # |
| 3 | # SPDX-License-Identifier: LGPL-2.1-only |
| 4 | |
| 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 \ |
| 17 | lttng-ust-dl \ |
| 18 | lttng-ust-cyg-profile \ |
| 19 | lttng_ust_tracef \ |
| 20 | lttng_ust_tracelog \ |
| 21 | tracef \ |
| 22 | tracelog |
| 23 | |
| 24 | # Man page aliases (generated from other sources): |
| 25 | MAN3_ALIASES = lttng_ust_vtracef.3 lttng_ust_vtracelog.3 |
| 26 | |
| 27 | # troff man pages: |
| 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 |
| 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 |
| 52 | XSL_FILE = $(srcdir)/manpage.xsl |
| 53 | |
| 54 | # Common dependencies: |
| 55 | COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT) |
| 56 | |
| 57 | # Man pages destinations: |
| 58 | MAN1 = $(addsuffix .1,$(MAN1_NAMES)) |
| 59 | MAN3 = $(addsuffix .3,$(MAN3_NAMES)) $(MAN3_ALIASES) |
| 60 | MAN = $(MAN1) $(MAN3) |
| 61 | |
| 62 | if ENABLE_MAN_PAGES |
| 63 | # At this point, we know the user asked to build the man pages. |
| 64 | if HAVE_ASCIIDOC_XMLTO |
| 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 | |
| 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 | |
| 78 | # Tools to execute: |
| 79 | ADOC = $(asciidoc_verbose)$(ASCIIDOC) -v -f $(ASCIIDOC_CONF) -d manpage \ |
| 80 | -a mansource="LTTng" \ |
| 81 | -a manmanual="LTTng Manual" \ |
| 82 | -a manversion="$(PACKAGE_VERSION)" \ |
| 83 | -a lttng_version="$(LTTNG_UST_MAJOR_VERSION).$(LTTNG_UST_MINOR_VERSION)" |
| 84 | |
| 85 | ADOC_DOCBOOK = $(ADOC) -b docbook |
| 86 | XTO = $(xmlto_verbose)$(XMLTO) -v -m $(XSL_FILE) man |
| 87 | |
| 88 | # Recipes: |
| 89 | %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS) |
| 90 | $(ADOC_DOCBOOK) -o $@ $< |
| 91 | |
| 92 | %.1: %.1.xml $(XSL_FILE) |
| 93 | $(XTO) $< $(xmlto_verbose_out) |
| 94 | |
| 95 | %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS) |
| 96 | $(ADOC_DOCBOOK) -o $@ $< |
| 97 | |
| 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. |
| 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 |
| 110 | |
| 111 | tracef.3.alias: tracef.3.xml $(XSL_FILE) |
| 112 | $(XTO) $< $(xmlto_verbose_out) |
| 113 | |
| 114 | tracelog.3.alias: tracelog.3.xml $(XSL_FILE) |
| 115 | $(XTO) $< $(xmlto_verbose_out) |
| 116 | |
| 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 | |
| 123 | %.3: %.3.xml $(XSL_FILE) |
| 124 | $(XTO) $< $(xmlto_verbose_out) |
| 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 |
| 142 | endif # ENABLE_MAN_PAGES |
| 143 | |
| 144 | # Start with empty distributed/installed man pages: |
| 145 | dist_man1_MANS = |
| 146 | dist_man3_MANS = |
| 147 | EXTRA_DIST = |
| 148 | |
| 149 | if ENABLE_MAN_PAGES |
| 150 | # Building man pages: we can install and distribute them. |
| 151 | dist_man1_MANS += $(MAN1) |
| 152 | dist_man3_MANS += $(MAN3) $(MAN3_TROFF) |
| 153 | else # ENABLE_MAN_PAGES |
| 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) |
| 157 | endif # ENABLE_MAN_PAGES |
| 158 | |
| 159 | if !ENABLE_MAN_PAGES |
| 160 | dist-hook: |
| 161 | @echo "Error: Please enable the man pages before creating a distribution tarball." |
| 162 | @false |
| 163 | endif # !ENABLE_MAN_PAGES |
| 164 | |
| 165 | # Always distribute the source files. |
| 166 | EXTRA_DIST += $(MAN_TXT) $(COMMON_TXT) $(XSL_FILE) $(ASCIIDOC_CONF) README.md |