1# Command to turn collection of policy files into a policy.conf file to be
2# processed by checkpolicy
3define transform-policy-to-conf
4@mkdir -p $(dir $@)
5$(hide) $(M4) --fatal-warnings $(PRIVATE_ADDITIONAL_M4DEFS) \
6	-D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
7	-D target_build_variant=$(PRIVATE_TARGET_BUILD_VARIANT) \
8	-D target_with_dexpreopt=$(WITH_DEXPREOPT) \
9	-D target_arch=$(PRIVATE_TGT_ARCH) \
10	-D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
11	-D target_with_native_coverage=$(PRIVATE_TGT_WITH_NATIVE_COVERAGE) \
12	-D target_full_treble=$(PRIVATE_SEPOLICY_SPLIT) \
13	-D target_compatible_property=$(PRIVATE_COMPATIBLE_PROPERTY) \
14	-D target_treble_sysprop_neverallow=$(PRIVATE_TREBLE_SYSPROP_NEVERALLOW) \
15	-D target_enforce_sysprop_owner=$(PRIVATE_ENFORCE_SYSPROP_OWNER) \
16	-D target_exclude_build_test=$(PRIVATE_EXCLUDE_BUILD_TEST) \
17	-D target_requires_insecure_execmem_for_swiftshader=$(PRODUCT_REQUIRES_INSECURE_EXECMEM_FOR_SWIFTSHADER) \
18	-D target_enforce_debugfs_restriction=$(PRIVATE_ENFORCE_DEBUGFS_RESTRICTION) \
19	$(PRIVATE_TGT_RECOVERY) \
20	-s $(PRIVATE_POLICY_FILES) > $@
21endef
22.KATI_READONLY := transform-policy-to-conf
23
24###########################################################
25## Collect file_contexts files into a single tmp file with m4
26##
27## $(1): list of file_contexts files
28## $(2): filename into which file_contexts files are merged
29###########################################################
30
31define _merge-fc-files
32$(2): $(1) $(M4)
33	$(hide) mkdir -p $$(dir $$@)
34	$(hide) $(M4) --fatal-warnings -s $(1) > $$@
35endef
36
37define merge-fc-files
38$(eval $(call _merge-fc-files,$(1),$(2)))
39endef
40