xref: /rk3399_rockchip-uboot/doc/DocBook/Makefile (revision 9e4140329ee9a787d0f96ac2829d618d47f7973f)
1###
2# This makefile is used to generate the kernel documentation,
3# primarily based on in-line comments in various source files.
4# See doc/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
9DOCBOOKS := fs.xml linker_lists.xml stdio.xml
10
11###
12# The build process is as follows (targets):
13#              (xmldocs) [by docproc]
14# file.tmpl --> file.xml +--> file.ps   (psdocs)   [by db2ps or xmlto]
15#                        +--> file.pdf  (pdfdocs)  [by db2pdf or xmlto]
16#                        +--> DIR=file  (htmldocs) [by xmlto]
17#                        +--> man/      (mandocs)  [by xmlto]
18
19
20# for PDF and PS output you can choose between xmlto and docbook-utils tools
21PDF_METHOD	= $(prefer-db2x)
22PS_METHOD	= $(prefer-db2x)
23
24
25###
26# The targets that may be used.
27PHONY += $(obj).depend xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs cleandocs
28
29BOOKS := $(addprefix $(OBJTREE)/doc/DocBook/,$(DOCBOOKS))
30xmldocs: $(BOOKS)
31sgmldocs: xmldocs
32
33PS := $(patsubst %.xml, %.ps, $(BOOKS))
34psdocs: $(PS)
35
36PDF := $(patsubst %.xml, %.pdf, $(BOOKS))
37pdfdocs: $(PDF)
38
39HTML := $(sort $(patsubst %.xml, %.html, $(BOOKS)))
40htmldocs: $(HTML)
41	$(call build_main_index)
42	$(call build_images)
43	$(call install_media_images)
44
45MAN := $(patsubst %.xml, %.9, $(BOOKS))
46mandocs: $(MAN)
47
48installmandocs: mandocs
49	mkdir -p /usr/local/man/man9/
50	install doc/DocBook/man/*.9.gz /usr/local/man/man9/
51
52###
53#External programs used
54KERNELDOC = $(SRCTREE)/tools/kernel-doc/kernel-doc
55DOCPROC   = $(OBJTREE)/tools/kernel-doc/docproc
56
57XMLTOFLAGS = -m $(SRCTREE)/doc/DocBook/stylesheet.xsl
58XMLTOFLAGS += --skip-validation
59
60###
61# DOCPROC is used for two purposes:
62# 1) To generate a dependency list for a .tmpl file
63# 2) To preprocess a .tmpl file and call kernel-doc with
64#     appropriate parameters.
65# The following rules are used to generate the .xml documentation
66# required to generate the final targets. (ps, pdf, html).
67%.xml: %.tmpl
68	$(DOCPROC) doc $< >$@
69
70ifeq ($@, "cleandocs")
71sinclude $(obj).depend
72$(obj).depend: $(patsubst %.xml, %.tmpl, $(DOCBOOKS))
73	rm -f $(obj).depend ;					\
74	touch $(obj).depend ;					\
75	for file in $^ ; do					\
76		xmlfile=`echo "$${file}" |			\
77			sed "s/tmpl$$/xml/"` ;			\
78		echo -n "$${xmlfile}: ">> $(obj).depend ;	\
79		$(DOCPROC) depend $$file >> $(obj).depend ;	\
80		echo -e "\n\t$(DOCPROC) doc $< >$${xmlfile} " >>	\
81			$(obj).depend ;				\
82	done
83endif
84
85###
86# Changes in kernel-doc force a rebuild of all documentation
87$(BOOKS): $(KERNELDOC)
88
89notfoundtemplate = echo "*** You have to install docbook-utils or xmlto ***"; \
90		   exit 1
91db2xtemplate = db2TYPE -o $(dir $@) $<
92xmltotemplate = xmlto TYPE $(XMLTOFLAGS) -o $(dir $@) $<
93
94# determine which methods are available
95ifeq ($(shell which db2ps >/dev/null 2>&1 && echo found),found)
96	use-db2x = db2x
97	prefer-db2x = db2x
98else
99	use-db2x = notfound
100	prefer-db2x = $(use-xmlto)
101endif
102ifeq ($(shell which xmlto >/dev/null 2>&1 && echo found),found)
103	use-xmlto = xmlto
104	prefer-xmlto = xmlto
105else
106	use-xmlto = notfound
107	prefer-xmlto = $(use-db2x)
108endif
109
110# the commands, generated from the chosen template
111quiet_cmd_db2ps = PS      $@
112      cmd_db2ps = $(subst TYPE,ps, $($(PS_METHOD)template))
113%.ps : %.xml
114	$(call cmd_db2ps)
115
116quiet_cmd_db2pdf = PDF     $@
117      cmd_db2pdf = $(subst TYPE,pdf, $($(PDF_METHOD)template))
118%.pdf : %.xml
119	$(call cmd_db2pdf)
120
121
122index = index.html
123main_idx = doc/DocBook/$(index)
124build_main_index = rm -rf $(main_idx); \
125		   echo '<h1>U-Boot Bootloader HTML Documentation</h1>' >> $(main_idx) && \
126		   echo '<h2>U-Boot Version: $(U_BOOT_VERSION)</h2>' >> $(main_idx) && \
127		   cat $(HTML) >> $(main_idx)
128
129# To work around bug [1] in docbook-xsl-stylesheets 1.76.1 , generate only html
130# docs instead of xhtml with xmlto.
131# [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=654338
132quiet_cmd_db2html = HTML    $@
133      cmd_db2html = xmlto html $(XMLTOFLAGS) -o $(patsubst %.html,%,$@) $< && \
134		echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/index.html"> \
135	$(patsubst %.html,%,$(notdir $@))</a><p>' > $@
136
137%.html:	%.xml
138	@(which xmlto > /dev/null 2>&1) || \
139	 (echo "*** You need to install xmlto ***"; \
140	  exit 1)
141	@rm -rf $@ $(patsubst %.html,%,$@)
142	$(call cmd_db2html)
143	@if [ ! -z "$(PNG-$(basename $(notdir $@)))" ]; then \
144	    cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
145
146quiet_cmd_db2man = MAN     $@
147      cmd_db2man = if grep -q refentry $<; then xmlto man $(XMLTOFLAGS) -o $(obj)/man $< ; gzip -f $(obj)/man/*.9; fi
148%.9 : %.xml
149	@(which xmlto > /dev/null 2>&1) || \
150	 (echo "*** You need to install xmlto ***"; \
151	  exit 1)
152	$(Q)mkdir -p $(obj)/man
153	$(call cmd_db2man)
154	@touch $@
155
156###
157# Rules to generate postscripts and PNG images from .fig format files
158quiet_cmd_fig2eps = FIG2EPS $@
159      cmd_fig2eps = fig2dev -Leps $< $@
160
161%.eps: %.fig
162	@(which fig2dev > /dev/null 2>&1) || \
163	 (echo "*** You need to install transfig ***"; \
164	  exit 1)
165	$(call cmd_fig2eps)
166
167quiet_cmd_fig2png = FIG2PNG $@
168      cmd_fig2png = fig2dev -Lpng $< $@
169
170%.png: %.fig
171	@(which fig2dev > /dev/null 2>&1) || \
172	 (echo "*** You need to install transfig ***"; \
173	  exit 1)
174	$(call cmd_fig2png)
175
176###
177# Rule to convert a .c file to inline XML documentation
178       gen_xml = :
179 quiet_gen_xml = echo '  GEN     $@'
180silent_gen_xml = :
181%.xml: %.c
182	@$($(quiet)gen_xml)
183	@(                            \
184	   echo "<programlisting>";   \
185	   expand --tabs=8 < $< |     \
186	   sed -e "s/&/\\&amp;/g"     \
187	       -e "s/</\\&lt;/g"      \
188	       -e "s/>/\\&gt;/g";     \
189	   echo "</programlisting>")  > $@
190
191###
192# Help targets as used by the top-level makefile
193dochelp:
194	@echo  ' U-Boot bootloader internal documentation in different formats:'
195	@echo  '  htmldocs        - HTML'
196	@echo  '  pdfdocs         - PDF'
197	@echo  '  psdocs          - Postscript'
198	@echo  '  xmldocs         - XML DocBook'
199	@echo  '  mandocs         - man pages'
200	@echo  '  installmandocs  - install man pages generated by mandocs'
201	@echo  '  cleandocs       - clean all generated DocBook files'
202
203###
204# Temporary files left by various tools
205clean-files := $(DOCBOOKS) \
206	$(patsubst %.xml, %.dvi,  $(DOCBOOKS)) \
207	$(patsubst %.xml, %.aux,  $(DOCBOOKS)) \
208	$(patsubst %.xml, %.tex,  $(DOCBOOKS)) \
209	$(patsubst %.xml, %.log,  $(DOCBOOKS)) \
210	$(patsubst %.xml, %.out,  $(DOCBOOKS)) \
211	$(patsubst %.xml, %.ps,   $(DOCBOOKS)) \
212	$(patsubst %.xml, %.pdf,  $(DOCBOOKS)) \
213	$(patsubst %.xml, %.html, $(DOCBOOKS)) \
214	$(patsubst %.xml, %.9,    $(DOCBOOKS)) \
215	$(index)
216
217clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS)) man
218
219cleandocs:
220	@rm -f $(obj).depend
221	@$(Q)rm -f $(call objectify, $(clean-files))
222	@$(Q)rm -rf $(call objectify, $(clean-dirs))
223
224# Declare the contents of the .PHONY variable as phony.  We keep that
225# information in a variable se we can use it in if_changed and friends.
226
227.PHONY: $(PHONY)
228