blob: f66710ce86323d6a4b581c33bd96e6f4243faaa9 [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
18# src:dest pair is the first one to match %:dest"
The Android Open Source Project88b60792009-03-03 19:28:42 -080019$(foreach cf,$(PRODUCT_COPY_FILES), \
Joe Onorato64d85d02009-04-09 19:31:12 -070020 $(eval _src := $(call word-colon,1,$(cf))) \
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080021 $(eval _dest := $(call word-colon,2,$(cf))) \
22 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
23 $(if $(filter $(_src):$(_dest),$(firstword $(filter %:$(_dest),$(PRODUCT_COPY_FILES)))), \
24 $(eval $(call copy-one-file,$(_src),$(_fulldest))),) \
25 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080026 )
27
28# -----------------------------------------------------------------
29# docs/index.html
30gen := $(OUT_DOCS)/index.html
31ALL_DOCS += $(gen)
32$(gen): frameworks/base/docs/docs-redirect-index.html
33 @mkdir -p $(dir $@)
34 @cp -f $< $@
35
36# -----------------------------------------------------------------
37# default.prop
38INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
39ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
40ADDITIONAL_DEFAULT_PROPERTIES := \
41 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
42
43$(INSTALLED_DEFAULT_PROP_TARGET):
44 @echo Target buildinfo: $@
45 @mkdir -p $(dir $@)
46 $(hide) echo "#" > $@; \
47 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
48 echo "#" >> $@;
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -070049 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
50 echo "$(line)" >> $@;)
The Android Open Source Project88b60792009-03-03 19:28:42 -080051
52# -----------------------------------------------------------------
53# build.prop
54INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
55ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
56ADDITIONAL_BUILD_PROPERTIES := \
57 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
58
59# A list of arbitrary tags describing the build configuration.
60# Force ":=" so we can use +=
61BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
62ifeq ($(TARGET_BUILD_TYPE),debug)
63 BUILD_VERSION_TAGS += debug
64endif
65# Apps are always signed with test keys, and may be re-signed in a post-build
66# step. If that happens, the "test-keys" tag will be removed by that step.
67BUILD_VERSION_TAGS += test-keys
The Android Open Source Project88b60792009-03-03 19:28:42 -080068BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
69
70# A human-readable string that descibes this build in detail.
71build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)
72$(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc)
73
74# The string used to uniquely identify this build; used by the OTA server.
75ifeq (,$(strip $(BUILD_FINGERPRINT)))
76 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE)/$(TARGET_BOOTLOADER_BOARD_NAME):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
77endif
78ifneq ($(words $(BUILD_FINGERPRINT)),1)
79 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
80endif
81
Sriram Raman7b641242009-03-24 22:40:59 -070082# Display parameters shown under Settings -> About Phone
83ifeq ($(TARGET_BUILD_VARIANT),user)
84 # User builds should show:
85 # release build number or branch.buld_number non-release builds
86
87 # Dev. branches should have DISPLAY_BUILD_NUMBER set
88 ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
89 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER)
90 else
91 BUILD_DISPLAY_ID := $(BUILD_ID)
92 endif
93else
94 # Non-user builds should show detailed build information
95 BUILD_DISPLAY_ID := $(build_desc)
96endif
97
Ying Wang77c882f2010-04-27 15:45:35 -070098# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
Ying Wang38d7f022010-07-21 14:58:42 -070099product_property_override_locale_language := $(strip \
100 $(patsubst ro.product.locale.language=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700101 $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
Ying Wang38d7f022010-07-21 14:58:42 -0700102product_property_overrides_locale_region := $(strip \
103 $(patsubst ro.product.locale.region=%,%,\
Ying Wang77c882f2010-04-27 15:45:35 -0700104 $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
105
The Android Open Source Project88b60792009-03-03 19:28:42 -0800106# Selects the first locale in the list given as the argument,
107# and splits it into language and region, which each may be
108# empty.
109define default-locale
110$(subst _, , $(firstword $(1)))
111endef
112
113# Selects the first locale in the list given as the argument
Ying Wang77c882f2010-04-27 15:45:35 -0700114# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
115# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800116define default-locale-language
Ying Wang38d7f022010-07-21 14:58:42 -0700117$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800118endef
119define default-locale-region
Ying Wang38d7f022010-07-21 14:58:42 -0700120$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800121endef
122
123BUILDINFO_SH := build/tools/buildinfo.sh
Chih-Wei Huang4e3c6682009-08-31 14:55:33 +0800124$(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 -0800125 @echo Target buildinfo: $@
126 @mkdir -p $(dir $@)
127 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
128 TARGET_DEVICE="$(TARGET_DEVICE)" \
129 PRODUCT_NAME="$(TARGET_PRODUCT)" \
130 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
131 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
132 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700133 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800134 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
135 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
136 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
137 BUILD_ID="$(BUILD_ID)" \
138 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
139 BUILD_NUMBER="$(BUILD_NUMBER)" \
140 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
141 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700142 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800143 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
144 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
145 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
146 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700147 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800148 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800149 bash $(BUILDINFO_SH) > $@
150 $(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \
151 cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \
152 fi
153 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
154 $(hide) echo >> $@; \
155 echo "#" >> $@; \
156 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
157 echo "#" >> $@; )
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700158 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
159 echo "$(line)" >> $@;)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800160
161build_desc :=
162
163# -----------------------------------------------------------------
164# sdk-build.prop
165#
166# There are certain things in build.prop that we don't want to
167# ship with the sdk; remove them.
168
169# This must be a list of entire property keys followed by
170# "=" characters, without any internal spaces.
171sdk_build_prop_remove := \
172 ro.build.user= \
173 ro.build.host= \
174 ro.product.brand= \
175 ro.product.manufacturer= \
176 ro.product.device=
177# TODO: Remove this soon-to-be obsolete property
178sdk_build_prop_remove += ro.build.product=
179INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
180$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
181 @echo SDK buildinfo: $@
182 @mkdir -p $(dir $@)
183 $(hide) grep -v "$(subst $(space),\|,$(strip \
184 $(sdk_build_prop_remove)))" $< > $@.tmp
185 $(hide) for x in $(sdk_build_prop_remove); do \
186 echo "$$x"generic >> $@.tmp; done
187 $(hide) mv $@.tmp $@
188
189# -----------------------------------------------------------------
190# package stats
191PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
192PACKAGES_TO_STAT := \
193 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
194 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
195$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
196 @echo Package stats: $@
197 @mkdir -p $(dir $@)
198 $(hide) rm -f $@
199 $(hide) build/tools/dump-package-stats $^ > $@
200
201.PHONY: package-stats
202package-stats: $(PACKAGE_STATS_FILE)
203
204# -----------------------------------------------------------------
205# Cert-to-package mapping. Used by the post-build signing tools.
206name := $(TARGET_PRODUCT)
207ifeq ($(TARGET_BUILD_TYPE),debug)
208 name := $(name)_debug
209endif
210name := $(name)-apkcerts-$(FILE_NAME_TAG)
211intermediates := \
212 $(call intermediates-dir-for,PACKAGING,apkcerts)
213APKCERTS_FILE := $(intermediates)/$(name).txt
214# Depending on the built packages isn't exactly right,
215# but it should guarantee that the apkcerts file is rebuilt
216# if any packages change which certs they're signed with.
217all_built_packages := $(foreach p,$(PACKAGES),$(ALL_MODULES.$(p).BUILT))
Ying Wangefb21682010-07-23 16:42:13 -0700218ifneq ($(TARGET_BUILD_APPS),)
219# We don't need to really build all the modules for apps_only build.
220$(APKCERTS_FILE):
221else
The Android Open Source Project88b60792009-03-03 19:28:42 -0800222$(APKCERTS_FILE): $(all_built_packages)
Ying Wangefb21682010-07-23 16:42:13 -0700223endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800224 @echo APK certs list: $@
225 @mkdir -p $(dir $@)
226 @rm -f $@
227 $(hide) $(foreach p,$(PACKAGES),\
Doug Zongkerf6a53aa2009-12-15 15:06:55 -0800228 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
229 echo 'name="$(p).apk" certificate="EXTERNAL" \
230 private_key=""' >> $@;,\
231 echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
232 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800233
234.PHONY: apkcerts-list
235apkcerts-list: $(APKCERTS_FILE)
236
Ying Wangefb21682010-07-23 16:42:13 -0700237$(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
238
The Android Open Source Project88b60792009-03-03 19:28:42 -0800239# -----------------------------------------------------------------
240# module info file
241ifdef CREATE_MODULE_INFO_FILE
242 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
243 $(info Generating $(MODULE_INFO_FILE)...)
244 $(shell rm -f $(MODULE_INFO_FILE))
245 $(foreach m,$(ALL_MODULES), \
246 $(shell echo "NAME=\"$(m)\"" \
247 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
248 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
249 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
250 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
251endif
252
Doug Zongker8678df42009-06-15 14:30:14 -0700253# -----------------------------------------------------------------
254
255# The test key is used to sign this package, and as the key required
256# for future OTA packages installed by this system. Actual product
257# deliverables will be re-signed by hand. We expect this file to
258# exist with the suffixes ".x509.pem" and ".pk8".
259DEFAULT_KEY_CERT_PAIR := $(SRC_TARGET_DIR)/product/security/testkey
260
261
The Android Open Source Project88b60792009-03-03 19:28:42 -0800262# Rules that need to be present for the simulator, even
263# if they don't do anything.
264.PHONY: systemimage
265systemimage:
266
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800267# -----------------------------------------------------------------
268
269.PHONY: event-log-tags
270
Joe Onoratob7510532010-07-14 10:22:54 -0700271# Produce an event logs tag file for everything we know about, in order
272# to properly allocate numbers. Then produce a file that's filtered
273# for what's going to be installed.
274
275all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
276
277# Include tags from all packages that we know about
278all_event_log_tags_src := \
279 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
280
281$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
282$(all_event_log_tags_file): $(all_event_log_tags_src)
283 $(hide) mkdir -p $(dir $@)
284 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
285
286
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800287event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800288
289# Include tags from all packages included in this product.
290event_log_tags_src := \
291 $(sort $(foreach m,\
292 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
293 $(call module-names-for-tag-list,user), \
294 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
295
296$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700297$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
298$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800299 $(hide) mkdir -p $(dir $@)
Joe Onoratob7510532010-07-14 10:22:54 -0700300 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800301
302event-log-tags: $(event_log_tags_file)
303
304ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
305
Joe Onoratob7510532010-07-14 10:22:54 -0700306
The Android Open Source Project88b60792009-03-03 19:28:42 -0800307ifneq ($(TARGET_SIMULATOR),true)
308
309# #################################################################
310# Targets for boot/OS images
311# #################################################################
312
313# -----------------------------------------------------------------
314# the ramdisk
315INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
316 $(ALL_PREBUILT) \
317 $(ALL_COPIED_HEADERS) \
318 $(ALL_GENERATED_SOURCES) \
319 $(ALL_DEFAULT_INSTALLED_MODULES))
320
Joe Onorato64d85d02009-04-09 19:31:12 -0700321BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
322
323# We just build this directly to the install location.
324INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700325$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800326 $(call pretty,"Target ram disk: $@")
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700327 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800328
329
330ifneq ($(strip $(TARGET_NO_KERNEL)),true)
331
332# -----------------------------------------------------------------
333# the boot image, which is a collection of other images.
334INTERNAL_BOOTIMAGE_ARGS := \
335 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
336 --kernel $(INSTALLED_KERNEL_TARGET) \
337 --ramdisk $(INSTALLED_RAMDISK_TARGET)
338
339INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
340
341BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
342ifdef BOARD_KERNEL_CMDLINE
343 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
344endif
345
Dima Zavin1e0847c2009-05-07 19:43:08 -0700346BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
347ifdef BOARD_KERNEL_BASE
348 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
349endif
350
Ying Wangffff0022010-08-23 12:56:25 -0700351BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
352ifdef BOARD_KERNEL_PAGESIZE
353 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
354endif
355
The Android Open Source Project88b60792009-03-03 19:28:42 -0800356INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
357
358ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
359tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
360INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
361INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
362$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
363 $(call pretty,"Target boot image: $@")
364 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
365
366else # TARGET_BOOTIMAGE_USE_EXT2 != true
367
368$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
369 $(call pretty,"Target boot image: $@")
370 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
Doug Zongkered96e882009-08-26 09:37:07 -0700371 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800372endif # TARGET_BOOTIMAGE_USE_EXT2
373
374else # TARGET_NO_KERNEL
375# HACK: The top-level targets depend on the bootimage. Not all targets
376# can produce a bootimage, though, and emulator targets need the ramdisk
377# instead. Fake it out by calling the ramdisk the bootimage.
378# TODO: make the emulator use bootimages, and make mkbootimg accept
379# kernel-less inputs.
380INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
381endif
382
383# -----------------------------------------------------------------
384# NOTICE files
385#
386# This needs to be before the systemimage rules, because it adds to
387# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
388# go into the systemimage.
389
390.PHONY: notice_files
391
392# Create the rule to combine the files into text and html forms
393# $(1) - Plain text output file
394# $(2) - HTML output file
395# $(3) - File title
396# $(4) - Directory to use. Notice files are all $(4)/src. Other
397# directories in there will be used for scratch
398# $(5) - Dependencies for the output files
399#
400# The algorithm here is that we go collect a hash for each of the notice
401# files and write the names of the files that match that hash. Then
402# to generate the real files, we go print out all of the files and their
403# hashes.
404#
405# These rules are fairly complex, so they depend on this makefile so if
406# it changes, they'll run again.
407#
408# TODO: We could clean this up so that we just record the locations of the
409# original notice files instead of making rules to copy them somwehere.
410# Then we could traverse that without quite as much bash drama.
411define combine-notice-files
412$(1) $(2): PRIVATE_MESSAGE := $(3)
413$(1) $(2) $(4)/hash-timestamp: PRIVATE_DIR := $(4)
414$(4)/hash-timestamp: $(5) $(BUILD_SYSTEM)/Makefile
415 @echo Finding NOTICE files: $$@
416 $$(hide) rm -rf $$@ $$(PRIVATE_DIR)/hash
417 $$(hide) mkdir -p $$(PRIVATE_DIR)/hash
418 $$(hide) for file in $$$$(find $$(PRIVATE_DIR)/src -type f); do \
419 hash=$$$$($(MD5SUM) $$$$file | sed -e "s/ .*//"); \
420 hashfile=$$(PRIVATE_DIR)/hash/$$$$hash; \
421 echo $$$$file >> $$$$hashfile; \
422 done
423 $$(hide) touch $$@
424$(1): $(4)/hash-timestamp
425 @echo Combining NOTICE files: $$@
426 $$(hide) mkdir -p $$(dir $$@)
427 $$(hide) echo $$(PRIVATE_MESSAGE) > $$@
428 $$(hide) find $$(PRIVATE_DIR)/hash -type f | xargs cat | sort | \
429 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> $$@
430 $$(hide) echo >> $$@
431 $$(hide) echo >> $$@
432 $$(hide) echo >> $$@
433 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
434 echo "============================================================"\
435 >> $$@; \
436 echo "Notices for file(s):" >> $$@; \
437 cat $$$$hashfile | sort | \
438 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \
439 $$@; \
440 echo "------------------------------------------------------------"\
441 >> $$@; \
442 echo >> $$@; \
443 orig=$$$$(head -n 1 $$$$hashfile); \
444 cat $$$$orig >> $$@; \
445 echo >> $$@; \
446 echo >> $$@; \
447 echo >> $$@; \
448 done
449$(2): $(4)/hash-timestamp
450 @echo Combining NOTICE files: $$@
451 $$(hide) mkdir -p $$(dir $$@)
452 $$(hide) echo "<html><head>" > $$@
453 $$(hide) echo "<style type=\"text/css\">" >> $$@
454 $$(hide) echo "body { padding: 0; font-family: sans-serif; }" >> $$@
455 $$(hide) echo ".same-license { background-color: #eeeeee; border-top: 20px solid white; padding: 10px; }" >> $$@
456 $$(hide) echo ".label { font-weight: bold; }" >> $$@
457 $$(hide) echo ".file-list { margin-left: 1em; font-color: blue; }" >> $$@
458 $$(hide) echo "</style>" >> $$@
459 $$(hide) echo "</head><body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">" >> $$@
460 $$(hide) echo "<table cellpading=\"0\" cellspacing=\"0\" border=\"0\">" \
461 >> $$@
462 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
463 cat $$$$hashfile | sort | \
464 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: <a name=\"\1\"></a>:" >> \
465 $$@; \
466 echo "<tr><td class=\"same-license\">" >> $$@; \
467 echo "<div class=\"label\">Notices for file(s):</div>" >> $$@; \
468 echo "<div class=\"file-list\">" >> $$@; \
469 cat $$$$hashfile | sort | \
470 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1<br/>:" >> $$@; \
471 echo "</div><!-- file-list -->" >> $$@; \
472 echo >> $$@; \
473 orig=$$$$(head -n 1 $$$$hashfile); \
474 echo "<pre class=\"license-text\">" >> $$@; \
475 cat $$$$orig | sed -e "s/\&/\&amp;/g" | sed -e "s/</\&lt;/g" \
476 | sed -e "s/>/\&gt;/g" >> $$@; \
477 echo "</pre><!-- license-text -->" >> $$@; \
478 echo "</td></tr><!-- same-license -->" >> $$@; \
479 echo >> $$@; \
480 echo >> $$@; \
481 echo >> $$@; \
482 done
483 $$(hide) echo "</table>" >> $$@
484 $$(hide) echo "</body></html>" >> $$@
485notice_files: $(1) $(2)
486endef
487
488# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
489# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
490# the src subdirectory.
491
492target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
493target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
494target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
495tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
496tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
497
498kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
499
500$(eval $(call combine-notice-files, \
501 $(target_notice_file_txt), \
502 $(target_notice_file_html), \
503 "Notices for files contained in the filesystem images in this directory:", \
504 $(TARGET_OUT_NOTICE_FILES), \
505 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)))
506
507$(eval $(call combine-notice-files, \
508 $(tools_notice_file_txt), \
509 $(tools_notice_file_html), \
510 "Notices for files contained in the tools directory:", \
511 $(HOST_OUT_NOTICE_FILES), \
512 $(ALL_DEFAULT_INSTALLED_MODULES)))
513
514# Install the html file at /system/etc/NOTICE.html.gz.
515# This is not ideal, but this is very late in the game, after a lot of
516# the module processing has already been done -- in fact, we used the
517# fact that all that has been done to get the list of modules that we
518# need notice files for.
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700519$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700520 $(hide) $(MINIGZIP) -9 < $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800521installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
522$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
523 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700524
525# if we've been run my mm, mmm, etc, don't reinstall this every time
526ifeq ($(ONE_SHOT_MAKEFILE),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800527ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700528endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800529
530# The kernel isn't really a module, so to get its module file in there, we
531# make the target NOTICE files depend on this particular file too, which will
532# then be in the right directory for the find in combine-notice-files to work.
533$(kernel_notice_file): \
534 prebuilt/$(TARGET_PREBUILT_TAG)/kernel/LINUX_KERNEL_COPYING \
535 | $(ACP)
536 @echo Copying: $@
537 $(hide) mkdir -p $(dir $@)
538 $(hide) $(ACP) $< $@
539
540
Doug Zongker8678df42009-06-15 14:30:14 -0700541# -----------------------------------------------------------------
542# Build a keystore with the authorized keys in it, used to verify the
543# authenticity of downloaded OTA packages.
544#
545# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
546# before the rules that use that variable to build the image.
547ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
548$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Doug Zongker37c0e272009-06-15 15:36:16 -0700549$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Doug Zongker8678df42009-06-15 14:30:14 -0700550 $(hide) rm -f $@
551 $(hide) mkdir -p $(dir $@)
Doug Zongker37c0e272009-06-15 15:36:16 -0700552 $(hide) zip -qj $@ $<
Doug Zongker8678df42009-06-15 14:30:14 -0700553
554.PHONY: otacerts
555otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
556
557
The Android Open Source Project88b60792009-03-03 19:28:42 -0800558# #################################################################
559# Targets for user images
560# #################################################################
561
Ying Wang933abf12010-06-16 14:31:34 -0700562INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800563ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -0700564INTERNAL_USERIMAGES_USE_EXT := true
565INTERNAL_USERIMAGES_EXT_VARIANT := ext2
566else
567ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
568INTERNAL_USERIMAGES_USE_EXT := true
569INTERNAL_USERIMAGES_EXT_VARIANT := ext3
570else
571ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
572INTERNAL_USERIMAGES_USE_EXT := true
573INTERNAL_USERIMAGES_EXT_VARIANT := ext4
574endif
575endif
576endif
577
578ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
Colin Cross9dd4ba82010-08-03 14:43:15 -0700579INTERNAL_USERIMAGES_DEPS := $(MKEXT2USERIMG) $(MAKE_EXT4FS)
Ying Wang933abf12010-06-16 14:31:34 -0700580INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
581
Ying Wangc79f4da2010-06-16 14:58:50 -0700582# $(1): src directory
583# $(2): output file
Colin Crosse0a40212010-08-03 14:43:34 -0700584# $(3): label
Ying Wangc79f4da2010-06-16 14:58:50 -0700585# $(4): ext variant (ext2, ext3, ext4)
Colin Crosse0a40212010-08-03 14:43:34 -0700586# $(5): size of the partition
Ying Wangc79f4da2010-06-16 14:58:50 -0700587define build-userimage-ext-target
588 @mkdir -p $(dir $(2))
Ying Wang933abf12010-06-16 14:31:34 -0700589 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$(PATH) \
Colin Crosse0a40212010-08-03 14:43:34 -0700590 $(MKEXT2USERIMG) $(1) $(2) $(4) $(3) $(5)
Ying Wangc79f4da2010-06-16 14:58:50 -0700591endef
The Android Open Source Project88b60792009-03-03 19:28:42 -0800592else
Colin Cross144b0282010-05-10 13:04:47 -0700593INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800594endif
595
596# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -0700597# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700598
599# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
Brian Swetland630b7d32009-08-07 18:09:44 -0700600ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY) $(BUILD_TINY_ANDROID)))
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700601
Doug Zongker4647f122009-07-02 09:00:54 -0700602INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
603
604recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
605recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
606recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
607recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
608recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
609recovery_resources_common := $(call include-path-for, recovery)/res
610recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
611recovery_resource_deps := $(shell find $(recovery_resources_common) \
612 $(recovery_resources_private) -type f)
613
614ifeq ($(recovery_resources_private),)
615 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
616endif
617
618INTERNAL_RECOVERYIMAGE_ARGS := \
619 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
620 --kernel $(recovery_kernel) \
621 --ramdisk $(recovery_ramdisk)
622
623# Assumes this has already been stripped
624ifdef BOARD_KERNEL_CMDLINE
625 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
626endif
627ifdef BOARD_KERNEL_BASE
628 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
629endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700630BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
631ifdef BOARD_KERNEL_PAGESIZE
632 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
633endif
Doug Zongker4647f122009-07-02 09:00:54 -0700634
635# Keys authorized to sign OTA packages this build will accept. The
636# build always uses test-keys for this; release packaging tools will
637# substitute other keys for this one.
638OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
639
640# Generate a file containing the keys that will be read by the
641# recovery binary.
642RECOVERY_INSTALL_OTA_KEYS := \
643 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
644DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
645$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
646$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR)
647 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS)"
648 @rm -rf $@
649 @mkdir -p $(dir $@)
650 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@
651
652$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
653 $(INSTALLED_RAMDISK_TARGET) \
654 $(INSTALLED_BOOTIMAGE_TARGET) \
655 $(recovery_binary) \
656 $(recovery_initrc) $(recovery_kernel) \
657 $(INSTALLED_2NDBOOTLOADER_TARGET) \
658 $(recovery_build_prop) $(recovery_resource_deps) \
659 $(RECOVERY_INSTALL_OTA_KEYS)
660 @echo ----- Making recovery image ------
661 rm -rf $(TARGET_RECOVERY_OUT)
662 mkdir -p $(TARGET_RECOVERY_OUT)
663 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)
664 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc
665 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp
666 echo Copying baseline ramdisk...
667 cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Doug Zongkerb4c7d322010-07-01 15:30:11 -0700668 rm $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
Doug Zongker4647f122009-07-02 09:00:54 -0700669 echo Modifying ramdisk contents...
670 cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
671 cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
672 cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
673 $(foreach item,$(recovery_resources_private), \
674 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
675 cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
676 cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
677 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
678 $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
679 $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@
680 @echo ----- Made recovery image -------- $@
Doug Zongkered96e882009-08-26 09:37:07 -0700681 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
Doug Zongker4647f122009-07-02 09:00:54 -0700682
683else
684INSTALLED_RECOVERYIMAGE_TARGET :=
685endif
686
687.PHONY: recoveryimage
688recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET)
689
Dima Zavin11818982010-02-05 13:34:34 -0800690ifneq ($(BOARD_NAND_PAGE_SIZE),)
691mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
692else
693mkyaffs2_extra_flags :=
694endif
695
696
Doug Zongker4647f122009-07-02 09:00:54 -0700697# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800698# system yaffs image
699#
700# First, the "unoptimized" image, which contains .apk/.jar files
701# that contain regular, unoptimized/unverified .dex entries.
702#
703systemimage_unopt_intermediates := \
704 $(call intermediates-dir-for,PACKAGING,systemimage_unopt)
705BUILT_SYSTEMIMAGE_UNOPT := $(systemimage_unopt_intermediates)/system.img
706
707INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
708 $(ALL_PREBUILT) \
709 $(ALL_COPIED_HEADERS) \
710 $(ALL_GENERATED_SOURCES) \
711 $(ALL_DEFAULT_INSTALLED_MODULES))
712
Colin Cross0a7b2c52010-05-07 02:23:59 -0700713ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
714## generate an ext image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800715# $(1): output file
716define build-systemimage-target
717 @echo "Target system fs image: $(1)"
Colin Crosse0a40212010-08-03 14:43:34 -0700718 $(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 -0800719endef
720
Colin Cross0a7b2c52010-05-07 02:23:59 -0700721else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800722
723## generate a yaffs2 image
724# $(1): output file
725define build-systemimage-target
726 @echo "Target system fs image: $(1)"
727 @mkdir -p $(dir $(1))
Dima Zavin11818982010-02-05 13:34:34 -0800728 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800729endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700730endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800731
Colin Cross144b0282010-05-10 13:04:47 -0700732$(BUILT_SYSTEMIMAGE_UNOPT): $(INTERNAL_SYSTEMIMAGE_FILES) \
733 $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800734 $(call build-systemimage-target,$@)
735
736# The installed image, which may be optimized or unoptimized.
737#
738INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
739
740ifdef WITH_DEXPREOPT
741 ifndef DISABLE_DEXPREOPT
742 with_dexpreopt := true
743 endif
744endif
745ifdef with_dexpreopt
746 # This file will set BUILT_SYSTEMIMAGE and SYSTEMIMAGE_SOURCE_DIR
747 include build/tools/dexpreopt/Config.mk
748else
749 BUILT_SYSTEMIMAGE := $(BUILT_SYSTEMIMAGE_UNOPT)
750 SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
751endif
752
Doug Zongker73ef8252009-07-23 15:12:53 -0700753# The system partition needs room for the recovery image as well. We
754# now store the recovery image as a binary patch using the boot image
755# as the source (since they are very similar). Generate the patch so
756# we can see how big it's going to be, and include that in the system
757# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700758ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700759intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
760RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
761$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
762 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700763 $(HOST_OUT_EXECUTABLES)/imgdiff \
764 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700765 @echo "Construct recovery from boot"
766 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700767 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700768endif
769
Doug Zongker73ef8252009-07-23 15:12:53 -0700770
771$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800772 @echo "Install system fs image: $@"
773 $(copy-file-to-target)
Doug Zongkered96e882009-08-26 09:37:07 -0700774 $(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 -0800775
776systemimage: $(INSTALLED_SYSTEMIMAGE)
777
778.PHONY: systemimage-nodeps snod
779systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -0700780 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800781 @echo "make $@: ignoring dependencies"
782 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
Doug Zongkered96e882009-08-26 09:37:07 -0700783 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800784
785#######
786## system tarball
787define build-systemtarball-target
788 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
789 $(MKTARBALL) $(FS_GET_STATS) \
790 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
791 $(INSTALLED_SYSTEMTARBALL_TARGET)
792endef
793
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700794ifndef SYSTEM_TARBALL_FORMAT
795 SYSTEM_TARBALL_FORMAT := bz2
796endif
797
The Android Open Source Project88b60792009-03-03 19:28:42 -0800798system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700799INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800800$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
801$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
802 $(build-systemtarball-target)
803
804.PHONY: systemtarball-nodeps
805systemtarball-nodeps: $(FS_GET_STATS) \
806 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
807 $(build-systemtarball-target)
808
809.PHONY: stnod
810stnod: systemtarball-nodeps
811
812
Bruce Beare52aac202010-06-04 15:24:49 -0700813#######
814## boot tarball
815define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -0700816 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -0700817 $(hide) mkdir -p $(PRODUCT_OUT)/boot
818 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
819 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
820 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
821 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
822 $(INSTALLED_BOOTTARBALL_TARGET)
823endef
824
825ifndef BOOT_TARBALL_FORMAT
826 BOOT_TARBALL_FORMAT := bz2
827endif
828
829boot_tar := $(PRODUCT_OUT)/boot.tar
830INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
831$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
832$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
833 $(build-boottarball-target)
834
835.PHONY: boottarball-nodeps btnod
836boottarball-nodeps btnod: $(FS_GET_STATS) \
837 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
838 $(build-boottarball-target)
839
840
The Android Open Source Project88b60792009-03-03 19:28:42 -0800841# -----------------------------------------------------------------
842# data partition image
843INTERNAL_USERDATAIMAGE_FILES := \
844 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
845
Colin Cross0a7b2c52010-05-07 02:23:59 -0700846ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800847## Generate an ext2 image
848define build-userdataimage-target
849 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
850 @mkdir -p $(TARGET_OUT_DATA)
Colin Crosse0a40212010-08-03 14:43:34 -0700851 $(call build-userimage-ext-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),userdata,$(INTERNAL_USERIMAGES_EXT_VARIANT),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Doug Zongkered96e882009-08-26 09:37:07 -0700852 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800853endef
854
Colin Cross0a7b2c52010-05-07 02:23:59 -0700855else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800856
857## Generate a yaffs2 image
858define build-userdataimage-target
859 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
860 @mkdir -p $(TARGET_OUT_DATA)
Dima Zavin11818982010-02-05 13:34:34 -0800861 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
Doug Zongkered96e882009-08-26 09:37:07 -0700862 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800863endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700864endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800865
Joe Onorato64d85d02009-04-09 19:31:12 -0700866BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
867
868# We just build this directly to the install location.
869INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -0700870$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800871 $(INTERNAL_USERDATAIMAGE_FILES)
872 $(build-userdataimage-target)
873
874.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -0700875userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800876 $(build-userdataimage-target)
877
878#######
879## data partition tarball
880define build-userdatatarball-target
881 $(call pretty,"Target userdata fs tarball: " \
882 "$(INSTALLED_USERDATATARBALL_TARGET)")
883 $(MKTARBALL) $(FS_GET_STATS) \
884 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
885 $(INSTALLED_USERDATATARBALL_TARGET)
886endef
887
888userdata_tar := $(PRODUCT_OUT)/userdata.tar
889INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
890$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
891$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
892 $(build-userdatatarball-target)
893
894.PHONY: userdatatarball-nodeps
895userdatatarball-nodeps: $(FS_GET_STATS)
896 $(build-userdatatarball-target)
897
898
The Android Open Source Project88b60792009-03-03 19:28:42 -0800899# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800900# bring in the installer image generation defines if necessary
901ifeq ($(TARGET_USE_DISKINSTALLER),true)
902include bootable/diskinstaller/config.mk
903endif
904
905# -----------------------------------------------------------------
Doug Zongker8678df42009-06-15 14:30:14 -0700906# host tools needed to build OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -0800907
Ying Wang06898662010-06-17 17:52:18 -0700908OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -0700909 $(HOST_OUT_EXECUTABLES)/mkbootfs \
910 $(HOST_OUT_EXECUTABLES)/mkbootimg \
911 $(HOST_OUT_EXECUTABLES)/fs_config \
912 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
913 $(HOST_OUT_EXECUTABLES)/zipalign \
914 $(HOST_OUT_EXECUTABLES)/aapt \
915 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -0700916 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -0700917 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -0700918 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
919 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
920 $(HOST_OUT_EXECUTABLES)/genext2fs \
921 $(HOST_OUT_EXECUTABLES)/tune2fs \
922 $(HOST_OUT_EXECUTABLES)/e2fsck
923
The Android Open Source Project88b60792009-03-03 19:28:42 -0800924
Ying Wang06898662010-06-17 17:52:18 -0700925.PHONY: otatools
926otatools: $(OTATOOLS)
927
The Android Open Source Project88b60792009-03-03 19:28:42 -0800928# -----------------------------------------------------------------
929# A zip of the directories that map to the target filesystem.
930# This zip can be used to create an OTA package or filesystem image
931# as a post-build step.
932#
933name := $(TARGET_PRODUCT)
934ifeq ($(TARGET_BUILD_TYPE),debug)
935 name := $(name)_debug
936endif
937name := $(name)-target_files-$(FILE_NAME_TAG)
938
939intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
940BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
941$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
942$(BUILT_TARGET_FILES_PACKAGE): \
943 zip_root := $(intermediates)/$(name)
944
945# $(1): Directory to copy
946# $(2): Location to copy it to
947# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
948define package_files-copy-root
949 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
950 mkdir -p $(2) && \
951 $(ACP) -rd $(strip $(1))/* $(2); \
952 fi
953endef
954
955built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -0700956 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -0700957 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -0700958 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
959 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -0800960$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
961
Doug Zongkerb1134dd2009-06-17 17:09:40 -0700962$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
963
Doug Zongkerc18736b2009-09-30 09:20:32 -0700964ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
965# default to common dir for device vendor
966$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
967else
968$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
969endif
970
The Android Open Source Project88b60792009-03-03 19:28:42 -0800971# Depending on the various images guarantees that the underlying
972# directories are up-to-date.
973$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800974 $(INSTALLED_BOOTIMAGE_TARGET) \
975 $(INSTALLED_RADIOIMAGE_TARGET) \
976 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -0700977 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800978 $(INSTALLED_USERDATAIMAGE_TARGET) \
979 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800980 $(built_ota_tools) \
981 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -0700982 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800983 | $(ACP)
984 @echo "Package target files: $@"
985 $(hide) rm -rf $@ $(zip_root)
986 $(hide) mkdir -p $(dir $@) $(zip_root)
987 @# Components of the recovery image
988 $(hide) mkdir -p $(zip_root)/RECOVERY
989 $(hide) $(call package_files-copy-root, \
990 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
991ifdef INSTALLED_KERNEL_TARGET
992 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
993endif
994ifdef INSTALLED_2NDBOOTLOADER_TARGET
995 $(hide) $(ACP) \
996 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
997endif
998ifdef BOARD_KERNEL_CMDLINE
999 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
1000endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001001ifdef BOARD_KERNEL_BASE
1002 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
1003endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001004ifdef BOARD_KERNEL_PAGESIZE
1005 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
1006endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001007 @# Components of the boot image
1008 $(hide) mkdir -p $(zip_root)/BOOT
1009 $(hide) $(call package_files-copy-root, \
1010 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1011ifdef INSTALLED_KERNEL_TARGET
1012 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1013endif
1014ifdef INSTALLED_2NDBOOTLOADER_TARGET
1015 $(hide) $(ACP) \
1016 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1017endif
1018ifdef BOARD_KERNEL_CMDLINE
1019 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1020endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001021ifdef BOARD_KERNEL_BASE
1022 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1023endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001024ifdef BOARD_KERNEL_PAGESIZE
1025 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1026endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001027 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1028 mkdir -p $(zip_root)/RADIO; \
1029 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001030 @# Contents of the system image
1031 $(hide) $(call package_files-copy-root, \
1032 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1033 @# Contents of the data image
1034 $(hide) $(call package_files-copy-root, \
1035 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1036 @# Extra contents of the OTA package
1037 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001038 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1039 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001040 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001041 @# build them.
1042 $(hide) mkdir -p $(zip_root)/META
1043 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker17c83cf2009-04-01 15:48:46 -07001044 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongkerb1134dd2009-06-17 17:09:40 -07001045 $(hide) echo "$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/recovery-api-version.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001046ifdef BOARD_FLASH_BLOCK_SIZE
1047 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" > $(zip_root)/META/misc_info.txt
1048endif
1049ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
1050 $(hide) echo "boot_size=$(call image-size-from-data-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1051endif
1052ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
1053 $(hide) echo "recovery_size=$(call image-size-from-data-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1054endif
1055ifdef BOARD_SYSTEMIMAGE_PARTITION_SIZE
1056 $(hide) echo "system_size=$(call image-size-from-data-size,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1057endif
1058ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
1059 $(hide) echo "userdata_size=$(call image-size-from-data-size,$(BOARD_USERDATAIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1060endif
1061ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
1062 $(hide) echo "fs_type=ext4" >> $(zip_root)/META/misc_info.txt
1063 $(hide) echo "partition_type=EMMC" >> $(zip_root)/META/misc_info.txt
1064 @# TODO: where is the right place to get this path from? BoardConfig.mk?
1065 $(hide) echo "partition_path=/dev/block/platform/sdhci-tegra.3/by-name/" >> $(zip_root)/META/misc_info.txt
1066else
1067 $(hide) echo "fs_type=yaffs2" >> $(zip_root)/META/misc_info.txt
1068 $(hide) echo "partition_type=MTD" >> $(zip_root)/META/misc_info.txt
1069endif
Doug Zongkerc18736b2009-09-30 09:20:32 -07001070 $(hide) echo "$(tool_extensions)" > $(zip_root)/META/tool-extensions.txt
Ying Wangd421f572010-08-25 20:39:41 -07001071ifdef mkyaffs2_extra_flags
1072 $(hide) echo "$(mkyaffs2_extra_flags)" > $(zip_root)/META/mkyaffs2-extra-flags.txt
1073endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001074 @# Zip everything up, preserving symlinks
1075 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongker283e2a12010-03-15 17:52:32 -07001076 @# Run fs_config on all the system files in the zip, and save the output
1077 $(hide) zipinfo -1 $@ | awk -F/ 'BEGIN { OFS="/" } /^SYSTEM\// {$$1 = "system"; print}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
1078 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/filesystem_config.txt)
1079
The Android Open Source Project88b60792009-03-03 19:28:42 -08001080
1081target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1082
1083# -----------------------------------------------------------------
Doug Zongker8678df42009-06-15 14:30:14 -07001084# OTA update package
Doug Zongker367910f2009-06-15 18:56:51 -07001085
1086ifneq ($(TARGET_SIMULATOR),true)
1087ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang910dcbe2010-03-24 23:22:33 -07001088ifneq ($(TARGET_DEVICE),generic)
Ying Wangfb0a3472010-08-25 16:06:06 -07001089ifneq ($(TARGET_NO_KERNEL),true)
Doug Zongker367910f2009-06-15 18:56:51 -07001090
Doug Zongker8678df42009-06-15 14:30:14 -07001091name := $(TARGET_PRODUCT)
1092ifeq ($(TARGET_BUILD_TYPE),debug)
1093 name := $(name)_debug
1094endif
1095name := $(name)-ota-$(FILE_NAME_TAG)
1096
1097INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1098
1099$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1100
Ying Wang06898662010-06-17 17:52:18 -07001101$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001102 @echo "Package OTA: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001103 $(hide) ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker602a84e2009-06-18 08:35:12 -07001104 -p $(HOST_OUT) \
Doug Zongker8678df42009-06-15 14:30:14 -07001105 -k $(KEY_CERT_PAIR) \
1106 $(BUILT_TARGET_FILES_PACKAGE) $@
1107
1108.PHONY: otapackage
1109otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1110
Ying Wangfb0a3472010-08-25 16:06:06 -07001111endif # TARGET_NO_KERNEL != true
Ying Wang910dcbe2010-03-24 23:22:33 -07001112endif # TARGET_DEVICE != generic
Doug Zongker367910f2009-06-15 18:56:51 -07001113endif # TARGET_PRODUCT != sdk
1114endif # TARGET_SIMULATOR != true
Doug Zongker8678df42009-06-15 14:30:14 -07001115
1116# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001117# installed file list
1118# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it
1119# gets the DexOpt one if we're doing that.
1120INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
1121$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE)
1122 @echo Installed file list: $@
1123 @mkdir -p $(dir $@)
1124 @rm -f $@
1125 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@
1126
1127.PHONY: installed-file-list
1128installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wanga37a2cb2010-04-28 12:59:51 -07001129ifneq ($(filter sdk,$(MAKECMDGOALS)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001130$(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE))
Ying Wanga37a2cb2010-04-28 12:59:51 -07001131endif
1132ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
Joe Onorato03fbe402009-04-13 08:31:16 -07001133$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wanga37a2cb2010-04-28 12:59:51 -07001134endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001135
1136# -----------------------------------------------------------------
1137# A zip of the tests that are built when running "make tests".
1138# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
1139# only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
1140#
1141name := $(TARGET_PRODUCT)
1142ifeq ($(TARGET_BUILD_TYPE),debug)
1143 name := $(name)_debug
1144endif
1145name := $(name)-tests-$(FILE_NAME_TAG)
1146
1147intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
1148BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
1149$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
1150$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
1151
1152# Depending on the images guarantees that the underlying
1153# directories are up-to-date.
1154$(BUILT_TESTS_ZIP_PACKAGE): \
1155 $(BUILT_SYSTEMIMAGE) \
1156 $(INSTALLED_USERDATAIMAGE_TARGET) \
1157 | $(ACP)
1158 @echo "Package test files: $@"
1159 $(hide) rm -rf $@ $(zip_root)
1160 $(hide) mkdir -p $(dir $@) $(zip_root)
1161 @# Some parts of the system image
1162 $(hide) $(call package_files-copy-root, \
1163 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin)
1164 $(hide) $(call package_files-copy-root, \
1165 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib)
1166 $(hide) $(call package_files-copy-root, \
1167 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \
1168 $(zip_root)/SYSTEM/framework)
1169 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM
1170 @# Contents of the data image
1171 $(hide) $(call package_files-copy-root, \
1172 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1173 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
1174
1175tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
1176
1177# -----------------------------------------------------------------
1178# A zip of the symbols directory. Keep the full paths to make it
1179# more obvious where these files came from.
1180#
1181name := $(TARGET_PRODUCT)
1182ifeq ($(TARGET_BUILD_TYPE),debug)
1183 name := $(name)_debug
1184endif
1185name := $(name)-symbols-$(FILE_NAME_TAG)
1186
1187SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1188$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1189 @echo "Package symbols: $@"
1190 $(hide) rm -rf $@
1191 $(hide) mkdir -p $(dir $@)
1192 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1193
1194# -----------------------------------------------------------------
1195# A zip of the Android Apps. Not keeping full path so that we don't
1196# include product names when distributing
1197#
1198name := $(TARGET_PRODUCT)
1199ifeq ($(TARGET_BUILD_TYPE),debug)
1200 name := $(name)_debug
1201endif
1202name := $(name)-apps-$(FILE_NAME_TAG)
1203
1204APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1205$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1206 @echo "Package apps: $@"
1207 $(hide) rm -rf $@
1208 $(hide) mkdir -p $(dir $@)
1209 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
1210
Guang Zhu0198d6e2010-04-23 11:54:37 -07001211
1212#------------------------------------------------------------------
1213# A zip of emma code coverage meta files. Generated for fully emma
1214# instrumented build.
1215#
1216EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
1217$(EMMA_META_ZIP): $(INSTALLED_SYSTEMIMAGE)
1218 @echo "Collecting Emma coverage meta files."
1219 $(hide) find $(TARGET_COMMON_OUT_ROOT) -name "coverage.em" | \
1220 zip -@ -q $@
1221
The Android Open Source Project88b60792009-03-03 19:28:42 -08001222endif # TARGET_SIMULATOR != true
1223
1224# -----------------------------------------------------------------
1225# dalvik something
1226.PHONY: dalvikfiles
1227dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1228
1229# -----------------------------------------------------------------
1230# The update package
1231
Doug Zongker367910f2009-06-15 18:56:51 -07001232ifneq ($(TARGET_SIMULATOR),true)
1233ifneq ($(TARGET_PRODUCT),sdk)
1234
The Android Open Source Project88b60792009-03-03 19:28:42 -08001235name := $(TARGET_PRODUCT)
1236ifeq ($(TARGET_BUILD_TYPE),debug)
1237 name := $(name)_debug
1238endif
1239name := $(name)-img-$(FILE_NAME_TAG)
1240
1241INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1242
Doug Zongker659fc552009-06-23 09:46:33 -07001243ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1244# default to common dir for device vendor
1245$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_DEVICE_DIR)/../common
1246else
1247$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1248endif
1249
Ying Wang06898662010-06-17 17:52:18 -07001250$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001251 @echo "Package: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001252 $(hide) ./build/tools/releasetools/img_from_target_files -v \
Doug Zongker659fc552009-06-23 09:46:33 -07001253 -s $(extensions) \
Doug Zongker602a84e2009-06-18 08:35:12 -07001254 -p $(HOST_OUT) \
Ying Wang933abf12010-06-16 14:31:34 -07001255 $(addprefix --fs_type ,$(INTERNAL_USERIMAGES_EXT_VARIANT)) \
Doug Zongker8678df42009-06-15 14:30:14 -07001256 $(BUILT_TARGET_FILES_PACKAGE) $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001257
Doug Zongker8678df42009-06-15 14:30:14 -07001258.PHONY: updatepackage
1259updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001260
Doug Zongker367910f2009-06-15 18:56:51 -07001261endif # TARGET_PRODUCT != sdk
1262endif # TARGET_SIMULATOR != true
1263
The Android Open Source Project88b60792009-03-03 19:28:42 -08001264# -----------------------------------------------------------------
1265# The emulator package
1266
1267ifneq ($(TARGET_SIMULATOR),true)
1268
1269INTERNAL_EMULATOR_PACKAGE_FILES += \
1270 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
1271 prebuilt/android-arm/kernel/kernel-qemu \
1272 $(INSTALLED_RAMDISK_TARGET) \
1273 $(INSTALLED_SYSTEMIMAGE) \
1274 $(INSTALLED_USERDATAIMAGE_TARGET)
1275
1276name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1277
1278INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1279
1280$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1281 @echo "Package: $@"
1282 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1283
1284endif
1285
1286# -----------------------------------------------------------------
1287# The pdk package (Platform Development Kit)
1288
1289ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1290 include development/pdk/Pdk.mk
1291endif
1292
1293# -----------------------------------------------------------------
1294# The SDK
1295
1296ifneq ($(TARGET_SIMULATOR),true)
1297
1298# The SDK includes host-specific components, so it belongs under HOST_OUT.
1299sdk_dir := $(HOST_OUT)/sdk
1300
1301# Build a name that looks like:
1302#
1303# linux-x86 --> android-sdk_12345_linux-x86
1304# darwin-x86 --> android-sdk_12345_mac-x86
1305# windows-x86 --> android-sdk_12345_windows
1306#
1307sdk_name := android-sdk_$(FILE_NAME_TAG)
1308ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001309 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001310else
Joe Onorato03fbe402009-04-13 08:31:16 -07001311 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001312endif
1313ifneq ($(HOST_OS),windows)
Joe Onorato03fbe402009-04-13 08:31:16 -07001314 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001315endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001316sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001317
1318sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1319
1320ATREE_FILES :=
1321-include $(sdk_dep_file)
1322
1323# if we don't have a real list, then use "everything"
1324ifeq ($(strip $(ATREE_FILES)),)
1325ATREE_FILES := \
1326 $(ALL_PREBUILT) \
1327 $(ALL_COPIED_HEADERS) \
1328 $(ALL_GENERATED_SOURCES) \
1329 $(ALL_DEFAULT_INSTALLED_MODULES) \
1330 $(INSTALLED_RAMDISK_TARGET) \
1331 $(ALL_DOCS) \
1332 $(ALL_SDK_FILES)
1333endif
1334
1335atree_dir := development/build
1336
1337sdk_atree_files := \
1338 $(atree_dir)/sdk.exclude.atree \
1339 $(atree_dir)/sdk.atree \
1340 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree
1341
1342deps := \
1343 $(target_notice_file_txt) \
1344 $(tools_notice_file_txt) \
1345 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001346 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001347 $(INSTALLED_SYSTEMIMAGE) \
1348 $(INSTALLED_USERDATAIMAGE_TARGET) \
1349 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001350 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001351 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001352 $(ATREE_FILES) \
1353 $(atree_dir)/sdk.atree \
1354 $(HOST_OUT_EXECUTABLES)/atree \
1355 $(HOST_OUT_EXECUTABLES)/line_endings
1356
1357INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1358$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1359$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1360$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1361$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1362
1363# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1364#
1365#SDK_GNU_ERROR := true
1366
1367$(INTERNAL_SDK_TARGET): $(deps)
1368 @echo "Package SDK: $@"
1369 $(hide) rm -rf $(PRIVATE_DIR) $@
1370 $(hide) for f in $(target_gnu_MODULES); do \
1371 if [ -f $$f ]; then \
1372 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1373 including GNU target $$f >&2; \
1374 FAIL=$(SDK_GNU_ERROR); \
1375 fi; \
1376 done; \
1377 if [ $$FAIL ]; then exit 1; fi
1378 $(hide) ( \
1379 $(HOST_OUT_EXECUTABLES)/atree \
1380 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1381 -m $(PRIVATE_DEP_FILE) \
1382 -I . \
1383 -I $(PRODUCT_OUT) \
1384 -I $(HOST_OUT) \
1385 -I $(TARGET_COMMON_OUT_ROOT) \
1386 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
1387 -o $(PRIVATE_DIR) && \
1388 cp -f $(target_notice_file_txt) \
1389 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \
1390 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
1391 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Xavier Ducrohet1ae98802009-11-17 15:10:41 -08001392 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001393 chmod -R ug+rwX $(PRIVATE_DIR) && \
1394 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1395 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1396
Raphael3d224a02010-04-16 17:50:09 -07001397
1398# Is a Windows SDK requested? If so, we need some definitions from here
1399# in order to find the Linux SDK used to create the Windows one.
1400ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
1401LINUX_SDK_NAME := $(sdk_name)
1402LINUX_SDK_DIR := $(sdk_dir)
1403include $(TOPDIR)development/build/tools/windows_sdk.mk
1404endif
1405
The Android Open Source Project88b60792009-03-03 19:28:42 -08001406endif # !simulator
1407
1408# -----------------------------------------------------------------
1409# Findbugs
1410INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1411INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1412$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1413 @echo UnionBugs: $@
1414 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1415 > $@
1416$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1417 @echo ConvertXmlToText: $@
1418 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1419 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1420
1421# -----------------------------------------------------------------
1422# Findbugs
1423
1424# -----------------------------------------------------------------
1425# These are some additional build tasks that need to be run.
1426include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))