blob: 12ae657cb71370738c8fc5c379ce51604e1d0963 [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
Ying Wang026f1452010-09-27 17:49:03 -0700584# $(3): mount point
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# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -0700706# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800707#
Ying Wang02352372010-09-27 10:37:25 -0700708systemimage_intermediates := \
709 $(call intermediates-dir-for,PACKAGING,systemimage)
710BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
The Android Open Source Project88b60792009-03-03 19:28:42 -0800711
712INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
713 $(ALL_PREBUILT) \
714 $(ALL_COPIED_HEADERS) \
715 $(ALL_GENERATED_SOURCES) \
716 $(ALL_DEFAULT_INSTALLED_MODULES))
717
Colin Cross0a7b2c52010-05-07 02:23:59 -0700718ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
719## generate an ext image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800720# $(1): output file
721define build-systemimage-target
722 @echo "Target system fs image: $(1)"
Colin Crosse0a40212010-08-03 14:43:34 -0700723 $(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 -0800724endef
725
Colin Cross0a7b2c52010-05-07 02:23:59 -0700726else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800727
728## generate a yaffs2 image
729# $(1): output file
730define build-systemimage-target
731 @echo "Target system fs image: $(1)"
732 @mkdir -p $(dir $(1))
Dima Zavin11818982010-02-05 13:34:34 -0800733 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800734endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700735endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800736
Ying Wang02352372010-09-27 10:37:25 -0700737$(BUILT_SYSTEMIMAGE): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800738 $(call build-systemimage-target,$@)
739
The Android Open Source Project88b60792009-03-03 19:28:42 -0800740INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700741SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800742
Doug Zongker73ef8252009-07-23 15:12:53 -0700743# The system partition needs room for the recovery image as well. We
744# now store the recovery image as a binary patch using the boot image
745# as the source (since they are very similar). Generate the patch so
746# we can see how big it's going to be, and include that in the system
747# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700748ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700749intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
750RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
751$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
752 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700753 $(HOST_OUT_EXECUTABLES)/imgdiff \
754 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700755 @echo "Construct recovery from boot"
756 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700757 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700758endif
759
Doug Zongker73ef8252009-07-23 15:12:53 -0700760
761$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800762 @echo "Install system fs image: $@"
763 $(copy-file-to-target)
Doug Zongkered96e882009-08-26 09:37:07 -0700764 $(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 -0800765
766systemimage: $(INSTALLED_SYSTEMIMAGE)
767
768.PHONY: systemimage-nodeps snod
769systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -0700770 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800771 @echo "make $@: ignoring dependencies"
772 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
Doug Zongkered96e882009-08-26 09:37:07 -0700773 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800774
775#######
776## system tarball
777define build-systemtarball-target
778 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
779 $(MKTARBALL) $(FS_GET_STATS) \
780 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
781 $(INSTALLED_SYSTEMTARBALL_TARGET)
782endef
783
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700784ifndef SYSTEM_TARBALL_FORMAT
785 SYSTEM_TARBALL_FORMAT := bz2
786endif
787
The Android Open Source Project88b60792009-03-03 19:28:42 -0800788system_tar := $(PRODUCT_OUT)/system.tar
Bruce Beare69ef5ce2010-06-11 12:05:57 -0700789INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800790$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
791$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
792 $(build-systemtarball-target)
793
794.PHONY: systemtarball-nodeps
795systemtarball-nodeps: $(FS_GET_STATS) \
796 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
797 $(build-systemtarball-target)
798
799.PHONY: stnod
800stnod: systemtarball-nodeps
801
802
Bruce Beare52aac202010-06-04 15:24:49 -0700803#######
804## boot tarball
805define build-boottarball-target
Bruce Beare45ac4342010-06-24 14:02:00 -0700806 $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
Bruce Beare52aac202010-06-04 15:24:49 -0700807 $(hide) mkdir -p $(PRODUCT_OUT)/boot
808 $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
809 $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
810 $(hide) $(MKTARBALL) $(FS_GET_STATS) \
811 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
812 $(INSTALLED_BOOTTARBALL_TARGET)
813endef
814
815ifndef BOOT_TARBALL_FORMAT
816 BOOT_TARBALL_FORMAT := bz2
817endif
818
819boot_tar := $(PRODUCT_OUT)/boot.tar
820INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
821$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
822$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
823 $(build-boottarball-target)
824
825.PHONY: boottarball-nodeps btnod
826boottarball-nodeps btnod: $(FS_GET_STATS) \
827 $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
828 $(build-boottarball-target)
829
830
The Android Open Source Project88b60792009-03-03 19:28:42 -0800831# -----------------------------------------------------------------
832# data partition image
833INTERNAL_USERDATAIMAGE_FILES := \
834 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
835
Colin Cross0a7b2c52010-05-07 02:23:59 -0700836ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800837## Generate an ext2 image
838define build-userdataimage-target
839 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
840 @mkdir -p $(TARGET_OUT_DATA)
Ying Wang026f1452010-09-27 17:49:03 -0700841 $(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 -0700842 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800843endef
844
Colin Cross0a7b2c52010-05-07 02:23:59 -0700845else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800846
847## Generate a yaffs2 image
848define build-userdataimage-target
849 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
850 @mkdir -p $(TARGET_OUT_DATA)
Dima Zavin11818982010-02-05 13:34:34 -0800851 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
Doug Zongkered96e882009-08-26 09:37:07 -0700852 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800853endef
Colin Cross0a7b2c52010-05-07 02:23:59 -0700854endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800855
Joe Onorato64d85d02009-04-09 19:31:12 -0700856BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
857
858# We just build this directly to the install location.
859INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Colin Cross144b0282010-05-10 13:04:47 -0700860$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800861 $(INTERNAL_USERDATAIMAGE_FILES)
862 $(build-userdataimage-target)
863
864.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -0700865userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800866 $(build-userdataimage-target)
867
868#######
869## data partition tarball
870define build-userdatatarball-target
871 $(call pretty,"Target userdata fs tarball: " \
872 "$(INSTALLED_USERDATATARBALL_TARGET)")
873 $(MKTARBALL) $(FS_GET_STATS) \
874 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
875 $(INSTALLED_USERDATATARBALL_TARGET)
876endef
877
878userdata_tar := $(PRODUCT_OUT)/userdata.tar
879INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
880$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
881$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
882 $(build-userdatatarball-target)
883
884.PHONY: userdatatarball-nodeps
885userdatatarball-nodeps: $(FS_GET_STATS)
886 $(build-userdatatarball-target)
887
888
The Android Open Source Project88b60792009-03-03 19:28:42 -0800889# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800890# bring in the installer image generation defines if necessary
891ifeq ($(TARGET_USE_DISKINSTALLER),true)
892include bootable/diskinstaller/config.mk
893endif
894
895# -----------------------------------------------------------------
Doug Zongker8678df42009-06-15 14:30:14 -0700896# host tools needed to build OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -0800897
Ying Wang06898662010-06-17 17:52:18 -0700898OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -0700899 $(HOST_OUT_EXECUTABLES)/mkbootfs \
900 $(HOST_OUT_EXECUTABLES)/mkbootimg \
901 $(HOST_OUT_EXECUTABLES)/fs_config \
902 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
903 $(HOST_OUT_EXECUTABLES)/zipalign \
904 $(HOST_OUT_EXECUTABLES)/aapt \
905 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -0700906 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -0700907 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Ying Wang933abf12010-06-16 14:31:34 -0700908 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
909 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
910 $(HOST_OUT_EXECUTABLES)/genext2fs \
911 $(HOST_OUT_EXECUTABLES)/tune2fs \
912 $(HOST_OUT_EXECUTABLES)/e2fsck
913
The Android Open Source Project88b60792009-03-03 19:28:42 -0800914
Ying Wang06898662010-06-17 17:52:18 -0700915.PHONY: otatools
916otatools: $(OTATOOLS)
917
The Android Open Source Project88b60792009-03-03 19:28:42 -0800918# -----------------------------------------------------------------
919# A zip of the directories that map to the target filesystem.
920# This zip can be used to create an OTA package or filesystem image
921# as a post-build step.
922#
923name := $(TARGET_PRODUCT)
924ifeq ($(TARGET_BUILD_TYPE),debug)
925 name := $(name)_debug
926endif
927name := $(name)-target_files-$(FILE_NAME_TAG)
928
929intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
930BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
931$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
932$(BUILT_TARGET_FILES_PACKAGE): \
933 zip_root := $(intermediates)/$(name)
934
935# $(1): Directory to copy
936# $(2): Location to copy it to
937# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
938define package_files-copy-root
939 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
940 mkdir -p $(2) && \
941 $(ACP) -rd $(strip $(1))/* $(2); \
942 fi
943endef
944
945built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -0700946 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -0700947 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -0700948 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
949 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -0800950$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
951
Doug Zongkerb1134dd2009-06-17 17:09:40 -0700952$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
953
Doug Zongkerc18736b2009-09-30 09:20:32 -0700954ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
955# default to common dir for device vendor
956$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
957else
958$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
959endif
960
The Android Open Source Project88b60792009-03-03 19:28:42 -0800961# Depending on the various images guarantees that the underlying
962# directories are up-to-date.
963$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800964 $(INSTALLED_BOOTIMAGE_TARGET) \
965 $(INSTALLED_RADIOIMAGE_TARGET) \
966 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -0700967 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800968 $(INSTALLED_USERDATAIMAGE_TARGET) \
969 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800970 $(built_ota_tools) \
971 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -0700972 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800973 | $(ACP)
974 @echo "Package target files: $@"
975 $(hide) rm -rf $@ $(zip_root)
976 $(hide) mkdir -p $(dir $@) $(zip_root)
977 @# Components of the recovery image
978 $(hide) mkdir -p $(zip_root)/RECOVERY
979 $(hide) $(call package_files-copy-root, \
980 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
981ifdef INSTALLED_KERNEL_TARGET
982 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
983endif
984ifdef INSTALLED_2NDBOOTLOADER_TARGET
985 $(hide) $(ACP) \
986 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
987endif
988ifdef BOARD_KERNEL_CMDLINE
989 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
990endif
Doug Zongker38a649f2009-06-17 09:07:09 -0700991ifdef BOARD_KERNEL_BASE
992 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
993endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700994ifdef BOARD_KERNEL_PAGESIZE
995 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
996endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800997 @# Components of the boot image
998 $(hide) mkdir -p $(zip_root)/BOOT
999 $(hide) $(call package_files-copy-root, \
1000 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
1001ifdef INSTALLED_KERNEL_TARGET
1002 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
1003endif
1004ifdef INSTALLED_2NDBOOTLOADER_TARGET
1005 $(hide) $(ACP) \
1006 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
1007endif
1008ifdef BOARD_KERNEL_CMDLINE
1009 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
1010endif
Doug Zongker38a649f2009-06-17 09:07:09 -07001011ifdef BOARD_KERNEL_BASE
1012 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
1013endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001014ifdef BOARD_KERNEL_PAGESIZE
1015 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
1016endif
Doug Zongkere01100c2009-06-19 17:12:18 -07001017 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
1018 mkdir -p $(zip_root)/RADIO; \
1019 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001020 @# Contents of the system image
1021 $(hide) $(call package_files-copy-root, \
1022 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
1023 @# Contents of the data image
1024 $(hide) $(call package_files-copy-root, \
1025 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1026 @# Extra contents of the OTA package
1027 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -08001028 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
1029 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -07001030 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08001031 @# build them.
1032 $(hide) mkdir -p $(zip_root)/META
1033 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker17c83cf2009-04-01 15:48:46 -07001034 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -07001035 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001036ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -07001037 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerb4c7d322010-07-01 15:30:11 -07001038endif
1039ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
1040 $(hide) echo "boot_size=$(call image-size-from-data-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1041endif
1042ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
1043 $(hide) echo "recovery_size=$(call image-size-from-data-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1044endif
1045ifdef BOARD_SYSTEMIMAGE_PARTITION_SIZE
1046 $(hide) echo "system_size=$(call image-size-from-data-size,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1047endif
1048ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
1049 $(hide) echo "userdata_size=$(call image-size-from-data-size,$(BOARD_USERDATAIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/misc_info.txt
1050endif
Doug Zongker37974732010-09-16 17:44:38 -07001051 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001052ifdef mkyaffs2_extra_flags
Doug Zongker37974732010-09-16 17:44:38 -07001053 $(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001054endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001055 @# Zip everything up, preserving symlinks
1056 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongker283e2a12010-03-15 17:52:32 -07001057 @# Run fs_config on all the system files in the zip, and save the output
1058 $(hide) zipinfo -1 $@ | awk -F/ 'BEGIN { OFS="/" } /^SYSTEM\// {$$1 = "system"; print}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
1059 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/filesystem_config.txt)
1060
The Android Open Source Project88b60792009-03-03 19:28:42 -08001061
1062target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1063
Doug Zongker367910f2009-06-15 18:56:51 -07001064
1065ifneq ($(TARGET_SIMULATOR),true)
1066ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang910dcbe2010-03-24 23:22:33 -07001067ifneq ($(TARGET_DEVICE),generic)
Ying Wangfb0a3472010-08-25 16:06:06 -07001068ifneq ($(TARGET_NO_KERNEL),true)
Doug Zongker367910f2009-06-15 18:56:51 -07001069
Ying Wang09a00a62010-10-20 14:01:09 -07001070# -----------------------------------------------------------------
1071# OTA update package
1072
Doug Zongker8678df42009-06-15 14:30:14 -07001073name := $(TARGET_PRODUCT)
1074ifeq ($(TARGET_BUILD_TYPE),debug)
1075 name := $(name)_debug
1076endif
1077name := $(name)-ota-$(FILE_NAME_TAG)
1078
1079INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1080
1081$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1082
Ying Wang06898662010-06-17 17:52:18 -07001083$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001084 @echo "Package OTA: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001085 $(hide) ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker602a84e2009-06-18 08:35:12 -07001086 -p $(HOST_OUT) \
Doug Zongker8678df42009-06-15 14:30:14 -07001087 -k $(KEY_CERT_PAIR) \
1088 $(BUILT_TARGET_FILES_PACKAGE) $@
1089
1090.PHONY: otapackage
1091otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1092
Ying Wang09a00a62010-10-20 14:01:09 -07001093# -----------------------------------------------------------------
1094# The update package
1095
1096name := $(TARGET_PRODUCT)
1097ifeq ($(TARGET_BUILD_TYPE),debug)
1098 name := $(name)_debug
1099endif
1100name := $(name)-img-$(FILE_NAME_TAG)
1101
1102INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1103
1104ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1105# default to common dir for device vendor
1106$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_DEVICE_DIR)/../common
1107else
1108$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1109endif
1110
1111$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
1112 @echo "Package: $@"
1113 $(hide) ./build/tools/releasetools/img_from_target_files -v \
1114 -s $(extensions) \
1115 -p $(HOST_OUT) \
1116 $(BUILT_TARGET_FILES_PACKAGE) $@
1117
1118.PHONY: updatepackage
1119updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
1120
Ying Wangfb0a3472010-08-25 16:06:06 -07001121endif # TARGET_NO_KERNEL != true
Ying Wang910dcbe2010-03-24 23:22:33 -07001122endif # TARGET_DEVICE != generic
Doug Zongker367910f2009-06-15 18:56:51 -07001123endif # TARGET_PRODUCT != sdk
1124endif # TARGET_SIMULATOR != true
Doug Zongker8678df42009-06-15 14:30:14 -07001125
1126# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001127# installed file list
1128# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it
1129# gets the DexOpt one if we're doing that.
1130INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
1131$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE)
1132 @echo Installed file list: $@
1133 @mkdir -p $(dir $@)
1134 @rm -f $@
1135 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@
1136
1137.PHONY: installed-file-list
1138installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wanga37a2cb2010-04-28 12:59:51 -07001139ifneq ($(filter sdk,$(MAKECMDGOALS)),)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001140$(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE))
Ying Wanga37a2cb2010-04-28 12:59:51 -07001141endif
1142ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
Joe Onorato03fbe402009-04-13 08:31:16 -07001143$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wanga37a2cb2010-04-28 12:59:51 -07001144endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001145
1146# -----------------------------------------------------------------
1147# A zip of the tests that are built when running "make tests".
1148# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
1149# only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
1150#
1151name := $(TARGET_PRODUCT)
1152ifeq ($(TARGET_BUILD_TYPE),debug)
1153 name := $(name)_debug
1154endif
1155name := $(name)-tests-$(FILE_NAME_TAG)
1156
1157intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
1158BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
1159$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
1160$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
1161
1162# Depending on the images guarantees that the underlying
1163# directories are up-to-date.
1164$(BUILT_TESTS_ZIP_PACKAGE): \
1165 $(BUILT_SYSTEMIMAGE) \
1166 $(INSTALLED_USERDATAIMAGE_TARGET) \
1167 | $(ACP)
1168 @echo "Package test files: $@"
1169 $(hide) rm -rf $@ $(zip_root)
1170 $(hide) mkdir -p $(dir $@) $(zip_root)
1171 @# Some parts of the system image
1172 $(hide) $(call package_files-copy-root, \
1173 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin)
1174 $(hide) $(call package_files-copy-root, \
1175 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib)
1176 $(hide) $(call package_files-copy-root, \
1177 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \
1178 $(zip_root)/SYSTEM/framework)
1179 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM
1180 @# Contents of the data image
1181 $(hide) $(call package_files-copy-root, \
1182 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1183 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
1184
Ying Wang9c762552010-09-10 14:39:33 -07001185.PHONY: tests-zip-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001186tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
1187
Ying Wangdb2cb632010-09-14 16:07:56 -07001188# Target needed by tests build
1189.PHONY: tests-build-target
1190tests-build-target: $(BUILT_TESTS_ZIP_PACKAGE) \
1191 $(BUILT_USERDATAIMAGE_TARGET)
1192
1193ifneq (,$(filter $(MAKECMDGOALS),tests-build-target))
1194 $(call dist-for-goals, tests-build-target, \
1195 $(BUILT_TESTS_ZIP_PACKAGE) \
1196 $(BUILT_USERDATAIMAGE_TARGET))
Ying Wang9c762552010-09-10 14:39:33 -07001197endif
1198
The Android Open Source Project88b60792009-03-03 19:28:42 -08001199# -----------------------------------------------------------------
1200# A zip of the symbols directory. Keep the full paths to make it
1201# more obvious where these files came from.
1202#
1203name := $(TARGET_PRODUCT)
1204ifeq ($(TARGET_BUILD_TYPE),debug)
1205 name := $(name)_debug
1206endif
1207name := $(name)-symbols-$(FILE_NAME_TAG)
1208
1209SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1210$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1211 @echo "Package symbols: $@"
1212 $(hide) rm -rf $@
1213 $(hide) mkdir -p $(dir $@)
1214 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1215
1216# -----------------------------------------------------------------
1217# A zip of the Android Apps. Not keeping full path so that we don't
1218# include product names when distributing
1219#
1220name := $(TARGET_PRODUCT)
1221ifeq ($(TARGET_BUILD_TYPE),debug)
1222 name := $(name)_debug
1223endif
1224name := $(name)-apps-$(FILE_NAME_TAG)
1225
1226APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1227$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1228 @echo "Package apps: $@"
1229 $(hide) rm -rf $@
1230 $(hide) mkdir -p $(dir $@)
1231 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
1232
Guang Zhu0198d6e2010-04-23 11:54:37 -07001233
1234#------------------------------------------------------------------
1235# A zip of emma code coverage meta files. Generated for fully emma
1236# instrumented build.
1237#
1238EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
1239$(EMMA_META_ZIP): $(INSTALLED_SYSTEMIMAGE)
1240 @echo "Collecting Emma coverage meta files."
1241 $(hide) find $(TARGET_COMMON_OUT_ROOT) -name "coverage.em" | \
1242 zip -@ -q $@
1243
The Android Open Source Project88b60792009-03-03 19:28:42 -08001244endif # TARGET_SIMULATOR != true
1245
1246# -----------------------------------------------------------------
1247# dalvik something
1248.PHONY: dalvikfiles
1249dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1250
1251# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001252# The emulator package
1253
1254ifneq ($(TARGET_SIMULATOR),true)
1255
1256INTERNAL_EMULATOR_PACKAGE_FILES += \
1257 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
1258 prebuilt/android-arm/kernel/kernel-qemu \
1259 $(INSTALLED_RAMDISK_TARGET) \
1260 $(INSTALLED_SYSTEMIMAGE) \
1261 $(INSTALLED_USERDATAIMAGE_TARGET)
1262
1263name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1264
1265INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1266
1267$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1268 @echo "Package: $@"
1269 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1270
1271endif
1272
1273# -----------------------------------------------------------------
1274# The pdk package (Platform Development Kit)
1275
1276ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1277 include development/pdk/Pdk.mk
1278endif
1279
1280# -----------------------------------------------------------------
1281# The SDK
1282
1283ifneq ($(TARGET_SIMULATOR),true)
1284
1285# The SDK includes host-specific components, so it belongs under HOST_OUT.
1286sdk_dir := $(HOST_OUT)/sdk
1287
1288# Build a name that looks like:
1289#
1290# linux-x86 --> android-sdk_12345_linux-x86
1291# darwin-x86 --> android-sdk_12345_mac-x86
1292# windows-x86 --> android-sdk_12345_windows
1293#
1294sdk_name := android-sdk_$(FILE_NAME_TAG)
1295ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001296 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001297else
Joe Onorato03fbe402009-04-13 08:31:16 -07001298 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001299endif
1300ifneq ($(HOST_OS),windows)
Joe Onorato03fbe402009-04-13 08:31:16 -07001301 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001302endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001303sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001304
1305sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1306
1307ATREE_FILES :=
1308-include $(sdk_dep_file)
1309
1310# if we don't have a real list, then use "everything"
1311ifeq ($(strip $(ATREE_FILES)),)
1312ATREE_FILES := \
1313 $(ALL_PREBUILT) \
1314 $(ALL_COPIED_HEADERS) \
1315 $(ALL_GENERATED_SOURCES) \
1316 $(ALL_DEFAULT_INSTALLED_MODULES) \
1317 $(INSTALLED_RAMDISK_TARGET) \
1318 $(ALL_DOCS) \
1319 $(ALL_SDK_FILES)
1320endif
1321
1322atree_dir := development/build
1323
1324sdk_atree_files := \
1325 $(atree_dir)/sdk.exclude.atree \
1326 $(atree_dir)/sdk.atree \
Xavier Ducrohetffd50872010-09-27 15:51:32 -07001327 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree \
1328 sdk/build/tools.atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08001329
1330deps := \
1331 $(target_notice_file_txt) \
1332 $(tools_notice_file_txt) \
1333 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001334 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001335 $(INSTALLED_SYSTEMIMAGE) \
1336 $(INSTALLED_USERDATAIMAGE_TARGET) \
1337 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001338 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001339 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001340 $(ATREE_FILES) \
1341 $(atree_dir)/sdk.atree \
Xavier Ducrohetffd50872010-09-27 15:51:32 -07001342 sdk/build/tools.atree \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001343 $(HOST_OUT_EXECUTABLES)/atree \
1344 $(HOST_OUT_EXECUTABLES)/line_endings
1345
1346INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1347$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1348$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1349$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1350$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1351
1352# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1353#
1354#SDK_GNU_ERROR := true
1355
1356$(INTERNAL_SDK_TARGET): $(deps)
1357 @echo "Package SDK: $@"
1358 $(hide) rm -rf $(PRIVATE_DIR) $@
1359 $(hide) for f in $(target_gnu_MODULES); do \
1360 if [ -f $$f ]; then \
1361 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1362 including GNU target $$f >&2; \
1363 FAIL=$(SDK_GNU_ERROR); \
1364 fi; \
1365 done; \
1366 if [ $$FAIL ]; then exit 1; fi
1367 $(hide) ( \
1368 $(HOST_OUT_EXECUTABLES)/atree \
1369 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1370 -m $(PRIVATE_DEP_FILE) \
1371 -I . \
1372 -I $(PRODUCT_OUT) \
1373 -I $(HOST_OUT) \
1374 -I $(TARGET_COMMON_OUT_ROOT) \
1375 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
1376 -o $(PRIVATE_DIR) && \
1377 cp -f $(target_notice_file_txt) \
1378 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \
1379 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
1380 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Xavier Ducrohet1ae98802009-11-17 15:10:41 -08001381 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001382 chmod -R ug+rwX $(PRIVATE_DIR) && \
1383 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1384 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1385
Raphael3d224a02010-04-16 17:50:09 -07001386
1387# Is a Windows SDK requested? If so, we need some definitions from here
1388# in order to find the Linux SDK used to create the Windows one.
1389ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
1390LINUX_SDK_NAME := $(sdk_name)
1391LINUX_SDK_DIR := $(sdk_dir)
1392include $(TOPDIR)development/build/tools/windows_sdk.mk
1393endif
1394
The Android Open Source Project88b60792009-03-03 19:28:42 -08001395endif # !simulator
1396
1397# -----------------------------------------------------------------
1398# Findbugs
1399INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1400INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1401$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1402 @echo UnionBugs: $@
1403 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1404 > $@
1405$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1406 @echo ConvertXmlToText: $@
1407 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1408 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1409
1410# -----------------------------------------------------------------
1411# Findbugs
1412
1413# -----------------------------------------------------------------
1414# These are some additional build tasks that need to be run.
1415include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))