Home | History | Annotate | Download | only in fs_config
      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 include $(CLEAR_VARS)
     18 
     19 LOCAL_SRC_FILES := fs_config.c
     20 LOCAL_MODULE := fs_config
     21 LOCAL_SHARED_LIBRARIES := libcutils libselinux
     22 LOCAL_CFLAGS := -Werror
     23 
     24 include $(BUILD_HOST_EXECUTABLE)
     25 
     26 # One can override the default android_filesystem_config.h file in one of two ways:
     27 #
     28 # 1. The old way:
     29 #   To Build the custom target binary for the host to generate the fs_config
     30 #   override files. The executable is hard coded to include the
     31 #   $(TARGET_ANDROID_FILESYSTEM_CONFIG_H) file if it exists.
     32 #   Expectations:
     33 #      device/<vendor>/<device>/android_filesystem_config.h
     34 #          fills in struct fs_path_config android_device_dirs[] and
     35 #                   struct fs_path_config android_device_files[]
     36 #      device/<vendor>/<device>/device.mk
     37 #          PRODUCT_PACKAGES += fs_config_dirs fs_config_files
     38 #   If not specified, check if default one to be found
     39 #
     40 # 2. The new way:
     41 #   set TARGET_FS_CONFIG_GEN to contain a list of intermediate format files
     42 #   for generating the android_filesystem_config.h file.
     43 #
     44 # More information can be found in the README
     45 ANDROID_FS_CONFIG_H := android_filesystem_config.h
     46 
     47 ifneq ($(TARGET_ANDROID_FILESYSTEM_CONFIG_H),)
     48 ifneq ($(TARGET_FS_CONFIG_GEN),)
     49 $(error Cannot set TARGET_ANDROID_FILESYSTEM_CONFIG_H and TARGET_FS_CONFIG_GEN simultaneously)
     50 endif
     51 
     52 # One and only one file can be specified.
     53 ifneq ($(words $(TARGET_ANDROID_FILESYSTEM_CONFIG_H)),1)
     54 $(error Multiple fs_config files specified, \
     55  see "$(TARGET_ANDROID_FILESYSTEM_CONFIG_H)".)
     56 endif
     57 
     58 ifeq ($(filter %/$(ANDROID_FS_CONFIG_H),$(TARGET_ANDROID_FILESYSTEM_CONFIG_H)),)
     59 $(error TARGET_ANDROID_FILESYSTEM_CONFIG_H file name must be $(ANDROID_FS_CONFIG_H), \
     60  see "$(notdir $(TARGET_ANDROID_FILESYSTEM_CONFIG_H))".)
     61 endif
     62 
     63 my_fs_config_h := $(TARGET_ANDROID_FILESYSTEM_CONFIG_H)
     64 else ifneq ($(wildcard $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H)),)
     65 
     66 ifneq ($(TARGET_FS_CONFIG_GEN),)
     67 $(error Cannot provide $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H) and set TARGET_FS_CONFIG_GEN simultaneously)
     68 endif
     69 my_fs_config_h := $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H)
     70 
     71 else
     72 my_fs_config_h := $(LOCAL_PATH)/default/$(ANDROID_FS_CONFIG_H)
     73 endif
     74 
     75 ##################################
     76 include $(CLEAR_VARS)
     77 LOCAL_SRC_FILES := fs_config_generate.c
     78 LOCAL_MODULE := fs_config_generate_$(TARGET_DEVICE)
     79 LOCAL_MODULE_CLASS := EXECUTABLES
     80 LOCAL_SHARED_LIBRARIES := libcutils
     81 LOCAL_CFLAGS := -Werror -Wno-error=\#warnings
     82 
     83 ifneq ($(TARGET_FS_CONFIG_GEN),)
     84 system_android_filesystem_config := system/core/include/private/android_filesystem_config.h
     85 
     86 # Generate the "generated_oem_aid.h" file
     87 oem := $(local-generated-sources-dir)/generated_oem_aid.h
     88 $(oem): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
     89 $(oem): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN)
     90 $(oem): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config)
     91 $(oem): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/fs_config_generator.py oemaid --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@
     92 $(oem): $(TARGET_FS_CONFIG_GEN) $(LOCAL_PATH)/fs_config_generator.py
     93 	$(transform-generated-source)
     94 
     95 # Generate the fs_config header
     96 gen := $(local-generated-sources-dir)/$(ANDROID_FS_CONFIG_H)
     97 $(gen): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
     98 $(gen): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN)
     99 $(gen): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config)
    100 $(gen): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/fs_config_generator.py fsconfig --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@
    101 $(gen): $(TARGET_FS_CONFIG_GEN) $(system_android_filesystem_config) $(LOCAL_PATH)/fs_config_generator.py
    102 	$(transform-generated-source)
    103 
    104 LOCAL_GENERATED_SOURCES := $(oem) $(gen)
    105 
    106 my_fs_config_h := $(gen)
    107 my_gen_oem_aid := $(oem)
    108 gen :=
    109 oem :=
    110 endif
    111 
    112 LOCAL_C_INCLUDES := $(dir $(my_fs_config_h)) $(dir $(my_gen_oem_aid))
    113 
    114 include $(BUILD_HOST_EXECUTABLE)
    115 fs_config_generate_bin := $(LOCAL_INSTALLED_MODULE)
    116 
    117 ##################################
    118 # Generate the system/etc/fs_config_dirs binary file for the target
    119 # Add fs_config_dirs to PRODUCT_PACKAGES in the device make file to enable
    120 include $(CLEAR_VARS)
    121 
    122 LOCAL_MODULE := fs_config_dirs
    123 LOCAL_MODULE_CLASS := ETC
    124 include $(BUILD_SYSTEM)/base_rules.mk
    125 $(LOCAL_BUILT_MODULE): $(fs_config_generate_bin)
    126 	@mkdir -p $(dir $@)
    127 	$< -D -o $@
    128 
    129 ##################################
    130 # Generate the system/etc/fs_config_files binary file for the target
    131 # Add fs_config_files to PRODUCT_PACKAGES in the device make file to enable
    132 include $(CLEAR_VARS)
    133 
    134 LOCAL_MODULE := fs_config_files
    135 LOCAL_MODULE_CLASS := ETC
    136 include $(BUILD_SYSTEM)/base_rules.mk
    137 $(LOCAL_BUILT_MODULE): $(fs_config_generate_bin)
    138 	@mkdir -p $(dir $@)
    139 	$< -F -o $@
    140 
    141 # The newer passwd/group targets are only generated if you
    142 # use the new TARGET_FS_CONFIG_GEN method.
    143 ifneq ($(TARGET_FS_CONFIG_GEN),)
    144 
    145 ##################################
    146 # Build the oemaid library when fs config files are present.
    147 # Intentionally break build if you require generated AIDS
    148 # header file, but are not using any fs config files.
    149 include $(CLEAR_VARS)
    150 LOCAL_MODULE := liboemaids
    151 LOCAL_EXPORT_C_INCLUDE_DIRS := $(dir $(my_gen_oem_aid))
    152 LOCAL_EXPORT_C_INCLUDE_DEPS := $(my_gen_oem_aid)
    153 include $(BUILD_STATIC_LIBRARY)
    154 
    155 ##################################
    156 # Generate the system/etc/passwd text file for the target
    157 # This file may be empty if no AIDs are defined in
    158 # TARGET_FS_CONFIG_GEN files.
    159 include $(CLEAR_VARS)
    160 
    161 LOCAL_MODULE := passwd
    162 LOCAL_MODULE_CLASS := ETC
    163 
    164 include $(BUILD_SYSTEM)/base_rules.mk
    165 
    166 $(LOCAL_BUILT_MODULE): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
    167 $(LOCAL_BUILT_MODULE): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN)
    168 $(LOCAL_BUILT_MODULE): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config)
    169 $(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/fs_config_generator.py $(TARGET_FS_CONFIG_GEN) $(system_android_filesystem_config)
    170 	@mkdir -p $(dir $@)
    171 	$(hide) $< passwd --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@
    172 
    173 ##################################
    174 # Generate the system/etc/group text file for the target
    175 # This file may be empty if no AIDs are defined in
    176 # TARGET_FS_CONFIG_GEN files.
    177 include $(CLEAR_VARS)
    178 
    179 LOCAL_MODULE := group
    180 LOCAL_MODULE_CLASS := ETC
    181 
    182 include $(BUILD_SYSTEM)/base_rules.mk
    183 
    184 $(LOCAL_BUILT_MODULE): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
    185 $(LOCAL_BUILT_MODULE): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN)
    186 $(LOCAL_BUILT_MODULE): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config)
    187 $(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/fs_config_generator.py $(TARGET_FS_CONFIG_GEN) $(system_android_filesystem_config)
    188 	@mkdir -p $(dir $@)
    189 	$(hide) $< group --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@
    190 
    191 system_android_filesystem_config :=
    192 endif
    193 
    194 ANDROID_FS_CONFIG_H :=
    195 my_fs_config_h :=
    196 fs_config_generate_bin :=
    197 my_gen_oem_aid :=
    198