PageRenderTime 78ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/Documentation/DocBook/media/Makefile

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