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