blob: bf78b4461d57f3220cb48962bbc11accef65663b [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Put some miscellaneous rules here
2
Ying Wang3bbfddd2014-03-01 15:32:04 -08003# HACK: clear LOCAL_PATH from including last build target before calling
4# intermedites-dir-for
5LOCAL_PATH := $(BUILD_SYSTEM)
6
The Android Open Source Project88b60792009-03-03 19:28:42 -08007# Pick a reasonable string to use to identify files.
8ifneq "" "$(filter eng.%,$(BUILD_NUMBER))"
9 # BUILD_NUMBER has a timestamp in it, which means that
10 # it will change every time. Pick a stable value.
11 FILE_NAME_TAG := eng.$(USER)
12else
13 FILE_NAME_TAG := $(BUILD_NUMBER)
14endif
15
16# -----------------------------------------------------------------
17# Define rules to copy PRODUCT_COPY_FILES defined by the product.
Ying Wang4b0486b2012-09-20 16:35:36 -070018# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
The Android Open Source Project88b60792009-03-03 19:28:42 -080019# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
20# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080021# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070022# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070023#$(1): the src:dest pair
24define check-product-copy-files
Ying Wangc6c21d02014-01-21 20:25:46 -080025$(if $(filter %.apk, $(call word-colon, 2, $(1))),$(error \
Ying Wang68864102011-09-29 13:23:25 -070026 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))
27endef
Ying Wang619fccf2012-09-05 18:08:29 -070028# filter out the duplicate <source file>:<dest file> pairs.
29unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080030$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070031 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
32 $(eval unique_product_copy_files_pairs += $(cf))))
33unique_product_copy_files_destinations :=
34$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070035 $(eval _src := $(call word-colon,1,$(cf))) \
36 $(eval _dest := $(call word-colon,2,$(cf))) \
Ying Wang68864102011-09-29 13:23:25 -070037 $(call check-product-copy-files,$(cf)) \
Ying Wang193010c2011-12-16 11:54:25 -080038 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
39 $(info PRODUCT_COPY_FILES $(cf) ignored.), \
Ying Wang462d26b2010-11-02 21:31:47 -070040 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070041 $(if $(filter %.xml,$(_dest)),\
42 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
43 $(eval $(call copy-one-file,$(_src),$(_fulldest)))) \
Ying Wang462d26b2010-11-02 21:31:47 -070044 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
Ying Wang7e8d4422011-06-17 17:05:35 -070045 $(eval unique_product_copy_files_destinations += $(_dest))))
Ying Wang619fccf2012-09-05 18:08:29 -070046unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070047unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080048
49# -----------------------------------------------------------------
50# docs/index.html
Ying Wang3f45b3c2012-04-02 18:21:36 -070051ifeq (,$(TARGET_BUILD_APPS))
The Android Open Source Project88b60792009-03-03 19:28:42 -080052gen := $(OUT_DOCS)/index.html
53ALL_DOCS += $(gen)
54$(gen): frameworks/base/docs/docs-redirect-index.html
55 @mkdir -p $(dir $@)
56 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -070057endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080058
59# -----------------------------------------------------------------
60# default.prop
61INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
62ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
63ADDITIONAL_DEFAULT_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -070064 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
Mike Lockwood0d23fec2011-06-09 14:54:40 -070065ADDITIONAL_DEFAULT_PROPERTIES += \
Ying Wang7e8d4422011-06-17 17:05:35 -070066 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
67ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
68 $(ADDITIONAL_DEFAULT_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -080069
70$(INSTALLED_DEFAULT_PROP_TARGET):
71 @echo Target buildinfo: $@
72 @mkdir -p $(dir $@)
73 $(hide) echo "#" > $@; \
74 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
75 echo "#" >> $@;
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -070076 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
77 echo "$(line)" >> $@;)
Joe Onorato9197a482011-06-08 16:04:14 -070078 build/tools/post_process_props.py $@
The Android Open Source Project88b60792009-03-03 19:28:42 -080079
80# -----------------------------------------------------------------
81# build.prop
82INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
83ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
84ADDITIONAL_BUILD_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -070085 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
86ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
87 $(ADDITIONAL_BUILD_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -080088
89# A list of arbitrary tags describing the build configuration.
90# Force ":=" so we can use +=
91BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
92ifeq ($(TARGET_BUILD_TYPE),debug)
93 BUILD_VERSION_TAGS += debug
94endif
Doug Zongker49c6a2b2011-10-05 12:41:56 -070095# The "test-keys" tag marks builds signed with the old test keys,
96# which are available in the SDK. "dev-keys" marks builds signed with
97# non-default dev keys (usually private keys from a vendor directory).
98# Both of these tags will be removed and replaced with "release-keys"
99# when the target-files is signed in a post-build step.
100ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
Doug Zongkera8608a72013-07-23 11:51:04 -0700101BUILD_KEYS := test-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700102else
Doug Zongkera8608a72013-07-23 11:51:04 -0700103BUILD_KEYS := dev-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700104endif
Doug Zongkera8608a72013-07-23 11:51:04 -0700105BUILD_VERSION_TAGS += $(BUILD_KEYS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800106BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
107
108# A human-readable string that descibes this build in detail.
109build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)
110$(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc)
111
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700112# The string used to uniquely identify the combined build and product; used by the OTA server.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800113ifeq (,$(strip $(BUILD_FINGERPRINT)))
Doug Zongker135a1202010-09-15 13:02:12 -0700114 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 -0800115endif
116ifneq ($(words $(BUILD_FINGERPRINT)),1)
117 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
118endif
119
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700120# The string used to uniquely identify the system build; used by the OTA server.
121# This purposefully excludes any product-specific variables.
122ifeq (,$(strip $(BUILD_THUMBPRINT)))
123 BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
124endif
125ifneq ($(words $(BUILD_THUMBPRINT)),1)
126 $(error BUILD_THUMBPRINT cannot contain spaces: "$(BUILD_THUMBPRINT)")
127endif
128
Sriram Raman7b641242009-03-24 22:40:59 -0700129# Display parameters shown under Settings -> About Phone
130ifeq ($(TARGET_BUILD_VARIANT),user)
131 # User builds should show:
132 # release build number or branch.buld_number non-release builds
133
134 # Dev. branches should have DISPLAY_BUILD_NUMBER set
135 ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
Doug Zongkera8608a72013-07-23 11:51:04 -0700136 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700137 else
Doug Zongkera8608a72013-07-23 11:51:04 -0700138 BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700139 endif
140else
141 # Non-user builds should show detailed build information
142 BUILD_DISPLAY_ID := $(build_desc)
143endif
144
Ying Wang77c882f2010-04-27 15:45:35 -0700145# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
Ying Wang38d7f022010-07-21 14:58:42 -0700146product_property_override_locale_language := $(strip \
147 $(patsubst ro.product.locale.language=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700148 $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
Ying Wang38d7f022010-07-21 14:58:42 -0700149product_property_overrides_locale_region := $(strip \
150 $(patsubst ro.product.locale.region=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700151 $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
152
The Android Open Source Project88b60792009-03-03 19:28:42 -0800153# Selects the first locale in the list given as the argument,
154# and splits it into language and region, which each may be
155# empty.
156define default-locale
157$(subst _, , $(firstword $(1)))
158endef
159
160# Selects the first locale in the list given as the argument
Ying Wang77c882f2010-04-27 15:45:35 -0700161# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
162# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800163define default-locale-language
Ying Wang38d7f022010-07-21 14:58:42 -0700164$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800165endef
166define default-locale-region
Ying Wang38d7f022010-07-21 14:58:42 -0700167$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800168endef
169
170BUILDINFO_SH := build/tools/buildinfo.sh
Andrew Boiefa61ff02012-09-28 09:33:45 -0700171
172ifdef TARGET_SYSTEM_PROP
173system_prop_file := $(TARGET_SYSTEM_PROP)
174else
175system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
176endif
Andrew Boiefa61ff02012-09-28 09:33:45 -0700177$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800178 @echo Target buildinfo: $@
179 @mkdir -p $(dir $@)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700180 $(hide) echo > $@
181ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),)
182 $(hide) echo "#" >> $@; \
183 echo "# PRODUCT_OEM_PROPERTIES" >> $@; \
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700184 echo "#" >> $@;
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700185 $(hide) $(foreach prop,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES), \
186 echo "import /oem/oem.prop $(prop)" >> $@;)
187endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800188 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
189 TARGET_DEVICE="$(TARGET_DEVICE)" \
190 PRODUCT_NAME="$(TARGET_PRODUCT)" \
191 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
192 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
193 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700194 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800195 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
196 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
197 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
198 BUILD_ID="$(BUILD_ID)" \
199 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
200 BUILD_NUMBER="$(BUILD_NUMBER)" \
201 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
202 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700203 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
Dianne Hackborn6ee3c432014-04-24 16:19:14 -0700204 PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800205 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
206 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
207 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700208 BUILD_THUMBPRINT="$(BUILD_THUMBPRINT)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800209 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
Narayan Kamath1a43b372014-03-26 17:33:55 +0000210 TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \
Narayan Kamath7303ebd2014-04-07 11:01:54 +0100211 TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \
212 TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700213 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800214 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Colin Crossd00c0a22014-06-26 13:05:29 -0700215 TARGET_2ND_CPU_ABI="$(TARGET_2ND_CPU_ABI)" \
216 TARGET_2ND_CPU_ABI2="$(TARGET_2ND_CPU_ABI2)" \
Joe Onorato25939e22010-11-09 08:53:01 -0800217 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700218 bash $(BUILDINFO_SH) >> $@
Johan Redestig674a27d2012-04-12 17:00:58 +0200219 $(hide) $(foreach file,$(system_prop_file), \
220 if [ -f "$(file)" ]; then \
221 echo "#" >> $@; \
222 echo Target buildinfo from: "$(file)"; \
223 echo "# from $(file)" >> $@; \
224 echo "#" >> $@; \
225 cat $(file) >> $@; \
226 fi;)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800227 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
228 $(hide) echo >> $@; \
229 echo "#" >> $@; \
230 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
231 echo "#" >> $@; )
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700232 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
233 echo "$(line)" >> $@;)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700234 $(hide) build/tools/post_process_props.py $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_PROPERTY_BLACKLIST)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800235
236build_desc :=
237
238# -----------------------------------------------------------------
239# sdk-build.prop
240#
241# There are certain things in build.prop that we don't want to
242# ship with the sdk; remove them.
243
244# This must be a list of entire property keys followed by
245# "=" characters, without any internal spaces.
246sdk_build_prop_remove := \
247 ro.build.user= \
248 ro.build.host= \
249 ro.product.brand= \
250 ro.product.manufacturer= \
251 ro.product.device=
252# TODO: Remove this soon-to-be obsolete property
253sdk_build_prop_remove += ro.build.product=
254INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
255$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
256 @echo SDK buildinfo: $@
257 @mkdir -p $(dir $@)
258 $(hide) grep -v "$(subst $(space),\|,$(strip \
259 $(sdk_build_prop_remove)))" $< > $@.tmp
260 $(hide) for x in $(sdk_build_prop_remove); do \
261 echo "$$x"generic >> $@.tmp; done
262 $(hide) mv $@.tmp $@
263
264# -----------------------------------------------------------------
265# package stats
266PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
267PACKAGES_TO_STAT := \
268 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
269 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
270$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
271 @echo Package stats: $@
272 @mkdir -p $(dir $@)
273 $(hide) rm -f $@
274 $(hide) build/tools/dump-package-stats $^ > $@
275
276.PHONY: package-stats
277package-stats: $(PACKAGE_STATS_FILE)
278
279# -----------------------------------------------------------------
280# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700281# Use a macro to add newline to each echo command
282define _apkcerts_echo_with_newline
283$(hide) echo $(1)
284
285endef
286
The Android Open Source Project88b60792009-03-03 19:28:42 -0800287name := $(TARGET_PRODUCT)
288ifeq ($(TARGET_BUILD_TYPE),debug)
289 name := $(name)_debug
290endif
291name := $(name)-apkcerts-$(FILE_NAME_TAG)
292intermediates := \
293 $(call intermediates-dir-for,PACKAGING,apkcerts)
294APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800295# We don't need to really build all the modules.
296# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700297$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800298 @echo APK certs list: $@
299 @mkdir -p $(dir $@)
300 @rm -f $@
Ying Wangd9a88d52012-10-26 09:21:28 -0700301 $(foreach p,$(PACKAGES),\
302 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
303 $(call _apkcerts_echo_with_newline,\
304 'name="$(p).apk" certificate="EXTERNAL" \
305 private_key=""' >> $@),\
306 $(call _apkcerts_echo_with_newline,\
307 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
308 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@)))
309 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700310 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800311
312.PHONY: apkcerts-list
313apkcerts-list: $(APKCERTS_FILE)
314
Ying Wang15e487a2011-02-15 10:56:18 -0800315ifneq (,$(TARGET_BUILD_APPS))
316 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
317endif
Ying Wangefb21682010-07-23 16:42:13 -0700318
The Android Open Source Project88b60792009-03-03 19:28:42 -0800319# -----------------------------------------------------------------
320# module info file
321ifdef CREATE_MODULE_INFO_FILE
322 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
323 $(info Generating $(MODULE_INFO_FILE)...)
324 $(shell rm -f $(MODULE_INFO_FILE))
325 $(foreach m,$(ALL_MODULES), \
326 $(shell echo "NAME=\"$(m)\"" \
327 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
328 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
329 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
330 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
331endif
332
Doug Zongker8678df42009-06-15 14:30:14 -0700333# -----------------------------------------------------------------
334
Ying Wang3c21fe52011-10-04 10:50:08 -0700335# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700336# for future OTA packages installed by this system. Actual product
337# deliverables will be re-signed by hand. We expect this file to
338# exist with the suffixes ".x509.pem" and ".pk8".
Ying Wang3c21fe52011-10-04 10:50:08 -0700339DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Doug Zongker8678df42009-06-15 14:30:14 -0700340
341
Jeff Browne33ba4c2011-07-11 22:11:46 -0700342# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800343# if they don't do anything.
344.PHONY: systemimage
345systemimage:
346
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800347# -----------------------------------------------------------------
348
349.PHONY: event-log-tags
350
Joe Onoratob7510532010-07-14 10:22:54 -0700351# Produce an event logs tag file for everything we know about, in order
352# to properly allocate numbers. Then produce a file that's filtered
353# for what's going to be installed.
354
355all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
356
Colin Crossdc8f8e42012-04-12 13:25:54 -0700357event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
358
Joe Onoratob7510532010-07-14 10:22:54 -0700359# Include tags from all packages that we know about
360all_event_log_tags_src := \
361 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
362
Colin Crossdc8f8e42012-04-12 13:25:54 -0700363# PDK builds will already have a full list of tags that needs to get merged
364# in with the ones from source
365pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
366
367$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
368$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700369 $(hide) mkdir -p $(dir $@)
370 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
371
Doug Zongkera34fa952011-02-23 12:17:29 -0800372# Include tags from all packages included in this product, plus all
373# tags that are part of the system (ie, not in a vendor/ or device/
374# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800375event_log_tags_src := \
376 $(sort $(foreach m,\
377 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
378 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800379 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
380 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800381
Colin Crossdc8f8e42012-04-12 13:25:54 -0700382$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700383$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossdc8f8e42012-04-12 13:25:54 -0700384$(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 -0800385 $(hide) mkdir -p $(dir $@)
Joe Onoratob7510532010-07-14 10:22:54 -0700386 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800387
388event-log-tags: $(event_log_tags_file)
389
390ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
391
Joe Onoratob7510532010-07-14 10:22:54 -0700392
The Android Open Source Project88b60792009-03-03 19:28:42 -0800393# #################################################################
394# Targets for boot/OS images
395# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800396ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
397 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
398 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
399 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
400 else
401 INSTALLED_2NDBOOTLOADER_TARGET :=
402 endif
403else
404 INSTALLED_BOOTLOADER_MODULE :=
405 INSTALLED_2NDBOOTLOADER_TARGET :=
406endif # TARGET_NO_BOOTLOADER
407ifneq ($(strip $(TARGET_NO_KERNEL)),true)
408 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
409else
410 INSTALLED_KERNEL_TARGET :=
411endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800412
413# -----------------------------------------------------------------
414# the ramdisk
415INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
416 $(ALL_PREBUILT) \
417 $(ALL_COPIED_HEADERS) \
418 $(ALL_GENERATED_SOURCES) \
419 $(ALL_DEFAULT_INSTALLED_MODULES))
420
Joe Onorato64d85d02009-04-09 19:31:12 -0700421BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
422
423# We just build this directly to the install location.
424INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Ying Wang82cceba2012-08-13 15:03:00 -0700425$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800426 $(call pretty,"Target ram disk: $@")
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700427 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800428
Ying Wangad7fd292013-08-08 16:34:29 -0700429.PHONY: ramdisk-nodeps
430ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP)
431 @echo "make $@: ignoring dependencies"
432 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800433
434ifneq ($(strip $(TARGET_NO_KERNEL)),true)
435
436# -----------------------------------------------------------------
437# the boot image, which is a collection of other images.
438INTERNAL_BOOTIMAGE_ARGS := \
439 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
440 --kernel $(INSTALLED_KERNEL_TARGET) \
441 --ramdisk $(INSTALLED_RAMDISK_TARGET)
442
443INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
444
445BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
446ifdef BOARD_KERNEL_CMDLINE
447 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
448endif
449
Dima Zavin1e0847c2009-05-07 19:43:08 -0700450BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
451ifdef BOARD_KERNEL_BASE
452 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
453endif
454
Ying Wangffff0022010-08-23 12:56:25 -0700455BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
456ifdef BOARD_KERNEL_PAGESIZE
457 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
458endif
459
The Android Open Source Project88b60792009-03-03 19:28:42 -0800460INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
461
462ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
463tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
464INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
465INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
466$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
467 $(call pretty,"Target boot image: $@")
468 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
469
Ying Wangad7fd292013-08-08 16:34:29 -0700470.PHONY: bootimage-nodeps
471bootimage-nodeps: $(MKEXT2IMG)
472 @echo "make $@: ignoring dependencies"
473 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
474
Geremy Condra740b6632014-07-08 20:07:41 -0700475else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)) # TARGET_BOOTIMAGE_USE_EXT2 != true
476
477$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
478 $(call pretty,"Target boot image: $@")
479 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
480 $(BOOT_SIGNER) /boot $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY) $@
481 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
482
483.PHONY: bootimage-nodeps
484bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
485 @echo "make $@: ignoring dependencies"
486 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
487 $(BOOT_SIGNER) /boot $(INSTALLED_BOOTIMAGE_TARGET) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY) $(INSTALLED_BOOTIMAGE_TARGET)
488 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
489
490else # PRODUCT_SUPPORTS_VERITY != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800491
492$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
493 $(call pretty,"Target boot image: $@")
Doug Zongkerd5131602012-08-02 14:46:42 -0700494 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700495 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700496
497.PHONY: bootimage-nodeps
498bootimage-nodeps: $(MKBOOTIMG)
499 @echo "make $@: ignoring dependencies"
500 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700501 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700502
The Android Open Source Project88b60792009-03-03 19:28:42 -0800503endif # TARGET_BOOTIMAGE_USE_EXT2
504
505else # TARGET_NO_KERNEL
506# HACK: The top-level targets depend on the bootimage. Not all targets
507# can produce a bootimage, though, and emulator targets need the ramdisk
508# instead. Fake it out by calling the ramdisk the bootimage.
509# TODO: make the emulator use bootimages, and make mkbootimg accept
510# kernel-less inputs.
511INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
512endif
513
514# -----------------------------------------------------------------
515# NOTICE files
516#
Steve Blockd14d3b42012-03-01 11:34:41 +0000517# We are required to publish the licenses for all code under BSD, GPL and
518# Apache licenses (and possibly other more exotic ones as well). We err on the
519# side of caution, so the licenses for other third-party code are included here
520# too.
521#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800522# This needs to be before the systemimage rules, because it adds to
523# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
524# go into the systemimage.
525
Steve Block495e5852012-02-29 19:18:08 +0000526.PHONY: notice_files
527
The Android Open Source Project88b60792009-03-03 19:28:42 -0800528# Create the rule to combine the files into text and html forms
Steve Block495e5852012-02-29 19:18:08 +0000529# $(1) - Plain text output file
530# $(2) - HTML output file
531# $(3) - File title
532# $(4) - Directory to use. Notice files are all $(4)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800533# directories in there will be used for scratch
Steve Block495e5852012-02-29 19:18:08 +0000534# $(5) - Dependencies for the output files
The Android Open Source Project88b60792009-03-03 19:28:42 -0800535#
536# The algorithm here is that we go collect a hash for each of the notice
537# files and write the names of the files that match that hash. Then
538# to generate the real files, we go print out all of the files and their
539# hashes.
540#
541# These rules are fairly complex, so they depend on this makefile so if
542# it changes, they'll run again.
543#
544# TODO: We could clean this up so that we just record the locations of the
545# original notice files instead of making rules to copy them somwehere.
546# Then we could traverse that without quite as much bash drama.
547define combine-notice-files
Steve Block495e5852012-02-29 19:18:08 +0000548$(1) $(2): PRIVATE_MESSAGE := $(3)
Daniel Berlinf5a97d72012-03-29 10:33:19 -0400549$(1) $(2): PRIVATE_DIR := $(4)
Ying Wangc4625ab2012-04-09 12:16:23 -0700550$(1) : $(2)
551$(2) : $(5) $(BUILD_SYSTEM)/Makefile build/tools/generate-notice-files.py
Daniel Berlinf5a97d72012-03-29 10:33:19 -0400552 build/tools/generate-notice-files.py $(1) $(2) $$(PRIVATE_MESSAGE) $$(PRIVATE_DIR)/src
Steve Block495e5852012-02-29 19:18:08 +0000553notice_files: $(1) $(2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800554endef
555
556# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
557# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
558# the src subdirectory.
559
Steve Block495e5852012-02-29 19:18:08 +0000560target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800561target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
562target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
Steve Block495e5852012-02-29 19:18:08 +0000563tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800564tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
565
Ying Wang62c81f82013-08-22 20:02:03 -0700566ifndef TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800567kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
Ying Wang4534d812012-04-09 17:04:12 -0700568pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800569
570$(eval $(call combine-notice-files, \
Steve Block495e5852012-02-29 19:18:08 +0000571 $(target_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800572 $(target_notice_file_html), \
573 "Notices for files contained in the filesystem images in this directory:", \
574 $(TARGET_OUT_NOTICE_FILES), \
Ying Wang4534d812012-04-09 17:04:12 -0700575 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800576
577$(eval $(call combine-notice-files, \
Steve Block495e5852012-02-29 19:18:08 +0000578 $(tools_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800579 $(tools_notice_file_html), \
580 "Notices for files contained in the tools directory:", \
581 $(HOST_OUT_NOTICE_FILES), \
582 $(ALL_DEFAULT_INSTALLED_MODULES)))
583
584# Install the html file at /system/etc/NOTICE.html.gz.
585# This is not ideal, but this is very late in the game, after a lot of
586# the module processing has already been done -- in fact, we used the
587# fact that all that has been done to get the list of modules that we
588# need notice files for.
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700589$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700590 $(hide) $(MINIGZIP) -9 < $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800591installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
592$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
593 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700594
595# if we've been run my mm, mmm, etc, don't reinstall this every time
596ifeq ($(ONE_SHOT_MAKEFILE),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800597ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700598endif
Ying Wang62c81f82013-08-22 20:02:03 -0700599endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800600
601# The kernel isn't really a module, so to get its module file in there, we
602# make the target NOTICE files depend on this particular file too, which will
603# then be in the right directory for the find in combine-notice-files to work.
604$(kernel_notice_file): \
Jean-Baptiste Querua230c4d2012-01-06 15:05:53 -0800605 prebuilts/qemu-kernel/arm/LINUX_KERNEL_COPYING \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800606 | $(ACP)
607 @echo Copying: $@
608 $(hide) mkdir -p $(dir $@)
609 $(hide) $(ACP) $< $@
610
611
Doug Zongker8678df42009-06-15 14:30:14 -0700612# -----------------------------------------------------------------
613# Build a keystore with the authorized keys in it, used to verify the
614# authenticity of downloaded OTA packages.
615#
616# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
617# before the rules that use that variable to build the image.
618ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
619$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Doug Zongker37c0e272009-06-15 15:36:16 -0700620$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Doug Zongker8678df42009-06-15 14:30:14 -0700621 $(hide) rm -f $@
622 $(hide) mkdir -p $(dir $@)
Doug Zongker37c0e272009-06-15 15:36:16 -0700623 $(hide) zip -qj $@ $<
Doug Zongker8678df42009-06-15 14:30:14 -0700624
625.PHONY: otacerts
626otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
627
628
The Android Open Source Project88b60792009-03-03 19:28:42 -0800629# #################################################################
630# Targets for user images
631# #################################################################
632
Ying Wang933abf12010-06-16 14:31:34 -0700633INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800634ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -0700635INTERNAL_USERIMAGES_USE_EXT := true
636INTERNAL_USERIMAGES_EXT_VARIANT := ext2
637else
638ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
639INTERNAL_USERIMAGES_USE_EXT := true
640INTERNAL_USERIMAGES_EXT_VARIANT := ext3
641else
642ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
643INTERNAL_USERIMAGES_USE_EXT := true
644INTERNAL_USERIMAGES_EXT_VARIANT := ext4
645endif
646endif
647endif
648
Ying Wang542903a2010-11-17 15:40:38 -0800649ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
650 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
651endif
652
Colin Cross0a7b2c52010-05-07 02:23:59 -0700653ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
JP Abgrall5bfed5a2014-06-16 14:17:40 -0700654INTERNAL_USERIMAGES_DEPS := $(SIMG2IMG)
655INTERNAL_USERIMAGES_DEPS += $(MKEXTUSERIMG) $(MAKE_EXT4FS) $(E2FSCK)
656ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
657INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG) $(MAKE_F2FS)
658endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800659else
Colin Cross144b0282010-05-10 13:04:47 -0700660INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800661endif
JP Abgrall5bfed5a2014-06-16 14:17:40 -0700662
Ying Wang178ef922011-10-31 18:13:30 -0700663INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800664
Colin Cross8a30f722014-04-28 16:27:32 -0700665ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY))
Colin Cross477cf2b2014-04-16 18:49:56 -0700666INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Geremy Condrafd6f7512013-06-16 17:26:08 -0700667endif
668
Ying Wangfdbd9cb2012-11-21 10:47:00 -0800669SELINUX_FC := $(TARGET_ROOT_OUT)/file_contexts
670INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
671
Ying Wangbd93d422011-10-28 17:02:30 -0700672# $(1): the path of the output dictionary file
Ying Wang6a42a252013-02-27 13:54:02 -0800673# $(2): additional "key=value" pairs to append to the dictionary file.
Ying Wangbd93d422011-10-28 17:02:30 -0700674define generate-userimage-prop-dictionary
675$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
676$(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
JP Abgrall5bfed5a2014-06-16 14:17:40 -0700677$(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -0700678$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wang9f8e8db2011-11-04 11:37:01 -0700679$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
680$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wanga0febe52013-03-20 11:02:05 -0700681$(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
682$(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangb8888432014-03-11 17:13:27 -0700683$(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -0700684$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
685$(if $(mkyaffs2_extra_flags),$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(1))
Ying Wangfdbd9cb2012-11-21 10:47:00 -0800686$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
Daniel Rosenbergf4eabc32014-07-10 15:42:38 -0700687$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)" >> $(1))
Geremy Condra5b5f4952014-05-05 22:19:37 -0700688$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
689$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(VERITY_SIGNER)" >> $(1))
Daniel Rosenbergf4eabc32014-07-10 15:42:38 -0700690$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
691$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
Ying Wang6a42a252013-02-27 13:54:02 -0800692$(if $(2),$(hide) $(foreach kv,$(2),echo "$(kv)" >> $(1);))
Ying Wangbd93d422011-10-28 17:02:30 -0700693endef
694
The Android Open Source Project88b60792009-03-03 19:28:42 -0800695# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -0700696# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700697
698# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
Mike Lockwooddaf5e222012-10-18 10:17:47 -0700699ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700700
Doug Zongker4647f122009-07-02 09:00:54 -0700701INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
702
703recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
Stephen Smalley5520f282014-05-29 16:41:03 -0400704recovery_sepolicy := $(call intermediates-dir-for,ETC,sepolicy.recovery)/sepolicy.recovery
Doug Zongker4647f122009-07-02 09:00:54 -0700705recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
706recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
707recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
708recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
709recovery_resources_common := $(call include-path-for, recovery)/res
Doug Zongkere1297322013-03-06 15:04:31 -0800710
Doug Zongker8eaeea92014-05-12 15:32:20 -0700711# Set recovery_density to the density bucket of the device.
712recovery_density := unknown
713ifneq (,$(PRODUCT_AAPT_PREF_CONFIG))
714# If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value.
715recovery_density := $(filter %dpi,$(PRODUCT_AAPT_PREF_CONFIG))
Doug Zongker25d55f82014-04-04 13:51:15 -0700716else
Doug Zongker8eaeea92014-05-12 15:32:20 -0700717# Otherwise, use the highest density that appears in PRODUCT_AAPT_CONFIG.
718# Order is important here; we'll take the first one that's found.
Joe LaPenna792ab6c2014-07-15 16:51:42 -0700719recovery_densities := $(filter $(PRODUCT_AAPT_CONFIG_SP),xxxhdpi xxhdpi xhdpi hdpi tvdpi mdpi ldpi)
Doug Zongker8eaeea92014-05-12 15:32:20 -0700720ifneq (,$(recovery_densities))
721recovery_density := $(word 1,$(recovery_densities))
722endif
723endif
724
725ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
726recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
727else
Doug Zongker25d55f82014-04-04 13:51:15 -0700728recovery_resources_common := $(recovery_resources_common)-xhdpi
729endif
730
Doug Zongker8eaeea92014-05-12 15:32:20 -0700731# Select the 18x32 font on high-density devices (xhdpi and up); and
732# the 12x22 font on other devices. Note that the font selected here
733# can be overridden for a particular device by putting a font.png in
734# its private recovery resources.
735
736ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Doug Zongkere1297322013-03-06 15:04:31 -0800737recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
738else
739recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
740endif
741
Doug Zongker4647f122009-07-02 09:00:54 -0700742recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
743recovery_resource_deps := $(shell find $(recovery_resources_common) \
744 $(recovery_resources_private) -type f)
Andrew Boiefa61ff02012-09-28 09:33:45 -0700745ifdef TARGET_RECOVERY_FSTAB
746recovery_fstab := $(TARGET_RECOVERY_FSTAB)
747else
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700748recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -0700749endif
Doug Zongker56588872012-08-20 15:38:58 -0700750# Named '.dat' so we don't attempt to use imgdiff for patching it.
751RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
Doug Zongker4647f122009-07-02 09:00:54 -0700752
753ifeq ($(recovery_resources_private),)
754 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
755endif
756
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700757ifeq ($(recovery_fstab),)
758 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
759endif
760
Doug Zongker4647f122009-07-02 09:00:54 -0700761INTERNAL_RECOVERYIMAGE_ARGS := \
762 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
763 --kernel $(recovery_kernel) \
764 --ramdisk $(recovery_ramdisk)
765
766# Assumes this has already been stripped
767ifdef BOARD_KERNEL_CMDLINE
768 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
769endif
770ifdef BOARD_KERNEL_BASE
771 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
772endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700773BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
774ifdef BOARD_KERNEL_PAGESIZE
775 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
776endif
Doug Zongker4647f122009-07-02 09:00:54 -0700777
778# Keys authorized to sign OTA packages this build will accept. The
Ying Wang3c21fe52011-10-04 10:50:08 -0700779# build always uses dev-keys for this; release packaging tools will
Doug Zongker4647f122009-07-02 09:00:54 -0700780# substitute other keys for this one.
Ying Wang3c21fe52011-10-04 10:50:08 -0700781OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem
Doug Zongker4647f122009-07-02 09:00:54 -0700782
783# Generate a file containing the keys that will be read by the
784# recovery binary.
785RECOVERY_INSTALL_OTA_KEYS := \
786 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
787DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
788$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
Doug Zongker5d4808d2011-03-16 07:49:13 -0700789$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
Doug Zongkere121d6a2011-02-01 14:13:52 -0800790$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys)
791 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
Doug Zongker4647f122009-07-02 09:00:54 -0700792 @rm -rf $@
793 @mkdir -p $(dir $@)
Doug Zongkere121d6a2011-02-01 14:13:52 -0800794 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
Doug Zongker4647f122009-07-02 09:00:54 -0700795
796$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
797 $(INSTALLED_RAMDISK_TARGET) \
798 $(INSTALLED_BOOTIMAGE_TARGET) \
799 $(recovery_binary) \
Stephen Smalley5520f282014-05-29 16:41:03 -0400800 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
Doug Zongker4647f122009-07-02 09:00:54 -0700801 $(INSTALLED_2NDBOOTLOADER_TARGET) \
802 $(recovery_build_prop) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700803 $(recovery_fstab) \
Doug Zongker4647f122009-07-02 09:00:54 -0700804 $(RECOVERY_INSTALL_OTA_KEYS)
805 @echo ----- Making recovery image ------
Doug Zongker72f0b672012-08-08 16:26:17 -0700806 $(hide) rm -rf $(TARGET_RECOVERY_OUT)
807 $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
808 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/tmp
809 @echo Copying baseline ramdisk...
810 $(hide) cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
811 @echo Modifying ramdisk contents...
812 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
813 $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
Stephen Smalley5520f282014-05-29 16:41:03 -0400814 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/sepolicy
815 $(hide) cp -f $(recovery_sepolicy) $(TARGET_RECOVERY_ROOT_OUT)/sepolicy
Doug Zongker72f0b672012-08-08 16:26:17 -0700816 $(hide) -cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/
817 $(hide) cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
Doug Zongker25d55f82014-04-04 13:51:15 -0700818 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
819 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
820 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
Doug Zongkere1297322013-03-06 15:04:31 -0800821 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
Doug Zongker72f0b672012-08-08 16:26:17 -0700822 $(hide) $(foreach item,$(recovery_resources_private), \
Doug Zongker4647f122009-07-02 09:00:54 -0700823 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
Doug Zongker72f0b672012-08-08 16:26:17 -0700824 $(hide) $(foreach item,$(recovery_fstab), \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700825 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Doug Zongker72f0b672012-08-08 16:26:17 -0700826 $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
827 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
Doug Zongker4647f122009-07-02 09:00:54 -0700828 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Doug Zongker72f0b672012-08-08 16:26:17 -0700829 $(hide) $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
830 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700831 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))
Doug Zongker72f0b672012-08-08 16:26:17 -0700832 @echo ----- Made recovery image: $@ --------
Doug Zongker4647f122009-07-02 09:00:54 -0700833
Doug Zongker56588872012-08-20 15:38:58 -0700834$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
Doug Zongker1a097262012-09-04 14:45:11 -0700835 $(hide) mkdir -p $(dir $@)
Doug Zongker56588872012-08-20 15:38:58 -0700836 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@
837
Doug Zongker4647f122009-07-02 09:00:54 -0700838else
839INSTALLED_RECOVERYIMAGE_TARGET :=
Doug Zongker56588872012-08-20 15:38:58 -0700840RECOVERY_RESOURCE_ZIP :=
Doug Zongker4647f122009-07-02 09:00:54 -0700841endif
842
843.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -0700844recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -0700845
Dima Zavin11818982010-02-05 13:34:34 -0800846ifneq ($(BOARD_NAND_PAGE_SIZE),)
847mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
848else
849mkyaffs2_extra_flags :=
Lars Svensson9cb8c282010-12-06 15:24:58 +0100850BOARD_NAND_PAGE_SIZE := 2048
Dima Zavin11818982010-02-05 13:34:34 -0800851endif
852
Naseer Ahmed53871882010-08-06 12:19:29 -0700853ifneq ($(BOARD_NAND_SPARE_SIZE),)
854mkyaffs2_extra_flags += -s $(BOARD_NAND_SPARE_SIZE)
Lars Svensson9cb8c282010-12-06 15:24:58 +0100855else
856BOARD_NAND_SPARE_SIZE := 64
Naseer Ahmed53871882010-08-06 12:19:29 -0700857endif
858
Doug Zongker4647f122009-07-02 09:00:54 -0700859# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -0700860# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800861#
Ying Wang9c649a72012-08-08 15:27:00 -0700862# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
863PDK_FUSION_SYSIMG_FILES := \
864 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
865 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800866
867INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -0700868 $(ALL_PREBUILT) \
869 $(ALL_COPIED_HEADERS) \
870 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -0700871 $(ALL_DEFAULT_INSTALLED_MODULES) \
872 $(PDK_FUSION_SYSIMG_FILES) \
873 $(RECOVERY_RESOURCE_ZIP))
Ying Wang160b6702012-03-13 18:58:27 -0700874
Ying Wang82cceba2012-08-13 15:03:00 -0700875FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Ying Wange5e8c5f2011-09-09 16:35:53 -0700876# -----------------------------------------------------------------
877# installed file list
878# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
879# We put installed-files.txt ahead of image itself in the dependency graph
880# so that we can get the size stat even if the build fails due to too large
881# system image.
882INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
883$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS)
884 @echo Installed file list: $@
885 @mkdir -p $(dir $@)
886 @rm -f $@
887 $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@
888
889.PHONY: installed-file-list
890installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -0800891
892$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -0700893
894systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -0700895 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -0700896BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
897
Ying Wang23898df2014-06-18 20:26:24 -0700898# Create symlink /system/vendor to /vendor if necessary.
899ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
900define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -0700901$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
902 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
903 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
904 exit 1; \
905fi
Ying Wang23898df2014-06-18 20:26:24 -0700906$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
907endef
908else
909define create-system-vendor-symlink
910endef
911endif
912
The Android Open Source Project88b60792009-03-03 19:28:42 -0800913# $(1): output file
914define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -0700915 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -0700916 $(call create-system-vendor-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -0700917 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Geremy Condrafd6f7512013-06-16 17:26:08 -0700918 $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt, \
Geremy Condra5b5f4952014-05-05 22:19:37 -0700919 skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -0700920 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
921 ./build/tools/releasetools/build_image.py \
922 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800923endef
924
Ying Wange5e8c5f2011-09-09 16:35:53 -0700925$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800926 $(call build-systemimage-target,$@)
927
The Android Open Source Project88b60792009-03-03 19:28:42 -0800928INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700929SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800930
Doug Zongker73ef8252009-07-23 15:12:53 -0700931# The system partition needs room for the recovery image as well. We
932# now store the recovery image as a binary patch using the boot image
933# as the source (since they are very similar). Generate the patch so
934# we can see how big it's going to be, and include that in the system
935# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700936ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700937intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
938RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
939$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
940 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700941 $(HOST_OUT_EXECUTABLES)/imgdiff \
942 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700943 @echo "Construct recovery from boot"
944 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700945 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700946endif
947
Doug Zongker73ef8252009-07-23 15:12:53 -0700948
949$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800950 @echo "Install system fs image: $@"
951 $(copy-file-to-target)
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700952 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800953
954systemimage: $(INSTALLED_SYSTEMIMAGE)
955
956.PHONY: systemimage-nodeps snod
957systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -0700958 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800959 @echo "make $@: ignoring dependencies"
960 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700961 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800962
Ying Wangacf01ec2012-02-24 11:05:48 -0800963ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
964ifeq (true,$(WITH_DEXPREOPT))
965$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
966endif
967endif
968
The Android Open Source Project88b60792009-03-03 19:28:42 -0800969#######
970## system tarball
971define build-systemtarball-target
Ying Wang23898df2014-06-18 20:26:24 -0700972 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
973 $(call create-system-vendor-symlink)
974 $(MKTARBALL) $(FS_GET_STATS) \
975 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
976 $(INSTALLED_SYSTEMTARBALL_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800977endef
978
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700979ifndef SYSTEM_TARBALL_FORMAT
980 SYSTEM_TARBALL_FORMAT := bz2
981endif
982
The Android Open Source Project88b60792009-03-03 19:28:42 -0800983system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700984INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800985$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
986$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
987 $(build-systemtarball-target)
988
989.PHONY: systemtarball-nodeps
990systemtarball-nodeps: $(FS_GET_STATS) \
991 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
992 $(build-systemtarball-target)
993
994.PHONY: stnod
995stnod: systemtarball-nodeps
996
Ying Wang4c289e52012-03-30 13:52:54 -0700997#######
Ying Wang4534d812012-04-09 17:04:12 -0700998## platform.zip: system, plus other files to be used in PDK fusion build,
999## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07001000##
1001## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
1002## The variable will be typically set from BoardConfig.mk.
1003## Files under out dir will be rejected to prevent possible conflicts with other rules.
1004PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07001005INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
1006$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES)
1007 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Ying Wang4c289e52012-03-30 13:52:54 -07001008 $(hide) rm -f $@
Ying Wang4534d812012-04-09 17:04:12 -07001009 $(hide) cd $(dir $@) && zip -qry $(notdir $@) \
1010 $(TARGET_COPY_OUT_SYSTEM) \
Keun young Park72226692012-07-31 17:13:20 -07001011 $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \
1012 $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST))
Ying Wangcff38622014-07-16 17:46:35 -07001013ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1014 $(hide) cd $(dir $@) && zip -qry $(notdir $@) \
1015 $(TARGET_COPY_OUT_VENDOR)
1016endif
Colin Crossc451a372013-12-18 19:36:44 -08001017ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Ying Wang28a18172012-06-02 09:22:31 -07001018 $(hide) cd $(OUT_DIR) && zip -qry $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
Keun young Park816b9fd2012-05-16 10:32:41 -07001019endif
keunyoungc0178062013-07-22 14:54:58 -07001020ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
1021 $(hide) zip -qry $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
1022endif
Ying Wang4c289e52012-03-30 13:52:54 -07001023
1024.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07001025platform: $(INSTALLED_PLATFORM_ZIP)
1026
1027.PHONY: platform-java
1028platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07001029
1030# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07001031ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
1032$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07001033endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001034
Bruce Beare52aac202010-06-04 15:24:49 -07001035#######
1036## boot tarball
1037define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -07001038 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -07001039 $(hide) mkdir -p $(PRODUCT_OUT)/boot
1040 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
1041 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
1042 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
1043 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
1044 $(INSTALLED_BOOTTARBALL_TARGET)
1045endef
1046
1047ifndef BOOT_TARBALL_FORMAT
1048 BOOT_TARBALL_FORMAT := bz2
1049endif
1050
1051boot_tar := $(PRODUCT_OUT)/boot.tar
1052INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
1053$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
1054$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
1055 $(build-boottarball-target)
1056
1057.PHONY: boottarball-nodeps btnod
1058boottarball-nodeps btnod: $(FS_GET_STATS) \
1059 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
1060 $(build-boottarball-target)
1061
1062
The Android Open Source Project88b60792009-03-03 19:28:42 -08001063# -----------------------------------------------------------------
1064# data partition image
1065INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001066 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001067
Ying Wangd7321d32013-03-15 10:32:29 -07001068# Don't build userdata.img if it's extfs but no partition size
1069skip_userdata.img :=
1070ifdef INTERNAL_USERIMAGES_EXT_VARIANT
1071ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE
1072skip_userdata.img := true
1073endif
1074endif
1075
1076ifneq ($(skip_userdata.img),true)
Ying Wangbd93d422011-10-28 17:02:30 -07001077userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001078 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07001079BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
1080
Ying Wangbd93d422011-10-28 17:02:30 -07001081define build-userdataimage-target
1082 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
1083 @mkdir -p $(TARGET_OUT_DATA)
1084 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001085 $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt, skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07001086 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1087 ./build/tools/releasetools/build_image.py \
Ying Wang178ef922011-10-31 18:13:30 -07001088 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001089 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07001090endef
1091
Joe Onorato64d85d02009-04-09 19:31:12 -07001092# We just build this directly to the install location.
1093INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -07001094$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001095 $(INTERNAL_USERDATAIMAGE_FILES)
1096 $(build-userdataimage-target)
1097
1098.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07001099userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001100 $(build-userdataimage-target)
1101
Ying Wangd7321d32013-03-15 10:32:29 -07001102endif # not skip_userdata.img
1103skip_userdata.img :=
Ying Wange215ed52012-10-15 14:36:22 -07001104
The Android Open Source Project88b60792009-03-03 19:28:42 -08001105#######
1106## data partition tarball
1107define build-userdatatarball-target
1108 $(call pretty,"Target userdata fs tarball: " \
1109 "$(INSTALLED_USERDATATARBALL_TARGET)")
1110 $(MKTARBALL) $(FS_GET_STATS) \
1111 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
1112 $(INSTALLED_USERDATATARBALL_TARGET)
1113endef
1114
1115userdata_tar := $(PRODUCT_OUT)/userdata.tar
1116INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
1117$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
1118$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
1119 $(build-userdatatarball-target)
1120
1121.PHONY: userdatatarball-nodeps
1122userdatatarball-nodeps: $(FS_GET_STATS)
1123 $(build-userdatatarball-target)
1124
1125
The Android Open Source Project88b60792009-03-03 19:28:42 -08001126# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07001127# cache partition image
1128ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1129INTERNAL_CACHEIMAGE_FILES := \
1130 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
1131
1132cacheimage_intermediates := \
1133 $(call intermediates-dir-for,PACKAGING,cache)
1134BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
1135
1136define build-cacheimage-target
1137 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
1138 @mkdir -p $(TARGET_OUT_CACHE)
1139 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001140 $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt, skip_fsck=true)
Ying Wang9f8e8db2011-11-04 11:37:01 -07001141 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1142 ./build/tools/releasetools/build_image.py \
1143 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001144 $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07001145endef
1146
1147# We just build this directly to the install location.
1148INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
1149$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
1150 $(build-cacheimage-target)
1151
1152.PHONY: cacheimage-nodeps
1153cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1154 $(build-cacheimage-target)
1155
1156endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1157
Ying Wanga0febe52013-03-20 11:02:05 -07001158
1159# -----------------------------------------------------------------
1160# vendor partition image
1161ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1162INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07001163 $(filter $(TARGET_OUT_VENDOR)/%,\
1164 $(ALL_DEFAULT_INSTALLED_MODULES)\
1165 $(ALL_PDK_FUSION_FILES))
1166
1167# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
1168$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07001169
1170vendorimage_intermediates := \
1171 $(call intermediates-dir-for,PACKAGING,vendor)
1172BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
1173
1174define build-vendorimage-target
1175 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
1176 @mkdir -p $(TARGET_OUT_VENDOR)
1177 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
1178 $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true)
1179 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1180 ./build/tools/releasetools/build_image.py \
1181 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001182 $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07001183endef
1184
1185# We just build this directly to the install location.
1186INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
1187$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES)
1188 $(build-vendorimage-target)
1189
1190.PHONY: vendorimage-nodeps
1191vendorimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1192 $(build-vendorimage-target)
1193
1194endif # BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1195
Ying Wang9f8e8db2011-11-04 11:37:01 -07001196# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001197# bring in the installer image generation defines if necessary
1198ifeq ($(TARGET_USE_DISKINSTALLER),true)
1199include bootable/diskinstaller/config.mk
1200endif
1201
1202# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07001203# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08001204
Colin Crossc312f312012-04-19 13:54:39 -07001205DISTTOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -07001206 $(HOST_OUT_EXECUTABLES)/mkbootfs \
1207 $(HOST_OUT_EXECUTABLES)/mkbootimg \
1208 $(HOST_OUT_EXECUTABLES)/fs_config \
1209 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
1210 $(HOST_OUT_EXECUTABLES)/zipalign \
Doug Zongker8678df42009-06-15 14:30:14 -07001211 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -07001212 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -07001213 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -07001214 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
1215 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
Ying Wang7dc45a82013-01-04 14:43:18 -08001216 $(HOST_OUT_EXECUTABLES)/make_ext4fs \
1217 $(HOST_OUT_EXECUTABLES)/simg2img \
Doug Zongker5fad2032014-02-24 08:13:45 -08001218 $(HOST_OUT_EXECUTABLES)/e2fsck \
Doug Zongker32b527d2014-03-04 10:03:02 -08001219 $(HOST_OUT_EXECUTABLES)/xdelta3 \
Doug Zongker9843fd82014-05-13 14:17:13 -07001220 $(HOST_OUT_EXECUTABLES)/syspatch_host \
1221 $(HOST_OUT_EXECUTABLES)/build_verity_tree \
1222 $(HOST_OUT_EXECUTABLES)/verity_signer \
Geremy Condra740b6632014-07-08 20:07:41 -07001223 $(HOST_OUT_EXECUTABLES)/append2simg \
1224 $(HOST_OUT_EXECUTABLES)/boot_signer
The Android Open Source Project88b60792009-03-03 19:28:42 -08001225
Colin Crossc312f312012-04-19 13:54:39 -07001226OTATOOLS := $(DISTTOOLS) \
1227 $(HOST_OUT_EXECUTABLES)/aapt
1228
Ying Wang06898662010-06-17 17:52:18 -07001229.PHONY: otatools
1230otatools: $(OTATOOLS)
1231
The Android Open Source Project88b60792009-03-03 19:28:42 -08001232# -----------------------------------------------------------------
1233# A zip of the directories that map to the target filesystem.
1234# This zip can be used to create an OTA package or filesystem image
1235# as a post-build step.
1236#
1237name := $(TARGET_PRODUCT)
1238ifeq ($(TARGET_BUILD_TYPE),debug)
1239 name := $(name)_debug
1240endif
1241name := $(name)-target_files-$(FILE_NAME_TAG)
1242
1243intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
1244BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
1245$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
1246$(BUILT_TARGET_FILES_PACKAGE): \
1247 zip_root := $(intermediates)/$(name)
1248
1249# $(1): Directory to copy
1250# $(2): Location to copy it to
1251# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
1252define package_files-copy-root
1253 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
1254 mkdir -p $(2) && \
1255 $(ACP) -rd $(strip $(1))/* $(2); \
1256 fi
1257endef
1258
1259built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -07001260 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -07001261 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001262 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
Doug Zongker25863d72011-09-19 15:02:03 -07001263 $(call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001264 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -08001265$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
1266
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001267$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
Ken Sumrall31ce31f2013-02-21 16:27:25 -08001268$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION)
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001269
Doug Zongkerc18736b2009-09-30 09:20:32 -07001270ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1271# default to common dir for device vendor
1272$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
1273else
1274$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1275endif
1276
The Android Open Source Project88b60792009-03-03 19:28:42 -08001277# Depending on the various images guarantees that the underlying
1278# directories are up-to-date.
1279$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001280 $(INSTALLED_BOOTIMAGE_TARGET) \
1281 $(INSTALLED_RADIOIMAGE_TARGET) \
1282 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -07001283 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001284 $(INSTALLED_USERDATAIMAGE_TARGET) \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001285 $(INSTALLED_CACHEIMAGE_TARGET) \
Ying Wanga0febe52013-03-20 11:02:05 -07001286 $(INSTALLED_VENDORIMAGE_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001287 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001288 $(SELINUX_FC) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001289 $(built_ota_tools) \
1290 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -07001291 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001292 | $(ACP)
1293 @echo "Package target files: $@"
1294 $(hide) rm -rf $@ $(zip_root)
1295 $(hide) mkdir -p $(dir $@) $(zip_root)
1296 @# Components of the recovery image
1297 $(hide) mkdir -p $(zip_root)/RECOVERY
1298 $(hide) $(call package_files-copy-root, \
1299 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
1300ifdef INSTALLED_KERNEL_TARGET
1301 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
1302endif
1303ifdef INSTALLED_2NDBOOTLOADER_TARGET
1304 $(hide) $(ACP) \
1305 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
1306endif
1307ifdef BOARD_KERNEL_CMDLINE
1308 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
1309endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001310ifdef BOARD_KERNEL_BASE
1311 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
1312endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001313ifdef BOARD_KERNEL_PAGESIZE
1314 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
1315endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001316 @# Components of the boot image
1317 $(hide) mkdir -p $(zip_root)/BOOT
1318 $(hide) $(call package_files-copy-root, \
1319 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1320ifdef INSTALLED_KERNEL_TARGET
1321 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1322endif
1323ifdef INSTALLED_2NDBOOTLOADER_TARGET
1324 $(hide) $(ACP) \
1325 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1326endif
1327ifdef BOARD_KERNEL_CMDLINE
1328 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1329endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001330ifdef BOARD_KERNEL_BASE
1331 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1332endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001333ifdef BOARD_KERNEL_PAGESIZE
1334 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1335endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001336 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1337 mkdir -p $(zip_root)/RADIO; \
1338 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001339 @# Contents of the system image
1340 $(hide) $(call package_files-copy-root, \
1341 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1342 @# Contents of the data image
1343 $(hide) $(call package_files-copy-root, \
1344 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Ying Wanga0febe52013-03-20 11:02:05 -07001345ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1346 @# Contents of the vendor image
1347 $(hide) $(call package_files-copy-root, \
1348 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
1349endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001350 @# Extra contents of the OTA package
1351 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001352 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1353 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001354 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001355 @# build them.
1356 $(hide) mkdir -p $(zip_root)/META
1357 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker816d73f2013-11-22 13:29:55 -08001358 $(hide) if test -e $(tool_extensions)/releasetools.py; then $(ACP) $(tool_extensions)/releasetools.py $(zip_root)/META/; fi
Doug Zongker17c83cf2009-04-01 15:48:46 -07001359 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -07001360 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Ken Sumrall31ce31f2013-02-21 16:27:25 -08001361 $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001362ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07001363 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001364endif
1365ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001366 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001367endif
1368ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001369 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001370endif
Doug Zongker37974732010-09-16 17:44:38 -07001371 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wang3c21fe52011-10-04 10:50:08 -07001372 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
Doug Zongker5d4808d2011-03-16 07:49:13 -07001373ifdef PRODUCT_EXTRA_RECOVERY_KEYS
1374 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
Doug Zongkere121d6a2011-02-01 14:13:52 -08001375endif
Jianxun Zhang09849492013-04-17 15:19:19 -07001376 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001377 $(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt
Doug Zongker9b23f2c2013-11-25 14:44:12 -08001378 $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
Michael Rungefacd9922013-12-20 11:50:16 -08001379 $(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt
Jeff Sharkey26e1a282014-03-21 16:20:05 -07001380ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),)
1381 # OTA scripts are only interested in fingerprint related properties
1382 $(hide) echo "oem_fingerprint_properties=$(filter ro.product.brand ro.product.name ro.product.device, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES))" >> $(zip_root)/META/misc_info.txt
1383endif
Ying Wangbd93d422011-10-28 17:02:30 -07001384 $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
Doug Zongkerc9253822014-02-04 12:17:58 -08001385 $(hide) ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001386 @# Zip everything up, preserving symlinks
1387 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongkerc8b4e842014-06-16 15:16:31 -07001388 @# Run fs_config on all the system, vendor, boot ramdisk,
1389 @# and recovery ramdisk files in the zip, and save the output
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001390 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/filesystem_config.txt
Doug Zongkerc8b4e842014-06-16 15:16:31 -07001391 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="VENDOR/" } /^VENDOR\// {print "vendor/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/vendor_filesystem_config.txt
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001392 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt
1393 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt
Doug Zongker23f8bde2011-09-07 14:11:51 -07001394 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
Doug Zongker283e2a12010-03-15 17:52:32 -07001395
Ying Wanga0febe52013-03-20 11:02:05 -07001396.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001397target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1398
Ying Wang4709d7c2014-04-14 17:25:43 -07001399ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
1400$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
1401endif
Doug Zongker367910f2009-06-15 18:56:51 -07001402
Doug Zongker367910f2009-06-15 18:56:51 -07001403ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang279f3082011-02-09 12:26:42 -08001404ifeq ($(filter generic%,$(TARGET_DEVICE)),)
Ying Wangfb0a3472010-08-25 16:06:06 -07001405ifneq ($(TARGET_NO_KERNEL),true)
Ying Wanga73b6562011-03-03 21:52:08 -08001406ifneq ($(recovery_fstab),)
Doug Zongker367910f2009-06-15 18:56:51 -07001407
Ying Wang09a00a62010-10-20 14:01:09 -07001408# -----------------------------------------------------------------
1409# OTA update package
1410
Doug Zongker8678df42009-06-15 14:30:14 -07001411name := $(TARGET_PRODUCT)
1412ifeq ($(TARGET_BUILD_TYPE),debug)
1413 name := $(name)_debug
1414endif
1415name := $(name)-ota-$(FILE_NAME_TAG)
1416
1417INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1418
1419$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1420
Ying Wang82cceba2012-08-13 15:03:00 -07001421$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001422 @echo "Package OTA: $@"
Ying Wang42c98042014-06-18 11:31:21 -07001423 $(hide) MKBOOTIMG=$(MKBOOTIMG) \
Bjorn Andersson612e2cd2012-11-25 16:53:44 -08001424 ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker26e66192014-02-20 13:22:07 -08001425 --block \
Doug Zongker602a84e2009-06-18 08:35:12 -07001426 -p $(HOST_OUT) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05001427 -k $(KEY_CERT_PAIR) \
Michael Runge6e836112014-04-15 17:40:21 -07001428 $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05001429 $(BUILT_TARGET_FILES_PACKAGE) $@
Doug Zongker8678df42009-06-15 14:30:14 -07001430
1431.PHONY: otapackage
1432otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1433
Ying Wangf8824af2014-06-03 14:07:27 -07001434endif # recovery_fstab is defined
1435endif # TARGET_NO_KERNEL != true
1436endif # TARGET_DEVICE != generic*
1437endif # TARGET_PRODUCT != sdk
1438
Ying Wang09a00a62010-10-20 14:01:09 -07001439# -----------------------------------------------------------------
1440# The update package
1441
1442name := $(TARGET_PRODUCT)
1443ifeq ($(TARGET_BUILD_TYPE),debug)
1444 name := $(name)_debug
1445endif
1446name := $(name)-img-$(FILE_NAME_TAG)
1447
1448INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1449
Ying Wang82cceba2012-08-13 15:03:00 -07001450$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
Ying Wang09a00a62010-10-20 14:01:09 -07001451 @echo "Package: $@"
Ying Wang42c98042014-06-18 11:31:21 -07001452 $(hide) MKBOOTIMG=$(MKBOOTIMG) \
Bjorn Andersson612e2cd2012-11-25 16:53:44 -08001453 ./build/tools/releasetools/img_from_target_files -v \
Ying Wang09a00a62010-10-20 14:01:09 -07001454 -p $(HOST_OUT) \
1455 $(BUILT_TARGET_FILES_PACKAGE) $@
1456
1457.PHONY: updatepackage
1458updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
1459
The Android Open Source Project88b60792009-03-03 19:28:42 -08001460# -----------------------------------------------------------------
1461# A zip of the symbols directory. Keep the full paths to make it
1462# more obvious where these files came from.
1463#
1464name := $(TARGET_PRODUCT)
1465ifeq ($(TARGET_BUILD_TYPE),debug)
1466 name := $(name)_debug
1467endif
1468name := $(name)-symbols-$(FILE_NAME_TAG)
1469
1470SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1471$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1472 @echo "Package symbols: $@"
1473 $(hide) rm -rf $@
1474 $(hide) mkdir -p $(dir $@)
1475 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1476
1477# -----------------------------------------------------------------
1478# A zip of the Android Apps. Not keeping full path so that we don't
1479# include product names when distributing
1480#
1481name := $(TARGET_PRODUCT)
1482ifeq ($(TARGET_BUILD_TYPE),debug)
1483 name := $(name)_debug
1484endif
1485name := $(name)-apps-$(FILE_NAME_TAG)
1486
1487APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1488$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1489 @echo "Package apps: $@"
1490 $(hide) rm -rf $@
1491 $(hide) mkdir -p $(dir $@)
Ying Wang2ce3d5c2014-07-18 19:15:15 -07001492 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*/*.apk $(TARGET_OUT_APPS_PRIVILEGED)/*/*.apk
The Android Open Source Project88b60792009-03-03 19:28:42 -08001493
Guang Zhu0198d6e2010-04-23 11:54:37 -07001494
1495#------------------------------------------------------------------
1496# A zip of emma code coverage meta files. Generated for fully emma
1497# instrumented build.
1498#
Ying Wangbc415dd2012-08-15 12:22:44 -07001499ifeq (true,$(EMMA_INSTRUMENT))
Guang Zhu0198d6e2010-04-23 11:54:37 -07001500EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
Ying Wangbc415dd2012-08-15 12:22:44 -07001501# the dependency will be set up later in build/core/main.mk.
1502$(EMMA_META_ZIP) :
Guang Zhu0198d6e2010-04-23 11:54:37 -07001503 @echo "Collecting Emma coverage meta files."
Ying Wang1ff08362013-12-27 15:55:08 -08001504 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "coverage.em" | \
Guang Zhu0198d6e2010-04-23 11:54:37 -07001505 zip -@ -q $@
1506
Ying Wangbc415dd2012-08-15 12:22:44 -07001507endif # EMMA_INSTRUMENT=true
1508
Ying Wangae9115a2013-08-22 20:52:47 -07001509#------------------------------------------------------------------
1510# A zip of Proguard obfuscation dictionary files.
1511# Only for apps_only build.
1512#
1513ifdef TARGET_BUILD_APPS
Ying Wangc62c92c2013-08-28 18:38:25 -07001514PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Ying Wangae9115a2013-08-22 20:52:47 -07001515# the dependency will be set up later in build/core/main.mk.
1516$(PROGUARD_DICT_ZIP) :
1517 @echo "Packaging Proguard obfuscation dictionary files."
1518 $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary`; \
1519 if [ -n "$$dict_files" ]; then \
Ying Wang33d64592013-11-25 17:39:50 -08001520 unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \
1521 zip -q $@ $$dict_files $$unobfuscated_jars; \
Ying Wangae9115a2013-08-22 20:52:47 -07001522 else \
Ying Wangc62c92c2013-08-28 18:38:25 -07001523 touch $(dir $@)/dummy; \
1524 (cd $(dir $@) && zip -q $(notdir $@) dummy); \
1525 zip -qd $@ dummy; \
1526 rm $(dir $@)/dummy; \
Ying Wangae9115a2013-08-22 20:52:47 -07001527 fi
1528
1529endif # TARGET_BUILD_APPS
1530
The Android Open Source Project88b60792009-03-03 19:28:42 -08001531# -----------------------------------------------------------------
1532# dalvik something
1533.PHONY: dalvikfiles
1534dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1535
1536# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001537# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07001538ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001539INTERNAL_EMULATOR_PACKAGE_FILES += \
1540 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08001541 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001542 $(INSTALLED_RAMDISK_TARGET) \
1543 $(INSTALLED_SYSTEMIMAGE) \
1544 $(INSTALLED_USERDATAIMAGE_TARGET)
1545
1546name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1547
1548INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1549
1550$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1551 @echo "Package: $@"
1552 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1553
Ying Wang7d8c5352012-07-26 10:15:21 -07001554endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001555# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08001556# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08001557# The pdk package (Platform Development Kit)
1558
Keun young Park7fc7aad2012-02-27 15:49:23 -08001559#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1560# include development/pdk/Pdk.mk
1561#endif
1562
The Android Open Source Project88b60792009-03-03 19:28:42 -08001563
1564# -----------------------------------------------------------------
1565# The SDK
1566
The Android Open Source Project88b60792009-03-03 19:28:42 -08001567# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07001568sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001569
1570# Build a name that looks like:
1571#
1572# linux-x86 --> android-sdk_12345_linux-x86
1573# darwin-x86 --> android-sdk_12345_mac-x86
1574# windows-x86 --> android-sdk_12345_windows
1575#
1576sdk_name := android-sdk_$(FILE_NAME_TAG)
1577ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001578 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001579else
Joe Onorato03fbe402009-04-13 08:31:16 -07001580 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001581endif
1582ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07001583 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001584endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001585sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001586
1587sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1588
1589ATREE_FILES :=
1590-include $(sdk_dep_file)
1591
1592# if we don't have a real list, then use "everything"
1593ifeq ($(strip $(ATREE_FILES)),)
1594ATREE_FILES := \
1595 $(ALL_PREBUILT) \
1596 $(ALL_COPIED_HEADERS) \
1597 $(ALL_GENERATED_SOURCES) \
1598 $(ALL_DEFAULT_INSTALLED_MODULES) \
1599 $(INSTALLED_RAMDISK_TARGET) \
1600 $(ALL_DOCS) \
1601 $(ALL_SDK_FILES)
1602endif
1603
1604atree_dir := development/build
1605
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001606
The Android Open Source Project88b60792009-03-03 19:28:42 -08001607sdk_atree_files := \
1608 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07001609 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08001610
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02001611# development/build/sdk-android-<abi>.atree is used to differentiate
1612# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
1613# files like the kernel image. We use TARGET_CPU_ABI because we don't
1614# have a better way to distinguish between CPU models.
1615ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
1616 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
1617endif
1618
Griff Hazen433febb2014-02-28 08:45:59 -08001619ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),)
1620sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES)
1621else
1622sdk_atree_files += $(atree_dir)/sdk.atree
1623endif
1624
The Android Open Source Project88b60792009-03-03 19:28:42 -08001625deps := \
1626 $(target_notice_file_txt) \
1627 $(tools_notice_file_txt) \
1628 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001629 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001630 $(INSTALLED_SYSTEMIMAGE) \
1631 $(INSTALLED_USERDATAIMAGE_TARGET) \
1632 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001633 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001634 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001635 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08001636 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001637 $(HOST_OUT_EXECUTABLES)/atree \
Joe Onorato63d56da2012-08-17 04:19:38 -07001638 $(HOST_OUT_EXECUTABLES)/line_endings
The Android Open Source Project88b60792009-03-03 19:28:42 -08001639
1640INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1641$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1642$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1643$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1644$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1645
Deepanshu Gupta887cd0c2014-05-27 18:07:49 -07001646sdk_font_temp_dir := $(call intermediates-dir-for,PACKAGING,sdk-fonts)
1647sdk_font_input_list := frameworks/base/data/fonts external/noto-fonts external/google-fonts external/naver-fonts
1648sdk_font_rename_script := frameworks/base/tools/layoutlib/rename_font/build_font.py
1649
The Android Open Source Project88b60792009-03-03 19:28:42 -08001650# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1651#
1652#SDK_GNU_ERROR := true
1653
1654$(INTERNAL_SDK_TARGET): $(deps)
1655 @echo "Package SDK: $@"
1656 $(hide) rm -rf $(PRIVATE_DIR) $@
1657 $(hide) for f in $(target_gnu_MODULES); do \
1658 if [ -f $$f ]; then \
1659 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1660 including GNU target $$f >&2; \
1661 FAIL=$(SDK_GNU_ERROR); \
1662 fi; \
1663 done; \
1664 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta887cd0c2014-05-27 18:07:49 -07001665 $(hide) mkdir -p $(sdk_font_temp_dir)
1666 $(hide) PYTHONPATH=$$PYTHONPATH:external/fonttools/Lib $(sdk_font_rename_script) $(sdk_font_input_list) \
1667 $(sdk_font_temp_dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001668 $(hide) ( \
Raphael Mollec5fe912012-06-06 19:33:31 -07001669 ATREE_STRIP="strip -x" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001670 $(HOST_OUT_EXECUTABLES)/atree \
1671 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1672 -m $(PRIVATE_DEP_FILE) \
1673 -I . \
1674 -I $(PRODUCT_OUT) \
1675 -I $(HOST_OUT) \
1676 -I $(TARGET_COMMON_OUT_ROOT) \
1677 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
Raphael Moll7558ad52011-01-05 14:58:17 -08001678 -v "OUT_DIR=$(OUT_DIR)" \
Raphael2a533172011-11-15 16:29:16 -08001679 -v "HOST_OUT=$(HOST_OUT)" \
Bruce Beare18a130e2011-02-18 15:06:20 -08001680 -v "TARGET_ARCH=$(TARGET_ARCH)" \
1681 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
David 'Digit' Turner557c51f2011-08-25 14:28:03 +02001682 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
Deepanshu Gupta887cd0c2014-05-27 18:07:49 -07001683 -v "FONT_OUT=$(sdk_font_temp_dir)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001684 -o $(PRIVATE_DIR) && \
1685 cp -f $(target_notice_file_txt) \
Xavier Ducrohet6de7bc62011-09-21 10:22:19 -07001686 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
Xavier Ducrohet4216a8c2011-03-15 13:28:40 -07001687 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001688 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Raphael7a6a9c32011-02-01 13:30:00 -08001689 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001690 chmod -R ug+rwX $(PRIVATE_DIR) && \
1691 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1692 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1693
Raphael3d224a02010-04-16 17:50:09 -07001694
1695# Is a Windows SDK requested? If so, we need some definitions from here
1696# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08001697MAIN_SDK_NAME := $(sdk_name)
1698MAIN_SDK_DIR := $(sdk_dir)
1699MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Raphael3d224a02010-04-16 17:50:09 -07001700ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07001701include $(TOPDIR)development/build/tools/windows_sdk.mk
1702endif
1703
The Android Open Source Project88b60792009-03-03 19:28:42 -08001704# -----------------------------------------------------------------
1705# Findbugs
1706INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1707INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1708$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1709 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09001710 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001711 > $@
1712$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1713 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09001714 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07001715 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001716
1717# -----------------------------------------------------------------
1718# Findbugs
1719
1720# -----------------------------------------------------------------
1721# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07001722ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001723include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01001724-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07001725-include $(sort $(wildcard device/*/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07001726endif
Raphaelc4d47312011-02-15 16:09:36 -08001727
1728# -----------------------------------------------------------------
1729# Create SDK repository packages. Must be done after tasks/* since
1730# we need the addon rules defined.
1731ifneq ($(sdk_repo_goal),)
1732include $(TOPDIR)development/build/tools/sdk_repo.mk
1733endif