blob: 7ba33a6d45808a083ff20f9d2541888716cebf9b [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"
19unique_product_copy_files_destinations := $(sort \
20 $(foreach cf,$(PRODUCT_COPY_FILES), $(call word-colon,2,$(cf))))
The Android Open Source Project88b60792009-03-03 19:28:42 -080021$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang462d26b2010-11-02 21:31:47 -070022 $(eval _src := $(call word-colon,1,$(cf))) \
23 $(eval _dest := $(call word-colon,2,$(cf))) \
24 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
25 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
26 $(eval $(call copy-one-file,$(_src),$(_fulldest))) \
27 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
28 $(eval unique_product_copy_files_destinations := $(filter-out $(_dest), \
29 $(unique_product_copy_files_destinations)))))
The Android Open Source Project88b60792009-03-03 19:28:42 -080030
31# -----------------------------------------------------------------
32# docs/index.html
33gen := $(OUT_DOCS)/index.html
34ALL_DOCS += $(gen)
35$(gen): frameworks/base/docs/docs-redirect-index.html
36 @mkdir -p $(dir $@)
37 @cp -f $< $@
38
39# -----------------------------------------------------------------
40# default.prop
41INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
42ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
43ADDITIONAL_DEFAULT_PROPERTIES := \
44 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
45
46$(INSTALLED_DEFAULT_PROP_TARGET):
47 @echo Target buildinfo: $@
48 @mkdir -p $(dir $@)
49 $(hide) echo "#" > $@; \
50 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
51 echo "#" >> $@;
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -070052 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
53 echo "$(line)" >> $@;)
The Android Open Source Project88b60792009-03-03 19:28:42 -080054
55# -----------------------------------------------------------------
56# build.prop
57INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
58ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
59ADDITIONAL_BUILD_PROPERTIES := \
60 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
61
62# A list of arbitrary tags describing the build configuration.
63# Force ":=" so we can use +=
64BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
65ifeq ($(TARGET_BUILD_TYPE),debug)
66 BUILD_VERSION_TAGS += debug
67endif
68# Apps are always signed with test keys, and may be re-signed in a post-build
69# step. If that happens, the "test-keys" tag will be removed by that step.
70BUILD_VERSION_TAGS += test-keys
The Android Open Source Project88b60792009-03-03 19:28:42 -080071BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
72
73# A human-readable string that descibes this build in detail.
74build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)
75$(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc)
76
77# The string used to uniquely identify this build; used by the OTA server.
78ifeq (,$(strip $(BUILD_FINGERPRINT)))
Doug Zongker135a1202010-09-15 13:02:12 -070079 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 -080080endif
81ifneq ($(words $(BUILD_FINGERPRINT)),1)
82 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
83endif
84
Sriram Raman7b641242009-03-24 22:40:59 -070085# Display parameters shown under Settings -> About Phone
86ifeq ($(TARGET_BUILD_VARIANT),user)
87 # User builds should show:
88 # release build number or branch.buld_number non-release builds
89
90 # Dev. branches should have DISPLAY_BUILD_NUMBER set
91 ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
92 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER)
93 else
94 BUILD_DISPLAY_ID := $(BUILD_ID)
95 endif
96else
97 # Non-user builds should show detailed build information
98 BUILD_DISPLAY_ID := $(build_desc)
99endif
100
Ying Wang77c882f2010-04-27 15:45:35 -0700101# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
Ying Wang38d7f022010-07-21 14:58:42 -0700102product_property_override_locale_language := $(strip \
103 $(patsubst ro.product.locale.language=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700104 $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
Ying Wang38d7f022010-07-21 14:58:42 -0700105product_property_overrides_locale_region := $(strip \
106 $(patsubst ro.product.locale.region=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700107 $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
108
The Android Open Source Project88b60792009-03-03 19:28:42 -0800109# Selects the first locale in the list given as the argument,
110# and splits it into language and region, which each may be
111# empty.
112define default-locale
113$(subst _, , $(firstword $(1)))
114endef
115
116# Selects the first locale in the list given as the argument
Ying Wang77c882f2010-04-27 15:45:35 -0700117# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
118# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800119define default-locale-language
Ying Wang38d7f022010-07-21 14:58:42 -0700120$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800121endef
122define default-locale-region
Ying Wang38d7f022010-07-21 14:58:42 -0700123$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800124endef
125
126BUILDINFO_SH := build/tools/buildinfo.sh
Chih-Wei Huang4e3c6682009-08-31 14:55:33 +0800127$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800128 @echo Target buildinfo: $@
129 @mkdir -p $(dir $@)
130 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
131 TARGET_DEVICE="$(TARGET_DEVICE)" \
132 PRODUCT_NAME="$(TARGET_PRODUCT)" \
133 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
134 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
135 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700136 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800137 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
138 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
139 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
140 BUILD_ID="$(BUILD_ID)" \
141 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
142 BUILD_NUMBER="$(BUILD_NUMBER)" \
143 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
144 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700145 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800146 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
147 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
148 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
149 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700150 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800151 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800152 bash $(BUILDINFO_SH) > $@
153 $(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \
154 cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \
155 fi
156 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
157 $(hide) echo >> $@; \
158 echo "#" >> $@; \
159 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
160 echo "#" >> $@; )
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700161 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
162 echo "$(line)" >> $@;)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800163
164build_desc :=
165
166# -----------------------------------------------------------------
167# sdk-build.prop
168#
169# There are certain things in build.prop that we don't want to
170# ship with the sdk; remove them.
171
172# This must be a list of entire property keys followed by
173# "=" characters, without any internal spaces.
174sdk_build_prop_remove := \
175 ro.build.user= \
176 ro.build.host= \
177 ro.product.brand= \
178 ro.product.manufacturer= \
179 ro.product.device=
180# TODO: Remove this soon-to-be obsolete property
181sdk_build_prop_remove += ro.build.product=
182INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
183$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
184 @echo SDK buildinfo: $@
185 @mkdir -p $(dir $@)
186 $(hide) grep -v "$(subst $(space),\|,$(strip \
187 $(sdk_build_prop_remove)))" $< > $@.tmp
188 $(hide) for x in $(sdk_build_prop_remove); do \
189 echo "$$x"generic >> $@.tmp; done
190 $(hide) mv $@.tmp $@
191
192# -----------------------------------------------------------------
193# package stats
194PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
195PACKAGES_TO_STAT := \
196 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
197 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
198$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
199 @echo Package stats: $@
200 @mkdir -p $(dir $@)
201 $(hide) rm -f $@
202 $(hide) build/tools/dump-package-stats $^ > $@
203
204.PHONY: package-stats
205package-stats: $(PACKAGE_STATS_FILE)
206
207# -----------------------------------------------------------------
208# Cert-to-package mapping. Used by the post-build signing tools.
209name := $(TARGET_PRODUCT)
210ifeq ($(TARGET_BUILD_TYPE),debug)
211 name := $(name)_debug
212endif
213name := $(name)-apkcerts-$(FILE_NAME_TAG)
214intermediates := \
215 $(call intermediates-dir-for,PACKAGING,apkcerts)
216APKCERTS_FILE := $(intermediates)/$(name).txt
217# Depending on the built packages isn't exactly right,
218# but it should guarantee that the apkcerts file is rebuilt
219# if any packages change which certs they're signed with.
220all_built_packages := $(foreach p,$(PACKAGES),$(ALL_MODULES.$(p).BUILT))
Ying Wangefb21682010-07-23 16:42:13 -0700221ifneq ($(TARGET_BUILD_APPS),)
222# We don't need to really build all the modules for apps_only build.
223$(APKCERTS_FILE):
224else
The Android Open Source Project88b60792009-03-03 19:28:42 -0800225$(APKCERTS_FILE): $(all_built_packages)
Ying Wangefb21682010-07-23 16:42:13 -0700226endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800227 @echo APK certs list: $@
228 @mkdir -p $(dir $@)
229 @rm -f $@
230 $(hide) $(foreach p,$(PACKAGES),\
Doug Zongkerf6a53aa2009-12-15 15:06:55 -0800231 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
232 echo 'name="$(p).apk" certificate="EXTERNAL" \
233 private_key=""' >> $@;,\
234 echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
235 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800236
237.PHONY: apkcerts-list
238apkcerts-list: $(APKCERTS_FILE)
239
Ying Wangefb21682010-07-23 16:42:13 -0700240$(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
241
The Android Open Source Project88b60792009-03-03 19:28:42 -0800242# -----------------------------------------------------------------
243# module info file
244ifdef CREATE_MODULE_INFO_FILE
245 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
246 $(info Generating $(MODULE_INFO_FILE)...)
247 $(shell rm -f $(MODULE_INFO_FILE))
248 $(foreach m,$(ALL_MODULES), \
249 $(shell echo "NAME=\"$(m)\"" \
250 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
251 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
252 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
253 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
254endif
255
Doug Zongker8678df42009-06-15 14:30:14 -0700256# -----------------------------------------------------------------
257
258# The test key is used to sign this package, and as the key required
259# for future OTA packages installed by this system. Actual product
260# deliverables will be re-signed by hand. We expect this file to
261# exist with the suffixes ".x509.pem" and ".pk8".
262DEFAULT_KEY_CERT_PAIR := $(SRC_TARGET_DIR)/product/security/testkey
263
264
The Android Open Source Project88b60792009-03-03 19:28:42 -0800265# Rules that need to be present for the simulator, even
266# if they don't do anything.
267.PHONY: systemimage
268systemimage:
269
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800270# -----------------------------------------------------------------
271
272.PHONY: event-log-tags
273
Joe Onoratob7510532010-07-14 10:22:54 -0700274# Produce an event logs tag file for everything we know about, in order
275# to properly allocate numbers. Then produce a file that's filtered
276# for what's going to be installed.
277
278all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
279
280# Include tags from all packages that we know about
281all_event_log_tags_src := \
282 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
283
284$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
285$(all_event_log_tags_file): $(all_event_log_tags_src)
286 $(hide) mkdir -p $(dir $@)
287 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
288
289
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800290event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800291
292# Include tags from all packages included in this product.
293event_log_tags_src := \
294 $(sort $(foreach m,\
295 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
296 $(call module-names-for-tag-list,user), \
297 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
298
299$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700300$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
301$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800302 $(hide) mkdir -p $(dir $@)
Joe Onoratob7510532010-07-14 10:22:54 -0700303 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800304
305event-log-tags: $(event_log_tags_file)
306
307ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
308
Joe Onoratob7510532010-07-14 10:22:54 -0700309
The Android Open Source Project88b60792009-03-03 19:28:42 -0800310ifneq ($(TARGET_SIMULATOR),true)
311
312# #################################################################
313# Targets for boot/OS images
314# #################################################################
315
316# -----------------------------------------------------------------
317# the ramdisk
318INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
319 $(ALL_PREBUILT) \
320 $(ALL_COPIED_HEADERS) \
321 $(ALL_GENERATED_SOURCES) \
322 $(ALL_DEFAULT_INSTALLED_MODULES))
323
Joe Onorato64d85d02009-04-09 19:31:12 -0700324BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
325
326# We just build this directly to the install location.
327INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700328$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800329 $(call pretty,"Target ram disk: $@")
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700330 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800331
332
333ifneq ($(strip $(TARGET_NO_KERNEL)),true)
334
335# -----------------------------------------------------------------
336# the boot image, which is a collection of other images.
337INTERNAL_BOOTIMAGE_ARGS := \
338 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
339 --kernel $(INSTALLED_KERNEL_TARGET) \
340 --ramdisk $(INSTALLED_RAMDISK_TARGET)
341
342INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
343
344BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
345ifdef BOARD_KERNEL_CMDLINE
346 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
347endif
348
Dima Zavin1e0847c2009-05-07 19:43:08 -0700349BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
350ifdef BOARD_KERNEL_BASE
351 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
352endif
353
Ying Wangffff0022010-08-23 12:56:25 -0700354BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
355ifdef BOARD_KERNEL_PAGESIZE
356 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
357endif
358
The Android Open Source Project88b60792009-03-03 19:28:42 -0800359INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
360
361ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
362tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
363INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
364INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
365$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
366 $(call pretty,"Target boot image: $@")
367 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
368
369else # TARGET_BOOTIMAGE_USE_EXT2 != true
370
371$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
372 $(call pretty,"Target boot image: $@")
373 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
Doug Zongkered96e882009-08-26 09:37:07 -0700374 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800375endif # TARGET_BOOTIMAGE_USE_EXT2
376
377else # TARGET_NO_KERNEL
378# HACK: The top-level targets depend on the bootimage. Not all targets
379# can produce a bootimage, though, and emulator targets need the ramdisk
380# instead. Fake it out by calling the ramdisk the bootimage.
381# TODO: make the emulator use bootimages, and make mkbootimg accept
382# kernel-less inputs.
383INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
384endif
385
386# -----------------------------------------------------------------
387# NOTICE files
388#
389# This needs to be before the systemimage rules, because it adds to
390# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
391# go into the systemimage.
392
393.PHONY: notice_files
394
395# Create the rule to combine the files into text and html forms
396# $(1) - Plain text output file
397# $(2) - HTML output file
398# $(3) - File title
399# $(4) - Directory to use. Notice files are all $(4)/src. Other
400# directories in there will be used for scratch
401# $(5) - Dependencies for the output files
402#
403# The algorithm here is that we go collect a hash for each of the notice
404# files and write the names of the files that match that hash. Then
405# to generate the real files, we go print out all of the files and their
406# hashes.
407#
408# These rules are fairly complex, so they depend on this makefile so if
409# it changes, they'll run again.
410#
411# TODO: We could clean this up so that we just record the locations of the
412# original notice files instead of making rules to copy them somwehere.
413# Then we could traverse that without quite as much bash drama.
414define combine-notice-files
415$(1) $(2): PRIVATE_MESSAGE := $(3)
416$(1) $(2) $(4)/hash-timestamp: PRIVATE_DIR := $(4)
417$(4)/hash-timestamp: $(5) $(BUILD_SYSTEM)/Makefile
418 @echo Finding NOTICE files: $$@
419 $$(hide) rm -rf $$@ $$(PRIVATE_DIR)/hash
420 $$(hide) mkdir -p $$(PRIVATE_DIR)/hash
421 $$(hide) for file in $$$$(find $$(PRIVATE_DIR)/src -type f); do \
422 hash=$$$$($(MD5SUM) $$$$file | sed -e "s/ .*//"); \
423 hashfile=$$(PRIVATE_DIR)/hash/$$$$hash; \
424 echo $$$$file >> $$$$hashfile; \
425 done
426 $$(hide) touch $$@
427$(1): $(4)/hash-timestamp
428 @echo Combining NOTICE files: $$@
429 $$(hide) mkdir -p $$(dir $$@)
430 $$(hide) echo $$(PRIVATE_MESSAGE) > $$@
431 $$(hide) find $$(PRIVATE_DIR)/hash -type f | xargs cat | sort | \
432 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> $$@
433 $$(hide) echo >> $$@
434 $$(hide) echo >> $$@
435 $$(hide) echo >> $$@
436 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
437 echo "============================================================"\
438 >> $$@; \
439 echo "Notices for file(s):" >> $$@; \
440 cat $$$$hashfile | sort | \
441 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \
442 $$@; \
443 echo "------------------------------------------------------------"\
444 >> $$@; \
445 echo >> $$@; \
446 orig=$$$$(head -n 1 $$$$hashfile); \
447 cat $$$$orig >> $$@; \
448 echo >> $$@; \
449 echo >> $$@; \
450 echo >> $$@; \
451 done
452$(2): $(4)/hash-timestamp
453 @echo Combining NOTICE files: $$@
454 $$(hide) mkdir -p $$(dir $$@)
455 $$(hide) echo "<html><head>" > $$@
456 $$(hide) echo "<style type=\"text/css\">" >> $$@
457 $$(hide) echo "body { padding: 0; font-family: sans-serif; }" >> $$@
458 $$(hide) echo ".same-license { background-color: #eeeeee; border-top: 20px solid white; padding: 10px; }" >> $$@
459 $$(hide) echo ".label { font-weight: bold; }" >> $$@
460 $$(hide) echo ".file-list { margin-left: 1em; font-color: blue; }" >> $$@
461 $$(hide) echo "</style>" >> $$@
462 $$(hide) echo "</head><body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">" >> $$@
463 $$(hide) echo "<table cellpading=\"0\" cellspacing=\"0\" border=\"0\">" \
464 >> $$@
465 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
466 cat $$$$hashfile | sort | \
467 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: <a name=\"\1\"></a>:" >> \
468 $$@; \
469 echo "<tr><td class=\"same-license\">" >> $$@; \
470 echo "<div class=\"label\">Notices for file(s):</div>" >> $$@; \
471 echo "<div class=\"file-list\">" >> $$@; \
472 cat $$$$hashfile | sort | \
473 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1<br/>:" >> $$@; \
474 echo "</div><!-- file-list -->" >> $$@; \
475 echo >> $$@; \
476 orig=$$$$(head -n 1 $$$$hashfile); \
477 echo "<pre class=\"license-text\">" >> $$@; \
478 cat $$$$orig | sed -e "s/\&/\&amp;/g" | sed -e "s/</\&lt;/g" \
479 | sed -e "s/>/\&gt;/g" >> $$@; \
480 echo "</pre><!-- license-text -->" >> $$@; \
481 echo "</td></tr><!-- same-license -->" >> $$@; \
482 echo >> $$@; \
483 echo >> $$@; \
484 echo >> $$@; \
485 done
486 $$(hide) echo "</table>" >> $$@
487 $$(hide) echo "</body></html>" >> $$@
488notice_files: $(1) $(2)
489endef
490
491# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
492# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
493# the src subdirectory.
494
495target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
496target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
497target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
498tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
499tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
500
501kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
502
503$(eval $(call combine-notice-files, \
504 $(target_notice_file_txt), \
505 $(target_notice_file_html), \
506 "Notices for files contained in the filesystem images in this directory:", \
507 $(TARGET_OUT_NOTICE_FILES), \
508 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)))
509
510$(eval $(call combine-notice-files, \
511 $(tools_notice_file_txt), \
512 $(tools_notice_file_html), \
513 "Notices for files contained in the tools directory:", \
514 $(HOST_OUT_NOTICE_FILES), \
515 $(ALL_DEFAULT_INSTALLED_MODULES)))
516
517# Install the html file at /system/etc/NOTICE.html.gz.
518# This is not ideal, but this is very late in the game, after a lot of
519# the module processing has already been done -- in fact, we used the
520# fact that all that has been done to get the list of modules that we
521# need notice files for.
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700522$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700523 $(hide) $(MINIGZIP) -9 < $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800524installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
525$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
526 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700527
528# if we've been run my mm, mmm, etc, don't reinstall this every time
529ifeq ($(ONE_SHOT_MAKEFILE),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800530ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700531endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800532
533# The kernel isn't really a module, so to get its module file in there, we
534# make the target NOTICE files depend on this particular file too, which will
535# then be in the right directory for the find in combine-notice-files to work.
536$(kernel_notice_file): \
537 prebuilt/$(TARGET_PREBUILT_TAG)/kernel/LINUX_KERNEL_COPYING \
538 | $(ACP)
539 @echo Copying: $@
540 $(hide) mkdir -p $(dir $@)
541 $(hide) $(ACP) $< $@
542
543
Doug Zongker8678df42009-06-15 14:30:14 -0700544# -----------------------------------------------------------------
545# Build a keystore with the authorized keys in it, used to verify the
546# authenticity of downloaded OTA packages.
547#
548# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
549# before the rules that use that variable to build the image.
550ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
551$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Doug Zongker37c0e272009-06-15 15:36:16 -0700552$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Doug Zongker8678df42009-06-15 14:30:14 -0700553 $(hide) rm -f $@
554 $(hide) mkdir -p $(dir $@)
Doug Zongker37c0e272009-06-15 15:36:16 -0700555 $(hide) zip -qj $@ $<
Doug Zongker8678df42009-06-15 14:30:14 -0700556
557.PHONY: otacerts
558otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
559
560
The Android Open Source Project88b60792009-03-03 19:28:42 -0800561# #################################################################
562# Targets for user images
563# #################################################################
564
Ying Wang933abf12010-06-16 14:31:34 -0700565INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800566ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -0700567INTERNAL_USERIMAGES_USE_EXT := true
568INTERNAL_USERIMAGES_EXT_VARIANT := ext2
569else
570ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
571INTERNAL_USERIMAGES_USE_EXT := true
572INTERNAL_USERIMAGES_EXT_VARIANT := ext3
573else
574ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
575INTERNAL_USERIMAGES_USE_EXT := true
576INTERNAL_USERIMAGES_EXT_VARIANT := ext4
577endif
578endif
579endif
580
581ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
Colin Cross9dd4ba82010-08-03 14:43:15 -0700582INTERNAL_USERIMAGES_DEPS := $(MKEXT2USERIMG) $(MAKE_EXT4FS)
Ying Wang933abf12010-06-16 14:31:34 -0700583INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
584
Ying Wangc79f4da2010-06-16 14:58:50 -0700585# $(1): src directory
586# $(2): output file
Ying Wang026f1452010-09-27 17:49:03 -0700587# $(3): mount point
Ying Wangc79f4da2010-06-16 14:58:50 -0700588# $(4): ext variant (ext2, ext3, ext4)
Colin Crosse0a40212010-08-03 14:43:34 -0700589# $(5): size of the partition
Ying Wangc79f4da2010-06-16 14:58:50 -0700590define build-userimage-ext-target
591 @mkdir -p $(dir $(2))
Ying Wang933abf12010-06-16 14:31:34 -0700592 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$(PATH) \
Colin Crosse0a40212010-08-03 14:43:34 -0700593 $(MKEXT2USERIMG) $(1) $(2) $(4) $(3) $(5)
Ying Wangc79f4da2010-06-16 14:58:50 -0700594endef
The Android Open Source Project88b60792009-03-03 19:28:42 -0800595else
Colin Cross144b0282010-05-10 13:04:47 -0700596INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800597endif
598
599# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -0700600# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700601
602# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
Brian Swetland630b7d32009-08-07 18:09:44 -0700603ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY) $(BUILD_TINY_ANDROID)))
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700604
Doug Zongker4647f122009-07-02 09:00:54 -0700605INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
606
607recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
608recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
609recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
610recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
611recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
612recovery_resources_common := $(call include-path-for, recovery)/res
613recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
614recovery_resource_deps := $(shell find $(recovery_resources_common) \
615 $(recovery_resources_private) -type f)
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700616recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Doug Zongker4647f122009-07-02 09:00:54 -0700617
618ifeq ($(recovery_resources_private),)
619 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
620endif
621
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700622ifeq ($(recovery_fstab),)
623 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
624endif
625
Doug Zongker4647f122009-07-02 09:00:54 -0700626INTERNAL_RECOVERYIMAGE_ARGS := \
627 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
628 --kernel $(recovery_kernel) \
629 --ramdisk $(recovery_ramdisk)
630
631# Assumes this has already been stripped
632ifdef BOARD_KERNEL_CMDLINE
633 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
634endif
635ifdef BOARD_KERNEL_BASE
636 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
637endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700638BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
639ifdef BOARD_KERNEL_PAGESIZE
640 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
641endif
Doug Zongker4647f122009-07-02 09:00:54 -0700642
643# Keys authorized to sign OTA packages this build will accept. The
644# build always uses test-keys for this; release packaging tools will
645# substitute other keys for this one.
646OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
647
648# Generate a file containing the keys that will be read by the
649# recovery binary.
650RECOVERY_INSTALL_OTA_KEYS := \
651 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
652DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
653$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
654$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR)
655 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS)"
656 @rm -rf $@
657 @mkdir -p $(dir $@)
658 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@
659
660$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
661 $(INSTALLED_RAMDISK_TARGET) \
662 $(INSTALLED_BOOTIMAGE_TARGET) \
663 $(recovery_binary) \
664 $(recovery_initrc) $(recovery_kernel) \
665 $(INSTALLED_2NDBOOTLOADER_TARGET) \
666 $(recovery_build_prop) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700667 $(recovery_fstab) \
Doug Zongker4647f122009-07-02 09:00:54 -0700668 $(RECOVERY_INSTALL_OTA_KEYS)
669 @echo ----- Making recovery image ------
670 rm -rf $(TARGET_RECOVERY_OUT)
671 mkdir -p $(TARGET_RECOVERY_OUT)
672 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)
673 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc
674 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp
675 echo Copying baseline ramdisk...
676 cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Doug Zongkerb4c7d322010-07-01 15:30:11 -0700677 rm $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
Doug Zongker4647f122009-07-02 09:00:54 -0700678 echo Modifying ramdisk contents...
679 cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
680 cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
681 cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
682 $(foreach item,$(recovery_resources_private), \
683 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700684 $(foreach item,$(recovery_fstab), \
685 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Doug Zongker4647f122009-07-02 09:00:54 -0700686 cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
687 cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
688 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
689 $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
690 $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@
691 @echo ----- Made recovery image -------- $@
Doug Zongkered96e882009-08-26 09:37:07 -0700692 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
Doug Zongker4647f122009-07-02 09:00:54 -0700693
694else
695INSTALLED_RECOVERYIMAGE_TARGET :=
696endif
697
698.PHONY: recoveryimage
699recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET)
700
Dima Zavin11818982010-02-05 13:34:34 -0800701ifneq ($(BOARD_NAND_PAGE_SIZE),)
702mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
703else
704mkyaffs2_extra_flags :=
705endif
706
707
Doug Zongker4647f122009-07-02 09:00:54 -0700708# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -0700709# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800710#
Ying Wang02352372010-09-27 10:37:25 -0700711systemimage_intermediates := \
712 $(call intermediates-dir-for,PACKAGING,systemimage)
713BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
The Android Open Source Project88b60792009-03-03 19:28:42 -0800714
715INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
716 $(ALL_PREBUILT) \
717 $(ALL_COPIED_HEADERS) \
718 $(ALL_GENERATED_SOURCES) \
719 $(ALL_DEFAULT_INSTALLED_MODULES))
720
Colin Cross0a7b2c52010-05-07 02:23:59 -0700721ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
722## generate an ext image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800723# $(1): output file
724define build-systemimage-target
725 @echo "Target system fs image: $(1)"
Colin Crosse0a40212010-08-03 14:43:34 -0700726 $(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 -0800727endef
728
Colin Cross0a7b2c52010-05-07 02:23:59 -0700729else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800730
731## generate a yaffs2 image
732# $(1): output file
733define build-systemimage-target
734 @echo "Target system fs image: $(1)"
735 @mkdir -p $(dir $(1))
Dima Zavin11818982010-02-05 13:34:34 -0800736 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800737endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700738endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800739
Ying Wang02352372010-09-27 10:37:25 -0700740$(BUILT_SYSTEMIMAGE): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800741 $(call build-systemimage-target,$@)
742
The Android Open Source Project88b60792009-03-03 19:28:42 -0800743INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700744SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800745
Doug Zongker73ef8252009-07-23 15:12:53 -0700746# The system partition needs room for the recovery image as well. We
747# now store the recovery image as a binary patch using the boot image
748# as the source (since they are very similar). Generate the patch so
749# we can see how big it's going to be, and include that in the system
750# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700751ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700752intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
753RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
754$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
755 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700756 $(HOST_OUT_EXECUTABLES)/imgdiff \
757 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700758 @echo "Construct recovery from boot"
759 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700760 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700761endif
762
Doug Zongker73ef8252009-07-23 15:12:53 -0700763
764$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800765 @echo "Install system fs image: $@"
766 $(copy-file-to-target)
Doug Zongkered96e882009-08-26 09:37:07 -0700767 $(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 -0800768
769systemimage: $(INSTALLED_SYSTEMIMAGE)
770
771.PHONY: systemimage-nodeps snod
772systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -0700773 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800774 @echo "make $@: ignoring dependencies"
775 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
Doug Zongkered96e882009-08-26 09:37:07 -0700776 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800777
778#######
779## system tarball
780define build-systemtarball-target
781 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
782 $(MKTARBALL) $(FS_GET_STATS) \
783 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
784 $(INSTALLED_SYSTEMTARBALL_TARGET)
785endef
786
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700787ifndef SYSTEM_TARBALL_FORMAT
788 SYSTEM_TARBALL_FORMAT := bz2
789endif
790
The Android Open Source Project88b60792009-03-03 19:28:42 -0800791system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700792INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800793$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
794$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
795 $(build-systemtarball-target)
796
797.PHONY: systemtarball-nodeps
798systemtarball-nodeps: $(FS_GET_STATS) \
799 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
800 $(build-systemtarball-target)
801
802.PHONY: stnod
803stnod: systemtarball-nodeps
804
805
Bruce Beare52aac202010-06-04 15:24:49 -0700806#######
807## boot tarball
808define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -0700809 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -0700810 $(hide) mkdir -p $(PRODUCT_OUT)/boot
811 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
812 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
813 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
814 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
815 $(INSTALLED_BOOTTARBALL_TARGET)
816endef
817
818ifndef BOOT_TARBALL_FORMAT
819 BOOT_TARBALL_FORMAT := bz2
820endif
821
822boot_tar := $(PRODUCT_OUT)/boot.tar
823INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
824$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
825$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
826 $(build-boottarball-target)
827
828.PHONY: boottarball-nodeps btnod
829boottarball-nodeps btnod: $(FS_GET_STATS) \
830 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
831 $(build-boottarball-target)
832
833
The Android Open Source Project88b60792009-03-03 19:28:42 -0800834# -----------------------------------------------------------------
835# data partition image
836INTERNAL_USERDATAIMAGE_FILES := \
837 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
838
Colin Cross0a7b2c52010-05-07 02:23:59 -0700839ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800840## Generate an ext2 image
841define build-userdataimage-target
842 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
843 @mkdir -p $(TARGET_OUT_DATA)
Ying Wang026f1452010-09-27 17:49:03 -0700844 $(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 -0700845 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800846endef
847
Colin Cross0a7b2c52010-05-07 02:23:59 -0700848else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800849
850## Generate a yaffs2 image
851define build-userdataimage-target
852 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
853 @mkdir -p $(TARGET_OUT_DATA)
Dima Zavin11818982010-02-05 13:34:34 -0800854 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
Doug Zongkered96e882009-08-26 09:37:07 -0700855 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800856endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700857endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800858
Joe Onorato64d85d02009-04-09 19:31:12 -0700859BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
860
861# We just build this directly to the install location.
862INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -0700863$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800864 $(INTERNAL_USERDATAIMAGE_FILES)
865 $(build-userdataimage-target)
866
867.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -0700868userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800869 $(build-userdataimage-target)
870
871#######
872## data partition tarball
873define build-userdatatarball-target
874 $(call pretty,"Target userdata fs tarball: " \
875 "$(INSTALLED_USERDATATARBALL_TARGET)")
876 $(MKTARBALL) $(FS_GET_STATS) \
877 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
878 $(INSTALLED_USERDATATARBALL_TARGET)
879endef
880
881userdata_tar := $(PRODUCT_OUT)/userdata.tar
882INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
883$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
884$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
885 $(build-userdatatarball-target)
886
887.PHONY: userdatatarball-nodeps
888userdatatarball-nodeps: $(FS_GET_STATS)
889 $(build-userdatatarball-target)
890
891
The Android Open Source Project88b60792009-03-03 19:28:42 -0800892# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800893# bring in the installer image generation defines if necessary
894ifeq ($(TARGET_USE_DISKINSTALLER),true)
895include bootable/diskinstaller/config.mk
896endif
897
898# -----------------------------------------------------------------
Doug Zongker8678df42009-06-15 14:30:14 -0700899# host tools needed to build OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -0800900
Ying Wang06898662010-06-17 17:52:18 -0700901OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -0700902 $(HOST_OUT_EXECUTABLES)/mkbootfs \
903 $(HOST_OUT_EXECUTABLES)/mkbootimg \
904 $(HOST_OUT_EXECUTABLES)/fs_config \
905 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
906 $(HOST_OUT_EXECUTABLES)/zipalign \
907 $(HOST_OUT_EXECUTABLES)/aapt \
908 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -0700909 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -0700910 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -0700911 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
912 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
913 $(HOST_OUT_EXECUTABLES)/genext2fs \
914 $(HOST_OUT_EXECUTABLES)/tune2fs \
915 $(HOST_OUT_EXECUTABLES)/e2fsck
916
The Android Open Source Project88b60792009-03-03 19:28:42 -0800917
Ying Wang06898662010-06-17 17:52:18 -0700918.PHONY: otatools
919otatools: $(OTATOOLS)
920
The Android Open Source Project88b60792009-03-03 19:28:42 -0800921# -----------------------------------------------------------------
922# A zip of the directories that map to the target filesystem.
923# This zip can be used to create an OTA package or filesystem image
924# as a post-build step.
925#
926name := $(TARGET_PRODUCT)
927ifeq ($(TARGET_BUILD_TYPE),debug)
928 name := $(name)_debug
929endif
930name := $(name)-target_files-$(FILE_NAME_TAG)
931
932intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
933BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
934$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
935$(BUILT_TARGET_FILES_PACKAGE): \
936 zip_root := $(intermediates)/$(name)
937
938# $(1): Directory to copy
939# $(2): Location to copy it to
940# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
941define package_files-copy-root
942 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
943 mkdir -p $(2) && \
944 $(ACP) -rd $(strip $(1))/* $(2); \
945 fi
946endef
947
948built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -0700949 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -0700950 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -0700951 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
952 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -0800953$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
954
Doug Zongkerb1134dd2009-06-17 17:09:40 -0700955$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
956
Doug Zongkerc18736b2009-09-30 09:20:32 -0700957ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
958# default to common dir for device vendor
959$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
960else
961$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
962endif
963
The Android Open Source Project88b60792009-03-03 19:28:42 -0800964# Depending on the various images guarantees that the underlying
965# directories are up-to-date.
966$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800967 $(INSTALLED_BOOTIMAGE_TARGET) \
968 $(INSTALLED_RADIOIMAGE_TARGET) \
969 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -0700970 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800971 $(INSTALLED_USERDATAIMAGE_TARGET) \
972 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800973 $(built_ota_tools) \
974 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -0700975 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800976 | $(ACP)
977 @echo "Package target files: $@"
978 $(hide) rm -rf $@ $(zip_root)
979 $(hide) mkdir -p $(dir $@) $(zip_root)
980 @# Components of the recovery image
981 $(hide) mkdir -p $(zip_root)/RECOVERY
982 $(hide) $(call package_files-copy-root, \
983 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
984ifdef INSTALLED_KERNEL_TARGET
985 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
986endif
987ifdef INSTALLED_2NDBOOTLOADER_TARGET
988 $(hide) $(ACP) \
989 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
990endif
991ifdef BOARD_KERNEL_CMDLINE
992 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
993endif
Doug Zongker38a649f2009-06-17 09:07:09 -0700994ifdef BOARD_KERNEL_BASE
995 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
996endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700997ifdef BOARD_KERNEL_PAGESIZE
998 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
999endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001000 @# Components of the boot image
1001 $(hide) mkdir -p $(zip_root)/BOOT
1002 $(hide) $(call package_files-copy-root, \
1003 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1004ifdef INSTALLED_KERNEL_TARGET
1005 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1006endif
1007ifdef INSTALLED_2NDBOOTLOADER_TARGET
1008 $(hide) $(ACP) \
1009 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1010endif
1011ifdef BOARD_KERNEL_CMDLINE
1012 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1013endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001014ifdef BOARD_KERNEL_BASE
1015 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1016endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001017ifdef BOARD_KERNEL_PAGESIZE
1018 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1019endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001020 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1021 mkdir -p $(zip_root)/RADIO; \
1022 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001023 @# Contents of the system image
1024 $(hide) $(call package_files-copy-root, \
1025 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1026 @# Contents of the data image
1027 $(hide) $(call package_files-copy-root, \
1028 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1029 @# Extra contents of the OTA package
1030 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001031 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1032 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001033 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001034 @# build them.
1035 $(hide) mkdir -p $(zip_root)/META
1036 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker17c83cf2009-04-01 15:48:46 -07001037 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -07001038 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001039ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07001040 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001041endif
1042ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
1043 $(hide) echo "boot_size=$(call image-size-from-data-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1044endif
1045ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
1046 $(hide) echo "recovery_size=$(call image-size-from-data-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1047endif
1048ifdef BOARD_SYSTEMIMAGE_PARTITION_SIZE
1049 $(hide) echo "system_size=$(call image-size-from-data-size,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1050endif
1051ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
1052 $(hide) echo "userdata_size=$(call image-size-from-data-size,$(BOARD_USERDATAIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1053endif
Doug Zongker37974732010-09-16 17:44:38 -07001054 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001055ifdef mkyaffs2_extra_flags
Doug Zongker37974732010-09-16 17:44:38 -07001056 $(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001057endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001058 @# Zip everything up, preserving symlinks
1059 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongker283e2a12010-03-15 17:52:32 -07001060 @# Run fs_config on all the system files in the zip, and save the output
1061 $(hide) zipinfo -1 $@ | awk -F/ 'BEGIN { OFS="/" } /^SYSTEM\// {$$1 = "system"; print}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
1062 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/filesystem_config.txt)
1063
The Android Open Source Project88b60792009-03-03 19:28:42 -08001064
1065target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1066
Doug Zongker367910f2009-06-15 18:56:51 -07001067
1068ifneq ($(TARGET_SIMULATOR),true)
1069ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang910dcbe2010-03-24 23:22:33 -07001070ifneq ($(TARGET_DEVICE),generic)
Ying Wangfb0a3472010-08-25 16:06:06 -07001071ifneq ($(TARGET_NO_KERNEL),true)
Doug Zongker367910f2009-06-15 18:56:51 -07001072
Ying Wang09a00a62010-10-20 14:01:09 -07001073# -----------------------------------------------------------------
1074# OTA update package
1075
Doug Zongker8678df42009-06-15 14:30:14 -07001076name := $(TARGET_PRODUCT)
1077ifeq ($(TARGET_BUILD_TYPE),debug)
1078 name := $(name)_debug
1079endif
1080name := $(name)-ota-$(FILE_NAME_TAG)
1081
1082INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1083
1084$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1085
Ying Wang06898662010-06-17 17:52:18 -07001086$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001087 @echo "Package OTA: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001088 $(hide) ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker602a84e2009-06-18 08:35:12 -07001089 -p $(HOST_OUT) \
Doug Zongker8678df42009-06-15 14:30:14 -07001090 -k $(KEY_CERT_PAIR) \
1091 $(BUILT_TARGET_FILES_PACKAGE) $@
1092
1093.PHONY: otapackage
1094otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1095
Ying Wang09a00a62010-10-20 14:01:09 -07001096# -----------------------------------------------------------------
1097# The update package
1098
1099name := $(TARGET_PRODUCT)
1100ifeq ($(TARGET_BUILD_TYPE),debug)
1101 name := $(name)_debug
1102endif
1103name := $(name)-img-$(FILE_NAME_TAG)
1104
1105INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1106
1107ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1108# default to common dir for device vendor
1109$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_DEVICE_DIR)/../common
1110else
1111$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1112endif
1113
1114$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
1115 @echo "Package: $@"
1116 $(hide) ./build/tools/releasetools/img_from_target_files -v \
1117 -s $(extensions) \
1118 -p $(HOST_OUT) \
1119 $(BUILT_TARGET_FILES_PACKAGE) $@
1120
1121.PHONY: updatepackage
1122updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
1123
Ying Wangfb0a3472010-08-25 16:06:06 -07001124endif # TARGET_NO_KERNEL != true
Ying Wang910dcbe2010-03-24 23:22:33 -07001125endif # TARGET_DEVICE != generic
Doug Zongker367910f2009-06-15 18:56:51 -07001126endif # TARGET_PRODUCT != sdk
1127endif # TARGET_SIMULATOR != true
Doug Zongker8678df42009-06-15 14:30:14 -07001128
1129# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001130# installed file list
1131# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it
1132# gets the DexOpt one if we're doing that.
1133INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
1134$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE)
1135 @echo Installed file list: $@
1136 @mkdir -p $(dir $@)
1137 @rm -f $@
1138 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@
1139
1140.PHONY: installed-file-list
1141installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wanga37a2cb2010-04-28 12:59:51 -07001142ifneq ($(filter sdk,$(MAKECMDGOALS)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001143$(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE))
Ying Wanga37a2cb2010-04-28 12:59:51 -07001144endif
1145ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
Joe Onorato03fbe402009-04-13 08:31:16 -07001146$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wanga37a2cb2010-04-28 12:59:51 -07001147endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001148
1149# -----------------------------------------------------------------
1150# A zip of the tests that are built when running "make tests".
1151# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
1152# only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
1153#
1154name := $(TARGET_PRODUCT)
1155ifeq ($(TARGET_BUILD_TYPE),debug)
1156 name := $(name)_debug
1157endif
1158name := $(name)-tests-$(FILE_NAME_TAG)
1159
1160intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
1161BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
1162$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
1163$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
1164
1165# Depending on the images guarantees that the underlying
1166# directories are up-to-date.
1167$(BUILT_TESTS_ZIP_PACKAGE): \
1168 $(BUILT_SYSTEMIMAGE) \
1169 $(INSTALLED_USERDATAIMAGE_TARGET) \
1170 | $(ACP)
1171 @echo "Package test files: $@"
1172 $(hide) rm -rf $@ $(zip_root)
1173 $(hide) mkdir -p $(dir $@) $(zip_root)
1174 @# Some parts of the system image
1175 $(hide) $(call package_files-copy-root, \
1176 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin)
1177 $(hide) $(call package_files-copy-root, \
1178 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib)
1179 $(hide) $(call package_files-copy-root, \
1180 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \
1181 $(zip_root)/SYSTEM/framework)
1182 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM
1183 @# Contents of the data image
1184 $(hide) $(call package_files-copy-root, \
1185 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1186 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
1187
Ying Wang9c762552010-09-10 14:39:33 -07001188.PHONY: tests-zip-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001189tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
1190
Ying Wangdb2cb632010-09-14 16:07:56 -07001191# Target needed by tests build
1192.PHONY: tests-build-target
1193tests-build-target: $(BUILT_TESTS_ZIP_PACKAGE) \
1194 $(BUILT_USERDATAIMAGE_TARGET)
1195
1196ifneq (,$(filter $(MAKECMDGOALS),tests-build-target))
1197 $(call dist-for-goals, tests-build-target, \
1198 $(BUILT_TESTS_ZIP_PACKAGE) \
1199 $(BUILT_USERDATAIMAGE_TARGET))
Ying Wang9c762552010-09-10 14:39:33 -07001200endif
1201
The Android Open Source Project88b60792009-03-03 19:28:42 -08001202# -----------------------------------------------------------------
1203# A zip of the symbols directory. Keep the full paths to make it
1204# more obvious where these files came from.
1205#
1206name := $(TARGET_PRODUCT)
1207ifeq ($(TARGET_BUILD_TYPE),debug)
1208 name := $(name)_debug
1209endif
1210name := $(name)-symbols-$(FILE_NAME_TAG)
1211
1212SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1213$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1214 @echo "Package symbols: $@"
1215 $(hide) rm -rf $@
1216 $(hide) mkdir -p $(dir $@)
1217 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1218
1219# -----------------------------------------------------------------
1220# A zip of the Android Apps. Not keeping full path so that we don't
1221# include product names when distributing
1222#
1223name := $(TARGET_PRODUCT)
1224ifeq ($(TARGET_BUILD_TYPE),debug)
1225 name := $(name)_debug
1226endif
1227name := $(name)-apps-$(FILE_NAME_TAG)
1228
1229APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1230$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1231 @echo "Package apps: $@"
1232 $(hide) rm -rf $@
1233 $(hide) mkdir -p $(dir $@)
1234 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
1235
Guang Zhu0198d6e2010-04-23 11:54:37 -07001236
1237#------------------------------------------------------------------
1238# A zip of emma code coverage meta files. Generated for fully emma
1239# instrumented build.
1240#
1241EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
1242$(EMMA_META_ZIP): $(INSTALLED_SYSTEMIMAGE)
1243 @echo "Collecting Emma coverage meta files."
1244 $(hide) find $(TARGET_COMMON_OUT_ROOT) -name "coverage.em" | \
1245 zip -@ -q $@
1246
The Android Open Source Project88b60792009-03-03 19:28:42 -08001247endif # TARGET_SIMULATOR != true
1248
1249# -----------------------------------------------------------------
1250# dalvik something
1251.PHONY: dalvikfiles
1252dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1253
1254# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001255# The emulator package
1256
1257ifneq ($(TARGET_SIMULATOR),true)
1258
1259INTERNAL_EMULATOR_PACKAGE_FILES += \
1260 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
1261 prebuilt/android-arm/kernel/kernel-qemu \
1262 $(INSTALLED_RAMDISK_TARGET) \
1263 $(INSTALLED_SYSTEMIMAGE) \
1264 $(INSTALLED_USERDATAIMAGE_TARGET)
1265
1266name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1267
1268INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1269
1270$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1271 @echo "Package: $@"
1272 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1273
1274endif
1275
1276# -----------------------------------------------------------------
1277# The pdk package (Platform Development Kit)
1278
1279ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1280 include development/pdk/Pdk.mk
1281endif
1282
1283# -----------------------------------------------------------------
1284# The SDK
1285
1286ifneq ($(TARGET_SIMULATOR),true)
1287
1288# The SDK includes host-specific components, so it belongs under HOST_OUT.
1289sdk_dir := $(HOST_OUT)/sdk
1290
1291# Build a name that looks like:
1292#
1293# linux-x86 --> android-sdk_12345_linux-x86
1294# darwin-x86 --> android-sdk_12345_mac-x86
1295# windows-x86 --> android-sdk_12345_windows
1296#
1297sdk_name := android-sdk_$(FILE_NAME_TAG)
1298ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001299 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001300else
Joe Onorato03fbe402009-04-13 08:31:16 -07001301 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001302endif
1303ifneq ($(HOST_OS),windows)
Joe Onorato03fbe402009-04-13 08:31:16 -07001304 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001305endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001306sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001307
1308sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1309
1310ATREE_FILES :=
1311-include $(sdk_dep_file)
1312
1313# if we don't have a real list, then use "everything"
1314ifeq ($(strip $(ATREE_FILES)),)
1315ATREE_FILES := \
1316 $(ALL_PREBUILT) \
1317 $(ALL_COPIED_HEADERS) \
1318 $(ALL_GENERATED_SOURCES) \
1319 $(ALL_DEFAULT_INSTALLED_MODULES) \
1320 $(INSTALLED_RAMDISK_TARGET) \
1321 $(ALL_DOCS) \
1322 $(ALL_SDK_FILES)
1323endif
1324
1325atree_dir := development/build
1326
1327sdk_atree_files := \
1328 $(atree_dir)/sdk.exclude.atree \
1329 $(atree_dir)/sdk.atree \
Xavier Ducrohetffd50872010-09-27 15:51:32 -07001330 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree \
1331 sdk/build/tools.atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08001332
1333deps := \
1334 $(target_notice_file_txt) \
1335 $(tools_notice_file_txt) \
1336 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001337 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001338 $(INSTALLED_SYSTEMIMAGE) \
1339 $(INSTALLED_USERDATAIMAGE_TARGET) \
1340 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001341 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001342 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001343 $(ATREE_FILES) \
1344 $(atree_dir)/sdk.atree \
Xavier Ducrohetffd50872010-09-27 15:51:32 -07001345 sdk/build/tools.atree \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001346 $(HOST_OUT_EXECUTABLES)/atree \
1347 $(HOST_OUT_EXECUTABLES)/line_endings
1348
1349INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1350$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1351$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1352$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1353$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1354
1355# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1356#
1357#SDK_GNU_ERROR := true
1358
1359$(INTERNAL_SDK_TARGET): $(deps)
1360 @echo "Package SDK: $@"
1361 $(hide) rm -rf $(PRIVATE_DIR) $@
1362 $(hide) for f in $(target_gnu_MODULES); do \
1363 if [ -f $$f ]; then \
1364 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1365 including GNU target $$f >&2; \
1366 FAIL=$(SDK_GNU_ERROR); \
1367 fi; \
1368 done; \
1369 if [ $$FAIL ]; then exit 1; fi
1370 $(hide) ( \
1371 $(HOST_OUT_EXECUTABLES)/atree \
1372 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1373 -m $(PRIVATE_DEP_FILE) \
1374 -I . \
1375 -I $(PRODUCT_OUT) \
1376 -I $(HOST_OUT) \
1377 -I $(TARGET_COMMON_OUT_ROOT) \
1378 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
1379 -o $(PRIVATE_DIR) && \
1380 cp -f $(target_notice_file_txt) \
1381 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \
1382 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
1383 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Xavier Ducrohet1ae98802009-11-17 15:10:41 -08001384 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001385 chmod -R ug+rwX $(PRIVATE_DIR) && \
1386 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1387 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1388
Raphael3d224a02010-04-16 17:50:09 -07001389
1390# Is a Windows SDK requested? If so, we need some definitions from here
1391# in order to find the Linux SDK used to create the Windows one.
1392ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
1393LINUX_SDK_NAME := $(sdk_name)
1394LINUX_SDK_DIR := $(sdk_dir)
1395include $(TOPDIR)development/build/tools/windows_sdk.mk
1396endif
1397
The Android Open Source Project88b60792009-03-03 19:28:42 -08001398endif # !simulator
1399
1400# -----------------------------------------------------------------
1401# Findbugs
1402INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1403INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1404$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1405 @echo UnionBugs: $@
1406 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1407 > $@
1408$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1409 @echo ConvertXmlToText: $@
1410 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1411 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1412
1413# -----------------------------------------------------------------
1414# Findbugs
1415
1416# -----------------------------------------------------------------
1417# These are some additional build tasks that need to be run.
1418include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))