blob: 36477d7664d79547a881433d43bd4f7896cc835d [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)))
Doug Zongker135a1202010-09-15 13:02:12 -070076 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 -080077endif
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)
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700613recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Doug Zongker4647f122009-07-02 09:00:54 -0700614
615ifeq ($(recovery_resources_private),)
616 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
617endif
618
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700619ifeq ($(recovery_fstab),)
620 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
621endif
622
Doug Zongker4647f122009-07-02 09:00:54 -0700623INTERNAL_RECOVERYIMAGE_ARGS := \
624 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
625 --kernel $(recovery_kernel) \
626 --ramdisk $(recovery_ramdisk)
627
628# Assumes this has already been stripped
629ifdef BOARD_KERNEL_CMDLINE
630 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
631endif
632ifdef BOARD_KERNEL_BASE
633 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
634endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700635BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
636ifdef BOARD_KERNEL_PAGESIZE
637 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
638endif
Doug Zongker4647f122009-07-02 09:00:54 -0700639
640# Keys authorized to sign OTA packages this build will accept. The
641# build always uses test-keys for this; release packaging tools will
642# substitute other keys for this one.
643OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
644
645# Generate a file containing the keys that will be read by the
646# recovery binary.
647RECOVERY_INSTALL_OTA_KEYS := \
648 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
649DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
650$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
651$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR)
652 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS)"
653 @rm -rf $@
654 @mkdir -p $(dir $@)
655 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@
656
657$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
658 $(INSTALLED_RAMDISK_TARGET) \
659 $(INSTALLED_BOOTIMAGE_TARGET) \
660 $(recovery_binary) \
661 $(recovery_initrc) $(recovery_kernel) \
662 $(INSTALLED_2NDBOOTLOADER_TARGET) \
663 $(recovery_build_prop) $(recovery_resource_deps) \
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700664 $(recovery_fstab) \
Doug Zongker4647f122009-07-02 09:00:54 -0700665 $(RECOVERY_INSTALL_OTA_KEYS)
666 @echo ----- Making recovery image ------
667 rm -rf $(TARGET_RECOVERY_OUT)
668 mkdir -p $(TARGET_RECOVERY_OUT)
669 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)
670 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc
671 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp
672 echo Copying baseline ramdisk...
673 cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Doug Zongkerb4c7d322010-07-01 15:30:11 -0700674 rm $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
Doug Zongker4647f122009-07-02 09:00:54 -0700675 echo Modifying ramdisk contents...
676 cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
677 cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
678 cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
679 $(foreach item,$(recovery_resources_private), \
680 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
Doug Zongker9ce0fb62010-09-20 18:04:41 -0700681 $(foreach item,$(recovery_fstab), \
682 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Doug Zongker4647f122009-07-02 09:00:54 -0700683 cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
684 cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
685 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
686 $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
687 $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@
688 @echo ----- Made recovery image -------- $@
Doug Zongkered96e882009-08-26 09:37:07 -0700689 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
Doug Zongker4647f122009-07-02 09:00:54 -0700690
691else
692INSTALLED_RECOVERYIMAGE_TARGET :=
693endif
694
695.PHONY: recoveryimage
696recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET)
697
Dima Zavin11818982010-02-05 13:34:34 -0800698ifneq ($(BOARD_NAND_PAGE_SIZE),)
699mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
700else
701mkyaffs2_extra_flags :=
702endif
703
704
Doug Zongker4647f122009-07-02 09:00:54 -0700705# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800706# system yaffs image
707#
708# First, the "unoptimized" image, which contains .apk/.jar files
709# that contain regular, unoptimized/unverified .dex entries.
710#
711systemimage_unopt_intermediates := \
712 $(call intermediates-dir-for,PACKAGING,systemimage_unopt)
713BUILT_SYSTEMIMAGE_UNOPT := $(systemimage_unopt_intermediates)/system.img
714
715INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
716 $(ALL_PREBUILT) \
717 $(ALL_COPIED_HEADERS) \
718 $(ALL_GENERATED_SOURCES) \
719 $(ALL_DEFAULT_INSTALLED_MODULES))
720
Colin Cross0a7b2c52010-05-07 02:23:59 -0700721ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
722## generate an ext image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800723# $(1): output file
724define build-systemimage-target
725 @echo "Target system fs image: $(1)"
Colin Crosse0a40212010-08-03 14:43:34 -0700726 $(call build-userimage-ext-target,$(TARGET_OUT),$(1),system,$(INTERNAL_USERIMAGES_EXT_VARIANT),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800727endef
728
Colin Cross0a7b2c52010-05-07 02:23:59 -0700729else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800730
731## generate a yaffs2 image
732# $(1): output file
733define build-systemimage-target
734 @echo "Target system fs image: $(1)"
735 @mkdir -p $(dir $(1))
Dima Zavin11818982010-02-05 13:34:34 -0800736 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800737endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700738endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800739
Colin Cross144b0282010-05-10 13:04:47 -0700740$(BUILT_SYSTEMIMAGE_UNOPT): $(INTERNAL_SYSTEMIMAGE_FILES) \
741 $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800742 $(call build-systemimage-target,$@)
743
744# The installed image, which may be optimized or unoptimized.
745#
746INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
747
748ifdef WITH_DEXPREOPT
749 ifndef DISABLE_DEXPREOPT
750 with_dexpreopt := true
751 endif
752endif
753ifdef with_dexpreopt
754 # This file will set BUILT_SYSTEMIMAGE and SYSTEMIMAGE_SOURCE_DIR
755 include build/tools/dexpreopt/Config.mk
756else
757 BUILT_SYSTEMIMAGE := $(BUILT_SYSTEMIMAGE_UNOPT)
758 SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
759endif
760
Doug Zongker73ef8252009-07-23 15:12:53 -0700761# The system partition needs room for the recovery image as well. We
762# now store the recovery image as a binary patch using the boot image
763# as the source (since they are very similar). Generate the patch so
764# we can see how big it's going to be, and include that in the system
765# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700766ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700767intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
768RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
769$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
770 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700771 $(HOST_OUT_EXECUTABLES)/imgdiff \
772 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700773 @echo "Construct recovery from boot"
774 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700775 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700776endif
777
Doug Zongker73ef8252009-07-23 15:12:53 -0700778
779$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800780 @echo "Install system fs image: $@"
781 $(copy-file-to-target)
Doug Zongkered96e882009-08-26 09:37:07 -0700782 $(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 -0800783
784systemimage: $(INSTALLED_SYSTEMIMAGE)
785
786.PHONY: systemimage-nodeps snod
787systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -0700788 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800789 @echo "make $@: ignoring dependencies"
790 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
Doug Zongkered96e882009-08-26 09:37:07 -0700791 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800792
793#######
794## system tarball
795define build-systemtarball-target
796 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
797 $(MKTARBALL) $(FS_GET_STATS) \
798 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
799 $(INSTALLED_SYSTEMTARBALL_TARGET)
800endef
801
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700802ifndef SYSTEM_TARBALL_FORMAT
803 SYSTEM_TARBALL_FORMAT := bz2
804endif
805
The Android Open Source Project88b60792009-03-03 19:28:42 -0800806system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700807INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800808$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
809$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
810 $(build-systemtarball-target)
811
812.PHONY: systemtarball-nodeps
813systemtarball-nodeps: $(FS_GET_STATS) \
814 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
815 $(build-systemtarball-target)
816
817.PHONY: stnod
818stnod: systemtarball-nodeps
819
820
Bruce Beare52aac202010-06-04 15:24:49 -0700821#######
822## boot tarball
823define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -0700824 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -0700825 $(hide) mkdir -p $(PRODUCT_OUT)/boot
826 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
827 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
828 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
829 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
830 $(INSTALLED_BOOTTARBALL_TARGET)
831endef
832
833ifndef BOOT_TARBALL_FORMAT
834 BOOT_TARBALL_FORMAT := bz2
835endif
836
837boot_tar := $(PRODUCT_OUT)/boot.tar
838INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
839$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
840$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
841 $(build-boottarball-target)
842
843.PHONY: boottarball-nodeps btnod
844boottarball-nodeps btnod: $(FS_GET_STATS) \
845 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
846 $(build-boottarball-target)
847
848
The Android Open Source Project88b60792009-03-03 19:28:42 -0800849# -----------------------------------------------------------------
850# data partition image
851INTERNAL_USERDATAIMAGE_FILES := \
852 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
853
Colin Cross0a7b2c52010-05-07 02:23:59 -0700854ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800855## Generate an ext2 image
856define build-userdataimage-target
857 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
858 @mkdir -p $(TARGET_OUT_DATA)
Colin Crosse0a40212010-08-03 14:43:34 -0700859 $(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 -0700860 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800861endef
862
Colin Cross0a7b2c52010-05-07 02:23:59 -0700863else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800864
865## Generate a yaffs2 image
866define build-userdataimage-target
867 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
868 @mkdir -p $(TARGET_OUT_DATA)
Dima Zavin11818982010-02-05 13:34:34 -0800869 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
Doug Zongkered96e882009-08-26 09:37:07 -0700870 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800871endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700872endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800873
Joe Onorato64d85d02009-04-09 19:31:12 -0700874BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
875
876# We just build this directly to the install location.
877INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -0700878$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800879 $(INTERNAL_USERDATAIMAGE_FILES)
880 $(build-userdataimage-target)
881
882.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -0700883userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800884 $(build-userdataimage-target)
885
886#######
887## data partition tarball
888define build-userdatatarball-target
889 $(call pretty,"Target userdata fs tarball: " \
890 "$(INSTALLED_USERDATATARBALL_TARGET)")
891 $(MKTARBALL) $(FS_GET_STATS) \
892 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
893 $(INSTALLED_USERDATATARBALL_TARGET)
894endef
895
896userdata_tar := $(PRODUCT_OUT)/userdata.tar
897INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
898$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
899$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
900 $(build-userdatatarball-target)
901
902.PHONY: userdatatarball-nodeps
903userdatatarball-nodeps: $(FS_GET_STATS)
904 $(build-userdatatarball-target)
905
906
The Android Open Source Project88b60792009-03-03 19:28:42 -0800907# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800908# bring in the installer image generation defines if necessary
909ifeq ($(TARGET_USE_DISKINSTALLER),true)
910include bootable/diskinstaller/config.mk
911endif
912
913# -----------------------------------------------------------------
Doug Zongker8678df42009-06-15 14:30:14 -0700914# host tools needed to build OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -0800915
Ying Wang06898662010-06-17 17:52:18 -0700916OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -0700917 $(HOST_OUT_EXECUTABLES)/mkbootfs \
918 $(HOST_OUT_EXECUTABLES)/mkbootimg \
919 $(HOST_OUT_EXECUTABLES)/fs_config \
920 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
921 $(HOST_OUT_EXECUTABLES)/zipalign \
922 $(HOST_OUT_EXECUTABLES)/aapt \
923 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -0700924 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -0700925 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -0700926 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
927 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
928 $(HOST_OUT_EXECUTABLES)/genext2fs \
929 $(HOST_OUT_EXECUTABLES)/tune2fs \
930 $(HOST_OUT_EXECUTABLES)/e2fsck
931
The Android Open Source Project88b60792009-03-03 19:28:42 -0800932
Ying Wang06898662010-06-17 17:52:18 -0700933.PHONY: otatools
934otatools: $(OTATOOLS)
935
The Android Open Source Project88b60792009-03-03 19:28:42 -0800936# -----------------------------------------------------------------
937# A zip of the directories that map to the target filesystem.
938# This zip can be used to create an OTA package or filesystem image
939# as a post-build step.
940#
941name := $(TARGET_PRODUCT)
942ifeq ($(TARGET_BUILD_TYPE),debug)
943 name := $(name)_debug
944endif
945name := $(name)-target_files-$(FILE_NAME_TAG)
946
947intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
948BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
949$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
950$(BUILT_TARGET_FILES_PACKAGE): \
951 zip_root := $(intermediates)/$(name)
952
953# $(1): Directory to copy
954# $(2): Location to copy it to
955# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
956define package_files-copy-root
957 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
958 mkdir -p $(2) && \
959 $(ACP) -rd $(strip $(1))/* $(2); \
960 fi
961endef
962
963built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -0700964 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -0700965 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -0700966 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
967 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -0800968$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
969
Doug Zongkerb1134dd2009-06-17 17:09:40 -0700970$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
971
Doug Zongkerc18736b2009-09-30 09:20:32 -0700972ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
973# default to common dir for device vendor
974$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
975else
976$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
977endif
978
The Android Open Source Project88b60792009-03-03 19:28:42 -0800979# Depending on the various images guarantees that the underlying
980# directories are up-to-date.
981$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800982 $(INSTALLED_BOOTIMAGE_TARGET) \
983 $(INSTALLED_RADIOIMAGE_TARGET) \
984 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -0700985 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800986 $(INSTALLED_USERDATAIMAGE_TARGET) \
987 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800988 $(built_ota_tools) \
989 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -0700990 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800991 | $(ACP)
992 @echo "Package target files: $@"
993 $(hide) rm -rf $@ $(zip_root)
994 $(hide) mkdir -p $(dir $@) $(zip_root)
995 @# Components of the recovery image
996 $(hide) mkdir -p $(zip_root)/RECOVERY
997 $(hide) $(call package_files-copy-root, \
998 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
999ifdef INSTALLED_KERNEL_TARGET
1000 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
1001endif
1002ifdef INSTALLED_2NDBOOTLOADER_TARGET
1003 $(hide) $(ACP) \
1004 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
1005endif
1006ifdef BOARD_KERNEL_CMDLINE
1007 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
1008endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001009ifdef BOARD_KERNEL_BASE
1010 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
1011endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001012ifdef BOARD_KERNEL_PAGESIZE
1013 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
1014endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001015 @# Components of the boot image
1016 $(hide) mkdir -p $(zip_root)/BOOT
1017 $(hide) $(call package_files-copy-root, \
1018 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1019ifdef INSTALLED_KERNEL_TARGET
1020 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1021endif
1022ifdef INSTALLED_2NDBOOTLOADER_TARGET
1023 $(hide) $(ACP) \
1024 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1025endif
1026ifdef BOARD_KERNEL_CMDLINE
1027 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1028endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001029ifdef BOARD_KERNEL_BASE
1030 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1031endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001032ifdef BOARD_KERNEL_PAGESIZE
1033 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1034endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001035 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1036 mkdir -p $(zip_root)/RADIO; \
1037 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001038 @# Contents of the system image
1039 $(hide) $(call package_files-copy-root, \
1040 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1041 @# Contents of the data image
1042 $(hide) $(call package_files-copy-root, \
1043 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1044 @# Extra contents of the OTA package
1045 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001046 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1047 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001048 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001049 @# build them.
1050 $(hide) mkdir -p $(zip_root)/META
1051 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker17c83cf2009-04-01 15:48:46 -07001052 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -07001053 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001054ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07001055 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001056endif
1057ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
1058 $(hide) echo "boot_size=$(call image-size-from-data-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1059endif
1060ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
1061 $(hide) echo "recovery_size=$(call image-size-from-data-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1062endif
1063ifdef BOARD_SYSTEMIMAGE_PARTITION_SIZE
1064 $(hide) echo "system_size=$(call image-size-from-data-size,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1065endif
1066ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
1067 $(hide) echo "userdata_size=$(call image-size-from-data-size,$(BOARD_USERDATAIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1068endif
Doug Zongker37974732010-09-16 17:44:38 -07001069 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001070ifdef mkyaffs2_extra_flags
Doug Zongker37974732010-09-16 17:44:38 -07001071 $(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001072endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001073 @# Zip everything up, preserving symlinks
1074 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongker283e2a12010-03-15 17:52:32 -07001075 @# Run fs_config on all the system files in the zip, and save the output
1076 $(hide) zipinfo -1 $@ | awk -F/ 'BEGIN { OFS="/" } /^SYSTEM\// {$$1 = "system"; print}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
1077 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/filesystem_config.txt)
1078
The Android Open Source Project88b60792009-03-03 19:28:42 -08001079
1080target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1081
1082# -----------------------------------------------------------------
Doug Zongker8678df42009-06-15 14:30:14 -07001083# OTA update package
Doug Zongker367910f2009-06-15 18:56:51 -07001084
1085ifneq ($(TARGET_SIMULATOR),true)
1086ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang910dcbe2010-03-24 23:22:33 -07001087ifneq ($(TARGET_DEVICE),generic)
Ying Wangfb0a3472010-08-25 16:06:06 -07001088ifneq ($(TARGET_NO_KERNEL),true)
Doug Zongker367910f2009-06-15 18:56:51 -07001089
Doug Zongker8678df42009-06-15 14:30:14 -07001090name := $(TARGET_PRODUCT)
1091ifeq ($(TARGET_BUILD_TYPE),debug)
1092 name := $(name)_debug
1093endif
1094name := $(name)-ota-$(FILE_NAME_TAG)
1095
1096INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1097
1098$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1099
Ying Wang06898662010-06-17 17:52:18 -07001100$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001101 @echo "Package OTA: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001102 $(hide) ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker602a84e2009-06-18 08:35:12 -07001103 -p $(HOST_OUT) \
Doug Zongker8678df42009-06-15 14:30:14 -07001104 -k $(KEY_CERT_PAIR) \
1105 $(BUILT_TARGET_FILES_PACKAGE) $@
1106
1107.PHONY: otapackage
1108otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1109
Ying Wangfb0a3472010-08-25 16:06:06 -07001110endif # TARGET_NO_KERNEL != true
Ying Wang910dcbe2010-03-24 23:22:33 -07001111endif # TARGET_DEVICE != generic
Doug Zongker367910f2009-06-15 18:56:51 -07001112endif # TARGET_PRODUCT != sdk
1113endif # TARGET_SIMULATOR != true
Doug Zongker8678df42009-06-15 14:30:14 -07001114
1115# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001116# installed file list
1117# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it
1118# gets the DexOpt one if we're doing that.
1119INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
1120$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE)
1121 @echo Installed file list: $@
1122 @mkdir -p $(dir $@)
1123 @rm -f $@
1124 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@
1125
1126.PHONY: installed-file-list
1127installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wanga37a2cb2010-04-28 12:59:51 -07001128ifneq ($(filter sdk,$(MAKECMDGOALS)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001129$(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE))
Ying Wanga37a2cb2010-04-28 12:59:51 -07001130endif
1131ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
Joe Onorato03fbe402009-04-13 08:31:16 -07001132$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wanga37a2cb2010-04-28 12:59:51 -07001133endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001134
1135# -----------------------------------------------------------------
1136# A zip of the tests that are built when running "make tests".
1137# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
1138# only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
1139#
1140name := $(TARGET_PRODUCT)
1141ifeq ($(TARGET_BUILD_TYPE),debug)
1142 name := $(name)_debug
1143endif
1144name := $(name)-tests-$(FILE_NAME_TAG)
1145
1146intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
1147BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
1148$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
1149$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
1150
1151# Depending on the images guarantees that the underlying
1152# directories are up-to-date.
1153$(BUILT_TESTS_ZIP_PACKAGE): \
1154 $(BUILT_SYSTEMIMAGE) \
1155 $(INSTALLED_USERDATAIMAGE_TARGET) \
1156 | $(ACP)
1157 @echo "Package test files: $@"
1158 $(hide) rm -rf $@ $(zip_root)
1159 $(hide) mkdir -p $(dir $@) $(zip_root)
1160 @# Some parts of the system image
1161 $(hide) $(call package_files-copy-root, \
1162 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin)
1163 $(hide) $(call package_files-copy-root, \
1164 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib)
1165 $(hide) $(call package_files-copy-root, \
1166 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \
1167 $(zip_root)/SYSTEM/framework)
1168 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM
1169 @# Contents of the data image
1170 $(hide) $(call package_files-copy-root, \
1171 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1172 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
1173
Ying Wang9c762552010-09-10 14:39:33 -07001174.PHONY: tests-zip-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001175tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
1176
Ying Wangdb2cb632010-09-14 16:07:56 -07001177# Target needed by tests build
1178.PHONY: tests-build-target
1179tests-build-target: $(BUILT_TESTS_ZIP_PACKAGE) \
1180 $(BUILT_USERDATAIMAGE_TARGET)
1181
1182ifneq (,$(filter $(MAKECMDGOALS),tests-build-target))
1183 $(call dist-for-goals, tests-build-target, \
1184 $(BUILT_TESTS_ZIP_PACKAGE) \
1185 $(BUILT_USERDATAIMAGE_TARGET))
Ying Wang9c762552010-09-10 14:39:33 -07001186endif
1187
The Android Open Source Project88b60792009-03-03 19:28:42 -08001188# -----------------------------------------------------------------
1189# A zip of the symbols directory. Keep the full paths to make it
1190# more obvious where these files came from.
1191#
1192name := $(TARGET_PRODUCT)
1193ifeq ($(TARGET_BUILD_TYPE),debug)
1194 name := $(name)_debug
1195endif
1196name := $(name)-symbols-$(FILE_NAME_TAG)
1197
1198SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1199$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1200 @echo "Package symbols: $@"
1201 $(hide) rm -rf $@
1202 $(hide) mkdir -p $(dir $@)
1203 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1204
1205# -----------------------------------------------------------------
1206# A zip of the Android Apps. Not keeping full path so that we don't
1207# include product names when distributing
1208#
1209name := $(TARGET_PRODUCT)
1210ifeq ($(TARGET_BUILD_TYPE),debug)
1211 name := $(name)_debug
1212endif
1213name := $(name)-apps-$(FILE_NAME_TAG)
1214
1215APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1216$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1217 @echo "Package apps: $@"
1218 $(hide) rm -rf $@
1219 $(hide) mkdir -p $(dir $@)
1220 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
1221
Guang Zhu0198d6e2010-04-23 11:54:37 -07001222
1223#------------------------------------------------------------------
1224# A zip of emma code coverage meta files. Generated for fully emma
1225# instrumented build.
1226#
1227EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
1228$(EMMA_META_ZIP): $(INSTALLED_SYSTEMIMAGE)
1229 @echo "Collecting Emma coverage meta files."
1230 $(hide) find $(TARGET_COMMON_OUT_ROOT) -name "coverage.em" | \
1231 zip -@ -q $@
1232
The Android Open Source Project88b60792009-03-03 19:28:42 -08001233endif # TARGET_SIMULATOR != true
1234
1235# -----------------------------------------------------------------
1236# dalvik something
1237.PHONY: dalvikfiles
1238dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1239
1240# -----------------------------------------------------------------
1241# The update package
1242
Doug Zongker367910f2009-06-15 18:56:51 -07001243ifneq ($(TARGET_SIMULATOR),true)
1244ifneq ($(TARGET_PRODUCT),sdk)
1245
The Android Open Source Project88b60792009-03-03 19:28:42 -08001246name := $(TARGET_PRODUCT)
1247ifeq ($(TARGET_BUILD_TYPE),debug)
1248 name := $(name)_debug
1249endif
1250name := $(name)-img-$(FILE_NAME_TAG)
1251
1252INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1253
Doug Zongker659fc552009-06-23 09:46:33 -07001254ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1255# default to common dir for device vendor
1256$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_DEVICE_DIR)/../common
1257else
1258$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1259endif
1260
Ying Wang06898662010-06-17 17:52:18 -07001261$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001262 @echo "Package: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001263 $(hide) ./build/tools/releasetools/img_from_target_files -v \
Doug Zongker659fc552009-06-23 09:46:33 -07001264 -s $(extensions) \
Doug Zongker602a84e2009-06-18 08:35:12 -07001265 -p $(HOST_OUT) \
Doug Zongker8678df42009-06-15 14:30:14 -07001266 $(BUILT_TARGET_FILES_PACKAGE) $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001267
Doug Zongker8678df42009-06-15 14:30:14 -07001268.PHONY: updatepackage
1269updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001270
Doug Zongker367910f2009-06-15 18:56:51 -07001271endif # TARGET_PRODUCT != sdk
1272endif # TARGET_SIMULATOR != true
1273
The Android Open Source Project88b60792009-03-03 19:28:42 -08001274# -----------------------------------------------------------------
1275# The emulator package
1276
1277ifneq ($(TARGET_SIMULATOR),true)
1278
1279INTERNAL_EMULATOR_PACKAGE_FILES += \
1280 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
1281 prebuilt/android-arm/kernel/kernel-qemu \
1282 $(INSTALLED_RAMDISK_TARGET) \
1283 $(INSTALLED_SYSTEMIMAGE) \
1284 $(INSTALLED_USERDATAIMAGE_TARGET)
1285
1286name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1287
1288INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1289
1290$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1291 @echo "Package: $@"
1292 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1293
1294endif
1295
1296# -----------------------------------------------------------------
1297# The pdk package (Platform Development Kit)
1298
1299ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1300 include development/pdk/Pdk.mk
1301endif
1302
1303# -----------------------------------------------------------------
1304# The SDK
1305
1306ifneq ($(TARGET_SIMULATOR),true)
1307
1308# The SDK includes host-specific components, so it belongs under HOST_OUT.
1309sdk_dir := $(HOST_OUT)/sdk
1310
1311# Build a name that looks like:
1312#
1313# linux-x86 --> android-sdk_12345_linux-x86
1314# darwin-x86 --> android-sdk_12345_mac-x86
1315# windows-x86 --> android-sdk_12345_windows
1316#
1317sdk_name := android-sdk_$(FILE_NAME_TAG)
1318ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001319 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001320else
Joe Onorato03fbe402009-04-13 08:31:16 -07001321 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001322endif
1323ifneq ($(HOST_OS),windows)
Joe Onorato03fbe402009-04-13 08:31:16 -07001324 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001325endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001326sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001327
1328sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1329
1330ATREE_FILES :=
1331-include $(sdk_dep_file)
1332
1333# if we don't have a real list, then use "everything"
1334ifeq ($(strip $(ATREE_FILES)),)
1335ATREE_FILES := \
1336 $(ALL_PREBUILT) \
1337 $(ALL_COPIED_HEADERS) \
1338 $(ALL_GENERATED_SOURCES) \
1339 $(ALL_DEFAULT_INSTALLED_MODULES) \
1340 $(INSTALLED_RAMDISK_TARGET) \
1341 $(ALL_DOCS) \
1342 $(ALL_SDK_FILES)
1343endif
1344
1345atree_dir := development/build
1346
1347sdk_atree_files := \
1348 $(atree_dir)/sdk.exclude.atree \
1349 $(atree_dir)/sdk.atree \
1350 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree
1351
1352deps := \
1353 $(target_notice_file_txt) \
1354 $(tools_notice_file_txt) \
1355 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001356 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001357 $(INSTALLED_SYSTEMIMAGE) \
1358 $(INSTALLED_USERDATAIMAGE_TARGET) \
1359 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001360 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001361 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001362 $(ATREE_FILES) \
1363 $(atree_dir)/sdk.atree \
1364 $(HOST_OUT_EXECUTABLES)/atree \
1365 $(HOST_OUT_EXECUTABLES)/line_endings
1366
1367INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1368$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1369$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1370$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1371$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1372
1373# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1374#
1375#SDK_GNU_ERROR := true
1376
1377$(INTERNAL_SDK_TARGET): $(deps)
1378 @echo "Package SDK: $@"
1379 $(hide) rm -rf $(PRIVATE_DIR) $@
1380 $(hide) for f in $(target_gnu_MODULES); do \
1381 if [ -f $$f ]; then \
1382 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1383 including GNU target $$f >&2; \
1384 FAIL=$(SDK_GNU_ERROR); \
1385 fi; \
1386 done; \
1387 if [ $$FAIL ]; then exit 1; fi
1388 $(hide) ( \
1389 $(HOST_OUT_EXECUTABLES)/atree \
1390 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1391 -m $(PRIVATE_DEP_FILE) \
1392 -I . \
1393 -I $(PRODUCT_OUT) \
1394 -I $(HOST_OUT) \
1395 -I $(TARGET_COMMON_OUT_ROOT) \
1396 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
1397 -o $(PRIVATE_DIR) && \
1398 cp -f $(target_notice_file_txt) \
1399 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \
1400 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
1401 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Xavier Ducrohet1ae98802009-11-17 15:10:41 -08001402 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001403 chmod -R ug+rwX $(PRIVATE_DIR) && \
1404 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1405 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1406
Raphael3d224a02010-04-16 17:50:09 -07001407
1408# Is a Windows SDK requested? If so, we need some definitions from here
1409# in order to find the Linux SDK used to create the Windows one.
1410ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
1411LINUX_SDK_NAME := $(sdk_name)
1412LINUX_SDK_DIR := $(sdk_dir)
1413include $(TOPDIR)development/build/tools/windows_sdk.mk
1414endif
1415
The Android Open Source Project88b60792009-03-03 19:28:42 -08001416endif # !simulator
1417
1418# -----------------------------------------------------------------
1419# Findbugs
1420INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1421INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1422$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1423 @echo UnionBugs: $@
1424 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1425 > $@
1426$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1427 @echo ConvertXmlToText: $@
1428 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1429 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1430
1431# -----------------------------------------------------------------
1432# Findbugs
1433
1434# -----------------------------------------------------------------
1435# These are some additional build tasks that need to be run.
1436include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))