1 # Copyright (C) 2008 The Android Open Source Project 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 LOCAL_PATH := $(call my-dir) 16 17 # One can override the default android_filesystem_config.h file in one of two ways: 18 # 19 # 1. The old way: 20 # To Build the custom target binary for the host to generate the fs_config 21 # override files. The executable is hard coded to include the 22 # $(TARGET_ANDROID_FILESYSTEM_CONFIG_H) file if it exists. 23 # Expectations: 24 # device/<vendor>/<device>/android_filesystem_config.h 25 # fills in struct fs_path_config android_device_dirs[] and 26 # struct fs_path_config android_device_files[] 27 # device/<vendor>/<device>/device.mk 28 # PRODUCT_PACKAGES += fs_config_dirs fs_config_files 29 # If not specified, check if default one to be found 30 # 31 # 2. The new way: 32 # set TARGET_FS_CONFIG_GEN to contain a list of intermediate format files 33 # for generating the android_filesystem_config.h file. 34 # 35 # More information can be found in the README 36 ANDROID_FS_CONFIG_H := android_filesystem_config.h 37 38 ifneq ($(TARGET_ANDROID_FILESYSTEM_CONFIG_H),) 39 ifneq ($(TARGET_FS_CONFIG_GEN),) 40 $(error Cannot set TARGET_ANDROID_FILESYSTEM_CONFIG_H and TARGET_FS_CONFIG_GEN simultaneously) 41 endif 42 43 # One and only one file can be specified. 44 ifneq ($(words $(TARGET_ANDROID_FILESYSTEM_CONFIG_H)),1) 45 $(error Multiple fs_config files specified, \ 46 see "$(TARGET_ANDROID_FILESYSTEM_CONFIG_H)".) 47 endif 48 49 ifeq ($(filter %/$(ANDROID_FS_CONFIG_H),$(TARGET_ANDROID_FILESYSTEM_CONFIG_H)),) 50 $(error TARGET_ANDROID_FILESYSTEM_CONFIG_H file name must be $(ANDROID_FS_CONFIG_H), \ 51 see "$(notdir $(TARGET_ANDROID_FILESYSTEM_CONFIG_H))".) 52 endif 53 54 my_fs_config_h := $(TARGET_ANDROID_FILESYSTEM_CONFIG_H) 55 else ifneq ($(wildcard $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H)),) 56 57 ifneq ($(TARGET_FS_CONFIG_GEN),) 58 $(error Cannot provide $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H) and set TARGET_FS_CONFIG_GEN simultaneously) 59 endif 60 my_fs_config_h := $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H) 61 62 else 63 my_fs_config_h := $(LOCAL_PATH)/default/$(ANDROID_FS_CONFIG_H) 64 endif 65 66 ################################## 67 include $(CLEAR_VARS) 68 LOCAL_SRC_FILES := fs_config_generate.c 69 LOCAL_MODULE := fs_config_generate_$(TARGET_DEVICE) 70 LOCAL_MODULE_CLASS := EXECUTABLES 71 LOCAL_SHARED_LIBRARIES := libcutils 72 LOCAL_CFLAGS := -Werror -Wno-error=\#warnings 73 74 ifneq ($(TARGET_FS_CONFIG_GEN),) 75 system_android_filesystem_config := system/core/include/private/android_filesystem_config.h 76 77 # Generate the "generated_oem_aid.h" file 78 oem := $(local-generated-sources-dir)/generated_oem_aid.h 79 $(oem): PRIVATE_LOCAL_PATH := $(LOCAL_PATH) 80 $(oem): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN) 81 $(oem): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config) 82 $(oem): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/fs_config_generator.py oemaid --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@ 83 $(oem): $(TARGET_FS_CONFIG_GEN) $(LOCAL_PATH)/fs_config_generator.py 84 $(transform-generated-source) 85 86 # Generate the fs_config header 87 gen := $(local-generated-sources-dir)/$(ANDROID_FS_CONFIG_H) 88 $(gen): PRIVATE_LOCAL_PATH := $(LOCAL_PATH) 89 $(gen): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN) 90 $(gen): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config) 91 $(gen): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/fs_config_generator.py fsconfig --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@ 92 $(gen): $(TARGET_FS_CONFIG_GEN) $(system_android_filesystem_config) $(LOCAL_PATH)/fs_config_generator.py 93 $(transform-generated-source) 94 95 LOCAL_GENERATED_SOURCES := $(oem) $(gen) 96 97 my_fs_config_h := $(gen) 98 my_gen_oem_aid := $(oem) 99 gen := 100 oem := 101 endif 102 103 LOCAL_C_INCLUDES := $(dir $(my_fs_config_h)) $(dir $(my_gen_oem_aid)) 104 105 include $(BUILD_HOST_EXECUTABLE) 106 fs_config_generate_bin := $(LOCAL_INSTALLED_MODULE) 107 # List of all supported vendor, oem and odm Partitions 108 fs_config_generate_extra_partition_list := $(strip \ 109 $(if $(BOARD_USES_VENDORIMAGE)$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),vendor) \ 110 $(if $(BOARD_USES_OEMIMAGE)$(BOARD_OEMIMAGE_FILE_SYSTEM_TYPE),oem) \ 111 $(if $(BOARD_USES_ODMIMAGE)$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),odm)) 112 113 ################################## 114 # Generate the system/etc/fs_config_dirs binary file for the target 115 # Add fs_config_dirs to PRODUCT_PACKAGES in the device make file to enable 116 include $(CLEAR_VARS) 117 118 LOCAL_MODULE := fs_config_dirs 119 LOCAL_MODULE_CLASS := ETC 120 LOCAL_REQUIRED_MODULES := $(foreach t,$(fs_config_generate_extra_partition_list),$(LOCAL_MODULE)_$(t)) 121 include $(BUILD_SYSTEM)/base_rules.mk 122 $(LOCAL_BUILT_MODULE): $(fs_config_generate_bin) 123 @mkdir -p $(dir $@) 124 $< -D $(if $(fs_config_generate_extra_partition_list), \ 125 -P '$(subst $(space),$(comma),$(addprefix -,$(fs_config_generate_extra_partition_list)))') \ 126 -o $@ 127 128 ################################## 129 # Generate the system/etc/fs_config_files binary file for the target 130 # Add fs_config_files to PRODUCT_PACKAGES in the device make file to enable 131 include $(CLEAR_VARS) 132 133 LOCAL_MODULE := fs_config_files 134 LOCAL_MODULE_CLASS := ETC 135 LOCAL_REQUIRED_MODULES := $(foreach t,$(fs_config_generate_extra_partition_list),$(LOCAL_MODULE)_$(t)) 136 include $(BUILD_SYSTEM)/base_rules.mk 137 $(LOCAL_BUILT_MODULE): $(fs_config_generate_bin) 138 @mkdir -p $(dir $@) 139 $< -F $(if $(fs_config_generate_extra_partition_list), \ 140 -P '$(subst $(space),$(comma),$(addprefix -,$(fs_config_generate_extra_partition_list)))') \ 141 -o $@ 142 143 ifneq ($(filter vendor,$(fs_config_generate_extra_partition_list)),) 144 ################################## 145 # Generate the vendor/etc/fs_config_dirs binary file for the target 146 # Add fs_config_dirs or fs_config_dirs_vendor to PRODUCT_PACKAGES in 147 # the device make file to enable. 148 include $(CLEAR_VARS) 149 150 LOCAL_MODULE := fs_config_dirs_vendor 151 LOCAL_MODULE_CLASS := ETC 152 LOCAL_INSTALLED_MODULE_STEM := fs_config_dirs 153 LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc 154 include $(BUILD_SYSTEM)/base_rules.mk 155 $(LOCAL_BUILT_MODULE): $(fs_config_generate_bin) 156 @mkdir -p $(dir $@) 157 $< -D -P vendor -o $@ 158 159 ################################## 160 # Generate the vendor/etc/fs_config_files binary file for the target 161 # Add fs_config_files or fs_config_files_vendor to PRODUCT_PACKAGES in 162 # the device make file to enable 163 include $(CLEAR_VARS) 164 165 LOCAL_MODULE := fs_config_files_vendor 166 LOCAL_MODULE_CLASS := ETC 167 LOCAL_INSTALLED_MODULE_STEM := fs_config_files 168 LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc 169 include $(BUILD_SYSTEM)/base_rules.mk 170 $(LOCAL_BUILT_MODULE): $(fs_config_generate_bin) 171 @mkdir -p $(dir $@) 172 $< -F -P vendor -o $@ 173 174 endif 175 176 ifneq ($(filter oem,$(fs_config_generate_extra_partition_list)),) 177 ################################## 178 # Generate the oem/etc/fs_config_dirs binary file for the target 179 # Add fs_config_dirs or fs_config_dirs_oem to PRODUCT_PACKAGES in 180 # the device make file to enable 181 include $(CLEAR_VARS) 182 183 LOCAL_MODULE := fs_config_dirs_oem 184 LOCAL_MODULE_CLASS := ETC 185 LOCAL_INSTALLED_MODULE_STEM := fs_config_dirs 186 LOCAL_MODULE_PATH := $(TARGET_OUT_OEM)/etc 187 include $(BUILD_SYSTEM)/base_rules.mk 188 $(LOCAL_BUILT_MODULE): $(fs_config_generate_bin) 189 @mkdir -p $(dir $@) 190 $< -D -P oem -o $@ 191 192 ################################## 193 # Generate the oem/etc/fs_config_files binary file for the target 194 # Add fs_config_files or fs_config_files_oem to PRODUCT_PACKAGES in 195 # the device make file to enable 196 include $(CLEAR_VARS) 197 198 LOCAL_MODULE := fs_config_files_oem 199 LOCAL_MODULE_CLASS := ETC 200 LOCAL_INSTALLED_MODULE_STEM := fs_config_files 201 LOCAL_MODULE_PATH := $(TARGET_OUT_OEM)/etc 202 include $(BUILD_SYSTEM)/base_rules.mk 203 $(LOCAL_BUILT_MODULE): $(fs_config_generate_bin) 204 @mkdir -p $(dir $@) 205 $< -F -P oem -o $@ 206 207 endif 208 209 ifneq ($(filter odm,$(fs_config_generate_extra_partition_list)),) 210 ################################## 211 # Generate the odm/etc/fs_config_dirs binary file for the target 212 # Add fs_config_dirs or fs_config_dirs_odm to PRODUCT_PACKAGES in 213 # the device make file to enable 214 include $(CLEAR_VARS) 215 216 LOCAL_MODULE := fs_config_dirs_odm 217 LOCAL_MODULE_CLASS := ETC 218 LOCAL_INSTALLED_MODULE_STEM := fs_config_dirs 219 LOCAL_MODULE_PATH := $(TARGET_OUT_ODM)/etc 220 include $(BUILD_SYSTEM)/base_rules.mk 221 $(LOCAL_BUILT_MODULE): $(fs_config_generate_bin) 222 @mkdir -p $(dir $@) 223 $< -D -P odm -o $@ 224 225 ################################## 226 # Generate the odm/etc/fs_config_files binary file for the target 227 # Add fs_config_files of fs_config_files_odm to PRODUCT_PACKAGES in 228 # the device make file to enable 229 include $(CLEAR_VARS) 230 231 LOCAL_MODULE := fs_config_files_odm 232 LOCAL_MODULE_CLASS := ETC 233 LOCAL_INSTALLED_MODULE_STEM := fs_config_files 234 LOCAL_MODULE_PATH := $(TARGET_OUT_ODM)/etc 235 include $(BUILD_SYSTEM)/base_rules.mk 236 $(LOCAL_BUILT_MODULE): $(fs_config_generate_bin) 237 @mkdir -p $(dir $@) 238 $< -F -P odm -o $@ 239 240 endif 241 242 # The newer passwd/group targets are only generated if you 243 # use the new TARGET_FS_CONFIG_GEN method. 244 ifneq ($(TARGET_FS_CONFIG_GEN),) 245 246 ################################## 247 # Build the oemaid header library when fs config files are present. 248 # Intentionally break build if you require generated AIDs 249 # header file, but are not using any fs config files. 250 include $(CLEAR_VARS) 251 LOCAL_MODULE := oemaids_headers 252 LOCAL_EXPORT_C_INCLUDE_DIRS := $(dir $(my_gen_oem_aid)) 253 LOCAL_EXPORT_C_INCLUDE_DEPS := $(my_gen_oem_aid) 254 include $(BUILD_HEADER_LIBRARY) 255 256 ################################## 257 # Generate the vendor/etc/passwd text file for the target 258 # This file may be empty if no AIDs are defined in 259 # TARGET_FS_CONFIG_GEN files. 260 include $(CLEAR_VARS) 261 262 LOCAL_MODULE := passwd 263 LOCAL_MODULE_CLASS := ETC 264 LOCAL_VENDOR_MODULE := true 265 266 include $(BUILD_SYSTEM)/base_rules.mk 267 268 $(LOCAL_BUILT_MODULE): PRIVATE_LOCAL_PATH := $(LOCAL_PATH) 269 $(LOCAL_BUILT_MODULE): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN) 270 $(LOCAL_BUILT_MODULE): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config) 271 $(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/fs_config_generator.py $(TARGET_FS_CONFIG_GEN) $(system_android_filesystem_config) 272 @mkdir -p $(dir $@) 273 $(hide) $< passwd --required-prefix=vendor_ --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@ 274 275 ################################## 276 # Generate the vendor/etc/group text file for the target 277 # This file may be empty if no AIDs are defined in 278 # TARGET_FS_CONFIG_GEN files. 279 include $(CLEAR_VARS) 280 281 LOCAL_MODULE := group 282 LOCAL_MODULE_CLASS := ETC 283 LOCAL_VENDOR_MODULE := true 284 285 include $(BUILD_SYSTEM)/base_rules.mk 286 287 $(LOCAL_BUILT_MODULE): PRIVATE_LOCAL_PATH := $(LOCAL_PATH) 288 $(LOCAL_BUILT_MODULE): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN) 289 $(LOCAL_BUILT_MODULE): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config) 290 $(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/fs_config_generator.py $(TARGET_FS_CONFIG_GEN) $(system_android_filesystem_config) 291 @mkdir -p $(dir $@) 292 $(hide) $< group --required-prefix=vendor_ --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@ 293 294 system_android_filesystem_config := 295 endif 296 297 ANDROID_FS_CONFIG_H := 298 my_fs_config_h := 299 fs_config_generate_bin := 300 my_gen_oem_aid := 301 fs_config_generate_extra_partition_list := 302