SHELL=/bin/bash SGMLS = \ biblio.xml \ capture.c.xml \ keytable.c.xml \ v4l2grab.c.xml \ common.xml \ compat.xml \ controls.xml \ dev-capture.xml \ dev-codec.xml \ dev-effect.xml \ dev-osd.xml \ dev-output.xml \ dev-overlay.xml \ dev-radio.xml \ dev-raw-vbi.xml \ dev-rds.xml \ dev-sliced-vbi.xml \ dev-teletext.xml \ driver.xml \ libv4l.xml \ remote_controllers.xml \ entities.xml \ fdl-appendix.xml \ func-close.xml \ func-ioctl.xml \ func-mmap.xml \ func-munmap.xml \ func-open.xml \ func-poll.xml \ func-read.xml \ func-select.xml \ func-write.xml \ indices.xml \ io.xml \ pixfmt-grey.xml \ pixfmt-nv12.xml \ pixfmt-nv16.xml \ pixfmt-packed-rgb.xml \ pixfmt-packed-yuv.xml \ pixfmt-sbggr16.xml \ pixfmt-sbggr8.xml \ pixfmt-sgbrg8.xml \ pixfmt-sgrbg8.xml \ pixfmt-uyvy.xml \ pixfmt-vyuy.xml \ pixfmt-y16.xml \ pixfmt-y41p.xml \ pixfmt-yuv410.xml \ pixfmt-yuv411p.xml \ pixfmt-yuv420.xml \ pixfmt-yuv422p.xml \ pixfmt-yuyv.xml \ pixfmt-yvyu.xml \ pixfmt.xml \ videodev2.h.xml \ vidioc-cropcap.xml \ vidioc-dbg-g-register.xml \ vidioc-encoder-cmd.xml \ vidioc-enum-fmt.xml \ vidioc-enum-frameintervals.xml \ vidioc-enum-framesizes.xml \ vidioc-enumaudio.xml \ vidioc-enumaudioout.xml \ vidioc-enuminput.xml \ vidioc-enumoutput.xml \ vidioc-enumstd.xml \ vidioc-g-audio.xml \ vidioc-g-audioout.xml \ vidioc-dbg-g-chip-ident.xml \ vidioc-g-crop.xml \ vidioc-g-ctrl.xml \ vidioc-g-enc-index.xml \ vidioc-g-ext-ctrls.xml \ vidioc-g-fbuf.xml \ vidioc-g-fmt.xml \ vidioc-g-frequency.xml \ vidioc-g-input.xml \ vidioc-g-jpegcomp.xml \ vidioc-g-modulator.xml \ vidioc-g-output.xml \ vidioc-g-parm.xml \ vidioc-g-priority.xml \ vidioc-g-sliced-vbi-cap.xml \ vidioc-g-std.xml \ vidioc-g-tuner.xml \ vidioc-log-status.xml \ vidioc-overlay.xml \ vidioc-qbuf.xml \ vidioc-querybuf.xml \ vidioc-querycap.xml \ vidioc-queryctrl.xml \ vidioc-querystd.xml \ vidioc-reqbufs.xml \ vidioc-s-hw-freq-seek.xml \ vidioc-streamon.xml \ v4l2.sgml PDFPICS = \ crop.pdf \ fieldseq_bt.pdf \ fieldseq_tb.pdf \ vbi_525.pdf \ vbi_625.pdf \ vbi_hsync.pdf GIFPICS = \ crop.gif \ fieldseq_bt.gif \ fieldseq_tb.gif \ vbi_525.gif \ vbi_625.gif \ vbi_hsync.gif # Some Jade warnings for authors. WARN = #WARN = -w all -w duplicate -w net # Stylesheet customization. # docbook/db2 syntax CUSTOM_HTML = --dsl custom.dsl\#html CUSTOM_PRINT = --dsl custom.dsl\#print # xmlto syntax CUSTOM_HTML_XMLTO = -m custom.xsl CUSTOM_PRINT_XMLTO = -m custom.xsl all: capture html-single html: html-build.stamp html-single: html-single-build.stamp pdf: pdf-build.stamp man: man-build.stamp man_install: man-build.stamp install -d /usr/local/man/man2 install -b man/* /usr/local/man/man2 coffeebreak: all html pdf FUNCS = \ close \ ioctl \ mmap \ munmap \ open \ poll \ read \ select \ write \ IOCTLS = \ VIDIOC_CROPCAP \ VIDIOC_DBG_G_CHIP_IDENT \ VIDIOC_DBG_G_REGISTER \ VIDIOC_DBG_S_REGISTER \ VIDIOC_DQBUF \ VIDIOC_ENCODER_CMD \ VIDIOC_ENUMAUDIO \ VIDIOC_ENUMAUDOUT \ VIDIOC_ENUMINPUT \ VIDIOC_ENUMOUTPUT \ VIDIOC_ENUMSTD \ VIDIOC_ENUM_FMT \ VIDIOC_ENUM_FRAMEINTERVALS \ VIDIOC_ENUM_FRAMESIZES \ VIDIOC_G_AUDIO \ VIDIOC_G_AUDOUT \ VIDIOC_G_CROP \ VIDIOC_G_CTRL \ VIDIOC_G_ENC_INDEX \ VIDIOC_G_EXT_CTRLS \ VIDIOC_G_FBUF \ VIDIOC_G_FMT \ VIDIOC_G_FREQUENCY \ VIDIOC_G_INPUT \ VIDIOC_G_JPEGCOMP \ VIDIOC_G_MPEGCOMP \ VIDIOC_G_MODULATOR \ VIDIOC_G_OUTPUT \ VIDIOC_G_PARM \ VIDIOC_G_PRIORITY \ VIDIOC_G_SLICED_VBI_CAP \ VIDIOC_G_STD \ VIDIOC_G_TUNER \ VIDIOC_LOG_STATUS \ VIDIOC_OVERLAY \ VIDIOC_QBUF \ VIDIOC_QUERYBUF \ VIDIOC_QUERYCAP \ VIDIOC_QUERYCTRL \ VIDIOC_QUERYMENU \ VIDIOC_QUERYSTD \ VIDIOC_REQBUFS \ VIDIOC_STREAMOFF \ VIDIOC_STREAMON \ VIDIOC_S_AUDIO \ VIDIOC_S_AUDOUT \ VIDIOC_S_CROP \ VIDIOC_S_CTRL \ VIDIOC_S_EXT_CTRLS \ VIDIOC_S_FBUF \ VIDIOC_S_FMT \ VIDIOC_S_FREQUENCY \ VIDIOC_S_HW_FREQ_SEEK \ VIDIOC_S_INPUT \ VIDIOC_S_JPEGCOMP \ VIDIOC_S_MPEGCOMP \ VIDIOC_S_MODULATOR \ VIDIOC_S_OUTPUT \ VIDIOC_S_PARM \ VIDIOC_S_PRIORITY \ VIDIOC_S_STD \ VIDIOC_S_TUNER \ VIDIOC_TRY_ENCODER_CMD \ VIDIOC_TRY_EXT_CTRLS \ VIDIOC_TRY_FMT \ TYPES = \ v4l2_std_id \ ENUMS = \ v4l2_buf_type \ v4l2_colorspace \ v4l2_ctrl_type \ v4l2_exposure_auto_type \ v4l2_field \ v4l2_frmivaltypes \ v4l2_frmsizetypes \ v4l2_memory \ v4l2_mpeg_audio_ac3_bitrate \ v4l2_mpeg_audio_crc \ v4l2_mpeg_audio_emphasis \ v4l2_mpeg_audio_encoding \ v4l2_mpeg_audio_l1_bitrate \ v4l2_mpeg_audio_l2_bitrate \ v4l2_mpeg_audio_l3_bitrate \ v4l2_mpeg_audio_mode \ v4l2_mpeg_audio_mode_extension \ v4l2_mpeg_audio_sampling_freq \ v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type \ v4l2_mpeg_cx2341x_video_luma_spatial_filter_type \ v4l2_mpeg_cx2341x_video_median_filter_type \ v4l2_mpeg_cx2341x_video_spatial_filter_mode \ v4l2_mpeg_cx2341x_video_temporal_filter_mode \ v4l2_mpeg_stream_type \ v4l2_mpeg_stream_vbi_fmt \ v4l2_mpeg_video_aspect \ v4l2_mpeg_video_bitrate_mode \ v4l2_mpeg_video_encoding \ v4l2_power_line_frequency \ v4l2_priority \ v4l2_tuner_type \ v4l2_preemphasis \ STRUCTS = \ v4l2_audio \ v4l2_audioout \ v4l2_buffer \ v4l2_capability \ v4l2_captureparm \ v4l2_clip \ v4l2_control \ v4l2_crop \ v4l2_cropcap \ v4l2_dbg_chip_ident \ v4l2_dbg_match \ v4l2_dbg_register \ v4l2_enc_idx \ v4l2_enc_idx_entry \ v4l2_encoder_cmd \ v4l2_ext_control \ v4l2_ext_controls \ v4l2_fmtdesc \ v4l2_format \ v4l2_fract \ v4l2_framebuffer \ v4l2_frequency \ v4l2_frmival_stepwise \ v4l2_frmivalenum \ v4l2_frmsize_discrete \ v4l2_frmsize_stepwise \ v4l2_frmsizeenum \ v4l2_hw_freq_seek \ v4l2_input \ v4l2_jpegcompression \ v4l2_modulator \ v4l2_mpeg_vbi_fmt_ivtv \ v4l2_output \ v4l2_outputparm \ v4l2_pix_format \ v4l2_queryctrl \ v4l2_querymenu \ v4l2_rect \ v4l2_requestbuffers \ v4l2_sliced_vbi_cap \ v4l2_sliced_vbi_data \ v4l2_sliced_vbi_format \ v4l2_standard \ v4l2_streamparm \ v4l2_timecode \ v4l2_tuner \ v4l2_vbi_format \ v4l2_window \ ERRORS = \ EACCES \ EAGAIN \ EBADF \ EBUSY \ EFAULT \ EIO \ EINTR \ EINVAL \ ENFILE \ ENOMEM \ ENOSPC \ ENOTTY \ ENXIO \ EMFILE \ EPERM \ ERANGE \ ESCAPE = \ -e "s/&/\\&/g" \ -e "s//\\>/g" # Generate references to these structs in videodev2.h.xml. DOCUMENTED = \ -e "s/\(enum *\)v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1v4l2_mpeg_cx2341x_video_\2<\/link>/g" \ -e "s/\(\(enum\|struct\) *\)\(v4l2_[a-zA-Z0-9_]*\)/\1\3<\/link>/g" \ -e "s/\(V4L2_PIX_FMT_[A-Z0-9_]\+\) /\1<\/link> /g" \ -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \ -e "s/(linkend=\")v4l2-mpeg-vbi-ITV0/\1)v4l2_mpeg_vbi_itv0-1/g" .PHONY: links $(SGMLS): links $(PDFPICS): links $(GIFPICS): links links:: ln -sf ../linux/Documentation/DocBook/v4l/* . libv4l-fmt.xml: ../v4l2-apps/libv4l/libv4lconvert/*.c Makefile cat ../v4l2-apps/libv4l/libv4lconvert/*.c| \ perl -ne 'if (m/(V4L2_PIX_FMT_[^\s\;\\)\,:]+)/) { printf "$$1,\n"; };' \ |sort|uniq| \ sed -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" > $@ capture.c.xml: ../v4l2-apps/test/capture-example.c Makefile echo "" > $@ expand --tabs=8 < $< | \ sed $(ESCAPE) $(DOCUMENTED) | \ sed 's/i\.e\./&ie;/' >> $@ echo "" >> $@ v4l2grab.c.xml: ../v4l2-apps/test/v4l2grab.c Makefile echo "" > $@ expand --tabs=8 < $< | \ sed $(ESCAPE) $(DOCUMENTED) | \ sed 's/i\.e\./&ie;/' >> $@ echo "" >> $@ keytable.c.xml: ../v4l2-apps/util/keytable.c Makefile echo "" > $@ expand --tabs=8 < $< | \ sed $(ESCAPE) $(DOCUMENTED) | \ sed 's/i\.e\./&ie;/' >> $@ echo "" >> $@ videodev2.h.xml: ../linux/include/linux/videodev2.h Makefile echo "" > $@ expand --tabs=8 < $< | \ sed $(ESCAPE) $(DOCUMENTED) | \ sed 's/i\.e\./&ie;/' >> $@ echo "" >> $@ checks: $(SGMLS) # Warn about FOO-BAR which should be # &FOO-BAR; or FOO_BAR. (! grep '>[A-Z]+-[A-Z-]+<' *.xml) # Don't end a refpurpose blob with a period. (! grep '\.' *.xml) # Catch typos in error code names. errs=`grep '[^<]\+' *.xml | \ sed 's/.*//;s/<\/errorcode>.*//' | sort -u` ; \ for err in $$errs; do \ if ! echo $(ERRORS) | grep -q $$err ; then \ echo Unknown error code $$err ; exit 1 ; \ fi ; \ done # Use the respective entities instead. for abbrev in "e\\.g\\." "i\\.e\\." "i2c" ; do \ grep "[^a-z&]$$abbrev[^a-z.;-]" *.xml | \ grep -v -E "(ENTITY|videodev2\.h)" && exit 1 ; \ done ; \ exit 0 # We're generating these entities to avoid typos, to enforce consistent # naming, an to be warned about missing items (Jade screams bloody murder # if references are dangling). entities.xml: Makefile $(SGMLS) echo "" >$@ echo -e "\n" >>$@ for ident in $(FUNCS) ; do \ entity=`echo $$ident | tr _ -` ; \ echo "$$ident()\">" \ >>$@ ; \ done echo -e "\n" >>$@ for ident in $(IOCTLS) ; do \ entity=`echo $$ident | tr _ -` ; \ id=`grep "$$ident" vidioc-*.xml | sed 's/\.xml.*//'` ; \ echo "$$ident\">" \ >>$@ ; \ done echo -e "\n" >>$@ for ident in $(TYPES) ; do \ entity=`echo $$ident | tr _ -` ; \ echo "$$ident\">" >>$@ ; \ done echo -e "\n" >>$@ for ident in $(ENUMS) ; do \ entity=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -` ; \ echo "$$ident\">" >>$@ ; \ done echo -e "\n" >>$@ for ident in $(STRUCTS) ; do \ entity=`echo $$ident | tr _ -` ; \ echo "$$ident\">" >>$@ ; \ done echo -e "\n" >>$@ for ident in $(ERRORS) ; do \ echo "$$ident" \ "error code\">" >>$@ ; \ done echo -e "\n" >>$@ for file in $(SGMLS) ; do \ entity=`echo "$$file" | sed 's/.xml//;s/\./-/g'` ; \ if ! echo "$$file" | \ grep -q -E -e '^(func|vidioc|pixfmt)-' ; then \ echo "" >>$@ ; \ fi ; \ done echo -e "\n" >>$@ for file in $(SGMLS) ; do \ if echo "$$file" | \ grep -q -E -e '^(func|vidioc|pixfmt)-' ; then \ entity=`echo "$$file" | sed 's/^[^-]*/sub/;s/.xml//'` ; \ echo "" >>$@ ; \ fi ; \ done # Jade can auto-generate a list-of-tables, which includes all structs, # but we only want data types, all types, and sorted please. indices.xml: Makefile $(SGMLS) echo "" >$@ echo -e "\nList of Types" >>$@ for ident in $(TYPES) ; do \ id=`echo $$ident | tr _ -` ; \ echo "$$ident" >>$@ ; \ done for ident in $(ENUMS) ; do \ id=`echo $$ident | sed -e "s/v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1/" | tr _ -`; \ echo "enum $$ident" >>$@ ; \ done for ident in $(STRUCTS) ; do \ id=`echo $$ident | tr _ -` ; \ echo "struct $$ident" >>$@ ; \ done echo "" >>$@ # HTML version. html-build.stamp: Makefile checks $(SGMLS) $(GIFPICS) rm -rf v4l2 if which xmlto >/dev/null ; then \ xmlto xhtml $(WARN) $(CUSTOM_HTML_XMLTO) -o v4l2 v4l2.sgml ; \ elif which docbook2html >/dev/null ; then \ export DCL="--dcl `find /usr/share.xml -name xml.dcl |head -1`"; \ docbook2html $(WARN) $$DCL $(CUSTOM_HTML) --output v4l2 v4l2.sgml ; \ else \ export DCL="--dcl `find /usr/share.xml -name xml.dcl |head -1`"; \ db2html $(WARN) $$DCL $(CUSTOM_HTML) --output v4l2 v4l2.sgml ; \ fi cp $(GIFPICS) v4l2/ cd v4l2 ; \ test -e index.html || ln -s book1.htm index.html ; \ test -e capture-example.html || \ ln -s `grep -l getopt_long *.htm` capture-example.html chmod a+rX -R v4l2 touch html-build.stamp # For online version. When you have a dial-up connection a single file # is more convenient than clicking through dozens of pages. html-single-build.stamp: Makefile checks $(SGMLS) $(GIFPICS) rm -rf v4l2-single if which xmlto >/dev/null ; then \ xmlto html-nochunks $(WARN) $(CUSTOM_HTML_XMLTO) -o v4l2-single v4l2.sgml ; \ elif which docbook2html >/dev/null ; then \ export DCL="--dcl `find /usr/share.xml -name xml.dcl |head -1`"; \ docbook2html $$DCL $(WARN) $(CUSTOM_HTML) --nochunks \ --output v4l2-single v4l2.sgml ; \ else \ export DCL="--dcl `find /usr/share.xml -name xml.dcl |head -1`"; \ db2html $$DCL $(WARN) $(CUSTOM_HTML) --nochunks \ --output v4l2-single v4l2.sgml ; \ fi cp $(GIFPICS) v4l2-single/ chmod a+rX -R v4l2-single touch html-single-build.stamp # For printing. pdf-build.stamp: Makefile checks $(SGMLS) $(PDFPICS) if which db2pdf >/dev/null ; then \ export DCL="--dcl `find /usr/share.xml -name xml.dcl|head -1`"; \ db2pdf $$DCL $(WARN) $(CUSTOM_PRINT) v4l2.sgml ; \ elif which xmlto >/dev/null ; then \ xmlto pdf $(WARN) $(CUSTOM_HTML_XMLTO) -o v4l2-single v4l2.sgml ; \ else \ export DCL="--dcl `find /usr/share.xml -name xml.dcl |head -1`"; \ docbook2pdf $$DCL $(WARN) $(CUSTOM_PRINT) v4l2.sgml ; \ fi touch pdf-build.stamp # For man man-build.stamp: Makefile checks $(SGMLS) $(PDFPICS) xmlto man $(WARN) $(CUSTOM_HTML_XMLTO) -o man v4l2.sgml # Example. capture: ../v4l2-apps/test/capture-example.c gcc $^ -o $@ distclean clean: rm -f *.stamp rm -f videodev2.h.xml rm -f capture.c.xml rm -f v4l2grab.c.xml rm -f capture rm -f indices.xml entities.xml rm -rf v4l2 v4l2-single v4l2.pdf man find . -type l -exec rm '{}' \;