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
9 DOCBOOKS := linker_lists.xml stdio.xml
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]
20 # for PDF and PS output you can choose between xmlto and docbook-utils tools
21 PDF_METHOD = $(prefer-db2x)
22 PS_METHOD = $(prefer-db2x)
26 # The targets that may be used.
27 PHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs cleandocs
29 targets += $(DOCBOOKS)
30 BOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
34 PS := $(patsubst %.xml, %.ps, $(BOOKS))
37 PDF := $(patsubst %.xml, %.pdf, $(BOOKS))
40 HTML := $(sort $(patsubst %.xml, %.html, $(BOOKS)))
42 $(call build_main_index)
44 $(call install_media_images)
46 MAN := $(patsubst %.xml, %.9, $(BOOKS))
48 $(if $(wildcard $(obj)/man/*.9),gzip -f $(obj)/man/*.9)
50 installmandocs: mandocs
51 mkdir -p /usr/local/man/man9/
52 install $(obj)/man/*.9.gz /usr/local/man/man9/
55 #External programs used
56 KERNELDOC = $(srctree)/scripts/kernel-doc
57 DOCPROC = $(objtree)/scripts/docproc
59 XMLTOFLAGS = -m $(srctree)/$(src)/stylesheet.xsl
60 XMLTOFLAGS += --skip-validation
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 $< >$@
73 $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \
76 echo 'cmd_$@ := $(cmd_$(1))'; \
77 echo $@: `SRCTREE=$(srctree) $(DOCPROC) depend $<`; \
78 ) > $(dir $@).$(notdir $@).cmd
81 %.xml: %.tmpl $(KERNELDOC) $(DOCPROC) FORCE
82 $(call if_changed_rule,docproc)
84 # Tell kbuild to always build the programs
85 always := $(hostprogs-y)
87 notfoundtemplate = echo "*** You have to install docbook-utils or xmlto ***"; \
89 db2xtemplate = db2TYPE -o $(dir $@) $<
90 xmltotemplate = xmlto TYPE $(XMLTOFLAGS) -o $(dir $@) $<
92 # determine which methods are available
93 ifeq ($(shell which db2ps >/dev/null 2>&1 && echo found),found)
98 prefer-db2x = $(use-xmlto)
100 ifeq ($(shell which xmlto >/dev/null 2>&1 && echo found),found)
105 prefer-xmlto = $(use-db2x)
108 # the commands, generated from the chosen template
109 quiet_cmd_db2ps = PS $@
110 cmd_db2ps = $(subst TYPE,ps, $($(PS_METHOD)template))
114 quiet_cmd_db2pdf = PDF $@
115 cmd_db2pdf = $(subst TYPE,pdf, $($(PDF_METHOD)template))
121 main_idx = $(obj)/$(index)
122 build_main_index = rm -rf $(main_idx); \
123 echo '<h1>U-Boot Bootloader HTML Documentation</h1>' >> $(main_idx) && \
124 echo '<h2>U-Boot Version: $(UBOOTVERSION)</h2>' >> $(main_idx) && \
125 cat $(HTML) >> $(main_idx)
127 quiet_cmd_db2html = HTML $@
128 cmd_db2html = xmlto html $(XMLTOFLAGS) -o $(patsubst %.html,%,$@) $< && \
129 echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/index.html"> \
130 $(patsubst %.html,%,$(notdir $@))</a><p>' > $@
133 @(which xmlto > /dev/null 2>&1) || \
134 (echo "*** You need to install xmlto ***"; \
136 @rm -rf $@ $(patsubst %.html,%,$@)
138 @if [ ! -z "$(PNG-$(basename $(notdir $@)))" ]; then \
139 cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
141 quiet_cmd_db2man = MAN $@
142 cmd_db2man = if grep -q refentry $<; then xmlto man $(XMLTOFLAGS) -o $(obj)/man $< ; fi
144 @(which xmlto > /dev/null 2>&1) || \
145 (echo "*** You need to install xmlto ***"; \
147 $(Q)mkdir -p $(obj)/man
152 # Rules to generate postscripts and PNG images from .fig format files
153 quiet_cmd_fig2eps = FIG2EPS $@
154 cmd_fig2eps = fig2dev -Leps $< $@
157 @(which fig2dev > /dev/null 2>&1) || \
158 (echo "*** You need to install transfig ***"; \
162 quiet_cmd_fig2png = FIG2PNG $@
163 cmd_fig2png = fig2dev -Lpng $< $@
166 @(which fig2dev > /dev/null 2>&1) || \
167 (echo "*** You need to install transfig ***"; \
172 # Rule to convert a .c file to inline XML documentation
174 quiet_gen_xml = echo ' GEN $@'
179 echo "<programlisting>"; \
180 expand --tabs=8 < $< | \
181 sed -e "s/&/\\&/g" \
184 echo "</programlisting>") > $@
187 # Help targets as used by the top-level makefile
189 @echo ' U-Boot bootloader internal documentation in different formats:'
190 @echo ' htmldocs - HTML'
191 @echo ' pdfdocs - PDF'
192 @echo ' psdocs - Postscript'
193 @echo ' xmldocs - XML DocBook'
194 @echo ' mandocs - man pages'
195 @echo ' installmandocs - install man pages generated by mandocs'
196 @echo ' cleandocs - clean all generated DocBook files'
199 # Temporary files left by various tools
200 clean-files := $(DOCBOOKS) \
201 $(patsubst %.xml, %.dvi, $(DOCBOOKS)) \
202 $(patsubst %.xml, %.aux, $(DOCBOOKS)) \
203 $(patsubst %.xml, %.tex, $(DOCBOOKS)) \
204 $(patsubst %.xml, %.log, $(DOCBOOKS)) \
205 $(patsubst %.xml, %.out, $(DOCBOOKS)) \
206 $(patsubst %.xml, %.ps, $(DOCBOOKS)) \
207 $(patsubst %.xml, %.pdf, $(DOCBOOKS)) \
208 $(patsubst %.xml, %.html, $(DOCBOOKS)) \
209 $(patsubst %.xml, %.9, $(DOCBOOKS)) \
212 clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS)) man
215 $(Q)rm -f $(call objectify, $(clean-files))
216 $(Q)rm -rf $(call objectify, $(clean-dirs))
218 # Declare the contents of the .PHONY variable as phony. We keep that
219 # information in a variable se we can use it in if_changed and friends.