blob: f4669f27be0f5b21ac2298cb082303ffccdb8e70 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Put some miscellaneous rules here
2
3# Pick a reasonable string to use to identify files.
4ifneq "" "$(filter eng.%,$(BUILD_NUMBER))"
5 # BUILD_NUMBER has a timestamp in it, which means that
6 # it will change every time. Pick a stable value.
7 FILE_NAME_TAG := eng.$(USER)
8else
9 FILE_NAME_TAG := $(BUILD_NUMBER)
10endif
11
12# -----------------------------------------------------------------
13# Define rules to copy PRODUCT_COPY_FILES defined by the product.
14# PRODUCT_COPY_FILES contains words like <source file>:<dest file>.
15# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
16# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080017# The filter part means "only eval the copy-one-file rule if this
Ying Wang9238d442010-11-02 21:31:47 -070018# src:dest pair is the first one to match the same dest"
19unique_product_copy_files_destinations := $(sort \
20 $(foreach cf,$(PRODUCT_COPY_FILES), $(call word-colon,2,$(cf))))
The Android Open Source Project88b60792009-03-03 19:28:42 -080021$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang9238d442010-11-02 21:31:47 -070022 $(eval _src := $(call word-colon,1,$(cf))) \
23 $(eval _dest := $(call word-colon,2,$(cf))) \
24 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
25 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
26 $(eval $(call copy-one-file,$(_src),$(_fulldest))) \
27 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
28 $(eval unique_product_copy_files_destinations := $(filter-out $(_dest), \
29 $(unique_product_copy_files_destinations)))))
The Android Open Source Project88b60792009-03-03 19:28:42 -080030
31# -----------------------------------------------------------------
32# docs/index.html
33gen := $(OUT_DOCS)/index.html
34ALL_DOCS += $(gen)
35$(gen): frameworks/base/docs/docs-redirect-index.html
36 @mkdir -p $(dir $@)
37 @cp -f $< $@
38
39# -----------------------------------------------------------------
40# default.prop
41INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
42ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
43ADDITIONAL_DEFAULT_PROPERTIES := \
44 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
45
46$(INSTALLED_DEFAULT_PROP_TARGET):
47 @echo Target buildinfo: $@
48 @mkdir -p $(dir $@)
49 $(hide) echo "#" > $@; \
50 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
51 echo "#" >> $@;
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -070052 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
53 echo "$(line)" >> $@;)
The Android Open Source Project88b60792009-03-03 19:28:42 -080054
55# -----------------------------------------------------------------
56# build.prop
57INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
58ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
59ADDITIONAL_BUILD_PROPERTIES := \
60 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
61
62# A list of arbitrary tags describing the build configuration.
63# Force ":=" so we can use +=
64BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
65ifeq ($(TARGET_BUILD_TYPE),debug)
66 BUILD_VERSION_TAGS += debug
67endif
68# Apps are always signed with test keys, and may be re-signed in a post-build
69# step. If that happens, the "test-keys" tag will be removed by that step.
70BUILD_VERSION_TAGS += test-keys
The Android Open Source Project88b60792009-03-03 19:28:42 -080071BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
72
73# A human-readable string that descibes this build in detail.
74build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)
75$(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc)
76
77# The string used to uniquely identify this build; used by the OTA server.
78ifeq (,$(strip $(BUILD_FINGERPRINT)))
Doug Zongker135a1202010-09-15 13:02:12 -070079 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
The Android Open Source Project88b60792009-03-03 19:28:42 -080080endif
81ifneq ($(words $(BUILD_FINGERPRINT)),1)
82 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
83endif
84
Sriram Raman7b641242009-03-24 22:40:59 -070085# Display parameters shown under Settings -> About Phone
86ifeq ($(TARGET_BUILD_VARIANT),user)
87 # User builds should show:
88 # release build number or branch.buld_number non-release builds
89
90 # Dev. branches should have DISPLAY_BUILD_NUMBER set
91 ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
92 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER)
93 else
94 BUILD_DISPLAY_ID := $(BUILD_ID)
95 endif
96else
97 # Non-user builds should show detailed build information
98 BUILD_DISPLAY_ID := $(build_desc)
99endif
100
The Android Open Source Project88b60792009-03-03 19:28:42 -0800101# Selects the first locale in the list given as the argument,
102# and splits it into language and region, which each may be
103# empty.
104define default-locale
105$(subst _, , $(firstword $(1)))
106endef
107
108# Selects the first locale in the list given as the argument
109# and returns the language (or the region)
110define default-locale-language
111$(word 2, 2, $(call default-locale, $(1)))
112endef
113define default-locale-region
114$(word 3, 3, $(call default-locale, $(1)))
115endef
116
117BUILDINFO_SH := build/tools/buildinfo.sh
118$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE)
119 @echo Target buildinfo: $@
120 @mkdir -p $(dir $@)
121 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
122 TARGET_DEVICE="$(TARGET_DEVICE)" \
123 PRODUCT_NAME="$(TARGET_PRODUCT)" \
124 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
125 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
126 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
Robert Greenwaltfbd10d92009-05-20 13:37:35 -0700127 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800128 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
129 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
130 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
131 BUILD_ID="$(BUILD_ID)" \
132 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
133 BUILD_NUMBER="$(BUILD_NUMBER)" \
134 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
135 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
Dianne Hackborn95378842009-05-08 12:06:17 -0700136 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800137 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
138 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
139 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
140 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
Dianne Hackbornecc70d72009-05-21 15:45:30 -0700141 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
David 'Digit' Turner2edfb712009-11-06 15:12:00 -0800142 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800143 bash $(BUILDINFO_SH) > $@
144 $(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \
145 cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \
146 fi
147 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
148 $(hide) echo >> $@; \
149 echo "#" >> $@; \
150 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
151 echo "#" >> $@; )
Jean-Baptiste Queru0545c912010-09-07 10:51:12 -0700152 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
153 echo "$(line)" >> $@;)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800154
155build_desc :=
156
157# -----------------------------------------------------------------
158# sdk-build.prop
159#
160# There are certain things in build.prop that we don't want to
161# ship with the sdk; remove them.
162
163# This must be a list of entire property keys followed by
164# "=" characters, without any internal spaces.
165sdk_build_prop_remove := \
166 ro.build.user= \
167 ro.build.host= \
168 ro.product.brand= \
169 ro.product.manufacturer= \
170 ro.product.device=
171# TODO: Remove this soon-to-be obsolete property
172sdk_build_prop_remove += ro.build.product=
173INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
174$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
175 @echo SDK buildinfo: $@
176 @mkdir -p $(dir $@)
177 $(hide) grep -v "$(subst $(space),\|,$(strip \
178 $(sdk_build_prop_remove)))" $< > $@.tmp
179 $(hide) for x in $(sdk_build_prop_remove); do \
180 echo "$$x"generic >> $@.tmp; done
181 $(hide) mv $@.tmp $@
182
183# -----------------------------------------------------------------
184# package stats
185PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
186PACKAGES_TO_STAT := \
187 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
188 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
189$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
190 @echo Package stats: $@
191 @mkdir -p $(dir $@)
192 $(hide) rm -f $@
193 $(hide) build/tools/dump-package-stats $^ > $@
194
195.PHONY: package-stats
196package-stats: $(PACKAGE_STATS_FILE)
197
198# -----------------------------------------------------------------
199# Cert-to-package mapping. Used by the post-build signing tools.
200name := $(TARGET_PRODUCT)
201ifeq ($(TARGET_BUILD_TYPE),debug)
202 name := $(name)_debug
203endif
204name := $(name)-apkcerts-$(FILE_NAME_TAG)
205intermediates := \
206 $(call intermediates-dir-for,PACKAGING,apkcerts)
207APKCERTS_FILE := $(intermediates)/$(name).txt
208# Depending on the built packages isn't exactly right,
209# but it should guarantee that the apkcerts file is rebuilt
210# if any packages change which certs they're signed with.
211all_built_packages := $(foreach p,$(PACKAGES),$(ALL_MODULES.$(p).BUILT))
Ying Wangefb21682010-07-23 16:42:13 -0700212ifneq ($(TARGET_BUILD_APPS),)
213# We don't need to really build all the modules for apps_only build.
214$(APKCERTS_FILE):
215else
The Android Open Source Project88b60792009-03-03 19:28:42 -0800216$(APKCERTS_FILE): $(all_built_packages)
Ying Wangefb21682010-07-23 16:42:13 -0700217endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800218 @echo APK certs list: $@
219 @mkdir -p $(dir $@)
220 @rm -f $@
221 $(hide) $(foreach p,$(PACKAGES),\
Doug Zongkerf6a53aa2009-12-15 15:06:55 -0800222 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
223 echo 'name="$(p).apk" certificate="EXTERNAL" \
224 private_key=""' >> $@;,\
225 echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
226 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800227
228.PHONY: apkcerts-list
229apkcerts-list: $(APKCERTS_FILE)
230
Ying Wangefb21682010-07-23 16:42:13 -0700231$(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
232
The Android Open Source Project88b60792009-03-03 19:28:42 -0800233# -----------------------------------------------------------------
234# module info file
235ifdef CREATE_MODULE_INFO_FILE
236 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
237 $(info Generating $(MODULE_INFO_FILE)...)
238 $(shell rm -f $(MODULE_INFO_FILE))
239 $(foreach m,$(ALL_MODULES), \
240 $(shell echo "NAME=\"$(m)\"" \
241 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
242 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
243 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
244 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
245endif
246
Doug Zongker8678df42009-06-15 14:30:14 -0700247# -----------------------------------------------------------------
248
249# The test key is used to sign this package, and as the key required
250# for future OTA packages installed by this system. Actual product
251# deliverables will be re-signed by hand. We expect this file to
252# exist with the suffixes ".x509.pem" and ".pk8".
253DEFAULT_KEY_CERT_PAIR := $(SRC_TARGET_DIR)/product/security/testkey
254
255
The Android Open Source Project88b60792009-03-03 19:28:42 -0800256# Rules that need to be present for the simulator, even
257# if they don't do anything.
258.PHONY: systemimage
259systemimage:
260
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800261# -----------------------------------------------------------------
262
263.PHONY: event-log-tags
264
Joe Onoratob7510532010-07-14 10:22:54 -0700265# Produce an event logs tag file for everything we know about, in order
266# to properly allocate numbers. Then produce a file that's filtered
267# for what's going to be installed.
268
269all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
270
271# Include tags from all packages that we know about
272all_event_log_tags_src := \
273 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
274
275$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
276$(all_event_log_tags_file): $(all_event_log_tags_src)
277 $(hide) mkdir -p $(dir $@)
278 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
279
280
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800281event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800282
Doug Zongkera34fa952011-02-23 12:17:29 -0800283# Include tags from all packages included in this product, plus all
284# tags that are part of the system (ie, not in a vendor/ or device/
285# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800286event_log_tags_src := \
287 $(sort $(foreach m,\
288 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
289 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800290 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
291 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800292
293$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700294$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
295$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800296 $(hide) mkdir -p $(dir $@)
Joe Onoratob7510532010-07-14 10:22:54 -0700297 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800298
299event-log-tags: $(event_log_tags_file)
300
301ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
302
Joe Onoratob7510532010-07-14 10:22:54 -0700303
The Android Open Source Project88b60792009-03-03 19:28:42 -0800304ifneq ($(TARGET_SIMULATOR),true)
305
306# #################################################################
307# Targets for boot/OS images
308# #################################################################
309
310# -----------------------------------------------------------------
311# the ramdisk
312INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
313 $(ALL_PREBUILT) \
314 $(ALL_COPIED_HEADERS) \
315 $(ALL_GENERATED_SOURCES) \
316 $(ALL_DEFAULT_INSTALLED_MODULES))
317
Joe Onorato64d85d02009-04-09 19:31:12 -0700318BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
319
320# We just build this directly to the install location.
321INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700322$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800323 $(call pretty,"Target ram disk: $@")
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700324 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800325
326
327ifneq ($(strip $(TARGET_NO_KERNEL)),true)
328
329# -----------------------------------------------------------------
330# the boot image, which is a collection of other images.
331INTERNAL_BOOTIMAGE_ARGS := \
332 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
333 --kernel $(INSTALLED_KERNEL_TARGET) \
334 --ramdisk $(INSTALLED_RAMDISK_TARGET)
335
336INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
337
338BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
339ifdef BOARD_KERNEL_CMDLINE
340 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
341endif
342
Dima Zavin1e0847c2009-05-07 19:43:08 -0700343BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
344ifdef BOARD_KERNEL_BASE
345 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
346endif
347
Ying Wangffff0022010-08-23 12:56:25 -0700348BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
349ifdef BOARD_KERNEL_PAGESIZE
350 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
351endif
352
The Android Open Source Project88b60792009-03-03 19:28:42 -0800353INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
354
355ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
356tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
357INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
358INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
359$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
360 $(call pretty,"Target boot image: $@")
361 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
362
363else # TARGET_BOOTIMAGE_USE_EXT2 != true
364
365$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
366 $(call pretty,"Target boot image: $@")
367 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
Doug Zongkered96e882009-08-26 09:37:07 -0700368 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800369endif # TARGET_BOOTIMAGE_USE_EXT2
370
371else # TARGET_NO_KERNEL
372# HACK: The top-level targets depend on the bootimage. Not all targets
373# can produce a bootimage, though, and emulator targets need the ramdisk
374# instead. Fake it out by calling the ramdisk the bootimage.
375# TODO: make the emulator use bootimages, and make mkbootimg accept
376# kernel-less inputs.
377INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
378endif
379
380# -----------------------------------------------------------------
381# NOTICE files
382#
383# This needs to be before the systemimage rules, because it adds to
384# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
385# go into the systemimage.
386
387.PHONY: notice_files
388
389# Create the rule to combine the files into text and html forms
390# $(1) - Plain text output file
391# $(2) - HTML output file
392# $(3) - File title
393# $(4) - Directory to use. Notice files are all $(4)/src. Other
394# directories in there will be used for scratch
395# $(5) - Dependencies for the output files
396#
397# The algorithm here is that we go collect a hash for each of the notice
398# files and write the names of the files that match that hash. Then
399# to generate the real files, we go print out all of the files and their
400# hashes.
401#
402# These rules are fairly complex, so they depend on this makefile so if
403# it changes, they'll run again.
404#
405# TODO: We could clean this up so that we just record the locations of the
406# original notice files instead of making rules to copy them somwehere.
407# Then we could traverse that without quite as much bash drama.
408define combine-notice-files
409$(1) $(2): PRIVATE_MESSAGE := $(3)
410$(1) $(2) $(4)/hash-timestamp: PRIVATE_DIR := $(4)
411$(4)/hash-timestamp: $(5) $(BUILD_SYSTEM)/Makefile
412 @echo Finding NOTICE files: $$@
413 $$(hide) rm -rf $$@ $$(PRIVATE_DIR)/hash
414 $$(hide) mkdir -p $$(PRIVATE_DIR)/hash
415 $$(hide) for file in $$$$(find $$(PRIVATE_DIR)/src -type f); do \
416 hash=$$$$($(MD5SUM) $$$$file | sed -e "s/ .*//"); \
417 hashfile=$$(PRIVATE_DIR)/hash/$$$$hash; \
418 echo $$$$file >> $$$$hashfile; \
419 done
420 $$(hide) touch $$@
421$(1): $(4)/hash-timestamp
422 @echo Combining NOTICE files: $$@
423 $$(hide) mkdir -p $$(dir $$@)
424 $$(hide) echo $$(PRIVATE_MESSAGE) > $$@
425 $$(hide) find $$(PRIVATE_DIR)/hash -type f | xargs cat | sort | \
426 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> $$@
427 $$(hide) echo >> $$@
428 $$(hide) echo >> $$@
429 $$(hide) echo >> $$@
430 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
431 echo "============================================================"\
432 >> $$@; \
433 echo "Notices for file(s):" >> $$@; \
434 cat $$$$hashfile | sort | \
435 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \
436 $$@; \
437 echo "------------------------------------------------------------"\
438 >> $$@; \
439 echo >> $$@; \
440 orig=$$$$(head -n 1 $$$$hashfile); \
441 cat $$$$orig >> $$@; \
442 echo >> $$@; \
443 echo >> $$@; \
444 echo >> $$@; \
445 done
446$(2): $(4)/hash-timestamp
447 @echo Combining NOTICE files: $$@
448 $$(hide) mkdir -p $$(dir $$@)
449 $$(hide) echo "<html><head>" > $$@
450 $$(hide) echo "<style type=\"text/css\">" >> $$@
451 $$(hide) echo "body { padding: 0; font-family: sans-serif; }" >> $$@
452 $$(hide) echo ".same-license { background-color: #eeeeee; border-top: 20px solid white; padding: 10px; }" >> $$@
453 $$(hide) echo ".label { font-weight: bold; }" >> $$@
454 $$(hide) echo ".file-list { margin-left: 1em; font-color: blue; }" >> $$@
455 $$(hide) echo "</style>" >> $$@
456 $$(hide) echo "</head><body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">" >> $$@
457 $$(hide) echo "<table cellpading=\"0\" cellspacing=\"0\" border=\"0\">" \
458 >> $$@
459 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
460 cat $$$$hashfile | sort | \
461 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: <a name=\"\1\"></a>:" >> \
462 $$@; \
463 echo "<tr><td class=\"same-license\">" >> $$@; \
464 echo "<div class=\"label\">Notices for file(s):</div>" >> $$@; \
465 echo "<div class=\"file-list\">" >> $$@; \
466 cat $$$$hashfile | sort | \
467 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1<br/>:" >> $$@; \
468 echo "</div><!-- file-list -->" >> $$@; \
469 echo >> $$@; \
470 orig=$$$$(head -n 1 $$$$hashfile); \
471 echo "<pre class=\"license-text\">" >> $$@; \
472 cat $$$$orig | sed -e "s/\&/\&amp;/g" | sed -e "s/</\&lt;/g" \
473 | sed -e "s/>/\&gt;/g" >> $$@; \
474 echo "</pre><!-- license-text -->" >> $$@; \
475 echo "</td></tr><!-- same-license -->" >> $$@; \
476 echo >> $$@; \
477 echo >> $$@; \
478 echo >> $$@; \
479 done
480 $$(hide) echo "</table>" >> $$@
481 $$(hide) echo "</body></html>" >> $$@
482notice_files: $(1) $(2)
483endef
484
485# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
486# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
487# the src subdirectory.
488
489target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
490target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
491target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
492tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
493tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
494
495kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
496
497$(eval $(call combine-notice-files, \
498 $(target_notice_file_txt), \
499 $(target_notice_file_html), \
500 "Notices for files contained in the filesystem images in this directory:", \
501 $(TARGET_OUT_NOTICE_FILES), \
502 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)))
503
504$(eval $(call combine-notice-files, \
505 $(tools_notice_file_txt), \
506 $(tools_notice_file_html), \
507 "Notices for files contained in the tools directory:", \
508 $(HOST_OUT_NOTICE_FILES), \
509 $(ALL_DEFAULT_INSTALLED_MODULES)))
510
511# Install the html file at /system/etc/NOTICE.html.gz.
512# This is not ideal, but this is very late in the game, after a lot of
513# the module processing has already been done -- in fact, we used the
514# fact that all that has been done to get the list of modules that we
515# need notice files for.
Doug Zongker8b70e8c2009-05-27 09:14:25 -0700516$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
Doug Zongker8678df42009-06-15 14:30:14 -0700517 $(hide) $(MINIGZIP) -9 < $< > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800518installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
519$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
520 $(copy-file-to-target)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700521
522# if we've been run my mm, mmm, etc, don't reinstall this every time
523ifeq ($(ONE_SHOT_MAKEFILE),)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800524ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
Joe Onorato7b2845a2009-04-30 13:52:50 -0700525endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800526
527# The kernel isn't really a module, so to get its module file in there, we
528# make the target NOTICE files depend on this particular file too, which will
529# then be in the right directory for the find in combine-notice-files to work.
530$(kernel_notice_file): \
531 prebuilt/$(TARGET_PREBUILT_TAG)/kernel/LINUX_KERNEL_COPYING \
532 | $(ACP)
533 @echo Copying: $@
534 $(hide) mkdir -p $(dir $@)
535 $(hide) $(ACP) $< $@
536
537
Doug Zongker8678df42009-06-15 14:30:14 -0700538# -----------------------------------------------------------------
539# Build a keystore with the authorized keys in it, used to verify the
540# authenticity of downloaded OTA packages.
541#
542# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
543# before the rules that use that variable to build the image.
544ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
545$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Doug Zongker37c0e272009-06-15 15:36:16 -0700546$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR))
Doug Zongker8678df42009-06-15 14:30:14 -0700547 $(hide) rm -f $@
548 $(hide) mkdir -p $(dir $@)
Doug Zongker37c0e272009-06-15 15:36:16 -0700549 $(hide) zip -qj $@ $<
Doug Zongker8678df42009-06-15 14:30:14 -0700550
551.PHONY: otacerts
552otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
553
554
The Android Open Source Project88b60792009-03-03 19:28:42 -0800555# #################################################################
556# Targets for user images
557# #################################################################
558
Ying Wang065521b2010-08-23 11:34:40 -0700559INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800560ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Ying Wang065521b2010-08-23 11:34:40 -0700561INTERNAL_USERIMAGES_USE_EXT := true
562INTERNAL_USERIMAGES_EXT_VARIANT := ext2
The Android Open Source Project88b60792009-03-03 19:28:42 -0800563else
Ying Wang065521b2010-08-23 11:34:40 -0700564ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
565INTERNAL_USERIMAGES_USE_EXT := true
566INTERNAL_USERIMAGES_EXT_VARIANT := ext3
567else
568ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
569INTERNAL_USERIMAGES_USE_EXT := true
570INTERNAL_USERIMAGES_EXT_VARIANT := ext4
571endif
572endif
573endif
574
575ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
576INTERNAL_USERIMAGES_DEPS := $(MKEXT2USERIMG) $(MAKE_EXT4FS)
577INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
578
579# $(1): src directory
580# $(2): output file
Ying Wang026f1452010-09-27 17:49:03 -0700581# $(3): mount point
Ying Wang065521b2010-08-23 11:34:40 -0700582# $(4): ext variant (ext2, ext3, ext4)
583# $(5): size of the partition
584define build-userimage-ext-target
585 @mkdir -p $(dir $(2))
586 $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$(PATH) \
587 $(MKEXT2USERIMG) $(1) $(2) $(4) $(3) $(5)
588endef
589else
590INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800591endif
592
593# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -0700594# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700595
596# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
Brian Swetland630b7d32009-08-07 18:09:44 -0700597ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY) $(BUILD_TINY_ANDROID)))
Doug Zongker8cebf1f2009-07-07 17:14:25 -0700598
Doug Zongker4647f122009-07-02 09:00:54 -0700599INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
600
601recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
602recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
603recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
604recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
605recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
606recovery_resources_common := $(call include-path-for, recovery)/res
607recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
608recovery_resource_deps := $(shell find $(recovery_resources_common) \
609 $(recovery_resources_private) -type f)
Doug Zongker258bf462010-09-20 18:04:41 -0700610recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Doug Zongker4647f122009-07-02 09:00:54 -0700611
612ifeq ($(recovery_resources_private),)
613 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
614endif
615
Doug Zongker258bf462010-09-20 18:04:41 -0700616ifeq ($(recovery_fstab),)
617 $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
618endif
619
Doug Zongker4647f122009-07-02 09:00:54 -0700620INTERNAL_RECOVERYIMAGE_ARGS := \
621 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
622 --kernel $(recovery_kernel) \
623 --ramdisk $(recovery_ramdisk)
624
625# Assumes this has already been stripped
626ifdef BOARD_KERNEL_CMDLINE
627 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
628endif
629ifdef BOARD_KERNEL_BASE
630 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
631endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700632BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
633ifdef BOARD_KERNEL_PAGESIZE
634 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
635endif
Doug Zongker4647f122009-07-02 09:00:54 -0700636
637# Keys authorized to sign OTA packages this build will accept. The
638# build always uses test-keys for this; release packaging tools will
639# substitute other keys for this one.
640OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
641
642# Generate a file containing the keys that will be read by the
643# recovery binary.
644RECOVERY_INSTALL_OTA_KEYS := \
645 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
646DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
647$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
648$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR)
649 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS)"
650 @rm -rf $@
651 @mkdir -p $(dir $@)
652 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@
653
654$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
655 $(INSTALLED_RAMDISK_TARGET) \
656 $(INSTALLED_BOOTIMAGE_TARGET) \
657 $(recovery_binary) \
658 $(recovery_initrc) $(recovery_kernel) \
659 $(INSTALLED_2NDBOOTLOADER_TARGET) \
660 $(recovery_build_prop) $(recovery_resource_deps) \
Doug Zongkerc0434ac2010-09-21 14:25:51 -0700661 $(recovery_fstab) \
Doug Zongker4647f122009-07-02 09:00:54 -0700662 $(RECOVERY_INSTALL_OTA_KEYS)
663 @echo ----- Making recovery image ------
664 rm -rf $(TARGET_RECOVERY_OUT)
665 mkdir -p $(TARGET_RECOVERY_OUT)
666 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)
667 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc
668 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp
669 echo Copying baseline ramdisk...
670 cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
Doug Zongkerc19a8d52010-07-01 15:30:11 -0700671 rm $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
Doug Zongker4647f122009-07-02 09:00:54 -0700672 echo Modifying ramdisk contents...
673 cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
674 cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
675 cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
676 $(foreach item,$(recovery_resources_private), \
677 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
Doug Zongker258bf462010-09-20 18:04:41 -0700678 $(foreach item,$(recovery_fstab), \
679 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
Doug Zongker4647f122009-07-02 09:00:54 -0700680 cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
681 cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
682 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
683 $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
684 $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@
685 @echo ----- Made recovery image -------- $@
Doug Zongkered96e882009-08-26 09:37:07 -0700686 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
Doug Zongker4647f122009-07-02 09:00:54 -0700687
688else
689INSTALLED_RECOVERYIMAGE_TARGET :=
690endif
691
692.PHONY: recoveryimage
693recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET)
694
Dima Zavin11818982010-02-05 13:34:34 -0800695ifneq ($(BOARD_NAND_PAGE_SIZE),)
696mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
697else
698mkyaffs2_extra_flags :=
699endif
700
701
Doug Zongker4647f122009-07-02 09:00:54 -0700702# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -0700703# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800704#
Ying Wang02352372010-09-27 10:37:25 -0700705systemimage_intermediates := \
706 $(call intermediates-dir-for,PACKAGING,systemimage)
707BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
The Android Open Source Project88b60792009-03-03 19:28:42 -0800708
709INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
710 $(ALL_PREBUILT) \
711 $(ALL_COPIED_HEADERS) \
712 $(ALL_GENERATED_SOURCES) \
713 $(ALL_DEFAULT_INSTALLED_MODULES))
714
Ying Wang065521b2010-08-23 11:34:40 -0700715ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800716## generate an ext2 image
717# $(1): output file
718define build-systemimage-target
719 @echo "Target system fs image: $(1)"
Ying Wang065521b2010-08-23 11:34:40 -0700720 $(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 -0800721endef
722
Ying Wang065521b2010-08-23 11:34:40 -0700723else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800724
725## generate a yaffs2 image
726# $(1): output file
727define build-systemimage-target
728 @echo "Target system fs image: $(1)"
729 @mkdir -p $(dir $(1))
Dima Zavin11818982010-02-05 13:34:34 -0800730 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800731endef
Ying Wang065521b2010-08-23 11:34:40 -0700732endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800733
Ying Wang02352372010-09-27 10:37:25 -0700734$(BUILT_SYSTEMIMAGE): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800735 $(call build-systemimage-target,$@)
736
The Android Open Source Project88b60792009-03-03 19:28:42 -0800737INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -0700738SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800739
Doug Zongker73ef8252009-07-23 15:12:53 -0700740# The system partition needs room for the recovery image as well. We
741# now store the recovery image as a binary patch using the boot image
742# as the source (since they are very similar). Generate the patch so
743# we can see how big it's going to be, and include that in the system
744# image size check calculation.
Sriram Raman1e96ac82009-07-24 13:52:32 -0700745ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Doug Zongker73ef8252009-07-23 15:12:53 -0700746intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
747RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
748$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
749 $(INSTALLED_BOOTIMAGE_TARGET) \
Doug Zongker22bc5172009-07-23 18:27:43 -0700750 $(HOST_OUT_EXECUTABLES)/imgdiff \
751 $(HOST_OUT_EXECUTABLES)/bsdiff
Doug Zongker73ef8252009-07-23 15:12:53 -0700752 @echo "Construct recovery from boot"
753 mkdir -p $(dir $@)
Doug Zongkerb003d892009-07-23 18:48:38 -0700754 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Sriram Raman1e96ac82009-07-24 13:52:32 -0700755endif
756
Doug Zongker73ef8252009-07-23 15:12:53 -0700757
758$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800759 @echo "Install system fs image: $@"
760 $(copy-file-to-target)
Doug Zongkered96e882009-08-26 09:37:07 -0700761 $(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 -0800762
763systemimage: $(INSTALLED_SYSTEMIMAGE)
764
765.PHONY: systemimage-nodeps snod
766systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Ying Wang065521b2010-08-23 11:34:40 -0700767 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800768 @echo "make $@: ignoring dependencies"
769 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
Doug Zongkered96e882009-08-26 09:37:07 -0700770 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800771
772#######
773## system tarball
774define build-systemtarball-target
775 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
776 $(MKTARBALL) $(FS_GET_STATS) \
777 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
778 $(INSTALLED_SYSTEMTARBALL_TARGET)
779endef
780
781system_tar := $(PRODUCT_OUT)/system.tar
782INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).bz2
783$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
784$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
785 $(build-systemtarball-target)
786
787.PHONY: systemtarball-nodeps
788systemtarball-nodeps: $(FS_GET_STATS) \
789 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
790 $(build-systemtarball-target)
791
792.PHONY: stnod
793stnod: systemtarball-nodeps
794
795
796# -----------------------------------------------------------------
797# data partition image
798INTERNAL_USERDATAIMAGE_FILES := \
799 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
800
Ying Wang065521b2010-08-23 11:34:40 -0700801ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
802## Generate an ext image
The Android Open Source Project88b60792009-03-03 19:28:42 -0800803define build-userdataimage-target
804 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
805 @mkdir -p $(TARGET_OUT_DATA)
Ying Wang026f1452010-09-27 17:49:03 -0700806 $(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 -0700807 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800808endef
809
Ying Wang065521b2010-08-23 11:34:40 -0700810else # INTERNAL_USERIMAGES_USE_EXT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800811
812## Generate a yaffs2 image
813define build-userdataimage-target
814 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
815 @mkdir -p $(TARGET_OUT_DATA)
Dima Zavin11818982010-02-05 13:34:34 -0800816 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
Doug Zongkered96e882009-08-26 09:37:07 -0700817 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800818endef
Ying Wang065521b2010-08-23 11:34:40 -0700819endif # INTERNAL_USERIMAGES_USE_EXT
The Android Open Source Project88b60792009-03-03 19:28:42 -0800820
Joe Onorato64d85d02009-04-09 19:31:12 -0700821BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
822
823# We just build this directly to the install location.
824INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Ying Wang065521b2010-08-23 11:34:40 -0700825$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800826 $(INTERNAL_USERDATAIMAGE_FILES)
827 $(build-userdataimage-target)
828
829.PHONY: userdataimage-nodeps
Ying Wang065521b2010-08-23 11:34:40 -0700830userdataimage-nodeps: $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800831 $(build-userdataimage-target)
832
833#######
834## data partition tarball
835define build-userdatatarball-target
836 $(call pretty,"Target userdata fs tarball: " \
837 "$(INSTALLED_USERDATATARBALL_TARGET)")
838 $(MKTARBALL) $(FS_GET_STATS) \
839 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
840 $(INSTALLED_USERDATATARBALL_TARGET)
841endef
842
843userdata_tar := $(PRODUCT_OUT)/userdata.tar
844INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
845$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
846$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
847 $(build-userdatatarball-target)
848
849.PHONY: userdatatarball-nodeps
850userdatatarball-nodeps: $(FS_GET_STATS)
851 $(build-userdatatarball-target)
852
853
The Android Open Source Project88b60792009-03-03 19:28:42 -0800854# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800855# bring in the installer image generation defines if necessary
856ifeq ($(TARGET_USE_DISKINSTALLER),true)
857include bootable/diskinstaller/config.mk
858endif
859
860# -----------------------------------------------------------------
Doug Zongker8678df42009-06-15 14:30:14 -0700861# host tools needed to build OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -0800862
Ying Wang06898662010-06-17 17:52:18 -0700863OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
Doug Zongker8678df42009-06-15 14:30:14 -0700864 $(HOST_OUT_EXECUTABLES)/mkbootfs \
865 $(HOST_OUT_EXECUTABLES)/mkbootimg \
866 $(HOST_OUT_EXECUTABLES)/fs_config \
867 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
868 $(HOST_OUT_EXECUTABLES)/zipalign \
869 $(HOST_OUT_EXECUTABLES)/aapt \
870 $(HOST_OUT_EXECUTABLES)/bsdiff \
Doug Zongkerc494d7c2009-06-18 08:43:44 -0700871 $(HOST_OUT_EXECUTABLES)/imgdiff \
Doug Zongker8678df42009-06-15 14:30:14 -0700872 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
Sriram Ramanc647aec2010-11-29 18:51:20 -0500873 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
874 $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
875 $(HOST_OUT_EXECUTABLES)/make_ext4fs
The Android Open Source Project88b60792009-03-03 19:28:42 -0800876
Ying Wang06898662010-06-17 17:52:18 -0700877.PHONY: otatools
878otatools: $(OTATOOLS)
879
The Android Open Source Project88b60792009-03-03 19:28:42 -0800880# -----------------------------------------------------------------
881# A zip of the directories that map to the target filesystem.
882# This zip can be used to create an OTA package or filesystem image
883# as a post-build step.
884#
885name := $(TARGET_PRODUCT)
886ifeq ($(TARGET_BUILD_TYPE),debug)
887 name := $(name)_debug
888endif
889name := $(name)-target_files-$(FILE_NAME_TAG)
890
891intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
892BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
893$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
894$(BUILT_TARGET_FILES_PACKAGE): \
895 zip_root := $(intermediates)/$(name)
896
897# $(1): Directory to copy
898# $(2): Location to copy it to
899# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
900define package_files-copy-root
901 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
902 mkdir -p $(2) && \
903 $(ACP) -rd $(strip $(1))/* $(2); \
904 fi
905endef
906
907built_ota_tools := \
Doug Zongker17c83cf2009-04-01 15:48:46 -0700908 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
Doug Zongker6c770462009-07-22 18:27:31 -0700909 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
Doug Zongkera406c1e2009-06-12 16:57:08 -0700910 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
911 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
The Android Open Source Project88b60792009-03-03 19:28:42 -0800912$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
913
Doug Zongkerb1134dd2009-06-17 17:09:40 -0700914$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
915
Doug Zongkerc18736b2009-09-30 09:20:32 -0700916ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
917# default to common dir for device vendor
918$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
919else
920$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
921endif
922
The Android Open Source Project88b60792009-03-03 19:28:42 -0800923# Depending on the various images guarantees that the underlying
924# directories are up-to-date.
925$(BUILT_TARGET_FILES_PACKAGE): \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800926 $(INSTALLED_BOOTIMAGE_TARGET) \
927 $(INSTALLED_RADIOIMAGE_TARGET) \
928 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Doug Zongker4647f122009-07-02 09:00:54 -0700929 $(INSTALLED_SYSTEMIMAGE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800930 $(INSTALLED_USERDATAIMAGE_TARGET) \
931 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800932 $(built_ota_tools) \
933 $(APKCERTS_FILE) \
Doug Zongker283e2a12010-03-15 17:52:32 -0700934 $(HOST_OUT_EXECUTABLES)/fs_config \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800935 | $(ACP)
936 @echo "Package target files: $@"
937 $(hide) rm -rf $@ $(zip_root)
938 $(hide) mkdir -p $(dir $@) $(zip_root)
939 @# Components of the recovery image
940 $(hide) mkdir -p $(zip_root)/RECOVERY
941 $(hide) $(call package_files-copy-root, \
942 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
943ifdef INSTALLED_KERNEL_TARGET
944 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
945endif
946ifdef INSTALLED_2NDBOOTLOADER_TARGET
947 $(hide) $(ACP) \
948 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
949endif
950ifdef BOARD_KERNEL_CMDLINE
951 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
952endif
Doug Zongker38a649f2009-06-17 09:07:09 -0700953ifdef BOARD_KERNEL_BASE
954 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
955endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700956ifdef BOARD_KERNEL_PAGESIZE
957 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
958endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800959 @# Components of the boot image
960 $(hide) mkdir -p $(zip_root)/BOOT
961 $(hide) $(call package_files-copy-root, \
962 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
963ifdef INSTALLED_KERNEL_TARGET
964 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
965endif
966ifdef INSTALLED_2NDBOOTLOADER_TARGET
967 $(hide) $(ACP) \
968 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
969endif
970ifdef BOARD_KERNEL_CMDLINE
971 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
972endif
Doug Zongker38a649f2009-06-17 09:07:09 -0700973ifdef BOARD_KERNEL_BASE
974 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
975endif
Ying Wang4de6b5b2010-08-25 14:29:34 -0700976ifdef BOARD_KERNEL_PAGESIZE
977 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
978endif
Doug Zongkere01100c2009-06-19 17:12:18 -0700979 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
980 mkdir -p $(zip_root)/RADIO; \
981 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800982 @# Contents of the system image
983 $(hide) $(call package_files-copy-root, \
984 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
985 @# Contents of the data image
986 $(hide) $(call package_files-copy-root, \
987 $(TARGET_OUT_DATA),$(zip_root)/DATA)
988 @# Extra contents of the OTA package
989 $(hide) mkdir -p $(zip_root)/OTA/bin
The Android Open Source Project88b60792009-03-03 19:28:42 -0800990 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
991 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Doug Zongker8678df42009-06-15 14:30:14 -0700992 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -0800993 @# build them.
994 $(hide) mkdir -p $(zip_root)/META
995 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Doug Zongker17c83cf2009-04-01 15:48:46 -0700996 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Doug Zongker37974732010-09-16 17:44:38 -0700997 $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
Doug Zongkerc19a8d52010-07-01 15:30:11 -0700998ifdef BOARD_FLASH_BLOCK_SIZE
Doug Zongker37974732010-09-16 17:44:38 -0700999 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
Doug Zongkerc19a8d52010-07-01 15:30:11 -07001000endif
1001ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
1002 $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
1003endif
1004ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
1005 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
1006endif
1007ifdef BOARD_SYSTEMIMAGE_PARTITION_SIZE
1008 $(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
1009endif
1010ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
1011 $(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
1012endif
Doug Zongker37974732010-09-16 17:44:38 -07001013 $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001014ifdef mkyaffs2_extra_flags
Doug Zongker37974732010-09-16 17:44:38 -07001015 $(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(zip_root)/META/misc_info.txt
Ying Wangd421f572010-08-25 20:39:41 -07001016endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001017 @# Zip everything up, preserving symlinks
1018 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
Doug Zongker283e2a12010-03-15 17:52:32 -07001019 @# Run fs_config on all the system files in the zip, and save the output
1020 $(hide) zipinfo -1 $@ | awk -F/ 'BEGIN { OFS="/" } /^SYSTEM\// {$$1 = "system"; print}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt
1021 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/filesystem_config.txt)
1022
The Android Open Source Project88b60792009-03-03 19:28:42 -08001023
1024target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
1025
Doug Zongker367910f2009-06-15 18:56:51 -07001026
1027ifneq ($(TARGET_SIMULATOR),true)
1028ifneq ($(TARGET_PRODUCT),sdk)
Ying Wang910dcbe2010-03-24 23:22:33 -07001029ifneq ($(TARGET_DEVICE),generic)
Ying Wangfb0a3472010-08-25 16:06:06 -07001030ifneq ($(TARGET_NO_KERNEL),true)
Ying Wanga73b6562011-03-03 21:52:08 -08001031ifneq ($(recovery_fstab),)
Doug Zongker367910f2009-06-15 18:56:51 -07001032
Ying Wang09a00a62010-10-20 14:01:09 -07001033# -----------------------------------------------------------------
1034# OTA update package
1035
Doug Zongker8678df42009-06-15 14:30:14 -07001036name := $(TARGET_PRODUCT)
1037ifeq ($(TARGET_BUILD_TYPE),debug)
1038 name := $(name)_debug
1039endif
1040name := $(name)-ota-$(FILE_NAME_TAG)
1041
1042INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1043
1044$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
1045
Ying Wang06898662010-06-17 17:52:18 -07001046$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
Doug Zongker8678df42009-06-15 14:30:14 -07001047 @echo "Package OTA: $@"
Ying Wang68bb6512010-08-25 15:23:21 -07001048 $(hide) ./build/tools/releasetools/ota_from_target_files -v \
Doug Zongker602a84e2009-06-18 08:35:12 -07001049 -p $(HOST_OUT) \
Doug Zongker8678df42009-06-15 14:30:14 -07001050 -k $(KEY_CERT_PAIR) \
1051 $(BUILT_TARGET_FILES_PACKAGE) $@
1052
1053.PHONY: otapackage
1054otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
1055
Ying Wang09a00a62010-10-20 14:01:09 -07001056# -----------------------------------------------------------------
1057# The update package
1058
1059name := $(TARGET_PRODUCT)
1060ifeq ($(TARGET_BUILD_TYPE),debug)
1061 name := $(name)_debug
1062endif
1063name := $(name)-img-$(FILE_NAME_TAG)
1064
1065INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1066
1067ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
1068# default to common dir for device vendor
1069$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_DEVICE_DIR)/../common
1070else
1071$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
1072endif
1073
1074$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
1075 @echo "Package: $@"
1076 $(hide) ./build/tools/releasetools/img_from_target_files -v \
1077 -s $(extensions) \
1078 -p $(HOST_OUT) \
1079 $(BUILT_TARGET_FILES_PACKAGE) $@
1080
1081.PHONY: updatepackage
1082updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
1083
Ying Wanga73b6562011-03-03 21:52:08 -08001084endif # recovery_fstab is defined
Ying Wangfb0a3472010-08-25 16:06:06 -07001085endif # TARGET_NO_KERNEL != true
Ying Wang910dcbe2010-03-24 23:22:33 -07001086endif # TARGET_DEVICE != generic
Doug Zongker367910f2009-06-15 18:56:51 -07001087endif # TARGET_PRODUCT != sdk
1088endif # TARGET_SIMULATOR != true
Doug Zongker8678df42009-06-15 14:30:14 -07001089
1090# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001091# installed file list
1092# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it
1093# gets the DexOpt one if we're doing that.
1094INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
1095$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE)
1096 @echo Installed file list: $@
1097 @mkdir -p $(dir $@)
1098 @rm -f $@
1099 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@
1100
1101.PHONY: installed-file-list
1102installed-file-list: $(INSTALLED_FILES_FILE)
Raphaelbd0c91c2011-02-15 16:09:36 -08001103ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
1104$(call dist-for-goals, sdk win_sdk, $(INSTALLED_FILES_FILE))
1105endif
1106ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
Joe Onorato03fbe402009-04-13 08:31:16 -07001107$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
Raphaelbd0c91c2011-02-15 16:09:36 -08001108endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001109
1110# -----------------------------------------------------------------
1111# A zip of the tests that are built when running "make tests".
1112# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
1113# only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
1114#
1115name := $(TARGET_PRODUCT)
1116ifeq ($(TARGET_BUILD_TYPE),debug)
1117 name := $(name)_debug
1118endif
1119name := $(name)-tests-$(FILE_NAME_TAG)
1120
1121intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
1122BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
1123$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
1124$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
1125
1126# Depending on the images guarantees that the underlying
1127# directories are up-to-date.
1128$(BUILT_TESTS_ZIP_PACKAGE): \
1129 $(BUILT_SYSTEMIMAGE) \
1130 $(INSTALLED_USERDATAIMAGE_TARGET) \
1131 | $(ACP)
1132 @echo "Package test files: $@"
1133 $(hide) rm -rf $@ $(zip_root)
1134 $(hide) mkdir -p $(dir $@) $(zip_root)
1135 @# Some parts of the system image
1136 $(hide) $(call package_files-copy-root, \
1137 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin)
1138 $(hide) $(call package_files-copy-root, \
1139 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib)
1140 $(hide) $(call package_files-copy-root, \
1141 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \
1142 $(zip_root)/SYSTEM/framework)
1143 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM
1144 @# Contents of the data image
1145 $(hide) $(call package_files-copy-root, \
1146 $(TARGET_OUT_DATA),$(zip_root)/DATA)
1147 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
1148
Ying Wang570a0ee2010-09-10 14:39:33 -07001149.PHONY: tests-zip-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08001150tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
1151
Ying Wangdb2cb632010-09-14 16:07:56 -07001152# Target needed by tests build
1153.PHONY: tests-build-target
1154tests-build-target: $(BUILT_TESTS_ZIP_PACKAGE) \
1155 $(BUILT_USERDATAIMAGE_TARGET)
1156
1157ifneq (,$(filter $(MAKECMDGOALS),tests-build-target))
1158 $(call dist-for-goals, tests-build-target, \
1159 $(BUILT_TESTS_ZIP_PACKAGE) \
1160 $(BUILT_USERDATAIMAGE_TARGET))
Ying Wang570a0ee2010-09-10 14:39:33 -07001161endif
1162
The Android Open Source Project88b60792009-03-03 19:28:42 -08001163# -----------------------------------------------------------------
1164# A zip of the symbols directory. Keep the full paths to make it
1165# more obvious where these files came from.
1166#
1167name := $(TARGET_PRODUCT)
1168ifeq ($(TARGET_BUILD_TYPE),debug)
1169 name := $(name)_debug
1170endif
1171name := $(name)-symbols-$(FILE_NAME_TAG)
1172
1173SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
1174$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
1175 @echo "Package symbols: $@"
1176 $(hide) rm -rf $@
1177 $(hide) mkdir -p $(dir $@)
1178 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
1179
1180# -----------------------------------------------------------------
1181# A zip of the Android Apps. Not keeping full path so that we don't
1182# include product names when distributing
1183#
1184name := $(TARGET_PRODUCT)
1185ifeq ($(TARGET_BUILD_TYPE),debug)
1186 name := $(name)_debug
1187endif
1188name := $(name)-apps-$(FILE_NAME_TAG)
1189
1190APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1191$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1192 @echo "Package apps: $@"
1193 $(hide) rm -rf $@
1194 $(hide) mkdir -p $(dir $@)
1195 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
1196
Guang Zhu18b75562010-05-13 16:46:21 -07001197
1198#------------------------------------------------------------------
1199# A zip of emma code coverage meta files. Generated for fully emma
1200# instrumented build.
1201#
1202EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
1203$(EMMA_META_ZIP): $(INSTALLED_SYSTEMIMAGE)
1204 @echo "Collecting Emma coverage meta files."
1205 $(hide) find $(TARGET_COMMON_OUT_ROOT) -name "coverage.em" | \
1206 zip -@ -q $@
1207
The Android Open Source Project88b60792009-03-03 19:28:42 -08001208endif # TARGET_SIMULATOR != true
1209
1210# -----------------------------------------------------------------
1211# dalvik something
1212.PHONY: dalvikfiles
1213dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1214
1215# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001216# The emulator package
1217
1218ifneq ($(TARGET_SIMULATOR),true)
1219
1220INTERNAL_EMULATOR_PACKAGE_FILES += \
1221 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
1222 prebuilt/android-arm/kernel/kernel-qemu \
1223 $(INSTALLED_RAMDISK_TARGET) \
1224 $(INSTALLED_SYSTEMIMAGE) \
1225 $(INSTALLED_USERDATAIMAGE_TARGET)
1226
1227name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1228
1229INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1230
1231$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1232 @echo "Package: $@"
1233 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1234
1235endif
1236
1237# -----------------------------------------------------------------
1238# The pdk package (Platform Development Kit)
1239
1240ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1241 include development/pdk/Pdk.mk
1242endif
1243
1244# -----------------------------------------------------------------
1245# The SDK
1246
1247ifneq ($(TARGET_SIMULATOR),true)
1248
1249# The SDK includes host-specific components, so it belongs under HOST_OUT.
1250sdk_dir := $(HOST_OUT)/sdk
1251
1252# Build a name that looks like:
1253#
1254# linux-x86 --> android-sdk_12345_linux-x86
1255# darwin-x86 --> android-sdk_12345_mac-x86
1256# windows-x86 --> android-sdk_12345_windows
1257#
1258sdk_name := android-sdk_$(FILE_NAME_TAG)
1259ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07001260 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08001261else
Joe Onorato03fbe402009-04-13 08:31:16 -07001262 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001263endif
1264ifneq ($(HOST_OS),windows)
Joe Onorato03fbe402009-04-13 08:31:16 -07001265 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001266endif
Joe Onorato03fbe402009-04-13 08:31:16 -07001267sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001268
1269sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1270
1271ATREE_FILES :=
1272-include $(sdk_dep_file)
1273
1274# if we don't have a real list, then use "everything"
1275ifeq ($(strip $(ATREE_FILES)),)
1276ATREE_FILES := \
1277 $(ALL_PREBUILT) \
1278 $(ALL_COPIED_HEADERS) \
1279 $(ALL_GENERATED_SOURCES) \
1280 $(ALL_DEFAULT_INSTALLED_MODULES) \
1281 $(INSTALLED_RAMDISK_TARGET) \
1282 $(ALL_DOCS) \
1283 $(ALL_SDK_FILES)
1284endif
1285
1286atree_dir := development/build
1287
1288sdk_atree_files := \
1289 $(atree_dir)/sdk.exclude.atree \
1290 $(atree_dir)/sdk.atree \
Xavier Ducrohetf51f24a2010-09-27 15:51:32 -07001291 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree \
1292 sdk/build/tools.atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08001293
1294deps := \
1295 $(target_notice_file_txt) \
1296 $(tools_notice_file_txt) \
1297 $(OUT_DOCS)/offline-sdk-timestamp \
Ying Wang139e3322010-03-31 17:29:04 -07001298 $(SYMBOLS_ZIP) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07001299 $(INSTALLED_SYSTEMIMAGE) \
1300 $(INSTALLED_USERDATAIMAGE_TARGET) \
1301 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001302 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07001303 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001304 $(ATREE_FILES) \
1305 $(atree_dir)/sdk.atree \
Xavier Ducrohetf51f24a2010-09-27 15:51:32 -07001306 sdk/build/tools.atree \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001307 $(HOST_OUT_EXECUTABLES)/atree \
1308 $(HOST_OUT_EXECUTABLES)/line_endings
1309
1310INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1311$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1312$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1313$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1314$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1315
1316# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1317#
1318#SDK_GNU_ERROR := true
1319
1320$(INTERNAL_SDK_TARGET): $(deps)
1321 @echo "Package SDK: $@"
1322 $(hide) rm -rf $(PRIVATE_DIR) $@
1323 $(hide) for f in $(target_gnu_MODULES); do \
1324 if [ -f $$f ]; then \
1325 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1326 including GNU target $$f >&2; \
1327 FAIL=$(SDK_GNU_ERROR); \
1328 fi; \
1329 done; \
1330 if [ $$FAIL ]; then exit 1; fi
1331 $(hide) ( \
1332 $(HOST_OUT_EXECUTABLES)/atree \
1333 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1334 -m $(PRIVATE_DEP_FILE) \
1335 -I . \
1336 -I $(PRODUCT_OUT) \
1337 -I $(HOST_OUT) \
1338 -I $(TARGET_COMMON_OUT_ROOT) \
1339 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
1340 -o $(PRIVATE_DIR) && \
1341 cp -f $(target_notice_file_txt) \
1342 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \
1343 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
1344 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
Xavier Ducrohet1ae98802009-11-17 15:10:41 -08001345 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001346 chmod -R ug+rwX $(PRIVATE_DIR) && \
1347 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1348 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1349
Raphael9ca16282010-04-16 17:50:09 -07001350
1351# Is a Windows SDK requested? If so, we need some definitions from here
1352# in order to find the Linux SDK used to create the Windows one.
Raphaelbd0c91c2011-02-15 16:09:36 -08001353MAIN_SDK_NAME := $(sdk_name)
1354MAIN_SDK_DIR := $(sdk_dir)
1355MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Raphael9ca16282010-04-16 17:50:09 -07001356ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
Raphael9ca16282010-04-16 17:50:09 -07001357include $(TOPDIR)development/build/tools/windows_sdk.mk
1358endif
1359
The Android Open Source Project88b60792009-03-03 19:28:42 -08001360endif # !simulator
1361
1362# -----------------------------------------------------------------
1363# Findbugs
1364INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1365INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1366$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1367 @echo UnionBugs: $@
1368 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1369 > $@
1370$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1371 @echo ConvertXmlToText: $@
1372 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1373 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1374
1375# -----------------------------------------------------------------
1376# Findbugs
1377
1378# -----------------------------------------------------------------
1379# These are some additional build tasks that need to be run.
1380include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Raphaelbd0c91c2011-02-15 16:09:36 -08001381-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
1382
1383# -----------------------------------------------------------------
1384# Create SDK repository packages. Must be done after tasks/* since
1385# we need the addon rules defined.
1386ifneq ($(sdk_repo_goal),)
1387include $(TOPDIR)development/build/tools/sdk_repo.mk
1388endif
1389