Makefile revision b75105315187ec2719bdc8adfdea6fc4f6b296ef
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# The filter part means "only eval the copy-one-file rule if this 18# src:dest pair is the first one to match %:dest" 19$(foreach cf,$(PRODUCT_COPY_FILES), \ 20 $(eval _src := $(call word-colon,1,$(cf))) \ 21 $(eval _dest := $(call word-colon,2,$(cf))) \ 22 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \ 23 $(if $(filter $(_src):$(_dest),$(firstword $(filter %:$(_dest),$(PRODUCT_COPY_FILES)))), \ 24 $(eval $(call copy-one-file,$(_src),$(_fulldest))),) \ 25 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \ 26 ) 27 28# ----------------------------------------------------------------- 29# docs/index.html 30gen := $(OUT_DOCS)/index.html 31ALL_DOCS += $(gen) 32$(gen): frameworks/base/docs/docs-redirect-index.html 33 @mkdir -p $(dir $@) 34 @cp -f $< $@ 35 36# ----------------------------------------------------------------- 37# default.prop 38INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop 39ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET) 40ADDITIONAL_DEFAULT_PROPERTIES := \ 41 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES)) 42 43$(INSTALLED_DEFAULT_PROP_TARGET): 44 @echo Target buildinfo: $@ 45 @mkdir -p $(dir $@) 46 $(hide) echo "#" > $@; \ 47 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \ 48 echo "#" >> $@; 49 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \ 50 echo "$(line)" >> $@;) 51 52# ----------------------------------------------------------------- 53# build.prop 54INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop 55ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET) 56ADDITIONAL_BUILD_PROPERTIES := \ 57 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES)) 58 59# A list of arbitrary tags describing the build configuration. 60# Force ":=" so we can use += 61BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS) 62ifeq ($(TARGET_BUILD_TYPE),debug) 63 BUILD_VERSION_TAGS += debug 64endif 65# Apps are always signed with test keys, and may be re-signed in a post-build 66# step. If that happens, the "test-keys" tag will be removed by that step. 67BUILD_VERSION_TAGS += test-keys 68BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS))) 69 70# A human-readable string that descibes this build in detail. 71build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS) 72$(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc) 73 74# The string used to uniquely identify this build; used by the OTA server. 75ifeq (,$(strip $(BUILD_FINGERPRINT))) 76 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE)/$(TARGET_BOOTLOADER_BOARD_NAME):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) 77endif 78ifneq ($(words $(BUILD_FINGERPRINT)),1) 79 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)") 80endif 81 82# Display parameters shown under Settings -> About Phone 83ifeq ($(TARGET_BUILD_VARIANT),user) 84 # User builds should show: 85 # release build number or branch.buld_number non-release builds 86 87 # Dev. branches should have DISPLAY_BUILD_NUMBER set 88 ifeq "true" "$(DISPLAY_BUILD_NUMBER)" 89 BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER) 90 else 91 BUILD_DISPLAY_ID := $(BUILD_ID) 92 endif 93else 94 # Non-user builds should show detailed build information 95 BUILD_DISPLAY_ID := $(build_desc) 96endif 97 98# Selects the first locale in the list given as the argument, 99# and splits it into language and region, which each may be 100# empty. 101define default-locale 102$(subst _, , $(firstword $(1))) 103endef 104 105# Selects the first locale in the list given as the argument 106# and returns the language (or the region) 107define default-locale-language 108$(word 2, 2, $(call default-locale, $(1))) 109endef 110define default-locale-region 111$(word 3, 3, $(call default-locale, $(1))) 112endef 113 114BUILDINFO_SH := build/tools/buildinfo.sh 115$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) 116 @echo Target buildinfo: $@ 117 @mkdir -p $(dir $@) 118 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \ 119 TARGET_DEVICE="$(TARGET_DEVICE)" \ 120 PRODUCT_NAME="$(TARGET_PRODUCT)" \ 121 PRODUCT_BRAND="$(PRODUCT_BRAND)" \ 122 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \ 123 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \ 124 PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \ 125 PRODUCT_MODEL="$(PRODUCT_MODEL)" \ 126 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \ 127 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \ 128 BUILD_ID="$(BUILD_ID)" \ 129 BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \ 130 BUILD_NUMBER="$(BUILD_NUMBER)" \ 131 PLATFORM_VERSION="$(PLATFORM_VERSION)" \ 132 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \ 133 PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \ 134 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \ 135 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \ 136 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \ 137 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \ 138 TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \ 139 TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \ 140 bash $(BUILDINFO_SH) > $@ 141 $(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \ 142 cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \ 143 fi 144 $(if $(ADDITIONAL_BUILD_PROPERTIES), \ 145 $(hide) echo >> $@; \ 146 echo "#" >> $@; \ 147 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \ 148 echo "#" >> $@; ) 149 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \ 150 echo "$(line)" >> $@;) 151 152build_desc := 153 154# ----------------------------------------------------------------- 155# sdk-build.prop 156# 157# There are certain things in build.prop that we don't want to 158# ship with the sdk; remove them. 159 160# This must be a list of entire property keys followed by 161# "=" characters, without any internal spaces. 162sdk_build_prop_remove := \ 163 ro.build.user= \ 164 ro.build.host= \ 165 ro.product.brand= \ 166 ro.product.manufacturer= \ 167 ro.product.device= 168# TODO: Remove this soon-to-be obsolete property 169sdk_build_prop_remove += ro.build.product= 170INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop 171$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET) 172 @echo SDK buildinfo: $@ 173 @mkdir -p $(dir $@) 174 $(hide) grep -v "$(subst $(space),\|,$(strip \ 175 $(sdk_build_prop_remove)))" $< > $@.tmp 176 $(hide) for x in $(sdk_build_prop_remove); do \ 177 echo "$$x"generic >> $@.tmp; done 178 $(hide) mv $@.tmp $@ 179 180# ----------------------------------------------------------------- 181# package stats 182PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt 183PACKAGES_TO_STAT := \ 184 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \ 185 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES)))) 186$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT) 187 @echo Package stats: $@ 188 @mkdir -p $(dir $@) 189 $(hide) rm -f $@ 190 $(hide) build/tools/dump-package-stats $^ > $@ 191 192.PHONY: package-stats 193package-stats: $(PACKAGE_STATS_FILE) 194 195# ----------------------------------------------------------------- 196# Cert-to-package mapping. Used by the post-build signing tools. 197name := $(TARGET_PRODUCT) 198ifeq ($(TARGET_BUILD_TYPE),debug) 199 name := $(name)_debug 200endif 201name := $(name)-apkcerts-$(FILE_NAME_TAG) 202intermediates := \ 203 $(call intermediates-dir-for,PACKAGING,apkcerts) 204APKCERTS_FILE := $(intermediates)/$(name).txt 205# Depending on the built packages isn't exactly right, 206# but it should guarantee that the apkcerts file is rebuilt 207# if any packages change which certs they're signed with. 208all_built_packages := $(foreach p,$(PACKAGES),$(ALL_MODULES.$(p).BUILT)) 209$(APKCERTS_FILE): $(all_built_packages) 210 @echo APK certs list: $@ 211 @mkdir -p $(dir $@) 212 @rm -f $@ 213 $(hide) $(foreach p,$(PACKAGES),\ 214 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\ 215 echo 'name="$(p).apk" certificate="EXTERNAL" \ 216 private_key=""' >> $@;,\ 217 echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \ 218 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;)) 219 220.PHONY: apkcerts-list 221apkcerts-list: $(APKCERTS_FILE) 222 223# ----------------------------------------------------------------- 224# module info file 225ifdef CREATE_MODULE_INFO_FILE 226 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt 227 $(info Generating $(MODULE_INFO_FILE)...) 228 $(shell rm -f $(MODULE_INFO_FILE)) 229 $(foreach m,$(ALL_MODULES), \ 230 $(shell echo "NAME=\"$(m)\"" \ 231 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \ 232 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \ 233 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \ 234 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE))) 235endif 236 237# ----------------------------------------------------------------- 238 239# The test key is used to sign this package, and as the key required 240# for future OTA packages installed by this system. Actual product 241# deliverables will be re-signed by hand. We expect this file to 242# exist with the suffixes ".x509.pem" and ".pk8". 243DEFAULT_KEY_CERT_PAIR := $(SRC_TARGET_DIR)/product/security/testkey 244 245 246# Rules that need to be present for the simulator, even 247# if they don't do anything. 248.PHONY: systemimage 249systemimage: 250 251# ----------------------------------------------------------------- 252 253.PHONY: event-log-tags 254 255# Produce an event logs tag file for everything we know about, in order 256# to properly allocate numbers. Then produce a file that's filtered 257# for what's going to be installed. 258 259all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt 260 261# Include tags from all packages that we know about 262all_event_log_tags_src := \ 263 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS))) 264 265$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) 266$(all_event_log_tags_file): $(all_event_log_tags_src) 267 $(hide) mkdir -p $(dir $@) 268 $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES) 269 270 271event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags 272 273# Include tags from all packages included in this product. 274event_log_tags_src := \ 275 $(sort $(foreach m,\ 276 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \ 277 $(call module-names-for-tag-list,user), \ 278 $(ALL_MODULES.$(m).EVENT_LOG_TAGS))) 279 280$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) 281$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file) 282$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) 283 $(hide) mkdir -p $(dir $@) 284 $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES) 285 286event-log-tags: $(event_log_tags_file) 287 288ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file) 289 290 291ifneq ($(TARGET_SIMULATOR),true) 292 293# ################################################################# 294# Targets for boot/OS images 295# ################################################################# 296 297# ----------------------------------------------------------------- 298# the ramdisk 299INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \ 300 $(ALL_PREBUILT) \ 301 $(ALL_COPIED_HEADERS) \ 302 $(ALL_GENERATED_SOURCES) \ 303 $(ALL_DEFAULT_INSTALLED_MODULES)) 304 305BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img 306 307# We just build this directly to the install location. 308INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET) 309$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP) 310 $(call pretty,"Target ram disk: $@") 311 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@ 312 313 314ifneq ($(strip $(TARGET_NO_KERNEL)),true) 315 316# ----------------------------------------------------------------- 317# the boot image, which is a collection of other images. 318INTERNAL_BOOTIMAGE_ARGS := \ 319 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 320 --kernel $(INSTALLED_KERNEL_TARGET) \ 321 --ramdisk $(INSTALLED_RAMDISK_TARGET) 322 323INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS)) 324 325BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE)) 326ifdef BOARD_KERNEL_CMDLINE 327 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 328endif 329 330BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE)) 331ifdef BOARD_KERNEL_BASE 332 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE) 333endif 334 335INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img 336 337ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true) 338tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg 339INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image) 340INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG) 341$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES) 342 $(call pretty,"Target boot image: $@") 343 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@ 344 345else # TARGET_BOOTIMAGE_USE_EXT2 != true 346 347$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) 348 $(call pretty,"Target boot image: $@") 349 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@ 350 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw) 351endif # TARGET_BOOTIMAGE_USE_EXT2 352 353else # TARGET_NO_KERNEL 354# HACK: The top-level targets depend on the bootimage. Not all targets 355# can produce a bootimage, though, and emulator targets need the ramdisk 356# instead. Fake it out by calling the ramdisk the bootimage. 357# TODO: make the emulator use bootimages, and make mkbootimg accept 358# kernel-less inputs. 359INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET) 360endif 361 362# ----------------------------------------------------------------- 363# NOTICE files 364# 365# This needs to be before the systemimage rules, because it adds to 366# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files 367# go into the systemimage. 368 369.PHONY: notice_files 370 371# Create the rule to combine the files into text and html forms 372# $(1) - Plain text output file 373# $(2) - HTML output file 374# $(3) - File title 375# $(4) - Directory to use. Notice files are all $(4)/src. Other 376# directories in there will be used for scratch 377# $(5) - Dependencies for the output files 378# 379# The algorithm here is that we go collect a hash for each of the notice 380# files and write the names of the files that match that hash. Then 381# to generate the real files, we go print out all of the files and their 382# hashes. 383# 384# These rules are fairly complex, so they depend on this makefile so if 385# it changes, they'll run again. 386# 387# TODO: We could clean this up so that we just record the locations of the 388# original notice files instead of making rules to copy them somwehere. 389# Then we could traverse that without quite as much bash drama. 390define combine-notice-files 391$(1) $(2): PRIVATE_MESSAGE := $(3) 392$(1) $(2) $(4)/hash-timestamp: PRIVATE_DIR := $(4) 393$(4)/hash-timestamp: $(5) $(BUILD_SYSTEM)/Makefile 394 @echo Finding NOTICE files: $$@ 395 $$(hide) rm -rf $$@ $$(PRIVATE_DIR)/hash 396 $$(hide) mkdir -p $$(PRIVATE_DIR)/hash 397 $$(hide) for file in $$$$(find $$(PRIVATE_DIR)/src -type f); do \ 398 hash=$$$$($(MD5SUM) $$$$file | sed -e "s/ .*//"); \ 399 hashfile=$$(PRIVATE_DIR)/hash/$$$$hash; \ 400 echo $$$$file >> $$$$hashfile; \ 401 done 402 $$(hide) touch $$@ 403$(1): $(4)/hash-timestamp 404 @echo Combining NOTICE files: $$@ 405 $$(hide) mkdir -p $$(dir $$@) 406 $$(hide) echo $$(PRIVATE_MESSAGE) > $$@ 407 $$(hide) find $$(PRIVATE_DIR)/hash -type f | xargs cat | sort | \ 408 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> $$@ 409 $$(hide) echo >> $$@ 410 $$(hide) echo >> $$@ 411 $$(hide) echo >> $$@ 412 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \ 413 echo "============================================================"\ 414 >> $$@; \ 415 echo "Notices for file(s):" >> $$@; \ 416 cat $$$$hashfile | sort | \ 417 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \ 418 $$@; \ 419 echo "------------------------------------------------------------"\ 420 >> $$@; \ 421 echo >> $$@; \ 422 orig=$$$$(head -n 1 $$$$hashfile); \ 423 cat $$$$orig >> $$@; \ 424 echo >> $$@; \ 425 echo >> $$@; \ 426 echo >> $$@; \ 427 done 428$(2): $(4)/hash-timestamp 429 @echo Combining NOTICE files: $$@ 430 $$(hide) mkdir -p $$(dir $$@) 431 $$(hide) echo "<html><head>" > $$@ 432 $$(hide) echo "<style type=\"text/css\">" >> $$@ 433 $$(hide) echo "body { padding: 0; font-family: sans-serif; }" >> $$@ 434 $$(hide) echo ".same-license { background-color: #eeeeee; border-top: 20px solid white; padding: 10px; }" >> $$@ 435 $$(hide) echo ".label { font-weight: bold; }" >> $$@ 436 $$(hide) echo ".file-list { margin-left: 1em; font-color: blue; }" >> $$@ 437 $$(hide) echo "</style>" >> $$@ 438 $$(hide) echo "</head><body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">" >> $$@ 439 $$(hide) echo "<table cellpading=\"0\" cellspacing=\"0\" border=\"0\">" \ 440 >> $$@ 441 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \ 442 cat $$$$hashfile | sort | \ 443 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: <a name=\"\1\"></a>:" >> \ 444 $$@; \ 445 echo "<tr><td class=\"same-license\">" >> $$@; \ 446 echo "<div class=\"label\">Notices for file(s):</div>" >> $$@; \ 447 echo "<div class=\"file-list\">" >> $$@; \ 448 cat $$$$hashfile | sort | \ 449 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1<br/>:" >> $$@; \ 450 echo "</div><!-- file-list -->" >> $$@; \ 451 echo >> $$@; \ 452 orig=$$$$(head -n 1 $$$$hashfile); \ 453 echo "<pre class=\"license-text\">" >> $$@; \ 454 cat $$$$orig | sed -e "s/\&/\&/g" | sed -e "s/</\</g" \ 455 | sed -e "s/>/\>/g" >> $$@; \ 456 echo "</pre><!-- license-text -->" >> $$@; \ 457 echo "</td></tr><!-- same-license -->" >> $$@; \ 458 echo >> $$@; \ 459 echo >> $$@; \ 460 echo >> $$@; \ 461 done 462 $$(hide) echo "</table>" >> $$@ 463 $$(hide) echo "</body></html>" >> $$@ 464notice_files: $(1) $(2) 465endef 466 467# TODO These intermediate NOTICE.txt/NOTICE.html files should go into 468# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from 469# the src subdirectory. 470 471target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt 472target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html 473target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz 474tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt 475tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html 476 477kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt 478 479$(eval $(call combine-notice-files, \ 480 $(target_notice_file_txt), \ 481 $(target_notice_file_html), \ 482 "Notices for files contained in the filesystem images in this directory:", \ 483 $(TARGET_OUT_NOTICE_FILES), \ 484 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file))) 485 486$(eval $(call combine-notice-files, \ 487 $(tools_notice_file_txt), \ 488 $(tools_notice_file_html), \ 489 "Notices for files contained in the tools directory:", \ 490 $(HOST_OUT_NOTICE_FILES), \ 491 $(ALL_DEFAULT_INSTALLED_MODULES))) 492 493# Install the html file at /system/etc/NOTICE.html.gz. 494# This is not ideal, but this is very late in the game, after a lot of 495# the module processing has already been done -- in fact, we used the 496# fact that all that has been done to get the list of modules that we 497# need notice files for. 498$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP) 499 $(hide) $(MINIGZIP) -9 < $< > $@ 500installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz 501$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP) 502 $(copy-file-to-target) 503 504# if we've been run my mm, mmm, etc, don't reinstall this every time 505ifeq ($(ONE_SHOT_MAKEFILE),) 506ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz) 507endif 508 509# The kernel isn't really a module, so to get its module file in there, we 510# make the target NOTICE files depend on this particular file too, which will 511# then be in the right directory for the find in combine-notice-files to work. 512$(kernel_notice_file): \ 513 prebuilt/$(TARGET_PREBUILT_TAG)/kernel/LINUX_KERNEL_COPYING \ 514 | $(ACP) 515 @echo Copying: $@ 516 $(hide) mkdir -p $(dir $@) 517 $(hide) $(ACP) $< $@ 518 519 520# ----------------------------------------------------------------- 521# Build a keystore with the authorized keys in it, used to verify the 522# authenticity of downloaded OTA packages. 523# 524# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come 525# before the rules that use that variable to build the image. 526ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip 527$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR) 528$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR)) 529 $(hide) rm -f $@ 530 $(hide) mkdir -p $(dir $@) 531 $(hide) zip -qj $@ $< 532 533.PHONY: otacerts 534otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip 535 536 537# ################################################################# 538# Targets for user images 539# ################################################################# 540 541ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 542include external/genext2fs/Config.mk 543INTERNAL_MKUSERFS := $(MKEXT2IMG) 544else 545INTERNAL_MKUSERFS := $(MKYAFFS2) 546endif 547 548# ----------------------------------------------------------------- 549# Recovery image 550 551# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true 552ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY) $(BUILD_TINY_ANDROID))) 553 554INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img 555 556recovery_initrc := $(call include-path-for, recovery)/etc/init.rc 557recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system 558recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img 559recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET) 560recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery 561recovery_resources_common := $(call include-path-for, recovery)/res 562recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)) 563recovery_resource_deps := $(shell find $(recovery_resources_common) \ 564 $(recovery_resources_private) -type f) 565 566ifeq ($(recovery_resources_private),) 567 $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE)) 568endif 569 570INTERNAL_RECOVERYIMAGE_ARGS := \ 571 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 572 --kernel $(recovery_kernel) \ 573 --ramdisk $(recovery_ramdisk) 574 575# Assumes this has already been stripped 576ifdef BOARD_KERNEL_CMDLINE 577 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 578endif 579ifdef BOARD_KERNEL_BASE 580 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE) 581endif 582 583# Keys authorized to sign OTA packages this build will accept. The 584# build always uses test-keys for this; release packaging tools will 585# substitute other keys for this one. 586OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem 587 588# Generate a file containing the keys that will be read by the 589# recovery binary. 590RECOVERY_INSTALL_OTA_KEYS := \ 591 $(call intermediates-dir-for,PACKAGING,ota_keys)/keys 592DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar 593$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS) 594$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) 595 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS)" 596 @rm -rf $@ 597 @mkdir -p $(dir $@) 598 java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@ 599 600$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \ 601 $(INSTALLED_RAMDISK_TARGET) \ 602 $(INSTALLED_BOOTIMAGE_TARGET) \ 603 $(recovery_binary) \ 604 $(recovery_initrc) $(recovery_kernel) \ 605 $(INSTALLED_2NDBOOTLOADER_TARGET) \ 606 $(recovery_build_prop) $(recovery_resource_deps) \ 607 $(RECOVERY_INSTALL_OTA_KEYS) 608 @echo ----- Making recovery image ------ 609 rm -rf $(TARGET_RECOVERY_OUT) 610 mkdir -p $(TARGET_RECOVERY_OUT) 611 mkdir -p $(TARGET_RECOVERY_ROOT_OUT) 612 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc 613 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp 614 echo Copying baseline ramdisk... 615 cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT) 616 echo Modifying ramdisk contents... 617 cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/ 618 cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/ 619 cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/ 620 $(foreach item,$(recovery_resources_private), \ 621 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/) 622 cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys 623 cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \ 624 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop 625 $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk) 626 $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@ 627 @echo ----- Made recovery image -------- $@ 628 $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw) 629 630else 631INSTALLED_RECOVERYIMAGE_TARGET := 632endif 633 634.PHONY: recoveryimage 635recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) 636 637ifneq ($(BOARD_NAND_PAGE_SIZE),) 638mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE) 639else 640mkyaffs2_extra_flags := 641endif 642 643 644# ----------------------------------------------------------------- 645# system yaffs image 646# 647# First, the "unoptimized" image, which contains .apk/.jar files 648# that contain regular, unoptimized/unverified .dex entries. 649# 650systemimage_unopt_intermediates := \ 651 $(call intermediates-dir-for,PACKAGING,systemimage_unopt) 652BUILT_SYSTEMIMAGE_UNOPT := $(systemimage_unopt_intermediates)/system.img 653 654INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \ 655 $(ALL_PREBUILT) \ 656 $(ALL_COPIED_HEADERS) \ 657 $(ALL_GENERATED_SOURCES) \ 658 $(ALL_DEFAULT_INSTALLED_MODULES)) 659 660ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 661## generate an ext2 image 662# $(1): output file 663define build-systemimage-target 664 @echo "Target system fs image: $(1)" 665 $(call build-userimage-ext2-target,$(TARGET_OUT),$(1),system,) 666endef 667 668else # TARGET_USERIMAGES_USE_EXT2 != true 669 670## generate a yaffs2 image 671# $(1): output file 672define build-systemimage-target 673 @echo "Target system fs image: $(1)" 674 @mkdir -p $(dir $(1)) 675 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1) 676endef 677endif # TARGET_USERIMAGES_USE_EXT2 678 679$(BUILT_SYSTEMIMAGE_UNOPT): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_MKUSERFS) 680 $(call build-systemimage-target,$@) 681 682# The installed image, which may be optimized or unoptimized. 683# 684INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img 685 686ifdef WITH_DEXPREOPT 687 ifndef DISABLE_DEXPREOPT 688 with_dexpreopt := true 689 endif 690endif 691ifdef with_dexpreopt 692 # This file will set BUILT_SYSTEMIMAGE and SYSTEMIMAGE_SOURCE_DIR 693 include build/tools/dexpreopt/Config.mk 694else 695 BUILT_SYSTEMIMAGE := $(BUILT_SYSTEMIMAGE_UNOPT) 696 SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT) 697endif 698 699# The system partition needs room for the recovery image as well. We 700# now store the recovery image as a binary patch using the boot image 701# as the source (since they are very similar). Generate the patch so 702# we can see how big it's going to be, and include that in the system 703# image size check calculation. 704ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),) 705intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch) 706RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p 707$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \ 708 $(INSTALLED_BOOTIMAGE_TARGET) \ 709 $(HOST_OUT_EXECUTABLES)/imgdiff \ 710 $(HOST_OUT_EXECUTABLES)/bsdiff 711 @echo "Construct recovery from boot" 712 mkdir -p $(dir $@) 713 PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@ 714endif 715 716 717$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP) 718 @echo "Install system fs image: $@" 719 $(copy-file-to-target) 720 $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs) 721 722systemimage: $(INSTALLED_SYSTEMIMAGE) 723 724.PHONY: systemimage-nodeps snod 725systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \ 726 | $(INTERNAL_MKUSERFS) 727 @echo "make $@: ignoring dependencies" 728 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE)) 729 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs) 730 731####### 732## system tarball 733define build-systemtarball-target 734 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)") 735 $(MKTARBALL) $(FS_GET_STATS) \ 736 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \ 737 $(INSTALLED_SYSTEMTARBALL_TARGET) 738endef 739 740system_tar := $(PRODUCT_OUT)/system.tar 741INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).bz2 742$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar) 743$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES) 744 $(build-systemtarball-target) 745 746.PHONY: systemtarball-nodeps 747systemtarball-nodeps: $(FS_GET_STATS) \ 748 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS)) 749 $(build-systemtarball-target) 750 751.PHONY: stnod 752stnod: systemtarball-nodeps 753 754 755# ----------------------------------------------------------------- 756# data partition image 757INTERNAL_USERDATAIMAGE_FILES := \ 758 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) 759 760ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 761## Generate an ext2 image 762define build-userdataimage-target 763 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)") 764 @mkdir -p $(TARGET_OUT_DATA) 765 $(call build-userimage-ext2-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),userdata,) 766 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs) 767endef 768 769else # TARGET_USERIMAGES_USE_EXT2 != true 770 771## Generate a yaffs2 image 772define build-userdataimage-target 773 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)") 774 @mkdir -p $(TARGET_OUT_DATA) 775 $(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET) 776 $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs) 777endef 778endif # TARGET_USERIMAGES_USE_EXT2 779 780BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img 781 782# We just build this directly to the install location. 783INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET) 784$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_MKUSERFS) \ 785 $(INTERNAL_USERDATAIMAGE_FILES) 786 $(build-userdataimage-target) 787 788.PHONY: userdataimage-nodeps 789userdataimage-nodeps: $(INTERNAL_MKUSERFS) 790 $(build-userdataimage-target) 791 792####### 793## data partition tarball 794define build-userdatatarball-target 795 $(call pretty,"Target userdata fs tarball: " \ 796 "$(INSTALLED_USERDATATARBALL_TARGET)") 797 $(MKTARBALL) $(FS_GET_STATS) \ 798 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \ 799 $(INSTALLED_USERDATATARBALL_TARGET) 800endef 801 802userdata_tar := $(PRODUCT_OUT)/userdata.tar 803INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2 804$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar) 805$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES) 806 $(build-userdatatarball-target) 807 808.PHONY: userdatatarball-nodeps 809userdatatarball-nodeps: $(FS_GET_STATS) 810 $(build-userdatatarball-target) 811 812 813# ----------------------------------------------------------------- 814# bring in the installer image generation defines if necessary 815ifeq ($(TARGET_USE_DISKINSTALLER),true) 816include bootable/diskinstaller/config.mk 817endif 818 819# ----------------------------------------------------------------- 820# host tools needed to build OTA packages 821 822OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \ 823 $(HOST_OUT_EXECUTABLES)/mkbootfs \ 824 $(HOST_OUT_EXECUTABLES)/mkbootimg \ 825 $(HOST_OUT_EXECUTABLES)/fs_config \ 826 $(HOST_OUT_EXECUTABLES)/mkyaffs2image \ 827 $(HOST_OUT_EXECUTABLES)/zipalign \ 828 $(HOST_OUT_EXECUTABLES)/aapt \ 829 $(HOST_OUT_EXECUTABLES)/bsdiff \ 830 $(HOST_OUT_EXECUTABLES)/imgdiff \ 831 $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \ 832 $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar 833 834.PHONY: otatools 835otatools: $(OTATOOLS) 836 837# ----------------------------------------------------------------- 838# A zip of the directories that map to the target filesystem. 839# This zip can be used to create an OTA package or filesystem image 840# as a post-build step. 841# 842name := $(TARGET_PRODUCT) 843ifeq ($(TARGET_BUILD_TYPE),debug) 844 name := $(name)_debug 845endif 846name := $(name)-target_files-$(FILE_NAME_TAG) 847 848intermediates := $(call intermediates-dir-for,PACKAGING,target_files) 849BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip 850$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates) 851$(BUILT_TARGET_FILES_PACKAGE): \ 852 zip_root := $(intermediates)/$(name) 853 854# $(1): Directory to copy 855# $(2): Location to copy it to 856# The "ls -A" is to prevent "acp s/* d" from failing if s is empty. 857define package_files-copy-root 858 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \ 859 mkdir -p $(2) && \ 860 $(ACP) -rd $(strip $(1))/* $(2); \ 861 fi 862endef 863 864built_ota_tools := \ 865 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \ 866 $(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \ 867 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \ 868 $(call intermediates-dir-for,EXECUTABLES,updater)/updater 869$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools) 870 871$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION) 872 873ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),) 874# default to common dir for device vendor 875$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common 876else 877$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS) 878endif 879 880# Depending on the various images guarantees that the underlying 881# directories are up-to-date. 882$(BUILT_TARGET_FILES_PACKAGE): \ 883 $(INSTALLED_BOOTIMAGE_TARGET) \ 884 $(INSTALLED_RADIOIMAGE_TARGET) \ 885 $(INSTALLED_RECOVERYIMAGE_TARGET) \ 886 $(INSTALLED_SYSTEMIMAGE) \ 887 $(INSTALLED_USERDATAIMAGE_TARGET) \ 888 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 889 $(built_ota_tools) \ 890 $(APKCERTS_FILE) \ 891 $(HOST_OUT_EXECUTABLES)/fs_config \ 892 | $(ACP) 893 @echo "Package target files: $@" 894 $(hide) rm -rf $@ $(zip_root) 895 $(hide) mkdir -p $(dir $@) $(zip_root) 896 @# Components of the recovery image 897 $(hide) mkdir -p $(zip_root)/RECOVERY 898 $(hide) $(call package_files-copy-root, \ 899 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK) 900ifdef INSTALLED_KERNEL_TARGET 901 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel 902endif 903ifdef INSTALLED_2NDBOOTLOADER_TARGET 904 $(hide) $(ACP) \ 905 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second 906endif 907ifdef BOARD_KERNEL_CMDLINE 908 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline 909endif 910ifdef BOARD_KERNEL_BASE 911 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base 912endif 913 @# Components of the boot image 914 $(hide) mkdir -p $(zip_root)/BOOT 915 $(hide) $(call package_files-copy-root, \ 916 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK) 917ifdef INSTALLED_KERNEL_TARGET 918 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel 919endif 920ifdef INSTALLED_2NDBOOTLOADER_TARGET 921 $(hide) $(ACP) \ 922 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second 923endif 924ifdef BOARD_KERNEL_CMDLINE 925 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline 926endif 927ifdef BOARD_KERNEL_BASE 928 $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base 929endif 930 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\ 931 mkdir -p $(zip_root)/RADIO; \ 932 $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));) 933 @# Contents of the system image 934 $(hide) $(call package_files-copy-root, \ 935 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM) 936 @# Contents of the data image 937 $(hide) $(call package_files-copy-root, \ 938 $(TARGET_OUT_DATA),$(zip_root)/DATA) 939 @# Extra contents of the OTA package 940 $(hide) mkdir -p $(zip_root)/OTA/bin 941 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/ 942 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/ 943 @# Files that do not end up in any images, but are necessary to 944 @# build them. 945 $(hide) mkdir -p $(zip_root)/META 946 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt 947 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt 948 $(hide) echo "$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/recovery-api-version.txt 949 $(hide) echo "blocksize $(BOARD_FLASH_BLOCK_SIZE)" > $(zip_root)/META/imagesizes.txt 950 $(hide) echo "boot $(call image-size-from-data-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/imagesizes.txt 951 $(hide) echo "recovery $(call image-size-from-data-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/imagesizes.txt 952 $(hide) echo "system $(call image-size-from-data-size,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/imagesizes.txt 953 $(hide) echo "userdata $(call image-size-from-data-size,$(BOARD_USERDATAIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/imagesizes.txt 954 $(hide) echo "$(tool_extensions)" > $(zip_root)/META/tool-extensions.txt 955 @# Zip everything up, preserving symlinks 956 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .) 957 @# Run fs_config on all the system files in the zip, and save the output 958 $(hide) zipinfo -1 $@ | awk -F/ 'BEGIN { OFS="/" } /^SYSTEM\// {$$1 = "system"; print}' | $(HOST_OUT_EXECUTABLES)/fs_config > $(zip_root)/META/filesystem_config.txt 959 $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/filesystem_config.txt) 960 961 962target-files-package: $(BUILT_TARGET_FILES_PACKAGE) 963 964# ----------------------------------------------------------------- 965# OTA update package 966 967ifneq ($(TARGET_SIMULATOR),true) 968ifneq ($(TARGET_PRODUCT),sdk) 969ifneq ($(TARGET_DEVICE),generic) 970 971name := $(TARGET_PRODUCT) 972ifeq ($(TARGET_BUILD_TYPE),debug) 973 name := $(name)_debug 974endif 975name := $(name)-ota-$(FILE_NAME_TAG) 976 977INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 978 979$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR) 980 981ifeq ($(TARGET_OTA_SCRIPT_MODE),) 982# default to "auto" 983$(INTERNAL_OTA_PACKAGE_TARGET): scriptmode := auto 984else 985$(INTERNAL_OTA_PACKAGE_TARGET): scriptmode := $(TARGET_OTA_SCRIPT_MODE) 986endif 987 988$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS) 989 @echo "Package OTA: $@" 990 $(hide) ./build/tools/releasetools/ota_from_target_files \ 991 -m $(scriptmode) \ 992 -p $(HOST_OUT) \ 993 -k $(KEY_CERT_PAIR) \ 994 $(BUILT_TARGET_FILES_PACKAGE) $@ 995 996.PHONY: otapackage 997otapackage: $(INTERNAL_OTA_PACKAGE_TARGET) 998 999endif # TARGET_DEVICE != generic 1000endif # TARGET_PRODUCT != sdk 1001endif # TARGET_SIMULATOR != true 1002 1003# ----------------------------------------------------------------- 1004# installed file list 1005# Depending on $(INSTALLED_SYSTEMIMAGE) ensures that it 1006# gets the DexOpt one if we're doing that. 1007INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt 1008$(INSTALLED_FILES_FILE): $(INSTALLED_SYSTEMIMAGE) 1009 @echo Installed file list: $@ 1010 @mkdir -p $(dir $@) 1011 @rm -f $@ 1012 $(hide) build/tools/fileslist.py $(TARGET_OUT) $(TARGET_OUT_DATA) > $@ 1013 1014.PHONY: installed-file-list 1015installed-file-list: $(INSTALLED_FILES_FILE) 1016$(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE)) 1017$(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE)) 1018 1019# ----------------------------------------------------------------- 1020# A zip of the tests that are built when running "make tests". 1021# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we 1022# only grab SYSTEM and DATA, and it's called "*-tests-*.zip". 1023# 1024name := $(TARGET_PRODUCT) 1025ifeq ($(TARGET_BUILD_TYPE),debug) 1026 name := $(name)_debug 1027endif 1028name := $(name)-tests-$(FILE_NAME_TAG) 1029 1030intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip) 1031BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip 1032$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates) 1033$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name) 1034 1035# Depending on the images guarantees that the underlying 1036# directories are up-to-date. 1037$(BUILT_TESTS_ZIP_PACKAGE): \ 1038 $(BUILT_SYSTEMIMAGE) \ 1039 $(INSTALLED_USERDATAIMAGE_TARGET) \ 1040 | $(ACP) 1041 @echo "Package test files: $@" 1042 $(hide) rm -rf $@ $(zip_root) 1043 $(hide) mkdir -p $(dir $@) $(zip_root) 1044 @# Some parts of the system image 1045 $(hide) $(call package_files-copy-root, \ 1046 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin) 1047 $(hide) $(call package_files-copy-root, \ 1048 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib) 1049 $(hide) $(call package_files-copy-root, \ 1050 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \ 1051 $(zip_root)/SYSTEM/framework) 1052 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM 1053 @# Contents of the data image 1054 $(hide) $(call package_files-copy-root, \ 1055 $(TARGET_OUT_DATA),$(zip_root)/DATA) 1056 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .) 1057 1058tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE) 1059 1060# ----------------------------------------------------------------- 1061# A zip of the symbols directory. Keep the full paths to make it 1062# more obvious where these files came from. 1063# 1064name := $(TARGET_PRODUCT) 1065ifeq ($(TARGET_BUILD_TYPE),debug) 1066 name := $(name)_debug 1067endif 1068name := $(name)-symbols-$(FILE_NAME_TAG) 1069 1070SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip 1071$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET) 1072 @echo "Package symbols: $@" 1073 $(hide) rm -rf $@ 1074 $(hide) mkdir -p $(dir $@) 1075 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED) 1076 1077# ----------------------------------------------------------------- 1078# A zip of the Android Apps. Not keeping full path so that we don't 1079# include product names when distributing 1080# 1081name := $(TARGET_PRODUCT) 1082ifeq ($(TARGET_BUILD_TYPE),debug) 1083 name := $(name)_debug 1084endif 1085name := $(name)-apps-$(FILE_NAME_TAG) 1086 1087APPS_ZIP := $(PRODUCT_OUT)/$(name).zip 1088$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE) 1089 @echo "Package apps: $@" 1090 $(hide) rm -rf $@ 1091 $(hide) mkdir -p $(dir $@) 1092 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/* 1093 1094 1095#------------------------------------------------------------------ 1096# A zip of emma code coverage meta files. Generated for fully emma 1097# instrumented build. 1098# 1099EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip 1100$(EMMA_META_ZIP): $(INSTALLED_SYSTEMIMAGE) 1101 @echo "Collecting Emma coverage meta files." 1102 $(hide) find $(TARGET_COMMON_OUT_ROOT) -name "coverage.em" | \ 1103 zip -@ -q $@ 1104 1105endif # TARGET_SIMULATOR != true 1106 1107# ----------------------------------------------------------------- 1108# dalvik something 1109.PHONY: dalvikfiles 1110dalvikfiles: $(INTERNAL_DALVIK_MODULES) 1111 1112# ----------------------------------------------------------------- 1113# The update package 1114 1115ifneq ($(TARGET_SIMULATOR),true) 1116ifneq ($(TARGET_PRODUCT),sdk) 1117 1118name := $(TARGET_PRODUCT) 1119ifeq ($(TARGET_BUILD_TYPE),debug) 1120 name := $(name)_debug 1121endif 1122name := $(name)-img-$(FILE_NAME_TAG) 1123 1124INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1125 1126ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),) 1127# default to common dir for device vendor 1128$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_DEVICE_DIR)/../common 1129else 1130$(INTERNAL_UPDATE_PACKAGE_TARGET): extensions := $(TARGET_RELEASETOOLS_EXTENSIONS) 1131endif 1132 1133$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS) 1134 @echo "Package: $@" 1135 $(hide) ./build/tools/releasetools/img_from_target_files \ 1136 -s $(extensions) \ 1137 -p $(HOST_OUT) \ 1138 $(BUILT_TARGET_FILES_PACKAGE) $@ 1139 1140.PHONY: updatepackage 1141updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET) 1142 1143endif # TARGET_PRODUCT != sdk 1144endif # TARGET_SIMULATOR != true 1145 1146# ----------------------------------------------------------------- 1147# The emulator package 1148 1149ifneq ($(TARGET_SIMULATOR),true) 1150 1151INTERNAL_EMULATOR_PACKAGE_FILES += \ 1152 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \ 1153 prebuilt/android-arm/kernel/kernel-qemu \ 1154 $(INSTALLED_RAMDISK_TARGET) \ 1155 $(INSTALLED_SYSTEMIMAGE) \ 1156 $(INSTALLED_USERDATAIMAGE_TARGET) 1157 1158name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG) 1159 1160INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1161 1162$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES) 1163 @echo "Package: $@" 1164 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES) 1165 1166endif 1167 1168# ----------------------------------------------------------------- 1169# The pdk package (Platform Development Kit) 1170 1171ifneq (,$(filter pdk,$(MAKECMDGOALS))) 1172 include development/pdk/Pdk.mk 1173endif 1174 1175# ----------------------------------------------------------------- 1176# The SDK 1177 1178ifneq ($(TARGET_SIMULATOR),true) 1179 1180# The SDK includes host-specific components, so it belongs under HOST_OUT. 1181sdk_dir := $(HOST_OUT)/sdk 1182 1183# Build a name that looks like: 1184# 1185# linux-x86 --> android-sdk_12345_linux-x86 1186# darwin-x86 --> android-sdk_12345_mac-x86 1187# windows-x86 --> android-sdk_12345_windows 1188# 1189sdk_name := android-sdk_$(FILE_NAME_TAG) 1190ifeq ($(HOST_OS),darwin) 1191 INTERNAL_SDK_HOST_OS_NAME := mac 1192else 1193 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS) 1194endif 1195ifneq ($(HOST_OS),windows) 1196 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(HOST_ARCH) 1197endif 1198sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME) 1199 1200sdk_dep_file := $(sdk_dir)/sdk_deps.mk 1201 1202ATREE_FILES := 1203-include $(sdk_dep_file) 1204 1205# if we don't have a real list, then use "everything" 1206ifeq ($(strip $(ATREE_FILES)),) 1207ATREE_FILES := \ 1208 $(ALL_PREBUILT) \ 1209 $(ALL_COPIED_HEADERS) \ 1210 $(ALL_GENERATED_SOURCES) \ 1211 $(ALL_DEFAULT_INSTALLED_MODULES) \ 1212 $(INSTALLED_RAMDISK_TARGET) \ 1213 $(ALL_DOCS) \ 1214 $(ALL_SDK_FILES) 1215endif 1216 1217atree_dir := development/build 1218 1219sdk_atree_files := \ 1220 $(atree_dir)/sdk.exclude.atree \ 1221 $(atree_dir)/sdk.atree \ 1222 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree 1223 1224deps := \ 1225 $(target_notice_file_txt) \ 1226 $(tools_notice_file_txt) \ 1227 $(OUT_DOCS)/offline-sdk-timestamp \ 1228 $(SYMBOLS_ZIP) \ 1229 $(INSTALLED_SYSTEMIMAGE) \ 1230 $(INSTALLED_USERDATAIMAGE_TARGET) \ 1231 $(INSTALLED_RAMDISK_TARGET) \ 1232 $(INSTALLED_SDK_BUILD_PROP_TARGET) \ 1233 $(INSTALLED_BUILD_PROP_TARGET) \ 1234 $(ATREE_FILES) \ 1235 $(atree_dir)/sdk.atree \ 1236 $(HOST_OUT_EXECUTABLES)/atree \ 1237 $(HOST_OUT_EXECUTABLES)/line_endings 1238 1239INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip 1240$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name) 1241$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name) 1242$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file) 1243$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files) 1244 1245# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built. 1246# 1247#SDK_GNU_ERROR := true 1248 1249$(INTERNAL_SDK_TARGET): $(deps) 1250 @echo "Package SDK: $@" 1251 $(hide) rm -rf $(PRIVATE_DIR) $@ 1252 $(hide) for f in $(target_gnu_MODULES); do \ 1253 if [ -f $$f ]; then \ 1254 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \ 1255 including GNU target $$f >&2; \ 1256 FAIL=$(SDK_GNU_ERROR); \ 1257 fi; \ 1258 done; \ 1259 if [ $$FAIL ]; then exit 1; fi 1260 $(hide) ( \ 1261 $(HOST_OUT_EXECUTABLES)/atree \ 1262 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \ 1263 -m $(PRIVATE_DEP_FILE) \ 1264 -I . \ 1265 -I $(PRODUCT_OUT) \ 1266 -I $(HOST_OUT) \ 1267 -I $(TARGET_COMMON_OUT_ROOT) \ 1268 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \ 1269 -o $(PRIVATE_DIR) && \ 1270 cp -f $(target_notice_file_txt) \ 1271 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \ 1272 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \ 1273 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \ 1274 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \ 1275 chmod -R ug+rwX $(PRIVATE_DIR) && \ 1276 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \ 1277 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 ) 1278 1279 1280# Is a Windows SDK requested? If so, we need some definitions from here 1281# in order to find the Linux SDK used to create the Windows one. 1282ifneq ($(filter win_sdk,$(MAKECMDGOALS)),) 1283LINUX_SDK_NAME := $(sdk_name) 1284LINUX_SDK_DIR := $(sdk_dir) 1285include $(TOPDIR)development/build/tools/windows_sdk.mk 1286endif 1287 1288endif # !simulator 1289 1290# ----------------------------------------------------------------- 1291# Findbugs 1292INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml 1293INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html 1294$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES) 1295 @echo UnionBugs: $@ 1296 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \ 1297 > $@ 1298$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET) 1299 @echo ConvertXmlToText: $@ 1300 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \ 1301 $(INTERNAL_FINDBUGS_XML_TARGET) > $@ 1302 1303# ----------------------------------------------------------------- 1304# Findbugs 1305 1306# ----------------------------------------------------------------- 1307# These are some additional build tasks that need to be run. 1308include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk)) 1309