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/linux/cec.h) \
68 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/v4l2-subdev.h) \
71 $(shell perl -ne 'print "$$1 " if /\#define\s+(DTV_[^\s]+)\s+/' $(srctree)/include/uapi/linux/dvb/frontend.h) \
74 $(shell perl -ne 'print "$$1 " if /^typedef\s+.*\s+(\S+)\;/' $(srctree)/include/uapi/linux/videodev2.h) \
75 $(shell perl -ne 'print "$$1 " if /^typedef\s+.*\s+(\S+)\;/' $(srctree)/include/uapi/linux/dvb/frontend.h)
78 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' \
79 $(srctree)/include/uapi/linux/videodev2.h \
80 $(srctree)/include/uapi/linux/dvb/audio.h \
81 $(srctree)/include/uapi/linux/dvb/ca.h \
82 $(srctree)/include/uapi/linux/dvb/dmx.h \
83 $(srctree)/include/uapi/linux/dvb/frontend.h \
84 $(srctree)/include/uapi/linux/dvb/net.h \
85 $(srctree)/include/uapi/linux/dvb/video.h \
86 $(srctree)/include/uapi/linux/media.h \
87 $(srctree)/include/uapi/linux/v4l2-mediabus.h \
88 $(srctree)/include/uapi/linux/v4l2-subdev.h)
91 $(shell perl -e 'open IN,"cat @ARGV| cpp -fpreprocessed |"; while (<IN>) { if ($$enum) {print "$$1\n" if (/\s*([A-Z]\S+)\b/); } $$enum = 0 if ($$enum && /^\}/); $$enum = 1 if(/^\s*enum\s/); }; close IN;' \
92 $(srctree)/include/uapi/linux/dvb/dmx.h \
93 $(srctree)/include/uapi/linux/dvb/frontend.h)
96 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/videodev2.h) \
97 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s\{]+)\s*/)' $(srctree)/include/uapi/linux/dvb/audio.h) \
98 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/ca.h) \
99 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/dmx.h) \
100 $(shell perl -ne 'print "$$1 " if (!/dtv\_cmds\_h/ && /^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/frontend.h) \
101 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/ && !/_old/)' $(srctree)/include/uapi/linux/dvb/net.h) \
102 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/video.h) \
103 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/media.h) \
104 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/cec.h) \
105 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/v4l2-subdev.h) \
106 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/v4l2-mediabus.h)
177 # Generate references to these structs in videodev2.h.xml.
179 -e "s/\(enum *\)v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1<link linkend=\"\2\">v4l2_mpeg_cx2341x_video_\2<\/link>/g" \
180 -e "s/\(\(enum\|struct\) *\)\(v4l2_[a-zA-Z0-9_]*\)/\1<link linkend=\"\3\">\3<\/link>/g" \
181 -e "s/\(V4L2_PIX_FMT_[A-Z0-9_]\+\)\(\s\+v4l2_fourcc\)/<link linkend=\"\1\">\1<\/link>\2/g" \
182 -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
183 -e "s/v4l2\-mpeg\-vbi\-ITV0/v4l2-mpeg-vbi-itv0-1/g"
186 -e "s,\(struct\s\+\)\([a-z0-9_]\+\)\(\s\+{\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
187 -e "s,\(}\s\+\)\([a-z0-9_]\+_t\+\),\1\<link linkend=\"\2\">\2\<\/link\>,g" \
188 -e "s,\(define\s\+\)\(DTV_[A-Z0-9_]\+\)\(\s\+[0-9]\+\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
189 -e "s,<link\s\+linkend=\".*\">\(DTV_IOCTL_MAX_MSGS\|dtv_cmds_h\|__.*_old\)<\/link>,\1,g" \
190 -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
191 -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" \
192 -e "s,DTV-ISDBT-LAYER[A-C],DTV-ISDBT-LAYER,g" \
193 -e "s,\(define\s\+\)\([A-Z0-9_]\+\)\(\s\+_IO\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
194 -e "s,\(define\s\+\)\(DTV_[A-Z0-9_]\+\)\(\s\+\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
195 -e "s,<link\s\+linkend=\".*\">\(__.*_OLD\)<\/link>,\1,g" \
196 -e "s/\(linkend\=\"\)FE_SET_PROPERTY/\1FE_GET_PROPERTY/g" \
197 -e "s,<link\s\+linkend=\".*\">\(DTV_ISDBS_TS_ID_LEGACY\|DTV_MAX_COMMAND\|DTV_IOCTL_MAX_MSGS\)<\/link>,\1,g" \
200 # Media targets and dependencies
203 install_media_images = \
204 $(Q)if [ "x$(findstring media_api.xml,$(DOCBOOKS))" != "x" ]; then \
205 mkdir -p $(MEDIA_OBJ_DIR)/media_api; \
206 cp $(OBJIMGFILES) $(MEDIA_SRC_DIR)/*.svg $(MEDIA_SRC_DIR)/v4l/*.svg $(MEDIA_OBJ_DIR)/media_api; \
209 $(MEDIA_OBJ_DIR)/%: $(MEDIA_SRC_DIR)/%.b64
212 $(MEDIA_OBJ_DIR)/v4l2.xml: $(OBJIMGFILES)
214 @(ln -sf `cd $(MEDIA_SRC_DIR) && /bin/pwd`/v4l/*xml $(MEDIA_OBJ_DIR)/)
215 @(ln -sf `cd $(MEDIA_SRC_DIR) && /bin/pwd`/dvb/*xml $(MEDIA_OBJ_DIR)/)
217 $(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/uapi/linux/videodev2.h $(MEDIA_OBJ_DIR)/v4l2.xml
220 echo "<programlisting>") > $@
222 expand --tabs=8 < $< | \
223 sed $(ESCAPE) $(DOCUMENTED) | \
224 sed 's/i\.e\./&ie;/') >> $@
226 echo "</programlisting>") >> $@
228 $(MEDIA_OBJ_DIR)/audio.h.xml: $(srctree)/include/uapi/linux/dvb/audio.h $(MEDIA_OBJ_DIR)/v4l2.xml
231 echo "<programlisting>") > $@
233 expand --tabs=8 < $< | \
234 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
235 sed 's/i\.e\./&ie;/') >> $@
237 echo "</programlisting>") >> $@
239 $(MEDIA_OBJ_DIR)/ca.h.xml: $(srctree)/include/uapi/linux/dvb/ca.h $(MEDIA_OBJ_DIR)/v4l2.xml
242 echo "<programlisting>") > $@
244 expand --tabs=8 < $< | \
245 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
246 sed 's/i\.e\./&ie;/') >> $@
248 echo "</programlisting>") >> $@
250 $(MEDIA_OBJ_DIR)/dmx.h.xml: $(srctree)/include/uapi/linux/dvb/dmx.h $(MEDIA_OBJ_DIR)/v4l2.xml
253 echo "<programlisting>") > $@
255 for ident in $(ENUM_DEFS) ; do \
256 entity=`echo $$ident | tr _ -` ; \
257 r="$$r s/([^\w\-])$$ident([^\w\-])/\1\&$$entity\;\2/g;";\
259 expand --tabs=8 < $< | \
260 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
261 sed 's/i\.e\./&ie;/' | \
262 perl -ne "$$r print $$_;") >> $@
264 echo "</programlisting>") >> $@
266 $(MEDIA_OBJ_DIR)/frontend.h.xml: $(srctree)/include/uapi/linux/dvb/frontend.h $(MEDIA_OBJ_DIR)/v4l2.xml
269 echo "<programlisting>") > $@
271 for ident in $(ENUM_DEFS) ; do \
272 entity=`echo $$ident | tr _ -` ; \
273 r="$$r s/([^\w\-])$$ident([^\w\-])/\1\&$$entity\;\2/g;";\
275 expand --tabs=8 < $< | \
276 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
277 sed 's/i\.e\./&ie;/' | \
278 perl -ne "$$r print $$_;") >> $@
280 echo "</programlisting>") >> $@
282 $(MEDIA_OBJ_DIR)/net.h.xml: $(srctree)/include/uapi/linux/dvb/net.h $(MEDIA_OBJ_DIR)/v4l2.xml
285 echo "<programlisting>") > $@
287 expand --tabs=8 < $< | \
288 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
289 sed 's/i\.e\./&ie;/') >> $@
291 echo "</programlisting>") >> $@
293 $(MEDIA_OBJ_DIR)/video.h.xml: $(srctree)/include/uapi/linux/dvb/video.h $(MEDIA_OBJ_DIR)/v4l2.xml
296 echo "<programlisting>") > $@
298 expand --tabs=8 < $< | \
299 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
300 sed 's/i\.e\./&ie;/') >> $@
302 echo "</programlisting>") >> $@
304 $(MEDIA_OBJ_DIR)/media-entities.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
307 echo "<!-- Generated file! Do not edit. -->") >$@
309 echo -e "\n<!-- Functions -->") >>$@
311 for ident in $(FUNCS) ; do \
312 entity=`echo $$ident | tr _ -` ; \
313 echo "<!ENTITY func-$$entity \"<link" \
314 "linkend='func-$$entity'><function>$$ident()</function></link>\">" \
318 echo -e "\n<!-- Ioctls -->") >>$@
320 for ident in `echo $(IOCTLS) | sed -e "s,VIDIOC_RESERVED,,"`; do\
321 entity=`echo $$ident | tr _ -` ; \
322 id=`grep -e "<refname>$$ident" -e "<section id=\"$$ident\"" $$(find $(MEDIA_SRC_DIR) -name *.xml -type f)| sed -r s,"^.*/(.*).xml.*","\1",` ; \
323 if [ "$$id" != "" ]; then echo "<!ENTITY $$entity \"<link" \
324 "linkend='$$id'><constant>$$ident</constant></link>\">" \
326 echo "Warning: undocumented ioctl: $$ident. Please document it at the media DocBook!" >&2; \
330 echo -e "\n<!-- Defines -->") >>$@
332 for ident in $(DEFINES) ; do \
333 entity=`echo $$ident | tr _ -` ; \
334 echo "<!ENTITY $$entity \"<link" \
335 "linkend='$$entity'><constant>$$ident</constant></link>\">" \
339 echo -e "\n<!-- Types -->") >>$@
341 for ident in $(TYPES) ; do \
342 entity=`echo $$ident | tr _ -` ; \
343 echo "<!ENTITY $$entity \"<link" \
344 "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
347 echo -e "\n<!-- Enums -->") >>$@
349 for ident in $(ENUMS) ; do \
350 entity=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -` ; \
351 echo "<!ENTITY $$entity \"enum <link" \
352 "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
355 echo -e "\n<!-- Enum definitions -->") >>$@
357 for ident in $(ENUM_DEFS) ; do \
358 entity=`echo $$ident | tr _ -` ; \
359 echo "<!ENTITY $$entity \"<link" \
360 "linkend='$$entity'><constant>$$ident</constant></link>\">" \
364 echo -e "\n<!-- Structures -->") >>$@
366 for ident in $(STRUCTS) ; do \
367 entity=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
368 echo "<!ENTITY $$entity \"struct <link" \
369 "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
372 echo -e "\n<!-- Error Codes -->") >>$@
374 for ident in $(ERRORS) ; do \
375 echo "<!ENTITY $$ident \"<errorcode>$$ident</errorcode>" \
376 "error code\">" >>$@ ; \
379 echo -e "\n<!-- Subsections -->") >>$@
381 for file in $(MEDIA_SGMLS) ; do \
382 entity=`echo "$$file" | sed $(FILENAME) -e s/"^([^-]*)"/sub\1/` ; \
383 if ! echo "$$file" | \
384 grep -q -E -e '^(func|vidioc|pixfmt)-' ; then \
385 echo "<!ENTITY sub-$$entity SYSTEM \"$$file\">" >>$@ ; \
389 echo -e "\n<!-- Function Reference -->") >>$@
391 for file in $(MEDIA_SGMLS) ; do \
393 grep -q -E -e '(func|vidioc|pixfmt)-' ; then \
394 entity=`echo "$$file" |sed $(FILENAME)` ; \
395 echo "<!ENTITY $$entity SYSTEM \"$$file\">" >>$@ ; \
399 # Jade can auto-generate a list-of-tables, which includes all structs,
400 # but we only want data types, all types, and sorted please.
401 $(MEDIA_OBJ_DIR)/media-indices.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
404 echo "<!-- Generated file! Do not edit. -->") >$@
406 echo -e "\n<index><title>List of Types</title>") >>$@
408 for ident in $(TYPES) ; do \
409 id=`echo $$ident | tr _ -` ; \
410 echo "<indexentry><primaryie><link" \
411 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
414 for ident in $(ENUMS) ; do \
415 id=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -`; \
416 echo "<indexentry><primaryie>enum <link" \
417 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
420 for ident in $(STRUCTS) ; do \
421 id=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
422 echo "<indexentry><primaryie>struct <link" \
423 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
426 echo "</index>") >>$@