[media] DocBook/frontend.xml: Better document fe_type_t
[linux-2.6.git] / Documentation / DocBook / media / Makefile
1 ###
2 # Media build rules - Auto-generates media contents/indexes and *.h xml's
3 #
4
5 SHELL=/bin/bash
6
7 MEDIA_OBJ_DIR=$(objtree)/Documentation/DocBook/
8 MEDIA_SRC_DIR=$(srctree)/Documentation/DocBook/media
9
10 MEDIA_TEMP =  media-entities.tmpl \
11               media-indices.tmpl \
12               videodev2.h.xml \
13               v4l2.xml \
14               frontend.h.xml
15
16 IMGFILES := $(addprefix $(MEDIA_OBJ_DIR)/media/, $(notdir $(shell ls $(MEDIA_SRC_DIR)/*/*.gif $(MEDIA_SRC_DIR)/*/*.png)))
17 GENFILES := $(addprefix $(MEDIA_OBJ_DIR)/, $(MEDIA_TEMP))
18
19 PHONY += cleanmediadocs mediaindexdocs
20
21 cleanmediadocs:
22         -@rm `find $(MEDIA_OBJ_DIR) -type l` $(GENFILES) $(IMGFILES)
23
24 $(obj)/media_api.xml: $(GENFILES) FORCE
25
26 #$(MEDIA_OBJ_DIR)/media_api.html: $(MEDIA_OBJ_DIR)/media_api.xml
27 #$(MEDIA_OBJ_DIR)/media_api.pdf: $(MEDIA_OBJ_DIR)/media_api.xml
28 #$(MEDIA_OBJ_DIR)/media_api.ps: $(MEDIA_OBJ_DIR)/media_api.xml
29
30 V4L_SGMLS = \
31         $(shell ls $(MEDIA_SRC_DIR)/v4l/*.xml|perl -ne 'print "$$1 " if (m,.*/(.*)\n,)') \
32         capture.c.xml \
33         keytable.c.xml \
34         v4l2grab.c.xml
35
36 DVB_SGMLS = \
37         $(shell ls $(MEDIA_SRC_DIR)/dvb/*.xml|perl -ne 'print "$$1 " if (m,.*/(.*)\n,)')
38
39 MEDIA_SGMLS =  $(addprefix ./,$(V4L_SGMLS)) $(addprefix ./,$(DVB_SGMLS)) $(addprefix ./,$(MEDIA_TEMP))
40
41 FUNCS = \
42         close \
43         ioctl \
44         mmap \
45         munmap \
46         open \
47         poll \
48         read \
49         select \
50         write \
51
52 IOCTLS = \
53         $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/videodev2.h) \
54         $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/frontend.h) \
55         $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/media.h) \
56         $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/v4l2-subdev.h) \
57         VIDIOC_SUBDEV_G_FRAME_INTERVAL \
58         VIDIOC_SUBDEV_S_FRAME_INTERVAL \
59         VIDIOC_SUBDEV_ENUM_MBUS_CODE \
60         VIDIOC_SUBDEV_ENUM_FRAME_SIZE \
61         VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL \
62
63 TYPES = \
64         $(shell perl -ne 'print "$$1 " if /^typedef\s+[^\s]+\s+([^\s]+)\;/' $(srctree)/include/linux/videodev2.h) \
65         $(shell perl -ne 'print "$$1 " if /^}\s+([a-z0-9_]+_t)/' $(srctree)/include/linux/dvb/frontend.h)
66
67 ENUMS = \
68         $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/videodev2.h) \
69         $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/frontend.h) \
70         $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/media.h) \
71         $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-mediabus.h) \
72         $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-subdev.h)
73
74 STRUCTS = \
75         $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/videodev2.h) \
76         $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/frontend.h) \
77         $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/media.h) \
78         $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-subdev.h) \
79         $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-mediabus.h)
80
81 ERRORS = \
82         EACCES \
83         EAGAIN \
84         EBADF \
85         EBUSY \
86         EFAULT \
87         EIO \
88         EINTR \
89         EINVAL \
90         ENFILE \
91         ENOMEM \
92         ENOSPC \
93         ENOTTY \
94         ENXIO \
95         EMFILE \
96         EPERM \
97         ERANGE \
98         EPIPE \
99
100 ESCAPE = \
101         -e "s/&/\\&/g" \
102         -e "s/</\\&lt;/g" \
103         -e "s/>/\\&gt;/g"
104
105 FILENAME = \
106         -e s,"^[^\/]*/",, \
107         -e s/"\\.xml"// \
108         -e s/"\\.tmpl"// \
109         -e s/\\\./-/g \
110         -e s/"^func-"// \
111         -e s/"^pixfmt-"// \
112         -e s/"^vidioc-"//
113
114 # Generate references to these structs in videodev2.h.xml.
115 DOCUMENTED = \
116         -e "s/\(enum *\)v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1<link linkend=\"\2\">v4l2_mpeg_cx2341x_video_\2<\/link>/g" \
117         -e "s/\(\(enum\|struct\) *\)\(v4l2_[a-zA-Z0-9_]*\)/\1<link linkend=\"\3\">\3<\/link>/g" \
118         -e "s/\(V4L2_PIX_FMT_[A-Z0-9_]\+\) /<link linkend=\"\1\">\1<\/link> /g" \
119         -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
120         -e "s/v4l2\-mpeg\-vbi\-ITV0/v4l2-mpeg-vbi-itv0-1/g"
121
122 DVB_DOCUMENTED = \
123         -e "s,\(define\s\+\)\([A-Z0-9_]\+\)\(\s\+_IO\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
124         -e "s/\(linkend\=\"\)FE_SET_PROPERTY/\1FE_GET_PROPERTY/g" \
125         -e "s,\(struct\s\+\)\([a-z0-9_]\+\)\(\s\+{\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
126         -e "s,\(}\s\+\)\([a-z0-9_]\+_t\+\),\1\<link linkend=\"\2\">\2\<\/link\>,g" \
127         -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
128 #       -e "s,\(\s\+\)\(FE_[A-Z0-9_]\+\)\([\s\=\,]*\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
129
130 #
131 # Media targets and dependencies
132 #
133
134 $(MEDIA_OBJ_DIR)/v4l2.xml:
135         @$($(quiet)gen_xml)
136         @(mkdir -p $(MEDIA_OBJ_DIR)/media)
137         @(cp $(MEDIA_SRC_DIR)/dvb/*.png $(MEDIA_SRC_DIR)/v4l/*.gif $(MEDIA_OBJ_DIR)/media/)
138         @(ln -sf $(MEDIA_SRC_DIR)/v4l/*xml $(MEDIA_OBJ_DIR)/)
139         @(ln -sf $(MEDIA_SRC_DIR)/dvb/*xml $(MEDIA_OBJ_DIR)/)
140
141 $(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/linux/videodev2.h $(MEDIA_OBJ_DIR)/v4l2.xml
142         @$($(quiet)gen_xml)
143         @(                                      \
144         echo "<programlisting>") > $@
145         @(                                      \
146         expand --tabs=8 < $< |                  \
147           sed $(ESCAPE) $(DOCUMENTED) |         \
148           sed 's/i\.e\./&ie;/') >> $@
149         @(                                      \
150         echo "</programlisting>") >> $@
151
152 $(MEDIA_OBJ_DIR)/frontend.h.xml: $(srctree)/include/linux/dvb/frontend.h $(MEDIA_OBJ_DIR)/v4l2.xml
153         @$($(quiet)gen_xml)
154         @(                                      \
155         echo "<programlisting>") > $@
156         @(                                      \
157         expand --tabs=8 < $< |                  \
158           sed $(ESCAPE) $(DVB_DOCUMENTED) |     \
159           sed 's/i\.e\./&ie;/') >> $@
160         @(                                      \
161         echo "</programlisting>") >> $@
162
163 $(MEDIA_OBJ_DIR)/media-entities.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
164         @$($(quiet)gen_xml)
165         @(                                                              \
166         echo "<!-- Generated file! Do not edit. -->") >$@
167         @(                                                              \
168         echo -e "\n<!-- Functions -->") >>$@
169         @(                                                              \
170         for ident in $(FUNCS) ; do                                      \
171           entity=`echo $$ident | tr _ -` ;                              \
172           echo "<!ENTITY func-$$entity \"<link"                         \
173             "linkend='func-$$entity'><function>$$ident()</function></link>\">" \
174           >>$@ ;                                                        \
175         done)
176         @(                                                              \
177         echo -e "\n<!-- Ioctls -->") >>$@
178         @(                                                              \
179         for ident in $(IOCTLS) ; do                                     \
180           entity=`echo $$ident | tr _ -` ;                              \
181           id=`grep "<refname>$$ident" $(MEDIA_OBJ_DIR)/vidioc-*.xml | sed -r s,"^.*/(.*).xml.*","\1",` ; \
182           echo "<!ENTITY $$entity \"<link"                              \
183             "linkend='$$id'><constant>$$ident</constant></link>\">"     \
184           >>$@ ;                                                        \
185         done)
186         @(                                                              \
187         echo -e "\n<!-- Types -->") >>$@
188         @(                                                              \
189         for ident in $(TYPES) ; do                                      \
190           entity=`echo $$ident | tr _ -` ;                              \
191           echo "<!ENTITY $$entity \"<link"                              \
192             "linkend='$$entity'>$$ident</link>\">" >>$@ ;               \
193         done)
194         @(                                                              \
195         echo -e "\n<!-- Enums -->") >>$@
196         @(                                                              \
197         for ident in $(ENUMS) ; do                                      \
198           entity=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -` ; \
199           echo "<!ENTITY $$entity \"enum&nbsp;<link"                    \
200             "linkend='$$entity'>$$ident</link>\">" >>$@ ;               \
201         done)
202         @(                                                              \
203         echo -e "\n<!-- Structures -->") >>$@
204         @(                                                              \
205         for ident in $(STRUCTS) ; do                                    \
206           entity=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
207           echo "<!ENTITY $$entity \"struct&nbsp;<link"                  \
208             "linkend='$$entity'>$$ident</link>\">" >>$@ ;               \
209         done)
210         @(                                                              \
211         echo -e "\n<!-- Error Codes -->") >>$@
212         @(                                                              \
213         for ident in $(ERRORS) ; do                                     \
214           echo "<!ENTITY $$ident \"<errorcode>$$ident</errorcode>"      \
215             "error code\">" >>$@ ;                                      \
216         done)
217         @(                                                              \
218         echo -e "\n<!-- Subsections -->") >>$@
219         @(                                                              \
220         for file in $(MEDIA_SGMLS) ; do                                 \
221           entity=`echo "$$file" | sed $(FILENAME) -e s/"^([^-]*)"/sub\1/` ; \
222           if ! echo "$$file" |                                          \
223             grep -q -E -e '^(func|vidioc|pixfmt)-' ; then               \
224             echo "<!ENTITY sub-$$entity SYSTEM \"$$file\">" >>$@ ;      \
225           fi ;                                                          \
226         done)
227         @(                                                              \
228         echo -e "\n<!-- Function Reference -->") >>$@
229         @(                                                              \
230         for file in $(MEDIA_SGMLS) ; do                                 \
231           if echo "$$file" |                                            \
232             grep -q -E -e '(func|vidioc|pixfmt)-' ; then                \
233             entity=`echo "$$file" |sed $(FILENAME)` ;                   \
234             echo "<!ENTITY $$entity SYSTEM \"$$file\">" >>$@ ;  \
235           fi ;                                                          \
236         done)
237
238 # Jade can auto-generate a list-of-tables, which includes all structs,
239 # but we only want data types, all types, and sorted please.
240 $(MEDIA_OBJ_DIR)/media-indices.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
241         @$($(quiet)gen_xml)
242         @(                                                              \
243         echo "<!-- Generated file! Do not edit. -->") >$@
244         @(                                                              \
245         echo -e "\n<index><title>List of Types</title>") >>$@
246         @(                                                              \
247         for ident in $(TYPES) ; do                                      \
248           id=`echo $$ident | tr _ -` ;                                  \
249           echo "<indexentry><primaryie><link"                           \
250             "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
251         done)
252         @(                                                              \
253         for ident in $(ENUMS) ; do                                      \
254           id=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -`; \
255           echo "<indexentry><primaryie>enum&nbsp;<link"                 \
256             "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
257         done)
258         @(                                                              \
259         for ident in $(STRUCTS) ; do                                    \
260           id=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
261           echo "<indexentry><primaryie>struct&nbsp;<link"               \
262             "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
263         done)
264         @(                                                              \
265         echo "</index>") >>$@
266