blob: c023783626bb9f7075b1eb5b5414aa8843b28923 [file] [log] [blame]
Stephen Smalley2dd4e512012-01-04 12:33:27 -05001LOCAL_PATH:= $(call my-dir)
William Robertsf0e0a942012-08-27 15:41:15 -07002
Stephen Smalley2dd4e512012-01-04 12:33:27 -05003include $(CLEAR_VARS)
4
5# SELinux policy version.
6# Must be <= /selinux/policyvers reported by the Android kernel.
7# Must be within the compatibility range reported by checkpolicy -V.
Stephen Smalley66a3e8d2012-09-18 15:11:49 -04008POLICYVERS ?= 24
Stephen Smalley2dd4e512012-01-04 12:33:27 -05009
10MLS_SENS=1
11MLS_CATS=1024
12
rpcraig47cd3962012-10-17 21:09:52 -040013# Quick edge case error detection for BOARD_SEPOLICY_REPLACE.
14# Builds the singular path for each replace file.
15sepolicy_replace_paths :=
16$(foreach pf, $(BOARD_SEPOLICY_REPLACE), \
17 $(if $(filter $(pf), $(BOARD_SEPOLICY_UNION)), \
18 $(error Ambiguous request for sepolicy $(pf). Appears in both \
19 BOARD_SEPOLICY_REPLACE and BOARD_SEPOLICY_UNION), \
20 ) \
21 $(eval _paths := $(wildcard $(addsuffix /$(pf), $(BOARD_SEPOLICY_DIRS)))) \
22 $(eval _occurrences := $(words $(_paths))) \
23 $(if $(filter 0,$(_occurrences)), \
24 $(error No sepolicy file found for $(pf) in $(BOARD_SEPOLICY_DIRS)), \
25 ) \
26 $(if $(filter 1, $(_occurrences)), \
27 $(eval sepolicy_replace_paths += $(_paths)), \
28 $(error Multiple occurrences of replace file $(pf) in $(_paths)) \
29 ) \
30 $(if $(filter 0, $(words $(wildcard $(addsuffix /$(pf), $(LOCAL_PATH))))), \
31 $(error Specified the sepolicy file $(pf) in BOARD_SEPOLICY_REPLACE, \
32 but none found in $(LOCAL_PATH)), \
33 ) \
34)
Stephen Smalley5b340be2012-03-06 11:12:41 -050035
rpcraig47cd3962012-10-17 21:09:52 -040036# Builds paths for all requested policy files w.r.t
37# both BOARD_SEPOLICY_REPLACE and BOARD_SEPOLICY_UNION
38# product variables.
39# $(1): the set of policy name paths to build
40build_policy = $(foreach type, $(1), \
41 $(foreach expanded_type, $(notdir $(wildcard $(addsuffix /$(type), $(LOCAL_PATH)))), \
42 $(if $(filter $(expanded_type), $(BOARD_SEPOLICY_REPLACE)), \
43 $(wildcard $(addsuffix $(expanded_type), $(dir $(sepolicy_replace_paths)))), \
44 $(LOCAL_PATH)/$(expanded_type) \
45 ) \
46 ) \
47 $(foreach union_policy, $(wildcard $(addsuffix /$(type), $(BOARD_SEPOLICY_DIRS))), \
48 $(if $(filter $(notdir $(union_policy)), $(BOARD_SEPOLICY_UNION)), \
49 $(union_policy), \
50 ) \
51 ) \
52)
Stephen Smalley5b340be2012-03-06 11:12:41 -050053
Ying Wang02fb5f32012-01-17 17:51:09 -080054##################################
55include $(CLEAR_VARS)
Stephen Smalley2dd4e512012-01-04 12:33:27 -050056
Ying Wang02fb5f32012-01-17 17:51:09 -080057LOCAL_MODULE := sepolicy
58LOCAL_MODULE_CLASS := ETC
59LOCAL_MODULE_TAGS := optional
Ying Wang02fb5f32012-01-17 17:51:09 -080060LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Stephen Smalley2dd4e512012-01-04 12:33:27 -050061
Ying Wang02fb5f32012-01-17 17:51:09 -080062include $(BUILD_SYSTEM)/base_rules.mk
Stephen Smalley2dd4e512012-01-04 12:33:27 -050063
Ying Wang02fb5f32012-01-17 17:51:09 -080064sepolicy_policy.conf := $(intermediates)/policy.conf
65$(sepolicy_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
66$(sepolicy_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Kenny Root9ceb47b2012-11-01 13:17:29 -070067$(sepolicy_policy.conf) : $(call build_policy, security_classes initial_sids access_vectors global_macros mls_macros mls policy_capabilities te_macros attributes *.te roles users initial_sid_contexts fs_use genfs_contexts port_contexts)
Ying Wang02fb5f32012-01-17 17:51:09 -080068 @mkdir -p $(dir $@)
Kenny Root9ceb47b2012-11-01 13:17:29 -070069 $(hide) m4 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) -s $^ > $@
Stephen Smalley2dd4e512012-01-04 12:33:27 -050070
Stephen Smalley2b826fc2012-01-24 08:46:13 -050071$(LOCAL_BUILT_MODULE) : $(sepolicy_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
Ying Wang02fb5f32012-01-17 17:51:09 -080072 @mkdir -p $(dir $@)
Ying Wangf4ea5b22012-04-09 15:31:03 -070073 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c $(POLICYVERS) -o $@ $<
Ying Wang02fb5f32012-01-17 17:51:09 -080074
Ying Wangd8b122c2012-10-25 19:01:31 -070075built_sepolicy := $(LOCAL_BUILT_MODULE)
Ying Wang02fb5f32012-01-17 17:51:09 -080076sepolicy_policy.conf :=
Stephen Smalley01a58af2012-10-02 12:46:37 -040077
78###################################
79include $(CLEAR_VARS)
80
Ying Wang02fb5f32012-01-17 17:51:09 -080081LOCAL_MODULE := file_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -080082LOCAL_MODULE_CLASS := ETC
83LOCAL_MODULE_TAGS := optional
84LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
85
Stephen Smalley5b340be2012-03-06 11:12:41 -050086include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -080087
rpcraig47cd3962012-10-17 21:09:52 -040088ALL_FC_FILES := $(call build_policy, file_contexts)
Stephen Smalley01a58af2012-10-02 12:46:37 -040089
Ying Wangd8b122c2012-10-25 19:01:31 -070090$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
91$(LOCAL_BUILT_MODULE): $(ALL_FC_FILES) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
Stephen Smalley5b340be2012-03-06 11:12:41 -050092 @mkdir -p $(dir $@)
Stephen Smalley01a58af2012-10-02 12:46:37 -040093 $(hide) m4 -s $(ALL_FC_FILES) > $@
Ying Wangd8b122c2012-10-25 19:01:31 -070094 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $@
Stephen Smalley5b340be2012-03-06 11:12:41 -050095
96file_contexts :=
William Roberts171a0622012-08-16 10:55:05 -070097
Ying Wang02fb5f32012-01-17 17:51:09 -080098##################################
99include $(CLEAR_VARS)
Ying Wang02fb5f32012-01-17 17:51:09 -0800100LOCAL_MODULE := seapp_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -0800101LOCAL_MODULE_CLASS := ETC
102LOCAL_MODULE_TAGS := optional
103LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
104
William Roberts171a0622012-08-16 10:55:05 -0700105include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800106
William Roberts98ed3922012-09-05 11:19:07 -0700107seapp_contexts.tmp := $(intermediates)/seapp_contexts.tmp
rpcraig47cd3962012-10-17 21:09:52 -0400108$(seapp_contexts.tmp): $(call build_policy, seapp_contexts)
William Roberts171a0622012-08-16 10:55:05 -0700109 @mkdir -p $(dir $@)
110 $(hide) m4 -s $^ > $@
111
Ying Wangd8b122c2012-10-25 19:01:31 -0700112$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
113$(LOCAL_BUILT_MODULE) : $(seapp_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkseapp
William Robertsf0e0a942012-08-27 15:41:15 -0700114 @mkdir -p $(dir $@)
Ying Wangd8b122c2012-10-25 19:01:31 -0700115 $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $<
Ying Wang02fb5f32012-01-17 17:51:09 -0800116
William Roberts98ed3922012-09-05 11:19:07 -0700117seapp_contexts.tmp :=
Ying Wangd8b122c2012-10-25 19:01:31 -0700118built_sepolicy :=
Ying Wang02fb5f32012-01-17 17:51:09 -0800119##################################
Stephen Smalley124720a2012-04-04 10:11:16 -0400120include $(CLEAR_VARS)
121
122LOCAL_MODULE := property_contexts
123LOCAL_MODULE_CLASS := ETC
124LOCAL_MODULE_TAGS := optional
125LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
126
127include $(BUILD_SYSTEM)/base_rules.mk
128
129property_contexts := $(intermediates)/property_contexts
rpcraig47cd3962012-10-17 21:09:52 -0400130$(property_contexts): $(call build_policy, property_contexts)
Stephen Smalley124720a2012-04-04 10:11:16 -0400131 @mkdir -p $(dir $@)
Stephen Smalleyefd6d6e2012-05-18 08:24:25 -0400132 $(hide) m4 -s $^ > $@
Stephen Smalley124720a2012-04-04 10:11:16 -0400133
134property_contexts :=
135##################################
Stephen Smalley7e8cf242012-02-02 13:28:28 -0500136
Joshua Brindle70d4fc22012-06-20 11:58:01 -0400137##################################
138include $(CLEAR_VARS)
139
140LOCAL_MODULE := selinux-network.sh
141LOCAL_SRC_FILES := $(LOCAL_MODULE)
142LOCAL_MODULE_CLASS := EXECUTABLES
143LOCAL_MODULE_TAGS := optional
144LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)
145
146include $(BUILD_PREBUILT)
147
148##################################
rpcraigb19665c2012-07-30 09:33:03 -0400149include $(CLEAR_VARS)
150
151LOCAL_MODULE := mac_permissions.xml
152LOCAL_MODULE_CLASS := ETC
153LOCAL_MODULE_TAGS := optional
154LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/security
155
156LOCAL_SRC_FILES := $(LOCAL_MODULE)
157
158include $(BUILD_PREBUILT)
159
160##################################
rpcraig47cd3962012-10-17 21:09:52 -0400161
162build_policy :=
163sepolicy_replace_paths :=
Alice Chucdfb06f2012-11-01 11:33:04 -0700164
165include $(call all-makefiles-under,$(LOCAL_PATH))