2 # Copyright (C) 2011 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 ifeq (,$(ONE_SHOT_MAKEFILE))
18 ifneq ($(TARGET_BUILD_PDK),true)
20 # PRODUCT_FACTORY_RAMDISK_MODULES consists of "<module_name>:<install_path>[:<install_path>...]" tuples.
21 # <install_path> is relative to TARGET_FACTORY_RAMDISK_OUT.
22 # We can have multiple <install_path>s because multiple modules may have the same name.
24 # PRODUCT_FACTORY_RAMDISK_MODULES := \
25 # toolbox:system/bin/toolbox adbd:sbin/adbd adb:system/bin/adb
26 factory_ramdisk_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_RAMDISK_MODULES))
27 ifneq (,$(factory_ramdisk_modules))
29 # A module name may end up in multiple modules (so multiple built files)
31 # This function selects the module built file based on the install path.
32 # $(1): the dest install path
33 # $(2): the module built files
34 define install-one-factory-ramdisk-module
35 $(eval _iofrm_suffix := $(suffix $(1))) \
36 $(if $(_iofrm_suffix), \
37 $(eval _iofrm_pattern := %$(_iofrm_suffix)), \
38 $(eval _iofrm_pattern := %$(notdir $(1)))) \
39 $(eval _iofrm_src := $(filter $(_iofrm_pattern),$(2))) \
40 $(if $(filter 1,$(words $(_iofrm_src))), \
41 $(eval _fulldest := $(TARGET_FACTORY_RAMDISK_OUT)/$(1)) \
42 $(eval $(call copy-one-file,$(_iofrm_src),$(_fulldest))) \
43 $(eval INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES += $(_fulldest)), \
44 $(error Error: Cannot find match in "$(2)" for "$(1)") \
48 INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES :=
49 $(foreach m, $(factory_ramdisk_modules), \
50 $(eval _fr_m_tuple := $(subst :, ,$(m))) \
51 $(eval _fr_m_name := $(word 1,$(_fr_m_tuple))) \
52 $(eval _fr_dests := $(wordlist 2,999,$(_fr_m_tuple))) \
53 $(eval _fr_m_built := $(filter $(PRODUCT_OUT)/%, $(ALL_MODULES.$(_fr_m_name).BUILT))) \
54 $(foreach d,$(_fr_dests),$(call install-one-factory-ramdisk-module,$(d),$(_fr_m_built))) \
58 # Files may also be installed via PRODUCT_COPY_FILES, PRODUCT_PACKAGES etc.
59 INTERNAL_FACTORY_RAMDISK_FILES := $(filter $(TARGET_FACTORY_RAMDISK_OUT)/%, \
60 $(ALL_DEFAULT_INSTALLED_MODULES))
62 ifneq (,$(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES)$(INTERNAL_FACTORY_RAMDISK_FILES))
64 # These files are made by magic in build/core/Makefile so we need to explicitly include them
65 $(eval $(call copy-one-file,$(TARGET_OUT)/build.prop,$(TARGET_FACTORY_RAMDISK_OUT)/system/build.prop))
66 INTERNAL_FACTORY_RAMDISK_FILES += $(TARGET_FACTORY_RAMDISK_OUT)/system/build.prop
68 BUILT_FACTORY_RAMDISK_FS := $(PRODUCT_OUT)/factory_ramdisk.gz
69 BUILT_FACTORY_RAMDISK_TARGET := $(PRODUCT_OUT)/factory_ramdisk.img
71 INSTALLED_FACTORY_RAMDISK_FS := $(BUILT_FACTORY_RAMDISK_FS)
72 $(INSTALLED_FACTORY_RAMDISK_FS) : $(MKBOOTFS) \
73 $(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES) $(INTERNAL_FACTORY_RAMDISK_FILES) | $(MINIGZIP)
74 $(call pretty,"Target factory ram disk file system: $@")
75 $(hide) $(MKBOOTFS) $(TARGET_FACTORY_RAMDISK_OUT) | $(MINIGZIP) > $@
77 TARGET_RAMDISK_KERNEL := $(INSTALLED_KERNEL_TARGET)
78 INSTALLED_FACTORY_RAMDISK_TARGET := $(BUILT_FACTORY_RAMDISK_TARGET)
79 ifneq (,$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT))
80 RAMDISK_CMDLINE := --cmdline "$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT)"
84 $(INSTALLED_FACTORY_RAMDISK_TARGET) : $(MKBOOTIMG) $(TARGET_RAMDISK_KERNEL) $(INSTALLED_FACTORY_RAMDISK_FS)
85 $(call pretty,"Target factory ram disk img format: $@")
86 $(MKBOOTIMG) --kernel $(TARGET_RAMDISK_KERNEL) --ramdisk $(INSTALLED_FACTORY_RAMDISK_FS) \
87 --base $(BOARD_KERNEL_BASE) $(BOARD_MKBOOTIMG_ARGS) $(RAMDISK_CMDLINE) --output $@
91 endif # TARGET_BUILD_PDK
92 endif # ONE_SHOT_MAKEFILE