blob: 399ba7b2a173ee50c55bb34f2538a8e724ae948f [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
Ying Wang160b6702012-03-13 18:58:27 -070016is_tests_build := $(filter tests,$(MAKECMDGOALS))
17
The Android Open Source Project88b60792009-03-03 19:28:42 -080018# -----------------------------------------------------------------
19# Define rules to copy PRODUCT_COPY_FILES defined by the product.
Ying Wang4b0486b2012-09-20 16:35:36 -070020# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
The Android Open Source Project88b60792009-03-03 19:28:42 -080021# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
22# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080023# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070024# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070025#$(1): the src:dest pair
26define check-product-copy-files
Ying Wangc6c21d02014-01-21 20:25:46 -080027$(if $(filter %.apk, $(call word-colon, 2, $(1))),$(error \
Ying Wang68864102011-09-29 13:23:25 -070028 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))
29endef
Ying Wang619fccf2012-09-05 18:08:29 -070030# filter out the duplicate <source file>:<dest file> pairs.
31unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080032$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070033 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
34 $(eval unique_product_copy_files_pairs += $(cf))))
35unique_product_copy_files_destinations :=
36$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070037 $(eval _src := $(call word-colon,1,$(cf))) \
38 $(eval _dest := $(call word-colon,2,$(cf))) \
Ying Wang68864102011-09-29 13:23:25 -070039 $(call check-product-copy-files,$(cf)) \
Ying Wang193010c2011-12-16 11:54:25 -080040 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
41 $(info PRODUCT_COPY_FILES $(cf) ignored.), \
Ying Wang462d26b2010-11-02 21:31:47 -070042 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070043 $(if $(filter %.xml,$(_dest)),\
44 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
45 $(eval $(call copy-one-file,$(_src),$(_fulldest)))) \
Ying Wang462d26b2010-11-02 21:31:47 -070046 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
Ying Wang7e8d4422011-06-17 17:05:35 -070047 $(eval unique_product_copy_files_destinations += $(_dest))))
Ying Wang619fccf2012-09-05 18:08:29 -070048unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070049unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080050
51# -----------------------------------------------------------------
52# docs/index.html
Ying Wang3f45b3c2012-04-02 18:21:36 -070053ifeq (,$(TARGET_BUILD_APPS))
The Android Open Source Project88b60792009-03-03 19:28:42 -080054gen := $(OUT_DOCS)/index.html
55ALL_DOCS += $(gen)
56$(gen): frameworks/base/docs/docs-redirect-index.html
57 @mkdir -p $(dir $@)
58 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -070059endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080060
61# -----------------------------------------------------------------
62# default.prop
63INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
64ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
65ADDITIONAL_DEFAULT_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -070066 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
Mike Lockwood0d23fec2011-06-09 14:54:40 -070067ADDITIONAL_DEFAULT_PROPERTIES += \
Ying Wang7e8d4422011-06-17 17:05:35 -070068 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
69ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
70 $(ADDITIONAL_DEFAULT_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -080071
72$(INSTALLED_DEFAULT_PROP_TARGET):
73 @echo Target buildinfo: $@
74 @mkdir -p $(dir $@)
75 $(hide) echo "#" > $@; \
76 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
77 echo "#" >> $@;
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -070078 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
79 echo "$(line)" >> $@;)
Joe Onorato9197a482011-06-08 16:04:14 -070080 build/tools/post_process_props.py $@
The Android Open Source Project88b60792009-03-03 19:28:42 -080081
82# -----------------------------------------------------------------
83# build.prop
84INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
85ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
86ADDITIONAL_BUILD_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -070087 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
88ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
89 $(ADDITIONAL_BUILD_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -080090
91# A list of arbitrary tags describing the build configuration.
92# Force ":=" so we can use +=
93BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
94ifeq ($(TARGET_BUILD_TYPE),debug)
95 BUILD_VERSION_TAGS += debug
96endif
Doug Zongker49c6a2b2011-10-05 12:41:56 -070097# The "test-keys" tag marks builds signed with the old test keys,
98# which are available in the SDK. "dev-keys" marks builds signed with
99# non-default dev keys (usually private keys from a vendor directory).
100# Both of these tags will be removed and replaced with "release-keys"
101# when the target-files is signed in a post-build step.
102ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
Doug Zongkera8608a72013-07-23 11:51:04 -0700103BUILD_KEYS := test-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700104else
Doug Zongkera8608a72013-07-23 11:51:04 -0700105BUILD_KEYS := dev-keys
Doug Zongker49c6a2b2011-10-05 12:41:56 -0700106endif
Doug Zongkera8608a72013-07-23 11:51:04 -0700107BUILD_VERSION_TAGS += $(BUILD_KEYS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800108BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
109
110# A human-readable string that descibes this build in detail.
111build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)
112$(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc)
113
114# The string used to uniquely identify this build; used by the OTA server.
115ifeq (,$(strip $(BUILD_FINGERPRINT)))
Doug Zongker135a1202010-09-15 13:02:12 -0700116 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800117endif
118ifneq ($(words $(BUILD_FINGERPRINT)),1)
119 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
120endif
121
Sriram Raman7b641242009-03-24 22:40:59 -0700122# Display parameters shown under Settings -> About Phone
123ifeq ($(TARGET_BUILD_VARIANT),user)
124 # User builds should show:
125 # release build number or branch.buld_number non-release builds
126
127 # Dev. branches should have DISPLAY_BUILD_NUMBER set
128 ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
Doug Zongkera8608a72013-07-23 11:51:04 -0700129 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700130 else
Doug Zongkera8608a72013-07-23 11:51:04 -0700131 BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS)
Sriram Raman7b641242009-03-24 22:40:59 -0700132 endif
133else
134 # Non-user builds should show detailed build information
135 BUILD_DISPLAY_ID := $(build_desc)
136endif
137
Ying Wang77c882f2010-04-27 15:45:35 -0700138# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
Ying Wang38d7f022010-07-21 14:58:42 -0700139product_property_override_locale_language := $(strip \
140 $(patsubst ro.product.locale.language=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700141 $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
Ying Wang38d7f022010-07-21 14:58:42 -0700142product_property_overrides_locale_region := $(strip \
143 $(patsubst ro.product.locale.region=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700144 $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
145
The Android Open Source Project88b60792009-03-03 19:28:42 -0800146# Selects the first locale in the list given as the argument,
147# and splits it into language and region, which each may be
148# empty.
149define default-locale
150$(subst _, , $(firstword $(1)))
151endef
152
153# Selects the first locale in the list given as the argument
Ying Wang77c882f2010-04-27 15:45:35 -0700154# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
155# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800156define default-locale-language
Ying Wang38d7f022010-07-21 14:58:42 -0700157$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800158endef
159define default-locale-region
Ying Wang38d7f022010-07-21 14:58:42 -0700160$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800161endef
162
163BUILDINFO_SH := build/tools/buildinfo.sh
Andrew Boiefa61ff02012-09-28 09:33:45 -0700164
165ifdef TARGET_SYSTEM_PROP
166system_prop_file := $(TARGET_SYSTEM_PROP)
167else
168system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
169endif
Andrew Boiefa61ff02012-09-28 09:33:45 -0700170$(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 -0800171 @echo Target buildinfo: $@
172 @mkdir -p $(dir $@)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700173 $(hide) echo > $@
174ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),)
175 $(hide) echo "#" >> $@; \
176 echo "# PRODUCT_OEM_PROPERTIES" >> $@; \
177 echo "#" >> $@; )
178 $(hide) $(foreach prop,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES), \
179 echo "import /oem/oem.prop $(prop)" >> $@;)
180endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800181 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
182 TARGET_DEVICE="$(TARGET_DEVICE)" \
183 PRODUCT_NAME="$(TARGET_PRODUCT)" \
184 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
185 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
186 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700187 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800188 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
189 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
190 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
191 BUILD_ID="$(BUILD_ID)" \
192 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
193 BUILD_NUMBER="$(BUILD_NUMBER)" \
194 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
195 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700196 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800197 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
198 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
199 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
200 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700201 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800202 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Joe Onorato25939e22010-11-09 08:53:01 -0800203 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700204 bash $(BUILDINFO_SH) >> $@
Johan Redestig674a27d2012-04-12 17:00:58 +0200205 $(hide) $(foreach file,$(system_prop_file), \
206 if [ -f "$(file)" ]; then \
207 echo "#" >> $@; \
208 echo Target buildinfo from: "$(file)"; \
209 echo "# from $(file)" >> $@; \
210 echo "#" >> $@; \
211 cat $(file) >> $@; \
212 fi;)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800213 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
214 $(hide) echo >> $@; \
215 echo "#" >> $@; \
216 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
217 echo "#" >> $@; )
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700218 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
219 echo "$(line)" >> $@;)
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700220 $(hide) build/tools/post_process_props.py $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_PROPERTY_BLACKLIST)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800221
222build_desc :=
223
224# -----------------------------------------------------------------
225# sdk-build.prop
226#
227# There are certain things in build.prop that we don't want to
228# ship with the sdk; remove them.
229
230# This must be a list of entire property keys followed by
231# "=" characters, without any internal spaces.
232sdk_build_prop_remove := \
233 ro.build.user= \
234 ro.build.host= \
235 ro.product.brand= \
236 ro.product.manufacturer= \
237 ro.product.device=
238# TODO: Remove this soon-to-be obsolete property
239sdk_build_prop_remove += ro.build.product=
240INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
241$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
242 @echo SDK buildinfo: $@
243 @mkdir -p $(dir $@)
244 $(hide) grep -v "$(subst $(space),\|,$(strip \
245 $(sdk_build_prop_remove)))" $< > $@.tmp
246 $(hide) for x in $(sdk_build_prop_remove); do \
247 echo "$$x"generic >> $@.tmp; done
248 $(hide) mv $@.tmp $@
249
250# -----------------------------------------------------------------
251# package stats
252PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
253PACKAGES_TO_STAT := \
254 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
255 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
256$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
257 @echo Package stats: $@
258 @mkdir -p $(dir $@)
259 $(hide) rm -f $@
260 $(hide) build/tools/dump-package-stats $^ > $@
261
262.PHONY: package-stats
263package-stats: $(PACKAGE_STATS_FILE)
264
265# -----------------------------------------------------------------
266# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700267# Use a macro to add newline to each echo command
268define _apkcerts_echo_with_newline
269$(hide) echo $(1)
270
271endef
272
The Android Open Source Project88b60792009-03-03 19:28:42 -0800273name := $(TARGET_PRODUCT)
274ifeq ($(TARGET_BUILD_TYPE),debug)
275 name := $(name)_debug
276endif
277name := $(name)-apkcerts-$(FILE_NAME_TAG)
278intermediates := \
279 $(call intermediates-dir-for,PACKAGING,apkcerts)
280APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800281# We don't need to really build all the modules.
282# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700283$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800284 @echo APK certs list: $@
285 @mkdir -p $(dir $@)
286 @rm -f $@
Ying Wangd9a88d52012-10-26 09:21:28 -0700287 $(foreach p,$(PACKAGES),\
288 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
289 $(call _apkcerts_echo_with_newline,\
290 'name="$(p).apk" certificate="EXTERNAL" \
291 private_key=""' >> $@),\
292 $(call _apkcerts_echo_with_newline,\
293 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
294 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@)))
295 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700296 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800297
298.PHONY: apkcerts-list
299apkcerts-list: $(APKCERTS_FILE)
300
Ying Wang15e487a2011-02-15 10:56:18 -0800301ifneq (,$(TARGET_BUILD_APPS))
302 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
303endif
Ying Wangefb21682010-07-23 16:42:13 -0700304
The Android Open Source Project88b60792009-03-03 19:28:42 -0800305# -----------------------------------------------------------------
306# module info file
307ifdef CREATE_MODULE_INFO_FILE
308 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
309 $(info Generating $(MODULE_INFO_FILE)...)
310 $(shell rm -f $(MODULE_INFO_FILE))
311 $(foreach m,$(ALL_MODULES), \
312 $(shell echo "NAME=\"$(m)\"" \
313 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
314 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
315 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
316 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
317endif
318
Doug Zongker8678df42009-06-15 14:30:14 -0700319# -----------------------------------------------------------------
320
Ying Wang3c21fe52011-10-04 10:50:08 -0700321# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700322# for future OTA packages installed by this system. Actual product
323# deliverables will be re-signed by hand. We expect this file to
324# exist with the suffixes ".x509.pem" and ".pk8".
Ying Wang3c21fe52011-10-04 10:50:08 -0700325DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Doug Zongker8678df42009-06-15 14:30:14 -0700326
327
Jeff Browne33ba4c2011-07-11 22:11:46 -0700328# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800329# if they don't do anything.
330.PHONY: systemimage
331systemimage:
332
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800333# -----------------------------------------------------------------
334
335.PHONY: event-log-tags
336
Joe Onoratob7510532010-07-14 10:22:54 -0700337# Produce an event logs tag file for everything we know about, in order
338# to properly allocate numbers. Then produce a file that's filtered
339# for what's going to be installed.
340
341all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
342
Colin Crossdc8f8e42012-04-12 13:25:54 -0700343event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
344
Joe Onoratob7510532010-07-14 10:22:54 -0700345# Include tags from all packages that we know about
346all_event_log_tags_src := \
347 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
348
Colin Crossdc8f8e42012-04-12 13:25:54 -0700349# PDK builds will already have a full list of tags that needs to get merged
350# in with the ones from source
351pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
352
353$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
354$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700355 $(hide) mkdir -p $(dir $@)
356 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
357
Doug Zongkera34fa952011-02-23 12:17:29 -0800358# Include tags from all packages included in this product, plus all
359# tags that are part of the system (ie, not in a vendor/ or device/
360# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800361event_log_tags_src := \
362 $(sort $(foreach m,\
363 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
364 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800365 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
366 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800367
Colin Crossdc8f8e42012-04-12 13:25:54 -0700368$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700369$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossdc8f8e42012-04-12 13:25:54 -0700370$(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 -0800371 $(hide) mkdir -p $(dir $@)
Joe Onoratob7510532010-07-14 10:22:54 -0700372 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800373
374event-log-tags: $(event_log_tags_file)
375
376ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
377
Joe Onoratob7510532010-07-14 10:22:54 -0700378
The Android Open Source Project88b60792009-03-03 19:28:42 -0800379# #################################################################
380# Targets for boot/OS images
381# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800382ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
383 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
384 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
385 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
386 else
387 INSTALLED_2NDBOOTLOADER_TARGET :=
388 endif
389else
390 INSTALLED_BOOTLOADER_MODULE :=
391 INSTALLED_2NDBOOTLOADER_TARGET :=
392endif # TARGET_NO_BOOTLOADER
393ifneq ($(strip $(TARGET_NO_KERNEL)),true)
394 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
395else
396 INSTALLED_KERNEL_TARGET :=
397endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800398
Geremy Condrafd6f7512013-06-16 17:26:08 -0700399VERITY_SIGNER_CMD := $(HOST_OUT_EXECUTABLES)/verity_signer
400
The Android Open Source Project88b60792009-03-03 19:28:42 -0800401# -----------------------------------------------------------------
402# the ramdisk
403INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
404 $(ALL_PREBUILT) \
405 $(ALL_COPIED_HEADERS) \
406 $(ALL_GENERATED_SOURCES) \
407 $(ALL_DEFAULT_INSTALLED_MODULES))
408
Joe Onorato64d85d02009-04-09 19:31:12 -0700409BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
410
411# We just build this directly to the install location.
412INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Ying Wang82cceba2012-08-13 15:03:00 -0700413$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800414 $(call pretty,"Target ram disk: $@")
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700415 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800416
Ying Wangad7fd292013-08-08 16:34:29 -0700417.PHONY: ramdisk-nodeps
418ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP)
419 @echo "make $@: ignoring dependencies"
420 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800421
422ifneq ($(strip $(TARGET_NO_KERNEL)),true)
423
424# -----------------------------------------------------------------
425# the boot image, which is a collection of other images.
426INTERNAL_BOOTIMAGE_ARGS := \
427 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
428 --kernel $(INSTALLED_KERNEL_TARGET) \
429 --ramdisk $(INSTALLED_RAMDISK_TARGET)
430
431INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
432
433BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
434ifdef BOARD_KERNEL_CMDLINE
435 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
436endif
437
Dima Zavin1e0847c2009-05-07 19:43:08 -0700438BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
439ifdef BOARD_KERNEL_BASE
440 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
441endif
442
Ying Wangffff0022010-08-23 12:56:25 -0700443BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
444ifdef BOARD_KERNEL_PAGESIZE
445 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
446endif
447
The Android Open Source Project88b60792009-03-03 19:28:42 -0800448INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
449
450ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
451tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
452INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
453INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
454$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
455 $(call pretty,"Target boot image: $@")
456 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
457
Ying Wangad7fd292013-08-08 16:34:29 -0700458.PHONY: bootimage-nodeps
459bootimage-nodeps: $(MKEXT2IMG)
460 @echo "make $@: ignoring dependencies"
461 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
462
The Android Open Source Project88b60792009-03-03 19:28:42 -0800463else # TARGET_BOOTIMAGE_USE_EXT2 != true
464
465$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
466 $(call pretty,"Target boot image: $@")
Doug Zongkerd5131602012-08-02 14:46:42 -0700467 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Doug Zongkered96e882009-08-26 09:37:07 -0700468 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
Ying Wangad7fd292013-08-08 16:34:29 -0700469
470.PHONY: bootimage-nodeps
471bootimage-nodeps: $(MKBOOTIMG)
472 @echo "make $@: ignoring dependencies"
473 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
474 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
475
The Android Open Source Project88b60792009-03-03 19:28:42 -0800476endif # TARGET_BOOTIMAGE_USE_EXT2
477
478else # TARGET_NO_KERNEL
479# HACK: The top-level targets depend on the bootimage. Not all targets
480# can produce a bootimage, though, and emulator targets need the ramdisk
481# instead. Fake it out by calling the ramdisk the bootimage.
482# TODO: make the emulator use bootimages, and make mkbootimg accept
483# kernel-less inputs.
484INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
485endif
486
487# -----------------------------------------------------------------
488# NOTICE files
489#
Steve Blockd14d3b42012-03-01 11:34:41 +0000490# We are required to publish the licenses for all code under BSD, GPL and
491# Apache licenses (and possibly other more exotic ones as well). We err on the
492# side of caution, so the licenses for other third-party code are included here
493# too.
494#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800495# This needs to be before the systemimage rules, because it adds to
496# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
497# go into the systemimage.
498
Steve Block495e5852012-02-29 19:18:08 +0000499.PHONY: notice_files
500
The Android Open Source Project88b60792009-03-03 19:28:42 -0800501# Create the rule to combine the files into text and html forms
Steve Block495e5852012-02-29 19:18:08 +0000502# $(1) - Plain text output file
503# $(2) - HTML output file
504# $(3) - File title
505# $(4) - Directory to use. Notice files are all $(4)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800506# directories in there will be used for scratch
Steve Block495e5852012-02-29 19:18:08 +0000507# $(5) - Dependencies for the output files
The Android Open Source Project88b60792009-03-03 19:28:42 -0800508#
509# The algorithm here is that we go collect a hash for each of the notice
510# files and write the names of the files that match that hash. Then
511# to generate the real files, we go print out all of the files and their
512# hashes.
513#
514# These rules are fairly complex, so they depend on this makefile so if
515# it changes, they'll run again.
516#
517# TODO: We could clean this up so that we just record the locations of the
518# original notice files instead of making rules to copy them somwehere.
519# Then we could traverse that without quite as much bash drama.
520define combine-notice-files
Steve Block495e5852012-02-29 19:18:08 +0000521$(1) $(2): PRIVATE_MESSAGE := $(3)
Daniel Berlinf5a97d72012-03-29 10:33:19 -0400522$(1) $(2): PRIVATE_DIR := $(4)
Ying Wangc4625ab2012-04-09 12:16:23 -0700523$(1) : $(2)
524$(2) : $(5) $(BUILD_SYSTEM)/Makefile build/tools/generate-notice-files.py
Daniel Berlinf5a97d72012-03-29 10:33:19 -0400525 build/tools/generate-notice-files.py $(1) $(2) $$(PRIVATE_MESSAGE) $$(PRIVATE_DIR)/src
Steve Block495e5852012-02-29 19:18:08 +0000526notice_files: $(1) $(2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800527endef
528
529# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
530# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
531# the src subdirectory.
532
Steve Block495e5852012-02-29 19:18:08 +0000533target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800534target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
535target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
Steve Block495e5852012-02-29 19:18:08 +0000536tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800537tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
538
Ying Wang62c81f82013-08-22 20:02:03 -0700539ifndef TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800540kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
Ying Wang4534d812012-04-09 17:04:12 -0700541pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800542
543$(eval $(call combine-notice-files, \
Steve Block495e5852012-02-29 19:18:08 +0000544 $(target_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800545 $(target_notice_file_html), \
546 "Notices for files contained in the filesystem images in this directory:", \
547 $(TARGET_OUT_NOTICE_FILES), \
Ying Wang4534d812012-04-09 17:04:12 -0700548 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800549
550$(eval $(call combine-notice-files, \
Steve Block495e5852012-02-29 19:18:08 +0000551 $(tools_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800552 $(tools_notice_file_html), \
553 "Notices for files contained in the tools directory:", \
554 $(HOST_OUT_NOTICE_FILES), \
555 $(ALL_DEFAULT_INSTALLED_MODULES)))
556
557# Install the html file at /system/etc/NOTICE.html.gz.
558# This is not ideal, but this is very late in the game, after a lot of
559# the module processing has already been done -- in fact, we used the
560# fact that all that has been done to get the list of modules that we
561# need notice files for.
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700562$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700563 $(hide) $(MINIGZIP) -9 < $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800564installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
565$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
566 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700567
568# if we've been run my mm, mmm, etc, don't reinstall this every time
569ifeq ($(ONE_SHOT_MAKEFILE),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800570ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700571endif
Ying Wang62c81f82013-08-22 20:02:03 -0700572endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800573
574# The kernel isn't really a module, so to get its module file in there, we
575# make the target NOTICE files depend on this particular file too, which will
576# then be in the right directory for the find in combine-notice-files to work.
577$(kernel_notice_file): \
Jean-Baptiste Querua230c4d2012-01-06 15:05:53 -0800578 prebuilts/qemu-kernel/arm/LINUX_KERNEL_COPYING \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800579 | $(ACP)
580 @echo Copying: $@
581 $(hide) mkdir -p $(dir $@)
582 $(hide) $(ACP) $< $@
583
584
Doug Zongker8678df42009-06-15 14:30:14 -0700585# -----------------------------------------------------------------
586# Build a keystore with the authorized keys in it, used to verify the
587# authenticity of downloaded OTA packages.
588#
589# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
590# before the rules that use that variable to build the image.
591ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
592$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Doug Zongker37c0e272009-06-15 15:36:16 -0700593$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Doug Zongker8678df42009-06-15 14:30:14 -0700594 $(hide) rm -f $@
595 $(hide) mkdir -p $(dir $@)
Doug Zongker37c0e272009-06-15 15:36:16 -0700596 $(hide) zip -qj $@ $<
Doug Zongker8678df42009-06-15 14:30:14 -0700597
598.PHONY: otacerts
599otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
600
601
The Android Open Source Project88b60792009-03-03 19:28:42 -0800602# #################################################################
603# Targets for user images
604# #################################################################
605
Ying Wang933abf12010-06-16 14:31:34 -0700606INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800607ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -0700608INTERNAL_USERIMAGES_USE_EXT := true
609INTERNAL_USERIMAGES_EXT_VARIANT := ext2
610else
611ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
612INTERNAL_USERIMAGES_USE_EXT := true
613INTERNAL_USERIMAGES_EXT_VARIANT := ext3
614else
615ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
616INTERNAL_USERIMAGES_USE_EXT := true
617INTERNAL_USERIMAGES_EXT_VARIANT := ext4
618endif
619endif
620endif
621
Ying Wang542903a2010-11-17 15:40:38 -0800622ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
623 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
624endif
625
Colin Cross0a7b2c52010-05-07 02:23:59 -0700626ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
Ying Wang69e9b4d2012-11-26 18:10:23 -0800627INTERNAL_USERIMAGES_DEPS := $(MKEXTUSERIMG) $(MAKE_EXT4FS) $(SIMG2IMG) $(E2FSCK)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800628else
Colin Cross144b0282010-05-10 13:04:47 -0700629INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800630endif
Ying Wang178ef922011-10-31 18:13:30 -0700631INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800632
Geremy Condrafd6f7512013-06-16 17:26:08 -0700633ifeq (true, $(PRODUCT_SUPPORTS_VERITY))
634INTERNAL_USERIMAGES_DEPS += $(HOST_OUT_EXECUTABLES)/verity_signer
635endif
636
Ying Wangfdbd9cb2012-11-21 10:47:00 -0800637SELINUX_FC := $(TARGET_ROOT_OUT)/file_contexts
638INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
639
Ying Wangbd93d422011-10-28 17:02:30 -0700640# $(1): the path of the output dictionary file
Ying Wang6a42a252013-02-27 13:54:02 -0800641# $(2): additional "key=value" pairs to append to the dictionary file.
Ying Wangbd93d422011-10-28 17:02:30 -0700642define generate-userimage-prop-dictionary
643$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
644$(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
645$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wang9f8e8db2011-11-04 11:37:01 -0700646$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
647$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wanga0febe52013-03-20 11:02:05 -0700648$(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
649$(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -0700650$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
651$(if $(mkyaffs2_extra_flags),$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(1))
Ying Wangfdbd9cb2012-11-21 10:47:00 -0800652$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
Ying Wang6a42a252013-02-27 13:54:02 -0800653$(if $(2),$(hide) $(foreach kv,$(2),echo "$(kv)" >> $(1);))
Ying Wangbd93d422011-10-28 17:02:30 -0700654endef
655
The Android Open Source Project88b60792009-03-03 19:28:42 -0800656# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -0700657# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700658
659# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
Mike Lockwooddaf5e222012-10-18 10:17:47 -0700660ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700661
Doug Zongker4647f122009-07-02 09:00:54 -0700662INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
663
664recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
665recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
666recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
667recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
668recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
669recovery_resources_common := $(call include-path-for, recovery)/res
Doug Zongkere1297322013-03-06 15:04:31 -0800670
671# Select the 18x32 font on high-density devices; and the 12x22 font on
672# other devices. Note that the font selected here can be overridden
673# for a particular device by putting a font.png in its private
674# recovery resources.
675ifneq (,$(filter xxhdpi xhdpi,$(subst $(comma),$(space),$(PRODUCT_AAPT_CONFIG))))
676recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
677else
678recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
679endif
680
Doug Zongker4647f122009-07-02 09:00:54 -0700681recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
682recovery_resource_deps := $(shell find $(recovery_resources_common) \
683 $(recovery_resources_private) -type f)
Andrew Boiefa61ff02012-09-28 09:33:45 -0700684ifdef TARGET_RECOVERY_FSTAB
685recovery_fstab := $(TARGET_RECOVERY_FSTAB)
686else
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700687recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -0700688endif
Doug Zongker56588872012-08-20 15:38:58 -0700689# Named '.dat' so we don't attempt to use imgdiff for patching it.
690RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
Doug Zongker4647f122009-07-02 09:00:54 -0700691
692ifeq ($(recovery_resources_private),)
693 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
694endif
695
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700696ifeq ($(recovery_fstab),)
697 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
698endif
699
Doug Zongker4647f122009-07-02 09:00:54 -0700700INTERNAL_RECOVERYIMAGE_ARGS := \
701 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
702 --kernel $(recovery_kernel) \
703 --ramdisk $(recovery_ramdisk)
704
705# Assumes this has already been stripped
706ifdef BOARD_KERNEL_CMDLINE
707 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
708endif
709ifdef BOARD_KERNEL_BASE
710 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
711endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700712BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
713ifdef BOARD_KERNEL_PAGESIZE
714 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
715endif
Doug Zongker4647f122009-07-02 09:00:54 -0700716
717# Keys authorized to sign OTA packages this build will accept. The
Ying Wang3c21fe52011-10-04 10:50:08 -0700718# build always uses dev-keys for this; release packaging tools will
Doug Zongker4647f122009-07-02 09:00:54 -0700719# substitute other keys for this one.
Ying Wang3c21fe52011-10-04 10:50:08 -0700720OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem
Doug Zongker4647f122009-07-02 09:00:54 -0700721
722# Generate a file containing the keys that will be read by the
723# recovery binary.
724RECOVERY_INSTALL_OTA_KEYS := \
725 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
726DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
727$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
Doug Zongker5d4808d2011-03-16 07:49:13 -0700728$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
Doug Zongkere121d6a2011-02-01 14:13:52 -0800729$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys)
730 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
Doug Zongker4647f122009-07-02 09:00:54 -0700731 @rm -rf $@
732 @mkdir -p $(dir $@)
Doug Zongkere121d6a2011-02-01 14:13:52 -0800733 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
Doug Zongker4647f122009-07-02 09:00:54 -0700734
735$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
736 $(INSTALLED_RAMDISK_TARGET) \
737 $(INSTALLED_BOOTIMAGE_TARGET) \
738 $(recovery_binary) \
739 $(recovery_initrc) $(recovery_kernel) \
740 $(INSTALLED_2NDBOOTLOADER_TARGET) \
741 $(recovery_build_prop) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700742 $(recovery_fstab) \
Doug Zongker4647f122009-07-02 09:00:54 -0700743 $(RECOVERY_INSTALL_OTA_KEYS)
744 @echo ----- Making recovery image ------
Doug Zongker72f0b672012-08-08 16:26:17 -0700745 $(hide) rm -rf $(TARGET_RECOVERY_OUT)
746 $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
747 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/tmp
748 @echo Copying baseline ramdisk...
749 $(hide) cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
750 @echo Modifying ramdisk contents...
751 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
752 $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
753 $(hide) -cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/
754 $(hide) cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
755 $(hide) cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
Doug Zongkere1297322013-03-06 15:04:31 -0800756 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
Doug Zongker72f0b672012-08-08 16:26:17 -0700757 $(hide) $(foreach item,$(recovery_resources_private), \
Doug Zongker4647f122009-07-02 09:00:54 -0700758 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
Doug Zongker72f0b672012-08-08 16:26:17 -0700759 $(hide) $(foreach item,$(recovery_fstab), \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700760 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Doug Zongker72f0b672012-08-08 16:26:17 -0700761 $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
762 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
Doug Zongker4647f122009-07-02 09:00:54 -0700763 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Doug Zongker72f0b672012-08-08 16:26:17 -0700764 $(hide) $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
765 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Doug Zongkered96e882009-08-26 09:37:07 -0700766 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
Doug Zongker72f0b672012-08-08 16:26:17 -0700767 @echo ----- Made recovery image: $@ --------
Doug Zongker4647f122009-07-02 09:00:54 -0700768
Doug Zongker56588872012-08-20 15:38:58 -0700769$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
Doug Zongker1a097262012-09-04 14:45:11 -0700770 $(hide) mkdir -p $(dir $@)
Doug Zongker56588872012-08-20 15:38:58 -0700771 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@
772
Doug Zongker4647f122009-07-02 09:00:54 -0700773else
774INSTALLED_RECOVERYIMAGE_TARGET :=
Doug Zongker56588872012-08-20 15:38:58 -0700775RECOVERY_RESOURCE_ZIP :=
Doug Zongker4647f122009-07-02 09:00:54 -0700776endif
777
778.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -0700779recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -0700780
Dima Zavin11818982010-02-05 13:34:34 -0800781ifneq ($(BOARD_NAND_PAGE_SIZE),)
782mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
783else
784mkyaffs2_extra_flags :=
Lars Svensson9cb8c282010-12-06 15:24:58 +0100785BOARD_NAND_PAGE_SIZE := 2048
Dima Zavin11818982010-02-05 13:34:34 -0800786endif
787
Naseer Ahmed53871882010-08-06 12:19:29 -0700788ifneq ($(BOARD_NAND_SPARE_SIZE),)
789mkyaffs2_extra_flags += -s $(BOARD_NAND_SPARE_SIZE)
Lars Svensson9cb8c282010-12-06 15:24:58 +0100790else
791BOARD_NAND_SPARE_SIZE := 64
Naseer Ahmed53871882010-08-06 12:19:29 -0700792endif
793
Doug Zongker4647f122009-07-02 09:00:54 -0700794# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -0700795# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800796#
Ying Wang9c649a72012-08-08 15:27:00 -0700797# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
798PDK_FUSION_SYSIMG_FILES := \
799 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
800 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800801
802INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -0700803 $(ALL_PREBUILT) \
804 $(ALL_COPIED_HEADERS) \
805 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -0700806 $(ALL_DEFAULT_INSTALLED_MODULES) \
807 $(PDK_FUSION_SYSIMG_FILES) \
808 $(RECOVERY_RESOURCE_ZIP))
Ying Wang160b6702012-03-13 18:58:27 -0700809
810ifdef is_tests_build
811# We don't want to install tests modules to the system partition
812# when building "tests", because now "tests" may be built in a user, userdebug
813# or eng build variant and we don't want to pollute the system partition.
814# INTERNAL_SYSTEMIMAGE_FILES += $(filter $(TARGET_OUT)/%, \
815# $(tests_MODULES))
816endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800817
Ying Wang82cceba2012-08-13 15:03:00 -0700818FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Ying Wange5e8c5f2011-09-09 16:35:53 -0700819# -----------------------------------------------------------------
820# installed file list
821# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
822# We put installed-files.txt ahead of image itself in the dependency graph
823# so that we can get the size stat even if the build fails due to too large
824# system image.
825INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
826$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS)
827 @echo Installed file list: $@
828 @mkdir -p $(dir $@)
829 @rm -f $@
830 $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@
831
832.PHONY: installed-file-list
833installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -0800834
835$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -0700836
837systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -0700838 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -0700839BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
840
The Android Open Source Project88b60792009-03-03 19:28:42 -0800841# $(1): output file
842define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -0700843 @echo "Target system fs image: $(1)"
844 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Geremy Condrafd6f7512013-06-16 17:26:08 -0700845 $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt, \
846 skip_fsck=true \
847 verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY) \
848 verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_PARTITION) \
849 verity_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY) \
850 verity_signer_cmd=$(VERITY_SIGNER_CMD))
Ying Wangbd93d422011-10-28 17:02:30 -0700851 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
852 ./build/tools/releasetools/build_image.py \
853 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800854endef
855
Ying Wange5e8c5f2011-09-09 16:35:53 -0700856$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800857 $(call build-systemimage-target,$@)
858
The Android Open Source Project88b60792009-03-03 19:28:42 -0800859INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700860SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800861
Doug Zongker73ef8252009-07-23 15:12:53 -0700862# The system partition needs room for the recovery image as well. We
863# now store the recovery image as a binary patch using the boot image
864# as the source (since they are very similar). Generate the patch so
865# we can see how big it's going to be, and include that in the system
866# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700867ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700868intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
869RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
870$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
871 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700872 $(HOST_OUT_EXECUTABLES)/imgdiff \
873 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700874 @echo "Construct recovery from boot"
875 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700876 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700877endif
878
Doug Zongker73ef8252009-07-23 15:12:53 -0700879
880$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800881 @echo "Install system fs image: $@"
882 $(copy-file-to-target)
Doug Zongkered96e882009-08-26 09:37:07 -0700883 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800884
885systemimage: $(INSTALLED_SYSTEMIMAGE)
886
887.PHONY: systemimage-nodeps snod
888systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -0700889 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800890 @echo "make $@: ignoring dependencies"
891 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
Doug Zongkered96e882009-08-26 09:37:07 -0700892 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800893
Ying Wangacf01ec2012-02-24 11:05:48 -0800894ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
895ifeq (true,$(WITH_DEXPREOPT))
896$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
897endif
898endif
899
The Android Open Source Project88b60792009-03-03 19:28:42 -0800900#######
901## system tarball
902define build-systemtarball-target
903 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
904 $(MKTARBALL) $(FS_GET_STATS) \
905 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
906 $(INSTALLED_SYSTEMTARBALL_TARGET)
907endef
908
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700909ifndef SYSTEM_TARBALL_FORMAT
910 SYSTEM_TARBALL_FORMAT := bz2
911endif
912
The Android Open Source Project88b60792009-03-03 19:28:42 -0800913system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700914INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800915$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
916$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
917 $(build-systemtarball-target)
918
919.PHONY: systemtarball-nodeps
920systemtarball-nodeps: $(FS_GET_STATS) \
921 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
922 $(build-systemtarball-target)
923
924.PHONY: stnod
925stnod: systemtarball-nodeps
926
Ying Wang4c289e52012-03-30 13:52:54 -0700927#######
Ying Wang4534d812012-04-09 17:04:12 -0700928## platform.zip: system, plus other files to be used in PDK fusion build,
929## in a zip file
keunyoungc0178062013-07-22 14:54:58 -0700930##
931## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
932## The variable will be typically set from BoardConfig.mk.
933## Files under out dir will be rejected to prevent possible conflicts with other rules.
934PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -0700935INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
936$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES)
937 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Ying Wang4c289e52012-03-30 13:52:54 -0700938 $(hide) rm -f $@
Ying Wang4534d812012-04-09 17:04:12 -0700939 $(hide) cd $(dir $@) && zip -qry $(notdir $@) \
940 $(TARGET_COPY_OUT_SYSTEM) \
Keun young Park72226692012-07-31 17:13:20 -0700941 $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \
942 $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST))
Colin Crossc451a372013-12-18 19:36:44 -0800943ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Ying Wang28a18172012-06-02 09:22:31 -0700944 $(hide) cd $(OUT_DIR) && zip -qry $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
Keun young Park816b9fd2012-05-16 10:32:41 -0700945endif
keunyoungc0178062013-07-22 14:54:58 -0700946ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
947 $(hide) zip -qry $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
948endif
Ying Wang4c289e52012-03-30 13:52:54 -0700949
950.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -0700951platform: $(INSTALLED_PLATFORM_ZIP)
952
953.PHONY: platform-java
954platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -0700955
956# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -0700957ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
958$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -0700959endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800960
Bruce Beare52aac202010-06-04 15:24:49 -0700961#######
962## boot tarball
963define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -0700964 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -0700965 $(hide) mkdir -p $(PRODUCT_OUT)/boot
966 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
967 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
968 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
969 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
970 $(INSTALLED_BOOTTARBALL_TARGET)
971endef
972
973ifndef BOOT_TARBALL_FORMAT
974 BOOT_TARBALL_FORMAT := bz2
975endif
976
977boot_tar := $(PRODUCT_OUT)/boot.tar
978INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
979$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
980$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
981 $(build-boottarball-target)
982
983.PHONY: boottarball-nodeps btnod
984boottarball-nodeps btnod: $(FS_GET_STATS) \
985 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
986 $(build-boottarball-target)
987
988
The Android Open Source Project88b60792009-03-03 19:28:42 -0800989# -----------------------------------------------------------------
990# data partition image
991INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -0700992 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800993
Ying Wang160b6702012-03-13 18:58:27 -0700994# If we build "tests" at the same time, make sure $(tests_MODULES) get covered.
995ifdef is_tests_build
996INTERNAL_USERDATAIMAGE_FILES += \
997 $(filter $(TARGET_OUT_DATA)/%,$(tests_MODULES))
998endif
999
Ying Wangd7321d32013-03-15 10:32:29 -07001000# Don't build userdata.img if it's extfs but no partition size
1001skip_userdata.img :=
1002ifdef INTERNAL_USERIMAGES_EXT_VARIANT
1003ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE
1004skip_userdata.img := true
1005endif
1006endif
1007
1008ifneq ($(skip_userdata.img),true)
Ying Wangbd93d422011-10-28 17:02:30 -07001009userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001010 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07001011BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
1012
Ying Wangbd93d422011-10-28 17:02:30 -07001013define build-userdataimage-target
1014 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
1015 @mkdir -p $(TARGET_OUT_DATA)
1016 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001017 $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt, skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07001018 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1019 ./build/tools/releasetools/build_image.py \
Ying Wang178ef922011-10-31 18:13:30 -07001020 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET)
Ying Wangbd93d422011-10-28 17:02:30 -07001021 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
1022endef
1023
Joe Onorato64d85d02009-04-09 19:31:12 -07001024# We just build this directly to the install location.
1025INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -07001026$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001027 $(INTERNAL_USERDATAIMAGE_FILES)
1028 $(build-userdataimage-target)
1029
1030.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07001031userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001032 $(build-userdataimage-target)
1033
Ying Wangd7321d32013-03-15 10:32:29 -07001034endif # not skip_userdata.img
1035skip_userdata.img :=
Ying Wange215ed52012-10-15 14:36:22 -07001036
The Android Open Source Project88b60792009-03-03 19:28:42 -08001037#######
1038## data partition tarball
1039define build-userdatatarball-target
1040 $(call pretty,"Target userdata fs tarball: " \
1041 "$(INSTALLED_USERDATATARBALL_TARGET)")
1042 $(MKTARBALL) $(FS_GET_STATS) \
1043 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
1044 $(INSTALLED_USERDATATARBALL_TARGET)
1045endef
1046
1047userdata_tar := $(PRODUCT_OUT)/userdata.tar
1048INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
1049$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
1050$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
1051 $(build-userdatatarball-target)
1052
1053.PHONY: userdatatarball-nodeps
1054userdatatarball-nodeps: $(FS_GET_STATS)
1055 $(build-userdatatarball-target)
1056
1057
The Android Open Source Project88b60792009-03-03 19:28:42 -08001058# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07001059# cache partition image
1060ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1061INTERNAL_CACHEIMAGE_FILES := \
1062 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
1063
1064cacheimage_intermediates := \
1065 $(call intermediates-dir-for,PACKAGING,cache)
1066BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
1067
1068define build-cacheimage-target
1069 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
1070 @mkdir -p $(TARGET_OUT_CACHE)
1071 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001072 $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt, skip_fsck=true)
Ying Wang9f8e8db2011-11-04 11:37:01 -07001073 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1074 ./build/tools/releasetools/build_image.py \
1075 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET)
1076 $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE),yaffs)
1077endef
1078
1079# We just build this directly to the install location.
1080INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
1081$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
1082 $(build-cacheimage-target)
1083
1084.PHONY: cacheimage-nodeps
1085cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1086 $(build-cacheimage-target)
1087
1088endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1089
Ying Wanga0febe52013-03-20 11:02:05 -07001090
1091# -----------------------------------------------------------------
1092# vendor partition image
1093ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1094INTERNAL_VENDORIMAGE_FILES := \
1095 $(filter $(TARGET_OUT_VENDOR)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
1096
1097vendorimage_intermediates := \
1098 $(call intermediates-dir-for,PACKAGING,vendor)
1099BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
1100
1101define build-vendorimage-target
1102 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
1103 @mkdir -p $(TARGET_OUT_VENDOR)
1104 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
1105 $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true)
1106 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1107 ./build/tools/releasetools/build_image.py \
1108 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET)
1109 $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE),yaffs)
1110endef
1111
1112# We just build this directly to the install location.
1113INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
1114$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES)
1115 $(build-vendorimage-target)
1116
1117.PHONY: vendorimage-nodeps
1118vendorimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1119 $(build-vendorimage-target)
1120
1121endif # BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1122
Ying Wang9f8e8db2011-11-04 11:37:01 -07001123# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001124# bring in the installer image generation defines if necessary
1125ifeq ($(TARGET_USE_DISKINSTALLER),true)
1126include bootable/diskinstaller/config.mk
1127endif
1128
1129# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07001130# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08001131
Colin Crossc312f312012-04-19 13:54:39 -07001132DISTTOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -07001133 $(HOST_OUT_EXECUTABLES)/mkbootfs \
1134 $(HOST_OUT_EXECUTABLES)/mkbootimg \
1135 $(HOST_OUT_EXECUTABLES)/fs_config \
1136 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
1137 $(HOST_OUT_EXECUTABLES)/zipalign \
Doug Zongker8678df42009-06-15 14:30:14 -07001138 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -07001139 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -07001140 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -07001141 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
1142 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
Ying Wang7dc45a82013-01-04 14:43:18 -08001143 $(HOST_OUT_EXECUTABLES)/make_ext4fs \
1144 $(HOST_OUT_EXECUTABLES)/simg2img \
Doug Zongker5fad2032014-02-24 08:13:45 -08001145 $(HOST_OUT_EXECUTABLES)/e2fsck \
Doug Zongker32b527d2014-03-04 10:03:02 -08001146 $(HOST_OUT_EXECUTABLES)/xdelta3 \
1147 $(HOST_OUT_EXECUTABLES)/syspatch_host
The Android Open Source Project88b60792009-03-03 19:28:42 -08001148
Colin Crossc312f312012-04-19 13:54:39 -07001149OTATOOLS := $(DISTTOOLS) \
1150 $(HOST_OUT_EXECUTABLES)/aapt
1151
Ying Wang06898662010-06-17 17:52:18 -07001152.PHONY: otatools
1153otatools: $(OTATOOLS)
1154
The Android Open Source Project88b60792009-03-03 19:28:42 -08001155# -----------------------------------------------------------------
1156# A zip of the directories that map to the target filesystem.
1157# This zip can be used to create an OTA package or filesystem image
1158# as a post-build step.
1159#
1160name := $(TARGET_PRODUCT)
1161ifeq ($(TARGET_BUILD_TYPE),debug)
1162 name := $(name)_debug
1163endif
1164name := $(name)-target_files-$(FILE_NAME_TAG)
1165
1166intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
1167BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
1168$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
1169$(BUILT_TARGET_FILES_PACKAGE): \
1170 zip_root := $(intermediates)/$(name)
1171
1172# $(1): Directory to copy
1173# $(2): Location to copy it to
1174# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
1175define package_files-copy-root
1176 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
1177 mkdir -p $(2) && \
1178 $(ACP) -rd $(strip $(1))/* $(2); \
1179 fi
1180endef
1181
1182built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -07001183 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -07001184 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001185 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
Doug Zongker25863d72011-09-19 15:02:03 -07001186 $(call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001187 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -08001188$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
1189
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001190$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
Ken Sumrall31ce31f2013-02-21 16:27:25 -08001191$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION)
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001192
Doug Zongkerc18736b2009-09-30 09:20:32 -07001193ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1194# default to common dir for device vendor
1195$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
1196else
1197$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1198endif
1199
The Android Open Source Project88b60792009-03-03 19:28:42 -08001200# Depending on the various images guarantees that the underlying
1201# directories are up-to-date.
1202$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001203 $(INSTALLED_BOOTIMAGE_TARGET) \
1204 $(INSTALLED_RADIOIMAGE_TARGET) \
1205 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -07001206 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001207 $(INSTALLED_USERDATAIMAGE_TARGET) \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001208 $(INSTALLED_CACHEIMAGE_TARGET) \
Ying Wanga0febe52013-03-20 11:02:05 -07001209 $(INSTALLED_VENDORIMAGE_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001210 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001211 $(SELINUX_FC) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001212 $(built_ota_tools) \
1213 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -07001214 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001215 | $(ACP)
1216 @echo "Package target files: $@"
1217 $(hide) rm -rf $@ $(zip_root)
1218 $(hide) mkdir -p $(dir $@) $(zip_root)
1219 @# Components of the recovery image
1220 $(hide) mkdir -p $(zip_root)/RECOVERY
1221 $(hide) $(call package_files-copy-root, \
1222 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
1223ifdef INSTALLED_KERNEL_TARGET
1224 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
1225endif
1226ifdef INSTALLED_2NDBOOTLOADER_TARGET
1227 $(hide) $(ACP) \
1228 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
1229endif
1230ifdef BOARD_KERNEL_CMDLINE
1231 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
1232endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001233ifdef BOARD_KERNEL_BASE
1234 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
1235endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001236ifdef BOARD_KERNEL_PAGESIZE
1237 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
1238endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001239 @# Components of the boot image
1240 $(hide) mkdir -p $(zip_root)/BOOT
1241 $(hide) $(call package_files-copy-root, \
1242 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1243ifdef INSTALLED_KERNEL_TARGET
1244 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1245endif
1246ifdef INSTALLED_2NDBOOTLOADER_TARGET
1247 $(hide) $(ACP) \
1248 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1249endif
1250ifdef BOARD_KERNEL_CMDLINE
1251 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1252endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001253ifdef BOARD_KERNEL_BASE
1254 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1255endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001256ifdef BOARD_KERNEL_PAGESIZE
1257 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1258endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001259 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1260 mkdir -p $(zip_root)/RADIO; \
1261 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001262 @# Contents of the system image
1263 $(hide) $(call package_files-copy-root, \
1264 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1265 @# Contents of the data image
1266 $(hide) $(call package_files-copy-root, \
1267 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Ying Wanga0febe52013-03-20 11:02:05 -07001268ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1269 @# Contents of the vendor image
1270 $(hide) $(call package_files-copy-root, \
1271 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
1272endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001273 @# Extra contents of the OTA package
1274 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001275 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1276 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001277 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001278 @# build them.
1279 $(hide) mkdir -p $(zip_root)/META
1280 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker816d73f2013-11-22 13:29:55 -08001281 $(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 -07001282 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -07001283 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Ken Sumrall31ce31f2013-02-21 16:27:25 -08001284 $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001285ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07001286 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001287endif
1288ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001289 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001290endif
1291ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001292 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001293endif
Doug Zongker37974732010-09-16 17:44:38 -07001294 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wang3c21fe52011-10-04 10:50:08 -07001295 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
Doug Zongker5d4808d2011-03-16 07:49:13 -07001296ifdef PRODUCT_EXTRA_RECOVERY_KEYS
1297 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
Doug Zongkere121d6a2011-02-01 14:13:52 -08001298endif
Jianxun Zhang09849492013-04-17 15:19:19 -07001299 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001300 $(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt
Doug Zongker9b23f2c2013-11-25 14:44:12 -08001301 $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
Michael Rungefacd9922013-12-20 11:50:16 -08001302 $(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt
Ying Wangbd93d422011-10-28 17:02:30 -07001303 $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
Doug Zongkerc9253822014-02-04 12:17:58 -08001304 $(hide) ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001305 @# Zip everything up, preserving symlinks
1306 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongker23f8bde2011-09-07 14:11:51 -07001307 @# Run fs_config on all the system, boot ramdisk, and recovery ramdisk files in the zip, and save the output
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001308 $(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
1309 $(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
1310 $(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 -07001311 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
Doug Zongker283e2a12010-03-15 17:52:32 -07001312
Ying Wanga0febe52013-03-20 11:02:05 -07001313.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001314target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1315
Doug Zongker367910f2009-06-15 18:56:51 -07001316
Doug Zongker367910f2009-06-15 18:56:51 -07001317ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang279f3082011-02-09 12:26:42 -08001318ifeq ($(filter generic%,$(TARGET_DEVICE)),)
Ying Wangfb0a3472010-08-25 16:06:06 -07001319ifneq ($(TARGET_NO_KERNEL),true)
Ying Wanga73b6562011-03-03 21:52:08 -08001320ifneq ($(recovery_fstab),)
Doug Zongker367910f2009-06-15 18:56:51 -07001321
Ying Wang09a00a62010-10-20 14:01:09 -07001322# -----------------------------------------------------------------
1323# OTA update package
1324
Doug Zongker8678df42009-06-15 14:30:14 -07001325name := $(TARGET_PRODUCT)
1326ifeq ($(TARGET_BUILD_TYPE),debug)
1327 name := $(name)_debug
1328endif
1329name := $(name)-ota-$(FILE_NAME_TAG)
1330
1331INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1332
1333$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1334
Ying Wang82cceba2012-08-13 15:03:00 -07001335$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001336 @echo "Package OTA: $@"
Bjorn Andersson612e2cd2012-11-25 16:53:44 -08001337 $(hide) MKBOOTIMG=$(BOARD_CUSTOM_MKBOOTIMG) \
1338 ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker26e66192014-02-20 13:22:07 -08001339 --block \
Doug Zongker602a84e2009-06-18 08:35:12 -07001340 -p $(HOST_OUT) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05001341 -k $(KEY_CERT_PAIR) \
1342 $(BUILT_TARGET_FILES_PACKAGE) $@
Doug Zongker8678df42009-06-15 14:30:14 -07001343
1344.PHONY: otapackage
1345otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1346
Ying Wang09a00a62010-10-20 14:01:09 -07001347# -----------------------------------------------------------------
1348# The update package
1349
1350name := $(TARGET_PRODUCT)
1351ifeq ($(TARGET_BUILD_TYPE),debug)
1352 name := $(name)_debug
1353endif
1354name := $(name)-img-$(FILE_NAME_TAG)
1355
1356INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1357
Ying Wang82cceba2012-08-13 15:03:00 -07001358$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
Ying Wang09a00a62010-10-20 14:01:09 -07001359 @echo "Package: $@"
Bjorn Andersson612e2cd2012-11-25 16:53:44 -08001360 $(hide) MKBOOTIMG=$(BOARD_CUSTOM_MKBOOTIMG) \
1361 ./build/tools/releasetools/img_from_target_files -v \
Ying Wang09a00a62010-10-20 14:01:09 -07001362 -p $(HOST_OUT) \
1363 $(BUILT_TARGET_FILES_PACKAGE) $@
1364
1365.PHONY: updatepackage
1366updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
1367
Ying Wanga73b6562011-03-03 21:52:08 -08001368endif # recovery_fstab is defined
Ying Wangfb0a3472010-08-25 16:06:06 -07001369endif # TARGET_NO_KERNEL != true
Ying Wang279f3082011-02-09 12:26:42 -08001370endif # TARGET_DEVICE != generic*
Doug Zongker367910f2009-06-15 18:56:51 -07001371endif # TARGET_PRODUCT != sdk
Doug Zongker8678df42009-06-15 14:30:14 -07001372
Ying Wangd0244b32011-11-17 14:51:12 -08001373ifdef is_tests_build
Doug Zongker8678df42009-06-15 14:30:14 -07001374# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001375# A zip of the tests that are built when running "make tests".
1376# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
Ying Wangc5f04972012-03-13 11:22:04 -07001377# only grab DATA, and it's called "*-tests-*.zip".
The Android Open Source Project88b60792009-03-03 19:28:42 -08001378#
1379name := $(TARGET_PRODUCT)
1380ifeq ($(TARGET_BUILD_TYPE),debug)
1381 name := $(name)_debug
1382endif
1383name := $(name)-tests-$(FILE_NAME_TAG)
1384
1385intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
1386BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
1387$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
1388$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
1389
Ying Wang64661472012-06-11 16:43:40 -07001390# Depending on the image dependency files, instead of the image files itself,
1391# guarantees that the underlying directories are up-to-date,
1392# but don't really build the image.
The Android Open Source Project88b60792009-03-03 19:28:42 -08001393$(BUILT_TESTS_ZIP_PACKAGE): \
Ying Wang64661472012-06-11 16:43:40 -07001394 $(INTERNAL_USERDATAIMAGE_FILES) \
Ying Wang160b6702012-03-13 18:58:27 -07001395 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001396 @echo "Package test files: $@"
1397 $(hide) rm -rf $@ $(zip_root)
1398 $(hide) mkdir -p $(dir $@) $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001399 @# Contents of the data image
1400 $(hide) $(call package_files-copy-root, \
1401 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1402 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
1403
Ying Wang160b6702012-03-13 18:58:27 -07001404.PHONY: tests
1405tests: $(BUILT_TESTS_ZIP_PACKAGE)
Ying Wangd0244b32011-11-17 14:51:12 -08001406
Ying Wang160b6702012-03-13 18:58:27 -07001407ifneq (,$(filter tests, $(MAKECMDGOALS)))
Ying Wangd0244b32011-11-17 14:51:12 -08001408 $(call dist-for-goals, tests, $(BUILT_TESTS_ZIP_PACKAGE))
Ying Wang160b6702012-03-13 18:58:27 -07001409endif
Ying Wangd0244b32011-11-17 14:51:12 -08001410endif # is_tests_build
Ying Wang160b6702012-03-13 18:58:27 -07001411
The Android Open Source Project88b60792009-03-03 19:28:42 -08001412# -----------------------------------------------------------------
1413# A zip of the symbols directory. Keep the full paths to make it
1414# more obvious where these files came from.
1415#
1416name := $(TARGET_PRODUCT)
1417ifeq ($(TARGET_BUILD_TYPE),debug)
1418 name := $(name)_debug
1419endif
1420name := $(name)-symbols-$(FILE_NAME_TAG)
1421
1422SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1423$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1424 @echo "Package symbols: $@"
1425 $(hide) rm -rf $@
1426 $(hide) mkdir -p $(dir $@)
1427 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1428
1429# -----------------------------------------------------------------
1430# A zip of the Android Apps. Not keeping full path so that we don't
1431# include product names when distributing
1432#
1433name := $(TARGET_PRODUCT)
1434ifeq ($(TARGET_BUILD_TYPE),debug)
1435 name := $(name)_debug
1436endif
1437name := $(name)-apps-$(FILE_NAME_TAG)
1438
1439APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1440$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1441 @echo "Package apps: $@"
1442 $(hide) rm -rf $@
1443 $(hide) mkdir -p $(dir $@)
Robert Craig59ec1952014-02-26 11:48:20 -05001444 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/* $(TARGET_OUT_APPS_PRIVILEGED)/*
The Android Open Source Project88b60792009-03-03 19:28:42 -08001445
Guang Zhu0198d6e2010-04-23 11:54:37 -07001446
1447#------------------------------------------------------------------
1448# A zip of emma code coverage meta files. Generated for fully emma
1449# instrumented build.
1450#
Ying Wangbc415dd2012-08-15 12:22:44 -07001451ifeq (true,$(EMMA_INSTRUMENT))
Guang Zhu0198d6e2010-04-23 11:54:37 -07001452EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
Ying Wangbc415dd2012-08-15 12:22:44 -07001453# the dependency will be set up later in build/core/main.mk.
1454$(EMMA_META_ZIP) :
Guang Zhu0198d6e2010-04-23 11:54:37 -07001455 @echo "Collecting Emma coverage meta files."
Ying Wang1ff08362013-12-27 15:55:08 -08001456 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "coverage.em" | \
Guang Zhu0198d6e2010-04-23 11:54:37 -07001457 zip -@ -q $@
1458
Ying Wangbc415dd2012-08-15 12:22:44 -07001459endif # EMMA_INSTRUMENT=true
1460
Ying Wangae9115a2013-08-22 20:52:47 -07001461#------------------------------------------------------------------
1462# A zip of Proguard obfuscation dictionary files.
1463# Only for apps_only build.
1464#
1465ifdef TARGET_BUILD_APPS
Ying Wangc62c92c2013-08-28 18:38:25 -07001466PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Ying Wangae9115a2013-08-22 20:52:47 -07001467# the dependency will be set up later in build/core/main.mk.
1468$(PROGUARD_DICT_ZIP) :
1469 @echo "Packaging Proguard obfuscation dictionary files."
1470 $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary`; \
1471 if [ -n "$$dict_files" ]; then \
Ying Wang33d64592013-11-25 17:39:50 -08001472 unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \
1473 zip -q $@ $$dict_files $$unobfuscated_jars; \
Ying Wangae9115a2013-08-22 20:52:47 -07001474 else \
Ying Wangc62c92c2013-08-28 18:38:25 -07001475 touch $(dir $@)/dummy; \
1476 (cd $(dir $@) && zip -q $(notdir $@) dummy); \
1477 zip -qd $@ dummy; \
1478 rm $(dir $@)/dummy; \
Ying Wangae9115a2013-08-22 20:52:47 -07001479 fi
1480
1481endif # TARGET_BUILD_APPS
1482
The Android Open Source Project88b60792009-03-03 19:28:42 -08001483# -----------------------------------------------------------------
1484# dalvik something
1485.PHONY: dalvikfiles
1486dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1487
1488# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001489# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07001490ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001491INTERNAL_EMULATOR_PACKAGE_FILES += \
1492 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08001493 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001494 $(INSTALLED_RAMDISK_TARGET) \
1495 $(INSTALLED_SYSTEMIMAGE) \
1496 $(INSTALLED_USERDATAIMAGE_TARGET)
1497
1498name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1499
1500INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1501
1502$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1503 @echo "Package: $@"
1504 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1505
Ying Wang7d8c5352012-07-26 10:15:21 -07001506endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001507# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08001508# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08001509# The pdk package (Platform Development Kit)
1510
Keun young Park7fc7aad2012-02-27 15:49:23 -08001511#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1512# include development/pdk/Pdk.mk
1513#endif
1514
The Android Open Source Project88b60792009-03-03 19:28:42 -08001515
1516# -----------------------------------------------------------------
1517# The SDK
1518
The Android Open Source Project88b60792009-03-03 19:28:42 -08001519# The SDK includes host-specific components, so it belongs under HOST_OUT.
1520sdk_dir := $(HOST_OUT)/sdk
1521
1522# Build a name that looks like:
1523#
1524# linux-x86 --> android-sdk_12345_linux-x86
1525# darwin-x86 --> android-sdk_12345_mac-x86
1526# windows-x86 --> android-sdk_12345_windows
1527#
1528sdk_name := android-sdk_$(FILE_NAME_TAG)
1529ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001530 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001531else
Joe Onorato03fbe402009-04-13 08:31:16 -07001532 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001533endif
1534ifneq ($(HOST_OS),windows)
Joe Onorato03fbe402009-04-13 08:31:16 -07001535 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001536endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001537sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001538
1539sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1540
1541ATREE_FILES :=
1542-include $(sdk_dep_file)
1543
1544# if we don't have a real list, then use "everything"
1545ifeq ($(strip $(ATREE_FILES)),)
1546ATREE_FILES := \
1547 $(ALL_PREBUILT) \
1548 $(ALL_COPIED_HEADERS) \
1549 $(ALL_GENERATED_SOURCES) \
1550 $(ALL_DEFAULT_INSTALLED_MODULES) \
1551 $(INSTALLED_RAMDISK_TARGET) \
1552 $(ALL_DOCS) \
1553 $(ALL_SDK_FILES)
1554endif
1555
1556atree_dir := development/build
1557
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001558# sdk/build/tools.atree contains the generic rules, while
1559#
1560# sdk/build/tools.$(TARGET_ARCH).atree contains target-specific rules
1561# the latter is optional.
1562#
1563sdk_tools_atree_files := sdk/build/tools.atree
1564ifneq (,$(strip $(wildcard sdk/build/tools.$(TARGET_ARCH).atree)))
1565 sdk_tools_atree_files += sdk/build/tools.$(TARGET_ARCH).atree
1566endif
Raphael Moll3ab307a2012-03-02 12:40:04 -08001567ifneq (,$(strip $(wildcard sdk/build/tools.$(HOST_OS).atree)))
1568 sdk_tools_atree_files += sdk/build/tools.$(HOST_OS).atree
1569endif
1570ifneq (,$(strip $(wildcard sdk/build/tools.$(HOST_OS)-$(HOST_ARCH).atree)))
1571 sdk_tools_atree_files += sdk/build/tools.$(HOST_OS)-$(HOST_ARCH).atree
1572endif
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001573
The Android Open Source Project88b60792009-03-03 19:28:42 -08001574sdk_atree_files := \
1575 $(atree_dir)/sdk.exclude.atree \
Xavier Ducrohetffd50872010-09-27 15:51:32 -07001576 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree \
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001577 $(sdk_tools_atree_files)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001578
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02001579# development/build/sdk-android-<abi>.atree is used to differentiate
1580# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
1581# files like the kernel image. We use TARGET_CPU_ABI because we don't
1582# have a better way to distinguish between CPU models.
1583ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
1584 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
1585endif
1586
Griff Hazen433febb2014-02-28 08:45:59 -08001587ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),)
1588sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES)
1589else
1590sdk_atree_files += $(atree_dir)/sdk.atree
1591endif
1592
The Android Open Source Project88b60792009-03-03 19:28:42 -08001593deps := \
1594 $(target_notice_file_txt) \
1595 $(tools_notice_file_txt) \
1596 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001597 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001598 $(INSTALLED_SYSTEMIMAGE) \
1599 $(INSTALLED_USERDATAIMAGE_TARGET) \
1600 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001601 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001602 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001603 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08001604 $(sdk_atree_files) \
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001605 $(sdk_tools_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001606 $(HOST_OUT_EXECUTABLES)/atree \
Joe Onorato63d56da2012-08-17 04:19:38 -07001607 $(HOST_OUT_EXECUTABLES)/line_endings
The Android Open Source Project88b60792009-03-03 19:28:42 -08001608
1609INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1610$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1611$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1612$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1613$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1614
1615# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1616#
1617#SDK_GNU_ERROR := true
1618
1619$(INTERNAL_SDK_TARGET): $(deps)
1620 @echo "Package SDK: $@"
1621 $(hide) rm -rf $(PRIVATE_DIR) $@
1622 $(hide) for f in $(target_gnu_MODULES); do \
1623 if [ -f $$f ]; then \
1624 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1625 including GNU target $$f >&2; \
1626 FAIL=$(SDK_GNU_ERROR); \
1627 fi; \
1628 done; \
1629 if [ $$FAIL ]; then exit 1; fi
1630 $(hide) ( \
Raphael Mollec5fe912012-06-06 19:33:31 -07001631 ATREE_STRIP="strip -x" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001632 $(HOST_OUT_EXECUTABLES)/atree \
1633 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1634 -m $(PRIVATE_DEP_FILE) \
1635 -I . \
1636 -I $(PRODUCT_OUT) \
1637 -I $(HOST_OUT) \
1638 -I $(TARGET_COMMON_OUT_ROOT) \
1639 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
Raphael Moll7558ad52011-01-05 14:58:17 -08001640 -v "OUT_DIR=$(OUT_DIR)" \
Raphael2a533172011-11-15 16:29:16 -08001641 -v "HOST_OUT=$(HOST_OUT)" \
Bruce Beare18a130e2011-02-18 15:06:20 -08001642 -v "TARGET_ARCH=$(TARGET_ARCH)" \
1643 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
David 'Digit' Turner557c51f2011-08-25 14:28:03 +02001644 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001645 -o $(PRIVATE_DIR) && \
1646 cp -f $(target_notice_file_txt) \
Xavier Ducrohet6de7bc62011-09-21 10:22:19 -07001647 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001648 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
Xavier Ducrohet4216a8c2011-03-15 13:28:40 -07001649 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001650 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Raphael7a6a9c32011-02-01 13:30:00 -08001651 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001652 chmod -R ug+rwX $(PRIVATE_DIR) && \
1653 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1654 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1655
Raphael3d224a02010-04-16 17:50:09 -07001656
1657# Is a Windows SDK requested? If so, we need some definitions from here
1658# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08001659MAIN_SDK_NAME := $(sdk_name)
1660MAIN_SDK_DIR := $(sdk_dir)
1661MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Raphael3d224a02010-04-16 17:50:09 -07001662ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07001663include $(TOPDIR)development/build/tools/windows_sdk.mk
1664endif
1665
The Android Open Source Project88b60792009-03-03 19:28:42 -08001666# -----------------------------------------------------------------
1667# Findbugs
1668INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1669INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1670$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1671 @echo UnionBugs: $@
1672 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1673 > $@
1674$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1675 @echo ConvertXmlToText: $@
1676 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07001677 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001678
1679# -----------------------------------------------------------------
1680# Findbugs
1681
1682# -----------------------------------------------------------------
1683# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07001684ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001685include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01001686-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07001687-include $(sort $(wildcard device/*/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07001688endif
Raphaelc4d47312011-02-15 16:09:36 -08001689
1690# -----------------------------------------------------------------
1691# Create SDK repository packages. Must be done after tasks/* since
1692# we need the addon rules defined.
1693ifneq ($(sdk_repo_goal),)
1694include $(TOPDIR)development/build/tools/sdk_repo.mk
1695endif