| 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 \ |
| 11 | lttng-create \ |
| 12 | lttng-destroy \ |
| 13 | lttng-set-session \ |
| 14 | lttng-save \ |
| 15 | lttng-load \ |
| 16 | lttng-start \ |
| 17 | lttng-stop \ |
| 18 | lttng-version \ |
| 19 | lttng-view \ |
| 20 | lttng-enable-channel \ |
| 21 | lttng-disable-channel \ |
| 22 | lttng-add-context \ |
| 23 | lttng-list \ |
| 24 | lttng-track \ |
| 25 | lttng-untrack \ |
| 26 | lttng-status \ |
| 27 | lttng-help \ |
| 28 | lttng-snapshot \ |
| 29 | lttng-enable-event \ |
| 30 | lttng-disable-event \ |
| 31 | lttng-crash \ |
| 32 | lttng-metadata \ |
| 33 | lttng-regenerate \ |
| 34 | lttng-rotate \ |
| 35 | lttng-enable-rotation \ |
| 36 | lttng-disable-rotation |
| 37 | MAN3_NAMES = |
| 38 | MAN8_NAMES = lttng-sessiond lttng-relayd |
| 39 | MAN1_NO_ASCIIDOC_NAMES = |
| 40 | MAN3_NO_ASCIIDOC_NAMES = lttng-health-check |
| 41 | MAN8_NO_ASCIIDOC_NAMES = |
| 42 | |
| 43 | # AsciiDoc sources and outputs |
| 44 | MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES)) |
| 45 | MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES)) |
| 46 | MAN8_TXT = $(call manaddsuffix,.8.txt,$(MAN8_NAMES)) |
| 47 | MAN_TXT = $(MAN1_TXT) $(MAN3_TXT) $(MAN8_TXT) |
| 48 | MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT)) |
| 49 | |
| 50 | # common AsciiDoc source files |
| 51 | COMMON_TXT = \ |
| 52 | $(srcdir)/common-footer.txt \ |
| 53 | $(srcdir)/common-cmd-footer.txt \ |
| 54 | $(srcdir)/common-cmd-options-head.txt \ |
| 55 | $(srcdir)/common-cmd-help-options.txt |
| 56 | |
| 57 | # config |
| 58 | ASCIIDOC_CONF = $(srcdir)/asciidoc.conf |
| 59 | ASCIIDOC_ATTRS_CONF = $(builddir)/asciidoc-attrs.conf |
| 60 | XSL_FILE = $(srcdir)/manpage.xsl |
| 61 | |
| 62 | # common dependencies |
| 63 | COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT) |
| 64 | |
| 65 | # man pages destinations |
| 66 | MAN1 = $(addsuffix .1,$(MAN1_NAMES)) |
| 67 | MAN3 = $(addsuffix .3,$(MAN3_NAMES)) |
| 68 | MAN8 = $(addsuffix .8,$(MAN8_NAMES)) |
| 69 | MAN1_NO_ASCIIDOC = $(addsuffix .1,$(MAN1_NO_ASCIIDOC_NAMES)) |
| 70 | MAN3_NO_ASCIIDOC = $(addsuffix .3,$(MAN3_NO_ASCIIDOC_NAMES)) |
| 71 | MAN8_NO_ASCIIDOC = $(addsuffix .8,$(MAN8_NO_ASCIIDOC_NAMES)) |
| 72 | MAN = $(MAN1) $(MAN3) $(MAN8) |
| 73 | |
| 74 | # initially empty |
| 75 | CLEANFILES = |
| 76 | |
| 77 | if EMBED_HELP |
| 78 | mantoh_verbose = $(mantoh_verbose_@AM_V@) |
| 79 | mantoh_verbose_ = $(mantoh_verbose_@AM_DEFAULT_V@) |
| 80 | mantoh_verbose_0 = @echo " MANTOH " $@; |
| 81 | |
| 82 | MAN1_H = $(addsuffix .1.h,$(MAN1_NAMES)) |
| 83 | MAN3_H = $(addsuffix .3.h,$(MAN3_NAMES)) |
| 84 | MAN8_H = $(addsuffix .8.h,$(MAN8_NAMES)) |
| 85 | MAN_H = $(MAN1_H) $(MAN3_H) $(MAN8_H) |
| 86 | MAN_H_RECIPE = \ |
| 87 | $(mantoh_verbose_0)\ |
| 88 | MANWIDTH=80 @MANPROG@ --encoding=UTF-8 --no-hyphenation --no-justification --local-file $< > $@ ; \ |
| 89 | $(SED) -i 's/\\/\\\\/g' $@ ; \ |
| 90 | $(SED) -i 's/"/\\"/g' $@ ; \ |
| 91 | $(SED) -i 's/^\(.*\)$$/"\1\\n"/' $@ |
| 92 | |
| 93 | %.1.h: %.1 |
| 94 | $(MAN_H_RECIPE) |
| 95 | |
| 96 | %.3.h: %.3 |
| 97 | $(MAN_H_RECIPE) |
| 98 | |
| 99 | %.8.h: %.8 |
| 100 | $(MAN_H_RECIPE) |
| 101 | |
| 102 | all-local: $(MAN_H) |
| 103 | |
| 104 | CLEANFILES += $(MAN_H) |
| 105 | endif # EMBED_HELP |
| 106 | |
| 107 | if MAN_PAGES_OPT |
| 108 | # at this point, we know the user asked to build the man pages |
| 109 | if HAVE_ASCIIDOC_XMLTO |
| 110 | |
| 111 | asciidoc_verbose = $(asciidoc_verbose_@AM_V@) |
| 112 | asciidoc_verbose_ = $(asciidoc_verbose_@AM_DEFAULT_V@) |
| 113 | asciidoc_verbose_0 = @echo " ASCIIDOC " $@; |
| 114 | |
| 115 | xmlto_verbose = $(xmlto_verbose_@AM_V@) |
| 116 | xmlto_verbose_ = $(xmlto_verbose_@AM_DEFAULT_V@) |
| 117 | xmlto_verbose_0 = @echo " XMLTO " $@; |
| 118 | |
| 119 | # tools |
| 120 | ADOC = $(asciidoc_verbose)$(ASCIIDOC) -f $(ASCIIDOC_CONF) -f $(ASCIIDOC_ATTRS_CONF) -d manpage |
| 121 | ADOC_DOCBOOK = $(ADOC) -b docbook |
| 122 | XTO = $(xmlto_verbose)$(XMLTO) -m $(XSL_FILE) man |
| 123 | |
| 124 | # only add this dependency if we can build the man pages because it's |
| 125 | # a file generated by the configure script, so it's more recent than |
| 126 | # the pregenerated man pages in a tarball |
| 127 | COMMON_DEPS += $(ASCIIDOC_ATTRS_CONF) |
| 128 | |
| 129 | # recipes |
| 130 | %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS) |
| 131 | $(ADOC_DOCBOOK) -o $@ $< |
| 132 | |
| 133 | %.1: %.1.xml $(XSL_FILE) |
| 134 | $(XTO) $< 2>/dev/null |
| 135 | |
| 136 | %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS) |
| 137 | $(ADOC_DOCBOOK) -o $@ $< |
| 138 | |
| 139 | %.3: %.3.xml $(XSL_FILE) |
| 140 | $(XTO) $< 2>/dev/null |
| 141 | |
| 142 | %.8.xml: $(srcdir)/%.8.txt $(COMMON_DEPS) |
| 143 | $(ADOC_DOCBOOK) -o $@ $< |
| 144 | |
| 145 | %.8: %.8.xml $(XSL_FILE) |
| 146 | $(XTO) $< 2>/dev/null |
| 147 | |
| 148 | # only clean the generated files if we have the tools to generate them again |
| 149 | CLEANFILES += $(MAN_XML) $(MAN) |
| 150 | else # HAVE_ASCIIDOC_XMLTO |
| 151 | # create man page targets used to stop the build if we want to |
| 152 | # build the man pages, but we don't have the necessary tools to do so |
| 153 | ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing." |
| 154 | ERR_MSG += "Make sure both tools are installed and run the configure script again." |
| 155 | |
| 156 | %.1: $(srcdir)/%.1.txt $(COMMON_DEPS) |
| 157 | @echo $(ERR_MSG) |
| 158 | @false |
| 159 | |
| 160 | %.3: $(srcdir)/%.3.txt $(COMMON_DEPS) |
| 161 | @echo $(ERR_MSG) |
| 162 | @false |
| 163 | |
| 164 | %.8: $(srcdir)/%.8.txt $(COMMON_DEPS) |
| 165 | @echo $(ERR_MSG) |
| 166 | @false |
| 167 | endif # HAVE_ASCIIDOC_XMLTO |
| 168 | endif # MAN_PAGES_OPT |
| 169 | |
| 170 | # those are always installed since they are directly written in troff |
| 171 | dist_man1_MANS = $(MAN1_NO_ASCIIDOC) |
| 172 | dist_man3_MANS = $(MAN3_NO_ASCIIDOC) |
| 173 | dist_man8_MANS = $(MAN8_NO_ASCIIDOC) |
| 174 | |
| 175 | if MAN_PAGES_OPT |
| 176 | # building man pages: we can install and distribute them |
| 177 | dist_man1_MANS += $(MAN1) |
| 178 | dist_man3_MANS += $(MAN3) |
| 179 | dist_man8_MANS += $(MAN8) |
| 180 | endif # MAN_PAGES_OPT |
| 181 | |
| 182 | if !MAN_PAGES_OPT |
| 183 | dist-hook: |
| 184 | @echo "Error: Please enable the man pages before creating a distribution tarball." |
| 185 | @false |
| 186 | endif # !MAN_PAGES_OPT |
| 187 | |
| 188 | # always distribute the source files |
| 189 | EXTRA_DIST = $(MAN_TXT) $(COMMON_TXT) $(XSL_FILE) \ |
| 190 | $(ASCIIDOC_CONF) $(ASCIIDOC_ATTRS_CONF).in |
| 191 | |
| 192 | # keep generated man pages that can be considered intermediate files |
| 193 | .PRECIOUS: %.1 %.3 %.8 |