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