blob: 2177a182da2852f6256056f8039ccf6869722d4a [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)))
Ying Wang50367cc2014-06-12 18:42:53 -0700114 ifneq ($(filter eng.%,$(BUILD_NUMBER)),)
115 # Trim down BUILD_FINGERPRINT: the default BUILD_NUMBER makes it easily exceed
116 # the Android system property length limit (PROPERTY_VALUE_MAX=92).
117 BF_BUILD_NUMBER := $(USER)$(shell date +%m%d%H%M)
118 else
119 BF_BUILD_NUMBER := $(BUILD_NUMBER)
120 endif
121 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BF_BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800122endif
123ifneq ($(words $(BUILD_FINGERPRINT)),1)
124 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
125endif
126
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700127# The string used to uniquely identify the system build; used by the OTA server.
128# This purposefully excludes any product-specific variables.
129ifeq (,$(strip $(BUILD_THUMBPRINT)))
130 BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
131endif
132ifneq ($(words $(BUILD_THUMBPRINT)),1)
133 $(error BUILD_THUMBPRINT cannot contain spaces: "$(BUILD_THUMBPRINT)")
134endif
135
Ying Wange24e17a2014-10-07 18:42:11 -0700136KNOWN_OEM_THUMBPRINT_PROPERTIES := \
137 ro.product.brand \
138 ro.product.name \
139 ro.product.device
140OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\
141 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES))
142
Sriram Raman7b641242009-03-24 22:40:59 -0700143# Display parameters shown under Settings -> About Phone
144ifeq ($(TARGET_BUILD_VARIANT),user)
145 # User builds should show:
146 # release build number or branch.buld_number non-release builds
147
148 # Dev. branches should have DISPLAY_BUILD_NUMBER set
149 ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
Doug Zongkera8608a72013-07-23 11:51:04 -0700150 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700151 else
Doug Zongkera8608a72013-07-23 11:51:04 -0700152 BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700153 endif
154else
155 # Non-user builds should show detailed build information
156 BUILD_DISPLAY_ID := $(build_desc)
157endif
158
Ying Wang77c882f2010-04-27 15:45:35 -0700159# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
Ying Wang38d7f022010-07-21 14:58:42 -0700160product_property_override_locale_language := $(strip \
161 $(patsubst ro.product.locale.language=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700162 $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
Ying Wang38d7f022010-07-21 14:58:42 -0700163product_property_overrides_locale_region := $(strip \
164 $(patsubst ro.product.locale.region=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700165 $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
166
The Android Open Source Project88b60792009-03-03 19:28:42 -0800167# Selects the first locale in the list given as the argument,
168# and splits it into language and region, which each may be
169# empty.
170define default-locale
171$(subst _, , $(firstword $(1)))
172endef
173
174# Selects the first locale in the list given as the argument
Ying Wang77c882f2010-04-27 15:45:35 -0700175# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
176# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800177define default-locale-language
Ying Wang38d7f022010-07-21 14:58:42 -0700178$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800179endef
180define default-locale-region
Ying Wang38d7f022010-07-21 14:58:42 -0700181$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800182endef
183
184BUILDINFO_SH := build/tools/buildinfo.sh
Andrew Boiefa61ff02012-09-28 09:33:45 -0700185
186ifdef TARGET_SYSTEM_PROP
187system_prop_file := $(TARGET_SYSTEM_PROP)
188else
189system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
190endif
Andrew Boiefa61ff02012-09-28 09:33:45 -0700191$(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 -0800192 @echo Target buildinfo: $@
193 @mkdir -p $(dir $@)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700194 $(hide) echo > $@
195ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),)
196 $(hide) echo "#" >> $@; \
197 echo "# PRODUCT_OEM_PROPERTIES" >> $@; \
Jeff Sharkey26e1a282014-03-21 16:20:05 -0700198 echo "#" >> $@;
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700199 $(hide) $(foreach prop,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES), \
200 echo "import /oem/oem.prop $(prop)" >> $@;)
201endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800202 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
203 TARGET_DEVICE="$(TARGET_DEVICE)" \
204 PRODUCT_NAME="$(TARGET_PRODUCT)" \
205 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
206 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
207 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700208 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800209 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
210 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
211 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
212 BUILD_ID="$(BUILD_ID)" \
213 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
214 BUILD_NUMBER="$(BUILD_NUMBER)" \
215 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
216 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700217 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
Dianne Hackborn6ee3c432014-04-24 16:19:14 -0700218 PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800219 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
220 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
221 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
Ying Wange24e17a2014-10-07 18:42:11 -0700222 $(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT)") \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800223 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
Narayan Kamath1a43b372014-03-26 17:33:55 +0000224 TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \
Narayan Kamath7303ebd2014-04-07 11:01:54 +0100225 TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \
226 TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700227 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800228 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Joe Onorato25939e22010-11-09 08:53:01 -0800229 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700230 bash $(BUILDINFO_SH) >> $@
Johan Redestig674a27d2012-04-12 17:00:58 +0200231 $(hide) $(foreach file,$(system_prop_file), \
232 if [ -f "$(file)" ]; then \
233 echo "#" >> $@; \
234 echo Target buildinfo from: "$(file)"; \
235 echo "# from $(file)" >> $@; \
236 echo "#" >> $@; \
237 cat $(file) >> $@; \
238 fi;)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800239 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
240 $(hide) echo >> $@; \
241 echo "#" >> $@; \
242 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
243 echo "#" >> $@; )
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700244 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
245 echo "$(line)" >> $@;)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700246 $(hide) build/tools/post_process_props.py $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_PROPERTY_BLACKLIST)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800247
248build_desc :=
249
250# -----------------------------------------------------------------
Daniel Rosenberg40b61ca2014-07-21 17:21:20 -0700251# vendor build.prop
252#
253# For verifying that the vendor build is what we thing it is
254ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
255INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop
256ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
257$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
258 @echo Target vendor buildinfo: $@
259 @mkdir -p $(dir $@)
260 $(hide) echo > $@
261 $(hide) echo ro.vendor.build.date=`date`>>$@
262 $(hide) echo ro.vendor.build.date.utc=`date +%s`>>$@
263 $(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT)">>$@
264endif
265
266# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800267# sdk-build.prop
268#
269# There are certain things in build.prop that we don't want to
270# ship with the sdk; remove them.
271
272# This must be a list of entire property keys followed by
273# "=" characters, without any internal spaces.
274sdk_build_prop_remove := \
275 ro.build.user= \
276 ro.build.host= \
277 ro.product.brand= \
278 ro.product.manufacturer= \
279 ro.product.device=
280# TODO: Remove this soon-to-be obsolete property
281sdk_build_prop_remove += ro.build.product=
282INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
283$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
284 @echo SDK buildinfo: $@
285 @mkdir -p $(dir $@)
286 $(hide) grep -v "$(subst $(space),\|,$(strip \
287 $(sdk_build_prop_remove)))" $< > $@.tmp
288 $(hide) for x in $(sdk_build_prop_remove); do \
289 echo "$$x"generic >> $@.tmp; done
290 $(hide) mv $@.tmp $@
291
292# -----------------------------------------------------------------
293# package stats
294PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
295PACKAGES_TO_STAT := \
296 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
297 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
298$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
299 @echo Package stats: $@
300 @mkdir -p $(dir $@)
301 $(hide) rm -f $@
302 $(hide) build/tools/dump-package-stats $^ > $@
303
304.PHONY: package-stats
305package-stats: $(PACKAGE_STATS_FILE)
306
307# -----------------------------------------------------------------
308# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700309# Use a macro to add newline to each echo command
310define _apkcerts_echo_with_newline
311$(hide) echo $(1)
312
313endef
314
The Android Open Source Project88b60792009-03-03 19:28:42 -0800315name := $(TARGET_PRODUCT)
316ifeq ($(TARGET_BUILD_TYPE),debug)
317 name := $(name)_debug
318endif
319name := $(name)-apkcerts-$(FILE_NAME_TAG)
320intermediates := \
321 $(call intermediates-dir-for,PACKAGING,apkcerts)
322APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800323# We don't need to really build all the modules.
324# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700325$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800326 @echo APK certs list: $@
327 @mkdir -p $(dir $@)
328 @rm -f $@
Ying Wangd9a88d52012-10-26 09:21:28 -0700329 $(foreach p,$(PACKAGES),\
330 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
331 $(call _apkcerts_echo_with_newline,\
332 'name="$(p).apk" certificate="EXTERNAL" \
333 private_key=""' >> $@),\
334 $(call _apkcerts_echo_with_newline,\
335 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
336 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@)))
337 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700338 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800339
340.PHONY: apkcerts-list
341apkcerts-list: $(APKCERTS_FILE)
342
Ying Wang15e487a2011-02-15 10:56:18 -0800343ifneq (,$(TARGET_BUILD_APPS))
344 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
345endif
Ying Wangefb21682010-07-23 16:42:13 -0700346
The Android Open Source Project88b60792009-03-03 19:28:42 -0800347# -----------------------------------------------------------------
348# module info file
349ifdef CREATE_MODULE_INFO_FILE
350 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
351 $(info Generating $(MODULE_INFO_FILE)...)
352 $(shell rm -f $(MODULE_INFO_FILE))
353 $(foreach m,$(ALL_MODULES), \
354 $(shell echo "NAME=\"$(m)\"" \
355 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
356 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
357 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
358 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
359endif
360
Doug Zongker8678df42009-06-15 14:30:14 -0700361# -----------------------------------------------------------------
362
Ying Wang3c21fe52011-10-04 10:50:08 -0700363# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700364# for future OTA packages installed by this system. Actual product
365# deliverables will be re-signed by hand. We expect this file to
366# exist with the suffixes ".x509.pem" and ".pk8".
Ying Wang3c21fe52011-10-04 10:50:08 -0700367DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Doug Zongker8678df42009-06-15 14:30:14 -0700368
369
Jeff Browne33ba4c2011-07-11 22:11:46 -0700370# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800371# if they don't do anything.
372.PHONY: systemimage
373systemimage:
374
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800375# -----------------------------------------------------------------
376
377.PHONY: event-log-tags
378
Joe Onoratob7510532010-07-14 10:22:54 -0700379# Produce an event logs tag file for everything we know about, in order
380# to properly allocate numbers. Then produce a file that's filtered
381# for what's going to be installed.
382
383all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
384
Colin Crossdc8f8e42012-04-12 13:25:54 -0700385event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
386
Joe Onoratob7510532010-07-14 10:22:54 -0700387# Include tags from all packages that we know about
388all_event_log_tags_src := \
389 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
390
Colin Crossdc8f8e42012-04-12 13:25:54 -0700391# PDK builds will already have a full list of tags that needs to get merged
392# in with the ones from source
393pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
394
395$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
396$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700397 $(hide) mkdir -p $(dir $@)
398 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
399
Doug Zongkera34fa952011-02-23 12:17:29 -0800400# Include tags from all packages included in this product, plus all
401# tags that are part of the system (ie, not in a vendor/ or device/
402# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800403event_log_tags_src := \
404 $(sort $(foreach m,\
405 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
406 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800407 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
408 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800409
Colin Crossdc8f8e42012-04-12 13:25:54 -0700410$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700411$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossdc8f8e42012-04-12 13:25:54 -0700412$(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 -0800413 $(hide) mkdir -p $(dir $@)
Joe Onoratob7510532010-07-14 10:22:54 -0700414 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800415
416event-log-tags: $(event_log_tags_file)
417
418ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
419
Joe Onoratob7510532010-07-14 10:22:54 -0700420
The Android Open Source Project88b60792009-03-03 19:28:42 -0800421# #################################################################
422# Targets for boot/OS images
423# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800424ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
425 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
426 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
427 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
428 else
429 INSTALLED_2NDBOOTLOADER_TARGET :=
430 endif
431else
432 INSTALLED_BOOTLOADER_MODULE :=
433 INSTALLED_2NDBOOTLOADER_TARGET :=
434endif # TARGET_NO_BOOTLOADER
435ifneq ($(strip $(TARGET_NO_KERNEL)),true)
436 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
437else
438 INSTALLED_KERNEL_TARGET :=
439endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800440
441# -----------------------------------------------------------------
442# the ramdisk
443INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
444 $(ALL_PREBUILT) \
445 $(ALL_COPIED_HEADERS) \
446 $(ALL_GENERATED_SOURCES) \
447 $(ALL_DEFAULT_INSTALLED_MODULES))
448
Joe Onorato64d85d02009-04-09 19:31:12 -0700449BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
450
451# We just build this directly to the install location.
452INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Ying Wang82cceba2012-08-13 15:03:00 -0700453$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800454 $(call pretty,"Target ram disk: $@")
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700455 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800456
Ying Wangad7fd292013-08-08 16:34:29 -0700457.PHONY: ramdisk-nodeps
458ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP)
459 @echo "make $@: ignoring dependencies"
460 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800461
462ifneq ($(strip $(TARGET_NO_KERNEL)),true)
463
464# -----------------------------------------------------------------
465# the boot image, which is a collection of other images.
466INTERNAL_BOOTIMAGE_ARGS := \
467 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
468 --kernel $(INSTALLED_KERNEL_TARGET) \
469 --ramdisk $(INSTALLED_RAMDISK_TARGET)
470
471INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
472
473BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
474ifdef BOARD_KERNEL_CMDLINE
475 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
476endif
477
Dima Zavin1e0847c2009-05-07 19:43:08 -0700478BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
479ifdef BOARD_KERNEL_BASE
480 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
481endif
482
Ying Wangffff0022010-08-23 12:56:25 -0700483BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
484ifdef BOARD_KERNEL_PAGESIZE
485 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
486endif
487
The Android Open Source Project88b60792009-03-03 19:28:42 -0800488INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
489
490ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
491tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
492INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
493INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
494$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
495 $(call pretty,"Target boot image: $@")
496 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
497
Ying Wangad7fd292013-08-08 16:34:29 -0700498.PHONY: bootimage-nodeps
499bootimage-nodeps: $(MKEXT2IMG)
500 @echo "make $@: ignoring dependencies"
501 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
502
Geremy Condra740b6632014-07-08 20:07:41 -0700503else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)) # TARGET_BOOTIMAGE_USE_EXT2 != true
504
505$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
506 $(call pretty,"Target boot image: $@")
507 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
508 $(BOOT_SIGNER) /boot $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY) $@
509 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
510
511.PHONY: bootimage-nodeps
512bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
513 @echo "make $@: ignoring dependencies"
514 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
515 $(BOOT_SIGNER) /boot $(INSTALLED_BOOTIMAGE_TARGET) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY) $(INSTALLED_BOOTIMAGE_TARGET)
516 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
517
518else # PRODUCT_SUPPORTS_VERITY != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800519
520$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
521 $(call pretty,"Target boot image: $@")
Doug Zongkerd5131602012-08-02 14:46:42 -0700522 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700523 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700524
525.PHONY: bootimage-nodeps
526bootimage-nodeps: $(MKBOOTIMG)
527 @echo "make $@: ignoring dependencies"
528 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700529 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700530
The Android Open Source Project88b60792009-03-03 19:28:42 -0800531endif # TARGET_BOOTIMAGE_USE_EXT2
532
533else # TARGET_NO_KERNEL
534# HACK: The top-level targets depend on the bootimage. Not all targets
535# can produce a bootimage, though, and emulator targets need the ramdisk
536# instead. Fake it out by calling the ramdisk the bootimage.
537# TODO: make the emulator use bootimages, and make mkbootimg accept
538# kernel-less inputs.
539INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
540endif
541
542# -----------------------------------------------------------------
543# NOTICE files
544#
Steve Blockd14d3b42012-03-01 11:34:41 +0000545# We are required to publish the licenses for all code under BSD, GPL and
546# Apache licenses (and possibly other more exotic ones as well). We err on the
547# side of caution, so the licenses for other third-party code are included here
548# too.
549#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800550# This needs to be before the systemimage rules, because it adds to
551# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
552# go into the systemimage.
553
Steve Block495e5852012-02-29 19:18:08 +0000554.PHONY: notice_files
555
The Android Open Source Project88b60792009-03-03 19:28:42 -0800556# Create the rule to combine the files into text and html forms
Steve Block495e5852012-02-29 19:18:08 +0000557# $(1) - Plain text output file
558# $(2) - HTML output file
559# $(3) - File title
560# $(4) - Directory to use. Notice files are all $(4)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800561# directories in there will be used for scratch
Steve Block495e5852012-02-29 19:18:08 +0000562# $(5) - Dependencies for the output files
The Android Open Source Project88b60792009-03-03 19:28:42 -0800563#
564# The algorithm here is that we go collect a hash for each of the notice
565# files and write the names of the files that match that hash. Then
566# to generate the real files, we go print out all of the files and their
567# hashes.
568#
569# These rules are fairly complex, so they depend on this makefile so if
570# it changes, they'll run again.
571#
572# TODO: We could clean this up so that we just record the locations of the
573# original notice files instead of making rules to copy them somwehere.
574# Then we could traverse that without quite as much bash drama.
575define combine-notice-files
Steve Block495e5852012-02-29 19:18:08 +0000576$(1) $(2): PRIVATE_MESSAGE := $(3)
Daniel Berlinf5a97d72012-03-29 10:33:19 -0400577$(1) $(2): PRIVATE_DIR := $(4)
Ying Wangc4625ab2012-04-09 12:16:23 -0700578$(1) : $(2)
579$(2) : $(5) $(BUILD_SYSTEM)/Makefile build/tools/generate-notice-files.py
Daniel Berlinf5a97d72012-03-29 10:33:19 -0400580 build/tools/generate-notice-files.py $(1) $(2) $$(PRIVATE_MESSAGE) $$(PRIVATE_DIR)/src
Steve Block495e5852012-02-29 19:18:08 +0000581notice_files: $(1) $(2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800582endef
583
584# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
585# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
586# the src subdirectory.
587
Steve Block495e5852012-02-29 19:18:08 +0000588target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800589target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
590target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
Steve Block495e5852012-02-29 19:18:08 +0000591tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800592tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
593
Ying Wang62c81f82013-08-22 20:02:03 -0700594ifndef TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800595kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
Ying Wang4534d812012-04-09 17:04:12 -0700596pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800597
598$(eval $(call combine-notice-files, \
Steve Block495e5852012-02-29 19:18:08 +0000599 $(target_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800600 $(target_notice_file_html), \
601 "Notices for files contained in the filesystem images in this directory:", \
602 $(TARGET_OUT_NOTICE_FILES), \
Ying Wang4534d812012-04-09 17:04:12 -0700603 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800604
605$(eval $(call combine-notice-files, \
Steve Block495e5852012-02-29 19:18:08 +0000606 $(tools_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800607 $(tools_notice_file_html), \
608 "Notices for files contained in the tools directory:", \
609 $(HOST_OUT_NOTICE_FILES), \
610 $(ALL_DEFAULT_INSTALLED_MODULES)))
611
612# Install the html file at /system/etc/NOTICE.html.gz.
613# This is not ideal, but this is very late in the game, after a lot of
614# the module processing has already been done -- in fact, we used the
615# fact that all that has been done to get the list of modules that we
616# need notice files for.
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700617$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700618 $(hide) $(MINIGZIP) -9 < $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800619installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
620$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
621 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700622
623# if we've been run my mm, mmm, etc, don't reinstall this every time
624ifeq ($(ONE_SHOT_MAKEFILE),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800625ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700626endif
Ying Wang62c81f82013-08-22 20:02:03 -0700627endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800628
629# The kernel isn't really a module, so to get its module file in there, we
630# make the target NOTICE files depend on this particular file too, which will
631# then be in the right directory for the find in combine-notice-files to work.
632$(kernel_notice_file): \
Jean-Baptiste Querua230c4d2012-01-06 15:05:53 -0800633 prebuilts/qemu-kernel/arm/LINUX_KERNEL_COPYING \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800634 | $(ACP)
635 @echo Copying: $@
636 $(hide) mkdir -p $(dir $@)
637 $(hide) $(ACP) $< $@
638
639
Doug Zongker8678df42009-06-15 14:30:14 -0700640# -----------------------------------------------------------------
641# Build a keystore with the authorized keys in it, used to verify the
642# authenticity of downloaded OTA packages.
643#
644# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
645# before the rules that use that variable to build the image.
646ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
647$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Doug Zongker37c0e272009-06-15 15:36:16 -0700648$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Doug Zongker8678df42009-06-15 14:30:14 -0700649 $(hide) rm -f $@
650 $(hide) mkdir -p $(dir $@)
Doug Zongker37c0e272009-06-15 15:36:16 -0700651 $(hide) zip -qj $@ $<
Doug Zongker8678df42009-06-15 14:30:14 -0700652
653.PHONY: otacerts
654otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
655
656
The Android Open Source Project88b60792009-03-03 19:28:42 -0800657# #################################################################
658# Targets for user images
659# #################################################################
660
Ying Wang933abf12010-06-16 14:31:34 -0700661INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800662ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -0700663INTERNAL_USERIMAGES_USE_EXT := true
664INTERNAL_USERIMAGES_EXT_VARIANT := ext2
665else
666ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
667INTERNAL_USERIMAGES_USE_EXT := true
668INTERNAL_USERIMAGES_EXT_VARIANT := ext3
669else
670ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
671INTERNAL_USERIMAGES_USE_EXT := true
672INTERNAL_USERIMAGES_EXT_VARIANT := ext4
673endif
674endif
675endif
676
JP Abgrall6ea5bd62014-10-22 20:01:22 -0700677# These options tell the recovery updater/installer how to mount the partitions writebale.
678# <fstype>=<fstype_opts>[|<fstype_opts>]...
679# fstype_opts := <opt>[,<opt>]...
680# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -0700681# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
682DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS := ext4=max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc
JP Abgrall6ea5bd62014-10-22 20:01:22 -0700683
Ying Wang542903a2010-11-17 15:40:38 -0800684ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
685 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
686endif
687
Colin Cross0a7b2c52010-05-07 02:23:59 -0700688ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
JP Abgrall5bfed5a2014-06-16 14:17:40 -0700689INTERNAL_USERIMAGES_DEPS := $(SIMG2IMG)
690INTERNAL_USERIMAGES_DEPS += $(MKEXTUSERIMG) $(MAKE_EXT4FS) $(E2FSCK)
691ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
692INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG) $(MAKE_F2FS)
693endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800694else
Colin Cross144b0282010-05-10 13:04:47 -0700695INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800696endif
JP Abgrall5bfed5a2014-06-16 14:17:40 -0700697
Ying Wang178ef922011-10-31 18:13:30 -0700698INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800699
Colin Cross8a30f722014-04-28 16:27:32 -0700700ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY))
Colin Cross477cf2b2014-04-16 18:49:56 -0700701INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Geremy Condrafd6f7512013-06-16 17:26:08 -0700702endif
703
Ying Wangfdbd9cb2012-11-21 10:47:00 -0800704SELINUX_FC := $(TARGET_ROOT_OUT)/file_contexts
705INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
706
Ying Wangbd93d422011-10-28 17:02:30 -0700707# $(1): the path of the output dictionary file
Ying Wang6a42a252013-02-27 13:54:02 -0800708# $(2): additional "key=value" pairs to append to the dictionary file.
Ying Wangbd93d422011-10-28 17:02:30 -0700709define generate-userimage-prop-dictionary
710$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
711$(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
JP Abgrall5bfed5a2014-06-16 14:17:40 -0700712$(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -0700713$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wang9f8e8db2011-11-04 11:37:01 -0700714$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
715$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wanga0febe52013-03-20 11:02:05 -0700716$(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
717$(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangb8888432014-03-11 17:13:27 -0700718$(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -0700719$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
720$(if $(mkyaffs2_extra_flags),$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(1))
Ying Wangfdbd9cb2012-11-21 10:47:00 -0800721$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
Daniel Rosenbergf4eabc32014-07-10 15:42:38 -0700722$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)" >> $(1))
Geremy Condra5b5f4952014-05-05 22:19:37 -0700723$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
724$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(VERITY_SIGNER)" >> $(1))
Daniel Rosenbergf4eabc32014-07-10 15:42:38 -0700725$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
726$(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 -0800727$(if $(2),$(hide) $(foreach kv,$(2),echo "$(kv)" >> $(1);))
Ying Wangbd93d422011-10-28 17:02:30 -0700728endef
729
The Android Open Source Project88b60792009-03-03 19:28:42 -0800730# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -0700731# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700732
733# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
Mike Lockwooddaf5e222012-10-18 10:17:47 -0700734ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700735
Doug Zongker4647f122009-07-02 09:00:54 -0700736INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
737
738recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
Stephen Smalley5520f282014-05-29 16:41:03 -0400739recovery_sepolicy := $(call intermediates-dir-for,ETC,sepolicy.recovery)/sepolicy.recovery
Doug Zongker4647f122009-07-02 09:00:54 -0700740recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
741recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
742recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
743recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
744recovery_resources_common := $(call include-path-for, recovery)/res
Doug Zongkere1297322013-03-06 15:04:31 -0800745
Doug Zongker8eaeea92014-05-12 15:32:20 -0700746# Set recovery_density to the density bucket of the device.
747recovery_density := unknown
748ifneq (,$(PRODUCT_AAPT_PREF_CONFIG))
749# If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value.
750recovery_density := $(filter %dpi,$(PRODUCT_AAPT_PREF_CONFIG))
Doug Zongker25d55f82014-04-04 13:51:15 -0700751else
Doug Zongker8eaeea92014-05-12 15:32:20 -0700752# Otherwise, use the highest density that appears in PRODUCT_AAPT_CONFIG.
753# Order is important here; we'll take the first one that's found.
Joe LaPenna792ab6c2014-07-15 16:51:42 -0700754recovery_densities := $(filter $(PRODUCT_AAPT_CONFIG_SP),xxxhdpi xxhdpi xhdpi hdpi tvdpi mdpi ldpi)
Doug Zongker8eaeea92014-05-12 15:32:20 -0700755ifneq (,$(recovery_densities))
756recovery_density := $(word 1,$(recovery_densities))
757endif
758endif
759
760ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
761recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
762else
Doug Zongker25d55f82014-04-04 13:51:15 -0700763recovery_resources_common := $(recovery_resources_common)-xhdpi
764endif
765
Doug Zongker8eaeea92014-05-12 15:32:20 -0700766# Select the 18x32 font on high-density devices (xhdpi and up); and
767# the 12x22 font on other devices. Note that the font selected here
768# can be overridden for a particular device by putting a font.png in
769# its private recovery resources.
770
771ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Doug Zongkere1297322013-03-06 15:04:31 -0800772recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
773else
774recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
775endif
776
Doug Zongker4647f122009-07-02 09:00:54 -0700777recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
778recovery_resource_deps := $(shell find $(recovery_resources_common) \
779 $(recovery_resources_private) -type f)
Andrew Boiefa61ff02012-09-28 09:33:45 -0700780ifdef TARGET_RECOVERY_FSTAB
781recovery_fstab := $(TARGET_RECOVERY_FSTAB)
782else
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700783recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -0700784endif
Doug Zongker56588872012-08-20 15:38:58 -0700785# Named '.dat' so we don't attempt to use imgdiff for patching it.
786RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
Doug Zongker4647f122009-07-02 09:00:54 -0700787
788ifeq ($(recovery_resources_private),)
789 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
790endif
791
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700792ifeq ($(recovery_fstab),)
793 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
794endif
795
Doug Zongker4647f122009-07-02 09:00:54 -0700796INTERNAL_RECOVERYIMAGE_ARGS := \
797 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
798 --kernel $(recovery_kernel) \
799 --ramdisk $(recovery_ramdisk)
800
801# Assumes this has already been stripped
802ifdef BOARD_KERNEL_CMDLINE
803 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
804endif
805ifdef BOARD_KERNEL_BASE
806 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
807endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700808BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
809ifdef BOARD_KERNEL_PAGESIZE
810 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
811endif
Doug Zongker4647f122009-07-02 09:00:54 -0700812
813# Keys authorized to sign OTA packages this build will accept. The
Ying Wang3c21fe52011-10-04 10:50:08 -0700814# build always uses dev-keys for this; release packaging tools will
Doug Zongker4647f122009-07-02 09:00:54 -0700815# substitute other keys for this one.
Ying Wang3c21fe52011-10-04 10:50:08 -0700816OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem
Doug Zongker4647f122009-07-02 09:00:54 -0700817
818# Generate a file containing the keys that will be read by the
819# recovery binary.
820RECOVERY_INSTALL_OTA_KEYS := \
821 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
822DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
823$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
Doug Zongker5d4808d2011-03-16 07:49:13 -0700824$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
Doug Zongkere121d6a2011-02-01 14:13:52 -0800825$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys)
826 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
Doug Zongker4647f122009-07-02 09:00:54 -0700827 @rm -rf $@
828 @mkdir -p $(dir $@)
Doug Zongkere121d6a2011-02-01 14:13:52 -0800829 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
Doug Zongker4647f122009-07-02 09:00:54 -0700830
831$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
832 $(INSTALLED_RAMDISK_TARGET) \
833 $(INSTALLED_BOOTIMAGE_TARGET) \
834 $(recovery_binary) \
Stephen Smalley5520f282014-05-29 16:41:03 -0400835 $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
Doug Zongker4647f122009-07-02 09:00:54 -0700836 $(INSTALLED_2NDBOOTLOADER_TARGET) \
837 $(recovery_build_prop) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700838 $(recovery_fstab) \
Doug Zongker4647f122009-07-02 09:00:54 -0700839 $(RECOVERY_INSTALL_OTA_KEYS)
840 @echo ----- Making recovery image ------
Doug Zongker72f0b672012-08-08 16:26:17 -0700841 $(hide) rm -rf $(TARGET_RECOVERY_OUT)
842 $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
843 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/tmp
844 @echo Copying baseline ramdisk...
845 $(hide) cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
846 @echo Modifying ramdisk contents...
847 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
848 $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
Stephen Smalley5520f282014-05-29 16:41:03 -0400849 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/sepolicy
850 $(hide) cp -f $(recovery_sepolicy) $(TARGET_RECOVERY_ROOT_OUT)/sepolicy
Doug Zongker72f0b672012-08-08 16:26:17 -0700851 $(hide) -cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/
852 $(hide) cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
Doug Zongker25d55f82014-04-04 13:51:15 -0700853 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
854 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
855 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
Doug Zongkere1297322013-03-06 15:04:31 -0800856 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
Doug Zongker72f0b672012-08-08 16:26:17 -0700857 $(hide) $(foreach item,$(recovery_resources_private), \
Doug Zongker4647f122009-07-02 09:00:54 -0700858 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
Doug Zongker72f0b672012-08-08 16:26:17 -0700859 $(hide) $(foreach item,$(recovery_fstab), \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700860 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Doug Zongker72f0b672012-08-08 16:26:17 -0700861 $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
862 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
Doug Zongker4647f122009-07-02 09:00:54 -0700863 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Doug Zongker72f0b672012-08-08 16:26:17 -0700864 $(hide) $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
865 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Andrew Boie194418c2014-08-20 14:43:06 -0700866ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY))
867 $(BOOT_SIGNER) /recovery $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY) $@
868endif
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700869 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))
Doug Zongker72f0b672012-08-08 16:26:17 -0700870 @echo ----- Made recovery image: $@ --------
Doug Zongker4647f122009-07-02 09:00:54 -0700871
Doug Zongker56588872012-08-20 15:38:58 -0700872$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
Doug Zongker1a097262012-09-04 14:45:11 -0700873 $(hide) mkdir -p $(dir $@)
Doug Zongker56588872012-08-20 15:38:58 -0700874 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@
875
Doug Zongker4647f122009-07-02 09:00:54 -0700876else
877INSTALLED_RECOVERYIMAGE_TARGET :=
Doug Zongker56588872012-08-20 15:38:58 -0700878RECOVERY_RESOURCE_ZIP :=
Doug Zongker4647f122009-07-02 09:00:54 -0700879endif
880
881.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -0700882recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -0700883
Dima Zavin11818982010-02-05 13:34:34 -0800884ifneq ($(BOARD_NAND_PAGE_SIZE),)
885mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
886else
887mkyaffs2_extra_flags :=
Lars Svensson9cb8c282010-12-06 15:24:58 +0100888BOARD_NAND_PAGE_SIZE := 2048
Dima Zavin11818982010-02-05 13:34:34 -0800889endif
890
Naseer Ahmed53871882010-08-06 12:19:29 -0700891ifneq ($(BOARD_NAND_SPARE_SIZE),)
892mkyaffs2_extra_flags += -s $(BOARD_NAND_SPARE_SIZE)
Lars Svensson9cb8c282010-12-06 15:24:58 +0100893else
894BOARD_NAND_SPARE_SIZE := 64
Naseer Ahmed53871882010-08-06 12:19:29 -0700895endif
896
Doug Zongker4647f122009-07-02 09:00:54 -0700897# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -0700898# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800899#
Ying Wang9c649a72012-08-08 15:27:00 -0700900# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
901PDK_FUSION_SYSIMG_FILES := \
902 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
903 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800904
905INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -0700906 $(ALL_PREBUILT) \
907 $(ALL_COPIED_HEADERS) \
908 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -0700909 $(ALL_DEFAULT_INSTALLED_MODULES) \
910 $(PDK_FUSION_SYSIMG_FILES) \
911 $(RECOVERY_RESOURCE_ZIP))
Ying Wang160b6702012-03-13 18:58:27 -0700912
Ying Wang82cceba2012-08-13 15:03:00 -0700913FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Ying Wange5e8c5f2011-09-09 16:35:53 -0700914# -----------------------------------------------------------------
915# installed file list
916# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
917# We put installed-files.txt ahead of image itself in the dependency graph
918# so that we can get the size stat even if the build fails due to too large
919# system image.
920INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
921$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS)
922 @echo Installed file list: $@
923 @mkdir -p $(dir $@)
924 @rm -f $@
925 $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@
926
927.PHONY: installed-file-list
928installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -0800929
930$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -0700931
932systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -0700933 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -0700934BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
935
Ying Wang23898df2014-06-18 20:26:24 -0700936# Create symlink /system/vendor to /vendor if necessary.
937ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
938define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -0700939$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
940 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
941 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
942 exit 1; \
943fi
Ying Wang23898df2014-06-18 20:26:24 -0700944$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
945endef
946else
947define create-system-vendor-symlink
948endef
949endif
950
The Android Open Source Project88b60792009-03-03 19:28:42 -0800951# $(1): output file
952define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -0700953 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -0700954 $(call create-system-vendor-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -0700955 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Geremy Condrafd6f7512013-06-16 17:26:08 -0700956 $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt, \
Geremy Condra5b5f4952014-05-05 22:19:37 -0700957 skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -0700958 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
959 ./build/tools/releasetools/build_image.py \
Ying Wang45ff36e2014-08-13 12:36:05 -0700960 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) \
961 || ( echo "Out of space? the tree size of $(TARGET_OUT) is (MB): " 1>&2 ;\
962 du -sm $(TARGET_OUT) 1>&2;\
963 echo "The max is $$(( $(BOARD_SYSTEMIMAGE_PARTITION_SIZE) / 1048576 )) MB." 1>&2 ;\
Ying Wangebe63fb2014-08-19 12:21:35 -0700964 mkdir -p $(DIST_DIR); cp $(INSTALLED_FILES_FILE) $(DIST_DIR)/installed-files-rescued.txt; \
Ying Wang45ff36e2014-08-13 12:36:05 -0700965 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -0800966endef
967
Ying Wange5e8c5f2011-09-09 16:35:53 -0700968$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800969 $(call build-systemimage-target,$@)
970
The Android Open Source Project88b60792009-03-03 19:28:42 -0800971INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700972SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800973
Doug Zongker73ef8252009-07-23 15:12:53 -0700974# The system partition needs room for the recovery image as well. We
975# now store the recovery image as a binary patch using the boot image
976# as the source (since they are very similar). Generate the patch so
977# we can see how big it's going to be, and include that in the system
978# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700979ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700980intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
981RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
982$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
983 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700984 $(HOST_OUT_EXECUTABLES)/imgdiff \
985 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700986 @echo "Construct recovery from boot"
987 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700988 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700989endif
990
Doug Zongker73ef8252009-07-23 15:12:53 -0700991
992$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800993 @echo "Install system fs image: $@"
994 $(copy-file-to-target)
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700995 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800996
997systemimage: $(INSTALLED_SYSTEMIMAGE)
998
999.PHONY: systemimage-nodeps snod
1000systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07001001 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001002 @echo "make $@: ignoring dependencies"
1003 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001004 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001005
Ying Wangacf01ec2012-02-24 11:05:48 -08001006ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
1007ifeq (true,$(WITH_DEXPREOPT))
1008$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
1009endif
1010endif
1011
The Android Open Source Project88b60792009-03-03 19:28:42 -08001012#######
1013## system tarball
1014define build-systemtarball-target
Ying Wang23898df2014-06-18 20:26:24 -07001015 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
1016 $(call create-system-vendor-symlink)
1017 $(MKTARBALL) $(FS_GET_STATS) \
1018 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
1019 $(INSTALLED_SYSTEMTARBALL_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001020endef
1021
Bruce Beare69ef5ce2010-06-11 12:05:57 -07001022ifndef SYSTEM_TARBALL_FORMAT
1023 SYSTEM_TARBALL_FORMAT := bz2
1024endif
1025
The Android Open Source Project88b60792009-03-03 19:28:42 -08001026system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -07001027INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001028$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
1029$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
1030 $(build-systemtarball-target)
1031
1032.PHONY: systemtarball-nodeps
1033systemtarball-nodeps: $(FS_GET_STATS) \
1034 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
1035 $(build-systemtarball-target)
1036
1037.PHONY: stnod
1038stnod: systemtarball-nodeps
1039
Ying Wang4c289e52012-03-30 13:52:54 -07001040#######
Ying Wang4534d812012-04-09 17:04:12 -07001041## platform.zip: system, plus other files to be used in PDK fusion build,
1042## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07001043##
1044## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
1045## The variable will be typically set from BoardConfig.mk.
1046## Files under out dir will be rejected to prevent possible conflicts with other rules.
1047PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07001048INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
1049$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES)
1050 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Ying Wang4c289e52012-03-30 13:52:54 -07001051 $(hide) rm -f $@
Ying Wang4534d812012-04-09 17:04:12 -07001052 $(hide) cd $(dir $@) && zip -qry $(notdir $@) \
1053 $(TARGET_COPY_OUT_SYSTEM) \
Keun young Park72226692012-07-31 17:13:20 -07001054 $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \
1055 $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST))
Ying Wangcff38622014-07-16 17:46:35 -07001056ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1057 $(hide) cd $(dir $@) && zip -qry $(notdir $@) \
1058 $(TARGET_COPY_OUT_VENDOR)
1059endif
Colin Crossc451a372013-12-18 19:36:44 -08001060ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Ying Wang28a18172012-06-02 09:22:31 -07001061 $(hide) cd $(OUT_DIR) && zip -qry $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
Keun young Park816b9fd2012-05-16 10:32:41 -07001062endif
keunyoungc0178062013-07-22 14:54:58 -07001063ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
1064 $(hide) zip -qry $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
1065endif
Ying Wang4c289e52012-03-30 13:52:54 -07001066
1067.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07001068platform: $(INSTALLED_PLATFORM_ZIP)
1069
1070.PHONY: platform-java
1071platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07001072
1073# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07001074ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
1075$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07001076endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001077
Bruce Beare52aac202010-06-04 15:24:49 -07001078#######
1079## boot tarball
1080define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -07001081 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -07001082 $(hide) mkdir -p $(PRODUCT_OUT)/boot
1083 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
1084 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
1085 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
1086 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
1087 $(INSTALLED_BOOTTARBALL_TARGET)
1088endef
1089
1090ifndef BOOT_TARBALL_FORMAT
1091 BOOT_TARBALL_FORMAT := bz2
1092endif
1093
1094boot_tar := $(PRODUCT_OUT)/boot.tar
1095INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
1096$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
1097$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
1098 $(build-boottarball-target)
1099
1100.PHONY: boottarball-nodeps btnod
1101boottarball-nodeps btnod: $(FS_GET_STATS) \
1102 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
1103 $(build-boottarball-target)
1104
1105
The Android Open Source Project88b60792009-03-03 19:28:42 -08001106# -----------------------------------------------------------------
1107# data partition image
1108INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001109 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001110
Ying Wangd7321d32013-03-15 10:32:29 -07001111# Don't build userdata.img if it's extfs but no partition size
1112skip_userdata.img :=
1113ifdef INTERNAL_USERIMAGES_EXT_VARIANT
1114ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE
1115skip_userdata.img := true
1116endif
1117endif
1118
1119ifneq ($(skip_userdata.img),true)
Ying Wangbd93d422011-10-28 17:02:30 -07001120userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001121 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07001122BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
1123
Ying Wangbd93d422011-10-28 17:02:30 -07001124define build-userdataimage-target
1125 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
1126 @mkdir -p $(TARGET_OUT_DATA)
1127 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001128 $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt, skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07001129 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1130 ./build/tools/releasetools/build_image.py \
Ying Wang178ef922011-10-31 18:13:30 -07001131 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001132 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07001133endef
1134
Joe Onorato64d85d02009-04-09 19:31:12 -07001135# We just build this directly to the install location.
1136INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -07001137$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001138 $(INTERNAL_USERDATAIMAGE_FILES)
1139 $(build-userdataimage-target)
1140
1141.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07001142userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001143 $(build-userdataimage-target)
1144
Ying Wangd7321d32013-03-15 10:32:29 -07001145endif # not skip_userdata.img
1146skip_userdata.img :=
Ying Wange215ed52012-10-15 14:36:22 -07001147
The Android Open Source Project88b60792009-03-03 19:28:42 -08001148#######
1149## data partition tarball
1150define build-userdatatarball-target
1151 $(call pretty,"Target userdata fs tarball: " \
1152 "$(INSTALLED_USERDATATARBALL_TARGET)")
1153 $(MKTARBALL) $(FS_GET_STATS) \
1154 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
1155 $(INSTALLED_USERDATATARBALL_TARGET)
1156endef
1157
1158userdata_tar := $(PRODUCT_OUT)/userdata.tar
1159INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
1160$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
1161$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
1162 $(build-userdatatarball-target)
1163
1164.PHONY: userdatatarball-nodeps
1165userdatatarball-nodeps: $(FS_GET_STATS)
1166 $(build-userdatatarball-target)
1167
1168
The Android Open Source Project88b60792009-03-03 19:28:42 -08001169# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07001170# cache partition image
1171ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1172INTERNAL_CACHEIMAGE_FILES := \
1173 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
1174
1175cacheimage_intermediates := \
1176 $(call intermediates-dir-for,PACKAGING,cache)
1177BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
1178
1179define build-cacheimage-target
1180 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
1181 @mkdir -p $(TARGET_OUT_CACHE)
1182 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001183 $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt, skip_fsck=true)
Ying Wang9f8e8db2011-11-04 11:37:01 -07001184 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1185 ./build/tools/releasetools/build_image.py \
1186 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001187 $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07001188endef
1189
1190# We just build this directly to the install location.
1191INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
1192$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
1193 $(build-cacheimage-target)
1194
1195.PHONY: cacheimage-nodeps
1196cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1197 $(build-cacheimage-target)
1198
1199endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1200
Ying Wanga0febe52013-03-20 11:02:05 -07001201
1202# -----------------------------------------------------------------
1203# vendor partition image
1204ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1205INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07001206 $(filter $(TARGET_OUT_VENDOR)/%,\
1207 $(ALL_DEFAULT_INSTALLED_MODULES)\
1208 $(ALL_PDK_FUSION_FILES))
1209
1210# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
1211$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07001212
1213vendorimage_intermediates := \
1214 $(call intermediates-dir-for,PACKAGING,vendor)
1215BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
1216
1217define build-vendorimage-target
1218 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
1219 @mkdir -p $(TARGET_OUT_VENDOR)
1220 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
1221 $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true)
1222 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1223 ./build/tools/releasetools/build_image.py \
1224 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -07001225 $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07001226endef
1227
1228# We just build this directly to the install location.
1229INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
1230$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES)
1231 $(build-vendorimage-target)
1232
1233.PHONY: vendorimage-nodeps
1234vendorimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1235 $(build-vendorimage-target)
1236
1237endif # BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1238
Ying Wang9f8e8db2011-11-04 11:37:01 -07001239# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07001240# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08001241
Colin Crossc312f312012-04-19 13:54:39 -07001242DISTTOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -07001243 $(HOST_OUT_EXECUTABLES)/mkbootfs \
1244 $(HOST_OUT_EXECUTABLES)/mkbootimg \
1245 $(HOST_OUT_EXECUTABLES)/fs_config \
1246 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
1247 $(HOST_OUT_EXECUTABLES)/zipalign \
Doug Zongker8678df42009-06-15 14:30:14 -07001248 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -07001249 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -07001250 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -07001251 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
1252 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
Ying Wang7dc45a82013-01-04 14:43:18 -08001253 $(HOST_OUT_EXECUTABLES)/make_ext4fs \
1254 $(HOST_OUT_EXECUTABLES)/simg2img \
Doug Zongker5fad2032014-02-24 08:13:45 -08001255 $(HOST_OUT_EXECUTABLES)/e2fsck \
Doug Zongker9843fd82014-05-13 14:17:13 -07001256 $(HOST_OUT_EXECUTABLES)/build_verity_tree \
1257 $(HOST_OUT_EXECUTABLES)/verity_signer \
Geremy Condra740b6632014-07-08 20:07:41 -07001258 $(HOST_OUT_EXECUTABLES)/append2simg \
1259 $(HOST_OUT_EXECUTABLES)/boot_signer
The Android Open Source Project88b60792009-03-03 19:28:42 -08001260
Colin Crossc312f312012-04-19 13:54:39 -07001261OTATOOLS := $(DISTTOOLS) \
1262 $(HOST_OUT_EXECUTABLES)/aapt
1263
Ying Wang06898662010-06-17 17:52:18 -07001264.PHONY: otatools
1265otatools: $(OTATOOLS)
1266
The Android Open Source Project88b60792009-03-03 19:28:42 -08001267# -----------------------------------------------------------------
1268# A zip of the directories that map to the target filesystem.
1269# This zip can be used to create an OTA package or filesystem image
1270# as a post-build step.
1271#
1272name := $(TARGET_PRODUCT)
1273ifeq ($(TARGET_BUILD_TYPE),debug)
1274 name := $(name)_debug
1275endif
1276name := $(name)-target_files-$(FILE_NAME_TAG)
1277
1278intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
1279BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
1280$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
1281$(BUILT_TARGET_FILES_PACKAGE): \
1282 zip_root := $(intermediates)/$(name)
1283
1284# $(1): Directory to copy
1285# $(2): Location to copy it to
1286# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
1287define package_files-copy-root
1288 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
1289 mkdir -p $(2) && \
1290 $(ACP) -rd $(strip $(1))/* $(2); \
1291 fi
1292endef
1293
1294built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -07001295 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -07001296 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001297 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
Doug Zongker25863d72011-09-19 15:02:03 -07001298 $(call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001299 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -08001300$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
1301
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001302$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
Ken Sumrall31ce31f2013-02-21 16:27:25 -08001303$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION)
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001304
Doug Zongkerc18736b2009-09-30 09:20:32 -07001305ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1306# default to common dir for device vendor
1307$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
1308else
1309$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1310endif
1311
The Android Open Source Project88b60792009-03-03 19:28:42 -08001312# Depending on the various images guarantees that the underlying
1313# directories are up-to-date.
1314$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001315 $(INSTALLED_BOOTIMAGE_TARGET) \
1316 $(INSTALLED_RADIOIMAGE_TARGET) \
1317 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -07001318 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001319 $(INSTALLED_USERDATAIMAGE_TARGET) \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001320 $(INSTALLED_CACHEIMAGE_TARGET) \
Ying Wanga0febe52013-03-20 11:02:05 -07001321 $(INSTALLED_VENDORIMAGE_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001322 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001323 $(SELINUX_FC) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001324 $(built_ota_tools) \
1325 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -07001326 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001327 | $(ACP)
1328 @echo "Package target files: $@"
1329 $(hide) rm -rf $@ $(zip_root)
1330 $(hide) mkdir -p $(dir $@) $(zip_root)
1331 @# Components of the recovery image
1332 $(hide) mkdir -p $(zip_root)/RECOVERY
1333 $(hide) $(call package_files-copy-root, \
1334 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
1335ifdef INSTALLED_KERNEL_TARGET
1336 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
1337endif
1338ifdef INSTALLED_2NDBOOTLOADER_TARGET
1339 $(hide) $(ACP) \
1340 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
1341endif
1342ifdef BOARD_KERNEL_CMDLINE
1343 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
1344endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001345ifdef BOARD_KERNEL_BASE
1346 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
1347endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001348ifdef BOARD_KERNEL_PAGESIZE
1349 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
1350endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001351 @# Components of the boot image
1352 $(hide) mkdir -p $(zip_root)/BOOT
1353 $(hide) $(call package_files-copy-root, \
1354 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1355ifdef INSTALLED_KERNEL_TARGET
1356 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1357endif
1358ifdef INSTALLED_2NDBOOTLOADER_TARGET
1359 $(hide) $(ACP) \
1360 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1361endif
1362ifdef BOARD_KERNEL_CMDLINE
1363 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1364endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001365ifdef BOARD_KERNEL_BASE
1366 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1367endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001368ifdef BOARD_KERNEL_PAGESIZE
1369 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1370endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001371 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1372 mkdir -p $(zip_root)/RADIO; \
1373 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001374 @# Contents of the system image
1375 $(hide) $(call package_files-copy-root, \
1376 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1377 @# Contents of the data image
1378 $(hide) $(call package_files-copy-root, \
1379 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Ying Wanga0febe52013-03-20 11:02:05 -07001380ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1381 @# Contents of the vendor image
1382 $(hide) $(call package_files-copy-root, \
1383 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
1384endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001385 @# Extra contents of the OTA package
1386 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001387 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1388 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001389 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001390 @# build them.
1391 $(hide) mkdir -p $(zip_root)/META
1392 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker816d73f2013-11-22 13:29:55 -08001393 $(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 -07001394 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -07001395 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Ken Sumrall31ce31f2013-02-21 16:27:25 -08001396 $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001397ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07001398 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001399endif
1400ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001401 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001402endif
1403ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001404 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001405endif
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001406ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
1407 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
1408 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
1409else
1410 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
1411endif
Doug Zongker37974732010-09-16 17:44:38 -07001412 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wang3c21fe52011-10-04 10:50:08 -07001413 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
Doug Zongker5d4808d2011-03-16 07:49:13 -07001414ifdef PRODUCT_EXTRA_RECOVERY_KEYS
1415 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
Doug Zongkere121d6a2011-02-01 14:13:52 -08001416endif
Jianxun Zhang09849492013-04-17 15:19:19 -07001417 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001418 $(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt
Doug Zongker9b23f2c2013-11-25 14:44:12 -08001419 $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
Michael Rungefacd9922013-12-20 11:50:16 -08001420 $(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt
Ying Wange24e17a2014-10-07 18:42:11 -07001421ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
Jeff Sharkey26e1a282014-03-21 16:20:05 -07001422 # OTA scripts are only interested in fingerprint related properties
Ying Wange24e17a2014-10-07 18:42:11 -07001423 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt
Vineeta Srivastava27262112014-09-18 14:34:00 -07001424endif
Ying Wangbd93d422011-10-28 17:02:30 -07001425 $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
Doug Zongkerc9253822014-02-04 12:17:58 -08001426 $(hide) ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001427 @# Zip everything up, preserving symlinks
1428 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongkerc8b4e842014-06-16 15:16:31 -07001429 @# Run fs_config on all the system, vendor, boot ramdisk,
1430 @# and recovery ramdisk files in the zip, and save the output
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001431 $(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 -07001432 $(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 -07001433 $(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
1434 $(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 -07001435 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
Doug Zongker85448772014-09-09 14:59:20 -07001436 $(hide) ./build/tools/releasetools/add_img_to_target_files -p $(HOST_OUT) $@
Doug Zongker283e2a12010-03-15 17:52:32 -07001437
Ying Wanga0febe52013-03-20 11:02:05 -07001438.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001439target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1440
Ying Wang4709d7c2014-04-14 17:25:43 -07001441ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
1442$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
1443endif
Doug Zongker367910f2009-06-15 18:56:51 -07001444
Doug Zongker367910f2009-06-15 18:56:51 -07001445ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang279f3082011-02-09 12:26:42 -08001446ifeq ($(filter generic%,$(TARGET_DEVICE)),)
Ying Wangfb0a3472010-08-25 16:06:06 -07001447ifneq ($(TARGET_NO_KERNEL),true)
Ying Wanga73b6562011-03-03 21:52:08 -08001448ifneq ($(recovery_fstab),)
Doug Zongker367910f2009-06-15 18:56:51 -07001449
Ying Wang09a00a62010-10-20 14:01:09 -07001450# -----------------------------------------------------------------
1451# OTA update package
1452
Doug Zongker8678df42009-06-15 14:30:14 -07001453name := $(TARGET_PRODUCT)
1454ifeq ($(TARGET_BUILD_TYPE),debug)
1455 name := $(name)_debug
1456endif
1457name := $(name)-ota-$(FILE_NAME_TAG)
1458
1459INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1460
1461$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1462
Ying Wang82cceba2012-08-13 15:03:00 -07001463$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001464 @echo "Package OTA: $@"
Ying Wang42c98042014-06-18 11:31:21 -07001465 $(hide) MKBOOTIMG=$(MKBOOTIMG) \
Bjorn Andersson612e2cd2012-11-25 16:53:44 -08001466 ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker26e66192014-02-20 13:22:07 -08001467 --block \
Doug Zongker602a84e2009-06-18 08:35:12 -07001468 -p $(HOST_OUT) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05001469 -k $(KEY_CERT_PAIR) \
Michael Runge6e836112014-04-15 17:40:21 -07001470 $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05001471 $(BUILT_TARGET_FILES_PACKAGE) $@
Doug Zongker8678df42009-06-15 14:30:14 -07001472
1473.PHONY: otapackage
1474otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1475
Ying Wangf8824af2014-06-03 14:07:27 -07001476endif # recovery_fstab is defined
1477endif # TARGET_NO_KERNEL != true
1478endif # TARGET_DEVICE != generic*
1479endif # TARGET_PRODUCT != sdk
1480
Ying Wang09a00a62010-10-20 14:01:09 -07001481# -----------------------------------------------------------------
1482# The update package
1483
1484name := $(TARGET_PRODUCT)
1485ifeq ($(TARGET_BUILD_TYPE),debug)
1486 name := $(name)_debug
1487endif
1488name := $(name)-img-$(FILE_NAME_TAG)
1489
1490INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1491
Ying Wang82cceba2012-08-13 15:03:00 -07001492$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
Ying Wang09a00a62010-10-20 14:01:09 -07001493 @echo "Package: $@"
Ying Wang42c98042014-06-18 11:31:21 -07001494 $(hide) MKBOOTIMG=$(MKBOOTIMG) \
Bjorn Andersson612e2cd2012-11-25 16:53:44 -08001495 ./build/tools/releasetools/img_from_target_files -v \
Ying Wang09a00a62010-10-20 14:01:09 -07001496 -p $(HOST_OUT) \
1497 $(BUILT_TARGET_FILES_PACKAGE) $@
1498
1499.PHONY: updatepackage
1500updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
1501
The Android Open Source Project88b60792009-03-03 19:28:42 -08001502# -----------------------------------------------------------------
1503# A zip of the symbols directory. Keep the full paths to make it
1504# more obvious where these files came from.
1505#
1506name := $(TARGET_PRODUCT)
1507ifeq ($(TARGET_BUILD_TYPE),debug)
1508 name := $(name)_debug
1509endif
1510name := $(name)-symbols-$(FILE_NAME_TAG)
1511
1512SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1513$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1514 @echo "Package symbols: $@"
1515 $(hide) rm -rf $@
1516 $(hide) mkdir -p $(dir $@)
1517 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1518
1519# -----------------------------------------------------------------
1520# A zip of the Android Apps. Not keeping full path so that we don't
1521# include product names when distributing
1522#
1523name := $(TARGET_PRODUCT)
1524ifeq ($(TARGET_BUILD_TYPE),debug)
1525 name := $(name)_debug
1526endif
1527name := $(name)-apps-$(FILE_NAME_TAG)
1528
1529APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1530$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1531 @echo "Package apps: $@"
1532 $(hide) rm -rf $@
1533 $(hide) mkdir -p $(dir $@)
Ying Wang2ce3d5c2014-07-18 19:15:15 -07001534 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*/*.apk $(TARGET_OUT_APPS_PRIVILEGED)/*/*.apk
The Android Open Source Project88b60792009-03-03 19:28:42 -08001535
Guang Zhu0198d6e2010-04-23 11:54:37 -07001536
1537#------------------------------------------------------------------
1538# A zip of emma code coverage meta files. Generated for fully emma
1539# instrumented build.
1540#
Ying Wangbc415dd2012-08-15 12:22:44 -07001541ifeq (true,$(EMMA_INSTRUMENT))
Guang Zhu0198d6e2010-04-23 11:54:37 -07001542EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
Ying Wangbc415dd2012-08-15 12:22:44 -07001543# the dependency will be set up later in build/core/main.mk.
1544$(EMMA_META_ZIP) :
Guang Zhu0198d6e2010-04-23 11:54:37 -07001545 @echo "Collecting Emma coverage meta files."
Ying Wang1ff08362013-12-27 15:55:08 -08001546 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "coverage.em" | \
Guang Zhu0198d6e2010-04-23 11:54:37 -07001547 zip -@ -q $@
1548
Ying Wangbc415dd2012-08-15 12:22:44 -07001549endif # EMMA_INSTRUMENT=true
1550
Ying Wangae9115a2013-08-22 20:52:47 -07001551#------------------------------------------------------------------
1552# A zip of Proguard obfuscation dictionary files.
1553# Only for apps_only build.
1554#
1555ifdef TARGET_BUILD_APPS
Ying Wangc62c92c2013-08-28 18:38:25 -07001556PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Ying Wangae9115a2013-08-22 20:52:47 -07001557# the dependency will be set up later in build/core/main.mk.
1558$(PROGUARD_DICT_ZIP) :
1559 @echo "Packaging Proguard obfuscation dictionary files."
1560 $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary`; \
1561 if [ -n "$$dict_files" ]; then \
Ying Wang33d64592013-11-25 17:39:50 -08001562 unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \
1563 zip -q $@ $$dict_files $$unobfuscated_jars; \
Ying Wangae9115a2013-08-22 20:52:47 -07001564 else \
Ying Wangc62c92c2013-08-28 18:38:25 -07001565 touch $(dir $@)/dummy; \
1566 (cd $(dir $@) && zip -q $(notdir $@) dummy); \
1567 zip -qd $@ dummy; \
1568 rm $(dir $@)/dummy; \
Ying Wangae9115a2013-08-22 20:52:47 -07001569 fi
1570
1571endif # TARGET_BUILD_APPS
1572
The Android Open Source Project88b60792009-03-03 19:28:42 -08001573# -----------------------------------------------------------------
1574# dalvik something
1575.PHONY: dalvikfiles
1576dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1577
1578# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001579# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07001580ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001581INTERNAL_EMULATOR_PACKAGE_FILES += \
1582 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08001583 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001584 $(INSTALLED_RAMDISK_TARGET) \
1585 $(INSTALLED_SYSTEMIMAGE) \
1586 $(INSTALLED_USERDATAIMAGE_TARGET)
1587
1588name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1589
1590INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1591
1592$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1593 @echo "Package: $@"
1594 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1595
Ying Wang7d8c5352012-07-26 10:15:21 -07001596endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001597# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08001598# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08001599# The pdk package (Platform Development Kit)
1600
Keun young Park7fc7aad2012-02-27 15:49:23 -08001601#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1602# include development/pdk/Pdk.mk
1603#endif
1604
The Android Open Source Project88b60792009-03-03 19:28:42 -08001605
1606# -----------------------------------------------------------------
1607# The SDK
1608
The Android Open Source Project88b60792009-03-03 19:28:42 -08001609# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07001610sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001611
1612# Build a name that looks like:
1613#
1614# linux-x86 --> android-sdk_12345_linux-x86
1615# darwin-x86 --> android-sdk_12345_mac-x86
1616# windows-x86 --> android-sdk_12345_windows
1617#
1618sdk_name := android-sdk_$(FILE_NAME_TAG)
1619ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001620 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001621else
Joe Onorato03fbe402009-04-13 08:31:16 -07001622 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001623endif
1624ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07001625 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001626endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001627sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001628
1629sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1630
1631ATREE_FILES :=
1632-include $(sdk_dep_file)
1633
1634# if we don't have a real list, then use "everything"
1635ifeq ($(strip $(ATREE_FILES)),)
1636ATREE_FILES := \
1637 $(ALL_PREBUILT) \
1638 $(ALL_COPIED_HEADERS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001639 $(ALL_DEFAULT_INSTALLED_MODULES) \
1640 $(INSTALLED_RAMDISK_TARGET) \
1641 $(ALL_DOCS) \
1642 $(ALL_SDK_FILES)
1643endif
1644
1645atree_dir := development/build
1646
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001647
The Android Open Source Project88b60792009-03-03 19:28:42 -08001648sdk_atree_files := \
1649 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07001650 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08001651
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02001652# development/build/sdk-android-<abi>.atree is used to differentiate
1653# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
1654# files like the kernel image. We use TARGET_CPU_ABI because we don't
1655# have a better way to distinguish between CPU models.
1656ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
1657 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
1658endif
1659
Griff Hazen433febb2014-02-28 08:45:59 -08001660ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),)
1661sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES)
1662else
1663sdk_atree_files += $(atree_dir)/sdk.atree
1664endif
1665
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07001666include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07001667
The Android Open Source Project88b60792009-03-03 19:28:42 -08001668deps := \
1669 $(target_notice_file_txt) \
1670 $(tools_notice_file_txt) \
1671 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001672 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001673 $(INSTALLED_SYSTEMIMAGE) \
1674 $(INSTALLED_USERDATAIMAGE_TARGET) \
1675 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001676 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001677 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001678 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08001679 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001680 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07001681 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07001682 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001683
1684INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1685$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1686$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1687$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1688$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1689
1690# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1691#
1692#SDK_GNU_ERROR := true
1693
1694$(INTERNAL_SDK_TARGET): $(deps)
1695 @echo "Package SDK: $@"
1696 $(hide) rm -rf $(PRIVATE_DIR) $@
1697 $(hide) for f in $(target_gnu_MODULES); do \
1698 if [ -f $$f ]; then \
1699 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1700 including GNU target $$f >&2; \
1701 FAIL=$(SDK_GNU_ERROR); \
1702 fi; \
1703 done; \
1704 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07001705 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001706 $(hide) ( \
Raphael Mollec5fe912012-06-06 19:33:31 -07001707 ATREE_STRIP="strip -x" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001708 $(HOST_OUT_EXECUTABLES)/atree \
1709 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1710 -m $(PRIVATE_DEP_FILE) \
1711 -I . \
1712 -I $(PRODUCT_OUT) \
1713 -I $(HOST_OUT) \
1714 -I $(TARGET_COMMON_OUT_ROOT) \
1715 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
Raphael Moll7558ad52011-01-05 14:58:17 -08001716 -v "OUT_DIR=$(OUT_DIR)" \
Raphael2a533172011-11-15 16:29:16 -08001717 -v "HOST_OUT=$(HOST_OUT)" \
Bruce Beare18a130e2011-02-18 15:06:20 -08001718 -v "TARGET_ARCH=$(TARGET_ARCH)" \
1719 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
David 'Digit' Turner557c51f2011-08-25 14:28:03 +02001720 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07001721 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001722 -o $(PRIVATE_DIR) && \
1723 cp -f $(target_notice_file_txt) \
Xavier Ducrohet6de7bc62011-09-21 10:22:19 -07001724 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
Xavier Ducrohet4216a8c2011-03-15 13:28:40 -07001725 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001726 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Raphael7a6a9c32011-02-01 13:30:00 -08001727 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001728 chmod -R ug+rwX $(PRIVATE_DIR) && \
1729 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1730 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1731
Raphael3d224a02010-04-16 17:50:09 -07001732
1733# Is a Windows SDK requested? If so, we need some definitions from here
1734# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08001735MAIN_SDK_NAME := $(sdk_name)
1736MAIN_SDK_DIR := $(sdk_dir)
1737MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Raphael3d224a02010-04-16 17:50:09 -07001738ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07001739include $(TOPDIR)development/build/tools/windows_sdk.mk
1740endif
1741
The Android Open Source Project88b60792009-03-03 19:28:42 -08001742# -----------------------------------------------------------------
1743# Findbugs
1744INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1745INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1746$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1747 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09001748 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001749 > $@
1750$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1751 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09001752 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07001753 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001754
1755# -----------------------------------------------------------------
1756# Findbugs
1757
1758# -----------------------------------------------------------------
1759# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07001760ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001761include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01001762-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07001763-include $(sort $(wildcard device/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07001764# Also the project-specific tasks
1765-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
1766-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07001767endif
Raphaelc4d47312011-02-15 16:09:36 -08001768
1769# -----------------------------------------------------------------
1770# Create SDK repository packages. Must be done after tasks/* since
1771# we need the addon rules defined.
1772ifneq ($(sdk_repo_goal),)
1773include $(TOPDIR)development/build/tools/sdk_repo.mk
1774endif