David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1 | include ../../../scripts/Makefile.include |
| 2 | include ../../../scripts/utilities.mak |
| 3 | |
| 4 | # This Makefile and manpage XSL files were taken from tools/perf/Documentation |
| 5 | # and modified for libtraceevent. |
| 6 | |
| 7 | MAN3_TXT= \ |
| 8 | $(wildcard libtraceevent-*.txt) \ |
| 9 | libtraceevent.txt |
| 10 | |
| 11 | MAN_TXT = $(MAN3_TXT) |
| 12 | _MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT)) |
| 13 | _MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT)) |
| 14 | _DOC_MAN3=$(patsubst %.txt,%.3,$(MAN3_TXT)) |
| 15 | |
| 16 | MAN_XML=$(addprefix $(OUTPUT),$(_MAN_XML)) |
| 17 | MAN_HTML=$(addprefix $(OUTPUT),$(_MAN_HTML)) |
| 18 | DOC_MAN3=$(addprefix $(OUTPUT),$(_DOC_MAN3)) |
| 19 | |
| 20 | # Make the path relative to DESTDIR, not prefix |
| 21 | ifndef DESTDIR |
| 22 | prefix?=$(HOME) |
| 23 | endif |
| 24 | bindir?=$(prefix)/bin |
| 25 | htmldir?=$(prefix)/share/doc/libtraceevent-doc |
| 26 | pdfdir?=$(prefix)/share/doc/libtraceevent-doc |
| 27 | mandir?=$(prefix)/share/man |
| 28 | man3dir=$(mandir)/man3 |
| 29 | |
| 30 | ASCIIDOC=asciidoc |
| 31 | ASCIIDOC_EXTRA = --unsafe -f asciidoc.conf |
| 32 | ASCIIDOC_HTML = xhtml11 |
| 33 | MANPAGE_XSL = manpage-normal.xsl |
| 34 | XMLTO_EXTRA = |
| 35 | INSTALL?=install |
| 36 | RM ?= rm -f |
| 37 | |
| 38 | ifdef USE_ASCIIDOCTOR |
| 39 | ASCIIDOC = asciidoctor |
| 40 | ASCIIDOC_EXTRA = -a compat-mode |
| 41 | ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions |
| 42 | ASCIIDOC_EXTRA += -a mansource="libtraceevent" -a manmanual="libtraceevent Manual" |
| 43 | ASCIIDOC_HTML = xhtml5 |
| 44 | endif |
| 45 | |
| 46 | XMLTO=xmlto |
| 47 | |
| 48 | _tmp_tool_path := $(call get-executable,$(ASCIIDOC)) |
| 49 | ifeq ($(_tmp_tool_path),) |
| 50 | missing_tools = $(ASCIIDOC) |
| 51 | endif |
| 52 | |
| 53 | ifndef USE_ASCIIDOCTOR |
| 54 | _tmp_tool_path := $(call get-executable,$(XMLTO)) |
| 55 | ifeq ($(_tmp_tool_path),) |
| 56 | missing_tools += $(XMLTO) |
| 57 | endif |
| 58 | endif |
| 59 | |
| 60 | # |
| 61 | # For asciidoc ... |
| 62 | # -7.1.2, no extra settings are needed. |
| 63 | # 8.0-, set ASCIIDOC8. |
| 64 | # |
| 65 | |
| 66 | # |
| 67 | # For docbook-xsl ... |
| 68 | # -1.68.1, set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0) |
| 69 | # 1.69.0, no extra settings are needed? |
| 70 | # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP? |
| 71 | # 1.71.1, no extra settings are needed? |
| 72 | # 1.72.0, set DOCBOOK_XSL_172. |
| 73 | # 1.73.0-, set ASCIIDOC_NO_ROFF |
| 74 | # |
| 75 | |
| 76 | # |
| 77 | # If you had been using DOCBOOK_XSL_172 in an attempt to get rid |
| 78 | # of 'the ".ft C" problem' in your generated manpages, and you |
| 79 | # instead ended up with weird characters around callouts, try |
| 80 | # using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8). |
| 81 | # |
| 82 | |
| 83 | ifdef ASCIIDOC8 |
| 84 | ASCIIDOC_EXTRA += -a asciidoc7compatible |
| 85 | endif |
| 86 | ifdef DOCBOOK_XSL_172 |
| 87 | ASCIIDOC_EXTRA += -a libtraceevent-asciidoc-no-roff |
| 88 | MANPAGE_XSL = manpage-1.72.xsl |
| 89 | else |
| 90 | ifdef ASCIIDOC_NO_ROFF |
| 91 | # docbook-xsl after 1.72 needs the regular XSL, but will not |
| 92 | # pass-thru raw roff codes from asciidoc.conf, so turn them off. |
| 93 | ASCIIDOC_EXTRA += -a libtraceevent-asciidoc-no-roff |
| 94 | endif |
| 95 | endif |
| 96 | ifdef MAN_BOLD_LITERAL |
| 97 | XMLTO_EXTRA += -m manpage-bold-literal.xsl |
| 98 | endif |
| 99 | ifdef DOCBOOK_SUPPRESS_SP |
| 100 | XMLTO_EXTRA += -m manpage-suppress-sp.xsl |
| 101 | endif |
| 102 | |
| 103 | SHELL_PATH ?= $(SHELL) |
| 104 | # Shell quote; |
| 105 | SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) |
| 106 | |
| 107 | DESTDIR ?= |
| 108 | DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' |
| 109 | |
| 110 | export DESTDIR DESTDIR_SQ |
| 111 | |
| 112 | # |
| 113 | # Please note that there is a minor bug in asciidoc. |
| 114 | # The version after 6.0.3 _will_ include the patch found here: |
| 115 | # http://marc.theaimsgroup.com/?l=libtraceevent&m=111558757202243&w=2 |
| 116 | # |
| 117 | # Until that version is released you may have to apply the patch |
| 118 | # yourself - yes, all 6 characters of it! |
| 119 | # |
| 120 | QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir |
| 121 | QUIET_SUBDIR1 = |
| 122 | |
| 123 | ifneq ($(findstring $(MAKEFLAGS),w),w) |
| 124 | PRINT_DIR = --no-print-directory |
| 125 | else # "make -w" |
| 126 | NO_SUBDIR = : |
| 127 | endif |
| 128 | |
| 129 | ifneq ($(findstring $(MAKEFLAGS),s),s) |
| 130 | ifneq ($(V),1) |
| 131 | QUIET_ASCIIDOC = @echo ' ASCIIDOC '$@; |
| 132 | QUIET_XMLTO = @echo ' XMLTO '$@; |
| 133 | QUIET_SUBDIR0 = +@subdir= |
| 134 | QUIET_SUBDIR1 = ;$(NO_SUBDIR) \ |
| 135 | echo ' SUBDIR ' $$subdir; \ |
| 136 | $(MAKE) $(PRINT_DIR) -C $$subdir |
| 137 | export V |
| 138 | endif |
| 139 | endif |
| 140 | |
| 141 | all: html man |
| 142 | |
| 143 | man: man3 |
| 144 | man3: $(DOC_MAN3) |
| 145 | |
| 146 | html: $(MAN_HTML) |
| 147 | |
| 148 | $(MAN_HTML) $(DOC_MAN3): asciidoc.conf |
| 149 | |
| 150 | install: install-man |
| 151 | |
| 152 | check-man-tools: |
| 153 | ifdef missing_tools |
| 154 | $(error "You need to install $(missing_tools) for man pages") |
| 155 | endif |
| 156 | |
| 157 | do-install-man: man |
| 158 | $(call QUIET_INSTALL, Documentation-man) \ |
| 159 | $(INSTALL) -d -m 755 $(DESTDIR)$(man3dir); \ |
| 160 | $(INSTALL) -m 644 $(DOC_MAN3) $(DESTDIR)$(man3dir); |
| 161 | |
| 162 | install-man: check-man-tools man do-install-man |
| 163 | |
| 164 | uninstall: uninstall-man |
| 165 | |
| 166 | uninstall-man: |
| 167 | $(call QUIET_UNINST, Documentation-man) \ |
| 168 | $(Q)$(RM) $(addprefix $(DESTDIR)$(man3dir)/,$(DOC_MAN3)) |
| 169 | |
| 170 | |
| 171 | ifdef missing_tools |
| 172 | DO_INSTALL_MAN = $(warning Please install $(missing_tools) to have the man pages installed) |
| 173 | else |
| 174 | DO_INSTALL_MAN = do-install-man |
| 175 | endif |
| 176 | |
| 177 | CLEAN_FILES = \ |
| 178 | $(MAN_XML) $(addsuffix +,$(MAN_XML)) \ |
| 179 | $(MAN_HTML) $(addsuffix +,$(MAN_HTML)) \ |
| 180 | $(DOC_MAN3) *.3 |
| 181 | |
| 182 | clean: |
| 183 | $(call QUIET_CLEAN, Documentation) $(RM) $(CLEAN_FILES) |
| 184 | |
| 185 | ifdef USE_ASCIIDOCTOR |
| 186 | $(OUTPUT)%.3 : $(OUTPUT)%.txt |
| 187 | $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ |
| 188 | $(ASCIIDOC) -b manpage -d manpage \ |
| 189 | $(ASCIIDOC_EXTRA) -alibtraceevent_version=$(EVENT_PARSE_VERSION) -o $@+ $< && \ |
| 190 | mv $@+ $@ |
| 191 | endif |
| 192 | |
| 193 | $(OUTPUT)%.3 : $(OUTPUT)%.xml |
| 194 | $(QUIET_XMLTO)$(RM) $@ && \ |
| 195 | $(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< |
| 196 | |
| 197 | $(OUTPUT)%.xml : %.txt |
| 198 | $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ |
| 199 | $(ASCIIDOC) -b docbook -d manpage \ |
| 200 | $(ASCIIDOC_EXTRA) -alibtraceevent_version=$(EVENT_PARSE_VERSION) -o $@+ $< && \ |
| 201 | mv $@+ $@ |
| 202 | |
| 203 | $(MAN_HTML): $(OUTPUT)%.html : %.txt |
| 204 | $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ |
| 205 | $(ASCIIDOC) -b $(ASCIIDOC_HTML) -d manpage \ |
| 206 | $(ASCIIDOC_EXTRA) -aperf_version=$(EVENT_PARSE_VERSION) -o $@+ $< && \ |
| 207 | mv $@+ $@ |