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