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
:= wanbook.xml z8530book.xml mcabook.xml videobook.xml \
10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \
11 procfs-guide.xml writing_usb_driver.xml \
12 kernel-api.xml journal-api.xml lsm.xml usb.xml \
13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
17 # The build process is as follows (targets):
19 # file.tmpl --> file.xml +--> file.ps (psdocs)
20 # +--> file.pdf (pdfdocs)
21 # +--> DIR=file (htmldocs)
25 # for PDF and PS output you can choose between xmlto and docbook-utils tools
26 PDF_METHOD
= $(prefer-db2x
)
27 PS_METHOD
= $(prefer-db2x
)
31 # The targets that may be used.
32 PHONY
+= xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs
34 BOOKS
:= $(addprefix $(obj
)/,$(DOCBOOKS
))
38 PS
:= $(patsubst %.xml
, %.ps
, $(BOOKS
))
41 PDF
:= $(patsubst %.xml
, %.pdf
, $(BOOKS
))
44 HTML
:= $(patsubst %.xml
, %.html
, $(BOOKS
))
47 MAN
:= $(patsubst %.xml
, %.9, $(BOOKS
))
50 installmandocs
: mandocs
51 mkdir
-p
/usr
/local
/man
/man9
/
52 install Documentation
/DocBook
/man
/*.9.gz
/usr
/local
/man
/man9
/
55 #External programs used
56 KERNELDOC
= scripts
/kernel-doc
57 DOCPROC
= scripts
/basic
/docproc
59 XMLTOFLAGS
= -m
$(srctree
)/Documentation
/DocBook
/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
82 $(call if_changed_rule
,docproc
)
85 #Read in all saved dependency files
86 cmd_files
:= $(wildcard $(foreach f
,$(BOOKS
),$(dir $(f
)).
$(notdir $(f
)).cmd
))
93 # Changes in kernel-doc force a rebuild of all documentation
94 $(BOOKS
): $(KERNELDOC
)
97 # procfs guide uses a .c file as example code.
98 # This requires an explicit dependency
99 C-procfs-example
= procfs_example.xml
100 C-procfs-example2
= $(addprefix $(obj
)/,$(C-procfs-example
))
101 $(obj
)/procfs-guide.xml
: $(C-procfs-example2
)
103 notfoundtemplate
= echo
"*** You have to install docbook-utils or xmlto ***"; \
105 db2xtemplate
= db2TYPE
-o
$(dir $@
) $<
106 xmltotemplate
= xmlto TYPE
$(XMLTOFLAGS
) -o
$(dir $@
) $<
108 # determine which methods are available
109 ifeq ($(shell which db2ps
>/dev
/null
2>&1 && echo found
),found
)
114 prefer-db2x
= $(use-xmlto
)
116 ifeq ($(shell which xmlto
>/dev
/null
2>&1 && echo found
),found
)
121 prefer-xmlto
= $(use-db2x
)
124 # the commands, generated from the chosen template
125 quiet_cmd_db2ps
= PS
$@
126 cmd_db2ps
= $(subst TYPE
,ps
, $($(PS_METHOD
)template
))
130 quiet_cmd_db2pdf
= PDF
$@
131 cmd_db2pdf
= $(subst TYPE
,pdf
, $($(PDF_METHOD
)template
))
135 quiet_cmd_db2html
= HTML
$@
136 cmd_db2html
= xmlto xhtml
$(XMLTOFLAGS
) -o
$(patsubst %.html
,%,$@
) $< && \
137 echo
'<a HREF="$(patsubst %.html,%,$(notdir $@))/index.html"> \
138 Goto $(patsubst %.html,%,$(notdir $@))</a><p>' > $@
141 @
(which xmlto
> /dev
/null
2>&1) || \
142 (echo
"*** You need to install xmlto ***"; \
144 @
rm -rf
$@
$(patsubst %.html
,%,$@
)
146 @if
[ ! -z
"$(PNG-$(basename $(notdir $@)))" ]; then \
147 cp
$(PNG-
$(basename $(notdir $@
))) $(patsubst %.html
,%,$@
); fi
149 quiet_cmd_db2man
= MAN
$@
150 cmd_db2man
= if grep
-q refentry
$<; then xmlto man
$(XMLTOFLAGS
) -o
$(obj
)/man
$< ; gzip
-f
$(obj
)/man
/*.9; fi
152 @
(which xmlto
> /dev
/null
2>&1) || \
153 (echo
"*** You need to install xmlto ***"; \
159 # Rules to generate postscripts and PNG imgages from .fig format files
160 quiet_cmd_fig2eps
= FIG2EPS
$@
161 cmd_fig2eps
= fig2dev
-Leps
$< $@
164 @
(which fig2dev
> /dev
/null
2>&1) || \
165 (echo
"*** You need to install transfig ***"; \
169 quiet_cmd_fig2png
= FIG2PNG
$@
170 cmd_fig2png
= fig2dev
-Lpng
$< $@
173 @
(which fig2dev
> /dev
/null
2>&1) || \
174 (echo
"*** You need to install transfig ***"; \
179 # Rule to convert a .c file to inline XML documentation
183 echo
"<programlisting>"; \
184 expand
--tabs
=8 < $< | \
185 sed
-e
"s/&/\\&/g" \
188 echo
"</programlisting>") > $@
191 # Help targets as used by the top-level makefile
193 @echo
' Linux kernel internal documentation in different formats:'
194 @echo
' xmldocs (XML DocBook), psdocs (Postscript), pdfdocs (PDF)'
195 @echo
' htmldocs (HTML), mandocs (man pages, use installmandocs to install)'
198 # Temporary files left by various tools
199 clean-files
:= $(DOCBOOKS
) \
200 $(patsubst %.xml
, %.
dvi, $(DOCBOOKS
)) \
201 $(patsubst %.xml
, %.aux
, $(DOCBOOKS
)) \
202 $(patsubst %.xml
, %.
tex, $(DOCBOOKS
)) \
203 $(patsubst %.xml
, %.log
, $(DOCBOOKS
)) \
204 $(patsubst %.xml
, %.out
, $(DOCBOOKS
)) \
205 $(patsubst %.xml
, %.ps
, $(DOCBOOKS
)) \
206 $(patsubst %.xml
, %.pdf
, $(DOCBOOKS
)) \
207 $(patsubst %.xml
, %.html
, $(DOCBOOKS
)) \
208 $(patsubst %.xml
, %.9, $(DOCBOOKS
)) \
211 clean-dirs
:= $(patsubst %.xml
,%,$(DOCBOOKS
))
213 #man put files in man subdir - traverse down
217 # Declare the contents of the .PHONY variable as phony. We keep that
218 # information in a variable se we can use it in if_changed and friends.