http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / kernel / linux / Documentation / DocBook / Makefile
1 ###
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 ducument 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
9 DOCBOOKS := wanbook.sgml z8530book.sgml mcabook.sgml videobook.sgml \
10             kernel-hacking.sgml kernel-locking.sgml via-audio.sgml \
11             mousedrivers.sgml deviceiobook.sgml procfs-guide.sgml \
12             tulip-user.sgml writing_usb_driver.sgml scsidrivers.sgml \
13             sis900.sgml kernel-api.sgml journal-api.sgml lsm.sgml usb.sgml \
14             gadget.sgml libata.sgml
15
16 ###
17 # The build process is as follows (targets):
18 #              (sgmldocs)
19 # file.tmpl --> file.sgml +--> file.ps  (psdocs)
20 #                         +--> file.pdf  (pdfdocs)
21 #                         +--> DIR=file  (htmldocs)
22 #                         +--> man/      (mandocs)
23
24 ###
25 # The targets that may be used.
26 .PHONY: sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs
27
28 BOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
29 sgmldocs: $(BOOKS)
30
31 PS := $(patsubst %.sgml, %.ps, $(BOOKS))
32 psdocs: $(PS)
33
34 PDF := $(patsubst %.sgml, %.pdf, $(BOOKS))
35 pdfdocs: $(PDF)
36
37 HTML := $(patsubst %.sgml, %.html, $(BOOKS))
38 htmldocs: $(HTML)
39
40 MAN := $(patsubst %.sgml, %.9, $(BOOKS))
41 mandocs: $(MAN)
42
43 installmandocs: mandocs
44         $(MAKEMAN) install Documentation/DocBook/man
45
46 ###
47 #External programs used
48 KERNELDOC = scripts/kernel-doc
49 DOCPROC   = scripts/basic/docproc
50 SPLITMAN  = $(PERL) $(srctree)/scripts/split-man
51 MAKEMAN   = $(PERL) $(srctree)/scripts/makeman
52
53 ###
54 # DOCPROC is used for two purposes:
55 # 1) To generate a dependency list for a .tmpl file
56 # 2) To preprocess a .tmpl file and call kernel-doc with
57 #     appropriate parameters.
58 # The following rules are used to generate the .sgml documentation
59 # required to generate the final targets. (ps, pdf, html).
60 quiet_cmd_docproc = DOCPROC $@
61       cmd_docproc = $(DOCPROC) doc $< >$@
62 define rule_docproc
63         set -e;                                                         \
64         $(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))';)         \
65         $(cmd_$(1));                                                    \
66         (                                                               \
67           echo 'cmd_$@ := $(cmd_$(1))';                                 \
68           echo $@: `$(DOCPROC) depend $<`;                              \
69         ) > $(dir $@).$(notdir $@).cmd
70 endef
71
72 %.sgml: %.tmpl FORCE
73         $(call if_changed_rule,docproc)
74
75 ###
76 #Read in all saved dependency files 
77 cmd_files := $(wildcard $(foreach f,$(BOOKS),$(dir $(f)).$(notdir $(f)).cmd))
78
79 ifneq ($(cmd_files),)
80   include $(cmd_files)
81 endif
82
83 ###
84 # Changes in kernel-doc force a rebuild of all documentation
85 $(BOOKS): $(KERNELDOC)
86
87 ###
88 # procfs guide uses a .c file as example code.
89 # This requires an explicit dependency
90 C-procfs-example = procfs_example.sgml
91 C-procfs-example2 = $(addprefix $(obj)/,$(C-procfs-example))
92 $(obj)/procfs-guide.sgml: $(C-procfs-example2)
93
94 ###
95 # Rules to generate postscript, PDF and HTML
96 # db2html creates a directory. Generate a html file used for timestamp
97
98 quiet_cmd_db2ps = DB2PS   $@
99       cmd_db2ps = db2ps -o $(dir $@) $<
100 %.ps : %.sgml
101         @(which db2ps > /dev/null 2>&1) || \
102          (echo "*** You need to install DocBook stylesheets ***"; \
103           exit 1)
104         $(call cmd,db2ps)
105
106 quiet_cmd_db2pdf = DB2PDF  $@
107       cmd_db2pdf = db2pdf -o $(dir $@) $<
108 %.pdf : %.sgml
109         @(which db2pdf > /dev/null 2>&1) || \
110          (echo "*** You need to install DocBook stylesheets ***"; \
111           exit 1)
112         $(call cmd,db2pdf)
113
114 quiet_cmd_db2html = DB2HTML $@
115       cmd_db2html = db2html -o $(patsubst %.html,%,$@) $< &&                  \
116                 echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/book1.html"> \
117          Goto $(patsubst %.html,%,$(notdir $@))</a><p>' > $@
118
119 %.html: %.sgml
120         @(which db2html > /dev/null 2>&1) || \
121          (echo "*** You need to install DocBook stylesheets ***"; \
122           exit 1)
123         @rm -rf $@ $(patsubst %.html,%,$@)
124         $(call cmd,db2html)
125         @if [ ! -z "$(PNG-$(basename $(notdir $@)))" ]; then \
126             cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
127
128 ###
129 # Rule to generate man files - output is placed in the man subdirectory
130
131 %.9:    %.sgml
132         $(SPLITMAN) $< $(objtree)/Documentation/DocBook/man "$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)"
133         $(MAKEMAN) convert $(objtree)/Documentation/DocBook/man $<
134
135 ###
136 # Rules to generate postscripts and PNG imgages from .fig format files
137 quiet_cmd_fig2eps = FIG2EPS $@
138       cmd_fig2eps = fig2dev -Leps $< $@
139
140 %.eps: %.fig
141         @(which fig2dev > /dev/null 2>&1) || \
142          (echo "*** You need to install transfig ***"; \
143           exit 1)
144         $(call cmd,fig2eps)
145
146 quiet_cmd_fig2png = FIG2PNG $@
147       cmd_fig2png = fig2dev -Lpng $< $@
148
149 %.png: %.fig
150         @(which fig2dev > /dev/null 2>&1) || \
151          (echo "*** You need to install transfig ***"; \
152           exit 1)
153         $(call cmd,fig2png)
154
155 ###
156 # Rule to convert a .c file to inline SGML documentation
157 %.sgml: %.c
158         @echo '  GEN     $@'
159         @(                            \
160            echo "<programlisting>";   \
161            expand --tabs=8 < $< |     \
162            sed -e "s/&/\\&amp;/g"     \
163                -e "s/</\\&lt;/g"      \
164                -e "s/>/\\&gt;/g";     \
165            echo "</programlisting>")  > $@
166
167 ###
168 # Help targets as used by the top-level makefile
169 dochelp:
170         @echo  '  Linux kernel internal documentation in different formats:'
171         @echo  '  sgmldocs (SGML), psdocs (Postscript), pdfdocs (PDF)'
172         @echo  '  htmldocs (HTML), mandocs (man pages, use installmandocs to install)'
173
174 ###
175 # Temporary files left by various tools
176 clean-files := $(DOCBOOKS) \
177         $(patsubst %.sgml, %.dvi,  $(DOCBOOKS)) \
178         $(patsubst %.sgml, %.aux,  $(DOCBOOKS)) \
179         $(patsubst %.sgml, %.tex,  $(DOCBOOKS)) \
180         $(patsubst %.sgml, %.log,  $(DOCBOOKS)) \
181         $(patsubst %.sgml, %.out,  $(DOCBOOKS)) \
182         $(patsubst %.sgml, %.ps,   $(DOCBOOKS)) \
183         $(patsubst %.sgml, %.pdf,  $(DOCBOOKS)) \
184         $(patsubst %.sgml, %.html, $(DOCBOOKS)) \
185         $(patsubst %.sgml, %.9,    $(DOCBOOKS)) \
186         $(C-procfs-example)
187
188 ifneq ($(wildcard $(patsubst %.html,%,$(HTML))),)
189 clean-rule := rm -rf $(wildcard $(patsubst %.html,%,$(HTML)))
190 endif
191
192 #man put files in man subdir - traverse down
193 subdir- := man/