Makefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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,\(audio-mixer\|audio-karaoke\|audio-status\|ca-slot-info\|ca-descr-info\|ca-caps\|ca-msg\|ca-descr\|ca-pid\|dmx-filter\|dmx-caps\)-t,\1,g" \
  133. -e "s,DTV-ISDBT-LAYER[A-C],DTV-ISDBT-LAYER,g" \
  134. -e "s,\(define\s\+\)\([A-Z0-9_]\+\)\(\s\+_IO\),\1\<link linkend=\"\2\">\2\<\/link\>\3,g" \
  135. #
  136. # Media targets and dependencies
  137. #
  138. $(MEDIA_OBJ_DIR)/v4l2.xml:
  139. @$($(quiet)gen_xml)
  140. @(mkdir -p $(MEDIA_OBJ_DIR)/media)
  141. @(cp $(MEDIA_SRC_DIR)/dvb/*.png $(MEDIA_SRC_DIR)/v4l/*.gif $(MEDIA_OBJ_DIR)/media/)
  142. @(ln -sf $(MEDIA_SRC_DIR)/v4l/*xml $(MEDIA_OBJ_DIR)/)
  143. @(ln -sf $(MEDIA_SRC_DIR)/dvb/*xml $(MEDIA_OBJ_DIR)/)
  144. $(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/linux/videodev2.h $(MEDIA_OBJ_DIR)/v4l2.xml
  145. @$($(quiet)gen_xml)
  146. @( \
  147. echo "<programlisting>") > $@
  148. @( \
  149. expand --tabs=8 < $< | \
  150. sed $(ESCAPE) $(DOCUMENTED) | \
  151. sed 's/i\.e\./&ie;/') >> $@
  152. @( \
  153. echo "</programlisting>") >> $@
  154. $(MEDIA_OBJ_DIR)/audio.h.xml: $(srctree)/include/linux/dvb/audio.h $(MEDIA_OBJ_DIR)/v4l2.xml
  155. @$($(quiet)gen_xml)
  156. @( \
  157. echo "<programlisting>") > $@
  158. @( \
  159. expand --tabs=8 < $< | \
  160. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  161. sed 's/i\.e\./&ie;/') >> $@
  162. @( \
  163. echo "</programlisting>") >> $@
  164. $(MEDIA_OBJ_DIR)/ca.h.xml: $(srctree)/include/linux/dvb/ca.h $(MEDIA_OBJ_DIR)/v4l2.xml
  165. @$($(quiet)gen_xml)
  166. @( \
  167. echo "<programlisting>") > $@
  168. @( \
  169. expand --tabs=8 < $< | \
  170. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  171. sed 's/i\.e\./&ie;/') >> $@
  172. @( \
  173. echo "</programlisting>") >> $@
  174. $(MEDIA_OBJ_DIR)/dmx.h.xml: $(srctree)/include/linux/dvb/dmx.h $(MEDIA_OBJ_DIR)/v4l2.xml
  175. @$($(quiet)gen_xml)
  176. @( \
  177. echo "<programlisting>") > $@
  178. @( \
  179. expand --tabs=8 < $< | \
  180. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  181. sed 's/i\.e\./&ie;/') >> $@
  182. @( \
  183. echo "</programlisting>") >> $@
  184. $(MEDIA_OBJ_DIR)/frontend.h.xml: $(srctree)/include/linux/dvb/frontend.h $(MEDIA_OBJ_DIR)/v4l2.xml
  185. @$($(quiet)gen_xml)
  186. @( \
  187. echo "<programlisting>") > $@
  188. @( \
  189. expand --tabs=8 < $< | \
  190. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  191. sed 's/i\.e\./&ie;/') >> $@
  192. @( \
  193. echo "</programlisting>") >> $@
  194. $(MEDIA_OBJ_DIR)/net.h.xml: $(srctree)/include/linux/dvb/net.h $(MEDIA_OBJ_DIR)/v4l2.xml
  195. @$($(quiet)gen_xml)
  196. @( \
  197. echo "<programlisting>") > $@
  198. @( \
  199. expand --tabs=8 < $< | \
  200. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  201. sed 's/i\.e\./&ie;/') >> $@
  202. @( \
  203. echo "</programlisting>") >> $@
  204. $(MEDIA_OBJ_DIR)/osd.h.xml: $(srctree)/include/linux/dvb/osd.h $(MEDIA_OBJ_DIR)/v4l2.xml
  205. @$($(quiet)gen_xml)
  206. @( \
  207. echo "<programlisting>") > $@
  208. @( \
  209. expand --tabs=8 < $< | \
  210. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  211. sed 's/i\.e\./&ie;/') >> $@
  212. @( \
  213. echo "</programlisting>") >> $@
  214. $(MEDIA_OBJ_DIR)/video.h.xml: $(srctree)/include/linux/dvb/video.h $(MEDIA_OBJ_DIR)/v4l2.xml
  215. @$($(quiet)gen_xml)
  216. @( \
  217. echo "<programlisting>") > $@
  218. @( \
  219. expand --tabs=8 < $< | \
  220. sed $(ESCAPE) $(DVB_DOCUMENTED) | \
  221. sed 's/i\.e\./&ie;/') >> $@
  222. @( \
  223. echo "</programlisting>") >> $@
  224. $(MEDIA_OBJ_DIR)/media-entities.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
  225. @$($(quiet)gen_xml)
  226. @( \
  227. echo "<!-- Generated file! Do not edit. -->") >$@
  228. @( \
  229. echo -e "\n<!-- Functions -->") >>$@
  230. @( \
  231. for ident in $(FUNCS) ; do \
  232. entity=`echo $$ident | tr _ -` ; \
  233. echo "<!ENTITY func-$$entity \"<link" \
  234. "linkend='func-$$entity'><function>$$ident()</function></link>\">" \
  235. >>$@ ; \
  236. done)
  237. @( \
  238. echo -e "\n<!-- Ioctls -->") >>$@
  239. @( \
  240. for ident in $(IOCTLS) ; do \
  241. entity=`echo $$ident | tr _ -` ; \
  242. id=`grep "<refname>$$ident" $(MEDIA_OBJ_DIR)/vidioc-*.xml | sed -r s,"^.*/(.*).xml.*","\1",` ; \
  243. echo "<!ENTITY $$entity \"<link" \
  244. "linkend='$$id'><constant>$$ident</constant></link>\">" \
  245. >>$@ ; \
  246. done)
  247. @( \
  248. echo -e "\n<!-- Types -->") >>$@
  249. @( \
  250. for ident in $(TYPES) ; do \
  251. entity=`echo $$ident | tr _ -` ; \
  252. echo "<!ENTITY $$entity \"<link" \
  253. "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
  254. done)
  255. @( \
  256. echo -e "\n<!-- Enums -->") >>$@
  257. @( \
  258. for ident in $(ENUMS) ; do \
  259. entity=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -` ; \
  260. echo "<!ENTITY $$entity \"enum&nbsp;<link" \
  261. "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
  262. done)
  263. @( \
  264. echo -e "\n<!-- Structures -->") >>$@
  265. @( \
  266. for ident in $(STRUCTS) ; do \
  267. entity=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
  268. echo "<!ENTITY $$entity \"struct&nbsp;<link" \
  269. "linkend='$$entity'>$$ident</link>\">" >>$@ ; \
  270. done)
  271. @( \
  272. echo -e "\n<!-- Error Codes -->") >>$@
  273. @( \
  274. for ident in $(ERRORS) ; do \
  275. echo "<!ENTITY $$ident \"<errorcode>$$ident</errorcode>" \
  276. "error code\">" >>$@ ; \
  277. done)
  278. @( \
  279. echo -e "\n<!-- Subsections -->") >>$@
  280. @( \
  281. for file in $(MEDIA_SGMLS) ; do \
  282. entity=`echo "$$file" | sed $(FILENAME) -e s/"^([^-]*)"/sub\1/` ; \
  283. if ! echo "$$file" | \
  284. grep -q -E -e '^(func|vidioc|pixfmt)-' ; then \
  285. echo "<!ENTITY sub-$$entity SYSTEM \"$$file\">" >>$@ ; \
  286. fi ; \
  287. done)
  288. @( \
  289. echo -e "\n<!-- Function Reference -->") >>$@
  290. @( \
  291. for file in $(MEDIA_SGMLS) ; do \
  292. if echo "$$file" | \
  293. grep -q -E -e '(func|vidioc|pixfmt)-' ; then \
  294. entity=`echo "$$file" |sed $(FILENAME)` ; \
  295. echo "<!ENTITY $$entity SYSTEM \"$$file\">" >>$@ ; \
  296. fi ; \
  297. done)
  298. # Jade can auto-generate a list-of-tables, which includes all structs,
  299. # but we only want data types, all types, and sorted please.
  300. $(MEDIA_OBJ_DIR)/media-indices.tmpl: $(MEDIA_OBJ_DIR)/v4l2.xml
  301. @$($(quiet)gen_xml)
  302. @( \
  303. echo "<!-- Generated file! Do not edit. -->") >$@
  304. @( \
  305. echo -e "\n<index><title>List of Types</title>") >>$@
  306. @( \
  307. for ident in $(TYPES) ; do \
  308. id=`echo $$ident | tr _ -` ; \
  309. echo "<indexentry><primaryie><link" \
  310. "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
  311. done)
  312. @( \
  313. for ident in $(ENUMS) ; do \
  314. id=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -`; \
  315. echo "<indexentry><primaryie>enum&nbsp;<link" \
  316. "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
  317. done)
  318. @( \
  319. for ident in $(STRUCTS) ; do \
  320. id=`echo $$ident | tr _ - | sed s/v4l2-mpeg-vbi-ITV0/v4l2-mpeg-vbi-itv0-1/g` ; \
  321. echo "<indexentry><primaryie>struct&nbsp;<link" \
  322. "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
  323. done)
  324. @( \
  325. echo "</index>") >>$@