blob: f2216b05b2d55cd5a5b250e5585e44fcf9945461 [file] [log] [blame]
Mauro Carvalho Chehab42661292011-05-31 16:27:44 -03001###
2# Media build rules - Auto-generates media contents/indexes and *.h xml's
3#
4
5SHELL=/bin/bash
6
7MEDIA_OBJ_DIR=$(objtree)/Documentation/DocBook/
8MEDIA_SRC_DIR=$(srctree)/Documentation/DocBook/media
9
10MEDIA_TEMP = media-entities.tmpl \
11 media-indices.tmpl \
12 videodev2.h.xml \
13 v4l2.xml \
14 frontend.h.xml
15
16IMGFILES := $(addprefix $(MEDIA_OBJ_DIR)/media/, $(notdir $(shell ls $(MEDIA_SRC_DIR)/*/*.gif $(MEDIA_SRC_DIR)/*/*.png)))
17GENFILES := $(addprefix $(MEDIA_OBJ_DIR)/, $(MEDIA_TEMP))
18
19PHONY += cleanmediadocs mediaindexdocs
20
21cleanmediadocs:
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
30V4L_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
36DVB_SGMLS = \
37 $(shell ls $(MEDIA_SRC_DIR)/dvb/*.xml|perl -ne 'print "$$1 " if (m,.*/(.*)\n,)')
38
39MEDIA_SGMLS = $(addprefix ./,$(V4L_SGMLS)) $(addprefix ./,$(DVB_SGMLS)) $(addprefix ./,$(MEDIA_TEMP))
40
41FUNCS = \
42 close \
43 ioctl \
44 mmap \
45 munmap \
46 open \
47 poll \
48 read \
49 select \
50 write \
51
52IOCTLS = \
53 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/videodev2.h) \
Mauro Carvalho Chehab98a2b602011-06-07 14:51:56 -030054 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/frontend.h) \
Mauro Carvalho Chehab42661292011-05-31 16:27:44 -030055 $(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
63TYPES = \
Mauro Carvalho Chehab98a2b602011-06-07 14:51:56 -030064 $(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)
Mauro Carvalho Chehab42661292011-05-31 16:27:44 -030066
67ENUMS = \
68 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/videodev2.h) \
Mauro Carvalho Chehab98a2b602011-06-07 14:51:56 -030069 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/frontend.h) \
Mauro Carvalho Chehab42661292011-05-31 16:27:44 -030070 $(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
74STRUCTS = \
75 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/videodev2.h) \
Mauro Carvalho Chehab98a2b602011-06-07 14:51:56 -030076 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/frontend.h) \
Mauro Carvalho Chehab42661292011-05-31 16:27:44 -030077 $(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
81ERRORS = \
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
100ESCAPE = \
101 -e "s/&/\\&/g" \
102 -e "s/</\\&lt;/g" \
103 -e "s/>/\\&gt;/g"
104
105FILENAME = \
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.
115DOCUMENTED = \
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
122DVB_DOCUMENTED = \
Mauro Carvalho Chehab98a2b602011-06-07 14:51:56 -0300123 -e "s/\(linkend\=\"\)FE_SET_PROPERTY/\1FE_GET_PROPERTY/g" \
124 -e "s,\(struct\s\+\)\([a-z0-9_]\+\)\(\s\+{\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
125 -e "s,\(}\s\+\)\([a-z0-9_]\+_t\+\),\1\<link linkend=\"\2\">\2\<\/link\>,g" \
Mauro Carvalho Chehab95e61e02011-06-07 16:58:00 -0300126 -e "s,\(define\s\+\)\(DTV_[A-Z0-9_]\+\)\(\s\+[0-9]\+\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
Mauro Carvalho Chehabd5dc2de2011-06-07 16:17:00 -0300127 -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
Mauro Carvalho Chehab95e61e02011-06-07 16:58:00 -0300128 -e "s,DTV-ISDBT-LAYER[A-C],DTV-ISDBT-LAYER,g" \
Mauro Carvalho Chehab6cb77a82011-06-07 17:58:59 -0300129 -e "s,\(define\s\+\)\([A-Z0-9_]\+\)\(\s\+_IO\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
Mauro Carvalho Chehab98a2b602011-06-07 14:51:56 -0300130# -e "s,\(\s\+\)\(FE_[A-Z0-9_]\+\)\([\s\=\,]*\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
Mauro Carvalho Chehab42661292011-05-31 16:27:44 -0300131
132#
133# Media targets and dependencies
134#
135
136$(MEDIA_OBJ_DIR)/v4l2.xml:
137 @$($(quiet)gen_xml)
138 @(mkdir -p $(MEDIA_OBJ_DIR)/media)
139 @(cp $(MEDIA_SRC_DIR)/dvb/*.png $(MEDIA_SRC_DIR)/v4l/*.gif $(MEDIA_OBJ_DIR)/media/)
140 @(ln -sf $(MEDIA_SRC_DIR)/v4l/*xml $(MEDIA_OBJ_DIR)/)
141 @(ln -sf $(MEDIA_SRC_DIR)/dvb/*xml $(MEDIA_OBJ_DIR)/)
142
143$(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/linux/videodev2.h $(MEDIA_OBJ_DIR)/v4l2.xml
144 @$($(quiet)gen_xml)
145 @( \
146 echo "<programlisting>") > $@
147 @( \
148 expand --tabs=8 < $< | \
149 sed $(ESCAPE) $(DOCUMENTED) | \
150 sed 's/i\.e\./&ie;/') >> $@
151 @( \
152 echo "</programlisting>") >> $@
153
154$(MEDIA_OBJ_DIR)/frontend.h.xml: $(srctree)/include/linux/dvb/frontend.h $(MEDIA_OBJ_DIR)/v4l2.xml
155 @$($(quiet)gen_xml)
156 @( \
157 echo "<programlisting>") > $@
158 @( \
159 expand --tabs=8 < $< | \
160 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
161 sed 's/i\.e\./&ie;/') >> $@
162 @( \
163 echo "</programlisting>") >> $@
164
165$(MEDIA_OBJ_DIR)/media-entities.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
166 @$($(quiet)gen_xml)
167 @( \
168 echo "<!-- Generated file! Do not edit. -->") >$@
169 @( \
170 echo -e "\n<!-- Functions -->") >>$@
171 @( \
172 for ident in $(FUNCS) ; do \
173 entity=`echo $$ident | tr _ -` ; \
174 echo "<!ENTITY func-$$entity \"<link" \
175 "linkend='func-$$entity'><function>$$ident()</function></link>\">" \
176 >>$@ ; \
177 done)
178 @( \
179 echo -e "\n<!-- Ioctls -->") >>$@
180 @( \
181 for ident in $(IOCTLS) ; do \
182 entity=`echo $$ident | tr _ -` ; \
183 id=`grep "<refname>$$ident" $(MEDIA_OBJ_DIR)/vidioc-*.xml | sed -r s,"^.*/(.*).xml.*","\1",` ; \
184 echo "<!ENTITY $$entity \"<link" \
185 "linkend='$$id'><constant>$$ident</constant></link>\">" \
186 >>$@ ; \
187 done)
188 @( \
189 echo -e "\n<!-- Types -->") >>$@
190 @( \
191 for ident in $(TYPES) ; do \
192 entity=`echo $$ident | tr _ -` ; \
193 echo "<!ENTITY $$entity \"<link" \
194 "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
195 done)
196 @( \
197 echo -e "\n<!-- Enums -->") >>$@
198 @( \
199 for ident in $(ENUMS) ; do \
200 entity=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -` ; \
201 echo "<!ENTITY $$entity \"enum&nbsp;<link" \
202 "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
203 done)
204 @( \
205 echo -e "\n<!-- Structures -->") >>$@
206 @( \
207 for ident in $(STRUCTS) ; do \
208 entity=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
209 echo "<!ENTITY $$entity \"struct&nbsp;<link" \
210 "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
211 done)
212 @( \
213 echo -e "\n<!-- Error Codes -->") >>$@
214 @( \
215 for ident in $(ERRORS) ; do \
216 echo "<!ENTITY $$ident \"<errorcode>$$ident</errorcode>" \
217 "error code\">" >>$@ ; \
218 done)
219 @( \
220 echo -e "\n<!-- Subsections -->") >>$@
221 @( \
222 for file in $(MEDIA_SGMLS) ; do \
223 entity=`echo "$$file" | sed $(FILENAME) -e s/"^([^-]*)"/sub\1/` ; \
224 if ! echo "$$file" | \
225 grep -q -E -e '^(func|vidioc|pixfmt)-' ; then \
226 echo "<!ENTITY sub-$$entity SYSTEM \"$$file\">" >>$@ ; \
227 fi ; \
228 done)
229 @( \
230 echo -e "\n<!-- Function Reference -->") >>$@
231 @( \
232 for file in $(MEDIA_SGMLS) ; do \
233 if echo "$$file" | \
234 grep -q -E -e '(func|vidioc|pixfmt)-' ; then \
235 entity=`echo "$$file" |sed $(FILENAME)` ; \
236 echo "<!ENTITY $$entity SYSTEM \"$$file\">" >>$@ ; \
237 fi ; \
238 done)
239
240# Jade can auto-generate a list-of-tables, which includes all structs,
241# but we only want data types, all types, and sorted please.
242$(MEDIA_OBJ_DIR)/media-indices.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
243 @$($(quiet)gen_xml)
244 @( \
245 echo "<!-- Generated file! Do not edit. -->") >$@
246 @( \
247 echo -e "\n<index><title>List of Types</title>") >>$@
248 @( \
249 for ident in $(TYPES) ; do \
250 id=`echo $$ident | tr _ -` ; \
251 echo "<indexentry><primaryie><link" \
252 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
253 done)
254 @( \
255 for ident in $(ENUMS) ; do \
256 id=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -`; \
257 echo "<indexentry><primaryie>enum&nbsp;<link" \
258 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
259 done)
260 @( \
261 for ident in $(STRUCTS) ; do \
262 id=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
263 echo "<indexentry><primaryie>struct&nbsp;<link" \
264 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
265 done)
266 @( \
267 echo "</index>") >>$@
268