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