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