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