Makefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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. osd.h.xml \
  17. video.h.xml \
  18. IMGFILES := $(addprefix $(MEDIA_OBJ_DIR)/media/, $(notdir $(shell ls $(MEDIA_SRC_DIR)/*/*.gif $(MEDIA_SRC_DIR)/*/*.png)))
  19. GENFILES := $(addprefix $(MEDIA_OBJ_DIR)/, $(MEDIA_TEMP))
  20. PHONY += cleanmediadocs mediaindexdocs
  21. cleanmediadocs:
  22. -@rm `find $(MEDIA_OBJ_DIR) -type l` $(GENFILES) $(IMGFILES)
  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/osd.h) \
  53. $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/video.h) \
  54. $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/media.h) \
  55. $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/v4l2-subdev.h) \
  56. VIDIOC_SUBDEV_G_FRAME_INTERVAL \
  57. VIDIOC_SUBDEV_S_FRAME_INTERVAL \
  58. VIDIOC_SUBDEV_ENUM_MBUS_CODE \
  59. VIDIOC_SUBDEV_ENUM_FRAME_SIZE \
  60. VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL \
  61. TYPES = \
  62. $(shell perl -ne 'print "$$1 " if /^typedef\s+[^\s]+\s+([^\s]+)\;/' $(srctree)/include/linux/videodev2.h) \
  63. $(shell perl -ne 'print "$$1 " if /^}\s+([a-z0-9_]+_t)/' $(srctree)/include/linux/dvb/frontend.h)
  64. ENUMS = \
  65. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/videodev2.h) \
  66. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/audio.h) \
  67. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/ca.h) \
  68. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/dmx.h) \
  69. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/frontend.h) \
  70. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/net.h) \
  71. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/osd.h) \
  72. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/video.h) \
  73. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/media.h) \
  74. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-mediabus.h) \
  75. $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-subdev.h)
  76. STRUCTS = \
  77. $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/videodev2.h) \
  78. $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s\{]+)\s*/)' $(srctree)/include/linux/dvb/audio.h) \
  79. $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/ca.h) \
  80. $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/dmx.h) \
  81. $(shell perl -ne 'print "$$1 " if (!/dtv\_cmds\_h/ && /^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/frontend.h) \
  82. $(shell perl -ne 'print "$$1 " if (/^struct\s+([A-Z][^\s]+)\s+/)' $(srctree)/include/linux/dvb/net.h) \
  83. $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/osd.h) \
  84. $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/video.h) \
  85. $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/media.h) \
  86. $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-subdev.h) \
  87. $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-mediabus.h)
  88. ERRORS = \
  89. EACCES \
  90. EAGAIN \
  91. EBADF \
  92. EBUSY \
  93. EFAULT \
  94. EIO \
  95. EINTR \
  96. EINVAL \
  97. ENFILE \
  98. ENOMEM \
  99. ENOSPC \
  100. ENOTTY \
  101. ENXIO \
  102. EMFILE \
  103. EPERM \
  104. ERANGE \
  105. EPIPE \
  106. ESCAPE = \
  107. -e "s/&/\\&/g" \
  108. -e "s/</\\&lt;/g" \
  109. -e "s/>/\\&gt;/g"
  110. FILENAME = \
  111. -e s,"^[^\/]*/",, \
  112. -e s/"\\.xml"// \
  113. -e s/"\\.tmpl"// \
  114. -e s/\\\./-/g \
  115. -e s/"^func-"// \
  116. -e s/"^pixfmt-"// \
  117. -e s/"^vidioc-"//
  118. # Generate references to these structs in videodev2.h.xml.
  119. DOCUMENTED = \
  120. -e "s/\(enum *\)v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1<link linkend=\"\2\">v4l2_mpeg_cx2341x_video_\2<\/link>/g" \
  121. -e "s/\(\(enum\|struct\) *\)\(v4l2_[a-zA-Z0-9_]*\)/\1<link linkend=\"\3\">\3<\/link>/g" \
  122. -e "s/\(V4L2_PIX_FMT_[A-Z0-9_]\+\) /<link linkend=\"\1\">\1<\/link> /g" \
  123. -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
  124. -e "s/v4l2\-mpeg\-vbi\-ITV0/v4l2-mpeg-vbi-itv0-1/g"
  125. DVB_DOCUMENTED = \
  126. -e "s/\(linkend\=\"\)FE_SET_PROPERTY/\1FE_GET_PROPERTY/g" \
  127. -e "s,\(struct\s\+\)\([a-z0-9_]\+\)\(\s\+{\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
  128. -e "s,\(}\s\+\)\([a-z0-9_]\+_t\+\),\1\<link linkend=\"\2\">\2\<\/link\>,g" \
  129. -e "s,\(define\s\+\)\(DTV_[A-Z0-9_]\+\)\(\s\+[0-9]\+\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
  130. -e "s,<link linkend=\".*\">\(DTV_IOCTL_MAX_MSGS\|dtv_cmds_h\)<\/link>,\1,g" \
  131. -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
  132. -e "s,DTV-ISDBT-LAYER[A-C],DTV-ISDBT-LAYER,g" \
  133. -e "s,\(define\s\+\)\([A-Z0-9_]\+\)\(\s\+_IO\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
  134. #
  135. # Media targets and dependencies
  136. #
  137. $(MEDIA_OBJ_DIR)/v4l2.xml:
  138. @$($(quiet)gen_xml)
  139. @(mkdir -p $(MEDIA_OBJ_DIR)/media)
  140. @(cp $(MEDIA_SRC_DIR)/dvb/*.png $(MEDIA_SRC_DIR)/v4l/*.gif $(MEDIA_OBJ_DIR)/media/)
  141. @(ln -sf $(MEDIA_SRC_DIR)/v4l/*xml $(MEDIA_OBJ_DIR)/)
  142. @(ln -sf $(MEDIA_SRC_DIR)/dvb/*xml $(MEDIA_OBJ_DIR)/)
  143. $(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/linux/videodev2.h $(MEDIA_OBJ_DIR)/v4l2.xml
  144. @$($(quiet)gen_xml)
  145. @( \
  146. echo "<programlisting>") > $@
  147. @( \
  148. expand --tabs=8 < $< | \
  149. sed $(ESCAPE) $(DOCUMENTED) | \
  150. sed 's/i\.e\./&ie;/') >> $@
  151. @( \
  152. echo "</programlisting>") >> $@
  153. $(MEDIA_OBJ_DIR)/audio.h.xml: $(srctree)/include/linux/dvb/audio.h $(MEDIA_OBJ_DIR)/v4l2.xml
  154. @$($(quiet)gen_xml)
  155. @( \
  156. echo "<programlisting>") > $@
  157. @( \
  158. expand --tabs=8 < $< | \
  159. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  160. sed 's/i\.e\./&ie;/') >> $@
  161. @( \
  162. echo "</programlisting>") >> $@
  163. $(MEDIA_OBJ_DIR)/ca.h.xml: $(srctree)/include/linux/dvb/ca.h $(MEDIA_OBJ_DIR)/v4l2.xml
  164. @$($(quiet)gen_xml)
  165. @( \
  166. echo "<programlisting>") > $@
  167. @( \
  168. expand --tabs=8 < $< | \
  169. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  170. sed 's/i\.e\./&ie;/') >> $@
  171. @( \
  172. echo "</programlisting>") >> $@
  173. $(MEDIA_OBJ_DIR)/dmx.h.xml: $(srctree)/include/linux/dvb/dmx.h $(MEDIA_OBJ_DIR)/v4l2.xml
  174. @$($(quiet)gen_xml)
  175. @( \
  176. echo "<programlisting>") > $@
  177. @( \
  178. expand --tabs=8 < $< | \
  179. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  180. sed 's/i\.e\./&ie;/') >> $@
  181. @( \
  182. echo "</programlisting>") >> $@
  183. $(MEDIA_OBJ_DIR)/frontend.h.xml: $(srctree)/include/linux/dvb/frontend.h $(MEDIA_OBJ_DIR)/v4l2.xml
  184. @$($(quiet)gen_xml)
  185. @( \
  186. echo "<programlisting>") > $@
  187. @( \
  188. expand --tabs=8 < $< | \
  189. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  190. sed 's/i\.e\./&ie;/') >> $@
  191. @( \
  192. echo "</programlisting>") >> $@
  193. $(MEDIA_OBJ_DIR)/net.h.xml: $(srctree)/include/linux/dvb/net.h $(MEDIA_OBJ_DIR)/v4l2.xml
  194. @$($(quiet)gen_xml)
  195. @( \
  196. echo "<programlisting>") > $@
  197. @( \
  198. expand --tabs=8 < $< | \
  199. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  200. sed 's/i\.e\./&ie;/') >> $@
  201. @( \
  202. echo "</programlisting>") >> $@
  203. $(MEDIA_OBJ_DIR)/osd.h.xml: $(srctree)/include/linux/dvb/osd.h $(MEDIA_OBJ_DIR)/v4l2.xml
  204. @$($(quiet)gen_xml)
  205. @( \
  206. echo "<programlisting>") > $@
  207. @( \
  208. expand --tabs=8 < $< | \
  209. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  210. sed 's/i\.e\./&ie;/') >> $@
  211. @( \
  212. echo "</programlisting>") >> $@
  213. $(MEDIA_OBJ_DIR)/video.h.xml: $(srctree)/include/linux/dvb/video.h $(MEDIA_OBJ_DIR)/v4l2.xml
  214. @$($(quiet)gen_xml)
  215. @( \
  216. echo "<programlisting>") > $@
  217. @( \
  218. expand --tabs=8 < $< | \
  219. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  220. sed 's/i\.e\./&ie;/') >> $@
  221. @( \
  222. echo "</programlisting>") >> $@
  223. $(MEDIA_OBJ_DIR)/media-entities.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
  224. @$($(quiet)gen_xml)
  225. @( \
  226. echo "<!-- Generated file! Do not edit. -->") >$@
  227. @( \
  228. echo -e "\n<!-- Functions -->") >>$@
  229. @( \
  230. for ident in $(FUNCS) ; do \
  231. entity=`echo $$ident | tr _ -` ; \
  232. echo "<!ENTITY func-$$entity \"<link" \
  233. "linkend='func-$$entity'><function>$$ident()</function></link>\">" \
  234. >>$@ ; \
  235. done)
  236. @( \
  237. echo -e "\n<!-- Ioctls -->") >>$@
  238. @( \
  239. for ident in $(IOCTLS) ; do \
  240. entity=`echo $$ident | tr _ -` ; \
  241. id=`grep "<refname>$$ident" $(MEDIA_OBJ_DIR)/vidioc-*.xml | sed -r s,"^.*/(.*).xml.*","\1",` ; \
  242. echo "<!ENTITY $$entity \"<link" \
  243. "linkend='$$id'><constant>$$ident</constant></link>\">" \
  244. >>$@ ; \
  245. done)
  246. @( \
  247. echo -e "\n<!-- Types -->") >>$@
  248. @( \
  249. for ident in $(TYPES) ; do \
  250. entity=`echo $$ident | tr _ -` ; \
  251. echo "<!ENTITY $$entity \"<link" \
  252. "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
  253. done)
  254. @( \
  255. echo -e "\n<!-- Enums -->") >>$@
  256. @( \
  257. for ident in $(ENUMS) ; do \
  258. entity=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -` ; \
  259. echo "<!ENTITY $$entity \"enum&nbsp;<link" \
  260. "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
  261. done)
  262. @( \
  263. echo -e "\n<!-- Structures -->") >>$@
  264. @( \
  265. for ident in $(STRUCTS) ; do \
  266. entity=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
  267. echo "<!ENTITY $$entity \"struct&nbsp;<link" \
  268. "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
  269. done)
  270. @( \
  271. echo -e "\n<!-- Error Codes -->") >>$@
  272. @( \
  273. for ident in $(ERRORS) ; do \
  274. echo "<!ENTITY $$ident \"<errorcode>$$ident</errorcode>" \
  275. "error code\">" >>$@ ; \
  276. done)
  277. @( \
  278. echo -e "\n<!-- Subsections -->") >>$@
  279. @( \
  280. for file in $(MEDIA_SGMLS) ; do \
  281. entity=`echo "$$file" | sed $(FILENAME) -e s/"^([^-]*)"/sub\1/` ; \
  282. if ! echo "$$file" | \
  283. grep -q -E -e '^(func|vidioc|pixfmt)-' ; then \
  284. echo "<!ENTITY sub-$$entity SYSTEM \"$$file\">" >>$@ ; \
  285. fi ; \
  286. done)
  287. @( \
  288. echo -e "\n<!-- Function Reference -->") >>$@
  289. @( \
  290. for file in $(MEDIA_SGMLS) ; do \
  291. if echo "$$file" | \
  292. grep -q -E -e '(func|vidioc|pixfmt)-' ; then \
  293. entity=`echo "$$file" |sed $(FILENAME)` ; \
  294. echo "<!ENTITY $$entity SYSTEM \"$$file\">" >>$@ ; \
  295. fi ; \
  296. done)
  297. # Jade can auto-generate a list-of-tables, which includes all structs,
  298. # but we only want data types, all types, and sorted please.
  299. $(MEDIA_OBJ_DIR)/media-indices.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
  300. @$($(quiet)gen_xml)
  301. @( \
  302. echo "<!-- Generated file! Do not edit. -->") >$@
  303. @( \
  304. echo -e "\n<index><title>List of Types</title>") >>$@
  305. @( \
  306. for ident in $(TYPES) ; do \
  307. id=`echo $$ident | tr _ -` ; \
  308. echo "<indexentry><primaryie><link" \
  309. "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
  310. done)
  311. @( \
  312. for ident in $(ENUMS) ; do \
  313. id=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -`; \
  314. echo "<indexentry><primaryie>enum&nbsp;<link" \
  315. "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
  316. done)
  317. @( \
  318. for ident in $(STRUCTS) ; do \
  319. id=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
  320. echo "<indexentry><primaryie>struct&nbsp;<link" \
  321. "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
  322. done)
  323. @( \
  324. echo "</index>") >>$@