Makefile 12 KB

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