1# SPDX-License-Identifier: GPL-2.0-only 2include ../../scripts/Makefile.include 3include ../../scripts/utilities.mak 4 5ARTICLES = 6# with their own formatting rules. 7SP_ARTICLES = 8 9MAN1_TXT= \ 10 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ 11 $(wildcard perf-*.txt)) \ 12 perf.txt 13MAN5_TXT= 14MAN7_TXT= 15 16MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT) 17_MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT)) 18_MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT)) 19 20MAN_XML=$(addprefix $(OUTPUT),$(_MAN_XML)) 21MAN_HTML=$(addprefix $(OUTPUT),$(_MAN_HTML)) 22 23_DOC_HTML = $(_MAN_HTML) 24_DOC_HTML+=$(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES)) 25DOC_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 31DOC_MAN1=$(addprefix $(OUTPUT),$(_DOC_MAN1)) 32DOC_MAN5=$(addprefix $(OUTPUT),$(_DOC_MAN5)) 33DOC_MAN7=$(addprefix $(OUTPUT),$(_DOC_MAN7)) 34 35# Make the path relative to DESTDIR, not prefix 36ifndef DESTDIR 37prefix?=$(HOME) 38endif 39bindir?=$(prefix)/bin 40htmldir?=$(prefix)/share/doc/perf-doc 41pdfdir?=$(prefix)/share/doc/perf-doc 42mandir?=$(prefix)/share/man 43man1dir=$(mandir)/man1 44man5dir=$(mandir)/man5 45man7dir=$(mandir)/man7 46 47ASCIIDOC=asciidoc 48ASCIIDOC_EXTRA += --unsafe -f asciidoc.conf 49ASCIIDOC_HTML = xhtml11 50MANPAGE_XSL = manpage-normal.xsl 51XMLTO_EXTRA = 52INSTALL?=install 53RM ?= rm -f 54DOC_REF = origin/man 55HTML_REF = origin/html 56 57ifdef USE_ASCIIDOCTOR 58ASCIIDOC = asciidoctor 59ASCIIDOC_EXTRA += -a compat-mode 60ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions 61ASCIIDOC_EXTRA += -a mansource="perf" -a manmanual="perf Manual" 62ASCIIDOC_HTML = xhtml5 63endif 64 65infodir?=$(prefix)/share/info 66MAKEINFO=makeinfo 67INSTALL_INFO=install-info 68DOCBOOK2X_TEXI=docbook2x-texi 69DBLATEX=dblatex 70XMLTO=xmlto 71ifndef PERL_PATH 72 PERL_PATH = /usr/bin/perl 73endif 74 75-include ../config.mak.autogen 76-include ../config.mak 77 78_tmp_tool_path := $(call get-executable,$(ASCIIDOC)) 79ifeq ($(_tmp_tool_path),) 80 missing_tools = $(ASCIIDOC) 81endif 82 83ifndef USE_ASCIIDOCTOR 84_tmp_tool_path := $(call get-executable,$(XMLTO)) 85ifeq ($(_tmp_tool_path),) 86 missing_tools += $(XMLTO) 87endif 88endif 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 113ifdef ASCIIDOC8 114ASCIIDOC_EXTRA += -a asciidoc7compatible 115endif 116ifdef DOCBOOK_XSL_172 117ASCIIDOC_EXTRA += -a perf-asciidoc-no-roff 118MANPAGE_XSL = manpage-1.72.xsl 119else 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 125endif 126ifdef MAN_BOLD_LITERAL 127XMLTO_EXTRA += -m manpage-bold-literal.xsl 128endif 129ifdef DOCBOOK_SUPPRESS_SP 130XMLTO_EXTRA += -m manpage-suppress-sp.xsl 131endif 132 133SHELL_PATH ?= $(SHELL) 134# Shell quote; 135SHELL_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 146QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir 147QUIET_SUBDIR1 = 148 149ifneq ($(findstring $(MAKEFLAGS),w),w) 150PRINT_DIR = --no-print-directory 151else # "make -w" 152NO_SUBDIR = : 153endif 154 155ifneq ($(findstring $(MAKEFLAGS),s),s) 156ifneq ($(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 170endif 171endif 172 173all: html man info 174 175html: $(DOC_HTML) 176 177$(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf 178 179man: man1 man5 man7 180man1: $(DOC_MAN1) 181man5: $(DOC_MAN5) 182man7: $(DOC_MAN7) 183 184info: $(OUTPUT)perf.info $(OUTPUT)perfman.info 185 186install: install-man 187 188check-man-tools: 189ifdef missing_tools 190 $(error "You need to install $(missing_tools) for man pages") 191endif 192 193do-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 202install-man: check-man-tools man do-install-man 203 204ifdef missing_tools 205 DO_INSTALL_MAN = $(warning Please install $(missing_tools) to have the man pages installed) 206else 207 DO_INSTALL_MAN = do-install-man 208endif 209 210try-install-man: $(DO_INSTALL_MAN) 211 212install-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 237CLEAN_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 244clean: 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 255PERF_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 261ifdef 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 $@+ $@ 268endif 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 281XSLT = docbook.xsl 282XSLTOPTS = --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 303WEBDOC_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) 316