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
9 DOCBOOKS := fs.xml 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 += $(obj).depend xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs cleandocs
29 BOOKS := $(addprefix $(OBJTREE)/doc/DocBook/,$(DOCBOOKS))
33 PS := $(patsubst %.xml, %.ps, $(BOOKS))
36 PDF := $(patsubst %.xml, %.pdf, $(BOOKS))
39 HTML := $(sort $(patsubst %.xml, %.html, $(BOOKS)))
41 $(call build_main_index)
43 $(call install_media_images)
45 MAN := $(patsubst %.xml, %.9, $(BOOKS))
48 installmandocs: mandocs
49 mkdir -p /usr/local/man/man9/
50 install doc/DocBook/man/*.9.gz /usr/local/man/man9/
53 #External programs used
54 KERNELDOC = $(SRCTREE)/tools/kernel-doc/kernel-doc
55 DOCPROC = $(OBJTREE)/tools/kernel-doc/docproc
57 XMLTOFLAGS = -m $(SRCTREE)/doc/DocBook/stylesheet.xsl
58 XMLTOFLAGS += --skip-validation
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).
70 ifeq ($@, "cleandocs")
71 sinclude $(obj).depend
72 $(obj).depend: $(patsubst %.xml, %.tmpl, $(DOCBOOKS))
73 rm -f $(obj).depend ; \
74 touch $(obj).depend ; \
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} " >> \
86 # Changes in kernel-doc force a rebuild of all documentation
87 $(BOOKS): $(KERNELDOC)
89 notfoundtemplate = echo "*** You have to install docbook-utils or xmlto ***"; \
91 db2xtemplate = db2TYPE -o $(dir $@) $<
92 xmltotemplate = xmlto TYPE $(XMLTOFLAGS) -o $(dir $@) $<
94 # determine which methods are available
95 ifeq ($(shell which db2ps >/dev/null 2>&1 && echo found),found)
100 prefer-db2x = $(use-xmlto)
102 ifeq ($(shell which xmlto >/dev/null 2>&1 && echo found),found)
107 prefer-xmlto = $(use-db2x)
110 # the commands, generated from the chosen template
111 quiet_cmd_db2ps = PS $@
112 cmd_db2ps = $(subst TYPE,ps, $($(PS_METHOD)template))
116 quiet_cmd_db2pdf = PDF $@
117 cmd_db2pdf = $(subst TYPE,pdf, $($(PDF_METHOD)template))
123 main_idx = doc/DocBook/$(index)
124 build_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)
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
132 quiet_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>' > $@
138 @(which xmlto > /dev/null 2>&1) || \
139 (echo "*** You need to install xmlto ***"; \
141 @rm -rf $@ $(patsubst %.html,%,$@)
143 @if [ ! -z "$(PNG-$(basename $(notdir $@)))" ]; then \
144 cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
146 quiet_cmd_db2man = MAN $@
147 cmd_db2man = if grep -q refentry $<; then xmlto man $(XMLTOFLAGS) -o $(obj)/man $< ; gzip -f $(obj)/man/*.9; fi
149 @(which xmlto > /dev/null 2>&1) || \
150 (echo "*** You need to install xmlto ***"; \
152 $(Q)mkdir -p $(obj)/man
157 # Rules to generate postscripts and PNG images from .fig format files
158 quiet_cmd_fig2eps = FIG2EPS $@
159 cmd_fig2eps = fig2dev -Leps $< $@
162 @(which fig2dev > /dev/null 2>&1) || \
163 (echo "*** You need to install transfig ***"; \
167 quiet_cmd_fig2png = FIG2PNG $@
168 cmd_fig2png = fig2dev -Lpng $< $@
171 @(which fig2dev > /dev/null 2>&1) || \
172 (echo "*** You need to install transfig ***"; \
177 # Rule to convert a .c file to inline XML documentation
179 quiet_gen_xml = echo ' GEN $@'
184 echo "<programlisting>"; \
185 expand --tabs=8 < $< | \
186 sed -e "s/&/\\&/g" \
189 echo "</programlisting>") > $@
192 # Help targets as used by the top-level makefile
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'
204 # Temporary files left by various tools
205 clean-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)) \
217 clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS)) man
221 @$(Q)rm -f $(call objectify, $(clean-files))
222 @$(Q)rm -rf $(call objectify, $(clean-dirs))
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.