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