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