Makefile 9.6 KB

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