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