blob: ace7e70bf0a120f935b637ac49a4c2056ff3a259 [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
901$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
902endef
903else
904define create-system-vendor-symlink
905endef
906endif
907
The Android Open Source Project88b60792009-03-03 19:28:42 -0800908# $(1): output file
909define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -0700910 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -0700911 $(call create-system-vendor-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -0700912 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Geremy Condrafd6f7512013-06-16 17:26:08 -0700913 $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt, \
Geremy Condra5b5f4952014-05-05 22:19:37 -0700914 skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -0700915 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
916 ./build/tools/releasetools/build_image.py \
917 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800918endef
919
Ying Wange5e8c5f2011-09-09 16:35:53 -0700920$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800921 $(call build-systemimage-target,$@)
922
The Android Open Source Project88b60792009-03-03 19:28:42 -0800923INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700924SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800925
Doug Zongker73ef8252009-07-23 15:12:53 -0700926# The system partition needs room for the recovery image as well. We
927# now store the recovery image as a binary patch using the boot image
928# as the source (since they are very similar). Generate the patch so
929# we can see how big it's going to be, and include that in the system
930# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700931ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700932intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
933RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
934$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
935 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700936 $(HOST_OUT_EXECUTABLES)/imgdiff \
937 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700938 @echo "Construct recovery from boot"
939 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700940 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700941endif
942
Doug Zongker73ef8252009-07-23 15:12:53 -0700943
944$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800945 @echo "Install system fs image: $@"
946 $(copy-file-to-target)
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700947 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800948
949systemimage: $(INSTALLED_SYSTEMIMAGE)
950
951.PHONY: systemimage-nodeps snod
952systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -0700953 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800954 @echo "make $@: ignoring dependencies"
955 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700956 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800957
Ying Wangacf01ec2012-02-24 11:05:48 -0800958ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
959ifeq (true,$(WITH_DEXPREOPT))
960$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
961endif
962endif
963
The Android Open Source Project88b60792009-03-03 19:28:42 -0800964#######
965## system tarball
966define build-systemtarball-target
Ying Wang23898df2014-06-18 20:26:24 -0700967 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
968 $(call create-system-vendor-symlink)
969 $(MKTARBALL) $(FS_GET_STATS) \
970 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
971 $(INSTALLED_SYSTEMTARBALL_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800972endef
973
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700974ifndef SYSTEM_TARBALL_FORMAT
975 SYSTEM_TARBALL_FORMAT := bz2
976endif
977
The Android Open Source Project88b60792009-03-03 19:28:42 -0800978system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700979INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800980$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
981$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
982 $(build-systemtarball-target)
983
984.PHONY: systemtarball-nodeps
985systemtarball-nodeps: $(FS_GET_STATS) \
986 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
987 $(build-systemtarball-target)
988
989.PHONY: stnod
990stnod: systemtarball-nodeps
991
Ying Wang4c289e52012-03-30 13:52:54 -0700992#######
Ying Wang4534d812012-04-09 17:04:12 -0700993## platform.zip: system, plus other files to be used in PDK fusion build,
994## in a zip file
keunyoungc0178062013-07-22 14:54:58 -0700995##
996## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
997## The variable will be typically set from BoardConfig.mk.
998## Files under out dir will be rejected to prevent possible conflicts with other rules.
999PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07001000INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
1001$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES)
1002 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Ying Wang4c289e52012-03-30 13:52:54 -07001003 $(hide) rm -f $@
Ying Wang4534d812012-04-09 17:04:12 -07001004 $(hide) cd $(dir $@) && zip -qry $(notdir $@) \
1005 $(TARGET_COPY_OUT_SYSTEM) \
Keun young Park72226692012-07-31 17:13:20 -07001006 $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \
1007 $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST))
Colin Crossc451a372013-12-18 19:36:44 -08001008ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Ying Wang28a18172012-06-02 09:22:31 -07001009 $(hide) cd $(OUT_DIR) && zip -qry $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
Keun young Park816b9fd2012-05-16 10:32:41 -07001010endif
keunyoungc0178062013-07-22 14:54:58 -07001011ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
1012 $(hide) zip -qry $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
1013endif
Ying Wang4c289e52012-03-30 13:52:54 -07001014
1015.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07001016platform: $(INSTALLED_PLATFORM_ZIP)
1017
1018.PHONY: platform-java
1019platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07001020
1021# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07001022ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
1023$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07001024endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001025
Bruce Beare52aac202010-06-04 15:24:49 -07001026#######
1027## boot tarball
1028define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -07001029 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -07001030 $(hide) mkdir -p $(PRODUCT_OUT)/boot
1031 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
1032 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
1033 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
1034 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
1035 $(INSTALLED_BOOTTARBALL_TARGET)
1036endef
1037
1038ifndef BOOT_TARBALL_FORMAT
1039 BOOT_TARBALL_FORMAT := bz2
1040endif
1041
1042boot_tar := $(PRODUCT_OUT)/boot.tar
1043INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
1044$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
1045$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
1046 $(build-boottarball-target)
1047
1048.PHONY: boottarball-nodeps btnod
1049boottarball-nodeps btnod: $(FS_GET_STATS) \
1050 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
1051 $(build-boottarball-target)
1052
1053
The Android Open Source Project88b60792009-03-03 19:28:42 -08001054# -----------------------------------------------------------------
1055# data partition image
1056INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001057 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001058
Ying Wangd7321d32013-03-15 10:32:29 -07001059# Don't build userdata.img if it's extfs but no partition size
1060skip_userdata.img :=
1061ifdef INTERNAL_USERIMAGES_EXT_VARIANT
1062ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE
1063skip_userdata.img := true
1064endif
1065endif
1066
1067ifneq ($(skip_userdata.img),true)
Ying Wangbd93d422011-10-28 17:02:30 -07001068userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001069 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07001070BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
1071
Ying Wangbd93d422011-10-28 17:02:30 -07001072define build-userdataimage-target
1073 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
1074 @mkdir -p $(TARGET_OUT_DATA)
1075 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001076 $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt, skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07001077 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1078 ./build/tools/releasetools/build_image.py \
Ying Wang178ef922011-10-31 18:13:30 -07001079 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001080 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07001081endef
1082
Joe Onorato64d85d02009-04-09 19:31:12 -07001083# We just build this directly to the install location.
1084INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -07001085$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001086 $(INTERNAL_USERDATAIMAGE_FILES)
1087 $(build-userdataimage-target)
1088
1089.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07001090userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001091 $(build-userdataimage-target)
1092
Ying Wangd7321d32013-03-15 10:32:29 -07001093endif # not skip_userdata.img
1094skip_userdata.img :=
Ying Wange215ed52012-10-15 14:36:22 -07001095
The Android Open Source Project88b60792009-03-03 19:28:42 -08001096#######
1097## data partition tarball
1098define build-userdatatarball-target
1099 $(call pretty,"Target userdata fs tarball: " \
1100 "$(INSTALLED_USERDATATARBALL_TARGET)")
1101 $(MKTARBALL) $(FS_GET_STATS) \
1102 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
1103 $(INSTALLED_USERDATATARBALL_TARGET)
1104endef
1105
1106userdata_tar := $(PRODUCT_OUT)/userdata.tar
1107INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
1108$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
1109$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
1110 $(build-userdatatarball-target)
1111
1112.PHONY: userdatatarball-nodeps
1113userdatatarball-nodeps: $(FS_GET_STATS)
1114 $(build-userdatatarball-target)
1115
1116
The Android Open Source Project88b60792009-03-03 19:28:42 -08001117# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07001118# cache partition image
1119ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1120INTERNAL_CACHEIMAGE_FILES := \
1121 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
1122
1123cacheimage_intermediates := \
1124 $(call intermediates-dir-for,PACKAGING,cache)
1125BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
1126
1127define build-cacheimage-target
1128 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
1129 @mkdir -p $(TARGET_OUT_CACHE)
1130 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001131 $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt, skip_fsck=true)
Ying Wang9f8e8db2011-11-04 11:37:01 -07001132 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1133 ./build/tools/releasetools/build_image.py \
1134 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001135 $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07001136endef
1137
1138# We just build this directly to the install location.
1139INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
1140$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
1141 $(build-cacheimage-target)
1142
1143.PHONY: cacheimage-nodeps
1144cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1145 $(build-cacheimage-target)
1146
1147endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1148
Ying Wanga0febe52013-03-20 11:02:05 -07001149
1150# -----------------------------------------------------------------
1151# vendor partition image
1152ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1153INTERNAL_VENDORIMAGE_FILES := \
1154 $(filter $(TARGET_OUT_VENDOR)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
1155
1156vendorimage_intermediates := \
1157 $(call intermediates-dir-for,PACKAGING,vendor)
1158BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
1159
1160define build-vendorimage-target
1161 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
1162 @mkdir -p $(TARGET_OUT_VENDOR)
1163 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
1164 $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true)
1165 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1166 ./build/tools/releasetools/build_image.py \
1167 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001168 $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07001169endef
1170
1171# We just build this directly to the install location.
1172INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
1173$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES)
1174 $(build-vendorimage-target)
1175
1176.PHONY: vendorimage-nodeps
1177vendorimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1178 $(build-vendorimage-target)
1179
1180endif # BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1181
Ying Wang9f8e8db2011-11-04 11:37:01 -07001182# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001183# bring in the installer image generation defines if necessary
1184ifeq ($(TARGET_USE_DISKINSTALLER),true)
1185include bootable/diskinstaller/config.mk
1186endif
1187
1188# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07001189# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08001190
Colin Crossc312f312012-04-19 13:54:39 -07001191DISTTOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -07001192 $(HOST_OUT_EXECUTABLES)/mkbootfs \
1193 $(HOST_OUT_EXECUTABLES)/mkbootimg \
1194 $(HOST_OUT_EXECUTABLES)/fs_config \
1195 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
1196 $(HOST_OUT_EXECUTABLES)/zipalign \
Doug Zongker8678df42009-06-15 14:30:14 -07001197 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -07001198 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -07001199 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -07001200 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
1201 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
Ying Wang7dc45a82013-01-04 14:43:18 -08001202 $(HOST_OUT_EXECUTABLES)/make_ext4fs \
1203 $(HOST_OUT_EXECUTABLES)/simg2img \
Doug Zongker5fad2032014-02-24 08:13:45 -08001204 $(HOST_OUT_EXECUTABLES)/e2fsck \
Doug Zongker32b527d2014-03-04 10:03:02 -08001205 $(HOST_OUT_EXECUTABLES)/xdelta3 \
Doug Zongker9843fd82014-05-13 14:17:13 -07001206 $(HOST_OUT_EXECUTABLES)/syspatch_host \
1207 $(HOST_OUT_EXECUTABLES)/build_verity_tree \
1208 $(HOST_OUT_EXECUTABLES)/verity_signer \
Geremy Condra740b6632014-07-08 20:07:41 -07001209 $(HOST_OUT_EXECUTABLES)/append2simg \
1210 $(HOST_OUT_EXECUTABLES)/boot_signer
The Android Open Source Project88b60792009-03-03 19:28:42 -08001211
Colin Crossc312f312012-04-19 13:54:39 -07001212OTATOOLS := $(DISTTOOLS) \
1213 $(HOST_OUT_EXECUTABLES)/aapt
1214
Ying Wang06898662010-06-17 17:52:18 -07001215.PHONY: otatools
1216otatools: $(OTATOOLS)
1217
The Android Open Source Project88b60792009-03-03 19:28:42 -08001218# -----------------------------------------------------------------
1219# A zip of the directories that map to the target filesystem.
1220# This zip can be used to create an OTA package or filesystem image
1221# as a post-build step.
1222#
1223name := $(TARGET_PRODUCT)
1224ifeq ($(TARGET_BUILD_TYPE),debug)
1225 name := $(name)_debug
1226endif
1227name := $(name)-target_files-$(FILE_NAME_TAG)
1228
1229intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
1230BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
1231$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
1232$(BUILT_TARGET_FILES_PACKAGE): \
1233 zip_root := $(intermediates)/$(name)
1234
1235# $(1): Directory to copy
1236# $(2): Location to copy it to
1237# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
1238define package_files-copy-root
1239 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
1240 mkdir -p $(2) && \
1241 $(ACP) -rd $(strip $(1))/* $(2); \
1242 fi
1243endef
1244
1245built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -07001246 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -07001247 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001248 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
Doug Zongker25863d72011-09-19 15:02:03 -07001249 $(call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001250 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -08001251$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
1252
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001253$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
Ken Sumrall31ce31f2013-02-21 16:27:25 -08001254$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION)
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001255
Doug Zongkerc18736b2009-09-30 09:20:32 -07001256ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1257# default to common dir for device vendor
1258$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
1259else
1260$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1261endif
1262
The Android Open Source Project88b60792009-03-03 19:28:42 -08001263# Depending on the various images guarantees that the underlying
1264# directories are up-to-date.
1265$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001266 $(INSTALLED_BOOTIMAGE_TARGET) \
1267 $(INSTALLED_RADIOIMAGE_TARGET) \
1268 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -07001269 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001270 $(INSTALLED_USERDATAIMAGE_TARGET) \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001271 $(INSTALLED_CACHEIMAGE_TARGET) \
Ying Wanga0febe52013-03-20 11:02:05 -07001272 $(INSTALLED_VENDORIMAGE_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001273 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001274 $(SELINUX_FC) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001275 $(built_ota_tools) \
1276 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -07001277 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001278 | $(ACP)
1279 @echo "Package target files: $@"
1280 $(hide) rm -rf $@ $(zip_root)
1281 $(hide) mkdir -p $(dir $@) $(zip_root)
1282 @# Components of the recovery image
1283 $(hide) mkdir -p $(zip_root)/RECOVERY
1284 $(hide) $(call package_files-copy-root, \
1285 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
1286ifdef INSTALLED_KERNEL_TARGET
1287 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
1288endif
1289ifdef INSTALLED_2NDBOOTLOADER_TARGET
1290 $(hide) $(ACP) \
1291 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
1292endif
1293ifdef BOARD_KERNEL_CMDLINE
1294 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
1295endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001296ifdef BOARD_KERNEL_BASE
1297 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
1298endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001299ifdef BOARD_KERNEL_PAGESIZE
1300 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
1301endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001302 @# Components of the boot image
1303 $(hide) mkdir -p $(zip_root)/BOOT
1304 $(hide) $(call package_files-copy-root, \
1305 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1306ifdef INSTALLED_KERNEL_TARGET
1307 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1308endif
1309ifdef INSTALLED_2NDBOOTLOADER_TARGET
1310 $(hide) $(ACP) \
1311 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1312endif
1313ifdef BOARD_KERNEL_CMDLINE
1314 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1315endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001316ifdef BOARD_KERNEL_BASE
1317 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1318endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001319ifdef BOARD_KERNEL_PAGESIZE
1320 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1321endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001322 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1323 mkdir -p $(zip_root)/RADIO; \
1324 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001325 @# Contents of the system image
1326 $(hide) $(call package_files-copy-root, \
1327 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1328 @# Contents of the data image
1329 $(hide) $(call package_files-copy-root, \
1330 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Ying Wanga0febe52013-03-20 11:02:05 -07001331ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1332 @# Contents of the vendor image
1333 $(hide) $(call package_files-copy-root, \
1334 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
1335endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001336 @# Extra contents of the OTA package
1337 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001338 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1339 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001340 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001341 @# build them.
1342 $(hide) mkdir -p $(zip_root)/META
1343 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker816d73f2013-11-22 13:29:55 -08001344 $(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 -07001345 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -07001346 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Ken Sumrall31ce31f2013-02-21 16:27:25 -08001347 $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001348ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07001349 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001350endif
1351ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001352 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001353endif
1354ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001355 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001356endif
Doug Zongker37974732010-09-16 17:44:38 -07001357 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wang3c21fe52011-10-04 10:50:08 -07001358 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
Doug Zongker5d4808d2011-03-16 07:49:13 -07001359ifdef PRODUCT_EXTRA_RECOVERY_KEYS
1360 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
Doug Zongkere121d6a2011-02-01 14:13:52 -08001361endif
Jianxun Zhang09849492013-04-17 15:19:19 -07001362 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001363 $(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt
Doug Zongker9b23f2c2013-11-25 14:44:12 -08001364 $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
Michael Rungefacd9922013-12-20 11:50:16 -08001365 $(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt
Jeff Sharkey26e1a282014-03-21 16:20:05 -07001366ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),)
1367 # OTA scripts are only interested in fingerprint related properties
1368 $(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
1369endif
Ying Wangbd93d422011-10-28 17:02:30 -07001370 $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
Doug Zongkerc9253822014-02-04 12:17:58 -08001371 $(hide) ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001372 @# Zip everything up, preserving symlinks
1373 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongkerc8b4e842014-06-16 15:16:31 -07001374 @# Run fs_config on all the system, vendor, boot ramdisk,
1375 @# and recovery ramdisk files in the zip, and save the output
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001376 $(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 -07001377 $(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 -07001378 $(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
1379 $(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 -07001380 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
Doug Zongker283e2a12010-03-15 17:52:32 -07001381
Ying Wanga0febe52013-03-20 11:02:05 -07001382.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001383target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1384
Ying Wang4709d7c2014-04-14 17:25:43 -07001385ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
1386$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
1387endif
Doug Zongker367910f2009-06-15 18:56:51 -07001388
Doug Zongker367910f2009-06-15 18:56:51 -07001389ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang279f3082011-02-09 12:26:42 -08001390ifeq ($(filter generic%,$(TARGET_DEVICE)),)
Ying Wangfb0a3472010-08-25 16:06:06 -07001391ifneq ($(TARGET_NO_KERNEL),true)
Ying Wanga73b6562011-03-03 21:52:08 -08001392ifneq ($(recovery_fstab),)
Doug Zongker367910f2009-06-15 18:56:51 -07001393
Ying Wang09a00a62010-10-20 14:01:09 -07001394# -----------------------------------------------------------------
1395# OTA update package
1396
Doug Zongker8678df42009-06-15 14:30:14 -07001397name := $(TARGET_PRODUCT)
1398ifeq ($(TARGET_BUILD_TYPE),debug)
1399 name := $(name)_debug
1400endif
1401name := $(name)-ota-$(FILE_NAME_TAG)
1402
1403INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1404
1405$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1406
Ying Wang82cceba2012-08-13 15:03:00 -07001407$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001408 @echo "Package OTA: $@"
Ying Wang42c98042014-06-18 11:31:21 -07001409 $(hide) MKBOOTIMG=$(MKBOOTIMG) \
Bjorn Andersson612e2cd2012-11-25 16:53:44 -08001410 ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker26e66192014-02-20 13:22:07 -08001411 --block \
Doug Zongker602a84e2009-06-18 08:35:12 -07001412 -p $(HOST_OUT) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05001413 -k $(KEY_CERT_PAIR) \
Michael Runge6e836112014-04-15 17:40:21 -07001414 $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05001415 $(BUILT_TARGET_FILES_PACKAGE) $@
Doug Zongker8678df42009-06-15 14:30:14 -07001416
1417.PHONY: otapackage
1418otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1419
Ying Wangf8824af2014-06-03 14:07:27 -07001420endif # recovery_fstab is defined
1421endif # TARGET_NO_KERNEL != true
1422endif # TARGET_DEVICE != generic*
1423endif # TARGET_PRODUCT != sdk
1424
Ying Wang09a00a62010-10-20 14:01:09 -07001425# -----------------------------------------------------------------
1426# The update package
1427
1428name := $(TARGET_PRODUCT)
1429ifeq ($(TARGET_BUILD_TYPE),debug)
1430 name := $(name)_debug
1431endif
1432name := $(name)-img-$(FILE_NAME_TAG)
1433
1434INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1435
Ying Wang82cceba2012-08-13 15:03:00 -07001436$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
Ying Wang09a00a62010-10-20 14:01:09 -07001437 @echo "Package: $@"
Ying Wang42c98042014-06-18 11:31:21 -07001438 $(hide) MKBOOTIMG=$(MKBOOTIMG) \
Bjorn Andersson612e2cd2012-11-25 16:53:44 -08001439 ./build/tools/releasetools/img_from_target_files -v \
Ying Wang09a00a62010-10-20 14:01:09 -07001440 -p $(HOST_OUT) \
1441 $(BUILT_TARGET_FILES_PACKAGE) $@
1442
1443.PHONY: updatepackage
1444updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
1445
The Android Open Source Project88b60792009-03-03 19:28:42 -08001446# -----------------------------------------------------------------
1447# A zip of the symbols directory. Keep the full paths to make it
1448# more obvious where these files came from.
1449#
1450name := $(TARGET_PRODUCT)
1451ifeq ($(TARGET_BUILD_TYPE),debug)
1452 name := $(name)_debug
1453endif
1454name := $(name)-symbols-$(FILE_NAME_TAG)
1455
1456SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1457$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1458 @echo "Package symbols: $@"
1459 $(hide) rm -rf $@
1460 $(hide) mkdir -p $(dir $@)
1461 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1462
1463# -----------------------------------------------------------------
1464# A zip of the Android Apps. Not keeping full path so that we don't
1465# include product names when distributing
1466#
1467name := $(TARGET_PRODUCT)
1468ifeq ($(TARGET_BUILD_TYPE),debug)
1469 name := $(name)_debug
1470endif
1471name := $(name)-apps-$(FILE_NAME_TAG)
1472
1473APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1474$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1475 @echo "Package apps: $@"
1476 $(hide) rm -rf $@
1477 $(hide) mkdir -p $(dir $@)
Robert Craig59ec1952014-02-26 11:48:20 -05001478 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/* $(TARGET_OUT_APPS_PRIVILEGED)/*
The Android Open Source Project88b60792009-03-03 19:28:42 -08001479
Guang Zhu0198d6e2010-04-23 11:54:37 -07001480
1481#------------------------------------------------------------------
1482# A zip of emma code coverage meta files. Generated for fully emma
1483# instrumented build.
1484#
Ying Wangbc415dd2012-08-15 12:22:44 -07001485ifeq (true,$(EMMA_INSTRUMENT))
Guang Zhu0198d6e2010-04-23 11:54:37 -07001486EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
Ying Wangbc415dd2012-08-15 12:22:44 -07001487# the dependency will be set up later in build/core/main.mk.
1488$(EMMA_META_ZIP) :
Guang Zhu0198d6e2010-04-23 11:54:37 -07001489 @echo "Collecting Emma coverage meta files."
Ying Wang1ff08362013-12-27 15:55:08 -08001490 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "coverage.em" | \
Guang Zhu0198d6e2010-04-23 11:54:37 -07001491 zip -@ -q $@
1492
Ying Wangbc415dd2012-08-15 12:22:44 -07001493endif # EMMA_INSTRUMENT=true
1494
Ying Wangae9115a2013-08-22 20:52:47 -07001495#------------------------------------------------------------------
1496# A zip of Proguard obfuscation dictionary files.
1497# Only for apps_only build.
1498#
1499ifdef TARGET_BUILD_APPS
Ying Wangc62c92c2013-08-28 18:38:25 -07001500PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Ying Wangae9115a2013-08-22 20:52:47 -07001501# the dependency will be set up later in build/core/main.mk.
1502$(PROGUARD_DICT_ZIP) :
1503 @echo "Packaging Proguard obfuscation dictionary files."
1504 $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary`; \
1505 if [ -n "$$dict_files" ]; then \
Ying Wang33d64592013-11-25 17:39:50 -08001506 unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \
1507 zip -q $@ $$dict_files $$unobfuscated_jars; \
Ying Wangae9115a2013-08-22 20:52:47 -07001508 else \
Ying Wangc62c92c2013-08-28 18:38:25 -07001509 touch $(dir $@)/dummy; \
1510 (cd $(dir $@) && zip -q $(notdir $@) dummy); \
1511 zip -qd $@ dummy; \
1512 rm $(dir $@)/dummy; \
Ying Wangae9115a2013-08-22 20:52:47 -07001513 fi
1514
1515endif # TARGET_BUILD_APPS
1516
The Android Open Source Project88b60792009-03-03 19:28:42 -08001517# -----------------------------------------------------------------
1518# dalvik something
1519.PHONY: dalvikfiles
1520dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1521
1522# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001523# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07001524ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001525INTERNAL_EMULATOR_PACKAGE_FILES += \
1526 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08001527 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001528 $(INSTALLED_RAMDISK_TARGET) \
1529 $(INSTALLED_SYSTEMIMAGE) \
1530 $(INSTALLED_USERDATAIMAGE_TARGET)
1531
1532name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1533
1534INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1535
1536$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1537 @echo "Package: $@"
1538 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1539
Ying Wang7d8c5352012-07-26 10:15:21 -07001540endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001541# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08001542# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08001543# The pdk package (Platform Development Kit)
1544
Keun young Park7fc7aad2012-02-27 15:49:23 -08001545#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1546# include development/pdk/Pdk.mk
1547#endif
1548
The Android Open Source Project88b60792009-03-03 19:28:42 -08001549
1550# -----------------------------------------------------------------
1551# The SDK
1552
The Android Open Source Project88b60792009-03-03 19:28:42 -08001553# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07001554sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001555
1556# Build a name that looks like:
1557#
1558# linux-x86 --> android-sdk_12345_linux-x86
1559# darwin-x86 --> android-sdk_12345_mac-x86
1560# windows-x86 --> android-sdk_12345_windows
1561#
1562sdk_name := android-sdk_$(FILE_NAME_TAG)
1563ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001564 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001565else
Joe Onorato03fbe402009-04-13 08:31:16 -07001566 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001567endif
1568ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07001569 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001570endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001571sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001572
1573sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1574
1575ATREE_FILES :=
1576-include $(sdk_dep_file)
1577
1578# if we don't have a real list, then use "everything"
1579ifeq ($(strip $(ATREE_FILES)),)
1580ATREE_FILES := \
1581 $(ALL_PREBUILT) \
1582 $(ALL_COPIED_HEADERS) \
1583 $(ALL_GENERATED_SOURCES) \
1584 $(ALL_DEFAULT_INSTALLED_MODULES) \
1585 $(INSTALLED_RAMDISK_TARGET) \
1586 $(ALL_DOCS) \
1587 $(ALL_SDK_FILES)
1588endif
1589
1590atree_dir := development/build
1591
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001592
The Android Open Source Project88b60792009-03-03 19:28:42 -08001593sdk_atree_files := \
1594 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07001595 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08001596
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02001597# development/build/sdk-android-<abi>.atree is used to differentiate
1598# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
1599# files like the kernel image. We use TARGET_CPU_ABI because we don't
1600# have a better way to distinguish between CPU models.
1601ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
1602 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
1603endif
1604
Griff Hazen433febb2014-02-28 08:45:59 -08001605ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),)
1606sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES)
1607else
1608sdk_atree_files += $(atree_dir)/sdk.atree
1609endif
1610
The Android Open Source Project88b60792009-03-03 19:28:42 -08001611deps := \
1612 $(target_notice_file_txt) \
1613 $(tools_notice_file_txt) \
1614 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001615 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001616 $(INSTALLED_SYSTEMIMAGE) \
1617 $(INSTALLED_USERDATAIMAGE_TARGET) \
1618 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001619 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001620 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001621 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08001622 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001623 $(HOST_OUT_EXECUTABLES)/atree \
Joe Onorato63d56da2012-08-17 04:19:38 -07001624 $(HOST_OUT_EXECUTABLES)/line_endings
The Android Open Source Project88b60792009-03-03 19:28:42 -08001625
1626INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1627$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1628$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1629$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1630$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1631
Deepanshu Gupta887cd0c2014-05-27 18:07:49 -07001632sdk_font_temp_dir := $(call intermediates-dir-for,PACKAGING,sdk-fonts)
1633sdk_font_input_list := frameworks/base/data/fonts external/noto-fonts external/google-fonts external/naver-fonts
1634sdk_font_rename_script := frameworks/base/tools/layoutlib/rename_font/build_font.py
1635
The Android Open Source Project88b60792009-03-03 19:28:42 -08001636# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1637#
1638#SDK_GNU_ERROR := true
1639
1640$(INTERNAL_SDK_TARGET): $(deps)
1641 @echo "Package SDK: $@"
1642 $(hide) rm -rf $(PRIVATE_DIR) $@
1643 $(hide) for f in $(target_gnu_MODULES); do \
1644 if [ -f $$f ]; then \
1645 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1646 including GNU target $$f >&2; \
1647 FAIL=$(SDK_GNU_ERROR); \
1648 fi; \
1649 done; \
1650 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta887cd0c2014-05-27 18:07:49 -07001651 $(hide) mkdir -p $(sdk_font_temp_dir)
1652 $(hide) PYTHONPATH=$$PYTHONPATH:external/fonttools/Lib $(sdk_font_rename_script) $(sdk_font_input_list) \
1653 $(sdk_font_temp_dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001654 $(hide) ( \
Raphael Mollec5fe912012-06-06 19:33:31 -07001655 ATREE_STRIP="strip -x" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001656 $(HOST_OUT_EXECUTABLES)/atree \
1657 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1658 -m $(PRIVATE_DEP_FILE) \
1659 -I . \
1660 -I $(PRODUCT_OUT) \
1661 -I $(HOST_OUT) \
1662 -I $(TARGET_COMMON_OUT_ROOT) \
1663 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
Raphael Moll7558ad52011-01-05 14:58:17 -08001664 -v "OUT_DIR=$(OUT_DIR)" \
Raphael2a533172011-11-15 16:29:16 -08001665 -v "HOST_OUT=$(HOST_OUT)" \
Bruce Beare18a130e2011-02-18 15:06:20 -08001666 -v "TARGET_ARCH=$(TARGET_ARCH)" \
1667 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
David 'Digit' Turner557c51f2011-08-25 14:28:03 +02001668 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
Deepanshu Gupta887cd0c2014-05-27 18:07:49 -07001669 -v "FONT_OUT=$(sdk_font_temp_dir)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001670 -o $(PRIVATE_DIR) && \
1671 cp -f $(target_notice_file_txt) \
Xavier Ducrohet6de7bc62011-09-21 10:22:19 -07001672 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
Xavier Ducrohet4216a8c2011-03-15 13:28:40 -07001673 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001674 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Raphael7a6a9c32011-02-01 13:30:00 -08001675 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001676 chmod -R ug+rwX $(PRIVATE_DIR) && \
1677 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1678 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1679
Raphael3d224a02010-04-16 17:50:09 -07001680
1681# Is a Windows SDK requested? If so, we need some definitions from here
1682# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08001683MAIN_SDK_NAME := $(sdk_name)
1684MAIN_SDK_DIR := $(sdk_dir)
1685MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Raphael3d224a02010-04-16 17:50:09 -07001686ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07001687include $(TOPDIR)development/build/tools/windows_sdk.mk
1688endif
1689
The Android Open Source Project88b60792009-03-03 19:28:42 -08001690# -----------------------------------------------------------------
1691# Findbugs
1692INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1693INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1694$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1695 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09001696 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001697 > $@
1698$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1699 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09001700 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07001701 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001702
1703# -----------------------------------------------------------------
1704# Findbugs
1705
1706# -----------------------------------------------------------------
1707# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07001708ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001709include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01001710-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07001711-include $(sort $(wildcard device/*/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07001712endif
Raphaelc4d47312011-02-15 16:09:36 -08001713
1714# -----------------------------------------------------------------
1715# Create SDK repository packages. Must be done after tasks/* since
1716# we need the addon rules defined.
1717ifneq ($(sdk_repo_goal),)
1718include $(TOPDIR)development/build/tools/sdk_repo.mk
1719endif