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