[media] DocBook/Makefile: add references for several dvb structures
[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 "s,\(\s\+\)\(FE_[A-Z0-9_]\+\)\([\s\=\,]*\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
128
129 #
130 # Media targets and dependencies
131 #
132
133 $(MEDIA_OBJ_DIR)/v4l2.xml:
134         @$($(quiet)gen_xml)
135         @(mkdir -p $(MEDIA_OBJ_DIR)/media)
136         @(cp $(MEDIA_SRC_DIR)/dvb/*.png $(MEDIA_SRC_DIR)/v4l/*.gif $(MEDIA_OBJ_DIR)/media/)
137         @(ln -sf $(MEDIA_SRC_DIR)/v4l/*xml $(MEDIA_OBJ_DIR)/)
138         @(ln -sf $(MEDIA_SRC_DIR)/dvb/*xml $(MEDIA_OBJ_DIR)/)
139
140 $(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/linux/videodev2.h $(MEDIA_OBJ_DIR)/v4l2.xml
141         @$($(quiet)gen_xml)
142         @(                                      \
143         echo "<programlisting>") > $@
144         @(                                      \
145         expand --tabs=8 < $< |                  \
146           sed $(ESCAPE) $(DOCUMENTED) |         \
147           sed 's/i\.e\./&ie;/') >> $@
148         @(                                      \
149         echo "</programlisting>") >> $@
150
151 $(MEDIA_OBJ_DIR)/frontend.h.xml: $(srctree)/include/linux/dvb/frontend.h $(MEDIA_OBJ_DIR)/v4l2.xml
152         @$($(quiet)gen_xml)
153         @(                                      \
154         echo "<programlisting>") > $@
155         @(                                      \
156         expand --tabs=8 < $< |                  \
157           sed $(ESCAPE) $(DVB_DOCUMENTED) |     \
158           sed 's/i\.e\./&ie;/') >> $@
159         @(                                      \
160         echo "</programlisting>") >> $@
161
162 $(MEDIA_OBJ_DIR)/media-entities.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
163         @$($(quiet)gen_xml)
164         @(                                                              \
165         echo "<!-- Generated file! Do not edit. -->") >$@
166         @(                                                              \
167         echo -e "\n<!-- Functions -->") >>$@
168         @(                                                              \
169         for ident in $(FUNCS) ; do                                      \
170           entity=`echo $$ident | tr _ -` ;                              \
171           echo "<!ENTITY func-$$entity \"<link"                         \
172             "linkend='func-$$entity'><function>$$ident()</function></link>\">" \
173           >>$@ ;                                                        \
174         done)
175         @(                                                              \
176         echo -e "\n<!-- Ioctls -->") >>$@
177         @(                                                              \
178         for ident in $(IOCTLS) ; do                                     \
179           entity=`echo $$ident | tr _ -` ;                              \
180           id=`grep "<refname>$$ident" $(MEDIA_OBJ_DIR)/vidioc-*.xml | sed -r s,"^.*/(.*).xml.*","\1",` ; \
181           echo "<!ENTITY $$entity \"<link"                              \
182             "linkend='$$id'><constant>$$ident</constant></link>\">"     \
183           >>$@ ;                                                        \
184         done)
185         @(                                                              \
186         echo -e "\n<!-- Types -->") >>$@
187         @(                                                              \
188         for ident in $(TYPES) ; do                                      \
189           entity=`echo $$ident | tr _ -` ;                              \
190           echo "<!ENTITY $$entity \"<link"                              \
191             "linkend='$$entity'>$$ident</link>\">" >>$@ ;               \
192         done)
193         @(                                                              \
194         echo -e "\n<!-- Enums -->") >>$@
195         @(                                                              \
196         for ident in $(ENUMS) ; do                                      \
197           entity=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -` ; \
198           echo "<!ENTITY $$entity \"enum&nbsp;<link"                    \
199             "linkend='$$entity'>$$ident</link>\">" >>$@ ;               \
200         done)
201         @(                                                              \
202         echo -e "\n<!-- Structures -->") >>$@
203         @(                                                              \
204         for ident in $(STRUCTS) ; do                                    \
205           entity=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
206           echo "<!ENTITY $$entity \"struct&nbsp;<link"                  \
207             "linkend='$$entity'>$$ident</link>\">" >>$@ ;               \
208         done)
209         @(                                                              \
210         echo -e "\n<!-- Error Codes -->") >>$@
211         @(                                                              \
212         for ident in $(ERRORS) ; do                                     \
213           echo "<!ENTITY $$ident \"<errorcode>$$ident</errorcode>"      \
214             "error code\">" >>$@ ;                                      \
215         done)
216         @(                                                              \
217         echo -e "\n<!-- Subsections -->") >>$@
218         @(                                                              \
219         for file in $(MEDIA_SGMLS) ; do                                 \
220           entity=`echo "$$file" | sed $(FILENAME) -e s/"^([^-]*)"/sub\1/` ; \
221           if ! echo "$$file" |                                          \
222             grep -q -E -e '^(func|vidioc|pixfmt)-' ; then               \
223             echo "<!ENTITY sub-$$entity SYSTEM \"$$file\">" >>$@ ;      \
224           fi ;                                                          \
225         done)
226         @(                                                              \
227         echo -e "\n<!-- Function Reference -->") >>$@
228         @(                                                              \
229         for file in $(MEDIA_SGMLS) ; do                                 \
230           if echo "$$file" |                                            \
231             grep -q -E -e '(func|vidioc|pixfmt)-' ; then                \
232             entity=`echo "$$file" |sed $(FILENAME)` ;                   \
233             echo "<!ENTITY $$entity SYSTEM \"$$file\">" >>$@ ;  \
234           fi ;                                                          \
235         done)
236
237 # Jade can auto-generate a list-of-tables, which includes all structs,
238 # but we only want data types, all types, and sorted please.
239 $(MEDIA_OBJ_DIR)/media-indices.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
240         @$($(quiet)gen_xml)
241         @(                                                              \
242         echo "<!-- Generated file! Do not edit. -->") >$@
243         @(                                                              \
244         echo -e "\n<index><title>List of Types</title>") >>$@
245         @(                                                              \
246         for ident in $(TYPES) ; do                                      \
247           id=`echo $$ident | tr _ -` ;                                  \
248           echo "<indexentry><primaryie><link"                           \
249             "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
250         done)
251         @(                                                              \
252         for ident in $(ENUMS) ; do                                      \
253           id=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -`; \
254           echo "<indexentry><primaryie>enum&nbsp;<link"                 \
255             "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
256         done)
257         @(                                                              \
258         for ident in $(STRUCTS) ; do                                    \
259           id=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
260           echo "<indexentry><primaryie>struct&nbsp;<link"               \
261             "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
262         done)
263         @(                                                              \
264         echo "</index>") >>$@
265