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