blob: 024e20383410aa06fa4bf5d60f2df0195f8db61e [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Put some miscellaneous rules here
2
3# Pick a reasonable string to use to identify files.
4ifneq "" "$(filter eng.%,$(BUILD_NUMBER))"
5 # BUILD_NUMBER has a timestamp in it, which means that
6 # it will change every time. Pick a stable value.
7 FILE_NAME_TAG := eng.$(USER)
8else
9 FILE_NAME_TAG := $(BUILD_NUMBER)
10endif
11
Ying Wang160b6702012-03-13 18:58:27 -070012is_tests_build := $(filter tests,$(MAKECMDGOALS))
13
The Android Open Source Project88b60792009-03-03 19:28:42 -080014# -----------------------------------------------------------------
15# Define rules to copy PRODUCT_COPY_FILES defined by the product.
Ying Wang4b0486b2012-09-20 16:35:36 -070016# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
The Android Open Source Project88b60792009-03-03 19:28:42 -080017# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
18# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080019# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070020# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070021#$(1): the src:dest pair
22define check-product-copy-files
23$(if $(filter %.apk, $(1)),$(error \
24 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))
25endef
Ying Wang619fccf2012-09-05 18:08:29 -070026# filter out the duplicate <source file>:<dest file> pairs.
27unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080028$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070029 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
30 $(eval unique_product_copy_files_pairs += $(cf))))
31unique_product_copy_files_destinations :=
32$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070033 $(eval _src := $(call word-colon,1,$(cf))) \
34 $(eval _dest := $(call word-colon,2,$(cf))) \
Ying Wang68864102011-09-29 13:23:25 -070035 $(call check-product-copy-files,$(cf)) \
Ying Wang193010c2011-12-16 11:54:25 -080036 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
37 $(info PRODUCT_COPY_FILES $(cf) ignored.), \
Ying Wang462d26b2010-11-02 21:31:47 -070038 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070039 $(if $(filter %.xml,$(_dest)),\
40 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
41 $(eval $(call copy-one-file,$(_src),$(_fulldest)))) \
Ying Wang462d26b2010-11-02 21:31:47 -070042 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
Ying Wang7e8d4422011-06-17 17:05:35 -070043 $(eval unique_product_copy_files_destinations += $(_dest))))
Ying Wang619fccf2012-09-05 18:08:29 -070044unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070045unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080046
47# -----------------------------------------------------------------
48# docs/index.html
Ying Wang3f45b3c2012-04-02 18:21:36 -070049ifeq (,$(TARGET_BUILD_APPS))
The Android Open Source Project88b60792009-03-03 19:28:42 -080050gen := $(OUT_DOCS)/index.html
51ALL_DOCS += $(gen)
52$(gen): frameworks/base/docs/docs-redirect-index.html
53 @mkdir -p $(dir $@)
54 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -070055endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080056
57# -----------------------------------------------------------------
58# default.prop
59INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
60ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
61ADDITIONAL_DEFAULT_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -070062 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
Mike Lockwood0d23fec2011-06-09 14:54:40 -070063ADDITIONAL_DEFAULT_PROPERTIES += \
Ying Wang7e8d4422011-06-17 17:05:35 -070064 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
65ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
66 $(ADDITIONAL_DEFAULT_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -080067
68$(INSTALLED_DEFAULT_PROP_TARGET):
69 @echo Target buildinfo: $@
70 @mkdir -p $(dir $@)
71 $(hide) echo "#" > $@; \
72 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
73 echo "#" >> $@;
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -070074 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
75 echo "$(line)" >> $@;)
Joe Onorato9197a482011-06-08 16:04:14 -070076 build/tools/post_process_props.py $@
The Android Open Source Project88b60792009-03-03 19:28:42 -080077
78# -----------------------------------------------------------------
79# build.prop
80INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
81ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
82ADDITIONAL_BUILD_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -070083 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
84ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
85 $(ADDITIONAL_BUILD_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -080086
87# A list of arbitrary tags describing the build configuration.
88# Force ":=" so we can use +=
89BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
90ifeq ($(TARGET_BUILD_TYPE),debug)
91 BUILD_VERSION_TAGS += debug
92endif
Doug Zongker49c6a2b2011-10-05 12:41:56 -070093# The "test-keys" tag marks builds signed with the old test keys,
94# which are available in the SDK. "dev-keys" marks builds signed with
95# non-default dev keys (usually private keys from a vendor directory).
96# Both of these tags will be removed and replaced with "release-keys"
97# when the target-files is signed in a post-build step.
98ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
99BUILD_VERSION_TAGS += test-keys
100else
Ying Wang3c21fe52011-10-04 10:50:08 -0700101BUILD_VERSION_TAGS += dev-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700102endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800103BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
104
105# A human-readable string that descibes this build in detail.
106build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)
107$(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc)
108
109# The string used to uniquely identify this build; used by the OTA server.
110ifeq (,$(strip $(BUILD_FINGERPRINT)))
Doug Zongker135a1202010-09-15 13:02:12 -0700111 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800112endif
113ifneq ($(words $(BUILD_FINGERPRINT)),1)
114 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
115endif
116
Sriram Raman7b641242009-03-24 22:40:59 -0700117# Display parameters shown under Settings -> About Phone
118ifeq ($(TARGET_BUILD_VARIANT),user)
119 # User builds should show:
120 # release build number or branch.buld_number non-release builds
121
122 # Dev. branches should have DISPLAY_BUILD_NUMBER set
123 ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
124 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER)
125 else
126 BUILD_DISPLAY_ID := $(BUILD_ID)
127 endif
128else
129 # Non-user builds should show detailed build information
130 BUILD_DISPLAY_ID := $(build_desc)
131endif
132
Ying Wang77c882f2010-04-27 15:45:35 -0700133# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
Ying Wang38d7f022010-07-21 14:58:42 -0700134product_property_override_locale_language := $(strip \
135 $(patsubst ro.product.locale.language=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700136 $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
Ying Wang38d7f022010-07-21 14:58:42 -0700137product_property_overrides_locale_region := $(strip \
138 $(patsubst ro.product.locale.region=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700139 $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
140
The Android Open Source Project88b60792009-03-03 19:28:42 -0800141# Selects the first locale in the list given as the argument,
142# and splits it into language and region, which each may be
143# empty.
144define default-locale
145$(subst _, , $(firstword $(1)))
146endef
147
148# Selects the first locale in the list given as the argument
Ying Wang77c882f2010-04-27 15:45:35 -0700149# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
150# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800151define default-locale-language
Ying Wang38d7f022010-07-21 14:58:42 -0700152$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800153endef
154define default-locale-region
Ying Wang38d7f022010-07-21 14:58:42 -0700155$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800156endef
157
158BUILDINFO_SH := build/tools/buildinfo.sh
Chih-Wei Huang75947ef2010-11-03 18:33:46 +0800159$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800160 @echo Target buildinfo: $@
161 @mkdir -p $(dir $@)
162 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
163 TARGET_DEVICE="$(TARGET_DEVICE)" \
164 PRODUCT_NAME="$(TARGET_PRODUCT)" \
165 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
166 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
167 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700168 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800169 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
170 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
171 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
172 BUILD_ID="$(BUILD_ID)" \
173 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
174 BUILD_NUMBER="$(BUILD_NUMBER)" \
175 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
176 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700177 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800178 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
179 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
180 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
181 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700182 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800183 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Joe Onorato25939e22010-11-09 08:53:01 -0800184 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800185 bash $(BUILDINFO_SH) > $@
186 $(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \
187 cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \
188 fi
189 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
190 $(hide) echo >> $@; \
191 echo "#" >> $@; \
192 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
193 echo "#" >> $@; )
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700194 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
195 echo "$(line)" >> $@;)
Joe Onorato9197a482011-06-08 16:04:14 -0700196 $(hide) build/tools/post_process_props.py $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800197
198build_desc :=
199
200# -----------------------------------------------------------------
201# sdk-build.prop
202#
203# There are certain things in build.prop that we don't want to
204# ship with the sdk; remove them.
205
206# This must be a list of entire property keys followed by
207# "=" characters, without any internal spaces.
208sdk_build_prop_remove := \
209 ro.build.user= \
210 ro.build.host= \
211 ro.product.brand= \
212 ro.product.manufacturer= \
213 ro.product.device=
214# TODO: Remove this soon-to-be obsolete property
215sdk_build_prop_remove += ro.build.product=
216INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
217$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
218 @echo SDK buildinfo: $@
219 @mkdir -p $(dir $@)
220 $(hide) grep -v "$(subst $(space),\|,$(strip \
221 $(sdk_build_prop_remove)))" $< > $@.tmp
222 $(hide) for x in $(sdk_build_prop_remove); do \
223 echo "$$x"generic >> $@.tmp; done
224 $(hide) mv $@.tmp $@
225
226# -----------------------------------------------------------------
227# package stats
228PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
229PACKAGES_TO_STAT := \
230 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
231 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
232$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
233 @echo Package stats: $@
234 @mkdir -p $(dir $@)
235 $(hide) rm -f $@
236 $(hide) build/tools/dump-package-stats $^ > $@
237
238.PHONY: package-stats
239package-stats: $(PACKAGE_STATS_FILE)
240
241# -----------------------------------------------------------------
242# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700243# Use a macro to add newline to each echo command
244define _apkcerts_echo_with_newline
245$(hide) echo $(1)
246
247endef
248
The Android Open Source Project88b60792009-03-03 19:28:42 -0800249name := $(TARGET_PRODUCT)
250ifeq ($(TARGET_BUILD_TYPE),debug)
251 name := $(name)_debug
252endif
253name := $(name)-apkcerts-$(FILE_NAME_TAG)
254intermediates := \
255 $(call intermediates-dir-for,PACKAGING,apkcerts)
256APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800257# We don't need to really build all the modules.
258# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700259$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800260 @echo APK certs list: $@
261 @mkdir -p $(dir $@)
262 @rm -f $@
Ying Wangd9a88d52012-10-26 09:21:28 -0700263 $(foreach p,$(PACKAGES),\
264 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
265 $(call _apkcerts_echo_with_newline,\
266 'name="$(p).apk" certificate="EXTERNAL" \
267 private_key=""' >> $@),\
268 $(call _apkcerts_echo_with_newline,\
269 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
270 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@)))
271 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700272 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800273
274.PHONY: apkcerts-list
275apkcerts-list: $(APKCERTS_FILE)
276
Ying Wang15e487a2011-02-15 10:56:18 -0800277ifneq (,$(TARGET_BUILD_APPS))
278 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
279endif
Ying Wangefb21682010-07-23 16:42:13 -0700280
The Android Open Source Project88b60792009-03-03 19:28:42 -0800281# -----------------------------------------------------------------
282# module info file
283ifdef CREATE_MODULE_INFO_FILE
284 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
285 $(info Generating $(MODULE_INFO_FILE)...)
286 $(shell rm -f $(MODULE_INFO_FILE))
287 $(foreach m,$(ALL_MODULES), \
288 $(shell echo "NAME=\"$(m)\"" \
289 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
290 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
291 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
292 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
293endif
294
Doug Zongker8678df42009-06-15 14:30:14 -0700295# -----------------------------------------------------------------
296
Ying Wang3c21fe52011-10-04 10:50:08 -0700297# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700298# for future OTA packages installed by this system. Actual product
299# deliverables will be re-signed by hand. We expect this file to
300# exist with the suffixes ".x509.pem" and ".pk8".
Ying Wang3c21fe52011-10-04 10:50:08 -0700301DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Doug Zongker8678df42009-06-15 14:30:14 -0700302
303
Jeff Browne33ba4c2011-07-11 22:11:46 -0700304# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800305# if they don't do anything.
306.PHONY: systemimage
307systemimage:
308
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800309# -----------------------------------------------------------------
310
311.PHONY: event-log-tags
312
Joe Onoratob7510532010-07-14 10:22:54 -0700313# Produce an event logs tag file for everything we know about, in order
314# to properly allocate numbers. Then produce a file that's filtered
315# for what's going to be installed.
316
317all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
318
Colin Crossdc8f8e42012-04-12 13:25:54 -0700319event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
320
Joe Onoratob7510532010-07-14 10:22:54 -0700321# Include tags from all packages that we know about
322all_event_log_tags_src := \
323 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
324
Colin Crossdc8f8e42012-04-12 13:25:54 -0700325# PDK builds will already have a full list of tags that needs to get merged
326# in with the ones from source
327pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
328
329$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
330$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700331 $(hide) mkdir -p $(dir $@)
332 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
333
Doug Zongkera34fa952011-02-23 12:17:29 -0800334# Include tags from all packages included in this product, plus all
335# tags that are part of the system (ie, not in a vendor/ or device/
336# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800337event_log_tags_src := \
338 $(sort $(foreach m,\
339 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
340 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800341 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
342 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800343
Colin Crossdc8f8e42012-04-12 13:25:54 -0700344$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700345$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossdc8f8e42012-04-12 13:25:54 -0700346$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(pdk_fusion_log_tags_file)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800347 $(hide) mkdir -p $(dir $@)
Joe Onoratob7510532010-07-14 10:22:54 -0700348 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800349
350event-log-tags: $(event_log_tags_file)
351
352ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
353
Joe Onoratob7510532010-07-14 10:22:54 -0700354
The Android Open Source Project88b60792009-03-03 19:28:42 -0800355# #################################################################
356# Targets for boot/OS images
357# #################################################################
358
359# -----------------------------------------------------------------
360# the ramdisk
361INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
362 $(ALL_PREBUILT) \
363 $(ALL_COPIED_HEADERS) \
364 $(ALL_GENERATED_SOURCES) \
365 $(ALL_DEFAULT_INSTALLED_MODULES))
366
Joe Onorato64d85d02009-04-09 19:31:12 -0700367BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
368
369# We just build this directly to the install location.
370INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Ying Wang82cceba2012-08-13 15:03:00 -0700371$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800372 $(call pretty,"Target ram disk: $@")
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700373 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800374
375
376ifneq ($(strip $(TARGET_NO_KERNEL)),true)
377
378# -----------------------------------------------------------------
379# the boot image, which is a collection of other images.
380INTERNAL_BOOTIMAGE_ARGS := \
381 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
382 --kernel $(INSTALLED_KERNEL_TARGET) \
383 --ramdisk $(INSTALLED_RAMDISK_TARGET)
384
385INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
386
387BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
388ifdef BOARD_KERNEL_CMDLINE
389 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
390endif
391
Dima Zavin1e0847c2009-05-07 19:43:08 -0700392BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
393ifdef BOARD_KERNEL_BASE
394 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
395endif
396
Ying Wangffff0022010-08-23 12:56:25 -0700397BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
398ifdef BOARD_KERNEL_PAGESIZE
399 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
400endif
401
The Android Open Source Project88b60792009-03-03 19:28:42 -0800402INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
403
404ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
405tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
406INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
407INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
408$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
409 $(call pretty,"Target boot image: $@")
410 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
411
412else # TARGET_BOOTIMAGE_USE_EXT2 != true
413
414$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
415 $(call pretty,"Target boot image: $@")
Doug Zongkerd5131602012-08-02 14:46:42 -0700416 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Doug Zongkered96e882009-08-26 09:37:07 -0700417 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800418endif # TARGET_BOOTIMAGE_USE_EXT2
419
420else # TARGET_NO_KERNEL
421# HACK: The top-level targets depend on the bootimage. Not all targets
422# can produce a bootimage, though, and emulator targets need the ramdisk
423# instead. Fake it out by calling the ramdisk the bootimage.
424# TODO: make the emulator use bootimages, and make mkbootimg accept
425# kernel-less inputs.
426INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
427endif
428
429# -----------------------------------------------------------------
430# NOTICE files
431#
Steve Blockd14d3b42012-03-01 11:34:41 +0000432# We are required to publish the licenses for all code under BSD, GPL and
433# Apache licenses (and possibly other more exotic ones as well). We err on the
434# side of caution, so the licenses for other third-party code are included here
435# too.
436#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800437# This needs to be before the systemimage rules, because it adds to
438# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
439# go into the systemimage.
440
Steve Block495e5852012-02-29 19:18:08 +0000441.PHONY: notice_files
442
The Android Open Source Project88b60792009-03-03 19:28:42 -0800443# Create the rule to combine the files into text and html forms
Steve Block495e5852012-02-29 19:18:08 +0000444# $(1) - Plain text output file
445# $(2) - HTML output file
446# $(3) - File title
447# $(4) - Directory to use. Notice files are all $(4)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800448# directories in there will be used for scratch
Steve Block495e5852012-02-29 19:18:08 +0000449# $(5) - Dependencies for the output files
The Android Open Source Project88b60792009-03-03 19:28:42 -0800450#
451# The algorithm here is that we go collect a hash for each of the notice
452# files and write the names of the files that match that hash. Then
453# to generate the real files, we go print out all of the files and their
454# hashes.
455#
456# These rules are fairly complex, so they depend on this makefile so if
457# it changes, they'll run again.
458#
459# TODO: We could clean this up so that we just record the locations of the
460# original notice files instead of making rules to copy them somwehere.
461# Then we could traverse that without quite as much bash drama.
462define combine-notice-files
Steve Block495e5852012-02-29 19:18:08 +0000463$(1) $(2): PRIVATE_MESSAGE := $(3)
Daniel Berlinf5a97d72012-03-29 10:33:19 -0400464$(1) $(2): PRIVATE_DIR := $(4)
Ying Wangc4625ab2012-04-09 12:16:23 -0700465$(1) : $(2)
466$(2) : $(5) $(BUILD_SYSTEM)/Makefile build/tools/generate-notice-files.py
Daniel Berlinf5a97d72012-03-29 10:33:19 -0400467 build/tools/generate-notice-files.py $(1) $(2) $$(PRIVATE_MESSAGE) $$(PRIVATE_DIR)/src
Steve Block495e5852012-02-29 19:18:08 +0000468notice_files: $(1) $(2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800469endef
470
471# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
472# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
473# the src subdirectory.
474
Steve Block495e5852012-02-29 19:18:08 +0000475target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800476target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
477target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
Steve Block495e5852012-02-29 19:18:08 +0000478tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800479tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
480
481kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
Ying Wang4534d812012-04-09 17:04:12 -0700482pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800483
484$(eval $(call combine-notice-files, \
Steve Block495e5852012-02-29 19:18:08 +0000485 $(target_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800486 $(target_notice_file_html), \
487 "Notices for files contained in the filesystem images in this directory:", \
488 $(TARGET_OUT_NOTICE_FILES), \
Ying Wang4534d812012-04-09 17:04:12 -0700489 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800490
491$(eval $(call combine-notice-files, \
Steve Block495e5852012-02-29 19:18:08 +0000492 $(tools_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800493 $(tools_notice_file_html), \
494 "Notices for files contained in the tools directory:", \
495 $(HOST_OUT_NOTICE_FILES), \
496 $(ALL_DEFAULT_INSTALLED_MODULES)))
497
498# Install the html file at /system/etc/NOTICE.html.gz.
499# This is not ideal, but this is very late in the game, after a lot of
500# the module processing has already been done -- in fact, we used the
501# fact that all that has been done to get the list of modules that we
502# need notice files for.
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700503$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700504 $(hide) $(MINIGZIP) -9 < $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800505installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
506$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
507 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700508
509# if we've been run my mm, mmm, etc, don't reinstall this every time
510ifeq ($(ONE_SHOT_MAKEFILE),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800511ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700512endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800513
514# The kernel isn't really a module, so to get its module file in there, we
515# make the target NOTICE files depend on this particular file too, which will
516# then be in the right directory for the find in combine-notice-files to work.
517$(kernel_notice_file): \
Jean-Baptiste Querua230c4d2012-01-06 15:05:53 -0800518 prebuilts/qemu-kernel/arm/LINUX_KERNEL_COPYING \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800519 | $(ACP)
520 @echo Copying: $@
521 $(hide) mkdir -p $(dir $@)
522 $(hide) $(ACP) $< $@
523
524
Doug Zongker8678df42009-06-15 14:30:14 -0700525# -----------------------------------------------------------------
526# Build a keystore with the authorized keys in it, used to verify the
527# authenticity of downloaded OTA packages.
528#
529# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
530# before the rules that use that variable to build the image.
531ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
532$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Doug Zongker37c0e272009-06-15 15:36:16 -0700533$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Doug Zongker8678df42009-06-15 14:30:14 -0700534 $(hide) rm -f $@
535 $(hide) mkdir -p $(dir $@)
Doug Zongker37c0e272009-06-15 15:36:16 -0700536 $(hide) zip -qj $@ $<
Doug Zongker8678df42009-06-15 14:30:14 -0700537
538.PHONY: otacerts
539otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
540
541
The Android Open Source Project88b60792009-03-03 19:28:42 -0800542# #################################################################
543# Targets for user images
544# #################################################################
545
Ying Wang933abf12010-06-16 14:31:34 -0700546INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800547ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -0700548INTERNAL_USERIMAGES_USE_EXT := true
549INTERNAL_USERIMAGES_EXT_VARIANT := ext2
550else
551ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
552INTERNAL_USERIMAGES_USE_EXT := true
553INTERNAL_USERIMAGES_EXT_VARIANT := ext3
554else
555ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
556INTERNAL_USERIMAGES_USE_EXT := true
557INTERNAL_USERIMAGES_EXT_VARIANT := ext4
558endif
559endif
560endif
561
Ying Wang542903a2010-11-17 15:40:38 -0800562ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
563 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
564endif
565
Colin Cross0a7b2c52010-05-07 02:23:59 -0700566ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
Ying Wang542903a2010-11-17 15:40:38 -0800567INTERNAL_USERIMAGES_DEPS := $(MKEXTUSERIMG) $(MAKE_EXT4FS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800568else
Colin Cross144b0282010-05-10 13:04:47 -0700569INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800570endif
Ying Wang178ef922011-10-31 18:13:30 -0700571INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800572
Ying Wangfdbd9cb2012-11-21 10:47:00 -0800573SELINUX_FC := $(TARGET_ROOT_OUT)/file_contexts
574INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
575
Ying Wangbd93d422011-10-28 17:02:30 -0700576# $(1): the path of the output dictionary file
577define generate-userimage-prop-dictionary
578$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
579$(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
580$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wang9f8e8db2011-11-04 11:37:01 -0700581$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
582$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -0700583$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
584$(if $(mkyaffs2_extra_flags),$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(1))
Ying Wangfdbd9cb2012-11-21 10:47:00 -0800585$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
Ying Wangbd93d422011-10-28 17:02:30 -0700586endef
587
The Android Open Source Project88b60792009-03-03 19:28:42 -0800588# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -0700589# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700590
591# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
Mike Lockwooddaf5e222012-10-18 10:17:47 -0700592ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700593
Doug Zongker4647f122009-07-02 09:00:54 -0700594INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
595
596recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
597recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
598recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
599recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
600recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
601recovery_resources_common := $(call include-path-for, recovery)/res
602recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
603recovery_resource_deps := $(shell find $(recovery_resources_common) \
604 $(recovery_resources_private) -type f)
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700605recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Doug Zongker56588872012-08-20 15:38:58 -0700606# Named '.dat' so we don't attempt to use imgdiff for patching it.
607RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
Doug Zongker4647f122009-07-02 09:00:54 -0700608
609ifeq ($(recovery_resources_private),)
610 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
611endif
612
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700613ifeq ($(recovery_fstab),)
614 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
615endif
616
Doug Zongker4647f122009-07-02 09:00:54 -0700617INTERNAL_RECOVERYIMAGE_ARGS := \
618 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
619 --kernel $(recovery_kernel) \
620 --ramdisk $(recovery_ramdisk)
621
622# Assumes this has already been stripped
623ifdef BOARD_KERNEL_CMDLINE
624 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
625endif
626ifdef BOARD_KERNEL_BASE
627 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
628endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700629BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
630ifdef BOARD_KERNEL_PAGESIZE
631 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
632endif
Doug Zongker4647f122009-07-02 09:00:54 -0700633
634# Keys authorized to sign OTA packages this build will accept. The
Ying Wang3c21fe52011-10-04 10:50:08 -0700635# build always uses dev-keys for this; release packaging tools will
Doug Zongker4647f122009-07-02 09:00:54 -0700636# substitute other keys for this one.
Ying Wang3c21fe52011-10-04 10:50:08 -0700637OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem
Doug Zongker4647f122009-07-02 09:00:54 -0700638
639# Generate a file containing the keys that will be read by the
640# recovery binary.
641RECOVERY_INSTALL_OTA_KEYS := \
642 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
643DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
644$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
Doug Zongker5d4808d2011-03-16 07:49:13 -0700645$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
Doug Zongkere121d6a2011-02-01 14:13:52 -0800646$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys)
647 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
Doug Zongker4647f122009-07-02 09:00:54 -0700648 @rm -rf $@
649 @mkdir -p $(dir $@)
Doug Zongkere121d6a2011-02-01 14:13:52 -0800650 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
Doug Zongker4647f122009-07-02 09:00:54 -0700651
652$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
653 $(INSTALLED_RAMDISK_TARGET) \
654 $(INSTALLED_BOOTIMAGE_TARGET) \
655 $(recovery_binary) \
656 $(recovery_initrc) $(recovery_kernel) \
657 $(INSTALLED_2NDBOOTLOADER_TARGET) \
658 $(recovery_build_prop) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700659 $(recovery_fstab) \
Doug Zongker4647f122009-07-02 09:00:54 -0700660 $(RECOVERY_INSTALL_OTA_KEYS)
661 @echo ----- Making recovery image ------
Doug Zongker72f0b672012-08-08 16:26:17 -0700662 $(hide) rm -rf $(TARGET_RECOVERY_OUT)
663 $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
664 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/tmp
665 @echo Copying baseline ramdisk...
666 $(hide) cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
667 @echo Modifying ramdisk contents...
668 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
669 $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
670 $(hide) -cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/
671 $(hide) cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
672 $(hide) cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
673 $(hide) $(foreach item,$(recovery_resources_private), \
Doug Zongker4647f122009-07-02 09:00:54 -0700674 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
Doug Zongker72f0b672012-08-08 16:26:17 -0700675 $(hide) $(foreach item,$(recovery_fstab), \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700676 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Doug Zongker72f0b672012-08-08 16:26:17 -0700677 $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
678 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
Doug Zongker4647f122009-07-02 09:00:54 -0700679 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Doug Zongker72f0b672012-08-08 16:26:17 -0700680 $(hide) $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
681 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Doug Zongkered96e882009-08-26 09:37:07 -0700682 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
Doug Zongker72f0b672012-08-08 16:26:17 -0700683 @echo ----- Made recovery image: $@ --------
Doug Zongker4647f122009-07-02 09:00:54 -0700684
Doug Zongker56588872012-08-20 15:38:58 -0700685$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
Doug Zongker1a097262012-09-04 14:45:11 -0700686 $(hide) mkdir -p $(dir $@)
Doug Zongker56588872012-08-20 15:38:58 -0700687 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@
688
Doug Zongker4647f122009-07-02 09:00:54 -0700689else
690INSTALLED_RECOVERYIMAGE_TARGET :=
Doug Zongker56588872012-08-20 15:38:58 -0700691RECOVERY_RESOURCE_ZIP :=
Doug Zongker4647f122009-07-02 09:00:54 -0700692endif
693
694.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -0700695recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -0700696
Dima Zavin11818982010-02-05 13:34:34 -0800697ifneq ($(BOARD_NAND_PAGE_SIZE),)
698mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
699else
700mkyaffs2_extra_flags :=
Lars Svensson9cb8c282010-12-06 15:24:58 +0100701BOARD_NAND_PAGE_SIZE := 2048
Dima Zavin11818982010-02-05 13:34:34 -0800702endif
703
Naseer Ahmed53871882010-08-06 12:19:29 -0700704ifneq ($(BOARD_NAND_SPARE_SIZE),)
705mkyaffs2_extra_flags += -s $(BOARD_NAND_SPARE_SIZE)
Lars Svensson9cb8c282010-12-06 15:24:58 +0100706else
707BOARD_NAND_SPARE_SIZE := 64
Naseer Ahmed53871882010-08-06 12:19:29 -0700708endif
709
Doug Zongker4647f122009-07-02 09:00:54 -0700710# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -0700711# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800712#
Ying Wang9c649a72012-08-08 15:27:00 -0700713# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
714PDK_FUSION_SYSIMG_FILES := \
715 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
716 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800717
718INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -0700719 $(ALL_PREBUILT) \
720 $(ALL_COPIED_HEADERS) \
721 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -0700722 $(ALL_DEFAULT_INSTALLED_MODULES) \
723 $(PDK_FUSION_SYSIMG_FILES) \
724 $(RECOVERY_RESOURCE_ZIP))
Ying Wang160b6702012-03-13 18:58:27 -0700725
726ifdef is_tests_build
727# We don't want to install tests modules to the system partition
728# when building "tests", because now "tests" may be built in a user, userdebug
729# or eng build variant and we don't want to pollute the system partition.
730# INTERNAL_SYSTEMIMAGE_FILES += $(filter $(TARGET_OUT)/%, \
731# $(tests_MODULES))
732endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800733
Ying Wang82cceba2012-08-13 15:03:00 -0700734FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Ying Wange5e8c5f2011-09-09 16:35:53 -0700735# -----------------------------------------------------------------
736# installed file list
737# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
738# We put installed-files.txt ahead of image itself in the dependency graph
739# so that we can get the size stat even if the build fails due to too large
740# system image.
741INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
742$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS)
743 @echo Installed file list: $@
744 @mkdir -p $(dir $@)
745 @rm -f $@
746 $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@
747
748.PHONY: installed-file-list
749installed-file-list: $(INSTALLED_FILES_FILE)
750ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
751$(call dist-for-goals, sdk win_sdk, $(INSTALLED_FILES_FILE))
752endif
753ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
754$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
755endif
756
757systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -0700758 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -0700759BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
760
The Android Open Source Project88b60792009-03-03 19:28:42 -0800761# $(1): output file
762define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -0700763 @echo "Target system fs image: $(1)"
764 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
765 $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt)
766 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
767 ./build/tools/releasetools/build_image.py \
768 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800769endef
770
Ying Wange5e8c5f2011-09-09 16:35:53 -0700771$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800772 $(call build-systemimage-target,$@)
773
The Android Open Source Project88b60792009-03-03 19:28:42 -0800774INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700775SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800776
Doug Zongker73ef8252009-07-23 15:12:53 -0700777# The system partition needs room for the recovery image as well. We
778# now store the recovery image as a binary patch using the boot image
779# as the source (since they are very similar). Generate the patch so
780# we can see how big it's going to be, and include that in the system
781# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700782ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700783intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
784RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
785$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
786 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700787 $(HOST_OUT_EXECUTABLES)/imgdiff \
788 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700789 @echo "Construct recovery from boot"
790 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700791 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700792endif
793
Doug Zongker73ef8252009-07-23 15:12:53 -0700794
795$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800796 @echo "Install system fs image: $@"
797 $(copy-file-to-target)
Doug Zongkered96e882009-08-26 09:37:07 -0700798 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800799
800systemimage: $(INSTALLED_SYSTEMIMAGE)
801
802.PHONY: systemimage-nodeps snod
803systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -0700804 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800805 @echo "make $@: ignoring dependencies"
806 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
Doug Zongkered96e882009-08-26 09:37:07 -0700807 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800808
Ying Wangacf01ec2012-02-24 11:05:48 -0800809ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
810ifeq (true,$(WITH_DEXPREOPT))
811$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
812endif
813endif
814
The Android Open Source Project88b60792009-03-03 19:28:42 -0800815#######
816## system tarball
817define build-systemtarball-target
818 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
819 $(MKTARBALL) $(FS_GET_STATS) \
820 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
821 $(INSTALLED_SYSTEMTARBALL_TARGET)
822endef
823
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700824ifndef SYSTEM_TARBALL_FORMAT
825 SYSTEM_TARBALL_FORMAT := bz2
826endif
827
The Android Open Source Project88b60792009-03-03 19:28:42 -0800828system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700829INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800830$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
831$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
832 $(build-systemtarball-target)
833
834.PHONY: systemtarball-nodeps
835systemtarball-nodeps: $(FS_GET_STATS) \
836 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
837 $(build-systemtarball-target)
838
839.PHONY: stnod
840stnod: systemtarball-nodeps
841
Keun young Park816b9fd2012-05-16 10:32:41 -0700842# For platform-java goal, add platform as well
843ifneq (,$(filter platform-java, $(MAKECMDGOALS)))
844PLATFORM_ZIP_ADD_JAVA := true
845endif
846
Ying Wang4c289e52012-03-30 13:52:54 -0700847#######
Ying Wang4534d812012-04-09 17:04:12 -0700848## platform.zip: system, plus other files to be used in PDK fusion build,
849## in a zip file
Keun young Park816b9fd2012-05-16 10:32:41 -0700850INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
851$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES)
852 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Ying Wang4c289e52012-03-30 13:52:54 -0700853 $(hide) rm -f $@
Ying Wang4534d812012-04-09 17:04:12 -0700854 $(hide) cd $(dir $@) && zip -qry $(notdir $@) \
855 $(TARGET_COPY_OUT_SYSTEM) \
Keun young Park72226692012-07-31 17:13:20 -0700856 $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \
857 $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST))
Keun young Park816b9fd2012-05-16 10:32:41 -0700858ifeq (true,$(PLATFORM_ZIP_ADD_JAVA))
Ying Wang28a18172012-06-02 09:22:31 -0700859 $(hide) cd $(OUT_DIR) && zip -qry $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
Keun young Park816b9fd2012-05-16 10:32:41 -0700860endif
861
Ying Wang4c289e52012-03-30 13:52:54 -0700862
863.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -0700864platform: $(INSTALLED_PLATFORM_ZIP)
865
866.PHONY: platform-java
867platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -0700868
869# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -0700870ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
871$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -0700872endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800873
Bruce Beare52aac202010-06-04 15:24:49 -0700874#######
875## boot tarball
876define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -0700877 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -0700878 $(hide) mkdir -p $(PRODUCT_OUT)/boot
879 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
880 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
881 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
882 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
883 $(INSTALLED_BOOTTARBALL_TARGET)
884endef
885
886ifndef BOOT_TARBALL_FORMAT
887 BOOT_TARBALL_FORMAT := bz2
888endif
889
890boot_tar := $(PRODUCT_OUT)/boot.tar
891INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
892$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
893$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
894 $(build-boottarball-target)
895
896.PHONY: boottarball-nodeps btnod
897boottarball-nodeps btnod: $(FS_GET_STATS) \
898 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
899 $(build-boottarball-target)
900
901
The Android Open Source Project88b60792009-03-03 19:28:42 -0800902# -----------------------------------------------------------------
903# data partition image
904INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -0700905 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800906
Ying Wang160b6702012-03-13 18:58:27 -0700907# If we build "tests" at the same time, make sure $(tests_MODULES) get covered.
908ifdef is_tests_build
909INTERNAL_USERDATAIMAGE_FILES += \
910 $(filter $(TARGET_OUT_DATA)/%,$(tests_MODULES))
911endif
912
Ying Wange215ed52012-10-15 14:36:22 -0700913ifneq (true,$(BOARD_DONT_BUILD_USERDATA_IMG))
Ying Wangbd93d422011-10-28 17:02:30 -0700914userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -0700915 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -0700916BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
917
Ying Wangbd93d422011-10-28 17:02:30 -0700918define build-userdataimage-target
919 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
920 @mkdir -p $(TARGET_OUT_DATA)
921 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
922 $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt)
923 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
924 ./build/tools/releasetools/build_image.py \
Ying Wang178ef922011-10-31 18:13:30 -0700925 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET)
Ying Wangbd93d422011-10-28 17:02:30 -0700926 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
927endef
928
Joe Onorato64d85d02009-04-09 19:31:12 -0700929# We just build this directly to the install location.
930INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -0700931$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800932 $(INTERNAL_USERDATAIMAGE_FILES)
933 $(build-userdataimage-target)
934
935.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -0700936userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800937 $(build-userdataimage-target)
938
Ying Wange215ed52012-10-15 14:36:22 -0700939endif # no BOARD_DONT_BUILD_USERDATA_IMG
940
The Android Open Source Project88b60792009-03-03 19:28:42 -0800941#######
942## data partition tarball
943define build-userdatatarball-target
944 $(call pretty,"Target userdata fs tarball: " \
945 "$(INSTALLED_USERDATATARBALL_TARGET)")
946 $(MKTARBALL) $(FS_GET_STATS) \
947 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
948 $(INSTALLED_USERDATATARBALL_TARGET)
949endef
950
951userdata_tar := $(PRODUCT_OUT)/userdata.tar
952INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
953$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
954$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
955 $(build-userdatatarball-target)
956
957.PHONY: userdatatarball-nodeps
958userdatatarball-nodeps: $(FS_GET_STATS)
959 $(build-userdatatarball-target)
960
961
The Android Open Source Project88b60792009-03-03 19:28:42 -0800962# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -0700963# cache partition image
964ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
965INTERNAL_CACHEIMAGE_FILES := \
966 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
967
968cacheimage_intermediates := \
969 $(call intermediates-dir-for,PACKAGING,cache)
970BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
971
972define build-cacheimage-target
973 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
974 @mkdir -p $(TARGET_OUT_CACHE)
975 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
976 $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt)
977 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
978 ./build/tools/releasetools/build_image.py \
979 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET)
980 $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE),yaffs)
981endef
982
983# We just build this directly to the install location.
984INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
985$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
986 $(build-cacheimage-target)
987
988.PHONY: cacheimage-nodeps
989cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
990 $(build-cacheimage-target)
991
992endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
993
994# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800995# bring in the installer image generation defines if necessary
996ifeq ($(TARGET_USE_DISKINSTALLER),true)
997include bootable/diskinstaller/config.mk
998endif
999
1000# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07001001# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08001002
Colin Crossc312f312012-04-19 13:54:39 -07001003DISTTOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -07001004 $(HOST_OUT_EXECUTABLES)/mkbootfs \
1005 $(HOST_OUT_EXECUTABLES)/mkbootimg \
1006 $(HOST_OUT_EXECUTABLES)/fs_config \
1007 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
1008 $(HOST_OUT_EXECUTABLES)/zipalign \
Doug Zongker8678df42009-06-15 14:30:14 -07001009 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -07001010 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -07001011 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -07001012 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
1013 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
Sriram Ramanc647aec2010-11-29 18:51:20 -05001014 $(HOST_OUT_EXECUTABLES)/make_ext4fs
The Android Open Source Project88b60792009-03-03 19:28:42 -08001015
Colin Crossc312f312012-04-19 13:54:39 -07001016OTATOOLS := $(DISTTOOLS) \
1017 $(HOST_OUT_EXECUTABLES)/aapt
1018
Ying Wang06898662010-06-17 17:52:18 -07001019.PHONY: otatools
1020otatools: $(OTATOOLS)
1021
The Android Open Source Project88b60792009-03-03 19:28:42 -08001022# -----------------------------------------------------------------
1023# A zip of the directories that map to the target filesystem.
1024# This zip can be used to create an OTA package or filesystem image
1025# as a post-build step.
1026#
1027name := $(TARGET_PRODUCT)
1028ifeq ($(TARGET_BUILD_TYPE),debug)
1029 name := $(name)_debug
1030endif
1031name := $(name)-target_files-$(FILE_NAME_TAG)
1032
1033intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
1034BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
1035$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
1036$(BUILT_TARGET_FILES_PACKAGE): \
1037 zip_root := $(intermediates)/$(name)
1038
1039# $(1): Directory to copy
1040# $(2): Location to copy it to
1041# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
1042define package_files-copy-root
1043 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
1044 mkdir -p $(2) && \
1045 $(ACP) -rd $(strip $(1))/* $(2); \
1046 fi
1047endef
1048
1049built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -07001050 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -07001051 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001052 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
Doug Zongker25863d72011-09-19 15:02:03 -07001053 $(call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001054 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -08001055$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
1056
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001057$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
1058
Doug Zongkerc18736b2009-09-30 09:20:32 -07001059ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1060# default to common dir for device vendor
1061$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
1062else
1063$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1064endif
1065
The Android Open Source Project88b60792009-03-03 19:28:42 -08001066# Depending on the various images guarantees that the underlying
1067# directories are up-to-date.
1068$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001069 $(INSTALLED_BOOTIMAGE_TARGET) \
1070 $(INSTALLED_RADIOIMAGE_TARGET) \
1071 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -07001072 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001073 $(INSTALLED_USERDATAIMAGE_TARGET) \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001074 $(INSTALLED_CACHEIMAGE_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001075 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001076 $(built_ota_tools) \
1077 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -07001078 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001079 | $(ACP)
1080 @echo "Package target files: $@"
1081 $(hide) rm -rf $@ $(zip_root)
1082 $(hide) mkdir -p $(dir $@) $(zip_root)
1083 @# Components of the recovery image
1084 $(hide) mkdir -p $(zip_root)/RECOVERY
1085 $(hide) $(call package_files-copy-root, \
1086 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
1087ifdef INSTALLED_KERNEL_TARGET
1088 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
1089endif
1090ifdef INSTALLED_2NDBOOTLOADER_TARGET
1091 $(hide) $(ACP) \
1092 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
1093endif
1094ifdef BOARD_KERNEL_CMDLINE
1095 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
1096endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001097ifdef BOARD_KERNEL_BASE
1098 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
1099endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001100ifdef BOARD_KERNEL_PAGESIZE
1101 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
1102endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001103 @# Components of the boot image
1104 $(hide) mkdir -p $(zip_root)/BOOT
1105 $(hide) $(call package_files-copy-root, \
1106 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1107ifdef INSTALLED_KERNEL_TARGET
1108 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1109endif
1110ifdef INSTALLED_2NDBOOTLOADER_TARGET
1111 $(hide) $(ACP) \
1112 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1113endif
1114ifdef BOARD_KERNEL_CMDLINE
1115 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1116endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001117ifdef BOARD_KERNEL_BASE
1118 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1119endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001120ifdef BOARD_KERNEL_PAGESIZE
1121 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1122endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001123 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1124 mkdir -p $(zip_root)/RADIO; \
1125 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001126 @# Contents of the system image
1127 $(hide) $(call package_files-copy-root, \
1128 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1129 @# Contents of the data image
1130 $(hide) $(call package_files-copy-root, \
1131 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1132 @# Extra contents of the OTA package
1133 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001134 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1135 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001136 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001137 @# build them.
1138 $(hide) mkdir -p $(zip_root)/META
1139 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker17c83cf2009-04-01 15:48:46 -07001140 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -07001141 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001142ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07001143 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001144endif
1145ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001146 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001147endif
1148ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001149 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001150endif
Doug Zongker37974732010-09-16 17:44:38 -07001151 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wang3c21fe52011-10-04 10:50:08 -07001152 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
Doug Zongker5d4808d2011-03-16 07:49:13 -07001153ifdef PRODUCT_EXTRA_RECOVERY_KEYS
1154 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
Doug Zongkere121d6a2011-02-01 14:13:52 -08001155endif
Doug Zongkerd5131602012-08-02 14:46:42 -07001156 $(hide) echo "mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)" >> $(zip_root)/META/misc_info.txt
Ying Wangbd93d422011-10-28 17:02:30 -07001157 $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001158 @# Zip everything up, preserving symlinks
1159 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongker23f8bde2011-09-07 14:11:51 -07001160 @# Run fs_config on all the system, boot ramdisk, and recovery ramdisk files in the zip, and save the output
1161 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
1162 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/boot_filesystem_config.txt
1163 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/recovery_filesystem_config.txt
1164 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
Doug Zongker283e2a12010-03-15 17:52:32 -07001165
The Android Open Source Project88b60792009-03-03 19:28:42 -08001166
1167target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1168
Doug Zongker367910f2009-06-15 18:56:51 -07001169
Doug Zongker367910f2009-06-15 18:56:51 -07001170ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang279f3082011-02-09 12:26:42 -08001171ifeq ($(filter generic%,$(TARGET_DEVICE)),)
Ying Wangfb0a3472010-08-25 16:06:06 -07001172ifneq ($(TARGET_NO_KERNEL),true)
Ying Wanga73b6562011-03-03 21:52:08 -08001173ifneq ($(recovery_fstab),)
Doug Zongker367910f2009-06-15 18:56:51 -07001174
Ying Wang09a00a62010-10-20 14:01:09 -07001175# -----------------------------------------------------------------
1176# OTA update package
1177
Doug Zongker8678df42009-06-15 14:30:14 -07001178name := $(TARGET_PRODUCT)
1179ifeq ($(TARGET_BUILD_TYPE),debug)
1180 name := $(name)_debug
1181endif
1182name := $(name)-ota-$(FILE_NAME_TAG)
1183
1184INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1185
1186$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1187
Ying Wang82cceba2012-08-13 15:03:00 -07001188$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001189 @echo "Package OTA: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001190 $(hide) ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker602a84e2009-06-18 08:35:12 -07001191 -p $(HOST_OUT) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05001192 -k $(KEY_CERT_PAIR) \
1193 $(BUILT_TARGET_FILES_PACKAGE) $@
Doug Zongker8678df42009-06-15 14:30:14 -07001194
1195.PHONY: otapackage
1196otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1197
Ying Wang09a00a62010-10-20 14:01:09 -07001198# -----------------------------------------------------------------
1199# The update package
1200
1201name := $(TARGET_PRODUCT)
1202ifeq ($(TARGET_BUILD_TYPE),debug)
1203 name := $(name)_debug
1204endif
1205name := $(name)-img-$(FILE_NAME_TAG)
1206
1207INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1208
1209ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1210# default to common dir for device vendor
1211$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_DEVICE_DIR)/../common
1212else
1213$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1214endif
1215
Ying Wang82cceba2012-08-13 15:03:00 -07001216$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
Ying Wang09a00a62010-10-20 14:01:09 -07001217 @echo "Package: $@"
1218 $(hide) ./build/tools/releasetools/img_from_target_files -v \
1219 -s $(extensions) \
1220 -p $(HOST_OUT) \
1221 $(BUILT_TARGET_FILES_PACKAGE) $@
1222
1223.PHONY: updatepackage
1224updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
1225
Ying Wanga73b6562011-03-03 21:52:08 -08001226endif # recovery_fstab is defined
Ying Wangfb0a3472010-08-25 16:06:06 -07001227endif # TARGET_NO_KERNEL != true
Ying Wang279f3082011-02-09 12:26:42 -08001228endif # TARGET_DEVICE != generic*
Doug Zongker367910f2009-06-15 18:56:51 -07001229endif # TARGET_PRODUCT != sdk
Doug Zongker8678df42009-06-15 14:30:14 -07001230
Ying Wangd0244b32011-11-17 14:51:12 -08001231ifdef is_tests_build
Doug Zongker8678df42009-06-15 14:30:14 -07001232# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001233# A zip of the tests that are built when running "make tests".
1234# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
Ying Wangc5f04972012-03-13 11:22:04 -07001235# only grab DATA, and it's called "*-tests-*.zip".
The Android Open Source Project88b60792009-03-03 19:28:42 -08001236#
1237name := $(TARGET_PRODUCT)
1238ifeq ($(TARGET_BUILD_TYPE),debug)
1239 name := $(name)_debug
1240endif
1241name := $(name)-tests-$(FILE_NAME_TAG)
1242
1243intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
1244BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
1245$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
1246$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
1247
Ying Wang64661472012-06-11 16:43:40 -07001248# Depending on the image dependency files, instead of the image files itself,
1249# guarantees that the underlying directories are up-to-date,
1250# but don't really build the image.
The Android Open Source Project88b60792009-03-03 19:28:42 -08001251$(BUILT_TESTS_ZIP_PACKAGE): \
Ying Wang64661472012-06-11 16:43:40 -07001252 $(INTERNAL_USERDATAIMAGE_FILES) \
Ying Wang160b6702012-03-13 18:58:27 -07001253 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001254 @echo "Package test files: $@"
1255 $(hide) rm -rf $@ $(zip_root)
1256 $(hide) mkdir -p $(dir $@) $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001257 @# Contents of the data image
1258 $(hide) $(call package_files-copy-root, \
1259 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1260 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
1261
Ying Wang160b6702012-03-13 18:58:27 -07001262.PHONY: tests
1263tests: $(BUILT_TESTS_ZIP_PACKAGE)
Ying Wangd0244b32011-11-17 14:51:12 -08001264
Ying Wang160b6702012-03-13 18:58:27 -07001265ifneq (,$(filter tests, $(MAKECMDGOALS)))
Ying Wangd0244b32011-11-17 14:51:12 -08001266 $(call dist-for-goals, tests, $(BUILT_TESTS_ZIP_PACKAGE))
Ying Wang160b6702012-03-13 18:58:27 -07001267endif
Ying Wangd0244b32011-11-17 14:51:12 -08001268endif # is_tests_build
Ying Wang160b6702012-03-13 18:58:27 -07001269
The Android Open Source Project88b60792009-03-03 19:28:42 -08001270# -----------------------------------------------------------------
1271# A zip of the symbols directory. Keep the full paths to make it
1272# more obvious where these files came from.
1273#
1274name := $(TARGET_PRODUCT)
1275ifeq ($(TARGET_BUILD_TYPE),debug)
1276 name := $(name)_debug
1277endif
1278name := $(name)-symbols-$(FILE_NAME_TAG)
1279
1280SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1281$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1282 @echo "Package symbols: $@"
1283 $(hide) rm -rf $@
1284 $(hide) mkdir -p $(dir $@)
1285 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1286
1287# -----------------------------------------------------------------
1288# A zip of the Android Apps. Not keeping full path so that we don't
1289# include product names when distributing
1290#
1291name := $(TARGET_PRODUCT)
1292ifeq ($(TARGET_BUILD_TYPE),debug)
1293 name := $(name)_debug
1294endif
1295name := $(name)-apps-$(FILE_NAME_TAG)
1296
1297APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1298$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1299 @echo "Package apps: $@"
1300 $(hide) rm -rf $@
1301 $(hide) mkdir -p $(dir $@)
1302 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
1303
Guang Zhu0198d6e2010-04-23 11:54:37 -07001304
1305#------------------------------------------------------------------
1306# A zip of emma code coverage meta files. Generated for fully emma
1307# instrumented build.
1308#
Ying Wangbc415dd2012-08-15 12:22:44 -07001309ifeq (true,$(EMMA_INSTRUMENT))
Guang Zhu0198d6e2010-04-23 11:54:37 -07001310EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
Ying Wangbc415dd2012-08-15 12:22:44 -07001311# the dependency will be set up later in build/core/main.mk.
1312$(EMMA_META_ZIP) :
Guang Zhu0198d6e2010-04-23 11:54:37 -07001313 @echo "Collecting Emma coverage meta files."
1314 $(hide) find $(TARGET_COMMON_OUT_ROOT) -name "coverage.em" | \
1315 zip -@ -q $@
1316
Ying Wangbc415dd2012-08-15 12:22:44 -07001317endif # EMMA_INSTRUMENT=true
1318
The Android Open Source Project88b60792009-03-03 19:28:42 -08001319# -----------------------------------------------------------------
1320# dalvik something
1321.PHONY: dalvikfiles
1322dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1323
1324# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001325# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07001326ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001327INTERNAL_EMULATOR_PACKAGE_FILES += \
1328 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08001329 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001330 $(INSTALLED_RAMDISK_TARGET) \
1331 $(INSTALLED_SYSTEMIMAGE) \
1332 $(INSTALLED_USERDATAIMAGE_TARGET)
1333
1334name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1335
1336INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1337
1338$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1339 @echo "Package: $@"
1340 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1341
Ying Wang7d8c5352012-07-26 10:15:21 -07001342endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001343# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08001344# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08001345# The pdk package (Platform Development Kit)
1346
Keun young Park7fc7aad2012-02-27 15:49:23 -08001347#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1348# include development/pdk/Pdk.mk
1349#endif
1350
The Android Open Source Project88b60792009-03-03 19:28:42 -08001351
1352# -----------------------------------------------------------------
1353# The SDK
1354
The Android Open Source Project88b60792009-03-03 19:28:42 -08001355# The SDK includes host-specific components, so it belongs under HOST_OUT.
1356sdk_dir := $(HOST_OUT)/sdk
1357
1358# Build a name that looks like:
1359#
1360# linux-x86 --> android-sdk_12345_linux-x86
1361# darwin-x86 --> android-sdk_12345_mac-x86
1362# windows-x86 --> android-sdk_12345_windows
1363#
1364sdk_name := android-sdk_$(FILE_NAME_TAG)
1365ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001366 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001367else
Joe Onorato03fbe402009-04-13 08:31:16 -07001368 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001369endif
1370ifneq ($(HOST_OS),windows)
Joe Onorato03fbe402009-04-13 08:31:16 -07001371 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001372endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001373sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001374
1375sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1376
1377ATREE_FILES :=
1378-include $(sdk_dep_file)
1379
1380# if we don't have a real list, then use "everything"
1381ifeq ($(strip $(ATREE_FILES)),)
1382ATREE_FILES := \
1383 $(ALL_PREBUILT) \
1384 $(ALL_COPIED_HEADERS) \
1385 $(ALL_GENERATED_SOURCES) \
1386 $(ALL_DEFAULT_INSTALLED_MODULES) \
1387 $(INSTALLED_RAMDISK_TARGET) \
1388 $(ALL_DOCS) \
1389 $(ALL_SDK_FILES)
1390endif
1391
1392atree_dir := development/build
1393
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001394# sdk/build/tools.atree contains the generic rules, while
1395#
1396# sdk/build/tools.$(TARGET_ARCH).atree contains target-specific rules
1397# the latter is optional.
1398#
1399sdk_tools_atree_files := sdk/build/tools.atree
1400ifneq (,$(strip $(wildcard sdk/build/tools.$(TARGET_ARCH).atree)))
1401 sdk_tools_atree_files += sdk/build/tools.$(TARGET_ARCH).atree
1402endif
Raphael Moll3ab307a2012-03-02 12:40:04 -08001403ifneq (,$(strip $(wildcard sdk/build/tools.$(HOST_OS).atree)))
1404 sdk_tools_atree_files += sdk/build/tools.$(HOST_OS).atree
1405endif
1406ifneq (,$(strip $(wildcard sdk/build/tools.$(HOST_OS)-$(HOST_ARCH).atree)))
1407 sdk_tools_atree_files += sdk/build/tools.$(HOST_OS)-$(HOST_ARCH).atree
1408endif
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001409
The Android Open Source Project88b60792009-03-03 19:28:42 -08001410sdk_atree_files := \
1411 $(atree_dir)/sdk.exclude.atree \
1412 $(atree_dir)/sdk.atree \
Xavier Ducrohetffd50872010-09-27 15:51:32 -07001413 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree \
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001414 $(sdk_tools_atree_files)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001415
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02001416# development/build/sdk-android-<abi>.atree is used to differentiate
1417# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
1418# files like the kernel image. We use TARGET_CPU_ABI because we don't
1419# have a better way to distinguish between CPU models.
1420ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
1421 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
1422endif
1423
The Android Open Source Project88b60792009-03-03 19:28:42 -08001424deps := \
1425 $(target_notice_file_txt) \
1426 $(tools_notice_file_txt) \
1427 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001428 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001429 $(INSTALLED_SYSTEMIMAGE) \
1430 $(INSTALLED_USERDATAIMAGE_TARGET) \
1431 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001432 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001433 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001434 $(ATREE_FILES) \
1435 $(atree_dir)/sdk.atree \
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001436 $(sdk_tools_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001437 $(HOST_OUT_EXECUTABLES)/atree \
Joe Onorato63d56da2012-08-17 04:19:38 -07001438 $(HOST_OUT_EXECUTABLES)/line_endings
The Android Open Source Project88b60792009-03-03 19:28:42 -08001439
1440INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1441$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1442$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1443$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1444$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1445
1446# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1447#
1448#SDK_GNU_ERROR := true
1449
1450$(INTERNAL_SDK_TARGET): $(deps)
1451 @echo "Package SDK: $@"
1452 $(hide) rm -rf $(PRIVATE_DIR) $@
1453 $(hide) for f in $(target_gnu_MODULES); do \
1454 if [ -f $$f ]; then \
1455 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1456 including GNU target $$f >&2; \
1457 FAIL=$(SDK_GNU_ERROR); \
1458 fi; \
1459 done; \
1460 if [ $$FAIL ]; then exit 1; fi
1461 $(hide) ( \
Raphael Mollec5fe912012-06-06 19:33:31 -07001462 ATREE_STRIP="strip -x" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001463 $(HOST_OUT_EXECUTABLES)/atree \
1464 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1465 -m $(PRIVATE_DEP_FILE) \
1466 -I . \
1467 -I $(PRODUCT_OUT) \
1468 -I $(HOST_OUT) \
1469 -I $(TARGET_COMMON_OUT_ROOT) \
1470 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
Raphael Moll7558ad52011-01-05 14:58:17 -08001471 -v "OUT_DIR=$(OUT_DIR)" \
Raphael2a533172011-11-15 16:29:16 -08001472 -v "HOST_OUT=$(HOST_OUT)" \
Bruce Beare18a130e2011-02-18 15:06:20 -08001473 -v "TARGET_ARCH=$(TARGET_ARCH)" \
1474 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
David 'Digit' Turner557c51f2011-08-25 14:28:03 +02001475 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001476 -o $(PRIVATE_DIR) && \
1477 cp -f $(target_notice_file_txt) \
Xavier Ducrohet6de7bc62011-09-21 10:22:19 -07001478 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001479 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
Xavier Ducrohet4216a8c2011-03-15 13:28:40 -07001480 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001481 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Raphael7a6a9c32011-02-01 13:30:00 -08001482 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001483 chmod -R ug+rwX $(PRIVATE_DIR) && \
1484 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1485 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1486
Raphael3d224a02010-04-16 17:50:09 -07001487
1488# Is a Windows SDK requested? If so, we need some definitions from here
1489# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08001490MAIN_SDK_NAME := $(sdk_name)
1491MAIN_SDK_DIR := $(sdk_dir)
1492MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Raphael3d224a02010-04-16 17:50:09 -07001493ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07001494include $(TOPDIR)development/build/tools/windows_sdk.mk
1495endif
1496
The Android Open Source Project88b60792009-03-03 19:28:42 -08001497# -----------------------------------------------------------------
1498# Findbugs
1499INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1500INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1501$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1502 @echo UnionBugs: $@
1503 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1504 > $@
1505$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1506 @echo ConvertXmlToText: $@
1507 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1508 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1509
1510# -----------------------------------------------------------------
1511# Findbugs
1512
1513# -----------------------------------------------------------------
1514# These are some additional build tasks that need to be run.
1515include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01001516-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07001517-include $(sort $(wildcard device/*/build/tasks/*.mk))
Raphaelc4d47312011-02-15 16:09:36 -08001518
1519# -----------------------------------------------------------------
1520# Create SDK repository packages. Must be done after tasks/* since
1521# we need the addon rules defined.
1522ifneq ($(sdk_repo_goal),)
1523include $(TOPDIR)development/build/tools/sdk_repo.mk
1524endif