18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci# Rules to convert a .h file to inline RST documentation
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ciSRC_DIR=$(srctree)/Documentation/userspace-api/media
68c2ecf20Sopenharmony_ciPARSER = $(srctree)/Documentation/sphinx/parse-headers.pl
78c2ecf20Sopenharmony_ciUAPI = $(srctree)/include/uapi/linux
88c2ecf20Sopenharmony_ciKAPI = $(srctree)/include/linux
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciFILES = audio.h.rst ca.h.rst dmx.h.rst frontend.h.rst net.h.rst video.h.rst \
118c2ecf20Sopenharmony_ci	  videodev2.h.rst media.h.rst cec.h.rst lirc.h.rst
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciTARGETS := $(addprefix $(BUILDDIR)/, $(FILES))
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cigen_rst = \
168c2ecf20Sopenharmony_ci	echo ${PARSER} $< $@ $(SRC_DIR)/$(notdir $@).exceptions; \
178c2ecf20Sopenharmony_ci	${PARSER} $< $@ $(SRC_DIR)/$(notdir $@).exceptions
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciquiet_gen_rst = echo '  PARSE   $(patsubst $(srctree)/%,%,$<)'; \
208c2ecf20Sopenharmony_ci	${PARSER} $< $@ $(SRC_DIR)/$(notdir $@).exceptions
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cisilent_gen_rst = ${gen_rst}
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci$(BUILDDIR)/audio.h.rst: ${UAPI}/dvb/audio.h ${PARSER} $(SRC_DIR)/audio.h.rst.exceptions
258c2ecf20Sopenharmony_ci	@$($(quiet)gen_rst)
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci$(BUILDDIR)/ca.h.rst: ${UAPI}/dvb/ca.h ${PARSER} $(SRC_DIR)/ca.h.rst.exceptions
288c2ecf20Sopenharmony_ci	@$($(quiet)gen_rst)
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci$(BUILDDIR)/dmx.h.rst: ${UAPI}/dvb/dmx.h ${PARSER} $(SRC_DIR)/dmx.h.rst.exceptions
318c2ecf20Sopenharmony_ci	@$($(quiet)gen_rst)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci$(BUILDDIR)/frontend.h.rst: ${UAPI}/dvb/frontend.h ${PARSER} $(SRC_DIR)/frontend.h.rst.exceptions
348c2ecf20Sopenharmony_ci	@$($(quiet)gen_rst)
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci$(BUILDDIR)/net.h.rst: ${UAPI}/dvb/net.h ${PARSER} $(SRC_DIR)/net.h.rst.exceptions
378c2ecf20Sopenharmony_ci	@$($(quiet)gen_rst)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci$(BUILDDIR)/video.h.rst: ${UAPI}/dvb/video.h ${PARSER} $(SRC_DIR)/video.h.rst.exceptions
408c2ecf20Sopenharmony_ci	@$($(quiet)gen_rst)
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci$(BUILDDIR)/videodev2.h.rst: ${UAPI}/videodev2.h ${PARSER} $(SRC_DIR)/videodev2.h.rst.exceptions
438c2ecf20Sopenharmony_ci	@$($(quiet)gen_rst)
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci$(BUILDDIR)/media.h.rst: ${UAPI}/media.h ${PARSER} $(SRC_DIR)/media.h.rst.exceptions
468c2ecf20Sopenharmony_ci	@$($(quiet)gen_rst)
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci$(BUILDDIR)/cec.h.rst: ${UAPI}/cec.h ${PARSER} $(SRC_DIR)/cec.h.rst.exceptions
498c2ecf20Sopenharmony_ci	@$($(quiet)gen_rst)
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci$(BUILDDIR)/lirc.h.rst: ${UAPI}/lirc.h ${PARSER} $(SRC_DIR)/lirc.h.rst.exceptions
528c2ecf20Sopenharmony_ci	@$($(quiet)gen_rst)
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci# Media build rules
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci.PHONY: all html epub xml latex
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ciall: $(IMGDOT) $(BUILDDIR) ${TARGETS}
598c2ecf20Sopenharmony_cihtml: all
608c2ecf20Sopenharmony_ciepub: all
618c2ecf20Sopenharmony_cixml: all
628c2ecf20Sopenharmony_cilatex: $(IMGPDF) all
638c2ecf20Sopenharmony_cilinkcheck:
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ciclean:
668c2ecf20Sopenharmony_ci	-rm -f $(DOTTGT) $(IMGTGT) ${TARGETS} 2>/dev/null
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci$(BUILDDIR):
698c2ecf20Sopenharmony_ci	$(Q)mkdir -p $@
70