blob: a3cfdd5d89a68ceea6b4fe1282a3a535beefc9a3 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Put some miscellaneous rules here
2
3# Pick a reasonable string to use to identify files.
4ifneq "" "$(filter eng.%,$(BUILD_NUMBER))"
5 # BUILD_NUMBER has a timestamp in it, which means that
6 # it will change every time. Pick a stable value.
7 FILE_NAME_TAG := eng.$(USER)
8else
9 FILE_NAME_TAG := $(BUILD_NUMBER)
10endif
11
12# -----------------------------------------------------------------
13# Define rules to copy PRODUCT_COPY_FILES defined by the product.
14# PRODUCT_COPY_FILES contains words like <source file>:<dest file>.
15# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
16# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080017# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070018# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070019#$(1): the src:dest pair
20define check-product-copy-files
21$(if $(filter %.apk, $(1)),$(error \
22 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))
23endef
Ying Wang7e8d4422011-06-17 17:05:35 -070024unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080025$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang462d26b2010-11-02 21:31:47 -070026 $(eval _src := $(call word-colon,1,$(cf))) \
27 $(eval _dest := $(call word-colon,2,$(cf))) \
Ying Wang68864102011-09-29 13:23:25 -070028 $(call check-product-copy-files,$(cf)) \
Ying Wang7e8d4422011-06-17 17:05:35 -070029 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)),, \
Ying Wang462d26b2010-11-02 21:31:47 -070030 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
31 $(eval $(call copy-one-file,$(_src),$(_fulldest))) \
32 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
Ying Wang7e8d4422011-06-17 17:05:35 -070033 $(eval unique_product_copy_files_destinations += $(_dest))))
34unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080035
36# -----------------------------------------------------------------
37# docs/index.html
38gen := $(OUT_DOCS)/index.html
39ALL_DOCS += $(gen)
40$(gen): frameworks/base/docs/docs-redirect-index.html
41 @mkdir -p $(dir $@)
42 @cp -f $< $@
43
44# -----------------------------------------------------------------
45# default.prop
46INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
47ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
48ADDITIONAL_DEFAULT_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -070049 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
Mike Lockwood0d23fec2011-06-09 14:54:40 -070050ADDITIONAL_DEFAULT_PROPERTIES += \
Ying Wang7e8d4422011-06-17 17:05:35 -070051 $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
52ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
53 $(ADDITIONAL_DEFAULT_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -080054
55$(INSTALLED_DEFAULT_PROP_TARGET):
56 @echo Target buildinfo: $@
57 @mkdir -p $(dir $@)
58 $(hide) echo "#" > $@; \
59 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
60 echo "#" >> $@;
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -070061 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
62 echo "$(line)" >> $@;)
Joe Onorato9197a482011-06-08 16:04:14 -070063 build/tools/post_process_props.py $@
The Android Open Source Project88b60792009-03-03 19:28:42 -080064
65# -----------------------------------------------------------------
66# build.prop
67INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
68ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
69ADDITIONAL_BUILD_PROPERTIES := \
Ying Wang7e8d4422011-06-17 17:05:35 -070070 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
71ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
72 $(ADDITIONAL_BUILD_PROPERTIES),=)
The Android Open Source Project88b60792009-03-03 19:28:42 -080073
74# A list of arbitrary tags describing the build configuration.
75# Force ":=" so we can use +=
76BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
77ifeq ($(TARGET_BUILD_TYPE),debug)
78 BUILD_VERSION_TAGS += debug
79endif
80# Apps are always signed with test keys, and may be re-signed in a post-build
81# step. If that happens, the "test-keys" tag will be removed by that step.
82BUILD_VERSION_TAGS += test-keys
The Android Open Source Project88b60792009-03-03 19:28:42 -080083BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
84
85# A human-readable string that descibes this build in detail.
86build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)
87$(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc)
88
89# The string used to uniquely identify this build; used by the OTA server.
90ifeq (,$(strip $(BUILD_FINGERPRINT)))
Doug Zongker135a1202010-09-15 13:02:12 -070091 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 -080092endif
93ifneq ($(words $(BUILD_FINGERPRINT)),1)
94 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
95endif
96
Sriram Raman7b641242009-03-24 22:40:59 -070097# Display parameters shown under Settings -> About Phone
98ifeq ($(TARGET_BUILD_VARIANT),user)
99 # User builds should show:
100 # release build number or branch.buld_number non-release builds
101
102 # Dev. branches should have DISPLAY_BUILD_NUMBER set
103 ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
104 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER)
105 else
106 BUILD_DISPLAY_ID := $(BUILD_ID)
107 endif
108else
109 # Non-user builds should show detailed build information
110 BUILD_DISPLAY_ID := $(build_desc)
111endif
112
Ying Wang77c882f2010-04-27 15:45:35 -0700113# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
Ying Wang38d7f022010-07-21 14:58:42 -0700114product_property_override_locale_language := $(strip \
115 $(patsubst ro.product.locale.language=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700116 $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
Ying Wang38d7f022010-07-21 14:58:42 -0700117product_property_overrides_locale_region := $(strip \
118 $(patsubst ro.product.locale.region=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700119 $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
120
The Android Open Source Project88b60792009-03-03 19:28:42 -0800121# Selects the first locale in the list given as the argument,
122# and splits it into language and region, which each may be
123# empty.
124define default-locale
125$(subst _, , $(firstword $(1)))
126endef
127
128# Selects the first locale in the list given as the argument
Ying Wang77c882f2010-04-27 15:45:35 -0700129# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
130# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800131define default-locale-language
Ying Wang38d7f022010-07-21 14:58:42 -0700132$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800133endef
134define default-locale-region
Ying Wang38d7f022010-07-21 14:58:42 -0700135$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800136endef
137
138BUILDINFO_SH := build/tools/buildinfo.sh
Chih-Wei Huang75947ef2010-11-03 18:33:46 +0800139$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800140 @echo Target buildinfo: $@
141 @mkdir -p $(dir $@)
142 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
143 TARGET_DEVICE="$(TARGET_DEVICE)" \
144 PRODUCT_NAME="$(TARGET_PRODUCT)" \
145 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
146 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
147 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700148 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800149 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
150 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
151 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
152 BUILD_ID="$(BUILD_ID)" \
153 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
154 BUILD_NUMBER="$(BUILD_NUMBER)" \
155 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
156 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700157 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800158 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
159 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
160 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
161 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700162 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800163 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
Joe Onorato25939e22010-11-09 08:53:01 -0800164 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800165 bash $(BUILDINFO_SH) > $@
166 $(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \
167 cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \
168 fi
169 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
170 $(hide) echo >> $@; \
171 echo "#" >> $@; \
172 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
173 echo "#" >> $@; )
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700174 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
175 echo "$(line)" >> $@;)
Joe Onorato9197a482011-06-08 16:04:14 -0700176 $(hide) build/tools/post_process_props.py $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800177
178build_desc :=
179
180# -----------------------------------------------------------------
181# sdk-build.prop
182#
183# There are certain things in build.prop that we don't want to
184# ship with the sdk; remove them.
185
186# This must be a list of entire property keys followed by
187# "=" characters, without any internal spaces.
188sdk_build_prop_remove := \
189 ro.build.user= \
190 ro.build.host= \
191 ro.product.brand= \
192 ro.product.manufacturer= \
193 ro.product.device=
194# TODO: Remove this soon-to-be obsolete property
195sdk_build_prop_remove += ro.build.product=
196INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
197$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
198 @echo SDK buildinfo: $@
199 @mkdir -p $(dir $@)
200 $(hide) grep -v "$(subst $(space),\|,$(strip \
201 $(sdk_build_prop_remove)))" $< > $@.tmp
202 $(hide) for x in $(sdk_build_prop_remove); do \
203 echo "$$x"generic >> $@.tmp; done
204 $(hide) mv $@.tmp $@
205
206# -----------------------------------------------------------------
207# package stats
208PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
209PACKAGES_TO_STAT := \
210 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
211 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
212$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
213 @echo Package stats: $@
214 @mkdir -p $(dir $@)
215 $(hide) rm -f $@
216 $(hide) build/tools/dump-package-stats $^ > $@
217
218.PHONY: package-stats
219package-stats: $(PACKAGE_STATS_FILE)
220
221# -----------------------------------------------------------------
222# Cert-to-package mapping. Used by the post-build signing tools.
223name := $(TARGET_PRODUCT)
224ifeq ($(TARGET_BUILD_TYPE),debug)
225 name := $(name)_debug
226endif
227name := $(name)-apkcerts-$(FILE_NAME_TAG)
228intermediates := \
229 $(call intermediates-dir-for,PACKAGING,apkcerts)
230APKCERTS_FILE := $(intermediates)/$(name).txt
Ying Wang15e487a2011-02-15 10:56:18 -0800231# We don't need to really build all the modules.
232# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700233$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800234 @echo APK certs list: $@
235 @mkdir -p $(dir $@)
236 @rm -f $@
237 $(hide) $(foreach p,$(PACKAGES),\
Doug Zongkerf6a53aa2009-12-15 15:06:55 -0800238 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
239 echo 'name="$(p).apk" certificate="EXTERNAL" \
240 private_key=""' >> $@;,\
241 echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
242 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;))
Ying Wangf272cd62011-09-26 12:05:06 -0700243 # In case $(PACKAGES) is empty.
244 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800245
246.PHONY: apkcerts-list
247apkcerts-list: $(APKCERTS_FILE)
248
Ying Wang15e487a2011-02-15 10:56:18 -0800249ifneq (,$(TARGET_BUILD_APPS))
250 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
251endif
Ying Wangefb21682010-07-23 16:42:13 -0700252
The Android Open Source Project88b60792009-03-03 19:28:42 -0800253# -----------------------------------------------------------------
254# module info file
255ifdef CREATE_MODULE_INFO_FILE
256 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
257 $(info Generating $(MODULE_INFO_FILE)...)
258 $(shell rm -f $(MODULE_INFO_FILE))
259 $(foreach m,$(ALL_MODULES), \
260 $(shell echo "NAME=\"$(m)\"" \
261 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
262 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
263 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
264 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
265endif
266
Doug Zongker8678df42009-06-15 14:30:14 -0700267# -----------------------------------------------------------------
268
269# The test key is used to sign this package, and as the key required
270# for future OTA packages installed by this system. Actual product
271# deliverables will be re-signed by hand. We expect this file to
272# exist with the suffixes ".x509.pem" and ".pk8".
273DEFAULT_KEY_CERT_PAIR := $(SRC_TARGET_DIR)/product/security/testkey
274
275
Jeff Browne33ba4c2011-07-11 22:11:46 -0700276# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800277# if they don't do anything.
278.PHONY: systemimage
279systemimage:
280
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800281# -----------------------------------------------------------------
282
283.PHONY: event-log-tags
284
Joe Onoratob7510532010-07-14 10:22:54 -0700285# Produce an event logs tag file for everything we know about, in order
286# to properly allocate numbers. Then produce a file that's filtered
287# for what's going to be installed.
288
289all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
290
291# Include tags from all packages that we know about
292all_event_log_tags_src := \
293 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
294
295$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
296$(all_event_log_tags_file): $(all_event_log_tags_src)
297 $(hide) mkdir -p $(dir $@)
298 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
299
300
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800301event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800302
Doug Zongkera34fa952011-02-23 12:17:29 -0800303# Include tags from all packages included in this product, plus all
304# tags that are part of the system (ie, not in a vendor/ or device/
305# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800306event_log_tags_src := \
307 $(sort $(foreach m,\
308 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
309 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800310 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
311 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800312
313$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700314$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
315$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800316 $(hide) mkdir -p $(dir $@)
Joe Onoratob7510532010-07-14 10:22:54 -0700317 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800318
319event-log-tags: $(event_log_tags_file)
320
321ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
322
Joe Onoratob7510532010-07-14 10:22:54 -0700323
The Android Open Source Project88b60792009-03-03 19:28:42 -0800324# #################################################################
325# Targets for boot/OS images
326# #################################################################
327
328# -----------------------------------------------------------------
329# the ramdisk
330INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
331 $(ALL_PREBUILT) \
332 $(ALL_COPIED_HEADERS) \
333 $(ALL_GENERATED_SOURCES) \
334 $(ALL_DEFAULT_INSTALLED_MODULES))
335
Joe Onorato64d85d02009-04-09 19:31:12 -0700336BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
337
338# We just build this directly to the install location.
339INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700340$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800341 $(call pretty,"Target ram disk: $@")
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700342 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800343
344
345ifneq ($(strip $(TARGET_NO_KERNEL)),true)
346
347# -----------------------------------------------------------------
348# the boot image, which is a collection of other images.
349INTERNAL_BOOTIMAGE_ARGS := \
350 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
351 --kernel $(INSTALLED_KERNEL_TARGET) \
352 --ramdisk $(INSTALLED_RAMDISK_TARGET)
353
354INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
355
356BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
357ifdef BOARD_KERNEL_CMDLINE
358 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
359endif
360
Dima Zavin1e0847c2009-05-07 19:43:08 -0700361BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
362ifdef BOARD_KERNEL_BASE
363 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
364endif
365
Ying Wangffff0022010-08-23 12:56:25 -0700366BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
367ifdef BOARD_KERNEL_PAGESIZE
368 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
369endif
370
The Android Open Source Project88b60792009-03-03 19:28:42 -0800371INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
372
373ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
374tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
375INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
376INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
377$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
378 $(call pretty,"Target boot image: $@")
379 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
380
381else # TARGET_BOOTIMAGE_USE_EXT2 != true
382
383$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
384 $(call pretty,"Target boot image: $@")
385 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
Doug Zongkered96e882009-08-26 09:37:07 -0700386 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800387endif # TARGET_BOOTIMAGE_USE_EXT2
388
389else # TARGET_NO_KERNEL
390# HACK: The top-level targets depend on the bootimage. Not all targets
391# can produce a bootimage, though, and emulator targets need the ramdisk
392# instead. Fake it out by calling the ramdisk the bootimage.
393# TODO: make the emulator use bootimages, and make mkbootimg accept
394# kernel-less inputs.
395INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
396endif
397
398# -----------------------------------------------------------------
399# NOTICE files
400#
401# This needs to be before the systemimage rules, because it adds to
402# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
403# go into the systemimage.
404
405.PHONY: notice_files
406
407# Create the rule to combine the files into text and html forms
408# $(1) - Plain text output file
409# $(2) - HTML output file
410# $(3) - File title
411# $(4) - Directory to use. Notice files are all $(4)/src. Other
412# directories in there will be used for scratch
413# $(5) - Dependencies for the output files
414#
415# The algorithm here is that we go collect a hash for each of the notice
416# files and write the names of the files that match that hash. Then
417# to generate the real files, we go print out all of the files and their
418# hashes.
419#
420# These rules are fairly complex, so they depend on this makefile so if
421# it changes, they'll run again.
422#
423# TODO: We could clean this up so that we just record the locations of the
424# original notice files instead of making rules to copy them somwehere.
425# Then we could traverse that without quite as much bash drama.
426define combine-notice-files
427$(1) $(2): PRIVATE_MESSAGE := $(3)
428$(1) $(2) $(4)/hash-timestamp: PRIVATE_DIR := $(4)
429$(4)/hash-timestamp: $(5) $(BUILD_SYSTEM)/Makefile
430 @echo Finding NOTICE files: $$@
431 $$(hide) rm -rf $$@ $$(PRIVATE_DIR)/hash
432 $$(hide) mkdir -p $$(PRIVATE_DIR)/hash
433 $$(hide) for file in $$$$(find $$(PRIVATE_DIR)/src -type f); do \
434 hash=$$$$($(MD5SUM) $$$$file | sed -e "s/ .*//"); \
435 hashfile=$$(PRIVATE_DIR)/hash/$$$$hash; \
436 echo $$$$file >> $$$$hashfile; \
437 done
438 $$(hide) touch $$@
439$(1): $(4)/hash-timestamp
440 @echo Combining NOTICE files: $$@
441 $$(hide) mkdir -p $$(dir $$@)
442 $$(hide) echo $$(PRIVATE_MESSAGE) > $$@
443 $$(hide) find $$(PRIVATE_DIR)/hash -type f | xargs cat | sort | \
444 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> $$@
445 $$(hide) echo >> $$@
446 $$(hide) echo >> $$@
447 $$(hide) echo >> $$@
448 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
449 echo "============================================================"\
450 >> $$@; \
451 echo "Notices for file(s):" >> $$@; \
452 cat $$$$hashfile | sort | \
453 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \
454 $$@; \
455 echo "------------------------------------------------------------"\
456 >> $$@; \
457 echo >> $$@; \
458 orig=$$$$(head -n 1 $$$$hashfile); \
459 cat $$$$orig >> $$@; \
460 echo >> $$@; \
461 echo >> $$@; \
462 echo >> $$@; \
463 done
464$(2): $(4)/hash-timestamp
465 @echo Combining NOTICE files: $$@
466 $$(hide) mkdir -p $$(dir $$@)
467 $$(hide) echo "<html><head>" > $$@
468 $$(hide) echo "<style type=\"text/css\">" >> $$@
469 $$(hide) echo "body { padding: 0; font-family: sans-serif; }" >> $$@
470 $$(hide) echo ".same-license { background-color: #eeeeee; border-top: 20px solid white; padding: 10px; }" >> $$@
471 $$(hide) echo ".label { font-weight: bold; }" >> $$@
472 $$(hide) echo ".file-list { margin-left: 1em; font-color: blue; }" >> $$@
473 $$(hide) echo "</style>" >> $$@
474 $$(hide) echo "</head><body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">" >> $$@
475 $$(hide) echo "<table cellpading=\"0\" cellspacing=\"0\" border=\"0\">" \
476 >> $$@
477 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
478 cat $$$$hashfile | sort | \
479 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: <a name=\"\1\"></a>:" >> \
480 $$@; \
481 echo "<tr><td class=\"same-license\">" >> $$@; \
482 echo "<div class=\"label\">Notices for file(s):</div>" >> $$@; \
483 echo "<div class=\"file-list\">" >> $$@; \
484 cat $$$$hashfile | sort | \
485 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1<br/>:" >> $$@; \
486 echo "</div><!-- file-list -->" >> $$@; \
487 echo >> $$@; \
488 orig=$$$$(head -n 1 $$$$hashfile); \
489 echo "<pre class=\"license-text\">" >> $$@; \
490 cat $$$$orig | sed -e "s/\&/\&amp;/g" | sed -e "s/</\&lt;/g" \
491 | sed -e "s/>/\&gt;/g" >> $$@; \
492 echo "</pre><!-- license-text -->" >> $$@; \
493 echo "</td></tr><!-- same-license -->" >> $$@; \
494 echo >> $$@; \
495 echo >> $$@; \
496 echo >> $$@; \
497 done
498 $$(hide) echo "</table>" >> $$@
499 $$(hide) echo "</body></html>" >> $$@
500notice_files: $(1) $(2)
501endef
502
503# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
504# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
505# the src subdirectory.
506
507target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
508target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
509target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
510tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
511tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
512
513kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
514
515$(eval $(call combine-notice-files, \
516 $(target_notice_file_txt), \
517 $(target_notice_file_html), \
518 "Notices for files contained in the filesystem images in this directory:", \
519 $(TARGET_OUT_NOTICE_FILES), \
520 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)))
521
522$(eval $(call combine-notice-files, \
523 $(tools_notice_file_txt), \
524 $(tools_notice_file_html), \
525 "Notices for files contained in the tools directory:", \
526 $(HOST_OUT_NOTICE_FILES), \
527 $(ALL_DEFAULT_INSTALLED_MODULES)))
528
529# Install the html file at /system/etc/NOTICE.html.gz.
530# This is not ideal, but this is very late in the game, after a lot of
531# the module processing has already been done -- in fact, we used the
532# fact that all that has been done to get the list of modules that we
533# need notice files for.
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700534$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700535 $(hide) $(MINIGZIP) -9 < $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800536installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
537$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
538 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700539
540# if we've been run my mm, mmm, etc, don't reinstall this every time
541ifeq ($(ONE_SHOT_MAKEFILE),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800542ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700543endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800544
545# The kernel isn't really a module, so to get its module file in there, we
546# make the target NOTICE files depend on this particular file too, which will
547# then be in the right directory for the find in combine-notice-files to work.
548$(kernel_notice_file): \
549 prebuilt/$(TARGET_PREBUILT_TAG)/kernel/LINUX_KERNEL_COPYING \
550 | $(ACP)
551 @echo Copying: $@
552 $(hide) mkdir -p $(dir $@)
553 $(hide) $(ACP) $< $@
554
555
Doug Zongker8678df42009-06-15 14:30:14 -0700556# -----------------------------------------------------------------
557# Build a keystore with the authorized keys in it, used to verify the
558# authenticity of downloaded OTA packages.
559#
560# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
561# before the rules that use that variable to build the image.
562ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
563$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Doug Zongker37c0e272009-06-15 15:36:16 -0700564$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Doug Zongker8678df42009-06-15 14:30:14 -0700565 $(hide) rm -f $@
566 $(hide) mkdir -p $(dir $@)
Doug Zongker37c0e272009-06-15 15:36:16 -0700567 $(hide) zip -qj $@ $<
Doug Zongker8678df42009-06-15 14:30:14 -0700568
569.PHONY: otacerts
570otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
571
572
The Android Open Source Project88b60792009-03-03 19:28:42 -0800573# #################################################################
574# Targets for user images
575# #################################################################
576
Ying Wang933abf12010-06-16 14:31:34 -0700577INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800578ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -0700579INTERNAL_USERIMAGES_USE_EXT := true
580INTERNAL_USERIMAGES_EXT_VARIANT := ext2
581else
582ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
583INTERNAL_USERIMAGES_USE_EXT := true
584INTERNAL_USERIMAGES_EXT_VARIANT := ext3
585else
586ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
587INTERNAL_USERIMAGES_USE_EXT := true
588INTERNAL_USERIMAGES_EXT_VARIANT := ext4
589endif
590endif
591endif
592
Ying Wang542903a2010-11-17 15:40:38 -0800593ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
594 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
595endif
596
Colin Cross0a7b2c52010-05-07 02:23:59 -0700597ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
Ying Wang542903a2010-11-17 15:40:38 -0800598INTERNAL_USERIMAGES_DEPS := $(MKEXTUSERIMG) $(MAKE_EXT4FS)
Ying Wang933abf12010-06-16 14:31:34 -0700599INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
600
Ying Wangc79f4da2010-06-16 14:58:50 -0700601# $(1): src directory
602# $(2): output file
Ying Wang026f1452010-09-27 17:49:03 -0700603# $(3): mount point
Ying Wangc79f4da2010-06-16 14:58:50 -0700604# $(4): ext variant (ext2, ext3, ext4)
Colin Crosse0a40212010-08-03 14:43:34 -0700605# $(5): size of the partition
Ying Wangc79f4da2010-06-16 14:58:50 -0700606define build-userimage-ext-target
607 @mkdir -p $(dir $(2))
Ying Wang1b5f1dc2011-02-17 15:44:45 -0800608 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
Ying Wang542903a2010-11-17 15:40:38 -0800609 $(MKEXTUSERIMG) $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG) $(1) $(2) $(4) $(3) $(5)
Ying Wangc79f4da2010-06-16 14:58:50 -0700610endef
The Android Open Source Project88b60792009-03-03 19:28:42 -0800611else
Colin Cross144b0282010-05-10 13:04:47 -0700612INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800613endif
614
615# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -0700616# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700617
618# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
Brian Swetland630b7d32009-08-07 18:09:44 -0700619ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY) $(BUILD_TINY_ANDROID)))
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700620
Doug Zongker4647f122009-07-02 09:00:54 -0700621INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
622
623recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
624recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
625recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
626recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
627recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
628recovery_resources_common := $(call include-path-for, recovery)/res
629recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
630recovery_resource_deps := $(shell find $(recovery_resources_common) \
631 $(recovery_resources_private) -type f)
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700632recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Doug Zongker4647f122009-07-02 09:00:54 -0700633
634ifeq ($(recovery_resources_private),)
635 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
636endif
637
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700638ifeq ($(recovery_fstab),)
639 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
640endif
641
Doug Zongker4647f122009-07-02 09:00:54 -0700642INTERNAL_RECOVERYIMAGE_ARGS := \
643 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
644 --kernel $(recovery_kernel) \
645 --ramdisk $(recovery_ramdisk)
646
647# Assumes this has already been stripped
648ifdef BOARD_KERNEL_CMDLINE
649 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
650endif
651ifdef BOARD_KERNEL_BASE
652 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
653endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700654BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
655ifdef BOARD_KERNEL_PAGESIZE
656 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
657endif
Doug Zongker4647f122009-07-02 09:00:54 -0700658
659# Keys authorized to sign OTA packages this build will accept. The
660# build always uses test-keys for this; release packaging tools will
661# substitute other keys for this one.
662OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
663
664# Generate a file containing the keys that will be read by the
665# recovery binary.
666RECOVERY_INSTALL_OTA_KEYS := \
667 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
668DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
669$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
Doug Zongker5d4808d2011-03-16 07:49:13 -0700670$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
Doug Zongkere121d6a2011-02-01 14:13:52 -0800671$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys)
672 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
Doug Zongker4647f122009-07-02 09:00:54 -0700673 @rm -rf $@
674 @mkdir -p $(dir $@)
Doug Zongkere121d6a2011-02-01 14:13:52 -0800675 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
Doug Zongker4647f122009-07-02 09:00:54 -0700676
677$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
678 $(INSTALLED_RAMDISK_TARGET) \
679 $(INSTALLED_BOOTIMAGE_TARGET) \
680 $(recovery_binary) \
681 $(recovery_initrc) $(recovery_kernel) \
682 $(INSTALLED_2NDBOOTLOADER_TARGET) \
683 $(recovery_build_prop) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700684 $(recovery_fstab) \
Doug Zongker4647f122009-07-02 09:00:54 -0700685 $(RECOVERY_INSTALL_OTA_KEYS)
686 @echo ----- Making recovery image ------
687 rm -rf $(TARGET_RECOVERY_OUT)
688 mkdir -p $(TARGET_RECOVERY_OUT)
689 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)
690 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc
691 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp
692 echo Copying baseline ramdisk...
693 cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Doug Zongkerb4c7d322010-07-01 15:30:11 -0700694 rm $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
Doug Zongker4647f122009-07-02 09:00:54 -0700695 echo Modifying ramdisk contents...
696 cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
697 cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
698 cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
699 $(foreach item,$(recovery_resources_private), \
700 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700701 $(foreach item,$(recovery_fstab), \
702 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Doug Zongker4647f122009-07-02 09:00:54 -0700703 cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
704 cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
705 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
706 $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
707 $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@
708 @echo ----- Made recovery image -------- $@
Doug Zongkered96e882009-08-26 09:37:07 -0700709 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
Doug Zongker4647f122009-07-02 09:00:54 -0700710
711else
712INSTALLED_RECOVERYIMAGE_TARGET :=
713endif
714
715.PHONY: recoveryimage
716recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET)
717
Dima Zavin11818982010-02-05 13:34:34 -0800718ifneq ($(BOARD_NAND_PAGE_SIZE),)
719mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
720else
721mkyaffs2_extra_flags :=
Lars Svensson9cb8c282010-12-06 15:24:58 +0100722BOARD_NAND_PAGE_SIZE := 2048
Dima Zavin11818982010-02-05 13:34:34 -0800723endif
724
Naseer Ahmed53871882010-08-06 12:19:29 -0700725ifneq ($(BOARD_NAND_SPARE_SIZE),)
726mkyaffs2_extra_flags += -s $(BOARD_NAND_SPARE_SIZE)
Lars Svensson9cb8c282010-12-06 15:24:58 +0100727else
728BOARD_NAND_SPARE_SIZE := 64
Naseer Ahmed53871882010-08-06 12:19:29 -0700729endif
730
Doug Zongker4647f122009-07-02 09:00:54 -0700731# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -0700732# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800733#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800734
735INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
736 $(ALL_PREBUILT) \
737 $(ALL_COPIED_HEADERS) \
738 $(ALL_GENERATED_SOURCES) \
739 $(ALL_DEFAULT_INSTALLED_MODULES))
740
Ying Wange5e8c5f2011-09-09 16:35:53 -0700741FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
742# -----------------------------------------------------------------
743# installed file list
744# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
745# We put installed-files.txt ahead of image itself in the dependency graph
746# so that we can get the size stat even if the build fails due to too large
747# system image.
748INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
749$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS)
750 @echo Installed file list: $@
751 @mkdir -p $(dir $@)
752 @rm -f $@
753 $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@
754
755.PHONY: installed-file-list
756installed-file-list: $(INSTALLED_FILES_FILE)
757ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
758$(call dist-for-goals, sdk win_sdk, $(INSTALLED_FILES_FILE))
759endif
760ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
761$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
762endif
763
764systemimage_intermediates := \
765 $(call intermediates-dir-for,PACKAGING,systemimage)
766BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
767
Colin Cross0a7b2c52010-05-07 02:23:59 -0700768ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
769## generate an ext image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800770# $(1): output file
771define build-systemimage-target
772 @echo "Target system fs image: $(1)"
Colin Crosse0a40212010-08-03 14:43:34 -0700773 $(call build-userimage-ext-target,$(TARGET_OUT),$(1),system,$(INTERNAL_USERIMAGES_EXT_VARIANT),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800774endef
775
Colin Cross0a7b2c52010-05-07 02:23:59 -0700776else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800777
778## generate a yaffs2 image
779# $(1): output file
780define build-systemimage-target
781 @echo "Target system fs image: $(1)"
782 @mkdir -p $(dir $(1))
Dima Zavin11818982010-02-05 13:34:34 -0800783 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800784endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700785endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800786
Ying Wange5e8c5f2011-09-09 16:35:53 -0700787$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800788 $(call build-systemimage-target,$@)
789
The Android Open Source Project88b60792009-03-03 19:28:42 -0800790INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700791SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800792
Doug Zongker73ef8252009-07-23 15:12:53 -0700793# The system partition needs room for the recovery image as well. We
794# now store the recovery image as a binary patch using the boot image
795# as the source (since they are very similar). Generate the patch so
796# we can see how big it's going to be, and include that in the system
797# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700798ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700799intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
800RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
801$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
802 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700803 $(HOST_OUT_EXECUTABLES)/imgdiff \
804 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700805 @echo "Construct recovery from boot"
806 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700807 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700808endif
809
Doug Zongker73ef8252009-07-23 15:12:53 -0700810
811$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800812 @echo "Install system fs image: $@"
813 $(copy-file-to-target)
Doug Zongkered96e882009-08-26 09:37:07 -0700814 $(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 -0800815
816systemimage: $(INSTALLED_SYSTEMIMAGE)
817
818.PHONY: systemimage-nodeps snod
819systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -0700820 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800821 @echo "make $@: ignoring dependencies"
822 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
Doug Zongkered96e882009-08-26 09:37:07 -0700823 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800824
825#######
826## system tarball
827define build-systemtarball-target
828 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
829 $(MKTARBALL) $(FS_GET_STATS) \
830 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
831 $(INSTALLED_SYSTEMTARBALL_TARGET)
832endef
833
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700834ifndef SYSTEM_TARBALL_FORMAT
835 SYSTEM_TARBALL_FORMAT := bz2
836endif
837
The Android Open Source Project88b60792009-03-03 19:28:42 -0800838system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700839INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800840$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
841$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
842 $(build-systemtarball-target)
843
844.PHONY: systemtarball-nodeps
845systemtarball-nodeps: $(FS_GET_STATS) \
846 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
847 $(build-systemtarball-target)
848
849.PHONY: stnod
850stnod: systemtarball-nodeps
851
852
Bruce Beare52aac202010-06-04 15:24:49 -0700853#######
854## boot tarball
855define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -0700856 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -0700857 $(hide) mkdir -p $(PRODUCT_OUT)/boot
858 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
859 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
860 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
861 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
862 $(INSTALLED_BOOTTARBALL_TARGET)
863endef
864
865ifndef BOOT_TARBALL_FORMAT
866 BOOT_TARBALL_FORMAT := bz2
867endif
868
869boot_tar := $(PRODUCT_OUT)/boot.tar
870INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
871$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
872$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
873 $(build-boottarball-target)
874
875.PHONY: boottarball-nodeps btnod
876boottarball-nodeps btnod: $(FS_GET_STATS) \
877 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
878 $(build-boottarball-target)
879
880
The Android Open Source Project88b60792009-03-03 19:28:42 -0800881# -----------------------------------------------------------------
882# data partition image
883INTERNAL_USERDATAIMAGE_FILES := \
884 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
885
Colin Cross0a7b2c52010-05-07 02:23:59 -0700886ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800887## Generate an ext2 image
888define build-userdataimage-target
889 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
890 @mkdir -p $(TARGET_OUT_DATA)
Ying Wang026f1452010-09-27 17:49:03 -0700891 $(call build-userimage-ext-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),data,$(INTERNAL_USERIMAGES_EXT_VARIANT),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Doug Zongkered96e882009-08-26 09:37:07 -0700892 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800893endef
894
Colin Cross0a7b2c52010-05-07 02:23:59 -0700895else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800896
897## Generate a yaffs2 image
898define build-userdataimage-target
899 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
900 @mkdir -p $(TARGET_OUT_DATA)
Dima Zavin11818982010-02-05 13:34:34 -0800901 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
Doug Zongkered96e882009-08-26 09:37:07 -0700902 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800903endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700904endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800905
Joe Onorato64d85d02009-04-09 19:31:12 -0700906BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
907
908# We just build this directly to the install location.
909INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -0700910$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800911 $(INTERNAL_USERDATAIMAGE_FILES)
912 $(build-userdataimage-target)
913
914.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -0700915userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800916 $(build-userdataimage-target)
917
918#######
919## data partition tarball
920define build-userdatatarball-target
921 $(call pretty,"Target userdata fs tarball: " \
922 "$(INSTALLED_USERDATATARBALL_TARGET)")
923 $(MKTARBALL) $(FS_GET_STATS) \
924 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
925 $(INSTALLED_USERDATATARBALL_TARGET)
926endef
927
928userdata_tar := $(PRODUCT_OUT)/userdata.tar
929INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
930$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
931$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
932 $(build-userdatatarball-target)
933
934.PHONY: userdatatarball-nodeps
935userdatatarball-nodeps: $(FS_GET_STATS)
936 $(build-userdatatarball-target)
937
938
The Android Open Source Project88b60792009-03-03 19:28:42 -0800939# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800940# bring in the installer image generation defines if necessary
941ifeq ($(TARGET_USE_DISKINSTALLER),true)
942include bootable/diskinstaller/config.mk
943endif
944
945# -----------------------------------------------------------------
Doug Zongker8678df42009-06-15 14:30:14 -0700946# host tools needed to build OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -0800947
Ying Wang06898662010-06-17 17:52:18 -0700948OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -0700949 $(HOST_OUT_EXECUTABLES)/mkbootfs \
950 $(HOST_OUT_EXECUTABLES)/mkbootimg \
951 $(HOST_OUT_EXECUTABLES)/fs_config \
952 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
953 $(HOST_OUT_EXECUTABLES)/zipalign \
954 $(HOST_OUT_EXECUTABLES)/aapt \
955 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -0700956 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -0700957 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -0700958 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
959 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
960 $(HOST_OUT_EXECUTABLES)/genext2fs \
961 $(HOST_OUT_EXECUTABLES)/tune2fs \
Sriram Ramanff83c852010-11-30 15:09:19 -0500962 $(HOST_OUT_EXECUTABLES)/e2fsck \
Sriram Ramanc647aec2010-11-29 18:51:20 -0500963 $(HOST_OUT_EXECUTABLES)/make_ext4fs
The Android Open Source Project88b60792009-03-03 19:28:42 -0800964
Ying Wang06898662010-06-17 17:52:18 -0700965.PHONY: otatools
966otatools: $(OTATOOLS)
967
The Android Open Source Project88b60792009-03-03 19:28:42 -0800968# -----------------------------------------------------------------
969# A zip of the directories that map to the target filesystem.
970# This zip can be used to create an OTA package or filesystem image
971# as a post-build step.
972#
973name := $(TARGET_PRODUCT)
974ifeq ($(TARGET_BUILD_TYPE),debug)
975 name := $(name)_debug
976endif
977name := $(name)-target_files-$(FILE_NAME_TAG)
978
979intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
980BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
981$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
982$(BUILT_TARGET_FILES_PACKAGE): \
983 zip_root := $(intermediates)/$(name)
984
985# $(1): Directory to copy
986# $(2): Location to copy it to
987# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
988define package_files-copy-root
989 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
990 mkdir -p $(2) && \
991 $(ACP) -rd $(strip $(1))/* $(2); \
992 fi
993endef
994
995built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -0700996 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -0700997 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -0700998 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
Doug Zongker25863d72011-09-19 15:02:03 -0700999 $(call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \
Doug Zongkera406c1e2009-06-12 16:57:08 -07001000 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -08001001$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
1002
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001003$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
1004
Doug Zongkerc18736b2009-09-30 09:20:32 -07001005ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1006# default to common dir for device vendor
1007$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
1008else
1009$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1010endif
1011
The Android Open Source Project88b60792009-03-03 19:28:42 -08001012# Depending on the various images guarantees that the underlying
1013# directories are up-to-date.
1014$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001015 $(INSTALLED_BOOTIMAGE_TARGET) \
1016 $(INSTALLED_RADIOIMAGE_TARGET) \
1017 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -07001018 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001019 $(INSTALLED_USERDATAIMAGE_TARGET) \
1020 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001021 $(built_ota_tools) \
1022 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -07001023 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001024 | $(ACP)
1025 @echo "Package target files: $@"
1026 $(hide) rm -rf $@ $(zip_root)
1027 $(hide) mkdir -p $(dir $@) $(zip_root)
1028 @# Components of the recovery image
1029 $(hide) mkdir -p $(zip_root)/RECOVERY
1030 $(hide) $(call package_files-copy-root, \
1031 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
1032ifdef INSTALLED_KERNEL_TARGET
1033 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
1034endif
1035ifdef INSTALLED_2NDBOOTLOADER_TARGET
1036 $(hide) $(ACP) \
1037 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
1038endif
1039ifdef BOARD_KERNEL_CMDLINE
1040 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
1041endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001042ifdef BOARD_KERNEL_BASE
1043 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
1044endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001045ifdef BOARD_KERNEL_PAGESIZE
1046 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
1047endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001048 @# Components of the boot image
1049 $(hide) mkdir -p $(zip_root)/BOOT
1050 $(hide) $(call package_files-copy-root, \
1051 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1052ifdef INSTALLED_KERNEL_TARGET
1053 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1054endif
1055ifdef INSTALLED_2NDBOOTLOADER_TARGET
1056 $(hide) $(ACP) \
1057 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1058endif
1059ifdef BOARD_KERNEL_CMDLINE
1060 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1061endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001062ifdef BOARD_KERNEL_BASE
1063 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1064endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001065ifdef BOARD_KERNEL_PAGESIZE
1066 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1067endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001068 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1069 mkdir -p $(zip_root)/RADIO; \
1070 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001071 @# Contents of the system image
1072 $(hide) $(call package_files-copy-root, \
1073 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1074 @# Contents of the data image
1075 $(hide) $(call package_files-copy-root, \
1076 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1077 @# Extra contents of the OTA package
1078 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001079 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1080 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001081 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001082 @# build them.
1083 $(hide) mkdir -p $(zip_root)/META
1084 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker17c83cf2009-04-01 15:48:46 -07001085 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -07001086 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001087ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07001088 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001089endif
1090ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001091 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001092endif
1093ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001094 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001095endif
1096ifdef BOARD_SYSTEMIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001097 $(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001098endif
1099ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
Ying Wang00836712011-01-14 11:30:56 -08001100 $(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001101endif
Doug Zongker37974732010-09-16 17:44:38 -07001102 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001103ifdef mkyaffs2_extra_flags
Doug Zongker37974732010-09-16 17:44:38 -07001104 $(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001105endif
Ying Wangc5a07ce2010-11-17 17:45:36 -08001106ifdef INTERNAL_USERIMAGES_SPARSE_EXT_FLAG
1107 $(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(zip_root)/META/misc_info.txt
1108endif
Doug Zongker5d4808d2011-03-16 07:49:13 -07001109ifdef PRODUCT_EXTRA_RECOVERY_KEYS
1110 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
Doug Zongkere121d6a2011-02-01 14:13:52 -08001111endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001112 @# Zip everything up, preserving symlinks
1113 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongker23f8bde2011-09-07 14:11:51 -07001114 @# Run fs_config on all the system, boot ramdisk, and recovery ramdisk files in the zip, and save the output
1115 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
1116 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/boot_filesystem_config.txt
1117 $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/recovery_filesystem_config.txt
1118 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
Doug Zongker283e2a12010-03-15 17:52:32 -07001119
The Android Open Source Project88b60792009-03-03 19:28:42 -08001120
1121target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1122
Doug Zongker367910f2009-06-15 18:56:51 -07001123
Doug Zongker367910f2009-06-15 18:56:51 -07001124ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang279f3082011-02-09 12:26:42 -08001125ifeq ($(filter generic%,$(TARGET_DEVICE)),)
Ying Wangfb0a3472010-08-25 16:06:06 -07001126ifneq ($(TARGET_NO_KERNEL),true)
Ying Wanga73b6562011-03-03 21:52:08 -08001127ifneq ($(recovery_fstab),)
Doug Zongker367910f2009-06-15 18:56:51 -07001128
Ying Wang09a00a62010-10-20 14:01:09 -07001129# -----------------------------------------------------------------
1130# OTA update package
1131
Doug Zongker8678df42009-06-15 14:30:14 -07001132name := $(TARGET_PRODUCT)
1133ifeq ($(TARGET_BUILD_TYPE),debug)
1134 name := $(name)_debug
1135endif
1136name := $(name)-ota-$(FILE_NAME_TAG)
1137
1138INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1139
1140$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1141
Ying Wang06898662010-06-17 17:52:18 -07001142$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001143 @echo "Package OTA: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001144 $(hide) ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker602a84e2009-06-18 08:35:12 -07001145 -p $(HOST_OUT) \
Doug Zongker8678df42009-06-15 14:30:14 -07001146 -k $(KEY_CERT_PAIR) \
1147 $(BUILT_TARGET_FILES_PACKAGE) $@
1148
1149.PHONY: otapackage
1150otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1151
Ying Wang09a00a62010-10-20 14:01:09 -07001152# -----------------------------------------------------------------
1153# The update package
1154
1155name := $(TARGET_PRODUCT)
1156ifeq ($(TARGET_BUILD_TYPE),debug)
1157 name := $(name)_debug
1158endif
1159name := $(name)-img-$(FILE_NAME_TAG)
1160
1161INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1162
1163ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1164# default to common dir for device vendor
1165$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_DEVICE_DIR)/../common
1166else
1167$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1168endif
1169
1170$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
1171 @echo "Package: $@"
1172 $(hide) ./build/tools/releasetools/img_from_target_files -v \
1173 -s $(extensions) \
1174 -p $(HOST_OUT) \
1175 $(BUILT_TARGET_FILES_PACKAGE) $@
1176
1177.PHONY: updatepackage
1178updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
1179
Ying Wanga73b6562011-03-03 21:52:08 -08001180endif # recovery_fstab is defined
Ying Wangfb0a3472010-08-25 16:06:06 -07001181endif # TARGET_NO_KERNEL != true
Ying Wang279f3082011-02-09 12:26:42 -08001182endif # TARGET_DEVICE != generic*
Doug Zongker367910f2009-06-15 18:56:51 -07001183endif # TARGET_PRODUCT != sdk
Doug Zongker8678df42009-06-15 14:30:14 -07001184
1185# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001186# A zip of the tests that are built when running "make tests".
1187# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
1188# only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
1189#
1190name := $(TARGET_PRODUCT)
1191ifeq ($(TARGET_BUILD_TYPE),debug)
1192 name := $(name)_debug
1193endif
1194name := $(name)-tests-$(FILE_NAME_TAG)
1195
1196intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
1197BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
1198$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
1199$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
1200
1201# Depending on the images guarantees that the underlying
1202# directories are up-to-date.
1203$(BUILT_TESTS_ZIP_PACKAGE): \
1204 $(BUILT_SYSTEMIMAGE) \
1205 $(INSTALLED_USERDATAIMAGE_TARGET) \
1206 | $(ACP)
1207 @echo "Package test files: $@"
1208 $(hide) rm -rf $@ $(zip_root)
1209 $(hide) mkdir -p $(dir $@) $(zip_root)
1210 @# Some parts of the system image
1211 $(hide) $(call package_files-copy-root, \
1212 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin)
1213 $(hide) $(call package_files-copy-root, \
1214 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib)
1215 $(hide) $(call package_files-copy-root, \
1216 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \
1217 $(zip_root)/SYSTEM/framework)
1218 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM
1219 @# Contents of the data image
1220 $(hide) $(call package_files-copy-root, \
1221 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1222 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
1223
Ying Wang9c762552010-09-10 14:39:33 -07001224.PHONY: tests-zip-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001225tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
1226
Ying Wangdb2cb632010-09-14 16:07:56 -07001227# Target needed by tests build
1228.PHONY: tests-build-target
1229tests-build-target: $(BUILT_TESTS_ZIP_PACKAGE) \
1230 $(BUILT_USERDATAIMAGE_TARGET)
1231
1232ifneq (,$(filter $(MAKECMDGOALS),tests-build-target))
1233 $(call dist-for-goals, tests-build-target, \
1234 $(BUILT_TESTS_ZIP_PACKAGE) \
1235 $(BUILT_USERDATAIMAGE_TARGET))
Ying Wang9c762552010-09-10 14:39:33 -07001236endif
1237
The Android Open Source Project88b60792009-03-03 19:28:42 -08001238# -----------------------------------------------------------------
1239# A zip of the symbols directory. Keep the full paths to make it
1240# more obvious where these files came from.
1241#
1242name := $(TARGET_PRODUCT)
1243ifeq ($(TARGET_BUILD_TYPE),debug)
1244 name := $(name)_debug
1245endif
1246name := $(name)-symbols-$(FILE_NAME_TAG)
1247
1248SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1249$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1250 @echo "Package symbols: $@"
1251 $(hide) rm -rf $@
1252 $(hide) mkdir -p $(dir $@)
1253 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1254
1255# -----------------------------------------------------------------
1256# A zip of the Android Apps. Not keeping full path so that we don't
1257# include product names when distributing
1258#
1259name := $(TARGET_PRODUCT)
1260ifeq ($(TARGET_BUILD_TYPE),debug)
1261 name := $(name)_debug
1262endif
1263name := $(name)-apps-$(FILE_NAME_TAG)
1264
1265APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1266$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1267 @echo "Package apps: $@"
1268 $(hide) rm -rf $@
1269 $(hide) mkdir -p $(dir $@)
1270 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
1271
Guang Zhu0198d6e2010-04-23 11:54:37 -07001272
1273#------------------------------------------------------------------
1274# A zip of emma code coverage meta files. Generated for fully emma
1275# instrumented build.
1276#
1277EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
1278$(EMMA_META_ZIP): $(INSTALLED_SYSTEMIMAGE)
1279 @echo "Collecting Emma coverage meta files."
1280 $(hide) find $(TARGET_COMMON_OUT_ROOT) -name "coverage.em" | \
1281 zip -@ -q $@
1282
The Android Open Source Project88b60792009-03-03 19:28:42 -08001283# -----------------------------------------------------------------
1284# dalvik something
1285.PHONY: dalvikfiles
1286dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1287
1288# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001289# The emulator package
1290
The Android Open Source Project88b60792009-03-03 19:28:42 -08001291INTERNAL_EMULATOR_PACKAGE_FILES += \
1292 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Bruce Beare18a130e2011-02-18 15:06:20 -08001293 prebuilt/android-$(TARGET_ARCH)/kernel/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001294 $(INSTALLED_RAMDISK_TARGET) \
1295 $(INSTALLED_SYSTEMIMAGE) \
1296 $(INSTALLED_USERDATAIMAGE_TARGET)
1297
1298name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1299
1300INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1301
1302$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1303 @echo "Package: $@"
1304 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1305
The Android Open Source Project88b60792009-03-03 19:28:42 -08001306# -----------------------------------------------------------------
1307# The pdk package (Platform Development Kit)
1308
1309ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1310 include development/pdk/Pdk.mk
1311endif
1312
1313# -----------------------------------------------------------------
1314# The SDK
1315
The Android Open Source Project88b60792009-03-03 19:28:42 -08001316# The SDK includes host-specific components, so it belongs under HOST_OUT.
1317sdk_dir := $(HOST_OUT)/sdk
1318
1319# Build a name that looks like:
1320#
1321# linux-x86 --> android-sdk_12345_linux-x86
1322# darwin-x86 --> android-sdk_12345_mac-x86
1323# windows-x86 --> android-sdk_12345_windows
1324#
1325sdk_name := android-sdk_$(FILE_NAME_TAG)
1326ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001327 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001328else
Joe Onorato03fbe402009-04-13 08:31:16 -07001329 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001330endif
1331ifneq ($(HOST_OS),windows)
Joe Onorato03fbe402009-04-13 08:31:16 -07001332 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001333endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001334sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001335
1336sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1337
1338ATREE_FILES :=
1339-include $(sdk_dep_file)
1340
1341# if we don't have a real list, then use "everything"
1342ifeq ($(strip $(ATREE_FILES)),)
1343ATREE_FILES := \
1344 $(ALL_PREBUILT) \
1345 $(ALL_COPIED_HEADERS) \
1346 $(ALL_GENERATED_SOURCES) \
1347 $(ALL_DEFAULT_INSTALLED_MODULES) \
1348 $(INSTALLED_RAMDISK_TARGET) \
1349 $(ALL_DOCS) \
1350 $(ALL_SDK_FILES)
1351endif
1352
1353atree_dir := development/build
1354
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001355# sdk/build/tools.atree contains the generic rules, while
1356#
1357# sdk/build/tools.$(TARGET_ARCH).atree contains target-specific rules
1358# the latter is optional.
1359#
1360sdk_tools_atree_files := sdk/build/tools.atree
1361ifneq (,$(strip $(wildcard sdk/build/tools.$(TARGET_ARCH).atree)))
1362 sdk_tools_atree_files += sdk/build/tools.$(TARGET_ARCH).atree
1363endif
1364
The Android Open Source Project88b60792009-03-03 19:28:42 -08001365sdk_atree_files := \
1366 $(atree_dir)/sdk.exclude.atree \
1367 $(atree_dir)/sdk.atree \
Xavier Ducrohetffd50872010-09-27 15:51:32 -07001368 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree \
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001369 $(sdk_tools_atree_files)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001370
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02001371# development/build/sdk-android-<abi>.atree is used to differentiate
1372# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
1373# files like the kernel image. We use TARGET_CPU_ABI because we don't
1374# have a better way to distinguish between CPU models.
1375ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
1376 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
1377endif
1378
The Android Open Source Project88b60792009-03-03 19:28:42 -08001379deps := \
1380 $(target_notice_file_txt) \
1381 $(tools_notice_file_txt) \
1382 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001383 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001384 $(INSTALLED_SYSTEMIMAGE) \
1385 $(INSTALLED_USERDATAIMAGE_TARGET) \
1386 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001387 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001388 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001389 $(ATREE_FILES) \
1390 $(atree_dir)/sdk.atree \
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01001391 $(sdk_tools_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001392 $(HOST_OUT_EXECUTABLES)/atree \
1393 $(HOST_OUT_EXECUTABLES)/line_endings
1394
1395INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1396$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1397$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1398$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1399$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1400
1401# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1402#
1403#SDK_GNU_ERROR := true
1404
1405$(INTERNAL_SDK_TARGET): $(deps)
1406 @echo "Package SDK: $@"
1407 $(hide) rm -rf $(PRIVATE_DIR) $@
1408 $(hide) for f in $(target_gnu_MODULES); do \
1409 if [ -f $$f ]; then \
1410 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1411 including GNU target $$f >&2; \
1412 FAIL=$(SDK_GNU_ERROR); \
1413 fi; \
1414 done; \
1415 if [ $$FAIL ]; then exit 1; fi
1416 $(hide) ( \
1417 $(HOST_OUT_EXECUTABLES)/atree \
1418 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1419 -m $(PRIVATE_DEP_FILE) \
1420 -I . \
1421 -I $(PRODUCT_OUT) \
1422 -I $(HOST_OUT) \
1423 -I $(TARGET_COMMON_OUT_ROOT) \
1424 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
Raphael Moll7558ad52011-01-05 14:58:17 -08001425 -v "OUT_DIR=$(OUT_DIR)" \
Bruce Beare18a130e2011-02-18 15:06:20 -08001426 -v "TARGET_ARCH=$(TARGET_ARCH)" \
1427 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
David 'Digit' Turner557c51f2011-08-25 14:28:03 +02001428 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001429 -o $(PRIVATE_DIR) && \
1430 cp -f $(target_notice_file_txt) \
Xavier Ducrohet6de7bc62011-09-21 10:22:19 -07001431 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001432 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
Xavier Ducrohet4216a8c2011-03-15 13:28:40 -07001433 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001434 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Raphael7a6a9c32011-02-01 13:30:00 -08001435 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001436 chmod -R ug+rwX $(PRIVATE_DIR) && \
1437 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1438 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1439
Raphael3d224a02010-04-16 17:50:09 -07001440
1441# Is a Windows SDK requested? If so, we need some definitions from here
1442# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08001443MAIN_SDK_NAME := $(sdk_name)
1444MAIN_SDK_DIR := $(sdk_dir)
1445MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Raphael3d224a02010-04-16 17:50:09 -07001446ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07001447include $(TOPDIR)development/build/tools/windows_sdk.mk
1448endif
1449
The Android Open Source Project88b60792009-03-03 19:28:42 -08001450# -----------------------------------------------------------------
1451# Findbugs
1452INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1453INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1454$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1455 @echo UnionBugs: $@
1456 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1457 > $@
1458$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1459 @echo ConvertXmlToText: $@
1460 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1461 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1462
1463# -----------------------------------------------------------------
1464# Findbugs
1465
1466# -----------------------------------------------------------------
1467# These are some additional build tasks that need to be run.
1468include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01001469-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Raphaelc4d47312011-02-15 16:09:36 -08001470
1471# -----------------------------------------------------------------
1472# Create SDK repository packages. Must be done after tasks/* since
1473# we need the addon rules defined.
1474ifneq ($(sdk_repo_goal),)
1475include $(TOPDIR)development/build/tools/sdk_repo.mk
1476endif