Makefile revision 03fbe40d5346eb4d5258aa55a00a9a7cb18f8551
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 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 >> $@; \ 136 fi 137 $(if $(ADDITIONAL_BUILD_PROPERTIES), \ 138 $(hide) echo >> $@; \ 139 echo "#" >> $@; \ 140 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \ 141 echo "#" >> $@; ) 142 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \ 143 echo "$(line)" >> $@;) 144 145build_desc := 146 147# ----------------------------------------------------------------- 148# sdk-build.prop 149# 150# There are certain things in build.prop that we don't want to 151# ship with the sdk; remove them. 152 153# This must be a list of entire property keys followed by 154# "=" characters, without any internal spaces. 155sdk_build_prop_remove := \ 156 ro.build.user= \ 157 ro.build.host= \ 158 ro.product.brand= \ 159 ro.product.manufacturer= \ 160 ro.product.device= 161# TODO: Remove this soon-to-be obsolete property 162sdk_build_prop_remove += ro.build.product= 163INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop 164$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET) 165 @echo SDK buildinfo: $@ 166 @mkdir -p $(dir $@) 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 171 $(hide) mv $@.tmp $@ 172 173# ----------------------------------------------------------------- 174# package stats 175PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt 176PACKAGES_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: $@ 181 @mkdir -p $(dir $@) 182 $(hide) rm -f $@ 183 $(hide) build/tools/dump-package-stats $^ > $@ 184 185.PHONY: package-stats 186package-stats: $(PACKAGE_STATS_FILE) 187 188# ----------------------------------------------------------------- 189# Cert-to-package mapping. Used by the post-build signing tools. 190name := $(TARGET_PRODUCT) 191ifeq ($(TARGET_BUILD_TYPE),debug) 192 name := $(name)_debug 193endif 194name := $(name)-apkcerts-$(FILE_NAME_TAG) 195intermediates := \ 196 $(call intermediates-dir-for,PACKAGING,apkcerts) 197APKCERTS_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. 201all_built_packages := $(foreach p,$(PACKAGES),$(ALL_MODULES.$(p).BUILT)) 202$(APKCERTS_FILE): $(all_built_packages) 203 @echo APK certs list: $@ 204 @mkdir -p $(dir $@) 205 @rm -f $@ 206 $(hide) $(foreach p,$(PACKAGES),\ 207 echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \ 208 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;) 209 210.PHONY: apkcerts-list 211apkcerts-list: $(APKCERTS_FILE) 212 213# ----------------------------------------------------------------- 214# module info file 215ifdef 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))) 225endif 226 227# Rules that need to be present for the simulator, even 228# if they don't do anything. 229.PHONY: systemimage 230systemimage: 231 232ifneq ($(TARGET_SIMULATOR),true) 233 234# ################################################################# 235# Targets for boot/OS images 236# ################################################################# 237 238# ----------------------------------------------------------------- 239# the ramdisk 240INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \ 241 $(ALL_PREBUILT) \ 242 $(ALL_COPIED_HEADERS) \ 243 $(ALL_GENERATED_SOURCES) \ 244 $(ALL_DEFAULT_INSTALLED_MODULES)) 245 246BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img 247 248# We just build this directly to the install location. 249INSTALLED_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 > $@ 253 254 255ifneq ($(strip $(TARGET_NO_KERNEL)),true) 256 257# ----------------------------------------------------------------- 258# the boot image, which is a collection of other images. 259INTERNAL_BOOTIMAGE_ARGS := \ 260 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 261 --kernel $(INSTALLED_KERNEL_TARGET) \ 262 --ramdisk $(INSTALLED_RAMDISK_TARGET) 263 264INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS)) 265 266BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE)) 267ifdef BOARD_KERNEL_CMDLINE 268 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 269endif 270 271INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img 272 273ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true) 274tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg 275INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image) 276INTERNAL_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 $@ 280 281else # TARGET_BOOTIMAGE_USE_EXT2 != true 282 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)) 287endif # TARGET_BOOTIMAGE_USE_EXT2 288 289else # 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. 295INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET) 296endif 297 298# ----------------------------------------------------------------- 299# NOTICE files 300# 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. 304 305.PHONY: notice_files 306 307# Create the rule to combine the files into text and html forms 308# $(1) - Plain text output file 309# $(2) - HTML output file 310# $(3) - File title 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 314# 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 318# hashes. 319# 320# These rules are fairly complex, so they depend on this makefile so if 321# it changes, they'll run again. 322# 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. 326define 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; \ 337 done 338 $$(hide) touch $$@ 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:" >> $$@ 345 $$(hide) echo >> $$@ 346 $$(hide) echo >> $$@ 347 $$(hide) echo >> $$@ 348 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \ 349 echo "============================================================"\ 350 >> $$@; \ 351 echo "Notices for file(s):" >> $$@; \ 352 cat $$$$hashfile | sort | \ 353 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \ 354 $$@; \ 355 echo "------------------------------------------------------------"\ 356 >> $$@; \ 357 echo >> $$@; \ 358 orig=$$$$(head -n 1 $$$$hashfile); \ 359 cat $$$$orig >> $$@; \ 360 echo >> $$@; \ 361 echo >> $$@; \ 362 echo >> $$@; \ 363 done 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\">" \ 376 >> $$@ 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>:" >> \ 380 $$@; \ 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 -->" >> $$@; \ 387 echo >> $$@; \ 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 -->" >> $$@; \ 394 echo >> $$@; \ 395 echo >> $$@; \ 396 echo >> $$@; \ 397 done 398 $$(hide) echo "</table>" >> $$@ 399 $$(hide) echo "</body></html>" >> $$@ 400notice_files: $(1) $(2) 401endef 402 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. 406 407target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt 408target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html 409target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz 410tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt 411tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html 412 413kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt 414 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))) 421 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))) 428 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) 435 gzip -c $< > $@ 436installed_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) 439ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz) 440 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 \ 446 | $(ACP) 447 @echo Copying: $@ 448 $(hide) mkdir -p $(dir $@) 449 $(hide) $(ACP) $< $@ 450 451 452# ################################################################# 453# Targets for user images 454# ################################################################# 455 456ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 457include external/genext2fs/Config.mk 458INTERNAL_MKUSERFS := $(MKEXT2IMG) 459else 460INTERNAL_MKUSERFS := $(MKYAFFS2) 461endif 462 463# ----------------------------------------------------------------- 464# system yaffs image 465# 466# First, the "unoptimized" image, which contains .apk/.jar files 467# that contain regular, unoptimized/unverified .dex entries. 468# 469systemimage_unopt_intermediates := \ 470 $(call intermediates-dir-for,PACKAGING,systemimage_unopt) 471BUILT_SYSTEMIMAGE_UNOPT := $(systemimage_unopt_intermediates)/system.img 472 473INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \ 474 $(ALL_PREBUILT) \ 475 $(ALL_COPIED_HEADERS) \ 476 $(ALL_GENERATED_SOURCES) \ 477 $(ALL_DEFAULT_INSTALLED_MODULES)) 478 479ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 480## generate an ext2 image 481# $(1): output file 482define build-systemimage-target 483 @echo "Target system fs image: $(1)" 484 $(call build-userimage-ext2-target,$(TARGET_OUT),$(1),system,) 485endef 486 487else # TARGET_USERIMAGES_USE_EXT2 != true 488 489## generate a yaffs2 image 490# $(1): output file 491define build-systemimage-target 492 @echo "Target system fs image: $(1)" 493 @mkdir -p $(dir $(1)) 494 $(hide) $(MKYAFFS2) -f $(TARGET_OUT) $(1) 495endef 496endif # TARGET_USERIMAGES_USE_EXT2 497 498$(BUILT_SYSTEMIMAGE_UNOPT): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_MKUSERFS) 499 $(call build-systemimage-target,$@) 500 501# The installed image, which may be optimized or unoptimized. 502# 503INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img 504 505ifdef WITH_DEXPREOPT 506 ifndef DISABLE_DEXPREOPT 507 with_dexpreopt := true 508 endif 509endif 510ifdef with_dexpreopt 511 # This file will set BUILT_SYSTEMIMAGE and SYSTEMIMAGE_SOURCE_DIR 512 include build/tools/dexpreopt/Config.mk 513else 514 BUILT_SYSTEMIMAGE := $(BUILT_SYSTEMIMAGE_UNOPT) 515 SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT) 516endif 517 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)) 522 523systemimage: $(INSTALLED_SYSTEMIMAGE) 524 525.PHONY: systemimage-nodeps snod 526systemimage-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)) 531 532####### 533## system tarball 534define 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) 539endef 540 541system_tar := $(PRODUCT_OUT)/system.tar 542INSTALLED_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) 546 547.PHONY: systemtarball-nodeps 548systemtarball-nodeps: $(FS_GET_STATS) \ 549 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS)) 550 $(build-systemtarball-target) 551 552.PHONY: stnod 553stnod: systemtarball-nodeps 554 555 556# ----------------------------------------------------------------- 557# data partition image 558INTERNAL_USERDATAIMAGE_FILES := \ 559 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) 560 561ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 562## Generate an ext2 image 563define 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)) 568endef 569 570else # TARGET_USERIMAGES_USE_EXT2 != true 571 572## Generate a yaffs2 image 573define 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)) 578endef 579endif # TARGET_USERIMAGES_USE_EXT2 580 581BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img 582 583# We just build this directly to the install location. 584INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET) 585$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_MKUSERFS) \ 586 $(INTERNAL_USERDATAIMAGE_FILES) 587 $(build-userdataimage-target) 588 589.PHONY: userdataimage-nodeps 590userdataimage-nodeps: $(INTERNAL_MKUSERFS) 591 $(build-userdataimage-target) 592 593####### 594## data partition tarball 595define 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) 601endef 602 603userdata_tar := $(PRODUCT_OUT)/userdata.tar 604INSTALLED_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) 608 609.PHONY: userdatatarball-nodeps 610userdatatarball-nodeps: $(FS_GET_STATS) 611 $(build-userdatatarball-target) 612 613 614# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true 615ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY))) 616 617# ----------------------------------------------------------------- 618# Recovery image 619INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img 620 621recovery_initrc := $(call include-path-for, recovery)/etc/init.rc 622recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system 623recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img 624recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET) 625recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery 626recovery_resources_common := $(call include-path-for, recovery)/res 627recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)) 628recovery_resource_deps := $(shell find $(recovery_resources_common) \ 629 $(recovery_resources_private) -type f) 630 631ifeq ($(recovery_resources_private),) 632 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE)) 633endif 634 635INTERNAL_RECOVERYIMAGE_ARGS := \ 636 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 637 --kernel $(recovery_kernel) \ 638 --ramdisk $(recovery_ramdisk) 639 640# Assumes this has already been stripped 641ifdef BOARD_KERNEL_CMDLINE 642 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 643endif 644 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. 648OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem 649 650# Generate a file containing the keys that will be read by the 651# recovery binary. 652RECOVERY_INSTALL_OTA_KEYS := \ 653 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys 654DUMPKEY_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)" 658 @rm -rf $@ 659 @mkdir -p $(dir $@) 660 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@ 661 662$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) \ 663 $(INSTALLED_RAMDISK_TARGET) \ 664 $(INSTALLED_BOOTIMAGE_TARGET) \ 665 $(recovery_binary) \ 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)) 691 692else 693INSTALLED_RECOVERYIMAGE_TARGET := 694endif 695 696.PHONY: recoveryimage 697recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) 698 699# ----------------------------------------------------------------- 700# bring in the installer image generation defines if necessary 701ifeq ($(TARGET_USE_DISKINSTALLER),true) 702include bootable/diskinstaller/config.mk 703endif 704 705# ----------------------------------------------------------------- 706# OTA update package 707name := $(TARGET_PRODUCT) 708ifeq ($(TARGET_BUILD_TYPE),debug) 709 name := $(name)_debug 710endif 711name := $(name)-ota-$(FILE_NAME_TAG) 712 713INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 714INTERNAL_OTA_INTERMEDIATES_DIR := $(call intermediates-dir-for,PACKAGING,ota) 715 716# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true 717ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY))) 718INTERNAL_OTA_RECOVERYIMAGE_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/system/recovery.img 719else 720INTERNAL_OTA_RECOVERYIMAGE_TARGET := 721endif 722INTERNAL_OTA_SCRIPT_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/META-INF/com/google/android/update-script 723 724# Sign OTA packages with the test key by default. 725# Actual product deliverables will be re-signed by hand. 726private_key := $(SRC_TARGET_DIR)/product/security/testkey.pk8 727certificate := $(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) 731 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: $@" 744 $(hide) rm -rf $@ 745 $(hide) jar cf $@ \ 746 $(foreach item, \ 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 & |' | \ 754 xargs jar uf $@ 755 $(hide) if jar tf $@ | egrep '.{65}' >&2; then \ 756 echo "Path too long (>64 chars) for OTA update" >&2; \ 757 exit 1; \ 758 fi 759 $(sign-package) 760 761$(INTERNAL_OTA_SCRIPT_TARGET): \ 762 $(HOST_OUT_EXECUTABLES)/make-update-script \ 763 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 764 $(INSTALLED_SYSTEMIMAGE) 765 @mkdir -p $(dir $@) 766 @rm -rf $@ 767 @echo "Update script: $@" 768 $(hide) TARGET_DEVICE=$(TARGET_DEVICE) \ 769 $< $(SYSTEMIMAGE_SOURCE_DIR) \ 770 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 771 > $@ 772 773ifneq (,$(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) 777 @mkdir -p $(dir $@) 778 $(hide) $(ACP) $< $@ 779endif 780 781.PHONY: otapackage 782otapackage: $(INTERNAL_OTA_PACKAGE_TARGET) 783 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. 787OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem 788 789# Build a keystore with the authorized keys in it. 790# java/android/android/server/checkin/UpdateVerifier.java uses this. 791ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip 792$(TARGET_OUT_ETC)/security/otacerts.zip: $(OTA_PUBLIC_KEYS) 793 $(hide) rm -f $@ 794 $(hide) mkdir -p $(dir $@) 795 zip -qj $@ $(OTA_PUBLIC_KEYS) 796 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; \ 802# done 803 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. 808# 809name := $(TARGET_PRODUCT) 810ifeq ($(TARGET_BUILD_TYPE),debug) 811 name := $(name)_debug 812endif 813name := $(name)-target_files-$(FILE_NAME_TAG) 814 815intermediates := $(call intermediates-dir-for,PACKAGING,target_files) 816BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip 817$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates) 818$(BUILT_TARGET_FILES_PACKAGE): \ 819 zip_root := $(intermediates)/$(name) 820 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. 824define package_files-copy-root 825 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \ 826 mkdir -p $(2) && \ 827 $(ACP) -rd $(strip $(1))/* $(2); \ 828 fi 829endef 830 831built_ota_tools := \ 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) 835 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) \ 847 $(built_ota_tools) \ 848 $(APKCERTS_FILE) \ 849 | $(ACP) 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) 857ifdef INSTALLED_KERNEL_TARGET 858 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel 859endif 860ifdef INSTALLED_2NDBOOTLOADER_TARGET 861 $(hide) $(ACP) \ 862 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second 863endif 864ifdef BOARD_KERNEL_CMDLINE 865 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline 866endif 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) 871ifdef INSTALLED_KERNEL_TARGET 872 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel 873endif 874ifdef INSTALLED_2NDBOOTLOADER_TARGET 875 $(hide) $(ACP) \ 876 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second 877endif 878ifdef BOARD_KERNEL_CMDLINE 879 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline 880endif 881ifdef INSTALLED_RADIOIMAGE_TARGET 882 @# The radio image 883 $(hide) mkdir -p $(zip_root)/RADIO 884 $(hide) $(ACP) $(INSTALLED_RADIOIMAGE_TARGET) $(zip_root)/RADIO/image 885endif 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 899 @# build them. 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 $@) .) 905 906target-files-package: $(BUILT_TARGET_FILES_PACKAGE) 907 908# ----------------------------------------------------------------- 909# installed file list 910# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it 911# gets the DexOpt one if we're doing that. 912INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt 913$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE) 914 @echo Installed file list: $@ 915 @mkdir -p $(dir $@) 916 @rm -f $@ 917 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@ 918 919.PHONY: installed-file-list 920installed-file-list: $(INSTALLED_FILES_FILE) 921$(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE)) 922$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE)) 923 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". 928# 929name := $(TARGET_PRODUCT) 930ifeq ($(TARGET_BUILD_TYPE),debug) 931 name := $(name)_debug 932endif 933name := $(name)-tests-$(FILE_NAME_TAG) 934 935intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip) 936BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip 937$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates) 938$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name) 939 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) \ 945 | $(ACP) 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 $@) .) 962 963tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE) 964 965# ----------------------------------------------------------------- 966# A zip of the symbols directory. Keep the full paths to make it 967# more obvious where these files came from. 968# 969name := $(TARGET_PRODUCT) 970ifeq ($(TARGET_BUILD_TYPE),debug) 971 name := $(name)_debug 972endif 973name := $(name)-symbols-$(FILE_NAME_TAG) 974 975SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip 976$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET) 977 @echo "Package symbols: $@" 978 $(hide) rm -rf $@ 979 $(hide) mkdir -p $(dir $@) 980 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED) 981 982# ----------------------------------------------------------------- 983# A zip of the Android Apps. Not keeping full path so that we don't 984# include product names when distributing 985# 986name := $(TARGET_PRODUCT) 987ifeq ($(TARGET_BUILD_TYPE),debug) 988 name := $(name)_debug 989endif 990name := $(name)-apps-$(FILE_NAME_TAG) 991 992APPS_ZIP := $(PRODUCT_OUT)/$(name).zip 993$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE) 994 @echo "Package apps: $@" 995 $(hide) rm -rf $@ 996 $(hide) mkdir -p $(dir $@) 997 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/* 998 999endif # TARGET_SIMULATOR != true 1000 1001# ----------------------------------------------------------------- 1002# dalvik something 1003.PHONY: dalvikfiles 1004dalvikfiles: $(INTERNAL_DALVIK_MODULES) 1005 1006# ----------------------------------------------------------------- 1007# The update package 1008 1009INTERNAL_UPDATE_PACKAGE_FILES += \ 1010 $(INSTALLED_BOOTIMAGE_TARGET) \ 1011 $(INSTALLED_RECOVERYIMAGE_TARGET) \ 1012 $(INSTALLED_SYSTEMIMAGE) \ 1013 $(INSTALLED_USERDATAIMAGE_TARGET) \ 1014 $(INSTALLED_ANDROID_INFO_TXT_TARGET) 1015 1016ifneq ($(strip $(INTERNAL_UPDATE_PACKAGE_FILES)),) 1017 1018name := $(TARGET_PRODUCT) 1019ifeq ($(TARGET_BUILD_TYPE),debug) 1020 name := $(name)_debug 1021endif 1022name := $(name)-img-$(FILE_NAME_TAG) 1023 1024INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1025 1026$(INTERNAL_UPDATE_PACKAGE_TARGET): $(INTERNAL_UPDATE_PACKAGE_FILES) 1027 @echo "Package: $@" 1028 $(hide) zip -qj $@ $(INTERNAL_UPDATE_PACKAGE_FILES) 1029 1030else 1031INTERNAL_UPDATE_PACKAGE_TARGET := 1032endif 1033 1034# ----------------------------------------------------------------- 1035# The emulator package 1036 1037ifneq ($(TARGET_SIMULATOR),true) 1038 1039INTERNAL_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) 1045 1046name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG) 1047 1048INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1049 1050$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES) 1051 @echo "Package: $@" 1052 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES) 1053 1054endif 1055 1056# ----------------------------------------------------------------- 1057# The pdk package (Platform Development Kit) 1058 1059ifneq (,$(filter pdk,$(MAKECMDGOALS))) 1060 include development/pdk/Pdk.mk 1061endif 1062 1063# ----------------------------------------------------------------- 1064# The SDK 1065 1066ifneq ($(TARGET_SIMULATOR),true) 1067 1068# The SDK includes host-specific components, so it belongs under HOST_OUT. 1069sdk_dir := $(HOST_OUT)/sdk 1070 1071# Build a name that looks like: 1072# 1073# linux-x86 --> android-sdk_12345_linux-x86 1074# darwin-x86 --> android-sdk_12345_mac-x86 1075# windows-x86 --> android-sdk_12345_windows 1076# 1077sdk_name := android-sdk_$(FILE_NAME_TAG) 1078ifeq ($(HOST_OS),darwin) 1079 INTERNAL_SDK_HOST_OS_NAME := mac 1080else 1081 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS) 1082endif 1083ifneq ($(HOST_OS),windows) 1084 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH) 1085endif 1086sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME) 1087 1088sdk_dep_file := $(sdk_dir)/sdk_deps.mk 1089 1090ATREE_FILES := 1091-include $(sdk_dep_file) 1092 1093# if we don't have a real list, then use "everything" 1094ifeq ($(strip $(ATREE_FILES)),) 1095ATREE_FILES := \ 1096 $(ALL_PREBUILT) \ 1097 $(ALL_COPIED_HEADERS) \ 1098 $(ALL_GENERATED_SOURCES) \ 1099 $(ALL_DEFAULT_INSTALLED_MODULES) \ 1100 $(INSTALLED_RAMDISK_TARGET) \ 1101 $(ALL_DOCS) \ 1102 $(ALL_SDK_FILES) 1103endif 1104 1105atree_dir := development/build 1106 1107sdk_atree_files := \ 1108 $(atree_dir)/sdk.exclude.atree \ 1109 $(atree_dir)/sdk.atree \ 1110 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree 1111 1112deps := \ 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) \ 1118 $(ATREE_FILES) \ 1119 $(atree_dir)/sdk.atree \ 1120 $(HOST_OUT_EXECUTABLES)/atree \ 1121 $(HOST_OUT_EXECUTABLES)/line_endings 1122 1123INTERNAL_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) 1128 1129# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built. 1130# 1131#SDK_GNU_ERROR := true 1132 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); \ 1141 fi; \ 1142 done; \ 1143 if [ $$FAIL ]; then exit 1; fi 1144 $(hide) ( \ 1145 $(HOST_OUT_EXECUTABLES)/atree \ 1146 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \ 1147 -m $(PRIVATE_DEP_FILE) \ 1148 -I . \ 1149 -I $(PRODUCT_OUT) \ 1150 -I $(HOST_OUT) \ 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 ) 1162 1163endif # !simulator 1164 1165# ----------------------------------------------------------------- 1166# Findbugs 1167INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml 1168INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html 1169$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES) 1170 @echo UnionBugs: $@ 1171 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \ 1172 > $@ 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) > $@ 1177 1178# ----------------------------------------------------------------- 1179# Findbugs 1180 1181# ----------------------------------------------------------------- 1182# These are some additional build tasks that need to be run. 1183include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk)) 1184