Ying Wang | 0a099d9 | 2011-12-16 11:27:52 -0800 | [diff] [blame] | 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 | |
Ying Wang | 14eeea6 | 2011-12-21 18:54:36 -0800 | [diff] [blame] | 17 | ifeq (,$(ONE_SHOT_MAKEFILE)) |
Nick Sanders | a1712ee | 2012-11-02 12:55:56 -0700 | [diff] [blame] | 18 | ifneq ($(TARGET_BUILD_PDK),true) |
Devin Kim | 60b9efc | 2013-02-04 12:24:44 -0800 | [diff] [blame] | 19 | TARGET_BUILD_FACTORY=true |
| 20 | endif |
| 21 | ifeq ($(TARGET_BUILD_FACTORY),true) |
Ying Wang | 9d5e83d | 2011-12-21 16:20:12 -0800 | [diff] [blame] | 22 | |
Ying Wang | c16dbcd | 2011-12-21 11:30:59 -0800 | [diff] [blame] | 23 | # PRODUCT_FACTORY_RAMDISK_MODULES consists of "<module_name>:<install_path>[:<install_path>...]" tuples. |
Ying Wang | 0a099d9 | 2011-12-16 11:27:52 -0800 | [diff] [blame] | 24 | # <install_path> is relative to TARGET_FACTORY_RAMDISK_OUT. |
Ying Wang | c16dbcd | 2011-12-21 11:30:59 -0800 | [diff] [blame] | 25 | # We can have multiple <install_path>s because multiple modules may have the same name. |
Ying Wang | 0a099d9 | 2011-12-16 11:27:52 -0800 | [diff] [blame] | 26 | # For example: |
| 27 | # PRODUCT_FACTORY_RAMDISK_MODULES := \ |
Ying Wang | c16dbcd | 2011-12-21 11:30:59 -0800 | [diff] [blame] | 28 | # toolbox:system/bin/toolbox adbd:sbin/adbd adb:system/bin/adb |
Ying Wang | 0a099d9 | 2011-12-16 11:27:52 -0800 | [diff] [blame] | 29 | factory_ramdisk_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_RAMDISK_MODULES)) |
| 30 | ifneq (,$(factory_ramdisk_modules)) |
Ying Wang | c16dbcd | 2011-12-21 11:30:59 -0800 | [diff] [blame] | 31 | |
| 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 |
| 37 | define 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 Rogers | 76a6dc3 | 2012-10-01 16:36:23 -0700 | [diff] [blame] | 47 | $(error Error: Cannot find match in "$(2)" for "$(1)") \ |
Ying Wang | c16dbcd | 2011-12-21 11:30:59 -0800 | [diff] [blame] | 48 | ) |
| 49 | endef |
| 50 | |
Ying Wang | 0a099d9 | 2011-12-16 11:27:52 -0800 | [diff] [blame] | 51 | INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES := |
| 52 | $(foreach m, $(factory_ramdisk_modules), \ |
Ying Wang | c16dbcd | 2011-12-21 11:30:59 -0800 | [diff] [blame] | 53 | $(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 Wang | 0a099d9 | 2011-12-16 11:27:52 -0800 | [diff] [blame] | 59 | endif |
| 60 | |
| 61 | # Files may also be installed via PRODUCT_COPY_FILES, PRODUCT_PACKAGES etc. |
| 62 | INTERNAL_FACTORY_RAMDISK_FILES := $(filter $(TARGET_FACTORY_RAMDISK_OUT)/%, \ |
| 63 | $(ALL_DEFAULT_INSTALLED_MODULES)) |
| 64 | |
| 65 | ifneq (,$(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES)$(INTERNAL_FACTORY_RAMDISK_FILES)) |
| 66 | |
Nick Sanders | 756eda8 | 2012-01-30 19:25:21 -0800 | [diff] [blame] | 67 | # 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)) |
| 69 | INTERNAL_FACTORY_RAMDISK_FILES += $(TARGET_FACTORY_RAMDISK_OUT)/system/build.prop |
| 70 | |
Nick Sanders | 7d2ba7c | 2011-12-29 15:44:29 -0800 | [diff] [blame] | 71 | BUILT_FACTORY_RAMDISK_FS := $(PRODUCT_OUT)/factory_ramdisk.gz |
Ying Wang | 0a099d9 | 2011-12-16 11:27:52 -0800 | [diff] [blame] | 72 | BUILT_FACTORY_RAMDISK_TARGET := $(PRODUCT_OUT)/factory_ramdisk.img |
| 73 | |
Nick Sanders | 7d2ba7c | 2011-12-29 15:44:29 -0800 | [diff] [blame] | 74 | INSTALLED_FACTORY_RAMDISK_FS := $(BUILT_FACTORY_RAMDISK_FS) |
| 75 | $(INSTALLED_FACTORY_RAMDISK_FS) : $(MKBOOTFS) \ |
Ying Wang | 0a099d9 | 2011-12-16 11:27:52 -0800 | [diff] [blame] | 76 | $(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES) $(INTERNAL_FACTORY_RAMDISK_FILES) | $(MINIGZIP) |
Nick Sanders | 7d2ba7c | 2011-12-29 15:44:29 -0800 | [diff] [blame] | 77 | $(call pretty,"Target factory ram disk file system: $@") |
Ying Wang | 0a099d9 | 2011-12-16 11:27:52 -0800 | [diff] [blame] | 78 | $(hide) $(MKBOOTFS) $(TARGET_FACTORY_RAMDISK_OUT) | $(MINIGZIP) > $@ |
| 79 | |
Nick Sanders | 7d2ba7c | 2011-12-29 15:44:29 -0800 | [diff] [blame] | 80 | TARGET_RAMDISK_KERNEL := $(INSTALLED_KERNEL_TARGET) |
| 81 | INSTALLED_FACTORY_RAMDISK_TARGET := $(BUILT_FACTORY_RAMDISK_TARGET) |
Nick Sanders | df49771 | 2012-04-05 18:30:02 -0700 | [diff] [blame] | 82 | ifneq (,$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT)) |
| 83 | RAMDISK_CMDLINE := --cmdline "$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT)" |
| 84 | else |
| 85 | RAMDISK_CMDLINE := |
| 86 | endif |
Nick Sanders | 7d2ba7c | 2011-12-29 15:44:29 -0800 | [diff] [blame] | 87 | $(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 Zongker | d513160 | 2012-08-02 14:46:42 -0700 | [diff] [blame] | 90 | --base $(BOARD_KERNEL_BASE) $(BOARD_MKBOOTIMG_ARGS) $(RAMDISK_CMDLINE) --output $@ |
Nick Sanders | 7d2ba7c | 2011-12-29 15:44:29 -0800 | [diff] [blame] | 91 | |
Ying Wang | 0a099d9 | 2011-12-16 11:27:52 -0800 | [diff] [blame] | 92 | endif |
Ying Wang | 9d5e83d | 2011-12-21 16:20:12 -0800 | [diff] [blame] | 93 | |
Nick Sanders | a1712ee | 2012-11-02 12:55:56 -0700 | [diff] [blame] | 94 | endif # TARGET_BUILD_PDK |
Ying Wang | 9d5e83d | 2011-12-21 16:20:12 -0800 | [diff] [blame] | 95 | endif # ONE_SHOT_MAKEFILE |