PageRenderTime 37ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/Documentation/DocBook/Makefile

https://bitbucket.org/abioy/linux
Makefile | 250 lines | 165 code | 42 blank | 43 comment | 15 complexity | 578ab441a4e7cbc851c24bb51f887086 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, GPL-2.0, LGPL-2.0, AGPL-1.0
  1. ###
  2. # This makefile is used to generate the kernel documentation,
  3. # primarily based on in-line comments in various source files.
  4. # See Documentation/kernel-doc-nano-HOWTO.txt for instruction in how
  5. # to document the SRC - and how to read it.
  6. # To add a new book the only step required is to add the book to the
  7. # list of DOCBOOKS.
  8. DOCBOOKS := z8530book.xml mcabook.xml device-drivers.xml \
  9. kernel-hacking.xml kernel-locking.xml deviceiobook.xml \
  10. writing_usb_driver.xml networking.xml \
  11. kernel-api.xml filesystems.xml lsm.xml usb.xml kgdb.xml \
  12. gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
  13. genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \
  14. mac80211.xml debugobjects.xml sh.xml regulator.xml \
  15. alsa-driver-api.xml writing-an-alsa-driver.xml \
  16. tracepoint.xml media.xml
  17. ###
  18. # The build process is as follows (targets):
  19. # (xmldocs) [by docproc]
  20. # file.tmpl --> file.xml +--> file.ps (psdocs) [by db2ps or xmlto]
  21. # +--> file.pdf (pdfdocs) [by db2pdf or xmlto]
  22. # +--> DIR=file (htmldocs) [by xmlto]
  23. # +--> man/ (mandocs) [by xmlto]
  24. # for PDF and PS output you can choose between xmlto and docbook-utils tools
  25. PDF_METHOD = $(prefer-db2x)
  26. PS_METHOD = $(prefer-db2x)
  27. ###
  28. # The targets that may be used.
  29. PHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs cleandocs xmldoclinks
  30. BOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
  31. xmldocs: $(BOOKS) xmldoclinks
  32. sgmldocs: xmldocs
  33. PS := $(patsubst %.xml, %.ps, $(BOOKS))
  34. psdocs: $(PS)
  35. PDF := $(patsubst %.xml, %.pdf, $(BOOKS))
  36. pdfdocs: $(PDF)
  37. HTML := $(sort $(patsubst %.xml, %.html, $(BOOKS)))
  38. htmldocs: $(HTML)
  39. $(call build_main_index)
  40. $(call build_images)
  41. MAN := $(patsubst %.xml, %.9, $(BOOKS))
  42. mandocs: $(MAN)
  43. build_images = mkdir -p $(objtree)/Documentation/DocBook/media/ && \
  44. cp $(srctree)/Documentation/DocBook/dvb/*.png $(srctree)/Documentation/DocBook/v4l/*.gif $(objtree)/Documentation/DocBook/media/
  45. xmldoclinks:
  46. ifneq ($(objtree),$(srctree))
  47. for dep in dvb media-entities.tmpl media-indices.tmpl v4l; do \
  48. rm -f $(objtree)/Documentation/DocBook/$$dep \
  49. && ln -s $(srctree)/Documentation/DocBook/$$dep $(objtree)/Documentation/DocBook/ \
  50. || exit; \
  51. done
  52. endif
  53. installmandocs: mandocs
  54. mkdir -p /usr/local/man/man9/
  55. install Documentation/DocBook/man/*.9.gz /usr/local/man/man9/
  56. ###
  57. #External programs used
  58. KERNELDOC = $(srctree)/scripts/kernel-doc
  59. DOCPROC = $(objtree)/scripts/basic/docproc
  60. XMLTOFLAGS = -m $(srctree)/Documentation/DocBook/stylesheet.xsl
  61. XMLTOFLAGS += --skip-validation
  62. ###
  63. # DOCPROC is used for two purposes:
  64. # 1) To generate a dependency list for a .tmpl file
  65. # 2) To preprocess a .tmpl file and call kernel-doc with
  66. # appropriate parameters.
  67. # The following rules are used to generate the .xml documentation
  68. # required to generate the final targets. (ps, pdf, html).
  69. quiet_cmd_docproc = DOCPROC $@
  70. cmd_docproc = SRCTREE=$(srctree)/ $(DOCPROC) doc $< >$@
  71. define rule_docproc
  72. set -e; \
  73. $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \
  74. $(cmd_$(1)); \
  75. ( \
  76. echo 'cmd_$@ := $(cmd_$(1))'; \
  77. echo $@: `SRCTREE=$(srctree) $(DOCPROC) depend $<`; \
  78. ) > $(dir $@).$(notdir $@).cmd
  79. endef
  80. %.xml: %.tmpl FORCE
  81. $(call if_changed_rule,docproc)
  82. ###
  83. #Read in all saved dependency files
  84. cmd_files := $(wildcard $(foreach f,$(BOOKS),$(dir $(f)).$(notdir $(f)).cmd))
  85. ifneq ($(cmd_files),)
  86. include $(cmd_files)
  87. endif
  88. ###
  89. # Changes in kernel-doc force a rebuild of all documentation
  90. $(BOOKS): $(KERNELDOC)
  91. # Tell kbuild to always build the programs
  92. always := $(hostprogs-y)
  93. notfoundtemplate = echo "*** You have to install docbook-utils or xmlto ***"; \
  94. exit 1
  95. db2xtemplate = db2TYPE -o $(dir $@) $<
  96. xmltotemplate = xmlto TYPE $(XMLTOFLAGS) -o $(dir $@) $<
  97. # determine which methods are available
  98. ifeq ($(shell which db2ps >/dev/null 2>&1 && echo found),found)
  99. use-db2x = db2x
  100. prefer-db2x = db2x
  101. else
  102. use-db2x = notfound
  103. prefer-db2x = $(use-xmlto)
  104. endif
  105. ifeq ($(shell which xmlto >/dev/null 2>&1 && echo found),found)
  106. use-xmlto = xmlto
  107. prefer-xmlto = xmlto
  108. else
  109. use-xmlto = notfound
  110. prefer-xmlto = $(use-db2x)
  111. endif
  112. # the commands, generated from the chosen template
  113. quiet_cmd_db2ps = PS $@
  114. cmd_db2ps = $(subst TYPE,ps, $($(PS_METHOD)template))
  115. %.ps : %.xml
  116. $(call cmd,db2ps)
  117. quiet_cmd_db2pdf = PDF $@
  118. cmd_db2pdf = $(subst TYPE,pdf, $($(PDF_METHOD)template))
  119. %.pdf : %.xml
  120. $(call cmd,db2pdf)
  121. index = index.html
  122. main_idx = Documentation/DocBook/$(index)
  123. build_main_index = rm -rf $(main_idx) && \
  124. echo '<h1>Linux Kernel HTML Documentation</h1>' >> $(main_idx) && \
  125. echo '<h2>Kernel Version: $(KERNELVERSION)</h2>' >> $(main_idx) && \
  126. cat $(HTML) >> $(main_idx)
  127. quiet_cmd_db2html = HTML $@
  128. cmd_db2html = xmlto xhtml $(XMLTOFLAGS) -o $(patsubst %.html,%,$@) $< && \
  129. echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/index.html"> \
  130. $(patsubst %.html,%,$(notdir $@))</a><p>' > $@
  131. %.html: %.xml
  132. @(which xmlto > /dev/null 2>&1) || \
  133. (echo "*** You need to install xmlto ***"; \
  134. exit 1)
  135. @rm -rf $@ $(patsubst %.html,%,$@)
  136. $(call cmd,db2html)
  137. @if [ ! -z "$(PNG-$(basename $(notdir $@)))" ]; then \
  138. cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
  139. quiet_cmd_db2man = MAN $@
  140. cmd_db2man = if grep -q refentry $<; then xmlto man $(XMLTOFLAGS) -o $(obj)/man $< ; gzip -f $(obj)/man/*.9; fi
  141. %.9 : %.xml
  142. @(which xmlto > /dev/null 2>&1) || \
  143. (echo "*** You need to install xmlto ***"; \
  144. exit 1)
  145. $(Q)mkdir -p $(obj)/man
  146. $(call cmd,db2man)
  147. @touch $@
  148. ###
  149. # Rules to generate postscripts and PNG images from .fig format files
  150. quiet_cmd_fig2eps = FIG2EPS $@
  151. cmd_fig2eps = fig2dev -Leps $< $@
  152. %.eps: %.fig
  153. @(which fig2dev > /dev/null 2>&1) || \
  154. (echo "*** You need to install transfig ***"; \
  155. exit 1)
  156. $(call cmd,fig2eps)
  157. quiet_cmd_fig2png = FIG2PNG $@
  158. cmd_fig2png = fig2dev -Lpng $< $@
  159. %.png: %.fig
  160. @(which fig2dev > /dev/null 2>&1) || \
  161. (echo "*** You need to install transfig ***"; \
  162. exit 1)
  163. $(call cmd,fig2png)
  164. ###
  165. # Rule to convert a .c file to inline XML documentation
  166. gen_xml = :
  167. quiet_gen_xml = echo ' GEN $@'
  168. silent_gen_xml = :
  169. %.xml: %.c
  170. @$($(quiet)gen_xml)
  171. @( \
  172. echo "<programlisting>"; \
  173. expand --tabs=8 < $< | \
  174. sed -e "s/&/\\&amp;/g" \
  175. -e "s/</\\&lt;/g" \
  176. -e "s/>/\\&gt;/g"; \
  177. echo "</programlisting>") > $@
  178. ###
  179. # Help targets as used by the top-level makefile
  180. dochelp:
  181. @echo ' Linux kernel internal documentation in different formats:'
  182. @echo ' htmldocs - HTML'
  183. @echo ' pdfdocs - PDF'
  184. @echo ' psdocs - Postscript'
  185. @echo ' xmldocs - XML DocBook'
  186. @echo ' mandocs - man pages'
  187. @echo ' installmandocs - install man pages generated by mandocs'
  188. @echo ' cleandocs - clean all generated DocBook files'
  189. ###
  190. # Temporary files left by various tools
  191. clean-files := $(DOCBOOKS) \
  192. $(patsubst %.xml, %.dvi, $(DOCBOOKS)) \
  193. $(patsubst %.xml, %.aux, $(DOCBOOKS)) \
  194. $(patsubst %.xml, %.tex, $(DOCBOOKS)) \
  195. $(patsubst %.xml, %.log, $(DOCBOOKS)) \
  196. $(patsubst %.xml, %.out, $(DOCBOOKS)) \
  197. $(patsubst %.xml, %.ps, $(DOCBOOKS)) \
  198. $(patsubst %.xml, %.pdf, $(DOCBOOKS)) \
  199. $(patsubst %.xml, %.html, $(DOCBOOKS)) \
  200. $(patsubst %.xml, %.9, $(DOCBOOKS)) \
  201. $(index)
  202. clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS)) man
  203. cleandocs:
  204. $(Q)rm -f $(call objectify, $(clean-files))
  205. $(Q)rm -rf $(call objectify, $(clean-dirs))
  206. # Declare the contents of the .PHONY variable as phony. We keep that
  207. # information in a variable se we can use it in if_changed and friends.
  208. .PHONY: $(PHONY)