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