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 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
130 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
131 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
132 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
133 bash $(BUILDINFO_SH) > $@
134 $(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \
135 cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \
137 $(if $(ADDITIONAL_BUILD_PROPERTIES), \
138 $(hide) echo >> $@; \
140 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
142 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
143 echo "$(line)" >> $@;)
147 # -----------------------------------------------------------------
150 # There are certain things in build.prop that we don't want to
151 # ship with the sdk; remove them.
153 # This must be a list of entire property keys followed by
154 # "=" characters, without any internal spaces.
155 sdk_build_prop_remove := \
159 ro.product.manufacturer= \
161 # TODO: Remove this soon-to-be obsolete property
162 sdk_build_prop_remove += ro.build.product=
163 INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
164 $(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
165 @echo SDK buildinfo: $@
167 $(hide) grep -v "$(subst $(space),\|,$(strip \
168 $(sdk_build_prop_remove)))" $< > $@.tmp
169 $(hide) for x in $(sdk_build_prop_remove); do \
170 echo "$$x"generic >> $@.tmp; done
173 # -----------------------------------------------------------------
175 PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
176 PACKAGES_TO_STAT := \
177 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
178 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
179 $(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
180 @echo Package stats: $@
183 $(hide) build/tools/dump-package-stats $^ > $@
185 .PHONY: package-stats
186 package-stats: $(PACKAGE_STATS_FILE)
188 # -----------------------------------------------------------------
189 # Cert-to-package mapping. Used by the post-build signing tools.
190 name := $(TARGET_PRODUCT)
191 ifeq ($(TARGET_BUILD_TYPE),debug)
192 name := $(name)_debug
194 name := $(name)-apkcerts-$(FILE_NAME_TAG)
196 $(call intermediates-dir-for,PACKAGING,apkcerts)
197 APKCERTS_FILE := $(intermediates)/$(name).txt
198 # Depending on the built packages isn't exactly right,
199 # but it should guarantee that the apkcerts file is rebuilt
200 # if any packages change which certs they're signed with.
201 all_built_packages := $(foreach p,$(PACKAGES),$(ALL_MODULES.$(p).BUILT))
202 $(APKCERTS_FILE): $(all_built_packages)
203 @echo APK certs list: $@
206 $(hide) $(foreach p,$(PACKAGES),\
207 echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
208 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;)
210 .PHONY: apkcerts-list
211 apkcerts-list: $(APKCERTS_FILE)
213 # -----------------------------------------------------------------
215 ifdef CREATE_MODULE_INFO_FILE
216 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
217 $(info Generating $(MODULE_INFO_FILE)...)
218 $(shell rm -f $(MODULE_INFO_FILE))
219 $(foreach m,$(ALL_MODULES), \
220 $(shell echo "NAME=\"$(m)\"" \
221 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
222 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
223 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
224 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
227 # Rules that need to be present for the simulator, even
228 # if they don't do anything.
232 ifneq ($(TARGET_SIMULATOR),true)
234 # #################################################################
235 # Targets for boot/OS images
236 # #################################################################
238 # -----------------------------------------------------------------
240 INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
242 $(ALL_COPIED_HEADERS) \
243 $(ALL_GENERATED_SOURCES) \
244 $(ALL_DEFAULT_INSTALLED_MODULES))
246 BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
248 # We just build this directly to the install location.
249 INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
250 $(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES)
251 $(call pretty,"Target ram disk: $@")
252 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | gzip > $@
255 ifneq ($(strip $(TARGET_NO_KERNEL)),true)
257 # -----------------------------------------------------------------
258 # the boot image, which is a collection of other images.
259 INTERNAL_BOOTIMAGE_ARGS := \
260 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
261 --kernel $(INSTALLED_KERNEL_TARGET) \
262 --ramdisk $(INSTALLED_RAMDISK_TARGET)
264 INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
266 BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
267 ifdef BOARD_KERNEL_CMDLINE
268 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
271 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
273 ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
274 tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
275 INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
276 INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
277 $(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
278 $(call pretty,"Target boot image: $@")
279 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
281 else # TARGET_BOOTIMAGE_USE_EXT2 != true
283 $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
284 $(call pretty,"Target boot image: $@")
285 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
286 $(hide) $(call assert-max-file-size,$@,$(BOARD_BOOTIMAGE_MAX_SIZE))
287 endif # TARGET_BOOTIMAGE_USE_EXT2
289 else # TARGET_NO_KERNEL
290 # HACK: The top-level targets depend on the bootimage. Not all targets
291 # can produce a bootimage, though, and emulator targets need the ramdisk
292 # instead. Fake it out by calling the ramdisk the bootimage.
293 # TODO: make the emulator use bootimages, and make mkbootimg accept
294 # kernel-less inputs.
295 INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
298 # -----------------------------------------------------------------
301 # This needs to be before the systemimage rules, because it adds to
302 # ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
303 # go into the systemimage.
307 # Create the rule to combine the files into text and html forms
308 # $(1) - Plain text output file
309 # $(2) - HTML output file
311 # $(4) - Directory to use. Notice files are all $(4)/src. Other
312 # directories in there will be used for scratch
313 # $(5) - Dependencies for the output files
315 # The algorithm here is that we go collect a hash for each of the notice
316 # files and write the names of the files that match that hash. Then
317 # to generate the real files, we go print out all of the files and their
320 # These rules are fairly complex, so they depend on this makefile so if
321 # it changes, they'll run again.
323 # TODO: We could clean this up so that we just record the locations of the
324 # original notice files instead of making rules to copy them somwehere.
325 # Then we could traverse that without quite as much bash drama.
326 define combine-notice-files
327 $(1) $(2): PRIVATE_MESSAGE := $(3)
328 $(1) $(2) $(4)/hash-timestamp: PRIVATE_DIR := $(4)
329 $(4)/hash-timestamp: $(5) $(BUILD_SYSTEM)/Makefile
330 @echo Finding NOTICE files: $$@
331 $$(hide) rm -rf $$@ $$(PRIVATE_DIR)/hash
332 $$(hide) mkdir -p $$(PRIVATE_DIR)/hash
333 $$(hide) for file in $$$$(find $$(PRIVATE_DIR)/src -type f); do \
334 hash=$$$$($(MD5SUM) $$$$file | sed -e "s/ .*//"); \
335 hashfile=$$(PRIVATE_DIR)/hash/$$$$hash; \
336 echo $$$$file >> $$$$hashfile; \
339 $(1): $(4)/hash-timestamp
340 @echo Combining NOTICE files: $$@
341 $$(hide) mkdir -p $$(dir $$@)
342 $$(hide) echo $$(PRIVATE_MESSAGE) > $$@
343 $$(hide) find $$(PRIVATE_DIR)/hash -type f | xargs cat | sort | \
344 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> $$@
348 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
349 echo "============================================================"\
351 echo "Notices for file(s):" >> $$@; \
352 cat $$$$hashfile | sort | \
353 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \
355 echo "------------------------------------------------------------"\
358 orig=$$$$(head -n 1 $$$$hashfile); \
359 cat $$$$orig >> $$@; \
364 $(2): $(4)/hash-timestamp
365 @echo Combining NOTICE files: $$@
366 $$(hide) mkdir -p $$(dir $$@)
367 $$(hide) echo "<html><head>" > $$@
368 $$(hide) echo "<style type=\"text/css\">" >> $$@
369 $$(hide) echo "body { padding: 0; font-family: sans-serif; }" >> $$@
370 $$(hide) echo ".same-license { background-color: #eeeeee; border-top: 20px solid white; padding: 10px; }" >> $$@
371 $$(hide) echo ".label { font-weight: bold; }" >> $$@
372 $$(hide) echo ".file-list { margin-left: 1em; font-color: blue; }" >> $$@
373 $$(hide) echo "</style>" >> $$@
374 $$(hide) echo "</head><body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">" >> $$@
375 $$(hide) echo "<table cellpading=\"0\" cellspacing=\"0\" border=\"0\">" \
377 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \
378 cat $$$$hashfile | sort | \
379 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: <a name=\"\1\"></a>:" >> \
381 echo "<tr><td class=\"same-license\">" >> $$@; \
382 echo "<div class=\"label\">Notices for file(s):</div>" >> $$@; \
383 echo "<div class=\"file-list\">" >> $$@; \
384 cat $$$$hashfile | sort | \
385 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1<br/>:" >> $$@; \
386 echo "</div><!-- file-list -->" >> $$@; \
388 orig=$$$$(head -n 1 $$$$hashfile); \
389 echo "<pre class=\"license-text\">" >> $$@; \
390 cat $$$$orig | sed -e "s/\&/\&/g" | sed -e "s/</\</g" \
391 | sed -e "s/>/\>/g" >> $$@; \
392 echo "</pre><!-- license-text -->" >> $$@; \
393 echo "</td></tr><!-- same-license -->" >> $$@; \
398 $$(hide) echo "</table>" >> $$@
399 $$(hide) echo "</body></html>" >> $$@
400 notice_files: $(1) $(2)
403 # TODO These intermediate NOTICE.txt/NOTICE.html files should go into
404 # TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
405 # the src subdirectory.
407 target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
408 target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
409 target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
410 tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
411 tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
413 kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
415 $(eval $(call combine-notice-files, \
416 $(target_notice_file_txt), \
417 $(target_notice_file_html), \
418 "Notices for files contained in the filesystem images in this directory:", \
419 $(TARGET_OUT_NOTICE_FILES), \
420 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)))
422 $(eval $(call combine-notice-files, \
423 $(tools_notice_file_txt), \
424 $(tools_notice_file_html), \
425 "Notices for files contained in the tools directory:", \
426 $(HOST_OUT_NOTICE_FILES), \
427 $(ALL_DEFAULT_INSTALLED_MODULES)))
429 # Install the html file at /system/etc/NOTICE.html.gz.
430 # This is not ideal, but this is very late in the game, after a lot of
431 # the module processing has already been done -- in fact, we used the
432 # fact that all that has been done to get the list of modules that we
433 # need notice files for.
434 $(target_notice_file_html_gz): $(target_notice_file_html)
436 installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
437 $(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
438 $(copy-file-to-target)
439 ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
441 # The kernel isn't really a module, so to get its module file in there, we
442 # make the target NOTICE files depend on this particular file too, which will
443 # then be in the right directory for the find in combine-notice-files to work.
444 $(kernel_notice_file): \
445 prebuilt/$(TARGET_PREBUILT_TAG)/kernel/LINUX_KERNEL_COPYING \
448 $(hide) mkdir -p $(dir $@)
452 # #################################################################
453 # Targets for user images
454 # #################################################################
456 ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
457 include external/genext2fs/Config.mk
458 INTERNAL_MKUSERFS := $(MKEXT2IMG)
460 INTERNAL_MKUSERFS := $(MKYAFFS2)
463 # -----------------------------------------------------------------
466 # First, the "unoptimized" image, which contains .apk/.jar files
467 # that contain regular, unoptimized/unverified .dex entries.
469 systemimage_unopt_intermediates := \
470 $(call intermediates-dir-for,PACKAGING,systemimage_unopt)
471 BUILT_SYSTEMIMAGE_UNOPT := $(systemimage_unopt_intermediates)/system.img
473 INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
475 $(ALL_COPIED_HEADERS) \
476 $(ALL_GENERATED_SOURCES) \
477 $(ALL_DEFAULT_INSTALLED_MODULES))
479 ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
480 ## generate an ext2 image
482 define build-systemimage-target
483 @echo "Target system fs image: $(1)"
484 $(call build-userimage-ext2-target,$(TARGET_OUT),$(1),system,)
487 else # TARGET_USERIMAGES_USE_EXT2 != true
489 ## generate a yaffs2 image
491 define build-systemimage-target
492 @echo "Target system fs image: $(1)"
493 @mkdir -p $(dir $(1))
494 $(hide) $(MKYAFFS2) -f $(TARGET_OUT) $(1)
496 endif # TARGET_USERIMAGES_USE_EXT2
498 $(BUILT_SYSTEMIMAGE_UNOPT): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_MKUSERFS)
499 $(call build-systemimage-target,$@)
501 # The installed image, which may be optimized or unoptimized.
503 INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
506 ifndef DISABLE_DEXPREOPT
507 with_dexpreopt := true
511 # This file will set BUILT_SYSTEMIMAGE and SYSTEMIMAGE_SOURCE_DIR
512 include build/tools/dexpreopt/Config.mk
514 BUILT_SYSTEMIMAGE := $(BUILT_SYSTEMIMAGE_UNOPT)
515 SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
518 $(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) | $(ACP)
519 @echo "Install system fs image: $@"
520 $(copy-file-to-target)
521 $(hide) $(call assert-max-file-size,$@,$(BOARD_SYSTEMIMAGE_MAX_SIZE))
523 systemimage: $(INSTALLED_SYSTEMIMAGE)
525 .PHONY: systemimage-nodeps snod
526 systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
527 | $(INTERNAL_MKUSERFS)
528 @echo "make $@: ignoring dependencies"
529 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
530 $(hide) $(call assert-max-file-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_MAX_SIZE))
534 define build-systemtarball-target
535 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
536 $(MKTARBALL) $(FS_GET_STATS) \
537 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
538 $(INSTALLED_SYSTEMTARBALL_TARGET)
541 system_tar := $(PRODUCT_OUT)/system.tar
542 INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).bz2
543 $(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
544 $(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
545 $(build-systemtarball-target)
547 .PHONY: systemtarball-nodeps
548 systemtarball-nodeps: $(FS_GET_STATS) \
549 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
550 $(build-systemtarball-target)
553 stnod: systemtarball-nodeps
556 # -----------------------------------------------------------------
557 # data partition image
558 INTERNAL_USERDATAIMAGE_FILES := \
559 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
561 ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
562 ## Generate an ext2 image
563 define build-userdataimage-target
564 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
565 @mkdir -p $(TARGET_OUT_DATA)
566 $(call build-userimage-ext2-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),userdata,)
567 $(hide) $(call assert-max-file-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_MAX_SIZE))
570 else # TARGET_USERIMAGES_USE_EXT2 != true
572 ## Generate a yaffs2 image
573 define build-userdataimage-target
574 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
575 @mkdir -p $(TARGET_OUT_DATA)
576 $(hide) $(MKYAFFS2) -f $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
577 $(hide) $(call assert-max-file-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_MAX_SIZE))
579 endif # TARGET_USERIMAGES_USE_EXT2
581 BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
583 # We just build this directly to the install location.
584 INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
585 $(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_MKUSERFS) \
586 $(INTERNAL_USERDATAIMAGE_FILES)
587 $(build-userdataimage-target)
589 .PHONY: userdataimage-nodeps
590 userdataimage-nodeps: $(INTERNAL_MKUSERFS)
591 $(build-userdataimage-target)
594 ## data partition tarball
595 define build-userdatatarball-target
596 $(call pretty,"Target userdata fs tarball: " \
597 "$(INSTALLED_USERDATATARBALL_TARGET)")
598 $(MKTARBALL) $(FS_GET_STATS) \
599 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
600 $(INSTALLED_USERDATATARBALL_TARGET)
603 userdata_tar := $(PRODUCT_OUT)/userdata.tar
604 INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
605 $(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
606 $(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
607 $(build-userdatatarball-target)
609 .PHONY: userdatatarball-nodeps
610 userdatatarball-nodeps: $(FS_GET_STATS)
611 $(build-userdatatarball-target)
614 # If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
615 ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
617 # -----------------------------------------------------------------
619 INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
621 recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
622 recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
623 recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
624 recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
625 recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
626 recovery_resources_common := $(call include-path-for, recovery)/res
627 recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
628 recovery_resource_deps := $(shell find $(recovery_resources_common) \
629 $(recovery_resources_private) -type f)
631 ifeq ($(recovery_resources_private),)
632 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
635 INTERNAL_RECOVERYIMAGE_ARGS := \
636 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
637 --kernel $(recovery_kernel) \
638 --ramdisk $(recovery_ramdisk)
640 # Assumes this has already been stripped
641 ifdef BOARD_KERNEL_CMDLINE
642 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
645 # Keys authorized to sign OTA packages this build will accept. The
646 # build always uses test-keys for this; release packaging tools will
647 # substitute other keys for this one.
648 OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
650 # Generate a file containing the keys that will be read by the
652 RECOVERY_INSTALL_OTA_KEYS := \
653 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
654 DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
655 $(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
656 $(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR)
657 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS)"
660 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@
662 $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) \
663 $(INSTALLED_RAMDISK_TARGET) \
664 $(INSTALLED_BOOTIMAGE_TARGET) \
666 $(recovery_initrc) $(recovery_kernel) \
667 $(INSTALLED_2NDBOOTLOADER_TARGET) \
668 $(recovery_build_prop) $(recovery_resource_deps) \
669 $(RECOVERY_INSTALL_OTA_KEYS)
670 @echo ----- Making recovery image ------
671 rm -rf $(TARGET_RECOVERY_OUT)
672 mkdir -p $(TARGET_RECOVERY_OUT)
673 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)
674 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc
675 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp
676 echo Copying baseline ramdisk...
677 cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
678 echo Modifying ramdisk contents...
679 cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
680 cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
681 cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
682 $(foreach item,$(recovery_resources_private), \
683 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
684 cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
685 cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
686 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
687 $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | gzip > $(recovery_ramdisk)
688 $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@
689 @echo ----- Made recovery image -------- $@
690 $(hide) $(call assert-max-file-size,$@,$(BOARD_RECOVERYIMAGE_MAX_SIZE))
693 INSTALLED_RECOVERYIMAGE_TARGET :=
696 .PHONY: recoveryimage
697 recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET)
699 # -----------------------------------------------------------------
700 # bring in the installer image generation defines if necessary
701 ifeq ($(TARGET_USE_DISKINSTALLER),true)
702 include bootable/diskinstaller/config.mk
705 # -----------------------------------------------------------------
707 name := $(TARGET_PRODUCT)
708 ifeq ($(TARGET_BUILD_TYPE),debug)
709 name := $(name)_debug
711 name := $(name)-ota-$(FILE_NAME_TAG)
713 INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
714 INTERNAL_OTA_INTERMEDIATES_DIR := $(call intermediates-dir-for,PACKAGING,ota)
716 # If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
717 ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
718 INTERNAL_OTA_RECOVERYIMAGE_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/system/recovery.img
720 INTERNAL_OTA_RECOVERYIMAGE_TARGET :=
722 INTERNAL_OTA_SCRIPT_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/META-INF/com/google/android/update-script
724 # Sign OTA packages with the test key by default.
725 # Actual product deliverables will be re-signed by hand.
726 private_key := $(SRC_TARGET_DIR)/product/security/testkey.pk8
727 certificate := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
728 $(INTERNAL_OTA_PACKAGE_TARGET): $(private_key) $(certificate) $(SIGNAPK_JAR)
729 $(INTERNAL_OTA_PACKAGE_TARGET): PRIVATE_PRIVATE_KEY := $(private_key)
730 $(INTERNAL_OTA_PACKAGE_TARGET): PRIVATE_CERTIFICATE := $(certificate)
732 # Depending on INSTALLED_SYSTEMIMAGE guarantees that SYSTEMIMAGE_SOURCE_DIR
733 # is up-to-date. We use jar instead of zip so that we can use the -C
734 # switch to avoid cd-ing all over the place.
735 # TODO: Make our own jar-creation tool to avoid all these shenanigans.
736 $(INTERNAL_OTA_PACKAGE_TARGET): \
737 $(INTERNAL_OTA_SCRIPT_TARGET) \
738 $(INTERNAL_OTA_RECOVERYIMAGE_TARGET) \
739 $(INSTALLED_BOOTIMAGE_TARGET) \
740 $(INSTALLED_RADIOIMAGE_TARGET) \
741 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
742 $(INSTALLED_SYSTEMIMAGE)
743 @echo "Package OTA: $@"
747 $(INSTALLED_BOOTIMAGE_TARGET) \
748 $(INSTALLED_RADIOIMAGE_TARGET) \
749 $(INSTALLED_ANDROID_INFO_TXT_TARGET), \
750 -C $(dir $(item)) $(notdir $(item))) \
751 -C $(INTERNAL_OTA_INTERMEDIATES_DIR) .
752 $(hide) find $(SYSTEMIMAGE_SOURCE_DIR) -type f -print | \
753 sed 's|^$(dir $(SYSTEMIMAGE_SOURCE_DIR))|-C & |' | \
755 $(hide) if jar tf $@ | egrep '.{65}' >&2; then \
756 echo "Path too long (>64 chars) for OTA update" >&2; \
761 $(INTERNAL_OTA_SCRIPT_TARGET): \
762 $(HOST_OUT_EXECUTABLES)/make-update-script \
763 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
764 $(INSTALLED_SYSTEMIMAGE)
767 @echo "Update script: $@"
768 $(hide) TARGET_DEVICE=$(TARGET_DEVICE) \
769 $< $(SYSTEMIMAGE_SOURCE_DIR) \
770 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
773 ifneq (,$(INTERNAL_OTA_RECOVERYIMAGE_TARGET))
774 # This copy is so recovery.img can be in /system within the OTA package.
775 # That way it gets installed into the system image, which in turn installs it.
776 $(INTERNAL_OTA_RECOVERYIMAGE_TARGET): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ACP)
782 otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
784 # Keys authorized to sign OTA packages this build will accept. The
785 # build always uses test-keys for this; release packaging tools will
786 # substitute other keys for this one.
787 OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem
789 # Build a keystore with the authorized keys in it.
790 # java/android/android/server/checkin/UpdateVerifier.java uses this.
791 ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
792 $(TARGET_OUT_ETC)/security/otacerts.zip: $(OTA_PUBLIC_KEYS)
794 $(hide) mkdir -p $(dir $@)
795 zip -qj $@ $(OTA_PUBLIC_KEYS)
797 # The device does not support JKS.
798 # $(hide) for f in $(OTA_PUBLIC_KEYS); do \
799 # echo "keytool: $@ <= $$f" && \
800 # keytool -keystore $@ -storepass $(notdir $@) -noprompt \
801 # -import -file $$f -alias $(notdir $$f) || exit 1; \
804 # -----------------------------------------------------------------
805 # A zip of the directories that map to the target filesystem.
806 # This zip can be used to create an OTA package or filesystem image
807 # as a post-build step.
809 name := $(TARGET_PRODUCT)
810 ifeq ($(TARGET_BUILD_TYPE),debug)
811 name := $(name)_debug
813 name := $(name)-target_files-$(FILE_NAME_TAG)
815 intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
816 BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
817 $(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
818 $(BUILT_TARGET_FILES_PACKAGE): \
819 zip_root := $(intermediates)/$(name)
821 # $(1): Directory to copy
822 # $(2): Location to copy it to
823 # The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
824 define package_files-copy-root
825 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
827 $(ACP) -rd $(strip $(1))/* $(2); \
832 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
833 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq
834 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
836 # Depending on the various images guarantees that the underlying
837 # directories are up-to-date.
838 $(BUILT_TARGET_FILES_PACKAGE): \
839 $(INTERNAL_OTA_SCRIPT_TARGET) \
840 $(INSTALLED_BOOTIMAGE_TARGET) \
841 $(INSTALLED_RADIOIMAGE_TARGET) \
842 $(INSTALLED_RECOVERYIMAGE_TARGET) \
843 $(BUILT_SYSTEMIMAGE) \
844 $(INSTALLED_USERDATAIMAGE_TARGET) \
845 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
846 $(INTERNAL_OTA_SCRIPT_TARGET) \
850 @echo "Package target files: $@"
851 $(hide) rm -rf $@ $(zip_root)
852 $(hide) mkdir -p $(dir $@) $(zip_root)
853 @# Components of the recovery image
854 $(hide) mkdir -p $(zip_root)/RECOVERY
855 $(hide) $(call package_files-copy-root, \
856 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
857 ifdef INSTALLED_KERNEL_TARGET
858 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
860 ifdef INSTALLED_2NDBOOTLOADER_TARGET
862 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
864 ifdef BOARD_KERNEL_CMDLINE
865 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
867 @# Components of the boot image
868 $(hide) mkdir -p $(zip_root)/BOOT
869 $(hide) $(call package_files-copy-root, \
870 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
871 ifdef INSTALLED_KERNEL_TARGET
872 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
874 ifdef INSTALLED_2NDBOOTLOADER_TARGET
876 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
878 ifdef BOARD_KERNEL_CMDLINE
879 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
881 ifdef INSTALLED_RADIOIMAGE_TARGET
883 $(hide) mkdir -p $(zip_root)/RADIO
884 $(hide) $(ACP) $(INSTALLED_RADIOIMAGE_TARGET) $(zip_root)/RADIO/image
886 @# Contents of the system image
887 $(hide) $(call package_files-copy-root, \
888 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
889 @# Contents of the data image
890 $(hide) $(call package_files-copy-root, \
891 $(TARGET_OUT_DATA),$(zip_root)/DATA)
892 @# Extra contents of the OTA package
893 $(hide) mkdir -p $(zip_root)/OTA/bin
894 $(hide) $(call package_files-copy-root, \
895 $(INTERNAL_OTA_INTERMEDIATES_DIR),$(zip_root)/OTA)
896 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
897 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
898 @# Files that don't end up in any images, but are necessary to
900 $(hide) mkdir -p $(zip_root)/META
901 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
902 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
903 @# Zip everything up, preserving symlinks
904 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
906 target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
908 # -----------------------------------------------------------------
909 # installed file list
910 # Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it
911 # gets the DexOpt one if we're doing that.
912 INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
913 $(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE)
914 @echo Installed file list: $@
917 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@
919 .PHONY: installed-file-list
920 installed-file-list: $(INSTALLED_FILES_FILE)
921 $(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE))
922 $(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE))
924 # -----------------------------------------------------------------
925 # A zip of the tests that are built when running "make tests".
926 # This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
927 # only grab SYSTEM and DATA, and it's called "*-tests-*.zip".
929 name := $(TARGET_PRODUCT)
930 ifeq ($(TARGET_BUILD_TYPE),debug)
931 name := $(name)_debug
933 name := $(name)-tests-$(FILE_NAME_TAG)
935 intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
936 BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
937 $(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
938 $(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
940 # Depending on the images guarantees that the underlying
941 # directories are up-to-date.
942 $(BUILT_TESTS_ZIP_PACKAGE): \
943 $(BUILT_SYSTEMIMAGE) \
944 $(INSTALLED_USERDATAIMAGE_TARGET) \
946 @echo "Package test files: $@"
947 $(hide) rm -rf $@ $(zip_root)
948 $(hide) mkdir -p $(dir $@) $(zip_root)
949 @# Some parts of the system image
950 $(hide) $(call package_files-copy-root, \
951 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin)
952 $(hide) $(call package_files-copy-root, \
953 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib)
954 $(hide) $(call package_files-copy-root, \
955 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \
956 $(zip_root)/SYSTEM/framework)
957 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM
958 @# Contents of the data image
959 $(hide) $(call package_files-copy-root, \
960 $(TARGET_OUT_DATA),$(zip_root)/DATA)
961 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
963 tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE)
965 # -----------------------------------------------------------------
966 # A zip of the symbols directory. Keep the full paths to make it
967 # more obvious where these files came from.
969 name := $(TARGET_PRODUCT)
970 ifeq ($(TARGET_BUILD_TYPE),debug)
971 name := $(name)_debug
973 name := $(name)-symbols-$(FILE_NAME_TAG)
975 SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
976 $(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
977 @echo "Package symbols: $@"
979 $(hide) mkdir -p $(dir $@)
980 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
982 # -----------------------------------------------------------------
983 # A zip of the Android Apps. Not keeping full path so that we don't
984 # include product names when distributing
986 name := $(TARGET_PRODUCT)
987 ifeq ($(TARGET_BUILD_TYPE),debug)
988 name := $(name)_debug
990 name := $(name)-apps-$(FILE_NAME_TAG)
992 APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
993 $(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
994 @echo "Package apps: $@"
996 $(hide) mkdir -p $(dir $@)
997 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*
999 endif # TARGET_SIMULATOR != true
1001 # -----------------------------------------------------------------
1004 dalvikfiles: $(INTERNAL_DALVIK_MODULES)
1006 # -----------------------------------------------------------------
1007 # The update package
1009 INTERNAL_UPDATE_PACKAGE_FILES += \
1010 $(INSTALLED_BOOTIMAGE_TARGET) \
1011 $(INSTALLED_RECOVERYIMAGE_TARGET) \
1012 $(INSTALLED_SYSTEMIMAGE) \
1013 $(INSTALLED_USERDATAIMAGE_TARGET) \
1014 $(INSTALLED_ANDROID_INFO_TXT_TARGET)
1016 ifneq ($(strip $(INTERNAL_UPDATE_PACKAGE_FILES)),)
1018 name := $(TARGET_PRODUCT)
1019 ifeq ($(TARGET_BUILD_TYPE),debug)
1020 name := $(name)_debug
1022 name := $(name)-img-$(FILE_NAME_TAG)
1024 INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1026 $(INTERNAL_UPDATE_PACKAGE_TARGET): $(INTERNAL_UPDATE_PACKAGE_FILES)
1028 $(hide) zip -qj $@ $(INTERNAL_UPDATE_PACKAGE_FILES)
1031 INTERNAL_UPDATE_PACKAGE_TARGET :=
1034 # -----------------------------------------------------------------
1035 # The emulator package
1037 ifneq ($(TARGET_SIMULATOR),true)
1039 INTERNAL_EMULATOR_PACKAGE_FILES += \
1040 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
1041 prebuilt/android-arm/kernel/kernel-qemu \
1042 $(INSTALLED_RAMDISK_TARGET) \
1043 $(INSTALLED_SYSTEMIMAGE) \
1044 $(INSTALLED_USERDATAIMAGE_TARGET)
1046 name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
1048 INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
1050 $(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
1052 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
1056 # -----------------------------------------------------------------
1057 # The pdk package (Platform Development Kit)
1059 ifneq (,$(filter pdk,$(MAKECMDGOALS)))
1060 include development/pdk/Pdk.mk
1063 # -----------------------------------------------------------------
1066 ifneq ($(TARGET_SIMULATOR),true)
1068 # The SDK includes host-specific components, so it belongs under HOST_OUT.
1069 sdk_dir := $(HOST_OUT)/sdk
1071 # Build a name that looks like:
1073 # linux-x86 --> android-sdk_12345_linux-x86
1074 # darwin-x86 --> android-sdk_12345_mac-x86
1075 # windows-x86 --> android-sdk_12345_windows
1077 sdk_name := android-sdk_$(FILE_NAME_TAG)
1078 ifeq ($(HOST_OS),darwin)
1079 INTERNAL_SDK_HOST_OS_NAME := mac
1081 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
1083 ifneq ($(HOST_OS),windows)
1084 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH)
1086 sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
1088 sdk_dep_file := $(sdk_dir)/sdk_deps.mk
1091 -include $(sdk_dep_file)
1093 # if we don't have a real list, then use "everything"
1094 ifeq ($(strip $(ATREE_FILES)),)
1097 $(ALL_COPIED_HEADERS) \
1098 $(ALL_GENERATED_SOURCES) \
1099 $(ALL_DEFAULT_INSTALLED_MODULES) \
1100 $(INSTALLED_RAMDISK_TARGET) \
1105 atree_dir := development/build
1107 sdk_atree_files := \
1108 $(atree_dir)/sdk.exclude.atree \
1109 $(atree_dir)/sdk.atree \
1110 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree
1113 $(target_notice_file_txt) \
1114 $(tools_notice_file_txt) \
1115 $(OUT_DOCS)/offline-sdk-timestamp \
1116 $(INTERNAL_UPDATE_PACKAGE_TARGET) \
1117 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
1119 $(atree_dir)/sdk.atree \
1120 $(HOST_OUT_EXECUTABLES)/atree \
1121 $(HOST_OUT_EXECUTABLES)/line_endings
1123 INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
1124 $(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
1125 $(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
1126 $(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
1127 $(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
1129 # Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
1131 #SDK_GNU_ERROR := true
1133 $(INTERNAL_SDK_TARGET): $(deps)
1134 @echo "Package SDK: $@"
1135 $(hide) rm -rf $(PRIVATE_DIR) $@
1136 $(hide) for f in $(target_gnu_MODULES); do \
1137 if [ -f $$f ]; then \
1138 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
1139 including GNU target $$f >&2; \
1140 FAIL=$(SDK_GNU_ERROR); \
1143 if [ $$FAIL ]; then exit 1; fi
1145 $(HOST_OUT_EXECUTABLES)/atree \
1146 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
1147 -m $(PRIVATE_DEP_FILE) \
1151 -I $(TARGET_COMMON_OUT_ROOT) \
1152 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
1153 -o $(PRIVATE_DIR) && \
1154 cp -f $(target_notice_file_txt) \
1155 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \
1156 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
1157 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
1158 development/tools/scripts/sdk_clean.sh $(PRIVATE_DIR) && \
1159 chmod -R ug+rwX $(PRIVATE_DIR) && \
1160 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
1161 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
1165 # -----------------------------------------------------------------
1167 INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
1168 INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
1169 $(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
1171 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \
1173 $(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
1174 @echo ConvertXmlToText: $@
1175 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \
1176 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
1178 # -----------------------------------------------------------------
1181 # -----------------------------------------------------------------
1182 # These are some additional build tasks that need to be run.
1183 include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))