blob: 38a588735ebdc2faa16e1601b76fdb7af2b1b4bf [file] [log] [blame]
Ying Wang0a099d92011-12-16 11:27:52 -08001#
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
Ying Wang14eeea62011-12-21 18:54:36 -080017ifeq (,$(ONE_SHOT_MAKEFILE))
Ying Wang9d5e83d2011-12-21 16:20:12 -080018
Ying Wangc16dbcd2011-12-21 11:30:59 -080019# PRODUCT_FACTORY_RAMDISK_MODULES consists of "<module_name>:<install_path>[:<install_path>...]" tuples.
Ying Wang0a099d92011-12-16 11:27:52 -080020# <install_path> is relative to TARGET_FACTORY_RAMDISK_OUT.
Ying Wangc16dbcd2011-12-21 11:30:59 -080021# We can have multiple <install_path>s because multiple modules may have the same name.
Ying Wang0a099d92011-12-16 11:27:52 -080022# For example:
23# PRODUCT_FACTORY_RAMDISK_MODULES := \
Ying Wangc16dbcd2011-12-21 11:30:59 -080024# toolbox:system/bin/toolbox adbd:sbin/adbd adb:system/bin/adb
Ying Wang0a099d92011-12-16 11:27:52 -080025factory_ramdisk_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_RAMDISK_MODULES))
26ifneq (,$(factory_ramdisk_modules))
Ying Wangc16dbcd2011-12-21 11:30:59 -080027
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
33define 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)), \
Ian Rogers76a6dc32012-10-01 16:36:23 -070043 $(error Error: Cannot find match in "$(2)" for "$(1)") \
Ying Wangc16dbcd2011-12-21 11:30:59 -080044 )
45endef
46
Ying Wang0a099d92011-12-16 11:27:52 -080047INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES :=
48$(foreach m, $(factory_ramdisk_modules), \
Ying Wangc16dbcd2011-12-21 11:30:59 -080049 $(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 )
Ying Wang0a099d92011-12-16 11:27:52 -080055endif
56
57# Files may also be installed via PRODUCT_COPY_FILES, PRODUCT_PACKAGES etc.
58INTERNAL_FACTORY_RAMDISK_FILES := $(filter $(TARGET_FACTORY_RAMDISK_OUT)/%, \
59 $(ALL_DEFAULT_INSTALLED_MODULES))
60
61ifneq (,$(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES)$(INTERNAL_FACTORY_RAMDISK_FILES))
62
Nick Sanders756eda82012-01-30 19:25:21 -080063# 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))
65INTERNAL_FACTORY_RAMDISK_FILES += $(TARGET_FACTORY_RAMDISK_OUT)/system/build.prop
66
Nick Sanders7d2ba7c2011-12-29 15:44:29 -080067BUILT_FACTORY_RAMDISK_FS := $(PRODUCT_OUT)/factory_ramdisk.gz
Ying Wang0a099d92011-12-16 11:27:52 -080068BUILT_FACTORY_RAMDISK_TARGET := $(PRODUCT_OUT)/factory_ramdisk.img
69
Nick Sanders7d2ba7c2011-12-29 15:44:29 -080070INSTALLED_FACTORY_RAMDISK_FS := $(BUILT_FACTORY_RAMDISK_FS)
71$(INSTALLED_FACTORY_RAMDISK_FS) : $(MKBOOTFS) \
Ying Wang0a099d92011-12-16 11:27:52 -080072 $(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES) $(INTERNAL_FACTORY_RAMDISK_FILES) | $(MINIGZIP)
Nick Sanders7d2ba7c2011-12-29 15:44:29 -080073 $(call pretty,"Target factory ram disk file system: $@")
Ying Wang0a099d92011-12-16 11:27:52 -080074 $(hide) $(MKBOOTFS) $(TARGET_FACTORY_RAMDISK_OUT) | $(MINIGZIP) > $@
75
Nick Sanders7d2ba7c2011-12-29 15:44:29 -080076TARGET_RAMDISK_KERNEL := $(INSTALLED_KERNEL_TARGET)
77INSTALLED_FACTORY_RAMDISK_TARGET := $(BUILT_FACTORY_RAMDISK_TARGET)
Nick Sandersdf497712012-04-05 18:30:02 -070078ifneq (,$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT))
79 RAMDISK_CMDLINE := --cmdline "$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT)"
80else
81 RAMDISK_CMDLINE :=
82endif
Nick Sanders7d2ba7c2011-12-29 15:44:29 -080083$(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) \
Doug Zongkerd5131602012-08-02 14:46:42 -070086 --base $(BOARD_KERNEL_BASE) $(BOARD_MKBOOTIMG_ARGS) $(RAMDISK_CMDLINE) --output $@
Nick Sanders7d2ba7c2011-12-29 15:44:29 -080087
Ying Wang0a099d92011-12-16 11:27:52 -080088endif
Ying Wang9d5e83d2011-12-21 16:20:12 -080089
90endif # ONE_SHOT_MAKEFILE