Makefile 9.0 KB

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