Makefile revision 9537884b0dabe81bf612c79d12c7b4bf40de10a5
1# 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". 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)) \ 23 ) 24 25# ----------------------------------------------------------------- 26# docs/index.html 27gen := $(OUT_DOCS)/index.html 28ALL_DOCS += $(gen) 29$(gen): frameworks/base/docs/docs-redirect-index.html 30 @mkdir -p $(dir $@) 31 @cp -f $< $@ 32 33# ----------------------------------------------------------------- 34# default.prop 35INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop 36ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET) 37ADDITIONAL_DEFAULT_PROPERTIES := \ 38 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES)) 39 40$(INSTALLED_DEFAULT_PROP_TARGET): 41 @echo Target buildinfo: $@ 42 @mkdir -p $(dir $@) 43 $(hide) echo "#" > $@; \ 44 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \ 45 echo "#" >> $@; 46 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \ 47 echo "$(line)" >> $@;) 48 49# ----------------------------------------------------------------- 50# build.prop 51INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop 52ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET) 53ADDITIONAL_BUILD_PROPERTIES := \ 54 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES)) 55 56# A list of arbitrary tags describing the build configuration. 57# Force ":=" so we can use += 58BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS) 59ifeq ($(TARGET_BUILD_TYPE),debug) 60 BUILD_VERSION_TAGS += debug 61endif 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. 64BUILD_VERSION_TAGS += test-keys 65BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS))) 66 67# A human-readable string that descibes this build in detail. 68build_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) 70 71# The string used to uniquely identify this build; used by the OTA server. 72ifeq (,$(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) 74endif 75ifneq ($(words $(BUILD_FINGERPRINT)),1) 76 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)") 77endif 78 79# Display parameters shown under Settings -> About Phone 80ifeq ($(TARGET_BUILD_VARIANT),user) 81 # User builds should show: 82 # release build number or branch.buld_number non-release builds 83 84 # Dev. branches should have DISPLAY_BUILD_NUMBER set 85 ifeq "true" "$(DISPLAY_BUILD_NUMBER)" 86 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER) 87 else 88 BUILD_DISPLAY_ID := $(BUILD_ID) 89 endif 90else 91 # Non-user builds should show detailed build information 92 BUILD_DISPLAY_ID := $(build_desc) 93endif 94 95# Selects the first locale in the list given as the argument, 96# and splits it into language and region, which each may be 97# empty. 98define default-locale 99$(subst _, , $(firstword $(1))) 100endef 101 102# Selects the first locale in the list given as the argument 103# and returns the language (or the region) 104define default-locale-language 105$(word 2, 2, $(call default-locale, $(1))) 106endef 107define default-locale-region 108$(word 3, 3, $(call default-locale, $(1))) 109endef 110 111BUILDINFO_SH := build/tools/buildinfo.sh 112$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) 113 @echo Target buildinfo: $@ 114 @mkdir -p $(dir $@) 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 >> $@; \ 137 fi 138 $(if $(ADDITIONAL_BUILD_PROPERTIES), \ 139 $(hide) echo >> $@; \ 140 echo "#" >> $@; \ 141 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \ 142 echo "#" >> $@; ) 143 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \ 144 echo "$(line)" >> $@;) 145 146build_desc := 147 148# ----------------------------------------------------------------- 149# sdk-build.prop 150# 151# There are certain things in build.prop that we don't want to 152# ship with the sdk; remove them. 153 154# This must be a list of entire property keys followed by 155# "=" characters, without any internal spaces. 156sdk_build_prop_remove := \ 157 ro.build.user= \ 158 ro.build.host= \ 159 ro.product.brand= \ 160 ro.product.manufacturer= \ 161 ro.product.device= 162# TODO: Remove this soon-to-be obsolete property 163sdk_build_prop_remove += ro.build.product= 164INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop 165$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET) 166 @echo SDK buildinfo: $@ 167 @mkdir -p $(dir $@) 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 172 $(hide) mv $@.tmp $@ 173 174# ----------------------------------------------------------------- 175# package stats 176PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt 177PACKAGES_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: $@ 182 @mkdir -p $(dir $@) 183 $(hide) rm -f $@ 184 $(hide) build/tools/dump-package-stats $^ > $@ 185 186.PHONY: package-stats 187package-stats: $(PACKAGE_STATS_FILE) 188 189# ----------------------------------------------------------------- 190# Cert-to-package mapping. Used by the post-build signing tools. 191name := $(TARGET_PRODUCT) 192ifeq ($(TARGET_BUILD_TYPE),debug) 193 name := $(name)_debug 194endif 195name := $(name)-apkcerts-$(FILE_NAME_TAG) 196intermediates := \ 197 $(call intermediates-dir-for,PACKAGING,apkcerts) 198APKCERTS_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. 202all_built_packages := $(foreach p,$(PACKAGES),$(ALL_MODULES.$(p).BUILT)) 203$(APKCERTS_FILE): $(all_built_packages) 204 @echo APK certs list: $@ 205 @mkdir -p $(dir $@) 206 @rm -f $@ 207 $(hide) $(foreach p,$(PACKAGES),\ 208 echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \ 209 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;) 210 211.PHONY: apkcerts-list 212apkcerts-list: $(APKCERTS_FILE) 213 214# ----------------------------------------------------------------- 215# module info file 216ifdef 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))) 226endif 227 228# Rules that need to be present for the simulator, even 229# if they don't do anything. 230.PHONY: systemimage 231systemimage: 232 233ifneq ($(TARGET_SIMULATOR),true) 234 235# ################################################################# 236# Targets for boot/OS images 237# ################################################################# 238 239# ----------------------------------------------------------------- 240# the ramdisk 241INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \ 242 $(ALL_PREBUILT) \ 243 $(ALL_COPIED_HEADERS) \ 244 $(ALL_GENERATED_SOURCES) \ 245 $(ALL_DEFAULT_INSTALLED_MODULES)) 246 247BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img 248 249# We just build this directly to the install location. 250INSTALLED_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 > $@ 254 255 256ifneq ($(strip $(TARGET_NO_KERNEL)),true) 257 258# ----------------------------------------------------------------- 259# the boot image, which is a collection of other images. 260INTERNAL_BOOTIMAGE_ARGS := \ 261 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 262 --kernel $(INSTALLED_KERNEL_TARGET) \ 263 --ramdisk $(INSTALLED_RAMDISK_TARGET) 264 265INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS)) 266 267BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE)) 268ifdef BOARD_KERNEL_CMDLINE 269 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 270endif 271 272BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE)) 273ifdef BOARD_KERNEL_BASE 274 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE) 275endif 276 277INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img 278 279ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true) 280tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg 281INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image) 282INTERNAL_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 $@ 286 287else # TARGET_BOOTIMAGE_USE_EXT2 != true 288 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)) 293endif # TARGET_BOOTIMAGE_USE_EXT2 294 295else # 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. 301INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET) 302endif 303 304# ----------------------------------------------------------------- 305# NOTICE files 306# 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. 310 311.PHONY: notice_files 312 313# Create the rule to combine the files into text and html forms 314# $(1) - Plain text output file 315# $(2) - HTML output file 316# $(3) - File title 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 320# 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 324# hashes. 325# 326# These rules are fairly complex, so they depend on this makefile so if 327# it changes, they'll run again. 328# 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. 332define 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; \ 343 done 344 $$(hide) touch $$@ 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:" >> $$@ 351 $$(hide) echo >> $$@ 352 $$(hide) echo >> $$@ 353 $$(hide) echo >> $$@ 354 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \ 355 echo "============================================================"\ 356 >> $$@; \ 357 echo "Notices for file(s):" >> $$@; \ 358 cat $$$$hashfile | sort | \ 359 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \ 360 $$@; \ 361 echo "------------------------------------------------------------"\ 362 >> $$@; \ 363 echo >> $$@; \ 364 orig=$$$$(head -n 1 $$$$hashfile); \ 365 cat $$$$orig >> $$@; \ 366 echo >> $$@; \ 367 echo >> $$@; \ 368 echo >> $$@; \ 369 done 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\">" \ 382 >> $$@ 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>:" >> \ 386 $$@; \ 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 -->" >> $$@; \ 393 echo >> $$@; \ 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 -->" >> $$@; \ 400 echo >> $$@; \ 401 echo >> $$@; \ 402 echo >> $$@; \ 403 done 404 $$(hide) echo "</table>" >> $$@ 405 $$(hide) echo "</body></html>" >> $$@ 406notice_files: $(1) $(2) 407endef 408 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. 412 413target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt 414target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html 415target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz 416tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt 417tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html 418 419kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt 420 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))) 427 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))) 434 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) 441 gzip -c $< > $@ 442installed_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) 445 446# if we've been run my mm, mmm, etc, don't reinstall this every time 447ifeq ($(ONE_SHOT_MAKEFILE),) 448ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz) 449endif 450 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 \ 456 | $(ACP) 457 @echo Copying: $@ 458 $(hide) mkdir -p $(dir $@) 459 $(hide) $(ACP) $< $@ 460 461 462# ################################################################# 463# Targets for user images 464# ################################################################# 465 466ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 467include external/genext2fs/Config.mk 468INTERNAL_MKUSERFS := $(MKEXT2IMG) 469else 470INTERNAL_MKUSERFS := $(MKYAFFS2) 471endif 472 473# ----------------------------------------------------------------- 474# system yaffs image 475# 476# First, the "unoptimized" image, which contains .apk/.jar files 477# that contain regular, unoptimized/unverified .dex entries. 478# 479systemimage_unopt_intermediates := \ 480 $(call intermediates-dir-for,PACKAGING,systemimage_unopt) 481BUILT_SYSTEMIMAGE_UNOPT := $(systemimage_unopt_intermediates)/system.img 482 483INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \ 484 $(ALL_PREBUILT) \ 485 $(ALL_COPIED_HEADERS) \ 486 $(ALL_GENERATED_SOURCES) \ 487 $(ALL_DEFAULT_INSTALLED_MODULES)) 488 489ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 490## generate an ext2 image 491# $(1): output file 492define build-systemimage-target 493 @echo "Target system fs image: $(1)" 494 $(call build-userimage-ext2-target,$(TARGET_OUT),$(1),system,) 495endef 496 497else # TARGET_USERIMAGES_USE_EXT2 != true 498 499## generate a yaffs2 image 500# $(1): output file 501define build-systemimage-target 502 @echo "Target system fs image: $(1)" 503 @mkdir -p $(dir $(1)) 504 $(hide) $(MKYAFFS2) -f $(TARGET_OUT) $(1) 505endef 506endif # TARGET_USERIMAGES_USE_EXT2 507 508$(BUILT_SYSTEMIMAGE_UNOPT): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_MKUSERFS) 509 $(call build-systemimage-target,$@) 510 511# The installed image, which may be optimized or unoptimized. 512# 513INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img 514 515ifdef WITH_DEXPREOPT 516 ifndef DISABLE_DEXPREOPT 517 with_dexpreopt := true 518 endif 519endif 520ifdef with_dexpreopt 521 # This file will set BUILT_SYSTEMIMAGE and SYSTEMIMAGE_SOURCE_DIR 522 include build/tools/dexpreopt/Config.mk 523else 524 BUILT_SYSTEMIMAGE := $(BUILT_SYSTEMIMAGE_UNOPT) 525 SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT) 526endif 527 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)) 532 533systemimage: $(INSTALLED_SYSTEMIMAGE) 534 535.PHONY: systemimage-nodeps snod 536systemimage-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)) 541 542####### 543## system tarball 544define 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) 549endef 550 551system_tar := $(PRODUCT_OUT)/system.tar 552INSTALLED_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) 556 557.PHONY: systemtarball-nodeps 558systemtarball-nodeps: $(FS_GET_STATS) \ 559 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS)) 560 $(build-systemtarball-target) 561 562.PHONY: stnod 563stnod: systemtarball-nodeps 564 565 566# ----------------------------------------------------------------- 567# data partition image 568INTERNAL_USERDATAIMAGE_FILES := \ 569 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) 570 571ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 572## Generate an ext2 image 573define 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)) 578endef 579 580else # TARGET_USERIMAGES_USE_EXT2 != true 581 582## Generate a yaffs2 image 583define 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)) 588endef 589endif # TARGET_USERIMAGES_USE_EXT2 590 591BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img 592 593# We just build this directly to the install location. 594INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET) 595$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_MKUSERFS) \ 596 $(INTERNAL_USERDATAIMAGE_FILES) 597 $(build-userdataimage-target) 598 599.PHONY: userdataimage-nodeps 600userdataimage-nodeps: $(INTERNAL_MKUSERFS) 601 $(build-userdataimage-target) 602 603####### 604## data partition tarball 605define 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) 611endef 612 613userdata_tar := $(PRODUCT_OUT)/userdata.tar 614INSTALLED_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) 618 619.PHONY: userdatatarball-nodeps 620userdatatarball-nodeps: $(FS_GET_STATS) 621 $(build-userdatatarball-target) 622 623 624# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true 625ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY))) 626 627# ----------------------------------------------------------------- 628# Recovery image 629INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img 630 631recovery_initrc := $(call include-path-for, recovery)/etc/init.rc 632recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system 633recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img 634recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET) 635recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery 636recovery_resources_common := $(call include-path-for, recovery)/res 637recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)) 638recovery_resource_deps := $(shell find $(recovery_resources_common) \ 639 $(recovery_resources_private) -type f) 640 641ifeq ($(recovery_resources_private),) 642 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE)) 643endif 644 645INTERNAL_RECOVERYIMAGE_ARGS := \ 646 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 647 --kernel $(recovery_kernel) \ 648 --ramdisk $(recovery_ramdisk) 649 650# Assumes this has already been stripped 651ifdef BOARD_KERNEL_CMDLINE 652 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 653endif 654ifdef BOARD_KERNEL_BASE 655 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE) 656endif 657 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. 661OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem 662 663# Generate a file containing the keys that will be read by the 664# recovery binary. 665RECOVERY_INSTALL_OTA_KEYS := \ 666 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys 667DUMPKEY_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)" 671 @rm -rf $@ 672 @mkdir -p $(dir $@) 673 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@ 674 675$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) \ 676 $(INSTALLED_RAMDISK_TARGET) \ 677 $(INSTALLED_BOOTIMAGE_TARGET) \ 678 $(recovery_binary) \ 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)) 704 705else 706INSTALLED_RECOVERYIMAGE_TARGET := 707endif 708 709.PHONY: recoveryimage 710recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) 711 712# ----------------------------------------------------------------- 713# bring in the installer image generation defines if necessary 714ifeq ($(TARGET_USE_DISKINSTALLER),true) 715include bootable/diskinstaller/config.mk 716endif 717 718# ----------------------------------------------------------------- 719# OTA update package 720name := $(TARGET_PRODUCT) 721ifeq ($(TARGET_BUILD_TYPE),debug) 722 name := $(name)_debug 723endif 724name := $(name)-ota-$(FILE_NAME_TAG) 725 726INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 727INTERNAL_OTA_INTERMEDIATES_DIR := $(call intermediates-dir-for,PACKAGING,ota) 728 729# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true 730ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY))) 731INTERNAL_OTA_RECOVERYIMAGE_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/system/recovery.img 732else 733INTERNAL_OTA_RECOVERYIMAGE_TARGET := 734endif 735INTERNAL_OTA_SCRIPT_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/META-INF/com/google/android/update-script 736 737# Sign OTA packages with the test key by default. 738# Actual product deliverables will be re-signed by hand. 739private_key := $(SRC_TARGET_DIR)/product/security/testkey.pk8 740certificate := $(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) 744 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: $@" 757 $(hide) rm -rf $@ 758 $(hide) jar cf $@ \ 759 $(foreach item, \ 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 & |' | \ 767 xargs jar uf $@ 768 $(hide) if jar tf $@ | egrep '.{65}' >&2; then \ 769 echo "Path too long (>64 chars) for OTA update" >&2; \ 770 exit 1; \ 771 fi 772 $(sign-package) 773 774$(INTERNAL_OTA_SCRIPT_TARGET): \ 775 $(HOST_OUT_EXECUTABLES)/make-update-script \ 776 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 777 $(INSTALLED_SYSTEMIMAGE) 778 @mkdir -p $(dir $@) 779 @rm -rf $@ 780 @echo "Update script: $@" 781 $(hide) TARGET_DEVICE=$(TARGET_DEVICE) \ 782 $< $(SYSTEMIMAGE_SOURCE_DIR) \ 783 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 784 > $@ 785 786ifneq (,$(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) 790 @mkdir -p $(dir $@) 791 $(hide) $(ACP) $< $@ 792endif 793 794.PHONY: otapackage 795otapackage: $(INTERNAL_OTA_PACKAGE_TARGET) 796 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. 800OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem 801 802# Build a keystore with the authorized keys in it. 803# java/android/android/server/checkin/UpdateVerifier.java uses this. 804ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip 805$(TARGET_OUT_ETC)/security/otacerts.zip: $(OTA_PUBLIC_KEYS) 806 $(hide) rm -f $@ 807 $(hide) mkdir -p $(dir $@) 808 zip -qj $@ $(OTA_PUBLIC_KEYS) 809 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; \ 815# done 816 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. 821# 822name := $(TARGET_PRODUCT) 823ifeq ($(TARGET_BUILD_TYPE),debug) 824 name := $(name)_debug 825endif 826name := $(name)-target_files-$(FILE_NAME_TAG) 827 828intermediates := $(call intermediates-dir-for,PACKAGING,target_files) 829BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip 830$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates) 831$(BUILT_TARGET_FILES_PACKAGE): \ 832 zip_root := $(intermediates)/$(name) 833 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. 837define package_files-copy-root 838 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \ 839 mkdir -p $(2) && \ 840 $(ACP) -rd $(strip $(1))/* $(2); \ 841 fi 842endef 843 844built_ota_tools := \ 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) 848 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) \ 860 $(built_ota_tools) \ 861 $(APKCERTS_FILE) \ 862 | $(ACP) 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) 870ifdef INSTALLED_KERNEL_TARGET 871 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel 872endif 873ifdef INSTALLED_2NDBOOTLOADER_TARGET 874 $(hide) $(ACP) \ 875 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second 876endif 877ifdef BOARD_KERNEL_CMDLINE 878 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline 879endif 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) 884ifdef INSTALLED_KERNEL_TARGET 885 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel 886endif 887ifdef INSTALLED_2NDBOOTLOADER_TARGET 888 $(hide) $(ACP) \ 889 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second 890endif 891ifdef BOARD_KERNEL_CMDLINE 892 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline 893endif 894ifdef INSTALLED_RADIOIMAGE_TARGET 895 @# The radio image 896 $(hide) mkdir -p $(zip_root)/RADIO 897 $(hide) $(ACP) $(INSTALLED_RADIOIMAGE_TARGET) $(zip_root)/RADIO/image 898endif 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 912 @# build them. 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 $@) .) 918 919target-files-package: $(BUILT_TARGET_FILES_PACKAGE) 920 921# ----------------------------------------------------------------- 922# installed file list 923# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it 924# gets the DexOpt one if we're doing that. 925INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt 926$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE) 927 @echo Installed file list: $@ 928 @mkdir -p $(dir $@) 929 @rm -f $@ 930 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@ 931 932.PHONY: installed-file-list 933installed-file-list: $(INSTALLED_FILES_FILE) 934$(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE)) 935$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE)) 936 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". 941# 942name := $(TARGET_PRODUCT) 943ifeq ($(TARGET_BUILD_TYPE),debug) 944 name := $(name)_debug 945endif 946name := $(name)-tests-$(FILE_NAME_TAG) 947 948intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip) 949BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip 950$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates) 951$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name) 952 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) \ 958 | $(ACP) 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 $@) .) 975 976tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE) 977 978# ----------------------------------------------------------------- 979# A zip of the symbols directory. Keep the full paths to make it 980# more obvious where these files came from. 981# 982name := $(TARGET_PRODUCT) 983ifeq ($(TARGET_BUILD_TYPE),debug) 984 name := $(name)_debug 985endif 986name := $(name)-symbols-$(FILE_NAME_TAG) 987 988SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip 989$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET) 990 @echo "Package symbols: $@" 991 $(hide) rm -rf $@ 992 $(hide) mkdir -p $(dir $@) 993 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED) 994 995# ----------------------------------------------------------------- 996# A zip of the Android Apps. Not keeping full path so that we don't 997# include product names when distributing 998# 999name := $(TARGET_PRODUCT) 1000ifeq ($(TARGET_BUILD_TYPE),debug) 1001 name := $(name)_debug 1002endif 1003name := $(name)-apps-$(FILE_NAME_TAG) 1004 1005APPS_ZIP := $(PRODUCT_OUT)/$(name).zip 1006$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE) 1007 @echo "Package apps: $@" 1008 $(hide) rm -rf $@ 1009 $(hide) mkdir -p $(dir $@) 1010 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/* 1011 1012endif # TARGET_SIMULATOR != true 1013 1014# ----------------------------------------------------------------- 1015# dalvik something 1016.PHONY: dalvikfiles 1017dalvikfiles: $(INTERNAL_DALVIK_MODULES) 1018 1019# ----------------------------------------------------------------- 1020# The update package 1021 1022INTERNAL_UPDATE_PACKAGE_FILES += \ 1023 $(INSTALLED_BOOTIMAGE_TARGET) \ 1024 $(INSTALLED_RECOVERYIMAGE_TARGET) \ 1025 $(INSTALLED_SYSTEMIMAGE) \ 1026 $(INSTALLED_USERDATAIMAGE_TARGET) \ 1027 $(INSTALLED_ANDROID_INFO_TXT_TARGET) 1028 1029ifneq ($(strip $(INTERNAL_UPDATE_PACKAGE_FILES)),) 1030 1031name := $(TARGET_PRODUCT) 1032ifeq ($(TARGET_BUILD_TYPE),debug) 1033 name := $(name)_debug 1034endif 1035name := $(name)-img-$(FILE_NAME_TAG) 1036 1037INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1038 1039$(INTERNAL_UPDATE_PACKAGE_TARGET): $(INTERNAL_UPDATE_PACKAGE_FILES) 1040 @echo "Package: $@" 1041 $(hide) zip -qj $@ $(INTERNAL_UPDATE_PACKAGE_FILES) 1042 1043else 1044INTERNAL_UPDATE_PACKAGE_TARGET := 1045endif 1046 1047# ----------------------------------------------------------------- 1048# The emulator package 1049 1050ifneq ($(TARGET_SIMULATOR),true) 1051 1052INTERNAL_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) 1058 1059name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG) 1060 1061INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1062 1063$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES) 1064 @echo "Package: $@" 1065 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES) 1066 1067endif 1068 1069# ----------------------------------------------------------------- 1070# The pdk package (Platform Development Kit) 1071 1072ifneq (,$(filter pdk,$(MAKECMDGOALS))) 1073 include development/pdk/Pdk.mk 1074endif 1075 1076# ----------------------------------------------------------------- 1077# The SDK 1078 1079ifneq ($(TARGET_SIMULATOR),true) 1080 1081# The SDK includes host-specific components, so it belongs under HOST_OUT. 1082sdk_dir := $(HOST_OUT)/sdk 1083 1084# Build a name that looks like: 1085# 1086# linux-x86 --> android-sdk_12345_linux-x86 1087# darwin-x86 --> android-sdk_12345_mac-x86 1088# windows-x86 --> android-sdk_12345_windows 1089# 1090sdk_name := android-sdk_$(FILE_NAME_TAG) 1091ifeq ($(HOST_OS),darwin) 1092 INTERNAL_SDK_HOST_OS_NAME := mac 1093else 1094 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS) 1095endif 1096ifneq ($(HOST_OS),windows) 1097 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH) 1098endif 1099sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME) 1100 1101sdk_dep_file := $(sdk_dir)/sdk_deps.mk 1102 1103ATREE_FILES := 1104-include $(sdk_dep_file) 1105 1106# if we don't have a real list, then use "everything" 1107ifeq ($(strip $(ATREE_FILES)),) 1108ATREE_FILES := \ 1109 $(ALL_PREBUILT) \ 1110 $(ALL_COPIED_HEADERS) \ 1111 $(ALL_GENERATED_SOURCES) \ 1112 $(ALL_DEFAULT_INSTALLED_MODULES) \ 1113 $(INSTALLED_RAMDISK_TARGET) \ 1114 $(ALL_DOCS) \ 1115 $(ALL_SDK_FILES) 1116endif 1117 1118atree_dir := development/build 1119 1120sdk_atree_files := \ 1121 $(atree_dir)/sdk.exclude.atree \ 1122 $(atree_dir)/sdk.atree \ 1123 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree 1124 1125deps := \ 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) \ 1131 $(ATREE_FILES) \ 1132 $(atree_dir)/sdk.atree \ 1133 $(HOST_OUT_EXECUTABLES)/atree \ 1134 $(HOST_OUT_EXECUTABLES)/line_endings 1135 1136INTERNAL_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) 1141 1142# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built. 1143# 1144#SDK_GNU_ERROR := true 1145 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); \ 1154 fi; \ 1155 done; \ 1156 if [ $$FAIL ]; then exit 1; fi 1157 $(hide) ( \ 1158 $(HOST_OUT_EXECUTABLES)/atree \ 1159 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \ 1160 -m $(PRIVATE_DEP_FILE) \ 1161 -I . \ 1162 -I $(PRODUCT_OUT) \ 1163 -I $(HOST_OUT) \ 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 ) 1175 1176endif # !simulator 1177 1178# ----------------------------------------------------------------- 1179# Findbugs 1180INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml 1181INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html 1182$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES) 1183 @echo UnionBugs: $@ 1184 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \ 1185 > $@ 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) > $@ 1190 1191# ----------------------------------------------------------------- 1192# Findbugs 1193 1194# ----------------------------------------------------------------- 1195# These are some additional build tasks that need to be run. 1196include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk)) 1197