PageRenderTime 1256ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 0ms

/Documentation/DocBook/media/Makefile

https://github.com/yz2365/linux-2.6
Makefile | 386 lines | 339 code | 35 blank | 12 comment | 47 complexity | b9a9803ff1d4eb8dd44aaf48964fbd6c MD5 | raw file
  1. ###
  2. # Media build rules - Auto-generates media contents/indexes and *.h xml's
  3. #
  4. SHELL=/bin/bash
  5. MEDIA_OBJ_DIR=$(objtree)/Documentation/DocBook/
  6. MEDIA_SRC_DIR=$(srctree)/Documentation/DocBook/media
  7. MEDIA_TEMP = media-entities.tmpl \
  8. media-indices.tmpl \
  9. videodev2.h.xml \
  10. v4l2.xml \
  11. audio.h.xml \
  12. ca.h.xml \
  13. dmx.h.xml \
  14. frontend.h.xml \
  15. net.h.xml \
  16. video.h.xml \
  17. IMGFILES := $(patsubst %.b64,%, $(notdir $(shell ls $(MEDIA_SRC_DIR)/*.b64)))
  18. OBJIMGFILES := $(addprefix $(MEDIA_OBJ_DIR)/, $(IMGFILES))
  19. GENFILES := $(addprefix $(MEDIA_OBJ_DIR)/, $(MEDIA_TEMP))
  20. PHONY += cleanmediadocs
  21. cleanmediadocs:
  22. -@rm `find $(MEDIA_OBJ_DIR) -type l` $(GENFILES) $(OBJIMGFILES) 2>/dev/null
  23. $(obj)/media_api.xml: $(GENFILES) FORCE
  24. #$(MEDIA_OBJ_DIR)/media_api.html: $(MEDIA_OBJ_DIR)/media_api.xml
  25. #$(MEDIA_OBJ_DIR)/media_api.pdf: $(MEDIA_OBJ_DIR)/media_api.xml
  26. #$(MEDIA_OBJ_DIR)/media_api.ps: $(MEDIA_OBJ_DIR)/media_api.xml
  27. V4L_SGMLS = \
  28. $(shell ls $(MEDIA_SRC_DIR)/v4l/*.xml|perl -ne 'print "$$1 " if (m,.*/(.*)\n,)') \
  29. capture.c.xml \
  30. keytable.c.xml \
  31. v4l2grab.c.xml
  32. DVB_SGMLS = \
  33. $(shell ls $(MEDIA_SRC_DIR)/dvb/*.xml|perl -ne 'print "$$1 " if (m,.*/(.*)\n,)')
  34. MEDIA_SGMLS = $(addprefix ./,$(V4L_SGMLS)) $(addprefix ./,$(DVB_SGMLS)) $(addprefix ./,$(MEDIA_TEMP))
  35. FUNCS = \
  36. close \
  37. ioctl \
  38. mmap \
  39. munmap \
  40. open \
  41. poll \
  42. read \
  43. select \
  44. write \
  45. IOCTLS = \
  46. $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/videodev2.h) \
  47. $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/audio.h) \
  48. $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/ca.h) \
  49. $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/dmx.h) \
  50. $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/frontend.h) \
  51. $(shell perl -ne 'print "$$1 " if /\#define\s+([A-Z][^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/net.h) \
  52. $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/video.h) \
  53. $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/media.h) \
  54. $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/v4l2-subdev.h) \
  55. VIDIOC_SUBDEV_G_FRAME_INTERVAL \
  56. VIDIOC_SUBDEV_S_FRAME_INTERVAL \
  57. VIDIOC_SUBDEV_ENUM_MBUS_CODE \
  58. VIDIOC_SUBDEV_ENUM_FRAME_SIZE \
  59. VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL \
  60. TYPES = \
  61. $(shell perl -ne 'print "$$1 " if /^typedef\s+[^\s]+\s+([^\s]+)\;/' $(srctree)/include/linux/videodev2.h) \
  62. $(shell perl -ne 'print "$$1 " if /^}\s+([a-z0-9_]+_t)/' $(srctree)/include/linux/dvb/frontend.h)
  63. ENUMS = \
  64. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/videodev2.h) \
  65. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/audio.h) \
  66. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/ca.h) \
  67. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/dmx.h) \
  68. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/frontend.h) \
  69. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/net.h) \
  70. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/video.h) \
  71. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/media.h) \
  72. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-mediabus.h) \
  73. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-subdev.h)
  74. STRUCTS = \
  75. $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/videodev2.h) \
  76. $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s\{]+)\s*/)' $(srctree)/include/linux/dvb/audio.h) \
  77. $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/ca.h) \
  78. $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/dmx.h) \
  79. $(shell perl -ne 'print "$$1 " if (!/dtv\_cmds\_h/ && /^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/frontend.h) \
  80. $(shell perl -ne 'print "$$1 " if (/^struct\s+([A-Z][^\s]+)\s+/)' $(srctree)/include/linux/dvb/net.h) \
  81. $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/video.h) \
  82. $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/media.h) \
  83. $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-subdev.h) \
  84. $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-mediabus.h)
  85. ERRORS = \
  86. E2BIG \
  87. EACCES \
  88. EAGAIN \
  89. EBADF \
  90. EBADFD \
  91. EBADR \
  92. EBADRQC \
  93. EBUSY \
  94. ECHILD \
  95. ECONNRESET \
  96. EDEADLK \
  97. EDOM \
  98. EEXIST \
  99. EFAULT \
  100. EFBIG \
  101. EILSEQ \
  102. EINIT \
  103. EINPROGRESS \
  104. EINTR \
  105. EINVAL \
  106. EIO \
  107. EMFILE \
  108. ENFILE \
  109. ENOBUFS \
  110. ENODATA \
  111. ENODEV \
  112. ENOENT \
  113. ENOIOCTLCMD \
  114. ENOMEM \
  115. ENOSPC \
  116. ENOSR \
  117. ENOSYS \
  118. ENOTSUP \
  119. ENOTSUPP \
  120. ENOTTY \
  121. ENXIO \
  122. EOPNOTSUPP \
  123. EOVERFLOW \
  124. EPERM \
  125. EPIPE \
  126. EPROTO \
  127. ERANGE \
  128. EREMOTE \
  129. EREMOTEIO \
  130. ERESTART \
  131. ERESTARTSYS \
  132. ESHUTDOWN \
  133. ESPIPE \
  134. ETIME \
  135. ETIMEDOUT \
  136. EUSERS \
  137. EWOULDBLOCK \
  138. EXDEV \
  139. ESCAPE = \
  140. -e "s/&/\\&/g" \
  141. -e "s/</\\&lt;/g" \
  142. -e "s/>/\\&gt;/g"
  143. FILENAME = \
  144. -e s,"^[^\/]*/",, \
  145. -e s/"\\.xml"// \
  146. -e s/"\\.tmpl"// \
  147. -e s/\\\./-/g \
  148. -e s/"^func-"// \
  149. -e s/"^pixfmt-"// \
  150. -e s/"^vidioc-"//
  151. # Generate references to these structs in videodev2.h.xml.
  152. DOCUMENTED = \
  153. -e "s/\(enum *\)v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1<link linkend=\"\2\">v4l2_mpeg_cx2341x_video_\2<\/link>/g" \
  154. -e "s/\(\(enum\|struct\) *\)\(v4l2_[a-zA-Z0-9_]*\)/\1<link linkend=\"\3\">\3<\/link>/g" \
  155. -e "s/\(V4L2_PIX_FMT_[A-Z0-9_]\+\) /<link linkend=\"\1\">\1<\/link> /g" \
  156. -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
  157. -e "s/v4l2\-mpeg\-vbi\-ITV0/v4l2-mpeg-vbi-itv0-1/g"
  158. DVB_DOCUMENTED = \
  159. -e "s/\(linkend\=\"\)FE_SET_PROPERTY/\1FE_GET_PROPERTY/g" \
  160. -e "s,\(struct\s\+\)\([a-z0-9_]\+\)\(\s\+{\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
  161. -e "s,\(}\s\+\)\([a-z0-9_]\+_t\+\),\1\<link linkend=\"\2\">\2\<\/link\>,g" \
  162. -e "s,\(define\s\+\)\(DTV_[A-Z0-9_]\+\)\(\s\+[0-9]\+\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
  163. -e "s,<link\s\+linkend=\".*\">\(DTV_IOCTL_MAX_MSGS\|dtv_cmds_h\|__.*_old\)<\/link>,\1,g" \
  164. -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
  165. -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" \
  166. -e "s,DTV-ISDBT-LAYER[A-C],DTV-ISDBT-LAYER,g" \
  167. -e "s,\(define\s\+\)\([A-Z0-9_]\+\)\(\s\+_IO\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
  168. -e "s,<link\s\+linkend=\".*\">\(__.*_OLD\)<\/link>,\1,g" \
  169. #
  170. # Media targets and dependencies
  171. #
  172. install_media_images = \
  173. $(Q)cp $(OBJIMGFILES) $(MEDIA_OBJ_DIR)/media_api
  174. $(MEDIA_OBJ_DIR)/%: $(MEDIA_SRC_DIR)/%.b64
  175. $(Q)base64 -d $< >$@
  176. $(MEDIA_OBJ_DIR)/v4l2.xml: $(OBJIMGFILES)
  177. @$($(quiet)gen_xml)
  178. @(ln -sf $(MEDIA_SRC_DIR)/v4l/*xml $(MEDIA_OBJ_DIR)/)
  179. @(ln -sf $(MEDIA_SRC_DIR)/dvb/*xml $(MEDIA_OBJ_DIR)/)
  180. $(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/linux/videodev2.h $(MEDIA_OBJ_DIR)/v4l2.xml
  181. @$($(quiet)gen_xml)
  182. @( \
  183. echo "<programlisting>") > $@
  184. @( \
  185. expand --tabs=8 < $< | \
  186. sed $(ESCAPE) $(DOCUMENTED) | \
  187. sed 's/i\.e\./&ie;/') >> $@
  188. @( \
  189. echo "</programlisting>") >> $@
  190. $(MEDIA_OBJ_DIR)/audio.h.xml: $(srctree)/include/linux/dvb/audio.h $(MEDIA_OBJ_DIR)/v4l2.xml
  191. @$($(quiet)gen_xml)
  192. @( \
  193. echo "<programlisting>") > $@
  194. @( \
  195. expand --tabs=8 < $< | \
  196. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  197. sed 's/i\.e\./&ie;/') >> $@
  198. @( \
  199. echo "</programlisting>") >> $@
  200. $(MEDIA_OBJ_DIR)/ca.h.xml: $(srctree)/include/linux/dvb/ca.h $(MEDIA_OBJ_DIR)/v4l2.xml
  201. @$($(quiet)gen_xml)
  202. @( \
  203. echo "<programlisting>") > $@
  204. @( \
  205. expand --tabs=8 < $< | \
  206. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  207. sed 's/i\.e\./&ie;/') >> $@
  208. @( \
  209. echo "</programlisting>") >> $@
  210. $(MEDIA_OBJ_DIR)/dmx.h.xml: $(srctree)/include/linux/dvb/dmx.h $(MEDIA_OBJ_DIR)/v4l2.xml
  211. @$($(quiet)gen_xml)
  212. @( \
  213. echo "<programlisting>") > $@
  214. @( \
  215. expand --tabs=8 < $< | \
  216. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  217. sed 's/i\.e\./&ie;/') >> $@
  218. @( \
  219. echo "</programlisting>") >> $@
  220. $(MEDIA_OBJ_DIR)/frontend.h.xml: $(srctree)/include/linux/dvb/frontend.h $(MEDIA_OBJ_DIR)/v4l2.xml
  221. @$($(quiet)gen_xml)
  222. @( \
  223. echo "<programlisting>") > $@
  224. @( \
  225. expand --tabs=8 < $< | \
  226. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  227. sed 's/i\.e\./&ie;/') >> $@
  228. @( \
  229. echo "</programlisting>") >> $@
  230. $(MEDIA_OBJ_DIR)/net.h.xml: $(srctree)/include/linux/dvb/net.h $(MEDIA_OBJ_DIR)/v4l2.xml
  231. @$($(quiet)gen_xml)
  232. @( \
  233. echo "<programlisting>") > $@
  234. @( \
  235. expand --tabs=8 < $< | \
  236. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  237. sed 's/i\.e\./&ie;/') >> $@
  238. @( \
  239. echo "</programlisting>") >> $@
  240. $(MEDIA_OBJ_DIR)/video.h.xml: $(srctree)/include/linux/dvb/video.h $(MEDIA_OBJ_DIR)/v4l2.xml
  241. @$($(quiet)gen_xml)
  242. @( \
  243. echo "<programlisting>") > $@
  244. @( \
  245. expand --tabs=8 < $< | \
  246. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  247. sed 's/i\.e\./&ie;/') >> $@
  248. @( \
  249. echo "</programlisting>") >> $@
  250. $(MEDIA_OBJ_DIR)/media-entities.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
  251. @$($(quiet)gen_xml)
  252. @( \
  253. echo "<!-- Generated file! Do not edit. -->") >$@
  254. @( \
  255. echo -e "\n<!-- Functions -->") >>$@
  256. @( \
  257. for ident in $(FUNCS) ; do \
  258. entity=`echo $$ident | tr _ -` ; \
  259. echo "<!ENTITY func-$$entity \"<link" \
  260. "linkend='func-$$entity'><function>$$ident()</function></link>\">" \
  261. >>$@ ; \
  262. done)
  263. @( \
  264. echo -e "\n<!-- Ioctls -->") >>$@
  265. @( \
  266. for ident in $(IOCTLS) ; do \
  267. entity=`echo $$ident | tr _ -` ; \
  268. id=`grep "<refname>$$ident" $(MEDIA_OBJ_DIR)/vidioc-*.xml | sed -r s,"^.*/(.*).xml.*","\1",` ; \
  269. echo "<!ENTITY $$entity \"<link" \
  270. "linkend='$$id'><constant>$$ident</constant></link>\">" \
  271. >>$@ ; \
  272. done)
  273. @( \
  274. echo -e "\n<!-- Types -->") >>$@
  275. @( \
  276. for ident in $(TYPES) ; do \
  277. entity=`echo $$ident | tr _ -` ; \
  278. echo "<!ENTITY $$entity \"<link" \
  279. "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
  280. done)
  281. @( \
  282. echo -e "\n<!-- Enums -->") >>$@
  283. @( \
  284. for ident in $(ENUMS) ; do \
  285. entity=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -` ; \
  286. echo "<!ENTITY $$entity \"enum&nbsp;<link" \
  287. "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
  288. done)
  289. @( \
  290. echo -e "\n<!-- Structures -->") >>$@
  291. @( \
  292. for ident in $(STRUCTS) ; do \
  293. entity=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
  294. echo "<!ENTITY $$entity \"struct&nbsp;<link" \
  295. "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
  296. done)
  297. @( \
  298. echo -e "\n<!-- Error Codes -->") >>$@
  299. @( \
  300. for ident in $(ERRORS) ; do \
  301. echo "<!ENTITY $$ident \"<errorcode>$$ident</errorcode>" \
  302. "error code\">" >>$@ ; \
  303. done)
  304. @( \
  305. echo -e "\n<!-- Subsections -->") >>$@
  306. @( \
  307. for file in $(MEDIA_SGMLS) ; do \
  308. entity=`echo "$$file" | sed $(FILENAME) -e s/"^([^-]*)"/sub\1/` ; \
  309. if ! echo "$$file" | \
  310. grep -q -E -e '^(func|vidioc|pixfmt)-' ; then \
  311. echo "<!ENTITY sub-$$entity SYSTEM \"$$file\">" >>$@ ; \
  312. fi ; \
  313. done)
  314. @( \
  315. echo -e "\n<!-- Function Reference -->") >>$@
  316. @( \
  317. for file in $(MEDIA_SGMLS) ; do \
  318. if echo "$$file" | \
  319. grep -q -E -e '(func|vidioc|pixfmt)-' ; then \
  320. entity=`echo "$$file" |sed $(FILENAME)` ; \
  321. echo "<!ENTITY $$entity SYSTEM \"$$file\">" >>$@ ; \
  322. fi ; \
  323. done)
  324. # Jade can auto-generate a list-of-tables, which includes all structs,
  325. # but we only want data types, all types, and sorted please.
  326. $(MEDIA_OBJ_DIR)/media-indices.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
  327. @$($(quiet)gen_xml)
  328. @( \
  329. echo "<!-- Generated file! Do not edit. -->") >$@
  330. @( \
  331. echo -e "\n<index><title>List of Types</title>") >>$@
  332. @( \
  333. for ident in $(TYPES) ; do \
  334. id=`echo $$ident | tr _ -` ; \
  335. echo "<indexentry><primaryie><link" \
  336. "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
  337. done)
  338. @( \
  339. for ident in $(ENUMS) ; do \
  340. id=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -`; \
  341. echo "<indexentry><primaryie>enum&nbsp;<link" \
  342. "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
  343. done)
  344. @( \
  345. for ident in $(STRUCTS) ; do \
  346. id=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
  347. echo "<indexentry><primaryie>struct&nbsp;<link" \
  348. "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
  349. done)
  350. @( \
  351. echo "</index>") >>$@