162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci# Rules to convert a .h file to inline RST documentation
462306a36Sopenharmony_ci
562306a36Sopenharmony_ciSRC_DIR=$(srctree)/Documentation/userspace-api/media
662306a36Sopenharmony_ciPARSER = $(srctree)/Documentation/sphinx/parse-headers.pl
762306a36Sopenharmony_ciUAPI = $(srctree)/include/uapi/linux
862306a36Sopenharmony_ciKAPI = $(srctree)/include/linux
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciFILES = ca.h.rst dmx.h.rst frontend.h.rst net.h.rst \
1162306a36Sopenharmony_ci	videodev2.h.rst media.h.rst cec.h.rst lirc.h.rst
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciTARGETS := $(addprefix $(BUILDDIR)/, $(FILES))
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_cigen_rst = \
1662306a36Sopenharmony_ci	echo ${PARSER} $< $@ $(SRC_DIR)/$(notdir $@).exceptions; \
1762306a36Sopenharmony_ci	${PARSER} $< $@ $(SRC_DIR)/$(notdir $@).exceptions
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciquiet_gen_rst = echo '  PARSE   $(patsubst $(srctree)/%,%,$<)'; \
2062306a36Sopenharmony_ci	${PARSER} $< $@ $(SRC_DIR)/$(notdir $@).exceptions
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_cisilent_gen_rst = ${gen_rst}
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci$(BUILDDIR)/ca.h.rst: ${UAPI}/dvb/ca.h ${PARSER} $(SRC_DIR)/ca.h.rst.exceptions
2562306a36Sopenharmony_ci	@$($(quiet)gen_rst)
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci$(BUILDDIR)/dmx.h.rst: ${UAPI}/dvb/dmx.h ${PARSER} $(SRC_DIR)/dmx.h.rst.exceptions
2862306a36Sopenharmony_ci	@$($(quiet)gen_rst)
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci$(BUILDDIR)/frontend.h.rst: ${UAPI}/dvb/frontend.h ${PARSER} $(SRC_DIR)/frontend.h.rst.exceptions
3162306a36Sopenharmony_ci	@$($(quiet)gen_rst)
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci$(BUILDDIR)/net.h.rst: ${UAPI}/dvb/net.h ${PARSER} $(SRC_DIR)/net.h.rst.exceptions
3462306a36Sopenharmony_ci	@$($(quiet)gen_rst)
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci$(BUILDDIR)/videodev2.h.rst: ${UAPI}/videodev2.h ${PARSER} $(SRC_DIR)/videodev2.h.rst.exceptions
3762306a36Sopenharmony_ci	@$($(quiet)gen_rst)
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci$(BUILDDIR)/media.h.rst: ${UAPI}/media.h ${PARSER} $(SRC_DIR)/media.h.rst.exceptions
4062306a36Sopenharmony_ci	@$($(quiet)gen_rst)
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci$(BUILDDIR)/cec.h.rst: ${UAPI}/cec.h ${PARSER} $(SRC_DIR)/cec.h.rst.exceptions
4362306a36Sopenharmony_ci	@$($(quiet)gen_rst)
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci$(BUILDDIR)/lirc.h.rst: ${UAPI}/lirc.h ${PARSER} $(SRC_DIR)/lirc.h.rst.exceptions
4662306a36Sopenharmony_ci	@$($(quiet)gen_rst)
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci# Media build rules
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci.PHONY: all html texinfo epub xml latex
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciall: $(IMGDOT) $(BUILDDIR) ${TARGETS}
5362306a36Sopenharmony_cihtml: all
5462306a36Sopenharmony_citexinfo: all
5562306a36Sopenharmony_ciepub: all
5662306a36Sopenharmony_cixml: all
5762306a36Sopenharmony_cilatex: $(IMGPDF) all
5862306a36Sopenharmony_cilinkcheck:
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ciclean:
6162306a36Sopenharmony_ci	-rm -f $(DOTTGT) $(IMGTGT) ${TARGETS} 2>/dev/null
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci$(BUILDDIR):
6462306a36Sopenharmony_ci	$(Q)mkdir -p $@
65