xref: /rk3399_rockchip-uboot/doc/DocBook/Makefile (revision 6825a95b0ba72c4e5667d02d8b31986e2e9abd5a)
130ff8918SMarek Vasut###
230ff8918SMarek Vasut# This makefile is used to generate the kernel documentation,
330ff8918SMarek Vasut# primarily based on in-line comments in various source files.
430ff8918SMarek Vasut# See doc/kernel-doc-nano-HOWTO.txt for instruction in how
530ff8918SMarek Vasut# to document the SRC - and how to read it.
630ff8918SMarek Vasut# To add a new book the only step required is to add the book to the
730ff8918SMarek Vasut# list of DOCBOOKS.
830ff8918SMarek Vasut
9e3ff797cSSimon GlassDOCBOOKS := fs.xml linker_lists.xml stdio.xml
1030ff8918SMarek Vasut
1130ff8918SMarek Vasut###
1230ff8918SMarek Vasut# The build process is as follows (targets):
1330ff8918SMarek Vasut#              (xmldocs) [by docproc]
1430ff8918SMarek Vasut# file.tmpl --> file.xml +--> file.ps   (psdocs)   [by db2ps or xmlto]
1530ff8918SMarek Vasut#                        +--> file.pdf  (pdfdocs)  [by db2pdf or xmlto]
1630ff8918SMarek Vasut#                        +--> DIR=file  (htmldocs) [by xmlto]
1730ff8918SMarek Vasut#                        +--> man/      (mandocs)  [by xmlto]
1830ff8918SMarek Vasut
1930ff8918SMarek Vasut
2030ff8918SMarek Vasut# for PDF and PS output you can choose between xmlto and docbook-utils tools
2130ff8918SMarek VasutPDF_METHOD	= $(prefer-db2x)
2230ff8918SMarek VasutPS_METHOD	= $(prefer-db2x)
2330ff8918SMarek Vasut
2430ff8918SMarek Vasut
2530ff8918SMarek Vasut###
2630ff8918SMarek Vasut# The targets that may be used.
27*6825a95bSMasahiro YamadaPHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs cleandocs
2830ff8918SMarek Vasut
29*6825a95bSMasahiro YamadaBOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
3030ff8918SMarek Vasutxmldocs: $(BOOKS)
3130ff8918SMarek Vasutsgmldocs: xmldocs
3230ff8918SMarek Vasut
3330ff8918SMarek VasutPS := $(patsubst %.xml, %.ps, $(BOOKS))
3430ff8918SMarek Vasutpsdocs: $(PS)
3530ff8918SMarek Vasut
3630ff8918SMarek VasutPDF := $(patsubst %.xml, %.pdf, $(BOOKS))
3730ff8918SMarek Vasutpdfdocs: $(PDF)
3830ff8918SMarek Vasut
3930ff8918SMarek VasutHTML := $(sort $(patsubst %.xml, %.html, $(BOOKS)))
4030ff8918SMarek Vasuthtmldocs: $(HTML)
4130ff8918SMarek Vasut	$(call build_main_index)
4230ff8918SMarek Vasut	$(call build_images)
4330ff8918SMarek Vasut	$(call install_media_images)
4430ff8918SMarek Vasut
4530ff8918SMarek VasutMAN := $(patsubst %.xml, %.9, $(BOOKS))
4630ff8918SMarek Vasutmandocs: $(MAN)
4730ff8918SMarek Vasut
4830ff8918SMarek Vasutinstallmandocs: mandocs
4930ff8918SMarek Vasut	mkdir -p /usr/local/man/man9/
5030ff8918SMarek Vasut	install doc/DocBook/man/*.9.gz /usr/local/man/man9/
5130ff8918SMarek Vasut
5230ff8918SMarek Vasut###
5330ff8918SMarek Vasut#External programs used
54*6825a95bSMasahiro YamadaKERNELDOC = $(srctree)/tools/kernel-doc/kernel-doc
55*6825a95bSMasahiro YamadaDOCPROC   = $(objtree)/tools/kernel-doc/docproc
5630ff8918SMarek Vasut
57*6825a95bSMasahiro YamadaXMLTOFLAGS = -m $(srctree)/doc/DocBook/stylesheet.xsl
5830ff8918SMarek VasutXMLTOFLAGS += --skip-validation
5930ff8918SMarek Vasut
6030ff8918SMarek Vasut###
6130ff8918SMarek Vasut# DOCPROC is used for two purposes:
6230ff8918SMarek Vasut# 1) To generate a dependency list for a .tmpl file
6330ff8918SMarek Vasut# 2) To preprocess a .tmpl file and call kernel-doc with
6430ff8918SMarek Vasut#     appropriate parameters.
6530ff8918SMarek Vasut# The following rules are used to generate the .xml documentation
6630ff8918SMarek Vasut# required to generate the final targets. (ps, pdf, html).
67*6825a95bSMasahiro Yamadaquiet_cmd_docproc = DOCPROC $@
68*6825a95bSMasahiro Yamada      cmd_docproc = SRCTREE=$(srctree)/ $(DOCPROC) doc $< >$@
69*6825a95bSMasahiro Yamadadefine rule_docproc
70*6825a95bSMasahiro Yamada	set -e;								\
71*6825a95bSMasahiro Yamada        $(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))';) 	\
72*6825a95bSMasahiro Yamada        $(cmd_$(1)); 							\
73*6825a95bSMasahiro Yamada        ( 								\
74*6825a95bSMasahiro Yamada          echo 'cmd_$@ := $(cmd_$(1))'; 				\
75*6825a95bSMasahiro Yamada          echo $@: `SRCTREE=$(srctree) $(DOCPROC) depend $<`; 		\
76*6825a95bSMasahiro Yamada        ) > $(dir $@).$(notdir $@).cmd
77*6825a95bSMasahiro Yamadaendef
7830ff8918SMarek Vasut
79*6825a95bSMasahiro Yamada%.xml: %.tmpl FORCE
80*6825a95bSMasahiro Yamada	$(call if_changed_rule,docproc)
81*6825a95bSMasahiro Yamada
82*6825a95bSMasahiro Yamada###
83*6825a95bSMasahiro Yamada#Read in all saved dependency files
84*6825a95bSMasahiro Yamadacmd_files := $(wildcard $(foreach f,$(BOOKS),$(dir $(f)).$(notdir $(f)).cmd))
85*6825a95bSMasahiro Yamada
86*6825a95bSMasahiro Yamadaifneq ($(cmd_files),)
87*6825a95bSMasahiro Yamada  include $(cmd_files)
8830ff8918SMarek Vasutendif
8930ff8918SMarek Vasut
9030ff8918SMarek Vasut###
9130ff8918SMarek Vasut# Changes in kernel-doc force a rebuild of all documentation
9230ff8918SMarek Vasut$(BOOKS): $(KERNELDOC)
9330ff8918SMarek Vasut
94*6825a95bSMasahiro Yamada# Tell kbuild to always build the programs
95*6825a95bSMasahiro Yamadaalways := $(hostprogs-y)
96*6825a95bSMasahiro Yamada
9730ff8918SMarek Vasutnotfoundtemplate = echo "*** You have to install docbook-utils or xmlto ***"; \
9830ff8918SMarek Vasut		   exit 1
9930ff8918SMarek Vasutdb2xtemplate = db2TYPE -o $(dir $@) $<
10030ff8918SMarek Vasutxmltotemplate = xmlto TYPE $(XMLTOFLAGS) -o $(dir $@) $<
10130ff8918SMarek Vasut
10230ff8918SMarek Vasut# determine which methods are available
10330ff8918SMarek Vasutifeq ($(shell which db2ps >/dev/null 2>&1 && echo found),found)
10430ff8918SMarek Vasut	use-db2x = db2x
10530ff8918SMarek Vasut	prefer-db2x = db2x
10630ff8918SMarek Vasutelse
10730ff8918SMarek Vasut	use-db2x = notfound
10830ff8918SMarek Vasut	prefer-db2x = $(use-xmlto)
10930ff8918SMarek Vasutendif
11030ff8918SMarek Vasutifeq ($(shell which xmlto >/dev/null 2>&1 && echo found),found)
11130ff8918SMarek Vasut	use-xmlto = xmlto
11230ff8918SMarek Vasut	prefer-xmlto = xmlto
11330ff8918SMarek Vasutelse
11430ff8918SMarek Vasut	use-xmlto = notfound
11530ff8918SMarek Vasut	prefer-xmlto = $(use-db2x)
11630ff8918SMarek Vasutendif
11730ff8918SMarek Vasut
11830ff8918SMarek Vasut# the commands, generated from the chosen template
11930ff8918SMarek Vasutquiet_cmd_db2ps = PS      $@
12030ff8918SMarek Vasut      cmd_db2ps = $(subst TYPE,ps, $($(PS_METHOD)template))
12130ff8918SMarek Vasut%.ps : %.xml
122*6825a95bSMasahiro Yamada	$(call cmd,db2ps)
12330ff8918SMarek Vasut
12430ff8918SMarek Vasutquiet_cmd_db2pdf = PDF     $@
12530ff8918SMarek Vasut      cmd_db2pdf = $(subst TYPE,pdf, $($(PDF_METHOD)template))
12630ff8918SMarek Vasut%.pdf : %.xml
127*6825a95bSMasahiro Yamada	$(call cmd,db2pdf)
12830ff8918SMarek Vasut
12930ff8918SMarek Vasut
13030ff8918SMarek Vasutindex = index.html
1319e414032SMasahiro Yamadamain_idx = doc/DocBook/$(index)
13230ff8918SMarek Vasutbuild_main_index = rm -rf $(main_idx); \
13330ff8918SMarek Vasut		   echo '<h1>U-Boot Bootloader HTML Documentation</h1>' >> $(main_idx) && \
13430ff8918SMarek Vasut		   echo '<h2>U-Boot Version: $(U_BOOT_VERSION)</h2>' >> $(main_idx) && \
13530ff8918SMarek Vasut		   cat $(HTML) >> $(main_idx)
13630ff8918SMarek Vasut
13730ff8918SMarek Vasut# To work around bug [1] in docbook-xsl-stylesheets 1.76.1 , generate only html
13830ff8918SMarek Vasut# docs instead of xhtml with xmlto.
13930ff8918SMarek Vasut# [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=654338
14030ff8918SMarek Vasutquiet_cmd_db2html = HTML    $@
14130ff8918SMarek Vasut      cmd_db2html = xmlto html $(XMLTOFLAGS) -o $(patsubst %.html,%,$@) $< && \
14230ff8918SMarek Vasut		echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/index.html"> \
14330ff8918SMarek Vasut        $(patsubst %.html,%,$(notdir $@))</a><p>' > $@
14430ff8918SMarek Vasut
14530ff8918SMarek Vasut%.html:	%.xml
14630ff8918SMarek Vasut	@(which xmlto > /dev/null 2>&1) || \
14730ff8918SMarek Vasut	 (echo "*** You need to install xmlto ***"; \
14830ff8918SMarek Vasut	  exit 1)
14930ff8918SMarek Vasut	@rm -rf $@ $(patsubst %.html,%,$@)
150*6825a95bSMasahiro Yamada	$(call cmd,db2html)
15130ff8918SMarek Vasut	@if [ ! -z "$(PNG-$(basename $(notdir $@)))" ]; then \
15230ff8918SMarek Vasut            cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
15330ff8918SMarek Vasut
15430ff8918SMarek Vasutquiet_cmd_db2man = MAN     $@
15530ff8918SMarek Vasut      cmd_db2man = if grep -q refentry $<; then xmlto man $(XMLTOFLAGS) -o $(obj)/man $< ; gzip -f $(obj)/man/*.9; fi
15630ff8918SMarek Vasut%.9 : %.xml
15730ff8918SMarek Vasut	@(which xmlto > /dev/null 2>&1) || \
15830ff8918SMarek Vasut	 (echo "*** You need to install xmlto ***"; \
15930ff8918SMarek Vasut	  exit 1)
1609e414032SMasahiro Yamada	$(Q)mkdir -p $(obj)/man
161*6825a95bSMasahiro Yamada	$(call cmd,db2man)
16230ff8918SMarek Vasut	@touch $@
16330ff8918SMarek Vasut
16430ff8918SMarek Vasut###
16530ff8918SMarek Vasut# Rules to generate postscripts and PNG images from .fig format files
16630ff8918SMarek Vasutquiet_cmd_fig2eps = FIG2EPS $@
16730ff8918SMarek Vasut      cmd_fig2eps = fig2dev -Leps $< $@
16830ff8918SMarek Vasut
16930ff8918SMarek Vasut%.eps: %.fig
17030ff8918SMarek Vasut	@(which fig2dev > /dev/null 2>&1) || \
17130ff8918SMarek Vasut	 (echo "*** You need to install transfig ***"; \
17230ff8918SMarek Vasut	  exit 1)
173*6825a95bSMasahiro Yamada	$(call cmd,fig2eps)
17430ff8918SMarek Vasut
17530ff8918SMarek Vasutquiet_cmd_fig2png = FIG2PNG $@
17630ff8918SMarek Vasut      cmd_fig2png = fig2dev -Lpng $< $@
17730ff8918SMarek Vasut
17830ff8918SMarek Vasut%.png: %.fig
17930ff8918SMarek Vasut	@(which fig2dev > /dev/null 2>&1) || \
18030ff8918SMarek Vasut	 (echo "*** You need to install transfig ***"; \
18130ff8918SMarek Vasut	  exit 1)
182*6825a95bSMasahiro Yamada	$(call cmd,fig2png)
18330ff8918SMarek Vasut
18430ff8918SMarek Vasut###
18530ff8918SMarek Vasut# Rule to convert a .c file to inline XML documentation
18630ff8918SMarek Vasut       gen_xml = :
18730ff8918SMarek Vasut quiet_gen_xml = echo '  GEN     $@'
18830ff8918SMarek Vasutsilent_gen_xml = :
18930ff8918SMarek Vasut%.xml: %.c
19030ff8918SMarek Vasut	@$($(quiet)gen_xml)
19130ff8918SMarek Vasut	@(                            \
19230ff8918SMarek Vasut	   echo "<programlisting>";   \
19330ff8918SMarek Vasut	   expand --tabs=8 < $< |     \
19430ff8918SMarek Vasut	   sed -e "s/&/\\&amp;/g"     \
19530ff8918SMarek Vasut	       -e "s/</\\&lt;/g"      \
19630ff8918SMarek Vasut	       -e "s/>/\\&gt;/g";     \
19730ff8918SMarek Vasut	   echo "</programlisting>")  > $@
19830ff8918SMarek Vasut
19930ff8918SMarek Vasut###
20030ff8918SMarek Vasut# Help targets as used by the top-level makefile
20130ff8918SMarek Vasutdochelp:
20230ff8918SMarek Vasut	@echo  ' U-Boot bootloader internal documentation in different formats:'
20330ff8918SMarek Vasut	@echo  '  htmldocs        - HTML'
20430ff8918SMarek Vasut	@echo  '  pdfdocs         - PDF'
20530ff8918SMarek Vasut	@echo  '  psdocs          - Postscript'
20630ff8918SMarek Vasut	@echo  '  xmldocs         - XML DocBook'
20730ff8918SMarek Vasut	@echo  '  mandocs         - man pages'
20830ff8918SMarek Vasut	@echo  '  installmandocs  - install man pages generated by mandocs'
20930ff8918SMarek Vasut	@echo  '  cleandocs       - clean all generated DocBook files'
21030ff8918SMarek Vasut
21130ff8918SMarek Vasut###
21230ff8918SMarek Vasut# Temporary files left by various tools
21330ff8918SMarek Vasutclean-files := $(DOCBOOKS) \
21430ff8918SMarek Vasut	$(patsubst %.xml, %.dvi,  $(DOCBOOKS)) \
21530ff8918SMarek Vasut	$(patsubst %.xml, %.aux,  $(DOCBOOKS)) \
21630ff8918SMarek Vasut	$(patsubst %.xml, %.tex,  $(DOCBOOKS)) \
21730ff8918SMarek Vasut	$(patsubst %.xml, %.log,  $(DOCBOOKS)) \
21830ff8918SMarek Vasut	$(patsubst %.xml, %.out,  $(DOCBOOKS)) \
21930ff8918SMarek Vasut	$(patsubst %.xml, %.ps,   $(DOCBOOKS)) \
22030ff8918SMarek Vasut	$(patsubst %.xml, %.pdf,  $(DOCBOOKS)) \
22130ff8918SMarek Vasut	$(patsubst %.xml, %.html, $(DOCBOOKS)) \
22230ff8918SMarek Vasut	$(patsubst %.xml, %.9,    $(DOCBOOKS)) \
22330ff8918SMarek Vasut	$(index)
22430ff8918SMarek Vasut
22530ff8918SMarek Vasutclean-dirs := $(patsubst %.xml,%,$(DOCBOOKS)) man
22630ff8918SMarek Vasut
22730ff8918SMarek Vasutcleandocs:
22830ff8918SMarek Vasut	@$(Q)rm -f $(call objectify, $(clean-files))
22930ff8918SMarek Vasut	@$(Q)rm -rf $(call objectify, $(clean-dirs))
23030ff8918SMarek Vasut
23130ff8918SMarek Vasut# Declare the contents of the .PHONY variable as phony.  We keep that
23230ff8918SMarek Vasut# information in a variable se we can use it in if_changed and friends.
23330ff8918SMarek Vasut
23430ff8918SMarek Vasut.PHONY: $(PHONY)
235