1# =============================================================================
2# DOCUMENTATION GENERATION
3# =============================================================================
4C2_ROOT := $(call my-dir)
5
6C2_DOCS_ROOT := $(OUT_DIR)/target/common/docs/codec2
7
8C2_OUT_TEMP := $(PRODUCT_OUT)/gen/ETC/Codec2-docs_intermediates
9
10C2_DOXY := $(or $(shell command -v doxygen),\
11		$(shell command -v /Applications/Doxygen.app/Contents/Resources/doxygen))
12
13.PHONY: check-doxygen
14check-doxygen:
15ifndef C2_DOXY
16	$(error 'doxygen is not available')
17endif
18
19$(C2_OUT_TEMP)/doxy-api.config: $(C2_ROOT)/docs/doxygen.config
20	# only document include directory, no internal sections
21	sed 's/\(^INPUT *=.*\)/\1include\//; \
22	s/\(^INTERNAL_DOCS *= *\).*/\1NO/; \
23	s/\(^ENABLED_SECTIONS *=.*\)INTERNAL\(.*\).*/\1\2/; \
24	s:\(^OUTPUT_DIRECTORY *= \)out:\1'$(OUT_DIR)':;' \
25		$(C2_ROOT)/docs/doxygen.config > $@
26
27$(C2_OUT_TEMP)/doxy-internal.config: $(C2_ROOT)/docs/doxygen.config
28	sed 's:\(^OUTPUT_DIRECTORY *= \)out\(.*\)api:\1'$(OUT_DIR)'\2internal:;' \
29		$(C2_ROOT)/docs/doxygen.config > $@
30
31.PHONY: docs-api
32docs-api: $(C2_OUT_TEMP)/doxy-api.config check-doxygen
33	echo API docs are building in $(C2_DOCS_ROOT)/api
34	rm -rf $(C2_DOCS_ROOT)/api
35	mkdir -p $(C2_DOCS_ROOT)/api
36	$(C2_DOXY) $(C2_OUT_TEMP)/doxy-api.config
37
38.PHONY: docs-internal
39docs-internal: $(C2_OUT_TEMP)/doxy-internal.config check-doxygen
40	echo Internal docs are building in $(C2_DOCS_ROOT)/internal
41	rm -rf $(C2_DOCS_ROOT)/internal
42	mkdir -p $(C2_DOCS_ROOT)/internal
43	$(C2_DOXY) $(C2_OUT_TEMP)/doxy-internal.config
44
45.PHONY: docs-all
46docs-all: docs-api docs-internal
47
48include $(call all-makefiles-under,$(call my-dir))
49