| 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 | lttng-gen-tp |
| 11 | MAN3_NAMES = \ |
| 12 | lttng-ust \ |
| 13 | tracef \ |
| 14 | tracelog \ |
| 15 | lttng-ust-dl \ |
| 16 | lttng-ust-cyg-profile |
| 17 | |
| 18 | # troff man pages: |
| 19 | MAN3_TROFF = do_tracepoint.3 tracepoint.3 tracepoint_enabled.3 |
| 20 | |
| 21 | # AsciiDoc sources and outputs: |
| 22 | MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES)) |
| 23 | MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES)) |
| 24 | MAN_TXT = $(MAN1_TXT) $(MAN3_TXT) $(MAN8_TXT) |
| 25 | MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT)) |
| 26 | |
| 27 | # Common AsciiDoc source files: |
| 28 | COMMON_TXT = \ |
| 29 | $(srcdir)/common-footer.txt \ |
| 30 | $(srcdir)/common-authors.txt \ |
| 31 | $(srcdir)/common-copyrights.txt \ |
| 32 | $(srcdir)/log-levels.txt \ |
| 33 | $(srcdir)/tracef-tracelog-limitations.txt |
| 34 | |
| 35 | # AsciiDoc configuration and XSL files: |
| 36 | ASCIIDOC_CONF = $(srcdir)/asciidoc.conf |
| 37 | XSL_FILES = \ |
| 38 | manpage.xsl \ |
| 39 | manpage-callouts.xsl \ |
| 40 | manpage-bold-literal.xsl \ |
| 41 | manpage-links.xsl \ |
| 42 | manpage-headings.xsl |
| 43 | XSL_SRC_FILES = $(addprefix $(srcdir)/xsl/,$(XSL_FILES)) |
| 44 | |
| 45 | # Common dependencies: |
| 46 | COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT) |
| 47 | |
| 48 | # Man pages destinations: |
| 49 | MAN1 = $(addsuffix .1,$(MAN1_NAMES)) |
| 50 | MAN3 = $(addsuffix .3,$(MAN3_NAMES)) |
| 51 | MAN = $(MAN1) $(MAN3) |
| 52 | |
| 53 | if MAN_PAGES_OPT |
| 54 | # At this point, we know the user asked to build the man pages. |
| 55 | if HAVE_ASCIIDOC_XMLTO |
| 56 | # Tools to execute: |
| 57 | ADOC = $(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \ |
| 58 | -a lttng_version="$(PACKAGE_VERSION)" \ |
| 59 | -a lttng_ust_register_timeout="@LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS@" |
| 60 | ADOC_DOCBOOK = $(ADOC) -b docbook |
| 61 | XTO = $(XMLTO) -m $(firstword $(XSL_SRC_FILES)) man |
| 62 | |
| 63 | # Recipes: |
| 64 | %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS) |
| 65 | $(ADOC_DOCBOOK) -o $@ $< |
| 66 | |
| 67 | %.1: %.1.xml $(XSL_SRC_FILES) |
| 68 | $(XTO) $< |
| 69 | |
| 70 | %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS) |
| 71 | $(ADOC_DOCBOOK) -o $@ $< |
| 72 | |
| 73 | %.3: %.3.xml $(XSL_SRC_FILES) |
| 74 | $(XTO) $< |
| 75 | |
| 76 | # Only clean the generated files if we have the tools to generate them again. |
| 77 | CLEANFILES = $(MAN_XML) $(MAN) |
| 78 | else # HAVE_ASCIIDOC_XMLTO |
| 79 | # Create man page targets used to stop the build if we want to |
| 80 | # build the man pages, but we don't have the necessary tools to do so. |
| 81 | ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing." |
| 82 | ERR_MSG += "Make sure both tools are installed and run the configure script again." |
| 83 | |
| 84 | %.1: $(srcdir)/%.1.txt $(COMMON_DEPS) |
| 85 | @echo $(ERR_MSG) |
| 86 | @false |
| 87 | |
| 88 | %.3: $(srcdir)/%.3.txt $(COMMON_DEPS) |
| 89 | @echo $(ERR_MSG) |
| 90 | @false |
| 91 | endif # HAVE_ASCIIDOC_XMLTO |
| 92 | endif # MAN_PAGES_OPT |
| 93 | |
| 94 | # Start with empty distributed/installed man pages: |
| 95 | dist_man1_MANS = |
| 96 | dist_man3_MANS = |
| 97 | EXTRA_DIST = |
| 98 | |
| 99 | if MAN_PAGES_OPT |
| 100 | # Building man pages: we can install and distribute them. |
| 101 | dist_man1_MANS += $(MAN1) |
| 102 | dist_man3_MANS += $(MAN3) $(MAN3_TROFF) |
| 103 | else # MAN_PAGES_OPT |
| 104 | # Those are not known by automake yet because dist_man3_MANS is empty |
| 105 | # at this point, so make sure they are distributed. |
| 106 | EXTRA_DIST += $(MAN3_TROFF) |
| 107 | endif # MAN_PAGES_OPT |
| 108 | |
| 109 | if !MAN_PAGES_OPT |
| 110 | dist-hook: |
| 111 | @echo "Error: Please enable the man pages before creating a distribution tarball." |
| 112 | @false |
| 113 | endif # !MAN_PAGES_OPT |
| 114 | |
| 115 | # Always distribute the source files. |
| 116 | EXTRA_DIST += $(MAN_TXT) $(COMMON_TXT) $(XSL_SRC_FILES) $(ASCIIDOC_CONF) |