1 # 2 # Copyright (C) 2011 The Android Open Source Project 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 # 16 17 ifeq (,$(ONE_SHOT_MAKEFILE)) 18 19 # PRODUCT_FACTORY_RAMDISK_MODULES consists of "<module_name>:<install_path>[:<install_path>...]" tuples. 20 # <install_path> is relative to TARGET_FACTORY_RAMDISK_OUT. 21 # We can have multiple <install_path>s because multiple modules may have the same name. 22 # For example: 23 # PRODUCT_FACTORY_RAMDISK_MODULES := \ 24 # toolbox:system/bin/toolbox adbd:sbin/adbd adb:system/bin/adb 25 factory_ramdisk_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_RAMDISK_MODULES)) 26 ifneq (,$(factory_ramdisk_modules)) 27 28 # A module name may end up in multiple modules (so multiple built files) 29 # with the same name. 30 # This function selects the module built file based on the install path. 31 # $(1): the dest install path 32 # $(2): the module built files 33 define install-one-factory-ramdisk-module 34 $(eval _iofrm_suffix := $(suffix $(1))) \ 35 $(if $(_iofrm_suffix), \ 36 $(eval _iofrm_pattern := %$(_iofrm_suffix)), \ 37 $(eval _iofrm_pattern := %$(notdir $(1)))) \ 38 $(eval _iofrm_src := $(filter $(_iofrm_pattern),$(2))) \ 39 $(if $(filter 1,$(words $(_iofrm_src))), \ 40 $(eval _fulldest := $(TARGET_FACTORY_RAMDISK_OUT)/$(1)) \ 41 $(eval $(call copy-one-file,$(_iofrm_src),$(_fulldest))) \ 42 $(eval INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES += $(_fulldest)), \ 43 $(error Error: Can not find match in "$(2)" for "$(1)") \ 44 ) 45 endef 46 47 INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES := 48 $(foreach m, $(factory_ramdisk_modules), \ 49 $(eval _fr_m_tuple := $(subst :, ,$(m))) \ 50 $(eval _fr_m_name := $(word 1,$(_fr_m_tuple))) \ 51 $(eval _fr_dests := $(wordlist 2,999,$(_fr_m_tuple))) \ 52 $(eval _fr_m_built := $(filter $(PRODUCT_OUT)/%, $(ALL_MODULES.$(_fr_m_name).BUILT))) \ 53 $(foreach d,$(_fr_dests),$(call install-one-factory-ramdisk-module,$(d),$(_fr_m_built))) \ 54 ) 55 endif 56 57 # Files may also be installed via PRODUCT_COPY_FILES, PRODUCT_PACKAGES etc. 58 INTERNAL_FACTORY_RAMDISK_FILES := $(filter $(TARGET_FACTORY_RAMDISK_OUT)/%, \ 59 $(ALL_DEFAULT_INSTALLED_MODULES)) 60 61 ifneq (,$(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES)$(INTERNAL_FACTORY_RAMDISK_FILES)) 62 63 # These files are made by magic in build/core/Makefile so we need to explicitly include them 64 $(eval $(call copy-one-file,$(TARGET_OUT)/build.prop,$(TARGET_FACTORY_RAMDISK_OUT)/system/build.prop)) 65 INTERNAL_FACTORY_RAMDISK_FILES += $(TARGET_FACTORY_RAMDISK_OUT)/system/build.prop 66 67 BUILT_FACTORY_RAMDISK_FS := $(PRODUCT_OUT)/factory_ramdisk.gz 68 BUILT_FACTORY_RAMDISK_TARGET := $(PRODUCT_OUT)/factory_ramdisk.img 69 70 INSTALLED_FACTORY_RAMDISK_FS := $(BUILT_FACTORY_RAMDISK_FS) 71 $(INSTALLED_FACTORY_RAMDISK_FS) : $(MKBOOTFS) \ 72 $(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES) $(INTERNAL_FACTORY_RAMDISK_FILES) | $(MINIGZIP) 73 $(call pretty,"Target factory ram disk file system: $@") 74 $(hide) $(MKBOOTFS) $(TARGET_FACTORY_RAMDISK_OUT) | $(MINIGZIP) > $@ 75 76 TARGET_RAMDISK_KERNEL := $(INSTALLED_KERNEL_TARGET) 77 INSTALLED_FACTORY_RAMDISK_TARGET := $(BUILT_FACTORY_RAMDISK_TARGET) 78 ifneq (,$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT)) 79 RAMDISK_CMDLINE := --cmdline "$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT)" 80 else 81 RAMDISK_CMDLINE := 82 endif 83 $(INSTALLED_FACTORY_RAMDISK_TARGET) : $(MKBOOTIMG) $(TARGET_RAMDISK_KERNEL) $(INSTALLED_FACTORY_RAMDISK_FS) 84 $(call pretty,"Target factory ram disk img format: $@") 85 $(MKBOOTIMG) --kernel $(TARGET_RAMDISK_KERNEL) --ramdisk $(INSTALLED_FACTORY_RAMDISK_FS) \ 86 --base $(BOARD_KERNEL_BASE) $(RAMDISK_CMDLINE) --output $@ 87 88 endif 89 90 endif # ONE_SHOT_MAKEFILE 91