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