Makefile 10 KB

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