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 \
22 IMGFILES := $(addprefix $(MEDIA_OBJ_DIR)/media/, $(notdir $(shell ls $(MEDIA_SRC_DIR)/*/*.gif $(MEDIA_SRC_DIR)/*/*.png)))
23 GENFILES := $(addprefix $(MEDIA_OBJ_DIR)/, $(MEDIA_TEMP))
25 PHONY += cleanmediadocs mediaindexdocs
28 -@rm `find $(MEDIA_OBJ_DIR) -type l` $(GENFILES) $(IMGFILES)
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/linux/videodev2.h) \
60 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/audio.h) \
61 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/ca.h) \
62 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/dmx.h) \
63 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/frontend.h) \
64 $(shell perl -ne 'print "$$1 " if /\#define\s+([A-Z][^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/net.h) \
65 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/osd.h) \
66 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/video.h) \
67 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/media.h) \
68 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/v4l2-subdev.h) \
69 VIDIOC_SUBDEV_G_FRAME_INTERVAL \
70 VIDIOC_SUBDEV_S_FRAME_INTERVAL \
71 VIDIOC_SUBDEV_ENUM_MBUS_CODE \
72 VIDIOC_SUBDEV_ENUM_FRAME_SIZE \
73 VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL \
76 $(shell perl -ne 'print "$$1 " if /^typedef\s+[^\s]+\s+([^\s]+)\;/' $(srctree)/include/linux/videodev2.h) \
77 $(shell perl -ne 'print "$$1 " if /^}\s+([a-z0-9_]+_t)/' $(srctree)/include/linux/dvb/frontend.h)
80 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/videodev2.h) \
81 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/audio.h) \
82 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/ca.h) \
83 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/dmx.h) \
84 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/frontend.h) \
85 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/net.h) \
86 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/osd.h) \
87 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/video.h) \
88 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/media.h) \
89 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-mediabus.h) \
90 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-subdev.h)
93 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/videodev2.h) \
94 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s\{]+)\s*/)' $(srctree)/include/linux/dvb/audio.h) \
95 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/ca.h) \
96 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/dmx.h) \
97 $(shell perl -ne 'print "$$1 " if (!/dtv\_cmds\_h/ && /^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/frontend.h) \
98 $(shell perl -ne 'print "$$1 " if (/^struct\s+([A-Z][^\s]+)\s+/)' $(srctree)/include/linux/dvb/net.h) \
99 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/osd.h) \
100 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/video.h) \
101 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/media.h) \
102 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-subdev.h) \
103 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-mediabus.h)
138 # Generate references to these structs in videodev2.h.xml.
140 -e "s/\(enum *\)v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1<link linkend=\"\2\">v4l2_mpeg_cx2341x_video_\2<\/link>/g" \
141 -e "s/\(\(enum\|struct\) *\)\(v4l2_[a-zA-Z0-9_]*\)/\1<link linkend=\"\3\">\3<\/link>/g" \
142 -e "s/\(V4L2_PIX_FMT_[A-Z0-9_]\+\) /<link linkend=\"\1\">\1<\/link> /g" \
143 -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
144 -e "s/v4l2\-mpeg\-vbi\-ITV0/v4l2-mpeg-vbi-itv0-1/g"
147 -e "s/\(linkend\=\"\)FE_SET_PROPERTY/\1FE_GET_PROPERTY/g" \
148 -e "s,\(struct\s\+\)\([a-z0-9_]\+\)\(\s\+{\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
149 -e "s,\(}\s\+\)\([a-z0-9_]\+_t\+\),\1\<link linkend=\"\2\">\2\<\/link\>,g" \
150 -e "s,\(define\s\+\)\(DTV_[A-Z0-9_]\+\)\(\s\+[0-9]\+\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
151 -e "s,<link linkend=\".*\">\(DTV_IOCTL_MAX_MSGS\|dtv_cmds_h\)<\/link>,\1,g" \
152 -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
153 -e "s,\(audio-mixer\|audio-karaoke\|audio-status\)-t,\1,g" \
154 -e "s,DTV-ISDBT-LAYER[A-C],DTV-ISDBT-LAYER,g" \
155 -e "s,\(define\s\+\)\([A-Z0-9_]\+\)\(\s\+_IO\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
158 # Media targets and dependencies
161 $(MEDIA_OBJ_DIR)/v4l2.xml:
163 @(mkdir -p $(MEDIA_OBJ_DIR)/media)
164 @(cp $(MEDIA_SRC_DIR)/dvb/*.png $(MEDIA_SRC_DIR)/v4l/*.gif $(MEDIA_OBJ_DIR)/media/)
165 @(ln -sf $(MEDIA_SRC_DIR)/v4l/*xml $(MEDIA_OBJ_DIR)/)
166 @(ln -sf $(MEDIA_SRC_DIR)/dvb/*xml $(MEDIA_OBJ_DIR)/)
168 $(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/linux/videodev2.h $(MEDIA_OBJ_DIR)/v4l2.xml
171 echo "<programlisting>") > $@
173 expand --tabs=8 < $< | \
174 sed $(ESCAPE) $(DOCUMENTED) | \
175 sed 's/i\.e\./&ie;/') >> $@
177 echo "</programlisting>") >> $@
179 $(MEDIA_OBJ_DIR)/audio.h.xml: $(srctree)/include/linux/dvb/audio.h $(MEDIA_OBJ_DIR)/v4l2.xml
182 echo "<programlisting>") > $@
184 expand --tabs=8 < $< | \
185 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
186 sed 's/i\.e\./&ie;/') >> $@
188 echo "</programlisting>") >> $@
190 $(MEDIA_OBJ_DIR)/ca.h.xml: $(srctree)/include/linux/dvb/ca.h $(MEDIA_OBJ_DIR)/v4l2.xml
193 echo "<programlisting>") > $@
195 expand --tabs=8 < $< | \
196 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
197 sed 's/i\.e\./&ie;/') >> $@
199 echo "</programlisting>") >> $@
201 $(MEDIA_OBJ_DIR)/dmx.h.xml: $(srctree)/include/linux/dvb/dmx.h $(MEDIA_OBJ_DIR)/v4l2.xml
204 echo "<programlisting>") > $@
206 expand --tabs=8 < $< | \
207 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
208 sed 's/i\.e\./&ie;/') >> $@
210 echo "</programlisting>") >> $@
212 $(MEDIA_OBJ_DIR)/frontend.h.xml: $(srctree)/include/linux/dvb/frontend.h $(MEDIA_OBJ_DIR)/v4l2.xml
215 echo "<programlisting>") > $@
217 expand --tabs=8 < $< | \
218 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
219 sed 's/i\.e\./&ie;/') >> $@
221 echo "</programlisting>") >> $@
223 $(MEDIA_OBJ_DIR)/net.h.xml: $(srctree)/include/linux/dvb/net.h $(MEDIA_OBJ_DIR)/v4l2.xml
226 echo "<programlisting>") > $@
228 expand --tabs=8 < $< | \
229 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
230 sed 's/i\.e\./&ie;/') >> $@
232 echo "</programlisting>") >> $@
234 $(MEDIA_OBJ_DIR)/osd.h.xml: $(srctree)/include/linux/dvb/osd.h $(MEDIA_OBJ_DIR)/v4l2.xml
237 echo "<programlisting>") > $@
239 expand --tabs=8 < $< | \
240 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
241 sed 's/i\.e\./&ie;/') >> $@
243 echo "</programlisting>") >> $@
245 $(MEDIA_OBJ_DIR)/video.h.xml: $(srctree)/include/linux/dvb/video.h $(MEDIA_OBJ_DIR)/v4l2.xml
248 echo "<programlisting>") > $@
250 expand --tabs=8 < $< | \
251 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
252 sed 's/i\.e\./&ie;/') >> $@
254 echo "</programlisting>") >> $@
256 $(MEDIA_OBJ_DIR)/media-entities.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
259 echo "<!-- Generated file! Do not edit. -->") >$@
261 echo -e "\n<!-- Functions -->") >>$@
263 for ident in $(FUNCS) ; do \
264 entity=`echo $$ident | tr _ -` ; \
265 echo "<!ENTITY func-$$entity \"<link" \
266 "linkend='func-$$entity'><function>$$ident()</function></link>\">" \
270 echo -e "\n<!-- Ioctls -->") >>$@
272 for ident in $(IOCTLS) ; do \
273 entity=`echo $$ident | tr _ -` ; \
274 id=`grep "<refname>$$ident" $(MEDIA_OBJ_DIR)/vidioc-*.xml | sed -r s,"^.*/(.*).xml.*","\1",` ; \
275 echo "<!ENTITY $$entity \"<link" \
276 "linkend='$$id'><constant>$$ident</constant></link>\">" \
280 echo -e "\n<!-- Types -->") >>$@
282 for ident in $(TYPES) ; do \
283 entity=`echo $$ident | tr _ -` ; \
284 echo "<!ENTITY $$entity \"<link" \
285 "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
288 echo -e "\n<!-- Enums -->") >>$@
290 for ident in $(ENUMS) ; do \
291 entity=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -` ; \
292 echo "<!ENTITY $$entity \"enum <link" \
293 "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
296 echo -e "\n<!-- Structures -->") >>$@
298 for ident in $(STRUCTS) ; do \
299 entity=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
300 echo "<!ENTITY $$entity \"struct <link" \
301 "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
304 echo -e "\n<!-- Error Codes -->") >>$@
306 for ident in $(ERRORS) ; do \
307 echo "<!ENTITY $$ident \"<errorcode>$$ident</errorcode>" \
308 "error code\">" >>$@ ; \
311 echo -e "\n<!-- Subsections -->") >>$@
313 for file in $(MEDIA_SGMLS) ; do \
314 entity=`echo "$$file" | sed $(FILENAME) -e s/"^([^-]*)"/sub\1/` ; \
315 if ! echo "$$file" | \
316 grep -q -E -e '^(func|vidioc|pixfmt)-' ; then \
317 echo "<!ENTITY sub-$$entity SYSTEM \"$$file\">" >>$@ ; \
321 echo -e "\n<!-- Function Reference -->") >>$@
323 for file in $(MEDIA_SGMLS) ; do \
325 grep -q -E -e '(func|vidioc|pixfmt)-' ; then \
326 entity=`echo "$$file" |sed $(FILENAME)` ; \
327 echo "<!ENTITY $$entity SYSTEM \"$$file\">" >>$@ ; \
331 # Jade can auto-generate a list-of-tables, which includes all structs,
332 # but we only want data types, all types, and sorted please.
333 $(MEDIA_OBJ_DIR)/media-indices.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
336 echo "<!-- Generated file! Do not edit. -->") >$@
338 echo -e "\n<index><title>List of Types</title>") >>$@
340 for ident in $(TYPES) ; do \
341 id=`echo $$ident | tr _ -` ; \
342 echo "<indexentry><primaryie><link" \
343 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
346 for ident in $(ENUMS) ; do \
347 id=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -`; \
348 echo "<indexentry><primaryie>enum <link" \
349 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
352 for ident in $(STRUCTS) ; do \
353 id=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
354 echo "<indexentry><primaryie>struct <link" \
355 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
358 echo "</index>") >>$@