blob: e03b03e9e0629c0bcc69e50774a8ccd4a0ce8f19 [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
170
171$(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 -0800172 @echo Target buildinfo: $@
173 @mkdir -p $(dir $@)
174 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
175 TARGET_DEVICE="$(TARGET_DEVICE)" \
176 PRODUCT_NAME="$(TARGET_PRODUCT)" \
177 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
178 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
179 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700180 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800181 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
182 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
183 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
184 BUILD_ID="$(BUILD_ID)" \
185 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
186 BUILD_NUMBER="$(BUILD_NUMBER)" \
187 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
188 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700189 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800190 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
191 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
192 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
193 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
Narayan Kamath1a43b372014-03-26 17:33:55 +0000194 TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700195 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800196 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Joe Onorato25939e22010-11-09 08:53:01 -0800197 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800198 bash $(BUILDINFO_SH) > $@
Johan Redestig674a27d2012-04-12 17:00:58 +0200199 $(hide) $(foreach file,$(system_prop_file), \
200 if [ -f "$(file)" ]; then \
201 echo "#" >> $@; \
202 echo Target buildinfo from: "$(file)"; \
203 echo "# from $(file)" >> $@; \
204 echo "#" >> $@; \
205 cat $(file) >> $@; \
206 fi;)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800207 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
208 $(hide) echo >> $@; \
209 echo "#" >> $@; \
210 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
211 echo "#" >> $@; )
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700212 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
213 echo "$(line)" >> $@;)
Joe Onorato9197a482011-06-08 16:04:14 -0700214 $(hide) build/tools/post_process_props.py $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800215
216build_desc :=
217
218# -----------------------------------------------------------------
219# sdk-build.prop
220#
221# There are certain things in build.prop that we don't want to
222# ship with the sdk; remove them.
223
224# This must be a list of entire property keys followed by
225# "=" characters, without any internal spaces.
226sdk_build_prop_remove := \
227 ro.build.user= \
228 ro.build.host= \
229 ro.product.brand= \
230 ro.product.manufacturer= \
231 ro.product.device=
232# TODO: Remove this soon-to-be obsolete property
233sdk_build_prop_remove += ro.build.product=
234INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
235$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
236 @echo SDK buildinfo: $@
237 @mkdir -p $(dir $@)
238 $(hide) grep -v "$(subst $(space),\|,$(strip \
239 $(sdk_build_prop_remove)))" $< > $@.tmp
240 $(hide) for x in $(sdk_build_prop_remove); do \
241 echo "$$x"generic >> $@.tmp; done
242 $(hide) mv $@.tmp $@
243
244# -----------------------------------------------------------------
245# package stats
246PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
247PACKAGES_TO_STAT := \
248 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
249 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
250$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
251 @echo Package stats: $@
252 @mkdir -p $(dir $@)
253 $(hide) rm -f $@
254 $(hide) build/tools/dump-package-stats $^ > $@
255
256.PHONY: package-stats
257package-stats: $(PACKAGE_STATS_FILE)
258
259# -----------------------------------------------------------------
260# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700261# Use a macro to add newline to each echo command
262define _apkcerts_echo_with_newline
263$(hide) echo $(1)
264
265endef
266
The Android Open Source Project88b60792009-03-03 19:28:42 -0800267name := $(TARGET_PRODUCT)
268ifeq ($(TARGET_BUILD_TYPE),debug)
269 name := $(name)_debug
270endif
271name := $(name)-apkcerts-$(FILE_NAME_TAG)
272intermediates := \
273 $(call intermediates-dir-for,PACKAGING,apkcerts)
274APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800275# We don't need to really build all the modules.
276# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700277$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800278 @echo APK certs list: $@
279 @mkdir -p $(dir $@)
280 @rm -f $@
Ying Wangd9a88d52012-10-26 09:21:28 -0700281 $(foreach p,$(PACKAGES),\
282 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
283 $(call _apkcerts_echo_with_newline,\
284 'name="$(p).apk" certificate="EXTERNAL" \
285 private_key=""' >> $@),\
286 $(call _apkcerts_echo_with_newline,\
287 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
288 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@)))
289 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700290 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800291
292.PHONY: apkcerts-list
293apkcerts-list: $(APKCERTS_FILE)
294
Ying Wang15e487a2011-02-15 10:56:18 -0800295ifneq (,$(TARGET_BUILD_APPS))
296 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
297endif
Ying Wangefb21682010-07-23 16:42:13 -0700298
The Android Open Source Project88b60792009-03-03 19:28:42 -0800299# -----------------------------------------------------------------
300# module info file
301ifdef CREATE_MODULE_INFO_FILE
302 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
303 $(info Generating $(MODULE_INFO_FILE)...)
304 $(shell rm -f $(MODULE_INFO_FILE))
305 $(foreach m,$(ALL_MODULES), \
306 $(shell echo "NAME=\"$(m)\"" \
307 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
308 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
309 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
310 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
311endif
312
Doug Zongker8678df42009-06-15 14:30:14 -0700313# -----------------------------------------------------------------
314
Ying Wang3c21fe52011-10-04 10:50:08 -0700315# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700316# for future OTA packages installed by this system. Actual product
317# deliverables will be re-signed by hand. We expect this file to
318# exist with the suffixes ".x509.pem" and ".pk8".
Ying Wang3c21fe52011-10-04 10:50:08 -0700319DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Doug Zongker8678df42009-06-15 14:30:14 -0700320
321
Jeff Browne33ba4c2011-07-11 22:11:46 -0700322# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800323# if they don't do anything.
324.PHONY: systemimage
325systemimage:
326
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800327# -----------------------------------------------------------------
328
329.PHONY: event-log-tags
330
Joe Onoratob7510532010-07-14 10:22:54 -0700331# Produce an event logs tag file for everything we know about, in order
332# to properly allocate numbers. Then produce a file that's filtered
333# for what's going to be installed.
334
335all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
336
Colin Crossdc8f8e42012-04-12 13:25:54 -0700337event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
338
Joe Onoratob7510532010-07-14 10:22:54 -0700339# Include tags from all packages that we know about
340all_event_log_tags_src := \
341 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
342
Colin Crossdc8f8e42012-04-12 13:25:54 -0700343# PDK builds will already have a full list of tags that needs to get merged
344# in with the ones from source
345pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
346
347$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
348$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700349 $(hide) mkdir -p $(dir $@)
350 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
351
Doug Zongkera34fa952011-02-23 12:17:29 -0800352# Include tags from all packages included in this product, plus all
353# tags that are part of the system (ie, not in a vendor/ or device/
354# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800355event_log_tags_src := \
356 $(sort $(foreach m,\
357 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
358 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800359 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
360 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800361
Colin Crossdc8f8e42012-04-12 13:25:54 -0700362$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700363$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossdc8f8e42012-04-12 13:25:54 -0700364$(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 -0800365 $(hide) mkdir -p $(dir $@)
Joe Onoratob7510532010-07-14 10:22:54 -0700366 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800367
368event-log-tags: $(event_log_tags_file)
369
370ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
371
Joe Onoratob7510532010-07-14 10:22:54 -0700372
The Android Open Source Project88b60792009-03-03 19:28:42 -0800373# #################################################################
374# Targets for boot/OS images
375# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800376ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
377 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
378 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
379 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
380 else
381 INSTALLED_2NDBOOTLOADER_TARGET :=
382 endif
383else
384 INSTALLED_BOOTLOADER_MODULE :=
385 INSTALLED_2NDBOOTLOADER_TARGET :=
386endif # TARGET_NO_BOOTLOADER
387ifneq ($(strip $(TARGET_NO_KERNEL)),true)
388 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
389else
390 INSTALLED_KERNEL_TARGET :=
391endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800392
Geremy Condrafd6f7512013-06-16 17:26:08 -0700393VERITY_SIGNER_CMD := $(HOST_OUT_EXECUTABLES)/verity_signer
394
The Android Open Source Project88b60792009-03-03 19:28:42 -0800395# -----------------------------------------------------------------
396# the ramdisk
397INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
398 $(ALL_PREBUILT) \
399 $(ALL_COPIED_HEADERS) \
400 $(ALL_GENERATED_SOURCES) \
401 $(ALL_DEFAULT_INSTALLED_MODULES))
402
Joe Onorato64d85d02009-04-09 19:31:12 -0700403BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
404
405# We just build this directly to the install location.
406INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Ying Wang82cceba2012-08-13 15:03:00 -0700407$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800408 $(call pretty,"Target ram disk: $@")
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700409 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800410
Ying Wangad7fd292013-08-08 16:34:29 -0700411.PHONY: ramdisk-nodeps
412ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP)
413 @echo "make $@: ignoring dependencies"
414 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800415
416ifneq ($(strip $(TARGET_NO_KERNEL)),true)
417
418# -----------------------------------------------------------------
419# the boot image, which is a collection of other images.
420INTERNAL_BOOTIMAGE_ARGS := \
421 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
422 --kernel $(INSTALLED_KERNEL_TARGET) \
423 --ramdisk $(INSTALLED_RAMDISK_TARGET)
424
425INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
426
427BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
428ifdef BOARD_KERNEL_CMDLINE
429 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
430endif
431
Dima Zavin1e0847c2009-05-07 19:43:08 -0700432BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
433ifdef BOARD_KERNEL_BASE
434 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
435endif
436
Ying Wangffff0022010-08-23 12:56:25 -0700437BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
438ifdef BOARD_KERNEL_PAGESIZE
439 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
440endif
441
The Android Open Source Project88b60792009-03-03 19:28:42 -0800442INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
443
444ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
445tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
446INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
447INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
448$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
449 $(call pretty,"Target boot image: $@")
450 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
451
Ying Wangad7fd292013-08-08 16:34:29 -0700452.PHONY: bootimage-nodeps
453bootimage-nodeps: $(MKEXT2IMG)
454 @echo "make $@: ignoring dependencies"
455 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
456
The Android Open Source Project88b60792009-03-03 19:28:42 -0800457else # TARGET_BOOTIMAGE_USE_EXT2 != true
458
459$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
460 $(call pretty,"Target boot image: $@")
Doug Zongkerd5131602012-08-02 14:46:42 -0700461 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Doug Zongkered96e882009-08-26 09:37:07 -0700462 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
Ying Wangad7fd292013-08-08 16:34:29 -0700463
464.PHONY: bootimage-nodeps
465bootimage-nodeps: $(MKBOOTIMG)
466 @echo "make $@: ignoring dependencies"
467 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
468 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
469
The Android Open Source Project88b60792009-03-03 19:28:42 -0800470endif # TARGET_BOOTIMAGE_USE_EXT2
471
472else # TARGET_NO_KERNEL
473# HACK: The top-level targets depend on the bootimage. Not all targets
474# can produce a bootimage, though, and emulator targets need the ramdisk
475# instead. Fake it out by calling the ramdisk the bootimage.
476# TODO: make the emulator use bootimages, and make mkbootimg accept
477# kernel-less inputs.
478INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
479endif
480
481# -----------------------------------------------------------------
482# NOTICE files
483#
Steve Blockd14d3b42012-03-01 11:34:41 +0000484# We are required to publish the licenses for all code under BSD, GPL and
485# Apache licenses (and possibly other more exotic ones as well). We err on the
486# side of caution, so the licenses for other third-party code are included here
487# too.
488#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800489# This needs to be before the systemimage rules, because it adds to
490# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
491# go into the systemimage.
492
Steve Block495e5852012-02-29 19:18:08 +0000493.PHONY: notice_files
494
The Android Open Source Project88b60792009-03-03 19:28:42 -0800495# Create the rule to combine the files into text and html forms
Steve Block495e5852012-02-29 19:18:08 +0000496# $(1) - Plain text output file
497# $(2) - HTML output file
498# $(3) - File title
499# $(4) - Directory to use. Notice files are all $(4)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800500# directories in there will be used for scratch
Steve Block495e5852012-02-29 19:18:08 +0000501# $(5) - Dependencies for the output files
The Android Open Source Project88b60792009-03-03 19:28:42 -0800502#
503# The algorithm here is that we go collect a hash for each of the notice
504# files and write the names of the files that match that hash. Then
505# to generate the real files, we go print out all of the files and their
506# hashes.
507#
508# These rules are fairly complex, so they depend on this makefile so if
509# it changes, they'll run again.
510#
511# TODO: We could clean this up so that we just record the locations of the
512# original notice files instead of making rules to copy them somwehere.
513# Then we could traverse that without quite as much bash drama.
514define combine-notice-files
Steve Block495e5852012-02-29 19:18:08 +0000515$(1) $(2): PRIVATE_MESSAGE := $(3)
Daniel Berlinf5a97d72012-03-29 10:33:19 -0400516$(1) $(2): PRIVATE_DIR := $(4)
Ying Wangc4625ab2012-04-09 12:16:23 -0700517$(1) : $(2)
518$(2) : $(5) $(BUILD_SYSTEM)/Makefile build/tools/generate-notice-files.py
Daniel Berlinf5a97d72012-03-29 10:33:19 -0400519 build/tools/generate-notice-files.py $(1) $(2) $$(PRIVATE_MESSAGE) $$(PRIVATE_DIR)/src
Steve Block495e5852012-02-29 19:18:08 +0000520notice_files: $(1) $(2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800521endef
522
523# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
524# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
525# the src subdirectory.
526
Steve Block495e5852012-02-29 19:18:08 +0000527target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800528target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
529target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
Steve Block495e5852012-02-29 19:18:08 +0000530tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800531tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
532
Ying Wang62c81f82013-08-22 20:02:03 -0700533ifndef TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800534kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
Ying Wang4534d812012-04-09 17:04:12 -0700535pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800536
537$(eval $(call combine-notice-files, \
Steve Block495e5852012-02-29 19:18:08 +0000538 $(target_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800539 $(target_notice_file_html), \
540 "Notices for files contained in the filesystem images in this directory:", \
541 $(TARGET_OUT_NOTICE_FILES), \
Ying Wang4534d812012-04-09 17:04:12 -0700542 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800543
544$(eval $(call combine-notice-files, \
Steve Block495e5852012-02-29 19:18:08 +0000545 $(tools_notice_file_txt), \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800546 $(tools_notice_file_html), \
547 "Notices for files contained in the tools directory:", \
548 $(HOST_OUT_NOTICE_FILES), \
549 $(ALL_DEFAULT_INSTALLED_MODULES)))
550
551# Install the html file at /system/etc/NOTICE.html.gz.
552# This is not ideal, but this is very late in the game, after a lot of
553# the module processing has already been done -- in fact, we used the
554# fact that all that has been done to get the list of modules that we
555# need notice files for.
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700556$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700557 $(hide) $(MINIGZIP) -9 < $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800558installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
559$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
560 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700561
562# if we've been run my mm, mmm, etc, don't reinstall this every time
563ifeq ($(ONE_SHOT_MAKEFILE),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800564ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700565endif
Ying Wang62c81f82013-08-22 20:02:03 -0700566endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -0800567
568# The kernel isn't really a module, so to get its module file in there, we
569# make the target NOTICE files depend on this particular file too, which will
570# then be in the right directory for the find in combine-notice-files to work.
571$(kernel_notice_file): \
Jean-Baptiste Querua230c4d2012-01-06 15:05:53 -0800572 prebuilts/qemu-kernel/arm/LINUX_KERNEL_COPYING \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800573 | $(ACP)
574 @echo Copying: $@
575 $(hide) mkdir -p $(dir $@)
576 $(hide) $(ACP) $< $@
577
578
Doug Zongker8678df42009-06-15 14:30:14 -0700579# -----------------------------------------------------------------
580# Build a keystore with the authorized keys in it, used to verify the
581# authenticity of downloaded OTA packages.
582#
583# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
584# before the rules that use that variable to build the image.
585ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
586$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Doug Zongker37c0e272009-06-15 15:36:16 -0700587$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Doug Zongker8678df42009-06-15 14:30:14 -0700588 $(hide) rm -f $@
589 $(hide) mkdir -p $(dir $@)
Doug Zongker37c0e272009-06-15 15:36:16 -0700590 $(hide) zip -qj $@ $<
Doug Zongker8678df42009-06-15 14:30:14 -0700591
592.PHONY: otacerts
593otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
594
595
The Android Open Source Project88b60792009-03-03 19:28:42 -0800596# #################################################################
597# Targets for user images
598# #################################################################
599
Ying Wang933abf12010-06-16 14:31:34 -0700600INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800601ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -0700602INTERNAL_USERIMAGES_USE_EXT := true
603INTERNAL_USERIMAGES_EXT_VARIANT := ext2
604else
605ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
606INTERNAL_USERIMAGES_USE_EXT := true
607INTERNAL_USERIMAGES_EXT_VARIANT := ext3
608else
609ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
610INTERNAL_USERIMAGES_USE_EXT := true
611INTERNAL_USERIMAGES_EXT_VARIANT := ext4
612endif
613endif
614endif
615
Ying Wang542903a2010-11-17 15:40:38 -0800616ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
617 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
618endif
619
Colin Cross0a7b2c52010-05-07 02:23:59 -0700620ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
Ying Wang69e9b4d2012-11-26 18:10:23 -0800621INTERNAL_USERIMAGES_DEPS := $(MKEXTUSERIMG) $(MAKE_EXT4FS) $(SIMG2IMG) $(E2FSCK)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800622else
Colin Cross144b0282010-05-10 13:04:47 -0700623INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800624endif
Ying Wang178ef922011-10-31 18:13:30 -0700625INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800626
Geremy Condrafd6f7512013-06-16 17:26:08 -0700627ifeq (true, $(PRODUCT_SUPPORTS_VERITY))
628INTERNAL_USERIMAGES_DEPS += $(HOST_OUT_EXECUTABLES)/verity_signer
629endif
630
Ying Wangfdbd9cb2012-11-21 10:47:00 -0800631SELINUX_FC := $(TARGET_ROOT_OUT)/file_contexts
632INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
633
Ying Wangbd93d422011-10-28 17:02:30 -0700634# $(1): the path of the output dictionary file
Ying Wang6a42a252013-02-27 13:54:02 -0800635# $(2): additional "key=value" pairs to append to the dictionary file.
Ying Wangbd93d422011-10-28 17:02:30 -0700636define generate-userimage-prop-dictionary
637$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
638$(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
639$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wang9f8e8db2011-11-04 11:37:01 -0700640$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
641$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wanga0febe52013-03-20 11:02:05 -0700642$(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
643$(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -0700644$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
645$(if $(mkyaffs2_extra_flags),$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(1))
Ying Wangfdbd9cb2012-11-21 10:47:00 -0800646$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
Ying Wang6a42a252013-02-27 13:54:02 -0800647$(if $(2),$(hide) $(foreach kv,$(2),echo "$(kv)" >> $(1);))
Ying Wangbd93d422011-10-28 17:02:30 -0700648endef
649
The Android Open Source Project88b60792009-03-03 19:28:42 -0800650# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -0700651# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700652
653# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
Mike Lockwooddaf5e222012-10-18 10:17:47 -0700654ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700655
Doug Zongker4647f122009-07-02 09:00:54 -0700656INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
657
658recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
659recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
660recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
661recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
662recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
663recovery_resources_common := $(call include-path-for, recovery)/res
Doug Zongkere1297322013-03-06 15:04:31 -0800664
Doug Zongker25d55f82014-04-04 13:51:15 -0700665ifneq (,$(filter xxxhdpi,$(PRODUCT_AAPT_CONFIG_SP)))
666recovery_resources_common := $(recovery_resources_common)-xxxhdpi
667else ifneq (,$(filter xxhdpi,$(PRODUCT_AAPT_CONFIG_SP)))
668recovery_resources_common := $(recovery_resources_common)-xxhdpi
669else ifneq (,$(filter xhdpi,$(PRODUCT_AAPT_CONFIG_SP)))
670recovery_resources_common := $(recovery_resources_common)-xhdpi
671else ifneq (,$(filter hdpi,$(PRODUCT_AAPT_CONFIG_SP)))
672recovery_resources_common := $(recovery_resources_common)-hdpi
673else ifneq (,$(filter mdpi,$(PRODUCT_AAPT_CONFIG_SP)))
674recovery_resources_common := $(recovery_resources_common)-mdpi
675else
676# xhdpi is closest in size to the single set of resources we had
677# before, so make that the default if PRODUCT_AAPT_CONFIG doesn't
678# specify a dpi we have.
679recovery_resources_common := $(recovery_resources_common)-xhdpi
680endif
681
Doug Zongkere1297322013-03-06 15:04:31 -0800682# Select the 18x32 font on high-density devices; and the 12x22 font on
683# other devices. Note that the font selected here can be overridden
684# for a particular device by putting a font.png in its private
685# recovery resources.
686ifneq (,$(filter xxhdpi xhdpi,$(subst $(comma),$(space),$(PRODUCT_AAPT_CONFIG))))
687recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
688else
689recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
690endif
691
Doug Zongker4647f122009-07-02 09:00:54 -0700692recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
693recovery_resource_deps := $(shell find $(recovery_resources_common) \
694 $(recovery_resources_private) -type f)
Andrew Boiefa61ff02012-09-28 09:33:45 -0700695ifdef TARGET_RECOVERY_FSTAB
696recovery_fstab := $(TARGET_RECOVERY_FSTAB)
697else
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700698recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -0700699endif
Doug Zongker56588872012-08-20 15:38:58 -0700700# Named '.dat' so we don't attempt to use imgdiff for patching it.
701RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
Doug Zongker4647f122009-07-02 09:00:54 -0700702
703ifeq ($(recovery_resources_private),)
704 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
705endif
706
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700707ifeq ($(recovery_fstab),)
708 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
709endif
710
Doug Zongker4647f122009-07-02 09:00:54 -0700711INTERNAL_RECOVERYIMAGE_ARGS := \
712 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
713 --kernel $(recovery_kernel) \
714 --ramdisk $(recovery_ramdisk)
715
716# Assumes this has already been stripped
717ifdef BOARD_KERNEL_CMDLINE
718 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
719endif
720ifdef BOARD_KERNEL_BASE
721 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
722endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700723BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
724ifdef BOARD_KERNEL_PAGESIZE
725 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
726endif
Doug Zongker4647f122009-07-02 09:00:54 -0700727
728# Keys authorized to sign OTA packages this build will accept. The
Ying Wang3c21fe52011-10-04 10:50:08 -0700729# build always uses dev-keys for this; release packaging tools will
Doug Zongker4647f122009-07-02 09:00:54 -0700730# substitute other keys for this one.
Ying Wang3c21fe52011-10-04 10:50:08 -0700731OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem
Doug Zongker4647f122009-07-02 09:00:54 -0700732
733# Generate a file containing the keys that will be read by the
734# recovery binary.
735RECOVERY_INSTALL_OTA_KEYS := \
736 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
737DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
738$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
Doug Zongker5d4808d2011-03-16 07:49:13 -0700739$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
Doug Zongkere121d6a2011-02-01 14:13:52 -0800740$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys)
741 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
Doug Zongker4647f122009-07-02 09:00:54 -0700742 @rm -rf $@
743 @mkdir -p $(dir $@)
Doug Zongkere121d6a2011-02-01 14:13:52 -0800744 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
Doug Zongker4647f122009-07-02 09:00:54 -0700745
746$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
747 $(INSTALLED_RAMDISK_TARGET) \
748 $(INSTALLED_BOOTIMAGE_TARGET) \
749 $(recovery_binary) \
750 $(recovery_initrc) $(recovery_kernel) \
751 $(INSTALLED_2NDBOOTLOADER_TARGET) \
752 $(recovery_build_prop) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700753 $(recovery_fstab) \
Doug Zongker4647f122009-07-02 09:00:54 -0700754 $(RECOVERY_INSTALL_OTA_KEYS)
755 @echo ----- Making recovery image ------
Doug Zongker72f0b672012-08-08 16:26:17 -0700756 $(hide) rm -rf $(TARGET_RECOVERY_OUT)
757 $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
758 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/tmp
759 @echo Copying baseline ramdisk...
760 $(hide) cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
761 @echo Modifying ramdisk contents...
762 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
763 $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
764 $(hide) -cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/
765 $(hide) cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
Doug Zongker25d55f82014-04-04 13:51:15 -0700766 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
767 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
768 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
Doug Zongkere1297322013-03-06 15:04:31 -0800769 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
Doug Zongker72f0b672012-08-08 16:26:17 -0700770 $(hide) $(foreach item,$(recovery_resources_private), \
Doug Zongker4647f122009-07-02 09:00:54 -0700771 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
Doug Zongker72f0b672012-08-08 16:26:17 -0700772 $(hide) $(foreach item,$(recovery_fstab), \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700773 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Doug Zongker72f0b672012-08-08 16:26:17 -0700774 $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
775 $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
Doug Zongker4647f122009-07-02 09:00:54 -0700776 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
Doug Zongker72f0b672012-08-08 16:26:17 -0700777 $(hide) $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
778 $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Doug Zongkered96e882009-08-26 09:37:07 -0700779 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
Doug Zongker72f0b672012-08-08 16:26:17 -0700780 @echo ----- Made recovery image: $@ --------
Doug Zongker4647f122009-07-02 09:00:54 -0700781
Doug Zongker56588872012-08-20 15:38:58 -0700782$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
Doug Zongker1a097262012-09-04 14:45:11 -0700783 $(hide) mkdir -p $(dir $@)
Doug Zongker56588872012-08-20 15:38:58 -0700784 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@
785
Doug Zongker4647f122009-07-02 09:00:54 -0700786else
787INSTALLED_RECOVERYIMAGE_TARGET :=
Doug Zongker56588872012-08-20 15:38:58 -0700788RECOVERY_RESOURCE_ZIP :=
Doug Zongker4647f122009-07-02 09:00:54 -0700789endif
790
791.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -0700792recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -0700793
Dima Zavin11818982010-02-05 13:34:34 -0800794ifneq ($(BOARD_NAND_PAGE_SIZE),)
795mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
796else
797mkyaffs2_extra_flags :=
Lars Svensson9cb8c282010-12-06 15:24:58 +0100798BOARD_NAND_PAGE_SIZE := 2048
Dima Zavin11818982010-02-05 13:34:34 -0800799endif
800
Naseer Ahmed53871882010-08-06 12:19:29 -0700801ifneq ($(BOARD_NAND_SPARE_SIZE),)
802mkyaffs2_extra_flags += -s $(BOARD_NAND_SPARE_SIZE)
Lars Svensson9cb8c282010-12-06 15:24:58 +0100803else
804BOARD_NAND_SPARE_SIZE := 64
Naseer Ahmed53871882010-08-06 12:19:29 -0700805endif
806
Doug Zongker4647f122009-07-02 09:00:54 -0700807# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -0700808# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800809#
Ying Wang9c649a72012-08-08 15:27:00 -0700810# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
811PDK_FUSION_SYSIMG_FILES := \
812 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
813 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800814
815INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -0700816 $(ALL_PREBUILT) \
817 $(ALL_COPIED_HEADERS) \
818 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -0700819 $(ALL_DEFAULT_INSTALLED_MODULES) \
820 $(PDK_FUSION_SYSIMG_FILES) \
821 $(RECOVERY_RESOURCE_ZIP))
Ying Wang160b6702012-03-13 18:58:27 -0700822
823ifdef is_tests_build
824# We don't want to install tests modules to the system partition
825# when building "tests", because now "tests" may be built in a user, userdebug
826# or eng build variant and we don't want to pollute the system partition.
827# INTERNAL_SYSTEMIMAGE_FILES += $(filter $(TARGET_OUT)/%, \
828# $(tests_MODULES))
829endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800830
Ying Wang82cceba2012-08-13 15:03:00 -0700831FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Ying Wange5e8c5f2011-09-09 16:35:53 -0700832# -----------------------------------------------------------------
833# installed file list
834# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
835# We put installed-files.txt ahead of image itself in the dependency graph
836# so that we can get the size stat even if the build fails due to too large
837# system image.
838INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
839$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS)
840 @echo Installed file list: $@
841 @mkdir -p $(dir $@)
842 @rm -f $@
843 $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@
844
845.PHONY: installed-file-list
846installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -0800847
848$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -0700849
850systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -0700851 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -0700852BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
853
The Android Open Source Project88b60792009-03-03 19:28:42 -0800854# $(1): output file
855define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -0700856 @echo "Target system fs image: $(1)"
857 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Geremy Condrafd6f7512013-06-16 17:26:08 -0700858 $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt, \
859 skip_fsck=true \
860 verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY) \
861 verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_PARTITION) \
862 verity_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY) \
863 verity_signer_cmd=$(VERITY_SIGNER_CMD))
Ying Wangbd93d422011-10-28 17:02:30 -0700864 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
865 ./build/tools/releasetools/build_image.py \
866 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800867endef
868
Ying Wange5e8c5f2011-09-09 16:35:53 -0700869$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800870 $(call build-systemimage-target,$@)
871
The Android Open Source Project88b60792009-03-03 19:28:42 -0800872INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700873SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800874
Doug Zongker73ef8252009-07-23 15:12:53 -0700875# The system partition needs room for the recovery image as well. We
876# now store the recovery image as a binary patch using the boot image
877# as the source (since they are very similar). Generate the patch so
878# we can see how big it's going to be, and include that in the system
879# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700880ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700881intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
882RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
883$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
884 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700885 $(HOST_OUT_EXECUTABLES)/imgdiff \
886 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700887 @echo "Construct recovery from boot"
888 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700889 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700890endif
891
Doug Zongker73ef8252009-07-23 15:12:53 -0700892
893$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800894 @echo "Install system fs image: $@"
895 $(copy-file-to-target)
Doug Zongkered96e882009-08-26 09:37:07 -0700896 $(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 -0800897
898systemimage: $(INSTALLED_SYSTEMIMAGE)
899
900.PHONY: systemimage-nodeps snod
901systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -0700902 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800903 @echo "make $@: ignoring dependencies"
904 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
Doug Zongkered96e882009-08-26 09:37:07 -0700905 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800906
Ying Wangacf01ec2012-02-24 11:05:48 -0800907ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
908ifeq (true,$(WITH_DEXPREOPT))
909$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
910endif
911endif
912
The Android Open Source Project88b60792009-03-03 19:28:42 -0800913#######
914## system tarball
915define build-systemtarball-target
916 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
917 $(MKTARBALL) $(FS_GET_STATS) \
918 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
919 $(INSTALLED_SYSTEMTARBALL_TARGET)
920endef
921
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700922ifndef SYSTEM_TARBALL_FORMAT
923 SYSTEM_TARBALL_FORMAT := bz2
924endif
925
The Android Open Source Project88b60792009-03-03 19:28:42 -0800926system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700927INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800928$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
929$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
930 $(build-systemtarball-target)
931
932.PHONY: systemtarball-nodeps
933systemtarball-nodeps: $(FS_GET_STATS) \
934 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
935 $(build-systemtarball-target)
936
937.PHONY: stnod
938stnod: systemtarball-nodeps
939
Ying Wang4c289e52012-03-30 13:52:54 -0700940#######
Ying Wang4534d812012-04-09 17:04:12 -0700941## platform.zip: system, plus other files to be used in PDK fusion build,
942## in a zip file
keunyoungc0178062013-07-22 14:54:58 -0700943##
944## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
945## The variable will be typically set from BoardConfig.mk.
946## Files under out dir will be rejected to prevent possible conflicts with other rules.
947PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -0700948INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
949$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES)
950 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Ying Wang4c289e52012-03-30 13:52:54 -0700951 $(hide) rm -f $@
Ying Wang4534d812012-04-09 17:04:12 -0700952 $(hide) cd $(dir $@) && zip -qry $(notdir $@) \
953 $(TARGET_COPY_OUT_SYSTEM) \
Keun young Park72226692012-07-31 17:13:20 -0700954 $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \
955 $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST))
Colin Crossc451a372013-12-18 19:36:44 -0800956ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Ying Wang28a18172012-06-02 09:22:31 -0700957 $(hide) cd $(OUT_DIR) && zip -qry $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
Keun young Park816b9fd2012-05-16 10:32:41 -0700958endif
keunyoungc0178062013-07-22 14:54:58 -0700959ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
960 $(hide) zip -qry $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
961endif
Ying Wang4c289e52012-03-30 13:52:54 -0700962
963.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -0700964platform: $(INSTALLED_PLATFORM_ZIP)
965
966.PHONY: platform-java
967platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -0700968
969# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -0700970ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
971$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -0700972endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800973
Bruce Beare52aac202010-06-04 15:24:49 -0700974#######
975## boot tarball
976define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -0700977 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -0700978 $(hide) mkdir -p $(PRODUCT_OUT)/boot
979 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
980 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
981 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
982 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
983 $(INSTALLED_BOOTTARBALL_TARGET)
984endef
985
986ifndef BOOT_TARBALL_FORMAT
987 BOOT_TARBALL_FORMAT := bz2
988endif
989
990boot_tar := $(PRODUCT_OUT)/boot.tar
991INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
992$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
993$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
994 $(build-boottarball-target)
995
996.PHONY: boottarball-nodeps btnod
997boottarball-nodeps btnod: $(FS_GET_STATS) \
998 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
999 $(build-boottarball-target)
1000
1001
The Android Open Source Project88b60792009-03-03 19:28:42 -08001002# -----------------------------------------------------------------
1003# data partition image
1004INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001005 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001006
Ying Wang160b6702012-03-13 18:58:27 -07001007# If we build "tests" at the same time, make sure $(tests_MODULES) get covered.
1008ifdef is_tests_build
1009INTERNAL_USERDATAIMAGE_FILES += \
1010 $(filter $(TARGET_OUT_DATA)/%,$(tests_MODULES))
1011endif
1012
Ying Wangd7321d32013-03-15 10:32:29 -07001013# Don't build userdata.img if it's extfs but no partition size
1014skip_userdata.img :=
1015ifdef INTERNAL_USERIMAGES_EXT_VARIANT
1016ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE
1017skip_userdata.img := true
1018endif
1019endif
1020
1021ifneq ($(skip_userdata.img),true)
Ying Wangbd93d422011-10-28 17:02:30 -07001022userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001023 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07001024BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
1025
Ying Wangbd93d422011-10-28 17:02:30 -07001026define build-userdataimage-target
1027 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
1028 @mkdir -p $(TARGET_OUT_DATA)
1029 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001030 $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt, skip_fsck=true)
Ying Wangbd93d422011-10-28 17:02:30 -07001031 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1032 ./build/tools/releasetools/build_image.py \
Ying Wang178ef922011-10-31 18:13:30 -07001033 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET)
Ying Wangbd93d422011-10-28 17:02:30 -07001034 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
1035endef
1036
Joe Onorato64d85d02009-04-09 19:31:12 -07001037# We just build this directly to the install location.
1038INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -07001039$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001040 $(INTERNAL_USERDATAIMAGE_FILES)
1041 $(build-userdataimage-target)
1042
1043.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07001044userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001045 $(build-userdataimage-target)
1046
Ying Wangd7321d32013-03-15 10:32:29 -07001047endif # not skip_userdata.img
1048skip_userdata.img :=
Ying Wange215ed52012-10-15 14:36:22 -07001049
The Android Open Source Project88b60792009-03-03 19:28:42 -08001050#######
1051## data partition tarball
1052define build-userdatatarball-target
1053 $(call pretty,"Target userdata fs tarball: " \
1054 "$(INSTALLED_USERDATATARBALL_TARGET)")
1055 $(MKTARBALL) $(FS_GET_STATS) \
1056 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
1057 $(INSTALLED_USERDATATARBALL_TARGET)
1058endef
1059
1060userdata_tar := $(PRODUCT_OUT)/userdata.tar
1061INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
1062$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
1063$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
1064 $(build-userdatatarball-target)
1065
1066.PHONY: userdatatarball-nodeps
1067userdatatarball-nodeps: $(FS_GET_STATS)
1068 $(build-userdatatarball-target)
1069
1070
The Android Open Source Project88b60792009-03-03 19:28:42 -08001071# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07001072# cache partition image
1073ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1074INTERNAL_CACHEIMAGE_FILES := \
1075 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
1076
1077cacheimage_intermediates := \
1078 $(call intermediates-dir-for,PACKAGING,cache)
1079BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
1080
1081define build-cacheimage-target
1082 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
1083 @mkdir -p $(TARGET_OUT_CACHE)
1084 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Ying Wang6a42a252013-02-27 13:54:02 -08001085 $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt, skip_fsck=true)
Ying Wang9f8e8db2011-11-04 11:37:01 -07001086 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1087 ./build/tools/releasetools/build_image.py \
1088 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET)
1089 $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE),yaffs)
1090endef
1091
1092# We just build this directly to the install location.
1093INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
1094$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
1095 $(build-cacheimage-target)
1096
1097.PHONY: cacheimage-nodeps
1098cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1099 $(build-cacheimage-target)
1100
1101endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
1102
Ying Wanga0febe52013-03-20 11:02:05 -07001103
1104# -----------------------------------------------------------------
1105# vendor partition image
1106ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1107INTERNAL_VENDORIMAGE_FILES := \
1108 $(filter $(TARGET_OUT_VENDOR)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
1109
1110vendorimage_intermediates := \
1111 $(call intermediates-dir-for,PACKAGING,vendor)
1112BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
1113
1114define build-vendorimage-target
1115 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
1116 @mkdir -p $(TARGET_OUT_VENDOR)
1117 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
1118 $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true)
1119 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
1120 ./build/tools/releasetools/build_image.py \
1121 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET)
1122 $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE),yaffs)
1123endef
1124
1125# We just build this directly to the install location.
1126INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
1127$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES)
1128 $(build-vendorimage-target)
1129
1130.PHONY: vendorimage-nodeps
1131vendorimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
1132 $(build-vendorimage-target)
1133
1134endif # BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1135
Ying Wang9f8e8db2011-11-04 11:37:01 -07001136# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001137# bring in the installer image generation defines if necessary
1138ifeq ($(TARGET_USE_DISKINSTALLER),true)
1139include bootable/diskinstaller/config.mk
1140endif
1141
1142# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07001143# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08001144
Colin Crossc312f312012-04-19 13:54:39 -07001145DISTTOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -07001146 $(HOST_OUT_EXECUTABLES)/mkbootfs \
1147 $(HOST_OUT_EXECUTABLES)/mkbootimg \
1148 $(HOST_OUT_EXECUTABLES)/fs_config \
1149 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
1150 $(HOST_OUT_EXECUTABLES)/zipalign \
Doug Zongker8678df42009-06-15 14:30:14 -07001151 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -07001152 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -07001153 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -07001154 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
1155 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
Ying Wang7dc45a82013-01-04 14:43:18 -08001156 $(HOST_OUT_EXECUTABLES)/make_ext4fs \
1157 $(HOST_OUT_EXECUTABLES)/simg2img \
Doug Zongker5fad2032014-02-24 08:13:45 -08001158 $(HOST_OUT_EXECUTABLES)/e2fsck \
Doug Zongker32b527d2014-03-04 10:03:02 -08001159 $(HOST_OUT_EXECUTABLES)/xdelta3 \
1160 $(HOST_OUT_EXECUTABLES)/syspatch_host
The Android Open Source Project88b60792009-03-03 19:28:42 -08001161
Colin Crossc312f312012-04-19 13:54:39 -07001162OTATOOLS := $(DISTTOOLS) \
1163 $(HOST_OUT_EXECUTABLES)/aapt
1164
Ying Wang06898662010-06-17 17:52:18 -07001165.PHONY: otatools
1166otatools: $(OTATOOLS)
1167
The Android Open Source Project88b60792009-03-03 19:28:42 -08001168# -----------------------------------------------------------------
1169# A zip of the directories that map to the target filesystem.
1170# This zip can be used to create an OTA package or filesystem image
1171# as a post-build step.
1172#
1173name := $(TARGET_PRODUCT)
1174ifeq ($(TARGET_BUILD_TYPE),debug)
1175 name := $(name)_debug
1176endif
1177name := $(name)-target_files-$(FILE_NAME_TAG)
1178
1179intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
1180BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
1181$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
1182$(BUILT_TARGET_FILES_PACKAGE): \
1183 zip_root := $(intermediates)/$(name)
1184
1185# $(1): Directory to copy
1186# $(2): Location to copy it to
1187# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
1188define package_files-copy-root
1189 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
1190 mkdir -p $(2) && \
1191 $(ACP) -rd $(strip $(1))/* $(2); \
1192 fi
1193endef
1194
1195built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -07001196 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -07001197 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001198 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
Doug Zongker25863d72011-09-19 15:02:03 -07001199 $(call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001200 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -08001201$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
1202
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001203$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
Ken Sumrall31ce31f2013-02-21 16:27:25 -08001204$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION)
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001205
Doug Zongkerc18736b2009-09-30 09:20:32 -07001206ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1207# default to common dir for device vendor
1208$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
1209else
1210$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1211endif
1212
The Android Open Source Project88b60792009-03-03 19:28:42 -08001213# Depending on the various images guarantees that the underlying
1214# directories are up-to-date.
1215$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001216 $(INSTALLED_BOOTIMAGE_TARGET) \
1217 $(INSTALLED_RADIOIMAGE_TARGET) \
1218 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -07001219 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001220 $(INSTALLED_USERDATAIMAGE_TARGET) \
Ying Wang9f8e8db2011-11-04 11:37:01 -07001221 $(INSTALLED_CACHEIMAGE_TARGET) \
Ying Wanga0febe52013-03-20 11:02:05 -07001222 $(INSTALLED_VENDORIMAGE_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001223 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001224 $(SELINUX_FC) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001225 $(built_ota_tools) \
1226 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -07001227 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001228 | $(ACP)
1229 @echo "Package target files: $@"
1230 $(hide) rm -rf $@ $(zip_root)
1231 $(hide) mkdir -p $(dir $@) $(zip_root)
1232 @# Components of the recovery image
1233 $(hide) mkdir -p $(zip_root)/RECOVERY
1234 $(hide) $(call package_files-copy-root, \
1235 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
1236ifdef INSTALLED_KERNEL_TARGET
1237 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
1238endif
1239ifdef INSTALLED_2NDBOOTLOADER_TARGET
1240 $(hide) $(ACP) \
1241 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
1242endif
1243ifdef BOARD_KERNEL_CMDLINE
1244 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
1245endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001246ifdef BOARD_KERNEL_BASE
1247 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
1248endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001249ifdef BOARD_KERNEL_PAGESIZE
1250 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
1251endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001252 @# Components of the boot image
1253 $(hide) mkdir -p $(zip_root)/BOOT
1254 $(hide) $(call package_files-copy-root, \
1255 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1256ifdef INSTALLED_KERNEL_TARGET
1257 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1258endif
1259ifdef INSTALLED_2NDBOOTLOADER_TARGET
1260 $(hide) $(ACP) \
1261 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1262endif
1263ifdef BOARD_KERNEL_CMDLINE
1264 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1265endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001266ifdef BOARD_KERNEL_BASE
1267 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1268endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001269ifdef BOARD_KERNEL_PAGESIZE
1270 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1271endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001272 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1273 mkdir -p $(zip_root)/RADIO; \
1274 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001275 @# Contents of the system image
1276 $(hide) $(call package_files-copy-root, \
1277 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1278 @# Contents of the data image
1279 $(hide) $(call package_files-copy-root, \
1280 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Ying Wanga0febe52013-03-20 11:02:05 -07001281ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
1282 @# Contents of the vendor image
1283 $(hide) $(call package_files-copy-root, \
1284 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
1285endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001286 @# Extra contents of the OTA package
1287 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001288 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1289 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001290 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001291 @# build them.
1292 $(hide) mkdir -p $(zip_root)/META
1293 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker816d73f2013-11-22 13:29:55 -08001294 $(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 -07001295 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -07001296 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Ken Sumrall31ce31f2013-02-21 16:27:25 -08001297 $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001298ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07001299 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001300endif
1301ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001302 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001303endif
1304ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001305 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001306endif
Doug Zongker37974732010-09-16 17:44:38 -07001307 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wang3c21fe52011-10-04 10:50:08 -07001308 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
Doug Zongker5d4808d2011-03-16 07:49:13 -07001309ifdef PRODUCT_EXTRA_RECOVERY_KEYS
1310 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
Doug Zongkere121d6a2011-02-01 14:13:52 -08001311endif
Jianxun Zhang09849492013-04-17 15:19:19 -07001312 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
Nick Kralevich0eb17d92013-09-07 17:10:29 -07001313 $(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt
Doug Zongker9b23f2c2013-11-25 14:44:12 -08001314 $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
Michael Rungefacd9922013-12-20 11:50:16 -08001315 $(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt
Ying Wangbd93d422011-10-28 17:02:30 -07001316 $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
Doug Zongkerc9253822014-02-04 12:17:58 -08001317 $(hide) ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001318 @# Zip everything up, preserving symlinks
1319 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongker23f8bde2011-09-07 14:11:51 -07001320 @# 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 -07001321 $(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
1322 $(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
1323 $(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 -07001324 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
Doug Zongker283e2a12010-03-15 17:52:32 -07001325
Ying Wanga0febe52013-03-20 11:02:05 -07001326.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001327target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1328
Doug Zongker367910f2009-06-15 18:56:51 -07001329
Doug Zongker367910f2009-06-15 18:56:51 -07001330ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang279f3082011-02-09 12:26:42 -08001331ifeq ($(filter generic%,$(TARGET_DEVICE)),)
Ying Wangfb0a3472010-08-25 16:06:06 -07001332ifneq ($(TARGET_NO_KERNEL),true)
Ying Wanga73b6562011-03-03 21:52:08 -08001333ifneq ($(recovery_fstab),)
Doug Zongker367910f2009-06-15 18:56:51 -07001334
Ying Wang09a00a62010-10-20 14:01:09 -07001335# -----------------------------------------------------------------
1336# OTA update package
1337
Doug Zongker8678df42009-06-15 14:30:14 -07001338name := $(TARGET_PRODUCT)
1339ifeq ($(TARGET_BUILD_TYPE),debug)
1340 name := $(name)_debug
1341endif
1342name := $(name)-ota-$(FILE_NAME_TAG)
1343
1344INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1345
1346$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1347
Ying Wang82cceba2012-08-13 15:03:00 -07001348$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001349 @echo "Package OTA: $@"
Bjorn Andersson612e2cd2012-11-25 16:53:44 -08001350 $(hide) MKBOOTIMG=$(BOARD_CUSTOM_MKBOOTIMG) \
1351 ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker26e66192014-02-20 13:22:07 -08001352 --block \
Doug Zongker602a84e2009-06-18 08:35:12 -07001353 -p $(HOST_OUT) \
Stephen Smalley56882bf2012-02-09 13:36:21 -05001354 -k $(KEY_CERT_PAIR) \
1355 $(BUILT_TARGET_FILES_PACKAGE) $@
Doug Zongker8678df42009-06-15 14:30:14 -07001356
1357.PHONY: otapackage
1358otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1359
Ying Wang09a00a62010-10-20 14:01:09 -07001360# -----------------------------------------------------------------
1361# The update package
1362
1363name := $(TARGET_PRODUCT)
1364ifeq ($(TARGET_BUILD_TYPE),debug)
1365 name := $(name)_debug
1366endif
1367name := $(name)-img-$(FILE_NAME_TAG)
1368
1369INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1370
Ying Wang82cceba2012-08-13 15:03:00 -07001371$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
Ying Wang09a00a62010-10-20 14:01:09 -07001372 @echo "Package: $@"
Bjorn Andersson612e2cd2012-11-25 16:53:44 -08001373 $(hide) MKBOOTIMG=$(BOARD_CUSTOM_MKBOOTIMG) \
1374 ./build/tools/releasetools/img_from_target_files -v \
Ying Wang09a00a62010-10-20 14:01:09 -07001375 -p $(HOST_OUT) \
1376 $(BUILT_TARGET_FILES_PACKAGE) $@
1377
1378.PHONY: updatepackage
1379updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
1380
Ying Wanga73b6562011-03-03 21:52:08 -08001381endif # recovery_fstab is defined
Ying Wangfb0a3472010-08-25 16:06:06 -07001382endif # TARGET_NO_KERNEL != true
Ying Wang279f3082011-02-09 12:26:42 -08001383endif # TARGET_DEVICE != generic*
Doug Zongker367910f2009-06-15 18:56:51 -07001384endif # TARGET_PRODUCT != sdk
Doug Zongker8678df42009-06-15 14:30:14 -07001385
Ying Wangd0244b32011-11-17 14:51:12 -08001386ifdef is_tests_build
Doug Zongker8678df42009-06-15 14:30:14 -07001387# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001388# A zip of the tests that are built when running "make tests".
1389# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
Ying Wangc5f04972012-03-13 11:22:04 -07001390# only grab DATA, and it's called "*-tests-*.zip".
The Android Open Source Project88b60792009-03-03 19:28:42 -08001391#
1392name := $(TARGET_PRODUCT)
1393ifeq ($(TARGET_BUILD_TYPE),debug)
1394 name := $(name)_debug
1395endif
1396name := $(name)-tests-$(FILE_NAME_TAG)
1397
1398intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
1399BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
1400$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
1401$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
1402
Ying Wang64661472012-06-11 16:43:40 -07001403# Depending on the image dependency files, instead of the image files itself,
1404# guarantees that the underlying directories are up-to-date,
1405# but don't really build the image.
The Android Open Source Project88b60792009-03-03 19:28:42 -08001406$(BUILT_TESTS_ZIP_PACKAGE): \
Ying Wang64661472012-06-11 16:43:40 -07001407 $(INTERNAL_USERDATAIMAGE_FILES) \
Ying Wang160b6702012-03-13 18:58:27 -07001408 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001409 @echo "Package test files: $@"
1410 $(hide) rm -rf $@ $(zip_root)
1411 $(hide) mkdir -p $(dir $@) $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001412 @# Contents of the data image
1413 $(hide) $(call package_files-copy-root, \
1414 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1415 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
1416
Ying Wang160b6702012-03-13 18:58:27 -07001417.PHONY: tests
1418tests: $(BUILT_TESTS_ZIP_PACKAGE)
Ying Wangd0244b32011-11-17 14:51:12 -08001419
Ying Wang160b6702012-03-13 18:58:27 -07001420ifneq (,$(filter tests, $(MAKECMDGOALS)))
Ying Wangd0244b32011-11-17 14:51:12 -08001421 $(call dist-for-goals, tests, $(BUILT_TESTS_ZIP_PACKAGE))
Ying Wang160b6702012-03-13 18:58:27 -07001422endif
Ying Wangd0244b32011-11-17 14:51:12 -08001423endif # is_tests_build
Ying Wang160b6702012-03-13 18:58:27 -07001424
The Android Open Source Project88b60792009-03-03 19:28:42 -08001425# -----------------------------------------------------------------
1426# A zip of the symbols directory. Keep the full paths to make it
1427# more obvious where these files came from.
1428#
1429name := $(TARGET_PRODUCT)
1430ifeq ($(TARGET_BUILD_TYPE),debug)
1431 name := $(name)_debug
1432endif
1433name := $(name)-symbols-$(FILE_NAME_TAG)
1434
1435SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1436$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1437 @echo "Package symbols: $@"
1438 $(hide) rm -rf $@
1439 $(hide) mkdir -p $(dir $@)
1440 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1441
1442# -----------------------------------------------------------------
1443# A zip of the Android Apps. Not keeping full path so that we don't
1444# include product names when distributing
1445#
1446name := $(TARGET_PRODUCT)
1447ifeq ($(TARGET_BUILD_TYPE),debug)
1448 name := $(name)_debug
1449endif
1450name := $(name)-apps-$(FILE_NAME_TAG)
1451
1452APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1453$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1454 @echo "Package apps: $@"
1455 $(hide) rm -rf $@
1456 $(hide) mkdir -p $(dir $@)
Robert Craig59ec1952014-02-26 11:48:20 -05001457 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/* $(TARGET_OUT_APPS_PRIVILEGED)/*
The Android Open Source Project88b60792009-03-03 19:28:42 -08001458
Guang Zhu0198d6e2010-04-23 11:54:37 -07001459
1460#------------------------------------------------------------------
1461# A zip of emma code coverage meta files. Generated for fully emma
1462# instrumented build.
1463#
Ying Wangbc415dd2012-08-15 12:22:44 -07001464ifeq (true,$(EMMA_INSTRUMENT))
Guang Zhu0198d6e2010-04-23 11:54:37 -07001465EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
Ying Wangbc415dd2012-08-15 12:22:44 -07001466# the dependency will be set up later in build/core/main.mk.
1467$(EMMA_META_ZIP) :
Guang Zhu0198d6e2010-04-23 11:54:37 -07001468 @echo "Collecting Emma coverage meta files."
Ying Wang1ff08362013-12-27 15:55:08 -08001469 $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "coverage.em" | \
Guang Zhu0198d6e2010-04-23 11:54:37 -07001470 zip -@ -q $@
1471
Ying Wangbc415dd2012-08-15 12:22:44 -07001472endif # EMMA_INSTRUMENT=true
1473
Ying Wangae9115a2013-08-22 20:52:47 -07001474#------------------------------------------------------------------
1475# A zip of Proguard obfuscation dictionary files.
1476# Only for apps_only build.
1477#
1478ifdef TARGET_BUILD_APPS
Ying Wangc62c92c2013-08-28 18:38:25 -07001479PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Ying Wangae9115a2013-08-22 20:52:47 -07001480# the dependency will be set up later in build/core/main.mk.
1481$(PROGUARD_DICT_ZIP) :
1482 @echo "Packaging Proguard obfuscation dictionary files."
1483 $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary`; \
1484 if [ -n "$$dict_files" ]; then \
Ying Wang33d64592013-11-25 17:39:50 -08001485 unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \
1486 zip -q $@ $$dict_files $$unobfuscated_jars; \
Ying Wangae9115a2013-08-22 20:52:47 -07001487 else \
Ying Wangc62c92c2013-08-28 18:38:25 -07001488 touch $(dir $@)/dummy; \
1489 (cd $(dir $@) && zip -q $(notdir $@) dummy); \
1490 zip -qd $@ dummy; \
1491 rm $(dir $@)/dummy; \
Ying Wangae9115a2013-08-22 20:52:47 -07001492 fi
1493
1494endif # TARGET_BUILD_APPS
1495
The Android Open Source Project88b60792009-03-03 19:28:42 -08001496# -----------------------------------------------------------------
1497# dalvik something
1498.PHONY: dalvikfiles
1499dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1500
1501# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001502# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07001503ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001504INTERNAL_EMULATOR_PACKAGE_FILES += \
1505 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08001506 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001507 $(INSTALLED_RAMDISK_TARGET) \
1508 $(INSTALLED_SYSTEMIMAGE) \
1509 $(INSTALLED_USERDATAIMAGE_TARGET)
1510
1511name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1512
1513INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1514
1515$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1516 @echo "Package: $@"
1517 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1518
Ying Wang7d8c5352012-07-26 10:15:21 -07001519endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001520# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08001521# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08001522# The pdk package (Platform Development Kit)
1523
Keun young Park7fc7aad2012-02-27 15:49:23 -08001524#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1525# include development/pdk/Pdk.mk
1526#endif
1527
The Android Open Source Project88b60792009-03-03 19:28:42 -08001528
1529# -----------------------------------------------------------------
1530# The SDK
1531
The Android Open Source Project88b60792009-03-03 19:28:42 -08001532# The SDK includes host-specific components, so it belongs under HOST_OUT.
1533sdk_dir := $(HOST_OUT)/sdk
1534
1535# Build a name that looks like:
1536#
1537# linux-x86 --> android-sdk_12345_linux-x86
1538# darwin-x86 --> android-sdk_12345_mac-x86
1539# windows-x86 --> android-sdk_12345_windows
1540#
1541sdk_name := android-sdk_$(FILE_NAME_TAG)
1542ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001543 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001544else
Joe Onorato03fbe402009-04-13 08:31:16 -07001545 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001546endif
1547ifneq ($(HOST_OS),windows)
Joe Onorato03fbe402009-04-13 08:31:16 -07001548 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001549endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001550sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001551
1552sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1553
1554ATREE_FILES :=
1555-include $(sdk_dep_file)
1556
1557# if we don't have a real list, then use "everything"
1558ifeq ($(strip $(ATREE_FILES)),)
1559ATREE_FILES := \
1560 $(ALL_PREBUILT) \
1561 $(ALL_COPIED_HEADERS) \
1562 $(ALL_GENERATED_SOURCES) \
1563 $(ALL_DEFAULT_INSTALLED_MODULES) \
1564 $(INSTALLED_RAMDISK_TARGET) \
1565 $(ALL_DOCS) \
1566 $(ALL_SDK_FILES)
1567endif
1568
1569atree_dir := development/build
1570
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001571# sdk/build/tools.atree contains the generic rules, while
1572#
1573# sdk/build/tools.$(TARGET_ARCH).atree contains target-specific rules
1574# the latter is optional.
1575#
1576sdk_tools_atree_files := sdk/build/tools.atree
1577ifneq (,$(strip $(wildcard sdk/build/tools.$(TARGET_ARCH).atree)))
1578 sdk_tools_atree_files += sdk/build/tools.$(TARGET_ARCH).atree
1579endif
Raphael Moll3ab307a2012-03-02 12:40:04 -08001580ifneq (,$(strip $(wildcard sdk/build/tools.$(HOST_OS).atree)))
1581 sdk_tools_atree_files += sdk/build/tools.$(HOST_OS).atree
1582endif
1583ifneq (,$(strip $(wildcard sdk/build/tools.$(HOST_OS)-$(HOST_ARCH).atree)))
1584 sdk_tools_atree_files += sdk/build/tools.$(HOST_OS)-$(HOST_ARCH).atree
1585endif
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001586
The Android Open Source Project88b60792009-03-03 19:28:42 -08001587sdk_atree_files := \
1588 $(atree_dir)/sdk.exclude.atree \
Xavier Ducrohetffd50872010-09-27 15:51:32 -07001589 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree \
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001590 $(sdk_tools_atree_files)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001591
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02001592# development/build/sdk-android-<abi>.atree is used to differentiate
1593# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
1594# files like the kernel image. We use TARGET_CPU_ABI because we don't
1595# have a better way to distinguish between CPU models.
1596ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
1597 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
1598endif
1599
Griff Hazen433febb2014-02-28 08:45:59 -08001600ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),)
1601sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES)
1602else
1603sdk_atree_files += $(atree_dir)/sdk.atree
1604endif
1605
The Android Open Source Project88b60792009-03-03 19:28:42 -08001606deps := \
1607 $(target_notice_file_txt) \
1608 $(tools_notice_file_txt) \
1609 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001610 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001611 $(INSTALLED_SYSTEMIMAGE) \
1612 $(INSTALLED_USERDATAIMAGE_TARGET) \
1613 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001614 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001615 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001616 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08001617 $(sdk_atree_files) \
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001618 $(sdk_tools_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001619 $(HOST_OUT_EXECUTABLES)/atree \
Joe Onorato63d56da2012-08-17 04:19:38 -07001620 $(HOST_OUT_EXECUTABLES)/line_endings
The Android Open Source Project88b60792009-03-03 19:28:42 -08001621
1622INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1623$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1624$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1625$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1626$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1627
1628# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1629#
1630#SDK_GNU_ERROR := true
1631
1632$(INTERNAL_SDK_TARGET): $(deps)
1633 @echo "Package SDK: $@"
1634 $(hide) rm -rf $(PRIVATE_DIR) $@
1635 $(hide) for f in $(target_gnu_MODULES); do \
1636 if [ -f $$f ]; then \
1637 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1638 including GNU target $$f >&2; \
1639 FAIL=$(SDK_GNU_ERROR); \
1640 fi; \
1641 done; \
1642 if [ $$FAIL ]; then exit 1; fi
1643 $(hide) ( \
Raphael Mollec5fe912012-06-06 19:33:31 -07001644 ATREE_STRIP="strip -x" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001645 $(HOST_OUT_EXECUTABLES)/atree \
1646 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1647 -m $(PRIVATE_DEP_FILE) \
1648 -I . \
1649 -I $(PRODUCT_OUT) \
1650 -I $(HOST_OUT) \
1651 -I $(TARGET_COMMON_OUT_ROOT) \
1652 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
Raphael Moll7558ad52011-01-05 14:58:17 -08001653 -v "OUT_DIR=$(OUT_DIR)" \
Raphael2a533172011-11-15 16:29:16 -08001654 -v "HOST_OUT=$(HOST_OUT)" \
Bruce Beare18a130e2011-02-18 15:06:20 -08001655 -v "TARGET_ARCH=$(TARGET_ARCH)" \
1656 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
David 'Digit' Turner557c51f2011-08-25 14:28:03 +02001657 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001658 -o $(PRIVATE_DIR) && \
1659 cp -f $(target_notice_file_txt) \
Xavier Ducrohet6de7bc62011-09-21 10:22:19 -07001660 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001661 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
Xavier Ducrohet4216a8c2011-03-15 13:28:40 -07001662 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001663 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Raphael7a6a9c32011-02-01 13:30:00 -08001664 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001665 chmod -R ug+rwX $(PRIVATE_DIR) && \
1666 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1667 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1668
Raphael3d224a02010-04-16 17:50:09 -07001669
1670# Is a Windows SDK requested? If so, we need some definitions from here
1671# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08001672MAIN_SDK_NAME := $(sdk_name)
1673MAIN_SDK_DIR := $(sdk_dir)
1674MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Raphael3d224a02010-04-16 17:50:09 -07001675ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07001676include $(TOPDIR)development/build/tools/windows_sdk.mk
1677endif
1678
The Android Open Source Project88b60792009-03-03 19:28:42 -08001679# -----------------------------------------------------------------
1680# Findbugs
1681INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1682INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1683$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1684 @echo UnionBugs: $@
1685 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1686 > $@
1687$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1688 @echo ConvertXmlToText: $@
1689 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07001690 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001691
1692# -----------------------------------------------------------------
1693# Findbugs
1694
1695# -----------------------------------------------------------------
1696# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07001697ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001698include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01001699-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07001700-include $(sort $(wildcard device/*/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07001701endif
Raphaelc4d47312011-02-15 16:09:36 -08001702
1703# -----------------------------------------------------------------
1704# Create SDK repository packages. Must be done after tasks/* since
1705# we need the addon rules defined.
1706ifneq ($(sdk_repo_goal),)
1707include $(TOPDIR)development/build/tools/sdk_repo.mk
1708endif