1 # SPDX-License-Identifier: GPL-2.0-only 2 include ../../scripts/Makefile.include 3 include ../../scripts/utilities.mak 4 5 ARTICLES = 6 # with their own formatting rules. 7 SP_ARTICLES = 8 9 MAN1_TXT= \ 10 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ 11 $(wildcard perf-*.txt)) \ 12 perf.txt 13 MAN5_TXT= 14 MAN7_TXT= 15 16 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT) 17 _MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT)) 18 _MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT)) 19 20 MAN_XML=$(addprefix $(OUTPUT),$(_MAN_XML)) 21 MAN_HTML=$(addprefix $(OUTPUT),$(_MAN_HTML)) 22 23 _DOC_HTML = $(_MAN_HTML) 24 _DOC_HTML+=$(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES)) 25 DOC_HTML=$(addprefix $(OUTPUT),$(_DOC_HTML)) 26 27 _DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT)) 28 _DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT)) 29 _DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT)) 30 31 DOC_MAN1=$(addprefix $(OUTPUT),$(_DOC_MAN1)) 32 DOC_MAN5=$(addprefix $(OUTPUT),$(_DOC_MAN5)) 33 DOC_MAN7=$(addprefix $(OUTPUT),$(_DOC_MAN7)) 34 35 # Make the path relative to DESTDIR, not prefix 36 ifndef DESTDIR 37 prefix?=$(HOME) 38 endif 39 bindir?=$(prefix)/bin 40 htmldir?=$(prefix)/share/doc/perf-doc 41 pdfdir?=$(prefix)/share/doc/perf-doc 42 mandir?=$(prefix)/share/man 43 man1dir=$(mandir)/man1 44 man5dir=$(mandir)/man5 45 man7dir=$(mandir)/man7 46 47 ASCIIDOC=asciidoc 48 ASCIIDOC_EXTRA += --unsafe -f asciidoc.conf 49 ASCIIDOC_HTML = xhtml11 50 MANPAGE_XSL = manpage-normal.xsl 51 XMLTO_EXTRA = 52 INSTALL?=install 53 RM ?= rm -f 54 DOC_REF = origin/man 55 HTML_REF = origin/html 56 57 ifdef USE_ASCIIDOCTOR 58 ASCIIDOC = asciidoctor 59 ASCIIDOC_EXTRA += -a compat-mode 60 ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions 61 ASCIIDOC_EXTRA += -a mansource="perf" -a manmanual="perf Manual" 62 ASCIIDOC_HTML = xhtml5 63 endif 64 65 infodir?=$(prefix)/share/info 66 MAKEINFO=makeinfo 67 INSTALL_INFO=install-info 68 DOCBOOK2X_TEXI=docbook2x-texi 69 DBLATEX=dblatex 70 XMLTO=xmlto 71 ifndef PERL_PATH 72 PERL_PATH = /usr/bin/perl 73 endif 74 75 -include ../config.mak.autogen 76 -include ../config.mak 77 78 _tmp_tool_path := $(call get-executable,$(ASCIIDOC)) 79 ifeq ($(_tmp_tool_path),) 80 missing_tools = $(ASCIIDOC) 81 endif 82 83 ifndef USE_ASCIIDOCTOR 84 _tmp_tool_path := $(call get-executable,$(XMLTO)) 85 ifeq ($(_tmp_tool_path),) 86 missing_tools += $(XMLTO) 87 endif 88 endif 89 90 # 91 # For asciidoc ... 92 # -7.1.2, no extra settings are needed. 93 # 8.0-, set ASCIIDOC8. 94 # 95 96 # 97 # For docbook-xsl ... 98 # -1.68.1, set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0) 99 # 1.69.0, no extra settings are needed? 100 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP? 101 # 1.71.1, no extra settings are needed? 102 # 1.72.0, set DOCBOOK_XSL_172. 103 # 1.73.0-, set ASCIIDOC_NO_ROFF 104 # 105 106 # 107 # If you had been using DOCBOOK_XSL_172 in an attempt to get rid 108 # of 'the ".ft C" problem' in your generated manpages, and you 109 # instead ended up with weird characters around callouts, try 110 # using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8). 111 # 112 113 ifdef ASCIIDOC8 114 ASCIIDOC_EXTRA += -a asciidoc7compatible 115 endif 116 ifdef DOCBOOK_XSL_172 117 ASCIIDOC_EXTRA += -a perf-asciidoc-no-roff 118 MANPAGE_XSL = manpage-1.72.xsl 119 else 120 ifdef ASCIIDOC_NO_ROFF 121 # docbook-xsl after 1.72 needs the regular XSL, but will not 122 # pass-thru raw roff codes from asciidoc.conf, so turn them off. 123 ASCIIDOC_EXTRA += -a perf-asciidoc-no-roff 124 endif 125 endif 126 ifdef MAN_BOLD_LITERAL 127 XMLTO_EXTRA += -m manpage-bold-literal.xsl 128 endif 129 ifdef DOCBOOK_SUPPRESS_SP 130 XMLTO_EXTRA += -m manpage-suppress-sp.xsl 131 endif 132 133 SHELL_PATH ?= $(SHELL) 134 # Shell quote; 135 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) 136 137 # 138 # Please note that there is a minor bug in asciidoc. 139 # The version after 6.0.3 _will_ include the patch found here: 140 # http://marc.theaimsgroup.com/?l=perf&m=111558757202243&w=2 141 # 142 # Until that version is released you may have to apply the patch 143 # yourself - yes, all 6 characters of it! 144 # 145 146 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir 147 QUIET_SUBDIR1 = 148 149 ifneq ($(findstring $(MAKEFLAGS),w),w) 150 PRINT_DIR = --no-print-directory 151 else # "make -w" 152 NO_SUBDIR = : 153 endif 154 155 ifneq ($(findstring $(MAKEFLAGS),s),s) 156 ifneq ($(V),1) 157 QUIET_ASCIIDOC = @echo ' ASCIIDOC '$@; 158 QUIET_XMLTO = @echo ' XMLTO '$@; 159 QUIET_DB2TEXI = @echo ' DB2TEXI '$@; 160 QUIET_MAKEINFO = @echo ' MAKEINFO '$@; 161 QUIET_DBLATEX = @echo ' DBLATEX '$@; 162 QUIET_XSLTPROC = @echo ' XSLTPROC '$@; 163 QUIET_GEN = @echo ' GEN '$@; 164 QUIET_STDERR = 2> /dev/null 165 QUIET_SUBDIR0 = +@subdir= 166 QUIET_SUBDIR1 = ;$(NO_SUBDIR) \ 167 echo ' SUBDIR ' $$subdir; \ 168 $(MAKE) $(PRINT_DIR) -C $$subdir 169 export V 170 endif 171 endif 172 173 all: html man info 174 175 html: $(DOC_HTML) 176 177 $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf 178 179 man: man1 man5 man7 180 man1: $(DOC_MAN1) 181 man5: $(DOC_MAN5) 182 man7: $(DOC_MAN7) 183 184 info: $(OUTPUT)perf.info $(OUTPUT)perfman.info 185 186 install: install-man 187 188 check-man-tools: 189 ifdef missing_tools 190 $(error "You need to install $(missing_tools) for man pages") 191 endif 192 193 do-install-man: man 194 $(call QUIET_INSTALL, Documentation-man) \ 195 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir); \ 196 # $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir); \ 197 # $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir); \ 198 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir); \ 199 # $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir); \ 200 # $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir) 201 202 install-man: check-man-tools man do-install-man 203 204 ifdef missing_tools 205 DO_INSTALL_MAN = $(warning Please install $(missing_tools) to have the man pages installed) 206 else 207 DO_INSTALL_MAN = do-install-man 208 endif 209 210 try-install-man: $(DO_INSTALL_MAN) 211 212 install-info: info 213 $(call QUIET_INSTALL, Documentation-info) \ 214 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir); \ 215 $(INSTALL) -m 644 $(OUTPUT)perf.info $(OUTPUT)perfman.info $(DESTDIR)$(infodir); \ 216 if test -r $(DESTDIR)$(infodir)/dir; then \ 217 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perf.info ;\ 218 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perfman.info ;\ 219 else \ 220 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \ 221 fi 222 223 #install-html: html 224 # '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir) 225 226 227 # 228 # Determine "include::" file references in asciidoc files. 229 # 230 $(OUTPUT)doc.dep : $(wildcard *.txt) build-docdep.perl 231 $(QUIET_GEN)$(RM) $@+ $@ && \ 232 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \ 233 mv $@+ $@ 234 235 -include $(OUTPUT)doc.dep 236 237 CLEAN_FILES = \ 238 $(MAN_XML) $(addsuffix +,$(MAN_XML)) \ 239 $(MAN_HTML) $(addsuffix +,$(MAN_HTML)) \ 240 $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7) \ 241 $(OUTPUT)*.texi $(OUTPUT)*.texi+ $(OUTPUT)*.texi++ \ 242 $(OUTPUT)perf.info $(OUTPUT)perfman.info $(OUTPUT)doc.dep \ 243 $(OUTPUT)technical/api-*.html $(OUTPUT)technical/api-index.txt 244 clean: 245 $(call QUIET_CLEAN, Documentation) $(RM) $(CLEAN_FILES) 246 247 $(MAN_HTML): $(OUTPUT)%.html : %.txt 248 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ 249 $(ASCIIDOC) -b $(ASCIIDOC_HTML) -d manpage \ 250 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \ 251 mv $@+ $@ 252 253 # Generate date from either KBUILD_BUILD_TIMESTAMP or git log of 254 # the doc input file 255 PERF_DATE = $(strip \ 256 $(if $(KBUILD_BUILD_TIMESTAMP), \ 257 $(shell date -u -d '$(KBUILD_BUILD_TIMESTAMP)' +%Y-%m-%d), \ 258 $(shell git log -1 --pretty="format:%cd" \ 259 --date=short --no-show-signature $<))) 260 261 ifdef USE_ASCIIDOCTOR 262 $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : %.txt 263 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ 264 $(ASCIIDOC) -b manpage -d manpage \ 265 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) \ 266 -adocdate=$(PERF_DATE) -o $@+ $< && \ 267 mv $@+ $@ 268 endif 269 270 $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml 271 $(QUIET_XMLTO)$(RM) $@ && \ 272 $(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< 273 274 $(OUTPUT)%.xml : %.txt 275 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ 276 $(ASCIIDOC) -b docbook -d manpage \ 277 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) \ 278 -aperf_date=$(PERF_DATE) -o $@+ $< && \ 279 mv $@+ $@ 280 281 XSLT = docbook.xsl 282 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css 283 284 $(OUTPUT)perfman.texi: $(MAN_XML) cat-texi.perl 285 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \ 286 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \ 287 --to-stdout $(xml) &&) true) > $@++ && \ 288 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \ 289 rm $@++ && \ 290 mv $@+ $@ 291 292 $(OUTPUT)perfman.info: $(OUTPUT)perfman.texi 293 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate -o $@ $*.texi 294 295 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml 296 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \ 297 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \ 298 mv $@+ $@ 299 300 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt 301 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b $(ASCIIDOC_HTML) $*.txt 302 303 WEBDOC_DEST = /pub/software/tools/perf/docs 304 305 # UNIMPLEMENTED 306 #install-webdoc : html 307 # '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST) 308 309 # quick-install: quick-install-man 310 311 # quick-install-man: 312 # '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir) 313 314 #quick-install-html: 315 # '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.