main.mk revision e2d27887bef08b9c3297e765d32397c1a8f7df87
1# Only use ANDROID_BUILD_SHELL to wrap around bash. 2# DO NOT use other shells such as zsh. 3ifdef ANDROID_BUILD_SHELL 4SHELL := $(ANDROID_BUILD_SHELL) 5else 6# Use bash, not whatever shell somebody has installed as /bin/sh 7# This is repeated in config.mk, since envsetup.sh runs that file 8# directly. 9SHELL := /bin/bash 10endif 11 12# this turns off the suffix rules built into make 13.SUFFIXES: 14 15# this turns off the RCS / SCCS implicit rules of GNU Make 16% : RCS/%,v 17% : RCS/% 18% : %,v 19% : s.% 20% : SCCS/s.% 21 22# If a rule fails, delete $@. 23.DELETE_ON_ERROR: 24 25# Figure out where we are. 26#TOP := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) 27#TOP := $(patsubst %/,%,$(TOP)) 28 29# TOPDIR is the normal variable you should use, because 30# if we are executing relative to the current directory 31# it can be "", whereas TOP must be "." which causes 32# pattern matching probles when make strips off the 33# trailing "./" from paths in various places. 34#ifeq ($(TOP),.) 35#TOPDIR := 36#else 37#TOPDIR := $(TOP)/ 38#endif 39 40# Check for broken versions of make. 41# (Allow any version under Cygwin since we don't actually build the platform there.) 42ifeq (,$(findstring CYGWIN,$(shell uname -sm))) 43ifneq (1,$(strip $(shell expr $(MAKE_VERSION) \>= 3.81))) 44$(warning ********************************************************************************) 45$(warning * You are using version $(MAKE_VERSION) of make.) 46$(warning * Android can only be built by versions 3.81 and higher.) 47$(warning * see https://source.android.com/source/download.html) 48$(warning ********************************************************************************) 49$(error stopping) 50endif 51endif 52 53# Absolute path of the present working direcotry. 54# This overrides the shell variable $PWD, which does not necessarily points to 55# the top of the source tree, for example when "make -C" is used in m/mm/mmm. 56PWD := $(shell pwd) 57 58TOP := . 59TOPDIR := 60 61BUILD_SYSTEM := $(TOPDIR)build/core 62 63# This is the default target. It must be the first declared target. 64.PHONY: droid 65DEFAULT_GOAL := droid 66$(DEFAULT_GOAL): 67 68# Used to force goals to build. Only use for conditionally defined goals. 69.PHONY: FORCE 70FORCE: 71 72# These goals don't need to collect and include Android.mks/CleanSpec.mks 73# in the source tree. 74dont_bother_goals := clean clobber dataclean installclean \ 75 help out \ 76 snod systemimage-nodeps \ 77 stnod systemtarball-nodeps \ 78 userdataimage-nodeps userdatatarball-nodeps \ 79 cacheimage-nodeps \ 80 vendorimage-nodeps \ 81 ramdisk-nodeps \ 82 bootimage-nodeps 83 84ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),) 85dont_bother := true 86endif 87 88# Targets that provide quick help on the build system. 89include $(BUILD_SYSTEM)/help.mk 90 91# Set up various standard variables based on configuration 92# and host information. 93include $(BUILD_SYSTEM)/config.mk 94 95# This allows us to force a clean build - included after the config.mk 96# environment setup is done, but before we generate any dependencies. This 97# file does the rm -rf inline so the deps which are all done below will 98# be generated correctly 99include $(BUILD_SYSTEM)/cleanbuild.mk 100 101# Include the google-specific config 102-include vendor/google/build/config.mk 103 104VERSION_CHECK_SEQUENCE_NUMBER := 3 105-include $(OUT_DIR)/versions_checked.mk 106ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED)) 107 108$(info Checking build tools versions...) 109 110ifneq ($(HOST_OS),windows) 111ifneq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc) 112# check for a case sensitive file system 113ifneq (a,$(shell mkdir -p $(OUT_DIR) ; \ 114 echo a > $(OUT_DIR)/casecheck.txt; \ 115 echo B > $(OUT_DIR)/CaseCheck.txt; \ 116 cat $(OUT_DIR)/casecheck.txt)) 117$(warning ************************************************************) 118$(warning You are building on a case-insensitive filesystem.) 119$(warning Please move your source tree to a case-sensitive filesystem.) 120$(warning ************************************************************) 121$(error Case-insensitive filesystems not supported) 122endif 123endif 124endif 125 126# Make sure that there are no spaces in the absolute path; the 127# build system can't deal with them. 128ifneq ($(words $(shell pwd)),1) 129$(warning ************************************************************) 130$(warning You are building in a directory whose absolute path contains) 131$(warning a space character:) 132$(warning $(space)) 133$(warning "$(shell pwd)") 134$(warning $(space)) 135$(warning Please move your source tree to a path that does not contain) 136$(warning any spaces.) 137$(warning ************************************************************) 138$(error Directory names containing spaces not supported) 139endif 140 141# Check for the current JDK. 142# 143# For Java 1.7, we require OpenJDK on linux and Oracle JDK on Mac OS. 144# For Java 1.6, we require Oracle for all host OSes. 145requires_openjdk := false 146ifneq ($(EXPERIMENTAL_USE_JAVA7),) 147ifeq ($(HOST_OS), linux) 148requires_openjdk := true 149endif 150endif 151 152ifeq ($(requires_openjdk), true) 153ifeq ($(shell java -version 2>&1 | grep -i openjdk),) 154$(info ************************************************************) 155$(info You are attempting to build with an unsupported JDK.) 156$(info $(space)) 157$(info This build requires OpenJDK, but you are using: 158$(info $(shell java -version 2>&1 | head -n 2).) 159$(info Please follow the machine setup instructions at) 160$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html) 161$(info ************************************************************) 162$(error stop) 163endif # java version is not OpenJdk 164else # if requires_openjdk 165ifneq ($(shell java -version 2>&1 | grep -i openjdk),) 166$(info ************************************************************) 167$(info You are attempting to build with an unsupported JDK.) 168$(info $(space)) 169$(info You use OpenJDK but only Sun/Oracle JDK is supported.) 170$(info Please follow the machine setup instructions at) 171$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html) 172$(info ************************************************************) 173$(error stop) 174endif # java version is not Sun Oracle JDK 175endif # if requires_openjdk 176 177# Check for the correct version of java, should be 1.7 if 178# EXPERIMENTAL_USE_JAVA7 is set, 1.6 otherwise. 179ifneq ($(EXPERIMENTAL_USE_JAVA7),) 180required_version := "1.7.x" 181java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.7[\. "$$]') 182javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.7[\. "$$]') 183else # if EXPERIMENTAL_USE_JAVA7 184required_version := "1.6.x" 185java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.6[\. "$$]') 186javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]') 187endif # if EXPERIMENTAL_USE_JAVA7 188 189ifeq ($(strip $(java_version)),) 190$(info ************************************************************) 191$(info You are attempting to build with the incorrect version) 192$(info of java.) 193$(info $(space)) 194$(info Your version is: $(shell java -version 2>&1 | head -n 1).) 195$(info The required version is: $(required_version)) 196$(info $(space)) 197$(info Please follow the machine setup instructions at) 198$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html) 199$(info ************************************************************) 200$(error stop) 201endif 202 203# Check for the correct version of javac 204ifeq ($(strip $(javac_version)),) 205$(info ************************************************************) 206$(info You are attempting to build with the incorrect version) 207$(info of javac.) 208$(info $(space)) 209$(info Your version is: $(shell javac -version 2>&1 | head -n 1).) 210$(info The required version is: $(required_java_version)) 211$(info $(space)) 212$(info Please follow the machine setup instructions at) 213$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html) 214$(info ************************************************************) 215$(error stop) 216endif 217 218ifndef BUILD_EMULATOR 219ifeq (darwin,$(HOST_OS)) 220GCC_REALPATH = $(realpath $(shell which $(HOST_CC))) 221ifneq ($(findstring llvm-gcc,$(GCC_REALPATH)),) 222 # Using LLVM GCC results in a non functional emulator due to it 223 # not honouring global register variables 224 $(warning ****************************************) 225 $(warning * gcc is linked to llvm-gcc which will *) 226 $(warning * not create a useable emulator. *) 227 $(warning ****************************************) 228 BUILD_EMULATOR := false 229else 230 BUILD_EMULATOR := true 231endif 232else # HOST_OS is not darwin 233 BUILD_EMULATOR := true 234endif # HOST_OS is darwin 235endif 236 237$(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \ 238 > $(OUT_DIR)/versions_checked.mk) 239$(shell echo 'BUILD_EMULATOR ?= $(BUILD_EMULATOR)' \ 240 >> $(OUT_DIR)/versions_checked.mk) 241endif 242 243# These are the modifier targets that don't do anything themselves, but 244# change the behavior of the build. 245# (must be defined before including definitions.make) 246INTERNAL_MODIFIER_TARGETS := showcommands all incrementaljavac 247 248.PHONY: incrementaljavac 249incrementaljavac: ; 250 251# WARNING: 252# ENABLE_INCREMENTALJAVAC should NOT be enabled by default, because change of 253# a Java source file won't trigger rebuild of its dependent Java files. 254# You can only enable it by adding "incrementaljavac" to your make command line. 255# You are responsible for the correctness of the incremental build. 256# This may decrease incremental build time dramatically for large Java libraries, 257# such as core.jar, framework.jar, etc. 258ENABLE_INCREMENTALJAVAC := 259ifneq (,$(filter incrementaljavac, $(MAKECMDGOALS))) 260ENABLE_INCREMENTALJAVAC := true 261MAKECMDGOALS := $(filter-out incrementaljavac, $(MAKECMDGOALS)) 262endif 263 264# EMMA_INSTRUMENT_STATIC merges the static emma library to each emma-enabled module. 265ifeq (true,$(EMMA_INSTRUMENT_STATIC)) 266EMMA_INSTRUMENT := true 267endif 268 269# Bring in standard build system definitions. 270include $(BUILD_SYSTEM)/definitions.mk 271 272# Bring in dex_preopt.mk 273include $(BUILD_SYSTEM)/dex_preopt.mk 274 275ifneq ($(filter user userdebug eng,$(MAKECMDGOALS)),) 276$(info ***************************************************************) 277$(info ***************************************************************) 278$(info Do not pass '$(filter user userdebug eng,$(MAKECMDGOALS))' on \ 279 the make command line.) 280$(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or) 281$(info choosecombo.) 282$(info ***************************************************************) 283$(info ***************************************************************) 284$(error stopping) 285endif 286 287ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),) 288$(info ***************************************************************) 289$(info ***************************************************************) 290$(info Invalid variant: $(TARGET_BUILD_VARIANT) 291$(info Valid values are: $(INTERNAL_VALID_VARIANTS) 292$(info ***************************************************************) 293$(info ***************************************************************) 294$(error stopping) 295endif 296 297# ----------------------------------------------------------------- 298# Variable to check java support level inside PDK build. 299# Not necessary if the components is not in PDK. 300# not defined : not supported 301# "sdk" : sdk API only 302# "platform" : platform API supproted 303TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform 304 305# ----------------------------------------------------------------- 306# The pdk (Platform Development Kit) build 307include build/core/pdk_config.mk 308 309# ----------------------------------------------------------------- 310### 311### In this section we set up the things that are different 312### between the build variants 313### 314 315is_sdk_build := 316 317ifneq ($(filter sdk win_sdk sdk_addon,$(MAKECMDGOALS)),) 318is_sdk_build := true 319endif 320 321## user/userdebug ## 322 323user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT)) 324enable_target_debugging := true 325tags_to_install := 326ifneq (,$(user_variant)) 327 # Target is secure in user builds. 328 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1 329 330 ifeq ($(user_variant),userdebug) 331 # Pick up some extra useful tools 332 tags_to_install += debug 333 334 # Enable Dalvik lock contention logging for userdebug builds. 335 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500 336 else 337 # Disable debugging in plain user builds. 338 enable_target_debugging := 339 endif 340 341 # Turn on Dalvik preoptimization for user builds, but only if not 342 # explicitly disabled and the build is running on Linux (since host 343 # Dalvik isn't built for non-Linux hosts). 344 ifneq (true,$(DISABLE_DEXPREOPT)) 345 ifeq ($(user_variant),user) 346 ifeq ($(HOST_OS),linux) 347 WITH_DEXPREOPT := true 348 endif 349 endif 350 endif 351 352 # Disallow mock locations by default for user builds 353 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0 354 355else # !user_variant 356 # Turn on checkjni for non-user builds. 357 ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1 358 # Set device insecure for non-user builds. 359 ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0 360 # Allow mock locations by default for non user builds 361 ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1 362endif # !user_variant 363 364ifeq (true,$(strip $(enable_target_debugging))) 365 # Target is more debuggable and adbd is on by default 366 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 367 # Include the debugging/testing OTA keys in this build. 368 INCLUDE_TEST_OTA_KEYS := true 369else # !enable_target_debugging 370 # Target is less debuggable and adbd is off by default 371 ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0 372endif # !enable_target_debugging 373 374## eng ## 375 376ifeq ($(TARGET_BUILD_VARIANT),eng) 377tags_to_install := debug eng 378ifneq ($(filter ro.setupwizard.mode=ENABLED, $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))),) 379 # Don't require the setup wizard on eng builds 380 ADDITIONAL_BUILD_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\ 381 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))) \ 382 ro.setupwizard.mode=OPTIONAL 383endif 384endif 385 386## sdk ## 387 388ifdef is_sdk_build 389 390# Detect if we want to build a repository for the SDK 391sdk_repo_goal := $(strip $(filter sdk_repo,$(MAKECMDGOALS))) 392MAKECMDGOALS := $(strip $(filter-out sdk_repo,$(MAKECMDGOALS))) 393 394ifneq ($(words $(filter-out $(INTERNAL_MODIFIER_TARGETS) checkbuild,$(MAKECMDGOALS))),1) 395$(error The 'sdk' target may not be specified with any other targets) 396endif 397 398# TODO: this should be eng I think. Since the sdk is built from the eng 399# variant. 400tags_to_install := debug eng 401ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true 402ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes 403else # !sdk 404endif 405 406BUILD_WITHOUT_PV := true 407 408## precise GC ## 409 410ifneq ($(filter dalvik.gc.type-precise,$(PRODUCT_TAGS)),) 411 # Enabling type-precise GC results in larger optimized DEX files. The 412 # additional storage requirements for ".odex" files can cause /system 413 # to overflow on some devices, so this is configured separately for 414 # each product. 415 ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dexopt-flags=m=y 416endif 417 418ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android 419 420# enable vm tracing in files for now to help track 421# the cause of ANRs in the content process 422ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.stack-trace-file=/data/anr/traces.txt 423 424# ------------------------------------------------------------ 425# Define a function that, given a list of module tags, returns 426# non-empty if that module should be installed in /system. 427 428# For most goals, anything not tagged with the "tests" tag should 429# be installed in /system. 430define should-install-to-system 431$(if $(filter tests,$(1)),,true) 432endef 433 434ifdef is_sdk_build 435# For the sdk goal, anything with the "samples" tag should be 436# installed in /data even if that module also has "eng"/"debug"/"user". 437define should-install-to-system 438$(if $(filter samples tests,$(1)),,true) 439endef 440endif 441 442 443# If they only used the modifier goals (showcommands, etc), we'll actually 444# build the default target. 445ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),) 446.PHONY: $(INTERNAL_MODIFIER_TARGETS) 447$(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL) 448endif 449 450# Bring in all modules that need to be built. 451ifeq ($(HOST_OS)-$(HOST_ARCH),darwin-ppc) 452SDK_ONLY := true 453$(info Building the SDK under darwin-ppc is actually obsolete and unsupported.) 454$(error stop) 455endif 456 457ifeq ($(HOST_OS),windows) 458SDK_ONLY := true 459endif 460 461ifeq ($(SDK_ONLY),true) 462include $(TOPDIR)sdk/build/windows_sdk_whitelist.mk 463include $(TOPDIR)development/build/windows_sdk_whitelist.mk 464 465# Exclude tools/acp when cross-compiling windows under linux 466ifeq ($(findstring Linux,$(UNAME)),) 467subdirs += build/tools/acp 468endif 469 470else # !SDK_ONLY 471# 472# Typical build; include any Android.mk files we can find. 473# 474subdirs := $(TOP) 475 476FULL_BUILD := true 477 478endif # !SDK_ONLY 479 480# Before we go and include all of the module makefiles, stash away 481# the PRODUCT_* values so that later we can verify they are not modified. 482stash_product_vars:=true 483ifeq ($(stash_product_vars),true) 484 $(call stash-product-vars, __STASHED) 485endif 486 487ifneq ($(ONE_SHOT_MAKEFILE),) 488# We've probably been invoked by the "mm" shell function 489# with a subdirectory's makefile. 490include $(ONE_SHOT_MAKEFILE) 491# Change CUSTOM_MODULES to include only modules that were 492# defined by this makefile; this will install all of those 493# modules as a side-effect. Do this after including ONE_SHOT_MAKEFILE 494# so that the modules will be installed in the same place they 495# would have been with a normal make. 496CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS))) 497FULL_BUILD := 498# Stub out the notice targets, which probably aren't defined 499# when using ONE_SHOT_MAKEFILE. 500NOTICE-HOST-%: ; 501NOTICE-TARGET-%: ; 502 503# A helper goal printing out install paths 504.PHONY: GET-INSTALL-PATH 505GET-INSTALL-PATH: 506 @$(foreach m, $(ALL_MODULES), $(if $(ALL_MODULES.$(m).INSTALLED), \ 507 echo 'INSTALL-PATH: $(m) $(ALL_MODULES.$(m).INSTALLED)';)) 508 509else # ONE_SHOT_MAKEFILE 510 511ifneq ($(dont_bother),true) 512# 513# Include all of the makefiles in the system 514# 515 516# Can't use first-makefiles-under here because 517# --mindepth=2 makes the prunes not work. 518subdir_makefiles := \ 519 $(shell build/tools/findleaves.py --prune=$(OUT_DIR) --prune=.repo --prune=.git $(subdirs) Android.mk) 520 521$(foreach mk, $(subdir_makefiles), $(info including $(mk) ...)$(eval include $(mk))) 522 523endif # dont_bother 524 525endif # ONE_SHOT_MAKEFILE 526 527# Now with all Android.mks loaded we can do post cleaning steps. 528include $(BUILD_SYSTEM)/post_clean.mk 529 530ifeq ($(stash_product_vars),true) 531 $(call assert-product-vars, __STASHED) 532endif 533 534include $(BUILD_SYSTEM)/legacy_prebuilts.mk 535ifneq ($(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),) 536 $(warning *** Some files have been added to ALL_PREBUILT.) 537 $(warning *) 538 $(warning * ALL_PREBUILT is a deprecated mechanism that) 539 $(warning * should not be used for new files.) 540 $(warning * As an alternative, use PRODUCT_COPY_FILES in) 541 $(warning * the appropriate product definition.) 542 $(warning * build/target/product/core.mk is the product) 543 $(warning * definition used in all products.) 544 $(warning *) 545 $(foreach bad_prebuilt,$(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),$(warning * unexpected $(bad_prebuilt) in ALL_PREBUILT)) 546 $(warning *) 547 $(error ALL_PREBUILT contains unexpected files) 548endif 549 550# ------------------------------------------------------------------- 551# All module makefiles have been included at this point. 552# ------------------------------------------------------------------- 553 554 555# ------------------------------------------------------------------- 556# Fix up CUSTOM_MODULES to refer to installed files rather than 557# just bare module names. Leave unknown modules alone in case 558# they're actually full paths to a particular file. 559known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES)) 560unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES)) 561CUSTOM_MODULES := \ 562 $(call module-installed-files,$(known_custom_modules)) \ 563 $(unknown_custom_modules) 564 565# ------------------------------------------------------------------- 566# Define dependencies for modules that require other modules. 567# This can only happen now, after we've read in all module makefiles. 568# 569# TODO: deal with the fact that a bare module name isn't 570# unambiguous enough. Maybe declare short targets like 571# APPS:Quake or HOST:SHARED_LIBRARIES:libutils. 572# BUG: the system image won't know to depend on modules that are 573# brought in as requirements of other modules. 574define add-required-deps 575$(1): | $(2) 576endef 577$(foreach m,$(ALL_MODULES), \ 578 $(eval r := $(ALL_MODULES.$(m).REQUIRED)) \ 579 $(if $(r), \ 580 $(eval r := $(call module-installed-files,$(r))) \ 581 $(eval t_m := $(filter $(TARGET_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \ 582 $(eval h_m := $(filter $(HOST_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \ 583 $(eval t_r := $(filter $(TARGET_OUT_ROOT)/%, $(r))) \ 584 $(eval h_r := $(filter $(HOST_OUT_ROOT)/%, $(r))) \ 585 $(if $(t_m), $(eval $(call add-required-deps, $(t_m),$(t_r)))) \ 586 $(if $(h_m), $(eval $(call add-required-deps, $(h_m),$(h_r)))) \ 587 ) \ 588 ) 589 590t_m := 591h_m := 592t_r := 593h_r := 594 595# Resolve the dependencies on shared libraries. 596$(foreach m,$(TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES), \ 597 $(eval p := $(subst :,$(space),$(m))) \ 598 $(eval r := $(filter $(TARGET_OUT_ROOT)/%,$(call module-installed-files,\ 599 $(subst $(comma),$(space),$(lastword $(p)))))) \ 600 $(eval $(call add-required-deps,$(word 2,$(p)),$(r)))) 601$(foreach m,$(HOST_DEPENDENCIES_ON_SHARED_LIBRARIES), \ 602 $(eval p := $(subst :,$(space),$(m))) \ 603 $(eval r := $(filter $(HOST_OUT_ROOT)/%,$(call module-installed-files,\ 604 $(subst $(comma),$(space),$(lastword $(p)))))) \ 605 $(eval $(call add-required-deps,$(word 2,$(p)),$(r)))) 606 607m := 608r := 609p := 610add-required-deps := 611 612# ------------------------------------------------------------------- 613# Figure out our module sets. 614# 615# Of the modules defined by the component makefiles, 616# determine what we actually want to build. 617 618ifdef FULL_BUILD 619 # The base list of modules to build for this product is specified 620 # by the appropriate product definition file, which was included 621 # by product_config.make. 622 product_MODULES := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) 623 # Filter out the overridden packages before doing expansion 624 product_MODULES := $(filter-out $(foreach p, $(product_MODULES), \ 625 $(PACKAGES.$(p).OVERRIDES)), $(product_MODULES)) 626 $(call expand-required-modules,product_MODULES,$(product_MODULES)) 627 product_FILES := $(call module-installed-files, $(product_MODULES)) 628 ifeq (0,1) 629 $(info product_FILES for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):) 630 $(foreach p,$(product_FILES),$(info : $(p))) 631 $(error done) 632 endif 633else 634 # We're not doing a full build, and are probably only including 635 # a subset of the module makefiles. Don't try to build any modules 636 # requested by the product, because we probably won't have rules 637 # to build them. 638 product_FILES := 639endif 640 641eng_MODULES := $(sort \ 642 $(call get-tagged-modules,eng) \ 643 $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG)) \ 644 ) 645debug_MODULES := $(sort \ 646 $(call get-tagged-modules,debug) \ 647 $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG)) \ 648 ) 649tests_MODULES := $(sort \ 650 $(call get-tagged-modules,tests) \ 651 $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS)) \ 652 ) 653 654# TODO: Remove the 3 places in the tree that use ALL_DEFAULT_INSTALLED_MODULES 655# and get rid of it from this list. 656modules_to_install := $(sort \ 657 $(ALL_DEFAULT_INSTALLED_MODULES) \ 658 $(product_FILES) \ 659 $(foreach tag,$(tags_to_install),$($(tag)_MODULES)) \ 660 $(CUSTOM_MODULES) \ 661 ) 662 663# Some packages may override others using LOCAL_OVERRIDES_PACKAGES. 664# Filter out (do not install) any overridden packages. 665overridden_packages := $(call get-package-overrides,$(modules_to_install)) 666ifdef overridden_packages 667# old_modules_to_install := $(modules_to_install) 668 modules_to_install := \ 669 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \ 670 $(modules_to_install)) 671endif 672#$(error filtered out 673# $(filter-out $(modules_to_install),$(old_modules_to_install))) 674 675# Don't include any GNU targets in the SDK. It's ok (and necessary) 676# to build the host tools, but nothing that's going to be installed 677# on the target (including static libraries). 678ifdef is_sdk_build 679 target_gnu_MODULES := \ 680 $(filter \ 681 $(TARGET_OUT_INTERMEDIATES)/% \ 682 $(TARGET_OUT)/% \ 683 $(TARGET_OUT_DATA)/%, \ 684 $(sort $(call get-tagged-modules,gnu))) 685 $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d))) 686 modules_to_install := \ 687 $(filter-out $(target_gnu_MODULES),$(modules_to_install)) 688 689 # Ensure every module listed in PRODUCT_PACKAGES* gets something installed 690 # TODO: Should we do this for all builds and not just the sdk? 691 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), \ 692 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\ 693 $(error $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES has nothing to install!))) 694 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG), \ 695 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\ 696 $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_DEBUG has nothing to install!))) 697 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG), \ 698 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\ 699 $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_ENG has nothing to install!))) 700 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS), \ 701 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\ 702 $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_TESTS has nothing to install!))) 703endif 704 705# build/core/Makefile contains extra stuff that we don't want to pollute this 706# top-level makefile with. It expects that ALL_DEFAULT_INSTALLED_MODULES 707# contains everything that's built during the current make, but it also further 708# extends ALL_DEFAULT_INSTALLED_MODULES. 709ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install) 710include $(BUILD_SYSTEM)/Makefile 711modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES)) 712ALL_DEFAULT_INSTALLED_MODULES := 713 714 715# These are additional goals that we build, in order to make sure that there 716# is as little code as possible in the tree that doesn't build. 717modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED)) 718 719# If you would like to build all goals, and not skip any intermediate 720# steps, you can pass the "all" modifier goal on the commandline. 721ifneq ($(filter all,$(MAKECMDGOALS)),) 722modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT)) 723endif 724 725# for easier debugging 726modules_to_check := $(sort $(modules_to_check)) 727#$(error modules_to_check $(modules_to_check)) 728 729# ------------------------------------------------------------------- 730# This is used to to get the ordering right, you can also use these, 731# but they're considered undocumented, so don't complain if their 732# behavior changes. 733.PHONY: prebuilt 734prebuilt: $(ALL_PREBUILT) 735 736# An internal target that depends on all copied headers 737# (see copy_headers.make). Other targets that need the 738# headers to be copied first can depend on this target. 739.PHONY: all_copied_headers 740all_copied_headers: ; 741 742$(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers 743 744# All the droid stuff, in directories 745.PHONY: files 746files: prebuilt \ 747 $(modules_to_install) \ 748 $(INSTALLED_ANDROID_INFO_TXT_TARGET) 749 750# ------------------------------------------------------------------- 751 752.PHONY: checkbuild 753checkbuild: $(modules_to_check) 754ifeq (true,$(ANDROID_BUILD_EVERYTHING_BY_DEFAULT)$(filter $(MAKECMDGOALS),checkbuild)) 755droid: checkbuild 756else 757# ANDROID_BUILD_EVERYTHING_BY_DEFAULT not set, or checkbuild is one of the cmd goals. 758checkbuild: droid 759endif 760 761.PHONY: ramdisk 762ramdisk: $(INSTALLED_RAMDISK_TARGET) 763 764.PHONY: factory_ramdisk 765factory_ramdisk: $(INSTALLED_FACTORY_RAMDISK_TARGET) 766 767.PHONY: factory_bundle 768factory_bundle: $(INSTALLED_FACTORY_BUNDLE_TARGET) 769 770.PHONY: systemtarball 771systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET) 772 773.PHONY: boottarball 774boottarball: $(INSTALLED_BOOTTARBALL_TARGET) 775 776.PHONY: userdataimage 777userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET) 778 779ifneq (,$(filter userdataimage, $(MAKECMDGOALS))) 780$(call dist-for-goals, userdataimage, $(BUILT_USERDATAIMAGE_TARGET)) 781endif 782 783.PHONY: userdatatarball 784userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET) 785 786.PHONY: cacheimage 787cacheimage: $(INSTALLED_CACHEIMAGE_TARGET) 788 789.PHONY: vendorimage 790vendorimage: $(INSTALLED_VENDORIMAGE_TARGET) 791 792.PHONY: bootimage 793bootimage: $(INSTALLED_BOOTIMAGE_TARGET) 794 795# phony target that include any targets in $(ALL_MODULES) 796.PHONY: all_modules 797ifndef BUILD_MODULES_IN_PATHS 798all_modules: $(ALL_MODULES) 799else 800# BUILD_MODULES_IN_PATHS is a list of paths relative to the top of the tree 801module_path_patterns := $(foreach p, $(BUILD_MODULES_IN_PATHS),\ 802 $(if $(filter %/,$(p)),$(p)%,$(p)/%)) 803my_all_modules := $(sort $(foreach m, $(ALL_MODULES),$(if $(filter\ 804 $(module_path_patterns), $(addsuffix /,$(ALL_MODULES.$(m).PATH))),$(m)))) 805all_modules: $(my_all_modules) 806endif 807 808 809# Build files and then package it into the rom formats 810.PHONY: droidcore 811droidcore: files \ 812 systemimage \ 813 $(INSTALLED_BOOTIMAGE_TARGET) \ 814 $(INSTALLED_RECOVERYIMAGE_TARGET) \ 815 $(INSTALLED_USERDATAIMAGE_TARGET) \ 816 $(INSTALLED_CACHEIMAGE_TARGET) \ 817 $(INSTALLED_VENDORIMAGE_TARGET) \ 818 $(INSTALLED_FILES_FILE) 819 820# dist_files only for putting your library into the dist directory with a full build. 821.PHONY: dist_files 822 823ifneq ($(TARGET_BUILD_APPS),) 824 # If this build is just for apps, only build apps and not the full system by default. 825 826 unbundled_build_modules := 827 ifneq ($(filter all,$(TARGET_BUILD_APPS)),) 828 # If they used the magic goal "all" then build all apps in the source tree. 829 unbundled_build_modules := $(foreach m,$(sort $(ALL_MODULES)),$(if $(filter APPS,$(ALL_MODULES.$(m).CLASS)),$(m))) 830 else 831 unbundled_build_modules := $(TARGET_BUILD_APPS) 832 endif 833 834 # Dist the installed files if they exist. 835 apps_only_installed_files := $(foreach m,$(unbundled_build_modules),$(ALL_MODULES.$(m).INSTALLED)) 836 $(call dist-for-goals,apps_only, $(apps_only_installed_files)) 837 # For uninstallable modules such as static Java library, we have to dist the built file, 838 # as <module_name>.<suffix> 839 apps_only_dist_built_files := $(foreach m,$(unbundled_build_modules),$(if $(ALL_MODULES.$(m).INSTALLED),,\ 840 $(if $(ALL_MODULES.$(m).BUILT),$(ALL_MODULES.$(m).BUILT):$(m)$(suffix $(ALL_MODULES.$(m).BUILT))))) 841 $(call dist-for-goals,apps_only, $(apps_only_dist_built_files)) 842 843 ifeq ($(EMMA_INSTRUMENT),true) 844 $(EMMA_META_ZIP) : $(apps_only_installed_files) 845 846 $(call dist-for-goals,apps_only, $(EMMA_META_ZIP)) 847 endif 848 849 $(PROGUARD_DICT_ZIP) : $(apps_only_installed_files) 850 $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP)) 851 852.PHONY: apps_only 853apps_only: $(unbundled_build_modules) 854 855droid: apps_only 856 857# Combine the NOTICE files for a apps_only build 858$(eval $(call combine-notice-files, \ 859 $(target_notice_file_txt), \ 860 $(target_notice_file_html), \ 861 "Notices for files for apps:", \ 862 $(TARGET_OUT_NOTICE_FILES), \ 863 $(apps_only_installed_files))) 864 865 866else # TARGET_BUILD_APPS 867 $(call dist-for-goals, droidcore, \ 868 $(INTERNAL_UPDATE_PACKAGE_TARGET) \ 869 $(INTERNAL_OTA_PACKAGE_TARGET) \ 870 $(SYMBOLS_ZIP) \ 871 $(INSTALLED_FILES_FILE) \ 872 $(INSTALLED_BUILD_PROP_TARGET) \ 873 $(BUILT_TARGET_FILES_PACKAGE) \ 874 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 875 $(INSTALLED_RAMDISK_TARGET) \ 876 $(INSTALLED_FACTORY_RAMDISK_TARGET) \ 877 $(INSTALLED_FACTORY_BUNDLE_TARGET) \ 878 ) 879 880 # Put a copy of the radio/bootloader files in the dist dir. 881 $(foreach f,$(INSTALLED_RADIOIMAGE_TARGET), \ 882 $(call dist-for-goals, droidcore, $(f))) 883 884 ifneq ($(TARGET_BUILD_PDK),true) 885 $(call dist-for-goals, droidcore, \ 886 $(APPS_ZIP) \ 887 $(INTERNAL_EMULATOR_PACKAGE_TARGET) \ 888 $(PACKAGE_STATS_FILE) \ 889 ) 890 endif 891 892 ifeq ($(EMMA_INSTRUMENT),true) 893 $(EMMA_META_ZIP) : $(INSTALLED_SYSTEMIMAGE) 894 895 $(call dist-for-goals, dist_files, $(EMMA_META_ZIP)) 896 endif 897 898# Building a full system-- the default is to build droidcore 899droid: droidcore dist_files 900 901endif # TARGET_BUILD_APPS 902 903.PHONY: docs 904docs: $(ALL_DOCS) 905 906.PHONY: sdk 907ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET) 908sdk: $(ALL_SDK_TARGETS) 909$(call dist-for-goals,sdk win_sdk, \ 910 $(ALL_SDK_TARGETS) \ 911 $(SYMBOLS_ZIP) \ 912 $(INSTALLED_BUILD_PROP_TARGET) \ 913) 914 915# umbrella targets to assit engineers in verifying builds 916.PHONY: java native target host java-host java-target native-host native-target \ 917 java-host-tests java-target-tests native-host-tests native-target-tests \ 918 java-tests native-tests host-tests target-tests 919# some synonyms 920.PHONY: host-java target-java host-native target-native \ 921 target-java-tests target-native-tests 922host-java : java-host 923target-java : java-target 924host-native : native-host 925target-native : native-target 926target-java-tests : java-target-tests 927target-native-tests : native-target-tests 928 929 930.PHONY: lintall 931 932.PHONY: samplecode 933sample_MODULES := $(sort $(call get-tagged-modules,samples)) 934sample_APKS_DEST_PATH := $(TARGET_COMMON_OUT_ROOT)/samples 935sample_APKS_COLLECTION := \ 936 $(foreach module,$(sample_MODULES),$(sample_APKS_DEST_PATH)/$(notdir $(module))) 937$(foreach module,$(sample_MODULES),$(eval $(call \ 938 copy-one-file,$(module),$(sample_APKS_DEST_PATH)/$(notdir $(module))))) 939sample_ADDITIONAL_INSTALLED := \ 940 $(filter-out $(modules_to_install) $(modules_to_check) $(ALL_PREBUILT),$(sample_MODULES)) 941samplecode: $(sample_APKS_COLLECTION) 942 @echo "Collect sample code apks: $^" 943 # remove apks that are not intended to be installed. 944 rm -f $(sample_ADDITIONAL_INSTALLED) 945 946.PHONY: findbugs 947findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET) 948 949.PHONY: clean 950clean: 951 @rm -rf $(OUT_DIR) 952 @echo "Entire build directory removed." 953 954.PHONY: clobber 955clobber: clean 956 957# The rules for dataclean and installclean are defined in cleanbuild.mk. 958 959#xxx scrape this from ALL_MODULE_NAME_TAGS 960.PHONY: modules 961modules: 962 @echo "Available sub-modules:" 963 @echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \ 964 tr -s ' ' '\n' | sort -u | $(COLUMN) 965 966.PHONY: showcommands 967showcommands: 968 @echo >/dev/null 969 970.PHONY: nothing 971nothing: 972 @echo Successfully read the makefiles. 973