1 # Put some miscellaneous rules here
3 # Pick a reasonable string to use to identify files.
4 ifneq "" "$(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)
9 FILE_NAME_TAG := $(BUILD_NUMBER)
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".
17 $(foreach cf,$(PRODUCT_COPY_FILES), \
18 $(eval _src := $(call word-colon,1,$(cf))) \
19 $(eval _dest := $(call \
20 append-path,$(PRODUCT_OUT),$(call word-colon,2,$(cf)))) \
21 $(eval $(call copy-one-file,$(_src),$(_dest))) \
22 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_dest)) \
25 # -----------------------------------------------------------------
27 gen := $(OUT_DOCS)/index.html
29 $(gen): frameworks/base/docs/docs-redirect-index.html
33 # -----------------------------------------------------------------
35 INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
36 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
37 ADDITIONAL_DEFAULT_PROPERTIES := \
38 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
40 $(INSTALLED_DEFAULT_PROP_TARGET):
41 @echo Target buildinfo: $@
43 $(hide) echo "#" > $@; \
44 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
46 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
47 echo "$(line)" >> $@;)
49 # -----------------------------------------------------------------
51 INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
52 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
53 ADDITIONAL_BUILD_PROPERTIES := \
54 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
56 # A list of arbitrary tags describing the build configuration.
57 # Force ":=" so we can use +=
58 BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
59 ifeq ($(TARGET_BUILD_TYPE),debug)
60 BUILD_VERSION_TAGS += debug
62 # Apps are always signed with test keys, and may be re-signed in a post-build
63 # step. If that happens, the "test-keys" tag will be removed by that step.
64 BUILD_VERSION_TAGS += test-keys
65 BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
67 # A human-readable string that descibes this build in detail.
68 build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)
69 $(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc)
71 # The string used to uniquely identify this build; used by the OTA server.
72 ifeq (,$(strip $(BUILD_FINGERPRINT)))
73 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE)/$(TARGET_BOOTLOADER_BOARD_NAME):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
75 ifneq ($(words $(BUILD_FINGERPRINT)),1)
76 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
79 # Display parameters shown under Settings -> About Phone
80 ifeq ($(TARGET_BUILD_VARIANT),user)
81 # User builds should show:
82 # release build number or branch.buld_number non-release builds
84 # Dev. branches should have DISPLAY_BUILD_NUMBER set
85 ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
86 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER)
88 BUILD_DISPLAY_ID := $(BUILD_ID)
91 # Non-user builds should show detailed build information
92 BUILD_DISPLAY_ID := $(build_desc)
95 # Selects the first locale in the list given as the argument,
96 # and splits it into language and region, which each may be
99 $(subst _, , $(firstword $(1)))
102 # Selects the first locale in the list given as the argument
103 # and returns the language (or the region)
104 define default-locale-language
105 $(word 2, 2, $(call default-locale, $(1)))
107 define default-locale-region
108 $(word 3, 3, $(call default-locale, $(1)))
111 BUILDINFO_SH := build/tools/buildinfo.sh
112 $(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE)
113 @echo Target buildinfo: $@
115 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
116 TARGET_DEVICE="$(TARGET_DEVICE)" \
117 PRODUCT_NAME="$(TARGET_PRODUCT)" \
118 PRODUCT_BRAND="$(PRODUCT_BRAND)" \
119 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
120 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
121 PRODUCT_MODEL="$(PRODUCT_MODEL)" \
122 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
123 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
124 BUILD_ID="$(BUILD_ID)" \
125 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
126 BUILD_NUMBER="$(BUILD_NUMBER)" \
127 PLATFORM_VERSION="$(PLATFORM_VERSION)" \
128 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
129 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
130 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
131 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
132 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
133 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
134 bash $(BUILDINFO_SH) > $@
135 $(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \
136 cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \
138 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
139 $(hide) echo >> $@; \
141 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
143 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
144 echo "$(line)" >> $@;)
148 # -----------------------------------------------------------------
151 # There are certain things in build.prop that we don't want to
152 # ship with the sdk; remove them.
154 # This must be a list of entire property keys followed by
155 # "=" characters, without any internal spaces.
156 sdk_build_prop_remove := \
160 ro.product.manufacturer= \
162 # TODO: Remove this soon-to-be obsolete property
163 sdk_build_prop_remove += ro.build.product=
164 INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
165 $(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
166 @echo SDK buildinfo: $@
168 $(hide) grep -v "$(subst $(space),\|,$(strip \
169 $(sdk_build_prop_remove)))" $< > $@.tmp
170 $(hide) for x in $(sdk_build_prop_remove); do \
171 echo "$$x"generic >> $@.tmp; done
174 # -----------------------------------------------------------------
176 PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
177 PACKAGES_TO_STAT := \
178 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
179 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
180 $(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
181 @echo Package stats: $@
184 $(hide) build/tools/dump-package-stats $^ > $@
186 .PHONY: package-stats
187 package-stats: $(PACKAGE_STATS_FILE)
189 # -----------------------------------------------------------------
190 # Cert-to-package mapping. Used by the post-build signing tools.
191 name := $(TARGET_PRODUCT)
192 ifeq ($(TARGET_BUILD_TYPE),debug)
193 name := $(name)_debug
195 name := $(name)-apkcerts-$(FILE_NAME_TAG)
197 $(call intermediates-dir-for,PACKAGING,apkcerts)
198 APKCERTS_FILE := $(intermediates)/$(name).txt
199 # Depending on the built packages isn't exactly right,
200 # but it should guarantee that the apkcerts file is rebuilt
201 # if any packages change which certs they're signed with.
202 all_built_packages := $(foreach p,$(PACKAGES),$(ALL_MODULES.$(p).BUILT))
203 $(APKCERTS_FILE): $(all_built_packages)
204 @echo APK certs list: $@
207 $(hide) $(foreach p,$(PACKAGES),\
208 echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
209 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;)
211 .PHONY: apkcerts-list
212 apkcerts-list: $(APKCERTS_FILE)
214 # -----------------------------------------------------------------
216 ifdef CREATE_MODULE_INFO_FILE
217 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
218 $(info Generating $(MODULE_INFO_FILE)...)
219 $(shell rm -f $(MODULE_INFO_FILE))
220 $(foreach m,$(ALL_MODULES), \
221 $(shell echo "NAME=\"$(m)\"" \
222 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
223 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
224 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
225 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
228 # Rules that need to be present for the simulator, even
229 # if they don't do anything.
233 ifneq ($(TARGET_SIMULATOR),true)
235 # #################################################################
236 # Targets for boot/OS images
237 # #################################################################
239 # -----------------------------------------------------------------
241 INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
243 $(ALL_COPIED_HEADERS) \
244 $(ALL_GENERATED_SOURCES) \
245 $(ALL_DEFAULT_INSTALLED_MODULES))
247 BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
249 # We just build this directly to the install location.
250 INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
251 $(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES)
252 $(call pretty,"Target ram disk: $@")
253 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | gzip > $@
256 ifneq ($(strip $(TARGET_NO_KERNEL)),true)
258 # -----------------------------------------------------------------
259 # the boot image, which is a collection of other images.
260 INTERNAL_BOOTIMAGE_ARGS := \
261 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
262 --kernel $(INSTALLED_KERNEL_TARGET) \
263 --ramdisk $(INSTALLED_RAMDISK_TARGET)
265 INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
267 BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
268 ifdef BOARD_KERNEL_CMDLINE
269 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
272 BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
273 ifdef BOARD_KERNEL_BASE
274 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
277 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
279 ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
280 tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
281 INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
282 INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
283 $(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
284 $(call pretty,"Target boot image: $@")
285 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
287 else # TARGET_BOOTIMAGE_USE_EXT2 != true
289 $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
290 $(call pretty,"Target boot image: $@")
291 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
292 $(hide) $(call assert-max-file-size,$@,$(BOARD_BOOTIMAGE_MAX_SIZE))
293 endif # TARGET_BOOTIMAGE_USE_EXT2
295 else # TARGET_NO_KERNEL
296 # HACK: The top-level targets depend on the bootimage. Not all targets
297 # can produce a bootimage, though, and emulator targets need the ramdisk
298 # instead. Fake it out by calling the ramdisk the bootimage.
299 # TODO: make the emulator use bootimages, and make mkbootimg accept
300 # kernel-less inputs.
301 INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
304 # -----------------------------------------------------------------
307 # This needs to be before the systemimage rules, because it adds to
308 # ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
309 # go into the systemimage.
313 # Create the rule to combine the files into text and html forms
314 # $(1) - Plain text output file
315 # $(2) - HTML output file
317 # $(4) - Directory to use. Notice files are all $(4)/src. Other
318 # directories in there will be used for scratch
319 # $(5) - Dependencies for the output files
321 # The algorithm here is that we go collect a hash for each of the notice
322 # files and write the names of the files that match that hash. Then
323 # to generate the real files, we go print out all of the files and their
326 # These rules are fairly complex, so they depend on this makefile so if
327 # it changes, they'll run again.
329 # TODO: We could clean this up so that we just record the locations of the
330 # original notice files instead of making rules to copy them somwehere.
331 # Then we could traverse that without quite as much bash drama.
332 define combine-notice-files
333 $(1) $(2): PRIVATE_MESSAGE := $(3)
334 $(1) $(2) $(4)/hash-timestamp: PRIVATE_DIR := $(4)
335 $(4)/hash-timestamp: $(5) $(BUILD_SYSTEM)/Makefile
336 @echo Finding NOTICE files: $$@
337 $$(hide) rm -rf $$@ $$(PRIVATE_DIR)/hash
338 $$(hide) mkdir -p $$(PRIVATE_DIR)/hash
339 $$(hide) for file in $$$$(find $$(PRIVATE_DIR)/src -type f); do \
340 hash=$$$$($(MD5SUM) $$$$file | sed -e "s/ .*//"); \
341 hashfile=$$(PRIVATE_DIR)/hash/$$$$hash; \
342 echo $$$$file >> $$$$hashfile; \
345 $(1): $(4)/hash-timestamp
346 @echo Combining NOTICE files: $$@
347 $$(hide) mkdir -p $$(dir $$@)
348 $$(hide) echo $$(PRIVATE_MESSAGE) > $$@
349 $$(hide) find $$(PRIVATE_DIR)/hash -type f | xargs cat | sort | \
350 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> $$@
354 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
355 echo "============================================================"\
357 echo "Notices for file(s):" >> $$@; \
358 cat $$$$hashfile | sort | \
359 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \
361 echo "------------------------------------------------------------"\
364 orig=$$$$(head -n 1 $$$$hashfile); \
365 cat $$$$orig >> $$@; \
370 $(2): $(4)/hash-timestamp
371 @echo Combining NOTICE files: $$@
372 $$(hide) mkdir -p $$(dir $$@)
373 $$(hide) echo "<html><head>" > $$@
374 $$(hide) echo "<style type=\"text/css\">" >> $$@
375 $$(hide) echo "body { padding: 0; font-family: sans-serif; }" >> $$@
376 $$(hide) echo ".same-license { background-color: #eeeeee; border-top: 20px solid white; padding: 10px; }" >> $$@
377 $$(hide) echo ".label { font-weight: bold; }" >> $$@
378 $$(hide) echo ".file-list { margin-left: 1em; font-color: blue; }" >> $$@
379 $$(hide) echo "</style>" >> $$@
380 $$(hide) echo "</head><body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">" >> $$@
381 $$(hide) echo "<table cellpading=\"0\" cellspacing=\"0\" border=\"0\">" \
383 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
384 cat $$$$hashfile | sort | \
385 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: <a name=\"\1\"></a>:" >> \
387 echo "<tr><td class=\"same-license\">" >> $$@; \
388 echo "<div class=\"label\">Notices for file(s):</div>" >> $$@; \
389 echo "<div class=\"file-list\">" >> $$@; \
390 cat $$$$hashfile | sort | \
391 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1<br/>:" >> $$@; \
392 echo "</div><!-- file-list -->" >> $$@; \
394 orig=$$$$(head -n 1 $$$$hashfile); \
395 echo "<pre class=\"license-text\">" >> $$@; \
396 cat $$$$orig | sed -e "s/\&/\&/g" | sed -e "s/</\</g" \
397 | sed -e "s/>/\>/g" >> $$@; \
398 echo "</pre><!-- license-text -->" >> $$@; \
399 echo "</td></tr><!-- same-license -->" >> $$@; \
404 $$(hide) echo "</table>" >> $$@
405 $$(hide) echo "</body></html>" >> $$@
406 notice_files: $(1) $(2)
409 # TODO These intermediate NOTICE.txt/NOTICE.html files should go into
410 # TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
411 # the src subdirectory.
413 target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
414 target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
415 target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
416 tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
417 tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
419 kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
421 $(eval $(call combine-notice-files, \
422 $(target_notice_file_txt), \
423 $(target_notice_file_html), \
424 "Notices for files contained in the filesystem images in this directory:", \
425 $(TARGET_OUT_NOTICE_FILES), \
426 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)))
428 $(eval $(call combine-notice-files, \
429 $(tools_notice_file_txt), \
430 $(tools_notice_file_html), \
431 "Notices for files contained in the tools directory:", \
432 $(HOST_OUT_NOTICE_FILES), \
433 $(ALL_DEFAULT_INSTALLED_MODULES)))
435 # Install the html file at /system/etc/NOTICE.html.gz.
436 # This is not ideal, but this is very late in the game, after a lot of
437 # the module processing has already been done -- in fact, we used the
438 # fact that all that has been done to get the list of modules that we
439 # need notice files for.
440 $(target_notice_file_html_gz): $(target_notice_file_html)
442 installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
443 $(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
444 $(copy-file-to-target)
446 # if we've been run my mm, mmm, etc, don't reinstall this every time
447 ifeq ($(ONE_SHOT_MAKEFILE),)
448 ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
451 # The kernel isn't really a module, so to get its module file in there, we
452 # make the target NOTICE files depend on this particular file too, which will
453 # then be in the right directory for the find in combine-notice-files to work.
454 $(kernel_notice_file): \
455 prebuilt/$(TARGET_PREBUILT_TAG)/kernel/LINUX_KERNEL_COPYING \
458 $(hide) mkdir -p $(dir $@)
462 # #################################################################
463 # Targets for user images
464 # #################################################################
466 ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
467 include external/genext2fs/Config.mk
468 INTERNAL_MKUSERFS := $(MKEXT2IMG)
470 INTERNAL_MKUSERFS := $(MKYAFFS2)
473 # -----------------------------------------------------------------
476 # First, the "unoptimized" image, which contains .apk/.jar files
477 # that contain regular, unoptimized/unverified .dex entries.
479 systemimage_unopt_intermediates := \
480 $(call intermediates-dir-for,PACKAGING,systemimage_unopt)
481 BUILT_SYSTEMIMAGE_UNOPT := $(systemimage_unopt_intermediates)/system.img
483 INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
485 $(ALL_COPIED_HEADERS) \
486 $(ALL_GENERATED_SOURCES) \
487 $(ALL_DEFAULT_INSTALLED_MODULES))
489 ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
490 ## generate an ext2 image
492 define build-systemimage-target
493 @echo "Target system fs image: $(1)"
494 $(call build-userimage-ext2-target,$(TARGET_OUT),$(1),system,)
497 else # TARGET_USERIMAGES_USE_EXT2 != true
499 ## generate a yaffs2 image
501 define build-systemimage-target
502 @echo "Target system fs image: $(1)"
503 @mkdir -p $(dir $(1))
504 $(hide) $(MKYAFFS2) -f $(TARGET_OUT) $(1)
506 endif # TARGET_USERIMAGES_USE_EXT2
508 $(BUILT_SYSTEMIMAGE_UNOPT): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_MKUSERFS)
509 $(call build-systemimage-target,$@)
511 # The installed image, which may be optimized or unoptimized.
513 INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
516 ifndef DISABLE_DEXPREOPT
517 with_dexpreopt := true
521 # This file will set BUILT_SYSTEMIMAGE and SYSTEMIMAGE_SOURCE_DIR
522 include build/tools/dexpreopt/Config.mk
524 BUILT_SYSTEMIMAGE := $(BUILT_SYSTEMIMAGE_UNOPT)
525 SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
528 $(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) | $(ACP)
529 @echo "Install system fs image: $@"
530 $(copy-file-to-target)
531 $(hide) $(call assert-max-file-size,$@,$(BOARD_SYSTEMIMAGE_MAX_SIZE))
533 systemimage: $(INSTALLED_SYSTEMIMAGE)
535 .PHONY: systemimage-nodeps snod
536 systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
537 | $(INTERNAL_MKUSERFS)
538 @echo "make $@: ignoring dependencies"
539 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
540 $(hide) $(call assert-max-file-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_MAX_SIZE))
544 define build-systemtarball-target
545 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
546 $(MKTARBALL) $(FS_GET_STATS) \
547 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
548 $(INSTALLED_SYSTEMTARBALL_TARGET)
551 system_tar := $(PRODUCT_OUT)/system.tar
552 INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).bz2
553 $(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
554 $(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
555 $(build-systemtarball-target)
557 .PHONY: systemtarball-nodeps
558 systemtarball-nodeps: $(FS_GET_STATS) \
559 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
560 $(build-systemtarball-target)
563 stnod: systemtarball-nodeps
566 # -----------------------------------------------------------------
567 # data partition image
568 INTERNAL_USERDATAIMAGE_FILES := \
569 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
571 ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
572 ## Generate an ext2 image
573 define build-userdataimage-target
574 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
575 @mkdir -p $(TARGET_OUT_DATA)
576 $(call build-userimage-ext2-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),userdata,)
577 $(hide) $(call assert-max-file-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_MAX_SIZE))
580 else # TARGET_USERIMAGES_USE_EXT2 != true
582 ## Generate a yaffs2 image
583 define build-userdataimage-target
584 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
585 @mkdir -p $(TARGET_OUT_DATA)
586 $(hide) $(MKYAFFS2) -f $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
587 $(hide) $(call assert-max-file-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_MAX_SIZE))
589 endif # TARGET_USERIMAGES_USE_EXT2
591 BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
593 # We just build this directly to the install location.
594 INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
595 $(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_MKUSERFS) \
596 $(INTERNAL_USERDATAIMAGE_FILES)
597 $(build-userdataimage-target)
599 .PHONY: userdataimage-nodeps
600 userdataimage-nodeps: $(INTERNAL_MKUSERFS)
601 $(build-userdataimage-target)
604 ## data partition tarball
605 define build-userdatatarball-target
606 $(call pretty,"Target userdata fs tarball: " \
607 "$(INSTALLED_USERDATATARBALL_TARGET)")
608 $(MKTARBALL) $(FS_GET_STATS) \
609 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
610 $(INSTALLED_USERDATATARBALL_TARGET)
613 userdata_tar := $(PRODUCT_OUT)/userdata.tar
614 INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
615 $(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
616 $(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
617 $(build-userdatatarball-target)
619 .PHONY: userdatatarball-nodeps
620 userdatatarball-nodeps: $(FS_GET_STATS)
621 $(build-userdatatarball-target)
624 # If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
625 ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
627 # -----------------------------------------------------------------
629 INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
631 recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
632 recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
633 recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
634 recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
635 recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
636 recovery_resources_common := $(call include-path-for, recovery)/res
637 recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
638 recovery_resource_deps := $(shell find $(recovery_resources_common) \
639 $(recovery_resources_private) -type f)
641 ifeq ($(recovery_resources_private),)
642 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
645 INTERNAL_RECOVERYIMAGE_ARGS := \
646 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
647 --kernel $(recovery_kernel) \
648 --ramdisk $(recovery_ramdisk)
650 # Assumes this has already been stripped
651 ifdef BOARD_KERNEL_CMDLINE
652 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
654 ifdef BOARD_KERNEL_BASE
655 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
658 # Keys authorized to sign OTA packages this build will accept. The
659 # build always uses test-keys for this; release packaging tools will
660 # substitute other keys for this one.
661 OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
663 # Generate a file containing the keys that will be read by the
665 RECOVERY_INSTALL_OTA_KEYS := \
666 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
667 DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
668 $(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
669 $(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR)
670 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS)"
673 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@
675 $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) \
676 $(INSTALLED_RAMDISK_TARGET) \
677 $(INSTALLED_BOOTIMAGE_TARGET) \
679 $(recovery_initrc) $(recovery_kernel) \
680 $(INSTALLED_2NDBOOTLOADER_TARGET) \
681 $(recovery_build_prop) $(recovery_resource_deps) \
682 $(RECOVERY_INSTALL_OTA_KEYS)
683 @echo ----- Making recovery image ------
684 rm -rf $(TARGET_RECOVERY_OUT)
685 mkdir -p $(TARGET_RECOVERY_OUT)
686 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)
687 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc
688 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp
689 echo Copying baseline ramdisk...
690 cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
691 echo Modifying ramdisk contents...
692 cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
693 cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
694 cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
695 $(foreach item,$(recovery_resources_private), \
696 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
697 cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
698 cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
699 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
700 $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | gzip > $(recovery_ramdisk)
701 $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@
702 @echo ----- Made recovery image -------- $@
703 $(hide) $(call assert-max-file-size,$@,$(BOARD_RECOVERYIMAGE_MAX_SIZE))
706 INSTALLED_RECOVERYIMAGE_TARGET :=
709 .PHONY: recoveryimage
710 recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET)
712 # -----------------------------------------------------------------
713 # bring in the installer image generation defines if necessary
714 ifeq ($(TARGET_USE_DISKINSTALLER),true)
715 include bootable/diskinstaller/config.mk
718 # -----------------------------------------------------------------
720 name := $(TARGET_PRODUCT)
721 ifeq ($(TARGET_BUILD_TYPE),debug)
722 name := $(name)_debug
724 name := $(name)-ota-$(FILE_NAME_TAG)
726 INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
727 INTERNAL_OTA_INTERMEDIATES_DIR := $(call intermediates-dir-for,PACKAGING,ota)
729 # If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
730 ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
731 INTERNAL_OTA_RECOVERYIMAGE_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/system/recovery.img
733 INTERNAL_OTA_RECOVERYIMAGE_TARGET :=
735 INTERNAL_OTA_SCRIPT_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/META-INF/com/google/android/update-script
737 # Sign OTA packages with the test key by default.
738 # Actual product deliverables will be re-signed by hand.
739 private_key := $(SRC_TARGET_DIR)/product/security/testkey.pk8
740 certificate := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
741 $(INTERNAL_OTA_PACKAGE_TARGET): $(private_key) $(certificate) $(SIGNAPK_JAR)
742 $(INTERNAL_OTA_PACKAGE_TARGET): PRIVATE_PRIVATE_KEY := $(private_key)
743 $(INTERNAL_OTA_PACKAGE_TARGET): PRIVATE_CERTIFICATE := $(certificate)
745 # Depending on INSTALLED_SYSTEMIMAGE guarantees that SYSTEMIMAGE_SOURCE_DIR
746 # is up-to-date. We use jar instead of zip so that we can use the -C
747 # switch to avoid cd-ing all over the place.
748 # TODO: Make our own jar-creation tool to avoid all these shenanigans.
749 $(INTERNAL_OTA_PACKAGE_TARGET): \
750 $(INTERNAL_OTA_SCRIPT_TARGET) \
751 $(INTERNAL_OTA_RECOVERYIMAGE_TARGET) \
752 $(INSTALLED_BOOTIMAGE_TARGET) \
753 $(INSTALLED_RADIOIMAGE_TARGET) \
754 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
755 $(INSTALLED_SYSTEMIMAGE)
756 @echo "Package OTA: $@"
760 $(INSTALLED_BOOTIMAGE_TARGET) \
761 $(INSTALLED_RADIOIMAGE_TARGET) \
762 $(INSTALLED_ANDROID_INFO_TXT_TARGET), \
763 -C $(dir $(item)) $(notdir $(item))) \
764 -C $(INTERNAL_OTA_INTERMEDIATES_DIR) .
765 $(hide) find $(SYSTEMIMAGE_SOURCE_DIR) -type f -print | \
766 sed 's|^$(dir $(SYSTEMIMAGE_SOURCE_DIR))|-C & |' | \
768 $(hide) if jar tf $@ | egrep '.{65}' >&2; then \
769 echo "Path too long (>64 chars) for OTA update" >&2; \
774 $(INTERNAL_OTA_SCRIPT_TARGET): \
775 $(HOST_OUT_EXECUTABLES)/make-update-script \
776 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
777 $(INSTALLED_SYSTEMIMAGE)
780 @echo "Update script: $@"
781 $(hide) TARGET_DEVICE=$(TARGET_DEVICE) \
782 $< $(SYSTEMIMAGE_SOURCE_DIR) \
783 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
786 ifneq (,$(INTERNAL_OTA_RECOVERYIMAGE_TARGET))
787 # This copy is so recovery.img can be in /system within the OTA package.
788 # That way it gets installed into the system image, which in turn installs it.
789 $(INTERNAL_OTA_RECOVERYIMAGE_TARGET): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ACP)
795 otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
797 # Keys authorized to sign OTA packages this build will accept. The
798 # build always uses test-keys for this; release packaging tools will
799 # substitute other keys for this one.
800 OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
802 # Build a keystore with the authorized keys in it.
803 # java/android/android/server/checkin/UpdateVerifier.java uses this.
804 ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
805 $(TARGET_OUT_ETC)/security/otacerts.zip: $(OTA_PUBLIC_KEYS)
807 $(hide) mkdir -p $(dir $@)
808 zip -qj $@ $(OTA_PUBLIC_KEYS)
810 # The device does not support JKS.
811 # $(hide) for f in $(OTA_PUBLIC_KEYS); do \
812 # echo "keytool: $@ <= $$f" && \
813 # keytool -keystore $@ -storepass $(notdir $@) -noprompt \
814 # -import -file $$f -alias $(notdir $$f) || exit 1; \
817 # -----------------------------------------------------------------
818 # A zip of the directories that map to the target filesystem.
819 # This zip can be used to create an OTA package or filesystem image
820 # as a post-build step.
822 name := $(TARGET_PRODUCT)
823 ifeq ($(TARGET_BUILD_TYPE),debug)
824 name := $(name)_debug
826 name := $(name)-target_files-$(FILE_NAME_TAG)
828 intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
829 BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
830 $(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
831 $(BUILT_TARGET_FILES_PACKAGE): \
832 zip_root := $(intermediates)/$(name)
834 # $(1): Directory to copy
835 # $(2): Location to copy it to
836 # The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
837 define package_files-copy-root
838 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
840 $(ACP) -rd $(strip $(1))/* $(2); \
845 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
846 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq
847 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
849 # Depending on the various images guarantees that the underlying
850 # directories are up-to-date.
851 $(BUILT_TARGET_FILES_PACKAGE): \
852 $(INTERNAL_OTA_SCRIPT_TARGET) \
853 $(INSTALLED_BOOTIMAGE_TARGET) \
854 $(INSTALLED_RADIOIMAGE_TARGET) \
855 $(INSTALLED_RECOVERYIMAGE_TARGET) \
856 $(BUILT_SYSTEMIMAGE) \
857 $(INSTALLED_USERDATAIMAGE_TARGET) \
858 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
859 $(INTERNAL_OTA_SCRIPT_TARGET) \
863 @echo "Package target files: $@"
864 $(hide) rm -rf $@ $(zip_root)
865 $(hide) mkdir -p $(dir $@) $(zip_root)
866 @# Components of the recovery image
867 $(hide) mkdir -p $(zip_root)/RECOVERY
868 $(hide) $(call package_files-copy-root, \
869 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
870 ifdef INSTALLED_KERNEL_TARGET
871 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
873 ifdef INSTALLED_2NDBOOTLOADER_TARGET
875 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
877 ifdef BOARD_KERNEL_CMDLINE
878 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
880 @# Components of the boot image
881 $(hide) mkdir -p $(zip_root)/BOOT
882 $(hide) $(call package_files-copy-root, \
883 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
884 ifdef INSTALLED_KERNEL_TARGET
885 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
887 ifdef INSTALLED_2NDBOOTLOADER_TARGET
889 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
891 ifdef BOARD_KERNEL_CMDLINE
892 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
894 ifdef INSTALLED_RADIOIMAGE_TARGET
896 $(hide) mkdir -p $(zip_root)/RADIO
897 $(hide) $(ACP) $(INSTALLED_RADIOIMAGE_TARGET) $(zip_root)/RADIO/image
899 @# Contents of the system image
900 $(hide) $(call package_files-copy-root, \
901 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
902 @# Contents of the data image
903 $(hide) $(call package_files-copy-root, \
904 $(TARGET_OUT_DATA),$(zip_root)/DATA)
905 @# Extra contents of the OTA package
906 $(hide) mkdir -p $(zip_root)/OTA/bin
907 $(hide) $(call package_files-copy-root, \
908 $(INTERNAL_OTA_INTERMEDIATES_DIR),$(zip_root)/OTA)
909 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
910 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
911 @# Files that don't end up in any images, but are necessary to
913 $(hide) mkdir -p $(zip_root)/META
914 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
915 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
916 @# Zip everything up, preserving symlinks
917 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
919 target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
921 # -----------------------------------------------------------------
922 # installed file list
923 # Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it
924 # gets the DexOpt one if we're doing that.
925 INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
926 $(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE)
927 @echo Installed file list: $@
930 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@
932 .PHONY: installed-file-list
933 installed-file-list: $(INSTALLED_FILES_FILE)
934 $(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE))
935 $(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
937 # -----------------------------------------------------------------
938 # A zip of the tests that are built when running "make tests".
939 # This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
940 # only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
942 name := $(TARGET_PRODUCT)
943 ifeq ($(TARGET_BUILD_TYPE),debug)
944 name := $(name)_debug
946 name := $(name)-tests-$(FILE_NAME_TAG)
948 intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
949 BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
950 $(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
951 $(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
953 # Depending on the images guarantees that the underlying
954 # directories are up-to-date.
955 $(BUILT_TESTS_ZIP_PACKAGE): \
956 $(BUILT_SYSTEMIMAGE) \
957 $(INSTALLED_USERDATAIMAGE_TARGET) \
959 @echo "Package test files: $@"
960 $(hide) rm -rf $@ $(zip_root)
961 $(hide) mkdir -p $(dir $@) $(zip_root)
962 @# Some parts of the system image
963 $(hide) $(call package_files-copy-root, \
964 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin)
965 $(hide) $(call package_files-copy-root, \
966 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib)
967 $(hide) $(call package_files-copy-root, \
968 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \
969 $(zip_root)/SYSTEM/framework)
970 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM
971 @# Contents of the data image
972 $(hide) $(call package_files-copy-root, \
973 $(TARGET_OUT_DATA),$(zip_root)/DATA)
974 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
976 tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
978 # -----------------------------------------------------------------
979 # A zip of the symbols directory. Keep the full paths to make it
980 # more obvious where these files came from.
982 name := $(TARGET_PRODUCT)
983 ifeq ($(TARGET_BUILD_TYPE),debug)
984 name := $(name)_debug
986 name := $(name)-symbols-$(FILE_NAME_TAG)
988 SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
989 $(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
990 @echo "Package symbols: $@"
992 $(hide) mkdir -p $(dir $@)
993 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
995 # -----------------------------------------------------------------
996 # A zip of the Android Apps. Not keeping full path so that we don't
997 # include product names when distributing
999 name := $(TARGET_PRODUCT)
1000 ifeq ($(TARGET_BUILD_TYPE),debug)
1001 name := $(name)_debug
1003 name := $(name)-apps-$(FILE_NAME_TAG)
1005 APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
1006 $(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
1007 @echo "Package apps: $@"
1009 $(hide) mkdir -p $(dir $@)
1010 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
1012 endif # TARGET_SIMULATOR != true
1014 # -----------------------------------------------------------------
1017 dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1019 # -----------------------------------------------------------------
1020 # The update package
1022 INTERNAL_UPDATE_PACKAGE_FILES += \
1023 $(INSTALLED_BOOTIMAGE_TARGET) \
1024 $(INSTALLED_RECOVERYIMAGE_TARGET) \
1025 $(INSTALLED_SYSTEMIMAGE) \
1026 $(INSTALLED_USERDATAIMAGE_TARGET) \
1027 $(INSTALLED_ANDROID_INFO_TXT_TARGET)
1029 ifneq ($(strip $(INTERNAL_UPDATE_PACKAGE_FILES)),)
1031 name := $(TARGET_PRODUCT)
1032 ifeq ($(TARGET_BUILD_TYPE),debug)
1033 name := $(name)_debug
1035 name := $(name)-img-$(FILE_NAME_TAG)
1037 INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1039 $(INTERNAL_UPDATE_PACKAGE_TARGET): $(INTERNAL_UPDATE_PACKAGE_FILES)
1041 $(hide) zip -qj $@ $(INTERNAL_UPDATE_PACKAGE_FILES)
1044 INTERNAL_UPDATE_PACKAGE_TARGET :=
1047 # -----------------------------------------------------------------
1048 # The emulator package
1050 ifneq ($(TARGET_SIMULATOR),true)
1052 INTERNAL_EMULATOR_PACKAGE_FILES += \
1053 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
1054 prebuilt/android-arm/kernel/kernel-qemu \
1055 $(INSTALLED_RAMDISK_TARGET) \
1056 $(INSTALLED_SYSTEMIMAGE) \
1057 $(INSTALLED_USERDATAIMAGE_TARGET)
1059 name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1061 INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1063 $(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1065 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1069 # -----------------------------------------------------------------
1070 # The pdk package (Platform Development Kit)
1072 ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1073 include development/pdk/Pdk.mk
1076 # -----------------------------------------------------------------
1079 ifneq ($(TARGET_SIMULATOR),true)
1081 # The SDK includes host-specific components, so it belongs under HOST_OUT.
1082 sdk_dir := $(HOST_OUT)/sdk
1084 # Build a name that looks like:
1086 # linux-x86 --> android-sdk_12345_linux-x86
1087 # darwin-x86 --> android-sdk_12345_mac-x86
1088 # windows-x86 --> android-sdk_12345_windows
1090 sdk_name := android-sdk_$(FILE_NAME_TAG)
1091 ifeq ($(HOST_OS),darwin)
1092 INTERNAL_SDK_HOST_OS_NAME := mac
1094 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
1096 ifneq ($(HOST_OS),windows)
1097 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
1099 sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
1101 sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1104 -include $(sdk_dep_file)
1106 # if we don't have a real list, then use "everything"
1107 ifeq ($(strip $(ATREE_FILES)),)
1110 $(ALL_COPIED_HEADERS) \
1111 $(ALL_GENERATED_SOURCES) \
1112 $(ALL_DEFAULT_INSTALLED_MODULES) \
1113 $(INSTALLED_RAMDISK_TARGET) \
1118 atree_dir := development/build
1120 sdk_atree_files := \
1121 $(atree_dir)/sdk.exclude.atree \
1122 $(atree_dir)/sdk.atree \
1123 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree
1126 $(target_notice_file_txt) \
1127 $(tools_notice_file_txt) \
1128 $(OUT_DOCS)/offline-sdk-timestamp \
1129 $(INTERNAL_UPDATE_PACKAGE_TARGET) \
1130 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
1132 $(atree_dir)/sdk.atree \
1133 $(HOST_OUT_EXECUTABLES)/atree \
1134 $(HOST_OUT_EXECUTABLES)/line_endings
1136 INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1137 $(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1138 $(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1139 $(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1140 $(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1142 # Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1144 #SDK_GNU_ERROR := true
1146 $(INTERNAL_SDK_TARGET): $(deps)
1147 @echo "Package SDK: $@"
1148 $(hide) rm -rf $(PRIVATE_DIR) $@
1149 $(hide) for f in $(target_gnu_MODULES); do \
1150 if [ -f $$f ]; then \
1151 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1152 including GNU target $$f >&2; \
1153 FAIL=$(SDK_GNU_ERROR); \
1156 if [ $$FAIL ]; then exit 1; fi
1158 $(HOST_OUT_EXECUTABLES)/atree \
1159 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1160 -m $(PRIVATE_DEP_FILE) \
1164 -I $(TARGET_COMMON_OUT_ROOT) \
1165 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
1166 -o $(PRIVATE_DIR) && \
1167 cp -f $(target_notice_file_txt) \
1168 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \
1169 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
1170 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
1171 development/tools/scripts/sdk_clean.sh $(PRIVATE_DIR) && \
1172 chmod -R ug+rwX $(PRIVATE_DIR) && \
1173 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1174 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1178 # -----------------------------------------------------------------
1180 INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1181 INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1182 $(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1184 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1186 $(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1187 @echo ConvertXmlToText: $@
1188 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1189 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1191 # -----------------------------------------------------------------
1194 # -----------------------------------------------------------------
1195 # These are some additional build tasks that need to be run.
1196 include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))