Move to kernel style SPDX license identifiers
[babeltrace.git] / doc / man / Makefile.am
1 # SPDX-License-Identifier: MIT
2
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 babeltrace2 \
13 babeltrace2-convert \
14 babeltrace2-help \
15 babeltrace2-list-plugins \
16 babeltrace2-query \
17 babeltrace2-run
18 MAN7_NAMES = babeltrace2-filter.utils.muxer \
19 babeltrace2-filter.utils.trimmer \
20 babeltrace2-intro \
21 babeltrace2-plugin-ctf \
22 babeltrace2-plugin-text \
23 babeltrace2-plugin-utils \
24 babeltrace2-sink.ctf.fs \
25 babeltrace2-sink.text.pretty \
26 babeltrace2-sink.text.details \
27 babeltrace2-sink.utils.counter \
28 babeltrace2-sink.utils.dummy \
29 babeltrace2-source.ctf.fs \
30 babeltrace2-source.ctf.lttng-live \
31 babeltrace2-source.text.dmesg \
32 babeltrace2-query-babeltrace.support-info \
33 babeltrace2-query-babeltrace.trace-infos
34 MAN1_NO_ASCIIDOC_NAMES =
35 MAN7_NO_ASCIIDOC_NAMES =
36
37 if ENABLE_DEBUG_INFO
38 MAN7_NAMES += \
39 babeltrace2-plugin-lttng-utils \
40 babeltrace2-filter.lttng-utils.debug-info
41 endif
42
43 # AsciiDoc sources and outputs
44 MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES))
45 MAN7_TXT = $(call manaddsuffix,.7.txt,$(MAN7_NAMES))
46 MAN_TXT = $(MAN1_TXT) $(MAN7_TXT)
47 MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT))
48
49 # common AsciiDoc source files
50 COMMON_TXT = \
51 $(srcdir)/common-cli-env.txt \
52 $(srcdir)/common-cli-files.txt \
53 $(srcdir)/common-cmd-footer.txt \
54 $(srcdir)/common-cmd-info-options.txt \
55 $(srcdir)/common-cmd-params-format.txt \
56 $(srcdir)/common-common-env.txt \
57 $(srcdir)/common-footer.txt \
58 $(srcdir)/common-gen-options.txt \
59 $(srcdir)/common-lib-env.txt \
60 $(srcdir)/common-see-babeltrace2-intro.txt \
61 $(srcdir)/common-convert-examples.txt \
62 $(srcdir)/common-log-levels.txt \
63 $(srcdir)/common-trimmer-time-format.txt
64
65 # config
66 ASCIIDOC_CONF = $(srcdir)/bt-asciidoc.conf
67 ASCIIDOC_ATTRS_CONF = $(builddir)/asciidoc-attrs.conf
68 XSL_SRC_FILE = $(srcdir)/manpage.xsl
69
70 # common dependencies
71 COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT)
72
73 # man pages destinations
74 MAN1 = $(addsuffix .1,$(MAN1_NAMES))
75 MAN7 = $(addsuffix .7,$(MAN7_NAMES))
76 MAN1_NO_ASCIIDOC = $(addsuffix .1,$(MAN1_NO_ASCIIDOC_NAMES))
77 MAN7_NO_ASCIIDOC = $(addsuffix .7,$(MAN7_NO_ASCIIDOC_NAMES))
78 MAN = $(MAN1) $(MAN7)
79
80 if ENABLE_MAN_PAGES
81 # at this point, we know the user asked to build the man pages
82 if HAVE_ASCIIDOC_XMLTO
83 asciidoc_verbose = $(asciidoc_verbose_@AM_V@)
84 asciidoc_verbose_ = $(asciidoc_verbose_@AM_DEFAULT_V@)
85 asciidoc_verbose_0 = @echo " ASCIIDOC " $@;
86 xmlto_verbose = $(xmlto_verbose_@AM_V@)
87 xmlto_verbose_ = $(xmlto_verbose_@AM_DEFAULT_V@)
88 xmlto_verbose_0 = @echo " XMLTO " $@;
89
90 # tools
91 ADOC = $(asciidoc_verbose)$(ASCIIDOC) -f $(ASCIIDOC_CONF) -f $(ASCIIDOC_ATTRS_CONF) -d manpage
92 ADOC_DOCBOOK = $(ADOC) -b docbook
93 XTO = $(xmlto_verbose)$(XMLTO) -m $(XSL_SRC_FILE) man
94
95 # only add this dependency if we can build the man pages because it's
96 # a file generated by the configure script, so it's more recent than
97 # the pregenerated man pages in a tarball
98 COMMON_DEPS += $(ASCIIDOC_ATTRS_CONF)
99
100 # recipes
101 %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS)
102 $(ADOC_DOCBOOK) -o $@ $<
103
104 %.1: %.1.xml $(XSL_SRC_FILE)
105 $(XTO) $< 2>/dev/null
106
107 %.7.xml: $(srcdir)/%.7.txt $(COMMON_DEPS)
108 $(ADOC_DOCBOOK) -o $@ $<
109
110 %.7: %.7.xml $(XSL_SRC_FILE)
111 $(XTO) $< 2>/dev/null
112
113 # only clean the generated files if we have the tools to generate them again
114 CLEANFILES = $(MAN_XML) $(MAN)
115 else # HAVE_ASCIIDOC_XMLTO
116 # create man page targets used to stop the build if we want to
117 # build the man pages, but we don't have the necessary tools to do so
118 ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing."
119 ERR_MSG += "Make sure both tools are installed and run the configure script again."
120
121 %.1: $(srcdir)/%.1.txt $(COMMON_DEPS)
122 @echo $(ERR_MSG)
123 @false
124
125 %.7: $(srcdir)/%.7.txt $(COMMON_DEPS)
126 @echo $(ERR_MSG)
127 @false
128 endif # HAVE_ASCIIDOC_XMLTO
129 endif # ENABLE_MAN_PAGES
130
131 # those are always installed since they are directly written in troff
132 dist_man1_MANS = $(MAN1_NO_ASCIIDOC)
133 dist_man7_MANS = $(MAN7_NO_ASCIIDOC)
134
135 if ENABLE_MAN_PAGES
136 # building man pages: we can install and distribute them
137 dist_man1_MANS += $(MAN1)
138 dist_man7_MANS += $(MAN7)
139 endif # ENABLE_MAN_PAGES
140
141 if !ENABLE_MAN_PAGES
142 dist-hook:
143 @echo "Error: Please enable the man pages before creating a distribution tarball."
144 @false
145 endif # !ENABLE_MAN_PAGES
146
147 # always distribute the source files
148 EXTRA_DIST = README.adoc $(MAN_TXT) $(COMMON_TXT) $(XSL_SRC_FILE) \
149 $(ASCIIDOC_CONF) $(ASCIIDOC_ATTRS_CONF).in
This page took 0.033326 seconds and 5 git commands to generate.