blob: 4d151c5e742193e00e436edba40a86bc49aa32ab [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 Huang75947ef2010-11-03 18:33:46 +0800127$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
The Android Open Source Project88b60792009-03-03 19:28:42 -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)" \
Joe Onorato25939e22010-11-09 08:53:01 -0800152 TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800153 bash $(BUILDINFO_SH) > $@
154 $(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \
155 cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \
156 fi
157 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
158 $(hide) echo >> $@; \
159 echo "#" >> $@; \
160 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
161 echo "#" >> $@; )
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700162 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
163 echo "$(line)" >> $@;)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800164
165build_desc :=
166
167# -----------------------------------------------------------------
168# sdk-build.prop
169#
170# There are certain things in build.prop that we don't want to
171# ship with the sdk; remove them.
172
173# This must be a list of entire property keys followed by
174# "=" characters, without any internal spaces.
175sdk_build_prop_remove := \
176 ro.build.user= \
177 ro.build.host= \
178 ro.product.brand= \
179 ro.product.manufacturer= \
180 ro.product.device=
181# TODO: Remove this soon-to-be obsolete property
182sdk_build_prop_remove += ro.build.product=
183INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
184$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
185 @echo SDK buildinfo: $@
186 @mkdir -p $(dir $@)
187 $(hide) grep -v "$(subst $(space),\|,$(strip \
188 $(sdk_build_prop_remove)))" $< > $@.tmp
189 $(hide) for x in $(sdk_build_prop_remove); do \
190 echo "$$x"generic >> $@.tmp; done
191 $(hide) mv $@.tmp $@
192
193# -----------------------------------------------------------------
194# package stats
195PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
196PACKAGES_TO_STAT := \
197 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
198 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
199$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
200 @echo Package stats: $@
201 @mkdir -p $(dir $@)
202 $(hide) rm -f $@
203 $(hide) build/tools/dump-package-stats $^ > $@
204
205.PHONY: package-stats
206package-stats: $(PACKAGE_STATS_FILE)
207
208# -----------------------------------------------------------------
209# Cert-to-package mapping. Used by the post-build signing tools.
210name := $(TARGET_PRODUCT)
211ifeq ($(TARGET_BUILD_TYPE),debug)
212 name := $(name)_debug
213endif
214name := $(name)-apkcerts-$(FILE_NAME_TAG)
215intermediates := \
216 $(call intermediates-dir-for,PACKAGING,apkcerts)
217APKCERTS_FILE := $(intermediates)/$(name).txt
218# Depending on the built packages isn't exactly right,
219# but it should guarantee that the apkcerts file is rebuilt
220# if any packages change which certs they're signed with.
221all_built_packages := $(foreach p,$(PACKAGES),$(ALL_MODULES.$(p).BUILT))
Ying Wangefb21682010-07-23 16:42:13 -0700222ifneq ($(TARGET_BUILD_APPS),)
223# We don't need to really build all the modules for apps_only build.
224$(APKCERTS_FILE):
225else
The Android Open Source Project88b60792009-03-03 19:28:42 -0800226$(APKCERTS_FILE): $(all_built_packages)
Ying Wangefb21682010-07-23 16:42:13 -0700227endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800228 @echo APK certs list: $@
229 @mkdir -p $(dir $@)
230 @rm -f $@
231 $(hide) $(foreach p,$(PACKAGES),\
Doug Zongkerf6a53aa2009-12-15 15:06:55 -0800232 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
233 echo 'name="$(p).apk" certificate="EXTERNAL" \
234 private_key=""' >> $@;,\
235 echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
236 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800237
238.PHONY: apkcerts-list
239apkcerts-list: $(APKCERTS_FILE)
240
Ying Wangefb21682010-07-23 16:42:13 -0700241$(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
242
The Android Open Source Project88b60792009-03-03 19:28:42 -0800243# -----------------------------------------------------------------
244# module info file
245ifdef CREATE_MODULE_INFO_FILE
246 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
247 $(info Generating $(MODULE_INFO_FILE)...)
248 $(shell rm -f $(MODULE_INFO_FILE))
249 $(foreach m,$(ALL_MODULES), \
250 $(shell echo "NAME=\"$(m)\"" \
251 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
252 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
253 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
254 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
255endif
256
Doug Zongker8678df42009-06-15 14:30:14 -0700257# -----------------------------------------------------------------
258
259# The test key is used to sign this package, and as the key required
260# for future OTA packages installed by this system. Actual product
261# deliverables will be re-signed by hand. We expect this file to
262# exist with the suffixes ".x509.pem" and ".pk8".
263DEFAULT_KEY_CERT_PAIR := $(SRC_TARGET_DIR)/product/security/testkey
264
265
The Android Open Source Project88b60792009-03-03 19:28:42 -0800266# Rules that need to be present for the simulator, even
267# if they don't do anything.
268.PHONY: systemimage
269systemimage:
270
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800271# -----------------------------------------------------------------
272
273.PHONY: event-log-tags
274
Joe Onoratob7510532010-07-14 10:22:54 -0700275# Produce an event logs tag file for everything we know about, in order
276# to properly allocate numbers. Then produce a file that's filtered
277# for what's going to be installed.
278
279all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
280
281# Include tags from all packages that we know about
282all_event_log_tags_src := \
283 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
284
285$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
286$(all_event_log_tags_file): $(all_event_log_tags_src)
287 $(hide) mkdir -p $(dir $@)
288 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
289
290
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800291event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800292
293# Include tags from all packages included in this product.
294event_log_tags_src := \
295 $(sort $(foreach m,\
296 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
297 $(call module-names-for-tag-list,user), \
298 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
299
300$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700301$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
302$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800303 $(hide) mkdir -p $(dir $@)
Joe Onoratob7510532010-07-14 10:22:54 -0700304 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800305
306event-log-tags: $(event_log_tags_file)
307
308ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
309
Joe Onoratob7510532010-07-14 10:22:54 -0700310
The Android Open Source Project88b60792009-03-03 19:28:42 -0800311ifneq ($(TARGET_SIMULATOR),true)
312
313# #################################################################
314# Targets for boot/OS images
315# #################################################################
316
317# -----------------------------------------------------------------
318# the ramdisk
319INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
320 $(ALL_PREBUILT) \
321 $(ALL_COPIED_HEADERS) \
322 $(ALL_GENERATED_SOURCES) \
323 $(ALL_DEFAULT_INSTALLED_MODULES))
324
Joe Onorato64d85d02009-04-09 19:31:12 -0700325BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
326
327# We just build this directly to the install location.
328INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700329$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800330 $(call pretty,"Target ram disk: $@")
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700331 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800332
333
334ifneq ($(strip $(TARGET_NO_KERNEL)),true)
335
336# -----------------------------------------------------------------
337# the boot image, which is a collection of other images.
338INTERNAL_BOOTIMAGE_ARGS := \
339 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
340 --kernel $(INSTALLED_KERNEL_TARGET) \
341 --ramdisk $(INSTALLED_RAMDISK_TARGET)
342
343INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
344
345BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
346ifdef BOARD_KERNEL_CMDLINE
347 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
348endif
349
Dima Zavin1e0847c2009-05-07 19:43:08 -0700350BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
351ifdef BOARD_KERNEL_BASE
352 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
353endif
354
Ying Wangffff0022010-08-23 12:56:25 -0700355BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
356ifdef BOARD_KERNEL_PAGESIZE
357 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
358endif
359
The Android Open Source Project88b60792009-03-03 19:28:42 -0800360INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
361
362ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
363tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
364INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
365INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
366$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
367 $(call pretty,"Target boot image: $@")
368 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
369
370else # TARGET_BOOTIMAGE_USE_EXT2 != true
371
372$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
373 $(call pretty,"Target boot image: $@")
374 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
Doug Zongkered96e882009-08-26 09:37:07 -0700375 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800376endif # TARGET_BOOTIMAGE_USE_EXT2
377
378else # TARGET_NO_KERNEL
379# HACK: The top-level targets depend on the bootimage. Not all targets
380# can produce a bootimage, though, and emulator targets need the ramdisk
381# instead. Fake it out by calling the ramdisk the bootimage.
382# TODO: make the emulator use bootimages, and make mkbootimg accept
383# kernel-less inputs.
384INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
385endif
386
387# -----------------------------------------------------------------
388# NOTICE files
389#
390# This needs to be before the systemimage rules, because it adds to
391# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
392# go into the systemimage.
393
394.PHONY: notice_files
395
396# Create the rule to combine the files into text and html forms
397# $(1) - Plain text output file
398# $(2) - HTML output file
399# $(3) - File title
400# $(4) - Directory to use. Notice files are all $(4)/src. Other
401# directories in there will be used for scratch
402# $(5) - Dependencies for the output files
403#
404# The algorithm here is that we go collect a hash for each of the notice
405# files and write the names of the files that match that hash. Then
406# to generate the real files, we go print out all of the files and their
407# hashes.
408#
409# These rules are fairly complex, so they depend on this makefile so if
410# it changes, they'll run again.
411#
412# TODO: We could clean this up so that we just record the locations of the
413# original notice files instead of making rules to copy them somwehere.
414# Then we could traverse that without quite as much bash drama.
415define combine-notice-files
416$(1) $(2): PRIVATE_MESSAGE := $(3)
417$(1) $(2) $(4)/hash-timestamp: PRIVATE_DIR := $(4)
418$(4)/hash-timestamp: $(5) $(BUILD_SYSTEM)/Makefile
419 @echo Finding NOTICE files: $$@
420 $$(hide) rm -rf $$@ $$(PRIVATE_DIR)/hash
421 $$(hide) mkdir -p $$(PRIVATE_DIR)/hash
422 $$(hide) for file in $$$$(find $$(PRIVATE_DIR)/src -type f); do \
423 hash=$$$$($(MD5SUM) $$$$file | sed -e "s/ .*//"); \
424 hashfile=$$(PRIVATE_DIR)/hash/$$$$hash; \
425 echo $$$$file >> $$$$hashfile; \
426 done
427 $$(hide) touch $$@
428$(1): $(4)/hash-timestamp
429 @echo Combining NOTICE files: $$@
430 $$(hide) mkdir -p $$(dir $$@)
431 $$(hide) echo $$(PRIVATE_MESSAGE) > $$@
432 $$(hide) find $$(PRIVATE_DIR)/hash -type f | xargs cat | sort | \
433 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> $$@
434 $$(hide) echo >> $$@
435 $$(hide) echo >> $$@
436 $$(hide) echo >> $$@
437 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
438 echo "============================================================"\
439 >> $$@; \
440 echo "Notices for file(s):" >> $$@; \
441 cat $$$$hashfile | sort | \
442 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \
443 $$@; \
444 echo "------------------------------------------------------------"\
445 >> $$@; \
446 echo >> $$@; \
447 orig=$$$$(head -n 1 $$$$hashfile); \
448 cat $$$$orig >> $$@; \
449 echo >> $$@; \
450 echo >> $$@; \
451 echo >> $$@; \
452 done
453$(2): $(4)/hash-timestamp
454 @echo Combining NOTICE files: $$@
455 $$(hide) mkdir -p $$(dir $$@)
456 $$(hide) echo "<html><head>" > $$@
457 $$(hide) echo "<style type=\"text/css\">" >> $$@
458 $$(hide) echo "body { padding: 0; font-family: sans-serif; }" >> $$@
459 $$(hide) echo ".same-license { background-color: #eeeeee; border-top: 20px solid white; padding: 10px; }" >> $$@
460 $$(hide) echo ".label { font-weight: bold; }" >> $$@
461 $$(hide) echo ".file-list { margin-left: 1em; font-color: blue; }" >> $$@
462 $$(hide) echo "</style>" >> $$@
463 $$(hide) echo "</head><body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">" >> $$@
464 $$(hide) echo "<table cellpading=\"0\" cellspacing=\"0\" border=\"0\">" \
465 >> $$@
466 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
467 cat $$$$hashfile | sort | \
468 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: <a name=\"\1\"></a>:" >> \
469 $$@; \
470 echo "<tr><td class=\"same-license\">" >> $$@; \
471 echo "<div class=\"label\">Notices for file(s):</div>" >> $$@; \
472 echo "<div class=\"file-list\">" >> $$@; \
473 cat $$$$hashfile | sort | \
474 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1<br/>:" >> $$@; \
475 echo "</div><!-- file-list -->" >> $$@; \
476 echo >> $$@; \
477 orig=$$$$(head -n 1 $$$$hashfile); \
478 echo "<pre class=\"license-text\">" >> $$@; \
479 cat $$$$orig | sed -e "s/\&/\&amp;/g" | sed -e "s/</\&lt;/g" \
480 | sed -e "s/>/\&gt;/g" >> $$@; \
481 echo "</pre><!-- license-text -->" >> $$@; \
482 echo "</td></tr><!-- same-license -->" >> $$@; \
483 echo >> $$@; \
484 echo >> $$@; \
485 echo >> $$@; \
486 done
487 $$(hide) echo "</table>" >> $$@
488 $$(hide) echo "</body></html>" >> $$@
489notice_files: $(1) $(2)
490endef
491
492# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
493# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
494# the src subdirectory.
495
496target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
497target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
498target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
499tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
500tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
501
502kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
503
504$(eval $(call combine-notice-files, \
505 $(target_notice_file_txt), \
506 $(target_notice_file_html), \
507 "Notices for files contained in the filesystem images in this directory:", \
508 $(TARGET_OUT_NOTICE_FILES), \
509 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)))
510
511$(eval $(call combine-notice-files, \
512 $(tools_notice_file_txt), \
513 $(tools_notice_file_html), \
514 "Notices for files contained in the tools directory:", \
515 $(HOST_OUT_NOTICE_FILES), \
516 $(ALL_DEFAULT_INSTALLED_MODULES)))
517
518# Install the html file at /system/etc/NOTICE.html.gz.
519# This is not ideal, but this is very late in the game, after a lot of
520# the module processing has already been done -- in fact, we used the
521# fact that all that has been done to get the list of modules that we
522# need notice files for.
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700523$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700524 $(hide) $(MINIGZIP) -9 < $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800525installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
526$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
527 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700528
529# if we've been run my mm, mmm, etc, don't reinstall this every time
530ifeq ($(ONE_SHOT_MAKEFILE),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800531ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700532endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800533
534# The kernel isn't really a module, so to get its module file in there, we
535# make the target NOTICE files depend on this particular file too, which will
536# then be in the right directory for the find in combine-notice-files to work.
537$(kernel_notice_file): \
538 prebuilt/$(TARGET_PREBUILT_TAG)/kernel/LINUX_KERNEL_COPYING \
539 | $(ACP)
540 @echo Copying: $@
541 $(hide) mkdir -p $(dir $@)
542 $(hide) $(ACP) $< $@
543
544
Doug Zongker8678df42009-06-15 14:30:14 -0700545# -----------------------------------------------------------------
546# Build a keystore with the authorized keys in it, used to verify the
547# authenticity of downloaded OTA packages.
548#
549# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
550# before the rules that use that variable to build the image.
551ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
552$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Doug Zongker37c0e272009-06-15 15:36:16 -0700553$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Doug Zongker8678df42009-06-15 14:30:14 -0700554 $(hide) rm -f $@
555 $(hide) mkdir -p $(dir $@)
Doug Zongker37c0e272009-06-15 15:36:16 -0700556 $(hide) zip -qj $@ $<
Doug Zongker8678df42009-06-15 14:30:14 -0700557
558.PHONY: otacerts
559otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
560
561
The Android Open Source Project88b60792009-03-03 19:28:42 -0800562# #################################################################
563# Targets for user images
564# #################################################################
565
Ying Wang933abf12010-06-16 14:31:34 -0700566INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800567ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -0700568INTERNAL_USERIMAGES_USE_EXT := true
569INTERNAL_USERIMAGES_EXT_VARIANT := ext2
570else
571ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
572INTERNAL_USERIMAGES_USE_EXT := true
573INTERNAL_USERIMAGES_EXT_VARIANT := ext3
574else
575ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
576INTERNAL_USERIMAGES_USE_EXT := true
577INTERNAL_USERIMAGES_EXT_VARIANT := ext4
578endif
579endif
580endif
581
Ying Wang542903a2010-11-17 15:40:38 -0800582ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
583 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
584endif
585
Colin Cross0a7b2c52010-05-07 02:23:59 -0700586ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
Ying Wang542903a2010-11-17 15:40:38 -0800587INTERNAL_USERIMAGES_DEPS := $(MKEXTUSERIMG) $(MAKE_EXT4FS)
Ying Wang933abf12010-06-16 14:31:34 -0700588INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
589
Ying Wangc79f4da2010-06-16 14:58:50 -0700590# $(1): src directory
591# $(2): output file
Ying Wang026f1452010-09-27 17:49:03 -0700592# $(3): mount point
Ying Wangc79f4da2010-06-16 14:58:50 -0700593# $(4): ext variant (ext2, ext3, ext4)
Colin Crosse0a40212010-08-03 14:43:34 -0700594# $(5): size of the partition
Ying Wangc79f4da2010-06-16 14:58:50 -0700595define build-userimage-ext-target
596 @mkdir -p $(dir $(2))
Ying Wang933abf12010-06-16 14:31:34 -0700597 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$(PATH) \
Ying Wang542903a2010-11-17 15:40:38 -0800598 $(MKEXTUSERIMG) $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG) $(1) $(2) $(4) $(3) $(5)
Ying Wangc79f4da2010-06-16 14:58:50 -0700599endef
The Android Open Source Project88b60792009-03-03 19:28:42 -0800600else
Colin Cross144b0282010-05-10 13:04:47 -0700601INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800602endif
603
604# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -0700605# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700606
607# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
Brian Swetland630b7d32009-08-07 18:09:44 -0700608ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY) $(BUILD_TINY_ANDROID)))
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700609
Doug Zongker4647f122009-07-02 09:00:54 -0700610INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
611
612recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
613recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
614recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
615recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
616recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
617recovery_resources_common := $(call include-path-for, recovery)/res
618recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
619recovery_resource_deps := $(shell find $(recovery_resources_common) \
620 $(recovery_resources_private) -type f)
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700621recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Doug Zongker4647f122009-07-02 09:00:54 -0700622
623ifeq ($(recovery_resources_private),)
624 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
625endif
626
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700627ifeq ($(recovery_fstab),)
628 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
629endif
630
Doug Zongker4647f122009-07-02 09:00:54 -0700631INTERNAL_RECOVERYIMAGE_ARGS := \
632 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
633 --kernel $(recovery_kernel) \
634 --ramdisk $(recovery_ramdisk)
635
636# Assumes this has already been stripped
637ifdef BOARD_KERNEL_CMDLINE
638 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
639endif
640ifdef BOARD_KERNEL_BASE
641 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
642endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700643BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
644ifdef BOARD_KERNEL_PAGESIZE
645 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
646endif
Doug Zongker4647f122009-07-02 09:00:54 -0700647
648# Keys authorized to sign OTA packages this build will accept. The
649# build always uses test-keys for this; release packaging tools will
650# substitute other keys for this one.
651OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
652
653# Generate a file containing the keys that will be read by the
654# recovery binary.
655RECOVERY_INSTALL_OTA_KEYS := \
656 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
657DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
658$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
659$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR)
660 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS)"
661 @rm -rf $@
662 @mkdir -p $(dir $@)
663 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@
664
665$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
666 $(INSTALLED_RAMDISK_TARGET) \
667 $(INSTALLED_BOOTIMAGE_TARGET) \
668 $(recovery_binary) \
669 $(recovery_initrc) $(recovery_kernel) \
670 $(INSTALLED_2NDBOOTLOADER_TARGET) \
671 $(recovery_build_prop) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700672 $(recovery_fstab) \
Doug Zongker4647f122009-07-02 09:00:54 -0700673 $(RECOVERY_INSTALL_OTA_KEYS)
674 @echo ----- Making recovery image ------
675 rm -rf $(TARGET_RECOVERY_OUT)
676 mkdir -p $(TARGET_RECOVERY_OUT)
677 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)
678 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc
679 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp
680 echo Copying baseline ramdisk...
681 cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Doug Zongkerb4c7d322010-07-01 15:30:11 -0700682 rm $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
Doug Zongker4647f122009-07-02 09:00:54 -0700683 echo Modifying ramdisk contents...
684 cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
685 cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
686 cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
687 $(foreach item,$(recovery_resources_private), \
688 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700689 $(foreach item,$(recovery_fstab), \
690 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Doug Zongker4647f122009-07-02 09:00:54 -0700691 cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
692 cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
693 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
694 $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
695 $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@
696 @echo ----- Made recovery image -------- $@
Doug Zongkered96e882009-08-26 09:37:07 -0700697 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
Doug Zongker4647f122009-07-02 09:00:54 -0700698
699else
700INSTALLED_RECOVERYIMAGE_TARGET :=
701endif
702
703.PHONY: recoveryimage
704recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET)
705
Dima Zavin11818982010-02-05 13:34:34 -0800706ifneq ($(BOARD_NAND_PAGE_SIZE),)
707mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
708else
709mkyaffs2_extra_flags :=
710endif
711
Naseer Ahmed53871882010-08-06 12:19:29 -0700712ifneq ($(BOARD_NAND_SPARE_SIZE),)
713mkyaffs2_extra_flags += -s $(BOARD_NAND_SPARE_SIZE)
714endif
715
Dima Zavin11818982010-02-05 13:34:34 -0800716
Doug Zongker4647f122009-07-02 09:00:54 -0700717# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -0700718# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800719#
Ying Wang02352372010-09-27 10:37:25 -0700720systemimage_intermediates := \
721 $(call intermediates-dir-for,PACKAGING,systemimage)
722BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
The Android Open Source Project88b60792009-03-03 19:28:42 -0800723
724INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
725 $(ALL_PREBUILT) \
726 $(ALL_COPIED_HEADERS) \
727 $(ALL_GENERATED_SOURCES) \
728 $(ALL_DEFAULT_INSTALLED_MODULES))
729
Colin Cross0a7b2c52010-05-07 02:23:59 -0700730ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
731## generate an ext image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800732# $(1): output file
733define build-systemimage-target
734 @echo "Target system fs image: $(1)"
Colin Crosse0a40212010-08-03 14:43:34 -0700735 $(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 -0800736endef
737
Colin Cross0a7b2c52010-05-07 02:23:59 -0700738else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800739
740## generate a yaffs2 image
741# $(1): output file
742define build-systemimage-target
743 @echo "Target system fs image: $(1)"
744 @mkdir -p $(dir $(1))
Dima Zavin11818982010-02-05 13:34:34 -0800745 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800746endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700747endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800748
Ying Wang02352372010-09-27 10:37:25 -0700749$(BUILT_SYSTEMIMAGE): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800750 $(call build-systemimage-target,$@)
751
The Android Open Source Project88b60792009-03-03 19:28:42 -0800752INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700753SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800754
Doug Zongker73ef8252009-07-23 15:12:53 -0700755# The system partition needs room for the recovery image as well. We
756# now store the recovery image as a binary patch using the boot image
757# as the source (since they are very similar). Generate the patch so
758# we can see how big it's going to be, and include that in the system
759# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700760ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700761intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
762RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
763$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
764 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700765 $(HOST_OUT_EXECUTABLES)/imgdiff \
766 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700767 @echo "Construct recovery from boot"
768 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700769 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700770endif
771
Doug Zongker73ef8252009-07-23 15:12:53 -0700772
773$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800774 @echo "Install system fs image: $@"
775 $(copy-file-to-target)
Doug Zongkered96e882009-08-26 09:37:07 -0700776 $(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 -0800777
778systemimage: $(INSTALLED_SYSTEMIMAGE)
779
780.PHONY: systemimage-nodeps snod
781systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -0700782 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800783 @echo "make $@: ignoring dependencies"
784 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
Doug Zongkered96e882009-08-26 09:37:07 -0700785 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800786
787#######
788## system tarball
789define build-systemtarball-target
790 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
791 $(MKTARBALL) $(FS_GET_STATS) \
792 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
793 $(INSTALLED_SYSTEMTARBALL_TARGET)
794endef
795
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700796ifndef SYSTEM_TARBALL_FORMAT
797 SYSTEM_TARBALL_FORMAT := bz2
798endif
799
The Android Open Source Project88b60792009-03-03 19:28:42 -0800800system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700801INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800802$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
803$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
804 $(build-systemtarball-target)
805
806.PHONY: systemtarball-nodeps
807systemtarball-nodeps: $(FS_GET_STATS) \
808 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
809 $(build-systemtarball-target)
810
811.PHONY: stnod
812stnod: systemtarball-nodeps
813
814
Bruce Beare52aac202010-06-04 15:24:49 -0700815#######
816## boot tarball
817define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -0700818 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -0700819 $(hide) mkdir -p $(PRODUCT_OUT)/boot
820 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
821 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
822 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
823 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
824 $(INSTALLED_BOOTTARBALL_TARGET)
825endef
826
827ifndef BOOT_TARBALL_FORMAT
828 BOOT_TARBALL_FORMAT := bz2
829endif
830
831boot_tar := $(PRODUCT_OUT)/boot.tar
832INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
833$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
834$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
835 $(build-boottarball-target)
836
837.PHONY: boottarball-nodeps btnod
838boottarball-nodeps btnod: $(FS_GET_STATS) \
839 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
840 $(build-boottarball-target)
841
842
The Android Open Source Project88b60792009-03-03 19:28:42 -0800843# -----------------------------------------------------------------
844# data partition image
845INTERNAL_USERDATAIMAGE_FILES := \
846 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
847
Colin Cross0a7b2c52010-05-07 02:23:59 -0700848ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800849## Generate an ext2 image
850define build-userdataimage-target
851 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
852 @mkdir -p $(TARGET_OUT_DATA)
Ying Wang026f1452010-09-27 17:49:03 -0700853 $(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 -0700854 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800855endef
856
Colin Cross0a7b2c52010-05-07 02:23:59 -0700857else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800858
859## Generate a yaffs2 image
860define build-userdataimage-target
861 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
862 @mkdir -p $(TARGET_OUT_DATA)
Dima Zavin11818982010-02-05 13:34:34 -0800863 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
Doug Zongkered96e882009-08-26 09:37:07 -0700864 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800865endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700866endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800867
Joe Onorato64d85d02009-04-09 19:31:12 -0700868BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
869
870# We just build this directly to the install location.
871INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -0700872$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800873 $(INTERNAL_USERDATAIMAGE_FILES)
874 $(build-userdataimage-target)
875
876.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -0700877userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800878 $(build-userdataimage-target)
879
880#######
881## data partition tarball
882define build-userdatatarball-target
883 $(call pretty,"Target userdata fs tarball: " \
884 "$(INSTALLED_USERDATATARBALL_TARGET)")
885 $(MKTARBALL) $(FS_GET_STATS) \
886 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
887 $(INSTALLED_USERDATATARBALL_TARGET)
888endef
889
890userdata_tar := $(PRODUCT_OUT)/userdata.tar
891INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
892$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
893$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
894 $(build-userdatatarball-target)
895
896.PHONY: userdatatarball-nodeps
897userdatatarball-nodeps: $(FS_GET_STATS)
898 $(build-userdatatarball-target)
899
900
The Android Open Source Project88b60792009-03-03 19:28:42 -0800901# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800902# bring in the installer image generation defines if necessary
903ifeq ($(TARGET_USE_DISKINSTALLER),true)
904include bootable/diskinstaller/config.mk
905endif
906
907# -----------------------------------------------------------------
Doug Zongker8678df42009-06-15 14:30:14 -0700908# host tools needed to build OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -0800909
Ying Wang06898662010-06-17 17:52:18 -0700910OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -0700911 $(HOST_OUT_EXECUTABLES)/mkbootfs \
912 $(HOST_OUT_EXECUTABLES)/mkbootimg \
913 $(HOST_OUT_EXECUTABLES)/fs_config \
914 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
915 $(HOST_OUT_EXECUTABLES)/zipalign \
916 $(HOST_OUT_EXECUTABLES)/aapt \
917 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -0700918 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -0700919 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -0700920 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
921 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
922 $(HOST_OUT_EXECUTABLES)/genext2fs \
923 $(HOST_OUT_EXECUTABLES)/tune2fs \
Sriram Ramanff83c852010-11-30 15:09:19 -0500924 $(HOST_OUT_EXECUTABLES)/e2fsck \
Sriram Ramanc647aec2010-11-29 18:51:20 -0500925 $(HOST_OUT_EXECUTABLES)/make_ext4fs
The Android Open Source Project88b60792009-03-03 19:28:42 -0800926
Ying Wang06898662010-06-17 17:52:18 -0700927.PHONY: otatools
928otatools: $(OTATOOLS)
929
The Android Open Source Project88b60792009-03-03 19:28:42 -0800930# -----------------------------------------------------------------
931# A zip of the directories that map to the target filesystem.
932# This zip can be used to create an OTA package or filesystem image
933# as a post-build step.
934#
935name := $(TARGET_PRODUCT)
936ifeq ($(TARGET_BUILD_TYPE),debug)
937 name := $(name)_debug
938endif
939name := $(name)-target_files-$(FILE_NAME_TAG)
940
941intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
942BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
943$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
944$(BUILT_TARGET_FILES_PACKAGE): \
945 zip_root := $(intermediates)/$(name)
946
947# $(1): Directory to copy
948# $(2): Location to copy it to
949# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
950define package_files-copy-root
951 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
952 mkdir -p $(2) && \
953 $(ACP) -rd $(strip $(1))/* $(2); \
954 fi
955endef
956
957built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -0700958 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -0700959 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -0700960 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
961 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -0800962$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
963
Doug Zongkerb1134dd2009-06-17 17:09:40 -0700964$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
965
Doug Zongkerc18736b2009-09-30 09:20:32 -0700966ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
967# default to common dir for device vendor
968$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
969else
970$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
971endif
972
The Android Open Source Project88b60792009-03-03 19:28:42 -0800973# Depending on the various images guarantees that the underlying
974# directories are up-to-date.
975$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800976 $(INSTALLED_BOOTIMAGE_TARGET) \
977 $(INSTALLED_RADIOIMAGE_TARGET) \
978 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -0700979 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800980 $(INSTALLED_USERDATAIMAGE_TARGET) \
981 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800982 $(built_ota_tools) \
983 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -0700984 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800985 | $(ACP)
986 @echo "Package target files: $@"
987 $(hide) rm -rf $@ $(zip_root)
988 $(hide) mkdir -p $(dir $@) $(zip_root)
989 @# Components of the recovery image
990 $(hide) mkdir -p $(zip_root)/RECOVERY
991 $(hide) $(call package_files-copy-root, \
992 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
993ifdef INSTALLED_KERNEL_TARGET
994 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
995endif
996ifdef INSTALLED_2NDBOOTLOADER_TARGET
997 $(hide) $(ACP) \
998 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
999endif
1000ifdef BOARD_KERNEL_CMDLINE
1001 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
1002endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001003ifdef BOARD_KERNEL_BASE
1004 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
1005endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001006ifdef BOARD_KERNEL_PAGESIZE
1007 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
1008endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001009 @# Components of the boot image
1010 $(hide) mkdir -p $(zip_root)/BOOT
1011 $(hide) $(call package_files-copy-root, \
1012 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1013ifdef INSTALLED_KERNEL_TARGET
1014 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1015endif
1016ifdef INSTALLED_2NDBOOTLOADER_TARGET
1017 $(hide) $(ACP) \
1018 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1019endif
1020ifdef BOARD_KERNEL_CMDLINE
1021 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1022endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001023ifdef BOARD_KERNEL_BASE
1024 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1025endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001026ifdef BOARD_KERNEL_PAGESIZE
1027 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1028endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001029 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1030 mkdir -p $(zip_root)/RADIO; \
1031 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001032 @# Contents of the system image
1033 $(hide) $(call package_files-copy-root, \
1034 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1035 @# Contents of the data image
1036 $(hide) $(call package_files-copy-root, \
1037 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1038 @# Extra contents of the OTA package
1039 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001040 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1041 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001042 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001043 @# build them.
1044 $(hide) mkdir -p $(zip_root)/META
1045 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker17c83cf2009-04-01 15:48:46 -07001046 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -07001047 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001048ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07001049 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001050endif
1051ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
1052 $(hide) echo "boot_size=$(call image-size-from-data-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1053endif
1054ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
1055 $(hide) echo "recovery_size=$(call image-size-from-data-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1056endif
1057ifdef BOARD_SYSTEMIMAGE_PARTITION_SIZE
1058 $(hide) echo "system_size=$(call image-size-from-data-size,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1059endif
1060ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
1061 $(hide) echo "userdata_size=$(call image-size-from-data-size,$(BOARD_USERDATAIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1062endif
Doug Zongker37974732010-09-16 17:44:38 -07001063 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001064ifdef mkyaffs2_extra_flags
Doug Zongker37974732010-09-16 17:44:38 -07001065 $(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001066endif
Ying Wangc5a07ce2010-11-17 17:45:36 -08001067ifdef INTERNAL_USERIMAGES_SPARSE_EXT_FLAG
1068 $(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(zip_root)/META/misc_info.txt
1069endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001070 @# Zip everything up, preserving symlinks
1071 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongker283e2a12010-03-15 17:52:32 -07001072 @# Run fs_config on all the system files in the zip, and save the output
1073 $(hide) zipinfo -1 $@ | awk -F/ 'BEGIN { OFS="/" } /^SYSTEM\// {$$1 = "system"; print}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
1074 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/filesystem_config.txt)
1075
The Android Open Source Project88b60792009-03-03 19:28:42 -08001076
1077target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1078
Doug Zongker367910f2009-06-15 18:56:51 -07001079
1080ifneq ($(TARGET_SIMULATOR),true)
1081ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang910dcbe2010-03-24 23:22:33 -07001082ifneq ($(TARGET_DEVICE),generic)
Ying Wangfb0a3472010-08-25 16:06:06 -07001083ifneq ($(TARGET_NO_KERNEL),true)
Doug Zongker367910f2009-06-15 18:56:51 -07001084
Ying Wang09a00a62010-10-20 14:01:09 -07001085# -----------------------------------------------------------------
1086# OTA update package
1087
Doug Zongker8678df42009-06-15 14:30:14 -07001088name := $(TARGET_PRODUCT)
1089ifeq ($(TARGET_BUILD_TYPE),debug)
1090 name := $(name)_debug
1091endif
1092name := $(name)-ota-$(FILE_NAME_TAG)
1093
1094INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1095
1096$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1097
Ying Wang06898662010-06-17 17:52:18 -07001098$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001099 @echo "Package OTA: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001100 $(hide) ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker602a84e2009-06-18 08:35:12 -07001101 -p $(HOST_OUT) \
Doug Zongker8678df42009-06-15 14:30:14 -07001102 -k $(KEY_CERT_PAIR) \
1103 $(BUILT_TARGET_FILES_PACKAGE) $@
1104
1105.PHONY: otapackage
1106otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1107
Ying Wang09a00a62010-10-20 14:01:09 -07001108# -----------------------------------------------------------------
1109# The update package
1110
1111name := $(TARGET_PRODUCT)
1112ifeq ($(TARGET_BUILD_TYPE),debug)
1113 name := $(name)_debug
1114endif
1115name := $(name)-img-$(FILE_NAME_TAG)
1116
1117INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1118
1119ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1120# default to common dir for device vendor
1121$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_DEVICE_DIR)/../common
1122else
1123$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1124endif
1125
1126$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
1127 @echo "Package: $@"
1128 $(hide) ./build/tools/releasetools/img_from_target_files -v \
1129 -s $(extensions) \
1130 -p $(HOST_OUT) \
1131 $(BUILT_TARGET_FILES_PACKAGE) $@
1132
1133.PHONY: updatepackage
1134updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
1135
Ying Wangfb0a3472010-08-25 16:06:06 -07001136endif # TARGET_NO_KERNEL != true
Ying Wang910dcbe2010-03-24 23:22:33 -07001137endif # TARGET_DEVICE != generic
Doug Zongker367910f2009-06-15 18:56:51 -07001138endif # TARGET_PRODUCT != sdk
1139endif # TARGET_SIMULATOR != true
Doug Zongker8678df42009-06-15 14:30:14 -07001140
1141# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001142# installed file list
1143# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it
1144# gets the DexOpt one if we're doing that.
1145INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
1146$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE)
1147 @echo Installed file list: $@
1148 @mkdir -p $(dir $@)
1149 @rm -f $@
1150 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@
1151
1152.PHONY: installed-file-list
1153installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wanga37a2cb2010-04-28 12:59:51 -07001154ifneq ($(filter sdk,$(MAKECMDGOALS)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001155$(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE))
Ying Wanga37a2cb2010-04-28 12:59:51 -07001156endif
1157ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
Joe Onorato03fbe402009-04-13 08:31:16 -07001158$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wanga37a2cb2010-04-28 12:59:51 -07001159endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001160
1161# -----------------------------------------------------------------
1162# A zip of the tests that are built when running "make tests".
1163# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
1164# only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
1165#
1166name := $(TARGET_PRODUCT)
1167ifeq ($(TARGET_BUILD_TYPE),debug)
1168 name := $(name)_debug
1169endif
1170name := $(name)-tests-$(FILE_NAME_TAG)
1171
1172intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
1173BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
1174$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
1175$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
1176
1177# Depending on the images guarantees that the underlying
1178# directories are up-to-date.
1179$(BUILT_TESTS_ZIP_PACKAGE): \
1180 $(BUILT_SYSTEMIMAGE) \
1181 $(INSTALLED_USERDATAIMAGE_TARGET) \
1182 | $(ACP)
1183 @echo "Package test files: $@"
1184 $(hide) rm -rf $@ $(zip_root)
1185 $(hide) mkdir -p $(dir $@) $(zip_root)
1186 @# Some parts of the system image
1187 $(hide) $(call package_files-copy-root, \
1188 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin)
1189 $(hide) $(call package_files-copy-root, \
1190 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib)
1191 $(hide) $(call package_files-copy-root, \
1192 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \
1193 $(zip_root)/SYSTEM/framework)
1194 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM
1195 @# Contents of the data image
1196 $(hide) $(call package_files-copy-root, \
1197 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1198 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
1199
Ying Wang9c762552010-09-10 14:39:33 -07001200.PHONY: tests-zip-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001201tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
1202
Ying Wangdb2cb632010-09-14 16:07:56 -07001203# Target needed by tests build
1204.PHONY: tests-build-target
1205tests-build-target: $(BUILT_TESTS_ZIP_PACKAGE) \
1206 $(BUILT_USERDATAIMAGE_TARGET)
1207
1208ifneq (,$(filter $(MAKECMDGOALS),tests-build-target))
1209 $(call dist-for-goals, tests-build-target, \
1210 $(BUILT_TESTS_ZIP_PACKAGE) \
1211 $(BUILT_USERDATAIMAGE_TARGET))
Ying Wang9c762552010-09-10 14:39:33 -07001212endif
1213
The Android Open Source Project88b60792009-03-03 19:28:42 -08001214# -----------------------------------------------------------------
1215# A zip of the symbols directory. Keep the full paths to make it
1216# more obvious where these files came from.
1217#
1218name := $(TARGET_PRODUCT)
1219ifeq ($(TARGET_BUILD_TYPE),debug)
1220 name := $(name)_debug
1221endif
1222name := $(name)-symbols-$(FILE_NAME_TAG)
1223
1224SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1225$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1226 @echo "Package symbols: $@"
1227 $(hide) rm -rf $@
1228 $(hide) mkdir -p $(dir $@)
1229 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1230
1231# -----------------------------------------------------------------
1232# A zip of the Android Apps. Not keeping full path so that we don't
1233# include product names when distributing
1234#
1235name := $(TARGET_PRODUCT)
1236ifeq ($(TARGET_BUILD_TYPE),debug)
1237 name := $(name)_debug
1238endif
1239name := $(name)-apps-$(FILE_NAME_TAG)
1240
1241APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1242$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1243 @echo "Package apps: $@"
1244 $(hide) rm -rf $@
1245 $(hide) mkdir -p $(dir $@)
1246 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
1247
Guang Zhu0198d6e2010-04-23 11:54:37 -07001248
1249#------------------------------------------------------------------
1250# A zip of emma code coverage meta files. Generated for fully emma
1251# instrumented build.
1252#
1253EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
1254$(EMMA_META_ZIP): $(INSTALLED_SYSTEMIMAGE)
1255 @echo "Collecting Emma coverage meta files."
1256 $(hide) find $(TARGET_COMMON_OUT_ROOT) -name "coverage.em" | \
1257 zip -@ -q $@
1258
The Android Open Source Project88b60792009-03-03 19:28:42 -08001259endif # TARGET_SIMULATOR != true
1260
1261# -----------------------------------------------------------------
1262# dalvik something
1263.PHONY: dalvikfiles
1264dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1265
1266# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001267# The emulator package
1268
1269ifneq ($(TARGET_SIMULATOR),true)
1270
1271INTERNAL_EMULATOR_PACKAGE_FILES += \
1272 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
1273 prebuilt/android-arm/kernel/kernel-qemu \
1274 $(INSTALLED_RAMDISK_TARGET) \
1275 $(INSTALLED_SYSTEMIMAGE) \
1276 $(INSTALLED_USERDATAIMAGE_TARGET)
1277
1278name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1279
1280INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1281
1282$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1283 @echo "Package: $@"
1284 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1285
1286endif
1287
1288# -----------------------------------------------------------------
1289# The pdk package (Platform Development Kit)
1290
1291ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1292 include development/pdk/Pdk.mk
1293endif
1294
1295# -----------------------------------------------------------------
1296# The SDK
1297
1298ifneq ($(TARGET_SIMULATOR),true)
1299
1300# The SDK includes host-specific components, so it belongs under HOST_OUT.
1301sdk_dir := $(HOST_OUT)/sdk
1302
1303# Build a name that looks like:
1304#
1305# linux-x86 --> android-sdk_12345_linux-x86
1306# darwin-x86 --> android-sdk_12345_mac-x86
1307# windows-x86 --> android-sdk_12345_windows
1308#
1309sdk_name := android-sdk_$(FILE_NAME_TAG)
1310ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001311 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001312else
Joe Onorato03fbe402009-04-13 08:31:16 -07001313 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001314endif
1315ifneq ($(HOST_OS),windows)
Joe Onorato03fbe402009-04-13 08:31:16 -07001316 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001317endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001318sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001319
1320sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1321
1322ATREE_FILES :=
1323-include $(sdk_dep_file)
1324
1325# if we don't have a real list, then use "everything"
1326ifeq ($(strip $(ATREE_FILES)),)
1327ATREE_FILES := \
1328 $(ALL_PREBUILT) \
1329 $(ALL_COPIED_HEADERS) \
1330 $(ALL_GENERATED_SOURCES) \
1331 $(ALL_DEFAULT_INSTALLED_MODULES) \
1332 $(INSTALLED_RAMDISK_TARGET) \
1333 $(ALL_DOCS) \
1334 $(ALL_SDK_FILES)
1335endif
1336
1337atree_dir := development/build
1338
1339sdk_atree_files := \
1340 $(atree_dir)/sdk.exclude.atree \
1341 $(atree_dir)/sdk.atree \
Xavier Ducrohetffd50872010-09-27 15:51:32 -07001342 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree \
1343 sdk/build/tools.atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08001344
1345deps := \
1346 $(target_notice_file_txt) \
1347 $(tools_notice_file_txt) \
1348 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001349 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001350 $(INSTALLED_SYSTEMIMAGE) \
1351 $(INSTALLED_USERDATAIMAGE_TARGET) \
1352 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001353 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001354 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001355 $(ATREE_FILES) \
1356 $(atree_dir)/sdk.atree \
Xavier Ducrohetffd50872010-09-27 15:51:32 -07001357 sdk/build/tools.atree \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001358 $(HOST_OUT_EXECUTABLES)/atree \
1359 $(HOST_OUT_EXECUTABLES)/line_endings
1360
1361INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1362$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1363$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1364$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1365$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1366
1367# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1368#
1369#SDK_GNU_ERROR := true
1370
1371$(INTERNAL_SDK_TARGET): $(deps)
1372 @echo "Package SDK: $@"
1373 $(hide) rm -rf $(PRIVATE_DIR) $@
1374 $(hide) for f in $(target_gnu_MODULES); do \
1375 if [ -f $$f ]; then \
1376 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1377 including GNU target $$f >&2; \
1378 FAIL=$(SDK_GNU_ERROR); \
1379 fi; \
1380 done; \
1381 if [ $$FAIL ]; then exit 1; fi
1382 $(hide) ( \
1383 $(HOST_OUT_EXECUTABLES)/atree \
1384 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1385 -m $(PRIVATE_DEP_FILE) \
1386 -I . \
1387 -I $(PRODUCT_OUT) \
1388 -I $(HOST_OUT) \
1389 -I $(TARGET_COMMON_OUT_ROOT) \
1390 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
1391 -o $(PRIVATE_DIR) && \
1392 cp -f $(target_notice_file_txt) \
1393 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \
1394 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
1395 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Xavier Ducrohet1ae98802009-11-17 15:10:41 -08001396 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001397 chmod -R ug+rwX $(PRIVATE_DIR) && \
1398 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1399 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1400
Raphael3d224a02010-04-16 17:50:09 -07001401
1402# Is a Windows SDK requested? If so, we need some definitions from here
1403# in order to find the Linux SDK used to create the Windows one.
1404ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
1405LINUX_SDK_NAME := $(sdk_name)
1406LINUX_SDK_DIR := $(sdk_dir)
1407include $(TOPDIR)development/build/tools/windows_sdk.mk
1408endif
1409
The Android Open Source Project88b60792009-03-03 19:28:42 -08001410endif # !simulator
1411
1412# -----------------------------------------------------------------
1413# Findbugs
1414INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1415INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1416$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1417 @echo UnionBugs: $@
1418 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1419 > $@
1420$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1421 @echo ConvertXmlToText: $@
1422 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1423 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1424
1425# -----------------------------------------------------------------
1426# Findbugs
1427
1428# -----------------------------------------------------------------
1429# These are some additional build tasks that need to be run.
1430include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01001431-include $(sort $(wildcard vendor/*/build/tasks/*.mk))