blob: 00fcdde7b495389fa157404761f05b8ec677462b [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))
Nick Sandersa1712ee2012-11-02 12:55:56 -070018ifneq ($(TARGET_BUILD_PDK),true)
Devin Kim60b9efc2013-02-04 12:24:44 -080019 TARGET_BUILD_FACTORY=true
20endif
21ifeq ($(TARGET_BUILD_FACTORY),true)
Ying Wang9d5e83d2011-12-21 16:20:12 -080022
Ying Wangc16dbcd2011-12-21 11:30:59 -080023# PRODUCT_FACTORY_RAMDISK_MODULES consists of "<module_name>:<install_path>[:<install_path>...]" tuples.
Ying Wang0a099d92011-12-16 11:27:52 -080024# <install_path> is relative to TARGET_FACTORY_RAMDISK_OUT.
Ying Wangc16dbcd2011-12-21 11:30:59 -080025# We can have multiple <install_path>s because multiple modules may have the same name.
Ying Wang0a099d92011-12-16 11:27:52 -080026# For example:
27# PRODUCT_FACTORY_RAMDISK_MODULES := \
Ying Wangc16dbcd2011-12-21 11:30:59 -080028# toolbox:system/bin/toolbox adbd:sbin/adbd adb:system/bin/adb
Ying Wang0a099d92011-12-16 11:27:52 -080029factory_ramdisk_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_RAMDISK_MODULES))
30ifneq (,$(factory_ramdisk_modules))
Ying Wangc16dbcd2011-12-21 11:30:59 -080031
32# A module name may end up in multiple modules (so multiple built files)
33# with the same name.
34# This function selects the module built file based on the install path.
35# $(1): the dest install path
36# $(2): the module built files
37define install-one-factory-ramdisk-module
38$(eval _iofrm_suffix := $(suffix $(1))) \
39$(if $(_iofrm_suffix), \
40 $(eval _iofrm_pattern := %$(_iofrm_suffix)), \
41 $(eval _iofrm_pattern := %$(notdir $(1)))) \
42$(eval _iofrm_src := $(filter $(_iofrm_pattern),$(2))) \
43$(if $(filter 1,$(words $(_iofrm_src))), \
44 $(eval _fulldest := $(TARGET_FACTORY_RAMDISK_OUT)/$(1)) \
45 $(eval $(call copy-one-file,$(_iofrm_src),$(_fulldest))) \
46 $(eval INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES += $(_fulldest)), \
Ian Rogers76a6dc32012-10-01 16:36:23 -070047 $(error Error: Cannot find match in "$(2)" for "$(1)") \
Ying Wangc16dbcd2011-12-21 11:30:59 -080048 )
49endef
50
Ying Wang0a099d92011-12-16 11:27:52 -080051INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES :=
52$(foreach m, $(factory_ramdisk_modules), \
Ying Wangc16dbcd2011-12-21 11:30:59 -080053 $(eval _fr_m_tuple := $(subst :, ,$(m))) \
54 $(eval _fr_m_name := $(word 1,$(_fr_m_tuple))) \
55 $(eval _fr_dests := $(wordlist 2,999,$(_fr_m_tuple))) \
56 $(eval _fr_m_built := $(filter $(PRODUCT_OUT)/%, $(ALL_MODULES.$(_fr_m_name).BUILT))) \
57 $(foreach d,$(_fr_dests),$(call install-one-factory-ramdisk-module,$(d),$(_fr_m_built))) \
58 )
Ying Wang0a099d92011-12-16 11:27:52 -080059endif
60
61# Files may also be installed via PRODUCT_COPY_FILES, PRODUCT_PACKAGES etc.
62INTERNAL_FACTORY_RAMDISK_FILES := $(filter $(TARGET_FACTORY_RAMDISK_OUT)/%, \
63 $(ALL_DEFAULT_INSTALLED_MODULES))
64
65ifneq (,$(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES)$(INTERNAL_FACTORY_RAMDISK_FILES))
66
Nick Sanders756eda82012-01-30 19:25:21 -080067# These files are made by magic in build/core/Makefile so we need to explicitly include them
68$(eval $(call copy-one-file,$(TARGET_OUT)/build.prop,$(TARGET_FACTORY_RAMDISK_OUT)/system/build.prop))
69INTERNAL_FACTORY_RAMDISK_FILES += $(TARGET_FACTORY_RAMDISK_OUT)/system/build.prop
70
Nick Sanders7d2ba7c2011-12-29 15:44:29 -080071BUILT_FACTORY_RAMDISK_FS := $(PRODUCT_OUT)/factory_ramdisk.gz
Ying Wang0a099d92011-12-16 11:27:52 -080072BUILT_FACTORY_RAMDISK_TARGET := $(PRODUCT_OUT)/factory_ramdisk.img
73
Nick Sanders7d2ba7c2011-12-29 15:44:29 -080074INSTALLED_FACTORY_RAMDISK_FS := $(BUILT_FACTORY_RAMDISK_FS)
75$(INSTALLED_FACTORY_RAMDISK_FS) : $(MKBOOTFS) \
Ying Wang0a099d92011-12-16 11:27:52 -080076 $(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES) $(INTERNAL_FACTORY_RAMDISK_FILES) | $(MINIGZIP)
Nick Sanders7d2ba7c2011-12-29 15:44:29 -080077 $(call pretty,"Target factory ram disk file system: $@")
Ying Wang0a099d92011-12-16 11:27:52 -080078 $(hide) $(MKBOOTFS) $(TARGET_FACTORY_RAMDISK_OUT) | $(MINIGZIP) > $@
79
Nick Sanders7d2ba7c2011-12-29 15:44:29 -080080TARGET_RAMDISK_KERNEL := $(INSTALLED_KERNEL_TARGET)
81INSTALLED_FACTORY_RAMDISK_TARGET := $(BUILT_FACTORY_RAMDISK_TARGET)
Nick Sandersdf497712012-04-05 18:30:02 -070082ifneq (,$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT))
83 RAMDISK_CMDLINE := --cmdline "$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT)"
84else
85 RAMDISK_CMDLINE :=
86endif
Nick Sanders7d2ba7c2011-12-29 15:44:29 -080087$(INSTALLED_FACTORY_RAMDISK_TARGET) : $(MKBOOTIMG) $(TARGET_RAMDISK_KERNEL) $(INSTALLED_FACTORY_RAMDISK_FS)
88 $(call pretty,"Target factory ram disk img format: $@")
89 $(MKBOOTIMG) --kernel $(TARGET_RAMDISK_KERNEL) --ramdisk $(INSTALLED_FACTORY_RAMDISK_FS) \
Doug Zongkerd5131602012-08-02 14:46:42 -070090 --base $(BOARD_KERNEL_BASE) $(BOARD_MKBOOTIMG_ARGS) $(RAMDISK_CMDLINE) --output $@
Nick Sanders7d2ba7c2011-12-29 15:44:29 -080091
Ying Wang0a099d92011-12-16 11:27:52 -080092endif
Ying Wang9d5e83d2011-12-21 16:20:12 -080093
Nick Sandersa1712ee2012-11-02 12:55:56 -070094endif # TARGET_BUILD_PDK
Ying Wang9d5e83d2011-12-21 16:20:12 -080095endif # ONE_SHOT_MAKEFILE