2 # Media build rules - Auto-generates media contents/indexes and *.h xml's
7 MEDIA_OBJ_DIR
=$(objtree
)/Documentation
/DocBook
/
8 MEDIA_SRC_DIR
=$(srctree
)/Documentation
/DocBook
/media
10 MEDIA_TEMP
= media-entities.tmpl \
21 IMGFILES
:= $(patsubst %.b64
,%, $(notdir $(shell ls
$(MEDIA_SRC_DIR
)/*.b64
)))
22 OBJIMGFILES
:= $(addprefix $(MEDIA_OBJ_DIR
)/, $(IMGFILES
))
23 GENFILES
:= $(addprefix $(MEDIA_OBJ_DIR
)/, $(MEDIA_TEMP
))
25 PHONY
+= cleanmediadocs
28 -@
rm -f
`find $(MEDIA_OBJ_DIR) -type l` $(GENFILES
) $(OBJIMGFILES
) 2>/dev
/null
30 $(obj
)/media_api.xml
: $(GENFILES
) FORCE
32 #$(MEDIA_OBJ_DIR)/media_api.html: $(MEDIA_OBJ_DIR)/media_api.xml
33 #$(MEDIA_OBJ_DIR)/media_api.pdf: $(MEDIA_OBJ_DIR)/media_api.xml
34 #$(MEDIA_OBJ_DIR)/media_api.ps: $(MEDIA_OBJ_DIR)/media_api.xml
37 $(shell ls
$(MEDIA_SRC_DIR
)/v4l
/*.xml|perl
-ne
'print "$$1 " if (m,.*/(.*)\n,)') \
43 $(shell ls
$(MEDIA_SRC_DIR
)/dvb
/*.xml|perl
-ne
'print "$$1 " if (m,.*/(.*)\n,)')
45 MEDIA_SGMLS
= $(addprefix .
/,$(V4L_SGMLS
)) $(addprefix .
/,$(DVB_SGMLS
)) $(addprefix .
/,$(MEDIA_TEMP
))
59 $(shell perl
-ne
'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree
)/include/uapi
/linux
/videodev2.h
) \
60 $(shell perl
-ne
'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree
)/include/uapi
/linux
/dvb
/audio.h
) \
61 $(shell perl
-ne
'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree
)/include/uapi
/linux
/dvb
/ca.h
) \
62 $(shell perl
-ne
'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree
)/include/uapi
/linux
/dvb
/dmx.h
) \
63 $(shell perl
-ne
'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree
)/include/uapi
/linux
/dvb
/frontend.h
) \
64 $(shell perl
-ne
'print "$$1 " if /\#define\s+([A-Z][^\s]+)\s+_IO/' $(srctree
)/include/uapi
/linux
/dvb
/net.h
) \
65 $(shell perl
-ne
'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree
)/include/uapi
/linux
/dvb
/video.h
) \
66 $(shell perl
-ne
'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree
)/include/uapi
/linux
/media.h
) \
67 $(shell perl
-ne
'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree
)/include/uapi
/linux
/v4l2-subdev.h
) \
68 VIDIOC_SUBDEV_G_FRAME_INTERVAL \
69 VIDIOC_SUBDEV_S_FRAME_INTERVAL \
70 VIDIOC_SUBDEV_ENUM_MBUS_CODE \
71 VIDIOC_SUBDEV_ENUM_FRAME_SIZE \
72 VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL \
73 VIDIOC_SUBDEV_G_SELECTION \
74 VIDIOC_SUBDEV_S_SELECTION \
77 $(shell perl
-ne
'print "$$1 " if /^typedef\s+[^\s]+\s+([^\s]+)\;/' $(srctree
)/include/uapi
/linux
/videodev2.h
) \
78 $(shell perl
-ne
'print "$$1 " if /^}\s+([a-z0-9_]+_t)/' $(srctree
)/include/uapi
/linux
/dvb
/frontend.h
)
81 $(shell perl
-ne
'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/videodev2.h
) \
82 $(shell perl
-ne
'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/dvb
/audio.h
) \
83 $(shell perl
-ne
'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/dvb
/ca.h
) \
84 $(shell perl
-ne
'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/dvb
/dmx.h
) \
85 $(shell perl
-ne
'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/dvb
/frontend.h
) \
86 $(shell perl
-ne
'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/dvb
/net.h
) \
87 $(shell perl
-ne
'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/dvb
/video.h
) \
88 $(shell perl
-ne
'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/media.h
) \
89 $(shell perl
-ne
'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/v4l2-mediabus.h
) \
90 $(shell perl
-ne
'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/v4l2-subdev.h
)
93 $(shell perl
-ne
'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/videodev2.h
) \
94 $(shell perl
-ne
'print "$$1 " if (/^struct\s+([^\s\{]+)\s*/)' $(srctree
)/include/uapi
/linux
/dvb
/audio.h
) \
95 $(shell perl
-ne
'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree
)/include/uapi
/linux
/dvb
/ca.h
) \
96 $(shell perl
-ne
'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree
)/include/uapi
/linux
/dvb
/dmx.h
) \
97 $(shell perl
-ne
'print "$$1 " if (!/dtv\_cmds\_h/ && /^struct\s+([^\s]+)\s+/)' $(srctree
)/include/uapi
/linux
/dvb
/frontend.h
) \
98 $(shell perl
-ne
'print "$$1 " if (/^struct\s+([A-Z][^\s]+)\s+/)' $(srctree
)/include/uapi
/linux
/dvb
/net.h
) \
99 $(shell perl
-ne
'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree
)/include/uapi
/linux
/dvb
/video.h
) \
100 $(shell perl
-ne
'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/media.h
) \
101 $(shell perl
-ne
'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/v4l2-subdev.h
) \
102 $(shell perl
-ne
'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree
)/include/uapi
/linux
/v4l2-mediabus.h
)
173 # Generate references to these structs in videodev2.h.xml.
175 -e
"s/\(enum *\)v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1<link linkend=\"\2\">v4l2_mpeg_cx2341x_video_\2<\/link>/g" \
176 -e
"s/\(\(enum\|struct\) *\)\(v4l2_[a-zA-Z0-9_]*\)/\1<link linkend=\"\3\">\3<\/link>/g" \
177 -e
"s/\(V4L2_PIX_FMT_[A-Z0-9_]\+\)\(\s\+v4l2_fourcc\)/<link linkend=\"\1\">\1<\/link>\2/g" \
178 -e
":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
179 -e
"s/v4l2\-mpeg\-vbi\-ITV0/v4l2-mpeg-vbi-itv0-1/g"
182 -e
"s/\(linkend\=\"\)FE_SET_PROPERTY/\1FE_GET_PROPERTY/g" \
183 -e
"s,\(struct\s\+\)\([a-z0-9_]\+\)\(\s\+{\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
184 -e
"s,\(}\s\+\)\([a-z0-9_]\+_t\+\),\1\<link linkend=\"\2\">\2\<\/link\>,g" \
185 -e
"s,\(define\s\+\)\(DTV_[A-Z0-9_]\+\)\(\s\+[0-9]\+\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
186 -e
"s,<link\s\+linkend=\".*\">\(DTV_IOCTL_MAX_MSGS\|dtv_cmds_h\|__.*_old\)<\/link>,\1,g" \
187 -e
":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
188 -e
"s,\(audio-mixer\|audio-karaoke\|audio-status\|ca-slot-info\|ca-descr-info\|ca-caps\|ca-msg\|ca-descr\|ca-pid\|dmx-filter\|dmx-caps\|video-system\|video-highlight\|video-spu\|video-spu-palette\|video-navi-pack\)-t,\1,g" \
189 -e
"s,DTV-ISDBT-LAYER[A-C],DTV-ISDBT-LAYER,g" \
190 -e
"s,\(define\s\+\)\([A-Z0-9_]\+\)\(\s\+_IO\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
191 -e
"s,<link\s\+linkend=\".*\">\(__.*_OLD\)<\/link>,\1,g" \
194 # Media targets and dependencies
197 install_media_images
= \
198 $(Q
)-cp
$(OBJIMGFILES
) $(MEDIA_SRC_DIR
)/v4l
/*.svg
$(MEDIA_OBJ_DIR
)/media_api
200 $(MEDIA_OBJ_DIR
)/%: $(MEDIA_SRC_DIR
)/%.b64
203 $(MEDIA_OBJ_DIR
)/v4l2.xml
: $(OBJIMGFILES
)
205 @
(ln
-sf
`cd $(MEDIA_SRC_DIR) && /bin/pwd`/v4l
/*xml
$(MEDIA_OBJ_DIR
)/)
206 @
(ln
-sf
`cd $(MEDIA_SRC_DIR) && /bin/pwd`/dvb
/*xml
$(MEDIA_OBJ_DIR
)/)
208 $(MEDIA_OBJ_DIR
)/videodev2.h.xml
: $(srctree
)/include/uapi
/linux
/videodev2.h
$(MEDIA_OBJ_DIR
)/v4l2.xml
211 echo
"<programlisting>") > $@
213 expand
--tabs
=8 < $< | \
214 sed
$(ESCAPE
) $(DOCUMENTED
) | \
215 sed
's/i\.e\./&ie;/') >> $@
217 echo
"</programlisting>") >> $@
219 $(MEDIA_OBJ_DIR
)/audio.h.xml
: $(srctree
)/include/uapi
/linux
/dvb
/audio.h
$(MEDIA_OBJ_DIR
)/v4l2.xml
222 echo
"<programlisting>") > $@
224 expand
--tabs
=8 < $< | \
225 sed
$(ESCAPE
) $(DVB_DOCUMENTED
) | \
226 sed
's/i\.e\./&ie;/') >> $@
228 echo
"</programlisting>") >> $@
230 $(MEDIA_OBJ_DIR
)/ca.h.xml
: $(srctree
)/include/uapi
/linux
/dvb
/ca.h
$(MEDIA_OBJ_DIR
)/v4l2.xml
233 echo
"<programlisting>") > $@
235 expand
--tabs
=8 < $< | \
236 sed
$(ESCAPE
) $(DVB_DOCUMENTED
) | \
237 sed
's/i\.e\./&ie;/') >> $@
239 echo
"</programlisting>") >> $@
241 $(MEDIA_OBJ_DIR
)/dmx.h.xml
: $(srctree
)/include/uapi
/linux
/dvb
/dmx.h
$(MEDIA_OBJ_DIR
)/v4l2.xml
244 echo
"<programlisting>") > $@
246 expand
--tabs
=8 < $< | \
247 sed
$(ESCAPE
) $(DVB_DOCUMENTED
) | \
248 sed
's/i\.e\./&ie;/') >> $@
250 echo
"</programlisting>") >> $@
252 $(MEDIA_OBJ_DIR
)/frontend.h.xml
: $(srctree
)/include/uapi
/linux
/dvb
/frontend.h
$(MEDIA_OBJ_DIR
)/v4l2.xml
255 echo
"<programlisting>") > $@
257 expand
--tabs
=8 < $< | \
258 sed
$(ESCAPE
) $(DVB_DOCUMENTED
) | \
259 sed
's/i\.e\./&ie;/') >> $@
261 echo
"</programlisting>") >> $@
263 $(MEDIA_OBJ_DIR
)/net.h.xml
: $(srctree
)/include/uapi
/linux
/dvb
/net.h
$(MEDIA_OBJ_DIR
)/v4l2.xml
266 echo
"<programlisting>") > $@
268 expand
--tabs
=8 < $< | \
269 sed
$(ESCAPE
) $(DVB_DOCUMENTED
) | \
270 sed
's/i\.e\./&ie;/') >> $@
272 echo
"</programlisting>") >> $@
274 $(MEDIA_OBJ_DIR
)/video.h.xml
: $(srctree
)/include/uapi
/linux
/dvb
/video.h
$(MEDIA_OBJ_DIR
)/v4l2.xml
277 echo
"<programlisting>") > $@
279 expand
--tabs
=8 < $< | \
280 sed
$(ESCAPE
) $(DVB_DOCUMENTED
) | \
281 sed
's/i\.e\./&ie;/') >> $@
283 echo
"</programlisting>") >> $@
285 $(MEDIA_OBJ_DIR
)/media-entities.tmpl
: $(MEDIA_OBJ_DIR
)/v4l2.xml
288 echo
"<!-- Generated file! Do not edit. -->") >$@
290 echo
-e
"\n<!-- Functions -->") >>$@
292 for ident in
$(FUNCS
) ; do \
293 entity
=`echo $$ident | tr _ -` ; \
294 echo
"<!ENTITY func-$$entity \"<link" \
295 "linkend='func-$$entity'><function>$$ident()</function></link>\">" \
299 echo
-e
"\n<!-- Ioctls -->") >>$@
301 for ident in
$(IOCTLS
) ; do \
302 entity
=`echo $$ident | tr _ -` ; \
303 id
=`grep "<refname>$$ident" $(MEDIA_OBJ_DIR)/vidioc-*.xml $(MEDIA_OBJ_DIR)/media-ioc-*.xml | sed -r s,"^.*/(.*).xml.*","\1",` ; \
304 echo
"<!ENTITY $$entity \"<link" \
305 "linkend='$$id'><constant>$$ident</constant></link>\">" \
309 echo
-e
"\n<!-- Types -->") >>$@
311 for ident in
$(TYPES
) ; do \
312 entity
=`echo $$ident | tr _ -` ; \
313 echo
"<!ENTITY $$entity \"<link" \
314 "linkend='$$entity'>$$ident</link>\">" >>$@
; \
317 echo
-e
"\n<!-- Enums -->") >>$@
319 for ident in
$(ENUMS
) ; do \
320 entity
=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -` ; \
321 echo
"<!ENTITY $$entity \"enum <link" \
322 "linkend='$$entity'>$$ident</link>\">" >>$@
; \
325 echo
-e
"\n<!-- Structures -->") >>$@
327 for ident in
$(STRUCTS
) ; do \
328 entity
=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
329 echo
"<!ENTITY $$entity \"struct <link" \
330 "linkend='$$entity'>$$ident</link>\">" >>$@
; \
333 echo
-e
"\n<!-- Error Codes -->") >>$@
335 for ident in
$(ERRORS
) ; do \
336 echo
"<!ENTITY $$ident \"<errorcode>$$ident</errorcode>" \
337 "error code\">" >>$@
; \
340 echo
-e
"\n<!-- Subsections -->") >>$@
342 for file in
$(MEDIA_SGMLS
) ; do \
343 entity
=`echo "$$file" | sed $(FILENAME) -e s/"^([^-]*)"/sub\1/` ; \
344 if
! echo
"$$file" | \
345 grep
-q
-E
-e
'^(func|vidioc|pixfmt)-' ; then \
346 echo
"<!ENTITY sub-$$entity SYSTEM \"$$file\">" >>$@
; \
350 echo
-e
"\n<!-- Function Reference -->") >>$@
352 for file in
$(MEDIA_SGMLS
) ; do \
354 grep
-q
-E
-e
'(func|vidioc|pixfmt)-' ; then \
355 entity
=`echo "$$file" |sed $(FILENAME)` ; \
356 echo
"<!ENTITY $$entity SYSTEM \"$$file\">" >>$@
; \
360 # Jade can auto-generate a list-of-tables, which includes all structs,
361 # but we only want data types, all types, and sorted please.
362 $(MEDIA_OBJ_DIR
)/media-indices.tmpl
: $(MEDIA_OBJ_DIR
)/v4l2.xml
365 echo
"<!-- Generated file! Do not edit. -->") >$@
367 echo
-e
"\n<index><title>List of Types</title>") >>$@
369 for ident in
$(TYPES
) ; do \
370 id
=`echo $$ident | tr _ -` ; \
371 echo
"<indexentry><primaryie><link" \
372 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@
; \
375 for ident in
$(ENUMS
) ; do \
376 id
=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -`; \
377 echo
"<indexentry><primaryie>enum <link" \
378 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@
; \
381 for ident in
$(STRUCTS
) ; do \
382 id
=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
383 echo
"<indexentry><primaryie>struct <link" \
384 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@
; \
387 echo
"</index>") >>$@