Add modern Babeltrace man pages
[babeltrace.git] / doc / man / Makefile.am
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
new file mode 100644 (file)
index 0000000..4c22e63
--- /dev/null
@@ -0,0 +1,146 @@
+# Man pages are only built if they are enabled at configure time.
+#
+# They should always be built before creating a distribution tarball.
+
+# function which adds the source directory prefix and adds a given suffix
+manaddsuffix = $(addsuffix $(1),$(addprefix $(srcdir)/,$(2)))
+
+# List only the names without the .*.txt extension here:
+MAN1_NAMES = \
+       babeltrace \
+       babeltrace-convert \
+       babeltrace-help \
+       babeltrace-list-plugins \
+       babeltrace-log \
+       babeltrace-query \
+       babeltrace-run
+MAN7_NAMES =
+MAN1_NO_ASCIIDOC_NAMES =
+MAN7_NO_ASCIIDOC_NAMES = \
+       babeltrace-filter.utils.muxer \
+       babeltrace-filter.utils.trimmer \
+       babeltrace-intro \
+       babeltrace-plugin-ctf \
+       babeltrace-plugin-text \
+       babeltrace-plugin-utils \
+       babeltrace-sink.ctf.fs \
+       babeltrace-sink.text.pretty \
+       babeltrace-sink.utils.counter \
+       babeltrace-sink.utils.dummy \
+       babeltrace-source.ctf.fs \
+       babeltrace-source.ctf.lttng-live \
+       babeltrace-source.text.dmesg
+
+if ENABLE_DEBUG_INFO
+MAN7_NO_ASCIIDOC_NAMES += \
+       babeltrace-plugin-lttng-utils \
+       babeltrace-filter.lttng-utils.debug-info
+endif
+
+# AsciiDoc sources and outputs
+MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES))
+MAN7_TXT = $(call manaddsuffix,.7.txt,$(MAN7_NAMES))
+MAN_TXT = $(MAN1_TXT) $(MAN7_TXT)
+MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT))
+
+# common AsciiDoc source files
+COMMON_TXT = \
+       $(srcdir)/common-cli-env.txt \
+       $(srcdir)/common-cli-files.txt \
+       $(srcdir)/common-cmd-footer.txt \
+       $(srcdir)/common-cmd-info-options.txt \
+       $(srcdir)/common-cmd-params-format.txt \
+       $(srcdir)/common-cmd-plugin-path.txt \
+       $(srcdir)/common-common-compat-env.txt \
+       $(srcdir)/common-ctf-plugin-env.txt \
+       $(srcdir)/common-footer.txt \
+       $(srcdir)/common-gen-options.txt \
+       $(srcdir)/common-lib-env.txt \
+       $(srcdir)/common-plugin-path-options.txt \
+       $(srcdir)/common-ppp-env.txt
+
+# config
+ASCIIDOC_CONF = $(srcdir)/bt-asciidoc.conf
+ASCIIDOC_ATTRS_CONF = $(builddir)/asciidoc-attrs.conf
+XSL_SRC_FILE = $(srcdir)/manpage.xsl
+
+# common dependencies
+COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT)
+
+# man pages destinations
+MAN1 = $(addsuffix .1,$(MAN1_NAMES))
+MAN7 = $(addsuffix .7,$(MAN7_NAMES))
+MAN1_NO_ASCIIDOC = $(addsuffix .1,$(MAN1_NO_ASCIIDOC_NAMES))
+MAN7_NO_ASCIIDOC = $(addsuffix .7,$(MAN7_NO_ASCIIDOC_NAMES))
+MAN = $(MAN1) $(MAN7)
+
+if ENABLE_MAN_PAGES
+# at this point, we know the user asked to build the man pages
+if HAVE_ASCIIDOC_XMLTO
+asciidoc_verbose = $(asciidoc_verbose_@AM_V@)
+asciidoc_verbose_ = $(asciidoc_verbose_@AM_DEFAULT_V@)
+asciidoc_verbose_0 = @echo "  ASCIIDOC  " $@;
+xmlto_verbose = $(xmlto_verbose_@AM_V@)
+xmlto_verbose_ = $(xmlto_verbose_@AM_DEFAULT_V@)
+xmlto_verbose_0 = @echo "  XMLTO     " $@;
+
+# tools
+ADOC = $(asciidoc_verbose)$(ASCIIDOC) -f $(ASCIIDOC_CONF) -f $(ASCIIDOC_ATTRS_CONF) -d manpage
+ADOC_DOCBOOK = $(ADOC) -b docbook
+XTO = $(xmlto_verbose)$(XMLTO) -m $(XSL_SRC_FILE) man
+
+# only add this dependency if we can build the man pages because it's
+# a file generated by the configure script, so it's more recent than
+# the pregenerated man pages in a tarball
+COMMON_DEPS += $(ASCIIDOC_ATTRS_CONF)
+
+# recipes
+%.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS)
+       $(ADOC_DOCBOOK) -o $@ $<
+
+%.1: %.1.xml $(XSL_SRC_FILE)
+       $(XTO) $< 2>/dev/null
+
+%.7.xml: $(srcdir)/%.7.txt $(COMMON_DEPS)
+       $(ADOC_DOCBOOK) -o $@ $<
+
+%.7: %.7.xml $(XSL_SRC_FILE)
+       $(XTO) $< 2>/dev/null
+
+# only clean the generated files if we have the tools to generate them again
+CLEANFILES = $(MAN_XML) $(MAN)
+else # HAVE_ASCIIDOC_XMLTO
+# create man page targets used to stop the build if we want to
+# build the man pages, but we don't have the necessary tools to do so
+ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing."
+ERR_MSG += "Make sure both tools are installed and run the configure script again."
+
+%.1: $(srcdir)/%.1.txt $(COMMON_DEPS)
+       @echo $(ERR_MSG)
+       @false
+
+%.7: $(srcdir)/%.7.txt $(COMMON_DEPS)
+       @echo $(ERR_MSG)
+       @false
+endif # HAVE_ASCIIDOC_XMLTO
+endif # ENABLE_MAN_PAGES
+
+# those are always installed since they are directly written in troff
+dist_man1_MANS = $(MAN1_NO_ASCIIDOC)
+dist_man7_MANS = $(MAN7_NO_ASCIIDOC)
+
+if ENABLE_MAN_PAGES
+# building man pages: we can install and distribute them
+dist_man1_MANS += $(MAN1)
+dist_man7_MANS += $(MAN7)
+endif # ENABLE_MAN_PAGES
+
+if !ENABLE_MAN_PAGES
+dist-hook:
+       @echo "Error: Please enable the man pages before creating a distribution tarball."
+       @false
+endif # !ENABLE_MAN_PAGES
+
+# always distribute the source files
+EXTRA_DIST = README.adoc $(MAN_TXT) $(COMMON_TXT) $(XSL_SRC_FILE) \
+       $(ASCIIDOC_CONF) $(ASCIIDOC_ATTRS_CONF).in
This page took 0.024159 seconds and 4 git commands to generate.