main.mk revision 4d2cc665eafb16ffe20b4ec8b2b2fc3a55f6f6ae
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)))) 606ifdef TARGET_2ND_ARCH 607$(foreach m,$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES), \ 608 $(eval p := $(subst :,$(space),$(m))) \ 609 $(eval r := $(filter $(TARGET_OUT_ROOT)/%,$(call module-installed-files,\ 610 $(addsuffix $(TARGET_2ND_ARCH_MODULE_SUFFIX), \ 611 $(subst $(comma),$(space),$(lastword $(p))))))) \ 612 $(eval $(call add-required-deps,$(word 2,$(p)),$(r)))) 613endif 614 615m := 616r := 617p := 618add-required-deps := 619 620# ------------------------------------------------------------------- 621# Figure out our module sets. 622# 623# Of the modules defined by the component makefiles, 624# determine what we actually want to build. 625 626ifdef FULL_BUILD 627 # The base list of modules to build for this product is specified 628 # by the appropriate product definition file, which was included 629 # by product_config.make. 630 product_MODULES := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) 631 # Filter out the overridden packages before doing expansion 632 product_MODULES := $(filter-out $(foreach p, $(product_MODULES), \ 633 $(PACKAGES.$(p).OVERRIDES)), $(product_MODULES)) 634 $(call expand-required-modules,product_MODULES,$(product_MODULES)) 635 product_FILES := $(call module-installed-files, $(product_MODULES)) 636 ifeq (0,1) 637 $(info product_FILES for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):) 638 $(foreach p,$(product_FILES),$(info : $(p))) 639 $(error done) 640 endif 641else 642 # We're not doing a full build, and are probably only including 643 # a subset of the module makefiles. Don't try to build any modules 644 # requested by the product, because we probably won't have rules 645 # to build them. 646 product_FILES := 647endif 648 649eng_MODULES := $(sort \ 650 $(call get-tagged-modules,eng) \ 651 $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG)) \ 652 ) 653debug_MODULES := $(sort \ 654 $(call get-tagged-modules,debug) \ 655 $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG)) \ 656 ) 657tests_MODULES := $(sort \ 658 $(call get-tagged-modules,tests) \ 659 $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS)) \ 660 ) 661 662# TODO: Remove the 3 places in the tree that use ALL_DEFAULT_INSTALLED_MODULES 663# and get rid of it from this list. 664modules_to_install := $(sort \ 665 $(ALL_DEFAULT_INSTALLED_MODULES) \ 666 $(product_FILES) \ 667 $(foreach tag,$(tags_to_install),$($(tag)_MODULES)) \ 668 $(CUSTOM_MODULES) \ 669 ) 670 671# Some packages may override others using LOCAL_OVERRIDES_PACKAGES. 672# Filter out (do not install) any overridden packages. 673overridden_packages := $(call get-package-overrides,$(modules_to_install)) 674ifdef overridden_packages 675# old_modules_to_install := $(modules_to_install) 676 modules_to_install := \ 677 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \ 678 $(modules_to_install)) 679endif 680#$(error filtered out 681# $(filter-out $(modules_to_install),$(old_modules_to_install))) 682 683# Don't include any GNU targets in the SDK. It's ok (and necessary) 684# to build the host tools, but nothing that's going to be installed 685# on the target (including static libraries). 686ifdef is_sdk_build 687 target_gnu_MODULES := \ 688 $(filter \ 689 $(TARGET_OUT_INTERMEDIATES)/% \ 690 $(TARGET_OUT)/% \ 691 $(TARGET_OUT_DATA)/%, \ 692 $(sort $(call get-tagged-modules,gnu))) 693 $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d))) 694 modules_to_install := \ 695 $(filter-out $(target_gnu_MODULES),$(modules_to_install)) 696 697 # Ensure every module listed in PRODUCT_PACKAGES* gets something installed 698 # TODO: Should we do this for all builds and not just the sdk? 699 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), \ 700 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\ 701 $(error $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES has nothing to install!))) 702 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG), \ 703 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\ 704 $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_DEBUG has nothing to install!))) 705 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG), \ 706 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\ 707 $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_ENG has nothing to install!))) 708 $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS), \ 709 $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\ 710 $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_TESTS has nothing to install!))) 711endif 712 713# build/core/Makefile contains extra stuff that we don't want to pollute this 714# top-level makefile with. It expects that ALL_DEFAULT_INSTALLED_MODULES 715# contains everything that's built during the current make, but it also further 716# extends ALL_DEFAULT_INSTALLED_MODULES. 717ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install) 718include $(BUILD_SYSTEM)/Makefile 719modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES)) 720ALL_DEFAULT_INSTALLED_MODULES := 721 722 723# These are additional goals that we build, in order to make sure that there 724# is as little code as possible in the tree that doesn't build. 725modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED)) 726 727# If you would like to build all goals, and not skip any intermediate 728# steps, you can pass the "all" modifier goal on the commandline. 729ifneq ($(filter all,$(MAKECMDGOALS)),) 730modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT)) 731endif 732 733# for easier debugging 734modules_to_check := $(sort $(modules_to_check)) 735#$(error modules_to_check $(modules_to_check)) 736 737# ------------------------------------------------------------------- 738# This is used to to get the ordering right, you can also use these, 739# but they're considered undocumented, so don't complain if their 740# behavior changes. 741.PHONY: prebuilt 742prebuilt: $(ALL_PREBUILT) 743 744# An internal target that depends on all copied headers 745# (see copy_headers.make). Other targets that need the 746# headers to be copied first can depend on this target. 747.PHONY: all_copied_headers 748all_copied_headers: ; 749 750$(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers 751 752# All the droid stuff, in directories 753.PHONY: files 754files: prebuilt \ 755 $(modules_to_install) \ 756 $(INSTALLED_ANDROID_INFO_TXT_TARGET) 757 758# ------------------------------------------------------------------- 759 760.PHONY: checkbuild 761checkbuild: $(modules_to_check) 762ifeq (true,$(ANDROID_BUILD_EVERYTHING_BY_DEFAULT)$(filter $(MAKECMDGOALS),checkbuild)) 763droid: checkbuild 764else 765# ANDROID_BUILD_EVERYTHING_BY_DEFAULT not set, or checkbuild is one of the cmd goals. 766checkbuild: droid 767endif 768 769.PHONY: ramdisk 770ramdisk: $(INSTALLED_RAMDISK_TARGET) 771 772.PHONY: factory_ramdisk 773factory_ramdisk: $(INSTALLED_FACTORY_RAMDISK_TARGET) 774 775.PHONY: factory_bundle 776factory_bundle: $(INSTALLED_FACTORY_BUNDLE_TARGET) 777 778.PHONY: systemtarball 779systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET) 780 781.PHONY: boottarball 782boottarball: $(INSTALLED_BOOTTARBALL_TARGET) 783 784.PHONY: userdataimage 785userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET) 786 787ifneq (,$(filter userdataimage, $(MAKECMDGOALS))) 788$(call dist-for-goals, userdataimage, $(BUILT_USERDATAIMAGE_TARGET)) 789endif 790 791.PHONY: userdatatarball 792userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET) 793 794.PHONY: cacheimage 795cacheimage: $(INSTALLED_CACHEIMAGE_TARGET) 796 797.PHONY: vendorimage 798vendorimage: $(INSTALLED_VENDORIMAGE_TARGET) 799 800.PHONY: bootimage 801bootimage: $(INSTALLED_BOOTIMAGE_TARGET) 802 803# phony target that include any targets in $(ALL_MODULES) 804.PHONY: all_modules 805ifndef BUILD_MODULES_IN_PATHS 806all_modules: $(ALL_MODULES) 807else 808# BUILD_MODULES_IN_PATHS is a list of paths relative to the top of the tree 809module_path_patterns := $(foreach p, $(BUILD_MODULES_IN_PATHS),\ 810 $(if $(filter %/,$(p)),$(p)%,$(p)/%)) 811my_all_modules := $(sort $(foreach m, $(ALL_MODULES),$(if $(filter\ 812 $(module_path_patterns), $(addsuffix /,$(ALL_MODULES.$(m).PATH))),$(m)))) 813all_modules: $(my_all_modules) 814endif 815 816 817# Build files and then package it into the rom formats 818.PHONY: droidcore 819droidcore: files \ 820 systemimage \ 821 $(INSTALLED_BOOTIMAGE_TARGET) \ 822 $(INSTALLED_RECOVERYIMAGE_TARGET) \ 823 $(INSTALLED_USERDATAIMAGE_TARGET) \ 824 $(INSTALLED_CACHEIMAGE_TARGET) \ 825 $(INSTALLED_VENDORIMAGE_TARGET) \ 826 $(INSTALLED_FILES_FILE) 827 828# dist_files only for putting your library into the dist directory with a full build. 829.PHONY: dist_files 830 831ifneq ($(TARGET_BUILD_APPS),) 832 # If this build is just for apps, only build apps and not the full system by default. 833 834 unbundled_build_modules := 835 ifneq ($(filter all,$(TARGET_BUILD_APPS)),) 836 # If they used the magic goal "all" then build all apps in the source tree. 837 unbundled_build_modules := $(foreach m,$(sort $(ALL_MODULES)),$(if $(filter APPS,$(ALL_MODULES.$(m).CLASS)),$(m))) 838 else 839 unbundled_build_modules := $(TARGET_BUILD_APPS) 840 endif 841 842 # Dist the installed files if they exist. 843 apps_only_installed_files := $(foreach m,$(unbundled_build_modules),$(ALL_MODULES.$(m).INSTALLED)) 844 $(call dist-for-goals,apps_only, $(apps_only_installed_files)) 845 # For uninstallable modules such as static Java library, we have to dist the built file, 846 # as <module_name>.<suffix> 847 apps_only_dist_built_files := $(foreach m,$(unbundled_build_modules),$(if $(ALL_MODULES.$(m).INSTALLED),,\ 848 $(if $(ALL_MODULES.$(m).BUILT),$(ALL_MODULES.$(m).BUILT):$(m)$(suffix $(ALL_MODULES.$(m).BUILT))))) 849 $(call dist-for-goals,apps_only, $(apps_only_dist_built_files)) 850 851 ifeq ($(EMMA_INSTRUMENT),true) 852 $(EMMA_META_ZIP) : $(apps_only_installed_files) 853 854 $(call dist-for-goals,apps_only, $(EMMA_META_ZIP)) 855 endif 856 857 $(PROGUARD_DICT_ZIP) : $(apps_only_installed_files) 858 $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP)) 859 860.PHONY: apps_only 861apps_only: $(unbundled_build_modules) 862 863droid: apps_only 864 865# Combine the NOTICE files for a apps_only build 866$(eval $(call combine-notice-files, \ 867 $(target_notice_file_txt), \ 868 $(target_notice_file_html), \ 869 "Notices for files for apps:", \ 870 $(TARGET_OUT_NOTICE_FILES), \ 871 $(apps_only_installed_files))) 872 873 874else # TARGET_BUILD_APPS 875 $(call dist-for-goals, droidcore, \ 876 $(INTERNAL_UPDATE_PACKAGE_TARGET) \ 877 $(INTERNAL_OTA_PACKAGE_TARGET) \ 878 $(SYMBOLS_ZIP) \ 879 $(INSTALLED_FILES_FILE) \ 880 $(INSTALLED_BUILD_PROP_TARGET) \ 881 $(BUILT_TARGET_FILES_PACKAGE) \ 882 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 883 $(INSTALLED_RAMDISK_TARGET) \ 884 $(INSTALLED_FACTORY_RAMDISK_TARGET) \ 885 $(INSTALLED_FACTORY_BUNDLE_TARGET) \ 886 ) 887 888 # Put a copy of the radio/bootloader files in the dist dir. 889 $(foreach f,$(INSTALLED_RADIOIMAGE_TARGET), \ 890 $(call dist-for-goals, droidcore, $(f))) 891 892 ifneq ($(TARGET_BUILD_PDK),true) 893 $(call dist-for-goals, droidcore, \ 894 $(APPS_ZIP) \ 895 $(INTERNAL_EMULATOR_PACKAGE_TARGET) \ 896 $(PACKAGE_STATS_FILE) \ 897 ) 898 endif 899 900 ifeq ($(EMMA_INSTRUMENT),true) 901 $(EMMA_META_ZIP) : $(INSTALLED_SYSTEMIMAGE) 902 903 $(call dist-for-goals, dist_files, $(EMMA_META_ZIP)) 904 endif 905 906# Building a full system-- the default is to build droidcore 907droid: droidcore dist_files 908 909endif # TARGET_BUILD_APPS 910 911.PHONY: docs 912docs: $(ALL_DOCS) 913 914.PHONY: sdk 915ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET) 916sdk: $(ALL_SDK_TARGETS) 917$(call dist-for-goals,sdk win_sdk, \ 918 $(ALL_SDK_TARGETS) \ 919 $(SYMBOLS_ZIP) \ 920 $(INSTALLED_BUILD_PROP_TARGET) \ 921) 922 923# umbrella targets to assit engineers in verifying builds 924.PHONY: java native target host java-host java-target native-host native-target \ 925 java-host-tests java-target-tests native-host-tests native-target-tests \ 926 java-tests native-tests host-tests target-tests 927# some synonyms 928.PHONY: host-java target-java host-native target-native \ 929 target-java-tests target-native-tests 930host-java : java-host 931target-java : java-target 932host-native : native-host 933target-native : native-target 934target-java-tests : java-target-tests 935target-native-tests : native-target-tests 936 937 938.PHONY: lintall 939 940.PHONY: samplecode 941sample_MODULES := $(sort $(call get-tagged-modules,samples)) 942sample_APKS_DEST_PATH := $(TARGET_COMMON_OUT_ROOT)/samples 943sample_APKS_COLLECTION := \ 944 $(foreach module,$(sample_MODULES),$(sample_APKS_DEST_PATH)/$(notdir $(module))) 945$(foreach module,$(sample_MODULES),$(eval $(call \ 946 copy-one-file,$(module),$(sample_APKS_DEST_PATH)/$(notdir $(module))))) 947sample_ADDITIONAL_INSTALLED := \ 948 $(filter-out $(modules_to_install) $(modules_to_check) $(ALL_PREBUILT),$(sample_MODULES)) 949samplecode: $(sample_APKS_COLLECTION) 950 @echo "Collect sample code apks: $^" 951 # remove apks that are not intended to be installed. 952 rm -f $(sample_ADDITIONAL_INSTALLED) 953 954.PHONY: findbugs 955findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET) 956 957.PHONY: clean 958clean: 959 @rm -rf $(OUT_DIR) 960 @echo "Entire build directory removed." 961 962.PHONY: clobber 963clobber: clean 964 965# The rules for dataclean and installclean are defined in cleanbuild.mk. 966 967#xxx scrape this from ALL_MODULE_NAME_TAGS 968.PHONY: modules 969modules: 970 @echo "Available sub-modules:" 971 @echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \ 972 tr -s ' ' '\n' | sort -u | $(COLUMN) 973 974.PHONY: showcommands 975showcommands: 976 @echo >/dev/null 977 978.PHONY: nothing 979nothing: 980 @echo Successfully read the makefiles. 981