Makefile revision 6ea3b8856d656752c0310ca237ed99e7451be83b
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 271BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE)) 272ifdef BOARD_KERNEL_BASE 273 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE) 274endif 275 276INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img 277 278ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true) 279tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg 280INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image) 281INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG) 282$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES) 283 $(call pretty,"Target boot image: $@") 284 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@ 285 286else # TARGET_BOOTIMAGE_USE_EXT2 != true 287 288$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) 289 $(call pretty,"Target boot image: $@") 290 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@ 291 $(hide) $(call assert-max-file-size,$@,$(BOARD_BOOTIMAGE_MAX_SIZE)) 292endif # TARGET_BOOTIMAGE_USE_EXT2 293 294else # TARGET_NO_KERNEL 295# HACK: The top-level targets depend on the bootimage. Not all targets 296# can produce a bootimage, though, and emulator targets need the ramdisk 297# instead. Fake it out by calling the ramdisk the bootimage. 298# TODO: make the emulator use bootimages, and make mkbootimg accept 299# kernel-less inputs. 300INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET) 301endif 302 303# ----------------------------------------------------------------- 304# NOTICE files 305# 306# This needs to be before the systemimage rules, because it adds to 307# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files 308# go into the systemimage. 309 310.PHONY: notice_files 311 312# Create the rule to combine the files into text and html forms 313# $(1) - Plain text output file 314# $(2) - HTML output file 315# $(3) - File title 316# $(4) - Directory to use. Notice files are all $(4)/src. Other 317# directories in there will be used for scratch 318# $(5) - Dependencies for the output files 319# 320# The algorithm here is that we go collect a hash for each of the notice 321# files and write the names of the files that match that hash. Then 322# to generate the real files, we go print out all of the files and their 323# hashes. 324# 325# These rules are fairly complex, so they depend on this makefile so if 326# it changes, they'll run again. 327# 328# TODO: We could clean this up so that we just record the locations of the 329# original notice files instead of making rules to copy them somwehere. 330# Then we could traverse that without quite as much bash drama. 331define combine-notice-files 332$(1) $(2): PRIVATE_MESSAGE := $(3) 333$(1) $(2) $(4)/hash-timestamp: PRIVATE_DIR := $(4) 334$(4)/hash-timestamp: $(5) $(BUILD_SYSTEM)/Makefile 335 @echo Finding NOTICE files: $$@ 336 $$(hide) rm -rf $$@ $$(PRIVATE_DIR)/hash 337 $$(hide) mkdir -p $$(PRIVATE_DIR)/hash 338 $$(hide) for file in $$$$(find $$(PRIVATE_DIR)/src -type f); do \ 339 hash=$$$$($(MD5SUM) $$$$file | sed -e "s/ .*//"); \ 340 hashfile=$$(PRIVATE_DIR)/hash/$$$$hash; \ 341 echo $$$$file >> $$$$hashfile; \ 342 done 343 $$(hide) touch $$@ 344$(1): $(4)/hash-timestamp 345 @echo Combining NOTICE files: $$@ 346 $$(hide) mkdir -p $$(dir $$@) 347 $$(hide) echo $$(PRIVATE_MESSAGE) > $$@ 348 $$(hide) find $$(PRIVATE_DIR)/hash -type f | xargs cat | sort | \ 349 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> $$@ 350 $$(hide) echo >> $$@ 351 $$(hide) echo >> $$@ 352 $$(hide) echo >> $$@ 353 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \ 354 echo "============================================================"\ 355 >> $$@; \ 356 echo "Notices for file(s):" >> $$@; \ 357 cat $$$$hashfile | sort | \ 358 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \ 359 $$@; \ 360 echo "------------------------------------------------------------"\ 361 >> $$@; \ 362 echo >> $$@; \ 363 orig=$$$$(head -n 1 $$$$hashfile); \ 364 cat $$$$orig >> $$@; \ 365 echo >> $$@; \ 366 echo >> $$@; \ 367 echo >> $$@; \ 368 done 369$(2): $(4)/hash-timestamp 370 @echo Combining NOTICE files: $$@ 371 $$(hide) mkdir -p $$(dir $$@) 372 $$(hide) echo "<html><head>" > $$@ 373 $$(hide) echo "<style type=\"text/css\">" >> $$@ 374 $$(hide) echo "body { padding: 0; font-family: sans-serif; }" >> $$@ 375 $$(hide) echo ".same-license { background-color: #eeeeee; border-top: 20px solid white; padding: 10px; }" >> $$@ 376 $$(hide) echo ".label { font-weight: bold; }" >> $$@ 377 $$(hide) echo ".file-list { margin-left: 1em; font-color: blue; }" >> $$@ 378 $$(hide) echo "</style>" >> $$@ 379 $$(hide) echo "</head><body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">" >> $$@ 380 $$(hide) echo "<table cellpading=\"0\" cellspacing=\"0\" border=\"0\">" \ 381 >> $$@ 382 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \ 383 cat $$$$hashfile | sort | \ 384 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: <a name=\"\1\"></a>:" >> \ 385 $$@; \ 386 echo "<tr><td class=\"same-license\">" >> $$@; \ 387 echo "<div class=\"label\">Notices for file(s):</div>" >> $$@; \ 388 echo "<div class=\"file-list\">" >> $$@; \ 389 cat $$$$hashfile | sort | \ 390 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1<br/>:" >> $$@; \ 391 echo "</div><!-- file-list -->" >> $$@; \ 392 echo >> $$@; \ 393 orig=$$$$(head -n 1 $$$$hashfile); \ 394 echo "<pre class=\"license-text\">" >> $$@; \ 395 cat $$$$orig | sed -e "s/\&/\&/g" | sed -e "s/</\</g" \ 396 | sed -e "s/>/\>/g" >> $$@; \ 397 echo "</pre><!-- license-text -->" >> $$@; \ 398 echo "</td></tr><!-- same-license -->" >> $$@; \ 399 echo >> $$@; \ 400 echo >> $$@; \ 401 echo >> $$@; \ 402 done 403 $$(hide) echo "</table>" >> $$@ 404 $$(hide) echo "</body></html>" >> $$@ 405notice_files: $(1) $(2) 406endef 407 408# TODO These intermediate NOTICE.txt/NOTICE.html files should go into 409# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from 410# the src subdirectory. 411 412target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt 413target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html 414target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz 415tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt 416tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html 417 418kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt 419 420$(eval $(call combine-notice-files, \ 421 $(target_notice_file_txt), \ 422 $(target_notice_file_html), \ 423 "Notices for files contained in the filesystem images in this directory:", \ 424 $(TARGET_OUT_NOTICE_FILES), \ 425 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file))) 426 427$(eval $(call combine-notice-files, \ 428 $(tools_notice_file_txt), \ 429 $(tools_notice_file_html), \ 430 "Notices for files contained in the tools directory:", \ 431 $(HOST_OUT_NOTICE_FILES), \ 432 $(ALL_DEFAULT_INSTALLED_MODULES))) 433 434# Install the html file at /system/etc/NOTICE.html.gz. 435# This is not ideal, but this is very late in the game, after a lot of 436# the module processing has already been done -- in fact, we used the 437# fact that all that has been done to get the list of modules that we 438# need notice files for. 439$(target_notice_file_html_gz): $(target_notice_file_html) 440 gzip -c $< > $@ 441installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz 442$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP) 443 $(copy-file-to-target) 444 445# if we've been run my mm, mmm, etc, don't reinstall this every time 446ifeq ($(ONE_SHOT_MAKEFILE),) 447ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz) 448endif 449 450# The kernel isn't really a module, so to get its module file in there, we 451# make the target NOTICE files depend on this particular file too, which will 452# then be in the right directory for the find in combine-notice-files to work. 453$(kernel_notice_file): \ 454 prebuilt/$(TARGET_PREBUILT_TAG)/kernel/LINUX_KERNEL_COPYING \ 455 | $(ACP) 456 @echo Copying: $@ 457 $(hide) mkdir -p $(dir $@) 458 $(hide) $(ACP) $< $@ 459 460 461# ################################################################# 462# Targets for user images 463# ################################################################# 464 465ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 466include external/genext2fs/Config.mk 467INTERNAL_MKUSERFS := $(MKEXT2IMG) 468else 469INTERNAL_MKUSERFS := $(MKYAFFS2) 470endif 471 472# ----------------------------------------------------------------- 473# system yaffs image 474# 475# First, the "unoptimized" image, which contains .apk/.jar files 476# that contain regular, unoptimized/unverified .dex entries. 477# 478systemimage_unopt_intermediates := \ 479 $(call intermediates-dir-for,PACKAGING,systemimage_unopt) 480BUILT_SYSTEMIMAGE_UNOPT := $(systemimage_unopt_intermediates)/system.img 481 482INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \ 483 $(ALL_PREBUILT) \ 484 $(ALL_COPIED_HEADERS) \ 485 $(ALL_GENERATED_SOURCES) \ 486 $(ALL_DEFAULT_INSTALLED_MODULES)) 487 488ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 489## generate an ext2 image 490# $(1): output file 491define build-systemimage-target 492 @echo "Target system fs image: $(1)" 493 $(call build-userimage-ext2-target,$(TARGET_OUT),$(1),system,) 494endef 495 496else # TARGET_USERIMAGES_USE_EXT2 != true 497 498## generate a yaffs2 image 499# $(1): output file 500define build-systemimage-target 501 @echo "Target system fs image: $(1)" 502 @mkdir -p $(dir $(1)) 503 $(hide) $(MKYAFFS2) -f $(TARGET_OUT) $(1) 504endef 505endif # TARGET_USERIMAGES_USE_EXT2 506 507$(BUILT_SYSTEMIMAGE_UNOPT): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_MKUSERFS) 508 $(call build-systemimage-target,$@) 509 510# The installed image, which may be optimized or unoptimized. 511# 512INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img 513 514ifdef WITH_DEXPREOPT 515 ifndef DISABLE_DEXPREOPT 516 with_dexpreopt := true 517 endif 518endif 519ifdef with_dexpreopt 520 # This file will set BUILT_SYSTEMIMAGE and SYSTEMIMAGE_SOURCE_DIR 521 include build/tools/dexpreopt/Config.mk 522else 523 BUILT_SYSTEMIMAGE := $(BUILT_SYSTEMIMAGE_UNOPT) 524 SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT) 525endif 526 527$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) | $(ACP) 528 @echo "Install system fs image: $@" 529 $(copy-file-to-target) 530 $(hide) $(call assert-max-file-size,$@,$(BOARD_SYSTEMIMAGE_MAX_SIZE)) 531 532systemimage: $(INSTALLED_SYSTEMIMAGE) 533 534.PHONY: systemimage-nodeps snod 535systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \ 536 | $(INTERNAL_MKUSERFS) 537 @echo "make $@: ignoring dependencies" 538 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE)) 539 $(hide) $(call assert-max-file-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_MAX_SIZE)) 540 541####### 542## system tarball 543define build-systemtarball-target 544 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)") 545 $(MKTARBALL) $(FS_GET_STATS) \ 546 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \ 547 $(INSTALLED_SYSTEMTARBALL_TARGET) 548endef 549 550system_tar := $(PRODUCT_OUT)/system.tar 551INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).bz2 552$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar) 553$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES) 554 $(build-systemtarball-target) 555 556.PHONY: systemtarball-nodeps 557systemtarball-nodeps: $(FS_GET_STATS) \ 558 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS)) 559 $(build-systemtarball-target) 560 561.PHONY: stnod 562stnod: systemtarball-nodeps 563 564 565# ----------------------------------------------------------------- 566# data partition image 567INTERNAL_USERDATAIMAGE_FILES := \ 568 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) 569 570ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 571## Generate an ext2 image 572define build-userdataimage-target 573 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)") 574 @mkdir -p $(TARGET_OUT_DATA) 575 $(call build-userimage-ext2-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),userdata,) 576 $(hide) $(call assert-max-file-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_MAX_SIZE)) 577endef 578 579else # TARGET_USERIMAGES_USE_EXT2 != true 580 581## Generate a yaffs2 image 582define build-userdataimage-target 583 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)") 584 @mkdir -p $(TARGET_OUT_DATA) 585 $(hide) $(MKYAFFS2) -f $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET) 586 $(hide) $(call assert-max-file-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_MAX_SIZE)) 587endef 588endif # TARGET_USERIMAGES_USE_EXT2 589 590BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img 591 592# We just build this directly to the install location. 593INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET) 594$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_MKUSERFS) \ 595 $(INTERNAL_USERDATAIMAGE_FILES) 596 $(build-userdataimage-target) 597 598.PHONY: userdataimage-nodeps 599userdataimage-nodeps: $(INTERNAL_MKUSERFS) 600 $(build-userdataimage-target) 601 602####### 603## data partition tarball 604define build-userdatatarball-target 605 $(call pretty,"Target userdata fs tarball: " \ 606 "$(INSTALLED_USERDATATARBALL_TARGET)") 607 $(MKTARBALL) $(FS_GET_STATS) \ 608 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \ 609 $(INSTALLED_USERDATATARBALL_TARGET) 610endef 611 612userdata_tar := $(PRODUCT_OUT)/userdata.tar 613INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2 614$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar) 615$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES) 616 $(build-userdatatarball-target) 617 618.PHONY: userdatatarball-nodeps 619userdatatarball-nodeps: $(FS_GET_STATS) 620 $(build-userdatatarball-target) 621 622 623# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true 624ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY))) 625 626# ----------------------------------------------------------------- 627# Recovery image 628INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img 629 630recovery_initrc := $(call include-path-for, recovery)/etc/init.rc 631recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system 632recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img 633recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET) 634recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery 635recovery_resources_common := $(call include-path-for, recovery)/res 636recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)) 637recovery_resource_deps := $(shell find $(recovery_resources_common) \ 638 $(recovery_resources_private) -type f) 639 640ifeq ($(recovery_resources_private),) 641 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE)) 642endif 643 644INTERNAL_RECOVERYIMAGE_ARGS := \ 645 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 646 --kernel $(recovery_kernel) \ 647 --ramdisk $(recovery_ramdisk) 648 649# Assumes this has already been stripped 650ifdef BOARD_KERNEL_CMDLINE 651 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 652endif 653ifdef BOARD_KERNEL_BASE 654 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE) 655endif 656 657# Keys authorized to sign OTA packages this build will accept. The 658# build always uses test-keys for this; release packaging tools will 659# substitute other keys for this one. 660OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem 661 662# Generate a file containing the keys that will be read by the 663# recovery binary. 664RECOVERY_INSTALL_OTA_KEYS := \ 665 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys 666DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar 667$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS) 668$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) 669 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS)" 670 @rm -rf $@ 671 @mkdir -p $(dir $@) 672 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@ 673 674$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) \ 675 $(INSTALLED_RAMDISK_TARGET) \ 676 $(INSTALLED_BOOTIMAGE_TARGET) \ 677 $(recovery_binary) \ 678 $(recovery_initrc) $(recovery_kernel) \ 679 $(INSTALLED_2NDBOOTLOADER_TARGET) \ 680 $(recovery_build_prop) $(recovery_resource_deps) \ 681 $(RECOVERY_INSTALL_OTA_KEYS) 682 @echo ----- Making recovery image ------ 683 rm -rf $(TARGET_RECOVERY_OUT) 684 mkdir -p $(TARGET_RECOVERY_OUT) 685 mkdir -p $(TARGET_RECOVERY_ROOT_OUT) 686 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc 687 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp 688 echo Copying baseline ramdisk... 689 cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT) 690 echo Modifying ramdisk contents... 691 cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/ 692 cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/ 693 cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/ 694 $(foreach item,$(recovery_resources_private), \ 695 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/) 696 cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys 697 cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \ 698 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop 699 $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | gzip > $(recovery_ramdisk) 700 $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@ 701 @echo ----- Made recovery image -------- $@ 702 $(hide) $(call assert-max-file-size,$@,$(BOARD_RECOVERYIMAGE_MAX_SIZE)) 703 704else 705INSTALLED_RECOVERYIMAGE_TARGET := 706endif 707 708.PHONY: recoveryimage 709recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) 710 711# ----------------------------------------------------------------- 712# bring in the installer image generation defines if necessary 713ifeq ($(TARGET_USE_DISKINSTALLER),true) 714include bootable/diskinstaller/config.mk 715endif 716 717# ----------------------------------------------------------------- 718# OTA update package 719name := $(TARGET_PRODUCT) 720ifeq ($(TARGET_BUILD_TYPE),debug) 721 name := $(name)_debug 722endif 723name := $(name)-ota-$(FILE_NAME_TAG) 724 725INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 726INTERNAL_OTA_INTERMEDIATES_DIR := $(call intermediates-dir-for,PACKAGING,ota) 727 728# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true 729ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY))) 730INTERNAL_OTA_RECOVERYIMAGE_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/system/recovery.img 731else 732INTERNAL_OTA_RECOVERYIMAGE_TARGET := 733endif 734INTERNAL_OTA_SCRIPT_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/META-INF/com/google/android/update-script 735 736# Sign OTA packages with the test key by default. 737# Actual product deliverables will be re-signed by hand. 738private_key := $(SRC_TARGET_DIR)/product/security/testkey.pk8 739certificate := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem 740$(INTERNAL_OTA_PACKAGE_TARGET): $(private_key) $(certificate) $(SIGNAPK_JAR) 741$(INTERNAL_OTA_PACKAGE_TARGET): PRIVATE_PRIVATE_KEY := $(private_key) 742$(INTERNAL_OTA_PACKAGE_TARGET): PRIVATE_CERTIFICATE := $(certificate) 743 744# Depending on INSTALLED_SYSTEMIMAGE guarantees that SYSTEMIMAGE_SOURCE_DIR 745# is up-to-date. We use jar instead of zip so that we can use the -C 746# switch to avoid cd-ing all over the place. 747# TODO: Make our own jar-creation tool to avoid all these shenanigans. 748$(INTERNAL_OTA_PACKAGE_TARGET): \ 749 $(INTERNAL_OTA_SCRIPT_TARGET) \ 750 $(INTERNAL_OTA_RECOVERYIMAGE_TARGET) \ 751 $(INSTALLED_BOOTIMAGE_TARGET) \ 752 $(INSTALLED_RADIOIMAGE_TARGET) \ 753 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 754 $(INSTALLED_SYSTEMIMAGE) 755 @echo "Package OTA: $@" 756 $(hide) rm -rf $@ 757 $(hide) jar cf $@ \ 758 $(foreach item, \ 759 $(INSTALLED_BOOTIMAGE_TARGET) \ 760 $(INSTALLED_RADIOIMAGE_TARGET) \ 761 $(INSTALLED_ANDROID_INFO_TXT_TARGET), \ 762 -C $(dir $(item)) $(notdir $(item))) \ 763 -C $(INTERNAL_OTA_INTERMEDIATES_DIR) . 764 $(hide) find $(SYSTEMIMAGE_SOURCE_DIR) -type f -print | \ 765 sed 's|^$(dir $(SYSTEMIMAGE_SOURCE_DIR))|-C & |' | \ 766 xargs jar uf $@ 767 $(hide) if jar tf $@ | egrep '.{65}' >&2; then \ 768 echo "Path too long (>64 chars) for OTA update" >&2; \ 769 exit 1; \ 770 fi 771 $(sign-package) 772 773$(INTERNAL_OTA_SCRIPT_TARGET): \ 774 $(HOST_OUT_EXECUTABLES)/make-update-script \ 775 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 776 $(INSTALLED_SYSTEMIMAGE) 777 @mkdir -p $(dir $@) 778 @rm -rf $@ 779 @echo "Update script: $@" 780 $(hide) TARGET_DEVICE=$(TARGET_DEVICE) \ 781 $< $(SYSTEMIMAGE_SOURCE_DIR) \ 782 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 783 > $@ 784 785ifneq (,$(INTERNAL_OTA_RECOVERYIMAGE_TARGET)) 786# This copy is so recovery.img can be in /system within the OTA package. 787# That way it gets installed into the system image, which in turn installs it. 788$(INTERNAL_OTA_RECOVERYIMAGE_TARGET): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ACP) 789 @mkdir -p $(dir $@) 790 $(hide) $(ACP) $< $@ 791endif 792 793.PHONY: otapackage 794otapackage: $(INTERNAL_OTA_PACKAGE_TARGET) 795 796# Keys authorized to sign OTA packages this build will accept. The 797# build always uses test-keys for this; release packaging tools will 798# substitute other keys for this one. 799OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem 800 801# Build a keystore with the authorized keys in it. 802# java/android/android/server/checkin/UpdateVerifier.java uses this. 803ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip 804$(TARGET_OUT_ETC)/security/otacerts.zip: $(OTA_PUBLIC_KEYS) 805 $(hide) rm -f $@ 806 $(hide) mkdir -p $(dir $@) 807 zip -qj $@ $(OTA_PUBLIC_KEYS) 808 809# The device does not support JKS. 810# $(hide) for f in $(OTA_PUBLIC_KEYS); do \ 811# echo "keytool: $@ <= $$f" && \ 812# keytool -keystore $@ -storepass $(notdir $@) -noprompt \ 813# -import -file $$f -alias $(notdir $$f) || exit 1; \ 814# done 815 816# ----------------------------------------------------------------- 817# A zip of the directories that map to the target filesystem. 818# This zip can be used to create an OTA package or filesystem image 819# as a post-build step. 820# 821name := $(TARGET_PRODUCT) 822ifeq ($(TARGET_BUILD_TYPE),debug) 823 name := $(name)_debug 824endif 825name := $(name)-target_files-$(FILE_NAME_TAG) 826 827intermediates := $(call intermediates-dir-for,PACKAGING,target_files) 828BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip 829$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates) 830$(BUILT_TARGET_FILES_PACKAGE): \ 831 zip_root := $(intermediates)/$(name) 832 833# $(1): Directory to copy 834# $(2): Location to copy it to 835# The "ls -A" is to prevent "acp s/* d" from failing if s is empty. 836define package_files-copy-root 837 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \ 838 mkdir -p $(2) && \ 839 $(ACP) -rd $(strip $(1))/* $(2); \ 840 fi 841endef 842 843built_ota_tools := \ 844 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \ 845 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq 846$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools) 847 848# Depending on the various images guarantees that the underlying 849# directories are up-to-date. 850$(BUILT_TARGET_FILES_PACKAGE): \ 851 $(INTERNAL_OTA_SCRIPT_TARGET) \ 852 $(INSTALLED_BOOTIMAGE_TARGET) \ 853 $(INSTALLED_RADIOIMAGE_TARGET) \ 854 $(INSTALLED_RECOVERYIMAGE_TARGET) \ 855 $(BUILT_SYSTEMIMAGE) \ 856 $(INSTALLED_USERDATAIMAGE_TARGET) \ 857 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 858 $(INTERNAL_OTA_SCRIPT_TARGET) \ 859 $(built_ota_tools) \ 860 $(APKCERTS_FILE) \ 861 | $(ACP) 862 @echo "Package target files: $@" 863 $(hide) rm -rf $@ $(zip_root) 864 $(hide) mkdir -p $(dir $@) $(zip_root) 865 @# Components of the recovery image 866 $(hide) mkdir -p $(zip_root)/RECOVERY 867 $(hide) $(call package_files-copy-root, \ 868 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK) 869ifdef INSTALLED_KERNEL_TARGET 870 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel 871endif 872ifdef INSTALLED_2NDBOOTLOADER_TARGET 873 $(hide) $(ACP) \ 874 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second 875endif 876ifdef BOARD_KERNEL_CMDLINE 877 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline 878endif 879 @# Components of the boot image 880 $(hide) mkdir -p $(zip_root)/BOOT 881 $(hide) $(call package_files-copy-root, \ 882 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK) 883ifdef INSTALLED_KERNEL_TARGET 884 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel 885endif 886ifdef INSTALLED_2NDBOOTLOADER_TARGET 887 $(hide) $(ACP) \ 888 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second 889endif 890ifdef BOARD_KERNEL_CMDLINE 891 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline 892endif 893ifdef INSTALLED_RADIOIMAGE_TARGET 894 @# The radio image 895 $(hide) mkdir -p $(zip_root)/RADIO 896 $(hide) $(ACP) $(INSTALLED_RADIOIMAGE_TARGET) $(zip_root)/RADIO/image 897endif 898 @# Contents of the system image 899 $(hide) $(call package_files-copy-root, \ 900 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM) 901 @# Contents of the data image 902 $(hide) $(call package_files-copy-root, \ 903 $(TARGET_OUT_DATA),$(zip_root)/DATA) 904 @# Extra contents of the OTA package 905 $(hide) mkdir -p $(zip_root)/OTA/bin 906 $(hide) $(call package_files-copy-root, \ 907 $(INTERNAL_OTA_INTERMEDIATES_DIR),$(zip_root)/OTA) 908 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/ 909 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/ 910 @# Files that don't end up in any images, but are necessary to 911 @# build them. 912 $(hide) mkdir -p $(zip_root)/META 913 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt 914 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt 915 @# Zip everything up, preserving symlinks 916 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .) 917 918target-files-package: $(BUILT_TARGET_FILES_PACKAGE) 919 920# ----------------------------------------------------------------- 921# installed file list 922# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it 923# gets the DexOpt one if we're doing that. 924INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt 925$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE) 926 @echo Installed file list: $@ 927 @mkdir -p $(dir $@) 928 @rm -f $@ 929 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@ 930 931.PHONY: installed-file-list 932installed-file-list: $(INSTALLED_FILES_FILE) 933$(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE)) 934$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE)) 935 936# ----------------------------------------------------------------- 937# A zip of the tests that are built when running "make tests". 938# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we 939# only grab SYSTEM and DATA, and it's called "*-tests-*.zip". 940# 941name := $(TARGET_PRODUCT) 942ifeq ($(TARGET_BUILD_TYPE),debug) 943 name := $(name)_debug 944endif 945name := $(name)-tests-$(FILE_NAME_TAG) 946 947intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip) 948BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip 949$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates) 950$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name) 951 952# Depending on the images guarantees that the underlying 953# directories are up-to-date. 954$(BUILT_TESTS_ZIP_PACKAGE): \ 955 $(BUILT_SYSTEMIMAGE) \ 956 $(INSTALLED_USERDATAIMAGE_TARGET) \ 957 | $(ACP) 958 @echo "Package test files: $@" 959 $(hide) rm -rf $@ $(zip_root) 960 $(hide) mkdir -p $(dir $@) $(zip_root) 961 @# Some parts of the system image 962 $(hide) $(call package_files-copy-root, \ 963 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin) 964 $(hide) $(call package_files-copy-root, \ 965 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib) 966 $(hide) $(call package_files-copy-root, \ 967 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \ 968 $(zip_root)/SYSTEM/framework) 969 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM 970 @# Contents of the data image 971 $(hide) $(call package_files-copy-root, \ 972 $(TARGET_OUT_DATA),$(zip_root)/DATA) 973 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .) 974 975tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE) 976 977# ----------------------------------------------------------------- 978# A zip of the symbols directory. Keep the full paths to make it 979# more obvious where these files came from. 980# 981name := $(TARGET_PRODUCT) 982ifeq ($(TARGET_BUILD_TYPE),debug) 983 name := $(name)_debug 984endif 985name := $(name)-symbols-$(FILE_NAME_TAG) 986 987SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip 988$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET) 989 @echo "Package symbols: $@" 990 $(hide) rm -rf $@ 991 $(hide) mkdir -p $(dir $@) 992 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED) 993 994# ----------------------------------------------------------------- 995# A zip of the Android Apps. Not keeping full path so that we don't 996# include product names when distributing 997# 998name := $(TARGET_PRODUCT) 999ifeq ($(TARGET_BUILD_TYPE),debug) 1000 name := $(name)_debug 1001endif 1002name := $(name)-apps-$(FILE_NAME_TAG) 1003 1004APPS_ZIP := $(PRODUCT_OUT)/$(name).zip 1005$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE) 1006 @echo "Package apps: $@" 1007 $(hide) rm -rf $@ 1008 $(hide) mkdir -p $(dir $@) 1009 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/* 1010 1011endif # TARGET_SIMULATOR != true 1012 1013# ----------------------------------------------------------------- 1014# dalvik something 1015.PHONY: dalvikfiles 1016dalvikfiles: $(INTERNAL_DALVIK_MODULES) 1017 1018# ----------------------------------------------------------------- 1019# The update package 1020 1021INTERNAL_UPDATE_PACKAGE_FILES += \ 1022 $(INSTALLED_BOOTIMAGE_TARGET) \ 1023 $(INSTALLED_RECOVERYIMAGE_TARGET) \ 1024 $(INSTALLED_SYSTEMIMAGE) \ 1025 $(INSTALLED_USERDATAIMAGE_TARGET) \ 1026 $(INSTALLED_ANDROID_INFO_TXT_TARGET) 1027 1028ifneq ($(strip $(INTERNAL_UPDATE_PACKAGE_FILES)),) 1029 1030name := $(TARGET_PRODUCT) 1031ifeq ($(TARGET_BUILD_TYPE),debug) 1032 name := $(name)_debug 1033endif 1034name := $(name)-img-$(FILE_NAME_TAG) 1035 1036INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1037 1038$(INTERNAL_UPDATE_PACKAGE_TARGET): $(INTERNAL_UPDATE_PACKAGE_FILES) 1039 @echo "Package: $@" 1040 $(hide) zip -qj $@ $(INTERNAL_UPDATE_PACKAGE_FILES) 1041 1042else 1043INTERNAL_UPDATE_PACKAGE_TARGET := 1044endif 1045 1046# ----------------------------------------------------------------- 1047# The emulator package 1048 1049ifneq ($(TARGET_SIMULATOR),true) 1050 1051INTERNAL_EMULATOR_PACKAGE_FILES += \ 1052 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \ 1053 prebuilt/android-arm/kernel/kernel-qemu \ 1054 $(INSTALLED_RAMDISK_TARGET) \ 1055 $(INSTALLED_SYSTEMIMAGE) \ 1056 $(INSTALLED_USERDATAIMAGE_TARGET) 1057 1058name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG) 1059 1060INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1061 1062$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES) 1063 @echo "Package: $@" 1064 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES) 1065 1066endif 1067 1068# ----------------------------------------------------------------- 1069# The pdk package (Platform Development Kit) 1070 1071ifneq (,$(filter pdk,$(MAKECMDGOALS))) 1072 include development/pdk/Pdk.mk 1073endif 1074 1075# ----------------------------------------------------------------- 1076# The SDK 1077 1078ifneq ($(TARGET_SIMULATOR),true) 1079 1080# The SDK includes host-specific components, so it belongs under HOST_OUT. 1081sdk_dir := $(HOST_OUT)/sdk 1082 1083# Build a name that looks like: 1084# 1085# linux-x86 --> android-sdk_12345_linux-x86 1086# darwin-x86 --> android-sdk_12345_mac-x86 1087# windows-x86 --> android-sdk_12345_windows 1088# 1089sdk_name := android-sdk_$(FILE_NAME_TAG) 1090ifeq ($(HOST_OS),darwin) 1091 INTERNAL_SDK_HOST_OS_NAME := mac 1092else 1093 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS) 1094endif 1095ifneq ($(HOST_OS),windows) 1096 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH) 1097endif 1098sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME) 1099 1100sdk_dep_file := $(sdk_dir)/sdk_deps.mk 1101 1102ATREE_FILES := 1103-include $(sdk_dep_file) 1104 1105# if we don't have a real list, then use "everything" 1106ifeq ($(strip $(ATREE_FILES)),) 1107ATREE_FILES := \ 1108 $(ALL_PREBUILT) \ 1109 $(ALL_COPIED_HEADERS) \ 1110 $(ALL_GENERATED_SOURCES) \ 1111 $(ALL_DEFAULT_INSTALLED_MODULES) \ 1112 $(INSTALLED_RAMDISK_TARGET) \ 1113 $(ALL_DOCS) \ 1114 $(ALL_SDK_FILES) 1115endif 1116 1117atree_dir := development/build 1118 1119sdk_atree_files := \ 1120 $(atree_dir)/sdk.exclude.atree \ 1121 $(atree_dir)/sdk.atree \ 1122 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree 1123 1124deps := \ 1125 $(target_notice_file_txt) \ 1126 $(tools_notice_file_txt) \ 1127 $(OUT_DOCS)/offline-sdk-timestamp \ 1128 $(INTERNAL_UPDATE_PACKAGE_TARGET) \ 1129 $(INSTALLED_SDK_BUILD_PROP_TARGET) \ 1130 $(ATREE_FILES) \ 1131 $(atree_dir)/sdk.atree \ 1132 $(HOST_OUT_EXECUTABLES)/atree \ 1133 $(HOST_OUT_EXECUTABLES)/line_endings 1134 1135INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip 1136$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name) 1137$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name) 1138$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file) 1139$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files) 1140 1141# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built. 1142# 1143#SDK_GNU_ERROR := true 1144 1145$(INTERNAL_SDK_TARGET): $(deps) 1146 @echo "Package SDK: $@" 1147 $(hide) rm -rf $(PRIVATE_DIR) $@ 1148 $(hide) for f in $(target_gnu_MODULES); do \ 1149 if [ -f $$f ]; then \ 1150 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \ 1151 including GNU target $$f >&2; \ 1152 FAIL=$(SDK_GNU_ERROR); \ 1153 fi; \ 1154 done; \ 1155 if [ $$FAIL ]; then exit 1; fi 1156 $(hide) ( \ 1157 $(HOST_OUT_EXECUTABLES)/atree \ 1158 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \ 1159 -m $(PRIVATE_DEP_FILE) \ 1160 -I . \ 1161 -I $(PRODUCT_OUT) \ 1162 -I $(HOST_OUT) \ 1163 -I $(TARGET_COMMON_OUT_ROOT) \ 1164 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \ 1165 -o $(PRIVATE_DIR) && \ 1166 cp -f $(target_notice_file_txt) \ 1167 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \ 1168 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \ 1169 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \ 1170 development/tools/scripts/sdk_clean.sh $(PRIVATE_DIR) && \ 1171 chmod -R ug+rwX $(PRIVATE_DIR) && \ 1172 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \ 1173 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 ) 1174 1175endif # !simulator 1176 1177# ----------------------------------------------------------------- 1178# Findbugs 1179INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml 1180INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html 1181$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES) 1182 @echo UnionBugs: $@ 1183 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \ 1184 > $@ 1185$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET) 1186 @echo ConvertXmlToText: $@ 1187 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \ 1188 $(INTERNAL_FINDBUGS_XML_TARGET) > $@ 1189 1190# ----------------------------------------------------------------- 1191# Findbugs 1192 1193# ----------------------------------------------------------------- 1194# These are some additional build tasks that need to be run. 1195include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk)) 1196