toshiba_acpi: Propagate the hotkey value via genetlink
[linux/fpc-iii.git] / Documentation / DocBook / media / Makefile
blob08527e7ea4d0ff009e55ddfb11f5efc716210e5d
1 ###
2 # Media build rules - Auto-generates media contents/indexes and *.h xml's
5 SHELL=/bin/bash
7 MEDIA_OBJ_DIR=$(objtree)/Documentation/DocBook/
8 MEDIA_SRC_DIR=$(srctree)/Documentation/DocBook/media
10 MEDIA_TEMP = media-entities.tmpl \
11 media-indices.tmpl \
12 videodev2.h.xml \
13 v4l2.xml \
14 audio.h.xml \
15 ca.h.xml \
16 dmx.h.xml \
17 frontend.h.xml \
18 net.h.xml \
19 video.h.xml \
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
27 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
36 V4L_SGMLS = \
37 $(shell ls $(MEDIA_SRC_DIR)/v4l/*.xml|perl -ne 'print "$$1 " if (m,.*/(.*)\n,)') \
38 capture.c.xml \
39 keytable.c.xml \
40 v4l2grab.c.xml
42 DVB_SGMLS = \
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))
47 FUNCS = \
48 close \
49 ioctl \
50 mmap \
51 munmap \
52 open \
53 poll \
54 read \
55 select \
56 write \
58 IOCTLS = \
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) \
69 DEFINES = \
70 $(shell perl -ne 'print "$$1 " if /\#define\s+(DTV_[^\s]+)\s+/' $(srctree)/include/uapi/linux/dvb/frontend.h) \
72 TYPES = \
73 $(shell perl -ne 'print "$$1 " if /^typedef\s+.*\s+(\S+)\;/' $(srctree)/include/uapi/linux/videodev2.h) \
74 $(shell perl -ne 'print "$$1 " if /^typedef\s+.*\s+(\S+)\;/' $(srctree)/include/uapi/linux/dvb/frontend.h)
76 ENUMS = \
77 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' \
78 $(srctree)/include/uapi/linux/videodev2.h \
79 $(srctree)/include/uapi/linux/dvb/audio.h \
80 $(srctree)/include/uapi/linux/dvb/ca.h \
81 $(srctree)/include/uapi/linux/dvb/dmx.h \
82 $(srctree)/include/uapi/linux/dvb/frontend.h \
83 $(srctree)/include/uapi/linux/dvb/net.h \
84 $(srctree)/include/uapi/linux/dvb/video.h \
85 $(srctree)/include/uapi/linux/media.h \
86 $(srctree)/include/uapi/linux/v4l2-mediabus.h \
87 $(srctree)/include/uapi/linux/v4l2-subdev.h)
89 ENUM_DEFS = \
90 $(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;' \
91 $(srctree)/include/uapi/linux/dvb/dmx.h \
92 $(srctree)/include/uapi/linux/dvb/frontend.h)
94 STRUCTS = \
95 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/videodev2.h) \
96 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s\{]+)\s*/)' $(srctree)/include/uapi/linux/dvb/audio.h) \
97 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/ca.h) \
98 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/dmx.h) \
99 $(shell perl -ne 'print "$$1 " if (!/dtv\_cmds\_h/ && /^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/frontend.h) \
100 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/ && !/_old/)' $(srctree)/include/uapi/linux/dvb/net.h) \
101 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/video.h) \
102 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/media.h) \
103 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/v4l2-subdev.h) \
104 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/v4l2-mediabus.h)
106 ERRORS = \
107 E2BIG \
108 EACCES \
109 EAGAIN \
110 EBADF \
111 EBADFD \
112 EBADR \
113 EBADRQC \
114 EBUSY \
115 ECHILD \
116 ECONNRESET \
117 EDEADLK \
118 EDOM \
119 EEXIST \
120 EFAULT \
121 EFBIG \
122 EILSEQ \
123 EINIT \
124 EINPROGRESS \
125 EINTR \
126 EINVAL \
127 EIO \
128 EMFILE \
129 ENFILE \
130 ENOBUFS \
131 ENODATA \
132 ENODEV \
133 ENOENT \
134 ENOIOCTLCMD \
135 ENOMEM \
136 ENOSPC \
137 ENOSR \
138 ENOSYS \
139 ENOTSUP \
140 ENOTSUPP \
141 ENOTTY \
142 ENXIO \
143 EOPNOTSUPP \
144 EOVERFLOW \
145 EPERM \
146 EPIPE \
147 EPROTO \
148 ERANGE \
149 EREMOTE \
150 EREMOTEIO \
151 ERESTART \
152 ERESTARTSYS \
153 ESHUTDOWN \
154 ESPIPE \
155 ETIME \
156 ETIMEDOUT \
157 EUSERS \
158 EWOULDBLOCK \
159 EXDEV \
161 ESCAPE = \
162 -e "s/&/\\&amp;/g" \
163 -e "s/</\\&lt;/g" \
164 -e "s/>/\\&gt;/g"
166 FILENAME = \
167 -e s,"^[^\/]*/",, \
168 -e s/"\\.xml"// \
169 -e s/"\\.tmpl"// \
170 -e s/\\\./-/g \
171 -e s/"^func-"// \
172 -e s/"^pixfmt-"// \
173 -e s/"^vidioc-"//
175 # Generate references to these structs in videodev2.h.xml.
176 DOCUMENTED = \
177 -e "s/\(enum *\)v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1<link linkend=\"\2\">v4l2_mpeg_cx2341x_video_\2<\/link>/g" \
178 -e "s/\(\(enum\|struct\) *\)\(v4l2_[a-zA-Z0-9_]*\)/\1<link linkend=\"\3\">\3<\/link>/g" \
179 -e "s/\(V4L2_PIX_FMT_[A-Z0-9_]\+\)\(\s\+v4l2_fourcc\)/<link linkend=\"\1\">\1<\/link>\2/g" \
180 -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
181 -e "s/v4l2\-mpeg\-vbi\-ITV0/v4l2-mpeg-vbi-itv0-1/g"
183 DVB_DOCUMENTED = \
184 -e "s,\(struct\s\+\)\([a-z0-9_]\+\)\(\s\+{\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
185 -e "s,\(}\s\+\)\([a-z0-9_]\+_t\+\),\1\<link linkend=\"\2\">\2\<\/link\>,g" \
186 -e "s,\(define\s\+\)\(DTV_[A-Z0-9_]\+\)\(\s\+[0-9]\+\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
187 -e "s,<link\s\+linkend=\".*\">\(DTV_IOCTL_MAX_MSGS\|dtv_cmds_h\|__.*_old\)<\/link>,\1,g" \
188 -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
189 -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" \
190 -e "s,DTV-ISDBT-LAYER[A-C],DTV-ISDBT-LAYER,g" \
191 -e "s,\(define\s\+\)\([A-Z0-9_]\+\)\(\s\+_IO\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
192 -e "s,\(define\s\+\)\(DTV_[A-Z0-9_]\+\)\(\s\+\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
193 -e "s,<link\s\+linkend=\".*\">\(__.*_OLD\)<\/link>,\1,g" \
194 -e "s/\(linkend\=\"\)FE_SET_PROPERTY/\1FE_GET_PROPERTY/g" \
195 -e "s,<link\s\+linkend=\".*\">\(DTV_ISDBS_TS_ID_LEGACY\|DTV_MAX_COMMAND\|DTV_IOCTL_MAX_MSGS\)<\/link>,\1,g" \
198 # Media targets and dependencies
201 install_media_images = \
202 $(Q)-mkdir $(MEDIA_OBJ_DIR)/media_api; \
203 cp $(OBJIMGFILES) $(MEDIA_SRC_DIR)/*.svg $(MEDIA_SRC_DIR)/v4l/*.svg $(MEDIA_OBJ_DIR)/media_api
205 $(MEDIA_OBJ_DIR)/%: $(MEDIA_SRC_DIR)/%.b64
206 $(Q)base64 -d $< >$@
208 $(MEDIA_OBJ_DIR)/v4l2.xml: $(OBJIMGFILES)
209 @$($(quiet)gen_xml)
210 @(ln -sf `cd $(MEDIA_SRC_DIR) && /bin/pwd`/v4l/*xml $(MEDIA_OBJ_DIR)/)
211 @(ln -sf `cd $(MEDIA_SRC_DIR) && /bin/pwd`/dvb/*xml $(MEDIA_OBJ_DIR)/)
213 $(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/uapi/linux/videodev2.h $(MEDIA_OBJ_DIR)/v4l2.xml
214 @$($(quiet)gen_xml)
215 @( \
216 echo "<programlisting>") > $@
217 @( \
218 expand --tabs=8 < $< | \
219 sed $(ESCAPE) $(DOCUMENTED) | \
220 sed 's/i\.e\./&ie;/') >> $@
221 @( \
222 echo "</programlisting>") >> $@
224 $(MEDIA_OBJ_DIR)/audio.h.xml: $(srctree)/include/uapi/linux/dvb/audio.h $(MEDIA_OBJ_DIR)/v4l2.xml
225 @$($(quiet)gen_xml)
226 @( \
227 echo "<programlisting>") > $@
228 @( \
229 expand --tabs=8 < $< | \
230 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
231 sed 's/i\.e\./&ie;/') >> $@
232 @( \
233 echo "</programlisting>") >> $@
235 $(MEDIA_OBJ_DIR)/ca.h.xml: $(srctree)/include/uapi/linux/dvb/ca.h $(MEDIA_OBJ_DIR)/v4l2.xml
236 @$($(quiet)gen_xml)
237 @( \
238 echo "<programlisting>") > $@
239 @( \
240 expand --tabs=8 < $< | \
241 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
242 sed 's/i\.e\./&ie;/') >> $@
243 @( \
244 echo "</programlisting>") >> $@
246 $(MEDIA_OBJ_DIR)/dmx.h.xml: $(srctree)/include/uapi/linux/dvb/dmx.h $(MEDIA_OBJ_DIR)/v4l2.xml
247 @$($(quiet)gen_xml)
248 @( \
249 echo "<programlisting>") > $@
250 @( \
251 for ident in $(ENUM_DEFS) ; do \
252 entity=`echo $$ident | tr _ -` ; \
253 r="$$r s/([^\w\-])$$ident([^\w\-])/\1\&$$entity\;\2/g;";\
254 done; \
255 expand --tabs=8 < $< | \
256 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
257 sed 's/i\.e\./&ie;/' | \
258 perl -ne "$$r print $$_;") >> $@
259 @( \
260 echo "</programlisting>") >> $@
262 $(MEDIA_OBJ_DIR)/frontend.h.xml: $(srctree)/include/uapi/linux/dvb/frontend.h $(MEDIA_OBJ_DIR)/v4l2.xml
263 @$($(quiet)gen_xml)
264 @( \
265 echo "<programlisting>") > $@
266 @( \
267 for ident in $(ENUM_DEFS) ; do \
268 entity=`echo $$ident | tr _ -` ; \
269 r="$$r s/([^\w\-])$$ident([^\w\-])/\1\&$$entity\;\2/g;";\
270 done; \
271 expand --tabs=8 < $< | \
272 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
273 sed 's/i\.e\./&ie;/' | \
274 perl -ne "$$r print $$_;") >> $@
275 @( \
276 echo "</programlisting>") >> $@
278 $(MEDIA_OBJ_DIR)/net.h.xml: $(srctree)/include/uapi/linux/dvb/net.h $(MEDIA_OBJ_DIR)/v4l2.xml
279 @$($(quiet)gen_xml)
280 @( \
281 echo "<programlisting>") > $@
282 @( \
283 expand --tabs=8 < $< | \
284 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
285 sed 's/i\.e\./&ie;/') >> $@
286 @( \
287 echo "</programlisting>") >> $@
289 $(MEDIA_OBJ_DIR)/video.h.xml: $(srctree)/include/uapi/linux/dvb/video.h $(MEDIA_OBJ_DIR)/v4l2.xml
290 @$($(quiet)gen_xml)
291 @( \
292 echo "<programlisting>") > $@
293 @( \
294 expand --tabs=8 < $< | \
295 sed $(ESCAPE) $(DVB_DOCUMENTED) | \
296 sed 's/i\.e\./&ie;/') >> $@
297 @( \
298 echo "</programlisting>") >> $@
300 $(MEDIA_OBJ_DIR)/media-entities.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
301 @$($(quiet)gen_xml)
302 @( \
303 echo "<!-- Generated file! Do not edit. -->") >$@
304 @( \
305 echo -e "\n<!-- Functions -->") >>$@
306 @( \
307 for ident in $(FUNCS) ; do \
308 entity=`echo $$ident | tr _ -` ; \
309 echo "<!ENTITY func-$$entity \"<link" \
310 "linkend='func-$$entity'><function>$$ident()</function></link>\">" \
311 >>$@ ; \
312 done)
313 @( \
314 echo -e "\n<!-- Ioctls -->") >>$@
315 @( \
316 for ident in `echo $(IOCTLS) | sed -e "s,VIDIOC_RESERVED,,"`; do\
317 entity=`echo $$ident | tr _ -` ; \
318 id=`grep -e "<refname>$$ident" -e "<section id=\"$$ident\"" $$(find $(MEDIA_SRC_DIR) -name *.xml -type f)| sed -r s,"^.*/(.*).xml.*","\1",` ; \
319 if [ "$$id" != "" ]; then echo "<!ENTITY $$entity \"<link" \
320 "linkend='$$id'><constant>$$ident</constant></link>\">" \
321 >>$@ ; else \
322 echo "Warning: undocumented ioctl: $$ident. Please document it at the media DocBook!" >&2; \
323 fi; \
324 done)
325 @( \
326 echo -e "\n<!-- Defines -->") >>$@
327 @( \
328 for ident in $(DEFINES) ; do \
329 entity=`echo $$ident | tr _ -` ; \
330 echo "<!ENTITY $$entity \"<link" \
331 "linkend='$$entity'><constant>$$ident</constant></link>\">" \
332 >>$@ ; \
333 done)
334 @( \
335 echo -e "\n<!-- Types -->") >>$@
336 @( \
337 for ident in $(TYPES) ; do \
338 entity=`echo $$ident | tr _ -` ; \
339 echo "<!ENTITY $$entity \"<link" \
340 "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
341 done)
342 @( \
343 echo -e "\n<!-- Enums -->") >>$@
344 @( \
345 for ident in $(ENUMS) ; do \
346 entity=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -` ; \
347 echo "<!ENTITY $$entity \"enum&nbsp;<link" \
348 "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
349 done)
350 @( \
351 echo -e "\n<!-- Enum definitions -->") >>$@
352 @( \
353 for ident in $(ENUM_DEFS) ; do \
354 entity=`echo $$ident | tr _ -` ; \
355 echo "<!ENTITY $$entity \"<link" \
356 "linkend='$$entity'><constant>$$ident</constant></link>\">" \
357 >>$@ ; \
358 done)
359 @( \
360 echo -e "\n<!-- Structures -->") >>$@
361 @( \
362 for ident in $(STRUCTS) ; do \
363 entity=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
364 echo "<!ENTITY $$entity \"struct&nbsp;<link" \
365 "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
366 done)
367 @( \
368 echo -e "\n<!-- Error Codes -->") >>$@
369 @( \
370 for ident in $(ERRORS) ; do \
371 echo "<!ENTITY $$ident \"<errorcode>$$ident</errorcode>" \
372 "error code\">" >>$@ ; \
373 done)
374 @( \
375 echo -e "\n<!-- Subsections -->") >>$@
376 @( \
377 for file in $(MEDIA_SGMLS) ; do \
378 entity=`echo "$$file" | sed $(FILENAME) -e s/"^([^-]*)"/sub\1/` ; \
379 if ! echo "$$file" | \
380 grep -q -E -e '^(func|vidioc|pixfmt)-' ; then \
381 echo "<!ENTITY sub-$$entity SYSTEM \"$$file\">" >>$@ ; \
382 fi ; \
383 done)
384 @( \
385 echo -e "\n<!-- Function Reference -->") >>$@
386 @( \
387 for file in $(MEDIA_SGMLS) ; do \
388 if echo "$$file" | \
389 grep -q -E -e '(func|vidioc|pixfmt)-' ; then \
390 entity=`echo "$$file" |sed $(FILENAME)` ; \
391 echo "<!ENTITY $$entity SYSTEM \"$$file\">" >>$@ ; \
392 fi ; \
393 done)
395 # Jade can auto-generate a list-of-tables, which includes all structs,
396 # but we only want data types, all types, and sorted please.
397 $(MEDIA_OBJ_DIR)/media-indices.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
398 @$($(quiet)gen_xml)
399 @( \
400 echo "<!-- Generated file! Do not edit. -->") >$@
401 @( \
402 echo -e "\n<index><title>List of Types</title>") >>$@
403 @( \
404 for ident in $(TYPES) ; do \
405 id=`echo $$ident | tr _ -` ; \
406 echo "<indexentry><primaryie><link" \
407 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
408 done)
409 @( \
410 for ident in $(ENUMS) ; do \
411 id=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -`; \
412 echo "<indexentry><primaryie>enum&nbsp;<link" \
413 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
414 done)
415 @( \
416 for ident in $(STRUCTS) ; do \
417 id=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
418 echo "<indexentry><primaryie>struct&nbsp;<link" \
419 "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
420 done)
421 @( \
422 echo "</index>") >>$@